summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2014-11-06 17:45:10 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2014-11-06 17:45:10 -0800
commit8e894b70a808ab91c183507b41e2bc5118078d6a (patch)
treeb944d315951e7fe4684ba8367a1a8bbcf63eff79
parent9e318853b2dca4c145d744b8b486684d93078724 (diff)
parenta1eb49cd9cfa7b1d93fffb1846ba43439f55e567 (diff)
downloadOMA-DM-master.tar.gz
Merge remote-tracking branch 'goog/stage-aosp-master' into HEADHEADmaster
-rw-r--r--Android.mk2
-rw-r--r--DMService/Android.mk50
-rw-r--r--DMService/AndroidManifest.xml194
-rw-r--r--DMService/assets/dm/dmt_data/acl.dat5
-rw-r--r--DMService/assets/dm/dmt_data/acl.txt2
-rw-r--r--DMService/assets/dm/dmt_data/customization.wbxmlbin0 -> 2912 bytes
-rw-r--r--DMService/assets/dm/dmt_data/customization.xml1191
-rw-r--r--DMService/assets/dm/dmt_data/devdetail_ext.wbxmlbin0 -> 124 bytes
-rw-r--r--DMService/assets/dm/dmt_data/devdetail_ext.xml45
-rw-r--r--DMService/assets/dm/dmt_data/devdetail_uri.wbxmlbin0 -> 179 bytes
-rw-r--r--DMService/assets/dm/dmt_data/devdetail_uri.xml60
-rw-r--r--DMService/assets/dm/dmt_data/fstab13
-rw-r--r--DMService/assets/dm/dmt_data/managedobjects.wbxmlbin0 -> 51 bytes
-rw-r--r--DMService/assets/dm/dmt_data/managedobjects.xml21
-rw-r--r--DMService/assets/dm/dmt_data/root.bmdfbin0 -> 6314 bytes
-rw-r--r--DMService/assets/dm/dmt_data/root.mdf1099
-rw-r--r--DMService/assets/dm/dmt_data/root.wbxmlbin0 -> 858 bytes
-rw-r--r--DMService/assets/dm/dmt_data/root.xml313
-rw-r--r--DMService/assets/dm/dmt_data/subscriber.wbxmlbin0 -> 394 bytes
-rw-r--r--DMService/assets/dm/dmt_data/subscriber.xml145
-rw-r--r--DMService/assets/dm/dmt_data/syncmldm.ddf5720
-rw-r--r--DMService/assets/dm/plugin/sysplugins.ini101
-rw-r--r--DMService/proguard.flags73
-rw-r--r--DMService/res/drawable/alert_dialog_icon.pngbin0 -> 1034 bytes
-rw-r--r--DMService/res/layout/textinput_dialog.xml11
-rw-r--r--DMService/res/values-ar/strings.xml20
-rw-r--r--DMService/res/values-bg/strings.xml20
-rw-r--r--DMService/res/values-ca/strings.xml20
-rw-r--r--DMService/res/values-cs/strings.xml20
-rw-r--r--DMService/res/values-da/strings.xml20
-rw-r--r--DMService/res/values-de/strings.xml20
-rw-r--r--DMService/res/values-el/strings.xml20
-rw-r--r--DMService/res/values-en-rGB/strings.xml20
-rw-r--r--DMService/res/values-es-rUS/strings.xml20
-rw-r--r--DMService/res/values-es/strings.xml20
-rw-r--r--DMService/res/values-fi/strings.xml20
-rw-r--r--DMService/res/values-fr/strings.xml20
-rw-r--r--DMService/res/values-hr/strings.xml20
-rw-r--r--DMService/res/values-hu/strings.xml20
-rw-r--r--DMService/res/values-it/strings.xml20
-rw-r--r--DMService/res/values-iw/strings.xml20
-rw-r--r--DMService/res/values-ja/strings.xml20
-rw-r--r--DMService/res/values-ko/strings.xml20
-rw-r--r--DMService/res/values-lt/strings.xml20
-rw-r--r--DMService/res/values-lv/strings.xml20
-rw-r--r--DMService/res/values-nb/strings.xml20
-rw-r--r--DMService/res/values-nl/strings.xml20
-rw-r--r--DMService/res/values-pl/strings.xml20
-rw-r--r--DMService/res/values-pt-rPT/strings.xml20
-rw-r--r--DMService/res/values-pt/strings.xml20
-rw-r--r--DMService/res/values-ro/strings.xml20
-rw-r--r--DMService/res/values-ru/strings.xml20
-rw-r--r--DMService/res/values-sk/strings.xml20
-rw-r--r--DMService/res/values-sl/strings.xml20
-rw-r--r--DMService/res/values-sr/strings.xml20
-rw-r--r--DMService/res/values-sv/strings.xml20
-rw-r--r--DMService/res/values-th/strings.xml20
-rw-r--r--DMService/res/values-tr/strings.xml20
-rw-r--r--DMService/res/values-uk/strings.xml20
-rw-r--r--DMService/res/values-vi/strings.xml20
-rw-r--r--DMService/res/values-zh-rCN/strings.xml20
-rw-r--r--DMService/res/values-zh-rTW/strings.xml20
-rw-r--r--DMService/res/values/dmAccounts.xml6
-rw-r--r--DMService/res/values/strings.xml24
-rw-r--r--DMService/res/xml/initial_dmt.xml49
-rw-r--r--DMService/src/com/android/omadm/service/DMAlert.java552
-rw-r--r--DMService/src/com/android/omadm/service/DMAlertActivity.java527
-rw-r--r--DMService/src/com/android/omadm/service/DMClientService.java673
-rwxr-xr-xDMService/src/com/android/omadm/service/DMConfigureDB.java834
-rw-r--r--DMService/src/com/android/omadm/service/DMDataConnectionService.java224
-rw-r--r--DMService/src/com/android/omadm/service/DMDatabaseTable.java218
-rw-r--r--DMService/src/com/android/omadm/service/DMDialog.java165
-rw-r--r--DMService/src/com/android/omadm/service/DMHelper.java383
-rw-r--r--DMService/src/com/android/omadm/service/DMHttpConnector.java408
-rw-r--r--DMService/src/com/android/omadm/service/DMInjectPackageReceiver.java40
-rw-r--r--DMService/src/com/android/omadm/service/DMIntent.java136
-rw-r--r--DMService/src/com/android/omadm/service/DMIntentReceiver.java1070
-rw-r--r--DMService/src/com/android/omadm/service/DMPkg0Notification.java121
-rw-r--r--DMService/src/com/android/omadm/service/DMResult.java91
-rw-r--r--DMService/src/com/android/omadm/service/DMSession.java309
-rw-r--r--DMService/src/com/android/omadm/service/DMSessionConfirmAlertActivity.java134
-rw-r--r--DMService/src/com/android/omadm/service/DMSettingsHelper.java45
-rw-r--r--DMService/src/com/android/omadm/service/DMWapPushReceiver.java42
-rw-r--r--DMService/src/com/android/omadm/service/FotaNotifyContext.java34
-rw-r--r--DMService/src/com/android/omadm/service/NativeDM.java230
-rw-r--r--DMService/src/com/android/omadm/service/package-info.java21
-rw-r--r--DMService/src/net/jcip/annotations/GuardedBy.java54
-rw-r--r--DMService/src/net/jcip/annotations/Immutable.java35
-rw-r--r--DMService/src/net/jcip/annotations/NotThreadSafe.java26
-rw-r--r--DMService/src/net/jcip/annotations/ThreadSafe.java27
-rw-r--r--DMService/src/net/jcip/annotations/package.html66
-rw-r--r--config/com.android.omadm.service.xml4
-rw-r--r--engine/Android.mk170
-rw-r--r--engine/dmlib/api/common/dmtDefs.h214
-rw-r--r--engine/dmlib/api/common/dmtError.h162
-rw-r--r--engine/dmlib/api/native/dmVersion.h42
-rw-r--r--engine/dmlib/api/native/dmstring.h437
-rw-r--r--engine/dmlib/api/native/dmt.hpp50
-rw-r--r--engine/dmlib/api/native/dmtAcl.hpp181
-rw-r--r--engine/dmlib/api/native/dmtAttributes.hpp327
-rw-r--r--engine/dmlib/api/native/dmtData.hpp516
-rw-r--r--engine/dmlib/api/native/dmtDataChunk.hpp190
-rw-r--r--engine/dmlib/api/native/dmtEvent.hpp214
-rw-r--r--engine/dmlib/api/native/dmtEventData.hpp166
-rw-r--r--engine/dmlib/api/native/dmtFirmAlert.hpp299
-rw-r--r--engine/dmlib/api/native/dmtNode.hpp920
-rw-r--r--engine/dmlib/api/native/dmtNotification.hpp222
-rw-r--r--engine/dmlib/api/native/dmtOverview.h116
-rw-r--r--engine/dmlib/api/native/dmtPrincipal.hpp108
-rw-r--r--engine/dmlib/api/native/dmtSessionProp.hpp273
-rw-r--r--engine/dmlib/api/native/dmtTree.hpp498
-rw-r--r--engine/dmlib/api/native/dmtTreeFactory.hpp451
-rw-r--r--engine/dmlib/api/native/dmvector.h953
-rw-r--r--engine/dmlib/api/native/jem_defs.hpp431
-rw-r--r--engine/dmlib/api/native/plugin/dmtCommitPlugin.hpp85
-rw-r--r--engine/dmlib/api/native/plugin/dmtPlugin.hpp1195
-rw-r--r--engine/dmlib/api/native/plugin/dmtPluginOverview.h119
-rw-r--r--engine/dmlib/api/native/plugin/dmtRWPlugin.hpp709
-rw-r--r--engine/dmlib/api/native_async/dmtAsyncAPI.h749
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_Commit_Log.H66
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Archive.H174
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Archiver.H108
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_FileHandle.H143
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Reader.H75
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLArchive.H150
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLReader.H116
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLWriter.H60
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Writer.H57
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/SyncML_Log.H82
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/dmBufferReader.h116
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/dmBufferWriter.h154
-rw-r--r--engine/dmlib/dmengine/dm_persist/hdr/file_manager.h63
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/SyncML_Commit_Log.cc428
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/SyncML_DM_Archive.cc101
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/SyncML_DM_Archiver.cc813
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/SyncML_DM_FileHandle.cc603
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLArchive.cc614
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLReader.cc808
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLWriter.cc299
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/SyncML_Log.cc180
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/dmBufferReader.cc107
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/dmBufferWriter.cc112
-rw-r--r--engine/dmlib/dmengine/dm_persist/src/multiple_file_manager.cc205
-rw-r--r--engine/dmlib/dmengine/dm_security/hdr/GeneratePassword.H74
-rw-r--r--engine/dmlib/dmengine/dm_security/hdr/dm_security.h117
-rw-r--r--engine/dmlib/dmengine/dm_security/src/GeneratePassword.cc532
-rw-r--r--engine/dmlib/dmengine/dm_security/src/dm_security.c754
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_Alert.H93
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_BuildPackage.H350
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_ChoiceAlert.H50
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_ConfirmAlert.H59
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_DisplayAlert.H56
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_MultipleChoiceAlert.H63
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_SingleChoiceAlert.H59
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_TextInputAlert.H64
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/dmBootstrapSession.h57
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/dmClientSrvCreds.h77
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/dmProcessScriptSession.h170
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/dmServerAuthentication.h48
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/dmServerSession.h90
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/dmSession.h96
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/dmSessionDefs.h271
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/dmSessionFactory.h88
-rw-r--r--engine/dmlib/dmengine/dm_ssession/hdr/dm_ua_handlecommand.h100
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_Alert.cc160
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_BuildPackage.cc4646
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_ChoiceAlert.cc63
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_ConfirmAlert.cc73
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_DisplayAlert.cc58
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_MultipleChoiceAlert.cc112
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_SingleChoiceAlert.cc76
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_TextInputAlert.cc143
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/dmBootstrapSession.cc441
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/dmClientSrvCreds.cc629
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/dmProcessScriptSession.cc395
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/dmServerAuthentication.cc342
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/dmServerSession.cc612
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/dmSession.cc278
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/dmSessionFactory.cc146
-rw-r--r--engine/dmlib/dmengine/dm_ssession/src/dm_ua_handlecommand.cc2909
-rw-r--r--engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_class.H663
-rw-r--r--engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_ESN_class.H123
-rw-r--r--engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_interior_node_class.H117
-rw-r--r--engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_leaf_node_class.H105
-rw-r--r--engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_node_class.H232
-rw-r--r--engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_plugin_root_node_class.H173
-rw-r--r--engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_plugin_util.H48
-rw-r--r--engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_typedef.h263
-rw-r--r--engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_util.h56
-rw-r--r--engine/dmlib/dmengine/dm_tnm/src/dm_tree_class_private.cc1770
-rw-r--r--engine/dmlib/dmengine/dm_tnm/src/dm_tree_class_public.cc3988
-rw-r--r--engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_ESN_class.cc658
-rw-r--r--engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_interior_node_class.cc247
-rw-r--r--engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_leaf_node_class.cc260
-rw-r--r--engine/dmlib/dmengine/dm_tnm/src/dm_tree_node_class.cc273
-rw-r--r--engine/dmlib/dmengine/dm_tnm/src/dm_tree_plugin_root_node_class.cc874
-rw-r--r--engine/dmlib/dmengine/dm_tnm/src/dm_tree_plugin_util.cc450
-rw-r--r--engine/dmlib/dmengine/dm_tnm/src/dm_tree_util.cc409
-rw-r--r--engine/dmlib/dmengine/dm_transport/hdr/DM_DmConnRef.h401
-rw-r--r--engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_connection.H249
-rw-r--r--engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_connection.H.contrib208
-rw-r--r--engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_utils.h56
-rw-r--r--engine/dmlib/dmengine/dm_transport/src/dm_tpt_connection.cc958
-rw-r--r--engine/dmlib/dmengine/dm_transport/src/dm_tpt_utils.c166
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/SYNCML_DM_TreeMount.H67
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmACLItem.h129
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmACLManager.h117
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmConfigItem.h141
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmConfigManager.h236
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmConstraints.h211
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmEvent.h223
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmEventLogger.h467
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmEventSubscription.h104
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmLock.h302
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmLockCtxMgr.h285
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmLockingHelper.h179
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataBuffer.h168
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataManager.h766
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataNode.h301
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmSubscriptionItem.h124
-rw-r--r--engine/dmlib/dmengine/dm_ua/hdr/dmSubscriptionManager.h343
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/SYNCML_DM_TreeMount.cc227
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmACLItem.cc194
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmACLManager.cc154
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmConfigItem.cc92
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmConfigManager.cc516
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmConstraints.cc226
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmEvent.cc159
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmEventLogger.cc1055
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmEventSubscription.cc185
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmLock.cc479
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmLockCtxMgr.cc615
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmLockingHelper.cc125
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmMetaDataBuffer.cc106
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmMetaDataManager.cc2037
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmMetaDataNode.cc272
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmSessionApi.cc175
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmSubscriptionItem.cc253
-rw-r--r--engine/dmlib/dmengine/dm_ua/src/dmSubscriptionManager.cc584
-rw-r--r--engine/dmlib/dmengine/dm_util/hdr/dm_uri_utils.h112
-rw-r--r--engine/dmlib/dmengine/dm_util/hdr/dmbuffer.h84
-rw-r--r--engine/dmlib/dmengine/dm_util/hdr/dmdefs.h16
-rw-r--r--engine/dmlib/dmengine/dm_util/hdr/dmtoken.h271
-rw-r--r--engine/dmlib/dmengine/dm_util/hdr/syncml_dm_data_types.h339
-rw-r--r--engine/dmlib/dmengine/dm_util/src/dm_uri_utils.cc242
-rw-r--r--engine/dmlib/dmengine/dm_util/src/dmbuffer.cc208
-rw-r--r--engine/dmlib/dmengine/dm_util/src/dmtoken.cc334
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/define.h164
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/libmem.h99
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/libstr.h111
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/libutil.h88
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/md5.h61
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/mgr.h187
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/mgrutil.h186
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/sml.h335
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/smldef.h232
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/smldevinfdtd.h171
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/smldmtnddtd.h98
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/smldtd.h421
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/smlerr.h136
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/smlmetinfdtd.h98
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/wsm.h427
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/wsm_sm.h290
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/xltdec.h240
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/xltenc.h201
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/xpt-b64.h169
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/xptdef.h93
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/xptport.h183
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/hdr/xpttypes.h80
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/ghdr/define.h164
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/ghdr/sml.h346
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldef.h232
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldevinfdtd.h171
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldmtnddtd.h99
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldtd.h421
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smlerr.h136
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smlmetinfdtd.h98
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/liblock.h16
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libmem.h99
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libstr.h111
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libutil.h88
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libmem.c175
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libstr.c138
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libutil.c184
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/mgr/hdr/mgr.h187
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/mgr/hdr/mgrutil.h186
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgr.c306
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrcmdbuilder.c901
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrcmddispatcher.c504
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrinstancelist.c233
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrinstancemgr.c1080
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrutil.c1694
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/wsm/hdr/wsm.h427
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/wsm/hdr/wsm_sm.h290
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/wsm/src/wsm.c1612
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/wsm/src/wsm_sm.c510
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/hdr/xltdec.h240
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/hdr/xltenc.h201
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdec.c2203
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdeccom.h241
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecwbxml.c1483
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecwbxml.h59
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecxml.c1370
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdevinf.c987
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdevinf.h75
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdmtnd.c755
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdmtnd.h41
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenc.c1502
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenccom.c106
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenccom.h132
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencwbxml.c311
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencwbxml.h181
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencxml.c170
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencxml.h102
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltmetinf.c354
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltmetinf.h69
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttags.c780
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttags.h376
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttagtbl.h116
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltutilstack.c205
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltutilstack.h174
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/md5.h51
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xpt-b64.h169
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xptdef.h93
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xptport.h183
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xpttypes.h80
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xpt/src/md5c.c299
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/sml/xpt/src/xpt-b64.c365
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/libmem.c175
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/libstr.c138
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/libutil.c206
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/md5c.c299
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/mgr.c306
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/mgrcmdbuilder.c901
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/mgrcmddispatcher.c504
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/mgrinstancelist.c233
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/mgrinstancemgr.c1080
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/mgrutil.c1694
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/wsm.c1612
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/wsm_sm.c510
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltdec.c2205
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltdecwbxml.c1516
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltdecxml.c1370
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltdevinf.c991
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltdmtnd.c869
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltenc.c1502
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltenccom.c106
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltencwbxml.c311
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltencxml.c170
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltmetinf.c354
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xlttags.c779
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xltutilstack.c205
-rw-r--r--engine/dmlib/dmengine/oma_toolkit/src/xpt-b64.c365
-rw-r--r--engine/dmlib/dmt-tools/DMTConv97
-rw-r--r--engine/dmlib/dmt-tools/DMTDiff90
-rw-r--r--engine/dmlib/dmt-tools/README49
-rw-r--r--engine/dmlib/dmt-tools/ReleaseNotes56
-rw-r--r--engine/dmlib/dmt-tools/convertMDF112
-rw-r--r--engine/dmlib/dmt-tools/generateDMT327
-rw-r--r--engine/dmlib/dmt-tools/lib/DMTTest.jarbin0 -> 9785 bytes
-rw-r--r--engine/dmlib/dmt-tools/lib/GenTool.jarbin0 -> 65056 bytes
-rw-r--r--engine/dmlib/dmt-tools/lib/jakarta-regexp-1.4.jarbin0 -> 28576 bytes
-rw-r--r--engine/dmlib/dmt-tools/lib/joda-time-1.1.jarbin0 -> 512337 bytes
-rw-r--r--engine/dmlib/dmt-tools/runDMTTest161
-rw-r--r--engine/dmlib/dmtapi/native/hdr/dmtNodeImpl.hpp98
-rw-r--r--engine/dmlib/dmtapi/native/hdr/dmtTreeImpl.hpp107
-rw-r--r--engine/dmlib/dmtapi/native/src/dmVersion.cc49
-rw-r--r--engine/dmlib/dmtapi/native/src/dmstring.cc349
-rw-r--r--engine/dmlib/dmtapi/native/src/dmt.cc529
-rw-r--r--engine/dmlib/dmtapi/native/src/dmtAcl.cc140
-rw-r--r--engine/dmlib/dmtapi/native/src/dmtAttributes.cc147
-rw-r--r--engine/dmlib/dmtapi/native/src/dmtData.cc408
-rw-r--r--engine/dmlib/dmtapi/native/src/dmtDataChunk.cc261
-rw-r--r--engine/dmlib/dmtapi/native/src/dmtEvent.cc33
-rw-r--r--engine/dmlib/dmtapi/native/src/dmtEventSubscription.cc80
-rw-r--r--engine/dmlib/dmtapi/native/src/dmtNode.cc473
-rw-r--r--engine/dmlib/dmtapi/native/src/dmtSessionProp.cc19
-rw-r--r--engine/dmlib/dmtapi/native/src/dmtTree.cc811
-rw-r--r--engine/dmlib/dmtapi/native_async/hdr/dmtAsyncData.h345
-rw-r--r--engine/dmlib/dmtapi/native_async/hdr/dmtAsyncMessage.h167
-rw-r--r--engine/dmlib/dmtapi/native_async/src/dmtAsyncAPI.cc2712
-rw-r--r--engine/dmlib/dmtapi/native_async/src/dmtAsyncData.cc577
-rw-r--r--engine/dmlib/linux_java/buildscripts/createPackage244
-rw-r--r--engine/dmlib/linux_java/buildscripts/release_version.txt1
-rw-r--r--engine/dmlib/linux_java/mkfiles/GenericMake200
-rw-r--r--engine/dmlib/linux_java/mkfiles/dm_make.a2so36
-rw-r--r--engine/dmlib/linux_java/mkfiles/dm_make.con38
-rw-r--r--engine/dmlib/linux_java/mkfiles/dm_make.native73
-rw-r--r--engine/dmlib/linux_java/mkfiles/dm_make.poccommit0
-rw-r--r--engine/dmlib/linux_java/mkfiles/dm_make.pocconstraint0
-rw-r--r--engine/dmlib/linux_java/mkfiles/dm_make.ssession70
-rw-r--r--engine/dmlib/linux_java/mkfiles/dm_make.xpl59
-rw-r--r--engine/dmlib/linux_java/mkfiles/versionsc_ssesion14
-rw-r--r--engine/dmlib/linux_java/mkfiles/versionscr_plugin7
-rw-r--r--engine/dmlib/linux_java/mkfiles/versionscript101
-rw-r--r--engine/dmlib/linux_java/samples/compile62
-rw-r--r--engine/dmlib/linux_java/samples/conui/hdr/dmSocketConnector.h116
-rw-r--r--engine/dmlib/linux_java/samples/conui/src/dmSocketConnector.cc577
-rw-r--r--engine/dmlib/linux_java/samples/conui/src/xpl_HTTP.cc223
-rw-r--r--engine/dmlib/linux_java/samples/conui/src/xpl_dm_ServerAlerts.cc52
-rw-r--r--engine/dmlib/linux_java/samples/ddd_test18
-rw-r--r--engine/dmlib/linux_java/samples/plugins/mandatoryconstplugin/src/plugin_dll_mandatory_constraint.cc121
-rw-r--r--engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.mandatoryconstplugin32
-rw-r--r--engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testconstplugin33
-rw-r--r--engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testdataplugin33
-rw-r--r--engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testexecplugin33
-rw-r--r--engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testrwplugin60
-rw-r--r--engine/dmlib/linux_java/samples/plugins/settings/sysplugins.ini31
-rw-r--r--engine/dmlib/linux_java/samples/plugins/settings/testplugins.ini43
-rw-r--r--engine/dmlib/linux_java/samples/plugins/settings/testrwplugin.ini6
-rw-r--r--engine/dmlib/linux_java/samples/plugins/testcommitplugin/src/plugin_dll_test_commit.cc88
-rw-r--r--engine/dmlib/linux_java/samples/plugins/testconstplugin/src/plugin_dll_test_constraint.cc110
-rw-r--r--engine/dmlib/linux_java/samples/plugins/testdataplugin/src/plugin_dll_test_data.cc169
-rw-r--r--engine/dmlib/linux_java/samples/plugins/testexecplugin/src/plugin_dll_test_exec.cc86
-rw-r--r--engine/dmlib/linux_java/samples/plugins/testrwplugin/src/test_rwplugin.cc615
-rw-r--r--engine/dmlib/linux_java/samples/portlib/src/xpl_Logger.cc72
-rw-r--r--engine/dmlib/linux_java/samples/portlib/src/xpl_dm_Notifications.cc43
-rw-r--r--engine/dmlib/linux_java/samples/run_test18
-rw-r--r--engine/dmlib/linux_java/samples/settings/Dmt.zipbin0 -> 45118 bytes
-rw-r--r--engine/dmlib/linux_java/samples/settings/fstab10
-rw-r--r--engine/dmlib/linux_java/samples/socketCon/compilePortlib17
-rw-r--r--engine/dmlib/linux_java/samples/socketCon/src/port_layer.cc70
-rw-r--r--engine/dmlib/linux_java/samples/unittest/src/dmt_stress.cc201
-rw-r--r--engine/dmlib/linux_java/samples/unittest/src/dmt_test.cc1961
-rw-r--r--engine/dmlib/linux_java/test/dm11/testadd.wbxmlbin0 -> 385 bytes
-rw-r--r--engine/dmlib/linux_java/test/dm11/testalertconfirm.xml32
-rw-r--r--engine/dmlib/linux_java/test/dm11/testalertconfirmatomic.xml48
-rw-r--r--engine/dmlib/linux_java/test/dm11/testalertdisplay.xml29
-rw-r--r--engine/dmlib/linux_java/test/dm11/testalertmultiplechoice.xml47
-rw-r--r--engine/dmlib/linux_java/test/dm11/testalertsinglechoice.xml47
-rw-r--r--engine/dmlib/linux_java/test/dm11/testalerttextinput.xml29
-rw-r--r--engine/dmlib/linux_java/test/dm11/testdelete.wbxmlbin0 -> 395 bytes
-rw-r--r--engine/dmlib/linux_java/test/dm11/testexecscript.xml30
-rw-r--r--engine/dmlib/linux_java/test/dm11/testexecscript2.xml30
-rw-r--r--engine/dmlib/linux_java/test/dm11/testget.wbxmlbin0 -> 380 bytes
-rw-r--r--engine/dmlib/linux_java/test/dm11/testgetscript.xml29
-rw-r--r--engine/dmlib/linux_java/test/dm11/testinput11280
-rw-r--r--engine/dmlib/linux_java/test/dm11/testlobdata1.dat1
-rw-r--r--engine/dmlib/linux_java/test/dm11/testlobdata2.dat1
-rw-r--r--engine/dmlib/linux_java/test/dm11/testoutput111741
-rw-r--r--engine/dmlib/linux_java/test/dm11/testreplace.wbxmlbin0 -> 662 bytes
-rw-r--r--engine/dmlib/linux_java/test/dm12/testadd.wbxmlbin0 -> 445 bytes
-rw-r--r--engine/dmlib/linux_java/test/dm12/testalertconfirm.xml32
-rw-r--r--engine/dmlib/linux_java/test/dm12/testalertconfirmatomic.xml48
-rw-r--r--engine/dmlib/linux_java/test/dm12/testalertdisplay.xml29
-rw-r--r--engine/dmlib/linux_java/test/dm12/testalertmultiplechoice.xml47
-rw-r--r--engine/dmlib/linux_java/test/dm12/testalertsinglechoice.xml47
-rw-r--r--engine/dmlib/linux_java/test/dm12/testalerttextinput.xml29
-rw-r--r--engine/dmlib/linux_java/test/dm12/testdelete.wbxmlbin0 -> 452 bytes
-rw-r--r--engine/dmlib/linux_java/test/dm12/testexecscript.xml30
-rw-r--r--engine/dmlib/linux_java/test/dm12/testexecscript2.xml30
-rw-r--r--engine/dmlib/linux_java/test/dm12/testget.wbxmlbin0 -> 437 bytes
-rw-r--r--engine/dmlib/linux_java/test/dm12/testgetscript.xml29
-rw-r--r--engine/dmlib/linux_java/test/dm12/testinput12511
-rw-r--r--engine/dmlib/linux_java/test/dm12/testlobdata1.dat1
-rw-r--r--engine/dmlib/linux_java/test/dm12/testlobdata2.dat1
-rw-r--r--engine/dmlib/linux_java/test/dm12/testnewdatatype.xml165
-rw-r--r--engine/dmlib/linux_java/test/dm12/testoutput123360
-rw-r--r--engine/dmlib/linux_java/test/dm12/testreplace.wbxmlbin0 -> 565 bytes
-rw-r--r--engine/dmlib/notification_agent/hdr/dmNotification.h34
-rw-r--r--engine/dmlib/notification_agent/src/dmNotification.cc147
-rw-r--r--engine/dmlib/plugin/hdr/SyncML_PlugIn_Log.H86
-rw-r--r--engine/dmlib/plugin/hdr/SyncML_PlugIn_WBXMLLog.H89
-rw-r--r--engine/dmlib/plugin/hdr/dmPlugin.h254
-rw-r--r--engine/dmlib/plugin/hdr/dmPluginManager.h288
-rw-r--r--engine/dmlib/plugin/src/SyncML_PlugIn_Log.cc74
-rw-r--r--engine/dmlib/plugin/src/SyncML_PlugIn_WBXMLLog.cc976
-rw-r--r--engine/dmlib/plugin/src/dmPlugin.cc218
-rw-r--r--engine/dmlib/plugin/src/dmPluginManager.cc758
-rw-r--r--engine/dmlib/plugin/src/dmtPlugin.cc715
-rw-r--r--engine/dmlib/plugin/src/dmtRWPlugin.cc1334
-rw-r--r--engine/dmlib/portlib/generic/dmAsyncMessageID.h77
-rw-r--r--engine/dmlib/portlib/generic/dmMemory.h43
-rw-r--r--engine/dmlib/portlib/generic/xpl_dm_Manager.h75
-rw-r--r--engine/dmlib/portlib/generic/xpl_dm_Notifications.h47
-rw-r--r--engine/dmlib/portlib/generic/xpl_dm_ServerAlert.h148
-rw-r--r--engine/dmlib/portlib/generic/xpl_dm_ServerAlertDef.h56
-rw-r--r--engine/dmlib/portlib/lj/hdr/dmAllocatedPointersPool.h125
-rw-r--r--engine/dmlib/portlib/lj/hdr/dmStringUtil.h55
-rw-r--r--engine/dmlib/portlib/lj/hdr/dmThreadHelper.h196
-rw-r--r--engine/dmlib/portlib/lj/hdr/dmThreadQueue.h171
-rw-r--r--engine/dmlib/portlib/lj/hdr/dmprofile.h200
-rw-r--r--engine/dmlib/portlib/lj/src/dmAllocatedPointersPool.cc63
-rw-r--r--engine/dmlib/portlib/lj/src/dmMemory.cc223
-rw-r--r--engine/dmlib/portlib/lj/src/dmThreadHelper.cc69
-rw-r--r--engine/dmlib/portlib/lj/src/dmThreadQueue.cc143
-rw-r--r--engine/dmlib/portlib/lj/src/dmprofile.cc452
-rw-r--r--engine/dmlib/portlib/lj/src/xpl_Alert.cc67
-rw-r--r--engine/dmlib/portlib/lj/src/xpl_File.cc477
-rw-r--r--engine/dmlib/portlib/lj/src/xpl_HTTP.cc181
-rw-r--r--engine/dmlib/portlib/lj/src/xpl_Lib.cc66
-rw-r--r--engine/dmlib/portlib/lj/src/xpl_Memory.cc31
-rw-r--r--engine/dmlib/portlib/lj/src/xpl_Regex.cc31
-rw-r--r--engine/dmlib/portlib/lj/src/xpl_Time.cc89
-rw-r--r--engine/dmlib/portlib/lj/src/xpl_dm_Manager.cc178
-rw-r--r--engine/dmlib/portlib/lj/test/port_layer.cc63
-rw-r--r--engine/dmlib/tool-src/bmdf_reader/reader.cpp375
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/BlockTable.java22
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Browser.java187
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/ByteArray.java34
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Const.java138
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/DBDumper.java174
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Generator.java493
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Helper.java52
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/IM.java234
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/JavaApp.java178
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/MMS.java176
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/OMACP.java434
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Record.java95
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Util.java451
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/ValTab.java6
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Validator.java687
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Value.java29
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/WbxmlEncoder.java177
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Worker.java901
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/compileDBProvTool42
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/generateDBProv114
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/lib/DBProvTool.jarbin0 -> 50383 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/BROWSER.xml57
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/IM.xml81
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/JAVA.xml25
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/MMS.xml53
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/browser.csv9
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/browser_template.xlsbin0 -> 45056 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/im.csv7
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/im_template.xlsbin0 -> 52736 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/java.csv9
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/java_template.xlsbin0 -> 43008 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/mms.csv9
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/mms.txtbin0 -> 1180 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/mms_template.xlsbin0 -> 45056 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/samples/mms_unicode_template.xlsbin0 -> 39424 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/templates/browser_template.xlsbin0 -> 38912 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/templates/im_template.xlsbin0 -> 44544 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/templates/java_template.xlsbin0 -> 37376 bytes
-rw-r--r--engine/dmlib/tool-src/db_wizard_tool/templates/mms_template.xlsbin0 -> 38400 bytes
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/DMTValidator.java1438
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/FactBootEnc.java180
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/Gen.java2992
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/Xml2WBXml.java514
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/FNode.java106
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/FNodeLoader.java55
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/Node.java38
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/NodeLoader.java65
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/DMTS.java288
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/DMTSTool.java137
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Diff.java291
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Util.java152
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Zip.java174
-rw-r--r--engine/dmlib/tool-src/dmt_gen_tool/compileTool38
-rw-r--r--engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Access.java12
-rw-r--r--engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Content.java6
-rw-r--r--engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Node.java15
-rw-r--r--engine/dmlib/tool-src/dmt_validate/com/mot/treetest/TreeTest.java491
-rw-r--r--engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Util.java193
-rw-r--r--engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Validator.java59
-rw-r--r--engine/dmlib/tool-src/dmt_validate/compileTestTool16
-rw-r--r--engine/dmlib/tool-src/file_convertor/file_convertorbin0 -> 16098 bytes
-rw-r--r--engine/dmlib/tool-src/file_convertor/src/file_convertor.cc350
-rw-r--r--engine/dmlib/tool-src/servercred/Server_Cred_users_guide.txt54
-rw-r--r--engine/dmlib/tool-src/servercred/hdr/DeviceInfo.H37
-rw-r--r--engine/dmlib/tool-src/servercred/hdr/GeneratePassword.H57
-rw-r--r--engine/dmlib/tool-src/servercred/hdr/md5.h51
-rw-r--r--engine/dmlib/tool-src/servercred/hdr/xpt-b64.h169
-rw-r--r--engine/dmlib/tool-src/servercred/hdr/xptdef.h93
-rw-r--r--engine/dmlib/tool-src/servercred/hdr/xptport.h183
-rw-r--r--engine/dmlib/tool-src/servercred/hdr/xpttypes.h80
-rw-r--r--engine/dmlib/tool-src/servercred/src/DeviceInfo.cc168
-rw-r--r--engine/dmlib/tool-src/servercred/src/GeneratePassword.cc568
-rw-r--r--engine/dmlib/tool-src/servercred/src/TestGenPasswd.cc47
-rw-r--r--engine/dmlib/tool-src/servercred/src/main.c398
-rw-r--r--engine/dmlib/tool-src/servercred/src/md5c.c299
-rw-r--r--engine/dmlib/tool-src/servercred/src/xpt-b64.c358
-rw-r--r--engine/dmlib/tool-src/servercred/win32.bat3
-rw-r--r--engine/javaplugin/Android.mk10
-rw-r--r--engine/javaplugin/api/Android.mk21
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/DmtBasePlugin.java122
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/DmtData.aidl19
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/DmtData.java546
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/DmtException.java78
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/DmtManagementObject.java498
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/DmtPathUtils.java163
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/DmtPluginNode.aidl19
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/DmtPluginNode.java123
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/ErrorCodes.java197
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/IDMClientService.aidl67
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/IDmtPlugin.aidl201
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/IDmtRootPlugin.java28
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/IDmtSubTree.java124
-rw-r--r--engine/javaplugin/api/com/android/omadm/plugin/impl/DmtPluginManager.java682
-rw-r--r--engine/javaplugin/nativelib/Android.mk59
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaItem.h76
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaMethod.h71
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaPlugin.cc83
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaPluginCommon.h26
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaPluginManager.cc615
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaPluginManager.h109
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaPluginNode.cc70
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaPluginNode.h43
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaPluginTree.cc275
-rw-r--r--engine/javaplugin/nativelib/src/DmtJavaPluginTree.h61
-rw-r--r--engine/jni/DMServiceAlert.cc397
-rw-r--r--engine/jni/DMServiceAlert.h199
-rw-r--r--engine/jni/DMServiceConnection.cc324
-rw-r--r--engine/jni/DMServiceMain.cc567
-rw-r--r--engine/jni/DMServiceMain.h57
-rwxr-xr-xengine/jni/DMTreeManager.cc575
-rw-r--r--engine/jni/DMTreeManager.h26
-rw-r--r--engine/xpl/hdr/dmAllocatedPointersPool.h116
-rw-r--r--engine/xpl/hdr/dmAsyncMessageID.h72
-rw-r--r--engine/xpl/hdr/dmMemory.h43
-rw-r--r--engine/xpl/hdr/dmNewDataTypesValidation.h35
-rw-r--r--engine/xpl/hdr/dmSocketConnector.h108
-rw-r--r--engine/xpl/hdr/dmStringUtil.h57
-rw-r--r--engine/xpl/hdr/dmThreadHelper.h188
-rw-r--r--engine/xpl/hdr/dmThreadQueue.h171
-rw-r--r--engine/xpl/hdr/dmdefs.h16
-rw-r--r--engine/xpl/hdr/dmprofile.h200
-rw-r--r--engine/xpl/hdr/dmvector.h954
-rw-r--r--engine/xpl/hdr/xpl_File.h191
-rw-r--r--engine/xpl/hdr/xpl_HTTP.h177
-rw-r--r--engine/xpl/hdr/xpl_Lib.h57
-rw-r--r--engine/xpl/hdr/xpl_Logger.h252
-rw-r--r--engine/xpl/hdr/xpl_Memory.h61
-rw-r--r--engine/xpl/hdr/xpl_Message.h57
-rw-r--r--engine/xpl/hdr/xpl_Port.h50
-rw-r--r--engine/xpl/hdr/xpl_Prompt.h44
-rw-r--r--engine/xpl/hdr/xpl_Regex.h46
-rw-r--r--engine/xpl/hdr/xpl_StringUtil.h85
-rw-r--r--engine/xpl/hdr/xpl_Time.h105
-rw-r--r--engine/xpl/hdr/xpl_Types.h114
-rw-r--r--engine/xpl/hdr/xpl_dm_Manager.h76
-rw-r--r--engine/xpl/hdr/xpl_dm_Notifications.h47
-rw-r--r--engine/xpl/hdr/xpl_dm_ServerAlert.h144
-rw-r--r--engine/xpl/hdr/xpl_dm_ServerAlertDef.h56
-rw-r--r--engine/xpl/src/dmAllocatedPointersPool.cc55
-rw-r--r--engine/xpl/src/dmMemory.cc240
-rw-r--r--engine/xpl/src/dmNewDataTypesValidation.cc751
-rw-r--r--engine/xpl/src/dmSocketConnector.cc577
-rw-r--r--engine/xpl/src/dmThreadHelper.cc61
-rw-r--r--engine/xpl/src/dmThreadQueue.cc135
-rw-r--r--engine/xpl/src/dmprofile.cc452
-rw-r--r--engine/xpl/src/xpl_Alert.cc78
-rw-r--r--engine/xpl/src/xpl_File.cc482
-rw-r--r--engine/xpl/src/xpl_HTTP.cc181
-rw-r--r--engine/xpl/src/xpl_HTTP_socket.cc223
-rw-r--r--engine/xpl/src/xpl_Lib.cc66
-rw-r--r--engine/xpl/src/xpl_Logger.cc72
-rw-r--r--engine/xpl/src/xpl_Memory.cc31
-rw-r--r--engine/xpl/src/xpl_Regex.cc91
-rw-r--r--engine/xpl/src/xpl_Time.cc90
-rw-r--r--engine/xpl/src/xpl_dm_Manager.cc179
-rw-r--r--engine/xpl/src/xpl_dm_Notifications.cc43
-rw-r--r--plugins/Android.mk10
-rw-r--r--plugins/devplugin/Android.mk15
-rw-r--r--plugins/devplugin/com/android/omadm/plugin/dev/DevPlugin.java472
-rw-r--r--plugins/devplugin/com/android/omadm/plugin/dev/DevService.java63
-rw-r--r--plugins/diagmon/Android.mk13
-rw-r--r--plugins/diagmon/com/android/omadm/plugin/diagmon/DiagmonPlugin.java296
-rw-r--r--plugins/diagmon/com/android/omadm/plugin/diagmon/DiagmonService.java60
-rw-r--r--plugins/pluginhelper/Android.mk15
-rw-r--r--plugins/pluginhelper/com/android/omadm/pluginhelper/DmtMoBuilder.java221
-rw-r--r--plugins/pluginhelper/com/android/omadm/pluginhelper/DmtPluginFacade.java187
-rw-r--r--plugins/pluginhelper/com/android/omadm/pluginhelper/IDmtPluginAdaptor.java38
-rw-r--r--plugins/testplugin/Android.mk13
-rw-r--r--plugins/testplugin/AndroidManifest.xml42
-rw-r--r--plugins/testplugin/res/layout/get_dm_tree_activity.xml15
-rw-r--r--plugins/testplugin/res/layout/inject_soap_package_activity.xml15
-rw-r--r--plugins/testplugin/res/layout/start_client_session_activity.xml15
-rw-r--r--plugins/testplugin/res/values/dimens.xml6
-rw-r--r--plugins/testplugin/res/values/strings.xml8
-rw-r--r--plugins/testplugin/res/xml/test_menu_settings.xml41
-rw-r--r--plugins/testplugin/src/com/android/example/testplugin/DMTestPluginActivity.java46
-rw-r--r--plugins/testplugin/src/com/android/example/testplugin/GetDMTreeActivity.java125
-rw-r--r--plugins/testplugin/src/com/android/example/testplugin/InjectSoapPackageActivity.java239
-rw-r--r--plugins/testplugin/src/com/android/example/testplugin/StartClientSessionActivity.java99
-rw-r--r--samples/dmAccounts.xml20
-rw-r--r--setting/Dmt.zipbin0 -> 139104 bytes
-rwxr-xr-xsetting/Makefile29
-rwxr-xr-xsetting/README14
-rw-r--r--setting/dmt_data/acl.dat5
-rw-r--r--setting/dmt_data/acl.txt2
-rw-r--r--setting/dmt_data/customization.wbxmlbin0 -> 2912 bytes
-rw-r--r--setting/dmt_data/customization.xml1191
-rw-r--r--setting/dmt_data/devdetail_ext.wbxmlbin0 -> 124 bytes
-rw-r--r--setting/dmt_data/devdetail_ext.xml45
-rw-r--r--setting/dmt_data/devdetail_uri.wbxmlbin0 -> 179 bytes
-rw-r--r--setting/dmt_data/devdetail_uri.xml60
-rw-r--r--setting/dmt_data/docs/desc.html2757
-rw-r--r--setting/dmt_data/docs/index-all.html305
-rw-r--r--setting/dmt_data/docs/index.html12
-rw-r--r--setting/dmt_data/docs/toc.html600
-rw-r--r--setting/dmt_data/fstab13
-rw-r--r--setting/dmt_data/managedobjects.wbxmlbin0 -> 51 bytes
-rw-r--r--setting/dmt_data/managedobjects.xml21
-rw-r--r--setting/dmt_data/root.bmdfbin0 -> 6314 bytes
-rw-r--r--setting/dmt_data/root.mdf1099
-rw-r--r--setting/dmt_data/root.wbxmlbin0 -> 858 bytes
-rw-r--r--setting/dmt_data/root.xml313
-rw-r--r--setting/dmt_data/subscriber.wbxmlbin0 -> 394 bytes
-rw-r--r--setting/dmt_data/subscriber.xml145
-rw-r--r--setting/dmt_data/syncmldm.ddf5720
-rw-r--r--setting/event.dat0
-rw-r--r--setting/fstab13
704 files changed, 191081 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..6361f9b
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,2 @@
+LOCAL_PATH := $(call my-dir)
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/DMService/Android.mk b/DMService/Android.mk
new file mode 100644
index 0000000..8faff94
--- /dev/null
+++ b/DMService/Android.mk
@@ -0,0 +1,50 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := src/com/android/omadm/service/DMIntent.java \
+ src/com/android/omadm/service/DMResult.java \
+ src/com/android/omadm/service/DMSettingsHelper.java \
+ src/com/android/omadm/service/DMDatabaseTable.java \
+
+LOCAL_CERTIFICATE := platform
+LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+LOCAL_MODULE := com.android.omadm.service.api
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+##############################################################################
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := com.android.omadm.service.xml
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/permissions
+LOCAL_SRC_FILES := ../config/com.android.omadm.service.xml
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+# Sign with platform certificate to prevent disabling the app from Settings menu
+LOCAL_PACKAGE_NAME := DMService
+LOCAL_CERTIFICATE := platform
+LOCAL_PRIVILEGED_MODULE := true
+LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+LOCAL_STATIC_JAVA_LIBRARIES := com.android.omadm.plugin \
+ com.android.omadm.plugin.dev \
+ com.android.omadm.pluginhelper \
+ com.android.omadm.plugin.diagmon
+
+LOCAL_JAVA_LIBRARIES := telephony-common
+LOCAL_JNI_SHARED_LIBRARIES := libdmengine libdmjavaplugin
+LOCAL_REQUIRED_MODULES := dmAccounts.xml com.android.omadm.service.xml
+
+LOCAL_MULTILIB := 32
+
+include $(BUILD_PACKAGE)
+
+# Use the following include to make our test apk.
+#include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/DMService/AndroidManifest.xml b/DMService/AndroidManifest.xml
new file mode 100644
index 0000000..d4e888a
--- /dev/null
+++ b/DMService/AndroidManifest.xml
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ android:versionCode="1"
+ android:versionName="1.0.0"
+ package="com.android.omadm.service"
+ android:sharedUserId="com.android.uid.omadm.service">
+
+ <uses-sdk
+ android:minSdkVersion="19"
+ android:targetSdkVersion="19"/>
+
+ <permission
+ android:name="com.android.permission.READ_OMADM_SETTINGS"
+ android:protectionLevel="signatureOrSystem"/>
+ <permission
+ android:name="com.android.permission.WRITE_OMADM_SETTINGS"
+ android:protectionLevel="signatureOrSystem"/>
+ <permission
+ android:name="com.android.permission.INJECT_OMADM_SETTINGS"
+ android:protectionLevel="signatureOrSystem"/>
+
+ <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
+ <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
+ <uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
+ <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
+ <uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>
+ <uses-permission android:name="android.permission.RECEIVE_WAP_PUSH"/>
+ <uses-permission android:name="android.permission.RECEIVE_SMS"/>
+ <uses-permission android:name="android.permission.CALL_PHONE"/>
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
+ <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.WAKE_LOCK"/>
+ <uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/>
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
+ <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
+ <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL"/>
+ <uses-permission android:name="com.android.permission.READ_OMADM_SETTINGS"/>
+ <uses-permission android:name="com.android.permission.WRITE_OMADM_SETTINGS"/>
+
+ <!-- FIXME: remove these permissions if not required. -->
+ <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
+ <uses-permission android:name="com.android.permission.CONNMO_SETTINGS"/>
+ <uses-permission android:name="com.android.permission.INJECT_OMADM_SETTINGS"/>
+
+ <application
+ android:label="@string/app_name"
+ android:allowBackup="false">
+
+ <!-- receives "com.android.omadm.service.Launch" action -->
+ <service
+ android:name=".DMClientService"
+ android:exported="true"
+ android:permission="com.android.permission.WRITE_OMADM_SETTINGS"/>
+
+ <!-- receives "com.android.omadm.plugin.dev.DevPlugin" action -->
+ <service
+ android:name="com.android.omadm.plugin.dev.DevService"
+ android:exported="false">
+ <intent-filter>
+ <action android:name="com.android.omadm.plugin.dev.DevPlugin"/>
+ </intent-filter>
+ </service>
+
+ <service
+ android:name=".DMDataConnectionService"
+ android:exported="false">
+ </service>
+
+ <service
+ android:name="com.android.omadm.plugin.diagmon.DiagmonService"
+ android:exported="false">
+ <intent-filter>
+ <action android:name="com.android.omadm.plugin.diagmon.DiagmonPlugin"/>
+ </intent-filter>
+ </service>
+
+ <!-- receives "com.android.omadm.service.InjectPackage0" action -->
+ <!-- for injecting test Package 0 from the command line -->
+ <receiver
+ android:name=".DMInjectPackageReceiver"
+ android:exported="true"
+ android:permission="com.android.permission.INJECT_OMADM_SETTINGS"/>
+
+ <!-- receives WAP push messages from framework. -->
+ <receiver
+ android:name=".DMWapPushReceiver"
+ android:permission="android.permission.BROADCAST_WAP_PUSH">
+ <intent-filter>
+ <action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED"/>
+ <data android:mimeType="application/vnd.syncml.notification"/>
+ </intent-filter>
+ </receiver>
+
+ <!-- main broadcast intent receiver -->
+ <receiver
+ android:name=".DMIntentReceiver"
+ android:enabled="true"
+ android:permission="com.android.permission.WRITE_OMADM_SETTINGS">
+ <intent-filter>
+ <action android:name="com.android.omadm.service.WAP_PUSH_RECEIVED_INTERNAL"/>
+ </intent-filter>
+
+ <!-- for injection package0 from the command line -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.InjectPackage0_Internal"/>
+ </intent-filter>
+
+ <!-- cancel information notification -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.close_notification_info"/>
+ </intent-filter>
+
+ <!--
+ call and data state both ready and DM session can be started (from
+ DataAndCallStateMonitoringService)
+ -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.call_and_data_state_ready"/>
+ </intent-filter>
+
+ <!--
+ Fota Apn is active and DM session can be started (from
+ ApnStateMonitoringService)
+ -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.apn_state_active"/>
+ </intent-filter>
+
+ <!-- FDM start intent -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.notify_result_to_server"/>
+ </intent-filter>
+
+ <!-- update server hostname and proxy address intent -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.set_server_config"/>
+ </intent-filter>
+
+ <!--
+ user from UI confirmed starting DM session (from
+ DMSessionConfirmAlertActivity)
+ -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.user_confirmed_dm_session"/>
+ </intent-filter>
+
+ <intent-filter android:priority="1">
+ <action android:name="com.android.omadm.service.start_up"/>
+ </intent-filter>
+
+ <!-- event to handle DM session result from DMClientService -->
+ <intent-filter android:priority="1">
+ <action android:name="com.android.omadm.service.Result"/>
+ </intent-filter>
+
+ <!-- timer alarm event -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.pending_notification"/>
+ </intent-filter>
+
+ <!-- event to handle client initiated alert 1226 type requests -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.client_initiated_fota"/>
+ </intent-filter>
+
+ <!-- event to handle DM session cancel request -->
+ <intent-filter>
+ <action android:name="com.android.omadm.service.cancel_dm_session"/>
+ </intent-filter>
+ </receiver>
+
+ <!-- receives "com.android.omadm.service.pkg0_alert_dlg", pkg0_info_dlg, update_cancel_dlg -->
+ <activity
+ android:name=".DMDialog"
+ android:label="@string/app_name"
+ android:exported="false"/>
+
+ <!-- receives intents to display alert dialogs and session timeout notice -->
+ <activity
+ android:name=".DMAlertActivity"
+ android:configChanges="orientation|keyboardHidden"
+ android:label="@string/app_name"
+ android:exported="false"/>
+
+ <activity
+ android:name=".DMSessionConfirmAlertActivity"
+ android:label=""
+ android:theme="@android:style/Theme.Holo"
+ android:launchMode="singleTask"/>
+
+ </application>
+
+</manifest>
diff --git a/DMService/assets/dm/dmt_data/acl.dat b/DMService/assets/dm/dmt_data/acl.dat
new file mode 100644
index 0000000..8f73e7a
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/acl.dat
@@ -0,0 +1,5 @@
+1:*
+
+[.]
+R=1&G=1&A=1&D=1&E=1
+
diff --git a/DMService/assets/dm/dmt_data/acl.txt b/DMService/assets/dm/dmt_data/acl.txt
new file mode 100644
index 0000000..4559206
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/acl.txt
@@ -0,0 +1,2 @@
+[.]
+Replace=*&Get=*&Add=*&Delete=*&Exec=*
diff --git a/DMService/assets/dm/dmt_data/customization.wbxml b/DMService/assets/dm/dmt_data/customization.wbxml
new file mode 100644
index 0000000..e96cd4d
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/customization.wbxml
Binary files differ
diff --git a/DMService/assets/dm/dmt_data/customization.xml b/DMService/assets/dm/dmt_data/customization.xml
new file mode 100644
index 0000000..5e0e61b
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/customization.xml
@@ -0,0 +1,1191 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>Customization</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>BrandAlpha</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>CarrierLegal</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>CustID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>0</Data>
+ </Node>
+
+ <Node>
+ <NodeName>DiagMSLReq</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>LaunchID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>LaunchZone</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>TetheredData</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>ADC</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Eighteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Eigth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Elevnth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fifteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>First</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fourteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Ninth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Second</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Seventeenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Seventh</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Sixteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Tenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Third</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Thirteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Twelfth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Android</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>ClientID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>AndroidMarket</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>MobileSearch</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Youtube</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>OperatorID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>NetworkCode</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Browser</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Homepage</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>SearchEngine</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>UAProfURL</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>CallIntercept</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Eight</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Eleventh</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>First</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Ninth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Second</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Seventh</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Tenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Third</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Twelfth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Contacts</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>First</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Second</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Third</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>EnabledApps</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Skyfire</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Touch</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>VoWifi</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>VVM</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>MMS</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Proxy</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>ServerUrl</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>RoamPreference</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>HomeOnly</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>MenuDisplay</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Wifi</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>DomRoamMaxUsers</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>GSMMaxUsers</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>IntRoamMaxUsers</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>MaxUsers</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>SSID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/DMService/assets/dm/dmt_data/devdetail_ext.wbxml b/DMService/assets/dm/dmt_data/devdetail_ext.wbxml
new file mode 100644
index 0000000..cb90e18
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/devdetail_ext.wbxml
Binary files differ
diff --git a/DMService/assets/dm/dmt_data/devdetail_ext.xml b/DMService/assets/dm/dmt_data/devdetail_ext.xml
new file mode 100644
index 0000000..eb4c20b
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/devdetail_ext.xml
@@ -0,0 +1,45 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>Ext</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>DateTime</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>SystemSettings</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/DMService/assets/dm/dmt_data/devdetail_uri.wbxml b/DMService/assets/dm/dmt_data/devdetail_uri.wbxml
new file mode 100644
index 0000000..9212cb6
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/devdetail_uri.wbxml
Binary files differ
diff --git a/DMService/assets/dm/dmt_data/devdetail_uri.xml b/DMService/assets/dm/dmt_data/devdetail_uri.xml
new file mode 100644
index 0000000..555c5c7
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/devdetail_uri.xml
@@ -0,0 +1,60 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>URI</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>MaxDepth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>20</Data>
+ </Node>
+
+ <Node>
+ <NodeName>MaxSegLen</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>256</Data>
+ </Node>
+
+ <Node>
+ <NodeName>MaxTotLen</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>512</Data>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/DMService/assets/dm/dmt_data/fstab b/DMService/assets/dm/dmt_data/fstab
new file mode 100644
index 0000000..125936a
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/fstab
@@ -0,0 +1,13 @@
+#PATH FILENAME (MUST END WITH .WBXML) fOR NOW, ALL subfile do not overlap
+# first file always is .
+#
+# Also parent URI must be BEFORE child URI
+#
+# This is a sample fstab - PLEASE EDIT this file to match your own tree!!!
+#
+. root.wbxml
+./DevDetail/Ext devdetail_ext.wbxml
+./DevDetail/URI devdetail_uri.wbxml
+./ManagedObjects managedobjects.wbxml
+./Customization customization.wbxml
+./Subscriber subscriber.wbxml
diff --git a/DMService/assets/dm/dmt_data/managedobjects.wbxml b/DMService/assets/dm/dmt_data/managedobjects.wbxml
new file mode 100644
index 0000000..85de5b6
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/managedobjects.wbxml
Binary files differ
diff --git a/DMService/assets/dm/dmt_data/managedobjects.xml b/DMService/assets/dm/dmt_data/managedobjects.xml
new file mode 100644
index 0000000..c5b6602
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/managedobjects.xml
@@ -0,0 +1,21 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>ManagedObjects</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+</MgmtTree>
diff --git a/DMService/assets/dm/dmt_data/root.bmdf b/DMService/assets/dm/dmt_data/root.bmdf
new file mode 100644
index 0000000..5ee9221
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/root.bmdf
Binary files differ
diff --git a/DMService/assets/dm/dmt_data/root.mdf b/DMService/assets/dm/dmt_data/root.mdf
new file mode 100644
index 0000000..637c65f
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/root.mdf
@@ -0,0 +1,1099 @@
+[.]
+type:node
+access:Get,Replace,Add,Delete,Exec
+mime:text/plain
+[/CDMA]
+type:node
+access:Get
+[/CDMA/BC10]
+type:int
+access:Get,Replace
+[/CDMA/BC14]
+type:int
+access:Get,Replace
+[/CDMA/RoamPreference]
+type:bin
+access:Get,Replace
+[/CDMA/SO68]
+type:int
+access:Get,Replace
+[/CDMA/1xA]
+type:node
+access:Get
+[/CDMA/1xA/Enabled]
+type:int
+access:Replace,Get
+[/CDMA/3GPD]
+type:node
+access:Get
+[/CDMA/3GPD/*]
+type:node
+access:Get,Add,Replace,Delete
+[/CDMA/3GPD/*/AuthAlgoAAA]
+type:chr
+access:Add,Get,Replace,Delete
+mime:text/plain
+[/CDMA/3GPD/*/AuthAlgoHA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/MobileIpAddress]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/NAI]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/PasswordAAA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/PasswordHA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/PriHAIp]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/ReverseTunneling]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/SecHAIp]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/SpiAAA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/SpiHA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/B25]
+type:node
+access:Get
+[/CDMA/B25/enablement]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B25/scanpriority]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B26]
+type:node
+access:Get
+[/CDMA/B26/enablement]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B26/scanpriority]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B41]
+type:node
+access:Get
+[/CDMA/B41/enablement]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B41/scanpriority]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/EHRPD]
+type:node
+access:Get
+[/CDMA/EHRPD/Enabled]
+type:int
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/NAM]
+type:node
+access:Get
+[/CDMA/NAM/CdmaNam]
+type:bin
+access:Get,Replace
+mime:text/plain
+[/CDMA/NAM/MobDirNum]
+type:bin
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/CDMA/PRL]
+type:node
+access:Get,Replace
+[/CDMA/PRL/PrefRoamList]
+type:bin
+access:Get,Replace
+[/CDMA/SO73]
+type:node
+access:Get
+[/CDMA/SO73/COP0]
+type:int
+access:Replace,Get
+[/CDMA/SO73/COP1to7]
+type:int
+access:Replace,Get
+[/Con]
+type:node
+access:Get,Replace
+[/Con/HPPTT]
+type:node
+access:Get,Replace
+[/Con/HPPTT/Enabled]
+type:bool
+access:Replace,Get,Delete
+[/Con/HPPTT/UserAddress]
+type:chr
+access:Replace,Get,Delete
+[/CSIM]
+type:node
+access:Get
+[/CSIM/CoverageObj]
+type:bin
+access:Get,Replace
+mime:text/plain
+[/CSIM/ProvObj]
+type:bin
+access:Get,Replace
+mime:text/plain
+[/Customization]
+type:node
+access:Get,Add,Replace
+[/Customization/BrandAlpha]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CarrierLegal]
+type:bin
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CustID]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/Customization/DiagMSLReq]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/LaunchID]
+type:int
+access:Get,Add,Replace,Delete
+[/Customization/LaunchZone]
+type:int
+access:Get,Add,Replace,Delete
+[/Customization/TetheredData]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC]
+type:node
+access:Get,Add,Replace
+[/Customization/ADC/Eighteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Eigth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Elevnth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Fifteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Fifth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/First]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Fourteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Fourth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Ninth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Second]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Seventeenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Seventh]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Sixteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Sixth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Tenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Third]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Thirteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Twelfth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Android]
+type:node
+access:Get,Add,Replace
+[/Customization/Android/ClientID]
+type:node
+access:Get,Add,Replace
+[/Customization/Android/ClientID/AndroidMarket]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Android/ClientID/MobileSearch]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Android/ClientID/Youtube]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Android/OperatorID]
+type:node
+access:Get,Add,Replace
+[/Customization/Android/OperatorID/NetworkCode]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Browser]
+type:node
+access:Get,Add,Replace
+[/Customization/Browser/Homepage]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Browser/SearchEngine]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Browser/UAProfURL]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept]
+type:node
+access:Get,Add,Replace
+[/Customization/CallIntercept/Eight]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Eleventh]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Fifth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/First]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Fourth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Ninth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Second]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Seventh]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Sixth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Tenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Third]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Twelfth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts]
+type:node
+access:Get,Add,Replace
+[/Customization/Contacts/Fifth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/First]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/Fourth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/Second]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/Sixth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/Third]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/EnabledApps]
+type:node
+access:Get,Add,Replace
+[/Customization/EnabledApps/Skyfire]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/EnabledApps/Touch]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/EnabledApps/VoWifi]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/EnabledApps/VVM]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/MMS]
+type:node
+access:Get,Add,Replace
+[/Customization/MMS/Proxy]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/MMS/ServerUrl]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/RoamPreference]
+type:node
+access:Get,Add,Replace
+[/Customization/RoamPreference/HomeOnly]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/RoamPreference/MenuDisplay]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi]
+type:node
+access:Get,Add,Replace
+[/Customization/Wifi/DomRoamMaxUsers]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi/GSMMaxUsers]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi/IntRoamMaxUsers]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi/MaxUsers]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi/SSID]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DevDetail]
+type:node
+access:Get
+[/DevDetail/DevTyp]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/DevDetail/ESNV]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevDetail/FlexV]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevDetail/FwV]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+default:1.0
+[/DevDetail/HwV]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/DevDetail/LrgObj]
+type:bool
+access:Get
+mime:text/plain
+default:true
+[/DevDetail/OEM]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/DevDetail/PRIChecksum]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevDetail/PRLV]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevDetail/SwV]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/DevDetail/Bearer]
+type:node
+access:Get,Replace
+[/DevDetail/Bearer/CDMA]
+type:chr
+maxLen:16
+access:Get,Replace
+mime:text/plain
+[/DevDetail/Bearer/GSM]
+type:chr
+maxLen:16
+access:Get,Replace
+mime:text/plain
+[/DevDetail/Ext]
+type:node
+access:Get,Add
+[/DevDetail/Ext/LastUpdateTime]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/PreFwV]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/SystemV]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/WLANMacAddr]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/DateTime]
+type:node
+access:Get
+[/DevDetail/Ext/DateTime/Date]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/DateTime/TimeUTC]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/SystemSettings]
+type:node
+access:Get
+[/DevDetail/Ext/SystemSettings/AllowUnknownSources]
+type:bool
+mime:text/plain
+access:Get,Replace
+[/DevDetail/URI]
+type:node
+access:Get
+[/DevDetail/URI/MaxDepth]
+type:int
+access:Get
+mime:text/plain
+[/DevDetail/URI/MaxSegLen]
+type:int
+access:Get
+mime:text/plain
+[/DevDetail/URI/MaxTotLen]
+type:int
+access:Get
+mime:text/plain
+[/DevInfo]
+type:node
+access:Get
+[/DevInfo/DevId]
+type:chr
+maxLen:31
+access:Get,Add,Replace
+mime:text/plain
+default:1.0
+[/DevInfo/DmV]
+type:chr
+maxLen:31
+access:Get,Add,Replace
+mime:text/plain
+default:1.0
+[/DevInfo/Lang]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevInfo/LangAuto]
+type:bool
+mime:text/plain
+access:Get,Replace
+[/DevInfo/Loc]
+type:chr
+maxLen:2
+access:Get,Replace
+mime:text/plain
+[/DevInfo/Man]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevInfo/Mod]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+default:1.0
+[/DevInfo/Sort]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/DevInfo/Bearer]
+type:node
+access:Get,Add,Replace,Delete
+[/DevInfo/Bearer/GSM]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+default:1.0
+[/DevInfo/Ext]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AAuthPref]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppID]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/Name]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/PrefConRef]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/ServerID]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAddr]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAddr/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAddr/*/Addr]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAddr/*/AddrType]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAddr/*/Port]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAddr/*/Port/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAddr/*/Port/*/PortNbr]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAuth]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAuth/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAuth/*/AAuthData]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAuth/*/AAuthLevel]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+values:CLCRED,SRVCRED,OBEX,HTTP
+[/DMAcc/*/AppAuth/*/AAuthName]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAuth/*/AAuthSecret]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAuth/*/AAuthType]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+values:HTTP-BASIC,HTTP-DIGEST,BASIC,DIGEST,HMAC,X509,SECUREID,SAFEWORD,DIGIPASS,TRANSPORT
+[/DMAcc/*/Ext]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/Ext/LastClientAuthType]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/ToConRef]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/ToConRef/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/ToConRef/*/ConRef]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/LTE]
+type:node
+access:Get
+[/LTE/BSRMaxTime]
+type:int
+access:Get,Replace
+[/LTE/BSRTimer]
+type:int
+access:Get,Replace
+[/LTE/nextLTEscan]
+type:int
+access:Get,Replace
+[/LTE/APN]
+type:node
+access:Get
+[/LTE/APN/0]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/1]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/2]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/3]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/4]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/5]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/6]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/7]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/Service]
+type:node
+access:Get
+[/LTE/Service/Enabled]
+type:int
+access:Get,Replace
+[/LTE/Service/Forced]
+type:int
+access:Get,Replace
+[/ManagedObjects]
+type:node
+access:Get,Add,Replace,Delete
+[/ManagedObjects/ConnMO]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/ext]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/ext/Settings]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/ext/Settings/t_1xRTT]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/ext/Settings/t_mpsr]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/ext/Settings/tbsr_cdma]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IMS/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IMS/Setting/Domain]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/SIPT1]
+type:int
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/SIPT2]
+type:int
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/SIPTf]
+type:int
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/sms_over_IP_network_indication]
+type:bool
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/smsformat]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IPV6Enable]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IPV6Enable/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IPV6Enable/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Enable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/2]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/3]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Enable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/4]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Enable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/VZW800]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Enable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/DiagMon]
+type:node
+access:Get
+[/ManagedObjects/DiagMon/RF]
+type:node
+access:Get
+[/ManagedObjects/DiagMon/RF/HomeRoam]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/ManagedObjects/DiagMon/RF/CurrentSystem]
+type:node
+access:Get
+[/ManagedObjects/DiagMon/RF/CurrentSystem/Data]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/ManagedObjects/DiagMon/RF/CurrentSystem/Voice]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/RemoteCommands]
+type:node
+access:Get
+[/RemoteCommands/Command]
+type:chr
+access:Get,Exec
+mime:text/plain
+[/SIM]
+type:node
+access:Get
+[/SIM/UICCID]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber]
+type:node
+access:Get,Replace
+[/Subscriber/AcctSubType]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/AcctType]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/BAN]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/BillCycleDate]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/CarrierID]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/CSA]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/State]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/UsageMode]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/ZIPCode]
+type:chr
+access:Get,Replace
+mime:text/plain
diff --git a/DMService/assets/dm/dmt_data/root.wbxml b/DMService/assets/dm/dmt_data/root.wbxml
new file mode 100644
index 0000000..9c8f64e
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/root.wbxml
Binary files differ
diff --git a/DMService/assets/dm/dmt_data/root.xml b/DMService/assets/dm/dmt_data/root.xml
new file mode 100644
index 0000000..1bb9b84
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/root.xml
@@ -0,0 +1,313 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>.</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ <Add/>
+ <Delete/>
+ <Exec/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>DevDetail</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>ESNV</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>1.0</Data>
+ </Node>
+
+ <Node>
+ <NodeName>FlexV</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>1.0</Data>
+ </Node>
+
+ <Node>
+ <NodeName>LrgObj</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>true</Data>
+ </Node>
+
+ <Node>
+ <NodeName>OEM</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>Google</Data>
+ </Node>
+
+ <Node>
+ <NodeName>PRIChecksum</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>111111</Data>
+ </Node>
+
+ <Node>
+ <NodeName>PRLV</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>1.0</Data>
+ </Node>
+
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>CDMA</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>GSM</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>1900-GSM</Data>
+ </Node>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>DevInfo</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>LangAuto</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>false</Data>
+ </Node>
+
+ <Node>
+ <NodeName>Loc</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>US</Data>
+ </Node>
+
+ <Node>
+ <NodeName>Sort</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>Latin</Data>
+ </Node>
+
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>GSM</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Ext</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>DMAcc</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>RemoteCommands</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Command</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Exec/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/DMService/assets/dm/dmt_data/subscriber.wbxml b/DMService/assets/dm/dmt_data/subscriber.wbxml
new file mode 100644
index 0000000..18969c8
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/subscriber.wbxml
Binary files differ
diff --git a/DMService/assets/dm/dmt_data/subscriber.xml b/DMService/assets/dm/dmt_data/subscriber.xml
new file mode 100644
index 0000000..db2502c
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/subscriber.xml
@@ -0,0 +1,145 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>Subscriber</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>AcctSubType</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>AcctType</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>BAN</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>BillCycleDate</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>CarrierID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>CSA</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>State</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>UsageMode</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>ZIPCode</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/DMService/assets/dm/dmt_data/syncmldm.ddf b/DMService/assets/dm/dmt_data/syncmldm.ddf
new file mode 100644
index 0000000..ec723ce
--- /dev/null
+++ b/DMService/assets/dm/dmt_data/syncmldm.ddf
@@ -0,0 +1,5720 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE MgmtTree SYSTEM "http://www.openmobilealliance.com/tech/DTD/dm_ddf-v1_2.dtd">
+<MgmtTree>
+ <VerDTD>1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+ <Node>
+ <NodeName>.</NodeName>
+ <Path></Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Exec/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>CDMA</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>BC10</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>BC14</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>RoamPreference</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SO68</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>1xA</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./CDMA/1xA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>3GPD</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./CDMA/3GPD</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AuthAlgoAAA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AuthAlgoHA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MobileIpAddress</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>NAI</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PasswordAAA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PasswordHA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PriHAIp</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ReverseTunneling</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SecHAIp</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SpiAAA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SpiHA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>B25</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>enablement</NodeName>
+ <Path>./CDMA/B25</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>scanpriority</NodeName>
+ <Path>./CDMA/B25</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>B26</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>enablement</NodeName>
+ <Path>./CDMA/B26</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>scanpriority</NodeName>
+ <Path>./CDMA/B26</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>B41</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>enablement</NodeName>
+ <Path>./CDMA/B41</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>scanpriority</NodeName>
+ <Path>./CDMA/B41</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>EHRPD</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./CDMA/EHRPD</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>NAM</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>CdmaNam</NodeName>
+ <Path>./CDMA/NAM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MobDirNum</NodeName>
+ <Path>./CDMA/NAM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>PRL</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>PrefRoamList</NodeName>
+ <Path>./CDMA/PRL</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>SO73</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>COP0</NodeName>
+ <Path>./CDMA/SO73</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>COP1to7</NodeName>
+ <Path>./CDMA/SO73</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Con</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>HPPTT</NodeName>
+ <Path>./Con</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./Con/HPPTT</Path>
+ <DFProperties>
+ <AccessType>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>UserAddress</NodeName>
+ <Path>./Con/HPPTT</Path>
+ <DFProperties>
+ <AccessType>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>CSIM</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>CoverageObj</NodeName>
+ <Path>./CSIM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ProvObj</NodeName>
+ <Path>./CSIM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Customization</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>BrandAlpha</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CarrierLegal</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CustID</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>DiagMSLReq</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LaunchID</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LaunchZone</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>TetheredData</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ADC</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Eighteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Eigth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Elevnth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fifteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>First</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fourteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Ninth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Second</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Seventeenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Seventh</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sixteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Tenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Third</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Thirteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Twelfth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Android</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>ClientID</NodeName>
+ <Path>./Customization/Android</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AndroidMarket</NodeName>
+ <Path>./Customization/Android/ClientID</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MobileSearch</NodeName>
+ <Path>./Customization/Android/ClientID</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Youtube</NodeName>
+ <Path>./Customization/Android/ClientID</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>OperatorID</NodeName>
+ <Path>./Customization/Android</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>NetworkCode</NodeName>
+ <Path>./Customization/Android/OperatorID</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Browser</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Homepage</NodeName>
+ <Path>./Customization/Browser</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SearchEngine</NodeName>
+ <Path>./Customization/Browser</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>UAProfURL</NodeName>
+ <Path>./Customization/Browser</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>CallIntercept</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Eight</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Eleventh</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>First</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Ninth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Second</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Seventh</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Tenth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Third</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Twelfth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Contacts</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>First</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Second</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Third</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>EnabledApps</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Skyfire</NodeName>
+ <Path>./Customization/EnabledApps</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Touch</NodeName>
+ <Path>./Customization/EnabledApps</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>VoWifi</NodeName>
+ <Path>./Customization/EnabledApps</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>VVM</NodeName>
+ <Path>./Customization/EnabledApps</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>MMS</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Proxy</NodeName>
+ <Path>./Customization/MMS</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ServerUrl</NodeName>
+ <Path>./Customization/MMS</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>RoamPreference</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>HomeOnly</NodeName>
+ <Path>./Customization/RoamPreference</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MenuDisplay</NodeName>
+ <Path>./Customization/RoamPreference</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Wifi</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>DomRoamMaxUsers</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>GSMMaxUsers</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IntRoamMaxUsers</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MaxUsers</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SSID</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DevDetail</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>DevTyp</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ESNV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>FlexV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>FwV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>HwV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LrgObj</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>OEM</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PRIChecksum</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PRLV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SwV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>CDMA</NodeName>
+ <Path>./DevDetail/Bearer</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>GSM</NodeName>
+ <Path>./DevDetail/Bearer</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>LastUpdateTime</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PreFwV</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SystemV</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>WLANMacAddr</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>DateTime</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Date</NodeName>
+ <Path>./DevDetail/Ext/DateTime</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>TimeUTC</NodeName>
+ <Path>./DevDetail/Ext/DateTime</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>SystemSettings</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AllowUnknownSources</NodeName>
+ <Path>./DevDetail/Ext/SystemSettings</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>URI</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>MaxDepth</NodeName>
+ <Path>./DevDetail/URI</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MaxSegLen</NodeName>
+ <Path>./DevDetail/URI</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MaxTotLen</NodeName>
+ <Path>./DevDetail/URI</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DevInfo</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>DevId</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>DmV</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Lang</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LangAuto</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Loc</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Man</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Mod</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sort</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>GSM</NodeName>
+ <Path>./DevInfo/Bearer</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DMAcc</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AAuthPref</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AppID</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PrefConRef</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ServerID</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AppAddr</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc/*/AppAddr</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Addr</NodeName>
+ <Path>./DMAcc/*/AppAddr/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AddrType</NodeName>
+ <Path>./DMAcc/*/AppAddr/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Port</NodeName>
+ <Path>./DMAcc/*/AppAddr/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc/*/AppAddr/*/Port</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>PortNbr</NodeName>
+ <Path>./DMAcc/*/AppAddr/*/Port/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>AppAuth</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc/*/AppAuth</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AAuthData</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthLevel</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthName</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthSecret</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthType</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>LastClientAuthType</NodeName>
+ <Path>./DMAcc/*/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>ToConRef</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc/*/ToConRef</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>ConRef</NodeName>
+ <Path>./DMAcc/*/ToConRef/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>LTE</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>BSRMaxTime</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>BSRTimer</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>nextLTEscan</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>APN</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>0</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>1</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>2</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>3</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>4</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>5</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>6</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>7</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Service</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./LTE/Service</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Forced</NodeName>
+ <Path>./LTE/Service</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>ManagedObjects</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>ConnMO</NodeName>
+ <Path>./ManagedObjects</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>ext</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Settings</NodeName>
+ <Path>./ManagedObjects/ConnMO/ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>t_1xRTT</NodeName>
+ <Path>./ManagedObjects/ConnMO/ext/Settings</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>t_mpsr</NodeName>
+ <Path>./ManagedObjects/ConnMO/ext/Settings</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>tbsr_cdma</NodeName>
+ <Path>./ManagedObjects/ConnMO/ext/Settings</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>IMS</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Domain</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SIPT1</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SIPT2</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SIPTf</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>sms_over_IP_network_indication</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>smsformat</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>IPV6Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>LTE</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>APN</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>1</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>2</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>3</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>4</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>VZW800</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>APN</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>5</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DiagMon</NodeName>
+ <Path>./ManagedObjects</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>RF</NodeName>
+ <Path>./ManagedObjects/DiagMon</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>HomeRoam</NodeName>
+ <Path>./ManagedObjects/DiagMon/RF</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CurrentSystem</NodeName>
+ <Path>./ManagedObjects/DiagMon/RF</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Data</NodeName>
+ <Path>./ManagedObjects/DiagMon/RF/CurrentSystem</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Voice</NodeName>
+ <Path>./ManagedObjects/DiagMon/RF/CurrentSystem</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>RemoteCommands</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Command</NodeName>
+ <Path>./RemoteCommands</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>SIM</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>UICCID</NodeName>
+ <Path>./SIM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Subscriber</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AcctSubType</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AcctType</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>BAN</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>BillCycleDate</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CarrierID</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CSA</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>State</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>UsageMode</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ZIPCode</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/DMService/assets/dm/plugin/sysplugins.ini b/DMService/assets/dm/plugin/sysplugins.ini
new file mode 100644
index 0000000..77fdfe7
--- /dev/null
+++ b/DMService/assets/dm/plugin/sysplugins.ini
@@ -0,0 +1,101 @@
+[./ManagedObjects/DiagMon]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.diagmon.DiagmonPlugin
+
+[./ManagedObjects/ConnMO]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.connmo.ConnmoPlugin
+
+[./ManagedObjects/ConnMO]
+_exec=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.connmo.ConnmoPlugin
+
+[./RemoteCommands/Command]
+_exec=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+
+[./DevDetail/FwV]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevDetail/SwV]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevDetail/Ext/WLANMacAddr]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevDetail/Ext/PreFwV]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevDetail/Ext/LastUpdateTime]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevDetail/Ext/DateTime/Date]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevDetail/Ext/DateTime/TimeUTC]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevDetail/HwV]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevDetail/DevTyp]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+
+[./DevInfo/DevId]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevInfo/DmV]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevInfo/Lang]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevInfo/Man]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevInfo/Mod]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+[./DevDetail/Ext/SystemSettings/AllowUnknownSources]
+_data=libdmjavaplugin.so
+_uid=com.android.omadm.plugin.dev.DevPlugin
+
+[./CDMA]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+[./CDMA/*]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+
+[./CSIM]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+[./CSIM/*]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+
+[./Con]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+[./Con/*]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+
+[./Customization/CustID]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+
+[./LTE]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+[./LTE/*]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+
+[./SIM]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
+[./SIM/*]
+_data=libdmjavaplugin.so
+_uid=com.android.sdm.plugins.sprintdm.SprintDMPlugin
diff --git a/DMService/proguard.flags b/DMService/proguard.flags
new file mode 100644
index 0000000..e921d81
--- /dev/null
+++ b/DMService/proguard.flags
@@ -0,0 +1,73 @@
+# Keep JNI native methods in NativeDM
+-keep class com.android.omadm.service.NativeDM {
+ static native int initialize();
+ static native int destroy();
+ static native int startClientSession(java.lang.String, com.android.omadm.service.DMSession);
+ static native int startFotaClientSession(java.lang.String, java.lang.String, com.android.omadm.service.DMSession);
+ static native int startFotaNotifySession(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, com.android.omadm.service.DMSession);
+ static native int cancelSession();
+ static native int parsePkg0(byte[], com.android.omadm.service.DMPkg0Notification);
+ static native int createInterior(java.lang.String);
+ static native int createLeaf(java.lang.String, java.lang.String);
+ static native int createLeaf(java.lang.String, byte[]);
+ static native int deleteNode(java.lang.String);
+ static native java.lang.String setStringNode(java.lang.String, java.lang.String);
+ static native java.lang.String CreateLeafInteger(java.lang.String, java.lang.String);
+ static native java.lang.String getNodeInfo(java.lang.String);
+ static native java.lang.String executePlugin(java.lang.String, java.lang.String);
+ static native java.lang.String dumpTree(java.lang.String);
+ static native byte[] nativeWbxmlToXml(byte[]);
+ static native byte[] processScript(java.lang.String, java.lang.String, boolean, int, com.android.omadm.service.DMSession);
+ static native byte[] processBootstrapScript(byte[], boolean, java.lang.String);
+ static native java.lang.String parseBootstrapServerId(byte[], boolean);
+}
+
+# Keep JNI callback methods in DMAlert
+-keep class com.android.omadm.service.DMAlert {
+ int showDisplayAlert(int, java.lang.String, int, int);
+ int showConfirmAlert(int, java.lang.String, int, int);
+ int showTextInputAlert(int, java.lang.String, java.lang.String, int, int, int, int, int);
+ int showSingleChoiceAlert(int, java.lang.String, java.lang.String[], int, int, int);
+ int showMultipleChoiceAlert(int, java.lang.String, java.lang.String[], boolean[], int, int);
+}
+
+# Keep JNI callback methods in DMHttpConnector
+-keep class com.android.omadm.service.DMHttpConnector {
+ void enableApnByName(java.lang.String);
+ int sendRequest(java.lang.String, byte[], java.lang.String);
+ long getResponseLength();
+ byte[] getResponseData();
+ java.lang.String getResponseHeader(java.lang.String);
+ void setContentType(java.lang.String);
+}
+
+# Keep JNI callback methods in DMPkg0Notification
+-keep class com.android.omadm.service.DMPkg0Notification {
+ void setSessionID(int);
+ void setUIMode(int);
+ void setInitiator(int);
+ void setAuthFlag(int);
+ void setServerID(java.lang.String);
+}
+
+# Keep JNI callback methods in DMSession
+-keep class com.android.omadm.service.DMSession {
+ com.android.omadm.service.DMHttpConnector getNetConnector();
+ com.android.omadm.service.DMAlert getDMAlert();
+}
+
+# Keep plugin wrapper JNI callback method in DmtPluginManager
+-keep class com.android.omadm.plugin.impl.DmtPluginManager {
+ boolean initJavaPlugin(java.lang.String, java.lang.String[]);
+ int executeNode(java.lang.String, java.lang.String);
+ int commit();
+ void setServerID(java.lang.String);
+ int createInteriorNode(java.lang.String);
+ int createLeafNode(java.lang.String, int, java.lang.String);
+ int renameNode(java.lang.String, java.lang.String);
+ int deleteNode(java.lang.String);
+ int setNodeValue(java.lang.String, int, java.lang.String);
+ java.lang.String[] getNodeValue(java.lang.String);
+ java.lang.String[] getNodes();
+ void release();
+}
diff --git a/DMService/res/drawable/alert_dialog_icon.png b/DMService/res/drawable/alert_dialog_icon.png
new file mode 100644
index 0000000..8f7bd5d
--- /dev/null
+++ b/DMService/res/drawable/alert_dialog_icon.png
Binary files differ
diff --git a/DMService/res/layout/textinput_dialog.xml b/DMService/res/layout/textinput_dialog.xml
new file mode 100644
index 0000000..1bad479
--- /dev/null
+++ b/DMService/res/layout/textinput_dialog.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" >
+
+ <EditText android:id="@+id/textinput_content"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+</LinearLayout>
diff --git a/DMService/res/values-ar/strings.xml b/DMService/res/values-ar/strings.xml
new file mode 100644
index 0000000..a298939
--- /dev/null
+++ b/DMService/res/values-ar/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">خدمة DM</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">إدارة الجهاز</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">رسالة النظام</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">مواÙÙ‚</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">رÙض</string>
+ <string name="dm_session_button_confirm">تحديث</string>
+ <string name="dm_session_button_reject">إلغاء</string>
+ <string name="dm_session_confirmation_title">تحديث النظام</string>
+ <string name="dm_session_confirmation_message">تحديث النظام الخاص بهاتÙÙƒ متاح</string>
+ <string name="dm_session_confirmation_notification_label">تحديث النظام</string>
+ <string name="dm_session_confirmation_notification_message">طلب جلسة DM جديد</string>
+ <string name="dm_session_information_notification_label">تحديث النظام</string>
+ <string name="dm_session_information_notification_message1">قام الخادم بتقديم طلب</string>
+ <string name="dm_session_information_notification_message2_success">أكمل الجهاز طلب الخادم</string>
+ <string name="dm_session_information_notification_message2_fail">Ùشل الجهاز ÙÙŠ إكمال طلب الخادم</string>
+
+</resources>
diff --git a/DMService/res/values-bg/strings.xml b/DMService/res/values-bg/strings.xml
new file mode 100644
index 0000000..ab2c429
--- /dev/null
+++ b/DMService/res/values-bg/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Управление на уÑтройÑтвото</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">СиÑтемно Ñъобщение</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">ОК</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">ОтхвърлÑне</string>
+ <string name="dm_session_button_confirm">ÐктуализациÑ</string>
+ <string name="dm_session_button_reject">Отказ</string>
+ <string name="dm_session_confirmation_title">ÐÐºÑ‚ÑƒÐ°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ñ Ð½Ð° ÑиÑтемата</string>
+ <string name="dm_session_confirmation_message">Ðалична е Ð°ÐºÑ‚ÑƒÐ°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ñ Ð½Ð° ÑиÑтемата за Ð²Ð°ÑˆÐ¸Ñ Ñ‚ÐµÐ»ÐµÑ„Ð¾Ð½</string>
+ <string name="dm_session_confirmation_notification_label">ÐÐºÑ‚ÑƒÐ°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ñ Ð½Ð° ÑиÑтемата</string>
+ <string name="dm_session_confirmation_notification_message">Ðово иÑкане за DM ÑеÑиÑ</string>
+ <string name="dm_session_information_notification_label">ÐÐºÑ‚ÑƒÐ°Ð»Ð¸Ð·Ð°Ñ†Ð¸Ñ Ð½Ð° ÑиÑтемата</string>
+ <string name="dm_session_information_notification_message1">Сървърът отправи иÑкане</string>
+ <string name="dm_session_information_notification_message2_success">УÑтройÑтвото изпълни иÑкането на Ñървъра</string>
+ <string name="dm_session_information_notification_message2_fail">УÑтройÑтвото не уÑÐ¿Ñ Ð´Ð° изпълни иÑкането на Ñървъра</string>
+
+</resources>
diff --git a/DMService/res/values-ca/strings.xml b/DMService/res/values-ca/strings.xml
new file mode 100644
index 0000000..7792bd1
--- /dev/null
+++ b/DMService/res/values-ca/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Gestió de dispositius</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Missatge del sistema</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">D\'acord</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Rebutja</string>
+ <string name="dm_session_button_confirm">Actualitza</string>
+ <string name="dm_session_button_reject">Cancel·la</string>
+ <string name="dm_session_confirmation_title">Actualització del sistema</string>
+ <string name="dm_session_confirmation_message">Hi ha una actualització del sistema disponible per al telèfon</string>
+ <string name="dm_session_confirmation_notification_label">Actualització del sistema</string>
+ <string name="dm_session_confirmation_notification_message">Sol·licitud de sessió DM nova</string>
+ <string name="dm_session_information_notification_label">Actualització del sistema</string>
+ <string name="dm_session_information_notification_message1">El servidor ha iniciat una sol·licitud</string>
+ <string name="dm_session_information_notification_message2_success">El dispositiu ha completat la sol·licitud del servidor</string>
+ <string name="dm_session_information_notification_message2_fail">El dispositiu no ha pogut completar la sol·licitud del servidor</string>
+
+</resources>
diff --git a/DMService/res/values-cs/strings.xml b/DMService/res/values-cs/strings.xml
new file mode 100644
index 0000000..02c498e
--- /dev/null
+++ b/DMService/res/values-cs/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Správa zařízení</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Systémová zpráva</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Odmítnout</string>
+ <string name="dm_session_button_confirm">Aktualizovat</string>
+ <string name="dm_session_button_reject">Zrušit</string>
+ <string name="dm_session_confirmation_title">Aktualizace systému</string>
+ <string name="dm_session_confirmation_message">Je k dispozici aktualizace systému pro váš telefon</string>
+ <string name="dm_session_confirmation_notification_label">Aktualizace systému</string>
+ <string name="dm_session_confirmation_notification_message">Nový požadavek na relaci DM</string>
+ <string name="dm_session_information_notification_label">Aktualizace systému</string>
+ <string name="dm_session_information_notification_message1">Server zaslal požadavek</string>
+ <string name="dm_session_information_notification_message2_success">Zařízení dokonÄilo požadavek serveru</string>
+ <string name="dm_session_information_notification_message2_fail">Zařízení se nepodaÅ™ilo dokonÄit požadavek serveru</string>
+
+</resources>
diff --git a/DMService/res/values-da/strings.xml b/DMService/res/values-da/strings.xml
new file mode 100644
index 0000000..6830f16
--- /dev/null
+++ b/DMService/res/values-da/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Enhedshåndtering</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Systembesked</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Afvis</string>
+ <string name="dm_session_button_confirm">Opdater</string>
+ <string name="dm_session_button_reject">Annuller</string>
+ <string name="dm_session_confirmation_title">Systemopdatering</string>
+ <string name="dm_session_confirmation_message">Der er en softwareopdatering til din telefon tilgængelig</string>
+ <string name="dm_session_confirmation_notification_label">Systemopdatering</string>
+ <string name="dm_session_confirmation_notification_message">Ny anmodning om DM-session</string>
+ <string name="dm_session_information_notification_label">Systemopdatering</string>
+ <string name="dm_session_information_notification_message1">Server har initieret en anmodning</string>
+ <string name="dm_session_information_notification_message2_success">Enheden har fuldført serverens anmodning</string>
+ <string name="dm_session_information_notification_message2_fail">Enheden kunne ikke fuldføre serverens anmodning</string>
+
+</resources>
diff --git a/DMService/res/values-de/strings.xml b/DMService/res/values-de/strings.xml
new file mode 100644
index 0000000..1f8e412
--- /dev/null
+++ b/DMService/res/values-de/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Gerätemanagement</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Systemmeldung</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">"OK"</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Ablehnen</string>
+ <string name="dm_session_button_confirm">Aktualis.</string>
+ <string name="dm_session_button_reject">Abbrechen</string>
+ <string name="dm_session_confirmation_title">Systemupdate</string>
+ <string name="dm_session_confirmation_message">Für Ihr Telefon ist ein Systemupdate verfügbar</string>
+ <string name="dm_session_confirmation_notification_label">Systemupdate</string>
+ <string name="dm_session_confirmation_notification_message">Neue DM-Sitzungsanforderung</string>
+ <string name="dm_session_information_notification_label">Systemupdate</string>
+ <string name="dm_session_information_notification_message1">Der Server hat eine Anfrage gestartet</string>
+ <string name="dm_session_information_notification_message2_success">Das Gerät hat die Anfrage des Servers abgeschlossen</string>
+ <string name="dm_session_information_notification_message2_fail">Das Gerät konnte die Anfrage des Servers nicht abschließen</string>
+
+</resources>
diff --git a/DMService/res/values-el/strings.xml b/DMService/res/values-el/strings.xml
new file mode 100644
index 0000000..d834535
--- /dev/null
+++ b/DMService/res/values-el/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">ΔιαχείÏιση συσκευών</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Μήνυμα συστήματος</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">"OK"</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">ΑπόÏÏιψη</string>
+ <string name="dm_session_button_confirm">"ΕνημέÏωση"</string>
+ <string name="dm_session_button_reject">"ΆκυÏο"</string>
+ <string name="dm_session_confirmation_title">ΕνημέÏωση συστήματος</string>
+ <string name="dm_session_confirmation_message">ΥπάÏχει ενημέÏωση συστήματος για το τηλέφωνο</string>
+ <string name="dm_session_confirmation_notification_label">ΕνημέÏωση συστήματος</string>
+ <string name="dm_session_confirmation_notification_message">Αίτημα νέας πεÏιόδου λειτουÏγίας DM</string>
+ <string name="dm_session_information_notification_label">ΕνημέÏωση συστήματος</string>
+ <string name="dm_session_information_notification_message1">Ο διακομιστής δημιοÏÏγησε ένα αίτημα</string>
+ <string name="dm_session_information_notification_message2_success">Η συσκευή ολοκλήÏωσε το αίτημα του διακομιστή</string>
+ <string name="dm_session_information_notification_message2_fail">Η συσκευή δεν ολοκλήÏωσε το αίτημα του διακομιστή</string>
+
+</resources>
diff --git a/DMService/res/values-en-rGB/strings.xml b/DMService/res/values-en-rGB/strings.xml
new file mode 100644
index 0000000..d5b73a2
--- /dev/null
+++ b/DMService/res/values-en-rGB/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Device management</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">System message</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Reject</string>
+ <string name="dm_session_button_confirm">Update</string>
+ <string name="dm_session_button_reject">Cancel</string>
+ <string name="dm_session_confirmation_title">System update</string>
+ <string name="dm_session_confirmation_message">System update for your phone is available</string>
+ <string name="dm_session_confirmation_notification_label">System update</string>
+ <string name="dm_session_confirmation_notification_message">New DM session request</string>
+ <string name="dm_session_information_notification_label">System update</string>
+ <string name="dm_session_information_notification_message1">Server has initiated a request</string>
+ <string name="dm_session_information_notification_message2_success">Device has completed server\'s request</string>
+ <string name="dm_session_information_notification_message2_fail">Device failed to complete server\'s request</string>
+
+</resources>
diff --git a/DMService/res/values-es-rUS/strings.xml b/DMService/res/values-es-rUS/strings.xml
new file mode 100644
index 0000000..d2fa4c5
--- /dev/null
+++ b/DMService/res/values-es-rUS/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">Servicio DM</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Administración del dispositivo</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Mensaje del sistema</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">Aceptar</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">No</string>
+ <string name="dm_session_button_confirm">"Actualizar"</string>
+ <string name="dm_session_button_reject">Cancelar</string>
+ <string name="dm_session_confirmation_title">Actualización del sistema</string>
+ <string name="dm_session_confirmation_message">La actualización del sistema para tu teléfono se encuentra disponible</string>
+ <string name="dm_session_confirmation_notification_label">Actualización del sistema</string>
+ <string name="dm_session_confirmation_notification_message">Nueva solicitud de sesión DM</string>
+ <string name="dm_session_information_notification_label">Actualización del sistema</string>
+ <string name="dm_session_information_notification_message1">El servidor ha iniciado una solicitud</string>
+ <string name="dm_session_information_notification_message2_success">El dispositivo ha completado la solicitud del servidor</string>
+ <string name="dm_session_information_notification_message2_fail">Falla del dispositivo al completar la solicitud del servidor</string>
+
+</resources>
diff --git a/DMService/res/values-es/strings.xml b/DMService/res/values-es/strings.xml
new file mode 100644
index 0000000..e24842f
--- /dev/null
+++ b/DMService/res/values-es/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Administración del dispositivo</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Mensaje del sistema</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">Aceptar</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Rechazar</string>
+ <string name="dm_session_button_confirm">"Actualizar"</string>
+ <string name="dm_session_button_reject">Cancelar</string>
+ <string name="dm_session_confirmation_title">Actualización del sistema</string>
+ <string name="dm_session_confirmation_message">Hay una actualización del sistema disponible para el teléfono</string>
+ <string name="dm_session_confirmation_notification_label">Actualización del sistema</string>
+ <string name="dm_session_confirmation_notification_message">Solicitud de sesión DM nueva</string>
+ <string name="dm_session_information_notification_label">Actualización del sistema</string>
+ <string name="dm_session_information_notification_message1">El servidor ha iniciado una solicitud</string>
+ <string name="dm_session_information_notification_message2_success">El dispositivo ha completado la solicitud del servidor</string>
+ <string name="dm_session_information_notification_message2_fail">El dispositivo no ha podido completar la solicitud del servidor</string>
+
+</resources>
diff --git a/DMService/res/values-fi/strings.xml b/DMService/res/values-fi/strings.xml
new file mode 100644
index 0000000..7bd951f
--- /dev/null
+++ b/DMService/res/values-fi/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Laitehallinta</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Järjestelmän sanoma</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Hylkää</string>
+ <string name="dm_session_button_confirm">Päivitä</string>
+ <string name="dm_session_button_reject">Peruuta</string>
+ <string name="dm_session_confirmation_title">Järjestelmäpäivitys</string>
+ <string name="dm_session_confirmation_message">Puhelimesi on saatavilla järjestelmäpäivitys</string>
+ <string name="dm_session_confirmation_notification_label">Järjestelmäpäivitys</string>
+ <string name="dm_session_confirmation_notification_message">Uusi DM-istuntopyyntö</string>
+ <string name="dm_session_information_notification_label">Järjestelmäpäivitys</string>
+ <string name="dm_session_information_notification_message1">Palvelin on aloittanut pyynnön</string>
+ <string name="dm_session_information_notification_message2_success">Laite on suorittanut palvelimen pyynnön</string>
+ <string name="dm_session_information_notification_message2_fail">Laite epäonnistui palvelimen pyynnön suorittamisessa</string>
+
+</resources>
diff --git a/DMService/res/values-fr/strings.xml b/DMService/res/values-fr/strings.xml
new file mode 100644
index 0000000..683015d
--- /dev/null
+++ b/DMService/res/values-fr/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Gestion des périphériques</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Message système</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">"OK"</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Rejeter</string>
+ <string name="dm_session_button_confirm">"Mettre à jour"</string>
+ <string name="dm_session_button_reject">Annuler</string>
+ <string name="dm_session_confirmation_title">Mise à jour système</string>
+ <string name="dm_session_confirmation_message">Une mise à jour système est disponible pour votre téléphone.</string>
+ <string name="dm_session_confirmation_notification_label">Mise à jour système</string>
+ <string name="dm_session_confirmation_notification_message">Nouvelle demande de session DM</string>
+ <string name="dm_session_information_notification_label">Mise à jour système</string>
+ <string name="dm_session_information_notification_message1">Le serveur a émis une requête</string>
+ <string name="dm_session_information_notification_message2_success">L\'appareil a traité la requête du serveur</string>
+ <string name="dm_session_information_notification_message2_fail">L\'appareil n\'a pas pu traiter la requête du serveur</string>
+
+</resources>
diff --git a/DMService/res/values-hr/strings.xml b/DMService/res/values-hr/strings.xml
new file mode 100644
index 0000000..8be2fb9
--- /dev/null
+++ b/DMService/res/values-hr/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Upravljanje uređajem</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Poruka sustava</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">U redu</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Odbij</string>
+ <string name="dm_session_button_confirm">Ažuriraj</string>
+ <string name="dm_session_button_reject">Odustani</string>
+ <string name="dm_session_confirmation_title">Ažuriranje sustava</string>
+ <string name="dm_session_confirmation_message">Dostupno je ažuriranje sustava za vaš telefon</string>
+ <string name="dm_session_confirmation_notification_label">Ažuriranje sustava</string>
+ <string name="dm_session_confirmation_notification_message">Novi zahtjev za sesiju upravljanja uređajem</string>
+ <string name="dm_session_information_notification_label">Ažuriranje sustava</string>
+ <string name="dm_session_information_notification_message1">Poslužitelj je pokrenuo zahtjev</string>
+ <string name="dm_session_information_notification_message2_success">Uređaj je izvršio zahtjev poslužitelja</string>
+ <string name="dm_session_information_notification_message2_fail">Uređaj nije uspio izvršiti zahtjev poslužitelja</string>
+
+</resources>
diff --git a/DMService/res/values-hu/strings.xml b/DMService/res/values-hu/strings.xml
new file mode 100644
index 0000000..5be2b1b
--- /dev/null
+++ b/DMService/res/values-hu/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Készülékkezelés</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Rendszerüzenet</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Elutasítás</string>
+ <string name="dm_session_button_confirm">Frissítés</string>
+ <string name="dm_session_button_reject">Mégse</string>
+ <string name="dm_session_confirmation_title">Rendszerfrissítés</string>
+ <string name="dm_session_confirmation_message">Rendszerfrissítés érhető el a telefon számára</string>
+ <string name="dm_session_confirmation_notification_label">Rendszerfrissítés</string>
+ <string name="dm_session_confirmation_notification_message">Új DM munkamenet kérés</string>
+ <string name="dm_session_information_notification_label">Rendszerfrissítés</string>
+ <string name="dm_session_information_notification_message1">A kiszolgáló kérést indított</string>
+ <string name="dm_session_information_notification_message2_success">A készülék teljesítette a kiszolgáló kérését</string>
+ <string name="dm_session_information_notification_message2_fail">A készülék nem tudta teljesíteni a kiszolgáló kérését</string>
+
+</resources>
diff --git a/DMService/res/values-it/strings.xml b/DMService/res/values-it/strings.xml
new file mode 100644
index 0000000..6abfa9f
--- /dev/null
+++ b/DMService/res/values-it/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">Servizio DM</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Gestione dispositivo</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Messaggio di sistema</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Rifiuta</string>
+ <string name="dm_session_button_confirm">"Aggiorna"</string>
+ <string name="dm_session_button_reject">Annulla</string>
+ <string name="dm_session_confirmation_title">Aggiornamento sistema</string>
+ <string name="dm_session_confirmation_message">È disponibile un aggiornamento di sistema per il telefono</string>
+ <string name="dm_session_confirmation_notification_label">Aggiornamento sistema</string>
+ <string name="dm_session_confirmation_notification_message">Nuova richiesta sessione DM</string>
+ <string name="dm_session_information_notification_label">Aggiornamento sistema</string>
+ <string name="dm_session_information_notification_message1">Il server ha avviato una richiesta</string>
+ <string name="dm_session_information_notification_message2_success">Il dispositivo ha completato la richiesta del server</string>
+ <string name="dm_session_information_notification_message2_fail">Il dispositivo non ha completato la richiesta del server</string>
+
+</resources>
diff --git a/DMService/res/values-iw/strings.xml b/DMService/res/values-iw/strings.xml
new file mode 100644
index 0000000..8c5826a
--- /dev/null
+++ b/DMService/res/values-iw/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">\u200fDMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">ניהול התקן</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">הודעת מערכת</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">×ישור</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">דחה</string>
+ <string name="dm_session_button_confirm">עדכן</string>
+ <string name="dm_session_button_reject">בטל</string>
+ <string name="dm_session_confirmation_title">עדכון מערכת</string>
+ <string name="dm_session_confirmation_message">עדכון מערכת זמין עבור הטלפון שלך</string>
+ <string name="dm_session_confirmation_notification_label">עדכון מערכת</string>
+ <string name="dm_session_confirmation_notification_message">בקשה חדשה להפעלת DM</string>
+ <string name="dm_session_information_notification_label">עדכון מערכת</string>
+ <string name="dm_session_information_notification_message1">השרת ×™×–× ×‘×§×©×”</string>
+ <string name="dm_session_information_notification_message2_success">ההתקן ×”×©×œ×™× ×ת בקשת השרת</string>
+ <string name="dm_session_information_notification_message2_fail">ההתקן ×œ× ×”×©×œ×™× ×ת בקשת השרת</string>
+
+</resources>
diff --git a/DMService/res/values-ja/strings.xml b/DMService/res/values-ja/strings.xml
new file mode 100644
index 0000000..0399712
--- /dev/null
+++ b/DMService/res/values-ja/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">デãƒã‚¤ã‚¹ç®¡ç†</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">システムメッセージ</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">æ‹’å¦</string>
+ <string name="dm_session_button_confirm">アップデート</string>
+ <string name="dm_session_button_reject">キャンセル</string>
+ <string name="dm_session_confirmation_title">システムアップデート</string>
+ <string name="dm_session_confirmation_message">ã”使用ã®é›»è©±æ©Ÿã«ã¯ã‚·ã‚¹ãƒ†ãƒ ã‚¢ãƒƒãƒ—デートãŒã‚ã‚Šã¾ã™ã€‚</string>
+ <string name="dm_session_confirmation_notification_label">システムアップデート</string>
+ <string name="dm_session_confirmation_notification_message">æ–°è¦ DM セッションã®ãƒªã‚¯ã‚¨ã‚¹ãƒˆ</string>
+ <string name="dm_session_information_notification_label">システムアップデート</string>
+ <string name="dm_session_information_notification_message1">サーãƒãƒ¼ãŒãƒªã‚¯ã‚¨ã‚¹ãƒˆã‚’開始ã—ã¾ã—ãŸ</string>
+ <string name="dm_session_information_notification_message2_success">デãƒã‚¤ã‚¹ã¯ã‚µãƒ¼ãƒãƒ¼ã®ãƒªã‚¯ã‚¨ã‚¹ãƒˆã‚’完了ã—ã¾ã—ãŸã€‚</string>
+ <string name="dm_session_information_notification_message2_fail">デãƒã‚¤ã‚¹ã¯ã‚µãƒ¼ãƒãƒ¼ã®ãƒªã‚¯ã‚¨ã‚¹ãƒˆã®å®Œäº†ã«å¤±æ•—ã—ã¾ã—ãŸã€‚</string>
+
+</resources>
diff --git a/DMService/res/values-ko/strings.xml b/DMService/res/values-ko/strings.xml
new file mode 100644
index 0000000..b7d7d3e
--- /dev/null
+++ b/DMService/res/values-ko/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">기기 관리</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">시스템 메시지</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">확ì¸</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">ê±°ì ˆ</string>
+ <string name="dm_session_button_confirm">ì—…ë°ì´íŠ¸</string>
+ <string name="dm_session_button_reject">취소</string>
+ <string name="dm_session_confirmation_title">시스템 ì—…ë°ì´íŠ¸</string>
+ <string name="dm_session_confirmation_message">íœ´ëŒ€ì „í™”ì˜ ì‹œìŠ¤í…œ ì—…ë°ì´íŠ¸ë¥¼ ì´ìš©í•  수 있습니다.</string>
+ <string name="dm_session_confirmation_notification_label">시스템 ì—…ë°ì´íŠ¸</string>
+ <string name="dm_session_confirmation_notification_message">새로운 DM 세션 요청</string>
+ <string name="dm_session_information_notification_label">시스템 ì—…ë°ì´íŠ¸</string>
+ <string name="dm_session_information_notification_message1">서버가 ìš”ì²­ì„ ì‹œìž‘í–ˆìŠµë‹ˆë‹¤.</string>
+ <string name="dm_session_information_notification_message2_success">기기가 ì„œë²„ì˜ ìš”ì²­ì„ ì™„ë£Œí–ˆìŠµë‹ˆë‹¤.</string>
+ <string name="dm_session_information_notification_message2_fail">기기가 ì„œë²„ì˜ ìš”ì²­ì„ ì™„ë£Œí•˜ëŠ” ë° ì‹¤íŒ¨í–ˆìŠµë‹ˆë‹¤.</string>
+
+</resources>
diff --git a/DMService/res/values-lt/strings.xml b/DMService/res/values-lt/strings.xml
new file mode 100644
index 0000000..92ae486
--- /dev/null
+++ b/DMService/res/values-lt/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Įrenginių tvarkytuvė</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Sistemos pranešimas</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">Gerai</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Atmesti</string>
+ <string name="dm_session_button_confirm">Atnaujinti</string>
+ <string name="dm_session_button_reject">Atšaukti</string>
+ <string name="dm_session_confirmation_title">Sistemos naujinys</string>
+ <string name="dm_session_confirmation_message">Yra sistemos naujinys jūsų telefonui</string>
+ <string name="dm_session_confirmation_notification_label">Sistemos naujinys</string>
+ <string name="dm_session_confirmation_notification_message">Nauja DM seanso užklausa</string>
+ <string name="dm_session_information_notification_label">Sistemos naujinys</string>
+ <string name="dm_session_information_notification_message1">Serveris inicijavo užklausą</string>
+ <string name="dm_session_information_notification_message2_success">Įrenginys užbaigė serverio užklausą</string>
+ <string name="dm_session_information_notification_message2_fail">Įrenginiui nepavyko užbaigti serverio užklausos</string>
+
+</resources>
diff --git a/DMService/res/values-lv/strings.xml b/DMService/res/values-lv/strings.xml
new file mode 100644
index 0000000..808445c
--- /dev/null
+++ b/DMService/res/values-lv/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">IerÄ«Äu pÄrvaldÄ«ba</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Sistēmas ziņojums</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">Labi</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Noraidīt</string>
+ <string name="dm_session_button_confirm">AtjauninÄt</string>
+ <string name="dm_session_button_reject">Atcelt</string>
+ <string name="dm_session_confirmation_title">SistÄ“mas atjauninÄjums</string>
+ <string name="dm_session_confirmation_message">JÅ«su tÄlrunim ir pieejams sistÄ“mas atjauninÄjums</string>
+ <string name="dm_session_confirmation_notification_label">SistÄ“mas atjauninÄjums</string>
+ <string name="dm_session_confirmation_notification_message">Jauns DM sesijas pieprasījums</string>
+ <string name="dm_session_information_notification_label">SistÄ“mas atjauninÄjums</string>
+ <string name="dm_session_information_notification_message1">Serveris ir uzsÄcis pieprasÄ«jumu</string>
+ <string name="dm_session_information_notification_message2_success">Ierīce ir izpildījusi servera pieprasījumu</string>
+ <string name="dm_session_information_notification_message2_fail">IerÄ«cei neizdevÄs izpildÄ«t servera pieprasÄ«jumu</string>
+
+</resources>
diff --git a/DMService/res/values-nb/strings.xml b/DMService/res/values-nb/strings.xml
new file mode 100644
index 0000000..06b4e5a
--- /dev/null
+++ b/DMService/res/values-nb/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Enhetsbehandling</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Systemmelding</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Avvis</string>
+ <string name="dm_session_button_confirm">Oppdater</string>
+ <string name="dm_session_button_reject">Avbryt</string>
+ <string name="dm_session_confirmation_title">Systemoppdatering</string>
+ <string name="dm_session_confirmation_message">En systemoppdatering er tilgjengelig for telefonen</string>
+ <string name="dm_session_confirmation_notification_label">Systemoppdatering</string>
+ <string name="dm_session_confirmation_notification_message">Ny forespørsel om enhetsbehandling</string>
+ <string name="dm_session_information_notification_label">Systemoppdatering</string>
+ <string name="dm_session_information_notification_message1">Serveren har iverksatt en forespørsel</string>
+ <string name="dm_session_information_notification_message2_success">Enheten har fullført serverens forespørsel</string>
+ <string name="dm_session_information_notification_message2_fail">Enheten kunne ikke fullføre serverens forespørsel</string>
+
+</resources>
diff --git a/DMService/res/values-nl/strings.xml b/DMService/res/values-nl/strings.xml
new file mode 100644
index 0000000..2ce41b1
--- /dev/null
+++ b/DMService/res/values-nl/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Apparaatbeheer</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Systeembericht</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Afwijzen</string>
+ <string name="dm_session_button_confirm">Bijwerken</string>
+ <string name="dm_session_button_reject">Annuleren</string>
+ <string name="dm_session_confirmation_title">Systeemupdate</string>
+ <string name="dm_session_confirmation_message">Systeemupdate voor uw telefoon is beschikbaar</string>
+ <string name="dm_session_confirmation_notification_label">Systeemupdate</string>
+ <string name="dm_session_confirmation_notification_message">Verzoek voor nieuwe DM-sessie</string>
+ <string name="dm_session_information_notification_label">Systeemupdate</string>
+ <string name="dm_session_information_notification_message1">Server heeft een verzoek gestart</string>
+ <string name="dm_session_information_notification_message2_success">Apparaat heeft het verzoek van de server uitgevoerd</string>
+ <string name="dm_session_information_notification_message2_fail">Apparaat heeft het verzoek van de server niet uitgevoerd</string>
+
+</resources>
diff --git a/DMService/res/values-pl/strings.xml b/DMService/res/values-pl/strings.xml
new file mode 100644
index 0000000..03e0ee9
--- /dev/null
+++ b/DMService/res/values-pl/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">Usługa DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">ZarzÄ…dzanie urzÄ…dzeniem</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Wiadomość systemowa</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">"OK"</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Odrzuć</string>
+ <string name="dm_session_button_confirm">"Aktualizuj"</string>
+ <string name="dm_session_button_reject">Anuluj</string>
+ <string name="dm_session_confirmation_title">Aktualizacja systemu</string>
+ <string name="dm_session_confirmation_message">Jest dostępna aktualizacja systemu do tego telefonu</string>
+ <string name="dm_session_confirmation_notification_label">Aktualizacja systemu</string>
+ <string name="dm_session_confirmation_notification_message">Żądanie nowej sesji DM</string>
+ <string name="dm_session_information_notification_label">Aktualizacja systemu</string>
+ <string name="dm_session_information_notification_message1">Serwer wysłał żądanie</string>
+ <string name="dm_session_information_notification_message2_success">Urządzenie wykonało żądanie serwera</string>
+ <string name="dm_session_information_notification_message2_fail">Urządzenie nie wykonało żądania serwera</string>
+
+</resources>
diff --git a/DMService/res/values-pt-rPT/strings.xml b/DMService/res/values-pt-rPT/strings.xml
new file mode 100644
index 0000000..567f955
--- /dev/null
+++ b/DMService/res/values-pt-rPT/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">Serviço DM</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Gestão de dispositivos</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Mensagem do sistema</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Rejeitar</string>
+ <string name="dm_session_button_confirm">"Atualizar"</string>
+ <string name="dm_session_button_reject">"Cancelar"</string>
+ <string name="dm_session_confirmation_title">Atualização do sistema</string>
+ <string name="dm_session_confirmation_message">Está disponível uma atualização do sistema para o telefone</string>
+ <string name="dm_session_confirmation_notification_label">Atualização do sistema</string>
+ <string name="dm_session_confirmation_notification_message">Pedido de nova sessão DM</string>
+ <string name="dm_session_information_notification_label">Atualização do sistema</string>
+ <string name="dm_session_information_notification_message1">O Servidor iniciou um pedido</string>
+ <string name="dm_session_information_notification_message2_success">O dispositivo concluiu o pedido do servidor</string>
+ <string name="dm_session_information_notification_message2_fail">O dispositivo falhou ao concluir o pedido do servidor</string>
+
+</resources>
diff --git a/DMService/res/values-pt/strings.xml b/DMService/res/values-pt/strings.xml
new file mode 100644
index 0000000..7780918
--- /dev/null
+++ b/DMService/res/values-pt/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">ServiçoDM</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Gerenciar dispositivo</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Mensagem do sistema</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Negar</string>
+ <string name="dm_session_button_confirm">Atualizar</string>
+ <string name="dm_session_button_reject">Cancelar</string>
+ <string name="dm_session_confirmation_title">Atualização do sistema</string>
+ <string name="dm_session_confirmation_message">Uma atualização do sistema para o seu telefone está disponível</string>
+ <string name="dm_session_confirmation_notification_label">Atualização do sistema</string>
+ <string name="dm_session_confirmation_notification_message">Nova solicitação de sessão de DM</string>
+ <string name="dm_session_information_notification_label">Atualização do sistema</string>
+ <string name="dm_session_information_notification_message1">O servidor iniciou uma solicitação</string>
+ <string name="dm_session_information_notification_message2_success">O dispositivo completou a solicitação do servidor</string>
+ <string name="dm_session_information_notification_message2_fail">Falha do dispositivo ao completar a solicitação do servidor</string>
+
+</resources>
diff --git a/DMService/res/values-ro/strings.xml b/DMService/res/values-ro/strings.xml
new file mode 100644
index 0000000..4a4e0ec
--- /dev/null
+++ b/DMService/res/values-ro/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Gestionare dispozitiv</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Mesaj de sistem</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Respingere</string>
+ <string name="dm_session_button_confirm">Actualizare</string>
+ <string name="dm_session_button_reject">Anulare</string>
+ <string name="dm_session_confirmation_title">Actualizare sistem</string>
+ <string name="dm_session_confirmation_message">Este disponibilă o actualizare a sistemului pentru telefonul dvs.</string>
+ <string name="dm_session_confirmation_notification_label">Actualizare sistem</string>
+ <string name="dm_session_confirmation_notification_message">Solicitare nouă sesiune DM</string>
+ <string name="dm_session_information_notification_label">Actualizare sistem</string>
+ <string name="dm_session_information_notification_message1">Serverul a iniţiat o solicitare</string>
+ <string name="dm_session_information_notification_message2_success">Dispozitivul a completat solicitarea serverului</string>
+ <string name="dm_session_information_notification_message2_fail">Dispozitivul nu a reuşit să încheie solicitarea serverului</string>
+
+</resources>
diff --git a/DMService/res/values-ru/strings.xml b/DMService/res/values-ru/strings.xml
new file mode 100644
index 0000000..f507c97
--- /dev/null
+++ b/DMService/res/values-ru/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Управление уÑтройÑтвом</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">СиÑтемное Ñообщение</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">ОК</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Отказать</string>
+ <string name="dm_session_button_confirm">Обновить</string>
+ <string name="dm_session_button_reject">Отмена</string>
+ <string name="dm_session_confirmation_title">Обновление ÑиÑтемы</string>
+ <string name="dm_session_confirmation_message">ДоÑтупно ÑиÑтемное обновление Ð´Ð»Ñ Ñ‚ÐµÐ»ÐµÑ„Ð¾Ð½Ð°</string>
+ <string name="dm_session_confirmation_notification_label">Обновление ÑиÑтемы</string>
+ <string name="dm_session_confirmation_notification_message">Ð—Ð°Ð¿Ñ€Ð¾Ñ Ð½Ð¾Ð²Ð¾Ð³Ð¾ ÑеанÑа DM</string>
+ <string name="dm_session_information_notification_label">Обновление ÑиÑтемы</string>
+ <string name="dm_session_information_notification_message1">Сервер инициировал запроÑ</string>
+ <string name="dm_session_information_notification_message2_success">УÑтройÑтво выполнило Ð·Ð°Ð¿Ñ€Ð¾Ñ Ñервера</string>
+ <string name="dm_session_information_notification_message2_fail">УÑтройÑтву не удалоÑÑŒ выполнить Ð·Ð°Ð¿Ñ€Ð¾Ñ Ñервера</string>
+
+</resources>
diff --git a/DMService/res/values-sk/strings.xml b/DMService/res/values-sk/strings.xml
new file mode 100644
index 0000000..2bb4d84
--- /dev/null
+++ b/DMService/res/values-sk/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Správa zariadenia</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Systémové hlásenie</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Zamietnuť</string>
+ <string name="dm_session_button_confirm">Aktualizovať</string>
+ <string name="dm_session_button_reject">Zrušiť</string>
+ <string name="dm_session_confirmation_title">Aktualizácia systému</string>
+ <string name="dm_session_confirmation_message">Aktualizácia systému je k dispozícii pre váš telefón</string>
+ <string name="dm_session_confirmation_notification_label">Aktualizácia systému</string>
+ <string name="dm_session_confirmation_notification_message">Žiadosť o novú reláciu DM</string>
+ <string name="dm_session_information_notification_label">Aktualizácia systému</string>
+ <string name="dm_session_information_notification_message1">Server inicioval požiadavku</string>
+ <string name="dm_session_information_notification_message2_success">Zariadenie dokonÄilo požiadavku servera</string>
+ <string name="dm_session_information_notification_message2_fail">Zariadeniu sa nepodarilo dokonÄiÅ¥ požiadavku servera</string>
+
+</resources>
diff --git a/DMService/res/values-sl/strings.xml b/DMService/res/values-sl/strings.xml
new file mode 100644
index 0000000..7b74106
--- /dev/null
+++ b/DMService/res/values-sl/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Upravljanje naprav</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Sistemsko sporoÄilo</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">V redu</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Zavrni</string>
+ <string name="dm_session_button_confirm">Posodobi</string>
+ <string name="dm_session_button_reject">PrekliÄi</string>
+ <string name="dm_session_confirmation_title">Posodobitev sistema</string>
+ <string name="dm_session_confirmation_message">Na voljo je posodobitev sistema za telefon</string>
+ <string name="dm_session_confirmation_notification_label">Posodobitev sistema</string>
+ <string name="dm_session_confirmation_notification_message">Zahteva za novo sejo neposrednih sporoÄil</string>
+ <string name="dm_session_information_notification_label">Posodobitev sistema</string>
+ <string name="dm_session_information_notification_message1">Strežnik je podal zahtevo</string>
+ <string name="dm_session_information_notification_message2_success">Naprava je izvedla zahtevo strežnika</string>
+ <string name="dm_session_information_notification_message2_fail">Naprava ni uspela izvesti zahteve strežnika</string>
+
+</resources>
diff --git a/DMService/res/values-sr/strings.xml b/DMService/res/values-sr/strings.xml
new file mode 100644
index 0000000..80a3c39
--- /dev/null
+++ b/DMService/res/values-sr/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Управљање уређајем</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">СиÑтемÑка порука</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">У реду</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Одбиј</string>
+ <string name="dm_session_button_confirm">Ðжурирај</string>
+ <string name="dm_session_button_reject">Откажи</string>
+ <string name="dm_session_confirmation_title">СиÑтемÑка иÑправка</string>
+ <string name="dm_session_confirmation_message">ДоÑтупна је ÑиÑтемÑка иÑправка за ваш телефон</string>
+ <string name="dm_session_confirmation_notification_label">СиÑтемÑка иÑправка</string>
+ <string name="dm_session_confirmation_notification_message">Захтев за нову DM ÑеÑију</string>
+ <string name="dm_session_information_notification_label">СиÑтемÑка иÑправка</string>
+ <string name="dm_session_information_notification_message1">Сервер је покренуо захтев</string>
+ <string name="dm_session_information_notification_message2_success">Уређај је обавио захтев Ñервера</string>
+ <string name="dm_session_information_notification_message2_fail">Уређај није уÑпео да обави захтев Ñервера</string>
+
+</resources>
diff --git a/DMService/res/values-sv/strings.xml b/DMService/res/values-sv/strings.xml
new file mode 100644
index 0000000..2311116
--- /dev/null
+++ b/DMService/res/values-sv/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Enhetshantering</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Systemmeddelande</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Avvisa</string>
+ <string name="dm_session_button_confirm">Uppdatera</string>
+ <string name="dm_session_button_reject">Avbryt</string>
+ <string name="dm_session_confirmation_title">Systemuppdatering</string>
+ <string name="dm_session_confirmation_message">Det finns en systemuppdatering för telefonen</string>
+ <string name="dm_session_confirmation_notification_label">Systemuppdatering</string>
+ <string name="dm_session_confirmation_notification_message">Ny DM-sessionsbegäran</string>
+ <string name="dm_session_information_notification_label">Systemuppdatering</string>
+ <string name="dm_session_information_notification_message1">Servern har initierat en begäran</string>
+ <string name="dm_session_information_notification_message2_success">Enheten har slutfört serverns begäran</string>
+ <string name="dm_session_information_notification_message2_fail">Enheten misslyckades med att slutföra serverns begäran</string>
+
+</resources>
diff --git a/DMService/res/values-th/strings.xml b/DMService/res/values-th/strings.xml
new file mode 100644
index 0000000..c961217
--- /dev/null
+++ b/DMService/res/values-th/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">à¸à¸²à¸£à¸ˆà¸±à¸”à¸à¸²à¸£à¸­à¸¸à¸›à¸à¸£à¸“์</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">ข้อความระบบ</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">ตà¸à¸¥à¸‡</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">ปà¸à¸´à¹€à¸ªà¸˜</string>
+ <string name="dm_session_button_confirm">อัพเดต</string>
+ <string name="dm_session_button_reject">ยà¸à¹€à¸¥à¸´à¸</string>
+ <string name="dm_session_confirmation_title">à¸à¸²à¸£à¸­à¸±à¸žà¹€à¸”ตระบบ</string>
+ <string name="dm_session_confirmation_message">มีà¸à¸²à¸£à¸­à¸±à¸žà¹€à¸”ตระบบสำหรับโทรศัพท์ของคุณ</string>
+ <string name="dm_session_confirmation_notification_label">à¸à¸²à¸£à¸­à¸±à¸žà¹€à¸”ตระบบ</string>
+ <string name="dm_session_confirmation_notification_message">คำขอรอบà¸à¸²à¸£à¹ƒà¸Šà¹‰ DM ใหม่</string>
+ <string name="dm_session_information_notification_label">à¸à¸²à¸£à¸­à¸±à¸žà¹€à¸”ตระบบ</string>
+ <string name="dm_session_information_notification_message1">เซิร์ฟเวอร์ได้สร้างคำขอ</string>
+ <string name="dm_session_information_notification_message2_success">อุปà¸à¸£à¸“์ได้ดำเนินà¸à¸²à¸£à¸•à¸²à¸¡à¸„ำขอของเซิร์ฟเวอร์เสร็จสมบูรณ์à¹à¸¥à¹‰à¸§</string>
+ <string name="dm_session_information_notification_message2_fail">อุปà¸à¸£à¸“์ไม่สามารถดำเนินà¸à¸²à¸£à¸•à¸²à¸¡à¸„ำขอของเซิร์ฟเวอร์ได้</string>
+
+</resources>
diff --git a/DMService/res/values-tr/strings.xml b/DMService/res/values-tr/strings.xml
new file mode 100644
index 0000000..8297ad3
--- /dev/null
+++ b/DMService/res/values-tr/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Cihaz Yönetimi</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Sistem Ä°letisi</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">"Tamam"</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Reddet</string>
+ <string name="dm_session_button_confirm">"Güncelle"</string>
+ <string name="dm_session_button_reject">Ä°ptal</string>
+ <string name="dm_session_confirmation_title">Sistem Güncellemesi</string>
+ <string name="dm_session_confirmation_message">Telefonunuz için bir sistem güncellemesi var</string>
+ <string name="dm_session_confirmation_notification_label">Sistem Güncellemesi</string>
+ <string name="dm_session_confirmation_notification_message">Yeni DM oturum isteÄŸi</string>
+ <string name="dm_session_information_notification_label">Sistem Güncellemesi</string>
+ <string name="dm_session_information_notification_message1">Sunucu bir istek başlattı</string>
+ <string name="dm_session_information_notification_message2_success">Cihaz sunucunun isteğini tamamladı</string>
+ <string name="dm_session_information_notification_message2_fail">Cihaz sunucunun isteğini tamamlayamadı</string>
+
+</resources>
diff --git a/DMService/res/values-uk/strings.xml b/DMService/res/values-uk/strings.xml
new file mode 100644
index 0000000..0650197
--- /dev/null
+++ b/DMService/res/values-uk/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">ÐšÐµÑ€ÑƒÐ²Ð°Ð½Ð½Ñ Ð¿Ñ€Ð¸Ñтроєм</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">СиÑтемне повідомленнÑ</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Відхилити</string>
+ <string name="dm_session_button_confirm">Оновити</string>
+ <string name="dm_session_button_reject">СкаÑувати</string>
+ <string name="dm_session_confirmation_title">ÐžÐ½Ð¾Ð²Ð»ÐµÐ½Ð½Ñ ÑиÑтеми</string>
+ <string name="dm_session_confirmation_message">З’ÑвилоÑÑ Ð¾Ð½Ð¾Ð²Ð»ÐµÐ½Ð½Ñ ÑиÑтеми Ð´Ð»Ñ Ð²Ð°ÑˆÐ¾Ð³Ð¾ телефону</string>
+ <string name="dm_session_confirmation_notification_label">ÐžÐ½Ð¾Ð²Ð»ÐµÐ½Ð½Ñ ÑиÑтеми</string>
+ <string name="dm_session_confirmation_notification_message">Запит нового ÑеанÑу ÐºÐµÑ€ÑƒÐ²Ð°Ð½Ð½Ñ Ð¿Ñ€Ð¸Ñтроєм</string>
+ <string name="dm_session_information_notification_label">ÐžÐ½Ð¾Ð²Ð»ÐµÐ½Ð½Ñ ÑиÑтеми</string>
+ <string name="dm_session_information_notification_message1">Сервер надіÑлав запит</string>
+ <string name="dm_session_information_notification_message2_success">ПриÑтрій виконав запит Ñервера</string>
+ <string name="dm_session_information_notification_message2_fail">ПриÑтрій не виконав запит Ñервера</string>
+
+</resources>
diff --git a/DMService/res/values-vi/strings.xml b/DMService/res/values-vi/strings.xml
new file mode 100644
index 0000000..e9391a7
--- /dev/null
+++ b/DMService/res/values-vi/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Quản lý thiết bị</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">Tin nhắn hệ thống</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Từ chối</string>
+ <string name="dm_session_button_confirm">Cập nhật</string>
+ <string name="dm_session_button_reject">Hủy</string>
+ <string name="dm_session_confirmation_title">Cập nhật hệ thống</string>
+ <string name="dm_session_confirmation_message">Cập nhật hệ thống cho điện thoại của bạn khả dụng</string>
+ <string name="dm_session_confirmation_notification_label">Cập nhật hệ thống</string>
+ <string name="dm_session_confirmation_notification_message">Yêu cầu phiên DM mới</string>
+ <string name="dm_session_information_notification_label">Cập nhật hệ thống</string>
+ <string name="dm_session_information_notification_message1">Máy chủ đã khởi chạy yêu cầu</string>
+ <string name="dm_session_information_notification_message2_success">Thiết bị đã hoàn thành yêu cầu của máy chủ</string>
+ <string name="dm_session_information_notification_message2_fail">Thiết bị không hoàn thành yêu cầu của máy chủ</string>
+
+</resources>
diff --git a/DMService/res/values-zh-rCN/strings.xml b/DMService/res/values-zh-rCN/strings.xml
new file mode 100644
index 0000000..ba0263c
--- /dev/null
+++ b/DMService/res/values-zh-rCN/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">设备管ç†æœåŠ¡</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">设备管ç†</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">系统信æ¯</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">确定</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">æ‹’ç»</string>
+ <string name="dm_session_button_confirm">æ›´æ–°</string>
+ <string name="dm_session_button_reject">å–消</string>
+ <string name="dm_session_confirmation_title">系统更新</string>
+ <string name="dm_session_confirmation_message">手机系统更新å¯ç”¨</string>
+ <string name="dm_session_confirmation_notification_label">系统更新</string>
+ <string name="dm_session_confirmation_notification_message">新设备管ç†ä¼šè¯è¯·æ±‚</string>
+ <string name="dm_session_information_notification_label">系统更新</string>
+ <string name="dm_session_information_notification_message1">æœåŠ¡å™¨å·²å‘起一个请求</string>
+ <string name="dm_session_information_notification_message2_success">设备已完æˆæœåŠ¡å™¨çš„请求</string>
+ <string name="dm_session_information_notification_message2_fail">设备无法完æˆæœåŠ¡å™¨çš„请求</string>
+
+</resources>
diff --git a/DMService/res/values-zh-rTW/strings.xml b/DMService/res/values-zh-rTW/strings.xml
new file mode 100644
index 0000000..f3a85f2
--- /dev/null
+++ b/DMService/res/values-zh-rTW/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string name="app_name">"è£ç½®ç®¡ç†æœå‹™"</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">"è£ç½®ç®¡ç†"</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">"系統訊æ¯"</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">"確定"</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">"拒絕"</string>
+ <string name="dm_session_button_confirm">"æ›´æ–°"</string>
+ <string name="dm_session_button_reject">"å–消"</string>
+ <string name="dm_session_confirmation_title">"系統更新"</string>
+ <string name="dm_session_confirmation_message">"手機系統更新å¯ç”¨"</string>
+ <string name="dm_session_confirmation_notification_label">"系統更新"</string>
+ <string name="dm_session_confirmation_notification_message">"æ–°è£ç½®ç®¡ç†æœƒè©±è¦æ±‚"</string>
+ <string name="dm_session_information_notification_label">"系統更新"</string>
+ <string name="dm_session_information_notification_message1">"伺æœå™¨å·²èµ·å§‹è¦æ±‚"</string>
+ <string name="dm_session_information_notification_message2_success">"è£ç½®å·²å®Œæˆä¼ºæœå™¨çš„è¦æ±‚"</string>
+ <string name="dm_session_information_notification_message2_fail">"è£ç½®ç„¡æ³•å®Œæˆä¼ºæœå™¨çš„è¦æ±‚"</string>
+
+</resources>
diff --git a/DMService/res/values/dmAccounts.xml b/DMService/res/values/dmAccounts.xml
new file mode 100644
index 0000000..d859146
--- /dev/null
+++ b/DMService/res/values/dmAccounts.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string-array name="dm_account_info">
+ <!-- <item>AccName, ServerID, Addr, AddrType, PortNbr, ConRef, ServerName, AuthPref, ServerPW, ServerNonce, UserName, ClientPW, ClientNonce, ProxyAddr, ProxyPortNbr</item> -->
+ </string-array>
+</resources>
diff --git a/DMService/res/values/strings.xml b/DMService/res/values/strings.xml
new file mode 100644
index 0000000..daade9d
--- /dev/null
+++ b/DMService/res/values/strings.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">DMService</string>
+ <string name="DM_SERVICE_ALERT_TITLE_DEVICE_MGMT">Device Management</string>
+ <string name="DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE">System Message</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_YES">OK</string>
+ <string name="DM_SERVICE_ALERT_BUTTON_NO">Reject</string>
+
+ <string name="dm_session_button_confirm">Update</string>
+ <string name="dm_session_button_reject">Cancel</string>
+ <string name="dm_session_confirmation_title">System Update</string>
+ <string name="dm_session_confirmation_message">System update for your phone is available</string>
+ <string name="dm_session_confirmation_notification_label">System Update</string>
+ <string name="dm_session_confirmation_notification_message">New DM session request</string>
+ <!-- <string name="dm_session_information_notification_label">System Update</string>
+ <string name="dm_session_information_notification_message1">Server has initiated a request</string>
+ <string name="dm_session_information_notification_message2_success">Device has completed server\'s request</string>
+ <string name="dm_session_information_notification_message2_fail">Device failed to complete server\'s request</string> -->
+ <string name="dm_session_information_notification_label">Network Update</string>
+ <string name="dm_session_information_notification_message1">The network is preparing service.</string>
+ <string name="dm_session_information_notification_message2_success">Network update successful</string>
+ <string name="dm_session_information_notification_message2_fail">Network update failed</string>
+
+</resources>
diff --git a/DMService/res/xml/initial_dmt.xml b/DMService/res/xml/initial_dmt.xml
new file mode 100644
index 0000000..fe33fd9
--- /dev/null
+++ b/DMService/res/xml/initial_dmt.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<dmtree>
+ <node name=".">
+ <node name="CDMA">
+ <node name="BC10" type="int" access="GR"/>
+ <node name="BC14" type="int" access="GR"/>
+ <node name="RoamPreference" type="bin" access="GR"/>
+ <node name="SO68" type="int" access="GR"/>
+ <node name="1xA">
+ <node name="Enabled" type="int" access="GR"/>
+ </node>
+ <node name="3GPD">
+ <node name="*" access="AGRD" acl="FIXME">
+ <node name="AuthAlgoAAA" type="chr" access="GR"/>
+ <node name="AuthAlgoHA" type="chr" access="GR"/>
+ <node name="MobileIpAddress" type="chr" access="GR"/>
+ <node name="NAI" type="chr" access="GR"/>
+ <node name="PasswordAAA" type="chr" access="GR"/>
+ <node name="PasswordHA" type="chr" access="GR"/>
+ <node name="PriHAIp" type="chr" access="GR"/>
+ <node name="ReverseTunneling" type="chr" access="GR"/>
+ <node name="SecHAIp" type="chr" access="GR"/>
+ <node name="SpiAAA" type="chr" access="GR"/>
+ <node name="SpiHA" type="chr" access="GR"/>
+ </node>
+ </node>
+ <node name="B25">
+ <node name="enablement" type="int" access="GR"/>
+ <node name="scanpriority" type="int" access="GR"/>
+ </node>
+ <node name="B26">
+ <node name="enablement" type="int" access="GR"/>
+ <node name="scanpriority" type="int" access="GR"/>
+ </node>
+ <node name="B41">
+ <node name="enablement" type="int" access="GR"/>
+ <node name="scanpriority" type="int" access="GR"/>
+ </node>
+ <node name="EHRPD">
+ <node name="Enabled" type="int" access="GR"/>
+ <node name="Forced" type="int" access="GR"/>
+ </node>
+ <node name="NAM">
+ <node name="CdmaNam" type="bin" access="GR"/>
+ <node name="MobDirNum" type="bin" access="GR"/>
+ </node>
+ </node>
+ </node>
+</dmtree>
diff --git a/DMService/src/com/android/omadm/service/DMAlert.java b/DMService/src/com/android/omadm/service/DMAlert.java
new file mode 100644
index 0000000..063f7b8
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMAlert.java
@@ -0,0 +1,552 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.text.InputType;
+import android.util.Log;
+
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+public class DMAlert {
+
+ /* DMServiceAlert Response Code */
+ private static final int DM_SERVICE_ALERT_RESP_FAIL = -1;
+
+ public static final int DM_SERVICE_ALERT_RESP_SUCCESS = 0;
+
+ public static final int DM_SERVICE_ALERT_RESP_NO = 1;
+
+ public static final int DM_SERVICE_ALERT_RESP_YES = 2;
+
+ public static final int DM_SERVICE_ALERT_RESP_CANCEL = 3;
+
+ public static final int DM_SERVICE_ALERT_RESP_TIMEOUT = 4;
+
+ // DMServiceAlert Input Type
+ private static final int DM_SERVICE_ALERT_INPUT_ALPHA = 0;
+
+ private static final int DM_SERVICE_ALERT_INPUT_NUMERIC = 1;
+
+ private static final int DM_SERVICE_ALERT_INPUT_DATE = 2;
+
+ private static final int DM_SERVICE_ALERT_INPUT_TIME = 3;
+
+ private static final int DM_SERVICE_ALERT_INPUT_PHONE_NUM = 4;
+
+ private static final int DM_SERVICE_ALERT_INPUT_IP_ADDR = 5;
+
+ // DMServiceAlert Echo Type
+ public static final int DM_SERVICE_ALERT_ECHO_TEXT = 0;
+
+ private static final int DM_SERVICE_ALERT_ECHO_PASSWD = 1;
+
+ // DMServiceAlert Icon Type
+ private static final int DM_SERVICE_ALERT_ICON_GENERIC = 0;
+
+ public static final int DM_SERVICE_ALERT_ICON_PROGRESS = 1;
+
+ public static final int DM_SERVICE_ALERT_ICON_OK = 2;
+
+ public static final int DM_SERVICE_ALERT_ICON_ERROR = 3;
+
+ public static final int DM_SERVICE_ALERT_ICON_CONFIRM = 4;
+
+ public static final int DM_SERVICE_ALERT_ICON_ACTION = 5;
+
+ public static final int DM_SERVICE_ALERT_ICON_INFO = 6;
+
+ // DMServiceAlert Title Type
+ private static final int DM_SERVICE_ALERT_TITLE_DEVICE_MGMT = 0;
+
+ public static final int DM_SERVICE_ALERT_TITLE_SYSTEM_UPDATE = 1;
+
+ public static final int DM_SERVICE_ALERT_TITLE_NEED_AUTHENTICATION = 2;
+
+ public static final int DM_SERVICE_ALERT_TITLE_UPDATE_COMPLETE = 3;
+
+ private static final int DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE = 4;
+
+ public static final int DM_SERVICE_ALERT_TITLE_AUTHENTICATION_FAILED = 5;
+
+ public static final int DM_SERVICE_ALERT_TITLE_UPDATE_ERROR = 6;
+
+ public static final int DM_SERVICE_ALERT_TITLE_UPDATE_CANCELLED = 7;
+
+ public static final int DM_SERVICE_ALERT_TITLE_PROFILE_FOR_BROWSER = 8;
+
+ public static final int DM_SERVICE_ALERT_TITLE_PROFILE_FOR_MMS = 9;
+
+ public static final int DM_SERVICE_ALERT_TITLE_CONNECTION_FAILED = 10;
+
+ public static final int DM_SERVICE_ALERT_TITLE_CONNECTION_FAILURE = 11;
+
+ public static final int DM_SERVICE_ALERT_TITLE_SW_UPDATE = 12;
+
+ private final Context mCtx;
+
+ private boolean mUIMode;
+
+ private Lock mLock;
+
+ private Condition mCond;
+
+ private int mResultCode;
+
+ private String mResultData;
+
+ private int mResultCheckedItem;
+
+ private boolean[] mResultCheckedItems;
+
+ public DMAlert(Context ctx) {
+ mCtx = ctx;
+ mUIMode = true;
+ }
+
+ public void setUIMode(boolean uiMode) {
+ mUIMode = uiMode;
+ }
+
+ // used for the test only
+ public boolean getUIMode() {
+ return mUIMode;
+ }
+
+ /**
+ * Display a text message. Called from JNI code.
+ *
+ * @param minDisplayTime minimum display time, in seconds.
+ * @param msg messages to display
+ * @param title resource ID for dialog title
+ * @param icon resource ID for dialog icon
+ * @return SYNCML_DM_SUCCESS on successful completion; SYNCML_DM_FAIL or another more specific
+ * error code on failure.
+ */
+ public int showDisplayAlert(int minDisplayTime, String msg, int title, int icon) {
+ //if ( !mUIMode) return DM_SERVICE_ALERT_RESP_FAIL;
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(DMIntent.DM_ALERT_DLG_CLOSED);
+
+ Intent intent = new Intent(DMIntent.SHOW_DISPLAY_ALERT_DLG);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClass(mCtx, DMAlertActivity.class);
+
+ intent.putExtra("Message", msg);
+ intent.putExtra("Title", getTitle(title));
+ intent.putExtra("Icon", getIcon(icon));
+ intent.putExtra("Timeout", minDisplayTime);
+
+ try {
+ mCtx.startActivity(intent);
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ return DM_SERVICE_ALERT_RESP_FAIL;
+ }
+
+ return DM_SERVICE_ALERT_RESP_SUCCESS;
+ }
+
+ /**
+ * Display a confirmation alert dialog: user can confirm or cancel the action. Called from JNI
+ * code.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param title resource ID for dialog title
+ * @param icon resource ID for dialog icon
+ * @return SYNCML_DM_SUCCESS on successful completion; SYNCML_DM_FAIL or another more specific
+ * error code on failure.
+ */
+ public int showConfirmAlert(int maxDisplayTime, String msg, int title, int icon) {
+ //if ( !mUIMode) return DM_SERVICE_ALERT_RESP_FAIL;
+
+ mLock = new ReentrantLock();
+ mCond = mLock.newCondition();
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(DMIntent.DM_ALERT_DLG_CLOSED);
+ mCtx.registerReceiver(mAlertCloseListener, filter);
+
+ Intent intent = new Intent(DMIntent.SHOW_CONFIRM_ALERT_DLG);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClass(mCtx, DMAlertActivity.class);
+
+ intent.putExtra("Message", msg);
+ intent.putExtra("Title", getTitle(title));
+ intent.putExtra("Icon", getIcon(icon));
+ intent.putExtra("Timeout", maxDisplayTime);
+
+ mCtx.startActivity(intent);
+
+ mLock.lock();
+ try {
+ mCond.await();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ mLock.unlock();
+ mCtx.unregisterReceiver(mAlertCloseListener);
+ }
+
+ return mResultCode;
+ }
+
+ /**
+ * Display a text input message box for user to enter input. Called from JNI code.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param defaultText default user action when timeout
+ * @param maxLength length allowed in user input
+ * @param inputType data format as specified in DM_ALERT_INPUT_T
+ * @param echoType whether to echo user input (hidden for password ) as specified in
+ * DM_ALERT_ECHO_T
+ * @param title either DM_SERVICE_ALERT_TITLE_DEVICE_MGMT or DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE
+ * @param icon is DM_SERVICE_ALERT_ICON_GENERIC
+ * @return SYNCML_DM_SUCCESS on successful completion; SYNCML_DM_FAIL or another more specific
+ * error code on failure.
+ */
+ public String showTextInputAlert(int maxDisplayTime, String msg, String defaultText,
+ int maxLength, int inputType, int echoType,
+ int title, int icon) {
+ //if ( !mUIMode) return String.valueOf(DM_SERVICE_ALERT_RESP_FAIL);
+
+ mLock = new ReentrantLock();
+ mCond = mLock.newCondition();
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(DMIntent.DM_ALERT_DLG_CLOSED);
+ mCtx.registerReceiver(mAlertCloseListener, filter);
+
+ Intent intent = new Intent(DMIntent.SHOW_TEXTINPUT_ALERT_DLG);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClass(mCtx, DMAlertActivity.class);
+
+ intent.putExtra("Message", msg);
+ intent.putExtra("Title", getTitle(title));
+ intent.putExtra("Icon", getIcon(icon));
+ intent.putExtra("Timeout", maxDisplayTime);
+ intent.putExtra("DefaultText", defaultText);
+ intent.putExtra("MaxLength", maxLength);
+ intent.putExtra("InputType", getInputType(inputType, echoType));
+
+ Log.d("showTextInputAlert", "Dialog Intent: " + intent);
+
+ mCtx.startActivity(intent);
+
+ mLock.lock();
+ try {
+ mCond.await();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ mLock.unlock();
+ mCtx.unregisterReceiver(mAlertCloseListener);
+ }
+
+ return String.valueOf(mResultCode) + ':' + mResultData;
+ }
+
+ /**
+ * Display a single choice message box for user to pick up one entry. Called from JNI code.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param choices an array of strings containing the text for each choice
+ * @param checkedItem the default checked entry
+ * @param title resource ID for dialog title
+ * @param icon resource ID for dialog icon
+ * @return SYNCML_DM_SUCCESS on successful completion; SYNCML_DM_FAIL or another more specific
+ * error code on failure.
+ */
+ public String showSingleChoiceAlert(int maxDisplayTime, String msg, String[] choices,
+ int checkedItem, int title, int icon) {
+ //if ( !mUIMode) return String.valueOf(DM_SERVICE_ALERT_RESP_FAIL);
+
+ mLock = new ReentrantLock();
+ mCond = mLock.newCondition();
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(DMIntent.DM_ALERT_DLG_CLOSED);
+ mCtx.registerReceiver(mAlertCloseListener, filter);
+
+ Intent intent = new Intent(DMIntent.SHOW_SINGLECHOICE_ALERT_DLG);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClass(mCtx, DMAlertActivity.class);
+
+ intent.putExtra("Message", msg);
+ intent.putExtra("Title", getTitle(title));
+ intent.putExtra("Icon", getIcon(icon));
+ intent.putExtra("Timeout", maxDisplayTime);
+ intent.putExtra("Choices", choices);
+ intent.putExtra("CheckedItem", checkedItem);
+
+ Log.d("showSingleChoiceAlert", "Dialog Intent: " + intent);
+
+ mCtx.startActivity(intent);
+
+ mLock.lock();
+ try {
+ mCond.await();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ mLock.unlock();
+ mCtx.unregisterReceiver(mAlertCloseListener);
+ }
+
+ return String.valueOf(mResultCode) + ':' + mResultCheckedItem;
+ }
+
+ /**
+ * Display a multiple choice message box for user to pick up zero to many entry. Called from JNI
+ * code.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param choices an array of strings to hold text for each choice
+ * @param checkedItems an array of booleans to indicate the checked items
+ * @param title resource ID for dialog title
+ * @param icon resource ID for dialog icon
+ * @return SYNCML_DM_SUCCESS on successful completion; SYNCML_DM_FAIL or another more specific
+ * error code on failure.
+ */
+ public int showMultipleChoiceAlert(int maxDisplayTime, String msg, String[] choices,
+ boolean[] checkedItems, int title, int icon) {
+ //if ( !mUIMode) return DM_SERVICE_ALERT_RESP_FAIL;
+
+ mLock = new ReentrantLock();
+ mCond = mLock.newCondition();
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(DMIntent.DM_ALERT_DLG_CLOSED);
+ mCtx.registerReceiver(mAlertCloseListener, filter);
+
+ Intent intent = new Intent(DMIntent.SHOW_MULTICHOICE_ALERT_DLG);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClass(mCtx, DMAlertActivity.class);
+
+ intent.putExtra("Message", msg);
+ intent.putExtra("Title", getTitle(title));
+ intent.putExtra("Icon", getIcon(icon));
+ intent.putExtra("Timeout", maxDisplayTime);
+ intent.putExtra("Choices", choices);
+ intent.putExtra("CheckedItems", checkedItems);
+
+ Log.d("showMultiChoiceAlert", "Dialog Intent: " + intent);
+
+ mCtx.startActivity(intent);
+
+ mLock.lock();
+ try {
+ mCond.await();
+ } catch (InterruptedException e) {
+ Log.e("DMAlert", "lock/await interrupted", e); // FIXME logging
+ } finally {
+ mLock.unlock();
+ mCtx.unregisterReceiver(mAlertCloseListener);
+ }
+
+ int checkedItemsLength = checkedItems.length;
+ for (int i = 0; DM_SERVICE_ALERT_RESP_YES == mResultCode && i < checkedItemsLength; i++) {
+ checkedItems[i] = mResultCheckedItems[i];
+ }
+
+ return mResultCode;
+ }
+
+ /**
+ * Display a progress bar. FIXME: remove if unused.
+ *
+ * @param minDisplayTime minimum display time, in seconds.
+ * @param msg messages to display
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ */
+ public int showProgressAlert(int minDisplayTime, String msg, int title, int icon) {
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(DMIntent.DM_ALERT_DLG_CLOSED);
+
+ Intent intent = new Intent(DMIntent.SHOW_PROGRESS_ALERT_DLG);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClass(mCtx, DMAlertActivity.class);
+
+ intent.putExtra("Message", msg);
+ intent.putExtra("Title", getTitle(title));
+ intent.putExtra("Icon", getIcon(icon));
+ intent.putExtra("Timeout", minDisplayTime);
+
+ try {
+ mCtx.startActivity(intent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return DM_SERVICE_ALERT_RESP_FAIL;
+ }
+
+ return DM_SERVICE_ALERT_RESP_SUCCESS;
+ }
+
+ /**
+ * Hide a progress bar. FIXME: remove if unneeded.
+ *
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ */
+ public int hideProgressAlert() {
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(DMIntent.DM_ALERT_DLG_CLOSED);
+
+ Intent intent = new Intent(DMIntent.HIDE_PROGRESS_ALERT_DLG);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClass(mCtx, DMAlertActivity.class);
+
+ try {
+ mCtx.startActivity(intent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return DM_SERVICE_ALERT_RESP_FAIL;
+ }
+
+ return DM_SERVICE_ALERT_RESP_SUCCESS;
+ }
+
+ /**
+ * Cancel alert when DM session times out.
+ */
+ public void cancelSession() {
+ if (!mUIMode) {
+ return;
+ }
+
+ Intent intent = new Intent(DMIntent.CANCEL_ALERT_DLG);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setClass(mCtx, DMAlertActivity.class);
+
+ try {
+ mCtx.startActivity(intent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String getTitle(int t) {
+ switch (t) {
+ case DM_SERVICE_ALERT_TITLE_DEVICE_MGMT:
+ return mCtx.getResources().getString(R.string.DM_SERVICE_ALERT_TITLE_DEVICE_MGMT);
+ case DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE:
+ return mCtx.getResources()
+ .getString(R.string.DM_SERVICE_ALERT_TITLE_SYSTEM_MESSAGE);
+ default:
+ break;
+ }
+ return "Title ID: " + t;
+ }
+
+ private static int getIcon(int i) {
+ switch (i) {
+ case DM_SERVICE_ALERT_ICON_GENERIC:
+ return R.drawable.alert_dialog_icon;
+ default:
+ break;
+ }
+ return R.drawable.alert_dialog_icon;
+ }
+
+ private static int getInputType(int i, int e) {
+ int t = InputType.TYPE_CLASS_TEXT;
+ switch (i) {
+ case DM_SERVICE_ALERT_INPUT_ALPHA:
+ t = InputType.TYPE_CLASS_TEXT;
+ break;
+ case DM_SERVICE_ALERT_INPUT_NUMERIC:
+ t = InputType.TYPE_CLASS_NUMBER;
+ break;
+ case DM_SERVICE_ALERT_INPUT_DATE:
+ t = InputType.TYPE_DATETIME_VARIATION_DATE;
+ break;
+ case DM_SERVICE_ALERT_INPUT_TIME:
+ t = InputType.TYPE_DATETIME_VARIATION_TIME;
+ break;
+ case DM_SERVICE_ALERT_INPUT_PHONE_NUM:
+ t = InputType.TYPE_CLASS_PHONE;
+ break;
+ case DM_SERVICE_ALERT_INPUT_IP_ADDR:
+ t = InputType.TYPE_CLASS_TEXT;
+ break;
+ default:
+ break;
+ }
+
+ if (e == DM_SERVICE_ALERT_ECHO_PASSWD) {
+ t |= InputType.TYPE_TEXT_VARIATION_PASSWORD;
+ }
+ return t;
+ }
+
+ private final BroadcastReceiver mAlertCloseListener = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mLock.lock();
+ try {
+ onReceiveLocked(intent);
+ } finally {
+ mLock.unlock();
+ }
+ }
+
+ private void onReceiveLocked(Intent intent) {
+ mResultCode = intent.getIntExtra("ResultCode", DM_SERVICE_ALERT_RESP_SUCCESS);
+ if (DMClientService.DBG) {
+ Log.d("mAlertCloseListener", "Dialog ResultCode: " + mResultCode);
+ }
+
+ mResultData = intent.getStringExtra("ResultData");
+ if (null != mResultData) {
+ if (DMClientService.DBG) {
+ Log.d("mAlertCloseListener", "Dialog ResultData: " + mResultData);
+ }
+ }
+
+ mResultCheckedItem = intent.getIntExtra("ResultCheckedItem", -1);
+ if (-1 != mResultCheckedItem) {
+ if (DMClientService.DBG) {
+ Log.d("mAlertCloseListener", "Dialog ResultCheckedItem: " + mResultCheckedItem);
+ }
+ }
+
+ boolean[] resultCheckedItems = intent.getBooleanArrayExtra("ResultCheckedItems");
+ mResultCheckedItems = resultCheckedItems;
+
+ if (DMClientService.DBG && resultCheckedItems != null) {
+ int resultCheckedItemsLength = resultCheckedItems.length;
+ for (int i = 0; i < resultCheckedItemsLength; i++) {
+ Log.d("mAlertCloseListener",
+ "Dialog ResultCheckedItems " + i + ": " + resultCheckedItems[i]);
+ }
+ }
+
+ mCond.signalAll();
+ }
+ };
+}
diff --git a/DMService/src/com/android/omadm/service/DMAlertActivity.java b/DMService/src/com/android/omadm/service/DMAlertActivity.java
new file mode 100644
index 0000000..3919540
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMAlertActivity.java
@@ -0,0 +1,527 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.KeyguardManager;
+import android.app.ProgressDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.PowerManager;
+import android.text.InputFilter;
+import android.text.InputType;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.EditText;
+
+import java.util.Arrays;
+
+public class DMAlertActivity extends Activity {
+ private static final String TAG = "DMAlertActivity";
+ private static final boolean DBG = DMClientService.DBG;
+
+ private static final int DISPLAY_ALERT_DIALOG = 1;
+
+ private static final int CONFIRM_ALERT_DIALOG = 2;
+
+ private static final int TEXTINPUT_ALERT_DIALOG = 3;
+
+ private static final int SINGLECHOICE_ALERT_DIALOG = 4;
+
+ private static final int MULTICHOICE_ALERT_DIALOG = 5;
+
+ private static final int SHOW_PROGRESS_ALERT_DIALOG = 6;
+
+ private static final int HIDE_PROGRESS_ALERT_DIALOG = 7;
+
+ private static final int CANCEL_ALERT_DIALOG = 8;
+
+ private static AlertDialog mDialog;
+
+ private Runnable mDialogTimeout;
+
+ private KeyReceiver mKeyReceiver;
+
+ private static PowerManager.WakeLock wl;
+
+ private KeyguardManager.KeyguardLock mKeyguardLock;
+
+ private int mType;
+
+ private String mMessage;
+
+ private String mTitle;
+
+ private int mIcon;
+
+ private int mTimeout;
+
+ private int mMaxLength;
+
+ private EditText mInputBox;
+
+ private int mInputType;
+
+ private String[] mChoices;
+
+ private int mCheckedItem;
+
+ private boolean[] mCheckedItems;
+
+ private int mResultCode; // == DMAlert.DM_SERVICE_ALERT_RESP_SUCCESS (0)
+
+ private String mResultData;
+
+ private Handler mHandler;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (DBG) {
+ logd("onCreate");
+ }
+
+ final Intent intent = getIntent();
+ mMessage = intent.getStringExtra("Message");
+ mTitle = intent.getStringExtra("Title");
+ mIcon = intent.getIntExtra("Icon", -1);
+ mTimeout = intent.getIntExtra("Timeout", 0);
+ if (DBG) {
+ logd("mMessage: " + mMessage);
+ }
+ if (DBG) {
+ logd("mTitle: " + mTitle);
+ }
+ if (DBG) {
+ logd("mIcon: " + mIcon);
+ }
+ if (DBG) {
+ logd("mTimeout: " + mTimeout);
+ }
+
+ String action = intent.getAction();
+ if (action.equals(DMIntent.SHOW_DISPLAY_ALERT_DLG)) {
+ mType = DISPLAY_ALERT_DIALOG;
+ } else if (action.equals(DMIntent.SHOW_CONFIRM_ALERT_DLG)) {
+ mType = CONFIRM_ALERT_DIALOG;
+ } else if (action.equals(DMIntent.SHOW_TEXTINPUT_ALERT_DLG)) {
+ mType = TEXTINPUT_ALERT_DIALOG;
+ mMaxLength = intent.getIntExtra("MaxLength", 80);
+ if (DBG) {
+ logd("mMaxLength: " + mMaxLength);
+ }
+ mInputType = intent.getIntExtra("InputType", InputType.TYPE_CLASS_TEXT);
+ if (DBG) {
+ logd("mInputType: " + mInputType);
+ }
+ mResultData = intent.getStringExtra("DefaultText");
+ if (DBG) {
+ logd("mResultData: " + mResultData);
+ }
+ } else if (action.equals(DMIntent.SHOW_SINGLECHOICE_ALERT_DLG)) {
+ mType = SINGLECHOICE_ALERT_DIALOG;
+ mChoices = intent.getStringArrayExtra("Choices");
+ mCheckedItem = intent.getIntExtra("CheckedItem", -1);
+ for (int i = 0; i < mChoices.length; i++) {
+ if (DMClientService.DBG) {
+ logd("mChoices: " + i + ": " + mChoices[i]);
+ }
+ }
+ if (DMClientService.DBG) {
+ logd("mCheckedItem: " + mCheckedItem);
+ }
+ } else if (action.equals(DMIntent.SHOW_MULTICHOICE_ALERT_DLG)) {
+ mType = MULTICHOICE_ALERT_DIALOG;
+ mChoices = intent.getStringArrayExtra("Choices");
+ for (int i = 0; i < mChoices.length; i++) {
+ if (DMClientService.DBG) {
+ logd("mChoices " + i + ": " + mChoices[i]);
+ }
+ }
+ mCheckedItems = intent.getBooleanArrayExtra("CheckedItems");
+ for (int i = 0; i < mCheckedItems.length; i++) {
+ if (DMClientService.DBG) {
+ logd("CheckedItems " + i + ": " + mCheckedItems[i]);
+ }
+ }
+ } else if (action.equals(DMIntent.SHOW_PROGRESS_ALERT_DLG)) {
+ mType = SHOW_PROGRESS_ALERT_DIALOG;
+ } else if (action.equals(DMIntent.HIDE_PROGRESS_ALERT_DLG)) {
+ mType = HIDE_PROGRESS_ALERT_DIALOG;
+ onFinish();
+ if (DMClientService.DBG) {
+ logd("HIDE_PROGRESS_ALERT_DLG");
+ }
+ return;
+ } else if (action.equals(DMIntent.CANCEL_ALERT_DLG)) {
+ mType = CANCEL_ALERT_DIALOG;
+ onFinish();
+ if (DMClientService.DBG) {
+ logd("CANCEL_ALERT_DIALOG");
+ }
+ return;
+ } else {
+ if (DMClientService.DBG) {
+ logd("TODO: new dialog type support!");
+ }
+ return;
+ }
+
+ if (null != mDialog) {
+ if (DMClientService.DBG) {
+ logd("Cancel previous dialog!");
+ }
+ mDialog.dismiss();
+ mDialog = null;
+ }
+
+ setVisible(false);
+
+ showDialog(mType);
+
+ mKeyReceiver = new KeyReceiver();
+ IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+ IntentFilter searchkeyFilter = new IntentFilter(Intent.ACTION_SEARCH);
+ IntentFilter searchkeyFilterLongPress = new IntentFilter(Intent.ACTION_SEARCH_LONG_PRESS);
+ registerReceiver(mKeyReceiver, searchkeyFilter);
+ registerReceiver(mKeyReceiver, searchkeyFilterLongPress);
+ registerReceiver(mKeyReceiver, filter);
+
+ if (mTimeout <= 0 || mTimeout > 300) {
+ if (DMClientService.DBG) {
+ logd("Forcing the default and max Timeout to 5mins");
+ }
+ mTimeout = 300; //forcing the default and max timeout to 5mins
+ //return;
+ }
+
+ mHandler = new Handler();
+ mDialogTimeout = new Runnable() {
+ @Override
+ public void run() {
+ mResultCode = DMAlert.DM_SERVICE_ALERT_RESP_TIMEOUT;
+ onFinish();
+ if (DMClientService.DBG) {
+ logd("DMAlert.DM_SERVICE_ALERT_RESP_TIMEOUT");
+ }
+ }
+ };
+ mHandler.postDelayed(mDialogTimeout, mTimeout * 1000);
+ }
+
+ private final class KeyReceiver extends BroadcastReceiver {
+
+ KeyReceiver() {
+ }
+
+ @Override
+ public void onReceive(Context arg0, Intent arg1) {
+ Log.i(TAG, "receive the broadcast " + arg1.getAction());
+ mResultCode = DMAlert.DM_SERVICE_ALERT_RESP_CANCEL;
+ onFinish();
+ }
+ }
+
+ @Override
+ protected AlertDialog onCreateDialog(int id) {
+ if (DMClientService.DBG) {
+ logd("Dialog Type: " + id);
+ }
+ getKeyGuardAndWakeLock();
+
+ switch (id) {
+ case DISPLAY_ALERT_DIALOG:
+ mDialog = new AlertDialog.Builder(this)
+ .setTitle(mTitle)
+ .setMessage(mMessage)
+ .setCancelable(true)
+ .setView(null)
+ .create();
+ break;
+ case CONFIRM_ALERT_DIALOG:
+ mDialog = new AlertDialog.Builder(this)
+ .setTitle(mTitle)
+ .setMessage(mMessage)
+ .setPositiveButton(
+ getResources().getString(R.string.DM_SERVICE_ALERT_BUTTON_YES),
+ mKeyYesClickListener)
+ .setNegativeButton(
+ getResources().getString(R.string.DM_SERVICE_ALERT_BUTTON_NO),
+ mKeyNoClickListener)
+ .setCancelable(true)
+ .create();
+ break;
+ case TEXTINPUT_ALERT_DIALOG:
+ View view = LayoutInflater.from(this).inflate(R.layout.textinput_dialog, null);
+ mInputBox = (EditText) view.findViewById(R.id.textinput_content);
+ mInputBox.requestFocus();
+ mInputBox.setText(mResultData);
+ mInputBox.setInputType(mInputType);
+ InputFilter[] f = new InputFilter[1];
+ f[0] = new InputFilter.LengthFilter(mMaxLength);
+ mInputBox.setFilters(f);
+
+ mDialog = new AlertDialog.Builder(this)
+ .setTitle(mTitle)
+ .setMessage(mMessage)
+ .setView(view)
+ .setPositiveButton(
+ getResources().getString(R.string.DM_SERVICE_ALERT_BUTTON_YES),
+ mKeyYesClickListener)
+ .setNegativeButton(
+ getResources().getString(R.string.DM_SERVICE_ALERT_BUTTON_NO),
+ mKeyNoClickListener)
+ .create();
+ break;
+ case SINGLECHOICE_ALERT_DIALOG:
+ mDialog = new AlertDialog.Builder(this)
+ .setTitle(mMessage)
+ .setSingleChoiceItems(mChoices, mCheckedItem, mSingleChoiceClickListener)
+ .setPositiveButton(
+ getResources().getString(R.string.DM_SERVICE_ALERT_BUTTON_YES),
+ mKeyYesClickListener)
+ .setNegativeButton(
+ getResources().getString(R.string.DM_SERVICE_ALERT_BUTTON_NO),
+ mKeyNoClickListener)
+ .setCancelable(true)
+ .create();
+ break;
+ case MULTICHOICE_ALERT_DIALOG:
+ mDialog = new AlertDialog.Builder(this)
+ .setTitle(mMessage)
+ .setMultiChoiceItems(mChoices, mCheckedItems, mMultiChoiceClickListener)
+ .setPositiveButton(
+ getResources().getString(R.string.DM_SERVICE_ALERT_BUTTON_YES),
+ mKeyYesClickListener)
+ .setNegativeButton(
+ getResources().getString(R.string.DM_SERVICE_ALERT_BUTTON_NO),
+ mKeyNoClickListener)
+ .setCancelable(true)
+ .create();
+ break;
+
+ case SHOW_PROGRESS_ALERT_DIALOG:
+ mDialog = new ProgressDialog(this);
+ mDialog.setTitle(mTitle);
+ mDialog.setMessage(mMessage);
+ mDialog.setCancelable(true);
+ if (DMClientService.DBG) {
+ logd("SHOW_PROGRESS_ALERT_DIALOG");
+ }
+ break;
+
+ default:
+ Log.i(TAG, "Unknown dialog type: " + id);
+ return null;
+ }
+
+ if (-1 != mIcon) {
+ mDialog.setIcon(mIcon);
+ }
+
+ mDialog.setOnCancelListener(mOnCancelListener);
+ return mDialog;
+ }
+
+ private void getKeyGuardAndWakeLock() {
+ logd("Inside getKeyGuardAndWakeLock");
+ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK |
+ PowerManager.ACQUIRE_CAUSES_WAKEUP |
+ PowerManager.ON_AFTER_RELEASE, TAG);
+ logd("Acquiring the wakelock");
+ wl.acquire();
+
+ KeyguardManager keyguardManager = (KeyguardManager) getSystemService(
+ Context.KEYGUARD_SERVICE);
+ mKeyguardLock = keyguardManager.newKeyguardLock(TAG);
+ logd("Disabling the KeyGuard");
+ mKeyguardLock.disableKeyguard();
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (DMClientService.DBG) {
+ logd("onKeyDown - keyCode: " + keyCode + " DialogType: " + mType);
+ }
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ onFinish();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void onDestroy() {
+ if (DMClientService.DBG) {
+ logd("onDestroy - DialogType: " + mType);
+ }
+ if (mKeyReceiver != null) {
+ unregisterReceiver(mKeyReceiver);
+ }
+ releaseKeyGuardAndWakeLock();
+ super.onDestroy();
+ }
+
+ private void onFinish() {
+ if (DMClientService.DBG) {
+ logd("OnFinish: Dialog - " + mType);
+ }
+
+ if (mTimeout > 0) {
+ mHandler.removeCallbacks(mDialogTimeout);
+ }
+
+ if (null != mDialog) {
+ mDialog.dismiss();
+ }
+
+ mDialog = null;
+
+ if (mType == DISPLAY_ALERT_DIALOG ||
+ mType == SHOW_PROGRESS_ALERT_DIALOG ||
+ mType == HIDE_PROGRESS_ALERT_DIALOG ||
+ mType == CANCEL_ALERT_DIALOG) {
+ finish();
+ return;
+ }
+
+ Intent i = new Intent(DMIntent.DM_ALERT_DLG_CLOSED);
+
+ i.putExtra("ResultCode", mResultCode);
+ if (DMClientService.DBG) {
+ logd("onFinish - ResultCode: " + mResultCode);
+ }
+
+ if (mType == TEXTINPUT_ALERT_DIALOG) {
+ i.putExtra("ResultData", mResultData);
+ if (DMClientService.DBG) {
+ logd("onFinish - ResultData: " + mResultData);
+ }
+ } else if (mType == SINGLECHOICE_ALERT_DIALOG) {
+ i.putExtra("ResultCheckedItem", mCheckedItem);
+ if (DMClientService.DBG) {
+ logd("onFinish - ResultCheckedItem: " + mCheckedItem);
+ }
+ } else if (mType == MULTICHOICE_ALERT_DIALOG) {
+ i.putExtra("ResultCheckedItems", mCheckedItems);
+ if (DMClientService.DBG) {
+ logd("onFinish - ResultCheckedItems: "
+ + Arrays.toString(mCheckedItems));
+ }
+ }
+
+ sendBroadcast(i);
+
+ finish();
+ }
+
+ private void releaseKeyGuardAndWakeLock() {
+ logd("Inside releaseKeyGuardAndWakeLock");
+ if (wl != null) {
+ logd("Releasing the wakelock");
+ wl.release();
+ wl = null;
+ }
+
+ if (mKeyguardLock != null) {
+ logd("Reenable the KeyGuard");
+ mKeyguardLock.reenableKeyguard();
+ mKeyguardLock = null;
+ }
+ }
+
+ private final DialogInterface.OnClickListener mKeyYesClickListener
+ = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (mTimeout > 0) {
+ mHandler.removeCallbacks(mDialogTimeout);
+ }
+
+ if (mType == TEXTINPUT_ALERT_DIALOG) {
+ mResultData = mInputBox.getText().toString();
+ }
+
+ mResultCode = DMAlert.DM_SERVICE_ALERT_RESP_YES;
+ onFinish();
+ if (DMClientService.DBG) {
+ logd("DMAlert.DM_SERVICE_ALERT_RESP_YES");
+ }
+ }
+ };
+
+ private final DialogInterface.OnClickListener mKeyNoClickListener
+ = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (mTimeout > 0) {
+ mHandler.removeCallbacks(mDialogTimeout);
+ }
+
+ mResultCode = DMAlert.DM_SERVICE_ALERT_RESP_NO;
+ onFinish();
+ if (DMClientService.DBG) {
+ logd("DMAlert.DM_SERVICE_ALERT_RESP_NO");
+ }
+ }
+ };
+
+ private final DialogInterface.OnCancelListener mOnCancelListener
+ = new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ if (DMClientService.DBG) {
+ logd("OnCancel: Dialog - " + mType);
+ }
+ mResultCode = DMAlert.DM_SERVICE_ALERT_RESP_CANCEL;
+ if (DMClientService.DBG) {
+ logd("DMAlert.DM_SERVICE_ALERT_RESP_CANCEL");
+ }
+ onFinish();
+ }
+ };
+
+ private final DialogInterface.OnClickListener mSingleChoiceClickListener
+ = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mCheckedItem = which;
+ }
+ };
+
+ private final DialogInterface.OnMultiChoiceClickListener mMultiChoiceClickListener
+ = new DialogInterface.OnMultiChoiceClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which, boolean isChecked) {
+ mCheckedItems[which] = isChecked;
+ }
+ };
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+}
+
diff --git a/DMService/src/com/android/omadm/service/DMClientService.java b/DMService/src/com/android/omadm/service/DMClientService.java
new file mode 100644
index 0000000..b0793ad
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMClientService.java
@@ -0,0 +1,673 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.app.IntentService;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.AssetManager;
+import android.os.AsyncTask;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.PowerManager;
+import android.os.PowerManager.WakeLock;
+import android.os.RemoteException;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.DmtException;
+import com.android.omadm.plugin.IDMClientService;
+import com.android.omadm.plugin.impl.DmtPluginManager;
+
+import net.jcip.annotations.GuardedBy;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * This is the OMA DM client service as an IntentService.
+ * FIXME: this should be rewritten as a regular Service with an associated StateMachine.
+ */
+public class DMClientService extends IntentService {
+ private static final String TAG = "DMClientService";
+ static final boolean DBG = false; // STOPSHIP: change to false
+
+ // flag "DM session in progress" used from DMIntentReceiver
+ public static boolean sIsDMSessionInProgress;
+
+ private boolean mInitGood;
+ private WakeLock mWakeLock;
+
+ /** Lock object for {@link #mSession} and {@link #mServiceID}. */
+ private final Object mSessionLock = new Object();
+
+ @GuardedBy("mSessionLock")
+ private DMSession mSession;
+
+ @GuardedBy("mSessionLock")
+ private long mServiceID;
+
+ @GuardedBy("mSessionTimeOutHandler")
+ private final Handler mSessionTimeOutHandler = new Handler();
+
+ /** AsyncTask to manage the settings SQLite database. */
+ private DMConfigureTask mDMConfigureTask;
+
+ /**
+ * Helper class for DM session packages.
+ */
+ static final class DMSessionPkg {
+ public DMSessionPkg(int type, long gId) {
+ mType = type;
+ mGlobalSID = gId;
+ mobj = null;
+ }
+
+ public final int mType;
+ public final long mGlobalSID;
+ public Object mobj;
+ public Object mobj2;
+ public boolean mbvalue;
+ }
+
+ // Class for clients to access. Because we know this service always runs
+ // in the same process as its clients, we don't need to deal with IPC.
+ public class LocalBinder extends IDMClientService.Stub {
+ @Override
+ public DmtData getDMTree(String path, boolean recursive)
+ throws RemoteException {
+ try {
+ if (DBG)
+ logd("getDMTree(\"" + path + "\", " + recursive + ") called");
+ synchronized (mSessionLock) {
+ int nodeType = NativeDM.getNodeType(path);
+ String nodeValue = NativeDM.getNodeValue(path);
+ DmtData dmtData = new DmtData(nodeValue, nodeType);
+ if (nodeType == DmtData.NODE && recursive) {
+ addNodeChildren(path, dmtData);
+ }
+ return dmtData;
+ }
+ } catch (Exception e) {
+ loge("caught exception", e);
+ return new DmtData("", DmtData.STRING);
+ }
+ }
+
+ private void addNodeChildren(String path, DmtData node) throws DmtException {
+ for (Map.Entry<String, DmtData> child : node.getChildNodeMap().entrySet()) {
+ String childPath = path + '/' + child.getKey();
+
+ int nodeType = NativeDM.getNodeType(childPath);
+ String nodeValue = NativeDM.getNodeValue(childPath);
+
+ DmtData newChildNode = new DmtData(nodeValue, nodeType);
+
+ node.addChildNode(child.getKey(), newChildNode);
+
+ if (nodeType == DmtData.NODE) {
+ addNodeChildren(childPath, newChildNode);
+ }
+ }
+ }
+
+ @Override
+ public int startClientSession(String path, String clientCert, String privateKey,
+ String alertType, String redirectURI, String username, String password)
+ throws RemoteException {
+ if (DBG) logd("startClientSession(\"" + path + "\", \"" + clientCert
+ + "\", \"" + privateKey + "\", \"" + alertType + "\", \"" + redirectURI
+ + "\", \"" + username + "\", \"" + password + "\") called");
+ return 0;
+ }
+
+ @Override
+ public int notifyExecFinished(String path) throws RemoteException {
+ if (DBG) logd("notifyExecFinished(\"" + path + "\") called");
+ return 0;
+ }
+
+ @Override
+ public int injectSoapPackage(String path, String command, String payload)
+ throws RemoteException {
+ if (DBG) logd("injectSoapPackage(\"" + path + "\", \"" + command
+ + "\", \"" + payload + "\") called");
+ synchronized (mSessionLock) {
+ //return processSerializedTree(serverId, path, command, payload); // FIXME
+ }
+ return DMResult.SYNCML_DM_FAIL;
+ }
+ }
+
+ /**
+ * Create the IntentService, naming the worker thread DMClientService.
+ */
+ public DMClientService() {
+ super(TAG);
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ logd("Enter onCreate tid=" + Thread.currentThread().getId());
+
+ copyFilesFromAssets(); // wait for completion before continuing
+
+ mInitGood = (NativeDM.initialize() == DMResult.SYNCML_DM_SUCCESS);
+ DmtPluginManager.setContext(this);
+
+ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ WakeLock lock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getClass().getName());
+ lock.setReferenceCounted(false);
+ lock.acquire();
+ logd("XXXXX mWakeLock.acquire() in DMClientService.onCreate() XXXXX");
+ mWakeLock = lock;
+
+ mDMConfigureTask = new DMConfigureTask();
+ mDMConfigureTask.execute(this);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ logd("Enter onDestroy tid=" + Thread.currentThread().getId());
+
+ mAbortSession = null;
+
+ if (mInitGood) NativeDM.destroy();
+
+ getConfigDB().closeDatabase();
+
+ logd("XXXXX mWakeLock.release() in DMClientService.onDestroy() XXXXX");
+ mWakeLock.release();
+
+ synchronized (mSessionLock) {
+ mSessionTimeOutHandler.removeCallbacks(mAbortSession);
+ }
+
+ if (DBG) logd("leave onDestroy");
+ }
+
+ /**
+ * AsyncTask to create the DMConfigureDB object on a helper thread.
+ */
+ private static class DMConfigureTask extends
+ AsyncTask<DMClientService, Void, DMConfigureDB> {
+ DMConfigureTask() {}
+
+ @Override
+ protected DMConfigureDB doInBackground(DMClientService... params) {
+ logd("creating new DMConfigureDB() on tid "
+ + Thread.currentThread().getId());
+ return new DMConfigureDB(params[0]);
+ }
+ }
+
+ /**
+ * Process message on IntentService worker thread.
+ * @param pkg the parameters to pass from the Intent
+ */
+ private void processMsg(DMSessionPkg pkg) {
+ // wait for up to 70 seconds for config DB to initialize.
+ if (getConfigDB() == null) {
+ loge("processMsg: getConfigDB() failed. Aborting session");
+ return;
+ }
+ logd("processMsg: received pkg type " + pkg.mType + "; getConfigDB() succeeded");
+
+ sIsDMSessionInProgress = true;
+
+ // check if DMT locked by DMSettingsProvider and wait. If DMT is
+ // locked more then 1 minute (error case, means that something
+ // wrong with DMSettingsProvider) we are continuing execution
+
+ try {
+ synchronized (mSessionLock) {
+ mSession = new DMSession(this);
+ mServiceID = pkg.mGlobalSID;
+ }
+
+ int timeOutSecond = 600 * 1000; /* 10 minutes */
+ int ret = DMResult.SYNCML_DM_SESSION_PARAM_ERR;
+
+ switch (pkg.mType) {
+ case DMIntent.TYPE_PKG0_NOTIFICATION:
+ if (DBG) {
+ logd("Start pkg0 alert session");
+ }
+ startTimeOutTick(timeOutSecond);
+ synchronized (mSessionLock) {
+ ret = mSession.startPkg0AlertSession((byte[]) pkg.mobj);
+ }
+ break;
+
+ case DMIntent.TYPE_FOTA_CLIENT_SESSION_REQUEST:
+ if (DBG) {
+ logd("Start fota client initialized session");
+ }
+ startTimeOutTick(timeOutSecond);
+ synchronized (mSessionLock) {
+ ret = mSession.startFotaClientSession(
+ (String) pkg.mobj, (String) pkg.mobj2);
+ }
+ break;
+
+ case DMIntent.TYPE_FOTA_NOTIFY_SERVER:
+ if (DBG) {
+ logd("Start FOTA notify session");
+ }
+ startTimeOutTick(timeOutSecond);
+ synchronized (mSessionLock) {
+ ret = mSession.fotaNotifyDMServer((FotaNotifyContext) pkg.mobj);
+ }
+ break;
+
+ case DMIntent.TYPE_CLIENT_SESSION_REQUEST:
+ if (DBG) {
+ logd("Start client initialized session:");
+ }
+ if (pkg.mobj != null) {
+ startTimeOutTick(timeOutSecond);
+ synchronized (mSessionLock) {
+ ret = mSession.startClientSession((String) pkg.mobj);
+ }
+ }
+ break;
+
+ case DMIntent.TYPE_LAWMO_NOTIFY_SESSION:
+ if (DBG) {
+ logd("Start LAWMO notify session");
+ }
+ startTimeOutTick(timeOutSecond);
+ synchronized (mSessionLock) {
+ ret = mSession
+ .startLawmoNotifySession((FotaNotifyContext) pkg.mobj);
+ }
+ break;
+ }
+
+ logd("DM Session result code=" + ret);
+
+ synchronized (mSessionLock) {
+ mSession = null;
+ }
+
+ Intent intent = new Intent(DMIntent.DM_SERVICE_RESULT_INTENT);
+ intent.putExtra(DMIntent.FIELD_DMRESULT, ret);
+ intent.putExtra(DMIntent.FIELD_REQUEST_ID, pkg.mGlobalSID);
+ sendBroadcast(intent);
+ } finally {
+ //set static flag "DM session in progress" to false. Used from DMIntentReceiver
+ sIsDMSessionInProgress = false;
+ }
+ }
+
+ void cancelSession(long requestID) {
+ synchronized (mSessionLock) {
+ if (requestID == 0 || mServiceID == requestID) {
+ if (mSession != null) {
+ loge("Cancel session with serviceID: " + mServiceID);
+ mSession.cancelSession();
+ }
+ }
+ }
+ }
+
+ /**
+ * Called on worker thread with the Intent to handle. Calls DMSession directly.
+ * @param intent The intent to handle
+ */
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ long requestID = intent.getLongExtra(DMIntent.FIELD_REQUEST_ID, 0);
+ int intentType = intent.getIntExtra(DMIntent.FIELD_TYPE, DMIntent.TYPE_UNKNOWN);
+
+ logd("onStart intentType: " + intentType + " requestID: "
+ + requestID);
+
+ // wait for up to 70 seconds for config DB to initialize.
+ if (getConfigDB() == null) {
+ loge("WARNING! getConfigDB() failed. Aborting session");
+ return;
+ }
+ if (DBG) logd("getConfigDB() succeeded");
+
+ switch (intentType) {
+ case DMIntent.TYPE_PKG0_NOTIFICATION: {
+ if (DBG) logd("Pkg0 provision received.");
+
+ byte[] pkg0data = intent.getByteArrayExtra(DMIntent.FIELD_PKG0);
+ if (pkg0data == null) {
+ if (DBG) logd("Pkg0 provision received, but no pkg0 data.");
+ return;
+ }
+ DMSessionPkg pkg = new DMSessionPkg(intentType, requestID);
+ pkg.mobj = intent.getByteArrayExtra(DMIntent.FIELD_PKG0);
+ processMsg(pkg);
+ break;
+ }
+ case DMIntent.TYPE_FOTA_CLIENT_SESSION_REQUEST: {
+ if (DBG) logd("Client initiated dm session was received.");
+
+ DMSessionPkg pkg = new DMSessionPkg(intentType, requestID);
+ String serverID = intent.getStringExtra(DMIntent.FIELD_SERVERID);
+ String alertStr = intent.getStringExtra(DMIntent.FIELD_ALERT_STR);
+
+ if (TextUtils.isEmpty(serverID)) {
+ loge("missing server ID, returning");
+ return;
+ }
+
+ if (TextUtils.isEmpty(alertStr)) {
+ loge("missing alert string, returning");
+ return;
+ }
+
+ pkg.mobj = serverID;
+ pkg.mobj2 = alertStr;
+ processMsg(pkg);
+ break;
+ }
+ case DMIntent.TYPE_FOTA_NOTIFY_SERVER: {
+ String result = intent.getStringExtra(DMIntent.FIELD_FOTA_RESULT);
+ String pkgURI = intent.getStringExtra(DMIntent.FIELD_PKGURI);
+ String alertType = intent.getStringExtra(DMIntent.FIELD_ALERTTYPE);
+ String serverID = intent.getStringExtra(DMIntent.FIELD_SERVERID);
+ String correlator = intent.getStringExtra(DMIntent.FIELD_CORR);
+
+ if (DBG) logd("FOTA_NOTIFY_SERVER_SESSION Input==>\n" + " Result="
+ + result + '\n' + " pkgURI=" + pkgURI + '\n'
+ + " alertType=" + alertType + '\n' + " serverID="
+ + serverID + '\n' + " correlator=" + correlator);
+
+ DMSessionPkg pkg = new DMSessionPkg(intentType, requestID);
+ pkg.mobj = new FotaNotifyContext(result, pkgURI, alertType,
+ serverID, correlator);
+ processMsg(pkg);
+ break;
+ }
+ case DMIntent.TYPE_CLIENT_SESSION_REQUEST: {
+ if (DBG) logd("Client initiated dm session was received.");
+
+ DMSessionPkg pkg = new DMSessionPkg(intentType, requestID);
+ String serverID = intent.getStringExtra(DMIntent.FIELD_SERVERID);
+ int timer = intent.getIntExtra(DMIntent.FIELD_TIMER, 0);
+
+ // XXXXX FIXME this should not be here!
+ synchronized (this) {
+ try {
+ if (DBG) logd("Timeout: " + timer);
+ if (timer > 0) {
+ wait(timer * 1000);
+ }
+ } catch (InterruptedException e) {
+ if (DBG) logd("Waiting has been interrupted.");
+ }
+ }
+ if (DBG) logd("Starting session.");
+
+ if (serverID != null && !serverID.isEmpty()) {
+ pkg.mobj = serverID;
+ processMsg(pkg);
+ }
+ break;
+ }
+ case DMIntent.TYPE_CANCEL_DM_SESSION: {
+ cancelSession(requestID);
+ processMsg(new DMSessionPkg(DMIntent.TYPE_DO_NOTHING, requestID));
+ break;
+ }
+ case DMIntent.TYPE_LAWMO_NOTIFY_SESSION: {
+ if (DBG) logd("LAWMO Notify DM Session was received");
+
+ DMSessionPkg pkg = new DMSessionPkg(intentType, requestID);
+
+ String result = intent.getStringExtra(DMIntent.FIELD_LAWMO_RESULT);
+ String pkgURI = intent.getStringExtra(DMIntent.FIELD_PKGURI);
+ String alertType = intent.getStringExtra(DMIntent.FIELD_ALERTTYPE);
+ String correlator = intent.getStringExtra(DMIntent.FIELD_CORR);
+
+ pkg.mobj = new FotaNotifyContext(result, pkgURI, alertType, null, correlator);
+ processMsg(pkg);
+ break;
+ }
+ }
+ }
+
+ public int deleteNode(String node) {
+ if (mInitGood) {
+ return NativeDM.deleteNode(node);
+ }
+ return DMResult.SYNCML_DM_FAIL;
+ }
+
+ public int createInterior(String node) {
+ if (mInitGood) {
+ return NativeDM.createInterior(node);
+ }
+ return DMResult.SYNCML_DM_FAIL;
+ }
+
+ public int createLeaf(String node, String value) {
+ if (mInitGood) {
+ return NativeDM.createLeaf(node, value);
+ }
+ return DMResult.SYNCML_DM_FAIL;
+ }
+
+ public String getNodeInfoSP(String node) {
+ if (mInitGood) {
+ return NativeDM.getNodeInfo(node);
+ }
+ return null;
+ }
+
+ // This is the object that receives interactions from clients. See
+ // RemoteService for a more complete example.
+ private final IBinder mBinder = new LocalBinder();
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ if (DBG) logd("entering onBind()");
+ DMConfigureDB db = getConfigDB(); // wait for configure DB to initialize
+ if (DBG) logd("returning mBinder");
+ return mBinder;
+ }
+
+ /**
+ * Get the {@code DMConfigureDB} object from the AsyncTask, waiting up to 70 seconds.
+ * @return the {@code DMConfigureDB} object, or null if the AsyncTask failed
+ */
+ public DMConfigureDB getConfigDB() {
+ try {
+ return mDMConfigureTask.get(70, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ loge("onBind() got InterruptedException waiting for config DB", e);
+ } catch (ExecutionException e) {
+ loge("onBind() got ExecutionException waiting for config DB", e);
+ } catch (TimeoutException e) {
+ loge("onBind() got TimeoutException waiting for config DB", e);
+ }
+ return null;
+ }
+
+ String parseBootstrapServerId(byte[] data, boolean isWbxml) {
+ String retServerId = NativeDM.parseBootstrapServerId(data, isWbxml);
+ if (DBG) logd("parseBootstrapServerId retServerId=" + retServerId);
+
+ if (DBG) { // dump data for debug
+ int logLevel = getConfigDB().getSyncMLLogLevel();
+ if (logLevel > 0) {
+ try {
+ // FIXME SECURITY: don't open file as world writeable, WTF!
+ FileOutputStream os = openFileOutput("syncml_" + System.currentTimeMillis()
+ + ".dump", MODE_WORLD_WRITEABLE);
+ os.write(data);
+ os.close();
+ logd("xml/wbxml file saved to "
+ + getApplication().getFilesDir().getAbsolutePath());
+
+ if (isWbxml && logLevel == 2) {
+ byte[] xml = NativeDM.nativeWbxmlToXml(data);
+ if (xml != null) {
+ // FIXME SECURITY: don't open file as world writeable, WTF!
+ FileOutputStream xmlos = openFileOutput("syncml_"
+ + System.currentTimeMillis() + ".xml", MODE_WORLD_WRITEABLE);
+ xmlos.write(xml);
+ xmlos.close();
+ logd("wbxml2xml converted successful and saved to file");
+ }
+ }
+ }
+ catch (FileNotFoundException e) {
+ logd("unable to open file for wbxml, e=" + e.toString());
+ }
+ catch (IOException e) {
+ logd("unable to write to wbxml file, e=" + e.toString());
+ }
+ catch(Exception e) {
+ loge("Unexpected exception converting wbxml to xml, e=" + e.toString());
+ }
+ }
+ }
+ return retServerId;
+ }
+
+ private static int processBootstrapScript(byte[] data, boolean isWbxml, String serverId) {
+ int retcode = NativeDM.processBootstrapScript(data, isWbxml, serverId);
+ if (DBG) logd("processBootstrapScript retcode=" + retcode);
+ return retcode;
+ }
+
+ private Runnable mAbortSession = new Runnable() {
+ @Override
+ public void run() {
+ cancelSession(0);
+ }
+ };
+
+ // FIXME: only used from SessionThread inner class
+ private void startTimeOutTick(long delayTime) {
+ synchronized (mSessionTimeOutHandler) {
+ mSessionTimeOutHandler.removeCallbacks(mAbortSession);
+ mSessionTimeOutHandler.postDelayed(mAbortSession, delayTime);
+ }
+ }
+
+ private static boolean copyFile(InputStream in, File to) {
+ try {
+ if (!to.exists()) {
+ to.createNewFile();
+ }
+ OutputStream out = new FileOutputStream(to);
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ out.close();
+ } catch (IOException e) {
+ loge("Error: copyFile exception", e);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Copy files from assets folder.
+ * @return true on success; false on any failure
+ */
+ private boolean copyFilesFromAssets() {
+ // Check files in assets folder
+ String strDes = getFilesDir().getAbsolutePath() + "/dm";
+ logd("Directory is: " + strDes);
+ File dirDes = new File(strDes);
+ if (dirDes.exists() && dirDes.isDirectory()) {
+ logd("Predefined files already created: " + strDes);
+ return true;
+ }
+ logd("Predefined files not created: " + strDes);
+ if (!dirDes.mkdir()) {
+ logd("Failed to create dir: " + dirDes.getAbsolutePath());
+ return false;
+ }
+ // Create log directory.
+ File dirLog = new File(dirDes, "log");
+ // FIXME: don't ignore return value
+ dirLog.mkdir();
+ if (DBG) logd("read assets");
+ try {
+ AssetManager am = getAssets();
+ String[] arrRoot = am.list("dm");
+ int cnt = arrRoot.length;
+ if (DBG) logd("assets count: " + cnt);
+ for (int i = 0; i < cnt; i++) {
+ if (DBG) logd("Root No. " + i + ':' + arrRoot[i]);
+ File dir2 = new File(dirDes, arrRoot[i]);
+ if (!dir2.mkdir()) {
+ // FIXME: don't ignore return value
+ dirDes.delete();
+ return false;
+ }
+ String[] arrSub = am.list("dm/" + arrRoot[i]);
+ int cntSub = arrSub.length;
+ if (DBG) logd(arrRoot[i] + " has " + cntSub + " items");
+ if (cntSub > 0) {
+ for (int j = 0; j < cntSub; j++) {
+ if (DBG) logd("Sub No. " + j + ':' + arrSub[j]);
+ File to2 = new File(dir2, arrSub[j]);
+ String strFrom = "dm/" + arrRoot[i] + '/' + arrSub[j];
+ InputStream in2 = am.open(strFrom);
+ if (!copyFile(in2, to2)) {
+ // FIXME: don't ignore return value
+ dirDes.delete();
+ return false;
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ loge("error copying file from assets", e);
+ return false;
+ }
+ return true;
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ private static void loge(String msg) {
+ Log.e(TAG, msg);
+ }
+
+ private static void loge(String msg, Throwable tr) {
+ Log.e(TAG, msg, tr);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMConfigureDB.java b/DMService/src/com/android/omadm/service/DMConfigureDB.java
new file mode 100755
index 0000000..2de0556
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMConfigureDB.java
@@ -0,0 +1,834 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.content.ComponentName;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.content.SharedPreferences;
+import android.content.res.Resources;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.IBinder;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.omadm.plugin.IDmtPlugin;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class DMConfigureDB {
+ private static final String TAG = "DMConfigureDB";
+ private static final boolean DBG = DMClientService.DBG;
+
+ private final DMClientService mContext;
+
+ private static final String DATABASE_NAME = "DMConfigure.db";
+
+ private final SQLiteDatabase mdb;
+
+ private IDmtPlugin mPluginConnection;
+
+ private String isBoundTo = null;
+
+ protected final Object mLock = new Object();
+
+ private ServiceConnection mConnection = new ServiceConnection() {
+
+ @Override
+ public void onServiceConnected(ComponentName className,
+ IBinder service) {
+ logd("onServiceConnected");
+ synchronized (mLock) {
+ // this gets an instance of the IRemoteInterface, which we can use to call on the service
+ mPluginConnection = IDmtPlugin.Stub.asInterface(service);
+ mLock.notifyAll();
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName arg0) {
+ logd("onServiceDisconnected");
+ synchronized (mLock) {
+ mPluginConnection = null;
+ }
+ }
+ };
+
+ static final class AccountInfo {
+ public String acctName; // DM server account name
+ public String serverID; // DM server ID
+ public String addr; // DM server URL
+ public String addrType; // e.g. "URI"
+ public String portNbr; // DM server port, e.g. "443"
+ public String conRef; // e.g. ""
+ public String serverName; // DM server name
+ public String authPref; // e.g. "HMAC"
+ public String serverPW; // HMAC server password
+ public String serverNonce; // HMAC server nonce
+ public String userName; // DM username (e.g. IMSI or MEID)
+ public String clientPW; // HMAC client password
+ public String clientNonce; // HMAC client nonce
+ public String proxyAddr; // HTTP proxy address
+ public String proxyPortNbr; // HTTP proxy port, e.g. "80"
+ }
+
+ public DMConfigureDB(DMClientService context) {
+ mContext = context;
+ mdb = mContext.openOrCreateDatabase(DATABASE_NAME, 0, null);
+ Cursor cur = null;
+ try {
+ cur = mdb.rawQuery("PRAGMA table_info( dmAccounts )", null);
+ int cnt = cur.getCount();
+ if (DBG) logd("Cursor count for table dmAccounts is " + cnt);
+ // TODO: we need a way for plugins to populate an empty table
+ if (cnt == 0) {
+ onCreate(mdb);
+ }
+ // NOTE: always update all the account info in DM tree
+ loadDmConfig();
+ loadDmAccount(mdb);
+
+ } catch (Exception e) {
+ loge("exception in DMConfigureDB", e);
+ } finally {
+ if (cur != null) {
+ cur.close();
+ }
+ }
+ }
+
+ public void closeDatabase() {
+ mdb.close();
+ unbind();
+ }
+
+ void onCreate(SQLiteDatabase db) {
+ logd("onCreate");
+
+ db.execSQL("CREATE TABLE dmAccounts (" +
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT," +
+ "ServerID TEXT UNIQUE ON CONFLICT REPLACE," +
+ "AccName TEXT," +
+ "Addr TEXT," +
+ "AddrType TEXT," +
+ "PortNbr TEXT," +
+ "ConRef TEXT," +
+ "Name TEXT," +
+ "AuthPref TEXT," +
+ "ServerPW TEXT," +
+ "ServerNonce TEXT," +
+ "UserName TEXT," +
+ "ClientPW TEXT," +
+ "ClientNonce TEXT," +
+ "ProxyAddr TEXT," +
+ "ProxyPortNbr TEXT" +
+ ");");
+
+ db.execSQL("CREATE TABLE dmFlexs (" +
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT," +
+ "name TEXT UNIQUE ON CONFLICT REPLACE," +
+ "value TEXT" +
+ ");");
+ }
+
+ public String getFotaServerID() {
+ String id = getConfigField("PreferredServerID");
+
+ if (id != null && !id.isEmpty()) {
+ return id;
+ }
+
+ return getConfigField("FOTAServerID");
+ }
+
+ public boolean isDmAlertEnabled() {
+ String value = getConfigField("DmAlertEnabled");
+ return null == value || "true".equalsIgnoreCase(value);
+ }
+
+ public boolean isDmNonceResyncEnabled() {
+ String value = getConfigField("DmNonceResyncEnabled");
+ return null != value && "true".equalsIgnoreCase(value);
+ }
+
+ /*
+ * Returns SyncML logging level
+ * 0 = do not log syncml messages
+ * 1 = log messages received as is
+ * 2 = convert wbxml to xml messages and log it
+ */
+ public int getSyncMLLogLevel() {
+ // FIXME always enable for now
+ return 2;
+
+// String value = getConfigField("DmSyncMLLogLevel");
+// if (null == value) {
+// return 0;
+// }
+// return Integer.parseInt(value);
+ }
+
+ private String getConfigField(String field) {
+ String value = null;
+
+ Cursor cr = mdb.query("dmFlexs", null, "name='" + field + '\'', null, null, null, null);
+
+ if (cr != null) {
+ if (cr.moveToFirst()) {
+ int index = cr.getColumnIndex("value");
+ value = cr.getString(index);
+ }
+ cr.close();
+ }
+
+ if (DBG) logd("get field '" + field + "'=" + value);
+ return value;
+ }
+
+ public void setFotaServerID(String serverID) {
+ ContentValues values = new ContentValues(1);
+
+ //values.put("Name", "FOTAServerID");
+ values.put("value", serverID);
+
+ mdb.update("dmFlexs", values, "name='FOTAServerID'", null);
+ }
+
+ void setGsmImei(String imei) {
+ ContentValues values = new ContentValues();
+ values.put("name", "gsmImei");
+ values.put("value", imei);
+ mdb.insert("dmFlexs", null, values);
+
+ }
+
+ private void loadDmConfig() {
+ //following statements just for debug print
+ getConfigField("CarrierName");
+ getConfigField("AdditionalCharge");
+ getConfigField("PreferredServerID");
+
+ // FIXME: this should be removed along with get/setGsmImei()
+ if (DMSettingsHelper.isPhoneTypeLTE()) {
+ SharedPreferences p = mContext.getSharedPreferences(DMHelper.IMEI_PREFERENCE_KEY, 0);
+ String gsmImei = p.getString(DMHelper.IMEI_VALUE_KEY, null);
+ logd("gsmImei in loadDmConfig is " + gsmImei);
+ //ed.clear();
+ if (null == gsmImei || gsmImei.isEmpty()) {
+ // this is needed to avoid showing DMService app force close
+ logd("set the imei value to zero");
+ gsmImei = "0";
+ } else if (gsmImei.length() > 15) {
+ logd("imei length exceeding 15 digits so trim it to 15");
+ gsmImei = gsmImei.substring(0, 15);
+ }
+ setGsmImei(gsmImei);
+ }
+ ///////////////////////////////////////////
+
+ }
+
+ private void loadDmAccount(SQLiteDatabase db) {
+ AccountInfo ai = new AccountInfo();
+ boolean isFirst = true;
+
+ Cursor cr = db.rawQuery("SELECT * FROM dmAccounts", null);
+
+ if (cr != null) {
+ if (cr.moveToFirst()) {
+ do {
+ ai.acctName = cr.getString(cr.getColumnIndex("AccName"));
+ logd("[Factory]account=" + ai.acctName);
+
+ ai.serverID = cr.getString(cr.getColumnIndex("ServerID"));
+ if (DBG) logd("[Factory]serverID=" + ai.serverID);
+
+ ai.addr = cr.getString(cr.getColumnIndex("Addr"));
+ if (DBG) logd("[Factory]addr=" + ai.addr);
+
+ ai.addrType = cr.getString(cr.getColumnIndex("AddrType"));
+ if (DBG) logd("[Factory]addrType=" + ai.addrType);
+
+ ai.portNbr = cr.getString(cr.getColumnIndex("PortNbr"));
+ if (DBG) logd("[Factory]portNbr=" + ai.portNbr);
+
+ ai.conRef = cr.getString(cr.getColumnIndex("ConRef"));
+ if (DBG) logd("[Factory]conRef=" + ai.conRef);
+
+ ai.serverName = cr.getString(cr.getColumnIndex("Name"));
+ if (DBG) logd("[Factory]serverName=" + ai.serverName);
+
+ ai.authPref = cr.getString(cr.getColumnIndex("AuthPref"));
+ if (DBG) logd("[Factory]authPref=" + ai.authPref);
+
+ ai.serverPW = cr.getString(cr.getColumnIndex("ServerPW"));
+ if (DBG) logd("[Factory]serverPW=" + ai.serverPW);
+
+ ai.serverNonce = cr.getString(cr.getColumnIndex("ServerNonce"));
+ if (DBG) logd("[Factory]serverNonce=" + ai.serverNonce);
+
+ ai.userName = cr.getString(cr.getColumnIndex("UserName"));
+ if (DBG) logd("[Factory]userName=" + ai.userName);
+
+ ai.clientPW = cr.getString(cr.getColumnIndex("ClientPW"));
+ if (DBG) logd("[Factory]clientPW=" + ai.clientPW);
+
+ ai.clientNonce = cr.getString(cr.getColumnIndex("ClientNonce"));
+ if (DBG) logd("[Factory]clientNonce=" + ai.clientNonce);
+
+ ai.proxyAddr = cr.getString(cr.getColumnIndex("ProxyAddr"));
+ if (DBG) logd("[Factory]proxyAddr=" + ai.proxyAddr);
+
+ ai.proxyPortNbr = cr.getString(cr.getColumnIndex("ProxyPortNbr"));
+ if (DBG) logd("[Factory]proxyPortNbr=" + ai.proxyPortNbr);
+
+ if (writeAccount2Dmt(ai) && isFirst) {
+ if (DBG) logd("[Factory]setFotaServerID: " + ai.serverID);
+
+ ContentValues values = new ContentValues();
+ values.put("name", "FOTAServerID");
+ values.put("value", ai.serverID);
+ db.insert("dmFlexs", null, values);
+
+ isFirst = false;
+ }
+
+ } while (cr.moveToNext());
+
+ cr.close();
+ return;
+ }
+ cr.close();
+ }
+
+ try {
+ XmlPullParser xpp = null;
+ String[] accountInfo = null;
+ int eventType = 0;
+ int num_accounts = 0;
+ InputStream in = getDMAccXmlInput();
+
+ if (in != null) {
+ XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ xpp = factory.newPullParser();
+ xpp.setInput(in, null);
+ eventType = xpp.getEventType();
+ } else {
+ logd("Reading dmAccounts from res");
+ Resources res = mContext.getResources();
+ accountInfo = res.getStringArray(R.array.dm_account_info);
+ if (accountInfo == null) {
+ if (DBG) logd("accountInfo == null");
+ return;
+ } else {
+ logd("Number of accounts = " + accountInfo.length);
+ }
+ }
+
+ while ((in != null && eventType != XmlPullParser.END_DOCUMENT) ||
+ (in == null && num_accounts < accountInfo.length)) {
+ if (in == null ||
+ (eventType == XmlPullParser.START_TAG && "Account".equals(xpp.getName()))) {
+ String[] account = null;
+ if (in == null) {
+ account = accountInfo[num_accounts].split(", ");
+ if (account == null) {
+ loge("account == null; invalid account info");
+ } else {
+ if (DBG) logd("Account # " + (num_accounts + 1) +
+ "; number of fields = " + account.length);
+ }
+ }
+
+ ai.acctName = getAttributeValue(xpp, "AccName", account, 0);
+ logd("account=" + ai.acctName);
+
+ ai.serverID = getAttributeValue(xpp, "ServerID", account, 1);
+ if (DBG) logd("serverID=" + ai.serverID);
+
+ ai.addr = getRealString(getAttributeValue(xpp, "Addr", account, 2));
+ if (DBG) logd("addr=" + ai.addr);
+
+ ai.addrType = getAttributeValue(xpp, "AddrType", account, 3);
+ if (DBG) logd("addrType=" + ai.addrType);
+
+ ai.portNbr = getAttributeValue(xpp, "PortNbr", account, 4);
+ if (DBG) logd("portNbr=" + ai.portNbr);
+
+ ai.conRef = getAttributeValue(xpp, "ConRef", account, 5);
+ if (DBG) logd("conRef=" + ai.conRef);
+
+ ai.serverName = getAttributeValue(xpp, "ServerName", account, 6);
+ if (DBG) logd("serverName=" + ai.serverName);
+
+ ai.authPref = getAttributeValue(xpp, "AuthPref", account, 7);
+ if (DBG) logd("authPref=" + ai.authPref);
+
+ ai.serverPW = getAttributeValue(xpp, "ServerPW", account, 8);
+ if (DBG) logd("serverPW=" + ai.serverPW);
+
+ ai.serverNonce = getAttributeValue(xpp, "ServerNonce", account, 9);
+ if (DBG) logd("serverNonce=" + ai.serverNonce);
+
+ ai.userName = getAttributeValue(xpp, "UserName", account, 10);
+ if (DBG) logd("userName=" + ai.userName);
+
+ ai.clientPW = getAttributeValue(xpp, "ClientPW", account, 11);
+ if (DBG) logd("clientPW=" + ai.clientPW);
+
+ ai.clientNonce = getAttributeValue(xpp, "ClientNonce", account, 12);
+ if (DBG) logd("clientNonce=" + ai.clientNonce);
+
+ ai.proxyAddr = getRealString(getAttributeValue(xpp, "ProxyAddr", account, 13));
+ if (DBG) logd("proxyAddr=" + ai.proxyAddr);
+
+ ai.proxyPortNbr = getRealString(getAttributeValue(xpp, "ProxyPortNbr", account, 14));
+ if (DBG) logd("addr=" + ai.proxyPortNbr);
+
+ // FIXME: check should be on account name instead of isFirst
+ if (writeAccount2Dmt(ai) && isFirst) {
+ if (DBG) logd("setFotaServerID: " + ai.serverID);
+
+ ContentValues values = new ContentValues();
+ values.put("name", "FOTAServerID");
+ values.put("value", ai.serverID);
+ db.insert("dmFlexs", null, values);
+ isFirst = false;
+ }
+ }
+
+ if (in != null) {
+ eventType = xpp.next();
+ } else {
+ num_accounts++;
+ }
+ }
+
+ if (in != null) {
+ in.close();
+ }
+
+ } catch (IOException e) {
+ loge("IOException in loadDmAccount", e);
+ } catch (XmlPullParserException e) {
+ loge("XmlPullParserException in loadDmAccount", e);
+ }
+ }
+
+ private String getAttributeValue(XmlPullParser xpp, String attribute, String[] account, int idx) {
+ if (xpp != null) {
+ return xpp.getAttributeValue(null, attribute);
+ } else if (account != null && idx < account.length) {
+ return account[idx];
+ } else {
+ return null;
+ }
+ }
+
+ private boolean writeAccount2Dmt(AccountInfo ai) {
+ if (DBG) logd("enter writeAccount2Dmt");
+
+ String acctName = ai.serverID; // e.g. "sprint"; this is also the value for ServerID
+ String dmServerNodePath = "./DMAcc/" + acctName;
+
+ logd("XXX DELETING old server node path: " + dmServerNodePath);
+ NativeDM.deleteNode(dmServerNodePath);
+
+ if (NativeDM.createInterior(dmServerNodePath) != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + acctName + "' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/ServerID", ai.serverID)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + dmServerNodePath + "/ServerId' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/AppID", "w7") != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + dmServerNodePath + "/AppID' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/Name", ai.serverName)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/Name' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/PrefConRef", ai.conRef)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/ConRef' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/AAuthPref", ai.authPref)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/AAuthPref' Error");
+ return false;
+ }
+
+ dmServerNodePath += "/AppAddr";
+ if (NativeDM.createInterior(dmServerNodePath) != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + dmServerNodePath + "' Error");
+ return false;
+ }
+
+ dmServerNodePath += "/1"; // limited to one server address per account
+
+ if (NativeDM.createInterior(dmServerNodePath) != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + dmServerNodePath + "' Error");
+ return false;
+ }
+
+ if ("sprint".equalsIgnoreCase(ai.serverID)) {
+ String address = DMHelper.getServerUrl(mContext);
+ if (!TextUtils.isEmpty(address)) {
+ logd("Overriding server URL to: " + address);
+ ai.addr = address;
+ }
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/Addr", ai.addr)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/Addr' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/AddrType", ai.addrType)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/AddrType' Error");
+ return false;
+ }
+
+ dmServerNodePath += "/Port";
+ if (NativeDM.createInterior(dmServerNodePath) != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + dmServerNodePath + "' Error");
+ return false;
+ }
+
+ dmServerNodePath += "/1"; // limited to one port number per server address
+
+ if (NativeDM.createInterior(dmServerNodePath) != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + dmServerNodePath + "' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/PortNbr", ai.portNbr)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/PortNbr' Error");
+ return false;
+ }
+
+ // collection of authentication credentials
+ dmServerNodePath = "./DMAcc/" + acctName + "/AppAuth";
+
+ if (NativeDM.createInterior(dmServerNodePath) != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + dmServerNodePath + "' Error");
+ return false;
+ }
+
+ // server credentials for authenticating the server from the OMA DM client
+ dmServerNodePath += "/Server";
+
+ if (NativeDM.createInterior(dmServerNodePath) != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + dmServerNodePath + "' Error");
+ return false;
+ }
+
+ String authLevel = "SRVCRED";
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/AAuthLevel", authLevel)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/AAuthLevel' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/AAuthType", ai.authPref)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/AAuthType' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/AAuthName", acctName)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/AAuthName' Error");
+ return false;
+ }
+
+ if (ai.serverID.equalsIgnoreCase("sprint") ||
+ ai.serverID.equalsIgnoreCase("com.vzwdmserver")) {
+ String intentName;
+ String serviceName;
+ if (ai.serverID.equalsIgnoreCase("sprint")) {
+ intentName = "com.android.sdm.plugins.sprintdm.SprintDMPlugin";
+ serviceName = "SprintDMService";
+ } else {
+ intentName = "com.android.sdm.plugins.connmo.ConnmoPlugin";
+ serviceName = "ConnmoService";
+ }
+ logd("ServerID is " + ai.serverID);
+ if (isBoundTo == null || !isBoundTo.equalsIgnoreCase(ai.serverID)) {
+ unbind();
+ Intent intent = new Intent(intentName);
+ if (mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE)) {
+ isBoundTo = ai.serverID;
+ synchronized (mLock) {
+ if (mPluginConnection == null) {
+ logd("Waiting for binding to " + serviceName);
+ try {
+ mLock.wait();
+ } catch (Exception e) {
+ loge("Exception in writeAccount2Dmt->wait: ", e);
+ }
+ }
+ }
+ }
+ } else {
+ logd("Already bound to " + serviceName);
+ }
+ } else {
+ unbind();
+ }
+
+ boolean hasWriteServerPW = false;
+ try {
+ if (mPluginConnection != null) {
+ String serverPW = mPluginConnection.getServerPW(ai.serverPW);
+ if (serverPW != null) {
+ ai.serverPW = serverPW;
+ logd("ServerPW from plugin: " + serverPW);
+ } else {
+ // This must be for vzw
+ byte[] svrPasswd = hexStringToBytes(ai.serverPW);
+ if (NativeDM.createLeaf(dmServerNodePath + "/AAuthSecret", svrPasswd)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("CreateLeaf '"+dmServerNodePath + "/AAuthSecret' Error");
+ return false;
+ }
+ hasWriteServerPW = true;
+ }
+ } else {
+ logd("Using default ServerPW from dmAccounts: " + ai.serverPW);
+ }
+ } catch (Exception e) {
+ loge("Exception in writeAccount2Dmt->getServerPW", e);
+ }
+
+ if (!hasWriteServerPW && NativeDM.createLeaf(dmServerNodePath + "/AAuthSecret", ai.serverPW)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/AAuthSecret' Error");
+ return false;
+ }
+
+ if (NativeDM.createLeaf(dmServerNodePath + "/AAuthData", ai.serverNonce)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmServerNodePath + "/AAuthData' Error");
+ return false;
+ }
+
+ // client credentials for authenticating ourselves to the OMA DM server
+ String dmClientNodePath = "./DMAcc/" + acctName + "/AppAuth/Client";
+
+ if (NativeDM.createInterior(dmClientNodePath) != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createInterior '" + dmServerNodePath + "' Error");
+ return false;
+ }
+
+ String clientAuthLevel = "CLCRED";
+
+ if (NativeDM.createLeaf(dmClientNodePath + "/AAuthLevel", clientAuthLevel)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmClientNodePath + "/AAuthLevel' Error");
+ return false;
+ }
+
+ String clientAuthType = ai.authPref;
+ if (NativeDM.createLeaf(dmClientNodePath + "/AAuthType", clientAuthType)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmClientNodePath + "/AAuthType' Error");
+ return false;
+ }
+
+ boolean hasWriteUserName = false;
+ try {
+ if (mPluginConnection != null) {
+ String username = mPluginConnection.getUsername(ai.userName);
+ if (username != null) {
+ ai.userName = username;
+ logd("Username from plugin: " + username);
+ } else {
+ // This must be for vzw
+ byte[] clientName = hexStringToBytes(ai.userName);//"e0e5e7eaebeb");
+ if (NativeDM.createLeaf(dmClientNodePath + "/AAuthName", clientName)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("CreateLeaf '"+dmClientNodePath + "/AAuthName' Error");
+ return false;
+ }
+ hasWriteUserName = true;
+ }
+ } else {
+ logd("Using default username from dmAccounts: " + ai.userName);
+ }
+ } catch (Exception e) {
+ loge("Exception in writeAccount2Dmt->getUsername", e);
+ }
+
+ if (!hasWriteUserName && NativeDM.createLeaf(dmClientNodePath + "/AAuthName", ai.userName)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmClientNodePath + "/AAuthName' Error");
+ return false;
+ }
+
+ boolean hasWriteClientPW = false;
+ try {
+ if (mPluginConnection != null) {
+ String clientPW = mPluginConnection.getClientPW(ai.clientPW);
+ if (clientPW != null) {
+ ai.clientPW = clientPW;
+ logd("ClientPW from plugin: " + clientPW);
+ } else {
+ // This must be for vzw
+ byte[] clientPasswd=hexStringToBytes(ai.clientPW);//"ebe8efeeecec");
+ if (NativeDM.createLeaf(dmClientNodePath + "/AAuthSecret", clientPasswd) !=
+ DMResult.SYNCML_DM_SUCCESS) {
+ loge("CreateLeaf '" + dmClientNodePath + "/AAuthSecret' Error");
+ return false;
+ }
+ hasWriteClientPW = true;
+ }
+ } else {
+ logd("Using default ClientPW from dmAccounts: " + ai.clientPW);
+ }
+ } catch (Exception e) {
+ loge("Exception in writeAccount2Dmt->getClientPW", e);
+ }
+
+ if (!hasWriteClientPW && NativeDM.createLeaf(dmClientNodePath + "/AAuthSecret", ai.clientPW)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmClientNodePath + "/AAuthSecret' Error");
+ return false;
+ }
+
+ String clientNonce = ai.clientNonce;
+ if (NativeDM.createLeaf(dmClientNodePath + "/AAuthData", clientNonce)
+ != DMResult.SYNCML_DM_SUCCESS) {
+ loge("createLeaf '" + dmClientNodePath + "/AAuthData' Error");
+ return false;
+ }
+
+ logd("leave writeAccount2Dmt: success");
+ return true;
+ }
+
+ private InputStream getDMAccXmlInput() {
+ try {
+ File file = new File("/system/etc/", "dmAccounts.xml");
+ if (file.exists()) {
+ InputStream in = new BufferedInputStream(new FileInputStream(file));
+ logd("Load config from /system/etc/dmAccounts.xml");
+ return in;
+ } else {
+ return null;
+ }
+ } catch (IOException e) {
+ loge("IOException in getDMAccXmlInput", e);
+ return null;
+ }
+ }
+
+ private String getRealString(String ins) {
+ if (ins != null && !ins.isEmpty() && ins.charAt(0) == '$') {
+ SharedPreferences prefs = mContext.getSharedPreferences("dmconfig", 0);
+ String key = ins.substring(1);
+ if (prefs.contains(key)) {
+ return prefs.getString(key, "unknown");
+ }
+ }
+ return ins;
+ }
+
+ private void unbind() {
+ if (isBoundTo != null) {
+ logd("Unbinding from " + isBoundTo);
+ mContext.unbindService(mConnection);
+ isBoundTo = null;
+ synchronized (mLock) {
+ mPluginConnection = null;
+ }
+ }
+ }
+
+ private static byte[] hexStringToBytes(String s) {
+ byte[] ret;
+
+ if (s == null) return null;
+
+ int sz = s.length();
+
+ ret = new byte[sz/2];
+
+ for (int i=0 ; i <sz ; i+=2) {
+ ret[i/2] = (byte) ((hexCharToInt(s.charAt(i)) << 4)
+ | hexCharToInt(s.charAt(i+1)));
+ }
+
+ return ret;
+ }
+
+ private static int hexCharToInt(char c) {
+ if (c >= '0' && c <= '9') return (c - '0');
+ if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
+ if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
+
+ throw new RuntimeException ("invalid hex char '" + c + "'");
+ }
+
+// private static void testSprintHashGenerator() {
+// String equip = "A000001A2B3C4F";
+// String server = "sprint";
+// String secret = "foobar";
+//
+// logd("XXXXX B64(MD5(\"foobar\") = " + sprintHashGenerator("foobar"));
+// logd("XXXXX f(equip,server,secret) = " + sprintHashGenerator(equip + server + secret));
+// logd("XXXXX f(server,equip,secret) = " + sprintHashGenerator(server + equip + secret));
+// }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ private static void loge(String msg) {
+ Log.e(TAG, msg);
+ }
+
+ private static void loge(String msg, Throwable tr) {
+ Log.d(TAG, msg, tr);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMDataConnectionService.java b/DMService/src/com/android/omadm/service/DMDataConnectionService.java
new file mode 100644
index 0000000..aaec060
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMDataConnectionService.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.Network;
+import android.net.NetworkCapabilities;
+import android.net.NetworkInfo;
+import android.net.NetworkRequest;
+import android.os.IBinder;
+import android.util.Log;
+
+/**
+ * This service monitors the data connection and call state and brings up the FOTA APN when
+ * started by an {@link DMIntent#ACTION_START_DATA_CONNECTION_SERVICE} intent.
+ *
+ * TODO: handle operators which disallow OMA DM sessions over Wi-Fi.
+ * TODO: handle mobile data disabled and roaming disabled cases.
+ */
+public class DMDataConnectionService extends Service {
+ private static final String TAG = "DMDataConnectionService";
+ private static final boolean DBG = true;
+
+ private ConnectivityManager mConnectivityManager;
+
+ /** Start ID of current network request. */
+ private int mCurrentStartId;
+
+ /** The active NetworkCallback for the FOTA APN, or null. */
+ private ConnectivityManager.NetworkCallback mCellNetworkCallback;
+
+ /** The active NetworkCallback for WiFi or Ethernet, or null. */
+ private ConnectivityManager.NetworkCallback mWiFiNetworkCallback;
+
+ /** The active FOTA APN network, or null. */
+ private Network mActiveCellNetwork;
+
+ /** The active WiFi or Ethernet network, or null. */
+ private Network mActiveWiFiNetwork;
+
+ /** Wait for 120 seconds after requesting the desired network types. */
+ private static final int WAIT_FOR_NETWORK_TIMEOUT_MS = 120 * 1000;
+
+ @Override
+ public void onCreate() {
+ if (DBG) logd("onCreate()");
+ mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+ }
+
+ @Override
+ public void onDestroy() {
+ if (DBG) logd("onDestroy()");
+
+ mCurrentStartId = 0;
+
+ if (mCellNetworkCallback != null) {
+ mConnectivityManager.unregisterNetworkCallback(mCellNetworkCallback);
+ if (DBG) logd("unregistered cell network callback");
+ mCellNetworkCallback = null;
+ }
+
+ if (mWiFiNetworkCallback != null) {
+ mConnectivityManager.unregisterNetworkCallback(mWiFiNetworkCallback);
+ if (DBG) logd("unregistered WiFi network callback");
+ mWiFiNetworkCallback = null;
+ }
+ // Unbind from any network.
+ ConnectivityManager.setProcessDefaultNetwork(null);
+ }
+
+ private boolean isWifiConnected() {
+ NetworkInfo ni = mConnectivityManager.getActiveNetworkInfo();
+ return ni != null && ni.isConnected()
+ && (ni.getType() == ConnectivityManager.TYPE_WIFI
+ || ni.getType() == ConnectivityManager.TYPE_ETHERNET);
+ }
+
+ /**
+ * Request route using FOTA APN on the cell network and/or Wi-Fi or Ethernet transport.
+ * @param wifiOrEthernet true if Wi-Fi transport type is allowed; false for mobile data only
+ */
+ private void requestNetworks(boolean wifiOrEthernet) {
+ if (wifiOrEthernet && isWifiConnected()) {
+ if (DBG) logd("requesting WiFi or Ethernet network transport");
+ NetworkRequest request = new NetworkRequest.Builder()
+ .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
+ .addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET).build();
+
+ mWiFiNetworkCallback = new WiFiCallback();
+ mConnectivityManager.requestNetwork(request, mWiFiNetworkCallback,
+ WAIT_FOR_NETWORK_TIMEOUT_MS);
+ } else {
+ if (DBG) logd("requesting cell network with FOTA capability");
+ NetworkRequest request = new NetworkRequest.Builder()
+ .addCapability(NetworkCapabilities.NET_CAPABILITY_FOTA).build();
+
+ mCellNetworkCallback = new CellCallback();
+ mConnectivityManager.requestNetwork(request, mCellNetworkCallback,
+ WAIT_FOR_NETWORK_TIMEOUT_MS);
+ }
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ if (DBG) logd("onStartCommand: startID " + startId);
+
+ if (intent != null) {
+ String action = intent.getAction();
+ if (DMIntent.ACTION_START_DATA_CONNECTION_SERVICE.equals(action)) {
+ int lastStartId = mCurrentStartId;
+ mCurrentStartId = startId;
+
+ if (lastStartId == 0) {
+ requestNetworks(true); // request FOTA APN or Wi-Fi/Ethernet networks
+ }
+ } else {
+ if (DBG) loge("unexpected intent: " + action);
+ stopSelf(startId);
+ }
+ } else {
+ if (DBG) logd("unexpected null intent");
+ stopSelf(startId);
+ }
+ return Service.START_REDELIVER_INTENT;
+ }
+
+ private void sendDataConnectionReady() {
+ Intent intent = new Intent(this, DMIntentReceiver.class);
+ intent.setAction(DMIntent.ACTION_DATA_CONNECTION_READY);
+ sendBroadcast(intent);
+ }
+
+ // Callback for FOTA APN of cellular network.
+ private class CellCallback extends ConnectivityManager.NetworkCallback {
+ @Override
+ public void onAvailable(Network network) {
+ if (mCurrentStartId != 0) {
+ if (DBG) logd("CellCallback.onAvailable() for network: " + network);
+ mActiveCellNetwork = network;
+ if (mActiveWiFiNetwork == null) {
+ if (DBG) logd("calling setProcessDefaultNetwork() for cell network");
+ ConnectivityManager.setProcessDefaultNetwork(network);
+ }
+ sendDataConnectionReady();
+ } else {
+ if (DBG) loge("CellCallback: ignoring onAvailable() after service quit");
+ }
+ }
+
+ @Override
+ public void onUnavailable() {
+ if (mCurrentStartId != 0) {
+ if (DBG) loge("CellCallback.onUnavailable() called (timeout)");
+ mActiveCellNetwork = null;
+ if (mActiveWiFiNetwork == null) {
+ if (DBG) logd("clearing setProcessDefaultNetwork() binding");
+ ConnectivityManager.setProcessDefaultNetwork(null);
+ }
+ } else {
+ if (DBG) loge("CellCallback: ignoring onUnavailable() after service quit");
+ }
+ }
+ }
+
+ // Callback for WiFi connectivity.
+ private class WiFiCallback extends ConnectivityManager.NetworkCallback {
+ @Override
+ public void onAvailable(Network network) {
+ if (mCurrentStartId != 0) {
+ if (DBG) logd("WiFiCallback.onAvailable() for network: " + network);
+ mActiveWiFiNetwork = network;
+ ConnectivityManager.setProcessDefaultNetwork(network);
+ sendDataConnectionReady();
+ } else {
+ if (DBG) loge("WiFiCallback: ignoring onAvailable() after service quit");
+ }
+ }
+
+ @Override
+ public void onUnavailable() {
+ if (mCurrentStartId != 0) {
+ if (DBG) loge("WiFi.onUnavailable() called (timeout)");
+ mActiveWiFiNetwork = null;
+ if (mActiveCellNetwork == null) {
+ if (DBG) logd("clearing setProcessDefaultNetwork() binding");
+ ConnectivityManager.setProcessDefaultNetwork(null);
+ requestNetworks(false); // request FOTA APN only
+ }
+ } else {
+ if (DBG) loge("WiFiCallback: ignoring onUnavailable() after service quit");
+ }
+ }
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ private static void loge(String msg) {
+ Log.e(TAG, msg);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMDatabaseTable.java b/DMService/src/com/android/omadm/service/DMDatabaseTable.java
new file mode 100644
index 0000000..39aa5ea
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMDatabaseTable.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteStatement;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a single table in an SQLite database.
+ */
+class DMDatabaseTable {
+ private static final String TAG = "DMDatabaseTable";
+
+ private static final int TABLE_INFO_PRAGMA_COLUMN_NAME = 1;
+ private static final int TABLE_INFO_PRAGMA_DATA_TYPE = 2;
+ public static final int TABLE_INFO_PRAGMA_NULL_ALLOWED = 3;
+ public static final int TABLE_INFO_PRAGMA_DEFAULT = 4;
+
+ private final String mName;
+
+ // map the name a a column to its type
+ private HashMap<String, String> mColumns = new HashMap<String, String>();
+ public DMDatabaseTable(SQLiteDatabase db, String name) {
+ mName = name;
+ mColumns = init(db);
+ }
+
+ String getName() {
+ return mName;
+ }
+
+ boolean containsColumn(String name) {
+ return mColumns != null && mColumns.containsKey(name);
+ }
+
+ /**
+ * Return whether the column map has been initialized.
+ * @return true if column map is valid; false if column map is null.
+ */
+ boolean isValid() {
+ return mColumns != null;
+ }
+
+ /**
+ * populate the mColumns table based on content of the database
+ *
+ * @param db
+ * @return
+ */
+ HashMap<String, String> init(SQLiteDatabase db) {
+ HashMap<String, String> ret = null;
+ Cursor cur = null;
+ try {
+ cur = db.rawQuery("PRAGMA table_info(" + mName + ')', null);
+ int cnt = cur.getCount();
+ logd(String.format("Cursor count for table %s is %d", mName, cnt));
+ if (cnt > 0) {
+ ret = new HashMap<String, String>(cur.getCount());
+ while (cur.moveToNext()) {
+ String columnName = cur.getString(TABLE_INFO_PRAGMA_COLUMN_NAME);
+ String dataType = cur.getString(TABLE_INFO_PRAGMA_DATA_TYPE);
+ ret.put(columnName, dataType);
+ logd(String.format("%s %s", columnName, dataType));
+ }
+ }
+ } finally {
+ if (cur != null) cur.close();
+ }
+
+ return ret;
+ }
+
+ boolean rowValid(ArrayList<String> cols) {
+ for (String col : cols) {
+ if (!containsColumn(col)) {
+ loge("Attempt to flex invalid column " + col);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * insert a single row
+ * TODO: call sequence should to be optimized so that we can reuse
+ * compiled statement rather than recreating on each row.
+ * @param db
+ * @param row a HashMap that was created from the UmlUtils.readXml() call
+ */
+ public void insertRow(SQLiteDatabase db, HashMap row) {
+
+ ArrayList<String> cols = new ArrayList<String>();
+ ArrayList<String> vals = new ArrayList<String>();
+ for (Object entryObject : row.entrySet()) {
+ Map.Entry<String, Object> entry = (Map.Entry<String, Object>) entryObject;
+ String key = entry.getKey();
+ if (!containsColumn(key)) {
+ loge("Attempt to flex invalid column " + key);
+ }
+ String val = entry.getValue().toString();
+ cols.add(key);
+ vals.add(val);
+ }
+
+ if (rowValid(cols)) {
+ try {
+ insertRow(db, cols, vals);
+ } catch (IllegalArgumentException iae) {
+ loge("Column count does not match values cannot create insert");
+ } catch (Exception e) {
+ loge(e.getMessage());
+ }
+ }
+ logd("insertRow - complete");
+ }
+
+ /**
+ * insert a single row
+ *
+ * TODO: use this for mkitso files also
+ *
+ * @param db
+ * @param cols list of columns
+ * @param vals list of values
+ */
+ void insertRow(SQLiteDatabase db, ArrayList<String> cols, ArrayList<String> vals)
+ throws IllegalArgumentException {
+ int numberColumns = cols.size();
+ int numberValues = vals.size();
+
+ if (numberColumns != numberValues) {
+ throw new IllegalArgumentException("vals.size() != cols.size()");
+ }
+
+ String insert = String.format("INSERT OR REPLACE INTO %s (%s) VALUES(%s);",
+ getName(), join(cols, ", "), joinNTimes("?", vals.size()));
+ logd(insert);
+ SQLiteStatement stmt = null;
+ try {
+ stmt = db.compileStatement(insert);
+ for (int i = 0; i < numberColumns; i++) {
+ stmt.bindString(i + 1, vals.get(i));
+ }
+ stmt.execute();
+ } catch (Exception e) {
+ loge(String.format("Unexpected exception for %s: %s", insert, e.getMessage()));
+ } finally {
+ if (stmt != null) stmt.close();
+ }
+ logd("insertRow - complete");
+ }
+
+ /**
+ * utility function to join a string separated by another string
+ *
+ * @param args
+ * @param sep
+ * @return
+ */
+ private static String join(List<String> args, String sep) {
+ StringBuilder sb = new StringBuilder();
+ if (args != null) {
+ int cnt = args.size();
+ if (cnt > 0) {
+ for (int i = 0; i < cnt - 1; i++) {
+ sb.append(args.get(i));
+ sb.append(sep);
+ }
+ sb.append(args.get(cnt - 1));
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * utility function to repeat a string in times separated by a comma
+ */
+ private static String joinNTimes(String str, int cnt) {
+ StringBuilder sb = new StringBuilder();
+ if (cnt > 0) {
+ for (int i = 0; i < cnt - 1; i++) {
+ sb.append(str);
+ sb.append(", ");
+ }
+ sb.append(str);
+ }
+ return sb.toString();
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ private static void loge(String msg) {
+ Log.e(TAG, msg);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMDialog.java b/DMService/src/com/android/omadm/service/DMDialog.java
new file mode 100644
index 0000000..7f65873
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMDialog.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+
+public class DMDialog extends Activity {
+
+ private static final String TAG = "DMDialog";
+
+ private static final int PKG0_ALERT_DLG = 1;
+
+ private static final int PKG0_INFO_DLG = 2;
+
+ private static final int UPDATE_CANCEL_DLG = 3;
+
+ private static final int USER_PRESS_OK = 1;
+
+ private static final int USER_PRESS_CANCEL = 2;
+
+ private String mTitle;
+
+ private String mMessage;
+
+ private int mResult;
+
+ private String mDlgType;
+
+ private AlertDialog mDialog;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (DMClientService.DBG) {
+ logd("onCreate");
+ }
+ final Intent intent = getIntent();
+ mDlgType = intent.getAction();
+
+ if (mDlgType.equals(DMIntent.SHOW_PKG0_ALERT_DLG)) {
+ mTitle = intent.getStringExtra("Title");
+ mMessage = intent.getStringExtra("Message");
+
+ showDialog(PKG0_ALERT_DLG);
+ }
+
+ if (mDlgType.equals(DMIntent.SHOW_PKG0_INFO_DLG)) {
+ mTitle = intent.getStringExtra("Title");
+ mMessage = intent.getStringExtra("Message");
+ showDialog(PKG0_INFO_DLG);
+
+ Handler handler = new Handler();
+ Runnable closeDialogTask = new Runnable() {
+ @Override
+ public void run() {
+ mDialog.dismiss();
+ finish();
+ }
+ };
+
+ handler.postDelayed(closeDialogTask, 40 * 1000);
+ }
+
+ if (mDlgType.equals(DMIntent.SHOW_UPDATE_CANCEL_DLG)) {
+
+ mTitle = intent.getStringExtra("Title");
+ mMessage = intent.getStringExtra("Message");
+ showDialog(UPDATE_CANCEL_DLG);
+ }
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ switch (id) {
+ case PKG0_ALERT_DLG:
+ mDialog = new AlertDialog.Builder(this)
+ .setTitle(mTitle)
+ .setIcon(R.drawable.alert_dialog_icon)
+ .setMessage(mMessage)
+ .setNegativeButton(android.R.string.cancel, mCancelClickListener)
+ .setPositiveButton(android.R.string.ok, mOKClickListener)
+ .setCancelable(false)
+ .create();
+ return mDialog;
+ case PKG0_INFO_DLG:
+ mDialog = new AlertDialog.Builder(this)
+ .setTitle(mTitle)
+ .setIcon(R.drawable.alert_dialog_icon)
+ .setMessage(mMessage)
+ .setCancelable(false)
+ .create();
+ return mDialog;
+ case UPDATE_CANCEL_DLG:
+ mDialog = new AlertDialog.Builder(this)
+ .setTitle(mTitle)
+ .setIcon(R.drawable.alert_dialog_icon)
+ .setMessage(mMessage)
+ .setPositiveButton(android.R.string.ok, mOKClickListener)
+ .setCancelable(false)
+ .create();
+ return mDialog;
+ }
+ return null;
+ }
+
+ private final DialogInterface.OnClickListener mOKClickListener = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mResult = USER_PRESS_OK;
+ if (DMClientService.DBG) {
+ logd("Press:OK");
+ }
+ mDialog.dismiss();
+ finish();
+ }
+ };
+
+ private final DialogInterface.OnClickListener mCancelClickListener = new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mResult = USER_PRESS_CANCEL;
+ if (DMClientService.DBG) {
+ logd("Press:Cancel");
+ }
+ mDialog.dismiss();
+ finish();
+ }
+ };
+
+ @Override
+ public void onDestroy() {
+ Log.i(TAG, "onDestroy");
+ if (mDlgType.equals(DMIntent.SHOW_PKG0_ALERT_DLG)) {
+ Intent i = new Intent(DMIntent.SHOW_PKG0_ALERT_DLG_CLOSE);
+ i.putExtra("Result", mResult);
+ sendBroadcast(i);
+ }
+ super.onDestroy();
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMHelper.java b/DMService/src/com/android/omadm/service/DMHelper.java
new file mode 100644
index 0000000..a5dab59
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMHelper.java
@@ -0,0 +1,383 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.app.AlarmManager;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Process;
+import android.content.pm.PackageManager;
+import android.util.Log;
+
+import java.io.File;
+
+final class DMHelper {
+ private static final String TAG = "DMHelper";
+ private static final boolean DBG = DMClientService.DBG;
+
+ public static final String POSTPONED_DATA_PATH
+ = "/data/data/com.android.omadm.service/shared_prefs/dmpostponed.dat";
+
+ private static final String FOTA_APN_FILE_PATH
+ = "/data/data/com.android.omadm.service/shared_prefs/fotaapnprefs.xml";
+
+ public static final int UI_MODE_INFORMATIVE = 2;
+
+ public static final int UI_MODE_CONFIRMATION = 3;
+
+ public static final int NOTIFICATION_INFORMATIVE_ID = 0xcb01fa64;
+
+ public static final int NOTIFICATION_CONFIRMATION_ID = 0xadc19b91;
+
+
+ // ------- Constant VALUES -----------//
+ // message lifetime (24 hours) in milliseconds
+ private static final long MESSAGE_LIFETIME = 24 * 60 * 60 * 1000000000L; //nanoseconds
+
+ // maximum number failures to attempt starting DM session
+ public static final long MAX_SESSION_ATTEMPTS = 3;
+
+ // time before attempt start DM session after a failure (in seconds)
+ public static final int TIME_BETWEEN_SESSION_ATTEMPTS = 30 * 60; //seconds
+
+ // time to check status after starting DM service; try to restart if service will die (in seconds)
+ public static final int TIME_CHECK_STATUS_AFTER_STARTING_DM_SERVICE = 30 * 60; //seconds
+
+ // time to check and repost notification in case if user cancel it; subscribe during posting notification (in seconds)
+ public static final int TIME_CHECK_NOTIFICATION_AFTER_SUBSCRIPTION = 30 * 60; //seconds
+
+ // time to check status after starting call and data monitoring service; try to restart if service will die (in seconds)
+ public static final int TIME_CHECK_STATUS_AFTER_STARTING_MONITORING_SERVICE = 20 * 60; //seconds
+
+
+ // ----- States ----//
+ public static final String STATE_KEY = "dmmsgstate";
+
+ public static final int STATE_IDLE = 0; // nothing there
+
+ public static final int STATE_PENDING_MESSAGE = 1; // message received and saved
+
+ public static final int STATE_APPROVED_BY_USER = 2; // message approved or silent
+
+ public static final int STATE_SESSION_IN_PROGRESS = 3; // DM session has been started
+
+
+ // ----- Keys ----//
+ // shared properties name
+ public static final String DM_PREFERENCES_KEY = "dmpostponed";
+
+ // key to keep timestamp for the message in the shared properties. Also used as a request ID
+ public static final String MESSAGE_TIMESTAMP_ID_KEY = "dm_msg_time_init";
+
+ public static final String MESSAGE_SERVER_URL_KEY = "dm_server_url";
+
+ public static final String MESSAGE_PROXY_HOSTNAME_KEY = "dm_proxy_hostname";
+
+ // key to keep number attempts to start DM session
+ public static final String DM_SESSION_ATTEMPTS_KEY = "dm_session_attempts";
+
+ // key to keep uiMode
+ public static final String DM_UI_MODE_KEY = "dm_ui_mode";
+
+ // key for pending session type
+ public static final String DM_SESSION_TYPE_KEY = "type";
+
+ // ---- Key and States used for fota apn ----//
+ // shared property name
+ public static final String FOTA_APN_PREFERENCE_KEY = "fotaapnprefs";
+
+ public static final String FOTA_APN_STATE_KEY = "fotapnstate";
+
+ public static final String FOTA_ALERT_STRING_KEY = "fota_alert_string";
+
+ public static final String FOTA_SERVER_ID_KEY = "fota_server_id";
+
+ // initial APN monitor state
+ public static final int FOTA_APN_STATE_INIT = 0; // no action needed for this
+
+ // apn switch needed for NI session
+ public static final int FOTA_APN_STATE_START_DM_SESSION = 1;
+
+ // apn switch needed for FDM session
+ public static final int FOTA_APN_STATE_REPORT_DM_SESSION = 2;
+
+ // RPTD states used to decide when to stop using fota apn
+ public static final int FOTA_APN_STATE_START_DM_SESSION_RPTD = 3;
+ public static final int FOTA_APN_STATE_REPORT_DM_SESSION_RPTD = 4;
+
+ // ---- Keys used for storing FDM MSG Values ----//
+ public static final String LAWMO_RESULT_KEY = "lawmoResult";
+
+ public static final String FOTA_RESULT_KEY = "fotaResult";
+
+ public static final String PKG_URI_KEY = "pkgURI";
+
+ public static final String ALERT_TYPE_KEY = "alertType";
+
+ public static final String CORRELATOR_KEY = "correlator";
+
+ public static final String SERVER_ID_KEY = "serverID";
+
+ // --- Key used for storing hostname override for Sprint ---//
+ public static final String SERVER_HOSTNAME_OVERRIDE_KEY = "serverHostname";
+
+ //--- Keys used for storing imei ---//
+ public static final String IMEI_PREFERENCE_KEY = "imeivalue";
+
+ public static final String IMEI_VALUE_KEY = "imei";
+
+ //--- Keys used for storing AKEY ---//
+ public static final String AKEY_PREFERENCE_KEY = "akeyvalue";
+
+ public static final String AKEY_VALUE_KEY = "akey";
+
+ private static boolean sfirstTriggerReceived = false;
+
+ // private constructor
+ private DMHelper() {}
+
+ // Subscribing for the Timer Alert
+ public static void subscribeForTimeAlert(Context context, int seconds) {
+ cancelTimeAlert(context);
+
+ logd("subscribeForTimeAlert ...");
+
+ Intent intent = new Intent(context, DMIntentReceiver.class);
+ intent.setAction(DMIntent.ACTION_TIMER_ALERT);
+ PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
+
+ long wakeupTime = System.currentTimeMillis() + (seconds * 1000L);
+
+ // Schedule the alarm
+ AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+ am.set(AlarmManager.RTC_WAKEUP, wakeupTime, sender);
+ logd("subscribeForTimeAlert for " + seconds + " seconds done!");
+ }
+
+ // Canceling subscription for time alert
+ private static void cancelTimeAlert(Context context) {
+ logd("cancelTimeAlarm ...");
+
+ Intent intent = new Intent(context, DMIntentReceiver.class);
+ intent.setAction(DMIntent.ACTION_TIMER_ALERT);
+ PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
+
+ AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
+ am.cancel(sender);
+ logd("cancelTimeAlarm done!");
+ }
+
+ // post confirmation notification when UI mode required user interaction
+ public static void postConfirmationNotification(Context context) {
+ NotificationManager mNotificationManager = (NotificationManager) context
+ .getSystemService(Context.NOTIFICATION_SERVICE);
+
+ CharSequence text = context.getText(
+ R.string.dm_session_confirmation_notification_message)
+ .toString();
+
+ Intent provisioning = new Intent(context, DMSessionConfirmAlertActivity.class);
+
+ PendingIntent contentIntent = PendingIntent.getActivity(context, 0, provisioning, 0);
+
+ Notification notification = new Notification.Builder(context)
+ .setSmallIcon(R.drawable.alert_dialog_icon)
+ .setTicker(text)
+ .setWhen(System.currentTimeMillis())
+ .setContentTitle(
+ context.getText(R.string.dm_session_confirmation_notification_label))
+ .setContentText(text)
+ .setContentIntent(contentIntent)
+ .setColor(context.getResources().getColor(
+ com.android.internal.R.color.system_notification_accent_color))
+ .build();
+
+ mNotificationManager.notify(NOTIFICATION_CONFIRMATION_ID,
+ notification);
+ }
+
+ // post informative notification when UI mode required to inform users
+ private static void postInformativeNotification(Context context, int titleId, int textId) {
+ NotificationManager mNotificationManager = (NotificationManager) context
+ .getSystemService(Context.NOTIFICATION_SERVICE);
+
+ CharSequence text = context.getText(textId);
+
+ Intent provisioning = new Intent(context, DMIntentReceiver.class);
+ provisioning.setAction(DMIntent.ACTION_CLOSE_NOTIFICATION_INFO);
+
+ PendingIntent contentIntent = PendingIntent.getBroadcast(context, 0, provisioning, 0);
+
+ Notification notification = new Notification.Builder(context)
+ .setSmallIcon(R.drawable.alert_dialog_icon)
+ .setTicker(text)
+ .setWhen(System.currentTimeMillis())
+ .setContentTitle(context.getText(titleId))
+ .setContentText(text)
+ .setContentIntent(contentIntent)
+ .setColor(context.getResources().getColor(
+ com.android.internal.R.color.system_notification_accent_color))
+ .build();
+
+ mNotificationManager.notify(NOTIFICATION_INFORMATIVE_ID, notification);
+ }
+
+ // post informative notification when UI mode required to inform users
+ public static void postInformativeNotification_message1(Context context) {
+ postInformativeNotification(context,
+ R.string.dm_session_information_notification_label,
+ R.string.dm_session_information_notification_message1);
+ }
+
+ //post informative notification when UI mode required to inform users
+ public static void postInformativeNotification_message2_success(Context context) {
+ postInformativeNotification(context,
+ R.string.dm_session_information_notification_label,
+ R.string.dm_session_information_notification_message2_success);
+ }
+
+ //post informative notification when UI mode required to inform users
+ public static void postInformativeNotification_message2_fail(Context context) {
+ postInformativeNotification(context,
+ R.string.dm_session_information_notification_label,
+ R.string.dm_session_information_notification_message2_fail);
+ }
+
+ //clear notification
+ public static void cancelNotification(Context context, int notificationId) {
+ NotificationManager nm = (NotificationManager) context
+ .getSystemService(Context.NOTIFICATION_SERVICE);
+ nm.cancel(notificationId);
+ }
+
+
+ //remove message and all from shared properties
+ private static void clearSharedPreferences(Context context) {
+ SharedPreferences p = context.getSharedPreferences(DM_PREFERENCES_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+ ed.clear();
+ ed.apply();
+
+ //remove file with message
+ File file = new File(POSTPONED_DATA_PATH);
+ if (file.exists()) {
+ file.delete();
+ }
+ }
+
+ // set Sprint server URL
+ public static void setServerUrl(Context context, String url) {
+ logd("setServerUrl: " + url);
+ SharedPreferences p = context.getSharedPreferences(SERVER_HOSTNAME_OVERRIDE_KEY, 0);
+ p.edit().putString(MESSAGE_SERVER_URL_KEY, url).apply();
+ }
+
+ // set Sprint proxy hostname
+ public static void setProxyHostname(Context context, String hostname) {
+ logd("setProxyHostname: " + hostname);
+ SharedPreferences p = context.getSharedPreferences(SERVER_HOSTNAME_OVERRIDE_KEY, 0);
+ p.edit().putString(MESSAGE_PROXY_HOSTNAME_KEY, hostname).apply();
+ }
+
+ // get Sprint server URL
+ public static String getServerUrl(Context context) {
+ SharedPreferences p = context.getSharedPreferences(SERVER_HOSTNAME_OVERRIDE_KEY, 0);
+ String url = p.getString(MESSAGE_SERVER_URL_KEY, null);
+ logd("getServerUrl: " + url);
+ return url;
+ }
+
+ // get Sprint proxy hostname
+ public static String getProxyHostname(Context context) {
+ SharedPreferences p = context.getSharedPreferences(SERVER_HOSTNAME_OVERRIDE_KEY, 0);
+ String hostname = p.getString(MESSAGE_PROXY_HOSTNAME_KEY, null);
+ logd("getProxyHostname: " + hostname);
+ return hostname;
+ }
+
+ // check if message is expired; compares current time with the timestamp
+ // for the message and its lifetime
+ public static boolean isMessageExpired(Context context) {
+ // get message timestamp from preferences
+ SharedPreferences p = context.getSharedPreferences(DM_PREFERENCES_KEY, 0);
+ long messageTimestamp = p.getLong(MESSAGE_TIMESTAMP_ID_KEY, -1);
+ logd("isMessageExpired: messageTimestamp is " + messageTimestamp);
+
+ return messageTimestamp == -1 || System.nanoTime() > (messageTimestamp
+ + MESSAGE_LIFETIME);
+ }
+
+ // clean all... shared preferences, notifications, time alerts....
+ public static void cleanAllResources(Context context) {
+ logd("Inside cleanAllResources");
+ clearSharedPreferences(context);
+ // Not canceling informative notification since otherwise it disappears very quickly (as
+ // soon as DM session ends which is just a few seconds)
+ // cancelNotification(context, NOTIFICATION_INFORMATIVE_ID);
+ cancelNotification(context, NOTIFICATION_CONFIRMATION_ID);
+ cancelTimeAlert(context);
+ }
+
+ // remove message and all from shared properties for fota apn
+ private static void clearFotaApnSharedPreferences(Context context) {
+ logd("Inside clearFotaApnSharedPreferences");
+ SharedPreferences p = context.getSharedPreferences(
+ FOTA_APN_PREFERENCE_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+ ed.clear();
+ ed.apply();
+
+ //remove file with message
+ File file = new File(FOTA_APN_FILE_PATH);
+ if (file.exists()) {
+ logd("fotaapnprefs.xml file deleted");
+ // FIXME: don't ignore result of delete
+ file.delete();
+ }
+ }
+
+ public static boolean isRunningAsOwner() {
+ return Process.myUserHandle().isOwner();
+ }
+
+ public static void cleanFotaApnResources(Context context) {
+ if (DBG) logd("Inside cleanFotaApnResources");
+ clearFotaApnSharedPreferences(context);
+ }
+
+ public static boolean disableIfSecondaryUser(Context context) {
+ if (sfirstTriggerReceived == false) {
+ sfirstTriggerReceived = true;
+ if (!isRunningAsOwner()) {
+ PackageManager pm = context.getPackageManager();
+ logd("Disabling com.android.omadm.service for secondary user");
+ pm.setApplicationEnabledSetting("com.android.omadm.service",
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0 );
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMHttpConnector.java b/DMService/src/com/android/omadm/service/DMHttpConnector.java
new file mode 100644
index 0000000..b49e7df
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMHttpConnector.java
@@ -0,0 +1,408 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.telephony.TelephonyManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.ProtocolException;
+import java.net.Proxy;
+import java.net.SocketAddress;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.Map;
+
+public class DMHttpConnector {
+ private static final String TAG = "DMHttpConnector";
+ private static final boolean DBG = DMClientService.DBG;
+
+ private HttpURLConnection mConnection;
+
+ private static final String USER_AGENT = "User-Agent";
+
+ private static final String CACHE_CONTROL = "Cache-Control";
+
+ private static final String ACCEPT = "Accept";
+
+ private static final String ACCEPT_LANGUAGE = "Accept-Language";
+
+ private static final String ACCEPT_CHARSET = "Accept-Charset";
+
+ private static final String CONTENT_TYPE = "Content-Type";
+
+ public static final String CONTENT_LENGTH = "Content-Length";
+
+ private static final String X_SYNCML_HMAC = "x-syncml-hmac";
+
+ // Sprint DM-Sess-29: User-Agent: <make>/<model> <DM-vendor>/<DM-version>
+ private static final String ANDROID_OMA_DM_CLIENT = "Google/Nexus Google/1";
+
+ private static final String LANGUAGE_EN = "en";
+
+ private static final String CHARSET_UTF8 = "utf-8";
+
+ private static final String MIME_TYPE_SYNCML_DM = "application/vnd.syncml.dm";
+
+ private static final String MIME_TYPE_SYNCML_DM_WBXML = MIME_TYPE_SYNCML_DM + "+wbxml";
+
+ //private static final String MIME_TYPE_SYNCML_DM_XML = MIME_TYPE_SYNCML_DM + "+xml";
+
+ private static final String CACHE_CONTROL_PRIVATE = "private";
+
+ private String mContentType;
+
+ private final DMSession mSession;
+
+ private final DMClientService mContext;
+
+ private Proxy mProxy;
+
+ public DMHttpConnector(DMSession session) {
+ mSession = session;
+ mContext = session.getServiceContext();
+ setHostProxy();
+ }
+
+ /**
+ * Enable an APN by name.
+ * Called from JNI code.
+ *
+ * @param apnName
+ */
+ public void enableApnByName(String apnName) {
+ if (DBG) logd("Enable Apn name=" + apnName);
+ }
+
+ /**
+ * Send an HTTP request.
+ * Called from JNI code.
+ *
+ * @param urlString the URL to request
+ * @param requestData the SyncML package to send
+ * @param hmacValue the HMAC value to send as a request header
+ * @return
+ */
+ public int sendRequest(String urlString, byte[] requestData, String hmacValue) {
+ if (mContentType == null) {
+ mContentType = MIME_TYPE_SYNCML_DM_WBXML;
+ }
+
+ if (DBG) logd("Post url=" + urlString + " HMAC value=" + hmacValue);
+
+ if (urlString.isEmpty()) {
+ return DMResult.SYNCML_DM_INVALID_URI;
+ }
+
+ HttpURLConnection connection = mConnection;
+ URL url;
+ try {
+ if (connection != null) {
+ loge("overwriting old mConnection!");
+ mConnection.disconnect();
+ }
+
+ url = new URL(urlString);
+
+ // STOPSHIP: remove this hack for Sprint
+ if (url.getHost().contains("sprint")) {
+ String serverUrl = DMHelper.getServerUrl(mContext);
+ if (!TextUtils.isEmpty(serverUrl)) {
+ if (DBG) logd("replacing URL with Sprint URL: " + serverUrl);
+ url = new URL(serverUrl);
+ urlString = serverUrl;
+ if (DBG) logd("new URL is " + url);
+ }
+ }
+
+ if (mProxy != null) {
+ if (DBG) logd("opening connection with proxy: " + mProxy);
+ connection = (HttpURLConnection) url.openConnection(mProxy);
+ } else {
+ if (DBG) logd("opening direct connection");
+ connection = (HttpURLConnection) url.openConnection();
+ }
+
+ mConnection = connection;
+ } catch (Exception e) {
+ loge("bad URL", e);
+ return DMResult.SYNCML_DM_INVALID_URI;
+ }
+
+ try {
+ connection.setRequestMethod("POST");
+ connection.addRequestProperty(ACCEPT, MIME_TYPE_SYNCML_DM_WBXML);
+ connection.addRequestProperty(ACCEPT_LANGUAGE, LANGUAGE_EN);
+ connection.addRequestProperty(ACCEPT_CHARSET, CHARSET_UTF8);
+ connection.addRequestProperty(USER_AGENT, ANDROID_OMA_DM_CLIENT);
+ connection.addRequestProperty(CACHE_CONTROL, CACHE_CONTROL_PRIVATE);
+ connection.addRequestProperty(CONTENT_TYPE, mContentType);
+ connection.addRequestProperty("Connection", "Close");
+ if (!TextUtils.isEmpty(hmacValue)) {
+ connection.addRequestProperty(X_SYNCML_HMAC, hmacValue);
+ }
+ } catch (ProtocolException e) {
+ loge("error setting headers", e);
+ return DMResult.SYNCML_DM_IO_FAILURE;
+ }
+
+ // Log outgoing headers and content
+ HttpLog log = new HttpLog(mContext, mSession.getLogFileName());
+ log.logHeaders(connection.getRequestProperties());
+ log.logContent(mContentType, requestData);
+ log.closeLogFile();
+
+ try {
+ // Send request data
+ OutputStream stream = connection.getOutputStream();
+ stream.write(requestData);
+ stream.flush();
+
+ int retcode = connection.getResponseCode();
+ if (DBG) logd(urlString + " code: " + retcode + " status: "
+ + connection.getResponseMessage());
+ return retcode;
+ } catch (UnknownHostException ignored) {
+ loge(url + " - Unknown host exception");
+ return DMResult.SYNCML_DM_UNKNOWN_HOST;
+ } catch (IOException e) {
+ loge(url + " - IOException error: ", e);
+ return DMResult.SYNCML_DM_SOCKET_CONNECT_ERR;
+ }
+ }
+
+ /**
+ * Get the response length.
+ * Called from JNI code.
+ *
+ * @return
+ */
+ long getResponseLength() {
+ if (mConnection != null) {
+ return mConnection.getContentLength();
+ }
+ return -1;
+ }
+
+ /**
+ * Get the response data.
+ * Called from JNI code.
+ *
+ * @return
+ */
+ public byte[] getResponseData() {
+ if (mConnection == null) {
+ return null;
+ }
+
+ int dataSize = (int) getResponseLength();
+ if (dataSize <= 0) {
+ return null;
+ }
+
+ byte[] data = new byte[dataSize];
+ if (DBG) logd("response dataSize=" + dataSize);
+
+ String contentType = mConnection.getContentType();
+ if (contentType == null) {
+ loge("getResponseData: contentType is null");
+ return null;
+ }
+
+ if (DBG) logd("content type = " + contentType);
+
+ try {
+ InputStream resInput = mConnection.getInputStream();
+ if (resInput != null) {
+ if (DBG) logd("inputstream type = " + resInput.getClass().getName());
+ int readTotal = 0;
+ synchronized (this) {
+ int read;
+ while ((read = resInput.read(data, readTotal, dataSize - readTotal)) != -1) {
+ readTotal += read;
+ }
+ }
+ if (DBG) logd("InputStream read len = " + readTotal);
+ }
+ } catch (IOException e) {
+ loge("IOException reading response", e);
+ }
+
+ // log incoming headers and content
+ HttpLog log = new HttpLog(mContext, mSession.getLogFileName());
+ log.logHeaders(mConnection.getHeaderFields());
+ log.logContent(contentType, data);
+ log.closeLogFile();
+
+ return data;
+ }
+
+ /**
+ * Get the response header.
+ * Called from JNI code.
+ *
+ * @param fieldName
+ * @return
+ */
+ public String getResponseHeader(String fieldName) {
+ if (mConnection != null) {
+ return mConnection.getHeaderField(fieldName);
+ }
+ return null;
+ }
+
+ /**
+ * Set the content type.
+ * Called from JNI code.
+ *
+ * @param type
+ */
+ public void setContentType(String type) {
+ mContentType = type;
+ }
+
+ public int closeSession() {
+ if (mConnection != null) {
+ mConnection.disconnect();
+ }
+
+ return 1;
+ }
+
+ private void setHostProxy() {
+ String hostname = DMHelper.getProxyHostname(mContext);
+ if (TextUtils.isEmpty(hostname)) {
+ TelephonyManager tm = (TelephonyManager) mContext
+ .getSystemService(mContext.TELEPHONY_SERVICE);
+ String simOperator = tm.getSimOperator();
+ String imsi = tm.getSubscriberId();
+ if ("310120".equals(simOperator) || (imsi != null && imsi.startsWith("310120"))) {
+ loge("Using default proxy hostname!!");
+ hostname = "oma.ssprov.sprint.com";
+ } else {
+ logd("no proxy");
+ mProxy = null;
+ return;
+ }
+ }
+
+ SocketAddress sa = InetSocketAddress.createUnresolved(hostname, 80);
+ if (DBG) logd("unresolved socket address created");
+
+ mProxy = new Proxy(Proxy.Type.HTTP, sa);
+ if (DBG) logd("Set Proxy: " + mProxy);
+ }
+
+ static final class HttpLog {
+
+ final int mLogLevel;
+
+ FileOutputStream mOut;
+
+ public HttpLog(DMClientService clientService, String logFileName) {
+ // TODO: make into a property or preference
+ mLogLevel = clientService.getConfigDB().getSyncMLLogLevel();
+ try {
+ if (mLogLevel > 0) {
+ mOut = new FileOutputStream(logFileName, true);
+ logd("XXXXX creating log file " + logFileName + " XXXXX");
+ }
+ } catch (Exception ex) {
+ loge("Exception opening syncml log file=" + logFileName, ex);
+ }
+ }
+
+ public void logHeaders(Map<String, List<String>> headers) {
+ FileOutputStream out = mOut;
+ if (out == null) {
+ return;
+ }
+ StringBuilder builder = new StringBuilder(256);
+ for (Map.Entry<String, List<String>> header : headers.entrySet()) {
+ for (String value : header.getValue()) {
+ builder.append(header.getKey()).append(':').append(value).append("\r\n");
+ }
+ }
+ try {
+ out.write(builder.toString().getBytes());
+ } catch (IOException ex) {
+ loge("Exception writing syncml headers log", ex);
+ }
+ }
+
+ public void logContent(String contentType, byte[] body) {
+ FileOutputStream out = mOut;
+ if (out == null) {
+ return;
+ }
+ try {
+ out.write("===================================".getBytes());
+ if (body == null || body.length == 0) {
+ out.write("empty body".getBytes());
+ return;
+ }
+ byte[] xml = null;
+ if ((contentType.toLowerCase()).startsWith(MIME_TYPE_SYNCML_DM_WBXML)) {
+ if (mLogLevel == 2) {
+ xml = NativeDM.nativeWbxmlToXml(body);
+ if (xml != null) {
+ out.write(xml);
+ }
+ }
+ }
+ if (xml == null) {
+ out.write(body);
+ }
+ out.write("===================================\n".getBytes());
+ } catch (Exception ex) { // catch all in case JNI throws exception
+ loge("Exception writing syncml content log", ex);
+ }
+
+ }
+
+ public void closeLogFile() {
+ FileOutputStream out = mOut;
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException ex) {
+ loge("Exception writing syncml headers log", ex);
+ }
+ mOut = null;
+ }
+ }
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ private static void loge(String msg) {
+ Log.e(TAG, msg);
+ }
+
+ private static void loge(String msg, Throwable tr) {
+ Log.e(TAG, msg, tr);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMInjectPackageReceiver.java b/DMService/src/com/android/omadm/service/DMInjectPackageReceiver.java
new file mode 100644
index 0000000..628a155
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMInjectPackageReceiver.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class DMInjectPackageReceiver extends BroadcastReceiver {
+ private static final String TAG = "DMInjectPackageReceiver";
+ private static final boolean DBG = DMClientService.DBG;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (DMHelper.disableIfSecondaryUser(context)) {
+ return;
+ }
+ if ("com.android.omadm.service.InjectPackage0".equals(intent.getAction())) {
+ if (DBG) Log.d(TAG, intent.getAction());
+ Intent iIntent = new Intent(DMIntent.ACTION_INJECT_PACKAGE_0_INTERNAL);
+ iIntent.replaceExtras(intent);
+ context.sendBroadcast(iIntent);
+ }
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMIntent.java b/DMService/src/com/android/omadm/service/DMIntent.java
new file mode 100644
index 0000000..3afc94a
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMIntent.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+public interface DMIntent {
+
+ String LAUNCH_INTENT = "com.android.omadm.service.Launch";
+
+ String DM_SERVICE_RESULT_INTENT = "com.android.omadm.service.Result";
+
+ String SHOW_PKG0_ALERT_DLG = "com.android.omadm.service.pkg0_alert_dlg";
+
+ String SHOW_PKG0_INFO_DLG = "com.android.omadm.service.pkg0_info_dlg";
+
+ String SHOW_UPDATE_CANCEL_DLG = "com.android.omadm.service.update_cancel_dlg";
+
+ String SHOW_PKG0_ALERT_DLG_CLOSE = "com.android.omadm.service.pkg0_alert_dlg_close";
+
+ String SHOW_DISPLAY_ALERT_DLG = "com.android.omadm.service.display_alert_dlg";
+
+ String SHOW_CONFIRM_ALERT_DLG = "com.android.omadm.service.confirm_alert_dlg";
+
+ String SHOW_TEXTINPUT_ALERT_DLG = "com.android.omadm.service.textinput_alert_dlg";
+
+ String SHOW_SINGLECHOICE_ALERT_DLG = "com.android.omadm.service.singlechoice_alert_dlg";
+
+ String SHOW_MULTICHOICE_ALERT_DLG = "com.android.omadm.service.multichoice_alert_dlg";
+
+ String SHOW_PROGRESS_ALERT_DLG = "com.android.omadm.service.show_progress_alert_dlg";
+
+ String HIDE_PROGRESS_ALERT_DLG = "com.android.omadm.service.hide_progress_alert_dlg";
+
+ String CANCEL_ALERT_DLG = "com.android.omadm.service.cancel_alert_dlg";
+
+ String DM_ALERT_DLG_CLOSED = "com.android.omadm.service.dm_alert_dlg_closed";
+
+ String ACTION_TIMER_ALERT = "com.android.omadm.service.pending_notification";
+
+ // for UI mode Informative management action
+ String ACTION_CLOSE_NOTIFICATION_INFO = "com.android.omadm.service.close_notification_info";
+
+ // for waiting for Wi-Fi or waiting for mobile data and then bringing up the FOTA APN
+ String ACTION_START_DATA_CONNECTION_SERVICE = "com.android.omadm.service.StartDataConnection";
+
+ // data connection was successfully started
+ String ACTION_DATA_CONNECTION_READY = "com.android.omadm.service.DataConnectionReady";
+
+ // user from UI confirmed starting DM session
+ String ACTION_USER_CONFIRMED_DM_SESSION
+ = "com.android.omadm.service.user_confirmed_dm_session";
+
+ // inject package0 from command line
+ String ACTION_INJECT_PACKAGE_0_INTERNAL = "com.android.omadm.service.InjectPackage0_Internal";
+
+ // internal wap push intent
+ String ACTION_WAP_PUSH_RECEIVED_INTERNAL
+ = "com.android.omadm.service.WAP_PUSH_RECEIVED_INTERNAL";
+
+ // start client initiated provisioning request
+ String ACTION_CLIENT_INITIATED_FOTA_SESSION
+ = "com.android.omadm.service.client_initiated_fota";
+
+ // set server hostname info
+ String ACTION_SET_SERVER_CONFIG = "com.android.omadm.service.set_server_config";
+
+ // cancel DM session
+ String ACTION_CANCEL_SESSION = "com.android.omadm.service.cancel_dm_session";
+
+ int TYPE_UNKNOWN = 0;
+
+ int TYPE_PKG0_NOTIFICATION = 1;
+
+ int TYPE_FOTA_CLIENT_SESSION_REQUEST = 2;
+
+ int TYPE_FOTA_NOTIFY_SERVER = 3;
+
+ int TYPE_CANCEL_DM_SESSION = 4;
+
+ int TYPE_CLIENT_SESSION_REQUEST = 6;
+
+ int TYPE_LAWMO_NOTIFY_SESSION = 15;
+
+ int TYPE_DO_NOTHING = 100;
+
+
+ String FIELD_TYPE = "Type";
+
+ String FIELD_PKG0 = "Pkg0";
+
+ String FIELD_REQUEST_ID = "RequestID";
+
+ String FIELD_ALERT_STR = "AlertStr";
+
+ String FIELD_DMRESULT = "DMResult";
+
+ String FIELD_FOTA_RESULT = "fotaResult";
+
+ String FIELD_PKGURI = "PkgURI";
+
+ String FIELD_ALERTTYPE = "AlertType";
+
+ String FIELD_SERVERID = "ServerID";
+
+ String FIELD_SERVER_URL = "ServerURL";
+
+ String FIELD_PROXY_ADDRESS = "ProxyAddress";
+
+ String FIELD_TIMER = "Timer";
+
+ String FIELD_CORR = "Correlator";
+
+ String FIELD_DM_UNITEST_RESULT = "UnitestResult";
+
+ String FIELD_FILENAME = "FileName";
+
+ String FIELD_IS_BINARY = "IsBinary";
+
+ String FIELD_BOOTSTRAP_MSG = "BootstrapMsg";
+
+ String FIELD_LAWMO_RESULT = "LawmoResult";
+
+}
diff --git a/DMService/src/com/android/omadm/service/DMIntentReceiver.java b/DMService/src/com/android/omadm/service/DMIntentReceiver.java
new file mode 100644
index 0000000..c576fc5
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMIntentReceiver.java
@@ -0,0 +1,1070 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.Bundle;
+import android.os.SystemProperties;
+import android.telephony.TelephonyManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.TelephonyProperties;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+public class DMIntentReceiver extends BroadcastReceiver {
+ private static final String TAG = "DMIntentReceiver";
+ private static final boolean DBG = DMClientService.DBG;
+
+ private int mUIMode = -1;
+
+ private byte[] mData;
+
+ private static final String ALERT_TYPE_DOWNLOADANDUPDATE
+ = "org.openmobilealliance.dm.firmwareupdate.downloadandupdate";
+
+ private static final String RP_OPERATIONS_FACTORYRESET
+ = "./ManagedObjects/LAWMO/Operations/FactoryReset";
+
+ private static final String RP_EXT_OPERATIONS_RESET
+ = "./ManagedObjects/LAWMO/Ext/Operations/Reset";
+
+ private static final String ACTION_NOTIFY_RESULT_TO_SERVER
+ = "com.android.omadm.service.notify_result_to_server";
+
+ private static final String ACTION_NOTIFY_START_UP_DMSERVICE
+ = "com.android.omadm.service.start_up";
+
+ private static final String DEV_DETAIL = "devdetail";
+
+ private static final String WIFI_MAC_ADDR = "wifimacaddr";
+
+ private static final String PRE_FW_VER = "prefwversion";
+
+ private static final String CURR_FW_VER = "currfwversion";
+
+ private static final String LAST_UPD_TIME = "lastupdatetime";
+
+ private static boolean initialWapPending;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (DMHelper.disableIfSecondaryUser(context)) {
+ return;
+ }
+
+ String action = intent.getAction();
+
+ logd("Received new intent: " + action);
+
+ if (action.equals(DMIntent.ACTION_WAP_PUSH_RECEIVED_INTERNAL)) {
+ handleWapPushIntent(context, intent);
+ } else if (action.equals(DMIntent.ACTION_CLOSE_NOTIFICATION_INFO)) {
+ DMHelper.cancelNotification(context, DMHelper.NOTIFICATION_INFORMATIVE_ID);
+ } else if (action.equals(DMIntent.ACTION_USER_CONFIRMED_DM_SESSION)) {
+ handleUserConfirmedSession(context);
+ } else if (action.equals(DMIntent.ACTION_CLIENT_INITIATED_FOTA_SESSION)) {
+ handleClientInitiatedFotaIntent(context, intent);
+ } else if (action.equals(DMIntent.ACTION_TIMER_ALERT)) {
+ handleTimeAlertIntent(context);
+ } else if (action.equals(DMIntent.DM_SERVICE_RESULT_INTENT)) {
+ handleDmServiceResult(context, intent);
+ } else if (action.equals(ACTION_NOTIFY_RESULT_TO_SERVER)) {
+ // FIXME old comment: change this to the DMIntent name
+ handleNotifyResultToServer(context, intent);
+ } else if (action.equals(DMIntent.ACTION_DATA_CONNECTION_READY)) {
+ handleDataConnectionReady(context);
+ } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
+ logd("Ignoring Intent.ACTION_BOOT_COMPLETED");
+ //if (!(isPhoneTypeLTE() || isPhoneTypeCDMA3G(context))) {
+ // saveDevDetail(context);
+ // handleBootCompletedIntent(context);
+ //}
+ } else if (action.equals(ACTION_NOTIFY_START_UP_DMSERVICE)) {
+ if (isPhoneTypeLTE()) {
+ saveDevDetail(context);
+ SharedPreferences p = context.getSharedPreferences(DMHelper.IMEI_PREFERENCE_KEY, 0);
+ String currGsmImei = p.getString(DMHelper.IMEI_VALUE_KEY, "");
+ if (currGsmImei != null && currGsmImei.equals(intent.getStringExtra("gsmimei"))) {
+ logd("IMEI already stored, continuing");
+ } else {
+ SharedPreferences.Editor ed = p.edit();
+ ed.putString(DMHelper.IMEI_VALUE_KEY, intent.getStringExtra("gsmimei"));
+ ed.apply();
+ }
+ } else if (isPhoneTypeCDMA3G(context)) {
+ SharedPreferences p = context.getSharedPreferences(DMHelper.AKEY_PREFERENCE_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+ ed.putString(DMHelper.AKEY_VALUE_KEY, intent.getStringExtra("akey"));
+ ed.apply();
+ }
+ handleBootCompletedIntent(context);
+ } else if (action.equals(DMIntent.ACTION_INJECT_PACKAGE_0_INTERNAL)) {
+ String strServerID = intent.getStringExtra(DMIntent.FIELD_SERVERID);
+ if (strServerID == null || strServerID.trim().isEmpty()) {
+ logd("Error! Can't inject package0. The required extras parameter '" +
+ DMIntent.FIELD_SERVERID + "' is null or an empty string.");
+ return;
+ }
+
+ Intent newIntent = new Intent(DMIntent.LAUNCH_INTENT);
+ newIntent.putExtra(DMIntent.FIELD_REQUEST_ID, System.currentTimeMillis());
+ newIntent.putExtra(DMIntent.FIELD_TYPE, DMIntent.TYPE_CLIENT_SESSION_REQUEST);
+ newIntent.putExtra(DMIntent.FIELD_SERVERID, strServerID);
+ logd("XXX received ACTION_INJECT_PACKAGE_0_INTERNAL, starting"
+ + " TYPE_CLIENT_SESSION_REQUEST with ID "
+ + newIntent.getLongExtra(DMIntent.FIELD_REQUEST_ID, 1234));
+ newIntent.setClass(context, DMClientService.class);
+ context.startService(newIntent);
+ } else if (action.equals(DMIntent.ACTION_SET_SERVER_CONFIG)) {
+ logd("ACTION_SET_SERVER_CONFIG received");
+ String hostUrl = intent.getStringExtra(DMIntent.FIELD_SERVER_URL);
+ String proxyAddress = intent.getStringExtra(DMIntent.FIELD_PROXY_ADDRESS);
+ logd("server URL: " + hostUrl + " proxy address: " + proxyAddress);
+ DMHelper.setServerUrl(context, hostUrl);
+ DMHelper.setProxyHostname(context, proxyAddress);
+ } else if (action.equals(DMIntent.ACTION_CANCEL_SESSION)) {
+ // create intent and start DM service
+ Intent newIntent = new Intent(DMIntent.LAUNCH_INTENT);
+ newIntent.putExtra(DMIntent.FIELD_TYPE, DMIntent.TYPE_CANCEL_DM_SESSION);
+ logd("cancelling DM Session");
+ newIntent.setClass(context, DMClientService.class);
+ context.startService(newIntent);
+ }
+ }
+
+ // handle client-initiated FOTA intents
+ private void handleClientInitiatedFotaIntent(Context context, Intent intent) {
+ String strServerID = intent.getStringExtra(DMIntent.FIELD_SERVERID);
+ if (TextUtils.isEmpty(strServerID)) {
+ logd("Error! Can't start FOTA session: " +
+ DMIntent.FIELD_SERVERID + " is null or an empty string.");
+ return;
+ }
+
+ String alertString = intent.getStringExtra(DMIntent.FIELD_ALERT_STR);
+ if (TextUtils.isEmpty(alertString)) {
+ logd("Error! Can't start FOTA session: " +
+ DMIntent.FIELD_ALERT_STR + " is null or an empty string.");
+ return;
+ }
+
+ setState(context, DMHelper.STATE_APPROVED_BY_USER);
+ long requestID = System.nanoTime();
+
+ // Save pending info here
+ SharedPreferences p = context.getSharedPreferences(DMHelper.DM_PREFERENCES_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+ ed.putInt(DMHelper.DM_SESSION_TYPE_KEY, DMIntent.TYPE_FOTA_CLIENT_SESSION_REQUEST);
+ ed.putLong(DMHelper.MESSAGE_TIMESTAMP_ID_KEY, requestID);
+ ed.putString(DMHelper.FOTA_SERVER_ID_KEY, strServerID);
+ ed.putString(DMHelper.FOTA_ALERT_STRING_KEY, alertString);
+ ed.apply();
+
+ if (isWifiConnected(context) || isDataNetworkAcceptable(context)) {
+ if (!isWifiConnected(context) && isDataNetworkAcceptable(context) && isPhoneTypeLTE()) {
+ logd("handleClientInitiatedFotaIntent, start apn monitoring service"
+ + " for requestID " + requestID);
+ setFotaApnState(context, DMHelper.FOTA_APN_STATE_START_DM_SESSION);
+ startDataConnectionService(context);
+ } else {
+ logd("handleClientInitiatedFotaIntent starting DM session");
+ startDMSession(context);
+ }
+ } else {
+ logd("handleClientInitiatedFotaIntent: start data/call state monitoring");
+ startDataConnectionService(context);
+ }
+ }
+
+ // handle SMS and WAP Push intents;
+ private void handleWapPushIntent(Context context, Intent intent) {
+
+ int currentState = getState(context);
+
+ logd("handleWapPushIntent() current state: " + currentState);
+
+ // if current state is already "session in progress" - ignore new message;
+ // otherwise remove old message and process a new one.
+ if (currentState == DMHelper.STATE_SESSION_IN_PROGRESS) {
+ loge("current state is 'Session-in-Progress', ignoring new message.");
+ return;
+ }
+
+ DMHelper.cleanAllResources(context);
+
+ //clean fota apn resources and stop using fota apn
+ if (isPhoneTypeLTE()) {
+ int mgetFotaApnState = getFotaApnState(context);
+ logd("handleWapPushIntent, check if necessary to stop using fota apn "
+ + mgetFotaApnState);
+ if (mgetFotaApnState != DMHelper.FOTA_APN_STATE_INIT) {
+ // resetting FOTA APN STATE
+ logd("XXX resetting FOTA APN state");
+ setFotaApnState(context, DMHelper.FOTA_APN_STATE_INIT);
+ stopUsingFotaApn(context);
+ DMHelper.cleanFotaApnResources(context);
+ }
+ }
+
+ //parse & save message; get UI mode
+ boolean result = parseAndSaveWapPushMessage(context, intent);
+
+ if (!result) {
+ loge("handleWapPushIntent(): error in parseAndSaveWapPushMessage()");
+ DMHelper.cleanAllResources(context);
+ return;
+ }
+
+ if (treeExist(context) || !isPhoneTypeLTE()) {
+ //check UI mode and prepare and start process
+ preprocess(context, currentState);
+ } else {
+ logd("WapPush arrived before tree initialization");
+ initialWapPending = true;
+ Intent intentConnmoInit = new Intent("com.android.omadm.service.wait_timer_alert");
+ context.sendBroadcast(intentConnmoInit);
+ }
+ }
+
+ private void handleUserConfirmedSession(Context context) {
+ // check if message is not expired
+ if (DMHelper.isMessageExpired(context)) {
+ DMHelper.cleanAllResources(context);
+ logd("handleUserConfirmedSession(): message is expired.");
+ return;
+ }
+
+ startProcess(context);
+ }
+
+ // handle boot completed intent
+ private void handleBootCompletedIntent(Context context) {
+ // Check if DM tree already has been generated. Start service to generate tree
+ // in case if required. It may happened only once during first boot.
+ if (!treeExist(context)) {
+ logd("Boot completed: there is no DM Tree. Start service to generate tree.");
+ Intent intent = new Intent(DMIntent.LAUNCH_INTENT);
+ intent.putExtra("NodePath", ".");
+ intent.putExtra(DMIntent.FIELD_REQUEST_ID, -2L);
+ intent.setClass(context, DMClientService.class);
+ context.startService(intent);
+ if (!initialWapPending) {
+ logd("handleBootCompletedIntent, no initial WapPush pending.");
+ DMHelper.cleanAllResources(context);
+ return;
+ } else {
+ logd("handleBootCompletedIntent, initial WapPush pending.");
+ initialWapPending = false;
+ setState(context, DMHelper.STATE_PENDING_MESSAGE);
+ }
+ }
+
+// if (isPhoneTypeLTE()) {
+// int fotaApnState = getFotaApnState(context);
+// logd("handleBootCompletedIntent, check if need to stop using fota apn "
+// + fotaApnState);
+// if (fotaApnState != DMHelper.FOTA_APN_STATE_INIT) {
+ // resetting FOTA APN STATE
+// setFotaApnState(context, DMHelper.FOTA_APN_STATE_INIT);
+ //stopUsingFotaApn();
+// DMHelper.cleanFotaApnResources(context);
+// }
+ // stopUsingFotaApn();
+// }
+
+ int currentState = getState(context);
+
+ if (currentState == DMHelper.STATE_IDLE) {
+ logd("Boot completed: there is no message to proceed.");
+ return;
+ }
+
+ // check if message is not expired
+ if (DMHelper.isMessageExpired(context)) {
+ DMHelper.cleanAllResources(context);
+ logd("handleBootCompletedIntent(): the message is expired.");
+ return;
+ }
+
+ // initiate mUIMode and mData from preferences
+ if (!initFromSharedPreferences(context)) {
+ DMHelper.cleanAllResources(context);
+ logd("handleBootCompletedIntent(): cannot init from shared preferences");
+ return;
+ }
+
+ preprocess(context, currentState);
+ }
+
+ // handle time alert intent (all instances)
+ private void handleTimeAlertIntent(Context context) {
+ int currentState = getState(context);
+ switch (currentState) {
+ case DMHelper.STATE_IDLE:
+ // nothing there
+ DMHelper.cleanAllResources(context);
+ logd("Time alert: there is no message to proceed.");
+ break;
+ }
+
+ if (currentState == DMHelper.STATE_IDLE) {
+ // nothing there
+ DMHelper.cleanAllResources(context);
+ logd("Time alert: there is no message to proceed.");
+ } else if (DMHelper.isMessageExpired(context)) {
+ // check if message is not expired
+ DMHelper.cleanAllResources(context);
+ logd("Warning from handleTimeAlertIntent(): the message is expired.");
+ } else if (currentState == DMHelper.STATE_SESSION_IN_PROGRESS) {
+ // session in progress; doing nothing.
+ logd("Time alert: session in progress; doing nothing.");
+ DMHelper.subscribeForTimeAlert(context,
+ DMHelper.TIME_CHECK_STATUS_AFTER_STARTING_DM_SERVICE);
+ } else if (currentState == DMHelper.STATE_APPROVED_BY_USER) {
+ // approved by user: try to start session or data/call monitoring service
+ logd("Time alert: state 'approved by user'; starting process");
+ startProcess(context);
+ } else if (currentState == DMHelper.STATE_PENDING_MESSAGE) {
+ // approved by user: try to start session or data/call monitoring service pending
+ logd("Time alert: state 'pending message'; read from preferences starting preprocess");
+
+ // initiate mUIMode and mData from preferences
+ if (!initFromSharedPreferences(context)) {
+ DMHelper.cleanAllResources(context);
+ logd("Warning from handleTimeAlertIntent(): cannot init from shared preferences");
+ return;
+ }
+ preprocess(context, currentState);
+ } else {
+ loge("Error from handleTimeAlertIntent(): unknown state " + currentState);
+ }
+ }
+
+ private static void handleNotifyResultToServer(Context context, Intent intent) {
+ logd("Inside handleNotifyResultToServer");
+
+ // Save message
+ SharedPreferences p = context.getSharedPreferences(DMHelper.FOTA_APN_PREFERENCE_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+
+ ed.putString(DMHelper.LAWMO_RESULT_KEY, intent.getStringExtra(DMIntent.FIELD_LAWMO_RESULT));
+ ed.putString(DMHelper.FOTA_RESULT_KEY, intent.getStringExtra(DMIntent.FIELD_FOTA_RESULT));
+ ed.putString(DMHelper.PKG_URI_KEY, intent.getStringExtra(DMIntent.FIELD_PKGURI));
+ ed.putString(DMHelper.ALERT_TYPE_KEY, intent.getStringExtra(DMIntent.FIELD_ALERTTYPE));
+ ed.putString(DMHelper.CORRELATOR_KEY, intent.getStringExtra(DMIntent.FIELD_CORR));
+ ed.putString(DMHelper.SERVER_ID_KEY, intent.getStringExtra(DMIntent.FIELD_SERVERID));
+
+ ed.apply();
+
+ if (isDataNetworkAcceptable(context) && !isWifiConnected(context) && isPhoneTypeLTE()) {
+ int mgetFotaApnState = getFotaApnState(context);
+ if (mgetFotaApnState != DMHelper.FOTA_APN_STATE_INIT) {
+ logd("there must be a pending session, return");
+ return;
+ }
+ // for LTE and eHRPD coverage , switch the apn before FDM
+ logd("handleNotifyResultToServer starting FOTA APN");
+ setFotaApnState(context, DMHelper.FOTA_APN_STATE_REPORT_DM_SESSION);
+ startDataConnectionService(context);
+ } else {
+ sendNotifyIntent(context);
+ }
+ }
+
+ // start session if we have network connectivity
+ private void handleDataConnectionReady(Context context) {
+ logd("Inside handleDataConnectionReady");
+ int fotaApnState = getFotaApnState(context);
+ logd("FOTA APN state is " + fotaApnState);
+
+ if (fotaApnState == DMHelper.FOTA_APN_STATE_REPORT_DM_SESSION) {
+ setFotaApnState(context, DMHelper.FOTA_APN_STATE_REPORT_DM_SESSION_RPTD);
+ sendNotifyIntent(context);
+ } else if (fotaApnState == DMHelper.FOTA_APN_STATE_START_DM_SESSION) {
+ setFotaApnState(context, DMHelper.FOTA_APN_STATE_START_DM_SESSION_RPTD);
+ // check if message is not expired
+ if (DMHelper.isMessageExpired(context)) {
+ DMHelper.cleanAllResources(context);
+ logd("Warning from handleApnStateActive(): the message is expired.");
+ return;
+ }
+
+ int currentState = getState(context);
+
+ // nothing to do here
+ if (currentState == DMHelper.STATE_IDLE) {
+ DMHelper.cleanAllResources(context);
+ logd("handleApnStateActive(): there is no message to proceed.");
+ return;
+ }
+
+ if (currentState == DMHelper.STATE_SESSION_IN_PROGRESS) {
+ logd("handleApnStateActive(): session in progress; doing nothing.");
+ return;
+ }
+
+ startDMSession(context);
+ } else {
+ logd("handleApnStateActive: NO ACTION NEEDED");
+ }
+ }
+
+ // check UI mode and prepare and start process
+ private void preprocess(Context context, int currentState) {
+
+ setState(context, currentState);
+
+ logd("From preprocess().... Current state = " + currentState);
+
+ // check UI mode. If updates has been replaced with the new one and user already
+ // confirmed - we are skipping confirmation.
+ if (mUIMode == DMHelper.UI_MODE_CONFIRMATION
+ && currentState != DMHelper.STATE_APPROVED_BY_USER) {
+
+ // user confirmation is required
+ logd("User confirmation is required");
+ DMHelper.postConfirmationNotification(context);
+ setState(context, DMHelper.STATE_PENDING_MESSAGE);
+
+ // check and repost notification in case user cancels it
+ DMHelper.subscribeForTimeAlert(context,
+ DMHelper.TIME_CHECK_NOTIFICATION_AFTER_SUBSCRIPTION);
+
+ return;
+ }
+
+ if (mUIMode == DMHelper.UI_MODE_INFORMATIVE) {
+ // required notification, just inform the user
+ logd("User notification is required");
+ DMHelper.postInformativeNotification_message1(context);
+ } else {
+ logd("Silent DM session: silent mode or user already has approved.");
+ }
+
+ // try to start DM session or start Data and Call State Monitoring Service
+ startProcess(context);
+ }
+
+ // parse data from intent; set UI mode; save required data.
+ private boolean parseAndSaveWapPushMessage(Context context, Intent intent) {
+
+ // Parse message
+ Bundle bdl = intent.getExtras();
+ byte[] data = bdl.getByteArray("data");
+ mData = data;
+
+ if (data == null || data.length < 25) {
+ loge("parseAndSaveWapPushMessage: data[] is null or length < 25.");
+ return false;
+ }
+
+ // first 16 bytes - digest
+ int version = ((data[17] >> 6) & 0x3) | ((data[16]) << 2);
+ int uiMode = (data[17] >> 4) & 0x3;
+ int indicator = (data[17] >> 3) & 0x1;
+ int sessionId = ((data[21] & 0xff) << 8) | data[22];
+ int serverIdLength = data[23]; // must be equal to data.length-24
+
+ if (serverIdLength <= 0) {
+ loge("parseAndSaveWapPushMessage: serverIdLength is invalid: " + serverIdLength);
+ return false;
+ }
+
+ String serverId = new String(data, 24, serverIdLength, StandardCharsets.UTF_8);
+ mUIMode = uiMode;
+
+ // fixme: treating invalid uimode as informative for now
+ if(mUIMode != DMHelper.UI_MODE_CONFIRMATION && mUIMode != DMHelper.UI_MODE_INFORMATIVE) {
+ loge("parseAndSaveWapPushMessage: received uimode " + uiMode + "; changing to informative");
+ mUIMode = DMHelper.UI_MODE_INFORMATIVE;
+ }
+
+ if (DBG) {
+ Log.i(TAG, "Get Provision Package0"
+ + " version:" + version
+ + " uiMode:" + uiMode
+ + " indicator:" + indicator
+ + " sessionId:" + sessionId
+ + " serverId:" + serverId);
+ }
+
+ // Save message
+ SharedPreferences p = context.getSharedPreferences(DMHelper.DM_PREFERENCES_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+ //ed.putInt("type", DMIntent.TYPE_PKG0_NOTIFICATION);
+ //ed.putLong(DMHelper.REQUEST_ID_KEY, System.currentTimeMillis());
+ ed.putInt("length", data.length);
+ ed.putInt(DMHelper.DM_SESSION_TYPE_KEY, DMIntent.TYPE_PKG0_NOTIFICATION);
+ ed.putLong(DMHelper.MESSAGE_TIMESTAMP_ID_KEY, System.nanoTime());
+ ed.putInt(DMHelper.DM_UI_MODE_KEY, mUIMode);
+
+ ed.apply();
+
+// PendingResult pendingResult = goAsync();
+// DMParseSaveWapMsgRunnable dmParseSaveWapMsgRunnable
+// = new DMParseSaveWapMsgRunnable(pendingResult);
+// Thread dmParseSaveWapMsgThread = new Thread(dmParseSaveWapMsgRunnable);
+// dmParseSaveWapMsgThread.start();
+
+ // TODO: move to worker thread
+ try {
+ FileOutputStream out = new FileOutputStream(DMHelper.POSTPONED_DATA_PATH);
+ out.write(mData);
+ out.close();
+ } catch (IOException e) {
+ loge("IOException while creating dmpostponed.dat", e);
+ }
+
+ return true;
+ }
+
+// TODO: remove or uncomment to use for saving file asynchronously
+// class DMParseSaveWapMsgRunnable implements Runnable {
+// /** Pending result to call finish() when thread returns. */
+// private final PendingResult mPendingResult;
+//
+// DMParseSaveWapMsgRunnable(PendingResult pendingResult) {
+// mPendingResult = pendingResult;
+// }
+//
+// @Override
+// public void run() {
+// logd("Enter dmParseSaveWapMsgThread tid=" + Thread.currentThread().getId());
+// try {
+// FileOutputStream out = new FileOutputStream(DMHelper.POSTPONED_DATA_PATH);
+// out.write(mData);
+// out.close();
+// } catch (IOException e) {
+// loge("IOException while creating dmpostponed.dat", e);
+// } finally {
+// mPendingResult.finish();
+// }
+// }
+// }
+
+ //try to start DM session or starts Data and Call State Monitoring Service
+ private void startProcess(Context context) {
+ //wrj348 - VZW customization: reject the wap push if phone is in ECB mode or Roaming
+ if (!allowDMSession()) {
+ return;
+ }
+ setState(context, DMHelper.STATE_APPROVED_BY_USER);
+
+ // Start DM session if wifi is available.
+ if (isWifiConnected(context)) {
+ startDMSession(context);
+ } else {
+ // request FOTA APN
+ logd("startProcess(), start data connection service");
+ setFotaApnState(context, DMHelper.FOTA_APN_STATE_START_DM_SESSION);
+ startDataConnectionService(context);
+ }
+ }
+
+ private static boolean allowDMSession() {
+ if (isInECBMode()) {
+ return false;
+ }
+
+ Log.i(TAG, "DMSession allowed - don't reject");
+ return true;
+ }
+
+ /**
+ * Returns whether phone is in emergency callback mode.
+ * @return true if the phone is in ECB mode; false if not
+ */
+ private static boolean isInECBMode() {
+ boolean ecbMode = SystemProperties.getBoolean(
+ TelephonyProperties.PROPERTY_INECM_MODE, false);
+ Log.i(TAG, "Phone ECB status: " + ecbMode);
+ return ecbMode;
+ }
+
+ //start DM session.
+ private void startDMSession(Context context) {
+ logd("startDMSession");
+ // get request ID from the shared preferences (the message time stamp used)
+ SharedPreferences p = context.getSharedPreferences(DMHelper.DM_PREFERENCES_KEY, 0);
+
+ long requestID = p.getLong(DMHelper.MESSAGE_TIMESTAMP_ID_KEY, -1);
+ int type = p.getInt(DMHelper.DM_SESSION_TYPE_KEY, -1);
+
+ // create intent and start DM service
+ Intent intent = new Intent(DMIntent.LAUNCH_INTENT);
+ intent.putExtra(DMIntent.FIELD_REQUEST_ID, requestID);
+ intent.putExtra(DMIntent.FIELD_TYPE, type);
+
+ if (type == DMIntent.TYPE_FOTA_CLIENT_SESSION_REQUEST) {
+ String serverID = p.getString(DMHelper.FOTA_SERVER_ID_KEY, null);
+ String alertString = p.getString(DMHelper.FOTA_ALERT_STRING_KEY, null);
+ intent.putExtra(DMIntent.FIELD_TYPE, DMIntent.TYPE_FOTA_CLIENT_SESSION_REQUEST);
+ intent.putExtra(DMIntent.FIELD_SERVERID, serverID);
+ intent.putExtra(DMIntent.FIELD_ALERT_STR, alertString);
+ logd("starting TYPE_FOTA_CLIENT_SESSION_REQUEST: serverID="
+ + serverID + " alertString=" + alertString
+ + " requestID=" + requestID);
+ } else {
+ // package 0 notification
+ intent.putExtra(DMIntent.FIELD_TYPE, type);
+
+ if (mData == null) { // session has not been started right away after receiving a message.
+ mData = setDataFromFile(context);
+
+ if (mData == null) {
+ logd("Error. Cannot read data from file dmpostponed.dat");
+ DMHelper.cleanAllResources(context);
+ return;
+ }
+ }
+
+ intent.putExtra(DMIntent.FIELD_PKG0, mData);
+ }
+
+ increaseDMSessionAttempt(context);
+
+ setState(context, DMHelper.STATE_SESSION_IN_PROGRESS);
+
+ DMHelper.subscribeForTimeAlert(context,
+ DMHelper.TIME_CHECK_STATUS_AFTER_STARTING_DM_SERVICE);
+
+ intent.setClass(context, DMClientService.class);
+ context.startService(intent);
+ }
+
+ // start data connection service
+ private static void startDataConnectionService(Context context) {
+ logd("Inside startDataConnectionService");
+ DMHelper.subscribeForTimeAlert(context,
+ DMHelper.TIME_CHECK_STATUS_AFTER_STARTING_MONITORING_SERVICE);
+ Intent intent = new Intent(DMIntent.ACTION_START_DATA_CONNECTION_SERVICE);
+ intent.setClass(context, DMDataConnectionService.class);
+ context.startService(intent);
+ }
+
+ // stop data connection service
+ private static void stopDataConnectionService(Context context) {
+ logd("Inside stopDataConnectionService");
+ Intent intent = new Intent(DMIntent.ACTION_START_DATA_CONNECTION_SERVICE);
+ intent.setClass(context, DMDataConnectionService.class);
+ context.stopService(intent);
+ }
+
+ // Verify session result: if result is successful, clean all resources.
+ // Otherwise, try to resubmit session request.
+ private void handleDmServiceResult(Context context, Intent intent) {
+ // check if request ID from incoming intent match to the one which has been sent and saved
+ // get request ID from the shared preferences (the message time stamp used)
+ SharedPreferences p = context.getSharedPreferences(DMHelper.DM_PREFERENCES_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+ long savedRequestId = p.getLong(DMHelper.MESSAGE_TIMESTAMP_ID_KEY, 0);
+ long receivedRequestId = intent.getLongExtra(DMIntent.FIELD_REQUEST_ID, -1);
+
+ if (receivedRequestId == -2) {
+ logd("handleDmServiceResult, tree initialisation session.");
+ return;
+ }
+
+ // clear fota apn resources and stop using fota apn
+ if (isPhoneTypeLTE()) {
+ int fotaApnState = getFotaApnState(context);
+ logd("handleDmServiceResult, chk if need to stop using fota apn "
+ + fotaApnState);
+ if (fotaApnState != DMHelper.FOTA_APN_STATE_INIT) {
+ // resetting FOTA APN STATE
+ setFotaApnState(context, DMHelper.FOTA_APN_STATE_INIT);
+ stopUsingFotaApn(context);
+ // removing shared prefs settings
+ DMHelper.cleanFotaApnResources(context);
+ }
+ stopUsingFotaApn(context);
+ }
+
+ if (savedRequestId != receivedRequestId) {
+ loge("request ID " + receivedRequestId + " from result intent doesn't "
+ + "match saved request ID " + savedRequestId + ", ignored");
+// return;
+ }
+
+ int sessionResult = intent.getIntExtra(DMIntent.FIELD_DMRESULT, -1);
+
+ int uiMode = p.getInt(DMHelper.DM_UI_MODE_KEY, -1);
+ mUIMode = uiMode;
+ logd("mUIMode is: " + uiMode);
+ if (uiMode == DMHelper.UI_MODE_INFORMATIVE) {
+ if (sessionResult == DMResult.SYNCML_DM_SUCCESS) {
+ logd("Displaying success notification message2");
+ DMHelper.postInformativeNotification_message2_success(context);
+ } else {
+ logd("Displaying Fail notification message2");
+ DMHelper.postInformativeNotification_message2_fail(context);
+ }
+ ed.putInt(DMHelper.DM_UI_MODE_KEY, -1);
+ ed.apply();
+ }
+
+ if (sessionResult == DMResult.SYNCML_DM_SUCCESS) {
+ DMHelper.cleanAllResources(context);
+ logd("Finished success.");
+ return;
+ }
+
+ if (!canRestartSession(context, p)) {
+ DMHelper.cleanAllResources(context);
+ return;
+ }
+
+ // update status in the preferences
+ setState(context, DMHelper.STATE_APPROVED_BY_USER);
+
+ //subscribe for the time alert to start DM session again after TIME_BETWEEN_SESSION_ATTEMPTS.
+ DMHelper.subscribeForTimeAlert(context, DMHelper.TIME_BETWEEN_SESSION_ATTEMPTS);
+ }
+
+ // check if session request can be resubmitted (if message still valid and
+ // number of tries doesn't exceed MAX)
+ private static boolean canRestartSession(Context context, SharedPreferences p) {
+ int numberOfSessionAttempts = p.getInt(DMHelper.DM_SESSION_ATTEMPTS_KEY, -1);
+
+ // check if max number has not been exceeded
+ if (numberOfSessionAttempts > DMHelper.MAX_SESSION_ATTEMPTS) {
+ logd("Error. Number of attempts to start DM session exceed MAX.");
+ return false;
+ }
+
+ // check if message is expired or not
+ if (DMHelper.isMessageExpired(context)) {
+ logd("Error from canRestartSession(): the message is expired.");
+ return false;
+ }
+
+ return true;
+ }
+
+ // set current state
+ private static void setState(Context context, int state) {
+ SharedPreferences p = context.getSharedPreferences(DMHelper.DM_PREFERENCES_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+ ed.putInt(DMHelper.STATE_KEY, state);
+ ed.apply();
+ }
+
+ /**
+ * Get current state from shared prefs. If state is "Session In Progress", verify that the DM
+ * session didn't fail and also has the same status, otherwise current state will be changed
+ * to "Approved by User" and will be ready to handle a request for a new DM session.
+ *
+ * @param context the context to use
+ * @return the current state
+ */
+ private static int getState(Context context) {
+ SharedPreferences p = context.getSharedPreferences(DMHelper.DM_PREFERENCES_KEY, 0);
+ int currentState = p.getInt(DMHelper.STATE_KEY, 0);
+
+ if (currentState == DMHelper.STATE_SESSION_IN_PROGRESS
+ && !DMClientService.sIsDMSessionInProgress) {
+ currentState = DMHelper.STATE_APPROVED_BY_USER;
+ setState(context, currentState);
+ }
+ return currentState;
+ }
+
+ // increase attempt to start DM session
+ private static void increaseDMSessionAttempt(Context context) {
+ SharedPreferences p = context.getSharedPreferences(DMHelper.DM_PREFERENCES_KEY, 0);
+ int numberOfSessionAttempts = p.getInt(DMHelper.DM_SESSION_ATTEMPTS_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+ ed.putInt(DMHelper.DM_SESSION_ATTEMPTS_KEY, (numberOfSessionAttempts + 1));
+ ed.apply();
+ }
+
+ // check and initialize variables from preferences
+ private boolean initFromSharedPreferences(Context context) {
+ SharedPreferences p = context.getSharedPreferences(DMHelper.DM_PREFERENCES_KEY, 0);
+ long timestamp = p.getLong(DMHelper.MESSAGE_TIMESTAMP_ID_KEY, -1);
+ mUIMode = p.getInt(DMHelper.DM_UI_MODE_KEY, -1);
+ mData = setDataFromFile(context);
+ boolean success = !(timestamp <= 0 || mUIMode < 0);
+ if (DBG) logd("initFromSharedPreferences: " + (success ? "ok" : "fail"));
+ return success;
+ }
+
+ private static byte[] setDataFromFile(Context context) {
+ SharedPreferences p = context.getSharedPreferences(DMHelper.DM_PREFERENCES_KEY, 0);
+ int length = p.getInt("length", -1);
+
+ if (length <= 0) {
+ //logd("Error. Invalid postponed data length.");
+ return null;
+ }
+
+ byte[] data = new byte[length];
+
+ try {
+ FileInputStream in = new FileInputStream(DMHelper.POSTPONED_DATA_PATH);
+ if (in.read(data) <= 0) {
+ logd("Invalid postponed data.");
+ in.close();
+ return null;
+ }
+ in.close();
+ return data;
+ } catch (IOException e) {
+ loge("IOException", e);
+ return null;
+ }
+ }
+
+ private static boolean treeExist(Context context) {
+ if (context != null) {
+ String strTreeHomeDir = context.getFilesDir().getAbsolutePath() + "/dm";
+ File dirDes = new File(strTreeHomeDir);
+
+ if (dirDes.exists() && dirDes.isDirectory()) {
+ logd("DM Tree exists:" + strTreeHomeDir);
+ return true;
+ } else {
+ logd("DM Tree NOT exists:" + strTreeHomeDir);
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ // set current state
+ private static void setFotaApnState(Context context, int state) {
+ logd("setFotaApnState: " + state);
+ SharedPreferences p = context.getSharedPreferences(DMHelper.FOTA_APN_PREFERENCE_KEY, 0);
+ SharedPreferences.Editor ed = p.edit();
+ ed.putInt(DMHelper.FOTA_APN_STATE_KEY, state);
+ ed.apply();
+ }
+
+ // get current state.
+ private static int getFotaApnState(Context context) {
+ SharedPreferences p = context.getSharedPreferences(DMHelper.FOTA_APN_PREFERENCE_KEY, 0);
+ return p.getInt(DMHelper.FOTA_APN_STATE_KEY, 0);
+ }
+
+ /**
+ * Stop using the FOTA APN.
+ * @param context the BroadcastReceiver context
+ */
+ private static void stopUsingFotaApn(Context context) {
+ logd("stopUsingFotaApn");
+
+ ConnectivityManager connMgr = (ConnectivityManager) context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ int result = connMgr.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,
+ Phone.FEATURE_ENABLE_FOTA);
+ if (result != -1) {
+ Log.w(TAG, "stopUsingNetworkFeature result=" + result);
+ }
+ stopDataConnectionService(context);
+ }
+
+ // Function which will send intents to start FDM
+ private static void sendNotifyIntent(Context context) {
+ logd("Inside sendNotifyIntent");
+
+ SharedPreferences p = context.getSharedPreferences(DMHelper.FOTA_APN_PREFERENCE_KEY, 0);
+ String lawmoResult = p.getString(DMHelper.LAWMO_RESULT_KEY, null);
+ String fotaResult = p.getString(DMHelper.FOTA_RESULT_KEY, null);
+ String pkgURI = p.getString(DMHelper.PKG_URI_KEY, null);
+ String alertType = p.getString(DMHelper.ALERT_TYPE_KEY, null);
+ String correlator = p.getString(DMHelper.CORRELATOR_KEY, null);
+ String serverID = p.getString(DMHelper.SERVER_ID_KEY, null);
+
+ logd("sendNotifyIntent Input==>\n" + " lawmoResult="
+ + lawmoResult + '\n' + "fotaResult="
+ + fotaResult + '\n' + " pkgURI="
+ + pkgURI + '\n' + " alertType="
+ + alertType + '\n' + " serverID="
+ + serverID + '\n' + " correlator="
+ + correlator);
+
+ if (alertType.equals(ALERT_TYPE_DOWNLOADANDUPDATE)) {
+ // Need to send an intent for doing a FOTA FDM session
+ Intent fotafdmintent = new Intent(DMIntent.LAUNCH_INTENT);
+ fotafdmintent.putExtra(DMIntent.FIELD_TYPE, DMIntent.TYPE_FOTA_NOTIFY_SERVER);
+ fotafdmintent.putExtra(DMIntent.FIELD_FOTA_RESULT, fotaResult);
+ fotafdmintent.putExtra(DMIntent.FIELD_PKGURI, pkgURI);
+ fotafdmintent.putExtra(DMIntent.FIELD_ALERTTYPE, alertType);
+ fotafdmintent.putExtra(DMIntent.FIELD_SERVERID, serverID);
+ fotafdmintent.putExtra(DMIntent.FIELD_CORR, correlator);
+ fotafdmintent.setClass(context, DMClientService.class);
+ context.startService(fotafdmintent);
+ } else if (pkgURI.equals(RP_OPERATIONS_FACTORYRESET) || pkgURI
+ .equals(RP_EXT_OPERATIONS_RESET)) {
+ // LAWMO FDM session
+ Intent lawmofdmintent = new Intent(DMIntent.LAUNCH_INTENT);
+ lawmofdmintent.putExtra(DMIntent.FIELD_TYPE, DMIntent.TYPE_LAWMO_NOTIFY_SESSION);
+ lawmofdmintent.putExtra(DMIntent.FIELD_LAWMO_RESULT, lawmoResult);
+ lawmofdmintent.putExtra(DMIntent.FIELD_PKGURI, pkgURI);
+ lawmofdmintent.putExtra(DMIntent.FIELD_ALERTTYPE, "");
+ lawmofdmintent.putExtra(DMIntent.FIELD_CORR, "");
+ lawmofdmintent.setClass(context, DMClientService.class);
+ context.startService(lawmofdmintent);
+ } else {
+ // just return for now
+ logd("No Action, Just return for now");
+ }
+ }
+
+ private static boolean isWifiConnected(Context context) {
+ logd("Inside isWifiConnected");
+
+ ConnectivityManager cm = (ConnectivityManager) context
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (cm == null) {
+ logd("can't get Connectivity Service");
+ return false;
+ }
+
+ NetworkInfo ni = cm.getActiveNetworkInfo();
+ if (ni == null) {
+ logd("NetworkInfo is null");
+ return false;
+ }
+ if (!ni.isConnected()) {
+ logd("Network is not connected");
+ return false;
+ }
+ if (ni.getType() != ConnectivityManager.TYPE_WIFI) {
+ logd("network type is not wifi");
+ return false;
+ }
+
+ // return true only when WiFi is connected
+ return true;
+ }
+
+
+ private static boolean isPhoneTypeLTE() {
+ return DMSettingsHelper.isPhoneTypeLTE();
+ }
+
+ private static boolean isPhoneTypeCDMA3G(Context context) {
+ TelephonyManager tm = (TelephonyManager) context
+ .getSystemService(Context.TELEPHONY_SERVICE);
+ if ((tm.getCurrentPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) && !isPhoneTypeLTE()) {
+ logd("3G CDMA phone");
+ return true;
+ }
+ logd("Non-CDMA or 4G Device");
+ return false;
+ }
+
+ // check if we can set up a mobile data connection on this network type
+ private static boolean isDataNetworkAcceptable(Context context) {
+ TelephonyManager tm = (TelephonyManager) context
+ .getSystemService(Context.TELEPHONY_SERVICE);
+
+ int callState = tm.getCallState();
+ if (callState != TelephonyManager.CALL_STATE_IDLE) {
+ logd("Call state not idle: " + callState);
+ return false;
+ }
+
+ int dataNetworkType = tm.getDataNetworkType();
+ switch (dataNetworkType) {
+ case TelephonyManager.NETWORK_TYPE_EVDO_0:
+ case TelephonyManager.NETWORK_TYPE_EVDO_A:
+ case TelephonyManager.NETWORK_TYPE_1xRTT:
+ case TelephonyManager.NETWORK_TYPE_EVDO_B:
+ case TelephonyManager.NETWORK_TYPE_LTE:
+ case TelephonyManager.NETWORK_TYPE_EHRPD:
+ logd("Data network type is acceptable: " + dataNetworkType);
+ return true;
+
+ default:
+ logd("Data network type is not acceptable: " + dataNetworkType);
+ return false;
+ }
+ }
+
+ private static void saveDevDetail(Context context) {
+ logd("Inside saveDevDetail");
+
+ String swVer = SystemProperties.get("ro.build.version.full");
+ if (TextUtils.isEmpty(swVer)) {
+ swVer = "Unknown";
+ }
+
+ SharedPreferences p = context.getSharedPreferences(DEV_DETAIL, 0);
+ String currFwV = p.getString(CURR_FW_VER, null);
+ //String preFwV = p.getString(PRE_FW_VER, null);
+
+ SharedPreferences.Editor ed = p.edit();
+ if (TextUtils.isEmpty(currFwV)) {
+ logd("First powerup or powerup after FDR, save current SwV");
+ ed.putString(CURR_FW_VER, swVer);
+ } else if (!(currFwV.equals(swVer))) {
+ logd("System Update success, save previous FwV and LastUpdateTime");
+ ed.putString(PRE_FW_VER, currFwV);
+ ed.putString(CURR_FW_VER, swVer);
+ SimpleDateFormat simpleDateFormat;
+ if (isPhoneTypeLTE()) {
+ simpleDateFormat = new SimpleDateFormat("MM:dd:yyyy:HH:mm", Locale.US);
+ simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ } else {
+ simpleDateFormat = new SimpleDateFormat("MM:dd:yy:HH:mm:ss:z", Locale.US);
+ }
+ String currTime = simpleDateFormat.format(new Date(System.currentTimeMillis()));
+ ed.putString(LAST_UPD_TIME, currTime);
+ }
+ WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ WifiInfo wi = wm.getConnectionInfo();
+ String wMacAddr = (wi == null) ? null : wi.getMacAddress();
+ logd("WiFi Mac address " + wMacAddr);
+ if (!TextUtils.isEmpty(wMacAddr)) {
+ ed.putString(WIFI_MAC_ADDR, wMacAddr);
+ }
+ ed.apply();
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ private static void loge(String msg) {
+ Log.e(TAG, msg);
+ }
+
+ private static void loge(String msg, Throwable tr) {
+ Log.e(TAG, msg, tr);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMPkg0Notification.java b/DMService/src/com/android/omadm/service/DMPkg0Notification.java
new file mode 100644
index 0000000..f4f0286
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMPkg0Notification.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.util.Log;
+
+class DMPkg0Notification {
+ private static final String TAG = "DMPkg0Notification";
+ private static final boolean DBG = DMClientService.DBG;
+
+ private int mUIMode;
+
+ private int mInitiator;
+
+ private int mSessionID;
+
+ private String mServerID;
+
+ private boolean mAuthFlag;
+
+ public DMPkg0Notification() {
+ mSessionID = 0;
+ mUIMode = 0;
+ mInitiator = 0;
+ mAuthFlag = false;
+ mServerID = null;
+ }
+
+ public int getSessionID() {
+ return mSessionID;
+ }
+
+ public int getUIMode() {
+ return mUIMode;
+ }
+
+ public int getInitiator() {
+ return mInitiator;
+ }
+
+ public boolean getAuthFlag() {
+ return mAuthFlag;
+ }
+
+ public String getServerID() {
+ return mServerID;
+ }
+
+ /**
+ * Set the session ID.
+ * Called from JNI code.
+ *
+ * @param sessionID
+ */
+ public void setSessionID(int sessionID) {
+ if (DBG) logd("setSessionID: " + sessionID);
+ mSessionID = sessionID;
+ }
+
+ /**
+ * Set the UI mode.
+ * Called from JNI code.
+ *
+ * @param uiMode
+ */
+ public void setUIMode(int uiMode) {
+ if (DBG) logd("setUIMode: " + uiMode);
+ mUIMode = uiMode;
+ }
+
+ /**
+ * Set the initiator.
+ * Called from JNI code.
+ *
+ * @param initiator
+ */
+ public void setInitiator(int initiator) {
+ if (DBG) logd("setInitiator: " + initiator);
+ mInitiator = initiator;
+ }
+
+ /**
+ * Set the auth flag.
+ * Called from JNI code.
+ *
+ * @param authFlag
+ */
+ public void setAuthFlag(int authFlag) {
+ if (DBG) logd("setAuthFlag: " + authFlag);
+ mAuthFlag = authFlag == 1;
+ }
+
+ /**
+ * Set the server ID.
+ * Called from JNI code.
+ *
+ * @param serverID
+ */
+ public void setServerID(String serverID) {
+ if (DBG) logd("setServerID: \"" + serverID + '"');
+ mServerID = serverID;
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMResult.java b/DMService/src/com/android/omadm/service/DMResult.java
new file mode 100644
index 0000000..bc194bc
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMResult.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+public interface DMResult {
+
+ // The DMEngine return code, which must be consistent with
+ // engine/dmlib/api/common/dmtError.h
+
+ int SYNCML_DM_SUCCESS = 0;
+ int SYNCML_DM_FAIL = 1;
+ int SYNCML_DM_ENTRY_EXIST = 2;
+ int SYNCML_DM_ENTRY_NOT_EXIST = 3;
+ int SYNCML_DM_SESSION_BUSY = 4;
+ int SYNCML_DM_INVALID_URI = 5;
+ int SYNCML_DM_SESSION_AUTH_FAIL = 6;
+ int SYNCML_DM_SESSION_NW_NOT_AVAILABLE = 7;
+ int SYNCML_DM_SESSION_NO_CONNECT = 8;
+ int SYNCML_DM_SESSION_CANCELED = 9;
+ int SYNCML_DM_IO_FAILURE = 10;
+ int SYNCML_DM_FILE_NOT_FOUND = 11;
+ int SYNCML_DM_URI_CONFLICT = 12;
+ int SYNCML_DM_TREE_CORRUPT = 13;
+ int SYNCML_DM_SKIP_SUBTREE = 14;
+ int SYNCML_DM_RESULTS_TOO_LARGE = 15;
+ int SYNCML_DM_LOCK_CTX_NOT_FOUND = 16;
+ int SYNCML_DM_UNABLE_START_THREAD = 17;
+ int SYNCML_DM_TOO_MANY_DATA_FILES = 18;
+ int SYNCML_DM_LOCK_TRY_AGAIN = 19;
+ int SYNCML_DM_CONSTRAINT_FAIL = 20;
+ int SYNCML_DM_LOAD_ACL_FAIL = 21;
+ int SYNCML_DM_TREE_READONLY = 22;
+ int SYNCML_DM_INVALID_PARAMETER = 23;
+ int SYNCML_DM_AUTHENTICATION_ACCEPTED = 212;
+ int SYNCML_DM_CHUNK_BUFFERED = 213;
+ int SYNCML_DM_OPERATION_CANCELLED = 214;
+ int SYNCML_DM_NOT_EXECUTED = 215;
+ int SYNCML_DM_ATOMIC_ROLLBACK_OK = 216;
+ int SYNCML_DM_NOT_MODIFIED = 304;
+ int SYNCML_DM_BAD_REQUEST = 400;
+ int SYNCML_DM_UNAUTHORIZED = 401;
+ int SYNCML_DM_NOT_FOUND = 404;
+ int SYNCML_DM_COMMAND_NOT_ALLOWED = 405;
+ int SYNCML_DM_FEATURE_NOT_SUPPORTED = 406;
+ int SYNCML_DM_AUTHENTICATION_REQUIRED = 407;
+ int SYNCML_DM_REQUEST_TIMEOUT = 408;
+ int SYNCML_DM_INCOMPLETE_COMMAND = 412;
+ int SYNCML_DM_REQUEST_ENTITY_TOO_LARGE = 413;
+ int SYNCML_DM_URI_TOO_LONG = 414;
+ int SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT = 415;
+ int SYNCML_DM_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
+ int SYNCML_DM_TARGET_ALREADY_EXISTS = 418;
+ int SYNCML_DM_DEVICE_FULL = 420;
+ int SYNCML_DM_SIZE_MISMATCH = 424;
+ int SYNCML_DM_PERMISSION_FAILED = 425;
+ int SYNCML_DM_COMMAND_FAILED = 500;
+ int SYNCML_DM_COMMAND_NOT_IMPLEMENTED = 501;
+ int SYNCML_DM_SERVICE_UNAVAILABLE = 503;
+ int SYNCML_DM_GATEWAY_TIMEOUT = 504;
+ int SYNCML_DM_PROCESSING_ERROR = 506;
+ int SYNCML_DM_ATOMIC_FAILED = 507;
+ int SYNCML_DM_DATA_STORE_FAILURE = 510;
+ int SYNCML_DM_OPERATION_CANCELLED_FAILURE = 514;
+ int SYNCML_DM_ATOMIC_ROLLBACK_FAILED = 516;
+ int SYNCML_DM_ATOMIC_RESPONSE_TOO_LARGE = 517;
+ int SYNCML_DM_ESN_SET_NOT_COMPLETE = 518;
+
+ int SYNCML_DM_SOCKET_TIMEOUT = 700;
+ int SYNCML_DM_SOCKET_CONNECT_ERR = 701;
+ int SYNCML_DM_NO_HTTP_RESPONSE = 702;
+ int SYNCML_DM_UNKNOWN_HOST = 703;
+ int SYNCML_DM_INTERRUPTED = 704;
+
+ int SYNCML_DM_SESSION_PARAM_ERR = 800;
+ int SYNCML_DM_SESSION_USER_REJECT = 801;
+ int SYNCML_DM_SESSION_NO_FOTA_SERVER_ID = 802;
+}
diff --git a/DMService/src/com/android/omadm/service/DMSession.java b/DMService/src/com/android/omadm/service/DMSession.java
new file mode 100644
index 0000000..27614c6
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMSession.java
@@ -0,0 +1,309 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.util.Log;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+class DMSession {
+ private static final String TAG = "DMSession";
+ private static final boolean DBG = DMClientService.DBG;
+
+ private final String mLogPath;
+
+ private int mResultCode;
+
+ private DMHttpConnector mHttpConnector;
+
+ private final DMAlert mDMAlert;
+
+ private final DMClientService mDMClientService;
+
+ private String mLogName;
+
+ private String mServerID;
+
+ public String getLogFileName() {
+ return mLogName;
+ }
+
+ DMSession(DMClientService context) {
+ mLogName = null;
+ mDMClientService = context;
+ mDMAlert = new DMAlert(context);
+ mLogPath = context.getFilesDir().getPath() + "/dm/log/";
+ if (DBG) logd("XXX DMSession mLogPath dir = " + mLogPath);
+ }
+
+ public int startClientSession(String serverID) {
+ prepareLogFile();
+
+ try {
+ mServerID = serverID;
+ mHttpConnector = new DMHttpConnector(this);
+
+ if (DBG) logd("Start client session with server: " + mServerID);
+ mResultCode = NativeDM.startClientSession(mServerID, this);
+
+ logd("startDmSession resultCode: " + mResultCode);
+ } catch (RuntimeException e) {
+ loge("Exception caught starting DM session", e);
+ }
+
+ mHttpConnector.closeSession();
+ mHttpConnector = null;
+ mLogName = null;
+
+ return mResultCode;
+ }
+
+ public int startFotaClientSession(String serverID, String alertStr) {
+ prepareLogFile();
+
+ try {
+ mServerID = serverID;
+ mHttpConnector = new DMHttpConnector(this);
+
+ if (DBG) logd("Start DM session with server: " + mServerID
+ + " alert string: " + alertStr);
+ mResultCode = NativeDM.startFotaClientSession(serverID, alertStr, this);
+
+ logd("startDmSession resultCode: " + mResultCode);
+ } catch (Exception e) {
+ loge("Exception caught starting DM session", e);
+ }
+
+ mHttpConnector.closeSession();
+ mHttpConnector = null;
+ mLogName = null;
+
+ return mResultCode;
+ }
+
+ public int startLawmoNotifySession(FotaNotifyContext LawmoContext) {
+ prepareLogFile();
+
+ try {
+ mServerID = mDMClientService.getConfigDB().getFotaServerID();
+ mHttpConnector = new DMHttpConnector(this);
+
+ if (DBG) logd("Start LAWMONotify session with server: " + mServerID
+ + " PkgURI: " + LawmoContext.mPkgURI
+ + " AlertType: " + LawmoContext.mAlertType
+ + " Result: " + LawmoContext.mResult);
+ mResultCode = NativeDM.startFotaNotifySession(
+ LawmoContext.mResult,
+ LawmoContext.mPkgURI,
+ LawmoContext.mAlertType,
+ mServerID,
+ LawmoContext.mCorrelator,
+ this);
+ logd("LAWMONotifySession resultCode: " + mResultCode);
+ } catch (Exception e) {
+ loge("Exception caught starting DM session", e);
+ }
+
+ mHttpConnector.closeSession();
+ mHttpConnector = null;
+ mLogName = null;
+
+ return mResultCode;
+ }
+
+ public int startPkg0AlertSession(byte[] data) {
+ DMPkg0Notification notification = new DMPkg0Notification();
+ int ret = NativeDM.parsePkg0(data, notification);
+ if (ret != DMResult.SYNCML_DM_SUCCESS) {
+ if (ret != DMResult.SYNCML_DM_SESSION_AUTH_FAIL) {
+ logd("parsePkg0 return:" + ret);
+ return ret;
+ }
+ if (mDMClientService.getConfigDB().isDmNonceResyncEnabled()) {
+ logd("Nonce resync enabled, ignore as per OMA DM spec.");
+ return ret;
+ }
+ }
+
+ if (DBG) logd("NativeDM.parsePkg0 result: uiMode: " + notification.getUIMode()
+ + " initiator: " + notification.getInitiator()
+ + " sessionId: " + notification.getSessionID()
+ + " serverId: " + notification.getServerID());
+
+ if (notification.getServerID() == null) {
+ return DMResult.SYNCML_DM_SESSION_PARAM_ERR;
+ }
+
+ if (notification.getUIMode() == 3 || notification.getUIMode() == 0) {
+ mDMAlert.setUIMode(mDMClientService.getConfigDB().isDmAlertEnabled());
+ } else {
+ mDMAlert.setUIMode(false);
+ }
+ prepareLogFile();
+
+ mServerID = notification.getServerID();
+ mHttpConnector = new DMHttpConnector(this);
+
+ try {
+ if (notification.getInitiator() == 1) {
+ logd("Start server initiated session");
+ mResultCode = NativeDM.startFotaServerSession(notification.getServerID(),
+ notification.getSessionID(),
+ this);
+ } else {
+ logd("Start client initiated session");
+ String alertStr = "org.openmobilealliance.dm.firmwareupdate.userrequest";
+ mResultCode = NativeDM.startFotaClientSession(notification.getServerID(), alertStr,
+ this);
+ }
+
+ logd("startDmSession resultCode: " + mResultCode);
+
+ if (mResultCode == DMResult.SYNCML_DM_SUCCESS) {
+ mDMClientService.getConfigDB().setFotaServerID(notification.getServerID());
+ }
+ } catch (Exception e) {
+ loge("Exception caught starting DM session", e);
+ }
+
+ mHttpConnector.closeSession();
+ mHttpConnector = null;
+ mLogName = null;
+
+ return mResultCode;
+ }
+
+ public int fotaNotifyDMServer(FotaNotifyContext fotaContext) {
+ prepareLogFile();
+
+ try {
+ mServerID = fotaContext.mServerID;
+ mHttpConnector = new DMHttpConnector(this);
+
+ mResultCode = NativeDM.startFotaNotifySession(
+ fotaContext.mResult,
+ fotaContext.mPkgURI,
+ fotaContext.mAlertType,
+ fotaContext.mServerID,
+ fotaContext.mCorrelator,
+ this);
+ if (DBG) logd("fotaNotifyDMServer resultCode: " + mResultCode);
+ } catch (Exception e) {
+ loge("Exception caught starting DM session", e);
+ }
+
+ mHttpConnector.closeSession();
+ mHttpConnector = null;
+ mLogName = null;
+
+ return mResultCode;
+ }
+
+ public int cancelSession() {
+ NativeDM.cancelSession(); // Just set cancel flag.
+
+ mHttpConnector.closeSession();
+ mHttpConnector = null;
+
+ mDMAlert.cancelSession();
+ return 0;
+ }
+
+ private void prepareLogFile() {
+ File dirs = new File(mLogPath);
+ FilenameFilter filter = new SyncMLFilenameFilter();
+
+ int maxNum = 0;
+ String[] files = dirs.list(filter);
+
+ if(files != null) {
+ for (String f : files) {
+ String digitalStr = f.substring(7, 8);
+ try {
+ int number = Integer.parseInt(digitalStr);
+ if (number > maxNum) {
+ maxNum = number;
+ }
+
+ } catch (NumberFormatException e) {
+ loge("NumberFormatException in prepareLogFile()", e);
+ }
+ }
+ maxNum++;
+ }
+
+ if (files == null || maxNum >= 10) {
+ // FIXME: check return value
+ dirs.delete();
+ // FIXME: check return value
+ dirs.mkdirs();
+ maxNum = 1;
+ }
+
+ String num = Integer.toString(maxNum);
+ String logName = "SyncML_" + num + ".txt";
+ mLogName = mLogPath + logName;
+ if (DBG) logd("Log File: " + mLogName);
+ }
+
+ public DMClientService getServiceContext() {
+ return mDMClientService;
+ }
+
+ /**
+ * Get the {@link DMHttpConnector} object for this session. Called from JNI code.
+ *
+ * @return the DMHttpConnector object for this session
+ */
+ public DMHttpConnector getNetConnector() {
+ return mHttpConnector;
+ }
+
+ /**
+ * Get the {@link DMAlert} object for this session. Called from JNI code.
+ *
+ * @return the DMAlert object for this session
+ */
+ public DMAlert getDMAlert() {
+ return mDMAlert;
+ }
+
+ // FIXME: remove if unused?!
+ public String getServerID() {
+ return mServerID;
+ }
+
+ private static class SyncMLFilenameFilter implements FilenameFilter {
+
+ SyncMLFilenameFilter() {
+ }
+
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".txt") && name.startsWith("SyncML_");
+ }
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ private static void loge(String msg, Throwable tr) {
+ Log.e(TAG, msg, tr);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMSessionConfirmAlertActivity.java b/DMService/src/com/android/omadm/service/DMSessionConfirmAlertActivity.java
new file mode 100644
index 0000000..a224005
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMSessionConfirmAlertActivity.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+public class DMSessionConfirmAlertActivity extends Activity {
+ private static final String TAG = "DMSessionConfirmAlertActivity";
+ private static final boolean DBG = DMClientService.DBG;
+
+ private AlertDialog mDialog;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ DMHelper.cancelNotification(this, DMHelper.NOTIFICATION_CONFIRMATION_ID);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ }
+
+ @Override
+ protected void onResume() {
+ logd("Activity DM session confirmation has been started.");
+ super.onResume();
+ showDialog();
+ }
+
+ public static class MyAlertDialogFragment extends DialogFragment {
+
+ public static MyAlertDialogFragment newInstance() {
+ MyAlertDialogFragment frag = new MyAlertDialogFragment();
+ Bundle args = new Bundle();
+ frag.setArguments(args);
+ return frag;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+
+ return new AlertDialog.Builder(getActivity())
+ .setIcon(R.drawable.alert_dialog_icon)
+ .setTitle(R.string.dm_session_confirmation_title)
+ .setMessage(R.string.dm_session_confirmation_message)
+ .setCancelable(false)
+ .setPositiveButton(getResources().getString(R.string.dm_session_button_confirm),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int whichButton) {
+ ((DMSessionConfirmAlertActivity) getActivity())
+ .doPositiveClick();
+ }
+ }
+ )
+ .setNegativeButton(getResources().getString(R.string.dm_session_button_reject),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int whichButton) {
+ ((DMSessionConfirmAlertActivity) getActivity())
+ .doNegativeClick();
+ }
+ }
+ )
+ .create();
+ }
+ }
+
+ void doNegativeClick() {
+ userDeniedSession();
+ }
+
+ void doPositiveClick() {
+ userConfirmedSession();
+ }
+
+ private void userConfirmedSession() {
+ logd("userConfirmedSession");
+ Intent intent = new Intent(DMIntent.ACTION_USER_CONFIRMED_DM_SESSION);
+ sendBroadcast(intent);
+
+ finishMe();
+
+ }
+
+ private void userDeniedSession() {
+ logd("userDeniedSession");
+ DMHelper.cleanAllResources(this);
+
+ finishMe();
+
+ }
+
+ private void showDialog() {
+ DialogFragment newFragment = MyAlertDialogFragment.newInstance();
+ newFragment.show(getFragmentManager(), "dialog");
+ }
+
+ private void finishMe() {
+
+ if (null != mDialog) {
+ mDialog.dismiss();
+ }
+
+ mDialog = null;
+ finish();
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMSettingsHelper.java b/DMService/src/com/android/omadm/service/DMSettingsHelper.java
new file mode 100644
index 0000000..0356b03
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMSettingsHelper.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+public final class DMSettingsHelper {
+ public static final String TAG = "DMSettingsHelper";
+ public static final String AUTHORITY = "com.android.omadm.service";
+ public static final String DM_TREE = "dmtree";
+ public static final String DM_TREE_STATUS = "dmtreestatus";
+ public static final String DM_DMFLEXS = "flexs";
+ public static final String DATABASE_NAME = "DmConfigure.db";
+
+ public static final String BLOB = "blob"; //only for DM bootstrap
+
+ // columns for data
+ public static final String COL_ROOT_NODE = "rootnode";
+ public static final String COL_SERVER_ID = "serverid";
+
+ // DMT availability. Fields for the cursor and values
+ public static final String COL_DM_AVAILABILITY = "dmavailability";
+ public static final String AVAILABLE = "available";
+ public static final String LOCKED = "locked";
+
+ private DMSettingsHelper() {
+ }
+
+ // TODO: For now, assume the device supports LTE.
+ public static boolean isPhoneTypeLTE() {
+ return true;
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/DMWapPushReceiver.java b/DMService/src/com/android/omadm/service/DMWapPushReceiver.java
new file mode 100644
index 0000000..350a495
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/DMWapPushReceiver.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.provider.Telephony;
+import android.util.Log;
+
+public class DMWapPushReceiver extends BroadcastReceiver {
+
+ private static final String TAG = "DMWapPushReceiver";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (DMHelper.disableIfSecondaryUser(context)) {
+ return;
+ }
+ String action = intent.getAction();
+ if (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(action)) {
+ Log.d(TAG, action);
+ Intent iIntent = new Intent(DMIntent.ACTION_WAP_PUSH_RECEIVED_INTERNAL);
+ iIntent.replaceExtras(intent);
+ context.sendBroadcast(iIntent);
+ }
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/FotaNotifyContext.java b/DMService/src/com/android/omadm/service/FotaNotifyContext.java
new file mode 100644
index 0000000..9f16fc7
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/FotaNotifyContext.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+class FotaNotifyContext {
+ FotaNotifyContext(String result, String pkgURI, String alertType,
+ String serverID, String correlator) {
+ mResult = result;
+ mPkgURI = pkgURI;
+ mAlertType = alertType;
+ mServerID = serverID;
+ mCorrelator = correlator;
+ }
+
+ public final String mResult;
+ public final String mPkgURI;
+ public final String mAlertType;
+ public final String mServerID;
+ public final String mCorrelator;
+}
diff --git a/DMService/src/com/android/omadm/service/NativeDM.java b/DMService/src/com/android/omadm/service/NativeDM.java
new file mode 100644
index 0000000..132e39f
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/NativeDM.java
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+import android.util.Log;
+
+final class NativeDM {
+ private static final String TAG = "NativeDM";
+
+ private NativeDM() {}
+
+ static {
+ try {
+ logd("loading libdmengine.so");
+ System.loadLibrary("dmengine");
+ logd("loaded libdmengine.so");
+ } catch (UnsatisfiedLinkError ule) {
+ loge("error: Could not load libdmengine.so", ule);
+ throw ule;
+ }
+ }
+
+ /**
+ * Initialize the native DM library.
+ * @return either {@link DMResult#SYNCML_DM_SUCCESS} or {@link DMResult#SYNCML_DM_FAIL}
+ */
+ public static native int initialize();
+
+ /**
+ * Initialize the native DM library.
+ * @return either {@link DMResult#SYNCML_DM_SUCCESS} or {@link DMResult#SYNCML_DM_FAIL}
+ */
+ public static native int destroy();
+
+ /**
+ * Start a DM client session.
+ * @param serverID the server ID to use
+ * @param sessionAgent the {@link DMSession} object to use
+ * @return either {@link DMResult#SYNCML_DM_SUCCESS} or a {@link DMResult} error code
+ */
+ public static native int startClientSession(String serverID, DMSession sessionAgent);
+
+ /**
+ * Start a FOTA client session. The alert URI is {@code "./DevDetail/Ext/SystemUpdate"}.
+ * @param serverID the server ID to use
+ * @param alertStr the alert string to use
+ * @param sessionAgent the {@link DMSession} object to use
+ * @return either {@link DMResult#SYNCML_DM_SUCCESS} or a {@link DMResult} error code
+ */
+ public static native int startFotaClientSession(String serverID, String alertStr,
+ DMSession sessionAgent);
+
+ /**
+ * Start a FOTA server session.
+ * @param serverID the server ID to use
+ * @param sessionID the session ID to use
+ * @param sessionAgent the {@link DMSession} object to use
+ * @return either {@link DMResult#SYNCML_DM_SUCCESS} or a {@link DMResult} error code
+ */
+ public static native int startFotaServerSession(String serverID, int sessionID,
+ DMSession sessionAgent);
+
+ /**
+ * Start a FOTA notification session.
+ * @param result
+ * @param pkgURI
+ * @param alertType
+ * @param serverID
+ * @param correlator
+ * @param sessionAgent
+ * @return either {@link DMResult#SYNCML_DM_SUCCESS} or a {@link DMResult} error code
+ */
+ public static native int startFotaNotifySession(String result, String pkgURI,
+ String alertType, String serverID, String correlator, DMSession sessionAgent);
+
+ /**
+ *
+ * @return
+ */
+ public static native int cancelSession();
+
+ /**
+ *
+ * @param pkg0
+ * @param dmtNotification
+ * @return
+ */
+ public static native int parsePkg0(byte[] pkg0, DMPkg0Notification dmtNotification);
+
+ /**
+ *
+ * @param node
+ * @return
+ */
+ public static native int createInterior(String node);
+
+ /**
+ *
+ * @param node
+ * @param value
+ * @return
+ */
+ public static native int createLeaf(String node, String value);
+
+ /**
+ *
+ * @param node
+ * @param value
+ * @return
+ */
+ public static native int createLeaf(String node, byte[] value);
+
+ /**
+ *
+ * @param node
+ * @return
+ */
+ public static native int deleteNode(String node);
+
+ /**
+ *
+ * @param node
+ * @param value
+ * @return
+ */
+ public static native String setStringNode(String node, String value);
+
+ /**
+ *
+ * @param node
+ * @param value
+ * @return
+ */
+ public static native String createLeafInteger(String node, String value);
+
+ /**
+ *
+ * @param node
+ * @return
+ */
+ public static native String getNodeInfo(String node);
+
+ /**
+ *
+ * @param node
+ * @param data
+ * @return
+ */
+ public static native String executePlugin(String node, String data);
+
+ /**
+ *
+ * @param node
+ * @return
+ */
+ public static native String dumpTree(String node);
+
+ /**
+ *
+ * @param wbxmlBuf
+ * @return
+ */
+ public static native byte[] nativeWbxmlToXml(byte[] wbxmlBuf);
+
+ /**
+ *
+ * @param serverId
+ * @param fileName
+ * @param bBinary
+ * @param retCode
+ * @param session
+ * @return
+ */
+ public static native byte[] processScript(String serverId, String fileName, boolean bBinary,
+ int retCode, DMSession session);
+
+ /**
+ *
+ * @param msgData
+ * @param bIsWbxml
+ * @param serverId
+ * @return
+ */
+ public static native int processBootstrapScript(byte[] msgData, boolean bIsWbxml,
+ String serverId);
+
+ /**
+ *
+ * @param msgData
+ * @param bIsWbxml
+ * @return
+ */
+ public static native String parseBootstrapServerId(byte[] msgData, boolean bIsWbxml);
+
+ /**
+ * Get the node type for a DM node.
+ * @param path the OMA DM path to use
+ * @return the DM node type
+ */
+ public static native int getNodeType(String path);
+
+ /**
+ * Get the node value for a DM node.
+ * @param path the OMA DM path to use
+ * @return the DM node value, as a String
+ */
+ public static native String getNodeValue(String path);
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ private static void loge(String msg, Throwable tr) {
+ Log.e(TAG, msg, tr);
+ }
+}
diff --git a/DMService/src/com/android/omadm/service/package-info.java b/DMService/src/com/android/omadm/service/package-info.java
new file mode 100644
index 0000000..7a94385
--- /dev/null
+++ b/DMService/src/com/android/omadm/service/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.service;
+
+/**
+ * Main package for {@code DMService}, generic OMA DM client service.
+ */
diff --git a/DMService/src/net/jcip/annotations/GuardedBy.java b/DMService/src/net/jcip/annotations/GuardedBy.java
new file mode 100644
index 0000000..e981a05
--- /dev/null
+++ b/DMService/src/net/jcip/annotations/GuardedBy.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2005 Brian Goetz and Tim Peierls
+ * Released under the Creative Commons Attribution License
+ * (http://creativecommons.org/licenses/by/2.5)
+ * Official home: http://www.jcip.net
+ *
+ * Any republication or derived work distributed in source code form
+ * must include this copyright and license notice.
+ */
+
+package net.jcip.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * The field or method to which this annotation is applied can only be accessed
+ * when holding a particular lock, which may be a built-in (synchronization) lock,
+ * or may be an explicit java.util.concurrent.Lock.
+ *
+ * The argument determines which lock guards the annotated field or method:
+ * <ul>
+ * <li>
+ * <code>this</code> : The intrinsic lock of the object in whose class the field is defined.
+ * </li>
+ * <li>
+ * <code>class-name.this</code> : For inner classes, it may be necessary to disambiguate 'this';
+ * the <em>class-name.this</em> designation allows you to specify which 'this' reference is intended
+ * </li>
+ * <li>
+ * <code>itself</code> : For reference fields only; the object to which the field refers.
+ * </li>
+ * <li>
+ * <code>field-name</code> : The lock object is referenced by the (instance or static) field
+ * specified by <em>field-name</em>.
+ * </li>
+ * <li>
+ * <code>class-name.field-name</code> : The lock object is reference by the static field specified
+ * by <em>class-name.field-name</em>.
+ * </li>
+ * <li>
+ * <code>method-name()</code> : The lock object is returned by calling the named nil-ary method.
+ * </li>
+ * <li>
+ * <code>class-name.class</code> : The Class object for the specified class should be used as the lock object.
+ * </li>
+ */
+@Target({ElementType.FIELD, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface GuardedBy {
+ String value();
+}
diff --git a/DMService/src/net/jcip/annotations/Immutable.java b/DMService/src/net/jcip/annotations/Immutable.java
new file mode 100644
index 0000000..a684565
--- /dev/null
+++ b/DMService/src/net/jcip/annotations/Immutable.java
@@ -0,0 +1,35 @@
+package net.jcip.annotations;
+import java.lang.annotation.*;
+
+/*
+ * Copyright (c) 2005 Brian Goetz and Tim Peierls
+ * Released under the Creative Commons Attribution License
+ * (http://creativecommons.org/licenses/by/2.5)
+ * Official home: http://www.jcip.net
+ *
+ * Any republication or derived work distributed in source code form
+ * must include this copyright and license notice.
+ */
+
+
+/**
+ * The class to which this annotation is applied is immutable. This means that
+ * its state cannot be seen to change by callers, which implies that
+ * <ul>
+ * <li> all public fields are final, </li>
+ * <li> all public final reference fields refer to other immutable objects, and </li>
+ * <li> constructors and methods do not publish references to any internal state
+ * which is potentially mutable by the implementation. </li>
+ * </ul>
+ * Immutable objects may still have internal mutable state for purposes of performance
+ * optimization; some state variables may be lazily computed, so long as they are computed
+ * from immutable state and that callers cannot tell the difference.
+ * <p>
+ * Immutable objects are inherently thread-safe; they may be passed between threads or
+ * published without synchronization.
+ */
+@Documented
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Immutable {
+}
diff --git a/DMService/src/net/jcip/annotations/NotThreadSafe.java b/DMService/src/net/jcip/annotations/NotThreadSafe.java
new file mode 100644
index 0000000..30a4ffd
--- /dev/null
+++ b/DMService/src/net/jcip/annotations/NotThreadSafe.java
@@ -0,0 +1,26 @@
+package net.jcip.annotations;
+import java.lang.annotation.*;
+
+/*
+ * Copyright (c) 2005 Brian Goetz and Tim Peierls
+ * Released under the Creative Commons Attribution License
+ * (http://creativecommons.org/licenses/by/2.5)
+ * Official home: http://www.jcip.net
+ *
+ * Any republication or derived work distributed in source code form
+ * must include this copyright and license notice.
+ */
+
+
+/**
+ * The class to which this annotation is applied is not thread-safe.
+ * This annotation primarily exists for clarifying the non-thread-safety of a class
+ * that might otherwise be assumed to be thread-safe, despite the fact that it is a bad
+ * idea to assume a class is thread-safe without good reason.
+ * @see ThreadSafe
+ */
+@Documented
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NotThreadSafe {
+}
diff --git a/DMService/src/net/jcip/annotations/ThreadSafe.java b/DMService/src/net/jcip/annotations/ThreadSafe.java
new file mode 100644
index 0000000..00ec035
--- /dev/null
+++ b/DMService/src/net/jcip/annotations/ThreadSafe.java
@@ -0,0 +1,27 @@
+package net.jcip.annotations;
+import java.lang.annotation.*;
+
+/*
+ * Copyright (c) 2005 Brian Goetz and Tim Peierls
+ * Released under the Creative Commons Attribution License
+ * (http://creativecommons.org/licenses/by/2.5)
+ * Official home: http://www.jcip.net
+ *
+ * Any republication or derived work distributed in source code form
+ * must include this copyright and license notice.
+ */
+
+
+
+/**
+ * The class to which this annotation is applied is thread-safe. This means that
+ * no sequences of accesses (reads and writes to public fields, calls to public methods)
+ * may put the object into an invalid state, regardless of the interleaving of those actions
+ * by the runtime, and without requiring any additional synchronization or coordination on the
+ * part of the caller.
+ */
+@Documented
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ThreadSafe {
+}
diff --git a/DMService/src/net/jcip/annotations/package.html b/DMService/src/net/jcip/annotations/package.html
new file mode 100644
index 0000000..8567dab
--- /dev/null
+++ b/DMService/src/net/jcip/annotations/package.html
@@ -0,0 +1,66 @@
+<html>
+<body>
+<p>
+ Class, field, and method level annotations for describing thread-safety policies.
+</p>
+
+<p>
+ Three class-level annotations describe the <em>intended</em> thread-safety promises of a class:
+ <code>@Immutable</code>, <code>@ThreadSafe</code>, and <code>@NotThreadSafe</code>.
+ <code>@Immutable</code> means that the class is immutable,
+ and implies <code>@ThreadSafe</code>.
+ <code>@NotThreadSafe</code> is optional;
+ if a class is not annotated as thread-safe, it should be presumed not to be
+ thread-safe, but if you want to make it extra clear, use
+ <code>@NotThreadSafe</code>.
+</p>
+
+<p>
+ These annotations are relatively unintrusive and are beneficial to
+ both users and maintainers. Users can see immediately whether a class
+ is thread-safe, and maintainers can see immediately whether
+ thread-safety guarantees must be preserved. Annotations are also
+ useful to a third constituency: tools. Static code-analysis tools may
+ be able to verify that the code complies with the contract indicated
+ by the annotation, such as verifying that a class annotated with
+ <code>@Immutable</code> actually is immutable.
+</p>
+
+<h2>Field and method annotations</h2>
+
+<p>
+ The class-level annotations above are part of the public documentation
+ for the class. Other aspects of a class's thread-safety strategy are
+ entirely for maintainers and are not part of its public documentation.
+</p>
+
+<p>
+ Classes that use locking should document which state variables are
+ guarded with which locks, and which locks are used to guard those
+ variables. A common source of inadvertent non-thread-safety is when a
+ thread-safe class consistently uses locking to guard its state, but is
+ later modified to add either new state variables that are not
+ adequately guarded by locking, or new methods that do not use locking
+ properly to guard the existing state variables. Documenting which
+ variables are guarded by which locks can help prevent both types of
+ omissions.
+</p>
+
+<p>
+ The <code>@GuardedBy(lock)</code> annotation documents that a field or method should
+ be accessed only with a specific lock held.
+</p>
+
+
+<h2>Copyright and license</h2>
+<p>
+This software is copyright (c) 2005 Brian Goetz and Tim Peierls
+and is released under the Creative Commons Attribution License
+(http://creativecommons.org/licenses/by/2.5). The official home
+for this software is http://www.jcip.net.
+Any republication or derived work distributed in source code form
+must include the copyright and license notice.
+</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/config/com.android.omadm.service.xml b/config/com.android.omadm.service.xml
new file mode 100644
index 0000000..b17e001
--- /dev/null
+++ b/config/com.android.omadm.service.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<permissions>
+ <assign-permission name="com.android.permission.INJECT_OMADM_SETTINGS" uid="shell" />
+</permissions>
diff --git a/engine/Android.mk b/engine/Android.mk
new file mode 100644
index 0000000..77580a4
--- /dev/null
+++ b/engine/Android.mk
@@ -0,0 +1,170 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+# DM Engine directories
+DM_GLOBAL_SUBDIRS_A := \
+ dmlib/dmengine/dm_ua/src \
+ dmlib/dmengine/dm_persist/src \
+ dmlib/dmengine/dm_tnm/src \
+ dmlib/dmengine/dm_util/src \
+ dmlib/dmtapi/native/src \
+ dmlib/plugin/src \
+ dmlib/notification_agent/src
+
+DM_GLOBAL_SUBDIRS_B := \
+ dmlib/dmengine/dm_security/src \
+ dmlib/dmengine/dm_ssession/src \
+ dmlib/dmengine/oma_toolkit/src
+
+
+ifdef DM_NATIVE_HTTP
+ DM_GLOBAL_SUBDIRS_B += dmlib/dmengine/dm_transport/src
+endif
+
+DM_OMA_TOOLKIT_INCLUDES := \
+ dmlib/dmengine/oma_toolkit/hdr \
+ dmlib/dmengine/oma_toolkit/sml/xpt/hdr \
+ dmlib/dmengine/oma_toolkit/sml/mgr/hdr \
+ dmlib/dmengine/oma_toolkit/sml/ghdr \
+ dmlib/dmengine/oma_toolkit/sml/lib/hdr \
+ dmlib/dmengine/oma_toolkit/sml/wsm/hdr \
+ dmlib/dmengine/oma_toolkit/sml/xlt/src \
+ dmlib/dmengine/oma_toolkit/sml/xlt/hdr
+
+DM_API_INCLUDES := \
+ dmlib/api/common \
+ dmlib/api/native \
+ dmlib/api/native/plugin
+
+# DM Engine source files
+DM_ENGINE_SRC_FILES:= $(foreach dir,$(DM_GLOBAL_SUBDIRS_A),$(wildcard $(LOCAL_PATH)/$(dir)/*.*))
+DM_ENGINE_SRC_FILES:= $(subst $(LOCAL_PATH)/,,$(DM_ENGINE_SRC_FILES))
+DM_ENGINE_SRC_FILES += xpl/src/xpl_dm_Notifications.cpp
+
+# DM Session source files
+DM_SESSION_SRC_FILES:= $(foreach dir,$(DM_GLOBAL_SUBDIRS_B),$(wildcard $(LOCAL_PATH)/$(dir)/*.*))
+DM_SESSION_SRC_FILES:= $(subst $(LOCAL_PATH)/,,$(DM_SESSION_SRC_FILES))
+
+# DM XPL source files
+DM_XPL_SRC_FILES := \
+ xpl/src/xpl_Alert.cc \
+ xpl/src/xpl_File.cc \
+ xpl/src/xpl_Lib.cc \
+ xpl/src/xpl_Memory.cc \
+ xpl/src/xpl_Regex.cc \
+ xpl/src/xpl_Time.cc \
+ xpl/src/xpl_dm_Manager.cc \
+ xpl/src/xpl_dm_Notifications.cc \
+ xpl/src/dmAllocatedPointersPool.cc \
+ xpl/src/dmMemory.cc \
+ xpl/src/dmNewDataTypesValidation.cc \
+ xpl/src/dmThreadHelper.cc \
+ xpl/src/dmThreadQueue.cc \
+ xpl/src/dmprofile.cc \
+
+ifdef DM_NATIVE_HTTP
+ DM_XPL_SRC_FILES += xpl/src/xpl_HTTP_socket.cc \
+ xpl/src/dmSocketConnector.cc
+else
+ DM_JNI_SRC_FILES:= jni/DMServiceConnection.cc \
+ jni/DMServiceAlert.cc \
+ jni/DMServiceMain.cc \
+ dmlib/dmengine/dm_transport/src/dm_tpt_utils.c \
+ jni/DMTreeManager.cc
+ LOCAL_SRC_FILES += $(DM_JNI_SRC_FILES)
+endif
+
+
+# DM source files
+LOCAL_SRC_FILES += $(DM_ENGINE_SRC_FILES)
+LOCAL_SRC_FILES += $(DM_SESSION_SRC_FILES)
+LOCAL_SRC_FILES += $(DM_XPL_SRC_FILES)
+
+#############################################
+# DM include files
+DM_ENGINE_INCLUDES = $(foreach dir1,$(DM_GLOBAL_SUBDIRS_A), \
+ $(subst /src,/hdr,$(dir1)) )
+DM_ENGINE_INCLUDES += $(foreach dir1,$(DM_GLOBAL_SUBDIRS_B), \
+ $(subst /src,/hdr,$(dir1)) )
+
+DM_ENGINE_INCLUDES += dmlib/dmengine/dm_transport/hdr
+DM_ENGINE_INCLUDES += jni
+
+DM_ENGINE_INCLUDES += $(DM_API_INCLUDES)
+DM_ENGINE_INCLUDES += $(DM_OMA_TOOLKIT_INCLUDES)
+
+DM_ENGINE_INCLUDES := $(addprefix $(LOCAL_PATH)/, $(DM_ENGINE_INCLUDES))
+DM_XPL_INCLUDES := $(LOCAL_PATH)/xpl/hdr
+
+
+LOCAL_C_INCLUDES += $(DM_ENGINE_INCLUDES)
+LOCAL_C_INCLUDES += $(DM_XPL_INCLUDES)
+LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
+
+############################################
+# general DM flags
+DM_CFLAGS := -DVRTXMC \
+ -DDM_ATOMIC_SUPPORTED \
+ -DLOB_SUPPORT \
+ -DXPL_LOG_LEVEL=XPL_LOG_Warn \
+ -DDM_NO_LOCKING \
+ -DDM_NO_SESSION_LIB \
+ -DTNDS_SUPPORT
+
+# for old ARM platform builds
+#DM_ARM_CFLAGS := -DPLATFORM_EZX \
+# -DDMSyncMLLibVersion=\"03.00.00\"
+
+# for x86/ARM builds on Android
+DM_X86_CFLAGS = -DEZX_PORT -DPLATFORM_X86 -DPLATFORM_ANDROID \
+ -DSYNCML_DM_DBG_USING_XML \
+ -DDM_SUPPORT_AUTHPREF \
+ -DNO_CAF \
+ -DNO_OTHER_PLUGIN
+
+# saved from LJ for future reference
+#DM_CFLAGS += -DFEAT_DM_VERSION_FLEX -DDM_PERFORMANCE_ENABLED
+
+# compile flags
+LOCAL_CFLAGS += $(DM_CFLAGS)
+LOCAL_CFLAGS += $(DM_X86_CFLAGS)
+
+ifdef FTR_OMADM_SDMSERVICES
+LOCAL_CFLAGS += -DDM_SDMSERVICES
+endif
+
+ifdef DM_NATIVE_HTTP
+LOCAL_CFLAGS += -DDM_NATIVE_HTTP
+endif
+
+ifeq ($(TARGET_BUILD_TYPE),release)
+LOCAL_CFLAGS += -DDM_UNITEST
+endif
+
+LOCAL_SHARED_LIBRARIES += \
+ libandroid_runtime \
+ liblog \
+ libdl
+
+LOCAL_MODULE := libdmengine
+LOCAL_PRELINK_MODULE := false
+#TARGET_BUILD_TYPE=debug
+LOCAL_STRIP_MODULE := true
+
+LOCAL_REQUIRED_MODULES := dmt_data
+LOCAL_CPP_EXTENSION := .cc
+
+LOCAL_MULTILIB := 32
+
+include $(BUILD_SHARED_LIBRARY)
+
+ifeq ($(TARGET_BUILD_TYPE),release)
+include $(CLEAR_VARS)
+include $(call all-makefiles-under,$(LOCAL_PATH)/../unitest)
+endif
+
+# This finds and builds the test apk as well, so a single make does both.
+include $(CLEAR_VARS)
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/engine/dmlib/api/common/dmtDefs.h b/engine/dmlib/api/common/dmtDefs.h
new file mode 100644
index 0000000..f1506bb
--- /dev/null
+++ b/engine/dmlib/api/common/dmtDefs.h
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMT_DEFS_H
+#define DMT_DEFS_H
+
+/**
+ \file dmtDefs.h
+
+ \brief The dmtDefs.h header file contains constants and datatype definitions exported
+ from the DM engine.
+*/
+
+#include "dmtError.h"
+
+/**
+ * The enumeration defines lock types for the access device management tree
+ */
+enum {
+ /**
+ * Shared lock allows read-only access to the tree, but can be shared between multiple readers.
+ */
+ SYNCML_DM_LOCK_TYPE_SHARED = 0,
+
+ /**
+ * Exclusive lock allows full access to the tree, but can not be shared with any other locks.
+ */
+ SYNCML_DM_LOCK_TYPE_EXCLUSIVE = 1,
+
+ /**
+ * Automatic lock is treated as "shared" by engine until first "set" operation.
+ * During first "set" operation lock is upgraded to exclusive with potential wait operation.
+ * Note: upgrade operation is performed via unlock, which makes it possible for the tree to change,
+ * so after first "read" but before next "write" operations, this field potentially can be changed.
+ * If this is crucial, explicit "Exclusive" lock should be specified.
+ * Note: in case of any lock, if tree object is held for more than 10 sec without accessing,
+ * lock is released automatically to prevent blocking other processes by misbehaving app.
+ */
+ SYNCML_DM_LOCK_TYPE_AUTOMATIC = 2
+};
+
+/**
+ * Lock types definition for the accessing device management tree
+ */
+typedef INT32 SYNCML_DM_TREE_LOCK_TYPE_T;
+
+/**
+ * The enumeration defines data types for the device management tree
+ */
+enum {
+ /** Undefined data type */
+ SYNCML_DM_DATAFORMAT_UNDEFINED = -1,
+ /** Null data type */
+ SYNCML_DM_DATAFORMAT_NULL = 0,
+ /** String data type */
+ SYNCML_DM_DATAFORMAT_STRING = 1,
+ /** Integer data type */
+ SYNCML_DM_DATAFORMAT_INT = 2,
+ /** Boolean data type */
+ SYNCML_DM_DATAFORMAT_BOOL = 3,
+ /** Binary data type */
+ SYNCML_DM_DATAFORMAT_BIN = 4,
+ /** Node data type */
+ SYNCML_DM_DATAFORMAT_NODE = 5,
+ /** Base 64 data encoding type */
+ SYNCML_DM_DATAFORMAT_B64 = 6,
+ /** XML data type */
+ SYNCML_DM_DATAFORMAT_XML = 7,
+ /** Date data type */
+ SYNCML_DM_DATAFORMAT_DATE = 8,
+ /** Time data type */
+ SYNCML_DM_DATAFORMAT_TIME = 10,
+ /** Float data type */
+ SYNCML_DM_DATAFORMAT_FLOAT = 11
+};
+
+/**
+ * Definition data types for the device management tree.
+ */
+typedef INT8 SYNCML_DM_DATAFORMAT_T;
+
+/**
+ * The enumeration defines operation types that can be performed on a plugin sub tree for
+ * the device management tree
+ */
+enum
+{
+ /** No command */
+ SYNCML_DM_PLUGIN_NO_COMMAND,
+ /** Command "Add" */
+ SYNCML_DM_PLUGIN_ADD,
+ /** Command "Delete" */
+ SYNCML_DM_PLUGIN_DELETE,
+ /** Command "Replace" */
+ SYNCML_DM_PLUGIN_REPLACE,
+ /** Command "Add Child" */
+ SYNCML_DM_PLUGIN_ADD_CHILD,
+ /** Command "Get" */
+ SYNCML_DM_PLUGIN_GET,
+ /** Command "Rename" */
+ SYNCML_DM_PLUGIN_RENAME
+};
+
+/**
+ * Definition operation types that can be performed on a plugin sub tree for
+ * the device management tree.
+ */
+typedef UINT8 SYNCML_DM_PLUGIN_COMMAND_T;
+
+/**
+ * The enumeration defines command properties for the device management tree operations
+ */
+enum
+{
+ /** Execute command on node */
+ SYNCML_DM_PLUGIN_COMMAND_ON_NODE,
+ /** Execute command on property name */
+ SYNCML_DM_PLUGIN_COMMAND_ON_NAME_PROPERTY,
+ /** Execute command on property titles */
+ SYNCML_DM_PLUGIN_COMMAND_ON_TITLE_PROPERTY,
+ /** Execute command on property LOB */
+ SYNCML_DM_PLUGIN_COMMAND_ON_LOB_PROPERTY
+};
+
+/**
+ * Definition command properties for the device management tree operations
+ */
+typedef UINT8 SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T;
+
+/**
+ * Access Control List (ACL) permissions - int "or'ed" of the following values
+ */
+enum {
+ /** Grants "Add" permissions */
+ SYNCML_DM_ACL_ADD = 0x01,
+ /** Grants "Delete" permissions */
+ SYNCML_DM_ACL_DELETE = 0x02,
+ /** Grants "Get" permissions */
+ SYNCML_DM_ACL_GET = 0x04,
+ /** Grants "Replace" permissions */
+ SYNCML_DM_ACL_REPLACE = 0x08,
+ /** Grants "Execute" permissions */
+ SYNCML_DM_ACL_EXEC = 0x10
+};
+
+/**
+ * Definition Access Control List (ACL) permissions.
+ */
+typedef UINT8 SYNCML_DM_ACL_PERMISSIONS_T;
+
+enum {
+ /** No updates */
+ SYNCML_DM_EVENT_NONE = 0,
+ /** Node added */
+ SYNCML_DM_EVENT_ADD = 0x01,
+ /** Leaf node replaced */
+ SYNCML_DM_EVENT_REPLACE = 0x02,
+ /** Node deleteds */
+ SYNCML_DM_EVENT_DELETE = 0x04,
+ /** Interior node renamed */
+ SYNCML_DM_EVENT_RENAME = 0x08,
+ /** Inderect update */
+ SYNCML_DM_EVENT_INDIRECT = 0x10,
+};
+
+/**
+ * Definition of action performed on DM node.
+ */
+typedef UINT8 SYNCML_DM_EVENT_ACTION_T;
+
+enum {
+ /** Event constructed only for updates on specific node */
+ SYNCML_DM_EVENT_NODE = 0,
+ /** Cumulative event constructed for sub tree */
+ SYNCML_DM_EVENT_CUMULATIVE = 1,
+ /** Detail event constracted for node or sub tree */
+ SYNCML_DM_EVENT_DETAIL = 2
+};
+
+/**
+ * Definition of depth of DM event.
+ */
+typedef UINT8 SYNCML_DM_EVENT_TYPE_T;
+
+/**
+ * The enumeration defines types for SyncML DM server session
+ */
+enum
+{
+ /** "Server Initiated" session type */
+ SYNCML_DM_SERVER_INITIATED_SESSION = 1200,
+ /** "Clien Initiated" session type */
+ SYNCML_DM_CLIENT_INITIATED_SESSION = 1201
+};
+
+/**
+ * Definition types for SyncML DM server session
+ */
+typedef UINT16 SYNCML_DM_SESSION_DIRECTION_T;
+
+#endif
diff --git a/engine/dmlib/api/common/dmtError.h b/engine/dmlib/api/common/dmtError.h
new file mode 100644
index 0000000..cbe66fb
--- /dev/null
+++ b/engine/dmlib/api/common/dmtError.h
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMT_ERROR_H
+#define DMT_ERROR_H
+
+/**
+ \file dmtError.h
+ \brief The dmtError.h header file contains DM engine error type definition.
+ There are two error types:
+ Standard SyncML DM Error codes
+ Extension ("EXT", use with device management tree API)
+*/
+
+#include "xpl_Types.h"
+
+/**Enumeration defines Sync ML return status codes */
+enum
+{
+/** Success */
+ SYNCML_DM_SUCCESS = 0,
+/** Unknown error (EXT) */
+ SYNCML_DM_FAIL = 1,
+/** Entry for tree mount point or transport already exist in the registry (EXT) */
+ SYNCML_DM_ENTRY_EXIST = 2,
+/** Entry for tree mount point or transport not found in the registry (EXT) */
+ SYNCML_DM_ENTRY_NOT_EXIST = 3,
+/** Other Session is in progress (EXT) */
+ SYNCML_DM_SESSION_BUSY = 4,
+/** URI is invalid (EXT) */
+ SYNCML_DM_INVALID_URI = 5,
+/** Session authentication failed */
+ SYNCML_DM_SESSION_AUTH_FAIL = 6,
+/** Second connection is not available (EXT) */
+ SYNCML_DM_SESSION_NW_NOT_AVAILABLE = 7,
+/** Session not connected*/
+ SYNCML_DM_SESSION_NO_CONNECT = 8,
+/** Session canceled*/
+ SYNCML_DM_SESSION_CANCELED = 9,
+/** File operation failure (EXT) */
+ SYNCML_DM_IO_FAILURE = 10,
+/** File not found (EXT) */
+ SYNCML_DM_FILE_NOT_FOUND = 11,
+/** URI is too long (EXT) */
+ SYNCML_DM_URI_CONFLICT = 12,
+/** Tree file is corrupted (EXT) */
+ SYNCML_DM_TREE_CORRUPT = 13,
+/** Internal error (EXT) */
+ SYNCML_DM_SKIP_SUBTREE = 14,
+/** Result is too large (EXT) */
+ SYNCML_DM_RESULTS_TOO_LARGE = 15,
+/** Lock context is invalid (EXT) */
+ SYNCML_DM_LOCKCTX_NOTFOUND = 16,
+/** Unable to create thread (EXT) */
+ SYNCML_DM_UNABLE_START_THREAD = 17,
+/** Too many data files - invalid configuration (EXT) */
+ SYNCML_DM_TOO_MANY_DATA_FILES = 18,
+/** File is locked, try again later (EXT) */
+ SYNCML_DM_LOCK_TRY_AGAIN = 19,
+/** Constraint failed (EXT) */
+ SYNCML_DM_CONSTRAINT_FAIL = 20,
+/** Unable to load Access Control List file (EXT) */
+ SYNCML_DM_LOAD_ACL_FAIL = 21,
+/** Tree is read only (EXT) */
+ SYNCML_DM_TREE_READONLY = 22,
+/** At least one of the parameters is invalid (EXT) */
+ SYNCML_DM_INVALID_PARAMETER = 23,
+/** Authentication accepted */
+ SYNCML_DM_AUTHENTICATION_ACCEPTED = 212,
+/** Chunked item accepted and buffered 213*/
+ SYNCML_DM_CHUNK_BUFFERED = 213,
+/** Operation canceled */
+ SYNCML_DM_OPERATION_CANCELLED = 214,
+/** DM engine not executed */
+ SYNCML_DM_NOT_EXECUTED = 215,
+/** Atomic rollback */
+ SYNCML_DM_ATOMIC_ROLLBACK_OK = 216,
+/** DM tree not modified */
+ SYNCML_DM_NOT_MODIFIED = 304,
+/** Bad request */
+ SYNCML_DM_BAD_REQUEST = 400,
+/** Unauthorized access */
+ SYNCML_DM_UNAUTHORIZED = 401,
+/** Not found */
+ SYNCML_DM_NOT_FOUND = 404,
+/** The command not allowed */
+ SYNCML_DM_COMMAND_NOT_ALLOWED = 405,
+/** The asking feature not supported */
+ SYNCML_DM_FEATURE_NOT_SUPPORTED = 406,
+/** Authentication required */
+ SYNCML_DM_AUTHENTICATION_REQUIRED = 407,
+/** Request timeout */
+ SYNCML_DM_REQUEST_TIMEOUT = 408,
+/** Incomplete command */
+ SYNCML_DM_INCOMPLETE_COMMAND = 412,
+/** Request entity too large */
+ SYNCML_DM_REQUEST_ENTITY_TOO_LARGE = 413,
+/** URI too long */
+ SYNCML_DM_URI_TOO_LONG = 414,
+/** Unsupported media type format */
+ SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT = 415,
+/** Request range not satisfied */
+ SYNCML_DM_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
+/** The target already exists */
+ SYNCML_DM_TARGET_ALREADY_EXISTS = 418,
+/** Device is full */
+ SYNCML_DM_DEVICE_FULL = 420,
+ /**Size Mismatch */
+SYNCML_DM_SIZE_MISMATCH =424,
+/** Permission verification failed */
+ SYNCML_DM_PERMISSION_FAILED = 425,
+/** Command failed */
+ SYNCML_DM_COMMAND_FAILED = 500,
+/** The command not implemented */
+ SYNCML_DM_COMMAND_NOT_IMPLEMENTED = 501,
+/** Service currently not available */
+ SYNCML_DM_SERVICE_UNAVAILABLE = 503,
+/** Gateway timeout */
+ SYNCML_DM_GATEWAY_TIMEOUT = 504,
+/** Processing error */
+ SYNCML_DM_PROCESSING_ERROR = 506,
+/** Atomic failed */
+ SYNCML_DM_ATOMIC_FAILED = 507,
+/** Data store failure */
+ SYNCML_DM_DATA_STORE_FAILURE = 510,
+/** Operation cancelled failure */
+ SYNCML_DM_OPERATION_CANCELLED_FAILURE = 514,
+/** Atomic rollback failed */
+ SYNCML_DM_ATOMIC_ROLLBACK_FAILED = 516,
+/** Atomic response too large */
+ SYNCML_DM_ATOMIC_RESPONSE_TOO_LARGE = 517,
+/** Data set not complete for an ESN */
+ SYNCML_DM_ESN_SET_NOT_COMPLETE = 518,
+
+/** Http execute exceptions; keep in sync with DmResult.java **/
+ SYNCML_DM_SOCKET_TIMEOUT = 700,
+ SYNCML_DM_SOCKET_CONNECT_ERR = 701,
+ SYNCML_DM_NO_HTTP_RESPONSE = 702,
+ SYNCML_DM_UNKNOWN_HOST = 703,
+ SYNCML_DM_INTERRUPTED = 704,
+ /**Factory Data Reset result code */
+ SYNCML_DM_PROCESS_ACCEPTED = 1200
+
+};
+
+/** Return codes definition */
+typedef UINT32 SYNCML_DM_RET_STATUS_T;
+
+#endif
diff --git a/engine/dmlib/api/native/dmVersion.h b/engine/dmlib/api/native/dmVersion.h
new file mode 100644
index 0000000..67a60bc
--- /dev/null
+++ b/engine/dmlib/api/native/dmVersion.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_SYNCML_VERSION_H
+#define _DM_SYNCML_VERSION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**
+ * Retrieves a SyncML version
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par API Migration State: FINAL
+ * \param version [out] - optional pointer to version in the numeric format
+ * \return pinter to version in string format
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+const char *GetDMSyncMLVersion(unsigned long *version);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/api/native/dmstring.h b/engine/dmlib/api/native/dmstring.h
new file mode 100644
index 0000000..fa7ae5c
--- /dev/null
+++ b/engine/dmlib/api/native/dmstring.h
@@ -0,0 +1,437 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMSTRING_H__
+#define __DMSTRING_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmstring.h
+ \brief The dmstring.h header file contains String type definition (class String)
+*/
+
+#include "xpl_Types.h"
+
+/**
+* A simple String class similar to Java String and STL string with limited functionality
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*
+*/
+class DMString
+{
+ public:
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DMString() {m_pStr = (char*)XPL_NULL;}
+
+ /**
+ * Construct a string based on input string (similar to strdup()). The memory for the size of parameter "szStr" will be allocated.
+ * \param szStr [in] - pointer to null terminated string
+ */
+ DMString(CPCHAR szStr);
+
+ /**
+ * Construct a string based on input string and length. The memory for the "length" bytes will be allocated.
+ * \param szStr [in] - pointer to string
+ * \param nLen [in] - an integer argument presents string length
+ */
+ DMString(CPCHAR szStr, int nLen);
+
+ /**
+ * Copy constructor. The memory for the size of parameter "str" will be allocated.
+ * \param str [in] - constant reference to DMString
+ */
+ DMString(const DMString& str);
+
+ /**
+ * Destructor - freeing all dynamic resources
+ */
+ ~DMString();
+
+ /**
+ * Allows direct modification of the buffer.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \warning Be carefully, don't overrun the buffer !!!
+ * \param nPos [in] - integer index
+ * \param c [in] - new character
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void SetAt(INT32 nPos, char c );
+
+ /**
+ * Replaces all old character occurrences with the new character
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oldCh [in] - old character which should be replaced
+ * \param newCh [in] - a new character
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void replaceAll(char oldCh, char newCh);
+
+ /**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str [in] - constant reference to DMString
+ * \return reference to constant DMString (itself)
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ inline DMString & operator=(const DMString& str) { return (*this) = str.m_pStr;}
+ /**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szStr [in] - pointer to null terminated string
+ * \return reference to constant DMString
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ DMString & operator=(CPCHAR szStr);
+
+ /**
+ * Saves casting DMString to CPCHAR.
+ * \par Important Notes:
+ * - Note: this never returns null; and empty string ("") will be returned instead
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to null terminated string.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ inline CPCHAR c_str() const { return m_pStr ? m_pStr : "";}
+
+ /**
+ * ()
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return constant character pointer, never returns null - empty string "" returned instead.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ inline operator const char* () const { return c_str();}
+
+ /**
+ * Comparison operator (equally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param s2 [in] - reference to constant DMString
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ inline BOOLEAN operator==(const DMString & s2) const {return this->operator == (s2.m_pStr);}
+
+ /**
+ * Comparison operator (equally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szStr [in] - pointer to null terminated string
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ BOOLEAN operator==(CPCHAR szStr) const;
+
+ /**
+ * Comparison operator (unequally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param s2 [in] - reference to constant DMString
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ inline BOOLEAN operator!=(const DMString & s2) const {return this->operator != (s2.m_pStr);}
+
+ /**
+ * Comparison operator (unequally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szStr [in] - pointer to null terminated string
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ inline BOOLEAN operator!=(CPCHAR szStr) const {return ! operator == ( szStr );}
+
+/**
+ * Comparison operator.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str2 [in] - pointer to DMString to be compared with
+ * \return integer result of comparison <br>
+ * Result may be: <br>
+ * less then zero - this string is less then parameter str2 <br>
+ * greater then zero - this string is greater then parameter str2 <br>
+ * equal to zero - this string and parameter str2 are equal<br>
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int CompareNoCase( const DMString& str2 ) const;
+
+ /**
+ * String concatenation
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param s2 [in] -reference to constant DMString
+ * \return reference to constant DMString result of concatenation
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ inline DMString& operator += (const DMString & s2) {return (*this) += s2.m_pStr;}
+
+ /**
+ * String concatenation
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szStr [in] - pointer to null terminated string
+ * \return reference to constant DMString result of concatenation
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ DMString& operator += (CPCHAR szStr);
+
+ /**
+ * String concatenation
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szStr [in] - pointer to null terminated string
+ * \return reference to constant DMString result of concatenation
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ DMString& operator += (char c);
+
+ /**
+ * Gets buffer
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return character pointer to this String
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ inline char* GetBuffer() {return m_pStr;}
+
+
+ /**
+ * Allocates buffer for the provided length
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nLen [in] - buffer length
+ * \return character pointer
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ char* AllocateBuffer( int nLen );
+
+ /**
+ * Gets length for String
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return length of the string (integer)
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ INT32 length() const;
+
+ /**
+ * Verifis if String is empty
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return true if string is empty
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ inline BOOLEAN empty() const {return m_pStr == XPL_NULL; }
+
+ /**
+ * Sets string/substring based on the input string and given length
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param pStr [in] - pointer to string
+ * \param nLen [in] - an integer argument presents length
+ * \return boolean result of operation
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN assign(CPCHAR pStr, INT32 nLen);
+
+ /**
+ * Gets rid of the white space at the beginning and at the end of the string.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void trim();
+
+ /**
+ * Clears the string contents.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void clear();
+
+ /**
+ * URI encoding/decoding support. Performs encoding of non-standard URI symbols according to the RFC 2396
+ * \warning This function is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return false if fails (out of memory)
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN Encode();
+
+ /**
+ * Performs URI string decoding according to the RFC2396. <br>
+ * \warning This function is for internal usage only!!!
+ * \par Important Notes:
+ * -Note: If function fails, string can be partially changed, since inplace decoding has been already performed.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return false if fails (invalid string).
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN Decode();
+
+ /**
+ * Removes reference to string from class, but does not deallocate memory.
+ * \warning This function is for internal usage only!!!
+ * \par Important Notes:
+ * -Note: Should be used in pair with function attach()
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to null terminated string
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ CPCHAR detach();
+
+ /**
+ * Resets pointer to string
+ * \warning This function is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szStr [in] - pointer to null terminated string
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void attach(CPCHAR szStr);
+
+/**
+ * Removes rest of the string sourceStr after first occurrence on the separator
+ * \warning This function is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sourceStr [in] - string that should be truncated
+ * \param seperator [in] - separator that point to part that should be removed
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void RemoveSufix(CPCHAR sourceStr, int seperator);
+
+ private:
+ char *m_pStr;
+};
+
+/**
+ * Overload operator; concatenates two strings
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str1 [in] - first string
+ * \param str2 [in] - second string
+ * \return result concatenation str1 and str2
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+inline
+const DMString operator +( const DMString& str1, const DMString str2)
+{
+ DMString str3( str1 );
+
+ return str3 += str2;
+}
+
+#endif
diff --git a/engine/dmlib/api/native/dmt.hpp b/engine/dmlib/api/native/dmt.hpp
new file mode 100644
index 0000000..b7146c5
--- /dev/null
+++ b/engine/dmlib/api/native/dmt.hpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMT_API_H__
+#define __DMT_API_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/** \file dmt.hpp
+ \brief External API for DMTree
+
+The dmt.hpp header file contains External API for DMTree C++ API
+
+<b>Design Consideration</b>\n
+1. Only smart pointers are used, so user never has to allocate or deallocate memory directly.\n\n
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "jem_defs.hpp"
+#include "dmtPrincipal.hpp"
+#include "dmtAcl.hpp"
+#include "dmtData.hpp"
+#include "dmtAttributes.hpp"
+#include "dmtDataChunk.hpp"
+#include "dmtNode.hpp"
+#include "dmtTree.hpp"
+#include "dmtTreeFactory.hpp"
+#include "dmtNotification.hpp"
+#include "dmtSessionProp.hpp"
+#include "dmtEvent.hpp"
+#include "dmtEventData.hpp"
+
+#endif
diff --git a/engine/dmlib/api/native/dmtAcl.hpp b/engine/dmlib/api/native/dmtAcl.hpp
new file mode 100644
index 0000000..653f901
--- /dev/null
+++ b/engine/dmlib/api/native/dmtAcl.hpp
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTACL_H__
+#define __DMTACL_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*! \file dmtAcl.hpp
+ \brief The dmtAcl.hpp header file contains DmtAcl class definition. \n
+ DmtAcl models the standard ACL attribute Acl composes of Principals associated with \n
+ accessrights Principals are server identifications.
+*/
+
+#include "jem_defs.hpp"
+#include "dmtDefs.h"
+#include "dmtPrincipal.hpp"
+
+/**
+ * DmtAcl models the standard ACL attribute Acl composes of Principals associated with \n
+ * access rights Principals are server identifications. <P>
+ *
+ * <b>Access rights are</b>\n
+ * ADD\n
+ * DELETE\n
+ * EXEC\n
+ * GET\n
+ * REPLACE \n\n
+ *
+ * They are bit-wised together so we can use an integer to represent combinations of Acl Rights.
+ * \par Category: General
+ * \par Persistence: Transient
+ * \par Security: Non-Secure
+ * \par Migration State: FINAL
+ */
+class DmtAcl
+{
+public:
+ /**
+ * SyncML DM basic permissions for the servers to access DMT. The "COPY" permission is not supported.
+ */
+ enum {
+ /** "Add" Permission (permission to add new node to DMT)*/
+ ADD = SYNCML_DM_ACL_ADD,
+ /** "Delete" Permission (permission to remove node from DMT)*/
+ DELETE = SYNCML_DM_ACL_DELETE,
+ /** "Execute" Permission (permission to launch executable plug-ins )*/
+ EXEC = SYNCML_DM_ACL_EXEC,
+ /** "Get" Permission (permission to get DMT node's value)*/
+ GET = SYNCML_DM_ACL_GET,
+ /** "Replace" Permission (permission to change DMT node's value)*/
+ REPLACE= SYNCML_DM_ACL_REPLACE
+ };
+public:
+
+ /**
+ * Default constructor - no memory allocation performed.
+ **/
+ DmtAcl();
+
+ /**
+ * Constructor receives ACLs are in the Syncml DM Format. The memory for the size of parameter "strAcl" will be allocated.
+ * \par Example of ACL format:<br>
+ * Get=ServerB&Replace=ServerB&Delete=ServerB.
+ * \param strAcl [in] - ACLs are in Syncml DM Format
+ */
+ DmtAcl(CPCHAR strAcl );
+
+ /**
+ * ACL Format conversion
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return ACLs in the Syncml DM Format
+ * \par Example of ACL format: <br>
+ * Get=ServerB&Replace=ServerB&Delete=ServerB.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ DMString toString() const;
+
+ /**
+ * Gets principals covered by the ACL.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param aPrincipals [out] -vector of all principals covered by the ACL (correspond to "servers" in SyncML parlance)
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void GetPrincipals( DMVector<DmtPrincipal>& aPrincipals ) const;
+
+
+ /**
+ * Gets permission for the principal
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DM server Id (principal)
+ * \return permissions as an integer
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_ACL_PERMISSIONS_T GetPermissions( const DmtPrincipal& principal) const;
+
+ /**
+ * Sets permission for the principal
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DM server Id (principal)
+ * \param permissions [in] - permissions Bit-wised for each individual permission.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void SetPermission( const DmtPrincipal& principal, SYNCML_DM_ACL_PERMISSIONS_T permissions);
+
+ /**
+ * Adds permission for the principal
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DM server Id (principal)
+ * \param permissions [in] - individual or group of permissions.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void AddPermission( const DmtPrincipal& principal, SYNCML_DM_ACL_PERMISSIONS_T permissions);
+
+ /**
+ * Deletes permission for the principal
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DM server Id (principal)
+ * \param permissions [in] - individual or group of permissions.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void DeletePermission( const DmtPrincipal& principal, SYNCML_DM_ACL_PERMISSIONS_T permissions );
+
+ /**
+ * Retrieves if action permitted for the principal
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DM server Id (principal)
+ * \param permissions [in] - individual or group of permissions.
+ * \return true if the operation for such principal is permitted.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ BOOLEAN IsPermitted( const DmtPrincipal& principal, SYNCML_DM_ACL_PERMISSIONS_T permissions) const;
+
+ private:
+ DMMap<DmtPrincipal, SYNCML_DM_ACL_PERMISSIONS_T> m_mapAcls;
+};
+
+#endif
diff --git a/engine/dmlib/api/native/dmtAttributes.hpp b/engine/dmlib/api/native/dmtAttributes.hpp
new file mode 100644
index 0000000..4459d1b
--- /dev/null
+++ b/engine/dmlib/api/native/dmtAttributes.hpp
@@ -0,0 +1,327 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTATTRIBUTES_H__
+#define __DMTATTRIBUTES_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtAttributes.hpp
+ \brief The dmtAttributes.hpp header file contains DmtAttributes class definition. \n
+ This class encapsulates all standard DMT attributes.
+*/
+
+#include "jem_defs.hpp"
+#include "dmtAcl.hpp"
+
+/**
+* This class encapsulates all standard DMT attributes.<P>
+*
+* <TABLE>
+* <TR><TD>ACL</TD><TD>Access Control List</TD></TR>
+* <TR><TD>Format</TD><TD>Specifies how object values should be interpreted (b64, int, boolean, string ¡­)</TD></TR>
+* <TR><TD>Name</TD><TD>The name of the object in the tree</TD></TR>
+* <TR><TD>Size</TD><TD>Size of the object value in bytes</TD></TR>
+* <TR><TD>Title</TD><TD>Human readable name</TD></TR>
+* <TR><TD>TStamp</TD><TD>Time stamp, date and time of last change</TD></TR>
+* <TR><TD>Type</TD><TD>The MIME type of the object</TD></TR>
+* <TR><TD>VerNo</TD><TD>Version number, automatically incremented at each modification</TD></TR>
+* </TABLE>
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtAttributes
+{
+private:
+ DMString m_strName;
+ DMString m_strFormat;
+ DMString m_strTitle;
+ DMString m_strType;
+ INT32 m_nVersion;
+ INT32 m_nSize;
+ JemDate m_nTimestamp;
+ DmtAcl m_oAcl;
+
+public:
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DmtAttributes();
+
+ /**
+ * Constructs DmtAttributes object with provided values . The memory required for DmtAttributes object will be allocated.
+ * \param name [in] - Name of attribute
+ * \param format [in] - Attribute format
+ * \param title [in] - Attribute titles
+ * \param type [in] - Attribute type
+ * \param version [in] - Version number
+ * \param size [in] - Attribute size
+ * \param timestamp [in] - Timestamp is number of milliseconds since the standard base time known as "the epoch",
+ * namely January 1, 1970, 00:00:00 GMT.
+ * which is locale-independent.
+ * \param acl [in] - access control list (DmtAcl type)
+ */
+ DmtAttributes( CPCHAR name,
+ CPCHAR format,
+ CPCHAR title,
+ CPCHAR type,
+ INT32 version,
+ INT32 size,
+ const JemDate& timestamp,
+ const DmtAcl& acl);
+
+ /**
+ * Sets all required parameters.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param name [in] - Name of attribute
+ * \param format [in] - Attribute format
+ * \param title [in] - Attribute titles
+ * \param type [in] - Attribute type
+ * \param version [in] - Version number
+ * \param size [in] - Attribute size
+ * \param timestamp [in] - Timestamp is number of milliseconds since the standard base time known as "the epoch",
+ * namely January 1, 1970, 00:00:00 GMT.
+ * which is locale-independent.
+ * \param acl [in] - access control list (DmtAcl type)
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T Set( CPCHAR name,
+ CPCHAR format,
+ CPCHAR title,
+ CPCHAR type,
+ INT32 version,
+ INT32 size,
+ const JemDate& timestamp,
+ const DmtAcl& acl);
+
+
+
+ /**
+ * Sets all required parameters.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oAttr [in] - reference to DmtAttributes object with all attributes
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T Set( const DmtAttributes & oAttr );
+
+
+ /**
+ * Sets name of the Node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param name [in] - name of the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetName( CPCHAR name);
+
+ /**
+ * Sets title of the Node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param title [in] - title of the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetTitle( CPCHAR title);
+
+ /**
+ * Sets format of the Node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param format [in] - format of the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetFormat( CPCHAR format);
+
+ /**
+ * Sets size of the Node value in bytes
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param size [in] - size of the node value in bytes
+ * \return None
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void SetSize( INT32 size);
+
+ /**
+ * Retrieves format of the Node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Format (String, Binary, Integer...) of the Node
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ inline const DMString& GetFormat() const
+ {
+ return m_strFormat;
+ }
+
+
+ /**
+ * Retrieves name of the node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Node name.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ inline const DMString& GetName() const
+ {
+ return m_strName;
+ }
+
+ /**
+ * Retrieves access control list for the node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return DmtAcl (DMT access control list ) for node
+ * \warning DMT access control could be null!
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ inline const DmtAcl& GetAcl() const
+ {
+ return m_oAcl;
+ }
+
+ /**
+ * Retrieves node size
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return node value's size (32-bit).
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ inline INT32 GetSize() const
+ {
+ return m_nSize;
+ }
+
+ /**
+ * Retrieves node titles
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return title (optional), could be null.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ inline const DMString& GetTitle() const
+ {
+ return m_strTitle;
+ }
+
+ /**
+ * Retrieves node type
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Mime-type of the Node, Could be null.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ inline const DMString& GetType() const
+ {
+ return m_strType;
+ }
+
+ /**
+ * Retrieves timestamp
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
+ * which is locale-independent
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ inline const JemDate& GetTimestamp() const
+ {
+ return m_nTimestamp;
+ }
+
+ /**
+ * Retrieves version
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Version ( a 16 bit unsigned integer ). Each time an object with this property changes value,\n
+ * through a management operation or other event, this value is incremented. If the property\n
+ * value has reached FFFF, and then is incremented, it returns to 0000.\n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ inline INT32 GetVersion() const
+ {
+ return m_nVersion;
+ }
+
+};
+
+//Changed Version from String to int to be compatible with Java API
+
+#endif
diff --git a/engine/dmlib/api/native/dmtData.hpp b/engine/dmlib/api/native/dmtData.hpp
new file mode 100644
index 0000000..69e3172
--- /dev/null
+++ b/engine/dmlib/api/native/dmtData.hpp
@@ -0,0 +1,516 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTDATA_H__
+#define __DMTDATA_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtData.hpp
+ \brief The dmtData.hpp header file contains DmtData class definition. \n
+ This class encapsulates various Device Management Tree leaf node \n
+ data formats.
+*/
+
+#include "jem_defs.hpp"
+#include "dmtDefs.h"
+
+/**
+* NULLVALUE MUST BE USED TO get a NULLTYPE DATA\n
+* Or (const char *)0, Do NOT use NULL as some SYSTEM header file\n
+* Will define NULL as integer 0.\n
+*/
+#define NULLVALUE ((const char *)0)
+
+
+
+/**
+* DmtData encapsulates various DMT leaf node data formats.\n
+* Note: Functions "Get" returns error code; possible errors are: \n
+* <i>enumDmtResult_Success </i> - means success, \n
+* <i>enumDmtResult_TypeMismatch </i> - means datatype of stored \n
+* value and asked type are mismatched and automatic conversion is not possible\n
+* <pre>
+* <b>Data formats includes:</b>
+* String
+* Integer
+* Boolean
+* Binary
+* </pre>
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtData
+{
+ /**
+ * Data Type as defined in SyncML DM Spec.<P>
+ * Format (b64 | bool | chr | int | node | float | date| time |
+ * null | xml)<P>
+ * Currently only support bool, chr, int, bin, node, float, date
+ * and time.
+ */
+
+public:
+ /**Deprecated: For legacy API calls support only. The api/common/dmtDefs.h
+ * will be the global place to define and expose DM data type
+ * enumerations that consist with MDF definition.
+ */
+ enum
+ {
+ UNDEFINED = SYNCML_DM_DATAFORMAT_UNDEFINED,
+ NULLTYPE = SYNCML_DM_DATAFORMAT_NULL,
+ STRING = SYNCML_DM_DATAFORMAT_STRING,
+ INT = SYNCML_DM_DATAFORMAT_INT,
+ BOOL = SYNCML_DM_DATAFORMAT_BOOL,
+ BIN = SYNCML_DM_DATAFORMAT_BIN,
+ NODE = SYNCML_DM_DATAFORMAT_NODE,
+ DATE = SYNCML_DM_DATAFORMAT_DATE,
+ TIME = SYNCML_DM_DATAFORMAT_TIME,
+ FLOATTYPE = SYNCML_DM_DATAFORMAT_FLOAT
+ };
+ /**Deprecated: For legacy API calls support only. */
+ typedef SYNCML_DM_DATAFORMAT_T EnumDataType;
+
+ //instance variables
+private:
+ EnumDataType metaFormat; // same as Format in SYNCML_DM_FORMAT
+
+ DMString m_strValue;
+ INT32 m_nValue;
+ BOOLEAN m_bValue;
+ DMVector<UINT8> m_pBinValue;
+ DMStringVector m_astrNodeValue; //Child Node Names
+
+public:
+ /**
+ * Default Constructor - no memory allocation performed.
+ */
+ DmtData();
+
+ /**
+ * Constructor for all data types with string based serialization/
+ * de-serialization with 1 param, i.e., String/int/Bool/Float/Date/Time data type.
+ * Default type is STRING for backward compatibility. The memory for the size of parameter "szStr" will be allocated.
+ * \param szStr [in] - data as nul terminated string
+ */
+ DmtData(CPCHAR szStr);
+
+ /**
+ * Constructor for all data types with string based serialization/
+ * de-serialization with 2 params, i.e., String/int/Bool/Float/Date/Time data type.
+ * Default type is STRING for backward compatibility.
+ * \par Important Notes:
+ * - Note: The memory for the size of parameter "szStr" will be allocated if type is bin or string.
+ * \param szStr [in] - data as nul terminated string
+ * \param type [in] - DM data type
+ */
+
+ DmtData(CPCHAR szStr , SYNCML_DM_DATAFORMAT_T type);
+
+ /**
+ * Data represents an integer type. No memory allocation performed.
+ * \param integer [in] - DM integer data
+ */
+ DmtData(INT32 integer);
+
+ /**
+ * Data represents a boolean type (explicit for backward compatibility). No memory allocation performed.
+ * \param b [in] - DM boolean data
+ */
+ explicit DmtData(BOOLEAN b);
+
+ /**
+ * Data represents a boolean type (for backward compatibility). No memory allocation performed.
+ * \param b [in] - DM boolean data
+ */
+ DmtData(BOOLTYPE b);
+
+
+ /**
+ * Data represents a binary type. The memory for the size of parameter "szStr" (parameter "len") will be allocated.
+ * \param bin [in] - DM binary data
+ * \param len [in] - length of the data
+ */
+ DmtData(const UINT8 * bin, INT32 len);
+
+ /**
+ * Supports node type as defined in SyncML DM Spec
+ * if the data type is node, it means it contains child node names.
+ * The memory required for the parameter "aChildren" will be allocated.
+ * \param aChildren [in] - vector with child node names
+ **/
+ DmtData(const DMStringVector& aChildren);
+
+ /** Destructor - freeing all dynamic resources */
+ ~DmtData();
+
+ /**
+ * Retrieves data type.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return type (SYNCML_DM_DATAFORMAT_T) - data type.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_DATAFORMAT_T GetType() const { return metaFormat; /* Type is format in this version.*/ }
+
+ /**
+ * Retrieves data string value.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str [out] - string representation of the value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_INVALID_PARAMETER - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetString( DMString& str ) const;
+
+ /**
+ *Retrieves boolean value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bValue [out] -boolean value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_INVALID_PARAMETER - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetBoolean( BOOLEAN& bValue ) const;
+
+ /**
+ *Retrieves boolean value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bValue [out] -boolean type value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetBoolean( BOOLTYPE& bValue ) const;
+
+ /**
+ * Retrieves integer value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nValue [out] -integer value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_INVALID_PARAMETER - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetInt( INT32& nValue ) const;
+
+ /**
+ * Retrieves date value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sDate [out] -date string value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_INVALID_PARAMETER - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetDate( DMString& sDate ) const;
+
+ /**
+ * Retrieves time value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sTime [out] -time string value
+ * \return status code
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetTime( DMString& sTime ) const;
+
+ /**
+ * Retrieves float value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param fValue [out] -float value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_INVALID_PARAMETER - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetFloat( DMString& fValue ) const;
+
+ /**
+ * Retrieves binary value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param buffer [out] -binary value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_INVALID_PARAMETER - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetBinary(DMVector<UINT8>& buffer ) const;
+
+ /**
+ * As mentioned before the complete structure of all management objects and the root (the
+ * device itself) forms a tree. Management servers can explore the structure of the tree by
+ * using the GET command. If the accessed object has child objects linked to it the name of
+ * these child objects are returned as a result of the GET.
+ * \par Important Notes:
+ * - Note: If there are no children the object MUST have a value, which could be null, and this value is returned.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param aChildren [out] - child node names
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_INVALID_PARAMETER - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetNodeValue( DMStringVector& aChildren ) const;
+
+ /**
+ * Sets string value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szStr [in] -string value
+ * \param type [in] -SYNCML_DM_DATAFORMAT_T value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetString(CPCHAR szStr, SYNCML_DM_DATAFORMAT_T type =
+ SYNCML_DM_DATAFORMAT_STRING);
+ /**
+ * Sets boolean value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bValue [in] -boolean value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetBoolean(BOOLEAN bValue);
+
+ /**
+ * Sets integer value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nValue [in] -integer value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetInt(INT32 nValue);
+
+ /**
+ * Sets date value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sDate [in] -date string value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetDate(CPCHAR sDate);
+
+ /**
+ * Sets time value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sTime [in] -time string value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetTime(CPCHAR sTime);
+
+ /**
+ * Sets float value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param fValue [in] -float value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetFloat(CPCHAR fValue);
+
+ /**
+ * Sets binary value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param buf [in] -binary value
+ * \param len [in] -size
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetBinary(const UINT8 * buf, INT32 len);
+
+
+ /**
+ * Sets node value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param aChildren [in] -child node names
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetNodeValue( const DMStringVector& aChildren );
+
+
+ /**
+ * Sets data
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oData [in] -dmt data
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T Set( const DmtData & oData );
+
+ /**
+ * Adds node value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sChild [in] -child node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T AddNodeValue( const DMString & sChild );
+
+
+ /**
+ * Retrieves string value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return reference on string value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ const DMString & GetStringValue() const;
+
+ /**
+ * Retrieves binary value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return reference on binary value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ const DMVector<UINT8> & GetBinaryValue() const;
+
+ /**
+ * Retrieves node value
+ * \return node value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ const DMStringVector & GetNodeValue() const;
+
+ /**
+ * Retrieves value(data) size
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_INVALID_PARAMETER - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+
+
+ SYNCML_DM_RET_STATUS_T GetSize(INT32 &dataSize) const;
+
+};
+
+#endif
diff --git a/engine/dmlib/api/native/dmtDataChunk.hpp b/engine/dmlib/api/native/dmtDataChunk.hpp
new file mode 100644
index 0000000..1d42e9b
--- /dev/null
+++ b/engine/dmlib/api/native/dmtDataChunk.hpp
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTDATACHUNK_H__
+#define __DMTDATACHUNK_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "jem_defs.hpp"
+#include "dmtDefs.h"
+
+/**
+ * DmtDataChunk encapsulates various methods to access External Storage Node (ESN) data.
+ * \par Category: General
+ * \par Persistence: Transient
+ * \par Security: Non-Secure
+ * \par Migration State: FINAL
+ */
+class DmtDataChunk
+{
+public:
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DmtDataChunk();
+ /**
+ * Destructor - freeing all dynamic resources
+ */
+ ~DmtDataChunk();
+ /**
+ * Gets chunk buffer size
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return chunk buffer size
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static UINT32 GetChunkSize();
+
+ /**
+ * Gets ESN data in chunk buffer
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bufp -[out] Pointer to chunk data
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T GetChunkData( UINT8 **bufp);
+
+ /**
+ * Gets ESN data in chunk buffer
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dataSize -[out] Actual length of return data in chunk buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T GetChunkDataSize( UINT32& dataSize);
+
+ /**
+ * Gets ESN data length in chunk buffer
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param len -[out] Actual length of return data in chunk buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T GetReturnLen( UINT32& len ) const;
+
+ /**
+ * Sets return data length in chunk buffer
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param len -[In] Actual length of return data in chunk buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T SetReturnLen( UINT32& len );
+
+ /**
+ * Sets input data (chunk)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T SetChunkData(const UINT8 *buf, UINT32 dataSize);
+
+ /**
+ * Allocates chunk buffer
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T AllocateChunkBuffer();
+
+ /**
+ * Frees chunk buffer
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T FreeChunkBuffer();
+
+ /**
+ * Detaches chunk buffer
+ * \warning This functions is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to chunk buffer
+ */
+ UINT8 * detach();
+
+ /**
+ * Attaches chunk buffer
+ * \warning This functions is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param chunkBuffer -[In] chunk buffer with data which should be attached
+ * \param dataSize -[In] Actual length of data in chunk buffer
+ */
+ void attach(UINT8 *chunkBuffer, UINT32 dataSize);
+
+ private:
+ UINT8 *chunkBuffer; // chunk data buffer
+ UINT32 dataSize; // actual size of input data
+ UINT32 returnLen; // valid content length returned
+ UINT32 maxDataSize; // Chunk buffer size
+
+};
+
+#endif
diff --git a/engine/dmlib/api/native/dmtEvent.hpp b/engine/dmlib/api/native/dmtEvent.hpp
new file mode 100644
index 0000000..cd5b723
--- /dev/null
+++ b/engine/dmlib/api/native/dmtEvent.hpp
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTEVENT_H__
+#define __DMTEVENT_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtEvent.hpp
+ \brief The dmtEvent.hpp header file contains DmtEventSubscription class definition. \n
+ This class represents a subscription on DMT update event.
+*/
+
+#include "dmtDefs.h"
+#include "dmstring.h"
+#include "dmvector.h"
+#include "dmtPrincipal.hpp"
+
+/**Topic of DM event about start of server session */
+#define DMT_EVENT_OTA_SESSION_STARTED "/motorola/dmt/ota/sessionstart"
+/**Topic of DM event about finish of server session */
+#define DMT_EVENT_OTA_SESSION_FINISHED "/motorola/dmt/ota/sessionend"
+/**Topic prefix of DM event about updates in the Screen3 sub tree */
+#define DMT_UPDATE_S3_PREFIX "/motorola/dmt/S3/"
+/**Topic prefix of generic of DM update event */
+#define DMT_UPDATE_GENERIC_PREFIX "/motorola/dmt/update/"
+
+/**Generic name for OTA principals */
+#define DM_SERVER_PRINCIPAL "OTA"
+
+
+
+/**
+* DmtEventSubscription represents subscription on DMT update event.
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtEventSubscription {
+
+public:
+
+ /**
+ * Default Constructor - no memory allocation performed.
+ */
+ DmtEventSubscription()
+ {
+ m_eAction = SYNCML_DM_EVENT_NONE;
+ m_nType = SYNCML_DM_EVENT_NODE;
+ }
+
+
+ /**
+ * Sets up subscription.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param eAction [in] - actions to track, Bit-wised
+ * \param nType [in] - event type
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
+ * - All other codes indicate failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ SYNCML_DM_RET_STATUS_T Set(SYNCML_DM_EVENT_ACTION_T eAction,
+ SYNCML_DM_EVENT_TYPE_T nType);
+
+
+ /**
+ * Sets up subscription.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param eAction [in] - actions to track, Bit-wised
+ * \param nType [in] - event type
+ * \param szTopic [in] - event topic suffix ( may be NULL )
+ * \param aIgnorePrincipals [in] - vector of principals, which initiated updates are to be ignored
+ * \param aNotifyPrincipals [in] - vector of principals, which initiated updates are to be processed
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
+ * - All other codes indicate failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ SYNCML_DM_RET_STATUS_T Set(SYNCML_DM_EVENT_ACTION_T eAction,
+ SYNCML_DM_EVENT_TYPE_T nType,
+ CPCHAR szTopic,
+ const DMVector<DmtPrincipal> & aIgnorePrincipals,
+ const DMVector<DmtPrincipal> & aNotifyPrincipals);
+
+ /**
+ * Sets up topic suffix for DMT update event.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szTopic [in] - event topic suffix
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
+ * - All other codes indicate failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T SetTopic(CPCHAR szTopic);
+
+ /**
+ * Adds principal into internal vector.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oPrincipal [in] - principal
+ * \param bIsIgnore [in] - specifies type of principal \n
+ * - TRUE - principal to ignore \n
+ * - FALSE - principal to process updates
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
+ * - All other codes indicate failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ SYNCML_DM_RET_STATUS_T AddPrincipal(const DmtPrincipal & oPrincipal, BOOLEAN bIsIgnore);
+
+ /**
+ * Retrieves operations (actions) to be tracked on node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_EVENT_ACTION_T)\n
+ * - Bit-wised actions to be tracked by DM engine
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_EVENT_ACTION_T GetAction() const { return m_eAction; }
+
+ /**
+ * Retrieves subscription type.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_EVENT_TYPE_T) - subscription type\n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_EVENT_TYPE_T GetType() const { return m_nType; }
+
+ /**
+ * Retrieves topic suffix for DMT update event.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return topic suffix
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ const DMString & GetTopic() const { return m_strTopic; }
+
+ /**
+ * Retrieves vector of principals.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bIsIgnore [in] - specifies type of principal \n
+ * - TRUE - principal to ignore \n
+ * - FALSE - principal to process updates
+ * \return vector of principals
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const DMVector<DmtPrincipal> & GetPrincipals(BOOLEAN bIsIgnore) const;
+
+protected:
+ /** Event Action*/
+ SYNCML_DM_EVENT_ACTION_T m_eAction;
+ /** Event Type*/
+ SYNCML_DM_EVENT_TYPE_T m_nType;
+ /**Topic*/
+ DMString m_strTopic;
+ /** Collection with principals, which initiated updates are to be ignored*/
+ DMVector<DmtPrincipal> m_aIgnorePrincipals;
+ /** Collection with principals, which initiated updates are to be processed*/
+ DMVector<DmtPrincipal> m_aNotifyPrincipals;
+
+};
+
+#endif
diff --git a/engine/dmlib/api/native/dmtEventData.hpp b/engine/dmlib/api/native/dmtEventData.hpp
new file mode 100644
index 0000000..1f662c8
--- /dev/null
+++ b/engine/dmlib/api/native/dmtEventData.hpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTEVENTDATA_H__
+#define __DMTEVENTDATA_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtEventData.hpp
+ \brief The dmtEventData.hpp header file contains DmtEventData class definition. \n
+ This class represents updates performed on particular DM node.
+*/
+
+#include "dmtEvent.hpp"
+#include "dmstring.h"
+#include "dmvector.h"
+
+/**
+* DmtEventData represents actual updates performed on DM node.
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtEventData : public JemBaseObject
+{
+
+public:
+
+ /**
+ * Default Constructor - no memory allocation performed.
+ */
+ DmtEventData()
+ {
+ m_eAction = SYNCML_DM_EVENT_NONE;
+ m_bIsLeaf = FALSE;
+ }
+
+ /**
+ * Default Destructor.
+ */
+ virtual ~DmtEventData() {}
+
+ /**
+ * Retrieves operations (actions) performed on node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_EVENT_ACTION_T)\n
+ * - Bit-wised actions performed on node
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ inline SYNCML_DM_EVENT_ACTION_T GetAction() const { return m_eAction; }
+
+
+ /**
+ * Retrieves type of node (leaf or interior).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return TRUE if node is leaf\n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ inline BOOLEAN IsLeaf() const { return m_bIsLeaf; }
+
+
+ /**
+ * Retrieves node name.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return const reference on node name\n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const DMString & GetName() const { return m_strName; }
+
+ /**
+ * Retrieves node name.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return reference on node name\n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ DMString & GetName() { return m_strName; }
+
+
+/**
+ * Retrieves new node name (Rename was performed).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return const reference on new node name\n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const DMString & GetNewName() const { return m_strNewName; }
+
+/**
+ * Retrieves new node name (Rename was performed).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return reference on new node name\n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ DMString & GetNewName() { return m_strNewName; }
+
+
+
+protected:
+ /** child node name */
+ DMString m_strName;
+ /** child node new name*/
+ DMString m_strNewName;
+
+ /** child node operation */
+ SYNCML_DM_EVENT_ACTION_T m_eAction;
+ /** flag contains info is a node is a leaf*/
+ BOOLEAN m_bIsLeaf;
+};
+
+
+/**
+* Type definition for DmtEventData smart pointer
+*/
+typedef JemSmartPtr<DmtEventData> PDmtEventData;
+
+/**
+* Type definition for vector containing DmtEventData smart pointers
+*/
+typedef DMVector<PDmtEventData> DmtEventDataVector;
+
+/**
+* Type definition for map containing parent node path and vector of updates on children nodes
+*/
+typedef DMMap<DMString, DmtEventDataVector> DmtEventMap;
+
+#endif
diff --git a/engine/dmlib/api/native/dmtFirmAlert.hpp b/engine/dmlib/api/native/dmtFirmAlert.hpp
new file mode 100644
index 0000000..13132dc
--- /dev/null
+++ b/engine/dmlib/api/native/dmtFirmAlert.hpp
@@ -0,0 +1,299 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTFIRMALERT_H__
+#define __DMTFIRMALERT_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtFirmAlert.hpp
+ \brief The dmtFirmAlert.hpp header file contains DmtFirmAlert class definition. \n
+ This class is a helper class for sending repair status with ALERT 1226.\n
+ <b>Warning:</b> All functions, structures, and classes from this header file are for internal usage only!!!
+*/
+
+#include "jem_defs.hpp"
+
+/**
+ * Helper class for sending repair status with ALERT 1226
+ * \warning This class is using <b>ONLY</b> for firmware update session!
+ * \par Category: General
+ * \par Persistence: Transient
+ * \par Security: Non-Secure
+ * \par Migration State: FINAL
+ */
+class DmtFirmAlert
+{
+private:
+ DMString m_strPackageURI; // URI of update package
+ DMString m_strCorrelator;
+ DMString m_strResultData;
+ DMString m_strAlertType;
+ DMString m_strAlertFormat;
+ DMString m_strAlertMark;
+
+public:
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DmtFirmAlert()
+ {
+ }
+
+ /**
+ * Constructor Firm Alert base on the parameters. The memory will be allocated.
+ * \param packageURI [in] - package URI, constant character pointer.
+ * \param resultData [in] - result data, constant character pointer.
+ * \param alertType [in] - alert type, constant character pointer.
+ * \param alertFormat [in] - alert format, constant character pointer.
+ * \param alertMark [in] - alert mark, constant character pointer.
+ * \param szCorrelator [in] - correlator, constant character pointer.
+ */
+ DmtFirmAlert(
+ const char* packageURI,
+ const char* resultData,
+ const char* alertType,
+ const char* alertFormat,
+ const char* alertMark,
+ const char* szCorrelator )
+ {
+ m_strPackageURI = packageURI;
+ m_strCorrelator = szCorrelator;
+ m_strResultData = resultData;
+ m_strAlertType = alertType;
+ m_strAlertFormat = alertFormat;
+ m_strAlertMark = alertMark;
+ }
+
+
+ /**
+ * Retrieves alert type
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \returns string alert type
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ const DMString & getAlertType() const
+ {
+ return m_strAlertType;
+ }
+
+ /**
+ * Retrieves alert format
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \returns alert format
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ const DMString& getAlertFormat() const
+ {
+ return m_strAlertFormat;
+ }
+
+ /**
+ * Retrieves alert mark
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \returns alert mark
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ const DMString& getAlertMark() const
+ {
+ return m_strAlertMark;
+ }
+
+
+ /**
+ * Retrieves result data
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \returns firmware update result code
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ const DMString& getResultData() const
+ {
+ return m_strResultData;
+ }
+
+
+ /**
+ * Retrieves package URI
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \returns update package URI in DMString.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ const DMString & getPackageURI() const
+ {
+ return m_strPackageURI;
+ }
+
+ /**
+ * Retrieves correlator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \returns Correlator in DMString.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ const DMString & getCorrelator() const
+ {
+ return m_strCorrelator;
+ }
+
+
+ /**
+ * Sets alert type
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param alertType [in] - alert type as a string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T setAlertType(const char* alertType)
+ {
+ m_strAlertType = alertType;
+ return SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Sets alert format
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param alertFormat [in] - alert format as a string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T setAlertFormat(const char* alertFormat)
+ {
+ m_strAlertFormat = alertFormat;
+ return SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Sets alert mark
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param alertMark [in] - alert mark as a string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T setAlertMark(const char* alertMark)
+ {
+ m_strAlertMark = alertMark;
+ return SYNCML_DM_SUCCESS;
+ }
+
+
+ /**
+ * Sets result code
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param resultData [in] - result data as a string, usually a result code
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T setResultData(const char* resultData )
+ {
+ m_strResultData = resultData;
+ return SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Sets correlator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param correlator [in] - correlator as a string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T setCorrelator(const char* correlator )
+ {
+ m_strCorrelator= correlator;
+ return SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Sets package URI
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param strPackageURI [in] - package URI as a string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_DEVICE_FULL - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_INVALID_PARAMETER - indicate that operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T setPackageURI(const DMString & strPackageURI)
+ {
+ if ( !strPackageURI.length() )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ m_strPackageURI = strPackageURI;
+ return SYNCML_DM_SUCCESS;
+ }
+
+};
+
+#endif //End of include file
diff --git a/engine/dmlib/api/native/dmtNode.hpp b/engine/dmlib/api/native/dmtNode.hpp
new file mode 100644
index 0000000..1e30f5d
--- /dev/null
+++ b/engine/dmlib/api/native/dmtNode.hpp
@@ -0,0 +1,920 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTNODE_H__
+#define __DMTNODE_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtNode.hpp
+ \brief The dmtNode.hpp header file contains DmtNode class definition. \n
+ DmtNode is the object representing tree nodes as they are\n
+ created and added to the tree. The class is NOT designed\n
+ to serve navigation of the DM Tree.
+*/
+
+#include "jem_defs.hpp"
+
+#include "dmt.hpp"
+
+class DmtTree;
+
+/**
+DmtNode is the object representing tree nodes as they are
+created and added to the tree. The class is NOT designed
+for its objects to serve for navigation of the tree.
+Almost all methods return a smart pointer to the
+error description object if failed and NULL if succeeded
+
+<P>
+
+Sample usage:<P>
+
+<PRE>
+ DmtPrincipal principal("localhost");
+ PDmtTree ptrTree;
+ SYNCML_DM_RET_STATUS_T ret_status ;
+
+ if ( (ret_status = DmtFactory::GetTree(principal, ptrTree ) ) != SYNCML_DM_SUCCESS )
+ {
+ ... error handling
+ return;
+ }
+
+ PDmtNode ptrNode;
+
+ if ( (ret_status = ptrTree->GetNode( "./SyncML/DMAcc/GUID/AddrType", ptrNode ) ) != SYNCML_DM_SUCCESS )
+ {
+ ... error handling
+ return;
+ }
+
+ std::string str;
+ if ( (ptrError = ptrNode->GetStringValue( str )) != NULL )
+ {
+ ... error handling
+ return;
+ }
+
+ printf( "String value is %s\n", str.c_str() );
+</PRE>
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtNode : public JemBaseObject
+{
+protected:
+ /** Destructor - freeing all dynamic resources */
+ virtual ~DmtNode(){}
+
+public:
+ /**
+ * Retrieves device management tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptrTree [out] - reference to the DM tree
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetTree( PDmtTree& ptrTree ) const = 0;
+
+ /**
+ * Retrieves node path
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [out] - reference to path in the tree
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetPath( DMString & path ) const = 0;
+
+ /**
+ * Gets a copy of DmtAttributes, user can modify the DmtAttributes individually.
+ * \warning Any change made to DmtAttributes will not propagated to the Node until a setAttributes is called.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oAttr [out] - reference to DM tree attributes
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetAttributes( DmtAttributes& oAttr ) const = 0;
+
+ /**
+ * Updates title information for the node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szTitle [in] - node titles string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetTitle( CPCHAR szTitle ) = 0;
+
+ /**
+ * Updates ACL for the node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oAcl [in] - reference to DMT ACL object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetAcl( const DmtAcl& oAcl ) = 0;
+
+ /**
+ * The DmtValue is a copy of current data of the node. Could set empty DmtData object if there is no value associated with it.
+ * \warning The node value will not be changed until a setValue is called.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oData [out] - reference to DmtData object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetValue( DmtData& oData ) const = 0;
+
+ /**
+ * Changes the value of a node. If not successful, return an error code.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param value [in] - new node value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetValue( const DmtData& value ) = 0;
+
+ /**
+ * Fills in the vector oChildren list of child nodes.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oChildren [out] - vector for child nodes
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetChildNodes( DMVector<PDmtNode>& oChildren ) const = 0;
+
+
+ /**
+ * Checks if a node is a leaf
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return 'true' if the node is a leaf
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual BOOLEAN IsLeaf() const = 0;
+
+ /**
+ * Function sets child node object by name
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szPath [in] - name of node
+ * \param ptrNode [out] - reference to DmtNode
+ * \return status code
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetChildNode( CPCHAR szPath, PDmtNode& ptrNode ) = 0;
+
+ /**
+ * Executes a node according to the specified path, passing a String
+ * parameter to the executable code
+ * \warning This functions is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param strData [in] - data to be executed as a string
+ * \param result [out] - the result of executing will be set to this string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Execute( CPCHAR strData, DMString& result ) = 0;
+
+
+ /**
+ * This is helper function: gets value of the node with type "string".
+ * It is a shortcut to the GetValue()->GetString().
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str [out] - result string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetStringValue( DMString& str ) const;
+
+ /**
+ * This is a helper function: gets value of the node with type "integer".
+ * It is a shortcut to the GetValue()->GetInt()
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nValue [out] - result integer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetIntValue( INT32& nValue ) const;
+
+ /**
+ * This is a helper function: gets value of the node with type "boolean".
+ * It is a shortcut to the GetValue()->GetBoolean()
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bValue [out] - result boolean
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetBooleanValue( BOOLEAN& bValue ) const;
+
+ /**
+ * This is a helper function: gets value of the node with type "boolean" (use for backward compatibility BOOLTYPE == bool).
+ * It is a shortcut to the GetValue()->GetBoolean().
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bValue [out] - result boolean
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetBooleanValue( BOOLTYPE& bValue ) const;
+
+ /**
+ * This is a helper function: gets value of the node with type "float".
+ * It is a shortcut to the GetValue()->GetFloat()
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sFloat [out] - result float
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetFloatValue(DMString& sFloat ) const;
+
+ /**
+ * This is a helper function: gets value of the node with type ""date".
+ * It is a shortcut to GetValue()->GetDate().
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sDate [out] - result date string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetDateValue( DMString& sDate ) const;
+
+ /**
+ * This is a helper function: gets value of the node with type "string".
+ * It is a shortcut to GetValue()->GetTime().
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sTime [out] - result time string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetTimeValue( DMString& sTime ) const;
+
+ /**
+ * This is a helper function: gets value of the node with type "binary".
+ * It is a shortcut to GetValue()->GetBinary().
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param binValue [out] - result binary blob
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T GetBinaryValue( DMVector<UINT8>& binValue ) const;
+
+ /**
+ * This is a helper function: sets value of the node with type "string".
+ * It is a shortcut to the SetValue(DmtData()).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetStringValue( CPCHAR str );
+
+ /**
+ * This is a helper function: sets value of the node with type "integer".
+ * It is a shortcut to the SetValue(DmtData()).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nValue [in]- the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetIntValue( INT32 nValue );
+
+ /**
+ * This is a helper function: sets value of the node with type "boolean".
+ * It is a shortcut to the SetValue(DmtData())
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bValue [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetBooleanValue( BOOLEAN bValue );
+
+ /**
+ * This is a helper function: sets value of the node with type "float".
+ * It is a shortcut to the SetValue(DmtData())
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param fValue [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetFloatValue( CPCHAR fValue );
+
+ /**
+ * This is a helper function: sets value of the node with type "date".
+ * It is a shortcut to the SetValue(DmtData()).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sDate [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetDateValue( CPCHAR sDate );
+
+ /**
+ * This is a helper function: sets value of the node with type "time".
+ * It is a shortcut to the SetValue(DmtData()).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sTime [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetTimeValue( CPCHAR sTime );
+
+ /**
+ * This is a helper function: sets value of the node with type "binary".
+ * It is a shortcut to the SetValue(DmtData()).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bin [in] - binary blob that should be set
+ * \param len [in] - length of the parameter "bin"
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_RET_STATUS_T SetBinaryValue( const UINT8 * bin, INT32 len );
+
+
+ /**
+ * Gets the name of the node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param name [out] - name of the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetNodeName(DMString & name) const = 0;
+
+ /**
+ * Gets the name of the node (wrapper for backward compatibility).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return name of the node \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ virtual DMString GetNodeName() const = 0;
+
+ /**
+ * Gets the first chunk of an ESN (External Storage Node) data . The chunk buffer is allocated internally.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [out] - result as a reference to the DMT Data Chunk object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that the ESN data reading successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+virtual SYNCML_DM_RET_STATUS_T GetFirstChunk(DmtDataChunk& dmtChunkData) = 0;
+
+ /**
+ * Gets the next chunk of an ESN (External Storage Node) data.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [out] - result as a reference to the DMT Data Chunk object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that the next chunk of ESN data reading successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+virtual SYNCML_DM_RET_STATUS_T GetNextChunk(DmtDataChunk& dmtChunkData) = 0;
+
+ /**
+ * Sets the first chunk of an ESN (External Storage Node) data . The chunk buffer is allocated internally.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [in] - reference to the DMT Data Chunk object that should be set.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that the ESN data reading successfully and first chunk of ESN data has been written. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+virtual SYNCML_DM_RET_STATUS_T SetFirstChunk(DmtDataChunk& dmtChunkData) = 0;
+
+ /**
+ * Sets the next chunk of an ESN (External Storage Node) data .
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [in] - reference to the DMT Data Chunk object that should be set.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that the next chunk of ESN data has been written successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+virtual SYNCML_DM_RET_STATUS_T SetNextChunk(DmtDataChunk& dmtChunkData) = 0;
+
+ /**
+ * Sets the last chunk of an ESN (External Storage Node) data .
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [in] - reference to the DMT Data Chunk object that should be set.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that the last chunk of ESN data has been written successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+virtual SYNCML_DM_RET_STATUS_T SetLastChunk(DmtDataChunk& dmtChunkData) = 0;
+
+ /**
+ * This function verifies if a node is an External Storage Node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return 'true' if the node is an External Storage Node
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+virtual boolean IsExternalStorageNode(void) const= 0;
+};
+
+ /**
+ * Gets value of the node with type "string".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str [out] - value of the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::GetStringValue( DMString& str ) const
+{
+ DmtData data;
+ SYNCML_DM_RET_STATUS_T ptrError = GetValue( data );
+ if ( ptrError != SYNCML_DM_SUCCESS )
+ return ptrError;
+ return data.GetString( str );
+}
+
+ /**
+ * Gets value of the node with type "integer".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nValue [out] - result integer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::GetIntValue( INT32& nValue ) const
+{
+ DmtData data;
+ SYNCML_DM_RET_STATUS_T ptrError = GetValue( data );
+ if ( ptrError != SYNCML_DM_SUCCESS )
+ return ptrError;
+ return data.GetInt( nValue );
+}
+
+ /**
+ * Gets value of the node with type "boolean".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bValue [out] - result boolean
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::GetBooleanValue( BOOLEAN& bValue ) const
+{
+ DmtData data;
+ SYNCML_DM_RET_STATUS_T ptrError = GetValue( data );
+ if ( ptrError != SYNCML_DM_SUCCESS )
+ return ptrError;
+ return data.GetBoolean( bValue );
+}
+
+ /**
+ * This is a helper function: gets boolean value of the node (use for backward compatibility BOOLTYPE == bool).
+ * It is a shortcut to the GetValue()->GetBoolean().
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bValue [out] - result boolean
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::GetBooleanValue( BOOLTYPE& bValue ) const
+{
+ DmtData data;
+ SYNCML_DM_RET_STATUS_T ptrError = GetValue( data );
+ if ( ptrError != SYNCML_DM_SUCCESS )
+ return ptrError;
+ return data.GetBoolean( bValue );
+}
+
+ /**
+ * Gets value of the node with type "float".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sFloat [out] - result float as a string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::GetFloatValue( DMString& sFloat ) const
+{
+ DmtData data;
+ SYNCML_DM_RET_STATUS_T ptrError = GetValue( data );
+ if ( ptrError != SYNCML_DM_SUCCESS )
+ return ptrError;
+ return data.GetFloat( sFloat );
+}
+
+ /**
+ * Gets value of the node with type "date".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sDate [out] - result date as a string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::GetDateValue( DMString& sDate ) const
+{
+ DmtData data;
+ SYNCML_DM_RET_STATUS_T ptrError = GetValue( data );
+ if ( ptrError != SYNCML_DM_SUCCESS )
+ return ptrError;
+ return data.GetDate( sDate );
+}
+
+ /**
+ * Gets value of the node with type "time".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sTime [out] - result time as a string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::GetTimeValue( DMString& sTime ) const
+{
+ DmtData data;
+ SYNCML_DM_RET_STATUS_T ptrError = GetValue( data );
+ if ( ptrError != SYNCML_DM_SUCCESS )
+ return ptrError;
+ return data.GetTime( sTime );
+}
+
+/**
+ * Gets value of the node with type "binary";
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param binValue [out] - result binary blob
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::GetBinaryValue( DMVector<UINT8>& binValue ) const
+{
+ DmtData data;
+ SYNCML_DM_RET_STATUS_T ptrError = GetValue( data );
+ if ( ptrError != SYNCML_DM_SUCCESS )
+ return ptrError;
+ return data.GetBinary( binValue );
+}
+
+ /**
+ * Sets value of the node with type "string".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::SetStringValue( CPCHAR str )
+{
+ return SetValue( DmtData( str ) );
+}
+
+ /**
+ * Sets value of the node with type "integer".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nValue [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::SetIntValue( INT32 nValue )
+{
+ return SetValue( DmtData( nValue ) );
+}
+
+ /**
+ * Sets value of the node with type "boolean".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bValue [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::SetBooleanValue( BOOLEAN bValue )
+{
+ return SetValue( DmtData( bValue ) );
+}
+
+
+ /**
+ * Sets value of the node with type "float".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sFloat [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::SetFloatValue( CPCHAR sFloat )
+{
+ return SetValue( DmtData( sFloat, SYNCML_DM_DATAFORMAT_FLOAT ) );
+}
+
+ /**
+ * Sets value of the node with type "date".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sDate [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::SetDateValue( CPCHAR sDate )
+{
+ return SetValue( DmtData( sDate, SYNCML_DM_DATAFORMAT_DATE ) );
+}
+
+ /**
+ * Sets value of the node with type "time".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sTime [in] - the value that should be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+
+inline SYNCML_DM_RET_STATUS_T DmtNode::SetTimeValue( CPCHAR sTime )
+{
+ return SetValue( DmtData( sTime, SYNCML_DM_DATAFORMAT_TIME ) );
+}
+
+ /**
+ * Sets value of the node with type "binary".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bin [in] - binary blob that should be set
+ * \param len [in] - length of the parameter "bin"
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+inline SYNCML_DM_RET_STATUS_T DmtNode::SetBinaryValue( const UINT8 * bin, INT32 len )
+{
+ return SetValue( DmtData( bin, len ) );
+}
+
+#endif
diff --git a/engine/dmlib/api/native/dmtNotification.hpp b/engine/dmlib/api/native/dmtNotification.hpp
new file mode 100644
index 0000000..c088bf5
--- /dev/null
+++ b/engine/dmlib/api/native/dmtNotification.hpp
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTNOTIFICATION_H__
+#define __DMTNOTIFICATION_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtNotification.hpp
+ \brief The dmtNotification.hpp header file contains DmtNotification class definition.
+ This class processes and parses "package0" information that is coming from server.
+ <b>Warning:</b> All functions, structures, and classes from this header file are for internal usage only!!!
+*/
+
+#include "jem_defs.hpp"
+#include "dmtDefs.h"
+
+/**
+ * This class processes and parses <i>"package0"</i> information that is coming from a server.
+ * All parsed data will be stored.
+ * \par Category: General
+ * \par Persistence: Transient
+ * \par Security: Non-Secure
+ * \par Migration State: FINAL
+ */
+class DmtNotification
+{
+private:
+ UINT8 m_nUIMode;
+ UINT8 m_nInitiator;
+ UINT16 m_nSessionID;
+ DMString m_sServerID;
+ BOOLEAN m_bAuthFlag;
+
+public:
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+
+ DmtNotification()
+ {
+ m_nSessionID = 0;
+ m_nUIMode = 0;
+ m_nInitiator = 0;;
+ }
+
+
+ /**
+ * Retrieves session ID
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return session ID as unsigned short.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ UINT16 getSessionID() const
+ {
+ return m_nSessionID;
+ }
+
+ /**
+ * Retrieves UI mode
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return UI mode as unsigned byte.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ UINT8 getUIMode() const
+ {
+ return m_nUIMode;
+ }
+
+
+ /**
+ * Retrieves initiator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return session initiator as unsigned byte.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ UINT8 getInitiator() const
+ {
+ return m_nInitiator;
+ }
+
+
+ /**
+ * Retrieves authentication flag
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return authentication flag as a boolean.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN getAuthFlag() const
+ {
+ return m_bAuthFlag;
+ }
+
+
+ /**
+ * Retrieves server ID
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return server ID as a string.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const DMString& getServerID() const
+ {
+ return m_sServerID;
+ }
+
+/**
+ * Sets value for session ID
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sessionID [in] - session ID as an unsigned integer
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void setSessionID(UINT16 sessionID)
+ {
+ m_nSessionID = sessionID;
+ }
+
+
+/**
+ * Sets UI mode value
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param uiMode [in] - UI Mode as an unsigned integer
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void setUIMode(UINT8 uiMode)
+ {
+ m_nUIMode = uiMode;
+ }
+
+
+/**
+ * Sets Session initiator ID
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param initiator [in] - session initiator as an unsigned integer
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void setInitiator(UINT8 initiator)
+ {
+ m_nInitiator = initiator;
+ }
+
+
+/**
+ * Sets authentication flag
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param authFlag [in] - authentication flag as a boolean
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void setAuthFlag(BOOLEAN authFlag)
+ {
+ m_bAuthFlag = authFlag;
+ }
+
+/**
+ * Sets server ID
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param serverID [in] - server ID as a string
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void setServerID(CPCHAR serverID)
+ {
+ m_sServerID = serverID;
+ }
+
+};
+
+#endif
diff --git a/engine/dmlib/api/native/dmtOverview.h b/engine/dmlib/api/native/dmtOverview.h
new file mode 100644
index 0000000..544a364
--- /dev/null
+++ b/engine/dmlib/api/native/dmtOverview.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+\mainpage DMT API Documentation
+
+\section Overview 2.0 Overview
+
+ The Device Management implementation is based on the OMA DM (Formerly called SyncML DM)
+ Standard. A core part of implementation is the Device Management Tree (DMT). Each device that
+ supports OMA DM must contain a management tree. This document describes API required for
+ access and control DMT. \n
+ Nodes are the entities which can be manipulated by management actions carried over the OMA DM protocol.
+ A node can be as small as an integer or as large and complex as a background picture or screen saver.
+
+\section IndustryStandard 3.0 Industry Standard
+
+ OMA DM (formerly SyncML DM)
+
+
+\section ExternalApiDocuments 4.0 External API Documents
+"None"
+
+\section ClassAndStructureDefinitions 5.0 C++ Class and Structure Definitions
+
+\subsection Classes 5.1 Classes
+-# DMFirmAlertVector <em>Helper class; due to gcc limitations, declaring separate class instead of typedef produces smaller binary </em>
+-# DMMap <em>Simple Collection Class without overhead of STL or QT DMMap template class is similar to Java's Hashmap </em>
+-# DMString <em>A simple String class similar to Java String and STL string with limited functionality</em>
+-# DMStringVector <em>Helper class; due to gcc limitations, declaring separate class instead of typedef produces smaller binary </em>
+-# DmtAcl <em>DMT Acl models the standard ACL attribute Acl composes of Principals associated with accessrights Principals are server identifications </em>
+-# DmtAttributes <em>DmtAttributes encapsulates all standard DMT attributes</em>
+-# DmtData <em>Encapsulates various DMT leaf node data formats </em>
+-# DmtDataChunk <em>encapsulates various methods to access External Storage Node (ESN) data</em>
+-# DmtEventData <em> represents actual updates performed on DM node</em>
+-# DmtEventSubscription <em>represents subscription on DMT update event</em>
+-# DmtFirmAlert <em>Helper class for sending repair status with ALERT 1226</em>
+-# DMFirmAlertVector <em>Helper class; due to gcc limitations, declaring separate class instead of typedef produces smaller binary</em>
+-# DmtNode <em>DMT Represents tree nodes as they are created and added to the tree. </em>
+-# DmtNotification <em>This class processes and parses "package0" information that is coming from a server </em>
+-# DmtPrincipal <em>Represents actors from the security viewpoint </em>
+-# DmtSessionProp <em>Structure with parameters for server session </em>
+-# DmtTree <em>Represents the object that carrying atomicity (when supported) and authentication functionality associated with DMT access, as well as basic node access </em>
+-# DmtTreeFactory <em>Represents a tree factory</em>
+-# DMVector <em>Simple Collection Class without overhead of STL or QT DMVector template class is similar to Java's ArrayList </em>
+-# JemBaseObject <em> Base object for any ref-counted object </em>
+-# JemSmartPtr <em>Smart pointer; works with classes derived from JemBaseObject </em>
+
+\subsection Structures 5.2 Structures
+
+Details of the structures are available from the source header files directly:
+-# DM_WlanEncoder.h
+
+
+\section CFunctionsAndDataTypes 6.0 "C" Functions and Data Types
+
+"None"
+
+\section HeaderFilesAndLibraries 7.0 Header Files And Libraries
+
+
+-# dmstring.h
+-# dmt.hpp
+-# dmtAcl.hpp
+-# dmtAttributes.hpp
+-# dmtData.hpp
+-# dmtDataChunk.hpp
+-# dmtDefs.h
+-# dmtError.h
+-# dmtErrorDescription.hpp
+-# dmtEvent.hpp
+-# dmtEventData.hpp
+-# dmtFirmAlert.hpp
+-# dmtNode.hpp
+-# dmtNotification.hpp
+-# dmtPrincipal.hpp
+-# dmtSessionProp.hpp
+-# dmtTree.hpp
+-# dmtTreeFactory.hpp
+-# dmvector.h
+-# dmVersion.h
+-# DM_WlanEncoder.h
+-# jem_defs.hpp
+-# omacp.h
+-# xpl_StringUtil.h
+-# xpl_Types.h
+
+
+\section PluginExtensionPointInterface 8.0 Plug-in Extension Point Interface
+
+\section OtherInterfaces 9.0 Other Interfaces
+
+"None"
+
+\section OtherNotes 10.0 Other Notes
+
+ - All APIs' functions are synchronous.
+
+ - All APIs are in the "Final" state and guaranteed backward compatibility.
+
+ - All APIs are not secured but protection enforced on the DMT subtree level.
+
+*/
diff --git a/engine/dmlib/api/native/dmtPrincipal.hpp b/engine/dmlib/api/native/dmtPrincipal.hpp
new file mode 100644
index 0000000..ab2392a
--- /dev/null
+++ b/engine/dmlib/api/native/dmtPrincipal.hpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTPRINCIPAL_H__
+#define __DMTPRINCIPAL_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtPrincipal.hpp
+ \brief The dmtPrincipal.hpp header file contains DmtPrincipal class definition. \n
+ This class represents actors from the security viewpoint. Every DmtTree \n
+ is associated with a DMTPrincipal, and they are also used in DmtAcl.
+*/
+
+#include "jem_defs.hpp"
+
+/**
+ * DmtPrincipal represents actors from the security viewpoint.
+ * Every DmtTree is associated with a DMTPrincipal,
+ * and they are also used in DmtAcl.
+ * \par Category: General
+ * \par Persistence: Transient
+ * \par Security: Non-Secure
+ * \par Migration State: FINAL
+ */
+class DmtPrincipal
+{
+private:
+ DMString m_strPrincipal;
+
+public:
+ /**
+ * Default constructor - no memory allocation or any other resources have been performed.
+ */
+ DmtPrincipal() {}
+
+/**
+ * Constructor receive object DmtPrincipal as a parameter. The memory for DMT Principal name will be allocated.
+ * \param oCopyFrom [in] - reference to DmtPrincipal object
+ */
+ DmtPrincipal( const DmtPrincipal& oCopyFrom ) {m_strPrincipal = oCopyFrom.m_strPrincipal; }
+
+ /**
+ * Constructor receive DmtPrincipal name as a parameter. The memory for DMT Principal name will be allocated.
+ * \param princip [in] - DMT principal as a string
+ */
+ DmtPrincipal(CPCHAR princip) {m_strPrincipal = princip;}
+
+ /**
+ * Comparison operator (equally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param p [in] - pointer to DmtPrincipal object
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ BOOLEAN operator==( const DmtPrincipal &p ) const { return m_strPrincipal == p.m_strPrincipal;}
+
+
+ /**
+ * Retrieves name of DMT principle
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return principal as ad DMString.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const DMString& getName() const
+ {
+ return m_strPrincipal;
+ }
+
+ /**
+ * Assigns DMT principle to the Provided string
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param princip [in] - principal as a string
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void assign(CPCHAR princip) {m_strPrincipal = princip;}
+
+};
+
+#endif
diff --git a/engine/dmlib/api/native/dmtSessionProp.hpp b/engine/dmlib/api/native/dmtSessionProp.hpp
new file mode 100644
index 0000000..f4b31a9
--- /dev/null
+++ b/engine/dmlib/api/native/dmtSessionProp.hpp
@@ -0,0 +1,273 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTSESSIONPROP_H__
+#define __DMTSESSIONPROP_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtSessionProp.hpp
+ \brief Contains DMFirmAlertVector and DmtSessionProp classes definition.\n
+ The dmtSessionProp.hpp header file contains DMFirmAlertVector and DmtSessionProp\n
+ classes definition. \n
+ <b>Warning:</b> All functions, structures, and classes from this header file are for internal usage only!!!\n
+
+ The <b>DMFirmAlertVector</b> is a helper class; due to gcc limitations, declaring separate \n
+ class instead of typedef produces smaller binary.\n
+ The <b>DmtSessionProp</b> is a structure with parameters for server session
+*/
+
+#include "jem_defs.hpp"
+#include "dmtDefs.h"
+#include "dmtFirmAlert.hpp"
+#include "dmvector.h"
+
+/**
+* Helper class; due to gcc limitations, declaring separate class instead of typedef
+* produces smaller binary
+* \warning This class is using <b>ONLY</b> for firmware update session!
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DMFirmAlertVector : public DMVector<DmtFirmAlert>
+{
+};
+
+
+/**
+* This class is a structure with parameters for the server session
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtSessionProp
+{
+private:
+ UINT16 m_nSessionID; // session ID
+ SYNCML_DM_SESSION_DIRECTION_T m_nDirection; // session direction
+ BOOLEAN m_bWBXML;
+
+ DMFirmAlertVector m_aFirmAlerts; // result of firmware update
+
+
+public:
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+
+ DmtSessionProp()
+ {
+ m_nSessionID = 0;
+ m_nDirection = SYNCML_DM_CLIENT_INITIATED_SESSION;
+ m_bWBXML = true;
+ }
+
+ /**
+ * Constructs (copy) a DMT Session Property object. The memory for this object will be allocated.
+ * \param oCopyFrom [in] - session property that should be copied
+ */
+ DmtSessionProp( const DmtSessionProp& oCopyFrom )
+ {
+ m_nSessionID = oCopyFrom.m_nSessionID;
+ m_nDirection = oCopyFrom.m_nDirection;
+ m_bWBXML = oCopyFrom.m_bWBXML;
+ if ( oCopyFrom.m_aFirmAlerts.size() )
+ m_aFirmAlerts = oCopyFrom.m_aFirmAlerts;
+ }
+
+ /**
+ * Constructs required fields for server initiated session. The memory for these fields will be allocated.
+ * \param sessionID [in] - provided by Syncml DM server in a notification package
+ * \param bWBXML [in] - true to use binary xml
+ */
+ DmtSessionProp(UINT16 sessionID, BOOLEAN bWBXML)
+ {
+ m_nSessionID = sessionID;
+ m_nDirection = SYNCML_DM_SERVER_INITIATED_SESSION;
+ m_bWBXML = bWBXML;
+ }
+
+ /**
+ * Constructs session property - no memory allocation performed.
+ * \param bWBXML [in] -true to use binary xml
+ */
+ DmtSessionProp(BOOLEAN bWBXML)
+ {
+ m_nSessionID = 0;
+ m_nDirection = SYNCML_DM_CLIENT_INITIATED_SESSION;
+ m_bWBXML = bWBXML;
+ }
+
+
+ /**
+ * Constructs session property for firmware.
+ * \param aFirmAlert [in] - firm alert to send to the Syncml DM server
+ * \param bWBXML [in] - true to use binary xml
+ */
+ DmtSessionProp(const DmtFirmAlert & aFirmAlert, BOOLEAN bWBXML)
+ {
+ m_nSessionID = 0;
+ m_nDirection = SYNCML_DM_CLIENT_INITIATED_SESSION;
+ m_bWBXML = bWBXML;
+ m_aFirmAlerts.push_back(aFirmAlert);
+ }
+
+ /**
+ * Retrieves session ID
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \returns session ID as an unsigned short.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ UINT16 getSessionID() const
+ {
+ return m_nSessionID;
+ }
+
+ /**
+ * Retrieves direction
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \returns session direction as an unsigned short.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ SYNCML_DM_SESSION_DIRECTION_T getDirection() const
+ {
+ return m_nDirection;
+ }
+
+ /**
+ * Sets session ID
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param sessionID [in] - session ID as an unsigned short.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void setSessionID(UINT16 sessionID)
+ {
+ m_nSessionID = sessionID;
+ m_nDirection = SYNCML_DM_SERVER_INITIATED_SESSION;
+ }
+
+ /**
+ * Sets session direction
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param direction [in] - session direction as an unsigned short.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void setDirection(SYNCML_DM_SESSION_DIRECTION_T direction)
+ {
+ m_nDirection = direction;
+ }
+
+/**
+ * Generates session ID
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void generateSessionID();
+
+ /**
+ * Sets session binary XML flag
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bWBXML [in] - true to use binary xml
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+
+ void setWBXML(BOOLEAN bWBXML)
+ {
+ m_bWBXML = bWBXML;
+ }
+
+ /**
+ * Retrieves binary XML flag
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \returns binary XML flag as a boolean.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ BOOLEAN isWBXML() const
+ {
+ return m_bWBXML;
+ }
+
+
+ /**
+ * Retrieves firmware alert
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param aFirmAlert [out] - firmware update result code in DMFirmAlertVector.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ void getFirmAlerts(DMFirmAlertVector & aFirmAlert)
+ {
+ aFirmAlert = m_aFirmAlerts;
+ }
+
+
+ /**
+ * Adds firmware update result
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param aFirmAlert [in] - reference to a DmtFirmAlert object
+ * \return index
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ INT32 addFirmAlert(const DmtFirmAlert & aFirmAlert)
+ {
+ m_aFirmAlerts.push_back(aFirmAlert);
+ return m_aFirmAlerts.size();
+ }
+
+};
+
+#endif
diff --git a/engine/dmlib/api/native/dmtTree.hpp b/engine/dmlib/api/native/dmtTree.hpp
new file mode 100644
index 0000000..203b9f5
--- /dev/null
+++ b/engine/dmlib/api/native/dmtTree.hpp
@@ -0,0 +1,498 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTTREE_H__
+#define __DMTTREE_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtTree.hpp
+ \brief The dmtTree.hpp header file contains DmtTree class definition. <br>
+ DmtTree is the object carrying atomicity (when supported) and<br>
+ authentication functionality associated with DMT access, as well<br>
+ as basic node access.
+*/
+
+#include "jem_defs.hpp"
+
+#include "dmt.hpp"
+
+
+/**
+DmtTree is the object carrying atomicity (when supported) and
+authentication functionality associated with DMT access, as well
+as basic node access. The object is obtained from the static create()
+method of the DmtTree's implementation class.
+Almost all methods return a smart pointer to the
+error description object if failed, NULL if succeeded
+
+\par Category: General
+
+\par Persistence: Transient
+
+\par Security: Non-Secure
+
+\par Migration State: FINAL
+
+
+\par Creating DmtTree object
+
+The factory class DmtTreeFactory is used to create a tree object. \n
+Alternatively, a sub-tree can be created using the GetSubTree method
+ to minimize blocking.
+
+\par Release DmtTree object
+
+ DmtTree is a smart-pointer. Smart-pointers are used in the DMT API to
+ return references to DmtTree, DmtNode and DmtErrorDescription. Usually you
+ can treat it as a normal pointer to a class, but in fact, it’s a small class
+ which takes care of the object’s life time. Here are some simple rules for
+working with smart pointers:\n\n
+
+ - warning never call delete on a smart pointer\n
+ - warning assign NULL to a smart pointer as soon as you don’t need the object anymore \n\n
+
+ After you have got a hold of a DmtTree object, you can access its child nodes and
+ read and modify them as desired. However it is important to release the object by
+assigning NULL to it after you have finished “get” operations, i.e. read only type of
+ operations. In case you have done “set” operations, i.e. write type of operations, a
+ call to Flush() will “commit” the change and release the lock on the tree. \n
+ Remember to:\n
+ - release (assign NULL) after read\n
+ - call Flush() after write\n
+
+ \par Example using DMT functions
+
+ \code
+ DmtPrincipal principal("localhost");
+ PDmtTree ptrTree;
+ SYNCML_DM_RET_STATUS_T ret_status;
+
+ if ( (ret_status = DmtFactory::GetTree(principal, ptrTree ) ) != SYNCML_DM_SUCCESS )
+ {
+ ... error handling
+ return;
+ }
+
+ PDmtNode ptrNode;
+
+ if ( (ret_status = ptrTree->GetNode( "./SyncML/DMAcc/GUID/AddrType", ptrNode ) ) != SYNCML_DM_SUCCESS )
+ {
+ ... error handling
+ return;
+ }
+
+ std::string str;
+ if ( (ret_status = ptrNode->GetStringValue( str )) != SYNCML_DM_SUCCESS )
+ {
+ ... error handling
+ return;
+ }
+
+ printf( "String value is %`s\n", str.c_str() );
+ \endcode
+
+*/
+
+
+class DmtTree : public JemBaseObject
+{
+protected:
+/** Destructor - freeing all dynamic resources */
+ virtual ~DmtTree(){}
+
+public:
+ /**
+ * Locates and return node by specified path.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - full path to the node
+ * \param ptrNode [out] - result node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetNode(CPCHAR path, PDmtNode& ptrNode )=0;
+
+ /**
+ * Deletes a node according to the specified path
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - full path to the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ * \par Example of how DeleteNode() function would be called
+ *
+ * \code
+ * PDmtTree ptrTree;
+ * SYNCML_DM_RET_STATUS_T ret_status;
+ * if ( (ret_status=DmtTreeFactory::GetSubtree(principal, "./SyncML/DMAcc”, ptrTree))!=SYNCML_DM_SUCCESS ){
+ * ... error processing here
+ * return;
+ * }
+ * if ( (ret_status=ptrTree->DeleteNode( "TEST" ) ) != SYNCML_DM_SUCCESS) {
+ * ... error
+ * return;
+ * }
+ * \endcode
+ */
+ virtual SYNCML_DM_RET_STATUS_T DeleteNode(CPCHAR path )=0;
+
+
+ /**
+ * Creates a sibling of the node specified by its URI "path".
+ * This new node's name is user-specified as "szNewNodename".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - URI of node to be cloned.
+ * \param szNewNodename [in] - new node name as specified by user.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Clone(CPCHAR path, CPCHAR szNewNodename) = 0;
+
+
+ /**
+ * Changes node's name. For example: RenameNode( "./SyncML/DMAcc/Test", "NewTest" );
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param szNewNodeName [in] - new node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T RenameNode(CPCHAR path, CPCHAR szNewNodeName ) = 0;
+
+ /**
+ * Creates a leaf node in the tree.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \param value [in] - data value DmtData type
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ * \par Example of how this function would be called
+ *
+ * \code
+ * DmtPrincipal principal("localhost");
+ * PDmtTree ptrTree;
+ * SYNCML_DM_RET_STATUS_T ret_status;
+ *
+ * if ( (ret_status = DmtFactory::GetTree(principal, ptrTree ) ) != SYNCML_DM_SUCCESS )
+ * {
+ * ... error handling
+ * return;
+ * }
+ * PDmtNode ptrNode;
+ * if ( (ret_status =ptrTree->CreateLeafNode( "./SyncML/DMAcc/TESTLeaf", ptrNode, DmtData(123) ) ) != SYNCML_DM_SUCCESS) ){
+ * … error handling
+ * return;
+ * }
+ * if ( (ret_statu= ptrTree->Flush() SYNCML_DM_SUCCESS) ){
+ * .... error processing here …
+ * }
+ * \endcode
+ *
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode(CPCHAR path, PDmtNode& ptrCreatedNode, const DmtData& value )=0;
+
+ /**
+ * Creates a External Storage leaf node in the tree.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \param value [in] - data value DmtData type
+ * \param isESN [in] - flag to indicate that it is External Storage Node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ *
+ * \code
+ * DmtPrincipal principal("localhost");
+ * PDmtTree ptrTree;
+ * SYNCML_DM_RET_STATUS_T ret_status;
+ *
+ * if ( (ret_status = DmtFactory::GetTree(principal, ptrTree ) ) != SYNCML_DM_SUCCESS )
+ * {
+ * ... error handling
+ * return;
+ * }
+ * PDmtNode ptrNode;
+ * if ( (ret_status =ptrTree->CreateLeafNode( "./SyncML/DMAcc/TESTLeaf", ptrNode, DmtData(123), TRUE ) ) != SYNCML_DM_SUCCESS) ){
+ * … error handling
+ * return;
+ * }
+ * if ( (ret_statu= ptrTree->Flush() SYNCML_DM_SUCCESS) ){
+ * .... error processing here …
+ * }
+ * \endcode
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode(CPCHAR path, PDmtNode& ptrCreatedNode, const DmtData& value , BOOLEAN isESN)=0;
+
+ /**
+ * Creates an interior node in the tree.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ *
+ * \par Example of how this function would be called
+ *
+ * \code
+ * DmtPrincipal principal("localhost");
+ * PDmtTree ptrTree;
+ * SYNCML_DM_RET_STATUS_T ret_status;
+ *
+ * if ( (ret_status = DmtFactory::GetTree(principal, ptrTree ) ) != SYNCML_DM_SUCCESS )
+ * {
+ * ... error handling
+ * return;
+ * }
+ * PDmtNode ptrNode;
+ * if ( ((ret_status =ptrTree->CreateInteriorNode( "./SyncML/DMAcc/TEST", ptrNode ) ) != SYNCML_DM_SUCCESS) {
+ * ... error handling
+ * return;
+ * }
+ * if ( (ret_statu= ptrTree->Flush() SYNCML_DM_SUCCESS) ){
+ * .... error processing here …
+ * }
+ * \endcode
+ *
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateInteriorNode(CPCHAR path, PDmtNode& ptrCreatedNode )=0;
+
+ /**
+ * This is a helper method. It returns a table of all leaf nodes for the current node.
+ * The table key is the child node name, and value is the string node value. It sets leaf nodes only
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param mapNodes [out] - map with leaf nodes only
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ *
+ * \par Example of how GetChildValuesMap() function would be called
+ *
+ * \code
+ * PDmtTree ptrTree;
+ * PDmtNode ptrNode;
+ * DMString strDefaultProfile;
+ * SYNCML_DM_RET_STATUS_T ret_status;
+ * .... initialisation ptrTree and ptrNode...
+ *
+ * if ( (ret_status=ptrNode->GetStringValue(strDefaultProfile) ) != SYNCML_DM_SUCCESS) {
+ * ... error
+ * return;
+ *}
+ * DMString strProfileURI = “Profiles/”;
+ * strProfileURI += strDefaultProfile;
+ * DMMap<DMString, DmtData> map;
+ * if ( (ret_status=ptrTree-> GetChildValuesMap (strProfileURI, map ))!=SYNCML_DM_SUCCESS ){
+ * ...error
+ * return;
+ * }
+ * \endcode
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetChildValuesMap(CPCHAR path, DMMap<DMString, DmtData>& mapNodes ) = 0;
+
+
+ /**
+ * This is a helper method. It deletes all leaf nodes and creates new ones, provided in the map. The table key is the child node name, and value is the node value.
+ * It changes leaf nodes only
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param mapNodes [in] - map with leaf nodes only
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ *
+ * \par Example of how GetChildValuesMap() function would be called
+ *
+ * \code
+ * ... all init the same as with GetChildValuesMap() function...
+ * if ( (ret_status=ptrTree-> SetChildValuesMap (strProfileURI, map ))!=SYNCML_DM_SUCCESS ){
+ * ...error
+ * return;
+ * }
+ * \endcode
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetChildValuesMap(CPCHAR path, const DMMap<DMString, DmtData>& mapNodes ) = 0;
+
+ /**
+ * This is a helper method. It sets an array of all child node names for the current node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param mapNodes [out] - map with leaf nodes only
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetChildNodeNames(CPCHAR path, DMStringVector& mapNodes ) = 0;
+
+ /**
+ * Flush all changes to the persistent layer and check the constrains.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Flush()=0;
+
+ /**
+ * Commits a series of atomic operations.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Commit()=0;
+
+ /**
+ * Rollbacks a series of atomic operations
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Rollback()=0;
+
+ /**
+ * Begins an atomic operation that will end with commit() or rollback();
+ * \warning An error code will be returned if a transaction is running already.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Begin()=0;
+
+ /**
+ * Checks for atomicity.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return 'true' if the begin() was invoked, but no commit() or rollback().
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual BOOLEAN IsAtomic() const =0;
+
+ /**
+ * Retrieves a principal
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return the DmtPrincipal object that the session was created with.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual DmtPrincipal GetPrincipal() const =0;
+
+ /**
+ * Function checks if specified path is "gettable" in the context of current tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to a node
+ * \return "true" if corresponding call GetNode is successful, otherwise "false"
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ inline BOOLEAN IsValidNode ( const char* path ) {
+ PDmtNode ptrNode;
+ return (GetNode( path, ptrNode ) == SYNCML_DM_SUCCESS ? TRUE : FALSE) ;
+ }
+};
+
+#endif
diff --git a/engine/dmlib/api/native/dmtTreeFactory.hpp b/engine/dmlib/api/native/dmtTreeFactory.hpp
new file mode 100644
index 0000000..dfac804
--- /dev/null
+++ b/engine/dmlib/api/native/dmtTreeFactory.hpp
@@ -0,0 +1,451 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTTREEFACTORY_H__
+#define __DMTTREEFACTORY_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtTreeFactory.hpp
+ \brief The dmtTreeFactory.hpp header file contains DmtTreeFactory class definition. \n
+ This class represents a tree factory. It is used to create a DmtTree from a given Principal.
+*/
+
+#include "jem_defs.hpp"
+#include "dmtPrincipal.hpp"
+#include "dmtNotification.hpp"
+#include "dmtSessionProp.hpp"
+#include "dmtEvent.hpp"
+#include "dmtEventData.hpp"
+
+/**
+* DmtTreeFactory represents a tree factory.
+* It is used to create a DmtTree from a given Principal.
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtTreeFactory
+{
+ public:
+/**
+* Enumaration that presents Device management tree lock types.
+*/
+ enum
+ {
+ /** Lock type "Shared"*/
+ LOCK_TYPE_SHARED = SYNCML_DM_LOCK_TYPE_SHARED,
+ /** Lock type "Exclusive"*/
+ LOCK_TYPE_EXCLUSIVE = SYNCML_DM_LOCK_TYPE_EXCLUSIVE,
+ /** Lock type "Automatic"*/
+ LOCK_TYPE_AUTOMATIC = SYNCML_DM_LOCK_TYPE_AUTOMATIC
+ };
+
+
+ /**
+ * Initialization - calls this function prior any other function.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return result as BOOLTYPE
+ * - true - indicates success and Dmt functions are ready to be called. \n
+ * - false - indicates failure and no more Dmt functions can be called. \n
+ * typical cause of failure is due to invalid Dmt root file path from "dm_setting_root" environment variable.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings.
+ */
+ static BOOLTYPE Initialize();
+
+
+ /**
+ * Clean up resources.
+ * \par Important Notes:
+ * - Note: no one Dmt function can be called after clean up.
+ * - Note: all tree and node handles should be released prior Uninitialized call
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T Uninitialize();
+
+ /**
+ * Gets a logic DmtTree for a given principal.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DMT principal
+ * \param ptrTree [out] - pointer to DMT
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * Make sure Initialize() function is called successfully prior to calling this function.
+ * \par Example of how this function would be called
+ *
+ * \code
+ * DmtPrincipal principal("localhost");
+ * PDmtTree ptrTree;
+ * SYNCML_DM_RET_STATUS_T ret_status;
+ *
+ * if ( (ret_status = DmtFactory::GetTree(principal, ptrTree ) ) != SYNCML_DM_SUCCESS )
+ * {
+ * ... error handling
+ * return;
+ * }
+ *
+ * \endcode
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T GetTree(const DmtPrincipal& principal,
+ PDmtTree& ptrTree);
+
+ /**
+ * Gets a logic part of DmtTree for a given principal; This tree
+ * object gives access only to subtree located by path.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DMT principal
+ * \param szSubtreeRoot [in] - sub tree root name
+ * \param ptrTree [out] - pointer to sub tree
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * Make sure Initialize() function is called successfully prior to calling this function. \n
+ * This function will return error for invalid subtree path.
+ *
+ * \par Example of how GetSubtree() function would be called
+ *
+ * \code
+ * DmtPrincipal principal("localhost");
+ * PDmtTree ptrTree;
+ * SYNCML_DM_RET_STATUS_T ret_status;
+ * if ( (ret_status =DmtTreeFactory::GetSubtree(principal, "./SyncML/DMAcc”, ptrTree))!=SYNCML_DM_SUCCESS ){
+ * ... error processing here
+ * return;
+ * }
+ * \endcode
+ *
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T GetSubtree(const DmtPrincipal& principal,
+ CPCHAR szSubtreeRoot,
+ PDmtTree& ptrTree);
+
+ /**
+ * Gets a logic part of DmtTree for a given principal
+ * This tree object gives access only to subtree located by path.
+ * All path access to subtree should be NOT have "./" or "/" before the path !
+ * Additional parameter lockType allows to specify desired access to the tree.
+ * If lockType is "shared" tree is read-only and any "Set" function will throw an exception.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DMT principal
+ * \param szSubtreeRoot [in] - sub tree root name
+ * \param nLockType [in] - tree lock type
+ * \param ptrTree [out] - pointer to sub tree
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * Make sure Initialize() function is called successfully prior to calling this function. \n
+ * This function will return error for invalid subtree path.
+ *
+ * \par Example of how GetSubtreeEx() function would be called
+ *
+ * \code
+ * DmtPrincipal principal("localhost");
+ * PDmtTree ptrTree;
+ * SYNCML_DM_RET_STATUS_T ret_status;
+ * if ( (ret_status =DmtTreeFactory::GetSubtree(principal, "./SyncML/DMAcc”, DmtTreeFactory::LOCK_TYPE_EXCLUSIVE, ptrTree))!=SYNCML_DM_SUCCESS ){
+ * ... error processing here
+ * return;
+ * }
+ * \endcode
+ *
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T GetSubtreeEx(const DmtPrincipal& principal,
+ CPCHAR szSubtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType,
+ PDmtTree& ptrTree);
+
+ /**
+ * Reads SyncML scripts from the InputStream then process to the tree
+ * \warning This functions is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DMT principal
+ * \param buf [in] - input stream
+ * \param len [in] - length of the input stream
+ * \param isWBXML [in] - flag to use binary xml
+ * \param oResult [out] - string with error description
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ *
+ * \par Example of how ProcessScript() function would be called
+ *
+ * \code
+ * const char* szFile = <path to file>;
+ * DmtPrincipal principal ("localhost");
+ * DMString oResult;
+ * char* szBuf = <script>
+ * int n = <size of 'script'>
+ * SYNCML_DM_RET_STATUS_T res = DmtTreeFactory::ProcessScript( principal , (const byte*)szBuf, n, false, oResult);
+ * \endcode
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ static SYNCML_DM_RET_STATUS_T ProcessScript(const DmtPrincipal& principal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ DMString& oResult);
+
+ /**
+ * Reads SyncML scripts from the InputStream then process to the tree and set the result
+ * in binary format.
+ * \warning This functions is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - DMT principal
+ * \param buf [in] - input stream
+ * \param len [in] - length of the input stream
+ * \param isWBXML [in] - to use binary xml
+ * \param oResult [out] - DMVector<UINT8> with error code
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * - All other codes indicates failure. The description can be found in the dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ static SYNCML_DM_RET_STATUS_T ProcessScript(const DmtPrincipal& principal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ DMVector<UINT8> & oResult);
+
+
+ /**
+ * Starts communication with Syncml DM server
+ * \warning This functions is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - Syncml DM server ID
+ * \param sessionProp [in] - additional session parameters
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ *
+ * \par Example of how StartServerSession() function would be called
+ *
+ * \code
+ * DmtSessionProp oClInitiated( true );
+ * DmtPrincipal principal(“ServerID”);
+ * SYNCML_DM_RET_STATUS_T ret_status;
+ *
+ * if ( (ret_status=DmtTreeFactory::StartServerSession(principal, oClInitiated )) == SYNCML_DM_SUCCESS )
+ * .....OK
+ * else
+ * .....Error
+ * );
+ * \endcode
+ *
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T StartServerSession(const DmtPrincipal& principal,
+ const DmtSessionProp& sessionProp);
+
+ /**
+ * Notification for the DMT
+ * \warning This functions is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - Syncml DM server ID
+ * \param buf [in] - input stream
+ * \param len [in] - length of the input stream
+ * \param notification [out] - string with a notification
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T ProcessNotification(const DmtPrincipal& principal,
+ const UINT8 *buf,
+ INT32 len,
+ DmtNotification & notification);
+
+
+ /**
+ * Notification for the process
+ * \warning This functions is for internal usage only!!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param principal [in] - Syncml DM server ID
+ * \param buf [in] - input stream
+ * \param len [in] - length of the input stream
+ * \param isWBXML [in] - to use binary xml
+ * \param isProcess [in] - flag to process script
+ * \param serverID [out] - reference to string with server ID
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation has completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T Bootstrap(const DmtPrincipal& principal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMString & serverID);
+
+
+ /**
+ * Checks if DMT is locked
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return "true" if locked
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ static BOOLEAN IsLocked();
+
+
+ /**
+ * Check if OTA DM session is in progress
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return "true" if session is started
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ static BOOLEAN IsSessionInProgress();
+
+
+ /**
+ * Subscribes on DMT update event (tells DM engine to track updates on specific node or sub tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szPath [in] - node path
+ * \param oEvent [in] - event subscription
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
+ * - All other codes indicate failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T SubscribeEvent(CPCHAR szPath,
+ const DmtEventSubscription & oEvent);
+
+ /**
+ * Unsubscribes from DMT update event (tells DM engine to stop tracking updates on specific node or sub tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szPath [in] - node path
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
+ * - All other codes indicate failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T UnSubscribeEvent(CPCHAR szPath);
+
+ /**
+ * Retrieves event subscription for specific path
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szPath [in] - node path
+ * \param oEvent [out] - event subscription
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
+ * - All other codes indicate failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ static SYNCML_DM_RET_STATUS_T GetEventSubscription(CPCHAR szPath,
+ DmtEventSubscription & oEvent);
+
+
+ /**
+ * Parses data received by application about DMT update on sub tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param pBuffer [in] - pointer on a data buffer
+ * \param size [in] - size of a buffer
+ * \param aEventMap [out] - map of events for sub tree
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully. \n
+ * - All other codes indicate failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ static SYNCML_DM_RET_STATUS_T ParseUpdateEvent(UINT8 * pBuffer,
+ UINT32 size,
+ DmtEventMap & aEventMap);
+
+
+
+
+};
+
+#endif
diff --git a/engine/dmlib/api/native/dmvector.h b/engine/dmlib/api/native/dmvector.h
new file mode 100644
index 0000000..75163ab
--- /dev/null
+++ b/engine/dmlib/api/native/dmvector.h
@@ -0,0 +1,953 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMVECTOR_H__
+#define __DMVECTOR_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmvector.h
+ \brief Contains DMVector and DMMap template classes definition
+
+ The dmvector.hpp header file contains DMVector and DMMap template classes definition. \n
+ <b>DMVector</b> template class is simple Collection Class without overhead of STL or QT\n
+ and id similar to Java's ArrayList\n
+ <b>DMMap</b> template class is simple Collection Class without overhead of STL or QT\n
+ DMMap template class is similar to Java's HashMap. Potentially can be slow, especially with \n
+ large number of keys, since linear search is used.
+*/
+
+#include <string.h>
+#include "dmstring.h"
+#include <new>
+
+#ifdef PLATFORM_X86
+#include <assert.h>
+/** Definition for DMASSERT for platform compatibility*/
+#define DMASSERT(expression) assert(expression)
+#else
+/** Definition for DMASSERT for platform compatibility*/
+#define DMASSERT(expression)
+#endif
+
+ /**
+ * Memory allocation routine. Used for debugging.
+ * \warning This method for internal usage only!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Migration State: FINAL
+ * \param nSize [in] - buffer size as an integer
+ * \param szFile [in] - file name
+ * \param nLine [in] - line number
+ * \return void pointer or null if no memory available
+ * \par Prospective Clients:
+ * For internal usage only
+ */
+extern "C" void* DmtMemAllocEx( size_t nSize, const char* szFile, int nLine );
+
+/**
+ * Memory deallocation routine
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Migration State: FINAL
+ * \param p [in] - pointer to memory that should be freed
+ * \par Prospective Clients:
+ * For internal usage only
+ */
+extern "C" void DmtMemFree( void* p );
+
+/**
+ * Memory allocation macro.
+ * \warning This method for internal usage only!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Migration State: FINAL
+ * \param size buffer size as an integer
+ * \par Prospective Clients:
+ * For internal usage only
+ */
+#define DmtMemAlloc(size) DmtMemAllocEx(size,__FILE__,__LINE__)
+
+
+/**
+* Simple Collection Class without overhead of STL or QT
+* DMVector template class is similar to Java's ArrayList
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+template<class type>
+class DMVector
+{
+ public:
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DMVector();
+
+ /**
+ * Construct a DMVector object as copy of a given one as a parameter. The memory for the size of parameter "oCopyFrom" will be allocated.
+ * \param oCopyFrom [in] - pointer to the DMVector that should be copied.
+ */
+ DMVector( const DMVector& oCopyFrom );
+
+ /* *
+ * Destructor - freeing all dynamic resources
+ */
+ ~DMVector();
+
+ /*
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str [in] - constant reference to DMVector
+ * \return reference to the DMVector object (itself)
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ DMVector& operator = ( const DMVector& oCopyFrom );
+
+ /**
+ * Retrieve number of elements in the vector
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return number of elements
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int size() const { return m_nCount; }
+
+ /*
+ * Sets size of the vector
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return number of elements
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int set_size( int nNewSize );
+
+ /**
+ * Appends a new element to array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - new element to add
+ * \return index of a new element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int push_back(const type& ptr);
+
+ /**
+ * Removes element from array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param index - element index; must be valid index.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void remove(int index);
+
+ /**
+ * Looks for an element in array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - reference to element
+ * \return index of an element if found, otherwise (-1) .
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int find(const type& ptr) const;
+
+
+ /**
+ * Detaches element.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to allocated element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ type* detach();
+
+ /**
+ * Const version of [] operator; allows to access any const method of element without making a copy of it.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nIndex [in] - element index
+ * \return element of a vector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const type& operator [] (int nIndex ) const;
+
+ /**
+ * Non const version of [] operator; allows to access any method of element without making a copy of it and assign a new value.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nIndex [in] - element index
+ * \return element of a vector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ type& operator [] (int nIndex );
+
+ /**
+ * Retrieves element
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to the element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ type* get_data() {return m_ptrs;}
+
+ /**
+ * Retrieves element
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return constant pointer to element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const type* get_data() const {return m_ptrs;}
+
+ /**
+ * Erases all elements from the collection
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void clear() {set_size(0);}
+
+
+private:
+ // helper functions
+ int Reallocate( int nNewSize );
+ void Destroy() {set_size(0);}
+
+ void DestructElement( int nIndex );
+ void ConstructElement( int nIndex );
+
+ int m_nAllocated, m_nCount;
+ type * m_ptrs;
+};
+
+
+/**
+* Simples Collection Class without overhead of STL or QT
+* DMMap template class is similar to Java's HashMap
+* Potentially can be slow, especially with large number of keys,
+* since linear search is used.
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+template<class Key, class Value>
+class DMMap
+{
+ public:
+/** Definition for position in DMMap*/
+ typedef int POS;
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DMMap();
+
+ /* *
+ * Destructor - freeing all dynamic resources
+ */
+ ~DMMap();
+
+/**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oCopyFrom [in] - constant reference to DMMap
+ * \return reference to the DMMap object (itself)
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ DMMap& operator = ( const DMMap& oCopyFrom );
+
+ /**
+ * Retrieves number of elements in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return number of elements
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int size() const;
+
+ /**
+ * Looks up for the element for the given key. Set value if an element has been found.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \param rValue [out] -element value
+ * \return "true" if element has been found otherwise - "false"
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ bool lookup( const Key & key, Value& rValue) const;
+
+/**
+ * Retrieves a value based on key. The key must exist in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] - element key
+ * \return constant value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const Value& get(const Key & key) const;
+
+ /**
+ * Retrieves a value based on key. The key must exist in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] - element key
+ * \return value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ Value& get(const Key & key);
+
+ /**
+ * Adds or replaces value for the given key.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \param value [in] -element value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void put(const Key & key, const Value & value);
+
+ /**
+ * Removes element for the given key
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \return "true" in case of success, otherwise - "false"
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ bool remove(const Key & key);
+
+ /**
+ * Erases all elements from the collection
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void clear() { m_aKeys.set_size( 0 ); m_aValues.set_size( 0);}
+
+ /**
+ * Retrieves first position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return first position; can be "end()" if map is empty
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ POS begin() const {return 0;}
+
+ /**
+ * Retrieves "end" of the map position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return "end" position
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ POS end() const {return m_aKeys.size();}
+
+ /**
+ * Returns constant value by given position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param n [in] - given position
+ * \return position value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const Value& get_value(POS n) const {return m_aValues[n];}
+
+ /**
+ * Returns value by given position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param n [in] - given position
+ * \return position value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ Value& get_value(POS n) {return m_aValues[n];}
+
+ /**
+ * Returns key for given position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param n [in] - given position
+ * \return key for the given position
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const Key& get_key(POS n) const {return m_aKeys[n];}
+
+
+ private:
+ DMVector<Key> m_aKeys;
+ DMVector<Value> m_aValues;
+};
+
+
+
+////////////////////////////////////////////////////////////
+// implementation DMVector
+//----------------------------------------------
+/**
+* Default constructor - constructs empty array. No memory alllocation is performed.
+*/
+template<class type>
+inline DMVector<type>::DMVector()
+{
+ m_nAllocated = m_nCount = 0;
+ m_ptrs = NULL;
+}
+
+ /**
+ * Copy constructor; makes exact copy of the source array. The memory for the size of parameter "oCopyFrom" will be allocated.
+ * \param oCopyFrom - source object
+ */
+template<class type>
+inline DMVector<type>::DMVector( const DMVector<type>& oCopyFrom )
+{
+ m_nCount = 0;
+ m_ptrs = NULL;
+
+ *this = oCopyFrom;
+}
+
+ /**
+ * Destructor - freeing all dynamic resources
+ */
+template<class type>
+inline DMVector<type>::~DMVector()
+{
+ Destroy();
+}
+
+ /**
+ * Const version of [] operator; allows to access any const method of element without making a copy of it.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nIndex [in] - element index
+ * \return element of a vector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+inline const type& DMVector<type>::operator [] (int nIndex ) const
+{
+ DMASSERT( nIndex >= 0 && nIndex < m_nCount );
+ return m_ptrs[nIndex];
+}
+
+ /**
+ * Non const version of [] operator; allows to access any method of element without making a copy of it and assign a new value.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nIndex [in] - element index
+ * \return element of a vector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+inline type& DMVector<type>::operator [] (int nIndex )
+{
+ DMASSERT( nIndex >= 0 && nIndex < m_nCount );
+ return m_ptrs[nIndex];
+}
+
+ /**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oCopyFrom [in] - reference to DMVector instance
+ * \return reference to DMVector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+DMVector<type>& DMVector<type>::operator = ( const DMVector& oCopyFrom )
+{
+ // free current
+ Destroy();
+ if ( !set_size( oCopyFrom.m_nCount ) )
+ return *this;
+
+
+ for ( int i = 0; i < oCopyFrom.m_nCount; i++ )
+ (*this)[i] = oCopyFrom[i];
+
+ return *this;
+}
+
+template<class type>
+inline void DMVector<type>::DestructElement( int nIndex )
+{
+ m_ptrs[nIndex].~type();
+}
+
+template<class type>
+inline void DMVector<type>::ConstructElement( int nIndex )
+{
+ ::new((void*)(m_ptrs + nIndex)) type;
+}
+
+ /**
+ * Resizes the array. This function actually construct elements calling default constructor. Elements can be reassign via [] operator.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nNewSize [in] - new array size. If new size is greater than current, new elements are constructed.
+ * If new size is smaller than current, extra elements are destructed.
+ * \return success (1) or failure (0)
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+int DMVector<type>::set_size( int nNewSize )
+{
+ // validate parameter
+ if ( nNewSize < 0 )
+ return 0;
+
+ // destroy deleted elements
+ int nIndex = 0;
+ for ( nIndex = m_nCount - 1; nIndex >= nNewSize; nIndex-- )
+ DestructElement( nIndex );
+
+ if ( !Reallocate( nNewSize ) )
+ { // out of memory case
+ if ( m_nCount > nNewSize )
+ m_nCount = nNewSize;
+
+ return 0;
+ }
+
+ // construct new elements
+ for ( nIndex = m_nCount; nIndex < nNewSize; nIndex++ )
+ ConstructElement( nIndex );
+
+ m_nCount = nNewSize;
+
+ return 1;
+}
+
+
+/*
+ * Private function
+ * Reallocates main storage, doesn't shrink the storage except when called with 0
+ */
+template<class type>
+int DMVector<type>::Reallocate( int nNewSize )
+{
+ // reallocate main storage
+ // don't shrink the storage except when called with 0
+
+ if ( !nNewSize )
+ {
+ if ( m_ptrs )
+ DmtMemFree( m_ptrs );
+ m_ptrs = NULL;
+ m_nAllocated = 0;
+ return 1;
+ }
+
+ if ( nNewSize < m_nAllocated )
+ return 1; // nothing to do
+
+ int nNewAlloc = (nNewSize + 3) /4 * 4;
+
+ type* pNewPtr = (type*)DmtMemAlloc( nNewAlloc* sizeof(type) );
+
+ if ( !pNewPtr )
+ return 0;
+
+ memcpy( pNewPtr, m_ptrs, sizeof(type) * m_nCount );
+
+ DmtMemFree( m_ptrs ); m_ptrs = pNewPtr;
+ m_nAllocated = nNewAlloc;
+
+ return 1;
+}
+
+ /**
+ * Appends a new element to array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - new element to add
+ * \return index of a new element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+int DMVector<type>::push_back(const type& ptr)
+{
+ if ( !set_size( m_nCount + 1 ) )
+ return m_nCount-1;
+
+ (*this)[m_nCount-1] = ptr;
+ return m_nCount-1;
+}
+
+
+ /**
+ * Detaches element.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to allocated element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+type* DMVector<type>::detach()
+{
+ type* ptr = m_ptrs;
+ m_nCount = 0;
+ m_nAllocated = 0;
+ m_ptrs = NULL;
+ return ptr;
+}
+
+ /**
+ * Removes element from array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param index - element index; must be valid index.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+template<class type>
+void DMVector<type>::remove(int index)
+{
+ if ( index < 0 || index >= m_nCount )
+ return; // invlaid index - ignore it
+
+ DestructElement( index );
+ memmove( m_ptrs + index, m_ptrs + index + 1, (m_nCount - index - 1) * sizeof(type) );
+ m_nCount--;
+}
+
+ /**
+ * Looks for an element in array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - reference to element
+ * \return index of an element if found, otherwise (-1) .
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+int DMVector<type>::find(const type& ptr) const
+{
+ for ( int nPos = 0; nPos < m_nCount; nPos++ )
+ {
+ if ( (*this)[nPos] == ptr )
+ return nPos;
+ }
+ return -1;
+}
+
+
+
+////////////////////////////////////////////////////////////
+// implementation DMMap
+//----------------------------------------------
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+template<class Key, class Value>
+inline DMMap<Key,Value>::DMMap()
+{
+}
+ /**
+ * Destructor - freeing all dynamic resources
+ */
+template<class Key, class Value>
+inline DMMap<Key,Value>::~DMMap()
+{
+}
+
+
+/**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oCopyFrom [in] - constant reference to DMMap
+ * \return reference to the DMMap object (itself)
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+
+template<class Key, class Value>
+DMMap<Key,Value>& DMMap<Key,Value>::operator = ( const DMMap& oCopyFrom )
+{
+ m_aKeys = oCopyFrom.m_aKeys;
+ m_aValues = oCopyFrom.m_aValues;
+ return *this;
+}
+
+
+ /**
+ * Retrieves number of elements in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return number of elements
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline int DMMap<Key,Value>::size() const
+{
+ return m_aKeys.size();
+}
+
+ /**
+ * Retrieves a value based on key. The key must exist in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] - element key
+ * \return constant value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline const Value& DMMap<Key,Value>::get(const Key & key) const
+{
+ int index=m_aKeys.find(key);
+ DMASSERT( index >= 0 );
+
+ return m_aValues[index];
+}
+
+ /**
+ * Retrieves a value based on key. The key must exist in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] - element key
+ * \return value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline Value& DMMap<Key,Value>::get(const Key & key)
+{
+ int index=m_aKeys.find(key);
+ DMASSERT( index >= 0 );
+
+ return m_aValues[index];
+}
+
+ /**
+ * Adds or replaces value for the given key.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \param value [in] -element value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline void DMMap<Key,Value>::put(const Key & key, const Value & value)
+{
+ int index=m_aKeys.find(key);
+ if (index<0)
+ {
+ int nSize = m_aKeys.size();
+
+ if ( m_aKeys.push_back(key) != nSize )
+ return;
+
+ if ( m_aValues.push_back(value) != nSize )
+ {
+ m_aKeys.remove(nSize);
+ return;
+ }
+ }
+ else
+ {
+ m_aValues[index] = value;
+ }
+}
+
+/**
+ * Removes element for the given key
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \return "true" in case of success, otherwise - "false"
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline bool DMMap<Key,Value>::remove(const Key & key)
+{
+ int index=m_aKeys.find(key);
+ if (index>=0)
+ {
+ m_aKeys.remove(index);
+ m_aValues.remove(index);
+ return true;
+ }
+ return false;
+}
+
+ /**
+ * Looks up for the element for the given key. Set value if an element has been found.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \param rValue [out] -element value
+ * \return "true" if element has been found otherwise - "false"
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline bool DMMap<Key,Value>::lookup( const Key & key, Value& rValue) const
+{
+ int index=m_aKeys.find(key);
+
+ if (index < 0)
+ return false;
+
+ rValue = m_aValues[index];
+ return true;
+}
+
+/**
+* This is a helper class. Due to gcc limitations, declaring separate class instead of typedef
+* produces smaller binary
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DMStringVector : public DMVector<DMString>
+{
+};
+
+#endif
diff --git a/engine/dmlib/api/native/jem_defs.hpp b/engine/dmlib/api/native/jem_defs.hpp
new file mode 100644
index 0000000..a53b90a
--- /dev/null
+++ b/engine/dmlib/api/native/jem_defs.hpp
@@ -0,0 +1,431 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __JEM_DEFS_H__
+#define __JEM_DEFS_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file jem_defs.hpp
+ \brief Contains JemBaseObject class and JemSmartPtr template class definition
+
+ The jem_defs.hpp header file contains JemBaseObject class and JemSmartPtr \n
+ template class definition. \n
+ This is the utility definition for the Dmt C++ API. It defineds Basic types as byte and boolean.\n
+ Also some standard collection helper class as Date that are used in the API.\n
+ The <b>JemSmartPtr</b> class is a Smart pointer; works with classes derived from JemBaseObject. \n
+ The Smart pointer class keeps tracking counter references to the object and deletes it (via "DecRef" method) \n
+ if no one longer keeps a pointer to this object.\n
+ The <b>JemBaseObject</b> class is a base object for any ref-counted object.
+*/
+
+#include "dmtDefs.h"
+#include "dmstring.h"
+#include "dmvector.h"
+
+ /**Definition for the "byte" as unsigned char*/
+typedef UINT8 byte;
+ /**Definition for the "boolean" as unsigned char*/
+typedef BOOLEAN boolean;
+ /**Definition for the "JemDate" as INT64*/
+typedef INT64 JemDate;
+
+ /**
+ * Gets "safe" string. If string is NULL then an empy string will be returned.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par API Migration State: FINAL
+ * \param str [in] - string to be evaluated
+ * \return original (if not null) or an empty string
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+inline CPCHAR DmtGetSafeStrPtr( CPCHAR str )
+{
+ return (str ? str : "" );
+}
+
+/**
+* Smart pointer; works with classes derived from JemBaseObject.
+* Smartpointer class keeps tracking refcounter of the object and deletes it
+* (via "DecRef" method) if no one longer keeps a pointer to this object.
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+template<typename T> class JemSmartPtr
+{
+ T * m_pData;
+public:
+ /**Definition for the element_type*/
+ typedef T element_type;
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ JemSmartPtr(): m_pData(NULL) {}
+
+/**
+ * Copy constructor. The memory for the "cp" will be allocated.
+ * \param cp [in] - source object
+ */
+
+ JemSmartPtr( const JemSmartPtr<element_type> & cp): m_pData(cp.m_pData) { _AddRef();}
+
+/**
+ * Constructor. The memory will be allocated.
+ * \param p [in] - pointer to an element
+ */
+ JemSmartPtr( element_type * p): m_pData( p ) { _AddRef(); }
+
+ /**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param pData [in] - pointer to object
+ * \return constant reference to Smart pointer
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const JemSmartPtr<element_type>& operator=( element_type * pData)
+ {
+ if (m_pData != pData){
+ element_type* pOldData = m_pData;
+ m_pData = pData;
+ _AddRef();
+ pOldData->DecRef();
+ }
+ return *this;
+ }
+
+ /**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param cp [in] - constant reference to object
+ * \return constant reference to Smart pointer
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const JemSmartPtr<element_type>& operator=(const JemSmartPtr<element_type>& cp)
+ {
+ return operator=(cp.m_pData);
+ }
+
+ /**
+ * Destructor - freeing all dynamic resources
+ */
+ ~JemSmartPtr()
+ {
+ _Release();
+ }
+
+ /**
+ * Casting to type operator
+ * \return pointer to an element
+ */
+ operator element_type*() const { return m_pData; }
+
+ /**
+ * Casting to type operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return reference to an element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ element_type& operator*() const
+ {
+ return *m_pData;
+ }
+
+ /**
+ * Member selection via pointer operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to an element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ element_type* operator->() const
+ {
+ return m_pData;
+ }
+
+ /**
+ * Comparison operator (equally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param p [in] - pointer to an element for comparison
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN operator==(element_type* p) const { return m_pData == p; }
+
+ /**
+ * Comparison operator (equally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - constant reference to Smart pointer for comparison
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN operator==(const JemSmartPtr<element_type>& ptr) const { return operator==(ptr.m_pData);}
+
+ /**
+ * Comparison operator (unequally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param p [in] - pointer to an element for comparison
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN operator!=(element_type* p) const { return !(operator==(p));}
+
+ /**
+ * Comparison operator (unequally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - constant reference to Smart pointer for comparison
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN operator!=(const JemSmartPtr<element_type> & ptr) const { return !(operator==(ptr));}
+
+ /**
+ * Retrieves pointer to an element
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to an element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ element_type* GetPtr() const { return m_pData; }
+
+
+
+private:
+ void _Release() { m_pData->DecRef(); }
+ void _AddRef() { m_pData->AddRef(); }
+};
+
+ /**
+ * Reverse comparison operators for JemSmartPtr (equally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param p [in] - Smart pointer
+ * \param ptr [in] - reference to Smart pointer
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<typename T> inline BOOLEAN operator==(T* p, const JemSmartPtr<T>& ptr)
+{
+ return ptr == p;
+}
+
+ /**
+ * Reverse comparison operators for JemSmartPtr (unequally)
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param p [in] - Smart pointer
+ * \param ptr [in] - reference to Smart pointer
+ * \return boolean result of comparison
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<typename T> inline BOOLEAN operator!=(T* p, const JemSmartPtr<T>& ptr)
+{
+ return ptr != p;
+}
+
+
+/**
+* Base object for any ref-counted object.
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class JemBaseObject
+{
+ INT64 m_nRefCount;
+
+protected:
+ /**
+ * Protected destructor, since this is reference counted object and nobody should delete it manually.
+ */
+ virtual ~JemBaseObject(){}
+
+public:
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ JemBaseObject();
+
+ /**
+ * Operator New
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nSize [in] - requested size
+ * \return void pointer
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void* operator new( size_t nSize )
+ { return DmtMemAlloc( nSize ); }
+
+ /**
+ * Operator Delete
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param p [in] - void pointer
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ inline void operator delete( void* p )
+ { DmtMemFree( p ); }
+
+ /**
+ * Increments reference counter
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par API Migration State: FINAL
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void AddRef();
+
+ /**
+ * Decrements reference counter; deletes object if it's the last reference
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par API Migration State: FINAL
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void DecRef();
+};
+
+/** Defines PJemBaseObject as a smart pointer for DmtNode class */
+typedef JemSmartPtr<JemBaseObject> PJemBaseObject;
+
+// some additional smart pointers:
+class DmtTree;
+class DmtNode;
+
+/** Defines PDmtNode as a smart pointer for DmtNode class */
+typedef JemSmartPtr<DmtTree> PDmtTree;
+
+/** Defines PDmtTree as a smartpointer type for DmtTree class*/
+typedef JemSmartPtr<DmtNode> PDmtNode;
+
+
+#ifndef NULL
+ /** Define NULL */
+ #define NULL ((void*) 0)
+#endif
+
+////////////////////////////////////////////////////////////////////
+// inline functions for JemBaseObject
+
+ /**
+ * Default constructor for the class JemBaseObject - no memory allocation performed.
+ */
+inline JemBaseObject::JemBaseObject()
+{
+ m_nRefCount = 0;
+}
+
+ /**
+ * Increments reference counter
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+inline void JemBaseObject::AddRef()
+{
+ if ( this == NULL )
+ return;
+
+ m_nRefCount++;
+}
+
+//decrement reference (if == 0 then delete object).
+ /**
+ * Decrements reference counter; delete object if it's the last reference
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+inline void JemBaseObject::DecRef()
+{
+ if ( this == NULL )
+ return;
+
+ if ( --m_nRefCount <= 0 )
+ delete this;
+}
+
+#endif
diff --git a/engine/dmlib/api/native/plugin/dmtCommitPlugin.hpp b/engine/dmlib/api/native/plugin/dmtCommitPlugin.hpp
new file mode 100644
index 0000000..dd4e706
--- /dev/null
+++ b/engine/dmlib/api/native/plugin/dmtCommitPlugin.hpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTCOMMITPLUGIN_H__
+#define __DMTCOMMITPLUGIN_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtCommitPlugin.hpp
+ \brief The dmtCommitPlugin.hpp header file contains constants and datatypes
+ for the device managment Commit plugin.\n
+ <b>Warning:</b> All functions, structures, and classes from this header file are for internal usage only!!!
+*/
+
+#include "dmtEventData.hpp"
+#include "dmtPlugin.hpp"
+
+/**
+* Enumeration for Event types, used for backward compatibility
+*/
+enum {
+/** Event "None" */
+ DMT_EVENT_NONE = -1,
+/** Event "Add" */
+ DMT_EVENT_ADD = 0,
+/** Event "Delete" */
+ DMT_EVENT_DELETE = 1,
+/** Event "Replace" */
+ DMT_EVENT_REPLACE = 2,
+/** Event "Indirect Update" */
+ DMT_EVENT_INDIRECT_UPDATE = 3
+};
+/** Definition for DMT_EVENT_T as INT32*/
+typedef INT32 DMT_EVENT_T;
+
+/** Structure Subscription Data, contains info about tree changes, used for backward compatibility */
+struct DM_SUBSCRIPTION_DATA_T
+{
+/**
+* Default constructor
+*/
+ DM_SUBSCRIPTION_DATA_T(){m_eAction = DMT_EVENT_NONE;}
+/**
+* Constructor
+* \param strKey [in] - child node name as a string
+* \param eAction [in] - child node operation as a DMT_EVENT_T
+*/
+ DM_SUBSCRIPTION_DATA_T( const DMString& strKey, DMT_EVENT_T eAction ){m_strKey = strKey; m_eAction = eAction;}
+
+ /** child node name */
+ DMString m_strKey;
+
+ /** child node operation */
+ DMT_EVENT_T m_eAction;
+};
+
+
+/** DM Subscription Vector, inheritance from DMVector, used for backward compatibility
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DMSubscriptionVector : public DMVector<DM_SUBSCRIPTION_DATA_T>
+{
+};
+
+
+#endif //__DMTCOMMITPLUGIN_H__
diff --git a/engine/dmlib/api/native/plugin/dmtPlugin.hpp b/engine/dmlib/api/native/plugin/dmtPlugin.hpp
new file mode 100644
index 0000000..84da97b
--- /dev/null
+++ b/engine/dmlib/api/native/plugin/dmtPlugin.hpp
@@ -0,0 +1,1195 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTPLUGIN_H__
+#define __DMTPLUGIN_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtPlugin.hpp
+ \brief The dmtPlugin.hpp is a helper header file contains constants and data types\n
+ of plugin API. Also it contains DmtPluginNode, DmtAPIPluginTree and \n
+ DmtAPIPluginTree classes definition.\n
+ <b>Warning:</b> All functions, structures, and classes from this header file are for internal usage only!!!
+
+<P>
+
+Plugin DLLs' exported function types:<P>
+
+\code
+
+ //Mandatory function:
+ int DMT_PluginLib_GetVersion(); //Should return DMT_PLUGIN_VERSION_1_1
+
+ //Data plug-in:
+ extern "C"
+ SYNCML_DM_RET_STATUS_T DMT_PluginLib_Data_GetTree(
+ const char * pluginRootNodePath,
+ DMStringMap & mapParameters, //For the Tree
+ PDmtAPIPluginTree & pPluginTree //root tree for the current path
+ );
+
+ DmtPluginTree and DmtPluginNode are only used for Data plug-ins.
+
+ //Exec plug-in:
+ extern "C"
+ SYNCML_DM_RET_STATUS_T DMT_PluginLib_Execute2(
+ const char * path,
+ DMStringMap & mapParameters,
+ CPCHAR args,
+ CPCHAR szCorrelator,
+ PDmtTree tree,
+ DMString & results);
+
+ //Constraint plug-in:
+ extern "C"
+ SYNCML_DM_RET_STATUS_T DMT_PluginLib_CheckConstraint(
+ const char * path,
+ DMStringMap & mapParameters,
+ PDmtTree tree //Global Tree with same access rights for current session
+ );
+
+ //Commit plug-in:
+ extern "C"
+ SYNCML_DM_RET_STATUS_T DMT_PluginLib_OnCommit(
+ const DMSubscriptionVector &updatedNodes,
+ DMStringMap& mapParameters,
+ PDmtTree tree );
+ \endcode
+*/
+
+#include "jem_defs.hpp"
+#include "dmt.hpp" // Use Dmt C++ API for Data Plugin
+
+/** Version definition that should be used by both DLL and plugin*/
+#define DMT_PLUGIN_VERSION_1_1 0x00010001
+
+/** Define DMStringMap for plugins*/
+typedef DMMap<DMString, DMString> DMStringMap;
+
+/** Define DmtOverlayPluginData for plugins*/
+typedef DMVector<unsigned char> DmtOverlayPluginData;
+
+/** Overlay plugin synchronization data */
+struct DmtOverlayPluginSyncData
+{
+/** possible values for a status */
+ enum {
+ /** status deleted */
+ enum_StatusDeleted,
+ /** status unchanged */
+ enum_StatusUnchanged,
+ /** status added */
+ enum_StatusAdded
+ };
+ /** node name */
+ DMString m_strNodeName;
+ /** plugin data */
+ DmtOverlayPluginData m_oData;
+ /** node status */
+ UINT8 m_nStatus;
+};
+
+/**
+* Device management plugin tree API class; inherited from the DmtTree class.
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtAPIPluginTree : public DmtTree
+{
+ public:
+
+ /**
+ * Will be called by DM Engine whenever in prior to add multi-nodes with flag "storesPD".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - node path
+ * \param data [in] - reference to a node data
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T OnAdd( CPCHAR path, DmtOverlayPluginData& data );
+
+ /**
+ * Will be called by DM Engine whenever in prior to delete multi-nodes with flag "storesPD".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - node path
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T OnDelete( CPCHAR path );
+
+ /**
+ * Will be called by DM Engine to make synchronization in prior execution other functions.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - node path
+ * \param data [in] - vector with data
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Synchronize( const char* path, DMVector<DmtOverlayPluginSyncData>& data );
+
+ /**
+ * Called whenever plugin is unloaded to help free all resources
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual void Release();
+
+ /**
+ * Flushs memory
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Flush();
+
+ /**
+ * Finds added node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - CPCHAR path to added node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T FindAddedNode(CPCHAR path);
+
+ /**
+ * Finds added parent node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - CPCHAR path to added parent node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T FindAddedParentNode(CPCHAR path);
+
+ /**
+ * Sets added node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptrNode [in] - reference to a node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetAddedNode(PDmtNode ptrNode);
+
+ /**
+ * Removes added node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - CPCHAR path to added node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T RemoveAddedNode(CPCHAR path);
+
+
+ /**
+ * Sets principal for the plugin tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param strPrincipal [in] - principal string for the session
+ * \return Return Type (BOOLEAN)
+ * - TRUE -set principal successful
+ * - FALSE -set principal fail
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual BOOLEAN SetPrincipal( CPCHAR strPrincipal );
+
+/**
+* Retrieves a principal
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return the DmtPrincipal object that the session was created with.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual DmtPrincipal GetPrincipal() const;
+
+
+protected:
+ /** DmtAPIPluginTree class member contains list of added nodes*/
+ DMVector<PDmtNode> m_oAddedNodes;
+ /** DmtAPIPluginTree class member contains principal*/
+ DmtPrincipal m_Principal;
+
+};
+
+/** Define PDmtAPIPluginTree for plugins*/
+typedef JemSmartPtr< DmtAPIPluginTree > PDmtAPIPluginTree;
+
+
+class DmtPluginTree;
+class DmtPluginNode;
+
+/** Define Dmt Plugin Tree smart pointer for plugins*/
+typedef JemSmartPtr< DmtPluginTree > PDmtPluginTree;
+
+/** Define Dmt Plugin Node smart pointer for plugins*/
+typedef JemSmartPtr< DmtPluginNode > PDmtPluginNode;
+
+
+/** Has parent DmtAPIPluginTree class; handle operation with nodes and other tasks:\n
+* 1. Provide default implementation for many DmtTree virtual functions for ease of plugin development.\n
+* 2. Support default power failure recovery internally. \n
+* 3. Support plugin node to check parameters for each different node (GerNodeParameters).
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+
+class DmtPluginTree : public DmtAPIPluginTree
+{
+ //With some default Implementation of the DmtTree API including helper functions
+protected:
+
+ DMString m_strRootPath;
+ DMMap<DMString, PDmtNode> m_Nodes;
+
+ /** Protected destructor */
+ virtual ~DmtPluginTree();
+
+public:
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DmtPluginTree();
+
+public:
+
+/**
+ * Initializes DM tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param rootNodePath [in] - path to root node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Init( CPCHAR rootNodePath );
+
+ /**
+ * Retrieves full path to node
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to a node
+ * \param fullPath [out] - full path to a node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetFullPath( CPCHAR path,
+ DMString & fullPath ) const;
+
+ /**
+ * Retrieves node by given path
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to a node
+ * \param ptrNode [out] - reference to a node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_NOT_FOUND - indicating the operation cannot be performed. \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetNode( CPCHAR path,
+ PDmtNode& ptrNode );
+
+ /**
+ * Retrieves child nodes names by given path
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to a node
+ * \param mapNodes [out] - vector with child nodes
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetChildNodeNames( CPCHAR path,
+ DMStringVector& mapNodes );
+ /**
+ * Default atomicity support will be provided here
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Flush();
+
+ /**
+ * Checks for atomicity.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return '"false", not supported.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual BOOLEAN IsAtomic() const;
+
+ /**
+ * Begins an atomic operation that will end with commit() or rollback();
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * returns an error code if a transaction is running already.
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Begin();
+
+ /**
+ * The method will commit a series of atomic operations
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Commit();
+
+ /**
+ * The method will rollback a series of atomic operations
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Rollback() ;
+
+ /**
+ * Deletes a node according to the specified path
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - full path to the node
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T DeleteNode( CPCHAR path );
+
+ /**
+ * Changes node's name. For example: RenameNode( "./SyncML/DMAcc/Test", "NewTest" );
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param szNewNodeName [in] - new node name
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T RenameNode( CPCHAR path,
+ CPCHAR szNewNodeName );
+
+ /**
+ * Creates an interior node in the tree.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateInteriorNode( CPCHAR path,
+ PDmtNode& ptrCreatedNode );
+
+
+ /**
+ * Creates a leaf node in the tree.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \param value [in] - data value DmtData type
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode( CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value );
+
+ /**
+ * Creates a leaf node in the tree.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \param value [in] - data value DmtData type
+ * \param isESN [in] - TRUE if path is to an ESN node, otherwise -FALSE
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode(CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value ,
+ BOOLEAN isESN);
+
+ /**
+ * Releases DM tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual void Release();
+
+public:
+
+ //Other Helper Function Implementation for the Tree, NOT used
+
+ /**
+ * <b>NOT used</b>. Creates a sibling of the node specified by its URI "path".
+ * This new node's name is user-specified as "szNewNodename".
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - URI of node to be cloned.
+ * \param szNewNodename [in] - new node name as specified by user.
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Clone(CPCHAR path,
+ CPCHAR szNewNodename);
+
+ /**
+ * <b>NOT used</b>. . This is a helper method. It will return a table of all leaf nodes of the current node.
+ * The table key is the child node name, and value is the string node value. It sets leaf nodes only.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param mapNodes [out] - map with leaf nodes only
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetChildValuesMap( CPCHAR path,
+ DMMap<DMString, DmtData>& mapNodes );
+
+ /**
+ * <b>NOT used</b>. This is a helper method. It will delete all leaf nodes and creates new which are provided in the map.
+ * The table key is the child node name, and value is the node value. It changes leaf nodes only.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param mapNodes [in] - map with leaf nodes only
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetChildValuesMap( CPCHAR path,
+ const DMMap<DMString, DmtData>& mapNodes );
+
+public:
+ //
+ //Additional API for Recovery and 2-phase commit for multiple plugins.
+ //For future expansion. Currently not used
+ //
+ /**
+ * Additional API for Recovery and 2-phase commit for multiple plugins.
+ * \warning This API is for the future expansion and currently <b>NOT used</b>.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Verify();
+
+
+ //Additional API to shield plugins from accessing engine functions directly
+ // i.e. to get parameters for each plugin Node
+ // this is more generic since they can query *ANY* other parameters
+ /**
+ * Additional API to shield plugins from accessing engine functions directly (i.e. to get parameters for each plugin Node).
+ * This is more generic since they can query *ANY* other parameters.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param name [in] - parameter name
+ * \param value [out] - parameter value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_NOT_FOUND - indicating the operation cannot be performed. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetParameter(CPCHAR name,
+ DMString & value);
+
+ //
+ // Helper set Functions for shared library developer to use
+ //
+ /**
+ * This is a helper method. It will set Functions for shared library developer to use.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - node path
+ * \param node [out] - node to be set
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+ SYNCML_DM_RET_STATUS_T SetNode(CPCHAR path,
+ PDmtNode node);
+
+ /**
+ * Removes node fron the tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - node path
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T RemoveNode(CPCHAR path);
+
+ /**
+ * Removes all nodes
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T ClearNodes();
+
+};
+
+
+/**
+* Class DmtPluginNode for default read only plugin node implementation.
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtPluginNode : public DmtNode
+{
+protected:
+ BOOLEAN m_bLeaf;
+ DMString m_strPath;
+ PDmtPluginTree m_ptrTree;
+ DMString m_strName;
+ DmtData m_oData;
+ DMString m_strTitle;
+ DmtAttributes m_oAttr;
+ BOOLEAN m_bESN;
+ /** Protected destructor is changed to public destructor*/
+public:
+ virtual ~DmtPluginNode();
+
+
+public:
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DmtPluginNode();
+
+ /**
+ * Initializes plugin
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptrTree [in] - DM tree pointer
+ * \param path [in] - path
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Init(PDmtPluginTree ptrTree,
+ CPCHAR path);
+ /**
+ * Initializes plugin
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptrTree [in] - DM tree pointer
+ * \param path [in] - path
+ * \param isleaf [in] - TRUE if path is to leaf node, otherwise -FALSE
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Init(PDmtPluginTree ptrTree,
+ CPCHAR path,
+ BOOLEAN isleaf);
+
+ /**
+ * Initializes plugin
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptrTree [in] - DM tree pointer
+ * \param path [in] - path
+ * \param oData [in] - node data
+ * \param isESN [in] - TRUE if path is to an ESN node, otherwise -FALSE
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Init(PDmtPluginTree ptrTree,
+ CPCHAR path,
+ const DmtData & oData,
+ BOOLEAN isESN = FALSE);
+ /**
+ * Initializes plugin
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptrTree [in] - DM tree pointer
+ * \param path [in] - path
+ * \param childNodeNames [in] - vector with child node names
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Init(PDmtPluginTree ptrTree,
+ CPCHAR path,
+ const DMStringVector & childNodeNames);
+
+
+ /**
+ * Could set empty DmtData object if there is no value associated with it.
+ * The DmtValue is a copy of current data of the node. The node value will not
+ * be changed until a <i>setValue()</i> is called.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oData [out] - reference to DmtData object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetValue( DmtData& oData ) const;
+
+
+ //Attributes May also need to be replaced IF DmtData size is not WWW
+ /**
+ * Gets a copy of DmtAttributes, user can modify the DmtAttributes individually
+ * but any change made to DmtAttributes will not propagated to the Node until a <i>setAttributes()</i> is called.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oAttr [out] - reference to DM tree attributes
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetAttributes( DmtAttributes& oAttr ) const;
+
+ /**
+ * Retrieves tree
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptrTree [out] - reference to the DM tree
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetTree( PDmtTree& ptrTree ) const;
+
+ /**
+ * Retrieves path
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [out] - reference to path in the tree
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetPath(DMString & path) const;
+
+ /**
+ * Updates title information for the node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szTitle [in] - node titles string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetTitle( CPCHAR szTitle );
+
+ /**
+ * Updates ACL for the node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oAcl [in] - reference to DMT ACL object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetAcl( const DmtAcl& oAcl );
+
+ /**
+ * Changes the value of a node. If not successful, return an error code
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param value [in] - new node value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetValue( const DmtData& value );
+
+ /**
+ * Fills in oChildren list of child nodes
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oChildren [out] - vector for child nodes
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetChildNodes( DMVector<PDmtNode>& oChildren ) const;
+
+ /**
+ * Checks if a node is leaf
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return TRUE if the node is a leaf, otherwise - FALSE
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual BOOLEAN IsLeaf() const;
+
+ /**
+ * Executes a node according to the specified path. Pass a String parameter to the executable code
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param strData [in] - data to be executed as a string
+ * \param result [out] - the result of executing will be set to this string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Execute( CPCHAR strData, DMString& result );
+
+ /**
+ * Gets the name of the node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * param node [out] - name string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_DEVICE_FULL - indicating the operation cannot be performed. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetNodeName(DMString & name) const;
+
+ /**
+ * Gets name of a node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return name of a node as DMString.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual DMString GetNodeName() const { return m_strName; };
+
+ /**
+ * Renames a node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * param szNewName [in] - new name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T Rename( CPCHAR szNewName );
+
+ /**
+ * Sets child node object by name
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szPath [in] - name of node
+ * \param ptrNode [out] - reference to DmtNode
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetChildNode( CPCHAR szPath, PDmtNode& ptrNode );
+
+ /**
+ * Gets first chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [out] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetFirstChunk(DmtDataChunk& dmtChunkData);
+ /**
+ * Gets next chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [out] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T GetNextChunk(DmtDataChunk& dmtChunkData);
+
+ /**
+ * Sets first chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [in] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetFirstChunk(DmtDataChunk& dmtChunkData);
+
+ /**
+ * Sets next chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [in] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetNextChunk(DmtDataChunk& dmtChunkData);
+
+ /**
+ * Sets last chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [in] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetLastChunk(DmtDataChunk& dmtChunkData);
+
+ /**
+ * Checks if a Node is an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (BOOLEAN) \n
+ * - TRUE - indicating it is an ESN node. \n
+ * - FALSE - not an ESN
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ boolean IsExternalStorageNode(void) const {return m_bESN;}
+
+private :
+ SYNCML_DM_RET_STATUS_T InitAttributes(SYNCML_DM_DATAFORMAT_T type);
+};
+
+
+/**
+* Engine side support for Overlay plug-ins including meta node ID and PD retrieval
+*/
+struct DmtOPINodeData
+{
+/** plugin data*/
+ DMVector< DmtOverlayPluginData > aPD;
+/** meta ID of a node */
+ int metaNodeID;
+};
+
+ /**
+ * Function should be called only from the plug-in "getNode" function
+ * \warning This method for internal usage only!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return cached PDs and metaNodeID (or -1 if not set) for the current node
+ * \par Prospective Clients:
+ * For internal usage only
+ */
+extern "C" const DmtOPINodeData* DmtGetCachedOPINodeData();
+
+ /**
+ * Allows to update plug-in data in DMT
+ * \warning This method for internal usage only!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szURI [in] - node URI
+ * \param oData [out] - node data
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * For internal usage only
+ */
+extern "C" SYNCML_DM_RET_STATUS_T DmtSetOPINodeData( CPCHAR szURI, const DmtOverlayPluginData& oData );
+
+#endif
diff --git a/engine/dmlib/api/native/plugin/dmtPluginOverview.h b/engine/dmlib/api/native/plugin/dmtPluginOverview.h
new file mode 100644
index 0000000..e6a024e
--- /dev/null
+++ b/engine/dmlib/api/native/plugin/dmtPluginOverview.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+\mainpage DMT Plugin API Documentation
+
+\section Overview 2.0 Overview
+
+\warning This file is for internal usage only!!!
+
+ The Device Management implementation is based on the OMA DM (Formerly called SyncML DM)
+ Standard. A core part of implementation is the Device Management Tree (DMT). Each device that
+ supports OMA DM must contain a management tree. This document describes API required for
+ access and control DMT. \n
+ Nodes are the entities which can be manipulated by management actions carried over the OMA DM protocol.
+ A node can be as small as an integer or as large and complex as a background picture or screen saver. \n
+
+ The DMT constitutes a universal management data access mechanism.
+However, in the OMA DM standard, the DMT is only defined logically,
+that is, it does not define how the nodes are stored or where they come from;
+therefore, in our implementation, there are two kinds of tree nodes – physical
+and logical. Physical nodes are easy to understand – all nodes together with
+their configuration data are physically persisted and stored.
+This is similar to the MS Windows registry. However not all management information
+can be covered by such a data repository. \n
+
+The information either is too dynamic or already exists in the system and cannot
+be duplicated in the DMT. However, these nodes can still appear in the DMT, and
+are referred to as logical nodes. \n
+
+For example, in the P2K DM engine, all of the nodes in the tree were logical – that is,
+configuration data was stored by each application on the phone, and the DMT was a logical
+representation of that data. \n
+
+The DM Engine supports both physical nodes and logical nodes. Different platforms may
+choose different approaches. To access these logical nodes, the DM engine supports a
+plug-in architecture, which allows libraries to be added to the DM engine for accessing
+nodes that are not physically in the tree. By using the data plug-ins, the DM engine can
+support those logical nodes. \n
+
+This plug-in architecture also allows for libraries that are used to enforce integrity
+constraints on the nodes in the tree, as well as ‘execute’ plug-ins which allow commands or
+pointers to applications to be stored in DMT nodes. \n
+
+The DM engine plug-in mechanism is designed to allow uniform access to both the built-in
+configuration repository and other types of management data. \n
+
+Data plug-ins can be written in both C++ and Java and their interface is an extension of
+the public DMT API. For details, refer to the DMT API Documentation.
+Native data plug-ins are separate libraries (in an OS environment allowing for such),
+deployed in a well-known directory along with their internal configuration files.
+The files describe the sub-tree(s) of the DMT claimed by the plug-in, as well as,
+optionally, its internal configuration information for the nodes it is responsible for.
+
+
+\section IndustryStandard 3.0 Industry Standard
+
+ OMA DM (formerly SyncML DM)
+
+\section ClassAndStructureDefinitions 5.0 C++ Class and Structure Definitions
+
+\subsection Classes 5.1 Classes
+-# DMSubscriptionVector <em>DM Subscription Vector, inheritance from DMVector </em>
+-# DmtAPIPluginTree <em> Device management plugin tree API class; inheritance from DmtTree </em>
+-# DmtOPINodeData <em> Engine side support for Overlay plug-ins including meta node ID and PD retrieval </em>
+-# DmtOverlayPluginSyncData <em> Overlay plugin synchronization data </em>
+-# DmtPluginNode <em> Class DmtPluginNode for default read only plugin node implementation </em>
+-# DmtPluginTree <em> Has parent DmtAPIPluginTree class; handle operation with nodes and other tasks </em>
+-# DmtRWPluginNode <em> Based plugin node class with read/write functionality, inheritance from DmtPluginNode </em>
+-# DmtRWPluginTree <em> Based plugin tree class with read/write functionality, inheritance from DmtPluginTree </em>
+
+\subsection Structures 5.2 Structures
+Details of the structures are available from the source header files directly:
+-# dmtCommitPlugin.hpp
+-# dmtPlugin.hpp
+
+\section CFunctionsAndDataTypes 6.0 "C" Functions and Data Types
+-# const DmtOPINodeData* DmtGetCachedOPINodeData() <em>For the internal usage only!This function should be called only from the plug-in "getNode" function</em>
+-# SYNCML_DM_RET_STATUS_T DmtSetOPINodeData( CPCHAR szURI, const DmtOverlayPluginData& oData ) <em>For the internal usage only! Allow to update plug-in data in DMT</em>
+
+\section HeaderFilesAndLibraries 7.0 Header Files And Libraries
+
+-# dmtDefs.h
+-# dmtError.h
+-# dmtCommitPlugin.hpp
+-# dmtPlugin.hpp
+-# dmtRWPlugin.hpp
+-# xpl_Types.h
+-# xpl_StringUtil.h
+
+\section PluginExtensionPointInterface 8.0 Plug-in Extension Point Interface
+
+ "None"
+
+\section OtherInterfaces 9.0 Other Interfaces
+
+"None"
+
+\section OtherNotes 10.0 Other Notes
+
+ - All APIs' functions are synchronous.
+
+ - All APIs are in the "Final" state and guaranteed backward compatibility.
+
+ - All APIs are not secured but protection enforced on the DMT subtree level.
+*/
diff --git a/engine/dmlib/api/native/plugin/dmtRWPlugin.hpp b/engine/dmlib/api/native/plugin/dmtRWPlugin.hpp
new file mode 100644
index 0000000..d9d659b
--- /dev/null
+++ b/engine/dmlib/api/native/plugin/dmtRWPlugin.hpp
@@ -0,0 +1,709 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTRWPLUGIN_H__
+#define __DMTRWPLUGIN_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmtRWPlugin.hpp
+ \brief Constants and datatypes for plugin API.\n
+ The dmtRWPlugin.hpp header file contains constants and data types of plugin API. \n
+ Also it contains DmtRWPluginNode, DmtRWPluginTree classes definition. \n
+ <b>Warning:</b> All functions, structures, and classes from this header file are for internal usage only!!!
+
+ The <i>DmtRWPluginTree</i> is a base plugin tree class with read/write functionality; \n
+ inheritance from DmtPluginTree \n
+ The <i>DmtRWPluginNode</i> is a base plugin node class with read/write functionality; \n
+ inheritance from DmtPluginNode \n
+*/
+
+#include "dmtPlugin.hpp"
+
+class DmtRWPluginTree;
+class DmtRWPluginNode;
+
+/** Define DMT RW Plugin Tree smart pointer for plugins*/
+typedef JemSmartPtr< DmtRWPluginTree > PDmtRWPluginTree;
+
+/** Define DMT RW Plugin Node smart pointer for plugins*/
+typedef JemSmartPtr< DmtRWPluginNode > PDmtRWPluginNode;
+
+class SyncML_PlugIn_WBXMLLog;
+class DMFileHandler;
+
+/**
+* Based plugin tree class with read/write functionality. This class is inherited from the "DmtPluginTree".
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+
+class DmtRWPluginTree : public DmtPluginTree
+{
+ //With some default Implementation of the DmtTree API including helper functions
+private:
+ SYNCML_DM_RET_STATUS_T DeleteSubTree( PDmtNode ptrNode);
+ BOOLEAN IsESNSetComplete(CPCHAR pbURI);
+ SYNCML_DM_RET_STATUS_T CommitESN(CPCHAR pbURI);
+ SYNCML_DM_RET_STATUS_T InitLog ();
+ DMFileHandler *fpLog;
+ SyncML_PlugIn_WBXMLLog* log;
+ BOOLEAN m_Playback;
+ BOOLEAN m_ESNDirty;
+ DMString m_strLogPath;
+ BOOLEAN m_bIsAtomic;
+protected:
+
+/**
+* Protected destructor
+*/
+ virtual ~DmtRWPluginTree();
+
+public:
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DmtRWPluginTree();
+
+ /**
+ * Collects all commands that has been executed on plugin tree for the recovery and rollback actions.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param type [in] - plugin command type
+ * \param pbURI [in] -node URI
+ * \param attribute [in] - plugin command attribute
+ * \param inNode [in] - pointer to DMT node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T LogCommand(SYNCML_DM_PLUGIN_COMMAND_T type,
+ CPCHAR pbURI,
+ SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T attribute,
+ const DmtNode * inNode);
+
+/**
+ * For RW Trees, default atomicity support will be provided here.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Flush();
+
+/**
+ * Begins an atomic operation that will end with commit() or rollback();
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Begin();
+
+ /**
+ * Commits a series of atomic operations
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Commit();
+
+ /**
+ * Rollbacks a series of atomic operations
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Rollback();
+
+
+ /**
+ * Retrieves if operation is atomic
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual BOOLEAN IsAtomic() const;
+
+
+ /**
+ * Deletes a node according to the specified path
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - full path to the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T DeleteNode( CPCHAR path );
+
+ /**
+ * Changes node's name. For example: <i>RenameNode( "./SyncML/DMAcc/Test", "NewTest" )</i>;
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param szNewNodeName [in] - new node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T RenameNode( CPCHAR path,
+ CPCHAR szNewNodeName );
+ /**
+ * Deletes a node according to the specified path
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - full path to the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T RemoveNode(CPCHAR path);
+
+ /**
+ * Creates an interior node in the tree.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateInteriorNode( CPCHAR path,
+ PDmtNode& ptrCreatedNode );
+
+ /**
+ * Creates a leaf node in the tree.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \param value [in] - data value DmtData type
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode( CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value );
+ /**
+ * Creates a leaf node in the tree.
+ * \par Important Notes:
+ * -Note: This method provides default log implementation.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \param value [in] - data value DmtData type
+ * \param isESN [in] - TRUE if it is an ESN, otherwise set to FALSE.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode(CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value ,
+ BOOLEAN isESN);
+
+ /**
+ * Creates a leaf node in the tree.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \param value [in] - data value DmtData type
+ * \param isESN [in] - TRUE if it is an ESN, otherwise set to FALSE.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNodeInternal( CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value ,
+ BOOLEAN isESN);
+
+#ifdef LOB_SUPPORT
+ /**
+ * Creates temporary storage for an ESN.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T BackupESNdata( CPCHAR path);
+
+ /**
+ * Indicates the ESN value is modified...
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void SetESNDirty() {m_ESNDirty = TRUE;}
+#endif
+
+
+ /**
+ * Sets handler to the log file.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param fileHandle [in] - handler to the log file
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T setLogFileHandle(DMFileHandler *fileHandle);
+
+ /**
+ * Creates an interior node in the tree.
+ * \par Important Notes:
+ * -Note: The plugin developers should provide implementation !!!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \param childNodeNames [in] - vector with child nodes
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateInteriorNodeInternal( CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DMStringVector & childNodeNames);
+
+ /**
+ * Creates a leaf node in the tree.
+ * \par Important Notes:
+ * -Note: The plugin developers should provide implementation !
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \param ptrCreatedNode [out] - new created node
+ * \param value [in] - data value DmtData type
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNodeInternal( CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value );
+
+ /**
+ * Creates link (virtual) to a parent for the given node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param path [in] - path to the node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T LinkToParentNode( CPCHAR path);
+
+ /**
+ * Additional API for Recovery and 2-phase commit for multiple plugins.
+ * There is a default implementation using backward for forward logging.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Verify();
+
+
+ /**
+ * Retrieves if plugin is in a playback mode (recovery or rollback).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (BOOLEAN)
+ * - TRUE - if plugin is in the playback mode
+ * - FALSE - if plugin is NOT in the playback mode
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN IsPlaybackMode();
+
+ /**
+ * Sets plugin in playback mode (recovery or rollback).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param bPlayback [in] - true or false
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T SetPlaybackMode(boolean bPlayback);
+};
+
+
+
+/**
+* Base plugin node class with the read/write functionality. This class is inherited from the "DmtPluginNode".
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DmtRWPluginNode :public DmtPluginNode
+{
+private:
+#ifdef LOB_SUPPORT
+ BOOLEAN m_LobComplete;
+ BOOLEAN m_LobDirty;
+ BOOLEAN m_LobLogging;
+ DMString abStorageName;
+#endif
+ SYNCML_DM_RET_STATUS_T RenameChildNodes( const char* szParentPath, const char* szNodeName );
+
+protected:
+ /** Protected destructor */
+ virtual ~DmtRWPluginNode();
+
+public:
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DmtRWPluginNode();
+
+/**
+ * Updates title information for the node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szTitle [in] - node titles string
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetTitle( CPCHAR szTitle );
+
+ /**
+ * Changes the value of a node. If not successful, return an error code
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param value [in] - new node value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T SetValue( const DmtData& value );
+
+ /**
+ * Changes the value of a node. If not successful, return an error code
+ * \par Important Notes:
+ * -Note: The plugin developers should provide implementation !
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param value [in] - new node value
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T SetValueInternal( const DmtData& value );
+
+ /**
+ * Renames a node.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * param szNewName [in] - new name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T Rename( CPCHAR szNewName );
+
+#ifdef LOB_SUPPORT
+
+ /**
+ * Gets first chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [out] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T GetFirstChunk(DmtDataChunk& dmtChunkData);
+
+ /**
+ * Gets next chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [out] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T GetNextChunk(DmtDataChunk& dmtChunkData);
+
+ /**
+ * Sets first chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [in] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T SetFirstChunk(DmtDataChunk& dmtChunkData);
+
+ /**
+ * Sets next chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [in] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T SetNextChunk(DmtDataChunk& dmtChunkData);
+
+ /**
+ * Sets last chunk of an ESN (External Storage Node).
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param dmtChunkData [in] - reference to dmtChunkData
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T SetLastChunk(DmtDataChunk& dmtChunkData);
+
+ /**
+ * Checks if the settings of all the ESN(External Storage Node) under a subtree are complete.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return Return Type (BOOLEAN) \n
+ * - TRUE - indicate that settings are complete. \n
+ * - FALSE - indicate that settings are not complete. \n
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ BOOLEAN IsESNSetComplete() const { return m_LobComplete;}
+
+ /**
+ * The method will commit a series of atomic operations.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Commit();
+
+ /**
+ * Place holder (for internal usage only !).
+ * \warning This method should not be called !
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * Internal classes
+ */
+ virtual SYNCML_DM_RET_STATUS_T Delete();
+
+ /**
+ * Gets the backup file name of an ESN.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return backup file name
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ CPCHAR GetESNBackupFileName(void) const {return ( !m_LobLogging && abStorageName != NULL) ? abStorageName.c_str() : NULL;};
+
+ /**
+ * Backs all ESN data of a subteee.
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return status code. Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - SYNCML_DM_FEATURE_NOT_SUPPORTED - indicate that this operation is not supported for "read only" plugins.
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * Internal classes
+ */
+ SYNCML_DM_RET_STATUS_T BackupESNData();
+
+ /**
+ * Restores an ESN data from a file.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param szBackupFileName [in] - reference to a backup file
+ * \return Return Type (SYNCML_DM_RET_STATUS_T) \n
+ * - SYNCML_DM_SUCCESS - indicates that the operation is completed successfully. \n
+ * - All other codes indicates failure. The description can be found in dmtError.h
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ SYNCML_DM_RET_STATUS_T RestoreESNData( CPCHAR szBackupFileName );
+#endif
+};
+
+#endif
diff --git a/engine/dmlib/api/native_async/dmtAsyncAPI.h b/engine/dmlib/api/native_async/dmtAsyncAPI.h
new file mode 100644
index 0000000..2247293
--- /dev/null
+++ b/engine/dmlib/api/native_async/dmtAsyncAPI.h
@@ -0,0 +1,749 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================================================================
+
+ Header Name: dmtAsyncAPI.h
+
+ General Description: This file contains declaration of the DMT async APIs
+
+==============================================================================*/
+
+#ifndef DMT_ASYNC_API_H
+#define DMT_ASYNC_API_H
+
+#include "dmtDefs.h"
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+typedef UINT32 DMT_H_TREE;
+typedef UINT32 DMT_H_NODE;
+
+typedef struct
+{
+ SYNCML_DM_DATAFORMAT_T meta_format;
+ union
+ {
+ CPCHAR str_value;
+ INT32 int_value; /* int/bool values */
+ struct
+ {
+ const UINT8* bin_value;
+ INT32 len_bin_data;
+ } bin;
+ } data;
+
+} DMT_DATA_T;
+
+typedef struct {
+ UINT8 *chunkBuffer; /* chunked data buffer */
+ INT32 dataSize; /* input data size */
+ INT32 returnLen; /* actual size of data get/set */
+} DMT_DATACHUNK_T;
+
+/* helper struct used by bulk operation functions like xxxValuesMap */
+typedef struct
+{
+ CPCHAR* ppChildren; /* array of names (leaf children) */
+ const DMT_DATA_T* pData; /* array of data (leaf children) */
+ INT32 num_children; /* number of elements in data/name arrays */
+} DMT_LEAF_CHILDREN_DATA_T;
+
+typedef struct
+{
+ CPCHAR name;
+ CPCHAR format;
+ CPCHAR title;
+ CPCHAR type;
+ CPCHAR acl;
+ INT32 version;
+ INT32 size;
+ INT64 timestamp;
+} DMT_ATTRIBUTE_T;
+
+
+typedef struct
+{
+ UINT8 uiMode;
+ UINT8 initiator;
+ UINT16 sessionID;
+ CPCHAR serverID;
+ BOOLEAN authFlag;
+} DMT_NOTIFICATION_T;
+
+
+typedef struct
+{
+ CPCHAR strPackageURI; // URI of update package
+ CPCHAR strCorrelator;
+ CPCHAR strResultData;
+ CPCHAR strAlertType;
+ CPCHAR strAlertFormat;
+ CPCHAR strAlertMark;
+} DMT_FRM_ALERT_T;
+
+
+typedef struct
+{
+ SYNCML_DM_SESSION_DIRECTION_T direction;
+ UINT32 sessionID;
+ BOOLEAN isWBXML;
+ DMT_FRM_ALERT_T * alerts;
+ INT32 num_alerts;
+
+} DMT_SESSION_PROP_T;
+
+/* callback type definition */
+typedef enum {
+ DMT_OPERATION_INIT,
+ DMT_OPERATION_UNINIT,
+ DMT_OPERATION_RELEASE_TREE,
+ DMT_OPERATION_START_SRV_SESSION,
+ DMT_OPERATION_RELEASE_NODE,
+ DMT_OPERATION_DELETE_NODE,
+ DMT_OPERATION_RENAME_NODE,
+ DMT_OPERATION_CREATEI_NODE,
+ DMT_OPERATION_CREATEL_NODE,
+ DMT_OPERATION_SET_CHILDVALUES_MAP,
+ DMT_OPERATION_FLUSH,
+ DMT_OPERATION_COMMIT,
+ DMT_OPERATION_ROLLBACK,
+ DMT_OPERATION_BEGIN,
+ DMT_OPERATION_SET_VALUE,
+ DMT_OPERATION_SET_TITLE,
+ DMT_OPERATION_SET_ACL,
+
+};
+typedef UINT8 DMT_OPERATION_TYPE_T;
+
+
+
+/* callback parameters */
+typedef struct
+{
+ void* pUserData;
+ DMT_OPERATION_TYPE_T nCallbackType;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+} DMT_CALLBACK_STRUCT_STATUS_T;
+
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ DMT_H_TREE htree; /* tree handle if succeeded */
+} DMT_CALLBACK_STRUCT_GETTREE_T;
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ CPCHAR result; /* result script if succeeded; */
+ INT32 result_len; /* length of the result (useful if binary)*/
+} DMT_CALLBACK_STRUCT_PROCESS_SCRIPT_T;
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ CPCHAR serverID; /* server Id extracted from package 0 */
+} DMT_CALLBACK_STRUCT_BOOTSTRAP_T;
+
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ DMT_NOTIFICATION_T notification;
+} DMT_CALLBACK_STRUCT_PROCESS_NOTIFICATION_T;
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ DMT_H_NODE hnode; /* node handle if succeeded */
+ BOOLEAN leaf_node;/* true if leaf node */
+ BOOLEAN external_storage_node;/* true if External Storage node */
+} DMT_CALLBACK_STRUCT_GETNODE_T;
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ CPCHAR* ppChildren; /* list of children */
+ INT32 num_children;
+} DMT_CALLBACK_STRUCT_GET_CHILDNODE_NAMES_T;
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ DMT_LEAF_CHILDREN_DATA_T data; /* name->data list */
+} DMT_CALLBACK_STRUCT_GET_CHILDVALUES_MAP_T;
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ DMT_ATTRIBUTE_T attributes; /* node's attributes */
+} DMT_CALLBACK_STRUCT_GET_ATTRIBUTES_T;
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ DMT_DATA_T data; /* node's value */
+} DMT_CALLBACK_STRUCT_GET_VALUE_T;
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ CPCHAR result; /* Exec's result */
+} DMT_CALLBACK_STRUCT_EXECUTE_T;
+
+typedef struct
+{
+ void* pUserData;
+ SYNCML_DM_RET_STATUS_T nStatusCode;
+ DMT_DATACHUNK_T *datachunk;
+} DMT_CALLBACK_STRUCT_DATA_CHUNK_T;
+
+
+
+/* Callback function */
+
+/* Callback function */
+typedef void (*DMT_CallbackNotifyOnIdle)(void);
+
+typedef void (*DMT_CallbackStatusCode)(DMT_CALLBACK_STRUCT_STATUS_T *pStruct);
+
+typedef void (*DMT_CallbackGetTree)(DMT_CALLBACK_STRUCT_GETTREE_T *pGetTreeStruct);
+
+typedef void (*DMT_CallbackProcessScript)(
+ DMT_CALLBACK_STRUCT_PROCESS_SCRIPT_T *pProcessScriptStruct);
+
+typedef void (*DMT_CallbackBootstrap)(
+ DMT_CALLBACK_STRUCT_BOOTSTRAP_T *pBootstrapStruct );
+
+
+typedef void (*DMT_CallbackProcessNotification)(
+ DMT_CALLBACK_STRUCT_PROCESS_NOTIFICATION_T *pProcessNotificationStruct );
+
+typedef void (*DMT_CallbackGetNode)(DMT_CALLBACK_STRUCT_GETNODE_T *pStruct );
+
+typedef void (*DMT_CallbackGetChildNodeNames)(DMT_CALLBACK_STRUCT_GET_CHILDNODE_NAMES_T *pStruct );
+
+typedef void (*DMT_CallbackGetChildValuesMap)(DMT_CALLBACK_STRUCT_GET_CHILDVALUES_MAP_T *pStruct );
+
+typedef void (*DMT_CallbackGetAttributes)(DMT_CALLBACK_STRUCT_GET_ATTRIBUTES_T *pStruct );
+
+typedef void (*DMT_CallbackGetValue)(DMT_CALLBACK_STRUCT_GET_VALUE_T *pStruct );
+
+typedef void (*DMT_CallbackExecute)(DMT_CALLBACK_STRUCT_EXECUTE_T *pStruct );
+
+typedef void (*DMT_CallbackDataChunk)(DMT_CALLBACK_STRUCT_DATA_CHUNK_T *pStruct );
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*=================================================================================
+ FUNCTION PROTOTYPES
+ APIs with CALLBACK
+==================================================================================*/
+
+SYNCML_DM_RET_STATUS_T
+DMT_NotifyOnIdle(DMT_CallbackNotifyOnIdle callback,
+ void* pUserData );
+
+/* ***** Functions from DmtTreeFactory class ***** */
+/* initializes engine, no other functions should be called until it's done */
+SYNCML_DM_RET_STATUS_T
+DMT_Init(DMT_CallbackStatusCode callback, void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_Uninit(DMT_CallbackStatusCode callback, void* pUserData);
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetTree(CPCHAR szPrincipal,
+ DMT_CallbackGetTree callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetSubtree(CPCHAR szPrincipal,
+ CPCHAR szSubtreeRoot,
+ DMT_CallbackGetTree callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetSubtreeEx(CPCHAR szPrincipal,
+ CPCHAR szSubtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType,
+ DMT_CallbackGetTree callback,
+ void* pUserData );
+
+/* caller is responsible for manual deletion of tree object later */
+/* this function also returns tree serialization result */
+SYNCML_DM_RET_STATUS_T
+DMT_TreeRelease(DMT_H_TREE htree,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_ProcessScript(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ DMT_CallbackProcessScript callback,
+ void* pUserData );
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_StartServerSession(CPCHAR szPrincipal,
+ const DMT_SESSION_PROP_T * pSessionProp,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_ProcessNotification(CPCHAR szPrincipal,
+ const UINT8 *buf,
+ INT32 len,
+ DMT_CallbackProcessNotification callback,
+ void* pUserData );
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Bootstrap(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMT_CallbackBootstrap callback,
+ void* pUserData );
+
+
+/* ***** Functions from DmtTree class ***** */
+SYNCML_DM_RET_STATUS_T
+DMT_GetNode(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetNode callback,
+ void* pUserData );
+
+/* release node when it no longer needed */
+SYNCML_DM_RET_STATUS_T
+DMT_NodeRelease(DMT_H_NODE hnode,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_DeleteNode(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_RenameNode(DMT_H_TREE htree,
+ CPCHAR path,
+ CPCHAR new_node_name,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_CreateInteriorNode(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_CreateLeafNode(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetChildNodeNames(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildNodeNames callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_Flush(DMT_H_TREE htree,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_Commit(DMT_H_TREE htree,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_Rollback(DMT_H_TREE htree,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_Begin(DMT_H_TREE htree,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+
+/* bulk operations support */
+SYNCML_DM_RET_STATUS_T
+DMT_GetChildValuesMap(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildValuesMap callback,
+ void* pUserData );
+
+/**
+A helper method, deletes all leaf nodes and creates new ones, provided in the map
+The table key is the child node name, and value is the node value
+It changes leaf nodes only
+*/
+SYNCML_DM_RET_STATUS_T
+DMT_SetChildValuesMap(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_LEAF_CHILDREN_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+
+/* ***** Functions from DmtNode class ***** */
+SYNCML_DM_RET_STATUS_T
+DMT_GetAttributes(DMT_H_NODE hnode,
+ DMT_CallbackGetAttributes callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetValue(DMT_H_NODE hnode,
+ DMT_CallbackGetValue callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetValue(DMT_H_NODE hnode,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetTitle(DMT_H_NODE hnode,
+ CPCHAR title,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetACL(DMT_H_NODE hnode,
+ CPCHAR acl,
+ DMT_CallbackStatusCode callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_Execute(DMT_H_NODE hnode,
+ CPCHAR params,
+ DMT_CallbackExecute callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetFirstChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetNextChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetFirstChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetNextChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetLastChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData );
+
+INT32 DMT_GetChunkSize();
+/*=================================================================================
+ FUNCTION PROTOTYPES
+ APIs with messaging
+==================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMT_NotifyOnIdle_Msg(UINT32 messageID,
+ void* pUserData );
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Init_Msg(UINT32 messageID, void* pUserData);
+
+SYNCML_DM_RET_STATUS_T
+DMT_Uninit_Msg(UINT32 messageID, void* pUserData);
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetTree_Msg(CPCHAR szPrincipal,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetSubtree_Msg(CPCHAR szPrincipal,
+ CPCHAR szSubtreeRoot,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetSubtreeEx_Msg(CPCHAR szPrincipal,
+ CPCHAR szSubtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType,
+ UINT32 messageID,
+ void* pUserData );
+
+/* caller is responsible for manual deletion of tree object later */
+/* this function also returns tree serialization result */
+SYNCML_DM_RET_STATUS_T
+DMT_TreeRelease_Msg(DMT_H_TREE htree,
+ UINT32 messageID,
+ void* pUserData );
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_ProcessScript_Msg(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ UINT32 messageID,
+ void* pUserData );
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_StartServerSession_Msg(CPCHAR szPrincipal,
+ const DMT_SESSION_PROP_T * pSessionProp,
+ UINT32 messageID,
+ void* pUserData );
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_ProcessNotification_Msg(CPCHAR szPrincipal,
+ const UINT8 *buf,
+ INT32 len,
+ UINT32 messageID,
+ void* pUserData );
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Bootstrap_Msg(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ UINT32 messageID,
+ void* pUserData );
+
+
+/* ***** Functions from DmtTree class ***** */
+SYNCML_DM_RET_STATUS_T
+DMT_GetNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData );
+
+/* release node when it no longer needed */
+SYNCML_DM_RET_STATUS_T
+DMT_NodeRelease_Msg(DMT_H_NODE hnode,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_DeleteNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_RenameNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ CPCHAR new_node_name,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_CreateInteriorNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_CreateLeafNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_DATA_T* data,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetChildNodeNames_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_Flush_Msg(DMT_H_TREE htree, UINT32 messageID, void* pUserData);
+
+SYNCML_DM_RET_STATUS_T
+DMT_Commit_Msg(DMT_H_TREE htree, UINT32 messageID, void* pUserData);
+
+SYNCML_DM_RET_STATUS_T
+DMT_Rollback_Msg(DMT_H_TREE htree, UINT32 messageID, void* pUserData);
+
+SYNCML_DM_RET_STATUS_T
+DMT_Begin_Msg(DMT_H_TREE htree, UINT32 messageID, void* pUserData);
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetChildValuesMap_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetChildValuesMap_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_LEAF_CHILDREN_DATA_T* data,
+ UINT32 messageID,
+ void* pUserData );
+
+
+/* ***** Functions from DmtNode class ***** */
+SYNCML_DM_RET_STATUS_T
+DMT_GetAttributes_Msg(DMT_H_NODE hnode,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetValue_Msg(DMT_H_NODE hnode,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetValue_Msg(DMT_H_NODE hnode,
+ const DMT_DATA_T* data,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetTitle_Msg(DMT_H_NODE hnode,
+ CPCHAR title,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetACL_Msg(DMT_H_NODE hnode,
+ CPCHAR acl,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_Execute_Msg(DMT_H_NODE hnode,
+ CPCHAR params,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetFirstChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetNextChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetFirstChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetNextChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData );
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetLastChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData );
+
+/*=================================================================================
+ FUNCTION PROTOTYPES
+ Synchronous helper APIs
+==================================================================================*/
+
+
+SYNCML_DM_ACL_PERMISSIONS_T
+DMT_AclGetPermissions(CPCHAR acl,CPCHAR principal);
+
+/* sets required permission for specified principal
+ if result isn't successful set buf_len into required acl len */
+SYNCML_DM_RET_STATUS_T
+DMT_AclSetPermissions(char * acl,
+ INT32 * buf_len,
+ CPCHAR principal,
+ SYNCML_DM_ACL_PERMISSIONS_T permissions );
+
+
+/* Handler of DMT task messages, should be called from DM task */
+void DMT_MessageHandler(UINT32 msgtype, void *data);
+
+void DMT_Free_ProcessScriptStruct(DMT_CALLBACK_STRUCT_PROCESS_SCRIPT_T *pStruct);
+
+void DMT_Free_BootstrapStruct(DMT_CALLBACK_STRUCT_BOOTSTRAP_T *pStruct);
+
+void DMT_Free_ProcessNotificationStruct(DMT_CALLBACK_STRUCT_PROCESS_NOTIFICATION_T *pStruct);
+
+void DMT_Free_GetChildNodeNamesStruct(DMT_CALLBACK_STRUCT_GET_CHILDNODE_NAMES_T *pStruct);
+
+void DMT_Free_GetChildValuesStruct(DMT_CALLBACK_STRUCT_GET_CHILDVALUES_MAP_T *pStruct);
+
+void DMT_Free_GetAttributesStruct(DMT_CALLBACK_STRUCT_GET_ATTRIBUTES_T *pStruct);
+
+void DMT_Free_GetValueStruct(DMT_CALLBACK_STRUCT_GET_VALUE_T *pStruct);
+
+void DMT_Free_ExecuteStruct(DMT_CALLBACK_STRUCT_EXECUTE_T *pStruct);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_Commit_Log.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_Commit_Log.H
new file mode 100644
index 0000000..0ec021c
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_Commit_Log.H
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_Commit_Log_H
+#define SYNCML_Commit_Log_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "syncml_dm_data_types.h"
+#include "dmMemory.h"
+#include "SyncML_DM_WBXMLWriter.H"
+#include "SyncML_DM_WBXMLReader.H"
+#include "SyncML_Log.H"
+
+/*==================================================================================================
+CLASS DECLARATION
+==================================================================================================*/
+class SyncML_Commit_Log:public SyncML_Log
+{
+ public:
+ /* Class constructor */
+ SyncML_Commit_Log();
+
+ /* Class destructor */
+ virtual ~SyncML_Commit_Log();
+ // Uninitialize log
+ SYNCML_DM_RET_STATUS_T UnInitLog();
+
+ SYNCML_DM_RET_STATUS_T logCommand(SYNCML_DM_COMMAND_T commandType,
+ CPCHAR pSourceFileName,
+ CPCHAR pTargetFileName);
+
+ /* Take each entry in the log file and play it on the tree (by passing to
+ * the tree and node manager) according to logic based on flags in the log entry
+ */
+ SYNCML_DM_RET_STATUS_T playLog() ;
+ SYNCML_DM_RET_STATUS_T playLog(CPCHAR logFileName);
+ SYNCML_DM_RET_STATUS_T CloseLog();
+
+ private:
+ /* Performs the actual recovery function calls */
+ SYNCML_DM_RET_STATUS_T playbackOneRecord(SYNCML_DM_COMMAND_T commandType,
+ CPCHAR pSourceFileName,
+ CPCHAR pTargetFileName);
+ SYNCML_DM_RET_STATUS_T renameESNfile(CPCHAR pTargetFileName, DMFileHandler &handler);
+ SyncML_DM_WBXMLWriter* writer;
+ SyncML_DM_WBXMLReader* reader;
+
+};
+
+#endif /* SYNCML_Commit_Log_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Archive.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Archive.H
new file mode 100644
index 0000000..5b21d89
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Archive.H
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_ARCHIVE_H
+#define SYNCML_DM_ARCHIVE_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SyncML_DM_Archive.H
+
+ General Description: This file contains the declaration for the SyncML_DM_Archive class.
+ SyncML_DM_Archive is the ABC (Abstract Base Class) of all Archive classes
+
+==================================================================================================*/
+
+#include "xpl_Time.h"
+#include "dmMemory.h"
+#include "dmEventLogger.h"
+#ifdef LOB_SUPPORT
+#include "SyncML_Commit_Log.H"
+#endif
+
+/*==================================================================================================
+CLASS DECLARATION
+==================================================================================================*/
+
+class DMNode;
+class DMTree;
+class CEnv;
+
+class SyncML_DM_Archive
+{
+ public:
+
+ DMEventLogger& GetEventLogger() { return oEventLogger; }
+
+ /* Class constructor
+ * The caller is responsible for allocating/freeing the two fields
+ * to this function
+ */
+ SyncML_DM_Archive(CEnv* env, CPCHAR pURI, CPCHAR path) ;
+
+ /* Class destructor (virtual because of the inheritance of
+ * other classes who might be referenced as SyncML_DM_Archive)
+ */
+ virtual ~SyncML_DM_Archive() ;
+
+ virtual SYNCML_DM_RET_STATUS_T Init(DMTree* pTree);
+
+ /* Serialization and Deserialization methods must be overridden
+ * by any concrete archive implementation
+ * The caller is responsible for allocating/freeing the DMTree
+ * for the serialize function
+ */
+ virtual SYNCML_DM_RET_STATUS_T serialize(DMTree* tree) = 0;
+ virtual SYNCML_DM_RET_STATUS_T deserialize(DMTree* tree,
+ BOOLEAN bIsReload = FALSE) = 0;
+
+ /* Operators to allocate and delete memory for operation */
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+ /* Accessor for the last modification time of the archive
+ */
+ virtual XPL_CLK_CLOCK_T getLastModifiedTime() = 0;
+
+ /* Get last persisted time */
+ virtual XPL_CLK_CLOCK_T getLastSavedTime() = 0;
+
+ /* Check permission */
+ virtual BOOLEAN verifyPermission(XPL_FS_OPEN_MODE_T permission) const {return TRUE;}
+
+ /* Update last accessed time */
+ void setLastAccessedTime(XPL_CLK_CLOCK_T lastAccessedTime);
+
+ /* Get last accessed time */
+ XPL_CLK_CLOCK_T getLastAccessedTime();
+
+ BOOLEAN isWritableExist() const {return m_bWritableExist;}
+
+ void setWritableExist( BOOLEAN bWritableExist ) {m_bWritableExist = bWritableExist;}
+
+ //Re-Set last persisted time
+ virtual void serializeDone() = 0;
+
+ /* Accessors for setting/getting the string representing the URI
+ * of the archive in the memory tree
+ *
+ * The caller is responsible for allocating/freeing memory for the
+ * set function but has no responsibilities when using the get
+ * function
+ */
+ CPCHAR getURI() const {return m_pURI;}
+
+ /* Accessor for setting the root node of the archive of the DMNode type
+ * The destructor of this class later frees the created DMAddNodeProp
+ * object
+ */
+ virtual void setRootNode(DMNode* node) { rootTreeNode=node; }
+
+ virtual DMNode* getRootNode() { return rootTreeNode; }
+
+ BOOLEAN isDirty() { return dirty; }
+
+ void setDirty(BOOLEAN dirty) { this->dirty=dirty; }
+
+ void getFilePath(char * path, CPCHAR ext);
+
+ SyncML_DM_Archive * getParentArchive() { return parent; }
+
+ void setParentArchive(SyncML_DM_Archive * parent) { this->parent=parent; }
+
+ BOOLEAN LoadSkeleton(DMTree* pTree) ;
+#ifdef LOB_SUPPORT
+ virtual SYNCML_DM_RET_STATUS_T rollbackESN(DMTree* tree) = 0;
+ virtual SYNCML_DM_RET_STATUS_T commitESN(DMTree* tree) = 0;
+ virtual SyncML_Commit_Log* GetCommitLogHandler() = 0;
+ virtual SYNCML_DM_RET_STATUS_T CloseCommitLog() = 0;
+ virtual SYNCML_DM_RET_STATUS_T PlayCommitLog() = 0;
+#endif
+
+ protected:
+
+ DMEventLogger oEventLogger;
+
+ //Parent archive of this archive. when loaded, parent MUST Have already been loaded
+ SyncML_DM_Archive * parent;
+
+ /* The top-level URI of the archive */
+ CPCHAR m_pURI;
+
+ /* The filesystem path string of the archive file */
+ CPCHAR m_path;
+ /* full name to file in WFS */
+ DMString m_strWFSFileName;
+
+ /* if the tree associated with the archive is dirty or not.*/
+ BOOLEAN dirty;
+ BOOLEAN m_bWritableExist;
+
+ /* permission mask on archive */
+ int m_permission;
+
+ DMNode* rootTreeNode; //Different from rootNode which is a serialized form
+ XPL_CLK_CLOCK_T m_lastAccessedTime;
+ DMTree* m_pTree;
+
+};
+
+#endif /* SYNCML_DM_ARCHIVE_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Archiver.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Archiver.H
new file mode 100644
index 0000000..f6ef0fd
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Archiver.H
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_ARCHIVER_H
+#define SYNCML_DM_ARCHIVER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "SyncML_DM_Archive.H"
+#include "file_manager.h"
+#include "dmdefs.h"
+
+#define MAX_ARCHIVES 32
+
+/*==================================================================================================
+CLASS DECLARATION
+==================================================================================================*/
+class DMTree;
+class CEnv;
+
+class SyncML_DM_Archiver
+{
+ public:
+ SyncML_DM_Archiver();
+
+ /* Methods for deserializing / serializing a DMTree from/into a file
+ * according to the URI-file path ordered pairs suggested in the mount list
+ */
+ SYNCML_DM_RET_STATUS_T deserialize(FILESETTYPE nFileSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType) ;
+
+ SYNCML_DM_RET_STATUS_T serialize(FILESETTYPE nFileSet, CPCHAR szURI) ;
+
+ /* A helper method for making sure that ALL archives is set up if possible */
+ SYNCML_DM_RET_STATUS_T initArchives( CEnv* env, DMTree* tree);
+
+ // A helper method for making sure that ALL archives is freed
+ SYNCML_DM_RET_STATUS_T deinitArchives() ;
+
+ // Used for recovery purposes in the next phase of development
+ //CheckRecovery should be done for ALL files
+ SYNCML_DM_RET_STATUS_T checkRecovery() ;
+
+ // rollback file set
+ SYNCML_DM_RET_STATUS_T rollback(INT32 nFileSet) ;
+
+ //Get the Archive containing the URI, the URI may NOT be a node in the tree !
+ FILESETTYPE getArchivesByURI(CPCHAR pURI) const;
+
+ //Get the Archive containing the URI
+ SyncML_DM_Archive* getArchiveByURI(CPCHAR pURI) const;
+
+ // Get the archive which is the Root of the tree
+ SyncML_DM_Archive* getRootArchive() { return m_pArchives[0]; }
+
+ //Get the num of Files
+ INT32 getNumArchives() const { return m_numArchives; }
+
+
+ BOOLEAN IsDirty(FILESETTYPE * nFileSet);
+
+
+ // Get the archive which is the Root of the tree
+ SyncML_DM_Archive* getArchive(INT32 index) { return m_pArchives[index]; }
+
+ // Unload files by memory aging
+ void CheckMemoryAging(INT32 nAgingTime);
+
+ SYNCML_DM_RET_STATUS_T CleanEvents(CPCHAR szURI);
+
+ SYNCML_DM_RET_STATUS_T UpdateEvents(CPCHAR szURI, CPCHAR szNewName);
+
+
+ private:
+ // this function does not return status code, since it notifies only
+ void InvokeCommitPlugins(FILESETTYPE nFileSet, CPCHAR szURI);
+
+
+
+ private:
+ // DM: not implemented to prevent copying
+ SyncML_DM_Archiver( const SyncML_DM_Archiver& );
+ const SyncML_DM_Archiver& operator =( const SyncML_DM_Archiver& );
+
+ private:
+ // The tree of archives in relative associative form
+ SyncML_DM_Archive *m_pArchives[MAX_ARCHIVES]; //[0] is always root archive
+ INT32 m_numArchives;
+ DMTree *m_pTree;
+ CEnv *m_pEnv;
+};
+
+#endif /* SYNCML_DM_ARCHIVER_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_FileHandle.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_FileHandle.H
new file mode 100644
index 0000000..e72b194
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_FileHandle.H
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_FILEHANDLE_H
+#define SYNCML_DM_FILEHANDLE_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "syncml_dm_data_types.h"
+#include "xpl_File.h"
+#include "dmMemory.h"
+#include "dmstring.h"
+
+class DMFileHandler
+{
+ public:
+
+ /* File name extensions for serialization */
+ static const char TEMP_FILE_EXTENSION[];
+ static const char BAK_FILE_EXTENSION[];
+ static const char COMMIT_LOG_EXTENSION[];
+ static const char LOG_FILE_EXTENSION[];
+ static const char MIDDLE_FILE_EXTENSION[];
+ enum { MAX_INTERNAL_BUFFER_LENGTH = 1024};
+
+
+ /* Constructor for the class takes absolute path of the file */
+ DMFileHandler(CPCHAR path);
+
+ DMFileHandler(CPCHAR path, BOOLEAN bIsCache);
+
+ /* Frees the internal buffer */
+ ~DMFileHandler();
+
+ /* Opens a file for I/O */
+ SYNCML_DM_RET_STATUS_T open(INT32 mode);
+
+ /* Reads count bytes into buffer */
+ inline SYNCML_DM_RET_STATUS_T read(UINT8* buffer, UINT16 count) {return read((char*)( buffer ), count);}
+ SYNCML_DM_RET_STATUS_T read(char* buffer, UINT16 count);
+
+ /* Writes count bytes into the buffer/file
+ * For the purposes of performance, this function
+ * adds small writes to a buffer before sending to the
+ * filesystem.*/
+ inline SYNCML_DM_RET_STATUS_T write(const UINT8* buffer, UINT16 count) {return write((const char*)( buffer ), count);}
+ SYNCML_DM_RET_STATUS_T write(const char* buffer, UINT16 count);
+
+ /* Seek offset bytes relative to seekFrom */
+ SYNCML_DM_RET_STATUS_T seek(XPL_FS_SEEK_MODE_T whence, INT32 offset);
+
+ /* Close the file handle */
+ SYNCML_DM_RET_STATUS_T close();
+
+ /* Rename the file to name */
+ SYNCML_DM_RET_STATUS_T rename(CPCHAR newFileName);
+
+ /* Delete the file */
+ SYNCML_DM_RET_STATUS_T deleteFile();
+
+ /* Create an unique External Storage Node file name */
+ static SYNCML_DM_RET_STATUS_T createTempESNFileName(DMString &fileName);
+
+ /* Returns file size */
+ XPL_FS_SIZE_T size();
+
+ // FILE* api functions
+ char* fgets( char* s, INT32 size );
+
+ BOOLEAN iseof();
+
+ /* Flushes the internal write buffer if it exists */
+ SYNCML_DM_RET_STATUS_T flush();
+
+ UINT8 * mmap();
+
+ SYNCML_DM_RET_STATUS_T unmmap();
+
+ XPL_FS_SEEK_OFFSET_T position();
+
+ #ifndef DM_NO_LOCKING
+ SYNCML_DM_RET_STATUS_T lock(BOOLEAN bLockExclusive );
+
+ SYNCML_DM_RET_STATUS_T unlock();
+#endif
+
+ inline const char* getFullPath() const { return m_strPath.c_str(); }
+
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+ private:
+
+ /* The file handle reference */
+ XPL_FS_HANDLE_T m_nFileHandle;
+
+ /* Absolute path of the file pointed to by the file handle */
+ DMString m_strPath;
+
+ /* Internal buffer data members */
+ char * m_pInternalBuf;
+ UINT8 * m_pMemMap;
+ UINT16 m_nInternalBufLen;
+ UINT16 m_nBufPos; // reading operations required 2 int: buf size and pos
+ XPL_FS_SIZE_T m_nSize;
+
+ XPL_FS_SEEK_OFFSET_T m_nFilePos;
+ XPL_FS_SEEK_OFFSET_T m_nBufOffset;
+ BOOLEAN m_bWrite;
+ BOOLEAN m_bIsCache;
+ BOOLEAN m_bIsMap;
+ XPL_FS_OPEN_MODE_T m_nMode;
+
+ /* Writes count bytes into the file.
+ * This method does the actual writes to the filesystem */
+ SYNCML_DM_RET_STATUS_T writeBuffer(const char* buffer, UINT16 count);
+
+ void init(CPCHAR path);
+};
+
+#endif /* SYNCML_DM_FILEHANDLE_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Reader.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Reader.H
new file mode 100644
index 0000000..aa7a37b
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Reader.H
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_READER_H
+#define SYNCML_DM_READER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SyncML_DM_Reader.H
+
+ General Description: ABC class for all readers of tree data. This class does not
+ possess a .cc file since there are two functions with little content.
+
+==================================================================================================*/
+
+#include "SyncML_DM_FileHandle.H"
+
+class DMAddNodeProp;
+
+class SyncML_DM_Reader
+{
+
+public:
+
+ /* Class constructor */
+ SyncML_DM_Reader(DMFileHandler* handle) : fileHandle(handle){ }
+
+ /* Class destructor */
+ virtual ~SyncML_DM_Reader(){ }
+
+ /* Accessor for setting the file handle used by the class' utilities */
+ virtual void setFileHandle(DMFileHandler* fileHandle){ this->fileHandle = fileHandle; }
+
+ /* Read a byte into the argument of this function
+ * pure virtual method. Implementations of Reader must override
+ */
+ virtual SYNCML_DM_RET_STATUS_T readByte(UINT8* bYte) = 0;
+
+ /* Read a tree node into the data structure pointer argument and
+ * return the next byte read
+ *
+ * This function allocates the memory returned in its node argument
+ * The stopByte is defined by the calling function and its pointer is passed.
+ */
+ virtual SYNCML_DM_RET_STATUS_T readNode(DMAddNodeProp* node, UINT8* stopByte) = 0;
+
+protected:
+
+ /* The file handle used by this object.
+ * As implemented, this class requires the user to open a file "on the side"
+ * and set this variable so then the writer can work on the file. The caller
+ * is responsinble for closing the file and freeing the handle.
+ */
+ DMFileHandler* fileHandle;
+
+};
+
+#endif /* SYNCML_DM_READER_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLArchive.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLArchive.H
new file mode 100644
index 0000000..51ae3b8
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLArchive.H
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_WBXMLARCHIVE_H
+#define SYNCML_DM_WBXMLARCHIVE_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SyncML_DM_WBXMLArchive.H
+
+ General Description: This class provides the implementation of WBXML logging in the file system
+
+==================================================================================================*/
+
+#include "SyncML_DM_Archive.H"
+#include "SyncML_DM_WBXMLWriter.H"
+#include "SyncML_DM_WBXMLReader.H"
+#include "syncml_dm_data_types.h"
+#ifdef LOB_SUPPORT
+#include "SyncML_Commit_Log.H"
+#endif
+
+class DMTree;
+class CEnv;
+
+/*==================================================================================================
+CLASS DECLARATION
+==================================================================================================*/
+class SyncML_DM_WBXMLArchive : public SyncML_DM_Archive
+{
+
+ public:
+
+ /* The default WBXML header used for string table lookups
+ */
+ static const UINT8 DEFAULT_FILE_HEADER[] ;
+
+ static const char FILE_EXTENSION[] ;
+
+ /* The list of tag values for WBXML encoding */
+ enum
+ {
+ WBXML_VERSION = 0x01, /* WBXML spec ver 1.1 (this is what our xml-to-wbxml tool does) */
+ PUBLIC_ID = 0x01, /* Unknown or missing identifier; must be <=127 */
+ CHARSET = 0x6A /* charset is UTF-8; value must be <=127 */
+ };
+
+ enum WBXML_TAGS
+ {
+ TAG_CONTENT_MASK = 0x40,
+ FILE_START_TAG = 0x1F,
+ TREE_START_TAG = 0x1E,
+ NODE_START_TAG = 0x1D,
+ NAME_START_TAG = 0x1C,
+ ACL_START_TAG = 0x1B,
+ ACCESS_START_TAG = 0x1A,
+ SCOPE_START_TAG = 0x19,
+ CLASSID_START_TAG = 0x18,
+ FORMAT_START_TAG = 0x17,
+ TYPE_START_TAG = 0x16,
+ FLAGS_START_TAG = 0x15, //DP substitution for SCOPE/CALSSID
+ TSTAMP_INT_START_TAG = 0x14, // DP: integer timestamp representation
+ FORMAT_NEW_START_TAG = 0x13,
+ URI_START_TAG = 0x12,
+
+ DATA_START_TAG = 0x08, //leave space 0x20-0x27 for urbana expansion
+ PLURAL_START_TAG = 0x09,
+ OPI_DATA_START_TAG = 0x0A,
+ TITLE_START_TAG = 0x10,
+ TSTAMP_START_TAG = 0x11,
+ VERSION_START_TAG = 0x07,
+#ifdef LOB_SUPPORT
+ ESN_File_NAME_START_TAG = 0x20,
+#endif
+ LOG_START_TAG = 0x21,
+ ENTRY_START_TAG = 0x22,
+ CMDTYPE_START_TAG = 0x23,
+ SOURCE_FILE_TAG = 0x24,
+ TARGET_FILE_TAG = 0x25,
+ END_TAG = 0x01
+ };
+
+ enum
+ {
+ OPAQUE_CODE = 0xC3,
+ STRING_TABLE = 0x00
+ };
+
+ /* Class constructor */
+ SyncML_DM_WBXMLArchive( CEnv* env, CPCHAR pURI, CPCHAR path) ;
+ ~SyncML_DM_WBXMLArchive() ;
+
+
+
+ /* Deserializes a set of tree files from the file system,
+ * creates nodes and passes them to the tree
+ */
+ virtual SYNCML_DM_RET_STATUS_T deserialize(DMTree* tree,
+ BOOLEAN bIsReload = FALSE);
+
+ /* Serializes a sub tree of data into the proper mount
+ * list referenced WBXML file
+ */
+ virtual SYNCML_DM_RET_STATUS_T serialize(DMTree* tree) ;
+ /* Accessor for the last modification time of the archive
+ */
+ virtual XPL_CLK_CLOCK_T getLastModifiedTime() ;
+
+ //Get last persisted time
+ virtual XPL_CLK_CLOCK_T getLastSavedTime() ;
+
+ // Check permission (flags from xpl_File.h)
+ virtual BOOLEAN verifyPermission(XPL_FS_OPEN_MODE_T permission) const;
+
+ virtual void serializeDone() ;
+#ifdef LOB_SUPPORT
+ // Rollback operation for ESN
+ virtual SYNCML_DM_RET_STATUS_T rollbackESN(DMTree* tree);
+ virtual SYNCML_DM_RET_STATUS_T commitESN(DMTree* tree);
+ SyncML_Commit_Log* GetCommitLogHandler();
+ SYNCML_DM_RET_STATUS_T CloseCommitLog();
+ SYNCML_DM_RET_STATUS_T PlayCommitLog();
+#endif
+ private:
+ SYNCML_DM_RET_STATUS_T deserializeFile(DMTree* tree, CPCHAR szFileName, BOOLEAN bWFS);
+#ifdef LOB_SUPPORT
+ SyncML_Commit_Log *commitLog;
+#endif
+ XPL_CLK_CLOCK_T lastSavedTime;
+ CEnv *m_pEnv;
+};
+
+#endif /* SYNCML_DM_WBXMLARCHIVE_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLReader.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLReader.H
new file mode 100644
index 0000000..a122322
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLReader.H
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_WBXMLREADER_H
+#define SYNCML_DM_WBXMLREADER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "SyncML_DM_Reader.H"
+#include "SyncML_DM_FileHandle.H"
+#include "syncml_dm_data_types.h"
+#include "dm_tree_typedef.h"
+
+class SyncML_DM_WBXMLReader : public SyncML_DM_Reader
+{
+
+public:
+
+ /* Class constructor */
+ SyncML_DM_WBXMLReader(DMFileHandler* fileHandle) : SyncML_DM_Reader(fileHandle) { }
+
+ /* Reads a byte of data from the file handle */
+ virtual SYNCML_DM_RET_STATUS_T readByte(UINT8 *bYte);
+
+ /* Reads an opaque encoded block of data from the file handle
+ * returning the length and a buffer holding the data.
+ */
+ SYNCML_DM_RET_STATUS_T readOpaque(DMBuffer *pBuffer);
+ SYNCML_DM_RET_STATUS_T readOpaque(UINT8 *pBuffer, UINT8 nSize);
+
+ /* Reads a node from the file handle
+ *
+ * The stopByte is defined by the calling function and its pointer is passed.
+ */
+ virtual SYNCML_DM_RET_STATUS_T readNode(DMAddNodeProp* node,
+ UINT8* stopByte);
+
+ /* Read the WBXML string table header from the file handle */
+ SYNCML_DM_RET_STATUS_T readHeader();
+
+ /* Read a log record from the RW plugin log file */
+ SYNCML_DM_RET_STATUS_T readOneLogRecord(SYNCML_DM_PLUGIN_COMMAND_T* cmdType,
+ DMBuffer *cmdURI,
+ SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T * attribute,
+ DMAddNodeProp* props,
+ UINT8* stopByte);
+
+ /* Read a log record from the commit log file */
+ SYNCML_DM_RET_STATUS_T readOneCommitLogRecord(SYNCML_DM_COMMAND_T* cmdType,
+ DMBuffer *sourceFileName,
+ DMBuffer *targetFileName,
+ UINT8* stopByte);
+ /* Operators to allocate and delete memory for operation */
+ void* operator new(size_t sz);
+ void operator delete(void* buf);
+
+private:
+ SYNCML_DM_RET_STATUS_T skipTag(UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readLen(UINT32 *pLen);
+
+ SYNCML_DM_RET_STATUS_T readOpaqueTag(UINT8* pByte, UINT8 *pBuffer, UINT8 nSize);
+
+ SYNCML_DM_RET_STATUS_T readOpaqueTag(UINT8* pByte, DMBuffer * pBuffer);
+
+ SYNCML_DM_RET_STATUS_T checkNextByteIsEndTag(UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readNodeName(DMAddNodeProp* nodeProps, UINT8* pByte);
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T readESNFileName(DMAddNodeProp* nodeProps, UINT8* pByte);
+#endif
+ SYNCML_DM_RET_STATUS_T readAccess(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readScope(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readClassID(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readFormat(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readFormatOld(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readMime(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readData(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readOPiData(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readTitle(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readFlag(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ SYNCML_DM_RET_STATUS_T readTStamp(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readIntTStamp(DMAddNodeProp* nodeProps, UINT8* pByte);
+
+ SYNCML_DM_RET_STATUS_T readVersion(DMAddNodeProp* nodeProps, UINT8* pByte);
+#endif
+};
+
+#endif /* SYNCML_DM_WBXMLREADER_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLWriter.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLWriter.H
new file mode 100644
index 0000000..c0f1ceb
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_WBXMLWriter.H
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_WBXMLWRITER_H
+#define SYNCML_DM_WBXMLWRITER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "SyncML_DM_Writer.H"
+#include "dm_tree_node_class.H"
+
+class SyncML_DM_WBXMLWriter : public SyncML_DM_Writer
+{
+ public:
+
+ /* Class constructor */
+ SyncML_DM_WBXMLWriter(DMFileHandler* fileHandle) : SyncML_DM_Writer(fileHandle) { }
+
+ /* Write a byte of data into the file handle */
+ virtual SYNCML_DM_RET_STATUS_T writeByte(UINT8 bYte);
+
+ /* Write a string into the file handle using opaque */
+ virtual SYNCML_DM_RET_STATUS_T writeString(CPCHAR string);
+
+ /* Write opaque data into the file handle */
+ SYNCML_DM_RET_STATUS_T writeOpaque(const UINT8* data, UINT32 len);
+
+ /* Write raw data string without WBXML encodings */
+ SYNCML_DM_RET_STATUS_T writeData(const UINT8* data, UINT8 len);
+
+ /* Write a tree node of type DMNode into the file handle */
+ //SYNCML_DM_RET_STATUS_T writeNode(const DMNode* pNode);
+
+ /* Write a tree node of type DMAddNodeProp into the file handle */
+ SYNCML_DM_RET_STATUS_T writeNode(const DMNode* node);
+
+ /* Operators to allocate and delete memory for operation */
+ void* operator new(size_t sz);
+ void operator delete(void* buf);
+
+ static const int MAX_OPAQUE_STRING_LENGTH;
+
+};
+
+#endif /* SYNCML_DM_WBXMLWRITER_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Writer.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Writer.H
new file mode 100644
index 0000000..a6fa38b
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_DM_Writer.H
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_WRITER_H
+#define SYNCML_DM_WRITER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "SyncML_DM_FileHandle.H"
+
+class SyncML_DM_Writer
+{
+
+ public:
+
+ /* Class constructor */
+ SyncML_DM_Writer(DMFileHandler* handle) : fileHandle(handle){ }
+
+ /* Class destructor */
+ virtual ~SyncML_DM_Writer(){ }
+
+ /* Accessor for setting the file handle used by this class */
+ virtual void setFileHandle(DMFileHandler* fileHandle){ this->fileHandle = fileHandle; }
+
+ /* write a byte into the file
+ * implementations of this class will take advantage of this method
+ */
+ virtual SYNCML_DM_RET_STATUS_T writeByte(UINT8 bYte) = 0;
+
+ /* write a string into the file
+ * implementations of this class will take advantage of this method
+ */
+ virtual SYNCML_DM_RET_STATUS_T writeString(CPCHAR string) = 0;
+
+ protected:
+
+ /* file handle used by class' utility methods */
+ DMFileHandler* fileHandle;
+
+};
+
+#endif /* SYNCML_DM_WRITER_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/SyncML_Log.H b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_Log.H
new file mode 100644
index 0000000..2ca087f
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/SyncML_Log.H
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_Log_H
+#define SYNCML_Log_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SyncML_Log.H
+
+ General Description: This file contains the declaration for the SyncML_Log class.
+==================================================================================================*/
+
+#include "syncml_dm_data_types.h"
+#include "dmMemory.h"
+#include "SyncML_DM_FileHandle.H"
+
+/*==================================================================================================
+CLASS DECLARATION
+==================================================================================================*/
+class SyncML_Log
+{
+ public:
+ /* Class constructor */
+ SyncML_Log();
+
+ /* Class destructor */
+ virtual ~SyncML_Log();
+
+ // Open log file and create one if the file doesn't exist
+ virtual SYNCML_DM_RET_STATUS_T InitLog(CPCHAR logFileName);
+
+ // Uninitialize log
+ virtual SYNCML_DM_RET_STATUS_T UnInitLog();
+
+ /* Take each entry in the log file and play it on the tree (by passing to
+ * the tree and node manager) according to logic based on flags in the log entry
+ */
+ virtual SYNCML_DM_RET_STATUS_T playLog() = 0;
+ virtual SYNCML_DM_RET_STATUS_T playLog(CPCHAR logFileName);
+
+ virtual SYNCML_DM_RET_STATUS_T RemoveLog();
+
+ virtual SYNCML_DM_RET_STATUS_T CloseLog();
+
+ /* Accessors for the file handle associated with this log */
+ virtual DMFileHandler* getLogFileHandle();
+ virtual SYNCML_DM_RET_STATUS_T setLogFileHandle(DMFileHandler *fileHandle);
+
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+ protected:
+ DMFileHandler *fileHandle;
+
+};
+
+#endif /* SYNCML_Log_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/dmBufferReader.h b/engine/dmlib/dmengine/dm_persist/hdr/dmBufferReader.h
new file mode 100644
index 0000000..fcff837
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/dmBufferReader.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMBUFFERREADER_H
+#define DMBUFFERREADER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "dmtDefs.h"
+#include "dmMemory.h"
+
+/**
+ * DMBufferReader represents a class that reads data from a binary buffer.
+ */
+class DMBufferReader
+{
+ public:
+ /**
+ * Constructor that initilizes object
+ * \param pBuffer [in] - pointer on a buffer
+ * \param size [in] - size of a buffer
+ */
+ DMBufferReader(UINT8 * pBuffer, UINT32 size);
+
+ /**
+ * Reads line from a buffer
+ * \return Return Type (char *)
+ * returns pointer on next line, or NULL if end of a buffer is reached
+ */
+ char * fgets();
+
+ /**
+ * Checks if end of a buffer is reached
+ * \return TRUE if end is reached
+ */
+ BOOLEAN iseof();
+
+ /**
+ * Operator to allocate memory
+ * \param sz [in] - number of bytes to be allocated
+ */
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ /**
+ * Operator to free memory
+ * \param buf [in] - pointer on buffer to be freed
+ */
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+ /**
+ * Reads string from a buffer
+ */
+ CPCHAR ReadString();
+
+ /**
+ * Reads one byte from a buffer
+ */
+ UINT8 ReadUINT8();
+
+ /**
+ * Reads two bytes from a buffer
+ */
+ UINT16 ReadUINT16();
+
+ /**
+ * Reads integer from a buffer
+ */
+ UINT32 ReadUINT32();
+
+ /**
+ * Retrieves size of a buffer
+ */
+ inline UINT32 GetSize() const { return m_nSize; }
+
+ private:
+ /* Pointer on a buffer */
+ UINT8 * m_pBuffer;
+ /* Size of a buffer */
+ UINT32 m_nSize;
+ /* Current position in a buffer */
+ UINT32 m_nPos;
+
+ /**
+ * Reads specified number of bytes from a buffer
+ * \param pBuffer [out] - pointer on a buffer to read into
+ * \param count [in] - number of bytes to read
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Read(UINT8 * pBuffer, UINT32 count);
+
+};
+
+#endif /* DM_BUFFERREADER_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/dmBufferWriter.h b/engine/dmlib/dmengine/dm_persist/hdr/dmBufferWriter.h
new file mode 100644
index 0000000..c52ddfe
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/dmBufferWriter.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMBUFFERWRITER_H
+#define DMBUFFERWITER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: dmBufferReader.h
+
+ General Description: This file contains the declaration of the DMBufferReader class.
+
+==================================================================================================*/
+
+#include "dmtDefs.h"
+#include "dmMemory.h"
+#include "dmstring.h"
+
+/**
+ * DMBufferWriter represents a class that writes into a binary buffer.
+ */
+class DMBufferWriter
+{
+ public:
+ /**
+ * Default constructor that initilizes object
+ */
+ DMBufferWriter();
+
+ /**
+ * Destructor
+ */
+ ~DMBufferWriter();
+
+ /**
+ * Operator to allocate memory
+ * \param sz [in] - number of bytes to be allocated
+ */
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ /**
+ * Operator to free memory
+ * \param buf [in] - pointer on buffer to be freed
+ */
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+ /**
+ * Retrieves pointer on a internal buffer
+ */
+ inline UINT8 * GetBuffer() const { return m_pBuffer; }
+
+ /**
+ * Retrieves size of a buffer
+ */
+ inline UINT32 GetSize() const { return m_nSize; }
+
+ /**
+ * Allocates internal buffer
+ * \param size [in] - number of bytes to allocate
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Allocate(UINT32 size);
+
+ /**
+ * Writes string into a buffer
+ * \param str [in] - string to write
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T WriteString(const DMString & str);
+
+ /**
+ * Writes string into a buffer
+ * \param str [in] - string to write
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T WriteString(CPCHAR str);
+
+ /**
+ * Writes integer into a buffer
+ * \param data [in] - integer to write
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T WriteUINT32(UINT32 data);
+
+ /**
+ * Writes byte into a buffer
+ * \param data [in] - byte to write
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T WriteUINT8(UINT8 data);
+
+ /**
+ * Writes two bytes into a buffer
+ * \param data [in] - short to write
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T WriteUINT16(UINT16 data);
+
+ private:
+ /* Pointer on a buffer */
+ UINT8 * m_pBuffer;
+ /* Size of a buffer */
+ UINT32 m_nSize;
+ /* Current position in a buffer */
+ UINT32 m_nPos;
+
+ /**
+ * Writes specified number of bytes into a buffer
+ * \param pBuffer [out] - pointer on a buffer to write from
+ * \param count [in] - count of bytes to write
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Write(UINT8 * pBuffer, UINT32 count);
+
+};
+
+#endif /* DM_BUFFERREADER_H */
diff --git a/engine/dmlib/dmengine/dm_persist/hdr/file_manager.h b/engine/dmlib/dmengine/dm_persist/hdr/file_manager.h
new file mode 100644
index 0000000..8c1e2aa
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/hdr/file_manager.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __FILE_MANAGER__H__
+#define __FILE_MANAGER__H__
+
+#include "syncml_dm_data_types.h" //For DM data type definitions
+#include "dmt.hpp"
+#include "dmdefs.h"
+
+// assume that we support 32 or less files, so we can pass "file set" as an integer (32 bits)
+// every bit means file "selected" if it set. For example, value 6, binary 0110 means files "1" and "2"
+// Bit 0 is file0, bit 1 is file1, bit is file 2
+typedef UINT32 FILESETTYPE;
+
+#define FILESET_ALLFILES 0xFFFFFFFF
+
+class DMTree;
+
+class CMultipleFileManager
+{
+public:
+ CMultipleFileManager();
+
+ virtual SYNCML_DM_RET_STATUS_T Init( DMTree* tree );
+ virtual SYNCML_DM_RET_STATUS_T DeInit();
+
+ virtual ~CMultipleFileManager() ;
+
+ virtual int GetFileNumber() const ;
+
+ virtual FILESETTYPE GetFileSetByURI( CPCHAR szURI, BOOLEAN bSharedLock ) const ;
+
+ virtual SYNCML_DM_RET_STATUS_T LockFileSet(CPCHAR szURI,
+ FILESETTYPE nFileSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType) ;
+
+ virtual SYNCML_DM_RET_STATUS_T UnlockFileSet(CPCHAR szURI,
+ FILESETTYPE nFileSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType) ;
+
+ virtual SYNCML_DM_RET_STATUS_T RollbackFileSet(CPCHAR szURI, FILESETTYPE nFileSet ) ;
+
+ virtual SYNCML_DM_RET_STATUS_T FlushFileSet(CPCHAR szURI, FILESETTYPE nFileSet ,SYNCML_DM_COMMAND_T type);
+
+private:
+ DMTree *m_pTree;
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_persist/src/SyncML_Commit_Log.cc b/engine/dmlib/dmengine/dm_persist/src/SyncML_Commit_Log.cc
new file mode 100644
index 0000000..c260982
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/SyncML_Commit_Log.cc
@@ -0,0 +1,428 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SyncML_DM_WBXMLArchive.H"
+#include "SyncML_Commit_Log.H"
+#include "dm_uri_utils.h"
+
+/*==================================================================================================
+
+Function: SyncML_Commit_Log::SyncML_Commit_Log
+
+Description: Constructor for the Log object
+
+==================================================================================================*/
+SyncML_Commit_Log::SyncML_Commit_Log():SyncML_Log()
+{
+ reader = NULL;
+ writer = NULL;
+}
+
+/*==================================================================================================
+
+Function: SyncML_Commit_Log::~SyncML_Commit_Log
+
+Description: Destructor for the Log object
+
+==================================================================================================*/
+SyncML_Commit_Log::~SyncML_Commit_Log()
+{
+ if(reader != NULL)
+ {
+ delete reader;
+ reader = NULL;
+ }
+
+ if(writer != NULL)
+ {
+ delete writer;
+ writer = NULL;
+ }
+}
+ /*==================================================================================================
+
+ Function: UnInitLog
+
+ Description: Uninitialize log
+
+ ==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_Commit_Log::UnInitLog()
+{
+ if(reader != NULL)
+ {
+ delete reader;
+ reader = NULL;
+ }
+
+ if(writer != NULL)
+ {
+ delete writer;
+ writer = NULL;
+ }
+ return SyncML_Log::UnInitLog();
+ }
+ /*============================================================================n
+
+ Function: SyncML_Commit_Log::CloseLog
+
+ Description: Write end of log tag log file and close it.
+
+
+ Notes:
+
+ ================================================================================*/
+ SYNCML_DM_RET_STATUS_T SyncML_Commit_Log::CloseLog()
+{
+ /* Write the end tag for the root node, then end tag for the MgmtTree */
+ UINT8 endTags[2] = { SyncML_DM_WBXMLArchive::END_TAG, SyncML_DM_WBXMLArchive::END_TAG };
+
+ if( fileHandle == NULL)
+ return SYNCML_DM_SUCCESS;
+
+ if(writer == NULL)
+ {
+ writer = new SyncML_DM_WBXMLWriter(this->fileHandle);
+ if(writer == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ // Go to end of log file
+ if(fileHandle->seek(XPL_FS_SEEK_END, 0) != SYNCML_DM_SUCCESS)
+ {
+ SyncML_Log::CloseLog();
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ if(writer->writeData(&endTags[0], 2) != SYNCML_DM_SUCCESS)
+ {
+ SyncML_Log::CloseLog();
+ return SYNCML_DM_IO_FAILURE;
+ }
+ return SyncML_Log::CloseLog();
+}
+ /*============================================================================n
+
+ Function: SyncML_Commit_Log::logCommand
+
+ Description: logs the command type, URI, node properties and recovery field for
+ a command in the log file.
+
+ Memory: The caller is responsible for freeing the SyncML_DM_Command object
+
+ Notes:
+
+ ================================================================================*/
+ SYNCML_DM_RET_STATUS_T
+ SyncML_Commit_Log::logCommand(SYNCML_DM_COMMAND_T commandType,
+ CPCHAR pSourceFileName,
+ CPCHAR pTargetFileName)
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ UINT8 ioArray[5] = { SyncML_DM_WBXMLArchive::ENTRY_START_TAG |
+ SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK,
+ SyncML_DM_WBXMLArchive::CMDTYPE_START_TAG |
+ SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK,
+ commandType,
+ SyncML_DM_WBXMLArchive::END_TAG,
+ SyncML_DM_WBXMLArchive::TARGET_FILE_TAG |
+ SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK};
+
+ // Check if the command is valid
+ if( commandType != SYNCML_DM_DELETE &&
+ commandType != SYNCML_DM_REPLACE)
+ {
+ return SYNCML_DM_FAIL;
+ }
+ if(writer == NULL)
+ {
+ writer = new SyncML_DM_WBXMLWriter(this->fileHandle);
+ if(writer == NULL)
+ {
+ ret_code = SYNCML_DM_DEVICE_FULL;
+ goto commitlogfailed;
+ }
+ }
+ if( fileHandle == NULL || pTargetFileName == NULL)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogfailed;
+ }
+ // Go to end of log file
+ if(this->fileHandle->seek(XPL_FS_SEEK_END, 0) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogfailed;
+ }
+
+ if(writer->writeData(ioArray, sizeof(ioArray)) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogfailed;
+}
+
+if(writer->writeString(pTargetFileName) != SYNCML_DM_SUCCESS)
+{
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogfailed;
+}
+
+/* End of the URI field */
+if(writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+{
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogfailed;
+}
+// Special case for SYNCML_DM_REPLACE command
+if( commandType == SYNCML_DM_REPLACE)
+{
+ // Write original file name
+ if(DmStrlen(pSourceFileName) ==0)
+ {
+ /* End of the URI field */
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogfailed;
+ }
+ }
+ else
+ {
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::SOURCE_FILE_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writer->writeString(pSourceFileName) != SYNCML_DM_SUCCESS ||
+ writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogfailed;
+ }
+ }
+}
+ return ret_code;
+
+commitlogfailed:
+ if(writer != NULL)
+ { delete writer;
+ writer = NULL;
+ }
+ if(fileHandle)
+ {
+ this->fileHandle->close();
+ }
+ return ret_code;
+ }
+ /*===============================================================================================
+
+ Function: SyncML_Commit_Log::renameESNfile
+
+ Description: Remove the .cmt suffix from ESN file
+
+ Returns: SYNCML_DM_IO_FAILURE - could not perform an I/O operation
+ SYNCML_DM_LOG_CORRUPT - there was an invalid byte read
+ SYNCML_DM_SUCCESS
+ SYNCML_DM_FILE_NOT_FOUND - could not find the log file
+
+ ==================================================================================================*/
+ SYNCML_DM_RET_STATUS_T SyncML_Commit_Log::renameESNfile(CPCHAR pTargetFileName, DMFileHandler &handler)
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ DMString fileName;
+ fileName.RemoveSufix(pTargetFileName, SYNCML_DM_DOT);
+ if (handler.rename(fileName.c_str()) != SYNCML_DM_SUCCESS)
+ ret_code = SYNCML_DM_IO_FAILURE;
+
+ handler.close();
+ return ret_code;
+}
+ /*===============================================================================================
+
+ Function: playbackOneRecord
+
+ Description: Playback one commit log record
+
+ Returns: SYNCML_DM_IO_FAILURE - could not perform an I/O operation
+ SYNCML_DM_LOG_CORRUPT - there was an invalid byte read
+ SYNCML_DM_SUCCESS
+ SYNCML_DM_FILE_NOT_FOUND - could not find the log file
+
+ ==================================================================================================*/
+ SYNCML_DM_RET_STATUS_T SyncML_Commit_Log::playbackOneRecord(SYNCML_DM_COMMAND_T commandType,
+ CPCHAR pSourceFileName,
+ CPCHAR pTargetFileName)
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ // No any log entry
+ if(commandType == SYNCML_DM_NO_COMMAND)
+ return SYNCML_DM_SUCCESS;
+
+ if (!XPL_FS_Exist(pTargetFileName))
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+
+ DMFileHandler targetHandle(pTargetFileName);
+ ret_code = targetHandle.open(XPL_FS_FILE_RDWR);
+ if(ret_code != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_SUCCESS;
+
+ switch(commandType)
+ {
+ // Delete the lob file
+ case SYNCML_DM_DELETE:
+ ret_code = targetHandle.deleteFile();
+ break;
+
+ // Delete the lob file
+ case SYNCML_DM_REPLACE:
+ // Delete the target file first
+ if(pSourceFileName != NULL)
+ {
+ DMFileHandler sourceHandle(pSourceFileName);
+ ret_code = sourceHandle.open(XPL_FS_FILE_RDWR);
+ if(ret_code == SYNCML_DM_SUCCESS)
+ sourceHandle.deleteFile();
+
+ if (targetHandle.rename(pSourceFileName) != SYNCML_DM_SUCCESS)
+ ret_code = SYNCML_DM_IO_FAILURE;
+ targetHandle.close();
+ }
+ else
+ ret_code = renameESNfile(pTargetFileName, targetHandle);
+ break;
+ default:
+ targetHandle.close();
+ ret_code = SYNCML_DM_FAIL;
+ break;
+ }
+ return ret_code;
+}
+
+ /*===============================================================================================
+
+ Function: SyncML_Commit_Log::playLog
+
+ Description: This function provides log looping for log playback and recovery
+ purposes. If the isRecovery field is set the function performs
+ calls to recovery functions for the log entries in the log file.
+ Otherwise, the function does log playback to the Tree and node
+ manager.
+
+ Returns: SYNCML_DM_IO_FAILURE - could not perform an I/O operation
+ SYNCML_DM_LOG_CORRUPT - there was an invalid byte read
+ SYNCML_DM_SUCCESS
+ SYNCML_DM_FILE_NOT_FOUND - could not find the log file
+
+ ==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_Commit_Log::playLog()
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ DMBuffer cmdURI;
+ DMAddNodeProp props;
+
+ UINT8 bYte;
+
+ if (reader == NULL)
+ {
+ reader = new SyncML_DM_WBXMLReader(this->fileHandle);
+ if (reader == NULL)
+ {
+ ret_code = SYNCML_DM_DEVICE_FULL;
+ goto commitlogplayfinished;
+ }
+ }
+ if (fileHandle == NULL)
+ {
+ ret_code = SYNCML_DM_FAIL;
+ goto commitlogplayfinished;
+ }
+
+ // Goto the entry
+ if (this->fileHandle->seek(XPL_FS_SEEK_SET, 0) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogplayfinished;
+ }
+ // Read the first byte of data looking for an ENTRY_START_TAG
+ if (reader->readByte(&bYte) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogplayfinished;
+ }
+ while (1)
+ {
+ if (bYte == SyncML_DM_WBXMLArchive::END_TAG)
+ {
+ /* Signifies the end of the log file */
+ break;
+ }
+ else
+ {
+ if (bYte == (SyncML_DM_WBXMLArchive::ENTRY_START_TAG
+ | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ {
+ SYNCML_DM_COMMAND_T cmdType;
+ DMBuffer sourceFileName;
+ DMBuffer targetFileName;
+ if (reader->readOneCommitLogRecord(&cmdType, &sourceFileName, &targetFileName,
+ &bYte) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogplayfinished;
+ }
+
+ ret_code = playbackOneRecord(cmdType, (CPCHAR)sourceFileName.getBuffer(),
+ (CPCHAR)targetFileName.getBuffer());
+
+ // Continue playing back the log even if the command fails
+ if (ret_code == SYNCML_DM_IO_FAILURE)
+ {
+ break;
+ }
+ // Read the first byte of data looking for an ENTRY_START_TAG
+ if (reader->readByte(&bYte) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto commitlogplayfinished;
+ }
+ }
+ }
+ }
+
+ commitlogplayfinished:
+
+ if (reader != NULL)
+ {
+ delete reader;
+ reader = NULL;
+ }
+
+ if (writer != NULL)
+ {
+ delete writer;
+ writer = NULL;
+ }
+ return ret_code;
+}
+
+/*==================================================================================================
+
+Function: SyncML_Commit_Log::playLog
+
+Description: Log file playback and remove
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_Commit_Log::playLog(CPCHAR logFileName)
+{
+ return SyncML_Log::playLog(logFileName);
+}
diff --git a/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_Archive.cc b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_Archive.cc
new file mode 100644
index 0000000..49292d5
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_Archive.cc
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dm_tree_class.H"
+#include "dm_uri_utils.h"
+#include "SyncML_DM_Archive.H"
+#include "xpl_Logger.h"
+#include "dm_uri_utils.h"
+
+/*==================================================================================================
+
+Function: SyncML_DM_Archive::SyncML_DM_Archive
+
+Description: The SyncML_DM_Archive class constructor.
+
+==================================================================================================*/
+SyncML_DM_Archive::SyncML_DM_Archive(CEnv* env, CPCHAR pURI, CPCHAR path)
+ : m_pURI(pURI),
+ m_path(path)
+{
+ rootTreeNode=NULL;
+ parent=NULL;
+ dirty = FALSE;
+ m_bWritableExist = FALSE;
+ m_permission = -1;
+
+ env->GetWFSFullPath(path,m_strWFSFileName);
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_Archive::~SyncML_DM_Archive
+
+Description: The SyncML_DM_Archive class deconstructor.
+
+==================================================================================================*/
+SyncML_DM_Archive::~SyncML_DM_Archive()
+{
+ if ( rootTreeNode )
+ rootTreeNode->pArchive = NULL;
+}
+
+void
+SyncML_DM_Archive::getFilePath(char * path, CPCHAR ext)
+{
+ DmStrcpy(path, m_strWFSFileName);
+ DmStrcat(path, ext);
+}
+
+BOOLEAN
+SyncML_DM_Archive::LoadSkeleton(DMTree* pTree)
+{
+ if ( rootTreeNode )
+ return TRUE;
+
+ rootTreeNode = pTree->CreateSkeletonNode( getURI() );
+
+ if ( rootTreeNode )
+ rootTreeNode->pArchive = this;
+ else
+ return FALSE;
+
+ return TRUE;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_Archive::Init(DMTree* pTree)
+{
+ if ( !pTree )
+ return SYNCML_DM_FAIL;
+
+ m_pTree = pTree;
+ return oEventLogger.Init(pTree);
+
+}
+
+void
+SyncML_DM_Archive::setLastAccessedTime(XPL_CLK_CLOCK_T lastAccessedTime)
+{
+ m_lastAccessedTime = lastAccessedTime;
+}
+
+XPL_CLK_CLOCK_T
+SyncML_DM_Archive::getLastAccessedTime()
+{
+ return m_lastAccessedTime;
+}
diff --git a/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_Archiver.cc b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_Archiver.cc
new file mode 100644
index 0000000..ebcfd52
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_Archiver.cc
@@ -0,0 +1,813 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SyncML_DM_Archiver.H"
+#include "SyncML_DM_WBXMLArchive.H"
+#include "xpl_Logger.h"
+#include "dm_tree_class.H"
+#include "dm_uri_utils.h"
+#include "dm_tree_plugin_util.H" //for Util function defns
+#include "dmprofile.h"
+#include "dmLockingHelper.h"
+#include "dmtTreeImpl.hpp"
+
+#ifdef TEST_DM_RECOVERY
+char power_fail_point[20] = {0};
+#endif
+
+SyncML_DM_Archiver::SyncML_DM_Archiver()
+ : m_numArchives( 0 ),
+ m_pTree( NULL ),
+ m_pEnv( NULL )
+{
+ // [0] is always root archive
+
+ for( int i = 0; i < MAX_ARCHIVES; ++i )
+ {
+ m_pArchives[ i ] = NULL;
+ }
+}
+
+SYNCML_DM_RET_STATUS_T SyncML_DM_Archiver::initArchives( CEnv* env, DMTree* tree )
+{
+ SYNCML_DM_RET_STATUS_T retStat=SYNCML_DM_SUCCESS;
+
+ if( !tree || !env ) return SYNCML_DM_FAIL;
+ m_pTree = tree;
+ m_pEnv = env;
+
+ //Load All the archives
+ m_numArchives=0;
+ m_pArchives[0]=NULL;
+
+ //Load from TreeMountList and new all the Archives
+ const char *pEntryTreePath = NULL;
+ const char *pEntryURI = NULL;
+
+ INT32 i = 0; //tree mount start from 0
+
+ // Get the first mount list entry
+ m_pTree->GetTreeMountEntry(pEntryURI, pEntryTreePath, i);
+
+ while(pEntryURI != NULL && pEntryTreePath != NULL)
+ {
+ /* Create the archive if it exists in the mount list */
+ m_pArchives[m_numArchives]=NULL;
+
+ if ( DmStrlen(pEntryTreePath) )
+ {
+ m_pArchives[m_numArchives]=new SyncML_DM_WBXMLArchive(env, pEntryURI, pEntryTreePath);
+
+ if ( !m_pArchives[m_numArchives] )
+ return SYNCML_DM_DEVICE_FULL;
+
+ if ( m_pArchives[m_numArchives]->Init(tree) != SYNCML_DM_SUCCESS )
+ return SYNCML_DM_FAIL;
+
+ // XPL_LOG_DM_TMN_Debug(("pEntryURI=%s, archive=%x\n", pEntryURI, m_pArchives[m_numArchives]));
+
+ INT32 parentindex=-1;
+ INT32 parentlen=0;
+ for (INT32 j=0; j< m_numArchives; j++)
+ {
+ if ( DmStrstr(pEntryURI, m_pArchives[j]->getURI())== pEntryURI)
+ {
+ INT32 len=DmStrlen(m_pArchives[j]->getURI());
+
+ if (parentlen < len)
+ {
+ parentlen=len;
+ parentindex=j;
+ }
+ }
+ }
+
+ if (parentindex >=0)
+ m_pArchives[m_numArchives]->setParentArchive(m_pArchives[parentindex]);
+
+ m_numArchives++;
+ //Does not support More than 32 archives...
+ if (m_numArchives >=32)
+ break;
+ }
+
+ /* In case the GetTreeMountEntry service has an error,
+ * Ensure these are sensible values going in
+ */
+ pEntryURI = NULL;
+ pEntryTreePath = NULL;
+ m_pTree->GetTreeMountEntry(pEntryURI, pEntryTreePath, ++i);
+ }
+
+ if (m_numArchives ==0)
+ retStat=SYNCML_DM_FAIL;
+
+ XPL_LOG_DM_TMN_Debug(("m_numArchives=%d\n", m_numArchives));
+
+#ifdef TEST_DM_RECOVERY
+ if(XPL_DM_GetEnv(SYNCML_DM_POWER_FAIL_IJECTION) != NULL) {
+ strcpy((char *)power_fail_point, (const char *)XPL_DM_GetEnv(SYNCML_DM_POWER_FAIL_IJECTION));
+ XPL_LOG_DM_TMN_Debug(("Power Fail Injected at: %s\n", power_fail_point));
+ }
+#endif
+
+ return retStat;
+}
+
+// A helper method for making sure that ALL archives is freed
+SYNCML_DM_RET_STATUS_T SyncML_DM_Archiver::deinitArchives()
+{
+ SYNCML_DM_RET_STATUS_T retStat=SYNCML_DM_SUCCESS;
+
+ //serialize if needed, Do we need to do so ? The lock manager should have already do it.
+
+ //delete the archives
+ for (int i=0; i<m_numArchives; i++)
+ {
+ if ( m_pArchives[i] !=NULL)
+ {
+ delete m_pArchives[i];
+ m_pArchives[i]=NULL;
+ }
+ }
+
+ m_numArchives = 0;
+ m_pTree = NULL;
+ m_pEnv = NULL;
+
+ return retStat;
+}
+
+
+/*==================================================================================================
+
+Function: SyncML_DM_Archiver::serialize
+
+Description: Distributes a serialization request to the proper archive(s). A search is performed
+ for the right archive relative to the root archive. All tree data will be serialized
+ to the point possible.
+
+Returns: SYNCML_DM_FAIL - tree or archive objects are NULL or an unspecified error occurred
+ SYNCML_DM_SUCCESS - tree was successfully serialized to proper files
+ SYNCML_DM_TREE_CORRUPT - tree storage entity was corrupt to the point where
+ serialization was partially or completely impossible
+ SYNCML_DM_IO_FAILURE - I/O failure occured while trying to write to the file handle
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_Archiver::serialize(FILESETTYPE nFileSet, CPCHAR szURI)
+{
+ DMGlobalLockHelper oGlobalLock; // protect serialize/recovery from multi process access
+ FILESETTYPE set=1;
+ SYNCML_DM_RET_STATUS_T retStat=SYNCML_DM_SUCCESS;
+ INT32 i=0;
+
+ if( !m_pTree ) return SYNCML_DM_FAIL;
+
+ XPL_LOG_DM_TMN_Debug(("Enter to serialize\n"));
+
+ for (i=0; i< m_numArchives && m_pArchives[i] !=NULL; i++)
+ {
+ if ( (nFileSet & set) !=0 ) {
+ if (m_pArchives[i]->isDirty()) {
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "DMTR_PF1") == 0)) {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+ XPL_LOG_DM_TMN_Debug(("m_pArchives[%d] %s is dirty, to be serialized", i, m_pArchives[i]->getURI()));
+ retStat=m_pArchives[i]->serialize(m_pTree);
+ XPL_LOG_DM_TMN_Debug(("serialize retStat = %d", retStat));
+ if (retStat != SYNCML_DM_SUCCESS )
+ break;
+ }
+ }
+ set = set <<1;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("serialize retStat = %d", retStat));
+ if (retStat != SYNCML_DM_SUCCESS )
+ return retStat;
+
+ /* Begin the power loss-tolerant steps to protect against a partially written Archive file:
+ * 1. Rename the original file by adding ".bak" to the name; this indicates the .temp file
+ * was completely written
+ * 2. Rename the .temp file to the original name (i.e., without the .temp extention)
+ * 3. Delete the .bak file
+ */
+ DMString strOrgFilePathBuffer, strTmpFilePathBuffer, strBakFilePathBuffer;
+
+ char *orgFilePath = strOrgFilePathBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+ char *tmpFilePath =strTmpFilePathBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+ char *bakFilePath = strBakFilePathBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+ XPL_FS_RET_STATUS_T ret=0;
+ BOOLEAN bAtLeastOneDirty = FALSE; // check if at least one change exist to invoke commit plug-in
+
+ if ( !orgFilePath || !tmpFilePath || !bakFilePath)
+ return SYNCML_DM_DEVICE_FULL;
+
+
+ // 2nd Change File names, orig->bak
+ for (i=0, set=1; i< m_numArchives && m_pArchives[i] !=NULL; i++, set = set <<1)
+ {
+ if ( (nFileSet & set) !=0 && m_pArchives[i]->isDirty() && m_pArchives[i]->isWritableExist() )
+ {
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "DMTR_PF2") == 0)) {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+#ifdef LOB_SUPPORT
+ retStat = m_pArchives[i]->CloseCommitLog();
+ if (retStat != SYNCML_DM_SUCCESS )
+ return retStat;
+#endif
+ m_pArchives[i]->getFilePath(orgFilePath, "");
+ m_pArchives[i]->getFilePath(bakFilePath, ".bak");
+ ret=XPL_FS_Rename( orgFilePath, bakFilePath );
+ if (ret != XPL_FS_RET_SUCCESS)
+ {
+ ret=XPL_FS_Rename( orgFilePath, bakFilePath );
+ retStat=SYNCML_DM_IO_FAILURE;
+ break;
+ }
+ }
+ }
+
+ for (i=0, set=1; i< m_numArchives && m_pArchives[i] !=NULL; i++, set = set <<1)
+ {
+ if ( (nFileSet & set) !=0 && m_pArchives[i]->isDirty() )
+ {
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "DMTR_PF3") == 0)) {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+
+ bAtLeastOneDirty = TRUE;
+
+ m_pArchives[i]->getFilePath(tmpFilePath, ".temp");
+ m_pArchives[i]->getFilePath(orgFilePath, "");
+ m_pArchives[i]->getFilePath(bakFilePath, ".bak");
+ ret=XPL_FS_Rename(tmpFilePath, orgFilePath);
+ if (ret != XPL_FS_RET_SUCCESS)
+ {
+ ret=XPL_FS_Rename(bakFilePath, orgFilePath);
+ retStat=SYNCML_DM_IO_FAILURE;
+ break;
+ }
+ }
+ }
+
+ // commit plug-in support - invoke it only when some changes were done
+ if ( bAtLeastOneDirty )
+ InvokeCommitPlugins( nFileSet, szURI );
+
+ for (i=0, set=1; i< m_numArchives && m_pArchives[i] !=NULL; i++, set = set <<1)
+ {
+ //set dirty to false
+ if ( (nFileSet & set) !=0 && m_pArchives[i]->isDirty() )
+ {
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "DMTR_PF4") == 0)) {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+#ifdef LOB_SUPPORT
+ // Commit changes for ESN
+ retStat=m_pArchives[i]->commitESN(m_pTree);
+#endif
+ m_pArchives[i]->setDirty(false);
+
+ //Let each archive finished its own task, reset timestamp etc.
+ m_pArchives[i]->serializeDone();
+ XPL_LOG_DM_TMN_Debug(("serializeDone for %s\n", orgFilePath));
+
+ if ( m_pArchives[i]->isWritableExist() )
+ {
+ m_pArchives[i]->getFilePath(bakFilePath, ".bak");
+
+#ifndef DM_NO_LOCKING
+ ret=XPL_FS_Unlink(bakFilePath);
+#else
+ ret=XPL_FS_Remove(bakFilePath);
+#endif
+ XPL_LOG_DM_TMN_Debug(("delete archives[%d] %s ret=%d\n", i, bakFilePath, ret));
+ if (ret != XPL_FS_RET_SUCCESS)
+ {
+ retStat = SYNCML_DM_IO_FAILURE;
+ break;
+ }
+ }
+ }
+ if ( (nFileSet & set) !=0 && m_pArchives[i]->isDirty() )
+ m_pArchives[i]->setWritableExist(TRUE);
+
+ }
+
+ return retStat;
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_Archiver::deserialize
+
+Description: Distributes a deserialization request to the proper archive(s). Each archive (starting
+ with the root archive) will deserialize into the DM T/N Manager using the AddNode
+ method for passing nodes.
+
+Returns: SYNCML_DM_FAIL - tree or archive objects are NULL or an unspecified error occured
+ SYNCML_DM_SUCCESS - tree was successfully deserialized from proper files
+ SYNCML_DM_TREE_CORRUPT - tree storage entity was corrupt to the point where
+ deserialization was partially or completely impossible
+ SYNCML_DM_FILE_NOT_FOUND - file was unavailable for deserialization
+ SYNCML_DM_IO_FAILURE - I/O failure occured while trying to read from the file handle
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_Archiver::deserialize(FILESETTYPE nFileSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType)
+{
+ DMGlobalLockHelper oGlobalLock; // protect serialize/recovery from multi process access
+ FILESETTYPE set=1;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if( !m_pTree ) return SYNCML_DM_FAIL;
+
+ checkRecovery();
+
+ // do not load files itself, instead create only skeleton based on file set.
+ for (INT32 i=0; i< m_numArchives && m_pArchives[i] !=NULL; i++)
+ {
+ if ( (nFileSet & set) !=0 )
+ {
+ BOOLEAN bIsPermitted = TRUE;
+ bIsPermitted = m_pArchives[i]->verifyPermission(XPL_FS_RDONLY_MODE);
+
+ if ( bIsPermitted )
+ {
+
+ if ( !m_pArchives[i]->LoadSkeleton(m_pTree))
+ dm_stat = SYNCML_DM_DEVICE_FULL;
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if ( eLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ {
+ dm_stat = m_pArchives[i]->deserialize(m_pTree,TRUE);
+ }
+ }
+
+ m_pArchives[i]->setDirty(FALSE);
+
+ }
+ set = set <<1;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("End of all deserialize retStat=%d\n", dm_stat));
+ return dm_stat;
+}
+
+
+//Get all required Archives containing the URI
+FILESETTYPE SyncML_DM_Archiver::getArchivesByURI(CPCHAR pURI) const
+{
+ FILESETTYPE nFileSet=0;
+ FILESETTYPE set=1;
+ SyncML_DM_Archive* pArchive=NULL;
+
+ INT32 containingArchive=0;
+ INT32 containingArchiveURIlen=0;
+ BOOLEAN bContainingNeeded = TRUE;
+
+ //set = set <<1; //start from 2nd file
+ for (int i=0; i< m_numArchives; i++) //NOT detect root !
+ {
+ pArchive = m_pArchives[i];
+
+ //For now assume no recursive files
+ const char * archivePath=pArchive->getURI();
+
+ char * ptr=NULL;
+
+ //we need any file that is subtree of the pURI
+ //For example, archivePath=./abc pURI=. then
+ //if we found pURI under archivePath, we go
+ ptr=(char*)DmStrstr(archivePath, pURI );
+
+ if ( ptr !=NULL && ptr == archivePath ) {
+ nFileSet= nFileSet | set;
+ }
+
+ // in case when we hit exactly root path , we don't need parent
+ if ( DmStrcmp( archivePath, pURI ) == 0 )
+ bContainingNeeded = FALSE;
+
+ //search for longest archives that has the pURI as a childnode
+ //For example, archivePath=./abc pURI=./abc/def then
+ //if we found archivePath under pURI, we go
+ ptr=(char*)DmStrstr(pURI, archivePath );
+
+ if (ptr !=NULL && ptr == pURI) {
+ if (containingArchiveURIlen < (INT32)DmStrlen(archivePath)) {
+ containingArchive=i;
+ containingArchiveURIlen = DmStrlen(archivePath);
+ }
+ }
+
+ set = set <<1;
+ }
+
+ if ( bContainingNeeded )
+ nFileSet=nFileSet | (1 << (containingArchive)); //we need the containing archive
+
+ //Debug("Add file [%d] to set, %s\n", containingArchive, m_pArchives[containingArchive]);
+
+ return nFileSet;
+}
+
+
+
+//Get exact Archive containing the URI
+SyncML_DM_Archive* SyncML_DM_Archiver::getArchiveByURI(CPCHAR pURI) const
+{
+
+
+ FILESETTYPE nFileSet ;
+ FILESETTYPE set=1;
+ INT32 index = 0;
+
+ nFileSet = getArchivesByURI(pURI);
+
+ for (INT32 i=0; i< m_numArchives && m_pArchives[i] !=NULL; i++)
+ {
+ if ( (nFileSet & set) !=0 )
+ {
+ if ( DmIsParentURI(m_pArchives[i]->getURI(), pURI) )
+ {
+ index = i;
+ break;
+ }
+ }
+ set = set <<1;
+ }
+
+ //XPL_LOG_DM_TMN_Debug(("returning archive=%x, uri=%s\n",m_pArchives[index], pURI ));
+ return m_pArchives[index];
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_Archiver::checkRecovery
+
+Description: Resolve recovery records after a serious phone critical failure event
+
+Returns: SYNCML_DM_SUCCESS
+ SYNCML_DM_IO_FAILURE
+ SYNCML_DM_FILE_NOT_FOUND
+ SYNCML_DM_LOG_CORRUPT
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_Archiver::checkRecovery()
+{
+ if( !m_pTree ) return SYNCML_DM_FAIL;
+
+ SYNCML_DM_RET_STATUS_T retStat=SYNCML_DM_SUCCESS;
+
+ //Check and recover All nodes all at once.
+ DMString strOrgFilePathBuffer, strTmpFilePathBuffer, strBakFilePathBuffer, strCmtFilePathBuffer;
+
+ char *orgFilePath = strOrgFilePathBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+ char *tmpFilePath =strTmpFilePathBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+ char *bakFilePath = strBakFilePathBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+ char *cmtFilePath = strCmtFilePathBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+
+ if ( !orgFilePath || !tmpFilePath || !bakFilePath || !cmtFilePath)
+ return SYNCML_DM_DEVICE_FULL;
+
+ XPL_FS_RET_STATUS_T ret=0;
+
+ //Logic for checking corrupted files
+ BOOLEAN tmpFileExists=FALSE;
+ BOOLEAN bakFileExists=FALSE;
+ BOOLEAN cmtFileExists=FALSE;
+ INT32 i;
+
+ if ( DmGetMemFailedFlag() ) // device runs out of memory
+ return SYNCML_DM_DEVICE_FULL;
+
+ m_pTree->RecoverPlugin();
+
+ for (i=0; i< m_numArchives; i++)
+ {
+ m_pArchives[i]->getFilePath(orgFilePath, "");
+ m_pArchives[i]->getFilePath(bakFilePath, ".bak");
+ m_pArchives[i]->getFilePath(tmpFilePath, ".temp");
+ m_pArchives[i]->getFilePath(cmtFilePath, ".cmt");
+
+ if (XPL_FS_Exist(tmpFilePath))
+ tmpFileExists=TRUE;
+ if (XPL_FS_Exist(bakFilePath))
+ bakFileExists=TRUE;
+ if (XPL_FS_Exist(cmtFilePath))
+ cmtFileExists=TRUE;
+ }
+
+ if ( tmpFileExists || bakFileExists )
+ XPL_FS_Remove(DM_ISP_LOCK);
+
+ if (tmpFileExists)
+ {
+ if (bakFileExists)
+ {
+ //Both temp file and bak file exists, rename bak to orig
+ // rename bak files to orig files, then delete tmp files and commit log files
+ for (i=0; i< m_numArchives; i++)
+ {
+ m_pArchives[i]->getFilePath(orgFilePath, "");
+ m_pArchives[i]->getFilePath(bakFilePath, ".bak");
+ ret=XPL_FS_Rename(bakFilePath, orgFilePath);
+ XPL_LOG_DM_TMN_Debug(("DmFsRename %s->%s ret=%d\n", bakFilePath, orgFilePath, ret));
+ }
+ }
+ for (i=0; i< m_numArchives; i++)
+ {
+ m_pArchives[i]->getFilePath(tmpFilePath, ".temp");
+ m_pArchives[i]->getFilePath(cmtFilePath, ".cmt");
+#ifndef DM_NO_LOCKING
+ ret=XPL_FS_Unlink(tmpFilePath);
+ ret=XPL_FS_Unlink(cmtFilePath);
+#else
+ ret=XPL_FS_Remove(tmpFilePath);
+ ret=XPL_FS_Remove(cmtFilePath);
+#endif
+ XPL_LOG_DM_TMN_Debug(("delete %s ret=%d\n", tmpFilePath, ret));
+ }
+ }
+ else
+ {
+ if (bakFileExists | cmtFileExists)
+ {
+ //Only bak file exists
+ // Delete bak files
+ for (i=0; i< m_numArchives; i++)
+ {
+ m_pArchives[i]->getFilePath(bakFilePath, ".bak");
+ m_pArchives[i]->getFilePath(cmtFilePath, ".cmt");
+ // Remove .bak file
+ if (XPL_FS_Exist(bakFilePath))
+ {
+#ifndef DM_NO_LOCKING
+ ret=XPL_FS_Unlink(bakFilePath);
+#else
+ ret=XPL_FS_Remove(bakFilePath);
+#endif
+ XPL_LOG_DM_TMN_Debug(("delete %s ret=%d\n", bakFilePath, ret));
+ }
+#ifdef LOB_SUPPORT
+ // Play and remove commit log file
+ if (XPL_FS_Exist(cmtFilePath))
+ {
+ m_pArchives[i]->PlayCommitLog();
+ }
+#endif
+ }
+ }
+ }
+
+ // Remove temorary LOB files
+ {
+ DMString lobDir;
+ m_pEnv->GetWFSFullPath(NULL,lobDir);
+ DmRemoveTempfile(lobDir);
+ }
+
+ //Logic for checking newer files
+ for (i=0; i< m_numArchives && m_pArchives[i] !=NULL; i++)
+ {
+ if (m_pArchives[i]->getRootNode() !=NULL && !m_pArchives[i]->getRootNode()->IsSkeletonNode())
+ {
+ //Already loaded in memory
+ if (m_pArchives[i]->getLastModifiedTime() != m_pArchives[i]->getLastSavedTime())
+ {
+ //The files needed to be reloaded.
+ XPL_LOG_DM_TMN_Debug(("File[%d] %s is newer, need delete subtree & reload\n", i, m_pArchives[i]->getURI()));
+ XPL_LOG_DM_TMN_Debug((" last file modified time=0x%x memory time=0x%x\n",m_pArchives[i]->getLastModifiedTime(), m_pArchives[i]->getLastSavedTime()));
+ m_pTree->UnloadArchive(m_pArchives[i]->getRootNode());
+ }
+ }
+ }
+
+ return retStat;
+}
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_Archiver::rollback(INT32 nFileSet)
+{
+ if( !m_pTree ) return SYNCML_DM_FAIL;
+
+ SYNCML_DM_RET_STATUS_T retStat=SYNCML_DM_SUCCESS;
+
+ INT32 i=0;
+ INT32 set=1;
+ for (i=0, set=1; i< m_numArchives && m_pArchives[i] !=NULL; i++, set = set <<1 )
+ {
+ if ( (nFileSet & set) !=0 && m_pArchives[i]->getRootNode() != NULL )
+ {
+ //Already loaded in memory
+ if ( m_pArchives[i]->isDirty() )
+ {
+ //The files needed to be reloaded.
+ XPL_LOG_DM_TMN_Debug((" last file modified time=0x%x memory time=0x%x\n", m_pArchives[i]->getLastModifiedTime(),
+ m_pArchives[i]->getLastSavedTime()));
+
+#ifdef LOB_SUPPORT
+ // Rollback all changes for ESN
+ m_pArchives[i]->rollbackESN(m_pTree);
+#endif
+ m_pTree->UnloadArchive(m_pArchives[i]->getRootNode());
+ m_pArchives[i]->setDirty(FALSE);
+ m_pArchives[i]->GetEventLogger().Reset();
+ }
+ }
+ }
+
+ return retStat;
+}
+
+void
+SyncML_DM_Archiver::CheckMemoryAging(INT32 nAgingTime)
+{
+ if( !m_pTree ) return;
+
+ // current time in seconds
+ XPL_CLK_CLOCK_T currentTime = XPL_CLK_GetClock();
+ for (INT32 i=0; i < m_numArchives && m_pArchives[i] !=NULL; i++)
+ {
+ // free from memory
+ if ( m_pArchives[i]->getRootNode()
+ && !m_pArchives[i]->getRootNode()->IsSkeletonNode()
+ && !m_pArchives[i]->isDirty() )
+ {
+ // Check the last accessed time in seconds
+ XPL_CLK_CLOCK_T lastAccessedTime = m_pArchives[i]->getLastAccessedTime();
+ if ( (currentTime - lastAccessedTime) >= (XPL_CLK_CLOCK_T)nAgingTime )
+ {
+ XPL_LOG_DM_TMN_Debug(("m_pArchives[%d]->getURI() : %s is being unloaded, unused for %d >= aging time = %d\n",
+ i, m_pArchives[i]->getURI(), (currentTime - lastAccessedTime), nAgingTime));
+ }
+
+ m_pTree->UnloadArchive(m_pArchives[i]->getRootNode());
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : InvokeCommitPlugins
+// DESCRIPTION : This function iterates all commit plug-ins
+// and calls "OnCommit" on each which has update event(s)
+// ARGUMENTS PASSED: szURI - sub-tree root uri
+// nFileSet - currently used file set
+// RETURN VALUE : void
+// PRE-CONDITIONS : called after successful serialization
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+void SyncML_DM_Archiver::InvokeCommitPlugins(FILESETTYPE nFileSet, CPCHAR szURI)
+{
+ PDmtTree tree( new DmtTreeImpl(true) );
+ DMPluginVector plugins;
+ FILESETTYPE set=1;
+ INT32 i=0;
+
+ DMPluginManager & oPluginManager = m_pTree->GetPluginManager();
+
+ oPluginManager.GetPlugins(szURI, SYNCML_DM_COMMIT_PLUGIN, plugins);
+
+ for (INT32 nPlugin = 0; nPlugin < plugins.size(); nPlugin++ )
+ {
+ DmtEventMap updatedNodes;
+
+ for (i=0, set=1; i< m_numArchives && m_pArchives[i] !=NULL; i++, set = set <<1)
+ {
+ if ( (nFileSet & set) !=0 && m_pArchives[i]->isDirty() )
+ {
+ m_pArchives[i]->GetEventLogger().GetCommitPluginEvents(plugins[nPlugin], updatedNodes );
+ }
+ }
+
+ if ( updatedNodes.size() > 0 )
+ plugins[nPlugin]->OnCommit( updatedNodes, tree );
+ }
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : CleanEvents
+// DESCRIPTION : This function iterates all archives and remove stored events
+// ARGUMENTS PASSED: szURI - sub-tree root uri
+// RETURN VALUE : void
+// PRE-CONDITIONS : called after successful serialization
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_Archiver::CleanEvents(CPCHAR szURI)
+
+{
+ FILESETTYPE set=1;
+ FILESETTYPE nFileSet=0;
+
+ nFileSet = getArchivesByURI(szURI);
+
+ for (FILESETTYPE i=0, set=1; i < m_numArchives; i++, set <<= 1)
+ {
+ if ( (nFileSet & set) !=0 && m_pArchives[i]->isDirty() )
+ {
+ m_pArchives[i]->GetEventLogger().CleanEvents(szURI);
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : UpdateEvents
+// DESCRIPTION : This function iterates all archives and remove stored events
+// ARGUMENTS PASSED: szURI - sub-tree root uri
+// RETURN VALUE : void
+// PRE-CONDITIONS : called after successful serialization
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_Archiver::UpdateEvents(CPCHAR szURI, CPCHAR szNewName)
+
+{
+ FILESETTYPE set=1;
+ FILESETTYPE nFileSet=0;
+
+ nFileSet = getArchivesByURI(szURI);
+
+ for (FILESETTYPE i=0, set=1; i< m_numArchives; i++, set = set <<1)
+ {
+ if ( (nFileSet & set) !=0 && m_pArchives[i]->isDirty() )
+ {
+ m_pArchives[i]->GetEventLogger().UpdateEvents(szURI,szNewName);
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : IsDirty
+// DESCRIPTION : Checks if file set has been modified
+//
+// ARGUMENTS PASSED: nFileSet - currently used file set
+// RETURN VALUE : void
+// PRE-CONDITIONS : called before serialization
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+BOOLEAN SyncML_DM_Archiver::IsDirty(FILESETTYPE * pFileSet)
+{
+ FILESETTYPE i=0;
+ FILESETTYPE set=1;
+
+ if ( pFileSet == NULL )
+ return TRUE;
+
+ for (i=0, set=1; i< m_numArchives; i++, set = set <<1)
+ {
+ if ( ((*pFileSet) & set) !=0 && m_pArchives[i]->isDirty() == FALSE )
+ (*pFileSet) &= ~set;
+ }
+
+ if ( (*pFileSet) == 0 )
+ return FALSE;
+ else
+ return TRUE;
+}
diff --git a/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_FileHandle.cc b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_FileHandle.cc
new file mode 100644
index 0000000..a04cd63
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_FileHandle.cc
@@ -0,0 +1,603 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dmdefs.h"
+#include "SyncML_DM_FileHandle.H"
+#include "dm_uri_utils.h"
+#include "dm_tree_class.H"
+
+#ifndef min
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+/* The .temp file extention is used for the archive being written
+ * the .bak file extention is used during the process of replacing
+ * the old with the new archive
+ */
+
+/* The wchar_t standard and handy L"string"; usage are not supported by the ARM compiler. */
+const char DMFileHandler::TEMP_FILE_EXTENSION[] = ".temp";
+const char DMFileHandler::BAK_FILE_EXTENSION[]= ".bak";
+const char DMFileHandler::COMMIT_LOG_EXTENSION[]= ".cmt";
+const char DMFileHandler::LOG_FILE_EXTENSION[]= ".log";
+const char DMFileHandler::MIDDLE_FILE_EXTENSION[]= ".mid";
+
+/*==================================================================================================
+
+Function: DMFileHandler::DMFileHandler
+
+Description: Constructor method for the DMFileHandler class
+
+==================================================================================================*/
+DMFileHandler::DMFileHandler(CPCHAR path)
+{
+ init(path);
+}
+
+
+DMFileHandler::DMFileHandler(CPCHAR path, BOOLEAN bIsCache)
+{
+ init(path);
+ m_bIsCache = bIsCache;
+}
+
+
+void DMFileHandler::init(CPCHAR path)
+{
+ m_pInternalBuf = NULL;
+ m_nInternalBufLen = 0;
+ m_nBufPos = 0;
+ m_nFilePos = 0;
+ m_nBufOffset = 0;
+ m_nFileHandle = -1;
+ m_strPath = path;
+ m_bWrite = FALSE;
+ m_bIsCache = TRUE;
+ m_pMemMap = NULL;
+ m_nSize = 0;
+
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::DMFileHandler
+
+Description: Destructor method for the DMFileHandler class
+
+==================================================================================================*/
+DMFileHandler::~DMFileHandler()
+{
+ close();
+ unmmap();
+ if ( m_pInternalBuf )
+ DmFreeMem(m_pInternalBuf);
+}
+
+
+/*==================================================================================================
+
+Function: DMFileHandler::open
+
+Description: Opens the file represented by this object for I/O
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::open(INT32 modeFlag)
+{
+ XPL_FS_RET_STATUS_T result;
+
+ m_nMode = modeFlag;
+ m_nFileHandle = XPL_FS_Open(m_strPath.c_str(), modeFlag, &result);
+
+ /* Reset the internal buffer length since we've opened a new file */
+ m_nInternalBufLen = 0;
+ m_nBufPos = 0;
+ m_nFilePos = 0;
+ m_nBufOffset =0;
+ m_bWrite = FALSE;
+
+ if ( !m_pInternalBuf && m_bIsCache )
+ m_pInternalBuf = (char *)DmAllocMem(MAX_INTERNAL_BUFFER_LENGTH);
+
+ if(m_nFileHandle >= 0 )
+ return SYNCML_DM_SUCCESS;
+
+ if (result == XPL_FS_RET_PERM_FAIL)
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+
+ return SYNCML_DM_IO_FAILURE;
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::read
+
+Description: Reads count bytes into buffer
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::read(char* buffer, UINT16 count)
+{
+ XPL_FS_RET_STATUS_T result;
+
+ if ( m_nFileHandle < 0 )
+ return SYNCML_DM_IO_FAILURE;
+
+ if ( m_nMode == XPL_FS_FILE_WRITE ||
+ m_nMode == XPL_FS_FILE_APPEND )
+ return SYNCML_DM_IO_FAILURE;
+
+ if ( !m_pInternalBuf ){
+ int nRead = XPL_FS_Read(m_nFileHandle, buffer, count,&result);
+ return nRead == count ? SYNCML_DM_SUCCESS : SYNCML_DM_IO_FAILURE;
+ }
+
+ int nRead = min( count, m_nInternalBufLen-m_nBufPos );
+ if ( nRead > 0 )
+ {
+ memcpy( buffer, m_pInternalBuf+m_nBufPos, nRead);
+ m_nBufPos += nRead;
+ }
+ if ( m_nBufPos == m_nInternalBufLen && count > nRead)
+ { // need more data
+ m_nBufPos = 0;
+ if (m_nMode == XPL_FS_FILE_RDWR )
+ flush();
+
+ m_nInternalBufLen = XPL_FS_Read(m_nFileHandle, m_pInternalBuf, MAX_INTERNAL_BUFFER_LENGTH, &result);
+ if ( m_nInternalBufLen <= 0 )
+ return SYNCML_DM_IO_FAILURE;
+
+ m_nBufOffset = m_nFilePos;
+ m_nFilePos += m_nInternalBufLen;
+ return read( buffer + nRead, count -nRead );
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::write
+
+Description: Writes count bytes into buffer. This method implements a double buffering scheme.
+ Writes less than MAX_INTERNAL_BUFFER_LENGTH are placed in a RAM queue. Large writes
+ are sent to the filesystem in blocks of size MAX_INTERNAL_BUFFER_LENGTH.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::write(const char* buffer, UINT16 count)
+{
+ //XPL_LOG_DM_TMN_Debug(("DMFileHandler::write: handle is %d, name = %s\n",m_nFileHandle, m_strPath.c_str()));
+
+ if ( m_nFileHandle < 0 )
+ return SYNCML_DM_IO_FAILURE;
+
+ if ( m_nMode == XPL_FS_FILE_READ )
+ return SYNCML_DM_IO_FAILURE;
+
+ if ( !m_pInternalBuf )
+ m_pInternalBuf = (char *)DmAllocMem(MAX_INTERNAL_BUFFER_LENGTH);
+
+ if ( !m_pInternalBuf || m_nFileHandle < 0 )
+ return SYNCML_DM_IO_FAILURE;
+
+ int nWriteCount = min( count, MAX_INTERNAL_BUFFER_LENGTH-m_nBufPos);
+
+ if ( nWriteCount > 0 )
+ {
+ m_bWrite = TRUE;
+ memcpy(m_pInternalBuf + m_nBufPos, buffer, nWriteCount);
+ m_nBufPos += nWriteCount;
+ if ( m_nBufPos > m_nInternalBufLen )
+ m_nInternalBufLen = m_nBufPos;
+ }
+
+ if ( m_nInternalBufLen == MAX_INTERNAL_BUFFER_LENGTH && m_nBufPos == MAX_INTERNAL_BUFFER_LENGTH )
+ {
+ if(flush() != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if ( count > nWriteCount )
+ return write(buffer + nWriteCount, count - nWriteCount);
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::writeBuffer
+
+Description: Writes count bytes to the filesystem. No double buffering is involved.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::writeBuffer(const char* buffer, UINT16 count)
+{
+ XPL_FS_RET_STATUS_T result;
+ int nWritten = XPL_FS_Write( m_nFileHandle, (char*)buffer, count, &result );
+ m_nFilePos += nWritten;
+ m_nBufOffset += nWritten;
+ if ( nWritten == count )
+ {
+ m_nInternalBufLen = 0;
+ m_nBufPos = 0;
+ m_bWrite = FALSE;
+ return SYNCML_DM_SUCCESS;
+ }
+ else
+ {
+ // TODO
+ return SYNCML_DM_IO_FAILURE;
+ }
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::seek
+
+Description: Seek offset bytes relative to seekFrom
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::seek(XPL_FS_SEEK_MODE_T whence, INT32 offset)
+{
+ if ( m_nFileHandle < 0 )
+ return SYNCML_DM_IO_FAILURE;
+
+
+ SYNCML_DM_RET_STATUS_T ret_stat;
+ XPL_FS_SEEK_OFFSET_T file_pos;
+ XPL_FS_RET_STATUS_T result;
+
+
+ if (m_nMode != XPL_FS_FILE_READ )
+ if((ret_stat = this->flush()) != SYNCML_DM_SUCCESS)
+ return ret_stat;
+
+ if ( (file_pos = XPL_FS_Seek(m_nFileHandle, offset, whence,&result)) >=0 )
+ {
+ if ( m_nInternalBufLen > 0 )
+ {
+// Cache should be cleanred when seeking to a new position.
+// if ( file_pos >= m_nFilePos || file_pos < m_nBufOffset )
+// {
+ m_nInternalBufLen = 0;
+ m_nBufPos = 0;
+ m_nBufOffset = file_pos;
+// }
+// else
+// {
+// m_nBufPos = file_pos-m_nBufOffset;
+// }
+ }
+ else
+ m_nBufOffset = file_pos;
+
+ m_nFilePos = file_pos;
+ return SYNCML_DM_SUCCESS;
+ }
+
+ return SYNCML_DM_IO_FAILURE;
+}
+
+/*============================================================================================
+======
+
+Function: DMFileHandler::flush
+
+Description: Flushes the internal write buffer if it exists into the filesystem
+ component.
+
+Notes: The file system may not actually flush the data to the file itself
+ as the file system component seems to maintain its own internal buffers
+
+==============================================================================================
+====*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::flush()
+{
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ if(m_nInternalBufLen > 0 && m_bWrite)
+ {
+ if ( m_nBufOffset != m_nFilePos )
+ XPL_FS_Seek(m_nFileHandle, m_nBufOffset, XPL_FS_SEEK_SET,NULL);
+ ret_stat = writeBuffer(m_pInternalBuf, m_nInternalBufLen);
+ }
+ return ret_stat;
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::close
+
+Description: Close the file handle
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::close()
+{
+ if ( m_nFileHandle < 0 )
+ return SYNCML_DM_FAIL;
+
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+ if ( m_nMode != XPL_FS_FILE_READ )
+ ret_stat = flush();
+
+ XPL_FS_Close(m_nFileHandle);
+ m_nFileHandle = -1;
+ if ( ret_stat == XPL_FS_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_IO_FAILURE;
+}
+/*==================================================================================================
+
+Function: DMFileHandler::rename
+
+Description: Create an unique External Storage Node file name
+
+ The function argument is the full path name of the file.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::createTempESNFileName(DMString &fileName)
+{
+ char uniqueStr[20];
+ XPL_CLK_LONG_CLOCK_T curTime = XPL_CLK_GetClockMs();
+ DmSprintf(uniqueStr, "%lld", curTime);
+ if(uniqueStr[0] == '-')
+ uniqueStr[0]='L';
+
+ dmTreeObj.GetWritableFileSystemFullPath(fileName);
+ CPCHAR pT = fileName.c_str();
+ if (pT[fileName.length()-1] != '/')
+ fileName += "/";
+
+ XPL_FS_MkDir(fileName);
+ fileName += uniqueStr;
+ fileName += ".lob";
+ fileName += MIDDLE_FILE_EXTENSION;
+ return SYNCML_DM_SUCCESS;
+}
+/*==================================================================================================
+
+Function: DMFileHandler::rename
+
+Description: Rename a file to new name.
+ On Win32 systems, the file must be closed to properly rename, however;
+ P2K requires that the filehandle be open. We handle that with preprocessor
+ logic here.
+
+ The function argument is the full path name of the file.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::rename(CPCHAR newFileName)
+{
+
+ this->close();
+ XPL_FS_RET_STATUS_T ret_stat;
+
+ ret_stat = XPL_FS_Rename(m_strPath, newFileName);
+ if ( ret_stat == XPL_FS_RET_SUCCESS )
+ {
+ m_strPath = newFileName;
+ return SYNCML_DM_SUCCESS;
+ }
+ else
+ return SYNCML_DM_IO_FAILURE;
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::deleteFile
+
+Description: Delete a file
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMFileHandler::deleteFile()
+{
+ XPL_FS_RET_STATUS_T ret_stat;
+
+ close();
+ ret_stat = XPL_FS_Remove(m_strPath);
+ if ( ret_stat == XPL_FS_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_IO_FAILURE;
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::getSize
+
+Description: Returns size of file
+
+==================================================================================================*/
+XPL_FS_SIZE_T
+DMFileHandler::size()
+{
+ if ( m_nFileHandle < 0 )
+ return 0;
+
+ if ( m_nMode != XPL_FS_FILE_READ || m_nSize == 0 )
+ m_nSize = XPL_FS_GetSize(m_nFileHandle);
+
+ return m_nSize;
+}
+
+
+/*==================================================================================================*/
+
+XPL_FS_SEEK_OFFSET_T
+DMFileHandler::position()
+{
+ return m_nFilePos;
+}
+
+#ifndef DM_NO_LOCKING
+/*==================================================================================================
+
+Function: DMFileHandler::lock
+
+Description: locks the file
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T DMFileHandler::lock(BOOLEAN bLockExclusive )
+{
+ XPL_FS_RET_STATUS_T result;
+ result = XPL_FS_Lock(m_nFileHandle, bLockExclusive);
+ if ( result == XPL_FS_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ if ( result == XPL_FS_RET_TRYAGAIN )
+ return SYNCML_DM_LOCK_TRY_AGAIN;
+ else
+ return SYNCML_DM_IO_FAILURE;
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::unlock
+
+Description: unlocks the file
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T DMFileHandler::unlock()
+{
+ XPL_FS_RET_STATUS_T result;
+ result = XPL_FS_Unlock(m_nFileHandle);
+ if ( result == XPL_FS_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_IO_FAILURE;
+}
+
+#endif
+
+/*==================================================================================================
+
+Function: DMFileHandler::fgets
+
+Description: read one more string from the file and returns or null if error
+
+==================================================================================================*/
+char* DMFileHandler::fgets( char* s, INT32 size )
+{
+ if ( size < 1 || !s )
+ return NULL;
+
+ s[0] = 0;
+ if ( iseof() )
+ return NULL;
+
+ char c = 0;
+ INT32 nPos = 0;
+ BOOLEAN bIsValid = FALSE;
+
+ while ( read( &c, 1 ) == SYNCML_DM_SUCCESS && (nPos +1 ) < size )
+ {
+ if ( c == '\n' )
+ break;
+
+ if ( c == '\r' )
+ continue;
+
+ if ( c == '\t' )
+ c = ' ';
+
+ if ( c != ' ' )
+ bIsValid = TRUE;
+ else
+ if ( !bIsValid )
+ continue;
+
+ s[nPos] = c;
+ nPos++;
+
+ }
+
+ while ( nPos > 0 && s[nPos-1] == ' ' )
+ nPos--;
+
+ s[nPos] = 0;
+
+ return s;
+}
+
+/*==================================================================================================
+
+Function: DMFileHandler::iseof
+
+Description: returns true if end of file reached
+
+==================================================================================================*/
+BOOLEAN DMFileHandler::iseof()
+{
+
+ size();
+ if ( !m_pInternalBuf )
+ {
+ m_nFilePos = XPL_FS_Seek(m_nFileHandle, 0, XPL_FS_SEEK_CUR,NULL);
+ if ( m_nFilePos < 0 )
+ return TRUE;
+ return (((INT32)m_nSize == m_nFilePos));
+ }
+ else
+ {
+ return ( ((INT32)m_nSize == m_nFilePos) && (m_nBufPos == m_nInternalBufLen) );
+ }
+}
+
+UINT8 * DMFileHandler::mmap()
+{
+ XPL_FS_RET_STATUS_T result;
+ if ( m_pMemMap == NULL )
+ {
+ if ( m_nFileHandle < 0 )
+ return NULL;
+
+
+ if ( m_nMode != XPL_FS_FILE_READ )
+ return NULL;
+
+ size();
+ if ( m_nSize == 0 )
+ return NULL;
+
+ m_pMemMap = XPL_FS_MemMap(m_nFileHandle,m_nSize,0,&result);
+ }
+
+ return m_pMemMap;
+}
+
+SYNCML_DM_RET_STATUS_T DMFileHandler::unmmap()
+{
+ XPL_FS_RET_STATUS_T result;
+ if ( m_pMemMap )
+ {
+ result = XPL_FS_MemUnMap(m_pMemMap,m_nSize);
+ if ( result == XPL_FS_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_IO_FAILURE;
+ }
+ else
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLArchive.cc b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLArchive.cc
new file mode 100644
index 0000000..fb03856
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLArchive.cc
@@ -0,0 +1,614 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SyncML_DM_WBXMLArchive.H"
+#include "SyncML_DM_Reader.H"
+#include "xpl_Logger.h"
+#include "dm_tree_class.H"
+#include "dmprofile.h"
+#include "dm_uri_utils.h"
+
+/* The DEFAULT_FILE_HEADER field represents the start of a standard WBXML document
+ * for standards compliance and for the purpose of file size efficiency.
+ *
+ * The first 3 bytes are WBXML standard values:
+ * version is always 1 byte.
+ * publicid - We assume the public ID is <=127, which only takes 1 byte
+ * for its mb_uint32 encoding.
+ * charset - 0x6A is the code for UTF-8; 1 byte for mb_uint32 encoding
+ * The 4th byte is the mb_uint32 length of the optional string table that follows;
+ * we will not have a string table, so the length is zero and no table follows.
+ *
+ * The purpose of the string table is to store common strings that occur multiple
+ * times in the document, and thus save space by referring to them. This is a
+ * possible future enhancement.
+ */
+const UINT8 SyncML_DM_WBXMLArchive::DEFAULT_FILE_HEADER[] = {
+ WBXML_VERSION, PUBLIC_ID, CHARSET, 0x00
+ };
+
+/* The wchar_t standard and handy L"string"; usage are not supported by the ARM compiler.*/
+const char SyncML_DM_WBXMLArchive::FILE_EXTENSION[] = ".wbxml";
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLArchive::SyncML_DM_WBXMLArchive
+
+Description: Constructor method that creates a log and sets up the path and uri of the archive
+
+==================================================================================================*/
+SyncML_DM_WBXMLArchive::SyncML_DM_WBXMLArchive(CEnv* env, CPCHAR pURI, CPCHAR path)
+ : SyncML_DM_Archive( env, pURI, path),
+ m_pEnv( env )
+{
+ lastSavedTime = 0;
+#ifdef LOB_SUPPORT
+ commitLog = NULL;
+#endif
+
+ if (!m_strWFSFileName.empty() && m_strWFSFileName.length() > 0) {
+ m_permission = 0;
+ // initialize permission mask
+ if (XPL_FS_CheckPermission(m_strWFSFileName, XPL_FS_RDONLY_MODE)) {
+ m_permission = XPL_FS_RDONLY_MODE;
+ }
+ if (XPL_FS_CheckPermission(m_strWFSFileName, XPL_FS_RDWR_MODE)) {
+ m_permission |= (XPL_FS_RDWR_MODE|XPL_FS_WRONLY_MODE|XPL_FS_RDWR_MODE|
+ XPL_FS_CREAT_MODE|XPL_FS_TRUNC_MODE|XPL_FS_APPEND_MODE);
+ }
+ }
+ XPL_LOG_DM_TMN_Debug(("m_permission initialized to %d, path %s, uri=%s\n", m_permission, m_strWFSFileName.c_str(), pURI ));
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLArchive::~SyncML_DM_WBXMLArchive
+
+Description: The SyncML_DM_WBXMLArchive class deconstructor.
+
+==================================================================================================*/
+SyncML_DM_WBXMLArchive::~SyncML_DM_WBXMLArchive()
+{
+#ifdef LOB_SUPPORT
+ // Remove commit log handler
+ if(commitLog != NULL)
+ {
+ commitLog->CloseLog();
+ delete commitLog;
+ commitLog = NULL;
+ }
+#endif
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLArchive::serialize
+
+Description: Serialization method takes a tree as an argument serializes to the file system
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLArchive::serialize(DMTree* tree)
+{
+ SYNCML_DM_SERIALIZATION_STATUS_T ser_ret_stat;
+
+#ifdef DM_PROFILER_ENABLED
+ DMString strCaption = "serialize ";
+ strCaption += getURI(); strCaption += ", \"";
+ strCaption += m_path; strCaption += "\"";
+ DM_PROFILE( strCaption );
+#endif
+
+ /* Create the path string for the temp file */
+ if (this->rootTreeNode==NULL)
+ return SYNCML_DM_SKIP_SUBTREE;
+
+ tree->InitSerializationList(this->rootTreeNode);
+
+ /* Path + Extension + null */
+ DMString strTempFilePath = m_strWFSFileName;
+ strTempFilePath += DMFileHandler::TEMP_FILE_EXTENSION;
+
+ /* Acquire a handle representation of the file */
+ DMFileHandler fileHandle(strTempFilePath.c_str());
+
+ /* Open the file for writing */
+
+ SYNCML_DM_RET_STATUS_T retstat = fileHandle.open(XPL_FS_FILE_WRITE);
+
+ if(retstat == SYNCML_DM_COMMAND_NOT_ALLOWED) {
+ return retstat;
+ }
+ else if (retstat != SYNCML_DM_SUCCESS) {
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* Create a WBXMLWriter utility class for handling the data */
+ SyncML_DM_WBXMLWriter writer(&fileHandle);
+
+ /* Write the default file header, which contains the WBXML version, public ID,
+ charset (UTF-8), lookup table length, and lookup table */
+ if(writer.writeData((UINT8 *)DEFAULT_FILE_HEADER,
+ (UINT8)sizeof(DEFAULT_FILE_HEADER)) != SYNCML_DM_SUCCESS) {
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* Write the MgmtTree start tag */
+ if(writer.writeByte(SyncML_DM_WBXMLArchive::TREE_START_TAG |
+ SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS) {
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* Create a URI object for the currURI
+ * For the purposes of conserving memory allocation cycles, we assume the worst
+ * case URI length + 1 for the nil terminator, and we will reuse this same
+ * buffer as the loop runs, putting in a nil terminator where its needed.
+ */
+ DMNode * pRetNode = NULL;
+ /* Loop on the nodes returned by the tree and node manager */
+ INT32 nEndTagsNumber = 0;
+ while((ser_ret_stat = tree->GetSerializationListNextItem(&pRetNode, nEndTagsNumber)) == SYNCML_DM_SERIALIZATION_SUCCESS)
+ {
+
+ // write "end" tags
+ while( nEndTagsNumber > 0 ) {
+ nEndTagsNumber--;
+
+ if(writer.writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+#ifdef LOB_SUPPORT
+ // Special case for ESN
+ if(pRetNode->IsESN())
+ {
+ SYNCML_DM_RET_STATUS_T retStatus;
+ // Convert to ESN pointer
+ DMDefaultESN *tempESN = reinterpret_cast< DMDefaultESN *>(pRetNode);
+ // Close internal files
+ retStatus = tempESN->CloseInternalFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ }
+#endif
+
+ if(writer.writeNode(pRetNode) != SYNCML_DM_SUCCESS) {
+ XPL_LOG_DM_TMN_Error((" SYNCML_DM_IO_FAILURE on %s\n", (const char *)m_pURI ));
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ if ( pRetNode->opiInSync() )
+ {
+ UINT8 flag = pRetNode->getFlags();
+ flag &= ~( DMNode::enum_NodeOPISyncUptodate );
+ pRetNode->setFlags(flag);
+ }
+
+ }/* End while */
+
+ /* Ensure the while() terminated as expected */
+ if (ser_ret_stat == SYNCML_DM_TREE_TRAVERSING_OVER) {
+ /* We have to write the end tag of the last node, as well as any
+ * parent nodes that also ended. currURI tells up how many (one
+ * for each / still in it)
+ */
+ while( nEndTagsNumber > 0 ) {
+ nEndTagsNumber--;
+
+ if(writer.writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+ } else /* ser_ret_stat == SYNCML_DM_SERIALIZATION_FAIL */
+ {
+ fileHandle.close();
+ return SYNCML_DM_FAIL;
+ }
+ /* Write the end tag for the root node, then end tag for the MgmtTree */
+ UINT8 endTags[2] = { SyncML_DM_WBXMLArchive::END_TAG, SyncML_DM_WBXMLArchive::END_TAG };
+
+ if(writer.writeData(&endTags[0], 2) != SYNCML_DM_SUCCESS)
+ {
+ fileHandle.close();
+ return SYNCML_DM_IO_FAILURE;
+ }
+ /* Close the file */
+ if (fileHandle.close() != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+
+
+Function: SyncML_DM_WBXMLArchive::deserialize
+
+Description: Deserializes a tree in the filesystem to the memory tree
+
+==================================================================================================*/
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLArchive::deserialize(DMTree * pTree,
+ BOOLEAN bIsReload)
+{
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+#ifdef DM_PROFILER_ENABLED
+ DMString strCaption = "deserialize ";
+ strCaption += getURI(); strCaption += ", \"";
+ strCaption += m_path; strCaption += "\"";
+ DM_PROFILE( strCaption );
+#endif
+
+ if ( !rootTreeNode )
+ return SYNCML_DM_FAIL;
+
+ oEventLogger.Reset();
+
+ if ( !rootTreeNode->IsSkeletonNode() )
+ {
+ if ( bIsReload )
+ m_pTree->UnloadArchive(rootTreeNode);
+ else
+ return SYNCML_DM_SUCCESS;
+ }
+
+ DMPluginManager & oPluginManager = m_pTree->GetPluginManager();
+
+ ret_stat = deserializeFile( pTree, m_strWFSFileName, true );
+
+ if ( ret_stat == SYNCML_DM_FILE_NOT_FOUND )
+ setWritableExist( FALSE );
+ else
+ {
+ setWritableExist( TRUE );
+ return oPluginManager.UpdatePluginNodes(m_pURI);
+ }
+
+ for ( int nFS = 0; nFS < m_pEnv->GetRFSCount(); nFS++ )
+ {
+ DMString sFile;
+ m_pEnv->GetRFSFullPath(nFS,m_path,sFile);
+ if ( deserializeFile( pTree, sFile, false ) == SYNCML_DM_SUCCESS )
+ ret_stat = SYNCML_DM_SUCCESS; // at least one file was successfully loaded
+ }
+
+ return oPluginManager.UpdatePluginNodes(m_pURI);
+}
+
+SYNCML_DM_RET_STATUS_T SyncML_DM_WBXMLArchive::deserializeFile(
+ DMTree* pTree,
+ CPCHAR szFileName,
+ BOOLEAN bWFS)
+{
+ if (!XPL_FS_Exist(szFileName))
+ return SYNCML_DM_FILE_NOT_FOUND;
+
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+ /* Create a file handle for the file to be deserialized */
+ DMFileHandler fileHandle(szFileName);
+ SYNCML_DM_RET_STATUS_T openstat = fileHandle.open(XPL_FS_FILE_READ);
+
+ /* If file cannot be opened, leave now */
+ if(openstat == SYNCML_DM_COMMAND_NOT_ALLOWED) {
+ return openstat;
+ }
+ else if (openstat != SYNCML_DM_SUCCESS) {
+ return SYNCML_DM_FILE_NOT_FOUND; /* Assume this is the underlying reason */
+ }
+
+ m_permission |= XPL_FS_RDONLY_MODE;
+
+ /* Create a reader utility class for the reading of tree data */
+ SyncML_DM_WBXMLReader reader(&fileHandle);
+
+ /* Working variable */
+ UINT8 bYte;
+
+ /* Read a WBXML header from the file */
+ if(reader.readHeader() != SYNCML_DM_SUCCESS)
+ {
+ fileHandle.close();
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* Read and verify the MgmtTree start tag */
+ if(reader.readByte(&bYte) != SYNCML_DM_SUCCESS)
+ {
+ fileHandle.close();
+ return SYNCML_DM_IO_FAILURE;
+ }
+ if(bYte != (TREE_START_TAG | TAG_CONTENT_MASK))
+ {
+ fileHandle.close();
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* Read the first byte of data, expected to be END_TAG or NODE_START_TAG.
+ * The byte read will be parsed in the upcoming loop.
+ * If the byte is not the NODE_START_TAG with content, there is no
+ * tree to parse or there is an error (we assume error here).
+ */
+ if(reader.readByte(&bYte) != SYNCML_DM_SUCCESS
+ || bYte != (SyncML_DM_WBXMLArchive::NODE_START_TAG
+ | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ {
+ fileHandle.close();
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* The properties data structure */
+ DMAddNodeProp props;
+
+ DMNode* pNode = rootTreeNode->GetParent(); // can be null for '.'; otherwise is valid parent
+
+ /* Loop until an internal break occurs (hopefully, not until the last END_TAG */
+ while(1)
+ {
+ /* If the read byte is an END_TAG... */
+ if(bYte == END_TAG)
+ {
+
+ if ( pNode == rootTreeNode )
+ break; // end of subtree
+
+ if ( !pNode || !pNode->GetParent() ){
+ XPL_LOG_DM_TMN_Error((" ! Unexpected condition (node is null) inside deserialize\n"));
+ fileHandle.close();
+ return SYNCML_DM_TREE_CORRUPT; // unexpected condition - looks like extra "end tag"
+ }
+
+ pNode = pNode->GetParent();
+
+ /* Get the next byte after the END_TAG */
+ ret_stat=reader.readByte(&bYte);
+ if(ret_stat != SYNCML_DM_SUCCESS) {
+ XPL_LOG_DM_TMN_Error((" ! Error ret_stat=%d\n", ret_stat));
+ fileHandle.close();
+ return SYNCML_DM_IO_FAILURE;
+ }
+ }
+ else
+ if(bYte == (NODE_START_TAG | TAG_CONTENT_MASK))
+ {
+
+ /* This method reads in the node property data as well as
+ * the byte that signaled the end of the node.
+ * It allocates a props structure we are responsible for,
+ * It also sets props->pbURI to NULL.
+ */
+ if(reader.readNode(&props, &bYte) != SYNCML_DM_SUCCESS)
+ {
+ fileHandle.close();
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* Add the node to the tree */
+
+ ret_stat = pTree->AddNode(&pNode, props);
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ break;
+
+ }
+ else
+ {
+ /* Invalid byte read */
+ ret_stat = SYNCML_DM_TREE_CORRUPT;
+ break;
+ }
+ }/* End while */
+
+ fileHandle.close();
+ XPL_LOG_DM_TMN_Debug(("End of deserialize ret_stat=%d\n", ret_stat));
+
+ //set time stamp to emmory file
+ if ( bWFS )
+ serializeDone();
+
+ return ret_stat;
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLArchive::getLastModifiedTime
+
+Description: Retrieves the last modification time of the archive
+
+==================================================================================================*/
+
+XPL_CLK_CLOCK_T
+SyncML_DM_WBXMLArchive::getLastModifiedTime()
+{
+ XPL_CLK_CLOCK_T lastModified=XPL_FS_GetModTime(m_strWFSFileName);
+ return lastModified;
+}
+
+XPL_CLK_CLOCK_T SyncML_DM_WBXMLArchive::getLastSavedTime()
+{
+ return lastSavedTime;
+}
+
+void SyncML_DM_WBXMLArchive::serializeDone()
+{
+ lastSavedTime=XPL_FS_GetModTime(m_strWFSFileName);
+ oEventLogger.OnTreeSaved();
+}
+
+// returns TRUE if permission is allowed
+BOOLEAN
+SyncML_DM_WBXMLArchive::verifyPermission(XPL_FS_OPEN_MODE_T permission) const
+{
+ // XPL_LOG_DM_TMN_Debug(("m_permission=%d, filename=%s\n", m_permission, m_strWFSFileName.c_str()));
+ return (m_permission & permission);
+}
+
+
+#ifdef LOB_SUPPORT
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLArchive::commitESN
+
+Description: Commit all changes for ESN
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLArchive::commitESN(DMTree* tree)
+{
+ SYNCML_DM_SERIALIZATION_STATUS_T ser_ret_stat;
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+
+ //Remove commit log file
+ if(commitLog != NULL)
+ {
+ //Commit log file name = Path + "commit" + null
+ DMString strTempFilePath = m_strWFSFileName;
+ strTempFilePath += DMFileHandler::COMMIT_LOG_EXTENSION;
+ commitLog->playLog(strTempFilePath.c_str());
+ delete commitLog;
+ commitLog = NULL;
+
+ /* Create the path string for the temp file */
+ if (this->rootTreeNode==NULL)
+ return SYNCML_DM_SKIP_SUBTREE;
+
+ tree->InitSerializationList(this->rootTreeNode);
+
+ DMNode * pRetNode = NULL;
+ /* Loop on the nodes returned by the tree and node manager */
+ INT32 nEndTagsNumber = 0;
+ while((ser_ret_stat = tree->GetSerializationListNextItem(&pRetNode, nEndTagsNumber)) == SYNCML_DM_SERIALIZATION_SUCCESS)
+ {
+ // Special case for ESN
+ if(pRetNode->IsESN())
+ {
+ // Convert to ESN pointer
+ DMDefaultESN *tempESN = reinterpret_cast< DMDefaultESN *>(pRetNode);
+ // Call commit command handler
+ retStatus = tempESN->Commit();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ }
+ }/* End while */
+ }
+ return SYNCML_DM_SUCCESS;
+}
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLArchive::rollback
+
+Description: Rollback all changes for ESN
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLArchive::rollbackESN(DMTree* tree)
+{
+ SYNCML_DM_SERIALIZATION_STATUS_T ser_ret_stat;
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+
+ //Remove commit log file
+ if(commitLog != NULL)
+ {
+ commitLog->RemoveLog();
+ delete commitLog;
+ commitLog = NULL;
+
+ /* Create the path string for the temp file */
+ if (this->rootTreeNode==NULL)
+ return SYNCML_DM_SKIP_SUBTREE;
+
+ tree->InitSerializationList(this->rootTreeNode);
+
+ DMNode * pRetNode = NULL;
+ /* Loop on the nodes returned by the tree and node manager */
+ INT32 nEndTagsNumber = 0;
+ while((ser_ret_stat = tree->GetSerializationListNextItem(&pRetNode, nEndTagsNumber)) == SYNCML_DM_SERIALIZATION_SUCCESS)
+ {
+ // Special case for ESN
+ if(pRetNode->IsESN())
+ {
+ // Convert to ESN pointer
+ DMDefaultESN *tempESN = reinterpret_cast< DMDefaultESN *>(pRetNode);
+ // Call rollback command handler
+ retStatus = tempESN->Rollback();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ }
+ }/* End while */
+ }
+ return SYNCML_DM_SUCCESS;
+}
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLArchive::GetCommitLogHandler
+
+Description: Retrieves the commit log handler
+
+==================================================================================================*/
+SyncML_Commit_Log* SyncML_DM_WBXMLArchive::GetCommitLogHandler()
+{
+ if(commitLog == NULL)
+ { commitLog = new SyncML_Commit_Log();
+ if(this->commitLog != NULL)
+ {
+ //Commit log file name = Path + "commit" + null
+ DMString strTempFilePath = m_strWFSFileName;
+ strTempFilePath += DMFileHandler::COMMIT_LOG_EXTENSION;
+ if(this->commitLog->InitLog(strTempFilePath.c_str()) != SYNCML_DM_SUCCESS)
+ {
+ delete commitLog;
+ commitLog = NULL;
+ }
+ }
+ }
+ return commitLog;
+}
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLArchive::CloseCommitLog
+
+Description: Close the commit log file
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_DM_WBXMLArchive::CloseCommitLog()
+{
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ if(commitLog != NULL)
+ ret_stat = commitLog->CloseLog();
+ return ret_stat;
+}
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLArchive::PlayCommitLog
+
+Description: Free the commit log handler
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_DM_WBXMLArchive::PlayCommitLog()
+{
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ if(commitLog == NULL)
+ GetCommitLogHandler();
+ if(commitLog != NULL)
+ {
+ commitLog->playLog();
+ commitLog->RemoveLog();
+ delete commitLog;
+ commitLog = NULL;
+ }
+ return ret_stat;
+}
+#endif
diff --git a/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLReader.cc b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLReader.cc
new file mode 100644
index 0000000..85f0406
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLReader.cc
@@ -0,0 +1,808 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SyncML_DM_WBXMLReader.H"
+#include "SyncML_DM_WBXMLArchive.H"
+#include "SyncML_Log.H"
+#include "SyncML_PlugIn_WBXMLLog.H"
+#include "dm_tree_util.h"
+#include "xpl_Logger.h"
+#include "dmprofile.h"
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLReader::readByte
+
+Description: Reads a byte of data from the file handle
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readByte(UINT8* byte) {
+ return this->fileHandle->read(byte, 1);
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLReader::readHeader
+
+Description: Reads the WBXML header from the file start.
+ We expect the exact 4 bytes that we serialize back out.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readHeader() {
+ UINT8 bYte;
+
+ /* Read in version */
+ if (this->readByte(&bYte) != SYNCML_DM_SUCCESS
+ || bYte != SyncML_DM_WBXMLArchive::WBXML_VERSION) {
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* Read in public identifier */
+ if (this->readByte(&bYte) != SYNCML_DM_SUCCESS
+ || bYte != SyncML_DM_WBXMLArchive::PUBLIC_ID) {
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* read charset (check for UTF-8 for all files) */
+ if (this->readByte(&bYte) != SYNCML_DM_SUCCESS
+ || bYte != SyncML_DM_WBXMLArchive::CHARSET) {
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ /* Read in string table length; better be zero, since not supported */
+ if (this->readByte(&bYte) != SYNCML_DM_SUCCESS
+ || bYte != 0) {
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLReader::readLen
+
+Description:
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readLen(UINT32 *pLen) {
+ SYNCML_DM_RET_STATUS_T ret;
+ UINT8 bYte;
+
+ /* Read and decode the data length.
+ * Note! The first byte of the length not expected to have the continue bit set (in msb).
+ * If it is, the length is >=128 and this code does not know how to decode it.
+ */
+
+ if ((ret = this->readByte(&bYte)) != SYNCML_DM_SUCCESS) {
+ return ret;
+ }
+ *pLen = bYte & 0x7F;
+ while(bYte & 0x80) {
+ if ((ret = this->readByte(&bYte)) != SYNCML_DM_SUCCESS)
+ return ret;
+ *pLen = ( (*pLen)<<7) |(bYte & 0x7F);
+ }
+
+ /* If there is data, get a buffer, read the data, append '\0' */
+ if (*pLen>127)
+ {
+ XPL_LOG_DM_TMN_Debug(("*pLen=%d\n", *pLen));
+ }
+ return ret;
+}
+
+ /*==================================================================================================
+
+Function: SyncML_DM_WBXMLReader::readOpaque
+
+Description: Reads opaquely encoded data expected to immediately follow the OPAQUE_CODE byte in the
+ WBXML file. This function expects a data length field, encoded as mb_u_int32
+ 32 bit unsigned integer, encoded in multi-byte integer format, to precede the data.
+ The length is decoded and returned. The data may or may not be a string, and so no
+ assumptions about null termination are made while reading it. However, as a courtesy to
+ the caller, a null character is appended to the data read. The returned length does not
+ include this character.
+
+ Note! The implementation only supports encoded lengths <= 127.
+ An I/O error (SYNCML_DM_IO_FAILURE) is returned otherwise, and no data buffer is allocated
+ (NULL is returned).
+
+ If the encoded length is zero, no data buffer is allocated
+ (NULL is returned). The result is SYNCML_DM_SUCCESS.
+
+ The file pointer is automatically advanced by the underlying file reader service. Any
+ underlying file I/O error code is expected to be SYNCML_DM_IO_FAILURE.
+
+ The caller must free the data buffer.
+
+ Future enhancement: If incoming *pDATA is NULL, this function should allocate memory;
+ else, the caller has provided the memory, and *pLen indicates how large it is. This
+ would reduce memory churn.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readOpaque(UINT8 *pBuffer, UINT8 nSize) {
+ SYNCML_DM_RET_STATUS_T ret;
+ UINT32 nLen;
+
+ *pBuffer = 0;
+ if ((ret = readLen(&nLen)) != SYNCML_DM_SUCCESS)
+ return ret;
+ if ( nLen > nSize )
+ return SYNCML_DM_FAIL;
+ if (nLen > 0)
+ ret = fileHandle->read(pBuffer, nLen);
+ return ret;
+}
+
+ /*==================================================================================================
+
+Function: SyncML_DM_WBXMLReader::readOpaque
+
+Description: Reads opaquely encoded data expected to immediately follow the OPAQUE_CODE byte in the
+ WBXML file. This function expects a data length field, encoded as mb_u_int32
+ 32 bit unsigned integer, encoded in multi-byte integer format, to precede the data.
+ The length is decoded and returned. The data may or may not be a string, and so no
+ assumptions about null termination are made while reading it. However, as a courtesy to
+ the caller, a null character is appended to the data read. The returned length does not
+ include this character.
+
+ Note! The implementation only supports encoded lengths <= 127.
+ An I/O error (SYNCML_DM_IO_FAILURE) is returned otherwise, and no data buffer is allocated
+ (NULL is returned).
+
+ If the encoded length is zero, no data buffer is allocated
+ (NULL is returned). The result is SYNCML_DM_SUCCESS.
+
+ The file pointer is automatically advanced by the underlying file reader service. Any
+ underlying file I/O error code is expected to be SYNCML_DM_IO_FAILURE.
+
+ The caller must free the data buffer.
+
+ Future enhancement: If incoming *pDATA is NULL, this function should allocate memory;
+ else, the caller has provided the memory, and *pLen indicates how large it is. This
+ would reduce memory churn.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readOpaque(DMBuffer *pBuffer) {
+ SYNCML_DM_RET_STATUS_T ret;
+ UINT32 nLen;
+
+ pBuffer->clear();
+ if ((ret = readLen(&nLen)) != SYNCML_DM_SUCCESS) {
+ return ret;
+ }
+ if (nLen > 0)
+ {
+ pBuffer->allocate(nLen);
+ if ( pBuffer->getBuffer() != NULL )
+ {
+ ret = fileHandle->read(pBuffer->getBuffer(), nLen);
+ pBuffer->setSize(nLen);
+ }
+ else
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ return ret;
+}
+
+
+/*==================================================================================================
+Function: SyncML_DM_WBXMLReader::readNode
+
+Description: Reads a node and its properties from a WBXML file. The NODE_START_TAG
+ is assumed to already have been read. Exits after all properties have
+ been read, signaled by an END_TAG or the NODE_START_TAG of the next node.
+
+Returns: - The byte that caused the node to stop (END_TAG or NODE_START_TAG w/content bit)
+ - A node props structure, with:
+ node->pbURI set to NULL
+ node->pbACL possibly set to an Alloc'd string
+ The caller is responsible for freeing these structs (on error or success).
+
+ SYNCML_DM_TREE_CORRUPT is returned if any I/O error occurs,
+ or an unexpected opcode is encountered, or an invalid length is encountered.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readNode(DMAddNodeProp* node, UINT8* stopByte) {
+
+ UINT8 bYte;
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_FAIL;
+
+
+ /* Initialize the property data */
+ node->clear();
+
+ /* While a byte is read correctly */
+ while((ret_stat = this->readByte(&bYte)) == SYNCML_DM_SUCCESS) {
+
+ /* Switch on that byte as an indicator of the data to follow
+ * and copy that data.
+ */
+ switch(bYte) {
+ case (SyncML_DM_WBXMLArchive::END_TAG):
+ case (SyncML_DM_WBXMLArchive::NODE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ *stopByte = bYte;
+ return SYNCML_DM_SUCCESS;
+
+#ifdef LOB_SUPPORT
+ case (SyncML_DM_WBXMLArchive::ESN_File_NAME_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readESNFileName(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+#endif
+ case (SyncML_DM_WBXMLArchive::NAME_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readNodeName(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+
+ case (SyncML_DM_WBXMLArchive::ACL_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ case (SyncML_DM_WBXMLArchive::PLURAL_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ case (SyncML_DM_WBXMLArchive::URI_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->skipTag(&bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+
+ case (SyncML_DM_WBXMLArchive::ACCESS_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readAccess(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+
+ case (SyncML_DM_WBXMLArchive::SCOPE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readScope(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+
+ case (SyncML_DM_WBXMLArchive::CLASSID_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readClassID(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+
+ case (SyncML_DM_WBXMLArchive::FORMAT_NEW_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readFormat(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+
+ case (SyncML_DM_WBXMLArchive::FORMAT_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readFormatOld(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+#ifdef LOB_SUPPORT
+ /* Handles an Empty NodeName */
+ case SyncML_DM_WBXMLArchive::ESN_File_NAME_START_TAG:
+ continue; /* Skip to top of while() */
+#endif
+ /* Handles an Empty NodeName */
+ case SyncML_DM_WBXMLArchive::NAME_START_TAG:
+ continue; /* Skip to top of while() */
+
+ case (SyncML_DM_WBXMLArchive::TYPE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readMime(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+
+ case (SyncML_DM_WBXMLArchive::DATA_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readData(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+
+ case (SyncML_DM_WBXMLArchive::TITLE_START_TAG |SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readTitle(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+
+ case (SyncML_DM_WBXMLArchive::VERSION_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readVersion(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue; /* Skip to top of while() */
+ // dp: compact format
+ case (SyncML_DM_WBXMLArchive::TSTAMP_INT_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readIntTStamp(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+ continue;
+
+#endif
+
+ case (SyncML_DM_WBXMLArchive::FLAGS_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readFlag(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+
+ continue;
+
+ case (SyncML_DM_WBXMLArchive::OPI_DATA_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK):
+ if((ret_stat = this->readOPiData(node, &bYte)) != SYNCML_DM_SUCCESS)
+ break;
+
+ continue;
+
+ default: /* Do not expect to get here */
+ ret_stat = SYNCML_DM_FAIL;
+ break;
+ }
+
+ /* If we get here, then either none of the continue statements in the switch happened,
+ * or else an unexpected byte value was read (and we exited the switch via a break).
+ * This next break will leave the while() loop, adn the fcn exits with an error.
+ */
+ break;
+ }
+
+ return ret_stat;
+}
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLReader::readOneLogRecord
+
+Description: The DMAddNodeProp and URI fields are completed by this function
+ on successful return. This function calls SyncML_DM_WBXMLReader::readNode() in order
+ to fill in the property data for the node.
+
+Memory policy: The caller is responsible for freeing the created objects (on error or success).
+
+Notes: The DMAddNodeProp.pbURI field is not filled by this function
+
+==================================================================================================*/
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readOneLogRecord(SYNCML_DM_PLUGIN_COMMAND_T* cmdType,
+ DMBuffer *cmdURI,
+ SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T * attribute,
+ DMAddNodeProp* props,
+ UINT8* stopByte)
+{
+
+ UINT8 bYte;
+ DMString tmpStr;
+
+ /* Default values */
+ *cmdType = SYNCML_DM_PLUGIN_NO_COMMAND;
+ props->clear();
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_FAIL;
+
+ //Read command type start tag
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != (SyncML_DM_WBXMLArchive::CMDTYPE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read command type
+ if((ret_code = this->readByte(cmdType)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read END_TAG
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS ||
+ bYte != SyncML_DM_WBXMLArchive::END_TAG)
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read command type start tag
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != (SyncML_DM_WBXMLArchive::URI_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read command type start tag
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != SyncML_DM_WBXMLArchive::OPAQUE_CODE)
+ return SYNCML_DM_IO_FAILURE;
+
+ // Read URI
+ if((ret_code = this->readOpaque(cmdURI)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read END_TAG
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != SyncML_DM_WBXMLArchive::END_TAG)
+ return SYNCML_DM_IO_FAILURE;
+
+ switch ( *cmdType )
+ {
+ case SYNCML_DM_PLUGIN_ADD:
+ //Read command type start tag
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != (SyncML_DM_WBXMLArchive::NODE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ return SYNCML_DM_IO_FAILURE;
+ if((ret_code = this->readNode(props, stopByte)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ break;
+
+ case SYNCML_DM_PLUGIN_DELETE:
+ case SYNCML_DM_PLUGIN_ADD_CHILD:
+ if((ret_code = this->readByte(stopByte)) != SYNCML_DM_SUCCESS
+ || *stopByte != SyncML_DM_WBXMLArchive::END_TAG)
+ return SYNCML_DM_IO_FAILURE;
+ break;
+
+ case SYNCML_DM_REPLACE:
+ if((ret_code = this->readByte(attribute)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ switch(*attribute)
+ {
+ case SYNCML_DM_PLUGIN_COMMAND_ON_NODE:
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != (SyncML_DM_WBXMLArchive::DATA_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ return SYNCML_DM_IO_FAILURE;
+
+ if((ret_code = this->readData(props, stopByte)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ break;
+
+
+ case SYNCML_DM_PLUGIN_COMMAND_ON_NAME_PROPERTY:
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != (SyncML_DM_WBXMLArchive::NAME_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ return SYNCML_DM_IO_FAILURE;
+
+ if((ret_code = this->readNodeName(props, stopByte)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ break;
+
+ case SYNCML_DM_PLUGIN_COMMAND_ON_TITLE_PROPERTY:
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != (SyncML_DM_WBXMLArchive::TITLE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ return SYNCML_DM_IO_FAILURE;
+ if((ret_code = this->readTitle(props, stopByte)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ break;
+
+#ifdef LOB_SUPPORT
+ case SYNCML_DM_PLUGIN_COMMAND_ON_LOB_PROPERTY:
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(bYte == (SyncML_DM_WBXMLArchive::ESN_File_NAME_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ { if((ret_code = this->readESNFileName(props, stopByte)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+ else
+ if(bYte != SyncML_DM_WBXMLArchive::END_TAG)
+ return SYNCML_DM_IO_FAILURE;
+
+ break;
+#endif
+ default:
+ return SYNCML_DM_IO_FAILURE;
+ }
+ break;
+
+
+ default:
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLReader::readOneCommitLogRecord
+
+Description: Read one record from commit log file
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_DM_WBXMLReader::readOneCommitLogRecord(SYNCML_DM_COMMAND_T* cmdType,
+ DMBuffer *sourceFileName,
+ DMBuffer *targetFileName,
+ UINT8* /*stopByte */)
+{
+
+ UINT8 bYte;
+ DMString tmpStr;
+
+ /* Default values */
+ *cmdType = SYNCML_DM_NO_COMMAND;
+
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_FAIL;
+
+ //Read command type start tag
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != (SyncML_DM_WBXMLArchive::CMDTYPE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read command type
+ if((ret_code = this->readByte(cmdType)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read END_TAG
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS ||
+ bYte != SyncML_DM_WBXMLArchive::END_TAG)
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read command type start tag
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != (SyncML_DM_WBXMLArchive::TARGET_FILE_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read target file name
+ if((ret_code = this->readOpaqueTag(&bYte, targetFileName)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if( *cmdType == SYNCML_DM_REPLACE)
+ {
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ // Is the original file name exist?
+ if(bYte == (SyncML_DM_WBXMLArchive::SOURCE_FILE_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ {
+ // Read source file name
+ if((ret_code = this->readOpaqueTag(&bYte, sourceFileName)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ //Read END_TAG
+ if((ret_code = this->readByte(&bYte)) != SYNCML_DM_SUCCESS
+ || bYte != SyncML_DM_WBXMLArchive::END_TAG)
+ return SYNCML_DM_IO_FAILURE;
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLReader::operator new
+
+Description: Allocate memory for this object
+
+Memory policy: The caller is responsible to delete (free) the new object (alloc'd memory)
+
+==================================================================================================*/
+void *
+SyncML_DM_WBXMLReader::operator new(size_t sz) {
+ return (DmAllocMem(sz));
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLReader::operator delete
+
+Description: De-allocate memory for this object
+
+==================================================================================================*/
+void
+SyncML_DM_WBXMLReader::operator delete (void *buf) {
+ DmFreeMem(buf);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readOpaqueTag(UINT8* pByte, UINT8 *pBuffer, UINT8 nSize) {
+
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+ if((ret_stat = this->readByte(pByte)) != SYNCML_DM_SUCCESS)
+ return ret_stat;
+
+ if(*pByte != SyncML_DM_WBXMLArchive::OPAQUE_CODE)
+ return SYNCML_DM_TREE_CORRUPT;
+
+ ret_stat = this->readOpaque(pBuffer, nSize);
+ if( ret_stat != SYNCML_DM_SUCCESS )
+ return ret_stat;
+
+ return checkNextByteIsEndTag(pByte);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readOpaqueTag(UINT8* pByte, DMBuffer *pBuffer) {
+
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+ if((ret_stat = this->readByte(pByte)) != SYNCML_DM_SUCCESS)
+ return ret_stat;
+
+ if(*pByte != SyncML_DM_WBXMLArchive::OPAQUE_CODE)
+ return SYNCML_DM_TREE_CORRUPT;
+
+ ret_stat = this->readOpaque(pBuffer);
+ if ( ret_stat != SYNCML_DM_SUCCESS )
+ return ret_stat;
+
+ return checkNextByteIsEndTag(pByte);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::checkNextByteIsEndTag(UINT8* pByte)
+{
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+ if((ret_stat = this->readByte(pByte)) != SYNCML_DM_SUCCESS)
+ return ret_stat;
+ if(*pByte != SyncML_DM_WBXMLArchive::END_TAG)
+ return SYNCML_DM_TREE_CORRUPT;
+
+ return ret_stat;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::skipTag(UINT8* pByte)
+{
+ DMBuffer property;
+
+ return this->readOpaqueTag(pByte,&property);
+}
+
+#ifdef LOB_SUPPORT
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readESNFileName(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ return this->readOpaqueTag(pByte, &nodeProps->m_oESNFileName);
+}
+#endif
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readNodeName(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+
+ return this->readOpaqueTag(pByte, &nodeProps->m_oName);
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readAccess(DMAddNodeProp* /*nodeProps*/, UINT8* pByte)
+{
+ UINT8 property[2];
+
+ return this->readOpaqueTag(pByte, property,2);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readScope(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ UINT8 bScope = 0;
+
+ if((ret_stat = this->readOpaqueTag(pByte, &bScope,1)) != SYNCML_DM_SUCCESS)
+ return ret_stat;
+
+ if ( bScope == DMTNM_NODE_PERMANENT )
+ nodeProps->m_nFlags |= DMNode::enum_NodePermanent;
+
+ return ret_stat;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readClassID(DMAddNodeProp* /*nodeProps*/, UINT8* pByte)
+{
+ UINT8 property[2];
+
+ return this->readOpaqueTag(pByte, property,2);
+}
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readFormat(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ return readOpaqueTag(pByte, &nodeProps->m_nFormat,1);
+}
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readFormatOld(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ SYNCML_DM_FORMAT_T nOldFormat = 0;
+ SYNCML_DM_RET_STATUS_T nRes = readOpaqueTag(pByte, &nOldFormat,1);
+
+ static const SYNCML_DM_FORMAT_T aFormats[] = {
+ SYNCML_DM_FORMAT_BIN,
+ SYNCML_DM_FORMAT_BOOL,
+ SYNCML_DM_FORMAT_B64,
+ SYNCML_DM_FORMAT_CHR,
+ SYNCML_DM_FORMAT_INT,
+ SYNCML_DM_FORMAT_NODE,
+ SYNCML_DM_FORMAT_NULL,
+ SYNCML_DM_FORMAT_XML,
+ SYNCML_DM_FORMAT_INVALID,
+ SYNCML_DM_FORMAT_TEST,
+ SYNCML_DM_FORMAT_FLOAT,
+ SYNCML_DM_FORMAT_DATE,
+ SYNCML_DM_FORMAT_TIME
+
+ };
+
+ if ( nRes == SYNCML_DM_SUCCESS && nOldFormat < DIM(aFormats) )
+ nodeProps->m_nFormat = aFormats[nOldFormat];
+ else
+ nodeProps->m_nFormat = SYNCML_DM_FORMAT_NODE;
+
+ return nRes;
+}
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readMime(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ return this->readOpaqueTag(pByte, &nodeProps->m_oMimeType);
+}
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readData(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ return this->readOpaqueTag(pByte, &nodeProps->m_oData);
+}
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readOPiData(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ return this->readOpaqueTag(pByte, &nodeProps->m_oOPiData);
+}
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readTitle(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ return this->readOpaqueTag(pByte, &nodeProps->m_oTitle);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readFlag(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ UINT8 property[2];
+ SYNCML_DM_RET_STATUS_T ret_stat;
+
+ if((ret_stat = this->readOpaqueTag(pByte, (UINT8*)&property,2)) != SYNCML_DM_SUCCESS)
+ return ret_stat;
+
+ nodeProps->m_nFlags = (property[0] << 8) | property[1]; /* stored in Big Endian order */
+ nodeProps->m_nFlags &= ~DMNode::enum_NodeNotPersisted;
+ return ret_stat;
+}
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readIntTStamp(DMAddNodeProp* nodeProps, UINT8* pByte)
+{
+ UINT8 timeStamp[ sizeof(XPL_CLK_CLOCK_T) ];
+ SYNCML_DM_RET_STATUS_T ret_stat;
+
+ if ( (ret_stat = this->readOpaqueTag(pByte, timeStamp, sizeof(timeStamp) )) != SYNCML_DM_SUCCESS)
+ return ret_stat;
+
+ nodeProps->m_nTStamp=0;
+ for ( UINT32 i = 0; i < sizeof(XPL_CLK_CLOCK_T); i++ ) {
+ //NOT USE nodeProps->wTStamp |= ((XPL_CLK_CLOCK_T)timeStamp[sizeof(XPL_CLK_CLOCK_T) - i -1]) << (i*8);
+ nodeProps->m_nTStamp |= ((XPL_CLK_CLOCK_T)timeStamp[i]) << (i*8);
+ }
+
+ return ret_stat;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLReader::readVersion(DMAddNodeProp* nodeProps, UINT8* pByte) {
+
+ UINT8 property[2];
+ SYNCML_DM_RET_STATUS_T ret_stat;
+
+ if((ret_stat = this->readOpaqueTag(pByte, (UINT8*)&property,2)) != SYNCML_DM_SUCCESS)
+ return ret_stat;
+
+ nodeProps->m_nVerNo = (property[0] << 8) | property[1]; /* stored in Big Endian order */
+ return ret_stat;
+}
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLWriter.cc b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLWriter.cc
new file mode 100644
index 0000000..eaf2d51
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/SyncML_DM_WBXMLWriter.cc
@@ -0,0 +1,299 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SyncML_DM_WBXMLWriter.H"
+#include "SyncML_DM_WBXMLArchive.H"
+
+#ifdef LOB_SUPPORT
+#include "dm_tree_default_ESN_class.H" //header file for class defn
+#endif
+
+#include "dm_uri_utils.h"
+const int SyncML_DM_WBXMLWriter::MAX_OPAQUE_STRING_LENGTH = 255;
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLWriter::writeByte
+
+Description: Write a byte of data to the file handle
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLWriter::writeByte(UINT8 byte) {
+ return this->fileHandle->write(&byte, 1);
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLWriter::writeString
+
+Description: Writes a string of data as opaque data. The null terminator will
+ not be written, as opaque data has a length stored with it. If the
+ string is NULL, that will be written as an opaque data with length 0.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLWriter::writeString(CPCHAR string) {
+ UINT32 len = 0;
+
+ if (string != NULL)
+ len = DmStrlen(string);
+ return writeOpaque((UINT8*)string, len);
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLWriter::writeData
+
+Description: Writes a given amount of raw data (without WBXML formatting or special encodings)
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLWriter::writeData(const UINT8* data, UINT8 len) {
+ return this->fileHandle->write(data, len);
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLWriter::writeOpaque
+
+Description:
+ Write opaque data of a given length.
+ The data better be less than 128 bytes in length,
+ as this service does not handle encoding the mb_u_int32 format.
+
+ The service returns the success/fail code from the lower level I/O, or
+ may also return SYNCML_DM_IO_FAILURE if the data was too long.
+
+ A length of 0 and/or a NULL data buffer is handled.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLWriter::writeOpaque(const UINT8* data, UINT32 len) {
+ SYNCML_DM_RET_STATUS_T ret_stat;
+
+ ret_stat = writeByte(SyncML_DM_WBXMLArchive::OPAQUE_CODE);
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ return ret_stat;
+
+ if((data != NULL) && (len != 0)) {
+
+ UINT8 result, bits;
+ int continuation=0;
+ for(int shift = 28; shift > 0; shift -= 7) {
+ bits = (len >> shift) & 0x7F;
+ if ((bits!=0) ||(continuation != 0)) {
+ result = 0x80 | bits;
+ ret_stat = writeByte((UINT8)result);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+ if (bits != 0)
+ continuation = 1;
+ }
+ result = len & 0x7F;
+ ret_stat = writeByte((UINT8)result);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ ret_stat = this->fileHandle->write(data, (UINT16)len);
+
+ } else {
+ /* Since the pointer to the byte is NULL, then there is no opaque data
+ * for this node to be written, so the length field is zero. Zero encoded
+ * in the mb_u_int32 format takes one byte, 0.
+ */
+ ret_stat = writeByte((UINT8)0);
+ }
+
+ return ret_stat;
+}
+
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLWriter::writeNode
+
+Description: Write a SYNCML_DM_NODE_PROPERTIES_T type node of data to the WBXML file
+ Note! This service does not write the END_TAG for the whole node; the next byte that can occur
+ is a NODE_START_TAG (indicating the start of a new sub-node) or an END_TAG, (indicating the end
+ of the current node, and parhaps the end of the current branch of the tree). The caller must
+ decide what to write next.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_DM_WBXMLWriter::writeNode(const DMNode* node) {
+ /* Write the start tag */
+ if(writeByte(SyncML_DM_WBXMLArchive::NODE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ /* Write node properties */
+ CPCHAR tmpStr;
+ tmpStr = node->getName();
+
+ if ( DmStrcmp(tmpStr,"") != 0 ) /* If there a NodeName to write... */
+ {
+ if(writeByte(SyncML_DM_WBXMLArchive::NAME_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writeString(tmpStr) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+ UINT8 nodeFormat = (const UINT8) node->getFormat();
+
+ if ( node->IsOverlayPIData() && nodeFormat == SYNCML_DM_FORMAT_NODE )
+ nodeFormat = SYNCML_DM_FORMAT_NODE_PDATA;
+
+ if ( nodeFormat != SYNCML_DM_FORMAT_NODE ) {
+ if(writeByte(SyncML_DM_WBXMLArchive::FORMAT_NEW_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writeOpaque((const UINT8*)&nodeFormat, sizeof(nodeFormat)) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+#ifdef LOB_SUPPORT
+ if(node->IsESN())
+ {
+ DMString tempESNName;
+
+ // Get ESN pointer
+ const DMDefaultESN *tempESN = reinterpret_cast<const DMDefaultESN *>(node);
+ // Get original storage file name
+ tmpStr = tempESN->GetOriginalInternalFileName();
+
+ // Storage file changed ?
+ if(tempESN->IsDirty())
+ {
+ if(tempESN->IsSetComplete())
+ {
+ // Newly created node
+ if(tmpStr == NULL)
+ { tempESNName.RemoveSufix(tempESN->GetInternalStorageFileName(), SYNCML_DM_DOT);
+ tmpStr = tempESNName.c_str();
+ }
+ }
+ else
+ return SYNCML_DM_INCOMPLETE_COMMAND;
+ }
+ if(DmStrlen(tmpStr) != 0) /* If there a file name to write... */
+ {
+ if(writeByte(SyncML_DM_WBXMLArchive::ESN_File_NAME_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writeString(tmpStr) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+ }
+#endif
+ if ( node->IsOverlayPIData() && node->getOverlayPIData() && node->getOverlayPIData()->size() > 0 )
+ {
+ if(writeByte(SyncML_DM_WBXMLArchive::OPI_DATA_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writeOpaque(node->getOverlayPIData()->get_data(), node->getOverlayPIData()->size()) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+ UINT16 flag = node->getFlags(); flag &= ~DMNode::enum_NodeNotPersisted;
+ /* Guarantee Big Endian storage of a UINT16 */
+ UINT8 flagNo[2] = { static_cast<UINT8>(flag >> 8),
+ static_cast<UINT8>(flag & 0xFF) };
+ if ( flag ){
+ if(writeByte(SyncML_DM_WBXMLArchive::FLAGS_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writeOpaque(flagNo, sizeof(flagNo)) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ tmpStr = node->getType();
+ if (DmStrcmp(tmpStr,"") != 0) /* If there are any mimetype to write... */
+ {
+ if(writeByte(SyncML_DM_WBXMLArchive::TYPE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writeString(tmpStr) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ const DMBuffer * psData = node->getData();
+
+ if ( psData && psData->getSize() ) /* If there are any ACLs to write... */
+ {
+ if(writeByte(SyncML_DM_WBXMLArchive::DATA_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writeOpaque(psData->getBuffer(), psData->getSize()) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ tmpStr = node->getTitle();
+ if (DmStrcmp(tmpStr,"") != 0) {
+ if(writeByte(SyncML_DM_WBXMLArchive::TITLE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writeString(tmpStr) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ {
+ DMNode * pNode = (DMNode*)node;
+
+ UINT8 timeStamp[ sizeof(XPL_CLK_CLOCK_T) ];
+
+ XPL_CLK_CLOCK_T tStamp = pNode->GetTStamp(NULL);
+
+ for ( UINT32 i = 0; i < sizeof(XPL_CLK_CLOCK_T); i++ )
+ timeStamp[i] = (UINT8)(tStamp >> (i*8));
+
+ if(writeByte(SyncML_DM_WBXMLArchive::TSTAMP_INT_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writeOpaque(timeStamp, sizeof(timeStamp) ) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(writeByte(SyncML_DM_WBXMLArchive::VERSION_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ /* Guarantee Big Endian storage of a UINT16 */
+ UINT16 wVerNo = pNode->GetVerNo(NULL);
+ UINT8 verNo[2] = { static_cast<UINT8>(wVerNo >> 8),
+ static_cast<UINT8>(wVerNo & 0xFF) };
+ if(writeOpaque(verNo, sizeof(verNo)) != SYNCML_DM_SUCCESS ||
+ writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+#endif
+
+ return SYNCML_DM_SUCCESS;
+}
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLWriter::operator new
+
+Description: Allocate memory for this object
+
+Memory policy: The caller is responsible to delete (free) the new object (alloc'd memory)
+
+==================================================================================================*/
+void *
+SyncML_DM_WBXMLWriter::operator new(size_t sz) {
+ return (DmAllocMem(sz));
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_WBXMLWriter::operator delete
+
+Description: De-allocate memory for this object
+
+==================================================================================================*/
+void
+SyncML_DM_WBXMLWriter::operator delete (void *buf) {
+ DmFreeMem(buf);
+}
diff --git a/engine/dmlib/dmengine/dm_persist/src/SyncML_Log.cc b/engine/dmlib/dmengine/dm_persist/src/SyncML_Log.cc
new file mode 100644
index 0000000..f45ec2b
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/SyncML_Log.cc
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "SyncML_Log.H"
+
+/*==================================================================================================
+
+Function: SyncML_Log::SyncML_Log
+
+Description: Constructor for the Log object
+
+==================================================================================================*/
+SyncML_Log::SyncML_Log()
+{
+ this->fileHandle = NULL;
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_Log::InitLog
+
+Description: Open log
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_Log::InitLog(CPCHAR logFileName)
+{
+ if (fileHandle != NULL)
+ CloseLog();
+
+ INT32 modeFlag = XPL_FS_FILE_RDWR;
+ // If file does not exist use write mode instead of read/write to prevent file I/O error
+ if (!XPL_FS_Exist(logFileName))
+ modeFlag = XPL_FS_FILE_WRITE;
+
+ fileHandle = new DMFileHandler(logFileName);
+ if(fileHandle == NULL)
+ return SYNCML_DM_IO_FAILURE;
+ if (fileHandle->open(modeFlag) != SYNCML_DM_SUCCESS)
+ {
+ fileHandle->deleteFile();
+ delete fileHandle;
+ fileHandle = NULL;
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ return setLogFileHandle(fileHandle);
+}
+
+/*==================================================================================================
+
+Function: UnInitLog
+
+Description: Uninitialize log
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_Log::UnInitLog()
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+
+Function: :~SyncML_Log
+
+Description: Destructor for the Log object
+
+==================================================================================================*/
+SyncML_Log::~SyncML_Log()
+{
+ /* The fileHandle reference is deleted by the calling class */
+}
+
+/*==================================================================================================
+
+Function: setLogFileHandle
+
+Description: Accessor method for the file reader
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_Log::setLogFileHandle(DMFileHandler* fileHandle)
+{
+ this->fileHandle = fileHandle;
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+
+Function: getLogFileHandle
+
+Description: Accessor method for the file reader
+
+==================================================================================================*/
+DMFileHandler*
+SyncML_Log::getLogFileHandle()
+{
+ return this->fileHandle;
+}
+
+/*==================================================================================================
+
+Function: RemoveLog
+
+Description: Remove log file
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_Log::RemoveLog()
+{
+ UnInitLog();
+ if(fileHandle != NULL)
+ {
+ fileHandle->deleteFile();
+ delete fileHandle;
+ fileHandle = NULL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+
+Function: CloseLog
+
+Description: Close log file
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_Log::CloseLog()
+{
+ UnInitLog();
+ if (fileHandle != NULL)
+ {
+ fileHandle->close();
+ delete fileHandle;
+ fileHandle = NULL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+
+Function: SyncML_Log::playLog
+
+Description: Log file playback
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_Log::playLog()
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+
+Function: SyncML_Log::playLog
+
+Description: Log file playback and remove
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_Log::playLog(CPCHAR logFileName)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ retStatus = InitLog(logFileName);
+ if (retStatus == SYNCML_DM_SUCCESS)
+ {
+ retStatus = playLog();
+ }
+ RemoveLog();
+ return retStatus;
+}
diff --git a/engine/dmlib/dmengine/dm_persist/src/dmBufferReader.cc b/engine/dmlib/dmengine/dm_persist/src/dmBufferReader.cc
new file mode 100644
index 0000000..2edc9d6
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/dmBufferReader.cc
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dmBufferReader.h"
+
+DMBufferReader::DMBufferReader(UINT8 * pBuffer, UINT32 size)
+{
+ m_pBuffer = pBuffer;
+ m_nSize = size;
+ m_nPos = 0;
+}
+
+char*
+DMBufferReader::fgets()
+{
+ if ( m_nSize < 1 || !m_pBuffer )
+ return NULL;
+
+ if ( iseof() )
+ return NULL;
+
+ UINT8 * str = &m_pBuffer[m_nPos];
+
+ while ( m_pBuffer[m_nPos] != 0 && m_nPos + 1 < m_nSize )
+ {
+ m_nPos++;
+ }
+
+ m_nPos++; // next line
+ return (char*)str;
+}
+
+BOOLEAN
+DMBufferReader::iseof()
+{
+ if ( m_nPos >= m_nSize )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+CPCHAR
+DMBufferReader::ReadString()
+{
+ return fgets();
+}
+
+
+UINT8
+DMBufferReader::ReadUINT8()
+{
+ UINT8 value = 0;
+
+ Read((UINT8*)&value,sizeof(UINT8));
+
+ return value;
+
+}
+
+UINT16
+DMBufferReader::ReadUINT16()
+{
+ UINT16 value = 0;
+
+ Read((UINT8*)&value,sizeof(UINT16));
+
+ return value;
+}
+
+UINT32
+DMBufferReader::ReadUINT32()
+{
+ UINT32 value = 0;
+
+ Read((UINT8*)&value,sizeof(UINT32));
+
+ return value;
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMBufferReader::Read(UINT8 * pBuffer, UINT32 count)
+{
+
+ if ( m_nSize < 1 || !m_pBuffer )
+ return SYNCML_DM_FAIL;
+
+ if ( m_nPos + count >= m_nSize )
+ return SYNCML_DM_FAIL;
+
+ memcpy(pBuffer,m_pBuffer+m_nPos,count) ;
+ m_nPos += count;
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_persist/src/dmBufferWriter.cc b/engine/dmlib/dmengine/dm_persist/src/dmBufferWriter.cc
new file mode 100644
index 0000000..0e092de
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/dmBufferWriter.cc
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dmBufferWriter.h"
+#include "dmMemory.h"
+
+DMBufferWriter::DMBufferWriter()
+{
+ m_pBuffer = NULL;
+ m_nSize = 0;
+ m_nPos = 0;
+}
+
+DMBufferWriter::~DMBufferWriter()
+{
+ if ( m_pBuffer != NULL )
+ DmFreeMem(m_pBuffer);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMBufferWriter::Allocate(UINT32 size)
+{
+ m_pBuffer = (UINT8*)DmAllocMem(size);
+ if ( m_pBuffer == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ memset(m_pBuffer,0,size);
+ m_nSize = size;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMBufferWriter::WriteString(const DMString & str)
+{
+ if ( m_pBuffer == NULL )
+ return SYNCML_DM_FAIL;
+
+ INT32 length = str.length();
+
+ if ( m_nPos + length + 1 > m_nSize )
+ return SYNCML_DM_FAIL;
+
+ memcpy(m_pBuffer+m_nPos,str.c_str(),length+1);
+ m_nPos += length+1;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMBufferWriter::WriteString(CPCHAR str)
+{
+
+ if ( str == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ INT32 length = DmStrlen(str);
+
+ return Write((UINT8*)str,length+1);
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMBufferWriter::WriteUINT32(UINT32 data)
+{
+ return Write((UINT8*)&data,sizeof(UINT32));
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMBufferWriter::WriteUINT8(UINT8 data)
+{
+ return Write((UINT8*)&data,sizeof(UINT8));
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMBufferWriter::WriteUINT16(UINT16 data)
+{
+ return Write((UINT8*)&data,sizeof(UINT16));
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMBufferWriter::Write(UINT8 * pBuffer, UINT32 count)
+{
+ if ( m_pBuffer == NULL )
+ return SYNCML_DM_FAIL;
+
+ if ( m_nPos + count > m_nSize )
+ return SYNCML_DM_FAIL;
+
+ memcpy(m_pBuffer+m_nPos,pBuffer,count);
+ m_nPos += count;
+
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_persist/src/multiple_file_manager.cc b/engine/dmlib/dmengine/dm_persist/src/multiple_file_manager.cc
new file mode 100644
index 0000000..7587efc
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_persist/src/multiple_file_manager.cc
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "file_manager.h"
+#include "SyncML_DM_Archiver.H" //for Archiver class functions
+#include "xpl_Logger.h"
+#include "dmLockingHelper.h"
+#include "dm_tree_class.H"
+#include "dmtTreeImpl.hpp"
+#include "dmPluginManager.h"
+#include "dm_tree_plugin_util.H"
+
+#include "dmprofile.h"
+
+// assume that we support 32 or less files, so we can pass "file set" as an integer (32 bits)
+// every bit means file "selected" if it set. For example, value 6, binary 0110 means files "1" and "2"
+
+CMultipleFileManager::CMultipleFileManager()
+ : m_pTree( NULL )
+{
+}
+
+CMultipleFileManager::~CMultipleFileManager()
+{
+ DeInit();
+}
+
+SYNCML_DM_RET_STATUS_T CMultipleFileManager::Init( DMTree* tree )
+{
+ if( !tree ) return SYNCML_DM_FAIL;
+
+ m_pTree = tree;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T CMultipleFileManager::DeInit()
+{
+ m_pTree = NULL;
+ return SYNCML_DM_SUCCESS;
+}
+
+INT32 CMultipleFileManager::GetFileNumber() const
+{
+ const SyncML_DM_Archiver& archiver = m_pTree->GetArchiver();
+
+ INT32 numFiles = archiver.getNumArchives();
+ XPL_LOG_DM_TMN_Debug(("CMultipleFileManager::GetFileNumber, numFiles=%d\n", numFiles));
+
+ return numFiles;
+}
+
+FILESETTYPE CMultipleFileManager::GetFileSetByURI( CPCHAR szURI, BOOLEAN bSharedLock ) const
+{
+ const SyncML_DM_Archiver& archiver = m_pTree->GetArchiver();
+ FILESETTYPE nFileSet=0;
+
+ nFileSet = archiver.getArchivesByURI(szURI);
+
+ if (!bSharedLock && DmStrlen(szURI) >1 ) //writable and it is NOT . (if . already covered everyone) )
+ {
+ //Check constraint overlap.
+ //Logic is this: if any plugin's ONE root path is contained in the path, then THE plugins'
+ // all root paths must also go into the locked fileset.
+
+ DMPluginVector plugins;
+ DMPluginManager & oPluginManager = m_pTree->GetPluginManager();
+
+ oPluginManager.GetPlugins( szURI, SYNCML_DM_CONSTRAINT_PLUGIN, plugins);
+
+ INT32 size = plugins.size();
+ for (int i=0; i<size;i++)
+ {
+ PDMPlugin plugin=plugins[i];
+
+ nFileSet |= archiver.getArchivesByURI(plugin->GetPath() );
+ }
+ }
+ XPL_LOG_DM_TMN_Debug(("GetFileSetByURI, szURI=%s nFileSet=0x%x, bSharedLock=%d\n", szURI, nFileSet, bSharedLock));
+ return nFileSet;
+}
+
+//DeSerialize files if Not loaded
+SYNCML_DM_RET_STATUS_T
+CMultipleFileManager::LockFileSet(CPCHAR szURI,
+ FILESETTYPE nFileSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType)
+{
+ SYNCML_DM_RET_STATUS_T retStat=SYNCML_DM_SUCCESS;
+ SyncML_DM_Archiver& archiver = m_pTree->GetArchiver();
+
+ //In deserialize. Note: ACL is handled from lock manager.
+ return archiver.deserialize(nFileSet,eLockType);
+
+// if ( retStat != SYNCML_DM_SUCCESS )
+// return retStat;
+
+// DMPluginManager & oPluginManager = m_pTree->GetPluginManager();
+// return oPluginManager.UpdatePluginNodes(szURI);
+
+}
+SYNCML_DM_RET_STATUS_T CMultipleFileManager::FlushFileSet(CPCHAR szURI, FILESETTYPE nFileSet, SYNCML_DM_COMMAND_T type)
+{
+ SYNCML_DM_RET_STATUS_T retStat=SYNCML_DM_SUCCESS;
+ SYNCML_DM_RET_STATUS_T retStat1=SYNCML_DM_SUCCESS;
+ FILESETTYPE nFileSetToRollback = 0;
+
+ XPL_LOG_DM_TMN_Debug(("Enter CMultipleFileManager::UnLockFileSet,szURI=%s nFileSet=0x%x\n",szURI, nFileSet));
+
+ if ( DmGetMemFailedFlag() ) // device runs out of memory
+ return SYNCML_DM_DEVICE_FULL;
+
+ SyncML_DM_Archiver& archiver = m_pTree->GetArchiver();
+
+ retStat=DmCheckConstraint(szURI, &nFileSet,&nFileSetToRollback);
+ if (retStat != SYNCML_DM_SUCCESS)
+ {
+ retStat = RollbackFileSet(szURI, nFileSetToRollback);
+ if ( nFileSet == 0 )
+ return retStat;
+ }
+
+ if ( nFileSet )
+ {
+ retStat = DmCallPluginFunction(szURI, nFileSet, type);
+ retStat1 = archiver.serialize(nFileSet, szURI);
+ if (retStat == SYNCML_DM_SUCCESS)
+ retStat=retStat1;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("Leave CMultipleFileManager::UnlockFileSet, nFileSet=0x%x, retStat=%d\n",nFileSet, retStat));
+ return retStat;
+
+}
+
+SYNCML_DM_RET_STATUS_T CMultipleFileManager::RollbackFileSet(CPCHAR szURI, FILESETTYPE nFileSet)
+{
+ SYNCML_DM_RET_STATUS_T retStat=SYNCML_DM_SUCCESS;
+ SYNCML_DM_RET_STATUS_T retStat1=SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_TMN_Debug(("Enter CMultipleFileManager::RollbackFileSet,szURI=%s nFileSet=0x%x\n",szURI, nFileSet));
+
+ SyncML_DM_Archiver& archiver = m_pTree->GetArchiver();
+ if ( archiver.IsDirty(&nFileSet) )
+ {
+ retStat = DmCallPluginFunction(szURI, nFileSet, SYNCML_DM_ROLLBACK);
+ retStat1 = archiver.rollback(nFileSet);
+ if (retStat == SYNCML_DM_SUCCESS)
+ retStat=retStat1;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("Leave CMultipleFileManager::RollbackFileSet, nFileSet=0x%x, retStat=%d\n",nFileSet, retStat));
+ return retStat;
+
+}
+
+SYNCML_DM_RET_STATUS_T
+CMultipleFileManager::UnlockFileSet(CPCHAR szURI,
+ FILESETTYPE nFileSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType)
+{
+ SYNCML_DM_RET_STATUS_T retStat=SYNCML_DM_SUCCESS;
+ SYNCML_DM_RET_STATUS_T retStat1=SYNCML_DM_SUCCESS;
+ FILESETTYPE nFileSetToRollback = 0;
+
+ XPL_LOG_DM_TMN_Debug(("Enter CMultipleFileManager::UnLockFileSet,szURI=%s nFileSet=0x%x\n",szURI, nFileSet));
+
+ if ( DmGetMemFailedFlag() ) // device runs out of memory
+ return SYNCML_DM_DEVICE_FULL;
+
+ if ( eLockType != SYNCML_DM_LOCK_TYPE_SHARED )
+ {
+ retStat=DmCheckConstraint(szURI, &nFileSet, &nFileSetToRollback);
+ if (retStat != SYNCML_DM_SUCCESS)
+ {
+ retStat = RollbackFileSet(szURI, nFileSetToRollback);
+ if ( nFileSet == 0 )
+ return retStat;
+ }
+ }
+
+ if ( nFileSet )
+ {
+ SyncML_DM_Archiver& archiver = m_pTree->GetArchiver();
+ retStat = DmCallPluginFunction(szURI, nFileSet, SYNCML_DM_RELEASE);
+ retStat1 = archiver.serialize(nFileSet, szURI);
+ if (retStat == SYNCML_DM_SUCCESS)
+ retStat=retStat1;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("Leave CMultipleFileManager::UnlockFileSet, nFileSet=0x%x, retStat=%d\n",nFileSet, retStat));
+ return retStat;
+}
diff --git a/engine/dmlib/dmengine/dm_security/hdr/GeneratePassword.H b/engine/dmlib/dmengine/dm_security/hdr/GeneratePassword.H
new file mode 100644
index 0000000..570cf0a
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_security/hdr/GeneratePassword.H
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef GENERATEPASSWORD_H
+#define GENERATEPASSWORD_H
+
+#include "xpl_Types.h"
+
+class GeneratePassword
+{
+
+ public:
+
+ GeneratePassword();
+
+ ~GeneratePassword();
+
+ char * generateClientPasswordKey(const char * deviceId);
+
+ char * generateKeyFromDict(const char * deviceId, const char dict[]);
+
+ char * generateServerPasswordKey(const char * deviceId);
+
+ char * generateClientPassword(const char * deviceId, const char * serverId);
+
+ char * generateServerPassword(const char * deviceId, const char * serverId);
+
+ char * generateClientPassword();
+
+ char * generateServerPassword();
+
+ char * encodeDeviceId(const char * deviceId);
+
+ char * get36BasedNumber(const char * deviceId);
+
+ char * generatePassword(const char * deviceId, const char * serverId, const char * key);
+
+ char * encodeHex(const char data[]);
+
+ UINT64 convertchar2Long(const char * input);
+
+ void shuffle(char & buffer);
+
+ void setServerId(const char * sid);
+
+ void setIMEI(const char * did);
+
+ const char * getIMEI();
+
+ const char * getServerId();
+
+ private:
+
+ char * serverId;
+ char * imei;
+ static const char clientPasswordDict [15];
+ static const char serverPasswordDict[15];
+ static const char hexTable[16];
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_security/hdr/dm_security.h b/engine/dmlib/dmengine/dm_security/hdr/dm_security.h
new file mode 100644
index 0000000..50fadad
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_security/hdr/dm_security.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _SYNCMLDM_SECURITY_H
+#define _SYNCMLDM_SECURITY_H
+
+/*========================================================================
+
+ Header Name: syncmldm_security.h
+
+ General Description: This file contains prototypes, data type
+ definitions and constants required to assess
+ Security API's.
+========================================================================*/
+
+#include "xpl_Types.h"
+#include "syncml_dm_data_types.h"
+
+/*=======================================================================
+ CONSTANTS
+========================================================================*/
+#define SYNCML_DM_PSEUDO_RANDOM_NUM_LENGTH 20 /* maximum array size of the
+ * pseudo ramdom number array
+ */
+#define SYNCML_DM_MAX_CRED_BUFFER_SIZE 200
+#define SYNCML_DM_HASHLEN 16
+#define SYNCML_DM_BAS64_ENCODING_SIZE_IN_MD5 \
+ (SYNCML_DM_HASHLEN + (SYNCML_DM_HASHLEN/2))
+
+/*========================================================================
+ STRUCTURES AND OTHER TYPEDEFS
+========================================================================*/
+/* NOTE: User Name and Password are NULL terminated strings
+ */
+typedef struct
+{
+ UINT8 *pb_user_name_or_server_id;
+ UINT8 *pb_password;
+} SYNCMLDM_BASIC_SEC_INFO_T;
+
+typedef struct
+{
+ UINT8 *pb_user_name;
+ UINT8 *pb_password;
+ UINT8 *pb_server_id;
+} SYNCMLDM_NONCE_GENERATE_PARAMETER_INFO_T;
+
+typedef struct
+{
+ UINT16 w_nonce_string_length;
+ UINT8 ab_nonce_string[1];
+} SYNCMLDM_NONCE_STRING_INFO_T;
+
+typedef struct
+{
+ UINT16 w_credential_string_length;
+ UINT8 ab_credential_string[1];
+} SYNCMLDM_SEC_CREDENTIALS_T;
+
+typedef struct
+{
+ UINT8 *pb_user_name_or_server_id;
+ UINT8 *pb_password;
+ UINT8 *pb_nonce;
+ BOOLEAN o_encode_base64;
+ UINT16 w_nonce_length;
+} SYNCMLDM_MD5_SEC_INFO_T;
+
+typedef struct
+{
+ UINT8 *pb_user_name_or_server_id;
+ UINT8 *pb_password;
+ UINT8 *pb_nonce;
+ UINT8 *pb_syncml_document;
+ BOOLEAN o_encode_base64;
+ UINT16 w_nonce_length;
+ UINT32 dw_syncml_document_length;
+} SYNCMLDM_HMAC_SEC_INFO_T;
+
+SYNCMLDM_SEC_CREDENTIALS_T* syncmldm_sec_build_basic_cred(
+ const SYNCMLDM_BASIC_SEC_INFO_T *ps_basic_sec_info);
+
+SYNCMLDM_SEC_CREDENTIALS_T* syncmldm_sec_build_md5_cred(
+ const SYNCMLDM_MD5_SEC_INFO_T *ps_md5_sec_info);
+
+SYNCMLDM_SEC_CREDENTIALS_T* syncmldm_sec_build_digest_cred(
+ const SYNCMLDM_MD5_SEC_INFO_T *ps_md5_sec_info);
+
+SYNCMLDM_SEC_CREDENTIALS_T* syncmldm_sec_build_hmac_cred(
+ const SYNCMLDM_HMAC_SEC_INFO_T *ps_hmac_sec_info);
+
+SYNCMLDM_NONCE_STRING_INFO_T* syncmldm_sec_generate_nonce(
+ const SYNCMLDM_NONCE_GENERATE_PARAMETER_INFO_T *ps_nonce_gen_parameters,
+ CPCHAR devID);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/dmengine/dm_security/src/GeneratePassword.cc b/engine/dmlib/dmengine/dm_security/src/GeneratePassword.cc
new file mode 100644
index 0000000..6b872e7
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_security/src/GeneratePassword.cc
@@ -0,0 +1,532 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//--------------------------------------------------------------------------------------------------
+//
+// Module Name: GeneratePassword.cc
+//
+// FCS14345 Implementation
+//
+// Based on an IMEI and serverId input, the algorithm for generating the OMADM client password
+// and server password actually has following three steps,
+//
+// Step 1 Generate the client password key and server password key:
+// char[] clientPasswordDict = new char[] { 0x0e, 0x06, 0x10,0x0c, 0x0a, 0x0e, 0x05, 0x0c,
+// 0x12, 0x0a, 0x0b, 0x06, 0x0d, 0x0e, 0x05 };
+// char[] serverPasswordDict = new char[] { 0x0a, 0x06, 0x0e,0x0e, 0x0a, 0x0b, 0x06, 0x0e,
+// 0x0b, 0x04, 0x04, 0x07, 0x11, 0x0c, 0x0c };
+//
+// It defines a client password dictionary and a server password dictionary which contain
+// 15 numbers, we use client password dictionary to generate client password key and server
+// password dictionary to generate server password key. Suppose IMEI string length is n, for
+// each character in IMEI string {imei[i], 0<= i <n-3}, we generate two serial numbers using
+// following calculation,
+//
+// Serial1 += imei[i + 3] * dict[i];
+// Serial2 += imei[i + 3] * imei[i + 2]*dict[i];
+//
+// Note: Serial numbers are in decimal.
+// Hence we get a password KEY which is Serial1+"-"+Serial2.
+//
+// Step 2 Generate Temporary passwords:
+// We generate a MD5 digest from IMEI+KEY+serverId, then we pick No. 2,7,8,12,25,30 characters
+// from MD5 DigestStr , let is be md5key. Convert IMEI to 36 radix number, let it be newImei
+// which is always 10 characters, then we get a temporary password which is md5key+newImei.
+//
+// Step 3 Shuffle the temporary password:
+// The last step is to shuffle the temporary password got from Step 2.
+// Since the password length is 16 and n is the length which is equal to 16,
+// let P1,P2,P3,P4,...,P[n/2]-1, P[n/2], P[n/2]+1 , ... , Pn are the characters in the
+// temporary password string, we do following shuffle,
+//
+// move P[n/2]+1 between P[n/2]-1 and P[n/2],
+// ....
+// move Pn before P1.
+// Then we get Pn,P1,Pn-1,P2,....,P[n/2]-1,P[n/2]+1,P[n/2].
+// Do the same shuffle three times, then after third time shuffle we get the password which
+// is 16 characters string.
+//
+// Usage: GeneratePassword [IMEI] [SERVER_ID]
+//
+// Example: GeneratePassword 000000011234564 motorola
+//
+// Default: IMEI = 123456789012345
+// SERVER_ID = openwave.com
+//
+
+#include "md5.h"
+#include "xpl_Types.h"
+#include "dmStringUtil.h"
+#include "dmMemory.h"
+
+#include "GeneratePassword.H"
+
+#define MD5_HASH_LENGTH 16
+
+const char GeneratePassword::hexTable[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
+const char GeneratePassword::clientPasswordDict[15] = { 0x0e, 0x06, 0x10,0x0c, 0x0a, 0x0e, 0x05, 0x0c, 0x12, 0x0a, 0x0b, 0x06, 0x0d, 0x0e, 0x05 };
+const char GeneratePassword::serverPasswordDict[15] = { 0x0a, 0x06, 0x0e,0x0e, 0x0a, 0x0b, 0x06, 0x0e, 0x0b, 0x04, 0x04, 0x07, 0x11, 0x0c, 0x0c };
+
+/**
+ * Initialize all the client/server password dictionaries and other values.
+ */
+GeneratePassword::GeneratePassword() {
+ imei = NULL;
+ serverId = NULL;
+}
+
+/**
+ * Free all dynamic allocated memories.
+ */
+GeneratePassword::~GeneratePassword() {
+
+ if (imei != NULL) {
+ DmFreeMem(imei);
+ imei = NULL;
+ }
+
+ if (serverId != NULL) {
+ DmFreeMem(serverId);
+ serverId = NULL;
+ }
+
+}
+
+/**
+ * Sets the sever ID for password generation
+ *
+ * @param serverId the serverId that represent a DM server
+ */
+void GeneratePassword::setServerId(const char * sid) {
+
+ if (serverId != NULL) {
+ DmFreeMem(serverId);
+ serverId = NULL;
+ }
+
+ if (sid != NULL) {
+ int len = sizeof(char) * (DmStrlen(sid) + 1);
+ serverId = (char *) DmAllocMem(len);
+ memset(serverId, '\0', (len));
+ DmStrcpy(serverId, sid);
+ }
+}
+
+/**
+ * Sets the IMEI for password generation
+ *
+ * @param aIMEI a phone identification number
+ */
+void GeneratePassword::setIMEI(const char * aIMEI) {
+
+ if (imei != NULL) {
+ DmFreeMem(imei);
+ imei = NULL;
+ }
+
+ if (aIMEI != NULL) {
+ int len = sizeof(char) * (DmStrlen(aIMEI) + 1);
+ imei = (char *) DmAllocMem(len);
+ memset(imei, '\0', (len));
+ DmStrcpy(imei, aIMEI);
+ }
+}
+
+/**
+ * Returns the IMEI number.
+ *
+ * @return a phone identification number
+ */
+const char * GeneratePassword::getIMEI() {
+ return imei;
+}
+
+/**
+ * Returns the server ID
+ *
+ * @return serverId the serverId that represent a DM server
+ */
+const char * GeneratePassword::getServerId() {
+ return serverId;
+}
+
+/**
+ * Generate a client password key with a predefined client password dictionary
+ * based on the IMEI.
+ *
+ * @param imei the imei use to generate the key
+ * @return the client password key
+ */
+char * GeneratePassword::generateClientPasswordKey(const char * imei) {
+ return generateKeyFromDict(imei, clientPasswordDict);
+}
+
+/**
+ * Generate a server password key with a predefined server password dictionary
+ * based on the IMEI.
+ *
+ * @param imei the imei use to generate the key
+ * @return the server password key
+ */
+char * GeneratePassword::generateServerPasswordKey(const char * imei) {
+ return generateKeyFromDict(imei, serverPasswordDict);
+}
+
+/**
+ * Generate a client password using a generated client password key, the IMEI, and
+ * the server ID.
+ *
+ * @return the client password
+ */
+char * GeneratePassword::generateClientPassword() {
+ char * key = generateClientPasswordKey(imei);
+ char * password = generatePassword(imei, serverId, key);
+
+ if (key != NULL) {
+ DmFreeMem(key);
+ key = NULL;
+ }
+
+ return password;
+}
+
+/**
+ * Generate a server password using a generated server password key, the IMEI, and
+ * the server ID.
+ *
+ * @return the server password
+ */
+char * GeneratePassword::generateServerPassword() {
+ char * key = generateServerPasswordKey(imei);
+ char * password = generatePassword(imei, serverId, key);
+
+ if (key != NULL) {
+ DmFreeMem(key);
+ key = NULL;
+ }
+
+ return password;
+}
+
+/**
+ * Generate a client password using a generated client password key, the IMEI, and
+ * the server ID.
+ *
+ * @param imei a phone identification number
+ * @param serverId the serverId that represent a DM server
+ * @return the client password
+ */
+char * GeneratePassword::generateClientPassword(const char * imei, const char * serverId) {
+ char * key = generateClientPasswordKey(imei);
+ char * password = generatePassword(imei, serverId, key);
+
+ if (key != NULL) {
+ DmFreeMem(key);
+ key = NULL;
+ }
+
+ return password;
+}
+
+/**
+ * Generate a server password using a generated server password key, the IMEI, and
+ * the server ID.
+ *
+ * @param imei a phone identification number
+ * @param serverId the serverId that represent a DM server
+ * @return the server password
+ */
+char * GeneratePassword::generateServerPassword(const char * imei, const char * serverId) {
+ char * key = generateServerPasswordKey(imei);
+ char * password = generatePassword(imei, serverId, key);
+
+ if (key != NULL) {
+ DmFreeMem(key);
+ key = NULL;
+ }
+
+ return password;
+}
+
+/**
+ * Generate a key with given IMEI and password dictionary.
+ * Suppose IMEI string length is n, for each character in IMEI string {imei[i], 0<= i <n-3},
+ * we generate two serial numbers using following calculation,
+ *
+ * Serial1 += imei[i + 3] * dict[i];
+ * Serial2 += imei[i + 3] * imei[i + 2]*dict[i];
+ *
+ * Note: Serial numbers are in decimal.
+ * Hence we get a password KEY which is Serial1+"-"+Serial2.
+ *
+ * @param imei a phone indentification number
+ * @param dict[] a password dictionary
+ * @return a password key
+ */
+char * GeneratePassword::generateKeyFromDict(const char * imei, const char dict[]) {
+ UINT16 i;
+ UINT16 length;
+ UINT64 serial1 = 0;
+ UINT64 serial2 = 0;
+ char * serial1_str;
+ char * serial2_str;
+ char * key;
+
+ length = DmStrlen(imei);
+
+ for (i = 0; i < length - 3; i++) {
+ serial1 += imei[i + 3] * dict[i];
+ serial2 += imei[i + 3] * imei[i + 2] * dict[i];
+ }
+
+ serial1_str = (char *) DmAllocMem(sizeof(char) * (24));
+ serial2_str = (char *) DmAllocMem(sizeof(char) * (24));
+ DmSprintf(serial1_str, "%llu", serial1);
+ DmSprintf(serial2_str, "%llu", serial2);
+
+ key = (char *) DmAllocMem(sizeof(char) * (DmStrlen(serial1_str) + DmStrlen(serial2_str) + 2));
+ memset(key, '\0', (sizeof(char) * (DmStrlen(serial1_str) + DmStrlen(serial2_str) + 2)));
+
+ DmStrcat(key, (const char *)serial1_str );
+ DmStrcat(key, "-");
+ DmStrcat(key, (const char *)serial2_str );
+
+ DmFreeMem(serial1_str);
+ serial1_str = NULL;
+ DmFreeMem(serial2_str);
+ serial2_str = NULL;
+
+ return key;
+}
+
+/**
+ * Convert an array of characters that represents a large number to a decimal number type
+ *
+ * @param input the array of characters thar represents a large number
+ * @return the decimal number
+ */
+UINT64 GeneratePassword::convertchar2Long(const char * input)
+{
+ char ch[2];
+ UINT16 i;
+ UINT64 tmp;
+ tmp = 0;
+
+ for (i=0 ; i < DmStrlen((const char *)input) ; i++ ) {
+ ch[0]=*(input+i);
+ ch[1]='\0';
+ tmp = (UINT64) ( ( (tmp) * 10) + atol((const char *)ch) );
+ }
+ return tmp;
+}
+
+/**
+ * Convert an array of characters that represents a number in decimal based to 36 based.
+ *
+ * @param target_imei the array of characters thar represents a number in decimal based
+ * @param the 36 based number represented by array of characters.
+ */
+char * GeneratePassword::get36BasedNumber(const char * target) {
+
+ char NumericBaseData[]= "0123456789abcdefghijklmnopqrstuvwxyz";
+ char tmp_number[11];
+ UINT64 Quotient;
+ UINT32 Remainder;
+ UINT16 i;
+ char tmpchar;
+
+ char * number36 = (char *) DmAllocMem(sizeof(char) * ( 10 + 1 ));
+ memset(number36, '\0', (sizeof(char) * (10 + 1)));
+
+ UINT64 number = 0;
+ number = convertchar2Long(target);
+
+ i=0;
+ while ( number > 0 ) {
+ Quotient = (UINT64)(number/36);
+ Remainder = (UINT32)(number%36);
+ tmp_number[i++] = NumericBaseData[Remainder];
+ number = Quotient;
+ }
+ tmp_number[i]='\0';
+
+ //If the length is <10 pad the remaining chracter to '0' to make the length 10
+ if( DmStrlen(tmp_number) < 10 ) {
+ for (i=DmStrlen(tmp_number); i<10 ; i++) {
+ tmp_number[i]='0';
+ }
+ tmp_number[i]='\0';
+ }
+
+ for( i=0 ; i < DmStrlen(tmp_number)/2 ; i++ ) {
+ tmpchar = tmp_number[i];
+ tmp_number[i] = tmp_number[ DmStrlen(tmp_number)-i-1];
+ tmp_number[ DmStrlen(tmp_number)-i-1] = tmpchar;
+ }
+
+ memcpy(number36,tmp_number,DmStrlen(tmp_number));
+ return number36;
+}
+
+/**
+ * Shuffle an array of characters.
+ *
+ * let P1,P2,P3,P4,...,P[n/2]-1, P[n/2], P[n/2]+1 , ... , Pn
+ * are the characters in the string, we do following shuffle,
+ *
+ * move P[n/2]+1 between P[n/2]-1 and P[n/2],
+ * ....
+ * move Pn before P1.
+ * Then we get
+ * Pn,P1,Pn-1,P2,....,P[n/2]-1,P[n/2]+1,P[n/2].
+ *
+ * @param buffer the string to be shuffle
+ */
+void GeneratePassword::shuffle(char & buffer) {
+
+ UINT16 length;
+ UINT16 secondHalfPos;
+ UINT16 insertPos;
+ char * buf;
+ char tmpchar;
+ UINT16 i;
+ UINT16 j;
+
+ insertPos = 0;
+ i=0;
+ j=0;
+ buf = & buffer;
+ length = DmStrlen((char *)buf);
+ secondHalfPos = (length / 2);
+
+ for ( i= secondHalfPos ; i < length ; i++ ) {
+ tmpchar = (char)buf[i];
+ insertPos = (length - i - 1);
+ for ( j = i ; j > insertPos ; j-- ) {
+ buf[j] = buf[j-1];
+ }
+ buf[j] = tmpchar;
+ }
+}
+
+/**
+ * Convert the input data from a decimal based number to Heximal based number.
+ *
+ * @param data the decimal based number to be covert
+ * @return the Heximal based number
+ */
+char * GeneratePassword::encodeHex(const char data[]) {
+
+ UINT16 i;
+ char tmpchar;
+ UINT16 len = MD5_HASH_LENGTH;
+ UINT16 size = len * 2 + 1;
+ char * output = (char *) DmAllocMem(sizeof(char) * size);
+ memset(output, '\0', (sizeof(char) * size));
+
+ for ( i = 0; i < len ; i++) {
+ tmpchar = data[i];
+ output[2*i] = hexTable[ (tmpchar & 0x0F) ]; // Get low 4 bits
+ output[(2*i)+1] = hexTable[ ((tmpchar >> 4) & 0x0F ) ]; // Get high 4 bits
+ }
+ output[2*i] = '\0';
+
+ return output;
+}
+
+
+/**
+ * Generate a password with given IMEI, serverID, and key.
+ * We generate a MD5 digest from IMEI+KEY+serverId, then we pick No. 2,7,8,12,25,30 characters
+ * from MD5 DigestStr , let is be md5key. Convert IMEI to 36 radix number, let it be newImei
+ * which is always 10 characters, then we get a temporary password which is md5key+newImei.
+ * Finally, we shuffle the temporary password three time.
+ *
+ * @param imei the phone identification number
+ * @param serverId the server ID of a DM server.
+ * @param key the key needs to generate password
+ * @return a password
+ */
+char * GeneratePassword::generatePassword(const char * imei, const char * serverId, const char * key) {
+
+ char * MD5DigestStr = (char *) DmAllocMem(sizeof(char) * (DmStrlen ((const char *)imei) + DmStrlen(key) + DmStrlen(serverId) +1));
+ memset( MD5DigestStr , '\0', (sizeof(char) * ( DmStrlen ((const char *)imei) + DmStrlen(key) + DmStrlen(serverId) +1 ) ) );
+
+ DmStrcpy( MD5DigestStr , (const char *)imei );
+ DmStrcat( MD5DigestStr , key );
+ DmStrcat( MD5DigestStr , serverId );
+
+ MD5_CTX md5_context;
+
+ char md5hash[MD5_HASH_LENGTH + 1]; /* Add 1 character for NULL */
+ memset(md5hash, '\0', (sizeof(char) * (MD5_HASH_LENGTH + 1)));
+
+ smlMD5Init(&md5_context);
+ smlMD5Update(&md5_context, (unsigned char *)MD5DigestStr,DmStrlen(MD5DigestStr));
+ smlMD5Final((unsigned char*)md5hash, &md5_context);
+ md5hash[MD5_HASH_LENGTH] = 0;
+
+ DmFreeMem(MD5DigestStr );
+ MD5DigestStr =NULL;
+
+ char * MD5DigestStr32 = encodeHex(md5hash);
+
+ // Pick only no. 2,7,8,12,25,30 characters from MD5 Digest String
+
+ MD5DigestStr = (char *) DmAllocMem(sizeof(char) * ( 6 + 1 ));
+ memset(MD5DigestStr, '\0', (sizeof(char) * ( 6 + 1)));
+
+ MD5DigestStr[0] = MD5DigestStr32[2];
+ MD5DigestStr[1] = MD5DigestStr32[7];
+ MD5DigestStr[2] = MD5DigestStr32[8];
+ MD5DigestStr[3] = MD5DigestStr32[12];
+ MD5DigestStr[4] = MD5DigestStr32[25];
+ MD5DigestStr[5] = MD5DigestStr32[30];
+
+ DmFreeMem(MD5DigestStr32 );
+ MD5DigestStr32 =NULL;
+
+ //Convert IMEI to 36(base) radixnumber to generate NewIMEI
+
+ char * IMEI36 = NULL;
+
+ IMEI36 = get36BasedNumber(imei);
+
+ //Create Password
+
+ UINT16 PWLength = DmStrlen (MD5DigestStr) + DmStrlen((const char *)IMEI36); //Length will be 16
+
+ char * password = (char *) DmAllocMem(sizeof(char) * ( PWLength + 1));
+ memset( password , '\0', (sizeof(char) * ( PWLength + 1 ) ) ); //this will be of 16 + 1
+
+ DmStrcpy( password , MD5DigestStr );
+ DmStrcat( password , (const char *)IMEI36 );
+
+ DmFreeMem(MD5DigestStr );
+ MD5DigestStr =NULL;
+
+ DmFreeMem(IMEI36);
+ IMEI36 =NULL;
+
+ DmFreeMem(MD5DigestStr32 );
+ MD5DigestStr32 =NULL;
+
+ shuffle(*password);
+ shuffle(*password);
+ shuffle(*password);
+
+ return password;
+}
diff --git a/engine/dmlib/dmengine/dm_security/src/dm_security.c b/engine/dmlib/dmengine/dm_security/src/dm_security.c
new file mode 100644
index 0000000..cbb0322
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_security/src/dm_security.c
@@ -0,0 +1,754 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*=======================================================================
+
+ Header Name: syncmldm_security.c
+
+ General Description: This file contains definition of functions to
+ build the credentials with Basic, MD5 and
+ HMAC-MD5 and to generate the nonce string.
+ NOTE: All the user name/serverid and password are NULL terminated
+ strings.
+=======================================================================*/
+
+#include "xpl_Time.h"
+#include "dmStringUtil.h"
+#include "dm_security.h"
+#include "xpt-b64.h" /* To include base64Encode function */
+#include "md5.h" /* To include smlMD5Init, smlMD5Update and smlMD5Final functions */
+
+#ifdef PLATFORM_ANDROID
+#include <sys/stat.h> /* include open and read functions */
+#include <fcntl.h> /* include O_RDONLY definition */
+#endif
+
+/*=======================================================================
+ MACROS
+=======================================================================*/
+
+#define MAXIMUM_SAVE_BYTES 4 /* This will be used in base64Encode function*/
+#define COLON_PLUS_NULL 2
+#define SYNCML_DM_NEXT_BLOCK 1
+
+extern void GetIMEI(char * str);
+
+/*=======================================================================
+ LOCAL FUNCTION PROTOTYPES
+=======================================================================*/
+
+/************************************************************************
+FUNCTION: get_pseudo_random
+
+DESCRIPTION: Generates pseudo random bytes and stores them in the
+ input buffer in reverse order
+
+ARGUMENTS PASSED:
+
+UINT8 *buffer
+ - Buffer which will contain output pseudo random bytes
+length
+ - Number of psuedo random bytes to be generated
+
+
+RETURN VALUE:
+void
+
+PRE-CONDITIONS:
+
+
+POST-CONDITIONS:
+
+IMPORTANT NOTES:
+ None
+************************************************************************/
+static void get_pseudo_random(UINT8 *pbBuffer, UINT16 wLength)
+{
+#ifdef PLATFORM_ANDROID
+ /* Use /dev/urandom for secure PRNG. */
+ int fd;
+ ssize_t count = 0;
+ while ((fd = open("/dev/urandom", O_RDONLY)) == -1) {
+ /* This open should always succeed; loop forever until it does. */
+ }
+ while (count < wLength) {
+ int b = read(fd, &pbBuffer[count], wLength - count);
+ if (b == -1) {
+ /* Error: should never happen with /dev/urandom; try again. */
+ } else {
+ count += b;
+ }
+ }
+ close(fd);
+#else
+ /* Location of this function is
+ * /vobs/core_browser/code/cryptolib/src/rsa_msg_enc.c
+ */
+ INT16 wCount = 0;
+
+ XPL_CLK_CLOCK_T t = XPL_CLK_GetClock();
+ /* The current time is given as seed for generating
+ * pseudo random numbers */
+ srand ((UINT32)t);
+ for (wCount = 0; wCount < wLength; wCount++)
+ {
+ pbBuffer[wCount] = (UINT8) rand ();
+ if (pbBuffer[wCount] == 0)
+ {
+ wCount--;
+ }
+ }
+#endif
+}
+
+/************************************************************************
+FUNCTION: syncmldm_sec_build_basic_cred
+
+DESCRIPTION: This function build the credentials for basic
+ authentication scheme:
+ Let B64 = the base64 encoding function.
+ Credential String = B64(username:password)
+
+ARGUMENTS PASSED:
+
+SYNCMLDM_BASIC_SEC_INFO_T *ps_basic_sec_info
+ - Reference to the structure containg user name and password.
+
+RETURN VALUE:
+SYNCMLDM_SEC_CREDENTIALS_T*
+ - Reference to the structure containing credential string and
+ its length.
+
+PRE-CONDITIONS:
+
+
+POST-CONDITIONS:
+ Caller MUST free the memory allocated by the callee for the
+ return structure and data members of the structure.
+
+IMPORTANT NOTES:
+ None
+************************************************************************/
+SYNCMLDM_SEC_CREDENTIALS_T* syncmldm_sec_build_basic_cred(
+ const SYNCMLDM_BASIC_SEC_INFO_T *ps_basic_sec_info)
+{
+ UINT8 *pb_username_and_password = NULL;
+ UINT8 ab_savebytes[MAXIMUM_SAVE_BYTES];
+ UINT32 dw_client_cred_length = 0;
+ UINT32 dw_offset = 0;
+ UINT32 dw_length = 0;
+ UINT32 dw_estimated_basic_cred_length = 0;
+ SYNCMLDM_SEC_CREDENTIALS_T *ps_security_credential = NULL;
+
+ memset(ab_savebytes, '\0', MAXIMUM_SAVE_BYTES);
+
+ /* To build basic credential string both user name and password
+ * are mandatory if either use name or password is null then
+ * this function return NULL.
+ */
+ if((ps_basic_sec_info == NULL) ||
+ (ps_basic_sec_info->pb_user_name_or_server_id == NULL) ||
+ (ps_basic_sec_info->pb_password == NULL))
+ {
+ return (SYNCMLDM_SEC_CREDENTIALS_T*)NULL;
+ }
+
+ /* We have to add COLON_PLUS_NULL because we have to add ':'
+ * length and null character length
+ */
+ dw_length =
+ ((DmStrlen((CPCHAR)ps_basic_sec_info->pb_user_name_or_server_id)
+ + DmStrlen((CPCHAR)ps_basic_sec_info->pb_password))
+ + COLON_PLUS_NULL);
+
+ /* RFC 2045 say's (in First paragraph of Section 6.8)
+ * "The encoding and decoding algorithms are simple, but the
+ * encoded data are consistently only about 33% larger than the
+ * unencoded data.". That's why i am calculating
+ * dw_estimated_basic_cred_length by dw_length + (dw_length/2)
+ */
+ dw_estimated_basic_cred_length = dw_length + (dw_length/2);
+
+ ps_security_credential = (SYNCMLDM_SEC_CREDENTIALS_T*)
+ DmAllocMem((sizeof(UINT16) + (sizeof(UINT8) * dw_estimated_basic_cred_length)));
+ if(ps_security_credential == NULL)
+ {
+ return ps_security_credential;
+ }
+
+ ps_security_credential->w_credential_string_length = 0;
+
+ pb_username_and_password = (UINT8*)DmAllocMem(dw_length);
+ if(pb_username_and_password == NULL)
+ {
+ DmFreeMem(ps_security_credential);
+ return (SYNCMLDM_SEC_CREDENTIALS_T*)NULL;
+ }
+
+ memset(ps_security_credential->ab_credential_string, '\0', dw_estimated_basic_cred_length);
+ memset(pb_username_and_password, '\0',dw_length);
+
+ dw_client_cred_length =
+ DmStrlen((CPCHAR)ps_basic_sec_info->pb_user_name_or_server_id);
+
+ memcpy(pb_username_and_password,
+ ps_basic_sec_info->pb_user_name_or_server_id,
+ dw_client_cred_length);
+
+ /* We have to add the ':' after UserName to build the
+ * basic credential string
+ */
+ pb_username_and_password[dw_client_cred_length++] = ':';
+
+ memcpy(&pb_username_and_password[dw_client_cred_length],
+ ps_basic_sec_info->pb_password,
+ DmStrlen((CPCHAR)ps_basic_sec_info->pb_password));
+
+ dw_client_cred_length += DmStrlen((CPCHAR)ps_basic_sec_info->pb_password);
+
+ /* base64Encode function encodes the (UserName:Password) to
+ * base64 encoding and it return the lenght of the encoded
+ * string
+ */
+ ps_security_credential->w_credential_string_length =
+ (UINT16)base64Encode(
+ ps_security_credential->ab_credential_string,
+ dw_estimated_basic_cred_length,
+ pb_username_and_password,
+ (unsigned long*)&dw_client_cred_length,
+ (unsigned long*)&dw_offset, SYNCML_DM_NEXT_BLOCK,
+ ab_savebytes
+ );
+
+ DmFreeMem(pb_username_and_password);
+
+ return ps_security_credential;
+}
+
+/************************************************************************
+FUNCTION: build_md5_cred
+
+DESCRIPTION: This function build the credentials for MD5
+ authentication scheme:
+ Let H = the MD5 Hashing function.
+ Let Digest = the output of the MD5 Hashing function.
+ Let B64 = the base64 encoding function.
+ Credential String = H(B64(H(username:password)):nonce)
+
+ARGUMENTS PASSED:
+
+SYNCMLDM_MD5_SEC_INFO_T *ps_md5_sec_info
+ - Reference to the structure containing user name, password
+ and nonce.
+
+RETURN VALUE:
+SYNCMLDM_SEC_CREDENTIALS_T*
+ - Reference to the structure containing credential string and
+ it's length.
+
+PRE-CONDITIONS:
+
+POST-CONDITIONS:
+ Caller MUST free the memory allocated by the callee for the
+ return parameter.
+
+IMPORTANT NOTES:
+ None
+************************************************************************/
+SYNCMLDM_SEC_CREDENTIALS_T* syncmldm_sec_build_md5_cred(
+ const SYNCMLDM_MD5_SEC_INFO_T *ps_md5_sec_info)
+{
+ UINT8 ab_savebytes[MAXIMUM_SAVE_BYTES];
+
+ UINT32 dw_client_cred_length = 0;
+ UINT32 dw_offset = 0;
+
+ MD5_CTX s_md5_ctx;
+ UINT8 ab_hash[SYNCML_DM_HASHLEN]; /* Contains the hash data after
+ * smlMD5Final function is called
+ */
+
+ SYNCMLDM_SEC_CREDENTIALS_T *ps_security_credential = NULL;
+
+ memset(ab_hash, '\0', SYNCML_DM_HASHLEN);
+ memset(ab_savebytes, '\0', MAXIMUM_SAVE_BYTES);
+
+ if((ps_md5_sec_info == NULL) ||
+ (ps_md5_sec_info->pb_user_name_or_server_id == NULL) ||
+ (ps_md5_sec_info->pb_password == NULL) ||
+ (ps_md5_sec_info->pb_nonce == NULL))
+ {
+ return ps_security_credential;
+ }
+
+ ps_security_credential = (SYNCMLDM_SEC_CREDENTIALS_T*)
+ DmAllocMem((sizeof(UINT16) + (sizeof(UINT8) + SYNCML_DM_BAS64_ENCODING_SIZE_IN_MD5)));
+ if(ps_security_credential == NULL)
+ {
+ return ps_security_credential;
+ }
+
+ memset(ps_security_credential->ab_credential_string, '\0', SYNCML_DM_BAS64_ENCODING_SIZE_IN_MD5);
+
+ /****** Calculation of the part B64(H(username:password) **********/
+ smlMD5Init(&s_md5_ctx);
+ smlMD5Update(&s_md5_ctx, ps_md5_sec_info->pb_user_name_or_server_id,
+ DmStrlen((CPCHAR)ps_md5_sec_info->pb_user_name_or_server_id));
+ smlMD5Update(&s_md5_ctx, (UINT8*)":", 1);
+ smlMD5Update(&s_md5_ctx, ps_md5_sec_info->pb_password,
+ DmStrlen((CPCHAR)ps_md5_sec_info->pb_password));
+ smlMD5Final(ab_hash, &s_md5_ctx);
+ dw_client_cred_length = SYNCML_DM_HASHLEN;
+ dw_client_cred_length = base64Encode(
+ ps_security_credential->ab_credential_string,
+ SYNCML_DM_BAS64_ENCODING_SIZE_IN_MD5,
+ ab_hash,
+ (unsigned long*)&dw_client_cred_length,
+ (unsigned long*)&dw_offset, SYNCML_DM_NEXT_BLOCK,
+ ab_savebytes);
+ /**** End of the Calculation of part B64(H(username:password) *****/
+
+ /*** Calculation of the part H(B64(H(username:password)):nonce) ***/
+ smlMD5Init(&s_md5_ctx);
+ smlMD5Update(&s_md5_ctx, ps_security_credential->ab_credential_string, dw_client_cred_length);
+ smlMD5Update(&s_md5_ctx, (UINT8*)":", 1);
+ smlMD5Update(&s_md5_ctx, ps_md5_sec_info->pb_nonce, ps_md5_sec_info->w_nonce_length);
+ smlMD5Final(ab_hash, &s_md5_ctx);
+ dw_client_cred_length = SYNCML_DM_HASHLEN;
+
+ if(ps_md5_sec_info->o_encode_base64 == TRUE)
+ {
+ ps_security_credential->w_credential_string_length =
+ (UINT16)base64Encode(ps_security_credential->ab_credential_string,
+ SYNCML_DM_BAS64_ENCODING_SIZE_IN_MD5,
+ ab_hash,
+ (unsigned long*)&dw_client_cred_length,
+ (unsigned long*)&dw_offset, SYNCML_DM_NEXT_BLOCK,
+ ab_savebytes
+ );
+ }
+ else
+ {
+ ps_security_credential->w_credential_string_length =
+ (UINT16)dw_client_cred_length;
+ memcpy(ps_security_credential->ab_credential_string,
+ &ab_hash,
+ dw_client_cred_length);
+ }
+ /****** End of the Calculation of part
+ H(B64(H(username:password)):nonce) *****/
+ return ps_security_credential;
+}
+
+/************************************************************************
+FUNCTION: build_hmac_cred
+
+DESCRIPTION: This function build the credentials for HMAC
+ authentication scheme:
+ Let H = the MD5 Hashing function.
+ Let Digest = the output of the MD5 Hashing function.
+ Let B64 = the base64 encoding function.
+ Credential String =
+ H(B64(H(username:password)):nonce:B64(H(message body)))
+
+ARGUMENTS PASSED:
+SYNCMLDM_HMAC_SEC_INFO_T *ps_hmac_sec_info
+ - Reference to the structure containing user name, password,
+ nonce and starting pointer to the SyncML Document.
+
+RETURN VALUE:
+SYNCMLDM_SEC_CREDENTIALS_T*
+ - Reference to the structure containing credential string and
+ it's length.
+
+PRE-CONDITIONS:
+
+POST-CONDITIONS:
+ Caller MUST free the memory allocated by the callee for the
+ return parameter.
+
+IMPORTANT NOTES:
+ None
+************************************************************************/
+SYNCMLDM_SEC_CREDENTIALS_T* syncmldm_sec_build_hmac_cred(
+ const SYNCMLDM_HMAC_SEC_INFO_T *ps_hmac_sec_info)
+{
+ UINT8 ab_savebytes[MAXIMUM_SAVE_BYTES];
+
+ UINT32 dw_client_cred_length = 0;
+ UINT32 dw_body_encoded_length = 0;
+ UINT32 dw_hash_length = SYNCML_DM_HASHLEN;
+ UINT32 dw_offset = 0;
+
+ MD5_CTX s_md5_ctx;
+ UINT8 ab_hash[SYNCML_DM_HASHLEN];
+
+ SYNCMLDM_SEC_CREDENTIALS_T *ps_security_credential = NULL;
+
+ memset(ab_savebytes, '\0', MAXIMUM_SAVE_BYTES);
+ memset(ab_hash, '\0', SYNCML_DM_HASHLEN);
+
+ /* If any one of the following parameter is NULL hash can't
+ * be build.
+ */
+ if((ps_hmac_sec_info == NULL) ||
+ (ps_hmac_sec_info->pb_user_name_or_server_id == NULL) ||
+ (ps_hmac_sec_info->pb_password == NULL) ||
+ (ps_hmac_sec_info->pb_nonce == NULL) ||
+ (ps_hmac_sec_info->pb_syncml_document == NULL) ||
+ (ps_hmac_sec_info->dw_syncml_document_length == 0))
+ {
+ return ps_security_credential;
+ }
+
+ ps_security_credential = (SYNCMLDM_SEC_CREDENTIALS_T*) DmAllocMem((sizeof(UINT8) + (sizeof(UINT8) +
+ SYNCML_DM_MAX_CRED_BUFFER_SIZE)));
+ if(ps_security_credential == NULL)
+ {
+ return ps_security_credential;
+ }
+
+ memset(ps_security_credential->ab_credential_string, '\0', SYNCML_DM_MAX_CRED_BUFFER_SIZE);
+
+ /***** Calculation of the part B64(H(username:password) ******/
+ smlMD5Init(&s_md5_ctx);
+ smlMD5Update(&s_md5_ctx,
+ ps_hmac_sec_info->pb_user_name_or_server_id,
+ DmStrlen((CPCHAR)ps_hmac_sec_info->pb_user_name_or_server_id));
+
+ smlMD5Update(&s_md5_ctx, (UINT8*)":", 1);
+ smlMD5Update(&s_md5_ctx, ps_hmac_sec_info->pb_password,
+ DmStrlen((CPCHAR)ps_hmac_sec_info->pb_password));
+ smlMD5Final(ab_hash, &s_md5_ctx);
+ dw_client_cred_length = SYNCML_DM_HASHLEN;
+ dw_client_cred_length =
+ base64Encode(ps_security_credential->ab_credential_string,
+ SYNCML_DM_MAX_CRED_BUFFER_SIZE,
+ ab_hash,
+ (unsigned long*)&dw_client_cred_length,
+ (unsigned long*)&dw_offset, SYNCML_DM_NEXT_BLOCK,
+ ab_savebytes);
+ /*** End of the Calculation of part B64(H(username:password) ****/
+
+ ps_security_credential->ab_credential_string[dw_client_cred_length++] = ':';
+ memcpy(&(ps_security_credential->ab_credential_string[dw_client_cred_length]),
+ ps_hmac_sec_info->pb_nonce,
+ ps_hmac_sec_info->w_nonce_length);
+
+ dw_client_cred_length = dw_client_cred_length +
+ ps_hmac_sec_info->w_nonce_length;
+ ps_security_credential->ab_credential_string[dw_client_cred_length++]
+ = ':';
+
+ /********** Calculation of B64(H(message body)) *****************/
+ smlMD5Init(&s_md5_ctx);
+ smlMD5Update(&s_md5_ctx, ps_hmac_sec_info->pb_syncml_document,
+ ps_hmac_sec_info->dw_syncml_document_length);
+ smlMD5Final(ab_hash, &s_md5_ctx);
+ dw_body_encoded_length = base64Encode(&ps_security_credential->ab_credential_string[dw_client_cred_length],
+ SYNCML_DM_MAX_CRED_BUFFER_SIZE,
+ ab_hash,
+ (unsigned long*)&dw_hash_length,
+ (unsigned long*)&dw_offset, SYNCML_DM_NEXT_BLOCK,
+ ab_savebytes);
+ /******** End of the Calculation of B64(H(message body)) *******/
+
+ dw_client_cred_length += dw_body_encoded_length;
+
+ /****** Calculation of
+ H(B64(H(username:password)):nonce:B64(H(message body))) *****/
+ smlMD5Init(&s_md5_ctx);
+ smlMD5Update(&s_md5_ctx,
+ ps_security_credential->ab_credential_string,
+ dw_client_cred_length);
+ smlMD5Final(ab_hash, &s_md5_ctx);
+
+ /* Reset the length variable.*/
+ dw_hash_length = SYNCML_DM_HASHLEN;
+
+ if(ps_hmac_sec_info->o_encode_base64 == TRUE)
+ {
+ dw_client_cred_length = SYNCML_DM_HASHLEN;
+ ps_security_credential->w_credential_string_length =
+ (UINT16)base64Encode(
+ ps_security_credential->ab_credential_string,
+ SYNCML_DM_MAX_CRED_BUFFER_SIZE,
+ ab_hash,
+ (unsigned long*)&dw_client_cred_length,
+ (unsigned long*)&dw_offset, SYNCML_DM_NEXT_BLOCK,
+ ab_savebytes
+ );
+ }
+ else
+ {
+ ps_security_credential->w_credential_string_length =
+ (UINT16)dw_hash_length;
+ memcpy(ps_security_credential->ab_credential_string, &ab_hash,
+ dw_hash_length);
+ }
+ ps_security_credential->ab_credential_string
+ [ps_security_credential->w_credential_string_length] = '\0';
+ /****** End of the calculation of
+ H(B64(H(username:password)):nonce:B64(H(message body))) *****/
+ return ps_security_credential;
+}
+
+/************************************************************************
+FUNCTION: syncmldm_sec_generate_nonce
+
+DESCRIPTION: This function generate the nonce.:
+ Let H = the MD5 Hashing function.
+ Let B64 = the base64 encoding function.
+ Nonce String =
+ b64(H(Random number+IMEI+User Name+Password+ServerId))
+
+ARGUMENTS PASSED:
+SYNCMLDM_NONCE_GENERATE_PARAMETER_INFO_T *ps_nonce_gen_parameters
+ - Reference to the structure containing user name, password,
+ serverid.
+
+RETURN VALUE:
+SYNCMLDM_NONCE_STRING_INFO_T*
+ - Reference to the structure containing nonce string and
+ it's length.
+
+PRE-CONDITIONS:
+
+POST-CONDITIONS:
+ Caller MUST free the memory allocated by the callee for the
+ return parameter.
+
+IMPORTANT NOTES:
+ None
+************************************************************************/
+SYNCMLDM_NONCE_STRING_INFO_T* syncmldm_sec_generate_nonce(
+ const SYNCMLDM_NONCE_GENERATE_PARAMETER_INFO_T *ps_nonce_gen_parameters,
+ CPCHAR devID)
+{
+ UINT8 ab_hash[SYNCML_DM_HASHLEN];
+ UINT8 ab_savebytes[MAXIMUM_SAVE_BYTES];
+ UINT8 *pb_nonce_string_parameters = NULL;
+ UINT8 ab_pseudo_random[SYNCML_DM_PSEUDO_RANDOM_NUM_LENGTH];
+
+ UINT32 dw_current_string_length = 0;
+ UINT32 dw_total_length = 0;
+ UINT32 dw_hash_length = SYNCML_DM_HASHLEN;
+ UINT32 dw_offset = 0;
+ UINT32 lengthDevID;
+
+ MD5_CTX s_md5_ctx;
+
+ SYNCMLDM_NONCE_STRING_INFO_T *ps_nonce_string_info = NULL;
+
+
+ if(ps_nonce_gen_parameters == NULL || !devID)
+ {
+ return NULL;
+ }
+
+ lengthDevID = DmStrlen(devID);
+ memset(ab_hash, '\0', SYNCML_DM_HASHLEN);
+ memset(ab_savebytes, '\0', MAXIMUM_SAVE_BYTES);
+
+ get_pseudo_random(ab_pseudo_random, SYNCML_DM_PSEUDO_RANDOM_NUM_LENGTH);
+
+ dw_total_length =
+ DmStrlen((CPCHAR)ps_nonce_gen_parameters->pb_user_name) +
+ DmStrlen((CPCHAR)ps_nonce_gen_parameters->pb_password) +
+ DmStrlen((CPCHAR)ps_nonce_gen_parameters->pb_server_id) +
+ SYNCML_DM_PSEUDO_RANDOM_NUM_LENGTH + lengthDevID + 1;
+ pb_nonce_string_parameters = (UINT8*)DmAllocMem((sizeof(char) * dw_total_length));
+ if(pb_nonce_string_parameters == NULL)
+ {
+ return NULL;
+ }
+
+ ps_nonce_string_info = (SYNCMLDM_NONCE_STRING_INFO_T*)
+ DmAllocMem((sizeof(UINT16) + (sizeof(UINT8) * SYNCML_DM_MAX_CRED_BUFFER_SIZE)));
+ if(ps_nonce_string_info == NULL)
+ {
+ DmFreeMem(pb_nonce_string_parameters);
+ return ps_nonce_string_info;
+ }
+
+ memset(pb_nonce_string_parameters, '\0', dw_total_length);
+ memset(ps_nonce_string_info->ab_nonce_string,'\0', SYNCML_DM_MAX_CRED_BUFFER_SIZE);
+
+ dw_total_length = 0;
+
+ /* Adding RandomNumber, IMEI, UserName, Password and ServerId
+ */
+ dw_current_string_length = SYNCML_DM_PSEUDO_RANDOM_NUM_LENGTH;
+ memcpy(pb_nonce_string_parameters,
+ ab_pseudo_random,
+ dw_current_string_length);
+ dw_total_length += dw_current_string_length;
+
+ dw_current_string_length = lengthDevID;
+ memcpy(&pb_nonce_string_parameters[dw_total_length],devID,dw_current_string_length);
+ dw_total_length += dw_current_string_length;
+
+ dw_current_string_length = DmStrlen((CPCHAR)ps_nonce_gen_parameters->pb_user_name);
+ memcpy(&pb_nonce_string_parameters[dw_total_length],
+ ps_nonce_gen_parameters->pb_user_name,
+ dw_current_string_length);
+ dw_total_length += dw_current_string_length;
+
+ dw_current_string_length = DmStrlen((CPCHAR)ps_nonce_gen_parameters->pb_password);
+ memcpy(&pb_nonce_string_parameters[dw_total_length],
+ ps_nonce_gen_parameters->pb_password,
+ dw_current_string_length);
+ dw_total_length += dw_current_string_length;
+
+ dw_current_string_length = DmStrlen((CPCHAR)ps_nonce_gen_parameters->pb_server_id);
+ memcpy(&pb_nonce_string_parameters[dw_total_length],
+ ps_nonce_gen_parameters->pb_server_id,
+ dw_current_string_length);
+ dw_total_length += dw_current_string_length;
+
+ /* Hashing the nonce string */
+ smlMD5Init(&s_md5_ctx);
+ smlMD5Update(&s_md5_ctx, pb_nonce_string_parameters, dw_total_length);
+ smlMD5Final(ab_hash, &s_md5_ctx);
+
+ /* Encoding the generated nonce string into base64 */
+ ps_nonce_string_info->w_nonce_string_length =
+ (UINT16)base64Encode(
+ ps_nonce_string_info->ab_nonce_string,
+ SYNCML_DM_MAX_CRED_BUFFER_SIZE,
+ ab_hash,
+ (unsigned long*)&dw_hash_length,
+ (unsigned long*)&dw_offset, SYNCML_DM_NEXT_BLOCK,
+ ab_savebytes
+ );
+
+ DmFreeMem(pb_nonce_string_parameters);
+
+ ps_nonce_string_info->ab_nonce_string[ps_nonce_string_info->w_nonce_string_length] = '\0';
+ return ps_nonce_string_info;
+}
+
+/************************************************************************
+FUNCTION: build_digest_cred
+
+DESCRIPTION: This function build the credentials for MD5
+ authentication scheme:
+ Let H = the MD5 Hashing function.
+ Let Digest = the output of the MD5 Hashing function.
+ Let B64 = the base64 encoding function.
+ Credential String = H(B64(H(username:password)):nonce)
+
+ARGUMENTS PASSED:
+
+SYNCMLDM_MD5_SEC_INFO_T *ps_md5_sec_info
+ - Reference to the structure containing user name, password
+ and nonce.
+
+RETURN VALUE:
+SYNCMLDM_SEC_CREDENTIALS_T*
+ - Reference to the structure containing credential string and
+ it's length.
+
+PRE-CONDITIONS:
+
+POST-CONDITIONS:
+ Caller MUST free the memory allocated by the callee for the
+ return parameter.
+
+IMPORTANT NOTES:
+ None
+************************************************************************/
+SYNCMLDM_SEC_CREDENTIALS_T* syncmldm_sec_build_digest_cred(
+ const SYNCMLDM_MD5_SEC_INFO_T *ps_md5_sec_info)
+{
+ UINT8 ab_savebytes[MAXIMUM_SAVE_BYTES];
+
+ UINT32 dw_client_cred_length = 0;
+ UINT32 dw_offset = 0;
+
+ MD5_CTX s_md5_ctx;
+ UINT8 ab_hash[SYNCML_DM_HASHLEN]; /* Contains the hash data after
+ * smlMD5Final function is called
+ */
+
+ SYNCMLDM_SEC_CREDENTIALS_T *ps_security_credential = NULL;
+
+ memset(ab_hash, '\0', SYNCML_DM_HASHLEN);
+ memset(ab_savebytes, '\0', MAXIMUM_SAVE_BYTES);
+
+ if ((ps_md5_sec_info == NULL) ||
+ (ps_md5_sec_info->pb_user_name_or_server_id == NULL) ||
+ (ps_md5_sec_info->pb_password == NULL) )
+ {
+ return ps_security_credential;
+ }
+
+ ps_security_credential = (SYNCMLDM_SEC_CREDENTIALS_T*)
+ DmAllocMem((sizeof(UINT16) + (sizeof(UINT8) + SYNCML_DM_HASHLEN)));
+ if(ps_security_credential == NULL)
+ {
+ return ps_security_credential;
+ }
+
+ memset(ps_security_credential->ab_credential_string, '0', SYNCML_DM_HASHLEN);
+
+
+ smlMD5Init(&s_md5_ctx);
+ smlMD5Update(&s_md5_ctx, ps_md5_sec_info->pb_user_name_or_server_id,
+ DmStrlen((CPCHAR)ps_md5_sec_info->pb_user_name_or_server_id));
+ UINT8 *p_nonce = NULL;
+ if ( NULL != ps_md5_sec_info->pb_nonce )
+ {
+ int nonceLen = DmStrlen((CPCHAR)ps_md5_sec_info->pb_nonce);
+ p_nonce = DmAllocMem(nonceLen + 2);
+ if(p_nonce == NULL)
+ {
+ DmFreeMem(ps_security_credential);
+ return (SYNCMLDM_SEC_CREDENTIALS_T*)NULL;
+ }
+ memcpy(p_nonce + 1, ps_md5_sec_info->pb_nonce, nonceLen);
+ p_nonce[0]= ':';
+ p_nonce[nonceLen]= ':';
+ smlMD5Update(&s_md5_ctx, (UINT8*)p_nonce, nonceLen + 2);
+ }
+ else
+ {
+ smlMD5Update(&s_md5_ctx, (UINT8*)":", 1);
+ }
+ smlMD5Update(&s_md5_ctx, ps_md5_sec_info->pb_password,
+ DmStrlen((CPCHAR)ps_md5_sec_info->pb_password));
+ smlMD5Final(ab_hash, &s_md5_ctx);
+
+ memcpy(ps_security_credential->ab_credential_string,
+ &ab_hash,
+ SYNCML_DM_HASHLEN);
+
+ if ( NULL != p_nonce )
+ {
+ DmFreeMem(p_nonce);
+ p_nonce = NULL;
+ }
+
+ return ps_security_credential;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_Alert.H b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_Alert.H
new file mode 100644
index 0000000..7a568ac
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_Alert.H
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_ALERT_H
+#define SYNCML_DM_ALERT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_Alert.H
+
+ General Description: A class representing the alert.
+
+==================================================================================================*/
+
+#include "dmSessionDefs.h"
+#include "xpl_dm_ServerAlert.h"
+
+#define SYNCML_DM_ALERT_OPTION_MINDT "MINDT" // Minimum Display Time
+#define SYNCML_DM_ALERT_OPTION_MAXDT "MAXDT" // Maximum Display Time
+#define SYNCML_DM_ALERT_OPTION_DEFAULT_RESPONSE "DR" // Default Response
+#define SYNCML_DM_ALERT_OPTION_MAX_LENGTH "MAXLEN" // Maximum Length
+#define SYNCML_DM_ALERT_OPTION_INPUT_TYPE "IT" // Input Type
+#define SYNCML_DM_ALERT_OPTION_ECHO_TYPE "ET" // Echo Type
+
+#define SYNCML_DM_ALERT_OPTION_IT_A "A" // Alphanumeric
+#define SYNCML_DM_ALERT_OPTION_IT_N "N" // Numeric
+#define SYNCML_DM_ALERT_OPTION_IT_D "D" // Date
+#define SYNCML_DM_ALERT_OPTION_IT_T "T" // Time
+#define SYNCML_DM_ALERT_OPTION_IT_P "P" // Phone
+#define SYNCML_DM_ALERT_OPTION_IT_I "I" // IP Address
+
+#define SYNCML_DM_ALERT_OPTION_ET_T "T" // Text
+#define SYNCML_DM_ALERT_OPTION_ET_P "P" // Password
+
+#define SYNCML_DM_ALERT_MAX_TIME 60 // maximum display time in seconds
+
+
+class SYNCML_DM_Alert {
+
+ public:
+
+
+ SYNCML_DM_Alert();
+ virtual ~SYNCML_DM_Alert() {};
+
+ virtual void parse(SmlAlertPtr_t pContent);
+
+ virtual SYNCML_DM_RET_STATUS_T show() = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T processResponse(DMStringVector & userResponse,
+ SYNCML_DM_ALERT_RES_T * alertStatus );
+
+ protected:
+
+ DMString msg; // the message to display
+ INT32 minDisplayTime; // minimum display time
+ INT32 maxDisplayTime; // maximum display time
+
+ virtual XPL_DM_ALERT_RES_T getAction() const = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T getDefaultResponse(DMStringVector & userResponse) const = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T getResponse(DMStringVector & userResponse) const = 0;
+
+ void parseParameters(SmlItemListPtr_t p_alert_list_item);
+
+ virtual void processParameter(CPCHAR name, CPCHAR value) = 0;
+
+ void parseMessage(SmlItemListPtr_t p_alert_list_item);
+
+ void setMinDisplayTime(INT32 minDisplayTime);
+
+ void setMaxDisplayTime(INT32 maxDisplayTime);
+};
+
+#endif /* SYNCML_DM_ALERT_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_BuildPackage.H b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_BuildPackage.H
new file mode 100644
index 0000000..0e29e19
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_BuildPackage.H
@@ -0,0 +1,350 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_BUILDPACKAGE_H
+#define SYNCML_DM_BUILDPACKAGE_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_BuildPackage.H
+
+ General Description: This contains declaration of SYNCML_DM_BuildPackage calss.
+
+==================================================================================================*/
+
+#include "syncml_dm_data_types.h"
+#include "dm_tree_typedef.h"
+#include "dmtFirmAlert.hpp"
+#include "dmSessionDefs.h"
+#include "dmClientSrvCreds.h"
+
+/* Include header files required in any SyncML session */
+extern "C" {
+#include "sml.h"
+#include "smldef.h"
+#include "smldevinfdtd.h"
+#include "smlmetinfdtd.h"
+#include "smldmtnddtd.h"
+#include "mgrutil.h"
+#include "smlerr.h"
+}
+
+enum {
+ SYNCML_DM_FACTORY_BOOTSTRAP_UNKNOWN = 0,
+ SYNCML_DM_FACTORY_BOOTSTRAP_FCS11384,
+ SYNCML_DM_FACTORY_BOOTSTRAP_FCS14345
+};
+typedef INT8 SYNCML_DM_FACTORY_BOOTSTRAP_T;
+
+static char DMACC_FACTORY_BOOTSTRAP_CLIENTPW_FCS11384[] = {0xeb, 0xe8, 0xef, 0xee, 0xec, 0};
+static char DMACC_FACTORY_BOOTSTRAP_SERVERPW_FCS11384[] = {0xfc, 0xe9, 0xe2, 0xe4, 0xe0, 0};
+static char DMACC_FACTORY_BOOTSTRAP_USERNAME_FCS11384[] = {0xe0, 0xe5, 0xe7, 0xea, 0xeb, 0};
+
+// Openwave
+static char DMACC_FACTORY_BOOTSTRAP_CLIENTPW_FCS14345[] = {0xeb, 0xe8, 0xef, 0xee, 0xec, 0xec, 0};
+static char DMACC_FACTORY_BOOTSTRAP_SERVERPW_FCS14345[] = {0xfc, 0xe9, 0xe2, 0xe4, 0xe0, 0xe0, 0};
+static char DMACC_FACTORY_BOOTSTRAP_USERNAME_FCS14345[] = {0xe0, 0xe5, 0xe7, 0xea, 0xeb, 0xeb, 0};
+
+
+class DMProcessScriptSession;
+
+class SYNCML_DM_BuildPackage
+{
+ public:
+ /* Class constructor */
+ SYNCML_DM_BuildPackage();
+
+ /* Class destructor */
+ virtual ~SYNCML_DM_BuildPackage();
+
+ /* Operators to allocate and delete memory for operation */
+ void *operator new(size_t);
+ void operator delete (void *);
+
+ void Cleanup();
+ void Init(DMProcessScriptSession *pSession);
+
+ /* This function will be called by HandleEndMessage to build up the SyncML package header.*/
+ SYNCML_DM_RET_STATUS_T BuildStartSyncHdr(SmlSyncHdrPtr_t p_Content, BOOLEAN isPackageOne);
+ SYNCML_DM_RET_STATUS_T BuildFinishSyncHdr(SYNCML_DM_CHAL_TYPE_T serverChalType);
+
+ SYNCML_DM_RET_STATUS_T BuildStatus(SmlStatusPtr_t p_status );
+
+ SYNCML_DM_RET_STATUS_T BuildResultsCommand( SmlResultsPtr_t p_results );
+ /* This function will be called by other functions to build up status for responding DM
+ * package. */
+ SmlStatusPtr_t AllocateStatus(
+ UINT8 *p_CmdRefData, /* Receiving DM package command Id */
+ UINT8 *p_CmdName,
+ UINT8 *p_SourceRefData,
+ UINT8 *p_TargetRefData,
+ DM_CHALLENGE_T *pClientChal,
+ SYNCML_DM_RET_STATUS_T status_Code,
+ const DMStringVector* responses );
+
+
+ /* This function will be called by BuildPackageOne and HandleStartMessage to add the last
+ * element to the DM package. */
+ SYNCML_DM_RET_STATUS_T EndSyncmlDoc(Boolean_t final);
+
+
+ SYNCML_DM_RET_STATUS_T AllocateResult(SmlResultsPtr_t & p_results,
+ CPCHAR p_target_uri,
+ CPCHAR p_CmdIdRef,
+ DMGetData *p_get_ret_data,
+ BOOLEAN is_ThisGetStructResult,
+ BOOLEAN isFirstGetStruct,
+ BOOLEAN isThisGetPropResult,
+ CPCHAR szMsgID,
+ SmlPcdataPtr_t p_data=NULL );
+
+ SYNCML_DM_RET_STATUS_T AllocateTndsResult(CPCHAR pStrTargetUri,
+ DMGetData *p_get_ret_data,
+ const SYNCML_DM_GET_ON_LIST_RET_DATA_T& oGetStructData,
+ SmlPcdataPtr_t p_data );
+
+ BOOLEAN ListTndsProp( CPCHAR uri, CPCHAR prop, BOOLEAN &listProp);
+
+ /* BuildPackageOne and the HandleStatus will call this function to build up the ALERT 1226
+ * command */
+ SYNCML_DM_RET_STATUS_T BuildAlert1226Command();
+ //SYNCML_DM_RET_STATUS_T BuildAlert1226Command (DMFirmAlertVector * pFirmAlerts);
+ SYNCML_DM_SESSION_DIRECTION_T getDirection() const;
+
+ /* BuildPackageOne and the HandleStatus will call this function to build up the ALERT
+ * command with management session type information. */
+ SYNCML_DM_RET_STATUS_T BuildAlertCommand(UINT16 alertCode, CPCHAR pSource, CPCHAR pTarget);
+
+ /* BuildPackageOne and the HandleStatus will call this function to build up the REPLACE
+ * command with DenInfo data from the DM tree. */
+ SYNCML_DM_RET_STATUS_T BuildReplaceCommand();
+
+ /* This function will be called by SessionStart to build up DM package one with device
+ * information. */
+ SYNCML_DM_RET_STATUS_T BuildPackageOne(CPCHAR pServerID, DmtSessionProp * pSessionProp);
+
+ /* This function will be called by BuildPackage functions to build up PC data structure.*/
+ void BuildPcData(SmlPcdataPtr_t p_PcData,
+ SmlPcdataType_t content_Type,
+ SmlPcdataExtension_t extension,
+ UINT32 dataSize,
+ UINT8 *p_Content);
+
+ /* This function will be called by BuildPackage functions to build up the meta data
+ * structure */
+ void BuildMetaInfo(SmlPcdataPtr_t p_PcData,
+ UINT8 *p_Format, UINT8 *p_Type,
+ UINT8 *p_Mark, UINT8 *p_Size,
+ UINT8 *p_NextNonce, UINT8 *p_Version,
+ UINT8 *p_Maxmsgsize, UINT8 *p_Maxobjsize);
+
+ SYNCML_DM_RET_STATUS_T BuildMetaSizeInfo(SmlPcdataPtr_t p_PcData, int datasize);
+
+ /* To access the MaxMessageSize data member */
+ UINT32 GetMaxMessageSize() const;
+
+ /* To set the MaxMessageSize data member */
+ void SetMaxMessageSize(UINT32 passedin_MaxMsgSize);
+
+ /* To access the MaxObjectSize data member */
+ UINT32 GetMaxObjectSize() const;
+
+ /* To set the MaxObjectSize data member */
+ void SetMaxObjectSize(UINT32 passedin_MaxObjSize);
+
+ inline const char * GetMsgRef() {return pMessageIdOfServer;}
+
+ inline void SetMsgRef(CPCHAR pMsgRef) {pMessageIdOfServer = pMsgRef;}
+
+ /* Free the memory of the p_GetStructData */
+ void FreeGetStructData(SYNCML_DM_GET_ON_LIST_RET_DATA_T& p_GetStructData);
+
+ static SYNCML_DM_RET_STATUS_T GetClientAuthValues( const DMString& device_id,
+ const DMString& server_id,
+ DMString& client_name,
+ DMString& client_password );
+
+ static SYNCML_DM_RET_STATUS_T GetServerAuthValues( const DMString& device_id,
+ const DMString& server_id,
+ DMString& server_password );
+
+ static SYNCML_DM_RET_STATUS_T GetDeviceID( DMString& device_id );
+
+ SYNCML_DM_RET_STATUS_T DecodBase64Data(SmlItemPtr_t &p_add_item, DMAddData & oAddData, BOOLEAN decodeB64);
+#ifdef LOB_SUPPORT
+ BOOLEAN IsProcessingLargeObject() const{ return m_bProcessingLargeObject; }
+ SYNCML_DM_RET_STATUS_T GenerateAlertForLOB(DMCommandType currentComm);
+
+ DMCommandType GetLargeObjectCmdType() const { return largeObjectCmd;}
+ SYNCML_DM_RET_STATUS_T LargeObjectRecvFirstChunk(DMAddData & oAddData,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_data_item);
+ SYNCML_DM_RET_STATUS_T LargeObjectRecvNextChunk(DMAddData & oAddData,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_data_item);
+ BOOLEAN LargeObjectSendNextChunk(SYNCML_DM_RET_STATUS_T &dm_stat, BOOLEAN &isLastChunk);
+ SYNCML_DM_RET_STATUS_T LargeObjectSendFirstChunk(SYNCML_DM_RESULT_VALUE &pResult);
+ void LargeObjectClear();
+#endif
+ /* create factory boot strap user name */
+ static SYNCML_DM_RET_STATUS_T CreateFactoryBootStrapUserName( SYNCML_DM_FACTORY_BOOTSTRAP_T bootStrapCode,
+ const DMString& server_id,
+ const DMString& devIMEI,
+ DMString& user_name );
+
+
+ /* create factory boot strap password for client or server */
+ static SYNCML_DM_RET_STATUS_T CreateFactoryBootStrapServerPW( SYNCML_DM_FACTORY_BOOTSTRAP_T bootStrapCode,
+ const DMString& server_id,
+ const DMString& abIMEI,
+ DMString& server_password );
+
+ /* create factory boot strap password for client or server */
+ static SYNCML_DM_RET_STATUS_T CreateFactoryBootStrapClientPW( SYNCML_DM_FACTORY_BOOTSTRAP_T bootStrapCode,
+ const DMString& server_id,
+ const DMString& abIMEI,
+ DMString& client_password );
+
+ static SYNCML_DM_RET_STATUS_T BuildFactoryBootstrapCredData(DMString& pp_credential_data,
+ CPCHAR p_CredData,
+ CPCHAR p_CredData1);
+
+ /* get factory bootstap code with user name */
+ static SYNCML_DM_FACTORY_BOOTSTRAP_T GetBootStrapCodeUserName( const DMString& user_name );
+
+ /* get factory bootstap code with client password */
+ static SYNCML_DM_FACTORY_BOOTSTRAP_T GetBootStrapCodeClientPW(const DMString& password);
+
+ /* get factory bootstap code with server password */
+ static SYNCML_DM_FACTORY_BOOTSTRAP_T GetBootStrapCodeServerPW(const DMString& password );
+
+ static CPCHAR GetIMEINumber(CPCHAR devID);
+ BOOLEAN IsSessionId();
+ private:
+ /* This function will be called by BuildPackage functions to allocate memory for PC data
+ structue and call BuildPcData to build up the structure.*/
+ void BuildPcDataWAllocMem (SmlPcdataPtr_t *pp_PcData,
+ UINT32 dataSize,
+ UINT8 *p_Content);
+
+
+ /* Get the remaining Security Info from the DM Tree.*/
+ SYNCML_DM_RET_STATUS_T GetRemainingSecInfo(CPCHAR pParentName,
+ DMClientServerCreds *pClientServerCreds,
+ CPCHAR devID);
+
+
+ BOOLEAN IsLargerThanMaxObjSize( int dataSize, BOOLEAN isESN, BOOLEAN isToServer);
+#ifdef LOB_SUPPORT
+ DmtDataChunk * AllocateChunkBuffer();
+ SYNCML_DM_RET_STATUS_T SetChunkData(DMAddData & oAddData, DMCommandType cmdType, BOOLEAN isLastChunk);
+ SYNCML_DM_RET_STATUS_T SetChunkDataToEngine(DMAddData & oAddData, BOOLEAN isAllSet);
+ SYNCML_DM_RET_STATUS_T GetLargeObjectTargetURI(SmlItemPtr_t p_get_item);
+ SYNCML_DM_RET_STATUS_T GetChunkData(DMBuffer & oSendData, int bufSize);
+ SYNCML_DM_RET_STATUS_T GetESNData2TempFile(int & dataSize);
+ SYNCML_DM_RET_STATUS_T CreateESNTempFile();
+ SYNCML_DM_RET_STATUS_T OpenESNTempFile();
+ SYNCML_DM_RET_STATUS_T GetChunkDataFromEngine();
+ SYNCML_DM_RET_STATUS_T AllocateLargeObjectResult(SmlResultsPtr_t & p_results);
+ SYNCML_DM_RET_STATUS_T BuildLargeObjectDataLast(SmlResultsPtr_t & p_results, int size, BOOLEAN isFirstChunk);
+ SYNCML_DM_RET_STATUS_T BuildLargeObjectDataNext(SmlResultsPtr_t & p_results, int dataBufferSize);
+ SYNCML_DM_RET_STATUS_T LargeObjectSendFirstChunkNoSpace(SYNCML_DM_RESULT_VALUE &pResult ,int size , int dataBufferSize );
+ SYNCML_DM_RET_STATUS_T LargeObjectSendGetFreeSpace( SmlResultsPtr_t p_results,
+ SmlItemPtr_t p_results_item ,
+ int &size ,
+ int &originalSize ,
+ int &dataBufferSize,
+ MemSize_t &freeSpace );
+ SYNCML_DM_RET_STATUS_T LargeObjectRecvDecodeData(DMAddData & oAddData, DMCommandType cmdType, SmlItemPtr_t p_data_item);
+
+ SYNCML_DM_RET_STATUS_T LargeObjectRecvLastChunk(DMAddData & oAddData,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_data_item);
+
+ SYNCML_DM_RET_STATUS_T IsRecveivingLastChunk(DMAddData & oAddData,
+ BOOLEAN bMoreData,
+ int &size,
+ BOOLEAN &lsLastChunk);
+
+ SYNCML_DM_RET_STATUS_T PrepareESNDataBuffer(UINT8 **pEncData, UINT32 & encLen , UINT8 **bufp);
+ SYNCML_DM_RET_STATUS_T SetLastChunkData(DMAddData & oAddData,DMCommandType cmdType);
+ SYNCML_DM_RET_STATUS_T SetLastChunkDataFromFile(DMAddData & oAddData,
+ DMBuffer &lastData,
+ UINT8**szBuf,
+ int chunksize,
+ UINT8 *decDataBuf,
+ UINT32 decMaxBufLen,
+ UINT32 &lastChunkSize);
+ SYNCML_DM_RET_STATUS_T SetLastChunkRemainData(DMAddData & oAddData,
+ DMBuffer &lastData,
+ UINT8* szBuf,
+ int chunksize,
+ UINT8 *decDataBuf,
+ UINT32 decMaxBufLen,
+ UINT32 lastChunkSize);
+ SYNCML_DM_RET_STATUS_T PreProcessFirstMoreData(DMAddData & oAddData,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_data_item,
+ int &size );
+
+#endif
+
+ SmlSyncHdrPtr_t pSyncHdr; /* Pointer to the SyncHdr memory.*/
+
+ DMString pMessageIdOfServer; /* Server message id reference */
+ UINT32 MaxMessageSize; /* Maximum message size can be handled */
+ UINT32 MaxObjectSize; /* Maximum object size can be handled */
+
+ UINT16 commandId; /* Sending package Command id reference */
+ UINT16 messageId; /* Message id reference, static across the BuildObjs in a
+ * Session. */
+ InstanceID_t sendInstanceId; /* Reference for Send DM doc SyncML instance */
+ DMProcessScriptSession * pDmMgmtSessionObj; /* Pointer to the MgmtSessionObj */
+ SYNCML_DM_SESSION_DIRECTION_T sessionDirection; /* Remember the SessionDirection */
+ DMGetData m_oAccData;
+ DMFirmAlertVector firmAlertVec; /* used to store firmAlertVector, rebuild 1226 in case authentication failure*/
+#ifdef LOB_SUPPORT
+ BOOLEAN m_bProcessingLargeObject;
+ BOOLEAN m_bESN;
+ BOOLEAN m_bBinary;
+ DmtDataChunk *m_pChunkData;
+ UINT32 m_ChunkOffset;
+
+ /* Large obect delivery */
+ int largeObjectCmdSize;
+ int largeObjectSize;
+ int largeObjectBufferUsedSize;
+ UINT32 largeObjectChunkSize;
+ int largeObjectChunkOffset;
+
+ DMBuffer largeObjectBuffer;
+ DMString largeObjectCmdRef;
+ DMString largeObjectMsgRef;
+ DMBuffer largeObjectTURI;
+ DMBuffer largeObjectSURI;
+ DMBuffer largeObjectType;
+ SYNCML_DM_FORMAT_T largeObjectFormat;
+ DMCommandType largeObjectCmd;
+ DMFileHandler *largeObjFileHandle;
+ DMString largeObjFileName;
+#endif
+};
+
+#endif /* SYNCML_DM_BUILDPACKAGE_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_ChoiceAlert.H b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_ChoiceAlert.H
new file mode 100644
index 0000000..51d7782
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_ChoiceAlert.H
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_CHOICE_ALERT_H
+#define SYNCML_DM_CHOICE_ALERT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_ChoiceAlert.h
+
+ General Description: A class representing the display alerts.
+
+==================================================================================================*/
+
+#include "SYNCML_DM_Alert.H"
+
+class SYNCML_DM_ChoiceAlert : public SYNCML_DM_Alert
+{
+
+public:
+ virtual void parse(SmlAlertPtr_t pContent);
+ virtual ~SYNCML_DM_ChoiceAlert(){}
+
+protected:
+ DMStringVector choices; // choices
+
+ void parseChoices(SmlItemListPtr_t p_alert_list_item);
+
+ void addChoice(const char* choice);
+
+};
+
+#endif /* SYNCML_DM_CHOICE_ALERT_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_ConfirmAlert.H b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_ConfirmAlert.H
new file mode 100644
index 0000000..4bab33b
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_ConfirmAlert.H
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_CONFIRM_ALERT_H
+#define SYNCML_DM_CONFIRM_ALERT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_DisplayAlert.h
+
+ General Description: A class representing the display alerts.
+
+==================================================================================================*/
+
+#include "SYNCML_DM_Alert.H"
+
+class SYNCML_DM_ConfirmAlert : public SYNCML_DM_Alert
+{
+
+public:
+
+ SYNCML_DM_ConfirmAlert();
+ virtual ~SYNCML_DM_ConfirmAlert() {};
+
+ SYNCML_DM_RET_STATUS_T show();
+
+
+private:
+ XPL_DM_ALERT_RES_T defaultResponse; // the default response
+ XPL_DM_ALERT_RES_T responseCode;
+
+ virtual XPL_DM_ALERT_RES_T getAction() const;
+
+ virtual SYNCML_DM_RET_STATUS_T getDefaultResponse(DMStringVector & userResponse) const;
+
+ virtual SYNCML_DM_RET_STATUS_T getResponse(DMStringVector & userResponse) const;
+
+ virtual void processParameter(CPCHAR name, CPCHAR value);
+
+};
+
+#endif /* SYNCML_DM_CONFIRM_ALERT_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_DisplayAlert.H b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_DisplayAlert.H
new file mode 100644
index 0000000..b973d06
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_DisplayAlert.H
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_DISPLAY_ALERT_H
+#define SYNCML_DM_DISPLAY_ALERT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_DisplayAlert.h
+
+ General Description: A class representing the display alerts.
+
+==================================================================================================*/
+
+#include "SYNCML_DM_Alert.H"
+
+class SYNCML_DM_DisplayAlert : public SYNCML_DM_Alert
+{
+
+public:
+
+ SYNCML_DM_RET_STATUS_T show();
+ virtual ~SYNCML_DM_DisplayAlert(){}
+
+
+private:
+
+ virtual XPL_DM_ALERT_RES_T getAction() const;
+
+ virtual SYNCML_DM_RET_STATUS_T getDefaultResponse(DMStringVector & userResponse) const;
+
+ virtual SYNCML_DM_RET_STATUS_T getResponse(DMStringVector & userResponse) const;
+
+
+ virtual void processParameter(CPCHAR name, CPCHAR value);
+
+};
+
+#endif /* SYNCML_DM_DISPLAY_ALERT_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_MultipleChoiceAlert.H b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_MultipleChoiceAlert.H
new file mode 100644
index 0000000..456b288
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_MultipleChoiceAlert.H
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_MULTIPLE_CHOICE_ALERT_H
+#define SYNCML_DM_MULTIPLE_CHOICE_ALERT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_MultipleChoiceAlert.h
+
+ General Description: A class representing the display alerts.
+
+==================================================================================================*/
+
+#include "SYNCML_DM_ChoiceAlert.H"
+
+class SYNCML_DM_MultipleChoiceAlert : public SYNCML_DM_ChoiceAlert
+{
+
+public:
+
+ SYNCML_DM_MultipleChoiceAlert();
+ virtual ~SYNCML_DM_MultipleChoiceAlert() {};
+
+ SYNCML_DM_RET_STATUS_T show();
+
+
+private:
+
+ DMStringVector defaultResponses; // the default responses
+ XPL_DM_ALERT_MCHOICE_RES_T response;
+
+ void parseDefaultResponses(CPCHAR defaultResponses);
+
+ virtual XPL_DM_ALERT_RES_T getAction() const;
+
+ virtual SYNCML_DM_RET_STATUS_T getDefaultResponse(DMStringVector & userResponse) const;
+
+ virtual SYNCML_DM_RET_STATUS_T getResponse(DMStringVector & userResponse) const;
+
+ virtual void processParameter(CPCHAR name, CPCHAR value);
+
+
+};
+
+#endif /* SYNCML_DM_MULTIPLE_CHOICE_ALERT_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_SingleChoiceAlert.H b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_SingleChoiceAlert.H
new file mode 100644
index 0000000..645f555
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_SingleChoiceAlert.H
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_SINGLECHOICE_ALERT_H
+#define SYNCML_DM_SINGLECHOICE_ALERT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_SingleChoiceAlert.h
+
+ General Description: A class representing the display alerts.
+
+==================================================================================================*/
+
+#include "SYNCML_DM_ChoiceAlert.H"
+
+class SYNCML_DM_SingleChoiceAlert : public SYNCML_DM_ChoiceAlert
+{
+
+public:
+
+ SYNCML_DM_SingleChoiceAlert();
+ virtual ~SYNCML_DM_SingleChoiceAlert() {};
+
+ SYNCML_DM_RET_STATUS_T show();
+
+private:
+
+ INT32 defaultResponse; // the default response
+ XPL_DM_ALERT_SCHOICE_RES_T response;
+
+ virtual XPL_DM_ALERT_RES_T getAction() const;
+
+ virtual SYNCML_DM_RET_STATUS_T getDefaultResponse(DMStringVector & userResponse) const;
+
+ virtual SYNCML_DM_RET_STATUS_T getResponse(DMStringVector & userResponse) const;
+
+ virtual void processParameter(CPCHAR name, CPCHAR value);
+
+};
+
+#endif /* SYNCML_DM_SINGLECHOICE_ALERT_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_TextInputAlert.H b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_TextInputAlert.H
new file mode 100644
index 0000000..c04e20c
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/SYNCML_DM_TextInputAlert.H
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_TEXTINPUT_ALERT_H
+#define SYNCML_DM_TEXTINPUT_ALERT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_TextInputAlert.h
+
+ General Description: A class representing the display alerts.
+
+==================================================================================================*/
+
+#include "SYNCML_DM_Alert.H"
+
+class SYNCML_DM_TextInputAlert : public SYNCML_DM_Alert
+{
+
+public:
+
+ SYNCML_DM_TextInputAlert();
+ virtual ~SYNCML_DM_TextInputAlert(){}
+
+ SYNCML_DM_RET_STATUS_T show();
+
+private:
+ DMString defaultResponse; // the default response
+ INT32 maxLength; // maximum length for user input text
+ XPL_DM_ALERT_INPUT_T inputType; // alert input type
+ XPL_DM_ALERT_ECHO_T echoType; // alert echo type
+ XPL_DM_ALERT_TEXTINPUT_RES_T response;
+
+ virtual XPL_DM_ALERT_RES_T getAction() const;
+
+ virtual SYNCML_DM_RET_STATUS_T getDefaultResponse(DMStringVector & userResponse) const;
+
+ virtual SYNCML_DM_RET_STATUS_T getResponse(DMStringVector & userResponse) const;
+
+ XPL_DM_ALERT_INPUT_T convertInputType(CPCHAR inputType);
+
+ XPL_DM_ALERT_ECHO_T convertEchoType(CPCHAR echoType);
+
+ virtual void processParameter(CPCHAR name, CPCHAR value);
+};
+
+#endif /* SYNCML_DM_TEXTINPUT_ALERT_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/dmBootstrapSession.h b/engine/dmlib/dmengine/dm_ssession/hdr/dmBootstrapSession.h
new file mode 100644
index 0000000..ab5e451
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/dmBootstrapSession.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_BOOTSTRAPSESSION_H
+#define DM_BOOTSTRAPSESSION_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: dmExtractServerIDSession.h
+
+ General Description: This file contains declaration of DMExractServerIDSession calls.
+
+==================================================================================================*/
+
+#include "dmSession.h"
+
+/*==================================================================================================
+ CLASSES DECLARATION
+==================================================================================================*/
+
+class DMBootstrapSession : public DMSession
+{
+
+ public:
+
+ virtual SYNCML_DM_RET_STATUS_T Start(const UINT8 *docInputBuffer ,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ DMString & serverID);
+
+ private:
+ /* This function will be called to register the DM Engine with the SyncML Toolkit. */
+ virtual SYNCML_DM_RET_STATUS_T SetToolkitCallbacks(SmlCallbacks_t * pSmlCallbacks);
+
+
+
+
+};
+
+#endif /* DMProcessScriptSession */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/dmClientSrvCreds.h b/engine/dmlib/dmengine/dm_ssession/hdr/dmClientSrvCreds.h
new file mode 100644
index 0000000..0b141a1
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/dmClientSrvCreds.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The dmClientSrvCreds.h header file provides declaration
+ * for class DMClientServerCreds
+ */
+
+#ifndef __DMCLIENT_SRVCREDS_H__
+#define __DMCLIENT_SRVCREDS_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "dmSessionDefs.h"
+
+class DMClientServerCreds
+{
+public:
+ DMClientServerCreds();
+
+ SYNCML_DM_RET_STATUS_T LoadInitialValues();
+ SYNCML_DM_RET_STATUS_T SetPrefClientAuth( SYNCML_DM_CHAL_TYPE_T nClientAuthType );
+ SYNCML_DM_RET_STATUS_T SetPrefServerAuth( SYNCML_DM_CHAL_TYPE_T nServerAuthType );
+
+ SYNCML_DM_RET_STATUS_T SaveClientAttribute( CPCHAR szAttribute, CPCHAR szValue );
+ SYNCML_DM_RET_STATUS_T SaveServerAttribute( CPCHAR szAttribute, CPCHAR szValue );
+ SYNCML_DM_RET_STATUS_T SaveAttribute( CPCHAR szProfile, CPCHAR szAttribute, CPCHAR szValue );
+ SYNCML_DM_RET_STATUS_T SaveAuthPref();
+
+ static SYNCML_DM_RET_STATUS_T DMGetDeviceID( DMString& device_id );
+ static DMString GetDefaultAuthType();
+
+ // implementation
+private:
+ static SYNCML_DM_CHAL_TYPE_T Str2ChalType( CPCHAR szChal );
+ static CPCHAR ChalType2Str( SYNCML_DM_CHAL_TYPE_T nChal );
+ SYNCML_DM_RET_STATUS_T SetClientAuth( CPCHAR szLastAuthPref, BOOLEAN bTryDefault );
+ SYNCML_DM_RET_STATUS_T GetDeviceID( DMString& device_id );
+
+ // data
+public:
+ // to minimize number of changes names for data members are left as in DM 1.1
+ // and members are declared public
+ DMString pDMAccNodeName; // Profile name for Current ServerID
+ DMString pClientUserName; // AAuthName for client profile
+ DMString pClientPW; // AAuthSecret for client profile
+ DMString pClientNonce; // AAuthData for client profile
+ DMString pServerId; // ServerID
+ DMString pServerPW; // AAuthSecret for server profile
+ DMString pServerNonce; // AAuthData for server profile
+ SYNCML_DM_CHAL_TYPE_T AuthPrefCredType; // used to choose right client credentials
+ SYNCML_DM_CHAL_TYPE_T ServerChalType; // used to choose server credentials
+
+private:
+ DMString m_strClientProfileURI;
+ DMString m_strServerProfileURI;
+ DMString m_strdevIMEI;
+ BOOLEAN m_bAuthPrefUpdated;
+};
+
+#endif /*__DMCLIENT_SRVCREDS_H__*/
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/dmProcessScriptSession.h b/engine/dmlib/dmengine/dm_ssession/hdr/dmProcessScriptSession.h
new file mode 100644
index 0000000..2ec9c2a
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/dmProcessScriptSession.h
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMPROCESSSCRIPTSESSION_H
+#define DMPROCESSSCRIPTSESSION_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: dmProcessScriptSession.h
+
+ General Description: This file contains declaration of DMProcessScriptSession calls.
+
+==================================================================================================*/
+
+#include "dmSession.h"
+#include "SYNCML_DM_BuildPackage.H"
+#include "dm_security.h"
+#include "dmSessionDefs.h"
+#include "dmClientSrvCreds.h"
+
+/*==================================================================================================
+ CONSTANTS
+==================================================================================================*/
+
+/*==================================================================================================
+ CLASSES DECLARATION
+==================================================================================================*/
+
+class DMProcessScriptSession : public DMSession
+{
+
+ public:
+
+ DMProcessScriptSession();
+
+ virtual ~DMProcessScriptSession();
+
+
+ /* set response URI */
+ virtual SYNCML_DM_RET_STATUS_T SetURI (CPCHAR szURI) { return SYNCML_DM_SUCCESS; }
+
+ void IncCommandCount ();
+
+ /* Get and Set the inAtomicCommand.*/
+ void SetInAtomicCommand (BOOLEAN newInAtomicCommand);
+
+ BOOLEAN GetInAtomicCommand ();
+
+ UINT16 GetServerSessionId ();
+
+ /* Get the sendInstanceId member.*/
+ InstanceID_t GetSendInstanceId();
+
+ void SetClientRetryCount(UINT8 newcount);
+
+ void IncClientRetryCount();
+
+ void SetSessionAborted() { m_bSessionAborted = TRUE; }
+
+ inline BOOLEAN IsSessionAborted() { return m_bSessionAborted; }
+
+ inline void ResetServerRetryCount() {serverRetryCount = 0;}
+
+ void SetSecState( SYNCML_DM_SEC_STATE_FLAG_T ua_SecState ) { m_nSecState = ua_SecState; }
+
+ SYNCML_DM_SEC_STATE_FLAG_T GetSecState() { return m_nSecState; }
+
+ inline void SetSecStateSrv( BOOLEAN bAuthorized )
+ {
+ if ( bAuthorized )
+ m_nSecState |= DM_CLIENT_NO_SERVER_Y_AUTH;
+ else
+ m_nSecState &= (~DM_CLIENT_NO_SERVER_Y_AUTH);
+ }
+
+ inline BOOLEAN IsServerAuthorized() const
+ {
+ return (m_nSecState & DM_CLIENT_NO_SERVER_Y_AUTH) != 0;
+ }
+
+
+ inline BOOLEAN IsAuthorized() const
+ {
+ return ( m_nSecState == DM_BOTH_CLIENT_SERVER_AUTH ||
+ m_nSecState == DM_CLIENT_NO_SERVER_Y_AUTH );
+
+ }
+
+ inline SYNCML_DM_RET_STATUS_T GetNotAuthorizedStatus()
+ {
+ return ( isServCredsMissing ? SYNCML_DM_AUTHENTICATION_REQUIRED : SYNCML_DM_UNAUTHORIZED);
+ }
+
+ /* Get the clientServerCreds structure.*/
+ virtual DMClientServerCreds * GetClientServerCreds();
+
+
+ virtual SYNCML_DM_RET_STATUS_T Start(const UINT8 *docInputBuffer ,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ DMBuffer & oResult);
+
+
+ virtual BOOLEAN IsProcessScript() { return TRUE; }
+#ifdef LOB_SUPPORT
+ BOOLEAN IsLargeObjectSupported() const{ return isLargeObjectSupported; };
+ UINT32 GetDefaultMaxObjectSize() const{ return dmtMaxObjectSize; };
+#endif
+
+#ifdef TNDS_SUPPORT
+ BOOLEAN IsWBXMLEncoding() const{ return smlEncodingType == SML_WBXML; };
+#endif
+
+
+ protected:
+ /* This function will be called to register the DM Engine with the SyncML Toolkit. */
+ virtual SYNCML_DM_RET_STATUS_T SetToolkitCallbacks(SmlCallbacks_t * pSmlCallbacks);
+
+ /* This function will be called when a new DM package is received. */
+ SYNCML_DM_RET_STATUS_T ParseMessage();
+
+
+ BOOLEAN inAtomicCommand; /* Flag for atomic command */
+
+ UINT16 commandCount; /* Keep track of the management commands.*/
+
+ UINT8 serverRetryCount; /* Keep track of server auth failures.*/
+
+ UINT8 clientRetryCount; /* Keep track of client auth failures.*/
+
+ UINT16 serverSessionId; /* Holds the Server's SessionID */
+
+ BOOLEAN m_bSessionAborted;
+
+ BOOLEAN isServCredsMissing;
+
+ SYNCML_DM_SEC_STATE_FLAG_T m_nSecState; /* DMUA Security state */
+
+ SYNCML_DM_USER_DATA_T userData; /* Structure that contains data shared between our
+ code and the callbacks. */
+ DMCredHeaders m_oRecvCredHeaders;
+
+ DMClientServerCreds clientServerCreds; /* Holds the Security Info for this
+ session.*/
+
+ SYNCML_DM_BuildPackage m_oPkgBuilder;
+#ifdef LOB_SUPPORT
+ BOOLEAN isLargeObjectSupported;
+ UINT32 dmtMaxObjectSize; /* Maximum object size can be handled */
+#endif
+};
+
+#endif /* DMProcessScriptSession */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/dmServerAuthentication.h b/engine/dmlib/dmengine/dm_ssession/hdr/dmServerAuthentication.h
new file mode 100644
index 0000000..4af1c14
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/dmServerAuthentication.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMSERVERAUTHENTICATION_H
+#define DMSERVERAUTHENTICATION_H
+
+/*==================================================================================================
+
+ Header Name: dmServerAuthentication.h
+
+ General Description: Declaration of DMServerAuthentication class.
+
+==================================================================================================*/
+
+#include "syncml_dm_data_types.h"
+#include "dmbuffer.h"
+
+/*==================================================================================================
+ CLASSES DECLARATION
+==================================================================================================*/
+class DMServerAuthentication
+{
+public:
+ SYNCML_DM_RET_STATUS_T AuthenticateServer(SYNCML_DM_AuthContext_T& AuthContext);
+
+private:
+ void CheckCredentials(SYNCML_DM_AuthContext_T& AuthContext,const DMString& password, const DMBuffer& data, BOOLEAN bDecodeNonce);
+
+ DMString GetPreferredProfilePath(const DMString& strAccName, const DMMap<DMString,UINT32>& dmAuthProfiles);
+
+ SYNCML_DM_RET_STATUS_T TryProfile_1_1(const DMString& strAccName, const DMString& strProfilePath, SYNCML_DM_AuthContext_T& AuthContext);
+
+ SYNCML_DM_RET_STATUS_T TryProfile_1_2(const DMString& strAccName, const DMString& strProfilePath, SYNCML_DM_AuthContext_T& AuthContext);
+};
+#endif
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/dmServerSession.h b/engine/dmlib/dmengine/dm_ssession/hdr/dmServerSession.h
new file mode 100644
index 0000000..bdbcf28
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/dmServerSession.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMSERVERSESSION_H
+#define DMSERVERSESSION_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: DMServerSession.h
+
+ General Description: This file contains declaration of DMServerSession class.
+ The class provides services to management DM sessions. It receives the
+ SYNCML DM packages from the Transport Binding module, starts the DM session, processes the
+ received DM package, builds the response DM package and sends it to the Transport Binding
+ module, and ends the DM session.
+
+==================================================================================================*/
+
+#include "dmtSessionProp.hpp"
+#include "dm_tpt_connection.H"
+#include "dmProcessScriptSession.h"
+
+/*==================================================================================================
+ CONSTANTS
+==================================================================================================*/
+
+/* According to spec, we should only have two attempts to access the server */
+#define MAX_AUTH_RETRY 2
+
+/*==================================================================================================
+ CLASSES DECLARATION
+==================================================================================================*/
+
+class DMServerSession : public DMProcessScriptSession
+{
+ public:
+
+ /* Class constructor and destructor. */
+ DMServerSession();
+
+
+ /* The UserAgent calls this function to start the DM session. */
+ virtual SYNCML_DM_RET_STATUS_T Start(CPCHAR pServerID,
+ DmtSessionProp * pSessionProp);
+
+ /* UserAgent object call this function to set the response URI */
+ virtual SYNCML_DM_RET_STATUS_T SetURI (CPCHAR pRespURI);
+
+ virtual BOOLEAN IsProcessScript() { return FALSE; }
+
+
+ protected:
+ void SetServCredsMissing( BOOLEAN newIsServCredsMissing );
+
+ /* This function will be called when a DM package is built up and ready to send. */
+ SYNCML_DM_RET_STATUS_T SendPackage();
+
+ SYNCML_DM_RET_STATUS_T RecvPackage();
+
+ /* This function will establish the DM session connection with the server. */
+ SYNCML_DM_RET_STATUS_T ConnectServer(CPCHAR pServerId);
+
+ /* This function will build and send the package one to the Server. */
+ SYNCML_DM_RET_STATUS_T BuildSendPackageOne(CPCHAR pServerID, DmtSessionProp * pSessionProp);
+
+
+ SYNCML_DM_OTAConnection m_oConnObject; /* Connection object */
+
+ };
+
+/*================================================================================================*/
+#endif /* SYNCML_DM_MGMTSESSION_H */
+
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/dmSession.h b/engine/dmlib/dmengine/dm_ssession/hdr/dmSession.h
new file mode 100644
index 0000000..be239e6
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/dmSession.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMSESSION_H
+#define DMSESSION_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: DMSession.h
+
+ General Description: This file contains declaration of of base DMSession class.
+
+==================================================================================================*/
+
+#include "dmtDefs.h"
+#include "dmMemory.h"
+#include "dmSessionDefs.h"
+
+extern "C" {
+#include "sml.h"
+#include "smlerr.h"
+}
+
+/*==================================================================================================
+ CLASSES DECLARATION
+==================================================================================================*/
+
+class DMSession
+{
+
+ public:
+ DMSession();
+
+ virtual ~DMSession();
+
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+ protected:
+ virtual SYNCML_DM_RET_STATUS_T Init(BOOLEAN isWBXML);
+
+ /* This function will be called to register the DM Engine with the SyncML Toolkit. */
+ SYNCML_DM_RET_STATUS_T RegisterDmEngineWithSyncmlToolkit(VoidPtr_t pUserData);
+
+ /* This function will be called to register the DM Engine with the SyncML Toolkit. */
+ virtual SYNCML_DM_RET_STATUS_T SetToolkitCallbacks(SmlCallbacks_t * pSmlCallbacks);
+
+ /* This function will be called to un-register the DM Engine with the SyncML Toolkit. */
+ virtual void UnRegisterDmEngineWithSyncmlToolkit();
+
+
+ protected:
+
+ InstanceID_t sendInstanceId; /* Reference for Send DM doc SyncML instance */
+ InstanceID_t recvInstanceId; /* Reference for Recv DM doc SyncML instance */
+
+ MemPtr_t pReadPos; /* Workspace Pointer from which data can be read */
+ MemPtr_t pWritePos; /* Workspace Pointer to which data can be written */
+
+ MemSize_t workspaceFreeSize; /* Max free Size of available space for data */
+ MemSize_t workspaceUsedSize; /* Size of used data in workspace which may be
+ read */
+ UINT8 *smlContentType;
+ SmlEncoding_t smlEncodingType;
+
+ SYNCML_DM_INDIRECT_BUFFER_T sendSmlDoc; /* The SyncML document to be send to the
+ server */
+ SYNCML_DM_INDIRECT_BUFFER_T recvSmlDoc; /* The SycnML document to be received from
+ the server */
+};
+
+#endif /* SYNCML_DM_MGMTSESSION_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/dmSessionDefs.h b/engine/dmlib/dmengine/dm_ssession/hdr/dmSessionDefs.h
new file mode 100644
index 0000000..8cbf505
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/dmSessionDefs.h
@@ -0,0 +1,271 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_UA_TYPEDEFS_H
+#define DM_UA_TYPEDEFS_H
+
+/*==================================================================================================
+
+ Header Name: dm_ua_typedefs.h
+
+ General Description: This contains DMUA data type definitions.
+
+==================================================================================================*/
+
+#include "syncml_dm_data_types.h"
+#include "smldtd.h"
+#include "dmbuffer.h"
+#include "dm_tree_class.H"
+
+/*==================================================================================================
+ CONSTANTS
+==================================================================================================*/
+
+#define UINT16_TYPE_STR_SIZE_5 6 /* Array size for coverting a UINT16 number to a string */
+#define UINT32_TYPE_STR_SIZE_10 11 /* Array size for coverting a UINT32 number to a string */
+
+#define NUMBER_OF_WORKSPACE 2 /* Number of workspace for a session */
+#define WORKSPACE_NAME_LEN 30 /* String length of workspace name */
+#define MAX_BIN_NONCE_LEN 50 /* Maximum length of a binary decoded Nonce */
+#define MAX_BIN_VAL_LEN 50 /* Max length of a b64 decode bin array */
+
+#define DEFAULT_MESSAGE_ID "1"
+#define DEFAULT_HDR_CMD_ID "0"
+
+#define SERVER_RESYNC_NONCE "AAAAAA==" // Motorola, <e50324>, <12/08/09>, <ikmap-2156> / Nonce Resynchronization
+//#define SERVER_RESYNC_NONCE "MTIzNDU=" // for Sprint HFA OMA DM
+
+/*==================================================================================================
+ ENUMS
+==================================================================================================*/
+/* These enums are used when handling the AppNotify messages.*/
+enum
+{
+ SYNCML_DM_NODE_ADD,
+ SYNCML_DM_NODE_DELETE,
+ SYNCML_DM_NODE_RENAME,
+ SYNCML_DM_NODE_INVALID
+};
+typedef UINT8 SYNCML_DM_NODE_CHANGE_T;
+
+/* These enums are used for the various Challenge types.*/
+enum
+{
+ SYNCML_DM_CHAL_UNDEFINED = -1,
+ SYNCML_DM_CHAL_NONE = 0,
+ SYNCML_DM_CHAL_BASIC = 1,
+ SYNCML_DM_CHAL_MD5 = 2,
+ SYNCML_DM_CHAL_HMAC = 3
+};
+typedef INT8 SYNCML_DM_CHAL_TYPE_T;
+
+/* Type Defines */
+enum {
+ DM_COMMAND_INVALID = 0,
+ DM_COMMAND_ADD,
+ DM_COMMAND_ALERT,
+ DM_COMMAND_ATOMIC_START,
+ DM_COMMAND_ATOMIC_END,
+ DM_COMMAND_COPY,
+ DM_COMMAND_DELETE,
+ DM_COMMAND_EXEC,
+ DM_COMMAND_GET,
+ DM_COMMAND_MAP,
+ DM_COMMAND_PUT,
+ DM_COMMAND_RESULTS,
+ DM_COMMAND_SEARCH,
+ DM_COMMAND_SEQUENCE_START,
+ DM_COMMAND_SEQUENCE_END,
+ DM_COMMAND_STATUS,
+ DM_COMMAND_SYNC_START,
+ DM_COMMAND_SYNC_END,
+ DM_COMMAND_REPLACE,
+ DM_COMMAND_HEADER,
+ DM_COMMAND_BODY_END,
+ DM_COMMAND_COUNT
+};
+typedef UINT8 DMCommandType;
+
+/*==================================================================================================
+ TYPEDEFS
+==================================================================================================*/
+
+/* This structure is used to hold credential information. */
+class DMCredHeaders
+{
+public:
+ inline void clear()
+ {
+ m_oAlgorithm.clear();
+ m_oUserName.clear();
+ m_oMac.clear();
+ }
+
+ inline BOOLEAN empty() const
+ {
+ return ( (m_oUserName.getSize() == 0 || m_oMac.getSize() == 0) ? TRUE : FALSE );
+ }
+
+ inline BOOLEAN isCorrect() const
+ {
+ if ( m_oUserName.getSize() != 0 )
+ {
+ if ( m_oMac.getSize() == 0 )
+ return FALSE;
+ }
+ else
+ {
+ if ( m_oMac.getSize() != 0 )
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ DMBuffer m_oAlgorithm;
+ DMBuffer m_oUserName;
+ DMBuffer m_oMac;
+};
+
+
+
+typedef struct
+{
+ UINT8 *pChalType;
+ UINT8 *pChalFormat;
+ UINT8 *pChalNonce;
+} DM_CHALLENGE_T;
+
+
+/* Added for Multiple Messages Support */
+struct SYNCML_DM_STATUS_DATA_T
+{
+ DMString pCmdId;
+ DMString pCmdName;
+ DMString pSource;
+ DMString pTarget;
+ SYNCML_DM_RET_STATUS_T status;
+ DMStringVector responses; // alert requires additional parameters
+ BOOLEAN bValueSet;
+ BOOLEAN bInSequence;
+
+ SYNCML_DM_STATUS_DATA_T() { status = 0; bValueSet = FALSE; bInSequence = FALSE;}
+ SYNCML_DM_STATUS_DATA_T( const char* szCmd, const char* szCmdName, const char* szSource,
+ const char* szTarget, SYNCML_DM_RET_STATUS_T st, DMStringVector* pAdditionalData = NULL ){
+ pCmdId = szCmd;
+ pCmdName = szCmdName;
+ pSource = szSource;
+ pTarget = szTarget;
+ status = st;
+ bValueSet = TRUE;
+ bInSequence = FALSE;
+
+ if ( pAdditionalData )
+ responses = *pAdditionalData;
+ }
+};
+
+struct SYNCML_DM_RESULT_VALUE {
+ enum {Enum_Result_Get, Enum_Result_GetStruct, Enum_Result_GetStructData, Enum_Result_GetTnds, Enum_Result_Exec};
+
+ SmlResultsPtr_t _pGetExecResult;
+ SYNCML_DM_GET_ON_LIST_RET_DATA_T _oGetStructPos; // cached position for GetStruct
+ UINT8 _type; // see enum above
+ DMString _cmdRef;
+ DMString _msgID;
+
+ // methods
+ inline SYNCML_DM_RESULT_VALUE()
+ {
+ _type = 0; _pGetExecResult = NULL;
+ }
+ inline SYNCML_DM_RESULT_VALUE( UINT8 type, SmlResultsPtr_t pRes, const SYNCML_DM_GET_ON_LIST_RET_DATA_T& oData, const char* strCmdRef, const char* strMsgID ){
+ _type = type;
+ _oGetStructPos = oData;
+ _pGetExecResult = pRes;
+ _cmdRef = strCmdRef;
+ _msgID = strMsgID;
+ }
+};
+
+
+class DMProcessScriptSession;
+class SYNCML_DM_BuildPackage;
+
+struct SYNCML_DM_USER_DATA_T
+{
+ enum {Enum_Alert_None, Enum_Alert_Cancel, Enum_Alert_No};
+
+ // saved statuses
+ DMVector<UINT32> aStatuses;
+ DMVector<SYNCML_DM_RESULT_VALUE> aResults;
+
+ DMString pMsgRef;
+ SYNCML_DM_STATUS_DATA_T pAtomicStatus; // atomic command state
+ DMVector<SYNCML_DM_STATUS_DATA_T> oStatus; // atomic statuses (not built)
+ BOOLEAN rollback; // inside atomic and already rolled back
+ BOOLEAN sequenceFailed;
+ SYNCML_DM_ALERT_RES_T alertState; // alert state in atomic/sequence/document -
+ BOOLEAN bNonceGenerated;
+ DMProcessScriptSession *pSessionMng;
+ SYNCML_DM_BuildPackage * pPkgBuilder;
+
+
+ inline SYNCML_DM_USER_DATA_T() {
+ rollback = FALSE;
+ sequenceFailed = FALSE;
+ bNonceGenerated = FALSE;
+ pMsgRef = NULL;
+ alertState = SYNCML_DM_ALERT_NONE;
+ pSessionMng = NULL;
+ pPkgBuilder = NULL;
+ }
+
+ inline bool IsCommandSkipped() const
+ {
+ return ( alertState == SYNCML_DM_ALERT_CANCEL ||
+ ( ((pAtomicStatus.bValueSet || pAtomicStatus.bInSequence) &&
+ (rollback || alertState == SYNCML_DM_ALERT_NO)) ||
+ (pAtomicStatus.bInSequence && sequenceFailed)));
+ }
+ inline void EndAtomic() {
+ pAtomicStatus.bValueSet = FALSE;
+ rollback = FALSE;
+ oStatus.clear();
+
+ if ( alertState != SYNCML_DM_ALERT_CANCEL )
+ alertState = SYNCML_DM_ALERT_NONE;
+ }
+
+ inline BOOLEAN IsSequence()
+ {
+ return pAtomicStatus.bInSequence;
+ }
+
+ inline void StartSequence()
+ {
+ pAtomicStatus.bInSequence = TRUE;
+ }
+ inline void EndSequence()
+ {
+ pAtomicStatus.bInSequence = FALSE;
+ sequenceFailed = FALSE;
+
+ if ( alertState != Enum_Alert_Cancel )
+ alertState = Enum_Alert_None;
+ }
+};
+
+#endif /* DM_UA_TYPEDEFS_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/dmSessionFactory.h b/engine/dmlib/dmengine/dm_ssession/hdr/dmSessionFactory.h
new file mode 100644
index 0000000..68f8849
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/dmSessionFactory.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMSESSIONFACTORY_H
+#define DMSESSIONFACTORY_H
+
+/*==================================================================================================
+
+ Header Name: dmSessionFactory.h
+
+ General Description: Declaration of Internal interfaces to Server Session.
+
+==================================================================================================*/
+
+#include "dmtSessionProp.hpp"
+#include "dmbuffer.h"
+#include "syncml_dm_data_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+SYNCML_DM_RET_STATUS_T DmProcessServerDataInternal(CPCHAR szPrincipal, const DmtSessionProp& session);
+
+SYNCML_DM_RET_STATUS_T DmProcessScriptDataInternal(const UINT8 * docInputBuffer,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ DMBuffer & oResult);
+
+SYNCML_DM_RET_STATUS_T DmBootstrapInternal(const UINT8 * docInputBuffer,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMString & serverID);
+
+
+SYNCML_DM_RET_STATUS_T DmAuthenticateServerInternal(SYNCML_DM_AuthContext_T& AuthContext );
+
+
+#ifndef DM_NO_SESSION_DLL
+SYNCML_DM_RET_STATUS_T DmProcessServerData(CPCHAR szPrincipal, const DmtSessionProp& session);
+
+SYNCML_DM_RET_STATUS_T DmProcessScriptData(const UINT8 * docInputBuffer,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ DMBuffer & oResult);
+
+SYNCML_DM_RET_STATUS_T DmBootstrap(const UINT8 * docInputBuffer,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMString & serverID);
+
+
+SYNCML_DM_RET_STATUS_T DmAuthenticateServer(SYNCML_DM_AuthContext_T& AuthContext );
+#else
+#define DmProcessServerData(szPrincipal, isWBXML) DmProcessServerDataInternal(szPrincipal, isWBXML)
+
+#define DmProcessScriptData(docInputBuffer,inDocSize,isWBXML, oResult) \
+ DmProcessScriptDataInternal(docInputBuffer,inDocSize,isWBXML, oResult)
+
+#define DmBootstrap(docInputBuffer,inDocSize,isWBXML, isProcess, serverID) \
+ DmBootstrapInternal(docInputBuffer,inDocSize,isWBXML, isProcess, serverID)
+
+#define DmAuthenticateServer(AuthContext) \
+ DmAuthenticateServerInternal(AuthContext)
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DMSESSION_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/hdr/dm_ua_handlecommand.h b/engine/dmlib/dmengine/dm_ssession/hdr/dm_ua_handlecommand.h
new file mode 100644
index 0000000..3e31b9d
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/hdr/dm_ua_handlecommand.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_UA_HANDLECOMMAND_H
+#define DM_UA_HANDLECOMMAND_H
+
+/*==================================================================================================
+
+ Header Name: dm_ua_handlecommand.h
+
+ General Description: This contains declaration of C functions corresponding to
+ SYNCML_DM_HandleCommand class.
+
+==================================================================================================*/
+
+extern "C" {
+#include "sml.h"
+}
+
+#include "syncml_dm_data_types.h"
+#include "dmSessionDefs.h"
+#include "dm_tree_typedef.h"
+
+/*==================================================================================================
+ Function declarations
+ These functions are declared for Callback Functions to be implemented by the Receiver.
+ Callback Functions are declared in the SyncML toolkit "syncml_toolkit/sml/ghdr/sml.h".
+==================================================================================================*/
+extern Ret_t HandleStartMessage(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlSyncHdrPtr_t pContent);
+
+extern Ret_t HandleEndMessage(InstanceID_t id,
+ VoidPtr_t userData,
+ Boolean_t final);
+
+extern Ret_t HandleAddCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlAddPtr_t pContent);
+
+extern Ret_t HandleAlertCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlAlertPtr_t pContent);
+
+extern Ret_t HandleDeleteCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlDeletePtr_t pContent);
+
+extern Ret_t HandleCopyCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlCopyPtr_t param);
+
+extern Ret_t HandleGetCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlGetPtr_t pContent);
+
+extern Ret_t HandleExecCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlExecPtr_t pContent);
+
+extern Ret_t HandleReplaceCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlReplacePtr_t pContent);
+
+extern Ret_t HandleStartSequenceCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlSequencePtr_t pContent);
+
+extern Ret_t HandleEndSequenceCommand(InstanceID_t id,
+ VoidPtr_t userData);
+
+extern Ret_t HandleStartAtomicCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlAtomicPtr_t pContent);
+
+extern Ret_t HandleEndAtomicCommand(InstanceID_t id,
+ VoidPtr_t userData);
+
+extern Ret_t HandleStatusCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlStatusPtr_t pContent);
+
+extern SYNCML_DM_RET_STATUS_T VerifyProtocolVersion( SmlSyncHdrPtr_t pContent);
+
+bool VerifyAlertItems(SmlAlertPtr_t pContent);
+
+#endif /* DM_UA_HANDLECOMMAND_H */
diff --git a/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_Alert.cc b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_Alert.cc
new file mode 100644
index 0000000..a9da710
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_Alert.cc
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: SYNCML_DM_Alert.cc
+
+ General Description: A class representing the alerts.
+
+==================================================================================================*/
+
+#include "dmStringUtil.h"
+#include "dm_uri_utils.h"
+#include "SYNCML_DM_Alert.H"
+
+SYNCML_DM_Alert::SYNCML_DM_Alert() {
+ maxDisplayTime = -1;
+ minDisplayTime = -1;
+}
+
+void SYNCML_DM_Alert::parse(SmlAlertPtr_t pContent) {
+
+ SmlItemListPtr_t p_alert_list_item;
+
+ if ( pContent == NULL )
+ return;
+
+ p_alert_list_item = pContent->itemList;
+
+ if ( p_alert_list_item != NULL )
+ {
+ parseParameters(p_alert_list_item);
+ parseMessage(p_alert_list_item->next);
+ }
+
+}
+
+void SYNCML_DM_Alert::parseParameters(SmlItemListPtr_t p_alert_list_item)
+{
+ SmlItemPtr_t p_alert_item;
+ SmlPcdataPtr_t p_alert_data;
+
+ if (p_alert_list_item == NULL)
+ return;
+
+ p_alert_item = p_alert_list_item->item;
+
+ if (p_alert_item == NULL)
+ return;
+
+ p_alert_data = p_alert_item->data;
+
+ if ( p_alert_data == NULL )
+ return;
+
+ CPCHAR name;
+ CPCHAR value;
+ DMToken params(FALSE,(CPCHAR)p_alert_data->content,'&');
+ CPCHAR pSegment = params.nextSegment();
+
+ while ( pSegment != NULL )
+ {
+ {
+ DMParser token(pSegment,'=');
+ name = token.nextSegment();
+ value = token.nextSegment();
+
+ if ( value != NULL && name != NULL )
+ processParameter(name,value);
+ }
+ pSegment = params.nextSegment();
+ }
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_Alert::processResponse(DMStringVector & userResponse,
+ SYNCML_DM_ALERT_RES_T * alertStatus)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ switch(getAction())
+ {
+ case XPL_DM_ALERT_RES_NO:
+ *alertStatus = SYNCML_DM_ALERT_NO;
+ dm_stat = SYNCML_DM_NOT_MODIFIED;
+ break;
+
+ case XPL_DM_ALERT_RES_YES:
+ getResponse(userResponse);
+ dm_stat = SYNCML_DM_SUCCESS;
+ break;
+
+ case XPL_DM_ALERT_RES_CANCEL:
+ *alertStatus = SYNCML_DM_ALERT_CANCEL;
+ dm_stat = SYNCML_DM_OPERATION_CANCELLED;
+ break;
+
+ case XPL_DM_ALERT_RES_NONE:
+ case XPL_DM_ALERT_RES_TIMEOUT:
+ getDefaultResponse(userResponse);
+ *alertStatus = SYNCML_DM_ALERT_CANCEL;
+ dm_stat = SYNCML_DM_REQUEST_TIMEOUT;
+ break;
+
+ default:
+ break;
+
+ }
+ return dm_stat;
+
+}
+
+
+void SYNCML_DM_Alert::parseMessage(SmlItemListPtr_t p_alert_list_item) {
+ SmlItemPtr_t p_alert_item;
+ SmlPcdataPtr_t p_alert_data;
+
+ if ( p_alert_list_item == NULL )
+ return;
+
+ p_alert_item = p_alert_list_item->item;
+
+ if ( p_alert_item == NULL )
+ return;
+
+ p_alert_data = p_alert_item->data;
+
+ if ( p_alert_data == NULL )
+ return;
+
+ msg = (CPCHAR)p_alert_data->content;
+}
+
+
+void SYNCML_DM_Alert::setMaxDisplayTime(INT32 maxDisplayTime)
+{
+ if (0 <= maxDisplayTime)
+ this->maxDisplayTime = maxDisplayTime;
+}
+
+void SYNCML_DM_Alert::setMinDisplayTime(INT32 minDisplayTime)
+{
+ if (0 <= minDisplayTime && minDisplayTime <= SYNCML_DM_ALERT_MAX_TIME)
+ this->minDisplayTime = minDisplayTime;
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_BuildPackage.cc b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_BuildPackage.cc
new file mode 100644
index 0000000..21263f3
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_BuildPackage.cc
@@ -0,0 +1,4646 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_BuildPackage.cc
+
+ General Description: Implementation of SYNCML_DM_BuildPackage class.
+
+==================================================================================================*/
+
+#include "SYNCML_DM_BuildPackage.H"
+#include "dm_security.h"
+#include "dmProcessScriptSession.h"
+#include "GeneratePassword.H"
+#include "dmt.hpp"
+#include "dm_tree_util.h"
+#include "xpl_File.h"
+
+extern "C" {
+#include "xpt-b64.h"
+#include "md5.h"
+#ifdef __SML_XML__
+#include <smldef.h>
+#endif
+#include <string.h>
+
+#include "xlttags.h"
+
+#ifdef __SML_XML__
+extern const ESCAPE_CHAR_TABLE_T escape_char_table[];
+#endif
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::SYNCML_DM_BuildPackage
+
+DESCRIPTION : The SYNCML_DM_BuildPackage class constructor.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_BuildPackage::SYNCML_DM_BuildPackage()
+{
+ commandId = 1;
+ messageId = 1;
+ MaxMessageSize = g_iDMWorkspaceSize; //DM_MAX_MSG_SIZE;
+ MaxObjectSize = 0;
+
+ pSyncHdr = NULL;
+
+ /* We need the MgmtSessionObj pointer and current sendInstanceId.*/
+ pDmMgmtSessionObj = NULL;
+ sendInstanceId = 0;
+ sessionDirection = SYNCML_DM_CLIENT_INITIATED_SESSION;
+#ifdef LOB_SUPPORT
+ m_pChunkData = NULL;
+ LargeObjectClear();
+#endif
+}
+
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::~SYNCML_DM_BuildPackage
+
+DESCRIPTION : The SYNCML_DM_BuildPackage class destructor.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_BuildPackage::~SYNCML_DM_BuildPackage()
+{
+ Cleanup();
+#ifdef LOB_SUPPORT
+ LargeObjectClear();
+#endif
+}
+
+void SYNCML_DM_BuildPackage::Cleanup()
+{
+ smlFreeSyncHdr(pSyncHdr);
+
+ pMessageIdOfServer = NULL;
+ pSyncHdr = NULL;
+
+}
+
+void SYNCML_DM_BuildPackage::Init(DMProcessScriptSession * pSession)
+{
+ pMessageIdOfServer = NULL;
+ commandId = 1;
+ MaxMessageSize = g_iDMWorkspaceSize; //DM_MAX_MSG_SIZE;
+ pSyncHdr = NULL;
+
+ /* We need the MgmtSessionObj pointer and current sendInstanceId.*/
+ pDmMgmtSessionObj = pSession;
+ sendInstanceId = pSession->GetSendInstanceId();
+
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::operator new
+
+DESCRIPTION : Operators to allocate memory for operation.
+ARGUMENT PASSED : sz
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+void * SYNCML_DM_BuildPackage::operator new(size_t sz)
+{
+ return (DmAllocMem(sz));
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::operator delete
+
+DESCRIPTION : Operators to delete memory for operation.
+ARGUMENT PASSED : buf
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+void SYNCML_DM_BuildPackage::operator delete(void *buf)
+{
+ DmFreeMem(buf);
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::GetMaxMessageSize
+
+DESCRIPTION : This function returns the value of MaxMessageSize.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : MaxMessageSize
+IMPORTANT NOTES :
+==================================================================================================*/
+UINT32
+SYNCML_DM_BuildPackage::GetMaxMessageSize() const
+{
+ return (MaxMessageSize);
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::GetMaxObjectSize
+
+DESCRIPTION : This function returns the value of MaxObjectSize.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : MaxMessageSize
+IMPORTANT NOTES :
+==================================================================================================*/
+UINT32
+SYNCML_DM_BuildPackage::GetMaxObjectSize() const
+{
+ return (MaxObjectSize);
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::SetMaxMessageSize
+
+DESCRIPTION : This function sets the value of MaxMessageSize.
+ARGUMENT PASSED : passedin_MaxMsgSize
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+void
+SYNCML_DM_BuildPackage::SetMaxMessageSize(UINT32 passedin_MaxMsgSize)
+{
+ MaxMessageSize = passedin_MaxMsgSize;
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::SetMaxObjectSize
+
+DESCRIPTION : This function sets the value of MaxObjectSize.
+ARGUMENT PASSED : passedin_MaxObjSize
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+void
+SYNCML_DM_BuildPackage::SetMaxObjectSize(UINT32 passedin_MaxObjSize)
+{
+ MaxObjectSize = passedin_MaxObjSize;
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::FreeGetStructData
+
+DESCRIPTION : This method will free the memeroy for the struct SYNCML_DM_GET_STRUCT_RET_DATA_T.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+void
+SYNCML_DM_BuildPackage:: FreeGetStructData(SYNCML_DM_GET_ON_LIST_RET_DATA_T& p_GetStructData)
+{
+ if (p_GetStructData.psRetData != NULL)
+ {
+ delete p_GetStructData.psRetData;
+ p_GetStructData.psRetData = NULL;
+ }
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildPcData
+
+DESCRIPTION : This method will build up the PC data structure.
+ARGUMENT PASSED : content_type
+ extension
+ p_Content
+OUTPUT PARAMETER: p_PcData
+RETURN VALUE :
+IMPORTANT NOTES : The calling function will not check the return value, since when memory allocation
+ fails, the phone will panic.
+==================================================================================================*/
+void
+SYNCML_DM_BuildPackage::BuildPcData (SmlPcdataPtr_t p_PcData,
+ SmlPcdataType_t content_type,
+ SmlPcdataExtension_t extension,
+ UINT32 dataSize,
+ UINT8 *p_Content)
+{
+ BOOLEAN bEscapeChar = FALSE;
+#ifdef __SML_XML__
+ CPCHAR dm_escape_env = XPL_DM_GetEnv(SYNCML_DM_ESCAPE_CHAR);
+#endif
+
+ p_PcData->contentType = content_type;
+ p_PcData->extension = extension;
+ p_PcData->length = dataSize;
+
+ if (p_PcData->content != NULL) {
+ DmFreeMem(p_PcData->content);
+ }
+
+#ifdef __SML_XML__
+ if (dm_escape_env && content_type == SML_PCDATA_STRING )
+ {
+ INT32 nLen = dataSize;
+
+ while ( nLen > 0 )
+ {
+ nLen--;
+
+ if ( p_Content[nLen] == '&' || p_Content[nLen] == '<' ||
+ p_Content[nLen] == '>' || p_Content[nLen] == '\\' ||
+ p_Content[nLen] == '"' )
+ {
+
+ UINT32 i=0;
+ for (i = 0; escape_char_table[i].escape_str != NULL; i++)
+ if ( escape_char_table[i].token == p_Content[nLen])
+ {
+ dataSize += smlLibStrlen( escape_char_table[i].escape_str);
+ bEscapeChar = FALSE;
+ break;
+ }
+ }
+ }
+ }
+#endif
+
+
+ p_PcData->content = (UINT8 *)DmAllocMem(dataSize+1);
+ if ( p_PcData->content == NULL )
+ return;
+
+ memset(p_PcData->content, 0, dataSize+1);
+
+ if(bEscapeChar == FALSE)
+ {
+ memcpy(p_PcData->content, p_Content, dataSize);
+
+ if ( content_type == SML_PCDATA_STRING && !dm_escape_env)
+ {
+ BOOLEAN bSendAsPCDATA = FALSE;
+ INT32 nLen = dataSize;
+
+ while ( nLen > 0 )
+ {
+ nLen--;
+
+ if ( p_Content[nLen] == '&' || p_Content[nLen] == '<' ||
+ p_Content[nLen] == '>' || p_Content[nLen] == '\\' ||
+ p_Content[nLen] == '"')
+ {
+ bSendAsPCDATA = TRUE;
+ break;
+ }
+ }
+
+ if ( bSendAsPCDATA )
+ p_PcData->contentType = SML_PCDATA_CDATA;
+ }
+ }
+#ifdef __SML_XML__
+ else
+ {
+ MemPtr_t buffer =(MemPtr_t) p_PcData->content;
+ for(INT32 nLen = 0; nLen < p_PcData->length; nLen++)
+ {
+ if ( p_Content[nLen] == '&' || p_Content[nLen] == '<' ||
+ p_Content[nLen] == '>' || p_Content[nLen] == '\\' ||
+ p_Content[nLen] == '"' )
+ {
+
+ *buffer++ = '&' ;
+ UINT32 i = 0;
+ for (i = 0; escape_char_table[i].escape_str != NULL; i++)
+ {
+ if ( escape_char_table[i].token == p_Content[nLen])
+ {
+ INT32 str_len = smlLibStrlen( escape_char_table[i].escape_str);
+ memcpy(buffer, (MemPtr_t)escape_char_table[i].escape_str, str_len);
+ buffer += str_len;
+ break;
+ }
+ }
+ }
+ else
+ *buffer++=p_Content[nLen];
+ }
+ p_PcData->length = dataSize;
+ }
+#endif
+
+
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildPcDataWAllocMem
+
+DESCRIPTION : This method will allocate the memory for PC data structure and call BuildPcData
+ to build up the PC data structure.
+ARGUMENT PASSED :
+ p_Content
+OUTPUT PARAMETER: p_PcData
+RETURN VALUE :
+IMPORTANT NOTES : The calling function will not check the return value, since when memory allocation
+ fails, the phone will panic.
+==================================================================================================*/
+void
+SYNCML_DM_BuildPackage::BuildPcDataWAllocMem (SmlPcdataPtr_t *pp_PcData,
+ UINT32 dataSize,
+ UINT8 *p_Data)
+{
+ SmlPcdataPtr_t p_temp_pc_data;
+
+ if (*pp_PcData != NULL) {
+ smlFreePcdata(*pp_PcData);
+ }
+
+ p_temp_pc_data = smlAllocPcdata();
+ if ( p_temp_pc_data != NULL)
+ {
+ BuildPcData(p_temp_pc_data, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED, dataSize, p_Data);
+
+ }
+ *pp_PcData = p_temp_pc_data;
+ p_temp_pc_data = NULL;
+}
+
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildMetaInfo
+
+DESCRIPTION : This method will build up the meta data structure.
+ARGUMENT PASSED : p_Format
+ p_Type
+ p_Size
+ p_NextNonce
+ p_Version
+ p_Maxmsgsize
+ p_Maxobjsize
+OUTPUT PARAMETER: p_PcData
+RETURN VALUE :
+IMPORTANT NOTES : The calling function will not check the return value, since when memory allocation
+ fails, the phone will panic.
+==================================================================================================*/
+void
+SYNCML_DM_BuildPackage::BuildMetaInfo (SmlPcdataPtr_t p_PcData,
+ UINT8 *p_Format, UINT8 *p_Type,
+ UINT8 *p_Mark, UINT8 *p_Size,
+ UINT8 *p_NextNonce, UINT8 *p_Version,
+ UINT8 *p_Maxmsgsize, UINT8 *p_Maxobjsize)
+{
+ SmlMetInfMetInfPtr_t p_meta_info;
+ UINT32 data_length = 0;
+ UINT32 data_size;
+
+ p_meta_info = smlAllocMetInfMetInf();
+
+ if ( p_meta_info != NULL)
+ {
+ if (p_Format != NULL)
+ {
+ data_size = DmStrlen((const char*)p_Format);
+ BuildPcDataWAllocMem (&p_meta_info->format, data_size, p_Format);
+ data_length += data_size;
+ }
+
+ if (p_Type != NULL)
+ {
+ data_size = DmStrlen((const char*)p_Type);
+ BuildPcDataWAllocMem (&p_meta_info->type, data_size, p_Type);
+ data_length += data_size;
+ }
+
+ if (p_Mark != NULL)
+ {
+ data_size = DmStrlen((const char*)p_Mark);
+ BuildPcDataWAllocMem (&p_meta_info->mark, data_size, p_Mark);
+ data_length += data_size;
+ }
+
+ if (p_Size != NULL)
+ {
+ data_size = DmStrlen((const char*)p_Size);
+ BuildPcDataWAllocMem(&p_meta_info->size, data_size, p_Size);
+ data_length += data_size;
+ }
+
+ if (p_NextNonce != NULL)
+ {
+ data_size = DmStrlen((const char*)p_NextNonce);
+ BuildPcDataWAllocMem(&p_meta_info->nextnonce, data_size, p_NextNonce);
+ data_length += data_size;
+ }
+
+ if (p_Version != NULL)
+ {
+ data_size = DmStrlen((const char*)p_Version);
+ BuildPcDataWAllocMem(&p_meta_info->version, data_size, p_Version);
+ data_length += data_size;
+ }
+
+ if (p_Maxmsgsize != NULL)
+ {
+ data_size = DmStrlen((const char*)p_Maxmsgsize);
+ BuildPcDataWAllocMem(&p_meta_info->maxmsgsize, data_size, p_Maxmsgsize);
+ data_length += data_size;
+ }
+
+ if (p_Maxobjsize != NULL)
+ {
+ data_size = DmStrlen((const char*)p_Maxobjsize);
+ BuildPcDataWAllocMem(&p_meta_info->maxobjsize, data_size, p_Maxobjsize);
+ data_length += data_size;
+ }
+
+ /* These elements are not used now. */
+ p_meta_info->mem = NULL;
+ p_meta_info->emi = NULL;
+ p_meta_info->anchor = NULL;
+ }
+
+ p_PcData->contentType = SML_PCDATA_EXTENSION;
+ p_PcData->extension = SML_EXT_METINF;
+ p_PcData->length = sizeof(p_meta_info) + data_length;
+
+ p_PcData->content = p_meta_info;
+}
+
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildMetaSizeInfo
+
+DESCRIPTION : This method will build up the meta size data structure.
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildMetaSizeInfo(SmlPcdataPtr_t p_PcData, int datasize)
+{
+ SmlMetInfMetInfPtr_t p_meta_info;
+ UINT32 data_length = 0;
+ if(p_PcData->content != NULL)
+ { p_meta_info = (SmlMetInfMetInfPtr_t)p_PcData->content;
+ data_length = p_PcData->length;
+ }
+ else
+ {
+ p_meta_info = smlAllocMetInfMetInf();
+ if(p_meta_info == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ data_length = sizeof(p_meta_info);
+ p_PcData->contentType = SML_PCDATA_EXTENSION;
+ p_PcData->extension = SML_EXT_METINF;
+ }
+ // <Size> information already built
+ if( p_meta_info->size!= NULL && p_meta_info->size->content != NULL)
+ return SYNCML_DM_SUCCESS;
+
+ UINT32 data_size;
+ UINT8 data_size_str[UINT32_TYPE_STR_SIZE_10];
+
+ DmSprintf((char *)data_size_str, "%d", datasize);
+
+ data_size = DmStrlen((const char*)data_size_str);
+ BuildPcDataWAllocMem(&p_meta_info->size, data_size, data_size_str);
+ data_length += data_size;
+
+ p_PcData->length = data_length;
+
+ p_PcData->content = p_meta_info;
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildStartSyncHdr
+
+DESCRIPTION : This function will be called by BuildPackageOne and HandleStartMessage to build up
+ the SyncML package header.
+
+ The function composes the SyncML header data.
+ARGUMENT PASSED : p_Content
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL if memory allocation failed.
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildStartSyncHdr (SmlSyncHdrPtr_t p_Content, BOOLEAN isPackageOne)
+{
+ UINT8 message_id_str[UINT16_TYPE_STR_SIZE_5];
+
+ pSyncHdr = smlAllocSyncHdr();
+
+ if (pSyncHdr == NULL)
+ return SYNCML_DM_FAIL;
+
+ /* Convert message id of the server */
+ if (p_Content->msgID->length == 0)
+ pMessageIdOfServer = DEFAULT_MESSAGE_ID;
+ else
+ {
+ /* Allocate the memory for pMessageIdOfServer, copy over the data. */
+ pMessageIdOfServer.assign((const char *)p_Content->msgID->content,
+ p_Content->msgID->length);
+ }
+
+
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ /* Build the <VerDTD> element */
+ BuildPcData(pSyncHdr->version, SML_PCDATA_STRING,SML_EXT_UNDEFINED,
+ DmStrlen((char *)SYNCML_REP_PROTOCOL_VERSION_1_2),
+ (UINT8 *)SYNCML_REP_PROTOCOL_VERSION_1_2);
+
+ /* Build the <VerProto> elelemnt */
+ BuildPcData(pSyncHdr->proto, SML_PCDATA_STRING, SML_EXT_UNDEFINED,
+ DmStrlen((char *)SYNCML_DM_PROTOCOL_VERSION_1_2),
+ (UINT8 *)SYNCML_DM_PROTOCOL_VERSION_1_2);
+ }
+ else
+ {
+ /* Build the <VerDTD> element */
+ BuildPcData(pSyncHdr->version, SML_PCDATA_STRING,SML_EXT_UNDEFINED,
+ DmStrlen((char *)SYNCML_REP_PROTOCOL_VERSION_1_1),
+ (UINT8 *)SYNCML_REP_PROTOCOL_VERSION_1_1);
+
+ /* Build the <VerProto> elelemnt */
+ BuildPcData(pSyncHdr->proto, SML_PCDATA_STRING, SML_EXT_UNDEFINED,
+ DmStrlen((char *)SYNCML_DM_PROTOCOL_VERSION_1_1),
+ (UINT8 *)SYNCML_DM_PROTOCOL_VERSION_1_1);
+
+ }
+
+ /* Build the <SessionId> element */
+ BuildPcData(pSyncHdr->sessionID, SML_PCDATA_STRING, SML_EXT_UNDEFINED,
+ p_Content->sessionID->length,
+ (UINT8 *)p_Content->sessionID->content);
+
+ /* Keep the sessionID information in the MgmtSessionObj's serverSessionId when building
+ package one */
+ if ( isPackageOne )
+ {
+ /* The message ID has to be set as "1" for the package one, this is required by the
+ * SyncML DM spec. */
+ messageId = 1;
+
+ }
+
+ /* Build the <MsgId> element */
+ DmSprintf((char *)message_id_str, "%d", messageId++);
+ BuildPcData(pSyncHdr->msgID, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)message_id_str),
+ message_id_str);
+
+ /* Need to swap the <target> and the <source> element when constructing the DM document.
+ The server SOURCE element from the receiving package will be client TARGET when sending back.
+ The server TARGET element from the receiving package will be client SOURCE. */
+ /* build the <target> element */
+
+ /* build the <target> element, Need to use the response URI if it exists */
+ DMString strSourceUri;
+ if((p_Content->source != NULL) && (p_Content->source->locURI != NULL) &&(p_Content->source->locURI->content !=NULL))
+ { strSourceUri = DMString((const char *)p_Content->source->locURI->content, (int)p_Content->source->locURI->length);
+ if(strSourceUri.Encode() == FALSE)
+ return SYNCML_DM_FAIL;
+ }
+
+ if (p_Content->respURI != NULL)
+ {
+ BuildPcData(pSyncHdr->target->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ p_Content->respURI->length,
+ (UINT8 *)p_Content->respURI->content);
+ }
+ else
+ {
+ BuildPcData(pSyncHdr->target->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ strSourceUri.length(),
+ (UINT8 *)strSourceUri.c_str());
+ }
+ if ((p_Content->source !=NULL) && (p_Content->source->locName != NULL))
+ {
+ if (p_Content->source->locName->content != NULL)
+ {
+ BuildPcDataWAllocMem(&pSyncHdr->target->locName,
+ p_Content->source->locName->length,
+ (UINT8 *)p_Content->source->locName->content);
+ }
+ else
+ {
+ pSyncHdr->target->locName = NULL;
+ }
+ }
+
+ /* Build the <source> element */
+ DMString strTargetUri;
+ if((p_Content->target != NULL) && (p_Content->target->locURI != NULL) && (p_Content->target->locURI->content != NULL))
+ {
+ strTargetUri = DMString((CPCHAR)p_Content->target->locURI->content, (INT32)p_Content->target->locURI->length);
+ if(strTargetUri.Encode() == FALSE)
+ return SYNCML_DM_FAIL;
+ }
+ BuildPcData(pSyncHdr->source->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ strTargetUri.length(),
+ (UINT8 *)strTargetUri.c_str());
+
+ if((p_Content->target != NULL) && (p_Content->target->locName != NULL))
+ {
+ if (p_Content->target->locName->content != NULL)
+ {
+ BuildPcDataWAllocMem(&pSyncHdr->source->locName,
+ p_Content->target->locName->length,
+ (UINT8 *)p_Content->target->locName->content);
+ }
+ else
+ {
+ pSyncHdr->source->locName = NULL;
+ }
+ }
+
+ /* Don't free the pSyncHdr memory until the BuildFinishSyncHdr() is called.*/
+ return SYNCML_DM_SUCCESS;
+}
+
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildFinishSyncHdr
+
+DESCRIPTION : This function will be called by BuildPackageOne and HandleStartMessage to
+ build up the SyncML package header.
+
+ The function finishes composing the SyncML header data, and calls the SyncML
+ toolkit smlStartMessageExt() to build the SyncHdr.
+ARGUMENT PASSED : serverChalType
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildFinishSyncHdr (SYNCML_DM_CHAL_TYPE_T serverChalType)
+{
+ UINT8 max_msg_size_str[UINT32_TYPE_STR_SIZE_10];
+ UINT8 *p_CredFormat = NULL;
+ UINT8 *p_CredType = NULL;
+ UINT8 *p_CredData = NULL;
+ Ret_t sml_ret_stat;
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ SYNCMLDM_MD5_SEC_INFO_T md5SecInfo;
+ SYNCMLDM_BASIC_SEC_INFO_T basicSecInfo;
+ DMClientServerCreds *pClientServerCreds;
+ SYNCMLDM_SEC_CREDENTIALS_T *pGenCred = NULL;
+ UINT8 decodedNonce[MAX_BIN_NONCE_LEN];
+ UINT32 encodedNonceLen;
+ UINT32 decodedNonceLen;
+ MemSize_t freeSpace;
+
+
+ pClientServerCreds = pDmMgmtSessionObj->GetClientServerCreds();
+
+ // change the auth method from server.
+ pClientServerCreds->SetPrefClientAuth(serverChalType);
+
+ /* The HMAC Credentials are always sent. So we do not need to do anything extra if challenged
+ * for HMAC.*/
+ if ((serverChalType != SYNCML_DM_CHAL_NONE) && (serverChalType != SYNCML_DM_CHAL_HMAC))
+ {
+
+ if (serverChalType == SYNCML_DM_CHAL_MD5)
+ {
+ /* The ClientNonce string is b64 encoded and must be decoded now.*/
+ encodedNonceLen = DmStrlen((const char *)pClientServerCreds->pClientNonce);
+ decodedNonceLen = base64Decode((unsigned char *)decodedNonce,
+ MAX_BIN_NONCE_LEN,
+ (unsigned char*)pClientServerCreds->pClientNonce.c_str(),
+ (unsigned long*)&encodedNonceLen);
+
+ /* We need to build up our MD5 credentials.*/
+ md5SecInfo.pb_user_name_or_server_id = (UINT8*)pClientServerCreds->pClientUserName.c_str();
+ md5SecInfo.pb_password = (UINT8*)pClientServerCreds->pClientPW.c_str();
+ md5SecInfo.pb_nonce = decodedNonce;
+ md5SecInfo.o_encode_base64 = TRUE;
+ md5SecInfo.w_nonce_length = decodedNonceLen;
+
+ pGenCred = syncmldm_sec_build_md5_cred(&md5SecInfo);
+
+ p_CredFormat = (UINT8 *)SYNCML_B64;
+ p_CredType = (UINT8 *)SYNCML_AUTH_MD5;
+ }
+ else /* SYNCML_DM_CHAL_BASIC */
+ {
+ /* We need to build up our Basic credentials.*/
+ basicSecInfo.pb_user_name_or_server_id = (UINT8*)pClientServerCreds->pClientUserName.c_str();
+ basicSecInfo.pb_password = (UINT8*)pClientServerCreds->pClientPW.c_str();
+
+ pGenCred = syncmldm_sec_build_basic_cred(&basicSecInfo);
+
+ p_CredFormat = (UINT8 *)SYNCML_B64;
+ p_CredType = (UINT8 *)SYNCML_AUTH_BASIC;
+ }
+
+ if (pGenCred == NULL)
+ {
+ /* Something went wrong in the Security Library.*/
+ p_CredData = NULL;
+ p_CredFormat = NULL;
+ p_CredType = NULL;
+ }
+ else
+ {
+ /* Copy over the new credential string and add the NULL char.*/
+ p_CredData = (UINT8 *)DmAllocMem(pGenCred->w_credential_string_length + 1);
+ if ( p_CredData == NULL )
+ {
+ DmFreeMem(pGenCred);
+ return SYNCML_DM_FAIL;
+ }
+
+ memcpy(p_CredData, pGenCred->ab_credential_string,
+ pGenCred->w_credential_string_length);
+ p_CredData[pGenCred->w_credential_string_length] = '\0';
+ DmFreeMem(pGenCred);
+
+ /* Build the <Cred> element */
+ if( pSyncHdr != NULL) {
+ pSyncHdr->cred = smlAllocCred();
+ if (pSyncHdr->cred != NULL)
+ {
+ pSyncHdr->cred->meta = smlAllocPcdata();
+
+ /* Build the MetaInfo and the PcData sections.*/
+ if (pSyncHdr->cred->meta != NULL)
+ BuildMetaInfo(pSyncHdr->cred->meta, p_CredFormat, p_CredType,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+
+ BuildPcData(pSyncHdr->cred->data, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)p_CredData),
+ p_CredData);
+ }
+ }
+ DmFreeMem(p_CredData);
+ }
+ } /* If Challenged */
+
+ /* For package one header, fill in the maximum message size which client can support to the
+ pSyncHdr->meta */
+ {
+ if( pSyncHdr != NULL) {
+ pSyncHdr->meta = smlAllocPcdata();
+
+ /* Convert MaxmessageSize to a string */
+ DmSprintf((char *)max_msg_size_str, "%d", MaxMessageSize);
+
+ /* Call BuildMetaInfo to set MaxMsgSize element */
+ if (pSyncHdr->meta != NULL)
+ BuildMetaInfo(pSyncHdr->meta,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ max_msg_size_str,
+ NULL);
+ }
+ }
+
+ /* Start a new message, toolkit will build up the DM package SyncHdr part */
+ if( pSyncHdr != NULL) {
+ if ( dmTreeObj.IsVersion_12() )
+ sml_ret_stat = smlStartMessageExt(sendInstanceId, pSyncHdr, SML_VERS_1_2);
+ else
+ sml_ret_stat = smlStartMessageExt(sendInstanceId, pSyncHdr, SML_VERS_1_1);
+ if (sml_ret_stat != SML_ERR_OK)
+ {
+ ret_stat = SYNCML_DM_FAIL;
+ }
+ }
+ freeSpace = smlGetFreeBuffer(sendInstanceId);
+
+ /* Free the memory. smlFreeSyncHdr will free every element in SmlSyncHdrPtr_t structure,
+ including ones we allocated. */
+ if( pSyncHdr != NULL)
+ smlFreeSyncHdr(pSyncHdr);
+ pSyncHdr = NULL;
+
+ return (ret_stat);
+}
+
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildAlertCommand
+
+DESCRIPTION : This method calls the SyncML Toolkit functions to build up the SyncML package
+ ALERT command as part of the SyncBody.
+ARGUMENT PASSED : session_Direction
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL if memory allocation failed.
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildAlert1226Command ()
+{
+ SmlAlertPtr_t p_alert;
+ UINT8 command_id_str[UINT16_TYPE_STR_SIZE_5];
+ if(firmAlertVec.size() < 1)
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+ DMFirmAlertVector * pFirmAlerts = &firmAlertVec;
+ char * alertStr = "1226";
+
+ for (INT32 i=0; i<pFirmAlerts->size(); i++)
+ {
+ p_alert = smlAllocAlert();
+
+ if ( p_alert == NULL )
+ return (SYNCML_DM_FAIL);
+
+ /* Convert the commandId to a string */
+ DmSprintf((char *)command_id_str, "%d", commandId++);
+ BuildPcData(p_alert->cmdID, SML_PCDATA_STRING,SML_EXT_UNDEFINED,
+ DmStrlen((char *)command_id_str),command_id_str);
+
+ /* Credentials are not sent in the Alert.*/
+ p_alert->cred = NULL;
+
+ BuildPcDataWAllocMem (&p_alert->data,4,(UINT8*)alertStr);
+ if ( p_alert->data == NULL )
+ {
+ smlFreeAlert(p_alert);
+ return (SYNCML_DM_FAIL);
+ }
+
+ SmlItemPtr_t p_item = p_alert->itemList->item;
+ const DmtFirmAlert& alert = (*pFirmAlerts)[i];
+ DMString uri = alert.getPackageURI();
+
+ if(uri.Encode() == FALSE)
+ {
+ smlFreeAlert(p_alert);
+ return (SYNCML_DM_FAIL);
+ }
+
+ if ( !alert.getCorrelator().empty() )
+ {
+ p_alert->correlator = smlAllocPcdata();
+ if ( !p_alert->correlator )
+ {
+ smlFreeAlert(p_alert);
+ return (SYNCML_DM_FAIL);
+ }
+
+ BuildPcData(p_alert->correlator, SML_PCDATA_STRING,SML_EXT_UNDEFINED,
+ alert.getCorrelator().length(), (UINT8*)alert.getCorrelator().c_str() );
+ }
+
+ /* Dont build the LocURI if its length is zero */
+ if( uri.length() != 0 )
+ {
+ p_item->source = smlAllocSource();
+ if ( p_item->source == NULL )
+ {
+ smlFreeAlert(p_alert);
+ return (SYNCML_DM_FAIL);
+ }
+ BuildPcData(p_item->source->locURI,SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,uri.length(),(UINT8*)uri.c_str());
+ }
+
+ UINT8* pType = alert.getAlertType().empty() ? NULL : (UINT8*)alert.getAlertType().c_str();
+ UINT8* pFormat = alert.getAlertFormat().empty() ? NULL : (UINT8*)alert.getAlertFormat().c_str();
+ UINT8* pMark = alert.getAlertMark().empty() ? NULL : (UINT8*)alert.getAlertMark().c_str();
+
+ if ( pType || pFormat || pMark )
+ {
+ if ((p_item->meta = smlAllocPcdata()) != NULL)
+ BuildMetaInfo(p_item->meta, pFormat, pType, pMark,NULL,NULL,NULL,NULL, NULL);
+ }
+
+ BuildPcDataWAllocMem (&p_item->data,
+ alert.getResultData().length(),
+ (UINT8*)alert.getResultData().c_str() );
+
+ if ( p_item->data == NULL )
+ {
+ smlFreeAlert(p_alert);
+ return (SYNCML_DM_FAIL);
+ }
+
+
+ /* Call the toolkit to build ALERT command to the DM package body. */
+ smlAlertCmd(sendInstanceId, p_alert);
+
+ /* Free the memory. smlFreeAlert will free every element in SmlAlertPtr_t structure,
+ including ones we allocated. */
+ smlFreeAlert(p_alert);
+ p_alert = NULL;
+
+ }
+
+ return (SYNCML_DM_SUCCESS);
+}
+
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildAlertCommand
+
+DESCRIPTION : This method calls the SyncML Toolkit functions to build up the SyncML package
+ ALERT command as part of the SyncBody.
+ARGUMENT PASSED : session_Direction
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL if memory allocation failed.
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildAlertCommand (UINT16 alertCode, CPCHAR pSource, CPCHAR pTarget)
+{
+ SmlAlertPtr_t p_alert;
+ UINT8 command_id_str[UINT16_TYPE_STR_SIZE_5];
+ UINT8 alert_str[UINT16_TYPE_STR_SIZE_5];
+ SmlItemPtr_t p_alert_item;
+
+ if ( (p_alert = smlAllocAlert() ) == NULL)
+ return SYNCML_DM_FAIL;
+
+ /* Convert the commandId to a string */
+ DmSprintf((char *)command_id_str, "%d", commandId++);
+ BuildPcData(p_alert->cmdID, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)command_id_str),
+ command_id_str);
+
+ /* Credentials are not sent in the Alert.*/
+ p_alert->cred = NULL;
+
+ if ( (p_alert->data = smlAllocPcdata()) != NULL)
+ {
+ /* We need to indicate whether the alert type is SERVER_INITIATED_SESSION or
+ * CLIENT_INITIATED_SESSION */
+ DmSprintf((char *)alert_str, "%d", alertCode);
+ BuildPcData(p_alert->data, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)alert_str),
+ alert_str);
+ }
+
+ /* Free p_alert->itemList, set it as NULL since we don't have data for it. Otherwise, empty
+ <ITEM/> will be generated for SyncHdr. */
+ if(pSource == NULL && pTarget== NULL)
+ { smlFreeItemList(p_alert->itemList);
+ p_alert->itemList = NULL;
+ }
+ else
+ {
+ p_alert_item = p_alert->itemList->item;
+
+ // Source
+ if(pSource != NULL)
+ { p_alert_item->source = smlAllocSource();
+ if (p_alert_item->source == NULL )
+ {
+ smlFreeAlert(p_alert);
+ return (SYNCML_DM_FAIL);
+ }
+ DMString strSourceUri(pSource);
+
+ if(strSourceUri.Encode() == FALSE)
+ {
+ smlFreeAlert(p_alert);
+ return (SYNCML_DM_INVALID_URI);
+ }
+
+ BuildPcData(p_alert_item->source->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ strSourceUri.length(),
+ (UINT8 *) strSourceUri.c_str());
+ }
+
+ // Target
+ if(pTarget != NULL)
+ { p_alert_item->target = smlAllocSource();
+ if (p_alert_item->target == NULL )
+ {
+ smlFreeAlert(p_alert);
+ return (SYNCML_DM_FAIL);
+ }
+ DMString strTargetUri(pTarget);
+
+ if(strTargetUri.Encode() == FALSE)
+ {
+ smlFreeAlert(p_alert);
+ return (SYNCML_DM_INVALID_URI);
+ }
+
+ BuildPcData(p_alert_item->target->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ strTargetUri.length(),
+ (UINT8 *) strTargetUri.c_str());
+ }
+ }
+
+ /* Call the toolkit to build ALERT command to the DM package body. */
+ smlAlertCmd(sendInstanceId, p_alert);
+
+ /* Free the memory. smlFreeAlert will free every element in SmlAlertPtr_t structure,
+ including ones we allocated. */
+ smlFreeAlert(p_alert);
+
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildReplaceCommand
+
+DESCRIPTION : This method calls the SyncML Toolkit functions to build up the SyncML package
+ REPLACE command as part of the SyncBody of DM package one. It will query the DM
+ tree to get all DevInfo data to place in the REPLACE command.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL if memory allocation failed.
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildReplaceCommand ()
+{
+ UINT8 command_id_str[UINT16_TYPE_STR_SIZE_5];
+ SmlReplacePtr_t p_replace;
+ SmlItemPtr_t p_replace_item;
+ SmlItemListPtr_t p_replace_item_list;
+ DMGetData devInfoData;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ SYNCML_DM_URI_RESULT_T dm_uri_result;
+ BOOLEAN first_item_on_list = TRUE;
+
+ SYNCML_DM_GET_ON_LIST_RET_DATA_T p_get_struct_data;
+
+ if ( (p_replace = (SmlReplacePtr_t)smlAllocReplace()) == NULL)
+ return (SYNCML_DM_FAIL);
+
+ /* Convert the commandId to a string */
+ DmSprintf((char *)command_id_str, "%d", commandId++);
+ BuildPcData(p_replace->cmdID, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)command_id_str),
+ (UINT8 *)command_id_str);
+
+ p_replace_item = p_replace->itemList->item;
+ p_replace_item_list = p_replace->itemList;
+
+
+ /* Call DMTNM to get all children nodes of devinfo from DM tree */
+ dm_stat = dmTreeObj.InitListAndGetListFirstItem( DM_DEV_INFO_URI_PAK1,
+ SYNCML_DM_GET_ON_LIST_STRUCT,
+ p_get_struct_data);
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ smlFreeGeneric(p_replace);
+ FreeGetStructData(p_get_struct_data);
+ return (SYNCML_DM_FAIL);
+ }
+
+ /* Loop through all data from Get Struct */
+ while (p_get_struct_data.psRetData != NULL)
+ {
+ /* If it is an interior node, we don't send it in the package one. */
+ if (p_get_struct_data.psRetData->m_nFormat != SYNCML_DM_FORMAT_NODE)
+ {
+ if (first_item_on_list != TRUE)
+ {
+ /* It is the first item, allocate the memory for the next replace item. */
+ p_replace_item_list->next = smlAllocItemList();
+ if (p_replace_item_list->next != NULL)
+ {
+ p_replace_item_list = p_replace_item_list->next;
+ p_replace_item = p_replace_item_list->item;
+ }
+ }
+ else
+ {
+ /* This is the first item. Set the flag to False for the next time around.*/
+ first_item_on_list = FALSE;
+ }
+
+ /* Allocate the memory for p_replace_item->source */
+ p_replace_item->source = smlAllocSource();
+
+ if ( p_replace_item->source == NULL )
+ {
+ smlFreeGeneric(p_replace);
+ FreeGetStructData(p_get_struct_data);
+ return (SYNCML_DM_FAIL);
+ }
+
+ DMString strGetetUri( p_get_struct_data._pbURI );
+
+ if(strGetetUri.Encode() == FALSE)
+ {
+ smlFreeGeneric(p_replace);
+ FreeGetStructData(p_get_struct_data);
+ return (SYNCML_DM_INVALID_URI);
+ }
+
+ BuildPcData(p_replace_item->source->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ strGetetUri.length(),
+ (UINT8 *) strGetetUri.c_str());
+
+ /* Validate the URI */
+ dm_uri_result = dmTreeObj.URIValidateAndParse( p_get_struct_data._pbURI);
+ if ((dm_uri_result == SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY) ||
+ (dm_uri_result == SYNCML_DM_COMMAND_INVALID_URI) ||
+ (dm_uri_result == SYNCML_DM_COMMAND_URI_TOO_LONG) ||
+ (dm_uri_result == SYNCML_DM_COMMAND_LIST_STRUCT))
+ {
+ smlFreeGeneric(p_replace);
+ FreeGetStructData(p_get_struct_data);
+ return (SYNCML_DM_INVALID_URI);
+ }
+
+ /* Get data for each node of devinfo */
+ dm_stat = dmTreeObj.Get(p_get_struct_data._pbURI, devInfoData,SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ FreeGetStructData(p_get_struct_data);
+
+ /* Check if there is data on this node.*/
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ smlFreeGeneric(p_replace);
+ return (SYNCML_DM_FAIL);
+ }
+
+ p_replace_item->data = smlAllocPcdata();
+ if (p_replace_item->data != NULL)
+ BuildPcData(p_replace_item->data, SML_PCDATA_STRING, SML_EXT_UNDEFINED,
+ devInfoData.m_oData.getSize(),
+ devInfoData.m_oData.getBuffer());
+
+ /* Replace doesn't have any meta.*/
+ p_replace_item->meta = NULL;
+
+ }
+
+ else /* bDataFormat == SYNCML_DM_FORMAT_NODE */
+ {
+ /* We need to free the memory for the interior node.*/
+ FreeGetStructData(p_get_struct_data);
+ }
+
+ /* Move to the next item. */
+ dm_stat = dmTreeObj.GetListNextItem(p_get_struct_data);
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ smlFreeGeneric(p_replace);
+ FreeGetStructData(p_get_struct_data);
+ return (SYNCML_DM_FAIL);
+ }
+ }
+
+ /* All replace command data are set, call toolkit to build REPLACE into the DM package body. */
+ smlReplaceCmd(sendInstanceId, p_replace);
+
+ /* Free the memory. smlFreeGeneric will free every element of SmlReplacePtr_t structure. */
+ smlFreeGeneric(p_replace);
+
+ return (SYNCML_DM_SUCCESS);
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::AllocateStatus
+
+DESCRIPTION : This function calls the SyncML Toolkit functions to build up the STATUS command
+ARGUMENT PASSED : p_CmdRefData
+ p_CmdName
+ p_TargetRefData
+ p_SourceRefData
+ pCientChal
+ status_Code
+OUTPUT PARAMETER:
+RETURN VALUE : newly constructed status
+IMPORTANT NOTES :
+==================================================================================================*/
+SmlStatusPtr_t SYNCML_DM_BuildPackage::AllocateStatus(
+ UINT8 *p_CmdRefData, /* Receiving DM package command Id */
+ UINT8 *p_CmdName,
+ UINT8 *p_SourceRefData,
+ UINT8 *p_TargetRefData,
+ DM_CHALLENGE_T *pClientChal,
+ SYNCML_DM_RET_STATUS_T status_Code,
+ const DMStringVector* responses )
+{
+ UINT8 status_code_str[UINT16_TYPE_STR_SIZE_5];
+ SmlStatusPtr_t p_status = smlAllocStatus();
+
+ if ( !p_status )
+ return NULL;
+
+ BuildPcData(p_status->msgRef, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen(pMessageIdOfServer),
+ (UINT8*)pMessageIdOfServer.c_str());
+
+ if (p_CmdRefData != NULL)
+ {
+ BuildPcData(p_status->cmdRef, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)p_CmdRefData),
+ p_CmdRefData);
+ }
+
+ if (p_CmdName != NULL)
+ {
+ BuildPcData(p_status->cmd, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)p_CmdName),
+ p_CmdName);
+ }
+
+ if (p_SourceRefData != NULL)
+ {
+ if ( (p_status->sourceRefList = smlAllocSourceRefList()) != NULL)
+ {
+ BuildPcData(p_status->sourceRefList->sourceRef, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)p_SourceRefData),
+ p_SourceRefData);
+ }
+ }
+
+ if (p_TargetRefData != NULL)
+ {
+ if (0 == DmStrcmp((char *)p_TargetRefData, FDR_URI))
+ {
+ SmlItemPtr_t p_status_item = NULL;
+ SmlItemListPtr_t p_status_list_item = NULL;
+ p_status->itemList = smlAllocItemList();
+ p_status_list_item = p_status->itemList;
+ p_status_item = p_status_list_item->item;
+ if ((p_status_item->source = smlAllocSource()) != NULL)
+ BuildPcData(p_status_item->source->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)p_TargetRefData),
+ p_TargetRefData);
+ }
+ else
+ {
+ if ((p_status->targetRefList = smlAllocTargetRefList()) != NULL)
+ BuildPcData(p_status->targetRefList->targetRef, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)p_TargetRefData),
+ p_TargetRefData);
+ }
+ }
+
+ if (pClientChal != NULL)
+ {
+ if (( pClientChal->pChalFormat != NULL ) ||
+ ( pClientChal->pChalType != NULL ) ||
+ ( pClientChal->pChalNonce != NULL ))
+ {
+ if ( (p_status->chal = smlAllocChal() ) != NULL)
+ BuildMetaInfo(p_status->chal->meta,
+ pClientChal->pChalFormat,
+ pClientChal->pChalType,
+ NULL,
+ NULL,
+ pClientChal->pChalNonce,
+ NULL, NULL, NULL);
+ }
+ }
+
+ /* Convert the status_Code to a string */
+ if ( status_Code == SYNCML_DM_SUCCESS )
+ status_Code = 200;
+ else if ( status_Code == SYNCML_DM_PROCESS_ACCEPTED )
+ status_Code = 1200;
+ else
+ {
+ if ( status_Code < 100 || status_Code > 600 )
+ status_Code = 500;
+ }
+
+
+ DmSprintf((char *)status_code_str, "%d", (int)status_Code);
+ BuildPcData(p_status->data, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)status_code_str),
+ status_code_str);
+
+ if (responses && responses->size() > 0) {
+
+ p_status->itemList = smlAllocItemList();
+ SmlItemListPtr_t itemListPtr_t = p_status->itemList;
+ int i = 0;
+ do {
+ if ( itemListPtr_t != NULL)
+ {
+ if ( (itemListPtr_t->item->data = smlAllocPcdata() ) != NULL)
+ BuildPcData(itemListPtr_t->item->data, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ (UINT32)DmStrlen((*responses)[i].c_str()),
+ (UINT8*)(*responses)[i].c_str());
+ }
+ i++;
+ if (i < responses->size()) {
+ if ( itemListPtr_t != NULL)
+ {
+ itemListPtr_t->next = smlAllocItemList();
+ itemListPtr_t = itemListPtr_t->next;
+ }
+ }
+ } while (i < responses->size());
+ }
+ return p_status;
+}
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_BuildPackage::BuildStatus(SmlStatusPtr_t p_status )
+{
+ MemSize_t freeSpace = 0;
+ Ret_t sml_ret_stat = 0;
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ UINT8 command_id_str[UINT16_TYPE_STR_SIZE_5];
+
+ /* Convert the commandId to a string */
+ DmSprintf((char *)command_id_str, "%d", commandId++);
+
+ BuildPcData(p_status->cmdID, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)command_id_str),
+ command_id_str);
+
+
+ /* Call the toolkit to construct the STATUS command */
+ smlStartEvaluation(sendInstanceId);
+ sml_ret_stat = smlStatusCmd(sendInstanceId, p_status);
+ smlEndEvaluation(sendInstanceId, &freeSpace);
+
+ /* Note that freeSpace accounts for the EndSyncmlDoc overhead as well.*/
+ if (freeSpace > 0)
+ {
+ sml_ret_stat = smlStatusCmd(sendInstanceId, p_status);
+ }
+ else
+ {
+ ret_stat = SYNCML_DM_RESULTS_TOO_LARGE;
+ }
+
+ /* Free the memory. smlFreeStatus will free every element in the SmlStatusPtr_t structure. */
+ //smlFreeStatus(p_status);
+
+ return (ret_stat);
+}
+
+#ifdef TNDS_SUPPORT
+BOOLEAN SYNCML_DM_BuildPackage::ListTndsProp( CPCHAR uri, CPCHAR prop, BOOLEAN &listProp)
+{
+ // Include property '+' and remove property '-' are not possible
+ // to combine in the same Get command
+ BOOLEAN includeProp = NULL != DmStrchr(uri, '+');
+ BOOLEAN removeProp = NULL != DmStrchr(uri, '-');
+ if ( includeProp && removeProp )
+ {
+ listProp = false;
+ return false;
+ }
+
+ // Return all properties by default
+ if ( !includeProp && !removeProp )
+ {
+ listProp = true;
+ return true;
+ }
+
+ // Return selected properties only
+ char *szQPos = DmStrstr(uri, prop);
+ if ( includeProp )
+ {
+ listProp = NULL != szQPos;
+ if ( listProp && *(szQPos-1) != '+' )
+ {
+ KCDBG("Invalid URI: %s, prop: %s\n", uri, prop);
+ listProp = false;
+ return false;
+ }
+ }
+
+ if ( removeProp )
+ {
+ listProp = NULL == szQPos;
+ if ( !listProp && *(szQPos-1) != '-' )
+ {
+ KCDBG("Invalid URI: %s, prop: %s\n", uri, prop);
+ listProp = false;
+ return false;
+ }
+ }
+
+ return true;
+}
+#endif //TNDS_SUPPORT
+
+#ifdef TNDS_SUPPORT
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::AllocateTndsResult( CPCHAR p_target_uri,
+ DMGetData *p_get_ret_data,
+ const SYNCML_DM_GET_ON_LIST_RET_DATA_T& oGetStructData,
+ SmlPcdataPtr_t pPcDataPtr )
+{
+ BOOLEAN listACL, listFormat, listName, listSize, listTitle, listTStamp, listVerNo, listValue;
+
+ BOOLEAN listProps = ListTndsProp(p_target_uri, "ACL", listACL) &&
+ ListTndsProp(p_target_uri, "Format", listFormat) &&
+ ListTndsProp(p_target_uri, "Name", listName) &&
+ ListTndsProp(p_target_uri, "Size", listSize) &&
+ ListTndsProp(p_target_uri, "Title", listTitle) &&
+ ListTndsProp(p_target_uri, "TStamp", listTStamp) &&
+ ListTndsProp(p_target_uri, "VerNo", listVerNo) &&
+ ListTndsProp(p_target_uri, "Value", listValue);
+ if ( !listProps )
+ {
+ return SYNCML_DM_COMMAND_INVALID_URI;
+ }
+
+ SmlDmTndPtr_t p_tnd_info = NULL;
+ UINT32 data_length = 0;
+ UINT32 data_size;
+
+ // Allocate TNDS object
+ data_size = sizeof(SmlDmTndPtr_t);
+ p_tnd_info = smlAllocDmTnd();
+ if ( p_tnd_info == NULL)
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ data_length += data_size;
+
+ // Append VerDTD Tag
+ data_size = 3;
+ BuildPcDataWAllocMem (&p_tnd_info->verdtd, data_size, (UINT8*)SYNCML_DM_PROTOCOL_VERSION_1_2+3);
+ data_length += data_size;
+
+ // Append Mod Tag
+ SYNCML_DM_RET_STATUS_T nRes = SYNCML_DM_SUCCESS;
+ DMGetData tmpGetData;
+ nRes = dmTreeObj.Get(DM_DEV_INFO_MOD_URI, tmpGetData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ if (nRes != SYNCML_DM_SUCCESS)
+ {
+ smlFreeDmTnd(p_tnd_info);
+ return (SYNCML_DM_FAIL);
+ }
+ data_size = tmpGetData.m_oData.getSize();
+ if (data_size != 0)
+ {
+ BuildPcDataWAllocMem(&p_tnd_info->mod, data_size, (UINT8*) tmpGetData.getCharData());
+ data_length += data_size;
+ }
+
+ // Append Man Tag
+ nRes = dmTreeObj.Get(DM_DEV_INFO_MAN_URI, tmpGetData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ if (nRes != SYNCML_DM_SUCCESS)
+ {
+ smlFreeDmTnd(p_tnd_info);
+ return (SYNCML_DM_FAIL);
+ }
+ data_size = tmpGetData.m_oData.getSize();
+ if (data_size != 0)
+ {
+ BuildPcDataWAllocMem(&p_tnd_info->man, data_size, (UINT8*) tmpGetData.getCharData());
+ data_length += data_size;
+ }
+
+ // TNDS last node list
+ p_tnd_info->nodelist = NULL;
+ SmlDmTndNodeListPtr_t last = NULL;
+
+ // Allocate TNDS node object(s)
+ SYNCML_DM_GET_ON_LIST_RET_DATA_T oTmpGetStructData = oGetStructData;
+ DMGetData *pTmpGetData = NULL;
+ CPCHAR pTmpTargetUri = p_target_uri;
+ nRes = dmTreeObj.GetListNextItem(oTmpGetStructData);
+ if ( nRes == SYNCML_DM_SUCCESS )
+ {
+ pTmpGetData = oTmpGetStructData.psRetData;
+ oTmpGetStructData.psRetData = NULL;
+ pTmpTargetUri = oTmpGetStructData._pbURI;
+ }
+
+ DMString targetUri = oTmpGetStructData.m_strStartURI;
+ DMString tmpNodeUri = "";
+ DMString tmpStr = "";
+ DmtAttributes oAttr;
+ while ( nRes == SYNCML_DM_SUCCESS && NULL != pTmpGetData )
+ {
+ // Get DMT node attribute
+ nRes = dmTreeObj.GetAttributes( pTmpTargetUri, oAttr, SYNCML_DM_REQUEST_TYPE_INTERNAL );
+ if ( nRes != SYNCML_DM_SUCCESS )
+ {
+ break;
+ }
+
+ // Allocate TNDS node list object
+ data_size = sizeof(SmlDmTndNodeListPtr_t);
+ SmlDmTndNodeListPtr_t p_tnd_nodelist = smlAllocDmTndNodeList();
+ if ( p_tnd_info == NULL)
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ if ( NULL == p_tnd_info->nodelist )
+ {
+ p_tnd_info->nodelist = p_tnd_nodelist;
+ }
+ else
+ {
+ last->next = p_tnd_nodelist;
+ }
+ last = p_tnd_nodelist;
+ data_length += data_size;
+
+ // Append Node tag
+ data_size = sizeof(SmlDmTndNodePtr_t);
+ SmlDmTndNodePtr_t p_tnd_node = smlAllocDmTndNode();
+ if ( p_tnd_node == NULL)
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ p_tnd_nodelist->node = p_tnd_node;
+ data_length += data_size;
+
+ // Append NodeName tag
+ data_size = oAttr.GetName().length();
+ BuildPcDataWAllocMem (&p_tnd_node->nodename, data_size, (UINT8*)oAttr.GetName().c_str());
+ data_length += data_size;
+
+ // Append Path tag
+ tmpNodeUri = "";
+ if ( (int)strlen(pTmpTargetUri) > targetUri.length() +
+ oAttr.GetName().length() + 1)
+ {
+ tmpNodeUri.assign(pTmpTargetUri + targetUri.length() + 1,
+ strlen(pTmpTargetUri) -
+ targetUri.length() -
+ oAttr.GetName().length() - 2 );
+ }
+ if ( tmpNodeUri.length() > 0 )
+ {
+ data_size = tmpNodeUri.length();
+ BuildPcDataWAllocMem (&p_tnd_node->path, data_size, (UINT8*)tmpNodeUri.c_str());
+ data_length += data_size;
+ }
+
+ // Append RTProperties start tag
+ data_size = sizeof(SmlDmTndRTPropsPtr_t);
+ SmlDmTndRTPropsPtr_t p_tnd_node_rtprops = smlAllocDmTndRTProps();
+ if ( p_tnd_node_rtprops == NULL)
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ p_tnd_node->rtprops = p_tnd_node_rtprops;
+ data_length += data_size;
+
+ // Append ACL Property
+ if ( listACL )
+ {
+ data_size = oAttr.GetAcl().toString().length();
+ BuildPcDataWAllocMem (&p_tnd_node_rtprops->acl, data_size, (UINT8*)oAttr.GetAcl().toString().c_str());
+ data_length += data_size;
+ }
+
+ // Append Format Property
+ if ( listFormat )
+ {
+ data_size = sizeof(SmlDmTndFormatPtr_t);
+ SmlDmTndFormatPtr_t p_tnd_node_format = smlAllocDmTndFormat();
+ if ( p_tnd_node_format == NULL)
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ p_tnd_node_rtprops->format = p_tnd_node_format;
+ data_length += data_size;
+
+ data_size = oAttr.GetFormat().length();
+ BuildPcDataWAllocMem (&p_tnd_node_rtprops->format->value, data_size, (UINT8*)oAttr.GetFormat().c_str());
+ data_length += data_size;
+ }
+
+ // Append Name Property
+ if ( listName )
+ {
+ data_size = oAttr.GetName().length();
+ BuildPcDataWAllocMem (&p_tnd_node_rtprops->name, data_size, (UINT8*)oAttr.GetName().c_str());
+ data_length += data_size;
+ }
+
+ // Append Size Property
+ if ( listSize )
+ {
+ char pTmpStr[UINT32_TYPE_STR_SIZE_10+1];
+ DmSprintf(pTmpStr, "%d", oAttr.GetSize());
+ data_size = DmStrlen(pTmpStr);
+ BuildPcDataWAllocMem (&p_tnd_node_rtprops->size, data_size, (UINT8*)pTmpStr);
+ data_length += data_size;
+ }
+
+ // Append Title Property
+ if ( listTitle )
+ {
+ data_size = oAttr.GetTitle().length();
+ BuildPcDataWAllocMem (&p_tnd_node_rtprops->title, data_size, (UINT8*)oAttr.GetTitle().c_str());
+ data_length += data_size;
+ }
+
+ // Append TStamp Property
+ if ( listTStamp )
+ {
+ tmpStr = "";
+ if ( oAttr.GetTimestamp() != 0 )
+ {
+ // convert msec to sec
+ time_t timestamp = (time_t)(oAttr.GetTimestamp()/1000L);
+ tmpStr = (CPCHAR)ctime(&timestamp);
+ tmpStr.SetAt(tmpStr.length()-1, '\0');
+ }
+ data_size = tmpStr.length();
+ BuildPcDataWAllocMem (&p_tnd_node_rtprops->tstamp, data_size, (UINT8*)tmpStr.c_str());
+ data_length += data_size;
+ }
+
+ // Append Type Property
+ data_size = sizeof(SmlDmTndTypePtr_t);
+ SmlDmTndTypePtr_t p_tnd_node_type = smlAllocDmTndType();
+ if ( p_tnd_node_type == NULL)
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ p_tnd_node->rtprops->type = p_tnd_node_type;
+ data_length += data_size;
+
+ data_size = oAttr.GetType().length();
+ BuildPcDataWAllocMem (&p_tnd_node_rtprops->type->mime, data_size, (UINT8*)oAttr.GetType().c_str());
+ data_length += data_size;
+
+ // Append VerNo Property
+ if ( listVerNo )
+ {
+ char pTmpStr[UINT32_TYPE_STR_SIZE_10+1];
+ DmSprintf(pTmpStr, "%d", oAttr.GetVersion());
+ data_size = DmStrlen(pTmpStr);
+ BuildPcDataWAllocMem (&p_tnd_node_rtprops->verno, data_size, (UINT8*)pTmpStr);
+ data_length += data_size;
+ }
+
+ // Append Value Tag
+ if ( listValue )
+ {
+ data_size = DmStrlen(pTmpGetData->getCharData());
+ BuildPcDataWAllocMem (&p_tnd_node->value, data_size, (UINT8*)pTmpGetData->getCharData());
+ data_length += data_size;
+ }
+
+ if ( pTmpGetData )
+ {
+ delete pTmpGetData;
+ pTmpGetData = NULL;
+ }
+
+ nRes = dmTreeObj.GetListNextItem(oTmpGetStructData);
+ if ( nRes != SYNCML_DM_SUCCESS || oTmpGetStructData._pbURI == p_target_uri )
+ {
+ break;
+ }
+ pTmpGetData = oTmpGetStructData.psRetData;
+ oTmpGetStructData.psRetData = NULL;
+ pTmpTargetUri = oTmpGetStructData._pbURI;
+ }
+
+ if ( pTmpGetData )
+ {
+ delete pTmpGetData;
+ pTmpGetData = NULL;
+ }
+
+ if ( nRes == SYNCML_DM_SUCCESS )
+ {
+ p_get_ret_data->m_nFormat = SYNCML_DM_FORMAT_XML;
+ p_get_ret_data->m_oMimeType.clear();
+ p_get_ret_data->m_oMimeType.assign( pDmMgmtSessionObj->IsWBXMLEncoding() ? SYNCML_CONTENT_TYPE_DM_TNDS_WBXML: SYNCML_CONTENT_TYPE_DM_TNDS_XML);
+ p_get_ret_data->m_oData.clear();
+
+ pPcDataPtr->content = p_tnd_info;
+ pPcDataPtr->length = data_length;
+ pPcDataPtr->contentType = SML_PCDATA_EXTENSION;
+ pPcDataPtr->extension = SML_EXT_DMTND;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+#endif //TNDS_SUPPORT
+
+/*
+ Allocates and fill in memory structure for result
+*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::AllocateResult(SmlResultsPtr_t & p_results,
+ CPCHAR p_target_uri,
+ CPCHAR p_CmdIdRef,
+ DMGetData *p_get_ret_data,
+ BOOLEAN is_ThisGetStructResult,
+ BOOLEAN isFirstGetStruct,
+ BOOLEAN isThisGetPropResult,
+ CPCHAR szMsgID,
+ SmlPcdataPtr_t p_data )
+{
+ DMString strTargetUri(p_target_uri);
+
+ if ( !strTargetUri.Encode() )
+ return SYNCML_DM_DEVICE_FULL;
+
+ p_results = smlAllocResults();
+ if ( !p_results )
+ return SYNCML_DM_DEVICE_FULL;
+
+ SmlItemListPtr_t p_results_list_item = p_results->itemList;
+ SmlItemPtr_t p_results_item = p_results_list_item->item;
+
+ UINT8 data_size_str[UINT32_TYPE_STR_SIZE_10];
+ UINT8 *pEncData = NULL;
+
+ p_results_item->source = smlAllocSource();
+ if ( p_results_item->source == NULL )
+ {
+ smlFreeResults(p_results);
+ p_results = NULL;
+ return (SYNCML_DM_FAIL);
+ }
+
+ BuildPcData( p_results_item->source->locURI,
+ SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ strTargetUri.length(),
+ (UINT8*)strTargetUri.c_str());
+
+ /* Set receiving package command id reference */
+ BuildPcData(p_results->cmdRef, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)p_CmdIdRef),
+ (UINT8*)p_CmdIdRef);
+
+ /* Call BuildPcDataWAllocMem to allocate the memory for p_results->msgRef, also construct the
+ data. */
+ CPCHAR sMsg = szMsgID ? szMsgID : (CPCHAR)pMessageIdOfServer;
+ BuildPcDataWAllocMem(&p_results->msgRef,DmStrlen(sMsg),(UINT8*)sMsg);
+
+ /* If p_get_ret_data is NULL, we don't construct further <RESULT> */
+ if (p_get_ret_data == NULL)
+ return SYNCML_DM_SUCCESS;
+
+
+ INT32 totalSize = p_get_ret_data->m_oData.getSize();
+ // special case for binary data
+ if ( !is_ThisGetStructResult &&
+ p_get_ret_data->m_nFormat == SYNCML_DM_FORMAT_BIN &&
+ !p_get_ret_data->IsESN())
+ {
+ if ( totalSize > 0 )
+ {
+ UINT32 encLen = base64GetSize((BufferSize_t)p_get_ret_data->m_oData.getSize());
+ pEncData = (UINT8 *)DmAllocMem(encLen+1);
+ if (pEncData == NULL)
+ {
+ smlFreeResults(p_results); p_results = NULL;
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ memset(pEncData, 0, encLen+1);
+
+ UINT32 offset = 0;
+ UINT32 dataSize = p_get_ret_data->m_oData.getSize();
+ totalSize = base64Encode (pEncData, encLen,
+ p_get_ret_data->m_oData.getBuffer(),
+ (BufferSize_t *)&dataSize,
+ (BufferSize_t *)&offset, 0, NULL);
+ }
+ p_get_ret_data->m_nFormat = SYNCML_DM_FORMAT_B64;
+ }
+ /* Convert the dwRetDataSize to a string */
+ if(p_get_ret_data->IsESN())
+ {
+ if ( !is_ThisGetStructResult &&
+ p_get_ret_data->m_nFormat == SYNCML_DM_FORMAT_BIN &&
+ p_get_ret_data->IsESN())
+ {
+ if(p_get_ret_data->m_TotalSize != 0)
+ totalSize = base64GetSize((BufferSize_t)p_get_ret_data->m_TotalSize);
+ p_get_ret_data->m_nFormat = SYNCML_DM_FORMAT_B64;
+ }
+ else
+ totalSize = p_get_ret_data->m_TotalSize;
+ }
+ DmSprintf((char *)data_size_str, "%d", p_get_ret_data->m_oData.getSize());
+
+ // Is data size too large ?
+ if(IsLargerThanMaxObjSize(totalSize, p_get_ret_data->IsESN(), TRUE))
+ {
+ if (pEncData != NULL)
+ {
+ DmFreeMem(pEncData);
+ }
+
+ smlFreeResults(p_results); p_results = NULL;
+ return SYNCML_DM_REQUEST_ENTITY_TOO_LARGE;
+ }
+
+ if (!isThisGetPropResult)
+ {
+ p_results_item->meta = smlAllocPcdata();
+ if (p_results_item->meta == NULL)
+ {
+ if (pEncData != NULL)
+ {
+ DmFreeMem(pEncData);
+ }
+ smlFreeResults(p_results); p_results = NULL;
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ DMString strFormat;
+ SYNCML_DM_RET_STATUS_T res = DMTree::ConvertFormat( p_get_ret_data->m_nFormat, strFormat);
+
+ if (res != SYNCML_DM_SUCCESS)
+ {
+ if (pEncData != NULL)
+ {
+ DmFreeMem(pEncData);
+ }
+ smlFreeResults(p_results); p_results = NULL;
+ return res;
+ }
+
+ if ((p_get_ret_data->m_oMimeType.getSize() == 0) || isFirstGetStruct)
+ {
+ BuildMetaInfo(p_results_item->meta,
+ (UINT8 *)strFormat.GetBuffer(),
+ NULL,NULL, NULL, NULL, NULL, NULL, NULL);
+ }
+ else
+ {
+ if (p_get_ret_data->m_nFormat == SYNCML_DM_FORMAT_B64)
+ {
+ BuildMetaInfo(p_results_item->meta,
+ (UINT8 *)strFormat.GetBuffer(),
+ NULL,NULL,
+ data_size_str,
+ NULL, NULL, NULL, NULL);
+ }
+ else
+ {
+ if (p_get_ret_data->m_nFormat == SYNCML_DM_FORMAT_CHR )
+ {
+ BuildMetaInfo(p_results_item->meta,
+ NULL,NULL,NULL,data_size_str,
+ NULL, NULL, NULL, NULL);
+ }
+ else
+ {
+ BuildMetaInfo(p_results_item->meta,
+ (UINT8 *)strFormat.GetBuffer(),
+ (UINT8*)p_get_ret_data->getType(),
+ NULL,
+ data_size_str,
+ NULL, NULL, NULL, NULL);
+ }
+ }
+ }
+ }
+
+ /* Set the p_results_item->data */
+ /* When data is from GET command on Struct, no need to construct <Data> element. */
+ if (!is_ThisGetStructResult)
+ {
+ /* Client construct <Data> element no matter there are data from GET command or not. */
+ p_results_item->data = smlAllocPcdata();
+ if(p_results_item->data == NULL)
+ {
+ if (pEncData != NULL)
+ {
+ DmFreeMem(pEncData);
+ }
+ smlFreeResults(p_results); p_results = NULL;
+ return SYNCML_DM_DEVICE_FULL;
+ }
+#ifdef LOB_SUPPORT
+ if(pDmMgmtSessionObj->IsLargeObjectSupported() && p_get_ret_data->IsESN())
+ {
+ p_results_item->data->length = totalSize;
+ p_results_item->flags |= SmlESNData_f;
+ // Need to encode binary data
+ if(p_get_ret_data->m_nFormat == SYNCML_DM_FORMAT_B64)
+ p_results_item->flags |= SmlESNBinary_f;
+ }
+ else
+#endif
+ {
+ if(p_get_ret_data->IsESN())
+ {
+ if (pEncData != NULL)
+ {
+ DmFreeMem(pEncData);
+ }
+ smlFreeResults(p_results); p_results = NULL;
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ }
+ UINT8 *pData = (pEncData == NULL) ? p_get_ret_data->m_oData.getBuffer() : pEncData;
+
+#ifdef TNDS_SUPPORT
+ if ( NULL != p_data )
+ {
+ p_results_item->data->content = p_data->content;
+ p_results_item->data->length = p_data->length;
+ p_results_item->data->contentType = p_data->contentType;
+ p_results_item->data->extension = p_data->extension;
+ }
+ else
+#endif
+ {
+ BuildPcData(p_results_item->data,
+ SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ totalSize,
+ pData);
+
+ }
+ }
+ }
+
+ if (pEncData != NULL)
+ DmFreeMem(pEncData);
+
+#ifdef LOB_SUPPORT
+ if(pDmMgmtSessionObj->IsLargeObjectSupported())
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+#endif
+ // check the size
+ MemSize_t freeSpace = 0, initialBufferSize = smlGetFreeBuffer(sendInstanceId);
+ SML_API Ret_t smlErr = SML_ERR_OK;
+ smlStartEvaluation(sendInstanceId);
+ smlErr = smlResultsCmd(sendInstanceId, p_results);
+ smlEndEvaluation(sendInstanceId, &freeSpace);
+
+ if ( smlErr != SML_ERR_OK )
+ {
+ smlFreeResults(p_results); p_results = NULL;
+ return (SYNCML_DM_FAIL);
+ }
+
+ /* DM_MSG_OVERHEAD is defined as the size of the syncHdr and the status
+ to Alert (DM_NEXT_MESSAGE). The size should be 531 bytes for XML and ? for WBXML */
+
+ MemSize_t nRequired = initialBufferSize - freeSpace;
+
+ if (nRequired > (g_iDMWorkspaceSize - DM_MSG_OVERHEAD) )
+ {
+ smlFreeResults(p_results); p_results = NULL;
+ return SYNCML_DM_RESULTS_TOO_LARGE;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildResultsCommand
+
+DESCRIPTION : This function will be called by HandleGetCommand to add the GET results to the DM
+ package.
+
+ This method calls the SyncML Toolkit function smlResultsCommand() to add results
+ into the SyncBody for the DM message.
+ARGUMENT PASSED : p_CmdIdRef
+ p_TargetUri
+ p_results
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildResultsCommand( SmlResultsPtr_t p_results )
+{
+ UINT8 command_id_str[UINT16_TYPE_STR_SIZE_5];
+
+ /* Convert the commandId to a string */
+ DmSprintf((char *)command_id_str, "%d", commandId++);
+ BuildPcData(p_results->cmdID, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)command_id_str),
+ command_id_str);
+
+ SML_API Ret_t smlErr = SML_ERR_OK;
+#ifdef LOB_SUPPORT
+ smlErr = smlResultsCmd(sendInstanceId, p_results);
+ if ( smlErr != SML_ERR_OK )
+ {
+ return SYNCML_DM_RESULTS_TOO_LARGE;
+ }
+
+#else
+ MemSize_t freeSpace;
+ MemSize_t initialBufferSize;
+ initialBufferSize = smlGetFreeBuffer(sendInstanceId);
+
+ smlStartEvaluation(sendInstanceId);
+ smlErr = smlResultsCmd(sendInstanceId, p_results);
+ smlEndEvaluation(sendInstanceId, &freeSpace);
+ if ( smlErr != SML_ERR_OK )
+ {
+ return (SYNCML_DM_FAIL);
+ }
+
+ /* Note that freeSpace accounts for the EndSyncmlDoc overhead as well.*/
+ if (freeSpace > 0) {
+ /* Call the toolkit to construct RESULTS for GET command. */
+ smlErr = smlResultsCmd(sendInstanceId, p_results);
+ } else
+ return SYNCML_DM_RESULTS_TOO_LARGE;
+#endif
+ /* We cannot free any memory here since it may be used later in multiple messages.*/
+ if ( smlErr != SML_ERR_OK )
+ {
+ return (SYNCML_DM_FAIL);
+ }
+
+ return (SYNCML_DM_SUCCESS);
+}
+
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::EndSyncmlDoc
+
+DESCRIPTION : This function will be called by BuildPackageOne and HandleStartMessage to add the
+ last element to the DM package.
+
+ This method calls the SyncML Toolkit function smlEndMessage() to add a Final element
+ into the SyncBody for the DM message.
+ARGUMENT PASSED : final
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::EndSyncmlDoc(Boolean_t final)
+{
+ Ret_t sml_ret_stat;
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+ /* This ends the SyncML document it has been assembled */
+ /* SmlFinal_f says this is the last message in the SyncML package */
+#ifdef LOB_SUPPORT
+ if (m_bProcessingLargeObject && largeObjectCmd!= DM_COMMAND_RESULTS)
+ {
+ ret_stat = BuildAlertCommand(DM_ALERT_NEXT_MESSAGE, NULL, NULL);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ return ret_stat;
+ // No <Final> statement
+ final = FALSE;
+ }
+#endif
+
+ sml_ret_stat = smlEndMessage(sendInstanceId, final);
+ if (sml_ret_stat != SML_ERR_OK)
+ {
+ ret_stat = SYNCML_DM_FAIL;
+ }
+ return (ret_stat);
+}
+
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::getDirection
+
+DESCRIPTION : This function returns session direction in unsigned short.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : session direction
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_SESSION_DIRECTION_T
+SYNCML_DM_BuildPackage::getDirection() const
+{
+ return sessionDirection;
+}
+
+
+/*==================================================================================================
+FUNCTION : SYNCML_DM_BuildPackage::BuildPackageOne
+
+DESCRIPTION : This function calls SYNCML_DM_BuildPackage class functions to build up the package one.
+ARGUMENT PASSED : session_Direction
+ p_ParsedPk0
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildPackageOne(CPCHAR pServerID, DmtSessionProp * pSessionProp)
+{
+ SYNCML_DM_RET_STATUS_T ret_stat;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ SmlSyncHdrPtr_t p_hdr_content;
+ char session_id_str[UINT16_TYPE_STR_SIZE_5];
+ DMGetData portNbrData;
+ DMGetData devID;
+ char *p_server_uri = NULL;
+ CPCHAR parent_name = NULL;
+ DMString strServerURI;
+ CPCHAR devIMEI = NULL;
+ bool sessionid_check = false;
+ UINT32 finalUriLength;
+ DMClientServerCreds *pClientServerCreds;
+
+ /* Allocate the memory for pSyncHdr */
+
+ sessionDirection = pSessionProp->getDirection();
+ p_hdr_content = smlAllocSyncHdr();
+ if ( p_hdr_content == NULL)
+ {
+ return (SYNCML_DM_DEVICE_FULL);
+ }
+
+ /* Fill in message id as 1 into the sync header */
+ BuildPcData(p_hdr_content->msgID, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)DEFAULT_MESSAGE_ID),
+ (UINT8 *)DEFAULT_MESSAGE_ID);
+
+ sessionid_check = IsSessionId();
+ if(sessionid_check == true)
+ {
+ /* Fill in the SessionId data which come from p_ParsedPk0, must be in upper case hex */
+ DmSprintf(session_id_str, "%X", pSessionProp->getSessionID());
+ }
+ else
+ {
+ /* Fill in the SessionId data which come from p_ParsedPk0, must be in decimal */
+ DmSprintf(session_id_str, "%d", pSessionProp->getSessionID());
+ }
+
+ BuildPcData(p_hdr_content->sessionID,
+ SML_PCDATA_STRING,SML_EXT_UNDEFINED,
+ DmStrlen(session_id_str),
+ (UINT8*)session_id_str);
+
+ /* We can use the DMAccNodeName that was stored in ConnectServer().*/
+ pClientServerCreds = pDmMgmtSessionObj->GetClientServerCreds();
+ parent_name = (CPCHAR)pClientServerCreds->pDMAccNodeName;
+ if (parent_name == NULL)
+ {
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_FAIL);
+ }
+
+ /* Call the local method to retrieve the value of "./SyncML/DMAcc/<parent_name>/Addr" */
+ DMGetData oDataAddrType, oAddr;
+
+ ret_stat = dmTreeObj.GetDefAccountAddrInfo( parent_name,
+ oAddr,
+ oDataAddrType,
+ portNbrData );
+
+ if ( (dm_stat != SYNCML_DM_SUCCESS) || (oAddr.m_oData.getSize() == 0) )
+ {
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_FAIL);
+ }
+
+ /* If port number is NULL, means its value is defaulted as 80, we don't need to do anything.
+ Otherwise, insert port number into the server address */
+ if ( portNbrData.m_oData.getSize() != 0 )
+ {
+ char * pUriBeg;
+ char * pUriMid;
+
+ /* Locate the position of '://' */
+ pUriBeg = (char*)DmStrstr(oAddr.getCharData(), "://");
+ if (pUriBeg == NULL)
+ {
+ pUriBeg = (char*)oAddr.getCharData();
+ }
+ else
+ {
+ pUriBeg += 3;
+ }
+ char* pUriBeg2 = NULL;
+ char* pPortNumber = NULL;
+
+ /* Locate the position of ':' */
+ pPortNumber = DmStrchr(pUriBeg, ':');
+
+ /* Locate the position of '/' */
+ pUriMid = DmStrchr(pUriBeg, '/');
+ if (pUriMid == NULL)
+ {
+ pUriBeg2 = (char*)DmAllocMem(DmStrlen(pUriBeg)+2);
+ if ( pUriBeg2 == NULL )
+ {
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_DEVICE_FULL);
+ }
+
+ DmStrcpy(pUriBeg2,pUriBeg);
+
+ /* Insert '/' at the end of URL */
+ DmStrcat(pUriBeg2, "/");
+ DmFreeMem(pUriBeg);
+
+ pUriBeg = pUriBeg2;
+ pUriMid = DmStrchr(pUriBeg, '/');
+ if ( pUriMid == NULL )
+ {
+ if ( pUriBeg2 != NULL )
+ {
+ DmFreeMem(pUriBeg2);
+ }
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_FAIL);
+ }
+ }
+ /* Calculate the length of the final server address */
+ finalUriLength = oAddr.m_oData.getSize() + portNbrData.m_oData.getSize() + 2;
+
+ /* Allocate memory for the new URL, copy addr and portNbr to new uri */
+ p_server_uri = (char*)DmAllocMem(finalUriLength);
+ if ( p_server_uri == NULL )
+ {
+ if ( pUriBeg2 != NULL )
+ {
+ DmFreeMem(pUriBeg2);
+ }
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_DEVICE_FULL);
+ }
+ memset(p_server_uri, 0, finalUriLength);
+ DmStrncpy(p_server_uri, oAddr.getCharData(),pUriMid - oAddr.getCharData());
+
+ if(portNbrData.m_oData.getSize() == 0 || pPortNumber != NULL)
+ DmStrcat(p_server_uri,pUriMid);
+ else
+ {
+ DmStrcat((char*)p_server_uri, ":");
+ DmStrcat((char*)p_server_uri, portNbrData.getCharData());
+ DmStrcat((char*)p_server_uri, pUriMid);
+ }
+
+ if ( pUriBeg2 != NULL )
+ {
+ DmFreeMem(pUriBeg2);
+ }
+ }
+ else
+ {
+ oAddr.m_oData.copyTo(&p_server_uri);
+ if ( p_server_uri == NULL )
+ {
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_DEVICE_FULL);
+ }
+ }
+
+
+ /* Call MgmtSession object to set server URI here to reduce code for transport module, since
+ we have constructed server uri with server address and port number */
+ strServerURI = (CPCHAR)p_server_uri;
+ pDmMgmtSessionObj->SetURI(strServerURI.c_str());
+ if(strServerURI.Encode()== FALSE)
+ {
+ if ( p_server_uri != NULL )
+ DmFreeMem(p_server_uri);
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_FAIL);
+ }
+
+ if(p_hdr_content->source == NULL)
+ {
+ if ( p_server_uri != NULL )
+ DmFreeMem(p_server_uri);
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_FAIL);
+ }
+
+ /* Fill in the server address information into pSyncHdr structure target->locURI element.*/
+ BuildPcData(p_hdr_content->source->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ strServerURI.length(),
+ (UINT8 *) strServerURI.c_str());
+
+ /* Free the memory of p_server_uri */
+ DmFreeMem(p_server_uri);
+
+ /* Fill in the server id information into pSyncHdr structure target->locName element. */
+ if (pServerID != NULL)
+ {
+ BuildPcDataWAllocMem(&p_hdr_content->source->locName,DmStrlen(pServerID),(UINT8*)pServerID);
+ }
+
+ /* While we are retrieving things from the DM Tree, we'll get the rest of the Security info.*/
+ pClientServerCreds->pServerId = pServerID;
+ if ( pClientServerCreds->pServerId != pServerID )
+ {
+ XPL_LOG_DM_SESS_Error(("SYNCML_DM_BuildPackage::BuildPackageOne : unable allocate memory"));
+ smlFreeSyncHdr(p_hdr_content);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ /* Call the local method to retrieve the value of "./DevInfo/DevId" */
+ dm_stat = dmTreeObj.Get(DM_DEV_INFO_DEVID_URI, devID,SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_FAIL);
+ }
+
+ if (devID.m_oData.getSize() != 0)
+ devIMEI = GetIMEINumber(devID.getCharData());
+
+ /* Call the local method to retrieve the remaining pieces of Security Info.*/
+
+ dm_stat = GetRemainingSecInfo(parent_name, pClientServerCreds, devIMEI);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ smlFreeSyncHdr(p_hdr_content);
+ return (SYNCML_DM_FAIL);
+ }
+
+ BuildPcDataWAllocMem(&p_hdr_content->target->locName,
+ DmStrlen((CPCHAR)(pClientServerCreds->pClientUserName)),
+ (UINT8*)pClientServerCreds->pClientUserName.c_str());
+
+ /* Fill the client dev id information into pSyncHdr structure source->locURI element. */
+ if (devID.m_oData.getSize() != 0)
+ {
+ BuildPcData(p_hdr_content->target->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ devID.m_oData.getSize(),
+ devID.m_oData.getBuffer());
+ }
+
+
+ /* Call BuildSyncHdr to construct the <SyncHdr> */
+ ret_stat = BuildStartSyncHdr(p_hdr_content,TRUE);
+ smlFreeSyncHdr(p_hdr_content);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ return(ret_stat);
+ }
+ ret_stat = BuildFinishSyncHdr(pClientServerCreds->AuthPrefCredType);
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ return(ret_stat);
+ }
+
+ /* Build up the Alert command to indicate server or client initiate the session */
+ ret_stat = BuildAlertCommand(sessionDirection, NULL, NULL);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ return(ret_stat);
+ }
+
+ /* Build the DevInfo data in REPLACE command */
+ ret_stat = BuildReplaceCommand();
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ return(ret_stat);
+ }
+
+ //DMFirmAlertVector aFirmAlert;
+ //pSessionProp->getFirmAlerts(aFirmAlert);
+ firmAlertVec.clear();
+ pSessionProp->getFirmAlerts(firmAlertVec);
+ //if ( aFirmAlert.size() > 0 )
+ //{
+ ret_stat = BuildAlert1226Command();
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ return(ret_stat);
+ }
+ //}
+
+ /* End the SyncML document */
+ ret_stat = EndSyncmlDoc(SmlFinal_f);
+ return (ret_stat);
+}
+
+
+
+/*==================================================================================================
+Function: SYNCML_DM_BuildPackage::GetRemainingSecInfo (private)
+
+Description: This method is called to retrieve the remaining pieces of Security Info needed for
+ creating credentials during this session. This method will retrieve:
+ - ServerPW
+ - ServerNonce
+ - user name (client)
+ - ClientPW
+ - ClientNonce
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL
+IMPORTANT NOTES : This method assumes the DM Tree is locked and the management session is in
+ progress.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::GetRemainingSecInfo (CPCHAR pParentName,
+ DMClientServerCreds *pClientServerCreds,
+ CPCHAR devIMEI)
+{
+ DMGetData serverData;
+ DMGetData clientData;
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ dm_stat = pClientServerCreds->LoadInitialValues();
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ pDmMgmtSessionObj->SetSecState(DM_CLIENT_NO_SERVER_NO_AUTH);
+
+ return (dm_stat);
+}
+
+/*===============================================================================
+FUNCTION : CreateFactoryBootStrapUserName
+
+DESCRIPTION : This function will create factory boot strap's user name
+
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_STATUS_T
+=================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::CreateFactoryBootStrapUserName( SYNCML_DM_FACTORY_BOOTSTRAP_T bootStrapCode,
+ const DMString& server_id,
+ const DMString& devIMEI,
+ DMString& user_name )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ switch ( bootStrapCode )
+ {
+ case SYNCML_DM_FACTORY_BOOTSTRAP_FCS11384:
+ {
+ dm_stat = BuildFactoryBootstrapCredData(user_name,
+ devIMEI + ":" + server_id,
+ DM_NAME);
+ break;
+ }
+ case SYNCML_DM_FACTORY_BOOTSTRAP_FCS14345:
+ {
+ // IMEI becomes the UserName
+ user_name = devIMEI;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ if( ( SYNCML_DM_SUCCESS != dm_stat ) ||
+ ( 0 == user_name.length() ) )
+ {
+ dm_stat = SYNCML_DM_DEVICE_FULL;
+ }
+
+ return dm_stat;
+}
+
+
+
+/*===============================================================================
+FUNCTION : CreateFactoryBootStrapPW
+
+DESCRIPTION : This function will create factory boot strap's server or client pass word
+
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_STATUS_T
+
+
+=================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::CreateFactoryBootStrapServerPW( SYNCML_DM_FACTORY_BOOTSTRAP_T bootStrapCode,
+ const DMString& server_id,
+ const DMString& abIMEI,
+ DMString& server_password )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ switch ( bootStrapCode )
+ {
+ case SYNCML_DM_FACTORY_BOOTSTRAP_FCS11384:
+ {
+ dm_stat = BuildFactoryBootstrapCredData(server_password,
+ server_id,
+ abIMEI);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return SYNCML_DM_DEVICE_FULL;
+ break;
+ }
+ case SYNCML_DM_FACTORY_BOOTSTRAP_FCS14345:
+ {
+
+ GeneratePassword gp;
+
+ gp.setIMEI(abIMEI);
+ gp.setServerId(server_id);
+
+ char* srvpw = gp.generateServerPassword();
+ server_password = srvpw;
+ DmFreeMem(srvpw);
+ break;
+ }
+ default:
+ {
+ return dm_stat;
+ }
+ }
+
+ return dm_stat;
+}
+
+
+/*===============================================================================
+FUNCTION : CreateFactoryBootStrapPW
+
+DESCRIPTION : This function will create factory boot strap's server or client pass word
+
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_STATUS_T
+
+
+=================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::CreateFactoryBootStrapClientPW( SYNCML_DM_FACTORY_BOOTSTRAP_T bootStrapCode,
+ const DMString& server_id,
+ const DMString& abIMEI,
+ DMString& client_password )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ switch (bootStrapCode)
+ {
+ case SYNCML_DM_FACTORY_BOOTSTRAP_FCS11384:
+ {
+ dm_stat = BuildFactoryBootstrapCredData( client_password,
+ abIMEI,
+ server_id );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ dm_stat = SYNCML_DM_DEVICE_FULL;
+ }
+
+ break;
+ }
+ case SYNCML_DM_FACTORY_BOOTSTRAP_FCS14345:
+ {
+ GeneratePassword gp;
+
+ gp.setIMEI(abIMEI);
+ gp.setServerId( server_id );
+
+ char* clnpw = gp.generateClientPassword();
+ client_password = clnpw;
+ DmFreeMem(clnpw);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return dm_stat;
+}
+
+
+/*=============================================================================
+FUNCTION:BuildFactoryBootstrapCredData
+DESCRIPTION:
+ This function builds the B64 encoded MD5 credential information.
+ The credential string is credential data:IMEI number . That string is then b64 encoded.
+
+ARGUMENTS PASSED:
+
+REFERENCE ARGUMENTS PASSED:
+ char **pp_credential_data - Output variable containing the encoded credential data
+ const char *p_CredData - credential_data .
+ const char *p_IMEI - Phone IMEI number.
+
+
+RETURN VALUE:
+ N/A
+
+PRE-CONDITIONS:
+
+POST-CONDITIONS:
+
+================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildFactoryBootstrapCredData(DMString& pp_credential_data,
+ CPCHAR p_CredData,
+ CPCHAR p_CredData1 )
+ {
+ char *p_CredData_IMEI;
+ MD5_CTX md5_context;
+ char md5hash[SYNCML_DM_HASHLEN + 1]; /* Add 1 character for NULL */
+ BufferSize_t offset = 0;
+ BufferSize_t md5_hash_length = SYNCML_DM_HASHLEN;
+ BufferSize_t total_length;
+
+ memset(md5hash, '\0', SYNCML_DM_HASHLEN + 1);
+
+ char* pCredData = pp_credential_data.AllocateBuffer(SYNCML_DM_BAS64_ENCODING_SIZE_IN_MD5 + 1);
+
+ if ( pCredData == NULL )
+ {
+ XPL_LOG_DM_SESS_Error(("BuildFactoryBootstrapCredData : unable allocate memory"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ memset(pCredData, 0, SYNCML_DM_BAS64_ENCODING_SIZE_IN_MD5+1);
+ /* Add space for the ":" and NULL character */
+ total_length= DmStrlen(p_CredData) + DmStrlen(p_CredData1) + 2;
+ p_CredData_IMEI = (char *)DmAllocMem(total_length);
+
+ if ( p_CredData_IMEI == NULL )
+ {
+ XPL_LOG_DM_SESS_Error(("BuildFactoryBootstrapCredData : unable allocate memory"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ memset(p_CredData_IMEI, '\0', total_length);
+ DmStrcpy(p_CredData_IMEI, p_CredData);
+ DmStrcat(p_CredData_IMEI, ":");
+ DmStrcat(p_CredData_IMEI, p_CredData1);
+
+ smlMD5Init(&md5_context);
+ smlMD5Update(&md5_context, (unsigned char *)p_CredData_IMEI,DmStrlen(p_CredData_IMEI));
+ smlMD5Final((unsigned char*)md5hash, &md5_context);
+ md5hash[SYNCML_DM_HASHLEN] = 0;
+ DmFreeMem(p_CredData_IMEI);
+
+ base64Encode((UINT8*)pCredData,
+ SYNCML_DM_BAS64_ENCODING_SIZE_IN_MD5+1,
+ (unsigned char *)md5hash,
+ &md5_hash_length,
+ &offset,
+ 1, /* Encode as single block */
+ NULL); /* No incomplete bl*/
+ return SYNCML_DM_SUCCESS;
+
+ }
+
+SYNCML_DM_FACTORY_BOOTSTRAP_T SYNCML_DM_BuildPackage::GetBootStrapCodeUserName(const DMString& user_name )
+{
+ if( user_name == DMACC_FACTORY_BOOTSTRAP_USERNAME_FCS11384 )
+ {
+ return SYNCML_DM_FACTORY_BOOTSTRAP_FCS11384;
+ }
+ else if ( user_name == DMACC_FACTORY_BOOTSTRAP_USERNAME_FCS14345 )
+ {
+ return SYNCML_DM_FACTORY_BOOTSTRAP_FCS14345;
+ }
+
+ return SYNCML_DM_FACTORY_BOOTSTRAP_UNKNOWN;
+}
+
+SYNCML_DM_FACTORY_BOOTSTRAP_T SYNCML_DM_BuildPackage::GetBootStrapCodeClientPW(const DMString& password )
+{
+ if ( password == DMACC_FACTORY_BOOTSTRAP_CLIENTPW_FCS11384 )
+ {
+ return SYNCML_DM_FACTORY_BOOTSTRAP_FCS11384;
+ }
+ else if ( password == DMACC_FACTORY_BOOTSTRAP_CLIENTPW_FCS14345 )
+ {
+ return SYNCML_DM_FACTORY_BOOTSTRAP_FCS14345;
+ }
+
+ return SYNCML_DM_FACTORY_BOOTSTRAP_UNKNOWN;
+}
+
+SYNCML_DM_FACTORY_BOOTSTRAP_T SYNCML_DM_BuildPackage::GetBootStrapCodeServerPW(const DMString& password )
+{
+ if ( password == DMACC_FACTORY_BOOTSTRAP_SERVERPW_FCS11384 )
+ {
+ return SYNCML_DM_FACTORY_BOOTSTRAP_FCS11384;
+ }
+ else if ( password == DMACC_FACTORY_BOOTSTRAP_SERVERPW_FCS14345 )
+ {
+ return SYNCML_DM_FACTORY_BOOTSTRAP_FCS14345;
+ }
+
+ return SYNCML_DM_FACTORY_BOOTSTRAP_UNKNOWN;
+}
+
+/*=================================================================
+
+===================================================================*/
+CPCHAR
+SYNCML_DM_BuildPackage::GetIMEINumber(CPCHAR devID)
+{
+ char *retValue = (char*)DmStrchr(devID, ':');
+ if( retValue == NULL )
+ return devID;
+ else
+ return (++retValue);
+}
+
+/*==================================================================================================
+FUNCTION :DecodBase64Data
+
+DESCRIPTION : Handling of SYNCML_DM_FORMAT_B64
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::DecodBase64Data(SmlItemPtr_t &p_add_item, DMAddData & oAddData, BOOLEAN decodeB64)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ if (p_add_item->data != NULL)
+ {
+ // special-case handling of SYNCML_DM_FORMAT_B64
+ if (oAddData.m_nFormat == SYNCML_DM_FORMAT_B64 && decodeB64)
+ {
+ UINT8 *decDataBuf;
+ UINT32 dataLen = p_add_item->data->length;;
+ UINT32 decDataLen;
+ UINT32 decMaxBufLen = dataLen*3/4+2;
+
+ decDataBuf = (UINT8*)DmAllocMem(decMaxBufLen);
+ if(decDataBuf == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ decDataLen = base64Decode(decDataBuf , decMaxBufLen, (DataBuffer_t) p_add_item->data->content,
+ (BufferSize_t *)&dataLen);
+ if (decDataLen == 0)
+ {
+ DmFreeMem(decDataBuf);
+ return SYNCML_DM_BAD_REQUEST;
+ }
+
+ oAddData.m_oData.assign(decDataBuf, decDataLen);
+
+ if ( oAddData.m_oData.getBuffer() == NULL )
+ {
+ DmFreeMem(decDataBuf);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ DmFreeMem(decDataBuf);
+ oAddData.m_nFormat = SYNCML_DM_FORMAT_BIN;
+ }
+ else
+ {
+ if ( p_add_item->data->length )
+ {
+ oAddData.m_oData.assign((UINT8*)p_add_item->data->content, p_add_item->data->length);
+ if ( oAddData.m_oData.getBuffer() == NULL )
+ dm_stat = SYNCML_DM_DEVICE_FULL;
+ }
+ }
+
+ }
+ return dm_stat;
+}
+/*==================================================================================================
+FUNCTION :IsLargerThanMaxObjSize
+
+DESCRIPTION : Is data size larger than MaxObjSize
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+BOOLEAN
+SYNCML_DM_BuildPackage::IsLargerThanMaxObjSize( int dataSize, BOOLEAN isESN, BOOLEAN isToServer)
+{
+ // If data size is larger then MaxObjSize
+ XPL_FS_SIZE_T maxSize = MaxObjectSize;
+
+#ifdef LOB_SUPPORT
+ if(!isToServer)
+ { if(isESN)
+ {
+ DMString m_strEsnDir;
+ dmTreeObj.GetWritableFileSystemFullPath( m_strEsnDir );
+ maxSize = XPL_FS_FreeDiskSpace(m_strEsnDir.c_str());
+ }
+ else
+ {
+ maxSize = MaxObjectSize = pDmMgmtSessionObj->GetDefaultMaxObjectSize();
+ }
+ }
+#endif
+
+ // <MaxObjSize> is missing
+ if(maxSize == 0)
+ {
+ if(isESN)
+ maxSize = SYNCML_DM_MAX_OBJ_SIZE;
+ else
+ maxSize = MaxMessageSize * 2;
+ }
+ if(dataSize > (int)maxSize)
+ return TRUE;
+ else
+ return FALSE;
+}
+#ifdef LOB_SUPPORT
+/*==================================================================================================
+FUNCTION :LargeObjectClear
+
+DESCRIPTION : Clears large object related variables
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+void
+SYNCML_DM_BuildPackage::LargeObjectClear()
+{
+ m_bProcessingLargeObject = FALSE;
+ m_bESN = FALSE;
+ m_bBinary = FALSE;
+ if(m_pChunkData != NULL)
+ delete m_pChunkData;
+
+ m_pChunkData = NULL;
+ m_ChunkOffset = 0;
+
+ largeObjectCmdSize = 0;
+ largeObjectSize = 0;
+ largeObjectBufferUsedSize = 0;
+ largeObjectMsgRef = 0;
+ largeObjectChunkSize = 0;
+ largeObjectChunkOffset = 0;
+
+ largeObjectBuffer.free();
+ largeObjectCmdRef = NULL;
+ largeObjectMsgRef = NULL;
+
+ largeObjectTURI.free();
+ largeObjectSURI.free();
+ largeObjectType.free();
+ largeObjectFormat = SYNCML_DM_FORMAT_INVALID;
+ largeObjectCmd = DM_COMMAND_INVALID;
+ if(largeObjFileHandle != NULL)
+ { largeObjFileHandle->deleteFile();
+ delete largeObjFileHandle;
+ largeObjFileHandle = NULL;
+ }
+ largeObjFileName = NULL;
+
+}
+/*==================================================================================================
+FUNCTION : AllocateChunkBuffer
+
+DESCRIPTION : Allocate chunk buffer
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+DmtDataChunk *
+SYNCML_DM_BuildPackage::AllocateChunkBuffer()
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DmtDataChunk *chunkData;
+
+ chunkData = new DmtDataChunk();
+ if(chunkData == NULL)
+ return NULL;
+
+ dm_stat = chunkData->AllocateChunkBuffer();
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ delete chunkData;
+ return NULL;
+ }
+ return chunkData;
+}
+
+/*==================================================================================================
+FUNCTION : SetEngineChunkData
+
+DESCRIPTION : Set chunk data to engine
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage:: SetChunkDataToEngine(DMAddData & oAddData, BOOLEAN isAllSet)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+DMAddData oReplace;
+
+oReplace.m_oURI.assign(oAddData.getURI());
+if(oReplace.m_oURI.getBuffer() == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+oReplace.m_bLastChunk = isAllSet;
+oReplace.chunkData = m_pChunkData;
+oReplace.m_chunkOffset = m_ChunkOffset;
+
+retStatus = dmTreeObj.Replace(oReplace,SYNCML_DM_REQUEST_TYPE_SERVER);
+ return retStatus;
+}
+/*==================================================================================================
+FUNCTION : SetLastChunkDataFromFile
+
+DESCRIPTION : Set last chunk data from file
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::SetLastChunkDataFromFile(DMAddData & oAddData,
+ DMBuffer &lastData,
+ UINT8**szBuf,
+ int chunksize,
+ UINT8 *decDataBuf,
+ UINT32 decMaxBufLen,
+ UINT32 &lastChunkSize)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ int setLen = 0;
+ BOOLEAN isAllSet = FALSE;
+ int offset = 0;
+ UINT32 dataLen = largeObjectSize;
+ UINT32 decDataLen = 0;
+ DMBuffer remainData;
+
+ // Close it first
+ largeObjFileHandle->close();
+ delete largeObjFileHandle;
+ largeObjFileHandle = NULL;
+ retStatus = OpenESNTempFile();
+ if (retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ m_pChunkData->GetChunkData(szBuf); // the chunk data is available
+
+ while (offset < largeObjectBufferUsedSize && !isAllSet)
+ {
+ setLen = largeObjectBufferUsedSize - offset;
+ if(setLen > chunksize)
+ setLen = chunksize;
+ else
+ isAllSet = TRUE;
+ if(largeObjFileHandle->seek(XPL_FS_SEEK_SET, offset) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(largeObjFileHandle->read(*szBuf, setLen) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ // special-case handling of SYNCML_DM_FORMAT_B64
+ if(decDataBuf != NULL)
+ {
+ dataLen = setLen;
+ decDataLen = base64Decode(decDataBuf , decMaxBufLen, (DataBuffer_t) *szBuf,
+ (BufferSize_t *)&dataLen);
+ if (decDataLen == 0)
+ return SYNCML_DM_BAD_REQUEST;
+ if(dataLen != 0)
+ remainData.assign((CPCHAR)& (*szBuf[0]), dataLen);
+
+ m_pChunkData->SetChunkData(decDataBuf, decDataLen);
+ setLen -= dataLen;
+
+ }
+ else
+ m_pChunkData->SetChunkData(NULL, setLen);
+
+ retStatus = SetChunkDataToEngine(oAddData, FALSE);
+ if(retStatus !=SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ if(decDataBuf != NULL)
+ m_ChunkOffset += decDataLen;
+ else
+ m_ChunkOffset += setLen;
+
+ offset += setLen;
+ }
+
+ if(decDataBuf != NULL && dataLen != 0)
+ {
+ // Allocate the Large Object Buffer based on the size
+ lastChunkSize = lastData.getSize() + dataLen;
+
+ largeObjectBuffer.allocate( lastChunkSize + 1);
+ if ( largeObjectBuffer.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ // All non-processed data are shifted to the start of the input buffer
+ largeObjectBuffer = remainData;
+ largeObjectBuffer.append( lastData.getBuffer(),lastData.getSize());
+ *szBuf = largeObjectBuffer.getBuffer();
+ }
+ else
+ {
+ *szBuf = lastData.getBuffer();
+ lastChunkSize = lastData.getSize();
+ }
+ return retStatus;
+}
+/*==================================================================================================
+FUNCTION : SetLastChunkRemainData
+
+DESCRIPTION : Processing all the remaining data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::SetLastChunkRemainData(DMAddData & oAddData,
+ DMBuffer &lastData,
+ UINT8* szBuf,
+ int chunksize,
+ UINT8 *decDataBuf,
+ UINT32 decMaxBufLen,
+ UINT32 lastChunkSize)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ BOOLEAN isAllSet = FALSE;
+ int offset = 0;
+ int setLen = 0;
+ UINT32 dataLen = largeObjectSize;
+ UINT32 decDataLen;
+
+ offset = 0;
+ while (offset <= (int)lastChunkSize && !isAllSet)
+ { setLen = lastChunkSize - offset;
+ if(setLen > chunksize)
+ setLen = chunksize;
+ else
+ isAllSet = TRUE;
+
+ if(szBuf != NULL)
+ {
+ // special-case handling of SYNCML_DM_FORMAT_B64
+ if(decDataBuf != NULL)
+ {
+ dataLen = setLen;
+ decDataLen = base64Decode(decDataBuf , decMaxBufLen, (DataBuffer_t) &szBuf[offset],
+ (BufferSize_t *)&dataLen);
+ if (decDataLen == 0)
+ return SYNCML_DM_BAD_REQUEST;
+
+ m_pChunkData->SetChunkData(decDataBuf, decDataLen);
+ setLen -= dataLen;
+ }
+ else
+ {
+ m_pChunkData->SetChunkData((const UINT8 *)&szBuf[offset], setLen);
+ }
+ }
+
+ retStatus = SetChunkDataToEngine(oAddData,isAllSet);
+ if(retStatus !=SYNCML_DM_SUCCESS)
+ return retStatus;
+ offset += setLen;
+
+ }
+
+ return retStatus;
+
+}
+
+
+/*==================================================================================================
+FUNCTION : SetLastChunkData
+
+DESCRIPTION : Set last chunk data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::SetLastChunkData(DMAddData & oAddData, DMCommandType cmdType)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ UINT8 *decDataBuf = NULL;
+ DMBuffer lastData;
+ m_ChunkOffset = 0;
+ UINT8* szBuf;
+ int chunksize = m_pChunkData->GetChunkSize();
+ UINT32 decMaxBufLen = chunksize*3/4+2;
+
+ if(oAddData.m_oData.getSize() != 0)
+ lastData.attach(oAddData.m_oData.getBuffer(), oAddData.m_oData.getSize()+1);
+ oAddData.m_oData.reset();
+ UINT32 lastChunkSize = lastData.getSize();
+
+ // special-case handling of SYNCML_DM_FORMAT_B64
+ if (oAddData.m_nFormat == SYNCML_DM_FORMAT_B64)
+ {
+ decDataBuf = (UINT8*)DmAllocMem(decMaxBufLen);
+ if(decDataBuf == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ oAddData.m_nFormat = SYNCML_DM_FORMAT_BIN;
+ }
+
+ // Create the leaf node first with empty data
+ if(cmdType == DM_COMMAND_ADD)
+ {
+ retStatus = dmTreeObj.Add( oAddData, SYNCML_DM_REQUEST_TYPE_SERVER );
+ if ( retStatus != SYNCML_DM_SUCCESS )
+ goto setchunkdatafailed;
+
+ if(largeObjFileHandle == NULL && m_ChunkOffset == 0 && lastData.getSize() ==0)
+ {
+ if(decDataBuf != NULL)
+ DmFreeMem(decDataBuf);
+ return retStatus;
+ }
+ }
+
+ if(m_pChunkData == NULL)
+ { m_pChunkData = AllocateChunkBuffer();
+ if(m_pChunkData == NULL)
+ { retStatus = SYNCML_DM_DEVICE_FULL;
+ goto setchunkdatafailed;
+ }
+ }
+ // Is there is temoprary file ?
+ if(largeObjFileHandle != NULL)
+ {
+ retStatus = SetLastChunkDataFromFile(oAddData,lastData, &szBuf, chunksize,decDataBuf,decMaxBufLen,lastChunkSize);
+ if ( retStatus != SYNCML_DM_SUCCESS )
+ goto setchunkdatafailed;
+ }
+ else
+ { szBuf = lastData.getBuffer();
+ lastChunkSize = lastData.getSize();
+ }
+
+ retStatus = SetLastChunkRemainData(oAddData,
+ lastData,
+ szBuf,
+ chunksize,
+ decDataBuf,
+ decMaxBufLen,
+ lastChunkSize);
+
+ if ( retStatus != SYNCML_DM_SUCCESS )
+ goto setchunkdatafailed;
+
+ if(decDataBuf != NULL)
+ DmFreeMem(decDataBuf);
+return retStatus;
+
+setchunkdatafailed:
+ if(decDataBuf != NULL)
+ DmFreeMem(decDataBuf);
+ if(cmdType == DM_COMMAND_ADD)
+ dmTreeObj.Delete( oAddData.getURI(), SYNCML_DM_REQUEST_TYPE_SERVER );
+ return retStatus;
+}
+
+/*==================================================================================================
+FUNCTION : SetChunkData
+
+DESCRIPTION : Set chunk data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::SetChunkData(DMAddData & oAddData,DMCommandType cmdType, BOOLEAN isLastChunk)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+
+// Save data in temporary file
+ if(!isLastChunk)
+ {
+
+ if(largeObjFileHandle->seek(XPL_FS_SEEK_SET, largeObjectBufferUsedSize) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ if(largeObjFileHandle->write((CPCHAR)oAddData.m_oData.getBuffer(), oAddData.m_oData.getSize()) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+ else
+ retStatus = SetLastChunkData(oAddData, cmdType);
+
+ return retStatus;
+}
+/*==================================================================================================
+FUNCTION : CreateESNTempFile
+
+DESCRIPTION : Create and open a temporary ESN file
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::CreateESNTempFile()
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ INT32 modeFlag = XPL_FS_FILE_WRITE;
+
+ largeObjFileName = XPL_FS_TempEsnDir();
+ XPL_FS_MkDir(largeObjFileName);
+ largeObjFileName += "##lob##.lob";
+
+ largeObjFileHandle = new DMFileHandler(largeObjFileName.c_str(), FALSE);
+ if(largeObjFileHandle == NULL)
+ return SYNCML_DM_IO_FAILURE;
+
+ if (largeObjFileHandle->open(modeFlag) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ return dm_stat;
+}
+/*==================================================================================================
+FUNCTION : OpenESNTempFile
+
+DESCRIPTION : Open the temporary ESN file
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::OpenESNTempFile()
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ INT32 modeFlag = XPL_FS_FILE_RDWR;
+ // Open again using different flag
+ largeObjFileHandle = new DMFileHandler(largeObjFileName.c_str(), FALSE);
+ if(largeObjFileHandle == NULL)
+ return SYNCML_DM_IO_FAILURE;
+
+ if (largeObjFileHandle->open(modeFlag) != SYNCML_DM_SUCCESS)
+ dm_stat = SYNCML_DM_IO_FAILURE;
+ return dm_stat;
+}
+/*==================================================================================================
+FUNCTION : PreProcessFirstMoreData
+
+DESCRIPTION : Handle more data case
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::PreProcessFirstMoreData(DMAddData & oAddData,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_data_item,
+ int &size )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ SmlMetInfMetInfPtr_t p_meta_info;
+ if(!pDmMgmtSessionObj->IsLargeObjectSupported())
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+
+ /* Set the ADD data */
+ dm_stat = DecodBase64Data(p_data_item, oAddData, FALSE);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ // Get size
+ if(p_data_item->meta == NULL || p_data_item->meta->content == NULL)
+ return SYNCML_DM_INCOMPLETE_COMMAND;
+
+ p_meta_info = (SmlMetInfMetInfPtr_t)p_data_item->meta->content;
+ // <Size> element MUST only be specified in the first data chunk
+ if(p_meta_info->size != NULL &&
+ p_meta_info->size->content != 0)
+ {
+ size = DmAtoi((const char *)p_meta_info->size->content);
+ if(IsLargerThanMaxObjSize(size, m_bESN, FALSE))
+ return SYNCML_DM_REQUEST_ENTITY_TOO_LARGE;
+
+ // Size of data chunk greater than/equal to specified object size
+ if((int)oAddData.m_oData.getSize() >= size)
+ return SYNCML_DM_SIZE_MISMATCH;
+
+ largeObjectCmd = cmdType;
+ largeObjectTURI = oAddData.m_oURI;
+ largeObjectFormat = oAddData.m_nFormat;
+ largeObjectSize = size;
+ largeObjectType = oAddData.m_oMimeType;
+ m_ChunkOffset = 0;
+ largeObjectBufferUsedSize = 0;
+ // Create temporary file for the Large Object
+ if(m_bESN)
+ dm_stat =CreateESNTempFile();
+
+ if(dm_stat == SYNCML_DM_SUCCESS)
+ m_bProcessingLargeObject = TRUE;
+ }
+ else
+ {
+ // Meta->Size /Item->Meta-Size missing
+ dm_stat = SYNCML_DM_INCOMPLETE_COMMAND;
+ }
+ return dm_stat;
+}
+
+/*==================================================================================================
+FUNCTION : LargeObjectRecvFirstChunk
+
+DESCRIPTION : Receives the first chunk of a large object data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::LargeObjectRecvFirstChunk(DMAddData & oAddData,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_data_item)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ int size = 0;
+ BOOLEAN lsLastChunk = FALSE;
+ BOOLEAN bMoreData = (p_data_item->flags & SmlMoreData_f) ==SmlMoreData_f;
+
+ if(bMoreData && pDmMgmtSessionObj->IsProcessScript())
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+
+ // Is ESN
+ dm_stat = dmTreeObj.IsESN(oAddData.getURI(), m_bESN);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ // Normal nodes
+ if( !bMoreData)
+ {
+ if(m_bESN)
+ {
+ /* Set the ADD data */
+ dm_stat = DecodBase64Data(p_data_item, oAddData, FALSE);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ lsLastChunk = TRUE;
+ }
+ else
+ {
+ /* Set the ADD data */
+ dm_stat = DecodBase64Data(p_data_item, oAddData, TRUE);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if(cmdType == DM_COMMAND_ADD)
+ dm_stat = dmTreeObj.Add( oAddData, SYNCML_DM_REQUEST_TYPE_SERVER );
+ else
+ dm_stat = dmTreeObj.Replace( oAddData, SYNCML_DM_REQUEST_TYPE_SERVER );
+ return dm_stat;
+ }
+ }
+ else
+ {
+ dm_stat= PreProcessFirstMoreData(oAddData, cmdType, p_data_item, size );
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ { BuildAlertCommand(DM_ALERT_SESSION_ABORT, NULL, NULL);
+ return dm_stat;
+ }
+
+ }
+ if(m_bESN)
+ {
+ dm_stat = SetChunkData(oAddData, cmdType, lsLastChunk);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto receivefirstchunkfailed;
+
+ if(bMoreData)
+ dm_stat = SYNCML_DM_CHUNK_BUFFERED;
+ }
+ else
+ {
+ // Allocate the Large Object Buffer based on the size
+ largeObjectBuffer.allocate(size+1);
+ if ( largeObjectBuffer.getBuffer() == NULL )
+ goto receivefirstchunkfailed;
+ largeObjectBuffer = oAddData.m_oData;
+
+ dm_stat = SYNCML_DM_CHUNK_BUFFERED;
+ }
+ largeObjectBufferUsedSize += oAddData.m_oData.getSize();
+ return dm_stat;
+ receivefirstchunkfailed:
+ if(m_bProcessingLargeObject)
+ {
+ BuildAlertCommand(DM_ALERT_SESSION_ABORT, NULL, NULL);
+ LargeObjectClear();
+ }
+ return dm_stat;
+
+}
+/*==================================================================================================
+FUNCTION : LargeObjectRecvDecodeData
+
+DESCRIPTION : Decode binary LOB data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::LargeObjectRecvDecodeData(DMAddData & oAddData,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_data_item)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ SmlMetInfMetInfPtr_t p_meta_info = NULL;
+
+ // Check if it is the correct item
+ if (m_bProcessingLargeObject && (largeObjectCmd!=cmdType ||
+ DmStrcmp((CPCHAR)largeObjectTURI.getBuffer(), oAddData.getURI()) !=0))
+
+ {
+ // Alert 1225 : End of data for chunked object not received
+ BuildAlertCommand(DM_ALERT_END_OF_DATA_NOT_RECEIVED, NULL,(CPCHAR) largeObjectTURI.getBuffer());
+ return SYNCML_DM_INCOMPLETE_COMMAND;
+ }
+ /* Set the ADD data */
+ dm_stat = DecodBase64Data(p_data_item, oAddData, FALSE);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ LargeObjectClear();
+ return dm_stat;
+ }
+ // Check if size has been specified again
+ if(p_data_item->meta != NULL)
+ { p_meta_info = (SmlMetInfMetInfPtr_t)p_data_item->meta->content;
+
+ if (p_meta_info != NULL && p_meta_info->size != NULL )
+ { dm_stat = SYNCML_DM_BAD_REQUEST;
+ LargeObjectClear();
+ return dm_stat;
+ }
+ }
+ return dm_stat;
+}
+/*==================================================================================================
+FUNCTION : LargeObjectRecvLastChunk
+
+DESCRIPTION : Processing the last chunk of a large object data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::LargeObjectRecvLastChunk(DMAddData & oAddData,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_data_item)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ if(largeObjectCmd == DM_COMMAND_ADD ||largeObjectCmd == DM_COMMAND_REPLACE)
+ {
+ // Replace data
+ oAddData.m_oData.free();
+ oAddData.m_oData.attach(largeObjectBuffer.getBuffer(), largeObjectBuffer.getSize() +1);
+
+ // special-case handling of SYNCML_DM_FORMAT_B64
+ if (oAddData.m_nFormat == SYNCML_DM_FORMAT_B64)
+ {
+ UINT8 *decDataBuf;
+ UINT32 dataLen = largeObjectSize;
+ UINT32 decDataLen;
+ UINT32 decMaxBufLen = largeObjectSize*3/4+2;
+
+ decDataBuf = (UINT8*)DmAllocMem(decMaxBufLen);
+ if(decDataBuf == NULL)
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ decDataLen = base64Decode(decDataBuf , decMaxBufLen, (DataBuffer_t) oAddData.m_oData.getBuffer(),
+ (BufferSize_t *)&dataLen);
+ if (decDataLen == 0)
+ {
+ DmFreeMem(decDataBuf);
+ return SYNCML_DM_BAD_REQUEST;
+ }
+
+ oAddData.m_oData.assign(decDataBuf, decDataLen);
+ // largeObjectBuffer is freed
+ largeObjectBuffer.reset();
+
+ if ( oAddData.m_oData.getBuffer() == NULL )
+ {
+ DmFreeMem(decDataBuf);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ DmFreeMem(decDataBuf);
+ oAddData.m_nFormat = SYNCML_DM_FORMAT_BIN;
+ }
+
+
+ if(largeObjectCmd == DM_COMMAND_ADD)
+ dm_stat = dmTreeObj.Add( oAddData, SYNCML_DM_REQUEST_TYPE_SERVER );
+ else
+ dm_stat = dmTreeObj.Replace( oAddData, SYNCML_DM_REQUEST_TYPE_SERVER);
+
+ oAddData.m_oData.reset();
+ }
+ return dm_stat;
+}
+/*==================================================================================================
+FUNCTION : IsRecveivingLastChunk
+
+DESCRIPTION : Is the last chunk of a large object data received?
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::IsRecveivingLastChunk(DMAddData & oAddData,
+ BOOLEAN bMoreData,
+ int &size,
+ BOOLEAN &lsLastChunk)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ lsLastChunk = FALSE;
+ size = oAddData.m_oData.getSize();
+ // Is data size too large
+ if(IsLargerThanMaxObjSize(size, m_bESN, FALSE))
+ return SYNCML_DM_REQUEST_ENTITY_TOO_LARGE;
+ // Object size is larger then MaxObjSize
+ if(size > largeObjectSize - largeObjectBufferUsedSize)
+ return SYNCML_DM_SIZE_MISMATCH;
+
+ // is it the last chunk ?
+ if(bMoreData == FALSE )
+ {
+ if(( size+ largeObjectBufferUsedSize)!= largeObjectSize)
+ return SYNCML_DM_SIZE_MISMATCH;
+ lsLastChunk = TRUE;
+ }
+ return dm_stat;
+}
+/*==================================================================================================
+FUNCTION : LargeObjectRecvNextChunk
+
+DESCRIPTION : Receives the next/last chunk of a large object data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::LargeObjectRecvNextChunk(DMAddData & oAddData,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_data_item)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ BOOLEAN bMoreData = (p_data_item->flags & SmlMoreData_f) ==SmlMoreData_f;
+ int size = 0;
+ BOOLEAN lsLastChunk = FALSE;
+
+ dm_stat = LargeObjectRecvDecodeData(oAddData, cmdType,p_data_item);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto receivechunkfailed;
+
+ // Is it the last chunk?
+ dm_stat = IsRecveivingLastChunk(oAddData, bMoreData, size, lsLastChunk);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto receivechunkfailed;
+
+ // Append to the buffer
+ if(m_bESN)
+ {
+ dm_stat = SetChunkData(oAddData, cmdType, lsLastChunk);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto receivechunkfailed;
+ }
+ else
+ {
+ largeObjectBuffer.append(oAddData.m_oData.getBuffer(), oAddData.m_oData.getSize());
+
+ // All the chunked data received
+ if(lsLastChunk)
+ { dm_stat = LargeObjectRecvLastChunk(oAddData,
+ cmdType,
+ p_data_item);
+
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto receivechunkfailed;
+ }
+ }
+ if(bMoreData)
+ { dm_stat = SYNCML_DM_CHUNK_BUFFERED;
+ largeObjectBufferUsedSize += size;
+ }
+ else
+ {
+ if(m_bProcessingLargeObject)
+ LargeObjectClear();
+ }
+ return dm_stat;
+receivechunkfailed:
+ if(m_bProcessingLargeObject)
+ {
+ BuildAlertCommand(DM_ALERT_SESSION_ABORT, NULL, NULL);
+ LargeObjectClear();
+ }
+ return dm_stat;
+
+
+}
+/*==================================================================================================
+FUNCTION : GetTargetURI
+
+DESCRIPTION : Get target URI.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::GetLargeObjectTargetURI(SmlItemPtr_t p_get_item)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ UINT8 * pTargetURL = NULL;
+ if(p_get_item==NULL)
+ {
+ return SYNCML_DM_BAD_REQUEST;
+ }
+ if((p_get_item->source != NULL) && (p_get_item->source->locURI != NULL))
+ {
+ DMString tempURI;
+ pTargetURL = (UINT8*)p_get_item->source->locURI->content;
+ tempURI.assign((CPCHAR)p_get_item->source->locURI->content,p_get_item->source->locURI->length);
+ if ( tempURI == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ largeObjectTURI.assign(tempURI);
+
+ if(tempURI.Decode() == FALSE)
+ return SYNCML_DM_BAD_REQUEST;
+
+ largeObjectSURI.assign(tempURI);
+
+ if(largeObjectSURI.getBuffer() == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ else
+ dm_stat = SYNCML_DM_BAD_REQUEST;
+
+ return dm_stat;
+
+}
+/*==================================================================================================
+FUNCTION : SetEngineChunkData
+
+DESCRIPTION : Set chunk data to engine
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage:: GetChunkDataFromEngine()
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ DMGetData getData;
+getData.chunkData = m_pChunkData;
+getData.m_chunkOffset = m_ChunkOffset;
+
+ retStatus = dmTreeObj.Get((CPCHAR)largeObjectSURI.getBuffer(),getData, SYNCML_DM_REQUEST_TYPE_SERVER);
+
+ if ( retStatus != SYNCML_DM_SUCCESS )
+ return retStatus;
+
+ UINT32 returnLen =0;
+ retStatus = m_pChunkData->GetReturnLen(returnLen);
+ m_ChunkOffset += returnLen;
+
+ return retStatus;
+}
+
+/*==================================================================================================
+FUNCTION : GetChunkData
+
+DESCRIPTION : Read one chunk of data from ESN
+ package.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::GetChunkData(DMBuffer & oSendData, int bufSize)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ UINT8 *bufp;
+
+ if(m_pChunkData == NULL)
+ { m_pChunkData = AllocateChunkBuffer();
+ if(m_pChunkData == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ // Is it an empty buffer
+ if ( oSendData.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ // Is data in temporary file already?
+ if(largeObjFileHandle != NULL)
+ {
+
+ if(largeObjFileHandle->seek(XPL_FS_SEEK_SET, largeObjectBufferUsedSize) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ if(largeObjFileHandle->read( oSendData.getBuffer() , bufSize) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ oSendData.setSize(bufSize);
+ }
+ else
+ {
+ UINT8 *pEncData = NULL;
+ UINT32 encLen =0;
+ // Allocate buffer for binary data encoding
+ if(m_bBinary)
+ {
+ encLen = base64GetSize(bufSize);
+ pEncData = (UINT8 *)DmAllocMem(encLen + 1);
+
+ if (pEncData == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ memset(pEncData, 0, encLen + 1);
+ }
+ m_pChunkData->GetChunkData(&bufp); // the chunk data is available
+
+ while (true)
+ {
+ retStatus = GetChunkDataFromEngine();
+ if( retStatus != SYNCML_DM_SUCCESS)
+ {
+ if(pEncData != NULL)
+ DmFreeMem(pEncData);
+ return retStatus;
+ }
+ m_pChunkData->GetReturnLen(largeObjectChunkSize);
+ if(largeObjectChunkSize == 0)
+ break;
+ // Is binary data?
+ if( pEncData != NULL)
+ {
+ UINT32 offset = 0;
+ UINT32 dataSize = largeObjectChunkSize;
+ UINT32 encSize = base64Encode (pEncData, encLen,
+ (DataBuffer_t)bufp,
+ (BufferSize_t *)&dataSize,
+ (BufferSize_t *)&offset, 0, NULL);
+ largeObjectChunkSize = encSize;
+ oSendData.append(pEncData, encSize);
+ }
+ else
+ oSendData.append(bufp, largeObjectChunkSize);
+
+ }
+ if(pEncData != NULL)
+ DmFreeMem(pEncData);
+
+ }
+ return retStatus;
+}
+/*==================================================================================================
+FUNCTION : BuildLargeObjectDataNext
+
+DESCRIPTION : Build the <data> item for the next chunk of a Large Object
+ package.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildLargeObjectDataNext(SmlResultsPtr_t & p_results, int dataBufferSize)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMBuffer sendData;
+ SmlItemListPtr_t p_results_list_item = p_results->itemList;
+ SmlItemPtr_t p_results_item = p_results_list_item->item;
+
+ sendData.allocate(dataBufferSize+1);
+ if ( sendData.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+
+ if(m_bESN)
+ {
+ dm_stat = GetChunkData(sendData, dataBufferSize);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ }
+ else
+ {
+ largeObjectBuffer.copyTo(largeObjectBufferUsedSize, dataBufferSize, sendData);
+ }
+ largeObjectBufferUsedSize += sendData.getSize();
+ p_results_item->flags |= SmlMoreData_f;
+
+ // Build data item
+ BuildPcData(p_results_item->data,
+ SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ sendData.getSize(),
+ sendData.getBuffer());
+ return dm_stat;
+}
+
+/*==================================================================================================
+FUNCTION : BuildLargeObjectDataLast
+
+DESCRIPTION : Build the <data> item for the last chunk of a Large Object
+ package.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::BuildLargeObjectDataLast(SmlResultsPtr_t & p_results, int size, BOOLEAN isFirstChunk)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMBuffer sendData;
+ SmlItemListPtr_t p_results_list_item = p_results->itemList;
+ SmlItemPtr_t p_results_item = p_results_list_item->item;
+ SmlMetInfMetInfPtr_t p_meta_info;
+
+ // Is ESN data?
+ if(m_bESN && size >0)
+ {
+ // Allocate the Large Object Buffer based on the size
+ sendData.allocate(size+1);
+ if ( sendData.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ dm_stat = GetChunkData(sendData, size);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ // If ESN data can hold one message
+ if(isFirstChunk )
+ {
+ largeObjectSize = sendData.getSize();
+ // Replace the <size> statement for binary data
+ if( m_bBinary && p_results_item->meta != NULL)
+ {
+ p_meta_info = (SmlMetInfMetInfPtr_t)p_results_item->meta->content;
+ if(p_meta_info != NULL && p_meta_info->size!= NULL && p_meta_info->size->content != NULL)
+ {
+ smlFreePcdata(p_meta_info->size);
+ p_meta_info->size = NULL;
+ dm_stat = BuildMetaSizeInfo(p_results_item->meta, sendData.getSize());
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ }
+
+ }
+ }
+ // Build data item
+ BuildPcData(p_results_item->data,
+ SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ sendData.getSize(),
+ sendData.getBuffer());
+
+ largeObjectBufferUsedSize += sendData.getSize();
+ if( largeObjectBufferUsedSize != largeObjectSize)
+ dm_stat = SYNCML_DM_SIZE_MISMATCH;
+
+ }
+ else
+ {
+ if(!isFirstChunk && size > 0)
+ {
+ // Copy all the remaining data
+ largeObjectBuffer.copyTo(largeObjectBufferUsedSize, size, sendData);
+ largeObjectBufferUsedSize += sendData.getSize();
+ if( largeObjectBufferUsedSize != largeObjectSize)
+ dm_stat = SYNCML_DM_SIZE_MISMATCH;
+
+ // Build data item
+ BuildPcData(p_results_item->data,
+ SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ sendData.getSize(),
+ sendData.getBuffer());
+
+
+ }
+ }
+ return dm_stat;
+}
+/*==================================================================================================
+FUNCTION : PrepareESNDataBuffer
+
+DESCRIPTION : Allocate ESN buffer and encoding binary data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::PrepareESNDataBuffer(UINT8 **pEncData, UINT32 & encLen , UINT8 **bufp)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ // Get chunk buffer
+ if(m_pChunkData == NULL)
+ { m_pChunkData = AllocateChunkBuffer();
+ if(m_pChunkData == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ m_pChunkData->GetChunkData(bufp); // the chunk data is available
+
+ // Allocate buffer for binary data encoding
+ if(m_bBinary)
+ {
+ encLen = base64GetSize((BufferSize_t)DmtDataChunk::GetChunkSize());
+ *pEncData = (UINT8 *)DmAllocMem(encLen + 1);
+
+ if (*pEncData == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ memset(*pEncData, 0, encLen + 1);
+ }
+ dm_stat =CreateESNTempFile();
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ {
+ if(*pEncData != NULL)
+ { DmFreeMem(*pEncData);
+ *pEncData = NULL;
+ }
+ }
+ return dm_stat;
+}
+
+/*==================================================================================================
+FUNCTION : GetESNData2TempFile
+
+DESCRIPTION : Read ESN data to a temporary file and encoding binary data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::GetESNData2TempFile(int & dataSize)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ UINT8 *pEncData = NULL;
+ UINT32 encLen =0;
+ UINT8 *bufp;
+
+ dm_stat = PrepareESNDataBuffer(&pEncData, encLen , &bufp);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ int offset =0;
+ UINT8 *tempPtr = bufp;
+ if( pEncData != NULL)
+ tempPtr = pEncData;
+ while (true)
+ {
+ dm_stat = GetChunkDataFromEngine();
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ goto getESNdatafailed;
+
+ m_pChunkData->GetReturnLen(largeObjectChunkSize);
+ if(largeObjectChunkSize == 0)
+ break;
+ if(largeObjFileHandle->seek(XPL_FS_SEEK_SET, offset) != SYNCML_DM_SUCCESS)
+ {
+ dm_stat = SYNCML_DM_IO_FAILURE;
+ goto getESNdatafailed;
+ }
+ // Is binary data?
+ if( pEncData != NULL)
+ {
+ UINT32 offset = 0;
+ UINT32 dataSize = largeObjectChunkSize;
+ UINT32 encSize = base64Encode (pEncData, encLen,
+ (DataBuffer_t) bufp,
+ (BufferSize_t *)&dataSize,
+ (BufferSize_t *)&offset, 0, NULL);
+ largeObjectChunkSize = encSize;
+ }
+ if(largeObjFileHandle->write((CPCHAR)tempPtr, largeObjectChunkSize) != SYNCML_DM_SUCCESS)
+ {
+ dm_stat = SYNCML_DM_IO_FAILURE;
+ goto getESNdatafailed;
+ }
+ offset += largeObjectChunkSize;
+ }
+ largeObjFileHandle->close();
+ delete largeObjFileHandle;
+ largeObjFileHandle = NULL;
+ if(pEncData != NULL)
+ DmFreeMem(pEncData);
+ dm_stat = OpenESNTempFile();
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto getESNdatafailed;
+
+// Real total size
+ dataSize = offset;
+
+ return dm_stat;
+ getESNdatafailed:
+ if(pEncData != NULL)
+ DmFreeMem(pEncData);
+ return dm_stat;
+}
+/*==================================================================================================
+FUNCTION : LargeObjectSendFirstChunk
+
+DESCRIPTION : PrepareSend result data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::LargeObjectSendFirstChunkNoSpace(SYNCML_DM_RESULT_VALUE &pResult ,int size , int dataBufferSize )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ SmlResultsPtr_t p_results = pResult._pGetExecResult;
+ if (p_results == NULL)
+ return (SYNCML_DM_FAIL);
+
+ SmlItemListPtr_t p_results_list_item = p_results->itemList;
+ SmlItemPtr_t p_results_item = p_results_list_item->item;
+
+ // Is Large Object supported?
+ if(!pDmMgmtSessionObj->IsLargeObjectSupported() || dataBufferSize<=0)
+ {
+ dm_stat = SYNCML_DM_RESULTS_TOO_LARGE;
+ return dm_stat;
+ }
+ dm_stat = GetLargeObjectTargetURI(p_results_item);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendNoSpacefailed;
+
+ if(m_bESN)
+ dm_stat = GetESNData2TempFile(size);
+
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendNoSpacefailed;
+
+ SmlMetInfMetInfPtr_t p_meta_info;
+ // At least <Size> meta information need to be built
+ if(p_results_item->meta == NULL)
+ p_results_item->meta = smlAllocPcdata();
+ if(p_results_item->meta == NULL)
+ {
+ dm_stat = SYNCML_DM_DEVICE_FULL;
+ goto sendNoSpacefailed;
+ }
+ // Save meta type information
+ p_meta_info = (SmlMetInfMetInfPtr_t)p_results_item->meta->content;
+ // Replace the <size> statement for binary data
+ if(p_meta_info != NULL && p_meta_info->size!= NULL && p_meta_info->size->content != NULL)
+ {
+ smlFreePcdata(p_meta_info->size);
+ p_meta_info->size = NULL;
+ }
+ // For Large Object delivery, <Size> must be built in first message
+ dm_stat = BuildMetaSizeInfo(p_results_item->meta, size);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendNoSpacefailed;
+
+ if(p_meta_info != NULL && p_meta_info->type!= NULL && p_meta_info->type->content != NULL)
+ largeObjectType.assign((CPCHAR)p_meta_info->type->content ,(INT32) p_meta_info->type->length);
+
+
+ largeObjectSize = size;
+ m_ChunkOffset = 0;
+ m_bProcessingLargeObject = TRUE;
+ largeObjectBufferUsedSize = 0;
+ largeObjectCmd = DM_COMMAND_RESULTS;
+ largeObjectChunkSize = 0;
+ largeObjectChunkOffset =0;
+
+ largeObjectCmdRef = pResult._cmdRef;
+ largeObjectMsgRef = pResult._msgID;
+ // Allocate the Large Object Buffer based on the size
+ if(dataBufferSize > size)
+ dataBufferSize = size;
+
+ // Data buffer already allocated
+ if(!m_bESN)
+ {
+ largeObjectBuffer.allocate(size+1);
+ if ( largeObjectBuffer.getBuffer() == NULL )
+ goto sendNoSpacefailed;
+ // Copy data in <data> to Large Object buffer
+ largeObjectBuffer.attach((UINT8 *)p_results_item->data->content ,size +1);
+ // Clear buffer pointer
+ p_results_item->data->content = NULL;
+ }
+ dm_stat = BuildLargeObjectDataNext(p_results, dataBufferSize);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendNoSpacefailed;
+
+ // Insert a result command
+ dm_stat = BuildResultsCommand(p_results);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendNoSpacefailed;
+
+ smlFreeResults(p_results);
+ pResult._pGetExecResult = NULL;
+
+ // No <Final> statement
+ dm_stat = SYNCML_DM_RESULTS_TOO_LARGE;
+ return dm_stat;
+
+sendNoSpacefailed:
+ if(p_results != NULL)
+ smlFreeResults(p_results);
+ pResult._pGetExecResult = NULL;
+ if(m_bProcessingLargeObject)
+ LargeObjectClear();
+ return dm_stat;
+
+}
+/*==================================================================================================
+FUNCTION : LargeObjectSendGetFreeSpace
+
+DESCRIPTION : Get free space left
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::LargeObjectSendGetFreeSpace( SmlResultsPtr_t p_results,
+ SmlItemPtr_t p_results_item ,
+ int &size ,
+ int &originalSize ,
+ int &dataBufferSize,
+ MemSize_t &freeSpace )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ size = 0;
+ originalSize = 0;
+ m_bESN = FALSE;
+ m_bBinary = FALSE;
+
+
+
+ // Raw data size
+ if(p_results_item != NULL && p_results_item->data != NULL)
+ { size = p_results_item->data->length;
+ originalSize = size;
+ p_results_item->data->length = 0;
+ }
+ // check the size
+ smlStartEvaluation(sendInstanceId);
+ smlResultsCmd(sendInstanceId, p_results);
+ smlEndEvaluation(sendInstanceId, &freeSpace);
+
+ // External Storage Node processing
+ if( p_results_item != NULL && p_results_item->flags & SmlESNData_f)
+ { m_bESN = TRUE;
+ // Always need to clearn up
+ m_bProcessingLargeObject = TRUE;
+ if( p_results_item->flags & SmlESNBinary_f)
+ m_bBinary = TRUE;
+ }
+ // Adjust for </moredata> statement <size>
+ dataBufferSize = freeSpace - 100;
+ freeSpace =freeSpace -size - 100;
+ return dm_stat;
+}
+/*==================================================================================================
+FUNCTION : LargeObjectSendFirstChunk
+
+DESCRIPTION : PrepareSend result data
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::LargeObjectSendFirstChunk(SYNCML_DM_RESULT_VALUE &pResult)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ SmlResultsPtr_t p_results = pResult._pGetExecResult;
+ SmlItemListPtr_t p_results_list_item = NULL;
+ SmlItemPtr_t p_results_item = NULL;
+ int size = 0;
+ int originalSize = 0;
+ int dataBufferSize = 0;
+
+
+ m_bESN = FALSE;
+ m_bBinary = FALSE;
+ DMBuffer sendData;
+ MemSize_t freeSpace = 0;
+
+ if( p_results == NULL)
+ return dm_stat;
+
+ p_results_list_item = p_results->itemList;
+ p_results_item = p_results_list_item->item;
+
+ dm_stat = LargeObjectSendGetFreeSpace(p_results, p_results_item , size , originalSize , dataBufferSize, freeSpace );
+
+ // Are there any free buffer left? ( </MoreData>
+ if(freeSpace <=0)
+ {
+ // Is Large Object supported?
+ if(!pDmMgmtSessionObj->IsLargeObjectSupported() || dataBufferSize<=0)
+ {
+ dm_stat = SYNCML_DM_RESULTS_TOO_LARGE;
+ return dm_stat;
+ }
+ dm_stat = LargeObjectSendFirstChunkNoSpace( pResult , size, dataBufferSize );
+ }
+ else
+ {
+ // Restore the length field
+ if(p_results_item != NULL && p_results_item->data != NULL)
+ p_results_item->data->length = originalSize;
+
+ if(m_bESN)
+ { dm_stat = GetLargeObjectTargetURI(p_results_item);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendfirstchunkfailed;
+ m_bProcessingLargeObject = TRUE;
+
+ }
+ dm_stat = BuildLargeObjectDataLast(p_results, size,TRUE);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ // Insert a result command
+ dm_stat = BuildResultsCommand(p_results);
+ smlFreeResults(p_results);
+ pResult._pGetExecResult = NULL;
+ if(m_bProcessingLargeObject)
+ LargeObjectClear();
+
+ }
+ return dm_stat;
+
+sendfirstchunkfailed:
+ if(p_results != NULL)
+ smlFreeResults(p_results);
+ pResult._pGetExecResult = NULL;
+ if(m_bProcessingLargeObject)
+ LargeObjectClear();
+ return dm_stat;
+
+}
+
+/*==================================================================================================
+FUNCTION : AllocateLargeObjectResult
+
+DESCRIPTION : Allocates and fill in memory structure for result
+ package.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::AllocateLargeObjectResult(SmlResultsPtr_t & p_results)
+{
+ p_results = smlAllocResults();
+ if ( !p_results )
+ return SYNCML_DM_DEVICE_FULL;
+
+ SmlItemListPtr_t p_results_list_item = p_results->itemList;
+ SmlItemPtr_t p_results_item = p_results_list_item->item;
+
+ p_results_item->source = smlAllocSource();
+ if ( p_results_item->source == NULL )
+ {
+ smlFreeResults(p_results);
+ p_results = NULL;
+ return (SYNCML_DM_FAIL);
+ }
+
+ BuildPcData( p_results_item->source->locURI,
+ SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ largeObjectTURI.getSize(),
+ (UINT8*)largeObjectTURI.getBuffer());
+
+ /* Set receiving package command id reference */
+ BuildPcData(p_results->cmdRef, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ largeObjectCmdRef.length(),
+ (UINT8*)largeObjectCmdRef.c_str());
+
+ CPCHAR sMsg = largeObjectMsgRef.c_str();
+ BuildPcDataWAllocMem(&p_results->msgRef,DmStrlen(sMsg),(UINT8*)sMsg);
+
+ if(largeObjectType.getSize() !=0)
+ {
+ if ((p_results_item->meta = smlAllocPcdata()) != NULL)
+ BuildMetaInfo(p_results_item->meta,
+ NULL,
+ (UINT8*)largeObjectType.getBuffer(),
+ NULL,
+ NULL,
+ NULL, NULL, NULL, NULL);
+ }
+
+ p_results_item->data = smlAllocPcdata();
+ if ( !p_results_item->data )
+ return SYNCML_DM_DEVICE_FULL;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+FUNCTION : LargeObjectSendNextChunk
+
+DESCRIPTION : Send next Large Object chunk data
+ package.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+BOOLEAN
+SYNCML_DM_BuildPackage::LargeObjectSendNextChunk(SYNCML_DM_RET_STATUS_T &dm_stat, BOOLEAN &isLastChunk )
+{
+ DMBuffer sendData;
+
+ isLastChunk = FALSE;
+
+ if (!m_bProcessingLargeObject || largeObjectCmd != DM_COMMAND_RESULTS)
+ {
+ dm_stat = SYNCML_DM_SUCCESS;
+ return FALSE;
+ }
+
+ SmlResultsPtr_t p_results = NULL;
+ int size = largeObjectSize - largeObjectBufferUsedSize;
+ int dataBufferSize = 0;
+
+ isLastChunk = TRUE;
+ // Need to send result back to server
+ pDmMgmtSessionObj->IncCommandCount();
+
+ dm_stat = AllocateLargeObjectResult(p_results);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+{ if(p_results != NULL)
+ smlFreeResults(p_results);
+ return FALSE;
+
+ }
+
+ // check the size
+ MemSize_t freeSpace = 0;
+
+ smlStartEvaluation(sendInstanceId);
+ smlResultsCmd(sendInstanceId, p_results);
+ smlEndEvaluation(sendInstanceId, &freeSpace);
+
+ // Adjust for </MoreData>
+ dataBufferSize = freeSpace - 100;
+ freeSpace =freeSpace -size - 100;
+ // Are there any free buffer left?
+ if(freeSpace <= 0)
+ {
+ if(dataBufferSize > size)
+ dataBufferSize = size;
+
+ dm_stat = BuildLargeObjectDataNext(p_results, dataBufferSize);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendchunkfailed;
+
+ // Insert a result command
+ dm_stat = BuildResultsCommand(p_results);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendchunkfailed;
+
+ smlFreeResults(p_results);
+ p_results = NULL;
+ dm_stat = SYNCML_DM_RESULTS_TOO_LARGE;
+ }
+ else
+ {
+ dm_stat = BuildLargeObjectDataLast(p_results, size,FALSE);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendchunkfailed;
+
+ // Insert a result command
+ dm_stat = BuildResultsCommand(p_results);
+
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ goto sendchunkfailed;
+
+ smlFreeResults(p_results);
+ LargeObjectClear();
+ return FALSE;
+ }
+ return TRUE;
+
+sendchunkfailed:
+ if(p_results != NULL)
+ smlFreeResults(p_results);
+
+ if(m_bProcessingLargeObject)
+ LargeObjectClear();
+ return FALSE;
+
+}
+
+/*==================================================================================================
+FUNCTION : GenerateAlertForLOB
+
+DESCRIPTION : Generate alert in error conditions.
+ package.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+
+ SYNCML_DM_RET_STATUS_T SYNCML_DM_BuildPackage::GenerateAlertForLOB(DMCommandType currentComm)
+ {
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ if(m_bProcessingLargeObject)
+ {
+ if(currentComm != largeObjectCmd)
+ {
+ BuildAlertCommand(DM_ALERT_END_OF_DATA_NOT_RECEIVED, NULL,(CPCHAR) largeObjectTURI.getBuffer());
+ LargeObjectClear();
+ dm_stat = SYNCML_DM_INCOMPLETE_COMMAND;
+ }
+ }
+ return dm_stat;
+ }
+
+// End of defination of LOB_SUPPORT
+#endif
+
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::GetClientAuthValues( const DMString& device_id,
+ const DMString& server_id,
+ DMString& client_name,
+ DMString& client_password )
+{
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_SUCCESS;
+
+ for( ; ; )
+ {
+ SYNCML_DM_FACTORY_BOOTSTRAP_T bootstrapCode = GetBootStrapCodeUserName( client_name );
+
+ if( SYNCML_DM_FACTORY_BOOTSTRAP_UNKNOWN != bootstrapCode )
+ {
+ result = CreateFactoryBootStrapUserName( bootstrapCode,
+ server_id,
+ device_id,
+ client_name );
+ if (SYNCML_DM_SUCCESS != result ) break;
+ }
+
+ SYNCML_DM_FACTORY_BOOTSTRAP_T clientPWCode = GetBootStrapCodeClientPW( client_password );
+
+ if( SYNCML_DM_FACTORY_BOOTSTRAP_UNKNOWN != clientPWCode )
+ {
+ result = CreateFactoryBootStrapClientPW( clientPWCode,
+ server_id,
+ device_id,
+ client_password );
+
+ if (SYNCML_DM_SUCCESS != result ) break;
+ }
+
+ break;
+ }
+
+ return result;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::GetServerAuthValues( const DMString& device_id,
+ const DMString& server_id,
+ DMString& server_password )
+{
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_SUCCESS;
+
+ for( ; ; )
+ {
+ SYNCML_DM_FACTORY_BOOTSTRAP_T serverPWCode = GetBootStrapCodeServerPW( server_password );
+ if ( SYNCML_DM_FACTORY_BOOTSTRAP_UNKNOWN != serverPWCode )
+ {
+
+ result = CreateFactoryBootStrapServerPW( serverPWCode,
+ server_id,
+ device_id,
+ server_password );
+ if (SYNCML_DM_SUCCESS != result ) break;
+ }
+
+ break;
+ }
+
+ return result;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_BuildPackage::GetDeviceID( DMString& device_id )
+{
+ DMGetData devID;
+ SYNCML_DM_RET_STATUS_T result = dmTreeObj.Get(DM_DEV_INFO_DEVID_URI, devID, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if( ( SYNCML_DM_SUCCESS == result ) &&
+ ( devID.m_oData.getSize() != 0 ) )
+ {
+ device_id = GetIMEINumber( devID.getCharData() );
+ }
+
+ return result;
+ }
+
+//SessionId option/FLEX is flexible feature.
+//TRUE - Session id will be converted into hex format which will be used for Dm sessions
+//FALSE - Session id will be in decimal format which will be used for Dm sessions
+ //PATH,Value Stored : ./DevDetail/Ext/Conf/PMF/Agents/syncmldm/Sessionid
+
+BOOLEAN
+SYNCML_DM_BuildPackage::IsSessionId()
+{
+
+ CPCHAR path = XPL_DM_GetEnv(SYNCML_DM_SESSION_ID);
+ if ( !path )
+ return TRUE;
+
+ DMGetData sessionId;
+ SYNCML_DM_RET_STATUS_T result = dmTreeObj.Get(path,
+ sessionId,
+ SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if( result != SYNCML_DM_SUCCESS )
+ return TRUE;
+
+ return sessionId.m_oData.compare("true");
+
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_ChoiceAlert.cc b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_ChoiceAlert.cc
new file mode 100644
index 0000000..94686dd
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_ChoiceAlert.cc
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: SYNCML_DM_ChoiceAlert.cc
+
+ General Description: A class representing the alerts.
+
+==================================================================================================*/
+
+#include "dmStringUtil.h"
+#include "SYNCML_DM_ChoiceAlert.H"
+
+void SYNCML_DM_ChoiceAlert::parse(SmlAlertPtr_t pContent)
+{
+
+ SmlItemListPtr_t p_alert_list_item;
+
+ if ( pContent == NULL )
+ return;
+
+ SYNCML_DM_Alert::parse(pContent);
+
+ p_alert_list_item = pContent->itemList;
+
+ if (p_alert_list_item != NULL && p_alert_list_item->next != NULL )
+ parseChoices(p_alert_list_item->next->next);
+}
+
+
+void SYNCML_DM_ChoiceAlert::parseChoices(SmlItemListPtr_t p_alert_list_item)
+{
+ SmlItemPtr_t p_alert_item;
+ SmlPcdataPtr_t p_alert_data;
+
+ while (p_alert_list_item != NULL)
+ {
+ p_alert_item = p_alert_list_item->item;
+ p_alert_data = p_alert_item->data;
+
+ addChoice((CPCHAR)p_alert_data->content);
+ p_alert_list_item = p_alert_list_item->next;
+ }
+}
+
+void SYNCML_DM_ChoiceAlert::addChoice(const char* choice)
+{
+ choices.push_back(choice);
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_ConfirmAlert.cc b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_ConfirmAlert.cc
new file mode 100644
index 0000000..4ffef2b
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_ConfirmAlert.cc
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: SYNCML_DM_ConfirmAlert.cc
+
+ General Description: A class representing the alerts.
+
+==================================================================================================*/
+
+#include "dmStringUtil.h"
+#include "dmtoken.h"
+#include "SYNCML_DM_ConfirmAlert.H"
+
+SYNCML_DM_ConfirmAlert::SYNCML_DM_ConfirmAlert()
+{
+ defaultResponse = XPL_DM_ALERT_RES_NONE;
+ responseCode = XPL_DM_ALERT_RES_TIMEOUT;
+}
+
+void SYNCML_DM_ConfirmAlert::processParameter(CPCHAR name, CPCHAR value)
+{
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_MAXDT) == 0 )
+ setMaxDisplayTime(DmAtoi(value));
+ else
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_DEFAULT_RESPONSE) == 0 )
+ {
+ defaultResponse = (XPL_DM_ALERT_RES_T)DmAtoi(value);
+ if (defaultResponse == 0)
+ defaultResponse = XPL_DM_ALERT_RES_NO;
+ else
+ if (defaultResponse == 1)
+ defaultResponse = XPL_DM_ALERT_RES_YES;
+ XPL_LOG_DM_SESS_Debug (("SYNCML_DM_ConfirmAlert::processParamete : defaultResponse = %d \n", defaultResponse));
+ }
+}
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_ConfirmAlert::show()
+{
+
+ return XPL_DM_ShowConfirmAlert(maxDisplayTime, msg, defaultResponse, &responseCode);
+}
+
+XPL_DM_ALERT_RES_T SYNCML_DM_ConfirmAlert::getAction() const
+{
+ return responseCode;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_ConfirmAlert::getDefaultResponse(DMStringVector & userResponse) const
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_ConfirmAlert::getResponse(DMStringVector & userResponse) const
+{
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_DisplayAlert.cc b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_DisplayAlert.cc
new file mode 100644
index 0000000..5c76fa4
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_DisplayAlert.cc
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: SYNCML_DM_DisplayAlert.cc
+
+ General Description: A class representing the alerts.
+
+==================================================================================================*/
+
+#include "dmStringUtil.h"
+#include "dm_uri_utils.h"
+#include "dmtoken.h"
+#include "SYNCML_DM_DisplayAlert.H"
+
+void SYNCML_DM_DisplayAlert::processParameter(CPCHAR name, CPCHAR value)
+{
+ if (DmStrcmp(name,SYNCML_DM_ALERT_OPTION_MINDT) == 0)
+ setMinDisplayTime(DmAtoi(value));
+}
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_DisplayAlert::show()
+{
+ return XPL_DM_ShowDisplayAlert(minDisplayTime,msg);
+}
+
+
+XPL_DM_ALERT_RES_T SYNCML_DM_DisplayAlert::getAction() const
+{
+ return XPL_DM_ALERT_RES_YES;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_DisplayAlert::getDefaultResponse(DMStringVector & userResponse) const
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_DisplayAlert::getResponse(DMStringVector & userResponse) const
+{
+ return SYNCML_DM_SUCCESS;
+}
+
diff --git a/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_MultipleChoiceAlert.cc b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_MultipleChoiceAlert.cc
new file mode 100644
index 0000000..3cb95b3
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_MultipleChoiceAlert.cc
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: SYNCML_DM_MultipleChoiceAlert.cc
+
+ General Description: A class representing the alerts.
+
+==================================================================================================*/
+
+#include "dmStringUtil.h"
+#include "dm_uri_utils.h"
+#include "dmtoken.h"
+#include "SYNCML_DM_MultipleChoiceAlert.H"
+
+SYNCML_DM_MultipleChoiceAlert::SYNCML_DM_MultipleChoiceAlert()
+{
+ response.action = XPL_DM_ALERT_RES_TIMEOUT;
+}
+
+void SYNCML_DM_MultipleChoiceAlert::processParameter(CPCHAR name, CPCHAR value)
+{
+
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_MAXDT) == 0 )
+ setMaxDisplayTime(DmAtoi(value));
+ else
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_DEFAULT_RESPONSE) == 0 )
+ parseDefaultResponses(value);
+}
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_MultipleChoiceAlert::show()
+{
+
+ return XPL_DM_ShowMultipleChoiceAlert(maxDisplayTime, msg, choices, defaultResponses, &response);
+
+}
+
+void SYNCML_DM_MultipleChoiceAlert::parseDefaultResponses(CPCHAR defaultResponses)
+{
+ DMToken token(FALSE,defaultResponses,',');
+ CPCHAR pSegment = token.nextSegment();
+ while( pSegment != NULL )
+ {
+ if ( NULL == strchr(pSegment, '-') ) {
+ this->defaultResponses.push_back(pSegment);
+ }
+ else {
+ DMToken dtoken(FALSE,defaultResponses,'-');
+ CPCHAR pdSegment = dtoken.nextSegment();
+
+ int first = atoi(pdSegment);
+
+ pdSegment = dtoken.nextSegment();
+ if ( NULL == pdSegment ) {
+ pSegment = token.nextSegment();
+ continue;
+ }
+
+ int last = atoi(pdSegment);
+
+ pdSegment = dtoken.nextSegment();
+ if ( NULL != pdSegment ) {
+ pSegment = token.nextSegment();
+ continue;
+ }
+
+ char idx[4]; // Max 3 digits index by default;
+ if((first >=0) && (last >= 0))
+ {
+ for ( first; first <= last; first++ ) {
+ snprintf(idx, 4, "%d", first);
+ this->defaultResponses.push_back(idx);
+ }
+ }
+ }
+ pSegment = token.nextSegment();
+ }
+}
+
+XPL_DM_ALERT_RES_T SYNCML_DM_MultipleChoiceAlert::getAction() const
+{
+ return response.action;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_MultipleChoiceAlert::getDefaultResponse(DMStringVector & userResponse) const
+{
+ userResponse = defaultResponses;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_MultipleChoiceAlert::getResponse(DMStringVector & userResponse) const
+{
+ userResponse = response.responses;
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_SingleChoiceAlert.cc b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_SingleChoiceAlert.cc
new file mode 100644
index 0000000..126dc7a
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_SingleChoiceAlert.cc
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: SYNCML_DM_SingleChoiceAlert.cc
+
+ General Description: A class representing the alerts.
+
+==================================================================================================*/
+
+#include "dmStringUtil.h"
+#include "dmtoken.h"
+#include "SYNCML_DM_SingleChoiceAlert.H"
+
+SYNCML_DM_SingleChoiceAlert::SYNCML_DM_SingleChoiceAlert()
+{
+ defaultResponse = -1;
+ response.action = XPL_DM_ALERT_RES_TIMEOUT;
+}
+
+
+void SYNCML_DM_SingleChoiceAlert::processParameter(CPCHAR name, CPCHAR value)
+{
+
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_MAXDT) == 0 )
+ setMaxDisplayTime(DmAtoi(value));
+ else
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_DEFAULT_RESPONSE) == 0 )
+ defaultResponse = DmAtoi(value);
+}
+
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_SingleChoiceAlert::show()
+{
+ return XPL_DM_ShowSingleChoiceAlert(maxDisplayTime, msg, choices, defaultResponse, &response);
+}
+
+XPL_DM_ALERT_RES_T SYNCML_DM_SingleChoiceAlert::getAction() const
+{
+ return response.action;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_SingleChoiceAlert::getDefaultResponse(DMStringVector & userResponse) const
+{
+ if (defaultResponse != -1)
+ {
+ char selection[UINT32_TYPE_STR_SIZE_10];
+ DmSprintf((char *)selection, "%d", defaultResponse );
+ userResponse.push_back(selection);
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_SingleChoiceAlert::getResponse(DMStringVector & userResponse) const
+{
+ char selection[UINT32_TYPE_STR_SIZE_10];
+ DmSprintf((char *)selection, "%d", response.response );
+ userResponse.push_back(selection);
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_TextInputAlert.cc b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_TextInputAlert.cc
new file mode 100644
index 0000000..2b0029c
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/SYNCML_DM_TextInputAlert.cc
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: SYNCML_DM_TextInputAlert.cc
+
+ General Description: A class representing the alerts.
+
+==================================================================================================*/
+
+#include "SYNCML_DM_TextInputAlert.H"
+#include "dmStringUtil.h"
+#include "dmtoken.h"
+
+
+SYNCML_DM_TextInputAlert::SYNCML_DM_TextInputAlert()
+{
+ maxLength = 20;
+ inputType = XPL_DM_ALERT_I_ALPHA;
+ echoType = XPL_DM_ALERT_E_TEXT;
+ response.action = XPL_DM_ALERT_RES_TIMEOUT;
+}
+
+
+void SYNCML_DM_TextInputAlert::processParameter(CPCHAR name, CPCHAR value)
+{
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_MAXDT) == 0 )
+ setMaxDisplayTime(DmAtoi(value));
+ else
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_DEFAULT_RESPONSE) == 0 )
+ defaultResponse = value;
+ else
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_MAX_LENGTH) == 0 )
+ maxLength = DmAtoi(value);
+ else
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_INPUT_TYPE) == 0 )
+ inputType = convertInputType(value);
+ else
+ if ( DmStrcmp(name,SYNCML_DM_ALERT_OPTION_ECHO_TYPE) == 0 )
+ echoType = convertEchoType(value);
+}
+
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_TextInputAlert::show()
+{
+
+ SYNCML_DM_RET_STATUS_T ret_status;
+
+ defaultResponse.replaceAll('+',' ');
+ ret_status = XPL_DM_ShowTextInputAlert(maxDisplayTime, msg,defaultResponse,
+ maxLength, inputType, echoType, &response );
+
+ defaultResponse.replaceAll(' ','+');
+ if ( ret_status == SYNCML_DM_SUCCESS )
+ {
+ response.response.replaceAll(' ','+');
+ }
+
+ return ret_status;
+}
+
+XPL_DM_ALERT_RES_T SYNCML_DM_TextInputAlert::getAction() const
+{
+ return response.action;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_TextInputAlert::getDefaultResponse(DMStringVector & userResponse) const
+{
+ userResponse.push_back(defaultResponse);
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_TextInputAlert::getResponse(DMStringVector & userResponse) const
+{
+ userResponse.push_back(response.response);
+ return SYNCML_DM_SUCCESS;
+}
+
+
+XPL_DM_ALERT_INPUT_T SYNCML_DM_TextInputAlert::convertInputType(CPCHAR inputType) {
+
+ if (DmStrcmp(inputType,SYNCML_DM_ALERT_OPTION_IT_A) == 0)
+ {
+ return XPL_DM_ALERT_I_ALPHA;
+ }
+ else
+ if (DmStrcmp(inputType,SYNCML_DM_ALERT_OPTION_IT_N) == 0)
+ {
+ return XPL_DM_ALERT_I_NUMERIC;
+ }
+ else
+ if (DmStrcmp(inputType,SYNCML_DM_ALERT_OPTION_IT_D) == 0)
+ {
+ return XPL_DM_ALERT_I_DATE;
+ }
+ else
+ if (DmStrcmp(inputType,SYNCML_DM_ALERT_OPTION_IT_T) == 0)
+ {
+ return XPL_DM_ALERT_I_TIME;
+ }
+ else
+ if (DmStrcmp(inputType,SYNCML_DM_ALERT_OPTION_IT_P) == 0)
+ {
+ return XPL_DM_ALERT_I_PHONE_NUM;
+ }
+ else
+ if (DmStrcmp(inputType,SYNCML_DM_ALERT_OPTION_IT_I) == 0)
+ {
+ return XPL_DM_ALERT_I_IP_ADDR;
+ }
+ return XPL_DM_ALERT_I_ALPHA;
+}
+
+XPL_DM_ALERT_ECHO_T SYNCML_DM_TextInputAlert::convertEchoType(CPCHAR echoType) {
+ if (DmStrcmp(echoType,SYNCML_DM_ALERT_OPTION_ET_T) == 0)
+ {
+ return XPL_DM_ALERT_E_TEXT;
+ }
+ else {
+ if (DmStrcmp(echoType,SYNCML_DM_ALERT_OPTION_ET_P) == 0)
+ {
+ return XPL_DM_ALERT_E_PASSWD;
+ }
+ }
+ return XPL_DM_ALERT_E_TEXT;
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/dmBootstrapSession.cc b/engine/dmlib/dmengine/dm_ssession/src/dmBootstrapSession.cc
new file mode 100644
index 0000000..e0d11d6
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/dmBootstrapSession.cc
@@ -0,0 +1,441 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Header Name: dmExractServerIDSession.cc
+
+ General Description: Implementation of DMBootstrapSession class.
+
+==================================================================================================*/
+
+#include "dmBootstrapSession.h"
+#include "dm_ua_handlecommand.h"
+#include "xpl_Logger.h"
+#include "dmProcessScriptSession.h"
+#include "dmClientSrvCreds.h"
+
+extern "C" {
+#include <sml.h>
+#include <smldtd.h>
+#include <smldevinfdtd.h>
+#include <smlmetinfdtd.h>
+#include <mgrutil.h>
+#include <smlerr.h>
+}
+
+/*==================================================================================================
+ SOURCE FUNCTIONS
+==================================================================================================*/
+
+static Ret_t
+HandleBootstrapStartMessage (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlSyncHdrPtr_t pContent);
+
+
+static Ret_t
+HandleBootstrapChkAddCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlAddPtr_t pContent);
+
+/*==================================================================================================
+FUNCTION : DMBootstrapSession::SessionStart
+
+DESCRIPTION : The UserAgen::SessionStart calls this function after it creates MgmtSession object.
+ The function will perform the following operations:
+ 1) Call SessionStart() to setup the DM tree.
+ 2) Register the DM engine with the SYNCML toolkit.
+ 3) Connect the client with the server.
+ 4) Build and send the package one.
+ARGUMENT PASSED : p_SessionStart
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMBootstrapSession::Start(const UINT8 *docInputBuffer ,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ DMString & serverID)
+{
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_FAIL;
+ Ret_t sml_ret_stat;
+
+ XPL_LOG_DM_SESS_Debug(("Entered DMBootstrapSession::SessionStart\n"));
+
+#ifdef DM_BOOTSTRAP_DEBUG
+ FILE *fp = fopen("/tmp/dm_triage.dat", "w");
+ fwrite(docInputBuffer, sizeof(char), inDocSize, fp);
+ fclose(fp);
+#endif
+
+ ret_stat = Init(isWBXML);
+ if ( ret_stat != SYNCML_DM_SUCCESS )
+ return ret_stat;
+
+ /* Register the DM engine with the SYNCML toolkit. */
+ ret_stat = RegisterDmEngineWithSyncmlToolkit(&serverID);
+ if ( ret_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_SESS_Debug(("Exiting: RegisterDmEngineWithSyncmlToolkit failed\n"));
+ return (ret_stat);
+ }
+
+ sml_ret_stat = smlLockWriteBuffer(recvInstanceId, &pWritePos, &workspaceFreeSize);
+
+ if ( sml_ret_stat != SML_ERR_OK )
+ return SYNCML_DM_FAIL;
+
+ memcpy(pWritePos,docInputBuffer,inDocSize);
+
+ smlUnlockWriteBuffer(recvInstanceId, inDocSize);
+
+ smlProcessData(recvInstanceId, SML_ALL_COMMANDS);
+
+ if ( serverID.GetBuffer() == NULL )
+ return SYNCML_DM_FAIL;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+/*==================================================================================================
+FUNCTION : DMSession::SetToolkitCallbacks
+
+DESCRIPTION : This function will to set toolkit callback functions.
+
+
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : It returns SYNCML_DM_SUCCESS.
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMBootstrapSession::SetToolkitCallbacks(SmlCallbacks_t * pSmlCallbacks)
+{
+ pSmlCallbacks->startMessageFunc = HandleBootstrapStartMessage;
+ pSmlCallbacks->addCmdFunc = HandleBootstrapChkAddCommand;
+ return (SYNCML_DM_SUCCESS);
+}
+
+
+
+/*========================= C FUNCTIONS USED BY THE SYNCML TOOLKIT FOR BOOTSTRAP =================*/
+/*==================================================================================================
+FUNCTION : HandleBootstrapStartMessage (C function)
+
+DESCRIPTION : This function should analyze SyncHeader data from received DM document.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleBootstrapStartMessage (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlSyncHdrPtr_t pContent)
+{
+
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ dm_stat = VerifyProtocolVersion(pContent);
+
+ smlFreeSyncHdr(pContent);
+
+ if ( dm_stat == SYNCML_DM_FAIL )
+ return (SML_ERR_XLT_INVAL_SYNCML_DOC);
+ else
+ return (SML_ERR_OK);
+}
+
+/*==================================================================================================
+FUNCTION : BootstrapChkTndsServerID
+
+DESCRIPTION : The utility function is to check Server ID from TNDS object.
+
+ARGUMENT PASSED : p_meta_info
+OUTPUT PARAMETER: pp_type
+ p_format
+RETURN VALUE : SYNCML_DM_RET_STATUS_T
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T BootstrapChkTndsServerID(
+ SmlDmTndNodeListPtr_t p_nodelist,
+ DMString &serverID)
+{
+ SYNCML_DM_RET_STATUS_T ret = SYNCML_DM_FAIL;
+ while ( NULL != p_nodelist && ret != SYNCML_DM_SUCCESS )
+ {
+ SmlDmTndNodePtr_t p_tnd_node = p_nodelist->node;
+ if ( p_tnd_node != NULL )
+ {
+ DMString nodeName;
+ nodeName =(CPCHAR)p_tnd_node->nodename->content;
+
+ KCDBG("TNDS Node Name: %s", nodeName.c_str());
+
+ if ( nodeName == DM_SERVERID_1_2 )
+ {
+ if ( NULL == p_tnd_node->value )
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+
+ if ( strncmp((CPCHAR)p_tnd_node->value->content, DM_INBOX, strlen(DM_INBOX)) == 0 )
+ {
+ serverID = (CPCHAR)p_tnd_node->value->content + strlen(DM_INBOX) + 1;
+ }
+ else
+ {
+ serverID = (CPCHAR)p_tnd_node->value->content;
+ }
+
+ return SYNCML_DM_SUCCESS;
+ }
+ ret = BootstrapChkTndsServerID(p_tnd_node->nodelist, serverID);
+ }
+
+ // Process sibling node
+ p_nodelist = p_nodelist->next;
+ }
+
+ return ret;
+}
+
+/*==================================================================================================
+FUNCTION : BootstrapChkSetMetaData
+
+DESCRIPTION : The utility function to set up the meta data.
+
+ARGUMENT PASSED : p_meta_info
+OUTPUT PARAMETER: pp_type
+ p_format
+RETURN VALUE : SYNCML_DM_RET_STATUS_T
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T BootstrapChkSetMetaData(SmlPcdataPtr_t p_meta_data,
+ DMBuffer& pp_type,
+ SYNCML_DM_FORMAT_T *p_format)
+{
+ SmlMetInfMetInfPtr_t p_meta_info;
+ CPCHAR p_temp_content;
+
+ /* Setup OUTPUT parameter type and format. If p_meta_data is not set, assign default value
+ to OUTPUT parameters, type as "text/plain", format as "chr". */
+ if (p_meta_data != NULL)
+ {
+ if (p_meta_data->content != NULL)
+ {
+ if ( SML_PCDATA_EXTENSION != p_meta_data->contentType &&
+ SML_EXT_METINF != p_meta_data->extension )
+ {
+ *p_format = SYNCML_DM_FORMAT_CHR;
+ pp_type.assign("text/plain");
+ }
+ else
+ {
+ p_meta_info = (SmlMetInfMetInfPtr_t)p_meta_data->content;
+ if ((p_meta_info->format != NULL) &&
+ (p_meta_info->format->length != 0))
+ {
+ p_temp_content = (CPCHAR)p_meta_info->format->content;
+ *p_format = DMTree::ConvertFormatStr(p_temp_content);
+ }
+ else
+ {
+ /* If there is no format information, set p_format as default format "chr" */
+ *p_format = SYNCML_DM_FORMAT_CHR;
+ }
+ /* Set p_temp_type to the passed in type */
+ if((p_meta_info->type != NULL) && (p_meta_info->type->length != 0))
+ {
+ pp_type.assign((UINT8*)p_meta_info->type->content,p_meta_info->type->length);
+ }
+ else
+ {
+ /* If there is no type information, set the type as 'text/plain' */
+ pp_type.assign("text/plain");
+ }
+ }
+ }
+ }
+ else
+ {
+ *p_format = SYNCML_DM_FORMAT_CHR;
+ pp_type.assign("text/plain");
+ }
+
+ if ( pp_type.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+Function: HandleBootstrapChkAddCommand (C function)
+
+Description: When the ADD element is processed from Bootstrap, this callback function
+ will be called.
+
+ This function will perform the following operations:
+ 1) Call the BootstrapObj.SetServerId with the value in the Bootstrap ADD item.
+
+==================================================================================================*/
+Ret_t
+HandleBootstrapChkAddCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlAddPtr_t pContent)
+{
+ DMString *pServerID = (DMString*)userData;
+ char *pTempNodeName = NULL;
+ SmlItemListPtr_t p_add_list_item = NULL;
+ SmlItemPtr_t p_add_item = NULL;
+ BOOLEAN isDmVer12 = dmTreeObj.IsVersion_12();
+
+ KCDBG("DMBootstrapSession::HandleBootstrapChkAddCommand: Enter");
+
+ /* The Bootstrap message must have a commandId of 1.*/
+ if (smlLibStrcmp((const char*)pContent->cmdID->content, "1") != 0)
+ {
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+ return (SML_ERR_XLT_INVAL_SYNCML_DOC);
+ }
+
+ p_add_list_item = pContent->itemList;
+ p_add_item = p_add_list_item->item;
+
+ while (p_add_item != NULL)
+ {
+#ifdef TNDS_SUPPORT
+ DMBuffer oCommandType;
+ SYNCML_DM_FORMAT_T commandFormat = SYNCML_DM_FORMAT_INVALID;
+
+ if ( isDmVer12 )
+ {
+ BootstrapChkSetMetaData(pContent->meta, oCommandType, &commandFormat);
+ KCDBG("DMBootstrapSession:: Command Meta Type: %s, Format : %d", oCommandType.getBuffer(), commandFormat);
+
+ if (p_add_item->meta != NULL)
+ {
+ BootstrapChkSetMetaData(p_add_item->meta, oCommandType, &commandFormat);
+ KCDBG("DMBootstrapSession:: Item Meta Type: %s, Format : %d", oCommandType.getBuffer(), commandFormat);
+ }
+
+ if ( ((SYNCML_DM_FORMAT_XML == commandFormat) && oCommandType.compare(SYNCML_CONTENT_TYPE_DM_TNDS_XML)) ||
+ ((SYNCML_DM_FORMAT_BIN == commandFormat) && oCommandType.compare(SYNCML_CONTENT_TYPE_DM_TNDS_WBXML)) )
+ {
+ KCDBG("DMBootstrapSession:: TNDS Bootstrap");
+
+ if ( NULL != p_add_item->data &&
+ NULL != p_add_item->data->content )
+ {
+ SmlDmTndPtr_t p_tnd_info = (SmlDmTndPtr_t)p_add_item->data->content;
+ SmlDmTndNodeListPtr_t p_nodelist = p_tnd_info->nodelist;
+ DMString serverID = NULL;
+ BootstrapChkTndsServerID(p_nodelist, serverID);
+ if ( NULL == serverID )
+ {
+ KCDBG("DMBootstrapSession:: Server ID not found");
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+ return (SML_ERR_XLT_INVAL_SYNCML_DOC);
+ }
+ KCDBG("DMBootstrapSession:: Server ID: %s", serverID.c_str());
+ (*pServerID) = serverID.c_str();
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+ return SML_ERR_OK;
+ }
+ else
+ {
+ KCDBG("DMBootstrapSession:: SML_ERR_XLT_INVAL_SYNCML_DOC");
+ if ( NULL == p_add_item )
+ {
+ KCDBG("DMBootstrapSession:: p_add_item is NULL");
+ }
+ else if ( NULL == p_add_item->data )
+ {
+ KCDBG("DMBootstrapSession:: p_add_item->data is NULL");
+ }
+ else if ( NULL == p_add_item->data->content )
+ {
+ KCDBG("DMBootstrapSession:: p_add_item->data->content is NULL");
+ }
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+ return (SML_ERR_XLT_INVAL_SYNCML_DOC);
+ }
+ }
+ }
+#endif
+
+ KCDBG("DMBootstrapSession:: Plain Profile Bootstrap");
+
+ /* Find the last '/' in the local URI.*/
+ pTempNodeName = (char *)strrchr((const char*)p_add_item->target->locURI->content, '/');
+
+ /* If there was no '/', just use the local URI. Other step forward one char past the '/'.*/
+ pTempNodeName = (pTempNodeName == NULL) ?
+ (char *)p_add_item->target->locURI->content : pTempNodeName + 1;
+
+ /* Check for the ServerId in the local URI for this item.*/
+ if ( isDmVer12 )
+ {
+ if (strcmp(pTempNodeName, DM_SERVERID_1_2) == 0)
+ {
+ /* Copy the ServerID data.*/
+ (*pServerID) = (CPCHAR)p_add_item->data->content;
+ break;
+ }
+ }
+ else
+ {
+ if (strcmp(pTempNodeName, DM_SERVERID_1_1) == 0)
+ {
+ /* Copy the ServerId data.*/
+ (*pServerID) = (CPCHAR)p_add_item->data->content;
+ break;
+ }
+
+ }
+
+ /* Move the pointers to the next item in the Add command, if there is a next item.*/
+ if (p_add_list_item->next != NULL)
+ {
+ p_add_list_item = p_add_list_item->next;
+ p_add_item = p_add_list_item->item;
+ }
+ else
+ {
+ p_add_item = NULL;
+ }
+ } /* End of while */
+
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+
+ return SML_ERR_OK;
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/dmClientSrvCreds.cc b/engine/dmlib/dmengine/dm_ssession/src/dmClientSrvCreds.cc
new file mode 100644
index 0000000..5597324
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/dmClientSrvCreds.cc
@@ -0,0 +1,629 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * Implementation for class DMClientServerCreds.
+ */
+
+#include "dmClientSrvCreds.h"
+#include "SYNCML_DM_BuildPackage.H"
+#include "xpl_dm_Manager.h"
+
+//------------------------------------------------------------------------
+// FUNCTION : constructor for class DMClientServerCreds
+// DESCRIPTION : This function inits integer members
+//
+// ARGUMENTS PASSED: none
+//
+// RETURN VALUE : none
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+DMClientServerCreds::DMClientServerCreds()
+{
+ LOGE("DMClientServerCreds::DMClientServerCreds()");
+ ServerChalType = AuthPrefCredType = SYNCML_DM_CHAL_UNDEFINED;
+ m_bAuthPrefUpdated = FALSE;
+
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : LoadInitialValues
+// DESCRIPTION : Loads initial values for client credentials based on
+// "AuthPref" node value or "Ext/LastAuthPref"
+//
+// ARGUMENTS PASSED: none
+//
+// RETURN VALUE : error code in case of failure, "SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMClientServerCreds::LoadInitialValues()
+{
+ LOGE("DMClientServerCreds::LoadInitialValues()");
+ // restore last used auth type for this server
+ m_bAuthPrefUpdated = FALSE;
+
+ DMGetData oData;
+ DMString strLastAuthPref;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_FAIL;
+
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ dm_stat = dmTreeObj.GetLastClientAuthType(pDMAccNodeName, oData );
+ LOGE("dmTreeObj.GetLastClientAuthType() returned %d\n", dm_stat);
+ }
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ strLastAuthPref = oData.getCharData();
+ LOGE("strLastAuthPref from GetLastClientAuthType = %s\n", strLastAuthPref.c_str());
+ }
+ else
+ { // try to get aauthpref if "last" is not available
+
+ DMString strUri = ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH ) +
+ DMString( DM_STR_SLASH ) +
+ pDMAccNodeName +
+ ( dmTreeObj.IsVersion_12()
+ ? DM_STR_SLASH DM_AAUTHPREF
+ : DM_STR_SLASH DM_AUTHPREF );
+
+ dm_stat = dmTreeObj.Get(strUri, oData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ strLastAuthPref = oData.getCharData();
+ LOGE("strLastAuthPref from dmTreeObj.Get(strUri...) = %s\n", strLastAuthPref.c_str());
+ }
+ }
+ LOGE("strLastAuthPref = %s\n", strLastAuthPref.c_str());
+
+ if( 0 == strLastAuthPref.length() )
+ {
+ strLastAuthPref = GetDefaultAuthType();
+ LOGE("strLastAuthPref from GetDefaultAuthType() = %s\n", strLastAuthPref.c_str());
+ dm_stat = SYNCML_DM_SUCCESS;
+ }
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ // load settings from tree
+ dm_stat = SetClientAuth( strLastAuthPref, TRUE);
+ LOGE("SetClientAuth(strLastAuthPref, TRUE) returns %d\n", dm_stat);
+ }
+
+ // server part is loaded whenever server credentials required
+ return dm_stat;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : SetPrefClientAuth
+// DESCRIPTION : Sets preferred AuthType for client and
+// reloads username/password/nonce from the tree
+//
+// ARGUMENTS PASSED: nClientAuthType - new auth type
+//
+// RETURN VALUE : error code in case of failure, "SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMClientServerCreds::SetPrefClientAuth( SYNCML_DM_CHAL_TYPE_T nClientAuthType )
+{
+ LOGE("DMClientServCreds::SetPrefClientAuth(%d): AuthPrefCredType == %d", nClientAuthType, AuthPrefCredType);
+ if ( nClientAuthType == AuthPrefCredType )
+ return SYNCML_DM_SUCCESS;
+
+ LOGE("ChalType2Str(%d) = %s", nClientAuthType, ChalType2Str(nClientAuthType));
+ return SetClientAuth( ChalType2Str(nClientAuthType), FALSE);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : SetPrefServerAuth
+// DESCRIPTION : Sets preferred AuthType for server and
+// reloads username/password/nonce from the DMTR
+//
+// ARGUMENTS PASSED: nServerAuthType - new auth type
+//
+// RETURN VALUE : error code in case of failure, "SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMClientServerCreds::SetPrefServerAuth( SYNCML_DM_CHAL_TYPE_T nServerAuthType )
+{
+ LOGE("DMClientServCreds::SetPrefServerAuth(%d): ServerChalType == %d", nServerAuthType, ServerChalType);
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if ( ServerChalType == nServerAuthType )
+ return dm_stat;
+
+ if ( nServerAuthType == SYNCML_DM_CHAL_NONE )
+ {
+ ServerChalType = nServerAuthType;
+ return dm_stat;
+ }
+
+ // load server settings
+ DMGetData oAuthSecret;
+ DMGetData oAuthData;
+ DMGetData oAuthType;
+ DMGetData oAuthName;
+
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ for (int index = nServerAuthType; index <= SYNCML_DM_CHAL_HMAC; index++)
+ {
+LOGE("DM 1.2 tree, index = %d", index);
+ dm_stat = dmTreeObj.GetServerAuthInfo(pDMAccNodeName,
+ ChalType2Str(index),
+ oAuthName,
+ oAuthSecret,
+ oAuthData,
+ m_strServerProfileURI );
+
+ // profile found
+ if( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ nServerAuthType = index;
+LOGE("DM 1.2 tree, nServerAuthType = %d", index);
+ break;
+ }
+ }
+ }
+ else
+ {
+ dm_stat = dmTreeObj.GetServerAuthInfo(pDMAccNodeName,
+ ChalType2Str(nServerAuthType),
+ oAuthName,
+ oAuthSecret,
+ oAuthData,
+ m_strServerProfileURI );
+ }
+
+ if( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ ServerChalType = nServerAuthType;
+
+ DMString device_id;
+ dm_stat = GetDeviceID( device_id );
+ if( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+LOGE("device_id = %s", device_id.c_str());
+
+ pServerPW.attach( (const char*)oAuthSecret.m_oData.detach() );
+LOGE("pServerPW = %s", pServerPW.c_str());
+
+ dm_stat = SYNCML_DM_BuildPackage::GetServerAuthValues( device_id,
+ pServerId,
+ pServerPW );
+ if( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ // DM: assume it is base64 encoded value
+ pServerNonce.attach( (const char*)oAuthData.m_oData.detach() );
+LOGE("pServerNonce = %s", pServerNonce.c_str());
+
+ if ( dmTreeObj.IsVersion_12() )
+ dm_stat = SaveServerAttribute(DM_AAUTHSECRET, pServerPW );
+ else
+ dm_stat = SaveServerAttribute(DM_SERVERPW, pServerPW);
+
+ return dm_stat;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Str2ChalType
+// DESCRIPTION : Converts string AuthPref representation into integer
+// SYNCML_DM_CHAL_TYPE_T enumeration
+//
+// ARGUMENTS PASSED: szChal - string auth type
+//
+// RETURN VALUE : integer auth pref, "none" for unknown types
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_CHAL_TYPE_T DMClientServerCreds::Str2ChalType( CPCHAR szChal )
+{
+ if ( !szChal )
+ return SYNCML_DM_CHAL_UNDEFINED;
+
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ if ( DmStrcmp(szChal, DM_AUTHTYPE_BASIC ) == 0 )
+ return SYNCML_DM_CHAL_BASIC;
+
+ if ( DmStrcmp(szChal, DM_AUTHTYPE_DIGEST ) == 0 )
+ return SYNCML_DM_CHAL_MD5;
+
+ if ( DmStrcmp(szChal, DM_AUTHTYPE_HMAC ) == 0 )
+ return SYNCML_DM_CHAL_HMAC;
+ }
+ else
+ {
+ if ( DmStrcmp(szChal, SYNCML_AUTH_BASIC ) == 0 )
+ return SYNCML_DM_CHAL_BASIC;
+
+ if ( DmStrcmp(szChal, SYNCML_AUTH_MD5 ) == 0 )
+ return SYNCML_DM_CHAL_MD5;
+
+ if ( DmStrcmp(szChal, SYNCML_AUTH_MAC ) == 0 )
+ return SYNCML_DM_CHAL_HMAC;
+ }
+
+
+ // all other types requires transport-level auth
+ return SYNCML_DM_CHAL_NONE;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : ChalType2Str
+// DESCRIPTION : Converts integer AuthPref representation into string
+//
+//
+// ARGUMENTS PASSED: nChal - SYNCML_DM_CHAL_TYPE_T enumeration
+// auth representation
+//
+// RETURN VALUE : string auth pref, empty string for "none",
+// NULL for unknown types
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+CPCHAR DMClientServerCreds::ChalType2Str( SYNCML_DM_CHAL_TYPE_T nChal )
+{
+
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ switch ( nChal )
+ {
+ case SYNCML_DM_CHAL_BASIC:
+ return DM_AUTHTYPE_BASIC;
+
+ case SYNCML_DM_CHAL_MD5:
+ return DM_AUTHTYPE_DIGEST;
+
+ case SYNCML_DM_CHAL_HMAC:
+ return DM_AUTHTYPE_HMAC;
+
+ case SYNCML_DM_CHAL_NONE:
+ return "";
+ }
+ }
+ else
+ {
+ switch ( nChal )
+ {
+ case SYNCML_DM_CHAL_BASIC:
+ return SYNCML_AUTH_BASIC;
+
+ case SYNCML_DM_CHAL_MD5:
+ return SYNCML_AUTH_MD5;
+
+ case SYNCML_DM_CHAL_HMAC:
+ return SYNCML_AUTH_MAC;
+
+ case SYNCML_DM_CHAL_NONE:
+ return "";
+ }
+ }
+
+ return NULL;
+}
+
+
+DMString DMClientServerCreds::GetDefaultAuthType()
+{
+ CPCHAR szStr = ::XPL_DM_GetEnv(SYNCML_DM_SECURITY_LEVEL);
+
+ return ChalType2Str( szStr ? DmAtoi( szStr ) : SYNCML_DM_CHAL_BASIC );
+}
+//------------------------------------------------------------------------
+// FUNCTION : SetClientAuth
+// DESCRIPTION : Sets preferred AuthType for client and
+// reloads username/password/nonce from the DMTR
+//
+// ARGUMENTS PASSED: szLastAuthPref - new auth type,
+// bTryDefault - if true, tries "default" one if
+// preferred one missing
+//
+// RETURN VALUE : error code in case of failure, "SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMClientServerCreds::SetClientAuth( CPCHAR szLastAuthPref, BOOLEAN bTryDefault )
+{
+ LOGE("DMClientServCreds::SetClientAuth(\"%s\", %d)", szLastAuthPref, bTryDefault);
+ // load client settings
+ DMGetData oAuthSecret;
+ DMGetData oAuthData;
+ DMGetData oAuthType;
+ DMGetData oAuthName;
+
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_FAIL;
+
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ dm_stat = dmTreeObj.GetClientAuthInfo(pDMAccNodeName,
+ szLastAuthPref,
+ oAuthName,
+ oAuthSecret,
+ oAuthData,
+ m_strClientProfileURI,
+ oAuthType );
+
+ if( dm_stat != SYNCML_DM_SUCCESS &&
+ szLastAuthPref &&
+ bTryDefault )
+ {
+ LOGE("DMClientServCreds::SetClientAuth() loading default settings");
+ // try to load default settings if last one failed
+ szLastAuthPref = NULL;
+
+ dm_stat = dmTreeObj.GetClientAuthInfo(pDMAccNodeName,
+ NULL,
+ oAuthName,
+ oAuthSecret,
+ oAuthData,
+ m_strClientProfileURI,
+ oAuthType );
+ }
+
+ // no profile found
+ if (dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if ( !szLastAuthPref )
+ {
+ szLastAuthPref = oAuthType.getCharData();
+ LOGE("szLastAuthPref is now %s", szLastAuthPref);
+ }
+ }
+ else
+ {
+ // DM: there is only one set of auth params in 1.1.2, so just load default settings
+ dm_stat = dmTreeObj.GetClientAuthInfo(pDMAccNodeName,
+ NULL,
+ oAuthName,
+ oAuthSecret,
+ oAuthData,
+ m_strClientProfileURI,
+ oAuthType );
+ // no profile found
+ if (dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if ( !szLastAuthPref )
+ {
+ szLastAuthPref = oAuthType.getCharData();
+ }
+ }
+
+ if ( AuthPrefCredType != SYNCML_DM_CHAL_UNDEFINED )
+ {
+ m_bAuthPrefUpdated = TRUE;
+ }
+
+ AuthPrefCredType = Str2ChalType( szLastAuthPref );
+
+ DMString device_id;
+ dm_stat = GetDeviceID( device_id );
+LOGE("device_id = %s", device_id.c_str());
+
+ if( SYNCML_DM_SUCCESS != dm_stat ) return dm_stat;
+
+ pClientUserName= oAuthName.getCharData();
+ pClientPW=oAuthSecret.getCharData();
+LOGE("pClientUserName = %s", pClientUserName.c_str());
+LOGE("pClientPW = %s", pClientPW.c_str());
+
+ dm_stat = SYNCML_DM_BuildPackage::GetClientAuthValues( device_id,
+ pServerId,
+ pClientUserName,
+ pClientPW );
+
+ if( SYNCML_DM_SUCCESS != dm_stat ) return dm_stat;
+
+ pClientNonce=oAuthData.getCharData();
+LOGE("pClientNonce = %s", pClientNonce.c_str());
+
+ // Motorola, <e50324>, <12/08/09>, <ikmap-2156> / Nonce Resynchronization
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ dm_stat = dmTreeObj.GetServerAuthInfo(pDMAccNodeName,
+ oAuthType.getCharData(),
+ oAuthName,
+ oAuthSecret,
+ oAuthData,
+ m_strServerProfileURI );
+
+ if( dm_stat == SYNCML_DM_SUCCESS && NULL != oAuthData.getCharData() )
+ {
+LOGE("comparing %s to %s", oAuthData.getCharData(), SERVER_RESYNC_NONCE);
+ if ( 0 == memcmp(oAuthData.getCharData(), SERVER_RESYNC_NONCE, 8) )
+ pClientNonce = SERVER_RESYNC_NONCE;
+ }
+ }
+
+ /* change the tree node value*/
+ if ( dmTreeObj.IsVersion_12() )
+ {
+LOGE("changing tree value of DM_AAUTHNAME to %s", pClientUserName.c_str());
+ dm_stat = SaveClientAttribute(DM_AAUTHNAME, pClientUserName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+LOGE("changing tree value of DM_AAUTHSECRET to %s", pClientPW.c_str());
+ dm_stat = SaveClientAttribute(DM_AAUTHSECRET, pClientPW);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+ else
+ {
+ dm_stat = SaveClientAttribute(DM_USERNAME, pClientUserName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = SaveClientAttribute(DM_CLIENTPW, pClientPW);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetDeviceID
+// DESCRIPTION : returns device ID; retrieves it only once and cache
+// the value; mainly used for Factory bootstrap
+//
+// ARGUMENTS PASSED: none
+//
+// RETURN VALUE : device id; empty string in case of error
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T
+DMClientServerCreds::GetDeviceID( DMString& device_id )
+{
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_SUCCESS;
+
+ if ( m_strdevIMEI.empty() )
+ {
+ result = SYNCML_DM_BuildPackage::GetDeviceID( device_id );
+
+ if( SYNCML_DM_SUCCESS == result )
+ {
+ m_strdevIMEI = device_id;
+ }
+ }
+ else
+ device_id = m_strdevIMEI;
+
+ return result;
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : SaveClientAttribute
+// DESCRIPTION : saves client attribute in node
+// "./SyncML/DMAcc/<x>/AppAuth/<x>/<attribute>" in DMTR
+//
+//
+// ARGUMENTS PASSED: szAttribute - attribute name like "AAuthData"
+// szValue - new value
+//
+// RETURN VALUE : error code in case of failure, "SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMClientServerCreds::SaveClientAttribute( CPCHAR szAttribute, CPCHAR szValue )
+{
+ return SaveAttribute(m_strClientProfileURI, szAttribute, szValue);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : SaveServerAttribute
+// DESCRIPTION : saves server attribute in node
+// "./SyncML/DMAcc/<x>/AppAuth/<x>/<attribute>" in DMTR
+//
+//
+// ARGUMENTS PASSED: szAttribute - attribute name like "AAuthData"
+// szValue - new value
+//
+// RETURN VALUE : error code in case of failure, "SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMClientServerCreds::SaveServerAttribute( CPCHAR szAttribute, CPCHAR szValue )
+{
+ return SaveAttribute(m_strServerProfileURI, szAttribute, szValue);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : SaveAttribute
+// DESCRIPTION : saves an attribute in node
+// "<profile>/<attribute>" in DMTR
+//
+//
+// ARGUMENTS PASSED: szProfile - "profile" name; cached value for last loaded
+// server or client account
+// szAttribute - attribute name like "AAuthData"
+// szValue - new value
+//
+// RETURN VALUE : error code in case of failure, "SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMClientServerCreds::SaveAttribute( CPCHAR szProfile, CPCHAR szAttribute, CPCHAR szValue )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMAddData oReplace;
+ DMString strURI = szProfile;
+
+ strURI += szAttribute;
+
+ dm_stat = oReplace.set(strURI, SYNCML_DM_FORMAT_CHR, szValue,DmStrlen(szValue),"text/plain");
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = dmTreeObj.Replace(oReplace,SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ return (dm_stat);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : SaveAuthPref
+// DESCRIPTION : saves AuthPref if different from initial value
+//
+// ARGUMENTS PASSED: none
+//
+// RETURN VALUE : error code in case of failure, "SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMClientServerCreds::SaveAuthPref()
+{
+ if ( !m_bAuthPrefUpdated || dmTreeObj.IsVersion_12() == FALSE )
+ return SYNCML_DM_SUCCESS;
+
+ m_bAuthPrefUpdated = FALSE;
+ return dmTreeObj.SetLastClientAuthType(pDMAccNodeName, ChalType2Str(AuthPrefCredType));
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/dmProcessScriptSession.cc b/engine/dmlib/dmengine/dm_ssession/src/dmProcessScriptSession.cc
new file mode 100644
index 0000000..75fc258
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/dmProcessScriptSession.cc
@@ -0,0 +1,395 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Header Name: dmProcessScriptSession.cc
+
+ General Description: Implementation of DMProcessScriptSession class.
+
+==================================================================================================*/
+
+#include "dmProcessScriptSession.h"
+#include "dm_ua_handlecommand.h"
+#include "xpl_Logger.h"
+
+/*==================================================================================================
+FUNCTION : DMProcessScriptSession::DMProcessScriptSession
+
+DESCRIPTION : The class constructor.
+ARGUMENT PASSED : sml_ContentType
+ sml_EncodingType
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+DMProcessScriptSession::DMProcessScriptSession()
+{
+
+ inAtomicCommand = FALSE;
+ commandCount = 0;
+ m_bSessionAborted = FALSE;
+
+ serverSessionId = 0;
+ serverRetryCount = 0;
+ clientRetryCount = 0;
+
+ m_nSecState = DM_CLIENT_NO_SERVER_Y_AUTH;
+ isServCredsMissing = FALSE;
+
+#ifdef LOB_SUPPORT
+ DMGetData lrgObjData;
+ isLargeObjectSupported = FALSE;
+ dmTreeObj.Get("./DevDetail/LrgObj", lrgObjData,SYNCML_DM_REQUEST_TYPE_SERVER);
+ isLargeObjectSupported = !lrgObjData.m_oData.compare("false");
+ // Get default MaxObjectSize
+ DMNode* pNode= dmTreeObj.FindNodeByURI("./DevDetail/Ext/MaxObjSize");
+ dmtMaxObjectSize = dmTreeObj.readOneWordFromTree(pNode, 0);
+#endif
+}
+
+/*==================================================================================================
+FUNCTION : DMProcessScriptSession::~DMProcessScriptSession
+
+DESCRIPTION : The class destructor.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+DMProcessScriptSession::~DMProcessScriptSession ()
+{
+ while ( userData.aStatuses.size() > 0 )
+ {
+ smlFreeStatus((SmlStatusPtr_t)userData.aStatuses[0]);
+ userData.aStatuses.remove(0);
+ }
+
+ while ( userData.aResults.size() > 0 )
+ {
+ smlFreeResults( userData.aResults[0]._pGetExecResult );
+ userData.aResults[0]._pGetExecResult= NULL;
+
+ if ( userData.aResults[0]._type == SYNCML_DM_RESULT_VALUE::Enum_Result_GetStruct ||
+ userData.aResults[0]._type == SYNCML_DM_RESULT_VALUE::Enum_Result_GetStructData )
+ {
+
+ if (userData.aResults[0]._oGetStructPos.psRetData )
+ {
+ delete userData.aResults[0]._oGetStructPos.psRetData;
+ }
+ }
+ userData.aResults.remove(0);
+ }
+}
+
+/*==================================================================================================
+FUNCTION : DMProcessScriptSession::IncCommandCount
+
+DESCRIPTION : This function will increment the value of data member commandCount by 1.
+ARGUMENT PASSED : newCommandCount
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+void
+DMProcessScriptSession::IncCommandCount ()
+{
+ commandCount++;
+}
+
+/*==================================================================================================
+Function: DMProcessScriptSession::SetInAtomicCommand
+
+Description: The function will set the value of data member inAtomicCommand.
+ARGUMENT PASSED : newInAtomicCommand
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+void
+DMProcessScriptSession::SetInAtomicCommand (BOOLEAN newInAtomicCommand)
+{
+ inAtomicCommand = newInAtomicCommand;
+}
+
+/*==================================================================================================
+Function: DMProcessScriptSession::GetInAtomicCommand
+
+Description: The function will return the value of data member inAtomicCommand.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : inAtomicCommand
+IMPORTANT NOTES :
+==================================================================================================*/
+BOOLEAN
+DMProcessScriptSession::GetInAtomicCommand()
+{
+ return inAtomicCommand;
+}
+
+
+/*==================================================================================================
+Function: DMProcessScriptSession::GetServerSessionId
+
+Description: The function will return the value of data member serverSessionId.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : serverSessionId
+IMPORTANT NOTES :
+==================================================================================================*/
+UINT16
+DMProcessScriptSession::GetServerSessionId()
+{
+ return serverSessionId;
+}
+
+
+/*==================================================================================================
+Function: DMProcessScriptSession::GetSendInstanceId
+
+Description: The function will return the value of data member sendInstanceId.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : sendInstanceId
+IMPORTANT NOTES :
+==================================================================================================*/
+InstanceID_t
+DMProcessScriptSession::GetSendInstanceId ()
+{
+ return sendInstanceId;
+}
+
+/*==================================================================================================
+Function: DMProcessScriptSession::SetClientRetryCount
+
+Description: The function will set the clientRetryCount to a new value.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : void
+IMPORTANT NOTES :
+==================================================================================================*/
+void
+DMProcessScriptSession::SetClientRetryCount (UINT8 newcount)
+{
+ clientRetryCount = newcount;
+}
+
+/*==================================================================================================
+Function: DMProcessScriptSession::IncClientRetryCount
+
+Description: The function will increment the clientRetryCount by 1.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : void
+IMPORTANT NOTES :
+==================================================================================================*/
+void
+DMProcessScriptSession::IncClientRetryCount ()
+{
+ clientRetryCount++;
+}
+
+
+/*==================================================================================================
+FUNCTION : DMProcessScriptSession::SessionStart
+
+DESCRIPTION : The UserAgen::SessionStart calls this function after it creates MgmtSession object.
+ The function will perform the following operations:
+ 1) Call SessionStart() to setup the DM tree.
+ 2) Register the DM engine with the SYNCML toolkit.
+ 3) Connect the client with the server.
+ 4) Build and send the package one.
+ARGUMENT PASSED : p_SessionStart
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMProcessScriptSession::Start(const UINT8 *docInputBuffer,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ DMBuffer & oResult)
+{
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_FAIL;
+ Ret_t sml_ret_stat;
+
+ XPL_LOG_DM_SESS_Debug(("Entered DMProcessScriptSession::SessionStart, buf=%x,size=%d, wbxml=%d\n", docInputBuffer, inDocSize, isWBXML));
+
+ XPL_LOG_DM_SESS_Debug(("Entered DMProcessScriptSession::SessionStart, resultbuf=%x", &oResult));
+
+ ret_stat = Init(isWBXML);
+ if ( ret_stat != SYNCML_DM_SUCCESS )
+ return ret_stat;
+
+ /* Register the DM engine with the SYNCML toolkit. */
+ userData.pSessionMng = this;
+ userData.pPkgBuilder = &m_oPkgBuilder;
+ ret_stat = RegisterDmEngineWithSyncmlToolkit(&userData);
+ XPL_LOG_DM_SESS_Debug(("after entered\n"));
+
+ if ( ret_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_SESS_Debug(("Exiting: RegisterDmEngineWithSyncmlToolkit failed\n"));
+ return (ret_stat);
+ }
+
+
+ sml_ret_stat = smlLockWriteBuffer(recvInstanceId, &pWritePos, &workspaceFreeSize);
+ XPL_LOG_DM_SESS_Debug(("after smlLockWriteBuffer\n"));
+
+ if ( sml_ret_stat != SML_ERR_OK )
+ return SYNCML_DM_FAIL;
+
+ memcpy(pWritePos,docInputBuffer,inDocSize);
+ XPL_LOG_DM_SESS_Debug(("after memcpy\n"));
+
+ recvSmlDoc.dataSize = inDocSize;
+
+ ret_stat = ParseMessage();
+ XPL_LOG_DM_SESS_Debug(("after ParseMessage\n"));
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ return ret_stat;
+
+
+ smlLockReadBuffer(sendInstanceId, &pReadPos, &workspaceUsedSize);
+ XPL_LOG_DM_SESS_Debug(("after smlLockReadBuffer\n"));
+
+ /* Set sendSmlDoc point to workspace */
+ if ( workspaceUsedSize )
+ {
+ oResult.assign(pReadPos,workspaceUsedSize);
+ if ( oResult.getBuffer() == NULL )
+ ret_stat = SYNCML_DM_DEVICE_FULL;
+ else
+ ret_stat = SYNCML_DM_SUCCESS;
+ }
+
+ XPL_LOG_DM_SESS_Debug(("dmProcessScriptSession:: workspaceUsedSize:%d, ret_stat:%d", workspaceUsedSize, ret_stat));
+ XPL_LOG_DM_SESS_Debug(("dmProcessScriptSession:: oResult.getBuffer()=%x, size=%d\n", oResult.getBuffer(), oResult.getSize()));
+ return ret_stat;
+}
+
+/*==================================================================================================
+FUNCTION : DMProcessScriptSession::ParseMessage
+
+DESCRIPTION : The UserAgent::TransportMsg will call this function after RecvMessage() call
+ returned.
+ The function will use SyncML toolkit smlProcessData() function to parse and
+ process commands in the package.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+
+ This method will perform the following operations:
+ 1) Unlock both of the Toolkit Buffers.
+ 2) Call smlProcessData for the first command.
+ 3) Loop around smlProcessData on the next command while checking for Multiple Messages
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMProcessScriptSession::ParseMessage()
+{
+ Ret_t sml_ret_stat;
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+ smlUnlockWriteBuffer(recvInstanceId, recvSmlDoc.dataSize);
+
+ /* Process the first command in the incoming message */
+ sml_ret_stat = smlProcessData(recvInstanceId, SML_FIRST_COMMAND);
+
+ if (sml_ret_stat != SML_ERR_OK)
+ return(SYNCML_DM_FAIL);
+
+ /* Loop through the remaining commands until we reach the end of the
+ current toolkit workspace */
+ while (sml_ret_stat != SML_ERR_XLT_END_OF_BUFFER)
+ {
+ sml_ret_stat = smlProcessData(recvInstanceId, SML_NEXT_COMMAND);
+ /* The callback routines set this value when they realize we need
+ to begin processing the other buffer. */
+
+ /* Anything wrong with the command, or inMultipleMessageMode is TRUE, break out here.
+ * The callbacks set inMultipleMessageMode when they can no longer
+ * fit anything into the outgoing message workspace
+ */
+ if ((sml_ret_stat != SML_ERR_OK) )
+ break;
+ }
+
+ if (sml_ret_stat != SML_ERR_OK && sml_ret_stat != SML_ERR_XLT_END_OF_BUFFER)
+ {
+ ret_stat = dmTreeObj.GetLockContextManager().ReleaseIDInternal(SYNCML_DM_LOCKID_CURRENT, SYNCML_DM_ROLLBACK);
+ ret_stat = SYNCML_DM_FAIL;
+ KCDBG("dmProcessScriptSession:: sml_ret_stat:%d, ret_stat:%d", sml_ret_stat, ret_stat);
+ }
+
+ return (ret_stat);
+}
+
+
+/*==================================================================================================
+FUNCTION : DMProcessScriptSession::SetToolkitCallbacks
+
+DESCRIPTION : This function will to set toolkit callback functions.
+
+
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : It returns SYNCML_DM_SUCCESS.
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMProcessScriptSession::SetToolkitCallbacks(SmlCallbacks_t * pSmlCallbacks)
+{
+
+ pSmlCallbacks->startMessageFunc = HandleStartMessage;
+ pSmlCallbacks->endMessageFunc = HandleEndMessage;
+
+ /* Sync Command callbacks */
+ pSmlCallbacks->addCmdFunc = HandleAddCommand;
+
+ pSmlCallbacks->alertCmdFunc = HandleAlertCommand;
+ pSmlCallbacks->copyCmdFunc = HandleCopyCommand;
+ pSmlCallbacks->deleteCmdFunc = HandleDeleteCommand;
+ pSmlCallbacks->getCmdFunc = HandleGetCommand;
+
+ pSmlCallbacks->startAtomicFunc = HandleStartAtomicCommand;
+ pSmlCallbacks->endAtomicFunc = HandleEndAtomicCommand;
+
+ pSmlCallbacks->startSequenceFunc = HandleStartSequenceCommand;
+ pSmlCallbacks->endSequenceFunc = HandleEndSequenceCommand;
+
+ pSmlCallbacks->execCmdFunc = HandleExecCommand;
+ pSmlCallbacks->statusCmdFunc = HandleStatusCommand;
+ pSmlCallbacks->replaceCmdFunc = HandleReplaceCommand;
+
+ /* The transmitChunkFunc callback is required for support of Large Objects. */
+
+ pSmlCallbacks->transmitChunkFunc = NULL;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+DMClientServerCreds * DMProcessScriptSession::GetClientServerCreds()
+{
+ return &clientServerCreds;
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/dmServerAuthentication.cc b/engine/dmlib/dmengine/dm_ssession/src/dmServerAuthentication.cc
new file mode 100644
index 0000000..e2cee67
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/dmServerAuthentication.cc
@@ -0,0 +1,342 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmServerAuthentication.cc
+
+ General Description: Implementation of DMServerAuthentication class.
+
+==================================================================================================*/
+
+#include "dmt.hpp"
+#include "dmStringUtil.h"
+#include "dm_security.h"
+#include "dm_tree_util.h"
+#include "dmSessionDefs.h"
+#include "SYNCML_DM_BuildPackage.H"
+#include "xpl_dm_Manager.h"
+#include "dmServerAuthentication.h"
+
+extern "C" {
+#include "xpt-b64.h"
+#include "stdio.h"
+}
+
+void DMServerAuthentication::CheckCredentials( SYNCML_DM_AuthContext_T& AuthContext, const DMString& password, const DMBuffer& data, BOOLEAN bDecodeNonce )
+{
+ UINT8 decodedNonce[MAX_BIN_NONCE_LEN];
+
+ XPL_LOG_DM_SESS_Debug(("CheckCredentials Entered\n"));
+
+ memset(decodedNonce, 0, MAX_BIN_NONCE_LEN);
+
+ UINT32 encodedNonceLen = data.getSize();
+
+ UINT32 decodedNonceLen = base64Decode((unsigned char *)decodedNonce, MAX_BIN_NONCE_LEN,(unsigned char*)data.getBuffer(),(unsigned long*) &encodedNonceLen);
+
+ SYNCMLDM_HMAC_SEC_INFO_T hmacSecInfo;
+
+ memset(&hmacSecInfo,0,sizeof(hmacSecInfo));
+
+ /* Call the security library to generate the credentials.*/
+
+ hmacSecInfo.pb_user_name_or_server_id = (UINT8*)AuthContext._pServerId;
+ hmacSecInfo.pb_password = (UINT8*)password.c_str();
+
+ if( bDecodeNonce )
+ {
+ hmacSecInfo.pb_nonce = decodedNonce;
+ hmacSecInfo.w_nonce_length = decodedNonceLen;
+ }
+ else
+ {
+ hmacSecInfo.pb_nonce = (unsigned char*)data.getBuffer();
+ hmacSecInfo.w_nonce_length = (unsigned long)data.getSize();
+
+ if( hmacSecInfo.pb_nonce == NULL )
+ {
+ hmacSecInfo.pb_nonce = (UINT8*)"";
+ hmacSecInfo.w_nonce_length = 0;
+ }
+ }
+
+ hmacSecInfo.pb_syncml_document = AuthContext._pTrigger; /* Pointer to the Trigger portion of the Pkg0.*/
+ hmacSecInfo.dw_syncml_document_length = AuthContext._triggerLen;
+ hmacSecInfo.o_encode_base64 = FALSE; /* The MD5 digest is 16 bytes of binary, not b64.*/
+
+ SYNCMLDM_SEC_CREDENTIALS_T *pGenCred = syncmldm_sec_build_hmac_cred(&hmacSecInfo);
+
+
+ if( pGenCred != NULL )
+ {
+
+ /* Compare the newly generated Credentials to the ones passed by the server.*/
+ char sdigest[2*pGenCred->w_credential_string_length+1];
+ char cdigest[2*pGenCred->w_credential_string_length+1];
+
+ for (int i=0; i<pGenCred->w_credential_string_length; i++ ) {
+ sprintf(sdigest+2*i, "%02X", (char)AuthContext._md5Digest[i]);
+ }
+
+ for (int i=0; i<pGenCred->w_credential_string_length; i++ ) {
+ sprintf(cdigest+2*i, "%02X", (char)pGenCred->ab_credential_string[i]);
+ }
+
+ sdigest[2*pGenCred->w_credential_string_length] = '\0';
+ cdigest[2*pGenCred->w_credential_string_length] = '\0';
+
+ XPL_LOG_DM_SESS_Debug(("Server Digest: %s\n", sdigest));
+ XPL_LOG_DM_SESS_Debug(("Client Digest: %s\n", cdigest));
+
+ AuthContext._AuthFlag = (pGenCred && (0 == memcmp((CPCHAR)AuthContext._md5Digest,(CPCHAR)pGenCred->ab_credential_string,pGenCred->w_credential_string_length )));
+ if( !AuthContext._AuthFlag )
+ {
+ XPL_LOG_DM_SESS_Error(("CheckCredentials Failed\n"));
+ }
+
+ DmFreeMem(pGenCred);
+ }
+ else
+ {
+ AuthContext._AuthFlag = FALSE;
+ }
+
+ XPL_LOG_DM_SESS_Debug(("CheckCredentials Exit\n"));
+}
+
+
+ DMString DMServerAuthentication::GetPreferredProfilePath( const DMString& strAccName, const DMMap<DMString, UINT32>& dmAuthProfiles )
+{
+
+ DMString strAAuthPrefURI( ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH ) + DMString( DM_STR_SLASH ) + strAccName + DM_STR_SLASH + DM_AAUTHPREF );
+ DMString strPreferredProfilePath;
+ DMGetData oAuthPref;
+
+ XPL_LOG_DM_SESS_Debug(("GetPrefferdProfilePath Entered\n"));
+
+ if( SYNCML_DM_SUCCESS == dmTreeObj.Get( strAAuthPrefURI, oAuthPref, SYNCML_DM_REQUEST_TYPE_INTERNAL ) )
+ {
+ DMString strAuthPref( oAuthPref.getCharData() );
+
+ if( strAuthPref.length() != 0 )
+ {
+ for( DMMap<DMString, UINT32>::POS pos = dmAuthProfiles.begin();pos != dmAuthProfiles.end(); ++pos )
+ {
+ DMGetData oAuthType;
+ if( SYNCML_DM_SUCCESS == dmTreeObj.Get(dmAuthProfiles.get_key(pos)+DM_STR_SLASH DM_AAUTHTYPE,oAuthType,SYNCML_DM_REQUEST_TYPE_INTERNAL))
+ {
+ DMString strCurrentAuthType = oAuthType.getCharData();
+
+ if( 0 == strCurrentAuthType.CompareNoCase( strAuthPref ) )
+ {
+ strPreferredProfilePath = dmAuthProfiles.get_key( pos );
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return strPreferredProfilePath;
+}
+
+ SYNCML_DM_RET_STATUS_T DMServerAuthentication::TryProfile_1_1( const DMString& strAccName, const DMString& strProlilePath,SYNCML_DM_AuthContext_T& AuthContext )
+{
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_SUCCESS;
+
+
+ DMGetData oAuthSecret;
+ DMGetData oAuthData;
+
+ XPL_LOG_DM_SESS_Debug(("TryProfile_1_1 Entered\n"));
+
+ result = dmTreeObj.Get( strProlilePath + DM_STR_SLASH DM_SERVERPW, oAuthSecret, SYNCML_DM_REQUEST_TYPE_INTERNAL );
+ if( SYNCML_DM_SUCCESS != result )
+ return result;
+ result = dmTreeObj.Get( strProlilePath + DM_STR_SLASH DM_SERVERNONCE, oAuthData, SYNCML_DM_REQUEST_TYPE_INTERNAL );
+ if( SYNCML_DM_SUCCESS != result )
+ return result;
+
+ DMString device_id;
+ result = SYNCML_DM_BuildPackage::GetDeviceID( device_id );
+ if( SYNCML_DM_SUCCESS != result )
+ return result;
+
+ DMString password( oAuthSecret.getCharData() );
+
+ result = SYNCML_DM_BuildPackage::GetServerAuthValues( device_id, AuthContext._pServerId, password );
+
+ if( SYNCML_DM_SUCCESS != result )
+ return result;
+
+ CheckCredentials( AuthContext, password, oAuthData.m_oData, TRUE );
+
+ return result;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMServerAuthentication::TryProfile_1_2( const DMString& strAccName,const DMString& strProlilePath, SYNCML_DM_AuthContext_T& AuthContext )
+{
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_SESS_Debug(("TryProfile_1_2 Entered\n"));
+ for( ; ; )
+ {
+ DMGetData oAuthLevel;
+ result = dmTreeObj.Get( strProlilePath + DM_STR_SLASH DM_AAUTHLEVEL, oAuthLevel, SYNCML_DM_REQUEST_TYPE_INTERNAL );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ // DM: filter out server credentials only
+ if( 0 != DMString( oAuthLevel.getCharData()).CompareNoCase( DM_AUTHLEVEL_SRVCRED ) ) break;
+
+ DMGetData oAuthSecret;
+ DMGetData oAuthData;
+
+ result = dmTreeObj.Get( strProlilePath + DM_STR_SLASH DM_AAUTHSECRET, oAuthSecret, SYNCML_DM_REQUEST_TYPE_INTERNAL );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ result = dmTreeObj.Get( strProlilePath + DM_STR_SLASH DM_AAUTHDATA, oAuthData, SYNCML_DM_REQUEST_TYPE_INTERNAL );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ DMString device_id;
+ result = SYNCML_DM_BuildPackage::GetDeviceID( device_id );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ DMString password( oAuthSecret.getCharData() );
+
+ result = SYNCML_DM_BuildPackage::GetServerAuthValues( device_id,AuthContext._pServerId, password );
+
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ CheckCredentials( AuthContext, password, oAuthData.m_oData, TRUE ); // decode nonce before calculating digest
+ if ( !AuthContext._AuthFlag )
+ {
+ XPL_LOG_DM_SESS_Warn(("CheckCredentials: Failed check credentials with decoding\n"));
+
+ CheckCredentials( AuthContext, password, oAuthData.m_oData, FALSE ); // do NOT decode nonce before calculating digest
+ if ( !AuthContext._AuthFlag )
+ {
+ XPL_LOG_DM_SESS_Warn(("CheckCredentials: Failed check credentials without decoding\n"));
+
+ oAuthData.m_oData.assign(SERVER_RESYNC_NONCE);
+ BOOLEAN bAuthFlag1 = FALSE;
+ BOOLEAN bAuthFlag2 = FALSE;
+
+ CheckCredentials( AuthContext, password, oAuthData.m_oData, TRUE );
+ bAuthFlag1 = AuthContext._AuthFlag;
+
+ if( !bAuthFlag1 )
+ {
+ CheckCredentials( AuthContext, password, oAuthData.m_oData, FALSE );
+ bAuthFlag2 = AuthContext._AuthFlag;
+ }
+
+ if ( bAuthFlag1 || bAuthFlag2 )
+ {
+ XPL_LOG_DM_SESS_Warn(("Nonce Resynchronization request detected\n"));
+ DMNode *pNode = dmTreeObj.FindNodeByURI(strProlilePath + DM_STR_SLASH DM_AAUTHDATA);
+ if ( NULL == pNode || NULL == pNode->getData() )
+ {
+ XPL_LOG_DM_SESS_Error(("Failed to reset server nonce!\n"));
+ AuthContext._AuthFlag = false;
+ result = SYNCML_DM_SESSION_AUTH_FAIL;
+ break;
+ }
+ pNode->getData()->assign(SERVER_RESYNC_NONCE);
+ }
+ else {
+ result = SYNCML_DM_SESSION_AUTH_FAIL;
+ }
+ }
+ }
+ break;
+ }
+
+ return result;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMServerAuthentication::AuthenticateServer (SYNCML_DM_AuthContext_T& AuthContext)
+{
+ XPL_LOG_DM_SESS_Debug(("AutenticateServer Entered\n"));
+
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_SUCCESS;
+ CPCHAR szDMAccRootPath = ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH );
+ CPCHAR szServerIdNodeName = ::XPL_DM_GetEnv( SYNCML_DM_NODENAME_SERVERID );
+
+ /* Get the DMAcc node using the ServerId.*/
+ DMString strAccName;
+
+ AuthContext._AuthFlag = FALSE;
+
+ if(!dmTreeObj.GetParentOfKeyValue( AuthContext._pServerId, szServerIdNodeName, szDMAccRootPath, strAccName ) )
+ {
+ return (SYNCML_DM_FAIL);
+ }
+
+ if( strAccName == NULL)
+ {
+ /* The ServerId was not found in the DM Tree.*/
+ return (SYNCML_DM_FAIL);
+ }
+
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ DMString strAppAuthPath = szDMAccRootPath + DMString( DM_STR_SLASH ) + strAccName.c_str() + DM_STR_SLASH + DM_APPAUTH;
+ DMMap<DMString, UINT32> dmAuthProfiles;
+
+ result = dmTreeObj.getChildren( strAppAuthPath, dmAuthProfiles, DMTNM_NODE_INTERIOR,SYNCML_DM_REQUEST_TYPE_INTERNAL );
+ if( SYNCML_DM_SUCCESS == result )
+ {
+ DMString strPreferredProfilePath = GetPreferredProfilePath( strAccName, dmAuthProfiles );
+
+ if( strPreferredProfilePath.length() != 0 )
+ {
+ result = TryProfile_1_2( strAccName, strPreferredProfilePath, AuthContext );
+ if ( SYNCML_DM_SUCCESS != result )
+ {
+ dmFreeGetMap(dmAuthProfiles);
+ return result;
+ }
+ }
+
+ if( !AuthContext._AuthFlag )
+ {
+ // DM: preferred method didn't work. Try all profiles
+ for( DMMap<DMString, UINT32>::POS pos = dmAuthProfiles.begin(); pos != dmAuthProfiles.end(); ++pos )
+ {
+ DMString strProfilePath = dmAuthProfiles.get_key( pos );
+
+ // DM: skip preferred profile
+ if( strPreferredProfilePath != strProfilePath )
+ {
+ result = TryProfile_1_2( strAccName, strProfilePath, AuthContext );
+ if( ( SYNCML_DM_SUCCESS != result ) || AuthContext._AuthFlag ) break;
+ }
+ }
+ }
+
+ dmFreeGetMap(dmAuthProfiles);
+ }
+ }
+ else
+ {
+ result = TryProfile_1_1( strAccName, szDMAccRootPath + DMString( DM_STR_SLASH ) + strAccName.c_str(),AuthContext );
+ }
+
+ return result;
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/dmServerSession.cc b/engine/dmlib/dmengine/dm_ssession/src/dmServerSession.cc
new file mode 100644
index 0000000..e9793eb
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/dmServerSession.cc
@@ -0,0 +1,612 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: DMServerSession.cc
+
+ General Description: Implementation of DMServerSession class.
+
+==================================================================================================*/
+
+#include "dmServerSession.h"
+#include "dm_ua_handlecommand.h"
+#include "dm_tree_util.h"
+#include "xpl_dm_Manager.h"
+#include "xpl_dm_Notifications.h"
+#include "dmLockingHelper.h"
+
+#ifndef DM_NO_LOCKING
+#include "dmThreadQueue.h"
+#endif
+
+extern "C" {
+#include "xpt-b64.h"
+#include "stdio.h"
+}
+
+#include "xpl_Logger.h"
+
+extern int g_cancelSession;
+
+/*==================================================================================================
+ SOURCE FUNCTIONS
+==================================================================================================*/
+
+
+/*==================================================================================================
+FUNCTION : DMServerSession::DMServerSession
+
+DESCRIPTION : The class constructor.
+ARGUMENT PASSED : sml_ContentType
+ sml_EncodingType
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+DMServerSession::DMServerSession()
+{
+
+ m_nSecState = DM_CLIENT_NO_SERVER_NO_AUTH;
+}
+
+
+
+
+/*==================================================================================================
+FUNCTION : DMServerSession::ConnectServer
+
+DESCRIPTION : The SessionStart() function calls this function to connect to the server.
+ The function will perform the following operations:
+ 1) Get the DM account URI from the DM tree.
+ 2) Call SYNCML_DM_TransportController::Connect() function to establish the DM
+ session clent/server connection.
+ARGUMENT PASSED : server_Id
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMServerSession::ConnectServer(CPCHAR pServerId)
+{
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ XPL_ADDR_TYPE_T addressType = XPL_ADDR_DEFAULT;
+ CPCHAR szDMAccRootPath = ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH );
+ CPCHAR szServerIdNodeName = ::XPL_DM_GetEnv( SYNCML_DM_NODENAME_SERVERID );
+
+
+ XPL_LOG_DM_SESS_Debug(("Entered DMServerSession::ConnectServer\n"));
+
+ /* Get the current server ID's DM account URI */
+ if ( !dmTreeObj.GetParentOfKeyValue (pServerId,
+ szServerIdNodeName,
+ szDMAccRootPath,
+ clientServerCreds.pDMAccNodeName) )
+ {
+ XPL_LOG_DM_SESS_Error(("Cannot Get Parent for %s\n",szServerIdNodeName ));
+ return SYNCML_DM_FAIL;
+ }
+
+ DMGetData oDataAddr, oDataAddrType, oDataPort, oData;
+
+ ret_stat = dmTreeObj.GetDefAccountAddrInfo((CPCHAR)clientServerCreds.pDMAccNodeName,
+ oDataAddr,
+ oDataAddrType,
+ oDataPort );
+
+ if ( ret_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_SESS_Error(("Cannot Get Account Address Info for %s\n",(CPCHAR)clientServerCreds.pDMAccNodeName ));
+ return ret_stat;
+ }
+
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ // Get the value of the pbDMAccUri/PrefConRef node
+ addressType = XPL_ADDR_HTTP;
+ ret_stat = dmTreeObj.GetAccNodeValue((CPCHAR)clientServerCreds.pDMAccNodeName,
+ DM_PREFCONREF,
+ oData);
+ }
+ else
+ {
+ if ( oDataAddrType.getCharData() )
+ addressType = DmAtoi(oDataAddrType.getCharData());
+ else
+ addressType = XPL_ADDR_HTTP;
+
+ if ( addressType != XPL_ADDR_HTTP && addressType != XPL_ADDR_WSP )
+ return SYNCML_DM_FAIL;
+
+ ret_stat = dmTreeObj.GetAccNodeValue((CPCHAR)clientServerCreds.pDMAccNodeName,
+ DM_CONREF,
+ oData);
+ }
+
+ if ( ret_stat == SYNCML_DM_SUCCESS )
+ { dmTreeObj.SetConRef(oData.getCharData());
+ ret_stat = m_oConnObject.Init(g_iDMWorkspaceSize,addressType,oData.getCharData());
+ }
+ else
+ if ( ret_stat == SYNCML_DM_NOT_FOUND )
+ { dmTreeObj.SetConRef(NULL);
+ ret_stat = m_oConnObject.Init(g_iDMWorkspaceSize,addressType,NULL);
+ }
+
+ XPL_LOG_DM_SESS_Debug (("Leaving DMServerSession::ConnectServer ret_stat=%d\n",ret_stat));
+ return (ret_stat);
+}
+
+
+/*==================================================================================================
+FUNCTION : DMServerSession::BuildSendPackageOne
+
+DESCRIPTION : SessionStart function calls this function to build the DM package one and send it
+ to the server.
+ The function will perform the following operations:
+ 1) Create the SYNCML_DM_BuildPackage object.
+ 2) Build the package one document.
+ 3) Send the package one to the Transport Binding.
+ARGUMENT PASSED : session_Direction
+ p_ParsedPk0
+OUTPUT PARAMETER:
+RETURN VALUE : STYNCML_DM_SUCCES for success or SYNCML_DM_FAIL for failure
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMServerSession::BuildSendPackageOne(CPCHAR pServerID, DmtSessionProp * pSessionProp)
+{
+ XPL_LOG_DM_SESS_Debug (("Entering DMServerSession::BuildSendPackageOne serverId = %s\n", pServerID));
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ m_oPkgBuilder.Init(this);
+
+#ifndef DM_NO_LOCKING
+ INT32 nLockID = 0;
+ {
+ DMLockingHelper oLock( 0, ".", pServerID,SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE);
+ nLockID = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() )
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+ ret_stat = m_oPkgBuilder.BuildPackageOne(pServerID, pSessionProp);
+ }
+
+ dmTreeObj.ReleaseLock( nLockID );
+#else
+ ret_stat = m_oPkgBuilder.BuildPackageOne(pServerID, pSessionProp);
+#endif
+ if ( ret_stat == SYNCML_DM_SUCCESS )
+ {
+ ret_stat = SendPackage();
+ }
+
+ return (ret_stat);
+}
+
+
+/*==================================================================================================
+FUNCTION : DMServerSession::SessionStart
+
+DESCRIPTION : The UserAgen::SessionStart calls this function after it creates MgmtSession object.
+ The function will perform the following operations:
+ 1) Call SessionStart() to setup the DM tree.
+ 2) Register the DM engine with the SYNCML toolkit.
+ 3) Connect the client with the server.
+ 4) Build and send the package one.
+ARGUMENT PASSED : p_SessionStart
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMServerSession::Start(CPCHAR pServerID,
+ DmtSessionProp * pSessionProp)
+{
+ SYNCML_DM_RET_STATUS_T ret_stat;
+ BOOLEAN bMoreMessage = TRUE;
+
+ ret_stat = Init(pSessionProp->isWBXML());
+ if ( ret_stat != SYNCML_DM_SUCCESS )
+ return ret_stat;
+
+ /* Register the DM engine with the SYNCML toolkit. */
+ userData.pSessionMng = this;
+ userData.pPkgBuilder = &m_oPkgBuilder;
+ ret_stat = RegisterDmEngineWithSyncmlToolkit(&userData);
+ if ( ret_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_SESS_Debug(("Exiting: RegisterDmEngineWithSyncmlToolkit failed\n"));
+ return (ret_stat);
+ }
+
+ /* Create connection between server and client */
+ ret_stat = ConnectServer(pServerID);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_SESS_Error(("Cannot connect server\n"));
+ return (ret_stat);
+ }
+
+ /* Remember the sessionDirection in case we have to resend the Alert.*/
+ pSessionProp->generateSessionID();
+ serverSessionId = pSessionProp->getSessionID();
+
+
+ /* Build and send the package one to the Server. */
+ ret_stat = BuildSendPackageOne(pServerID, pSessionProp);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ return (ret_stat);
+
+ XPL_DM_NotifySessionProgress(TRUE);
+
+ while (bMoreMessage == TRUE && g_cancelSession == 0)
+ {
+ /* Call the method to receive the package from the transport.*/
+ ret_stat = RecvPackage();
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ XPL_DM_NotifySessionProgress(FALSE);
+ return ret_stat;
+ }
+
+ /* Call the method to parse and handle the commands in the package.*/
+ commandCount = 0;
+
+ #ifndef DM_NO_LOCKING
+ int nLockID = 0;
+
+ {
+ DMLockingHelper oLock( 0, ".", pServerID, SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE );
+ nLockID = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() )
+ {
+ XPL_DM_NotifySessionProgress(FALSE);
+ return SYNCML_DM_FAIL;
+ }
+
+ ret_stat = ParseMessage();
+ }
+
+ dmTreeObj.ReleaseLock( nLockID );
+#else
+ ret_stat = ParseMessage();
+#endif
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ XPL_DM_NotifySessionProgress(FALSE);
+ return ret_stat;
+ }
+
+ /* Check to see if we are passed the max retries */
+ if (serverRetryCount > MAX_AUTH_RETRY || clientRetryCount > MAX_AUTH_RETRY)
+ {
+ XPL_DM_NotifySessionProgress(FALSE);
+ return SYNCML_DM_SESSION_AUTH_FAIL;
+ }
+
+ /* Check to see if any operational commands were parsed.*/
+ if ( commandCount != 0 && m_bSessionAborted == FALSE && g_cancelSession == 0)
+ {
+ ret_stat = SendPackage();
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ XPL_DM_NotifySessionProgress(FALSE);
+ return ret_stat;
+ }
+ }
+ else
+ {
+ /* End the DM Session.*/
+ bMoreMessage = FALSE;
+
+ }
+ }
+
+ XPL_DM_NotifySessionProgress(FALSE);
+ return SYNCML_DM_SUCCESS;
+}
+
+
+/*==================================================================================================
+FUNCTION : DMServerSession::SetURI
+
+DESCRIPTION : The UserAgent::SetURI will call this function if receiving package set the
+ response URI to a new value.
+ The function will call Connection object to set the URI of the SyncML server
+ for HTTP/WSP.
+ARGUMENT PASSED : p_RespURI
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS if success,
+ SYNCML_DM_FAIL if failed.
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMServerSession::SetURI (const char *p_RespURI)
+{
+ return m_oConnObject.SetURI(p_RespURI);
+}
+
+
+
+/*==================================================================================================
+FUNCTION : DMServerSession::RecvPackage
+
+DESCRIPTION : The UserAgent::TransportMsg will call this function when data is received
+ This function calls SYNCML_DM_Connection::Recv() to get the DM docuemnt from the
+ Transport.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMServerSession::RecvPackage()
+{
+ SYNCML_DM_RET_STATUS_T serverAuthStatus = SYNCML_DM_SUCCESS;
+ SYNCMLDM_SEC_CREDENTIALS_T *pGenHmac;
+ UINT8 decodedNonce[MAX_BIN_NONCE_LEN];
+ UINT32 encodedNonceLen =0;
+ UINT32 decodedNonceLen =0;
+ SYNCML_DM_RET_STATUS_T retStat = SYNCML_DM_SUCCESS;
+
+
+ pWritePos = recvSmlDoc.pData;
+
+ /* Unlock the workspace so the Toolkit controls it again. */
+ smlUnlockReadBuffer(sendInstanceId, workspaceUsedSize);
+
+ /* Check if the HMAC-MD5 headers were included.*/
+ if( m_oRecvCredHeaders.empty() == FALSE )
+ {
+ //XPL_LOG_DM_SESS_Debug(("m_oRecvCredHeaders is not empty.\n"));
+ //XPL_LOG_DM_SESS_Debug(("m_oRecvCredHeaders: username:%s\n", (CPCHAR)(m_oRecvCredHeaders.m_oUserName.getBuffer())));
+ //XPL_LOG_DM_SESS_Debug(("m_oRecvCredHeaders: mac:%s\n", (CPCHAR)(m_oRecvCredHeaders.m_oMac.getBuffer())));
+
+ SYNCMLDM_HMAC_SEC_INFO_T hmacSecInfo;
+ // since server sends hmac, use hmac after that
+ clientServerCreds.SetPrefServerAuth(SYNCML_DM_CHAL_HMAC);
+
+ /* Remember that the Cred Headers are here.*/
+ SetServCredsMissing(FALSE);
+
+ /* Copy the received DM document into the SyncML workspace */
+ /* Create the Server Credentials.*/
+ hmacSecInfo.pb_user_name_or_server_id = (UINT8*)clientServerCreds.pServerId.c_str();
+ hmacSecInfo.pb_password = (UINT8*)clientServerCreds.pServerPW.c_str();
+ hmacSecInfo.o_encode_base64 = TRUE; /* Always true for HMAC */
+ hmacSecInfo.pb_syncml_document = pWritePos; /* Pointer for SyncML Doc */
+ hmacSecInfo.dw_syncml_document_length = recvSmlDoc.dataSize; /* Size of Doc*/
+
+ /* Validate the HMAC-MD5 header from the HTTP header.
+ * We will check every message regardless of the Security state.
+ * The ServerNonce string is b64 encoded and must be decoded now.*/
+ if(clientServerCreds.pServerNonce != NULL)
+ {
+ encodedNonceLen = DmStrlen((const char *)clientServerCreds.pServerNonce);
+ decodedNonceLen = base64Decode((unsigned char *)decodedNonce,
+ MAX_BIN_NONCE_LEN,
+ (unsigned char*)clientServerCreds.pServerNonce.c_str(),
+ (unsigned long*)&encodedNonceLen);
+ }
+
+ /* Generate the Server Credentials.*/
+ hmacSecInfo.pb_nonce = decodedNonce;
+ hmacSecInfo.w_nonce_length = decodedNonceLen;
+
+ pGenHmac = syncmldm_sec_build_hmac_cred((const SYNCMLDM_HMAC_SEC_INFO_T *)&hmacSecInfo);
+
+ /* Compare the created creds to the received creds.*/
+ if ( pGenHmac == NULL || !m_oRecvCredHeaders.m_oMac.compare((CPCHAR)pGenHmac->ab_credential_string,
+ pGenHmac->w_credential_string_length) )
+
+ {
+ serverAuthStatus = SYNCML_DM_UNAUTHORIZED;
+ serverRetryCount++;
+ }
+ else
+ {
+ /* Reset count since server is now authenticated.*/
+ serverRetryCount = 0;
+ }
+ DmFreeMem(pGenHmac);
+
+ /* Update the security state with the server authentication status. Note that
+ * we only check for cases that cause a change in the SecurityState.
+ */
+ switch (m_nSecState)
+ {
+ case DM_CLIENT_NO_SERVER_NO_AUTH:
+ if (serverAuthStatus == SYNCML_DM_SUCCESS)
+ m_nSecState = DM_CLIENT_NO_SERVER_Y_AUTH;
+ break;
+
+ case DM_CLIENT_Y_SERVER_NO_AUTH:
+ if (serverAuthStatus == SYNCML_DM_SUCCESS)
+ m_nSecState = DM_BOTH_CLIENT_SERVER_AUTH;
+ break;
+
+ case DM_CLIENT_NO_SERVER_Y_AUTH:
+ if (serverAuthStatus != SYNCML_DM_SUCCESS)
+ m_nSecState = DM_CLIENT_NO_SERVER_NO_AUTH;
+ break;
+
+ case DM_BOTH_CLIENT_SERVER_AUTH:
+ if (serverAuthStatus != SYNCML_DM_SUCCESS)
+ m_nSecState = DM_CLIENT_Y_SERVER_NO_AUTH;
+ break;
+
+ default:
+ /* The Security State is messed up, so reset it.*/
+ m_nSecState = DM_CLIENT_NO_SERVER_NO_AUTH;
+ break;
+ }
+ /* Update the User Agent's security state.*/
+
+ } /* p_cred_headers != NULL */
+ else
+ {
+ /* The HMAC-MD5 creditials are missing.*/
+ if ( !IsServerAuthorized() )
+ {
+ SetServCredsMissing(TRUE);
+ serverRetryCount++;
+ }
+ else
+ serverRetryCount = 0;
+
+ }
+
+ return(retStat);
+
+}
+
+
+/*==================================================================================================
+FUNCTION : DMServerSession::SendPackage
+
+DESCRIPTION : This function will be called when a DM package is built up and ready to send.
+ The function will call SYNCML_DM_Connection::Send() to send the DM document to
+ the remote server.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES : Both sendSmlDoc and pRecvSmlDoc must pass to pConnObject->Send. pConnObject will
+ write receiving DM document to the pRecvSmlDoc after it sends sendSmlDoc.
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMServerSession::SendPackage()
+{
+ SYNCMLDM_HMAC_SEC_INFO_T hmacSecInfo;
+ SYNCMLDM_SEC_CREDENTIALS_T *pHmacCreds = NULL;
+ SYNCML_DM_RET_STATUS_T ret_stat;
+ UINT8 decodedNonce[MAX_BIN_NONCE_LEN];
+ UINT32 encodedNonceLen = 0;
+ UINT32 decodedNonceLen = 0;
+ Ret_t sml_ret_stat;
+
+ /* Lock the workspace for reading and writing SyncML document.
+ * These buffers will be unlocked after the UA receives SyncML document */
+ smlLockReadBuffer(sendInstanceId, &pReadPos, &workspaceUsedSize);
+
+ /* Set sendSmlDoc point to workspace */
+ sendSmlDoc.dataSize = workspaceUsedSize;
+ sendSmlDoc.pData = pReadPos;
+
+ /* The ClientNonce string is b64 encoded and must be decoded now.*/
+ if(clientServerCreds.pClientNonce != NULL)
+ {
+ const char *clientNonce = clientServerCreds.pClientNonce.c_str();
+ encodedNonceLen = DmStrlen(clientNonce);
+ if (encodedNonceLen == 0) {
+ clientNonce = SERVER_RESYNC_NONCE;
+ encodedNonceLen = DmStrlen(clientNonce);
+ }
+ decodedNonceLen = base64Decode((UINT8*)decodedNonce,
+ MAX_BIN_NONCE_LEN,
+ (unsigned char*)clientNonce,
+ (unsigned long*)&encodedNonceLen);
+ }
+ /* Let's make up our credentials before we send the package. */
+ hmacSecInfo.pb_user_name_or_server_id = (UINT8*)clientServerCreds.pClientUserName.c_str();
+ hmacSecInfo.pb_password = (UINT8*)clientServerCreds.pClientPW.c_str();
+ hmacSecInfo.pb_nonce = decodedNonce;
+ hmacSecInfo.pb_syncml_document = pReadPos; /* Used as the pointer to the SyncML Doc */
+ hmacSecInfo.o_encode_base64 = TRUE; /* Always true for HMAC credentials */
+ hmacSecInfo.w_nonce_length = decodedNonceLen;
+ hmacSecInfo.dw_syncml_document_length = workspaceUsedSize; /* Size of the SyncML Doc */
+
+ if( clientServerCreds.AuthPrefCredType == SYNCML_DM_CHAL_HMAC )
+ pHmacCreds = syncmldm_sec_build_hmac_cred((const SYNCMLDM_HMAC_SEC_INFO_T *)&hmacSecInfo);
+
+ m_oRecvCredHeaders.clear();
+ if ( pHmacCreds != NULL )
+ {
+ if ( pHmacCreds->w_credential_string_length )
+ {
+ m_oRecvCredHeaders.m_oMac.assign(pHmacCreds->ab_credential_string,pHmacCreds->w_credential_string_length);
+ if ( m_oRecvCredHeaders.m_oMac.getBuffer() == NULL )
+ {
+ FreeAndSetNull(pHmacCreds);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+
+ m_oRecvCredHeaders.m_oAlgorithm.assign(SYNCML_MAC_ALG);
+ if ( m_oRecvCredHeaders.m_oAlgorithm.getBuffer() == NULL )
+ {
+ FreeAndSetNull(pHmacCreds);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ if ( clientServerCreds.pClientUserName )
+ {
+ m_oRecvCredHeaders.m_oUserName.assign((CPCHAR)clientServerCreds.pClientUserName);
+ if ( m_oRecvCredHeaders.m_oUserName.getBuffer() == NULL )
+ {
+ FreeAndSetNull(pHmacCreds);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ }
+
+ sml_ret_stat = smlLockWriteBuffer(recvInstanceId, &pWritePos, &workspaceFreeSize);
+
+ if ( sml_ret_stat == SML_ERR_OK )
+ {
+ recvSmlDoc.pData = pWritePos;
+ ret_stat = m_oConnObject.Send(&sendSmlDoc, &recvSmlDoc, smlContentType, &m_oRecvCredHeaders);
+ }
+ else
+ ret_stat = SYNCML_DM_FAIL;
+
+ FreeAndSetNull(pHmacCreds);
+ return (ret_stat);
+}
+
+
+/*==================================================================================================
+FUNCTION : DMProcessScriptSession::SetServCredsMissing
+
+DESCRIPTION : This function reset class data members value to defaults after one DM session is
+ ended.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+
+==================================================================================================*/
+void
+DMServerSession::SetServCredsMissing( BOOLEAN newIsServCredsMissing )
+{
+ isServCredsMissing = newIsServCredsMissing;
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/dmSession.cc b/engine/dmlib/dmengine/dm_ssession/src/dmSession.cc
new file mode 100644
index 0000000..bef538a
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/dmSession.cc
@@ -0,0 +1,278 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Header Name: DMSession.cc
+
+ General Description: Implementation of DMSession class.
+
+==================================================================================================*/
+
+#include "dmSession.h"
+
+extern "C" {
+#include "xpt-b64.h"
+#include "stdio.h"
+}
+
+#include "xpl_Logger.h"
+
+/*==================================================================================================
+FUNCTION : DMSession::DMSession
+
+DESCRIPTION : The class constructor.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+DMSession::DMSession()
+{
+
+ smlContentType = NULL;
+ smlEncodingType = SML_UNDEF;
+
+ sendInstanceId = 0xFF;
+
+ pWritePos = NULL;
+ pReadPos = NULL;
+
+ memset( &sendSmlDoc, 0, sizeof(sendSmlDoc));
+ memset( &recvSmlDoc, 0, sizeof(recvSmlDoc));
+
+ workspaceFreeSize = 0;
+ workspaceUsedSize = 0;
+
+}
+
+/*==================================================================================================
+FUNCTION : DMSession::~DMSession
+
+DESCRIPTION : The class destructor.
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+DMSession::~DMSession ()
+{
+ /* Free all the Client and Server Credential memory.*/
+ UnRegisterDmEngineWithSyncmlToolkit();
+ if ( smlContentType )
+ DmFreeMem(smlContentType);
+}
+
+/*==================================================================================================
+FUNCTION : DMSession::Init
+
+DESCRIPTION : The class constructor.
+ARGUMENT PASSED : sml_ContentType
+ sml_EncodingType
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T DMSession::Init(BOOLEAN isWBXML)
+{
+ INT32 size;
+
+ size = DmStrlen(SYNCML_CONTENT_TYPE_DM_WBXML)+1;
+ smlContentType = (UINT8 *)DmAllocMem(size);
+ if ( smlContentType == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ if ( isWBXML )
+ {
+ DmStrncpy((char *)smlContentType, SYNCML_CONTENT_TYPE_DM_WBXML, size);
+ smlEncodingType = SML_WBXML;
+ }
+ else
+ {
+ DmStrncpy((char *)smlContentType, SYNCML_CONTENT_TYPE_DM_XML, size);
+ smlEncodingType = SML_XML;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+FUNCTION : DMSession::SetToolkitCallbacks
+
+DESCRIPTION : This function will to set toolkit callback functions.
+
+
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : It returns SYNCML_DM_SUCCESS.
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMSession::SetToolkitCallbacks(SmlCallbacks_t * pSmlCallbacks)
+{
+
+ pSmlCallbacks->startMessageFunc = NULL;
+ pSmlCallbacks->endMessageFunc = NULL;
+
+ pSmlCallbacks->addCmdFunc = NULL;
+
+ pSmlCallbacks->alertCmdFunc = NULL;
+ pSmlCallbacks->copyCmdFunc = NULL;
+ pSmlCallbacks->deleteCmdFunc = NULL;
+ pSmlCallbacks->getCmdFunc = NULL;
+
+ pSmlCallbacks->startAtomicFunc = NULL;
+ pSmlCallbacks->endAtomicFunc = NULL;
+
+ pSmlCallbacks->startSequenceFunc = NULL;
+ pSmlCallbacks->endSequenceFunc = NULL;
+
+ pSmlCallbacks->execCmdFunc = NULL;
+ pSmlCallbacks->statusCmdFunc = NULL;
+ pSmlCallbacks->replaceCmdFunc = NULL;
+
+ /* The transmitChunkFunc callback is required for support of Large Objects. */
+ pSmlCallbacks->transmitChunkFunc = NULL;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+FUNCTION : DMSession::RegisterDmEngineWithSyncmlToolkit
+
+DESCRIPTION : This function will to register the DM Engine with the SyncML Toolkit.
+
+ The function will perform the following operations:
+ 1) Call smlInit() to initialize the SyncML Toolkit.
+ 2) Allocate all callback functions.
+ 3) Call smlInitInstance() to initialize the SyncML instances.
+
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : It returns SYNCML_DM_SUCCESS when the DM Engine is registered with the SyncML
+ Toolkit successfully, SYNCML_DM_FAIL when any error occurs.
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMSession::RegisterDmEngineWithSyncmlToolkit(VoidPtr_t pUserData)
+{
+ SmlOptions_t smlOptions; /* Structure describing the options and
+ * setting of this syncml process */
+ SmlCallbacks_t smlCallbacks; /* Structure defining references to the
+ * applications callback implementations */
+ SmlInstanceOptions_t smlInstOptionsRecvDoc; /* Structure specifying options to be used for
+ Recv DM doc instance */
+ SmlInstanceOptions_t smlInstOptionsSendDoc; /* Structure specifying options to be used for
+ Send DM doc instance */
+
+ Ret_t sml_ret_stat;
+ SYNCML_DM_RET_STATUS_T dm_ret_stat = SYNCML_DM_SUCCESS;
+
+ //fdp101: make sure we don't have un-inited fields in structs...
+ memset( &smlOptions, 0, sizeof(smlOptions));
+ memset( &smlCallbacks, 0, sizeof(smlCallbacks));
+ memset( &smlInstOptionsRecvDoc, 0, sizeof(smlInstOptionsRecvDoc));
+ memset( &smlInstOptionsSendDoc, 0, sizeof(smlInstOptionsSendDoc));
+
+ /* Set Toolkit options and setting of this syncml process */
+ smlOptions.defaultPrintFunc = NULL;
+
+ /* maxWorkspaceAvailMem is the size which all workspaces in total MUST not exceed. Since we have
+ * send and recv document exist at the same time, the available memory size is 2 times of the
+ * DM_SMLTK_WORKSPACE_SIZE */
+ smlOptions.maxWorkspaceAvailMem = NUMBER_OF_WORKSPACE * g_iDMWorkspaceSize; //DM_SMLTK_WORKSPACE_SIZE;
+
+ /* Initialize SyncML Toolkit */
+ sml_ret_stat = smlInit(&smlOptions);
+ if (sml_ret_stat != SML_ERR_OK)
+ {
+ return (SYNCML_DM_FAIL);
+ }
+
+ /* Receiving DM document instance */
+ smlInstOptionsRecvDoc.encoding = smlEncodingType; /* Use WBXML or XML encoding */
+ smlInstOptionsRecvDoc.workspaceName = (char *)DmAllocMem(WORKSPACE_NAME_LEN);
+ DmStrcpy(smlInstOptionsRecvDoc.workspaceName, RECV_WORKSPACE_NAME);
+ smlInstOptionsRecvDoc.workspaceSize = g_iDMWorkspaceSize; //DM_SMLTK_WORKSPACE_SIZE;
+
+ /* Sending DM dcoument instance */
+ smlInstOptionsSendDoc.encoding = smlEncodingType; /* Use WBXML or XML encoding */
+ smlInstOptionsSendDoc.workspaceName = (char *)DmAllocMem(WORKSPACE_NAME_LEN);
+ smlLibStrcpy(smlInstOptionsSendDoc.workspaceName, SEND_WORKSPACE_NAME);
+ smlInstOptionsSendDoc.workspaceSize = g_iDMWorkspaceSize; //DM_SMLTK_WORKSPACE_SIZE;
+
+ /* Allocate function pointers for callbacks structure */
+ /* Protocol Management Callbacks */
+ dm_ret_stat = SetToolkitCallbacks(&smlCallbacks);
+
+ /* The transmitChunkFunc callback is required for support of Large Objects. */
+
+ smlCallbacks.transmitChunkFunc = NULL;
+
+ /* Initialize the SyncML instance, get an instance Id, and assigns to it a workspace buffer in
+ which SyncML will assemble or parse XML documents.
+ */
+ sml_ret_stat = smlInitInstance(&smlCallbacks, &smlInstOptionsRecvDoc, pUserData, &recvInstanceId);
+ if (sml_ret_stat != SML_ERR_OK)
+ {
+ /* Free the memory and exit now.*/
+ DmFreeMem(smlInstOptionsRecvDoc.workspaceName);
+ DmFreeMem(smlInstOptionsSendDoc.workspaceName);
+ smlTerminate();
+ return (SYNCML_DM_FAIL);
+ }
+ sml_ret_stat = smlInitInstance(&smlCallbacks, &smlInstOptionsSendDoc, pUserData, &sendInstanceId);
+ if (sml_ret_stat != SML_ERR_OK)
+ {
+ /* Undo the first instance, free the memory and exit.*/
+ smlTerminateInstance(recvInstanceId);
+ DmFreeMem(smlInstOptionsRecvDoc.workspaceName);
+ DmFreeMem(smlInstOptionsSendDoc.workspaceName);
+ smlTerminate();
+ return (SYNCML_DM_FAIL);
+ }
+
+ /* Free the memory which we allocated */
+ DmFreeMem(smlInstOptionsRecvDoc.workspaceName);
+ DmFreeMem(smlInstOptionsSendDoc.workspaceName);
+
+ return (dm_ret_stat);
+}
+
+/*==================================================================================================
+FUNCTION : DMSession::UnRegisterDmEngineWithSyncmlToolkit
+
+DESCRIPTION : This function will be called by the SYNCML_DM_Session::SessionEnd() to un-register
+ the DM Engine with the SyncML Toolkit.
+
+ The function will perform the following operations:
+ 1) Call smlTerminateInstance() to close the SyncML instance.
+ 2) Call smlTerminate() to close the Toolkit session.
+
+ARGUMENT PASSED :
+OUTPUT PARAMETER:
+RETURN VALUE : It returns SML_ERR_OK when the DM Engine is un-registered with the SyncML Toolkit
+ successfully, error code when any error occurs.
+IMPORTANT NOTES :
+==================================================================================================*/
+void
+DMSession::UnRegisterDmEngineWithSyncmlToolkit()
+{
+ /* Close SyncML instance and Toolkit session */
+ smlTerminateInstance(recvInstanceId);
+ smlTerminateInstance(sendInstanceId);
+ smlTerminate();
+}
diff --git a/engine/dmlib/dmengine/dm_ssession/src/dmSessionFactory.cc b/engine/dmlib/dmengine/dm_ssession/src/dmSessionFactory.cc
new file mode 100644
index 0000000..a689743
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/dmSessionFactory.cc
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmSessionFactory.cc
+
+ General Description: Implementation of Internal interfaces to Server Session.
+
+==================================================================================================*/
+
+#include "dmtSessionProp.hpp"
+#include "dmMemory.h"
+#include "dmSessionFactory.h"
+#include "xpl_Time.h"
+#include "xpl_Logger.h"
+#include "dmProcessScriptSession.h"
+#include "dmBootstrapSession.h"
+#include "dmServerSession.h"
+#include "dmServerAuthentication.h"
+
+/*
+ * The instance data of the application
+ */
+
+INT32 g_iDMWorkspaceSize = DEFAULT_DM_SMLTK_WORKSPACE_SIZE;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void DmSetWorkspaceSize(UINT32 inDocSize)
+{
+ if (inDocSize <= DEFAULT_DM_SMLTK_WORKSPACE_SIZE) {
+ g_iDMWorkspaceSize = DEFAULT_DM_SMLTK_WORKSPACE_SIZE;
+ } else {
+ g_iDMWorkspaceSize = ((inDocSize / 1000) + 1 ) * 1000;
+ }
+}
+
+SYNCML_DM_RET_STATUS_T DmProcessServerDataInternal(CPCHAR szPrincipal, const DmtSessionProp& sessionProp)
+{
+ SYNCML_DM_RET_STATUS_T retStat;
+
+ g_iDMWorkspaceSize = DEFAULT_DM_SMLTK_WORKSPACE_SIZE;
+
+ DMServerSession * pSessionObj = new DMServerSession();
+
+ if ( pSessionObj == NULL )
+ {
+ XPL_LOG_DM_SESS_Error(("SYNCML_DM_UserAgent::SessionStart : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ retStat = pSessionObj->Start(szPrincipal,(DmtSessionProp*)&sessionProp);
+
+ delete pSessionObj;
+ XPL_LOG_DM_SESS_Debug(("Returning from DmProcessServerDataInternal, status=%d\n", retStat));
+ return retStat;
+}
+
+SYNCML_DM_RET_STATUS_T DmProcessScriptDataInternal(const UINT8 *docInputBuffer ,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ DMBuffer & oResult)
+{
+
+ SYNCML_DM_RET_STATUS_T retStat;
+
+ DmSetWorkspaceSize(inDocSize);
+
+ DMProcessScriptSession * pSessionObj = new DMProcessScriptSession();
+
+ if ( pSessionObj == NULL )
+ {
+ XPL_LOG_DM_SESS_Error(("SYNCML_DM_UserAgent::SessionStart : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ retStat = pSessionObj->Start(docInputBuffer,inDocSize,isWBXML,oResult);
+
+ delete pSessionObj;
+
+ return retStat;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmBootstrapInternal(const UINT8 *docInputBuffer ,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMString & serverID)
+{
+ SYNCML_DM_RET_STATUS_T retStat;
+
+ DmSetWorkspaceSize(inDocSize);
+
+ if ( isProcess )
+ {
+ DMBuffer oResult;
+ DMProcessScriptSession * pSessionObj = new DMProcessScriptSession();
+
+ if ( pSessionObj == NULL )
+ {
+ XPL_LOG_DM_SESS_Error(("SYNCML_DM_UserAgent::SessionStart : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ retStat = pSessionObj->Start(docInputBuffer,inDocSize,isWBXML,oResult);
+
+ delete pSessionObj;
+ }
+ else
+ {
+ DMBootstrapSession oSession;
+
+ retStat = oSession.Start(docInputBuffer,inDocSize,isWBXML,serverID);
+ }
+ return retStat;
+}
+
+SYNCML_DM_RET_STATUS_T DmAuthenticateServerInternal(SYNCML_DM_AuthContext_T& AuthContext )
+{
+
+ DMServerAuthentication oAuth;
+
+ return oAuth.AuthenticateServer(AuthContext);
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/dmengine/dm_ssession/src/dm_ua_handlecommand.cc b/engine/dmlib/dmengine/dm_ssession/src/dm_ua_handlecommand.cc
new file mode 100644
index 0000000..b0e59ec
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ssession/src/dm_ua_handlecommand.cc
@@ -0,0 +1,2909 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Header Name: dm_ua_handlecommand.cc
+
+ General Description: Implementation of SyncML toolkit callback functions.
+
+==================================================================================================*/
+
+#include "dmstring.h"
+#include "dmStringUtil.h"
+#include "dm_tree_util.h"
+#include "xpl_dm_Manager.h"
+#include "dm_ua_handlecommand.h"
+#include "dmProcessScriptSession.h"
+#include "dmServerSession.h"
+#include "dm_security.h"
+#include "dmLockingHelper.h"
+#include "SYNCML_DM_DisplayAlert.H"
+#include "SYNCML_DM_ConfirmAlert.H"
+#include "SYNCML_DM_TextInputAlert.H"
+#include "SYNCML_DM_SingleChoiceAlert.H"
+#include "SYNCML_DM_MultipleChoiceAlert.H"
+#include "xpl_Logger.h"
+
+#include "xlttags.h"
+
+extern "C" {
+#include "smlerr.h"
+#include "xpt-b64.h"
+}
+
+/*==================================================================================================
+ TYPEDEFS
+==================================================================================================*/
+/* Note that the order of this table MUST match the order of the SYNCML_DM_COMMAND_T enum in
+ * syncml_dm_data_types.h
+ */
+static const CPCHAR dm_command_name_table[] = {
+ "", //SYNCML_DM_NO_COMMAND
+ "Add", //SYNCML_DM_ADD
+ "Delete", //SYNCML_DM_DELETE
+ "Replace", //SYNCML_DM_REPLACE
+ "Get", //SYNCML_DM_GET
+ "Rename", //SYNCML_DM_RENAME
+ "Exec", //SYNCML_DM_EXEC
+ "Copy", //SYNCML_DM_COPY
+ "Alert", //SYNCML_DM_ALERT
+ "SyncHdr", //SYNCML_DM_HEADER
+ "Status", //SYNCML_DM_STATUS
+ "Atomic", //SYNCML_DM_ATOMIC
+ "Sequence" //SYNCML_DM_SEQUENCE
+};
+
+static SYNCML_DM_BuildPackage *pDmBuildPackage;
+static DMProcessScriptSession *pDmMgmtSessionObj;
+
+/* Since SyncHdr STATUS doesn't get constructed until the receiving package's STATUS command is
+ * handled, we need to save synchdr_dm_stat when the starting message is handled. Keep it until
+ * SyncHdr STATUS is constructed. */
+static SYNCML_DM_RET_STATUS_T synchdr_dm_stat = SYNCML_DM_SUCCESS;
+
+static SYNCML_DM_CHAL_TYPE_T s_nSrvSecLevel = SYNCML_DM_CHAL_UNDEFINED;
+
+/*==================================================================================================
+ LOCAL FUNCTION PROTOTYPES
+==================================================================================================*/
+
+
+/*==================================================================================================
+ LOCAL FUNCTIONS
+==================================================================================================*/
+static inline SYNCML_DM_RET_STATUS_T SyncML2DMCode( const char* szSyncMLCode )
+{
+ SYNCML_DM_RET_STATUS_T nRet = DmAtoi( szSyncMLCode );
+
+ if ( nRet == 200 )
+ return SYNCML_DM_SUCCESS;
+
+ return nRet;
+}
+
+
+
+/*==================================================================================================
+ FUNCTIONS
+==================================================================================================*/
+
+/*==================================================================================================
+FUNCTION : SetMetaData
+
+DESCRIPTION : The utility function to set up the meta data.
+
+ARGUMENT PASSED : p_meta_info
+OUTPUT PARAMETER: pp_type
+ p_format
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SetMetaData(SmlPcdataPtr_t p_meta_data,
+ DMBuffer& pp_type,
+ SYNCML_DM_FORMAT_T *p_format)
+{
+ SmlMetInfMetInfPtr_t p_meta_info;
+ CPCHAR p_temp_content;
+
+ /* Setup OUTPUT parameter type and format. If p_meta_data is not set, assign default value
+ to OUTPUT parameters, type as "text/plain", format as "chr". */
+ if (p_meta_data != NULL)
+ {
+ if (p_meta_data->content != NULL)
+ {
+ if ( SML_PCDATA_EXTENSION != p_meta_data->contentType &&
+ SML_EXT_METINF != p_meta_data->extension )
+ {
+ *p_format = SYNCML_DM_FORMAT_CHR;
+ pp_type.assign("text/plain");
+ }
+ else
+ {
+ p_meta_info = (SmlMetInfMetInfPtr_t)p_meta_data->content;
+ if ((p_meta_info->format != NULL) &&
+ (p_meta_info->format->length != 0))
+ {
+ p_temp_content = (CPCHAR)p_meta_info->format->content;
+ *p_format = DMTree::ConvertFormatStr(p_temp_content);
+ }
+ else
+ {
+ /* If there is no format information, set p_format as default format "chr" */
+ *p_format = SYNCML_DM_FORMAT_CHR;
+ }
+ /* Set p_temp_type to the passed in type */
+ if((p_meta_info->type != NULL) && (p_meta_info->type->length != 0))
+ {
+ pp_type.assign((UINT8*)p_meta_info->type->content,p_meta_info->type->length);
+ }
+ else
+ {
+ /* If there is no type information, set the type as 'text/plain' */
+ pp_type.assign("text/plain");
+ }
+ }
+ }
+ }
+ else
+ {
+ *p_format = SYNCML_DM_FORMAT_CHR;
+ pp_type.assign("text/plain");
+ }
+
+ if ( pp_type.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+/*==================================================================================================
+FUNCTION : SetExecResultsData
+
+DESCRIPTION : The utility function to set up the results data for Exec command.
+
+ARGUMENT PASSED : p_passedin_result_item. p_target_uri
+ p_exec_ret_data
+OUTPUT PARAMETER: p_passedin_result_item
+
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+SetExecResultsData(SmlItemPtr_t p_passedin_result_item,
+ CPCHAR pURI,
+ const DMString & execResults)
+{
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ char data_size_str[UINT32_TYPE_STR_SIZE_10];
+
+
+ p_passedin_result_item->source = smlAllocSource();
+ if ( p_passedin_result_item->source == NULL )
+ return SYNCML_DM_FAIL;
+
+ pDmBuildPackage->BuildPcData(p_passedin_result_item->source->locURI, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,DmStrlen(pURI),(UINT8*)pURI);
+
+ /* Convert the dwRetDataSize to a string */
+ DmSprintf(data_size_str, "%d", execResults.length());
+ p_passedin_result_item->meta = smlAllocPcdata();
+ if ( p_passedin_result_item->meta == NULL )
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+
+ pDmBuildPackage->BuildMetaInfo(
+ p_passedin_result_item->meta,
+ NULL, NULL, NULL,
+ (UINT8*)data_size_str,
+ NULL, NULL, NULL, NULL);
+
+ /* Set the p_passedin_result_item->data */
+ /* Client construct <Data> element no matter there are data from GET command or not. */
+ p_passedin_result_item->data = smlAllocPcdata();
+ if ( p_passedin_result_item->data == NULL )
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+ pDmBuildPackage->BuildPcData(p_passedin_result_item->data, SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,execResults.length(),(UINT8*)execResults.c_str());
+ return sml_ret_stat;
+}
+
+
+static SYNCML_DM_RET_STATUS_T SaveStatus(UINT8 *p_CmdRefData,
+ UINT8 *p_CmdName,
+ UINT8 *p_SourceRefData,
+ UINT8 *p_TargetRefData,
+ UINT16 status_Code,
+ const DMStringVector* responses,
+ SYNCML_DM_USER_DATA_T *pUserData )
+{
+ SmlStatusPtr_t pStatus = pDmBuildPackage->AllocateStatus(
+ p_CmdRefData, p_CmdName, p_SourceRefData, p_TargetRefData, NULL,
+ status_Code, responses );
+
+ if ( !pStatus )
+ return SYNCML_DM_FAIL;
+
+ pUserData->aStatuses.push_back((UINT32)pStatus);
+ return SYNCML_DM_SUCCESS;
+}
+
+
+static SYNCML_DM_RET_STATUS_T
+SaveCommandRefStatus(UINT8 *p_CmdRefData,
+ UINT8 *p_CmdName,
+ SmlItemPtr_t pCommandItem,
+ SYNCML_DM_RET_STATUS_T status_Code,
+ SYNCML_DM_USER_DATA_T *pUserData )
+{
+
+ UINT8 *p_SourceRefData = NULL;
+ UINT8 *p_TargetRefData = NULL;
+ SmlStatusPtr_t pStatus = NULL;
+
+ if(pCommandItem->target != NULL && pCommandItem->target->locURI != NULL)
+ p_TargetRefData = (UINT8 *)pCommandItem->target->locURI->content;
+ else
+ {
+ if ( status_Code == SYNCML_DM_SUCCESS )
+ status_Code = SYNCML_DM_BAD_REQUEST;
+ }
+
+ if (pCommandItem->source != NULL && pCommandItem->source->locURI != NULL)
+ p_SourceRefData = (UINT8*)pCommandItem->source->locURI->content;
+
+ return SaveStatus(p_CmdRefData,
+ p_CmdName,
+ p_SourceRefData,
+ p_TargetRefData,
+ status_Code,
+ NULL,
+ pUserData);
+
+ if ( !pStatus )
+ return SYNCML_DM_FAIL;
+
+ pUserData->aStatuses.push_back((UINT32)pStatus);
+ return SYNCML_DM_SUCCESS;
+}
+
+static SYNCML_DM_RET_STATUS_T SaveResult(CPCHAR pStrTargetUri,
+ CPCHAR p_CmdIdRef,
+ DMGetData *p_get_ret_data,
+ BOOLEAN is_ThisGetStructResult,
+ BOOLEAN isFirstGetStruct,
+ BOOLEAN isThisGetPropResult,
+ SYNCML_DM_USER_DATA_T *pUserData,
+ UINT8 type, // exec/get/getstruct
+ const SYNCML_DM_GET_ON_LIST_RET_DATA_T& oGetStructData )
+{
+ SmlResultsPtr_t p_results = NULL;
+ SmlPcdataPtr_t p_data = NULL;
+ SYNCML_DM_RET_STATUS_T nRes = SYNCML_DM_SUCCESS;
+ CPCHAR p_target_uri = pStrTargetUri;
+
+#ifdef TNDS_SUPPORT
+ SmlPcdata_t pcData;
+ if ( type == SYNCML_DM_RESULT_VALUE::Enum_Result_GetTnds )
+ {
+ p_target_uri = oGetStructData._pbURI;
+ nRes = pDmBuildPackage->AllocateTndsResult(pStrTargetUri, p_get_ret_data, oGetStructData, &pcData);
+ if ( nRes == SYNCML_DM_SUCCESS )
+ {
+ p_data = &pcData;
+ }
+ }
+#endif
+
+ nRes = pDmBuildPackage->AllocateResult( p_results, p_target_uri,
+ p_CmdIdRef, p_get_ret_data,
+ is_ThisGetStructResult, isFirstGetStruct,
+ isThisGetPropResult, NULL, p_data);
+
+ if ( nRes != SYNCML_DM_SUCCESS )
+ {
+ if ( NULL != p_results )
+ {
+ smlFreeResults(p_results);
+ p_results = NULL;
+ }
+ return nRes;
+ }
+
+ pUserData->aResults.push_back( SYNCML_DM_RESULT_VALUE( type, p_results,
+ oGetStructData, p_CmdIdRef,
+ (CPCHAR)pDmBuildPackage->GetMsgRef()) );
+ return nRes;
+}
+
+static SYNCML_DM_RET_STATUS_T AtomicRollback (VoidPtr_t userData)
+{
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+ SYNCML_DM_RET_STATUS_T retStatus=SYNCML_DM_FAIL;
+
+ if( !pUserData->rollback )
+ {
+ retStatus = dmTreeObj.GetLockContextManager().ReleaseIDInternal( SYNCML_DM_LOCKID_CURRENT, SYNCML_DM_ROLLBACK);
+
+ pUserData->pAtomicStatus.status = SYNCML_DM_ATOMIC_FAILED;
+
+ if (retStatus != SYNCML_DM_SUCCESS)
+ retStatus = SYNCML_DM_ATOMIC_ROLLBACK_FAILED;
+ else
+ retStatus = SYNCML_DM_ATOMIC_ROLLBACK_OK;
+
+ for ( int i = 0; i <pUserData->oStatus.size(); i++ )
+ pUserData->oStatus[i].status = retStatus;
+
+ pUserData->rollback = TRUE;
+ }
+ return retStatus;
+}
+
+
+static void SequenceStatus(VoidPtr_t userData, SYNCML_DM_RET_STATUS_T status)
+{
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+
+ if ( pUserData->IsSequence() )
+ {
+ if ( status != SYNCML_DM_SUCCESS )
+ pUserData->sequenceFailed = TRUE;
+ }
+}
+
+static void CheckAuthorization( SmlCredPtr_t pCred )
+{
+ DMClientServerCreds *pClientServerCreds = pDmMgmtSessionObj->GetClientServerCreds();
+ SmlMetInfMetInfPtr_t pMeta = NULL;
+
+ // check default required level
+ if ( s_nSrvSecLevel == SYNCML_DM_CHAL_UNDEFINED )
+ {
+ CPCHAR szStr = XPL_DM_GetEnv(SYNCML_DM_SECURITY_LEVEL);
+ if ( !szStr )
+ s_nSrvSecLevel = SYNCML_DM_CHAL_BASIC;
+ else {
+ s_nSrvSecLevel = DmAtoi(szStr);
+
+ if ( s_nSrvSecLevel < SYNCML_DM_CHAL_NONE ||
+ s_nSrvSecLevel > SYNCML_DM_CHAL_HMAC )
+ s_nSrvSecLevel = SYNCML_DM_CHAL_BASIC;
+ }
+ }
+
+ if ( pClientServerCreds->ServerChalType <= SYNCML_DM_CHAL_NONE )
+ pClientServerCreds->SetPrefServerAuth(s_nSrvSecLevel); // use default only if it's not set yet
+
+ if ( pClientServerCreds->ServerChalType == SYNCML_DM_CHAL_HMAC )
+ return; // authorization performed in onStatus handler
+
+ // if none - just authorize at once, but if server provides credentials - verify it
+ if ( pClientServerCreds->ServerChalType == SYNCML_DM_CHAL_NONE )
+ pDmMgmtSessionObj->SetSecStateSrv( TRUE );
+
+ if ( !pCred || !pCred->data || !pCred->meta)
+ return; // no credentials
+
+ const char* szType = NULL;
+ const char* szData = NULL;
+
+ szData = (const char*)pCred->data->content;
+
+ if ( pCred->meta->contentType == SML_PCDATA_EXTENSION &&
+ pCred->meta->extension == SML_EXT_METINF ){
+ pMeta = (SmlMetInfMetInfPtr_t)pCred->meta->content;
+
+ if ( pMeta && pMeta->type && pMeta->type->contentType == SML_PCDATA_STRING )
+ szType = (const char*)pMeta->type->content;
+ }
+
+ if ( !szType || !szData )
+ return;
+
+ SYNCMLDM_SEC_CREDENTIALS_T *pGenCred = NULL;
+
+ if ( DmStrcmp(szType, SYNCML_AUTH_BASIC) == 0 )
+ {
+ if ( pClientServerCreds->ServerChalType > SYNCML_DM_CHAL_BASIC)
+ return; // basic is not allowed
+
+ pClientServerCreds->SetPrefServerAuth(SYNCML_DM_CHAL_BASIC); // use basic after that for this session
+
+ SYNCMLDM_BASIC_SEC_INFO_T basicSecInfo;
+
+ basicSecInfo.pb_password = (UINT8*)pClientServerCreds->pServerPW.c_str();
+ basicSecInfo.pb_user_name_or_server_id = (UINT8*)pClientServerCreds->pServerId.c_str();
+
+ pGenCred = syncmldm_sec_build_basic_cred(&basicSecInfo);
+ }
+ else
+ if ( DmStrcmp(szType, SYNCML_AUTH_MD5) == 0 )
+ {
+ if ( pClientServerCreds->ServerChalType > SYNCML_DM_CHAL_MD5)
+ return; // MD5 digest is not allowed
+
+ pClientServerCreds->SetPrefServerAuth( SYNCML_DM_CHAL_MD5 ); // use MD5 after that for this session
+
+ SYNCMLDM_MD5_SEC_INFO_T md5SecInfo;
+ UINT8 decodedNonce[MAX_BIN_NONCE_LEN];
+ UINT32 encodedNonceLen;
+ UINT32 decodedNonceLen;
+
+ /* The ClientNonce string is b64 encoded and must be decoded now.*/
+ encodedNonceLen = DmStrlen((const char *)pClientServerCreds->pServerNonce);
+ decodedNonceLen = base64Decode((unsigned char *)decodedNonce,
+ MAX_BIN_NONCE_LEN,
+ (unsigned char*)pClientServerCreds->pServerNonce.c_str(),
+ (unsigned long*)&encodedNonceLen);
+ md5SecInfo.pb_user_name_or_server_id = (UINT8*)pClientServerCreds->pServerId.c_str();
+ md5SecInfo.pb_password = (UINT8*)pClientServerCreds->pServerPW.c_str();
+ md5SecInfo.pb_nonce = decodedNonce;
+ md5SecInfo.o_encode_base64 = FALSE;
+ if ( pMeta->format )
+ md5SecInfo.o_encode_base64 = TRUE;
+ md5SecInfo.w_nonce_length = decodedNonceLen;
+
+ pGenCred = syncmldm_sec_build_md5_cred(&md5SecInfo);
+ }
+
+ if ( !pGenCred )
+ return;
+
+ if ( memcmp(szData, (const char*)pGenCred->ab_credential_string, pGenCred->w_credential_string_length) == 0 )
+ pDmMgmtSessionObj->SetSecStateSrv( TRUE );
+ else
+ pDmMgmtSessionObj->SetSecStateSrv( FALSE );
+
+ DmFreeMem(pGenCred);
+}
+
+/*==================================================================================================
+FUNCTION : HandleEndMessage
+
+DESCRIPTION : This method calls SyncML Toolkit smlEndMessage to add the Final element in the
+ SyncBody for the sending message.
+ARGUMENT PASSED : id
+ userData
+ final
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+
+Ret_t
+HandleEndMessage (InstanceID_t id,
+ VoidPtr_t userData,
+ Boolean_t final)
+{
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ BOOLEAN isLastChunk = FALSE;
+
+ // Is session aborted?
+ if( pDmMgmtSessionObj->IsSessionAborted())
+ return SYNCML_DM_SUCCESS;
+
+ // put cahced statuses (if any)
+ while ( ret_stat == SYNCML_DM_SUCCESS && pUserData->aStatuses.size() > 0 ) {
+ ret_stat = pDmBuildPackage->BuildStatus( (SmlStatusPtr_t)pUserData->aStatuses[0] );
+ if ( ret_stat == SYNCML_DM_SUCCESS ){
+ smlFreeStatus((SmlStatusPtr_t)pUserData->aStatuses[0]);
+ pUserData->aStatuses.remove(0);
+ }
+ }
+ // Large Object delivery
+#ifdef LOB_SUPPORT
+if( !pDmBuildPackage->LargeObjectSendNextChunk(ret_stat, isLastChunk))
+#endif
+ {
+#ifdef LOB_SUPPORT
+ if(ret_stat != SYNCML_DM_SUCCESS)
+ { pUserData->aResults.remove(0);
+ isLastChunk = FALSE;
+ }
+#endif
+
+ // pur cached results
+ while ( ret_stat == SYNCML_DM_SUCCESS && pUserData->aResults.size() > 0 ) {
+ // Large Object delivery
+#ifdef LOB_SUPPORT
+ if(!isLastChunk)
+ ret_stat = pDmBuildPackage->LargeObjectSendFirstChunk(pUserData->aResults[0]);
+ isLastChunk = FALSE;
+#else
+ // try to insert result first
+ ret_stat = pDmBuildPackage->BuildResultsCommand(pUserData->aResults[0]._pGetExecResult);
+#endif
+ if ( ret_stat == SYNCML_DM_RESULTS_TOO_LARGE )
+ break;
+#ifndef LOB_SUPPORT
+ smlFreeResults( pUserData->aResults[0]._pGetExecResult ); pUserData->aResults[0]._pGetExecResult= NULL;
+#endif
+
+ if ( pUserData->aResults[0]._type == SYNCML_DM_RESULT_VALUE::Enum_Result_GetStruct ||
+ pUserData->aResults[0]._type == SYNCML_DM_RESULT_VALUE::Enum_Result_GetStructData )
+ {
+ ret_stat = dmTreeObj.GetListNextItem(pUserData->aResults[0]._oGetStructPos);
+
+ if (ret_stat == SYNCML_DM_SUCCESS && pUserData->aResults[0]._oGetStructPos.psRetData ) {
+ ret_stat = pDmBuildPackage->AllocateResult(
+ pUserData->aResults[0]._pGetExecResult,
+ pUserData->aResults[0]._oGetStructPos._pbURI,
+ pUserData->aResults[0]._cmdRef,
+ pUserData->aResults[0]._oGetStructPos.psRetData,
+ pUserData->aResults[0]._type == SYNCML_DM_RESULT_VALUE::Enum_Result_GetStruct,
+ FALSE, FALSE,
+ pUserData->aResults[0]._msgID, NULL );
+
+
+ delete pUserData->aResults[0]._oGetStructPos.psRetData;
+ pUserData->aResults[0]._oGetStructPos.psRetData = NULL;
+ if(ret_stat != SYNCML_DM_SUCCESS)
+ pUserData->aResults.remove(0);
+
+ continue; // write more data
+ }
+ }
+ pUserData->aResults.remove(0);
+ }
+}
+ pDmBuildPackage->EndSyncmlDoc( ret_stat != SYNCML_DM_RESULTS_TOO_LARGE );
+ pDmBuildPackage->Cleanup();
+
+ return SML_ERR_OK;
+}
+
+
+/*==================================================================================================
+FUNCTION : VerifyProtocolVersion
+
+DESCRIPTION :
+ARGUMENT PASSED : pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+VerifyProtocolVersion( SmlSyncHdrPtr_t pContent)
+{
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ /* Verify that the presentation protocol is what we support. */
+ if (DmStrcmp((const char *)pContent->version->content, SYNCML_REP_PROTOCOL_VERSION_1_2) != 0)
+ return SYNCML_DM_FAIL;
+ /* Verify that the DM protocol is what we support. */
+ if (DmStrcmp((const char *)pContent->proto->content, SYNCML_DM_PROTOCOL_VERSION_1_2) != 0)
+ return SYNCML_DM_FAIL;
+ }
+ else
+ {
+ /* Verify that the presentation protocol is what we support. */
+ if (DmStrcmp((const char *)pContent->version->content, SYNCML_REP_PROTOCOL_VERSION_1_1) != 0)
+ return SYNCML_DM_FAIL;
+ /* Verify that the DM protocol is what we support. */
+ if (DmStrcmp((const char *)pContent->proto->content, SYNCML_DM_PROTOCOL_VERSION_1_1) != 0)
+ return SYNCML_DM_FAIL;
+ }
+ return SYNCML_DM_SUCCESS;
+
+
+}
+
+/*==================================================================================================
+FUNCTION : HandleStartMessage
+
+DESCRIPTION : This function should analyze SyncHeader data from received DM document, and build
+ responding SyncML header.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleStartMessage (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlSyncHdrPtr_t pContent)
+{
+
+ SYNCML_DM_RET_STATUS_T ret_stat;
+ UINT32 temp_max_msg_size;
+ SmlMetInfMetInfPtr_t p_temp_meta_info;
+ DMString strRespUri;
+ UINT16 server_session_id;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+
+ /* Reset the synchdr_dm_stat for this message.*/
+ synchdr_dm_stat = SYNCML_DM_SUCCESS;
+
+ /* Get the Session Object.*/
+ pDmMgmtSessionObj = pUserData->pSessionMng;
+ pDmBuildPackage = pUserData->pPkgBuilder;
+ // ignore session ID when processing XML script
+ if(pDmMgmtSessionObj->IsProcessScript() == FALSE)
+ {
+ // Verify that this is the same session, hex string
+ if(pDmBuildPackage->IsSessionId() == TRUE)
+ {
+ // Verify that this is the same session, hex string
+ server_session_id = DmStrtol((const char *)pContent->sessionID->content, NULL, 16 );
+ }
+ else
+ {
+ // Verify that this is the same session, dec string
+ server_session_id = DmStrtol((const char *)pContent->sessionID->content, NULL, 10 );
+ }
+
+ if (server_session_id != pDmMgmtSessionObj->GetServerSessionId())
+ {
+ smlFreeSyncHdr(pContent);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+
+ ret_stat = VerifyProtocolVersion(pContent);
+ if ( ret_stat != SYNCML_DM_SUCCESS )
+ {
+ smlFreeSyncHdr(pContent);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ /* Create the BuildPackage object instance. */
+ pDmBuildPackage->Init(pUserData->pSessionMng);
+
+ /* If respURI exists, call transport API to set the URI. */
+ if ((pContent->respURI != NULL) && (pContent->respURI->length != 0))
+ {
+ /* Copy over the response URI */
+ strRespUri.assign((const char *)pContent->respURI->content, pContent->respURI->length);
+ if(strRespUri.Encode() == FALSE)
+ synchdr_dm_stat = SYNCML_DM_PROCESSING_ERROR;
+
+ /* Call the MgmtSessionObj to set the response URI */
+ ret_stat = pDmMgmtSessionObj->SetURI(strRespUri.c_str() );
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ synchdr_dm_stat = SYNCML_DM_PROCESSING_ERROR;
+ }
+ }
+
+ /* If the MaxMsgSize is sent by the server, when it's greater than our MaxMsgSize, don't need
+ to do anything; if it's smaller than our MaxMsgSize, set our MaxMsgSize to the new value. */
+ if ((pContent->meta != NULL) && (pContent->meta->content != NULL))
+ {
+ p_temp_meta_info = (SmlMetInfMetInfPtr_t)pContent->meta->content;
+ if ((p_temp_meta_info->maxmsgsize != NULL) &&
+ (p_temp_meta_info->maxmsgsize->length != 0))
+ {
+ temp_max_msg_size = DmAtoi((const char *)p_temp_meta_info->maxmsgsize->content);
+ /* If the Server MaxMsgSize is smaller than what we have, reset our MaxMessageSize */
+ if (temp_max_msg_size < pDmBuildPackage->GetMaxMessageSize())
+ {
+ pDmBuildPackage->SetMaxMessageSize(temp_max_msg_size);
+ }
+ }
+#ifdef LOB_SUPPORT
+ if ((p_temp_meta_info->maxobjsize != NULL) &&
+ (p_temp_meta_info->maxobjsize->length != 0))
+ {
+ temp_max_msg_size = DmAtoi((const char *)p_temp_meta_info->maxobjsize->content);
+ /* If the Server MaxObjSize is smaller than what we have, reset our MaxObjectSize */
+ if (pDmBuildPackage->GetMaxObjectSize()==0 || temp_max_msg_size < pDmBuildPackage->GetMaxObjectSize())
+ {
+ pDmBuildPackage->SetMaxObjectSize(temp_max_msg_size);
+ }
+ }
+#endif
+ }
+
+ /* Build up the SyncML document header */
+ ret_stat = pDmBuildPackage->BuildStartSyncHdr(pContent,FALSE);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ synchdr_dm_stat = SYNCML_DM_BAD_REQUEST;
+ smlFreeSyncHdr(pContent);
+ return SML_ERR_UNSPECIFIC;
+ }
+
+ CheckAuthorization( pContent->cred );
+
+
+ if ( pDmMgmtSessionObj->IsServerAuthorized())
+ pDmMgmtSessionObj->ResetServerRetryCount();
+
+ if( pDmMgmtSessionObj->IsProcessScript() )
+ {
+ ret_stat = pDmBuildPackage->BuildFinishSyncHdr(SYNCML_DM_CHAL_NONE);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ synchdr_dm_stat = SYNCML_DM_BAD_REQUEST;
+ smlFreeSyncHdr(pContent);
+ return SML_ERR_UNSPECIFIC;
+ }
+ }
+ /* We need to check the source and target URI and set the dm_stat to the correct status before
+ we free the pContent.*/
+ if ((pContent->target->locURI == NULL) || (pContent->source->locURI == NULL) ||
+ (pContent->target->locURI->length == 0) || (pContent->source->locURI->length == 0))
+ {
+ synchdr_dm_stat = SYNCML_DM_PERMISSION_FAILED;
+ }
+
+ /* Free the memory */
+ smlFreeSyncHdr(pContent);
+
+ return SML_ERR_OK;
+}
+
+
+
+/*==================================================================================================
+FUNCTION : PrepareCommandItem
+
+DESCRIPTION : Check if command should be skipped and decode item URI
+
+ARGUMENT PASSED :
+ userData
+ pContent
+ command
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+static SYNCML_DM_RET_STATUS_T
+PrepareCommandItem (SmlItemPtr_t pCommandItem,
+ SYNCML_DM_USER_DATA_T *pUserData,
+ DMString & strCommandUri )
+{
+
+ BOOLEAN res;
+
+ if ( pUserData->IsCommandSkipped() )
+ return SYNCML_DM_NOT_EXECUTED;
+
+ if ((pCommandItem->target == NULL) || (pCommandItem->target->locURI == NULL))
+ return SYNCML_DM_BAD_REQUEST;
+
+ res = strCommandUri.assign((CPCHAR)pCommandItem->target->locURI->content,
+ pCommandItem->target->locURI->length);
+ if ( res == FALSE )
+ return SYNCML_DM_DEVICE_FULL;
+
+ if(strCommandUri.Decode() == FALSE)
+ return SYNCML_DM_BAD_REQUEST;
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+/*==================================================================================================
+FUNCTION : ProcessStatus
+
+DESCRIPTION : Process status of operationd
+
+ARGUMENT PASSED :
+ userData
+ pContent
+ command
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+
+static SYNCML_DM_RET_STATUS_T
+ProcessStatus (SYNCML_DM_RET_STATUS_T dm_stat,
+ VoidPtr_t userData,
+ UINT8 * p_CmdRefData,
+ SmlItemPtr_t pCommandItem,
+ SYNCML_DM_COMMAND_T command)
+{
+
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+ if ( pCommandItem == NULL )
+ return SYNCML_DM_FAIL;
+
+
+ UINT8 *pTargetURL = NULL;
+ //Fix for Upmerge CR# LIBoo12975
+ if((pCommandItem->target != NULL) && (pCommandItem->target->locURI != NULL))
+ {
+ if(command == SYNCML_DM_GET)
+ {
+ DMString strTargetEncode;
+ strTargetEncode = DMString((const char *)pCommandItem->target->locURI->content, (int)pCommandItem->target->locURI->length);
+ if(strTargetEncode.Encode() == FALSE)
+ {
+ return SYNCML_DM_FAIL;
+ }
+ pTargetURL = (UINT8 *)strTargetEncode.c_str();
+ }
+ else
+ {
+ pTargetURL = (UINT8 *)pCommandItem->target->locURI->content;
+ }
+ }
+
+ UINT8* pSourceURL = NULL;
+ pSourceURL = (UINT8*)(pCommandItem->source != NULL ? pCommandItem->source->locURI->content : NULL);
+
+ if( pDmMgmtSessionObj->GetInAtomicCommand() )
+ {
+#ifdef DM_ATOMIC_SUPPORTED
+ // Save the data for the status and results
+ if(dm_stat != SYNCML_DM_SUCCESS && !pUserData->rollback)
+ AtomicRollback(userData);
+#endif
+ pUserData->oStatus.push_back( SYNCML_DM_STATUS_DATA_T(
+ (CPCHAR)p_CmdRefData,
+ dm_command_name_table[command],
+ (CPCHAR)pSourceURL,
+ (CPCHAR)pTargetURL,
+ dm_stat) );
+
+ }
+ else
+ {
+ ret_stat = SaveCommandRefStatus((UINT8 *)p_CmdRefData,
+ (UINT8 *)dm_command_name_table[command],
+ pCommandItem,
+ dm_stat,
+ pUserData );
+
+ }
+
+ return ret_stat;
+
+}
+
+#ifdef TNDS_SUPPORT
+SYNCML_DM_RET_STATUS_T ProcessTndsNode( SYNCML_DM_COMMAND_T command,
+ SmlDmTndNodeListPtr_t p_nodelist,
+ const DMString &parentURI,
+ const DMString &targetURI)
+{
+ SYNCML_DM_RET_STATUS_T ret = SYNCML_DM_SUCCESS;
+ DMAddData oCommandData;
+ while ( NULL != p_nodelist && ret == SYNCML_DM_SUCCESS)
+ {
+ SmlDmTndNodePtr_t p_tnd_node = p_nodelist->node;
+ if ( p_tnd_node != NULL )
+ {
+ // node name
+ DMString nodeName;
+ nodeName = (CPCHAR)p_tnd_node->nodename->content;
+ KCDBG("ProcessTndsNode: node name = %s", nodeName.c_str());
+
+ // node format and type
+ SYNCML_DM_FORMAT_T nodeFormat = SYNCML_DM_FORMAT_NODE;
+ DMString nodeType = "text/plain", nodeValue = "";
+ if ( p_tnd_node->rtprops != NULL )
+ {
+ if ( p_tnd_node->rtprops->format != NULL )
+ {
+ nodeFormat = DMTree::ConvertFormatStr((CPCHAR)p_tnd_node->rtprops->format->value->content);
+ if ( (nodeFormat == SYNCML_DM_FORMAT_BIN) && (nodeName == DM_AAUTHDATA) )
+ {
+ nodeFormat = SYNCML_DM_FORMAT_CHR;
+ }
+ }
+ if ( p_tnd_node->rtprops->type != NULL )
+ {
+ if ( p_tnd_node->rtprops->type->mime != NULL )
+ {
+ nodeType = (CPCHAR)p_tnd_node->rtprops->type->mime->content;
+ }
+ else if ( p_tnd_node->rtprops->type->ddfname != NULL )
+ {
+ nodeType = (CPCHAR)p_tnd_node->rtprops->type->ddfname->content;
+ }
+ }
+ }
+ KCDBG("ProcessTndsNode: nodeType = %s", nodeType.c_str());
+
+ DMString nodeTargetURI;
+ if ( ( nodeType == MNG_OBJID_DMACC1 ) || (nodeType == MNG_OBJID_DMACC2) )
+ {
+ KCDBG("ProcessTndsNode: modified Target URI");
+ nodeTargetURI = DM_DMACC_1_2_URI; // TNDS is defined for 1.2 only
+ }
+
+ // calculate node path
+ DMString nodePath;
+ if (!nodeTargetURI.empty())
+ {
+ nodePath = nodeTargetURI + "/";
+ }
+ else
+ {
+ nodePath = parentURI + "/";
+ }
+
+ if ( p_tnd_node->path != NULL )
+ {
+ DMString path = (CPCHAR)p_tnd_node->path->content;
+ nodePath = nodeTargetURI + "/" + path + "/";
+ }
+ nodePath += nodeName;
+ KCDBG("ProcessTndsNode: node path = %s", nodePath.c_str());
+
+ // node value
+ if ( p_tnd_node->value != NULL )
+ {
+ if ( DmStrncmp((CPCHAR)p_tnd_node->value->content, DM_INBOX, strlen(DM_INBOX)) == 0 )
+ {
+ nodeValue = (CPCHAR)p_tnd_node->value->content + strlen(DM_INBOX) + 1;
+ }
+ else
+ {
+ nodeValue = (CPCHAR)p_tnd_node->value->content;
+ }
+ }
+
+ // Construct Add/Replace Data
+ oCommandData.clear();
+ oCommandData.m_oURI.assign(nodePath.c_str());
+ oCommandData.m_nFormat = nodeFormat;
+ oCommandData.m_oMimeType.assign(nodeType.c_str());
+ oCommandData.m_oData.assign(nodeValue.c_str());
+
+ // Add/Replace node in DMT
+ if ( command == SYNCML_DM_ADD )
+ {
+ KCDBG("ProcessTndsNode: command == ADD");
+ ret = dmTreeObj.Add(oCommandData,SYNCML_DM_REQUEST_TYPE_SERVER);
+ // Interior node exist
+ if ( nodeFormat == SYNCML_DM_FORMAT_NODE && ret == SYNCML_DM_TARGET_ALREADY_EXISTS )
+ {
+ ret = SYNCML_DM_SUCCESS;
+ }
+ }
+ else
+ {
+ KCDBG("ProcessTndsNode: command == REPLACE");
+ ret = dmTreeObj.Replace(oCommandData,SYNCML_DM_REQUEST_TYPE_SERVER);
+ }
+
+ // Process children node
+ if ( ret == SYNCML_DM_SUCCESS )
+ {
+ if (nodeTargetURI.empty())
+ {
+ ret = ProcessTndsNode(command, p_tnd_node->nodelist, nodePath, targetURI);
+ }
+ else
+ {
+ ret = ProcessTndsNode(command, p_tnd_node->nodelist, nodePath, nodeTargetURI);
+ }
+ }
+ else
+ {
+ KCDBG("Failed to handle TNDS node: %s, format: %d, value: %s, status:%d\n", nodePath.c_str(), nodeFormat, nodeValue.c_str(), ret);
+ }
+ }
+
+ // Process sibling node
+ p_nodelist = p_nodelist->next;
+ }
+
+ return ret;
+}
+
+SYNCML_DM_RET_STATUS_T ProcessTndsCommand(
+ SYNCML_DM_COMMAND_T command,
+ VoidPtr_t userData,
+ DMAddData & oCommand,
+ DMCommandType cmdType,
+ SmlItemPtr_t p_command_item)
+{
+ DMString dataStr;
+ if ( NULL == p_command_item->data || NULL == p_command_item->data->content )
+ {
+ return SML_ERR_UNSPECIFIC;
+ }
+ if ( SML_PCDATA_EXTENSION != p_command_item->data->contentType &&
+ SML_EXT_DMTND != p_command_item->data->extension )
+ {
+ return SML_ERR_UNSPECIFIC;
+ }
+
+ SmlDmTndPtr_t p_tnd_info = NULL;
+ p_tnd_info = (SmlDmTndPtr_t)p_command_item->data->content;
+ if ( oCommand.m_oURI.compare(DM_INBOX) )
+ {
+ oCommand.m_oURI.assign(".");
+ }
+
+ SYNCML_DM_RET_STATUS_T dm_stat=dmTreeObj.GetLockContextManager().ReleaseIDInternal(SYNCML_DM_LOCKID_CURRENT, SYNCML_DM_ATOMIC);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS && dm_stat != SYNCML_DM_FEATURE_NOT_SUPPORTED )
+ {
+ return SML_ERR_UNSPECIFIC;
+ }
+
+ /* Remember that we are in an Atomic command.*/
+ bool bIsInAtomic = pDmMgmtSessionObj->GetInAtomicCommand();
+
+ pDmMgmtSessionObj->SetInAtomicCommand(TRUE);
+
+ SmlDmTndNodeListPtr_t p_nodelist = p_tnd_info->nodelist;
+ DMString path = (CPCHAR)oCommand.m_oURI.getBuffer();
+ if ( oCommand.m_oURI.getBuffer()[0] == '/' )
+ {
+ DMString tmpPath = ".";
+ path = tmpPath + path;
+ }
+ dm_stat = ProcessTndsNode(command, p_nodelist, path.c_str(), path.c_str());
+ if ( dm_stat != SYNCML_DM_SUCCESS && dm_stat != SYNCML_DM_FEATURE_NOT_SUPPORTED )
+ {
+ // Roll back TNDS objects
+ AtomicRollback(userData);
+ }
+
+ pDmMgmtSessionObj->SetInAtomicCommand(bIsInAtomic);
+ return dm_stat;
+}
+#endif // TNDS_SUPPORT
+
+/*==================================================================================================
+FUNCTION : ProcessCommand
+
+DESCRIPTION : Process ADD?REPLACE command
+
+ This function will perform the following operations:
+ 1) Call DMTree::Add() or DMTree::Replace() function to perform ADD command on the DM tree.
+ 2) Call SYNCML_DM_BuildPackage::BuildStatus() to build up the staus command with
+ return status for each ADD command performed.
+ARGUMENT PASSED : id
+ userData
+ pContent
+ command
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t ProcessCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlAddPtr_t pContent,
+ SYNCML_DM_COMMAND_T command)
+{
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ SmlItemListPtr_t p_command_list_item;
+ SmlItemPtr_t p_command_item;
+ DMBuffer oCommandType;
+ SYNCML_DM_FORMAT_T commandFormat;
+
+ DMAddData oCommandData;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+
+ /* Get the data we need to work on */
+ p_command_list_item = pContent->itemList;
+ p_command_item = p_command_list_item->item;
+
+ XPL_LOG_DM_TMN_Debug(("dm_ua_handlecommand::ProcessCommand command=%d", command));
+
+ if ( command == SYNCML_DM_ADD )
+ dm_stat = pDmBuildPackage->GenerateAlertForLOB(DM_COMMAND_ADD);
+ else
+ dm_stat = pDmBuildPackage->GenerateAlertForLOB(DM_COMMAND_REPLACE);
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ ret_stat = ProcessStatus (dm_stat,
+ userData,
+ (UINT8*)pContent->cmdID->content,
+ p_command_item,
+ command);
+ /* Free the memeory we allocated (p_plugin_add), and passed in (pContent). */
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+ return SML_ERR_OK;
+ }
+
+ pDmMgmtSessionObj->IncCommandCount(); /* This variable is used to check if syncml document has
+ * any management commands */
+
+ /* Fill in meta data when meta data info is defined outside of the ITEM in the receiving
+ package.
+ if meta data is not set, default format "chr" and type "text/plain" will be filled. */
+ dm_stat = SetMetaData(pContent->meta, oCommandType, &commandFormat);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+ return SML_ERR_UNSPECIFIC;
+ }
+
+ /* Make sure we are not in an atomic and the Server is authenticated before performing any
+ * DM commands.*/
+ if (pDmMgmtSessionObj->IsAuthorized())
+ {
+ /* Loop on every ADD ITEM */
+ while (p_command_item != NULL)
+ {
+ oCommandData.clear();
+
+ // perform operation
+
+ while ( TRUE )
+ {
+ DMString tempURI;
+ dm_stat = PrepareCommandItem (p_command_item,
+ pUserData,
+ tempURI);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ break;
+
+ oCommandData.m_oURI.assign(tempURI);
+
+ if(oCommandData.m_oURI.getBuffer() == NULL)
+ {
+ dm_stat = SYNCML_DM_DEVICE_FULL;
+ break;
+ }
+
+ /* Set the meta data for ADD/REPLACE command if it's defined for each ITEM */
+
+ if (p_command_item->meta != NULL)
+ {
+ dm_stat = SetMetaData(p_command_item->meta, oCommandData.m_oMimeType, &oCommandData.m_nFormat);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ break;
+ }
+ else
+ {
+ /* This particular item does not have meta data, so we need to use the meta data
+ * from outside the command.
+ */
+ oCommandData.m_oMimeType = oCommandType;
+ if ( oCommandData.getType() == NULL )
+ {
+ dm_stat = SYNCML_DM_DEVICE_FULL;
+ break;
+ }
+ oCommandData.m_nFormat = commandFormat;
+ }
+
+#ifdef TNDS_SUPPORT
+ /* Handle TNDS object */
+ if ( oCommandData.m_oMimeType.compare(SYNCML_CONTENT_TYPE_DM_TNDS_XML, strlen(SYNCML_CONTENT_TYPE_DM_TNDS_XML)) ||
+ oCommandData.m_oMimeType.compare(SYNCML_CONTENT_TYPE_DM_TNDS_WBXML, strlen(SYNCML_CONTENT_TYPE_DM_TNDS_WBXML)) )
+ {
+ dm_stat = ProcessTndsCommand( command,
+ userData,
+ oCommandData,
+ command == SYNCML_DM_ADD ?
+ DM_COMMAND_ADD :
+ DM_COMMAND_REPLACE,
+ p_command_item);
+ }
+ else
+ {
+#endif // TNDS_SUPPORT
+
+#ifdef LOB_SUPPORT
+
+ if(pDmBuildPackage->IsProcessingLargeObject())
+ {
+ XPL_LOG_DM_TMN_Debug(("dm_ua_handlecommand::ProcessCommand processing lob\n"));
+ if ( command == SYNCML_DM_ADD )
+ dm_stat = pDmBuildPackage->LargeObjectRecvNextChunk(oCommandData,
+ DM_COMMAND_ADD,
+ p_command_item);
+ else
+ dm_stat = pDmBuildPackage->LargeObjectRecvNextChunk(oCommandData,
+ DM_COMMAND_REPLACE,
+ p_command_item);
+
+
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Debug(("not processing large obj\n"));
+ if ( command == SYNCML_DM_ADD )
+ dm_stat = pDmBuildPackage->LargeObjectRecvFirstChunk(oCommandData,
+ DM_COMMAND_ADD,
+ p_command_item);
+ else
+ dm_stat = pDmBuildPackage->LargeObjectRecvFirstChunk(oCommandData,
+ DM_COMMAND_REPLACE,
+ p_command_item);
+
+ }
+#else // LOB_SUPPORT
+
+ /* Call TNM module to perform ADD command */
+#ifdef DM_ATOMIC_SUPPORTED
+ if ( command == SYNCML_DM_ADD ) {
+ XPL_LOG_DM_TMN_Debug(("about to add atomic supported\n"));
+ dm_stat = dmTreeObj.Add(oCommandData,SYNCML_DM_REQUEST_TYPE_SERVER);
+ XPL_LOG_DM_TMN_Debug(("add atomic supported dm_stat=%d\n", dm_stat));
+ }
+ else
+ dm_stat = dmTreeObj.Replace(oCommandData,SYNCML_DM_REQUEST_TYPE_SERVER);
+#else // DM_ATOMIC_SUPPORTED
+ if ( pDmMgmtSessionObj->GetInAtomicCommand() )
+ dm_stat = SYNCML_DM_COMMAND_FAILED;
+ else
+ {
+ if ( command == SYNCML_DM_ADD ) {
+ XPL_LOG_DM_TMN_Debug(("about to add atomic not supported\n"));
+ dm_stat = dmTreeObj.Add(oCommandData,SYNCML_DM_REQUEST_TYPE_SERVER);
+ XPL_LOG_DM_TMN_Debug(("add atomic not supported dm_stat=%d\n", dm_stat));
+ }
+ else
+ dm_stat = dmTreeObj.Replace(oCommandData,SYNCML_DM_REQUEST_TYPE_SERVER);
+ }
+#endif // DM_ATOMIC_SUPPORTED
+#endif // LOB_SUPPORT
+
+#ifdef TNDS_SUPPORT
+ }
+#endif // TNDS_SUPPORT
+
+ SequenceStatus(userData, dm_stat);
+
+ break;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("dm_ua_handlecommand::ProcessCommand dm_stat=%d, command=%d\n",dm_stat, command));
+
+ ret_stat = ProcessStatus (dm_stat,
+ userData,
+ (UINT8*)pContent->cmdID->content,
+ p_command_item,
+ command);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ break;
+ }
+
+ if (p_command_list_item->next != NULL)
+ {
+ p_command_list_item = p_command_list_item->next;
+ p_command_item = p_command_list_item->item;
+ }
+ else
+ p_command_item = NULL;
+ } /* End of while */
+ } /* !inAtomicCommand && dmSecState */
+ else /* dmSecState not authenticated */
+ {
+ /* Call the toolkit to construct the STATUS for ADD command */
+ ret_stat = SaveCommandRefStatus((UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[command],
+ p_command_item,
+ pDmMgmtSessionObj->GetNotAuthorizedStatus(),
+ pUserData );
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+ /* Free the memeory we allocated (p_plugin_add), and passed in (pContent). */
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+
+ return sml_ret_stat;
+}
+
+
+
+/*==================================================================================================
+FUNCTION : HandleAddCommand
+
+DESCRIPTION : When the ADD element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+ 1) Call DMTree::Add() function to perform ADD command on the DM tree.
+ 2) Call SYNCML_DM_BuildPackage::BuildStatus() to build up the staus command with
+ return status for each ADD command performed.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t HandleAddCommand (InstanceID_t id, VoidPtr_t userData, SmlAddPtr_t pContent)
+{
+ XPL_LOG_DM_TMN_Debug(("dm_ua_handlecommand::HandleAdd enter"));
+ return ProcessCommand(id, userData, pContent,SYNCML_DM_ADD);
+}
+
+/*==================================================================================================
+FUNCTION : HandleCopyCommand
+
+DESCRIPTION : When the COPY element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+ 1) Set DM status as SYNCML_DM_FEATURE_NOT_SUPPORTED.
+ 2) Call SYNCML_DM_BuildPackage::BuildStatus() to build up the staus command with
+ return status for each COPY command performed.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleCopyCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlCopyPtr_t pContent)
+{
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ SYNCML_DM_RET_STATUS_T ret_stat;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+
+ pDmMgmtSessionObj->IncCommandCount(); /* This variable is used to check if syncml document has
+ * any management commands */
+
+ /* Call the toolkit to construct the STATUS for COPY command */
+ ret_stat = SaveStatus(
+ (UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_COPY],
+ NULL,
+ NULL,
+ SYNCML_DM_FEATURE_NOT_SUPPORTED,
+ NULL,
+ pUserData);
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+
+ /* Free the memory of pContent. */
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+
+ return sml_ret_stat;
+}
+
+
+/*==================================================================================================
+FUNCTION : HandleDeleteCommand
+
+DESCRIPTION : When the DELETE element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+ 1) Call DMTree::Delete() function to perform DELETE command on the DM tree.
+ 2) Call SYNCML_DM_BuildPackage::BuildStatus() to build up the staus command with
+ return status for each DELETE command performed.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleDeleteCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlDeletePtr_t pContent)
+{
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ SYNCML_DM_RET_STATUS_T dm_stat = 0;
+ SYNCML_DM_RET_STATUS_T ret_stat = 0;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+
+ SmlItemListPtr_t p_delete_list_item;
+ SmlItemPtr_t p_delete_item;
+
+ p_delete_list_item = pContent->itemList;
+ p_delete_item = p_delete_list_item->item;
+
+ XPL_LOG_DM_TMN_Debug(("dm_ua_handlecommand::HandleDelete enter"));
+
+ ret_stat = pDmBuildPackage->GenerateAlertForLOB(DM_COMMAND_REPLACE);
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ ret_stat = ProcessStatus (dm_stat,
+ userData,
+ (UINT8*)pContent->cmdID->content,
+ p_delete_item,
+ SYNCML_DM_DELETE);
+ /* Free the memory of pContent and p_target_uri. */
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+ return SML_ERR_OK;
+ }
+
+ pDmMgmtSessionObj->IncCommandCount(); /* This variable is used to check if syncml document has
+ * any management commands */
+
+ /* Make sure we are not in an atomic and the Server is authenticated before performing any
+ * DM commands.*/
+ if (pDmMgmtSessionObj->IsAuthorized())
+ {
+ /* Loop on each DELETE item */
+ while (p_delete_item != NULL) {
+
+
+ // perform operation
+ while ( true )
+ {
+ DMString strDeleteUri;
+ dm_stat = PrepareCommandItem (p_delete_item,
+ pUserData,
+ strDeleteUri);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ break;
+
+ XPL_LOG_DM_TMN_Debug(("dm_ua_handlecommand::HandleDelete uri=%s\n", strDeleteUri.c_str()));
+
+#ifdef DM_ATOMIC_SUPPORTED
+ dm_stat = dmTreeObj.Delete (strDeleteUri.c_str(),SYNCML_DM_REQUEST_TYPE_SERVER );
+#else
+ if ( pDmMgmtSessionObj->GetInAtomicCommand() )
+ dm_stat = SYNCML_DM_COMMAND_FAILED;
+ else
+ dm_stat = dmTreeObj.Delete (strDeleteUri.c_str(),SYNCML_DM_REQUEST_TYPE_SERVER );
+#endif
+ SequenceStatus(userData, dm_stat);
+ break;
+ }
+
+ ret_stat = ProcessStatus (dm_stat,
+ userData,
+ (UINT8*)pContent->cmdID->content,
+ p_delete_item,
+ SYNCML_DM_DELETE);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ break;
+ }
+
+ /* Move to the next item on the list */
+ if (p_delete_list_item->next != NULL) {
+ p_delete_list_item = p_delete_list_item->next;
+ p_delete_item = p_delete_list_item->item;
+ }
+ else
+ p_delete_item = NULL;
+ } /* End of while */
+ } /* !inAtomicCommand && dmSecState */
+ else /* dmSecState not authenticated */
+ {
+ ret_stat = SaveCommandRefStatus(
+ (UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_DELETE],
+ p_delete_item,
+ pDmMgmtSessionObj->GetNotAuthorizedStatus(),
+ pUserData );
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+ }
+
+ /* Free the memory of pContent and p_target_uri. */
+ smlFreeGeneric((SmlGenericCmdPtr_t)pContent);
+
+ return sml_ret_stat;
+}
+
+
+/*==================================================================================================
+FUNCTION : ProcessAlertCommand
+
+DESCRIPTION : When the ALERT element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+ 1) Process alert via XPL.
+ return status for each ALERT command performed.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+static SYNCML_DM_RET_STATUS_T
+ProcessAlertCommand (VoidPtr_t userData,
+ SmlAlertPtr_t pContent,
+ SYNCML_DM_Alert * pAlert,
+ DMStringVector & responses)
+{
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if ( pAlert == NULL )
+ return SYNCML_DM_FAIL;
+
+ if ( pUserData->IsCommandSkipped() || pDmMgmtSessionObj->IsSessionAborted() )
+ return SYNCML_DM_NOT_EXECUTED;
+
+ pAlert->parse(pContent);
+ dm_stat = pAlert->show();
+ switch ( dm_stat )
+ {
+ case SYNCML_DM_SESSION_CANCELED:
+ pDmMgmtSessionObj->SetSessionAborted();
+ return SYNCML_DM_SUCCESS;
+
+ case SYNCML_DM_SUCCESS:
+ dm_stat = pAlert->processResponse(responses,&pUserData->alertState);
+ break;
+
+ default:
+ pUserData->alertState = SYNCML_DM_ALERT_CANCEL;
+ break;
+ }
+
+ return dm_stat;
+
+}
+
+
+/*==================================================================================================
+FUNCTION : HandleAlertCommand
+
+DESCRIPTION : When the ALERT element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+ 1) Check the ALERT value, set the DM status accordingly.
+ 2) Call SYNCML_DM_BuildPackage::BuildStatus() to build up the staus command with
+ return status for each ALERT command performed.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleAlertCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlAlertPtr_t pContent)
+{
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ SYNCML_DM_RET_STATUS_T ret_stat = 0;
+ SYNCML_DM_RET_STATUS_T dm_stat = 0;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+ DMStringVector responses; // holds all the user responses
+
+ pDmMgmtSessionObj->IncCommandCount(); /* This variable is used to check if syncml document has
+ * any management commands */
+
+ if (pDmMgmtSessionObj->IsAuthorized())
+ {
+
+ UINT32 alert_code_value;
+
+ /* Get the data we need to work on */
+
+ alert_code_value = DmAtoi((const char *)pContent->data->content);
+
+ /* Please refer syncml_dm_represent_v111_20021002.pdf section 8 */
+ switch (alert_code_value)
+ {
+ case DM_ALERT_SERVER_INITIATED_MGMT:
+ case DM_ALERT_CLIENT_INITIATED_MGMT:
+ case DM_ALERT_NEXT_MESSAGE:
+ dm_stat = SYNCML_DM_SUCCESS;
+ break;
+
+ case DM_ALERT_SESSION_ABORT:
+ pDmMgmtSessionObj->SetSessionAborted();
+ dm_stat = SYNCML_DM_SUCCESS;
+ break;
+
+ // handle user interaction alerts
+ case DM_ALERT_DISPLAY:
+ {
+ if ( !VerifyAlertItems(pContent) )
+ {
+ XPL_LOG_DM_TMN_Debug(("HandleAlertCommand, alert command items incorrect."));
+ dm_stat = SYNCML_DM_INCOMPLETE_COMMAND;
+ }
+ else {
+ SYNCML_DM_DisplayAlert displayAlert;
+ dm_stat = ProcessAlertCommand(userData,pContent,&displayAlert,responses);
+ }
+ }
+ break;
+
+ case DM_ALERT_CONTINUE_OR_ABORT:
+ {
+ if ( !VerifyAlertItems(pContent) )
+ {
+ XPL_LOG_DM_TMN_Debug(("HandleAlertCommand, alert command items incorrect."));
+ dm_stat = SYNCML_DM_INCOMPLETE_COMMAND;
+ }
+ else {
+ SYNCML_DM_ConfirmAlert confirmAlert;
+ dm_stat = ProcessAlertCommand(userData,pContent,&confirmAlert,responses);
+ }
+ }
+ break;
+
+ case DM_ALERT_TEXT_INPUT:
+ {
+ if ( !VerifyAlertItems(pContent) )
+ {
+ XPL_LOG_DM_TMN_Debug(("HandleAlertCommand, alert command items incorrect."));
+ dm_stat = SYNCML_DM_INCOMPLETE_COMMAND;
+ }
+ else {
+ SYNCML_DM_TextInputAlert textInputAlert;
+ dm_stat = ProcessAlertCommand(userData,pContent,&textInputAlert,responses);
+ }
+ }
+ break;
+
+ case DM_ALERT_SINGLE_CHOICE:
+ {
+ SYNCML_DM_SingleChoiceAlert singleChoiceAlert;
+ dm_stat = ProcessAlertCommand(userData,pContent,&singleChoiceAlert,responses);
+ }
+ break;
+
+ case DM_ALERT_MULTIPLE_CHOICE:
+ {
+ SYNCML_DM_MultipleChoiceAlert multipleChoiceAlert;
+ dm_stat = ProcessAlertCommand(userData,pContent,&multipleChoiceAlert,responses);
+ }
+ break;
+
+ default:
+ dm_stat = SYNCML_DM_FEATURE_NOT_SUPPORTED; /* Optional feature not supported */
+ break;
+ }
+
+ if(pDmMgmtSessionObj->GetInAtomicCommand())
+ {
+#ifdef DM_ATOMIC_SUPPORTED
+ // Save the data for the status and results
+ if ( dm_stat != SYNCML_DM_SUCCESS && dm_stat != SYNCML_DM_FEATURE_NOT_SUPPORTED )
+ AtomicRollback(userData);
+#endif
+ pUserData->oStatus.push_back(
+ SYNCML_DM_STATUS_DATA_T((const char*)pContent->cmdID->content,
+ dm_command_name_table[SYNCML_DM_ALERT],
+ NULL,
+ NULL,
+ dm_stat,
+ &responses) );
+ }
+ else
+ {
+ ret_stat = SaveStatus((UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_ALERT],
+ NULL,
+ NULL,
+ dm_stat,
+ &responses,
+ pUserData );
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+ }
+ }
+ else
+ {
+
+ ret_stat = SaveStatus(
+ (UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_ALERT],
+ NULL,
+ NULL,
+ pDmMgmtSessionObj->GetNotAuthorizedStatus(),
+ &responses,
+ pUserData );
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+
+ /* Free the memory of the pContent */
+ smlFreeAlert(pContent);
+
+ return sml_ret_stat;
+}
+
+
+/*==================================================================================================
+FUNCTION : HandleExecCommand
+
+DESCRIPTION : When the EXEC element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+ 1) Call DMTree::Exec() function to perform EXEC command on the DM tree.
+ 2) Call SYNCML_DM_BuildPackage::BuildStatus() to build up the staus command with
+ return status for each EXEC command performed.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleExecCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlExecPtr_t pContent)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat=SYNCML_DM_SUCCESS;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+
+ SYNCML_DM_RET_STATUS_T ret_stat = 0;
+ SYNCML_DM_URI_RESULT_T dm_uri_result = 0;
+ SmlItemPtr_t p_exec_item;
+ DMString strExecUri;
+ DMString strOriExecUri;
+
+ DMString execResults;
+ DMString execData;
+
+ p_exec_item = pContent->item;
+
+ ret_stat = pDmBuildPackage->GenerateAlertForLOB(DM_COMMAND_EXEC);
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ smlFreeExec((SmlExecPtr_t)pContent);
+ return SML_ERR_OK;
+ }
+
+ pDmMgmtSessionObj->IncCommandCount(); /* This variable is used to check if syncml document has
+ * any management commands */
+
+ /* Make sure we are not in an atomic and the Server is authenticated before performing any
+ * DM commands.*/
+ if (pDmMgmtSessionObj->GetInAtomicCommand() == FALSE &&
+ pDmMgmtSessionObj->IsAuthorized())
+ {
+
+ if ((p_exec_item->target == NULL) || (p_exec_item->target->locURI == NULL))
+ {
+ smlFreeExec((SmlExecPtr_t)pContent);
+ return SML_ERR_UNSPECIFIC;
+ }
+
+ strExecUri.assign((CPCHAR)p_exec_item->target->locURI->content,p_exec_item->target->locURI->length);
+
+ strOriExecUri = strExecUri;
+ if(strExecUri.Decode() == FALSE)
+ {
+ smlFreeExec((SmlExecPtr_t)pContent);
+ return SML_ERR_UNSPECIFIC;
+ }
+ /* Fill the data for p_exec_data */
+ if (p_exec_item->data != NULL && p_exec_item->data->length > 0)
+ {
+ execData.assign((CPCHAR)p_exec_item->data->content,p_exec_item->data->length);
+ if ( execData == NULL )
+ {
+ smlFreeExec((SmlExecPtr_t)pContent);
+ return SML_ERR_UNSPECIFIC;
+ }
+ }
+
+ const char* szCorrelator = NULL;
+
+ if ( pContent->correlator && pContent->correlator->contentType == SML_PCDATA_STRING )
+ szCorrelator = (const char*)pContent->correlator->content;
+
+
+ /* Validate the URI */
+ dm_uri_result = dmTreeObj.URIValidateAndParse(strExecUri);
+ switch (dm_uri_result)
+ {
+ case SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY:
+ case SYNCML_DM_COMMAND_INVALID_URI:
+ case SYNCML_DM_COMMAND_URI_TOO_LONG:
+ dm_stat = SYNCML_DM_BAD_REQUEST;
+ break;
+
+ default:
+
+ // schen link error, code is not there
+ // dm_stat = SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ dm_stat = dmTreeObj.Exec(strExecUri.c_str(), execData, execResults, szCorrelator);
+ SequenceStatus(userData, dm_stat);
+ break;
+ }
+
+ }
+ else
+ if (pDmMgmtSessionObj->GetInAtomicCommand())
+ {
+ AtomicRollback(userData);
+ /* We don't apply commands within the Atomic.*/
+ dm_stat = SYNCML_DM_COMMAND_FAILED;
+ }
+ else
+ dm_stat = pDmMgmtSessionObj->GetNotAuthorizedStatus();
+
+ UINT8 *p_TargetRefData = NULL;
+ if(p_exec_item->target != NULL && p_exec_item->target->locURI != NULL){
+ p_TargetRefData = (UINT8 *)p_exec_item->target->locURI->content;
+ }
+
+ if (0 == DmStrcmp((char *)p_TargetRefData, FDR_URI))
+ {
+ /* Build tha status with item tag for the EXEC command for FDR*/
+ ret_stat = SaveStatus((UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_EXEC],
+ NULL,
+ p_TargetRefData,
+ dm_stat,
+ NULL,
+ pUserData );
+ }
+ else
+ {
+ /* Build tha status for the EXEC command */
+ ret_stat = SaveStatus((UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_EXEC],
+ NULL,
+ NULL,
+ dm_stat,
+ NULL,
+ pUserData );
+
+ }
+
+ if (dm_stat == SYNCML_DM_SUCCESS && execResults.length() )
+ {
+ XPL_LOG_DM_TMN_Debug(("dm_ua_handlecommand::HandleExecCommand, inside success chk\n"));
+ SmlResultsPtr_t p_results=NULL; /* To hold RESULTS structure */
+ SmlItemPtr_t p_results_item; /* To hold GET results item */
+ SmlItemListPtr_t p_results_list_item; /* To hold GET results list */
+
+ // Allocate the memory for p_results
+ p_results = smlAllocResults();
+
+ if ( !p_results )
+ {
+ smlFreeExec((SmlExecPtr_t)pContent);
+ return SML_ERR_UNSPECIFIC;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("dm_ua_handlecommand::HandleExecCommand, before buildpcdata\n"));
+ pDmBuildPackage->BuildPcData(p_results->cmdRef,
+ SML_PCDATA_STRING,
+ SML_EXT_UNDEFINED,
+ DmStrlen((char *)pContent->cmdID->content),
+ (UINT8*)pContent->cmdID->content);
+
+
+ /* Fill in item fileds */
+ p_results_list_item = p_results->itemList;
+
+ p_results_item = p_results_list_item->item;
+ ret_stat = SetExecResultsData( p_results_item, strOriExecUri, execResults);
+ pUserData->aResults.push_back(
+ SYNCML_DM_RESULT_VALUE( SYNCML_DM_RESULT_VALUE::Enum_Result_Exec, p_results,
+ SYNCML_DM_GET_ON_LIST_RET_DATA_T(), (CPCHAR)pContent->cmdID->content,
+ (const char*)pDmBuildPackage->GetMsgRef()) );
+ }
+
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ smlFreeExec((SmlExecPtr_t)pContent);
+ return SML_ERR_UNSPECIFIC;
+ }
+
+ smlFreeExec((SmlExecPtr_t)pContent);
+
+ XPL_LOG_DM_TMN_Debug(("dm_ua_handlecommand::HandleExecCommand leaving\n"));
+ return SML_ERR_OK;
+}
+
+
+/*==================================================================================================
+FUNCTION : HandleGetCommand
+
+DESCRIPTION : When the GET element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+ 1) Call DMTree::Get() function to perform GET command on the DM tree.
+ 2) Call BuildResultsCommand() to build the results from GET command.
+ 3) Call SYNCML_DM_BuildPackage::BuildStatus() to build up the staus command with
+ return status for each GET command performed.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleGetCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlGetPtr_t pContent)
+{
+ DMString strTargetUri;
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ SYNCML_DM_RET_STATUS_T dm_stat = 0;
+ SYNCML_DM_RET_STATUS_T ret_stat = 0;
+ DMGetData getData;
+
+ /* p_get_struct_data is OUTPUT parameter of dmTreeObj.InitListAndGetListFirstItem call. We
+ need to initialize it as NULL before we pass it to the call, p_get_struct_data could not
+ be set if the return is not SUCCESS. */
+
+ SYNCML_DM_GET_ON_LIST_RET_DATA_T p_get_struct_data;
+ SYNCML_DM_URI_RESULT_T dm_uri_result = 0;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+
+ SmlItemPtr_t p_get_item;
+ SmlItemListPtr_t p_get_list_item;
+
+ pDmMgmtSessionObj->IncCommandCount();
+
+ /* Point the GET item to the correct spot */
+ p_get_list_item = pContent->itemList;
+ p_get_item = p_get_list_item->item;
+
+ dm_stat = pDmBuildPackage->GenerateAlertForLOB(DM_COMMAND_GET);
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ ret_stat = ProcessStatus (dm_stat,
+ userData,
+ (UINT8*)pContent->cmdID->content,
+ p_get_item,
+ SYNCML_DM_GET);
+ /* Free the memory */
+ smlFreeGetPut(pContent);
+ return SML_ERR_OK;
+ }
+
+ /* Make sure we are not in an atomic and the Server is authenticated before performing any
+ * DM commands.*/
+ if (pDmMgmtSessionObj->GetInAtomicCommand() == FALSE &&
+ pDmMgmtSessionObj->IsAuthorized())
+ {
+
+ while (p_get_item != NULL)
+ { /* Loop through each GET ITEM */
+
+ getData.clear();
+ while ( true )
+ {
+ DMString strTargetUri;
+ XPL_LOG_DM_TMN_Debug(("\ninside dm_ua_handlecommand::HandleGet, uri=%s\n", strTargetUri.c_str()));
+ dm_stat = PrepareCommandItem (p_get_item,
+ pUserData,
+ strTargetUri);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ break;
+
+ /* Validete the URI */
+ dm_uri_result = dmTreeObj.URIValidateAndParse((char*)strTargetUri.c_str());
+ switch (dm_uri_result) {
+ case SYNCML_DM_COMMAND_INVALID_URI:
+ case SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY:
+ case SYNCML_DM_COMMAND_URI_TOO_LONG:
+ dm_stat = SYNCML_DM_BAD_REQUEST;
+ break;
+
+ case SYNCML_DM_COMMAND_ON_NODE:
+ case SYNCML_DM_COMMAND_ON_ACL_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_FORMAT_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_NAME_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_SIZE_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_TYPE_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_TITLE_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_TSTAMP_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_VERNO_PROPERTY:
+ dm_stat = dmTreeObj.Get(strTargetUri.c_str(), getData,SYNCML_DM_REQUEST_TYPE_SERVER);
+ XPL_LOG_DM_TMN_Debug(("\ninside dm_ua_handlecommand::HandleGet, dmTreeObj.Get=%d", dm_stat));
+ if (dm_stat == SYNCML_DM_SUCCESS)
+ {
+ dm_stat = SaveResult( strTargetUri, (const char *)pContent->cmdID->content,
+ &getData, FALSE, FALSE,
+ (dm_uri_result == SYNCML_DM_COMMAND_ON_NODE ? FALSE : TRUE),
+ pUserData, SYNCML_DM_RESULT_VALUE::Enum_Result_Get,
+ p_get_struct_data );
+ }
+ break;
+
+ case SYNCML_DM_COMMAND_LIST_STRUCT:
+ case SYNCML_DM_COMMAND_LIST_STRUCTDATA:
+ case SYNCML_DM_COMMAND_LIST_TNDS:
+ /* Call TNM to get the first item on the Get Struct results list */
+ {
+ DMGetData * pGetData = NULL;
+ DMString strTargetUriNoQuery(strTargetUri);
+
+ // remove query from URI
+ char *psQPos = DmStrstr(strTargetUri, SYNCML_DM_LIST);
+ if (psQPos != NULL)
+ {
+ strTargetUriNoQuery.assign(strTargetUri.c_str(), psQPos - strTargetUri.c_str());
+ }
+
+ dm_stat = dmTreeObj.InitListAndGetListFirstItem(strTargetUriNoQuery,
+ SYNCML_DM_GET_ON_LIST_STRUCT,
+ p_get_struct_data);
+
+ if (dm_stat == SYNCML_DM_SUCCESS)
+ {
+ UINT8 type = 0;
+ if ( dm_uri_result == SYNCML_DM_COMMAND_LIST_STRUCT )
+ {
+ type = SYNCML_DM_RESULT_VALUE::Enum_Result_GetStruct;
+ }
+ else if ( dm_uri_result == SYNCML_DM_COMMAND_LIST_STRUCTDATA )
+ {
+ type = SYNCML_DM_RESULT_VALUE::Enum_Result_GetStructData;
+ }
+ else if ( dm_uri_result == SYNCML_DM_COMMAND_LIST_TNDS )
+ {
+ type = SYNCML_DM_RESULT_VALUE::Enum_Result_GetTnds;
+ }
+ else
+ {
+ dm_stat = SYNCML_DM_BAD_REQUEST;
+ break;
+ }
+ pGetData = p_get_struct_data.psRetData; p_get_struct_data.psRetData = NULL;
+ dm_stat = SaveResult( strTargetUriNoQuery.c_str(), (CPCHAR)pContent->cmdID->content,
+ pGetData,
+ dm_uri_result == SYNCML_DM_COMMAND_LIST_STRUCT,
+ type != SYNCML_DM_RESULT_VALUE::Enum_Result_GetTnds,
+ FALSE,
+ pUserData,
+ type,
+ p_get_struct_data);
+ if ( pGetData )
+ delete pGetData;
+ }
+ else
+ /* Free the memory of p_passedin_get_struct_data */
+ pDmBuildPackage->FreeGetStructData(p_get_struct_data);
+ }
+ break;
+ default:
+ dm_stat = SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ break;
+
+ } // end switch
+ break;
+
+ }
+ ret_stat = ProcessStatus (dm_stat,
+ userData,
+ (UINT8*)pContent->cmdID->content,
+ p_get_item,
+ SYNCML_DM_GET);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ break;
+ }
+
+ /* Move to the next item */
+ if (p_get_list_item->next != NULL)
+ {
+ p_get_list_item = p_get_list_item->next;
+ p_get_item = p_get_list_item->item;
+ }
+ else
+ p_get_item = NULL;
+ } /* End of while */
+
+ }
+ else
+ { /* !inAtomicCommand && dmSecState */ /* inAtomicCommand == TRUE || dmSecState not authenticated */
+
+ if (pDmMgmtSessionObj->GetInAtomicCommand() == TRUE)
+ {
+ AtomicRollback(userData);
+ dm_stat = SYNCML_DM_COMMAND_FAILED; /* We don't apply commands within the Atomic.*/
+ }
+ else
+ dm_stat = pDmMgmtSessionObj->GetNotAuthorizedStatus();
+
+ ret_stat = SaveCommandRefStatus(
+ (UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_GET],
+ p_get_item,
+ dm_stat,
+ pUserData);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+
+ /* Free the memory */
+ smlFreeGetPut(pContent);
+ pContent = NULL;
+
+ return (sml_ret_stat);
+}
+
+
+/*==================================================================================================
+FUNCTION : HandleReplaceCommand
+
+DESCRIPTION : When the REPLACE element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+ 1) Call DMTree::Replace() function to perform REPLACE command on the DM
+ tree.
+ 2) Call SYNCML_DM_BuildPackage::BuildStatus() to build up the staus command with
+ return status for each REPLACE command performed.
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleReplaceCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlReplacePtr_t pContent)
+{
+ return ProcessCommand(id, userData, pContent,SYNCML_DM_REPLACE);
+}
+
+
+/*==================================================================================================
+FUNCTION : HandleStartSequenceCommand
+
+DESCRIPTION : When the SEQUENCE element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleStartSequenceCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlSequencePtr_t pContent)
+{
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ SYNCML_DM_RET_STATUS_T ret_stat;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ ret_stat = pDmBuildPackage->GenerateAlertForLOB(DM_COMMAND_SEQUENCE_START);
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ /* Free the memory of pContent. Toolkit use same API to free the memory for atomic and
+ sequence */
+ smlFreeAtomic((SmlAtomicPtr_t)pContent);
+ return SML_ERR_OK;
+ }
+ pUserData->StartSequence();
+
+ if (pDmMgmtSessionObj->IsAuthorized())
+ dm_stat = SYNCML_DM_SUCCESS;
+ else
+ dm_stat = pDmMgmtSessionObj->GetNotAuthorizedStatus();
+
+ pDmMgmtSessionObj->IncCommandCount(); /* This variable is used to check if syncml document has
+ * any management commands */
+
+ /* Call the toolkit to construct the STATUS for SEQUENCE command */
+ ret_stat = SaveStatus(
+ (UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_SEQUENCE],
+ NULL,
+ NULL,
+ dm_stat,
+ NULL,
+ pUserData );
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+
+ /* Free the memory of pContent. Toolkit use same API to free the memory for atomic and
+ sequence */
+ smlFreeAtomic((SmlAtomicPtr_t)pContent);
+
+ return sml_ret_stat;
+}
+
+/*==================================================================================================
+FUNCTION : HandleEndSequenceCommand
+
+DESCRIPTION : When the SEQUENCE element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+
+ARGUMENT PASSED : id
+ userData
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleEndSequenceCommand(InstanceID_t id,
+ VoidPtr_t userData)
+{
+ /* We don't need to do anything special for the End Sequence.*/
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+
+ if(pUserData)
+ pUserData->EndSequence();
+ return SML_ERR_OK;
+}
+
+
+
+/*==================================================================================================
+FUNCTION : HandleStartAtomicCommand
+
+DESCRIPTION : When the ATOMIC element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleStartAtomicCommand(InstanceID_t id,
+ VoidPtr_t userData,
+ SmlAtomicPtr_t pContent)
+{
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+
+ dm_stat = pDmBuildPackage->GenerateAlertForLOB(DM_COMMAND_ATOMIC_START);
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ smlFreeAtomic(pContent );
+ return SML_ERR_OK;
+ }
+
+ if (pDmMgmtSessionObj->IsAuthorized())
+ {
+ if(pDmMgmtSessionObj->GetInAtomicCommand())
+ { // nested atomics are not allowed
+ SaveStatus((UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_ATOMIC],
+ NULL,
+ NULL,
+ SYNCML_DM_COMMAND_FAILED,
+ NULL,
+ pUserData);
+ smlFreeAtomic(pContent );
+ return sml_ret_stat;
+ }
+
+ dm_stat=dmTreeObj.GetLockContextManager().ReleaseIDInternal(SYNCML_DM_LOCKID_CURRENT, SYNCML_DM_ATOMIC);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS && dm_stat != SYNCML_DM_FEATURE_NOT_SUPPORTED )
+ {
+ smlFreeAtomic(pContent );
+ return SML_ERR_UNSPECIFIC;
+ }
+
+ /* Remember that we are in an Atomic command.*/
+ pDmMgmtSessionObj->SetInAtomicCommand(TRUE);
+
+ // Save the data for the status
+ pUserData->pAtomicStatus.bValueSet = TRUE;
+ pUserData->pAtomicStatus.pCmdId = (CPCHAR)pContent->cmdID->content;
+ pUserData->pAtomicStatus.pCmdName = dm_command_name_table[SYNCML_DM_ATOMIC];
+ pUserData->pAtomicStatus.status = dm_stat;
+ }
+ else
+ {
+ dm_stat = SaveStatus((UINT8 *)pContent->cmdID->content,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_ATOMIC],
+ NULL,
+ NULL,
+ pDmMgmtSessionObj->GetNotAuthorizedStatus(),
+ NULL,
+ pUserData);
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+ smlFreeAtomic(pContent );
+ return sml_ret_stat;
+}
+
+
+/*==================================================================================================
+FUNCTION : HandleEndAtomicCommand
+
+DESCRIPTION : When the End ATOMIC element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+
+ARGUMENT PASSED : id
+ userData
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleEndAtomicCommand(InstanceID_t id,
+ VoidPtr_t userData)
+{
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+ SYNCML_DM_RET_STATUS_T retStatus=SYNCML_DM_SUCCESS;
+
+ if (pDmMgmtSessionObj->IsAuthorized())
+ {
+ pDmMgmtSessionObj->SetInAtomicCommand(FALSE);
+
+ if ( !pUserData->rollback )
+ {
+ retStatus=dmTreeObj.GetLockContextManager().ReleaseIDInternal(SYNCML_DM_LOCKID_CURRENT, SYNCML_DM_COMMIT);
+
+ if ( retStatus != SYNCML_DM_SUCCESS && retStatus != SYNCML_DM_FEATURE_NOT_SUPPORTED)
+ return SML_ERR_UNSPECIFIC;
+ }
+
+ /* We are now out of the Atomic command.*/
+ UINT8 *p_SourceRefData = !pUserData->pAtomicStatus.pSource.empty() ?
+ (UINT8 *)(pUserData->pAtomicStatus.pSource.c_str()) : NULL;
+ UINT8 *p_TargetRefData = !pUserData->pAtomicStatus.pTarget.empty() ?
+ (UINT8 *)pUserData->pAtomicStatus.pTarget.c_str() : NULL;
+
+ retStatus = SaveStatus((UINT8 *)pUserData->pAtomicStatus.pCmdId.c_str(),
+ (UINT8 *)pUserData->pAtomicStatus.pCmdName.c_str(),
+ p_SourceRefData,
+ p_TargetRefData,
+ pUserData->pAtomicStatus.status,
+ NULL,
+ pUserData);
+
+ if (retStatus != SYNCML_DM_SUCCESS)
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+
+ for ( int i = 0; i <pUserData->oStatus.size(); i++ )
+ {
+ const SYNCML_DM_STATUS_DATA_T& ptrStatus = pUserData->oStatus[i];
+
+ UINT8 *p_SourceRefData = !ptrStatus.pSource.empty() ?
+ (UINT8 *)(ptrStatus.pSource.c_str()) : NULL;
+ retStatus = SaveStatus((UINT8 *)ptrStatus.pCmdId.c_str(),
+ (UINT8 *)ptrStatus.pCmdName.c_str(),
+ p_SourceRefData,
+ (UINT8 *)ptrStatus.pTarget.c_str(),
+ ptrStatus.status,
+ &ptrStatus.responses,
+ pUserData);
+
+ if (retStatus != SYNCML_DM_SUCCESS)
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+
+ pUserData->EndAtomic();
+ }
+
+ return sml_ret_stat;
+}
+
+
+/*==================================================================================================
+FUNCTION : HandleStatusCommand
+
+DESCRIPTION : When the STATUS element is processed from the received message, this callback
+ function will be called.
+
+ This function will perform the following operations:
+ 1) Check the status code.
+ 2) Call TNMTree::Replace() to replace the nonce value.
+ 3) Update the UserAgent's Security state based on the client authentication
+ status received from the server.
+ 4) Call SYNCML_DM_BuildPackage::BuildFinishSyncHdr() to finish our SyncHdr
+ 5) Determine if we need to Challenge the server
+ 6) Call SYNCML_DM_BuildPackage::BuildStatus() to build up our first status
+ which contains our server authentication disposition.
+
+ARGUMENT PASSED : id
+ userData
+ pContent
+OUTPUT PARAMETER:
+RETURN VALUE : SML_ERR_OK or ERR code
+IMPORTANT NOTES :
+
+
+==================================================================================================*/
+Ret_t
+HandleStatusCommand (InstanceID_t id,
+ VoidPtr_t userData,
+ SmlStatusPtr_t pContent)
+{
+ SYNCML_DM_USER_DATA_T *pUserData = (SYNCML_DM_USER_DATA_T *)userData;
+ Ret_t sml_ret_stat = SML_ERR_OK;
+ SYNCML_DM_RET_STATUS_T ret_stat;
+ SYNCML_DM_RET_STATUS_T local_dm_stat = SYNCML_DM_SUCCESS;
+ UINT8 *pClientNonce = NULL;
+ UINT8 *pServerNonce = NULL;
+ UINT8 *p_auth = NULL;
+ SYNCML_DM_RET_STATUS_T clientAuthStatus;
+ SYNCML_DM_RET_STATUS_T serverStatus;
+ SYNCML_DM_CHAL_TYPE_T serverChalType = SYNCML_DM_CHAL_NONE;
+ UINT8 command_id_str[UINT16_TYPE_STR_SIZE_5] = "0";
+ /* command_id_str reference should be "0" for header */
+ DM_CHALLENGE_T *pClientChal = NULL;
+ DMClientServerCreds *pClientServerCreds;
+ SYNCML_DM_SEC_STATE_FLAG_T currSecState;
+ SYNCMLDM_NONCE_STRING_INFO_T *pNonceStruct = NULL;
+ SYNCMLDM_NONCE_GENERATE_PARAMETER_INFO_T nonceInfo;
+ SmlMetInfMetInfPtr_t p_meta_info = NULL;
+
+ /* First check if this status is for the "SyncHdr".*/
+ if (DmStrncmp((char *)pContent->cmd->content, SYNCML_SYNCHDR, pContent->cmd->length) == 0)
+ {
+ XPL_LOG_DM_TMN_Debug(("\ninside dm_ua_handlecommand::handleStatusCommand, synchdr command ref:%s\n\n", (char*)pContent->cmdRef->content));
+ /* Get the Client and Server Cred info and current Security state.*/
+ pClientServerCreds = pDmMgmtSessionObj->GetClientServerCreds();
+ currSecState = pDmMgmtSessionObj->GetSecState();
+
+ // DP: if we have postponed nonce - save it
+ if ( pUserData->bNonceGenerated )
+ {
+ pUserData->bNonceGenerated = FALSE;
+ if ( pClientServerCreds && pClientServerCreds->pServerNonce )
+ {
+ if ( dmTreeObj.IsVersion_12() )
+ pClientServerCreds->SaveServerAttribute(DM_AAUTHDATA, pClientServerCreds->pServerNonce);
+ else
+ pClientServerCreds->SaveServerAttribute(DM_SERVERNONCE, pClientServerCreds->pServerNonce);
+ }
+ }
+
+ /* We must check the new Status value from the Server in case our Security State changed.*/
+ p_auth = (UINT8 *)DmAllocMem(pContent->data->length+1);
+ if ( p_auth == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ DmStrncpy((char *)p_auth,
+ (const char *)pContent->data->content,
+ pContent->data->length);
+ p_auth[pContent->data->length] = '\0';
+
+ /* We always need to check the clientAuthStatus since we send creds on every message.*/
+ clientAuthStatus = SyncML2DMCode((char *)p_auth);
+ DmFreeMem(p_auth);
+
+ XPL_LOG_DM_TMN_Debug(("\ninside dm_ua_handlecommand::handleStatusCommand, synchdr command clientAuthStatus: %d\n\n", clientAuthStatus));
+
+ if (clientAuthStatus == SYNCML_DM_AUTHENTICATION_REQUIRED)
+ {
+ return clientAuthStatus;
+ }
+
+ /* Update the client retry count */
+ if (clientAuthStatus == SYNCML_DM_AUTHENTICATION_ACCEPTED ||
+ clientAuthStatus == SYNCML_DM_SUCCESS)
+ {
+ /* Reset client retry count when client is authenticated */
+ pDmMgmtSessionObj->SetClientRetryCount(0);
+
+ // Save authPref value if needed
+ pClientServerCreds->SaveAuthPref();
+ }
+ else
+ {
+ /* Increment the retry count when client is not authenticated.*/
+ pDmMgmtSessionObj->IncClientRetryCount();
+ }
+
+ /* Update the security state with the client authentication status. Note that we only
+ * check for cases that cause a change in the SecurityState.
+ */
+ switch (currSecState)
+ {
+ case DM_CLIENT_NO_SERVER_NO_AUTH:
+ if (clientAuthStatus == SYNCML_DM_AUTHENTICATION_ACCEPTED ||
+ clientAuthStatus == SYNCML_DM_SUCCESS)
+ {
+ currSecState = DM_CLIENT_Y_SERVER_NO_AUTH;
+ }
+ break;
+
+ case DM_CLIENT_NO_SERVER_Y_AUTH:
+ if (clientAuthStatus == SYNCML_DM_AUTHENTICATION_ACCEPTED ||
+ clientAuthStatus == SYNCML_DM_SUCCESS)
+ {
+ currSecState = DM_BOTH_CLIENT_SERVER_AUTH;
+ }
+ break;
+
+ case DM_CLIENT_Y_SERVER_NO_AUTH:
+ if (clientAuthStatus != SYNCML_DM_AUTHENTICATION_ACCEPTED &&
+ clientAuthStatus != SYNCML_DM_SUCCESS)
+ {
+ currSecState = DM_CLIENT_NO_SERVER_NO_AUTH;
+ }
+ break;
+
+ case DM_BOTH_CLIENT_SERVER_AUTH:
+ if (clientAuthStatus != SYNCML_DM_AUTHENTICATION_ACCEPTED &&
+ clientAuthStatus != SYNCML_DM_SUCCESS)
+ {
+ currSecState = DM_CLIENT_NO_SERVER_Y_AUTH;
+ }
+ break;
+ }
+
+ /* Update the UserAgent Security state in case it changed.*/
+ pDmMgmtSessionObj->SetSecState(currSecState);
+
+ if ((pContent->chal != NULL) && (pContent->chal->meta != NULL))
+ {
+ /* We were challenged in the SyncHdr, so we need to build our creditials in the package.*/
+ if (currSecState == DM_CLIENT_NO_SERVER_NO_AUTH ||
+ currSecState == DM_CLIENT_NO_SERVER_Y_AUTH)
+ {
+ /* If the client has not been authenticated yet, increment the commandCount so
+ * we'll still respond even if there are no other operational commmands.
+ * But if the client has already been authenticated, then we won't increment since
+ * this may be the end of the session. In that case, the nonce will be used
+ * in the next session.
+ */
+ pDmMgmtSessionObj->IncCommandCount();
+ }
+
+ p_meta_info = (sml_metinf_metinf_s *)pContent->chal->meta->content;
+
+ /* Check the Type.*/
+ if (p_meta_info->type != NULL)
+ {
+ /* Check which type of challenge was sent.*/
+ if (smlLibStrncmp((char *)p_meta_info->type->content, SYNCML_AUTH_MAC,
+ p_meta_info->type->length) == 0)
+ {
+ /* We received a challenge for HMAC-MD5.*/
+ serverChalType = SYNCML_DM_CHAL_HMAC;
+ }
+ else if (smlLibStrncmp((char *)p_meta_info->type->content, SYNCML_AUTH_MD5,
+ p_meta_info->type->length) == 0)
+ {
+ /* We received a challenge for MD5.*/
+ serverChalType = SYNCML_DM_CHAL_MD5;
+ }
+ else
+ {
+ /* We received a challenge for Basic security.*/
+ serverChalType = SYNCML_DM_CHAL_BASIC;
+ }
+ }
+
+ // DP switch to new auth type if needed
+ if ( dmTreeObj.IsVersion_12() )
+ {
+ local_dm_stat = pClientServerCreds->SetPrefClientAuth(serverChalType);
+ if ( local_dm_stat != SYNCML_DM_SUCCESS )
+ {
+ pDmMgmtSessionObj->SetClientRetryCount(MAX_AUTH_RETRY+1);
+ }
+ }
+ /* Get the nextnonce sent to us from the server.*/
+ if (p_meta_info->nextnonce != NULL)
+ {
+ pClientNonce = (UINT8 *)DmAllocMem(p_meta_info->nextnonce->length + 1);
+ if ( pClientNonce == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ memcpy(pClientNonce,
+ p_meta_info->nextnonce->content,
+ p_meta_info->nextnonce->length);
+ pClientNonce[p_meta_info->nextnonce->length] = '\0';
+
+ /* Save the new ClientNonce in the Tree.*/
+ if ( dmTreeObj.IsVersion_12() )
+ local_dm_stat = pClientServerCreds->SaveClientAttribute(DM_AAUTHDATA, (CPCHAR)pClientNonce);
+ else
+ local_dm_stat = pClientServerCreds->SaveClientAttribute(DM_CLIENTNONCE, (CPCHAR)pClientNonce);
+ /* Note that we continue even if we failed to store the clientNonce.*/
+ pClientServerCreds->pClientNonce = (const char*)pClientNonce;
+ DmFreeMem(pClientNonce);
+
+ /* Note that we continue even if we failed to store the clientNonce.*/
+ }
+ } /* If chal != NULL */
+
+ /* Call the method to finish our SyncHdr and start the toolkit message.*/
+ ret_stat = pDmBuildPackage->BuildFinishSyncHdr(serverChalType);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ synchdr_dm_stat = SYNCML_DM_BAD_REQUEST;
+ }
+
+ /* Determine if we need to challenge the server. Note that we will challange
+ * the Server even if it has already been authenticated (hmac/md5 only).*/
+ if ( (currSecState == DM_CLIENT_NO_SERVER_NO_AUTH ||
+ currSecState == DM_CLIENT_Y_SERVER_NO_AUTH) &&
+ pClientServerCreds->ServerChalType > SYNCML_DM_CHAL_BASIC )
+ { // generate new nonce if required
+ DMGetData devID;
+ /* First we need to generate a new nextNonce for the server.*/
+ nonceInfo.pb_user_name = (UINT8*)pClientServerCreds->pClientUserName.c_str();
+ nonceInfo.pb_password = (UINT8*)pClientServerCreds->pServerPW.c_str();
+ nonceInfo.pb_server_id = (UINT8*)pClientServerCreds->pServerId.c_str();
+
+ dmTreeObj.Get(DM_DEV_INFO_DEVID_URI, devID,SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ pNonceStruct = syncmldm_sec_generate_nonce(&nonceInfo,devID.getCharData());
+ if ( pNonceStruct == NULL )
+ {
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+
+ /* Copy the new Server Nonce.*/
+ pServerNonce = (UINT8 *)DmAllocMem(pNonceStruct->w_nonce_string_length + 1);
+ if ( pServerNonce == NULL )
+ {
+ DmFreeMem(pNonceStruct);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ memcpy(pServerNonce, pNonceStruct->ab_nonce_string,
+ pNonceStruct->w_nonce_string_length);
+ pServerNonce[pNonceStruct->w_nonce_string_length] = '\0';
+
+ /* Store the new ServerNonce in the Tree.*/
+ // DP: don't save nonce in the tree yet, since server answer can be empty packet and
+ // we can end session without sending it to the server
+ pUserData->bNonceGenerated = TRUE;
+ DmFreeMem(pNonceStruct);
+
+ /* Note we continue even if we failed to store the serverNonce.*/
+ pClientServerCreds->pServerNonce = (const char*)pServerNonce;
+ DmFreeMem(pServerNonce);
+ }
+
+ if (currSecState == DM_CLIENT_NO_SERVER_NO_AUTH ||
+ currSecState == DM_CLIENT_Y_SERVER_NO_AUTH ||
+ pClientServerCreds->ServerChalType >= SYNCML_DM_CHAL_MD5 ) { // no authenticated or needs chal
+ /* Setup the Client Challenge information.*/
+ pClientChal = (DM_CHALLENGE_T *)DmAllocMem(sizeof(DM_CHALLENGE_T));
+ if ( pClientChal == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ if ( pClientServerCreds->ServerChalType == SYNCML_DM_CHAL_HMAC )
+ pClientChal->pChalType = (UINT8 *) SYNCML_AUTH_MAC;
+ else if ( pClientServerCreds->ServerChalType == SYNCML_DM_CHAL_MD5 )
+ pClientChal->pChalType = (UINT8 *) SYNCML_AUTH_MD5;
+ else
+ pClientChal->pChalType = (UINT8 *) SYNCML_AUTH_BASIC;
+
+ pClientChal->pChalFormat = (UINT8 *)SYNCML_B64;
+ pClientChal->pChalNonce = pClientServerCreds->ServerChalType >= SYNCML_DM_CHAL_MD5 ?
+ (UINT8*)pClientServerCreds->pServerNonce.c_str() : NULL;
+ }
+
+ /* Set the Server's authentication status.*/
+ if (currSecState == DM_CLIENT_NO_SERVER_NO_AUTH ||
+ currSecState == DM_CLIENT_Y_SERVER_NO_AUTH)
+ synchdr_dm_stat = pDmMgmtSessionObj->GetNotAuthorizedStatus();
+
+ /* Now that our SyncHdr is header is closed, we need to create our first status.
+ * Call the toolkit to construct STATUS for SyncHdr */
+ SmlStatusPtr_t pStatus = pDmBuildPackage->AllocateStatus(
+ command_id_str,
+ (UINT8 *)dm_command_name_table[SYNCML_DM_HEADER],
+ NULL, /* Source URI, it's not needed for SyncHdr STATUS */
+ NULL, /* Target URI, it's not needed for SyncHdr STATUS */
+ pClientChal,
+ synchdr_dm_stat, NULL );
+ if ( pStatus ) {
+ ret_stat = pDmBuildPackage->BuildStatus( pStatus );
+ smlFreeStatus(pStatus);
+ }
+ else
+ ret_stat = SYNCML_DM_FAIL;
+
+ DmFreeMem(pClientChal);
+
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+ } /* SyncHdr check */
+
+ /* Check if this Status is for our "Replace" command (Our DevInfo) */
+ else if (DmStrncmp((char *)pContent->cmd->content, SYNCML_REPLACE, pContent->cmd->length) == 0)
+ {
+ XPL_LOG_DM_TMN_Debug(("\ninside dm_ua_handlecommand::handleStatusCommand, replace command ref:%s\n\n", (char*)pContent->cmdRef->content));
+ /* Determine the serverStatus for our DevInfo.*/
+ p_auth = (UINT8 *)DmAllocMem(pContent->data->length+1);
+ if ( p_auth == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ DmStrncpy((char *)p_auth,
+ (const char *)pContent->data->content,
+ pContent->data->length);
+ p_auth[pContent->data->length] = '\0';
+ serverStatus = SyncML2DMCode((char *)p_auth);
+ DmFreeMem(p_auth);
+
+ /* We only resend the DevInfo in the case of Authentication failure.*/
+ if (serverStatus == SYNCML_DM_UNAUTHORIZED)
+ {
+ /* Call the method to build our DevInfo into the REPLACE command for this package. */
+ ret_stat = pDmBuildPackage->BuildReplaceCommand();
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+ }
+ else if (serverStatus == SYNCML_DM_AUTHENTICATION_REQUIRED)
+ {
+ return serverStatus;
+ }
+ } /* Replace check */
+
+ /* Check if this Status is for our "Alert" command (Our SessionDirection) */
+ else if (DmStrncmp((char *)pContent->cmd->content, SYNCML_ALERT, pContent->cmd->length) == 0 &&
+ DmStrncmp((char *)pContent->cmdRef->content, "1", pContent->cmdRef->length) == 0)
+ {
+ XPL_LOG_DM_TMN_Debug(("\ninside dm_ua_handlecommand::handleStatusCommand, alert command ref:%s\n\n", (char*)pContent->cmdRef->content));
+ /* Determine the serverStatus for our Alert (Session Direction).*/
+ p_auth = (UINT8 *)DmAllocMem(pContent->data->length+1);
+ if ( p_auth == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ DmStrncpy((char *)p_auth,
+ (const char *)pContent->data->content,
+ pContent->data->length);
+ p_auth[pContent->data->length] = '\0';
+ serverStatus = SyncML2DMCode((char *)p_auth);
+ DmFreeMem(p_auth);
+
+ /* We only resend the DevInfo in the case of Authentication failure.*/
+ if (serverStatus == SYNCML_DM_UNAUTHORIZED)
+ {
+ /* Call the method to build our DevInfo into the REPLACE command for this package. */
+ ret_stat = pDmBuildPackage->BuildAlertCommand(pDmBuildPackage->getDirection(), NULL, NULL);
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+ /* Call the method to build 1226 command for this package. */
+ ret_stat = pDmBuildPackage->BuildAlert1226Command();
+ if (ret_stat != SYNCML_DM_SUCCESS)
+ {
+ sml_ret_stat = SML_ERR_UNSPECIFIC;
+ }
+ }
+ else if (serverStatus == SYNCML_DM_AUTHENTICATION_REQUIRED)
+ {
+ return serverStatus;
+ }
+ } /* Replace check */
+
+ /* Free the memory we allocated. */
+ smlFreeStatus(pContent);
+
+ return sml_ret_stat;
+}
+
+bool VerifyAlertItems(SmlAlertPtr_t pContent)
+{
+ if ( pContent == NULL )
+ {
+ return false;
+ }
+
+ // Verify first alert item is not NULL.
+ SmlItemListPtr_t p_alert_list_item;
+ p_alert_list_item = pContent->itemList;
+ if (p_alert_list_item == NULL)
+ {
+ return false;
+ }
+
+ SmlItemPtr_t p_alert_item;
+ p_alert_item = p_alert_list_item->item;
+ if (p_alert_item == NULL)
+ {
+ return false;
+ }
+
+ // Verify second alert item is not NULL.
+ p_alert_list_item = p_alert_list_item->next;
+ if (p_alert_list_item == NULL)
+ {
+ return false;
+ }
+
+ p_alert_item = p_alert_list_item->item;
+ if (p_alert_item == NULL)
+ {
+ return false;
+ }
+
+ // Verify no more than 2 items are specified in alert.
+ p_alert_list_item = p_alert_list_item->next;
+ if (p_alert_list_item != NULL)
+ {
+ return false;
+ }
+
+ return true;
+}
diff --git a/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_class.H b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_class.H
new file mode 100644
index 0000000..fdbf8eb
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_class.H
@@ -0,0 +1,663 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_TREE_CLASS_H
+#define _DM_TREE_CLASS_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//------------------------------------------------------------------------
+// Header Name: dm_tree_class.H
+//
+// General Description: This file contains prototypes, data type
+// definitions and constants required to access DMTNM
+// API's and the definition of DMTree class
+//------------------------------------------------------------------------
+
+#include "dm_tree_plugin_root_node_class.H"
+#include "dmtPlugin.hpp"
+#include "dmvector.h"
+#include "dmdefs.h"
+#include "dmMetaDataManager.h"
+#include "dmPluginManager.h"
+#include "SyncML_DM_Archiver.H"
+#include "file_manager.h"
+#include "dmLockCtxMgr.h"
+#include "dmACLManager.h"
+#include "dmSubscriptionManager.h"
+#include "SYNCML_DM_TreeMount.H"
+
+#ifdef LOB_SUPPORT
+#include "dm_tree_default_ESN_class.H" //header file for class defn
+#endif
+
+
+//------------------------------------------------------------------------
+// CONSTANTS
+//------------------------------------------------------------------------
+
+
+#define REPLACE_CMD_LENGTH_IN_ACL 8
+#define GET_CMD_LENGTH_IN_ACL 4
+#define ADD_CMD_LENGTH_IN_ACL 4
+#define DELETE_CMD_LENGTH_IN_ACL 7
+#define EXEC_CMD_LENGTH_IN_ACL 5
+
+#define REPLACE_CMD_IN_ACL "Replace="
+#define GET_CMD_IN_ACL "Get="
+#define ADD_CMD_IN_ACL "Add="
+#define DELETE_CMD_IN_ACL "Delete="
+#define EXEC_CMD_IN_ACL "Exec="
+
+#define SYNCML_DM_PROP ("?prop=")
+#define SYNCML_DM_LIST ("?list=")
+#define SYNCML_DM_STRUCT ("Struct")
+#define SYNCML_DM_STRUCT_DATA ("StructData")
+#define SYNCML_DM_TNDS ("TNDS")
+
+#define SYNCML_DM_PROP_LENGTH 6
+#define SYNCML_DM_LIST_LENGTH 6
+
+#define SYNCML_DM_NULL_STRING ("null")
+#define SYNCML_DM_NULL_STRING_LENGTH 4
+
+#define FORMAT_LENGTH 10
+
+#define SIZE_LENGTH 10
+#define VERSION_LENGTH 5
+#define TSTAMP_LENGTH 20
+
+#define FIRST_SERVER_INDEX_IN_LOOKUP_TABLE 1
+#define MAX_SERVER_INDEX_IN_LOOKUP_TABLE (SYNCML_DM_MAX_SERVER_ALLOWED)
+
+#define ROOT_NODE_NAME (".")
+#define ROOT_NODE_ACL ("Add=*&Replace=*&Get=*&Delete=*") //YXU
+
+#define SYNCML_DM_ASCII_EXCLAMATION ('!')
+#define SYNCML_DM_ASCII_DOLLAR ('$')
+#define SYNCML_DM_ASCII_MINUS ('-')
+#define SYNCML_DM_ASCII_ZERO ('0')
+#define SYNCML_DM_ASCII_NINE ('9')
+#define SYNCML_DM_ASCII_EQUAL_TO ('=')
+#define SYNCML_DM_ASCII_ATTHERATE ('@')
+#define SYNCML_DM_ASCII_CAPITAL_A ('A')
+#define SYNCML_DM_ASCII_CAPITAL_D ('D')
+#define SYNCML_DM_ASCII_CAPITAL_E ('E')
+#define SYNCML_DM_ASCII_CAPITAL_F ('F')
+#define SYNCML_DM_ASCII_CAPITAL_G ('G')
+#define SYNCML_DM_ASCII_CAPITAL_N ('N')
+#define SYNCML_DM_ASCII_CAPITAL_R ('R')
+#define SYNCML_DM_ASCII_CAPITAL_S ('S')
+#define SYNCML_DM_ASCII_CAPITAL_V ('V')
+#define SYNCML_DM_ASCII_CAPITAL_Z ('Z')
+#define SYNCML_DM_ASCII_UNDERSCORE ('_')
+#define SYNCML_DM_ASCII_80 0x80
+#define SYNCML_DM_ASCII_FF 0xFF
+
+#define SYNCML_DM_ASCII_SMALL_A ('a')
+#define SYNCML_DM_ASCII_SMALL_F ('f')
+#define SYNCML_DM_ASCII_SMALL_Z ('z')
+#define SYNCML_DM_ASCII_TILDE ('~')
+
+#define SYNCML_DM_ASCII_CAPITAL_CL ("CL")
+#define SYNCML_DM_AME ("ame")
+#define SYNCML_DM_ORMAT ("ormat")
+#define SYNCML_DM_IZE ("ize")
+#define SYNCML_DM_ERNO ("erNo")
+#define SYNCML_DM_EPLACE ("eplace")
+#define SYNCML_DM_ET ("et")
+#define SYNCML_DM_DD ("dd")
+#define SYNCML_DM_ELETE ("elete")
+#define SYNCML_DM_XEC ("xec")
+#define SYNCML_DM_TITLE ("Title")
+#define SYNCML_DM_TYPE ("Type")
+#define SYNCML_DM_TSTAMP ("TStamp")
+
+#define SYNCML_DM_SEG_LEN_AFTER_PERCENTAGE (2)
+#define SYNCML_DMTNM_MAX_ENCODED_ACL_LENGTH (48)
+#define SYNCML_DM_RELATIVE_URI_OFFSET_LENGTH (2)
+
+//#define DM_ISP_LOCK "/data/dm/tmp/isp"
+#define DM_ISP_LOCK "/data/data/com.android.omadm.service/files/dm/tmp/isp"
+
+//------------------------------------------------------------------------
+// STRUCTURES AND OTHER TYPEDEFS
+//------------------------------------------------------------------------
+struct LIST_STRUCT_OR_STRUCT_DATA_INFO_T
+{
+ LIST_STRUCT_OR_STRUCT_DATA_INFO_T() {Clear();}
+
+ void Clear() {
+ psCurrent = NULL;
+ }
+ DMNode *psCurrent;
+};
+
+//------------------------------------------------------------------------
+// GLOBAL VARIABLE DECLARATIONS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// FUNCTION PROTOTYPES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// CLASS
+//------------------------------------------------------------------------
+
+//Definition of DMTree class
+class DMTree
+{
+
+ enum {
+ CLEAN = -1,
+ DIRTY = 0,
+ REPLACED = 1,
+ ADDED =2,
+ DELETED = 1
+ };
+
+public:
+ friend class DMTreeCacheCurrentTime;
+ //Constructor
+ DMTree();
+
+ //Destructor
+ ~DMTree();
+
+ //Overloading new and delete operators
+ inline void* operator new(size_t dwSize)
+ {
+ return (DmAllocMem(dwSize));
+ }
+
+ inline void operator delete(void *pvBuf)
+ {
+ DmFreeMem(pvBuf);
+ }
+
+
+ //Method that UA will call to let DMTNM initialize data members
+ //that should not be set/reset through constructor
+ SYNCML_DM_RET_STATUS_T Init();
+
+ SYNCML_DM_RET_STATUS_T DeInit(BOOLEAN bIsDestructor);
+
+ //Method to Initiallize and get first item from list
+ SYNCML_DM_RET_STATUS_T InitListAndGetListFirstItem(CPCHAR pbURI,
+ SYNCML_DM_GET_ON_LIST_T bGetOnList,
+ SYNCML_DM_GET_ON_LIST_RET_DATA_T& ppsReturnData);
+ //Method to get next item from list
+ SYNCML_DM_RET_STATUS_T GetListNextItem(SYNCML_DM_GET_ON_LIST_RET_DATA_T& ppsReturnData);
+
+ //method to initialise the list for serialization process
+ SYNCML_DM_RET_STATUS_T InitSerializationList(DMNode * serializeRoot);
+
+ //method to return properties for serialization one by one
+ SYNCML_DM_SERIALIZATION_STATUS_T GetSerializationListNextItem(DMNode **ppsRetNode,
+ INT32& nEndTagsNumber );
+
+
+ //Method to get the name of the Parent node when the value of
+ //the child node is given
+ BOOLEAN GetParentOfKeyValue(CPCHAR pbvalueOfKey,
+ CPCHAR pKey,
+ CPCHAR pSubtreeURI,
+ DMString& strResult);
+
+ //To add a node
+ SYNCML_DM_RET_STATUS_T Add( DMAddData & oAddData,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType );
+
+ //To delete a node/subtree
+ SYNCML_DM_RET_STATUS_T Delete(CPCHAR pbURI,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType);
+
+ //To exec a URI
+ SYNCML_DM_RET_STATUS_T Exec(CPCHAR pbUri,
+ CPCHAR pExecData,
+ DMString & oExecResult,
+ CPCHAR szCorrelator = NULL );
+
+ //To get value of a node
+ SYNCML_DM_RET_STATUS_T Get(CPCHAR pbUri,
+ DMGetData & oReturnData,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType);
+
+
+ //To get attributes of a node
+ SYNCML_DM_RET_STATUS_T GetAttributes(CPCHAR pbUri,
+ DmtAttributes& attrs,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType);
+
+
+ //To replace a node's value/property value
+ SYNCML_DM_RET_STATUS_T Replace( DMAddData & oReplaceData,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType );
+
+ //To set links of a de-serialized node
+ SYNCML_DM_RET_STATUS_T AddNode(DMNode **psNodeObject,
+ const DMAddNodeProp & oAddNodeProperties,
+ DMNode* pNewNode = NULL );
+
+ //Invoked by Archiver to get a pointer to the root node
+ //Archiver then uses this object to traverse the tree
+ //(using different traversal mechanism)
+ inline DMNode* GetRootNode() { return( m_psRoot); }
+
+
+ //To validate and Parse URI
+ SYNCML_DM_URI_RESULT_T URIValidateAndParse(CPCHAR pbUri) const;
+
+ //To decode the ACL to get back actual server names
+ static SYNCML_DM_RET_STATUS_T DecodeACL(const UINT8 *pbEncodedACL,
+ UINT8 **ppbDecodedACL,
+ UINT16 *pwDecodedACLLength);
+
+ //Detach the node from tree
+ void DetachNodeFromTree(DMNode *);
+
+ //Move to public as it may be used by notification manager
+ //This method will return a pointer to the node(which is the
+ //last segment in the URI)
+ DMNode* FindNodeByURI(CPCHAR pURI);
+
+ SYNCML_DM_RET_STATUS_T getChildren( CPCHAR uri,
+ DMMap<DMString, UINT32>& childrenMap,
+ DMTNM_NODE_TYPE nodeType,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType);
+
+ SYNCML_DM_RET_STATUS_T getLeafChildren( CPCHAR uri,
+ DMMap<DMString, UINT32>& childrenMap,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType);
+
+ SYNCML_DM_RET_STATUS_T getInteriorChildren( CPCHAR uri,
+ DMMap<DMString, UINT32>& childrenMap,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType);
+
+ SYNCML_DM_RET_STATUS_T setLeafChildren( CPCHAR uri,
+ DMMap<DMString, UINT32>& childrenMap );
+
+ SYNCML_DM_RET_STATUS_T rollback( DMMap<DMString, UINT32> oldChildrenMap,
+ DMMap<DMString, UINT32>& newChildrenMap,
+ INT8 actionList[],
+ INT8 deleteList[] );
+
+ SYNCML_DM_RET_STATUS_T handleNewChildren( DMMap<DMString, UINT32> oldChildrenMap,
+ DMMap<DMString, UINT32>& newChildrenMap,
+ INT8 actionList[],
+ INT8 deleteList[] );
+
+ SYNCML_DM_RET_STATUS_T handleOldChildren( DMMap<DMString, UINT32> oldChildrenMap,
+ DMMap<DMString, UINT32>& newChildrenMap,
+ INT8 actionList[],
+ INT8 deleteList[] );
+
+ // return the associated Archive that the node is in.
+ SyncML_DM_Archive * GetArchive(const DMNode * node);
+
+ /* SessionStart functions call this to set the server Id. */
+ SYNCML_DM_RET_STATUS_T SetServerId (CPCHAR p_ServerId);
+
+ /* The DMTNM calls this to get the current server Id. */
+ inline CPCHAR GetServerId() const { return (m_strPrincipal.c_str() );}
+
+ /* Set CcnRef. */
+ SYNCML_DM_RET_STATUS_T SetConRef (CPCHAR p_ConRef);
+
+ /* Get COnRef */
+ inline CPCHAR GetConRef() const { return (m_strConRef.c_str() );}
+
+ // default leaf/interior node creation (except plug-ins)
+ static DMNode* CreateNodeObj( SYNCML_DM_FORMAT_T bFormat, BOOLEAN isESN, CPCHAR pbFileName);
+
+
+ DMNode* CreateSkeletonNode( CPCHAR szURI );
+
+ static BOOLEAN GetLastSegmentOfURI( DMString& strURI, DMString& strLastSegment );
+
+ void DeleteNodesFromTree(DMNode * startNode);
+
+ UINT16 readOneWordFromTree(DMNode * pNode, UINT16 defaultValue);
+
+ void UnloadArchive(DMNode * psStartNode );
+
+ void SubstituteNode( DMNode* pOldNode, DMNode* pNewNode );
+
+ inline const DmtOPINodeData* GetCachedOPINodeData() { return &m_oOPICacheData;}
+ SYNCML_DM_RET_STATUS_T SetOPINodeData( CPCHAR szURI, const DmtOverlayPluginData& oData );
+
+ SYNCML_DM_RET_STATUS_T GetAccNodeValue (CPCHAR pParentName,
+ CPCHAR pSubNode,
+ DMGetData & oAccData);
+
+ SYNCML_DM_RET_STATUS_T GetDefAccountAddrInfo(CPCHAR pAccProfileName,
+ DMGetData& oAddr,
+ DMGetData& oAddrType,
+ DMGetData& oPortNbr);
+
+ SYNCML_DM_RET_STATUS_T GetServerAuthInfo(CPCHAR pAccProfileName,
+ CPCHAR pAuthType,
+ DMGetData& oAuthName,
+ DMGetData& oAuthSecret,
+ DMGetData& oAuthData,
+ DMString& oAuthDataUri);
+
+ SYNCML_DM_RET_STATUS_T GetHttpAuthInfo(CPCHAR pAccProfileName,
+ DMGetData& oAuthType,
+ DMGetData& oAuthName,
+ DMGetData& oAuthSecret,
+ DMGetData& oAuthData,
+ DMString& oAuthDataUri);
+
+ SYNCML_DM_RET_STATUS_T GetClientAuthInfo(CPCHAR pAccProfileName,
+ CPCHAR pAuthType,
+ DMGetData& oAuthName,
+ DMGetData& oAuthSecret,
+ DMGetData& oAuthData,
+ DMString& oAuthDataUri,
+ DMGetData& oAuthType );
+
+ SYNCML_DM_RET_STATUS_T GetAuthInfo(CPCHAR pAccProfileName,
+ CPCHAR pAuthLevel,
+ CPCHAR pAuthType,
+ DMGetData& oAuthType,
+ DMGetData& oAuthName,
+ DMGetData& oAuthSecret,
+ DMGetData& oAuthData,
+ DMString& oAuthDataUri);
+
+ SYNCML_DM_RET_STATUS_T GetLastClientAuthType(CPCHAR pAccProfileName,
+ DMGetData& oClientAuthType);
+
+ SYNCML_DM_RET_STATUS_T SetLastClientAuthType(CPCHAR pAccProfileName,
+ CPCHAR pClientAuthType);
+
+
+ // Utility method used to convert SYNCML_DM_FORMAT_T type format to string
+ static SYNCML_DM_RET_STATUS_T ConvertFormat(SYNCML_DM_FORMAT_T format,
+ DMString & strFormat);
+
+ // Utility method used to convert string format to SYNCML_DM_FORMAT_T type
+ static SYNCML_DM_FORMAT_T ConvertFormatStr(const DMString& formatStr);
+
+ BOOLEAN IsVersion_12() { return m_bVersion_1_2; }
+
+ // Verify if URI is blocked - feature isn't available
+ BOOLEAN IsUriEnabled(CPCHAR szURI) const;
+
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T IsESN(CPCHAR pbURI, BOOLEAN &isESN);
+#endif
+ DMMetaDataManager & GetMetaDataManager();
+ DMPluginManager & GetPluginManager();
+ SyncML_DM_Archiver & GetArchiver();
+ DMLockContextManager & GetLockContextManager();
+ DMSubscriptionManager & GetSubscriptionManager();
+
+ void CheckMemoryAging();
+ SYNCML_DM_RET_STATUS_T ReleaseLock( INT32 nLockID ,SYNCML_DM_COMMAND_T command = SYNCML_DM_RELEASE );
+ SYNCML_DM_RET_STATUS_T SaveFile(SYNCML_DM_FILE_TYPE_T eFileType);
+ SYNCML_DM_RET_STATUS_T RevertFile(SYNCML_DM_FILE_TYPE_T eFileType);
+ SYNCML_DM_RET_STATUS_T Flush();
+ void GetTreeMountEntry (CPCHAR& p_Uri,
+ CPCHAR& p_TreePath,
+ UINT16 index ) const;
+
+ SYNCML_DM_RET_STATUS_T RecoverPlugin();
+ CPCHAR GetWritableFileSystemFullPath( DMString & path );
+ BOOLEAN IsInitialized() const;
+ UINT16 GetMaxPathDepth() const;
+ UINT16 GetMaxTotalPathLength() const;
+ UINT16 GetMaxPathSegmentLength() const;
+
+
+private:
+ //FOR getStruct to free the list
+ inline void FreeListStruct() { psListInfo.Clear(); }
+
+
+ //To find the next sibling while traversing the child list
+ DMNode* FindNodeInNextSiblingsList(DMNode *psFindNode,
+ CPCHAR pbURISegment) const;
+
+
+ //To insert a newly added child in the Child list
+ SYNCML_DM_RET_STATUS_T InsertNodeIntoNextSiblingsList(DMNode *psNextSiblingStartNode,
+ DMNode *psInsertNode);
+
+ BOOLEAN ParentExistsForPluginNode( CPCHAR pURI, DMNode *psNode) const;
+
+ //To parse the ACL string and replace with server Indices
+ SYNCML_DM_RET_STATUS_T ParseACL(UINT8* pACL);
+
+
+ SYNCML_DM_RET_STATUS_T CheckDeleteForNode(DMNode *psDeletingNode,
+ CPCHAR pbURI);
+
+ SYNCML_DM_RET_STATUS_T DeleteNode(DMNode *psDeletingNode,
+ CPCHAR pbURI,
+ DMStringVector & aDeletedChildren);
+
+ //To check if the server is allowed to do the DM operation
+ SYNCML_DM_RET_STATUS_T IsValidServer(CPCHAR pURI,
+ SYNCML_DM_ACCESS_TYPE_T accessType,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ BOOLEAN bCheckAccess,
+ BOOLEAN bIsCheckLocal,
+ DMMetaPCharVector* pChildDependNodes = NULL);
+
+ //To get all the child names for GET on Interior node
+ SYNCML_DM_RET_STATUS_T GetChildren( CPCHAR szURI,
+ const DMNode *psNode,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ DMString& strChildren ) const;
+
+ //To get number of child on Interior node
+ UINT16 GetChildrenCount(const DMNode *psNode) const;
+
+ //validates the segment (grammar of node name)
+ BOOLEAN IsValidSegment(CPCHAR pbSegment, UINT8 bSegmentLength);
+
+ SYNCML_DM_RET_STATUS_T CheckDeleteForPluginNodes(SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ CPCHAR pbURI,
+ DMNode *psProxyNode,
+ DMStringVector & aChildren);
+
+ SYNCML_DM_RET_STATUS_T CheckDeleteForPluginNode(SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ CPCHAR pbURI,
+ PDmtNode ptrNode,
+ DMStringVector & aChildren,
+ BOOLEAN bIsParent);
+
+ BOOLEAN GetPluginURI(CPCHAR szURI, DMString& strURI, DMString& strShortURI ) const;
+
+ BOOLEAN LoadSkeletonParentArchive( DMNode* pNode );
+
+ SYNCML_DM_RET_STATUS_T GetListItemData(SYNCML_DM_GET_ON_LIST_RET_DATA_T& ppsReturnData);
+
+ DMNode* GetOPINode( CPCHAR szURI );
+
+ void ResetOPICache();
+ SYNCML_DM_RET_STATUS_T OnOPiDelete( CPCHAR szURI );
+ SYNCML_DM_RET_STATUS_T OnOPiAdd( CPCHAR szURI, DmtOverlayPluginData& data );
+ void CheckOpiSync( DMNode* pNode, char* szURI, const char* szLastSegment );
+ void OpiSync( DMNode* pNode, const char* szURI );
+ void CheckForIndirectUpdates( CPCHAR szURI, const DMMetaPCharVector& asChildDepend, DMNode* inNode );
+ void CheckURIForIndirectUpdates( CPCHAR szChild, CPCHAR szURI, DMNode* inNode );
+#ifdef LOB_SUPPORT
+ void ResetESNCache();
+ void RemoveESNCache(CPCHAR szURI );
+ DMNode* GetESN( CPCHAR szURI );
+ void SetESNCache( CPCHAR szURI , DMNode* pESN);
+ void LogDeleteForESN(DMNode *psDeletingNode);
+#endif
+ void LoadMaxValues();
+
+ SYNCML_DM_RET_STATUS_T InternalInit();
+ void InternalDeInit();
+ SYNCML_DM_RET_STATUS_T RecoverPluginFromFile( const DMString& file_bak_name );
+ SYNCML_DM_RET_STATUS_T ReadCommandFromFile( DMFileHandler *fileHandle,
+ DMBuffer& cmdURI );
+
+ BOOLEAN NeedCheckParent( const DMString& strURI,
+ DMNode *psReplacingNode,
+ BOOLEAN bInPlugin,
+ SYNCML_DM_FORMAT_T bFormat,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType);
+
+ SYNCML_DM_RET_STATUS_T ReplaceACLProperty( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ const DMString& strPluginURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode );
+
+ SYNCML_DM_RET_STATUS_T ReplaceTitleProperty( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ const DMString& strPluginURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode );
+
+ SYNCML_DM_RET_STATUS_T AddNodeInternal( DMAddData & oAddData,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType );
+
+ SYNCML_DM_RET_STATUS_T ReplaceNodeInternal( const DMString& strURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode,
+ DMMetaPCharVector& asChildDepend );
+
+ SYNCML_DM_RET_STATUS_T PrepareNamePropertyReplace( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode );
+
+ SYNCML_DM_RET_STATUS_T CheckReplacingNodeName( DMAddData& oReplaceData,
+ DMNode* psReplacingNode );
+
+ SYNCML_DM_RET_STATUS_T ReplaceProperty( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ const DMString& strPluginURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode,
+ SYNCML_DM_RET_STATUS_T wURIValidateRetCode );
+
+ SYNCML_DM_RET_STATUS_T ReplaceNameProperty( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ const DMString& strPluginURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode,
+ SYNCML_DM_RET_STATUS_T wURIValidateRetCode );
+
+ SYNCML_DM_RET_STATUS_T FixACL( const DMString& strURI,
+ DMAddData& oReplaceData );
+
+ SYNCML_DM_RET_STATUS_T SetACL(CPCHAR szURI);
+
+ BOOLEAN VerifyArchiveReadAccess(CPCHAR szURI);
+ BOOLEAN VerifyArchiveWriteAccess(CPCHAR szURI);
+
+ SYNCML_DM_RET_STATUS_T AddAutoNodes(CPCHAR szURI,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ DMToken & oAutoNodes);
+
+ SYNCML_DM_RET_STATUS_T LogEvent(SYNCML_DM_COMMAND_T type,
+ CPCHAR pbURI,
+ CPCHAR szNewName = NULL);
+
+ SYNCML_DM_RET_STATUS_T LogEvent(CPCHAR pbURI,
+ const DMStringVector & aDeletedChildren);
+
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T LogESNCommandForArchiver(CPCHAR pbURI,
+ DMNode * inNode);
+#endif
+
+private:
+#ifndef DM_NO_LOCKING
+ DMCriticalSection m_csInitLock;
+#endif
+
+ SYNCML_DM_TreeMount m_oTreeMountObj;
+ mutable DMMetaDataManager m_oMDFObj;
+ DMPluginManager m_oPluginManager;
+ SyncML_DM_Archiver m_oArchiver;
+ CMultipleFileManager m_oFileManager;
+ DMLockContextManager m_oLockContextManager;
+ DMAclManager m_oACLObj;
+ DMSubscriptionManager m_oEvtObj;
+ CEnv m_oEnv;
+ SYNCML_DM_RET_STATUS_T m_init_status;
+
+ DMString m_strPrincipal; /* Server ID */
+ DMString m_strConRef;
+
+ DMNode *m_psRoot; //The root node object
+
+ // the following 3 members are used for OPI support and cached by "FindNode" function
+ DmtOPINodeData m_oOPICacheData;
+ PDMPlugin m_ptrCacheOPI;
+ DMOverlayDataPluginNode *m_pOPINode;
+ BOOLEAN m_bVersion_1_2;
+
+#ifdef LOB_SUPPORT
+ DMNode *m_pESN; //The External Storage Node
+ DMString m_strESNPath; //URI of the ESN
+#endif
+
+ LIST_STRUCT_OR_STRUCT_DATA_INFO_T psListInfo;
+ UINT16 m_wMaxDepth;
+ UINT16 m_wMaxTotLen;
+ UINT16 m_wMaxSegLen;
+ INT32 m_nRefCount; // number of users
+
+ static const UINT8 *m_pDataFormatTable[];
+ XPL_CLK_CLOCK_T m_currentTime; // cached current time value
+};
+
+//Definition of DMTreeLastAccessedTime class
+//can be used to cache system call to XPL_CLK_GetClock,
+//which may occur quite frequently to update LastAccessedTime of archives
+class DMTreeCacheCurrentTime
+{
+ BOOLEAN m_resetCacheOnDestruct;
+ DMTree* m_tree;
+
+public:
+ DMTreeCacheCurrentTime(DMTree* tree)
+ {
+ m_resetCacheOnDestruct = (tree->m_currentTime==0);
+ m_tree = tree;
+ if (m_resetCacheOnDestruct)
+ tree->m_currentTime = XPL_CLK_GetClock();
+
+ }
+ ~DMTreeCacheCurrentTime()
+ {
+ if (m_resetCacheOnDestruct)
+ m_tree->m_currentTime = 0;
+ }
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern DMTree dmTreeObj;
+#ifdef __cplusplus
+}
+#endif
+
+//---------------------------------------------------------------------
+#endif // _DM_TREE_CLASS_H
diff --git a/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_ESN_class.H b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_ESN_class.H
new file mode 100644
index 0000000..37490cb
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_ESN_class.H
@@ -0,0 +1,123 @@
+#ifndef _DM_TREE_DEFAULT_ESN_CLASS_H
+#define _DM_TREE_DEFAULT_ESN_CLASS_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//------------------------------------------------------------------------
+// Header Name: dm_tree_default_ESN_class.H
+//
+// General Description: This file contains the definition of
+// DMDefaultESN class
+//------------------------------------------------------------------------
+// Revision History:
+// Author Modification Tracking Description
+// 2003-2007 refactoring
+// c23495 11/29/2006 libgg67059 LOB support
+// cdp180 03/16/2007 LIBll55345 Removing ACL check for internal calls
+//
+// ----------------- ------------ ---------- ----------------------
+
+//------------------------------------------------------------------------
+// INCLUDE FILES
+//------------------------------------------------------------------------
+#include "dm_tree_default_leaf_node_class.H" //header file for class defn
+#include "SyncML_DM_FileHandle.H"
+//------------------------------------------------------------------------
+// CONSTANTS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// MACROS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// ENUMS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// STRUCTURES AND OTHER TYPEDEFS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// GLOBAL VARIABLE DECLARATIONS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// FUNCTION PROTOTYPES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// CLASS
+//------------------------------------------------------------------------
+
+//class Definition for Default External Storage Nodes
+//IMPORTANT NOTE: A plug-in that supports Interior nodes can derive from
+//this class.Only DM_XXX methods are implemented in this class.
+// The Plug-in MUST implement functions for Initialization,CreateObject
+//callback,SessionEndcallback and GetClassUUID methods.
+
+class DMDefaultESN:public DMDefaultLeafNode
+{
+public:
+ //default constructor
+ DMDefaultESN(CPCHAR pbFileName);
+ ~DMDefaultESN();
+
+ //function to add an INTERIOR node for which no plug-in
+ //registered
+ virtual SYNCML_DM_RET_STATUS_T Add(DMAddData & oAddData);
+
+ //To delete a node's data :COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T Delete(CPCHAR pbUri);
+
+ //To get node's data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T Get(CPCHAR pbUri, DMGetData & oReturnData);
+
+ //To get node's format of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetFormat(CPCHAR pbUri,
+ SYNCML_DM_FORMAT_T *pdwRetPropertyData);
+
+ //To get node's type of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetType(CPCHAR pbUri, DMString& strType);
+
+ //To get node's size of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetSize(CPCHAR pbUri, UINT32 *pdwRetPropertyData);
+
+ //To update node's new name in database: COMMAND NOT ALLOWED
+ //on interior node
+ virtual SYNCML_DM_RET_STATUS_T Rename(CPCHAR pbUri, CPCHAR psNewNodeName);
+
+ //To replace node's size of data: COMMAND NOT ALLOWED
+ //on interior node
+ virtual SYNCML_DM_RET_STATUS_T Replace(DMAddData & oReplace);
+
+ // To rollback the operation,not supported in Phase 1
+ virtual SYNCML_DM_RET_STATUS_T Rollback();
+
+ virtual SYNCML_DM_RET_STATUS_T Commit();
+
+ BOOLEAN IsSetComplete() const { return m_bSetComplete;}
+ BOOLEAN IsDirty() const { return m_bDirty;}
+ BOOLEAN NeedLogging() const { return m_bNeedLogging;}
+ CPCHAR GetInternalStorageFileName(void) const;
+ CPCHAR GetOriginalInternalFileName(void) const;
+ SYNCML_DM_RET_STATUS_T OpenInternalStorageFile();
+ SYNCML_DM_RET_STATUS_T CloseInternalFile(void);
+ SYNCML_DM_RET_STATUS_T GetFirstChunk(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T GetNextChunk(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T SetFirstChunk(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T SetNextChunk(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T SetLastChunk(DmtDataChunk& chunkData);
+
+private:
+ DMString abStorageName;
+ DMString abOriginalName;
+ UINT32 totalSize;
+ BOOLEAN m_bSetComplete;
+ BOOLEAN m_bDirty;
+ DMFileHandler *fileHandle;
+ UINT32 offset;
+ BOOLEAN m_bNeedLogging;
+
+
+};
+//------------------------------------------------------------------------
+#endif //_DM_TREE_DEFAULT_ESN_CLASS_H
+
+
diff --git a/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_interior_node_class.H b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_interior_node_class.H
new file mode 100644
index 0000000..8fbd452
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_interior_node_class.H
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_TREE_DEFAULT_INTERIOR_NODE_CLASS_H
+#define _DM_TREE_DEFAULT_INTERIOR_NODE_CLASS_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//------------------------------------------------------------------------
+// Header Name: dm_tree_default_interior_node_class.H
+//
+// General Description: This file contains the definition of
+// DMDefaultInteriorNode class
+//------------------------------------------------------------------------
+
+#include "dm_tree_node_class.H" //for DMNode class defn
+
+//class Definition for Default interior nodes
+//IMPORTANT NOTE: A plug-in that supports Interior nodes can derive from
+//this class. Only DM_XXX methods are implemented in this class.
+
+// The Plug-in MUST implement functions for Initialization, CreateObject
+// callback, SessionEndcallback and GetClassUUID methods.
+
+class DMDefaultInteriorNode:public DMNode
+{
+public:
+ //default constructor
+ DMDefaultInteriorNode():DMNode(FALSE){bFormat = SYNCML_DM_FORMAT_NODE;};
+
+ //function to add an INTERIOR node for which no plug-in
+ //registered
+ virtual SYNCML_DM_RET_STATUS_T Add( DMAddData & oAddData );
+
+ //To delete a node's data :COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T Delete(CPCHAR pbUri);
+
+ //To get node's data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T Get(CPCHAR pbUri, DMGetData & oReturnData);
+
+ virtual SYNCML_DM_RET_STATUS_T Find(CPCHAR pbUri) { return SYNCML_DM_SUCCESS; }
+
+ virtual SYNCML_DM_RET_STATUS_T SetAddedNode(CPCHAR pbUri) { return SYNCML_DM_SUCCESS; }
+
+ virtual SYNCML_DM_RET_STATUS_T RemoveAddedNode(CPCHAR pbUri) { return SYNCML_DM_SUCCESS; }
+
+ //To get node's format of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetFormat(CPCHAR pbUri,
+ SYNCML_DM_FORMAT_T *pdwRetPropertyData);
+
+ //To get node's type of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetType(CPCHAR pbUri, DMString& strType);
+
+ //To get node's size of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetSize(CPCHAR pbUri, UINT32 *pdwRetPropertyData);
+
+ //To update node's new name in database: COMMAND NOT ALLOWED
+ //on interior node
+ virtual SYNCML_DM_RET_STATUS_T Rename(CPCHAR pbUri, CPCHAR psNewNodeName);
+
+ //To replace node's size of data: COMMAND NOT ALLOWED
+ //on interior node
+ virtual SYNCML_DM_RET_STATUS_T Replace(DMAddData & oReplace);
+
+ // To rollback the operation,not supported in Phase 1
+ virtual SYNCML_DM_RET_STATUS_T Rollback(SYNCML_DM_COMMAND_T bDMCommand, CPCHAR pbUri);
+};
+//------------------------------------------------------------------------
+
+
+class DMOverlayPINode :public DMDefaultInteriorNode
+{
+ DmtOverlayPluginData m_piData;
+ PDMPlugin m_ptrPI;
+public:
+ DMOverlayPINode( PDMPlugin pi, const DMNode* pOrgNode )
+ {
+ // make a copy of all attributes including pointers to parent/next/child and names
+ *reinterpret_cast<DMNode*>(this) = *pOrgNode;
+ m_ptrPI = pi;
+ m_nFlags |= enum_NodeOverlayPI;
+ }
+
+ DMOverlayPINode( PDMPlugin pi, const char* szName, const DmtOverlayPluginData& data)
+ {
+ // make a copy of all attributes including pointers to parent/next/child and names
+ m_ptrPI = pi;
+ m_nFlags |= enum_NodeStoresPID;
+ m_piData = data;
+ abNodeName = szName;
+ }
+
+ DMOverlayPINode()
+ {
+ m_nFlags |= enum_NodeStoresPID;
+ }
+ virtual DmtOverlayPluginData* getOverlayPIData() { return &m_piData;}
+ virtual const DmtOverlayPluginData* getOverlayPIData() const { return &m_piData;}
+ virtual PDMPlugin getOverlayPI() {return m_ptrPI;}
+};
+
+#endif //_DM_TREE_DEFAULT_INTERIOR_NODE_CLASS_H
diff --git a/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_leaf_node_class.H b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_leaf_node_class.H
new file mode 100644
index 0000000..b476722
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_default_leaf_node_class.H
@@ -0,0 +1,105 @@
+#ifndef _DM_TREE_DEFAULT_LEAF_NODE_CLASS_H
+#define _DM_TREE_DEFAULT_LEAF_NODE_CLASS_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//------------------------------------------------------------------------
+// Header Name: dm_tree_default_interior_node_class.H
+//
+// General Description: This file contains the definition of
+// DMDefaultLeafNode class
+//------------------------------------------------------------------------
+// Revision History:
+// Author Modification Tracking Description
+// (core ID) Date Number of Changes
+// ----------------------------------------------------------------------
+// 2003-2007 refactoring
+// cdp180 03/16/2007 LIBll55345 Removing ACL check for internal calls
+//
+//------------------------------------------------------------------------
+// INCLUDE FILES
+//------------------------------------------------------------------------
+#include "dm_tree_node_class.H" //for DMNode class defn
+//------------------------------------------------------------------------
+// CONSTANTS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// MACROS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// ENUMS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// STRUCTURES AND OTHER TYPEDEFS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// GLOBAL VARIABLE DECLARATIONS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// FUNCTION PROTOTYPES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// CLASS
+//------------------------------------------------------------------------
+
+//class Definition for Default interior nodes
+//IMPORTANT NOTE: A plug-in that supports Interior nodes can derive from
+//this class.Only DM_XXX methods are implemented in this class.
+// The Plug-in MUST implement functions for Initialization,CreateObject
+//callback,SessionEndcallback and GetClassUUID methods.
+
+class DMDefaultLeafNode:public DMNode
+{
+ DMBuffer psData;
+
+public:
+ //default constructor
+ DMDefaultLeafNode():DMNode(FALSE){};
+
+ //function to add an INTERIOR node for which no plug-in
+ //registered
+ virtual SYNCML_DM_RET_STATUS_T Add(DMAddData & oAddData);
+
+ //To delete a node's data :COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T Delete(CPCHAR pbUri);
+
+ //To get node's data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T Get(CPCHAR pbUri, DMGetData & oReturnData);
+
+ virtual SYNCML_DM_RET_STATUS_T Find(CPCHAR pbUri) { return SYNCML_DM_SUCCESS; }
+
+ virtual SYNCML_DM_RET_STATUS_T SetAddedNode(CPCHAR pbUri) { return SYNCML_DM_SUCCESS; }
+
+ virtual SYNCML_DM_RET_STATUS_T RemoveAddedNode(CPCHAR pbUri) { return SYNCML_DM_SUCCESS; }
+
+ //To get node's format of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetFormat(CPCHAR pbUri,
+ SYNCML_DM_FORMAT_T *pdwRetPropertyData);
+
+ //To get node's type of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetType(CPCHAR pbUri, DMString& strType);
+
+ //To get node's size of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetSize(CPCHAR pbUri, UINT32 *pdwRetPropertyData);
+
+ //To update node's new name in database: COMMAND NOT ALLOWED
+ //on interior node
+ virtual SYNCML_DM_RET_STATUS_T Rename(CPCHAR pbUri, CPCHAR psNewNodeName);
+
+ //To replace node's size of data: COMMAND NOT ALLOWED
+ //on interior node
+ virtual SYNCML_DM_RET_STATUS_T Replace(DMAddData & oReplace);
+
+ // To rollback the operation,not supported in Phase 1
+ virtual SYNCML_DM_RET_STATUS_T Rollback(SYNCML_DM_COMMAND_T bDMCommand,
+ CPCHAR pbUri);
+
+
+ virtual DMBuffer * getData() { return &psData; }
+ virtual const DMBuffer * getData() const { return &psData; }
+
+};
+//------------------------------------------------------------------------
+#endif //_DM_TREE_DEFAULT_INTERIOR_NODE_CLASS_H
diff --git a/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_node_class.H b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_node_class.H
new file mode 100644
index 0000000..81d3b1a
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_node_class.H
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_TREE_NODE_CLASS_H
+#define _DM_TREE_NODE_CLASS_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//------------------------------------------------------------------------
+// Header Name: dm_tree_node_class.H
+//
+// General Description: This file contains the definition of
+// DMNode class.
+//------------------------------------------------------------------------
+
+#include "syncml_dm_data_types.h" //For DM data type definitions
+#include "xpl_Logger.h"
+#include "dm_tree_typedef.h" //For tree type definitions
+#include "dmstring.h"
+#include "dmbuffer.h"
+#include "dmdefs.h"
+
+#include "dmt.hpp"
+#include "dmtPlugin.hpp"
+#include "dmPlugin.h"
+
+class SyncML_DM_Archive;
+
+class DMNode
+{
+protected:
+ //Those values should not be called directly as For
+ // plugin proxy node, you must access them through accessor function.
+ // For archiver, it is OK.
+
+ DMString abNodeName;
+ DMNode *pcParentOfNode; //Pointer to Parent of the node
+ DMNode *pcFirstChild; //Pointer to First Child of the node
+ DMNode *pcNextSibling; //Pointer to Next Sibling of the node
+
+ // psType cannot be accessed directly for mime type optimization
+ DMString psType_;
+ DMString m_strTitle;
+ SYNCML_DM_FORMAT_T bFormat;
+ UINT16 m_nFlags; // bit 0 set if plugin, bit 1 set if permanent: see next enum for details
+
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ XPL_CLK_CLOCK_T wTStamp;
+ UINT16 wVerNo;
+#endif
+
+ CPCHAR getType() const;
+ SYNCML_DM_RET_STATUS_T setType(const char * strType);
+
+ SYNCML_DM_RET_STATUS_T set(const DMGetData * pData);
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR strName, CPCHAR strTitle, const DMGetData * pData);
+
+ SYNCML_DM_RET_STATUS_T set(const DMAddNodeProp * pNodeProp);
+
+public:
+ SyncML_DM_Archive * pArchive;
+
+ enum {
+ enum_NodePlugin = 1,
+ enum_NodePermanent = 2,
+ enum_NodeSkeleton = 4, // fake node for lazy loading
+ enum_NodeOverlayPI = 8, // mount point for Overlay Pi
+ enum_NodeStoresPID = 16, // multinode with Overlay PI data
+ enum_NodeOPISyncNeeded = 32,
+ enum_NodeOPISyncNotNeeded = 64,
+ enum_NodeNoGetAccess = 128, // multinode with Overlay PI data
+ enum_NodeOPISyncUptodate = 256,
+ enum_NodeESN = 512,
+ enum_NodeNotPersisted = enum_NodePlugin | enum_NodeSkeleton | enum_NodeOverlayPI |enum_NodeOPISyncUptodate
+ };
+
+ friend class DMTree;
+ friend class SyncML_DM_Archive;
+ friend class DMMetaDataManager;
+ friend class SyncML_PlugIn_WBXMLLog;
+ friend class SyncML_DM_WBXMLWriter;
+
+
+ DMNode(BOOLEAN bPlugin);
+ virtual ~DMNode();
+ //Overloading new and delete operators
+
+ inline void* operator new(size_t dwSize)
+ {
+ return (DmAllocMem(dwSize));
+ }
+
+ inline void operator delete(void *pvBuf)
+ {
+ DmFreeMem(pvBuf);
+ }
+
+ inline DMNode *GetParent() {return pcParentOfNode;}
+
+ //The following are Pure virtual functions.Leaf or Interior node
+ //Classes deriving from this class MUST implement the functions.
+ virtual SYNCML_DM_RET_STATUS_T Add(DMAddData & oAddData) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T Delete(CPCHAR pbUri) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T Get(CPCHAR pbUri, DMGetData & oReturnData) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T Find(CPCHAR pbUri) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T SetAddedNode(CPCHAR pbUri) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T RemoveAddedNode(CPCHAR pbUri) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T GetFormat(CPCHAR pbUri,
+ SYNCML_DM_FORMAT_T * pdwRetPropertyData) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T GetSize(CPCHAR pbUri,
+ UINT32 *pdwRetPropertyData) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T GetType(CPCHAR pbUri,
+ DMString& strType) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T Replace(DMAddData & oReplaceData) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T Rename(CPCHAR pbUri, CPCHAR psNewNodeName) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T Rollback(SYNCML_DM_COMMAND_T bDMCommand,
+ CPCHAR pbUri) = 0;
+
+ virtual SYNCML_DM_RET_STATUS_T GetName(CPCHAR pbUri, DMString& strName);
+
+ virtual SYNCML_DM_RET_STATUS_T SetName(CPCHAR pbUri, CPCHAR pbNewName);
+
+ virtual SYNCML_DM_RET_STATUS_T GetTitle(CPCHAR pbUri, DMString& ppbTitle);
+
+ virtual SYNCML_DM_RET_STATUS_T SetTitle(CPCHAR pbUri, CPCHAR pbNewTitle);
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+
+ virtual XPL_CLK_CLOCK_T GetTStamp(CPCHAR /*pbUri*/)
+ {
+// pbUri = NULL;
+ return wTStamp;
+ }
+
+ virtual SYNCML_DM_RET_STATUS_T SetTStamp(CPCHAR pbUri, XPL_CLK_CLOCK_T timeStamp);
+
+ virtual UINT16 GetVerNo(const char* /*pbUri*/)
+ {
+// pbUri = NULL;
+ return wVerNo;
+ }
+
+ virtual SYNCML_DM_RET_STATUS_T SetVerNo (CPCHAR pbUri, UINT16 wVerNo);
+#endif
+
+ // DP: leaf node data access
+ virtual DMBuffer * getData() { return NULL; }
+ virtual const DMBuffer * getData() const { return NULL; }
+
+ // overlay plug-in access
+ virtual DmtOverlayPluginData* getOverlayPIData() { return NULL;}
+ virtual const DmtOverlayPluginData* getOverlayPIData() const { return NULL;}
+ virtual PDMPlugin getOverlayPI() {return PDMPlugin();}
+
+ //-----------Work on THIS NODE ONLY --------------
+ // And should used only by persistence layer etc.
+ //More methods implemented in the DMNode class.
+
+ //returns the Format of the node
+ inline SYNCML_DM_FORMAT_T getFormat() const { return(bFormat);}
+
+ inline BOOLEAN isPermanent() const {return (m_nFlags & enum_NodePermanent) != 0; }
+
+ inline BOOLEAN isPlugin() const {return (m_nFlags & enum_NodePlugin) != 0; }
+
+ inline BOOLEAN IsSkeletonNode() const {return (m_nFlags & enum_NodeSkeleton) != 0; }
+
+ // synchronization state of Overlay PI
+ inline BOOLEAN opiSyncNeeded() const {return (m_nFlags & enum_NodeOPISyncNeeded) != 0; }
+ inline BOOLEAN opiSyncNotNeeded() const {return (m_nFlags & enum_NodeOPISyncNotNeeded) != 0; }
+ inline BOOLEAN opiSyncMayNeeded() const {return (m_nFlags & (enum_NodeOPISyncNeeded |enum_NodeOPISyncNotNeeded)) == 0; }
+ inline BOOLEAN opiInSync() const {return (m_nFlags & enum_NodeOPISyncUptodate) != 0; }
+ inline BOOLEAN IsOverlayPI() const {return (m_nFlags & enum_NodeOverlayPI) != 0; }
+ inline BOOLEAN IsOverlayPIData() const {return (m_nFlags & enum_NodeStoresPID) != 0; }
+ virtual BOOLEAN IsGetAccess(CPCHAR pURI = NULL) const {return (m_nFlags & enum_NodeNoGetAccess) == 0; }
+
+
+
+ inline UINT16 getFlags() const {return m_nFlags;}
+
+ inline void setFlags( UINT16 n ) { m_nFlags = n;}
+ inline void addFlags( UINT16 n ) { m_nFlags |= n;}
+
+ inline CPCHAR getName() const { return abNodeName.c_str(); }
+
+
+ inline CPCHAR getTitle() const { return m_strTitle.c_str();}
+
+ DMNode* GetChildByName( const char* szName ) const;
+
+ DMNode* GetNextSerializeItem() ;
+
+ void ConvertPathToSkeleton( DMNode* psStartNode ) ;
+#ifdef LOB_SUPPORT
+ inline BOOLEAN IsESN() const {return (m_nFlags & enum_NodeESN) != 0; }
+ virtual SYNCML_DM_RET_STATUS_T IsESN(CPCHAR pbUri, BOOLEAN& bESN);
+ inline void SetESN() { m_nFlags |= enum_NodeESN; }
+#endif
+
+};
+
+
+//------------------------------------------------------------------------
+#endif //_DM_TREE_NODE_CLASS_H
diff --git a/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_plugin_root_node_class.H b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_plugin_root_node_class.H
new file mode 100644
index 0000000..7934589
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_plugin_root_node_class.H
@@ -0,0 +1,173 @@
+#ifndef _DM_TREE_PLUGIN_ROOT_NODE_CLASS_H
+#define _DM_TREE_PLUGIN_ROOT_NODE_CLASS_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+//------------------------------------------------------------------------
+// General Description: This file contains the definition of
+// DMPluginRootNode class
+//------------------------------------------------------------------------
+// Revision History:
+// Author Modification Tracking Description
+// (core ID) Date Number of Changes
+// -----------------------------------------------------------------------
+// 2003-2007 refactoring
+// cdp180 03/16/2007 LIBll55345 Removing ACL check for internal calls
+//------------------------------------------------------------------------
+// INCLUDE FILES
+//------------------------------------------------------------------------
+#include "dm_tree_node_class.H"
+#include "dmt.hpp"
+#include "dmPlugin.h"
+#include "dmMetaDataNode.h"
+
+//------------------------------------------------------------------------
+// CONSTANTS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// MACROS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// ENUMS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// STRUCTURES AND OTHER TYPEDEFS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// GLOBAL VARIABLE DECLARATIONS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// FUNCTION PROTOTYPES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// CLASS
+//------------------------------------------------------------------------
+
+//class Definition for Default interior nodes
+//Only DM_XXX methods are implemented in this class.
+// The Plug-in MUST implement functions for
+// Initialization,
+// CreateObject callback,
+// SessionEndcallback and
+// GetClassUUID methods.
+
+class DMPluginRootNode:public DMNode
+{
+public:
+ //default constructor
+ DMPluginRootNode( PDMPlugin pPlugin );
+
+ //destructor of the class
+ virtual ~DMPluginRootNode();
+
+ //function to add an INTERIOR node for which no plug-in
+ //registered
+ virtual SYNCML_DM_RET_STATUS_T Add (DMAddData & oAddData);
+
+ //To delete a node's data :COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T Delete(CPCHAR pURI);
+
+ //To get node's data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T Get(CPCHAR pURI, DMGetData & oReturnData);
+
+ virtual SYNCML_DM_RET_STATUS_T Find(CPCHAR pbUri);
+
+ virtual SYNCML_DM_RET_STATUS_T SetAddedNode(CPCHAR pbUri);
+
+ virtual SYNCML_DM_RET_STATUS_T RemoveAddedNode(CPCHAR pbUri);
+
+ //To get node's format of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetFormat(CPCHAR pURI, SYNCML_DM_FORMAT_T *pdwRetPropertyData);
+
+ //To get node's type of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetType(CPCHAR pURI, DMString& strType);
+
+ //To get node's size of data: COMMAND NOT ALLOWED on interior node
+ virtual SYNCML_DM_RET_STATUS_T GetSize (CPCHAR pURI,UINT32 * pdwRetPropertyData);
+
+ //To update node's new name in database: COMMAND NOT ALLOWED
+ //on interior node
+ virtual SYNCML_DM_RET_STATUS_T Rename(CPCHAR pURI, CPCHAR psNewNodeName);
+
+ //To replace node's size of data: COMMAND NOT ALLOWED
+ //on interior node
+ virtual SYNCML_DM_RET_STATUS_T Replace(DMAddData & oReplace);
+
+ // To rollback the operation,not supported in Phase 1
+ virtual SYNCML_DM_RET_STATUS_T Rollback (SYNCML_DM_COMMAND_T bDMCommand, CPCHAR pURI);
+
+ //Work on Multiple Nodes
+ virtual SYNCML_DM_RET_STATUS_T GetName(CPCHAR pURI, DMString& strName );
+
+ virtual SYNCML_DM_RET_STATUS_T SetName(CPCHAR pURI, CPCHAR pbNewName);
+
+ virtual SYNCML_DM_RET_STATUS_T GetTitle(CPCHAR pURI,DMString& ppbTitle);
+
+ virtual SYNCML_DM_RET_STATUS_T SetTitle(CPCHAR pURI, CPCHAR pbNewTitle);
+#ifdef LOB_SUPPORT
+ virtual SYNCML_DM_RET_STATUS_T IsESN(CPCHAR pbUri, BOOLEAN& bESN);
+#endif
+ SYNCML_DM_RET_STATUS_T GetTree(PDmtAPIPluginTree & ptrTree);
+
+ inline PDMPlugin GetPlugin() { return m_ptrPlugin;}
+
+ CPCHAR GetPluginURI(CPCHAR pURI);
+
+ virtual BOOLEAN IsGetAccess(CPCHAR pURI) const;
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+
+ //TStamp and VerNo are AutoSet.
+ virtual XPL_CLK_CLOCK_T GetTStamp(CPCHAR pURI);
+
+ virtual SYNCML_DM_RET_STATUS_T SetTStamp(CPCHAR /*pURI*/, XPL_CLK_CLOCK_T /*timeStamp*/)
+ {
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ }
+
+ virtual UINT16 GetVerNo(CPCHAR pURI);
+
+ virtual SYNCML_DM_RET_STATUS_T SetVerNo(CPCHAR /*pURI*/, UINT16 /*wVerNo*/)
+ {
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ }
+
+#endif
+
+ private:
+ virtual SYNCML_DM_RET_STATUS_T GetTree();
+
+
+ PDMPlugin m_ptrPlugin;
+ PDmtAPIPluginTree m_ptrPluginTree;
+
+};
+
+
+
+class DMOverlayDataPluginNode:public DMPluginRootNode
+{
+public:
+ //default constructor
+ DMOverlayDataPluginNode( PDMPlugin pPlugin );
+
+
+ virtual SYNCML_DM_RET_STATUS_T GetFormat(CPCHAR pURI, SYNCML_DM_FORMAT_T *pdwRetPropertyData);
+
+ inline void SetNodeAttributes( SYNCML_DM_ACCESS_TYPE_T wAccessType,
+ SYNCML_DM_FORMAT_T nNodeFormat )
+ {
+ m_wAccessType = wAccessType;
+ m_nNodeFormat = nNodeFormat;
+ }
+
+
+private:
+ SYNCML_DM_ACCESS_TYPE_T m_wAccessType;
+ SYNCML_DM_FORMAT_T m_nNodeFormat;
+
+};
+
+//------------------------------------------------------------------------
+#endif //_DM_TREE_PLUGIN_ROOT_NODE_CLASS_H
diff --git a/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_plugin_util.H b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_plugin_util.H
new file mode 100644
index 0000000..3df6b20
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_plugin_util.H
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_TREE_PLUGIN_UTIL_H
+#define _DM_TREE_PLUGIN_UTIL_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//------------------------------------------------------------------------
+// Header Name: dm_tree_plugin_util.H
+//
+// General Description: This file contains prototypes of plugin utilities
+//------------------------------------------------------------------------
+
+#include "dmPluginManager.h"
+#include "SyncML_DM_Archiver.H"
+
+SYNCML_DM_RET_STATUS_T DmRemoveTempfile(DMString &dirName);
+
+SYNCML_DM_RET_STATUS_T DmCallPluginFunction(CPCHAR szURI,
+ FILESETTYPE nFileSet,
+ SYNCML_DM_COMMAND_T type);
+
+SYNCML_DM_RET_STATUS_T DmExecutePlugin(CPCHAR path,
+ CPCHAR args,
+ CPCHAR szCorrelator,
+ DMString & oResult);
+
+SYNCML_DM_RET_STATUS_T DmCheckConstraint(CPCHAR szURI,
+ FILESETTYPE * nFileSet,
+ FILESETTYPE * nFileSetToRollback);
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_typedef.h b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_typedef.h
new file mode 100644
index 0000000..eda8595
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_typedef.h
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_TREE_TYPEDEF_H
+#define _DM_TREE_TYPEDEF_H
+
+/*========================================================================
+ Header Name: dm_tree_typedef.h
+
+ General Description: This file gives the data type definitions used
+ by the DMTNM module.
+========================================================================*/
+
+#include "syncml_dm_data_types.h" /*data defns of UA global data types*/
+#include "xpl_Time.h"
+#include "dmbuffer.h"
+#include "dmtData.hpp"
+#include "dmt.hpp"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*========================================================================
+ ENUMS
+========================================================================*/
+enum
+{
+ SYNCML_DM_GET_ON_LIST_STRUCT, /* ?list=Struct found in URI */
+ SYNCML_DM_GET_ON_LIST_STRUCTDATA /* ?list=StructData found in URI */
+
+};
+typedef UINT8 SYNCML_DM_GET_ON_LIST_T;
+
+enum
+{
+ SYNCML_DM_SERIALIZATION_SUCCESS,
+ SYNCML_DM_SERIALIZATION_FAIL,
+ SYNCML_DM_TREE_TRAVERSING_OVER
+};
+typedef UINT16 SYNCML_DM_SERIALIZATION_STATUS_T;
+
+enum
+{
+ SYNCML_DM_REQUEST_TYPE_API,
+ SYNCML_DM_REQUEST_TYPE_SERVER,
+ SYNCML_DM_REQUEST_TYPE_INTERNAL
+};
+typedef UINT8 SYNCML_DM_REQUEST_TYPE_T;
+
+
+#ifdef __cplusplus
+}
+#endif
+/*========================================================================
+ STRUCTURES AND OTHER TYPEDEFS
+========================================================================*/
+
+
+/*class used for returning the data for GET operation */
+class DMGetData
+{
+public:
+
+ inline DMGetData() {
+ m_nFormat = SYNCML_DM_FORMAT_INVALID;
+#ifdef LOB_SUPPORT
+ m_chunkOffset = 0L; // offset
+ chunkData = NULL;
+#endif
+ }
+
+ inline ~DMGetData() {}
+
+ inline void clear()
+ {
+ m_nFormat = SYNCML_DM_FORMAT_INVALID;
+ m_TotalSize = -1;
+ m_oMimeType.clear();
+ m_oData.clear();
+ }
+
+ SYNCML_DM_RET_STATUS_T set(SYNCML_DM_FORMAT_T wFormat,
+ CPCHAR pData,
+ UINT32 dataLength,
+ CPCHAR pMimeType);
+
+ SYNCML_DM_RET_STATUS_T set(const DmtData & data, CPCHAR pMimeType);
+
+ inline CPCHAR getCharData() const { return (CPCHAR)m_oData.getBuffer(); }
+
+ inline CPCHAR getType() const { return (CPCHAR)m_oMimeType.getBuffer(); }
+
+ inline void* operator new(size_t dwSize) {return (DmAllocMem(dwSize)); }
+
+ inline void operator delete(void *pvBuf) { DmFreeMem(pvBuf); }
+
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T set(DmtDataChunk *dmtChunk, UINT32 dmtChunkoffset);
+ void clearESNData();
+ void SetESN(BOOLEAN isESN) {m_bESN = isESN;}
+ BOOLEAN IsESN() const {return m_bESN;}
+#else
+ BOOLEAN IsESN() const {return FALSE;}
+#endif
+ DMBuffer m_oMimeType;
+ SYNCML_DM_FORMAT_T m_nFormat;
+ DMBuffer m_oData;
+ int m_TotalSize;
+
+#ifdef LOB_SUPPORT
+ UINT32 m_chunkOffset; // offset
+ DmtDataChunk *chunkData;
+ BOOLEAN m_bESN;
+#endif
+
+};
+
+
+/*class used for ADD on a node*/
+class DMAddData : public DMGetData
+{
+public:
+
+ DMAddData ()
+ {
+ clear();
+ }
+ inline void clear()
+ {
+ DMGetData::clear();
+ m_oURI.clear();
+ }
+
+ inline CPCHAR getURI() const { return (CPCHAR)m_oURI.getBuffer(); }
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR pURI,
+ SYNCML_DM_FORMAT_T wFormat,
+ CPCHAR pData,
+ UINT32 dataLength,
+ CPCHAR pMimeType);
+
+ SYNCML_DM_RET_STATUS_T set(SYNCML_DM_FORMAT_T wFormat, CPCHAR pMimeType);
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR pURI, const DmtData & data, CPCHAR pMimeType);
+#ifdef LOB_SUPPORT
+ void clearESNData()
+{ DMGetData::clearESNData();
+ m_bLastChunk = FALSE;
+}
+ BOOLEAN IsLastChunk() const {return m_bLastChunk;}
+ SYNCML_DM_RET_STATUS_T set(CPCHAR pURI,
+ DmtDataChunk *dmtChunk,
+ UINT32 dmtChunkoffset,
+ BOOLEAN isLastChunk);
+ BOOLEAN m_bLastChunk;
+#endif
+
+
+ DMBuffer m_oURI;
+};
+
+
+
+struct SYNCML_DM_GET_ON_LIST_RET_DATA_T
+{
+ DMGetData *psRetData;
+ DMString _pbURI;
+ DMString m_strStartURI;
+ DMString m_strNextChild;
+
+ inline SYNCML_DM_GET_ON_LIST_RET_DATA_T() {psRetData=NULL;}
+};
+
+
+/*structure for passing properties in ADD*/
+class DMAddNodeProp : public DMAddData
+{
+public:
+
+ DMAddNodeProp ()
+ {
+ m_nFlags = 0;
+ m_nFormat = SYNCML_DM_FORMAT_NODE;
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ m_nTStamp = 0;
+ m_nVerNo = 0;
+#endif
+
+ m_oURI.allocate(SYNCML_DM_URI_MAX_TOTAL_LENGTH);
+ m_oName.allocate(SYNCML_DM_MAX_TITLE_LENGTH);
+ m_oTitle.allocate(SYNCML_DM_MAX_TITLE_LENGTH);
+ m_oMimeType.allocate(SYNCML_DM_MAX_TITLE_LENGTH);
+ m_oData.allocate(SYNCML_DM_MAX_TITLE_LENGTH);
+#ifdef LOB_SUPPORT
+ m_oESNFileName.allocate(SYNCML_DM_URI_MAX_TOTAL_LENGTH);
+#endif
+ }
+
+ inline void clear()
+ {
+ DMAddData::clear();
+ m_oName.clear();
+ m_oTitle.clear();
+#ifdef LOB_SUPPORT
+ m_oESNFileName.clear();
+#endif
+ m_nFlags = 0;
+ m_nFormat = SYNCML_DM_FORMAT_NODE;
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ m_nTStamp = 0;
+ m_nVerNo = 0;
+#endif
+ m_oOPiData.clear();
+ }
+
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR pName,
+ CPCHAR pTitle,
+ SYNCML_DM_FORMAT_T wFormat,
+ CPCHAR pData,
+ UINT32 dataLength,
+ CPCHAR pMimeType,
+ UINT16 flag);
+
+
+ inline CPCHAR getName() const { return (CPCHAR)m_oName.getBuffer(); }
+
+ inline CPCHAR getTitle() const { return (CPCHAR)m_oTitle.getBuffer(); }
+
+#ifdef LOB_SUPPORT
+ inline CPCHAR getESNFileName() const { return (CPCHAR)m_oESNFileName.getBuffer(); }
+ SYNCML_DM_RET_STATUS_T setESNFileName(CPCHAR pFileName);
+#endif
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ XPL_CLK_CLOCK_T m_nTStamp;
+ UINT16 m_nVerNo;
+#endif
+
+
+ UINT16 m_nFlags;
+#ifdef LOB_SUPPORT
+ DMBuffer m_oESNFileName;
+#endif
+ DMBuffer m_oName;
+ DMBuffer m_oTitle;
+ DMBuffer m_oOPiData;
+};
+
+#endif /*DM_TREE_TYPEDEF_H*/
diff --git a/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_util.h b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_util.h
new file mode 100644
index 0000000..799e6af
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/hdr/dm_tree_util.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_TREE_UTIL_H
+#define _DM_TREE_UTIL_H
+
+/*========================================================================
+ Header Name: dm_tree_util.h
+
+ General Description: This file gives the definitions of UTILITY
+ functions provided by the DMTNM module.
+========================================================================*/
+
+#include "dm_tree_typedef.h" /* for defn of plug-in get ret structure */
+#include "dm_tree_class.H"
+#include "dmt.hpp"
+
+#define FDR_URI "./ManagedObjects/LAWMO/Operations/FactoryReset"
+
+SYNCML_DM_RET_STATUS_T dmBuildData(SYNCML_DM_FORMAT_T format,
+ const DMBuffer & oData,
+ DmtData & oDmtData);
+
+SYNCML_DM_RET_STATUS_T dmConvertDataMap(CPCHAR path,
+ const DMMap<DMString, DmtData>& mapNodes,
+ DMMap<DMString, UINT32>& newChildrenMap);
+
+void dmFreeGetMap( DMMap<DMString, UINT32>& getDataMap);
+
+void dmFreeAddMap( DMMap<DMString, UINT32>& addDataMap);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern DMTree dmTreeObj;
+SYNCML_DM_RET_STATUS_T dmGetNodeValue(CPCHAR uriPath, DmtData& oDmtData);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*DM_TREE_UTIL_H*/
diff --git a/engine/dmlib/dmengine/dm_tnm/src/dm_tree_class_private.cc b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_class_private.cc
new file mode 100644
index 0000000..838c80a
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_class_private.cc
@@ -0,0 +1,1770 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//------------------------------------------------------------------------
+//
+// Module Name: dm_tree_class_private.cc
+//
+// General Description:Contains the implementations of the methods of
+// DMNode class.
+//------------------------------------------------------------------------
+
+#include "dm_tree_util.h"
+#include "dm_tree_plugin_root_node_class.H"
+#include "xpl_Logger.h"
+#include "dm_uri_utils.h"
+#include "SyncML_DM_Archive.H"
+#include "dmprofile.h"
+#include "dm_tree_plugin_util.H"
+#include "dm_tree_default_interior_node_class.H"
+#include "dm_tree_class.H"
+
+//------------------------------------------------------------------------
+// GLOBAL VARIABLES
+//------------------------------------------------------------------------
+DMTree dmTreeObj;
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : GetLastSegmentOfURI
+//
+// DESCRIPTION : This function will return the starting location
+// of the last segment of the URI.
+//
+// ARGUMENTS PASSED: UINT8 *pbURI
+// RETURN VALUE : UINT8 *
+// - Pointer to starting location of last segment
+// PRE-CONDITIONS : Input parameter SHOULD NOT BE NULL.
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : N/A The methods in this file are private methods
+// internal to DMTNM implementation
+//------------------------------------------------------------------------
+BOOLEAN DMTree::GetLastSegmentOfURI( DMString& strURI, DMString& strLastSegment )
+{
+ if (!strURI.GetBuffer())
+ return FALSE;
+
+ char* szLastSlash = DmStrrchr( strURI.GetBuffer(), SYNCML_DM_FORWARD_SLASH );
+
+ if ( !szLastSlash )
+ return FALSE;
+
+ *szLastSlash = 0;
+
+ strLastSegment = ++szLastSlash;
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : IsValidServer
+//
+// DESCRIPTION : This function will check the access type and the
+// ACL permissions of the node.
+//
+//
+// ARGUMENTS PASSED:
+
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// - It returns SYNCML_DM_SUCCESS if the AccessType is set
+// and the ACL permisssion is there for the requested
+// operation.
+// - It returns SYNCML_DM_COMMAND_NOT_ALLOWED if the
+// Accesstype is not for the requested operation.
+// - It returns SYNCML_DM_PERMISSION_FAILED if the ACL
+// permission is not for the requested operation
+// - It returns SYNCML_DM_COMMAND_NOT_IMPLEMENTED if
+// the command is not implemented by the client.
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM00xx-m in SYNCML-DM-ENGINE-FSRS-02101010
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::IsValidServer(CPCHAR pURI,
+ SYNCML_DM_ACCESS_TYPE_T accessType,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ BOOLEAN bCheckAccess,
+ BOOLEAN bIsCheckLocal,
+ DMMetaPCharVector* pChildDependNodes /*=NULL*/)
+{
+
+ if (pURI == NULL)
+ {
+ //XPL_LOG_DM_TMN_Debug(("DMTree::IsValidServer: pURI is null \n"));
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+
+ if ( eRequestType != SYNCML_DM_REQUEST_TYPE_SERVER )
+ {
+ //XPL_LOG_DM_TMN_Debug(("DMTree::IsValidServer: Request type is not SYNCML_DM_REQUEST_TYPE_SERVER \n"));
+ bIsCheckLocal = FALSE;
+ }
+
+ if ( !m_oACLObj.IsPermitted( pURI,
+ GetServerId(),
+ (SYNCML_DM_ACL_PERMISSIONS_T)accessType,
+ bIsCheckLocal) )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::IsValidServer: permission failed \n"));
+ return SYNCML_DM_PERMISSION_FAILED;
+ }
+
+ if ( accessType != SYNCML_DM_GET_ACCESS_TYPE && bCheckAccess )
+ {
+ if( !m_oMDFObj.VerifyAccessType(pURI,accessType, pChildDependNodes) )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::IsValidServer: access not allowed \n"));
+ return (SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : GetChildren
+//
+// DESCRIPTION : This function gives the list of childs of the node
+//
+//
+// ARGUMENTS PASSED: DMNode *psNode
+// DMString & strChildren
+// - contains childs each child seperated by '/'
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// - It returns SYNCML_DM_SUCCESS if the function return
+// the childs.
+// - It returns SYNCML_DM_COMMAND_FAILED if the
+// pointer psNode is NULL.
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM00xx-m in SYNCML-DM-ENGINE-FSRS-02101010
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::GetChildren(
+ CPCHAR szURI,
+ const DMNode *psNode,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ DMString& strChildren ) const
+{
+ DMMetaDataManager & m_oMDFObj = dmTreeObj.GetMetaDataManager();
+ BOOLEAN bIsLocal = FALSE;
+
+ DMString strChildrenOPI;
+
+ strChildren = NULL;
+
+ if( !psNode )
+ return SYNCML_DM_COMMAND_FAILED;
+
+ psNode = psNode->pcFirstChild;
+
+ while(psNode)
+ {
+ bIsLocal = FALSE;
+ if ( eRequestType == SYNCML_DM_REQUEST_TYPE_SERVER )
+ {
+ DMString szChildURI(szURI);
+
+ szChildURI += "/";
+ szChildURI += psNode->abNodeName;
+ bIsLocal = m_oMDFObj.IsLocal(szChildURI);
+ }
+ if ( !bIsLocal )
+ {
+ strChildren += psNode->abNodeName;
+
+ if ( psNode->pcNextSibling )
+ strChildren += "/";
+ }
+ strChildrenOPI += psNode->abNodeName;
+
+ if ( psNode->pcNextSibling )
+ strChildrenOPI += "/";
+
+ psNode = psNode->pcNextSibling;
+ }
+
+ // DP: Overlay plugin support
+ if ( m_ptrCacheOPI != NULL )
+ {
+ m_oMDFObj.UpdateChildrenList( szURI, strChildrenOPI );
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : GetChildrenCount
+//
+// DESCRIPTION : This function gives the number of childs of the node
+//
+//
+// ARGUMENTS PASSED: DMNode *psNode
+//
+// RETURN VALUE : childs count
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+UINT16 DMTree::GetChildrenCount(const DMNode *psNode)const
+{
+ int childCount = 0;
+
+ if( !psNode )
+ return 0;
+
+ psNode = psNode->pcFirstChild;
+
+ while(psNode)
+ {
+ childCount++;
+ psNode = psNode->pcNextSibling;
+ }
+
+ return childCount;
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : FindNodeByURI
+//
+// DESCRIPTION : This functions returns the pointer to DMNode of the
+// the last segment of the URI. This function will use
+// both Depth First Search and Breadth First Search
+// traversal algorithms to search.
+//
+//
+// ARGUMENTS PASSED: UINT8* pbURI - Contails the URI
+// RETURN VALUE : DMNode*
+// - It returns NULL if the node was NOT found
+// in the tree.
+// - It returns Pointer to the DMNode if it finds
+// the node in the tree.
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM00xx-m in SYNCML-DM-ENGINE-FSRS-02101010
+//------------------------------------------------------------------------
+DMNode* DMTree::FindNodeByURI(CPCHAR pbURI)
+{
+ XPL_LOG_DM_TMN_Debug(("DMTree::FindNodeByURI: Enter. pbURI=%s\n",pbURI));
+ DMString strURI = pbURI;
+ char *szURI = strURI.GetBuffer();
+
+ const char *pbURISegment = NULL;
+ DMNode *psFindNode = NULL;
+ DMNode *pParentCopy = NULL;
+
+#ifdef LOB_SUPPORT
+ // Is a cached ESD
+ psFindNode = GetESN(pbURI);
+ if (psFindNode != NULL)
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::FindNodeByURI: this is a cached ESD\n"));
+ return psFindNode;
+ }
+#endif
+ // last access time for pArchive
+ XPL_CLK_CLOCK_T currentTime = m_currentTime; // use cached value if available
+ if (currentTime==0)
+ currentTime = XPL_CLK_GetClock();
+
+ // reset OPI cache
+ m_ptrCacheOPI = NULL;
+ m_oOPICacheData.metaNodeID = -1; // metanode ID is set later only for PI node
+
+ while ( m_oOPICacheData.aPD.size() )
+ m_oOPICacheData.aPD.remove(0); // function "remove" does not free buffer in contrast to "removeall"
+
+ psFindNode = m_psRoot;
+
+ pbURISegment = GetURISegment(&szURI);
+ while(psFindNode != NULL && pbURISegment)
+ {
+ //XPL_LOG_DM_TMN_Debug(("DMTree::FindNodeByURI: szURI=%s, pbURISegment=%s\n",szURI, pbURISegment));
+ //XPL_LOG_DM_TMN_Debug(("DMTree::FindNodeByURI: m_psRoot.abNodeName=%s\n",m_psRoot->abNodeName.GetBuffer()));
+ // This functions will seach for the segment in the siblings linked
+ // list
+ pParentCopy = psFindNode;
+
+ psFindNode = FindNodeInNextSiblingsList(psFindNode, pbURISegment);
+ if(psFindNode == NULL) {
+ pParentCopy = pParentCopy->pcParentOfNode;
+ if ( pParentCopy && LoadSkeletonParentArchive(pParentCopy) ) {
+ psFindNode = FindNodeInNextSiblingsList(pParentCopy->pcFirstChild, pbURISegment);
+ }
+
+ if ( !psFindNode )
+ {
+ if (szURI == NULL && m_ptrCacheOPI != NULL )
+ {
+ psFindNode = GetOPINode( pbURI );
+#ifdef LOB_SUPPORT
+ if(psFindNode != NULL && m_oMDFObj.IsESN( pbURI ))
+ SetESNCache(pbURI ,psFindNode);
+#endif
+ XPL_LOG_DM_TMN_Debug(("DMTree::FindNodeByURI: find node from OPI cache \n"));
+ return psFindNode;
+ }
+ XPL_LOG_DM_TMN_Debug(("DMTree::FindNodeByURI: can not find the node \n"));
+ return (NULL);
+ }
+ }
+
+ // OPI
+ //XPL_LOG_DM_TMN_Debug(("DMTree::FindNodeByURI: Check if the node is a OverlayPI \n"));
+ if ( psFindNode->IsOverlayPI() )
+ {
+ m_ptrCacheOPI = psFindNode->getOverlayPI();
+ // reset data again for case overlapped opi
+ while ( m_oOPICacheData.aPD.size() )
+ m_oOPICacheData.aPD.remove(0); // function "remove" does not free buffer in contrast to "removeall"
+ }
+
+ if ( psFindNode->IsOverlayPIData() && psFindNode->getOverlayPIData())
+ m_oOPICacheData.aPD.push_back( *psFindNode->getOverlayPIData());
+
+ // OPI synchronization support
+ if ( m_ptrCacheOPI != NULL && !psFindNode->opiSyncNotNeeded() )
+ CheckOpiSync( psFindNode, strURI.GetBuffer(), pbURISegment );
+
+ pbURISegment = GetURISegment(&szURI);
+ // If the pbURISegment is NULL means then it has processed the
+ // full URI and got the DMNode pointer for the last segment of
+ // the URI.
+ // For plugin Proxy node, use the proxy node for ALL subtree.
+ if ((pbURISegment == NULL) || (pbURISegment[0] == '\0') || (psFindNode->isPlugin())) {
+
+ if ( psFindNode->IsSkeletonNode() && psFindNode->pArchive )
+ psFindNode->pArchive->deserialize(this);
+
+ // e50024
+ // Update last access time of the archive
+ DMNode * pNode = psFindNode;
+
+ while ( pNode ) {
+ if ( pNode->pArchive ) {
+ pNode->pArchive->setLastAccessedTime(currentTime);
+ break;
+ }
+ pNode = pNode->pcParentOfNode;
+ }
+#ifdef LOB_SUPPORT
+ if(psFindNode != NULL && m_oMDFObj.IsESN( pbURI ))
+ SetESNCache(pbURI ,psFindNode);
+#endif
+
+ return (psFindNode);
+ }
+
+ // If the URI segment is NOT NULL then we have look into
+ // the childs list of the current node because previous URI
+ // segment will become the parent of the current URI segment.
+ if ( !psFindNode->pcFirstChild )
+ LoadSkeletonParentArchive( psFindNode );
+
+ psFindNode = psFindNode->pcFirstChild;
+ }
+
+ if (szURI == NULL && m_ptrCacheOPI != NULL )
+ { psFindNode = GetOPINode( pbURI );
+
+#ifdef LOB_SUPPORT
+ if(psFindNode != NULL && m_oMDFObj.IsESN( pbURI ))
+ SetESNCache(pbURI ,psFindNode);
+#endif
+ return psFindNode;
+ }
+ return (NULL);
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : ParseACL
+//
+// DESCRIPTION : This function will parse the ACL according the BNF
+// defined in FSRS.
+//
+// ARGUMENTS PASSED: UINT8* pACL
+// - ACL value
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// - It returns SYNCML_DM_COMMAND_FAILED in case
+// if there is any failure.
+// - It returns SYNCML_DM_SUCCESS in case if the ACL value
+// parsed successfully.
+// - It returns SYNCML_DM_DEVICE_FULL in case if the
+// device is out of memory.
+//
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM00xx-m in SYNCML-DM-ENGINE-FSRS-02101010
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::ParseACL(UINT8* pACL)
+{
+ UINT8 *pbStartingPosOfCmd = NULL;
+ UINT8 *pbACL = NULL, *pNew;
+
+ // oCommandsInACL variable is used to decide whether to add "&" to the
+ // ACL value or not while parsing the ACL. Assume that if the server
+ // has fired an ACL value like ACL = Add=ServerA&Get=ServerB then after
+ // processing "ADD".
+ // BOOLEAN oCommandsInACL = FALSE;
+
+ SYNCML_DM_RET_STATUS_T wReturnCode = SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_TMN_Debug(("Entered DMTree::ParseACL \n"));
+
+ if(pACL == NULL)
+ return (SYNCML_DM_SUCCESS);
+
+ if(pACL[0] == '\0')
+ return (SYNCML_DM_COMMAND_FAILED);
+
+ pNew = pbACL = (UINT8*) DmAllocMem((sizeof(UINT8) * (DmStrlen((const char*)pACL) + 1)));
+ if (!pbACL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ DmStrcpy((char*)pbACL, (const char*)pACL);
+ pbStartingPosOfCmd = (UINT8*)pbACL;
+
+ while(*pbACL != '\0')
+ {
+ pbACL = (UINT8*)DmStrchr((CPCHAR)pbACL, SYNCML_DM_EQUAL_TO);
+
+ if(pbACL == NULL)
+ {
+ XPL_LOG_DM_TMN_Debug(("Invalid ACL String \n"));
+ DmFreeMem(pNew);
+ return (SYNCML_DM_COMMAND_FAILED);
+ }
+ *pbACL = '\0';
+
+ // Here we are checking for the first character to reduce
+ // the time.
+ if(pbStartingPosOfCmd[0] == SYNCML_DM_ASCII_CAPITAL_R)
+ {
+ // We have already compared "R" and now we have to check if it is
+ // "eplace".
+ if(DmStrcmp((CPCHAR)&pbStartingPosOfCmd[1], SYNCML_DM_EPLACE))
+ wReturnCode = SYNCML_DM_COMMAND_FAILED;
+ else
+ {
+ pbStartingPosOfCmd += REPLACE_CMD_LENGTH_IN_ACL;
+ pbStartingPosOfCmd = (UINT8*) DmStrchr((CPCHAR)pbStartingPosOfCmd, SYNCML_DM_AMPERSAND);
+ if ( !pbStartingPosOfCmd )
+ break;
+ pbStartingPosOfCmd++;
+ }
+ }
+ else
+ if(pbStartingPosOfCmd[0] == SYNCML_DM_ASCII_CAPITAL_G)
+ {
+ if(DmStrcmp((CPCHAR)&pbStartingPosOfCmd[1], SYNCML_DM_ET))
+ wReturnCode = SYNCML_DM_COMMAND_FAILED;
+ else
+ {
+ pbStartingPosOfCmd += GET_CMD_LENGTH_IN_ACL;
+ pbStartingPosOfCmd = (UINT8*) DmStrchr((CPCHAR)pbStartingPosOfCmd, SYNCML_DM_AMPERSAND);
+ if ( !pbStartingPosOfCmd )
+ break;
+ pbStartingPosOfCmd++;
+ }
+ }
+ else
+ if(pbStartingPosOfCmd[0] == SYNCML_DM_ASCII_CAPITAL_A)
+ {
+ if(DmStrcmp((CPCHAR)&pbStartingPosOfCmd[1], SYNCML_DM_DD))
+ wReturnCode = SYNCML_DM_COMMAND_FAILED;
+ else
+ {
+ pbStartingPosOfCmd += ADD_CMD_LENGTH_IN_ACL;
+ pbStartingPosOfCmd = (UINT8*) DmStrchr((CPCHAR)pbStartingPosOfCmd, SYNCML_DM_AMPERSAND);
+ if ( !pbStartingPosOfCmd )
+ break;
+ pbStartingPosOfCmd++;
+ }
+ }
+ else
+ if(pbStartingPosOfCmd[0] == SYNCML_DM_ASCII_CAPITAL_D)
+ {
+ if(DmStrcmp((CPCHAR)&pbStartingPosOfCmd[1], SYNCML_DM_ELETE))
+ wReturnCode = SYNCML_DM_COMMAND_FAILED;
+ else
+ {
+ pbStartingPosOfCmd += DELETE_CMD_LENGTH_IN_ACL;
+ pbStartingPosOfCmd = (UINT8*) DmStrchr((CPCHAR)pbStartingPosOfCmd, SYNCML_DM_AMPERSAND);
+ if ( !pbStartingPosOfCmd )
+ break;
+ pbStartingPosOfCmd++;
+ }
+ }
+ else
+ if(pbStartingPosOfCmd[0] == SYNCML_DM_ASCII_CAPITAL_E)
+ {
+ if(DmStrcmp((CPCHAR)&pbStartingPosOfCmd[1], SYNCML_DM_XEC))
+ wReturnCode = SYNCML_DM_COMMAND_FAILED;
+ else
+ {
+ pbStartingPosOfCmd += EXEC_CMD_LENGTH_IN_ACL;
+ pbStartingPosOfCmd = (UINT8*) DmStrchr((CPCHAR)pbStartingPosOfCmd, SYNCML_DM_AMPERSAND);
+ if ( !pbStartingPosOfCmd )
+ break;
+ pbStartingPosOfCmd++;
+ }
+ }
+ else
+ {
+ wReturnCode = SYNCML_DM_COMMAND_FAILED;
+ }
+
+ pbACL = pbStartingPosOfCmd;
+ }
+
+ DmFreeMem(pNew);
+ return wReturnCode;
+}
+
+
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : FindNodeInNextSiblingsList
+//
+// DESCRIPTION : This function will search for the URI Segment in
+// the siblings list. If the node was found then it
+// returns the DMNode pointer otherwise it returns NULL.
+//
+//
+// ARGUMENTS PASSED: const DMNode *psFindNode
+// - Starting position of the siblings linked list.
+// const UINT8 *pbURISegment
+// - Contains the URI segment.
+// RETURN VALUE : DMNode*
+// - It returns DMNode pointer if the node was found.
+// - NULL if the node was NOT found.
+//
+// PRE-CONDITIONS : pbURISegment SHOULD NOT BE NULL.
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM00xx-m in SYNCML-DM-ENGINE-FSRS-02101010
+//------------------------------------------------------------------------
+DMNode* DMTree::FindNodeInNextSiblingsList(DMNode *psFindNode,
+ CPCHAR pbURISegment) const
+{
+ DMNode *psCurNode = psFindNode;
+
+ while(psCurNode != NULL)
+ {
+ if(DmStrcmp(psCurNode->abNodeName, pbURISegment) == 0)
+ return (psCurNode);
+
+ psCurNode = psCurNode->pcNextSibling;
+ }
+
+ return (NULL);
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : InsertNodeIntoNextSiblingsList
+//
+// DESCRIPTION : This function will insert the node into the siblings
+// list and before inserting the node it checks if the
+// node already existed or NOT. if the node already
+// existed then it will add the node into the siblings
+// list.
+//
+//
+// ARGUMENTS PASSED: DMNode *psNextSiblingStartNode
+// - Starting position of the siblings linked list.
+// DMNode *psInsertNode
+// - Inserting node pointer.
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// - It returns SYNCML_DM_SUCCESS if the functions inserts
+// the node successfully into the siblings list.
+// - It returns SYNCML_DM_TARGET_ALREADY_EXISTS the
+// node already existed in the siblings list.
+//
+// PRE-CONDITIONS : Input parameters SHOULD NOT BE NULL.
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM00xx-m in SYNCML-DM-ENGINE-FSRS-02101010
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::InsertNodeIntoNextSiblingsList(
+ DMNode *psNextSiblingStartNode,
+ DMNode *psInsertNode)
+{
+ XPL_LOG_DM_TMN_Debug(("Entered DMTree::InsertNodeIntoNextSiblingsList \n"));
+ while(psNextSiblingStartNode->pcNextSibling != NULL)
+ {
+ if(DmStrcmp((CPCHAR)psNextSiblingStartNode->abNodeName,
+ (CPCHAR)psInsertNode->abNodeName) == 0)
+ {
+ XPL_LOG_DM_TMN_Debug(("Node Already exists in the Tree \n"));
+ return (SYNCML_DM_TARGET_ALREADY_EXISTS);
+ }
+
+ psNextSiblingStartNode = psNextSiblingStartNode->pcNextSibling;
+ }
+
+ if(DmStrcmp((CPCHAR)psNextSiblingStartNode->abNodeName,
+ (CPCHAR)psInsertNode->abNodeName) == 0)
+ {
+ XPL_LOG_DM_TMN_Debug(("Node Already exists in the Tree \n"));
+ return (SYNCML_DM_TARGET_ALREADY_EXISTS);
+ }
+
+ psInsertNode->pcParentOfNode = psNextSiblingStartNode->pcParentOfNode;
+ psNextSiblingStartNode->pcNextSibling = psInsertNode;
+ return (SYNCML_DM_SUCCESS);
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : IsValidSegment
+//
+// DESCRIPTION : This function checks if the URI segment is valid.
+//
+//
+// ARGUMENTS PASSED: UINT8 *pbSegment
+// - Pointer to the URI segment.
+// UINT8 bSegmentLength
+// - Length of the pbSegment.
+// RETURN VALUE : BOOLEAN
+// - It returns TRUE if the URI segment is valid
+// otherwise it returns FALSE.
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+BOOLEAN DMTree::IsValidSegment(CPCHAR pbSegment, UINT8 bSegmentLength)
+{
+ if((pbSegment == NULL) ||
+ (bSegmentLength == 0) ||
+ (bSegmentLength > GetMaxPathSegmentLength()) )
+ return (FALSE);
+
+ while (bSegmentLength != 0)
+ {
+ bSegmentLength--; //decrementing to indicate character processed
+
+ if ((pbSegment[0] == '/') || (pbSegment[0] == '?') || (pbSegment[0] == 0))
+ return FALSE;
+
+ pbSegment++;
+ }
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : DeleteNode
+//
+// DESCRIPTION : This function performs ACL check for children nodes of deleting node
+// This function will use DFS algorithm to traverse the
+// tree.
+//
+// ARGUMENTS PASSED:
+// psDeletingNode - Pointer to the deleting node.
+// pbURI - Pointer the deleting node URI.
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+//
+// PRE-CONDITIONS : psDeletingNode pointer SHOULD NEVER be NULL.
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+
+SYNCML_DM_RET_STATUS_T
+DMTree::CheckDeleteForNode(DMNode *psDeletingNode,
+ CPCHAR pbURI)
+{
+
+ XPL_LOG_DM_TMN_Debug(("Entered DMTree::CheckDeleteForNode \n"));
+
+ if( !psDeletingNode )
+ return SYNCML_DM_FAIL;
+
+ DMBuffer aRelativeBuffer;
+ DMBuffer aAbsoluteBuffer;
+
+ char * abRelativeURI = (char*)aRelativeBuffer.allocate(GetMaxTotalPathLength());
+ if(abRelativeURI == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ char * abAbsoluteURI = (char*)aAbsoluteBuffer.allocate(GetMaxTotalPathLength());
+ if(abAbsoluteURI == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ UINT16 wRelativeURILength = 0;
+ BOOLEAN bFlag = TRUE;
+ DMNode *psTemp = NULL;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ wRelativeURILength = (UINT16)DmSprintf(abRelativeURI, "%s",pbURI);
+
+ psTemp = psDeletingNode;
+ psTemp = psTemp->pcFirstChild;
+
+ if( !psTemp )
+ return dm_stat;
+
+ while(psTemp != psDeletingNode)
+ {
+ if(bFlag == TRUE)
+ {
+ if(psTemp->pcFirstChild)
+ {
+ wRelativeURILength = (UINT16)DmSprintf(abRelativeURI,"%s/%s",abRelativeURI,(CPCHAR)psTemp->abNodeName);
+ psTemp = psTemp->pcFirstChild;
+ }
+ else
+ bFlag = FALSE;
+ }
+ else
+ {
+ DmSprintf(abAbsoluteURI, "%s/%s",abRelativeURI,(CPCHAR)psTemp->abNodeName);
+
+ if(psTemp->pcNextSibling)
+ {
+ psTemp = psTemp->pcNextSibling;
+ bFlag = TRUE;
+ }
+ else
+ {
+ while((abRelativeURI[wRelativeURILength] != SYNCML_DM_FORWARD_SLASH) &&
+ (wRelativeURILength > 0))
+ {
+ --wRelativeURILength;
+ }
+ abRelativeURI[wRelativeURILength] = '\0';
+ psTemp = psTemp->pcParentOfNode;
+ }
+
+ dm_stat = IsValidServer((CPCHAR)abAbsoluteURI,
+ SYNCML_DM_DELETE_ACCESS_TYPE,
+ SYNCML_DM_REQUEST_TYPE_SERVER,
+ FALSE,
+ FALSE);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ break;
+
+ }
+ }
+
+ return dm_stat;
+
+}
+
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : DeleteNode
+//
+// DESCRIPTION : This function will perform deleting of subtree
+//
+// ARGUMENTS PASSED:
+// psDeletingNode - Pointer to the deleting node.
+// pbURI - Pointer the deleting node URI.
+// aDeletedChildren - Vector of deleted children nodes
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+//
+// PRE-CONDITIONS : psDeletingNode pointer SHOULD NEVER be NULL.
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+
+SYNCML_DM_RET_STATUS_T
+DMTree::DeleteNode(DMNode *psDeletingNode,
+ CPCHAR pbURI,
+ DMStringVector & aDeletedChildren)
+{
+ XPL_LOG_DM_TMN_Debug(("Entered DMTree::DeleteNode \n"));
+
+ if( !psDeletingNode )
+ return SYNCML_DM_FAIL;
+
+ DMBuffer aRelativeBuffer;
+ DMBuffer aAbsoluteBuffer;
+
+ char * abRelativeURI = (char*)aRelativeBuffer.allocate(GetMaxTotalPathLength());
+ if(abRelativeURI == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ char * abAbsoluteURI = (char*)aAbsoluteBuffer.allocate(GetMaxTotalPathLength());
+ if(abAbsoluteURI == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ UINT16 wRelativeURILength = 0;
+ BOOLEAN bFlag = TRUE;
+ // TRUE 1st exploration of the node, continue with 1st subnode
+ // FALSE node completely explored, should contine with sibling
+
+ DMNode *psTemp = NULL;
+ DMNode *psRemovingNode = NULL;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ wRelativeURILength = (UINT16)DmSprintf(abRelativeURI, "%s",pbURI);
+ psTemp = psDeletingNode;
+ psTemp = psTemp->pcFirstChild;
+
+ // When the processing of all the nodes is over then psTemp will
+ // become NULL.
+ if (psTemp)
+ {
+ // The processing of subtree is over when psTemp equals to
+ // psDeletingNode
+ while(psTemp != psDeletingNode)
+ {
+ // exploration of the node
+
+ if(bFlag == TRUE)
+ {
+ if(psTemp->pcFirstChild)
+ {
+ // In case if the bOperation is SYNCML_TNM_DELETE_NODE then we
+ // have to build URI. This will become relative URI
+ // because there are childs for current node. For the
+ // Childs it will become the relative URI.
+
+ wRelativeURILength = (UINT16)DmSprintf(abRelativeURI,"%s/%s",abRelativeURI,(CPCHAR)psTemp->abNodeName);
+
+ // Here we are doing depth first search
+ psTemp = psTemp->pcFirstChild;
+ } // End of if (psTemp->pcFirstChild)
+ else
+ {
+ // 1st exploration of current node is finished
+ // go to 2nd exploration of the current node
+ bFlag = FALSE;
+ }
+ } // End of if (bFlag == TRUE)
+ else
+ {
+ // If it has come to this condition means psTemp does NOT
+ // have any childs. So we can process this node and
+ // move to the next sibling if there are any otherwise
+ // we can move the pointer to the Parent.
+
+ DmSprintf(abAbsoluteURI, "%s/%s",abRelativeURI,(CPCHAR)psTemp->abNodeName);
+
+ //exploration of the node, should continue with sibling
+ if(psTemp->pcNextSibling)
+ {
+ psRemovingNode = psTemp;
+ psTemp = psTemp->pcNextSibling;
+ // goto 1st exploration of the sibling (now current)
+ bFlag = TRUE;
+ }
+ else
+ {
+ // exploration of the node, should continue if
+ // there is no sibling
+
+ // If there are no siblings we are moving to parent
+ // so we can remove the last node segment in the Relative
+ // URI because we have process psTemp and curent psTemp
+ // does NOT have any childs and we have to move the pointer
+ // to the parent because there could be some more siblings
+ // on the parent siblings list.
+ while((abRelativeURI[wRelativeURILength] != SYNCML_DM_FORWARD_SLASH) &&
+ (wRelativeURILength > 0))
+ {
+ --wRelativeURILength;
+ }
+ abRelativeURI[wRelativeURILength] = '\0';
+
+ psRemovingNode = psTemp;
+ psTemp = psTemp->pcParentOfNode;
+ }// End of else of if(psTemp->pcNextSibling)
+
+ dm_stat = m_oMDFObj.VerifyDeleteParameters(psRemovingNode,(CPCHAR)abAbsoluteURI);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+#ifdef LOB_SUPPORT
+ LogDeleteForESN(psRemovingNode);
+#endif
+
+ // In this case first we have to call plug-in.Delete
+ // if this plug-in.Delete return SYNCML_DM_SUCCESS then
+ // it will delete the node from the tree.
+ dm_stat = psRemovingNode->Delete(abAbsoluteURI);
+
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ psRemovingNode->pcParentOfNode->pcFirstChild = psRemovingNode->pcNextSibling;
+ delete psRemovingNode;
+ psRemovingNode = NULL;
+ aDeletedChildren.push_back(DMString(abAbsoluteURI));
+
+ m_oACLObj.Delete(abAbsoluteURI);
+ }// End of else of if (bFlag == TRUE)
+ }// End of while (psTemp != psDeletingNode)
+ }// End of if(psTemp)
+
+ // Contains pointer to the parent of the deleting node.
+ DMNode *psParentNode = NULL;
+ // Contains previous node pointer to the directly referenced deleting node.
+ DMNode *psPrevNode = NULL;
+ // Contais pointer to the first child in the deleting node silings list.
+ DMNode *psListNode = NULL;
+
+ psParentNode = psDeletingNode->pcParentOfNode;
+ psListNode = psParentNode->pcFirstChild;
+
+ // This while stores the previous pointer to the deleting node.
+ while(psListNode)
+ {
+ if(psListNode == psDeletingNode)
+ break;
+ psPrevNode = psListNode;
+ psListNode = psListNode->pcNextSibling;
+ }
+
+ if(psListNode == psDeletingNode)
+ {
+ XPL_LOG_DM_TMN_Debug(("Deleting node: %s \n", pbURI));
+ dm_stat = m_oMDFObj.VerifyDeleteParameters(psDeletingNode,(CPCHAR)pbURI);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+#ifdef LOB_SUPPORT
+ LogDeleteForESN(psDeletingNode);
+#endif
+ dm_stat = psDeletingNode->Delete( pbURI );
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ if (psPrevNode != NULL)
+ {
+ // If previous node is not equals to NULL then we will
+ // set the deleting node next pointer to the next node
+ // pointer of previous node
+ psPrevNode->pcNextSibling = psDeletingNode->pcNextSibling;
+ }
+ else
+ {
+ // If the previous node is NOT there mean then deleting
+ // node is first child in the siblings list.
+ psParentNode->pcFirstChild = psDeletingNode->pcNextSibling;
+ }
+ delete psDeletingNode;
+ psDeletingNode = NULL;
+ }
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ if (psParentNode != NULL)
+ {
+ // Set timestamp and version number for parent Node
+ // Use parentURI's URI.
+ psParentNode->wTStamp=XPL_CLK_GetClock();
+ psParentNode->wVerNo ++;
+ }
+#endif
+
+ return dm_stat;
+}
+
+
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : DeleteNodesFromTree
+//
+// DESCRIPTION : This function will delete all the nodes in the tree.
+//
+//
+// ARGUMENTS PASSED:
+//
+//
+// RETURN VALUE :
+//
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+void
+DMTree::DeleteNodesFromTree(DMNode * psStartNode)
+{
+
+
+ BOOLEAN oFlag = TRUE; // This variable is used to explore the child
+
+ DMNode *psCurrent = psStartNode;
+
+ XPL_LOG_DM_TMN_Debug(("Entered DMTree::DeleteNodesFromTree \n"));
+
+ if (psStartNode != m_psRoot)
+ {
+ //detach the node.
+ DetachNodeFromTree(psStartNode);
+ }
+
+ if (psCurrent != NULL)
+ {
+ psCurrent = psCurrent->pcFirstChild;
+ if (psCurrent)
+ {
+ while (psCurrent != psStartNode)
+ {
+ // exploration of the node
+ if (oFlag == TRUE)
+ {
+ if (psCurrent->pcFirstChild)
+ {
+ //Here we are doing depth first search
+ psCurrent = psCurrent->pcFirstChild;
+ }
+ else
+ {
+ // exploration of node is finished
+ // start the exploration of the next node
+ oFlag = FALSE;
+ }
+ }// End of if(oFlag == TRUE)
+ else
+ {
+ //exploration of the node, should continue with sibling
+ if (psCurrent->pcNextSibling)
+ {
+ DMNode* psTemp = psCurrent;
+ psCurrent = psCurrent->pcNextSibling;
+ delete psTemp;
+ psTemp = NULL;
+ // goto 1st exploration of the sibling (now current)
+ oFlag = TRUE;
+ }
+ else
+ {
+ // exploration of the node, should continue if
+ // there is no sibling
+ DMNode* psTemp = psCurrent;
+ psCurrent = psCurrent->pcParentOfNode;
+ delete psTemp;
+ psTemp = NULL;
+ }
+ }// End of else
+ }// End of while(psCurrent)
+
+ //Now delete psStartNode
+ {
+ XPL_LOG_DM_TMN_Debug(("Delete root %s\n", (const char*)psStartNode->abNodeName));
+ delete psStartNode;
+ //Fix the node links for parent nodes etc.
+ }
+ }// End of if(psCurrent)
+ else
+ {
+ XPL_LOG_DM_TMN_Debug(("Delete root %s\n", (const char*)psStartNode->abNodeName));
+ delete psStartNode;
+ //Fix the node links for parent nodes etc.
+ }
+ }// End of if(psCurrent != NULL)
+
+ if (psStartNode==m_psRoot)
+ {
+ m_psRoot = NULL;
+ }
+}
+
+SYNCML_DM_RET_STATUS_T
+DMTree::CheckDeleteForPluginNodes(SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ CPCHAR pbURI,
+ DMNode *psProxyNode,
+ DMStringVector & aChildren)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if (!psProxyNode->isPlugin())
+ return SYNCML_DM_PERMISSION_FAILED;
+
+ PDmtAPIPluginTree tree;
+ dm_stat = ((DMPluginRootNode*)psProxyNode)->GetTree(tree);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ CPCHAR pPluginURI= ((DMPluginRootNode*)psProxyNode)->GetPluginURI(pbURI);
+
+ // Proxy root node should not be deleted
+ if(DmStrlen(pPluginURI) == 0)
+ return SYNCML_DM_PERMISSION_FAILED;
+
+ PDmtNode ptrNode;
+
+ dm_stat = tree->GetNode(pPluginURI, ptrNode);
+ if (dm_stat == SYNCML_DM_SUCCESS)
+ dm_stat = CheckDeleteForPluginNode(eRequestType,pbURI, ptrNode, aChildren, TRUE);
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMTree::CheckDeleteForPluginNode(SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ CPCHAR pbURI,
+ PDmtNode ptrNode,
+ DMStringVector & aChildren,
+ BOOLEAN bIsParent)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ if ( !bIsParent )
+ aChildren.push_back(DMString(pbURI));
+ if (ptrNode->IsLeaf())
+ {
+ dm_stat = IsValidServer( pbURI,
+ SYNCML_DM_DELETE_ACCESS_TYPE,
+ eRequestType,
+ FALSE,
+ TRUE);
+ }
+ else
+ {
+ DMVector<PDmtNode> vecNodes;
+
+ dm_stat = ptrNode->GetChildNodes(vecNodes);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ for (INT32 i = 0; i < vecNodes.size(); i++)
+ {
+ DMString nodeName;
+
+ dm_stat = vecNodes[i]->GetNodeName(nodeName);
+ if( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DMString uri = pbURI;
+ uri += "/";
+ uri += nodeName;
+ dm_stat = CheckDeleteForPluginNode(eRequestType,uri.c_str(),vecNodes[i],aChildren,FALSE);
+ if( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+ }
+ }
+ return dm_stat;
+}
+
+BOOLEAN DMTree::GetPluginURI(CPCHAR szURI, DMString& strURI, DMString& strShortURI ) const
+{
+ if ( !szURI )
+ return FALSE;
+
+ if ( szURI[0] != '.' )
+ strURI = "./";
+ else
+ strURI = NULL;
+
+ strURI += szURI;
+
+ const char* szShortURI = strURI;
+ const char* szQuestionPos = DmStrrchr( szShortURI, SYNCML_DM_FORWARD_SLASH);
+
+ if( !szQuestionPos )
+ szQuestionPos = DmStrrchr( szShortURI, SYNCML_DM_QUESTION_MARK);
+ else
+ szQuestionPos = DmStrrchr( szQuestionPos, SYNCML_DM_QUESTION_MARK);
+
+ if( szQuestionPos )
+ strShortURI.assign( szShortURI, szQuestionPos - szShortURI );
+ else
+ strShortURI = strURI;
+
+ return TRUE;
+}
+
+void DMTree::UnloadArchive(DMNode * psStartNode )
+{
+ ResetOPICache();
+#ifdef LOB_SUPPORT
+ ResetESNCache();
+#endif
+ // unload archive performed in 2 steps:
+ // 1. find all child archives and converting path to them to "skeleton"
+ // 2. unload remaining stuff.
+ DMNode* pNode = psStartNode->pcFirstChild;
+
+ if ( !pNode ){
+ DeleteNodesFromTree( psStartNode );
+ return;
+ }
+
+ // traverse sub-tree
+ while ( pNode != psStartNode ){
+ BOOLEAN bSkipChildren = FALSE;
+ if ( pNode->pArchive ) {
+ bSkipChildren = TRUE;
+ pNode->ConvertPathToSkeleton( psStartNode );
+ }
+
+ if ( !bSkipChildren && pNode->pcFirstChild )
+ pNode = pNode->pcFirstChild;
+ else if ( pNode->pcNextSibling )
+ pNode = pNode->pcNextSibling;
+ else {
+ while ( pNode != psStartNode ) {
+ pNode = pNode->pcParentOfNode;
+
+ if ( pNode != psStartNode && pNode->pcNextSibling ){
+ pNode = pNode->pcNextSibling;
+ break;
+ }
+ }
+ }
+ }
+
+
+ // traverse sub-tree again and free all "non-skeleton" nodes:
+ pNode = psStartNode->pcFirstChild;
+
+ while ( pNode != psStartNode ){
+ BOOLEAN bSkipChildren = FALSE;
+ BOOLEAN bDelete = FALSE;
+ if ( pNode->pArchive ) {
+ bSkipChildren = TRUE;
+ } else if ( !pNode->IsSkeletonNode() )
+ bDelete = TRUE;
+
+ DMNode *pNodeDelete = pNode;
+
+ if ( !bSkipChildren && !bDelete && pNode->pcFirstChild )
+ pNode = pNode->pcFirstChild;
+ else if ( pNode->pcNextSibling )
+ pNode = pNode->pcNextSibling;
+ else{
+ while ( pNode != psStartNode ) {
+ pNode = pNode->pcParentOfNode;
+
+ if ( pNode != psStartNode && pNode->pcNextSibling ){
+ pNode = pNode->pcNextSibling;
+ break;
+ }
+ }
+ }
+
+ if ( bDelete ) {
+ DeleteNodesFromTree( pNodeDelete );
+ }
+ }
+
+ psStartNode->m_nFlags |= DMNode::enum_NodeSkeleton;
+}
+
+BOOLEAN DMTree::LoadSkeletonParentArchive( DMNode* pNode )
+{
+ while ( pNode ) {
+ if ( pNode->pArchive ) {
+ if ( pNode->IsSkeletonNode() )
+ return ( (pNode->pArchive->deserialize(this) == SYNCML_DM_SUCCESS) ? TRUE : FALSE );
+
+ return FALSE; // parent node already loaded
+ }
+ pNode = pNode->pcParentOfNode;
+ }
+ return FALSE;
+}
+
+
+/*
+This function returns fantom node for OPI if confirmed by MDF
+*/
+DMNode* DMTree::GetOPINode( CPCHAR szURI )
+{
+ CPCHAR szID = NULL;
+ SYNCML_DM_ACCESS_TYPE_T wAccessType = 0;
+ SYNCML_DM_FORMAT_T nNodeFormat = 0;
+
+ if ( !m_oMDFObj.VerifyOPINode(szURI, szID, wAccessType, nNodeFormat) )
+ return NULL;
+
+ if ( szID )
+ m_oOPICacheData.metaNodeID = DmAtol(szID);
+
+ if ( m_pOPINode && m_pOPINode->GetPlugin() != m_ptrCacheOPI ){
+ delete m_pOPINode;
+ m_pOPINode = NULL;
+ }
+
+ if ( !m_pOPINode )
+ m_pOPINode = new DMOverlayDataPluginNode( m_ptrCacheOPI );
+
+ if ( m_pOPINode )
+ m_pOPINode->SetNodeAttributes( wAccessType, nNodeFormat );
+
+ return m_pOPINode;
+}
+
+
+void DMTree::ResetOPICache()
+{
+ delete m_pOPINode;
+ m_pOPINode = NULL;
+ m_ptrCacheOPI = NULL;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::OnOPiDelete( CPCHAR szURI )
+{
+ // in case the overlay plugin library is not loaded
+ // to account for edge case where the plugin ini file does not have entry or has
+ // incorrect entry for the overlay plugin library
+ if (m_ptrCacheOPI == NULL) {
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ }
+
+ // notify opi about "data" node to be deleted
+ PDmtAPIPluginTree ptrPluginTree;
+ CPCHAR szPath = m_ptrCacheOPI->GetPath();
+
+ SYNCML_DM_RET_STATUS_T dm_stat = m_ptrCacheOPI->GetTree(szPath, ptrPluginTree);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if ( ptrPluginTree != NULL )
+ {
+ dm_stat = ptrPluginTree->OnDelete( szURI );
+
+ return dm_stat;
+ }
+
+ return SYNCML_DM_FAIL; // unlikely case, since if tree is null, plug-in should return an error
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::OnOPiAdd( CPCHAR szURI, DmtOverlayPluginData& data )
+{
+
+ // in case the overlay plugin library is not loaded
+ // to account for edge case where the plugin ini file does not have entry or has
+ // incorrect entry for the overlay plugin library
+ if (m_ptrCacheOPI == NULL) {
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ }
+
+ // notify opi about "data" node to be deleted
+ PDmtAPIPluginTree ptrPluginTree;
+ CPCHAR szPath = m_ptrCacheOPI->GetPath();
+
+ SYNCML_DM_RET_STATUS_T dm_stat = m_ptrCacheOPI->GetTree(szPath, ptrPluginTree);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if ( ptrPluginTree != NULL )
+ {
+ dm_stat = ptrPluginTree->OnAdd( szURI, data );
+
+ return dm_stat;
+ }
+
+ return SYNCML_DM_FAIL; // unlikely case, since if tree is null, plug-in should return an error
+}
+
+
+void DMTree::CheckOpiSync( DMNode* pNode, char* szURI, const char* szLastSegment )
+{
+ if ( pNode->opiSyncMayNeeded() )
+ {
+ // sync state unknown - mdf data required
+ // restore URI
+ char* s = szURI;
+
+ while ( s < szLastSegment )
+ {
+ if ( *s == 0 )
+ *s = SYNCML_DM_FORWARD_SLASH;
+ s++;
+ }
+
+ if ( !m_oMDFObj.IsOPiDataParent( szURI ) )
+ {
+ pNode->addFlags( DMNode::enum_NodeOPISyncNotNeeded);
+ return;
+ }
+ pNode->addFlags( DMNode::enum_NodeOPISyncNeeded);
+ }
+
+ if ( pNode->opiInSync() )
+ return; // up-to-date
+
+ // perform sync
+ OpiSync( pNode, szURI );
+
+ pNode->addFlags( DMNode::enum_NodeOPISyncUptodate );
+}
+
+void DMTree::OpiSync( DMNode* pNode, const char* szURI )
+{
+ // in case the overlay plugin library is not loaded
+ // to account for edge case where the plugin ini file does not have entry or has
+ // incorrect entry for the overlay plugin library
+ if (m_ptrCacheOPI == NULL) {
+ return;
+ }
+
+ // get tree
+ PDmtAPIPluginTree ptrPluginTree;
+ CPCHAR szPath = m_ptrCacheOPI->GetPath();
+
+ SYNCML_DM_RET_STATUS_T dm_stat = m_ptrCacheOPI->GetTree(szPath, ptrPluginTree);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS || ptrPluginTree == NULL )
+ return ;
+
+ // fill in sync data
+ DMVector<DmtOverlayPluginSyncData> data;
+
+ DMNode* pChild = pNode->pcFirstChild;
+
+ while ( pChild )
+ {
+ data.push_back(DmtOverlayPluginSyncData());
+
+ DmtOverlayPluginSyncData& item = data[data.size()-1];
+
+ item.m_nStatus = DmtOverlayPluginSyncData::enum_StatusUnchanged;
+ item.m_strNodeName = pChild->abNodeName;
+
+ if ( pChild->getOverlayPIData() )
+ item.m_oData = *pChild->getOverlayPIData();
+
+ pChild = pChild->pcNextSibling;
+ }
+
+ dm_stat = ptrPluginTree->Synchronize( szURI, data );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return;
+
+ for ( int i = 0; i < data.size(); i++ )
+ {
+ if ( data[i].m_nStatus == DmtOverlayPluginSyncData::enum_StatusUnchanged )
+ continue;
+
+ if ( data[i].m_nStatus == DmtOverlayPluginSyncData::enum_StatusAdded )
+ {
+ // create a node
+ DMNode* pNewNode = new DMOverlayPINode( m_ptrCacheOPI, data[i].m_strNodeName,
+ data[i].m_oData );
+
+ if ( !pNewNode )
+ return; // sync failed
+
+ pNewNode->pcParentOfNode = pNode;
+
+ if(pNode->pcFirstChild)
+ {
+ // if the current addind node is NOT the first child of the
+ // parent then insert the node in the siblings list.
+ InsertNodeIntoNextSiblingsList(pNode->pcFirstChild,pNewNode);
+ }
+ else
+ {
+ // if the current adding node is the first child of the
+ // parent then assign adding node pointer tp parent first
+ // child pointer.
+ pNode->pcFirstChild = pNewNode;;
+ }
+ }
+
+ if ( data[i].m_nStatus == DmtOverlayPluginSyncData::enum_StatusDeleted )
+ { // find and delete the node
+ pChild = pNode->pcFirstChild;
+
+ while ( pChild )
+ {
+ if ( pChild->abNodeName == data[i].m_strNodeName )
+ {
+ DeleteNodesFromTree( pChild );
+ break;
+ }
+
+ pChild = pChild->pcNextSibling;
+ }
+
+ }
+ }
+}
+#ifdef LOB_SUPPORT
+void DMTree::ResetESNCache()
+{
+ m_pESN = NULL;
+ m_strESNPath= NULL;
+}
+void DMTree::SetESNCache( CPCHAR szURI , DMNode* pESN)
+{
+ m_strESNPath = szURI;
+ m_pESN = pESN;
+}
+DMNode* DMTree::GetESN( CPCHAR szURI )
+{
+ if(m_pESN != NULL)
+ {
+ if (DmStrcmp((CPCHAR)m_strESNPath.c_str(), szURI) == 0 )
+ return m_pESN;
+ }
+ return NULL;
+}
+void DMTree::RemoveESNCache(CPCHAR szURI)
+{
+ if(m_pESN != NULL)
+ { if (DmStrncmp((CPCHAR)m_strESNPath.c_str(), szURI, DmStrlen(szURI)) == 0 )
+ ResetESNCache();
+ }
+}
+//------------------------------------------------------------------------
+//
+// FUNCTION : LogDeleteForESN
+//
+// DESCRIPTION : This function logs delete command for an ESN.
+//
+//
+// ARGUMENTS PASSED: DMNode - node to be removed
+
+//
+// RETURN VALUE : error code if failed, "DM_SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+void DMTree::LogDeleteForESN(DMNode *psDeletingNode)
+{
+ BOOLEAN IsESN = psDeletingNode->IsESN();
+ if(IsESN)
+ {
+ DMDefaultESN *tempESN = reinterpret_cast< DMDefaultESN *>(psDeletingNode);
+ SyncML_DM_Archive * pArchive=GetArchive(psDeletingNode);
+ if(pArchive != NULL)
+ { SyncML_Commit_Log *commitLog = pArchive->GetCommitLogHandler();
+ if(commitLog != NULL)
+ {
+ DMString targetFileName = tempESN->GetOriginalInternalFileName();
+ if(targetFileName != NULL)
+ commitLog->logCommand(SYNCML_DM_DELETE, NULL, targetFileName.c_str());
+ }
+ }
+ }
+}
+#endif
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : SetOPINodeData
+//
+// DESCRIPTION : This function sets Overlay plug-in data for multi-node
+//
+//
+// ARGUMENTS PASSED: szURI - node uri
+// oData - new data
+//
+// RETURN VALUE : error code if failed, "DM_SUCCESS" otherwise
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::SetOPINodeData( CPCHAR szURI, const DmtOverlayPluginData& oData )
+{
+ DMNode* pNode = FindNodeByURI(szURI);
+
+ if ( !pNode || !pNode->IsOverlayPIData() || !pNode->getOverlayPIData() )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ *pNode->getOverlayPIData() = oData;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : CheckForIndirectUpdates
+// DESCRIPTION : This function checks all child/depend nodes
+// and for all of them ponting to current uri
+// issues "indirect" update
+// ARGUMENTS PASSED: szURI - currently updated uri
+// asChildDepend - list of "child/depend" constraints for
+// parent nodes
+// inNode - currently updated node
+// RETURN VALUE : void
+// PRE-CONDITIONS : called from tree update function
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+void DMTree::CheckForIndirectUpdates( CPCHAR szURI, const DMMetaPCharVector& asChildDepend, DMNode* inNode )
+{
+ // check if provided nodes
+ for ( int i = 0; i < asChildDepend.size(); i++ )
+ {
+ DMToken oChild(TRUE,asChildDepend[i],SYNCML_DM_COMMA);
+
+ if ( !oChild.getBuffer() )
+ return ; //low memory condition
+
+ const char* szChild = oChild.nextSegment();
+
+ while ( szChild )
+ {
+ // if ( m_oPluginManager.IsCommitPluginMounted(szChild) == TRUE )
+ CheckURIForIndirectUpdates( szChild, szURI, inNode);
+
+ szChild = oChild.nextSegment();
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : CheckURIForIndirectUpdates
+// DESCRIPTION : This function checks one child/depend uri
+// and if it ponts to the current uri
+// issues "indirect" update
+// ARGUMENTS PASSED: szURI - currently updated uri
+// szChild - "child/depend" constraint
+// inNode - currently updated node
+// RETURN VALUE : void
+// PRE-CONDITIONS : called from CheckForIndirectUpdates function
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+void DMTree::CheckURIForIndirectUpdates( CPCHAR szChild, CPCHAR szURI, DMNode* inNode )
+{
+ // node can have '*' inside, so we have to traverse all posible nodes to look for corresponding values
+ CPCHAR szStarPos = DmStrstr(szChild, "*");
+ if ( !szStarPos )
+ {
+ DMGetData oReturnData;
+ SYNCML_DM_RET_STATUS_T res = Get(szChild, oReturnData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( res == SYNCML_DM_SUCCESS && DmStrstr( szURI, oReturnData.getCharData() ) != NULL )
+ {
+ LogEvent(SYNCML_DM_EVENT_INDIRECT, szChild);
+ }
+
+ return;
+ }
+
+ if ( szStarPos == szChild )
+ return; // incorect uri - '*' first symbol
+
+ DMString strParent( szChild, szStarPos-szChild-1);
+
+ DMGetData oData;
+ SYNCML_DM_RET_STATUS_T res = Get(strParent, oData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( res != SYNCML_DM_SUCCESS )
+ return; // node probably does not exist
+
+ DMToken oChild(FALSE, oData.getCharData(), '/' );
+
+ const char* szNextChild = oChild.nextSegment();
+
+ while ( szNextChild )
+ {
+ DMString strURI( szChild, szStarPos-szChild); // 'parent' with '/' at the end
+ strURI += szNextChild;
+ strURI += (szStarPos+1); // the rest after '*'
+
+ CheckURIForIndirectUpdates( strURI, szURI, inNode );
+
+ szNextChild = oChild.nextSegment();
+ }
+
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : IsUriEnabled
+// DESCRIPTION : This function checks if URI is blocked
+// ARGUMENTS PASSED: szURI - currently updated uri
+// RETURN VALUE : TRUE/FALSE
+// PRE-CONDITIONS : called from Add/Replace/Delete/Get functions
+// POST-CONDITIONS : none
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+BOOLEAN
+DMTree::IsUriEnabled(CPCHAR szURI) const
+{
+ BOOLEAN bIsEnabled;
+ bIsEnabled = m_oTreeMountObj.IsMountPointEnabled(szURI);
+ if ( bIsEnabled == FALSE )
+ return FALSE;
+
+ bIsEnabled = m_oPluginManager.IsMountPointEnabled(szURI);
+ if ( bIsEnabled == FALSE )
+ return FALSE;
+
+ if ( DmIsDMAccNodePath(szURI) == SYNCML_DM_FEATURE_NOT_SUPPORTED )
+ return FALSE;
+
+
+ if ( szURI!=NULL && DmStrstr( szURI, "/DevDetail/Ext/OMA_PoC" )!=NULL )
+ {
+ CPCHAR bit = ::XPL_DM_GetEnv(SYNCML_DM_FEATURE_ID_POC_PROVISION_VIA_OMADM);
+ if (bit!=NULL && bit[0]=='0' && bit[1]==0)
+ {
+ const DMString & sessionName = GetServerId();
+ DMString dmProfleNodeName;
+ if ((sessionName != "DM_OMACP") && (sessionName != "localhost") &&
+ ((DMTree*)this)->GetParentOfKeyValue (sessionName,
+ ::XPL_DM_GetEnv( SYNCML_DM_NODENAME_SERVERID ),
+ ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH ),
+ dmProfleNodeName))
+ {
+ return FALSE;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+BOOLEAN
+DMTree::VerifyArchiveReadAccess(CPCHAR szURI)
+{
+ BOOLEAN result = TRUE;
+ SyncML_DM_Archive* archive = this->GetArchiver().getArchiveByURI(szURI);
+ if (archive != NULL) {
+ result = archive->verifyPermission(XPL_FS_RDONLY_MODE);
+ }
+ return result;
+}
+
+BOOLEAN
+DMTree::VerifyArchiveWriteAccess(CPCHAR szURI)
+{
+ BOOLEAN result = TRUE;
+ SyncML_DM_Archive* archive = this->GetArchiver().getArchiveByURI(szURI);
+ if (archive != NULL) {
+ result = archive->verifyPermission(XPL_FS_RDWR_MODE);
+ }
+ return result;
+}
diff --git a/engine/dmlib/dmengine/dm_tnm/src/dm_tree_class_public.cc b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_class_public.cc
new file mode 100644
index 0000000..22e72aa
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_class_public.cc
@@ -0,0 +1,3988 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//------------------------------------------------------------------------
+//
+// Module Name: dm_tree_node_class_public.cc
+//
+// General Description: Contains the implementations of the Public
+// methods of DMNTree class.
+//------------------------------------------------------------------------
+
+#include "dmprofile.h"
+#include "dm_tree_util.h"
+#include "dmLockingHelper.h"
+#include "dm_tree_class.H"
+#include "SyncML_DM_Archiver.H"
+#include "dm_tree_default_leaf_node_class.H"
+#ifdef LOB_SUPPORT
+#include "dm_tree_default_ESN_class.H"
+#endif
+#include "dm_tree_default_interior_node_class.H"
+#include "dm_uri_utils.h"
+#include "xpl_Logger.h"
+#include "dmtTreeImpl.hpp"
+#include "dm_tree_plugin_root_node_class.H"
+#include "dm_tree_plugin_util.H"
+#include "dmtoken.h"
+#include "xpl_dm_Manager.h"
+
+//------------------------------------------------------------------------
+// LOCAL VARIABLES
+//------------------------------------------------------------------------
+const UINT8 *DMTree::m_pDataFormatTable[] =
+{
+ (UINT8 *)"null", // SYNCML_DM_FORMAT_NULL
+ (UINT8 *)"chr", //SYNCML_DM_FORMAT_CHR,
+ (UINT8 *)"int", //SYNCML_DM_FORMAT_INT,
+ (UINT8 *)"bool", //SYNCML_DM_FORMAT_BOOL,
+ (UINT8 *)"bin", //SYNCML_DM_FORMAT_BIN,
+ (UINT8 *)"node", //SYNCML_DM_FORMAT_NODE,
+ (UINT8 *)"b64", //SYNCML_DM_FORMAT_B64,
+ (UINT8 *)"xml", //SYNCML_DM_FORMAT_XML,
+ (UINT8 *)"date", //SYNCML_DM_FORMAT_DATE,
+ (UINT8 *)"test", //SYNCML_DM_FORMAT_TEST,
+ (UINT8 *)"time", //SYNCML_DM_FORMAT_TIME,
+ (UINT8 *)"float",//SYNCML_DM_FORMAT_FLOAT,
+ (UINT8 *)NULL, //SYNCML_DM_FORMAT_INVALID
+};
+
+//------------------------------------------------------------------------
+// FUNCTION : LogEvent
+// DESCRIPTION : Logging the DELETE command which was executed successfully
+// ARGUMENTS PASSED : pbURI - updated node
+// aDeletedChildren - deleted children nodes
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// SYNCML_DM_SUCCESS or SYNCML_DM_FAIL if some
+// failure in logCommand occured
+// PRE-CONDITIONS : The command was successful
+// Tree was updated accordingly
+// POST-CONDITIONS : the Archiver validates the log and will use it
+// while serializing the tree
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T
+DMTree::LogEvent(CPCHAR pbURI, const DMStringVector & aDeletedChildren)
+{
+ SyncML_DM_Archive * pArchive = m_oArchiver.getArchiveByURI(pbURI);
+
+ if (pArchive == NULL)
+ return SYNCML_DM_FAIL;
+
+ pArchive->setDirty(TRUE);
+
+ return m_oEvtObj.OnNodeDeleted(pArchive, pbURI, aDeletedChildren);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : LogEvent
+// DESCRIPTION : Logging the command which was executed
+// successfully in the log file
+// sets the command type, URI and pointer to a copy
+// of the node and calls the logCommand method of
+// archiver
+// ARGUMENTS PASSED : commandType ADD/REPLACE/DELETE/RENAME/INDIRECT UPDATE
+// pbURI - updated node
+// szNewName - new name
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// SYNCML_DM_SUCCESS or SYNCML_DM_FAIL if some
+// failure in logCommand occured
+// PRE-CONDITIONS : The command was successful
+// Tree was updated accordingly
+// POST-CONDITIONS : the Archiver validates the log and will use it
+// while serializing the tree
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T
+DMTree::LogEvent(SYNCML_DM_EVENT_ACTION_T eEvent,
+ CPCHAR pbURI,
+ CPCHAR szNewName)
+{
+ SyncML_DM_Archive * pArchive = m_oArchiver.getArchiveByURI(pbURI);
+
+ if (pArchive == NULL)
+ return SYNCML_DM_FAIL;
+
+ pArchive->setDirty(TRUE);
+
+ return m_oEvtObj.OnNodeChanged( pArchive, pbURI, eEvent, szNewName );
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : LogESNCommandForArchiver
+// DESCRIPTION : Logging the command which was executed
+// successfully in the log file
+// sets the command type, URI and pointer to a copy
+// of the node and calls the logCommand method of
+// archiver
+// ARGUMENTS PASSED : pbURI - updated node
+// inNode - updated node
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// SYNCML_DM_SUCCESS or SYNCML_DM_FAIL if some
+// failure in logCommand occured
+// PRE-CONDITIONS : The command was successful
+// Tree was updated accordingly
+// POST-CONDITIONS : the Archiver validates the log and will use it
+// while serializing the tree
+//------------------------------------------------------------------------
+#ifdef LOB_SUPPORT
+SYNCML_DM_RET_STATUS_T
+DMTree::LogESNCommandForArchiver(CPCHAR pbURI, DMNode * inNode)
+{
+ SyncML_DM_Archive * pArchive = m_oArchiver.getArchiveByURI(pbURI);
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+
+ if (pArchive == NULL)
+ return SYNCML_DM_FAIL;
+
+ DMDefaultESN *tempESN = reinterpret_cast< DMDefaultESN *>(inNode);;
+ SyncML_Commit_Log *commitLog = pArchive->GetCommitLogHandler();
+ if(commitLog != NULL && tempESN->NeedLogging())
+ retStatus = commitLog->logCommand(SYNCML_DM_REPLACE, tempESN->GetOriginalInternalFileName() , tempESN->GetInternalStorageFileName());
+
+ return retStatus;
+}
+#endif
+
+SYNCML_DM_RET_STATUS_T DMTree::ConvertFormat(SYNCML_DM_FORMAT_T format,
+ DMString & strFormat)
+{
+ strFormat = format >= sizeof(m_pDataFormatTable)/sizeof(int) ?
+ NULL : (CPCHAR)m_pDataFormatTable[format];
+
+ if ( strFormat == NULL && format != SYNCML_DM_FORMAT_NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ else
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_FORMAT_T DMTree::ConvertFormatStr(const DMString& formatStr)
+{
+ SYNCML_DM_FORMAT_T bFormat = SYNCML_DM_FORMAT_NODE;
+
+ if (formatStr == "chr" || formatStr == "string")
+ {
+ bFormat = SYNCML_DM_FORMAT_CHR;
+ } else
+ if (formatStr == "int" )
+ {
+ bFormat = SYNCML_DM_FORMAT_INT;
+ } else
+ if (formatStr == "bool" )
+ {
+ bFormat = SYNCML_DM_FORMAT_BOOL;
+ } else
+ if (formatStr == "b64" )
+ {
+ bFormat = SYNCML_DM_FORMAT_B64;
+ } else
+ if (formatStr == "bin" )
+ {
+ bFormat = SYNCML_DM_FORMAT_BIN;
+ } else
+ if (formatStr == "node" )
+ {
+ bFormat = SYNCML_DM_FORMAT_NODE;
+ } else
+ if (formatStr == "xml" )
+ {
+ bFormat = SYNCML_DM_FORMAT_XML;
+ } else
+ if (formatStr == "date" )
+ {
+ bFormat = SYNCML_DM_FORMAT_DATE;
+ } else
+ if (formatStr == "time" )
+ {
+ bFormat = SYNCML_DM_FORMAT_TIME;
+ } else
+ if (formatStr == "float" )
+ {
+ bFormat = SYNCML_DM_FORMAT_FLOAT;
+ } else
+ if (formatStr == "null" )
+ {
+ bFormat = SYNCML_DM_FORMAT_NULL;
+ }
+ else
+ {
+ bFormat = SYNCML_DM_FORMAT_CHR; //Cover unknown Meta data format
+ }
+
+ return bFormat;
+}
+
+BOOLEAN DMTree::ParentExistsForPluginNode(CPCHAR pURI, DMNode *psNode) const
+{
+ DMString strParentURI = pURI, strLastSegment;
+
+ if ( !GetLastSegmentOfURI(strParentURI, strLastSegment) )
+ return FALSE;
+
+ if ( strParentURI == "." )
+ return TRUE;
+
+ DMGetData getData;
+
+ if (psNode->Get(strParentURI, getData) != SYNCML_DM_SUCCESS)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+void DMTree::DetachNodeFromTree(DMNode *psDeletingNode)
+{
+ DMNode *psParentNode = NULL;
+ DMNode *psPrevNode = NULL;
+ DMNode *psListNode = NULL;
+
+ psParentNode = psDeletingNode->pcParentOfNode;
+ psListNode = psParentNode->pcFirstChild;
+
+ // This while stores the previous pointer to the deleting node.
+ while(psListNode)
+ {
+ if(psListNode == psDeletingNode)
+ break;
+ psPrevNode = psListNode;
+ psListNode = psListNode->pcNextSibling;
+ }
+
+ if(psListNode == psDeletingNode)
+ {
+ if(psPrevNode != NULL)
+ {
+ // If previous node is not equals to NULL then we will
+ // set the deleting node next pointer to the next node
+ // pointer of previous node
+ psPrevNode->pcNextSibling = psDeletingNode->pcNextSibling;
+ }
+ else
+ {
+ // If the previous node is NOT there mean then deleting
+ // node is first child in the siblings list.
+ psParentNode->pcFirstChild = psDeletingNode->pcNextSibling;
+ }
+ psDeletingNode->pcParentOfNode=NULL;
+ psDeletingNode->pcNextSibling=NULL;
+
+ }// End of if(psListNode == psDeletingNode)
+
+}
+
+// DMTree constructor
+DMTree::DMTree()
+ : m_init_status( SYNCML_DM_FAIL ),
+ m_psRoot( NULL ),
+ m_wMaxDepth( SYNCML_DM_URI_MAX_DEPTH ),
+ m_wMaxTotLen( SYNCML_DM_URI_MAX_TOTAL_LENGTH ),
+ m_wMaxSegLen( SYNCML_DM_URI_MAX_SEGMENT_LENGTH ),
+ m_nRefCount( 0 ),
+ m_currentTime( 0 )
+{
+ m_strPrincipal = "";
+
+ m_oOPICacheData.metaNodeID = -1;
+ m_pOPINode = NULL;
+ m_bVersion_1_2 = FALSE;
+#ifdef LOB_SUPPORT
+ m_pESN = NULL;
+ m_strESNPath= "";
+#endif
+}
+
+// DMTree destructor
+DMTree::~DMTree()
+{
+ DeInit(TRUE);
+}
+
+/*==================================================================================================
+FUNCTION : DMTree::SetServerId
+
+DESCRIPTION : This function will set the server Id.
+ARGUMENT PASSED : p_ServerId
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS if success,
+ SYNCML_DM_FAIL if allocating memory failed.
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMTree::SetServerId (CPCHAR p_ServerId)
+{
+ m_strPrincipal = p_ServerId;
+ return SYNCML_DM_SUCCESS;
+}
+
+/*==================================================================================================
+FUNCTION : DMTree::SetConRef
+
+DESCRIPTION : This function will set the ConRef
+ARGUMENT PASSED : p_ConRef
+OUTPUT PARAMETER:
+RETURN VALUE : SYNCML_DM_SUCCESS if success,
+ SYNCML_DM_FAIL if allocating memory failed.
+IMPORTANT NOTES :
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMTree::SetConRef (CPCHAR p_ConRef)
+{
+ //m_strPrincipal = p_ConRef;
+ m_strConRef = p_ConRef;
+ return SYNCML_DM_SUCCESS;
+}
+
+BOOLEAN DMTree::IsInitialized() const
+{
+ return (SYNCML_DM_SUCCESS == m_init_status);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Init
+// DESCRIPTION : The UA calls this method once the syncml task is up
+// The DMTNM initializes it's data members and also
+// creates a timer
+// ARGUMENTS PASSED: None
+// RETURN VALUE : void
+// PRE-CONDITIONS : syncml task is ready
+// POST-CONDITIONS : the Tree obtains a timer handle and resets it's flags
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::Init()
+{
+#ifndef DM_NO_LOCKING
+ DMSingleLock oLock( m_csInitLock );
+#endif
+
+ XPL_LOG_Startup();
+
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_SUCCESS;
+
+ if ( 0 == m_nRefCount )
+ {
+ result = InternalInit();
+ m_init_status = result;
+ }
+
+ if( SYNCML_DM_SUCCESS == result )
+ {
+ m_nRefCount++;
+ DM_MEMORY_STATISTICS_WRITE("Initialize\n");
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Error(("Initializing failed\n"));
+
+ // DM: reverting to uninitialized state partially initialized object
+ InternalDeInit();
+ }
+
+ return result;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::InternalInit()
+{
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_SUCCESS;
+
+ for (;;)
+ {
+ DM_PROFILE( "DmMnInit" );
+
+
+ if( IsInitialized() )
+ {
+ XPL_LOG_DM_TMN_Error(("Already initialized\n"));
+ result = SYNCML_DM_FAIL;
+ break;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("Initializing XPL...\n"));
+ result = XPL_DM_Init();
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ XPL_LOG_DM_TMN_Debug(("Initializing environment...\n"));
+ if( !m_oEnv.Init() )
+ {
+ result = SYNCML_DM_FAIL;
+ break;
+ }
+
+ CPCHAR dm_ver = XPL_DM_GetEnv(SYNCML_DM_VERSION);
+ m_bVersion_1_2 = ( dm_ver && DmStrcmp(dm_ver,SYNCML_REP_PROTOCOL_VERSION_1_2) == 0 );
+
+ XPL_LOG_DM_TMN_Debug(("DM version is %s\nMounting tree...\n", m_bVersion_1_2 ? "1.2" : "1.1.2" ));
+ DM_PERFORMANCE(DM_INITIALIZE_MOUNT);
+ result = m_oTreeMountObj.MountTree( &m_oEnv, this );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ XPL_LOG_DM_TMN_Debug(("Initializing MDF and Plugin Manager...\n"));
+ DM_PERFORMANCE(DM_INITIALIZE_MDF);
+ result = m_oMDFObj.Init( &m_oEnv, this );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ DM_PERFORMANCE(DM_INITIALIZE_PLUGIN);
+ result = m_oPluginManager.Init( &m_oEnv, this );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ XPL_LOG_DM_TMN_Debug(("Initializing Archiver and File Manager...\n"));
+ DM_PERFORMANCE(DM_INITIALIZE_ACRHIVER);
+ result = m_oArchiver.initArchives( &m_oEnv, this );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ DM_PERFORMANCE(DM_INITIALIZE_FILE);
+ result = m_oFileManager.Init( this );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ XPL_LOG_DM_TMN_Debug(("Initializing Lock Context Manager and ACL...\n"));
+ DM_PERFORMANCE(DM_INITIALIZE_LOCK);
+ result = m_oLockContextManager.Init( this, &m_oFileManager );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ DM_PERFORMANCE(DM_INITIALIZE_ACL);
+ result = m_oACLObj.Init( &m_oEnv, this );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ DM_PERFORMANCE(DM_INITIALIZE_EVENT);
+ result = m_oEvtObj.Init( &m_oEnv, this );
+ if( SYNCML_DM_SUCCESS != result ) break;
+
+ DM_PERFORMANCE(DM_INITIALIZE_LOAD);
+ // LoadMaxValues();
+
+ if ( DmGetMemFailedFlag() ) // device runs out of memory
+ {
+ result = SYNCML_DM_DEVICE_FULL;
+ break;
+ }
+
+ result = SYNCML_DM_SUCCESS;
+ break;
+ }
+
+ if( SYNCML_DM_SUCCESS == result )
+ {
+ XPL_LOG_DM_TMN_Debug(("Initialized successfully\n"));
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Error(( "Initialization faled\n" ));
+ }
+
+ return result;
+}
+
+UINT16 DMTree::GetMaxPathDepth() const
+{
+ return m_wMaxDepth;
+}
+
+UINT16 DMTree::GetMaxTotalPathLength() const
+{
+ return m_wMaxTotLen;
+}
+
+UINT16 DMTree::GetMaxPathSegmentLength() const
+{
+ return m_wMaxSegLen;
+}
+
+void DMTree::LoadMaxValues()
+{
+ // special case for some nodes
+ int nLock = 0;
+ {
+ DMLockingHelper oLock( 0, "./DevDetail/URI", "localhost", SYNCML_DM_LOCK_TYPE_SHARED, FALSE );
+ nLock = oLock.GetID();
+
+ if ( oLock.IsLockedSuccessfully() )
+ {
+ DMNode* pNode = FindNodeByURI("./DevDetail/URI/MaxDepth");
+
+ m_wMaxDepth = readOneWordFromTree(pNode, SYNCML_DM_URI_MAX_DEPTH);
+
+ pNode = FindNodeByURI("./DevDetail/URI/MaxTotLen");
+
+ m_wMaxTotLen = readOneWordFromTree(pNode, SYNCML_DM_URI_MAX_TOTAL_LENGTH);
+
+ pNode = FindNodeByURI("./DevDetail/URI/MaxSegLen");
+
+ m_wMaxSegLen = readOneWordFromTree(pNode, SYNCML_DM_URI_MAX_SEGMENT_LENGTH);
+
+ }
+ }
+
+ ReleaseLock( nLock );
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::DeInit(BOOLEAN bIsDestructor)
+{
+#ifndef DM_NO_LOCKING
+ DMSingleLock oLock( m_csInitLock );
+#endif
+
+ if ( m_nRefCount < 1 )
+ {
+ if (bIsDestructor == FALSE)
+ {
+ XPL_LOG_DM_TMN_Error(("Invalid ref count = %i\n", m_nRefCount ));
+ }
+ return SYNCML_DM_FAIL;
+
+ }
+
+ m_nRefCount--;
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing, ref count = %i\n", m_nRefCount ));
+
+ if ( ( 0 == m_nRefCount ) && IsInitialized() )
+ {
+ InternalDeInit();
+
+ DM_MEMORY_STATISTICS_REPORT_LEAKS
+ }
+
+ XPL_LOG_Shutdown();
+
+ return SYNCML_DM_SUCCESS;
+}
+
+void DMTree::InternalDeInit()
+{
+ XPL_LOG_DM_TMN_Debug(("Uninitializing, releasing locks...\n" ));
+ m_oLockContextManager.ReleaseAll();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing ACL...\n" ));
+ m_oACLObj.DeInit();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing lock context manager...\n" ));
+ m_oLockContextManager.Destroy();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing file manager...\n" ));
+ m_oFileManager.DeInit();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing Archiver...\n" ));
+ m_oArchiver.deinitArchives();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing, reseting cache...\n" ));
+#ifdef LOB_SUPPORT
+ ResetESNCache();
+#endif
+ ResetOPICache();
+ m_oOPICacheData.aPD.clear();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing, deleting nodes...\n" ));
+ if( m_psRoot )
+ {
+ DeleteNodesFromTree( m_psRoot );
+ m_psRoot = NULL;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing Plugin manager...\n" ));
+ m_oPluginManager.DeInit();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing MDF...\n" ));
+ m_oMDFObj.DeInit();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing: unmounting trees...\n" ));
+ m_oTreeMountObj.UnMountTree();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing environment...\n" ));
+ m_oEnv.Done();
+
+ XPL_LOG_DM_TMN_Debug(("Uninitializing XPL...\n" ));
+ XPL_DM_DeInit();
+
+ m_strPrincipal = "";
+ m_init_status = SYNCML_DM_FAIL;
+ XPL_LOG_DM_TMN_Debug(("Uninitializing : succeeded\n" ));
+
+}
+
+// force to unload all loaded sub-trees and plug-ins
+SYNCML_DM_RET_STATUS_T DMTree::Flush()
+{
+ XPL_LOG_DM_TMN_Debug(("DMTree::Flush\n"));
+ ResetOPICache();
+ m_oOPICacheData.aPD.clear();
+
+ if( m_psRoot )
+ {
+ DeleteNodesFromTree( m_psRoot );
+ }
+
+ m_oPluginManager.DeInit();
+ return m_oPluginManager.Init( &m_oEnv, this );
+}
+
+void DMTree::GetTreeMountEntry (CPCHAR &p_Uri, CPCHAR& p_TreePath, UINT16 index) const
+{
+ m_oTreeMountObj.GetTreeMountEntry( p_Uri, p_TreePath, index );
+}
+
+DMPluginManager & DMTree::GetPluginManager()
+{
+ return m_oPluginManager;
+}
+
+SyncML_DM_Archiver& DMTree::GetArchiver()
+{
+ return m_oArchiver;
+}
+
+DMLockContextManager& DMTree::GetLockContextManager()
+{
+ return m_oLockContextManager;
+}
+
+DMSubscriptionManager & DMTree::GetSubscriptionManager()
+ {
+ return m_oEvtObj;
+ }
+
+SYNCML_DM_RET_STATUS_T DMTree::ReleaseLock( INT32 nLockID ,SYNCML_DM_COMMAND_T command /* = SYNCML_DM_RELEASE*/)
+{
+ return m_oLockContextManager.ReleaseID( nLockID, command );
+}
+
+
+void DMTree::CheckMemoryAging()
+{
+ m_oLockContextManager.CheckMemoryAging();
+}
+
+
+SYNCML_DM_RET_STATUS_T DMTree::SaveFile(SYNCML_DM_FILE_TYPE_T eFileType)
+{
+ if ( eFileType == SYNCML_DM_FILE_ACL )
+ return m_oACLObj.Serialize();
+ else
+ return m_oEvtObj.Serialize();
+
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::RevertFile(SYNCML_DM_FILE_TYPE_T eFileType)
+{
+ if ( eFileType == SYNCML_DM_FILE_ACL )
+ return m_oACLObj.Revert();
+ else
+ return m_oEvtObj.Revert();
+}
+
+
+CPCHAR DMTree::GetWritableFileSystemFullPath( DMString & path )
+{
+ return m_oEnv.GetWFSFullPath( NULL, path );
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMTree::SetACL(CPCHAR szURI)
+{
+ //This variable stores the length of the ACL
+ UINT16 totalLength = 0;
+ UINT16 length = 0;
+ DMBuffer oACL;
+
+ length = m_strPrincipal.length();
+
+ totalLength = ADD_CMD_LENGTH_IN_ACL + length + 1 +
+ GET_CMD_LENGTH_IN_ACL + length + 1 +
+ REPLACE_CMD_LENGTH_IN_ACL + length + 1 +
+ DELETE_CMD_LENGTH_IN_ACL + length + 1 +
+ EXEC_CMD_LENGTH_IN_ACL + length + 1;
+
+ if ( oACL.allocate(totalLength) == NULL )
+ return(SYNCML_DM_DEVICE_FULL);
+
+
+ oACL.assign(ADD_CMD_IN_ACL);
+ oACL.append((UINT8*) m_strPrincipal.GetBuffer(),length);
+ oACL.append((UINT8*)"&",1);
+
+ oACL.append((UINT8*)GET_CMD_IN_ACL,GET_CMD_LENGTH_IN_ACL);
+ oACL.append((UINT8*)m_strPrincipal.GetBuffer(),length);
+ oACL.append((UINT8*)"&",1);
+
+ oACL.append((UINT8*)REPLACE_CMD_IN_ACL,REPLACE_CMD_LENGTH_IN_ACL);
+ oACL.append((UINT8*)m_strPrincipal.GetBuffer(),length);
+ oACL.append((UINT8*)"&",1);
+
+ oACL.append((UINT8*)DELETE_CMD_IN_ACL,DELETE_CMD_LENGTH_IN_ACL);
+ oACL.append((UINT8*)m_strPrincipal.GetBuffer(),length);
+ oACL.append((UINT8*)"&",1);
+
+ oACL.append((UINT8*)EXEC_CMD_IN_ACL,EXEC_CMD_LENGTH_IN_ACL);
+ oACL.append((UINT8*)m_strPrincipal.GetBuffer(),length);
+
+ m_oACLObj.SetACL(szURI, (CPCHAR)oACL.getBuffer());
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMTree::AddAutoNodes(CPCHAR szURI,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType,
+ DMToken & oAutoNodes)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if ( oAutoNodes.getBuffer() == NULL )
+ return SYNCML_DM_SUCCESS;
+
+ DMString autoNodeURI;
+ DMAddData oAddChildren;
+ CPCHAR sSegment = NULL;
+
+ while ( (sSegment = oAutoNodes.nextSegment()) != NULL )
+ {
+ autoNodeURI = szURI;
+ autoNodeURI += "/";
+ autoNodeURI += sSegment;
+
+ dm_stat = m_oMDFObj.SetAutoNodeProperty(autoNodeURI,oAddChildren);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = Add( oAddChildren,eRequestType);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+
+ return dm_stat;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Add
+// DESCRIPTION : The UA calls this method to add a node/data in the
+// tree.The UA need not call URIValidateAndParse
+// for ADD operation.DMTNM will internally call before
+// adding
+// ARGUMENTS PASSED: SYNCML_DM_PLUGIN_ADD_T *pAdd - pointer to adding node
+// information.
+
+//If default value then pAdd->bFormat=SYNCML_DM_FORMAT_INVALID
+// contains value TRUE.
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// - It returns SYNCML_DM_SUCCESS if the plug-in
+// adds the node succefully.
+// - It returns SYNCML_DM_DEVICE_FULL if the
+// device is out of memory.
+// - It returns SYNCML_DM_COMMAND_NOT_ALLOWED
+// if the commad is NOT allowed because
+// Access type and etc.
+// - It returns SYNCML_DM_TARGET_ALREADY_EXISTS
+// if the node already exists.
+// - It returns SYNCML_DM_INVALID_URI
+// if the node path is not valid for current DMT version
+// PRE-CONDITIONS : The Tree is in memory
+// POST-CONDITIONS : the node is added in the tree only if the plug-in
+// returns SYNCML_DM_SUCCESS
+// else the object is deleted.
+// after adding the node successfully,the DMTNM sets the
+// Name and ACL and Access Type properties.It uses the
+// access type sent by plug-in.
+// IMPORTANT NOTES : PHASE 1 implementation
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::Add( DMAddData & oAddData,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+ XPL_LOG_DM_TMN_Debug(("Enter DMTree::Add(DMAddData&, SYNCML_DM_REQUEST_TYPE_T)"));
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode = AddNodeInternal(oAddData, eRequestType);
+
+ if ( wReturnStatusCode == SYNCML_DM_SUCCESS || wReturnStatusCode != SYNCML_DM_NOT_FOUND )
+ {
+ return wReturnStatusCode;
+ }
+
+ // Add interior node(s) in the chain
+ DMString strURI = oAddData.getURI();
+ DMString strLastInteriorNodeAdded = NULL;
+ DMVector<DMAddData *> interiorNodeList;
+ DMAddData *pAddInteriorNodeData;
+ while ( GetLastSegmentOfURI(strURI, strLastInteriorNodeAdded ) )
+ {
+ pAddInteriorNodeData = new DMAddData();
+ if ( NULL == pAddInteriorNodeData )
+ {
+ wReturnStatusCode = SYNCML_DM_DEVICE_FULL;
+ break;
+ }
+ pAddInteriorNodeData->m_oURI.assign(strURI.c_str());
+ pAddInteriorNodeData->m_nFormat = SYNCML_DM_FORMAT_NODE;
+ wReturnStatusCode = AddNodeInternal(*pAddInteriorNodeData, eRequestType);
+ if ( wReturnStatusCode == SYNCML_DM_SUCCESS )
+ {
+ strLastInteriorNodeAdded = strURI;
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: set strLastInteriorNodeAdded=%s\n", strLastInteriorNodeAdded.c_str() ));
+ pAddInteriorNodeData->clear();
+ delete pAddInteriorNodeData;
+ break;
+ }
+ interiorNodeList.push_back(pAddInteriorNodeData);
+ }
+
+ while ( interiorNodeList.size() > 0 )
+ {
+ int idx = interiorNodeList.size() - 1;
+ pAddInteriorNodeData = interiorNodeList[idx];
+ if ( wReturnStatusCode == SYNCML_DM_SUCCESS )
+ {
+ wReturnStatusCode = AddNodeInternal(*pAddInteriorNodeData, eRequestType);
+ }
+ pAddInteriorNodeData->clear();
+ delete pAddInteriorNodeData;
+ interiorNodeList.remove(idx);
+ }
+
+ // Add target node again
+ if ( wReturnStatusCode == SYNCML_DM_SUCCESS )
+ {
+ wReturnStatusCode = AddNodeInternal(oAddData, eRequestType);
+ }
+
+ if ( wReturnStatusCode != SYNCML_DM_SUCCESS && strLastInteriorNodeAdded != NULL )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: deleting last added node \n"));
+ Delete(strLastInteriorNodeAdded.c_str(),SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ }
+ return wReturnStatusCode;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::AddNodeInternal( DMAddData & oAddData,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+ m_oLockContextManager.OnTreeAccessed();
+
+ DMString strURI;
+ DMString strPluginURI; // uri without ?xxx stuff for plugins and so on
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode;
+
+ if ( !GetPluginURI( oAddData.getURI(), strURI, strPluginURI ) )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: GetPluginURI path:%s\n",oAddData.getURI() ));
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: Validating URI:%s\n",strURI.c_str()));
+ SYNCML_DM_URI_RESULT_T wURIValidateRetCode = URIValidateAndParse( strURI );
+
+ // if wURIValidateRetCode != SYNCML_DM_COMMAND_ON_NODE
+ // means the server has fired adding the following commands
+ // example: ./TestAdd?prop=Format, ./Adding?prop=Type etc.
+ switch(wURIValidateRetCode)
+ {
+ case SYNCML_DM_COMMAND_URI_TOO_LONG:
+ return(SYNCML_DM_URI_TOO_LONG);
+ case SYNCML_DM_COMMAND_INVALID_URI:
+ return(SYNCML_DM_COMMAND_FAILED);
+ case SYNCML_DM_COMMAND_ON_NODE :
+ //do nothing here,proceed
+ break;
+ default:
+ return(SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: Get Node name from:%s\n",strURI.c_str()));
+ // The last segment of URI contains the node name
+ DMString strLastSegment;
+ if ( !GetLastSegmentOfURI(strURI, strLastSegment ) )
+ return(SYNCML_DM_COMMAND_FAILED);
+
+ // FindNodeByURI() function returns the node pointer
+ // of the last segment of the node name.
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: Check permission to write:%s\n",strURI.c_str()));
+ // check permission to write
+ if (!VerifyArchiveWriteAccess(strURI)) {
+ XPL_LOG_DM_TMN_Error(("archive has no write access for uri %s\n", strURI.c_str()));
+ return (SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: Get Parent Node from:%s\n",strURI.c_str()));
+ DMNode *psParentNodeOftheAddingNode = FindNodeByURI(strURI);
+ BOOLEAN bInPlugin = FALSE;
+
+ if (psParentNodeOftheAddingNode &&
+ psParentNodeOftheAddingNode->isPlugin())
+ {
+ bInPlugin = TRUE;
+ }
+ else if ( m_ptrCacheOPI != NULL )
+ { // OPI support:
+ DMNode *pNode = FindNodeByURI( strPluginURI );
+
+ if ( pNode && pNode->isPlugin() )
+ {
+ psParentNodeOftheAddingNode = pNode;
+ bInPlugin = TRUE;
+ }
+ }
+
+ // If the Parent doesn't exists then FindNodeByURI will return
+ // NULL and If the parent of the Addind node is a leaf node then we
+ // SHOULD NOT to create a node under a leaf node.
+
+ if(!bInPlugin &&
+ ((psParentNodeOftheAddingNode == NULL) ||
+ (psParentNodeOftheAddingNode->bFormat != SYNCML_DM_FORMAT_NODE)))
+ {
+ XPL_LOG_DM_TMN_Debug(("Either the Parent does not exists or the server \
+ is trying to add a node under a leaf node \n"));
+ return psParentNodeOftheAddingNode == NULL ? SYNCML_DM_NOT_FOUND : SYNCML_DM_COMMAND_NOT_ALLOWED;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: Parent Node got successfully\n Check isEnabled\n"));
+ BOOLEAN bIsEnabled;
+ bIsEnabled = IsUriEnabled(oAddData.getURI());
+ if ( bIsEnabled == FALSE )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: check if the new node already exists\n"));
+ DMNode *psPluginNode = NULL;
+ // The following condition is used to checks if the node already
+ // exists
+ if (bInPlugin)
+ {
+ psPluginNode = psParentNodeOftheAddingNode;
+
+ if (psPluginNode->Find(oAddData.getURI()) == SYNCML_DM_SUCCESS) {
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: pluginNode already exists \n"));
+ return(SYNCML_DM_TARGET_ALREADY_EXISTS);
+ }
+ }
+ else
+ {
+ if(FindNodeInNextSiblingsList(psParentNodeOftheAddingNode->pcFirstChild,strLastSegment) != NULL) {
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: node already exists \n"));
+ return(SYNCML_DM_TARGET_ALREADY_EXISTS);
+ }
+ }
+
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: check access type and ACL permissions\n"));
+ DMMetaPCharVector asChildDepend; // array of child/dependend nodes for indirect updates
+ // check the Access type and ACL permissions.
+ wReturnStatusCode = IsValidServer(strURI,
+ SYNCML_DM_ADD_ACCESS_TYPE,
+ eRequestType,
+ TRUE,
+ TRUE,
+ &asChildDepend);
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: IsValidServer uri:%s %d\n",strURI.c_str(), wReturnStatusCode));
+ return(wReturnStatusCode);
+ }
+ UINT16 count = GetChildrenCount(psParentNodeOftheAddingNode);
+ BOOLEAN bOPiDataParent = FALSE; // indicator that plug-in wants to store some data inside
+
+ BOOLEAN bESN = FALSE; // Is an ESN
+
+#ifdef LOB_SUPPORT
+ bESN = m_oMDFObj.IsESN(oAddData.getURI() );
+ oAddData.SetESN(bESN);
+#endif
+ if ( !m_oMDFObj.VerifyChildrenMultiNodesCount(strURI,count, bOPiDataParent) )
+ return SYNCML_DM_DEVICE_FULL;
+
+ DMNode *psAddingNode = NULL;
+
+ if (!bInPlugin)
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: not plugin, create node\n"));
+ psAddingNode = CreateNodeObj( bOPiDataParent ? SYNCML_DM_FORMAT_NODE_PDATA : oAddData.m_nFormat, bESN, NULL);
+
+ if(psAddingNode == NULL)
+ {
+ XPL_LOG_DM_TMN_Debug(("CreateNodeObj returned NULL pointer \n"));
+ return(SYNCML_DM_COMMAND_FAILED);
+ }
+
+ if ( bOPiDataParent && psAddingNode->getOverlayPIData())
+ {
+ wReturnStatusCode = OnOPiAdd(oAddData.getURI(), *psAddingNode->getOverlayPIData());
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: OnOPiAdd uri:%s %d\n",oAddData.getURI(), wReturnStatusCode));
+ delete(psAddingNode);
+ return(wReturnStatusCode);
+ }
+
+ }
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: check if server has replace permission\n"));
+ // This function checks if the server has replace permissions
+ SYNCML_DM_RET_STATUS_T wLocalRetStatusCode;
+ wLocalRetStatusCode = IsValidServer(strURI,
+ SYNCML_DM_REPLACE_ACCESS_TYPE,
+ eRequestType,
+ FALSE,
+ TRUE);
+
+ if (!bInPlugin) {
+ psAddingNode->abNodeName = strLastSegment;
+ }
+
+ // If the current connected doesn't have ACL permissions on
+ // replace command then we have to give all the ACL command
+ // permissions to connected server.
+
+ if(wLocalRetStatusCode == SYNCML_DM_PERMISSION_FAILED)
+ {
+ wLocalRetStatusCode = SetACL(oAddData.getURI());
+ if ( wLocalRetStatusCode != SYNCML_DM_SUCCESS )
+ {
+ delete(psAddingNode);
+ return(wLocalRetStatusCode);
+ }
+ }
+
+ DMNode *psTheNode = (bInPlugin) ? psPluginNode : psAddingNode;
+ DMToken aAutoNodes(SYNCML_DM_COMMA);
+
+ BOOLEAN bNodeGetAccess;
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: verify parameters\n"));
+ wReturnStatusCode = m_oMDFObj.VerifyAddParameters(psTheNode,oAddData,aAutoNodes,bNodeGetAccess);
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_TMN_Debug(("MDF check returned failure status code \n"));
+ delete psAddingNode;
+ return(wReturnStatusCode);
+ }
+
+ wReturnStatusCode = psTheNode->Add(oAddData);
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_TMN_Debug(("Plug-in Add returned failure status code \n"));
+ delete psAddingNode;
+ return wReturnStatusCode;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: setup the links of the node before adding the node into the tree\n"));
+ if (!bInPlugin)
+ {
+ // Setup the links of the node before adding the node into the tree
+ if ( bNodeGetAccess == FALSE )
+ psAddingNode->addFlags(DMNode::enum_NodeNoGetAccess);
+ psAddingNode->pcParentOfNode = psParentNodeOftheAddingNode;
+ psAddingNode->pcFirstChild = NULL;
+ psAddingNode->bFormat = oAddData.m_nFormat;
+
+ if(psParentNodeOftheAddingNode->pcFirstChild)
+ {
+ // if the current addind node is NOT the first child of the
+ // parent then insert the node in the siblings list.
+
+ wReturnStatusCode = InsertNodeIntoNextSiblingsList
+ (psParentNodeOftheAddingNode->pcFirstChild,
+ psAddingNode);
+ }
+ else
+ {
+ // if the current adding node is the first child of the
+ // parent then assign adding node pointer tp parent first
+ // child pointer.
+
+ psParentNodeOftheAddingNode->pcFirstChild = psAddingNode;
+ }
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ if ( psParentNodeOftheAddingNode )
+ {
+ // Set timestamp and version number for parent Node
+ // Use parentURI's URI.
+ psParentNodeOftheAddingNode->SetTStamp(strURI.c_str(),XPL_CLK_GetClock());
+ psParentNodeOftheAddingNode->SetVerNo(strURI.c_str(),psParentNodeOftheAddingNode->GetVerNo(strURI)+1);
+ }
+#endif
+
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: set time stamp and version number, add auto nodes\n"));
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ if (psAddingNode)
+ {
+ // Set timestamp and version number for currently added Node
+ psAddingNode->SetTStamp(strPluginURI.c_str(),XPL_CLK_GetClock());
+ psAddingNode->SetVerNo(strPluginURI.c_str(),0);
+ }
+#endif
+
+ wReturnStatusCode = AddAutoNodes(oAddData.getURI(), eRequestType, aAutoNodes);
+ if ( wReturnStatusCode != SYNCML_DM_SUCCESS )
+ {
+ Delete(oAddData.getURI(),SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ return wReturnStatusCode;
+ }
+
+#ifdef LOB_SUPPORT
+ if(bESN)
+ SetESNCache(oAddData.getURI(), psTheNode);
+#endif
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: log command and send event\n"));
+ //Logging the command which was executed successfully in the log file
+ LogEvent(SYNCML_DM_EVENT_ADD, oAddData.getURI());
+ if ( asChildDepend.size() > 0 )
+ CheckForIndirectUpdates( oAddData.getURI(), asChildDepend, psTheNode );
+
+ if ( bInPlugin == FALSE && oAddData.m_nFormat == SYNCML_DM_FORMAT_NODE &&
+ m_ptrCacheOPI )
+ {
+ DMNode *psPluginFantomNode = new DMPluginRootNode( m_ptrCacheOPI );
+
+ if ( psPluginFantomNode == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ psPluginFantomNode->SetAddedNode(oAddData.getURI());
+
+ DMNode::operator delete (psPluginFantomNode);
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMTree::Add: returing\n"));
+
+ return(wReturnStatusCode);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Delete
+//
+// DESCRIPTION : This function deletes the node incase if the directly
+// referenced node is an interior node then it deletes
+// it childs also. Before deleting the node first it
+// checks the ACL incase if the directly referenced node
+// is an interior node then it checks the ACL of childs
+// also. In case if the ACL permissions are then then
+// it calls plug-in.Delete function. If
+// plug-in.Delete function returns SUCCESS then this
+// function deletes the node from the tree.
+//
+//
+// ARGUMENTS PASSED: UINT32 commandId
+// UINT8 itemNumber
+// UINT8 *pbURI
+// -- URI of the deleting node.
+// BOOLEAN isThisAtomic
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// - It returns SYNCML_DM_URI_TOO_LONG incase if the
+// URI is too long.
+// - It returns SYNCML_DM_COMMAND_FAILED incase if the
+// URI is invalid like ?prop=Name.
+// - It returns SYNCML_DM_NOT_FOUND incase if the
+// node does not exists.
+// - It returns SYNCML_DM_COMMAND_NOT_ALLOWED incase
+// if the referenced node is a permanent node.
+// - It returns 206 incase if the this function
+// deletes only part of the directly referenced node.
+// This mostly happens if the referenced node is
+// an interior node.
+// - It returns SYNCML_DM_SUCCESS incase this function
+// deletes node succefully from the tree.
+// - It returns SYNCML_DM_INVALID_URI
+// if the node path is not valid for current DMT version
+//
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::Delete(CPCHAR pbURI,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+ m_oLockContextManager.OnTreeAccessed();
+
+ DMString strPluginURI; // uri without ?xxx stuff for plugins and so on
+ DMString strURI;
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode;
+ DMNode *psDeletingNode = NULL;
+ SYNCML_DM_RET_STATUS_T wURIValidateRetCode;
+ BOOLEAN bInPlugin = FALSE;
+
+ if ( !GetPluginURI( pbURI, strURI, strPluginURI ) )
+ return SYNCML_DM_COMMAND_FAILED;
+
+ // We are maintaing a local of the URI send by the UA
+ // because we are going to modify the URI value.
+ // This checks for a relative URI if so, force the ./
+
+ wURIValidateRetCode = URIValidateAndParse( strURI );
+ if(wURIValidateRetCode != SYNCML_DM_COMMAND_ON_NODE)
+ {
+ if(wURIValidateRetCode == SYNCML_DM_COMMAND_URI_TOO_LONG)
+ return(SYNCML_DM_URI_TOO_LONG);
+ else
+ {
+ XPL_LOG_DM_TMN_Debug(("Invalid URI \n"));
+ return(SYNCML_DM_COMMAND_FAILED);
+ }
+ }
+ // check permission to write
+ if (!VerifyArchiveWriteAccess(strURI)) {
+ XPL_LOG_DM_TMN_Error(("archive has no write access for uri %s\n", strURI.c_str()));
+ return (SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+
+ psDeletingNode = FindNodeByURI(strURI);
+ BOOLEAN bIsEnabled;
+ bIsEnabled = IsUriEnabled(strURI);
+
+ // In Node or Parent does NOT exists
+ if(psDeletingNode == NULL)
+ {
+ XPL_LOG_DM_TMN_Debug(("Node not exists in the Tree \n"));
+
+ if ( bIsEnabled == FALSE )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ else
+ return SYNCML_DM_NOT_FOUND;
+ }
+ else
+ {
+ if ( bIsEnabled == FALSE )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ }
+
+ bInPlugin = psDeletingNode->isPlugin();
+
+ // Is this the correct position to check this condition
+ if(psDeletingNode->isPermanent())
+ {
+ XPL_LOG_DM_TMN_Debug(("Deleting node is a PERMANENT node \n"));
+ return(SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+
+ //YXU if Node is .
+ if(psDeletingNode->pcParentOfNode == NULL && !bInPlugin)
+ {
+ XPL_LOG_DM_TMN_Debug(("Deleting . node is a PERMANENT node \n"));
+ return(SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+
+ wReturnStatusCode = IsValidServer(strURI,
+ SYNCML_DM_DELETE_ACCESS_TYPE,
+ eRequestType,
+ TRUE,
+ TRUE);
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ {
+ return(wReturnStatusCode);
+ }
+
+
+ //This function is checking for the ACL permissions of
+ //an interior.
+ DMStringVector aChildren;
+ if(!bInPlugin &&
+ (psDeletingNode->bFormat == SYNCML_DM_FORMAT_NODE) &&
+ (psDeletingNode->pcFirstChild != NULL))
+ {
+ if ( eRequestType == SYNCML_DM_REQUEST_TYPE_SERVER )
+ wReturnStatusCode = CheckDeleteForNode(psDeletingNode,strURI);
+ }
+
+ if (bInPlugin )
+ {
+ wReturnStatusCode = CheckDeleteForPluginNodes(eRequestType,strURI, psDeletingNode, aChildren);
+ }
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ return wReturnStatusCode;
+
+ //If the all the nodes the has ACL permissions then
+ //we have to delete the nodes from the tree after
+ //calling Delete of each node. In case of atomic
+ //we are not deleting any node from the tree here
+ //we are deleting the tree in DataCommit or
+ //RollBack function.
+
+ SYNCML_DM_FORMAT_T format = psDeletingNode->bFormat;
+ if (!bInPlugin)
+ {
+ if ( psDeletingNode->IsOverlayPIData() && m_ptrCacheOPI != NULL ) // notify plug-in first
+ {
+ wReturnStatusCode = OnOPiDelete( strURI );
+ }
+
+ if ( wReturnStatusCode == SYNCML_DM_SUCCESS )
+ wReturnStatusCode = DeleteNode(psDeletingNode,strURI,aChildren);
+
+ } else
+ wReturnStatusCode = psDeletingNode->Delete( strURI );
+
+ if ( wReturnStatusCode != SYNCML_DM_SUCCESS )
+ return wReturnStatusCode;
+
+ if ( bInPlugin == FALSE &&
+ format == SYNCML_DM_FORMAT_NODE &&
+ m_ptrCacheOPI )
+ {
+
+ DMNode* psPluginFantomNode = new DMPluginRootNode( m_ptrCacheOPI );
+
+ if ( psPluginFantomNode == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ psPluginFantomNode->RemoveAddedNode(strURI);
+
+ DMNode::operator delete (psPluginFantomNode);
+ }
+
+
+ m_oACLObj.Delete(strURI);
+ LogEvent(pbURI,aChildren);
+
+#ifdef LOB_SUPPORT
+ RemoveESNCache(pbURI);
+#endif
+
+ return(wReturnStatusCode);
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : Exec
+//
+// DESCRIPTION : This function execute the node by fist check permission
+// - It returns SYNCML_DM_INVALID_URI
+// if the node path is not valid for current DMT version
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::Exec(CPCHAR pbURI,
+ CPCHAR pExecData,
+ DMString & oExecResult,
+ CPCHAR szCorrelator)
+{
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode;
+
+ m_oLockContextManager.OnTreeAccessed();
+
+ XPL_LOG_DM_TMN_Debug(("Entered DMTree::Exec \n"));
+
+ if(pbURI == NULL)
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::Exec: pbURI is null\n"));
+ return(SYNCML_DM_COMMAND_FAILED);
+ }
+
+ char *abTempURI = (char*) DmAllocMem(GetMaxTotalPathLength() + 1);
+ if(abTempURI == NULL)
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree::Exec: abTempURI allocate memory failed\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ abTempURI[0] = '\0';
+
+ XPL_LOG_DM_TMN_Debug(("Server fired <Exec> on: %s \n", pbURI));
+
+ UINT16 bStringLength = DmStrlen(pbURI);
+ // We are maintaing a local of the URI send by the UA
+ // because we are going to modify the URI value.
+ // This checks for a relative URI if so, force the ./
+
+ if(pbURI[0] != SYNCML_DM_DOT)
+ {
+ abTempURI[0] = SYNCML_DM_DOT;
+ abTempURI[1] = SYNCML_DM_FORWARD_SLASH;
+ abTempURI[2] = '\0';
+ bStringLength += SYNCML_DM_RELATIVE_URI_OFFSET_LENGTH; // For "./"
+ }
+
+ if(bStringLength > GetMaxTotalPathLength() )
+ {
+ XPL_LOG_DM_TMN_Debug(("URI Too long \n"));
+ DmFreeMem(abTempURI);
+ return(SYNCML_DM_URI_TOO_LONG);
+ }
+
+ DmStrcat(abTempURI, pbURI);
+
+ SYNCML_DM_RET_STATUS_T wURIValidateRetCode = URIValidateAndParse(abTempURI);
+
+ if(wURIValidateRetCode != SYNCML_DM_COMMAND_ON_NODE)
+ {
+ if(wURIValidateRetCode == SYNCML_DM_COMMAND_URI_TOO_LONG)
+ {
+ XPL_LOG_DM_TMN_Debug(("URI Too long \n"));
+ DmFreeMem(abTempURI);
+ return(SYNCML_DM_URI_TOO_LONG);
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Debug(("Invalid URI \n"));
+ DmFreeMem(abTempURI);
+ return(SYNCML_DM_COMMAND_FAILED);
+ }
+ }
+
+ DMNode *psExecNode = FindNodeByURI(abTempURI);
+
+ // In Node or Parent does NOT exists
+ BOOLEAN bIsEnabled;
+ bIsEnabled = IsUriEnabled(abTempURI);
+
+ if(psExecNode == NULL)
+ {
+ XPL_LOG_DM_TMN_Debug(("Node not exists in the Tree \n"));
+ DmFreeMem(abTempURI);
+ if ( bIsEnabled == FALSE )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ else
+ return SYNCML_DM_NOT_FOUND;
+ }
+ else
+ {
+ if ( bIsEnabled == FALSE )
+ {
+ DmFreeMem(abTempURI);
+ XPL_LOG_DM_TMN_Debug(("DMTree::Exec: Node not enabled! \n"));
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ }
+ }
+
+ wReturnStatusCode = IsValidServer(abTempURI,
+ SYNCML_DM_EXEC_ACCESS_TYPE,
+ SYNCML_DM_REQUEST_TYPE_SERVER,
+ TRUE,
+ TRUE);
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ {
+ DmFreeMem(abTempURI);
+ XPL_LOG_DM_TMN_Debug(("DMTree::Exec: Not valid server! \n"));
+ return(wReturnStatusCode);
+ }
+ XPL_LOG_DM_TMN_Debug(("DMTree::Exec: Execute plugin... \n"));
+ if ( pExecData )
+ wReturnStatusCode=DmExecutePlugin(abTempURI,pExecData,szCorrelator,oExecResult);
+ else
+ wReturnStatusCode=DmExecutePlugin(abTempURI,"",szCorrelator,oExecResult);
+
+ DmFreeMem(abTempURI);
+
+ XPL_LOG_DM_TMN_Debug(("Exec: exec plugin for uri %s, data %s, correlator %s returned %d\n",
+ abTempURI,
+ pExecData ? pExecData : "<NULL>",
+ szCorrelator,
+ wReturnStatusCode));
+
+ return(wReturnStatusCode);
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : Get
+// DESCRIPTION : Get Node value
+// ARGUMENTS PASSED: the URI(target to get)
+// the pointer to the structure to return after filling in the value
+// RETURN VALUE : status code indicating result of the operation
+// and the structure filled with the values
+// PRE-CONDITIONS : ONLY THE DM ENGINE INVOKES THIS,it is an INTERNAL
+// METHOD
+// POST-CONDITIONS : The UA is able to retrieve the value through the
+// return structure
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::Get(CPCHAR pbUri,
+ DMGetData & oReturnData,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+
+ m_oLockContextManager.OnTreeAccessed();
+
+ DMNode *psGetNode = NULL;
+ SYNCML_DM_URI_RESULT_T wURIValidateRetCode;
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode = SYNCML_DM_SUCCESS;
+ DMString strPluginURI; // uri without ?xxx stuff for plugins and so on
+ DMString strURI;
+
+ if ( !GetPluginURI( pbUri, strURI, strPluginURI ) )
+ return SYNCML_DM_COMMAND_FAILED;
+
+ wURIValidateRetCode = URIValidateAndParse( strURI );
+ switch(wURIValidateRetCode)
+ {
+ case SYNCML_DM_COMMAND_INVALID_URI:
+ return(SYNCML_DM_COMMAND_NOT_ALLOWED);
+
+ case SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY:
+ return(SYNCML_DM_FEATURE_NOT_SUPPORTED);
+
+ default :
+ //not processed immedietely,do nothing
+ break;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("Get %s, %s, %s\n", pbUri, strURI.c_str(), strPluginURI.c_str()));
+ // check permission to read
+ if (!VerifyArchiveReadAccess(strPluginURI)) {
+ XPL_LOG_DM_TMN_Error(("archive has no read access for uri %s\n", strPluginURI.c_str()));
+ return (SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+
+ psGetNode = FindNodeByURI( strPluginURI );
+
+ BOOLEAN bIsEnabled;
+ bIsEnabled = IsUriEnabled(strPluginURI);
+ if(psGetNode == NULL) // If this node doesn't exist
+ {
+ if ( bIsEnabled == FALSE )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ else
+ return SYNCML_DM_NOT_FOUND;
+
+ }
+ else
+ {
+ if ( bIsEnabled == FALSE )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ }
+
+ if ( eRequestType != SYNCML_DM_REQUEST_TYPE_INTERNAL )
+ {
+
+ if( psGetNode->IsGetAccess(strPluginURI) == FALSE )
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+
+ wReturnStatusCode = IsValidServer(strPluginURI,
+ SYNCML_DM_GET_ACCESS_TYPE,
+ eRequestType,
+ TRUE,
+ TRUE);
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ return(wReturnStatusCode);
+ }
+
+ DMString strData;
+ SYNCML_DM_FORMAT_T bNodeFormat = SYNCML_DM_FORMAT_CHR;
+#ifdef LOB_SUPPORT
+ oReturnData.SetESN(psGetNode->IsESN());
+#endif
+
+ switch(wURIValidateRetCode)
+ {
+ case SYNCML_DM_COMMAND_ON_NODE:
+ if(psGetNode->bFormat != SYNCML_DM_FORMAT_NODE)
+ {
+ return psGetNode->Get(strPluginURI, oReturnData);
+ }
+ else
+ {
+ wReturnStatusCode = GetChildren(strPluginURI, psGetNode, eRequestType, strData );
+ bNodeFormat = SYNCML_DM_FORMAT_NODE;
+ }
+ break;
+
+ case SYNCML_DM_COMMAND_ON_ACL_PROPERTY:
+ m_oACLObj.GetACL(strPluginURI, strData);
+ break;
+
+ case SYNCML_DM_COMMAND_ON_FORMAT_PROPERTY:
+ {
+ SYNCML_DM_FORMAT_T dwFormat = 0;
+
+ if(psGetNode->bFormat == SYNCML_DM_FORMAT_NODE)
+ {
+ dwFormat = SYNCML_DM_FORMAT_NODE;
+ wReturnStatusCode = SYNCML_DM_SUCCESS;
+ }
+ else
+ {
+ wReturnStatusCode = psGetNode->GetFormat(strPluginURI,&dwFormat);
+ }
+
+ if(wReturnStatusCode == SYNCML_DM_SUCCESS)
+ wReturnStatusCode = ConvertFormat(dwFormat,strData);
+ }
+ break;
+
+ case SYNCML_DM_COMMAND_ON_TYPE_PROPERTY:
+ wReturnStatusCode = psGetNode->GetType(strPluginURI, strData);
+ break;
+
+#ifdef LOB_SUPPORT
+ case SYNCML_DM_COMMAND_ON_ESN_PROPERTY:
+ {
+ char szSize[4];
+ BOOLEAN bESN = FALSE;
+ wReturnStatusCode = psGetNode->IsESN(strPluginURI, bESN);
+ if(bESN)
+ DmSprintf(szSize, "%s", "yes");
+ else
+ DmSprintf(szSize, "%s", "no");
+ strData = szSize;
+ }
+ break;
+#endif
+
+ case SYNCML_DM_COMMAND_ON_SIZE_PROPERTY:
+ {
+ UINT32 dwSize = 0;
+ char szSize[ SIZE_LENGTH + 1 ];
+
+ wReturnStatusCode = psGetNode->GetSize(strPluginURI,&dwSize);
+
+ if(wReturnStatusCode == SYNCML_DM_SUCCESS)
+ {
+ DmSprintf(szSize, "%d", dwSize);
+ strData = szSize;
+ }
+ }
+ break;
+
+ case SYNCML_DM_COMMAND_ON_NAME_PROPERTY:
+ wReturnStatusCode = psGetNode->GetName(strPluginURI, strData);
+ break;
+
+ case SYNCML_DM_COMMAND_ON_TITLE_PROPERTY:
+ wReturnStatusCode = psGetNode->GetTitle(strPluginURI, strData);
+ break;
+
+ case SYNCML_DM_COMMAND_ON_TSTAMP_PROPERTY:
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ {
+ char szTimeStamp[ TSTAMP_LENGTH+1 ];
+ XPL_CLK_CLOCK_T timestamp=psGetNode->GetTStamp(strPluginURI); //In seconds
+ //OK, interface uses milleseconds %lld while internal TStamp uses seconds
+ DmSprintf(szTimeStamp, "%lld", (XPL_CLK_LONG_CLOCK_T)timestamp * 1000L);
+ strData = szTimeStamp;
+ }
+#else
+ wReturnStatusCode = SYNCML_DM_FEATURE_NOT_SUPPORTED;
+#endif
+ break;
+
+ case SYNCML_DM_COMMAND_ON_VERNO_PROPERTY:
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ {
+ char szVer[ VERSION_LENGTH + 1 ];
+ DmSprintf(szVer, "%d", psGetNode->GetVerNo(strPluginURI));
+ strData = szVer;
+ }
+#else
+ wReturnStatusCode = SYNCML_DM_FEATURE_NOT_SUPPORTED;
+#endif
+ break;
+
+ default:
+ wReturnStatusCode = SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ break;
+ }// End of switch case
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ return wReturnStatusCode;
+
+ if(strData[0] == 0 && (psGetNode->bFormat != SYNCML_DM_FORMAT_NODE))
+ bNodeFormat = SYNCML_DM_FORMAT_NULL;
+ return oReturnData.set(bNodeFormat,strData,strData.length(),NULL);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : InternalGetAttributes
+// DESCRIPTION : This method is called INTERNALLY by the DM Engine(UA)
+// to mimic the DM GET operation to get the node attributes.
+// ARGUMENTS PASSED:
+// pbURI -- URI of the node.
+// attrs -- reference to DmtAttributes object.
+// bInternalGet -- whether this is an internal call or not.
+// RETURN VALUE : status code indicating result of the operation
+// and the structure filled with the values
+// PRE-CONDITIONS : ONLY THE DM ENGINE INVOKES THIS,it is an INTERNAL
+// METHOD
+// POST-CONDITIONS : The UA is able to retrieve the value through the
+// return structure
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::GetAttributes(CPCHAR pbUri,
+ DmtAttributes& attrs,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+ m_oLockContextManager.OnTreeAccessed();
+
+ DMNode *psGetNode = NULL;
+ SYNCML_DM_RET_STATUS_T wURIValidateRetCode;
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode = SYNCML_DM_SUCCESS;
+ DMString strPluginURI; // uri without ?xxx stuff for plugins and so on
+ DMString strURI;
+
+ if ( !GetPluginURI( pbUri, strURI, strPluginURI ) )
+ return SYNCML_DM_COMMAND_FAILED;
+
+ wURIValidateRetCode = URIValidateAndParse( strURI );
+ switch(wURIValidateRetCode)
+ {
+ case SYNCML_DM_COMMAND_INVALID_URI:
+ return(SYNCML_DM_COMMAND_NOT_ALLOWED);
+
+ case SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY:
+ return(SYNCML_DM_FEATURE_NOT_SUPPORTED);
+
+ default :
+ //not processed immedietely,do nothing
+ break;
+ }
+
+ psGetNode = FindNodeByURI( strPluginURI );
+ if(psGetNode == NULL)
+ {
+ BOOLEAN bIsEnabled;
+ bIsEnabled = IsUriEnabled(strPluginURI);
+ if ( bIsEnabled == FALSE )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ else
+ return SYNCML_DM_NOT_FOUND;
+
+ }
+
+
+ if ( eRequestType != SYNCML_DM_REQUEST_TYPE_INTERNAL ) {
+ wReturnStatusCode = IsValidServer(strPluginURI,
+ SYNCML_DM_GET_ACCESS_TYPE,
+ eRequestType,
+ TRUE,
+ TRUE);
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ return(wReturnStatusCode);
+ }
+
+ DMString strName, strFormat, strTitle, strType, strAcl;
+ UINT32 nVer = 0, nSize = 0;
+ INT64 timestamp =0;
+
+ if (wURIValidateRetCode == SYNCML_DM_COMMAND_ON_NODE)
+ {
+ wReturnStatusCode = psGetNode->GetName(strPluginURI, strName);
+
+ if (wReturnStatusCode != SYNCML_DM_SUCCESS)
+ return(wReturnStatusCode);
+
+ SYNCML_DM_FORMAT_T dwFormat = 0;
+ if(psGetNode->bFormat == SYNCML_DM_FORMAT_NODE)
+ {
+ dwFormat = SYNCML_DM_FORMAT_NODE;
+ wReturnStatusCode = SYNCML_DM_SUCCESS;
+ }
+ else
+ wReturnStatusCode = psGetNode->GetFormat(strPluginURI, &dwFormat);
+
+ if(wReturnStatusCode == SYNCML_DM_SUCCESS)
+ wReturnStatusCode = ConvertFormat(dwFormat,strFormat);
+ else
+ return(wReturnStatusCode);
+
+ m_oACLObj.GetACL(strPluginURI, strAcl);
+ wReturnStatusCode = psGetNode->GetType(strPluginURI, strType);
+ wReturnStatusCode = psGetNode->GetTitle(strPluginURI, strTitle);
+ wReturnStatusCode = psGetNode->GetSize(strPluginURI, &nSize);
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ timestamp=(JemDate)(psGetNode->GetTStamp(strPluginURI) * 1000L);
+ nVer = psGetNode->GetVerNo(strPluginURI);
+#else
+ return(SYNCML_DM_FEATURE_NOT_SUPPORTED);
+#endif
+
+ }
+ else
+ return(SYNCML_DM_FEATURE_NOT_SUPPORTED);
+
+ return attrs.Set(strName, strFormat, strTitle, strType, nVer, nSize, timestamp, DmtAcl(strAcl));
+
+}
+
+BOOLEAN DMTree::NeedCheckParent( const DMString& strURI,
+ DMNode *psReplacingNode,
+ BOOLEAN bInPlugin,
+ SYNCML_DM_FORMAT_T bFormat,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+ BOOLEAN bCheckParent = FALSE;
+ BOOLEAN bContinueChecking = TRUE;
+
+ if( bFormat == SYNCML_DM_FORMAT_NODE )
+ {
+ bContinueChecking = ( IsValidServer( strURI,
+ SYNCML_DM_REPLACE_ACCESS_TYPE,
+ eRequestType,
+ FALSE,
+ TRUE) != SYNCML_DM_SUCCESS );
+ }
+
+ if( bContinueChecking )
+ {
+ if (!bInPlugin)
+ {
+ if(psReplacingNode->pcParentOfNode )
+ {
+ bCheckParent = TRUE;
+ }
+ }
+ else
+ {
+ if( ParentExistsForPluginNode(strURI, psReplacingNode ) )
+ {
+ bCheckParent = TRUE;
+ }
+ }
+ }
+
+ return bCheckParent;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::ReplaceACLProperty( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ const DMString& strPluginURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode )
+{
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode = SYNCML_DM_SUCCESS;
+
+ if ( strURI == "." )
+ return (SYNCML_DM_COMMAND_NOT_ALLOWED);
+
+ if((oReplaceData.m_oData.getSize() == 0))
+ {
+ m_oACLObj.Delete(strURI);
+ LogEvent(SYNCML_DM_EVENT_REPLACE,oReplaceData.getURI());
+ }
+ else
+ {
+ char *pACL = NULL;
+ oReplaceData.m_oData.copyTo(&pACL);
+ if( pACL == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ wReturnStatusCode = ParseACL((UINT8*)pACL);
+ if(wReturnStatusCode == SYNCML_DM_SUCCESS)
+ {
+ LogEvent(SYNCML_DM_EVENT_REPLACE,oReplaceData.getURI());
+ if( oReplaceData.m_oURI.compare(".?prop=ACL") )
+ {
+ XPL_LOG_DM_TMN_Debug(("Server fired <Replace> on the ACL of a Root node \n"));
+ UINT8 *pbADDLoc = NULL;
+
+ pbADDLoc = (UINT8*)DmStrstr(pACL, "Add=");
+ if(pbADDLoc != NULL)
+ {
+ pbADDLoc += ADD_CMD_LENGTH_IN_ACL;
+ if((pbADDLoc != NULL) && (pbADDLoc[0] != SYNCML_DM_STAR))
+ {
+ XPL_LOG_DM_TMN_Debug(("Root node Replacing ACL value does NOT have \
+ Add permissions to ALL servers it should Add=* \n"));
+
+ if (pACL)
+ DmFreeMem(pACL);
+ return (SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Debug(("Root node Replacing ACL value does NOT have \
+ Add permissions to. This is NOT allowed according to spec \n"));
+
+ if (pACL)
+ DmFreeMem(pACL);
+ return (SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+ }
+
+ m_oACLObj.SetACL(strURI, pACL);
+ }
+
+ DmFreeMem(pACL);
+ }
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ if ( (wReturnStatusCode == SYNCML_DM_SUCCESS) && !bInPlugin && psReplacingNode )
+ {
+ psReplacingNode->SetTStamp(strPluginURI, XPL_CLK_GetClock());
+ psReplacingNode->SetVerNo(strPluginURI, psReplacingNode->GetVerNo(strPluginURI) + 1);
+ }
+#endif
+
+ return wReturnStatusCode;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::ReplaceTitleProperty( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ const DMString& strPluginURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode )
+{
+ if( oReplaceData.m_oData.getSize() == 0)
+ {
+ psReplacingNode->m_strTitle = "";
+ LogEvent(SYNCML_DM_EVENT_REPLACE,oReplaceData.getURI());
+ }
+ else
+ {
+ if ( oReplaceData.m_oData.getSize() > SYNCML_DM_MAX_TITLE_LENGTH )
+ {
+ oReplaceData.m_oData.setSize(SYNCML_DM_MAX_TITLE_LENGTH);
+ }
+
+ psReplacingNode->SetTitle( strURI, oReplaceData.getCharData());
+ LogEvent(SYNCML_DM_EVENT_REPLACE,oReplaceData.getURI());
+ }
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ // Update timestamp and increment version number !!
+ if( !bInPlugin && psReplacingNode)
+ {
+ psReplacingNode->SetTStamp(strPluginURI.c_str(),XPL_CLK_GetClock());
+ psReplacingNode->SetVerNo(strPluginURI.c_str(),psReplacingNode->GetVerNo(strPluginURI.c_str()) + 1);
+ }
+#endif
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::ReplaceNodeInternal( const DMString& strURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode,
+ DMMetaPCharVector& asChildDepend )
+{
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode = m_oMDFObj.VerifyReplaceParameters(psReplacingNode,
+ strURI,
+ oReplaceData,
+ NULL);
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ return(wReturnStatusCode);
+
+ wReturnStatusCode = psReplacingNode->Replace( oReplaceData );
+
+ if(wReturnStatusCode == SYNCML_DM_SUCCESS)
+ {
+ LogEvent(SYNCML_DM_EVENT_REPLACE,oReplaceData.getURI());
+
+#ifdef LOB_SUPPORT
+ if(psReplacingNode->IsESN())
+ LogESNCommandForArchiver(oReplaceData.getURI(),psReplacingNode);
+#endif
+
+ if ( asChildDepend.size() > 0 )
+ CheckForIndirectUpdates( strURI, asChildDepend, psReplacingNode );
+ }
+
+ return wReturnStatusCode;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::PrepareNamePropertyReplace( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode )
+{
+ if(psReplacingNode->isPermanent())
+ {
+ XPL_LOG_DM_TMN_Debug(("Server fired <Replace> on the name of a permanent node which is NOT allowed \n"));
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+ }
+
+ // For a Replace command on the name of a node, the DMTNM shall
+ // first verify that the result of the operation will not cause
+ // any inconsistencies in the tree, before it executes the command.
+
+ // The following condition is used to check if the node name
+ // already existing or not
+
+ if( oReplaceData.m_oData.getSize() == 0 )
+ return(SYNCML_DM_COMMAND_FAILED);
+
+ if( oReplaceData.m_oData.getSize() > GetMaxPathSegmentLength() )
+ {
+ XPL_LOG_DM_TMN_Debug(("Replacing Name is too long \n"));
+ return(SYNCML_DM_REQUEST_ENTITY_TOO_LARGE);
+ }
+
+ if(IsValidSegment((CPCHAR)oReplaceData.m_oData.getBuffer(),oReplaceData.m_oData.getSize()) == FALSE)
+ return(SYNCML_DM_COMMAND_FAILED);
+
+ BOOLEAN noParent = FALSE;
+ if (bInPlugin) {
+ if (!ParentExistsForPluginNode(strURI, psReplacingNode))
+ noParent = TRUE;
+ } else
+ if (psReplacingNode->pcParentOfNode == NULL)
+ noParent = TRUE;
+
+ if (noParent)
+ return(SYNCML_DM_COMMAND_FAILED);
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::CheckReplacingNodeName( DMAddData& oReplaceData,
+ DMNode* psReplacingNode )
+{
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode = SYNCML_DM_SUCCESS;
+
+ if ( oReplaceData.m_oData.compare(psReplacingNode->abNodeName) )
+ {
+ if((psReplacingNode->pcParentOfNode != NULL) &&
+ psReplacingNode->pcParentOfNode->abNodeName == "." )
+ {
+ if( oReplaceData.m_oData.compare("DevDetail") ||
+ oReplaceData.m_oData.compare("SyncML") ||
+ oReplaceData.m_oData.compare("DevInfo") )
+ {
+ wReturnStatusCode = SYNCML_DM_COMMAND_NOT_ALLOWED;
+ }
+ else
+ {
+ wReturnStatusCode = SYNCML_DM_SUCCESS;
+ }
+ }
+ else
+ {
+ wReturnStatusCode = SYNCML_DM_SUCCESS;
+ }
+ }
+ else
+ {
+ wReturnStatusCode = SYNCML_DM_COMMAND_NOT_ALLOWED;
+ }
+
+ return wReturnStatusCode;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::FixACL( const DMString& strURI,
+ DMAddData& oReplaceData )
+{
+ DMString dacl;
+ m_oACLObj.GetACL(strURI, dacl);
+ if (dacl != "")
+ {
+ DMString strParentURI = strURI, strLastSegment;
+
+ if ( !GetLastSegmentOfURI(strParentURI, strLastSegment) )
+ return SYNCML_DM_DEVICE_FULL;
+
+ strParentURI += "/";
+ strParentURI += (CPCHAR)oReplaceData.getCharData();
+
+ m_oACLObj.Delete(strURI);
+ m_oACLObj.SetACL( strParentURI, dacl);
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::ReplaceNameProperty( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ const DMString& strPluginURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode,
+ SYNCML_DM_RET_STATUS_T wURIValidateRetCode )
+{
+ XPL_LOG_DM_TMN_Error(("ReplaceNameProperty() called \n"));
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode = PrepareNamePropertyReplace( strURI,
+ bInPlugin,
+ oReplaceData,
+ psReplacingNode );
+ XPL_LOG_DM_TMN_Error(("From ReplaceNameProperty(): Call to PrepareNamePropertyReplace() returns %d \n", wReturnStatusCode));
+
+ if( SYNCML_DM_SUCCESS != wReturnStatusCode ) return wReturnStatusCode;
+
+ if(!bInPlugin && (FindNodeInNextSiblingsList((psReplacingNode->pcParentOfNode)->pcFirstChild,
+ oReplaceData.getCharData()) != NULL))
+ {
+ wReturnStatusCode = CheckReplacingNodeName( oReplaceData,
+ psReplacingNode );
+ XPL_LOG_DM_TMN_Error(("From ReplaceNameProperty(): Call to CheckReplacingNodeName() returns %d \n", wReturnStatusCode));
+ }
+ else
+ {
+ DMString origName;
+
+ if((wURIValidateRetCode == SYNCML_DM_COMMAND_ON_NAME_PROPERTY) && !bInPlugin)
+ {
+ origName = psReplacingNode->abNodeName;
+ psReplacingNode->abNodeName = oReplaceData.getCharData();
+ }
+
+ DMString strParentURI = strURI, strLastSegment;
+
+ if ( !GetLastSegmentOfURI(strParentURI, strLastSegment) )
+ return SYNCML_DM_DEVICE_FULL;
+
+ strParentURI += "/";
+ strParentURI += oReplaceData.getCharData();
+
+ wReturnStatusCode = m_oMDFObj.VerifyReplaceParameters(psReplacingNode,
+ strParentURI,
+ oReplaceData,
+ origName);
+
+ XPL_LOG_DM_TMN_Error(("From ReplaceNameProperty(): Call to VerifyReplaceParameters() returns %d \n", wReturnStatusCode));
+
+ if(wURIValidateRetCode == SYNCML_DM_COMMAND_ON_NAME_PROPERTY)
+ {
+ if (!bInPlugin)
+ psReplacingNode->abNodeName = origName;
+ }
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ return(wReturnStatusCode);
+
+
+ wReturnStatusCode = psReplacingNode->Rename(strPluginURI,oReplaceData.getCharData());
+ XPL_LOG_DM_TMN_Error(("From ReplaceNameProperty(): Call to psReplacingNode->Rename() returns %d \n", wReturnStatusCode));
+ }
+
+ if(wReturnStatusCode == SYNCML_DM_SUCCESS)
+ {
+ if (!bInPlugin) {
+ psReplacingNode->SetName( oReplaceData.getURI(), oReplaceData.getCharData());
+ }
+
+ LogEvent(SYNCML_DM_EVENT_RENAME,strURI,oReplaceData.getCharData());
+ wReturnStatusCode = FixACL( strURI, oReplaceData );
+ XPL_LOG_DM_TMN_Error(("From ReplaceNameProperty(): Call to FixACL() returns %d \n", wReturnStatusCode));
+ }
+
+ return wReturnStatusCode;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::ReplaceProperty( const DMString& strURI,
+ BOOLEAN bInPlugin,
+ const DMString& strPluginURI,
+ DMAddData& oReplaceData,
+ DMNode* psReplacingNode,
+ SYNCML_DM_RET_STATUS_T wURIValidateRetCode )
+{
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode = SYNCML_DM_SUCCESS;
+
+ switch( wURIValidateRetCode )
+ {
+ case SYNCML_DM_COMMAND_ON_NAME_PROPERTY:
+ {
+ wReturnStatusCode = ReplaceNameProperty( strURI,
+ bInPlugin,
+ strPluginURI,
+ oReplaceData,
+ psReplacingNode,
+ wURIValidateRetCode );
+ break;
+ }
+ case SYNCML_DM_COMMAND_ON_ACL_PROPERTY:
+ {
+ wReturnStatusCode = ReplaceACLProperty( strURI,
+ bInPlugin,
+ strPluginURI,
+ oReplaceData,
+ psReplacingNode );
+ break;
+ }
+ case SYNCML_DM_COMMAND_ON_TITLE_PROPERTY:
+ {
+ wReturnStatusCode = ReplaceTitleProperty( strURI,
+ bInPlugin,
+ strPluginURI,
+ oReplaceData,
+ psReplacingNode );
+ break;
+ }
+ case SYNCML_DM_COMMAND_ON_FORMAT_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_SIZE_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_TYPE_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_TSTAMP_PROPERTY:
+ case SYNCML_DM_COMMAND_ON_VERNO_PROPERTY:
+ {
+ wReturnStatusCode = SYNCML_DM_COMMAND_NOT_ALLOWED;
+ break;
+ }
+ default:
+ {
+ wReturnStatusCode = SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ break;
+ }
+ }
+
+ return wReturnStatusCode;
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : Replace
+//
+// DESCRIPTION : This function first will check the ACL and access type
+// and after that if the both permissions are there then
+// it will call respective plug-in.Replace.
+//
+// ARGUMENTS PASSED: UINT32 commandId
+// UINT8 itemNumber
+// SYNCML_DM_PLUGIN_ADD_T *pReplace
+// -- Contains the replacing dat and it's format and
+// type.
+// BOOLEAN moreData
+// BOOLEAN isThisAtomic
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// -- It returns SYNCML_DM_COMMAND_FAILED in case if
+// pReplace is NULL or incase of invalid name if
+// the server fire replace on ?prop=Name
+// -- It returns SYNCML_DM_COMMAND_INVALID_URI incase
+// if the input URI is invalid.
+// - It returns SYNCML_DM_INVALID_URI
+// if the node path is not valid for current DMT version
+// -- It returns SYNCML_DM_URI_TOO_LONG incase
+// if the input URI is long.
+// -- It returns SYNCML_DM_DEVICE_FULL incase
+// if the device is out of memory.
+// -- It returns SYNCML_DM_FEATURE_NOT_SUPPORTED
+// incase if the server fire replace on ?prop=Title
+// -- It returns SYNCML_DM_COMMAND_NOT_ALLOWED incase
+// if the command is not allowed on the target.
+// -- It returns SYNCML_DM_REQUEST_ENTITY_TOO_LARGE
+// incase if the replacing name is large.
+// -- It returns SYNCML_DM_SUCCESS incase if the operation
+// is success.
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::Replace( DMAddData & oReplaceData,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+ m_oLockContextManager.OnTreeAccessed();
+
+ if(oReplaceData.getURI() == NULL)
+ return(SYNCML_DM_COMMAND_INVALID_URI);
+
+ SYNCML_DM_RET_STATUS_T wReturnStatusCode = SYNCML_DM_SUCCESS;
+ DMString strPluginURI; // uri without ?xxx stuff for plugins and so on
+ DMString strURI;
+
+ if ( !GetPluginURI( oReplaceData.getURI(), strURI, strPluginURI ) )
+ return SYNCML_DM_COMMAND_FAILED;
+
+ SYNCML_DM_RET_STATUS_T wURIValidateRetCode = URIValidateAndParse( strURI );
+
+ if((wURIValidateRetCode != SYNCML_DM_COMMAND_ON_NODE) &&
+ (wURIValidateRetCode != SYNCML_DM_COMMAND_ON_ACL_PROPERTY) &&
+ (wURIValidateRetCode != SYNCML_DM_COMMAND_ON_NAME_PROPERTY) &&
+ (wURIValidateRetCode != SYNCML_DM_COMMAND_ON_TITLE_PROPERTY)
+ ) //TStamp VerNo goes here.
+ return(SYNCML_DM_COMMAND_NOT_ALLOWED);
+
+
+ //This if statement checks for ?prop attribute such that
+ // '?' is set to NULL.This is because before sending to plugins
+ //?prop=<property_name> must be removed from the URI
+ //example if ./SyncML?prop=ACL,we need to send only ./SyncML
+
+ if(wURIValidateRetCode != SYNCML_DM_COMMAND_ON_NODE)
+ strURI = strPluginURI;
+
+ // check permission to write
+ if (!VerifyArchiveWriteAccess(strURI)) {
+ XPL_LOG_DM_TMN_Error(("archive has no write access for uri %s\n", strURI.c_str()));
+ return (SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+
+ DMNode *psReplacingNode = FindNodeByURI(strURI);
+
+ BOOLEAN bIsEnabled;
+ bIsEnabled = IsUriEnabled(strURI);
+ if(psReplacingNode == NULL) // In this parent doesn't exists
+ {
+
+ if ( bIsEnabled == FALSE )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ else
+ return SYNCML_DM_NOT_FOUND;
+
+ }
+ else
+ {
+ if ( bIsEnabled == FALSE )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+
+ }
+
+ BOOLEAN bInPlugin = FALSE;
+
+ if (psReplacingNode->isPlugin())
+ bInPlugin = TRUE;
+
+ SYNCML_DM_FORMAT_T bFormat;
+ psReplacingNode->GetFormat(strURI, &bFormat);
+
+ // C23495 Verify replace parameters using DDF information
+ //modify the URI sent to plugin by truncating ?prop
+ if( ( wURIValidateRetCode != SYNCML_DM_COMMAND_ON_NODE) &&
+ ( wURIValidateRetCode != SYNCML_DM_COMMAND_ON_FORMAT_PROPERTY)) //So far engine does not replacing FORMAT
+ {
+ oReplaceData.m_nFormat = bFormat;
+ }
+
+ //if (bInPlugin)
+ //pReplace->bFormat = bFormat;
+
+ //Added this check to first see if REPLACE command is allowed on the
+ //TARGET node,only then ACL is checked
+
+ DMMetaPCharVector asChildDepend; // array of child/dependend nodes for indirect updates
+
+ if( !m_oMDFObj.VerifyAccessType(strURI,
+ SYNCML_DM_REPLACE_ACCESS_TYPE,
+ &asChildDepend) )
+ {
+ XPL_LOG_DM_TMN_Debug(("<Replace> Access type is NOT there \n"));
+ return (SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+
+ /**
+ * if ACL is being set for a leaf node, then ACL of the parent node
+ * (or the parent's parent and so on) is used to enforce the replace operation
+ *
+ * If ACL is being set for an interior node, then the ACL of that node is
+ * checked first and if it does not have replace permission, then the parent
+ * node's ACL is checked for enforcement.
+ */
+ BOOLEAN bCheckParent = FALSE;
+
+ if (wURIValidateRetCode == SYNCML_DM_COMMAND_ON_ACL_PROPERTY)
+ {
+ bCheckParent = NeedCheckParent( strURI,
+ psReplacingNode,
+ bInPlugin,
+ bFormat,
+ eRequestType);
+ }
+
+ if( bCheckParent )
+ {
+ DMString strParentURI = strURI, strLastSegment;
+
+ if ( !GetLastSegmentOfURI(strParentURI, strLastSegment) )
+ return SYNCML_DM_DEVICE_FULL;
+
+ wReturnStatusCode = IsValidServer(strParentURI,
+ SYNCML_DM_REPLACE_ACCESS_TYPE,
+ eRequestType,
+ FALSE,
+ TRUE);
+ }
+ else
+ {
+ wReturnStatusCode = IsValidServer(strURI,
+ SYNCML_DM_REPLACE_ACCESS_TYPE,
+ eRequestType,
+ FALSE,
+ TRUE);
+ }
+
+ if(wReturnStatusCode != SYNCML_DM_SUCCESS)
+ return(wReturnStatusCode);
+
+ // The following condition is used check if the server is trying
+ // replace the value of the interior node. which is not possible.
+
+ if((bFormat == SYNCML_DM_FORMAT_NODE) &&
+ (wURIValidateRetCode == SYNCML_DM_COMMAND_ON_NODE))
+ {
+ XPL_LOG_DM_TMN_Debug(("Server is trying to replace the value of an interior node which is NOT allowed \n"));
+ return(SYNCML_DM_COMMAND_NOT_ALLOWED);
+ }
+
+ // that means the URI in the Replace command doesn't have
+ // any property "?prop=..
+
+ if((bFormat != SYNCML_DM_FORMAT_NODE) &&
+ (wURIValidateRetCode == SYNCML_DM_COMMAND_ON_NODE))
+ {
+ wReturnStatusCode = ReplaceNodeInternal( strURI,
+ oReplaceData,
+ psReplacingNode,
+ asChildDepend );
+ }
+ else
+ {
+ wReturnStatusCode = ReplaceProperty( strURI,
+ bInPlugin,
+ strPluginURI,
+ oReplaceData,
+ psReplacingNode,
+ wURIValidateRetCode );
+ }
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+
+ // set timestamp and increment version number
+ if ( ( wReturnStatusCode == SYNCML_DM_SUCCESS ) &&
+ !bInPlugin &&
+ psReplacingNode)
+ {
+ psReplacingNode->SetTStamp(strPluginURI.c_str(), XPL_CLK_GetClock());
+ psReplacingNode->SetVerNo(strPluginURI.c_str(), psReplacingNode->GetVerNo(strPluginURI.c_str()) + 1);
+ }
+#endif
+
+ return(wReturnStatusCode);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : URIValidateAndParse
+// DESCRIPTION : This method validates URI as per RFC 2 and rules
+// specified in TreeNode spec
+//
+// ARGUMENTS PASSED: pbURI :pointer to the URI to be validated
+// RETURN VALUE : SYNCML_DM_URI_RESULT_T indicating validity of URI
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_URI_RESULT_T DMTree::URIValidateAndParse(CPCHAR pbURI) const
+{
+ if ( !pbURI )
+ return SYNCML_DM_COMMAND_INVALID_URI;
+
+ // checks that:
+ // length of each segment is less or equal to GetMaxPathSegmentLength()
+ // number of segments is equal or less than GetMaxPathDepth()
+ int nFullLen = DmStrlen( pbURI );
+ const char* szQpos = DmStrchr( pbURI, SYNCML_DM_QUESTION_MARK);
+ const char* szPathEnd = szQpos ? szQpos : pbURI + nFullLen;
+ int nSegmentsCount = 1;
+ int nSegmentLen = 0;
+
+ if ( (szPathEnd - pbURI) > GetMaxTotalPathLength() )
+ return SYNCML_DM_COMMAND_URI_TOO_LONG;
+
+ if ( (szPathEnd - pbURI) == 0 || (*(szPathEnd -1)) == '/' )
+ return SYNCML_DM_COMMAND_INVALID_URI;
+
+ while ( pbURI <szPathEnd ) {
+ if ( *pbURI == '/' ) { // next segment
+ if ( nSegmentLen > GetMaxPathSegmentLength() )
+ return SYNCML_DM_COMMAND_URI_TOO_LONG;
+
+ if ( !nSegmentLen )
+ return SYNCML_DM_COMMAND_INVALID_URI;
+
+ nSegmentLen = 0;
+ nSegmentsCount++;
+
+ if ( nSegmentsCount > GetMaxPathDepth() )
+ return SYNCML_DM_COMMAND_URI_TOO_LONG;
+
+ } else
+ nSegmentLen++;
+
+ pbURI++;
+ }
+
+ // check optional part after '?'
+ if ( !szQpos )
+ return SYNCML_DM_COMMAND_ON_NODE;
+
+
+ if( DmStrstr(szQpos, SYNCML_DM_PROP) != NULL) {
+ // 6 is the lenth of the "?prop="
+ szQpos += SYNCML_DM_PROP_LENGTH;
+
+ if( DmStrcmp( szQpos, "ACL") == 0)
+ return SYNCML_DM_COMMAND_ON_ACL_PROPERTY;
+
+#ifdef LOB_SUPPORT
+ if( DmStrcmp( szQpos, "ESN") == 0)
+ return SYNCML_DM_COMMAND_ON_ESN_PROPERTY;
+#endif
+ if(DmStrcmp( szQpos, "Format") == 0)
+ return SYNCML_DM_COMMAND_ON_FORMAT_PROPERTY;
+
+ if(DmStrcmp( szQpos, "Name") == 0)
+ return SYNCML_DM_COMMAND_ON_NAME_PROPERTY;
+
+ if(DmStrcmp( szQpos, "Size") == 0)
+ return SYNCML_DM_COMMAND_ON_SIZE_PROPERTY;
+
+ if(DmStrcmp( szQpos, "VerNo") == 0)
+ return SYNCML_DM_COMMAND_ON_VERNO_PROPERTY;
+
+ if(DmStrcmp( szQpos, SYNCML_DM_TITLE) == 0)
+ return SYNCML_DM_COMMAND_ON_TITLE_PROPERTY;
+
+ if(DmStrcmp( szQpos, SYNCML_DM_TYPE) == 0)
+ return SYNCML_DM_COMMAND_ON_TYPE_PROPERTY;
+
+ if(DmStrcmp( szQpos, SYNCML_DM_TSTAMP) == 0)
+ return SYNCML_DM_COMMAND_ON_TSTAMP_PROPERTY;
+
+ return SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY;
+ }
+
+ if (DmStrstr(szQpos, SYNCML_DM_LIST) != NULL) {
+
+ // 6 is the lenth of the "?list="
+ szQpos += SYNCML_DM_LIST_LENGTH;
+
+ if(DmStrcmp(szQpos, SYNCML_DM_STRUCT) == 0)
+ return SYNCML_DM_COMMAND_LIST_STRUCT;
+
+ if(DmStrcmp(szQpos, SYNCML_DM_STRUCT_DATA) == 0)
+ return SYNCML_DM_COMMAND_LIST_STRUCTDATA;
+
+ if(DmStrncmp(szQpos,SYNCML_DM_TNDS, 4) == 0)
+#ifdef TNDS_SUPPORT
+ return SYNCML_DM_COMMAND_LIST_TNDS;
+#else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+#endif
+
+ return SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY;
+ }
+
+ return(SYNCML_DM_COMMAND_INVALID_URI);
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : readOneWordFromTree
+//
+// DESCRIPTION :
+//
+//
+// ARGUMENTS PASSED: None
+// RETURN VALUE :
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+UINT16
+DMTree::readOneWordFromTree(DMNode *pNode, UINT16 defaultValue)
+{
+ UINT16 retData = 0;
+
+ if ( pNode )
+ {
+ if ( pNode->getData() && !(pNode->getData()->empty()) )
+ {
+ retData = DmAtoi((CPCHAR)pNode->getData()->getBuffer());
+ }
+ }
+
+ if(retData == 0)
+ retData = defaultValue;
+
+ return retData;
+}
+
+// Simplified function for deserialize,
+// does not perform lookup, justcreat a child for given node,
+// reutrns newly created node.
+SYNCML_DM_RET_STATUS_T DMTree::AddNode(DMNode **psNodeObject,
+ const DMAddNodeProp & oAddNodeProperties,
+ DMNode* pNewNode )
+{
+ DMNode *pParent = *psNodeObject;
+ BOOLEAN bUpdateNode = TRUE;
+ BOOLEAN bESN = FALSE;
+ CPCHAR tmpSt = NULL;
+
+ SYNCML_DM_RET_STATUS_T res;
+
+ if ( !m_psRoot )
+ return SYNCML_DM_FAIL; // unexpected condition
+
+#ifdef LOB_SUPPORT
+ if((oAddNodeProperties.m_nFlags & DMNode::enum_NodeESN) != 0)
+ { bESN = TRUE;
+ tmpSt =oAddNodeProperties.getESNFileName();
+ }
+#endif
+ // lookup for the node
+ DMNode* pChild = pParent ? pParent->GetChildByName(oAddNodeProperties.getName()) : m_psRoot;
+
+ if ( !pChild )
+ {
+ // node does not exist - create it
+ pChild = pNewNode ? pNewNode : DMTree::CreateNodeObj(oAddNodeProperties.m_nFormat, bESN, tmpSt);
+
+ if ( !pChild )
+ return SYNCML_DM_DEVICE_FULL;
+
+ // add child:
+ pChild->pcParentOfNode = pParent;
+
+ if ( pParent ) {
+ pChild->pcNextSibling = pParent->pcFirstChild;
+ pParent->pcFirstChild = pChild;
+ }
+ } else {
+ if ( pNewNode )
+ delete pNewNode;
+
+ pNewNode = NULL;
+
+ if ( !pChild->IsSkeletonNode() )
+ bUpdateNode = FALSE;
+ }
+
+
+ if ( bUpdateNode )
+ {
+ res = pChild->set(&oAddNodeProperties);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+ }
+
+ *psNodeObject = pChild;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : GetParentOfKeyValue
+// DESCRIPTION : This method returns the name of a parent whose child
+// node's name and value of the child node(leaf node)
+// are passed
+// ARGUMENTS PASSED: pbValueOfKey pointer to value of leaf node
+// pbKey : leaf node's name whose parent's name has to
+// be found
+// RETURN VALUE : UINT8: name of parent node
+// NULL if node does not exist
+// PRE-CONDITIONS : If the node does not exist,parent's name will be
+// returned as NULL
+// POST-CONDITIONS :
+// IMPORTANT NOTES :This API is meant to be used when there can be many
+// instances of a particular interior node and the UA
+// needs to know the name of a parent,given it's child
+// name and value
+//------------------------------------------------------------------------
+BOOLEAN DMTree::GetParentOfKeyValue(CPCHAR pbValueOfKey,
+ CPCHAR pbKey,
+ CPCHAR pbSubtreeURI,
+ DMString& strResult )
+{
+ DMNode *psFindNode = NULL;
+ DMNode *psKeyNode = NULL;
+ SYNCML_DM_RET_STATUS_T wRetStausCode = SYNCML_DM_SUCCESS;
+ DMGetData getData;
+ DMString strPluginURI;
+ DMString strURI;
+
+ if((pbValueOfKey == NULL) || (pbKey == NULL) || (pbSubtreeURI == NULL))
+ {
+ XPL_LOG_DM_TMN_Error(("Invalid Parameters\n"));
+ return FALSE;
+ }
+
+ if ( !GetPluginURI( pbSubtreeURI, strURI, strPluginURI ) )
+ {
+ XPL_LOG_DM_TMN_Error(("cannot parse URI\n"));
+ return FALSE;
+ }
+
+ psFindNode = FindNodeByURI( strURI );
+ if(psFindNode == NULL)
+ {
+ XPL_LOG_DM_TMN_Error(("Node isn't found\n"));
+ return FALSE;
+ }
+
+ psFindNode = psFindNode->pcFirstChild;
+
+ while(psFindNode != NULL)
+ {
+ strURI = pbSubtreeURI;
+ strURI += "/";
+ strURI += psFindNode->abNodeName;
+
+ psKeyNode = FindNodeInNextSiblingsList(psFindNode->pcFirstChild,pbKey);
+ if(psKeyNode != NULL)
+ {
+ strURI += "/";
+ strURI += pbKey;
+
+ wRetStausCode = psKeyNode->Get(strURI, getData);
+
+ if( wRetStausCode == SYNCML_DM_SUCCESS )
+ {
+ if( getData.m_oData.compare(pbValueOfKey) )
+ {
+ strResult = psFindNode->abNodeName;
+ return TRUE;
+ }
+ }
+ }
+ psFindNode = psFindNode->pcNextSibling;
+ }// End of while(psFindNode != NULL)
+
+ XPL_LOG_DM_TMN_Error(("Node isn't found\n"));
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : InitListAndGetListFirstItem
+//
+// DESCRIPTION : This function initializes the list and returns first.
+// item for GetStruct
+//
+// ARGUMENTS PASSED: UINT8 *pbSegment
+// - Pointer to the URI segment.
+// SYNCML_DM_GET_ON_LIST_T bGetOnList
+// - whether get is ?list=Struct or ?list=StructData
+// SYNCML_DM_GET_ON_LIST_RET_DATA_T **ppsReturnData
+// - Contains first item
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// - It returns SYNCML_DM_COMMAND_FAILED incase if
+// the URI is NULL or if root node pointer is NULL
+// or if the URI is invalid.
+// - It returns SYNCML_DM_DEVICE_FULL if the device
+// is out of memory.
+// - It returns SYNCML_DM_SUCCESS if the operation is
+// success.
+// - It returns SYNCML_DM_URI_TOO_LONG if the uri is
+// long.
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::InitListAndGetListFirstItem(
+ CPCHAR pbURI,
+ SYNCML_DM_GET_ON_LIST_T bGetOnList,
+ SYNCML_DM_GET_ON_LIST_RET_DATA_T& ppsReturnData)
+{
+ DMString strFullURI;
+
+
+ if( !GetPluginURI(pbURI, strFullURI, ppsReturnData.m_strStartURI) || ( m_psRoot == NULL))
+ {
+ return(SYNCML_DM_COMMAND_FAILED);
+ }
+
+ ppsReturnData._pbURI = ppsReturnData.m_strStartURI;
+ return GetListItemData( ppsReturnData );
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::GetListItemData(SYNCML_DM_GET_ON_LIST_RET_DATA_T& ppsReturnData)
+{
+
+ DMGetData * pData = NULL;
+ pData = new DMGetData();
+
+ if ( pData == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ ppsReturnData.psRetData = pData;
+ SYNCML_DM_RET_STATUS_T nRes = Get(ppsReturnData._pbURI, *pData ,SYNCML_DM_REQUEST_TYPE_SERVER);
+
+ if ( nRes == SYNCML_DM_SUCCESS && pData->m_nFormat == SYNCML_DM_FORMAT_NODE )
+ {
+
+ DMString strChild( pData->getCharData() );
+ char* szSlash = (char*)DmStrchr(strChild, '/');
+ if ( szSlash )
+ *szSlash = 0;
+ if ( strChild.empty() )
+ ppsReturnData.m_strNextChild = "";
+ else {
+ ppsReturnData.m_strNextChild = ppsReturnData._pbURI;
+ ppsReturnData.m_strNextChild += "/";
+ ppsReturnData.m_strNextChild += strChild;
+ }
+ } else
+ ppsReturnData.m_strNextChild = "";
+
+ return nRes;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetListNextItem
+// DESCRIPTION : The UA calls this to get the entire structure of the
+// subtree.The Tree traverses the subtree and returns
+// the list of names for which the current server has
+// ACL permissions.
+// ARGUMENTS PASSED: dwCommandId command Id
+// bItemNumber
+// pbURI target URI whose subtree structure has to be
+// returned
+// ppsReturnData containing linked list of the names
+// RETURN VALUE : ppsReturnData and SYNCML_DM_RET_STATUS_T
+// SYNCML_DM_SUCCESS if successful
+// else error specific code indicating failure
+// PRE-CONDITIONS : None
+// POST-CONDITIONS : None
+// IMPORTANT NOTES : None
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::GetListNextItem(SYNCML_DM_GET_ON_LIST_RET_DATA_T& ppsReturnData)
+{
+
+ XPL_LOG_DM_TMN_Debug(("DMTree: in the GetListNextItem() for %s\n", ppsReturnData._pbURI.c_str()));
+
+ // look for the next node -
+ // 1. try child
+ if ( !ppsReturnData.m_strNextChild.empty() ) {
+ ppsReturnData._pbURI = ppsReturnData.m_strNextChild;
+ int ret = GetListItemData( ppsReturnData );
+
+ //returns only in case of success; otherwise skip this node and going to take another sibbling (do/while loop)
+ if( ret == SYNCML_DM_SUCCESS ){
+ return ret;
+ }
+ XPL_LOG_DM_TMN_Error(("DMTree: The function GetListItemData() (1) for %s returns error = %d \n", ppsReturnData._pbURI.c_str(), ret ));
+ }
+
+ do {
+ // 2. try next sibling
+ DMString strURI = ppsReturnData._pbURI, strLastSegment;
+
+ if ( !GetLastSegmentOfURI( strURI, strLastSegment ) ) // no parent
+ return SYNCML_DM_SUCCESS;
+
+ // in case of empty node we should not look for sibling...
+ if ( strURI.length() < ppsReturnData.m_strStartURI.length() )
+ return SYNCML_DM_SUCCESS; // no more items
+
+ DMGetData getData;
+
+ SYNCML_DM_RET_STATUS_T nRes = Get(strURI, getData,SYNCML_DM_REQUEST_TYPE_SERVER);
+
+ if ( nRes != SYNCML_DM_SUCCESS )
+ return nRes;
+
+ DMString strAllChildren( getData.getCharData() ), strChild;
+
+ while ( DmStringParserGetItem( strChild, strAllChildren, '/' ) )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMTree: strChild = %s , strAllChildren = %s\n", strChild.c_str(), strAllChildren.c_str() ));
+
+ if ( strChild == strLastSegment ) { // found current node - take next
+
+ while ( DmStringParserGetItem( strChild, strAllChildren, '/' ) )
+ {
+ ppsReturnData._pbURI = strURI;
+ ppsReturnData._pbURI += "/";
+ ppsReturnData._pbURI+= strChild;
+ int ret = GetListItemData( ppsReturnData );
+
+ //returns only in case of success; otherwise skip this node and going to take another sibbling
+ if( ret == SYNCML_DM_SUCCESS ){
+ return ret;
+ }
+ else{
+ XPL_LOG_DM_TMN_Error(("DMTree: The function GetListItemData() (2) for %s returns error = %d \n", ppsReturnData._pbURI.c_str(), ret ));
+ continue;
+ }
+ }
+ break;
+ }
+ }
+
+ // 3. take parent
+ ppsReturnData._pbURI = strURI;
+ if ( strURI.length() <= ppsReturnData.m_strStartURI.length() )
+ return SYNCML_DM_SUCCESS; // no more items
+
+ // goto step 2...
+ } while ( 1 );
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : InitSerializationList
+//
+// DESCRIPTION : This function will allocate and initialize the values
+// of the LIST_STRUCT_OR_STRUCT_DATA_INFO_T psListInfo.
+//
+// ARGUMENTS PASSED:
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// - It returns SYNCML_DM_COMMAND_FAILED if the
+// root node is NULL.
+// - It returns SYNCML_DM_DEVICE_FULL if the device
+// is out of memory.
+// - It returns SYNCML_DM_SUCCESS if the operation is
+// success.
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMTree::InitSerializationList(DMNode * serializeRoot)
+{
+ psListInfo.Clear();
+ psListInfo.psCurrent = serializeRoot;
+ return(SYNCML_DM_SUCCESS);
+}
+
+//------------------------------------------------------------------------
+//
+// FUNCTION : GetSerializationListNextItem
+//
+// DESCRIPTION : This function will return the properties of a node.
+// This function will use DFS algorithm to traverse the
+// tree.
+//
+//
+// ARGUMENTS PASSED: DMNode *psRetNode the node to serialize next
+//
+// RETURN VALUE : SYNCML_DM_SERIALIZATION_STATUS_T
+// -- It returns SYNCML_DM_SERIALIZATION_FAIL
+// if there is any failure.
+// -- It returns SYNCML_DM_SERIALIZATION_SUCCESS
+// if it can retrieve the properties of a node.
+// -- It returns SYNCML_DM_TREE_TRAVERSING_OVER
+// in case if the it has visited all the nodes.
+// in a tree.
+// PRE-CONDITIONS :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_SERIALIZATION_STATUS_T DMTree::
+GetSerializationListNextItem (DMNode **ppsRetNode, INT32& nEndTagsNumber )
+{
+ DMNode *psCurrent = *ppsRetNode;
+
+ nEndTagsNumber = 0;
+ if ( !psCurrent ) {
+ *ppsRetNode = psListInfo.psCurrent;
+ return SYNCML_DM_SERIALIZATION_SUCCESS;
+ }
+
+ // try child first
+ DMNode* pChild = psCurrent->pcFirstChild ?
+ psCurrent->pcFirstChild->GetNextSerializeItem() : NULL;
+
+ if ( pChild ) {
+ *ppsRetNode = pChild;
+ return SYNCML_DM_SERIALIZATION_SUCCESS;
+ }
+
+ // look up for sibling of the parent including self
+ DMNode *pParent = psCurrent;
+
+ while ( pParent != psListInfo.psCurrent ) {
+ // try next sibling after that
+ DMNode *pNextSibling = pParent->pcNextSibling ?
+ pParent->pcNextSibling->GetNextSerializeItem() : NULL;
+
+ nEndTagsNumber++; // even sibling required at least one "end" tag
+
+ if ( pNextSibling ) {
+ *ppsRetNode = pNextSibling;
+ return SYNCML_DM_SERIALIZATION_SUCCESS;
+ }
+
+ // take parent
+ pParent = pParent->pcParentOfNode;
+ }
+
+ // not found
+ return SYNCML_DM_TREE_TRAVERSING_OVER;
+}
+
+SyncML_DM_Archive* DMTree::GetArchive(const DMNode * node)
+{
+ const DMNode * tmpNode=node;
+ while (tmpNode != NULL && tmpNode->pArchive == NULL)
+ {
+ tmpNode=tmpNode->pcParentOfNode;
+ }
+
+ return tmpNode ? tmpNode->pArchive : NULL;
+}
+
+DMNode* DMTree::CreateNodeObj( SYNCML_DM_FORMAT_T bFormat, BOOLEAN isESN, CPCHAR pbFileName )
+{
+ switch ( bFormat )
+ {
+ case SYNCML_DM_FORMAT_NODE:
+ return(new DMDefaultInteriorNode);
+
+ case SYNCML_DM_FORMAT_NODE_PDATA:
+ return(new DMOverlayPINode);
+
+ default:
+#ifdef LOB_SUPPORT
+ if(isESN)
+ return( new DMDefaultESN(pbFileName));
+ else
+#endif
+ return(new DMDefaultLeafNode);
+ }
+}
+
+DMNode* DMTree::CreateSkeletonNode( CPCHAR pbURI )
+{
+ DMString strURI = pbURI;
+ char *szURI = strURI.GetBuffer();
+ const char *pbURISegment = GetURISegment(&szURI);
+
+ if ( !m_psRoot ) {
+ m_psRoot = DMTree::CreateNodeObj(SYNCML_DM_FORMAT_NODE, FALSE, NULL);
+
+ if ( !m_psRoot )
+ return NULL; // out of memory
+
+ m_psRoot->abNodeName = pbURISegment; // it should be "."
+ m_psRoot->setFlags( DMNode::enum_NodeSkeleton );
+ }
+
+ DMNode *psParentNode = m_psRoot;
+
+ pbURISegment = GetURISegment(&szURI); // skip dot
+
+ while( pbURISegment ) {
+
+ DMNode *pChild = psParentNode->GetChildByName(pbURISegment);
+
+ if ( !pChild ) {
+ pChild = DMTree::CreateNodeObj(SYNCML_DM_FORMAT_NODE, FALSE, NULL);
+
+ if ( !pChild )
+ return NULL; // out of memory
+
+ pChild->abNodeName = pbURISegment;
+ pChild->setFlags( DMNode::enum_NodeSkeleton );
+
+ pChild->pcParentOfNode = psParentNode;
+
+ pChild->pcNextSibling = psParentNode->pcFirstChild;
+ psParentNode->pcFirstChild = pChild;
+ }
+
+ psParentNode = pChild;
+ pbURISegment = GetURISegment(&szURI);
+ }
+ return psParentNode;
+}
+
+// function "detaches" old node from the tree and inserts new node in the same place.
+void DMTree::SubstituteNode( DMNode* pOldNode, DMNode* pNewNode )
+{
+ // parent
+ if ( pOldNode->pcParentOfNode && pOldNode->pcParentOfNode->pcFirstChild == pOldNode )
+ pOldNode->pcParentOfNode->pcFirstChild = pNewNode;
+
+ // prev sibling
+ DMNode *pNode = pOldNode->pcParentOfNode ? pOldNode->pcParentOfNode->pcFirstChild : NULL;
+
+ while ( pNode )
+ {
+ if ( pNode->pcNextSibling == pOldNode )
+ pNode->pcNextSibling = pNewNode;
+
+ pNode = pNode->pcNextSibling;
+ }
+
+ // children
+ pNode = pOldNode->pcFirstChild;
+ while ( pNode )
+ {
+ pNode->pcParentOfNode = pNewNode;
+
+ pNode = pNode->pcNextSibling;
+ }
+
+}
+
+/**
+ * Get the immediate children of a node based on the desired node type.
+ *
+ * @author Andy
+ * @param uri the URI to the node E.g. ./DevInfo
+ * @param childrenMap the map that will hold the URI of the children
+ * and the children
+ * @param nodeType the type of nodes that get store in the map either leaf node
+ * or interior node
+ * @return the status of the operation
+ */
+SYNCML_DM_RET_STATUS_T
+DMTree::getChildren( CPCHAR uri,
+ DMMap<DMString, UINT32>& childrenMap,
+ DMTNM_NODE_TYPE nodeType,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+ SYNCML_DM_RET_STATUS_T eSuccessCode = SYNCML_DM_SUCCESS;
+ DMGetData parentNodeData;
+
+ eSuccessCode = Get(uri, parentNodeData,eRequestType);
+
+ if (eSuccessCode != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_COMMAND_FAILED;
+
+ DMString remindStr = parentNodeData.getCharData(); // children names
+ DMString tmpStr;
+ DMString tmpRootPath = uri;
+ DMString tmpChildPath;
+ DMString sperator = "/";
+ DMGetData * tmpNodeData = NULL;
+
+ // loop through children that seperated by forward slash
+ while(DmStringParserGetItem(tmpStr, remindStr, '/'))
+ {
+ tmpChildPath += tmpRootPath;
+ tmpChildPath += sperator;
+ tmpChildPath += tmpStr;
+
+ tmpNodeData = new DMGetData();
+ if ( tmpNodeData == NULL )
+ {
+ dmFreeGetMap(childrenMap);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ eSuccessCode = Get(tmpChildPath.c_str(), *tmpNodeData,eRequestType); // get child node
+ if (eSuccessCode != SYNCML_DM_SUCCESS)
+ {
+ dmFreeGetMap(childrenMap);
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+
+ if (tmpNodeData->m_nFormat == SYNCML_DM_FORMAT_NODE && nodeType == DMTNM_NODE_INTERIOR)
+ {
+ childrenMap.put(tmpChildPath.c_str(), (UINT32)tmpNodeData);
+ }
+ else
+ if (tmpNodeData->m_nFormat != SYNCML_DM_FORMAT_NODE && nodeType == DMTNM_NODE_LEAF)
+ {
+ childrenMap.put(tmpChildPath.c_str(), (UINT32)tmpNodeData);
+ }
+ else // no match
+ DMGetData::operator delete (tmpNodeData);
+
+ tmpChildPath = NULL;
+ }
+ return eSuccessCode;
+}
+
+/**
+ * Get the immediate leaf children
+ *
+ * @author Andy
+ * @param uri the URI to the node E.g. ./DevInfo
+ * @param childrenMap the map that will hold the URI of the children
+ * and the children
+ * @return the status of the operation
+ */
+SYNCML_DM_RET_STATUS_T
+DMTree::getLeafChildren( CPCHAR uri,
+ DMMap<DMString,
+ UINT32>& childrenMap,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+ return getChildren(uri, childrenMap, DMTNM_NODE_LEAF,eRequestType);
+}
+
+/**
+ * Get the immediate interior children
+ *
+ * @author Andy
+ * @param uri the URI to the node E.g. ./DevInfo
+ * @param childrenMap the map that will hold the URI of the children
+ * and the children
+ * @return the status of the operation
+ */
+SYNCML_DM_RET_STATUS_T
+DMTree::getInteriorChildren( CPCHAR uri,
+ DMMap<DMString,
+ UINT32>& childrenMap,
+ SYNCML_DM_REQUEST_TYPE_T eRequestType)
+{
+ return getChildren(uri, childrenMap, DMTNM_NODE_INTERIOR,eRequestType);
+}
+
+/**
+ * Set the leaf children with the new set of leaf children. If the children already
+ * exist, replace them. If the children are new, add them. If the children were not
+ * in the new set of leaf children, remove them. Since this is a atomic operation,
+ * it will roll back to the original state if any of above operations failed,
+ *
+ * @author Andy
+ * @param uri the URI to the node E.g. ./DevInfo
+ * @param childrenMap the new set of leaf children
+ * @return the status of the operation
+ */
+SYNCML_DM_RET_STATUS_T DMTree::setLeafChildren( CPCHAR uri, DMMap<DMString, UINT32>& childrenMap )
+{
+
+ DMMap<DMString, UINT32> oldChildrenMap;
+ SYNCML_DM_RET_STATUS_T status = SYNCML_DM_SUCCESS;
+
+ status = getLeafChildren(uri,
+ (DMMap<DMString, UINT32>&)oldChildrenMap,
+ SYNCML_DM_REQUEST_TYPE_API);
+
+ if (status != SYNCML_DM_SUCCESS) {
+ dmFreeGetMap((DMMap<DMString, UINT32>&)oldChildrenMap);
+ return status;
+ }
+
+ int numOfNewChildren = childrenMap.size();
+
+ DMVector<INT8> deleteList; // mark the delete on a child for rollback
+ deleteList.set_size(numOfNewChildren);
+ for (int i = 0; i < numOfNewChildren; i++)
+ {
+ deleteList[i] = CLEAN;
+ }
+
+ int numOfOldChildren = oldChildrenMap.size();
+ // mark the action (add or replace) on a child for rollback
+ DMVector<INT8> actionList;
+ actionList.set_size(numOfOldChildren);
+
+ if (numOfNewChildren != 0)
+ {
+ for (int i = 0; i < numOfOldChildren; i++)
+ {
+ actionList[i] = CLEAN;
+ }
+ status = handleNewChildren(oldChildrenMap, (DMMap<DMString, UINT32>&)childrenMap,
+ (INT8*)actionList.get_data(), (INT8*)deleteList.get_data());
+ }
+ else
+ {
+ for (int i = 0; i < numOfOldChildren; i++)
+ {
+ actionList[i] = DIRTY; //mark DIRTY to delete all old leaf children
+ }
+ }
+
+ if (status == SYNCML_DM_SUCCESS)
+ {
+ status = handleOldChildren(oldChildrenMap, (DMMap<DMString, UINT32>&)childrenMap,
+ (INT8*)actionList.get_data(), (INT8*)deleteList.get_data());
+ }
+
+ dmFreeGetMap((DMMap<DMString, UINT32>&)oldChildrenMap);
+ return status;
+}
+
+/**
+ * Loop through the new set of children and compare them with the old set of children
+ * If exist in the old set of children, replace them with new value from the new children.
+ * If not exist, add them. Roll back when any of those operation failed.
+ *
+ * @author Andy
+ * @param oldChildrenMap the old set of leaf children
+ * @param newChildrenMap the new set of leaf children
+ * @param actionList a list that match with the order of the old children in the map. It
+ * marks REPLACED if the child was replaced and marks DIRTY otherwise.
+ * This list will be use to replace back the old value when rollback.
+ *
+ * @param deleteList a list that match with the order of the new children in the map and
+ * marks DELETED if the child is added. This list will be use to delete newly
+ * added node when rollback.
+ * @return the status of the operation
+ */
+SYNCML_DM_RET_STATUS_T DMTree::handleNewChildren( DMMap<DMString, UINT32> oldChildrenMap,
+ DMMap<DMString, UINT32>& newChildrenMap,
+ INT8 actionList[],
+ INT8 deleteList[] )
+{
+ SYNCML_DM_RET_STATUS_T status = SYNCML_DM_SUCCESS;
+ INT32 oldIndex = 0;
+ INT32 newIndex = 0;
+ BOOLEAN found = FALSE;
+
+ for ( DMMap<DMString, UINT32>::POS newIt= newChildrenMap.begin(); newIt < newChildrenMap.end(); newIt++ )
+ {
+ DMAddData *newData = (DMAddData*)newChildrenMap.get_value( newIt );
+
+ // compare the new child with list of old children
+ for ( DMMap<DMString, UINT32>::POS oldIt = oldChildrenMap.begin(); oldIt < oldChildrenMap.end(); oldIt++ )
+ {
+
+ if (actionList[oldIndex] == CLEAN || actionList[oldIndex] != REPLACED)
+ { // if not replaced yet
+ const DMString & oldNodeURI = oldChildrenMap.get_key( oldIt );
+ if ( oldNodeURI == newData->getURI() ) // new child has the same name as the old child
+ {
+ status = Replace( *newData, SYNCML_DM_REQUEST_TYPE_API );
+ if (status != SYNCML_DM_SUCCESS)
+ {
+ SYNCML_DM_RET_STATUS_T rollbackStatus = rollback(oldChildrenMap, newChildrenMap, actionList, deleteList);
+ if (rollbackStatus == SYNCML_DM_SUCCESS)
+ return status;
+ else
+ return rollbackStatus;
+ }
+ actionList[oldIndex] = REPLACED; // mark replece for roll back
+ found = TRUE;
+ break;
+ }
+ else
+ {
+ actionList[oldIndex] = DIRTY; // mark visited
+ }
+ }
+ oldIndex++;
+ }
+
+ if (!found)
+ {
+ status = Add( *newData, SYNCML_DM_REQUEST_TYPE_API );
+ if (status != SYNCML_DM_SUCCESS)
+ {
+ SYNCML_DM_RET_STATUS_T rollbackStatus = rollback(oldChildrenMap, newChildrenMap, actionList, deleteList);
+ if (rollbackStatus == SYNCML_DM_SUCCESS)
+ return status;
+ else
+ return rollbackStatus;
+ }
+ deleteList[newIndex] = DELETED; // mark delete for roll back
+ }
+ else
+ {
+ deleteList[newIndex] = DIRTY; // mark visited
+ }
+ newIndex++;
+ oldIndex = 0;
+ found = FALSE;
+ }
+ return status;
+}
+
+/**
+ * Loop through the old set of children and check if it has been replaced.
+ * If false, delete the child. Roll back when fail to delete.
+ *
+ * @author Andy
+ * @param oldChildrenMap the old set of leaf children
+ * @param newChildrenMap the new set of leaf children
+ * @param actionList a list that match with the order of the old children in the map. It
+ * marks ADDED if the child was added. This list will be use to add back
+ * the old value when rollback.
+ *
+ * @param deleteList a list that match with the order of the new children in the map and
+ * will be use to delete newly added node when rollback.
+ * @return the status of the operation
+ */
+SYNCML_DM_RET_STATUS_T DMTree::handleOldChildren( DMMap<DMString, UINT32> oldChildrenMap,
+ DMMap<DMString, UINT32>& newChildrenMap,
+ INT8 actionList[],
+ INT8 deleteList[] )
+{
+ SYNCML_DM_RET_STATUS_T status = SYNCML_DM_SUCCESS;
+ SYNCML_DM_RET_STATUS_T rollbackStatus = SYNCML_DM_SUCCESS;
+ int oldIndex = 0;
+
+ for ( DMMap<DMString, UINT32>::POS oldIt = oldChildrenMap.begin(); oldIt < oldChildrenMap.end(); oldIt++ )
+ {
+ if (actionList[oldIndex] == DIRTY)
+ { // if has not been replaced means the child is not in the new list
+ const DMString & oldNodeURI = oldChildrenMap.get_key( oldIt );
+ status = Delete( oldNodeURI, SYNCML_DM_REQUEST_TYPE_API );
+ if (status != SYNCML_DM_SUCCESS)
+ {
+ rollbackStatus = rollback(oldChildrenMap, newChildrenMap, actionList, deleteList);
+ if (rollbackStatus == SYNCML_DM_SUCCESS)
+ return status;
+ else
+ return rollbackStatus;
+ }
+ actionList[oldIndex] = ADDED; // mark for add back on roll back
+ }
+ oldIndex++;
+ }
+ return status;
+}
+
+/**
+ * Rollback operation for SetLeafChildren. It will replace the replaced children
+ * with original values. It will delete the added children. It will add back
+ * the delete children.
+ *
+ * @author Andy
+ * @param oldChildrenMap the old set of leaf children
+ * @param newChildrenMap the new set of leaf children
+ * @param actionList a list that match with the order of the old children in the map. It marks
+ * the children with REPLACED means replace with the children with old children
+ * It marks children with ADDED means add back the old children to the parent.
+ *
+ * @param deleteList a list that match with the order of the new children in the map.
+ * DELETED mark mean delete the child
+ * @return the status of the operation
+ */
+SYNCML_DM_RET_STATUS_T DMTree::rollback( DMMap<DMString, UINT32> oldChildrenMap,
+ DMMap<DMString, UINT32>& newChildrenMap,
+ INT8 actionList[],
+ INT8 deleteList[] )
+{
+ int i = 0;
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ DMAddData oldData;
+
+ // unreplace and add back
+ for ( DMMap<DMString, UINT32>::POS oldIt = oldChildrenMap.begin(); oldIt < oldChildrenMap.end(); oldIt++ )
+ {
+ if (actionList[i] != CLEAN)
+ {
+ oldData.clear();
+ DMGetData* oldGetData = (DMGetData*)oldChildrenMap.get_value( oldIt );
+ retStatus = oldData.set(oldChildrenMap.get_key(oldIt),
+ oldGetData->m_nFormat,
+ (CPCHAR)oldGetData->m_oData.getBuffer(),
+ oldGetData->m_oData.getSize(),
+ oldGetData->getType());
+ if (retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ if (actionList[i] == REPLACED)
+ { // replace back
+ retStatus = Replace( oldData, SYNCML_DM_REQUEST_TYPE_API );
+ if (retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ }
+ else
+ if (actionList[i] == ADDED)
+ { // add back
+ retStatus = Add( oldData, SYNCML_DM_REQUEST_TYPE_API );
+ if (retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ }
+ }
+ else
+ {
+ break; // didn't touch the node, so stop over here
+ }
+ i++;
+ }
+
+ i = 0;
+ // delete added nodes
+ for ( DMMap<DMString, UINT32>::POS newIt = newChildrenMap.begin(); newIt < newChildrenMap.end(); newIt++ )
+ {
+ if (deleteList[i] != CLEAN)
+ {
+ if (deleteList[i] == DELETED)
+ {
+ retStatus = Delete(((DMAddData*)newChildrenMap.get_value( newIt ))->getURI(),
+ SYNCML_DM_REQUEST_TYPE_API);
+ if (retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ }
+ }
+ else
+ {
+ break; // didn't touch the node, so stop over here
+ }
+ i++;
+ } // end for loop
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+/*==================================================================================================
+Function: GetSubNodeValue
+
+Description: This method is called to retrieve the a value from beneath the DMAcc node for the
+ current Server.)
+ARGUMENT PASSED : pParentName
+ pSubNode
+
+OUTPUT PARAMETER: ppDmaccData
+RETURN VALUE : SYNCML_DM_SUCCESS or SYNCML_DM_FAIL
+IMPORTANT NOTES : This method assumes the DM Tree is locked and the management session is in
+ progress.
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMTree::GetAccNodeValue (CPCHAR pParentName,
+ CPCHAR pSubNode,
+ DMGetData & oAccData)
+{
+ return Get( ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH ) +
+ DMString( DM_STR_SLASH ) +
+ pParentName +
+ DM_STR_SLASH +
+ pSubNode,
+ oAccData,
+ SYNCML_DM_REQUEST_TYPE_INTERNAL );
+
+}
+
+
+/**
+ * Get the default server address information
+ *
+ * @param pAccProfileName the DMAcc node name
+ * @param oAddr the object that will hold the server address
+ * @param oAddrType the object that will hold the server address type, valud values are "URI", "IPv4"or "IPv6"
+ * @param oPortNbr the object that will hold the port address, pPortNbr.oData.getSize() is zero if PortNbr node not found or not set
+ * @return the status of the operation
+ **/
+SYNCML_DM_RET_STATUS_T
+DMTree::GetDefAccountAddrInfo(CPCHAR pAccProfileName,
+ DMGetData & oAddr,
+ DMGetData & oAddrType,
+ DMGetData & oPortNbr)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_FAIL;
+
+ if ( m_bVersion_1_2 == TRUE )
+ {
+ DMString strNodeURI = ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH ) +
+ DMString( DM_STR_SLASH ) +
+ pAccProfileName +
+ DM_STR_SLASH +
+ DM_APPADDR;
+
+ DMMap<DMString, UINT32> addrNodesMap;
+
+ dm_stat = getInteriorChildren( strNodeURI, addrNodesMap, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ dmFreeGetMap((DMMap<DMString, UINT32>&)addrNodesMap);
+ return SYNCML_DM_FAIL;
+ }
+
+ if( addrNodesMap.size() == 0 )
+ {
+ dmFreeGetMap((DMMap<DMString, UINT32>&)addrNodesMap);
+ return SYNCML_DM_NOT_FOUND;
+ }
+
+ while ( true )
+ {
+ DMMap<DMString, UINT32>::POS iter = addrNodesMap.begin();
+ DMString addrNodeName = addrNodesMap.get_key(iter);
+
+ addrNodeName += DM_STR_SLASH;
+
+ dm_stat = Get( addrNodeName + DM_ADDR, oAddr, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ if ( dm_stat != SYNCML_DM_SUCCESS ) {
+ break;
+ }
+
+ // Get the Addr Type
+ dm_stat = Get(addrNodeName + DM_ADDRTYPE, oAddrType, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ // session will set to default (1=http) if null
+ oAddrType.set(SYNCML_DM_FORMAT_CHR, "1", 1, NULL);
+ }
+
+ // Get the portNbrs if any is specified
+ DMMap<DMString, UINT32>portNbrNodesMap;
+ dm_stat = getInteriorChildren( addrNodeName + DM_PORT, portNbrNodesMap, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ // if there are no child nodes, but this is OK since portNbr is optional
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ DMString dummyStr = NULL;
+ oPortNbr.set(SYNCML_DM_FORMAT_NULL, dummyStr, 0, NULL);
+ dmFreeGetMap((DMMap<DMString, UINT32>&)addrNodesMap);
+ return SYNCML_DM_SUCCESS;
+ }
+
+ // if portNbr node is present, retrieve its value
+ iter = portNbrNodesMap.begin();
+ DMString portNbrName = portNbrNodesMap.get_key(iter);
+
+ dm_stat = Get(portNbrName + DM_STR_SLASH + DM_PORTNBR, oPortNbr, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ DMString dummyStr = NULL;
+ oPortNbr.set(SYNCML_DM_FORMAT_NULL, dummyStr, 0, NULL);
+ }
+
+ dmFreeGetMap((DMMap<DMString, UINT32>&)addrNodesMap);
+ dmFreeGetMap((DMMap<DMString, UINT32>&)portNbrNodesMap);
+ return SYNCML_DM_SUCCESS;
+ }
+
+ // Got here because something went wrong
+ dmFreeGetMap((DMMap<DMString, UINT32>&)addrNodesMap);
+ }
+ else
+ {
+ /* Fill the pNodeUri with the string "./SyncML/DMAcc/<pAccProfileName>/AppAddr" */
+ DMString strNodeURI = ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH ) +
+ DMString( DM_STR_SLASH ) +
+ pAccProfileName +
+ DM_STR_SLASH;
+
+ dm_stat = Get(strNodeURI + DM_ADDR, oAddr, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ dm_stat = Get( strNodeURI + DM_ADDRTYPE, oAddrType, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ dm_stat = Get( strNodeURI + DM_PORTNBR, oPortNbr, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( SYNCML_DM_NOT_FOUND == dm_stat )
+ {
+ // DM: optional, set to default if not found
+ DMString dummyStr = NULL;
+ oPortNbr.set(SYNCML_DM_FORMAT_NULL, dummyStr, 0, NULL);
+ dm_stat = SYNCML_DM_SUCCESS;
+ }
+ }
+ }
+ }
+
+ return dm_stat;
+}
+
+/**
+ * Get the server authentication information in the specified DMAcc profile
+ *
+ * @param pAccProfileName the DMAcc node name
+ * @param oAuthType the object that will hold the authentication type
+ * @param oAuthName the object that will hold the authentication name
+ * @param oAuthSecret the object that will hold the authentication secret
+ * @param oAuthData the object that will hold the authentication data
+ * @param sAuthDataUri the DMString object that will hold the full server AAuthData (nonce) URI
+ * @return the status of the operation
+ **/
+SYNCML_DM_RET_STATUS_T
+DMTree::GetServerAuthInfo(CPCHAR pAccProfileName,
+ CPCHAR pAuthType,
+ DMGetData& oAuthName,
+ DMGetData& oAuthSecret,
+ DMGetData& oAuthData,
+ DMString& oAuthDataUri)
+{
+ DMGetData oAuthType; // dummy parameter
+
+ return this->GetAuthInfo(pAccProfileName,
+ DM_AUTHLEVEL_SRVCRED,
+ pAuthType,
+ oAuthType,
+ oAuthName,
+ oAuthSecret,
+ oAuthData,
+ oAuthDataUri);
+}
+
+/**
+ * Get the HTTP authentication information in the specified DMAcc profile
+ *
+ * @param pAccProfileName the DMAcc node name
+ * @param oAuthType the object that will hold the authentication type
+ * @param oAuthName the object that will hold the authentication name
+ * @param oAuthSecret the object that will hold the authentication secret
+ * @param oAuthData the object that will hold the authentication data
+ * @return the status of the operation
+ **/
+SYNCML_DM_RET_STATUS_T
+DMTree::GetHttpAuthInfo(CPCHAR pAccProfileName,
+ DMGetData& oAuthType,
+ DMGetData& oAuthName,
+ DMGetData& oAuthSecret,
+ DMGetData& oAuthData,
+ DMString& oAuthDataUri)
+{
+ return this->GetAuthInfo(pAccProfileName,
+ DM_AUTHLEVEL_HTTP,
+ NULL,
+ oAuthType,
+ oAuthName,
+ oAuthSecret,
+ oAuthData,
+ oAuthDataUri);
+}
+
+/**
+ * Get the client authentication information matching the specified authentication type
+ *
+ * @param pAccProfileName the DMAcc node name
+ * @param pAuthType the required client authentication type
+ * @param oAuthName the object that will hold the authentication name
+ * @param oAuthSecret the object that will hold the authentication secret
+ * @param oAuthData the object that will hold the authentication data
+ * @param sAuthDataUri the DMString object that will hold the full client AAuthData (nonce) URI
+ * @return the status of the operation
+ **/
+SYNCML_DM_RET_STATUS_T
+DMTree::GetClientAuthInfo(CPCHAR pAccProfileName,
+ CPCHAR pAuthType,
+ DMGetData& oAuthName,
+ DMGetData& oAuthSecret,
+ DMGetData& oAuthData,
+ DMString& oAuthDataUri,
+ DMGetData& oAuthType)
+{
+ return this->GetAuthInfo(pAccProfileName,
+ DM_AUTHLEVEL_CLCRED,
+ pAuthType,
+ oAuthType,
+ oAuthName,
+ oAuthSecret,
+ oAuthData,
+ oAuthDataUri);
+}
+
+/**
+ * Get the authentication information matching the specified authentication level and type
+ *
+ * @param pAccProfileName the DMAcc node name
+ * @param pAuthLevel the required authentication level, should be either "CLCRED","SRVCRED","OBEX" or "HTTP"
+ * @param pAuthType the required authentication type, should be either "HTTP-BASIC", "HTTP-DIGEST", "TRANSPORT", "HMAC", "DIGEST" or "BASIC". NULL if no specific type is required, then the first node with matching authentication level is returned
+ * @param oAuthType the object that will hold the authentication type
+ * @param oAuthName the object that will hold the authentication name
+ * @param oAuthSecret the object that will hold the authentication secret
+ * @param oAuthData the object that will hold the authentication data
+ * @param sAuthDataUri the DMString object that will hold the full AAuthData (nonce) URI
+ * @return the status of the operation
+ **/
+SYNCML_DM_RET_STATUS_T
+DMTree::GetAuthInfo(CPCHAR pAccProfileName,
+ CPCHAR pAuthLevel,
+ CPCHAR pAuthType,
+ DMGetData& oAuthType,
+ DMGetData& oAuthName,
+ DMGetData& oAuthSecret,
+ DMGetData& oAuthData,
+ DMString& oAuthDataUri)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_FAIL;
+ CPCHAR szDMAccRootPath = ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH );
+
+ oAuthDataUri = NULL;
+
+ if ( m_bVersion_1_2 == TRUE )
+ {
+ /* Fill the pNodeUri with the string "./SyncML/DMAcc/<pAccProfileName>/AppAuth" */
+ DMString strAPPAUTHNodeUri = szDMAccRootPath +
+ DMString( DM_STR_SLASH ) +
+ pAccProfileName +
+ DM_STR_SLASH +
+ DM_APPAUTH;
+
+ DMMap<DMString, UINT32> authNodesMap;
+
+ dm_stat = getInteriorChildren( strAPPAUTHNodeUri, authNodesMap,SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ // if there are no child nodes, no client authentication nodes are found
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ dmFreeGetMap((DMMap<DMString, UINT32>&)authNodesMap);
+ return SYNCML_DM_FAIL;
+ }
+
+ for ( DMMap<DMString, UINT32>::POS iter= authNodesMap.begin();
+ iter < authNodesMap.end();
+ iter++ )
+ {
+ dm_stat = SYNCML_DM_FAIL;
+
+ DMString authNodeName = authNodesMap.get_key(iter);
+ DMString strAPPAUTHInstPath = authNodeName + DM_STR_SLASH;
+ DMString authLevelUri(strAPPAUTHInstPath + DM_AAUTHLEVEL);
+ DMString authTypeUri(strAPPAUTHInstPath + DM_AAUTHTYPE);
+ DMString authNameUri(strAPPAUTHInstPath + DM_AAUTHNAME);
+ DMString authSecretUri(strAPPAUTHInstPath + DM_AAUTHSECRET);
+ DMString authDataUri(strAPPAUTHInstPath + DM_AAUTHDATA);
+ DMGetData authLevel;
+
+ dm_stat = Get(authLevelUri.c_str(), authLevel, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( ( dm_stat == SYNCML_DM_SUCCESS ) &&
+ ( DmStrcmp(authLevel.getCharData(), pAuthLevel) == 0 ) )
+ {
+ dm_stat = Get(authTypeUri.c_str(), oAuthType, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( pAuthType == NULL || strlen(pAuthType) == 0 ||
+ (oAuthType.getCharData() != NULL && DmStrcmp( oAuthType.getCharData(), pAuthType) == 0) )
+ {
+ dm_stat = Get(authNameUri.c_str(), oAuthName, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ dm_stat = Get(authSecretUri.c_str(), oAuthSecret, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ dm_stat = Get(authDataUri.c_str(), oAuthData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ }
+ }
+
+ oAuthDataUri = strAPPAUTHInstPath;
+ break;
+ }
+ }
+ }
+
+ if (0 == oAuthDataUri.length())
+ {
+ // DM: no matching AUTHINFO is found
+ dm_stat = SYNCML_DM_FAIL;
+ }
+
+ dmFreeGetMap((DMMap<DMString, UINT32>&)authNodesMap);
+ }
+ else
+ {
+ DMString strNodeURI = szDMAccRootPath +
+ DMString( DM_STR_SLASH ) +
+ pAccProfileName +
+ DM_STR_SLASH;
+
+ DMString authNameUri(strNodeURI);
+ DMString authSecretUri(strNodeURI);
+ DMString authDataUri(strNodeURI);
+ DMString authTypeUri(strNodeURI);
+ BOOLEAN bClientAuth = ( DmStrcmp(pAuthLevel,DM_AUTHLEVEL_CLCRED) == 0 );
+
+ if ( bClientAuth )
+ {
+ authTypeUri += DM_AUTHPREF;
+ authNameUri += DM_USERNAME;
+ authSecretUri += DM_CLIENTPW;
+ authDataUri += DM_CLIENTNONCE;
+
+ dm_stat = Get(authTypeUri.c_str(), oAuthType, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ }
+ else
+ {
+ authNameUri += DM_NAME;
+ authSecretUri += DM_SERVERPW;
+ authDataUri += DM_SERVERNONCE;
+
+ dm_stat = SYNCML_DM_SUCCESS;
+ }
+
+ if ( dm_stat == SYNCML_DM_SUCCESS || dm_stat == SYNCML_DM_NOT_FOUND )
+ {
+ dm_stat = Get(authNameUri.c_str(), oAuthName, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ dm_stat = Get(authSecretUri.c_str(), oAuthSecret, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ dm_stat = Get(authDataUri.c_str(), oAuthData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ }
+ }
+ }
+
+ oAuthDataUri = strNodeURI;
+ }
+
+ return dm_stat;
+}
+
+/**
+ * Get the authentication type used by the last DM session
+ *
+ * @param pAccProfileName the DMAcc node name
+ * @param oClientAuthType the object that will hold the client authentication type
+ * @return the status of the operation
+ **/
+SYNCML_DM_RET_STATUS_T
+DMTree::GetLastClientAuthType(CPCHAR pAccProfileName,
+ DMGetData& oClientAuthType)
+{
+ return Get( ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH ) +
+ DMString( DM_STR_SLASH ) +
+ pAccProfileName +
+ DM_STR_SLASH +
+ DM_EXT +
+ DM_STR_SLASH +
+ DM_LASTCLIENTAUTHTYPE,
+ oClientAuthType,
+ SYNCML_DM_REQUEST_TYPE_INTERNAL);
+}
+/**
+ * Set the authentication type used by the last DM session
+ *
+ * @param pAccProfileName the DMAcc node name
+ * @param pClientAuthType the client authentication type value to set
+ * @return the status of the operation
+ **/
+SYNCML_DM_RET_STATUS_T
+DMTree::SetLastClientAuthType(CPCHAR pAccProfileName,
+ CPCHAR pClientAuthType)
+{
+ DMAddData oNodeData;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ DMString strEXTURI = ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH ) +
+ DMString( DM_STR_SLASH ) +
+ pAccProfileName +
+ DM_STR_SLASH +
+ DM_EXT;
+
+ DMString strLastClientAuthURI = strEXTURI +
+ DM_STR_SLASH +
+ DM_LASTCLIENTAUTHTYPE;
+
+ dm_stat = oNodeData.set( strEXTURI,
+ SYNCML_DM_FORMAT_NODE,
+ NULL,
+ 0,
+ "text/plain");
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ Add(oNodeData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ }
+
+ dm_stat = oNodeData.set(strLastClientAuthURI,
+ SYNCML_DM_FORMAT_CHR,
+ pClientAuthType,
+ DmStrlen(pClientAuthType),
+ "text/plain" );
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ dm_stat = Replace(oNodeData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+
+ if ( dm_stat == SYNCML_DM_NOT_FOUND )
+ {
+ dm_stat = Add(oNodeData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ }
+ }
+
+ return dm_stat;
+}
+
+#ifdef LOB_SUPPORT
+/*==============================================================================
+FUNCTION : IsESN
+
+DESCRIPTION : Is it a External Storage Node
+
+ARGUMENT PASSED : pNodeValue,
+ nodeLength,
+ pNode
+ pNodeName
+OUTPUT PARAMETER:
+RETURN VALUE :
+IMPORTANT NOTES :
+==============================================================================*/
+SYNCML_DM_RET_STATUS_T
+DMTree::IsESN(CPCHAR pbURI, BOOLEAN &isESN)
+{
+ DMString strPluginURI; // uri without ?xxx stuff for plugins and so on
+ DMString strURI;
+
+ if ( !GetPluginURI( pbURI, strURI, strPluginURI ) )
+ return SYNCML_DM_COMMAND_FAILED;
+
+ isESN = m_oMDFObj.IsESN( strPluginURI );
+ return SYNCML_DM_SUCCESS;
+}
+#endif
+
+DMMetaDataManager& DMTree::GetMetaDataManager()
+{
+ return m_oMDFObj;
+}
diff --git a/engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_ESN_class.cc b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_ESN_class.cc
new file mode 100644
index 0000000..fac4616
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_ESN_class.cc
@@ -0,0 +1,658 @@
+#ifdef LOB_SUPPORT
+//------------------------------------------------------------------------
+//
+// Module Name: dm_tree_default_ESN_class.cc
+//
+// General Description:Contains the implementations of the methods of
+// DMDefaultESN class.
+//------------------------------------------------------------------------
+// Revision History:
+// Modification Tracking
+// Author (core ID) Date Number Description of Changes
+//c23495 11/29/2006 libgg67059 LOB support
+// cdp180 03/16/2007 LIBll55345 Removing ACL check for internal calls
+// ----------------- ------------ ---------- -------------------------
+// Portability: This module is portable to other compilers.
+//------------------------------------------------------------------------
+// INCLUDE FILES
+//------------------------------------------------------------------------
+#include "dmdefs.h"
+#include "dm_tree_default_ESN_class.H" //header file for class defn
+#include "dm_tree_util.h" //FillgetRetData
+#include "xpl_File.h"
+#include "dm_uri_utils.h"
+
+//------------------------------------------------------------------------
+// LOCAL FUNCTION PROTOTYPES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL CONSTANTS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+// LOCAL MACROS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL VARIABLES
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+// GLOBAL VARIABLES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL FUNCTIONS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// GLOBAL FUNCTIONS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+
+//default constructor
+DMDefaultESN::DMDefaultESN(CPCHAR pbFileName):DMDefaultLeafNode()
+{
+ abStorageName = NULL;
+ abOriginalName = (pbFileName != NULL) ? pbFileName : NULL;
+
+ totalSize = 0L;
+ m_bSetComplete = TRUE;
+ m_bDirty = FALSE;
+ m_bNeedLogging = FALSE;
+
+ fileHandle = NULL;
+ offset = 0L;
+ // Mark as ESN
+ SetESN();
+}
+// Destructor for ESN
+DMDefaultESN::~DMDefaultESN()
+{
+ CloseInternalFile();
+ abStorageName = NULL;
+ abOriginalName = NULL;
+}
+// Get internal storage file name
+CPCHAR DMDefaultESN::GetInternalStorageFileName(void) const
+{
+ return (abStorageName != NULL) ? abStorageName.c_str() : NULL;
+
+}
+CPCHAR DMDefaultESN::GetOriginalInternalFileName(void) const
+{
+ return (abOriginalName != NULL) ? abOriginalName.c_str() : NULL;
+}
+/*==================================================================================================
+ * Function: : Close intenal storage file
+ * param:
+ * return : Return SYNCML_DM_SUCCESS if file open successfull and others in case of error
+*==================================================================================================
+*/
+SYNCML_DM_RET_STATUS_T DMDefaultESN::CloseInternalFile(void)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ if (fileHandle != NULL)
+ {
+ fileHandle->close();
+ delete fileHandle;
+ fileHandle = NULL;
+ }
+ return retStatus;
+}
+/*==================================================================================================
+ * Function: : Open intenal storage file
+ * param:
+ * return : Return SYNCML_DM_SUCCESS if file open successfull and others in case of error
+*==================================================================================================
+*/
+
+SYNCML_DM_RET_STATUS_T DMDefaultESN::OpenInternalStorageFile()
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ // If the file is not opened before
+ if(fileHandle == NULL)
+ {
+ DMString abESNFileName;
+
+ if(abStorageName.length() != 0)
+ abESNFileName = abStorageName;
+ else
+ abESNFileName = abOriginalName;
+
+ if(abESNFileName.length() != 0) {
+
+ INT32 modeFlag = XPL_FS_FILE_RDWR;
+ // If file does not exist use write mode instead of read/write to prevent file I/O error
+ if (!XPL_FS_Exist(abESNFileName.c_str()))
+ {
+ modeFlag = XPL_FS_FILE_WRITE;
+ }
+ fileHandle = new DMFileHandler(abESNFileName.c_str(), FALSE);
+ if (fileHandle == NULL)
+ return SYNCML_DM_IO_FAILURE;
+ if (fileHandle->open(modeFlag) != SYNCML_DM_SUCCESS)
+ {
+ fileHandle->deleteFile();
+ delete fileHandle;
+ fileHandle = NULL;
+ return SYNCML_DM_IO_FAILURE;
+ }
+ totalSize = fileHandle->size();
+ }
+ else
+ totalSize = 0;
+ }
+ return retStatus;
+}
+//------------------------------------------------------------------------
+// FUNCTION : Add
+// DESCRIPTION : This function sets the ACCESS type and format
+// properties for an Interior node added in the tree.
+// No data involved ,so synchronous Non-blocking call
+// callback function pointers will be ignored
+// ARGUMENTS PASSED: *psAdd,
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : status code
+// PRE-CONDITIONS : 1.URI has already been validated
+// 2.The node object of the plug-in class has been
+// created and a reference has been given to DMTNM
+// POST-CONDITIONS : Following property values are set by the function
+// Format = SYNCML_DM_FORMAT_NODE
+// IMPORTANT NOTES : The default Leaf node class grants all Access
+// rights to the Node in Add
+// If a Plug-in needs to implement a class for interior
+// nodes in which the access type needs to be plug-in
+// specific Ex: that plug-in does not want to give
+// delete access type, then the plug-in SHALL implement
+// it's own Add accordingly.
+// REQUIREMENT # : ESR-DMTNM0042-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN::Add(DMAddData & oAddData)
+{
+ return set(&oAddData);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Delete
+// DESCRIPTION : This function should not actually not get called.
+// since DMTNM deletes the node object.It is a pure
+// virtual function in DMNode,hence is implemented and
+// returns SYNCML_DM_SUCCESS
+// ARGUMENTS PASSED: waitMsgForStatus
+// replyStatusCback
+// dwCommandId,
+// bItemNumber,
+// *pbUri,
+// oIsThisAtomic,
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : ALWAYS returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS : DMTNM actually deletes the node object
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0025-m to ESR-DMTNM0027-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN::Delete(CPCHAR pbUri)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+
+ // Remoeve temporary file
+ if(m_bDirty)
+ {
+ retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ retStatus = fileHandle->deleteFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ delete fileHandle;
+ fileHandle = NULL;
+ }
+ return CloseInternalFile();
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : Get
+// DESCRIPTION :
+// ARGUMENTS PASSED: waitMsgForGetdata
+// waitMsgForGetdata
+// dwCommandId,
+// bItemNumber,
+// *pbUri,
+// dwStartByte,
+// dwNBytes
+// **ppsReturnData
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : ALWAYS returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : The DMTNM will return the list of child names(if
+// the interior node has no children it will return
+// an empty list
+// REQUIREMENT # : ESR-DMTNM0028-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN::Get(CPCHAR pbUri, DMGetData & oReturnData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ // Set ESN flag
+ oReturnData.SetESN(TRUE);
+
+ if(oReturnData.chunkData != NULL)
+ {
+ if(m_bSetComplete == FALSE)
+ return SYNCML_DM_ESN_SET_NOT_COMPLETE;
+
+ offset = oReturnData.m_chunkOffset;
+ if(oReturnData.m_chunkOffset ==0)
+ retStatus = GetFirstChunk(*oReturnData.chunkData);
+ else
+ retStatus = GetNextChunk(*oReturnData.chunkData);
+ }
+ else
+ {
+ retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ retStatus = DMDefaultLeafNode::Get(pbUri, oReturnData);
+ oReturnData.m_TotalSize = totalSize;
+ }
+ return retStatus;
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : GetFormat
+//
+// DESCRIPTION : This function returns FORMAT of the node
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE : ALWAYS returns SYNCML_DM_FORMAT_NODE
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0033-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN::GetFormat(CPCHAR pbUri,
+ SYNCML_DM_FORMAT_T *dwpRetPropertyData)
+{
+ *dwpRetPropertyData = this->bFormat;
+ return(SYNCML_DM_SUCCESS);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetType
+// DESCRIPTION : This function returns MIME type
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE : status code,type is NULL for interior nodes
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0033-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN::GetType(CPCHAR pbUri,
+ DMString& strType)
+{
+ strType = this->getType();
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetSize
+// DESCRIPTION : This function returns SIZE of the node.
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE :
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN ::GetSize(CPCHAR pbUri,
+ UINT32 *dwpRetPropertyData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ *dwpRetPropertyData= totalSize;
+ return(SYNCML_DM_SUCCESS);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Rename
+// DESCRIPTION : This function is called when a node's name has
+// been changed
+// ARGUMENTS PASSED: *pbUri,
+// pNewNodeName
+// RETURN VALUE : ALWAYS returns SYNCML_DM_SUCCESS
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : The node Name will be renamed by the DMTNM.It informs
+// the plug-in about this to allow the plug-in to change
+// the name in the data-base correspondingly.Since
+// Interior nodes in this class have no database this
+// method simply returns SYNCML_DM_SUCCESS.This means that
+// name of node will be renamed by DMTNM,and plug-in
+// does not have anything specific to do.
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN::Rename(CPCHAR pbUri,
+ CPCHAR pNewNodeName)
+{
+ return(SYNCML_DM_SUCCESS);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Replace
+//
+// DESCRIPTION : This function is called when a node's value has
+// to be replaced.
+// ARGUMENTS PASSED: waitMsgForStatus,
+// replyStatusCback,
+// dwCommandId,
+// bItemNumber,
+// *pReplace,
+// oMoreData
+// oIsThisAtomic
+// RETURN VALUE :
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0024-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN::Replace(DMAddData & oReplace)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ if(oReplace.chunkData != NULL)
+ {
+ offset = oReplace.m_chunkOffset;
+
+ if(oReplace.m_chunkOffset ==0)
+ {
+ retStatus = CloseInternalFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ retStatus = SetFirstChunk(*oReplace.chunkData);
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ if(oReplace.IsLastChunk())
+ { m_bSetComplete = TRUE;
+ retStatus = CloseInternalFile();
+ }
+ }
+ else
+ {
+ if(m_bDirty)
+ { if(oReplace.IsLastChunk())
+ retStatus = SetLastChunk(*oReplace.chunkData);
+ else
+ retStatus = SetNextChunk(*oReplace.chunkData);
+ }
+ else
+ retStatus = SYNCML_DM_INVALID_PARAMETER;
+ }
+ }
+ else
+ retStatus = DMDefaultLeafNode::Replace(oReplace);
+ return retStatus;
+}
+//------------------------------------------------------------------------
+// FUNCTION : Commit
+//
+// DESCRIPTION : This function The method will commit operations on the node
+// ARGUMENTS PASSED: waitMsgForStatus,
+//
+// RETURN VALUE :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN::Commit()
+{
+ SYNCML_DM_RET_STATUS_T retStatus = CloseInternalFile();
+
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ // Is temporary file created?
+ if(m_bDirty)
+ {
+ // Check if operations to the node is complete
+ if(m_bSetComplete)
+ {
+ // Newly created node
+ if(abOriginalName == NULL)
+ abOriginalName.RemoveSufix(abStorageName.c_str(), SYNCML_DM_DOT);
+
+ abStorageName = NULL;
+ m_bDirty = FALSE;
+ m_bSetComplete = TRUE;
+ }
+ else
+ {
+ retStatus = SYNCML_DM_INCOMPLETE_COMMAND;
+ }
+ }
+ return retStatus;
+
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Rollback
+//
+// DESCRIPTION : This function is called when a node's value has
+// needs to be rolledback. NOT SUPPORTED FOR PHASE 1
+// ARGUMENTS PASSED: waitMsgForStatus,
+// replyStatusCback,
+// dwCommandId,
+// bItemNumber,
+// dmCommand
+// *pbUri,
+// RETURN VALUE : returns SYNCML_DM_FEATURE_NOT_SUPPORTED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0037-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultESN::Rollback()
+{
+ SYNCML_DM_RET_STATUS_T retStatus = CloseInternalFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ if(m_bDirty)
+ { // Are there any temoprary file?
+ if( abStorageName.length() != 0)
+ {
+ SYNCML_DM_RET_STATUS_T retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ // Always delete the temporary file
+ if(fileHandle != NULL)
+ { retStatus = fileHandle->deleteFile();
+ delete fileHandle;
+ fileHandle = NULL;
+ }
+ }
+ // Clear the temporary file name
+ abStorageName = NULL;
+ m_bDirty = FALSE;
+ m_bSetComplete = TRUE;
+ }
+ return retStatus;
+}
+/*==================================================================================================
+ * Function: :Get the first chunk
+ * param dmtChunkData -- reference to DmtDataChunk
+ * return status code
+*==================================================================================================
+*/
+SYNCML_DM_RET_STATUS_T DMDefaultESN::GetFirstChunk(DmtDataChunk& chunkData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = OpenInternalStorageFile();
+ UINT32 remainlLen = totalSize- offset;
+ UINT32 getLen = 0L;
+ UINT8 *bufp;
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ if(fileHandle == NULL)
+ {
+ chunkData.SetChunkData(NULL, 0L);
+ chunkData.SetReturnLen(getLen);
+ return retStatus;
+ }
+ chunkData.GetChunkData(&bufp);
+ if(remainlLen <0|| bufp == NULL)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ if(remainlLen == 0)
+ {
+ chunkData.SetChunkData(NULL, 0L);
+ chunkData.SetReturnLen(remainlLen);
+ return SYNCML_DM_SUCCESS;
+ }
+
+ getLen = chunkData.GetChunkSize();
+ if(getLen > remainlLen)
+ getLen = remainlLen;
+
+ chunkData.GetChunkData(&bufp); // the chunk data is available
+ if(bufp == NULL)
+ return SYNCML_DM_INVALID_PARAMETER;
+ if(fileHandle->seek(XPL_FS_SEEK_SET, offset) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ if(fileHandle->read(bufp, getLen) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ // Set data size
+ chunkData.SetChunkData(NULL, getLen);
+ // Set return data size
+ chunkData.SetReturnLen(getLen);
+ return retStatus;
+}
+
+/*==================================================================================================
+ * Function: :Get the first chunk
+ * param dmtChunkData -- reference to DmtDataChunk
+ * return status code
+*==================================================================================================
+*/
+
+SYNCML_DM_RET_STATUS_T DMDefaultESN::GetNextChunk(DmtDataChunk& chunkData)
+{
+ return GetFirstChunk(chunkData);
+}
+/*==================================================================================================
+ * Function: :set the first chunk
+ * param dmtChunkData -- reference to DmtDataChunk
+ * return status code
+*==================================================================================================
+*/
+SYNCML_DM_RET_STATUS_T DMDefaultESN::SetFirstChunk(DmtDataChunk& chunkData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ UINT32 dataLen;
+ UINT8 *bufp;
+ LOGD("DMDefaultESN::SetFirstChunk");
+
+ // No internal file created yet
+ if(abStorageName.length() == 0) {
+ retStatus = DMFileHandler::createTempESNFileName(abStorageName);
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ if(offset == 0L)
+ { m_bNeedLogging = TRUE;
+ m_bSetComplete = FALSE;
+ }
+
+ }
+ else// Replace previous data
+ {
+ // Set first trunk
+ if(offset == 0L)
+ { totalSize = 0L;
+ m_bSetComplete = FALSE;
+ m_bNeedLogging = TRUE;
+
+ // Remove the current data file
+ retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ retStatus = fileHandle->deleteFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ delete fileHandle;
+ fileHandle = NULL;
+ }
+ else
+ { m_bNeedLogging = FALSE;
+ }
+ }
+ chunkData.GetChunkDataSize(dataLen);
+ if(dataLen != 0)
+ { retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ chunkData.GetChunkData(&bufp); // the chunk data is available
+ if(fileHandle == NULL ||bufp == NULL)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ XPL_FS_SIZE_T fsize = fileHandle->size();
+ LOGD("fileHandle file size=%d", fsize);
+
+ // ehb005: no need to seek since we're writing and always appending to end of file
+ //if(fileHandle->seek(XPL_FS_SEEK_SET, offset) != SYNCML_DM_SUCCESS)
+ // return SYNCML_DM_IO_FAILURE;
+ if(fileHandle->write(bufp, dataLen) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ totalSize = offset + dataLen;
+ chunkData.SetReturnLen(dataLen);
+ m_bDirty = TRUE;
+ LOGD("dataLen=%d, totalSize=%d, offset=%d", dataLen, totalSize, offset);
+ LOGD("DMDefaultESN::SetFirstChunk abStorageName=%s", abStorageName.c_str());
+
+ return retStatus;
+}
+/*==================================================================================================
+ * Function: :set the next chunk
+ * param dmtChunkData -- reference to DmtDataChunk
+ * return status code
+*==================================================================================================
+*/
+SYNCML_DM_RET_STATUS_T DMDefaultESN::SetNextChunk(DmtDataChunk& chunkData)
+{
+ LOGD("DMDefaultESN::SetNextChunk");
+ return SetFirstChunk(chunkData);
+}
+
+/*==================================================================================================
+ * Function: :set the last chunk
+ * param dmtChunkData -- reference to DmtDataChunk
+ * return status code
+*==================================================================================================
+*/
+SYNCML_DM_RET_STATUS_T DMDefaultESN::SetLastChunk(DmtDataChunk& chunkData)
+{
+ LOGD("DMDefaultESN::SetLastChunk");
+ SYNCML_DM_RET_STATUS_T retStatus = SetFirstChunk(chunkData);;
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ m_bSetComplete = TRUE;
+ retStatus = CloseInternalFile();
+ return retStatus;
+}
+#endif
+
diff --git a/engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_interior_node_class.cc b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_interior_node_class.cc
new file mode 100644
index 0000000..6b71ddf
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_interior_node_class.cc
@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//------------------------------------------------------------------------
+//
+// Module Name: dm_default_interior_node_class.cpp
+//
+// General Description: Contains the implementations of the methods of
+// DMDefaultInteriorNode class.
+//------------------------------------------------------------------------
+
+#include "dm_tree_default_interior_node_class.H" //header file for class defn
+
+#define ADD_INT_NODES_DYNAMICALLY_FOR_TESTING 1
+
+//------------------------------------------------------------------------
+// FUNCTION : Add
+// DESCRIPTION : This function sets the ACCESS type and format
+// properties for an Interior node added in the tree.
+// No data involved ,so synchronous Non-blocking call
+// callback function pointers will be ignored
+// ARGUMENTS PASSED: *psAdd,
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : status code
+// PRE-CONDITIONS : 1.URI has already been validated
+// 2.The node object of the plug-in class has been
+// created and a reference has been given to DMTNM
+// POST-CONDITIONS : Following property values are set by the function
+// Format = SYNCML_DM_FORMAT_NODE
+// IMPORTANT NOTES : The default Interior node class grants all Access
+// rights to the Node in Add
+// If a Plug-in needs to implement a class for interior
+// nodes in which the access type needs to be plug-in
+// specific Ex: that plug-in does not want to give
+// delete access type, then the plug-in SHALL implement
+// it's own Add accordingly.
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultInteriorNode::Add(DMAddData & oAddData)
+{
+ XPL_LOG_DM_TMN_Debug(("Entered DMDefaultInteriorNode::Add \n"));
+#ifdef ADD_INT_NODES_DYNAMICALLY_FOR_TESTING
+ return SYNCML_DM_SUCCESS;
+#else
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+#endif
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Delete
+// DESCRIPTION : This function should not actually not get called.
+// since DMTNM deletes the node object.It is a pure
+// virtual function in DMNode,hence is implemented and
+// returns SYNCML_DM_SUCCESS
+// ARGUMENTS PASSED: waitMsgForStatus
+// replyStatusCback
+// dwCommandId,
+// bItemNumber,
+// *pbUri,
+// oIsThisAtomic,
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : ALWAYS returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS : DMTNM actually deletes the node object
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultInteriorNode :: Delete(CPCHAR pbUri)
+{
+ XPL_LOG_DM_TMN_Debug(("Entered DMDefaultInteriorNode::Delete \n"));
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Get
+// DESCRIPTION : This function should not actually not get called.
+// since interior node has no value to return.It is a
+// pure virtual function in DMNode,hence is implemented
+// and returns SYNCML_DM_SUCCESS
+// ARGUMENTS PASSED: waitMsgForGetdata
+// waitMsgForGetdata
+// dwCommandId,
+// bItemNumber,
+// *pbUri,
+// dwStartByte,
+// dwNBytes
+// **ppsReturnData
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : ALWAYS returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : The DMTNM will return the list of child names(if
+// the interior node has no children it will return
+// an empty list
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultInteriorNode::Get(CPCHAR pbUri, DMGetData & oReturnData)
+{
+#ifdef LOB_SUPPORT
+ oReturnData.SetESN(FALSE);
+#endif
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetFormat
+//
+// DESCRIPTION : This function returns FORMAT of the node
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE : ALWAYS returns SYNCML_DM_FORMAT_NODE
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultInteriorNode::GetFormat(CPCHAR pbUri,
+ SYNCML_DM_FORMAT_T *dwpRetPropertyData)
+{
+ XPL_LOG_DM_TMN_Debug(("Entered DMDefaultInteriorNode::GetFormat \n"));
+ *dwpRetPropertyData = SYNCML_DM_FORMAT_NODE;
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetType
+// DESCRIPTION : This function returns SYNCML_DM_COMMAND_NOT_ALLOWED
+// since TYPE of the interior node is not present
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE : status code,type is NULL for interior nodes
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultInteriorNode::GetType(CPCHAR pbUri,
+ DMString& strType)
+{
+ strType = NULL;
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetSize
+// DESCRIPTION : This function returns SIZE of the node.Interior node
+// has no data,hence there is no Size property value
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE : ALWAYS returns SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultInteriorNode::GetSize(CPCHAR pbUri,
+ UINT32 *dwpRetPropertyData)
+{
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Rename
+// DESCRIPTION : This function is called when a node's name has
+// been changed
+// ARGUMENTS PASSED: waitMsgForStatus,
+// replyStatusCback,
+// dwCommandId,
+// bItemNumber,
+// *pbUri,
+// pNewNodeName
+// oIsThisAtomic
+// RETURN VALUE : ALWAYS returns SYNCML_DM_SUCCESS
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : The node Name will be renamed by the DMTNM.It informs
+// the plug-in about this to allow the plug-in to change
+// the name in the data-base correspondingly.Since
+// Interior nodes in this class have no database this
+// method simply returns SYNCML_DM_SUCCESS.This means that
+// name of node will be renamed by DMTNM,and plug-in
+// does not have anything specific to do.
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultInteriorNode::Rename(CPCHAR pbUri, CPCHAR ppNewNodeName)
+{
+ XPL_LOG_DM_TMN_Debug(("Entered DMDefaultInteriorNode::Rename\n"));
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Replace
+//
+// DESCRIPTION : This function is called when a node's value has
+// to be replaced.It returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// ARGUMENTS PASSED: waitMsgForStatus,
+// replyStatusCback,
+// dwCommandId,
+// bItemNumber,
+// *pReplace,
+// oMoreData
+// oIsThisAtomic
+// RETURN VALUE : ALWAYS returns SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultInteriorNode::Replace(DMAddData & oReplace)
+{
+ XPL_LOG_DM_TMN_Debug(("Entered DMDefaultInteriorNode::Replace \n"));
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Rollback
+//
+// DESCRIPTION : This function is called when a node's value has
+// needs to be rolledback. NOT SUPPORTED FOR PHASE 1
+// ARGUMENTS PASSED: waitMsgForStatus,
+// replyStatusCback,
+// dwCommandId,
+// bItemNumber,
+// dmCommand
+// *pbUri,
+// RETURN VALUE : returns SYNCML_DM_FEATURE_NOT_SUPPORTED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultInteriorNode::Rollback(SYNCML_DM_COMMAND_T dmCommand, CPCHAR pbUri)
+{
+ XPL_LOG_DM_TMN_Debug(("Entered DMDefaultInteriorNode::Rollback \n"));
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
diff --git a/engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_leaf_node_class.cc b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_leaf_node_class.cc
new file mode 100644
index 0000000..e96a040
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_default_leaf_node_class.cc
@@ -0,0 +1,260 @@
+//------------------------------------------------------------------------
+//
+// Module Name: dm_tree_default_leaf_node_class.cpp
+//
+// General Description:Contains the implementations of the methods of
+// DMDefaultLeafNode class.
+//------------------------------------------------------------------------
+// Revision History:
+// Modification Tracking
+// Author (core ID) Date Number Description of Changes
+// ----------------- ----
+// 2003-2007 refactoring
+// cdp180 03/16/2007 LIBll55345 Removing ACL check for internal calls
+// Portability: This module is portable to other compilers.
+//------------------------------------------------------------------------
+// INCLUDE FILES
+//------------------------------------------------------------------------
+#include "dmdefs.h"
+#include "dm_tree_default_leaf_node_class.H"
+#include "dm_tree_util.h"
+
+//------------------------------------------------------------------------
+// LOCAL FUNCTION PROTOTYPES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL CONSTANTS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+// LOCAL MACROS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL VARIABLES
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+// GLOBAL VARIABLES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL FUNCTIONS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// GLOBAL FUNCTIONS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+// FUNCTION : Add
+// DESCRIPTION : This function sets the ACCESS type and format
+// properties for an Interior node added in the tree.
+// No data involved ,so synchronous Non-blocking call
+// callback function pointers will be ignored
+// ARGUMENTS PASSED: *psAdd,
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : status code
+// PRE-CONDITIONS : 1.URI has already been validated
+// 2.The node object of the plug-in class has been
+// created and a reference has been given to DMTNM
+// POST-CONDITIONS : Following property values are set by the function
+// Format = SYNCML_DM_FORMAT_NODE
+// IMPORTANT NOTES : The default Leaf node class grants all Access
+// rights to the Node in Add
+// If a Plug-in needs to implement a class for interior
+// nodes in which the access type needs to be plug-in
+// specific Ex: that plug-in does not want to give
+// delete access type, then the plug-in SHALL implement
+// it's own Add accordingly.
+// REQUIREMENT # : ESR-DMTNM0042-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultLeafNode::Add(DMAddData & oAddData)
+{
+ return set(&oAddData);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Delete
+// DESCRIPTION : This function should not actually not get called.
+// since DMTNM deletes the node object.It is a pure
+// virtual function in DMNode,hence is implemented and
+// returns SYNCML_DM_SUCCESS
+// ARGUMENTS PASSED: waitMsgForStatus
+// replyStatusCback
+// dwCommandId,
+// bItemNumber,
+// *pbUri,
+// oIsThisAtomic,
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : ALWAYS returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS : DMTNM actually deletes the node object
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0025-m to ESR-DMTNM0027-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultLeafNode::Delete(CPCHAR pbUri)
+{
+ return(SYNCML_DM_SUCCESS);
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : Get
+// DESCRIPTION :
+// ARGUMENTS PASSED: waitMsgForGetdata
+// waitMsgForGetdata
+// dwCommandId,
+// bItemNumber,
+// *pbUri,
+// dwStartByte,
+// dwNBytes
+// **ppsReturnData
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : ALWAYS returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : The DMTNM will return the list of child names(if
+// the interior node has no children it will return
+// an empty list
+// REQUIREMENT # : ESR-DMTNM0028-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultLeafNode::Get(CPCHAR pbUri, DMGetData & oReturnData)
+{
+#ifdef LOB_SUPPORT
+ oReturnData.SetESN(IsESN());
+#endif
+ return oReturnData.set(bFormat,(CPCHAR)psData.getBuffer(),psData.getSize(),getType());
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : GetFormat
+//
+// DESCRIPTION : This function returns FORMAT of the node
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE : ALWAYS returns SYNCML_DM_FORMAT_NODE
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0033-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultLeafNode::GetFormat(CPCHAR pbUri,
+ SYNCML_DM_FORMAT_T *dwpRetPropertyData)
+{
+ *dwpRetPropertyData = this->bFormat;
+ return(SYNCML_DM_SUCCESS);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetType
+// DESCRIPTION : This function returns MIME type
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE : status code,type is NULL for interior nodes
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0033-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultLeafNode::GetType(CPCHAR pbUri,
+ DMString& strType)
+{
+ strType = this->getType();
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetSize
+// DESCRIPTION : This function returns SIZE of the node.
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE :
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultLeafNode ::GetSize(CPCHAR pbUri,
+ UINT32 *dwpRetPropertyData)
+{
+ *dwpRetPropertyData=psData.getSize();
+ return(SYNCML_DM_SUCCESS);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Rename
+// DESCRIPTION : This function is called when a node's name has
+// been changed
+// ARGUMENTS PASSED: *pbUri,
+// pNewNodeName
+// RETURN VALUE : ALWAYS returns SYNCML_DM_SUCCESS
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : The node Name will be renamed by the DMTNM.It informs
+// the plug-in about this to allow the plug-in to change
+// the name in the data-base correspondingly.Since
+// Interior nodes in this class have no database this
+// method simply returns SYNCML_DM_SUCCESS.This means that
+// name of node will be renamed by DMTNM,and plug-in
+// does not have anything specific to do.
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultLeafNode::Rename(CPCHAR pbUri,
+ CPCHAR pNewNodeName)
+{
+ return(SYNCML_DM_SUCCESS);
+}
+//------------------------------------------------------------------------
+// FUNCTION : Replace
+//
+// DESCRIPTION : This function is called when a node's value has
+// to be replaced.
+// ARGUMENTS PASSED: waitMsgForStatus,
+// replyStatusCback,
+// dwCommandId,
+// bItemNumber,
+// *pReplace,
+// oMoreData
+// oIsThisAtomic
+// RETURN VALUE :
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0024-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultLeafNode::Replace(DMAddData & oReplace)
+{
+ return set(&oReplace);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Rollback
+//
+// DESCRIPTION : This function is called when a node's value has
+// needs to be rolledback. NOT SUPPORTED FOR PHASE 1
+// ARGUMENTS PASSED: waitMsgForStatus,
+// replyStatusCback,
+// dwCommandId,
+// bItemNumber,
+// dmCommand
+// *pbUri,
+// RETURN VALUE : returns SYNCML_DM_FEATURE_NOT_SUPPORTED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0037-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMDefaultLeafNode::Rollback(SYNCML_DM_COMMAND_T dmCommand,
+ CPCHAR pbUri)
+{
+ return(SYNCML_DM_FEATURE_NOT_SUPPORTED);
+}
+
diff --git a/engine/dmlib/dmengine/dm_tnm/src/dm_tree_node_class.cc b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_node_class.cc
new file mode 100644
index 0000000..30e0cae
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_node_class.cc
@@ -0,0 +1,273 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//------------------------------------------------------------------------
+//
+// Module Name: dm_tree_node_class.cc
+//
+// General Description:Contains the implementations of the methods of
+// DMNode class.
+//------------------------------------------------------------------------
+
+#include "dmdefs.h"
+#include "dm_tree_node_class.H"
+#include "dm_tree_class.H"
+#include "SyncML_DM_Archive.H"
+
+// For the mime type optimization
+#define DEFAULT_MIME_TYPE "text/plain"
+#define DEFAULT_MIME_TYPE_INTERNAL ""
+
+class DMTree;
+
+// Constructor that sets class UID to the object while creating the object
+DMNode::DMNode(BOOLEAN bPlugin):
+ pcParentOfNode(NULL),
+ pcFirstChild(NULL),
+ pcNextSibling(NULL)
+{
+ bFormat = 0;
+ m_nFlags = bPlugin ? enum_NodePlugin : 0;
+
+ //Only root of the archive has it set. Others will be NULL.
+ this->pArchive=NULL;
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ wTStamp = 0;
+ wVerNo = 0;
+#endif
+}
+
+//Destructor of the DMNode class
+DMNode::~DMNode()
+{
+ //Only root of the archive has it set. Others will be NULL.
+ if (this->pArchive != NULL)
+ {
+ if ( this->pArchive->getRootNode() == this )
+ {
+ this->pArchive->setRootNode(NULL);
+ }
+ }
+
+
+
+}
+
+
+SYNCML_DM_RET_STATUS_T DMNode::GetName(CPCHAR pbUri, DMString& strName )
+{
+ strName = abNodeName;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMNode::SetName(CPCHAR pbUri, CPCHAR pbNewName)
+{
+ SYNCML_DM_RET_STATUS_T sRetStatus = SYNCML_DM_SUCCESS;
+
+ this->abNodeName = pbNewName;
+ return sRetStatus;
+}
+
+SYNCML_DM_RET_STATUS_T DMNode::GetTitle(CPCHAR pbUri, DMString& ppbTitle)
+{
+ ppbTitle = m_strTitle;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMNode::SetTitle(CPCHAR pbUri, CPCHAR pbNewTitle)
+{
+ m_strTitle = pbNewTitle;
+ return SYNCML_DM_SUCCESS;
+}
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+
+SYNCML_DM_RET_STATUS_T DMNode::SetTStamp(CPCHAR pbUri, XPL_CLK_CLOCK_T timeStamp)
+{
+ wTStamp = timeStamp;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMNode::SetVerNo(CPCHAR pbUri, UINT16 verNo)
+{
+ if (verNo == 0xffff)
+ {
+ wVerNo = 0;
+ }
+ else
+ wVerNo = verNo;
+ return SYNCML_DM_SUCCESS;
+}
+#endif
+
+DMNode* DMNode::GetChildByName( CPCHAR szName ) const
+{
+ DMNode *pNode = pcFirstChild;
+
+ while ( pNode && pNode->abNodeName != szName )
+ pNode = pNode->pcNextSibling;
+
+ return pNode;
+}
+
+DMNode* DMNode::GetNextSerializeItem()
+{
+ DMNode *pItem = this;
+
+ while ( pItem ) {
+ if ( !pItem->isPlugin() && !pItem->pArchive )
+ return pItem;
+
+ pItem = pItem->pcNextSibling;
+ }
+ return NULL;
+}
+
+void DMNode::ConvertPathToSkeleton( DMNode* psStartNode )
+{
+ DMNode *pNode = pcParentOfNode;
+
+ while ( pNode && pNode != psStartNode ){
+ pNode->m_nFlags |= enum_NodeSkeleton;
+ pNode = pNode->pcParentOfNode;
+ }
+
+ if ( pNode )
+ pNode->m_nFlags |= enum_NodeSkeleton;
+}
+
+CPCHAR DMNode::getType() const
+{
+ if (psType_ == DEFAULT_MIME_TYPE_INTERNAL) {
+ return DEFAULT_MIME_TYPE;
+ } else {
+ return psType_.c_str();
+ }
+}
+
+SYNCML_DM_RET_STATUS_T DMNode::setType(CPCHAR strType)
+{
+ if ( strType )
+ {
+ if ( DmStrcmp(strType,DEFAULT_MIME_TYPE) == 0 )
+ {
+ psType_ = DEFAULT_MIME_TYPE_INTERNAL;
+ } else {
+ psType_ = strType;
+ if ( psType_ == NULL && strType[0] )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMNode::set(const DMGetData * pData)
+{
+ SYNCML_DM_RET_STATUS_T res;
+
+ bFormat= pData->m_nFormat == SYNCML_DM_FORMAT_NODE_PDATA ? SYNCML_DM_FORMAT_NODE : pData->m_nFormat;
+
+ CPCHAR pMimeType = ( pData->m_oMimeType.getSize() ? pData->getType() : NULL );
+
+ res = setType(pMimeType);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ if ( pData->m_oData.getSize() && getData())
+ {
+ *getData() = pData->m_oData;
+ if ( getData()->getBuffer() == 0 )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ else
+ if ( getData() )
+ {
+ // Set boolean string value if it is omitted, otherwise size 0
+ // will be returned for DM API call.
+ if (!pData->m_oData.getSize() )
+ {
+ if (bFormat == SYNCML_DM_FORMAT_BOOL)
+ {
+ (*getData()).assign("false");
+ }
+ else
+ {
+ (*getData()).clear();
+ }
+ }
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMNode::set(CPCHAR strName, CPCHAR strTitle, const DMGetData * pData)
+{
+
+ if ( strName )
+ {
+ abNodeName = strName;
+ if ( abNodeName == NULL && strName[0] )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ else
+ return SYNCML_DM_FAIL;
+
+
+ if ( strTitle )
+ {
+ m_strTitle = strTitle;
+ if ( m_strTitle == NULL && strTitle[0] )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ return set(pData);
+
+}
+
+
+SYNCML_DM_RET_STATUS_T DMNode::set(const DMAddNodeProp * pNodeProp)
+{
+
+ m_nFlags = pNodeProp->m_nFlags;
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+ wTStamp = pNodeProp->m_nTStamp;
+ wVerNo = pNodeProp->m_nVerNo;
+#endif
+
+ CPCHAR pTitle = ( pNodeProp->m_oTitle.getSize() ? pNodeProp->getTitle() : NULL );
+ CPCHAR pName = ( pNodeProp->m_oName.getSize() ? pNodeProp->getName() : NULL );
+
+ if ( getOverlayPIData() )
+ {
+ getOverlayPIData()->set_size( pNodeProp->m_oOPiData.getSize() );
+ if ( getOverlayPIData()->size() != pNodeProp->m_oOPiData.getSize() )
+ return SYNCML_DM_DEVICE_FULL;
+ memcpy( getOverlayPIData()->get_data(), pNodeProp->m_oOPiData.getBuffer(),
+ getOverlayPIData()->size() );
+ }
+
+ return set(pName,pTitle,(DMGetData*)pNodeProp);
+
+}
+
+#ifdef LOB_SUPPORT
+SYNCML_DM_RET_STATUS_T DMNode::IsESN(CPCHAR pbUri, BOOLEAN& bESN)
+{
+ bESN = (m_nFlags & enum_NodeESN) != 0;
+ return SYNCML_DM_SUCCESS;
+}
+#endif
diff --git a/engine/dmlib/dmengine/dm_tnm/src/dm_tree_plugin_root_node_class.cc b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_plugin_root_node_class.cc
new file mode 100644
index 0000000..ef18410
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_plugin_root_node_class.cc
@@ -0,0 +1,874 @@
+//------------------------------------------------------------------------
+//
+// Module Name: dm_tree_plugin_root_node_class.cpp
+//
+//YXU ADD
+//This is the adapter class that redirect calls back to
+// plugin API
+//
+// General Description:Contains the implementations of the methods of
+// DMPluginRootNode class.
+//------------------------------------------------------------------------
+// Revision History:
+// Modification Tracking
+// Author (core ID) Date Number Description of Changes
+// ----------------- ------------ ---------- -------------------------
+// Denis Makarenko 02/19/2007 LIBll07144 Getting rid of global objects to fix deinitialization problems
+// ehb005 01/09/2007 libkk95578 added SetPrincipal on plugin tree
+// cdp180 03/16/2007 LIBll55345 Removing ACL check for internal calls
+//
+// Portability: This module is portable to other compilers.
+//------------------------------------------------------------------------
+// INCLUDE FILES
+//------------------------------------------------------------------------
+
+#include "dm_tree_plugin_root_node_class.H"
+#include "dm_tree_util.h"
+#include "xpl_Logger.h"
+#include "dm_tree_plugin_util.H"
+
+
+//------------------------------------------------------------------------
+// LOCAL FUNCTION PROTOTYPES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL CONSTANTS
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+// LOCAL MACROS
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+// LOCAL VARIABLES
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+// GLOBAL VARIABLES
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+// LOCAL FUNCTIONS
+//------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------
+// GLOBAL FUNCTIONS
+//------------------------------------------------------------------------
+
+DMPluginRootNode::DMPluginRootNode(PDMPlugin pPlugin ):DMNode(TRUE)
+{
+ m_ptrPlugin = pPlugin;
+}
+
+DMPluginRootNode::~DMPluginRootNode()
+{
+}
+
+BOOLEAN DMPluginRootNode::IsGetAccess(CPCHAR pURI) const
+{
+ return dmTreeObj.GetMetaDataManager().VerifyAccessType(pURI,SYNCML_DM_GET_ACCESS_TYPE);
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Add
+// DESCRIPTION : This function sets the ACCESS type and format
+// properties for an Interior node added in the tree.
+// No data involved ,so synchronous Non-blocking call
+// callback function pointers will be ignored
+// ARGUMENTS PASSED: *psAdd,
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : status code
+// PRE-CONDITIONS : 1.URI has already been validated
+// 2.The node object of the plug-in class has been
+// created and a reference has been given to DMTNM
+// POST-CONDITIONS : Following property values are set by the function
+// Format = SYNCML_DM_FORMAT_NODE
+// IMPORTANT NOTES : The default Leaf node class grants all Access
+// rights to the Node in Add
+// If a Plug-in needs to implement a class for interior
+// nodes in which the access type needs to be plug-in
+// specific Ex: that plug-in does not want to give
+// delete access type, then the plug-in SHALL implement
+// it's own Add accordingly.
+// REQUIREMENT # : ESR-DMTNM0042-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::Add(DMAddData & oAddData)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ PDmtNode ptrNode;
+
+ CPCHAR pPluginPath = GetPluginURI(oAddData.getURI());
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if (oAddData.m_nFormat == SYNCML_DM_FORMAT_NODE)
+ {
+ dm_stat = m_ptrPluginTree->CreateInteriorNode(pPluginPath,ptrNode);
+ }
+ else
+ {
+ DmtData oData;
+
+ dm_stat = dmBuildData(oAddData.m_nFormat, oAddData.m_oData, oData);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+#ifdef LOB_SUPPORT
+ dm_stat = m_ptrPluginTree->CreateLeafNode(pPluginPath,ptrNode,oData, oAddData.IsESN());
+#else
+ dm_stat = m_ptrPluginTree->CreateLeafNode(pPluginPath,ptrNode,oData);
+#endif
+
+ }
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ if ( ptrNode == NULL )
+ SetAddedNode(oAddData.getURI());
+ else
+ m_ptrPluginTree->SetAddedNode(ptrNode);
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMPluginRootNode::Add, dm_stat=%d\n", dm_stat));
+ return dm_stat;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Delete
+// DESCRIPTION : This function should not actually not get called.
+// since DMTNM deletes the node object.It is a pure
+// virtual function in DMNode,hence is implemented and
+// returns SYNCML_DM_SUCCESS
+// ARGUMENTS PASSED: waitMsgForStatus
+// replyStatusCback
+// dwCommandId,
+// bItemNumber,
+// *pbUri,
+// oIsThisAtomic,
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : ALWAYS returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS : DMTNM actually deletes the node object
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0025-m to ESR-DMTNM0027-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::Delete(CPCHAR pURI)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = m_ptrPluginTree->DeleteNode(pPluginPath);
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ m_ptrPluginTree->RemoveAddedNode(pPluginPath);
+ }
+ return dm_stat;
+
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : Get
+// DESCRIPTION :
+// ARGUMENTS PASSED: *pbUri - full path name
+// **ppsReturnData
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : ALWAYS returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : The DMTNM will return the list of child names(if
+// the interior node has no children it will return
+// an empty list
+// REQUIREMENT # : ESR-DMTNM0028-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::Get(CPCHAR pURI,
+ DMGetData &oReturnData)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtNode ptrNode;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ oReturnData.clear();
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("Can't Get Node for %s, error=%d\n", pPluginPath, dm_stat));
+ return dm_stat;
+ }
+
+ if (ptrNode->IsLeaf())
+ {
+ DmtData data;
+#ifdef LOB_SUPPORT
+ if(ptrNode->IsExternalStorageNode() && oReturnData.chunkData != NULL)
+ {
+ if(oReturnData.m_chunkOffset ==0)
+ dm_stat = ptrNode->GetFirstChunk(*oReturnData.chunkData);
+ else
+ dm_stat = ptrNode->GetNextChunk(*oReturnData.chunkData);
+ }
+ else
+#endif
+ {
+ dm_stat = ptrNode->GetValue(data);
+
+ XPL_LOG_DM_TMN_Debug(("Get Attributes error=%d\n", dm_stat));
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("Can't Get Value for %s, error=%d\n", pPluginPath, dm_stat));
+ return dm_stat;
+ }
+
+ if ( data.GetType() == SYNCML_DM_DATAFORMAT_UNDEFINED )
+ return SYNCML_DM_DEVICE_FULL;
+
+ DmtAttributes oAttr;
+ dm_stat = ptrNode->GetAttributes( oAttr );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("Can't Get Attributes for %s, error=%d\n", pPluginPath, dm_stat));
+ return dm_stat;
+ }
+
+ dm_stat = oReturnData.set(data,oAttr.GetType());
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ return dm_stat;
+ }
+ oReturnData.m_nFormat = DMTree::ConvertFormatStr(oAttr.GetFormat());
+#ifdef LOB_SUPPORT
+ if(ptrNode->IsExternalStorageNode())
+ {
+ oReturnData.m_TotalSize = oAttr.GetSize();
+ }
+#endif
+ } }
+ else
+ {
+ DMStringVector mapNodeNames;
+ DMString strVal;
+ dm_stat = m_ptrPluginTree->GetChildNodeNames( pPluginPath,mapNodeNames);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("Can't Get Child Node Names for %s, error=%d\n", pPluginPath, dm_stat));
+ return dm_stat;
+ }
+
+ // Make sure that there are no duplicate child node names. It's a huck for GetStruct.
+ // In future should be fixed in the GetStruct
+ DMStringVector aChildren;
+ for ( int i = 0; i < mapNodeNames.size(); i++ )
+ {
+ DMString strChild = mapNodeNames[i];
+ if ( aChildren.find( strChild ) == -1 )
+ {
+ aChildren.push_back( strChild );
+ if (i > 0)
+ strVal += "/";
+ strVal += strChild;
+ }
+ }
+
+ dm_stat = oReturnData.set(SYNCML_DM_FORMAT_NODE,strVal,strVal.length(),"text/plain");
+ }
+#ifdef LOB_SUPPORT
+ // Set ESN flag
+ oReturnData.SetESN(ptrNode->IsExternalStorageNode());
+#endif
+ return dm_stat;
+
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : SetAddedNode
+// DESCRIPTION :
+// ARGUMENTS PASSED: *pUri - full path name
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : will add URI of interior node into internal vector
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::SetAddedNode(CPCHAR pURI)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ PDmtPluginNode ptrNode = new DmtPluginNode();
+
+ if ( ptrNode == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ DmtPluginTree *pTree = (DmtPluginTree *)m_ptrPluginTree.GetPtr();
+
+ dm_stat = ptrNode->Init(PDmtPluginTree(pTree), pPluginPath);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ return dm_stat;
+ }
+
+ m_ptrPluginTree->SetAddedNode(PDmtNode(ptrNode));
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : RemoveAddedNode
+// DESCRIPTION :
+// ARGUMENTS PASSED: *pUri - full path name
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : will remove URI of interior node from internal vector
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::RemoveAddedNode(CPCHAR pURI)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ m_ptrPluginTree->RemoveAddedNode(pPluginPath);
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : Find
+// DESCRIPTION :
+// ARGUMENTS PASSED: *pUri - full path name
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : ALWAYS returns
+// SYNCML_DM_COMMAND_NOT_ALLOWED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : The DMTNM will return the list of child names(if
+// the interior node has no children it will return
+// an empty list
+// REQUIREMENT # : ESR-DMTNM0028-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::Find(CPCHAR pURI)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtNode ptrNode;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = m_ptrPluginTree->FindAddedNode(pPluginPath);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+
+ dm_stat = m_ptrPluginTree->FindAddedParentNode(pPluginPath);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ return SYNCML_DM_NOT_FOUND;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ DmtData data;
+ dm_stat = ptrNode->GetValue(data);
+ }
+
+ return dm_stat;
+
+}
+
+
+//------------------------------------------------------------------------
+// FUNCTION : GetFormat
+//
+// DESCRIPTION : This function returns FORMAT of the node
+// ARGUMENTS PASSED:
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE : ALWAYS returns SYNCML_DM_FORMAT_NODE
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0033-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::GetFormat(CPCHAR pURI,
+ SYNCML_DM_FORMAT_T *dwpRetPropertyData)
+{
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DmtAttributes oAttr;
+ dm_stat = ptrNode->GetAttributes( oAttr );
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ *dwpRetPropertyData=DMTree::ConvertFormatStr(oAttr.GetFormat());
+ }
+
+ return dm_stat;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetType
+// DESCRIPTION : This function returns MIME type
+// ARGUMENTS PASSED:
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE : status code,type is NULL for interior nodes
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0033-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::GetType(CPCHAR pURI, DMString& strType)
+{
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DmtAttributes oAttr;
+ dm_stat = ptrNode->GetAttributes( oAttr );
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ const DMString & type = oAttr.GetType();
+ strType = type;
+ if ( type.length() && strType == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::GetName(CPCHAR pURI, DMString& strName )
+{
+ CPCHAR szName=DmStrrchr(pURI, '/');
+
+ if ( szName )
+ strName = (szName + 1 );
+ else
+ strName = pURI;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : GetSize
+// DESCRIPTION : This function returns SIZE of the node.
+// ARGUMENTS PASSED: waitMsgForGetFormat,
+// replyGetFormatCback,
+// *pbUri,
+// **pRetPropertyData
+// RETURN VALUE :
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode ::GetSize(CPCHAR pURI, UINT32 *dwpRetPropertyData)
+{
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ *dwpRetPropertyData = 0;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DmtAttributes oAttr;
+ dm_stat = ptrNode->GetAttributes( oAttr );
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ *dwpRetPropertyData=oAttr.GetSize();
+
+ return dm_stat;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Rename
+// DESCRIPTION : This function is called when a node's name has
+// been changed
+// ARGUMENTS PASSED:
+// dwCommandId,
+// bItemNumber,
+// *pbUri,
+// pNewNodeName
+// oIsThisAtomic
+// RETURN VALUE : ALWAYS returns SYNCML_DM_SUCCESS
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES : The node Name will be renamed by the DMTNM.It informs
+// the plug-in about this to allow the plug-in to change
+// the name in the data-base correspondingly.Since
+// Interior nodes in this class have no database this
+// method simply returns SYNCML_DM_SUCCESS.This means that
+// name of node will be renamed by DMTNM,and plug-in
+// does not have anything specific to do.
+// REQUIREMENT # :
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::Rename(CPCHAR pURI, CPCHAR psNewNodeName)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = m_ptrPluginTree->RenameNode(pPluginPath, psNewNodeName);
+ return dm_stat;
+}
+//------------------------------------------------------------------------
+// FUNCTION : Replace
+//
+// DESCRIPTION : This function is called when a node's value has
+// to be replaced.
+// ARGUMENTS PASSED: waitMsgForStatus,
+// replyStatusCback,
+// dwCommandId,
+// bItemNumber,
+// *pReplace,
+// oMoreData
+// oIsThisAtomic
+// RETURN VALUE :
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0024-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::Replace(DMAddData & oReplace)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtNode ptrNode;
+
+ CPCHAR pPluginPath = GetPluginURI(oReplace.getURI());
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if (ptrNode->IsLeaf())
+ {
+ DmtData oData;
+#ifdef LOB_SUPPORT
+ if(ptrNode->IsExternalStorageNode() && oReplace.chunkData != NULL)
+ {
+ if(oReplace.m_chunkOffset ==0)
+ dm_stat = ptrNode->SetFirstChunk(*oReplace.chunkData);
+ else
+ if(oReplace.IsLastChunk())
+ dm_stat = ptrNode->SetLastChunk(*oReplace.chunkData);
+ else
+ dm_stat = ptrNode->SetNextChunk(*oReplace.chunkData);
+ }
+ else
+#endif
+ {
+ dm_stat = dmBuildData(oReplace.m_nFormat, oReplace.m_oData, oData);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = ptrNode->SetValue(oData);
+ }
+ }
+ else
+ dm_stat = SYNCML_DM_COMMAND_NOT_ALLOWED;
+
+ return dm_stat;
+}
+
+//------------------------------------------------------------------------
+// FUNCTION : Rollback
+//
+// DESCRIPTION : This function is called when a node's value has
+// needs to be rolledback. NOT SUPPORTED FOR PHASE 1
+// ARGUMENTS PASSED: waitMsgForStatus,
+// replyStatusCback,
+// dwCommandId,
+// bItemNumber,
+// dmCommand
+// *pbUri,
+// RETURN VALUE : returns SYNCML_DM_FEATURE_NOT_SUPPORTED
+// PRE-CONDITIONS : 1.URI has already been validated
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+// REQUIREMENT # : ESR-DMTNM0037-m
+//------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DMPluginRootNode :: Rollback(SYNCML_DM_COMMAND_T /*dmCommand*/, CPCHAR /*pURI*/)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ return m_ptrPluginTree->Rollback();
+}
+
+
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::SetName(CPCHAR pURI, CPCHAR pbNewName)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ return m_ptrPluginTree->RenameNode(pPluginPath, pbNewName);
+}
+
+#ifdef LOB_SUPPORT
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::IsESN(CPCHAR pbUri, BOOLEAN& bESN)
+{
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ CPCHAR pPluginPath = GetPluginURI(pbUri);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ bESN = ptrNode->IsExternalStorageNode();
+ return SYNCML_DM_SUCCESS;
+
+}
+#endif
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::GetTitle(CPCHAR pURI, DMString& ppbTitle)
+{
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DmtAttributes oAttr;
+ dm_stat = ptrNode->GetAttributes( oAttr );
+ if (dm_stat == SYNCML_DM_SUCCESS)
+ {
+ const DMString & title = oAttr.GetTitle();
+ ppbTitle = title;
+ if ( title.length() && ppbTitle == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::SetTitle(CPCHAR pURI, CPCHAR pbNewTitle)
+{
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = ptrNode->SetTitle(pbNewTitle);
+
+ return dm_stat;
+}
+
+#ifndef DM_IGNORE_TSTAMP_AND_VERSION
+
+XPL_CLK_CLOCK_T DMPluginRootNode::GetTStamp(CPCHAR pURI)
+{
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return 0;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return 0;
+
+ DmtAttributes oAttr;
+ dm_stat = ptrNode->GetAttributes( oAttr );
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ XPL_CLK_CLOCK_T timestamp;
+ timestamp = (oAttr.GetTimestamp()/1000);
+ return timestamp;
+ }
+
+ return 0;
+}
+
+UINT16 DMPluginRootNode::GetVerNo(CPCHAR pURI)
+{
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ CPCHAR pPluginPath = GetPluginURI(pURI);
+
+ dm_stat = GetTree();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return 0;
+
+ dm_stat = m_ptrPluginTree->GetNode( pPluginPath, ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return 0;
+
+ DmtAttributes oAttr;
+ dm_stat = ptrNode->GetAttributes( oAttr );
+ if (dm_stat == SYNCML_DM_SUCCESS)
+ return oAttr.GetVersion();
+
+ return(0);
+}
+
+#endif
+
+
+CPCHAR DMPluginRootNode::GetPluginURI(CPCHAR pURI)
+{
+
+ char * pPluginPath = (char*)pURI;
+
+ if (DmStrstr(pPluginPath, GetPlugin()->GetPath().c_str()) != NULL)
+ pPluginPath += GetPlugin()->GetPath().length();
+
+ if ((*pPluginPath) == '/')
+ pPluginPath++;
+ return pPluginPath;
+
+}
+
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::GetTree()
+{
+ if (m_ptrPluginTree != NULL)
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+
+ CPCHAR szPath = GetPlugin()->GetPath();
+
+ XPL_LOG_DM_TMN_Debug(("DMPluginRootNode::GetTree m_ptrPluginTree == NULL, %s\n", szPath));
+
+ SYNCML_DM_RET_STATUS_T dm_stat = GetPlugin()->GetTree(szPath, m_ptrPluginTree);
+ if (dm_stat == SYNCML_DM_SUCCESS)
+ {
+ if (m_ptrPluginTree != NULL)
+ {
+ // set the principal string for the plugin tree
+ m_ptrPluginTree->SetPrincipal(dmTreeObj.GetServerId());
+ }
+ else
+ {
+ dm_stat = SYNCML_DM_FAIL;
+ }
+ }
+ else
+ {
+ m_ptrPluginTree = NULL;
+ }
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DMPluginRootNode::GetTree(PDmtAPIPluginTree & ptrTree)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ dm_stat = GetTree();
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ ptrTree = m_ptrPluginTree;
+ return dm_stat;
+}
+
+
+
+//////////////////////////////////////////////////////////////
+// class DMOverlayDataPluginNode
+DMOverlayDataPluginNode::DMOverlayDataPluginNode(PDMPlugin pPlugin) :
+ DMPluginRootNode( pPlugin )
+{
+}
+
+
+SYNCML_DM_RET_STATUS_T DMOverlayDataPluginNode::GetFormat(CPCHAR , SYNCML_DM_FORMAT_T *pdwRetPropertyData)
+{
+ *pdwRetPropertyData= m_nNodeFormat;
+ return SYNCML_DM_SUCCESS;
+}
+
+
diff --git a/engine/dmlib/dmengine/dm_tnm/src/dm_tree_plugin_util.cc b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_plugin_util.cc
new file mode 100644
index 0000000..487cca5
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_plugin_util.cc
@@ -0,0 +1,450 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The dm_tree_plugin_util.cc file contains helper functions
+ * for plug-in support
+ */
+
+#include "xpl_Logger.h"
+#include "dmtTreeImpl.hpp"
+#include "dm_tree_plugin_root_node_class.H"
+#include "dm_tree_plugin_util.H"
+#include "dm_tree_util.h"
+#include "SyncML_DM_WBXMLArchive.H"
+#include "SyncML_PlugIn_WBXMLLog.H"
+#include "dm_uri_utils.h"
+
+#ifndef min
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+SYNCML_DM_RET_STATUS_T
+DmCheckNodeConstraint(const PDMPlugin & pPlugin) ;
+
+SYNCML_DM_RET_STATUS_T
+DmCheckMultiNodeConstraint(const PDMPlugin & pPlugin, CPCHAR path, CPCHAR remain, const PDmtTree & tree);
+
+SYNCML_DM_RET_STATUS_T DmRemoveTempfile(DMString &dirName)
+{
+
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ XPL_FS_SHANDLE_T search_handle;
+ DMString strFileNameBuffer;
+ char *file_name = strFileNameBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+
+ if (file_name == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ search_handle = XPL_FS_StartSearch(dirName, DMFileHandler::MIDDLE_FILE_EXTENSION, TRUE, NULL);
+ if ( search_handle == XPL_FS_SHANDLE_INVALID)
+ return SYNCML_DM_IO_FAILURE;
+
+ //Loop through all .temp files in the directory
+ memset(file_name,0,XPL_FS_MAX_FILE_NAME_LENGTH);
+ while ( XPL_FS_GetSearchResult(search_handle,file_name) != XPL_FS_RET_NOT_FOUND )
+ {
+
+ DMFileHandler fileHandler(file_name);
+ ret_code = fileHandler.open(XPL_FS_FILE_RDWR);
+ // Remove temporary ESN file
+ if(ret_code == SYNCML_DM_SUCCESS)
+ fileHandler.deleteFile();
+ }
+ XPL_FS_EndSearch(search_handle);
+ return ret_code;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::ReadCommandFromFile( DMFileHandler *fileHandle,
+ DMBuffer& cmdURI )
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_FAIL;
+ SyncML_DM_WBXMLReader* reader = new SyncML_DM_WBXMLReader( fileHandle );
+
+ if( reader ) for( ; ; )
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ if(fileHandle->seek(XPL_FS_SEEK_SET, sizeof(INT32) + 2) != XPL_FS_RET_SUCCESS) break;
+
+ // Read URI
+ ret_code = reader->readOpaque( &cmdURI );
+ if( SYNCML_DM_SUCCESS != ret_code ) break;
+
+ //Read END_TAG
+ UINT8 bYte = 0;
+ ret_code = reader->readByte( &bYte );
+ if( SYNCML_DM_SUCCESS != ret_code ) break;
+
+ ret_code = SYNCML_DM_IO_FAILURE;
+ if( bYte != SyncML_DM_WBXMLArchive::END_TAG ) break;
+
+ ret_code = SYNCML_DM_SUCCESS;
+ break;
+ }
+
+ if( reader )
+ {
+ delete reader;
+ reader = NULL;
+ }
+
+ return ret_code;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::RecoverPluginFromFile( const DMString& file_bak_name )
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_FAIL;
+ DMFileHandler *fileHandle = new DMFileHandler( file_bak_name );
+
+ if( fileHandle )
+ {
+ BOOLEAN delete_file = FALSE;
+
+ if(fileHandle->open(XPL_FS_FILE_RDWR) != SYNCML_DM_SUCCESS)
+ {
+ // DM: Ignore files that cannot be opened ?
+ ret_code = SYNCML_DM_SUCCESS;
+ }
+ else
+ {
+ delete_file = TRUE;
+
+ DMBuffer cmdURI;
+ ret_code = ReadCommandFromFile( fileHandle, cmdURI );
+
+ if( ret_code == SYNCML_DM_SUCCESS )
+ {
+ PDMPlugin pPlugin = m_oPluginManager.FindPlugin(SYNCML_DM_DATA_PLUGIN, (CPCHAR)cmdURI.getBuffer());
+
+ if (pPlugin != NULL)
+ {
+ PDmtAPIPluginTree pluginTree;
+ ret_code=pPlugin->GetTree((CPCHAR) cmdURI.getBuffer(), pluginTree);
+
+ if(ret_code == SYNCML_DM_SUCCESS)
+ {
+ PDmtRWPluginTree ptrRWTree = (DmtRWPluginTree *) ((DmtTree *)pluginTree);
+ ret_code = ptrRWTree->setLogFileHandle(fileHandle);
+
+ if( ret_code == SYNCML_DM_SUCCESS)
+ {
+ ret_code = ptrRWTree->Rollback();
+
+ // DM: hands-off from file
+ fileHandle = NULL;
+ }
+ }
+ }
+ }
+ }
+
+ if( fileHandle )
+ {
+ if( delete_file )
+ {
+ fileHandle->deleteFile();
+ }
+
+ delete fileHandle;
+ fileHandle = NULL;
+ }
+ }
+
+ return ret_code;
+}
+
+SYNCML_DM_RET_STATUS_T DMTree::RecoverPlugin()
+{
+
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ DMString strFileNameBuffer;
+ DMString strFileBakNameBuffer;
+
+ char *file_name = strFileNameBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+ char *file_bak_name = strFileBakNameBuffer.AllocateBuffer(XPL_FS_MAX_FILE_NAME_LENGTH);
+
+ if ( !file_name || !file_bak_name )
+ return SYNCML_DM_DEVICE_FULL;
+
+ DMString logtdir;
+ m_oEnv.GetWFSFullPath( NULL, logtdir );
+
+ XPL_FS_SHANDLE_T search_handle = XPL_FS_StartSearch(logtdir, DMFileHandler::LOG_FILE_EXTENSION, TRUE, NULL);
+ if ( search_handle == XPL_FS_SHANDLE_INVALID)
+ return SYNCML_DM_IO_FAILURE;
+
+ //Loop through all .log files in the directory
+ memset(file_name, 0, XPL_FS_MAX_FILE_NAME_LENGTH );
+ memset(file_bak_name, 0, XPL_FS_MAX_FILE_NAME_LENGTH );
+
+ int nExtLength = DmStrlen( DMFileHandler::LOG_FILE_EXTENSION );
+
+ while ( XPL_FS_GetSearchResult(search_handle, file_name) != XPL_FS_RET_NOT_FOUND )
+ {
+ int nFileNameLen = DmStrlen(file_name);
+
+ if ( file_name[0] == 0 || nFileNameLen < 5 ) continue;
+
+ DmStrncpy(file_bak_name, file_name, nFileNameLen - nExtLength );
+ DmStrcat(file_bak_name, DMFileHandler::MIDDLE_FILE_EXTENSION);
+
+ if( XPL_FS_RET_SUCCESS != XPL_FS_Rename( file_name, file_bak_name ) )
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ continue;
+ }
+
+ ret_code = RecoverPluginFromFile( file_bak_name );
+ // DM: continue even if there is an error ( exactly as in original version of code )
+ }
+
+ XPL_FS_EndSearch(search_handle);
+ return ret_code;
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DmExecutePlugin(CPCHAR path,
+ CPCHAR args,
+ CPCHAR szCorrelator,
+ DMString & oResult)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_FAIL;
+ DMPluginManager & oPluginManager = dmTreeObj.GetPluginManager();
+
+ XPL_LOG_DM_TMN_Debug((" DmExecutePlugin find plugin\n"));
+ PDMPlugin pPlugin = oPluginManager.FindPlugin(SYNCML_DM_EXECUTE_PLUGIN, path);
+
+ if (pPlugin == NULL)
+ {
+ XPL_LOG_DM_TMN_Debug((" DmExecutePlugin plugin not found\n"));
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ }
+
+ PDmtTree ptrTree( new DmtTreeImpl(FALSE) ); // readonly version of the tree
+
+ XPL_LOG_DM_TMN_Debug((" DmExecutePlugin plugin being executed...\n"));
+ return pPlugin->Execute(path,args,szCorrelator,ptrTree,oResult);
+}
+
+SYNCML_DM_RET_STATUS_T
+DmCallPluginFunction(CPCHAR szSessionRootURI,
+ FILESETTYPE nFileSet,
+ SYNCML_DM_COMMAND_T type)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMPluginManager & oPluginManager = dmTreeObj.GetPluginManager();
+
+ DMPluginVector plugins;
+ PDmtAPIPluginTree pluginTree;
+
+ oPluginManager.GetPlugins(szSessionRootURI, SYNCML_DM_DATA_PLUGIN, plugins);
+
+ INT32 size = plugins.size();
+ for ( INT32 i=0; i<size; i++ )
+ {
+ PDMPlugin plugin = plugins[i];
+ if(plugin->IsTreeEmpty())
+ continue;
+
+ dm_stat=plugin->GetTree(plugin->GetPath(), pluginTree);
+ if(dm_stat == SYNCML_DM_SUCCESS)
+ {
+ switch(type)
+ {
+ case SYNCML_DM_RELEASE:
+ dm_stat = pluginTree->Flush();
+ break;
+
+ case SYNCML_DM_ROLLBACK:
+ {
+ FILESETTYPE sets = 0;
+
+ SyncML_DM_Archiver& archiver = dmTreeObj.GetArchiver();
+ sets = archiver.getArchivesByURI(plugin->GetPath());
+ sets &= nFileSet;
+
+ if ( sets != 0 )
+ {
+ dm_stat = pluginTree->Rollback();
+ }
+ }
+ break;
+
+ case SYNCML_DM_COMMIT:
+ dm_stat = pluginTree->Commit();
+ break;
+
+ case SYNCML_DM_ATOMIC:
+ dm_stat = pluginTree->Begin();
+ break;
+ }
+ }
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ if((dm_stat == SYNCML_DM_FEATURE_NOT_SUPPORTED)&&(type == SYNCML_DM_ATOMIC))
+ return dm_stat;
+ else
+ dm_stat = SYNCML_DM_SUCCESS;
+ }
+ }
+
+ XPL_LOG_DM_TMN_Debug((" DmCallPluginFunction retStat=%d\n", dm_stat));
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T
+DmCheckConstraint(CPCHAR szSessionRootURI,
+ FILESETTYPE * pFileSet,
+ FILESETTYPE * pFileSetToRollback)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ SYNCML_DM_RET_STATUS_T dm_const_stat = SYNCML_DM_SUCCESS;
+
+ SyncML_DM_Archiver& archiver = dmTreeObj.GetArchiver();
+ FILESETTYPE numArchives = archiver.getNumArchives();
+ FILESETTYPE i = 0;
+ FILESETTYPE set = 1;
+
+
+ if ( pFileSet == NULL || pFileSetToRollback == NULL )
+ return SYNCML_DM_FAIL;
+
+ XPL_LOG_DM_TMN_Debug(("--- DmCheckConstraint for %s, pFileSet=0x%x, numArchives=%d\n", szSessionRootURI, *pFileSet, numArchives));
+
+ if ( !archiver.IsDirty(pFileSet) )
+ {
+ XPL_LOG_DM_TMN_Debug(("No archives are dirty\n"));
+ return dm_stat;
+ }
+
+ DMPluginVector aSessionPlugins;
+
+ DMPluginManager & oPluginManager = dmTreeObj.GetPluginManager();
+ oPluginManager.GetPlugins(szSessionRootURI, SYNCML_DM_CONSTRAINT_PLUGIN, aSessionPlugins);
+
+ INT32 size = aSessionPlugins.size();
+ for (INT32 index=0; index< size; index++)
+ {
+ FILESETTYPE sets = 0;
+
+ CPCHAR strRootPath=(aSessionPlugins[index])->GetPath();
+
+ sets = archiver.getArchivesByURI(strRootPath);
+ sets = sets & (*pFileSet);
+ if ( sets )
+ {
+ dm_stat = DmCheckNodeConstraint(aSessionPlugins[index]);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ for (i=0, set=1; i< numArchives; i++, set = set <<1)
+ {
+ if ( (sets & set) != 0 && ((*pFileSetToRollback) & set) == 0 )
+ {
+ (*pFileSetToRollback) |= set;
+ (*pFileSet) &= ~ set;
+ }
+ }
+ dm_const_stat = dm_stat;
+ }
+ }
+ }
+
+ if ( dm_const_stat != SYNCML_DM_SUCCESS )
+ dm_stat = dm_const_stat;
+
+ XPL_LOG_DM_TMN_Debug((" DmCheckConstraint retStat=%d\n", dm_stat));
+ return dm_stat;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DmCheckNodeConstraint(const PDMPlugin & pPlugin)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtTree tree( new DmtTreeImpl(true) );
+
+ CPCHAR strPluginPath=pPlugin->GetPath();
+
+ if ( (DmStrchr(strPluginPath, '*')) == NULL)
+ {
+ dm_stat = (pPlugin)->CheckConstraint(strPluginPath,tree);
+ }
+ else
+ {
+ dm_stat = DmCheckMultiNodeConstraint(pPlugin,"",strPluginPath,tree);
+ }
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ dm_stat = SYNCML_DM_CONSTRAINT_FAIL;
+
+ return dm_stat;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DmCheckMultiNodeConstraint(const PDMPlugin & pPlugin,
+ CPCHAR path,
+ CPCHAR remain,
+ const PDmtTree & tree)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ const char * ptr; //point to remaining stuff after *
+
+ XPL_LOG_DM_TMN_Debug(("CheckMultiNode %s:%s\n", path, remain));
+
+ ptr=remain;
+ while ( * ptr != '*' && * ptr != '\0')
+ ptr ++;
+
+ if ( *ptr == '*' )
+ {
+ DMString strPath=path;
+ strPath += DMString(remain, (int) ptr - (int)remain -1);
+
+ ptr++;
+
+ DMStringVector mapNodeNames;
+ dm_stat = tree->GetChildNodeNames(strPath.c_str(),mapNodeNames);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ for (INT32 i=0; i<mapNodeNames.size(); i++)
+ {
+ DMString childPath;
+ childPath =strPath;
+ childPath += "/";
+ childPath += mapNodeNames[i];
+
+ dm_stat = DmCheckMultiNodeConstraint(pPlugin,childPath.c_str(),ptr,tree);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ }
+ }
+ else
+ {
+ DMString strPath=path;
+ strPath += remain;
+ dm_stat=(pPlugin)->CheckConstraint(strPath.c_str(),tree);
+ }
+
+
+ return dm_stat;
+}
diff --git a/engine/dmlib/dmengine/dm_tnm/src/dm_tree_util.cc b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_util.cc
new file mode 100644
index 0000000..2185386
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_tnm/src/dm_tree_util.cc
@@ -0,0 +1,409 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*=======================================================================
+
+ Module Name: dm_tree_util.c
+ General Description: Implementation of UTILITY functions provided by
+ DMTNM module
+=======================================================================*/
+
+#include "dm_tree_util.h"
+#include "dm_uri_utils.h"
+#include "xpl_Logger.h"
+
+SYNCML_DM_RET_STATUS_T dmGetNodeValue(CPCHAR uriPath, DmtData& oDmtData)
+{
+ SYNCML_DM_RET_STATUS_T status = SYNCML_DM_SUCCESS;
+
+ DMGetData getData;
+ status = dmTreeObj.Get(uriPath, getData, SYNCML_DM_REQUEST_TYPE_INTERNAL);
+ if (status == SYNCML_DM_SUCCESS) {
+ dmBuildData(getData.m_nFormat, getData.m_oData, oDmtData);
+ }
+ return status;
+}
+
+SYNCML_DM_RET_STATUS_T dmBuildData(SYNCML_DM_FORMAT_T format, const DMBuffer & oData, DmtData & oDmtData)
+{
+
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+ switch (format)
+ {
+ case SYNCML_DM_FORMAT_CHR:
+ case SYNCML_DM_FORMAT_INT:
+ case SYNCML_DM_FORMAT_BOOL:
+ case SYNCML_DM_FORMAT_FLOAT:
+ case SYNCML_DM_FORMAT_DATE:
+ case SYNCML_DM_FORMAT_TIME:
+ res = oDmtData.SetString((CPCHAR)oData.getBuffer(), format);
+ break;
+
+ case SYNCML_DM_FORMAT_BIN:
+ res = oDmtData.SetBinary(oData.getBuffer(), oData.getSize());
+ break;
+
+ case SYNCML_DM_FORMAT_NULL:
+ oDmtData = DmtData( (CPCHAR) NULL );
+ break;
+
+ case SYNCML_DM_FORMAT_NODE:
+ case SYNCML_DM_FORMAT_INVALID:
+ oDmtData = DmtData();
+ break;
+
+ default:
+ oDmtData = DmtData();
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ }
+ return res;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMGetData::set(SYNCML_DM_FORMAT_T wFormat,
+ CPCHAR pData,
+ UINT32 dataLength,
+ CPCHAR pMimeType)
+{
+
+ clear();
+ m_nFormat = wFormat;
+
+ if( dataLength != 0 && pData != NULL )
+ {
+ m_oData.assign(pData, dataLength);
+ if ( m_oData.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ if( pMimeType )
+ {
+ m_oMimeType.assign(pMimeType);
+ if ( m_oMimeType.getBuffer() == NULL && pMimeType[0] )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ return (SYNCML_DM_SUCCESS);
+
+}
+
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T DMGetData::set(DmtDataChunk *dmtChunk, UINT32 dmtChunkoffset)
+{
+ m_chunkOffset = dmtChunkoffset;
+ chunkData = dmtChunk;
+ return (SYNCML_DM_SUCCESS);
+}
+void DMGetData::clearESNData()
+{ m_chunkOffset = 0L;
+ chunkData = NULL;
+ m_bESN = FALSE;
+}
+#endif
+
+SYNCML_DM_RET_STATUS_T DMGetData::set(const DmtData & data, CPCHAR pMimeType)
+{
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+
+ clear();
+#ifdef LOB_SUPPORT
+ clearESNData();
+#endif
+ switch ( data.GetType() )
+ {
+ default:
+ {
+ DMString strValue;
+ data.GetString(strValue);
+ if ( strValue.length() )
+ {
+ m_oData.assign(strValue);
+ if ( m_oData.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ break;
+
+ case SYNCML_DM_DATAFORMAT_STRING:
+ {
+ const DMString & strValue = data.GetStringValue();
+ if ( strValue.length() )
+ {
+ m_oData.assign(strValue);
+ if ( m_oData.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ break;
+
+ case SYNCML_DM_DATAFORMAT_UNDEFINED:
+ case SYNCML_DM_DATAFORMAT_NULL:
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BIN:
+ {
+ DMVector<UINT8> & buffer = (DMVector<UINT8> &)data.GetBinaryValue();
+ if ( buffer.size() )
+ {
+ m_oData.assign(buffer.get_data(), buffer.size());
+ if ( m_oData.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ break;
+ }
+
+
+ switch ( data.GetType() )
+ {
+ case SYNCML_DM_DATAFORMAT_UNDEFINED:
+ m_nFormat=SYNCML_DM_FORMAT_INVALID;
+ break;
+
+ case SYNCML_DM_DATAFORMAT_NULL:
+ case SYNCML_DM_DATAFORMAT_BIN:
+ case SYNCML_DM_DATAFORMAT_STRING:
+ case SYNCML_DM_DATAFORMAT_INT:
+ case SYNCML_DM_DATAFORMAT_FLOAT:
+ case SYNCML_DM_DATAFORMAT_DATE:
+ case SYNCML_DM_DATAFORMAT_TIME:
+ case SYNCML_DM_DATAFORMAT_BOOL:
+ m_nFormat=data.GetType();
+ break;
+ }
+
+ if( pMimeType )
+ {
+ m_oMimeType.assign(pMimeType);
+ if ( m_oMimeType.getBuffer() == NULL && pMimeType[0] )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ return (SYNCML_DM_SUCCESS);
+}
+
+SYNCML_DM_RET_STATUS_T DMAddData::set(SYNCML_DM_FORMAT_T wFormat,
+ CPCHAR pMimeType)
+{
+ return DMGetData::set(wFormat, NULL, 0, pMimeType);
+
+}
+
+SYNCML_DM_RET_STATUS_T DMAddData::set(CPCHAR pURI,
+ SYNCML_DM_FORMAT_T wFormat,
+ CPCHAR pData,
+ UINT32 dataLength,
+ CPCHAR pMimeType)
+{
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+
+ clear();
+#ifdef LOB_SUPPORT
+ clearESNData();
+#endif
+
+ res = DMGetData::set(wFormat,pData,dataLength, pMimeType);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ if ( pURI )
+ {
+ m_oURI.assign(pURI);
+ if ( m_oURI.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ return (SYNCML_DM_SUCCESS);
+}
+
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T DMAddData::set(CPCHAR pURI,
+ DmtDataChunk *dmtChunk,
+ UINT32 dmtChunkoffset,
+ BOOLEAN isLastChunk)
+{
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+ m_oURI.clear();
+
+ if ( pURI )
+ {
+ m_oURI.assign(pURI);
+ if ( pURI[0] && m_oURI.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ res = DMGetData::set(dmtChunk, dmtChunkoffset);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ m_bLastChunk = isLastChunk;
+ return (SYNCML_DM_SUCCESS);
+}
+#endif
+SYNCML_DM_RET_STATUS_T DMAddData::set(CPCHAR pURI, const DmtData & data, CPCHAR pMimeType)
+{
+
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+
+ m_oURI.clear();
+
+ res = DMGetData::set(data, pMimeType);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ if ( pURI )
+ {
+ m_oURI.assign(pURI);
+ if ( pURI[0] && m_oURI.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ return (SYNCML_DM_SUCCESS);
+}
+
+#ifdef LOB_SUPPORT
+SYNCML_DM_RET_STATUS_T DMAddNodeProp::setESNFileName(CPCHAR pFileName)
+{
+ if ( pFileName )
+ {
+ m_oESNFileName.assign(pFileName);
+ if ( pFileName[0] && m_oESNFileName.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ return (SYNCML_DM_SUCCESS);
+}
+#endif
+
+
+SYNCML_DM_RET_STATUS_T DMAddNodeProp::set(CPCHAR pName,
+ CPCHAR pTitle,
+ SYNCML_DM_FORMAT_T wFormat,
+ CPCHAR pData,
+ UINT32 dataLength,
+ CPCHAR pMimeType,
+ UINT16 flag)
+{
+
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+
+ m_oName.clear();
+ m_oTitle.clear();
+
+ res = DMAddData::set(NULL, wFormat, pData, dataLength, pMimeType);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ if ( pName )
+ {
+ m_oName.assign(pName);
+ if ( pName[0] && m_oName.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ if ( pTitle )
+ {
+ m_oTitle.assign(pName);
+ if ( pTitle[0] && m_oTitle.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ m_nFlags = flag;
+
+ return SYNCML_DM_SUCCESS;
+
+
+
+}
+
+
+
+ /**
+ * Free the memory of the GET data structure in the Map
+ *
+ * @author Andy
+ * @param getDataMap the GET data structure Map to be free
+ * @return the status of the operation
+ */
+void dmFreeGetMap( DMMap<DMString, UINT32>& getDataMap)
+{
+ DMGetData* tmpData = NULL;
+ for ( DMMap<DMString, UINT32>::POS it = getDataMap.begin(); it < getDataMap.end(); it++ )
+ {
+ tmpData = (DMGetData*)getDataMap.get_value(it);
+
+ if (tmpData != NULL)
+ delete tmpData;
+ }
+
+ getDataMap.clear();
+}
+
+/**
+ * Free the memory of the ADD data structure in the Map
+ *
+ * @author Andy
+ * @param addDataMap the ADD data structure Map to be free
+ * @return the status of the operation
+ */
+void dmFreeAddMap( DMMap<DMString, UINT32>& addDataMap)
+{
+ DMAddData * tmpData = NULL;
+ for ( DMMap<DMString, UINT32>::POS it = addDataMap.begin(); it < addDataMap.end(); it++ )
+ {
+ tmpData = (DMAddData *)addDataMap.get_value(it);
+ delete tmpData;
+ }
+ addDataMap.clear();
+}
+
+
+/**
+ * Convert the GET data map to ADD data map
+ *
+ * @author Andy
+ * @param path the path to the parent of the nodes in the map
+ * @param mapNodes, the GET data map
+ * @param newChildrenMap the ADD data map
+ * @return the status of the operation
+ */
+SYNCML_DM_RET_STATUS_T dmConvertDataMap(CPCHAR path, const DMMap<DMString, DmtData>& mapNodes, DMMap<DMString, UINT32>& newChildrenMap)
+{
+ SYNCML_DM_RET_STATUS_T res;
+ DMAddData * pData = NULL;
+
+ for ( DMMap<DMString, DmtData>::POS it = mapNodes.begin(); it != mapNodes.end(); it++ )
+ {
+ DMString strChildPath = path;
+ strChildPath += "/";
+ strChildPath += mapNodes.get_key( it );
+ pData = new DMAddData();
+ if ( pData == NULL )
+ {
+ XPL_LOG_DM_TMN_Error(("dmConvertDataMap : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ res = pData->set(strChildPath,mapNodes.get_value( it ),"text/plain");
+ if ( res != SYNCML_DM_SUCCESS )
+ {
+ delete pData;
+ return res;
+ }
+ newChildrenMap.put(mapNodes.get_key( it ), (UINT32)pData);
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_transport/hdr/DM_DmConnRef.h b/engine/dmlib/dmengine/dm_transport/hdr/DM_DmConnRef.h
new file mode 100644
index 0000000..b4918be
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_transport/hdr/DM_DmConnRef.h
@@ -0,0 +1,401 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_DMCONNREF_H
+#define DM_DMCONNREF_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//--------------------------------------------------------------------------------------------------
+//
+// Header Name: DM_DmConnRef.h
+//
+// General Description: DmConnRef implementation class header file.
+//
+//--------------------------------------------------------------------------------------------------
+
+#include "dmstring.h"
+#include "dmvector.h"
+#include "dmt.hpp"
+#include "DM_DmtUtil.h"
+
+/**
+ * The dm connection reference class.
+ */
+class DmConnRef {
+public:
+ /**
+ * The definition for the node path - ./SyncML/Con.
+ */
+ static const char * const SYNCML_CON;
+ /**
+ * The definition for the node name - NAP.
+ */
+ static const char * const NODE_NAME_NAP;
+ /**
+ * The definition for the node name - PX.
+ */
+ static const char * const NODE_NAME_PX;
+ /**
+ * The definition for the node name - Bearer.
+ */
+ static const char * const NODE_NAME_BEARER;
+ /**
+ * The definition for the node name - AddrType.
+ */
+ static const char * const NODE_NAME_ADDRTYPE;
+ /**
+ * The definition for the node name - Addr.
+ */
+ static const char * const NODE_NAME_ADDR;
+ /**
+ * The definition for the node name - Auth.
+ */
+ static const char * const NODE_NAME_AUTH;
+ /**
+ * The definition for the node name - Id.
+ */
+ static const char * const NODE_NAME_ID;
+ /**
+ * The definition for the node name - Secret.
+ */
+ static const char * const NODE_NAME_SECRET;
+ /**
+ * The definition for the node name - PortNbr.
+ */
+ static const char * const NODE_NAME_PORTNBR;
+
+ /**
+ * The data structure for ./SyncML/Con/w/NAP
+ */
+ class DmSyncmlNAP * mpNAP;
+
+ /**
+ * The data structure for ./SyncML/Con/w/PX
+ */
+ class DmSyncmlPX * mpPX;
+
+ /**
+ * The default deconstructor.
+ */
+ ~DmConnRef();
+
+ /**
+ * Create a instance for DmConnRef.
+ * @param ConRef the value in the node ./SyncML/DMAcc/x/ConRef
+ * @return a pointer to the DmConnRef instance. Return NULL for error.
+ * @note please release the instance by invoker, after finishing to use
+ * the instance.
+ */
+ static DmConnRef * Create(const char * ConRef);
+
+ /**
+ * Create a network profile.
+ * @param profile the network profile name. If users pass a profile name,
+ * then this function will create a real profile in the phone. If users pass
+ * a temp profile with the full path, such as /tmp/dm_tmp_profile, this function
+ * will create a temp profile, and users can not see it in the UI. After finishing
+ * to use the tmp profile, invoker need call DeleteNetworkProfile(const char * profile)
+ * to remove the tmp profile.
+ * @return true, if successful. Otherwise, return false, if any errors.
+ * @note After finishing to use the tmp profile, invoker need call DeleteNetworkProfile(const char * profile)
+ * to remove the tmp profile.
+ */
+ bool CreateNetworkProfile(INT8 * profile);
+
+ /**
+ * Delete a network profile.
+ * @param profile the network profile name.
+ * @return true, if successful. Otherwise, return false, if any errors.
+ * @see CreateNetworkProfile(const char * profile);
+ */
+ bool DeleteNetworkProfile(INT8 * profile);
+
+ /**
+ * Get the proxy IP address and port, which type is IPV4.
+ * @param proxy [out] the proxy IP address.
+ * @param port [out] the proxy port.
+ * @return true, if successful. Otherwise, return false, if any errors.
+ */
+ bool GetIPV4Proxy(DMString &proxy, UINT16 &port);
+
+ /**
+ * Get the proxy user and password.
+ * @param user [out] the proxy user.
+ * @param pwd [out] the proxy pwd.
+ * @return true, if successful. Otherwise, return false, if any errors.
+ */
+ bool GetIPV4ProxyAuth(DMString &user, DMString &pwd);
+
+private:
+ /**
+ * The protected default constructor.
+ */
+ DmConnRef() {
+ mpNAP = NULL;
+ mpPX = NULL;
+ };
+
+ /**
+ * Get the DmSyncmlNAP instance.
+ * @param pTree pTree the pointer to DmtTree instance.
+ * @return a pointer to the DmSyncmlNAP instance. Return NULL for error.
+ */
+ static DmSyncmlNAP * GetNAP(PDmtTree pTree);
+
+ /**
+ * Get the DmSyncmlPX instance.
+ * @param pTree pTree the pointer to DmtTree instance.
+ * @return a pointer to the DmSyncmlPX instance. Return NULL for error.
+ */
+ static DmSyncmlPX * GetPX(PDmtTree pTree);
+
+ /**
+ * Get the DMMap<DMString, DmSyncmlAuth>.
+ * The key will be the node name of ./SyncML/Con/w/PX/Auth/z
+ * or the node name of ./SyncML/Con/w/NAP/Auth/y
+ * The value will be the instance of DmSyncmlAuth.
+ * @param pTree pTree the pointer to DmtTree instance.
+ * @param nodeName the node name.
+ * @param auths [out] the DMMap<DMString, DmSyncmlAuth>.
+ * @return true, if successful, otherwise return false.
+ */
+ static bool GetAuths(PDmtTree pTree, const char * nodeName,
+ DMMap<DMString, class DmSyncmlAuth> &auths);
+};
+
+/**
+ * This class will describe the structure for ./SyncML/Con/w/NAP/Auth and
+ * ./SyncML/Con/w/PX/Auth
+ * Used as structure.
+ */
+class DmSyncmlAuth {
+public:
+ /**
+ * The definition for ./SyncML/Con/w/NAP/Auth/y in SyncML dm spec.
+ * NAP_AUTH_PAP is for PAP - "Password Authentication Protocol"
+ * NAP_AUTH_CHAP is for CHAP - "Challenge Handshake Authentication Protocol"
+ */
+ static const char * const NAP_AUTH_PAP;
+ static const char * const NAP_AUTH_CHAP;
+
+ /**
+ * The definition for ./SyncML/Con/w/PX/Auth/z in SyncML dm spec.
+ */
+ static const char * const PX_AUTH_HTTP_BASIC;
+ static const char * const PX_AUTH_HTTP_DIGEST;
+ static const char * const PX_AUTH_WTLS_SS;
+
+ /**
+ * ./SyncML/Con/w/NAP/Auth/y/Id
+ * ./SyncML/Con/w/PX/Auth/z/Id
+ */
+ DMString mId;
+ /**
+ * ./SyncML/Con/w/NAP/Auth/y/Secret
+ * ./SyncML/Con/w/PX/Auth/z/Secret
+ */
+ DMString mSecret;
+
+ /**
+ * The default constructor.
+ */
+ DmSyncmlAuth() {
+ };
+
+ /**
+ * The copy constructor.
+ * @param id ./SyncML/Con/w/NAP/Auth/y/Id or ./SyncML/Con/w/PX/Auth/z/Id.
+ * @param secret ./SyncML/Con/w/NAP/Auth/y/Secret
+ * or ./SyncML/Con/w/PX/Auth/z/Secret.
+ */
+ DmSyncmlAuth(DmSyncmlAuth &auth) {
+ mId = auth.mId;
+ mSecret = auth.mSecret;
+ };
+
+ /**
+ * The constructor.
+ * @param id ./SyncML/Con/w/NAP/Auth/y/Id or ./SyncML/Con/w/PX/Auth/z/Id.
+ * @param secret ./SyncML/Con/w/NAP/Auth/y/Secret
+ * or ./SyncML/Con/w/PX/Auth/z/Secret.
+ */
+ DmSyncmlAuth(DMString id, DMString secret) {
+ mId = id;
+ mSecret = secret;
+ };
+
+ inline DmSyncmlAuth & operator= (const DmSyncmlAuth &auth) {
+ mId = auth.mId;
+ mSecret = auth.mSecret;
+ return *this;
+ }
+};
+
+/**
+ * This class will describe the structure for ./SyncML/Con/w/NAP
+ * Used as structure.
+ */
+class DmSyncmlNAP {
+public:
+ /**
+ * The definition for ./SyncML/Con/w/NAP/Bearer in SyncML dm spec.
+ */
+ enum NAP_BEARER {
+ NAP_BEARER_OBEX = 1,
+ NAP_BEARER_GSM_USSD = 2,
+ NAP_BEARER_GSM_SMS = 3,
+ NAP_BEARER_ANSI_136_GUTS = 4,
+ NAP_BEARER_IS_95_CDMA_SMS = 5,
+ NAP_BEARER_IS_95_CDMA_CSD = 6,
+ NAP_BEARER_IS_95_CDMA_PACKET = 7,
+ NAP_BEARER_ANSI_136_CSD = 8,
+ NAP_BEARER_ANSI_136_GPRS = 9,
+ NAP_BEARER_GSM_CSD = 10,
+ NAP_BEARER_GSM_GPRS = 11,
+ NAP_BEARER_AMPS_CDPD = 12,
+ NAP_BEARER_PDC_CSD = 13,
+ NAP_BEARER_PDC_PACKET = 14,
+ NAP_BEARER_IDEN_SMS = 15,
+ NAP_BEARER_IDEN_CSD = 16,
+ NAP_BEARER_IDEN_PACKET = 17,
+ NAP_BEARER_FLEX_REFLEX = 18,
+ NAP_BEARER_PHS_SMS = 19,
+ NAP_BEARER_PHS_CSD = 20,
+ NAP_BEARER_TETRA_SDS = 21,
+ NAP_BEARER_TETRA_PACKET = 22,
+ NAP_BEARER_MOBITEX_MPAK = 23,
+ NAP_BEARER_ANSI_136_GHOST = 24
+ };
+
+ /**
+ * The definition for ./SyncML/Con/w/NAP/AddrType in SyncML dm spec.
+ */
+ enum NAP_ADDRTYPE {
+ NAP_ADDRTYPE_IPV4 = 1,
+ NAP_ADDRTYPE_IPV6 = 2,
+ NAP_ADDRTYPE_E164 = 3,
+ NAP_ADDRTYPE_ALPHA = 4,
+ NAP_ADDRTYPE_APN = 5
+ } ;
+
+ /**
+ * ./SyncML/Con/w/NAP/Bearer
+ */
+ NAP_BEARER mBearer;
+
+ /**
+ * ./SyncML/Con/w/NAP/AddrType
+ */
+ NAP_ADDRTYPE mAddrType;
+
+ /**
+ * ./SyncML/Con/w/NAP/Addr
+ */
+ DMString mAddr;
+
+ /**
+ * ./SyncML/Con/w/NAP/Auth
+ */
+ DMMap<DMString, DmSyncmlAuth> mAuth;
+
+ /**
+ * The default constructor.
+ */
+ DmSyncmlNAP() {
+ mBearer = NAP_BEARER_GSM_GPRS;
+ mAddrType = NAP_ADDRTYPE_APN;
+ };
+
+ /**
+ * The constructor.
+ * @param bearer ./SyncML/Con/w/NAP/Bearer
+ * @param addrType ./SyncML/Con/w/NAP/AddrType
+ * @param addr ./SyncML/Con/w/NAP/Addr
+ * @param auth ./SyncML/Con/w/NAP/Auth
+ */
+ DmSyncmlNAP(NAP_BEARER bearer, NAP_ADDRTYPE addrType, DMString addr,
+ DMMap<DMString, DmSyncmlAuth> auth) {
+ mBearer = bearer;
+ mAddrType = addrType;
+ mAddr = addr;
+ mAuth = auth;
+ };
+};
+
+/**
+ * This class will describe the structure for ./SyncML/Con/w/PX
+ * Used as structure.
+ */
+class DmSyncmlPX {
+public:
+ /**
+ * The definition for ./SyncML/Con/w/PX/AddrType in SyncML dm spec.
+ */
+ enum PX_ADDRTYPE {
+ PX_ADDRTYPE_IPV4 = 1,
+ PX_ADDRTYPE_IPV6 = 2,
+ PX_ADDRTYPE_E164 = 3,
+ PX_ADDRTYPE_ALPHA = 4
+ };
+
+ /**
+ * ./SyncML/Con/w/PX/Bearer
+ */
+ UINT16 mPortNbr;
+
+ /**
+ * ./SyncML/Con/w/PX/AddrType
+ */
+ PX_ADDRTYPE mAddrType;
+
+ /**
+ * ./SyncML/Con/w/PX/Addr
+ */
+ DMString mAddr;
+
+ /**
+ * ./SyncML/Con/w/PX/Auth
+ */
+ DMMap<DMString, DmSyncmlAuth> mAuth;
+
+ /**
+ * The default constructor.
+ */
+ DmSyncmlPX() {
+ mAddrType = PX_ADDRTYPE_IPV4;
+ mPortNbr = 80;
+ };
+
+ /**
+ * The constructor.
+ * @param portNbr ./SyncML/Con/w/PX/PortNbr
+ * @param addrType ./SyncML/Con/w/PX/AddrType
+ * @param addr ./SyncML/Con/w/PX/Addr
+ * @param auth ./SyncML/Con/w/PX/Auth
+ */
+ DmSyncmlPX(UINT16 portNbr, PX_ADDRTYPE addrType, DMString addr,
+ DMMap<DMString, DmSyncmlAuth> auth) {
+ mPortNbr = portNbr;
+ mAddrType = addrType;
+ mAddr = addr;
+ mAuth = auth;
+ };
+};
+
+#endif //DM_DMCONNREF_H
diff --git a/engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_connection.H b/engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_connection.H
new file mode 100644
index 0000000..025f375
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_connection.H
@@ -0,0 +1,249 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_TPT_CONNECTION_H
+#define _DM_TPT_CONNECTION_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//-----------------------------------------------------------------------
+//
+// Header Name: dm_tpt_connection.H
+//
+// General Description: This file contains the class declaration for
+// SYNCML_DM_Connection and SYNCML_DM_OTAConnection.
+//
+//-----------------------------------------------------------------------
+
+#include "syncml_dm_data_types.h"
+#include "dm_tpt_utils.h"
+#include "dmSessionDefs.h"
+#include "dmMemory.h"
+#include "xpl_HTTP.h"
+
+
+//-----------------------------------------------------------------------
+// CONSTANTS
+//-----------------------------------------------------------------------
+
+// define for initial chunk size for HTTP transport
+#define DMTPT_HTTP_CHUNK_SIZE 10240
+
+// define for initial chunk size for WSP transport
+#define DMTPT_WSP_CHUNK_SIZE 8192
+
+// define for maximum number of retries
+#define DMTPT_MAX_RETRIES 5
+
+//-----------------------------------------------------------------------
+// MACROS
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+// ENUMS
+//-----------------------------------------------------------------------
+//-----------------------------------------------------------------------
+// STRUCTURES AND OTHER TYPEDEFS
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+// GLOBAL VARIABLE DECLARATIONS
+//-----------------------------------------------------------------------
+//-----------------------------------------------------------------------
+// FUNCTION PROTOTYPES
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+// CLASS
+//-----------------------------------------------------------------------
+
+
+#if (!defined (PLATFORM_ANDROID) || defined(DM_NATIVE_HTTP))
+// Abstract class that provides the interfaces to the DMUA for Sending/
+// Receiving documents
+
+class SYNCML_DM_Connection
+{
+protected:
+
+ // AddrType stores stores the format and interpretation of the
+ // DMAcc/x/AddrType node value
+ XPL_ADDR_TYPE_T AddrType;
+
+ // URL of the SyncML DM Server
+ DMString m_szURL;
+
+public:
+
+ virtual SYNCML_DM_RET_STATUS_T Init(UINT32 dwMaxAcptSize,
+ XPL_ADDR_TYPE_T AddressType,
+ CPCHAR ConRef) = 0;
+
+ // Interface for Send method
+ virtual SYNCML_DM_RET_STATUS_T Send(
+ const SYNCML_DM_INDIRECT_BUFFER_T *psSendDoc,
+ SYNCML_DM_INDIRECT_BUFFER_T *psRecvDoc,
+ const UINT8 *pbContentType,
+ const DMCredHeaders * psCredHeaders) = 0;
+
+ // Interface for SetURI method
+ virtual SYNCML_DM_RET_STATUS_T SetURI(CPCHAR szURL);
+
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+};
+
+
+class SYNCML_DM_OTAConnection : public SYNCML_DM_Connection
+{
+public:
+
+ SYNCML_DM_OTAConnection();
+
+ virtual ~SYNCML_DM_OTAConnection();
+
+ virtual SYNCML_DM_RET_STATUS_T Init(UINT32 dwMaxAcptSize,
+ XPL_ADDR_TYPE_T AddressType,
+ CPCHAR ConRef);
+
+ // Method to send the SyncML document to the SyncML Server
+ virtual SYNCML_DM_RET_STATUS_T Send(
+ const SYNCML_DM_INDIRECT_BUFFER_T *psSendDoc,
+ SYNCML_DM_INDIRECT_BUFFER_T *psRecvDoc,
+ const UINT8 *pbContentType,
+ const DMCredHeaders * psCredHeaders);
+
+private:
+
+ XPL_HTTP_HANDLE_T m_hConnection;
+
+ // Number of retries that are attempted
+ UINT8 bNumRetries;
+
+ // Maximum size of the Message
+ MAX_MSG_SIZE_T dwMaxAcceptSize;
+
+ // HTTP header to be sent to the Server
+ DMBuffer m_oHttpHdr;
+
+ // SyncML document to be sent to the Server
+ SYNCML_DM_INDIRECT_BUFFER_T *psSendSyncMLDoc;
+
+ // SyncML document to be received from the Server
+ SYNCML_DM_INDIRECT_BUFFER_T *psRecvSyncMLDoc;
+
+ // Credential headers sent and received from the Server
+ DMCredHeaders * m_pCredHeaders;
+
+ DMString m_szConRef;
+
+#ifdef DM_DUMP_SYNCML_PACKAGE
+
+ // The path where the dump package file stores
+ DMString dump_path;
+
+ int package_counter;
+
+ char * HTTP_HEADER_SERVER;
+ char * HTTP_HEADER_DATE;
+ char * HTTP_HEADER_ACCEPT_RANGES;
+ char * HTTP_HEADER_CACHE_CONTROL;
+ char * HTTP_HEADER_CONNECTION;
+ char * HTTP_HEADER_CONTENT_TYPE;
+ char * HTTP_HEADER_X_SYNCML_HMAC;
+
+ DMString bodyFileName;
+ DMString bodyFileExt;
+
+ DMString hdrFileName;
+ DMString hdrFileExt;
+
+#endif
+
+ // Method that prepares request headers
+ SYNCML_DM_RET_STATUS_T PrepareRequestHeaders(const UINT8 *pbContentTypetoSend);
+
+ // Method that computes the HTTP header fields length
+ UINT16 ComputeHTTPHeaderLength(const UINT8 *pbContentTypetoSend);
+
+ // Method that Sends the Inital chunk of the SyncML document
+ SYNCML_DM_RET_STATUS_T SendInitialChunk(void);
+
+ SYNCML_DM_RET_STATUS_T ProcessCredHeaders(CPCHAR pbOrigHmacStr);
+
+ SYNCML_DM_RET_STATUS_T IssueURLRequest(XPL_HTTP_CODE_T *ret_code);
+
+ SYNCML_DM_RET_STATUS_T ConvertXPLCode(XPL_HTTP_RET_STATUS_T http_result);
+};
+
+#else //under android platform
+
+#include "JNIHelp.h"
+#include "jni.h"
+
+class SYNCML_DM_OTAConnection
+{
+ public:
+
+ SYNCML_DM_OTAConnection();
+
+ ~SYNCML_DM_OTAConnection();
+
+ SYNCML_DM_RET_STATUS_T Init(UINT32 dwMaxAcptSize,
+ XPL_ADDR_TYPE_T AddressType,
+ CPCHAR ConRef);
+
+ // Method to send the SyncML document to the SyncML Server
+ SYNCML_DM_RET_STATUS_T Send(
+ const SYNCML_DM_INDIRECT_BUFFER_T *psSendDoc,
+ SYNCML_DM_INDIRECT_BUFFER_T *psRecvDoc,
+ const UINT8 *pbContentType,
+ const DMCredHeaders * psCredHeaders);
+
+ SYNCML_DM_RET_STATUS_T SetURI(CPCHAR szURL);
+
+ private:
+
+ SYNCML_DM_RET_STATUS_T ProcessCredHeaders(CPCHAR pbOrigHmacStr);
+ UINT32 m_maxAcptSize;
+
+ DMString m_szURL;
+
+ jobject m_jNetConnObj;
+
+ jmethodID m_jSendRequest;
+ jmethodID m_jGetRespLength;
+ jmethodID m_jGetRespData;
+ jmethodID m_jSetContentType;
+ jmethodID m_jclose;
+ jmethodID m_jEnbleApnByName;
+
+ // Credential headers sent and received from the Server
+ DMCredHeaders * m_pCredHeaders;
+};
+#endif
+
+//---------------------------------------------------------------------
+#endif /* _DM_TPT_CONNECTION_H */
diff --git a/engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_connection.H.contrib b/engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_connection.H.contrib
new file mode 100644
index 0000000..1889dfe
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_connection.H.contrib
@@ -0,0 +1,208 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_TPT_CONNECTION_H
+#define _DM_TPT_CONNECTION_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//-----------------------------------------------------------------------
+//
+// Header Name: dm_tpt_connection.H
+//
+// General Description: This file contains the class declaration for
+// SYNCML_DM_Connection & SYNCML_DM_OTAConnection class
+//
+//-----------------------------------------------------------------------
+
+#include "syncml_dm_data_types.h"
+#include "dm_tpt_utils.h"
+#include "dmSessionDefs.h"
+#include "dmMemory.h"
+#include "xpl_HTTP.h"
+
+
+//-----------------------------------------------------------------------
+// CONSTANTS
+//-----------------------------------------------------------------------
+
+// define for initial chunk size for HTTP transport
+#define DMTPT_HTTP_CHUNK_SIZE 10240
+
+// define for initial chunk size for WSP transport
+#define DMTPT_WSP_CHUNK_SIZE 8192
+
+// define for maximum number of retries
+#define DMTPT_MAX_RETRIES 3
+
+//-----------------------------------------------------------------------
+// MACROS
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+// ENUMS
+//-----------------------------------------------------------------------
+//-----------------------------------------------------------------------
+// STRUCTURES AND OTHER TYPEDEFS
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+// GLOBAL VARIABLE DECLARATIONS
+//-----------------------------------------------------------------------
+//-----------------------------------------------------------------------
+// FUNCTION PROTOTYPES
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+// CLASS
+//-----------------------------------------------------------------------
+
+
+
+// Abstract class that provides the interfaces to the DMUA for Sending/
+// Receiving documents
+
+class SYNCML_DM_Connection
+{
+protected:
+ // AddrType stores stores the format and interpretation of the
+ // DMAcc/x/AddrType node value
+
+ XPL_ADDR_TYPE_T AddrType;
+
+ // URL of the SyncML DM Server
+ DMString m_szURL;
+
+public:
+
+ virtual SYNCML_DM_RET_STATUS_T Init(UINT32 dwMaxAcptSize,
+ XPL_ADDR_TYPE_T AddressType,
+ CPCHAR ConRef) = 0;
+
+ // Interface for Send method
+ virtual SYNCML_DM_RET_STATUS_T Send(
+ const SYNCML_DM_INDIRECT_BUFFER_T *psSendDoc,
+ SYNCML_DM_INDIRECT_BUFFER_T *psRecvDoc,
+ const UINT8 *pbContentType,
+ const DMCredHeaders * psCredHeaders) = 0;
+
+ // Interface for SetURI method
+ virtual SYNCML_DM_RET_STATUS_T SetURI(CPCHAR szURL);
+
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+
+};
+
+
+class SYNCML_DM_OTAConnection : public SYNCML_DM_Connection
+{
+
+public:
+
+ SYNCML_DM_OTAConnection();
+
+
+ ~SYNCML_DM_OTAConnection();
+
+ virtual SYNCML_DM_RET_STATUS_T Init(UINT32 dwMaxAcptSize,
+ XPL_ADDR_TYPE_T AddressType,
+ CPCHAR ConRef);
+
+ // Method to send the SyncML document to the SyncML Server
+ virtual SYNCML_DM_RET_STATUS_T Send(
+ const SYNCML_DM_INDIRECT_BUFFER_T *psSendDoc,
+ SYNCML_DM_INDIRECT_BUFFER_T *psRecvDoc,
+ const UINT8 *pbContentType,
+ const DMCredHeaders * psCredHeaders);
+
+
+private:
+ XPL_HTTP_HANDLE_T m_hConnection;
+
+ // Number of retries that are attempted
+ UINT8 bNumRetries;
+
+ // Maximum size of the Message
+ MAX_MSG_SIZE_T dwMaxAcceptSize;
+
+ // HTTP header to be sent to the Server
+ DMBuffer m_oHttpHdr;
+
+ // SyncML document to be sent to the Server
+ SYNCML_DM_INDIRECT_BUFFER_T *psSendSyncMLDoc;
+
+ // SyncML document to be received from the Server
+ SYNCML_DM_INDIRECT_BUFFER_T *psRecvSyncMLDoc;
+
+ // Credential headers sent and received from the Server
+ DMCredHeaders * m_pCredHeaders;
+
+
+ DMString m_szConRef;
+
+#ifdef DM_DUMP_SYNCML_PACKAGE
+
+ // The path where the dump package file stores
+ DMString dump_path;
+
+ int package_counter;
+
+ char * HTTP_HEADER_SERVER;
+ char * HTTP_HEADER_DATE;
+ char * HTTP_HEADER_ACCEPT_RANGES;
+ char * HTTP_HEADER_CACHE_CONTROL;
+ char * HTTP_HEADER_CONNECTION;
+ char * HTTP_HEADER_CONTENT_TYPE;
+ char * HTTP_HEADER_X_SYNCML_HMAC;
+
+ DMString bodyFileName;
+ DMString bodyFileExt;
+
+ DMString hdrFileName;
+ DMString hdrFileExt;
+#endif
+
+ // Method that prepares request headers
+ SYNCML_DM_RET_STATUS_T PrepareRequestHeaders(const UINT8 *pbContentTypetoSend);
+
+ // Method that computes the HTTP header fields length
+ UINT16 ComputeHTTPHeaderLength(const UINT8 *pbContentTypetoSend);
+
+ // Method that Sends the Inital chunk of the SyncML document
+ SYNCML_DM_RET_STATUS_T SendInitialChunk(void);
+
+ SYNCML_DM_RET_STATUS_T ProcessCredHeaders(CPCHAR pbOrigHmacStr);
+
+ SYNCML_DM_RET_STATUS_T IssueURLRequest(XPL_HTTP_CODE_T *ret_code);
+
+ SYNCML_DM_RET_STATUS_T ConvertXPLCode(XPL_HTTP_RET_STATUS_T http_result);
+
+};
+
+
+//---------------------------------------------------------------------
+#endif /* _DM_TPT_CONNECTION_H */
diff --git a/engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_utils.h b/engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_utils.h
new file mode 100644
index 0000000..dbeaf4f
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_transport/hdr/dm_tpt_utils.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _DM_TPT_UTILS_H
+#define _DM_TPT_UTILS_H
+
+//-----------------------------------------------------------------------
+//
+// Header Name: dm_tpt_utils.h
+//
+// General Description: This file contains Transport utility function
+// prototypes.
+//-----------------------------------------------------------------------
+
+#include "syncml_dm_data_types.h"
+
+//-----------------------------------------------------------------------
+// MACROS
+//-----------------------------------------------------------------------
+
+#define SKIP_WHITESPACE(s) \
+ while (((s)[0] == ' ')||((s)[0] == ',')||((s)[0] == '\t')||((s)[0] == ';')) (s) ++
+
+//-----------------------------------------------------------------------
+// FUNCTION PROTOTYPES
+//-----------------------------------------------------------------------
+
+
+UINT8* DMTPTTrimString(UINT8 *pbOrigHmacStr);
+
+UINT8* DM_TPT_splitParamValue (UINT8* pbLine, // i: line
+ UINT8** ppbParm, // o: ptr to extracted parameter
+ UINT8** ppbValue); // o: ptr to extracted parameter value
+
+#endif //_DM_TPT_UTILS_H
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/dmengine/dm_transport/src/dm_tpt_connection.cc b/engine/dmlib/dmengine/dm_transport/src/dm_tpt_connection.cc
new file mode 100644
index 0000000..6af571b
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_transport/src/dm_tpt_connection.cc
@@ -0,0 +1,958 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//-----------------------------------------------------------------------
+//
+// Module Name: dm_tpt_connection.cc
+//
+// General Description: This file contains the Implementation of
+// SYNCML_DM_OTAConnection class
+//
+//------------------------------------------------------------------------
+
+#include "dm_tpt_connection.H"
+#include "dm_tree_util.h"
+#include "xpl_Logger.h"
+#include "xpl_File.h"
+
+//------------------------------------------------------------------------
+// LOCAL MACROS
+//------------------------------------------------------------------------
+
+// Size of MD5 string
+#define DMTPT_MD5_STRING_SIZE 3
+
+// Maximum size of the MAC string size
+#define DMTPT_MAX_MAC_SIZE 100
+
+// Maximiun size of the Algorithm string
+#define DMTPT_MAX_ALGO_SIZE 10
+
+// Maximiun value of the Request ID.
+#define DMTPT_MAX_REQ_ID_VALUE 30000
+
+// Language to be used
+#define DMTPT_HTTP_LANGUAGE "en"
+
+// Name of the DM Client
+#define DMTPT_CLIENT_NAME "Motorola SyncML DM Client ["DMTPT_HTTP_LANGUAGE"] "
+
+// Version of the HTTP protocol used
+#define DMTPT_HTTP_VERSION "HTTP/1.0"
+
+#define DMTPT_HTTP_MIME_TYPES "application/vnd.syncml.dm+wbxml"
+
+// Specifying the Cache-control Http header field option
+#define DMTPT_HTTP_CACHECONTROL "private"
+
+// Defining location string
+// WSP module converts headers to lower-case
+#define DMTPT_FIELD_LOCATION "location:"
+
+// Defining location string
+// HTTP stack maintains headers in mixed-case
+#define DMTPT_FIELD_LOCATION_HTTP "Location:"
+
+// Size of the Location string
+#define DMTPT_LOCATION_SIZE 9
+
+// User Agent Header Field
+#define DMTPT_USER_AGENT_HF "User-Agent: "
+#define DMTPT_USER_AGENT_HF_LEN 12
+
+//Accept Haeder field
+#define DMTPT_ACCEPT_HF "Accept: "
+#define DMTPT_ACCEPT_HF_LEN 8
+
+//Accept language header field
+#define DMTPT_ACCEPT_LANG_HF "Accept-Language: "
+#define DMTPT_ACCEPT_LANG_HF_LEN 17
+
+//Accept Charset header
+#define DMTPT_ACCEPT_CHARSET "Accept-Charset: utf-8"
+#define DMTPT_ACCEPT_CHARSET_LEN 21
+
+//Cache control header field
+#define DMTPT_CACHE_CONTROL_HF "Cache-Control: "
+#define DMTPT_CACHE_CONTROL_HF_LEN 15
+
+//Content type header field
+#define DMTPT_CONT_TYPE_HF "Content-type: "
+#define DMTPT_CONT_TYPE_HF_LEN 14
+
+
+//HMAC Algo
+#define DMTPT_HMAC_ALGO_HF "x-syncml-hmac: algorithm="
+#define DMTPT_HMAC_ALGO_HF_LEN 25
+
+//HMAC uname
+#define DMTPT_HMAC_UNAME_HF ", username="
+#define DMTPT_HMAC_UNAME_HF_LEN 11
+
+//HMAC mac
+#define DMTPT_HMAC_MAC_HF ", mac="
+#define DMTPT_HMAC_MAC_HF_LEN 6
+
+//Carriage return line feed string
+#define DMTPT_CR_LF "\r\n"
+#define DMTPT_CR_LF_LEN 2
+
+// two double quotes " "
+#define DMTPT_TWO_DOUBLEQUOTES 2
+
+
+//------------------------------------------------------------------------
+// CLASS IMPLEMENTATION
+//------------------------------------------------------------------------
+
+SYNCML_DM_OTAConnection::SYNCML_DM_OTAConnection()
+{
+ bNumRetries = 0;
+ m_hConnection = 0;
+ psSendSyncMLDoc = NULL;
+ psRecvSyncMLDoc = NULL;
+}
+
+SYNCML_DM_OTAConnection::~SYNCML_DM_OTAConnection()
+{
+ if ( m_hConnection )
+ XPL_HTTP_Close(m_hConnection);
+}
+
+//========================================================================
+//
+// DESCRIPTION: Init routine
+//
+// ARGUMENTS PASSED:
+// INPUT : UINT32 dwMaxAcptSize - Maximum size of the message
+// UINT8 bWebSessIndex - Web session index to be used
+// UINT16 wWapGatePortno - WAP Gateway port number
+// SYNCML_DM_ADDR_TYPE_T AddressType - Address type
+// provided by the DMUA.
+//
+//
+//
+// OUTPUT:
+// None
+//
+// RETURN VALUE: None
+//
+//
+// IMPORTANT NOTES: The constructor gets called when the SYNCML_DM_OTATransport
+// creates a new SYNCML_DM_OTAConnection object.
+//===========================================================================
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_OTAConnection::Init(UINT32 dwMaxAcptSize,
+ XPL_ADDR_TYPE_T AddressType,
+ CPCHAR ConRef)
+{
+
+ // Initialize the member variables
+ dwMaxAcceptSize = dwMaxAcptSize;
+ AddrType = AddressType;
+
+ // Copy the new ConRef to the pConRef member variable.
+ if(ConRef != NULL && ConRef[0] != 0)
+ {
+ m_szConRef = ConRef;
+ if( m_szConRef.GetBuffer() ==NULL )
+ {
+ XPL_LOG_DM_SESS_Error(("SYNCML_DM_OTAConnection::Init : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+
+#ifdef DM_DUMP_SYNCML_PACKAGE
+ dump_path = XPL_DM_GetEnv(SYNCML_DM_DUMP_SESSION_PACKAGE_PATH);
+
+ if (dump_path == NULL)
+ {
+ dump_path="/tmp";
+ }
+ package_counter = 1;
+
+ HTTP_HEADER_SERVER = "Server";
+ HTTP_HEADER_DATE = "Date";
+ HTTP_HEADER_ACCEPT_RANGES = "Accept-Ranges";
+ HTTP_HEADER_CACHE_CONTROL = "Cache-Control";
+ HTTP_HEADER_CONNECTION = "Connection";
+ HTTP_HEADER_CONTENT_TYPE = "Content-Type";
+ HTTP_HEADER_X_SYNCML_HMAC = "x-syncml-hmac";
+
+ bodyFileName = "/package";
+ bodyFileExt = ".xml";
+
+ hdrFileName = "/header";
+ hdrFileExt = ".txt";
+#endif
+
+ return SYNCML_DM_SUCCESS;
+}
+
+//==============================================================================
+// FUNCTION: SYNCML_DM_OTAConnection::Send
+//
+// DESCRIPTION: This function sends the data to the Server
+//
+// ARGUMENTS PASSED:
+// INPUT : psSendSyncMLDocument - Pointer to the SyncML DM document
+// to be sent
+// psRecvSyncMLDocument - Pointer to the memory, where
+// the received document will be stored.
+// pbContType - Pointer to the content type of the
+// SyncML DM document that will be sent.
+// psCredHdr - Pointer to the HMAC Credential header
+//
+//
+//
+// OUTPUT:
+//
+//
+// RETURN VALUE: SYNCML_DM_RET_STATUS_T
+// SYNCML_DM_SUCCESS - If data is sent successfully to the Fetch Agent
+//
+// SYNCML_DM_FAIL - There were some problems either with the data
+// or while sending
+//
+// SYNCML_DM_SEC_CONN_NOT_AVAILABLE - Secure connection is required,
+// but it is not available.
+//
+//
+//
+// IMPORTANT NOTES: DMUA calls this function to send the data to the Server.
+//==============================================================================
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_OTAConnection::Send(
+ const SYNCML_DM_INDIRECT_BUFFER_T *psSendSyncMLDocument,
+ SYNCML_DM_INDIRECT_BUFFER_T *psRecvSyncMLDocument,
+ const UINT8 *pbContType,
+ const DMCredHeaders * psCredHdr)
+{
+
+ XPL_LOG_DM_SESS_Debug(("Enter SYNCML_DM_OTAConnection::Send \n"));
+
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ m_pCredHeaders = (DMCredHeaders*)psCredHdr;
+
+ // Check whether the input parameters are valid
+
+ if ((psSendSyncMLDocument EQ NULL) OR
+ (psSendSyncMLDocument->pData EQ NULL) OR
+ (psSendSyncMLDocument->dataSize EQ 0 ))
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+ if ((psRecvSyncMLDocument EQ NULL) OR
+ (psRecvSyncMLDocument->pData EQ NULL))
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+ if ((pbContType EQ NULL) OR (pbContType[0] EQ '\0'))
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+ // Check whether psCredHdr is valid
+ if ( psCredHdr->isCorrect() == FALSE )
+ return SYNCML_DM_FAIL;
+
+
+ psSendSyncMLDoc = (SYNCML_DM_INDIRECT_BUFFER_T*)psSendSyncMLDocument;
+
+ psRecvSyncMLDoc = psRecvSyncMLDocument;
+
+ //Call PrepareRequestHeaders method of this class with pbConType,
+ //psCredHdr parameters to prepare the HTTP headers.
+ ret_status = PrepareRequestHeaders(pbContType);
+
+ if (ret_status == SYNCML_DM_SUCCESS )
+ ret_status = SendInitialChunk();
+
+ return ret_status;
+
+}
+
+
+//==============================================================================
+// FUNCTION: SYNCML_DM_Connection::SetURI
+//
+// DESCRIPTION: This method sets the URL of the Server
+//
+// ARGUMENTS PASSED:
+// INPUT : pbUrl - URL of the Server
+//
+//
+// OUTPUT: None
+//
+// RETURN VALUE: SYNCML_DM_RET_STATUS_T
+// SYNCML_DM_SUCCESS - Whether the new URL has been set
+// successfully
+// SYNCML_DM_FAIL - Setting the new URL met with failure
+
+//
+//
+// IMPORTANT NOTES: This method is called by the DMUA and the
+// SYNCML_DM_OTATransport to set the new URL of the Server.
+//==============================================================================
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_Connection::SetURI(CPCHAR szURL)
+{
+ if (szURL EQ NULL)
+ return SYNCML_DM_FAIL;
+
+ m_szURL = szURL;
+ if ( m_szURL.GetBuffer() == NULL )
+ {
+ XPL_LOG_DM_SESS_Error(("SYNCML_DM_OTAConnection::SetURI : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+//==============================================================================
+// FUNCTION: SYNCML_DM_OTAConnection::PrepareRequestHeaders
+//
+// DESCRIPTION: This method prepares the Request Headers
+//
+// ARGUMENTS PASSED:
+// INPUT : pbContentTypetoSend -Pointer to the Content type of the
+// document to be sent
+// psCredHeaderstoSend - Pointer to the Credential headers to
+// be sent.
+//
+//
+// OUTPUT:
+// None
+//
+// RETURN VALUE: BOOLEAN - TRUE - Successfully prepared the HTTP headers
+// FALSE - HTTP headers preparation failed.
+//
+//
+// IMPORTANT NOTES: The SYNCML_DM_OTAConnection class this method.
+//==============================================================================
+SYNCML_DM_RET_STATUS_T SYNCML_DM_OTAConnection::PrepareRequestHeaders(const UINT8 *pbContentTypetoSend)
+{
+ char *pBuffer = NULL;
+ UINT32 size = 0;
+
+ XPL_LOG_DM_SESS_Debug(("Enter SYNCML_DM_OTAConnection::PrepareRequestHeaders \n"));
+
+ // Free the old HTTP headers
+ m_oHttpHdr.clear();
+
+ // Compute the HTTP header string length
+ size = ComputeHTTPHeaderLength(pbContentTypetoSend);
+
+ // Allocate memory for the new string
+ m_oHttpHdr.allocate(size);
+ pBuffer = (char*)m_oHttpHdr.getBuffer();
+ if ( pBuffer == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+
+ // Prepare General HTTP header fields
+ size = DmSprintf(pBuffer,DMTPT_CACHE_CONTROL_HF \
+ DMTPT_HTTP_CACHECONTROL \
+ DMTPT_CR_LF);
+
+
+ // Prepare Request HTTP header fields
+ size += DmSprintf(pBuffer + size,DMTPT_USER_AGENT_HF \
+ DMTPT_CLIENT_NAME \
+ DMTPT_CR_LF \
+ DMTPT_ACCEPT_HF \
+ DMTPT_HTTP_MIME_TYPES \
+ DMTPT_CR_LF \
+ DMTPT_ACCEPT_LANG_HF \
+ DMTPT_HTTP_LANGUAGE \
+ DMTPT_CR_LF );
+
+ // Prepare Entity HTTP header fields
+ size += DmSprintf(pBuffer + size,DMTPT_CONT_TYPE_HF "%s" DMTPT_CR_LF,pbContentTypetoSend);
+
+ if ( m_pCredHeaders->empty() == FALSE )
+ {
+ UINT8 bTempAlgo[DMTPT_MAX_ALGO_SIZE+1] = {0};
+ if ( m_pCredHeaders->m_oAlgorithm.getSize() == 0 )
+ DmStrcpy((char*)bTempAlgo,"MD5");
+ else
+ m_pCredHeaders->m_oAlgorithm.copyTo((char*)bTempAlgo);
+
+ size += DmSprintf(pBuffer + size,DMTPT_HMAC_ALGO_HF "%s" \
+ DMTPT_HMAC_UNAME_HF "\"%s\"" \
+ DMTPT_HMAC_MAC_HF "%s" DMTPT_CR_LF,
+ bTempAlgo,
+ (CPCHAR)m_pCredHeaders->m_oUserName.getBuffer(),
+ (CPCHAR)m_pCredHeaders->m_oMac.getBuffer());
+
+ }
+ m_oHttpHdr.setSize(size);
+ return SYNCML_DM_SUCCESS;
+}
+
+//==============================================================================
+// FUNCTION: SYNCML_DM_OTAConnection::ComputeHTTPHeaderLength
+//
+// DESCRIPTION: This method computes the length of the HTTP header fields
+//
+// ARGUMENTS PASSED:
+// INPUT : pbContentTypetoSend -Pointer to the Content type of the
+// document to be sent
+// psCredHeaderstoSend - Pointer to the Credential headers to
+// be sent.
+//
+//
+// OUTPUT:
+// None
+//
+// RETURN VALUE: Length of the HTTP Header fields
+//
+//
+// IMPORTANT NOTES: This class calls this method. We support ATMOST 64K chunk of
+// data to be sent to the Server. That's why the return type is
+// UINT16.
+//==============================================================================
+
+UINT16 SYNCML_DM_OTAConnection::ComputeHTTPHeaderLength(const UINT8 *pbContentTypetoSend)
+{
+
+ //Find the length of the following individual header fields to compute
+ // the total length of the HTTP header: Cache-Control, User-Agent,
+ //Accept, Accept-Language, Accept-Charset, Content-Type, Content-Length,
+ //x-syncml-hmac.
+
+ UINT16 wTotalLength =0;
+ UINT8 bCrLfLen =0;
+
+ bCrLfLen = DmStrlen(DMTPT_CR_LF) ;
+
+ wTotalLength = DMTPT_USER_AGENT_HF_LEN + DmStrlen(DMTPT_CLIENT_NAME) +
+ bCrLfLen +
+ DMTPT_ACCEPT_HF_LEN + DmStrlen(DMTPT_HTTP_MIME_TYPES) +
+ bCrLfLen +
+ DMTPT_ACCEPT_LANG_HF_LEN + DmStrlen(DMTPT_HTTP_LANGUAGE) +
+ bCrLfLen +
+ DMTPT_ACCEPT_CHARSET_LEN + bCrLfLen +
+ DMTPT_CACHE_CONTROL_HF_LEN + DmStrlen(DMTPT_HTTP_CACHECONTROL)+
+ bCrLfLen ;
+
+ wTotalLength += DMTPT_CONT_TYPE_HF_LEN + DmStrlen((CPCHAR)pbContentTypetoSend) + bCrLfLen ;
+
+ if ( m_pCredHeaders->empty() == FALSE )
+ {
+
+ wTotalLength += DMTPT_HMAC_ALGO_HF_LEN + DMTPT_HMAC_UNAME_HF_LEN +
+ m_pCredHeaders->m_oUserName.getSize() +
+ DMTPT_HMAC_MAC_HF_LEN +
+ m_pCredHeaders->m_oMac.getSize() +
+ DMTPT_TWO_DOUBLEQUOTES +
+ bCrLfLen;
+
+ if ( m_pCredHeaders->m_oAlgorithm.getSize() == 0)
+ wTotalLength += DMTPT_MD5_STRING_SIZE;
+ else
+ wTotalLength += m_pCredHeaders->m_oAlgorithm.getSize();
+ }
+
+ return wTotalLength;
+
+}
+
+
+//==============================================================================
+// FUNCTION: SYNCML_DM_OTAConnection::ProcessCredHeaders
+//
+// DESCRIPTION: This method extracts the Credential headers from the
+// Response headers
+//
+// ARGUMENTS PASSED:
+// INPUT : Pointer to the Response header
+//
+//
+// OUTPUT: None
+//
+// RETURN VALUE: BOOLEAN
+// TRUE - If handled successfully
+// FALSE - If there is some failure
+
+//
+//
+// IMPORTANT NOTES: The HandleOTARedirect method calls this method.
+//==============================================================================
+SYNCML_DM_RET_STATUS_T SYNCML_DM_OTAConnection::ProcessCredHeaders(CPCHAR pbOrigHmacStr)
+{
+
+ UINT8 *pbHmacString = NULL;
+ UINT8 *pbInitialHmacString = NULL;
+ UINT8 *pbParam = NULL;
+ UINT8 *pbValue = NULL;
+ char *pbAlgo = NULL;
+ char *pbUname = NULL;
+ char *pbMAC = NULL;
+
+ XPL_LOG_DM_SESS_Debug(("Enter SYNCML_DM_OTAConnection::ProcessCredHeaders\n"));
+ if(pbOrigHmacStr EQ NULL)
+ return TRUE;
+
+ //Trim the blank space and tabs
+ pbHmacString = DMTPTTrimString((UINT8*)pbOrigHmacStr);
+ if (pbHmacString EQ NULL)
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+ pbInitialHmacString = pbHmacString;
+
+ pbHmacString = (UINT8*)DmStrstr((CPCHAR)pbHmacString, "algorithm");
+
+ if (pbHmacString EQ NULL)
+ pbHmacString = (UINT8*)DmStrstr((CPCHAR)pbInitialHmacString,"username");
+
+ //Extract the algorithm, Username and mac from
+ //the x-syncml-hmac header
+ while (pbHmacString NE NULL)
+ {
+ pbHmacString = DM_TPT_splitParamValue(pbHmacString,&pbParam,&pbValue);
+
+ if ((pbParam NE NULL) AND (pbParam [0] NE '\0'))
+ {
+ if (!DmStrcmp ((CPCHAR)pbParam, "algorithm"))
+ {
+ pbAlgo = (char*)pbValue;
+ }
+ else
+ if (!DmStrcmp ((CPCHAR)pbParam, "username"))
+ {
+ pbUname = (char*)pbValue;
+ }
+ else
+ if (!DmStrcmp ((CPCHAR)pbParam, "mac"))
+ {
+ pbMAC = (char*)pbValue;
+ }
+ }
+ }
+
+ // Allocate memory to hold username, mac, algorithm
+ if (pbUname == NULL || pbMAC == NULL)
+ {
+ DmFreeMem(pbInitialHmacString);
+ return SYNCML_DM_FAIL;
+ }
+
+ if (pbAlgo NE NULL)
+ m_pCredHeaders->m_oAlgorithm.assign(pbAlgo);
+ else
+ m_pCredHeaders->m_oAlgorithm.assign("MD5");
+
+ if ( m_pCredHeaders->m_oAlgorithm.getBuffer() == NULL )
+ {
+ DmFreeMem(pbInitialHmacString);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ m_pCredHeaders->m_oUserName.assign(pbUname);
+
+ if ( m_pCredHeaders->m_oUserName.getBuffer() == NULL )
+ {
+ DmFreeMem(pbInitialHmacString);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ m_pCredHeaders->m_oMac.assign(pbMAC);
+
+ if ( m_pCredHeaders->m_oMac.getBuffer() == NULL )
+ {
+ DmFreeMem(pbInitialHmacString);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ DmFreeMem(pbInitialHmacString);
+ XPL_LOG_DM_SESS_Debug(("Leave SYNCML_DM_OTAConnection::ProcessCredHeaders\n"));
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_OTAConnection::ConvertXPLCode(XPL_HTTP_RET_STATUS_T http_result)
+{
+ SYNCML_DM_RET_STATUS_T return_result;
+ switch ( http_result )
+ {
+ case XPL_HTTP_RET_NW_NOT_AVAILABLE:
+ return_result = SYNCML_DM_SESSION_NW_NOT_AVAILABLE;
+ break;
+
+ case XPL_HTTP_RET_NO_CONNECT:
+ return_result = SYNCML_DM_SESSION_NO_CONNECT;
+ break;
+
+ default :
+ return_result = SYNCML_DM_FAIL;
+ break;
+ }
+ return return_result;
+}
+
+
+/*******************************************************************************
+*
+* Function : FA_issue_urlRequest()
+* Parameters : user id, request id, URL, method type, headers,
+* data buffer(post), content preferences,
+* progress indicator.
+* Return Value : Boolean (success or failure)
+* Description : This api checks for the validity of the parameters received.
+* Additional check for data buffer is made for Put and Post
+* requests. Finally a message FA_GET_URL is constructed and
+* posted to the Fetch Module.
+*
+********************************************************************************/
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_OTAConnection::IssueURLRequest(XPL_HTTP_CODE_T *ret_code)
+{
+ char * value = NULL;
+ UINT32 receivedLength = 0;
+ SYNCML_DM_RET_STATUS_T return_result = SYNCML_DM_SUCCESS;
+ XPL_HTTP_RET_STATUS_T http_result = XPL_HTTP_OK_200;
+
+ XPL_LOG_DM_SESS_Debug(("Enter SYNCML_DM_OTAConnection::IssueURLRequest \n"));
+
+#ifdef DM_DUMP_SYNCML_PACKAGE
+
+ XPL_FS_HANDLE_T hBodyFile = XPL_FS_HANDLE_INVALID;
+ XPL_FS_HANDLE_T hHeaderFile = XPL_FS_HANDLE_INVALID;
+ XPL_FS_RET_STATUS_T nStatus = XPL_FS_RET_FAIL;
+ char szName [512];
+
+ DmSprintf( szName, "%s%s%d_request%s", dump_path.c_str(), hdrFileName.c_str(),
+ package_counter, hdrFileExt.c_str() );
+
+ hHeaderFile = XPL_FS_Open( szName,
+ XPL_FS_FILE_WRITE,
+ &nStatus );
+#endif
+
+ // Use open method for the first time
+ if (m_hConnection == 0)
+ m_hConnection = XPL_HTTP_Open((CPCHAR)m_szURL, (CPCHAR)m_szConRef, AddrType,&http_result);
+ else
+ http_result = XPL_HTTP_SetUrl(m_hConnection,(CPCHAR)m_szURL, (CPCHAR)m_szConRef, AddrType);
+
+ if ( http_result != XPL_HTTP_RET_SUCCESS )
+ return SYNCML_DM_FAIL;
+
+
+ http_result = XPL_HTTP_SetRequestMethod(m_hConnection,XPL_HTTP_METHOD_POST);
+ if ( http_result != XPL_HTTP_RET_SUCCESS)
+ {
+ return_result = ConvertXPLCode(http_result);
+ goto GetResponseCode;
+ }
+
+ http_result = XPL_HTTP_SetRequestProperty(m_hConnection,(CPCHAR)m_oHttpHdr.getBuffer());
+ if ( http_result != XPL_HTTP_RET_SUCCESS)
+ {
+ return_result = ConvertXPLCode(http_result);
+ goto GetResponseCode;
+ }
+
+
+#ifdef DM_DUMP_SYNCML_PACKAGE
+ // capture header info
+ if ( XPL_FS_HANDLE_INVALID != hHeaderFile )
+ {
+ XPL_FS_Write( hHeaderFile,
+ m_oHttpHdr.getBuffer(),
+ m_oHttpHdr.getSize(),
+ &nStatus );
+
+ XPL_FS_Close( hHeaderFile );
+ hHeaderFile = XPL_FS_HANDLE_INVALID;
+ }
+
+ DmSprintf( szName, "%s%s%d_request%s", dump_path.c_str(), bodyFileName.c_str(),
+ package_counter++, bodyFileExt.c_str() );
+
+ hBodyFile = XPL_FS_Open( szName,
+ XPL_FS_FILE_WRITE,
+ &nStatus );
+
+ if ( XPL_FS_HANDLE_INVALID != hBodyFile )
+ {
+ XPL_FS_Write( hBodyFile,
+ psSendSyncMLDoc->pData,
+ psSendSyncMLDoc->dataSize,
+ &nStatus );
+
+ XPL_FS_Close( hBodyFile );
+ hBodyFile = XPL_FS_HANDLE_INVALID;
+ }
+#endif
+
+ // Upload buffer
+ http_result = XPL_HTTP_Send(m_hConnection,(CPCHAR)psSendSyncMLDoc->pData,psSendSyncMLDoc->dataSize);
+ if ( http_result != XPL_HTTP_RET_SUCCESS)
+ {
+ return_result = ConvertXPLCode(http_result);
+ goto GetResponseCode;
+ }
+
+ receivedLength = XPL_HTTP_GetResponseLength(m_hConnection);
+
+ if (receivedLength EQ 0)
+ {
+ receivedLength = dwMaxAcceptSize;
+ }
+
+ if (receivedLength GT dwMaxAcceptSize)
+ {
+ return_result = SYNCML_DM_FAIL;
+ goto GetResponseCode;
+ }
+
+ psRecvSyncMLDoc->dataSize = receivedLength;
+
+ http_result = XPL_HTTP_GetResponse(m_hConnection,(char *)psRecvSyncMLDoc->pData,(INT32)receivedLength);
+ if ( http_result != XPL_HTTP_RET_SUCCESS)
+ {
+ return_result = ConvertXPLCode(http_result);
+ goto GetResponseCode;
+ }
+
+#ifdef DM_DUMP_SYNCML_PACKAGE
+ // open a file to capture response header info
+ value=(char*)DmAllocMem(512);
+ DmSprintf( szName, "%s%s%d_response%s", dump_path.c_str(), hdrFileName.c_str(), package_counter, hdrFileExt.c_str() );
+
+ hHeaderFile = XPL_FS_Open( szName,
+ XPL_FS_FILE_WRITE,
+ &nStatus );
+
+ // capture header info
+ if ( XPL_FS_HANDLE_INVALID != hHeaderFile )
+ {
+ const char szCRLF[] = "\r\n";
+ const XPL_FS_COUNT_T nCRLFlen = DmStrlen(szCRLF);
+
+ if((XPL_HTTP_GetHeaderField(m_hConnection,HTTP_HEADER_SERVER, &value)) EQ XPL_HTTP_RET_SUCCESS)
+ {
+ XPL_FS_Write( hHeaderFile,
+ value,
+ DmStrlen(value),
+ &nStatus );
+
+ XPL_FS_Write( hHeaderFile,
+ (void*)szCRLF,
+ nCRLFlen,
+ &nStatus );
+ }
+
+ if((XPL_HTTP_GetHeaderField(m_hConnection,HTTP_HEADER_DATE, &value)) EQ XPL_HTTP_RET_SUCCESS)
+ {
+ XPL_FS_Write( hHeaderFile,
+ value,
+ DmStrlen(value),
+ &nStatus );
+
+ XPL_FS_Write( hHeaderFile,
+ (void*)szCRLF,
+ nCRLFlen,
+ &nStatus );
+ }
+
+ if((XPL_HTTP_GetHeaderField(m_hConnection,HTTP_HEADER_ACCEPT_RANGES, &value)) EQ XPL_HTTP_RET_SUCCESS)
+ {
+ XPL_FS_Write( hHeaderFile,
+ value,
+ DmStrlen(value),
+ &nStatus );
+
+ XPL_FS_Write( hHeaderFile,
+ (void*)szCRLF,
+ nCRLFlen,
+ &nStatus );
+ }
+
+ if((XPL_HTTP_GetHeaderField(m_hConnection,HTTP_HEADER_CACHE_CONTROL, &value)) EQ XPL_HTTP_RET_SUCCESS)
+ {
+ XPL_FS_Write( hHeaderFile,
+ value,
+ DmStrlen(value),
+ &nStatus );
+
+ XPL_FS_Write( hHeaderFile,
+ (void*)szCRLF,
+ nCRLFlen,
+ &nStatus );
+ }
+
+ if((XPL_HTTP_GetHeaderField(m_hConnection,HTTP_HEADER_CONNECTION, &value)) EQ XPL_HTTP_RET_SUCCESS)
+ {
+ XPL_FS_Write( hHeaderFile,
+ value,
+ DmStrlen(value),
+ &nStatus );
+
+ XPL_FS_Write( hHeaderFile,
+ (void*)szCRLF,
+ nCRLFlen,
+ &nStatus );
+ }
+
+ if((XPL_HTTP_GetHeaderField(m_hConnection,HTTP_HEADER_CONTENT_TYPE, &value)) EQ XPL_HTTP_RET_SUCCESS)
+ {
+ XPL_FS_Write( hHeaderFile,
+ value,
+ DmStrlen(value),
+ &nStatus );
+
+ XPL_FS_Write( hHeaderFile,
+ (void*)szCRLF,
+ nCRLFlen,
+ &nStatus );
+ }
+
+ if((XPL_HTTP_GetHeaderField(m_hConnection,HTTP_HEADER_X_SYNCML_HMAC, &value)) EQ XPL_HTTP_RET_SUCCESS)
+ {
+ XPL_FS_Write( hHeaderFile,
+ value,
+ DmStrlen(value),
+ &nStatus );
+
+ XPL_FS_Write( hHeaderFile,
+ (void*)szCRLF,
+ nCRLFlen,
+ &nStatus );
+ }
+
+ XPL_FS_Close( hHeaderFile );
+ hHeaderFile = XPL_FS_HANDLE_INVALID;
+ }
+
+ DmSprintf( szName, "%s%s%d_response%s", dump_path.c_str(), bodyFileName.c_str(), package_counter++, bodyFileExt.c_str() );
+
+ hBodyFile = XPL_FS_Open( szName,
+ XPL_FS_FILE_WRITE,
+ &nStatus );
+
+ if ( XPL_FS_HANDLE_INVALID != hBodyFile )
+ {
+ XPL_FS_Write( hBodyFile,
+ psRecvSyncMLDoc->pData,
+ receivedLength,
+ &nStatus );
+
+ XPL_FS_Close( hBodyFile );
+ hBodyFile = XPL_FS_HANDLE_INVALID;
+ }
+
+ DmFreeMem(value);
+ value = NULL;
+#endif
+
+ // Clean the Previously received Credential headers
+ m_pCredHeaders->clear();
+ value=(char*)DmAllocMem(512);
+ http_result = XPL_HTTP_GetHeaderField(m_hConnection,"x-syncml-hmac", &value);
+ if ( http_result == XPL_HTTP_RET_SUCCESS)
+ {
+ return_result = ProcessCredHeaders(value);
+ if ( return_result != SYNCML_DM_SUCCESS )
+ {
+ DmFreeMem(value);
+ XPL_HTTP_CloseReq(m_hConnection);
+ return SYNCML_DM_FAIL;
+ }
+ }
+ else
+ return_result = ConvertXPLCode(http_result);
+ DmFreeMem(value);
+
+ GetResponseCode:
+
+ *ret_code = XPL_HTTP_GetResponseCode(m_hConnection);
+ XPL_HTTP_CloseReq(m_hConnection);
+
+ XPL_LOG_DM_SESS_Debug(("Exit from IssueURLRequest\n", return_result));
+
+ return SYNCML_DM_SUCCESS;
+}
+
+//==============================================================================
+// FUNCTION: SYNCML_DM_OTAConnection::SendInitialChunk
+//
+// DESCRIPTION: This method sends the initial chunk of data to the server.
+//
+// ARGUMENTS PASSED:
+// INPUT : None
+//
+//
+// OUTPUT:
+// None
+//
+// RETURN VALUE: BOOLEAN -
+// TRUE - Whether the data is successfully posted to the
+// Fetch agent
+// FALSE - posting the data to the Fetch Agent met with failure.
+//
+//
+// IMPORTANT NOTES: Send method calls this method.
+//==============================================================================
+SYNCML_DM_RET_STATUS_T SYNCML_DM_OTAConnection::SendInitialChunk()
+{
+
+
+ SYNCML_DM_RET_STATUS_T return_result;
+ int wNumRetries = 0;
+ XPL_HTTP_CODE_T ret_code = XPL_HTTP_OK_200;
+
+ XPL_LOG_DM_SESS_Debug(("Enter SYNCML_DM_OTAConnection::SendInitialChunk \n"));
+
+ if (m_szURL == NULL)
+ return SYNCML_DM_FAIL;
+
+ while (wNumRetries LT DMTPT_MAX_RETRIES)
+ {
+ return_result = IssueURLRequest(&ret_code);
+ if(return_result != SYNCML_DM_SUCCESS)
+ return return_result;
+
+ switch(ret_code)
+ {
+ case XPL_HTTP_REQUEST_TIMEOUT_408:
+ case XPL_HTTP_INTERNAL_SERVER_ERROR_500:
+ case XPL_HTTP_BAD_GATEWAY_502:
+ case XPL_HTTP_SERVICE_UNAVAILABLE_503:
+ case XPL_HTTP_GATEWAY_TIMEOUT_504:
+ wNumRetries++;
+ break;
+
+ case XPL_HTTP_OK_200:
+ return SYNCML_DM_SUCCESS;
+
+ default:
+ return SYNCML_DM_FAIL;
+ }
+ }
+
+ XPL_LOG_DM_SESS_Debug(("OTAConnection send failed due failure in SendInitialChunk\n"));
+ return SYNCML_DM_FAIL;
+}
diff --git a/engine/dmlib/dmengine/dm_transport/src/dm_tpt_utils.c b/engine/dmlib/dmengine/dm_transport/src/dm_tpt_utils.c
new file mode 100644
index 0000000..6b11f6d
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_transport/src/dm_tpt_utils.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//-----------------------------------------------------------------------
+//
+// Module Name: dm_tpt_utils.c
+//
+// General Description: This file contains the Implementation of
+// utility functions: DMTPT_PostMessage,
+// DMTPT_Post_DataMessages &
+// DM_TPT_splitParamValue
+//
+//------------------------------------------------------------------------
+
+/* This file contains Transport utility function prototypes. */
+#include "dm_tpt_utils.h"
+
+//==============================================================================
+// FUNCTION: DMTPTTrimString
+//
+// DESCRIPTION: Trim the Input string: Remove the blank spaces and tabs.
+//
+// ARGUMENTS PASSED:
+// INPUT : UINT8* pbOrigHmacStr String to be trimmed
+//
+// RETURN VALUE: Pointer to the trimmed string
+//
+//
+// IMPORTANT NOTES: This utility function is called to trim the input string
+//==============================================================================
+UINT8* DMTPTTrimString(UINT8 *pbOrigHmacStr)
+{
+
+ UINT8 bIndex1 =0;
+ UINT8 bIndex2 =0;
+ UINT8 bOrigHmacStrlen =0;
+ UINT8 *pbHmacStr = NULL;
+
+ bOrigHmacStrlen = DmStrlen((CPCHAR)pbOrigHmacStr);
+
+ pbHmacStr = (UINT8*)DmAllocMem((sizeof(UINT8)*(bOrigHmacStrlen+1)));
+
+ if (pbHmacStr == NULL)
+ {
+ return NULL;
+ }
+
+ memset(pbHmacStr,0,bOrigHmacStrlen+1);
+
+ for (bIndex1 = 0; bIndex1 < bOrigHmacStrlen; bIndex1++)
+ {
+
+ if ((pbOrigHmacStr[bIndex1] != ' ') && (pbOrigHmacStr[bIndex1] != '\t' ))
+ {
+ pbHmacStr[bIndex2] = pbOrigHmacStr[bIndex1] ;
+ bIndex2++;
+ }
+
+ }
+
+ return pbHmacStr;
+}
+
+//==============================================================================
+// FUNCTION: DM_TPT_splitParamValue
+//
+// DESCRIPTION: Parse one parameter from the specified line.
+// it is assumed that the parameter has the following format:
+// parm={ value | "value" }[,] [;]
+// The function changes the contents of pbLine!!
+//
+// ARGUMENTS PASSED:
+// INPUT : UINT8* pbLine, String to be split up
+// OUTPUT:
+// UINT8** ppbParam ptr to extracted parameter
+// UINT8** ppbValue ptr to extracted parameter value
+//
+//
+//
+// RETURN VALUE: Return the rest of the string, or NULL if here are no more
+//
+//
+// IMPORTANT NOTES: This utility function is called to parse the string
+// of the form parameter[;/,]value
+//==============================================================================
+UINT8* DM_TPT_splitParamValue (UINT8* pbLine,
+ UINT8** ppbParam,
+ UINT8** ppbValue)
+{
+ UINT8* pbToken = pbLine;
+ UINT8* pbRest = NULL;
+
+ if (pbToken == NULL)
+ {
+ return NULL;
+ }
+
+ /* skip leading blanks */
+ SKIP_WHITESPACE (pbToken);
+ pbRest = pbToken;
+ *ppbParam = pbRest;
+
+ if (pbToken [0] == '\0')
+ {
+ return NULL;
+ }
+
+ /* Find the delimiter */
+ while ((*pbRest != '\0') && (*pbRest != '=') &&
+ (*pbRest != ' ') && (*pbRest != ','))
+ pbRest ++;
+
+ switch (*pbRest)
+ {
+ case '\0': //
+ *ppbValue = pbRest;
+ break;
+
+ case ',':
+ case ' ': // whitespace: there is no value assigned to this parameter
+ *pbRest = '\0';
+ *ppbValue = pbRest;
+ pbRest ++;
+ break;
+
+ case '=':
+ /* The value part may or may not be enclosed in quotes */
+ *pbRest = '\0';
+ pbRest ++;
+ SKIP_WHITESPACE (pbRest);
+ if (pbRest[0] == '\"')
+ {
+ *ppbValue = ++pbRest;
+ while ((*pbRest != '\0') && (*pbRest != '\"'))
+ pbRest ++;
+ }
+ else
+ {
+ *ppbValue = pbRest;
+ while ((*pbRest != '\0') && (*pbRest != ' ') && (*pbRest != ',') && (*pbRest != ';'))
+ pbRest ++;
+ }
+
+ if (*pbRest)
+ {
+ *pbRest = '\0';
+ pbRest ++;
+ }
+
+ break;
+ }
+ return pbRest;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/SYNCML_DM_TreeMount.H b/engine/dmlib/dmengine/dm_ua/hdr/SYNCML_DM_TreeMount.H
new file mode 100644
index 0000000..af3230b
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/SYNCML_DM_TreeMount.H
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_TREEMOUNT_H
+#define SYNCML_DM_TREEMOUNT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_TreeMount.H
+
+ General Description: This file contains declaration of the SYNCML_DM_TreeMount_ListItem and
+ SYNCML_DM_TreeMount classes.
+
+==================================================================================================*/
+
+#include "dm_tree_node_class.H"
+#include "dmvector.h"
+#include "dmdefs.h"
+
+class CEnv;
+class DMTree;
+
+/* SYNCML_DM_TreeMount class provides functions to add, delete and retrieve tree mount
+ * information. */
+class SYNCML_DM_TreeMount
+{
+public:
+ SYNCML_DM_TreeMount();
+
+ /* DMArchiver calls this method to retrieve tree mount information to deserialize the tree. */
+ void GetTreeMountEntry (CPCHAR &p_Uri, CPCHAR& p_TreePath, UINT16 index) const ;
+
+ BOOLEAN IsMountPointEnabled(CPCHAR pUri) const ;
+
+ SYNCML_DM_RET_STATUS_T MountTree( CEnv* env, DMTree* tree );
+
+ void UnMountTree(void) ;
+
+private:
+ /* UA API calls this function to add the tree information into the tree mount list. */
+ SYNCML_DM_RET_STATUS_T TreeAddToMountList (CPCHAR pUri, CPCHAR pTreePath) ;
+
+private:
+ DMStringVector m_astrURIs;
+ DMStringVector m_astrPaths;
+ DMTree *m_pTree;
+};
+
+/*================================================================================================*/
+#endif /* SYNCML_DM_TreeMount_H */
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmACLItem.h b/engine/dmlib/dmengine/dm_ua/hdr/dmACLItem.h
new file mode 100644
index 0000000..5c7a0bc
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmACLItem.h
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMACLITEM_H
+#define DMACLITEM_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmACLItem.h
+
+General Description: This file contains declaration of the dmACLItem class
+
+==================================================================================================*/
+
+#include "dmstring.h"
+#include "dmvector.h"
+#include "syncml_dm_data_types.h"
+#include "dmtAcl.hpp"
+#include "dmConfigItem.h"
+
+/**
+ * DMAclItem represents an acl config record.
+ */
+class DMAclItem : public DmtAcl, public DMConfigItem {
+public:
+
+ /**
+ * Default constructor
+ */
+ DMAclItem() {}
+
+ /**
+ * Constructor, which sets path of configuration item and parses encoded acl record
+ * \param szPath [in] - configuration path (URI of a node)
+ * \param szAcl [in] - encoded acl record
+ */
+ DMAclItem(CPCHAR szPath, CPCHAR szAcl );
+
+ /**
+ * Parses encoded acl record and assign values of object members
+ * \param szPath [in] - configuration path (URI of a node)
+ * \param szConfig[in] - encoded acl record
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Set(CPCHAR szPath,
+ CPCHAR szConfig,
+ const DMMap<INT32, DMString>& aDict);
+
+
+/**
+ * Saves acl record back to a file
+ * \param dmf [in] - file handler object
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Serialize( DMFileHandler& dmf,
+ const DMMap<DMString, INT32>& aDict );
+
+ /**
+ * Adds principals stored in the acl item into dictionary before serialization of config file
+ * \param aDict [out] - dictionary of principals
+ */
+ virtual void UpdateDictionary( DMMap<DMString, INT32>& aDict);
+
+
+private:
+
+/**
+ * Parses "key=value" segment of acl property
+ * (where key is a permission and value is a "+" separated list of principals indexes )
+ * \param szSegment [in] - segment of acl config record
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ParseSegment(CPCHAR szSegment,
+ const DMMap<INT32, DMString>& aDict);
+
+/**
+ * Parses list of principals indexes (value)
+ * \param szSegment [in] - list of principals
+ * \param nPermission [in] - permission
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ParsePrincipal(CPCHAR szSegment,
+ SYNCML_DM_ACL_PERMISSIONS_T nPermission,
+ const DMMap<INT32, DMString>& aDict );
+
+/**
+ * Parses permission
+ * \param szKeyWord [in] - key letter that specifies a permission ( A/G/R/D )
+ * \param pPermission [out] - permission
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ static SYNCML_DM_RET_STATUS_T ParsePermission(CPCHAR szkeyWord,
+ SYNCML_DM_ACL_PERMISSIONS_T * pPermission );
+
+
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmACLManager.h b/engine/dmlib/dmengine/dm_ua/hdr/dmACLManager.h
new file mode 100644
index 0000000..e0dc1af
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmACLManager.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMACLMANAGER_H
+#define DMACLMANAGER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmACLManager.h
+
+General Description: This file contains declaration of the dmACLManager class, which provides
+ interfaces to read from the ACL information file and enforce ACL.
+
+==================================================================================================*/
+
+#include "dmACLItem.h"
+#include "dmConfigManager.h"
+
+/**
+ * DMAclManager handles ACL records management.
+ */
+class DMAclManager : public DMConfigManager {
+public:
+
+ /**
+ * Default constructor
+ */
+ DMAclManager() {}
+
+ /**
+ * Initializes a manager
+ * \param env [in] - pointer on env object
+ * \param pTree [in] - pointer on DM tree object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Init( CEnv* env, DMTree* tree );
+
+ /**
+ * Checks if operation is allowed for particular server
+ * \param szPath [in] - DM node path
+ * \param szServerID [in] - server name
+ * \param nPermissions [ in] - permission to check
+ * \param bIsCheckLocal [ in] - specifies if local status of node should be checked
+ * \return TRUE if permitted
+ */
+ BOOLEAN IsPermitted(CPCHAR szPath,
+ CPCHAR szServerID,
+ SYNCML_DM_ACL_PERMISSIONS_T nPermissions,
+ BOOLEAN bIsCheckLocal);
+
+ /**
+ * Retrieves ACL property as a string for particular node
+ * \param szPath [in] - DM node path
+ * \param strACL [out] - ACL property
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T GetACL(CPCHAR szPath,
+ DMString& strACL);
+
+ /**
+ * Sets ACL property for particular node
+ * \param szPath [in] - DM node path
+ * \param strACL [out] - ACL property
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T SetACL(CPCHAR szPath,
+ CPCHAR szACL );
+
+private:
+ /**
+ * Returns name of configuration file ("acl.dat")
+ * \param strFileName [out] - file name
+ */
+ virtual void GetFileName(DMString & strFileName);
+
+ /**
+ * Allocates new acl item
+ * \return pointer on new config item
+ */
+ virtual DMConfigItem * AllocateConfigItem();
+
+ /**
+ * Checks if operation is allowed for particular server
+ * \param szPath [in] - DM node path
+ * \param szServerID [in] - server name
+ * \param nPermissions [ in] - permission to check
+ * \return TRUE if permitted
+ */
+ BOOLEAN IsPermitted(CPCHAR szPath,
+ CPCHAR szServerID,
+ SYNCML_DM_ACL_PERMISSIONS_T nPermissions) const;
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmConfigItem.h b/engine/dmlib/dmengine/dm_ua/hdr/dmConfigItem.h
new file mode 100644
index 0000000..7fe6ff1
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmConfigItem.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMCONFIGITEM_H
+#define DMCONFIGITEM_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*=================================================================================================
+
+Header Name: dmConfigItem.h
+
+General Description: This file contains declaration of the DMConfigItem class
+
+==================================================================================================*/
+
+#include "dmvector.h"
+#include "dmstring.h"
+#include "jem_defs.hpp"
+#include "dmtPrincipal.hpp"
+#include "SyncML_DM_FileHandle.H"
+
+/**
+ * DMConfigItem is the base class for configuration records such as ACL or Event subscriptions.
+ */
+class DMConfigItem : public JemBaseObject {
+public:
+
+ /**
+ * Default constructor
+ */
+ DMConfigItem() {};
+
+ /**
+ * Constructor, which sets path of configuration item
+ * \param szPath [in] - configuration path (URI of a node)
+ */
+ DMConfigItem(CPCHAR szPath);
+
+ /**
+ * Saves configuration record back to a file
+ * \param dmf [in] - file handler object
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Serialize(DMFileHandler& dmf,
+ const DMMap<DMString, INT32>& aDict ) = 0 ;
+
+ /**
+ * Parses encoded configuration data and assign values of object members
+ * \param szPath [in] - configuration path (URI of a node)
+ * \param szConfig[in] - encoded configuration record
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Set(CPCHAR szPath,
+ CPCHAR szConfig,
+ const DMMap<INT32, DMString>& aDict) = 0;
+
+
+ /**
+ * Adds principals stored in the configuration item into dictionary before serialization of config file
+ * \param aDict [out] - dictionary of principals
+ */
+ virtual void UpdateDictionary(DMMap<DMString, INT32>& aDict ) = 0;
+
+
+ /**
+ * Attaches property into encoded configuration record before serialization of config item
+ * \param strConfig [out] - encoded configuration data
+ * \param cDelim[in] - delimeter to use for particular property
+ * \param szProperty [in] - property to attach
+ */
+ static void AttachProperty(DMString & strConfig,
+ char cDelim,
+ CPCHAR szProperty );
+
+ /**
+ * Creates "key=value" config property (example "G=1+2")
+ * \param aPrincipals [in] - vector of principals to add into value
+ * \param szKey[in] - key ( example "G=" )
+ * \param aDict [in] - dictionary of principals
+ * \param szProperty [out] - created config property
+ */
+ static void CreateProperty(const DMVector<DmtPrincipal> aPrincipals,
+ CPCHAR szKey,
+ const DMMap<DMString, INT32>& aDict,
+ DMString & strProperty);
+
+/**
+ * Returns configuration path
+ */
+ const DMString & GetPath() const { return m_strPath; }
+
+
+protected:
+ /* Configuration path*/
+ DMString m_strPath;
+
+/**
+ * Saves configuration path back to a file
+ * \param dmf [in] - file handler object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Serialize( DMFileHandler& dmf );
+
+/**
+ * Sets value of configuration path
+ * \param szPath [in] - configuration path (URI of a node)
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Set(CPCHAR szPath);
+
+};
+
+typedef JemSmartPtr<DMConfigItem> PDMConfigItem;
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmConfigManager.h b/engine/dmlib/dmengine/dm_ua/hdr/dmConfigManager.h
new file mode 100644
index 0000000..4efe059
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmConfigManager.h
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMCONFIGMANAGER_H
+#define DMCONFIGMANAGER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmConfigManager.h
+
+General Description: Declaration of DMConfigManager, the base class for ACL and Event managers.
+
+==================================================================================================*/
+
+#include "dmACLItem.h"
+
+/**
+ * DMConfigManager is the base class for ACL and Event subscription records management.
+ */
+class DMConfigManager {
+public:
+
+ /**
+ * Default constructor
+ */
+ DMConfigManager();
+
+ /**
+ * Default destructor
+ */
+ virtual ~DMConfigManager();
+
+ /**
+ * Initializes a manager
+ * \param env [in] - pointer on env object
+ * \param pTree[in] - pointer on DM tree object
+ * \param fileType [in] - specifies type of config file object will handle
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Init(CEnv* env,
+ DMTree* pTree ,
+ SYNCML_DM_FILE_TYPE_T fileType);
+
+ /**
+ * Deinitializes manager
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T DeInit();
+
+ /**
+ * Loads configuartion records into memory
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Deserialize();
+
+ /**
+ * Saves configurations records
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Serialize();
+
+ /**
+ * Rollbacks all changes in the config records
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Revert();
+
+ /**
+ * Deletes configuration record
+ * \param env [in] - configuration path to be deleted
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Delete(CPCHAR szPath);
+
+
+protected:
+ /* pointer on env object */
+ CEnv* m_pEnv;
+ /* pointer on DMTree object */
+ DMTree* m_pTree;
+ /* file name */
+ DMString m_strFileName;
+ /* flag to specify if config records are modified */
+ BOOLEAN m_bChanged;
+ /* flag to specify if config records are loaded */
+ BOOLEAN m_bLoaded;
+ /* time stamp of last deserialization */
+ XPL_CLK_CLOCK_T m_nLastLoadTimeStamp;
+ /* type of config file (acl or event subscriptions */
+ SYNCML_DM_FILE_TYPE_T m_efileType;
+ /* storage for confif records */
+ DMVector<PDMConfigItem> m_aConfig;
+
+ /**
+ * Allocates new configuration item
+ * \return pointer on new config item
+ */
+ virtual DMConfigItem * AllocateConfigItem() = 0;
+
+ /**
+ * Returns name of configuration file
+ * \param strFileName [out] - file name
+ */
+ virtual void GetFileName(DMString & strFileName) = 0;
+
+ /**
+ * Ensures that config file is locked
+ */
+ void CheckLocking();
+
+ /**
+ * Finds config item by path
+ * \param szPath [in] - configuration path to be found
+ * \param oConfigItem [out] - smart pointer on found config item
+ * \return index of config item in the internal storage if found, -1 otherwise
+ */
+ INT32 Find(CPCHAR szPath,
+ PDMConfigItem & oConfigItem) const;
+
+ /**
+ * Finds config item by path
+ * \param szPath [in] - configuration path to be found
+ * \return index of config item in the internal storage if found, -1 otherwise
+ */
+ INT32 Find(CPCHAR szPath) const;
+
+ /**
+ * Gets config item by path
+ * \param szPath [in] - configuration path
+ * \param oConfigItem [out] - smart pointer on found config item
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Get(CPCHAR szPath,
+ PDMConfigItem & pItem) const;
+
+
+private:
+
+ /**
+ * Cleans internal memory
+ */
+ void ClearMemory();
+
+ /**
+ * Adds new config item into storage
+ * \param szPath [in] - configuration path
+ * \param szConfig [in] - encoded config record
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Add(const DMString & szPath,
+ CPCHAR szConfig,
+ const DMMap<INT32, DMString>& aDict);
+
+ /**
+ * Extracts path from a config file line (line is encoded as "[path]")
+ * \param line [in] - config file line
+ * \param strPath [in] - extracted path
+ * \return TRUE if peration is completed successfully
+ */
+ static BOOLEAN GetPath(char* line,
+ DMString& strPath );
+
+ /**
+ * Reads new line from a config file
+ * \param dmf [in] - file handler object
+ * \param line [out] - config file line
+ * \return TRUE if peration is completed successfully
+ */
+ static BOOLEAN GetNextLine(DMFileHandler& dmf,
+ char *line);
+
+ /**
+ * Performs recovery if needed
+ */
+ void CheckRecovery() const;
+
+ /**
+ * Adds principals stored in the config items into dictionary before serialization of config file
+ * \param aDict [out] - dictionary of principals
+ */
+ void UpdateDictionary(DMMap<DMString, INT32>& aDict);
+
+ /**
+ * Serializes dictionary into a config file
+ * \param dmf [in] - file handler object
+ * \param aDict [out] - dictionary of principals
+ */
+ static SYNCML_DM_RET_STATUS_T SerializeDictionary(DMFileHandler& dmf,
+ const DMMap<DMString, INT32>& aDict);
+
+
+ /**
+ * Deserializes dictionary from a config file
+ * \param dmf [in] - file handler object
+ * \param aDict [out] - dictionary of principals
+ */
+ static SYNCML_DM_RET_STATUS_T DeserializeDictionary(DMFileHandler& dmf,
+ DMMap<INT32, DMString>& aDict);
+
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmConstraints.h b/engine/dmlib/dmengine/dm_ua/hdr/dmConstraints.h
new file mode 100644
index 0000000..1bb82a2
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmConstraints.h
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMCONSTRAINTS_H
+#define DMCONSTRAINTS_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmConstrians.h
+
+General Description: This file contains declaration of the DMConstraints class, which specifies MDF constraints
+
+==================================================================================================*/
+
+#include "dmMetaDataBuffer.h"
+
+/* These enum values are used to indicate the node access type for SYNCML_DM_ACCESS_TYPE_T */
+enum
+{
+ SYNCML_DM_ADD_ACCESS_TYPE = SYNCML_DM_ACL_ADD,
+ SYNCML_DM_DELETE_ACCESS_TYPE = SYNCML_DM_ACL_DELETE,
+ SYNCML_DM_GET_ACCESS_TYPE = SYNCML_DM_ACL_GET,
+ SYNCML_DM_REPLACE_ACCESS_TYPE = SYNCML_DM_ACL_REPLACE,
+ SYNCML_DM_EXEC_ACCESS_TYPE = SYNCML_DM_ACL_EXEC,
+ SYNCML_DM_LOCAL_ACCESS_TYPE = 0x020,
+};
+typedef UINT8 SYNCML_DM_ACCESS_TYPE_T;
+
+
+enum
+{
+ SYNCML_DM_DDF_MIN = 1,
+ SYNCML_DM_DDF_MAX,
+ SYNCML_DM_DDF_VALUES,
+ SYNCML_DM_DDF_DEFAULTVALUE,
+ SYNCML_DM_DDF_MINLEN,
+ SYNCML_DM_DDF_MAXLEN,
+ SYNCML_DM_DDF_REGEXP,
+ SYNCML_DM_DDF_NMAXLEN,
+ SYNCML_DM_DDF_NVALUES,
+ SYNCML_DM_DDF_NREGEXP,
+ SYNCML_DM_DDF_AUTONODE,
+ SYNCML_DM_DDF_RECUR_AFTER_SEGMENT,
+ SYNCML_DM_DDF_MAX_RECURRANCE,
+ SYNCML_DM_DDF_FK,
+ SYNCML_DM_DDF_CHILD,
+ SYNCML_DM_DDF_DEPEND,
+ SYNCML_DM_DDF_MAX_MULTINODES
+
+};
+typedef UINT8 SYNCML_DM_DDF_CONSTRAINT_TYPE_T;
+
+
+/* These enum values are used to indicate the format of the data for SYNCML_DM_FORMAT_T */
+enum
+{
+ SYNCML_DM_DDF_MIME_TYPE_TEXTPLAIN = 0
+};
+typedef UINT8 SYNCML_DM_DDF_MIME_TYPE_T;
+
+
+
+/**
+* DMConstraints represent MDF constraints
+*/
+class DMConstraints
+{
+
+ friend class DMMetaDataManager;
+ friend class DMMetaDataNode;
+
+public:
+ /**
+ * Default constructor
+ */
+ DMConstraints();
+
+ /**
+ * Destructor
+ */
+ ~DMConstraints();
+
+ /**
+ * Operator to allocate memory
+ * \param sz [in] - number of bytes to be allocated
+ */
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ /**
+ * Operator to free memory
+ * \param buf [in] - pointer on buffer to be freed
+ */
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+ /**
+ * Reads constraints from MDF file
+ * \param pBuffer [in] - pointer on Meta Data buffer
+ * \param count [in] - number constraints to read
+ * \param nNodeType [in] - node type
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Read(DMMetaDataBuffer * pBuffer,
+ UINT8 count,
+ INT32 nNodeType);
+
+ /**
+ * Checks if default value may be set
+ * \return TRUE if set
+ */
+ inline BOOLEAN IsDefaultSet() const
+ {
+ return m_nNodeType != SYNCML_DM_FORMAT_NULL;
+ }
+
+ /**
+ * Retrieves default value as a string
+ * \param strValue [out] - default value as a string
+ */
+ void GetDefaultString( DMString& strValue )const;
+
+private:
+
+ /* Minimum value of int node*/
+ INT32 m_nMin;
+ /* Maximum value of int node*/
+ INT32 m_nMax;
+ /* Comma separated values */
+ CPCHAR m_psValues;
+ /* Node type */
+ INT32 m_nNodeType;
+ union {
+ /* Default value as a string */
+ CPCHAR m_psDef_Value;
+ /* Default int value */
+ INT32 m_nDef_Value;
+ /* Default float value */
+ FLOAT m_fDef_Value;
+ };
+
+ /* Maximum length of value */
+ UINT16 m_nMaxLen;
+ /* Minimum length of value */
+ UINT16 m_nMinLen;
+ /* Regular expression for value */
+ CPCHAR m_psRegexp;
+ /* Maximum length of node name */
+ UINT8 m_nnMaxLen;
+ /* Comma separated node names */
+ CPCHAR m_psnValues;
+ /* Regular expression for node name */
+ CPCHAR m_psnRegexp;
+ /* Auto nodes */
+ CPCHAR m_psAutoNodes;
+ /* Reccurrance pattern */
+ CPCHAR m_psRecurAfterSegment;
+ /* Maximum times the recurrance pattern can occur */
+ UINT16 m_nMaxRecurrance;
+ /* Foreign key */
+ CPCHAR m_psForeignKey;
+ /* Hard child dependency */
+ CPCHAR m_psChild;
+ /* Soft child dependency */
+ CPCHAR m_psDepend;
+ /* Max number of multinodes to be created */
+ UINT16 m_nMaxMultiNodes;
+
+
+ /**
+ * Initializes object
+ */
+ void Init();
+
+ /**
+ * Reads default value from MDF file
+ * \param pBuffer [in] - pointer on Meta Data buffer
+ * \param nNodeType [in] - node type
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ReadDefaultValue(DMMetaDataBuffer * pBuffer,
+ INT32 nNodeType);
+
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmEvent.h b/engine/dmlib/dmengine/dm_ua/hdr/dmEvent.h
new file mode 100644
index 0000000..f4810e1
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmEvent.h
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMEVENT_H
+#define DMEVENT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmEvent.h
+
+General Description: This file contains declaration of the DMEventPath and DMEventData classes,
+ which define DMT event
+
+==================================================================================================*/
+
+#include "dmtEventData.hpp"
+#include "dmBufferWriter.h"
+#include "dmBufferReader.h"
+
+/**
+* DMEventPath represents a path to parent of upadted node
+*/
+class DMEventPath : public JemBaseObject
+{
+
+public:
+ /**
+ * Default constructor
+ */
+ DMEventPath() {}
+
+ /**
+ * Constructor, which sets parent path
+ * \param szPath [in] - parent path
+ */
+ DMEventPath(CPCHAR szPath);
+
+ /**
+ * Default destructor
+ */
+ virtual ~DMEventPath() {}
+
+ /**
+ * Retrieves path
+ */
+ const DMString & GetPath() const { return m_strPath; }
+
+ /**
+ * Retrieves path
+ */
+ DMString & GetPath() { return m_strPath; }
+
+ /**
+ * Serializes path into a binary buffer
+ * \param oBuffer [out] - binary buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Serialize(DMBufferWriter & oBuffer);
+
+ /**
+ * Calculates size of path for serialization
+ * \return Return Type (UINT32)
+ */
+ UINT32 GetSize();
+
+ /**
+ * Deserializes path from a binary buffer
+ * \param oBuffer [out] - binary buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Deserialize(DMBufferReader & oBuffer);
+
+
+protected:
+ /* parent path */
+ DMString m_strPath;
+
+};
+
+
+
+
+/**
+* DMEventPath represents actual updates performed on node
+*/
+class DMEventData : public DmtEventData
+{
+
+public:
+ /**
+ * Default constructor
+ */
+ DMEventData()
+ {
+ m_bIsEnabledByParent = FALSE;
+ }
+
+ /**
+ * Constructor, that sets object members
+ * \param bIsLeaf [in] - specifies if node is a leaf
+ * \param eAction [in] - bit-wised actions performed on a node
+ * \param bIsEnabledByParent [in] - specifies if action is enabled by parent node
+ * \param szName [in] - node name
+ * \param szNewName [in] - new node name in case of "Rename" operation
+ */
+ DMEventData(BOOLEAN bIsLeaf,
+ SYNCML_DM_EVENT_ACTION_T eAction,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR strName,
+ CPCHAR strNewName = NULL);
+
+
+ /**
+ * Sets flag that specifies if node is a leaf
+ * \param bIsLeaf [in] - specifies if node is a leaf
+ */
+ void SetLeaf(BOOLEAN bIsLeaf);
+
+ /**
+ * Sets flag that specifies if action is a enabled by parent node
+ * \param bIsEnabledByparent [in] - specifies if event is enabled by parent node
+ */
+ void SetEnabledByParent(BOOLEAN bIsEnabledByParent);
+
+ /**
+ * Sets bit-wised action performed on node
+ * \param eAction [in] - bit-wised actions performed on a node
+ */
+ void SetAction(SYNCML_DM_EVENT_ACTION_T eAction);
+
+ /**
+ * Sets node name
+ * \param szName [in] - node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T SetName(CPCHAR strName);
+
+ /**
+ * Sets node new name
+ * \param szNewName [in] - node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T SetNewName(CPCHAR strNewName);
+
+ /**
+ * Adds action performed on node
+ * \param eAction [in] - action performed on a node
+ */
+ void AddAction(SYNCML_DM_EVENT_ACTION_T eAction) ;
+
+ /**
+ * Reset action performed on node
+ * \param eAction [in] - action should be removed
+ */
+ void RemoveAction(SYNCML_DM_EVENT_ACTION_T eAction) ;
+
+ /**
+ * Serializes object into a binary buffer
+ * \param oBuffer [out] - binary buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Serialize(DMBufferWriter & oBuffer);
+
+ /**
+ * Deserializes object from a binary buffer
+ * \param oBuffer [out] - binary buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Deserialize(DMBufferReader & oBuffer);
+
+ /**
+ * Calculates size of object for serialization
+ * \return Return Type (UINT32)
+ */
+ UINT32 GetSize();
+
+ /**
+ * Check if event is enabled by parent node
+ * \return TRUE if enabled by parent
+ */
+ BOOLEAN IsEnabledByParent() const { return m_bIsEnabledByParent; }
+
+private:
+ /* Specifies if event is enabled by parent node */
+ BOOLEAN m_bIsEnabledByParent;
+
+
+};
+
+typedef JemSmartPtr<DMEventPath> PDMEventPath;
+
+typedef DMMap<PDMEventPath, DmtEventDataVector > DMEventMap;
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmEventLogger.h b/engine/dmlib/dmengine/dm_ua/hdr/dmEventLogger.h
new file mode 100644
index 0000000..32a82d5
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmEventLogger.h
@@ -0,0 +1,467 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMEVENTLOGGER_H
+#define DMEVENTLOGGER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "dmstring.h"
+#include "dmvector.h"
+#include "dmEvent.h"
+#include "dmConfigItem.h"
+#include "dmPlugin.h"
+
+class DMTree;
+
+typedef DMMap<PDMConfigItem, DMEventMap> DMPostEventMap;
+typedef DMMap<PDMPlugin, DMEventMap> DMPluginEventMap;
+
+/**
+ * DMEventLogger represents event storage for broadcast events and commit plug-ins events.
+ */
+class DMEventLogger
+{
+public:
+ /**
+ * Default constructor
+ */
+ DMEventLogger();
+
+ /**
+ * Default destructor
+ */
+ ~DMEventLogger();
+
+ /**
+ * Initializes event logger
+ * \param pTree [in] - pointer on DM tree object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Init( DMTree* tree );
+
+ /**
+ * Adds a commit-plug-in event
+ * \param szPath [in/out] - path of updated node
+ * \param nAction [in] - action performed on a node
+ * \param pPlugin [in] - smart pointer on commit plug-in
+ * \param bIsEnabledByParent [in] - specifies if action is enabled by parent node
+ * \param szNewName [in] - new node name in case of "Rename" operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T OnNodeChanged(CPCHAR szPath ,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ const PDMPlugin & pPlugin,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szNewName = NULL );
+
+ /**
+ * Adds a broadcast event
+ * \param szPath [in/out] - path of updated node
+ * \param nAction [in] - action performed on a node
+ * \param pItem [in] - smart pointer on event subscription
+ * \param bIsEnabledByParent [in] - specifies if action is enabled by parent node
+ * \param szNewName [in] - new node name in case of "Rename" operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T OnNodeChanged(CPCHAR szPath ,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ const PDMConfigItem & pItem,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szNewName = NULL );
+
+ /**
+ * Post broadcast events via XPL layer.
+ */
+ void OnTreeSaved();
+
+ /**
+ * Reset internal storage.
+ */
+ void Reset();
+
+ /**
+ * Retrieves events map for specified commit plug-in
+ * \param pPlugin [in] - smart pointer on commit plug-in
+ * \param aUpdatedNodes [out] - events to be passed to commit plug-in
+ */
+ void GetCommitPluginEvents(const PDMPlugin & pPlugin,
+ DmtEventMap & aUpdatedNodes ) const;
+
+
+ /**
+ * Deserializes events map
+ * \param oBuffer [in] - binary buffer that contains events data
+ * \param aEventMap [out] - events map
+ * \param pItem [in] - smart pointer on event subscription
+ * \param bIsEnabledByParent [in] - specifies if action is enabled by parent node
+ * \param szNewName [in] - new node name in case of "Rename" operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ static SYNCML_DM_RET_STATUS_T Deserialize(DMBufferReader & oBuffer,
+ DmtEventMap & aEventMap);
+
+
+ /**
+ * Deserializes event data for leaf node
+ * \param oBuffer [in] - binary buffer that contains events data
+ * \param strParent [out] - parent node path
+ * \param aData [out] - smart pointer on event data (update description)
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ static SYNCML_DM_RET_STATUS_T Deserialize(DMBufferReader & oBuffer,
+ DMString & strParent,
+ PDmtEventData & aData);
+
+ /**
+ * Cleans records in the Event Logger in case of "Delete" operation performed on node.
+ * \param szPath [in] - path of deleted node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T CleanEvents(CPCHAR szPath);
+
+ /**
+ * Updates records in the Event Logger in case of "Rename" operation performed on node.
+ * \param szPath [in] - path of updated node
+ * \param szNewName [in] - new node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T UpdateEvents(CPCHAR szPath,
+ CPCHAR szNewName);
+
+
+ /**
+ * Verifies if update on node should be ignored (because it was already logged)
+ * \param szPath [in] - path of updated node
+ * \param nAction [in] - action performed on a node
+ * \param szNewName [in] - new node name
+ * \return TRUE if should be ignored
+ */
+ BOOLEAN IsIgnoreSubscriptionEvent(CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName = NULL);
+
+ /**
+ * Verifies if update on node should be ignored (because it was already logged)
+ * \param szPath [in] - path of updated node
+ * \param nAction [in] - action performed on a node
+ * \param szNewName [in] - new node name
+ * \return TRUE if should be ignored
+ */
+ BOOLEAN IsIgnorePluginEvent(CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName = NULL);
+
+
+private:
+ /* Map to store broadcast events */
+ DMPostEventMap m_aPostEvents;
+ /* Map to store commit plug-ins events */
+ DMPluginEventMap m_aPluginEvents;
+ /* Pointer on DM tree */
+ DMTree* m_pTree;
+
+ /**
+ * Calculates size of map for serialization
+ * \param aEventMap [in] - map of events
+ * \return Return Type (UINT32)
+ */
+ static UINT32 GetSize(const DMEventMap & aEventMap);
+
+
+ /**
+ * Finds records in the map by specified parent path
+ * \param szPath [in] - parent path to search
+ * \param aEventMap [in] - map of events
+ * \param pEventPath [out] - smart pointer on found path to parent node ( key )
+ * \param aVector [out] - found events vector ( value )
+ * \return TRUE if found
+ */
+ BOOLEAN Find(CPCHAR szPath,
+ const DMEventMap & aEventMap,
+ PDMEventPath & pEventPath,
+ DmtEventDataVector & aVector);
+
+ /**
+ * Finds record in the vector by specified name
+ * \param aVector [in] - vector of logged events
+ * \param nAction [in] - action performed on a node
+ * \param bIsCumulative [in] - specifies if event is a Cumulative
+ * \param bIsEnabledByParent [in] - specifies if event is enabled by parent node (Cumulative or Detailed)
+ * \param szName [in] - node name
+ * \param szNewName [in] - new node name in case of "Rename"
+ * \return Return Type (PDmtEventData)
+ * returns smart pointer on event data if found, null otherwise
+ */
+ PDmtEventData Find(const DmtEventDataVector & aVector,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ BOOLEAN bIsCumulative,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szName,
+ CPCHAR szNewName);
+
+ /**
+ * Adds action into existing event data
+ * \param pEventData [in/out] - smart pointer on event data
+ * \param nAction [in] - action performed on a node
+ * \param szNewName [in] - new node name in case of "Rename"
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T AddEvent(PDmtEventData & pEventData,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName);
+
+ /**
+ * Adds new event data into storage
+ * \param aVector [in] - vector of logged events
+ * \param nAction [in] - action performed on a node
+ * \param bIsLeaf [in] - specifies if node is a leaf
+ * \param bIsEnabledByParent [in] - specifies if event is enabled by parent node (Cumulative or Detailed)
+ * \param szName [in] - node name
+ * \param szNewName [in] - new node name in case of "Rename"
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T AddEvent(DmtEventDataVector & aVector,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ BOOLEAN bIsLeaf,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szName,
+ CPCHAR szNewName);
+
+
+ /**
+ * Adds an event (new event data or new action on existing record)
+ * \param szPath [in/out] - path of updated node
+ * \param nAction [in] - action performed on a node
+ * \param aEventMap [in/out] - map of events
+ * \param bIsCumulative [in] - specifies if event is a Cumulative
+ * \param bIsEnabledByParent [in] - specifies if action is enabled by parent node
+ * \param szNewName [in] - new node name in case of "Rename" operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T OnNodeChanged(CPCHAR szPath ,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ DMEventMap & aEventMap,
+ BOOLEAN bIsCumulative,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szNewName );
+
+
+ /**
+ * Cleans broadcast records in the Event Logger in case of "Delete" operation performed on node.
+ * \param szPath [in] - path of deleted node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T CleanConfigEvents(CPCHAR szPath);
+
+ /**
+ * Cleans commit plug-ins records in the Event Logger in case of "Delete" operation performed on node.
+ * \param szPath [in] - path of deleted node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T CleanPluginEvents(CPCHAR szPath);
+
+ /**
+ * Cleans records in the event map in case of "Delete" operation performed on node.
+ * \param aEventMap [in/out] - events map
+ * \param szPath [in] - path of deleted node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T CleanEvents(DMEventMap & aEventMap,
+ CPCHAR szPath);
+
+ /**
+ * Cleans event data records in the vectore in case of "Delete" operation performed on node.
+ * It removes only data enabled by parent node
+ * \param aVector [in/out] - events data vector
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T CleanEvents(DmtEventDataVector & aVector);
+
+
+ /**
+ * Updates records in the Event Logger in case of "Rename" operation performed on node.
+ * \param aEventMap [in/out] - events map
+ * \param szPath [in] - path of updated node
+ * \param szNewName [in] - new node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T UpdateEvents(DMEventMap & aEventMap,
+ CPCHAR szPath,
+ CPCHAR szNewName);
+
+ /**
+ * Updates broadcast records in the Event Logger in case of "Rename" operation performed on node.
+ * \param szPath [in] - path of updated node
+ * \param szNewName [in] - new node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T UpdateSubscriptionEvents(CPCHAR szPath,
+ CPCHAR szNewName);
+
+ /**
+ * Updates commit plug-ins records in the Event Logger in case of "Rename" operation performed on node.
+ * \param szPath [in] - path of updated node
+ * \param szNewName [in] - new node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T UpdatePluginEvents(CPCHAR szPath,
+ CPCHAR szNewName);
+
+
+ /**
+ * Finds and updates record for node in case of "Add" operation
+ * "Delete"-"Add" sequence on leaf node converted into "Replace"
+ * \param aVector [in/out] - events data vector
+ * \param szName [in] - node name
+ * \return TRUE if found
+ */
+ BOOLEAN FindRecordForAdd(const DmtEventDataVector & aVector, CPCHAR szName);
+
+ /**
+ * Finds record for node in case of "Replace" operation
+ * \param aVector [in/out] - events data vector
+ * \param szName [in] - node name
+ * \return TRUE if found
+ */
+ BOOLEAN FindRecordForReplace(const DmtEventDataVector & aVector,
+ CPCHAR szName);
+
+
+ /**
+ * Finds and updates record for node in case of "Rename" operation
+ * \param aVector [in/out] - events data vector
+ * \param szName [in] - node name
+ * \param szNewName [in] - node name
+ * \return TRUE if found
+ */
+ BOOLEAN FindRecordForRename(DmtEventDataVector & aVector,
+ CPCHAR szName,
+ CPCHAR szNewName);
+
+ /**
+ * Finds and remove rocord about add operation in case of "Delete" operation
+ * \param aVector [in/out] - events data vector
+ * \param szName [in] - node name
+ * \return TRUE if found
+ */
+ BOOLEAN FindRecordForDelete(DmtEventDataVector & aVector,
+ CPCHAR szName);
+
+ /**
+ * Finds and updates record for same node (Only 'Rename" checked in case of Cumulative events)
+ * \param aVector [in/out] - events data vector
+ * \param nAction [in] - action performed on a node
+ * \param szName [in] - node name
+ * \param bIsCumulative [in] - specifies if event is a Cumulative
+ * \param szNewName [in] - node name
+ * \return TRUE if found
+ */
+ BOOLEAN CheckEventOnSameNode(DmtEventDataVector & aVector,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szName,
+ BOOLEAN bIsCumulative,
+ CPCHAR szNewName);
+
+/**
+ * Checks if update should be ignored by Event Logger
+ * \param szPath [in/out] - path of updated node
+ * \param nAction [in] - action performed on a node
+ * \param aEventMap [in/out] - events map
+ * \param bIsCumulative [in] - specifies if event is a Cumulative
+ * \param szNewName [in] - node name
+ * \return TRUE if event should be ignored
+ */
+ BOOLEAN IsIgnoreEvent(CPCHAR szPath ,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ DMEventMap & aEventMap,
+ BOOLEAN bIsCumulative,
+ CPCHAR szNewName);
+
+
+ /**
+ * Deserializes events data vector
+ * \param oBuffer [in] - binary buffer that contains events data
+ * \param aVector [out] - events data vector
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ static SYNCML_DM_RET_STATUS_T Deserialize(DMBufferReader & oBuffer,
+ DmtEventDataVector & aVector);
+
+ /**
+ * Serializes events data vector into a binary buffer
+ * \param aVector [in] - events data vector
+ * \param oBuffer [out] - binary buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ static SYNCML_DM_RET_STATUS_T Serialize(const DmtEventDataVector & aVector,
+ DMBufferWriter & oBuffer);
+
+ /**
+ * Serializes events map into a binary buffer
+ * \param aEventMap [in] - events map
+ * \param oBuffer [out] - binary buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+static SYNCML_DM_RET_STATUS_T Serialize(const DMEventMap & aEventMap,
+ DMBufferWriter & oBuffer);
+
+
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmEventSubscription.h b/engine/dmlib/dmengine/dm_ua/hdr/dmEventSubscription.h
new file mode 100644
index 0000000..61014a4
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmEventSubscription.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMEVENTSUBSCRIPTION_H
+#define DMEVENTSUBSCRIPTION_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmEventSubscription.h
+
+General Description: This file contains declaration declaration
+ of DMEventSubscription class used for notification storing/handling
+
+==================================================================================================*/
+
+#include "dmstring.h"
+#include "dmvector.h"
+#include "dmtEvent.hpp"
+
+class DMTree;
+
+/**
+* DMEventSubscription represents an DMT event subscription.
+* Base class for DMSubscriptionItem and commit plug-in.
+*/
+class DMEventSubscription : public DmtEventSubscription {
+
+public:
+
+ /**
+ * Default constructor
+ */
+ DMEventSubscription() {}
+
+ /**
+ * Parses encoded event subscription record from sysplugin.ini file and sets values of object members
+ * \param szEvent [in] - encoded event subscription record
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Set(CPCHAR szEvent);
+
+ /**
+ * Verifies if particular operation/action should generate an event
+ * \param nAction [in] - action to check
+ * \param pTree [in] - pointer on tree object to access to DM accounts (verify OTA principals)
+ * \return TRUE if enabled
+ */
+ BOOLEAN IsEnabled(SYNCML_DM_EVENT_ACTION_T nAction,
+ DMTree* pTree);
+
+
+private:
+
+ /**
+ * Verifies if particular principal that initiated update is found in the list of principals
+ * \param pTree [in] - pointer on tree object to access to DM accounts (verify OTA principals)
+ * \param aPrincipals [in] - vector of principals
+ * \return TRUE if found
+ */
+ BOOLEAN VerifyPrincipal(DMTree * pTree,
+ const DMVector<DmtPrincipal> & aPrincipals);
+
+ /**
+ * Parses "key=value" segment of event subscription record from sysplugin.ini file
+ * \param szSegment [in] - segment of event subscription record
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ParseSegment(CPCHAR szSegment);
+
+ /**
+ * Parses "+" separated list of principals
+ * \param szSegment [in] - list of principals
+ * \param bIgnore [in] - TRUE if list principals to ignore is parsed
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ParsePrincipal(CPCHAR szSegment,
+ BOOLEAN bIsIgnore);
+
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmLock.h b/engine/dmlib/dmengine/dm_ua/hdr/dmLock.h
new file mode 100644
index 0000000..97f4b5a
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmLock.h
@@ -0,0 +1,302 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMLOCK_H
+#define DMLOCK_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: dmLock.h
+
+ General Description: Declaration of DMFileLockingThread, Clock and DMLockManager classes.
+
+==================================================================================================*/
+
+#include "dmdefs.h"
+#include "SyncML_DM_FileHandle.H"
+#include "dmvector.h"
+#include "file_manager.h"
+#include "dmtDefs.h"
+
+#ifndef DM_NO_LOCKING
+#include "dmThreadQueue.h"
+#endif
+
+enum {
+ SYNCML_DM_LOCKID_NONE = 0,
+ SYNCML_DM_LOCKID_IGNORE = 2,
+ SYNCML_DM_LOCKID_CURRENT = 4
+}; // predefined lock ids: ignore - means "no lock", current - means "whatever is registered"
+typedef UINT8 SYNCML_DM_LOCKID_T;
+
+enum {
+ SYNCML_DM_FILE_LOCK_STATUS_IN_PROGRESS,
+ SYNCML_DM_FILE_LOCK_STATUS_OK,
+ SYNCML_DM_FILE_LOCK_STATUS_TRY_AGAIN,
+ SYNCML_DM_FILE_LOCK_STATUS_ERROR
+};
+typedef UINT8 SYNCML_DM_FILE_LOCK_STATUS_T;
+
+enum {
+ SYNCML_DM_THREAD_STARTING,
+ SYNCML_DM_THREAD_STARTED,
+ SYNCML_DM_THREAD_FAILED
+};
+typedef UINT8 SYNCML_DM_THREAD_STATUS_T;
+
+
+enum {
+ /** Lock applied on ACL file */
+ SYNCML_DM_FILE_ACL = 0,
+ /** Lock applied on Event file */
+ SYNCML_DM_FILE_EVENT = 1,
+};
+typedef UINT8 SYNCML_DM_FILE_TYPE_T;
+
+
+#ifndef DM_NO_LOCKING
+struct DMFileLockParam
+{
+ INT32* m_pDoneFlag;
+ BOOLEAN m_bIsLock;
+ FILESETTYPE m_nLockSet;
+ SYNCML_DM_TREE_LOCK_TYPE_T m_eLockType;
+};
+
+class DMLock
+{
+public:
+ /**
+ * Default constructor
+ */
+ DMLock() ;
+
+ /**
+ * Destructor
+ */
+ ~DMLock() ;
+
+ /**
+ * Initializes file lock
+ * \param szLockFileName [in] - lock file name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Init( CPCHAR szLockFileName) ;
+
+ /**
+ * Cleanups file lock
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Destroy() ;
+
+ /**
+ * Locks file
+ * \param eLockType [in] - type of DM lock
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Lock( SYNCML_DM_TREE_LOCK_TYPE_T eLockType);
+
+ /**
+ * Unlocks file
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Unlock() ;
+
+ /**
+ * Verifies if lock counter equal 1 (last reader)
+ */
+ inline BOOLEAN IsLastLock() { return ( (m_nReadWriteCounter <= 1) ? TRUE : FALSE ); }
+
+protected:
+ /** Tree pointer */
+ DMFileHandler* m_pFile;
+ /**Number of readers (>0) or writers (<0)*/
+ INT32 m_nReadWriteCounter;
+
+public:
+ /** Saves system handles and use only 1 mutex, since it's locked time very short */
+ static DMCriticalSection m_csLock ;
+
+};
+
+class DMLockManager;
+
+
+class DMFileLockingThread : public DMThread
+{
+public:
+
+ /**
+ * Constructor
+ * \param pLockManager [in] - pointer on file lock manager
+ */
+ DMFileLockingThread ( DMLockManager* pLockManager ) ;
+
+ /**
+ * Retrieves thread state
+ */
+ SYNCML_DM_THREAD_STATUS_T GetThreadState() const;
+
+protected:
+ /**
+ * Thread run method
+ */
+ virtual void* Run();
+ /**Thread state */
+ SYNCML_DM_THREAD_STATUS_T m_nReady;
+ /** Memory check interval time in msec */
+ INT32 m_nAgingCheckInterval;
+ /** File lock manager */
+ DMLockManager * m_pLockManager;
+};
+
+
+class DMLockManager
+{
+public:
+ /**
+ * Default constructor
+ */
+ DMLockManager() ;
+
+ /**
+ * Destructor
+ */
+ ~DMLockManager() ;
+
+ /**
+ * Initializes locking manager
+ * \param szLockFileNamePrefix [in] - lock file name preffix
+ * \param nNumberOfLocks [in] - maximum number of locks to be applied
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Init(CPCHAR szLockFileNamePrefix,
+ INT32 nNumberOfLocks ) ;
+
+ /**
+ * Cleanups locking manager
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Destroy() ;
+
+ /**
+ * Locks file set
+ * \param nLockSet [in] - lock set
+ * \param eLockType [in] - type of lock
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T LockSet( FILESETTYPE nLockSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType) ;
+
+ /**
+ * Unlocks file set
+ * \param nLockSet [in] - lock set
+ * \param eLockType [in] - type of lock
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T UnlockSet( FILESETTYPE nLockSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType) ;
+
+ /**
+ * Processes lock request by service thread
+ * \param pFileLockMsg [in] - locking request
+ * \returns TRUE if request is successful
+ */
+ BOOLEAN ProcessLockRequest( DMFileLockParam* pFileLockMsg ) ;
+
+ /**
+ * Retrieves pointer on message queue
+ */
+ DMThreadQueue* GetQueue() const {return m_ptrQueue;}
+
+
+ /**
+ * Unlocks acl or event file
+ * \param eFileType [in] - type of a file
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ReleaseFile(SYNCML_DM_FILE_TYPE_T eFileType);
+
+ /**
+ * Unlocks acl or event file
+ * \param eFileType [in] - type of a file
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T AcquireFile(SYNCML_DM_FILE_TYPE_T eFileType);
+
+private:
+ /**
+ * Sends locking request to management thread Unlocks acl or event file
+ * \param nOperation [in] - type requested operation (lock/unlock)
+ * \param nLockSet [in] - file set to lock
+ * \param eLockType [in] - type of requested lock
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T SendAndWait(BOOLEAN bIsLock,
+ FILESETTYPE nLockSet,
+ INT32 eLockType ) ;
+
+private:
+ /** Vector of locks */
+ DMVector<DMLock> m_aLocks;
+ /** Housekeeping thread */
+ DMFileLockingThread m_oThread;
+ /** Tree pointer */
+ PDMThreadQueue m_ptrQueue;
+
+ /**
+ * Starts DM house keeping thread
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T StartThread();
+
+};
+
+inline SYNCML_DM_THREAD_STATUS_T DMFileLockingThread::GetThreadState() const
+{
+ return m_nReady;
+}
+
+#endif // !DM_NO_LOCKING
+#endif // !DMLOCK_H
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmLockCtxMgr.h b/engine/dmlib/dmengine/dm_ua/hdr/dmLockCtxMgr.h
new file mode 100644
index 0000000..e6a955b
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmLockCtxMgr.h
@@ -0,0 +1,285 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMLOCKCTXMANAGER_H
+#define DMLOCKCTXMANAGER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: dmLockCtxMgr.h
+
+ General Description: This file contains declaration of the DMLockContextManager class
+
+==================================================================================================*/
+
+#include "dmLock.h"
+#ifndef DM_NO_LOCKING
+#include "dmThreadQueue.h"
+#endif
+
+class DMLockContext
+{
+
+public:
+ inline DMLockContext() {m_nFileSet = 0; m_eLockType = 0; m_bAtomic = FALSE;}
+
+ void Set(FILESETTYPE nFileSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType,
+ DMString strRoot,
+ BOOLEAN bAtomic)
+ {
+ m_nFileSet = nFileSet;
+ m_eLockType = eLockType;
+ m_strRoot = strRoot;
+ m_bAtomic = bAtomic;
+ }
+
+ /** File set to apply lock */
+ FILESETTYPE m_nFileSet;
+ /** Lock type */
+ SYNCML_DM_TREE_LOCK_TYPE_T m_eLockType;
+ /** Root path of sub tree */
+ DMString m_strRoot;
+ /** Flag to check if operation is an atomic */
+ BOOLEAN m_bAtomic;
+};
+
+class DMLockContextManager
+{
+public:
+
+ /**
+ * Default constructor
+ */
+ DMLockContextManager() ;
+
+/**
+ * Destructor
+ */
+ ~DMLockContextManager() ;
+
+ /**
+ * Initializes locking manager
+ * \param pTree [in] - pointer on DM tree
+ * \param pFileManager [in] - pointer on file manager
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Init(DMTree* pTree,
+ CMultipleFileManager* pFileManager) ;
+
+ /**
+ * Destroys/cleanup locking manager
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Destroy() ;
+
+
+ /**
+ * Validates lock context
+ * \param nID [in/out] - lock id
+ * \param szURI [in] - locking path
+ * \param szPrincipal [in] - principal that attempt to get tree access
+ * \param eLockType [in] - lock type (read only/shared/exclusive)
+ * \param bInTransaction [in] - specifies if DMT within atomic transaction
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully and global lock is aquired.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ValidateAndLockTNM(INT32& nID,
+ CPCHAR szURI,
+ CPCHAR szPrincipal,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType,
+ BOOLEAN bInTransaction );
+
+ /**
+ * Releases locks and all corresponding files; acquire global lock internaly only
+ * \param nID [in] - lock id
+ * \param command [in] - command performed on DMT
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully and global lock is aquired.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ReleaseID(INT32 nID,
+ SYNCML_DM_COMMAND_T command);
+
+ /**
+ * Releases locks and all corresponding files; does not acquire global lock internaly
+ * \param nID [in] - lock id
+ * \param command [in] - command performed on DMT
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully and global lock is acquired.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ReleaseIDInternal(INT32 nID,
+ SYNCML_DM_COMMAND_T command);
+
+ /**
+ * Releases global lock
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully and global lock is acquired.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T UnlockTNM();
+
+ /**
+ * Releases all locks
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully and global lock is acquired.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ReleaseAll();
+
+ /**
+ * Starts auto-release timer
+ */
+ void OnTreeAccessed();
+
+#ifndef DM_NO_LOCKING
+ /**
+ * Returns critical section to enable direct engine locking - use with caution
+ */
+ inline DMCriticalSection& GetEngineLock() { return m_csTNMLock;}
+#else
+
+ /**
+ * Verifies if DMT is locked
+ * \returns TRUE if DMT is locked
+ */
+ inline BOOLEAN IsLocked() const { return m_bIsLocked; }
+
+ /**
+ * Locks DMT
+ */
+ void Lock();
+
+ /**
+ * Unlocks DMT
+ */
+ void UnLock();
+
+#endif
+
+
+ /**
+ * Acquires global lock for recovery or persistence
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully and global lock is aquired.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T GlobalLock() ;
+
+ /**
+ * Releases global lock for recovery or persistence
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully and global lock is aquired.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T GlobalUnlock() ;
+
+ /**
+ * Locks event or acl file
+ */
+ void InsureFileLocked(SYNCML_DM_FILE_TYPE_T eLockType);
+
+ /**
+ * Checks memory aging
+ */
+ void CheckMemoryAging();
+
+private:
+ /**
+ * Copy constructor
+ */
+ DMLockContextManager( const DMLockContextManager& );
+ const DMLockContextManager& operator=( const DMLockContextManager& );
+
+ /**
+ * Stops auto-release timer
+ */
+ void StopTimer() ;
+
+ /**
+ * Releases lock context by lock id
+ * \param nID [in] - lock id
+ * \param ctx [in] - lock context
+ * \param command [in] - command performed on DMT
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully and global lock is acquired.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ReleaseContext( INT32 nLockID,
+ const DMLockContext& ctx,
+ SYNCML_DM_COMMAND_T command);
+
+ /**
+ * Checks if config file should be released
+ * \param nID [in] - lock id
+ * \param index [out] - index of file to be released
+ * \returns TRUE if lock ID is found
+ */
+ BOOLEAN IsReleaseConfigFile(INT32 nLockID,
+ SYNCML_DM_FILE_TYPE_T & index);
+
+ /**
+ * Releases/revert config file based on result of previous operation
+ * \param index [out] - index of file to be released
+ * \param dm_stat [in] - result of previous operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully and global lock is acquired.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ReleaseConfigFile(SYNCML_DM_FILE_TYPE_T index,
+ SYNCML_DM_RET_STATUS_T dm_stat);
+
+ /** Tree pointer */
+ DMTree *m_pTree;
+ /** Unique id for next context */
+ INT32 m_nNewUniqueID;
+ /** Map of locked context */
+ DMMap< INT32, DMLockContext > m_mapContexts;
+ /** Pointer on file manager */
+ CMultipleFileManager *m_ptrFM;
+ /** Tree pointer */
+ INT32 m_nCurrentLockID;
+ /** Lock Ids who owns acl and evt */
+ SYNCML_DM_FILE_TYPE_T m_nLockWithConfig_ID[2];
+ /** Memory aging time */
+ INT32 m_nAgingTime;
+#ifndef DM_NO_LOCKING
+ /** Global lock to share access to DMT */
+ DMCriticalSection m_csTNMLock;
+ /** Lock manager */
+ DMLockManager m_oLockManager;
+ /** File to apply global lock */
+ DMFileHandler* m_pGlobalLockFile;
+#else
+ /** Timer handler for memory aging */
+ XPL_TIMER_HANDLE_T m_nMemoryTimer;
+ /** Locking flag */
+ BOOLEAN m_bIsLocked;
+#endif
+};
+
+/*================================================================================================*/
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmLockingHelper.h b/engine/dmlib/dmengine/dm_ua/hdr/dmLockingHelper.h
new file mode 100644
index 0000000..5e0f858
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmLockingHelper.h
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DKLOCKINGHELPER_H
+#define DMLOCKINGHELPER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: dmLockingHelper.h
+
+ General Description: This file contains declaration of the SYNCML_DM_LockCtxMgr class
+
+==================================================================================================*/
+
+#include "dmLockCtxMgr.h"
+
+/**
+* helper class to init/done locking stuff
+*/
+class DmtTreeImpl;
+
+class DMLockingHelper
+{
+public:
+
+ /**
+ * Default constructor
+ * \param nID [in] - lock id
+ * \param szURI [in] - locking path
+ * \param szPrincipal [in] - principal that attempt to get tree access
+ * \param eLockType [in] - lock type (read only/shared/exclusive)
+ * \param bInTransaction [in] - specifies if DMT within atomic transaction
+ */
+
+ DMLockingHelper()
+ {
+ m_nLockID = 0; m_bIDChanged = FALSE; m_nError = SYNCML_DM_FAIL;
+ }
+
+ /**
+ * Constructor
+ * \param nID [in] - lock id
+ * \param szURI [in] - locking path
+ * \param szPrincipal [in] - principal that attempt to get tree access
+ * \param eLockType [in] - lock type (read only/shared/exclusive)
+ * \param bInTransaction [in] - specifies if DMT within atomic transaction
+ */
+ DMLockingHelper( INT32 nCurID,
+ CPCHAR szURI,
+ CPCHAR szPrincipal,
+ INT32 eLockType,
+ BOOLEAN bInTransaction )
+ {
+ Lock(nCurID, szURI, szPrincipal, eLockType, bInTransaction);
+ }
+
+
+ /**
+ * Constructor
+ * \param pTree [in] - pointer on tree to be locked
+ * \param eLockType [in] - lock type (read only/shared/exclusive)
+ */
+
+ DMLockingHelper(DmtTreeImpl* pTree,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType );
+
+
+ /**
+ * Destructor
+ */
+ ~DMLockingHelper();
+
+ /**
+ * Verifies if tree is locked successfully
+ * returns TRUE if subtree is locked successfully
+ */
+ BOOLEAN IsLockedSuccessfully() const {return m_nError == SYNCML_DM_SUCCESS;}
+
+ /**
+ * Retrieves DM status code
+ */
+ SYNCML_DM_RET_STATUS_T GetError() const { return m_nError; }
+
+ /**
+ * Verifies if lock ID is updated
+ * returns TRUE if lock ID is changed
+ */
+ BOOLEAN IsIDChanged() const {return m_bIDChanged;}
+
+ /**
+ * Retrieves lock ID
+ */
+ INT32 GetID() const {return m_nLockID;}
+
+protected:
+ /** Lock ID */
+ INT32 m_nLockID;
+ /** Locking status */
+ SYNCML_DM_RET_STATUS_T m_nError;
+ /** Lock update flag */
+ BOOLEAN m_bIDChanged;
+
+ /**
+ * Locks subtree
+ * \param nID [in] - lock id
+ * \param szURI [in] - locking path
+ * \param szPrincipal [in] - principal that attempt to get tree access
+ * \param eLockType [in] - lock type (read only/shared/exclusive)
+ * \param bInTransaction [in] - specifies if DMT within atomic transaction
+ * returns TRUE if subtree is locked successfully
+ */
+ BOOLEAN Lock( INT32 nCurID,
+ CPCHAR szURI,
+ CPCHAR szPrincipal,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType,
+ BOOLEAN bInTransaction );
+
+};
+
+
+/**
+* ShortTime global interprocess lock (file-based);
+* used for file operations to prevent race-conditions during power-loss recovery.
+*/
+struct DMGlobalLockHelper
+{
+ /**
+ * Default constructor
+ */
+ DMGlobalLockHelper();
+
+ /**
+ * Destructor
+ */
+ ~DMGlobalLockHelper();
+};
+
+/**
+* Special lock for OMA toolkit workspace - it can't be shared in one process
+*/
+struct DMGlobalOMAWorkspaceSharing
+{
+ /**
+ * Default constructor
+ */
+ DMGlobalOMAWorkspaceSharing();
+
+ /**
+ * Destructor
+ */
+ ~DMGlobalOMAWorkspaceSharing();
+
+private:
+#ifndef DM_NO_LOCKING
+ /** Critical section */
+ static DMCriticalSection m_csInitLock;
+ /** Flag to specify that workspace is locked */
+ static BOOLEAN m_bWorkspaceLocked;
+#endif
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataBuffer.h b/engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataBuffer.h
new file mode 100644
index 0000000..1122889
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataBuffer.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMMETADATABUFFER_H
+#define DMMETADATABUFFER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmMetaDataBuffer.h
+
+General Description: This file contains declaration declaration
+ of DMMetaBuffer class used for reading meta information from MDF file
+
+==================================================================================================*/
+
+#include <ctype.h>
+#include "syncml_dm_data_types.h"
+#include "dmvector.h"
+#include "dmbuffer.h"
+
+typedef const UINT8 * MDF_BUFFER_T;
+
+/**
+* DMMetaDataBuffer represent MDF reader
+*/
+class DMMetaDataBuffer
+{
+
+public:
+ /**
+ * Default constructor
+ */
+ DMMetaDataBuffer();
+
+ /**
+ * Constructor, that sets pointer on a MDF buffer
+ * \param pBuffer [in] - pointer on binary buffer
+ */
+ DMMetaDataBuffer(MDF_BUFFER_T pBuffer);
+
+ /**
+ * Retrieves pointer on a binary MDF buffer
+ */
+ inline MDF_BUFFER_T GetBuffer() const { return m_pBuffer; }
+
+ /**
+ * Sets pointer on a MDF buffer
+ * \param pBuffer [in] - pointer on binary buffer
+ */
+ inline void SetBuffer(MDF_BUFFER_T pBuffer)
+ {
+ m_pBuffer = pBuffer;
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ m_nOffset = 0;
+ m_nFilesSize = ReadUINT32();
+#endif
+ m_nOffset = 0;
+ }
+
+ /**
+ * Sets offset in a buffer
+ * \param offset [in] - position in the buffer to be set
+ */
+ inline void SetOffset(UINT32 offset)
+ {
+ m_nOffset = offset;
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ if ( m_nOffset >= m_nFilesSize )
+ {
+ m_bCorrupted = 1;
+ m_nOffset = 0;
+ }
+#endif
+ }
+
+ /**
+ * Changes position in a buffer
+ * \param offset [in] - number of bytes to move pistion in the buffer
+ */
+ inline void IncOffset(UINT32 offset)
+ {
+ m_nOffset += offset;
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ if ( m_nOffset >= m_nFilesSize )
+ {
+ m_bCorrupted = 1;
+ m_nOffset = 0;
+ }
+#endif
+ }
+
+ /**
+ * Retrieves current offset in a buffer
+ */
+ inline UINT32 GetOffset() { return m_nOffset; }
+
+ /**
+ * Reads string from a buffer
+ */
+ CPCHAR ReadString();
+
+ /**
+ * Reads one byte from a buffer
+ */
+ inline UINT8 ReadUINT8()
+ {
+ return *(m_pBuffer+m_nOffset++);
+ }
+
+ /**
+ * Reads two bytes value from a buffer
+ */
+ UINT16 ReadUINT16();
+
+ /**
+ * Reads integer value from a buffer
+ */
+ UINT32 ReadUINT32();
+
+ /**
+ * Reads float value from a buffer
+ */
+ FLOAT ReadFLOAT();
+
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ /**
+ * Checks if a buffer is corrupted
+ * \return 1 if corrupted
+ */
+ inline int IsCorrupted() const { return m_bCorrupted;}
+
+ /**
+ * Resets flag for corruption verification
+ */
+ inline void ResetCorrupted() { m_bCorrupted = 0;}
+#endif
+
+private:
+ /* Pointer on binary buffer that hold MDF */
+ MDF_BUFFER_T m_pBuffer;
+ /* Buffer offset */
+ UINT32 m_nOffset;
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ /* Buffer size */
+ UINT32 m_nFilesSize;
+ /* Flag to verify if buffer is corrupted */
+ static UINT32 m_bCorrupted;
+#endif
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataManager.h b/engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataManager.h
new file mode 100644
index 0000000..255968c
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataManager.h
@@ -0,0 +1,766 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_DDF_H
+#define SYNCML_DM_DDF_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: dmMetaDataManager.h
+
+ General Description: This file contains declaration of the DMMetaDataManager class
+
+==================================================================================================*/
+
+#include "dm_tree_class.H"
+#include "SyncML_DM_FileHandle.H"
+#include "dmMetaDataNode.h"
+#include "dmtoken.h"
+
+typedef BOOLEAN (*SYNCML_DM_MDF_CBACK)(DMNode* pNode, PDmtNode ptrPluginNode, CPCHAR szNodeName, CPCHAR szOrigName);
+
+
+class DMMetaDataVector : public DMVector<UINT32>
+{
+};
+
+class DMMetaPCharVector : public DMVector<CPCHAR>
+{
+};
+
+/**
+* DMMetaNodeLocator represents a locator of Meta Data node stored in a cache
+*/
+struct DMMetaNodeLocator
+{
+ /**
+ * Default constructor
+ */
+ DMMetaNodeLocator()
+ {
+ m_szName = NULL;
+ m_nOffset = 0;
+ m_wAccessType = 0;
+ }
+
+ /**
+ * Constructor that sets values of structures
+ * \param szName [in] - node name
+ * \param offset [in] - offset of a node in the MDF file
+ * \param wAccessType [in] - node access type
+ * \param oPath [in] - full MDF path
+ */
+ DMMetaNodeLocator(CPCHAR szName,
+ UINT32 offset,
+ SYNCML_DM_ACCESS_TYPE_T wAccessType,
+ const DMBuffer & oPath)
+ {
+ m_szName = szName;
+ m_nOffset = offset;
+ m_wAccessType = wAccessType;
+ oPath.copyTo(m_strPath);
+ }
+
+
+ /* Node name */
+ CPCHAR m_szName;
+ /* Offset of a node in the MDF file */
+ UINT32 m_nOffset;
+ /* Node access type */
+ SYNCML_DM_ACCESS_TYPE_T m_wAccessType;
+ /* Full MDF path */
+ DMString m_strPath;
+};
+
+
+class DMMetaDataNodeVector : public DMVector<DMMetaNodeLocator>
+{
+};
+
+/**
+* DMLastMetaDataNode represents a last accessed MDF node
+*/
+class DMLastMetaDataNode
+{
+public:
+ /**
+ * Default constructor
+ */
+ DMLastMetaDataNode ()
+ {
+ m_pBuffer = NULL;
+ }
+
+ /**
+ * Initializes object
+ */
+ void Init()
+ {
+ m_pBuffer = NULL;
+ m_oLocator.clear();
+ }
+
+ /* MDF buffer */
+ MDF_BUFFER_T m_pBuffer;
+ /* Meta node locator */
+ DMMetaDataNodeVector m_oLocator;
+};
+
+class DMTree;
+
+/**
+* DMMetaDataManager represents a Meda Data Manager for constraints and DMT schema verification
+*/
+class DMMetaDataManager
+{
+public:
+ /**
+ * Default constructor
+ */
+ DMMetaDataManager();
+
+ /**
+ * Destructor
+ */
+ ~DMMetaDataManager();
+
+ /**
+ * Initializes Meta Data manager
+ * \param env [in] - pointer on env object
+ * \param pTree[in] - pointer on DM tree object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Init( CEnv* env, DMTree* tree );
+
+ /**
+ * Deinitializes Meta Data manager
+ */
+ void DeInit();
+
+ /**
+ * Verifyes parameters of a node to be added
+ * \param pNode [in] - pointer on DM node to be added
+ * \param oAddData [in] - data to be added
+ * \param oAutoNodes [out] - comma separated list of nodes to be auto added
+ * \param bNodeGetAccess [out] - specifies if node has "Get" permission
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyAddParameters(DMNode* pNode,
+ DMAddData & oAddData,
+ DMToken & oAutoNodes,
+ BOOLEAN & bNodeGetAccess);
+
+ /**
+ * Verifyes parameters of a node to be replaced/renamed
+ * \param pNode [in] - pointer on DM node to be replaced
+ * \param szURI [in] - path to replaced node
+ * \param oAddData [in] - data to be replaced with
+ * \param szOrigName [in] - original name of a node (in case of "Rename" operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyReplaceParameters(DMNode* pNode,
+ CPCHAR szURI,
+ DMAddData & oAddData,
+ CPCHAR szOrigName);
+
+ /**
+ * Verifyes if node can de deleted
+ * \param pNode [in] - pointer on DM node to be deleted
+ * \param szURI [in] - path of node to be deleted
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyDeleteParameters(DMNode* pNode,
+ CPCHAR szURI);
+
+ /**
+ * Sets auto node property
+ * \param szURI [in] - path to replaced node
+ * \param oAddData [out] - data to be set for auto node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T SetAutoNodeProperty(CPCHAR szURI,
+ DMAddData & pAdd);
+
+ /**
+ * Verifyes access type od a node
+ * \param szURI [in] - node path
+ * \param accessType [in] - access type to be verified
+ * \param pChildDependNodes [out] - pointer on list of hard and soft dependencies of node
+ * \return TRUE if access type is found (operation is allowed)
+ */
+ BOOLEAN VerifyAccessType(CPCHAR szURI,
+ SYNCML_DM_ACCESS_TYPE_T accessType,
+ DMMetaPCharVector* pChildDependNodes = NULL);
+
+ /**
+ * Verifies max number of children multinodes that can by created under a node
+ * \param szURI [in] - Node path
+ * \param count [in] - current number of nodes
+ * \param bOPiDataParent [in] - specifies if node is a parent of node containing plug-in data
+ * \return TRUE if max number isn't reached
+ */
+ BOOLEAN VerifyChildrenMultiNodesCount(CPCHAR szURI,
+ UINT16 count,
+ BOOLEAN& bOPiDataParent);
+
+ /**
+ * Verifies if node is a overlay plug-in node
+ * \param szURI [in] - node path
+ * \param szID [out] - node id
+ * \param wAccessType [out] - node access type
+ * \param nNodeFormat [out] - node format
+ * \return TRUE if node ia a overlay plug-in node
+ */
+ BOOLEAN VerifyOPINode(CPCHAR szURI,
+ CPCHAR& szID,
+ SYNCML_DM_ACCESS_TYPE_T& wAccessType,
+ SYNCML_DM_FORMAT_T& nNodeFormat );
+
+ /**
+ * Retrieves children of node as "/" separated string
+ * \param szURI [in] - node path
+ * \param strChildrenList [out] - list of children
+ * \return count of children
+ */
+ UINT16 UpdateChildrenList(CPCHAR szURI,
+ DMString& strChildrenList );
+
+ /**
+ * Verifies if node is a parent of node containing plg-in data
+ * \param szURI [in] - node path
+ * \return TRUE if node is a parent of node containing plg-in data
+ */
+ BOOLEAN IsOPiDataParent(CPCHAR szURI);
+
+ /**
+ * Checks if node has a "Local" attribute
+ * \param szURI [in] - node path
+ * \return TRUE if "Local" attribute is set
+ */
+ BOOLEAN IsLocal(CPCHAR szURI);
+
+ /**
+ * Checks if node is a leaf
+ * \param szURI [in] - node path
+ * \return TRUE if is a leaf
+ */
+ BOOLEAN IsLeaf(CPCHAR szURI);
+
+ /**
+ * Retrieves a MDF path for a node (could different because of multinodes and reccurance pattern
+ * \param szURI [in] - node path
+ * \param szPath [out] - MDF path
+ * \return count of children
+ */
+ SYNCML_DM_RET_STATUS_T GetPath(CPCHAR szURI,
+ DMString & szMDF);
+
+#ifdef LOB_SUPPORT
+ /**
+ * Verifies if node is a large object
+ * \param szURI [in] - node path
+ * \return TRUE if node is a large object
+ */
+ BOOLEAN IsESN( CPCHAR szURI );
+
+ /**
+ * Verifies if node is a progress bar is required for large object
+ * \param szURI [in] - node path
+ * \return TRUE if progress bar is required
+ */
+ BOOLEAN IsProgressBarNeeded( CPCHAR szURI );
+#endif
+
+private:
+ enum
+ {
+ CurrentBMDFVersion = 1,
+ BMDFHeaderSize = 6 /* file size (4) and version (2) */
+ };
+
+ /**
+ * Copy constructor
+ */
+ DMMetaDataManager( const DMMetaDataManager& mdm );
+
+ /** Assignment operator */
+ const DMMetaDataManager& operator=( const DMMetaDataManager& mdm );
+
+ /**
+ * Retrieves node name (from path in case of plugin node or from URI
+ * \param pNode [in] - pointer on DM node
+ * \param szURI [in] - node path
+ * \return pointer on node name
+ */
+ CPCHAR GetNodeName(DMNode *pNode, CPCHAR szURI);
+
+ /**
+ * Verifyes parameters of a node for Add/Replace and Rename operation
+ * \param oNodeMDF [in] - Meta node
+ * \param pNode [in] - pointer on DM node to be verified
+ * \param szNodeName [in] - node name
+ * \param oAddData [in] - data to be added or replaced with
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyParameters(const DMMetaDataNode & oNodeMDF,
+ DMNode* pNode,
+ CPCHAR szNodeName,
+ DMAddData & oAddData);
+
+ /**
+ * Verifyes data field (value)
+ * \param oAddData [in] - data to be added or replaced with
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyData(DMAddData & oAddData);
+
+ /**
+ * Verifyes format of a node
+ * \param oNodeMDF [in] - Meta node
+ * \param oAddData [in] - data to be added or replaced with
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyFormat(const DMMetaDataNode & oNodeMDF,
+ DMAddData & oAddData);
+
+ /**
+ * Verifyes integer value
+ * \param oData [in] - value to be checked
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyInteger(const DMBuffer & oData);
+
+ /**
+ * Verifyes interior node constraints
+ * \param pConstraints [in] - pointer of node constraints
+ * \param szNodeName [in] - node name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyInteriorNodeConstraints(DMConstraints *pConstraints,
+ CPCHAR szNodeName);
+
+ /**
+ * Sets default value to data structure
+ * \param oNodeMDF [in] - Meta node
+ * \param oAddData [out] - data to be added or replaced with
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T SetDefaultValue(const DMMetaDataNode & oNodeMDF,
+ DMAddData & oAddData);
+
+ /**
+ * Verifies leaf node constraints
+ * \param oNodeMDF [in] - Meta node
+ * \param oAddData [out] - data to be added or replaced with
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyLeafNodeConstraints(const DMMetaDataNode & oNodeMDF,
+ DMAddData & oAddData);
+
+ /**
+ * Verifies node constraints
+ * \param oNodeMDF [in] - Meta node
+ * \param pNode [in] - pointer on DM node to be verified
+ * \param szNodeName [in] - node name
+ * \param oAddData [out] - data to be added or replaced with
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T VerifyConstraints(const DMMetaDataNode & oNodeMDF,
+ DMNode* pNode,
+ CPCHAR szNodeName,
+ DMAddData & oAddData);
+
+
+ /**
+ * Verifyes if value is a digit
+ * \param oData [in] - value to be checked
+ * \return TRUE if value correct
+ */
+ BOOLEAN IsDigit(const DMBuffer & oData);
+
+ /**
+ * Verifyes if value is a boolean
+ * \param oData [in] - value to be checked
+ * \return TRUE if value correct
+ */
+ BOOLEAN IsBoolean(const DMBuffer & oData);
+
+ /**
+ * Verifyes if value is a float
+ * \param oData [in] - value to be checked
+ * \return TRUE if value correct
+ */
+ BOOLEAN IsFloat(const DMBuffer & oData);
+
+ /**
+ * Verifyes if value is a date
+ * \param oData [in] - value to be checked
+ * \return TRUE if value correct
+ */
+ BOOLEAN IsDate(const DMBuffer & oData);
+
+ /**
+ * Verifyes if value is a time
+ * \param oData [in] - value to be checked
+ * \return TRUE if value correct
+ */
+ BOOLEAN IsTime(const DMBuffer & oData);
+
+ /**
+ * Verifyes node name value constraint
+ * \param pConstraints [in] - pointer of node constraints
+ * \param szNodeName [in] - node name
+ * \return TRUE if node name is correct
+ */
+ BOOLEAN VerifynValues(DMConstraints *pConstraints,
+ const DMString & szNodeName);
+
+ /**
+ * Verifyes node value constraint
+ * \param pConstraints [in] - pointer of node constraints
+ * \param format [in] - node format
+ * \param oData [in] - node value
+ * \return TRUE if value is correct
+ */
+ BOOLEAN VerifyValues(DMConstraints *pConstraints,
+ SYNCML_DM_FORMAT_T format,
+ const DMBuffer & oData);
+
+ /**
+ * Verifyes foreign key constraint
+ * \param pConstraints [in] - pointer of node constraints
+ * \param oData [in] - node value
+ * \return TRUE if value is correct
+ */
+ BOOLEAN VerifyForeignKey(DMConstraints * pConstraints,
+ const DMBuffer & oData);
+
+ /**
+ * Verifyes regular expression constraint
+ * \param pConstraints [in] - pointer of node constraints
+ * \param szData [in] - value to check
+ * \return TRUE if value is correct
+ */
+ SYNCML_DM_RET_STATUS_T VerifyRegExp(CPCHAR szPattern,
+ CPCHAR szData);
+
+ /**
+ * Searches Meta Data node name in the children list
+ * \param oBuffer [in] - Meta Data buffer (MDF file)
+ * \param szName [in] - node name
+ * \return Return Type (UINT32)
+ * returns offset on node if name is found, 0 otherwise
+ */
+ UINT32 FindNodeInChildrenList(DMMetaDataBuffer oBuffer,
+ CPCHAR szName) const;
+
+ /**
+ * Verifies hard and soft dependency constraints
+ * \param szNodeName [in] - node name
+ * \param szURI [in] - node path
+ * \param szOrigName [in] - original node name (in case of Rename)
+ * \param callBackSoft [in] - method to call for soft dependency constraint
+ * \param callBackHard [in] - method to call for hard dependency constraint
+ * \param accessType [in] - access type
+ * \return TRUE if constraints verified with success
+ */
+ BOOLEAN VerifyChildDependency(CPCHAR szNodeName,
+ CPCHAR szURI,
+ CPCHAR szOrigName,
+ SYNCML_DM_MDF_CBACK callBackSoft,
+ SYNCML_DM_MDF_CBACK callBackHard,
+ SYNCML_DM_ACCESS_TYPE_T accessType);
+
+ /**
+ * Verifies hard or soft dependency constraints
+ * \param szNodeName [in] - node name
+ * \param szDependencies [in] - soft or hard dependency constraint
+ * \param szOrigName [in] - original node name (in case of Rename)
+ * \param callBack [in] - method to call for constraint
+ * \param callBackSoft [in] - method to call for hard dependency constraint
+ * \return TRUE if constraints verified with success
+ */
+ BOOLEAN VerifyDependency(CPCHAR szNodeName,
+ CPCHAR szDependecies,
+ CPCHAR szOrigName,
+ SYNCML_DM_MDF_CBACK callBack);
+
+ /**
+ * Verifies hard or soft dependency constraint for one specified path (from constraint)
+ * \param pNode [in] - pointer on DM node to be verified
+ * \param szURI [in] - node path
+ * \param szNodeName [in] - node name
+ * \param szOneURI [in] - constraint path
+ * \param szOrigName [in] - original node name (in case of Rename)
+ * \param callBack [in] - method to call for dependency constraint
+ * \param bIsMultiNode [in] - specifies if node is a multinode
+ * \return TRUE if constraints verified with success
+ */
+ BOOLEAN VerifyOneURIDependency(DMNode* pNode,
+ char * sURI,
+ CPCHAR szNodeName,
+ CPCHAR szOneURI,
+ CPCHAR szOrigName,
+ SYNCML_DM_MDF_CBACK callBack,
+ BOOLEAN bIsMultiNode);
+
+ /**
+ * Verifies hard or soft dependency constraint for one specified path (from constraint) on plug-in node
+ * \param pNode [in] - pointer on DM node to be verified
+ * \param pPluginNode [in] - smart pointer on plug-in node
+ * \param szURI [in] - node path
+ * \param szNodeName [in] - node name
+ * \param szOneURI [in] - constraint path
+ * \param szOrigName [in] - original node name (in case of Rename)
+ * \param callBack [in] - method to call for dependency constraint
+ * \param bIsMultiNode [in] - specifies if node is a multinode
+ * \return TRUE if constraints verified with success
+ */
+ BOOLEAN VerifyPluginURIDependency(DMNode* pNode,
+ PDmtNode pPluginNode,
+ char * sURI,
+ CPCHAR szNodeName,
+ CPCHAR szOneURI,
+ CPCHAR szOrigName,
+ SYNCML_DM_MDF_CBACK callBack,
+ BOOLEAN bIsMultiNode);
+
+ /**
+ * Builds start point of search of MDF node base on last MDF node accessed
+ * \param szURI [in] - DM node path to be found in a cache
+ * \param oBuffer [in] - Meta Data buffer (MDF file)
+ * \param accessType [out] - accessType (is set if path is found in a cache)
+ * \param oNode [out] - Meta Node (is set if path is found in a cache)
+ * \return Return Type (CPCHAR)
+ * returns tail segments of szURI from which manager continues seach, NULL if path isn't found in a cache.
+ * - All other codes indicate failure.
+ */
+ CPCHAR BuildSearchURI(CPCHAR szURI,
+ DMMetaDataBuffer & oBuffer,
+ SYNCML_DM_ACCESS_TYPE_T & accessType,
+ DMMetaDataNode & oNode );
+
+ /**
+ * Searches MDF node
+ * \param szURI [in] - node path to be found
+ * \param oBuffer [in] - Meta Data buffer (MDF file)
+ * \param parentAccessType [in] - access type from parent node
+ * \param bCheckMultiNode [in] - specifies if max number of multinodes should be read
+ * \param oNode [out] - found Meta Data node
+ * \param pChildDependNodes [out] - pointer on list of hard and soft dependencies of node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T SearchNode(CPCHAR szURI,
+ DMMetaDataBuffer oBuffer,
+ SYNCML_DM_ACCESS_TYPE_T parentAccessType,
+ BOOLEAN bCheckMultiNode,
+ DMMetaDataNode & oNode,
+ DMMetaPCharVector* pChildDependNodes );
+
+ /**
+ * Retrieves a MDF node
+ * \param szURI [in] - node path to be found
+ * \param bCheckMultiNode [in] - specifies if max number of multinodes should be read
+ * \param oNode [out] - found Meta Data node
+ * \param pChildDependNodes [out] - pointer on list of hard and soft dependencies of node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T GetNode(CPCHAR szURI,
+ BOOLEAN bCheckMultiNode,
+ DMMetaDataNode & pNode,
+ DMMetaPCharVector* pChildDependNodes = NULL);
+
+ /**
+ * Removes reccursive segments form search path
+ * \param sTailSegments [in] - URI to remove reccursive segments
+ * \param oNode [in] - Meta Data node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T RemoveRecursiveSegments(char* sTailSegment,
+ DMMetaDataNode & oNode);
+
+ /**
+ * Unloads MDF files from memory
+ */
+ void UnLoad();
+
+#ifndef DM_STATIC_FILES
+ /**
+ * Loads MDF files located in the specified directory
+ * \param szDirectory [in] - name of directory
+ * \param bIgnoreRoot [in] - specifies if root.bmdf should be ignored
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T LoadDir(CPCHAR szDirectory, BOOLEAN bIgnoreRoot);
+
+ /**
+ * Loads MDF file
+ * \param szPath [in] - file name
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T LoadBuffer(CPCHAR szPath);
+#else
+ /**
+ * Loads static MDF file
+ * \param szPath [in] - file index
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T LoadBuffer(UINT32 index);
+#endif
+
+ /**
+ * Loads MDF files
+ */
+ SYNCML_DM_RET_STATUS_T Load();
+
+ /**
+ * Verifies if specified node name is a value of other node
+ * \param pNode [in] - pointer on DM node to be verified
+ * \param pPluginNode [in] - smart pointer on plug-in node
+ * \param szNodeName [in] - node name
+ * \param szOrigName [in] - original node name (in case of Rename)
+ * \return TRUE if name is not value of other node
+ */
+ static BOOLEAN CheckFieldInUse(DMNode* pNode,
+ PDmtNode pPluginNode,
+ CPCHAR szNodeName,
+ CPCHAR szOrigName);
+
+ /**
+ * Clears value of node if specified node name is a value
+ * \param pNode [in] - pointer on DM node to be verified
+ * \param pPluginNode [in] - smart pointer on plug-in node
+ * \param szNodeName [in] - node name
+ * \param szOrigName [in] - original node name (in case of Rename)
+ * \return TRUE if name is not value of other node
+ */
+ static BOOLEAN ClearNodeValue(DMNode* pNode,
+ PDmtNode pPluginNode,
+ CPCHAR szNodeName,
+ CPCHAR szOrigName);
+
+ /**
+ * Resets value of node if specified node name is a value
+ * \param pNode [in] - pointer on DM node to be verified
+ * \param pPluginNode [in] - smart pointer on plug-in node
+ * \param szNodeName [in] - node name
+ * \param szOrigName [in] - original node name (in case of Rename)
+ * \return TRUE if name is not value of other node
+ */
+ static BOOLEAN ResetNodeValue(DMNode* pNode,
+ PDmtNode pPluginNode,
+ CPCHAR szNodeName,
+ CPCHAR szOrigName);
+
+ /**
+ * Retrieves root node from MDF file
+ * \param oNode [out] - Meta node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T GetRootNode(DMMetaDataNode & oNode);
+
+ /**
+ * Verifies and retrieves start position of path to search (skips "./" )
+ * \param szURI [in] - Meta node
+ * \return Return Type (CPCHAR)
+ * adjusted path, or NULL if URI isn't correct
+ */
+ CPCHAR GetStartPos(CPCHAR szURI);
+
+ /**
+ * Finds path in the cache of last accessed node
+ * \param szURI [in] - DM node path to be found in a cache
+ * \param bCheckMultiNode [in] - specifies if max number of multinodes should be read
+ * \param oNode [out] - Meta Data node
+ * \param oBuffer [out] - Meta Data buffer
+ * \param oNode [out] - Meta Node (is set if path is found in a cache)
+ * \param pChildDependNodes [out] - pointer on list of hard and soft dependencies of node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T FindCacheNode(CPCHAR szURI,
+ BOOLEAN bCheckMultiNode,
+ DMMetaDataNode & oNode,
+ DMMetaDataBuffer & oBuffer,
+ DMMetaPCharVector* pChildDependNodes);
+
+ /* Regular expression pattern for float values */
+ static CPCHAR m_pFloatPattern[];
+ /* Regular expression pattern for date values */
+ static CPCHAR m_pDatePattern[];
+ /* Regular expression pattern for time values */
+ static CPCHAR m_pTimePattern[];
+
+
+ /* pointer on env object */
+ CEnv* m_pEnv;
+ /* pointer on DMTree object */
+ DMTree* m_pTree;
+ /* Specifies if MDF file is loaded */
+ BOOLEAN m_bIsLoad;
+ /* Vector that hold pointers on MDF buffers loaded into memory */
+ DMMetaDataVector m_oDDFInfo;
+ /* Last accessed Meta Data node */
+ DMLastMetaDataNode m_oLastNodeLocator;
+};
+
+/*================================================================================================*/
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataNode.h b/engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataNode.h
new file mode 100644
index 0000000..25b20d8
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmMetaDataNode.h
@@ -0,0 +1,301 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMMETADATANODE_H
+#define DMMETADATANODE_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "dmConstraints.h"
+
+/**
+ * DMMetaDataNode represents a metadata node.
+ */
+class DMMetaDataNode
+{
+
+ friend class DMMetaDataManager;
+
+public:
+ DMMetaDataNode();
+
+ /**
+ * Operator to allocate memory
+ * \param sz [in] - number of bytes to be allocated
+ */
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ /**
+ * Operator to free memory
+ * \param buf [in] - pointer on buffer to be freed
+ */
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+ /**
+ * Retrieves pointer on constraints associated with meta node
+ * \return pointer on DMConstraints object
+ */
+ DMConstraints * GetConstraints() const;
+
+ /**
+ * Checks if meta node has child defined as multinode
+ * \return TRUE if has
+ */
+ inline BOOLEAN IsHasMultiNodes() const { return m_bIsHasMultiChildren; }
+
+ /**
+ * Checks if meta node is a multinode
+ * \return TRUE if it is a multinode
+ */
+ inline BOOLEAN IsMultiNode() const { return m_bIsMultiNode; }
+
+ /**
+ * Checks if node is a plugin node
+ * \return TRUE if it is a multinode
+ */
+ inline BOOLEAN IsPluginNode() const { return m_bPluginNode; }
+
+ /**
+ * Sets offset in the Meta Data buffer on specified child
+ * \param pBuffer [in] - pointer on Meta Data buffer
+ * \param index [in] - child index ( starts from 0 )
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T SetChildrenOffset(DMMetaDataBuffer * pBuffer,
+ UINT8 index);
+
+ /**
+ * Retrieves full path of meta
+ * \return Return Type (DMBuffer &)
+ */
+ const DMBuffer & GetPath() const { return m_oPath; }
+
+ /**
+ * Sets starting path of meta node
+ * \param szPath [in] - starting path of multinode
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T SetPath(CPCHAR szPath);
+
+ /**
+ * Allocates memory for full MDF path
+ * \param size [in] - number of bites to allocate
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T AllocatePath(UINT32 size);
+
+ /**
+ * Appends node name to built MDF path
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T AppendSegment();
+
+ /**
+ * Sets access type for node inherited from parent node
+ * \param accessType [in] - access type
+ */
+ void SetAccessType(SYNCML_DM_ACCESS_TYPE_T accessType);
+
+ /**
+ * Retrieves mime type
+ * \param strType [out] - myme type
+ */
+ void GetMimeType(DMString & strType);
+
+ /**
+ * Checks if node has a "Local" attribute
+ * \return TRUE if "Local" attribute is set
+ */
+ BOOLEAN IsLocal();
+
+ /**
+ * Checks if node is a leaf
+ * \return TRUE if is a leaf
+ */
+ BOOLEAN IsLeaf();
+
+ /**
+ * Verifies if access is specified for meta node
+ * \param accessType [in] - access type to check
+ * \return TRUE if operation is allowed
+ */
+ BOOLEAN VerifyAccessType(SYNCML_DM_ACCESS_TYPE_T accessType) const;
+
+ /**
+ * Verifies mime type
+ * \param mimeType [in] - mime type to checks
+ * \return TRUE if mime type is correct
+ */
+ BOOLEAN VerifyMimeType(CPCHAR mimeType) const;
+
+ /**
+ * Verifies max number of children multinodes that can by created under a node
+ * \param count [in] - current number of nodes
+ * \param bOPiDataParent [in] - specifies if node is a parent of node containing plug-in data
+ * \return TRUE if max number isn't reached
+ */
+ BOOLEAN VerifyChildrenMultiNodesCount(UINT16 count,
+ BOOLEAN& bOPiDataParent) const;
+
+ /**
+ * Reads max number of children multinodes may by created under a node
+ * \param oBuffer [in] - Meta Data buffer
+ * \param bOPiDataParent [in] - specifies if node is a parent of node containing plug-in data
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T GetMaxMultiNodeChildren(DMMetaDataBuffer oBuffer);
+
+ /**
+ * Reads node info from MDF file
+ * \param oBuffer [in] - Meta Data buffer
+ * \param bReadConstraints [in] - specifies if node constraints should be read
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Read(DMMetaDataBuffer oBuffer,
+ BOOLEAN bReadConstraints);
+
+ /**
+ * Reads node name from MDF file
+ * \param oBuffer [in] - Meta Data buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ReadName(DMMetaDataBuffer oBuffer);
+
+ /**
+ * Verifies if node is a overlay plug-in node
+ * \param szID [out] - node id
+ * \param wAccessType [out] - node access type
+ * \param nNodeFormat [out] - node format
+ * \return TRUE if node ia a overlay plug-in node
+ */
+ BOOLEAN VerifyOPINode(CPCHAR& szID,
+ SYNCML_DM_ACCESS_TYPE_T& wAccessType,
+ SYNCML_DM_FORMAT_T& nNodeFormat) const;
+
+ /**
+ * Verifies if node is a parent of node containing plg-in data
+ * \return TRUE if node is a parent of node containing plg-in data
+ */
+ inline BOOLEAN IsOPiDataParent() const { return m_bOPiDataParent;}
+
+#ifdef LOB_SUPPORT
+ /**
+ * Verifies if node is a large object
+ * \return TRUE if node is a large object
+ */
+ inline BOOLEAN IsESN() const { return m_bESN;}
+
+ /**
+ * Verifies if node is a progress bar is required for large object
+ * \return TRUE if progress bar is required
+ */
+ inline BOOLEAN IsProgressBarNeeded() const { return m_bProgressBarNeeded;}
+#endif
+
+private:
+ enum {
+ /* Mask for node type verification */
+ nodeTypeMask = 0x7f,
+ /* Specifies if node a multinode */
+ nodeMultiNode = 0x80,
+ /* Specifies if node stores plug-in data */
+ nodeStoresPD = 0x100,
+ /* Specifies if node a ovelraly plug-in node */
+ nodePluginNode = 0x200,
+ /* Specifies if node has an ID */
+ nodeHasID = 0x400,
+#ifdef LOB_SUPPORT
+ /* Specifies if node is a large object */
+ nodeESN = 0x800,
+ /* Specifies if progress bar is needed */
+ nodeProgressBar = 0x1000
+#endif
+ };
+
+ /**
+ * Verifies if node has multinode children
+ * \return TRUE if hode has multinode children
+ */
+ void CheckHasMultiNode(DMMetaDataBuffer oBuffer);
+
+ /**
+ * Initializes object
+ */
+ void Init();
+
+ /* Node name */
+ CPCHAR m_psName;
+ /* Node ID for overlay plug-in node */
+ CPCHAR m_szID;
+ /* Full MDF path to a node */
+ DMBuffer m_oPath;
+ /* Access type */
+ SYNCML_DM_ACCESS_TYPE_T m_wAccessType;
+ /* Node format */
+ SYNCML_DM_FORMAT_T m_nNodeFormat;
+ /* Mime Type */
+ SYNCML_DM_DDF_MIME_TYPE_T m_nMimeType;
+ /* Number of constraints a node has */
+ UINT8 m_nNumConstraints;
+ /* Number of children a node has */
+ UINT16 m_nNumChildren;
+ /* Offset to first child */
+ UINT32 m_nOffsetChildren;
+ /* Node constraints */
+ DMConstraints m_oConstraints;
+ /* Max number of multinode children */
+ UINT16 m_nMaxChildrenMultiNodes;
+ /* Specifies if node has multinode children */
+ BOOLEAN m_bIsHasMultiChildren;
+ /* Specifies if node is a multinode */
+ BOOLEAN m_bIsMultiNode;
+ /* Specifies if node stores a plug-in data */
+ BOOLEAN m_bStoresPD;
+ /* Specifies if node is a overlay plug-in node */
+ BOOLEAN m_bPluginNode;
+ /* Specifies if node is a parent of node that stores a plug-in data */
+ BOOLEAN m_bOPiDataParent;
+#ifdef LOB_SUPPORT
+ /* Specifies if node is a large object */
+ BOOLEAN m_bESN;
+ /* Specifies if progress bar is needed */
+ BOOLEAN m_bProgressBarNeeded;
+#endif
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmSubscriptionItem.h b/engine/dmlib/dmengine/dm_ua/hdr/dmSubscriptionItem.h
new file mode 100644
index 0000000..83fea38
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmSubscriptionItem.h
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMSUBSCRIPTIONITEM_H
+#define DMSUBSCRIPTIONITEM_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmSubscriptionItem.h
+
+General Description: This file contains declaration declaration
+ of DMSubscriptionItem class used for notification storing/handling
+
+==================================================================================================*/
+
+#include "dmstring.h"
+#include "dmConfigItem.h"
+#include "dmEventSubscription.h"
+
+/**
+* DMSubscriptionItem represents an DMT event subscription record.
+*/
+class DMSubscriptionItem : public DMConfigItem, public DMEventSubscription {
+
+public:
+
+ /**
+ * Default constructor
+ */
+ DMSubscriptionItem() {}
+
+ /**
+ * Constructor, which sets subscription path
+ * \param szPath [in] - configuration path (URI of a node)
+ */
+ DMSubscriptionItem(CPCHAR szPath);
+
+/**
+ * Assign values of object members
+ * \param oEvent [in] - subscription event set by application to add into config file
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Set(const DmtEventSubscription & oEvent);
+
+/**
+ * Parses encoded event subscription record and assign values of object members
+ * \param szPath [in] - configuration path (URI of a node)
+ * \param szConfig[in] - encoded acl record
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Set(CPCHAR szPath,
+ CPCHAR szConfig,
+ const DMMap<INT32, DMString>& aDict);
+
+
+/**
+ * Saves event subscription record back to a file
+ * \param dmf [in] - file handler object
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ virtual SYNCML_DM_RET_STATUS_T Serialize(DMFileHandler& dmf,
+ const DMMap<DMString, INT32>& aDict );
+
+ /**
+ * Adds principals stored in the acl item into dictionary before serialization of config file
+ * \param aDict [out] - dictionary of principals
+ */
+ virtual void UpdateDictionary(DMMap<DMString, INT32>& aDict);
+
+private:
+
+ /**
+ * Parses "key=value" segment of event subscription record
+ * \param szSegment [in] - segment of event subscription record
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ParseSegment(CPCHAR szSegment,
+ const DMMap<INT32, DMString>& aDict);
+
+/**
+ * Parses "+" separated list of principals (value)
+ * \param szSegment [in] - list of principals
+ * \param nPermission [in] - permission
+ * \param aDict [in] - dictionary of principals
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ParsePrincipal(CPCHAR szSegment,
+ BOOLEAN bIsIgnore,
+ const DMMap<INT32, DMString>& aDict);
+
+
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/hdr/dmSubscriptionManager.h b/engine/dmlib/dmengine/dm_ua/hdr/dmSubscriptionManager.h
new file mode 100644
index 0000000..ca7437f
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/hdr/dmSubscriptionManager.h
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMSUBSCRIPTIONMANAGER_H
+#define DMSUBSCRIPTIONMANAGER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmSubscriptionManager.h
+
+General Description: This file contains declaration declaration
+ of DMSubscriptionManager class used for notification storing/handling
+
+==================================================================================================*/
+
+#include "dmSubscriptionItem.h"
+#include "dmConfigManager.h"
+
+class DMTree;
+class CEnv;
+class SyncML_DM_Archive;
+
+/**
+* DMSubscriptionManager represents a class DM event subscription records management.
+* This class operates with subscriptions specified in the config file and subscriptions specified
+* by commit plug-ins
+*/
+class DMSubscriptionManager : public DMConfigManager {
+
+public:
+ /**
+ * Default constructor
+ */
+ DMSubscriptionManager() {}
+
+ /**
+ * Initializes a manager
+ * \param env [in] - pointer on env object
+ * \param pTree [in] - pointer on DM tree object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Init( CEnv* env, DMTree* tree );
+
+ /**
+ * Verifies if operation on DM node should be stored into Event Logger
+ * \param pArchive [in] - pointer on archive where node is persisted
+ * \param szPath [in] - path of updated node (Add/Replace/Rename/Indirect)
+ * \param nAction [in] - operation performed on node
+ * \param szNewName [in] - new node name in case of "Rename" operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T OnNodeChanged(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName = NULL );
+
+ /**
+ * Verifies if "Delete" operation on DM node should be stored into Event Logger
+ * \param pArchive [in] - pointer on archive where node is persisted
+ * \param szPath [in] - path of deleted node
+ * \param aDeletedChildren [in] - children of deleted node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T OnNodeDeleted(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ const DMStringVector & aDeletedChildren );
+
+
+ /**
+ * Adds event subscription record into config file. Called from DMT API
+ * \param szPath [in] - DM node path
+ * \param oEvent [in] - DM event subscription
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T EnableEvent(CPCHAR szPath,
+ const DmtEventSubscription & oEvent);
+
+ /**
+ * Retrieves DM event subscription
+ * \param szPath [in] - DM node path
+ * \param oEvent [out] - DM event subscription
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T GetEvent(CPCHAR szPath,
+ DmtEventSubscription & oEvent);
+
+private:
+ /**
+ * Returns name of configuration file ("event.dat")
+ * \param strFileName [out] - file name
+ */
+ virtual void GetFileName(DMString & strFileName);
+
+ /**
+ * Allocates new event subscription item
+ * \return pointer on new config item
+ */
+ virtual DMConfigItem * AllocateConfigItem();
+
+ /**
+ * Verifies if event is enabled on parent node by record from config file or commit plug-in
+ * \param strPath [out] - DM node path - set to parent path if event is Cumulative
+ * \param szParent [in] - path of parent node
+ * \param nAction [in] - action performed on a node
+ * \param pItem [in] - pointer on event subscription of parent node
+ * \return TRUE if enabled
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ BOOLEAN IsParentEnabled( DMString & strPath,
+ CPCHAR szParent,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ DMEventSubscription * pItem) const;
+
+ /**
+ * Verifies if event is enabled on parent node by event subscription record
+ * \param strPath [out] - DM node path to be logged - set to parent path if event is Cumulative
+ * \param szParent [in] - path of parent node
+ * \param nAction [in] - action performed on a node
+ * \param pItem [in] - smart pointer on event subscription of parent node
+ * \return TRUE if enabled
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ BOOLEAN IsParentEnabledBySubscription(DMString & strPath,
+ CPCHAR szParent,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMConfigItem & pItem) const;
+
+ /**
+ * Verifies if event is enabled by commit plug-in mounted on parent node
+ * \param strPath [out] - DM node path to be logged - set to parent path if event is Cumulative
+ * \param szParent [in] - path of parent node
+ * \param nAction [in] - action performed on a node
+ * \param pPlugin [in] - smart pointer on commit plug-in
+ * \return TRUE if enabled
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ BOOLEAN IsParentEnabledByPlugin(DMString & strPath,
+ CPCHAR szParent,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMPlugin & pPlugin) const;
+
+ /**
+ * Verifies if event is enabled by event subscription record
+ * \param strPath [in/out] - DM node path to be logged - set to parent path if event is Cumulative
+ * \param nAction [in] - action performed on a node
+ * \param pItem [out] - smart pointer on event subscription
+ * \param bIsEnabledByParent [out] - specifies if action is enabled by parent node (Cumulative or Detailed)
+ * \param bIsChild [in] - specifies if child node is checked (used for "Delete" operation)
+ * \return TRUE if enabled
+ */
+ BOOLEAN IsEnabledBySubscription(DMString & strPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMConfigItem & pItem,
+ BOOLEAN & bIsEnabledByParent,
+ BOOLEAN bIsChild) const;
+
+ /**
+ * Verifies if event is enabled by commit plug-in.
+ * \param strPath [in/out] - DM node path to be logged - set to parent path if event is Cumulative
+ * \param nAction [in] - action performed on a node
+ * \param pPlugin [out] - smart pointer on commit plug-in
+ * \param bIsEnabledByParent [out] - specifies if action is enabled by parent node (Cumulative or Detailed)
+ * \param bIsChild [in] - specifies if child node is checked (used for "Delete" operation)
+ * \return TRUE if enabled
+ */
+ BOOLEAN IsEnabledByPlugin(DMString & strPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMPlugin & pPlugin,
+ BOOLEAN & bIsEnabledByParent,
+ BOOLEAN bIsChild) const;
+
+ /**
+ * Verifies if event is enabled by commit plug-in. Checks node path and node MDF path if they are
+ * different
+ * \param strPath [in/out] - DM node path to be logged - set to parent path if event is Cumulative
+ * \param nAction [in] - action performed on a node
+ * \param pPlugin [out] - smart pointer on commit plig-in
+ * \param bIsEnabledByParent [out] - specifies if action is enabled by parent node (Cumulative or Detailed)
+ * \param bIsChild [in] - specifies if child node is checked (used for "Delete" operation)
+ * \return TRUE if enabled
+ */
+BOOLEAN IsEnabled(DMString & strPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMPlugin & pPlugin,
+ BOOLEAN & bIsEnabledByParent,
+ BOOLEAN bIsChild) const;
+
+
+/**
+ * Verifies if event is enabled by event subscription record. Checks node path and node MDF path if they are
+ * different
+ * \param strPath [in/out] - DM node path to be logged - set to parent path if event is Cumulative
+ * \param nAction [in] - action performed on a node
+ * \param pItem [out] - smart pointer on event subscription
+ * \param bIsEnabledByParent [out] - specifies if action is enabled by parent node (Cumulative or Detailed)
+ * \param bIsChild [in] - specifies if child node is checked (used for "Delete" operation)
+ * \return TRUE if enabled
+ */
+BOOLEAN IsEnabled(DMString & strPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMConfigItem & pItem,
+ BOOLEAN & bIsEnabledByParent,
+ BOOLEAN bIsChild) const;
+
+
+/**
+ * Verifies if event is enabled by event subscription record and logs it into Event Logger.
+ * \param pArchive [in] - pointer on archive where node is persisted
+ * \param strPath [in] - path of updated node
+ * \param nAction [in] - action performed on a node
+ * \param szNewName [in] - new node name in case of "Rename" operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+SYNCML_DM_RET_STATUS_T ProcessUpdateForSubscription(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName);
+
+
+/**
+ * Verifies if event is enabled by commit plug-in and logs it into Event Logger.
+ * \param pArchive [in] - pointer on archive where node is persisted
+ * \param strPath [in] - path of updated node
+ * \param nAction [in] - action performed on a node
+ * \param szNewName [in] - new node name in case of "Rename" operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+SYNCML_DM_RET_STATUS_T ProcessUpdateForPlugin(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName);
+
+
+/**
+ * Verifies if "Delete" event is enabled by event subscription record and logs it into Event Logger.
+ * \param pArchive [in] - pointer on archive where node is persisted
+ * \param strPath [in] - path of deleted node
+ * \param bIsChild [in] - specifies if child node of deleted node is processed
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+SYNCML_DM_RET_STATUS_T ProcessDeleteForSubscription(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ BOOLEAN bIsChild );
+
+/**
+ * Verifies if "Delete" event is enabled by commit plug-in and logs it into Event Logger.
+ * \param pArchive [in] - pointer on archive where node is persisted
+ * \param strPath [in] - path of deleted node
+ * \param bIsChild [in] - specifies if child node of deleted node is processed
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+SYNCML_DM_RET_STATUS_T ProcessDeleteForPlugin(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ BOOLEAN bIsChild );
+
+/**
+ * Trims path for Event Logger in case if cumulitive event enabled on parent node by MDF subscription path.
+ * \param strPath [in/out] - path for Event Logger (path of updated node)
+ * \param szMDF [in] - MDF path of parent node on which cumulative event is enabled
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+SYNCML_DM_RET_STATUS_T GetLogPath(DMString & strPath,
+ CPCHAR szMDF) const;
+
+
+/**
+ * Updates records in the Event Logger in case of Rename operation performed on node.
+ * \param strPath [in] - path of updated node
+ * \param nAction [in] - action performed on a node
+ * \param szNewName [in] - new node name in case of "Rename" operation
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+SYNCML_DM_RET_STATUS_T UpdateEvents(CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName);
+
+/**
+ * Cleans records in the Event Logger in case of Delete operation performed on node.
+ * \param strPath [in] - path of deleted node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+SYNCML_DM_RET_STATUS_T CleanEvents(CPCHAR szPath);
+
+/**
+ * Sets new name to null for "Rename" operation if event is a Cumulative and is enabled by parent node.
+ * \param bIsEnabledByparent [in] - specifies if event enebled by parent node
+ * \param pItem [in] - pointer on event subscription
+ * \param szNewName [in] - new node name
+ * \return pointer on new node name ( NULL or szNewName )
+ */
+CPCHAR ResetName(BOOLEAN bIsEnabledByParent,
+ DMEventSubscription * pItem,
+ CPCHAR szNewName);
+
+
+
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/src/SYNCML_DM_TreeMount.cc b/engine/dmlib/dmengine/dm_ua/src/SYNCML_DM_TreeMount.cc
new file mode 100644
index 0000000..c7f3346
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/SYNCML_DM_TreeMount.cc
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Header Name: SYNCML_DM_TreeMount.cc
+
+ General Description: Implementation of the and SYNCML_DM_TreeMount classes.
+
+==================================================================================================*/
+
+#include "dm_uri_utils.h"
+#include "SyncML_DM_WBXMLArchive.H"
+#include "dmBufferReader.h"
+#include "xpl_dm_Manager.h"
+#include "dm_tree_class.H"
+#include "SYNCML_DM_TreeMount.H"
+
+SYNCML_DM_TreeMount::SYNCML_DM_TreeMount()
+ : m_pTree( NULL )
+{
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_TreeMount::TreeAddToMountList (CPCHAR pUri, CPCHAR pTreePath)
+{
+ if( !m_pTree ) return SYNCML_DM_FAIL;
+
+ /* Validate the URI */
+ SYNCML_DM_URI_RESULT_T dm_uri_result = m_pTree->URIValidateAndParse(pUri);
+
+ if (( dm_uri_result == SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY ) ||
+ ( dm_uri_result == SYNCML_DM_COMMAND_INVALID_URI) ||
+ ( dm_uri_result == SYNCML_DM_COMMAND_URI_TOO_LONG ))
+ {
+ return (SYNCML_DM_FAIL);
+ }
+
+ /* Check if the entry is existed in the list already */
+ if ( m_astrURIs.find( pUri ) >= 0 )
+ return SYNCML_DM_ENTRY_EXIST;
+
+ CPCHAR loc = DmStrrchr(pTreePath, '.');
+
+ // Compare the last six chars for a ".wbxml" extension
+ if(loc == NULL || DmStrcmp(loc, SyncML_DM_WBXMLArchive::FILE_EXTENSION) != 0)
+ return SYNCML_DM_FAIL;
+
+ BOOLEAN bFeatureEnabled = TRUE;
+ bFeatureEnabled = DmIsEnabledURI(pUri);
+
+ m_astrURIs.push_back( pUri );
+ if ( bFeatureEnabled )
+ m_astrPaths.push_back( pTreePath );
+ else
+ m_astrPaths.push_back( NULL );
+
+ return (SYNCML_DM_SUCCESS);
+}
+
+void
+SYNCML_DM_TreeMount::GetTreeMountEntry(CPCHAR &p_Uri,
+ CPCHAR& p_TreePath,
+ UINT16 index) const
+{
+ /* If the list is empty, set OUTPUT parameters as NULL and return. */
+ if ( index >= m_astrURIs.size() ) {
+ p_Uri = NULL;
+ p_TreePath = NULL;
+ return;
+ }
+ p_Uri = m_astrURIs[index].c_str();
+ p_TreePath = m_astrPaths[index].c_str();
+}
+
+BOOLEAN
+SYNCML_DM_TreeMount::IsMountPointEnabled(CPCHAR pUri) const
+{
+ INT32 size = m_astrURIs.size();
+
+ for (INT32 index = 0; index < size; index++)
+ {
+ const DMString & str = m_astrURIs[index];
+ if ( DmIsParentURI( str.c_str(), pUri ) )
+ {
+ if ( m_astrPaths[index] == NULL )
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ }
+ return TRUE;
+}
+
+void
+SYNCML_DM_TreeMount::UnMountTree(void)
+{
+ m_astrURIs.clear();
+ m_astrPaths.clear();
+ m_pTree = NULL;
+}
+
+
+#ifndef DM_STATIC_FILES
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_TreeMount::MountTree( CEnv* env, DMTree* tree )
+{
+ if( !env || !tree ) return SYNCML_DM_FAIL;
+
+ m_pTree = tree;
+
+ DMString strLineBuffer;
+ char *line = strLineBuffer.AllocateBuffer(DM_MAX_CONFIG_LINE);
+ SYNCML_DM_RET_STATUS_T dm_result = SYNCML_DM_SUCCESS;
+ DMString strFstabFileName;
+
+ if ( !line )
+ return SYNCML_DM_DEVICE_FULL;
+
+ env->GetMainRFSFullPath(DM_FSTAB_FILENAME,strFstabFileName);
+
+ DMFileHandler fp( strFstabFileName );
+
+ dm_result = fp.open(XPL_FS_FILE_READ);
+
+ if ( dm_result != SYNCML_DM_SUCCESS )
+ return dm_result;
+
+ INT32 numMountedFiles =0;
+ char * uri = NULL;
+ char * filepath = NULL;
+ while( !fp.iseof() )
+ {
+ fp.fgets((char *)line, DM_MAX_CONFIG_LINE);
+ if( line[0] == '#' || line[0] == '\0' )
+ continue;
+
+ uri = line;
+ filepath = (char*)DmStrchr(line,' ');
+
+ if ( filepath == NULL )
+ break;
+
+ *filepath ='\0';
+ filepath++;
+
+ while ( *filepath !='\0' && *filepath == ' ' )
+ filepath ++;
+
+ if (filepath == '\0')
+ break;
+
+ //Now add to the mount table
+ dm_result = TreeAddToMountList(uri, filepath);
+ if ( dm_result == SYNCML_DM_SUCCESS)
+ numMountedFiles++;
+ }
+
+ fp.close();
+
+ //If no files are there, bail out.
+ if (numMountedFiles==0)
+ return SYNCML_DM_IO_FAILURE;
+
+ return dm_result;
+}
+#else
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_TreeMount::MountTree( CEnv* env, DMTree* tree )
+{
+ SYNCML_DM_RET_STATUS_T dm_result = SYNCML_DM_SUCCESS;
+
+ UINT8 * pBuffer;
+ UINT32 size;
+ char * line;
+
+ pBuffer = (UINT8*)XPL_DM_GetFstab(&size);
+
+ if ( !pBuffer )
+ return SYNCML_DM_FAIL;
+
+ DMBufferReader fp(pBuffer,size);
+ INT32 numMountedFiles =0;
+ DMString uri;
+ char * filepath = NULL;
+ while( !fp.iseof() )
+ {
+ line = fp.fgets();
+
+ filepath = (char*)DmStrchr(line,' ');
+
+ if ( filepath == NULL)
+ break;
+
+ uri.assign(line,filepath-line);
+ filepath++;
+
+ while ( *filepath !='\0' && *filepath ==' ' )
+ filepath++;
+
+ dm_result = TreeAddToMountList(uri, filepath);
+ if ( dm_result == SYNCML_DM_SUCCESS)
+ numMountedFiles++;
+ }
+
+ //If no files are there, bail out.
+ if (numMountedFiles==0)
+ return SYNCML_DM_IO_FAILURE;
+
+ return dm_result;
+}
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmACLItem.cc b/engine/dmlib/dmengine/dm_ua/src/dmACLItem.cc
new file mode 100644
index 0000000..7f31420
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmACLItem.cc
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmACLItem.cc
+
+ General Description: Implementation of the dmACLItem class
+
+==================================================================================================*/
+
+#include "dm_uri_utils.h"
+#include "dm_tree_class.H"
+#include "xpl_Logger.h"
+#include "dmACLItem.h"
+
+DMAclItem::DMAclItem(CPCHAR szPath, CPCHAR szAcl ) : DmtAcl(szAcl), DMConfigItem(szPath)
+{
+}
+
+SYNCML_DM_RET_STATUS_T
+DMAclItem::ParsePermission(CPCHAR szKeyWord, SYNCML_DM_ACL_PERMISSIONS_T * pPermission)
+{
+ if ( pPermission == NULL )
+ return SYNCML_DM_FAIL;
+
+ if ( DmStrcmp(szKeyWord,"A") == 0 )
+ *pPermission = ADD;
+ else if ( DmStrcmp(szKeyWord,"D") ==0 )
+ *pPermission = DELETE;
+ else if ( DmStrcmp(szKeyWord,"E") == 0 )
+ *pPermission = EXEC;
+ else if ( DmStrcmp(szKeyWord,"G") == 0 )
+ *pPermission = GET;
+ else if ( DmStrcmp(szKeyWord,"R") == 0 )
+ *pPermission = REPLACE;
+ else
+ {
+ XPL_LOG_DM_TMN_Error(("ACL file format error - unknown command %s\n \n", szKeyWord));
+ return SYNCML_DM_FAIL;
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMAclItem::ParseSegment(CPCHAR szSegment,
+ const DMMap<INT32, DMString>& aDict)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ DMParser oParser(szSegment,'=');
+ CPCHAR pKeyWord = oParser.nextSegment();
+ CPCHAR pValue = oParser.nextSegment();
+
+ if ( pKeyWord == NULL || pValue == NULL )
+ return SYNCML_DM_FAIL;
+
+ SYNCML_DM_ACL_PERMISSIONS_T nPermission = 0;
+
+ dm_stat = ParsePermission(pKeyWord,&nPermission);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ return ParsePrincipal(pValue,nPermission,aDict);
+
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMAclItem::ParsePrincipal(CPCHAR szSegment,
+ SYNCML_DM_ACL_PERMISSIONS_T nPermission,
+ const DMMap<INT32, DMString>& aDict )
+{
+ DMToken oParser(FALSE,szSegment,'+');
+ CPCHAR pSegment = NULL;
+
+ while ( (pSegment = oParser.nextSegment()) != NULL )
+ {
+ DMString strPrincipal;
+ if ( aDict.lookup(DmAtoi(pSegment), strPrincipal) )
+ {
+ AddPermission( DmtPrincipal( strPrincipal ), nPermission );
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Error(("ACL file format error - unknown id %s\n \n", pSegment));
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMAclItem::Set(CPCHAR szPath,
+ CPCHAR szConfig,
+ const DMMap<INT32, DMString>& aDict )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ dm_stat = DMConfigItem::Set(szPath);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DMToken oParser(FALSE,szConfig,'&');
+ CPCHAR pCommand = NULL;
+
+ while ( (pCommand = oParser.nextSegment()) != NULL )
+ {
+ dm_stat = ParseSegment(pCommand,aDict);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+void DMAclItem::UpdateDictionary( DMMap<DMString, INT32>& aDict )
+{
+ DMVector<DmtPrincipal> aPrincipals;
+ INT32 iDummy = 0;
+
+ GetPrincipals( aPrincipals );
+
+ for ( INT32 i = 0; i < aPrincipals.size(); i++ ){
+ if ( !aDict.lookup( aPrincipals[i].getName(), iDummy ) ){
+ aDict.put( aPrincipals[i].getName(), aDict.size() + 1);
+ }
+ }
+}
+
+SYNCML_DM_RET_STATUS_T
+DMAclItem::Serialize( DMFileHandler& dmf,
+ const DMMap<DMString, INT32>& aDict )
+{
+
+ DMVector<DmtPrincipal> aPrincipals;
+ GetPrincipals( aPrincipals );
+
+ DMStringVector strCmdPerm;
+ SYNCML_DM_ACL_PERMISSIONS_T nPermissions[5] = {ADD, DELETE, GET, EXEC, REPLACE};
+ CPCHAR szCmds[5] = {"A=", "D=", "G=", "E=", "R="};
+
+ DMString str = "";
+ DMString strProperty = "";
+
+ SYNCML_DM_RET_STATUS_T dm_stat =SYNCML_DM_SUCCESS;
+ dm_stat = DMConfigItem::Serialize(dmf);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ for ( UINT32 nPerm = 0; nPerm < DIM(nPermissions); nPerm++ )
+ {
+ DMVector<DmtPrincipal> aSelectedPrincipals;
+ for ( INT32 i = 0; i < aPrincipals.size(); i++ )
+ {
+ if ( IsPermitted(aPrincipals[i], nPermissions[nPerm]) )
+ aSelectedPrincipals.push_back(aPrincipals[i]);
+ }
+ if ( aSelectedPrincipals.size() )
+ {
+ CreateProperty(aSelectedPrincipals, szCmds[nPerm], aDict, strProperty);
+ AttachProperty(str, '&', strProperty);
+ }
+ }
+
+ if ( str.empty() )
+ return SYNCML_DM_SUCCESS;
+
+ if (dmf.write(str.c_str(), str.length()) != SYNCML_DM_SUCCESS ||
+ dmf.write("\n", 1) != SYNCML_DM_SUCCESS) {
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmACLManager.cc b/engine/dmlib/dmengine/dm_ua/src/dmACLManager.cc
new file mode 100644
index 0000000..e42b6c2
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmACLManager.cc
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmACLManager.cc
+
+ General Description: Implementation of the DMAclManager class
+
+==================================================================================================*/
+
+#include "dm_uri_utils.h"
+#include "dm_tree_class.H"
+#include "xpl_Logger.h"
+#include "dmACLManager.h"
+
+SYNCML_DM_RET_STATUS_T
+DMAclManager::Init(CEnv* env,
+ DMTree* tree)
+{
+ return DMConfigManager::Init(env,tree,SYNCML_DM_FILE_ACL);
+}
+
+void DMAclManager::GetFileName(DMString & strFileName)
+{
+ m_pEnv->GetWFSFullPath(DM_DEFAULT_ACL_FILENAME,strFileName);
+}
+
+
+DMConfigItem * DMAclManager::AllocateConfigItem()
+{
+ return (new DMAclItem());
+
+}
+
+
+
+
+BOOLEAN
+DMAclManager::IsPermitted( CPCHAR szPath,
+ CPCHAR szServerID,
+ SYNCML_DM_ACL_PERMISSIONS_T nPermissions ) const
+{
+ DMURI oURI(FALSE,szPath);
+ CPCHAR pParent = szPath;
+
+ if ( !m_aConfig.size() )
+ return TRUE;
+
+ do
+ {
+ PDMConfigItem pItem;
+ if ( Find(pParent,pItem) != -1 )
+ {
+ if ( ((DMAclItem*)(pItem.GetPtr()))->IsPermitted( "*", nPermissions ) ||
+ ((DMAclItem*)(pItem.GetPtr()))->IsPermitted( szServerID, nPermissions ) )
+ return TRUE;
+ XPL_LOG_DM_TMN_Debug(("DMAclManager::IsPermitted(,,): check permission failed... \n"));
+ return FALSE;
+ }
+ } while ( (pParent = oURI.getParentURI()) != NULL ) ;
+
+ XPL_LOG_DM_TMN_Debug(("DMAclManager::IsPermitted(,,): check . node, permission not allowed \n"));
+ return FALSE; // not . node
+}
+
+BOOLEAN
+DMAclManager::IsPermitted( CPCHAR szPath,
+ CPCHAR szServerID,
+ SYNCML_DM_ACL_PERMISSIONS_T nPermissions,
+ BOOLEAN bIsCheckLocal )
+{
+
+ DMMetaDataManager & m_oMDFObj = m_pTree->GetMetaDataManager();
+
+ if ( bIsCheckLocal && m_oMDFObj.IsLocal(szPath) )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMAclManager::IsPermitted(,,,): check local but path is not local\n"));
+ return FALSE;
+ }
+
+ // Deserialize() make expensive XPL_FS_GetModTime call
+ // we just trying to minimize them
+ if (!m_bLoaded)
+ Deserialize();
+
+ if ( IsPermitted(szPath, szServerID, nPermissions) == FALSE )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMAclManager::IsPermitted(,,,): permission for node %s is not granted to the server %s\n", szPath,szServerID));
+ return FALSE;
+ }
+
+ DMString szMDF;
+ m_oMDFObj.GetPath(szPath, szMDF);
+
+ if (szMDF != szPath )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMAclManager::IsPermitted(,,,): permission mdf check, szMDF:%s, szPath:%s",szMDF.c_str(), szPath));
+ return IsPermitted(szMDF, szServerID, nPermissions);
+ }
+
+ return TRUE;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMAclManager::SetACL( CPCHAR szPath, CPCHAR szACL )
+{
+
+ CheckLocking();
+ Delete(szPath);
+
+ DMAclItem *pItem = new DMAclItem(szPath, szACL);
+ if ( pItem == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ m_aConfig.push_back(PDMConfigItem(pItem));
+ m_bChanged = true;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMAclManager::GetACL(CPCHAR szPath,
+ DMString& strACL)
+{
+ strACL = NULL;
+
+ PDMConfigItem pItem;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ // Deserialize() make expensive XPL_FS_GetModTime call
+ // we just trying to minimize them
+ if (!m_bLoaded)
+ Deserialize();
+
+ dm_stat = Get(szPath,pItem);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ strACL = ((DMAclItem*)(pItem.GetPtr()))->toString();
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmConfigItem.cc b/engine/dmlib/dmengine/dm_ua/src/dmConfigItem.cc
new file mode 100644
index 0000000..576434d
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmConfigItem.cc
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmConfigItem.cc
+
+ General Description: Implementation of the DMConfigItem class
+
+==================================================================================================*/
+
+#include "dmConfigItem.h"
+#include "dm_uri_utils.h"
+#include "dmdefs.h"
+#include "dmtoken.h"
+
+DMConfigItem::DMConfigItem(CPCHAR szPath)
+{
+ m_strPath = szPath;
+}
+
+void DMConfigItem::AttachProperty( DMString & strConfig, char cDelim, CPCHAR szProperty )
+{
+ if ( !strConfig[0] == 0 )
+ {
+ char s[2] = {cDelim,0};
+ strConfig += s;
+ }
+
+ strConfig += szProperty;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMConfigItem::Serialize( DMFileHandler& dmf)
+{
+ if ( dmf.write( "[", 1 ) != SYNCML_DM_SUCCESS ||
+ dmf.write( m_strPath.c_str(), m_strPath.length())!= SYNCML_DM_SUCCESS ||
+ dmf.write( "]\n", 2 ) != SYNCML_DM_SUCCESS )
+ return SYNCML_DM_IO_FAILURE;
+ return SYNCML_DM_SUCCESS;
+
+}
+
+void DMConfigItem::CreateProperty( const DMVector<DmtPrincipal> aPrincipals,
+ CPCHAR szKey,
+ const DMMap<DMString, INT32>& aDict,
+ DMString & strProperty )
+{
+
+ if ( aPrincipals.size() == 0 )
+ return;
+
+ DMString strPrincipals = "";
+ for (INT32 index=0; index<aPrincipals.size(); index++)
+ {
+ const DmtPrincipal& oPrincipal = aPrincipals[index];
+ INT32 nID = aDict.get(oPrincipal.getName());
+ char szNumBuffer[20] = "";
+ sprintf( szNumBuffer, "%d", nID );
+
+ AttachProperty( strPrincipals, '+', szNumBuffer );
+ }
+
+ strProperty = szKey;
+ strProperty += strPrincipals;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMConfigItem::Set(CPCHAR szPath)
+{
+ if ( szPath == NULL )
+ return SYNCML_DM_FAIL;
+
+ m_strPath = szPath;
+ return SYNCML_DM_SUCCESS;
+
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmConfigManager.cc b/engine/dmlib/dmengine/dm_ua/src/dmConfigManager.cc
new file mode 100644
index 0000000..cd9243b
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmConfigManager.cc
@@ -0,0 +1,516 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmConfigManager.cc
+
+ General Description: Implementation of the DMConfigManager class
+
+==================================================================================================*/
+
+#include "dm_tree_class.H"
+#include "dmConfigManager.h"
+#include "dmLockingHelper.h"
+#include "dm_uri_utils.h"
+#include "xpl_Logger.h"
+
+DMConfigManager::DMConfigManager()
+ : m_pEnv( NULL ),
+ m_pTree( NULL )
+{
+ m_bChanged = FALSE;
+ m_bLoaded = FALSE;
+ m_nLastLoadTimeStamp = 0;
+}
+
+DMConfigManager::~DMConfigManager()
+{
+}
+
+
+
+
+SYNCML_DM_RET_STATUS_T DMConfigManager::Init( CEnv* env,
+ DMTree* tree,
+ SYNCML_DM_FILE_TYPE_T fileType)
+{
+ if( !env || !tree ) return SYNCML_DM_FAIL;
+
+ m_pEnv = env;
+ m_pTree = tree;
+ m_efileType = fileType;
+
+ GetFileName(m_strFileName);
+ if ( !XPL_FS_Exist(m_strFileName) )
+ {
+ DMFileHandler tf(m_strFileName);
+ tf.open(XPL_FS_FILE_WRITE);
+ tf.close();
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMConfigManager::DeInit()
+{
+ m_bChanged = FALSE;
+ m_bLoaded = FALSE;
+ m_nLastLoadTimeStamp = 0;
+ m_strFileName = NULL;
+ m_pEnv = NULL;
+ m_pTree = NULL;
+ ClearMemory();
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMConfigManager::DeserializeDictionary(DMFileHandler& dmf,
+ DMMap<INT32, DMString>& aDict)
+{
+
+ DMString strLineBuffer;
+ char *line = strLineBuffer.AllocateBuffer(DM_MAX_CONFIG_LINE);
+
+ if ( !line )
+ {
+ XPL_LOG_DM_TMN_Error(("Device memory is full"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ while ( GetNextLine(dmf, line) && line[0] )
+ {
+ DMString strID, strSrv = line;
+
+ DmStringParserGetItem( strID, strSrv, ':' );
+ aDict.put( DmAtoi(strID), strSrv );
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T DMConfigManager::Deserialize()
+{
+ // check if we have latest copy in memory already
+ XPL_CLK_CLOCK_T lastLoadTimeStamp = XPL_FS_GetModTime(m_strFileName.c_str());
+ if ( m_bLoaded && lastLoadTimeStamp == m_nLastLoadTimeStamp )
+ return SYNCML_DM_SUCCESS;
+
+ DMGlobalLockHelper oGlobalLock; // protect serialize/recovery from multi process access
+
+ CheckRecovery();
+
+ ClearMemory();
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ DMFileHandler evtFile(m_strFileName);
+
+ if ( evtFile.open(XPL_FS_FILE_READ) != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Error(("Failed to open config file, %s\n", m_strFileName.c_str()));
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ if ( !evtFile.size() )
+ return SYNCML_DM_SUCCESS;
+
+ DMMap<INT32, DMString> aDict;
+ dm_stat = DeserializeDictionary(evtFile, aDict);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DMString strLineBuffer;
+ char *line = strLineBuffer.AllocateBuffer(DM_MAX_CONFIG_LINE);
+ UINT16 lineNo = 0;
+
+ if ( !line )
+ {
+ XPL_LOG_DM_TMN_Error(("Device memory is full"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ while ( GetNextLine(evtFile, line ) )
+ {
+ lineNo++;
+
+ DMString strPath;
+ if ( !GetPath( line, strPath ) )
+ continue;
+
+ // get the value
+ if (!GetNextLine(evtFile, line ))
+ {
+ XPL_LOG_DM_TMN_Error(("config file format error at line %d - unexpected end of file\n \n", lineNo ));
+ dm_stat = SYNCML_DM_IO_FAILURE;
+ break; // end of file
+ }
+
+ dm_stat = Add(strPath, line,aDict);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ break;
+ }
+
+ evtFile.close();
+ m_bChanged = FALSE;
+ m_nLastLoadTimeStamp = lastLoadTimeStamp;
+ m_bLoaded = TRUE;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+BOOLEAN
+DMConfigManager::GetPath( char* line,
+ DMString& strPath )
+{
+ char* startP = DmStrchr( line, '[' );
+ if (!startP)
+ return FALSE;
+
+ char* endP = DmStrchr(line, ']' );
+
+ if ( !endP || endP < startP ) {
+ XPL_LOG_DM_TMN_Error(("config file format error \n %s\n", line));
+ return FALSE;
+ }
+
+ // remove [], add '.' if necessary to create a full uri
+ *endP = 0;
+ startP++;
+
+ if ( *startP != '.' )
+ strPath = ".";
+
+ strPath += startP;
+ return TRUE;
+}
+
+
+void DMConfigManager::CheckRecovery() const
+{
+ DMString strTempFile = m_strFileName;
+ DMString strBakFile = m_strFileName;
+ UINT8 state = 0;
+
+ strTempFile += DMFileHandler::TEMP_FILE_EXTENSION;
+ strBakFile += DMFileHandler::BAK_FILE_EXTENSION;
+
+#define TEMP_EXISTS 1 // .temp file exists state bit
+#define BAK_EXISTS 2 // .bak file exists state bit
+
+ if (XPL_FS_Exist(strTempFile.c_str()))
+ state |= TEMP_EXISTS;
+
+ if (XPL_FS_Exist(strBakFile.c_str()))
+ state |= BAK_EXISTS;
+
+ switch(state) {
+ case (TEMP_EXISTS | BAK_EXISTS): // case C
+ if (XPL_FS_Rename(strBakFile.c_str(), m_strFileName.c_str()) == XPL_FS_RET_FAIL)
+ break;
+ //continue to delete .temp files
+
+ case TEMP_EXISTS: // case B
+ XPL_FS_Remove(strTempFile.c_str());
+ break;
+
+ case BAK_EXISTS: // case D
+ XPL_FS_Remove(strBakFile.c_str());
+ break;
+
+ default: // no action needed
+ break;
+ }
+}
+
+BOOLEAN
+DMConfigManager::GetNextLine(DMFileHandler& dmf,
+ char *line)
+
+{
+
+ line[0]= 0;
+
+ while (!dmf.iseof()) {
+ dmf.fgets(line, DM_MAX_CONFIG_LINE);
+
+ if(*line != '#')
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMConfigManager::Serialize()
+{
+ if ( !m_bChanged )
+ return SYNCML_DM_SUCCESS;
+
+ DMGlobalLockHelper oGlobalLock; // protect serialize/recovery from multi process access
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ DMString strTmpName = m_strFileName;
+ DMString strBakName = m_strFileName;
+
+ strTmpName += DMFileHandler::TEMP_FILE_EXTENSION;
+ strBakName += DMFileHandler::BAK_FILE_EXTENSION;
+
+ DMFileHandler tf(strTmpName.c_str());
+
+ if (tf.open(XPL_FS_FILE_WRITE) != SYNCML_DM_SUCCESS) {
+ XPL_LOG_DM_TMN_Error(("Error opening %s\n", strTmpName.c_str()));
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ if ( !m_aConfig.size() )
+ {
+ if (tf.close() != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ XPL_FS_Rename(m_strFileName.c_str(), strBakName.c_str());
+ XPL_FS_Rename(strTmpName.c_str(), m_strFileName.c_str());
+ XPL_FS_Remove(strBakName.c_str());
+ m_nLastLoadTimeStamp = XPL_FS_GetModTime(m_strFileName.c_str());
+ m_bChanged = FALSE;
+ m_bLoaded = TRUE;
+ return SYNCML_DM_SUCCESS;
+ }
+
+ DMMap<DMString, INT32> aDict;
+ UpdateDictionary(aDict);
+
+ dm_stat = SerializeDictionary(tf,aDict);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ // empty line between dictionary and data
+ if ( tf.write( "\n", 1 ) != SYNCML_DM_SUCCESS )
+ return SYNCML_DM_IO_FAILURE;
+
+ for ( INT32 index=0; index<m_aConfig.size(); index++)
+ {
+
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "PF1") == 0))
+ {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+ PDMConfigItem & oConfigItem = m_aConfig[index];
+ if ( oConfigItem->Serialize( tf, aDict ) != SYNCML_DM_SUCCESS )
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ if (tf.close() != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "PF2") == 0))
+ {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+
+ // rename to .bak file
+ XPL_FS_Rename(m_strFileName.c_str(), strBakName.c_str());
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "PF3") == 0))
+ {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+
+ // rename .temp file to original name
+ XPL_FS_Rename(strTmpName.c_str(), m_strFileName.c_str());
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "PF4") == 0)) {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+
+ // delete .bak file
+ XPL_FS_Remove(strBakName.c_str());
+
+ m_nLastLoadTimeStamp = XPL_FS_GetModTime(m_strFileName.c_str());
+ m_bChanged = FALSE;
+ m_bLoaded = TRUE;
+
+ return SYNCML_DM_SUCCESS ;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMConfigManager::SerializeDictionary( DMFileHandler& dmf,
+ const DMMap<DMString, INT32>& aDict)
+{
+
+ char szNumBuffer[20] = ""; // big enough to hold a number
+ for ( DMMap<DMString, INT32>::POS pos = aDict.begin(); pos < aDict.end(); pos++ )
+ {
+ INT32 nLen = sprintf( szNumBuffer, "%d:", aDict.get_value(pos) );
+ if ( dmf.write( szNumBuffer, nLen ) != SYNCML_DM_SUCCESS ||
+ dmf.write( aDict.get_key(pos).c_str(), aDict.get_key(pos).length()) != SYNCML_DM_SUCCESS ||
+ dmf.write( "\n", 1 ) != SYNCML_DM_SUCCESS )
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T DMConfigManager::Revert()
+{
+ if ( !m_bLoaded || !m_bChanged )
+ return SYNCML_DM_SUCCESS;
+
+ m_bChanged = false;
+ m_bLoaded = false;
+ return Deserialize();
+}
+
+
+void DMConfigManager::CheckLocking()
+{
+ if ( !m_bChanged )
+ {
+ m_pTree->GetLockContextManager().InsureFileLocked(m_efileType);
+ Deserialize();
+ }
+}
+
+
+INT32 DMConfigManager::Find(CPCHAR szPath) const
+{
+ for (INT32 index=0; index<m_aConfig.size(); index ++)
+ {
+ const PDMConfigItem & pItem = m_aConfig[index];
+ if ( pItem->GetPath() == szPath )
+ {
+ return index;
+ }
+ }
+ return -1;
+
+}
+
+
+INT32 DMConfigManager::Find(CPCHAR szPath, PDMConfigItem & oConfigItem) const
+{
+ INT32 index = Find(szPath);
+ if ( index != -1 )
+ oConfigItem = m_aConfig[index];
+ return index;
+
+}
+
+
+void DMConfigManager::ClearMemory()
+{
+ m_aConfig.clear();
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMConfigManager::Add(const DMString & szPath,
+ CPCHAR szConfig,
+ const DMMap<INT32, DMString>& aDict)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if ( Find(szPath) != -1 )
+ return SYNCML_DM_FAIL;
+
+ DMConfigItem * pConfigItem = AllocateConfigItem();
+
+ if ( !pConfigItem )
+ return SYNCML_DM_DEVICE_FULL;
+
+ dm_stat = pConfigItem->Set( szPath, szConfig, aDict );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ delete pConfigItem;
+ return dm_stat;
+ }
+
+ m_aConfig.push_back(PDMConfigItem(pConfigItem));
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+void DMConfigManager::UpdateDictionary(DMMap<DMString, INT32>& aDict)
+{
+
+ for (INT32 index=0; index<m_aConfig.size(); index++)
+ {
+ PDMConfigItem & pConfigItem = m_aConfig[index];
+ pConfigItem->UpdateDictionary( aDict );
+ }
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMConfigManager::Delete(CPCHAR szPath)
+{
+ INT32 index = Find(szPath);
+ if ( index == -1 )
+ return SYNCML_DM_NOT_FOUND;
+
+ CheckLocking();
+ m_aConfig.remove(index);
+ m_bChanged = true;
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMConfigManager::Get(CPCHAR szPath,
+ PDMConfigItem & pItem) const
+{
+
+ if ( Find(szPath, pItem) == -1 )
+ {
+ DMString szMDF;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ DMMetaDataManager & m_oMDFObj = m_pTree->GetMetaDataManager();
+ dm_stat = m_oMDFObj.GetPath(szPath, szMDF);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if ( szMDF != szPath )
+ {
+ if ( Find(szMDF, pItem) == -1 )
+ return SYNCML_DM_NOT_FOUND;
+ }
+ else
+ return SYNCML_DM_NOT_FOUND;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmConstraints.cc b/engine/dmlib/dmengine/dm_ua/src/dmConstraints.cc
new file mode 100644
index 0000000..4330a5e
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmConstraints.cc
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmConstraints.cc
+
+ General Description: Implementation of the DMConstraints class
+
+==================================================================================================*/
+
+#include <limits.h>
+#include "dm_uri_utils.h"
+#include "dmStringUtil.h"
+#include "dmConstraints.h"
+
+DMConstraints::DMConstraints()
+{
+ Init();
+}
+
+
+DMConstraints::~DMConstraints()
+{
+}
+
+void DMConstraints::Init()
+{
+ m_nMax = INT_MAX;
+ m_nMin = INT_MIN;
+ m_nMaxLen = SHRT_MAX;
+ m_nMinLen = 0;
+ m_nnMaxLen = 255;
+ m_nMaxRecurrance = 0xffff;
+ m_nMaxMultiNodes = 0;
+
+ m_psValues = NULL;
+ m_nNodeType = SYNCML_DM_FORMAT_NULL;
+ m_psRegexp = NULL;
+ m_psAutoNodes = NULL;
+ m_psRecurAfterSegment = NULL;
+ m_psForeignKey = NULL;
+ m_psChild = NULL;
+ m_psDepend = NULL;
+
+ m_psnValues = NULL;
+ m_psnRegexp = NULL;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMConstraints::ReadDefaultValue(DMMetaDataBuffer * pBuffer,
+ INT32 nNodeType)
+{
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ switch( nNodeType )
+ {
+ case SYNCML_DM_FORMAT_BOOL:
+ m_nDef_Value = pBuffer->ReadUINT8();
+ break;
+
+ case SYNCML_DM_FORMAT_CHR:
+ m_psDef_Value = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_FORMAT_INT:
+ m_nDef_Value = pBuffer->ReadUINT32();
+ break;
+
+ case SYNCML_DM_FORMAT_FLOAT:
+ m_fDef_Value = pBuffer->ReadFLOAT();
+ break;
+
+ case SYNCML_DM_FORMAT_DATE:
+ m_psDef_Value = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_FORMAT_TIME:
+ m_psDef_Value = pBuffer->ReadString();
+ break;
+ }
+ return ret_status;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMConstraints::Read(DMMetaDataBuffer * pBuffer,
+ UINT8 count,
+ INT32 nNodeType)
+{
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+ UINT8 type;
+
+ Init();
+ for (int i=0; i<count; i++)
+ {
+ type = pBuffer->ReadUINT8();
+ switch ( type )
+ {
+ case SYNCML_DM_DDF_MIN:
+ m_nMin = pBuffer->ReadUINT32();
+ break;
+
+ case SYNCML_DM_DDF_MAX:
+ m_nMax = pBuffer->ReadUINT32();
+ break;
+
+ case SYNCML_DM_DDF_VALUES:
+ m_psValues = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_DDF_DEFAULTVALUE:
+ ret_status = ReadDefaultValue(pBuffer,nNodeType);
+ m_nNodeType = nNodeType;
+ break;
+
+ case SYNCML_DM_DDF_MAXLEN:
+ m_nMaxLen = pBuffer->ReadUINT16();
+ break;
+
+ case SYNCML_DM_DDF_MINLEN:
+ m_nMinLen = pBuffer->ReadUINT16();
+ break;
+
+ case SYNCML_DM_DDF_REGEXP:
+ m_psRegexp = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_DDF_NMAXLEN:
+ m_nnMaxLen = pBuffer->ReadUINT16();
+ break;
+
+ case SYNCML_DM_DDF_NVALUES:
+ m_psnValues = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_DDF_NREGEXP:
+ m_psnRegexp = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_DDF_AUTONODE:
+ m_psAutoNodes = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_DDF_RECUR_AFTER_SEGMENT:
+ m_psRecurAfterSegment = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_DDF_MAX_RECURRANCE:
+ m_nMaxRecurrance = pBuffer->ReadUINT16();
+ break;
+
+ case SYNCML_DM_DDF_FK:
+ m_psForeignKey = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_DDF_CHILD:
+ m_psChild = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_DDF_DEPEND:
+ m_psDepend = pBuffer->ReadString();
+ break;
+
+ case SYNCML_DM_DDF_MAX_MULTINODES:
+ m_nMaxMultiNodes = pBuffer->ReadUINT16();
+ break;
+
+ }
+
+
+ }
+ return ret_status;
+
+}
+
+void DMConstraints::GetDefaultString( DMString& strValue )const
+{
+ char s[MAX_FLOAT_STRING_LENGTH] = "";
+
+ switch ( m_nNodeType )
+ {
+ case SYNCML_DM_FORMAT_INT:
+ DmSprintf(s, "%d", m_nDef_Value );
+ break;
+
+ case SYNCML_DM_FORMAT_BOOL:
+ strValue = m_nDef_Value ? "true" : "false";
+ return;
+
+ case SYNCML_DM_FORMAT_CHR:
+ strValue = m_psDef_Value;
+ return;
+
+ case SYNCML_DM_FORMAT_FLOAT:
+ DmSprintf(s, "%+e", m_fDef_Value );
+ break;
+
+ case SYNCML_DM_FORMAT_DATE:
+ strValue = m_psDef_Value;
+ return;
+
+ case SYNCML_DM_FORMAT_TIME:
+ strValue = m_psDef_Value;
+ return;
+
+ }
+
+ strValue = s;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmEvent.cc b/engine/dmlib/dmengine/dm_ua/src/dmEvent.cc
new file mode 100644
index 0000000..b7a72c1
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmEvent.cc
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmEvent.cc
+
+ General Description: Implementation of the DMEventPath and DMEventData classes
+
+==================================================================================================*/
+
+#include "dmEvent.h"
+
+DMEventPath::DMEventPath(CPCHAR szPath)
+{
+ m_strPath = szPath;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMEventPath::Serialize(DMBufferWriter & oBuffer)
+{
+ return oBuffer.WriteString(m_strPath);
+}
+
+UINT32 DMEventPath::GetSize()
+{
+ return m_strPath.length()+1;
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMEventPath::Deserialize(DMBufferReader & oBuffer)
+{
+ m_strPath = oBuffer.ReadString();
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+DMEventData::DMEventData(BOOLEAN bIsLeaf,
+ SYNCML_DM_EVENT_ACTION_T eAction,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR strName,
+ CPCHAR strNewName)
+{
+ m_bIsLeaf = bIsLeaf;
+ m_eAction = eAction;
+ m_strName = strName;
+ m_strNewName = strNewName;
+ m_bIsEnabledByParent = bIsEnabledByParent;
+
+}
+
+void
+DMEventData::AddAction(SYNCML_DM_EVENT_ACTION_T eAction)
+{
+ m_eAction |= eAction;
+}
+
+
+void
+DMEventData::RemoveAction(SYNCML_DM_EVENT_ACTION_T eAction)
+{
+ m_eAction &= ~eAction;
+}
+
+
+
+void
+DMEventData::SetLeaf(BOOLEAN bIsLeaf)
+{
+ m_bIsLeaf = bIsLeaf;
+}
+
+
+void
+DMEventData::SetEnabledByParent(BOOLEAN bIsEnabledByParent)
+{
+ m_bIsEnabledByParent = bIsEnabledByParent;
+}
+
+void
+DMEventData::SetAction(SYNCML_DM_EVENT_ACTION_T eAction)
+{
+ m_eAction = eAction;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventData::SetName(CPCHAR strName)
+{
+ m_strName = strName;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventData::SetNewName(CPCHAR strNewName)
+{
+ m_strNewName = strNewName;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventData::Serialize(DMBufferWriter & oBuffer)
+{
+
+ oBuffer.WriteUINT8(m_eAction);
+ oBuffer.WriteUINT8(m_bIsLeaf);
+
+ oBuffer.WriteString(m_strName);
+
+ if ( (m_eAction & SYNCML_DM_EVENT_RENAME) == SYNCML_DM_EVENT_RENAME )
+ {
+ oBuffer.WriteString(m_strNewName);
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+UINT32 DMEventData::GetSize()
+{
+ UINT32 size = sizeof(UINT8)*2;
+ size += m_strName.length() + 1;
+ if ( (m_eAction & SYNCML_DM_EVENT_RENAME) == SYNCML_DM_EVENT_RENAME)
+ {
+ size += m_strNewName.length() + 1;
+ }
+ return size;
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMEventData::Deserialize(DMBufferReader & oBuffer)
+{
+ m_eAction = oBuffer.ReadUINT8();
+ m_bIsLeaf = (BOOLEAN)oBuffer.ReadUINT8();
+ m_strName = oBuffer.ReadString();
+ if ( (m_eAction & SYNCML_DM_EVENT_RENAME) == SYNCML_DM_EVENT_RENAME)
+ {
+ m_strNewName = oBuffer.ReadString();
+ }
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmEventLogger.cc b/engine/dmlib/dmengine/dm_ua/src/dmEventLogger.cc
new file mode 100644
index 0000000..71b9b68
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmEventLogger.cc
@@ -0,0 +1,1055 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmEventLogger.cc
+
+ General Description: Implementation of the DMEventLogger class
+
+==================================================================================================*/
+
+#include "dmEventLogger.h"
+#include "dm_uri_utils.h"
+#include "dmtoken.h"
+#include "xpl_dm_Notifications.h"
+#include "dmPluginManager.h"
+#include "dm_tree_class.H"
+#include "dmEvent.h"
+#include "xpl_Logger.h"
+
+DMEventLogger::DMEventLogger()
+{
+ m_pTree = NULL;
+}
+
+
+DMEventLogger::~DMEventLogger()
+{
+}
+
+SYNCML_DM_RET_STATUS_T DMEventLogger::Init( DMTree* tree )
+{
+ if( !tree ) return SYNCML_DM_FAIL;
+
+ m_pTree = tree;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+PDmtEventData
+DMEventLogger::Find(const DmtEventDataVector & aVector,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ BOOLEAN bIsCumulative,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szName,
+ CPCHAR szNewName)
+{
+
+ if ( bIsCumulative )
+ {
+ // no need to search if new node added in it is tracked by node itself
+ if ( nAction == SYNCML_DM_EVENT_ADD && !bIsEnabledByParent )
+ return NULL;
+ }
+ else
+ {
+ if ( nAction != SYNCML_DM_EVENT_INDIRECT && nAction != SYNCML_DM_EVENT_REPLACE )
+ return NULL;
+ }
+
+ for (INT32 index=aVector.size()-1; index>=0; index--)
+ {
+ PDmtEventData & pEventData = (PDmtEventData&)(aVector[index]);
+ if ( pEventData->GetName() == szName || pEventData->GetNewName() == szName )
+ {
+ return pEventData;
+ }
+ }
+ return NULL;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::AddEvent(PDmtEventData & pEventData,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ ((DMEventData*)pEventData.GetPtr())->AddAction(nAction);
+ if ( nAction == SYNCML_DM_EVENT_RENAME && szNewName )
+ {
+ dm_stat = ((DMEventData*)pEventData.GetPtr())->SetNewName(szNewName);
+ }
+
+ XPL_LOG_DM_TMN_Debug(("New action is added to logger, name = %s\n", (pEventData->GetName().c_str())));
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::AddEvent(DmtEventDataVector & aVector,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ BOOLEAN bIsLeaf,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szName,
+ CPCHAR szNewName)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ DMEventData* pDataPtr = NULL;
+
+ pDataPtr = new DMEventData();
+ if ( pDataPtr == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ pDataPtr->SetAction(nAction);
+ pDataPtr->SetLeaf(bIsLeaf);
+ pDataPtr->SetEnabledByParent(bIsEnabledByParent);
+
+ dm_stat = pDataPtr->SetName(szName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ delete pDataPtr;
+ return dm_stat;
+ }
+
+ if ( nAction == SYNCML_DM_EVENT_RENAME && szNewName )
+ {
+ dm_stat = pDataPtr->SetNewName(szNewName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ delete pDataPtr;
+ return dm_stat;
+ }
+ }
+
+ aVector.push_back(PDmtEventData(pDataPtr));
+ XPL_LOG_DM_TMN_Debug(("New event is added to logger, name = %s\n", szName));
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+BOOLEAN
+DMEventLogger::Find(CPCHAR szPath,
+ const DMEventMap & aEventMap,
+ PDMEventPath & pEventPath,
+ DmtEventDataVector & aVector)
+{
+
+ for ( DmtEventMap::POS nPos = 0; nPos < aEventMap.end(); nPos++ )
+ {
+ pEventPath = aEventMap.get_key(nPos);
+ if ( pEventPath ->GetPath() == szPath )
+ {
+ aVector = aEventMap.get_value(nPos);
+ return TRUE;
+ break;
+ }
+ }
+ return FALSE;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::OnNodeChanged(CPCHAR szPath ,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ DMEventMap & aEventMap,
+ BOOLEAN bIsCumulative,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szNewName )
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ DMURI oURI(FALSE, szPath);
+
+ CPCHAR pParent = oURI.getParentURI();
+ CPCHAR pNode = oURI.getTailSegments();
+
+ DmtEventDataVector aVector;
+ PDMEventPath pEventPath;
+ BOOLEAN bFound = Find(pParent,aEventMap, pEventPath,aVector);
+
+ if ( bFound == FALSE )
+ {
+ pEventPath = PDMEventPath(new DMEventPath(pParent));
+
+ if ( pEventPath == NULL )
+ {
+ XPL_LOG_DM_TMN_Error(("Memory allocation error \n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+
+ PDmtEventData pEventData = NULL;
+ pEventData = Find(aVector,nAction, bIsCumulative,bIsEnabledByParent,pNode,szNewName);
+
+ if ( pEventData != NULL )
+ {
+ dm_stat = AddEvent(pEventData, nAction, szNewName);
+ }
+ else
+ {
+ BOOLEAN bIsLeaf = FALSE;
+
+ if ( nAction == SYNCML_DM_EVENT_REPLACE )
+ bIsLeaf = TRUE;
+ else
+ {
+ DMMetaDataManager & m_oMDFObj = m_pTree->GetMetaDataManager();
+ bIsLeaf = m_oMDFObj.IsLeaf(szPath);
+ }
+ dm_stat = AddEvent(aVector, nAction, bIsLeaf, bIsEnabledByParent, pNode, szNewName);
+ }
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Error(("Cannot add new event, dm_stat = %d\n", dm_stat));
+ return dm_stat;
+ }
+
+ aEventMap.put( pEventPath , aVector );
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::OnNodeChanged(CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ const PDMPlugin & pPlugin,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szNewName )
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ BOOLEAN bIsCumulative = FALSE;
+
+ DMEventMap aEventMap;
+
+ XPL_LOG_DM_TMN_Debug(("OnNodeChanged called for commit plug-in %s\n", szPath));
+ m_aPluginEvents.lookup(pPlugin,aEventMap);
+
+ if ( pPlugin->GetType() == SYNCML_DM_EVENT_CUMULATIVE )
+ bIsCumulative = TRUE;
+
+ dm_stat = OnNodeChanged(szPath,nAction,aEventMap,bIsCumulative,bIsEnabledByParent,szNewName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ m_aPluginEvents.put(pPlugin,aEventMap);
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::OnNodeChanged(CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ const PDMConfigItem & pItem,
+ BOOLEAN bIsEnabledByParent,
+ CPCHAR szNewName )
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ BOOLEAN bIsCumulative = FALSE;
+
+ DMEventMap aEventMap;
+ XPL_LOG_DM_TMN_Debug(("OnNodeChanged called for ES %s\n", szPath));
+ m_aPostEvents.lookup(pItem,aEventMap);
+
+ if ( ((DMSubscriptionItem*)(pItem.GetPtr()))->GetType() == SYNCML_DM_EVENT_CUMULATIVE )
+ bIsCumulative = TRUE;
+
+ dm_stat = OnNodeChanged(szPath,nAction,aEventMap,bIsCumulative,bIsEnabledByParent,szNewName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ m_aPostEvents.put(pItem,aEventMap);
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+UINT32 DMEventLogger::GetSize(const DMEventMap & aEventMap)
+{
+ UINT32 size = sizeof(UINT32) * 2;
+
+ for ( DMEventMap::POS nPos = 0; nPos < aEventMap.end(); nPos++ )
+ {
+ const PDMEventPath & pPath = aEventMap.get_key(nPos);
+ const DmtEventDataVector & aVector = aEventMap.get_value(nPos);
+
+ size += pPath->GetSize();
+ size += sizeof(UINT32);
+ for (INT32 index=0; index<aVector.size(); index++)
+ {
+ const PDmtEventData & pData = aVector[index];
+ DMEventData * pDataPtr = (DMEventData*)pData.GetPtr();
+ size += pDataPtr->GetSize();
+ }
+ }
+
+ return size;
+}
+
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::Serialize(const DmtEventDataVector & aVector,
+ DMBufferWriter & oBuffer)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ oBuffer.WriteUINT32(aVector.size());
+
+ for (INT32 index=0; index<aVector.size(); index++)
+ {
+ const PDmtEventData & pData = aVector[index];
+ dm_stat = ((DMEventData*)(pData.GetPtr()))->Serialize(oBuffer);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::Serialize(const DMEventMap & aEventMap,
+ DMBufferWriter & oBuffer)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ INT32 size = GetSize(aEventMap);
+ dm_stat = oBuffer.Allocate(size);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ oBuffer.WriteUINT32(size);
+
+ oBuffer.WriteUINT32(aEventMap.end());
+
+ for ( DMEventMap::POS nPos = 0; nPos < aEventMap.end(); nPos++ )
+ {
+ const PDMEventPath & pPath = aEventMap.get_key(nPos);
+ const DmtEventDataVector & aVector = aEventMap.get_value(nPos);
+
+ dm_stat = pPath->Serialize(oBuffer);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = Serialize(aVector,oBuffer);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::Deserialize(DMBufferReader & oBuffer,
+ DMString & strParent,
+ PDmtEventData & aData)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ UINT32 size = oBuffer.ReadUINT32();
+ if ( size != oBuffer.GetSize() )
+ return SYNCML_DM_FAIL;
+
+ INT32 nPathsCount = (INT32)oBuffer.ReadUINT32();
+ if ( nPathsCount != 1 )
+ return SYNCML_DM_FAIL;
+
+ DMEventPath oPath;
+ dm_stat = oPath.Deserialize(oBuffer);
+
+ strParent = oPath.GetPath();
+
+ INT32 nNodesCount = (INT32)oBuffer.ReadUINT32();
+ if ( nNodesCount != 1 )
+ return SYNCML_DM_FAIL;
+
+ DMEventData * pDataPtr = new DMEventData();
+ if ( pDataPtr == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ dm_stat = pDataPtr->Deserialize(oBuffer);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ delete pDataPtr;
+ return dm_stat;
+ }
+
+ aData = PDmtEventData(pDataPtr);
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::Deserialize(DMBufferReader & oBuffer,
+ DmtEventDataVector & aVector)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ INT32 nNodesCount = (INT32)oBuffer.ReadUINT32();
+ if ( nNodesCount == 0 )
+ return SYNCML_DM_FAIL;
+
+ for (INT32 index =0; index<nNodesCount; index++)
+ {
+ DMEventData * pDataPtr = new DMEventData();
+ if ( pDataPtr == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ dm_stat = pDataPtr->Deserialize(oBuffer);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ delete pDataPtr;
+ return dm_stat;
+ }
+ aVector.push_back(PDmtEventData(pDataPtr));
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::Deserialize(DMBufferReader & oBuffer,
+ DmtEventMap & aEventMap)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ UINT32 size = oBuffer.ReadUINT32();
+ if ( size != oBuffer.GetSize() )
+ return SYNCML_DM_FAIL;
+
+ INT32 nPathsCount = (INT32)oBuffer.ReadUINT32();
+ if ( nPathsCount == 0 )
+ return SYNCML_DM_FAIL;
+
+ for (INT32 index = 0; index<nPathsCount; index++)
+ {
+ DMEventPath oPath;
+ dm_stat = oPath.Deserialize(oBuffer);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DmtEventDataVector aVector;
+
+ dm_stat = Deserialize(oBuffer,aVector);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ aEventMap.put(oPath.GetPath(), aVector);
+
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+void DMEventLogger::OnTreeSaved()
+{
+
+ for ( DMPostEventMap::POS nPos = 0; nPos < m_aPostEvents.end(); nPos++ )
+ {
+ const PDMConfigItem & pItem = m_aPostEvents.get_key(nPos);
+ const DMEventMap & aEventMap = m_aPostEvents.get_value(nPos);
+ SYNCML_DM_EVENT_TYPE_T nType = ((DMSubscriptionItem*)(pItem.GetPtr()))->GetType();
+ DMString strTopic = ((DMSubscriptionItem*)(pItem.GetPtr()))->GetTopic();
+
+ DMBufferWriter oBuffer;
+ if ( Serialize(aEventMap,oBuffer) == SYNCML_DM_SUCCESS )
+ {
+ if ( strTopic == NULL )
+ {
+ strTopic = pItem->GetPath();
+ XPL_LOG_DM_TMN_Debug(("Sending event for %s\n", strTopic.c_str()));
+ XPL_DM_NotifyTreeUpdate(strTopic, NULL, nType, oBuffer.GetBuffer(), oBuffer.GetSize());
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Debug(("Sending event for %s\n", strTopic.c_str()));
+ XPL_DM_NotifyTreeUpdate(strTopic, pItem->GetPath(), nType, oBuffer.GetBuffer(), oBuffer.GetSize());
+ }
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Error(("Event Serialization failed\n"));
+ }
+ }
+
+ Reset();
+}
+
+void DMEventLogger::Reset()
+{
+ m_aPostEvents.clear();
+ m_aPluginEvents.clear();
+}
+
+void DMEventLogger::GetCommitPluginEvents(const PDMPlugin & pPlugin,
+ DmtEventMap & aUpdatedNodes ) const
+{
+ DMEventMap aStoredMap;
+
+ m_aPluginEvents.lookup(pPlugin,aStoredMap);
+ for ( DmtEventMap::POS nPos = 0; nPos < aStoredMap.end(); nPos++ )
+ {
+ const PDMEventPath & pPath = aStoredMap.get_key(nPos);
+ const DmtEventDataVector & aVector = aStoredMap.get_value(nPos);
+ aUpdatedNodes.put(pPath->GetPath(),aVector);
+ }
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::CleanEvents(DmtEventDataVector & aVector)
+{
+
+ for ( INT32 index = aVector.size()-1; index >= 0; index-- )
+ {
+ const PDmtEventData & pData = aVector[index];
+ if ( ((DMEventData*)(pData.GetPtr()))->IsEnabledByParent() )
+ aVector.remove(index);
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::CleanEvents(DMEventMap & aEventMap, CPCHAR szPath)
+{
+
+ for ( DMEventMap::POS nPos = aEventMap.end()-1; nPos >= 0; nPos-- )
+ {
+ const PDMEventPath & pPath = aEventMap.get_key(nPos);
+
+ BOOLEAN bIsParent = DmIsParentURI(szPath,pPath->GetPath());
+ if ( !bIsParent && !DmIsParentURI(pPath->GetPath(),szPath) )
+ {
+ continue;
+ }
+
+ if ( bIsParent )
+ {
+ DmtEventDataVector & aVector = aEventMap.get_value(nPos);
+ CleanEvents(aVector);
+ if ( !aVector.size() )
+ aEventMap.remove(pPath);
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::CleanConfigEvents(CPCHAR szPath)
+{
+
+ for ( DMPostEventMap::POS nPos = m_aPostEvents.end()-1; nPos >= 0; nPos-- )
+ {
+ const PDMConfigItem & pConfigItem = m_aPostEvents.get_key(nPos);
+
+ if ( !DmIsParentURI(szPath,pConfigItem->GetPath()) &&
+ !DmIsParentURI(pConfigItem->GetPath(),szPath) )
+ {
+ continue;
+ }
+
+ DMParser oStored(pConfigItem->GetPath());
+ DMParser oRemoved(szPath);
+
+ if ( oRemoved.getSegmentsCount() < oStored.getSegmentsCount() )
+ {
+ m_aPostEvents.remove(pConfigItem);
+ continue;
+ }
+
+ DMEventMap & aEventMap = m_aPostEvents.get_value(nPos);
+ CleanEvents(aEventMap,szPath);
+ if ( !aEventMap.size() )
+ m_aPostEvents.remove(pConfigItem);
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::CleanPluginEvents(CPCHAR szPath)
+{
+
+ for ( DMPostEventMap::POS nPos = m_aPluginEvents.end()-1; nPos >= 0; nPos-- )
+ {
+ const PDMPlugin & pPlugin = m_aPluginEvents.get_key(nPos);
+
+ if ( !DmIsParentURI(szPath,pPlugin->GetPath()) &&
+ !DmIsParentURI(pPlugin->GetPath(),szPath) )
+ {
+ continue;
+ }
+
+ DMParser oStored(pPlugin->GetPath());
+ DMParser oRemoved(szPath);
+
+ if ( oRemoved.getSegmentsCount() < oStored.getSegmentsCount() )
+ {
+ m_aPluginEvents.remove(pPlugin);
+ continue;
+ }
+
+ DMEventMap & aEventMap = m_aPluginEvents.get_value(nPos);
+ CleanEvents(aEventMap,szPath);
+ if ( !aEventMap.size() )
+ m_aPluginEvents.remove(pPlugin);
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::CleanEvents(CPCHAR szPath)
+{
+ XPL_LOG_DM_TMN_Debug(("Clean events for %s\n", szPath));
+ CleanConfigEvents(szPath);
+ CleanPluginEvents(szPath);
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::UpdateEvents(DMEventMap & aEventMap,
+ CPCHAR szPath,
+ CPCHAR szNewName)
+{
+
+ for ( DMEventMap::POS nPos = aEventMap.end()-1; nPos >= 0; nPos-- )
+ {
+ PDMEventPath & pPath = (PDMEventPath &)aEventMap.get_key(nPos);
+
+ if ( !DmIsParentURI(szPath,pPath->GetPath()) )
+ continue;
+
+ DMBuffer oNewPath;
+ if ( !oNewPath.allocate((pPath->GetPath()).length() + DmStrlen(szNewName)) )
+ return SYNCML_DM_DEVICE_FULL;
+
+ DMURI oPath(FALSE,szPath);
+ CPCHAR pParent = oPath.getParentURI();
+
+ CPCHAR pStoredPath = (CPCHAR)(pPath->GetPath());
+ DMURI oStoredTail(FALSE, pStoredPath + DmStrlen(szPath) + 1);
+
+ oStoredTail.nextSegment();
+ CPCHAR pTailSegments = oStoredTail.getTailSegments();
+
+
+ oNewPath.assign(pParent);
+ oNewPath.append((UINT8*)"/",1);
+ oNewPath.append((UINT8*)szNewName,DmStrlen(szNewName));
+
+ if ( pTailSegments )
+ {
+ oNewPath.append((UINT8*)"/",1);
+ oNewPath.append((UINT8*)pTailSegments,DmStrlen(pTailSegments));
+ }
+
+ pPath = PDMEventPath(new DMEventPath((CPCHAR)oNewPath.getBuffer()));
+
+ if ( pPath == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::UpdateSubscriptionEvents(CPCHAR szPath,
+ CPCHAR szNewName)
+{
+
+ for ( DMPostEventMap::POS nPos = m_aPostEvents.end()-1; nPos >= 0; nPos-- )
+ {
+ const PDMConfigItem & pConfigItem = m_aPostEvents.get_key(nPos);
+
+ if ( !DmIsParentURI(szPath,pConfigItem->GetPath()) &&
+ !DmIsParentURI(pConfigItem->GetPath(),szPath) )
+ {
+ continue;
+ }
+
+ DMEventMap & aEventMap = m_aPostEvents.get_value(nPos);
+ UpdateEvents(aEventMap,szPath,szNewName);
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::UpdatePluginEvents(CPCHAR szPath,
+ CPCHAR szNewName)
+{
+
+ for ( DMPluginEventMap::POS nPos = m_aPluginEvents.end()-1; nPos >= 0; nPos-- )
+ {
+ const PDMPlugin & pPlugin = m_aPluginEvents.get_key(nPos);
+
+ if ( !DmIsParentURI(szPath,pPlugin->GetPath()) &&
+ !DmIsParentURI(pPlugin->GetPath(),szPath) )
+ {
+ continue;
+ }
+
+ DMEventMap & aEventMap = m_aPluginEvents.get_value(nPos);
+ UpdateEvents(aEventMap,szPath,szNewName);
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventLogger::UpdateEvents(CPCHAR szPath,
+ CPCHAR szNewName)
+{
+ XPL_LOG_DM_TMN_Debug(("Update events for %s\n", szPath));
+ UpdateSubscriptionEvents(szPath,szNewName);
+ UpdatePluginEvents(szPath,szNewName);
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+BOOLEAN
+DMEventLogger::FindRecordForAdd(const DmtEventDataVector & aVector,
+ CPCHAR szName)
+{
+
+ for (INT32 index=aVector.size()-1; index>=0; index--)
+ {
+ const PDmtEventData & pEventData = aVector[index];
+
+ if ( !pEventData->IsLeaf() )
+ continue; // we need only leaf nodes
+
+ if ( pEventData->GetName() == szName ) // No Rename on leaf nodes, so compare only name
+ {
+ if (pEventData->GetAction() == SYNCML_DM_EVENT_DELETE) // node was deleted
+ {
+ ((DMEventData*)pEventData.GetPtr())->SetAction(SYNCML_DM_EVENT_REPLACE); // delete+add on leaf node = replace
+ return TRUE;
+ }
+ break;
+ }
+ }
+ return FALSE;
+}
+
+
+BOOLEAN
+DMEventLogger::FindRecordForDelete(DmtEventDataVector & aVector,
+ CPCHAR szName)
+{
+ BOOLEAN bIsIgnore = FALSE;
+ for (INT32 index=aVector.size()-1; index>=0; index--)
+ {
+ const PDmtEventData & pEventData = aVector[index];
+ if ( pEventData->GetName() == szName || pEventData->GetNewName() == szName)
+ {
+ if ( (pEventData->GetAction() & SYNCML_DM_EVENT_ADD) == SYNCML_DM_EVENT_ADD )
+ {
+ bIsIgnore = TRUE;
+ aVector.remove(index);
+ }
+
+ return bIsIgnore;
+ }
+ }
+
+ return bIsIgnore;
+
+}
+
+
+BOOLEAN
+DMEventLogger::FindRecordForReplace(const DmtEventDataVector & aVector,
+ CPCHAR szName)
+{
+
+ for (INT32 index=aVector.size()-1; index>=0; index--)
+ {
+ const PDmtEventData & pEventData = aVector[index];
+ if ( pEventData->GetName() == szName ) // Replace is only on leaf nodes , no need to check new name
+ {
+ if ((pEventData->GetAction() & SYNCML_DM_EVENT_REPLACE) == SYNCML_DM_EVENT_REPLACE)
+ return TRUE;
+
+ if ((pEventData->GetAction() & SYNCML_DM_EVENT_ADD) == SYNCML_DM_EVENT_ADD)
+ return TRUE;
+
+ break;
+ }
+ }
+ return FALSE;
+}
+
+
+BOOLEAN
+DMEventLogger::FindRecordForRename(DmtEventDataVector & aVector,
+ CPCHAR szName,
+ CPCHAR szNewName)
+{
+ BOOLEAN bIsIgnore = FALSE;
+
+ for (INT32 index=aVector.size()-1; index>=0; index--)
+ {
+ PDmtEventData & pEventData = aVector[index];
+ if ( ((pEventData->GetAction() & SYNCML_DM_EVENT_ADD) == SYNCML_DM_EVENT_ADD) &&
+ pEventData->GetName() == szName )
+ {
+ ((DMEventData*)pEventData.GetPtr())->SetName(szNewName);
+ bIsIgnore = TRUE;
+ break;
+ }
+
+ if ( ((pEventData->GetAction() & SYNCML_DM_EVENT_RENAME) == SYNCML_DM_EVENT_RENAME) &&
+ pEventData->GetNewName() == szName )
+ {
+ ((DMEventData*)pEventData.GetPtr())->SetNewName(szNewName);
+ bIsIgnore = TRUE;
+ break;
+ }
+ }
+ return bIsIgnore;
+}
+
+
+
+BOOLEAN
+DMEventLogger::CheckEventOnSameNode(DmtEventDataVector & aVector,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szName,
+ BOOLEAN bIsCumulative,
+ CPCHAR szNewName)
+{
+
+
+ if ( bIsCumulative )
+ {
+ if ( nAction == SYNCML_DM_EVENT_RENAME )
+ return FindRecordForRename(aVector,szName,szNewName);
+ }
+ else
+ {
+ switch ( nAction )
+ {
+ case SYNCML_DM_EVENT_ADD:
+ return FindRecordForAdd(aVector,szName);
+
+ case SYNCML_DM_EVENT_REPLACE:
+ return FindRecordForReplace(aVector,szName);
+
+ case SYNCML_DM_EVENT_DELETE:
+ return FindRecordForDelete(aVector, szName);
+
+ case SYNCML_DM_EVENT_RENAME:
+ return FindRecordForRename(aVector,szName,szNewName);
+ }
+ }
+
+ return FALSE;
+
+}
+
+
+
+
+BOOLEAN
+DMEventLogger::IsIgnoreEvent(CPCHAR szPath ,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ DMEventMap & aEventMap,
+ BOOLEAN bIsCumulative,
+ CPCHAR szNewName )
+{
+
+
+ DMURI oURI(FALSE, szPath);
+
+ CPCHAR pParent = oURI.getParentURI();
+ CPCHAR pNode = oURI.getTailSegments();
+
+ DmtEventDataVector aVector;
+ PDMEventPath pEventPath;
+ BOOLEAN bIsFound = Find(pParent,aEventMap, pEventPath,aVector);
+
+ if ( !bIsFound )
+ return FALSE;
+
+ BOOLEAN bIsIgnore = CheckEventOnSameNode(aVector,
+ nAction,
+ pNode,
+ bIsCumulative,
+ szNewName);
+ if ( !aVector.size() )
+ aEventMap.remove(pEventPath);
+ else
+ aEventMap.put(pEventPath,aVector);
+
+ return bIsIgnore;
+
+}
+
+
+
+BOOLEAN
+DMEventLogger::IsIgnoreSubscriptionEvent(CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName)
+{
+
+ BOOLEAN bIsIgnore = TRUE;
+ BOOLEAN bIsCumulative = FALSE;
+
+ PDMConfigItem pFoundItem;
+ DMEventMap aEventMap;
+ UINT32 nSegmentCount = 0;
+
+ for ( DMPostEventMap::POS nPos = m_aPostEvents.end()-1; nPos >= 0; nPos-- )
+ {
+ const PDMConfigItem & pConfigItem = m_aPostEvents.get_key(nPos);
+
+ if ( !DmIsParentURI(pConfigItem->GetPath(),szPath) )
+ continue;
+
+ DMParser oParser(szPath);
+ if ( nSegmentCount < oParser.getSegmentsCount() )
+ {
+ nSegmentCount = oParser.getSegmentsCount();
+ pFoundItem = pConfigItem;
+ aEventMap = m_aPostEvents.get_value(nPos);
+ }
+ }
+
+ if ( pFoundItem == NULL )
+ return FALSE;
+
+ if ( ((DMSubscriptionItem*)( pFoundItem.GetPtr()))->GetType() == SYNCML_DM_EVENT_CUMULATIVE )
+ bIsCumulative = TRUE;
+
+ bIsIgnore = IsIgnoreEvent(szPath,
+ nAction,
+ aEventMap,
+ bIsCumulative,
+ szNewName);
+
+ if ( !aEventMap.size() )
+ m_aPostEvents.remove( pFoundItem);
+ else
+ m_aPostEvents.put(pFoundItem,aEventMap);
+
+ return bIsIgnore;
+}
+
+
+
+
+
+BOOLEAN
+DMEventLogger::IsIgnorePluginEvent(CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName)
+{
+
+ BOOLEAN bIsIgnore = TRUE;
+ BOOLEAN bIsCumulative = FALSE;
+
+ PDMPlugin pFoundPlugin;
+ DMEventMap aEventMap;
+ UINT32 nSegmentCount = 0;
+
+ for ( DMPluginEventMap::POS nPos = m_aPluginEvents.end()-1; nPos >= 0; nPos-- )
+ {
+ const PDMPlugin & pPlugin = m_aPluginEvents.get_key(nPos);
+
+ if ( !DmIsParentURI(pPlugin->GetPath(),szPath) )
+ continue;
+
+ DMParser oParser(szPath);
+ if ( nSegmentCount < oParser.getSegmentsCount() )
+ {
+ nSegmentCount = oParser.getSegmentsCount();
+ pFoundPlugin = pPlugin;
+ aEventMap = m_aPluginEvents.get_value(nPos);
+ }
+ }
+
+
+ if ( pFoundPlugin == NULL )
+ return FALSE;
+
+ if ( pFoundPlugin->GetType() == SYNCML_DM_EVENT_CUMULATIVE )
+ bIsCumulative = TRUE;
+
+ bIsIgnore = IsIgnoreEvent(szPath,
+ nAction,
+ aEventMap,
+ bIsCumulative,
+ szNewName);
+
+ if ( !aEventMap.size() )
+ m_aPluginEvents.remove(pFoundPlugin);
+ else
+ m_aPluginEvents.put(pFoundPlugin,aEventMap);
+
+ return bIsIgnore;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmEventSubscription.cc b/engine/dmlib/dmengine/dm_ua/src/dmEventSubscription.cc
new file mode 100644
index 0000000..2d74cb7
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmEventSubscription.cc
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmEventSubscription.cc
+
+ General Description: Implementation of the DMEventSubscription class
+
+==================================================================================================*/
+
+#include "dmEventSubscription.h"
+#include "dm_uri_utils.h"
+#include "dmdefs.h"
+#include "dmtoken.h"
+#include "xpl_Logger.h"
+#include "xpl_dm_Manager.h"
+#include "dm_tree_class.H"
+
+SYNCML_DM_RET_STATUS_T
+DMEventSubscription::ParseSegment(CPCHAR szSegment)
+{
+ DMParser oParser(szSegment,'=');
+ CPCHAR pKeyWord = oParser.nextSegment();
+ CPCHAR pValue = oParser.nextSegment();
+
+ if ( pKeyWord == NULL || pValue == NULL )
+ return SYNCML_DM_FAIL;
+
+ if ( DmStrcmp(pKeyWord,"Ignore") == 0 )
+ ParsePrincipal(pValue,TRUE);
+ else
+ if ( DmStrcmp(pKeyWord,"Notify") == 0 )
+ ParsePrincipal(pValue,FALSE);
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventSubscription::ParsePrincipal(CPCHAR szSegment,
+ BOOLEAN bIsIgnore)
+{
+ DMToken oParser(FALSE,szSegment,'+');
+ CPCHAR pSegment = NULL;
+
+ while ( (pSegment = oParser.nextSegment()) != NULL )
+ {
+ DMString strPrincipal = pSegment;
+ if ( bIsIgnore == TRUE )
+ m_aIgnorePrincipals.push_back(DmtPrincipal(strPrincipal));
+ else
+ m_aNotifyPrincipals.push_back(DmtPrincipal(strPrincipal));
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMEventSubscription::Set(CPCHAR szConfig)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ DMToken oParser(FALSE,szConfig,'&');
+ CPCHAR pCommand = NULL;
+
+ while ( (pCommand = oParser.nextSegment()) != NULL )
+ {
+
+ SYNCML_DM_EVENT_ACTION_T nAction = SYNCML_DM_EVENT_NONE;
+ SYNCML_DM_EVENT_TYPE_T nType = SYNCML_DM_EVENT_NODE;
+
+
+ if ( DmStrcmp(pCommand,"Add") == 0 )
+ nAction = SYNCML_DM_EVENT_ADD;
+ else if ( DmStrcmp(pCommand,"Delete") ==0 )
+ nAction = SYNCML_DM_EVENT_DELETE;
+ else if ( DmStrcmp(pCommand,"Indirect") == 0 )
+ nAction = SYNCML_DM_EVENT_INDIRECT;
+ else if (( DmStrcmp(pCommand,"Replace") == 0 || DmStrcmp(pCommand,"Rename") == 0 ))
+ nAction = SYNCML_DM_EVENT_REPLACE | SYNCML_DM_EVENT_RENAME;
+ else if (DmStrcmp(pCommand,"Node") == 0 )
+ nType = SYNCML_DM_EVENT_NODE;
+ else if ( DmStrcmp(pCommand,"Cumulative") == 0 )
+ nType = SYNCML_DM_EVENT_CUMULATIVE;
+ else if ( DmStrcmp(pCommand,"Detail") == 0 )
+ nType = SYNCML_DM_EVENT_DETAIL;
+ else
+ {
+ dm_stat = ParseSegment(pCommand);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ continue;
+ }
+
+ m_eAction |= nAction;
+ m_nType = nType;
+
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+BOOLEAN
+DMEventSubscription::VerifyPrincipal(DMTree * pTree,
+ const DMVector<DmtPrincipal> & aPrincipals)
+{
+
+ for (INT32 index=0; index < aPrincipals.size(); index++)
+ {
+ const DmtPrincipal & oPrincipal = aPrincipals[index];
+ if ( oPrincipal.getName() == "OTA" )
+ {
+ CPCHAR szDMAccRootPath = ::XPL_DM_GetEnv( SYNCML_DM_DMACC_ROOT_PATH );
+ CPCHAR szServerIdNodeName = ::XPL_DM_GetEnv( SYNCML_DM_NODENAME_SERVERID );
+ DMString dmProfleNodeName;
+ BOOLEAN bIsFound;
+
+ bIsFound = pTree->GetParentOfKeyValue (pTree->GetServerId(),
+ szServerIdNodeName,
+ szDMAccRootPath,
+ dmProfleNodeName);
+ if ( bIsFound )
+ return TRUE;
+ }
+ else
+ if ( oPrincipal.getName() == pTree->GetServerId() )
+ return TRUE;
+ }
+ return FALSE;
+
+}
+
+
+
+
+
+
+BOOLEAN
+DMEventSubscription::IsEnabled(SYNCML_DM_EVENT_ACTION_T nAction,
+ DMTree* pTree)
+{
+ BOOLEAN bIsEnabled = ((m_eAction & nAction) == nAction);
+ if ( bIsEnabled == TRUE )
+ {
+ if ( pTree == NULL )
+ return TRUE;
+
+
+ if ( m_aIgnorePrincipals.size() )
+ {
+ if ( VerifyPrincipal(pTree,m_aIgnorePrincipals) == TRUE )
+ return FALSE;
+ }
+
+ if ( m_aNotifyPrincipals.size() )
+ {
+ if ( VerifyPrincipal(pTree,m_aNotifyPrincipals) == FALSE )
+ return FALSE;
+ }
+
+ return TRUE;
+
+ }
+
+ return FALSE;
+
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmLock.cc b/engine/dmlib/dmengine/dm_ua/src/dmLock.cc
new file mode 100644
index 0000000..82874e0
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmLock.cc
@@ -0,0 +1,479 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: SYNCML_DM_Lock.cc
+
+ General Description: Implementation of the DMFileLockingThread, Clock and DMLockManager classes
+
+==================================================================================================*/
+
+#include "dmLock.h"
+#include "xpl_Logger.h"
+#include "xpl_dm_Manager.h"
+#include "dm_tree_class.H"
+
+#ifndef DM_NO_LOCKING
+// memory aging check interval in seconds
+#define DEFAULT_AGING_CHECK_INTERVAL 60
+
+// Static member
+DMCriticalSection DMLock::m_csLock;
+
+DMFileLockingThread::DMFileLockingThread( DMLockManager* pLockManager )
+{
+ m_nReady=SYNCML_DM_THREAD_STARTING;
+ m_pLockManager = pLockManager;
+
+ m_nAgingCheckInterval = DEFAULT_AGING_CHECK_INTERVAL;
+ CPCHAR dm_aging_env = XPL_DM_GetEnv(SYNCML_DM_MEMORY_AGING_INTERVAL);
+ if ( dm_aging_env != NULL) {
+ INT32 interval = DmAtoi(dm_aging_env);
+ if (interval >= 0) {
+ m_nAgingCheckInterval = interval;
+ } else {
+ m_nAgingCheckInterval = 0;
+ }
+ }
+}
+
+void* DMFileLockingThread ::Run()
+{
+ BOOLEAN bDone = FALSE;
+ DMVector< DMFileLockParam > aMessages;
+
+ m_nReady = SYNCML_DM_THREAD_STARTED;
+ INT32 nAgingCheck = m_nAgingCheckInterval;
+ INT32 nElapsed = 0;
+ XPL_CLK_CLOCK_T startTime, endTime;
+
+ while(!bDone)
+ {
+ INT64 nTimeoutMS;
+ if (m_nAgingCheckInterval <= 0)
+ {
+ nTimeoutMS = (aMessages.size() == 0 ? DM_WAIT_FOREVER : 100 );
+ }
+ else
+ {
+ nTimeoutMS = (aMessages.size()==0 ? (nAgingCheck * 1000) : 100 );
+ }
+ startTime = XPL_CLK_GetClock();
+ DMThreadEvent evt;
+
+ if ( m_pLockManager->GetQueue()->Wait(nTimeoutMS, evt))
+ {
+ switch ( evt.GetEventType() )
+ {
+ case SYNCML_DM_THREAD_EVENT_TYPE_TIMEOUT:
+ dmTreeObj.GetLockContextManager().ReleaseAll();
+ break;
+ case SYNCML_DM_THREAD_EVENT_TYPE_FILELOCK:
+ {
+ DMFileLockParam* ptr = (DMFileLockParam*)evt.GetData();
+ aMessages.push_back( *ptr );
+ DmFreeMem( ptr );
+ break;
+ }
+ case SYNCML_DM_THREAD_EVENT_TYPE_SHUTDOWN:
+ bDone = true;
+ break;
+ default:
+ case SYNCML_DM_THREAD_EVENT_TYPE_NONE:
+ {
+ // DM: just to supress warning, do nothing here
+ break;
+ }
+ }
+
+ endTime = XPL_CLK_GetClock();
+ nAgingCheck -= (int)(endTime - startTime);
+ nElapsed += (int)(endTime - startTime);
+ }
+ else
+ {
+
+ endTime = XPL_CLK_GetClock();
+ nElapsed += (int)(endTime - startTime);
+
+ if ( (nTimeoutMS == nAgingCheck * 1000) &&
+ (!m_pLockManager->GetQueue()->IsTimerSet()) )
+ {
+ XPL_LOG_DM_TMN_Debug(("Memory aging time out = %d sec.\n", nElapsed));
+ dmTreeObj.CheckMemoryAging();
+ nAgingCheck = m_nAgingCheckInterval;
+ nElapsed = 0;
+ }
+ else
+ {
+ nAgingCheck -= (int)(endTime - startTime);
+ }
+ }
+
+ if (nAgingCheck < 1)
+ {
+ endTime = XPL_CLK_GetClock();
+ XPL_LOG_DM_TMN_Debug(("Memory aging time out = %d sec.\n", nElapsed ));
+ nAgingCheck = 1;
+ }
+
+ // try to lock/unlock all postponed requests:
+ for ( int i = 0; i < aMessages.size(); i++ ) {
+ DMFileLockParam& pFileLockMsg = aMessages[i];
+
+ if ( m_pLockManager->ProcessLockRequest( &pFileLockMsg ) ) {
+ aMessages.remove(i);
+ i--; // don't skip next
+ }
+ }
+ }
+
+ m_nReady = SYNCML_DM_THREAD_STARTING;
+
+ return NULL;
+}
+
+DMLock::DMLock()
+{
+ m_pFile = NULL;
+ m_nReadWriteCounter = 0;
+}
+
+DMLock::~DMLock()
+{
+ if (m_pFile)
+ {
+ Destroy();
+ }
+}
+
+SYNCML_DM_RET_STATUS_T
+DMLock::Init( CPCHAR p_LockFileName)
+{
+ m_nReadWriteCounter = 0;
+ m_pFile = new DMFileHandler(p_LockFileName);
+
+ SYNCML_DM_RET_STATUS_T nRes = m_pFile->open(XPL_FS_FILE_RDWR);
+
+ if ( nRes != SYNCML_DM_SUCCESS )
+ Destroy();
+
+ return nRes;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMLock::Destroy(void)
+{
+ if (!m_pFile)
+ return SYNCML_DM_SUCCESS;
+
+ m_pFile->unlock();
+ m_pFile->close();
+ delete m_pFile;
+ m_pFile = NULL;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMLock::Lock( SYNCML_DM_TREE_LOCK_TYPE_T eLockType)
+{
+ DMSingleLock oLock( DMLock::m_csLock );
+
+ INT32 nPrevCounter = m_nReadWriteCounter;
+ SYNCML_DM_RET_STATUS_T nRes = SYNCML_DM_SUCCESS;
+
+ if ( eLockType == SYNCML_DM_LOCK_TYPE_EXCLUSIVE )
+ {
+ if ( m_nReadWriteCounter != 0 )
+ return SYNCML_DM_LOCK_TRY_AGAIN; // not available
+
+ m_nReadWriteCounter = -1; // writer
+ }
+ else
+ { // shared lock
+ if ( m_nReadWriteCounter < 0 )
+ return SYNCML_DM_LOCK_TRY_AGAIN; // writer in progress
+
+ m_nReadWriteCounter++; // reader
+ }
+
+
+ if ( m_nReadWriteCounter <= 1 )
+ { // only first reader/writer should lock the file
+ if (!m_pFile)
+ return SYNCML_DM_FAIL;
+
+ if ( eLockType == SYNCML_DM_LOCK_TYPE_EXCLUSIVE )
+ nRes = m_pFile->lock( TRUE );
+ else
+ nRes = m_pFile->lock( FALSE );
+
+ if ( nRes == SYNCML_DM_LOCK_TRY_AGAIN )
+ m_nReadWriteCounter = nPrevCounter;
+ }
+
+ return nRes;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMLock::Unlock()
+{
+ SYNCML_DM_RET_STATUS_T nRes = SYNCML_DM_SUCCESS;
+ DMSingleLock oLock( DMLock::m_csLock );
+
+ if ( m_pFile && IsLastLock() )
+ nRes = m_pFile->unlock();
+
+ if ( m_nReadWriteCounter < 0 )
+ m_nReadWriteCounter = 0; // writer
+ else
+ m_nReadWriteCounter--;
+
+ return nRes;
+}
+
+
+DMLockManager::DMLockManager() :
+ m_oThread( this )
+{
+ m_ptrQueue = NULL;
+}
+
+DMLockManager::~DMLockManager()
+{
+ Destroy();
+}
+
+SYNCML_DM_RET_STATUS_T DMLockManager::Init( CPCHAR szLockFileNamePrefix, INT32 nNumberOfLocks )
+{
+
+ nNumberOfLocks += 2; // count for ACL lock as well (the last one) and Evt lock
+ m_aLocks.set_size( nNumberOfLocks );
+ if ( m_aLocks.size() != nNumberOfLocks )
+ {
+ m_aLocks.clear();
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ while( nNumberOfLocks-- )
+ {
+ char szIndex[10];
+ DMString strName = szLockFileNamePrefix;
+ DmSnprintf( szIndex, sizeof(szIndex), "%d", nNumberOfLocks );
+ strName += szIndex;
+
+ dm_stat = m_aLocks[ nNumberOfLocks ].Init( strName.c_str() );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+
+ return dm_stat;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMLockManager::StartThread()
+{
+
+ if ( m_ptrQueue == NULL )
+ {
+ m_ptrQueue = new DMThreadQueue;
+ if( m_ptrQueue == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ if ( !m_oThread.StartThread() )
+ return SYNCML_DM_UNABLE_START_THREAD;
+
+
+ INT32 nThreadState;
+
+ while ( (nThreadState = m_oThread.GetThreadState()) == SYNCML_DM_THREAD_STARTING )
+ DmThSleep( 1000 ); /// give a chance to start
+
+ if ( nThreadState != SYNCML_DM_THREAD_STARTED )
+ {
+ Destroy();
+ return SYNCML_DM_UNABLE_START_THREAD;
+ }
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMLockManager::Destroy()
+{
+ if(m_ptrQueue != NULL)
+ {
+ if ( m_oThread.GetThreadState() == SYNCML_DM_THREAD_STARTED )
+ {
+ m_ptrQueue->Post(SYNCML_DM_THREAD_EVENT_TYPE_SHUTDOWN);
+ m_oThread.StopThread();
+
+ }
+ m_ptrQueue = NULL;
+ }
+
+ //release locks
+
+ for( int i = 0; i < m_aLocks.size(); i++ )
+ m_aLocks[i].Destroy();
+
+ m_aLocks.clear();
+
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMLockManager::LockSet( FILESETTYPE nLockSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType )
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if ( eLockType != SYNCML_DM_LOCK_TYPE_SHARED )
+ {
+ dm_stat = StartThread();
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = SendAndWait( TRUE, nLockSet, eLockType );
+ }
+ else
+ {
+ INT32 nNumber = m_aLocks.size();
+
+ for ( int i = 0; i < nNumber; i++ )
+ {
+ if ( (1 << i) & nLockSet )
+ {
+ while( m_aLocks[i].Lock( eLockType ) == SYNCML_DM_LOCK_TRY_AGAIN )
+ DmThSleep( 1000 );
+ }
+ }
+ }
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMLockManager::UnlockSet( FILESETTYPE nLockSet,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType )
+{
+ if ( eLockType != SYNCML_DM_LOCK_TYPE_SHARED )
+ return SendAndWait( FALSE, nLockSet, 0 );
+ else
+ {
+ INT32 nNumber = m_aLocks.size();
+
+ for ( int i = 0; i < nNumber; i++ )
+ {
+ if ( (1 << i) & nLockSet )
+ {
+ m_aLocks[i].Unlock();
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+ }
+}
+
+SYNCML_DM_RET_STATUS_T DMLockManager::SendAndWait(BOOLEAN bIsLock, FILESETTYPE nLockSet, INT32 eLockType )
+{
+ BOOLEAN bOK = FALSE;
+
+ while ( !bOK ) {
+ DMFileLockParam* pFileLockMsg = (DMFileLockParam*)DmAllocMem(sizeof(DMFileLockParam) );
+
+ if ( !pFileLockMsg )
+ return SYNCML_DM_DEVICE_FULL;
+
+ int nStatus = SYNCML_DM_FILE_LOCK_STATUS_IN_PROGRESS;
+
+ pFileLockMsg->m_bIsLock = bIsLock;
+ pFileLockMsg->m_pDoneFlag = bIsLock ? &nStatus : NULL;
+ pFileLockMsg->m_eLockType = eLockType;
+ pFileLockMsg->m_nLockSet = nLockSet;
+
+ if ( !m_ptrQueue->Post( SYNCML_DM_THREAD_EVENT_TYPE_FILELOCK, pFileLockMsg) ) {
+ DmFreeMem(pFileLockMsg);
+ return SYNCML_DM_FAIL;
+ }
+
+ if ( !bIsLock )
+ break;
+
+ // wait for "done" flag marked
+ while ( nStatus == SYNCML_DM_FILE_LOCK_STATUS_IN_PROGRESS )
+ DmThSleep(1000);
+
+ if ( nStatus != SYNCML_DM_FILE_LOCK_STATUS_TRY_AGAIN )
+ return nStatus == SYNCML_DM_FILE_LOCK_STATUS_OK ? SYNCML_DM_SUCCESS : SYNCML_DM_FAIL;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+BOOLEAN DMLockManager::ProcessLockRequest( DMFileLockParam* pFileLockMsg )
+{
+ INT32 nNumber = m_aLocks.size();
+ SYNCML_DM_RET_STATUS_T nRes = SYNCML_DM_SUCCESS;
+
+ for ( int i = 0; i < nNumber; i++ ){
+ if ( (1 << i) & pFileLockMsg->m_nLockSet ) {
+ if ( !pFileLockMsg->m_bIsLock )
+ {
+ nRes = m_aLocks[i].Unlock();
+ }
+ else
+ {
+ if ( (nRes = m_aLocks[i].Lock( pFileLockMsg->m_eLockType)) == SYNCML_DM_LOCK_TRY_AGAIN )
+ return FALSE;
+ }
+ // mark processed files
+ pFileLockMsg->m_nLockSet &= ~((FILESETTYPE)((FILESETTYPE)1 << i));
+ }
+ }
+
+ if ( pFileLockMsg->m_pDoneFlag )
+ *(pFileLockMsg->m_pDoneFlag) = (nRes == SYNCML_DM_SUCCESS ? SYNCML_DM_FILE_LOCK_STATUS_OK : SYNCML_DM_FILE_LOCK_STATUS_ERROR);
+
+ return TRUE;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMLockManager::ReleaseFile(SYNCML_DM_FILE_TYPE_T eFileType)
+{
+ if ( eFileType == SYNCML_DM_FILE_ACL )
+ return SendAndWait( FALSE, 1 << (m_aLocks.size()-1), 0 );
+ else
+ return SendAndWait( FALSE, 1 << (m_aLocks.size()-2), 0 );
+}
+
+SYNCML_DM_RET_STATUS_T
+DMLockManager::AcquireFile(SYNCML_DM_FILE_TYPE_T eFileType )
+{
+ if ( eFileType == SYNCML_DM_FILE_ACL )
+ return LockSet( 1 << (m_aLocks.size()-1), SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+ else
+ return LockSet( 1 << (m_aLocks.size()-2), SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+}
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmLockCtxMgr.cc b/engine/dmlib/dmengine/dm_ua/src/dmLockCtxMgr.cc
new file mode 100644
index 0000000..4f4fd87
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmLockCtxMgr.cc
@@ -0,0 +1,615 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: SYNCML_DM_LockCtxMgr.cc
+
+ General Description: Implementation of the DMLockContextManager class
+
+==================================================================================================*/
+
+#include "dmprofile.h"
+#include "xpl_Logger.h"
+#include "dmLockingHelper.h"
+#include "dm_tree_class.H"
+#include "SyncML_DM_Archiver.H"
+#include "dmLockCtxMgr.h"
+
+// memory aging time in seconds
+#ifndef DM_NO_LOCKING
+#define DEFAULT_AGING_TIME 120
+#else
+#define DEFAULT_AGING_TIME 60
+#endif
+
+void DmOnMemoryTimer()
+{
+ dmTreeObj.CheckMemoryAging();
+}
+
+
+DMLockContextManager::DMLockContextManager()
+ : m_pTree( NULL )
+{
+ m_nLockWithConfig_ID[0] = SYNCML_DM_LOCKID_NONE;
+ m_nLockWithConfig_ID[1] = SYNCML_DM_LOCKID_NONE;
+ m_nCurrentLockID = SYNCML_DM_LOCKID_NONE;
+
+ m_nAgingTime = DEFAULT_AGING_TIME;
+ CPCHAR dm_aging_env = XPL_DM_GetEnv(SYNCML_DM_MEMORY_AGING_TIME);
+ if ( dm_aging_env != NULL )
+ {
+ INT32 agingTime = DmAtoi(dm_aging_env);
+ m_nAgingTime = ((agingTime>=0) ? agingTime : 0);
+ }
+
+#ifndef DM_NO_LOCKING
+ m_ptrFM = NULL;
+ m_nNewUniqueID = 1;
+ m_pGlobalLockFile = NULL;
+#else
+ m_bIsLocked = FALSE;
+ m_nMemoryTimer = XPL_CLK_HANDLE_INVALID;
+#endif
+}
+
+DMLockContextManager::~DMLockContextManager()
+{
+ Destroy();
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMLockContextManager::Init(DMTree* tree,
+ CMultipleFileManager* ptrFM)
+{
+ if( !tree || !ptrFM )
+ return SYNCML_DM_FAIL;
+
+ m_ptrFM = ptrFM;
+ m_pTree = tree;
+
+ m_nLockWithConfig_ID[0] = SYNCML_DM_LOCKID_NONE;
+ m_nLockWithConfig_ID[1] = SYNCML_DM_LOCKID_NONE;
+ #ifndef DM_NO_LOCKING
+ int nLocksNumber = m_ptrFM->GetFileNumber();
+
+ if ( nLocksNumber >= 32 )
+ {
+ XPL_LOG_DM_TMN_Error(("DMLockContextManager::Init: too many files - simple locking supports only up to 31 files\n"));
+ return SYNCML_DM_TOO_MANY_DATA_FILES;
+ }
+
+ DMString strLockFileNamePrefix;
+
+ strLockFileNamePrefix = "/tmp/dm";
+ XPL_FS_MkDir(strLockFileNamePrefix);
+ strLockFileNamePrefix += "/##lock##";
+
+ DMString strName = strLockFileNamePrefix;
+ strName += "g";
+ m_pGlobalLockFile = new DMFileHandler(strName);
+
+ if ( !m_pGlobalLockFile || m_pGlobalLockFile->open(XPL_FS_FILE_RDWR) != SYNCML_DM_SUCCESS )
+ return SYNCML_DM_FAIL;
+
+ return m_oLockManager.Init( strLockFileNamePrefix, nLocksNumber);
+#else
+ return SYNCML_DM_SUCCESS;
+#endif
+}
+
+SYNCML_DM_RET_STATUS_T DMLockContextManager::Destroy()
+{
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_SUCCESS;
+ if(m_ptrFM == NULL)
+ return SYNCML_DM_SUCCESS;
+
+ m_ptrFM = NULL;
+ m_mapContexts.clear();
+
+#ifndef DM_NO_LOCKING
+ if ( m_pGlobalLockFile )
+ {
+ m_pGlobalLockFile->close();
+ delete m_pGlobalLockFile;
+ m_pGlobalLockFile = NULL;
+ }
+ result = m_oLockManager.Destroy();
+#endif
+
+ m_pTree = NULL;
+ return result;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMLockContextManager::ValidateAndLockTNM( INT32& nID,
+ CPCHAR szURI,
+ CPCHAR szPrincipal,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType,
+ BOOLEAN bInTransaction)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if ( DmGetMemFailedFlag() ) // device runs out of memory
+ return SYNCML_DM_DEVICE_FULL;
+
+#ifndef DM_NO_LOCKING
+
+ m_csTNMLock.Enter();
+ DMLockContext ctx;
+
+ if ( m_mapContexts.lookup( nID, ctx ) )
+ {
+ if ( eLockType == SYNCML_DM_LOCK_TYPE_EXCLUSIVE && eLockType != ctx.m_eLockType )
+ {
+ m_csTNMLock.Leave();
+ ReleaseID( nID, SYNCML_DM_RELEASE);
+ return ValidateAndLockTNM( nID, szURI, szPrincipal, eLockType, bInTransaction );
+ }
+
+ // found appropriate lock; return without UNLOCKING if no error occurs
+ m_pTree->SetServerId( szPrincipal ); // substitute principal
+
+ m_nCurrentLockID = nID;
+ return SYNCML_DM_SUCCESS;
+ }
+
+ m_csTNMLock.Leave(); // unlock area
+
+ if ( bInTransaction ) //in transactions we do not upgrade the lock, but throw exception instead
+ return SYNCML_DM_LOCKCTX_NOTFOUND;
+
+ FILESETTYPE nFileSet = m_ptrFM->GetFileSetByURI( szURI, eLockType != SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ dm_stat = m_oLockManager.LockSet(nFileSet, eLockType);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Error(("unable to lock file set %d nFileSet %d with lock type %d error\n",nFileSet,eLockType,dm_stat));
+ return dm_stat;
+ }
+
+ // Locked area again
+ m_csTNMLock.Enter();
+
+ if ( nFileSet )
+ {
+ XPL_LOG_DM_TMN_Debug(("LockFileSet szURI:%s\n", szURI));
+ dm_stat = m_ptrFM->LockFileSet(szURI, nFileSet, eLockType );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ m_oLockManager.UnlockSet( nFileSet,eLockType );
+ m_csTNMLock.Leave();
+ XPL_LOG_DM_TMN_Error(("DM_LOCKING: failed to load files %d\n",dm_stat));
+ return dm_stat;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("after LockFileSet szURI:%s\n", szURI));
+ if ( eLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ m_oLockManager.UnlockSet( nFileSet,eLockType );
+ }
+
+ m_nNewUniqueID += 2; // 0 is predefined for new lock (non existing), start value is 1, so we never get 0
+ nID = m_nNewUniqueID;
+
+ DMLockContext oLC;
+
+ oLC.Set(nFileSet, eLockType, szURI,FALSE);
+
+ OnTreeAccessed();
+
+ m_mapContexts.put( nID, oLC );
+ m_pTree->SetServerId( szPrincipal );
+ m_nCurrentLockID = nID;
+
+ return SYNCML_DM_SUCCESS;
+#else
+ DMLockContext ctx;
+
+ FILESETTYPE nFileSet = m_ptrFM->GetFileSetByURI( szURI, FALSE );
+
+ if ( m_mapContexts.lookup( nID, ctx ) )
+ {
+ m_pTree->SetServerId( szPrincipal );
+ return SYNCML_DM_SUCCESS;
+ }
+
+
+ dm_stat = m_ptrFM->LockFileSet(szURI, nFileSet, eLockType);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ m_pTree->SetServerId( szPrincipal );
+ DMLockContext oLC;
+
+ oLC.Set(nFileSet, eLockType, szURI,FALSE);
+
+ OnTreeAccessed();
+ m_mapContexts.put( nID, oLC );
+ m_nCurrentLockID = nID;
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Error(("DM_NO_LOCKING: failed to load files %d\n",dm_stat));
+ }
+ return dm_stat;
+#endif
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMLockContextManager::ReleaseID( INT32 nID,
+ SYNCML_DM_COMMAND_T command)
+{
+ DM_PROFILE ( "Release lock including unloading files" );
+
+ SYNCML_DM_RET_STATUS_T dm_stat=SYNCML_DM_SUCCESS;
+
+
+ if ( SYNCML_DM_LOCKID_IGNORE == nID ) // ignore lock
+ return SYNCML_DM_SUCCESS;
+
+#ifndef DM_NO_LOCKING
+ DMSingleLock oLock( m_csTNMLock );
+#endif
+
+ if ( SYNCML_DM_LOCKID_CURRENT == nID )
+ {
+ if ( m_mapContexts.size() != 1 )
+ return SYNCML_DM_LOCKCTX_NOTFOUND; // works only with one lock
+
+ nID = m_mapContexts.get_key( 0 );
+ }
+
+ DMLockContext ctx;
+
+ if ( !m_mapContexts.lookup(nID, ctx ) )
+ return SYNCML_DM_LOCKCTX_NOTFOUND;
+
+ dm_stat=ReleaseContext( nID, ctx, command );
+
+ if ((command != SYNCML_DM_ATOMIC) &&
+ (command != SYNCML_DM_COMMIT) &&
+ ( m_mapContexts.size() == 0 ))
+ {
+ StopTimer();
+ }
+ return dm_stat;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMLockContextManager::ReleaseIDInternal(INT32 nID,
+ SYNCML_DM_COMMAND_T command)
+{
+ DM_PROFILE ( "Release lock including unloading files" );
+
+ SYNCML_DM_RET_STATUS_T dm_stat=SYNCML_DM_SUCCESS;
+
+ if ( SYNCML_DM_LOCKID_IGNORE == nID ) // ignore lock
+ return SYNCML_DM_SUCCESS;
+
+ if ( SYNCML_DM_LOCKID_CURRENT == nID )
+ {
+ if ( m_mapContexts.size() != 1 )
+ return SYNCML_DM_LOCKCTX_NOTFOUND; // works only with one lock
+
+ nID = m_mapContexts.get_key( 0 );
+ }
+
+ DMLockContext ctx;
+
+ if ( !m_mapContexts.lookup(nID, ctx ) )
+ return SYNCML_DM_LOCKCTX_NOTFOUND;
+
+ dm_stat=ReleaseContext( nID, ctx, command );
+
+ if (m_mapContexts.size() == 0 )
+ StopTimer();
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMLockContextManager::UnlockTNM()
+{
+#ifndef DM_NO_LOCKING
+ m_nCurrentLockID = SYNCML_DM_LOCKID_NONE;
+ m_csTNMLock.Leave();
+#endif
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMLockContextManager::ReleaseAll()
+{
+ SYNCML_DM_RET_STATUS_T dm_stat=SYNCML_DM_SUCCESS;
+#ifndef DM_NO_LOCKING
+ DMSingleLock oLock( m_csTNMLock );
+#endif
+
+ StopTimer();
+
+ for ( DMMap< int, DMLockContext >::POS nK = m_mapContexts.begin(); nK < m_mapContexts.end(); nK++ )
+ {
+ //Pass through errors if not the same
+ DMLockContext ctx = m_mapContexts.get_value( nK );
+ SYNCML_DM_RET_STATUS_T retStatus1=ReleaseContext( m_mapContexts.get_key(nK),ctx,
+ ctx.m_bAtomic ? SYNCML_DM_ROLLBACK : SYNCML_DM_RELEASE);
+ if (dm_stat == SYNCML_DM_SUCCESS)
+ dm_stat=retStatus1;
+ }
+ return dm_stat;
+}
+
+
+
+BOOLEAN
+DMLockContextManager::IsReleaseConfigFile(INT32 nLockID,
+ SYNCML_DM_FILE_TYPE_T & index)
+{
+
+ for (index=0; index<2; index++)
+ {
+ if ( nLockID == m_nLockWithConfig_ID[index] )
+ return TRUE;
+ }
+ return FALSE;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMLockContextManager::ReleaseConfigFile(SYNCML_DM_FILE_TYPE_T index,
+ SYNCML_DM_RET_STATUS_T dm_stat)
+{
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ return m_pTree->SaveFile(index);
+ else
+ return m_pTree->RevertFile(index);
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMLockContextManager::ReleaseContext(INT32 nLockID,
+ const DMLockContext& ctx,
+ SYNCML_DM_COMMAND_T command)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat=SYNCML_DM_SUCCESS;
+
+ SYNCML_DM_FILE_TYPE_T index=0;
+ BOOLEAN bReleaseFile = IsReleaseConfigFile(nLockID,index);
+
+ FILESETTYPE nLocksSet = ctx.m_nFileSet;
+
+
+ if ( command == SYNCML_DM_COMMIT || command == SYNCML_DM_ROLLBACK )
+ { // reset 'atomic' flag
+ DMLockContext oUpdateCtx = ctx;
+ oUpdateCtx.m_bAtomic = FALSE;
+ m_mapContexts.put( nLockID, oUpdateCtx );
+ }
+
+
+ switch(command)
+ {
+ case SYNCML_DM_RELEASE:
+ dm_stat=m_ptrFM->UnlockFileSet(ctx.m_strRoot.c_str(), nLocksSet, ctx.m_eLockType);
+ break;
+
+ case SYNCML_DM_ROLLBACK:
+ if ( bReleaseFile )
+ {
+ m_pTree->RevertFile(index);
+ }
+
+ dm_stat=m_ptrFM->RollbackFileSet(ctx.m_strRoot.c_str(), nLocksSet );
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat=m_ptrFM->LockFileSet(ctx.m_strRoot.c_str(), nLocksSet, ctx.m_eLockType );
+ return dm_stat;
+
+ case SYNCML_DM_ATOMIC: // update context to set 'atomic' flag
+ case SYNCML_DM_COMMIT:
+ dm_stat=m_ptrFM->FlushFileSet(ctx.m_strRoot.c_str(), nLocksSet ,command);
+ if ( bReleaseFile )
+ {
+ ReleaseConfigFile(index,dm_stat);
+ }
+ if ( dm_stat == SYNCML_DM_SUCCESS && command == SYNCML_DM_ATOMIC )
+ {
+ DMLockContext oUpdateCtx = ctx;
+ oUpdateCtx.m_bAtomic = TRUE;
+ m_mapContexts.put( nLockID, oUpdateCtx );
+ }
+ return dm_stat;
+
+ default:
+ return SYNCML_DM_INVALID_PARAMETER;
+ }
+
+#ifndef DM_NO_LOCKING
+ if ( ctx.m_eLockType != SYNCML_DM_LOCK_TYPE_SHARED )
+ m_oLockManager.UnlockSet( nLocksSet, ctx.m_eLockType );
+#endif
+
+ if ( bReleaseFile )
+ {
+ ReleaseConfigFile(index,dm_stat);
+#ifndef DM_NO_LOCKING
+ m_nLockWithConfig_ID[index] = SYNCML_DM_LOCKID_NONE;
+ m_oLockManager.ReleaseFile(index);
+#endif
+ }
+
+ m_mapContexts.remove( nLockID ); // delete context
+
+ if ( m_mapContexts.size() == 0 && DmGetMemFailedFlag() )
+ {
+ DmResetMemFailedFlag();
+
+ // force to unload all loaded sub-trees and plug-ins
+ m_pTree->Flush();
+ }
+
+ return dm_stat;
+}
+
+#ifdef DM_NO_LOCKING
+void DMLockContextManager::Lock()
+{
+ XPL_LOG_DM_TMN_Debug(("Locking...\n"));
+ m_bIsLocked = TRUE;
+ if ( m_nMemoryTimer != XPL_CLK_HANDLE_INVALID )
+ XPL_CLK_StopTimer(m_nMemoryTimer);
+ m_nMemoryTimer = XPL_CLK_HANDLE_INVALID;
+}
+
+void DMLockContextManager::UnLock()
+{
+ XPL_LOG_DM_TMN_Debug(("UnLocking...\n"));
+ XPL_LOG_DM_TMN_Debug(("and returning\n"));
+ m_bIsLocked = FALSE;
+ if ( m_nAgingTime > 0 )
+ {
+ if ( m_nMemoryTimer == XPL_CLK_HANDLE_INVALID )
+ m_nMemoryTimer = XPL_CLK_StartTimer(XPL_PORT_DM_TASK, m_nAgingTime*1000, DmOnMemoryTimer);
+ }
+ else
+ {
+ SyncML_DM_Archiver& oArchiver = m_pTree->GetArchiver();
+ oArchiver.CheckMemoryAging(m_nAgingTime);
+
+ DMPluginManager & oPluginManager = m_pTree->GetPluginManager();
+ oPluginManager.CheckPluginAging(m_nAgingTime);
+ }
+}
+#endif
+
+void DMLockContextManager::OnTreeAccessed()
+{
+#ifndef DM_NO_LOCKING
+ if ( m_oLockManager.GetQueue() != NULL )
+ {
+#ifdef DEBUG
+ m_oLockManager.GetQueue()->SetTimer( 7000 );
+#else
+ m_oLockManager.GetQueue()->SetTimer( 3000 );
+#endif
+ }
+
+#endif
+}
+
+void DMLockContextManager::StopTimer()
+{
+#ifndef DM_NO_LOCKING
+ // DP: the only place where queue ptr can be null, is here during failed initi function call.
+ if ( m_oLockManager.GetQueue() != NULL )
+ m_oLockManager.GetQueue()->KillTimer();
+#endif
+}
+
+SYNCML_DM_RET_STATUS_T DMLockContextManager::GlobalLock()
+{
+#ifndef DM_NO_LOCKING
+ if ( !m_pGlobalLockFile )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ while ( (dm_stat = m_pGlobalLockFile->lock(TRUE) ) == SYNCML_DM_LOCK_TRY_AGAIN )
+ DmThSleep( 1000 );
+
+ return dm_stat;
+#else
+ return SYNCML_DM_SUCCESS;
+#endif
+
+}
+
+SYNCML_DM_RET_STATUS_T DMLockContextManager::GlobalUnlock()
+{
+#ifndef DM_NO_LOCKING
+ if ( !m_pGlobalLockFile )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return m_pGlobalLockFile->unlock();
+#else
+ return SYNCML_DM_SUCCESS;
+#endif
+}
+
+void DMLockContextManager::InsureFileLocked(SYNCML_DM_FILE_TYPE_T eFileType)
+{
+
+ if ( m_nCurrentLockID == m_nLockWithConfig_ID[eFileType] )
+ return; // already locked by us
+
+ DMString strPrincipal = m_pTree->GetServerId();
+ int nCurID = m_nCurrentLockID;
+ DMLockContext ctx;
+
+ // temporary unlock the tree cs, unregister context to prevent expiration of it and wait for acl lock
+ if ( !m_mapContexts.lookup( nCurID, ctx ) )
+ {
+ XPL_LOG_DM_TMN_Debug(("DM: ACL locking internal error!\n"));
+ return; // some error happened
+ }
+ m_mapContexts.remove(nCurID);
+ UnlockTNM();
+
+#ifndef DM_NO_LOCKING
+ // acquire lock
+ m_oLockManager.AcquireFile( eFileType );
+
+ // restore state
+ m_csTNMLock.Enter();
+#endif
+ m_mapContexts.put( nCurID, ctx );
+ m_pTree->SetServerId( strPrincipal ); // substitute principal
+ m_nCurrentLockID = nCurID;
+ m_nLockWithConfig_ID[eFileType] = nCurID;
+}
+
+
+void DMLockContextManager::CheckMemoryAging()
+{
+ if ( m_nAgingTime <= 0 )
+ return;
+
+#ifndef DM_NO_LOCKING
+ DMSingleLock oLock(m_csTNMLock);
+ if ( m_mapContexts.size() == 0 )
+ {
+#else
+ if ( m_nMemoryTimer != XPL_CLK_HANDLE_INVALID && !m_bIsLocked )
+ {
+ XPL_CLK_StopTimer(m_nMemoryTimer);
+ m_nMemoryTimer = XPL_CLK_HANDLE_INVALID;
+#endif
+ SyncML_DM_Archiver& oArchiver = m_pTree->GetArchiver();
+ oArchiver.CheckMemoryAging(m_nAgingTime);
+
+ DMPluginManager & oPluginManager = m_pTree->GetPluginManager();
+ oPluginManager.CheckPluginAging(m_nAgingTime);
+ }
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmLockingHelper.cc b/engine/dmlib/dmengine/dm_ua/src/dmLockingHelper.cc
new file mode 100644
index 0000000..f209992
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmLockingHelper.cc
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: LockingHelper.cc
+
+ General Description: Implementation of the locking helper classes
+
+==================================================================================================*/
+
+#include "dm_tree_class.H"
+#include "dmtTreeImpl.hpp"
+#include "dmLockingHelper.h"
+
+#ifndef DM_NO_LOCKING
+BOOLEAN DMGlobalOMAWorkspaceSharing::m_bWorkspaceLocked = FALSE;
+DMCriticalSection DMGlobalOMAWorkspaceSharing::m_csInitLock;
+#endif
+
+DMGlobalOMAWorkspaceSharing::DMGlobalOMAWorkspaceSharing()
+{
+#ifndef DM_NO_LOCKING
+ while ( true ) {
+ {
+ DMSingleLock oLock(m_csInitLock);
+
+ if ( !m_bWorkspaceLocked ){
+ m_bWorkspaceLocked = TRUE;
+ break;
+ }
+ }
+ DmThSleep( 1000 );
+ }
+#else
+ dmTreeObj.GetLockContextManager().Lock();
+#endif
+}
+
+DMGlobalOMAWorkspaceSharing::~DMGlobalOMAWorkspaceSharing()
+{
+#ifndef DM_NO_LOCKING
+ DMSingleLock oLock(m_csInitLock);
+ m_bWorkspaceLocked = FALSE;
+#else
+ dmTreeObj.GetLockContextManager().UnLock();
+#endif
+}
+
+
+DMGlobalLockHelper::DMGlobalLockHelper()
+{
+ dmTreeObj.GetLockContextManager().GlobalLock();
+}
+
+DMGlobalLockHelper::~DMGlobalLockHelper()
+{
+ dmTreeObj.GetLockContextManager().GlobalUnlock();
+}
+
+
+BOOLEAN DMLockingHelper::Lock( INT32 nCurID,
+ CPCHAR szURI,
+ CPCHAR szPrincipal,
+ SYNCML_DM_TREE_LOCK_TYPE_T eLockType,
+ BOOLEAN bInTransaction )
+{
+ if ( SYNCML_DM_LOCKID_IGNORE == nCurID )
+ {
+ m_nLockID = nCurID; m_nError = SYNCML_DM_SUCCESS; m_bIDChanged = FALSE;
+ return FALSE;
+ }
+
+ m_nLockID = nCurID;
+
+ m_nError = dmTreeObj.GetLockContextManager().ValidateAndLockTNM( m_nLockID,
+ szURI,
+ szPrincipal,
+ eLockType,
+ bInTransaction );
+
+ m_bIDChanged = (nCurID != m_nLockID);
+ return m_nError == SYNCML_DM_SUCCESS;
+}
+
+
+
+DMLockingHelper::DMLockingHelper(DmtTreeImpl* pTree,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType )
+{
+ if ( nLockType == SYNCML_DM_LOCK_TYPE_EXCLUSIVE &&
+ pTree->m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ {
+ m_nError = SYNCML_DM_TREE_READONLY;
+ return;
+ }
+
+ if ( Lock( pTree->m_nLockID,
+ pTree->m_strRootPath,
+ pTree->m_strServerID,
+ nLockType,
+ pTree->m_isAtmoic ) )
+ pTree->m_nLockID = GetID();
+}
+
+DMLockingHelper::~DMLockingHelper()
+{
+ if ( SYNCML_DM_LOCKID_IGNORE != m_nLockID && m_nError == SYNCML_DM_SUCCESS )
+ {
+ dmTreeObj.GetLockContextManager().UnlockTNM();
+ }
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmMetaDataBuffer.cc b/engine/dmlib/dmengine/dm_ua/src/dmMetaDataBuffer.cc
new file mode 100644
index 0000000..8d00b2f
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmMetaDataBuffer.cc
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmMetaDataBuffer.cc
+
+ General Description: Implementation of the DMMetaDataBuffer class
+
+==================================================================================================*/
+
+#include "dm_uri_utils.h"
+#include "dmStringUtil.h"
+#include "dmMetaDataBuffer.h"
+
+UINT32 DMMetaDataBuffer::m_bCorrupted = 0; // due to multiple passing by value, it's reasonable to use static
+
+
+DMMetaDataBuffer::DMMetaDataBuffer()
+ {
+ m_pBuffer = NULL;
+ m_nOffset = 0;
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ m_nFilesSize = 0;
+#endif
+ }
+
+DMMetaDataBuffer::DMMetaDataBuffer(MDF_BUFFER_T pBuffer)
+ {
+ m_pBuffer = pBuffer;
+ m_nOffset = 0;
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ m_nFilesSize = ReadUINT32();
+ m_nOffset = 0;
+#endif
+ }
+
+
+
+CPCHAR DMMetaDataBuffer::ReadString()
+{
+ UINT32 offset = ReadUINT32();
+
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ if ( offset >= m_nFilesSize ) {
+ m_bCorrupted = 1;
+ return "";
+ }
+#endif
+ CPCHAR str = (CPCHAR)(m_pBuffer + offset);
+ return str;
+}
+
+
+UINT16 DMMetaDataBuffer::ReadUINT16()
+{
+ UINT16 value = 0;
+
+ for (UINT32 i=0; i<sizeof(UINT16); i++)
+ {
+ value |= (*(m_pBuffer+m_nOffset)) << (i*8);
+ m_nOffset++;
+ }
+ return value;
+ }
+
+
+UINT32 DMMetaDataBuffer::ReadUINT32()
+{
+ UINT32 value = 0;
+
+ for (int i=0; i<sizeof(UINT32); i++)
+ {
+ value |= (*(m_pBuffer + m_nOffset)) << (i*8);
+ m_nOffset++;
+ }
+ return value;
+}
+
+FLOAT DMMetaDataBuffer::ReadFLOAT()
+{
+ FLOAT value = 0;
+ UINT8 *ptr = (UINT8 *)&value;
+ UINT8 len = sizeof(FLOAT) - 1;
+
+ for (int i=0; i<=len; i++)
+ {
+ *(ptr+i) = *(m_pBuffer+m_nOffset);
+ m_nOffset++;
+ }
+
+ return value;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmMetaDataManager.cc b/engine/dmlib/dmengine/dm_ua/src/dmMetaDataManager.cc
new file mode 100644
index 0000000..548da66
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmMetaDataManager.cc
@@ -0,0 +1,2037 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: DMMetaDataManager.cc
+
+ General Description: Implementation of the DMMetaDataManager class
+
+==================================================================================================*/
+
+#include "dmStringUtil.h"
+#include "dm_tree_util.h"
+#include "dm_uri_utils.h"
+#include "xpl_Logger.h"
+#include "xpl_dm_Manager.h"
+#include "dm_tree_plugin_util.H"
+#include "dm_tree_plugin_root_node_class.H"
+#include "dmMetaDataManager.h"
+#include "xpl_Regex.h"
+
+CPCHAR DMMetaDataManager::m_pFloatPattern[] =
+{
+ "^[+-]?[0-9]+[.]?[0-9]*[Ee]?[+-]?[0-9]*$", // ±dE±n or ±de±n
+ "^[+-,0-9,Ee,.]*[Ee+-.]$", // ends in character 'E' 'e' '+' '-'
+ "^[^Ee]+[+-][0-9]$" // '±' is not following 'E' or 'e'
+};
+
+CPCHAR DMMetaDataManager::m_pDatePattern[] =
+{
+ "^[0-9]{4}-[0-9]{2}-[0-9]{2}$", // YYYY-MM-DD
+ "^[0-9]{4}-[0-9]{2}$", // YYYY-MM
+ "^[0-9]{4}-[0-9]{3}$", //YYY-DDD
+ "^[0-9]{4}-[W][0-9]{2}-[1-7]$", //YYYY-Wxx-d
+ "^[0-9]{4}-[W][0-9]{2}$", //YYYY-Wxx
+ "^[0-9]{8}$", //YYYYMMDD
+ "^[0-9]{6}$", //YYYYMM
+ "^[0-9]{7}$", //YYYDDD
+ "^[0-9]{4}$", // YYYY
+ "^[0-9]{4}[W][0-9]{2}[1-7]$", //YYYYWxxd
+ "^[0-9]{4}[W][0-9]{2}$" //YYYYWxx
+};
+
+CPCHAR DMMetaDataManager::m_pTimePattern[] =
+{
+ "^[0-9]{2}:[0-9]{2}:[0-9]{2}$", //hh:mm:ss
+ "^[0-9]{2}:[0-9]{2}$", //hh:mm
+ "^[0-9]{6}$", //hhmmss
+ "^[0-9]{4}$", //hhmm
+ "^[0-9]{2}$", //hh
+ "^[0-9]{2}:[0-9]{2}:[0-9]{2}Z$", //hh:mm:ssZ
+ "^[0-9]{2}:[0-9]{2}:[0-9]{2}[+-][0-9]{2}:[0-9]{2}$" //hh:mm:ss±hh:mm
+};
+
+DMMetaDataManager::DMMetaDataManager()
+ : m_pEnv( NULL ),
+ m_pTree( NULL ),
+ m_bIsLoad( FALSE )
+{
+}
+
+SYNCML_DM_RET_STATUS_T DMMetaDataManager::Init( CEnv* env, DMTree* tree )
+{
+ if( !env || !tree ) return SYNCML_DM_FAIL;
+ m_pEnv = env;
+ m_pTree = tree;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+void DMMetaDataManager::DeInit()
+{
+ UnLoad();
+ m_pEnv = NULL;
+ m_pTree = NULL;
+}
+
+DMMetaDataManager::~DMMetaDataManager()
+{
+ DeInit();
+}
+
+
+void
+DMMetaDataManager::UnLoad()
+{
+ if(m_bIsLoad == FALSE)
+ return;
+
+ XPL_LOG_DM_TMN_Debug(("UNLOAD\n"));
+#ifndef DM_STATIC_FILES
+ UINT32 size = m_oDDFInfo.size();
+ for (UINT32 i=0; i<size; i++)
+ {
+ DMFileHandler * pFile = (DMFileHandler*)m_oDDFInfo[i];
+ delete pFile;
+ }
+#endif
+ m_oDDFInfo.clear();
+ m_bIsLoad = FALSE;
+ m_oLastNodeLocator.Init();
+}
+
+CPCHAR
+DMMetaDataManager::GetNodeName(DMNode* pNode, CPCHAR szURI)
+{
+ if ( pNode->isPlugin() )
+ {
+ DMURI uri(FALSE,szURI);
+ return uri.getLastSegment();
+ } else
+ return pNode->abNodeName.GetBuffer();
+}
+
+
+BOOLEAN
+DMMetaDataManager::VerifyChildDependency(CPCHAR szNodeName,
+ CPCHAR szURI,
+ CPCHAR szOrigName,
+ SYNCML_DM_MDF_CBACK callBackSoft,
+ SYNCML_DM_MDF_CBACK callBackHard,
+ SYNCML_DM_ACCESS_TYPE_T accessType)
+{
+ DMMetaDataNode oNodeMDF;
+ DMConstraints *pConstraints = NULL;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ ret_status = GetNode(szURI, FALSE, oNodeMDF);
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ {
+ return FALSE;
+ }
+ if ( oNodeMDF.m_nNodeFormat == SYNCML_DM_FORMAT_TEST )
+ return TRUE;
+
+ pConstraints = oNodeMDF.GetConstraints();
+ if ( !pConstraints )
+ return TRUE;
+
+ if( pConstraints->m_psChild != 0 )
+ {
+ if( !VerifyDependency(szNodeName,pConstraints->m_psChild,szOrigName,callBackHard) )
+ return FALSE;
+ }
+ if( pConstraints->m_psDepend != 0 )
+ {
+ if( !VerifyDependency(szNodeName,pConstraints->m_psDepend,szOrigName,callBackSoft) )
+ return FALSE;
+ }
+ return TRUE;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyDeleteParameters(DMNode* pNode, CPCHAR szURI)
+
+{
+ DMMetaDataNode oNodeMDF;
+ CPCHAR strNodeName;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ strNodeName = GetNodeName(pNode,szURI);
+ if(strNodeName == NULL)
+ return SYNCML_DM_COMMAND_FAILED;
+ if (!VerifyChildDependency(strNodeName,szURI,NULL,ClearNodeValue,CheckFieldInUse,SYNCML_DM_DELETE_ACCESS_TYPE))
+ return SYNCML_DM_COMMAND_FAILED;
+ return ret_status;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyData(DMAddData & oAddData)
+
+{
+
+ if( !oAddData.m_oData.getSize() )
+ return SYNCML_DM_SUCCESS;
+
+ switch ( oAddData.m_nFormat )
+ {
+ case SYNCML_DM_FORMAT_INT:
+ if ( !IsDigit(oAddData.m_oData) )
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ break;
+
+ case SYNCML_DM_FORMAT_FLOAT:
+ if ( !IsFloat(oAddData.m_oData) )
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ break;
+
+ case SYNCML_DM_FORMAT_DATE:
+ if ( !IsDate(oAddData.m_oData) )
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ break;
+
+ case SYNCML_DM_FORMAT_TIME:
+ if ( !IsTime(oAddData.m_oData) )
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ break;
+
+ case SYNCML_DM_FORMAT_BOOL:
+ if ( !IsBoolean(oAddData.m_oData) )
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ break;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyFormat(const DMMetaDataNode & oNodeMDF,
+ DMAddData & oAddData)
+
+{
+
+ if ( m_pTree->IsVersion_12() == FALSE )
+ {
+ if ( oAddData.m_nFormat == SYNCML_DM_FORMAT_FLOAT ||
+ oAddData.m_nFormat == SYNCML_DM_FORMAT_DATE ||
+ oAddData.m_nFormat == SYNCML_DM_FORMAT_TIME )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyFormat: format not supported: float,data, time\n"));
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ }
+ }
+
+
+ if ( oNodeMDF.m_nNodeFormat == SYNCML_DM_FORMAT_TEST )
+ return SYNCML_DM_SUCCESS;
+
+ if ( oAddData.m_nFormat != SYNCML_DM_FORMAT_INVALID &&
+ oAddData.m_nFormat != SYNCML_DM_FORMAT_NULL )
+ {
+ if (oNodeMDF.m_nNodeFormat != oAddData.m_nFormat)
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyFormat: unsupported mediatype: %d != %d\n", oNodeMDF.m_nNodeFormat, oAddData.m_nFormat));
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ }
+ }
+
+ if( oNodeMDF.VerifyMimeType(oAddData.getType()) != TRUE )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyFormat: verify mime type failed\n"));
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyInteger(const DMBuffer & oData)
+{
+
+ if ( !oData.getSize() )
+ return SYNCML_DM_SUCCESS;
+
+ INT32 int_value = 0;
+ char numbuf[MAX_INT_STRING_LENGTH];
+
+ int_value = DmAtoi((CPCHAR)oData.getBuffer());
+
+ DmSprintf( numbuf, "%d", int_value );
+ if ( DmStrcmp(numbuf, (CPCHAR)oData.getBuffer()) != 0 )
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyInteriorNodeConstraints(DMConstraints *pConstraints,
+ CPCHAR szNodeName)
+
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if( pConstraints->m_nnMaxLen < DmStrlen(szNodeName) )
+#ifdef DM_NO_REGEX
+ return SYNCML_DM_REQUEST_ENTITY_TOO_LARGE;
+#else
+ return SYNCML_DM_URI_TOO_LONG;
+#endif
+
+ if(VerifynValues(pConstraints, szNodeName) != TRUE)
+ return SYNCML_DM_COMMAND_FAILED;
+
+ if( pConstraints->m_psnRegexp != NULL)
+ dm_stat = VerifyRegExp(pConstraints->m_psnRegexp,szNodeName);
+
+ return dm_stat;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::SetDefaultValue(const DMMetaDataNode & oNodeMDF,
+ DMAddData & oAddData)
+{
+ DMConstraints *pConstraints = NULL;
+
+ pConstraints = oNodeMDF.GetConstraints();
+
+ if ( pConstraints == NULL )
+ return SYNCML_DM_SUCCESS;
+
+ if( !pConstraints->IsDefaultSet() )
+ return(SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT);
+
+ if(oNodeMDF.m_nNodeFormat == SYNCML_DM_FORMAT_INVALID)
+ return(SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT);
+
+ DMString strDefaultValue;
+ pConstraints->GetDefaultString(strDefaultValue);
+ if ( strDefaultValue.GetBuffer() )
+ {
+ oAddData.m_oData.assign(strDefaultValue);
+ if ( oAddData.m_oData.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ oAddData.m_nFormat = oNodeMDF.m_nNodeFormat;
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyLeafNodeConstraints(const DMMetaDataNode & oNodeMDF,
+ DMAddData & oAddData)
+
+{
+ DMConstraints *pConstraints = NULL;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ pConstraints = oNodeMDF.GetConstraints();
+
+ if ( pConstraints == NULL )
+ return SYNCML_DM_SUCCESS;
+
+#ifdef LOB_SUPPORT
+ // ESN only support SYNCML_DM_FORMAT_BIN and SYNCML_DM_FORMAT_STRING
+ if(oNodeMDF.IsESN())
+ {
+ if ( oAddData.m_nFormat != SYNCML_DM_FORMAT_CHR &&
+ oAddData.m_nFormat != SYNCML_DM_FORMAT_BIN)
+ return(SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT);
+ }
+#endif
+
+ if(pConstraints->m_nMaxLen < oAddData.m_oData.getSize())
+ return SYNCML_DM_REQUEST_ENTITY_TOO_LARGE;
+
+ if (pConstraints->m_nMinLen > oAddData.m_oData.getSize())
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+
+ if ( oAddData.m_nFormat == SYNCML_DM_FORMAT_INT )
+ {
+ INT32 int_value = 0;
+ if ( oAddData.m_oData.getSize() )
+ int_value = DmAtoi(oAddData.getCharData());
+
+ if((pConstraints->m_nMin > int_value) || (pConstraints->m_nMax < int_value))
+ return SYNCML_DM_COMMAND_FAILED;
+
+ }
+
+ if (pConstraints->m_psValues != NULL )
+ {
+ if ( oAddData.m_nFormat != SYNCML_DM_FORMAT_NULL )
+ {
+ if(!VerifyValues(pConstraints, oAddData.m_nFormat, oAddData.m_oData))
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+ else
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+
+ if ( pConstraints->m_psForeignKey != NULL )
+ {
+ if ( oAddData.m_nFormat != SYNCML_DM_FORMAT_NULL )
+ {
+ if(!VerifyForeignKey(pConstraints, oAddData.m_oData))
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+ else
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+
+ if( pConstraints->m_psRegexp != NULL)
+ {
+ if ( oAddData.m_nFormat != SYNCML_DM_FORMAT_NULL )
+ {
+ dm_stat = VerifyRegExp(pConstraints->m_psRegexp,oAddData.getCharData());
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ return(SYNCML_DM_COMMAND_FAILED);
+ }
+ else
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+
+ return dm_stat;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyConstraints(const DMMetaDataNode & oNodeMDF,
+ DMNode* pNode,
+ CPCHAR szNodeName,
+ DMAddData & oAddData)
+
+{
+ DMConstraints *pConstraints = NULL;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ pConstraints = oNodeMDF.GetConstraints();
+
+ if ( pConstraints == NULL )
+ return SYNCML_DM_SUCCESS;
+
+ dm_stat = VerifyInteriorNodeConstraints(pConstraints,szNodeName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+
+ if ( oNodeMDF.m_nNodeFormat == SYNCML_DM_FORMAT_TEST )
+ return SYNCML_DM_SUCCESS;
+
+ if ( oAddData.m_nFormat == SYNCML_DM_FORMAT_INVALID )
+ dm_stat = SetDefaultValue(oNodeMDF,oAddData);
+ else
+ if ( oAddData.m_nFormat != SYNCML_DM_FORMAT_NODE )
+ dm_stat = VerifyLeafNodeConstraints(oNodeMDF, oAddData);
+ else
+ if ( oAddData.m_nFormat == SYNCML_DM_FORMAT_NULL && oAddData.m_oData.getSize() )
+ return SYNCML_DM_COMMAND_FAILED;
+
+ return dm_stat;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyParameters(const DMMetaDataNode & oNodeMDF,
+ DMNode* pNode,
+ CPCHAR szNodeName,
+ DMAddData & oAddData)
+
+{
+ DMConstraints *pConstraints = NULL;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ dm_stat = VerifyFormat(oNodeMDF,oAddData);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyParameters: verify format failed \n"));
+ return dm_stat;
+ }
+
+ dm_stat = VerifyData(oAddData);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyParameters: verify data failed \n"));
+ return dm_stat;
+ }
+
+ pConstraints = oNodeMDF.GetConstraints();
+
+ if ( !pConstraints )
+ {
+ if ( oAddData.m_nFormat == SYNCML_DM_FORMAT_INVALID ||
+ oAddData.m_nFormat == SYNCML_DM_FORMAT_NULL )
+ oAddData.m_nFormat = oNodeMDF.m_nNodeFormat;
+ }
+
+ if ( oAddData.m_nFormat == SYNCML_DM_FORMAT_INT )
+ {
+ dm_stat = VerifyInteger(oAddData.m_oData);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyParameters: verify Integer failed \n"));
+ return dm_stat;
+ }
+ }
+
+ if ( pConstraints )
+ dm_stat = VerifyConstraints(oNodeMDF,pNode,szNodeName,oAddData);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyParameters: verify Constraits failed \n"));
+ }
+
+ return dm_stat;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyReplaceParameters(DMNode* pNode,
+ CPCHAR szURI,
+ DMAddData & oAddData,
+ CPCHAR szOrigName)
+
+{
+ DMMetaDataNode oNodeMDF;
+ CPCHAR strNodeName;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_TMN_Debug(("Enter to DMMetaDataManager::VerifyReplaceParameters %s\n",szURI));
+
+ ret_status = GetNode(szURI, FALSE, oNodeMDF);
+ XPL_LOG_DM_TMN_Error(("From VerifyReplaceParameters(): Call to GetNode() returns %d \n", ret_status));
+
+ if(ret_status == SYNCML_DM_NOT_FOUND)
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+
+ else if(ret_status != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_COMMAND_FAILED;
+
+#ifdef LOB_SUPPORT
+ // ESN only only be created using empty data
+ if(oNodeMDF.IsESN() && oAddData.m_oData.getSize() )
+ return(SYNCML_DM_COMMAND_FAILED);
+#endif
+
+ strNodeName = GetNodeName(pNode,szURI);
+ if(strNodeName == NULL){
+ XPL_LOG_DM_TMN_Error(("From VerifyReplaceParameters(): call getNode().... strNodeName == NULL"));
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+ ret_status = VerifyParameters(oNodeMDF,pNode,strNodeName,oAddData);
+ XPL_LOG_DM_TMN_Error(("From VerifyReplaceParameters(): Call to VerifyParameters() returns %d \n", ret_status));
+
+ if(ret_status != SYNCML_DM_SUCCESS)
+ return ret_status;
+
+ if(szOrigName == NULL)
+ return ret_status;
+
+ if ( oNodeMDF.m_nNodeFormat == SYNCML_DM_FORMAT_TEST )
+ return SYNCML_DM_SUCCESS;
+
+ if (!VerifyChildDependency(strNodeName, szURI, szOrigName, ResetNodeValue, ResetNodeValue,
+ SYNCML_DM_REPLACE_ACCESS_TYPE)) {
+ XPL_LOG_DM_TMN_Error(("From VerifyReplaceParameters(): Call to VerifyChildDependency() returns FALSE"));
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+ return ret_status;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyAddParameters(DMNode* pNode,
+ DMAddData & oAddData,
+ DMToken & oAutoNodes,
+ BOOLEAN & bNodeGetAccess)
+{
+ DMMetaDataNode oNodeMDF;
+ CPCHAR strNodeName;
+ DMConstraints *pConstraints = NULL;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_TMN_Debug(("Enter to DMMetaDataManager::VerifyAddParameters %s\n",oAddData.getURI()));
+
+ ret_status = GetNode(oAddData.getURI(), FALSE, oNodeMDF);
+ if(ret_status != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyAddParameters: failed to get node MDF.\n"));
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+
+#ifdef LOB_SUPPORT
+ // ESN only only be created using empty data
+ if(oNodeMDF.IsESN() && oAddData.m_oData.getSize() )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyAddParameters: ESN, but not empty\n"));
+ return(SYNCML_DM_COMMAND_FAILED);
+ }
+#endif
+ strNodeName = GetNodeName(pNode,oAddData.getURI());
+ if(strNodeName == NULL)
+ return SYNCML_DM_COMMAND_FAILED;
+ ret_status = VerifyParameters(oNodeMDF,pNode,strNodeName,oAddData);
+ if(ret_status != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyAddParameters: failed to get verify parameters.\n"));
+ return ret_status;
+ }
+
+ bNodeGetAccess = oNodeMDF.VerifyAccessType(SYNCML_DM_GET_ACCESS_TYPE);
+
+ if (oNodeMDF.m_nNodeFormat == SYNCML_DM_FORMAT_NODE )
+ {
+ pConstraints = oNodeMDF.GetConstraints();
+ if ( pConstraints && pConstraints->m_psAutoNodes )
+ {
+ oAutoNodes.assign(pConstraints->m_psAutoNodes);
+ if ( !oAutoNodes.getBuffer() )
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyAddParameters: failed to get verify Access Type.\n"));
+ return SYNCML_DM_COMMAND_FAILED;
+ }
+ }
+ return ret_status;
+}
+
+
+
+BOOLEAN
+DMMetaDataManager::IsDigit(const DMBuffer & oData)
+{
+ INT32 start_index = 0;
+ UINT8 *pData = oData.getBuffer();
+
+ if (pData[0] == '-' || pData[0] == '+')
+ start_index++;
+
+ for (UINT32 i=start_index; i<oData.getSize(); i++)
+ {
+ if (pData[i]<0x30 || pData[i]>0x39)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+BOOLEAN
+DMMetaDataManager::IsBoolean(const DMBuffer & oData)
+{
+ INT32 size = oData.getSize();
+ UINT8 *pData = oData.getBuffer();
+
+ if(size < 4 && size > 5)
+ return FALSE;
+
+ char str[6];
+
+ for (int i=0; i<size; i++)
+ str[i] = DmTolower((char)pData[i]);
+ str[size] = SYNCML_DM_NULL;
+
+ if ( DmStrcmp(str,"true") == 0 || DmStrcmp(str, "false") == 0 )
+ return TRUE;
+
+ return FALSE;
+}
+
+
+BOOLEAN
+DMMetaDataManager::IsFloat(const DMBuffer & oData)
+{
+#ifdef DM_NO_REGEX
+
+ return ::XPL_RG_Comp( XPL_RG_PATTERN_IS_FLOAT, (CPCHAR)oData.getBuffer() )
+ ? SYNCML_DM_SUCCESS
+ : SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+#else
+
+ // Validate float string with XML 1.0 regular express
+ if (VerifyRegExp((CPCHAR)m_pFloatPattern[0], (CPCHAR)oData.getBuffer())
+ != SYNCML_DM_SUCCESS)
+ {
+ return FALSE;
+ }
+ else
+ {
+ // Float string ends with 'E', 'e', '+' '-' or '.' character.
+ if (VerifyRegExp((CPCHAR)m_pFloatPattern[1], (CPCHAR)oData.getBuffer())
+ == SYNCML_DM_SUCCESS)
+ {
+ return FALSE;
+ }
+ else
+ {
+ // '+' or '-' character is not next to 'E' or 'e'.
+ if (VerifyRegExp((CPCHAR)m_pFloatPattern[2], (CPCHAR)oData.getBuffer())
+ == SYNCML_DM_SUCCESS)
+ {
+ return FALSE;
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+ }
+
+ return TRUE;
+
+#endif
+}
+
+
+BOOLEAN
+DMMetaDataManager::IsDate(const DMBuffer & oData)
+{
+#ifdef DM_NO_REGEX
+ return ::XPL_RG_Comp( XPL_RG_PATTERN_IS_DATE, (CPCHAR)oData.getBuffer() )
+ ? SYNCML_DM_SUCCESS
+ : SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+#else
+
+ for (UINT8 i=0; i<sizeof(m_pDatePattern)/sizeof(int); i++)
+ {
+ if (VerifyRegExp(m_pDatePattern[i],(CPCHAR)oData.getBuffer())==SYNCML_DM_SUCCESS)
+ {
+ CPCHAR pData = (CPCHAR)oData.getBuffer();
+ switch (i)
+ {
+ case 0: // YYYY-MM-DD
+ if ((DmStrncmp(pData+5,"01",2)<0 || DmStrncmp(pData+5,"12",2)>0)||
+ (DmStrncmp(pData+8,"01",2)<0 || DmStrncmp(pData+8,"31",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 1: // YYYY-MM
+ if ((DmStrncmp(pData+5,"01",2)<0 || DmStrncmp(pData+5,"12",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 2: // YYYY-DDD
+ if ((DmStrncmp(pData+5,"001",3)<0 || DmStrncmp(pData+5,"366",3)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 3: // YYYY-Wxx-d
+ case 4: // YYYY-Wxx
+ if ((DmStrncmp(pData+6,"01",2)<0 || DmStrncmp(pData+6,"52",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 5: // YYYYMMDD
+ if ((DmStrncmp(pData+4,"01",2)<0 || DmStrncmp(pData+4,"12",2)>0)||
+ (DmStrncmp(pData+6,"01",2)<0 || DmStrncmp(pData+6,"31",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 6: // YYYYMM
+ if ((DmStrncmp(pData+4,"01",2)<0 || DmStrncmp(pData+4,"12",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 7: // YYYYDDD
+ if ((DmStrncmp(pData+4,"001",3)<0 || DmStrncmp(pData+4,"365",3)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 8: // YYYY
+ return TRUE;
+ case 9: // YYYYWxxd
+ case 10: // YYYYWxx
+ if ((DmStrncmp(pData+5,"01",2)<0 || DmStrncmp(pData+5,"52",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ }
+ }
+
+ return FALSE;
+
+#endif
+}
+
+
+BOOLEAN
+DMMetaDataManager::IsTime(const DMBuffer & oData)
+{
+#ifdef DM_NO_REGEX
+ return ::XPL_RG_Comp( XPL_RG_PATTERN_IS_TIME, (CPCHAR)oData.getBuffer() )
+ ? SYNCML_DM_SUCCESS
+ : SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+#else
+
+ for (UINT8 i=0; i<sizeof(m_pTimePattern)/sizeof(int); i++)
+ {
+ if (VerifyRegExp(m_pTimePattern[i], (CPCHAR)oData.getBuffer()) == SYNCML_DM_SUCCESS)
+ {
+ CPCHAR pData = (CPCHAR)oData.getBuffer();
+ // Validate hour
+ if ((DmStrncmp(pData,"00",2)<0 || DmStrncmp(pData,"23",2)>0))
+ return FALSE;
+
+ switch (i)
+ {
+ case 0: // hh:mm:ss
+ case 5: // hh:mm:ssZ
+ if ((DmStrncmp(pData+3,"00",2)<0 || DmStrncmp(pData+3,"59",2)>0) ||
+ (DmStrncmp(pData+6,"00",2)<0 || DmStrncmp(pData+6,"59",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 1: // hh:mm
+ if ((DmStrncmp(pData+3,"00",2)<0 || DmStrncmp(pData+3,"59",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 2: // hhmmss
+ if ((DmStrncmp(pData+2,"00",2)<0 || DmStrncmp(pData+2,"59",2)>0)||
+ (DmStrncmp(pData+4,"00",2)<0 || DmStrncmp(pData+4,"59",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 3: // hhmm
+ if ((DmStrncmp(pData+2,"00",2)<0 || DmStrncmp(pData+2,"59",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ case 4: // hh
+ return TRUE;
+ case 6: // hh:mm:ss±hh:mm
+ if ((DmStrncmp(pData,"00",2)<0 || DmStrncmp(pData,"23",2)>0)||
+ (DmStrncmp(pData+3,"00",2)<0 || DmStrncmp(pData+3,"59",2)>0)||
+ (DmStrncmp(pData+6,"00",2)<0 || DmStrncmp(pData+6,"59",2)>0)||
+ (DmStrncmp(pData+9,"00",2)<0 || DmStrncmp(pData+9,"23",2)>0)||
+ (DmStrncmp(pData+12,"00",2)<0 || DmStrncmp(pData+12,"59",2)>0))
+ return FALSE;
+ else
+ return TRUE;
+ default:
+ return FALSE;
+ }
+ }
+ }
+
+ return FALSE;
+
+#endif
+}
+
+BOOLEAN
+DMMetaDataManager::VerifynValues(DMConstraints *pConstraints, const DMString & oNodeName)
+{
+
+ if ( pConstraints->m_psnValues == NULL )
+ return TRUE;
+
+ DMToken oValues(TRUE,pConstraints->m_psnValues,SYNCML_DM_COMMA);
+ CPCHAR sName = NULL;
+
+ while ( (sName = oValues.nextSegment()) != NULL )
+ if( oNodeName == sName )
+ return TRUE;
+ return FALSE;
+}
+
+
+BOOLEAN
+DMMetaDataManager::VerifyValues(DMConstraints *pConstraints, SYNCML_DM_FORMAT_T format, const DMBuffer & oData)
+{
+ CPCHAR sValue = NULL;
+
+ if (pConstraints->m_psValues == NULL)
+ return TRUE;
+
+ DMToken oValues(TRUE,pConstraints->m_psValues,SYNCML_DM_COMMA);
+ sValue = oValues.nextSegment();
+
+ while ( sValue )
+ {
+ switch(format)
+ {
+ case SYNCML_DM_FORMAT_INT:
+ if(DmAtoi((CPCHAR)oData.getBuffer()) == DmAtoi(sValue))
+ return TRUE;
+ break;
+
+ case SYNCML_DM_FORMAT_CHR:
+ case SYNCML_DM_FORMAT_FLOAT:
+ case SYNCML_DM_FORMAT_DATE:
+ case SYNCML_DM_FORMAT_TIME:
+ if( oData.compare(sValue) == TRUE )
+ return TRUE;
+ break;
+
+ default:
+ return TRUE;
+ break;
+ }
+ sValue = oValues.nextSegment();
+ }
+
+ return FALSE;
+
+}
+
+
+BOOLEAN
+DMMetaDataManager::VerifyForeignKey(DMConstraints * pConstraints, const DMBuffer & oData)
+{
+ if (pConstraints->m_psForeignKey == NULL)
+ return TRUE;
+
+ DMGetData getData;
+ DMString strURI = pConstraints->m_psForeignKey;
+ DMString strName( (const char*)oData.getBuffer(), oData.getSize() );
+
+ strURI += "/";
+ strURI += strName;
+
+ /* Retrieve the child node names from the DM Tree.*/
+
+ if( SYNCML_DM_SUCCESS != m_pTree->Get(strURI,getData,SYNCML_DM_REQUEST_TYPE_INTERNAL) )
+ return FALSE;
+
+ return TRUE;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::VerifyRegExp(CPCHAR sPattern, CPCHAR sData)
+{
+ BOOLEAN reg_status = FALSE;
+
+#ifndef DM_NO_REGEX
+ reg_status = XPL_RG_Comp(sPattern, sData);
+#endif
+ if ( reg_status )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+}
+
+#ifndef DM_STATIC_FILES
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::LoadBuffer(CPCHAR pPath)
+{
+ DMFileHandler *fp;
+
+ fp = new DMFileHandler(pPath,FALSE);
+ if ( fp == NULL )
+ return SYNCML_DM_FAIL;
+
+ if(fp->open(XPL_FS_FILE_READ) != SYNCML_DM_SUCCESS)
+ {
+ DMFileHandler::operator delete (fp);
+ return SYNCML_DM_IO_FAILURE;
+ }
+
+ UINT8 * pBuffer = fp->mmap();
+ if ( !pBuffer )
+ {
+ DMFileHandler::operator delete (fp);
+ return SYNCML_DM_FAIL;
+ }
+
+ if ( pBuffer[0] == '[' && (pBuffer[1] == '/' || pBuffer[1] == '.') )
+ {
+ XPL_LOG_DM_TMN_Error(("BMDF: file %s not recognized as a bmdf file, ignored\n", pPath));
+ DMFileHandler::operator delete (fp);
+ return SYNCML_DM_IO_FAILURE;
+ }
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ {
+ // verify file length
+ DMMetaDataBuffer buf( pBuffer );
+ UINT32 nFileSize = buf.ReadUINT32();
+ int nVersion = buf.ReadUINT16();
+
+ if ( nFileSize!= fp->size() )
+ {
+ XPL_LOG_DM_TMN_Error(("BMDF: file %s size %d mismatch with buffer value %d, ignored\n",pPath,fp->size(),nFileSize));
+ DMFileHandler::operator delete (fp);
+ return SYNCML_DM_IO_FAILURE;
+ }
+ if ( nVersion != CurrentBMDFVersion )
+ {
+ XPL_LOG_DM_TMN_Error(("BMDF: file %s supported version %d mismatch with buffer value %d, ignored\n",
+ pPath, (int)CurrentBMDFVersion, nVersion));
+ DMFileHandler::operator delete (fp);
+ return SYNCML_DM_IO_FAILURE;
+ }
+ }
+#endif
+
+ fp->close();
+ XPL_LOG_DM_TMN_Debug(("LOAD BUFFER %s\n",pPath));
+ m_oDDFInfo.push_back((UINT32)fp);
+ return SYNCML_DM_SUCCESS;
+}
+#else
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::LoadBuffer(UINT32 index)
+{
+ UINT8 * pBuffer;
+ UINT32 size;
+
+ pBuffer = (UINT8*)XPL_DM_GetMDF(index,&size);
+
+ if ( !pBuffer )
+ return SYNCML_DM_FAIL;
+ m_oDDFInfo.push_back((UINT32)pBuffer);
+ return SYNCML_DM_SUCCESS;
+}
+#endif
+
+UINT32
+DMMetaDataManager::FindNodeInChildrenList(DMMetaDataBuffer oBuffer, CPCHAR psName) const
+{
+
+ DMMetaDataNode oNode;
+ DMMetaDataNode oChildrenNode;
+ UINT32 offsetChildren = 0;
+
+ oNode.Read(oBuffer,FALSE);
+ if ( oNode.IsHasMultiNodes() == FALSE )
+ {
+ for (int i=0; i<oNode.m_nNumChildren; i++)
+ {
+ oNode.SetChildrenOffset(&oBuffer,i);
+ offsetChildren = oBuffer.GetOffset();
+ oChildrenNode.ReadName(oBuffer);
+ if ( !DmStrcmp(oChildrenNode.m_psName,psName) )
+ return offsetChildren;
+ }
+ }
+ else
+ {
+ oNode.SetChildrenOffset(&oBuffer,0);
+ return oBuffer.GetOffset();
+ }
+ return 0;
+}
+
+
+CPCHAR
+DMMetaDataManager::BuildSearchURI(CPCHAR szURI,
+ DMMetaDataBuffer & oBuffer,
+ SYNCML_DM_ACCESS_TYPE_T & accessType,
+ DMMetaDataNode & oNode )
+{
+
+ DMParser sURIParser(szURI);
+ CPCHAR sSegment1 = NULL;
+ CPCHAR sSegment2 = NULL;
+
+ UINT16 count1 = sURIParser.getSegmentsCount();
+ UINT16 count2 = m_oLastNodeLocator.m_oLocator.size();
+ UINT16 count = ( count1 > count2 ) ? count2 : count1;
+ UINT32 offset = 0;
+
+
+ for (int i=0 ; i<count; i++)
+ {
+ sSegment1 = (m_oLastNodeLocator.m_oLocator[i]).m_szName;
+ sSegment2 = sURIParser.nextSegment();
+
+ if (sSegment2 != NULL && DmStrcmp(sSegment1,sSegment2) != 0 )
+ {
+ if ( i == 0 )
+ return szURI;
+
+ m_oLastNodeLocator.m_oLocator.set_size(i);
+ oBuffer.SetBuffer(m_oLastNodeLocator.m_pBuffer);
+ offset = (m_oLastNodeLocator.m_oLocator[i-1]).m_nOffset;
+ accessType = (m_oLastNodeLocator.m_oLocator[i-1]).m_wAccessType;
+ oNode.SetPath((m_oLastNodeLocator.m_oLocator[i-1]).m_strPath);
+ oBuffer.SetOffset(offset);
+ return sSegment2;
+ }
+ }
+
+ oBuffer.SetBuffer(m_oLastNodeLocator.m_pBuffer);
+ if ( count2 >= count1 )
+ {
+ offset = (m_oLastNodeLocator.m_oLocator[count1-1]).m_nOffset;
+ accessType = (m_oLastNodeLocator.m_oLocator[count1-1]).m_wAccessType;
+ oNode.SetPath((m_oLastNodeLocator.m_oLocator[count1-1]).m_strPath);
+ oBuffer.SetOffset(offset);
+ return NULL;
+ }
+ else
+ {
+ offset = (m_oLastNodeLocator.m_oLocator[count2-1]).m_nOffset;
+ accessType = (m_oLastNodeLocator.m_oLocator[count2-1]).m_wAccessType;
+ oNode.SetPath((m_oLastNodeLocator.m_oLocator[count2-1]).m_strPath);
+
+ oBuffer.SetOffset(offset);
+ return sURIParser.nextSegment();
+ }
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::SearchNode(CPCHAR szURI,
+ DMMetaDataBuffer oBuffer,
+ SYNCML_DM_ACCESS_TYPE_T parentAccessType,
+ BOOLEAN bCheckMultiNode,
+ DMMetaDataNode & oNode,
+ DMMetaPCharVector* pChildDependNodes )
+{
+
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+ CPCHAR sSegment = NULL;
+ UINT32 nodeOffset = 0;
+ DMURI oURI(FALSE,szURI);
+ BOOLEAN bIsFound = FALSE;
+ DMConstraints * pConstraints = NULL;
+
+
+ sSegment = oURI.nextSegment();
+ while( sSegment != NULL )
+ {
+ nodeOffset = FindNodeInChildrenList(oBuffer,sSegment);
+ if ( nodeOffset == 0 )
+ {
+ oNode.Init();
+ break;
+ }
+
+
+ oBuffer.SetOffset(nodeOffset);
+ oNode.Read(oBuffer,TRUE);
+
+
+ pConstraints = oNode.GetConstraints();
+ if ( pConstraints && pConstraints->m_psRecurAfterSegment )
+ {
+ bIsFound = TRUE;
+ ret_status = RemoveRecursiveSegments((char*)oURI.getTailSegments(),oNode);
+ if ( ret_status == SYNCML_DM_FAIL )
+ {
+ oNode.Init();
+ return ret_status;
+ }
+ }
+
+ if ( pChildDependNodes && pConstraints )
+ {
+ if ( pConstraints->m_psChild )
+ pChildDependNodes->push_back( pConstraints->m_psChild );
+
+ if ( pConstraints->m_psDepend )
+ pChildDependNodes->push_back( pConstraints->m_psDepend );
+ }
+
+ if ( oNode.m_wAccessType == 0 )
+ oNode.SetAccessType(parentAccessType);
+
+ parentAccessType = oNode.m_wAccessType;
+
+ if ( !bIsFound )
+ {
+ oNode.AppendSegment();
+ m_oLastNodeLocator.m_oLocator.push_back(DMMetaNodeLocator(oNode.m_psName,
+ nodeOffset,
+ oNode.m_wAccessType,
+ oNode.GetPath()));
+ }
+
+ sSegment = oURI.nextSegment();
+ if( sSegment == NULL )
+ {
+ if ( bCheckMultiNode )
+ oNode.GetMaxMultiNodeChildren(oBuffer);
+ return SYNCML_DM_SUCCESS;
+ }
+
+ }
+
+ return SYNCML_DM_NOT_FOUND;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::GetRootNode(DMMetaDataNode & oNode)
+{
+ DMMetaDataBuffer oBuffer;
+
+ #ifndef DM_STATIC_FILES
+ DMFileHandler * pFile = (DMFileHandler*)m_oDDFInfo[0];
+ oBuffer.SetBuffer((MDF_BUFFER_T)pFile->mmap());
+#else
+ oBuffer.SetBuffer((MDF_BUFFER_T)m_oDDFInfo[0]);
+#endif
+ oBuffer.SetOffset(BMDFHeaderSize); // file size and version
+ oNode.Read(oBuffer,TRUE);
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+CPCHAR
+DMMetaDataManager::GetStartPos(CPCHAR szURI)
+{
+ switch ( szURI[0] )
+ {
+ case SYNCML_DM_DOT:
+ if (DmStrlen(szURI) >= 3)
+ return &szURI[2];
+ break;
+
+ case SYNCML_DM_FORWARD_SLASH:
+ return NULL;
+
+ default:
+ return szURI;
+ }
+ return NULL;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::FindCacheNode(CPCHAR szURI,
+ BOOLEAN bCheckMultiNode,
+ DMMetaDataNode & oNode,
+ DMMetaDataBuffer & oBuffer,
+ DMMetaPCharVector* pChildDependNodes)
+{
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+ SYNCML_DM_ACCESS_TYPE_T parentAccessType;
+ CPCHAR sStartPos = NULL;
+
+ if ( m_oLastNodeLocator.m_oLocator.size() == 0)
+ return SYNCML_DM_NOT_FOUND;
+
+ sStartPos = BuildSearchURI((CPCHAR)szURI,oBuffer,parentAccessType, oNode);
+ if ( oBuffer.GetBuffer() == NULL )
+ return SYNCML_DM_NOT_FOUND;
+
+ if ( sStartPos == NULL )
+ {
+ ret_status = oNode.Read(oBuffer,TRUE);
+ if ( ret_status == SYNCML_DM_SUCCESS && bCheckMultiNode )
+ ret_status = oNode.GetMaxMultiNodeChildren(oBuffer);
+
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ oNode.Init();
+ else
+ {
+ if ( oNode.m_wAccessType == 0 )
+ oNode.m_wAccessType = parentAccessType;
+ }
+ return ret_status;
+ }
+ ret_status = SearchNode(sStartPos,oBuffer,parentAccessType,bCheckMultiNode,oNode, pChildDependNodes);
+ if ( ret_status == SYNCML_DM_SUCCESS )
+ return ret_status;
+
+ return SYNCML_DM_NOT_FOUND;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::GetNode(CPCHAR szURI,
+ BOOLEAN bCheckMultiNode,
+ DMMetaDataNode & oNode,
+ DMMetaPCharVector* pChildDependNodes /*=NULL*/)
+{
+
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+ DMString sNodeURI;
+
+ ret_status = oNode.AllocatePath(DmStrlen(szURI)+1);
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+
+ oNode.Init();
+
+ if(m_bIsLoad == FALSE)
+ {
+ ret_status = Load();
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+ }
+
+ if ( DmStrcmp(szURI,".") == 0 )
+ return GetRootNode(oNode);
+
+ sNodeURI = GetStartPos(szURI);
+ if ( sNodeURI == NULL )
+ return SYNCML_DM_FAIL;
+
+ DMMetaDataBuffer oBuffer;
+ ret_status = FindCacheNode((CPCHAR)sNodeURI,bCheckMultiNode,oNode,oBuffer,pChildDependNodes);
+ if ( ret_status == SYNCML_DM_SUCCESS )
+ return ret_status;
+
+ SYNCML_DM_ACCESS_TYPE_T parentAccessType;
+ MDF_BUFFER_T pSearchedBuffer = oBuffer.GetBuffer();
+ UINT32 size = m_oDDFInfo.size();
+
+ for (UINT32 i=0; i<size; i++) // loop through all mdf's files
+ {
+#ifndef DM_STATIC_FILES
+ DMFileHandler * pFile = (DMFileHandler*)m_oDDFInfo[i];
+ oBuffer.SetBuffer((MDF_BUFFER_T)pFile->mmap());
+#else
+ oBuffer.SetBuffer((MDF_BUFFER_T)m_oDDFInfo[i]);
+#endif
+ oBuffer.SetOffset(BMDFHeaderSize); // file size and version
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ oBuffer.ResetCorrupted();
+#endif
+ if (pSearchedBuffer == oBuffer.GetBuffer())
+ continue;
+
+ oNode.Read(oBuffer,FALSE);
+ if (DmStrcmp(oNode.m_psName,".") != 0)
+ {
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ if ( oBuffer.IsCorrupted() ){
+#ifndef DM_STATIC_FILES
+ XPL_LOG_DM_TMN_Error(("BMDF: File %s is corrupted!\n", pFile->getFullPath()));
+ delete pFile;
+ pFile = NULL;
+#endif
+ m_oLastNodeLocator.Init();
+ m_oDDFInfo.remove( i );
+ i--; size--;
+ }
+#else
+ continue;
+#endif
+ }
+ parentAccessType = oNode.m_wAccessType;
+ m_oLastNodeLocator.Init();
+ m_oLastNodeLocator.m_pBuffer = oBuffer.GetBuffer();
+ ret_status = SearchNode((CPCHAR)sNodeURI,oBuffer,parentAccessType,bCheckMultiNode,oNode, pChildDependNodes);
+
+#ifndef DM_IGNORE_BMDF_VERIFICATION
+ if ( oBuffer.IsCorrupted() )
+ {
+#ifndef DM_STATIC_FILES
+ if (pFile != NULL)
+ {
+ XPL_LOG_DM_TMN_Error(("BMDF: File %s is corrupted!\n", pFile->getFullPath()));
+ delete pFile;
+ pFile = NULL;
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Error(("BMDF: File is corrupted!\n"));
+ }
+#endif
+ m_oLastNodeLocator.Init();
+ m_oDDFInfo.remove( i );
+ i--; size--;
+ }
+#endif
+
+
+ if ( ret_status != SYNCML_DM_NOT_FOUND )
+ return ret_status;
+
+ }
+
+ return SYNCML_DM_NOT_FOUND;
+
+}
+
+BOOLEAN
+DMMetaDataManager::CheckFieldInUse(DMNode* pNode,
+ PDmtNode pPluginNode,
+ CPCHAR szNodeName,
+ CPCHAR szOrigName)
+{
+ if (pPluginNode != NULL)
+ {
+ SYNCML_DM_RET_STATUS_T e;
+ DmtData data;
+
+ e = pPluginNode->GetValue(data);
+ if ( (e==SYNCML_DM_SUCCESS) && (data.GetType() == SYNCML_DM_DATAFORMAT_STRING) )
+ {
+ const DMString & strVal = data.GetStringValue();
+ if (DmStrncmp((CPCHAR)strVal.c_str(), szNodeName, DmStrlen(szNodeName)) == 0 )
+ return FALSE;
+ }
+ else
+ return FALSE;
+ }
+ else
+ if ( pNode->getData() && pNode->getData()->getSize() )
+ {
+ if (DmStrncmp((CPCHAR)pNode->getData()->getBuffer(), szNodeName, pNode->getData()->getSize())==0)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+BOOLEAN
+DMMetaDataManager::ClearNodeValue(DMNode* pNode,
+ PDmtNode pPluginNode,
+ CPCHAR szNodeName,
+ CPCHAR szOrigName)
+{
+ if ( pPluginNode != NULL )
+ {
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ DmtData data;
+
+ dm_stat = pPluginNode->GetValue(data);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return FALSE;
+ if ( data.GetType() == SYNCML_DM_DATAFORMAT_STRING )
+ {
+ dm_stat = pPluginNode->SetValue(DmtData((CPCHAR)""));
+ if (dm_stat != SYNCML_DM_SUCCESS )
+ return FALSE;
+ }
+ else
+ return FALSE;
+ }
+ else
+ if( pNode->getData() && pNode->getData()->getSize() )
+ {
+ if (DmStrncmp((CPCHAR)pNode->getData()->getBuffer(), szNodeName, pNode->getData()->getSize())==0)
+ pNode->getData()->clear();
+ }
+ return TRUE;
+}
+
+
+BOOLEAN
+DMMetaDataManager::ResetNodeValue(DMNode* pNode,
+ PDmtNode pPluginNode,
+ CPCHAR szNodeName,
+ CPCHAR szOrigName)
+{
+ if (pPluginNode != NULL)
+ {
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ DmtData data;
+
+ dm_stat = pPluginNode->GetValue(data);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return FALSE;
+
+ if ( data.GetType() == SYNCML_DM_DATAFORMAT_STRING )
+ {
+ // Get Data
+ const DMString & strVal = data.GetStringValue();
+ if (DmStrncmp( (CPCHAR)strVal.c_str(), szOrigName, DmStrlen(szOrigName)) == 0)
+ {
+ dm_stat = pPluginNode->SetValue(DmtData(szNodeName));
+ if (dm_stat != SYNCML_DM_SUCCESS )
+ return FALSE;
+ }
+
+ }
+ else
+ return FALSE;
+ }
+ else
+ {
+ if( !pNode->getData() || !pNode->getData()->getSize() )
+ return TRUE;
+
+ if (DmStrncmp((CPCHAR)pNode->getData()->getBuffer(),szOrigName,pNode->getData()->getSize()) ==0)
+ {
+ if ( pNode->getData()->assign(szNodeName) == NULL )
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+
+BOOLEAN
+DMMetaDataManager::VerifyOneURIDependency(DMNode* pNode,
+ char * sAbsoluteURI,
+ CPCHAR szNodeName,
+ CPCHAR szOneURIDep,
+ CPCHAR szOrigName,
+ SYNCML_DM_MDF_CBACK callBack,
+ BOOLEAN bIsMultiNode)
+{
+ BOOLEAN ret_status = TRUE;
+ DMNode *psTempNode = NULL;
+ DMMetaDataNode oNodeMDF;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ psTempNode = pNode->pcFirstChild;
+ if( !psTempNode )
+ return TRUE;
+
+ DMURI oOneURI(FALSE,szOneURIDep);
+ CPCHAR szSegment = oOneURI.nextSegment();
+
+ DmStrcat(sAbsoluteURI,"/");
+ INT32 nLen = DmStrlen(sAbsoluteURI);
+ while(psTempNode != NULL)
+ {
+ sAbsoluteURI[nLen] = 0;
+ DmStrcat(sAbsoluteURI,psTempNode->abNodeName);
+
+ dm_stat = GetNode(sAbsoluteURI, FALSE, oNodeMDF);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ if ( bIsMultiNode || psTempNode->abNodeName == szSegment )
+ {
+ if(oOneURI.getTailSegments() == NULL)
+ ret_status = callBack(psTempNode, NULL,szNodeName, szOrigName);
+ else
+ if ( !psTempNode->isPlugin() )
+ {
+ ret_status = VerifyOneURIDependency(psTempNode,
+ sAbsoluteURI,
+ szNodeName,
+ oOneURI.getTailSegments(),
+ szOrigName,
+ callBack,
+ oNodeMDF.IsHasMultiNodes());
+ }
+ else
+ {
+ PDmtAPIPluginTree tree;
+ dm_stat = ((DMPluginRootNode*)psTempNode)->GetTree(tree);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return FALSE;
+
+ CPCHAR pbPluginURI = ((DMPluginRootNode*)psTempNode)->GetPluginURI(sAbsoluteURI);
+ PDmtNode ptrNode;
+
+ dm_stat = tree->GetNode(pbPluginURI, ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return FALSE;
+
+ ret_status = VerifyPluginURIDependency(psTempNode,
+ ptrNode,
+ sAbsoluteURI,
+ szNodeName,
+ oOneURI.getTailSegments(),
+ szOrigName,
+ callBack,
+ oNodeMDF.IsHasMultiNodes());
+ }
+
+ if(ret_status == FALSE)
+ return FALSE;
+
+ if(bIsMultiNode == FALSE)
+ return TRUE;
+ }
+ }
+
+ psTempNode = psTempNode->pcNextSibling;
+
+ }
+
+ return ret_status;
+
+}
+
+
+BOOLEAN
+DMMetaDataManager::VerifyDependency(CPCHAR szNodeName,
+ CPCHAR szDependecies,
+ CPCHAR szOrigName,
+ SYNCML_DM_MDF_CBACK callBack)
+{
+ BOOLEAN ret_status = TRUE;
+
+ DMNode* pNode = NULL;
+ CPCHAR sSegment = NULL;
+ char * sAbsoluteURI = NULL;
+ DMToken oDependensies(TRUE,szDependecies,SYNCML_DM_COMMA);
+
+
+ if ( !oDependensies.getBuffer() )
+ return FALSE;
+
+ pNode = m_pTree->GetRootNode();
+
+ if ( pNode == NULL )
+ return FALSE;
+
+ sAbsoluteURI = (char*)DmAllocMem( m_pTree->GetMaxTotalPathLength() + 1 );
+
+ if ( sAbsoluteURI == NULL )
+ return FALSE;
+
+ memset(sAbsoluteURI, 0, m_pTree->GetMaxTotalPathLength() + 1 );
+
+ sSegment = oDependensies.nextSegment();
+ while ( sSegment )
+ {
+ if ( sSegment[0] == '.' && sSegment[1] == '/' )
+ sSegment += 2; // skip "./" part
+
+ DmStrcpy(sAbsoluteURI,".");
+ ret_status = VerifyOneURIDependency(pNode,
+ sAbsoluteURI,
+ szNodeName,
+ sSegment,
+ szOrigName,
+ callBack,
+ FALSE);
+
+ if( ret_status != TRUE)
+ {
+ DmFreeMem(sAbsoluteURI);
+ return FALSE;
+ }
+ sSegment = oDependensies.nextSegment();
+ }
+
+ DmFreeMem(sAbsoluteURI);
+ return TRUE;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::SetAutoNodeProperty(CPCHAR szURI, DMAddData & pAdd)
+{
+ DMMetaDataNode oNode;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+ SYNCML_DM_FORMAT_T format;
+
+ ret_status = GetNode(szURI, FALSE, oNode);
+
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+
+ DMConstraints *pConstraints = oNode.GetConstraints();
+ DMString mimeType;
+
+ oNode.GetMimeType(mimeType);
+
+ if ( !pConstraints || !pConstraints->IsDefaultSet() )
+ format = ((oNode.m_nNodeFormat == SYNCML_DM_FORMAT_NODE) ?
+ SYNCML_DM_FORMAT_NODE : SYNCML_DM_FORMAT_NULL);
+ else
+ format = SYNCML_DM_FORMAT_INVALID;
+
+ return pAdd.set(szURI,format,NULL,0,mimeType);
+}
+
+
+BOOLEAN DMMetaDataManager::IsLocal(CPCHAR szURI)
+{
+
+ DMMetaDataNode oNode;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ ret_status = GetNode(szURI, FALSE, oNode, NULL);
+ if ( ret_status == SYNCML_DM_SUCCESS )
+ {
+ return oNode.IsLocal();
+ }
+ return FALSE;
+}
+
+
+BOOLEAN DMMetaDataManager::IsLeaf(CPCHAR szURI)
+{
+
+ DMMetaDataNode oNode;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ ret_status = GetNode(szURI, FALSE, oNode, NULL);
+ if ( ret_status == SYNCML_DM_SUCCESS )
+ {
+ return oNode.IsLeaf();
+ }
+ return FALSE;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::GetPath(CPCHAR szURI, DMString & szMDF)
+{
+
+ DMMetaDataNode oNode;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ ret_status = GetNode(szURI, FALSE, oNode, NULL);
+ if ( ret_status == SYNCML_DM_SUCCESS )
+ {
+ const DMBuffer & oMDF = oNode.GetPath();
+ oMDF.copyTo(szMDF);
+ }
+ return ret_status;
+}
+
+BOOLEAN
+DMMetaDataManager::VerifyAccessType(CPCHAR szURI,
+ SYNCML_DM_ACCESS_TYPE_T accessType,
+ DMMetaPCharVector* pChildDependNodes /*=null*/)
+{
+ DMMetaDataNode oNode;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ ret_status = GetNode(szURI, FALSE, oNode, pChildDependNodes);
+ if( ret_status != SYNCML_DM_SUCCESS)
+ {
+ // If meta information not available, the default access is Get and Exec
+ XPL_LOG_DM_TMN_Debug(("Meta Information isn't found %s\n",szURI));
+ oNode.SetAccessType(SYNCML_DM_GET_ACCESS_TYPE | SYNCML_DM_EXEC_ACCESS_TYPE);
+ }
+
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataManager::VerifyAccessType: call oNode.VerifyAccessType() %s\n",szURI));
+ BOOLEAN access = oNode.VerifyAccessType(accessType);
+ return access;
+}
+
+
+BOOLEAN
+DMMetaDataManager::VerifyChildrenMultiNodesCount(CPCHAR szURI,
+ UINT16 count,
+ BOOLEAN& bOPiDataParent)
+{
+ DMMetaDataNode oNode;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ ret_status = GetNode(szURI, TRUE, oNode);
+ if( ret_status != SYNCML_DM_SUCCESS)
+ return FALSE;
+
+ return oNode.VerifyChildrenMultiNodesCount(count, bOPiDataParent);
+}
+
+BOOLEAN
+DMMetaDataManager::VerifyOPINode(CPCHAR szURI,
+ CPCHAR& szID,
+ SYNCML_DM_ACCESS_TYPE_T& wAccessType,
+ SYNCML_DM_FORMAT_T& nNodeFormat)
+{
+ DMMetaDataNode oNode;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ szID = NULL;
+ ret_status = GetNode(szURI, FALSE, oNode);
+ if( ret_status != SYNCML_DM_SUCCESS)
+ return FALSE;
+
+ return oNode.VerifyOPINode(szID, wAccessType, nNodeFormat);
+}
+
+BOOLEAN DMMetaDataManager::IsOPiDataParent( CPCHAR szURI )
+{
+ DMMetaDataNode oNode;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ ret_status = GetNode(szURI, TRUE, oNode);
+ if( ret_status != SYNCML_DM_SUCCESS)
+ return FALSE;
+
+ return oNode.IsOPiDataParent();
+}
+
+#ifdef LOB_SUPPORT
+BOOLEAN DMMetaDataManager::IsESN( CPCHAR szURI )
+{
+ DMMetaDataNode oNode;
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ ret_status = GetNode(szURI, TRUE, oNode);
+ if( ret_status != SYNCML_DM_SUCCESS)
+ return FALSE;
+
+ return oNode.IsESN();
+}
+#endif
+
+UINT16 DMMetaDataManager::UpdateChildrenList( CPCHAR szURI,
+ DMString& strChildrenList )
+{
+ UINT16 nChildrenCount = 0;
+ DMMetaDataNode oNode, oChildrenNode;
+ DMMetaDataBuffer oBuffer;
+
+ if ( SYNCML_DM_SUCCESS != GetNode(szURI, TRUE, oNode) ||
+ !m_oLastNodeLocator.m_pBuffer ||
+ oNode.IsHasMultiNodes() )
+ return 0;
+
+ oBuffer.SetBuffer( m_oLastNodeLocator.m_pBuffer );
+
+ for (int i=0; i<oNode.m_nNumChildren; i++)
+ {
+ oNode.SetChildrenOffset(&oBuffer,i);
+ oChildrenNode.Read(oBuffer, FALSE);
+
+ if ( oChildrenNode.IsPluginNode() ) {
+ if ( !strChildrenList.empty() )
+ strChildrenList += "/";
+
+ strChildrenList += oChildrenNode.m_psName;
+ }
+ }
+
+ return nChildrenCount;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::RemoveRecursiveSegments(char* sTailSegment,
+ DMMetaDataNode & oNode)
+{
+
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_NOT_FOUND;
+ DMConstraints * pConstraints = oNode.GetConstraints();
+
+
+ if ( pConstraints == NULL ||
+ sTailSegment == NULL )
+ return ret_status;
+
+ INT32 lenMatchSeg = DmStrlen(pConstraints->m_psRecurAfterSegment)+DmStrlen(oNode.m_psName)+1;
+ INT32 lenTailSeg = DmStrlen(sTailSegment);
+
+ if ( lenMatchSeg > lenTailSeg )
+ return ret_status;
+
+ DMString sMatchSegment;
+
+ sMatchSegment = pConstraints->m_psRecurAfterSegment;
+ sMatchSegment += "/";
+ sMatchSegment += oNode.m_psName;
+
+ DMParser oMatchSegmentParser(sMatchSegment);
+
+ CPCHAR sSegment1 = NULL;
+ CPCHAR sSegment2 = NULL;
+ CPCHAR sRestTail = NULL;
+ for (int i=0; i<pConstraints->m_nMaxRecurrance; i++)
+ {
+ DMURI oTailSegmentParser(TRUE,sTailSegment);
+
+ oMatchSegmentParser.reset();
+ for (UINT32 j=0; j<oMatchSegmentParser.getSegmentsCount()-1; j++)
+ {
+ sSegment1 = oMatchSegmentParser.nextSegment();
+ sSegment2 = oTailSegmentParser.nextSegment();
+ if ( sSegment2 == NULL )
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+ if ( DmStrcmp(sSegment1,"*") != 0 &&
+ DmStrcmp(sSegment1,sSegment2) != 0 )
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+ }
+
+ sSegment1 = oMatchSegmentParser.nextSegment();
+ sSegment2 = oTailSegmentParser.nextSegment();
+ if ( sSegment2 == NULL )
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+ if ( !oNode.IsMultiNode() )
+ {
+ if ( DmStrcmp(sSegment1,"*") != 0 &&
+ DmStrcmp(sSegment1,sSegment2) != 0 )
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+ }
+
+
+ sRestTail = oTailSegmentParser.getTailSegments();
+ if ( sRestTail != NULL )
+ memmove(sTailSegment, sRestTail, DmStrlen(sRestTail)+1);
+ else
+ {
+ sTailSegment[0] = SYNCML_DM_NULL;
+ break;
+ }
+
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::Load()
+{
+ SYNCML_DM_RET_STATUS_T ret_status;
+
+ if( !m_pEnv ) return SYNCML_DM_FAIL;
+
+#ifndef DM_STATIC_FILES
+ DMString sRootMDF;
+ DMString sFullPath;
+
+ m_pEnv->GetMainRFSFullPath(DM_ROOT_MDF_FILENAME,sRootMDF);
+
+ ret_status = LoadBuffer(sRootMDF);
+
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+
+ m_bIsLoad = TRUE;
+
+ // load all extra mdf files...
+ ret_status = LoadDir(m_pEnv->GetWFSFullPath(NULL,sFullPath), false);
+
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+
+ for (INT32 nFS = 0; nFS < m_pEnv->GetRFSCount(); nFS++)
+ {
+ LoadDir( m_pEnv->GetRFSFullPath(nFS,NULL,sFullPath), nFS == 0); // ignore root.mdf only on first RO fs, since it's already loaded
+ }
+#else
+ UINT8 count = XPL_DM_GetMDFCount();
+
+ for (UINT8 index=0; index<count; index++)
+ {
+ ret_status = LoadBuffer(index);
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+ }
+ m_bIsLoad = TRUE;
+#endif
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+#ifndef DM_STATIC_FILES
+SYNCML_DM_RET_STATUS_T
+DMMetaDataManager::LoadDir(CPCHAR szDirectory, BOOLEAN bIgnoreRoot)
+{
+
+ XPL_FS_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+ XPL_FS_SHANDLE_T search_handle = XPL_FS_SHANDLE_INVALID;
+ char file_name[XPL_FS_MAX_FILE_NAME_LENGTH];
+
+ search_handle = XPL_FS_StartSearch(szDirectory, "bmdf", TRUE, &ret_status);
+ if ( ret_status != XPL_FS_RET_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ // load all files with .mdf extension
+ while ( XPL_FS_GetSearchResult(search_handle,file_name) != XPL_FS_RET_NOT_FOUND )
+ {
+ if (( bIgnoreRoot || DmStrcmp(file_name, DM_ROOT_MDF_FILENAME) != 0) )
+ {
+ ret_status = LoadBuffer(file_name);
+ if ( ret_status != SYNCML_DM_SUCCESS)
+ break;
+ }
+ }
+
+ XPL_FS_EndSearch(search_handle);
+ return ret_status;
+}
+#endif
+
+
+BOOLEAN
+DMMetaDataManager::VerifyPluginURIDependency(DMNode* pNode,
+ PDmtNode pPluginNode,
+ char * sAbsoluteURI,
+ CPCHAR szNodeName,
+ CPCHAR szOneURIDep,
+ CPCHAR szOrigName,
+ SYNCML_DM_MDF_CBACK callBack,
+ BOOLEAN bIsMultiNode)
+{
+ BOOLEAN ret_status = TRUE;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ DmStrcat(sAbsoluteURI, "/");
+ DMVector<PDmtNode> vecNodes;
+
+ dm_stat = pPluginNode->GetChildNodes(vecNodes);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ DMMetaDataNode oNodeMDF;
+ DMURI oOneURI(FALSE, szOneURIDep);
+ CPCHAR szSegment = oOneURI.nextSegment();
+
+ DMString nodeName;
+ INT32 nLen = DmStrlen(sAbsoluteURI);
+
+
+ for (INT32 i=0; i < vecNodes.size(); i++)
+ {
+ sAbsoluteURI[nLen] = 0;
+ dm_stat = vecNodes[i]->GetNodeName(nodeName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return FALSE;
+
+ DmStrcat(sAbsoluteURI, nodeName.c_str());
+
+ dm_stat = GetNode(sAbsoluteURI, FALSE, oNodeMDF);
+ if ( dm_stat == SYNCML_DM_SUCCESS)
+ {
+ if ( bIsMultiNode || nodeName == szSegment)
+ {
+ if (oOneURI.getTailSegments() == NULL)
+ {
+ ret_status = callBack(pNode, vecNodes[i], szNodeName, szOrigName);
+ }
+ else
+ {
+ ret_status = VerifyPluginURIDependency(pNode,
+ vecNodes[i],
+ sAbsoluteURI,
+ szNodeName,
+ oOneURI.getTailSegments(),
+ szOrigName,
+ callBack,
+ oNodeMDF.IsHasMultiNodes());
+ }
+
+ if (ret_status == FALSE)
+ return FALSE;
+ if (bIsMultiNode == FALSE)
+ return TRUE;
+ }
+ }
+ }
+ }
+ return ret_status;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmMetaDataNode.cc b/engine/dmlib/dmengine/dm_ua/src/dmMetaDataNode.cc
new file mode 100644
index 0000000..6b9f4ac
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmMetaDataNode.cc
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmMetaDataNode.cc
+
+ General Description: Implementation of the DMMetaDataNode class
+
+==================================================================================================*/
+
+#include <limits.h>
+#include "dm_uri_utils.h"
+#include "dmStringUtil.h"
+#include "dmMetaDataNode.h"
+#include "xpl_Logger.h"
+
+DMMetaDataNode::DMMetaDataNode()
+{
+ Init();
+}
+
+
+DMConstraints *
+DMMetaDataNode::GetConstraints() const
+{
+ if ( m_nNumConstraints )
+ return (DMConstraints*)&m_oConstraints;
+ else
+ return NULL;
+}
+
+void DMMetaDataNode::Init()
+{
+ m_psName = NULL;
+ m_szID = NULL;
+ m_wAccessType = SYNCML_DM_GET_ACCESS_TYPE | SYNCML_DM_EXEC_ACCESS_TYPE;
+ m_nNodeFormat = SYNCML_DM_FORMAT_INVALID;
+ m_nMimeType = SYNCML_DM_DDF_MIME_TYPE_TEXTPLAIN;
+ m_nNumConstraints = 0;
+ m_nMaxChildrenMultiNodes = 0;
+ m_bIsHasMultiChildren = FALSE;
+ m_bIsMultiNode = FALSE;
+ m_bStoresPD = FALSE;
+ m_bPluginNode = FALSE;
+ m_bOPiDataParent = FALSE;
+#ifdef LOB_SUPPORT
+ m_bESN = FALSE;
+ m_bProgressBarNeeded = FALSE;
+#endif
+}
+
+
+void
+DMMetaDataNode::CheckHasMultiNode(DMMetaDataBuffer oBuffer)
+{
+
+ UINT16 nodeType;
+
+
+ oBuffer.SetOffset(oBuffer.ReadUINT32() + sizeof(UINT32));
+ nodeType = oBuffer.ReadUINT16();
+ if ( (nodeType & 0x80) == 0x80 )
+ m_bIsHasMultiChildren = TRUE;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataNode::Read(DMMetaDataBuffer oBuffer,
+ BOOLEAN bReadConstraints)
+{
+
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+ UINT16 nodeType;
+
+ Init();
+
+ m_psName = oBuffer.ReadString();
+ nodeType = oBuffer.ReadUINT16();
+ if ( (nodeType & nodeMultiNode) == nodeMultiNode)
+ m_bIsMultiNode = TRUE;
+
+#ifdef LOB_SUPPORT
+ if ( (nodeType & nodeESN) == nodeESN)
+ m_bESN = TRUE;
+
+ if ( (nodeType & nodeProgressBar) == nodeProgressBar)
+ m_bProgressBarNeeded = TRUE;
+#endif
+ m_nNodeFormat = (UINT8)(nodeType & nodeTypeMask );
+
+ if ( (nodeType & nodeHasID) != 0 )
+ m_szID = oBuffer.ReadString();
+
+ m_bPluginNode = ((nodeType & nodePluginNode) != 0);
+ m_bStoresPD = ((nodeType & nodeStoresPD) != 0);
+
+ m_wAccessType = oBuffer.ReadUINT8();
+ m_nMimeType = oBuffer.ReadUINT8();
+ m_nNumChildren = oBuffer.ReadUINT16();
+
+ m_nOffsetChildren = oBuffer.GetOffset();
+
+ if ( m_nNumChildren == 1 )
+ CheckHasMultiNode(oBuffer);
+
+ if ( bReadConstraints )
+ {
+ oBuffer.IncOffset(m_nNumChildren*sizeof(UINT32));
+ m_nNumConstraints = oBuffer.ReadUINT8();
+ ret_status = m_oConstraints.Read(&oBuffer, m_nNumConstraints, nodeType);
+ }
+ return ret_status;
+
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataNode::SetChildrenOffset(DMMetaDataBuffer * pBuffer,
+ UINT8 index)
+{
+ if ( index > m_nNumChildren )
+ return SYNCML_DM_SUCCESS;
+
+ pBuffer->SetOffset(m_nOffsetChildren + index*sizeof(UINT32));
+
+ UINT32 offset = pBuffer->ReadUINT32();
+ pBuffer->SetOffset(offset);
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataNode::GetMaxMultiNodeChildren(DMMetaDataBuffer oBuffer)
+{
+
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ if ( m_bIsHasMultiChildren )
+ {
+ oBuffer.SetOffset(m_nOffsetChildren);
+ UINT32 offset = oBuffer.ReadUINT32();
+ oBuffer.SetOffset(offset);
+ DMMetaDataNode oChildren;
+ DMConstraints * pConstraints = NULL;
+
+ ret_status = oChildren.Read(oBuffer,TRUE);
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+
+ m_bOPiDataParent = oChildren.m_bStoresPD;
+ pConstraints = oChildren.GetConstraints();
+ if ( pConstraints )
+ m_nMaxChildrenMultiNodes = pConstraints->m_nMaxMultiNodes;
+ }
+ return ret_status;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMMetaDataNode::ReadName(DMMetaDataBuffer oBuffer)
+{
+
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_SUCCESS;
+
+ Init();
+ m_psName = oBuffer.ReadString();
+ return ret_status;
+}
+
+
+BOOLEAN
+DMMetaDataNode::VerifyAccessType(SYNCML_DM_ACCESS_TYPE_T accessType) const
+{
+ XPL_LOG_DM_TMN_Debug(("DMMetaDataNode::VerifyAccessType: node m_wAccesstype is:%x, passed accessType is %x\n", m_wAccessType,accessType));
+ return ( (m_wAccessType & accessType) == accessType );
+}
+
+BOOLEAN DMMetaDataNode::VerifyMimeType(CPCHAR mimeType) const
+{
+ return TRUE;
+}
+
+
+void DMMetaDataNode::GetMimeType(DMString & strType)
+{
+ strType = "text/plain";
+}
+
+void DMMetaDataNode::SetAccessType(SYNCML_DM_ACCESS_TYPE_T accessType)
+{
+ m_wAccessType = accessType;
+
+}
+
+
+BOOLEAN DMMetaDataNode::IsLocal()
+{
+ return ( (m_wAccessType & SYNCML_DM_LOCAL_ACCESS_TYPE) == SYNCML_DM_LOCAL_ACCESS_TYPE );
+
+}
+
+BOOLEAN DMMetaDataNode::IsLeaf()
+{
+ if ( m_nNodeFormat != SYNCML_DM_FORMAT_NODE &&
+ m_nNodeFormat != SYNCML_DM_FORMAT_NODE_PDATA )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+SYNCML_DM_RET_STATUS_T DMMetaDataNode::SetPath(CPCHAR szPath)
+{
+ if ( m_oPath.assign(szPath) == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DMMetaDataNode::AllocatePath(UINT32 size)
+{
+ if ( m_oPath.allocate(size) == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ return SetPath(".");
+}
+
+SYNCML_DM_RET_STATUS_T DMMetaDataNode::AppendSegment()
+{
+ m_oPath.append((UINT8*)"/", 1);
+ m_oPath.append((UINT8*)m_psName,DmStrlen(m_psName));
+ return SYNCML_DM_SUCCESS;
+}
+
+BOOLEAN
+DMMetaDataNode::VerifyChildrenMultiNodesCount(UINT16 count,
+ BOOLEAN& bOPiDataParent ) const
+{
+ bOPiDataParent = m_bOPiDataParent;
+ if ( m_nMaxChildrenMultiNodes > 0 )
+ {
+ return ( (count < m_nMaxChildrenMultiNodes) );
+ }
+ else
+ return TRUE;
+}
+
+BOOLEAN
+DMMetaDataNode::VerifyOPINode( CPCHAR& szID,
+ SYNCML_DM_ACCESS_TYPE_T& wAccessType,
+ SYNCML_DM_FORMAT_T& nNodeFormat ) const
+{
+ szID = m_szID;
+ wAccessType = m_wAccessType;
+ nNodeFormat = m_nNodeFormat;
+
+ return m_bPluginNode;
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmSessionApi.cc b/engine/dmlib/dmengine/dm_ua/src/dmSessionApi.cc
new file mode 100644
index 0000000..1fde884
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmSessionApi.cc
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_NO_SESSION_DLL
+/*==================================================================================================
+
+ Source Name: dmSessionAPI.cc
+
+ General Description: Implementation of External interfaces to Server Session.
+
+==================================================================================================*/
+
+#include "dmSessionFactory.h"
+#include "xpl_dm_Manager.h"
+#include "xpl_Lib.h"
+#include "xpl_Logger.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SYNCML_DM_RET_STATUS_T
+DmProcessServerData(CPCHAR szPrincipal,
+ const DmtSessionProp& session)
+{
+ SYNCML_DM_RET_STATUS_T ret_status;
+
+#ifndef DM_NO_SESSION_LIB
+ const char * lib_name = XPL_DM_GetEnv(SYNCML_DM_SESSION_LIB);
+ /* Loads dynamic library */
+ XPL_DL_HANDLE_T lib_handle = XPL_DL_Load(lib_name);
+
+ if ( lib_handle == NULL )
+ return SYNCML_DM_FAIL;
+
+ XPL_DL_HANDLE_T pFunc = XPL_DL_GetFunction(lib_handle, "DmProcessServerDataInternal");
+
+ if ( pFunc == NULL )
+ {
+ XPL_DL_Unload(lib_handle);
+ return SYNCML_DM_FAIL;
+ }
+
+ ret_status = ((SYNCML_DM_RET_STATUS_T (*)(CPCHAR ,const DmtSessionProp&))(pFunc))(szPrincipal,session);
+
+ XPL_DL_Unload(lib_handle);
+#else
+ ret_status = DmProcessServerDataInternal(szPrincipal,session);
+ XPL_LOG_DM_SESS_Debug(("Returning from DmProcessServerDataInternal status=%d\n", ret_status));
+#endif
+
+ return ret_status;
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DmProcessScriptData(const UINT8 * docInputBuffer,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ DMBuffer & oResult)
+{
+ SYNCML_DM_RET_STATUS_T ret_status;
+
+#ifndef DM_NO_SESSION_LIB
+ const char * lib_name = XPL_DM_GetEnv(SYNCML_DM_SESSION_LIB);
+ /* Loads dynamic library */
+ XPL_DL_HANDLE_T lib_handle = XPL_DL_Load(lib_name);
+
+ if ( lib_handle == NULL )
+ return SYNCML_DM_FAIL;
+
+ XPL_DL_HANDLE_T pFunc = XPL_DL_GetFunction(lib_handle, "DmProcessScriptDataInternal");
+
+ if ( pFunc == NULL )
+ {
+ XPL_DL_Unload(lib_handle);
+ return SYNCML_DM_FAIL;
+ }
+
+ ret_status = ((SYNCML_DM_RET_STATUS_T (*)(const UINT8 * , UINT32, BOOLEAN, DMBuffer &))(pFunc))
+ (docInputBuffer,inDocSize,isWBXML,oResult);
+
+ XPL_DL_Unload(lib_handle);
+#else
+ ret_status = DmProcessScriptDataInternal(docInputBuffer,inDocSize,isWBXML,oResult);
+#endif
+
+ return ret_status;
+
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DmBootstrap(const UINT8 * docInputBuffer,
+ UINT32 inDocSize,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMString & serverID)
+{
+
+ SYNCML_DM_RET_STATUS_T ret_status;
+
+#ifndef DM_NO_SESSION_LIB
+ const char * lib_name = XPL_DM_GetEnv(SYNCML_DM_SESSION_LIB);
+
+ XPL_DL_HANDLE_T lib_handle = XPL_DL_Load(lib_name);
+
+ if ( lib_handle == NULL )
+ return SYNCML_DM_FAIL;
+
+ XPL_DL_HANDLE_T pFunc = XPL_DL_GetFunction(lib_handle, "DmBootstrapInternal");
+
+ if ( pFunc == NULL )
+ {
+ XPL_DL_Unload(lib_handle);
+ return SYNCML_DM_FAIL;
+ }
+
+ ret_status = ((SYNCML_DM_RET_STATUS_T (*)(const UINT8 * , UINT32, BOOLEAN, BOOLEAN, DMString &))(pFunc))
+ (docInputBuffer,inDocSize,isWBXML,isProcess, serverID);
+
+ XPL_DL_Unload(lib_handle);
+#else
+ ret_status = DmBootstrapInternal(docInputBuffer,inDocSize,isWBXML,isProcess, serverID);
+#endif
+ return ret_status;
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DmAuthenticateServer(SYNCML_DM_AuthContext_T& AuthContext )
+{
+ SYNCML_DM_RET_STATUS_T ret_status;
+
+#ifndef DM_NO_SESSION_LIB
+ const char * lib_name = XPL_DM_GetEnv(SYNCML_DM_SESSION_LIB);
+
+ XPL_DL_HANDLE_T lib_handle = XPL_DL_Load(lib_name);
+ if ( lib_handle == NULL )
+ return SYNCML_DM_FAIL;
+
+ XPL_DL_HANDLE_T pFunc = XPL_DL_GetFunction(lib_handle, "DmAuthenticateServerInternal");
+ if ( pFunc == NULL )
+ {
+ XPL_DL_Unload(lib_handle);
+ return SYNCML_DM_FAIL;
+ }
+ ret_status = ((SYNCML_DM_RET_STATUS_T (*)(SYNCML_DM_AuthContext_T& ))(pFunc))(AuthContext);
+
+ XPL_DL_Unload(lib_handle);
+#else
+ ret_status = DmAuthenticateServerInternal(AuthContext);
+#endif
+
+ return ret_status;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmSubscriptionItem.cc b/engine/dmlib/dmengine/dm_ua/src/dmSubscriptionItem.cc
new file mode 100644
index 0000000..e49de1e
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmSubscriptionItem.cc
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmSubscriptionItem.cc
+
+ General Description: Implementation of the DMSubscriptionItem class
+
+==================================================================================================*/
+
+#include "dmSubscriptionItem.h"
+#include "dm_uri_utils.h"
+#include "dmdefs.h"
+#include "dmtoken.h"
+#include "xpl_Logger.h"
+#include "xpl_dm_Manager.h"
+#include "dm_tree_class.H"
+
+DMSubscriptionItem::DMSubscriptionItem(CPCHAR szPath ) : DMConfigItem (szPath )
+{
+ m_eAction = SYNCML_DM_EVENT_NONE;
+ m_nType = SYNCML_DM_EVENT_NODE;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionItem::Set(const DmtEventSubscription & pItem)
+{
+ return DmtEventSubscription::Set(pItem.GetAction(),
+ pItem.GetType(),
+ pItem.GetTopic(),
+ pItem.GetPrincipals(TRUE),
+ pItem.GetPrincipals(FALSE));
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionItem::Set(CPCHAR szPath,
+ CPCHAR szConfig,
+ const DMMap<INT32, DMString>& aDict)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_TMN_Debug(("Parse subscription=%s for path =%s\n", szConfig,szPath));
+ dm_stat = DMConfigItem::Set(szPath);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+
+ DMToken oParser(FALSE,szConfig,'&');
+ CPCHAR pCommand = NULL;
+
+ while ( (pCommand = oParser.nextSegment()) != NULL )
+ {
+
+ SYNCML_DM_EVENT_ACTION_T nAction = SYNCML_DM_EVENT_NONE;
+ SYNCML_DM_EVENT_TYPE_T nType = SYNCML_DM_EVENT_NODE;
+
+
+ if ( DmStrcmp(pCommand,"A") == 0 )
+ nAction = SYNCML_DM_EVENT_ADD;
+ else if ( DmStrcmp(pCommand,"D") ==0 )
+ nAction = SYNCML_DM_EVENT_DELETE;
+ else if ( DmStrcmp(pCommand,"I") == 0 )
+ nAction = SYNCML_DM_EVENT_INDIRECT;
+ else if ( DmStrcmp(pCommand,"R") == 0 )
+ nAction = SYNCML_DM_EVENT_REPLACE | SYNCML_DM_EVENT_RENAME;
+ else if (DmStrcmp(pCommand,"N") == 0 )
+ nType = SYNCML_DM_EVENT_NODE;
+ else if ( DmStrcmp(pCommand,"C") == 0 )
+ nType = SYNCML_DM_EVENT_CUMULATIVE;
+ else if ( DmStrcmp(pCommand,"F") == 0 )
+ nType = SYNCML_DM_EVENT_DETAIL;
+ else
+ {
+ dm_stat = ParseSegment(pCommand,aDict);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ continue;
+ }
+
+ m_eAction |= nAction;
+ m_nType = nType;
+
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionItem::ParseSegment(CPCHAR szSegment,
+ const DMMap<INT32, DMString>& aDict)
+{
+ DMParser oParser(szSegment,'=');
+ CPCHAR pKeyWord = oParser.nextSegment();
+ CPCHAR pValue = oParser.nextSegment();
+
+ if ( pKeyWord == NULL || pValue == NULL )
+ return SYNCML_DM_FAIL;
+
+ if ( DmStrcmp(pKeyWord,"P") == 0 )
+ ParsePrincipal(pValue,TRUE,aDict);
+ else
+ if ( DmStrcmp(pKeyWord,"S") == 0 )
+ ParsePrincipal(pValue,FALSE,aDict);
+ else
+ if ( DmStrcmp(pKeyWord,"T") == 0 )
+ m_strTopic = pValue;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionItem::ParsePrincipal(CPCHAR szSegment,
+ BOOLEAN bIsIgnore,
+ const DMMap<INT32, DMString>& aDict )
+{
+ DMToken oParser(FALSE,szSegment,'+');
+ CPCHAR pSegment = NULL;
+
+ while ( (pSegment = oParser.nextSegment()) != NULL )
+ {
+ DMString strPrincipal;
+ if ( aDict.lookup(DmAtoi(pSegment), strPrincipal) )
+ {
+ if ( bIsIgnore == TRUE )
+ m_aIgnorePrincipals.push_back(DmtPrincipal(strPrincipal));
+ else
+ m_aNotifyPrincipals.push_back(DmtPrincipal(strPrincipal));
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Error(("event file format error - unknown id %s\n \n", pSegment));
+ return SYNCML_DM_FAIL;
+ }
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionItem::Serialize( DMFileHandler& dmf,
+ const DMMap<DMString, INT32>& aDict )
+{
+
+ SYNCML_DM_EVENT_ACTION_T nAction[4] = {SYNCML_DM_EVENT_ADD,
+ SYNCML_DM_EVENT_DELETE,
+ SYNCML_DM_EVENT_REPLACE,
+ SYNCML_DM_EVENT_INDIRECT};
+
+ SYNCML_DM_EVENT_TYPE_T nType[3] = { SYNCML_DM_EVENT_NODE,
+ SYNCML_DM_EVENT_CUMULATIVE,
+ SYNCML_DM_EVENT_DETAIL};
+
+
+ CPCHAR szEvent[4] = {"A", "D", "R", "I"};
+ CPCHAR szEventDetail[3] = { "N", "C", "F"};
+ UINT8 index;
+
+ SYNCML_DM_RET_STATUS_T dm_stat =SYNCML_DM_SUCCESS;
+ dm_stat = DMConfigItem::Serialize(dmf);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DMString str = "";
+ for (index = 0; index < DIM(nAction); index++ )
+ {
+ if ( IsEnabled(nAction[index],NULL) )
+ AttachProperty( str, '&', szEvent[index] );
+ }
+ for (index = 0; index < DIM(nType); index++ )
+ {
+ if ( m_nType == nType[index] )
+ {
+ AttachProperty( str, '&', szEventDetail[index] );
+ break;
+ }
+ }
+
+ DMString strProperty;
+ if ( m_strTopic != NULL )
+ {
+ strProperty = "T=" + m_strTopic;
+ AttachProperty(str, '&', strProperty);
+ }
+
+ if ( m_aIgnorePrincipals.size() )
+ {
+ DMConfigItem::CreateProperty( m_aIgnorePrincipals, "P=",aDict,strProperty);
+ AttachProperty(str, '&', strProperty);
+ }
+
+ if ( m_aNotifyPrincipals.size() )
+ {
+ DMConfigItem::CreateProperty( m_aNotifyPrincipals, "S=",aDict,strProperty);
+ AttachProperty(str, '&', strProperty);
+ }
+
+ if ( str.empty() )
+ return SYNCML_DM_SUCCESS;
+
+ if ( dmf.write(str.c_str(), str.length()) != SYNCML_DM_SUCCESS ||
+ dmf.write( "\n", 1 )!= SYNCML_DM_SUCCESS )
+ return SYNCML_DM_IO_FAILURE;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+void DMSubscriptionItem::UpdateDictionary( DMMap<DMString, INT32>& aDict )
+{
+ DMVector<DmtPrincipal> aPrincipals;
+ INT32 iDummy = 0;
+ INT32 index=0;
+
+ for (index=0; index<m_aIgnorePrincipals.size(); index++)
+ {
+ if ( !aDict.lookup( m_aIgnorePrincipals[index].getName(), iDummy ) ){
+ aDict.put( m_aIgnorePrincipals[index].getName(), aDict.size() + 1);
+ }
+ }
+
+ for (index=0; index<m_aNotifyPrincipals.size(); index++)
+ {
+ if ( !aDict.lookup(m_aNotifyPrincipals[index].getName(), iDummy ) ){
+ aDict.put( m_aNotifyPrincipals[index].getName(), aDict.size() + 1);
+ }
+ }
+}
diff --git a/engine/dmlib/dmengine/dm_ua/src/dmSubscriptionManager.cc b/engine/dmlib/dmengine/dm_ua/src/dmSubscriptionManager.cc
new file mode 100644
index 0000000..09859ff
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_ua/src/dmSubscriptionManager.cc
@@ -0,0 +1,584 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmSubscriptionManager.cc
+
+ General Description: Implementation of the DMSubscriptionManager class
+
+==================================================================================================*/
+
+#include "dm_tree_class.H"
+#include "dmSubscriptionManager.h"
+#include "dm_uri_utils.h"
+#include "xpl_Logger.h"
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::Init( CEnv* env, DMTree* tree )
+{
+ return DMConfigManager::Init(env,tree,SYNCML_DM_FILE_EVENT);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::UpdateEvents(CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ SyncML_DM_Archiver & m_oArchiver = m_pTree->GetArchiver();
+
+ if ( nAction == SYNCML_DM_EVENT_RENAME )
+ {
+ dm_stat = m_oArchiver.UpdateEvents(szPath,szNewName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::CleanEvents(CPCHAR szPath)
+{
+ SyncML_DM_Archiver & m_oArchiver = m_pTree->GetArchiver();
+
+ return m_oArchiver.CleanEvents(szPath);
+
+}
+
+CPCHAR
+DMSubscriptionManager::ResetName(BOOLEAN bIsEnabledByParent,
+ DMEventSubscription * pItem,
+ CPCHAR szNewName)
+{
+ if ( bIsEnabledByParent && pItem->GetType() == SYNCML_DM_EVENT_CUMULATIVE )
+ return NULL;
+ else
+ return szNewName;
+}
+
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::ProcessUpdateForSubscription(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName)
+{
+
+
+ if ( pArchive == NULL )
+ return SYNCML_DM_FAIL;
+
+ DMString strTrackedPath = szPath;
+
+ PDMConfigItem pItem;
+ CPCHAR pNewName = NULL;
+ BOOLEAN bIsEnabledByParent = FALSE;
+
+
+ if ( IsEnabled( strTrackedPath,nAction,pItem, bIsEnabledByParent,FALSE) )
+ {
+ pNewName = ResetName(bIsEnabledByParent,(DMSubscriptionItem*)(pItem.GetPtr()),szNewName);
+ pArchive->GetEventLogger().OnNodeChanged( strTrackedPath,
+ nAction,
+ pItem,
+ bIsEnabledByParent,
+ pNewName);
+ }
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::ProcessUpdateForPlugin(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName)
+{
+
+ if ( pArchive == NULL )
+ return SYNCML_DM_FAIL;
+
+ DMString strTrackedPath = szPath;
+
+ PDMPlugin pPlugin;
+ CPCHAR pNewName = NULL;
+ BOOLEAN bIsEnabledByParent = FALSE;
+
+
+ if ( !IsEnabled(strTrackedPath,nAction,pPlugin, bIsEnabledByParent,FALSE) )
+ return SYNCML_DM_SUCCESS;
+
+ pNewName = ResetName(bIsEnabledByParent,(DMSubscriptionItem*)(pPlugin.GetPtr()),szNewName);
+ pArchive->GetEventLogger().OnNodeChanged(strTrackedPath,
+ nAction,
+ pPlugin,
+ bIsEnabledByParent,
+ pNewName);
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::OnNodeChanged(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ CPCHAR szNewName)
+{
+
+ Deserialize();
+
+
+ XPL_LOG_DM_TMN_Debug(("Received update notification for path= %s\n", szPath));
+
+ UpdateEvents(szPath,nAction,szNewName);
+ if ( !pArchive->GetEventLogger().IsIgnoreSubscriptionEvent(szPath, nAction,szNewName) )
+ ProcessUpdateForSubscription(pArchive,szPath,nAction,szNewName);
+ if ( !pArchive->GetEventLogger().IsIgnorePluginEvent(szPath, nAction,szNewName) )
+ ProcessUpdateForPlugin(pArchive,szPath,nAction,szNewName);
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::ProcessDeleteForSubscription(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ BOOLEAN bIsChild )
+{
+ if ( pArchive == NULL )
+ return SYNCML_DM_FAIL;
+
+ DMString strTrackedPath = szPath;
+ PDMConfigItem pItem;
+ BOOLEAN bIsEnabledByParent = FALSE;
+
+
+ if ( IsEnabled(strTrackedPath,SYNCML_DM_EVENT_DELETE,pItem, bIsEnabledByParent,bIsChild) )
+ {
+ pArchive->GetEventLogger().OnNodeChanged(strTrackedPath,
+ SYNCML_DM_EVENT_DELETE,
+ pItem,
+ bIsEnabledByParent);
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::ProcessDeleteForPlugin(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ BOOLEAN bIsChild)
+{
+ if ( pArchive == NULL )
+ return SYNCML_DM_FAIL;
+
+ DMString strTrackedPath = szPath;
+ PDMPlugin pPlugin;
+ BOOLEAN bIsEnabledByParent = FALSE;
+
+ if ( IsEnabled(strTrackedPath,SYNCML_DM_EVENT_DELETE,pPlugin,bIsEnabledByParent,bIsChild) )
+ {
+ pArchive->GetEventLogger().OnNodeChanged(strTrackedPath,
+ SYNCML_DM_EVENT_DELETE,
+ pPlugin,
+ bIsEnabledByParent);
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::OnNodeDeleted(SyncML_DM_Archive * pArchive,
+ CPCHAR szPath,
+ const DMStringVector & aDeletedChildren )
+{
+
+ Deserialize();
+
+ XPL_LOG_DM_TMN_Debug(("Received delete notification for path= %s\n", szPath));
+
+
+ CleanEvents(szPath);
+ if ( !pArchive->GetEventLogger().IsIgnoreSubscriptionEvent(szPath,SYNCML_DM_EVENT_DELETE) )
+ ProcessDeleteForSubscription(pArchive,szPath,FALSE);
+ if ( !pArchive->GetEventLogger().IsIgnorePluginEvent(szPath,SYNCML_DM_EVENT_DELETE) )
+ ProcessDeleteForPlugin(pArchive,szPath,FALSE);
+
+ for (INT32 index=0; index<aDeletedChildren.size(); index++)
+ {
+ CPCHAR szChildPath = aDeletedChildren[index].c_str();
+ if ( !pArchive->GetEventLogger().IsIgnoreSubscriptionEvent(szChildPath,SYNCML_DM_EVENT_DELETE) )
+ ProcessDeleteForSubscription(pArchive,szChildPath,TRUE);
+ if ( !pArchive->GetEventLogger().IsIgnorePluginEvent(szChildPath,SYNCML_DM_EVENT_DELETE) )
+ ProcessDeleteForPlugin(pArchive,szChildPath,TRUE);
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+
+BOOLEAN
+DMSubscriptionManager::IsParentEnabled(DMString & strPath,
+ CPCHAR szParent,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ DMEventSubscription * pItem) const
+{
+
+ if ( pItem->IsEnabled( nAction, m_pTree ) )
+ {
+ if ( pItem->GetType() == SYNCML_DM_EVENT_CUMULATIVE )
+ {
+ strPath = szParent;
+ return TRUE;
+ }
+ else
+ if ( pItem->GetType() == SYNCML_DM_EVENT_DETAIL )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+
+BOOLEAN
+DMSubscriptionManager::IsParentEnabledBySubscription(DMString & strPath,
+ CPCHAR szParent,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMConfigItem & pItem) const
+{
+
+ INT32 index = Find(szParent,pItem);
+ if ( index == -1 )
+ return FALSE;
+
+ DMSubscriptionItem * pSubscriptionItem = (DMSubscriptionItem*)(pItem.GetPtr());
+
+ return IsParentEnabled(strPath,
+ szParent,
+ nAction,
+ (DMEventSubscription*)pSubscriptionItem);
+}
+
+
+
+BOOLEAN
+DMSubscriptionManager::IsParentEnabledByPlugin(DMString & strPath,
+ CPCHAR szParent,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMPlugin & pPlugin) const
+{
+ DMPluginManager & oPluginManager = m_pTree->GetPluginManager();
+
+ pPlugin = oPluginManager.FindCommitPlugin(szParent);
+ if ( pPlugin == NULL )
+ return FALSE;
+
+ return IsParentEnabled(strPath,
+ szParent,
+ nAction,
+ (DMEventSubscription*)(pPlugin.GetPtr()));
+}
+
+
+
+BOOLEAN
+DMSubscriptionManager::IsEnabledBySubscription(DMString & strPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMConfigItem & pItem,
+ BOOLEAN & bIsEnabledByParent,
+ BOOLEAN bIsChild) const
+{
+
+ bIsEnabledByParent = FALSE;
+ INT32 index = Find(strPath,pItem);
+ if ( index != -1 )
+ {
+ if ( ((DMSubscriptionItem*)(pItem.GetPtr()))->IsEnabled( nAction,m_pTree) )
+ return TRUE;
+ }
+
+ if ( bIsChild )
+ return FALSE;
+
+ DMURI oURI(TRUE,strPath.GetBuffer());
+ CPCHAR pParent = NULL;
+ bIsEnabledByParent = TRUE;
+
+ while ( (pParent = oURI.getParentURI()) != NULL )
+ {
+ if ( IsParentEnabledBySubscription(strPath,pParent,nAction, pItem) )
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+
+
+
+BOOLEAN
+DMSubscriptionManager::IsEnabledByPlugin(DMString & strPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMPlugin & pPlugin,
+ BOOLEAN & bIsEnabledByParent,
+ BOOLEAN bIsChild) const
+{
+
+ DMPluginManager & oPluginManager = m_pTree->GetPluginManager();
+
+ bIsEnabledByParent = FALSE;
+ pPlugin = oPluginManager.FindCommitPlugin(strPath);
+ if ( pPlugin != NULL )
+ {
+ if ( pPlugin->IsEnabled( nAction,m_pTree) )
+ return TRUE;
+ }
+
+ if ( bIsChild )
+ return FALSE;
+
+ DMURI oURI(TRUE,strPath.GetBuffer());
+ CPCHAR pParent = NULL;
+ bIsEnabledByParent = TRUE;
+
+ while ( (pParent = oURI.getParentURI()) != NULL )
+ {
+ if ( IsParentEnabledByPlugin(strPath,pParent,nAction, pPlugin) )
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::GetLogPath(DMString & strPath,
+ CPCHAR szMDF) const
+{
+
+ UINT32 nSegmentCount = 0;
+ {
+ DMParser oParser(szMDF);
+ nSegmentCount = oParser.getSegmentsCount();
+ }
+ char * pEnd = NULL;
+
+ {
+ DMParser oParser(strPath);
+ if ( nSegmentCount == oParser.getSegmentsCount() )
+ return SYNCML_DM_SUCCESS;
+
+ for (INT32 count=0; count<=(INT32)nSegmentCount; count++)
+ pEnd = (char*)oParser.nextSegment();
+ }
+
+ if ( pEnd != NULL )
+ {
+ pEnd--;
+ *pEnd = '\0'; // pEnd can't be NULL
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+
+
+BOOLEAN
+DMSubscriptionManager:: IsEnabled(DMString & strPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMConfigItem & pItem,
+ BOOLEAN & bIsEnabledByParent,
+ BOOLEAN bIsChild) const
+{
+
+ BOOLEAN bIsEnabled = FALSE;
+
+ if ( !m_aConfig.size() )
+ return FALSE;
+
+ bIsEnabled = IsEnabledBySubscription(strPath,
+ nAction,
+ pItem,
+ bIsEnabledByParent,
+ bIsChild);
+ if ( bIsEnabled )
+ return TRUE;
+
+ DMString strMDF;
+ SYNCML_DM_RET_STATUS_T ret_status;
+ DMMetaDataManager & m_oMDFObj = m_pTree->GetMetaDataManager();
+ ret_status = m_oMDFObj.GetPath(strPath, strMDF);
+
+ if ( ret_status == SYNCML_DM_SUCCESS && strMDF != strPath)
+ {
+ bIsEnabled = IsEnabledBySubscription(strMDF,
+ nAction,
+ pItem,
+ bIsEnabledByParent,
+ bIsChild);
+
+ if ( bIsEnabled && bIsChild )
+ {
+ if ( ((DMSubscriptionItem*)(pItem.GetPtr()))->GetType() == SYNCML_DM_EVENT_CUMULATIVE )
+ GetLogPath(strPath,(CPCHAR)strMDF);
+
+ return TRUE;
+ }
+ }
+
+ return bIsEnabled;
+
+}
+
+
+
+BOOLEAN
+DMSubscriptionManager:: IsEnabled(DMString & strPath,
+ SYNCML_DM_EVENT_ACTION_T nAction,
+ PDMPlugin & pPlugin,
+ BOOLEAN & bIsEnabledByParent,
+ BOOLEAN bIsChild) const
+{
+
+ BOOLEAN bIsEnabled = FALSE;
+
+ bIsEnabled = IsEnabledByPlugin(strPath,
+ nAction,
+ pPlugin,
+ bIsEnabledByParent,
+ bIsChild);
+
+ if ( bIsEnabled )
+ return TRUE;
+
+ DMString strMDF;
+ SYNCML_DM_RET_STATUS_T ret_status;
+ DMMetaDataManager & m_oMDFObj = m_pTree->GetMetaDataManager();
+ ret_status = m_oMDFObj.GetPath(strPath, strMDF);
+
+ if ( ret_status == SYNCML_DM_SUCCESS && strMDF != strPath)
+ {
+ bIsEnabled = IsEnabledByPlugin(strMDF,
+ nAction,
+ pPlugin,
+ bIsEnabledByParent,
+ bIsChild);
+
+ if ( bIsEnabled && bIsChild == FALSE )
+ {
+ if ( (pPlugin.GetPtr())->GetType() == SYNCML_DM_EVENT_CUMULATIVE )
+ GetLogPath(strPath,(CPCHAR)strMDF);
+ return TRUE;
+ }
+ }
+
+ return bIsEnabled;
+
+}
+
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMSubscriptionManager::EnableEvent(CPCHAR szPath,
+ const DmtEventSubscription & oEvent)
+{
+
+ CheckLocking();
+
+ DMString szMDF;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMMetaDataManager & m_oMDFObj = m_pTree->GetMetaDataManager();
+ dm_stat = m_oMDFObj.GetPath(szPath, szMDF);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Error(("MDF path isn't found, path = %s\n", szPath));
+ return dm_stat;
+ }
+
+ Delete(szPath);
+
+ DMSubscriptionItem * pEventItem = new DMSubscriptionItem(szPath);
+ if ( pEventItem == NULL )
+ {
+ XPL_LOG_DM_TMN_Error(("Not enough memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ dm_stat = pEventItem->Set(oEvent);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Error(("Event data can't be set for path = %s\n", szPath));
+ delete pEventItem;
+ return dm_stat;
+ }
+
+ m_aConfig.push_back(PDMConfigItem((DMConfigItem*)pEventItem));
+ m_bChanged = true;
+ return dm_stat;
+}
+
+
+void DMSubscriptionManager::GetFileName(DMString & strFileName)
+{
+ m_pEnv->GetWFSFullPath(DM_DEFAULT_EVENT_FILENAME,strFileName);
+}
+
+DMConfigItem * DMSubscriptionManager::AllocateConfigItem()
+{
+ return new DMSubscriptionItem();
+}
+
+
+SYNCML_DM_RET_STATUS_T DMSubscriptionManager::GetEvent(CPCHAR szPath,
+ DmtEventSubscription & oEvent)
+{
+ PDMConfigItem pItem;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ Deserialize();
+
+ dm_stat = Get(szPath,pItem);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DMSubscriptionItem * ptr = ((DMSubscriptionItem*)(pItem.GetPtr()));
+
+ return oEvent.Set(ptr->GetAction(),
+ ptr->GetType(),
+ ptr->GetTopic(),
+ ptr->GetPrincipals(TRUE),
+ ptr->GetPrincipals(FALSE));
+}
diff --git a/engine/dmlib/dmengine/dm_util/hdr/dm_uri_utils.h b/engine/dmlib/dmengine/dm_util/hdr/dm_uri_utils.h
new file mode 100644
index 0000000..c5a35fd
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_util/hdr/dm_uri_utils.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMURIUTILITY_H
+#define DMURIUTILITY_H
+
+/*==================================================================================================
+
+Header Name: dm_uri_utils.h
+
+General Description: This file contains declaration declaration of helper functions for uri processing
+
+==================================================================================================*/
+
+#include <stdlib.h>
+#include "xpl_Types.h"
+#include "syncml_dm_data_types.h"
+#include "dmvector.h"
+
+#define SYNCML_DM_NULL ('\0')
+#define SYNCML_DM_AMPERSAND ('&')
+#define SYNCML_DM_STAR ('*')
+#define SYNCML_DM_PLUS ('+')
+#define SYNCML_DM_EQUAL_TO ('=')
+#define SYNCML_DM_FORWARD_SLASH ('/')
+#define SYNCML_DM_DOT ('.')
+#define SYNCML_DM_PERCENTAGE ('%')
+#define SYNCML_DM_QUESTION_MARK ('?')
+#define SYNCML_DM_SPACE (' ')
+#define SYNCML_DM_COMMA (',')
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void DmParseURI(CPCHAR szPath, DMString& strURI, DMString& strKey );
+
+bool DmStringParserGetItem( DMString& strItem, DMString& strReminder, char cDelim );
+
+int DmStrToStringVector(const char * pStr, int nLen, DMStringVector& oVector, char cDelim );
+
+char* GetURISegment(char **ppbURI);
+
+char* GetStringSegment(char **ppbURI, char cDelim);
+
+/**
+ * Verifies if path is the DMAcc path
+ * \param szPath [in/out] - node path
+ * \return TRUE if path is the DMAcc path
+ */
+SYNCML_DM_RET_STATUS_T DmIsDMAccNodePath(CPCHAR szPath);
+
+/**
+ * Verifies if path is enabled
+ * \param szPath [in/out] - node path
+ * \return TRUE if enabled
+ */
+BOOLEAN DmIsEnabledURI(CPCHAR szPath);
+
+/**
+ * Verifies if szParentURI is direct or indirect parent (including node itself) of node szChildURI
+ * Both URIs can contain multi-node characters ('*')
+ * \param szParentURI [in] - parent path
+ * \param szChildURI [in] - child path
+ * \return TRUE if path is a parent
+ */
+BOOLEAN DmIsParentURI(CPCHAR szParentURI, CPCHAR szChildURI);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+class CEnv
+{
+public:
+ CEnv();
+
+ BOOLEAN Init();
+ void Done();
+
+ CPCHAR GetWFS() const { return m_szWFS;}
+ CPCHAR GetMainRFS() const { return m_szMainRFS; }
+ int GetRFSCount() const { return m_aFSes.size() > 1 ? m_aFSes.size() - 1 : 0;}
+ CPCHAR GetRFS( int index ) const { return (index +1) >= m_aFSes.size() ? NULL : m_aFSes[index +1].c_str(); }
+ CPCHAR GetWFSFullPath(CPCHAR name, DMString & path);
+ CPCHAR GetMainRFSFullPath(CPCHAR name, DMString & path);
+ CPCHAR GetRFSFullPath(int index, CPCHAR name, DMString & path);
+
+private:
+ DMStringVector m_aFSes; // first element is WFS, second is MainRFS, all other - auxulary RFS
+ CPCHAR m_szWFS;
+ CPCHAR m_szMainRFS;
+
+ CPCHAR GetFullPath(CPCHAR fs_path, CPCHAR name, DMString & path);
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_util/hdr/dmbuffer.h b/engine/dmlib/dmengine/dm_util/hdr/dmbuffer.h
new file mode 100644
index 0000000..e35afee
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_util/hdr/dmbuffer.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMBUFFER_H__
+#define __DMBUFFER_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "xpl_Types.h"
+#include "dmstring.h"
+
+/**
+ * A simple Buffer class.
+ */
+class DMBuffer
+{
+ public:
+ DMBuffer();
+ ~DMBuffer();
+
+ DMBuffer & operator=(const DMBuffer& pBuffer);
+
+ inline UINT8* getBuffer() const {return m_pBuf;}
+
+ inline UINT32 getSize() const {return m_nSize;}
+
+ UINT8 * allocate(UINT32 nCapacity);
+
+ UINT8 * assign(CPCHAR szStr);
+
+ UINT8 * assign(const UINT8 * pBuffer, INT32 size);
+ void append(const UINT8 * pBuffer, INT32 size);
+
+ inline UINT8 * assign(CPCHAR szStr, INT32 size) { return assign((UINT8*)szStr,size); }
+
+ void clear();
+ void free();
+ void reset();
+
+ void setSize(UINT32 size);
+
+ void copyTo(UINT8 **ppBuffer) const;
+
+ void copyTo(INT32 offset,INT32 size, DMBuffer& pBuffer) const;
+
+ inline void copyTo(char ** ppStr) const { copyTo((UINT8**)ppStr); }
+
+ void copyTo(char * pStr) const;
+
+ void copyTo(DMString & sStr) const;
+
+ BOOLEAN compare(CPCHAR pStr) const;
+
+ BOOLEAN compare(CPCHAR pStr, UINT32 len) const;
+
+ BOOLEAN empty() { return ((m_nSize == 0) ? TRUE : FALSE); }
+
+ void attach(UINT8 * pBuffer, INT32 nCapacity);
+
+ UINT8 * detach();
+
+
+ private:
+ UINT8 *m_pBuf;
+ UINT32 m_nSize;
+ UINT32 m_nCapacity;
+};
+
+#endif //End of include File
diff --git a/engine/dmlib/dmengine/dm_util/hdr/dmdefs.h b/engine/dmlib/dmengine/dm_util/hdr/dmdefs.h
new file mode 100644
index 0000000..137b0da
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_util/hdr/dmdefs.h
@@ -0,0 +1,16 @@
+#ifndef DM_DEFS_H
+#define DM_DEFS_H
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include "dmMemory.h"
+
+
+#define DIM(array) (sizeof(array)/sizeof((array)[0]))
+
+#define FreeAndSetNull(_x) \
+ if ((_x)!=NULL) { DmFreeMem(_x); (_x)=NULL; }
+
+
+#endif /* DMDEFS_H */
+
diff --git a/engine/dmlib/dmengine/dm_util/hdr/dmtoken.h b/engine/dmlib/dmengine/dm_util/hdr/dmtoken.h
new file mode 100644
index 0000000..cc87925
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_util/hdr/dmtoken.h
@@ -0,0 +1,271 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTOKEN_H__
+#define __DMTOKEN_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmToken.h
+
+General Description: This file contains declaration of utility classes DMToken, DMURI, DMParser
+
+==================================================================================================*/
+
+#include "xpl_Types.h"
+#include "dmStringUtil.h"
+#include "dm_uri_utils.h"
+
+/**
+ * DMToken represents a parser of a string with segments separated by specified delimeter.
+ */
+class DMToken
+{
+ public:
+ /**
+ * Default constructor
+ */
+ DMToken();
+
+ /**
+ * Constructor that sets value of delimeter
+ * \param delimeter [in] - delimeter
+ */
+ DMToken(char delimeter);
+
+ /**
+ * Constructor that sets parameters of an object
+ * \param bIsAlloc [in] - specifies if internal buffer should be allocated and string copied into it
+ * \param szStr [in] - string to parse
+ * \param delimeter [in] - delimeter
+ */
+ DMToken(BOOLEAN bIsAlloc, CPCHAR szStr, char delimeter);
+
+ /**
+ * Destructor
+ */
+ ~DMToken();
+
+ /**
+ * Assigns string to parse
+ * \param szStr [in] - string to parse
+ * \return Return Type (CPCHAR)
+ * - Pointer on internal buffer if operation is completed successfully.
+ * - NULL otherwise.
+ */
+ CPCHAR assign(CPCHAR szStr);
+
+ /**
+ * Retrieves next segment of a string
+ * \return Return Type (CPCHAR)
+ * - Pointer on next segment if operation is completed successfully.
+ * - NULL otherwise.
+ */
+ CPCHAR nextSegment();
+
+ /**
+ * Retrieves pointer on string
+ */
+ char * getBuffer() const { return m_pStr; }
+
+ /**
+ * Retrieves length of a string
+ */
+ INT32 length() { return m_pStr ? DmStrlen(m_pStr):0; }
+
+ /**
+ * Retrieves count of segments in a string
+ */
+ UINT32 getSegmentsCount();
+
+ /**
+ * Resets object
+ */
+ void reset();
+
+
+ protected:
+ /* Pointer on current segment position */
+ char * m_pTokenPos;
+ /* Pointer on current delimeter position */
+ char * m_pDelimPos;
+ /* Pointer on parsed string */
+ char * m_pStr;
+ /* Delimeter */
+ char m_cDelim;
+ /* Specifies if internal buffer should eb allocated */
+ BOOLEAN m_bIsAlloc;
+
+
+};
+
+
+/**
+* DMToken represents a URI parser
+*/
+class DMURI : public DMToken
+{
+
+public:
+ /**
+ * Default constructor
+ */
+ DMURI();
+
+ /**
+ * Constructor that sets parameters of an object
+ * \param bIsAlloc [in] - specifies if internal buffer should be allocated and string copied into it
+ */
+ DMURI(BOOLEAN bIsAlloc);
+
+ /**
+ * Constructor that sets parameters of an object
+ * \param bIsAlloc [in] - specifies if internal buffer should be allocated and string copied into it
+ * \param szURI [in] - string to parse
+ */
+ DMURI(BOOLEAN bIsAlloc, CPCHAR szURI);
+
+ /**
+ * Retrieves last segment of URI
+ * \return Return Type (CPCHAR)
+ * - Pointer on last segment if operation is completed successfully.
+ * - NULL otherwise.
+ */
+ CPCHAR getLastSegment();
+
+ /**
+ * Retrieves tail segments of URI
+ * \return Return Type (CPCHAR)
+ * - Pointer on last segment if operation is completed successfully.
+ * - NULL otherwise.
+ */
+ CPCHAR getTailSegments() const;
+
+ /**
+ * Retrieves parent URI (without last segment)
+ * \return Return Type (CPCHAR)
+ * - Pointer on last segment if operation is completed successfully.
+ * - NULL otherwise.
+ */
+ CPCHAR getParentURI();
+
+};
+
+
+/**
+* Represents segments of URI
+*/
+struct DM_URI_SEGMENT_T
+{
+
+public:
+ /**
+ * Default constructor
+ */
+ DM_URI_SEGMENT_T()
+ {
+ m_pStr = 0;
+ m_nLen = 0;
+ }
+
+ /* Pointer on segment */
+ char * m_pStr;
+ /* Segment length */
+ INT32 m_nLen;
+};
+
+
+/**
+* DMToken represents a URI parser
+*/
+class DMParser
+{
+
+public:
+ /**
+ * Constructor that sets parameters of an object
+ * \param delimeter [in] - delimeter
+ */
+ DMParser(char delimeter = SYNCML_DM_FORWARD_SLASH);
+
+ /**
+ * Constructor that sets parameters of an object
+ * \param szURI [in] - URI to parse
+ * \param delimeter [in] - delimeter
+ */
+ DMParser(CPCHAR szURI, char delimeter = SYNCML_DM_FORWARD_SLASH);
+
+ /**
+ * Destructor
+ */
+ ~DMParser();
+
+ /**
+ * Retrieves count of segments in a string
+ */
+ inline UINT32 getSegmentsCount() const { return m_nSegmentsCount; }
+
+ /**
+ * Assigns string to parse
+ * \param szStr [in] - string to parse
+ * \return Return Type (CPCHAR)
+ * - Pointer on internal buffer if operation is completed successfully.
+ * - NULL otherwise.
+ */
+ CPCHAR assign(CPCHAR szStr);
+
+ /**
+ * Retrieves next segment of a string
+ * \return Return Type (CPCHAR)
+ * - Pointer on next segment if operation is completed successfully.
+ * - NULL otherwise.
+ */
+ CPCHAR nextSegment();
+
+ /**
+ * Searches segment in the URI
+ * \return TRUE if segment is found
+ */
+ BOOLEAN findSegment(CPCHAR szSegment);
+
+ /**
+ * Resets object
+ */
+ void reset();
+
+protected:
+ /* Parsed segments */
+ DM_URI_SEGMENT_T * m_aSegments;
+ /* Current segment index */
+ INT32 m_nCurrentSegment;
+ /* Segments count */
+ INT32 m_nSegmentsCount;
+ /* Pointer on current segment position */
+ char * m_pTokenPos;
+ /* Pointer on current delimeter position */
+ char * m_pDelimPos;
+ /* Pointer on parsed string */
+ char * m_pStr;
+ /* Delimeter */
+ char m_cDelim;
+
+};
+
+#endif
diff --git a/engine/dmlib/dmengine/dm_util/hdr/syncml_dm_data_types.h b/engine/dmlib/dmengine/dm_util/hdr/syncml_dm_data_types.h
new file mode 100644
index 0000000..64ebef6
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_util/hdr/syncml_dm_data_types.h
@@ -0,0 +1,339 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_DATA_TYPES_H
+#define SYNCML_DM_DATA_TYPES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*==================================================================================================
+
+ Header Name: syncml_dm_data_types.h
+
+ General Description: This contains declaration of DM engine general enums and data structures.
+
+==================================================================================================*/
+
+#include "dmtError.h"
+#include "dmMemory.h"
+#include "dmtDefs.h"
+
+/*==================================================================================================
+ CONSTANTS
+==================================================================================================*/
+
+#define DM_MD5_DIGEST_LENGTH 16 /* For package 0 data */
+
+#define SYNCML_DM_MAX_SERVER_ALLOWED 3 /* for Current implementation */
+
+#define SYNCML_DM_URI_MAX_DEPTH 20 //Max allowed levels
+
+/* The DDF file for Motorola SyncML DM devices defines MaxTotLen = 127, and MaxSegLen = 32.
+ MaxTotLen is limited to 127 due to persistent storage implementation. It serializes the tree
+ structure into a flat file using WBXML format; opaque data values are stored with a multi-byte
+ integer encoded length. The implementation of the mb_uint_32 format is limited to encode/decode
+ up to the value 127. Anywhere memory is allocated for the Max URI length should use
+ SYNCML_DM_URI_MAX_TOTAL_LENGTH+1 to account for a null string terminator, since the code works
+ with the URI as a string. In the same manner, SYNCML_DM_URI_MAX_SEGMENT_LENGTH+1 should be used
+ to account for its string terminator. Note! The SyncML specs state that by default, characters
+ are encoded in UTF-8. The MaxTotLen and MaxSegLen values indicate the number of characters the
+ device allows, which may be LESS than the number of bytes it actually takes to UTF-8 encode the
+ string. In theory, the size in bytes of the memory to hold these strings should be much larger,
+ to allow the UTF-8 encoded data to fit (as much as 2 or 3 times the size, worst case). At the
+ moment, the byte-size and character-length for these limits are coded to be the same, which
+ always works if the characters are ASCII. */
+
+#define SYNCML_DM_URI_MAX_TOTAL_LENGTH 255 // will use too many stack spaces
+#define SYNCML_DM_URI_MAX_SEGMENT_LENGTH 120
+
+#define SYNCML_DM_MAX_TITLE_LENGTH 255
+#define SYNCML_DM_MAX_TSTAMP_LENGTH 17
+#define SYNCML_DM_STR_MAX_LEN 120 /* Max length of a string leaf node data value. */
+#define SYNCML_DM_MAX_OBJ_SIZE 262080 // This is the maximum FOTA obj size required by TRS.
+
+#define DEFAULT_DM_SMLTK_WORKSPACE_SIZE (120*1024)
+
+#define DM_MSG_OVERHEAD 600 /* SyncML DM document overhead (none data part). */
+extern INT32 g_iDMWorkspaceSize;
+
+#define DM_FSTAB_FILENAME "fstab"
+#define DM_ROOT_MDF_FILENAME "root.bmdf"
+#define DM_PLUGINS_INI_FILENAME "sysplugins.ini"
+#define DM_PLIGINS_INI_FILEEXTENSION "ini"
+#define DM_MDF_FILEEXTENSION "bmdf"
+#define DM_DEFAULT_ACL_FILENAME "acl.dat"
+#define DM_DEFAULT_EVENT_FILENAME "event.dat"
+#define DM_DATASUBFOLDER ""
+
+#define DM_MAX_CONFIG_LINE 400
+
+
+/*==================================================================================================
+ GLOBAL VARIABLES DECLARATION
+==================================================================================================*/
+/* These strings are used throughout the DM engine code. They are externed here to keep them
+ * in one ROM location. Please see the actual value definitions in "syncml_dm_main.cc".
+ */
+
+#define SYNCML_CONTENT_TYPE_DM_WBXML "application/vnd.syncml.dm+wbxml"
+#define SYNCML_CONTENT_TYPE_DM_XML "application/vnd.syncml.dm+xml"
+#define SYNCML_CONTENT_TYPE_DM_TNDS_WBXML "application/vnd.syncml.dmtnds+wbxml"
+#define SYNCML_CONTENT_TYPE_DM_TNDS_XML "application/vnd.syncml.dmtnds+xml"
+#define SYNCML_DM_PROTOCOL_VERSION_1_2 "DM/1.2"
+#define SYNCML_DM_PROTOCOL_VERSION_1_1 "DM/1.1"
+
+
+#define RECV_WORKSPACE_NAME "Received SyncML Document"
+#define SEND_WORKSPACE_NAME "Send SyncML Document"
+#define CACHE_WORKSPACE_NAME "SyncML Document Cache"
+
+#define DM_DEV_INFO_URI_PAK1 "./DevInfo?list=Struct"
+
+#define RECV_WORKSPACE_NAME "Received SyncML Document"
+#define SEND_WORKSPACE_NAME "Send SyncML Document"
+#define CACHE_WORKSPACE_NAME "SyncML Document Cache"
+
+#define DM_ROOT_URI "."
+#define DM_STR_SLASH "/"
+#define DM_INBOX "./Inbox"
+#define DM_DMACC_1_1_URI "./SyncML/DMAcc"
+#define DM_DMACC_1_2_URI "./DMAcc"
+#define DM_DMCON_URI "./SyncML/Con"
+
+#define DM_APPID "AppID"
+#define DM_SERVERID_1_2 "ServerID"
+#define DM_SERVERID_1_1 "ServerId"
+
+#define MNG_OBJID_DMACC1 "urn:oma:mo:oma-dm-dmacc:1.0"
+#define MNG_OBJID_DMACC2 "org.openmobilealliance/1.0/w7"
+
+#define DM_NAME "Name"
+#define DM_PREFCONREF "PrefConRef"
+#define DM_CONREF "ConRef"
+#define DM_TOCONREF "ToConRef"
+#define DM_APPADDR "AppAddr"
+#define DM_ADDR "Addr"
+#define DM_ADDRTYPE "AddrType"
+#define DM_PORT "Port"
+#define DM_PORTNBR "PortNbr"
+#define DM_USERNAME "UserName"
+#define DM_AUTHPREF "AuthPref"
+#define DM_CLIENTNONCE "ClientNonce"
+#define DM_SERVERNONCE "ServerNonce"
+#define DM_CLIENTPW "ClientPW"
+#define DM_SERVERPW "ServerPW"
+
+// OMA DM 1.2 changes
+#define DM_AAUTHPREF "AAuthPref"
+#define DM_APPAUTH "AppAuth"
+#define DM_AAUTHLEVEL "AAuthLevel"
+#define DM_AAUTHTYPE "AAuthType"
+#define DM_AAUTHNAME "AAuthName"
+#define DM_AAUTHSECRET "AAuthSecret"
+#define DM_AAUTHDATA "AAuthData"
+#define DM_EXT "Ext"
+#define DM_LASTCLIENTAUTHTYPE "LastClientAuthType"
+
+// Application service
+#define DM_APPID_VALUE "w7"
+
+#define DM_AUTHLEVEL_CLCRED "CLCRED"
+#define DM_AUTHLEVEL_SRVCRED "SRVCRED"
+#define DM_AUTHLEVEL_OBEX "OBEX"
+#define DM_AUTHLEVEL_HTTP "HTTP"
+
+#define DM_AUTHTYPE_HTTPBASIC "HTTP-BASIC"
+#define DM_AUTHTYPE_HTTPDIGEST "HTTP-DIGEST"
+#define DM_AUTHTYPE_BASIC "BASIC"
+#define DM_AUTHTYPE_DIGEST "DIGEST"
+#define DM_AUTHTYPE_HMAC "HMAC"
+#define DM_AUTHTYPE_TRANPORT "TRANSPORT"
+// end of OMA DM 1.2 changes
+
+#define DM_DEV_INFO_URI_PAK1 "./DevInfo?list=Struct"
+#define DM_DEV_INFO_DEVID_URI "./DevInfo/DevId"
+#define DM_DEV_INFO_MOD_URI "./DevInfo/Mod"
+#define DM_DEV_INFO_MAN_URI "./DevInfo/Man"
+
+#define SYNCML_AUTH_MAC "syncml:auth-MAC"
+#define SYNCML_AUTH_MD5 "syncml:auth-md5"
+#define SYNCML_AUTH_BASIC "syncml:auth-basic"
+#define SYNCML_B64 "b64"
+#define SYNCML_MAC_ALG "MD5"
+
+#define SYNCML_SYNCHDR "SyncHdr"
+#define SYNCML_REPLACE "Replace"
+#define SYNCML_ALERT "Alert"
+
+/*==================================================================================================
+ ENUMS
+==================================================================================================*/
+/* Need to find the right global .h file for these defines */
+
+typedef UINT32 MAX_MSG_SIZE_T;
+
+/* These enum values are used to indicate the node scope for DMTNM_NODE_SCOPE */
+enum
+{
+ DMTNM_NODE_PERMANENT = 1,
+ DMTNM_NODE_DYNAMIC = 2
+};
+typedef UINT8 DMTNM_NODE_SCOPE;
+
+enum
+{
+ DMTNM_NODE_INTERIOR = 1,
+ DMTNM_NODE_LEAF = 2
+};
+typedef UINT8 DMTNM_NODE_TYPE;
+
+/* These enum values are used to indicate command type for SYNCML_DM_COMMAND_T.
+ * DON'T CHANGE THE ORDER OF THIS ENUM, TEHY ARE USED BY FEATURE DATABASES. */
+enum
+{
+ SYNCML_DM_NO_COMMAND,
+ SYNCML_DM_ADD,
+ SYNCML_DM_DELETE,
+ SYNCML_DM_REPLACE,
+ SYNCML_DM_GET,
+ SYNCML_DM_RENAME,
+ SYNCML_DM_EXEC,
+ SYNCML_DM_COPY,
+ SYNCML_DM_ALERT,
+ SYNCML_DM_HEADER,
+ SYNCML_DM_STATUS,
+ SYNCML_DM_ATOMIC,
+ SYNCML_DM_SEQUENCE,
+ SYNCML_DM_MAX_CMD,
+ SYNCML_DM_ADD_CHILD,
+ SYNCML_DM_RELEASE,
+ SYNCML_DM_ROLLBACK,
+ SYNCML_DM_COMMIT
+};
+typedef UINT8 SYNCML_DM_COMMAND_T;
+
+/* These enum values are used to indicate the format of the data for SYNCML_DM_FORMAT_T */
+enum
+{
+ SYNCML_DM_FORMAT_BIN = SYNCML_DM_DATAFORMAT_BIN,
+ SYNCML_DM_FORMAT_BOOL = SYNCML_DM_DATAFORMAT_BOOL,
+ SYNCML_DM_FORMAT_B64 = SYNCML_DM_DATAFORMAT_B64,
+ SYNCML_DM_FORMAT_CHR = SYNCML_DM_DATAFORMAT_STRING,
+ SYNCML_DM_FORMAT_INT = SYNCML_DM_DATAFORMAT_INT,
+ SYNCML_DM_FORMAT_NODE = SYNCML_DM_DATAFORMAT_NODE,
+ SYNCML_DM_FORMAT_NULL = SYNCML_DM_DATAFORMAT_NULL,
+ SYNCML_DM_FORMAT_XML = SYNCML_DM_DATAFORMAT_XML,
+ SYNCML_DM_FORMAT_FLOAT = SYNCML_DM_DATAFORMAT_FLOAT,
+ SYNCML_DM_FORMAT_DATE = SYNCML_DM_DATAFORMAT_DATE,
+ SYNCML_DM_FORMAT_TIME = SYNCML_DM_DATAFORMAT_TIME,
+ SYNCML_DM_FORMAT_TEST = 9,
+ SYNCML_DM_FORMAT_INVALID = 21,
+ SYNCML_DM_FORMAT_NODE_PDATA = 22 /* special type for serialization only */
+};
+typedef UINT8 SYNCML_DM_FORMAT_T;
+
+
+/* These values came from the DM spec, are used for SYNCML_DM_ALERT_CODE. */
+enum
+{
+ DM_ALERT_DISPLAY = 1100,
+ DM_ALERT_CONTINUE_OR_ABORT = 1101,
+ DM_ALERT_TEXT_INPUT = 1102,
+ DM_ALERT_SINGLE_CHOICE = 1103,
+ DM_ALERT_MULTIPLE_CHOICE = 1104,
+ DM_ALERT_SERVER_INITIATED_MGMT = 1200,
+ DM_ALERT_CLIENT_INITIATED_MGMT = 1201,
+ DM_ALERT_NEXT_MESSAGE = 1222,
+ DM_ALERT_SESSION_ABORT = 1223,
+ DM_ALERT_END_OF_DATA_NOT_RECEIVED = 1225,
+ DM_ALERT_FIRMWARE_UPDATE = 1226
+};
+typedef UINT16 SYNCML_DM_ALERT_CODE;
+
+
+/* These enum values are used to indicate the state of Security for the DM User Agent
+ * SYNCML_DM_SEC_STATE_FLAG_T */
+/* NOTE: DO NOT change numeric values, since bitwise operations used */
+enum {
+ DM_CLIENT_NO_SERVER_NO_AUTH = 0, /* Neither client nor server are authenticated.*/
+ DM_CLIENT_NO_SERVER_Y_AUTH = 1, /* Server Authenticated, Client not authenticated.*/
+ DM_CLIENT_Y_SERVER_NO_AUTH = 2, /* Client Authenticated, Server not authenticated.*/
+ DM_BOTH_CLIENT_SERVER_AUTH = 3 /* Both Client and Server Authenticated.*/
+};
+typedef UINT8 SYNCML_DM_SEC_STATE_FLAG_T;
+
+
+/* These enum values are used to indicate the URI checking result for SYNCML_DM_URI_RESULT_T */
+enum
+{
+ SYNCML_DM_COMMAND_ON_NODE, /* means URI doesnt have any special case */
+ SYNCML_DM_COMMAND_ON_ACL_PROPERTY, /* ?prop=ACL or ?prop=Name , Format etc */
+ SYNCML_DM_COMMAND_ON_FORMAT_PROPERTY,
+ SYNCML_DM_COMMAND_ON_NAME_PROPERTY,
+ SYNCML_DM_COMMAND_ON_SIZE_PROPERTY,
+ SYNCML_DM_COMMAND_ON_ESN_PROPERTY,
+ SYNCML_DM_COMMAND_ON_TYPE_PROPERTY,
+ SYNCML_DM_COMMAND_ON_TITLE_PROPERTY,
+ SYNCML_DM_COMMAND_ON_TSTAMP_PROPERTY,
+ SYNCML_DM_COMMAND_ON_VERNO_PROPERTY,
+ SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY,
+ SYNCML_DM_COMMAND_LIST_STRUCT, /* ?list=Struct found in URI */
+ SYNCML_DM_COMMAND_LIST_STRUCTDATA, /* ?list=StructData found in URI */
+ SYNCML_DM_COMMAND_LIST_TNDS, /* ?list=TNDS found in URI */
+ SYNCML_DM_COMMAND_URI_TOO_LONG, /* URI is too long */
+ SYNCML_DM_COMMAND_INVALID_URI /* URI was invalid */
+};
+typedef UINT8 SYNCML_DM_URI_RESULT_T;
+
+
+enum
+{
+ SYNCML_DM_ALERT_NONE,
+ SYNCML_DM_ALERT_CANCEL,
+ SYNCML_DM_ALERT_NO
+};
+typedef UINT8 SYNCML_DM_ALERT_RES_T;
+
+
+/*==================================================================================================
+ Structures
+==================================================================================================*/
+
+/* This buffer is used to hold syncml document data */
+typedef struct
+{
+ UINT32 dataSize;
+ UINT8 *pData;
+} SYNCML_DM_INDIRECT_BUFFER_T;
+
+
+typedef struct
+{
+ BOOLEAN _AuthFlag;
+ CPCHAR _pServerId;
+ UINT8 *_md5Digest;
+ UINT8 *_pTrigger;
+ UINT8 _triggerLen;
+} SYNCML_DM_AuthContext_T;
+
+/*================================================================================================*/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SYNCML_DM_DATA_TYPES_H */
diff --git a/engine/dmlib/dmengine/dm_util/src/dm_uri_utils.cc b/engine/dmlib/dmengine/dm_util/src/dm_uri_utils.cc
new file mode 100644
index 0000000..b0deda6
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_util/src/dm_uri_utils.cc
@@ -0,0 +1,242 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dm_uri_utils.cc
+
+ General Description: File contains implementation for helper functions for uri processing
+
+==================================================================================================*/
+
+#include "dm_uri_utils.h"
+#include "xpl_dm_Manager.h"
+#include "dmdefs.h"
+#include "dmtoken.h"
+#include "dm_tree_class.H"
+
+CEnv::CEnv()
+{
+ m_szWFS = m_szMainRFS = "";
+}
+
+CPCHAR CEnv::GetWFSFullPath(CPCHAR name, DMString & path)
+{
+ return GetFullPath(m_szWFS,name,path);
+}
+
+CPCHAR CEnv::GetMainRFSFullPath(CPCHAR name, DMString & path)
+{
+ return GetFullPath(m_szMainRFS,name,path);
+}
+
+CPCHAR CEnv::GetFullPath(CPCHAR fs_path, CPCHAR name, DMString & path)
+{
+ path = fs_path;
+ path += "/";
+ path += name;
+ return path.GetBuffer();
+}
+
+CPCHAR CEnv::GetRFSFullPath(int index, CPCHAR name, DMString & path)
+{
+ return GetFullPath(GetRFS(index),name,path);
+}
+
+
+BOOLEAN CEnv::Init()
+{
+ const char* szEnv = XPL_DM_GetEnv(SYNCML_DM_SETTINGS_PATH);
+
+ if ( !szEnv )
+ return FALSE;
+
+ DMString strItem, strReminder(szEnv);
+
+ while( DmStringParserGetItem( strItem, strReminder, ':' ) )
+ m_aFSes.push_back( strItem );
+
+ if ( m_aFSes.size() == 0 )
+ return FALSE;
+
+ m_szWFS = m_aFSes[0].c_str();
+
+ if ( m_aFSes.size() > 1 )
+ m_szMainRFS = m_aFSes[1].c_str();
+ else
+ m_szMainRFS = m_szWFS;
+
+ return TRUE;
+}
+
+void CEnv::Done()
+{
+ m_szWFS = m_szMainRFS = "";
+ m_aFSes.clear();
+}
+
+
+
+bool DmStringParserGetItem( DMString& strItem, DMString& strReminder, char cDelim )
+{
+ if ( strReminder[0] == 0 )
+ return false;
+
+ const char* s = DmStrchr( strReminder, cDelim );
+ int nPos = s ? s - strReminder : -1; //strReminder.find( cDelim );
+
+ if ( nPos < 0 ){
+ strItem = strReminder;
+ strReminder = "";
+ }
+ else {
+ strItem.assign( strReminder, nPos );
+ strReminder = DMString(s+1);
+ }
+ return true;
+}
+
+
+void DmParseURI(CPCHAR szPath, DMString& strURI, DMString& strKey )
+{
+ const char* szSlashPos = DmStrrchr( szPath, SYNCML_DM_FORWARD_SLASH );
+
+ if ( !szSlashPos )
+ return;
+
+ strURI.assign( szPath, szSlashPos-szPath);
+
+ szSlashPos++; // skip slash
+ const char* szQuestionPos = DmStrchr( szSlashPos, '?' );
+
+ if ( szQuestionPos ) {
+ strKey.assign( szSlashPos, szQuestionPos-szSlashPos );
+ }
+ else
+ strKey = szSlashPos;
+}
+
+int DmStrToStringVector(const char * pStr, int nLen, DMStringVector& oVector, char cDelim )
+{
+ // load/unload plugins
+ DMString strChild, strList; // = (const char*)pStr;
+ if (nLen >0)
+ {
+ strChild= DMString((const char*)pStr, nLen);
+ strList= DMString((const char*)pStr, nLen);
+ } else
+ {
+ strChild= (const char*)pStr;
+ strList = (const char*)pStr;
+ }
+
+ int i=0;
+ while ( DmStringParserGetItem( strChild, strList, cDelim ) )
+ {
+ oVector.push_back(strChild);
+ i++;
+ }
+ return i;
+}
+
+char* GetURISegment(char **ppbURI)
+{
+ return GetStringSegment(ppbURI, SYNCML_DM_FORWARD_SLASH);
+}
+
+char* GetStringSegment(char **ppbURI, char cDelim)
+{
+ char *pbURI = *ppbURI;
+ char *pURIStartLocation = pbURI;
+
+ if(pbURI != NULL)
+ {
+ pbURI = DmStrchr(pbURI, cDelim);
+ if(pbURI != NULL)
+ {
+ *pbURI++ = SYNCML_DM_NULL;
+ }
+ }
+ *ppbURI = pbURI;
+ return (pURIStartLocation);
+}
+
+BOOLEAN DmIsParentURI( CPCHAR szParentURI, CPCHAR szChildURI )
+{
+ DMParser sURIParserP(szParentURI);
+ DMParser sURIParserC(szChildURI);
+ CPCHAR sSegmentP = sURIParserP.nextSegment();
+ CPCHAR sSegmentC = sURIParserC.nextSegment();
+
+ UINT16 countP = sURIParserP.getSegmentsCount();
+ UINT16 countC = sURIParserC.getSegmentsCount();
+
+ if ( countP == 0 )
+ return TRUE;
+
+ if ( countP > countC )
+ return FALSE;
+
+ while ( sSegmentP && sSegmentC )
+ {
+ if ( *sSegmentP != '*' && *sSegmentC != '*' && DmStrcmp(sSegmentC, sSegmentP) != 0 )
+ {
+ return FALSE;
+ }
+
+ sSegmentP = sURIParserP.nextSegment();
+ sSegmentC = sURIParserC.nextSegment();
+ }
+ return TRUE;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DmIsDMAccNodePath(CPCHAR szPath)
+{
+ //CPCHAR dm_ver = XPL_DM_GetEnv(SYNCML_DM_VERSION);
+ SYNCML_DM_RET_STATUS_T result = SYNCML_DM_COMMAND_INVALID_URI;
+
+ const char *found = NULL;
+
+ if( dmTreeObj.IsVersion_12() )
+ {
+ found = DmStrstr(szPath, DM_DMACC_1_1_URI );
+ }
+ else
+ {
+ found = DmStrstr(szPath, DM_DMACC_1_2_URI );
+ }
+
+ result = found && ( found == szPath )
+ ? SYNCML_DM_FEATURE_NOT_SUPPORTED
+ : SYNCML_DM_SUCCESS;
+
+ return result;
+}
+
+BOOLEAN
+DmIsEnabledURI(CPCHAR szPath)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ dm_stat = DmIsDMAccNodePath(szPath);
+ if ( dm_stat == SYNCML_DM_FEATURE_NOT_SUPPORTED )
+ return FALSE;
+
+ return XPL_DM_IsFeatureEnabled(szPath);
+}
diff --git a/engine/dmlib/dmengine/dm_util/src/dmbuffer.cc b/engine/dmlib/dmengine/dm_util/src/dmbuffer.cc
new file mode 100644
index 0000000..b51fcbd
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_util/src/dmbuffer.cc
@@ -0,0 +1,208 @@
+#include "dmStringUtil.h"
+#include "dmbuffer.h"
+#include "dmdefs.h"
+#include "xpl_Logger.h"
+
+DMBuffer::DMBuffer()
+{
+ m_pBuf = NULL;
+ m_nCapacity = 0;
+ m_nSize = 0;
+}
+
+DMBuffer::~DMBuffer()
+{
+ FreeAndSetNull(m_pBuf);
+ m_nCapacity = 0;
+ m_nSize = 0;
+}
+
+
+DMBuffer& DMBuffer::operator=(const DMBuffer & buffer )
+{
+ assign(buffer.getBuffer(),buffer.getSize());
+ return *this;
+}
+
+UINT8 * DMBuffer::allocate(UINT32 nCapacity)
+{
+ if ( !nCapacity )
+ return m_pBuf;
+
+ m_nSize = 0;
+ if ( m_nCapacity < nCapacity + 1 )
+ {
+ FreeAndSetNull(m_pBuf);
+ m_pBuf = (UINT8*)DmAllocMem(nCapacity+1);
+ if ( m_pBuf )
+ {
+ m_nCapacity = nCapacity+1;
+ memset(m_pBuf,0,m_nCapacity);
+ }
+ else
+ {
+ m_nCapacity = 0;
+ XPL_LOG_DM_TMN_Error(("DMBuffer::Allocate : Unable to allocate memory\n"));
+ }
+ }
+ else
+ if ( m_pBuf )
+ memset(m_pBuf,0,m_nCapacity);
+ return m_pBuf;
+}
+
+void DMBuffer::reset()
+{
+ m_pBuf = NULL;
+ m_nCapacity = 0;
+ m_nSize = 0;
+}
+void DMBuffer::free()
+{
+ FreeAndSetNull(m_pBuf);
+ m_nCapacity = 0;
+ m_nSize = 0;
+}
+
+void DMBuffer::clear()
+{
+ if ( m_pBuf )
+ {
+ memset(m_pBuf,0,m_nCapacity);
+ m_nSize = 0;
+ }
+}
+
+UINT8 * DMBuffer::assign(CPCHAR szStr)
+{
+ return assign((UINT8*)szStr,DmStrlen(szStr));
+}
+void DMBuffer::append(const UINT8 * pBuffer, INT32 size)
+{
+ if ( m_pBuf && (m_nSize + size <= m_nCapacity))
+ {
+ memcpy((UINT8*)&m_pBuf[m_nSize],pBuffer,size);
+ m_nSize += size;
+ }
+}
+
+UINT8 * DMBuffer::assign(const UINT8 * pBuffer, INT32 size)
+{
+ allocate(size);
+ if ( m_pBuf )
+ {
+ memcpy(m_pBuf,pBuffer,size);
+ m_pBuf[size] = (UINT8)'\0';
+ m_nSize = size;
+ }
+ else
+ {
+ m_nSize = 0;
+ }
+ return m_pBuf;
+}
+
+void DMBuffer::setSize(UINT32 size)
+{
+ if ( size == 0 )
+ clear();
+ else
+ {
+ if ( size <= m_nCapacity-1 )
+ {
+ m_nSize = size;
+ }
+ else
+ {
+ m_nSize = m_nCapacity - 1;
+ }
+ m_pBuf[m_nSize] = (UINT8)'\0';
+ }
+}
+
+
+void DMBuffer::copyTo(UINT8 ** pBuffer) const
+{
+ if ( pBuffer == NULL )
+ return;
+
+ *pBuffer = NULL;
+
+ *pBuffer = (UINT8*)DmAllocMem(m_nSize+1);
+ if ( *pBuffer == NULL )
+ {
+ XPL_LOG_DM_TMN_Error(("DMBuffer::copyTo : Unable to allocate memory\n"));
+ return;
+ }
+ if ( m_nSize )
+ memcpy(*pBuffer,m_pBuf,m_nSize+1);
+ else
+ (*pBuffer)[0] = 0;
+}
+
+
+void DMBuffer::copyTo(DMString &sStr) const
+{
+
+ if ( m_nSize == 0 )
+ return;
+
+ sStr.assign((char*)m_pBuf,m_nSize);
+}
+void DMBuffer::copyTo(INT32 offset,INT32 size, DMBuffer& pBuffer) const
+{
+ if(offset > m_nSize)
+ return;
+
+ pBuffer.assign((char*)&m_pBuf[offset],size);
+}
+void DMBuffer::copyTo(char * pStr) const
+{
+ if ( pStr == NULL )
+ return;
+
+ if ( m_nSize == 0 )
+ return;
+
+ memcpy(pStr,m_pBuf,m_nSize+1);
+}
+
+BOOLEAN DMBuffer::compare(CPCHAR pStr) const
+{
+ if ( !m_nSize || m_nSize != DmStrlen(pStr) )
+ return FALSE;
+ return ( DmStrncmp(pStr,(CPCHAR)m_pBuf,m_nSize) == 0 ? TRUE : FALSE );
+
+}
+
+
+BOOLEAN DMBuffer::compare(CPCHAR pStr, UINT32 size) const
+{
+
+ if ( !m_nSize || m_nSize < size )
+ return FALSE;
+
+ return ( DmStrncmp(pStr,(CPCHAR)m_pBuf,size) == 0 ? TRUE : FALSE );
+
+}
+
+
+
+void DMBuffer::attach(UINT8 * pBuffer, INT32 nCapacity)
+{
+ FreeAndSetNull(m_pBuf);
+ m_pBuf = pBuffer;
+ m_nCapacity = nCapacity;
+ m_nSize = nCapacity-1;
+ m_pBuf[m_nSize] = (UINT8)'\0';
+}
+
+UINT8 * DMBuffer::detach()
+{
+ UINT8 *pBuffer = m_pBuf;
+ m_pBuf = NULL;
+ m_nCapacity = 0;
+ m_nSize = 0;
+ return pBuffer;
+}
+
diff --git a/engine/dmlib/dmengine/dm_util/src/dmtoken.cc b/engine/dmlib/dmengine/dm_util/src/dmtoken.cc
new file mode 100644
index 0000000..aee3f3a
--- /dev/null
+++ b/engine/dmlib/dmengine/dm_util/src/dmtoken.cc
@@ -0,0 +1,334 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+Source Name: dmToken.cc
+
+General Description: This file contains implementation of utility classes DMToken, DMURI, DMParser
+
+==================================================================================================*/
+
+#include "dmtoken.h"
+#include "dmdefs.h"
+#include "xpl_Logger.h"
+#include "syncml_dm_data_types.h"
+#include "dm_tree_class.H"
+
+DMToken::DMToken()
+{
+ m_pDelimPos = NULL;
+ m_pStr = NULL;
+ m_pTokenPos = NULL;
+ m_cDelim = SYNCML_DM_COMMA;
+ m_bIsAlloc = TRUE;
+}
+
+DMToken::DMToken(char delimeter)
+{
+ m_pDelimPos = NULL;
+ m_pStr = NULL;
+ m_pTokenPos = NULL;
+ m_cDelim = delimeter;
+ m_bIsAlloc = TRUE;
+}
+
+
+DMToken::DMToken(BOOLEAN bIsAlloc, CPCHAR str, char delimeter)
+{
+
+ m_pDelimPos = NULL;
+ m_pStr = NULL;
+ m_bIsAlloc = bIsAlloc;
+ m_cDelim = delimeter;
+ assign(str);
+}
+
+
+DMToken::~DMToken()
+{
+ if ( m_bIsAlloc == TRUE )
+ {
+ FreeAndSetNull(m_pStr);
+ }
+ else
+ reset();
+}
+
+
+CPCHAR DMToken::assign(CPCHAR szStr)
+{
+ if ( m_bIsAlloc == TRUE )
+ {
+ FreeAndSetNull(m_pStr);
+
+ if ( szStr && szStr[0] )
+ { // copy non empty string only
+ m_pStr = (char *)DmAllocMem( DmStrlen(szStr)+1);
+ if ( m_pStr != NULL) {
+ DmStrcpy( m_pStr, szStr );
+ }
+ else {
+ XPL_LOG_DM_TMN_Error(("DMToken::assign : unable allocate memory\n"));
+ }
+ }
+ }
+ else
+ {
+ reset();
+ m_pStr = (char*)szStr;
+ }
+
+ m_pDelimPos = m_pStr;
+ m_pTokenPos = m_pStr;
+ return m_pStr;
+}
+
+CPCHAR DMToken::nextSegment()
+{
+
+ if ( m_pDelimPos == NULL )
+ return NULL;
+
+ if ( m_pDelimPos != m_pStr )
+ {
+ *m_pDelimPos = m_cDelim;
+ m_pTokenPos = m_pDelimPos+1;
+ }
+ m_pDelimPos = DmStrchr(m_pTokenPos, m_cDelim);
+ if(m_pDelimPos != NULL)
+ {
+ *m_pDelimPos = SYNCML_DM_NULL;
+ }
+
+ if ( m_pTokenPos[0] == SYNCML_DM_NULL )
+ return NULL;
+
+ return (m_pTokenPos);
+
+}
+
+
+UINT32 DMToken::getSegmentsCount()
+{
+ UINT32 count = 0;
+ char * sTokenPos = m_pStr;
+
+ if ( !sTokenPos )
+ return 0;
+
+ reset();
+
+ m_pDelimPos = DmStrchr(m_pTokenPos,m_cDelim);
+ while ( m_pDelimPos )
+ {
+ count++;
+ m_pTokenPos = m_pDelimPos + 1;
+ m_pDelimPos = DmStrchr(m_pTokenPos,m_cDelim);
+ }
+
+ if ( *m_pTokenPos == SYNCML_DM_NULL )
+ return count;
+
+ m_pDelimPos = m_pStr;
+ m_pTokenPos = m_pStr;
+ return count+1;
+}
+
+void DMToken::reset()
+{
+ if ( m_pDelimPos && m_pDelimPos != m_pStr )
+ *m_pDelimPos = m_cDelim;
+ m_pDelimPos = m_pStr;
+ m_pTokenPos = m_pStr;
+}
+
+DMURI::DMURI() : DMToken(TRUE, NULL,SYNCML_DM_FORWARD_SLASH)
+{
+}
+
+DMURI::DMURI(BOOLEAN bIsAlloc) : DMToken(bIsAlloc, NULL,SYNCML_DM_FORWARD_SLASH)
+{
+}
+
+DMURI::DMURI(BOOLEAN bIsAlloc, CPCHAR szURI) : DMToken(bIsAlloc, szURI,SYNCML_DM_FORWARD_SLASH)
+{
+}
+
+
+CPCHAR DMURI::getTailSegments() const
+{
+ if ( m_pDelimPos == NULL )
+ return NULL;
+
+ if ( m_pDelimPos == m_pStr && *m_pStr != SYNCML_DM_FORWARD_SLASH )
+ return m_pStr;
+
+ return m_pDelimPos+1;
+}
+
+
+CPCHAR DMURI::getLastSegment()
+{
+
+ if ( m_pStr == NULL )
+ return NULL;
+
+ reset();
+ char * sPos = DmStrrchr(m_pStr,m_cDelim);
+ if ( sPos == NULL )
+ return NULL;
+ else
+ return sPos+1;
+}
+
+CPCHAR DMURI::getParentURI()
+{
+
+ if ( m_pStr == NULL )
+ return NULL;
+
+ char * pDelimPosPrev = m_pDelimPos;
+ m_pDelimPos = DmStrrchr(m_pStr, SYNCML_DM_FORWARD_SLASH);
+ if ( !m_pDelimPos || m_pDelimPos == m_pStr )
+ {
+ m_pDelimPos = pDelimPosPrev;
+ return NULL;
+ }
+
+ *m_pDelimPos = SYNCML_DM_NULL;
+ if ( pDelimPosPrev != m_pStr )
+ *pDelimPosPrev = SYNCML_DM_FORWARD_SLASH;
+
+
+ return m_pStr;
+}
+
+DMParser::DMParser(char delimeter)
+{
+ m_pDelimPos = NULL;
+ m_pStr = NULL;
+ m_cDelim = delimeter;
+
+ m_nCurrentSegment = 0;
+ m_nSegmentsCount = 0;
+
+ m_aSegments = (DM_URI_SEGMENT_T*)DmAllocMem( dmTreeObj.GetMaxPathDepth() * sizeof(DM_URI_SEGMENT_T));
+
+}
+
+DMParser::DMParser(CPCHAR szURI, char delimeter)
+{
+ m_pDelimPos = NULL;
+ m_pStr = NULL;
+ m_cDelim = delimeter;
+
+
+ m_nCurrentSegment = 0;
+ m_nSegmentsCount = 0;
+ m_aSegments = (DM_URI_SEGMENT_T*)DmAllocMem( dmTreeObj.GetMaxPathDepth() * sizeof(DM_URI_SEGMENT_T));
+ assign(szURI);
+}
+
+
+DMParser::~DMParser()
+{
+ reset();
+ FreeAndSetNull(m_aSegments);
+}
+
+CPCHAR DMParser::nextSegment()
+{
+
+ if ( m_nCurrentSegment == m_nSegmentsCount )
+ return NULL;
+
+ char * pStr = m_aSegments[m_nCurrentSegment].m_pStr;
+// XPL_LOG_DM_TMN_Debug(("DMParser::nextSegment, pStr:%s, m_nCurrentSegment:%d, m_nLen:%d\n", pStr, m_nCurrentSegment, m_aSegments[m_nCurrentSegment].m_nLen));
+ pStr[m_aSegments[m_nCurrentSegment].m_nLen] = SYNCML_DM_NULL;
+// XPL_LOG_DM_TMN_Debug(("DMParser::nextSegment, pStr:%s, m_nCurrentSegment:%d, m_nLen:%d\n", pStr, m_nCurrentSegment, m_aSegments[m_nCurrentSegment].m_nLen));
+
+ m_nCurrentSegment++;
+
+ return pStr;
+}
+
+
+CPCHAR DMParser::assign(CPCHAR szStr)
+{
+ DM_URI_SEGMENT_T segment;
+
+ if ( !m_aSegments )
+ return NULL;
+
+ m_pStr = (char*)szStr;
+
+ m_nCurrentSegment = 0;
+ m_nSegmentsCount = 0;
+
+ if ( !m_pStr )
+ return m_pStr;
+
+
+ m_pTokenPos = m_pStr;
+ m_pDelimPos = DmStrchr(m_pTokenPos,m_cDelim);
+
+ while ( m_pDelimPos )
+ {
+ segment.m_pStr = m_pTokenPos;
+ segment.m_nLen = m_pDelimPos - m_pTokenPos;
+ m_aSegments[m_nSegmentsCount++] = segment;
+ m_pTokenPos = m_pDelimPos + 1;
+ m_pDelimPos = DmStrchr(m_pTokenPos,m_cDelim);
+ }
+
+ if ( *m_pTokenPos == SYNCML_DM_NULL )
+ return m_pStr;
+
+
+ segment.m_pStr = m_pTokenPos;
+ segment.m_nLen = DmStrlen(m_pTokenPos);
+ m_aSegments[m_nSegmentsCount++] = segment;
+ return m_pStr;
+
+}
+
+void DMParser::reset()
+{
+ if ( !m_aSegments )
+ return;
+
+ if ( m_nCurrentSegment > 0 )
+ {
+ for (int i=0; i<m_nSegmentsCount-1; i++)
+ m_aSegments[i].m_pStr[m_aSegments[i].m_nLen] = m_cDelim;
+ }
+
+ m_nCurrentSegment = 0;
+}
+
+BOOLEAN DMParser::findSegment(CPCHAR szSegment)
+{
+
+ for (int i=0; i<m_nSegmentsCount; i++)
+ {
+ m_aSegments[i].m_pStr[m_aSegments[i].m_nLen] = SYNCML_DM_NULL;
+ if ( DmStrcmp(m_aSegments[i].m_pStr,szSegment) == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/define.h b/engine/dmlib/dmengine/oma_toolkit/hdr/define.h
new file mode 100644
index 0000000..5604c67
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/define.h
@@ -0,0 +1,164 @@
+/*************************************************************************/
+/* module: Compiler Flag Definition File */
+/* file: define.h */
+/* target system: win */
+/* target OS: win */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * File for Windows Specific Compiler Flags
+ */
+
+#ifndef _DEFINE_H
+ #define _DEFINE_H
+#define __ANSI_C__
+
+
+/* thread safety (added by luz@synthesis.ch, 2001-10-29) */
+/* Note: moved define of this to target_options.h of every target */
+//#undef __MAKE_THREADSAFE
+
+/* enable Alloc helpers */
+#define __USE_ALLOCFUNCS__
+
+/* do we need WBXML (binary XML) processing ? */
+#define __SML_WBXML__
+/* do we need XML processing ? */
+#define __SML_XML__
+/* are we using a 'light' toolkit ? */
+//#define __SML_LITE__
+/* do we use Sub DTD extensions ? */
+#define __USE_EXTENSIONS__
+/* do we need Metainformation DTD parsing ? */
+#define __USE_METINF__
+/* do we use Device Info DTD ? */
+#define __USE_DEVINF__
+/* do we use DM TND DTD ? */
+#define __USE_DMTND__
+
+/* which of the following optional commands should be included ? */
+
+#define ADD_SEND
+#define ATOMIC_SEND
+#define ATOMIC_RECEIVE
+#define COPY_SEND
+#define COPY_RECEIVE
+#define EXEC_SEND
+#define EXEC_RECEIVE
+#define GET_SEND
+#define MAP_RECEIVE
+#define MAPITEM_RECEIVE
+#define RESULT_RECEIVE
+#define SEARCH_SEND
+#define SEARCH_RECEIVE
+#define SEQUENCE_SEND
+#define SEQUENCE_RECEIVE
+
+
+/* TK: to improve interoperability and handling we
+ * switched to using .def files instead of compiler
+ * specific per function definitions. As long as we only
+ * use C this is the easiest and cleanes way
+ */
+
+#define SML_API
+#define SML_API_DEF
+#define XPT_API
+#define XPT_API_DEF
+
+/* TK: Old, now obsolete code follows here */
+#ifdef USE_OLD_DEFINES
+/*
+When building the DLL code with GNU, you should define BUILDING_DLL so that
+the variables/functions are exported correctly. When using the DLL,
+do NOT define BUILDING_DLL, and then the variables/functions will be
+imported correctly.
+
+You need to be using egcs-1.1.1 or newer.
+
+Building the DLL:
+ - define BUILDING_DLL, which defines SML_API __attribute__((dllexport))
+Building the client code:
+ - DO NOT define BUILDING_DLL, which defines SML_API to be one __attribute__((dllimport))
+*/
+
+
+#if __GNUC__ || __MSVC__ || __MSVCPP__ || _WIN32_WCE
+ /* define this, if you want to link the toolkit static */
+ #if __LINK_TOOLKIT_STATIC__ || __linux__
+ #define SML_API
+ #define SML_API_DEF
+ #define XPT_API
+ #define XPT_API_DEF
+ #else
+ #if BUILDING_DLL
+ #define SML_API __declspec (dllexport)
+ #define SML_API_DEF __declspec (dllexport)
+ #define XPT_API __declspec (dllexport)
+ #define XPT_API_DEF __declspec (dllexport)
+ #else /* Not BUILDING_DLL */
+ #define SML_API __declspec (dllimport)
+ #define SML_API_DEF __declspec (dllimport)
+ #define XPT_API __declspec (dllimport)
+ #define XPT_API_DEF __declspec (dllimport)
+ #endif /* Not BUILDING_DLL */
+ #endif
+#else
+ #if __IBMC__ || __IBMCPP__
+ #define SML_API_DEF __stdcall
+ #define SML_API __stdcall _Export
+ #define XPT_API_DEF __stdcall
+ #define XPT_API __stdcall _Export
+ #else
+ #if WIN32
+ #define SML_API __declspec (dllexport)
+ #define SML_API_DEF __declspec (dllexport)
+ #define XPT_API #error
+ #define XPT_API_DEF #error
+ #else
+ #define SML_API_DEF __stdcall
+ #define SML_API __stdcall
+ #define XPT_API_DEF __stdcall
+ #define XPT_API __stdcall
+ #endif
+#endif
+#endif
+#endif // USE_OLD_DEFINES
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/libmem.h b/engine/dmlib/dmengine/oma_toolkit/hdr/libmem.h
new file mode 100644
index 0000000..2fe8960
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/libmem.h
@@ -0,0 +1,99 @@
+/*************************************************************************/
+/* module: Library for Memory Functions */
+/* */
+/* file: libmem.h */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Header for the implementation of common memory handling functions */
+/*************************************************************************/
+
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+#ifndef _LIB_MEM_H
+#define _LIB_MEM_H
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+#include <stdlib.h>
+#include <smldef.h>
+#ifdef __ANSI_C__
+#include <string.h>
+#endif
+#ifdef __PALM_OS__
+#include <MemoryMgr.h>
+#endif
+
+#include "dmMemory.h"
+
+/*************************************************************************
+ * External Functions for all Toolkit versions
+ *************************************************************************/
+
+
+#ifdef __PALM_OS__ /* we use #define to reduce heap usage */
+ void *smlLibRealloc (VoidPtr_t objectP, MemSize_t constSize);
+ void smlLibFree (void* objectP);
+ #define smlLibMemset(pObject,value,count) ((void)MemSet((VoidPtr_t)pObject,(MemSize_t)count,(int)value))
+ #define smlLibMemcpy(pTarget,pSource,count) (MemMove(pTarget,(VoidPtr_t)pSource,count) ? pTarget : pTarget)
+ #define smlLibMemmove(pTarget,pSource,count) (MemMove(pTarget,(VoidPtr_t)pSource,(MemSize_t)count) ? pTarget : pTarget)
+ #define smlLibMemcmp(pTarget,pSource,count) (MemCmp((VoidPtr_t)pTarget,(VoidPtr_t)pSource,(MemSize_t)count))
+ #define smlLibMalloc(size) ((VoidPtr_t)MemPtrNew((MemSize_t)size))
+ #define smlLibMemsize(pObject) ((MemSize_t)MemPtrSize((VoidPtr_t)pObject))
+#else
+ SML_API_DEF void *smlLibRealloc(void *pObject, MemSize_t size);
+ SML_API_DEF void smlLibFree(void *pObject);
+ SML_API_DEF void *smlLibMemset(void *pObject, int value, MemSize_t count);
+ SML_API_DEF void *smlLibMemcpy(void *pTarget, const void *pSource, MemSize_t count);
+ SML_API_DEF void *smlLibMemmove(void *pTarget, const void *pSource, MemSize_t count);
+ SML_API_DEF int smlLibMemcmp(const void *pTarget, const void *pSource, MemSize_t count);
+ //SML_API_DEF void *smlLibMalloc(MemSize_t size);
+ #define smlLibMalloc DmAllocMem
+#endif
+
+
+#endif
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/libstr.h b/engine/dmlib/dmengine/oma_toolkit/hdr/libstr.h
new file mode 100644
index 0000000..1be201d
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/libstr.h
@@ -0,0 +1,111 @@
+/*************************************************************************/
+/* module: Library for String Functions */
+/* */
+/* file: libstr.h */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Header for the implementation of common string-handling functions */
+/*************************************************************************/
+
+
+
+ /*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef __LIB_STR_H
+#define __LIB_STR_H
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+#include "smldef.h"
+#include "libmem.h"
+#ifdef __ANSI_C__
+#include <string.h>
+#endif
+#ifdef __PALM_OS__
+#include <StringMgr.h>
+#endif
+
+
+/*************************************************************************
+ * External Functions for all Toolkit versions
+ *************************************************************************/
+
+
+#ifdef __PALM_OS__ /* we use #define to reduce heap usage */
+ String_t smlLibStrdup (const char* constStringP);
+ #define smlLibStrcpy(pTarget,pSource) (char*)StrCopy((char*)pTarget,(char*)pSource)
+ #define smlLibStrncpy(pTarget,pSource,count) (char*)StrNCopy((char*)pTarget,(char*)pSource,count)
+ #define smlLibStrcat(pTarget,pSource) (char*)StrCat((char*)pTarget,(char*)pSource)
+ #define smlLibStrcmp(pTarget,pSource) StrCompare((char*)pTarget,(char*)pSource)
+ #define smlLibStrncmp(pTarget,pSource,count) StrNCompare((char*)pTarget,(char*)pSource,count)
+ #define smlLibStrchr(pString,character) (char*)StrChr((String_t)pString,character)
+ #define smlLibStrlen(pString) StrLen((char*)pString)
+#else /* we use functions, to make the library exportable */
+ SML_API_DEF String_t smlLibStrdup (const char *constStringP);
+ SML_API_DEF String_t smlLibStrcpy(const char *pTarget, const char *pSource);
+ SML_API_DEF String_t smlLibStrncpy(const char *pTarget, const char *pSource, int count);
+ SML_API_DEF String_t smlLibStrcat(const char *pTarget, const char *pSource);
+ SML_API_DEF int smlLibStrcmp(const char *pTarget, const char *pSource);
+ SML_API_DEF int smlLibStrncmp(const char *pTarget, const char *pSource, int count);
+ SML_API_DEF String_t smlLibStrchr(const char *pString, char character);
+ SML_API_DEF int smlLibStrlen(const char *pString);
+#endif
+
+
+
+
+/*************************************************************************
+ * Additional External Functions for Full Sized Toolkit Only
+ *************************************************************************/
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+#ifdef __PALM_OS__ /* we use define to reduce heap usage */
+ #define smlLibStrncat(pTarget,pSource,count) (char*)StrNCat((char*)pTarget,(char*)pSource,count)
+ #define smlLibStrstr(pString,pSubstring) (char*)StrStr((char*)pString,(char*)pSubstring)
+#else /* we use functions, to make the library exportable */
+ SML_API_DEF String_t smlLibStrncat(const char *pTarget, const char *pSource, int count);
+ SML_API_DEF String_t smlLibStrstr(const char *pString, const char *pSubString);
+#endif
+#endif
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/libutil.h b/engine/dmlib/dmengine/oma_toolkit/hdr/libutil.h
new file mode 100644
index 0000000..bef0579
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/libutil.h
@@ -0,0 +1,88 @@
+/*************************************************************************/
+/* module: Library for utility Functions */
+/* */
+/* file: libutil.c */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Some I/O Utilities */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _LIB_UTIL_H
+#define _LIB_UTIL_H
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <smldef.h>
+
+
+#ifdef __ANSI_C__
+ #include <stdarg.h>
+#endif
+
+#ifdef __PALM_OS__
+ #ifndef _MSL_CSTDARG
+ #include <unix_stdarg.h> // only if we don't use MSL
+ #endif
+#endif
+
+#ifdef __EPOC_OS__
+ #include <stdarg.h>
+#endif
+
+
+/*************************************************************************
+ * External Functions
+ *************************************************************************/
+
+/* IO functions */
+SML_API_DEF void smlLibPrint(const char *text, ...);
+SML_API_DEF void smlLibVprintf(const char *format, va_list va);
+
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/md5.h b/engine/dmlib/dmengine/oma_toolkit/hdr/md5.h
new file mode 100644
index 0000000..83c81f3
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/md5.h
@@ -0,0 +1,61 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+ */
+
+/*==================================================================================================
+Motorola Revision History:
+Modification
+Author Date CR Number and Major Changes
+---------------- ------------ ---------------------------------------------------------------
+Emily Bernotas 05/08/03 LIBbb96206 Add MD5 algorithm to OMA toolkit. Prefix function
+ names with "sml" and change UINT4 typedef
+
+==================================================================================================*/
+
+/* POINTER defines a generic pointer type */
+typedef unsigned char *POINTER;
+
+/* UINT2 defines a two byte word */
+typedef unsigned short int UINT2;
+
+/* UINT4 defines a four byte word */
+typedef unsigned int UINT4;
+
+
+/* MD5 context. */
+typedef struct {
+ UINT4 state[4]; /* state (ABCD) */
+ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ unsigned char buffer[64]; /* input buffer */
+} MD5_CTX;
+
+void smlMD5Init (MD5_CTX *);
+void smlMD5Update (MD5_CTX *, unsigned char *, unsigned int);
+void smlMD5Final (unsigned char [16], MD5_CTX *);
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/mgr.h b/engine/dmlib/dmengine/oma_toolkit/hdr/mgr.h
new file mode 100644
index 0000000..cd2186f
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/mgr.h
@@ -0,0 +1,187 @@
+/*************************************************************************/
+/* module: SyncML internal API of the MGR module */
+/* */
+/* file: mgr.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definitions for internal use within the SyncML implementation */
+/*************************************************************************/
+
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _MGR_H
+ #define _MGR_H
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <smldef.h>
+#include <sml.h>
+#include "wsm.h"
+#include <xlttagtbl.h>
+
+
+/**
+ * ========================================
+ * Definitions used for Instance Management
+ * ========================================
+ **/
+
+
+
+/**
+ * Current instance status
+ **/
+typedef enum {
+ MGR_IDLE, // instance is idle (available for usage by applications)
+ MGR_USED, // instance is in use, but currently inactive
+ MGR_RECEIVE, // actively used for receiving (locked by application)
+ MGR_SEND, // actively used for sending (locked by application)
+ MGR_ENCODING, // actively used for encoding (locked by SyncML)
+ MGR_DECODING // actively used for decoding (locked by SyncML)
+} InstanceStatus_t;
+
+
+
+/**
+ * structure describing the current status of an instance,
+ **/
+typedef struct instance_info_s {
+ #ifndef NOWSM
+ InstanceID_t id; // unique ID of the instance
+ MemPtr_t workspaceHandle; // handle to the first position of the assigned workspace memory
+ #else
+ // buffer pointers for NOWSM simplified case
+ MemPtr_t instanceBuffer; // pointer to instance work buffer
+ MemSize_t instanceBufSiz; // size of currently allocated buffer
+ Byte_t readLocked; // set when buffer is locked for read
+ Byte_t writeLocked; // set when buffer is locked for read
+ MemPtr_t readPointer; // read pointer
+ MemPtr_t writePointer; // write pointer
+ MemPtr_t outgoingMsgStart; // set whenever a smlStartMessage is issued, NULL when invalid
+ MemSize_t maxOutgoingSize; // if<>0, smlXXXCmd will not modify the buffer when there's not enough room
+ #endif
+ InstanceStatus_t status; // current internal state of instance
+ SmlCallbacksPtr_t callbacks; // Defined callback refererences for this Instance
+ SmlInstanceOptionsPtr_t instanceOptions; // Defined options for this Instance (e.g. encoding type)
+ VoidPtr_t userData; // Pointer to a structure, which is passed to the invoked callback functions
+ #ifndef NOWSM
+ VoidPtr_t workspaceState; // Pointer to a structure defining the current workspace status
+ #endif
+ VoidPtr_t encoderState; // Pointer to a structure defining the current encoder status
+ VoidPtr_t decoderState; // Pointer to a structure defining the current decoder status
+ #ifndef NOWSM
+ struct instance_info_s* nextInfo; // Pointer to next Instance Info in a list
+ #else
+ smlPrintFunc defaultPrintFunc; // default application callback for displaying strings (is a global in original version)
+ #endif
+} *InstanceInfoPtr_t, InstanceInfo_t;
+
+
+/* Pointers to store the global Tag tables */
+typedef struct tokeninfo_s {
+ TagPtr_t SyncML;
+ TagPtr_t MetInf;
+ TagPtr_t DevInf;
+ TagPtr_t DmTnd;
+} *TokenInfoPtr_t, TokenInfo_t;
+
+
+#ifndef NOWSM
+// Note, version without WSM has NO globals at all
+/**
+ * structure describing the current status of the global syncml module
+ * (holds all global variables within SyncML)
+ **/
+typedef struct syncml_info_s {
+ InstanceInfoPtr_t instanceListAnchor;// Anchor of the global list of known SyncML instances
+ SmlOptionsPtr_t syncmlOptions; // Options valid for this SyncML Process
+ WsmGlobalsPtr_t wsmGlobals; // Workspace global variables
+ TokenInfoPtr_t tokTbl;
+} *SyncMLInfoPtr_t, SyncMLInfo_t;
+#endif
+
+
+
+#ifndef NOWSM
+
+/*************************************************************************
+ * External Function Declarations
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: mgrGetSyncMLInfo
+ * Retrieves a pointer to the structure holding all global informations within SyncML
+ *
+ * RETURN: SyncMLInfoPtr_t
+ * Pointer to the pGlobalAnchor
+ */
+SyncMLInfoPtr_t mgrGetSyncMLAnchor(void);
+
+
+/**
+ * FUNCTION: mgrGetInstanceListAnchor
+ * Retrieves a pointer to the list holding all instance informations
+ *
+ * RETURN: InstanceInfoPtr_t
+ * Pointer to the pInstanceListAnchor
+ */
+InstanceInfoPtr_t mgrGetInstanceListAnchor(void);
+
+
+/**
+ * FUNCTION: mgrSetInstanceListAnchor
+ * Set the pointer to the list holding all instance informations
+ *
+ * IN: InstanceInfoPtr_t
+ * Pointer to the pInstanceListAnchor
+ */
+void mgrSetInstanceListAnchor(InstanceInfoPtr_t newListAnchor);
+
+#endif // !defined(NOWSM)
+
+
+#endif // ifndef _MGR_H
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/mgrutil.h b/engine/dmlib/dmengine/oma_toolkit/hdr/mgrutil.h
new file mode 100644
index 0000000..2502be1
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/mgrutil.h
@@ -0,0 +1,186 @@
+/*************************************************************************/
+/* module: SyncML API for freeing SyncML C structures */
+/* */
+/* file: mgrutil.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definitions for internal use within the SyncML implementation */
+/*************************************************************************/
+
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+#ifndef _MGR_UTIL_H
+ #define _MGR_UTIL_H
+
+
+/* Prototypes of exported SyncML API functions */
+SML_API Ret_t smlFreeProtoElement(VoidPtr_t pProtoElement);
+SML_API void smlFreePcdata(SmlPcdataPtr_t pPcdata);
+SML_API void smlFreePcdataList(SmlPcdataListPtr_t list);
+
+SML_API void smlFreeSyncHdr(SmlSyncHdrPtr_t pSyncHdr);
+SML_API void smlFreeSync(SmlSyncPtr_t pSync);
+SML_API void smlFreeGeneric(SmlGenericCmdPtr_t pGenericCmd);
+SML_API void smlFreeAlert(SmlAlertPtr_t pAlert);
+SML_API void smlFreeAtomic(SmlAtomicPtr_t pAtomic);
+#if (defined EXEC_SEND || defined EXEC_RECEIVE)
+ SML_API void smlFreeExec(SmlExecPtr_t pExec);
+#endif
+SML_API void smlFreeGetPut(SmlPutPtr_t pGetPut);
+SML_API void smlFreeMap(SmlMapPtr_t pMap);
+SML_API void smlFreeResults(SmlResultsPtr_t pResults);
+#if (defined SEARCH_SEND || defined SEARCH_RECEIVE)
+ SML_API void smlFreeSearch(SmlSearchPtr_t pSearch);
+#endif
+SML_API void smlFreeStatus(SmlStatusPtr_t pStatus);
+SML_API void smlFreeCredPtr(SmlCredPtr_t pCred);
+SML_API void smlFreeChalPtr(SmlChalPtr_t pChal);
+SML_API void smlFreeSourceTargetPtr(SmlSourcePtr_t pSourceTarget);
+SML_API void smlFreeSourceList(SmlSourceListPtr_t pSourceList);
+SML_API void smlFreeSourceRefList(SmlSourceRefListPtr_t pSourceRefList);
+SML_API void smlFreeTargetRefList(SmlTargetRefListPtr_t pTargetRefList);
+SML_API void smlFreeItemPtr(SmlItemPtr_t pItem);
+SML_API void smlFreeItemList(SmlItemListPtr_t pItemList);
+SML_API void smlFreeMapItemPtr(SmlMapItemPtr_t pMapItem);
+SML_API void smlFreeMapItemList(SmlMapItemListPtr_t pMapItemList);
+
+#ifdef __USE_METINF__
+SML_API void smlFreeMetinfAnchor(SmlMetInfAnchorPtr_t data);
+SML_API void smlFreeMetinfMem(SmlMetInfMemPtr_t data);
+SML_API void smlFreeMetinfMetinf(SmlMetInfMetInfPtr_t data);
+#endif
+#ifdef __USE_DEVINF__
+SML_API void smlFreeDevInfDatastore(SmlDevInfDatastorePtr_t data);
+SML_API void smlFreeDevInfDatastoreList(SmlDevInfDatastoreListPtr_t data);
+SML_API void smlFreeDevInfXmitList(SmlDevInfXmitListPtr_t data);
+SML_API void smlFreeDevInfXmit(SmlDevInfXmitPtr_t data);
+SML_API void smlFreeDevInfDSMem(SmlDevInfDSMemPtr_t data);
+SML_API void smlFreeDevInfSynccap(SmlDevInfSyncCapPtr_t data);
+SML_API void smlFreeDevInfExt(SmlDevInfExtPtr_t data);
+SML_API void smlFreeDevInfExtList(SmlDevInfExtListPtr_t data);
+SML_API void smlFreeDevInfCTData(SmlDevInfCTDataPtr_t data);
+SML_API void smlFreeDevInfCTDataList(SmlDevInfCTDataListPtr_t data);
+SML_API void smlFreeDevInfCTDataProp(SmlDevInfCTDataPropPtr_t data);
+SML_API void smlFreeDevInfCTDataPropList(SmlDevInfCTDataPropListPtr_t data);
+SML_API void smlFreeDevInfCTCap(SmlDevInfCTCapPtr_t data);
+SML_API void smlFreeDevInfCtcapList(SmlDevInfCtcapListPtr_t data);
+SML_API void smlFreeDevInfDevInf(SmlDevInfDevInfPtr_t data);
+#endif
+
+#ifdef __USE_DMTND__
+SML_API void smlFreeDmTnd(SmlDmTndPtr_t data);
+#endif
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+SML_API String_t smlPcdata2String( SmlPcdataPtr_t pcdata );
+SML_API SmlPcdataPtr_t smlString2Pcdata( String_t str );
+SML_API SmlPcdataPtr_t smlPcdataDup(SmlPcdataPtr_t pcdata);
+SML_API MemSize_t smlGetFreeBuffer(InstanceID_t id);
+#endif
+
+#ifdef __USE_ALLOCFUNCS__
+SML_API SmlPcdataPtr_t smlAllocPcdata();
+SML_API SmlPcdataListPtr_t smlAllocPcdataList();
+SML_API SmlChalPtr_t smlAllocChal();
+SML_API SmlCredPtr_t smlAllocCred();
+SML_API SmlSourcePtr_t smlAllocSource();
+SML_API SmlTargetPtr_t smlAllocTarget();
+SML_API SmlSourceListPtr_t smlAllocSourceList();
+SML_API SmlSyncHdrPtr_t smlAllocSyncHdr();
+SML_API SmlItemPtr_t smlAllocItem();
+SML_API SmlItemListPtr_t smlAllocItemList();
+SML_API SmlGenericCmdPtr_t smlAllocGeneric();
+SML_API SmlAddPtr_t smlAllocAdd();
+SML_API SmlCopyPtr_t smlAllocCopy();
+SML_API SmlReplacePtr_t smlAllocReplace();
+SML_API SmlDeletePtr_t smlAllocDelete();
+SML_API SmlAlertPtr_t smlAllocAlert();
+SML_API SmlAtomicPtr_t smlAllocAtomic();
+SML_API SmlSequencePtr_t smlAllocSequence();
+SML_API SmlSyncPtr_t smlAllocSync();
+SML_API SmlExecPtr_t smlAllocExec();
+SML_API SmlGetPtr_t smlAllocGet();
+SML_API SmlPutPtr_t smlAllocPut();
+SML_API SmlMapItemPtr_t smlAllocMapItem();
+SML_API SmlMapItemListPtr_t smlAllocMapItemList();
+SML_API SmlMapPtr_t smlAllocMap();
+SML_API SmlResultsPtr_t smlAllocResults();
+SML_API SmlSearchPtr_t smlAllocSearch();
+SML_API SmlTargetRefListPtr_t smlAllocTargetRefList();
+SML_API SmlSourceRefListPtr_t smlAllocSourceRefList();
+SML_API SmlStatusPtr_t smlAllocStatus();
+SML_API SmlUnknownProtoElementPtr_t smlAllocUnknownProtoElement();
+#ifdef __USE_METINF__
+SML_API SmlMetInfMetInfPtr_t smlAllocMetInfMetInf();
+SML_API SmlMetInfAnchorPtr_t smlAllocMetInfAnchor();
+SML_API SmlMetInfMemPtr_t smlAllocMetInfMem();
+#endif // MetInf
+
+#ifdef __USE_DEVINF__
+SML_API SmlDevInfExtPtr_t smlAllocDevInfExt();
+SML_API SmlDevInfExtListPtr_t smlAllocDevInfExtList();
+SML_API SmlDevInfSyncCapPtr_t smlAllocDevInfSyncCap();
+SML_API SmlDevInfCTDataPtr_t smlAllocDevInfCTData();
+SML_API SmlDevInfCTDataListPtr_t smlAllocDevInfCTDataList();
+SML_API SmlDevInfCTDataPropPtr_t smlAllocDevInfCTDataProp();
+SML_API SmlDevInfCTDataPropListPtr_t smlAllocDevInfCTDataPropList();
+SML_API SmlDevInfCTCapPtr_t smlAllocDevInfCTCap();
+SML_API SmlDevInfCtcapListPtr_t smlAllocDevInfCtcapList();
+SML_API SmlDevInfDSMemPtr_t smlAllocDevInfDSMem();
+SML_API SmlDevInfXmitPtr_t smlAllocDevInfXmit();
+SML_API SmlDevInfXmitListPtr_t smlAllocDevInfXmitList();
+SML_API SmlDevInfDatastorePtr_t smlAllocDevInfDatastore();
+SML_API SmlDevInfDatastoreListPtr_t smlAllocDevInfDatastoreList();
+SML_API SmlDevInfDevInfPtr_t smlAllocDevInfDevInf();
+#endif // DevInf
+
+#ifdef __USE_DMTND__
+SML_API SmlDmTndPtr_t smlAllocDmTnd();
+SML_API SmlDmTndNodeListPtr_t smlAllocDmTndNodeList();
+SML_API SmlDmTndNodePtr_t smlAllocDmTndNode();
+SML_API SmlDmTndRTPropsPtr_t smlAllocDmTndRTProps();
+SML_API SmlDmTndFormatPtr_t smlAllocDmTndFormat();
+SML_API SmlDmTndTypePtr_t smlAllocDmTndType();
+#endif // DmTnd
+#endif // AllocFuncs
+#endif // MgrUtil.h
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/sml.h b/engine/dmlib/dmengine/oma_toolkit/hdr/sml.h
new file mode 100644
index 0000000..7e02d82
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/sml.h
@@ -0,0 +1,335 @@
+/*************************************************************************/
+/* module: External SyncML API */
+/* */
+/* file: sml.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Platform independent definition of the SyncML API functions */
+/* This is the external API exposed to applications using SyncML */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _SML_H
+ #define _SML_H
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+#include <smldef.h>
+#include <smldtd.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+/*************************************************************************
+ * External Functions
+ *************************************************************************/
+
+#if !defined(NOWSM) || !__LINK_TOOLKIT_STATIC__
+
+/**
+ * ============================
+ * General SyncML Functions
+ * ============================
+ **/
+SML_API_DEF Ret_t smlInit(SmlOptionsPtr_t pOptions);
+SML_API_DEF Ret_t smlSetSyncMLOptions (SmlOptionsPtr_t pOptions);
+SML_API_DEF Ret_t smlTerminate(void);
+
+#endif
+
+
+/**
+ * ============================
+ * Workspace Handling Functions
+ * ============================
+ **/
+
+SML_API_DEF Ret_t smlLockReadBuffer(InstanceID_t id, MemPtr_t *pReadPosition, MemSize_t *usedSize);
+SML_API_DEF Ret_t smlUnlockReadBuffer(InstanceID_t id, MemSize_t processedBytes);
+#ifdef NOWSM
+SML_API Ret_t smlSetMaxOutgoingSize(InstanceID_t id, MemSize_t maxOutgoingSize);
+SML_API Ret_t smlSetOutgoingBegin(InstanceID_t id);
+#endif
+SML_API_DEF Ret_t smlLockWriteBuffer(InstanceID_t id, MemPtr_t *pWritePosition, MemSize_t *freeSize);
+SML_API_DEF Ret_t smlUnlockWriteBuffer(InstanceID_t id, MemSize_t writtenBytes);
+
+
+
+/**
+ * ===========================================
+ * Protocol Element Building Functions (for Originator)
+ * ===========================================
+ **/
+
+/* Protocol Management */
+SML_API_DEF Ret_t smlStartMessage(InstanceID_t id, SmlSyncHdrPtr_t pContent);
+SML_API_DEF Ret_t smlStartMessageExt(InstanceID_t id, SmlSyncHdrPtr_t pContent, SmlVersion_t vers); /* %%% added by luz 2003-08-06) */
+SML_API_DEF Ret_t smlEndMessage(InstanceID_t id, Boolean_t final);
+SML_API_DEF Ret_t smlStartSync(InstanceID_t id, SmlSyncPtr_t pContent);
+SML_API_DEF Ret_t smlEndSync(InstanceID_t id);
+
+#ifdef ATOMIC_SEND /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF Ret_t smlStartAtomic(InstanceID_t id, SmlAtomicPtr_t pContent);
+ SML_API_DEF Ret_t smlEndAtomic(InstanceID_t id);
+#endif
+#ifdef SEQUENCE_SEND
+ SML_API_DEF Ret_t smlStartSequence(InstanceID_t id, SmlSequencePtr_t pContent);
+ SML_API_DEF Ret_t smlEndSequence(InstanceID_t id);
+#endif
+
+/* Sync Commands */
+#ifdef ADD_SEND
+ SML_API_DEF Ret_t smlAddCmd(InstanceID_t id, SmlAddPtr_t pContent);
+#endif
+SML_API_DEF Ret_t smlAlertCmd(InstanceID_t id, SmlAlertPtr_t pContent);
+SML_API_DEF Ret_t smlDeleteCmd(InstanceID_t id, SmlDeletePtr_t pContent);
+#ifdef GET_SEND
+ SML_API_DEF Ret_t smlGetCmd(InstanceID_t id, SmlGetPtr_t pContent);
+#endif
+SML_API_DEF Ret_t smlPutCmd(InstanceID_t id, SmlPutPtr_t pContent);
+SML_API_DEF Ret_t smlMapCmd(InstanceID_t id, SmlMapPtr_t pContent);
+SML_API_DEF Ret_t smlResultsCmd(InstanceID_t id, SmlResultsPtr_t pContent);
+SML_API_DEF Ret_t smlStatusCmd(InstanceID_t id, SmlStatusPtr_t pContent);
+SML_API_DEF Ret_t smlReplaceCmd(InstanceID_t id, SmlReplacePtr_t pContent);
+
+#ifdef COPY_SEND /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF Ret_t smlCopyCmd(InstanceID_t id, SmlCopyPtr_t pContent);
+#endif
+#ifdef EXEC_SEND
+ SML_API_DEF Ret_t smlExecCmd(InstanceID_t id, SmlExecPtr_t pContent);
+#endif
+#ifdef SEARCH_SEND
+ SML_API_DEF Ret_t smlSearchCmd(InstanceID_t id, SmlSearchPtr_t pContent);
+#endif
+SML_API_DEF Ret_t smlStartEvaluation(InstanceID_t id);
+SML_API_DEF Ret_t smlEndEvaluation(InstanceID_t id, MemSize_t *freemem);
+
+
+/**
+ * ============================================
+ * Command Dispatching Functions (for Receiver)
+ * ============================================
+ **/
+
+SML_API_DEF Ret_t smlProcessData(InstanceID_t id, SmlProcessMode_t mode);
+
+
+
+/**
+ * ====================================================
+ * Callback Functions to be implemented by the Receiver
+ * ====================================================
+ **/
+
+/* Protocol Management */
+typedef Ret_t (*smlStartMessageFunc) (InstanceID_t id, VoidPtr_t userData, SmlSyncHdrPtr_t pContent);
+typedef Ret_t (*smlEndMessageFunc) (InstanceID_t id, VoidPtr_t userData, Boolean_t final);
+typedef Ret_t (*smlStartSyncFunc) (InstanceID_t id, VoidPtr_t userData, SmlSyncPtr_t pContent);
+typedef Ret_t (*smlEndSyncFunc) (InstanceID_t id, VoidPtr_t userData);
+
+#ifdef ATOMIC_RECEIVE /* these callbacks are NOT included in the Toolkit lite version */
+ typedef Ret_t (*smlStartAtomicFunc) (InstanceID_t id, VoidPtr_t userData, SmlAtomicPtr_t pContent);
+ typedef Ret_t (*smlEndAtomicFunc) (InstanceID_t id, VoidPtr_t userData);
+#endif
+#ifdef SEQUENCE_RECEIVE
+ typedef Ret_t (*smlStartSequenceFunc) (InstanceID_t id, VoidPtr_t userData, SmlSequencePtr_t pContent);
+ typedef Ret_t (*smlEndSequenceFunc) (InstanceID_t id, VoidPtr_t userData);
+#endif
+
+/* Sync Commands */
+typedef Ret_t (*smlAddCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlAddPtr_t pContent);
+typedef Ret_t (*smlAlertCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlAlertPtr_t pContent);
+typedef Ret_t (*smlDeleteCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlDeletePtr_t pContent);
+typedef Ret_t (*smlGetCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlGetPtr_t pContent);
+typedef Ret_t (*smlPutCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlPutPtr_t pContent);
+#ifdef MAP_RECEIVE
+ typedef Ret_t (*smlMapCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlMapPtr_t pContent);
+#endif
+#ifdef RESULT_RECEIVE
+ typedef Ret_t (*smlResultsCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlResultsPtr_t pContent);
+#endif
+typedef Ret_t (*smlStatusCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlStatusPtr_t pContent);
+typedef Ret_t (*smlReplaceCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlReplacePtr_t pContent);
+
+#ifdef COPY_RECEIVE /* these callbacks are NOT included in the Toolkit lite version */
+ typedef Ret_t (*smlCopyCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlCopyPtr_t param);
+#endif
+#ifdef EXEC_RECEIVE
+ typedef Ret_t (*smlExecCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlExecPtr_t pContent);
+#endif
+#ifdef SEARCH_RECEIVE
+ typedef Ret_t (*smlSearchCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlSearchPtr_t pContent);
+#endif
+
+
+/* Other Callbacks */
+typedef Ret_t (*smlHandleErrorFunc) (InstanceID_t id, VoidPtr_t userData);
+typedef Ret_t (*smlTransmitChunkFunc) (InstanceID_t id, VoidPtr_t userData);
+
+
+
+
+/**
+ * Structure defining references to the applications callback implementations
+ **/
+typedef struct sml_callbacks_s {
+ /* Protocol Management Callbacks */
+ smlStartMessageFunc startMessageFunc;
+ smlEndMessageFunc endMessageFunc;
+ smlStartSyncFunc startSyncFunc;
+ smlEndSyncFunc endSyncFunc;
+#ifdef ATOMIC_RECEIVE /* these callbacks are NOT included in the Toolkit lite version */
+ smlStartAtomicFunc startAtomicFunc;
+ smlEndAtomicFunc endAtomicFunc;
+#endif
+#ifdef SEQUENCE_RECEIVE
+ smlStartSequenceFunc startSequenceFunc;
+ smlEndSequenceFunc endSequenceFunc;
+#endif
+ /* Sync Command callbacks */
+ smlAddCmdFunc addCmdFunc;
+ smlAlertCmdFunc alertCmdFunc;
+ smlDeleteCmdFunc deleteCmdFunc;
+ smlGetCmdFunc getCmdFunc;
+ smlPutCmdFunc putCmdFunc;
+#ifdef MAP_RECEIVE
+ smlMapCmdFunc mapCmdFunc;
+#endif
+#ifdef RESULT_RECEIVE
+ smlResultsCmdFunc resultsCmdFunc;
+#endif
+ smlStatusCmdFunc statusCmdFunc;
+ smlReplaceCmdFunc replaceCmdFunc;
+#ifdef COPY_RECEIVE /* these callbacks are NOT included in the Toolkit lite version */
+ smlCopyCmdFunc copyCmdFunc;
+#endif
+#ifdef EXEC_RECEIVE
+ smlExecCmdFunc execCmdFunc;
+#endif
+#ifdef SEARCH_RECEIVE
+ smlSearchCmdFunc searchCmdFunc;
+#endif
+ /* Other Callbacks */
+ smlHandleErrorFunc handleErrorFunc;
+ smlTransmitChunkFunc transmitChunkFunc;
+ //smlPrintFunc printFunc;
+} *SmlCallbacksPtr_t, SmlCallbacks_t;
+
+
+
+/**
+ * ============================
+ * Instance Management Functions
+ * ============================
+ **/
+
+SML_API_DEF Ret_t smlInitInstance(SmlCallbacksPtr_t pCallbacks, SmlInstanceOptionsPtr_t pOptions, VoidPtr_t pUserData, InstanceID_t *pId);
+SML_API_DEF Ret_t smlTerminateInstance (InstanceID_t id);
+SML_API_DEF Ret_t smlSetCallbacks (InstanceID_t id, SmlCallbacksPtr_t pCallbacks);
+SML_API_DEF Ret_t smlSetUserData (InstanceID_t id, VoidPtr_t pUserData);
+// added by luz %%%:
+SML_API Ret_t smlGetUserData(InstanceID_t id, VoidPtr_t *ppUserData);
+SML_API Ret_t smlGetEncoding(InstanceID_t id, SmlEncoding_t *pEncoding);
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF Ret_t smlSetEncoding (InstanceID_t id, SmlEncoding_t encoding);
+#endif
+
+
+
+/**
+ * ===================================
+ * Some Helper Functions and Utilities
+ * ===================================
+ **/
+
+SML_API_DEF Ret_t smlFreeProtoElement(VoidPtr_t pProtoElement);
+SML_API_DEF void smlFreePcdata(SmlPcdataPtr_t pPcdata);
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF String_t smlPcdata2String( SmlPcdataPtr_t pcdata );
+ SML_API_DEF SmlPcdataPtr_t smlString2Pcdata( String_t str );
+ SML_API_DEF SmlPcdataPtr_t smlPcdataDup(SmlPcdataPtr_t pcdata);
+ SML_API_DEF MemSize_t smlGetFreeBuffer(InstanceID_t id);
+#endif
+
+#ifndef __PALM_OS__ /* these API calls are NOT exported in the Palm OS version */
+SML_API_DEF void *smlLibMemset(void *pObject, int value, MemSize_t count);
+SML_API_DEF void *smlLibMemcpy(void *pTarget, const void *pSource, MemSize_t count);
+SML_API_DEF int smlLibMemcmp(const void *pTarget, const void *pSource, MemSize_t count);
+/*SML_API_DEF void *smlLibMalloc(MemSize_t size);*/
+ #define smlLibMalloc DmAllocMem
+#include "dmMemory.h"
+
+SML_API_DEF void smlLibFree(void *pObject);
+SML_API_DEF MemSize_t smlLibMemsize(const void *pObject);
+
+SML_API_DEF String_t smlLibStrdup (const char *constStringP);
+SML_API_DEF String_t smlLibStrcpy(const char *pTarget, const char *pSource);
+SML_API_DEF int smlLibStrcmp(const char *pTarget, const char *pSource);
+SML_API_DEF int smlLibStrlen(const char *pString);
+SML_API_DEF String_t smlLibStrncpy(const char *pTarget, const char *pSource, int count);
+SML_API_DEF int smlLibStrncmp(const char *pTarget, const char *pSource, int count);
+SML_API_DEF String_t smlLibStrcat(const char *pTarget, const char *pSource);
+SML_API_DEF String_t smlLibStrchr(const char *pString, char character);
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF void smlLibPrint(const char *text, ...);
+ SML_API_DEF void *smlLibMemmove(void *pTarget, const void *pSource, MemSize_t count);
+ SML_API_DEF void *smlLibRealloc(void *pObject, MemSize_t size);
+ SML_API_DEF String_t smlLibStrncat(const char *pTarget, const char *pSource, int count);
+ SML_API_DEF String_t smlLibStrstr(const char *pString, const char *pSubString);
+#endif
+#endif
+
+//#define MOT_OTK_DEBUG
+#ifdef MOT_OTK_DEBUG
+#include <stdarg.h>
+
+void __kcdbg__(char *fmt, ...);
+#define KCDBG(EXP, args...) __kcdbg__("(%s:%s:%d) " #EXP " %s", "", __FUNCTION__, __LINE__, ##args, "\n")
+#else
+#define KCDBG(EXP, args...)
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/smldef.h b/engine/dmlib/dmengine/oma_toolkit/hdr/smldef.h
new file mode 100644
index 0000000..8ae056b
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/smldef.h
@@ -0,0 +1,232 @@
+/*************************************************************************/
+/* module: Type definitions for SyncML */
+/* */
+/* file: SMLDef.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Platform independent header with syncML types and definitions */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+#ifndef _SML_DEF_H
+ #define _SML_DEF_H
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+
+/**
+ * include target/compiler specific defines/options/settings
+ **/
+#include <define.h>
+
+
+/**
+ * ===================================
+ * Common all-purpose type definitions
+ * ===================================
+ **/
+
+
+
+/**
+ * ==================================
+ * Basic data types
+ * ==================================
+ **/
+typedef short Short_t; // short integer, 16 Bytes
+typedef long Long_t; // long integer, 32 Bytes
+typedef char* String_t; // String pointer,
+typedef unsigned char Byte_t; // a single byte
+typedef Byte_t Boolean_t; // a boolean
+#ifndef NULL // a NULL pointer
+ #define NULL (void*) 0
+#endif
+
+
+typedef Short_t Ret_t; // Return Type of API Commands
+typedef Long_t Length_t; // System dependent string length
+typedef Short_t MemHandle_t; // Memory object Handle
+typedef unsigned char *MemPtr_t; // Memory object Pointer
+typedef void *VoidPtr_t; // Void Pointer
+typedef Long_t MemSize_t; // System dependent memory object size
+typedef unsigned char MemByte_t; // Memory element
+typedef unsigned int Flag_t; // A generic flag type. This type is used to
+ // declare variables in structures wherever
+ // flags are used.
+
+
+
+
+/**
+ * ==================================
+ * Definitions used in the SyncML API
+ * ==================================
+ **/
+
+
+/**
+ * Application callback function displaying output strings to the user
+ **/
+typedef void (*smlPrintFunc) (String_t outputString);
+
+
+/**
+ * structure describing the options and setting of this syncml process
+ **/
+typedef struct sml_options_s {
+ smlPrintFunc defaultPrintFunc; // default application callback for displaying strings,
+ MemSize_t maxWorkspaceAvailMem; // size which all workspaces in total MUST not exceed
+} *SmlOptionsPtr_t, SmlOptions_t;
+
+
+/**
+ * Reference of an instance
+ **/
+#ifdef NOWSM
+typedef void *InstanceID_t; // without wsm, instance ID is direct pointer to instance info
+#else
+typedef MemHandle_t InstanceID_t; // Handle, used as a unique ID of
+#endif // an synchronization instance
+
+
+/**
+ * Type of used encoding
+ **/
+typedef enum {
+ SML_UNDEF = 0,
+ SML_WBXML,
+ SML_XML
+} SmlEncoding_t;
+
+
+/** %%% added luz 2003-07-31:
+ * SyncML version
+ **/
+typedef enum {
+ SML_VERS_UNDEF = 0,
+ SML_VERS_1_0,
+ SML_VERS_1_1,
+ SML_VERS_1_2,
+ SML_NUM_VERS
+} SmlVersion_t;
+
+/**
+ * structure describing the options of an instance,
+ **/
+typedef struct sml_instance_options_s {
+ SmlEncoding_t encoding; // Used encoding type,
+ MemSize_t workspaceSize; // size of the workspace to allocate (instance buffer size if NOWSM defined)
+ #ifndef NOWSM
+ String_t workspaceName; // name of the workspace
+ #else
+ MemSize_t maxOutgoingSize; // max size of outgoing message, 0 if no restriction
+ #endif
+} *SmlInstanceOptionsPtr_t, SmlInstanceOptions_t;
+
+
+/**
+ * Processing modes
+ **/
+typedef enum {
+ SML_DO_NOTHING = 0,
+ SML_FIRST_COMMAND,
+ SML_NEXT_COMMAND,
+ SML_NEXT_MESSAGE,
+ SML_ALL_COMMANDS
+} SmlProcessMode_t;
+
+
+/**
+ * Requested buffer pointer position
+ **/
+typedef enum {
+ SML_FIRST_DATA_ITEM = 0,
+ SML_FIRST_FREE_ITEM
+} SmlBufPtrPos_t;
+
+
+
+/**
+ * SyncML Protocol Management and Command Elements (PE)
+ **/
+typedef enum {
+ SML_PE_UNDEF = 0,
+ SML_PE_ERROR,
+ SML_PE_ADD,
+ SML_PE_ALERT,
+ SML_PE_ATOMIC_START,
+ SML_PE_ATOMIC_END,
+ SML_PE_COPY,
+ SML_PE_DELETE,
+ SML_PE_EXEC,
+ SML_PE_GET,
+ SML_PE_MAP,
+ SML_PE_PUT,
+ SML_PE_RESULTS,
+ SML_PE_SEARCH,
+ SML_PE_SEQUENCE_START,
+ SML_PE_SEQUENCE_END,
+ SML_PE_STATUS,
+ SML_PE_SYNC_START,
+ SML_PE_SYNC_END,
+ SML_PE_REPLACE,
+ SML_PE_HEADER,
+ SML_PE_PUT_GET,
+ SML_PE_CMD_GROUP,
+ SML_PE_GENERIC,
+ SML_PE_FINAL
+} SmlProtoElement_t;
+
+typedef struct
+{
+ Byte_t token;
+ String_t escape_str;
+} ESCAPE_CHAR_TABLE_T;
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/smldevinfdtd.h b/engine/dmlib/dmengine/oma_toolkit/hdr/smldevinfdtd.h
new file mode 100644
index 0000000..49a0ae4
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/smldevinfdtd.h
@@ -0,0 +1,171 @@
+/*****************************************************************************/
+/* module: SyncML Device Information DTD specific type definitions */
+/* */
+/* file: smldevinfdtd.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definition of structures representing DevInf DTD elements */
+/* This file reflects DevInf as specified in the document */
+/* http://www.syncml.org/docs/syncml_devinf_v10_20001207.pdf */
+/*****************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+#ifndef _SML_DEVINFDTD_H
+#define _SML_DEVINFDTD_H
+
+/* process only if we really use DevInf DTD */
+#ifdef __USE_DEVINF__
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+
+#include <smldef.h>
+#include <smldtd.h>
+
+
+typedef struct sml_devinf_ext_s {
+ SmlPcdataPtr_t xnam;
+ SmlPcdataListPtr_t xval; /* optional */
+} *SmlDevInfExtPtr_t, SmlDevInfExt_t;
+
+typedef struct sml_devinf_extlist_s {
+ SmlDevInfExtPtr_t data;
+ struct sml_devinf_extlist_s *next;
+} *SmlDevInfExtListPtr_t, SmlDevInfExtList_t;
+
+typedef struct sml_devinf_synccap_s {
+ SmlPcdataListPtr_t synctype;
+} *SmlDevInfSyncCapPtr_t, SmlDevInfSyncCap_t;
+
+
+typedef struct sml_devinf_ctdata_s {
+ SmlPcdataPtr_t name;
+ SmlPcdataPtr_t dname; /* optional, display name */
+
+ SmlPcdataListPtr_t valenum;
+ SmlPcdataPtr_t datatype;
+ SmlPcdataPtr_t size;
+} *SmlDevInfCTDataPtr_t, SmlDevInfCTData_t;
+
+typedef struct sml_devinf_ctdatalist_s {
+ SmlDevInfCTDataPtr_t data;
+ struct sml_devinf_ctdatalist_s *next;
+} *SmlDevInfCTDataListPtr_t, SmlDevInfCTDataList_t;
+
+typedef struct sml_devinf_ctdataprop_s {
+ SmlDevInfCTDataPtr_t prop;
+ SmlDevInfCTDataListPtr_t param;
+} *SmlDevInfCTDataPropPtr_t, SmlDevInfCTDataProp_t;
+
+typedef struct sml_devinf_ctdataproplist_s {
+ SmlDevInfCTDataPropPtr_t data;
+ struct sml_devinf_ctdataproplist_s *next;
+} *SmlDevInfCTDataPropListPtr_t, SmlDevInfCTDataPropList_t;
+
+typedef struct sml_devinf_ctcap_s {
+ SmlPcdataPtr_t cttype;
+ SmlDevInfCTDataPropListPtr_t prop;
+} *SmlDevInfCTCapPtr_t, SmlDevInfCTCap_t;
+
+typedef struct sml_devinf_ctcaplist_s {
+ SmlDevInfCTCapPtr_t data;
+ struct sml_devinf_ctcaplist_s *next;
+} *SmlDevInfCtcapListPtr_t, SmlDevInfCtcapList_t;
+
+
+typedef struct sml_devinf_dsmem_s {
+ Flag_t flags; /* %%% luz:2003-04-28, mad flag, was PCData (completely wrong) */
+ SmlPcdataPtr_t maxmem; /* optional */
+ SmlPcdataPtr_t maxid; /* optional */
+} *SmlDevInfDSMemPtr_t, SmlDevInfDSMem_t;
+
+
+typedef struct sml_devinf_xmit_s {
+ SmlPcdataPtr_t cttype;
+ SmlPcdataPtr_t verct;
+} *SmlDevInfXmitPtr_t, SmlDevInfXmit_t;
+
+typedef struct sml_devinf_xmitlist_s {
+ SmlDevInfXmitPtr_t data;
+ struct sml_devinf_xmitlist_s *next;
+} *SmlDevInfXmitListPtr_t, SmlDevInfXmitList_t;
+
+typedef struct sml_devinf_datastore_s {
+ SmlPcdataPtr_t sourceref;
+ SmlPcdataPtr_t displayname; /* optional */
+ SmlPcdataPtr_t maxguidsize; /* optional */
+ SmlDevInfXmitPtr_t rxpref;
+ SmlDevInfXmitListPtr_t rx; /* optional */
+ SmlDevInfXmitPtr_t txpref;
+ SmlDevInfXmitListPtr_t tx; /* optional */
+ SmlDevInfDSMemPtr_t dsmem; /* optional */
+ SmlDevInfSyncCapPtr_t synccap;
+} *SmlDevInfDatastorePtr_t, SmlDevInfDatastore_t;
+
+
+typedef struct sml_devinf_datastorelist_s {
+ SmlDevInfDatastorePtr_t data;
+ struct sml_devinf_datastorelist_s *next;
+} *SmlDevInfDatastoreListPtr_t, SmlDevInfDatastoreList_t;
+
+typedef struct sml_devinf_devinf_s {
+ SmlPcdataPtr_t verdtd;
+ SmlPcdataPtr_t man; /* optional */
+ SmlPcdataPtr_t mod; /* optional */
+ SmlPcdataPtr_t oem; /* optional */
+ SmlPcdataPtr_t fwv; /* optional */
+ SmlPcdataPtr_t swv; /* optional */
+ SmlPcdataPtr_t hwv; /* optional */
+ SmlPcdataPtr_t devid;
+ SmlPcdataPtr_t devtyp;
+ SmlDevInfDatastoreListPtr_t datastore;
+ SmlDevInfCtcapListPtr_t ctcap;
+ SmlDevInfExtListPtr_t ext;
+ /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+ Flag_t flags;
+} *SmlDevInfDevInfPtr_t, SmlDevInfDevInf_t;
+
+#endif // __USE_DEVINF__
+#endif //_SML_DEVINFDTD_H_
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/smldmtnddtd.h b/engine/dmlib/dmengine/oma_toolkit/hdr/smldmtnddtd.h
new file mode 100644
index 0000000..49b2526
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/smldmtnddtd.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*--------------------------------------------------------------------------------------------------
+
+ Header Name: smldmtnddtd.h
+
+ General Description: OMA DM TND DTD specific type definitions
+
+--------------------------------------------------------------------------------------------------*/
+
+#ifndef _SML_DM_TND_DTD_H
+#define _SML_DM_TND_DTD_H
+
+/* process only if we really use DM TND DTD */
+#ifdef __USE_DMTND__
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include <smldef.h>
+#include <smldtd.h>
+
+typedef struct sml_dmtnd_format_s {
+ SmlPcdataPtr_t value; /* optional */
+} *SmlDmTndFormatPtr_t, SmlDmTndFormat_t;
+
+typedef struct sml_dmtnd_type_s {
+ SmlPcdataPtr_t mime; /* optional */
+ SmlPcdataPtr_t ddfname; /* optional */
+} *SmlDmTndTypePtr_t, SmlDmTndType_t;
+
+typedef struct sml_dmtnd_rtprops_s {
+ SmlPcdataPtr_t acl; /* optional */
+ SmlDmTndFormatPtr_t format; /* optional */
+ SmlPcdataPtr_t name; /* optional */
+ SmlPcdataPtr_t size; /* optional */
+ SmlPcdataPtr_t title; /* optional */
+ SmlPcdataPtr_t tstamp; /* optional */
+ SmlDmTndTypePtr_t type;
+ SmlPcdataPtr_t verno; /* optional */
+} *SmlDmTndRTPropsPtr_t, SmlDmTndRTProps_t;
+
+typedef struct sml_dmtnd_dfelement_s {
+ SmlPcdataPtr_t value; /* optional */
+} *SmlDmTndDFElementPtr_t, SmlDmTndDFElement_t;
+
+typedef struct sml_dmtnd_dfprops_s {
+ SmlDmTndDFElementPtr_t accesstype;
+ SmlPcdataPtr_t defaultvalue; /* optional */
+ SmlPcdataPtr_t description; /* optional */
+ SmlDmTndFormatPtr_t dfformat;
+ SmlDmTndDFElementPtr_t occurrence; /* optional */
+ SmlDmTndDFElementPtr_t scope; /* optional */
+ SmlPcdataPtr_t dftitle; /* optional */
+ SmlDmTndTypePtr_t dftype;
+ SmlDmTndDFElementPtr_t casesense;
+} *SmlDmTndDFPropsPtr_t, SmlDmTndDFProps_t;
+
+typedef struct sml_dmtnd_node_list_s *SmlDmTndNodeListPtr_t;
+
+typedef struct sml_dmtnd_node_s {
+ SmlPcdataPtr_t nodename;
+ SmlPcdataPtr_t path; /* optional */
+ SmlDmTndRTPropsPtr_t rtprops; /* optional */
+ SmlDmTndDFPropsPtr_t dfprops; /* optional */
+ SmlPcdataPtr_t value; /* optional */
+ SmlDmTndNodeListPtr_t nodelist; /* optional */
+} *SmlDmTndNodePtr_t, SmlDmTndNode_t;
+
+typedef struct sml_dmtnd_node_list_s {
+ SmlDmTndNodePtr_t node;
+ struct sml_dmtnd_node_list_s *next;
+} SmlDmTndNodeList_t;
+
+typedef struct sml_dmtnd_s {
+ SmlPcdataPtr_t verdtd;
+ SmlPcdataPtr_t man; /* optional */
+ SmlPcdataPtr_t mod; /* optional */
+ SmlDmTndNodeListPtr_t nodelist; /* optional */
+} *SmlDmTndPtr_t, SmlDmTnd_t;
+
+#endif // __USE_DMTND__
+#endif /* _SML_DM_TND_DTD_H */
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/smldtd.h b/engine/dmlib/dmengine/oma_toolkit/hdr/smldtd.h
new file mode 100644
index 0000000..5c82024
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/smldtd.h
@@ -0,0 +1,421 @@
+/*************************************************************************/
+/* module: SyncML DTD specific type definitions */
+/* */
+/* file: smldtd.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definition of structures representing DTD elements */
+/*************************************************************************/
+
+
+/********************************************************************/
+/* NOTE: */
+/* These definitions are based on the DTD dated from July, 7th, 00 */
+/********************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _SML_DTD_H
+ #define _SML_DTD_H
+
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+
+#include <smldef.h>
+
+
+
+
+/**
+ * ===========================
+ * Common used SyncML Elements
+ * ===========================
+ */
+
+
+
+/**
+ * PCDATA - types of synchronization data which SyncML supports
+ **/
+typedef enum {
+ SML_PCDATA_UNDEFINED = 0,
+ SML_PCDATA_STRING, // String type
+ SML_PCDATA_OPAQUE, // Opaque type
+ SML_PCDATA_EXTENSION, // Extention type - specified by PcdataExtension_t
+ SML_PCDATA_CDATA // XML CDATA type
+} SmlPcdataType_t;
+
+
+/**
+ * PCDATA - types of extensions for PCData elements
+ */
+typedef enum {
+ SML_EXT_UNDEFINED = 0,
+ SML_EXT_METINF, // Meta Information
+ SML_EXT_DEVINF, // Device Information
+ SML_EXT_DMTND, // DM TNM DDF
+ SML_EXT_LAST // last codepage, needed for loops!
+} SmlPcdataExtension_t;
+
+
+
+/**
+ * PCDATA - into this structure SyncML wraps the synchronization data itself
+ **/
+typedef struct sml_pcdata_s {
+ SmlPcdataType_t contentType; // The type of data which a PCDATA structure contains
+ SmlPcdataExtension_t extension; // PCData Extension type
+ MemSize_t length; // length of the data in this PCDATA structure
+ VoidPtr_t content; // Pointer to the data itself
+} *SmlPcdataPtr_t, SmlPcdata_t;
+
+/* generic list of PCData elements */
+typedef struct sml_pcdata_list_s {
+ SmlPcdataPtr_t data;
+ struct sml_pcdata_list_s *next;
+} *SmlPcdataListPtr_t, SmlPcdataList_t;
+
+/**
+ * Various flags which are actually declared and (EMPTY) elements in
+ * SyncML. This assumes at least a 16-bit architecture for the
+ * underlying OS. We need to review this if that is deemed a problem.
+ **/
+#define SmlArchive_f 0x8000 // Delete flags
+#define SmlSftDel_f 0x4000 // Delete flags
+#define SmlESNData_f 0x2000 // ESN data flags
+#define SmlESNBinary_f 0x1000 // ESN binary data flags
+#define SmlMoreData_f 0x0400 // MoreData flag
+#define SmlNoResults_f 0x0200 // No Results flag
+#define SmlNoResp_f 0x0100 // No Response flag
+#define SmlFinal_f 0x0001 // Header flag
+#ifdef __USE_METINF__
+#define SmlMetInfSharedMem_f 0x0002 // MetInf Shared Memory Flag
+#endif
+#ifdef __USE_DEVINF__
+#define SmlDevInfSharedMem_f 0x0004 // DevInf Shared Memory Flag
+/* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+#define SmlDevInfUTC_f 0x0001 // DevInf utc Flag
+#define SmlDevInfNOfM_f 0x0002 // DevInf support n of m Flag
+#define SmlDevInfLargeObject_f 0x0008 // DevInf support large object Flag
+#endif
+
+
+/**
+ * Chal
+ **/
+typedef struct sml_chal_s {
+ SmlPcdataPtr_t meta;
+} *SmlChalPtr_t, SmlChal_t;
+
+/**
+ * Credentials
+ **/
+typedef struct sml_cred_s {
+ SmlPcdataPtr_t meta; // opt.
+ SmlPcdataPtr_t data;
+} *SmlCredPtr_t, SmlCred_t;
+
+
+
+/**
+ * Source or target location
+ **/
+typedef struct sml_source_or_target_s {
+ SmlPcdataPtr_t locURI;
+ SmlPcdataPtr_t locName; // opt.
+} *SmlSourcePtr_t, SmlSource_t,
+ *SmlTargetPtr_t, SmlTarget_t;
+
+typedef struct sml_source_list_s {
+ SmlSourcePtr_t source;
+ struct sml_source_list_s *next;
+} *SmlSourceListPtr_t, SmlSourceList_t;
+
+
+
+/**
+ * ==============================
+ * SyncML Message Header Elements
+ * ==============================
+ **/
+
+
+/**
+ * SyncML header
+ * As the header is needed for each SyncML message, it's also the parameter
+ * of the startMessage call.
+ **/
+typedef struct sml_sync_hdr_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t version;
+ SmlPcdataPtr_t proto;
+ SmlPcdataPtr_t sessionID;
+ SmlPcdataPtr_t msgID;
+ Flag_t flags; // NoResp
+ SmlTargetPtr_t target;
+ SmlSourcePtr_t source;
+ SmlPcdataPtr_t respURI; // opt.
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+} *SmlSyncHdrPtr_t, SmlSyncHdr_t;
+
+// SyncML Body and SyncML container is not needed, as there are function calls
+// (smlStartMessage(), smlEndMessage()) that let the framework know when to start and end
+// the SyncML document
+
+
+
+/**
+ * =========================
+ * Data description elements
+ * =========================
+ **/
+
+
+/**
+ * Data in SyncML is encapsulated in an "item" element.
+ **/
+typedef struct sml_item_s {
+ SmlTargetPtr_t target; // opt.
+ SmlSourcePtr_t source; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlPcdataPtr_t data; // opt.
+ Flag_t flags; // opt. for MoreData
+} *SmlItemPtr_t, SmlItem_t;
+
+typedef struct sml_item_list_s {
+ SmlItemPtr_t item;
+ struct sml_item_list_s *next;
+} *SmlItemListPtr_t, SmlItemList_t;
+
+
+/**
+ * ==============================================
+ * SyncML Commands (Protocol Management Elements)
+ * ==============================================
+ **/
+
+
+
+/**
+ * Generic commands:
+ * Add, Copy, Replace, Delete
+ **/
+typedef struct sml_generic_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp, Archive (Delete), SftDel (Delete)
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlItemListPtr_t itemList;
+} *SmlAddPtr_t, SmlAdd_t,
+ *SmlCopyPtr_t, SmlCopy_t,
+ *SmlReplacePtr_t, SmlReplace_t,
+ *SmlDeletePtr_t, SmlDelete_t,
+ *SmlGenericCmdPtr_t, SmlGenericCmd_t;
+
+/**
+ * Alert command:
+ **/
+typedef struct sml_alert_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t data; // opt.
+ SmlItemListPtr_t itemList;
+ SmlPcdataPtr_t correlator; // opt.
+} *SmlAlertPtr_t, SmlAlert_t;
+
+
+/**
+ * Atomic/Sequence command:
+ **/
+typedef struct sml_atomic_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlPcdataPtr_t meta; // opt.
+} *SmlAtomicPtr_t, SmlAtomic_t,
+ *SmlSequencePtr_t, SmlSequence_t;
+
+
+/**
+ * Sync command:
+ **/
+typedef struct sml_sync_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlCredPtr_t cred; // opt.
+ SmlTargetPtr_t target; // opt.
+ SmlSourcePtr_t source; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlPcdataPtr_t noc; // opt. (SyncML 1.1)
+} *SmlSyncPtr_t, SmlSync_t;
+
+
+/**
+ * Exec command:
+ **/
+typedef struct sml_exec_s {
+ SmlProtoElement_t elementType;
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlItemPtr_t item;
+ SmlPcdataPtr_t correlator; // opt.
+
+} *SmlExecPtr_t, SmlExec_t;
+
+
+/**
+ * Get and Put command:
+ **/
+typedef struct sml_get_put_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlPcdataPtr_t lang; // opt.
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlItemListPtr_t itemList;
+} *SmlPutPtr_t, SmlPut_t,
+ *SmlGetPtr_t, SmlGet_t;
+
+
+/**
+ * Map command:
+ **/
+typedef struct sml_map_item_s {
+ SmlTargetPtr_t target;
+ SmlSourcePtr_t source;
+} *SmlMapItemPtr_t, SmlMapItem_t;
+
+typedef struct sml_map_item_list_s {
+ SmlMapItemPtr_t mapItem;
+ struct sml_map_item_list_s *next;
+} *SmlMapItemListPtr_t, SmlMapItemList_t;
+
+typedef struct sml_map_s {
+ SmlProtoElement_t elementType; // InternalToolkit Field
+ SmlPcdataPtr_t cmdID;
+ SmlTargetPtr_t target;
+ SmlSourcePtr_t source;
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlMapItemListPtr_t mapItemList;
+} *SmlMapPtr_t, SmlMap_t;
+
+
+
+/**
+ * Results command:
+ **/
+typedef struct sml_results_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ SmlPcdataPtr_t msgRef; // opt.
+ SmlPcdataPtr_t cmdRef;
+ SmlPcdataPtr_t meta; // opt.
+ SmlPcdataPtr_t targetRef; // opt.
+ SmlPcdataPtr_t sourceRef; // opt.
+ SmlItemListPtr_t itemList;
+} *SmlResultsPtr_t, SmlResults_t;
+
+
+/**
+ * Search command:
+ **/
+typedef struct sml_search_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp, NoResults
+ SmlCredPtr_t cred; // opt.
+ SmlTargetPtr_t target; // opt.
+ SmlSourceListPtr_t sourceList;
+ SmlPcdataPtr_t lang; // opt.
+ SmlPcdataPtr_t meta;
+ SmlPcdataPtr_t data;
+} *SmlSearchPtr_t, SmlSearch_t;
+
+
+/**
+ * Status command:
+ **/
+
+typedef struct sml_target_ref_list_s {
+ SmlPcdataPtr_t targetRef;
+ struct sml_target_ref_list_s *next;
+} *SmlTargetRefListPtr_t, SmlTargetRefList_t;
+
+typedef struct sml_source_ref_list_s {
+ SmlPcdataPtr_t sourceRef;
+ struct sml_source_ref_list_s *next;
+} *SmlSourceRefListPtr_t, SmlSourceRefList_t;
+
+typedef struct sml_status_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ SmlPcdataPtr_t msgRef; // Opt.
+ SmlPcdataPtr_t cmdRef;
+ SmlPcdataPtr_t cmd;
+ SmlTargetRefListPtr_t targetRefList; // opt.
+ SmlSourceRefListPtr_t sourceRefList; // opt.
+ SmlCredPtr_t cred; // opt.
+ SmlChalPtr_t chal; // opt.
+ SmlPcdataPtr_t data;
+ SmlItemListPtr_t itemList; // opt.
+} *SmlStatusPtr_t, SmlStatus_t;
+
+
+/**
+ * a little helper for typecasting
+ **/
+typedef struct sml_unknown_proto_element_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+} *SmlUnknownProtoElementPtr_t, SmlUnknownProtoElement_t;
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/smlerr.h b/engine/dmlib/dmengine/oma_toolkit/hdr/smlerr.h
new file mode 100644
index 0000000..57f5eac
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/smlerr.h
@@ -0,0 +1,136 @@
+/*************************************************************************/
+/* module: ErrorLibrary */
+/* */
+/* file: smlerr.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definition of the used Error Codes */
+/*************************************************************************/
+
+
+
+ /*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _SML_ERR_H
+ #define _SML_ERR_H
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+
+/**
+ * No error, success code
+ **/
+#define SML_ERR_OK 0x00 // OK
+
+
+
+
+/**
+ * SyncML Common Error Codes
+ **/
+
+// general errors
+#define SML_ERR_UNSPECIFIC 0x10 // unspecific error
+#define SML_ERR_NOT_ENOUGH_SPACE 0x11 // not enough memory to perform this operation
+#define SML_ERR_WRONG_USAGE 0x13 // function was called in wrong context
+
+// wrong parameters
+#define SML_ERR_WRONG_PARAM 0x20 // wrong parameter
+#define SML_ERR_INVALID_SIZE 0x21 // param has an invalid size
+#define SML_ERR_INVALID_HANDLE 0x22 // if handle is invalid/unknown
+#define SML_ERR_INVALID_OPTIONS 0x23 // unkown or unallowed options
+
+
+/**
+ * SyncML Mgr Error Codes
+ **/
+#define SML_ERR_A_MGR_ERROR 0x1001 // a template
+#define SML_ERR_MGR_INVALID_INSTANCE_INFO 0x1002 // a invalid Instance Info structure is used
+#define SML_ERR_COMMAND_NOT_HANDLED 0x1003 // no callback function is available to handle this command
+#define SML_ERR_ALREADY_INITIALIZED 0x1004 // Mgr allready initialized
+
+
+/**
+ * SyncML Xlt Error Codes
+ **/
+#define SML_ERR_XLT_MISSING_CONT 0x2001 // required field content missing
+#define SML_ERR_XLT_BUF_ERR 0x2002 // Buffer too small
+#define SML_ERR_XLT_INVAL_PCDATA_TYPE 0x2003 // Invalid (WBXML) Element Type (STR_I etc.)
+#define SML_ERR_XLT_INVAL_LIST_TYPE 0x2004 // Invalid List Type (COL_LIST etc.)
+#define SML_ERR_XLT_INVAL_TAG_TYPE 0x2005 // Invalid Tag Type (TT_BEG etc.)
+#define SML_ERR_XLT_ENC_UNK 0x2007 // Unknown Encoding (WBXML, XML)
+#define SML_ERR_XLT_INVAL_PROTO_ELEM 0x2008 // Invalid Protocol Element (ADD, Delete, ...)
+#define SML_ERR_MISSING_LIST_ELEM 0x2009 // Missing Content of List Elements
+#define SML_ERR_XLT_INCOMP_WBXML_VERS 0x200A // Incompatible WBXML Content Format Version
+#define SML_ERR_XLT_INVAL_SYNCML_DOC 0x200B // Document does not conform to SyncML DTD
+#define SML_ERR_XLT_INVAL_PCDATA 0x200C // Invalid PCData elem (e.g. not encoded as OPAQUE data)
+#define SML_ERR_XLT_TOKENIZER_ERROR 0x200D // Unspecified tokenizer error
+#define SML_ERR_XLT_INVAL_WBXML_DOC 0x200E // Document does not conform to WBXML specification
+#define SML_ERR_XLT_WBXML_UKN_TOK 0x200F // Document contains unknown WBXML token
+#define SML_ERR_XLT_MISSING_END_TAG 0x2010 // Non-empty start tag without matching end tag
+#define SML_ERR_XLT_INVALID_CODEPAGE 0x2011 // WBXML document uses unspecified code page
+#define SML_ERR_XLT_END_OF_BUFFER 0x2012 // End of buffer reached
+#define SML_ERR_XLT_INVAL_XML_DOC 0x2013 // Document does not conform to XML 1.0 specification
+#define SML_ERR_XLT_XML_UKN_TAG 0x2014 // Document contains unknown XML tag
+#define SML_ERR_XLT_INVAL_PUB_IDENT 0x2015 // Invalid Public Identifier
+#define SML_ERR_XLT_INVAL_EXT 0x2016 // Invalid Codepage Extension
+#define SML_ERR_XLT_NO_MATCHING_CODEPAGE 0x2017 // No matching Codepage could be found
+#define SML_ERR_XLT_INVAL_INPUT_DATA 0x2018 // Data missing in input structure
+
+
+/**
+ * SyncML Wsm Error Codes
+ **/
+#define SML_ERR_WSM_BUF_TABLE_FULL 0x3001 // no more empty entries in buffer table available
+
+/**
+ * SyncML Util Error Codes
+ **/
+#define SML_ERR_A_UTI_UNKNOWN_PROTO_ELEMENT 0x7001
+
+
+#endif
+
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/smlmetinfdtd.h b/engine/dmlib/dmengine/oma_toolkit/hdr/smlmetinfdtd.h
new file mode 100644
index 0000000..b899086
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/smlmetinfdtd.h
@@ -0,0 +1,98 @@
+/*****************************************************************************/
+/* module: SyncML Meta Information DTD specific type definitions */
+/* */
+/* file: smlmetinfdtd.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definition of structures representing MetInf DTD elements */
+/*****************************************************************************/
+
+
+/**************************************************************************/
+/* NOTE: */
+/* These definitions are based on the MetInf DTD dated from Aug, 29th, 00 */
+/**************************************************************************/
+
+
+
+ /*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#ifndef _SML_METINFDTD_H
+#define _SML_METINFDTD_H
+
+/* process only if we really use MetInf DTD */
+#ifdef __USE_METINF__
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+
+#include <smldef.h>
+#include <smldtd.h>
+
+
+typedef struct sml_metinf_anchor_s {
+ SmlPcdataPtr_t last; /* optional */
+ SmlPcdataPtr_t next;
+} *SmlMetInfAnchorPtr_t, SmlMetInfAnchor_t;
+
+typedef struct sml_metinf_mem_s {
+ SmlPcdataPtr_t shared; /* optional */
+ SmlPcdataPtr_t free;
+ SmlPcdataPtr_t freeid;
+} *SmlMetInfMemPtr_t, SmlMetInfMem_t;
+
+typedef struct sml_metinf_metinf_s {
+ SmlPcdataPtr_t format; /* opt. */
+ SmlPcdataPtr_t type; /* opt. */
+ SmlPcdataPtr_t mark; /* opt. */
+ SmlPcdataPtr_t size; /* opt. */
+ SmlPcdataPtr_t nextnonce; /* opt. */
+ SmlPcdataPtr_t version;
+ SmlPcdataPtr_t maxmsgsize; /* optional */
+ /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+ SmlPcdataPtr_t maxobjsize; /* optional */
+ SmlMetInfMemPtr_t mem; /* optional */
+ SmlPcdataListPtr_t emi; /* optional */
+ SmlMetInfAnchorPtr_t anchor; /* opt. */
+} *SmlMetInfMetInfPtr_t, SmlMetInfMetInf_t;
+
+#endif /* __USE_METINF__ */
+#endif /* _SML_METINFDTD_H */
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/wsm.h b/engine/dmlib/dmengine/oma_toolkit/hdr/wsm.h
new file mode 100644
index 0000000..2ebc138
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/wsm.h
@@ -0,0 +1,427 @@
+/*************************************************************************/
+/* module: SyncML WorkSpace Manager */
+/* file: WSM.h */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Workspace Manager API <BR>
+ * Manages the SyncML document in memory.
+ *
+ * @version @label
+ *
+ */
+
+#ifndef _WSM_H
+#define _WSM_H
+
+#include "smlerr.h"
+#include "smldef.h"
+
+#ifndef NOWSM
+
+#include "wsm_sm.h"
+
+
+typedef struct WsmOptions_s {
+ MemSize_t maxAvailMem; // maximum amount of memory available for all wsm buffers
+} WsmOptions_t;
+
+
+#ifdef __SML_LITE__
+ #ifdef MAX_WSM_BUFFERS
+ #error "for __SML_LITE__, MAX_WSM_BUFFERS must not be predefined!"
+ #endif
+ #define MAX_WSM_BUFFERS 1
+#else
+ #ifndef MAX_WSM_BUFFERS
+ // use default value of 4 (not much for a multi-connection server)
+ #define MAX_WSM_BUFFERS 4
+ #endif
+#endif
+
+
+/** WSM internal buffer structure */
+typedef struct WsmBuf_s {
+ String_t bufName; // external name of buffer
+ MemHandle_t memH; // memory handle
+ MemPtr_t pFirstFree; // pointer to first free element in buffer
+ MemPtr_t pFirstData; // pointer to first data element in buffer
+ MemSize_t size; // size of buffer
+ MemSize_t usedBytes; // used bytes in buffer
+ Byte_t flags;
+} WsmBuf_t;
+
+
+/** WSM globals for use with global Anchor */
+typedef struct WsmGlobals_s {
+ Ret_t wsmRet; // last WSM return code
+ Byte_t initWasCalled; // was wsmInit() called?
+ WsmBuf_t wsmBuf[MAX_WSM_BUFFERS];
+ Short_t wsmIndex; // Index of actual buffer
+ WsmSmGlobals_t wsmSm; // WSM_SM global; device dependent!
+} *WsmGlobalsPtr_t, WsmGlobals_t;
+
+
+/**
+ * FUNCTION: wsmInit
+ *
+ * Initializes all Workspace Manager related resources.<BR>
+ * Should only be called once!
+ *
+ * PRE-Condition: This is the first function call to WSM
+ *
+ * POST-Condition: All WSM resources are initialized
+ *
+ * IN: wsmOpts
+ * WSM options, valid options are:
+ * <UL>
+ * <LI> tbd
+ * </UL>
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_OPTIONS, if wsmOpts is not valid
+ * SML_ERR_NOT_ENOUGH_SPACE, if not enough available memory
+ * SML_ERR_WRONG_USAGE, if wsmInit was already called
+ */
+Ret_t wsmInit (const WsmOptions_t *wsmOpts);
+
+
+/**
+ * FUNCTION: wsmCreate
+ *
+ * Creates and opens a new buffer with name bufName and size bufSize.<BR>
+ * If a buffer with name bufName already exists, the existing buffer
+ * is resized to bufSize.
+ *
+ * PRE-Condition: bufSize > 0
+ *
+ * POST-Condition: handle refers to buffer bufName; BufferSize = size
+ *
+ * IN: bufName
+ * Name of buffer to be created
+ * IN: bufSize
+ * Size of buffer to be created
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_SIZE, if bufSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < bufSize
+ * SML_ERR_WSM_BUF_TABLE_FULL, if buffer table is full
+ * SML_ERR_WRONG_USAGE, if wsmInit wasn't called before
+ *
+ * @see wsmDestroy
+ */
+Ret_t wsmCreate (String_t bufName, MemSize_t bufSize, MemHandle_t *wsmH);
+
+
+/**
+ * FUNCTION: wsmOpen
+ *
+ * Open existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName
+ *
+ * POST-Condition: wsmH refers to buffer bufName
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_WRONG_PARAM, if bufName is unknown
+ *
+ * @see wsmClose
+ */
+Ret_t wsmOpen (String_t bufName, MemHandle_t *wsmH);
+
+
+/**
+ * FUNCTION: wsmClose
+ *
+ * Close an open buffer.
+ *
+ * PRE-Condition: handle is valid; handle is unlocked
+ *
+ * POST-Condition: handle is not known to WSM any more
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmOpen
+ */
+Ret_t wsmClose (MemHandle_t wsmH);
+
+
+/**
+ * FUNCTION: wsmDestroy
+ *
+ * Destroy existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName; handle is unlocked
+ *
+ * POST-Condition: buffer is not known to WSM any more; all resources
+ * connected to this buffer are freed
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if bufName is unknown to WSM
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmCreate
+ */
+Ret_t wsmDestroy (String_t bufName);
+
+
+/**
+ * FUNCTION: wsmTerminate
+ *
+ * Terminate WSM; free all buffers and resources.
+ *
+ * PRE-Condition: all handles must be unlocked
+ *
+ * POST-Condition: all resources are freed
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if a handle was still locked
+ *
+ */
+Ret_t wsmTerminate (void);
+
+/**
+ * FUNCTION: wsmProcessedBytes
+ *
+ * Tell Workspace Manager the number of bytes already processed.
+ *
+ * PRE-Condition: handle is locked; handle is valid;
+ * noBytes <= wsmGetUsedSize
+ *
+ * POST-Condition: noBytes starting at wsmGetPtr() position are deleted;
+ * remaining bytes are copied to
+ * wsmGetPtr(SML_FIRST_FREE_ITEM) position;
+ * wsmGetUsedSize -= noBytes; wsmGetFreeSize += noBytes
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: noBytes
+ * Number of bytes already processed from buffer.
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_INVALID_SIZE, if noBytes > wsmGetUsedSize
+ *
+ * @see wsmGetFreeSize
+ */
+Ret_t wsmProcessedBytes (MemHandle_t wsmH, MemSize_t noBytes);
+
+
+/**
+ * FUNCTION: wsmLockH
+ *
+ * Locks handle wsmH and get a pointer to the contents of wsmH. <BR>
+ * RequestedPos describes the position in the buffer to which the returned
+ * pointer should point to. Valid values are:
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM
+ * <LI> SML_FIRST_FREE_ITEM
+ * </UL>
+ *
+ * PRE-Condition: handle is unlocked; handle is valid
+ *
+ * POST-Condition: handle is locked; points to first data item,
+ * or first free item.
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: requestedPos
+ * Requested position of the returned pointer
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM : points to first data entry
+ * <LI> SML_FIRST_FREE_ITEM : points to first free entry
+ * </UL>
+ *
+ * OUT: pMem
+ * Pointer to requested memory
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ * SML_ERR_UNSPECIFIC, if requested position is unknown, or lock failed
+ *
+ * @see wsmUnlockH
+ */
+Ret_t wsmLockH (MemHandle_t wsmH, SmlBufPtrPos_t requestedPos,
+ MemPtr_t *pMem);
+
+
+/**
+ * FUNCTION: wsmGetFreeSize
+ *
+ * Returns the remaining unused bytes in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: wsmGetFreeSize = BufferSize - wsmGetUsedSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: freeSize
+ * Number of bytes which are unused in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetUsedSize
+ * @see wsmProcessedBytes
+ */
+Ret_t wsmGetFreeSize(MemHandle_t wsmH, MemSize_t *freeSize);
+
+
+/**
+ * FUNCTION: wsmGetUsedSize
+ *
+ * Returns the number of bytes used in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: usedSize = BufferSize - wsmGetFreeSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: usedSize
+ * Number of bytes which are already used in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetFreeSize
+ * @see wsmSetUsedSize
+ */
+Ret_t wsmGetUsedSize(MemHandle_t wsmH, MemSize_t *usedSize);
+
+
+/**
+ * FUNCTION: wsmUnlockH
+ *
+ * Unlock handle wsmH. <BR>
+ * After this call all pointers to this memory handle are invalid
+ * and should no longer be used.
+ *
+ * PRE-Condition: handle is locked; handle is valid
+ *
+ * POST-Condition: handle is unlocked
+ *
+ * OUT: wsmH
+ * Handle to unlock
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_UNSPECIFIC, unlock failed
+ *
+ * @see wsmLockH
+ */
+Ret_t wsmUnlockH (MemHandle_t wsmH);
+
+
+/**
+ * FUNCTION: wsmSetUsedSize
+ *
+ * Tell Workspace how many data were written into buffer.
+ *
+ * PRE-Condition: handle is valid; usedSize <= wsmGetFreeSize; handle is
+ * locked
+ *
+ * POST-Condition: wsmGetUsedSize += usedSize; wsmGetFreeSize -= usedSize;
+ * instancePtr += usedSize;
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: usedSize
+ * Number of bytes which were written into buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_INVALID_SIZE, if usedSize <= wsmGetFreeSize
+ *
+ * @see wsmGetUsedSize
+ */
+Ret_t wsmSetUsedSize (MemHandle_t wsmH, MemSize_t usedSize);
+
+/**
+ * FUNCTION: wsmReset
+ *
+ * Reset the Workspace
+ *
+ * PRE-Condition: -
+ *
+ * POST-Condition: all data is lost. The FirstFree Position equals
+ * the First Data position
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ *
+ */
+Ret_t wsmReset (MemHandle_t wsmH) ;
+
+#endif // !defined(NOWSM)
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/wsm_sm.h b/engine/dmlib/dmengine/oma_toolkit/hdr/wsm_sm.h
new file mode 100644
index 0000000..b07463e
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/wsm_sm.h
@@ -0,0 +1,290 @@
+/*************************************************************************/
+/* module: SyncML WorkSpace Manager */
+/* */
+/* file: WSM_SM.h */
+/* target system: All */
+/* target OS: All */
+/* */
+/* Description */
+/* Storage Management for Workspace Manager API <BR> */
+/* Encapsulates OS dependent parts of WSM. */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * @version @label
+ */
+
+#ifndef _WSM_SM_H
+#define _WSM_SM_H
+
+#include <smldef.h>
+
+
+#ifdef __ANSI_C__
+/* sbuffer list */
+typedef struct smWinList_s {
+ char *memName; // name of buffer
+ char *winH; // reference to memory block
+ MemHandle_t memH; // handle of memory block
+ Byte_t locked; // is handle locked?
+ MemSize_t memSize; // size of memory block
+ struct smWinList_s *next; // next list item
+} smWinList_t;
+typedef smWinList_t *WsmSmGlobals_t;
+#endif
+
+#ifdef __PALM_OS__
+#include <Pilot.h>
+/* dynamic buffer array */
+typedef struct smPalm_s {
+ Handle smPalmH; // reference to only memory block
+ MemHandle_t smMemH; // handle of only memory block
+ Byte_t smLocked; // is handle locked?
+} WsmSmGlobals_t;
+#endif
+
+#ifdef __EPOC_OS__
+/* sbuffer list */
+typedef struct smWinList_s {
+ char *memName; // name of buffer
+ char *winH; // reference to memory block
+ MemHandle_t memH; // handle of memory block
+ Byte_t locked; // is handle locked?
+ MemSize_t memSize; // size of memory block
+ struct smWinList_s *next; // next list item
+} smWinList_t;
+typedef smWinList_t *WsmSmGlobals_t;
+#endif
+
+
+/**
+ * FUNCTION: smCreate
+ *
+ * Creates a new memory block with name memName and size memSize.
+ *
+ * PRE-Condition: OS does not know memName; memSize > 0
+ *
+ * POST-Condition: memName exists with size memSize;
+ * memH refers to new memory block.
+ *
+ * IN: memName
+ * Name of new memory block
+ * IN: memSize
+ * Size of new memory block
+ *
+ * OUT: memH
+ * Handle to new memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if memName is already known to the OS
+ * SML_ERR_INVALID_SIZE, if memSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < memSize
+ *
+ * @see smDestroy
+ */
+Ret_t smCreate (String_t memName, MemSize_t memSize, MemHandle_t *memH);
+
+
+/**
+ * FUNCTION: smOpen
+ *
+ * Open connection to memory block with name memName.
+ *
+ * PRE-Condition: OS does know memName
+ *
+ * POST-Condition: memH refers to memory block memName
+ *
+ * IN: memName
+ * Name of memory block to open
+ *
+ * OUT: memH
+ * Handle to opened memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memName is unknown
+ *
+ * @see smClose
+ */
+Ret_t smOpen (String_t memName, MemHandle_t *memH);
+
+
+/**
+ * FUNCTION: smClose
+ *
+ * Close link to memory block.
+ *
+ * PRE-Condition: memH is a valid memory block handle; memH is unlocked;
+ * no pointers to records are in use
+ *
+ * POST-Condition: memH is not valid anymore
+ *
+ * IN: memH
+ * Handle to close
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if memH is locked
+ *
+ * @see smOpen
+ */
+Ret_t smClose (MemHandle_t memH);
+
+
+/**
+ * FUNCTION: smDestroy
+ *
+ * Remove memory block memName within OS.
+ *
+ * PRE-Condition: memName is a valid memory block name;
+ * memory block is not in use (i.e. no handles and
+ * pointers to this memory block are in use)
+ *
+ * POST-Condition: memName is not a valid memory block name anymore
+ *
+ * IN: memName
+ * Name of memory block to remove
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memName is unknown
+ * SML_ERR_WRONG_USAGE, if memory block is still locked
+ *
+ * @see smCreate
+ */
+Ret_t smDestroy (String_t memName);
+
+
+/**
+ * FUNCTION: smLock
+ *
+ * Map memory block memH to local address space.
+ *
+ * PRE-Condition: memH is a valid handle; memory block is not locked
+ *
+ * POST-Condition: pMem points to memory block memH;
+ * memory block is locked
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * OUT: pMem
+ * Pointer to memory block memH mapped in local address space
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH was already locked
+ * SML_ERR_UNSPECIFIC, if lock failed
+ *
+ * @see smUnlock
+ */
+Ret_t smLock (MemHandle_t memH, MemPtr_t *pMem);
+
+
+/**
+ * FUNCTION: smUnlock
+ *
+ * Free pointer mapped to memH memory block.
+ *
+ * PRE-Condition: memH is a valid handle; memory block is locked
+ *
+ * POST-Condition: memory block is unlocked
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH was already unlocked
+ * SML_ERR_UNSPECIFIC, if unlock failed
+ *
+ * @see smLock
+ */
+Ret_t smUnlock (MemHandle_t memH);
+
+
+/**
+ * FUNCTION: smSetSize
+ *
+ * Set size of memory block memH to newSize.
+ *
+ * PRE-Condition: memH is a valid handle; newSize > 0;
+ * memory block is unlocked
+ *
+ * POST-Condition: memory block size = newSize
+ *
+ * IN: memH
+ * Handle to memory block
+ * IN: newSize
+ * New size of memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH is locked
+ * SML_ERR_INVALID_SIZE, if newSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < newSize
+ *
+ * @see smGetSize
+ */
+Ret_t smSetSize (MemHandle_t memH, MemSize_t newSize);
+
+
+/**
+ * FUNCTION: smGetSize
+ *
+ * Get size of memory block memH.
+ *
+ * PRE-Condition: memH is a valid handle
+ *
+ * POST-Condition: actSize = memory block size
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * OUT: actSize
+ * Actual size of memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ *
+ * @see smSetSize
+ */
+Ret_t smGetSize (MemHandle_t memH, MemSize_t *actSize);
+
+#endif
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/xltdec.h b/engine/dmlib/dmengine/oma_toolkit/hdr/xltdec.h
new file mode 100644
index 0000000..9fec585
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/xltdec.h
@@ -0,0 +1,240 @@
+/*************************************************************************/
+/* module: Interface for the XLT Decoder component. */
+/* file: XLTDec.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * Interface for the WBXML and XML decoder component.
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#ifndef _XLT_DEC_H
+#define _XLT_DEC_H
+
+#include <smldef.h>
+#include <smldtd.h>
+#include <smlerr.h>
+
+#include "xltdeccom.h"
+#include "xltutilstack.h"
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+/**
+ * The XLT Decoder Interface consists of a single XltDecoder "object"
+ * (struct) and an creation/initialization function. The XltDecoder
+ * object contains all "public" methods and data structures. The first
+ * parameter for any public method is the object of which the method is
+ * called.
+ *
+ * The decoder's public methods/attributes are:
+ *
+ * ATTRIBUTE: charset
+ *
+ * Character set used in the document - this is the MIBEnum value assigned
+ * by the IANA for the character encoding, e.g. "3" for US-ASCII.
+ *
+ * ATTRIBUTE: charsetStr
+ *
+ * Name of the character set, e.g. "US-ASCII" - valid only when charset == 0.
+ *
+ * ATTRIBUTE: finished
+ *
+ * Indicates whether the decoder has reached the end of the buffer during
+ * the last call to xltDecNext.
+ *
+ * ATTRIBUTE: scanner
+ *
+ * Pointer to the scanner status object used by this decoder. The scanner
+ * will be created during the initialization of the decoder as either a XML
+ * or WBXML scanner.
+ *
+ *
+ * ATTRIBUTE: tagstack
+ *
+ * The decoder uses an internal stack to check that for every start tag
+ * there is a corresponding end tag.
+
+ */
+typedef struct XltDecoder_s
+{
+ Long_t charset;
+ String_t charsetStr;
+ Flag_t finished;
+ Boolean_t final;
+ XltDecScannerPtr_t scanner;
+ XltUtilStackPtr_t tagstack;
+#ifdef __USE_DMTND__
+ SmlEncoding_t smlEncoding;
+ SmlEncoding_t tndsEncoding;
+#endif
+
+} XltDecoder_t, *XltDecoderPtr_t;
+
+/**
+ * FUNCTION: xltDecInit
+ *
+ * Initializes a new decoder object. This function allocates memory for the
+ * decoder structure which has to be freed by a call to the decoder's
+ * terminate method when the decoder is not needed anymore. As part of the
+ * initialization the decoder begins decoding the SyncML document to find
+ * the SyncHdr element.
+ *
+ * PRE-Condition:
+ * ppDecoder is NULL
+ * ppBufPos
+ *
+ * POST-Condition:
+ * ppDecoder points to an initialized decoder status object
+ *
+ * IN: enc, the document encoding (WBXML or XML)
+ * pBufEnd, pointer to the end of the buffer which contains
+ * the document
+ *
+ * IN/OUT: ppBufPos, pointer to the current position within the
+ * buffer
+ *
+ * OUT: ppDecoder, the decoder status object
+ * ppSyncHdr, the SyncHdr element
+ *
+ * RETURNS: SML_ERR_OK, if the decoder could be created and the
+ * SmlSyncHdr was found
+ * else error code
+ */
+Ret_t xltDecInit(const SmlEncoding_t enc,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ XltDecoderPtr_t *ppDecoder,
+ SmlSyncHdrPtr_t *ppSyncHdr);
+
+/**
+ * FUNCTION: xltDecNext
+ *
+ * Decodes the next protocol element of the given SyncML document. This
+ * function creates the data structures detailed in the SMLDtd header file.
+ * It is the responsibility of the SyncML client application to free the
+ * allocated memory after it is done processing the data.
+ * This function sets the decoder's finished flag if no protocol element was
+ * found. In that case pPE is set to SML_PE_UNDEF and pContent is NULL.
+ *
+ * PRE-Condition:
+ * pDecoder points to a decoder status object initialized
+ * by xltDecInit
+ *
+ * POST-Condition:
+ * pPE and pContent describe the next valid protocol
+ * element within the SyncML document OR
+ * the finished flag of the decoder status object is set
+ *
+ * IN: pBufEnd, pointer to the end of the buffer
+ *
+ * IN/OUT: pDecoder, the decoder status object
+ * ppBufPos, pointer to the current position within the
+ * buffer before and after the call to xltDecNext
+ *
+ * OUT: pPE, the type of the protocol element (e.g. SML_PE_ADD)
+ * pContent, the data structure for the p.e. cast
+ * (e.g. AddPtr_t) to a void pointer
+ *
+ * RETURN: SML_ERR_OK, if a valid protocol element was found or if
+ * decoder reached the end of the buffer
+ * else error code showing where the parsing failed
+ */
+Ret_t xltDecNext(XltDecoderPtr_t pDecoder,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ SmlProtoElement_t *pPE,
+ VoidPtr_t *pContent);
+
+/**
+ * FUNCTION: xltDecTerminate
+ *
+ * Frees the memory allocated by the decoder.
+ *
+ * PRE-Condition:
+ * pDecoder points to a decoder status object initialized
+ * by xltDecInit
+ *
+ * POST-Condition:
+ * all memory allocated by the decoder status object is
+ * freed
+ *
+ * IN: pDecoder, the decoder
+ *
+ * RETURN: SML_ERR_OK, if the memory could be freed
+ * else error code
+ */
+Ret_t xltDecTerminate(XltDecoderPtr_t pDecoder);
+
+
+Ret_t xltDecReset(XltDecoderPtr_t pDecoder);
+
+/* T.K. moved here from xltdec.c for use in sub-DTD parsing */
+#define IS_START(tok) ((tok)->type == TOK_TAG_START)
+#define IS_END(tok) ((tok)->type == TOK_TAG_END)
+#define IS_EMPTY(tok) ((tok)->type == TOK_TAG_EMPTY)
+#define IS_TAG(tok) (IS_START(tok) || IS_EMPTY(tok) || IS_END(tok))
+#define IS_START_OR_EMPTY(tok) (IS_START(tok) || IS_EMPTY(tok))
+#define IS_CONTENT(tok) ((tok)->type == TOK_CONT)
+/**
+ * nextToken and discardToken are just wrappers around the scanner's
+ * nextTok and pushTok methods that do some error checking.
+ */
+Ret_t nextToken(XltDecoderPtr_t pDecoder);
+Ret_t discardToken(XltDecoderPtr_t pDecoder);
+/* eof xltdec.c stuff */
+
+#ifdef __SML_WBXML__
+/*Added by w21034 begin*/
+Ret_t wbxml2xmlInternal(unsigned char *bufIn, int bufInLen, unsigned char *bufOut, int * bufOutLen);
+/*Added by w21034 end*/
+#endif
+
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/xltenc.h b/engine/dmlib/dmengine/oma_toolkit/hdr/xltenc.h
new file mode 100644
index 0000000..3a3fc3b
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/xltenc.h
@@ -0,0 +1,201 @@
+/*************************************************************************/
+/* module: Encoder header file */
+/* file: xltenc.h */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#ifndef _XLT_ENC_H
+#define _XLT_ENC_H
+
+
+#include <smlerr.h>
+#include <xltenccom.h>
+#include <smldef.h>
+#include <smldtd.h>
+#include <xlttags.h>
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+//Type for storing encoder information
+typedef struct XltEncoder_s
+{
+ SmlEncoding_t enc;
+ SmlVersion_t vers; // %%% luz 2003-07-31: added SyncML version here
+ SmlPcdataExtension_t cur_ext;
+ SmlPcdataExtension_t last_ext;
+ Boolean_t final;
+ XltSpaceEvaluationPtr_t space_evaluation;
+ MemSize_t end_tag_size;
+} XltEncoder_t, *XltEncoderPtr_t;
+
+
+/**
+ * FUNCTION: smlXltEncInit
+ *
+ * Initializes an XML buffer; Creates XML code for the SyncHdr
+ * and appends it to the buffer.
+ * Returns 0 if operation was successful.
+ *
+ * PRE-Condition: no memory should be allocated for ppEncoder (should be NULL)
+ * pHeader has to contain a valid SyncHdr structure
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: enc, the encoding constant (SML_WBXML or SML_XML)
+ * pHeader, the SyncML header structure
+ * pBufEnd, pointer to the end of the buffer to write on
+ * %%% luz:2003-07-31: vers must be the SyncML version (for namespaces and FPI's)
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ * ppEncoder, the encoder object
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_CONTENT_SIZE_LENGTH
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncInit(SmlEncoding_t enc, const SmlSyncHdrPtr_t pHeader, const MemPtr_t pBufEnd, MemPtr_t *ppBufPos, XltEncoderPtr_t *ppEncoder, SmlVersion_t vers);
+
+/**
+ * FUNCTION: smlXltEncAppend
+ *
+ * Generates XML code and appends it to the XML buffer.
+ *
+ * PRE-Condition: pEncoder holds the initialized encoder structure.
+ * the initialization takes place in the xltEncAppend function
+ * pContent has to contain a valid content structure structure
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: pEncoder, the encoder object
+ * pe, the protocol element (PE_ADD, ...)
+ * pBufEnd, pointer to the end of the buffer to write on
+ * pContent, the content to append to the SyncML document
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_CONTENT_SIZE_LENGTH
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+
+Ret_t xltEncAppend(const XltEncoderPtr_t pEncoder,
+ SmlProtoElement_t pe,
+ const MemPtr_t pBufEnd,
+ const VoidPtr_t pContent,
+ MemPtr_t *ppBufPos);
+/**
+ * FUNCTION: smlXltEncTerminate_t pBufEnd, const VoidPtr_t pContent, MemPtr_t *ppBufPos,
+ *
+ * Finalizes the (WB)XML document and returns the size of written bytes to
+ * the workspace module
+ *
+ * PRE-Condition: pEncoder holds the initialized encoder structure.
+ * the initialization takes place in the xltEncAppend function
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: pEncoder, the encoder object
+ * pBufEnd, pointer to the end of the buffer to write on
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_CONTENT_SIZE_LENGTH
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncTerminate(const XltEncoderPtr_t pEncoder, const MemPtr_t pBufEnd, MemPtr_t *ppBufPos);
+Ret_t xltEncReset(XltEncoderPtr_t pEncoder);
+Ret_t xltGenerateTag(XltTagID_t, XltTagType_t, SmlEncoding_t, BufferMgmtPtr_t, SmlPcdataExtension_t);
+Ret_t xltStartEvaluation(XltEncoderPtr_t pEncoder);
+Ret_t xltEndEvaluation(InstanceID_t id, XltEncoderPtr_t pEncoder, MemSize_t *freemem);
+Ret_t xltEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+Ret_t xltBuildExtention(SmlPcdataExtension_t extId, XltRO_t reqOptFlag, VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr);
+Ret_t xltEncPcdata(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+Ret_t subdtdEncWBXML(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/xpt-b64.h b/engine/dmlib/dmengine/oma_toolkit/hdr/xpt-b64.h
new file mode 100644
index 0000000..a5cfbec
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/xpt-b64.h
@@ -0,0 +1,169 @@
+/*************************************************************************/
+/* module: Communication Services, base64 encoding/decoding fns.*/
+/* file: /src/xpt/all/xpt-b64.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * function prototypes and return codes
+ * for base64 encoding/ decoding functions.
+ *
+ */
+
+#ifndef XPT_B64_H
+#define XPT_B64_H
+
+#include "xpttypes.h"
+
+/**
+ * FUNCTION: base64GetSize
+ *
+ * Precalculates the size of an encoded document with the given size
+ *
+ * PRE-Condition:
+ * The function is called to get the size of the document that
+ * will be encoded with the base64Encode() service.
+ *
+ * POST-Condition:
+ *
+ * IN: cbRealDataSize, the size of the non-encoded document.
+ *
+ * RETURN: BufferSize_t, the size of the encoded document that will be
+ * generated using the base64Encode() service.
+ *
+ */
+
+BufferSize_t base64GetSize (BufferSize_t cbRealDataSize);
+
+/**
+ * FUNCTION: base64Encode
+ *
+ * Encodes a chunk of data according to the base64 encoding rules
+ *
+ * PRE-Condition:
+ * A chunk of data os copied to the source data buffer pbData, and the
+ * length of the data chunk is specified in *pcbDataLength;
+ *
+ * POST-Condition:
+ * A block of encoded data is available in the specified target buffer.
+ * The length of the encoded data is returned by the function.
+ *
+ *
+ * IN: pbTarget, pointer to an allocated chunk of memory that receives the
+ * encoded data block.
+ * cbTargetSize, size of the data buffer above.
+ * bLast, flag that indicates if the specified block is the last
+ * part of the document. If the value is 0, the funciton expects
+ * that other blocks will follow, a value of 1 indicates that
+ * the data block that is presented in the input buffer is the
+ * last data block to be encoded.
+ * pbSaveBytes, pointer to a block of at least 3 Bytes. When this function
+ * is invoked the first time, the first byte of this buffer MUST
+ * be set to 0.
+ * IN/OUT:
+ * pbData, pointer to a data block that contains the clear data that
+ * are to be encoded. On return, the remaining piece of the
+ * input data block that could not be encoded is copied to
+ * the memory that pbData points at.
+ * pcbDataLength, pointer to a variable that denotes the length of
+ * the data block that is to be encoded, The function updates
+ * this value with the size of the data block that could not
+ * be processed. If all data were able to be encoded, the
+ * value will be 0.
+ * pcbOffset, pointer to a variable that is internally used by the
+ * function. before the first call of base64encode() for a
+ * certain document is made, the variable that pcbOffset points
+ * at must be set to 0. The variable will be updated by the
+ * function, and should not be modified by the caller.
+ * RETURN: BufferSize_t, the size of the data block that are available in
+ * pbTarget.
+ *
+ */
+
+BufferSize_t base64Encode (DataBuffer_t pbTarget,
+ BufferSize_t cbTargetSize,
+ DataBuffer_t pbData,
+ BufferSize_t *pcbDataLength,
+ BufferSize_t *pcbOffset,
+ unsigned int bLast,
+ unsigned char *pbSavebytes);
+/**
+ * FUNCTION: base64Decode
+ *
+ * Decodes a chunk of data according to the base64 encoding rules
+ *
+ * PRE-Condition:
+ * A chunk of data os copied to the source data buffer pbData, and the
+ * length of the data chunk is specified in *pcbDataLength;
+ *
+ * POST-Condition:
+ * A block of decoded data is available in the specified target buffer.
+ * The length of the decoded data is returned by the function.
+ *
+ *
+ * IN: pbTarget, pointer to an allocated chunk of memory that receives the
+ * decoded data block.
+ * cbTargetSize, size of the data buffer above.
+ * IN/OUT:
+ * pbData, pointer to a data block that contains the clear data that
+ * are to be decoded. On return, the remaining piece of the
+ * input data block that could not be decoded is copied to
+ * the memory that pbData points at.
+ * pcbDataLength, pointer to a variable that denotes the length of
+ * the data block that is to be decoded, The function updates
+ * this value with the size of the data block that could not
+ * be processed. If all data were able to be decoded, the
+ * value will be 0.
+ * RETURN: BufferSize_t, the size of the data block that are available in
+ * pbTarget. If some invalid data were detected in the input
+ * data buffer, or if cbTargetSize is less than 3,
+ * the function returns 0. The caller should treat this as an
+ * error condition.
+ *
+ */
+
+BufferSize_t base64Decode (DataBuffer_t pbTarget,
+ BufferSize_t cbTargetSize,
+ DataBuffer_t pbData,
+ BufferSize_t *pcbDataLength);
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/xptdef.h b/engine/dmlib/dmengine/oma_toolkit/hdr/xptdef.h
new file mode 100644
index 0000000..7d27f47
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/xptdef.h
@@ -0,0 +1,93 @@
+/*************************************************************************/
+/* module: SyncML Communication Protocol include file (Windows) */
+/* file: src/xpt/win/xptdef.h */
+/* target system: win */
+/* target OS: win */
+/* Purpose: Define platform-specific values for public header */
+/* files. */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#ifndef XPTDEF_H
+#define XPTDEF_H
+
+#include <stdlib.h> /* For NULL and size_t */
+
+#define XPT_SECTION
+#define XPT_DATA_SECTION
+
+
+
+/* TK: to improve interoperability and handling we
+ * switched to using .def files instead of compiler
+ * specific per function definitions. As long as we only
+ * use C this is the easiest and cleanes way
+ */
+#define XPT_API
+#define XPT_API_DEF
+#define XPTAPI
+#define XPTEXP1 //__declspec(dllexport)
+#define XPTEXP2
+#define XPTDECLEXP1 //__declspec(dllexport)
+
+/* TK: Old, now obsolete code follows here */
+#ifdef FOOBAZZBUMMBAGGEL
+
+#if defined(__IBMC__) || defined(__IBMCPP__)
+ #define XPTAPI __stdcall
+ #define XPTEXP1
+ #define XPTEXP2 _Export
+ #define XPTDECLEXP1
+#else
+ #define XPTAPI __stdcall
+ #define XPTEXP1 __declspec(dllexport)
+ #define XPTEXP2
+
+// #ifdef BUILDING_XPT
+ #ifdef BUILDING_DLL
+ #define XPTDECLEXP1 XPTEXP1
+ #else
+ #define XPTDECLEXP1 __declspec(dllimport)
+ #endif
+#endif
+#endif // FOBAZZBUMMBAGGEL
+
+#define stricmp _stricmp
+#define memicmp _memicmp
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/xptport.h b/engine/dmlib/dmengine/oma_toolkit/hdr/xptport.h
new file mode 100644
index 0000000..3602be6
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/xptport.h
@@ -0,0 +1,183 @@
+/*************************************************************************/
+/* module: SyncML xpt portability header file */
+/* file: src/xpt/inc/xptport.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Isolate here the differences between ANSI string and memory functions and
+ * Palm string and memory functions. Note the sml tree contains similar
+ * mappings, but we avoid those for two reasons:
+ *
+ * 1. They are all implemented as functions, which makes calling them less
+ * efficient, especially on the Palm. Also, if they are implemented as
+ * functions, then the xpt DLL and the DLLs of all transport
+ * implementations must be linked to the sml DLL, which seems unnecessary.
+ *
+ * 2. Even on the Palm, the libstr.h and libmem.h header files include ANSI C
+ * header files like string.h and stdlib.h. These shouldn't be included
+ * on the Palm, because with some compilers, the introduced typedefs
+ * conflict with typedefs from the Palm SDK, causing compilation errors.
+ *
+ * We start the names of these functions with a different prefix so they are
+ * not confused with functions of the official xpt interface. We use "xpp"
+ * here instead of "xpt".
+ */
+
+#ifndef XPTPORT_H
+#define XPTPORT_H
+
+#include <xptdef.h>
+
+/*
+ * If we neglect some of the return values, most of the functions have simple
+ * mappings.
+ */
+#ifdef __PALM_OS__
+
+ /* Palm mappings */
+
+ #include <StringMgr.h>
+ #include <MemoryMgr.h>
+
+ #define xppStrcpy(target, source) StrCopy(target, source)
+ #define xppStrncpy(target, source, cnt) StrNCopy(target, source, cnt)
+ #define xppStrcat(target, source) StrCat(target, source)
+ #define xppStrncat(target, source, cnt) StrNCat(target, source, cnt)
+ #define xppStrcmp(first, second) StrCompare(first, second)
+ #define xppStrncmp(first, second, cnt) StrNCompare(first, second, cnt)
+ #define xppStrchr(string, c) StrChr(string, c)
+ #define xppStrstr(string, substr) StrStr(string, substr)
+ #define xppStrlen(string) StrLen(string)
+ #define xppAtoi(string) StrAToI(string)
+
+ #define xppMemset(s, c, n) MemSet(s, n, c)
+ #define xppMemcpy(target, source, cnt) MemMove(target, source, cnt)
+ #define xppMemmove(target, source, cnt) MemMove(target, source, cnt)
+ #define xppMemcmp(target, source, cnt) MemCmp(target, source, cnt)
+ #define xppMalloc(size) MemPtrNew(size)
+ XPTDECLEXP1 void * XPTAPI xppRealloc(void *ptr, size_t size) XPT_SECTION;
+ #define xppFree(ptr) MemPtrFree(ptr)
+
+ #define xppStricmp(first, second) StrCaselessCompare(first, second)
+ #define xppMemicmp(first, second, cnt) StrNCaselessCompare(first, second, cnt)
+
+#endif
+#if !defined(__EPOC_OS__) && !defined(__PALM_OS__)
+
+ /* ANSI C mappings */
+
+ #include <string.h>
+ #include <stdlib.h>
+
+ #define xppStrcpy(target, source) strcpy(target, source)
+ #define xppStrncpy(target, source, cnt) strncpy(target, source, cnt)
+ #define xppStrcat(target, source) strcat(target, source)
+ #define xppStrncat(target, source, cnt) strncat(target, source, cnt)
+ #define xppStrcmp(first, second) strcmp(first, second)
+ #define xppStrncmp(first, second, cnt) strncmp(first, second, cnt)
+ #define xppStrchr(string, c) strchr(string, c)
+ #define xppStrstr(string, substr) strstr(string, substr)
+ #define xppStrlen(string) strlen(string)
+ #define xppAtoi(string) atoi(string)
+
+ #define xppMemset(s, c, n) memset(s, c, n)
+ #define xppMemcpy(target, source, cnt) memcpy(target, source, cnt)
+ #define xppMemmove(target, source, cnt) memmove(target, source, cnt)
+ #define xppMemcmp(target, source, cnt) memcmp(target, source, cnt)
+ #define xppMalloc(size) malloc(size)
+ #define xppRealloc(ptr, size) realloc(ptr, size)
+ #define xppFree(ptr) free(ptr)
+
+ /* These aren't ANSI C functions, but they're pretty common */
+
+ #ifdef _WIN32
+ #define xppStricmp(first, second) stricmp(first, second)
+ #endif
+
+ /* Most other systems call it strcasecmp */
+ #ifndef xppStricmp
+ #define xppStricmp(first, second) strcasecmp(first, second)
+ #endif
+
+ #ifdef _WIN32
+ #define xppMemicmp(first, second, cnt) memicmp(first, second, cnt)
+ #endif
+
+ #ifndef xppMemicmp
+ #define xppMemicmp(first, second, cnt) strncasecmp(first, second, cnt)
+ #endif
+
+#endif
+
+#if defined(__EPOC_OS__)
+
+/* EPOC mappings */
+
+#include <string.h>
+#include <stdlib.h>
+
+#define xppStrcpy(target, source) strcpy(target, source)
+#define xppStrncpy(target, source, cnt) strncpy(target, source, cnt)
+#define xppStrcat(target, source) strcat(target, source)
+#define xppStrncat(target, source, cnt) strncat(target, source, cnt)
+#define xppStrcmp(first, second) strcmp(first, second)
+#define xppStrncmp(first, second, cnt) strncmp(first, second, cnt)
+#define xppStrchr(string, c) strchr(string, c)
+#define xppStrstr(string, substr) strstr(string, substr)
+#define xppStrlen(string) strlen(string)
+#define xppAtoi(string) atoi(string)
+
+#define xppMemset(s, c, n) memset(s, c, n)
+#define xppMemcpy(target, source, cnt) memcpy(target, source, cnt)
+#define xppMemmove(target, source, cnt) memmove(target, source, cnt)
+#define xppMemcmp(target, source, cnt) memcmp(target, source, cnt)
+#define xppMalloc(size) malloc(size)
+#define xppRealloc(ptr, size) realloc(ptr, size)
+#define xppFree(ptr) free(ptr)
+
+#define xppStricmp(first, second) strcasecmp(first, second)
+#define xppMemicmp(first, second, cnt) strncasecmp(first, second, cnt)
+
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/hdr/xpttypes.h b/engine/dmlib/dmengine/oma_toolkit/hdr/xpttypes.h
new file mode 100644
index 0000000..bc96619
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/hdr/xpttypes.h
@@ -0,0 +1,80 @@
+/*************************************************************************/
+/* module: Communication Services, standard type definitions */
+/* file: src/xpt/all/xpttypes.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Definition of several basic datatypes.
+ *
+ */
+
+#ifndef XPTTYPES_H
+#define XPTTYPES_H
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+
+#ifndef Bool_t
+typedef int Bool_t;
+#endif
+
+typedef unsigned char *DataBuffer_t;
+typedef DataBuffer_t *DataPtr_t;
+typedef unsigned long BufferSize_t;
+typedef BufferSize_t *BufferSizePtr_t;
+
+typedef const char *CString_t;
+typedef char *Ptr_t;
+typedef char *StringBuffer_t;
+typedef CString_t *StringPtr_t;
+typedef StringBuffer_t *StringBufferPtr_t;
+typedef unsigned short StringLength_t;
+
+
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/define.h b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/define.h
new file mode 100644
index 0000000..5604c67
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/define.h
@@ -0,0 +1,164 @@
+/*************************************************************************/
+/* module: Compiler Flag Definition File */
+/* file: define.h */
+/* target system: win */
+/* target OS: win */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * File for Windows Specific Compiler Flags
+ */
+
+#ifndef _DEFINE_H
+ #define _DEFINE_H
+#define __ANSI_C__
+
+
+/* thread safety (added by luz@synthesis.ch, 2001-10-29) */
+/* Note: moved define of this to target_options.h of every target */
+//#undef __MAKE_THREADSAFE
+
+/* enable Alloc helpers */
+#define __USE_ALLOCFUNCS__
+
+/* do we need WBXML (binary XML) processing ? */
+#define __SML_WBXML__
+/* do we need XML processing ? */
+#define __SML_XML__
+/* are we using a 'light' toolkit ? */
+//#define __SML_LITE__
+/* do we use Sub DTD extensions ? */
+#define __USE_EXTENSIONS__
+/* do we need Metainformation DTD parsing ? */
+#define __USE_METINF__
+/* do we use Device Info DTD ? */
+#define __USE_DEVINF__
+/* do we use DM TND DTD ? */
+#define __USE_DMTND__
+
+/* which of the following optional commands should be included ? */
+
+#define ADD_SEND
+#define ATOMIC_SEND
+#define ATOMIC_RECEIVE
+#define COPY_SEND
+#define COPY_RECEIVE
+#define EXEC_SEND
+#define EXEC_RECEIVE
+#define GET_SEND
+#define MAP_RECEIVE
+#define MAPITEM_RECEIVE
+#define RESULT_RECEIVE
+#define SEARCH_SEND
+#define SEARCH_RECEIVE
+#define SEQUENCE_SEND
+#define SEQUENCE_RECEIVE
+
+
+/* TK: to improve interoperability and handling we
+ * switched to using .def files instead of compiler
+ * specific per function definitions. As long as we only
+ * use C this is the easiest and cleanes way
+ */
+
+#define SML_API
+#define SML_API_DEF
+#define XPT_API
+#define XPT_API_DEF
+
+/* TK: Old, now obsolete code follows here */
+#ifdef USE_OLD_DEFINES
+/*
+When building the DLL code with GNU, you should define BUILDING_DLL so that
+the variables/functions are exported correctly. When using the DLL,
+do NOT define BUILDING_DLL, and then the variables/functions will be
+imported correctly.
+
+You need to be using egcs-1.1.1 or newer.
+
+Building the DLL:
+ - define BUILDING_DLL, which defines SML_API __attribute__((dllexport))
+Building the client code:
+ - DO NOT define BUILDING_DLL, which defines SML_API to be one __attribute__((dllimport))
+*/
+
+
+#if __GNUC__ || __MSVC__ || __MSVCPP__ || _WIN32_WCE
+ /* define this, if you want to link the toolkit static */
+ #if __LINK_TOOLKIT_STATIC__ || __linux__
+ #define SML_API
+ #define SML_API_DEF
+ #define XPT_API
+ #define XPT_API_DEF
+ #else
+ #if BUILDING_DLL
+ #define SML_API __declspec (dllexport)
+ #define SML_API_DEF __declspec (dllexport)
+ #define XPT_API __declspec (dllexport)
+ #define XPT_API_DEF __declspec (dllexport)
+ #else /* Not BUILDING_DLL */
+ #define SML_API __declspec (dllimport)
+ #define SML_API_DEF __declspec (dllimport)
+ #define XPT_API __declspec (dllimport)
+ #define XPT_API_DEF __declspec (dllimport)
+ #endif /* Not BUILDING_DLL */
+ #endif
+#else
+ #if __IBMC__ || __IBMCPP__
+ #define SML_API_DEF __stdcall
+ #define SML_API __stdcall _Export
+ #define XPT_API_DEF __stdcall
+ #define XPT_API __stdcall _Export
+ #else
+ #if WIN32
+ #define SML_API __declspec (dllexport)
+ #define SML_API_DEF __declspec (dllexport)
+ #define XPT_API #error
+ #define XPT_API_DEF #error
+ #else
+ #define SML_API_DEF __stdcall
+ #define SML_API __stdcall
+ #define XPT_API_DEF __stdcall
+ #define XPT_API __stdcall
+ #endif
+#endif
+#endif
+#endif // USE_OLD_DEFINES
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/sml.h b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/sml.h
new file mode 100644
index 0000000..e954f71
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/sml.h
@@ -0,0 +1,346 @@
+/*************************************************************************/
+/* module: External SyncML API */
+/* */
+/* file: sml.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Platform independent definition of the SyncML API functions */
+/* This is the external API exposed to applications using SyncML */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _SML_H
+ #define _SML_H
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+#include <smldef.h>
+#include <smldtd.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+/*************************************************************************
+ * External Functions
+ *************************************************************************/
+
+#if !defined(NOWSM) || !__LINK_TOOLKIT_STATIC__
+
+/**
+ * ============================
+ * General SyncML Functions
+ * ============================
+ **/
+SML_API_DEF Ret_t smlInit(SmlOptionsPtr_t pOptions);
+SML_API_DEF Ret_t smlSetSyncMLOptions (SmlOptionsPtr_t pOptions);
+SML_API_DEF Ret_t smlTerminate(void);
+
+#endif
+
+
+/**
+ * ============================
+ * Workspace Handling Functions
+ * ============================
+ **/
+
+SML_API_DEF Ret_t smlLockReadBuffer(InstanceID_t id, MemPtr_t *pReadPosition, MemSize_t *usedSize);
+SML_API_DEF Ret_t smlUnlockReadBuffer(InstanceID_t id, MemSize_t processedBytes);
+#ifdef NOWSM
+SML_API Ret_t smlSetMaxOutgoingSize(InstanceID_t id, MemSize_t maxOutgoingSize);
+SML_API Ret_t smlSetOutgoingBegin(InstanceID_t id);
+#endif
+SML_API_DEF Ret_t smlLockWriteBuffer(InstanceID_t id, MemPtr_t *pWritePosition, MemSize_t *freeSize);
+SML_API_DEF Ret_t smlUnlockWriteBuffer(InstanceID_t id, MemSize_t writtenBytes);
+
+
+
+/**
+ * ===========================================
+ * Protocol Element Building Functions (for Originator)
+ * ===========================================
+ **/
+
+/* Protocol Management */
+SML_API_DEF Ret_t smlStartMessage(InstanceID_t id, SmlSyncHdrPtr_t pContent);
+SML_API_DEF Ret_t smlStartMessageExt(InstanceID_t id, SmlSyncHdrPtr_t pContent, SmlVersion_t vers); /* %%% added by luz 2003-08-06) */
+SML_API_DEF Ret_t smlEndMessage(InstanceID_t id, Boolean_t final);
+SML_API_DEF Ret_t smlStartSync(InstanceID_t id, SmlSyncPtr_t pContent);
+SML_API_DEF Ret_t smlEndSync(InstanceID_t id);
+
+#ifdef ATOMIC_SEND /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF Ret_t smlStartAtomic(InstanceID_t id, SmlAtomicPtr_t pContent);
+ SML_API_DEF Ret_t smlEndAtomic(InstanceID_t id);
+#endif
+#ifdef SEQUENCE_SEND
+ SML_API_DEF Ret_t smlStartSequence(InstanceID_t id, SmlSequencePtr_t pContent);
+ SML_API_DEF Ret_t smlEndSequence(InstanceID_t id);
+#endif
+
+/* Sync Commands */
+#ifdef ADD_SEND
+ SML_API_DEF Ret_t smlAddCmd(InstanceID_t id, SmlAddPtr_t pContent);
+#endif
+SML_API_DEF Ret_t smlAlertCmd(InstanceID_t id, SmlAlertPtr_t pContent);
+SML_API_DEF Ret_t smlDeleteCmd(InstanceID_t id, SmlDeletePtr_t pContent);
+#ifdef GET_SEND
+ SML_API_DEF Ret_t smlGetCmd(InstanceID_t id, SmlGetPtr_t pContent);
+#endif
+SML_API_DEF Ret_t smlPutCmd(InstanceID_t id, SmlPutPtr_t pContent);
+SML_API_DEF Ret_t smlMapCmd(InstanceID_t id, SmlMapPtr_t pContent);
+SML_API_DEF Ret_t smlResultsCmd(InstanceID_t id, SmlResultsPtr_t pContent);
+SML_API_DEF Ret_t smlStatusCmd(InstanceID_t id, SmlStatusPtr_t pContent);
+SML_API_DEF Ret_t smlReplaceCmd(InstanceID_t id, SmlReplacePtr_t pContent);
+
+#ifdef COPY_SEND /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF Ret_t smlCopyCmd(InstanceID_t id, SmlCopyPtr_t pContent);
+#endif
+#ifdef EXEC_SEND
+ SML_API_DEF Ret_t smlExecCmd(InstanceID_t id, SmlExecPtr_t pContent);
+#endif
+#ifdef SEARCH_SEND
+ SML_API_DEF Ret_t smlSearchCmd(InstanceID_t id, SmlSearchPtr_t pContent);
+#endif
+SML_API_DEF Ret_t smlStartEvaluation(InstanceID_t id);
+SML_API_DEF Ret_t smlEndEvaluation(InstanceID_t id, MemSize_t *freemem);
+
+
+/**
+ * ============================================
+ * Command Dispatching Functions (for Receiver)
+ * ============================================
+ **/
+
+SML_API_DEF Ret_t smlProcessData(InstanceID_t id, SmlProcessMode_t mode);
+
+
+
+/**
+ * ====================================================
+ * Callback Functions to be implemented by the Receiver
+ * ====================================================
+ **/
+
+/* Protocol Management */
+typedef Ret_t (*smlStartMessageFunc) (InstanceID_t id, VoidPtr_t userData, SmlSyncHdrPtr_t pContent);
+typedef Ret_t (*smlEndMessageFunc) (InstanceID_t id, VoidPtr_t userData, Boolean_t final);
+typedef Ret_t (*smlStartSyncFunc) (InstanceID_t id, VoidPtr_t userData, SmlSyncPtr_t pContent);
+typedef Ret_t (*smlEndSyncFunc) (InstanceID_t id, VoidPtr_t userData);
+
+#ifdef ATOMIC_RECEIVE /* these callbacks are NOT included in the Toolkit lite version */
+ typedef Ret_t (*smlStartAtomicFunc) (InstanceID_t id, VoidPtr_t userData, SmlAtomicPtr_t pContent);
+ typedef Ret_t (*smlEndAtomicFunc) (InstanceID_t id, VoidPtr_t userData);
+#endif
+#ifdef SEQUENCE_RECEIVE
+ typedef Ret_t (*smlStartSequenceFunc) (InstanceID_t id, VoidPtr_t userData, SmlSequencePtr_t pContent);
+ typedef Ret_t (*smlEndSequenceFunc) (InstanceID_t id, VoidPtr_t userData);
+#endif
+
+/* Sync Commands */
+typedef Ret_t (*smlAddCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlAddPtr_t pContent);
+typedef Ret_t (*smlAlertCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlAlertPtr_t pContent);
+typedef Ret_t (*smlDeleteCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlDeletePtr_t pContent);
+typedef Ret_t (*smlGetCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlGetPtr_t pContent);
+typedef Ret_t (*smlPutCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlPutPtr_t pContent);
+#ifdef MAP_RECEIVE
+ typedef Ret_t (*smlMapCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlMapPtr_t pContent);
+#endif
+#ifdef RESULT_RECEIVE
+ typedef Ret_t (*smlResultsCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlResultsPtr_t pContent);
+#endif
+typedef Ret_t (*smlStatusCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlStatusPtr_t pContent);
+typedef Ret_t (*smlReplaceCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlReplacePtr_t pContent);
+
+#ifdef COPY_RECEIVE /* these callbacks are NOT included in the Toolkit lite version */
+ typedef Ret_t (*smlCopyCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlCopyPtr_t param);
+#endif
+#ifdef EXEC_RECEIVE
+ typedef Ret_t (*smlExecCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlExecPtr_t pContent);
+#endif
+#ifdef SEARCH_RECEIVE
+ typedef Ret_t (*smlSearchCmdFunc) (InstanceID_t id, VoidPtr_t userData, SmlSearchPtr_t pContent);
+#endif
+
+
+/* Other Callbacks */
+typedef Ret_t (*smlHandleErrorFunc) (InstanceID_t id, VoidPtr_t userData);
+typedef Ret_t (*smlTransmitChunkFunc) (InstanceID_t id, VoidPtr_t userData);
+
+
+
+
+/**
+ * Structure defining references to the applications callback implementations
+ **/
+typedef struct sml_callbacks_s {
+ /* Protocol Management Callbacks */
+ smlStartMessageFunc startMessageFunc;
+ smlEndMessageFunc endMessageFunc;
+ smlStartSyncFunc startSyncFunc;
+ smlEndSyncFunc endSyncFunc;
+#ifdef ATOMIC_RECEIVE /* these callbacks are NOT included in the Toolkit lite version */
+ smlStartAtomicFunc startAtomicFunc;
+ smlEndAtomicFunc endAtomicFunc;
+#endif
+#ifdef SEQUENCE_RECEIVE
+ smlStartSequenceFunc startSequenceFunc;
+ smlEndSequenceFunc endSequenceFunc;
+#endif
+ /* Sync Command callbacks */
+ smlAddCmdFunc addCmdFunc;
+ smlAlertCmdFunc alertCmdFunc;
+ smlDeleteCmdFunc deleteCmdFunc;
+ smlGetCmdFunc getCmdFunc;
+ smlPutCmdFunc putCmdFunc;
+#ifdef MAP_RECEIVE
+ smlMapCmdFunc mapCmdFunc;
+#endif
+#ifdef RESULT_RECEIVE
+ smlResultsCmdFunc resultsCmdFunc;
+#endif
+ smlStatusCmdFunc statusCmdFunc;
+ smlReplaceCmdFunc replaceCmdFunc;
+#ifdef COPY_RECEIVE /* these callbacks are NOT included in the Toolkit lite version */
+ smlCopyCmdFunc copyCmdFunc;
+#endif
+#ifdef EXEC_RECEIVE
+ smlExecCmdFunc execCmdFunc;
+#endif
+#ifdef SEARCH_RECEIVE
+ smlSearchCmdFunc searchCmdFunc;
+#endif
+ /* Other Callbacks */
+ smlHandleErrorFunc handleErrorFunc;
+ smlTransmitChunkFunc transmitChunkFunc;
+ //smlPrintFunc printFunc;
+} *SmlCallbacksPtr_t, SmlCallbacks_t;
+
+
+
+/**
+ * ============================
+ * Instance Management Functions
+ * ============================
+ **/
+
+SML_API_DEF Ret_t smlInitInstance(SmlCallbacksPtr_t pCallbacks, SmlInstanceOptionsPtr_t pOptions, VoidPtr_t pUserData, InstanceID_t *pId);
+SML_API_DEF Ret_t smlTerminateInstance (InstanceID_t id);
+SML_API_DEF Ret_t smlSetCallbacks (InstanceID_t id, SmlCallbacksPtr_t pCallbacks);
+SML_API_DEF Ret_t smlSetUserData (InstanceID_t id, VoidPtr_t pUserData);
+// added by luz %%%:
+SML_API Ret_t smlGetUserData(InstanceID_t id, VoidPtr_t *ppUserData);
+SML_API Ret_t smlGetEncoding(InstanceID_t id, SmlEncoding_t *pEncoding);
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF Ret_t smlSetEncoding (InstanceID_t id, SmlEncoding_t encoding);
+#endif
+
+
+
+/**
+ * ===================================
+ * Some Helper Functions and Utilities
+ * ===================================
+ **/
+
+SML_API_DEF Ret_t smlFreeProtoElement(VoidPtr_t pProtoElement);
+SML_API_DEF void smlFreePcdata(SmlPcdataPtr_t pPcdata);
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF String_t smlPcdata2String( SmlPcdataPtr_t pcdata );
+ SML_API_DEF SmlPcdataPtr_t smlString2Pcdata( String_t str );
+ SML_API_DEF SmlPcdataPtr_t smlPcdataDup(SmlPcdataPtr_t pcdata);
+ SML_API_DEF MemSize_t smlGetFreeBuffer(InstanceID_t id);
+#endif
+
+#ifndef __PALM_OS__ /* these API calls are NOT exported in the Palm OS version */
+SML_API_DEF void *smlLibMemset(void *pObject, int value, MemSize_t count);
+SML_API_DEF void *smlLibMemcpy(void *pTarget, const void *pSource, MemSize_t count);
+SML_API_DEF int smlLibMemcmp(const void *pTarget, const void *pSource, MemSize_t count);
+/*SML_API_DEF void *smlLibMalloc(MemSize_t size);*/
+ #define smlLibMalloc DmAllocMem
+#include "dmMemory.h"
+
+SML_API_DEF void smlLibFree(void *pObject);
+SML_API_DEF MemSize_t smlLibMemsize(const void *pObject);
+
+SML_API_DEF String_t smlLibStrdup (const char *constStringP);
+SML_API_DEF String_t smlLibStrcpy(const char *pTarget, const char *pSource);
+SML_API_DEF int smlLibStrcmp(const char *pTarget, const char *pSource);
+SML_API_DEF int smlLibStrlen(const char *pString);
+SML_API_DEF String_t smlLibStrncpy(const char *pTarget, const char *pSource, int count);
+SML_API_DEF int smlLibStrncmp(const char *pTarget, const char *pSource, int count);
+SML_API_DEF String_t smlLibStrcat(const char *pTarget, const char *pSource);
+SML_API_DEF String_t smlLibStrchr(const char *pString, char character);
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ SML_API_DEF void smlLibPrint(const char *text, ...);
+ SML_API_DEF void *smlLibMemmove(void *pTarget, const void *pSource, MemSize_t count);
+ SML_API_DEF void *smlLibRealloc(void *pObject, MemSize_t size);
+ SML_API_DEF String_t smlLibStrncat(const char *pTarget, const char *pSource, int count);
+ SML_API_DEF String_t smlLibStrstr(const char *pString, const char *pSubString);
+#endif
+#endif
+
+//#define MOT_OTK_DEBUG
+#ifdef MOT_OTK_DEBUG
+#include <stdarg.h>
+
+#define KCDBG(EXP, args...) __kcdbg__(">>>>> (%s:%s:%d)" #EXP "%s", __FILE__, __FUNCTION__, __LINE__, ##args, "\n")
+void __kcdbg__(char *fmt, ...)
+{
+ FILE *fp = fopen("/data/data/tmp/dm_otk.log", "a+");
+ va_list ap;
+
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ vfprintf(fp, fmt, ap);
+ va_end(ap);
+
+ fclose(fp);
+}
+#else
+#define KCDBG(EXP, args...)
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldef.h b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldef.h
new file mode 100644
index 0000000..8ae056b
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldef.h
@@ -0,0 +1,232 @@
+/*************************************************************************/
+/* module: Type definitions for SyncML */
+/* */
+/* file: SMLDef.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Platform independent header with syncML types and definitions */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+#ifndef _SML_DEF_H
+ #define _SML_DEF_H
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+
+/**
+ * include target/compiler specific defines/options/settings
+ **/
+#include <define.h>
+
+
+/**
+ * ===================================
+ * Common all-purpose type definitions
+ * ===================================
+ **/
+
+
+
+/**
+ * ==================================
+ * Basic data types
+ * ==================================
+ **/
+typedef short Short_t; // short integer, 16 Bytes
+typedef long Long_t; // long integer, 32 Bytes
+typedef char* String_t; // String pointer,
+typedef unsigned char Byte_t; // a single byte
+typedef Byte_t Boolean_t; // a boolean
+#ifndef NULL // a NULL pointer
+ #define NULL (void*) 0
+#endif
+
+
+typedef Short_t Ret_t; // Return Type of API Commands
+typedef Long_t Length_t; // System dependent string length
+typedef Short_t MemHandle_t; // Memory object Handle
+typedef unsigned char *MemPtr_t; // Memory object Pointer
+typedef void *VoidPtr_t; // Void Pointer
+typedef Long_t MemSize_t; // System dependent memory object size
+typedef unsigned char MemByte_t; // Memory element
+typedef unsigned int Flag_t; // A generic flag type. This type is used to
+ // declare variables in structures wherever
+ // flags are used.
+
+
+
+
+/**
+ * ==================================
+ * Definitions used in the SyncML API
+ * ==================================
+ **/
+
+
+/**
+ * Application callback function displaying output strings to the user
+ **/
+typedef void (*smlPrintFunc) (String_t outputString);
+
+
+/**
+ * structure describing the options and setting of this syncml process
+ **/
+typedef struct sml_options_s {
+ smlPrintFunc defaultPrintFunc; // default application callback for displaying strings,
+ MemSize_t maxWorkspaceAvailMem; // size which all workspaces in total MUST not exceed
+} *SmlOptionsPtr_t, SmlOptions_t;
+
+
+/**
+ * Reference of an instance
+ **/
+#ifdef NOWSM
+typedef void *InstanceID_t; // without wsm, instance ID is direct pointer to instance info
+#else
+typedef MemHandle_t InstanceID_t; // Handle, used as a unique ID of
+#endif // an synchronization instance
+
+
+/**
+ * Type of used encoding
+ **/
+typedef enum {
+ SML_UNDEF = 0,
+ SML_WBXML,
+ SML_XML
+} SmlEncoding_t;
+
+
+/** %%% added luz 2003-07-31:
+ * SyncML version
+ **/
+typedef enum {
+ SML_VERS_UNDEF = 0,
+ SML_VERS_1_0,
+ SML_VERS_1_1,
+ SML_VERS_1_2,
+ SML_NUM_VERS
+} SmlVersion_t;
+
+/**
+ * structure describing the options of an instance,
+ **/
+typedef struct sml_instance_options_s {
+ SmlEncoding_t encoding; // Used encoding type,
+ MemSize_t workspaceSize; // size of the workspace to allocate (instance buffer size if NOWSM defined)
+ #ifndef NOWSM
+ String_t workspaceName; // name of the workspace
+ #else
+ MemSize_t maxOutgoingSize; // max size of outgoing message, 0 if no restriction
+ #endif
+} *SmlInstanceOptionsPtr_t, SmlInstanceOptions_t;
+
+
+/**
+ * Processing modes
+ **/
+typedef enum {
+ SML_DO_NOTHING = 0,
+ SML_FIRST_COMMAND,
+ SML_NEXT_COMMAND,
+ SML_NEXT_MESSAGE,
+ SML_ALL_COMMANDS
+} SmlProcessMode_t;
+
+
+/**
+ * Requested buffer pointer position
+ **/
+typedef enum {
+ SML_FIRST_DATA_ITEM = 0,
+ SML_FIRST_FREE_ITEM
+} SmlBufPtrPos_t;
+
+
+
+/**
+ * SyncML Protocol Management and Command Elements (PE)
+ **/
+typedef enum {
+ SML_PE_UNDEF = 0,
+ SML_PE_ERROR,
+ SML_PE_ADD,
+ SML_PE_ALERT,
+ SML_PE_ATOMIC_START,
+ SML_PE_ATOMIC_END,
+ SML_PE_COPY,
+ SML_PE_DELETE,
+ SML_PE_EXEC,
+ SML_PE_GET,
+ SML_PE_MAP,
+ SML_PE_PUT,
+ SML_PE_RESULTS,
+ SML_PE_SEARCH,
+ SML_PE_SEQUENCE_START,
+ SML_PE_SEQUENCE_END,
+ SML_PE_STATUS,
+ SML_PE_SYNC_START,
+ SML_PE_SYNC_END,
+ SML_PE_REPLACE,
+ SML_PE_HEADER,
+ SML_PE_PUT_GET,
+ SML_PE_CMD_GROUP,
+ SML_PE_GENERIC,
+ SML_PE_FINAL
+} SmlProtoElement_t;
+
+typedef struct
+{
+ Byte_t token;
+ String_t escape_str;
+} ESCAPE_CHAR_TABLE_T;
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldevinfdtd.h b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldevinfdtd.h
new file mode 100644
index 0000000..49a0ae4
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldevinfdtd.h
@@ -0,0 +1,171 @@
+/*****************************************************************************/
+/* module: SyncML Device Information DTD specific type definitions */
+/* */
+/* file: smldevinfdtd.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definition of structures representing DevInf DTD elements */
+/* This file reflects DevInf as specified in the document */
+/* http://www.syncml.org/docs/syncml_devinf_v10_20001207.pdf */
+/*****************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+#ifndef _SML_DEVINFDTD_H
+#define _SML_DEVINFDTD_H
+
+/* process only if we really use DevInf DTD */
+#ifdef __USE_DEVINF__
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+
+#include <smldef.h>
+#include <smldtd.h>
+
+
+typedef struct sml_devinf_ext_s {
+ SmlPcdataPtr_t xnam;
+ SmlPcdataListPtr_t xval; /* optional */
+} *SmlDevInfExtPtr_t, SmlDevInfExt_t;
+
+typedef struct sml_devinf_extlist_s {
+ SmlDevInfExtPtr_t data;
+ struct sml_devinf_extlist_s *next;
+} *SmlDevInfExtListPtr_t, SmlDevInfExtList_t;
+
+typedef struct sml_devinf_synccap_s {
+ SmlPcdataListPtr_t synctype;
+} *SmlDevInfSyncCapPtr_t, SmlDevInfSyncCap_t;
+
+
+typedef struct sml_devinf_ctdata_s {
+ SmlPcdataPtr_t name;
+ SmlPcdataPtr_t dname; /* optional, display name */
+
+ SmlPcdataListPtr_t valenum;
+ SmlPcdataPtr_t datatype;
+ SmlPcdataPtr_t size;
+} *SmlDevInfCTDataPtr_t, SmlDevInfCTData_t;
+
+typedef struct sml_devinf_ctdatalist_s {
+ SmlDevInfCTDataPtr_t data;
+ struct sml_devinf_ctdatalist_s *next;
+} *SmlDevInfCTDataListPtr_t, SmlDevInfCTDataList_t;
+
+typedef struct sml_devinf_ctdataprop_s {
+ SmlDevInfCTDataPtr_t prop;
+ SmlDevInfCTDataListPtr_t param;
+} *SmlDevInfCTDataPropPtr_t, SmlDevInfCTDataProp_t;
+
+typedef struct sml_devinf_ctdataproplist_s {
+ SmlDevInfCTDataPropPtr_t data;
+ struct sml_devinf_ctdataproplist_s *next;
+} *SmlDevInfCTDataPropListPtr_t, SmlDevInfCTDataPropList_t;
+
+typedef struct sml_devinf_ctcap_s {
+ SmlPcdataPtr_t cttype;
+ SmlDevInfCTDataPropListPtr_t prop;
+} *SmlDevInfCTCapPtr_t, SmlDevInfCTCap_t;
+
+typedef struct sml_devinf_ctcaplist_s {
+ SmlDevInfCTCapPtr_t data;
+ struct sml_devinf_ctcaplist_s *next;
+} *SmlDevInfCtcapListPtr_t, SmlDevInfCtcapList_t;
+
+
+typedef struct sml_devinf_dsmem_s {
+ Flag_t flags; /* %%% luz:2003-04-28, mad flag, was PCData (completely wrong) */
+ SmlPcdataPtr_t maxmem; /* optional */
+ SmlPcdataPtr_t maxid; /* optional */
+} *SmlDevInfDSMemPtr_t, SmlDevInfDSMem_t;
+
+
+typedef struct sml_devinf_xmit_s {
+ SmlPcdataPtr_t cttype;
+ SmlPcdataPtr_t verct;
+} *SmlDevInfXmitPtr_t, SmlDevInfXmit_t;
+
+typedef struct sml_devinf_xmitlist_s {
+ SmlDevInfXmitPtr_t data;
+ struct sml_devinf_xmitlist_s *next;
+} *SmlDevInfXmitListPtr_t, SmlDevInfXmitList_t;
+
+typedef struct sml_devinf_datastore_s {
+ SmlPcdataPtr_t sourceref;
+ SmlPcdataPtr_t displayname; /* optional */
+ SmlPcdataPtr_t maxguidsize; /* optional */
+ SmlDevInfXmitPtr_t rxpref;
+ SmlDevInfXmitListPtr_t rx; /* optional */
+ SmlDevInfXmitPtr_t txpref;
+ SmlDevInfXmitListPtr_t tx; /* optional */
+ SmlDevInfDSMemPtr_t dsmem; /* optional */
+ SmlDevInfSyncCapPtr_t synccap;
+} *SmlDevInfDatastorePtr_t, SmlDevInfDatastore_t;
+
+
+typedef struct sml_devinf_datastorelist_s {
+ SmlDevInfDatastorePtr_t data;
+ struct sml_devinf_datastorelist_s *next;
+} *SmlDevInfDatastoreListPtr_t, SmlDevInfDatastoreList_t;
+
+typedef struct sml_devinf_devinf_s {
+ SmlPcdataPtr_t verdtd;
+ SmlPcdataPtr_t man; /* optional */
+ SmlPcdataPtr_t mod; /* optional */
+ SmlPcdataPtr_t oem; /* optional */
+ SmlPcdataPtr_t fwv; /* optional */
+ SmlPcdataPtr_t swv; /* optional */
+ SmlPcdataPtr_t hwv; /* optional */
+ SmlPcdataPtr_t devid;
+ SmlPcdataPtr_t devtyp;
+ SmlDevInfDatastoreListPtr_t datastore;
+ SmlDevInfCtcapListPtr_t ctcap;
+ SmlDevInfExtListPtr_t ext;
+ /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+ Flag_t flags;
+} *SmlDevInfDevInfPtr_t, SmlDevInfDevInf_t;
+
+#endif // __USE_DEVINF__
+#endif //_SML_DEVINFDTD_H_
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldmtnddtd.h b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldmtnddtd.h
new file mode 100644
index 0000000..8d98412
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldmtnddtd.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*--------------------------------------------------------------------------------------------------
+
+ Header Name: smldmtnddtd.h
+
+ General Description: OMA DM TND DTD specific type definitions
+
+--------------------------------------------------------------------------------------------------*/
+
+#ifndef _SML_DM_TND_DTD_H
+#define _SML_DM_TND_DTD_H
+
+/* process only if we really use DM TND DTD */
+#ifdef __USE_DMTND__
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+
+#include <smldef.h>
+#include <smldtd.h>
+
+typedef struct sml_dmtnd_format_s {
+ SmlPcdataPtr_t value; /* optional */
+} *SmlDmTndFormatPtr_t, SmlDmTndFormat_t;
+
+typedef struct sml_dmtnd_type_s {
+ SmlPcdataPtr_t mime; /* optional */
+ SmlPcdataPtr_t ddfname; /* optional */
+} *SmlDmTndTypePtr_t, SmlDmTndType_t;
+
+typedef struct sml_dmtnd_rtprops_s {
+ SmlPcdataPtr_t acl; /* optional */
+ SmlDmTndFormatPtr_t format; /* optional */
+ SmlPcdataPtr_t name; /* optional */
+ SmlPcdataPtr_t size; /* optional */
+ SmlPcdataPtr_t title; /* optional */
+ SmlPcdataPtr_t tstamp; /* optional */
+ SmlDmTndTypePtr_t type;
+ SmlPcdataPtr_t verno; /* optional */
+} *SmlDmTndRTPropsPtr_t, SmlDmTndRTProps_t;
+
+typedef struct sml_dmtnd_dfelement_s {
+ SmlPcdataPtr_t value; /* optional */
+} *SmlDmTndDFElementPtr_t, SmlDmTndDFElement_t;
+
+typedef struct sml_dmtnd_dfprops_s {
+ SmlDmTndDFElementPtr_t accesstype;
+ SmlPcdataPtr_t defaultvalue; /* optional */
+ SmlPcdataPtr_t description; /* optional */
+ SmlDmTndFormatPtr_t dfformat;
+ SmlDmTndDFElementPtr_t occurrence; /* optional */
+ SmlDmTndDFElementPtr_t scope; /* optional */
+ SmlPcdataPtr_t dftitle; /* optional */
+ SmlDmTndTypePtr_t dftype;
+ SmlDmTndDFElementPtr_t casesense;
+} *SmlDmTndDFPropsPtr_t, SmlDmTndDFProps_t;
+
+typedef struct sml_dmtnd_node_list_s *SmlDmTndNodeListPtr_t;
+
+typedef struct sml_dmtnd_node_s {
+ SmlPcdataPtr_t nodename;
+ SmlPcdataPtr_t path; /* optional */
+ SmlDmTndRTPropsPtr_t rtprops; /* optional */
+ SmlDmTndDFPropsPtr_t dfprops; /* optional */
+ SmlPcdataPtr_t value; /* optional */
+ SmlDmTndNodeListPtr_t nodelist; /* optional */
+} *SmlDmTndNodePtr_t, SmlDmTndNode_t;
+
+typedef struct sml_dmtnd_node_list_s {
+ SmlDmTndNodePtr_t node;
+ struct sml_dmtnd_node_list_s *next;
+} SmlDmTndNodeList_t;
+
+typedef struct sml_dmtnd_s {
+ SmlPcdataPtr_t verdtd;
+ SmlPcdataPtr_t man; /* optional */
+ SmlPcdataPtr_t mod; /* optional */
+ SmlDmTndNodeListPtr_t nodelist; /* optional */
+} *SmlDmTndPtr_t, SmlDmTnd_t;
+
+#endif // __USE_DMTND__
+#endif /* _SML_DM_TND_DTD_H */
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldtd.h b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldtd.h
new file mode 100644
index 0000000..5c82024
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smldtd.h
@@ -0,0 +1,421 @@
+/*************************************************************************/
+/* module: SyncML DTD specific type definitions */
+/* */
+/* file: smldtd.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definition of structures representing DTD elements */
+/*************************************************************************/
+
+
+/********************************************************************/
+/* NOTE: */
+/* These definitions are based on the DTD dated from July, 7th, 00 */
+/********************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _SML_DTD_H
+ #define _SML_DTD_H
+
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+
+#include <smldef.h>
+
+
+
+
+/**
+ * ===========================
+ * Common used SyncML Elements
+ * ===========================
+ */
+
+
+
+/**
+ * PCDATA - types of synchronization data which SyncML supports
+ **/
+typedef enum {
+ SML_PCDATA_UNDEFINED = 0,
+ SML_PCDATA_STRING, // String type
+ SML_PCDATA_OPAQUE, // Opaque type
+ SML_PCDATA_EXTENSION, // Extention type - specified by PcdataExtension_t
+ SML_PCDATA_CDATA // XML CDATA type
+} SmlPcdataType_t;
+
+
+/**
+ * PCDATA - types of extensions for PCData elements
+ */
+typedef enum {
+ SML_EXT_UNDEFINED = 0,
+ SML_EXT_METINF, // Meta Information
+ SML_EXT_DEVINF, // Device Information
+ SML_EXT_DMTND, // DM TNM DDF
+ SML_EXT_LAST // last codepage, needed for loops!
+} SmlPcdataExtension_t;
+
+
+
+/**
+ * PCDATA - into this structure SyncML wraps the synchronization data itself
+ **/
+typedef struct sml_pcdata_s {
+ SmlPcdataType_t contentType; // The type of data which a PCDATA structure contains
+ SmlPcdataExtension_t extension; // PCData Extension type
+ MemSize_t length; // length of the data in this PCDATA structure
+ VoidPtr_t content; // Pointer to the data itself
+} *SmlPcdataPtr_t, SmlPcdata_t;
+
+/* generic list of PCData elements */
+typedef struct sml_pcdata_list_s {
+ SmlPcdataPtr_t data;
+ struct sml_pcdata_list_s *next;
+} *SmlPcdataListPtr_t, SmlPcdataList_t;
+
+/**
+ * Various flags which are actually declared and (EMPTY) elements in
+ * SyncML. This assumes at least a 16-bit architecture for the
+ * underlying OS. We need to review this if that is deemed a problem.
+ **/
+#define SmlArchive_f 0x8000 // Delete flags
+#define SmlSftDel_f 0x4000 // Delete flags
+#define SmlESNData_f 0x2000 // ESN data flags
+#define SmlESNBinary_f 0x1000 // ESN binary data flags
+#define SmlMoreData_f 0x0400 // MoreData flag
+#define SmlNoResults_f 0x0200 // No Results flag
+#define SmlNoResp_f 0x0100 // No Response flag
+#define SmlFinal_f 0x0001 // Header flag
+#ifdef __USE_METINF__
+#define SmlMetInfSharedMem_f 0x0002 // MetInf Shared Memory Flag
+#endif
+#ifdef __USE_DEVINF__
+#define SmlDevInfSharedMem_f 0x0004 // DevInf Shared Memory Flag
+/* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+#define SmlDevInfUTC_f 0x0001 // DevInf utc Flag
+#define SmlDevInfNOfM_f 0x0002 // DevInf support n of m Flag
+#define SmlDevInfLargeObject_f 0x0008 // DevInf support large object Flag
+#endif
+
+
+/**
+ * Chal
+ **/
+typedef struct sml_chal_s {
+ SmlPcdataPtr_t meta;
+} *SmlChalPtr_t, SmlChal_t;
+
+/**
+ * Credentials
+ **/
+typedef struct sml_cred_s {
+ SmlPcdataPtr_t meta; // opt.
+ SmlPcdataPtr_t data;
+} *SmlCredPtr_t, SmlCred_t;
+
+
+
+/**
+ * Source or target location
+ **/
+typedef struct sml_source_or_target_s {
+ SmlPcdataPtr_t locURI;
+ SmlPcdataPtr_t locName; // opt.
+} *SmlSourcePtr_t, SmlSource_t,
+ *SmlTargetPtr_t, SmlTarget_t;
+
+typedef struct sml_source_list_s {
+ SmlSourcePtr_t source;
+ struct sml_source_list_s *next;
+} *SmlSourceListPtr_t, SmlSourceList_t;
+
+
+
+/**
+ * ==============================
+ * SyncML Message Header Elements
+ * ==============================
+ **/
+
+
+/**
+ * SyncML header
+ * As the header is needed for each SyncML message, it's also the parameter
+ * of the startMessage call.
+ **/
+typedef struct sml_sync_hdr_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t version;
+ SmlPcdataPtr_t proto;
+ SmlPcdataPtr_t sessionID;
+ SmlPcdataPtr_t msgID;
+ Flag_t flags; // NoResp
+ SmlTargetPtr_t target;
+ SmlSourcePtr_t source;
+ SmlPcdataPtr_t respURI; // opt.
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+} *SmlSyncHdrPtr_t, SmlSyncHdr_t;
+
+// SyncML Body and SyncML container is not needed, as there are function calls
+// (smlStartMessage(), smlEndMessage()) that let the framework know when to start and end
+// the SyncML document
+
+
+
+/**
+ * =========================
+ * Data description elements
+ * =========================
+ **/
+
+
+/**
+ * Data in SyncML is encapsulated in an "item" element.
+ **/
+typedef struct sml_item_s {
+ SmlTargetPtr_t target; // opt.
+ SmlSourcePtr_t source; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlPcdataPtr_t data; // opt.
+ Flag_t flags; // opt. for MoreData
+} *SmlItemPtr_t, SmlItem_t;
+
+typedef struct sml_item_list_s {
+ SmlItemPtr_t item;
+ struct sml_item_list_s *next;
+} *SmlItemListPtr_t, SmlItemList_t;
+
+
+/**
+ * ==============================================
+ * SyncML Commands (Protocol Management Elements)
+ * ==============================================
+ **/
+
+
+
+/**
+ * Generic commands:
+ * Add, Copy, Replace, Delete
+ **/
+typedef struct sml_generic_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp, Archive (Delete), SftDel (Delete)
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlItemListPtr_t itemList;
+} *SmlAddPtr_t, SmlAdd_t,
+ *SmlCopyPtr_t, SmlCopy_t,
+ *SmlReplacePtr_t, SmlReplace_t,
+ *SmlDeletePtr_t, SmlDelete_t,
+ *SmlGenericCmdPtr_t, SmlGenericCmd_t;
+
+/**
+ * Alert command:
+ **/
+typedef struct sml_alert_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t data; // opt.
+ SmlItemListPtr_t itemList;
+ SmlPcdataPtr_t correlator; // opt.
+} *SmlAlertPtr_t, SmlAlert_t;
+
+
+/**
+ * Atomic/Sequence command:
+ **/
+typedef struct sml_atomic_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlPcdataPtr_t meta; // opt.
+} *SmlAtomicPtr_t, SmlAtomic_t,
+ *SmlSequencePtr_t, SmlSequence_t;
+
+
+/**
+ * Sync command:
+ **/
+typedef struct sml_sync_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlCredPtr_t cred; // opt.
+ SmlTargetPtr_t target; // opt.
+ SmlSourcePtr_t source; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlPcdataPtr_t noc; // opt. (SyncML 1.1)
+} *SmlSyncPtr_t, SmlSync_t;
+
+
+/**
+ * Exec command:
+ **/
+typedef struct sml_exec_s {
+ SmlProtoElement_t elementType;
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlItemPtr_t item;
+ SmlPcdataPtr_t correlator; // opt.
+
+} *SmlExecPtr_t, SmlExec_t;
+
+
+/**
+ * Get and Put command:
+ **/
+typedef struct sml_get_put_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp
+ SmlPcdataPtr_t lang; // opt.
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlItemListPtr_t itemList;
+} *SmlPutPtr_t, SmlPut_t,
+ *SmlGetPtr_t, SmlGet_t;
+
+
+/**
+ * Map command:
+ **/
+typedef struct sml_map_item_s {
+ SmlTargetPtr_t target;
+ SmlSourcePtr_t source;
+} *SmlMapItemPtr_t, SmlMapItem_t;
+
+typedef struct sml_map_item_list_s {
+ SmlMapItemPtr_t mapItem;
+ struct sml_map_item_list_s *next;
+} *SmlMapItemListPtr_t, SmlMapItemList_t;
+
+typedef struct sml_map_s {
+ SmlProtoElement_t elementType; // InternalToolkit Field
+ SmlPcdataPtr_t cmdID;
+ SmlTargetPtr_t target;
+ SmlSourcePtr_t source;
+ SmlCredPtr_t cred; // opt.
+ SmlPcdataPtr_t meta; // opt.
+ SmlMapItemListPtr_t mapItemList;
+} *SmlMapPtr_t, SmlMap_t;
+
+
+
+/**
+ * Results command:
+ **/
+typedef struct sml_results_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ SmlPcdataPtr_t msgRef; // opt.
+ SmlPcdataPtr_t cmdRef;
+ SmlPcdataPtr_t meta; // opt.
+ SmlPcdataPtr_t targetRef; // opt.
+ SmlPcdataPtr_t sourceRef; // opt.
+ SmlItemListPtr_t itemList;
+} *SmlResultsPtr_t, SmlResults_t;
+
+
+/**
+ * Search command:
+ **/
+typedef struct sml_search_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ Flag_t flags; // NoResp, NoResults
+ SmlCredPtr_t cred; // opt.
+ SmlTargetPtr_t target; // opt.
+ SmlSourceListPtr_t sourceList;
+ SmlPcdataPtr_t lang; // opt.
+ SmlPcdataPtr_t meta;
+ SmlPcdataPtr_t data;
+} *SmlSearchPtr_t, SmlSearch_t;
+
+
+/**
+ * Status command:
+ **/
+
+typedef struct sml_target_ref_list_s {
+ SmlPcdataPtr_t targetRef;
+ struct sml_target_ref_list_s *next;
+} *SmlTargetRefListPtr_t, SmlTargetRefList_t;
+
+typedef struct sml_source_ref_list_s {
+ SmlPcdataPtr_t sourceRef;
+ struct sml_source_ref_list_s *next;
+} *SmlSourceRefListPtr_t, SmlSourceRefList_t;
+
+typedef struct sml_status_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+ SmlPcdataPtr_t cmdID;
+ SmlPcdataPtr_t msgRef; // Opt.
+ SmlPcdataPtr_t cmdRef;
+ SmlPcdataPtr_t cmd;
+ SmlTargetRefListPtr_t targetRefList; // opt.
+ SmlSourceRefListPtr_t sourceRefList; // opt.
+ SmlCredPtr_t cred; // opt.
+ SmlChalPtr_t chal; // opt.
+ SmlPcdataPtr_t data;
+ SmlItemListPtr_t itemList; // opt.
+} *SmlStatusPtr_t, SmlStatus_t;
+
+
+/**
+ * a little helper for typecasting
+ **/
+typedef struct sml_unknown_proto_element_s {
+ SmlProtoElement_t elementType; // Internal Toolkit Field
+} *SmlUnknownProtoElementPtr_t, SmlUnknownProtoElement_t;
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smlerr.h b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smlerr.h
new file mode 100644
index 0000000..57f5eac
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smlerr.h
@@ -0,0 +1,136 @@
+/*************************************************************************/
+/* module: ErrorLibrary */
+/* */
+/* file: smlerr.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definition of the used Error Codes */
+/*************************************************************************/
+
+
+
+ /*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _SML_ERR_H
+ #define _SML_ERR_H
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+
+/**
+ * No error, success code
+ **/
+#define SML_ERR_OK 0x00 // OK
+
+
+
+
+/**
+ * SyncML Common Error Codes
+ **/
+
+// general errors
+#define SML_ERR_UNSPECIFIC 0x10 // unspecific error
+#define SML_ERR_NOT_ENOUGH_SPACE 0x11 // not enough memory to perform this operation
+#define SML_ERR_WRONG_USAGE 0x13 // function was called in wrong context
+
+// wrong parameters
+#define SML_ERR_WRONG_PARAM 0x20 // wrong parameter
+#define SML_ERR_INVALID_SIZE 0x21 // param has an invalid size
+#define SML_ERR_INVALID_HANDLE 0x22 // if handle is invalid/unknown
+#define SML_ERR_INVALID_OPTIONS 0x23 // unkown or unallowed options
+
+
+/**
+ * SyncML Mgr Error Codes
+ **/
+#define SML_ERR_A_MGR_ERROR 0x1001 // a template
+#define SML_ERR_MGR_INVALID_INSTANCE_INFO 0x1002 // a invalid Instance Info structure is used
+#define SML_ERR_COMMAND_NOT_HANDLED 0x1003 // no callback function is available to handle this command
+#define SML_ERR_ALREADY_INITIALIZED 0x1004 // Mgr allready initialized
+
+
+/**
+ * SyncML Xlt Error Codes
+ **/
+#define SML_ERR_XLT_MISSING_CONT 0x2001 // required field content missing
+#define SML_ERR_XLT_BUF_ERR 0x2002 // Buffer too small
+#define SML_ERR_XLT_INVAL_PCDATA_TYPE 0x2003 // Invalid (WBXML) Element Type (STR_I etc.)
+#define SML_ERR_XLT_INVAL_LIST_TYPE 0x2004 // Invalid List Type (COL_LIST etc.)
+#define SML_ERR_XLT_INVAL_TAG_TYPE 0x2005 // Invalid Tag Type (TT_BEG etc.)
+#define SML_ERR_XLT_ENC_UNK 0x2007 // Unknown Encoding (WBXML, XML)
+#define SML_ERR_XLT_INVAL_PROTO_ELEM 0x2008 // Invalid Protocol Element (ADD, Delete, ...)
+#define SML_ERR_MISSING_LIST_ELEM 0x2009 // Missing Content of List Elements
+#define SML_ERR_XLT_INCOMP_WBXML_VERS 0x200A // Incompatible WBXML Content Format Version
+#define SML_ERR_XLT_INVAL_SYNCML_DOC 0x200B // Document does not conform to SyncML DTD
+#define SML_ERR_XLT_INVAL_PCDATA 0x200C // Invalid PCData elem (e.g. not encoded as OPAQUE data)
+#define SML_ERR_XLT_TOKENIZER_ERROR 0x200D // Unspecified tokenizer error
+#define SML_ERR_XLT_INVAL_WBXML_DOC 0x200E // Document does not conform to WBXML specification
+#define SML_ERR_XLT_WBXML_UKN_TOK 0x200F // Document contains unknown WBXML token
+#define SML_ERR_XLT_MISSING_END_TAG 0x2010 // Non-empty start tag without matching end tag
+#define SML_ERR_XLT_INVALID_CODEPAGE 0x2011 // WBXML document uses unspecified code page
+#define SML_ERR_XLT_END_OF_BUFFER 0x2012 // End of buffer reached
+#define SML_ERR_XLT_INVAL_XML_DOC 0x2013 // Document does not conform to XML 1.0 specification
+#define SML_ERR_XLT_XML_UKN_TAG 0x2014 // Document contains unknown XML tag
+#define SML_ERR_XLT_INVAL_PUB_IDENT 0x2015 // Invalid Public Identifier
+#define SML_ERR_XLT_INVAL_EXT 0x2016 // Invalid Codepage Extension
+#define SML_ERR_XLT_NO_MATCHING_CODEPAGE 0x2017 // No matching Codepage could be found
+#define SML_ERR_XLT_INVAL_INPUT_DATA 0x2018 // Data missing in input structure
+
+
+/**
+ * SyncML Wsm Error Codes
+ **/
+#define SML_ERR_WSM_BUF_TABLE_FULL 0x3001 // no more empty entries in buffer table available
+
+/**
+ * SyncML Util Error Codes
+ **/
+#define SML_ERR_A_UTI_UNKNOWN_PROTO_ELEMENT 0x7001
+
+
+#endif
+
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smlmetinfdtd.h b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smlmetinfdtd.h
new file mode 100644
index 0000000..b899086
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/ghdr/smlmetinfdtd.h
@@ -0,0 +1,98 @@
+/*****************************************************************************/
+/* module: SyncML Meta Information DTD specific type definitions */
+/* */
+/* file: smlmetinfdtd.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definition of structures representing MetInf DTD elements */
+/*****************************************************************************/
+
+
+/**************************************************************************/
+/* NOTE: */
+/* These definitions are based on the MetInf DTD dated from Aug, 29th, 00 */
+/**************************************************************************/
+
+
+
+ /*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#ifndef _SML_METINFDTD_H
+#define _SML_METINFDTD_H
+
+/* process only if we really use MetInf DTD */
+#ifdef __USE_METINF__
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+
+#include <smldef.h>
+#include <smldtd.h>
+
+
+typedef struct sml_metinf_anchor_s {
+ SmlPcdataPtr_t last; /* optional */
+ SmlPcdataPtr_t next;
+} *SmlMetInfAnchorPtr_t, SmlMetInfAnchor_t;
+
+typedef struct sml_metinf_mem_s {
+ SmlPcdataPtr_t shared; /* optional */
+ SmlPcdataPtr_t free;
+ SmlPcdataPtr_t freeid;
+} *SmlMetInfMemPtr_t, SmlMetInfMem_t;
+
+typedef struct sml_metinf_metinf_s {
+ SmlPcdataPtr_t format; /* opt. */
+ SmlPcdataPtr_t type; /* opt. */
+ SmlPcdataPtr_t mark; /* opt. */
+ SmlPcdataPtr_t size; /* opt. */
+ SmlPcdataPtr_t nextnonce; /* opt. */
+ SmlPcdataPtr_t version;
+ SmlPcdataPtr_t maxmsgsize; /* optional */
+ /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+ SmlPcdataPtr_t maxobjsize; /* optional */
+ SmlMetInfMemPtr_t mem; /* optional */
+ SmlPcdataListPtr_t emi; /* optional */
+ SmlMetInfAnchorPtr_t anchor; /* opt. */
+} *SmlMetInfMetInfPtr_t, SmlMetInfMetInf_t;
+
+#endif /* __USE_METINF__ */
+#endif /* _SML_METINFDTD_H */
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/liblock.h b/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/liblock.h
new file mode 100644
index 0000000..3632c12
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/liblock.h
@@ -0,0 +1,16 @@
+/* thread-locking library, RTK addition by luz@synthesis.ch */
+
+#ifndef LIBLOCK_H
+#define LIBLOCK_H
+
+#include <define.h>
+
+
+ /* just NOP */
+#define TOOLKITLOCK_INIT(m)
+#define TOOLKITLOCK_FREE(m)
+#define LOCKTOOLKIT(m)
+#define RELEASETOOLKIT(m)
+
+#endif
+/* eof */
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libmem.h b/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libmem.h
new file mode 100644
index 0000000..2fe8960
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libmem.h
@@ -0,0 +1,99 @@
+/*************************************************************************/
+/* module: Library for Memory Functions */
+/* */
+/* file: libmem.h */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Header for the implementation of common memory handling functions */
+/*************************************************************************/
+
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+#ifndef _LIB_MEM_H
+#define _LIB_MEM_H
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+#include <stdlib.h>
+#include <smldef.h>
+#ifdef __ANSI_C__
+#include <string.h>
+#endif
+#ifdef __PALM_OS__
+#include <MemoryMgr.h>
+#endif
+
+#include "dmMemory.h"
+
+/*************************************************************************
+ * External Functions for all Toolkit versions
+ *************************************************************************/
+
+
+#ifdef __PALM_OS__ /* we use #define to reduce heap usage */
+ void *smlLibRealloc (VoidPtr_t objectP, MemSize_t constSize);
+ void smlLibFree (void* objectP);
+ #define smlLibMemset(pObject,value,count) ((void)MemSet((VoidPtr_t)pObject,(MemSize_t)count,(int)value))
+ #define smlLibMemcpy(pTarget,pSource,count) (MemMove(pTarget,(VoidPtr_t)pSource,count) ? pTarget : pTarget)
+ #define smlLibMemmove(pTarget,pSource,count) (MemMove(pTarget,(VoidPtr_t)pSource,(MemSize_t)count) ? pTarget : pTarget)
+ #define smlLibMemcmp(pTarget,pSource,count) (MemCmp((VoidPtr_t)pTarget,(VoidPtr_t)pSource,(MemSize_t)count))
+ #define smlLibMalloc(size) ((VoidPtr_t)MemPtrNew((MemSize_t)size))
+ #define smlLibMemsize(pObject) ((MemSize_t)MemPtrSize((VoidPtr_t)pObject))
+#else
+ SML_API_DEF void *smlLibRealloc(void *pObject, MemSize_t size);
+ SML_API_DEF void smlLibFree(void *pObject);
+ SML_API_DEF void *smlLibMemset(void *pObject, int value, MemSize_t count);
+ SML_API_DEF void *smlLibMemcpy(void *pTarget, const void *pSource, MemSize_t count);
+ SML_API_DEF void *smlLibMemmove(void *pTarget, const void *pSource, MemSize_t count);
+ SML_API_DEF int smlLibMemcmp(const void *pTarget, const void *pSource, MemSize_t count);
+ //SML_API_DEF void *smlLibMalloc(MemSize_t size);
+ #define smlLibMalloc DmAllocMem
+#endif
+
+
+#endif
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libstr.h b/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libstr.h
new file mode 100644
index 0000000..1be201d
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libstr.h
@@ -0,0 +1,111 @@
+/*************************************************************************/
+/* module: Library for String Functions */
+/* */
+/* file: libstr.h */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Header for the implementation of common string-handling functions */
+/*************************************************************************/
+
+
+
+ /*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef __LIB_STR_H
+#define __LIB_STR_H
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+#include "smldef.h"
+#include "libmem.h"
+#ifdef __ANSI_C__
+#include <string.h>
+#endif
+#ifdef __PALM_OS__
+#include <StringMgr.h>
+#endif
+
+
+/*************************************************************************
+ * External Functions for all Toolkit versions
+ *************************************************************************/
+
+
+#ifdef __PALM_OS__ /* we use #define to reduce heap usage */
+ String_t smlLibStrdup (const char* constStringP);
+ #define smlLibStrcpy(pTarget,pSource) (char*)StrCopy((char*)pTarget,(char*)pSource)
+ #define smlLibStrncpy(pTarget,pSource,count) (char*)StrNCopy((char*)pTarget,(char*)pSource,count)
+ #define smlLibStrcat(pTarget,pSource) (char*)StrCat((char*)pTarget,(char*)pSource)
+ #define smlLibStrcmp(pTarget,pSource) StrCompare((char*)pTarget,(char*)pSource)
+ #define smlLibStrncmp(pTarget,pSource,count) StrNCompare((char*)pTarget,(char*)pSource,count)
+ #define smlLibStrchr(pString,character) (char*)StrChr((String_t)pString,character)
+ #define smlLibStrlen(pString) StrLen((char*)pString)
+#else /* we use functions, to make the library exportable */
+ SML_API_DEF String_t smlLibStrdup (const char *constStringP);
+ SML_API_DEF String_t smlLibStrcpy(const char *pTarget, const char *pSource);
+ SML_API_DEF String_t smlLibStrncpy(const char *pTarget, const char *pSource, int count);
+ SML_API_DEF String_t smlLibStrcat(const char *pTarget, const char *pSource);
+ SML_API_DEF int smlLibStrcmp(const char *pTarget, const char *pSource);
+ SML_API_DEF int smlLibStrncmp(const char *pTarget, const char *pSource, int count);
+ SML_API_DEF String_t smlLibStrchr(const char *pString, char character);
+ SML_API_DEF int smlLibStrlen(const char *pString);
+#endif
+
+
+
+
+/*************************************************************************
+ * Additional External Functions for Full Sized Toolkit Only
+ *************************************************************************/
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+#ifdef __PALM_OS__ /* we use define to reduce heap usage */
+ #define smlLibStrncat(pTarget,pSource,count) (char*)StrNCat((char*)pTarget,(char*)pSource,count)
+ #define smlLibStrstr(pString,pSubstring) (char*)StrStr((char*)pString,(char*)pSubstring)
+#else /* we use functions, to make the library exportable */
+ SML_API_DEF String_t smlLibStrncat(const char *pTarget, const char *pSource, int count);
+ SML_API_DEF String_t smlLibStrstr(const char *pString, const char *pSubString);
+#endif
+#endif
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libutil.h b/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libutil.h
new file mode 100644
index 0000000..bef0579
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/lib/hdr/libutil.h
@@ -0,0 +1,88 @@
+/*************************************************************************/
+/* module: Library for utility Functions */
+/* */
+/* file: libutil.c */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Some I/O Utilities */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _LIB_UTIL_H
+#define _LIB_UTIL_H
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <smldef.h>
+
+
+#ifdef __ANSI_C__
+ #include <stdarg.h>
+#endif
+
+#ifdef __PALM_OS__
+ #ifndef _MSL_CSTDARG
+ #include <unix_stdarg.h> // only if we don't use MSL
+ #endif
+#endif
+
+#ifdef __EPOC_OS__
+ #include <stdarg.h>
+#endif
+
+
+/*************************************************************************
+ * External Functions
+ *************************************************************************/
+
+/* IO functions */
+SML_API_DEF void smlLibPrint(const char *text, ...);
+SML_API_DEF void smlLibVprintf(const char *format, va_list va);
+
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libmem.c b/engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libmem.c
new file mode 100644
index 0000000..2cd9f6a
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libmem.c
@@ -0,0 +1,175 @@
+/*************************************************************************/
+/* module: Library for Memory Functions */
+/* */
+/* file: libmem.c */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Header for the implementation of common memory handling functions */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <smldef.h>
+#include "dmMemory.h"
+#include "libmem.h"
+#ifdef __PALM_OS__
+#include "MemoryMgr.h"
+#endif
+
+#ifdef MEMORY_PROFILING
+ // %%% luz 2002-10-02
+ #include "profiling.h"
+#endif
+
+/*************************************************************************
+ * External Functions for all TOOLKIT Versions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlLibFree
+ *
+ * Deallocates the memory of object "pObject", which has been allocated
+ * previously.
+ * If "pObject" is a NULL pointer nothing happens.
+ * If "pObject" is a pointer to memory which has not been allocated
+ * previouly, the behaviour is undefined.
+ * The contents of the deallocated memory object is destroyed.
+ */
+SML_API void smlLibFree(void *pObject)
+{
+ if (! pObject) return;
+ #ifdef __PALM_OS__
+ MemPtrFree(pObject);
+ #else
+ DmFreeMem(pObject);
+ #endif
+}
+
+
+/**
+ * FUNCTION: smlLibRealloc
+ *
+ * Changes size of preallocated space for memory object "pObject"
+ * to the new size specified by "constSize".
+ *
+ * If the new size is larger than the old size, the old contents
+ * is not changed. Additionally space is added at the the end of
+ * "pObject". The new allocated space is not initialized
+ * to any special value.
+ * If the new size is smaller than the old size, the unused space
+ * is discarded.
+ *
+ * If "pObject" is a NULL pointer, this function behaves just like
+ * smlLibMalloc().
+ * If "pObject" does not point to a previously allocated memory area,
+ * the behavior is undefined.
+ * If "constSize" is 0, a NULL pointer is returned and the space
+ * which "pObject" points to is freed up.
+ *
+ * Returns a pointer to the first byte of the resized object.
+ * If no new memory could be allocated, a NULL Pointer is returned
+ * without changing the memory object "pObject" (Nothing happens to the content).
+ *
+ * IN/OUT void *pObject, memory object, which size should be changed
+ * IN: MemSize_t constSize new size the memory object shall use
+ * RETURN: void* Pointer to memory object, which size has been
+ * be changed
+ * NULL, if not successfull or
+ * if constSize==0
+ */
+SML_API void *smlLibRealloc(void *pObject, MemSize_t constSize)
+{
+#ifdef __PALM_OS__
+ VoidPtr_t _new_object;
+ MemSize_t _old_size;
+
+ // It's a malloc!
+ if (pObject == NULL)
+ return smlLibMalloc(constSize);
+
+ _old_size = MemPtrSize(pObject);
+ if (constSize <= _old_size) {
+ // make it smaller
+ MemPtrResize(pObject, constSize);
+ _new_object = pObject;
+ } else {
+ // maker it larger (we need to allocate new memory somewhere else)
+ _new_object = smlLibMalloc(constSize);
+ if (_new_object != NULL) {
+ smlLibMemmove(_new_object, pObject, _old_size);
+ smlLibFree(pObject);
+ }
+ }
+
+ return _new_object;
+#else
+ return DmReallocMem(pObject, (UINT32)constSize);
+
+#endif
+}
+
+
+#ifndef __PALM_OS__
+/* If not Palm OS we use the Standard ANSI C functions */
+SML_API void *smlLibMemset(void *pObject, int value, MemSize_t count){
+ return memset(pObject, value, count);
+}
+SML_API void *smlLibMemcpy(void *pTarget, const void *pSource, MemSize_t count){
+ return memcpy(pTarget, pSource, count);
+}
+SML_API void *smlLibMemmove(void *pTarget, const void *pSource, MemSize_t count){
+ return memmove(pTarget, pSource, count);
+}
+SML_API int smlLibMemcmp(const void *pTarget, const void *pSource, MemSize_t count){
+ return memcmp(pTarget, pSource, count);
+}
+/*SML_API void *smlLibMalloc(MemSize_t size) {
+ return (void *)DmAllocMem((UINT32)size);
+
+}*/
+#endif
+
+
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libstr.c b/engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libstr.c
new file mode 100644
index 0000000..319dd0b
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libstr.c
@@ -0,0 +1,138 @@
+/*************************************************************************/
+/* module: Library for String Functions */
+/* */
+/* file: libstr.c */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* implementation of common string-handling functions */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <smldef.h>
+#include "libstr.h"
+#include "libmem.h"
+#ifdef __ANSI_C__
+#include <string.h>
+#endif
+#ifdef __PALM_OS__
+#include <StringMgr.h>
+#endif
+
+
+
+/*************************************************************************
+ * External Functions for all TOOLKIT Versions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlLibStrdup
+ *
+ * Duplicates the String "constStringP".
+ * Returns a pointer to the new copy of "constStringP".
+ *
+ * IN: String_t constStringP string, which is duplicated
+ * RETURN: String_t pointer to the new copy,
+ * null, if no copy could be allocated
+ */
+SML_API String_t smlLibStrdup (const char *constStringP)
+{
+ String_t _new_str;
+
+ // allocate memory for new copy
+ _new_str = (String_t)smlLibMalloc(smlLibStrlen(constStringP) + 1);
+
+ // Copy the string into the new memory
+ if (_new_str != NULL)
+ smlLibStrcpy(_new_str, constStringP);
+
+ return _new_str;
+}
+
+
+#ifndef __PALM_OS__
+/* If not Palm OS we use the Standard ANSI C functions */
+SML_API String_t smlLibStrcpy(const char *pTarget, const char *pSource) {
+ return strcpy((char *)pTarget, (char *)pSource);
+}
+SML_API String_t smlLibStrncpy(const char *pTarget, const char *pSource, int count){
+ return strncpy((char *)pTarget, (char *)pSource, count);
+}
+SML_API String_t smlLibStrcat(const char *pTarget, const char *pSource){
+ return strcat((char *)pTarget, (char *)pSource);
+}
+SML_API int smlLibStrcmp(const char *pTarget, const char *pSource){
+ return strcmp((char *)pTarget, (char *)pSource);
+}
+SML_API int smlLibStrncmp(const char *pTarget, const char *pSource, int count){
+ return strncmp((char *)pTarget, (char *)pSource, count);
+}
+SML_API String_t smlLibStrchr(const char *pString, char character){
+ return strchr((char *)pString, character);
+}
+SML_API int smlLibStrlen(const char *pString){
+ return strlen((char *)pString);
+}
+
+
+#endif
+
+
+
+/*************************************************************************
+ * Additional External Functions for Full Size TOOLKIT ONLY
+ *************************************************************************/
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+#ifndef __PALM_OS__ /* we use #define to reduce heap usage */
+SML_API String_t smlLibStrncat(const char *pTarget, const char *pSource, int count){
+ return strncat((char *)pTarget, (char *)pSource, count);
+}
+SML_API String_t smlLibStrstr(const char *pString, const char *pSubString){
+ return strstr((char *)pString, (char *)pSubString);
+}
+#endif
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libutil.c b/engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libutil.c
new file mode 100644
index 0000000..da29a14
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/lib/src/libutil.c
@@ -0,0 +1,184 @@
+/*************************************************************************/
+/* module: Library for IO Functions */
+/* */
+/* file: libio.c */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Utility I/O functions */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#ifndef NOWSM
+// Note: in NOWSM case, these routines must be implemented in the
+// calling main code.
+
+#include <smldef.h>
+#include <smlerr.h>
+
+#ifdef __ANSI_C__
+#include <stdarg.h>
+#include <stdio.h>
+#endif
+
+#ifdef __PALM_OS__
+#include <Pilot.h>
+#include <unix_stdarg.h>
+#endif
+
+#ifdef __EPOC_OS__
+#include <stdarg.h>
+#include <stdio.h>
+#endif
+
+#include "define.h"
+#include "libmem.h"
+#include "mgr.h"
+#include "libutil.h"
+
+
+// size of output buffer
+#define BUFFERSIZE 128
+
+
+/* Used external functions */
+extern SyncMLInfoPtr_t mgrGetSyncMLAnchor();
+
+
+/*************************************************************************
+ * External Functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlLibPrint
+ *
+ * Assembles a formatted textstring out of a list of argument. This string is
+ * passed to a callback function, which is implementated by the application
+ * for output to the user
+ *
+ * IN: A printf like format text string with multiple
+ * arguments to be formatted as specified
+ * Supported are:
+ * %d, %i, %u, %x, %s, %c
+ * +, -, <space>, *, <number>, h, l, L
+ *
+ * RETURN: - - -
+ */
+
+
+SML_API void smlLibPrint(const char *text, ...)
+{
+ char pBuffer[BUFFERSIZE];
+ va_list args;
+ SyncMLInfoPtr_t pSyncMLInfo;
+
+ if ((pSyncMLInfo = mgrGetSyncMLAnchor()) != NULL) {
+
+ pBuffer[0] = '\0';
+
+ va_start(args, text);
+
+ // assemble the text string out of the single arguments
+ #ifdef __ANSI_C__
+ vsprintf(pBuffer, text, args);
+ #endif
+
+ #ifdef __PALM_OS__
+ StrVPrintF(pBuffer, text, args);
+ #endif
+
+ #ifdef __EPOC_OS__
+ vsprintf(pBuffer, text, args);
+ #endif
+
+ va_end(args);
+
+ // use the application callback function,
+ // which implements the output.
+ if (pSyncMLInfo &&
+ pSyncMLInfo->syncmlOptions &&
+ pSyncMLInfo->syncmlOptions->defaultPrintFunc)
+ ((smlPrintFunc)(pSyncMLInfo->syncmlOptions->defaultPrintFunc))(pBuffer);
+ }
+}
+
+SML_API void smlLibVprintf(const char *format, va_list args)
+{
+ char pBuffer[BUFFERSIZE];
+ SyncMLInfoPtr_t pSyncMLInfo;
+
+ if ((pSyncMLInfo = mgrGetSyncMLAnchor()) != NULL) {
+
+ pBuffer[0] = '\0';
+
+ // assemble the text string out of the single arguments
+ #ifdef __ANSI_C__
+ vsprintf(pBuffer, format, args);
+ #endif
+
+ #ifdef __PALM_OS__
+ StrVPrintF(pBuffer, format, args);
+ #endif
+
+ #ifdef __EPOC_OS__
+ vsprintf(pBuffer, format, args);
+ #endif
+
+ // use the application callback function,
+ // which implements the output.
+ if (pSyncMLInfo &&
+ pSyncMLInfo->syncmlOptions &&
+ pSyncMLInfo->syncmlOptions->defaultPrintFunc)
+ ((smlPrintFunc)(pSyncMLInfo->syncmlOptions->defaultPrintFunc))(pBuffer);
+ }
+}
+
+#endif // !defined(NOWSM)
+
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/mgr/hdr/mgr.h b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/hdr/mgr.h
new file mode 100644
index 0000000..cd2186f
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/hdr/mgr.h
@@ -0,0 +1,187 @@
+/*************************************************************************/
+/* module: SyncML internal API of the MGR module */
+/* */
+/* file: mgr.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definitions for internal use within the SyncML implementation */
+/*************************************************************************/
+
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _MGR_H
+ #define _MGR_H
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <smldef.h>
+#include <sml.h>
+#include "wsm.h"
+#include <xlttagtbl.h>
+
+
+/**
+ * ========================================
+ * Definitions used for Instance Management
+ * ========================================
+ **/
+
+
+
+/**
+ * Current instance status
+ **/
+typedef enum {
+ MGR_IDLE, // instance is idle (available for usage by applications)
+ MGR_USED, // instance is in use, but currently inactive
+ MGR_RECEIVE, // actively used for receiving (locked by application)
+ MGR_SEND, // actively used for sending (locked by application)
+ MGR_ENCODING, // actively used for encoding (locked by SyncML)
+ MGR_DECODING // actively used for decoding (locked by SyncML)
+} InstanceStatus_t;
+
+
+
+/**
+ * structure describing the current status of an instance,
+ **/
+typedef struct instance_info_s {
+ #ifndef NOWSM
+ InstanceID_t id; // unique ID of the instance
+ MemPtr_t workspaceHandle; // handle to the first position of the assigned workspace memory
+ #else
+ // buffer pointers for NOWSM simplified case
+ MemPtr_t instanceBuffer; // pointer to instance work buffer
+ MemSize_t instanceBufSiz; // size of currently allocated buffer
+ Byte_t readLocked; // set when buffer is locked for read
+ Byte_t writeLocked; // set when buffer is locked for read
+ MemPtr_t readPointer; // read pointer
+ MemPtr_t writePointer; // write pointer
+ MemPtr_t outgoingMsgStart; // set whenever a smlStartMessage is issued, NULL when invalid
+ MemSize_t maxOutgoingSize; // if<>0, smlXXXCmd will not modify the buffer when there's not enough room
+ #endif
+ InstanceStatus_t status; // current internal state of instance
+ SmlCallbacksPtr_t callbacks; // Defined callback refererences for this Instance
+ SmlInstanceOptionsPtr_t instanceOptions; // Defined options for this Instance (e.g. encoding type)
+ VoidPtr_t userData; // Pointer to a structure, which is passed to the invoked callback functions
+ #ifndef NOWSM
+ VoidPtr_t workspaceState; // Pointer to a structure defining the current workspace status
+ #endif
+ VoidPtr_t encoderState; // Pointer to a structure defining the current encoder status
+ VoidPtr_t decoderState; // Pointer to a structure defining the current decoder status
+ #ifndef NOWSM
+ struct instance_info_s* nextInfo; // Pointer to next Instance Info in a list
+ #else
+ smlPrintFunc defaultPrintFunc; // default application callback for displaying strings (is a global in original version)
+ #endif
+} *InstanceInfoPtr_t, InstanceInfo_t;
+
+
+/* Pointers to store the global Tag tables */
+typedef struct tokeninfo_s {
+ TagPtr_t SyncML;
+ TagPtr_t MetInf;
+ TagPtr_t DevInf;
+ TagPtr_t DmTnd;
+} *TokenInfoPtr_t, TokenInfo_t;
+
+
+#ifndef NOWSM
+// Note, version without WSM has NO globals at all
+/**
+ * structure describing the current status of the global syncml module
+ * (holds all global variables within SyncML)
+ **/
+typedef struct syncml_info_s {
+ InstanceInfoPtr_t instanceListAnchor;// Anchor of the global list of known SyncML instances
+ SmlOptionsPtr_t syncmlOptions; // Options valid for this SyncML Process
+ WsmGlobalsPtr_t wsmGlobals; // Workspace global variables
+ TokenInfoPtr_t tokTbl;
+} *SyncMLInfoPtr_t, SyncMLInfo_t;
+#endif
+
+
+
+#ifndef NOWSM
+
+/*************************************************************************
+ * External Function Declarations
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: mgrGetSyncMLInfo
+ * Retrieves a pointer to the structure holding all global informations within SyncML
+ *
+ * RETURN: SyncMLInfoPtr_t
+ * Pointer to the pGlobalAnchor
+ */
+SyncMLInfoPtr_t mgrGetSyncMLAnchor(void);
+
+
+/**
+ * FUNCTION: mgrGetInstanceListAnchor
+ * Retrieves a pointer to the list holding all instance informations
+ *
+ * RETURN: InstanceInfoPtr_t
+ * Pointer to the pInstanceListAnchor
+ */
+InstanceInfoPtr_t mgrGetInstanceListAnchor(void);
+
+
+/**
+ * FUNCTION: mgrSetInstanceListAnchor
+ * Set the pointer to the list holding all instance informations
+ *
+ * IN: InstanceInfoPtr_t
+ * Pointer to the pInstanceListAnchor
+ */
+void mgrSetInstanceListAnchor(InstanceInfoPtr_t newListAnchor);
+
+#endif // !defined(NOWSM)
+
+
+#endif // ifndef _MGR_H
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/mgr/hdr/mgrutil.h b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/hdr/mgrutil.h
new file mode 100644
index 0000000..2502be1
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/hdr/mgrutil.h
@@ -0,0 +1,186 @@
+/*************************************************************************/
+/* module: SyncML API for freeing SyncML C structures */
+/* */
+/* file: mgrutil.h */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Definitions for internal use within the SyncML implementation */
+/*************************************************************************/
+
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+#ifndef _MGR_UTIL_H
+ #define _MGR_UTIL_H
+
+
+/* Prototypes of exported SyncML API functions */
+SML_API Ret_t smlFreeProtoElement(VoidPtr_t pProtoElement);
+SML_API void smlFreePcdata(SmlPcdataPtr_t pPcdata);
+SML_API void smlFreePcdataList(SmlPcdataListPtr_t list);
+
+SML_API void smlFreeSyncHdr(SmlSyncHdrPtr_t pSyncHdr);
+SML_API void smlFreeSync(SmlSyncPtr_t pSync);
+SML_API void smlFreeGeneric(SmlGenericCmdPtr_t pGenericCmd);
+SML_API void smlFreeAlert(SmlAlertPtr_t pAlert);
+SML_API void smlFreeAtomic(SmlAtomicPtr_t pAtomic);
+#if (defined EXEC_SEND || defined EXEC_RECEIVE)
+ SML_API void smlFreeExec(SmlExecPtr_t pExec);
+#endif
+SML_API void smlFreeGetPut(SmlPutPtr_t pGetPut);
+SML_API void smlFreeMap(SmlMapPtr_t pMap);
+SML_API void smlFreeResults(SmlResultsPtr_t pResults);
+#if (defined SEARCH_SEND || defined SEARCH_RECEIVE)
+ SML_API void smlFreeSearch(SmlSearchPtr_t pSearch);
+#endif
+SML_API void smlFreeStatus(SmlStatusPtr_t pStatus);
+SML_API void smlFreeCredPtr(SmlCredPtr_t pCred);
+SML_API void smlFreeChalPtr(SmlChalPtr_t pChal);
+SML_API void smlFreeSourceTargetPtr(SmlSourcePtr_t pSourceTarget);
+SML_API void smlFreeSourceList(SmlSourceListPtr_t pSourceList);
+SML_API void smlFreeSourceRefList(SmlSourceRefListPtr_t pSourceRefList);
+SML_API void smlFreeTargetRefList(SmlTargetRefListPtr_t pTargetRefList);
+SML_API void smlFreeItemPtr(SmlItemPtr_t pItem);
+SML_API void smlFreeItemList(SmlItemListPtr_t pItemList);
+SML_API void smlFreeMapItemPtr(SmlMapItemPtr_t pMapItem);
+SML_API void smlFreeMapItemList(SmlMapItemListPtr_t pMapItemList);
+
+#ifdef __USE_METINF__
+SML_API void smlFreeMetinfAnchor(SmlMetInfAnchorPtr_t data);
+SML_API void smlFreeMetinfMem(SmlMetInfMemPtr_t data);
+SML_API void smlFreeMetinfMetinf(SmlMetInfMetInfPtr_t data);
+#endif
+#ifdef __USE_DEVINF__
+SML_API void smlFreeDevInfDatastore(SmlDevInfDatastorePtr_t data);
+SML_API void smlFreeDevInfDatastoreList(SmlDevInfDatastoreListPtr_t data);
+SML_API void smlFreeDevInfXmitList(SmlDevInfXmitListPtr_t data);
+SML_API void smlFreeDevInfXmit(SmlDevInfXmitPtr_t data);
+SML_API void smlFreeDevInfDSMem(SmlDevInfDSMemPtr_t data);
+SML_API void smlFreeDevInfSynccap(SmlDevInfSyncCapPtr_t data);
+SML_API void smlFreeDevInfExt(SmlDevInfExtPtr_t data);
+SML_API void smlFreeDevInfExtList(SmlDevInfExtListPtr_t data);
+SML_API void smlFreeDevInfCTData(SmlDevInfCTDataPtr_t data);
+SML_API void smlFreeDevInfCTDataList(SmlDevInfCTDataListPtr_t data);
+SML_API void smlFreeDevInfCTDataProp(SmlDevInfCTDataPropPtr_t data);
+SML_API void smlFreeDevInfCTDataPropList(SmlDevInfCTDataPropListPtr_t data);
+SML_API void smlFreeDevInfCTCap(SmlDevInfCTCapPtr_t data);
+SML_API void smlFreeDevInfCtcapList(SmlDevInfCtcapListPtr_t data);
+SML_API void smlFreeDevInfDevInf(SmlDevInfDevInfPtr_t data);
+#endif
+
+#ifdef __USE_DMTND__
+SML_API void smlFreeDmTnd(SmlDmTndPtr_t data);
+#endif
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+SML_API String_t smlPcdata2String( SmlPcdataPtr_t pcdata );
+SML_API SmlPcdataPtr_t smlString2Pcdata( String_t str );
+SML_API SmlPcdataPtr_t smlPcdataDup(SmlPcdataPtr_t pcdata);
+SML_API MemSize_t smlGetFreeBuffer(InstanceID_t id);
+#endif
+
+#ifdef __USE_ALLOCFUNCS__
+SML_API SmlPcdataPtr_t smlAllocPcdata();
+SML_API SmlPcdataListPtr_t smlAllocPcdataList();
+SML_API SmlChalPtr_t smlAllocChal();
+SML_API SmlCredPtr_t smlAllocCred();
+SML_API SmlSourcePtr_t smlAllocSource();
+SML_API SmlTargetPtr_t smlAllocTarget();
+SML_API SmlSourceListPtr_t smlAllocSourceList();
+SML_API SmlSyncHdrPtr_t smlAllocSyncHdr();
+SML_API SmlItemPtr_t smlAllocItem();
+SML_API SmlItemListPtr_t smlAllocItemList();
+SML_API SmlGenericCmdPtr_t smlAllocGeneric();
+SML_API SmlAddPtr_t smlAllocAdd();
+SML_API SmlCopyPtr_t smlAllocCopy();
+SML_API SmlReplacePtr_t smlAllocReplace();
+SML_API SmlDeletePtr_t smlAllocDelete();
+SML_API SmlAlertPtr_t smlAllocAlert();
+SML_API SmlAtomicPtr_t smlAllocAtomic();
+SML_API SmlSequencePtr_t smlAllocSequence();
+SML_API SmlSyncPtr_t smlAllocSync();
+SML_API SmlExecPtr_t smlAllocExec();
+SML_API SmlGetPtr_t smlAllocGet();
+SML_API SmlPutPtr_t smlAllocPut();
+SML_API SmlMapItemPtr_t smlAllocMapItem();
+SML_API SmlMapItemListPtr_t smlAllocMapItemList();
+SML_API SmlMapPtr_t smlAllocMap();
+SML_API SmlResultsPtr_t smlAllocResults();
+SML_API SmlSearchPtr_t smlAllocSearch();
+SML_API SmlTargetRefListPtr_t smlAllocTargetRefList();
+SML_API SmlSourceRefListPtr_t smlAllocSourceRefList();
+SML_API SmlStatusPtr_t smlAllocStatus();
+SML_API SmlUnknownProtoElementPtr_t smlAllocUnknownProtoElement();
+#ifdef __USE_METINF__
+SML_API SmlMetInfMetInfPtr_t smlAllocMetInfMetInf();
+SML_API SmlMetInfAnchorPtr_t smlAllocMetInfAnchor();
+SML_API SmlMetInfMemPtr_t smlAllocMetInfMem();
+#endif // MetInf
+
+#ifdef __USE_DEVINF__
+SML_API SmlDevInfExtPtr_t smlAllocDevInfExt();
+SML_API SmlDevInfExtListPtr_t smlAllocDevInfExtList();
+SML_API SmlDevInfSyncCapPtr_t smlAllocDevInfSyncCap();
+SML_API SmlDevInfCTDataPtr_t smlAllocDevInfCTData();
+SML_API SmlDevInfCTDataListPtr_t smlAllocDevInfCTDataList();
+SML_API SmlDevInfCTDataPropPtr_t smlAllocDevInfCTDataProp();
+SML_API SmlDevInfCTDataPropListPtr_t smlAllocDevInfCTDataPropList();
+SML_API SmlDevInfCTCapPtr_t smlAllocDevInfCTCap();
+SML_API SmlDevInfCtcapListPtr_t smlAllocDevInfCtcapList();
+SML_API SmlDevInfDSMemPtr_t smlAllocDevInfDSMem();
+SML_API SmlDevInfXmitPtr_t smlAllocDevInfXmit();
+SML_API SmlDevInfXmitListPtr_t smlAllocDevInfXmitList();
+SML_API SmlDevInfDatastorePtr_t smlAllocDevInfDatastore();
+SML_API SmlDevInfDatastoreListPtr_t smlAllocDevInfDatastoreList();
+SML_API SmlDevInfDevInfPtr_t smlAllocDevInfDevInf();
+#endif // DevInf
+
+#ifdef __USE_DMTND__
+SML_API SmlDmTndPtr_t smlAllocDmTnd();
+SML_API SmlDmTndNodeListPtr_t smlAllocDmTndNodeList();
+SML_API SmlDmTndNodePtr_t smlAllocDmTndNode();
+SML_API SmlDmTndRTPropsPtr_t smlAllocDmTndRTProps();
+SML_API SmlDmTndFormatPtr_t smlAllocDmTndFormat();
+SML_API SmlDmTndTypePtr_t smlAllocDmTndType();
+#endif // DmTnd
+#endif // AllocFuncs
+#endif // MgrUtil.h
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgr.c b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgr.c
new file mode 100644
index 0000000..a72c160
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgr.c
@@ -0,0 +1,306 @@
+/*************************************************************************/
+/* module: Managing SyncML */
+/* */
+/* file: mgr.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Core Module managing the life-cycle of a syncML Process itself */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <sml.h>
+#include <smldef.h>
+#include <smlerr.h>
+
+#if defined(NOWSM) && !__LINK_TOOLKIT_STATIC__
+// we need dummies of these as they are listed in the SyncML.def file
+SML_API_DEF Ret_t smlInit(SmlOptionsPtr_t pOptions) { return SML_ERR_OK; }
+SML_API_DEF Ret_t smlSetSyncMLOptions (SmlOptionsPtr_t pOptions) { return SML_ERR_OK; }
+SML_API_DEF Ret_t smlTerminate(void) { return SML_ERR_OK; }
+#endif
+
+#ifndef NOWSM
+
+#include "libmem.h"
+#include "liblock.h"
+#include "wsm.h"
+#include "mgr.h"
+
+#ifdef __EPOC_OS__
+#include "core_globals_epoc.h"
+#endif
+
+/* Prototypes of exported SyncML API functions */
+SML_API Ret_t smlInit(SmlOptionsPtr_t pOptions);
+SML_API Ret_t smlSetSyncMLOptions (SmlOptionsPtr_t pOptions);
+SML_API Ret_t smlTerminate(void);
+
+/* SyncML internal function prototypes */
+InstanceInfoPtr_t mgrGetInstanceListAnchor(void);
+void mgrSetInstanceListAnchor(InstanceInfoPtr_t newListAnchor);
+SyncMLInfoPtr_t mgrGetSyncMLAnchor(void);
+
+
+/**
+ * Anchor of the global syncML info structure
+ */
+#ifndef __EPOC_OS__
+static SyncMLInfoPtr_t pGlobalAnchor=NULL; // this global pointer is used to access ALL globals within syncml
+#endif // This is the ONLY global varible of SyncML!
+
+#ifdef __EPOC_OS__
+#define pGlobalAnchor TheCoreGlobalsEpoc()->pGlobalAnchor
+#endif
+
+/*************************************************************************
+ * Exported SyncML API functions
+ *************************************************************************/
+
+
+
+
+/**
+ * FUNCTION: smlInit
+ *
+ * Initializes the SyncML Reference Tookit. This is required, before any
+ * other function can be used.
+ *
+ * IN: SyncMLOptionsPtr_t
+ * options to be applied for the toolkit
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlInit(SmlOptionsPtr_t pCoreOptions)
+{
+
+ /* ---- Definitions --- */
+ WsmOptions_t* pWorkspaceOptions;
+ Ret_t rc;
+
+
+ /* --- check, if SyncML has already been initialized --- */
+ if (pGlobalAnchor!=NULL) return SML_ERR_ALREADY_INITIALIZED;
+
+ /* --- Check pOptions, which have been passed by the application --- */
+ if (!pCoreOptions)
+ return SML_ERR_WRONG_USAGE;
+
+
+ /* --- Create a SyncML info memory object to store all globals --- */
+ TOOLKITLOCK_INIT("smlInit");
+ pGlobalAnchor = (SyncMLInfoPtr_t)smlLibMalloc((MemSize_t)sizeof(SyncMLInfo_t));
+ if (pGlobalAnchor==NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pGlobalAnchor,0,(MemSize_t)sizeof(SyncMLInfo_t));
+
+
+ /* --- Set SyncML settings and options --- */
+ pGlobalAnchor->instanceListAnchor = NULL; // no instance exists at the beginning
+ rc = smlSetSyncMLOptions (pCoreOptions); // store the options in the global structure
+ if (rc!=SML_ERR_OK){
+ smlLibFree(pGlobalAnchor);
+ pGlobalAnchor = NULL;
+ return rc;
+ }
+
+ pGlobalAnchor->tokTbl = (TokenInfoPtr_t)smlLibMalloc(sizeof(TokenInfo_t));
+ if (pGlobalAnchor->tokTbl == NULL)
+ {
+ smlLibFree(pGlobalAnchor);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pGlobalAnchor->tokTbl, 0, sizeof(TokenInfo_t));
+ /* --- Init all modules ---*/
+
+ /* Init Workspace Module */
+ pWorkspaceOptions=(WsmOptions_t*)smlLibMalloc((MemSize_t)sizeof(WsmOptions_t)); // create workspace options
+ if (pWorkspaceOptions == NULL) {
+ smlLibFree(pGlobalAnchor->syncmlOptions);
+ smlLibFree(pGlobalAnchor->tokTbl);
+ smlLibFree(pGlobalAnchor);
+ pGlobalAnchor = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ smlLibMemset(pWorkspaceOptions,0,(MemSize_t)sizeof(WsmOptions_t));
+ pWorkspaceOptions->maxAvailMem=(MemSize_t)pGlobalAnchor->syncmlOptions->maxWorkspaceAvailMem;
+
+ rc = wsmInit (pWorkspaceOptions);
+ if (rc!=SML_ERR_OK){
+ smlLibFree(pGlobalAnchor->syncmlOptions);
+ smlLibFree(pGlobalAnchor->tokTbl);
+ smlLibFree(pGlobalAnchor);
+ pGlobalAnchor = NULL;
+ smlLibFree(pWorkspaceOptions);
+ return rc;
+ }
+ smlLibFree(pWorkspaceOptions);
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlTerminate
+ *
+ * Terminate SyncML. Frees all memory and other ressources used by
+ * SyncML. This function must be called when terminating SyncML
+ *
+ * PRE-Condition: All instances must have been terminated
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlTerminate(void) {
+ // Have all Instances been terminated?
+ if (pGlobalAnchor->instanceListAnchor!=NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ /* --- Make sure, the workspace is destroyed --*/
+ LOCKTOOLKIT("smlTerminate");
+ wsmTerminate();
+
+ /* --- Free the global structure --*/
+ smlLibFree(pGlobalAnchor->tokTbl->SyncML);
+ smlLibFree(pGlobalAnchor->tokTbl->MetInf);
+ smlLibFree(pGlobalAnchor->tokTbl->DevInf);
+ smlLibFree(pGlobalAnchor->tokTbl->DmTnd);
+ smlLibFree(pGlobalAnchor->tokTbl);
+ smlLibFree(pGlobalAnchor->syncmlOptions);
+ smlLibFree(pGlobalAnchor);
+ pGlobalAnchor=NULL;
+
+ TOOLKITLOCK_FREE("smlTerminate");
+
+ return SML_ERR_OK;
+
+}
+
+
+
+/**
+ * FUNCTION: smlSetSyncMLOptions
+ *
+ * change the option settings for syncML
+ *
+ * IN: SyncMLOptionsPtr_t
+ * options to be applied for the toolkit
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlSetSyncMLOptions(SmlOptionsPtr_t pCoreOptions) {
+
+
+ /* ---- Definitions --- */
+ SmlOptionsPtr_t pCoreOptionsCopy;
+
+
+ /* --- Check pOptions, which have been passed by the application --- */
+ if (!pCoreOptions)
+ return SML_ERR_WRONG_USAGE;
+
+
+ /* --- free SyncML options --- */
+ smlLibFree(pGlobalAnchor->syncmlOptions);
+ pGlobalAnchor->syncmlOptions = NULL;
+ /* --- Use a copy of pCoreOptions --- */
+ pCoreOptionsCopy = (SmlOptionsPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlOptions_t));
+ if (pCoreOptionsCopy==NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemcpy(pCoreOptionsCopy,pCoreOptions,(MemSize_t)sizeof(SmlOptions_t));
+
+
+ /* --- set new SyncML options --- */
+ pGlobalAnchor->syncmlOptions = pCoreOptionsCopy; // set the options,passed from the application
+
+ return SML_ERR_OK;
+
+}
+
+/*************************************************************************
+ * SyncML internal functions
+ *************************************************************************/
+/**
+ * FUNCTION: mgrGetSyncMLInfo
+ * Retrieves a pointer to the structure holding all global informations within SyncML
+ *
+ * RETURN: SyncMLInfoPtr_t
+ * Pointer to the pGlobalAnchor
+ */
+SyncMLInfoPtr_t mgrGetSyncMLAnchor(void)
+{
+ return pGlobalAnchor;
+}
+
+/**
+ * FUNCTION: mgrGetInstanceListAnchor
+ * Retrieves a pointer to the list holding all instance informations
+ *
+ * RETURN: InstanceInfoPtr_t
+ * Pointer to the pInstanceListAnchor
+ */
+InstanceInfoPtr_t mgrGetInstanceListAnchor(void)
+{
+ return pGlobalAnchor->instanceListAnchor;
+}
+
+/**
+ * FUNCTION: mgrSetInstanceListAnchor
+ * Set the pointer to the list holding all instance informations
+ *
+ * IN: InstanceInfoPtr_t
+ * Pointer to the pInstanceListAnchor
+ */
+void mgrSetInstanceListAnchor(InstanceInfoPtr_t newListAnchor)
+{
+ pGlobalAnchor->instanceListAnchor=newListAnchor;
+}
+
+
+#endif // !defined(NOWSM)
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrcmdbuilder.c b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrcmdbuilder.c
new file mode 100644
index 0000000..7cc0bbf
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrcmdbuilder.c
@@ -0,0 +1,901 @@
+/*************************************************************************/
+/* module: SyncML Command Builder */
+/* */
+/* file: mgrcmdbuilder.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Core Module for assembling SyncML compliant documents */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <smldef.h>
+#include "xltenc.h"
+#include "xltdec.h"
+#include "libmem.h"
+#include "mgr.h"
+
+
+/* Used external functions */
+extern Ret_t smlLockWriteBuffer(InstanceID_t id, MemPtr_t *pWritePosition, MemSize_t *freeSize);
+extern Ret_t smlUnlockWriteBuffer(InstanceID_t id, MemSize_t writtenBytes);
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ extern Ret_t addInfo(InstanceInfoPtr_t pInfo);
+ extern InstanceInfoPtr_t findInfo(InstanceID_t id);
+ extern Ret_t removeInfo(InstanceID_t id);
+#endif
+
+/* Prototypes of exported SyncML API functions */
+SML_API Ret_t smlStartMessage(InstanceID_t id, SmlSyncHdrPtr_t pContent);
+SML_API Ret_t smlStartMessageExt(InstanceID_t id, SmlSyncHdrPtr_t pContent, SmlVersion_t vers);
+SML_API Ret_t smlEndMessage(InstanceID_t id, Boolean_t final);
+SML_API Ret_t smlStartSync(InstanceID_t id, SmlSyncPtr_t pContent);
+SML_API Ret_t smlEndSync(InstanceID_t id);
+
+#ifdef ATOMIC_SEND /* these API calls are NOT included in the Toolkit lite version */
+ SML_API Ret_t smlStartAtomic(InstanceID_t id, SmlAtomicPtr_t pContent);
+ SML_API Ret_t smlEndAtomic(InstanceID_t id);
+#endif
+#ifdef SEQUENCE_SEND
+ SML_API Ret_t smlStartSequence(InstanceID_t id, SmlSequencePtr_t pContent);
+ SML_API Ret_t smlEndSequence(InstanceID_t id);
+#endif
+
+#ifdef ADD_SEND
+ SML_API Ret_t smlAddCmd(InstanceID_t id, SmlAddPtr_t pContent);
+#endif
+SML_API Ret_t smlAlertCmd(InstanceID_t id, SmlAlertPtr_t pContent);
+SML_API Ret_t smlDeleteCmd(InstanceID_t id, SmlDeletePtr_t pContent);
+#ifdef GET_SEND
+ SML_API Ret_t smlGetCmd(InstanceID_t id, SmlGetPtr_t pContent);
+#endif
+SML_API Ret_t smlPutCmd(InstanceID_t id, SmlPutPtr_t pContent);
+SML_API Ret_t smlMapCmd(InstanceID_t id, SmlMapPtr_t pContent);
+SML_API Ret_t smlResultsCmd(InstanceID_t id, SmlResultsPtr_t pContent);
+SML_API Ret_t smlStatusCmd(InstanceID_t id, SmlStatusPtr_t pContent);
+SML_API Ret_t smlReplaceCmd(InstanceID_t id, SmlReplacePtr_t pContent);
+
+#ifdef COPY_SEND /* these API calls are NOT included in the Toolkit lite version */
+ SML_API Ret_t smlCopyCmd(InstanceID_t id, SmlCopyPtr_t pContent);
+#endif
+#ifdef EXEC_SEND
+ SML_API Ret_t smlExecCmd(InstanceID_t id, SmlExecPtr_t pContent);
+#endif
+#ifdef SEARCH_SEND
+ SML_API Ret_t smlSearchCmd(InstanceID_t id, SmlSearchPtr_t pContent);
+#endif
+
+/* Private function prototypes */
+static Ret_t mgrCreateNextCommand(InstanceID_t id, SmlProtoElement_t cmdType, VoidPtr_t pContent);
+Ret_t mgrResetWorkspace (InstanceID_t id);
+
+
+
+
+/*************************************************************************
+ * Exported SyncML API functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlStartMessage
+ *
+ * Start a SyncML Message
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlSyncHdrPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ *
+ * NOTE: (%%% luz 2003-08-06) this entry point is for compatibilty reasons only
+ * and works for SyncML 1.0 only
+ * please use smlStartMessageExt() instead in new projects.
+ */
+SML_API Ret_t smlStartMessage(InstanceID_t id, SmlSyncHdrPtr_t pContent)
+{
+ /* just call smlStartMessageExt with vers set to SyncML 1.0 */
+ return smlStartMessageExt(id,pContent,SML_VERS_1_1);
+}
+
+
+/**
+ * FUNCTION: smlStartMessageExt
+ * (%%% added by luz 2003-08-06 to support SyncML versions other than
+ * 1.0 with new vers parameter)
+ *
+ * Start a SyncML Message
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ * SyncML version
+ *
+ * IN: SmlSyncHdrPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartMessageExt(InstanceID_t id, SmlSyncHdrPtr_t pContent, SmlVersion_t vers)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+ MemPtr_t pCurrentWritePosition; // current Position from to which to write
+ MemPtr_t pBeginPosition; // saves the first position which has been written
+ MemSize_t freeSize; // size of free memory for writing
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- Get Write Access to the workspace --- */
+ rc = smlLockWriteBuffer(id, &pCurrentWritePosition, &freeSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+ #ifdef NOWSM
+ // remember where outgoing message starts in buffer
+ smlSetOutgoingBegin(id);
+ #endif
+
+ /* Remember the position we have started writing */
+ pBeginPosition=pCurrentWritePosition;
+
+ /* --- Call the encoder module --- */
+ /* (Saves the returned encoder state to the corresponding instanceInfo structure */
+ rc = xltEncInit(pInstanceInfo->instanceOptions->encoding, pContent,
+ pCurrentWritePosition+freeSize, &pCurrentWritePosition,
+ (XltEncoderPtr_t *)&(pInstanceInfo->encoderState),
+ vers);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // Reset the encoder module (free the encoding object)
+ xltEncReset(pInstanceInfo->encoderState);
+ // this encoding job is over! reset instanceInfo pointer
+ pInstanceInfo->encoderState=NULL;
+
+ return rc;
+ }
+
+ /* --- End Write Access to the workspace --- */
+ rc = smlUnlockWriteBuffer(id, (MemSize_t)pCurrentWritePosition-(MemSize_t)pBeginPosition);
+ return rc;
+}
+
+/**
+ * FUNCTION: smlEndMessage
+ *
+ * End a SyncML Message
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: Boolean_t
+ * Final Flag indicates last message within a package
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndMessage(InstanceID_t id, Boolean_t final)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+ MemPtr_t pCurrentWritePosition; // current Position from to which to write
+ MemPtr_t pBeginPosition; // saves the first position which has been written
+ MemSize_t freeSize; // size of free memory for writing
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // %%% luz 2003-08-19: added NULL check as previously failed encoding will delete encoder
+ if (pInstanceInfo->encoderState==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- Get Write Access to the workspace --- */
+ rc = smlLockWriteBuffer(id, &pCurrentWritePosition, &freeSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+
+ /* Remember the position we have started writing */
+ pBeginPosition=pCurrentWritePosition;
+
+ /* -- set Final Flag --*/
+ ((XltEncoderPtr_t)(pInstanceInfo->encoderState))->final = final;
+
+ /* --- Call the encoder module --- */
+ rc = xltEncTerminate(pInstanceInfo->encoderState, pCurrentWritePosition+freeSize,&pCurrentWritePosition);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // this encoding job is over! reset instanceInfo pointer
+ pInstanceInfo->encoderState=NULL;
+
+ return rc;
+ }
+
+ // this encoding job is over! reset instanceInfo pointer
+ // (the decoding object itself has been freed by the decoder)
+ pInstanceInfo->encoderState=NULL;
+
+ /* --- End Write Access to the workspace --- */
+ rc = smlUnlockWriteBuffer(id, (MemSize_t)pCurrentWritePosition-(MemSize_t)pBeginPosition);
+
+
+ return rc;
+}
+
+
+
+
+
+/**
+ * FUNCTION: smlStartSync
+ *
+ * Start synchronizing
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SyncPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartSync(InstanceID_t id, SmlSyncPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_SYNC_START, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlEndSync
+ *
+ * End synchronizing
+ *
+ * IN: InstanceID_t
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndSync(InstanceID_t id)
+{
+ return mgrCreateNextCommand(id, SML_PE_SYNC_END, NULL);
+}
+
+
+#ifdef ATOMIC_SEND /* these API calls are NOT included in the Toolkit lite version */
+
+/**
+ * FUNCTION: smlStartAtomic
+ *
+ * Start an atomic sequence
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlAtomicPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartAtomic(InstanceID_t id, SmlAtomicPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_ATOMIC_START, pContent);
+}
+
+
+/**
+ * FUNCTION: smlEndAtomic
+ *
+ * End an atomic sequence
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndAtomic(InstanceID_t id)
+{
+ return mgrCreateNextCommand(id, SML_PE_ATOMIC_END, NULL);
+}
+
+#endif
+
+#ifdef SEQUENCE_SEND
+
+/**
+ * FUNCTION: smlStartSequence
+ *
+ * Start a sequence
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SequencePtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartSequence(InstanceID_t id, SmlSequencePtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_SEQUENCE_START, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlEndSequence
+ *
+ * End a sequence
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndSequence(InstanceID_t id)
+{
+ return mgrCreateNextCommand(id, SML_PE_SEQUENCE_END, NULL);
+}
+
+#endif
+
+
+#ifdef ADD_SEND
+/**
+ * FUNCTION: smlAddCmd
+ *
+ * Create a Add Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlAddPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlAddCmd(InstanceID_t id, SmlAddPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_ADD, pContent);
+}
+#endif
+
+
+/**
+ * FUNCTION: smlAlertCmd
+ *
+ * Create a Alert Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlAlertPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlAlertCmd(InstanceID_t id, SmlAlertPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_ALERT, pContent);
+}
+
+
+
+
+/**
+ * FUNCTION: smlDeleteCmd
+ *
+ * Create a Start Message Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: DeletePtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlDeleteCmd(InstanceID_t id, SmlDeletePtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_DELETE, pContent);
+}
+
+
+
+#ifdef GET_SEND
+
+
+/**
+ * FUNCTION: smlGetCmd
+ *
+ * Create a Get Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: GetPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlGetCmd(InstanceID_t id, SmlGetPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_GET, pContent);
+}
+
+#endif
+
+
+/**
+ * FUNCTION: smlPutCmd
+ *
+ * Create a Put Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: PutPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlPutCmd(InstanceID_t id, SmlPutPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_PUT, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlMapCmd
+ *
+ * Create a Map Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: MapPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlMapCmd(InstanceID_t id, SmlMapPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_MAP, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlResultsCmd
+ *
+ * Create a Results Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: ResultsPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlResultsCmd(InstanceID_t id, SmlResultsPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_RESULTS, pContent);
+}
+
+
+
+
+
+/**
+ * FUNCTION: smlStatusCmd
+ *
+ * Create a Status Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: StatusPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStatusCmd(InstanceID_t id, SmlStatusPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_STATUS, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlReplaceCmd
+ *
+ * Create a Replace Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlReplacePtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlReplaceCmd(InstanceID_t id, SmlReplacePtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_REPLACE, pContent);
+}
+
+
+
+#ifdef COPY_SEND /* these API calls are NOT included in the Toolkit lite version */
+
+
+/**
+ * FUNCTION: smlCopyCmd
+ *
+ * Create a Copy Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: CopyPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlCopyCmd(InstanceID_t id, SmlCopyPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_COPY, pContent);
+}
+
+#endif
+
+#ifdef EXEC_SEND
+
+/**
+ * FUNCTION: smlExecCmd
+ *
+ * Create a Exec Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: ExecPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlExecCmd(InstanceID_t id, SmlExecPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_EXEC, pContent);
+}
+
+#endif
+
+#ifdef SEARCH_SEND
+
+/**
+ * FUNCTION: smlSearchCmd
+ *
+ * Create a Search Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SearchPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlSearchCmd(InstanceID_t id, SmlSearchPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_SEARCH, pContent);
+}
+
+
+#endif
+
+
+/*************************************************************************
+ * Exported SyncML API functions (FULL-SIZE TOOLKIT ONLY)
+ *************************************************************************/
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+/**
+ * FUNCTION: smlStartEvaluation
+ *
+ * Starts an evaluation run which prevents further API-Calls to write tags -
+ * just the tag-sizes are calculated. Must be sopped via smlEndEvaluation
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartEvaluation(InstanceID_t id)
+{
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- Initialize Encoder for evaluation mode --- */
+
+ rc = xltStartEvaluation((XltEncoderPtr_t)(pInstanceInfo->encoderState));
+
+ return rc;
+}
+
+
+/**
+ * FUNCTION: smlEndEvaluation
+ *
+ * Stops an evaluation run which prevents further API-Calls to write tags -
+ * the remaining free buffer size after all Tags are written is returned
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN/OUT: MemSize_t
+ * Size of free buffer for data after all tags are written
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndEvaluation(InstanceID_t id, MemSize_t *freemem)
+{
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ // %%% luz 2002-09-03: encoder can be null here if fatal error occurred before
+ if (pInstanceInfo->encoderState==NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ rc = xltEndEvaluation(id, (XltEncoderPtr_t)(pInstanceInfo->encoderState), freemem);
+ return SML_ERR_OK;
+}
+
+#endif
+
+
+/*************************************************************************
+ * Private Functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION:
+ * Calls the encoding routines of the Encoder Module for a given Command Type
+ * and Command Content
+ *
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: ProtoElement_t
+ * Type of the command (defined by the Proto Element Enumeration)
+ *
+ * IN: VoidPtr_t
+ * Content of the command to encode
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if command has been encoded successfully
+ */
+static Ret_t mgrCreateNextCommand(InstanceID_t id, SmlProtoElement_t cmdType, VoidPtr_t pContent)
+{
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+ MemPtr_t pCurrentWritePosition; // current Position from to which to write
+ MemPtr_t pBeginPosition; // saves the first position which has been written
+ MemSize_t freeSize; // size of free memory for writing
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // %%% luz 2002-11-27: added NULL check as previously failed encoding will delete encoder
+ if (pInstanceInfo->encoderState==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ /* --- Get Write Access to the workspace --- */
+ rc = smlLockWriteBuffer(id, &pCurrentWritePosition, &freeSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+
+ // Remember the position we have started writing
+ pBeginPosition=pCurrentWritePosition;
+
+
+ /* --- Call the encoder module --- */
+ rc = xltEncAppend(pInstanceInfo->encoderState, cmdType, pCurrentWritePosition+freeSize, pContent, &pCurrentWritePosition);
+
+ if (rc!=SML_ERR_OK) {
+ /* check for full buffer and call TransmitChunk */
+ if (rc == SML_ERR_XLT_BUF_ERR) {
+ // first check wether callback is defined
+ if (pInstanceInfo->callbacks->transmitChunkFunc!= NULL) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // call the callback
+ pInstanceInfo->callbacks->transmitChunkFunc(id,NULL);
+ // lock -> returns the amount of free buffer space
+ smlLockWriteBuffer(id, &pCurrentWritePosition, &freeSize);
+ pBeginPosition = pCurrentWritePosition;
+ // now try again to encode and see wether we now have enough mem available
+ rc = xltEncAppend(pInstanceInfo->encoderState, cmdType, pCurrentWritePosition+freeSize, pContent, &pCurrentWritePosition);
+ // if rc == SML_ERR_OK continue else
+ // return the errorcode
+ if( rc != SML_ERR_OK)
+ {
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // Reset the encoder module (free the encoding object)
+ xltEncReset(pInstanceInfo->encoderState);
+ // this encoding job is over! reset instanceInfo pointer
+ pInstanceInfo->encoderState=NULL;
+ return rc;
+ }
+ }
+ } else {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // Reset the encoder module (free the encoding object)
+ xltEncReset(pInstanceInfo->encoderState);
+ // this encoding job is over! reset instanceInfo pointer
+ pInstanceInfo->encoderState=NULL;
+ return rc;
+ }
+ }
+ /* --- End Write Access to the workspace --- */
+ rc = smlUnlockWriteBuffer(id, (MemSize_t)pCurrentWritePosition-(MemSize_t)pBeginPosition);
+ return rc;
+}
+
+/* eof */
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrcmddispatcher.c b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrcmddispatcher.c
new file mode 100644
index 0000000..b49d787
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrcmddispatcher.c
@@ -0,0 +1,504 @@
+/*************************************************************************/
+/* module: SyncML Command Dispatcher */
+/* */
+/* file: mgrcmddispatcher.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Core module for dispatching parsed commands and invoking callback */
+/* functions of the application */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <define.h>
+/* Include Headers */
+#include <smldef.h>
+#include <smldtd.h>
+#include <smlerr.h>
+
+#include "libmem.h"
+#include "xltdec.h"
+#include "mgr.h"
+
+
+
+/* Used external functions */
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ extern Ret_t addInfo(InstanceInfoPtr_t pInfo);
+ extern InstanceInfoPtr_t findInfo(InstanceID_t id);
+ extern Ret_t removeInfo(InstanceID_t id);
+#endif
+Ret_t smlLockReadBuffer(InstanceID_t id, MemPtr_t *pReadPosition, MemSize_t *usedSize);
+Ret_t smlUnlockReadBuffer(InstanceID_t id, MemSize_t processedBytes);
+
+/* Prototypes of exported SyncML API functions */
+extern Ret_t smlProcessData(InstanceID_t id, SmlProcessMode_t mode);
+
+/* Private function prototypes */
+static Ret_t mgrProcessNextCommand(InstanceID_t id, InstanceInfoPtr_t pInstanceInfo);
+static Ret_t mgrProcessStartMessage(InstanceID_t id, InstanceInfoPtr_t pInstanceInfo);
+Ret_t mgrResetWorkspace (InstanceID_t id);
+
+
+
+/*************************************************************************
+ * Exported SyncML API functions
+ *************************************************************************/
+
+
+
+
+/**
+ * FUNCTION: smlProcessData
+ *
+ * Start the parsing of the XML code in the workspace buffer,
+ * dispatches the interpreted command and calls the corresponding callback
+ * functions provided by the application.
+ *
+ * IN: InstanceID_t
+ * The SyncML instance id is used for referencing the
+ * workspace buffer from the XML content is parsed
+ *
+ * IN: ProcessMode_t
+ * Mode of processing, Defines, if only the first or next
+ * XML command is parsed or if all commands are processed
+ * subsequently until the end of the entire workspace buffer
+ * is reached. The NEXT_COMMAND flag defines the blocking mode,
+ * the ALL_COMMANDS tag defines the non-blocking mode.
+ *
+ * RETURN: Ret_t
+ */
+SML_API Ret_t smlProcessData(InstanceID_t id, SmlProcessMode_t mode)
+{
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo; // state info for the given instanceID
+ Ret_t rc; // Temporary return code saver
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ /* --- Are callback functions defined? --- */
+ if (pInstanceInfo->callbacks==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+
+ /* --- Is parsing already in progress? --- */
+ if (pInstanceInfo->decoderState==NULL)
+ {
+ /* No! Parse the Message header section first */
+ rc = mgrProcessStartMessage(id, pInstanceInfo);
+
+ if (rc!=SML_ERR_OK) return rc;
+ }
+
+
+ /* --- Parse now the Message body section! --- */
+ do {
+ rc=mgrProcessNextCommand(id, pInstanceInfo);
+ } while (
+ // keep processing while no error occurs,
+ // AND the document end was not reached (decoderState has been invalidated),
+ // AND the ALL_COMMAND mode is used
+ (rc==SML_ERR_OK)
+ &&((pInstanceInfo->decoderState)!=NULL)
+ &&(mode==SML_ALL_COMMANDS)
+ );
+
+ if (rc != SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ }
+
+ return rc;
+}
+
+
+/*************************************************************************
+ * Private Functions
+ *************************************************************************/
+
+
+
+
+/**
+ * FUNCTION:
+ * Parses the header information at the beginning of an SyncML document.
+ *
+ * IN: InstanceID
+ * current InstanceID to pass to callback functions
+ *
+ * IN/OUT: InstanceInfo
+ * state information of the given InstanceID (decoder state will be changed)
+ *
+ * RETURN: Return value of the Parser,
+ * SML_ERR_OK if next command was handled successfully
+ */
+static Ret_t mgrProcessStartMessage(InstanceID_t id, InstanceInfoPtr_t pInstanceInfo)
+{
+
+
+ /* --- Definitions --- */
+ Ret_t rc; // Temporary return code saver
+ SmlSyncHdrPtr_t pContent=NULL; // data of the command to process
+ MemPtr_t pCurrentReadPosition ; // current Position from which is read
+ MemPtr_t pBeginPosition; // saves the first position which has been reading
+ MemSize_t usedSize ; // size of used memory to be read
+
+
+ /* --- Get Read Access to the workspace --- */
+ rc = smlLockReadBuffer(id, &pCurrentReadPosition, &usedSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+ // Remember the position we have started reading
+ pBeginPosition=pCurrentReadPosition;
+
+ /* --- Start new decoding sequence and pass returned decoder status structure to instanceInfo --- */
+ rc = xltDecInit(pInstanceInfo->instanceOptions->encoding,
+ pCurrentReadPosition+usedSize-1, &pCurrentReadPosition,
+ (XltDecoderPtr_t *)&(pInstanceInfo->decoderState), &pContent);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ return rc;
+ }
+
+ /* --- End Read Access to the workspace --- */
+ rc = smlUnlockReadBuffer(id, (MemSize_t)pCurrentReadPosition-(MemSize_t)pBeginPosition);
+ if (rc!=SML_ERR_OK) return rc;
+
+ /* --- Perform callback to handle the beginning of a new message --- */
+ if (pInstanceInfo->callbacks->startMessageFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ rc=pInstanceInfo->callbacks->startMessageFunc(id, pInstanceInfo->userData, pContent);
+
+ if (rc != SML_ERR_OK)
+ {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ }
+
+ return rc;
+}
+
+
+
+/**
+ * FUNCTION:
+ * Parses the next Sync Command in the sync document.
+ *
+ * IN: InstanceID
+ * current InstanceID to pass to callback functions
+ *
+ * IN: InstanceInfo
+ * state information of the given InstanceID
+ *
+ * RETURN: Return value of the Parser of the called application callback,
+ * SML_ERR_OK if next command was handled successfully
+ */
+static Ret_t mgrProcessNextCommand(InstanceID_t id, InstanceInfoPtr_t pInstanceInfo)
+{
+
+ /* --- Definitions --- */
+ Ret_t rc; // Temporary return code saver
+ SmlProtoElement_t cmdType; // ID of the command to process
+ VoidPtr_t pContent=NULL; // data of the command to process
+ MemPtr_t pCurrentReadPosition; // current Position from which is read
+ MemPtr_t pBeginPosition; // saves the first position which has been reading
+ MemSize_t usedSize; // size of used memory to be read
+ Boolean_t final; // flag indicates last message within a package
+
+
+ /* --- Get Read Access to the workspace --- */
+ rc = smlLockReadBuffer(id, &pCurrentReadPosition, &usedSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+ // Remember the position we have started reading
+ pBeginPosition=pCurrentReadPosition;
+
+
+ /* --- Parse next Command --- */
+ rc = xltDecNext(pInstanceInfo->decoderState, pCurrentReadPosition+usedSize, &pCurrentReadPosition, &cmdType, &pContent);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ return rc;
+ }
+
+ /* --- End Read Access to the workspace --- */
+ rc = smlUnlockReadBuffer(id, (MemSize_t)pCurrentReadPosition-(MemSize_t)pBeginPosition);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+ /* --- Did we reach end of synchronization document? --- */
+ if (((XltDecoderPtr_t)(pInstanceInfo->decoderState))->finished!=0) {
+ final = ((XltDecoderPtr_t)(pInstanceInfo->decoderState))->final; // flag is returned to appl. with callback
+ rc=xltDecTerminate(pInstanceInfo->decoderState);
+
+ if (rc!=SML_ERR_OK)
+ {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ return rc;
+ }
+
+ // this decoding job is over! reset Instance Info pointer
+ // (the decoding object itself has been freed by the decoder)
+ pInstanceInfo->decoderState=NULL;
+
+ // Call the callback for handling an message ending
+ if (pInstanceInfo->callbacks->endMessageFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+
+ rc=pInstanceInfo->callbacks->endMessageFunc(id, pInstanceInfo->userData, final);
+ return rc;
+ }
+
+ /* --- Dispatch parsed command (and call the applications command handler function)--- */
+ switch (cmdType)
+ {
+ /* Handle ADD Command */
+ case SML_PE_ADD:
+ if (pInstanceInfo->callbacks->addCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->addCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle ALERT Command */
+ case SML_PE_ALERT:
+ if (pInstanceInfo->callbacks->alertCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->alertCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle DELETE Command */
+ case SML_PE_DELETE:
+ if (pInstanceInfo->callbacks->deleteCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->deleteCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle PUT Command */
+ case SML_PE_PUT:
+ if (pInstanceInfo->callbacks->putCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->putCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle GET Command */
+ case SML_PE_GET:
+ if (pInstanceInfo->callbacks->getCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->getCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ #ifdef MAP_RECEIVE
+ /* Handle MAP Command */
+ case SML_PE_MAP:
+ if (pInstanceInfo->callbacks->mapCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->mapCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+ #endif
+
+ #ifdef RESULT_RECEIVE
+ /* Handle RESULTS Command */
+ case SML_PE_RESULTS:
+ if (pInstanceInfo->callbacks->resultsCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->resultsCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+ #endif
+
+ /* Handle STATUS Command */
+ case SML_PE_STATUS:
+ if (pInstanceInfo->callbacks->statusCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->statusCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle START SYNC Command */
+ case SML_PE_SYNC_START:
+ if (pInstanceInfo->callbacks->startSyncFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->startSyncFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle END SYNC Command */
+ case SML_PE_SYNC_END:
+ if (pInstanceInfo->callbacks->endSyncFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->endSyncFunc (id, pInstanceInfo->userData);
+ break;
+
+ /* Handle REPLACE Command */
+ case SML_PE_REPLACE:
+ if (pInstanceInfo->callbacks->replaceCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->replaceCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle Final Flag */
+ case SML_PE_FINAL:
+ // if a FINAL Flag appears do nothing
+ return SML_ERR_OK;
+ break;
+
+
+ #ifdef SEARCH_RECEIVE /* these API calls are NOT included in the Toolkit lite version */
+
+ /* Handle SEARCH Command */
+ case SML_PE_SEARCH:
+ if (pInstanceInfo->callbacks->searchCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->searchCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+ #endif
+
+ #ifdef SEQUENCE_RECEIVE
+ /* Handle START SEQUENCE Command */
+ case SML_PE_SEQUENCE_START:
+ if (pInstanceInfo->callbacks->startSequenceFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->startSequenceFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle END SEQUENCE Command */
+ case SML_PE_SEQUENCE_END:
+ if (pInstanceInfo->callbacks->endSequenceFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->endSequenceFunc (id, pInstanceInfo->userData);
+ break;
+ #endif
+
+ #ifdef ATOMIC_RECEIVE
+
+ /* Handle START ATOMIC Command */
+ case SML_PE_ATOMIC_START:
+ if (pInstanceInfo->callbacks->startAtomicFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->startAtomicFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle END ATOMIC Command */
+ case SML_PE_ATOMIC_END:
+ if (pInstanceInfo->callbacks->endAtomicFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->endAtomicFunc (id, pInstanceInfo->userData);
+ break;
+ #endif
+
+ #ifdef COPY_RECEIVE
+
+ /* Handle COPY Command */
+ case SML_PE_COPY:
+ if (pInstanceInfo->callbacks->copyCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->copyCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+ #endif
+
+ #ifdef EXEC_RECEIVE
+
+ /* Handle EXEC Command */
+ case SML_PE_EXEC:
+ if (pInstanceInfo->callbacks->execCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->execCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ #endif
+
+ /* Handle ERROR DETECTED */
+ //case SML_PE_ERROR:
+ // if (pInstanceInfo->callbacks->handleErrorFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ // return pInstanceInfo->callbacks->handleErrorFunc (id, pInstanceInfo->userData);
+ // break;
+
+ /* --- Invalid Command Element --- */
+ default:
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+ break;
+ } // switch
+}
+
+/* eof */
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrinstancelist.c b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrinstancelist.c
new file mode 100644
index 0000000..6d38341
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrinstancelist.c
@@ -0,0 +1,233 @@
+/*************************************************************************/
+/* module: List of SyncML Instances */
+/* */
+/* file: mgrinstancelist.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* This module handles an element list of type InstanceInfo. Each */
+/* element is identified by the InstanceID. There are functions provided */
+/* to add, find and remove InstanceInfo elements. */
+/* This file is private to the core module. The InstanceInfo list is */
+/* used by the Modules MGR, MGRCmdDispatcher, MGRCmdBuilder */
+/* and MGRInstanceMgr. */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <smlerr.h>
+#include "libmem.h"
+#include "liblock.h"
+#include "mgr.h"
+
+#ifndef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+
+#ifndef NOWSM /* only need if we are using workspace manager */
+
+
+/* Used external functions */
+SyncMLInfoPtr_t mgrGetSyncMLAnchor(void);
+InstanceInfoPtr_t mgrGetInstanceListAnchor(void);
+void mgrSetInstanceListAnchor(InstanceInfoPtr_t newListAnchor);
+
+
+/* SyncML internal function prototypes */
+Ret_t addInfo(InstanceInfoPtr_t pInfo);
+InstanceInfoPtr_t findInfo(InstanceID_t id);
+Ret_t removeInfo(InstanceID_t id);
+
+
+/* Private function prototypes */
+
+
+
+
+
+
+/*************************************************************************
+ * SyncML internal functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION:
+ * Adds a new element to the list
+ *
+ * IN: InstanceInfoPtr_t
+ * pointer to the structure to be be added to list
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if element was added successfully
+ */
+Ret_t addInfo(InstanceInfoPtr_t pInfo)
+{
+
+ if (pInfo!=NULL)
+ {
+ InstanceInfoPtr_t _pTmp;
+
+ LOCKTOOLKIT("addInfo");
+ /* Remember old beginning of the list */
+ _pTmp=mgrGetInstanceListAnchor();
+
+ /* insert element immediately after anchor */
+ mgrSetInstanceListAnchor(pInfo); // anchor of list points now to new info element
+ pInfo->nextInfo=_pTmp; // Next info element is the prior first one.
+ RELEASETOOLKIT("addInfo");
+ return SML_ERR_OK;
+
+ } else { // Invalid InstanceInfo pointer was used (NULL)
+
+ return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ }
+
+}
+
+
+
+
+
+/**
+ * FUNCTION:
+ * Searches an element with the given InstanceID in the list
+ *
+ * IN: InstanceID_t
+ * ID of the InstanceInfo structure to be retrieved
+ *
+ * RETURN: InstanceInfoPtr_t
+ * Pointer to the InstanceInfo structure with the given ID
+ * NULL, if no InstanceInfo with the given ID has been found
+ */
+InstanceInfoPtr_t findInfo(InstanceID_t id)
+{
+
+ InstanceInfoPtr_t _pTmp; // A helper pointer
+
+ /* go through the list until end */
+ LOCKTOOLKIT("findInfo");
+ for (_pTmp=mgrGetInstanceListAnchor(); _pTmp!=NULL; _pTmp=_pTmp->nextInfo)
+ {
+ if (_pTmp->id == id) {
+ RELEASETOOLKIT("findInfo");
+ return _pTmp; // STOP, we've found the info, return!
+ }
+ }
+ RELEASETOOLKIT("findInfo");
+ return NULL; // Info was not found, return NULL
+
+}
+
+
+
+
+
+/**
+ * FUNCTION:
+ * Removes an element with the given InstanceID from the list
+ *
+ * IN: InstanceID_t
+ * ID of the InstanceInfo structure to be removed
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if element was removed successfully
+ */
+Ret_t removeInfo(InstanceID_t id)
+{
+
+ InstanceInfoPtr_t _pTmp; // A helper pointer
+ InstanceInfoPtr_t _pRemember; // A helper pointer
+
+
+ LOCKTOOLKIT("removeInfo");
+ /* Remember current anchor */
+ _pRemember=mgrGetInstanceListAnchor();
+
+ /* special check, if list is empty */
+ if (_pRemember==NULL ) {
+ RELEASETOOLKIT("removeInfo");
+ return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ }
+
+ /* special check, if first element should be removed */
+ if (_pRemember->id == id)
+ {
+ // It's the first element, update anchor!
+ mgrSetInstanceListAnchor(_pRemember->nextInfo);
+ //freeInfo(_pRemember); // Delete structure, free memory
+ RELEASETOOLKIT("removeInfo");
+ return SML_ERR_OK; // return
+ }
+
+
+ /* go through the list until end */
+ for (_pTmp=_pRemember->nextInfo; _pTmp!=NULL; _pTmp=_pTmp->nextInfo)
+ {
+ if (_pTmp->id == id) // STOP, we've found the info
+ {
+ _pRemember->nextInfo=_pTmp->nextInfo;
+ //freeInfo(_pTmp); // Delete structure, free memory
+ RELEASETOOLKIT("removeInfo");
+ return SML_ERR_OK; // return
+
+ } else {
+
+ _pRemember=_pTmp; // update helper pointer
+ }
+ }
+
+ RELEASETOOLKIT("removeInfo");
+ return SML_ERR_MGR_INVALID_INSTANCE_INFO; // Info wasn't found
+
+}
+
+
+
+
+#endif // !defined(NOWSM)
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrinstancemgr.c b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrinstancemgr.c
new file mode 100644
index 0000000..95a82d9
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrinstancemgr.c
@@ -0,0 +1,1080 @@
+/*************************************************************************/
+/* module: Managing SyncML Instances */
+/* */
+/* file: mgrinstancemgr.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Core module for managing creation and usage of instances */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <smldef.h>
+#include <sml.h>
+#include <smlerr.h>
+#include "libmem.h"
+#include "libstr.h"
+#include "liblock.h"
+#include "wsm.h"
+#include "mgr.h"
+
+
+
+/* Used external functions */
+#ifndef NOWSM
+ #ifndef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ extern Ret_t addInfo(InstanceInfoPtr_t pInfo);
+ extern InstanceInfoPtr_t findInfo(InstanceID_t id);
+ extern Ret_t removeInfo(InstanceID_t id);
+ #endif
+ SyncMLInfoPtr_t mgrGetSyncMLAnchor(void);
+#endif
+
+/* Prototypes of exported SyncML API functions */
+SML_API Ret_t smlInitInstance(SmlCallbacksPtr_t callbacks, SmlInstanceOptionsPtr_t pOptions, VoidPtr_t pUserData, InstanceID_t *pInstanceID);
+SML_API Ret_t smlTerminateInstance (InstanceID_t id);
+SML_API Ret_t smlLockReadBuffer(InstanceID_t id, MemPtr_t *pReadPosition, MemSize_t *usedSize);
+SML_API Ret_t smlUnlockReadBuffer(InstanceID_t id, MemSize_t processedBytes);
+#ifdef NOWSM
+SML_API Ret_t smlSetMaxOutgoingSize(InstanceID_t id, MemSize_t maxOutgoingSize);
+SML_API Ret_t smlSetOutgoingBegin(InstanceID_t id);
+#endif
+SML_API Ret_t smlLockWriteBuffer(InstanceID_t id, MemPtr_t *pWritePosition, MemSize_t *freeSize);
+SML_API Ret_t smlUnlockWriteBuffer(InstanceID_t id, MemSize_t writtenBytes);
+SML_API Ret_t smlSetCallbacks (InstanceID_t id, SmlCallbacksPtr_t pCallbacks);
+SML_API Ret_t smlSetUserData (InstanceID_t id, VoidPtr_t pUserData);
+// added by luz %%%:
+SML_API Ret_t smlGetUserData(InstanceID_t id, VoidPtr_t *ppUserData);
+SML_API Ret_t smlGetEncoding(InstanceID_t id, SmlEncoding_t *pEncoding);
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ SML_API Ret_t smlSetEncoding (InstanceID_t id, SmlEncoding_t encoding);
+#endif
+
+
+
+/* Private function prototypes */
+Ret_t freeInstanceOptions (InstanceInfoPtr_t pInstanceInfo);
+static Ret_t freeInstanceInfo (InstanceInfoPtr_t pInfo);
+Ret_t mgrResetWorkspace (InstanceID_t id);
+Ret_t setInstanceOptions (InstanceID_t id, SmlInstanceOptionsPtr_t pOptions);
+
+
+/*************************************************************************
+ * Public SyncML API Functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlInitInstance
+ *
+ * Creates a SyncML instance and assigns a corresponding workspace buffer in
+ * which XML documents are assembled or parsed.
+ * All callback functions implemented by a particular application are defined.
+ * Instance specific options can be passed. This function has to be called
+ * before the first synchronization tasks can be performed. A reference valid
+ * for a SyncML instance is returned.
+ * An instance is active when processing a synchronization request
+ * otherwise it is idle. An instance is terminated when smlTerminateInstance
+ * is called.
+ *
+ * IN: SmlCallbacks_t
+ * A structure holding references to the callback functions
+ * implemented by the application
+ *
+ * IN: SmlInstanceOptionsPtr_t
+ * Option settings of a particular SyncML instance
+ *
+ * IN: VoidPtr_t
+ * UserData is a pointer to a void structure the application
+ * can pass into the SyncML Toolkit instance info.
+ * It will be returned to the application with every called
+ * callback function call!
+ * NOTE: This is only a pointer, the memory object itself
+ * remains within the responsibility of the calling application.
+ * The memory object will not be copied, moved or freed by the
+ * Toolkit.
+ *
+ * OUT: InstanceID_t
+ * Instance ID assigned to the initialized instance
+ *
+ * RETURN: Ret_t
+ * Error Code
+ */
+SML_API Ret_t smlInitInstance(SmlCallbacksPtr_t pCallbacks, SmlInstanceOptionsPtr_t pOptions, VoidPtr_t pUserData, InstanceID_t *pInstanceID)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+ Ret_t rc;
+
+
+ #ifndef NOWSM
+ /* --- Check pOptions, which have been passed by the application --- */
+ if (!pOptions || !pOptions->workspaceName)
+ return SML_ERR_WRONG_USAGE;
+
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ /* if ONE instance is already initialized */
+ if (mgrGetInstanceListAnchor()!=NULL)
+ return SML_ERR_WRONG_USAGE;
+ #endif
+
+ /* --- check wether we already know about this instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(*pInstanceID);
+ #endif
+
+ /* --- bail outh when we already have a instance with that id --- */
+ if (pInstanceInfo != NULL) return SML_ERR_WRONG_USAGE;
+
+
+ /* --- Create a workspace for this instance --- */
+ LOCKTOOLKIT("smlInitInstance");
+ if ((rc = wsmCreate(pOptions->workspaceName, pOptions->workspaceSize, pInstanceID)) != SML_ERR_OK) {
+ RELEASETOOLKIT("smlInitInstance after wsmCreate failure");
+ return rc;
+ }
+ RELEASETOOLKIT("smlInitInstance");
+ #else // NOWSM
+ /* --- Check pOptions, which have been passed by the application --- */
+ if (!pOptions || !pOptions->workspaceSize)
+ return SML_ERR_WRONG_USAGE;
+ // ok so far
+ rc=SML_ERR_OK;
+ #endif
+
+ /* --- Create an instance info memory object --- */
+ pInstanceInfo = (InstanceInfoPtr_t)smlLibMalloc((MemSize_t)sizeof(InstanceInfo_t));
+ if (pInstanceInfo==NULL) {
+ #ifndef NOWSM
+ wsmDestroy(pOptions->workspaceName);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ #endif
+ }
+ #ifdef NOWSM
+ else {
+ // instance info created, return pointer as instanceID
+ *pInstanceID = (InstanceID_t)pInstanceInfo;
+ }
+ #endif
+
+ smlLibMemset(pInstanceInfo,0,(MemSize_t)sizeof(InstanceInfo_t));
+
+
+
+ /* --- Set mandatory instance infos for this instance to defaults --- */
+ pInstanceInfo->status=MGR_IDLE;
+ pInstanceInfo->encoderState=NULL; // no encoding in progress, currently not used
+ pInstanceInfo->decoderState=NULL; // no decoding in progress, currently not used
+ #ifndef NOWSM
+ pInstanceInfo->id=*pInstanceID;
+ pInstanceInfo->workspaceState=NULL; // to do: some workspace status info
+ pInstanceInfo->nextInfo=NULL;
+ #else
+ // create a instance buffer
+ pInstanceInfo->instanceBufSiz=pOptions->workspaceSize; // get requested size for the buffer
+ pInstanceInfo->maxOutgoingSize=pOptions->maxOutgoingSize; // set max outgoing message size
+ pInstanceInfo->instanceBuffer=smlLibMalloc(pInstanceInfo->instanceBufSiz);
+ if (pInstanceInfo->instanceBuffer==NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ // init buffer pointers
+ pInstanceInfo->readPointer=pInstanceInfo->instanceBuffer;
+ pInstanceInfo->writePointer=pInstanceInfo->instanceBuffer;
+ pInstanceInfo->readLocked=0;
+ pInstanceInfo->writeLocked=0;
+ pInstanceInfo->outgoingMsgStart=NULL;
+ #endif
+
+
+ #ifndef NOWSM
+ /* --- Add instance infos memory object to the instance info list --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ mgrSetInstanceListAnchor(pInstanceInfo);
+ #else
+ rc = addInfo( pInstanceInfo );
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+ #endif
+
+
+ /* --- Set the values of instance Infos as defined by the calling application ---*/
+
+ /* Set user data pointer */
+ pInstanceInfo->userData=pUserData;
+ /* Set callback functions implemented by applications */
+ if (smlSetCallbacks(*pInstanceID, pCallbacks) != SML_ERR_OK) {
+ #ifndef NOWSM
+ wsmDestroy(pOptions->workspaceName);
+ #endif
+ return rc;
+ }
+
+ // luz: %%% this was called twice, probably this is a bug, so I disabled the second call
+ //smlSetCallbacks(*pInstanceID, pCallbacks);
+
+ /* Set other application defined options for that instance */
+ if (setInstanceOptions (*pInstanceID, pOptions) != SML_ERR_OK) {
+ #ifndef NOWSM
+ wsmDestroy(pOptions->workspaceName);
+ #endif
+ return rc;
+ }
+
+ return SML_ERR_OK;
+
+}
+
+
+
+/**
+ * FUNCTION: smlTerminateInstance
+ *
+ * Terminates a SyncML instance. The instance info is removed from the instances
+ * list. Allmemory allocated for the workspace and the options variables is freed.
+ *
+ * IN: InstanceID_t
+ * ID of the instance to be terminated
+ *
+ * RETURN: Ret_t
+ * Error Code
+ */
+SML_API Ret_t smlTerminateInstance (InstanceID_t id)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ Ret_t rc;
+
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ #ifndef NOWSM
+ /* --- Close the workspace --- */
+ if (pInstanceInfo->instanceOptions != NULL) {
+ LOCKTOOLKIT("smlTerminateInstance");
+ rc = wsmDestroy(pInstanceInfo->instanceOptions->workspaceName);
+ RELEASETOOLKIT("smlTerminateInstance");
+ if (rc!=SML_ERR_OK) {
+ // freeInstanceInfo(pInstanceInfo);
+ return rc;
+ }
+ }
+
+ /* --- Delete instance info and options --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ mgrSetInstanceListAnchor(NULL);
+ #else
+ removeInfo(id);
+ #endif
+ #endif
+
+ freeInstanceInfo (pInstanceInfo);
+
+ return SML_ERR_OK;
+}
+
+
+
+/**
+ * FUNCTION: smlSetCallbacks
+ *
+ * Sets new callback functions to an instance
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: SmlCallbacksPtr_t
+ * A structure holding references to the callback functions
+ * implemented by the application
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlSetCallbacks(InstanceID_t id, SmlCallbacksPtr_t pCallbacks)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+ SmlCallbacksPtr_t pCallbacksCopy;
+
+ /* --- Check pCallbacks, which have been passed by the application --- */
+ if (!pCallbacks)
+ return SML_ERR_WRONG_USAGE;
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ #endif
+
+ /* --- free old callback structure ---*/
+ smlLibFree(pInstanceInfo->callbacks);
+
+
+ /* --- Use a copy of pCallbacksCopy --- */
+ pCallbacksCopy = (SmlCallbacksPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlCallbacks_t));
+ if (pCallbacksCopy==NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemcpy(pCallbacksCopy,pCallbacks,(MemSize_t)sizeof(SmlCallbacks_t));
+
+
+ /* --- set new Callbacks --- */
+ pInstanceInfo->callbacks = pCallbacksCopy;
+
+ return SML_ERR_OK;
+}
+
+
+
+/**
+ * FUNCTION: smlSetUserData
+ *
+ * Sets a new Pointer to application specific user data,
+ * which is passed to all invoked callback functions
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: VoidPtr_t
+ * UserData is a pointer to a void structure the application
+ * can pass into the SyncML Toolkit instance info.
+ * It will be returned to the application with every called
+ * callback function call!
+ * NOTE: This is only a pointer, the memory object itself
+ * remains within the responsibility of the calling application.
+ * The memory object will not be copied, moved or freed by the
+ * Toolkit.
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlSetUserData(InstanceID_t id, VoidPtr_t pUserData)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- set new user data pointer ---*/
+ pInstanceInfo->userData=pUserData;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlGetUserData (added by luz %%%)
+ *
+ * Returns Pointer to application specific user data,
+ * which is passed to all invoked callback functions
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: *VoidPtr_t
+ * Receives current Userdata pointer
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlGetUserData(InstanceID_t id, VoidPtr_t *ppUserData)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- get userdata pointer ---*/
+ *ppUserData = pInstanceInfo->userData;
+
+ return SML_ERR_OK;
+} // smlGetUserData
+
+
+/**
+ * FUNCTION: smlGetEncoding (added by luz %%%)
+ *
+ * Returns Currently set encoding type
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: *SmlEncoding_t
+ * Receives current encoding
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlGetEncoding(InstanceID_t id, SmlEncoding_t *pEncoding)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ /* --- get encoding ---*/
+ *pEncoding = pInstanceInfo->instanceOptions->encoding;
+
+ return SML_ERR_OK;
+} // smlGetEncoding
+
+
+/**
+ * FUNCTION: smlSetEncoding
+ *
+ * Sets new encoding type for this Instance
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: SmlEncoding_t
+ * Type of Encoding to be used within this Instance
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+SML_API Ret_t smlSetEncoding(InstanceID_t id, SmlEncoding_t encoding)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+ /* --- Check pCallbacks, which have been passed by the application --- */
+ if (encoding==SML_UNDEF)
+ return SML_ERR_WRONG_USAGE;
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- free old callback structure ---*/
+ pInstanceInfo->instanceOptions->encoding = encoding;
+
+ return SML_ERR_OK;
+}
+#endif
+
+
+
+
+/**
+ * FUNCTION: smlLockReadBuffer
+ *
+ * Locks the workspace buffer, which is assigned to the given instance
+ * for reading. After this function is called, the application has
+ * access to the workspace buffer, beginning at the address pReadPosition which
+ * is returned by this function. SyncML will not change the workspace
+ * buffer until smlUnlockReadBuffer is called.
+ * pReadPosition returns a pointer to a valid position in the SyncML workspace
+ * buffer. The pointer can be used by the application for copying outgoing
+ * synchronization data from the buffer into some transport layer. usedSize
+ * retrieves the size of synchronization data currently stored in the
+ * workspace buffer beginning from the address to which pReadPosition points to.
+ * This information is needed by the application when copying XML code out
+ * of the buffer (while sending synchronization data)
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * OUT: MemPtr_t
+ * Workspace Pointer from which data can be read
+ *
+ * OUT: MemSize_t
+ * Size of used data in workspace which may be read
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlLockReadBuffer(InstanceID_t id, MemPtr_t *pReadPosition, MemSize_t *usedSize)
+{
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // must not be already locked here
+ if (pInstanceInfo->readLocked)
+ return SML_ERR_WRONG_USAGE;
+ // everything that is already written can also be read
+ *pReadPosition = pInstanceInfo->readPointer;
+ // used portion is what is between read and write pointers
+ *usedSize = pInstanceInfo->writePointer-pInstanceInfo->readPointer;
+ // lock
+ pInstanceInfo->readLocked=1;
+ #else
+ Ret_t rc;
+
+ LOCKTOOLKIT("smlLockReadBuffer");
+ /* --- Lock Workspace exclusively for reading and get a "Read" pointer --- */
+ rc = wsmLockH(id, SML_FIRST_DATA_ITEM, pReadPosition);
+ RELEASETOOLKIT("smlLockReadBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+
+ /* --- Check, how much data has to be read ---*/
+ LOCKTOOLKIT("smlLockReadBuffer");
+ rc = wsmGetUsedSize(id,usedSize);
+ RELEASETOOLKIT("smlLockReadBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+
+ return SML_ERR_OK;
+}
+
+
+
+
+/**
+ * FUNCTION: smlUnlockReadBuffer
+ *
+ * End the read access of the application to the workspace buffer.
+ * SyncML is now owner of the buffer again and is able to manipulate its contents.
+ * processedBytes passes the number of bytes, which the application has
+ * successfully read and processed (e.g. when the application has copied
+ * outgoing synchronization data from the workspace into a communication module).
+ * SyncML removes the given number of bytes from the workspace!
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: MemSize_t
+ * Actually read and processed bytes
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlUnlockReadBuffer(InstanceID_t id, MemSize_t processedBytes)
+{
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // must be already locked here
+ if (!pInstanceInfo->readLocked)
+ return SML_ERR_WRONG_USAGE;
+ // advance read pointer by number of bytes processed
+ if (pInstanceInfo->readPointer+processedBytes>pInstanceInfo->writePointer)
+ return SML_ERR_WRONG_USAGE; // too many bytes processed
+ // update read pointer
+ pInstanceInfo->readPointer+=processedBytes;
+ // auto-reset pointers if we have now read everything
+ if (pInstanceInfo->readPointer == pInstanceInfo->writePointer) {
+ // clear the buffer
+ mgrResetWorkspace(pInstanceInfo);
+ }
+ // unlock
+ pInstanceInfo->readLocked=0;
+ #else
+ Ret_t rc;
+
+ /* --- Pass the number of bytes which have been read --- */
+ LOCKTOOLKIT("smlUnlockReadBuffer");
+ rc = wsmProcessedBytes (id,processedBytes);
+ RELEASETOOLKIT("smlUnlockReadBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+
+ /* --- Unlock Workspace --- */
+ LOCKTOOLKIT("smlUnlockReadBuffer");
+ rc = wsmUnlockH(id);
+ RELEASETOOLKIT("smlUnlockReadBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+
+ return SML_ERR_OK;
+}
+
+
+#ifdef NOWSM
+
+/**
+ * FUNCTION: smlSetMaxOutgoingSize
+ *
+ * marks the current write pointer position as beginning of a new outgoing
+ * message. This is used to track outgoing message size while writing it
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: MemSize_t
+ * maximum size of outgoing message (0=no limit except buffer size)
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlSetMaxOutgoingSize(InstanceID_t id, MemSize_t maxOutgoingSize)
+{
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ // set max outgoing message size
+ pInstanceInfo->maxOutgoingSize = maxOutgoingSize;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlSetOutgoingBegin
+ *
+ * marks the current write pointer position as beginning of a new outgoing
+ * message. This is used to track outgoing message size while writing it
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlSetOutgoingBegin(InstanceID_t id)
+{
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ // remember current write pointer
+ pInstanceInfo->outgoingMsgStart=pInstanceInfo->writePointer;
+
+ return SML_ERR_OK;
+}
+
+#endif
+
+/**
+ * FUNCTION: smlLockWriteBuffer
+ *
+ * Locks the workspace buffer, which is assigned to the given
+ * instance for writing. After this function is called, the
+ * application has access to the workspace buffer, beginning
+ * at the address pWritePosition which is returned by this
+ * function. SyncML will not change the workspace buffer until
+ * smlUnlockWriteBuffer is called.
+ * pWritePosition returns a pointer to a valid position in the
+ * SyncML workspace buffer. The pointer can be used by the application
+ * for copying incoming synchronization data from some transport
+ * layer into the buffer. freeSize retrieves the maximum usable
+ * size of the workspace buffer beginning from the address to
+ * which pWritePosition points to. This information is needed by
+ * the application when copying XML code into the buffer (while
+ * receiving synchronization data)
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * OUT: MemPtr_t
+ * Workspace Pointer to which data can be written
+ *
+ * OUT: MemSize_t
+ * Max free Size of available space for data
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlLockWriteBuffer(InstanceID_t id, MemPtr_t *pWritePosition, MemSize_t *freeSize)
+{
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // must not be already locked here
+ if (pInstanceInfo->writeLocked)
+ return SML_ERR_WRONG_USAGE;
+ // return current write pointer
+ *pWritePosition = pInstanceInfo->writePointer;
+ // free portion is either determined by actual room in buffer, or maximum outgoing size if set
+ if (
+ pInstanceInfo->maxOutgoingSize &&
+ pInstanceInfo->outgoingMsgStart &&
+ pInstanceInfo->outgoingMsgStart<pInstanceInfo->writePointer
+ ) {
+ // calculate what is allowed according to maxOutgoingSize
+ *freeSize =
+ (pInstanceInfo->maxOutgoingSize) - // maximum outgoing size
+ (pInstanceInfo->writePointer-pInstanceInfo->outgoingMsgStart); // size of outgoing message so far
+ if (pInstanceInfo->writePointer+*freeSize > pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz) {
+ // actual space in buffer is smaller
+ *freeSize =
+ (pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz) - // end of buffer
+ pInstanceInfo->writePointer; // current write position
+ }
+ }
+ else {
+ // simply return available size in buffer
+ *freeSize =
+ (pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz) - // end of buffer
+ pInstanceInfo->writePointer; // current write position
+ }
+ // lock
+ pInstanceInfo->writeLocked=1;
+ #else
+ Ret_t rc;
+
+ /* --- Lock Workspace exclusively for writing and get a "Write" pointer --- */
+ LOCKTOOLKIT("smlLockWriteBuffer");
+ rc = wsmLockH(id, SML_FIRST_FREE_ITEM, pWritePosition);
+ RELEASETOOLKIT("smlLockWriteBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+
+ /* --- Check, how much free space is available for writing --- */
+ LOCKTOOLKIT("smlLockWriteBuffer");
+ rc = wsmGetFreeSize(id, freeSize);
+ RELEASETOOLKIT("smlLockWriteBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+
+ return SML_ERR_OK;
+}
+
+
+
+
+/**
+ * FUNCTION: smlUnlockWriteBuffer
+ *
+ * End the write access of the application to the workspace buffer.
+ * SyncML is now owner of the buffer again and is able to manipulate its
+ * contents. writtenBytes passes the number of bytes which have been
+ * written into the workspace buffer (e.g. when the application has copied
+ * incoming synchronization data from a communication module into the
+ * workspace). This information is needed by SyncML when processing received
+ * synchronization data.
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: MemSize_t
+ * Actually written bytes
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlUnlockWriteBuffer(InstanceID_t id, MemSize_t writtenBytes)
+{
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // must be already locked here
+ if (!pInstanceInfo->writeLocked)
+ return SML_ERR_WRONG_USAGE;
+ if (writtenBytes > 0) {
+ // advance write pointer by number of bytes written
+ if (pInstanceInfo->writePointer+writtenBytes>pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz)
+ return SML_ERR_WRONG_USAGE; // too many bytes written
+ // update write pointer
+ pInstanceInfo->writePointer+=writtenBytes;
+ }
+ // unlock
+ pInstanceInfo->writeLocked=0;
+ #else
+ Ret_t rc;
+
+ if (writtenBytes > 0)
+ {
+ /* --- Pass the number of bytes which have been written --- */
+ LOCKTOOLKIT("smlUnlockWriteBuffer");
+ rc = wsmSetUsedSize(id,writtenBytes);
+ RELEASETOOLKIT("smlUnlockWriteBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ }
+ /* --- Unlock Workspace --- */
+ LOCKTOOLKIT("smlUnlockWriteBuffer");
+ rc = wsmUnlockH(id);
+ RELEASETOOLKIT("smlUnlockWriteBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+
+ return SML_ERR_OK;
+}
+
+
+
+
+/*************************************************************************
+ * SyncML internal functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: mgrResetWorkspace
+ * Reset the Workspace Buffer position to the beginning of the workspace
+ * (clears all data in the buffer)
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+Ret_t mgrResetWorkspace (InstanceID_t id) {
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ pInstanceInfo->readPointer=pInstanceInfo->instanceBuffer;
+ pInstanceInfo->writePointer=pInstanceInfo->instanceBuffer;
+ pInstanceInfo->outgoingMsgStart=NULL; // no outgoing message in the buffer
+ return SML_ERR_OK; // ok
+ #else
+ Ret_t rc;
+ LOCKTOOLKIT("mgrResetWorkspace");
+ rc=wsmReset (id);
+ RELEASETOOLKIT("mgrResetWorkspace");
+ return rc;
+ #endif
+}
+
+
+
+/**
+ * FUNCTION: setInstanceOptions
+ *
+ * the options settings of an instance are set to a new value
+ *
+ * IN: InstanceID_t
+ * Instance ID assigned to the instance
+ *
+ * IN: SmlInstanceOptionsPtr_t
+ * New option settings of that particular SyncML instance
+ * NOTE: only the encoding can be changed during life-time
+ * of an instance
+ * The other parameters of the instance options
+ * (workspace size and name cannot be changed)
+ *
+ * RETURN: Ret_t
+ * Error Code
+ */
+Ret_t setInstanceOptions (InstanceID_t id, SmlInstanceOptionsPtr_t pOptions)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+ SmlInstanceOptionsPtr_t pOptionsCopy;
+
+
+ #ifdef NOWSM
+ /* --- Ckeck pOptions, which have been passed by the application --- */
+ if (!pOptions || (pOptions->encoding==SML_UNDEF))
+ return SML_ERR_WRONG_USAGE;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Ckeck pOptions, which have been passed by the application --- */
+ if (!pOptions || !pOptions->workspaceName|| (pOptions->encoding==SML_UNDEF))
+ return SML_ERR_WRONG_USAGE;
+
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ /* --- free old instance options ---*/
+ freeInstanceOptions(pInstanceInfo);
+
+ /* --- Use a copy of pOptionsCopy --- */
+ pOptionsCopy = (SmlInstanceOptionsPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlInstanceOptions_t));
+ if (pOptionsCopy==NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemcpy(pOptionsCopy,pOptions,(MemSize_t)sizeof(SmlInstanceOptions_t));
+
+ #ifndef NOWSM
+ pOptionsCopy->workspaceName=smlLibStrdup(pOptions->workspaceName);
+
+ if (pOptionsCopy->workspaceName == NULL) {
+ pInstanceInfo->instanceOptions=NULL;
+ smlLibFree(pOptionsCopy);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ #endif
+
+ /* --- Assign the new options --- */
+ pInstanceInfo->instanceOptions=pOptionsCopy;
+
+
+ /* --- Let the new settingds take effect --- */
+ /* --- Adjust workspace size ---*/
+ /* --- Change workspace name ---*/
+ // NOT SUPPORTED FOR YELLOW
+
+ return SML_ERR_OK;
+}
+
+
+
+/**
+ * FUNCTION: freeInstanceOptions
+ * Free Instances Options
+ *
+ * RETURN: InstanceInfoPtr_t
+ * Pointer to the pInstance Info, which options should be freed
+ */
+Ret_t freeInstanceOptions (InstanceInfoPtr_t pInfo) {
+
+ /* --- Delete instance options (if there are any) --- */
+ if (pInfo->instanceOptions!=NULL) {
+ #ifndef NOWSM
+ if (pInfo->instanceOptions->workspaceName!=NULL)
+ smlLibFree(pInfo->instanceOptions->workspaceName); // don't forget the substructures
+ #endif
+ smlLibFree(pInfo->instanceOptions);
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION:
+ * Free the memory of an removed Instance Info (including referenced sub structures)
+ *
+ * IN: InstanceID_t
+ * ID of the InstanceInfo structure to be freed
+ */
+static Ret_t freeInstanceInfo(InstanceInfoPtr_t pInfo) {
+
+ if (pInfo) {
+
+ #ifdef NOWSM
+ // return the instance buffer
+ if (pInfo->instanceBuffer)
+ smlLibFree(pInfo->instanceBuffer);
+ #else
+ if (pInfo->workspaceState)
+ smlLibFree(pInfo->workspaceState);
+ #endif
+ if (pInfo->encoderState)
+ smlLibFree(pInfo->encoderState);
+ if (pInfo->decoderState)
+ smlLibFree(pInfo->decoderState);
+ if (pInfo->callbacks)
+ smlLibFree(pInfo->callbacks);
+
+ freeInstanceOptions(pInfo);
+
+ smlLibFree(pInfo);
+ }
+
+ return SML_ERR_OK;
+}
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrutil.c b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrutil.c
new file mode 100644
index 0000000..70df177
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/mgr/src/mgrutil.c
@@ -0,0 +1,1694 @@
+/*************************************************************************/
+/* module: some helper functions */
+/* */
+/* file: mgrutil.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <sml.h>
+#include <smldtd.h>
+#include <smldef.h>
+#include <smlerr.h>
+#include <smlmetinfdtd.h>
+#include <smldevinfdtd.h>
+#include <smldmtnddtd.h>
+#include "libmem.h"
+#include "libstr.h"
+#include "liblock.h"
+#include "mgr.h"
+#include "mgrutil.h"
+
+
+/*************************************************************************
+ * Exported SyncML API functions
+ *************************************************************************/
+
+/**
+ * FUNCTION: smlFreeProtoElement
+ *
+ * frees all allocated memory of a smlProtoElement
+ *
+ * IN: VoidPtr_t
+ * Element to free
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlFreeProtoElement(VoidPtr_t pProtoElement)
+{
+ if (! pProtoElement)
+ return(SML_ERR_OK);
+
+ switch (((SmlUnknownProtoElementPtr_t)pProtoElement)->elementType) {
+
+ case SML_PE_HEADER:
+ smlFreeSyncHdr((SmlSyncHdrPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_SYNC_START:
+ smlFreeSync((SmlSyncPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_ADD:
+ case SML_PE_COPY:
+ case SML_PE_REPLACE:
+ case SML_PE_DELETE:
+ case SML_PE_GENERIC:
+ smlFreeGeneric((SmlGenericCmdPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_ALERT:
+ smlFreeAlert((SmlAlertPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_ATOMIC_START:
+ case SML_PE_SEQUENCE_START:
+ case SML_PE_CMD_GROUP:
+ smlFreeAtomic((SmlAtomicPtr_t)pProtoElement);
+ break;
+
+#if (defined EXEC_SEND || defined EXEC_RECEIVE)
+ case SML_PE_EXEC:
+ smlFreeExec((SmlExecPtr_t)pProtoElement);
+ break;
+#endif
+
+ case SML_PE_PUT:
+ case SML_PE_GET:
+ case SML_PE_PUT_GET:
+ smlFreeGetPut((SmlPutPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_MAP:
+ smlFreeMap((SmlMapPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_RESULTS:
+ smlFreeResults((SmlResultsPtr_t)pProtoElement);
+ break;
+
+#if (defined SEARCH_SEND || defined SEARCH_RECEIVE)
+ case SML_PE_SEARCH:
+ smlFreeSearch((SmlSearchPtr_t)pProtoElement);
+ break;
+#endif
+ case SML_PE_STATUS:
+ smlFreeStatus((SmlStatusPtr_t)pProtoElement);
+ break;
+
+ default:
+ return(SML_ERR_A_UTI_UNKNOWN_PROTO_ELEMENT);
+ }
+
+ return(SML_ERR_OK);
+}
+
+
+/**
+ * FUNCTION: smlFreePcdata
+ *
+ * frees the Memory of an allocated Pcdata memory object
+ *
+ * IN: SmlPcdataPtr_t
+ * A Pointer to a PcData structure, which should be freed
+ *
+ * RETURN: ---
+ *
+ */
+SML_API void smlFreePcdata(SmlPcdataPtr_t pPcdata)
+{
+ if (! pPcdata)
+ return;
+
+ if (pPcdata->contentType == SML_PCDATA_EXTENSION) {
+ switch ((int)pPcdata->extension) {
+#ifdef __USE_METINF__
+ case SML_EXT_METINF:
+ smlFreeMetinfMetinf(pPcdata->content);
+ smlLibFree(pPcdata);
+ break;
+#endif
+#ifdef __USE_DEVINF__
+ case SML_EXT_DEVINF:
+ smlFreeDevInfDevInf(pPcdata->content);
+ smlLibFree(pPcdata);
+ break;
+#endif
+#ifdef __USE_DMTND__
+ case SML_EXT_DMTND:
+ smlFreeDmTnd(pPcdata->content);
+ smlLibFree(pPcdata);
+ break;
+#endif
+ }
+ return;
+ }
+
+ if (pPcdata->content)
+ smlLibFree(pPcdata->content);
+
+ smlLibFree(pPcdata);
+}
+
+
+SML_API void smlFreePcdataList(SmlPcdataListPtr_t list) {
+ if (!list) return;
+ smlFreePcdataList(list->next);
+ smlFreePcdata(list->data);
+ smlLibFree(list);
+ return;
+}
+
+#ifdef __USE_METINF__
+/** Subfunctions to smlFreePcdata, to freeup MetaInf DTD structures **/
+SML_API void smlFreeMetinfMetinf(SmlMetInfMetInfPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->format);
+ smlFreePcdata(data->type);
+ smlFreePcdata(data->mark);
+ smlFreePcdata(data->size);
+ smlFreePcdata(data->version);
+ smlFreePcdata(data->nextnonce);
+ smlFreePcdata(data->maxmsgsize);
+ /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+ smlFreePcdata(data->maxobjsize);
+ smlFreeMetinfAnchor(data->anchor);
+ smlFreeMetinfMem(data->mem);
+ smlFreePcdataList(data->emi);
+ smlLibFree(data);
+ return;
+}
+SML_API void smlFreeMetinfAnchor(SmlMetInfAnchorPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->last);
+ smlFreePcdata(data->next);
+ smlLibFree(data);
+ return;
+}
+SML_API void smlFreeMetinfMem(SmlMetInfMemPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->shared);
+ smlFreePcdata(data->free);
+ smlFreePcdata(data->freeid);
+ smlLibFree(data);
+ return;
+}
+#endif
+
+#ifdef __USE_DEVINF__
+/** Subfunctions to smlFreePcdata, to freeup DevInf DTD structures **/
+SML_API void smlFreeDevInfDevInf(SmlDevInfDevInfPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->verdtd);
+ smlFreePcdata(data->man);
+ smlFreePcdata(data->mod);
+ smlFreePcdata(data->oem);
+ smlFreePcdata(data->fwv);
+ smlFreePcdata(data->hwv);
+ smlFreePcdata(data->swv);
+ smlFreePcdata(data->devid);
+ smlFreePcdata(data->devtyp);
+ smlFreeDevInfDatastoreList(data->datastore);
+ smlFreeDevInfExtList(data->ext);
+ smlFreeDevInfCtcapList(data->ctcap);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfDatastore(SmlDevInfDatastorePtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->sourceref);
+ smlFreePcdata(data->displayname);
+ smlFreePcdata(data->maxguidsize);
+ smlFreeDevInfXmit(data->rxpref);
+ smlFreeDevInfXmit(data->txpref);
+ smlFreeDevInfXmitList(data->rx);
+ smlFreeDevInfXmitList(data->tx);
+ smlFreeDevInfDSMem(data->dsmem);
+ smlFreeDevInfSynccap(data->synccap);
+ smlLibFree(data);
+ return;
+}
+SML_API void smlFreeDevInfDatastoreList(SmlDevInfDatastoreListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfDatastore(data->data);
+ smlFreeDevInfDatastoreList(data->next);
+ smlLibFree(data);
+ return;
+}
+SML_API void smlFreeDevInfXmitList(SmlDevInfXmitListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfXmit(data->data);
+ smlFreeDevInfXmitList(data->next);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfXmit(SmlDevInfXmitPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->cttype);
+ smlFreePcdata(data->verct);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfDSMem(SmlDevInfDSMemPtr_t data) {
+ if (!data) return;
+ // %%%luz:2003-04-28: this is now a flag! smlFreePcdata(data->shared);
+ smlFreePcdata(data->maxmem);
+ smlFreePcdata(data->maxid);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfSynccap(SmlDevInfSyncCapPtr_t data) {
+ if (!data) return;
+ smlFreePcdataList(data->synctype);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfExt(SmlDevInfExtPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->xnam);
+ smlFreePcdataList(data->xval);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfExtList(SmlDevInfExtListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfExt(data->data);
+ smlFreeDevInfExtList(data->next);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfCTData(SmlDevInfCTDataPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->name);
+ smlFreePcdata(data->dname);
+ smlFreePcdataList(data->valenum);
+ smlFreePcdata(data->datatype);
+ smlFreePcdata(data->size);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfCTDataProp(SmlDevInfCTDataPropPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfCTData(data->prop);
+ smlFreeDevInfCTDataList(data->param);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDevInfCTDataList(SmlDevInfCTDataListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfCTData(data->data);
+ smlFreeDevInfCTDataList(data->next);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDevInfCTDataPropList(SmlDevInfCTDataPropListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfCTDataProp(data->data);
+ smlFreeDevInfCTDataPropList(data->next);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDevInfCTCap(SmlDevInfCTCapPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->cttype);
+ smlFreeDevInfCTDataPropList(data->prop);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDevInfCtcapList(SmlDevInfCtcapListPtr_t data) {
+ if (!data) return;
+
+ smlFreeDevInfCTCap(data->data);
+ smlFreeDevInfCtcapList(data->next);
+ smlLibFree(data);
+}
+#endif
+
+#ifdef __USE_DMTND__
+/** Subfunctions to smlFreePcdata, to freeup DM TND DTD structures **/
+SML_API void smlFreeDmTndFormat(SmlDmTndFormatPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->value);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndType(SmlDmTndTypePtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->mime);
+ smlFreePcdata(data->ddfname);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndDFElement(SmlDmTndDFElementPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->value);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndRTProps(SmlDmTndRTPropsPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->acl);
+ smlFreeDmTndFormat(data->format);
+ smlFreePcdata(data->name);
+ smlFreePcdata(data->size);
+ smlFreePcdata(data->title);
+ smlFreePcdata(data->tstamp);
+ smlFreeDmTndType(data->type);
+ smlFreePcdata(data->verno);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndDFProps(SmlDmTndDFPropsPtr_t data) {
+ if (!data) return;
+ smlFreeDmTndDFElement(data->accesstype);
+ smlFreePcdata(data->defaultvalue);
+ smlFreePcdata(data->description);
+ smlFreeDmTndFormat(data->dfformat);
+ smlFreeDmTndDFElement(data->occurrence);
+ smlFreeDmTndDFElement(data->scope);
+ smlFreePcdata(data->dftitle);
+ smlFreeDmTndType(data->dftype);
+ smlFreeDmTndDFElement(data->casesense);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndNodeList(SmlDmTndNodeListPtr_t data);
+
+SML_API void smlFreeDmTndNode(SmlDmTndNodePtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->nodename);
+ smlFreePcdata(data->path);
+ smlFreeDmTndRTProps(data->rtprops);
+ smlFreeDmTndDFProps(data->dfprops);
+ smlFreePcdata(data->value);
+ smlFreeDmTndNodeList(data->nodelist);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndNodeList(SmlDmTndNodeListPtr_t data) {
+ if (!data) return;
+ smlFreeDmTndNode(data->node);
+ smlFreeDmTndNodeList(data->next);
+ smlLibFree(data);
+ return;
+}
+
+SML_API void smlFreeDmTnd(SmlDmTndPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->verdtd);
+ smlFreePcdata(data->man);
+ smlFreePcdata(data->mod);
+ smlFreeDmTndNodeList(data->nodelist);
+ smlLibFree(data);
+ return;
+}
+#endif
+
+/*************************************************************************
+ * Exported SyncML API functions (FULL-SIZE TOOLKIT ONLY)
+ *************************************************************************/
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+
+/**
+ * FUNCTION: smlGetFreeBuffer
+ *
+ * Return amount of unused Workspace memory
+ *
+ * RETURN: MemSize_t
+ * Amount of unused Workspace memory
+ *
+ */
+SML_API MemSize_t smlGetFreeBuffer(InstanceID_t id)
+{
+ /* Definitions */
+ MemSize_t freeMem=0;
+
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return 0; // no buffer if no instance there
+ freeMem =
+ (pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz) - // end of buffer
+ pInstanceInfo->writePointer; // current write pointer
+ #else
+ /* ask the Workspace Buffer */
+ LOCKTOOLKIT("smlGetFreeBuffer");
+ wsmGetFreeSize(id, &freeMem);
+ RELEASETOOLKIT("smlGetFreeBuffer");
+ #endif
+
+ return (MemSize_t)freeMem;
+}
+
+
+/**
+ * FUNCTION: smlString2Pcdata
+ *
+ * copy a string into a Pcdata structure
+ *
+ * IN: String_t
+ * Input String
+ *
+ * RETURN: SmlPcdataPtr_t
+ * A Pointer to a PcData structure
+ *
+ */
+SML_API SmlPcdataPtr_t smlString2Pcdata(String_t str)
+{
+ /* Definitions */
+ SmlPcdataPtr_t pcdata;
+
+ /* Invalid Input */
+ if (! str)
+ return NULL;
+
+ /* Allocate the PcData Structure */
+ pcdata = (SmlPcdataPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlPcdata_t));
+ if (! pcdata)
+ return NULL;
+ smlLibMemset (pcdata, 0, (MemSize_t)sizeof(SmlPcdata_t));
+
+ /* Set the PcData Structure */
+ pcdata->contentType = SML_PCDATA_STRING;
+ pcdata->length = smlLibStrlen( str );
+ pcdata->content = (VoidPtr_t)smlLibStrdup(str);
+
+ return pcdata;
+}
+
+
+/**
+ * FUNCTION: smlPcdata2String
+ *
+ * copy a Pcdata structure into a string
+ *
+ * IN: SmlPcdataPtr_t
+ * A Pointer to a PcData structure
+ * RETURN: String_t
+ * Input String
+ *
+ */
+SML_API String_t smlPcdata2String(SmlPcdataPtr_t pcdata)
+{
+ /* Definitions */
+ String_t str;
+
+ /* Invalid Input */
+ if (! pcdata)
+ return NULL;
+
+ /* Allocate the String */
+ str = (String_t)smlLibMalloc((MemSize_t)(pcdata->length+1));
+ if (str == NULL)
+ return NULL;
+
+ /* Copy the string into the allocated data structure */
+ smlLibMemcpy((MemPtr_t)str, (MemPtr_t)pcdata->content, pcdata->length);
+ *(str + pcdata->length) = '\0';
+
+ return str;
+}
+
+
+/**
+ * FUNCTION: smlPcdataDup
+ *
+ * Duplicates a Pcdata memory object
+ *
+ * IN: SmlPcdataPtr_t
+ * A Pointer to the original PcData structure
+ *
+ * RETURN: SmlPcdataPtr_t
+ * A Pointer to the copy of the PcData structure
+ *
+ */
+SML_API SmlPcdataPtr_t smlPcdataDup(SmlPcdataPtr_t pcdata)
+{
+ /* Definitions */
+ SmlPcdataPtr_t newPcdata;
+
+ /* Invalid Input */
+ if (! pcdata)
+ return NULL;
+
+ /* Allocate the new pcdata memory object */
+ newPcdata = (SmlPcdataPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlPcdata_t));
+ if (! newPcdata)
+ return NULL;
+ smlLibMemset (newPcdata, 0, (MemSize_t)sizeof(SmlPcdata_t));
+
+ /* Set the PcData Structure */
+ newPcdata->contentType = pcdata->contentType;
+ newPcdata->length = pcdata->length;
+ newPcdata->content =(VoidPtr_t)smlLibMalloc((MemSize_t)pcdata->length+1);
+ if (newPcdata->content ==NULL)
+ {
+ smlLibFree(newPcdata->content);
+ smlLibFree(newPcdata);
+ return NULL;
+ }
+ smlLibMemset(newPcdata->content, 0, (MemSize_t)((pcdata->length)+1));
+ smlLibMemcpy(newPcdata->content, pcdata->content, (MemSize_t)pcdata->length);
+
+ return newPcdata;
+}
+
+#endif
+
+SML_API void smlFreeSyncHdr(SmlSyncHdrPtr_t pSyncHdr)
+{
+ if (! pSyncHdr)
+ return;
+
+ smlFreePcdata(pSyncHdr->version);
+ smlFreePcdata(pSyncHdr->proto);
+ smlFreePcdata(pSyncHdr->sessionID);
+ smlFreePcdata(pSyncHdr->msgID);
+ smlFreePcdata(pSyncHdr->respURI);
+ smlFreePcdata(pSyncHdr->meta);
+
+ smlFreeSourceTargetPtr(pSyncHdr->source);
+ smlFreeSourceTargetPtr(pSyncHdr->target);
+
+ smlFreeCredPtr(pSyncHdr->cred);
+
+ smlLibFree(pSyncHdr);
+}
+
+
+SML_API void smlFreeSync(SmlSyncPtr_t pSync)
+{
+ if (! pSync)
+ return;
+
+ smlFreePcdata(pSync->cmdID);
+ smlFreePcdata(pSync->meta);
+
+ smlFreeSourceTargetPtr(pSync->source);
+ smlFreeSourceTargetPtr(pSync->target);
+
+ smlFreeCredPtr(pSync->cred);
+
+ smlLibFree(pSync);
+}
+
+
+SML_API void smlFreeGeneric(SmlGenericCmdPtr_t pGenericCmd)
+{
+ if (! pGenericCmd)
+ return;
+
+ smlFreePcdata(pGenericCmd->cmdID);
+ smlFreePcdata(pGenericCmd->meta);
+
+ smlFreeCredPtr(pGenericCmd->cred);
+
+ smlFreeItemList(pGenericCmd->itemList);
+
+ smlLibFree(pGenericCmd);
+}
+
+
+SML_API void smlFreeAlert(SmlAlertPtr_t pAlert)
+{
+ if (! pAlert)
+ return;
+
+ smlFreePcdata(pAlert->cmdID);
+ smlFreePcdata(pAlert->data);
+
+ smlFreeCredPtr(pAlert->cred);
+
+ smlFreeItemList(pAlert->itemList);
+ smlFreePcdata(pAlert->correlator);
+
+ smlLibFree(pAlert);
+}
+
+
+SML_API void smlFreeAtomic(SmlAtomicPtr_t pAtomic)
+{
+ if (! pAtomic)
+ return;
+
+ smlFreePcdata(pAtomic->cmdID);
+ smlFreePcdata(pAtomic->meta);
+
+ smlLibFree(pAtomic);
+}
+
+#if (defined EXEC_SEND || defined EXEC_RECEIVE)
+
+SML_API void smlFreeExec(SmlExecPtr_t pExec)
+{
+ if (! pExec)
+ return;
+
+ smlFreePcdata(pExec->cmdID);
+
+ smlFreeCredPtr(pExec->cred);
+
+ smlFreeItemPtr(pExec->item);
+
+ smlFreePcdata(pExec->correlator);
+
+ smlLibFree(pExec);
+}
+
+#endif
+
+SML_API void smlFreeGetPut(SmlPutPtr_t pGetPut)
+{
+ if (! pGetPut)
+ return;
+
+ smlFreePcdata(pGetPut->cmdID);
+ smlFreePcdata(pGetPut->meta);
+ smlFreePcdata(pGetPut->lang);
+
+ smlFreeCredPtr(pGetPut->cred);
+
+ smlFreeItemList(pGetPut->itemList);
+
+ smlLibFree(pGetPut);
+}
+
+
+SML_API void smlFreeMap(SmlMapPtr_t pMap)
+{
+ if (! pMap)
+ return;
+
+ smlFreePcdata(pMap->cmdID);
+ smlFreePcdata(pMap->meta);
+
+ smlFreeCredPtr(pMap->cred);
+
+ smlFreeSourceTargetPtr(pMap->source);
+ smlFreeSourceTargetPtr(pMap->target);
+
+ smlFreeMapItemList(pMap->mapItemList);
+
+ smlLibFree(pMap);
+}
+
+
+SML_API void smlFreeResults(SmlResultsPtr_t pResults)
+{
+ if (! pResults)
+ return;
+
+ smlFreePcdata(pResults->cmdID);
+ smlFreePcdata(pResults->msgRef);
+ smlFreePcdata(pResults->cmdRef);
+ smlFreePcdata(pResults->meta);
+ smlFreePcdata(pResults->targetRef);
+ smlFreePcdata(pResults->sourceRef);
+
+ smlFreeItemList(pResults->itemList);
+
+ smlLibFree(pResults);
+}
+
+#if (defined SEARCH_SEND || defined SEARCH_RECEIVE)
+
+SML_API void smlFreeSearch(SmlSearchPtr_t pSearch)
+{
+ if (! pSearch)
+ return;
+
+ smlFreePcdata(pSearch->cmdID);
+ smlFreePcdata(pSearch->lang);
+ smlFreePcdata(pSearch->meta);
+ smlFreePcdata(pSearch->data);
+
+ smlFreeCredPtr(pSearch->cred);
+
+ smlFreeSourceTargetPtr(pSearch->target);
+
+ smlFreeSourceList(pSearch->sourceList);
+
+ smlLibFree(pSearch);
+}
+
+#endif
+
+SML_API void smlFreeStatus(SmlStatusPtr_t pStatus)
+{
+ if (! pStatus)
+ return;
+
+ smlFreePcdata(pStatus->cmdID);
+ smlFreePcdata(pStatus->msgRef);
+ smlFreePcdata(pStatus->cmdRef);
+ smlFreePcdata(pStatus->cmd);
+ smlFreePcdata(pStatus->data);
+
+ smlFreeCredPtr(pStatus->cred);
+ smlFreeChalPtr(pStatus->chal);
+
+ smlFreeTargetRefList(pStatus->targetRefList);
+ smlFreeSourceRefList(pStatus->sourceRefList);
+
+ smlFreeItemList(pStatus->itemList);
+
+ smlLibFree(pStatus);
+}
+
+
+SML_API void smlFreeCredPtr(SmlCredPtr_t pCred)
+{
+ if (! pCred)
+ return;
+
+ smlFreePcdata(pCred->meta);
+ smlFreePcdata(pCred->data);
+
+ smlLibFree(pCred);
+}
+
+
+SML_API void smlFreeChalPtr(SmlChalPtr_t pChal)
+{
+ if (! pChal)
+ return;
+
+ smlFreePcdata(pChal->meta);
+
+ smlLibFree(pChal);
+}
+
+
+SML_API void smlFreeSourceTargetPtr(SmlSourcePtr_t pSourceTarget)
+{
+ if (! pSourceTarget)
+ return;
+
+ smlFreePcdata(pSourceTarget->locURI);
+ smlFreePcdata(pSourceTarget->locName);
+
+ smlLibFree(pSourceTarget);
+}
+
+
+SML_API void smlFreeSourceList(SmlSourceListPtr_t pSourceList)
+{
+ SmlSourceListPtr_t pTmp;
+
+ while (pSourceList) {
+ pTmp = pSourceList->next;
+ smlFreeSourceTargetPtr(pSourceList->source);
+ smlLibFree(pSourceList);
+ pSourceList = pTmp;
+ }
+}
+
+
+SML_API void smlFreeSourceRefList(SmlSourceRefListPtr_t pSourceRefList)
+{
+ SmlSourceRefListPtr_t pTmp;
+
+ while (pSourceRefList) {
+ pTmp = pSourceRefList->next;
+ smlFreePcdata(pSourceRefList->sourceRef);
+ smlLibFree(pSourceRefList);
+ pSourceRefList = pTmp;
+ }
+}
+
+
+SML_API void smlFreeTargetRefList(SmlTargetRefListPtr_t pTargetRefList)
+{
+ SmlTargetRefListPtr_t pTmp;
+
+ while (pTargetRefList) {
+ pTmp = pTargetRefList->next;
+ smlFreePcdata(pTargetRefList->targetRef);
+ smlLibFree(pTargetRefList);
+ pTargetRefList = pTmp;
+ }
+}
+
+
+SML_API void smlFreeItemPtr(SmlItemPtr_t pItem)
+{
+ if (! pItem)
+ return;
+
+ smlFreePcdata(pItem->meta);
+ smlFreePcdata(pItem->data);
+
+ smlFreeSourceTargetPtr(pItem->source);
+ smlFreeSourceTargetPtr(pItem->target);
+
+ smlLibFree(pItem);
+}
+
+
+SML_API void smlFreeItemList(SmlItemListPtr_t pItemList)
+{
+ SmlItemListPtr_t pTmp;
+
+ while (pItemList) {
+ pTmp = pItemList->next;
+ smlFreeItemPtr(pItemList->item);
+ smlLibFree(pItemList);
+ pItemList = pTmp;
+ }
+}
+
+
+SML_API void smlFreeMapItemPtr(SmlMapItemPtr_t pMapItem)
+{
+ if (! pMapItem)
+ return;
+
+ smlFreeSourceTargetPtr(pMapItem->source);
+ smlFreeSourceTargetPtr(pMapItem->target);
+
+ smlLibFree(pMapItem);
+}
+
+
+SML_API void smlFreeMapItemList(SmlMapItemListPtr_t pMapItemList)
+{
+ SmlMapItemListPtr_t pTmp;
+
+ while (pMapItemList) {
+ pTmp = pMapItemList->next;
+ smlFreeMapItemPtr(pMapItemList->mapItem);
+ smlLibFree(pMapItemList);
+ pMapItemList = pTmp;
+ }
+}
+
+#ifdef __USE_ALLOCFUNCS__
+/* Helperfunctions, that allocate and preset SyncML C structs */
+SML_API SmlPcdataPtr_t smlAllocPcdata() {
+ SmlPcdataPtr_t p = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlPcdata_t));
+ return p;
+}
+
+SML_API SmlPcdataListPtr_t smlAllocPcdataList() {
+ SmlPcdataListPtr_t p = (SmlPcdataListPtr_t)smlLibMalloc(sizeof(SmlPcdataList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlPcdataList_t));
+ p->data = smlAllocPcdata();
+ if (p->data == NULL) {
+ smlFreePcdataList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlChalPtr_t smlAllocChal() {
+ SmlChalPtr_t p = (SmlChalPtr_t)smlLibMalloc(sizeof(SmlChal_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlChal_t));
+ p->meta = smlAllocPcdata();
+ if (p->meta == NULL) {
+ smlFreeChalPtr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlCredPtr_t smlAllocCred() {
+ SmlCredPtr_t p = (SmlCredPtr_t)smlLibMalloc(sizeof(SmlCred_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlCred_t));
+ p->data = smlAllocPcdata();
+ if (p->data == NULL) {
+ smlFreeCredPtr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlSourcePtr_t smlAllocSource() {
+ SmlSourcePtr_t p = (SmlSourcePtr_t)smlLibMalloc(sizeof(SmlSource_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSource_t));
+ p->locURI = smlAllocPcdata();
+ if (p->locURI == NULL) {
+ smlFreeSourceTargetPtr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlTargetPtr_t smlAllocTarget() {
+ return smlAllocSource();
+}
+
+SML_API SmlSourceListPtr_t smlAllocSourceList() {
+ SmlSourceListPtr_t p = (SmlSourceListPtr_t)smlLibMalloc(sizeof(SmlSourceList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSourceList_t));
+ p->source = smlAllocSource();
+ if (p->source == NULL) {
+ smlFreeSourceList(p);
+ return NULL;
+ }
+ return p;
+}
+
+
+SML_API SmlSyncHdrPtr_t smlAllocSyncHdr() {
+ SmlSyncHdrPtr_t p = (SmlSyncHdrPtr_t)smlLibMalloc(sizeof(SmlSyncHdr_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSyncHdr_t));
+ p->elementType = SML_PE_HEADER;
+ p->version = smlAllocPcdata();
+ if (p->version == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->proto = smlAllocPcdata();
+ if (p->proto == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->sessionID = smlAllocPcdata();
+ if (p->sessionID == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->msgID = smlAllocPcdata();
+ if (p->msgID == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->target = smlAllocTarget();
+ if (p->target == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->source = smlAllocSource();
+ if (p->source == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlItemPtr_t smlAllocItem() {
+ SmlItemPtr_t p = (SmlItemPtr_t)smlLibMalloc(sizeof(SmlItem_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlItem_t));
+ return p;
+}
+
+SML_API SmlItemListPtr_t smlAllocItemList() {
+ SmlItemListPtr_t p = (SmlItemListPtr_t)smlLibMalloc(sizeof(SmlItemList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlItemList_t));
+ p->item = smlAllocItem();
+ if (p->item == NULL) {
+ smlFreeItemList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlGenericCmdPtr_t smlAllocGeneric() {
+ SmlGenericCmdPtr_t p = (SmlGenericCmdPtr_t)smlLibMalloc(sizeof(SmlGenericCmd_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlGenericCmd_t));
+ p->elementType = SML_PE_GENERIC;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeGeneric(p);
+ return NULL;
+ }
+ p->itemList = smlAllocItemList();
+ if (p->itemList == NULL) {
+ smlFreeGeneric(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlAddPtr_t smlAllocAdd() {
+ SmlAddPtr_t p = smlAllocGeneric();
+ if (p == NULL) return p;
+ p->elementType = SML_PE_ADD;
+ return p;
+}
+
+SML_API SmlCopyPtr_t smlAllocCopy() {
+ SmlCopyPtr_t p = smlAllocGeneric();
+ if (p == NULL) return p;
+ p->elementType = SML_PE_COPY;
+ return p;
+}
+
+SML_API SmlReplacePtr_t smlAllocReplace() {
+ SmlReplacePtr_t p = smlAllocGeneric();
+ if (p == NULL) return p;
+ p->elementType = SML_PE_REPLACE;
+ return p;
+}
+
+SML_API SmlDeletePtr_t smlAllocDelete() {
+ SmlDeletePtr_t p = smlAllocGeneric();
+ if (p == NULL) return p;
+ p->elementType = SML_PE_DELETE;
+ return p;
+}
+
+SML_API SmlAlertPtr_t smlAllocAlert() {
+ SmlAlertPtr_t p = (SmlAlertPtr_t)smlLibMalloc(sizeof(SmlAlert_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlAlert_t));
+ p->elementType = SML_PE_ALERT;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeAlert(p);
+ return NULL;
+ }
+ p->itemList = smlAllocItemList();
+ if (p->itemList == NULL) {
+ smlFreeAlert(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlAtomicPtr_t smlAllocAtomic() {
+ SmlAtomicPtr_t p = (SmlAtomicPtr_t)smlLibMalloc(sizeof(SmlAtomic_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlAtomic_t));
+ p->elementType = SML_PE_ATOMIC_START;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeAtomic(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlSequencePtr_t smlAllocSequence() {
+ SmlSequencePtr_t p = smlAllocAtomic();
+ if (p == NULL) return NULL;
+ p->elementType = SML_PE_SEQUENCE_START;
+ return p;
+}
+
+SML_API SmlSyncPtr_t smlAllocSync() {
+ SmlSyncPtr_t p = (SmlSyncPtr_t)smlLibMalloc(sizeof(SmlSync_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSync_t));
+ p->elementType = SML_PE_SYNC_START;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeSync(p);
+ return NULL;
+ }
+ return p;
+}
+
+#if defined(EXEC_SEND) || defined(EXEC_RECEIVE)
+SML_API SmlExecPtr_t smlAllocExec() {
+ SmlExecPtr_t p = (SmlExecPtr_t)smlLibMalloc(sizeof(SmlExec_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlExec_t));
+ p->elementType = SML_PE_EXEC;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeExec(p);
+ return NULL;
+ }
+ p->item = smlAllocItem();
+ if (p->item == NULL) {
+ smlFreeExec(p);
+ return NULL;
+ }
+ return p;
+}
+#endif
+
+SML_API SmlGetPtr_t smlAllocGet() {
+ SmlGetPtr_t p = (SmlGetPtr_t)smlLibMalloc(sizeof(SmlGet_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlGet_t));
+ p->elementType = SML_PE_GET;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeGetPut(p);
+ return NULL;
+ }
+ p->itemList = smlAllocItemList();
+ if (p->itemList == NULL) {
+ smlFreeGetPut(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlPutPtr_t smlAllocPut() {
+ SmlPutPtr_t p = smlAllocGet();
+ if (p == NULL) return NULL;
+ p->elementType = SML_PE_PUT;
+ return p;
+}
+
+SML_API SmlMapItemPtr_t smlAllocMapItem() {
+ SmlMapItemPtr_t p = (SmlMapItemPtr_t)smlLibMalloc(sizeof(SmlMapItem_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMapItem_t));
+ p->target = smlAllocTarget();
+ if (p->target == NULL) {
+ smlFreeMapItemPtr(p);
+ return NULL;
+ }
+ p->source = smlAllocSource();
+ if (p->source == NULL) {
+ smlFreeMapItemPtr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlMapItemListPtr_t smlAllocMapItemList() {
+ SmlMapItemListPtr_t p = (SmlMapItemListPtr_t)smlLibMalloc(sizeof(SmlMapItemList_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMapItemList_t));
+ p->mapItem = smlAllocMapItem();
+ if (p->mapItem == NULL) {
+ smlFreeMapItemList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlMapPtr_t smlAllocMap() {
+ SmlMapPtr_t p = (SmlMapPtr_t)smlLibMalloc(sizeof(SmlMap_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMap_t));
+ p->elementType = SML_PE_MAP;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeMap(p);
+ return NULL;
+ }
+ p->target = smlAllocTarget();
+ if (p->target == NULL) {
+ smlFreeMap(p);
+ return NULL;
+ }
+ p->source = smlAllocSource();
+ if (p->source == NULL) {
+ smlFreeMap(p);
+ return NULL;
+ }
+ p->mapItemList = smlAllocMapItemList();
+ if (p->mapItemList == NULL) {
+ smlFreeMap(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlResultsPtr_t smlAllocResults() {
+ SmlResultsPtr_t p = (SmlResultsPtr_t)smlLibMalloc(sizeof(SmlResults_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlResults_t));
+ p->elementType = SML_PE_RESULTS;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeResults(p);
+ return NULL;
+ }
+ p->cmdRef = smlAllocPcdata();
+ if (p->cmdRef == NULL) {
+ smlFreeResults(p);
+ return NULL;
+ }
+ p->itemList = smlAllocItemList();
+ if (p->itemList == NULL) {
+ smlFreeResults(p);
+ return NULL;
+ }
+ return p;
+}
+
+#if (defined SEARCH_SEND || defined SEARCH_RECEIVE)
+
+SML_API SmlSearchPtr_t smlAllocSearch() {
+ SmlSearchPtr_t p = (SmlSearchPtr_t)smlLibMalloc(sizeof(SmlSearch_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSearch_t));
+ p->elementType = SML_PE_SEARCH;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeSearch(p);
+ return NULL;
+ }
+ p->meta = smlAllocPcdata();
+ if (p->meta == NULL) {
+ smlFreeSearch(p);
+ return NULL;
+ }
+ p->data = smlAllocPcdata();
+ if (p->data == NULL) {
+ smlFreeSearch(p);
+ return NULL;
+ }
+ p->sourceList = smlAllocSourceList();
+ if (p->sourceList == NULL) {
+ smlFreeSearch(p);
+ return NULL;
+ }
+ return p;
+}
+#endif
+
+SML_API SmlTargetRefListPtr_t smlAllocTargetRefList() {
+ SmlTargetRefListPtr_t p = (SmlTargetRefListPtr_t)smlLibMalloc(sizeof(SmlTargetRefList_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlTargetRefList_t));
+ p->targetRef = smlAllocPcdata();
+ if (p->targetRef == NULL) {
+ smlFreeTargetRefList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlSourceRefListPtr_t smlAllocSourceRefList() {
+ SmlSourceRefListPtr_t p = (SmlSourceRefListPtr_t)smlLibMalloc(sizeof(SmlSourceRefList_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSourceRefList_t));
+ p->sourceRef = smlAllocPcdata();
+ if (p->sourceRef == NULL) {
+ smlFreeSourceRefList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlStatusPtr_t smlAllocStatus() {
+ SmlStatusPtr_t p = (SmlStatusPtr_t)smlLibMalloc(sizeof(SmlStatus_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlStatus_t));
+ p->elementType = SML_PE_STATUS;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ p->msgRef = smlAllocPcdata();
+ if (p->msgRef == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ p->cmdRef = smlAllocPcdata();
+ if (p->cmdRef == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ p->cmd = smlAllocPcdata();
+ if (p->cmd == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ p->data = smlAllocPcdata();
+ if (p->data == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlUnknownProtoElementPtr_t smlAllocUnknownProtoElement() {
+ SmlUnknownProtoElementPtr_t p = (SmlUnknownProtoElementPtr_t)smlLibMalloc(sizeof(SmlUnknownProtoElement_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlUnknownProtoElement_t));
+ p->elementType = SML_PE_UNDEF;
+ return p;
+}
+
+#ifdef __USE_METINF__
+SML_API SmlMetInfMetInfPtr_t smlAllocMetInfMetInf() {
+ SmlMetInfMetInfPtr_t p = (SmlMetInfMetInfPtr_t)smlLibMalloc(sizeof(SmlMetInfMetInf_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMetInfMetInf_t));
+ return p;
+}
+
+SML_API SmlMetInfAnchorPtr_t smlAllocMetInfAnchor() {
+ SmlMetInfAnchorPtr_t p = (SmlMetInfAnchorPtr_t)smlLibMalloc(sizeof(SmlMetInfAnchor_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMetInfAnchor_t));
+ p->next = smlAllocPcdata();
+ if (p->next == NULL) {
+ smlFreeMetinfAnchor(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlMetInfMemPtr_t smlAllocMetInfMem() {
+ SmlMetInfMemPtr_t p = (SmlMetInfMemPtr_t)smlLibMalloc(sizeof(SmlMetInfMem_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMetInfMem_t));
+ p->free = smlAllocPcdata();
+ if (p->free == NULL) {
+ smlFreeMetinfMem(p);
+ return NULL;
+ }
+ p->freeid = smlAllocPcdata();
+ if (p->freeid == NULL) {
+ smlFreeMetinfMem(p);
+ return NULL;
+ }
+ return p;
+}
+#endif
+
+#ifdef __USE_DEVINF__
+SML_API SmlDevInfExtPtr_t smlAllocDevInfExt() {
+ SmlDevInfExtPtr_t p = (SmlDevInfExtPtr_t)smlLibMalloc(sizeof(SmlDevInfExt_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfExt_t));
+ p->xnam = smlAllocPcdata();
+ if (p->xnam == NULL) {
+ smlFreeDevInfExt(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfExtListPtr_t smlAllocDevInfExtList() {
+ SmlDevInfExtListPtr_t p = (SmlDevInfExtListPtr_t)smlLibMalloc(sizeof(SmlDevInfExtList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfExtList_t));
+ p->data = smlAllocDevInfExt();
+ if (p->data == NULL) {
+ smlFreeDevInfExtList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfSyncCapPtr_t smlAllocDevInfSyncCap() {
+ SmlDevInfSyncCapPtr_t p = (SmlDevInfSyncCapPtr_t)smlLibMalloc(sizeof(SmlDevInfSyncCap_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfSyncCap_t));
+ p->synctype = smlAllocPcdataList();
+ if (p->synctype == NULL) {
+ smlFreeDevInfSynccap(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTDataPtr_t smlAllocDevInfCTData() {
+ SmlDevInfCTDataPtr_t p = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTData_t));
+ p->name = smlAllocPcdata();
+ if (p->name == NULL) {
+ smlFreeDevInfCTData(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTDataListPtr_t smlAllocDevInfCTDataList() {
+ SmlDevInfCTDataListPtr_t p = (SmlDevInfCTDataListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTDataList_t));
+ p->data = smlAllocDevInfCTData();
+ if (p->data == NULL) {
+ smlFreeDevInfCTDataList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTDataPropPtr_t smlAllocDevInfCTDataProp() {
+ SmlDevInfCTDataPropPtr_t p = (SmlDevInfCTDataPropPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataProp_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTDataProp_t));
+ p->prop = smlAllocDevInfCTData();
+ if (p->prop == NULL) {
+ smlFreeDevInfCTDataProp(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTDataPropListPtr_t smlAllocDevInfCTDataPropList() {
+ SmlDevInfCTDataPropListPtr_t p = (SmlDevInfCTDataPropListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataPropList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTDataPropList_t));
+ p->data = smlAllocDevInfCTDataProp();
+ if (p->data == NULL) {
+ smlFreeDevInfCTDataPropList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTCapPtr_t smlAllocDevInfCTCap() {
+ SmlDevInfCTCapPtr_t p = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTCap_t));
+ p->cttype = smlAllocPcdata();
+ if (p->cttype == NULL) {
+ smlFreeDevInfCTCap(p);
+ return NULL;
+ }
+ p->prop = smlAllocDevInfCTDataPropList();
+ if (p->prop == NULL) {
+ smlFreeDevInfCTCap(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCtcapListPtr_t smlAllocDevInfCtcapList() {
+ SmlDevInfCtcapListPtr_t p = (SmlDevInfCtcapListPtr_t)smlLibMalloc(sizeof(SmlDevInfCtcapList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCtcapList_t));
+ p->data = smlAllocDevInfCTCap();
+ if (p->data == NULL) {
+ smlFreeDevInfCtcapList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfDSMemPtr_t smlAllocDevInfDSMem() {
+ SmlDevInfDSMemPtr_t p = (SmlDevInfDSMemPtr_t)smlLibMalloc(sizeof(SmlDevInfDSMem_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfDSMem_t));
+ return p;
+}
+
+SML_API SmlDevInfXmitPtr_t smlAllocDevInfXmit() {
+ SmlDevInfXmitPtr_t p = (SmlDevInfXmitPtr_t)smlLibMalloc(sizeof(SmlDevInfXmit_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfXmit_t));
+ p->cttype = smlAllocPcdata();
+ if (p->cttype == NULL) {
+ smlFreeDevInfXmit(p);
+ return NULL;
+ }
+ p->verct = smlAllocPcdata();
+ if (p->verct == NULL) {
+ smlFreeDevInfXmit(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfXmitListPtr_t smlAllocDevInfXmitList() {
+ SmlDevInfXmitListPtr_t p = (SmlDevInfXmitListPtr_t)smlLibMalloc(sizeof(SmlDevInfXmitList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfXmitList_t));
+ p->data = smlAllocDevInfXmit();
+ if (p->data == NULL) {
+ smlFreeDevInfXmitList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfDatastorePtr_t smlAllocDevInfDatastore() {
+ SmlDevInfDatastorePtr_t p = (SmlDevInfDatastorePtr_t)smlLibMalloc(sizeof(SmlDevInfDatastore_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfDatastore_t));
+ p->sourceref = smlAllocPcdata();
+ if (p->sourceref == NULL) {
+ smlFreeDevInfDatastore(p);
+ return NULL;
+ }
+ p->rxpref = smlAllocDevInfXmit();
+ if (p->rxpref == NULL) {
+ smlFreeDevInfDatastore(p);
+ return NULL;
+ }
+ p->txpref = smlAllocDevInfXmit();
+ if (p->txpref == NULL) {
+ smlFreeDevInfDatastore(p);
+ return NULL;
+ }
+ p->synccap = smlAllocDevInfSyncCap();
+ if (p->synccap == NULL) {
+ smlFreeDevInfDatastore(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfDatastoreListPtr_t smlAllocDevInfDatastoreList() {
+ SmlDevInfDatastoreListPtr_t p = (SmlDevInfDatastoreListPtr_t)smlLibMalloc(sizeof(SmlDevInfDatastoreList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfDatastoreList_t));
+ p->data = smlAllocDevInfDatastore();
+ if (p->data == NULL) {
+ smlFreeDevInfDatastoreList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfDevInfPtr_t smlAllocDevInfDevInf() {
+ SmlDevInfDevInfPtr_t p = (SmlDevInfDevInfPtr_t)smlLibMalloc(sizeof(SmlDevInfDevInf_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfDevInf_t));
+ p->verdtd = smlAllocPcdata();
+ if (p->verdtd == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ p->devid = smlAllocPcdata();
+ if (p->devid == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ p->devtyp = smlAllocPcdata();
+ if (p->devtyp == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+
+ p->datastore = smlAllocDevInfDatastoreList();
+ /* Fixed error checking. 3/07/03 Emily Bernotas */
+ if (p->datastore == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ /* When developing the DS Stack, testing showed that the RTK was depending on these
+ * two optional DevInf element to have valid data when encoding the SyncML document.
+ * Although the phone does use the CTCAP element, it does NOT use the Ext element and
+ * not having valid data in the Ext was causing a PANIC.
+ * The design decision was made to fix the RTK here to follow the original philosophy
+ * not allocating memory of optional elements. For example, memory for other optional
+ * elements like Man, FwV, etc is not allocated here. It is now the responsibility of
+ * the DS Stack to allocate memory for CTCAP. 04/02/03 Emily Bernotas
+ */
+ /*
+ p->ctcap = smlAllocDevInfCtcapList();
+ if (p->ctcap == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ p->ext = smlAllocDevInfExtList();
+ if (p->ext == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ */
+ return p;
+}
+
+#endif // DevInf
+
+#ifdef __USE_DMTND__
+SML_API SmlDmTndPtr_t smlAllocDmTnd() {
+ SmlDmTndPtr_t p = (SmlDmTndPtr_t)smlLibMalloc(sizeof(SmlDmTnd_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTnd_t));
+ return p;
+}
+
+SML_API SmlDmTndNodeListPtr_t smlAllocDmTndNodeList() {
+ SmlDmTndNodeListPtr_t p = (SmlDmTndNodeListPtr_t)smlLibMalloc(sizeof(SmlDmTndNodeList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndNodeList_t));
+ return p;
+}
+
+SML_API SmlDmTndNodePtr_t smlAllocDmTndNode() {
+ SmlDmTndNodePtr_t p = (SmlDmTndNodePtr_t)smlLibMalloc(sizeof(SmlDmTndNode_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndNode_t));
+ return p;
+}
+
+SML_API SmlDmTndRTPropsPtr_t smlAllocDmTndRTProps() {
+ SmlDmTndRTPropsPtr_t p = (SmlDmTndRTPropsPtr_t)smlLibMalloc(sizeof(SmlDmTndRTProps_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndRTProps_t));
+ return p;
+}
+
+SML_API SmlDmTndFormatPtr_t smlAllocDmTndFormat() {
+ SmlDmTndFormatPtr_t p = (SmlDmTndFormatPtr_t)smlLibMalloc(sizeof(SmlDmTndFormatPtr_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndFormat_t));
+ return p;
+}
+
+SML_API SmlDmTndTypePtr_t smlAllocDmTndType() {
+ SmlDmTndTypePtr_t p = (SmlDmTndTypePtr_t)smlLibMalloc(sizeof(SmlDmTndRTProps_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndType_t));
+ return p;
+}
+#endif // AllocDmTnd
+
+#endif // AllocFuncs
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/wsm/hdr/wsm.h b/engine/dmlib/dmengine/oma_toolkit/sml/wsm/hdr/wsm.h
new file mode 100644
index 0000000..2ebc138
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/wsm/hdr/wsm.h
@@ -0,0 +1,427 @@
+/*************************************************************************/
+/* module: SyncML WorkSpace Manager */
+/* file: WSM.h */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Workspace Manager API <BR>
+ * Manages the SyncML document in memory.
+ *
+ * @version @label
+ *
+ */
+
+#ifndef _WSM_H
+#define _WSM_H
+
+#include "smlerr.h"
+#include "smldef.h"
+
+#ifndef NOWSM
+
+#include "wsm_sm.h"
+
+
+typedef struct WsmOptions_s {
+ MemSize_t maxAvailMem; // maximum amount of memory available for all wsm buffers
+} WsmOptions_t;
+
+
+#ifdef __SML_LITE__
+ #ifdef MAX_WSM_BUFFERS
+ #error "for __SML_LITE__, MAX_WSM_BUFFERS must not be predefined!"
+ #endif
+ #define MAX_WSM_BUFFERS 1
+#else
+ #ifndef MAX_WSM_BUFFERS
+ // use default value of 4 (not much for a multi-connection server)
+ #define MAX_WSM_BUFFERS 4
+ #endif
+#endif
+
+
+/** WSM internal buffer structure */
+typedef struct WsmBuf_s {
+ String_t bufName; // external name of buffer
+ MemHandle_t memH; // memory handle
+ MemPtr_t pFirstFree; // pointer to first free element in buffer
+ MemPtr_t pFirstData; // pointer to first data element in buffer
+ MemSize_t size; // size of buffer
+ MemSize_t usedBytes; // used bytes in buffer
+ Byte_t flags;
+} WsmBuf_t;
+
+
+/** WSM globals for use with global Anchor */
+typedef struct WsmGlobals_s {
+ Ret_t wsmRet; // last WSM return code
+ Byte_t initWasCalled; // was wsmInit() called?
+ WsmBuf_t wsmBuf[MAX_WSM_BUFFERS];
+ Short_t wsmIndex; // Index of actual buffer
+ WsmSmGlobals_t wsmSm; // WSM_SM global; device dependent!
+} *WsmGlobalsPtr_t, WsmGlobals_t;
+
+
+/**
+ * FUNCTION: wsmInit
+ *
+ * Initializes all Workspace Manager related resources.<BR>
+ * Should only be called once!
+ *
+ * PRE-Condition: This is the first function call to WSM
+ *
+ * POST-Condition: All WSM resources are initialized
+ *
+ * IN: wsmOpts
+ * WSM options, valid options are:
+ * <UL>
+ * <LI> tbd
+ * </UL>
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_OPTIONS, if wsmOpts is not valid
+ * SML_ERR_NOT_ENOUGH_SPACE, if not enough available memory
+ * SML_ERR_WRONG_USAGE, if wsmInit was already called
+ */
+Ret_t wsmInit (const WsmOptions_t *wsmOpts);
+
+
+/**
+ * FUNCTION: wsmCreate
+ *
+ * Creates and opens a new buffer with name bufName and size bufSize.<BR>
+ * If a buffer with name bufName already exists, the existing buffer
+ * is resized to bufSize.
+ *
+ * PRE-Condition: bufSize > 0
+ *
+ * POST-Condition: handle refers to buffer bufName; BufferSize = size
+ *
+ * IN: bufName
+ * Name of buffer to be created
+ * IN: bufSize
+ * Size of buffer to be created
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_SIZE, if bufSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < bufSize
+ * SML_ERR_WSM_BUF_TABLE_FULL, if buffer table is full
+ * SML_ERR_WRONG_USAGE, if wsmInit wasn't called before
+ *
+ * @see wsmDestroy
+ */
+Ret_t wsmCreate (String_t bufName, MemSize_t bufSize, MemHandle_t *wsmH);
+
+
+/**
+ * FUNCTION: wsmOpen
+ *
+ * Open existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName
+ *
+ * POST-Condition: wsmH refers to buffer bufName
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_WRONG_PARAM, if bufName is unknown
+ *
+ * @see wsmClose
+ */
+Ret_t wsmOpen (String_t bufName, MemHandle_t *wsmH);
+
+
+/**
+ * FUNCTION: wsmClose
+ *
+ * Close an open buffer.
+ *
+ * PRE-Condition: handle is valid; handle is unlocked
+ *
+ * POST-Condition: handle is not known to WSM any more
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmOpen
+ */
+Ret_t wsmClose (MemHandle_t wsmH);
+
+
+/**
+ * FUNCTION: wsmDestroy
+ *
+ * Destroy existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName; handle is unlocked
+ *
+ * POST-Condition: buffer is not known to WSM any more; all resources
+ * connected to this buffer are freed
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if bufName is unknown to WSM
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmCreate
+ */
+Ret_t wsmDestroy (String_t bufName);
+
+
+/**
+ * FUNCTION: wsmTerminate
+ *
+ * Terminate WSM; free all buffers and resources.
+ *
+ * PRE-Condition: all handles must be unlocked
+ *
+ * POST-Condition: all resources are freed
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if a handle was still locked
+ *
+ */
+Ret_t wsmTerminate (void);
+
+/**
+ * FUNCTION: wsmProcessedBytes
+ *
+ * Tell Workspace Manager the number of bytes already processed.
+ *
+ * PRE-Condition: handle is locked; handle is valid;
+ * noBytes <= wsmGetUsedSize
+ *
+ * POST-Condition: noBytes starting at wsmGetPtr() position are deleted;
+ * remaining bytes are copied to
+ * wsmGetPtr(SML_FIRST_FREE_ITEM) position;
+ * wsmGetUsedSize -= noBytes; wsmGetFreeSize += noBytes
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: noBytes
+ * Number of bytes already processed from buffer.
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_INVALID_SIZE, if noBytes > wsmGetUsedSize
+ *
+ * @see wsmGetFreeSize
+ */
+Ret_t wsmProcessedBytes (MemHandle_t wsmH, MemSize_t noBytes);
+
+
+/**
+ * FUNCTION: wsmLockH
+ *
+ * Locks handle wsmH and get a pointer to the contents of wsmH. <BR>
+ * RequestedPos describes the position in the buffer to which the returned
+ * pointer should point to. Valid values are:
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM
+ * <LI> SML_FIRST_FREE_ITEM
+ * </UL>
+ *
+ * PRE-Condition: handle is unlocked; handle is valid
+ *
+ * POST-Condition: handle is locked; points to first data item,
+ * or first free item.
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: requestedPos
+ * Requested position of the returned pointer
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM : points to first data entry
+ * <LI> SML_FIRST_FREE_ITEM : points to first free entry
+ * </UL>
+ *
+ * OUT: pMem
+ * Pointer to requested memory
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ * SML_ERR_UNSPECIFIC, if requested position is unknown, or lock failed
+ *
+ * @see wsmUnlockH
+ */
+Ret_t wsmLockH (MemHandle_t wsmH, SmlBufPtrPos_t requestedPos,
+ MemPtr_t *pMem);
+
+
+/**
+ * FUNCTION: wsmGetFreeSize
+ *
+ * Returns the remaining unused bytes in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: wsmGetFreeSize = BufferSize - wsmGetUsedSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: freeSize
+ * Number of bytes which are unused in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetUsedSize
+ * @see wsmProcessedBytes
+ */
+Ret_t wsmGetFreeSize(MemHandle_t wsmH, MemSize_t *freeSize);
+
+
+/**
+ * FUNCTION: wsmGetUsedSize
+ *
+ * Returns the number of bytes used in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: usedSize = BufferSize - wsmGetFreeSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: usedSize
+ * Number of bytes which are already used in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetFreeSize
+ * @see wsmSetUsedSize
+ */
+Ret_t wsmGetUsedSize(MemHandle_t wsmH, MemSize_t *usedSize);
+
+
+/**
+ * FUNCTION: wsmUnlockH
+ *
+ * Unlock handle wsmH. <BR>
+ * After this call all pointers to this memory handle are invalid
+ * and should no longer be used.
+ *
+ * PRE-Condition: handle is locked; handle is valid
+ *
+ * POST-Condition: handle is unlocked
+ *
+ * OUT: wsmH
+ * Handle to unlock
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_UNSPECIFIC, unlock failed
+ *
+ * @see wsmLockH
+ */
+Ret_t wsmUnlockH (MemHandle_t wsmH);
+
+
+/**
+ * FUNCTION: wsmSetUsedSize
+ *
+ * Tell Workspace how many data were written into buffer.
+ *
+ * PRE-Condition: handle is valid; usedSize <= wsmGetFreeSize; handle is
+ * locked
+ *
+ * POST-Condition: wsmGetUsedSize += usedSize; wsmGetFreeSize -= usedSize;
+ * instancePtr += usedSize;
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: usedSize
+ * Number of bytes which were written into buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_INVALID_SIZE, if usedSize <= wsmGetFreeSize
+ *
+ * @see wsmGetUsedSize
+ */
+Ret_t wsmSetUsedSize (MemHandle_t wsmH, MemSize_t usedSize);
+
+/**
+ * FUNCTION: wsmReset
+ *
+ * Reset the Workspace
+ *
+ * PRE-Condition: -
+ *
+ * POST-Condition: all data is lost. The FirstFree Position equals
+ * the First Data position
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ *
+ */
+Ret_t wsmReset (MemHandle_t wsmH) ;
+
+#endif // !defined(NOWSM)
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/wsm/hdr/wsm_sm.h b/engine/dmlib/dmengine/oma_toolkit/sml/wsm/hdr/wsm_sm.h
new file mode 100644
index 0000000..b07463e
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/wsm/hdr/wsm_sm.h
@@ -0,0 +1,290 @@
+/*************************************************************************/
+/* module: SyncML WorkSpace Manager */
+/* */
+/* file: WSM_SM.h */
+/* target system: All */
+/* target OS: All */
+/* */
+/* Description */
+/* Storage Management for Workspace Manager API <BR> */
+/* Encapsulates OS dependent parts of WSM. */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * @version @label
+ */
+
+#ifndef _WSM_SM_H
+#define _WSM_SM_H
+
+#include <smldef.h>
+
+
+#ifdef __ANSI_C__
+/* sbuffer list */
+typedef struct smWinList_s {
+ char *memName; // name of buffer
+ char *winH; // reference to memory block
+ MemHandle_t memH; // handle of memory block
+ Byte_t locked; // is handle locked?
+ MemSize_t memSize; // size of memory block
+ struct smWinList_s *next; // next list item
+} smWinList_t;
+typedef smWinList_t *WsmSmGlobals_t;
+#endif
+
+#ifdef __PALM_OS__
+#include <Pilot.h>
+/* dynamic buffer array */
+typedef struct smPalm_s {
+ Handle smPalmH; // reference to only memory block
+ MemHandle_t smMemH; // handle of only memory block
+ Byte_t smLocked; // is handle locked?
+} WsmSmGlobals_t;
+#endif
+
+#ifdef __EPOC_OS__
+/* sbuffer list */
+typedef struct smWinList_s {
+ char *memName; // name of buffer
+ char *winH; // reference to memory block
+ MemHandle_t memH; // handle of memory block
+ Byte_t locked; // is handle locked?
+ MemSize_t memSize; // size of memory block
+ struct smWinList_s *next; // next list item
+} smWinList_t;
+typedef smWinList_t *WsmSmGlobals_t;
+#endif
+
+
+/**
+ * FUNCTION: smCreate
+ *
+ * Creates a new memory block with name memName and size memSize.
+ *
+ * PRE-Condition: OS does not know memName; memSize > 0
+ *
+ * POST-Condition: memName exists with size memSize;
+ * memH refers to new memory block.
+ *
+ * IN: memName
+ * Name of new memory block
+ * IN: memSize
+ * Size of new memory block
+ *
+ * OUT: memH
+ * Handle to new memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if memName is already known to the OS
+ * SML_ERR_INVALID_SIZE, if memSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < memSize
+ *
+ * @see smDestroy
+ */
+Ret_t smCreate (String_t memName, MemSize_t memSize, MemHandle_t *memH);
+
+
+/**
+ * FUNCTION: smOpen
+ *
+ * Open connection to memory block with name memName.
+ *
+ * PRE-Condition: OS does know memName
+ *
+ * POST-Condition: memH refers to memory block memName
+ *
+ * IN: memName
+ * Name of memory block to open
+ *
+ * OUT: memH
+ * Handle to opened memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memName is unknown
+ *
+ * @see smClose
+ */
+Ret_t smOpen (String_t memName, MemHandle_t *memH);
+
+
+/**
+ * FUNCTION: smClose
+ *
+ * Close link to memory block.
+ *
+ * PRE-Condition: memH is a valid memory block handle; memH is unlocked;
+ * no pointers to records are in use
+ *
+ * POST-Condition: memH is not valid anymore
+ *
+ * IN: memH
+ * Handle to close
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if memH is locked
+ *
+ * @see smOpen
+ */
+Ret_t smClose (MemHandle_t memH);
+
+
+/**
+ * FUNCTION: smDestroy
+ *
+ * Remove memory block memName within OS.
+ *
+ * PRE-Condition: memName is a valid memory block name;
+ * memory block is not in use (i.e. no handles and
+ * pointers to this memory block are in use)
+ *
+ * POST-Condition: memName is not a valid memory block name anymore
+ *
+ * IN: memName
+ * Name of memory block to remove
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memName is unknown
+ * SML_ERR_WRONG_USAGE, if memory block is still locked
+ *
+ * @see smCreate
+ */
+Ret_t smDestroy (String_t memName);
+
+
+/**
+ * FUNCTION: smLock
+ *
+ * Map memory block memH to local address space.
+ *
+ * PRE-Condition: memH is a valid handle; memory block is not locked
+ *
+ * POST-Condition: pMem points to memory block memH;
+ * memory block is locked
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * OUT: pMem
+ * Pointer to memory block memH mapped in local address space
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH was already locked
+ * SML_ERR_UNSPECIFIC, if lock failed
+ *
+ * @see smUnlock
+ */
+Ret_t smLock (MemHandle_t memH, MemPtr_t *pMem);
+
+
+/**
+ * FUNCTION: smUnlock
+ *
+ * Free pointer mapped to memH memory block.
+ *
+ * PRE-Condition: memH is a valid handle; memory block is locked
+ *
+ * POST-Condition: memory block is unlocked
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH was already unlocked
+ * SML_ERR_UNSPECIFIC, if unlock failed
+ *
+ * @see smLock
+ */
+Ret_t smUnlock (MemHandle_t memH);
+
+
+/**
+ * FUNCTION: smSetSize
+ *
+ * Set size of memory block memH to newSize.
+ *
+ * PRE-Condition: memH is a valid handle; newSize > 0;
+ * memory block is unlocked
+ *
+ * POST-Condition: memory block size = newSize
+ *
+ * IN: memH
+ * Handle to memory block
+ * IN: newSize
+ * New size of memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH is locked
+ * SML_ERR_INVALID_SIZE, if newSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < newSize
+ *
+ * @see smGetSize
+ */
+Ret_t smSetSize (MemHandle_t memH, MemSize_t newSize);
+
+
+/**
+ * FUNCTION: smGetSize
+ *
+ * Get size of memory block memH.
+ *
+ * PRE-Condition: memH is a valid handle
+ *
+ * POST-Condition: actSize = memory block size
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * OUT: actSize
+ * Actual size of memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ *
+ * @see smSetSize
+ */
+Ret_t smGetSize (MemHandle_t memH, MemSize_t *actSize);
+
+#endif
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/wsm/src/wsm.c b/engine/dmlib/dmengine/oma_toolkit/sml/wsm/src/wsm.c
new file mode 100644
index 0000000..760cbad
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/wsm/src/wsm.c
@@ -0,0 +1,1612 @@
+/*************************************************************************/
+/* module: SyncML WorkSpace Manager */
+/* file: WSM.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Workspace Manager API <BR>
+ * Manages the SyncML document in memory.
+ *
+ * @version @label
+ *
+ *
+ */
+
+
+#ifndef NOWSM
+// if no WSM, we can leave this one out completely
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "wsm.h"
+
+#include "wsm_sm.h"
+#include "smldef.h"
+#include "libmem.h"
+#include "libstr.h"
+#include "liblock.h" // for THREADDEBUGPRINTF %%% luz
+#include "mgr.h" // for global anchor
+
+
+/** WSM buffer flags */
+#define WSM_VALID_F (Byte_t) 0x01
+#define WSM_LOCKED_F (Byte_t) 0x02
+
+#define WSM_MEMH_UNUSED -1
+
+#ifndef __SML_LITE__
+
+/* Global Vars */
+/* =========== */
+
+/* defines for convient use of global anchor */
+
+#define wsmRet (mgrGetSyncMLAnchor())->wsmGlobals->wsmRet
+#define initWasCalled (mgrGetSyncMLAnchor())->wsmGlobals->initWasCalled
+#define maxWsmAvailMem (mgrGetSyncMLAnchor())->syncmlOptions->maxWorkspaceAvailMem
+#define wsmBuf (mgrGetSyncMLAnchor())->wsmGlobals->wsmBuf
+#define wsmIndex (mgrGetSyncMLAnchor())->wsmGlobals->wsmIndex
+
+void createDataStructs(void);
+
+void createDataStructs() {
+ if ( (mgrGetSyncMLAnchor())->wsmGlobals == NULL ) {
+ if ( ((mgrGetSyncMLAnchor())->wsmGlobals=smlLibMalloc(sizeof(WsmGlobals_t))) == 0 ) {
+ return;
+ }
+ smlLibMemset((mgrGetSyncMLAnchor())->wsmGlobals, 0, sizeof(WsmGlobals_t));
+ wsmRet = 0;
+ initWasCalled = 0;
+ wsmIndex = 0;
+#ifdef __ANSI_C__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm = NULL;
+#endif
+#ifdef __PALM_OS__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm.smMemH = 0;
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm.smLocked = 0;
+#endif
+#ifdef __EPOC_OS__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm = NULL;
+#endif
+ }
+}
+#define freeDataStructs() smlLibFree((mgrGetSyncMLAnchor())->wsmGlobals)
+
+
+/* private functions prototypes */
+static Short_t getNextFreeEntry();
+static Short_t lookup(MemHandle_t memH);
+static MemHandle_t nameToHandle(String_t name);
+static Short_t deleteBufferHandle(MemHandle_t memH);
+static Short_t resetBufferGlobals(MemHandle_t memH);
+static Byte_t isValidMemH(MemHandle_t memH);
+static Byte_t isLockedMemH(MemHandle_t memH);
+static Byte_t isMemAvailable(MemSize_t memToAlloc);
+
+
+
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+
+
+/**
+ * Get next free buffer entry.
+ * Returns index of next free entry, or -1 if buffer table is full.
+ */
+static Short_t getNextFreeEntry() {
+ Short_t i;
+
+ for ( i=0; i < MAX_WSM_BUFFERS; ++i )
+ if ( wsmBuf[i].memH == WSM_MEMH_UNUSED )
+ return i;
+
+ return -1;
+}
+
+
+
+/**
+ * Get buffer table index for memH.
+ * Returns -1 if memH not found.
+ */
+static Short_t lookup(MemHandle_t memH) {
+ Short_t i;
+
+ // first check cache
+ if ( wsmBuf[wsmIndex].memH == memH )
+ return wsmIndex;
+
+ // search through buffer
+ for ( i=0; (i < MAX_WSM_BUFFERS) && (wsmBuf[i].memH != memH); ++i )
+ ;
+ if ( i < MAX_WSM_BUFFERS ) {
+ wsmIndex = i;
+ return i;
+ }
+ else {
+ return -1; // memH not found
+ }
+}
+
+
+/**
+ * Find memory handle corresponding to name.
+ * Return WSM_MEMH_UNUSED, if name not found in wsmBuf.
+ */
+static MemHandle_t nameToHandle(String_t name) {
+ int i;
+
+ // first check cache
+ if ( (wsmBuf[wsmIndex].bufName != NULL) &&
+ (smlLibStrcmp(wsmBuf[wsmIndex].bufName, name) == 0) )
+ return wsmBuf[wsmIndex].memH;
+
+ // search through buffer
+ for ( i=0; ((i < MAX_WSM_BUFFERS) &&
+ (wsmBuf[i].bufName == NULL ? 1 :
+ smlLibStrcmp(wsmBuf[i].bufName, name) != 0)); ++i )
+ ;
+ if ( i < MAX_WSM_BUFFERS )
+ return wsmBuf[i].memH;
+ else {
+ return WSM_MEMH_UNUSED; // name not found
+ }
+}
+
+
+
+/**
+ * Delete memory handle from buffer.
+ * Return -1, if handle not found.
+ */
+static Short_t deleteBufferHandle(MemHandle_t memH) {
+ if ( (wsmIndex = lookup(memH)) < 0 )
+ return -1; // handle not found
+
+ // reset the values
+ wsmBuf[wsmIndex].memH = WSM_MEMH_UNUSED;
+ wsmBuf[wsmIndex].pFirstFree = NULL;
+ wsmBuf[wsmIndex].pFirstData = NULL;
+ wsmBuf[wsmIndex].size = 0;
+ wsmBuf[wsmIndex].usedBytes = 0;
+ //wsmBuf[wsmIndex].flags = ~WSM_VALID_F;
+ wsmBuf[wsmIndex].flags = ((Byte_t) ~WSM_VALID_F);
+ smlLibFree(wsmBuf[wsmIndex].bufName); // free mem
+ wsmBuf[wsmIndex].bufName = NULL;
+
+ return 0;
+}
+
+
+/**
+ * Reset values in buffer table for entry memH.
+ * If memH doesn't exist create an entry.
+ * Return index to memH in buffer table,
+ * or -1 if table is full
+ */
+static Short_t resetBufferGlobals(MemHandle_t memH) {
+ if ( (wsmIndex = lookup(memH)) < 0 ) {
+ // create new one
+ if ( (wsmIndex = getNextFreeEntry()) < 0 )
+ return -1; // buffer table full
+ wsmBuf[wsmIndex].memH = memH;
+ } else
+ // use existing one, which has to be reset prior usage
+ smlLibFree(wsmBuf[wsmIndex].bufName); // free mem
+
+ // reset the values
+ wsmBuf[wsmIndex].pFirstFree = NULL;
+ wsmBuf[wsmIndex].pFirstData = NULL;
+ wsmBuf[wsmIndex].size = 0;
+ wsmBuf[wsmIndex].usedBytes = 0;
+ wsmBuf[wsmIndex].flags = WSM_VALID_F;
+ wsmBuf[wsmIndex].bufName = NULL;
+
+ return wsmIndex;
+}
+
+
+static Byte_t isValidMemH(MemHandle_t memH) {
+ Short_t i;
+ i = lookup(memH);
+ if (i < 0)
+ {
+ return 0;
+ }else{
+ return (Byte_t) (wsmBuf[i].flags & WSM_VALID_F);
+ }
+}
+
+static Byte_t isLockedMemH(MemHandle_t memH) {
+ Short_t i;
+ i = lookup(memH);
+ if (i < 0)
+ {
+ return 0;
+ }else{
+ return (Byte_t) (wsmBuf[i].flags & WSM_LOCKED_F);
+ }
+}
+
+static Byte_t isMemAvailable(MemSize_t memToAlloc) {
+ int i;
+ MemSize_t actMem = memToAlloc;
+ if ( maxWsmAvailMem == 0 )
+ return 1; // no memsize restrictions
+ for (i=0; i < MAX_WSM_BUFFERS; ++i) {
+ if ( wsmBuf[i].memH != WSM_MEMH_UNUSED )
+ actMem += wsmBuf[i].size;
+ }
+ return ((Byte_t)(actMem <= maxWsmAvailMem));
+}
+
+
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+
+
+/**
+ * FUNCTION: wsmInit
+ *
+ * Initializes all Workspace Manager related resources.<BR>
+ * Should only be called once!
+ *
+ * PRE-Condition: This is the first function call to WSM
+ *
+ * POST-Condition: All WSM resources are initialized
+ *
+ * IN: wsmOpts
+ * WSM options, valid options are:
+ * <UL>
+ * <LI> maxAvailMem<BR>
+ * Maximal amount of memory which wsm can use for the buffers<BR>
+ * 0 == no limitation
+ * </UL>
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_OPTIONS, if wsmOpts is not valid
+ * SML_ERR_NOT_ENOUGH_SPACE, if not enough available memory
+ * SML_ERR_WRONG_USAGE, if wsmInit was already called
+ */
+Ret_t wsmInit (const WsmOptions_t *wsmOpts) {
+ int i;
+
+ // create global datastructs
+ createDataStructs();
+
+ if (NULL == mgrGetSyncMLAnchor()->wsmGlobals) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // check if init was already called
+ if ( initWasCalled )
+ return SML_ERR_WRONG_USAGE;
+
+ // check options
+ if ( wsmOpts != NULL ) {
+ if ( wsmOpts->maxAvailMem > 0 ) {
+ maxWsmAvailMem = wsmOpts->maxAvailMem;
+ }
+ }
+
+ // init resources
+ for ( i=0; i < MAX_WSM_BUFFERS; ++i )
+ wsmBuf[i].memH = WSM_MEMH_UNUSED;
+ wsmIndex = 0;
+ initWasCalled = (Byte_t) 1;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmCreate
+ *
+ * Creates and opens a new buffer with name bufName and size bufSize.<BR>
+ * If a buffer with name bufName already exists, the existing buffer
+ * is resized to bufSize.
+ *
+ * PRE-Condition: bufSize > 0
+ *
+ * POST-Condition: handle refers to buffer bufName; BufferSize = size
+ *
+ * IN: bufName
+ * Name of buffer to be created
+ * IN: bufSize
+ * Size of buffer to be created
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_SIZE, if bufSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < bufSize
+ * SML_ERR_WSM_BUF_TABLE_FULL, if buffer table is full
+ * SML_ERR_WRONG_USAGE, if wsmInit wasn't called before
+ *
+ * @see wsmDestroy
+ */
+Ret_t wsmCreate (String_t bufName, MemSize_t bufSize, MemHandle_t *wsmH) {
+
+ *wsmH = 0; // 0 in case of error
+
+ if ( ! initWasCalled )
+ return SML_ERR_WRONG_USAGE;
+
+ // check buffer space
+ if ( getNextFreeEntry() == -1 ) {
+ return wsmRet=SML_ERR_WSM_BUF_TABLE_FULL;
+ }
+ // check for maxMemAvailable
+ if ( ! isMemAvailable(bufSize) ) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // create buffer
+ if ( (wsmRet = smCreate(bufName, bufSize, wsmH)) != SML_ERR_OK ) {
+ if ( wsmRet == SML_ERR_WRONG_USAGE ) { // buffer already exists
+ // resize existing buffer
+ // open buffer
+ if ( (wsmRet = smOpen(bufName, wsmH)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ // resize buffer
+ if ( (wsmRet = smSetSize(*wsmH, bufSize)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ }
+ else {
+ return wsmRet;
+ }
+ }
+
+ // reset buffer vars
+ wsmIndex = resetBufferGlobals(*wsmH);
+
+ // set buffer vars
+ wsmBuf[wsmIndex].size = bufSize;
+ wsmBuf[wsmIndex].bufName = smlLibStrdup(bufName);
+
+ if (wsmBuf[wsmIndex].bufName == NULL) {
+ smClose(*wsmH);
+ smDestroy(bufName);
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmOpen
+ *
+ * Open existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName
+ *
+ * POST-Condition: wsmH refers to buffer bufName
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_WRONG_PARAM, if bufName is unknown
+ *
+ * @see wsmClose
+ */
+Ret_t wsmOpen (String_t bufName, MemHandle_t *wsmH){
+
+ // open buffer
+ if ( (wsmRet = smOpen(bufName, wsmH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ // reset buffer vars
+ wsmIndex = resetBufferGlobals(*wsmH);
+
+ // set buf vars
+ wsmRet = smGetSize(*wsmH, &wsmBuf[wsmIndex].size);
+ wsmBuf[wsmIndex].bufName = smlLibStrdup(bufName);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmClose
+ *
+ * Close an open buffer.
+ *
+ * PRE-Condition: handle is valid; handle is unlocked
+ *
+ * POST-Condition: handle is not known to WSM any more
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmOpen
+ */
+Ret_t wsmClose (MemHandle_t wsmH) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ // close handle
+ if ( (wsmRet = smClose(wsmH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+ wsmRet = deleteBufferHandle(wsmH);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmDestroy
+ *
+ * Destroy existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName; handle is unlocked
+ *
+ * POST-Condition: buffer is not known to WSM any more; all resources
+ * connected to this buffer are freed
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if bufName is unknown to WSM
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmCreate
+ */
+Ret_t wsmDestroy (String_t bufName) {
+
+ // free resources
+ if ( (wsmRet = wsmClose(nameToHandle(bufName))) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ // free buffer
+ if ( (wsmRet = smDestroy(bufName)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmTerminate
+ *
+ * Terminate WSM; free all buffers and resources.
+ *
+ * PRE-Condition: all handles must be unlocked
+ *
+ * POST-Condition: all resources are freed
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if a handle was still locked
+ *
+ */
+Ret_t wsmTerminate (void) {
+ int i;
+
+ // free all WSM resources
+ for (i=0; i < MAX_WSM_BUFFERS; ++i) {
+ if ( wsmBuf[i].memH != WSM_MEMH_UNUSED )
+ if ( wsmDestroy(wsmBuf[i].bufName) == SML_ERR_WRONG_USAGE ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+ }
+
+ // free global DataStructs
+ freeDataStructs();
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmProcessedBytes
+ *
+ * Tell Workspace Manager the number of bytes already processed.
+ *
+ * PRE-Condition: handle is locked; handle is valid;
+ * noBytes <= wsmGetUsedSize
+ *
+ * POST-Condition: noBytes starting at wsmGetPtr() position are deleted;
+ * remaining bytes are copied to
+ * wsmGetPtr(SML_FIRST_FREE_ITEM) position;
+ * wsmGetUsedSize -= noBytes; wsmGetFreeSize += noBytes
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: noBytes
+ * Number of bytes already processed from buffer.
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_INVALID_SIZE, if noBytes > wsmGetUsedSize
+ *
+ * @see wsmGetFreeSize
+ */
+Ret_t wsmProcessedBytes (MemHandle_t wsmH, MemSize_t noBytes) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is unlocked
+ if ( ! isLockedMemH(wsmH) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ wsmIndex = lookup(wsmH);
+
+ if ( noBytes > wsmBuf[wsmIndex].usedBytes ) {
+ return wsmRet=SML_ERR_INVALID_SIZE;
+ }
+
+ // adapt usedSize
+ wsmBuf[wsmIndex].usedBytes -= noBytes;
+
+ // move memory
+ // check return ?????
+ smlLibMemmove(wsmBuf[wsmIndex].pFirstData,
+ (wsmBuf[wsmIndex].pFirstData + noBytes),
+ wsmBuf[wsmIndex].usedBytes);
+
+ // move pFirstFree
+ wsmBuf[wsmIndex].pFirstFree -= noBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmLockH
+ *
+ * Locks handle wsmH and get a pointer to the contents of wsmH. <BR>
+ * RequestedPos describes the position in the buffer to which the returned
+ * pointer should point. Valid values are:
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM
+ * <LI> SML_FIRST_FREE_ITEM
+ * </UL>
+ *
+ * PRE-Condition: handle is unlocked; handle is valid
+ *
+ * POST-Condition: handle is locked; points to first data item,
+ * or first free item.
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: requestedPos
+ * Requested position of the returned pointer
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM : points to first data entry
+ * <LI> SML_FIRST_FREE_ITEM : points to first free entry
+ * </UL>
+ *
+ * OUT: pMem
+ * Pointer to requested memory
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ * SML_ERR_UNSPECIFIC, if requested position is unknown, or lock failed
+ *
+ * @see wsmUnlockH
+ */
+Ret_t wsmLockH (MemHandle_t wsmH, SmlBufPtrPos_t requestedPos,
+ MemPtr_t *pMem) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is locked
+ if ( isLockedMemH(wsmH) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // lock
+ if ( (wsmRet = smLock(wsmH, pMem)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ // set local pointers
+ wsmIndex = lookup(wsmH);
+ wsmBuf[wsmIndex].pFirstData = *pMem;
+ wsmBuf[wsmIndex].pFirstFree = *pMem + wsmBuf[wsmIndex].usedBytes;
+ wsmBuf[wsmIndex].flags |= WSM_LOCKED_F;
+
+ switch (requestedPos) {
+ case SML_FIRST_DATA_ITEM:
+ *pMem = wsmBuf[wsmIndex].pFirstData;
+ break;
+ case SML_FIRST_FREE_ITEM:
+ *pMem = wsmBuf[wsmIndex].pFirstFree;
+ break;
+ default:
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmGetFreeSize
+ *
+ * Returns the remaining unused bytes in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: wsmGetFreeSize = BufferSize - wsmGetUsedSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: freeSize
+ * Number of bytes which are unused in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetUsedSize
+ * @see wsmProcessedBytes
+ */
+Ret_t wsmGetFreeSize(MemHandle_t wsmH, MemSize_t *freeSize) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ wsmIndex = lookup(wsmH);
+
+ *freeSize = wsmBuf[wsmIndex].size - wsmBuf[wsmIndex].usedBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmGetUsedSize
+ *
+ * Returns the number of bytes used in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: usedSize = BufferSize - wsmGetFreeSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: usedSize
+ * Number of bytes which are already used in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetFreeSize
+ * @see wsmSetUsedSize
+ */
+Ret_t wsmGetUsedSize(MemHandle_t wsmH, MemSize_t *usedSize) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ wsmIndex = lookup(wsmH);
+
+ *usedSize = wsmBuf[wsmIndex].usedBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmUnlockH
+ *
+ * Unlock handle wsmH. <BR>
+ * After this call all pointers to this memory handle are invalid
+ * and should no longer be used.
+ *
+ * PRE-Condition: handle is locked; handle is valid
+ *
+ * POST-Condition: handle is unlocked
+ *
+ * OUT: wsmH
+ * Handle to unlock
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_UNSPECIFIC, unlock failed
+ *
+ * @see wsmLockH
+ */
+Ret_t wsmUnlockH (MemHandle_t wsmH) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is already unlocked
+ if ( ! isLockedMemH(wsmH) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // unlock
+ if ( (wsmRet = smUnlock(wsmH)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ // set local pointers
+ wsmIndex = lookup(wsmH);
+ wsmBuf[wsmIndex].pFirstData = NULL;
+ wsmBuf[wsmIndex].pFirstFree = NULL;
+ wsmBuf[wsmIndex].flags &= ~WSM_LOCKED_F;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmSetUsedSize
+ *
+ * Tell Workspace how many data were written into buffer.
+ *
+ * PRE-Condition: handle is valid; usedSize <= wsmGetFreeSize; handle is
+ * locked
+ *
+ * POST-Condition: wsmGetUsedSize += usedSize; wsmGetFreeSize -= usedSize;
+ * instancePtr += usedSize;
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: usedSize
+ * Number of bytes which were written into buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_INVALID_SIZE, if usedSize <= wsmGetFreeSize
+ *
+ * @see wsmGetUsedSize
+ */
+Ret_t wsmSetUsedSize (MemHandle_t wsmH, MemSize_t usedSize) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is unlocked
+ if ( ! isLockedMemH(wsmH) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ wsmIndex = lookup(wsmH);
+
+ // usedSize > freeSize?
+ if ( usedSize >
+ (wsmBuf[wsmIndex].size - wsmBuf[wsmIndex].usedBytes) ) {
+ return wsmRet=SML_ERR_INVALID_SIZE;
+ }
+
+ // adapt usedSize
+ wsmBuf[wsmIndex].usedBytes += usedSize;
+
+ // move pFirstFree
+ wsmBuf[wsmIndex].pFirstFree += usedSize;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wsmReset
+ *
+ * Reset the Workspace
+ *
+ * PRE-Condition: -
+ *
+ * POST-Condition: all data is lost. The FirstFree Position equals
+ * the First Data position
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ *
+ */
+Ret_t wsmReset (MemHandle_t wsmH) {
+
+ wsmIndex = lookup(wsmH);
+ wsmBuf[wsmIndex].pFirstFree = wsmBuf[wsmIndex].pFirstFree - wsmBuf[wsmIndex].usedBytes ;
+ wsmBuf[wsmIndex].pFirstData = wsmBuf[wsmIndex].pFirstFree;
+ wsmBuf[wsmIndex].usedBytes = 0;
+
+ return SML_ERR_OK;
+}
+
+/*======================================================================================*/
+#else
+/* WSM_LITE Version - uses only one buffer*/
+/*======================================================================================*/
+
+
+/* Global Vars */
+/* =========== */
+
+/* defines for convient use of global anchor */
+#define wsmRet (mgrGetSyncMLAnchor())->wsmGlobals->wsmRet
+#define initWasCalled (mgrGetSyncMLAnchor())->wsmGlobals->initWasCalled
+#define maxWsmAvailMem (mgrGetSyncMLAnchor())->syncmlOptions->maxWorkspaceAvailMem
+#define wsmBuf (mgrGetSyncMLAnchor())->wsmGlobals->wsmBuf
+#define wsmIndex (mgrGetSyncMLAnchor())->wsmGlobals->wsmIndex
+
+void createDataStructs(void);
+
+void createDataStructs() {
+ if ( (mgrGetSyncMLAnchor())->wsmGlobals == NULL ) {
+ if ( ((mgrGetSyncMLAnchor())->wsmGlobals=smlLibMalloc(sizeof(WsmGlobals_t))) == 0 ) {
+ return;
+ }
+ wsmRet = 0;
+ initWasCalled = 0;
+ wsmIndex = 0;
+#ifdef __ANSI_C__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm = NULL;
+#endif
+#ifdef __PALM_OS__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm.smMemH = 0;
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm.smLocked = 0;
+#endif
+#ifdef __EPOC_OS__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm = NULL;
+#endif
+ }
+}
+#define freeDataStructs() smlLibFree((mgrGetSyncMLAnchor())->wsmGlobals)
+
+
+
+/* private functions prototypes */
+static Short_t getNextFreeEntry();
+static Short_t deleteBufferHandle(MemHandle_t memH);
+static Short_t resetBufferGlobals(MemHandle_t memH);
+static Byte_t isMemAvailable(MemSize_t memToAlloc);
+
+
+
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+
+
+
+/**
+ * Delete memory handle from buffer.
+ * Return -1, if handle not found.
+ */
+static Short_t deleteBufferHandle(MemHandle_t memH) {
+ // reset the values
+ wsmBuf[0].memH = WSM_MEMH_UNUSED;
+ wsmBuf[0].pFirstFree = NULL;
+ wsmBuf[0].pFirstData = NULL;
+ wsmBuf[0].size = 0;
+ wsmBuf[0].usedBytes = 0;
+ wsmBuf[0].flags = ~WSM_VALID_F;
+ smlLibFree(wsmBuf[0].bufName); // free mem
+ wsmBuf[0].bufName = NULL;
+
+ return 0;
+}
+
+
+/**
+ * Reset values in buffer table for entry memH.
+ * If memH doesn't exist create an entry.
+ * Return index to memH in buffer table,
+ * or -1 if table is full
+ */
+static Short_t resetBufferGlobals(MemHandle_t memH) {
+ if ( (wsmBuf[0].memH != memH) && (wsmBuf[0].memH == WSM_MEMH_UNUSED)) {
+ // create new one
+ wsmBuf[0].memH = memH;
+ } else {
+ // use existing one, which has to be reset prior usage
+ smlLibFree(wsmBuf[0].bufName); // free mem
+ }
+ // reset the values
+ wsmBuf[0].pFirstFree = NULL;
+ wsmBuf[0].pFirstData = NULL;
+ wsmBuf[0].size = 0;
+ wsmBuf[0].usedBytes = 0;
+ wsmBuf[0].flags = WSM_VALID_F;
+ wsmBuf[0].bufName = NULL;
+
+ return 0;
+}
+
+
+static Byte_t isMemAvailable(MemSize_t memToAlloc) {
+ MemSize_t actMem = memToAlloc;
+ if ( maxWsmAvailMem == 0 )
+ return 1; // no memsize restrictions
+ if ( wsmBuf[0].memH != WSM_MEMH_UNUSED )
+ actMem += wsmBuf[0].size;
+ return (actMem <= maxWsmAvailMem);
+}
+
+
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+
+
+/**
+ * FUNCTION: wsmInit
+ *
+ * Initializes all Workspace Manager related resources.<BR>
+ * Should only be called once!
+ *
+ * PRE-Condition: This is the first function call to WSM
+ *
+ * POST-Condition: All WSM resources are initialized
+ *
+ * IN: wsmOpts
+ * WSM options, valid options are:
+ * <UL>
+ * <LI> maxAvailMem<BR>
+ * Maximal amount of memory which wsm can use for the buffers<BR>
+ * 0 == no limitation
+ * </UL>
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_OPTIONS, if wsmOpts is not valid
+ * SML_ERR_NOT_ENOUGH_SPACE, if not enough available memory
+ * SML_ERR_WRONG_USAGE, if wsmInit was already called
+ */
+Ret_t wsmInit (const WsmOptions_t *wsmOpts) {
+ // create global datastructs
+ createDataStructs();
+
+ if (NULL == mgrGetSyncMLAnchor()->wsmGlobals) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+
+ // check if init was already called
+ if ( initWasCalled )
+ return SML_ERR_WRONG_USAGE;
+
+ // check options
+ if ( wsmOpts != NULL ) {
+ if ( wsmOpts->maxAvailMem > 0 ) {
+ maxWsmAvailMem = wsmOpts->maxAvailMem;
+ }
+ }
+
+ // init resources
+ wsmBuf[0].memH = WSM_MEMH_UNUSED;
+ wsmIndex = 0;
+ initWasCalled = (Byte_t) 1;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmCreate
+ *
+ * Creates and opens a new buffer with name bufName and size bufSize.<BR>
+ * If a buffer with name bufName already exists, the existing buffer
+ * is resized to bufSize.
+ *
+ * PRE-Condition: bufSize > 0
+ *
+ * POST-Condition: handle refers to buffer bufName; BufferSize = size
+ *
+ * IN: bufName
+ * Name of buffer to be created
+ * IN: bufSize
+ * Size of buffer to be created
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_SIZE, if bufSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < bufSize
+ * SML_ERR_WSM_BUF_TABLE_FULL, if buffer table is full
+ * SML_ERR_WRONG_USAGE, if wsmInit wasn't called before
+ *
+ * @see wsmDestroy
+ */
+Ret_t wsmCreate (String_t bufName, MemSize_t bufSize, MemHandle_t *wsmH) {
+
+ *wsmH = 0; // 0 in case of error
+
+ if ( ! initWasCalled )
+ return SML_ERR_WRONG_USAGE;
+
+ // check buffer space
+ if ( wsmBuf[0].memH != WSM_MEMH_UNUSED ) {
+ return wsmRet=SML_ERR_WSM_BUF_TABLE_FULL;
+ }
+ // check for maxMemAvailable
+ if ( ! isMemAvailable(bufSize) ) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // create buffer
+ if ( (wsmRet = smCreate(bufName, bufSize, wsmH)) != SML_ERR_OK ) {
+ if ( wsmRet == SML_ERR_WRONG_USAGE ) { // buffer already exists
+ // resize existing buffer
+ // open buffer
+ if ( (wsmRet = smOpen(bufName, wsmH)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ // resize buffer
+ if ( (wsmRet = smSetSize(*wsmH, bufSize)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ }
+ else {
+ return wsmRet;
+ }
+ }
+
+ // reset buffer vars
+ resetBufferGlobals(*wsmH);
+
+ // set buffer vars
+ wsmBuf[0].size = bufSize;
+ wsmBuf[0].bufName = smlLibStrdup(bufName);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmOpen
+ *
+ * Open existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName
+ *
+ * POST-Condition: wsmH refers to buffer bufName
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_WRONG_PARAM, if bufName is unknown
+ *
+ * @see wsmClose
+ */
+Ret_t wsmOpen (String_t bufName, MemHandle_t *wsmH){
+
+ // open buffer
+ if ( (wsmRet = smOpen(bufName, wsmH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ // reset buffer vars
+ resetBufferGlobals(*wsmH);
+
+ // set buf vars
+ wsmRet = smGetSize(*wsmH, &wsmBuf[0].size);
+ wsmBuf[0].bufName = smlLibStrdup(bufName);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmClose
+ *
+ * Close an open buffer.
+ *
+ * PRE-Condition: handle is valid; handle is unlocked
+ *
+ * POST-Condition: handle is not known to WSM any more
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmOpen
+ */
+Ret_t wsmClose (MemHandle_t wsmH) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ // close handle
+ if ( (wsmRet = smClose(wsmH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+ wsmRet = deleteBufferHandle(wsmH);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmDestroy
+ *
+ * Destroy existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName; handle is unlocked
+ *
+ * POST-Condition: buffer is not known to WSM any more; all resources
+ * connected to this buffer are freed
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if bufName is unknown to WSM
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmCreate
+ */
+Ret_t wsmDestroy (String_t bufName) {
+
+ // free resources
+ if ( (wsmRet = wsmClose(wsmBuf[0].memH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ // free buffer
+ if ( (wsmRet = smDestroy(bufName)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmTerminate
+ *
+ * Terminate WSM; free all buffers and resources.
+ *
+ * PRE-Condition: all handles must be unlocked
+ *
+ * POST-Condition: all resources are freed
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if a handle was still locked
+ *
+ */
+Ret_t wsmTerminate () {
+ int i;
+
+ // free all WSM resources
+ for (i=0; i < MAX_WSM_BUFFERS; ++i) {
+ if ( wsmBuf[i].memH != WSM_MEMH_UNUSED )
+ if ( wsmDestroy(wsmBuf[i].bufName) == SML_ERR_WRONG_USAGE ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+ }
+
+ // free global DataStructs
+ freeDataStructs();
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmProcessedBytes
+ *
+ * Tell Workspace Manager the number of bytes already processed.
+ *
+ * PRE-Condition: handle is locked; handle is valid;
+ * noBytes <= wsmGetUsedSize
+ *
+ * POST-Condition: noBytes starting at wsmGetPtr() position are deleted;
+ * remaining bytes are copied to
+ * wsmGetPtr(SML_FIRST_FREE_ITEM) position;
+ * wsmGetUsedSize -= noBytes; wsmGetFreeSize += noBytes
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: noBytes
+ * Number of bytes already processed from buffer.
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_INVALID_SIZE, if noBytes > wsmGetUsedSize
+ *
+ * @see wsmGetFreeSize
+ */
+Ret_t wsmProcessedBytes (MemHandle_t wsmH, MemSize_t noBytes) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is unlocked
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_LOCKED_F)) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ if ( noBytes > wsmBuf[0].usedBytes ) {
+ return wsmRet=SML_ERR_INVALID_SIZE;
+ }
+
+ // adapt usedSize
+ wsmBuf[0].usedBytes -= noBytes;
+
+ // move memory
+ // check return ?????
+ smlLibMemmove(wsmBuf[0].pFirstData,
+ (wsmBuf[0].pFirstData + noBytes),
+ wsmBuf[0].usedBytes);
+
+ // move pFirstFree
+ wsmBuf[0].pFirstFree -= noBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmLockH
+ *
+ * Locks handle wsmH and get a pointer to the contents of wsmH. <BR>
+ * RequestedPos describes the position in the buffer to which the returned
+ * pointer should point. Valid values are:
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM
+ * <LI> SML_FIRST_FREE_ITEM
+ * </UL>
+ *
+ * PRE-Condition: handle is unlocked; handle is valid
+ *
+ * POST-Condition: handle is locked; points to first data item,
+ * or first free item.
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: requestedPos
+ * Requested position of the returned pointer
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM : points to first data entry
+ * <LI> SML_FIRST_FREE_ITEM : points to first free entry
+ * </UL>
+ *
+ * OUT: pMem
+ * Pointer to requested memory
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ * SML_ERR_UNSPECIFIC, if requested position is unknown, or lock failed
+ *
+ * @see wsmUnlockH
+ */
+Ret_t wsmLockH (MemHandle_t wsmH, SmlBufPtrPos_t requestedPos,
+ MemPtr_t *pMem) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is locked
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_LOCKED_F)) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // lock
+ if ( (wsmRet = smLock(wsmH, pMem)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ // set local pointers
+ wsmBuf[0].pFirstData = *pMem;
+ wsmBuf[0].pFirstFree = *pMem + wsmBuf[0].usedBytes;
+ wsmBuf[0].flags |= WSM_LOCKED_F;
+
+ switch (requestedPos) {
+ case SML_FIRST_DATA_ITEM:
+ *pMem = wsmBuf[0].pFirstData;
+ break;
+ case SML_FIRST_FREE_ITEM:
+ *pMem = wsmBuf[0].pFirstFree;
+ break;
+ default:
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmGetFreeSize
+ *
+ * Returns the remaining unused bytes in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: wsmGetFreeSize = BufferSize - wsmGetUsedSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: freeSize
+ * Number of bytes which are unused in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetUsedSize
+ * @see wsmProcessedBytes
+ */
+Ret_t wsmGetFreeSize(MemHandle_t wsmH, MemSize_t *freeSize) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ *freeSize = wsmBuf[0].size - wsmBuf[0].usedBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmGetUsedSize
+ *
+ * Returns the number of bytes used in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: usedSize = BufferSize - wsmGetFreeSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: usedSize
+ * Number of bytes which are already used in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetFreeSize
+ * @see wsmSetUsedSize
+ */
+Ret_t wsmGetUsedSize(MemHandle_t wsmH, MemSize_t *usedSize) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ *usedSize = wsmBuf[0].usedBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmUnlockH
+ *
+ * Unlock handle wsmH. <BR>
+ * After this call all pointers to this memory handle are invalid
+ * and should no longer be used.
+ *
+ * PRE-Condition: handle is locked; handle is valid
+ *
+ * POST-Condition: handle is unlocked
+ *
+ * OUT: wsmH
+ * Handle to unlock
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_UNSPECIFIC, unlock failed
+ *
+ * @see wsmLockH
+ */
+Ret_t wsmUnlockH (MemHandle_t wsmH) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is already unlocked
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_LOCKED_F)) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // unlock
+ if ( (wsmRet = smUnlock(wsmH)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ // set local pointers
+ wsmBuf[0].pFirstData = NULL;
+ wsmBuf[0].pFirstFree = NULL;
+ wsmBuf[0].flags &= ~WSM_LOCKED_F;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmSetUsedSize
+ *
+ * Tell Workspace how many data were written into buffer.
+ *
+ * PRE-Condition: handle is valid; usedSize <= wsmGetFreeSize; handle is
+ * locked
+ *
+ * POST-Condition: wsmGetUsedSize += usedSize; wsmGetFreeSize -= usedSize;
+ * instancePtr += usedSize;
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: usedSize
+ * Number of bytes which were written into buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_INVALID_SIZE, if usedSize <= wsmGetFreeSize
+ *
+ * @see wsmGetUsedSize
+ */
+Ret_t wsmSetUsedSize (MemHandle_t wsmH, MemSize_t usedSize) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is unlocked
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_LOCKED_F)) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // usedSize > freeSize?
+ if ( usedSize >
+ (wsmBuf[0].size - wsmBuf[0].usedBytes) ) {
+ return wsmRet=SML_ERR_INVALID_SIZE;
+ }
+
+ // adapt usedSize
+ wsmBuf[0].usedBytes += usedSize;
+
+ // move pFirstFree
+ wsmBuf[0].pFirstFree += usedSize;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wsmReset
+ *
+ * Reset the Workspace
+ *
+ * PRE-Condition: -
+ *
+ * POST-Condition: all data is lost. The FirstFree Position equals
+ * the First Data position
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ *
+ */
+Ret_t wsmReset (MemHandle_t wsmH) {
+ wsmBuf[0].pFirstFree = wsmBuf[0].pFirstFree - wsmBuf[0].usedBytes ;
+ wsmBuf[0].pFirstData = wsmBuf[0].pFirstFree;
+ wsmBuf[0].usedBytes = 0;
+
+ return SML_ERR_OK;
+}
+
+
+#endif // #ifndef __SML_LITE__
+
+#endif // #idndef NOWSM
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/wsm/src/wsm_sm.c b/engine/dmlib/dmengine/oma_toolkit/sml/wsm/src/wsm_sm.c
new file mode 100644
index 0000000..b59c17d
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/wsm/src/wsm_sm.c
@@ -0,0 +1,510 @@
+/*************************************************************************/
+/* module: SyncML WorkSpace Manager */
+/* file: WSM_SM.c */
+/* target system: MS Windows */
+/* target OS: Windows 98 / NT */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Storage Management for Workspace Manager API. <BR>
+ * MS Windows version.
+ *
+ * @version @label
+ *
+ */
+
+#ifndef NOWSM
+// if no WSM, we can leave this one out completely
+
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "wsm_sm.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include "libmem.h"
+#include "liblock.h" // for THREADDEBUGPRINTF %%% luz
+#include "smldef.h"
+#include "smlerr.h"
+
+
+/* Global Vars */
+/* =========== */
+
+/** root of buffer list */
+
+#include "mgr.h"
+#define root (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm
+
+/* private functions prototypes */
+static Byte_t newListEle(const char *name, smWinList_t **newEle, MemHandle_t *newHandle);
+static Byte_t locateEle(const char *eleName, smWinList_t **p);
+static Byte_t locateH(MemHandle_t memH, smWinList_t **p);
+static void removeEle(const char *eleName);
+
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+/** create new buffer element and assign name to it
+ * return pointer to new element and handle of new element
+ */
+/*
+ SCTSTK - 16/03/2002 S.H. 2002-04-05 : fixed so that it works even if the sequence of buffer termination
+ is not in the reverse order of buffer creation
+ */
+
+// luz %%% NOTE: called only from routines which lock the toolkit already,
+// no separate lock required here
+static Byte_t newListEle(const char *name,
+ smWinList_t **newEle,
+ MemHandle_t *newHandle
+)
+{
+ smWinList_t *p;
+ int i;
+ for ( i=0; *newHandle < MAX_WSM_BUFFERS && (mgrGetSyncMLAnchor())->wsmGlobals->wsmBuf[i].memH != -1; ++i ) {};
+ if (i == MAX_WSM_BUFFERS) return 0;
+ *newHandle=i+1;
+
+ if ( ((*newEle) = smlLibMalloc(sizeof(smWinList_t))) == 0 )
+ return 0; // no more memory
+ if ( ((*newEle)->memName = smlLibMalloc(strlen(name)+1)) == 0 ){
+ smlLibFree(*newEle);
+ return 0; // no more memory
+ }
+ memcpy((*newEle)->memName, name, strlen(name));
+ (*newEle)->memName[strlen(name)] = '\0';
+ if ( root == 0 )
+ root = *newEle;
+ else {
+ p=root;
+ while ( p->next != NULL) p = p->next;
+ p->next = *newEle;
+ }
+ return 1;
+}
+
+
+/**
+ * search for buffer with name eleName and return pointer to it in p.
+ * return == 0 if not found; 1 if found
+ */
+// luz %%% NOTE: called only from routines which lock the toolkit already,
+// no separate lock required here
+static Byte_t locateEle(const char *eleName, smWinList_t **p) {
+ *p = root;
+ while ( (*p != NULL) && (strcmp((*p)->memName, eleName) != 0) ) {
+ *p = (*p)->next;
+ }
+ if ( *p == NULL )
+ return 0;
+ else
+ return 1;
+}
+
+/**
+ * search for buffer with memHandle memH and return pointer to it in p.
+ * return == 0 if not found; 1 if found
+ */
+// luz %%% NOTE: called only from routines which lock the toolkit already,
+// no separate lock required here
+static Byte_t locateH(MemHandle_t memH, smWinList_t **p) {
+ *p = root;
+ while ( (*p != NULL) && ((*p)->memH != memH) ) {
+ *p = (*p)->next;
+ }
+ if ( *p == NULL )
+ return 0;
+ else
+ return 1;
+}
+
+/**
+ * remove buffer with name eleName from smWinList.
+ */
+// luz %%% NOTE: called only from routines which lock the toolkit already,
+// no separate lock required here
+static void removeEle(const char *eleName) {
+ smWinList_t *act, *old;
+
+ old = act = root;
+ while ( (act != NULL) && (strcmp(act->memName, eleName) != 0) ) {
+ old = act;
+ act = act->next;
+ }
+ if ( act != NULL ) {
+ if ( old == act ) // delete first list ele
+ root = act->next;
+ else
+ old->next = act->next;
+ smlLibFree(act->memName);
+ smlLibFree(act);
+ }
+}
+
+
+
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+
+/**
+ * FUNCTION: smCreate
+ *
+ * Creates a new memory block with name memName and size memSize.
+ *
+ * PRE-Condition: OS does not know memName; memSize > 0
+ *
+ * POST-Condition: memName exists with size memSize;
+ * memH refers to new memory block.
+ *
+ * IN: memName
+ * Name of new memory block
+ * IN: memSize
+ * Size of new memory block
+ *
+ * OUT: memH
+ * Handle to new memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if memName is already known to the OS
+ * SML_ERR_INVALID_SIZE, if memSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < memSize
+ *
+ * @see smDestroy
+ */
+Ret_t smCreate (String_t memName, MemSize_t memSize, MemHandle_t *memH) {
+ smWinList_t *pEle; // pointer to new buffer
+
+ if ( memSize <= 0 ) {
+ return SML_ERR_INVALID_SIZE;
+ }
+ if ( locateEle(memName, &pEle) ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ // create new element in buffer list
+ if ( ! newListEle(memName, &pEle, memH) ) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // create memory
+ if ( (pEle->winH=smlLibMalloc(memSize)) == 0 ) {
+ smlLibFree(pEle->memName);
+ smlLibFree(pEle);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // set new values
+ pEle->locked = 0;
+ pEle->memH = *memH;
+ pEle->memSize = memSize;
+ pEle->next = NULL;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smOpen
+ *
+ * Open connection to memory block with name memName.
+ *
+ * PRE-Condition: OS does know memName
+ *
+ * POST-Condition: memH refers to memory block memName
+ *
+ * IN: memName
+ * Name of memory block to open<BR>
+ * Windows version: Name is ignored
+ *
+ * OUT: memH
+ * Handle to opened memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memName is unknown
+ *
+ * @see smClose
+ */
+Ret_t smOpen (String_t memName, MemHandle_t *memH) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateEle(memName, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+
+ *memH = pEle->memH;
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smClose
+ *
+ * Close link to memory block.
+ *
+ * PRE-Condition: memH is a valid memory block handle; memH is unlocked;
+ * no pointers to records are in use
+ *
+ * POST-Condition: memH is not valid anymore
+ *
+ * IN: memH
+ * Handle to close
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if memH is locked or unknown
+ *
+ * @see smOpen
+ */
+Ret_t smClose (MemHandle_t memH) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ // reset handle
+ smlLibFree(pEle->winH);
+ pEle->memH = 0;
+ pEle->locked = 0;
+ pEle->memSize = 0;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smDestroy
+ *
+ * Remove memory block memName within OS.
+ *
+ * PRE-Condition: memName is a valid memory block name;
+ * memory block is not in use (i.e. no handles and
+ * pointers to this memory block are in use)
+ *
+ * POST-Condition: memName is not a valid memory block name anymore
+ *
+ * IN: memName
+ * Name of memory block to remove
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memName is unknown
+ * SML_ERR_WRONG_USAGE, if memory block is still locked
+ *
+ * @see smCreate
+ */
+Ret_t smDestroy (String_t memName) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateEle(memName, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+ if ( pEle->locked ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ // remove memory buffer
+ removeEle(memName);
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smLock
+ *
+ * Map memory block memH to local address space.
+ *
+ * PRE-Condition: memH is a valid handle; memory block is not locked
+ *
+ * POST-Condition: pMem points to memory block memH;
+ * memory block is locked
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * OUT: pMem
+ * Pointer to memory block memH mapped in local address space
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH was already locked
+ * SML_ERR_UNSPECIFIC, if lock failed
+ *
+ * @see smUnlock
+ */
+Ret_t smLock (MemHandle_t memH, MemPtr_t *pMem) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+ if ( pEle->locked ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ *pMem = (MemPtr_t)pEle->winH;
+ pEle->locked = 1;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smUnlock
+ *
+ * Free pointer mapped to memH memory block.
+ *
+ * PRE-Condition: memH is a valid handle; memory block is locked
+ *
+ * POST-Condition: memory block is unlocked
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH was already unlocked
+ * SML_ERR_UNSPECIFIC, if unlock failed
+ *
+ * @see smLock
+ */
+Ret_t smUnlock (MemHandle_t memH) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+ if ( ! pEle->locked ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ pEle->locked = 0;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smSetSize
+ *
+ * Set size of memory block memH to newSize.
+ *
+ * PRE-Condition: memH is a valid handle; newSize > 0;
+ * memory block is unlocked
+ *
+ * POST-Condition: memory block size = newSize
+ *
+ * IN: memH
+ * Handle to memory block
+ * IN: newSize
+ * New size of memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH is locked
+ * SML_ERR_INVALID_SIZE, if newSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < newSize
+ *
+ * @see smGetSize
+ */
+Ret_t smSetSize (MemHandle_t memH, MemSize_t newSize) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+ if ( pEle->locked ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+ if ( newSize <= 0 ) {
+ return SML_ERR_INVALID_SIZE;
+ }
+
+ smlLibFree(pEle->winH);
+ if ( (pEle->winH=smlLibMalloc(newSize)) == 0 ) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ pEle->memSize = newSize;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smGetSize
+ *
+ * Get size of memory block memH.
+ *
+ * PRE-Condition: memH is a valid handle
+ *
+ * POST-Condition: actSize = memory block size
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * OUT: actSize
+ * Actual size of memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ *
+ * @see smSetSize
+ */
+Ret_t smGetSize (MemHandle_t memH, MemSize_t *actSize) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+
+ *actSize = pEle->memSize;
+
+ return SML_ERR_OK;
+}
+
+#endif // #ifndef NOWSM
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/hdr/xltdec.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/hdr/xltdec.h
new file mode 100644
index 0000000..9fec585
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/hdr/xltdec.h
@@ -0,0 +1,240 @@
+/*************************************************************************/
+/* module: Interface for the XLT Decoder component. */
+/* file: XLTDec.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * Interface for the WBXML and XML decoder component.
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#ifndef _XLT_DEC_H
+#define _XLT_DEC_H
+
+#include <smldef.h>
+#include <smldtd.h>
+#include <smlerr.h>
+
+#include "xltdeccom.h"
+#include "xltutilstack.h"
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+/**
+ * The XLT Decoder Interface consists of a single XltDecoder "object"
+ * (struct) and an creation/initialization function. The XltDecoder
+ * object contains all "public" methods and data structures. The first
+ * parameter for any public method is the object of which the method is
+ * called.
+ *
+ * The decoder's public methods/attributes are:
+ *
+ * ATTRIBUTE: charset
+ *
+ * Character set used in the document - this is the MIBEnum value assigned
+ * by the IANA for the character encoding, e.g. "3" for US-ASCII.
+ *
+ * ATTRIBUTE: charsetStr
+ *
+ * Name of the character set, e.g. "US-ASCII" - valid only when charset == 0.
+ *
+ * ATTRIBUTE: finished
+ *
+ * Indicates whether the decoder has reached the end of the buffer during
+ * the last call to xltDecNext.
+ *
+ * ATTRIBUTE: scanner
+ *
+ * Pointer to the scanner status object used by this decoder. The scanner
+ * will be created during the initialization of the decoder as either a XML
+ * or WBXML scanner.
+ *
+ *
+ * ATTRIBUTE: tagstack
+ *
+ * The decoder uses an internal stack to check that for every start tag
+ * there is a corresponding end tag.
+
+ */
+typedef struct XltDecoder_s
+{
+ Long_t charset;
+ String_t charsetStr;
+ Flag_t finished;
+ Boolean_t final;
+ XltDecScannerPtr_t scanner;
+ XltUtilStackPtr_t tagstack;
+#ifdef __USE_DMTND__
+ SmlEncoding_t smlEncoding;
+ SmlEncoding_t tndsEncoding;
+#endif
+
+} XltDecoder_t, *XltDecoderPtr_t;
+
+/**
+ * FUNCTION: xltDecInit
+ *
+ * Initializes a new decoder object. This function allocates memory for the
+ * decoder structure which has to be freed by a call to the decoder's
+ * terminate method when the decoder is not needed anymore. As part of the
+ * initialization the decoder begins decoding the SyncML document to find
+ * the SyncHdr element.
+ *
+ * PRE-Condition:
+ * ppDecoder is NULL
+ * ppBufPos
+ *
+ * POST-Condition:
+ * ppDecoder points to an initialized decoder status object
+ *
+ * IN: enc, the document encoding (WBXML or XML)
+ * pBufEnd, pointer to the end of the buffer which contains
+ * the document
+ *
+ * IN/OUT: ppBufPos, pointer to the current position within the
+ * buffer
+ *
+ * OUT: ppDecoder, the decoder status object
+ * ppSyncHdr, the SyncHdr element
+ *
+ * RETURNS: SML_ERR_OK, if the decoder could be created and the
+ * SmlSyncHdr was found
+ * else error code
+ */
+Ret_t xltDecInit(const SmlEncoding_t enc,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ XltDecoderPtr_t *ppDecoder,
+ SmlSyncHdrPtr_t *ppSyncHdr);
+
+/**
+ * FUNCTION: xltDecNext
+ *
+ * Decodes the next protocol element of the given SyncML document. This
+ * function creates the data structures detailed in the SMLDtd header file.
+ * It is the responsibility of the SyncML client application to free the
+ * allocated memory after it is done processing the data.
+ * This function sets the decoder's finished flag if no protocol element was
+ * found. In that case pPE is set to SML_PE_UNDEF and pContent is NULL.
+ *
+ * PRE-Condition:
+ * pDecoder points to a decoder status object initialized
+ * by xltDecInit
+ *
+ * POST-Condition:
+ * pPE and pContent describe the next valid protocol
+ * element within the SyncML document OR
+ * the finished flag of the decoder status object is set
+ *
+ * IN: pBufEnd, pointer to the end of the buffer
+ *
+ * IN/OUT: pDecoder, the decoder status object
+ * ppBufPos, pointer to the current position within the
+ * buffer before and after the call to xltDecNext
+ *
+ * OUT: pPE, the type of the protocol element (e.g. SML_PE_ADD)
+ * pContent, the data structure for the p.e. cast
+ * (e.g. AddPtr_t) to a void pointer
+ *
+ * RETURN: SML_ERR_OK, if a valid protocol element was found or if
+ * decoder reached the end of the buffer
+ * else error code showing where the parsing failed
+ */
+Ret_t xltDecNext(XltDecoderPtr_t pDecoder,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ SmlProtoElement_t *pPE,
+ VoidPtr_t *pContent);
+
+/**
+ * FUNCTION: xltDecTerminate
+ *
+ * Frees the memory allocated by the decoder.
+ *
+ * PRE-Condition:
+ * pDecoder points to a decoder status object initialized
+ * by xltDecInit
+ *
+ * POST-Condition:
+ * all memory allocated by the decoder status object is
+ * freed
+ *
+ * IN: pDecoder, the decoder
+ *
+ * RETURN: SML_ERR_OK, if the memory could be freed
+ * else error code
+ */
+Ret_t xltDecTerminate(XltDecoderPtr_t pDecoder);
+
+
+Ret_t xltDecReset(XltDecoderPtr_t pDecoder);
+
+/* T.K. moved here from xltdec.c for use in sub-DTD parsing */
+#define IS_START(tok) ((tok)->type == TOK_TAG_START)
+#define IS_END(tok) ((tok)->type == TOK_TAG_END)
+#define IS_EMPTY(tok) ((tok)->type == TOK_TAG_EMPTY)
+#define IS_TAG(tok) (IS_START(tok) || IS_EMPTY(tok) || IS_END(tok))
+#define IS_START_OR_EMPTY(tok) (IS_START(tok) || IS_EMPTY(tok))
+#define IS_CONTENT(tok) ((tok)->type == TOK_CONT)
+/**
+ * nextToken and discardToken are just wrappers around the scanner's
+ * nextTok and pushTok methods that do some error checking.
+ */
+Ret_t nextToken(XltDecoderPtr_t pDecoder);
+Ret_t discardToken(XltDecoderPtr_t pDecoder);
+/* eof xltdec.c stuff */
+
+#ifdef __SML_WBXML__
+/*Added by w21034 begin*/
+Ret_t wbxml2xmlInternal(unsigned char *bufIn, int bufInLen, unsigned char *bufOut, int * bufOutLen);
+/*Added by w21034 end*/
+#endif
+
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/hdr/xltenc.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/hdr/xltenc.h
new file mode 100644
index 0000000..3a3fc3b
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/hdr/xltenc.h
@@ -0,0 +1,201 @@
+/*************************************************************************/
+/* module: Encoder header file */
+/* file: xltenc.h */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#ifndef _XLT_ENC_H
+#define _XLT_ENC_H
+
+
+#include <smlerr.h>
+#include <xltenccom.h>
+#include <smldef.h>
+#include <smldtd.h>
+#include <xlttags.h>
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+//Type for storing encoder information
+typedef struct XltEncoder_s
+{
+ SmlEncoding_t enc;
+ SmlVersion_t vers; // %%% luz 2003-07-31: added SyncML version here
+ SmlPcdataExtension_t cur_ext;
+ SmlPcdataExtension_t last_ext;
+ Boolean_t final;
+ XltSpaceEvaluationPtr_t space_evaluation;
+ MemSize_t end_tag_size;
+} XltEncoder_t, *XltEncoderPtr_t;
+
+
+/**
+ * FUNCTION: smlXltEncInit
+ *
+ * Initializes an XML buffer; Creates XML code for the SyncHdr
+ * and appends it to the buffer.
+ * Returns 0 if operation was successful.
+ *
+ * PRE-Condition: no memory should be allocated for ppEncoder (should be NULL)
+ * pHeader has to contain a valid SyncHdr structure
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: enc, the encoding constant (SML_WBXML or SML_XML)
+ * pHeader, the SyncML header structure
+ * pBufEnd, pointer to the end of the buffer to write on
+ * %%% luz:2003-07-31: vers must be the SyncML version (for namespaces and FPI's)
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ * ppEncoder, the encoder object
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_CONTENT_SIZE_LENGTH
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncInit(SmlEncoding_t enc, const SmlSyncHdrPtr_t pHeader, const MemPtr_t pBufEnd, MemPtr_t *ppBufPos, XltEncoderPtr_t *ppEncoder, SmlVersion_t vers);
+
+/**
+ * FUNCTION: smlXltEncAppend
+ *
+ * Generates XML code and appends it to the XML buffer.
+ *
+ * PRE-Condition: pEncoder holds the initialized encoder structure.
+ * the initialization takes place in the xltEncAppend function
+ * pContent has to contain a valid content structure structure
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: pEncoder, the encoder object
+ * pe, the protocol element (PE_ADD, ...)
+ * pBufEnd, pointer to the end of the buffer to write on
+ * pContent, the content to append to the SyncML document
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_CONTENT_SIZE_LENGTH
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+
+Ret_t xltEncAppend(const XltEncoderPtr_t pEncoder,
+ SmlProtoElement_t pe,
+ const MemPtr_t pBufEnd,
+ const VoidPtr_t pContent,
+ MemPtr_t *ppBufPos);
+/**
+ * FUNCTION: smlXltEncTerminate_t pBufEnd, const VoidPtr_t pContent, MemPtr_t *ppBufPos,
+ *
+ * Finalizes the (WB)XML document and returns the size of written bytes to
+ * the workspace module
+ *
+ * PRE-Condition: pEncoder holds the initialized encoder structure.
+ * the initialization takes place in the xltEncAppend function
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: pEncoder, the encoder object
+ * pBufEnd, pointer to the end of the buffer to write on
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_CONTENT_SIZE_LENGTH
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncTerminate(const XltEncoderPtr_t pEncoder, const MemPtr_t pBufEnd, MemPtr_t *ppBufPos);
+Ret_t xltEncReset(XltEncoderPtr_t pEncoder);
+Ret_t xltGenerateTag(XltTagID_t, XltTagType_t, SmlEncoding_t, BufferMgmtPtr_t, SmlPcdataExtension_t);
+Ret_t xltStartEvaluation(XltEncoderPtr_t pEncoder);
+Ret_t xltEndEvaluation(InstanceID_t id, XltEncoderPtr_t pEncoder, MemSize_t *freemem);
+Ret_t xltEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+Ret_t xltBuildExtention(SmlPcdataExtension_t extId, XltRO_t reqOptFlag, VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr);
+Ret_t xltEncPcdata(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+Ret_t subdtdEncWBXML(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdec.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdec.c
new file mode 100644
index 0000000..a3e182c
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdec.c
@@ -0,0 +1,2203 @@
+/*************************************************************************/
+/* module: SyncmML Decoder */
+/* file: XLTDec.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * The SyncML parser.
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#include "xltdec.h"
+#include "xltdeccom.h"
+#include "xlttags.h"
+#include "xltutilstack.h"
+#include "xlttagtbl.h"
+#include "xltmetinf.h"
+#include "xltdevinf.h"
+#include "xltdmtnd.h"
+
+#include <smldef.h>
+#include <smldtd.h>
+#include <smlmetinfdtd.h>
+#include <smldevinfdtd.h>
+#include <smldmtnddtd.h>
+#include <smlerr.h>
+
+#include <libmem.h>
+#include <libstr.h>
+#include <mgrutil.h>
+
+#ifdef __USE_EXTENSIONS__
+/* prototype for function in xltdecwbxml.c */
+void subdtdDecodeWbxml(XltDecoderPtr_t pDecoder,SmlPcdataPtr_t *ppPcdata);
+#endif
+
+/**
+ * FUNCTION: concatPCData
+ *
+ * Tries to concatenate two Pcdata elements. Only works when the two
+ * elements are of the same type (e.g. SML_PCDATA_STRING). Returns a
+ * pointer to the new Pcdata element or NULL if concatenation failed.
+ */
+static SmlPcdataPtr_t concatPCData(SmlPcdataPtr_t pDat1, const SmlPcdataPtr_t pDat2);
+
+
+/**
+ * FUNCTION: appendXXXList
+ *
+ * These are auxiliary functions for building SyncML elements that contain
+ * lists of certain other data structures (e.g. Items). They take an
+ * existing list (e.g. of type ItemListPtr_t) and append an appropriate
+ * element at the end. If the ListPtr points to NULL a new list is created.
+ *
+ * PRE-Condition:
+ * The scanner's current token is the start tag (may be
+ * empty) of the SyncML element to be appended to the list.
+ *
+ * POST-Condition:
+ * The scanner's current token is the end tag (or empty
+ * start tag) of the SyncML element that was added to the
+ * list.
+ *
+ * IN/OUT: pDecoder, the decoder
+ * ppXXXList, NULL or an initialized list, to which element
+ * will be appended
+ *
+ * RETURNS: SML_ERR_OK, if an element was successfully appended
+ * else error code
+ */
+static Ret_t appendItemList(XltDecoderPtr_t pDecoder, SmlItemListPtr_t *ppItemList);
+static Ret_t appendSourceList(XltDecoderPtr_t pDecoder, SmlSourceListPtr_t *ppSourceList);
+#ifdef MAPITEM_RECEIVE
+ static Ret_t appendMapItemList(XltDecoderPtr_t pDecoder, SmlMapItemListPtr_t *ppMapItemList);
+#endif
+static Ret_t appendTargetRefList(XltDecoderPtr_t pDecoder, SmlTargetRefListPtr_t *ppTargetRefList);
+static Ret_t appendSourceRefList(XltDecoderPtr_t pDecoder, SmlSourceRefListPtr_t *ppSourceRefList);
+
+/* if the commands are not defined we let the functions point to NULL */
+#ifndef RESULT_RECEIVE
+#define buildResults NULL
+#endif
+
+#ifndef MAP_RECEIVE
+#define buildMap NULL
+#endif
+
+#ifndef EXEC_RECEIVE
+#define buildExec NULL
+#endif
+
+#if !defined(ATOM_RECEIVE) && !defined(SEQUENCE_RECEIVE)
+#define buildAtomOrSeq NULL
+#endif
+
+#ifndef SEARCH_RECEIVE
+#define buildSearch NULL
+#endif
+
+
+typedef struct PEBuilder_s
+{
+ XltTagID_t tagid;
+ SmlProtoElement_t type;
+ Ret_t (*build)(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+} PEBuilder_t, *PEBuilderPtr_t;
+
+PEBuilderPtr_t getPETable(void);
+
+PEBuilderPtr_t getPETable(void)
+{
+ PEBuilderPtr_t _tmpPEPtr;
+ PEBuilder_t PE[] = {
+ { TN_ADD, SML_PE_ADD, buildGenericCmd },
+ { TN_ALERT, SML_PE_ALERT, buildAlert },
+ { TN_ATOMIC, SML_PE_ATOMIC_START, buildAtomOrSeq },
+ { TN_COPY, SML_PE_COPY, buildGenericCmd },
+ { TN_DELETE, SML_PE_DELETE, buildGenericCmd },
+ { TN_EXEC, SML_PE_EXEC, buildExec },
+ { TN_GET, SML_PE_GET, buildPutOrGet },
+ { TN_MAP, SML_PE_MAP, buildMap },
+ { TN_PUT, SML_PE_PUT, buildPutOrGet },
+ { TN_RESULTS, SML_PE_RESULTS, buildResults },
+ { TN_SEARCH, SML_PE_SEARCH, buildSearch },
+ { TN_SEQUENCE, SML_PE_SEQUENCE_START, buildAtomOrSeq },
+ { TN_STATUS, SML_PE_STATUS, buildStatus },
+ { TN_SYNC, SML_PE_SYNC_START, buildSync },
+ { TN_REPLACE, SML_PE_REPLACE, buildGenericCmd },
+ { TN_UNDEF, SML_PE_UNDEF, 0 }
+ };
+
+ _tmpPEPtr = smlLibMalloc(sizeof(PE));
+ if (_tmpPEPtr == NULL) return NULL;
+ smlLibMemcpy(_tmpPEPtr, &PE, sizeof(PE));
+ return _tmpPEPtr;
+}
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+/**
+ * Description see XLTDec.h header file.
+ */
+Ret_t
+xltDecInit(const SmlEncoding_t enc,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ XltDecoderPtr_t *ppDecoder,
+ SmlSyncHdrPtr_t *ppSyncHdr)
+{
+ XltDecoderPtr_t pDecoder;
+ Ret_t rc;
+
+
+ /* create new decoder object */
+ if ((pDecoder = (XltDecoderPtr_t)smlLibMalloc(sizeof(XltDecoder_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ pDecoder->finished = 0;
+ pDecoder->final = 0;
+ pDecoder->scanner = NULL;
+ if ((rc = xltUtilCreateStack(&pDecoder->tagstack, 10)) != SML_ERR_OK) {
+ xltDecTerminate(pDecoder);
+ return rc;
+ }
+
+#ifdef __SML_WBXML__
+ if (enc == SML_WBXML)
+ {
+ rc = xltDecWbxmlInit(pBufEnd, ppBufPos, &pDecoder->scanner);
+ if (rc == SML_ERR_OK)
+ {
+ pDecoder->charset = pDecoder->scanner->charset;
+ pDecoder->charsetStr = NULL;
+ }
+ } else
+#endif
+
+#ifdef __SML_XML__
+ if (enc == SML_XML)
+ {
+
+ rc = xltDecXmlInit(pBufEnd, ppBufPos, &pDecoder->scanner);
+ if (rc == SML_ERR_OK)
+ {
+ pDecoder->charset = 0;
+ pDecoder->charsetStr = pDecoder->scanner->charsetStr;
+ }
+ } else
+#endif
+
+ {
+ rc = SML_ERR_XLT_ENC_UNK;
+ }
+
+ if (rc != SML_ERR_OK)
+ {
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return rc;
+ }
+
+ /* try to find SyncHdr element, first comes the SyncML tag... */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return rc;
+ }
+ if (!IS_START(pDecoder->scanner->curtok) ||
+ (pDecoder->scanner->curtok->tagid != TN_SYNCML)) {
+ smlFreePcdata(pDecoder->scanner->curtok->pcdata);
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ /* ... then the SyncHdr */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return rc;
+ }
+ if ((rc = buildSyncHdr(pDecoder, (VoidPtr_t)ppSyncHdr)) != SML_ERR_OK) {
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return rc;
+ }
+
+ *ppBufPos = pDecoder->scanner->getPos(pDecoder->scanner);
+
+#ifdef __DM_TND__
+ pDecoder->smlEncoding = enc;
+ pDecoder->tndsEncoding = pDecoder->smlEncoding;
+#endif
+ *ppDecoder = (XltDecoderPtr_t)pDecoder;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * Description see XLTDec.h header file.
+ */
+Ret_t
+xltDecNext(XltDecoderPtr_t pDecoder,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ SmlProtoElement_t *pe,
+ VoidPtr_t *ppContent)
+{
+ XltDecoderPtr_t pDecPriv = (XltDecoderPtr_t)pDecoder;
+ XltDecScannerPtr_t pScanner = pDecPriv->scanner;
+ XltTagID_t tagid;
+ Ret_t rc;
+ int i;
+
+ pScanner->setBuf(pScanner, *ppBufPos, pBufEnd);
+
+ /* if we are still outside the SyncBody, look for SyncBody start tag */
+ if ((rc = pDecPriv->tagstack->top(pDecPriv->tagstack, &tagid)) != SML_ERR_OK)
+ return rc;
+ if (tagid == TN_SYNCML) {
+ if (((rc = nextToken(pDecPriv)) != SML_ERR_OK)) {
+ return rc;
+ }
+ if (!((IS_START(pScanner->curtok)) &&
+ (pScanner->curtok->tagid == TN_SYNCBODY))) {
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+ }
+ }
+
+ if ((rc = nextToken(pDecPriv)) != SML_ERR_OK)
+ return rc;
+
+ /* if we find a SyncML protocol element build the corresponding
+ data structure */
+ if ((IS_START_OR_EMPTY(pScanner->curtok)) && (pScanner->curtok->tagid != TN_FINAL)) {
+
+ PEBuilderPtr_t pPEs = getPETable();
+ if (pPEs == NULL)
+ {
+ smlLibFree(pPEs);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ i = 0;
+ while (((pPEs+i)->tagid) != TN_UNDEF)
+ {
+ if (((pPEs+i)->tagid) == pScanner->curtok->tagid)
+ {
+ *pe = ((pPEs+i)->type);
+ if ((rc = (pPEs+i)->build(pDecPriv, ppContent)) != SML_ERR_OK)
+ {
+ smlLibFree(pPEs);
+ return rc;
+ }
+ /* T.K. adjust the SML_PE_ for 'generic' structures */
+ if (*pe == SML_PE_GENERIC) {
+ SmlGenericCmdPtr_t g = *ppContent;
+ switch ((int) ((pPEs+i)->tagid)) {
+ case TN_ADD : g->elementType = SML_PE_ADD; break;
+ case TN_COPY : g->elementType = SML_PE_COPY; break;
+ case TN_DELETE : g->elementType = SML_PE_DELETE; break;
+ case TN_REPLACE: g->elementType = SML_PE_REPLACE; break;
+ }
+ }
+ break;
+ }
+ i++;
+ }
+ if (((pPEs+i)->tagid) == TN_UNDEF)
+ {
+ *pe = SML_PE_UNDEF;
+ *ppContent = NULL;
+ smlLibFree(pPEs);
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+ }
+ smlLibFree(pPEs);
+ } else {
+
+ /* found end tag */
+ switch (pScanner->curtok->tagid) {
+ case TN_ATOMIC:
+ *pe = SML_PE_ATOMIC_END;
+ *ppContent = NULL;
+ break;
+ case TN_SEQUENCE:
+ *pe = SML_PE_SEQUENCE_END;
+ *ppContent = NULL;
+ break;
+ case TN_SYNC:
+ *pe = SML_PE_SYNC_END;
+ *ppContent = NULL;
+ break;
+ case TN_FINAL:
+ *pe = SML_PE_FINAL;
+ *ppContent = NULL;
+ pDecPriv->final = 1;
+ break;
+ case TN_SYNCBODY:
+ /* next comes the SyncML end tag, then we're done */
+ if ((rc = nextToken(pDecPriv)) != SML_ERR_OK)
+ return rc;
+ if ((pScanner->curtok->type == TOK_TAG_END) &&
+ (pScanner->curtok->tagid == TN_SYNCML)) {
+ *pe = SML_PE_UNDEF;
+ *ppContent = NULL;
+ pDecPriv->finished = 1;
+ } else {
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ break;
+ default:
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+ }
+ }
+
+ *ppBufPos = pScanner->getPos(pScanner);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * Description see XLTDec.h header file.
+ */
+Ret_t
+xltDecTerminate(XltDecoderPtr_t pDecoder)
+{
+ XltDecoderPtr_t pDecPriv;
+
+ if (pDecoder == NULL)
+ return SML_ERR_OK;
+
+ pDecPriv = (XltDecoderPtr_t)pDecoder;
+ if (pDecPriv->scanner != NULL)
+ pDecPriv->scanner->destroy(pDecPriv->scanner);
+ if (pDecPriv->tagstack != NULL)
+ pDecPriv->tagstack->destroy(pDecPriv->tagstack);
+ smlLibFree(pDecPriv);
+
+ return SML_ERR_OK;
+}
+
+
+Ret_t xltDecReset(XltDecoderPtr_t pDecoder)
+{
+ return xltDecTerminate(pDecoder);
+}
+
+/**
+ * Gets the next token from the scanner.
+ * Checks if the current tag is an end tag and if so, whether the last
+ * open start tag has the same tag id as the current end tag. An open start
+ * tag is one which matching end tag has not been seen yet.
+ * If the current tag is a start tag its tag ID will be pushed onto the
+ * tag stack.
+ * If the current tag is an empty tag or not a tag at all nothing will be
+ * done.
+ */
+Ret_t
+nextToken(XltDecoderPtr_t pDecoder)
+{
+ XltUtilStackPtr_t pTagStack;
+ XltDecTokenPtr_t pToken;
+ Ret_t rc;
+
+#ifdef __USE_DMTND__
+ // TODO
+ if ( pDecoder->smlEncoding != pDecoder->tndsEncoding )
+ {
+ KCDBG("pDecoder->smlEncoding != pDecoder->tndsEncoding\n");
+ return SML_ERR_OK;
+ }
+#endif
+
+ if ((rc = pDecoder->scanner->nextTok(pDecoder->scanner)) != SML_ERR_OK)
+ return rc;
+
+ pToken = pDecoder->scanner->curtok;
+ pTagStack = pDecoder->tagstack;
+
+ if (IS_START(pToken)) {
+ if (pTagStack->push(pTagStack, pToken->tagid))
+ return SML_ERR_UNSPECIFIC;
+ } else if (IS_END(pToken)) {
+ XltTagID_t lastopen;
+ if (pTagStack->pop(pTagStack, &lastopen))
+ return SML_ERR_UNSPECIFIC;
+ if (pToken->tagid != lastopen)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ return SML_ERR_OK;
+}
+
+Ret_t discardToken(XltDecoderPtr_t pDecoder)
+
+{
+ Ret_t rc;
+ XltTagID_t tmp;
+ if ((rc = pDecoder->scanner->pushTok(pDecoder->scanner)) != SML_ERR_OK)
+ return rc;
+ if ((rc = pDecoder->tagstack->pop(pDecoder->tagstack, &tmp)) != SML_ERR_OK)
+ return rc;
+ return SML_ERR_OK;
+}
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+static SmlPcdataPtr_t
+concatPCData(SmlPcdataPtr_t pDat1, const SmlPcdataPtr_t pDat2)
+{
+ if (pDat1->contentType != pDat2->contentType)
+ return NULL;
+
+ switch (pDat1->contentType) {
+ case SML_PCDATA_STRING:
+ pDat1->content = (VoidPtr_t)smlLibStrcat(pDat1->content, pDat2->content);
+ pDat1->length += pDat2->length;
+ break;
+ case SML_PCDATA_OPAQUE:
+ if ((pDat1->content = smlLibRealloc(pDat1->content, pDat1->length + pDat2->length)) == NULL)
+ return NULL;
+ smlLibMemmove(((Byte_t*)pDat1->content) + pDat1->length, pDat2->content, pDat2->length);
+ pDat1->length += pDat2->length;
+ break;
+ default:
+ return NULL;
+ }
+ return pDat1;
+}
+
+Ret_t
+buildSyncHdr(XltDecoderPtr_t pDecoder, VoidPtr_t *ppSyncHdr)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlSyncHdrPtr_t pSyncHdr;
+ Ret_t rc;
+ Long_t sessionid = 0, msgid = 0, source = 0, target = 0, version = 0, proto = 0;
+
+ /* shortcut to the scanner object */
+ pScanner = pDecoder->scanner;
+
+ /* if ppSyncHdr is not NULL we've already
+ found a SyncHdr before! */
+ if (*ppSyncHdr != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ /* initialize new SmlSyncHdr */
+ if ((pSyncHdr = (SmlSyncHdrPtr_t)smlLibMalloc(sizeof(SmlSyncHdr_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pSyncHdr, 0, sizeof(SmlSyncHdr_t));
+
+ /* initialize the element type field */
+ pSyncHdr->elementType = SML_PE_HEADER;
+
+ /* empty SmlSyncHdr is possible */
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppSyncHdr = pSyncHdr;
+ return SML_ERR_OK;
+ }
+
+ /* get next Token */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pSyncHdr);
+ return rc;
+ }
+
+ /* parse child elements until we find a matching end tag */
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_VERSION:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->version);
+ version++;
+ break;
+ case TN_PROTO:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->proto);
+ proto++;
+ break;
+ case TN_SESSIONID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->sessionID);
+ sessionid++;
+ break;
+ case TN_MSGID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->msgID);
+ msgid++;
+ break;
+ case TN_RESPURI:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->respURI);
+ break;
+
+ /* child tags */
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSyncHdr->target);
+ target++;
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSyncHdr->source);
+ source++;
+ break;
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pSyncHdr->cred);
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->meta);
+ break;
+
+ /* flags (empty tags) */
+ case TN_NORESP:
+ pSyncHdr->flags |= SmlNoResp_f;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ /* decoding of child element went ok? */
+ if (rc != SML_ERR_OK) {
+ smlFreeSyncHdr(pSyncHdr);
+
+ return rc;
+ }
+
+ /* get next token */
+ if ((rc = nextToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeSyncHdr(pSyncHdr);
+ return rc;
+ }
+ }
+
+ if ((sessionid == 0) || (msgid == 0) || (target == 0) || (source == 0) || (version == 0) || (proto == 0))
+ {
+ smlFreeSyncHdr(pSyncHdr);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppSyncHdr = pSyncHdr;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildSync(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlSyncPtr_t pSync;
+ Ret_t rc;
+ Long_t cmdid = 0;
+
+ /* stop decoding the Sync when we find a SyncML command */
+ Byte_t break_sync = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ /* initialize a new Sync */
+ if ((pSync = (SmlSyncPtr_t)smlLibMalloc(sizeof(SmlSync_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pSync, 0, sizeof(SmlSync_t));
+
+ /* initialize the element type field */
+ pSync->elementType = SML_PE_SYNC_START;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+
+ smlLibFree(pSync);
+ return SML_ERR_OK;
+ }
+
+ /* get next token */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pSync);
+ return rc;
+ }
+
+ /* parse child elements until we find a matching end tag
+ or until we find a TN_ADD, TN_ATOMIC, etc. start tag */
+ while ((pScanner->curtok->type != TOK_TAG_END) && !break_sync) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSync->cmdID);
+ cmdid++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSync->meta);
+ break;
+ case TN_NUMBEROFCHANGES:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSync->noc);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pSync->cred);
+ break;
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSync->target);
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSync->source);
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pSync->flags |= SmlNoResp_f;
+ break;
+
+ /* quit if we find an Add, Atomic, etc.
+ element */
+ case TN_ADD:
+ case TN_ATOMIC:
+ case TN_COPY:
+ case TN_DELETE:
+ case TN_SEQUENCE:
+ case TN_REPLACE:
+ break_sync = 1;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeSync(pSync);
+ return rc;
+ }
+ if (!break_sync) {
+ /* get next token and continue as usual */
+ if ((rc = nextToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeSync(pSync);
+ return rc;
+ }
+ } else {
+ /* we've found a SyncML command - we need to go
+ back one token and correct the tagstack */
+ if ((rc = discardToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeSync(pSync);
+ return rc;
+ }
+ }
+ }
+
+ if (!break_sync) {
+ if ((pScanner->curtok->tagid) != TN_SYNC)
+ {
+ smlFreeSync(pSync);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ else
+ {
+ if (pDecoder->tagstack->push(pDecoder->tagstack, pScanner->curtok->tagid))
+ {
+ smlFreeSync(pSync);
+ return SML_ERR_UNSPECIFIC;
+ }
+ if ((rc = pDecoder->scanner->pushTok(pDecoder->scanner)) != SML_ERR_OK)
+ {
+ smlFreeSync(pSync);
+ return rc;
+ }
+ }
+ }
+
+ *ppElem = pSync;
+
+ return SML_ERR_OK;
+}
+
+#if (defined ATOMIC_RECEIVE || defined SEQUENCE_RECEIVE)
+Ret_t
+buildAtomOrSeq(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlAtomicPtr_t pAoS; /* SmlAtomicPtr_t and SequencePtr_t are pointer
+ to the same structure! */
+ Ret_t rc;
+ Byte_t break_aos = 0; /* stop decoding the Atomic when we find a
+ SyncML command */
+ Long_t cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pAoS = (SmlAtomicPtr_t)smlLibMalloc(sizeof(SmlAtomic_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pAoS, 0, sizeof(SmlAtomic_t));
+
+ /* initialize the element type field */
+ pAoS->elementType = SML_PE_CMD_GROUP;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pAoS);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ /* get next token */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree (pAoS);
+ return rc;
+ }
+
+ /* parse child elements until we find a matching end tag
+ or until we find a TN_ADD, TN_ATOMIC, etc. start tag */
+ while ((pScanner->curtok->type != TOK_TAG_END) && !break_aos) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAoS->cmdID);
+ cmdid++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAoS->meta);
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pAoS->flags |= SmlNoResp_f;
+ break;
+
+ /* quit if we find an Add, Atomic, etc.
+ element */
+ case TN_ADD:
+ case TN_REPLACE:
+ case TN_DELETE:
+ case TN_COPY:
+ case TN_ATOMIC:
+ case TN_MAP:
+ case TN_SYNC:
+ case TN_GET:
+ case TN_ALERT:
+ case TN_EXEC:
+ break_aos = 1;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeAtomic(pAoS);
+ return rc;
+ }
+ if (!break_aos) {
+ if ((rc = nextToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeAtomic(pAoS);
+ return rc;
+ }
+ } else {
+ /* we've found a SyncML command - we need to go
+ back one token and correct the tagstack */
+ if ((rc = discardToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeAtomic(pAoS);
+ return rc;
+ }
+ }
+ }
+
+ if (!break_aos) {
+ /* Atomic/Sequence must contain at least one SyncML command */
+ smlFreeAtomic(pAoS);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (cmdid == 0)
+ {
+ smlFreeAtomic(pAoS);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pAoS;
+
+ return SML_ERR_OK;
+}
+#endif
+
+#ifdef EXEC_RECEIVE
+Ret_t
+buildExec(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlExecPtr_t pExec;
+ Ret_t rc;
+ Long_t items = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pExec = (SmlExecPtr_t)smlLibMalloc(sizeof(SmlExec_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pExec, 0, sizeof(SmlExec_t));
+
+ /* initialize the element type field */
+ pExec->elementType = SML_PE_EXEC;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pExec);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pExec);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCData */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pExec->cmdID);
+ cmdid++;
+ break;
+
+ case TN_CORRELATOR:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pExec->correlator);
+ break;
+
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pExec->meta);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pExec->cred);
+ break;
+
+ case TN_ITEM:
+ rc = buildItem(pDecoder, (VoidPtr_t)&pExec->item);
+ items++;
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pExec->flags |= SmlNoResp_f;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeExec(pExec);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeExec(pExec);
+ return rc;
+ }
+ }
+
+ if ((items == 0) || (cmdid == 0)) {
+ smlFreeExec(pExec);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pExec;
+
+ return SML_ERR_OK;
+}
+#endif
+
+Ret_t
+buildGenericCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlGenericCmdPtr_t pGenCmd;
+ Ret_t rc;
+ Long_t items = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ /* initialize a new GenericCmd */
+ if ((pGenCmd = (SmlGenericCmdPtr_t)smlLibMalloc(sizeof(SmlGenericCmd_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pGenCmd, 0, sizeof(SmlGenericCmd_t));
+
+ /* initialize the element type field */
+ pGenCmd->elementType = SML_PE_GENERIC;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pGenCmd);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pGenCmd);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGenCmd->cmdID);
+ cmdid++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGenCmd->meta);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pGenCmd->cred);
+ break;
+
+ /* flags (empty tags) */
+ case TN_NORESP:
+ pGenCmd->flags |= SmlNoResp_f;
+ break;
+ case TN_ARCHIVE:
+ pGenCmd->flags |= SmlArchive_f;
+ break;
+ case TN_SFTDEL:
+ pGenCmd->flags |= SmlSftDel_f;
+ break;
+
+ /* Lists */
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, &pGenCmd->itemList);
+ items++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeGeneric(pGenCmd);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeGeneric(pGenCmd);
+ return rc;
+ }
+ }
+
+ if ((items == 0) || (cmdid == 0))
+ {
+ smlFreeGeneric(pGenCmd);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pGenCmd;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildAlert(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlAlertPtr_t pAlert;
+ Ret_t rc;
+ Long_t cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pAlert = (SmlAlertPtr_t)smlLibMalloc(sizeof(SmlAlert_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pAlert, 0, sizeof(SmlAlert_t));
+
+ /* initialize the element type field */
+ pAlert->elementType = SML_PE_ALERT;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pAlert);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pAlert);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAlert->cmdID);
+ cmdid++;
+ break;
+
+ case TN_CORRELATOR:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAlert->correlator);
+ break;
+
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAlert->data);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pAlert->cred);
+ break;
+
+ /* flags (empty tags) */
+ case TN_NORESP:
+ pAlert->flags |= SmlNoResp_f;
+ break;
+
+ /* Lists */
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, &pAlert->itemList);
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeAlert(pAlert);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeAlert(pAlert);
+ return rc;
+ }
+ }
+
+ if (cmdid == 0)
+ {
+ smlFreeAlert(pAlert);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pAlert;
+
+ return SML_ERR_OK;
+}
+
+#ifdef MAP_RECEIVE
+Ret_t
+buildMap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlMapPtr_t pMap;
+ Ret_t rc;
+ Long_t target = 0, source = 0, mapitems = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pMap = (SmlMapPtr_t)smlLibMalloc(sizeof(SmlMap_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pMap, 0, sizeof(SmlMap_t));
+
+ /* initialize the element type field */
+ pMap->elementType = SML_PE_MAP;
+
+ /* Source is required */
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pMap);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pMap);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMap->cmdID);
+ cmdid++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMap->meta);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pMap->cred);
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pMap->source);
+ source++;
+ break;
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pMap->target);
+ target++;
+ break;
+#ifdef MAPITEM_RECEIVE
+ /* Lists */
+ case TN_MAPITEM:
+ rc = appendMapItemList(pDecoder, &pMap->mapItemList);
+ mapitems++;
+ break;
+#endif
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMap(pMap);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMap(pMap);
+ return rc;
+ }
+ }
+
+ if ((source == 0) || (mapitems == 0) || (target == 0) || (cmdid == 0)) {
+ smlFreeMap(pMap);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pMap;
+
+ return SML_ERR_OK;
+}
+#endif
+
+#ifdef SEARCH_RECEIVE
+Ret_t
+buildSearch(XltDecoderPtr_t pDecoder, VoidPtr_t *ppSearch)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlSearchPtr_t pSearch;
+ Ret_t rc;
+ Long_t source = 0, meta = 0, data = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppSearch != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pSearch = (SmlSearchPtr_t)smlLibMalloc(sizeof(SmlSearch_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pSearch, 0, sizeof(SmlSearch_t));
+
+ /* initialize the element type field */
+ pSearch->elementType = SML_PE_SEARCH;
+
+ /* Meta is required */
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pSearch);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pSearch);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSearch->cmdID);
+ cmdid++;
+ break;
+ case TN_LANG:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSearch->lang);
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSearch->meta);
+ meta++;
+ break;
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSearch->data);
+ data++;
+ break;
+
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pSearch->cred);
+ break;
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSearch->target);
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pSearch->flags |= SmlNoResp_f;
+ break;
+ case TN_NORESULTS:
+ pSearch->flags |= SmlNoResults_f;
+ break;
+
+ /* Lists */
+ case TN_SOURCE:
+ rc = appendSourceList(pDecoder, &pSearch->sourceList);
+ source++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeSearch(pSearch);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeSearch(pSearch);
+ return rc;
+ }
+ }
+
+ if ((source == 0) || (meta == 0) || (data == 0) || (cmdid == 0)) {
+ smlFreeSearch(pSearch);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppSearch = pSearch;
+
+ return SML_ERR_OK;
+}
+#endif
+
+Ret_t
+buildPutOrGet(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlGetPtr_t pGet;
+ Ret_t rc;
+ Long_t items = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pGet = (SmlGetPtr_t)smlLibMalloc(sizeof(SmlGet_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pGet, 0, sizeof(SmlGet_t));
+
+ /* initialize the element type field */
+ pGet->elementType = SML_PE_PUT_GET;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pGet);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pGet);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGet->cmdID);
+ cmdid++;
+ break;
+ case TN_LANG:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGet->lang);
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGet->meta);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pGet->cred);
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pGet->flags |= SmlNoResp_f;
+ break;
+
+ /* Lists */
+
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, &pGet->itemList);
+ items++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeGetPut(pGet);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeGetPut(pGet);
+ return rc;
+ }
+ }
+
+ if ((items == 0) || (cmdid == 0))
+ {
+ smlFreeGetPut(pGet);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pGet;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildTargetOrSource(XltDecoderPtr_t pDecoder, VoidPtr_t *ppTarget)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlTargetPtr_t pTarget;
+ Long_t locuri = 0;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppTarget != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pTarget = (SmlTargetPtr_t)smlLibMalloc(sizeof(SmlTarget_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pTarget, 0, sizeof(SmlTarget_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pTarget);
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pTarget);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_LOCURI:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pTarget->locURI);
+ locuri++;
+ break;
+ case TN_LOCNAME:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pTarget->locName);
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ if(pScanner->curtok->pcdata != NULL)
+ smlLibFree(pScanner->curtok->pcdata->content);
+ smlLibFree(pScanner->curtok->pcdata);
+ smlFreeSourceTargetPtr(pTarget);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeSourceTargetPtr(pTarget);
+ return rc;
+ }
+ }
+
+ if (locuri == 0)
+ {
+ smlFreeSourceTargetPtr(pTarget);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppTarget = pTarget;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildChal(XltDecoderPtr_t pDecoder, VoidPtr_t *ppChal)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlChalPtr_t pChal;
+ Long_t meta = 0;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppChal != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pChal = (SmlChalPtr_t)smlLibMalloc(sizeof(SmlChal_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pChal, 0, sizeof(SmlChal_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppChal = pChal;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pChal);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pChal->meta);
+ meta++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeChalPtr(pChal);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeChalPtr(pChal);
+ return rc;
+ }
+ }
+
+ if (meta == 0)
+ {
+ smlFreeChalPtr(pChal);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppChal = pChal;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildCred(XltDecoderPtr_t pDecoder, VoidPtr_t *ppCred)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlCredPtr_t pCred;
+ Ret_t rc;
+ Long_t data = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppCred != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pCred = (SmlCredPtr_t)smlLibMalloc(sizeof(SmlCred_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pCred, 0, sizeof(SmlCred_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppCred = pCred;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pCred);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pCred->data);
+ data++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pCred->meta);
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeCredPtr(pCred);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeCredPtr(pCred);
+ return rc;
+ }
+ }
+
+ if (data == 0)
+ {
+ smlFreeCredPtr(pCred);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppCred = pCred;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildItem(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlItemPtr_t pItem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pItem = (SmlItemPtr_t)smlLibMalloc(sizeof(SmlItem_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pItem, 0, sizeof(SmlItem_t));
+
+ /* Item might be empty */
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pItem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pItem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pItem->meta);
+ break;
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pItem->data);
+#ifdef __USE_EXTENSIONS__
+#ifdef __SML_WBXML__
+ if (pItem->data && pItem->data->contentType == SML_PCDATA_OPAQUE)
+ subdtdDecodeWbxml(pDecoder, (SmlPcdataPtr_t*)&pItem->data);
+#endif
+#endif
+ break;
+ /* child tags */
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pItem->target);
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pItem->source);
+ break;
+
+ /* flags */
+ case TN_MOREDATA:
+ pItem->flags |= SmlMoreData_f;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeItemPtr(pItem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeItemPtr(pItem);
+ return rc;
+ }
+ }
+
+ *ppElem = pItem;
+
+ return SML_ERR_OK;
+}
+
+#ifdef MAPITEM_RECEIVE
+Ret_t
+buildMapItem(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlMapItemPtr_t pMapItem;
+ Long_t target = 0, source = 0;
+ Ret_t rc;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ pScanner = pDecoder->scanner;
+
+ if ((pMapItem = (SmlMapItemPtr_t)smlLibMalloc(sizeof(SmlMapItem_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pMapItem, 0, sizeof(SmlMapItem_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pMapItem);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pMapItem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* child tags */
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pMapItem->target);
+ target++;
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pMapItem->source);
+ source++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMapItemPtr(pMapItem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMapItemPtr(pMapItem);
+ return rc;
+ }
+ }
+
+ if ((target == 0) || (source == 0)) {
+ smlFreeMapItemPtr(pMapItem);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pMapItem;
+
+ return SML_ERR_OK;
+}
+
+#endif
+
+Ret_t
+buildStatus(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlStatusPtr_t pStatus;
+ Ret_t rc;
+ Long_t cmd = 0, data = 0, cmdid = 0;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ pScanner = pDecoder->scanner;
+
+ if ((pStatus = (SmlStatusPtr_t)smlLibMalloc(sizeof(SmlStatus_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pStatus, 0, sizeof(SmlStatus_t));
+
+ /* initialize the element type field */
+ pStatus->elementType = SML_PE_STATUS;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pStatus);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pStatus);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCData elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->cmdID);
+ cmdid++;
+ break;
+ case TN_MSGREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->msgRef);
+ break;
+ case TN_CMDREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->cmdRef);
+ break;
+ case TN_CMD:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->cmd);
+ cmd++;
+ break;
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->data);
+ data++;
+ break;
+ case TN_CHAL:
+ rc = buildChal(pDecoder, (VoidPtr_t)&pStatus->chal);
+ break;
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pStatus->cred);
+ break;
+
+ /* Lists */
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, (VoidPtr_t)&pStatus->itemList);
+ break;
+ case TN_TARGETREF:
+ rc = appendTargetRefList(pDecoder, (VoidPtr_t)&pStatus->targetRefList);
+ break;
+ case TN_SOURCEREF:
+ rc = appendSourceRefList(pDecoder, (VoidPtr_t)&pStatus->sourceRefList);
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeStatus(pStatus);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeStatus(pStatus);
+ return rc;
+ }
+ }
+
+ if ((cmd == 0) || (data == 0) || (cmdid == 0))
+ {
+ smlFreeStatus(pStatus);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pStatus;
+
+ return SML_ERR_OK;
+}
+
+#ifdef RESULT_RECEIVE
+Ret_t
+buildResults(XltDecoderPtr_t pDecoder, VoidPtr_t *ppResults)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlResultsPtr_t pResults;
+ Ret_t rc;
+ Long_t cmdref = 0, items = 0, cmdid = 0;
+
+ if (*ppResults != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ pScanner = pDecoder->scanner;
+
+ if ((pResults = (SmlResultsPtr_t)smlLibMalloc(sizeof(SmlResults_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pResults, 0, sizeof(SmlResults_t));
+
+ /* initialize the element type field */
+ pResults->elementType = SML_PE_RESULTS;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pResults);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pResults);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->cmdID);
+ cmdid++;
+ break;
+ case TN_MSGREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->msgRef);
+ break;
+ case TN_CMDREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->cmdRef);
+ cmdref++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->meta);
+ break;
+ case TN_TARGETREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->targetRef);
+ break;
+ case TN_SOURCEREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->sourceRef);
+ break;
+
+ /* Lists */
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, &pResults->itemList);
+ items++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeResults(pResults);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeResults(pResults);
+ return rc;
+ }
+ }
+
+ if ((cmdref == 0) || (items == 0) || (cmdid == 0))
+ {
+ smlFreeResults(pResults);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppResults = pResults;
+
+ return SML_ERR_OK;
+}
+
+#endif
+
+Ret_t
+buildPCData(XltDecoderPtr_t pDecoder, VoidPtr_t *ppPCData)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlPcdataPtr_t pPCData = 0;
+ SmlPcdataExtension_t ext;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppPCData != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ if ((pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+
+ smlLibMemset(pPCData, 0, sizeof(SmlPcdata_t));
+
+ *ppPCData = pPCData;
+ return SML_ERR_OK;
+ }
+
+ pPCData = NULL;
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ if (rc == SML_ERR_XLT_INVAL_SYNCML_DOC) { /* leaks if dtd failed */
+ pPCData = pScanner->curtok->pcdata;
+ *ppPCData = pPCData;
+ }
+
+ return rc;
+ }
+
+ if (IS_CONTENT(pScanner->curtok)) {
+ /* PCData element has a regular string or opaque content */
+ while (pScanner->curtok->type == TOK_CONT) {
+ if (pPCData == NULL)
+ pPCData = pScanner->curtok->pcdata;
+ else {
+ pPCData = concatPCData(pPCData, pScanner->curtok->pcdata);
+ smlLibFree(pScanner->curtok->pcdata->content);
+ smlLibFree(pScanner->curtok->pcdata);
+
+ if (pPCData == NULL)
+ return SML_ERR_XLT_INVAL_PCDATA;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ *ppPCData = pPCData;
+ return rc;
+ }
+ }
+ } else if (IS_START_OR_EMPTY(pScanner->curtok)) {
+ /* PCData element contains an XML dokument that is handled by an
+ extension mechanism */
+ ext = pScanner->curtok->ext;
+ if ((rc = discardToken(pDecoder)) != SML_ERR_OK) return rc;
+ if ((pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pPCData, 0, sizeof(SmlPcdata_t));
+ pPCData->contentType = SML_PCDATA_EXTENSION;
+ pPCData->extension = ext;
+ switch (ext) {
+#ifdef __USE_METINF__
+ case SML_EXT_METINF:
+
+ if ((rc = buildMetInfMetInfCmd(pDecoder, (VoidPtr_t)&pPCData->content)) != SML_ERR_OK) {
+ smlLibFree(pPCData);
+ return rc;
+ }
+ break;
+#endif
+#ifdef __USE_DEVINF__
+ case SML_EXT_DEVINF:
+
+ if ((rc = buildDevInfDevInfCmd(pDecoder, (VoidPtr_t)&pPCData->content)) != SML_ERR_OK) {
+
+ smlLibFree(pPCData);
+ return rc;
+ }
+
+ /* the scanner must point to the closing PCDATA tag */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pPCData);
+ return rc;
+ }
+ break;
+#endif
+#ifdef __USE_DMTND__
+ case SML_EXT_DMTND:
+
+ if ((rc = buildDmTndCmd(pDecoder, (VoidPtr_t)&pPCData->content)) != SML_ERR_OK) {
+
+ smlLibFree(pPCData);
+ return rc;
+ }
+
+ /* the scanner must point to the closing PCDATA tag */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pPCData);
+ return rc;
+ }
+ break;
+#endif
+ default:
+ smlFreePcdata(pPCData);
+ return SML_ERR_XLT_INVAL_EXT;
+ }
+
+ } else if (IS_END(pScanner->curtok)) {
+ /* PCData element is empty */
+ } else {
+ return SML_ERR_XLT_INVAL_PCDATA;
+ }
+
+
+ if (pScanner->curtok->type != TOK_TAG_END)
+ return SML_ERR_XLT_INVAL_PCDATA;
+
+ if (pPCData == NULL) {
+ if ((pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pPCData, 0, sizeof(SmlPcdata_t));
+ }
+
+ *ppPCData = pPCData;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildPCDataList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppPCData)
+{
+ SmlPcdataListPtr_t pPCDataList = NULL, pPrev = NULL;
+
+ pPCDataList = (SmlPcdataListPtr_t) *ppPCData;
+
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pPCDataList != NULL) {
+ pPrev = pPCDataList;
+ pPCDataList = pPrev->next;
+ }
+ if ((pPCDataList = (SmlPcdataListPtr_t)smlLibMalloc(sizeof(SmlPcdataList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pPCDataList, 0, sizeof(SmlPcdataList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pPCDataList;
+ else /* nope we created a new list */
+ *ppPCData = pPCDataList;
+ pPCDataList->data = NULL;
+ /* at this point pPCDataList should point to an valid list element */
+ return buildPCData(pDecoder, (VoidPtr_t)&pPCDataList->data);
+}
+
+
+static Ret_t
+appendItemList(XltDecoderPtr_t pDecoder, SmlItemListPtr_t *ppItemList)
+{
+ SmlItemListPtr_t pNewItemList;
+ SmlItemListPtr_t pItemList;
+ Ret_t rc;
+
+ pItemList = *ppItemList;
+ if (pItemList != NULL)
+ while (pItemList->next != NULL)
+ pItemList = pItemList->next;
+
+ if ((pNewItemList = (SmlItemListPtr_t)smlLibMalloc(sizeof(SmlItemList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewItemList, 0, sizeof(SmlItemList_t));
+
+ if ((rc = buildItem(pDecoder, (VoidPtr_t)&pNewItemList->item)) != SML_ERR_OK) {
+ smlLibFree(pNewItemList);
+ return rc;
+ }
+
+ if (pItemList == NULL)
+ *ppItemList = pNewItemList;
+ else
+ pItemList->next = pNewItemList;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+appendSourceList(XltDecoderPtr_t pDecoder, SmlSourceListPtr_t *ppSourceList)
+{
+ SmlSourceListPtr_t pNewSourceList;
+ SmlSourceListPtr_t pSourceList;
+ Ret_t rc;
+
+ pSourceList = *ppSourceList;
+ if (pSourceList != NULL)
+ while (pSourceList->next != NULL)
+ pSourceList = pSourceList->next;
+
+ if ((pNewSourceList = (SmlSourceListPtr_t)smlLibMalloc(sizeof(SmlSourceList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewSourceList, 0, sizeof(SmlSourceList_t));
+
+ if ((rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pNewSourceList->source)) != SML_ERR_OK) {
+ smlLibFree(pNewSourceList);
+ return rc;
+ }
+
+ if (pSourceList == NULL)
+ *ppSourceList = pNewSourceList;
+ else
+ pSourceList->next = pNewSourceList;
+
+ return SML_ERR_OK;
+}
+
+#ifdef MAPITEM_RECEIVE
+
+static Ret_t
+appendMapItemList(XltDecoderPtr_t pDecoder, SmlMapItemListPtr_t *ppMapItemList)
+{
+ SmlMapItemListPtr_t pNewMapItemList;
+ SmlMapItemListPtr_t pMapItemList;
+ Ret_t rc;
+
+ pMapItemList = *ppMapItemList;
+ if (pMapItemList != NULL)
+ while (pMapItemList->next != NULL)
+ pMapItemList = pMapItemList->next;
+
+ if ((pNewMapItemList = (SmlMapItemListPtr_t)smlLibMalloc(sizeof(SmlMapItemList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewMapItemList, 0, sizeof(SmlMapItemList_t));
+
+ if ((rc = buildMapItem(pDecoder, (VoidPtr_t)&pNewMapItemList->mapItem)) != SML_ERR_OK) {
+ smlLibFree(pNewMapItemList);
+ return rc;
+ }
+
+ if (pMapItemList == NULL)
+ *ppMapItemList = pNewMapItemList;
+ else
+ pMapItemList->next = pNewMapItemList;
+
+ return SML_ERR_OK;
+}
+#endif
+
+static Ret_t
+appendTargetRefList(XltDecoderPtr_t pDecoder, SmlTargetRefListPtr_t *ppTargetRefList)
+{
+ SmlTargetRefListPtr_t pNewTargetRefList;
+ SmlTargetRefListPtr_t pTargetRefList;
+ Ret_t rc;
+
+ pTargetRefList = *ppTargetRefList;
+ if (pTargetRefList != NULL)
+ while (pTargetRefList->next != NULL)
+ pTargetRefList = pTargetRefList->next;
+
+ if ((pNewTargetRefList = (SmlTargetRefListPtr_t)smlLibMalloc(sizeof(SmlTargetRefList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewTargetRefList, 0, sizeof(SmlTargetRefList_t));
+
+ if ((rc = buildPCData(pDecoder, (VoidPtr_t)&pNewTargetRefList->targetRef)) != SML_ERR_OK) {
+ smlFreePcdata(pNewTargetRefList->targetRef);
+ smlLibFree(pNewTargetRefList);
+ return rc;
+ }
+
+ if (pTargetRefList == NULL)
+ *ppTargetRefList = pNewTargetRefList;
+ else
+ pTargetRefList->next = pNewTargetRefList;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+appendSourceRefList(XltDecoderPtr_t pDecoder, SmlSourceRefListPtr_t *ppSourceRefList)
+{
+ SmlSourceRefListPtr_t pNewSourceRefList;
+ SmlSourceRefListPtr_t pSourceRefList;
+ Ret_t rc;
+
+ pSourceRefList = *ppSourceRefList;
+ if (pSourceRefList != NULL)
+ while (pSourceRefList->next != NULL)
+ pSourceRefList = pSourceRefList->next;
+
+ if ((pNewSourceRefList = (SmlSourceRefListPtr_t)smlLibMalloc(sizeof(SmlSourceRefList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewSourceRefList, 0, sizeof(SmlSourceRefList_t));
+
+ if ((rc = buildPCData(pDecoder, (VoidPtr_t)&pNewSourceRefList->sourceRef)) != SML_ERR_OK) {
+ smlFreePcdata(pNewSourceRefList->sourceRef);
+ smlLibFree(pNewSourceRefList);
+ return rc;
+ }
+
+ if (pSourceRefList == NULL)
+ *ppSourceRefList = pNewSourceRefList;
+ else
+ pSourceRefList->next = pNewSourceRefList;
+
+ return SML_ERR_OK;
+}
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdeccom.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdeccom.h
new file mode 100644
index 0000000..d77bc03
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdeccom.h
@@ -0,0 +1,241 @@
+/*************************************************************************/
+/* module: XML/WBXML scanner */
+/* file: XLTDecCom.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+/**
+ * Common header file for the WBXML and the XML scanner.
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#ifndef _XLT_DEC_COM_H
+#define _XLT_DEC_COM_H
+
+#include <smldef.h>
+#include <smldtd.h>
+#include "xlttags.h"
+
+#define DEC_ID XLT_DEC_ID + 0
+#define WBXML_ID XLT_DEC_ID + 200
+#define XML_ID XLT_DEC_ID + 400
+#define STACK_ID XLT_DEC_ID + 600
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+
+/* Token types returned by the scanner */
+typedef enum {
+ TOK_UNDEF = 0,
+ TOK_TAG_START,
+ TOK_TAG_END,
+ TOK_TAG_EMPTY,
+ TOK_CONT
+} XltTokType_t;
+
+/**
+ * Struct containing a token returned by the scanner
+ */
+typedef struct
+{
+ XltTokType_t type; /* XLT_TOK_TAG_START, etc. */
+ XltTagID_t tagid; /* TN_SYNCHDR, etc. - valid for token of type
+ XLT_TOK_TAG_xxx */
+ SmlPcdataExtension_t ext; /* type of extension this tag belongs to -
+ valid for token of type XLT_TOK_TAG_xxx */
+ SmlPcdataPtr_t pcdata; /* valid for token of type XLT_TOK_CONT_xxx */
+ MemPtr_t start; /* pointer to the start of this token within
+ the document - needed for pushback */
+} XltDecToken_t, *XltDecTokenPtr_t;
+
+/**
+ * Public interface for the XML/WBXML scanner components.
+ *
+ * The struct used for holding the XML and WBXML scanner state information
+ * are the same - function pointers are used to map the "objects" public
+ * methods to the right functions for scanning XML and WBXML documents.
+ * This object-oriented interface enables the parser component to use the
+ * two scanners interchangeably.
+ * The interface contains serveral public methods and attributes:
+ *
+ * FUNCTION: nextTok
+ *
+ * Decodes the next valid token at the current position within the
+ * document. Information about this token is placed into the curtok
+ * attribute of the scanner object.
+ *
+ * PRE-Condition:
+ *
+ * POST-Condition:
+ * curtok contains the last valid token.
+ *
+ * IN:
+ *
+ * OUT:
+ *
+ * IN/OUT: the scanner
+ *
+ * RETURNS: SML_ERR_OK or an appropriate error code
+ *
+ *
+ * FUNCTION: destroy
+ *
+* Free the memory allocated by the scanner.
+*
+* PRE-Condition:
+* POST-Condition:
+*
+* IN:
+*
+* OUT:
+*
+* IN/OUT: the scanner
+*
+* RETURNS: SML_ERR_OK or an appropriate error code
+*
+*
+* FUNCTION: pushTok
+*
+* Resets the scanner to the beginning position within the document of the
+* last valid token stored in curtok. Only the last found token can be
+* pushed back. It is not possible to go back more than one token.
+*
+* PRE-Condition:
+* curtok contains a valid token.
+*
+* POST-Condition:
+* the next call of nextTok will find the token that was
+* pushed back.
+*
+* IN/OUT: the scanner
+*
+* RETURNS: SML_ERR_OK or an appropriate error code
+*
+* FUNCITON: setBuf
+*
+* Set the buffer the scanner works on.
+*
+* FUNCTION: getPos
+*
+* Get the current position of the scanner within the working buffer.
+*
+* ATTRIBUTE: curtok
+*
+* Contains the last valid token found by a call to nextTok.
+*
+* ATTRIBUTE: charset
+*
+* The charset information as specified in the XML/WBXML document. This is
+* the IANA assigned MIBEnum value.
+
+* ATTRIBUTE: charsetStr
+*
+* String representation of the charset. This attribute is valid only when
+* charset equals zero. Otherwise charsetStr will be NULL.
+*
+* ATTRIBUTE: pubID
+*
+* The document public identifier as specified in the XML/WBXML document.
+* This is the numeric identifier assigned by the WAP Forum. If this value
+* is zero, the public ID is instead specified as a string contained in the
+* pubIDStr public attribute.
+*
+* ATTRIBUTE: pubIDStr
+*
+* The string representation of the document public identifier as specified
+* in the XML/WBXML document (e.g. "-//WAPFORUM//DTD WML 1.0//EN"). This
+* attribute is valid only when pubID equals zero. Otherwise pubIDStr will
+* be NULL.
+*
+* ATTRIBUTE: finished
+*
+* This flag is set by the nextTok method when the scanner reaches the end
+* of the buffer.
+*/
+typedef struct XltDecScanner_s XltDecScanner_t, *XltDecScannerPtr_t;
+struct XltDecScanner_s
+{
+ /* public methods */
+ Ret_t (*nextTok)(XltDecScannerPtr_t pScanner);
+ Ret_t (*destroy)(XltDecScannerPtr_t pScanner);
+ Ret_t (*pushTok)(XltDecScannerPtr_t pScanner);
+ void (*setBuf)(XltDecScannerPtr_t pScanner, const MemPtr_t pBufStart, const MemPtr_t pBufEnd);
+ MemPtr_t (*getPos)(XltDecScannerPtr_t pScanner);
+
+ /* public attributes */
+ XltDecTokenPtr_t curtok;
+ Long_t charset;
+ String_t charsetStr;
+ Long_t pubID;
+ String_t pubIDStr;
+ Flag_t finished;
+};
+
+/**
+ * FUNCTION: xltDecWbxmlInit, xltDecXmlInit
+ *
+ * Initialize a new WBXML/XML scanner.
+ *
+ * PRE-Condition:
+ * ppScanner is NULL
+ *
+ * POST-Condition:
+ * ppScanner points to an initialized scanner status object
+ *
+ * IN: pBufEnd, buffer containing the WBXML/XML document
+ *
+ * IN/OUT: pBufPos, pointer to the current position within the
+ * buffer
+ *
+ * OUT: ppScanner, a new WBXML/XML scanner status object
+ *
+ * RETURNS: SML_ERR_OK or an appropriate error code
+ */
+Ret_t xltDecWbxmlInit(const MemPtr_t pBufEnd, MemPtr_t *ppBufPos, XltDecScannerPtr_t *ppScanner);
+Ret_t xltDecXmlInit(const MemPtr_t pBufEnd, MemPtr_t *ppBufPos, XltDecScannerPtr_t *ppScanner);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecwbxml.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecwbxml.c
new file mode 100644
index 0000000..1cf20e0
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecwbxml.c
@@ -0,0 +1,1483 @@
+/*************************************************************************/
+/* module: WBXML decoder */
+/* file: XLTDecWbxml.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * The WBXML scanner/tokenizer. Used by the SyncML parser.
+ */
+
+
+#include <define.h>
+#ifdef __SML_WBXML__
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#include "xltdevinf.h"
+#include "xltdeccom.h"
+#include "xlttags.h"
+#include "xltutilstack.h"
+#include "xltdec.h"
+
+#include <smldtd.h>
+#include <smldevinfdtd.h>
+#include <smlmetinfdtd.h>
+#include <smldmtnddtd.h>
+#include "mgrutil.h"
+
+#include <libmem.h>
+#include <libstr.h>
+
+#include <smlerr.h>
+#include <mgr.h>
+
+#ifdef IS_END /* to avoid redefinition of this macro */
+#undef IS_END
+#endif
+
+void
+subdtdDecodeWbxml(XltDecoderPtr_t pDecoder,SmlPcdataPtr_t *ppPcdata);
+
+
+/* WBXML version that this parser knows */
+#define _MAJOR_VERSION 1
+#define _MINOR_VERSION 2
+
+#define TAG_STATE 0
+#define ATTRIBUTE_STATE 1
+
+/* various checks about wbxml token */
+#define HAS_ATTRIBUTES(tag) (*tag & 0x80)
+#define HAS_CONTENT(tag) (*tag & 0x40)
+#define IDENTITY(tag) (*tag & 0x3F)
+
+#define IS_SWITCH(tok) (*(tok) == 0x00)
+#define IS_END(tok) (*(tok) == 0x01)
+#define IS_ENTITY(tok) (*(tok) == 0x02)
+#define IS_STR_I(tok) (*(tok) == 0x03)
+#define IS_LITERAL(tok) (IDENTITY(tok) == 0x04)
+// Note: gcc cannot parse multi-line macros when file has DOS line ends
+#define IS_EXT_I(tok) ((*(tok) == 0x40) || (*(tok) == 0x41) || (*(tok) == 0x42))
+#define IS_PI(tok) (*(tok) == 0x43)
+#define IS_EXT_T(tok) ((*(tok) == 0x80) || (*(tok) == 0x81) || (*(tok) == 0x82))
+#define IS_STR_T(tok) (*(tok) == 0x83)
+#define IS_EXT(tok) ((*(tok) == 0xC0) || (*(tok) == 0xC1) || (*(tok) == 0xC2))
+#define IS_OPAQUE(tok) (*(tok) == 0xC3)
+#define IS_STRING(tok) (IS_STR_I(tok) || IS_STR_T(tok))
+#define IS_EXTENSION(tok) (IS_EXT_I(tok) || IS_EXT_T(tok) || IS_EXT(tok))
+
+#define IS_ATTRIBUTE_VALUE(tok) (*(tok) & 0x80)
+#define IS_ATTRIBUTE_START(tok) (~IS_ATTRIBUTE_VALUE(tok))
+
+
+/**
+ * Private Interface for the WBXML scanner.
+ *
+ * The private scanner interface contains some additional member attributes
+ * that are not listed in the public interface, e.g. a copy of the string
+ * table and some other items that do not need to be known outside the
+ * scanner module.
+ */
+typedef struct wbxmlScannerPriv_s wbxmlScannerPriv_t, *wbxmlScannerPrivPtr_t;
+struct wbxmlScannerPriv_s
+{
+ /* public methods */
+ Ret_t (*nextTok)(XltDecScannerPtr_t);
+ Ret_t (*destroy)(XltDecScannerPtr_t);
+ Ret_t (*pushTok)(XltDecScannerPtr_t);
+ void (*setBuf)(XltDecScannerPtr_t pScanner, const MemPtr_t pBufStart, const MemPtr_t pBufEnd);
+ MemPtr_t (*getPos)(XltDecScannerPtr_t pScanner);
+
+ /* public attributes */
+ XltDecTokenPtr_t curtok; /* current token */
+ Long_t charset; /* character set as specified in the
+ WBXML header */
+ String_t charsetStr; /* NULL */
+ Long_t pubID; /* document public identifier as
+ specified in the WBXML header */
+ String_t pubIDStr; /* pubID as a string - valid only when
+ pubID == 0 */
+ Flag_t finished; /* set when end of buffer is reached */
+
+ /* private attributes */
+ MemPtr_t pos; /* current buffer position */
+ MemPtr_t bufend; /* end of buffer */
+ Long_t pubIDIdx; /* strtbl index of the string
+ version of the pubID - valid only
+ when pubID == 0 */
+
+ XltUtilStackPtr_t tagstack; /* stack of open start tags */
+
+ MemPtr_t strtbl; /* copy of the string table */
+ Long_t strtbllen; /* length of the string table */
+
+ Byte_t state; /* tag state or attribute state */
+ SmlPcdataExtension_t cptag; /* current codepage for tags */
+ Byte_t cpattr; /* current codepage for attributes */
+ SmlPcdataExtension_t activeExt; /* the active Sub DTD */
+};
+
+/* typedef for multi-byte unsigned integers as specified in the
+ WAP Binary XML Content Format specification */
+typedef Long_t MBINT;
+
+/**
+ * Public methods of the scanner interface.
+ *
+ * Description see XLTDecCom.h.
+ */
+static Ret_t _destroy(XltDecScannerPtr_t);
+static Ret_t _nextTok(XltDecScannerPtr_t);
+static Ret_t _pushTok(XltDecScannerPtr_t);
+static void _setBuf(XltDecScannerPtr_t, const MemPtr_t, const MemPtr_t);
+static MemPtr_t _getPos(XltDecScannerPtr_t);
+
+/**
+ * FUNCTION: readBytes
+ *
+ * Advance the current position pointer after checking whether the end of
+ * the buffer has been reached. If the end of the buffer has been reached
+ * the scanner's finished flag is set.
+
+ * RETURNS: 0, if end of buffer has been reached
+ * 1 otherwise
+ */
+static Boolean_t readBytes(wbxmlScannerPrivPtr_t pScanner, Long_t bytes);
+
+/**
+ * FUNCTION: parseInt
+ *
+ * Decodes multi-byte integers.
+ *
+ * PRE-Condition:
+ * pScanner->pos points to the first byte of the mb_int.
+ *
+ * POST-Condition:
+ * pScanner->pos points to the last byte of the mb_int.
+ */
+static Ret_t parseInt(wbxmlScannerPrivPtr_t pScanner, MBINT *mbi);
+
+/**
+ * FUNCTION: wbxmlHeader, wbxmlVersion, wbxmlPublicID, wbxmlCharset
+ *
+ * These functions are used for decoding the WBXML document header.
+ * wbxmlHeader is a short wrapper that calls the other four functions in
+ * the right order to scan the header. wbxmlStrtbl makes a copy of the
+ * string table.
+ */
+static Ret_t wbxmlHeader(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlVersion(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlPublicID(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlCharset(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlStrtbl(wbxmlScannerPrivPtr_t pScanner);
+
+/**
+ * FUNCTION: wbxmlSwitchPage
+ *
+ * Switch WBXML code page
+ */
+static Ret_t wbxmlSwitchPage(wbxmlScannerPrivPtr_t pScanner);
+
+/**
+ * FUNCTION: wbxmlXXXToken
+ *
+ * Scan the document for the next valid XML/WBXML token as defined in the
+ * XLTDecCom header file (e.g. TOK_TAG_START).
+ *
+ * PRE-Condition:
+ * pScanner->pos points to the first byte of a valid WBXML
+ * element (String, Tag, etc.)
+ *
+ * POST-Condition:
+ * pScanner->pos points to the last byte of the WBXML
+ * element;
+ * pScanner->curtok contains type and tagid or pcdata of
+ * the token
+ */
+static Ret_t wbxmlStringToken(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlOpaqueToken(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlTagToken(wbxmlScannerPrivPtr_t pScanner);
+
+/**
+ * FUNCTION: wbxmlXXXToken
+ *
+ * WBXML extensions, entities, processing instructions and attributes are
+ * not supported by this scanner. If one is found it is skipped and
+ * processing continues afterwards.
+ */
+static Ret_t wbxmlSkipExtension(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlSkipEntity(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlSkipPI(wbxmlScannerPrivPtr_t);
+static Ret_t wbxmlSkipAttribute(wbxmlScannerPrivPtr_t);
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+/**
+ * FUNCTION: XltDecWbxmlInit
+ *
+ * Create and initialize a new WBXML scanner. Description see XLTDec.h.
+ */
+Ret_t
+xltDecWbxmlInit(const MemPtr_t pBufEnd, MemPtr_t *ppBufPos,
+ XltDecScannerPtr_t *ppScanner)
+{
+ wbxmlScannerPrivPtr_t pScanner;
+ Ret_t rc;
+
+ /* initialize new WBXML scanner */
+ if ((pScanner = (wbxmlScannerPrivPtr_t)smlLibMalloc(sizeof(wbxmlScannerPriv_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pScanner, 0, sizeof(wbxmlScannerPriv_t));
+ pScanner->bufend = pBufEnd;
+ pScanner->pos = *ppBufPos;
+ if ((pScanner->curtok = (XltDecTokenPtr_t)smlLibMalloc(sizeof(XltDecToken_t))) == NULL) {
+ smlLibFree(pScanner);
+ *ppScanner = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ pScanner->curtok->pcdata = NULL;
+ if ((rc = xltUtilCreateStack(&pScanner->tagstack, 10)) != SML_ERR_OK) {
+ smlLibFree(pScanner->curtok);
+ smlLibFree(pScanner);
+ *ppScanner = NULL;
+ return rc;
+ }
+ pScanner->state = TAG_STATE;
+
+ /* point public/private methods to the right implementation */
+ pScanner->nextTok = _nextTok;
+ pScanner->destroy = _destroy;
+ pScanner->pushTok = _pushTok;
+ pScanner->setBuf = _setBuf;
+ pScanner->getPos = _getPos;
+
+ /* decode WBXML header */
+ if ((rc = wbxmlHeader(pScanner)) != SML_ERR_OK) {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ *ppScanner = NULL;
+ return rc;
+ }
+
+ *ppScanner = (XltDecScannerPtr_t)pScanner;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: destroy
+ *
+ * Free memory. Description see XltDecAll.h.
+ */
+static Ret_t
+_destroy(XltDecScannerPtr_t pScanner)
+{
+ wbxmlScannerPrivPtr_t pScannerPriv;
+
+ if (pScanner == NULL)
+ return SML_ERR_OK;
+
+ pScannerPriv = (wbxmlScannerPrivPtr_t)pScanner;
+ if (pScannerPriv->tagstack != NULL)
+ pScannerPriv->tagstack->destroy(pScannerPriv->tagstack);
+ smlLibFree(pScannerPriv->curtok);
+ smlLibFree(pScannerPriv->strtbl);
+ smlLibFree(pScannerPriv);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: nextTok
+ *
+ * Get next token.
+ */
+static Ret_t
+_nextTok(XltDecScannerPtr_t pScanner)
+{
+ wbxmlScannerPrivPtr_t pScannerPriv;
+ Ret_t rc;
+
+ pScannerPriv = (wbxmlScannerPrivPtr_t)pScanner;
+ // T.K.: chanched Ptr_t to _t
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScannerPriv->curtok->start = pScannerPriv->pos;
+
+ /* keep going until we find a "supported" element */
+ rc = SML_ERR_OK;
+ while (rc == SML_ERR_OK) {
+ /* skip PIs, extensions and entities... */
+ if (IS_PI(pScannerPriv->pos)) {
+ rc = wbxmlSkipPI(pScannerPriv);
+ } else if (IS_EXTENSION(pScannerPriv->pos)) {
+ rc = wbxmlSkipExtension(pScannerPriv);
+ } else if (IS_ENTITY(pScannerPriv->pos)) {
+ rc = wbxmlSkipEntity(pScannerPriv);
+
+ /* ... decode strings, opaque data and tags */
+ } else if (IS_STRING(pScannerPriv->pos)) {
+ rc = wbxmlStringToken(pScannerPriv);
+ break;
+ } else if (IS_OPAQUE(pScannerPriv->pos)) {
+ rc = wbxmlOpaqueToken(pScannerPriv);
+ break;
+ } else {
+ rc = wbxmlTagToken(pScannerPriv);
+ break;
+ }
+ }
+
+ return rc;
+}
+
+/**
+ * FUNCTION: pushTok
+ *
+ * Reset the scanner to the starting position of the current token within
+ * the buffer.
+ */
+static Ret_t
+_pushTok(XltDecScannerPtr_t pScanner)
+{
+ wbxmlScannerPrivPtr_t pScannerPriv;
+ XltUtilStackPtr_t pTagStack;
+ XltTagID_t tagid;
+ Ret_t rc = 0;
+
+ pScannerPriv = (wbxmlScannerPrivPtr_t)pScanner;
+ pTagStack = pScannerPriv->tagstack;
+
+ if (pScannerPriv->curtok->start == NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ /* reset scanner to position where tok begins */
+ pScannerPriv->pos = pScannerPriv->curtok->start;
+
+ /* correct the tag stack */
+ if (pScannerPriv->curtok->type == TOK_TAG_START) {
+ rc = pTagStack->pop(pTagStack, &tagid);
+ } else if (pScannerPriv->curtok->type == TOK_TAG_END) {
+ tagid = pScannerPriv->curtok->tagid;
+ rc = pTagStack->push(pTagStack, tagid);
+ }
+ if (rc) return rc;
+
+ /* invalidate curtok */
+ /* T.K. Possible Error. pScannerPriv->curtok is of type XltDecToken_t NOT ...Ptr_t */
+ // OrigLine:
+ // smlLibMemset(pScannerPriv->curtok, 0, sizeof(XltDecTokenPtr_t));
+ pScannerPriv->curtok->type = (XltTokType_t)0;
+
+ return SML_ERR_OK;
+}
+
+static void
+_setBuf(XltDecScannerPtr_t pScanner, const MemPtr_t pBufStart,
+ const MemPtr_t pBufEnd)
+{
+ wbxmlScannerPrivPtr_t pScannerPriv = (wbxmlScannerPrivPtr_t)pScanner;
+ pScannerPriv->pos = pBufStart;
+ pScannerPriv->bufend = pBufEnd;
+}
+
+static MemPtr_t
+_getPos(XltDecScannerPtr_t pScanner)
+{
+ return ((wbxmlScannerPrivPtr_t)pScanner)->pos;
+}
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+/**
+ * FUNCTION: readBytes
+ *
+ * Advance the position pointer. Description see above.
+ */
+static Boolean_t
+readBytes(wbxmlScannerPrivPtr_t pScanner, Long_t bytes)
+{
+ if (pScanner->pos + bytes > pScanner->bufend) {
+ pScanner->finished = 1;
+ return 0;
+ }
+ pScanner->pos += bytes;
+ return 1;
+}
+
+/**
+ * NOTICE: Entities, Extensions, Processing Instructions and Attributes
+ * are not supported by the WBXML scanner.
+ *
+ * Extensions and Attributes are document-specific and are as such not used
+ * by the SyncML specification.
+ * The scanner will just ignore and skip over them. Neither
+ * this scanner nor the parser use processing instructions so they are
+ * skipped as well.
+ */
+
+/**
+ * FUNCTION: wbxmlHeader
+ *
+ * Decode the WBXML header containing version number, document public
+ * identifier, character set and a string table.
+ */
+static Ret_t
+wbxmlHeader(wbxmlScannerPrivPtr_t pScanner)
+{
+ Ret_t rc;
+
+ /* decode the WBXML header */
+ if ((rc = wbxmlVersion(pScanner)) != SML_ERR_OK)
+ return rc;
+ if ((rc = wbxmlPublicID(pScanner)) != SML_ERR_OK)
+ return rc;
+ if ((rc = wbxmlCharset(pScanner)) != SML_ERR_OK)
+ return rc;
+ if ((rc = wbxmlStrtbl(pScanner)) != SML_ERR_OK)
+ return rc;
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlVersion
+ *
+ * Decode WBXML version. The scanner returns an error if the major version
+ * of the document differs from the major version this scanner supports or
+ * if the minor version of the document is larger than the minor version
+ * the scanner supports.
+ */
+static Ret_t
+wbxmlVersion(wbxmlScannerPrivPtr_t pScanner)
+{
+ Byte_t major, minor;
+
+ minor = ((Byte_t)(*pScanner->pos & 0x0F));
+ major = ((Byte_t)((*pScanner->pos >> 4) + 1));
+
+
+
+ if (major != _MAJOR_VERSION || minor > _MINOR_VERSION)
+ return SML_ERR_XLT_INCOMP_WBXML_VERS;
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlPublicID
+ *
+ * Decodes WBXML Document Public Identifier.
+ */
+static Ret_t
+wbxmlPublicID(wbxmlScannerPrivPtr_t pScanner)
+{
+ MBINT tmp;
+ Ret_t rc;
+
+ if (*pScanner->pos != 0) {
+ /* pre-defined numeric identifier */
+ if ((rc = parseInt(pScanner, &tmp)) != SML_ERR_OK)
+ return rc;
+ pScanner->pubID = tmp;
+ pScanner->pubIDIdx = 0;
+ } else {
+ /* public id is given as string table entry (which we
+ haven't read at this point so we'll save the reference
+ for later) */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((rc = parseInt(pScanner, &tmp)) != SML_ERR_OK)
+ return rc;
+ pScanner->pubID = 0;
+ pScanner->pubIDIdx = tmp;
+ }
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlCharset
+ *
+ * Decode WBXML Charset.
+ */
+static Ret_t
+wbxmlCharset(wbxmlScannerPrivPtr_t pScanner)
+{
+ /* TODO: if charset iformation has to be processed
+ it can be done here. For the moment only UTF-8 is used by SyncML */
+ MBINT mibenum;
+ Ret_t rc;
+
+ /* charset is given as a single IANA assigned MIBEnum value */
+ if ((rc = parseInt(pScanner, &mibenum)) != SML_ERR_OK)
+ return rc;
+ pScanner->charset = mibenum;
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlStrtbl
+ *
+ * Keep a copy of the string table.
+ */
+static Ret_t
+wbxmlStrtbl(wbxmlScannerPrivPtr_t pScanner)
+{
+ MBINT len;
+ Ret_t rc;
+
+ if ((rc = parseInt(pScanner, &len)) != SML_ERR_OK)
+ return rc;
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ pScanner->strtbllen = len;
+ if (len > 0) {
+ if (pScanner->pos + len > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((pScanner->strtbl = smlLibMalloc(len)) == NULL)
+ {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemcpy(pScanner->strtbl, pScanner->pos, len);
+ readBytes(pScanner, len);
+ } else {
+ pScanner->strtbl = NULL;
+ }
+
+ /* if the public ID was given as a string table reference save a
+ reference to the corresponding string for later */
+ if (pScanner->pubID == 0) {
+ if (pScanner->pubIDIdx > pScanner->strtbllen)
+ return SML_ERR_XLT_INVAL_WBXML_DOC;
+ pScanner->pubIDStr = (String_t)(pScanner->strtbl + pScanner->pubIDIdx);
+ }
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+parseInt(wbxmlScannerPrivPtr_t pScanner, MBINT *mbi)
+{
+ *mbi = 0;
+ /* accumulate byte value until continuation flag (MSB) is zero */
+ for (;;) {
+ *mbi = *mbi << 7;
+ *mbi += *(pScanner->pos) & 0x7F;
+ if (!(*pScanner->pos & 0x80)) break;
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ return SML_ERR_OK;
+}
+
+static Ret_t
+wbxmlStringToken(wbxmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPcdata;
+ Ret_t rc;
+
+ if ((pPcdata = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ /* copy the string into the new PCdata struct */
+ if (IS_STR_I(pScanner->pos)) {
+ /* inline string */
+ if (!readBytes(pScanner, 1))
+ {
+ /* LIBnn25123 Fix*/
+ if(pPcdata != NULL) { smlLibFree(pPcdata); pPcdata = NULL; }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ pPcdata->extension = SML_EXT_UNDEFINED;
+ pPcdata->contentType = SML_PCDATA_STRING;
+ pPcdata->length = smlLibStrlen((String_t)pScanner->pos);
+ if (pScanner->pos + pPcdata->length + 1 > pScanner->bufend) {
+ smlLibFree(pPcdata);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ if ((pPcdata->content = smlLibMalloc(pPcdata->length + 1)) == NULL) {
+ smlLibFree(pPcdata);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibStrncpy(pPcdata->content, (String_t)pScanner->pos, pPcdata->length + 1);
+ readBytes(pScanner, pPcdata->length + 1);
+
+ } else {
+ /* string table reference */
+ MBINT offset; /* offset into string table */
+ if (!readBytes(pScanner, 1))
+ {
+ /* LIBnn25123 Fix*/
+ if(pPcdata != NULL) { smlLibFree(pPcdata); pPcdata = NULL;}
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ if ((rc = parseInt(pScanner, &offset)) != SML_ERR_OK)
+ {
+ smlLibFree(pPcdata);
+ return rc;
+ }
+ if (offset >= pScanner->strtbllen) {
+ smlLibFree(pPcdata);
+ return SML_ERR_XLT_INVAL_WBXML_DOC;
+ }
+ pPcdata->contentType = SML_PCDATA_STRING;
+ pPcdata->length = smlLibStrlen((String_t)(pScanner->strtbl + offset));
+ if ((pPcdata->content = smlLibMalloc(pPcdata->length + 1)) == NULL) {
+ smlLibFree(pPcdata);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibStrncpy(pPcdata->content, (String_t)(pScanner->strtbl + offset), pPcdata->length + 1);
+ readBytes(pScanner, 1);
+ }
+
+ pScanner->curtok->pcdata = pPcdata;
+
+ pScanner->curtok->type = TOK_CONT;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+wbxmlOpaqueToken(wbxmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPcdata = NULL;
+ MBINT len;
+ Ret_t rc;
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ /* a mbi indicates the length of the opaque data block that we'll
+ copy into new PCdata struct */
+ if ((rc = parseInt(pScanner, &len)) != SML_ERR_OK)
+ return rc;
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if (pScanner->pos + len > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((pPcdata = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ pPcdata->extension = SML_EXT_UNDEFINED;
+ pPcdata->contentType = SML_PCDATA_OPAQUE;
+ pPcdata->length = len;
+ /* Modification 2001-07-03 by Luz %%%%%:
+ * made sure that content is one null byte longer
+ * than indicated opaque content, such that strings that are coded as
+ * opaque (happens to be the case with Nokia 9210) can still be read
+ * as C-string without need for an intermediate buffer
+ */
+ /* original:
+ if ((pPcdata->content = smlLibMalloc(len)) == NULL) {
+ smlLibFree(pPcdata);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ */
+ /* modified: */
+ if ((pPcdata->content = smlLibMalloc(len+1)) == NULL) {
+ smlLibFree(pPcdata);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ ((char *)pPcdata->content)[len]=0; /* make sure there is a c-string terminator */
+ /* end modification */
+
+ smlLibMemcpy(pPcdata->content, pScanner->pos, len);
+ pScanner->curtok->pcdata = pPcdata;
+
+ readBytes(pScanner, len);
+
+ pScanner->curtok->type = TOK_CONT;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+wbxmlTagToken(wbxmlScannerPrivPtr_t pScanner)
+{
+ XltTagID_t tagid;
+ Boolean_t has_cont, has_attr;
+ Ret_t rc;
+
+ if (IS_SWITCH(pScanner->pos)) {
+ if ((rc = wbxmlSwitchPage(pScanner)) != SML_ERR_OK)
+ return rc;
+ }
+
+ /* we have to look at the top of the tagstack to see which
+ start tag an end tag belongs to */
+ if (IS_END(pScanner->pos)) {
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ pScanner->curtok->type = TOK_TAG_END;
+ rc = pScanner->tagstack->pop(pScanner->tagstack, &tagid);
+ if (rc == SML_ERR_WRONG_USAGE)
+ return SML_ERR_XLT_INVAL_WBXML_DOC;
+ else if (rc)
+ return rc;
+ pScanner->curtok->tagid = tagid;
+ return SML_ERR_OK;
+ }
+
+
+ /* look at the two MSB: does this tag have content or attributes? */
+
+ has_cont = ((Boolean_t)(HAS_CONTENT(pScanner->pos)));
+ has_attr = ((Boolean_t)(HAS_ATTRIBUTES(pScanner->pos)));
+
+
+ /* look up tag ID either by string or by number */
+ if (IS_LITERAL(pScanner->pos)) {
+ MBINT offset; /* offset into the string table */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((rc = parseInt(pScanner, &offset)) != SML_ERR_OK)
+ return rc;
+ if (offset > pScanner->strtbllen)
+ return SML_ERR_XLT_INVAL_WBXML_DOC;
+
+ rc = (Ret_t)getTagIDByStringAndExt((String_t)(pScanner->strtbl + offset), pScanner->activeExt, &tagid);
+ if ((tagid == TN_UNDEF) || (rc != SML_ERR_OK)) return rc;
+
+ } else {
+ rc = (Ret_t)getTagIDByByteAndExt((Byte_t)IDENTITY(pScanner->pos), pScanner->activeExt, &tagid);
+ if ((tagid == TN_UNDEF) || (rc != SML_ERR_OK)) return rc;
+
+ }
+
+ /* we know everything we need to know */
+ pScanner->curtok->tagid = tagid;
+ pScanner->curtok->type = has_cont ? TOK_TAG_START : TOK_TAG_EMPTY;
+ switch ( pScanner->cptag )
+ {
+ case 0x00 :
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+ break;
+ case 0x01 :
+#ifdef __USE_METINF__
+ pScanner->curtok->ext = SML_EXT_METINF;
+#else
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+#endif
+ break;
+ case 0x02 :
+#ifdef __USE_DMTND__
+ pScanner->curtok->ext = SML_EXT_DMTND;
+#else
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+#endif
+ break;
+ case 0xFD2 :
+#ifdef __USE_DEVINF__
+ pScanner->curtok->ext = SML_EXT_DEVINF;
+#else
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+#endif
+ break;
+ default:
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+ break;
+ }
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ /* push tag onto tagstack unless this tag is empty */
+ if (has_cont) {
+ if ((rc = pScanner->tagstack->push(pScanner->tagstack, tagid)) != SML_ERR_OK)
+ return rc;
+ }
+
+ /* skip attributes */
+ if (has_attr) {
+ pScanner->state = ATTRIBUTE_STATE;
+ if ((rc = wbxmlSkipAttribute(pScanner)) != SML_ERR_OK)
+ return rc;
+ pScanner->state = TAG_STATE;
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlSwitchPage
+ *
+ * Switch WBXML code page.
+ */
+/* T.K. 06.02.01
+ * We need to enhance this as soon as we introduce
+ * Sub DTD's with more than one WBXML codepage. But till then
+ * there is only one case where WBXML codepages can occure, and
+ * this is the MetInf Sub DTD. So in case we find a codepage switch
+ * to something other than codepage zero, we set the active extension
+ * to metinf.
+ * In future versions the pScanner needs to be enhanced, to translate
+ * codepageswitches context sensitive to the active extension.
+ */
+static Ret_t
+wbxmlSwitchPage(wbxmlScannerPrivPtr_t pScanner)
+{
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if (pScanner->state == TAG_STATE)
+ pScanner->cptag = (SmlPcdataExtension_t)*pScanner->pos;
+ else
+ pScanner->cpattr = *pScanner->pos;
+ readBytes(pScanner, 1);
+ /* T.K. this needs to be adjusted as described above */
+ /* Ken Chen/Motorola, switch WBXML switch page accordingly */
+
+ switch ( pScanner->cptag )
+ {
+ case 0x00 :
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+ break;
+ case 0x01 :
+#ifdef __USE_METINF__
+ pScanner->activeExt = SML_EXT_METINF;
+#else
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+#endif
+ break;
+ case 0x02 :
+#ifdef __USE_DMTND__
+ pScanner->activeExt = SML_EXT_DMTND;
+#else
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+#endif
+ break;
+ case 0xFD2 :
+#ifdef __USE_DEVINF__
+ pScanner->activeExt = SML_EXT_DEVINF;
+#else
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+#endif
+ break;
+ default:
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+ break;
+ }
+
+ return SML_ERR_OK;
+}
+
+
+/******************************/
+/* Unsupported WBXML elements */
+/******************************/
+
+/**
+ * FUNCTION: wbxmlSkipEntity
+ *
+ * Skips entities but doesn't do anything useful yet.
+ */
+static Ret_t
+wbxmlSkipEntity(wbxmlScannerPrivPtr_t pScanner)
+{
+ MBINT tmp;
+ Ret_t rc;
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((rc = parseInt(pScanner, &tmp)) != SML_ERR_OK)
+ return rc;
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wbxmlSkipExtension
+ *
+ * Decode WBXML extensions. Skips the extension but doesn't do anything
+ * useful with it.
+ */
+static Ret_t
+wbxmlSkipExtension(wbxmlScannerPrivPtr_t pScanner)
+{
+ MBINT tmp;
+ Ret_t rc;
+
+ if (IS_EXT(pScanner->pos)) {
+ /* single byte extension token */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ } else if (IS_EXT_I(pScanner->pos)) {
+ /* inline string extension token */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if (!readBytes(pScanner, smlLibStrlen((String_t)pScanner->pos) + 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ } else {
+ /* inline integer extension token */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((rc = parseInt(pScanner, &tmp)) != SML_ERR_OK)
+ return rc;
+ if (!readBytes(pScanner, tmp + 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlSkipPI
+ *
+ * Handle XML processing instructions. PIs are not supported but the
+ * scanner recognizes and skips over them.
+ */
+static Ret_t
+wbxmlSkipPI(wbxmlScannerPrivPtr_t pScanner)
+{
+ /* PIs are just like tag attributes with a special PI token instead
+ * of the attribute start token */
+ return wbxmlSkipAttribute(pScanner);
+}
+
+/**
+ * FUNCTION: wbxmlSkipAttribute
+ *
+ * Handle attributes. Attributes are not supported but the
+ * scanner recognizes and skips over them.
+ */
+static Ret_t
+wbxmlSkipAttribute(wbxmlScannerPrivPtr_t pScanner)
+{
+ XltDecTokenPtr_t oldtok;
+ MBINT tmp;
+ Ret_t rc = 0;
+
+ /* skipping attributes shouldn't change the current token so we
+ make a copy... */
+ if ((oldtok = (XltDecTokenPtr_t)smlLibMalloc(sizeof(XltDecToken_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemcpy(oldtok, pScanner->curtok, sizeof(XltDecToken_t));
+
+ /* ... skip until attribute end tag... */
+ while (!IS_END(pScanner->pos)) {
+ if (IS_STRING(pScanner->pos)) {
+ rc = wbxmlStringToken(pScanner);
+ /* avoid memory leak due to this ugly workaround of
+ skipping attributes */
+ smlLibFree(pScanner->curtok->pcdata);
+ } else if (IS_EXTENSION(pScanner->pos)) {
+ rc = wbxmlSkipExtension(pScanner);
+ } else if (IS_ENTITY(pScanner->pos)) {
+ rc = wbxmlSkipEntity(pScanner);
+ } else if (IS_OPAQUE(pScanner->pos)) {
+ rc = wbxmlOpaqueToken(pScanner);
+ /* avoid memory leak due to this ugly workaround of
+ skipping attributes */
+ smlLibFree(pScanner->curtok->pcdata);
+ } else if (IS_LITERAL(pScanner->pos)) {
+ if (!readBytes(pScanner, 1))
+ {
+ if(oldtok) { smlLibFree(oldtok); oldtok= NULL; }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ rc = parseInt(pScanner, &tmp);
+ if (!readBytes(pScanner, 1))
+ {
+ if(oldtok) { smlLibFree(oldtok); oldtok= NULL; }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ } else if (IS_SWITCH(pScanner->pos)) {
+ rc = wbxmlSwitchPage(pScanner);
+ } else {
+ if (!readBytes(pScanner, 1))
+ {
+ if(oldtok) { smlLibFree(oldtok); oldtok= NULL; }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ }
+
+ if (rc != SML_ERR_OK) {
+ smlLibFree(oldtok);
+ return rc;
+ }
+
+ }
+ /* ... then skip the end tag itself... */
+ readBytes(pScanner, 1);
+
+ /* ... and finaly restore our copy of curtok */
+ smlLibMemcpy(pScanner->curtok, oldtok, sizeof(XltDecToken_t));
+ smlLibFree(oldtok);
+
+ return SML_ERR_OK;
+}
+
+#ifdef __USE_EXTENSIONS__
+/*
+ * This function tries to decode an inlined WBXML document inside
+ * an PCDATA element.
+ * In case of failing to decode it the PCDATA element isn't changed
+ * at all.
+ */
+
+void
+subdtdDecodeWbxml(XltDecoderPtr_t pDecoder,SmlPcdataPtr_t *ppPcdata) {
+ Ret_t _err = SML_ERR_OK;
+ MemPtr_t pSubBuf = NULL;
+ SmlPcdataPtr_t pSubPcdata = NULL;
+ XltDecoderPtr_t pSubDecoder = NULL;
+#ifdef __USE_DEVINF__
+ wbxmlScannerPrivPtr_t pScannerPriv = NULL;
+#endif
+
+ /* some sanity checks at first */
+
+ if (*ppPcdata == NULL) {
+ if (pDecoder) /* use this rare case to remove warning */
+ {
+ }
+ return;
+ }
+
+ if ((*ppPcdata)->contentType != SML_PCDATA_OPAQUE) return;
+
+ // now create a sub buffer
+ pSubBuf = (MemPtr_t)smlLibMalloc((*ppPcdata)->length);
+ if (pSubBuf == NULL) return;
+ smlLibMemset(pSubBuf, 0x00, (*ppPcdata)->length);
+ smlLibMemmove(pSubBuf, (*ppPcdata)->content, (*ppPcdata)->length);
+
+ /* ok looks fine sofar - now lets decode the rest */
+ /* now lets create a decoder, but without parsing the SyncML
+ * start tags (because it's not there) and skip the XML
+ * part as we don't need it.
+ */
+ pSubDecoder = (XltDecoderPtr_t)smlLibMalloc(sizeof(XltDecoder_t));
+ if (pSubDecoder == NULL) {
+ smlLibFree(pSubBuf);
+ return;
+ }
+ pSubDecoder->finished = 0;
+ pSubDecoder->final = 0;
+ pSubDecoder->scanner = NULL;
+ if (xltUtilCreateStack(&pSubDecoder->tagstack, 10) != SML_ERR_OK) {
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubBuf);
+ return;
+ }
+ if (xltDecWbxmlInit(pSubBuf+(*ppPcdata)->length,&pSubBuf, &pSubDecoder->scanner) != SML_ERR_OK) {
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubBuf);
+ return;
+ }
+ pSubDecoder->charset = pSubDecoder->scanner->charset;
+ pSubDecoder->charsetStr = NULL;
+
+ pSubPcdata = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+ if (pSubPcdata == NULL) {
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubPcdata);
+ smlLibFree(pSubBuf);
+ return;
+ }
+ /* T.K.
+ * In the future we need to check the WBXML stringtable and
+ * switch into the right Sub DTD. But sofar only DevInf is
+ * supported so we can save time and space
+ */
+ /* T.K.
+ * To prevent buffer corruption when __USE_DEVINF__ is not used
+ * we initialize _err with any errorcode != OK, and this way
+ * force the function to exit without modifying the ppPcdata
+ */
+ _err = SML_ERR_UNSPECIFIC;
+#ifdef __USE_DEVINF__
+ pSubPcdata->contentType = SML_PCDATA_EXTENSION;
+ pSubPcdata->extension = SML_EXT_DEVINF;
+ pSubPcdata->length = 0;
+ pSubPcdata->content = NULL;
+
+ pScannerPriv = (wbxmlScannerPrivPtr_t)pSubDecoder->scanner;
+ pScannerPriv->activeExt = SML_EXT_DEVINF;
+ pScannerPriv->cpattr = 0;
+ pScannerPriv->cptag = (SmlPcdataExtension_t)0;
+ smlLibMemset(pScannerPriv->curtok, 0,sizeof(XltDecToken_t));
+
+ _err = buildDevInfDevInfCmd(pSubDecoder, (VoidPtr_t)&pSubPcdata->content);
+#endif
+
+ if (_err != SML_ERR_OK) {
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubPcdata);
+ smlLibFree(pSubBuf);
+ return;
+ }
+
+ /* parsing is done, now lets anchor it within the original PCDATA element */
+ smlFreePcdata(*ppPcdata);
+ *ppPcdata = pSubPcdata;
+
+ /* we are done */
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubBuf);
+
+ return;
+}
+
+#endif
+
+/*Added by w21034 begin*/
+Ret_t wbxml2xmlInternal(unsigned char *bufIn, int bufInLen, unsigned char *bufOut, int * bufOutLen)
+{
+ #define Debug printf
+ Debug("Enter wbxml2xmlInternal\n");
+ wbxmlScannerPrivPtr_t pScanner;
+ Ret_t rc;
+
+ //check
+ int smlInitByMe = 0;
+ if(mgrGetSyncMLAnchor()== NULL)
+ {
+ Debug("Init syncML\n");
+ SmlOptions_t smlOptions;
+ memset(&smlOptions, 0, sizeof(smlOptions));
+ smlOptions.defaultPrintFunc = NULL;
+ smlOptions.maxWorkspaceAvailMem = 40000;
+ rc = smlInit(&smlOptions);
+ if(rc!=SML_ERR_OK)
+ {
+ return rc;
+ }
+ smlInitByMe = 1;
+ }
+
+ /* initialize new WBXML scanner */
+ if ((pScanner = (wbxmlScannerPrivPtr_t)smlLibMalloc(sizeof(wbxmlScannerPriv_t))) == NULL)
+ {
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pScanner, 0, sizeof(wbxmlScannerPriv_t));
+ //Debug("wbxml2xmlInternal 2\n");
+ pScanner->bufend = bufIn + bufInLen;
+ pScanner->pos = bufIn;
+ if ((pScanner->curtok = (XltDecTokenPtr_t)smlLibMalloc(sizeof(XltDecToken_t))) == NULL) {
+ smlLibFree(pScanner);
+ pScanner = NULL;
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ //Debug("wbxml2xmlInternal 3\n");
+ pScanner->curtok->pcdata = NULL;
+ if ((rc = xltUtilCreateStack(&pScanner->tagstack, 10)) != SML_ERR_OK) {
+ smlLibFree(pScanner->curtok);
+ smlLibFree(pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return rc;
+ }
+ pScanner->state = TAG_STATE;
+
+ //Debug("wbxml2xmlInternal 4\n");
+ /* point public/private methods to the right implementation */
+ pScanner->nextTok = _nextTok;
+ pScanner->destroy = _destroy;
+ pScanner->pushTok = _pushTok;
+ pScanner->setBuf = _setBuf;
+ pScanner->getPos = _getPos;
+
+ //Debug("wbxml2xmlInternal 5\n");
+ unsigned char* tmpBufOut = bufOut;
+ int tmpBufOutLen = 0;
+
+ Debug("wbxml2xmlInternal 6\n");
+ /* decode the WBXML header */
+ /*decode wbxml verson*/
+ Byte_t major, minor;
+ minor = ((Byte_t)(*pScanner->pos & 0x0F));
+ major = ((Byte_t)((*pScanner->pos >> 4) + 1));
+ String_t wbxmlVer = NULL;
+ if((wbxmlVer = smlLibMalloc(50))== NULL)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ Debug("wbxml2xmlInternal 7\n");
+ smlLibMemset(wbxmlVer, 0, 50);
+ sprintf(wbxmlVer, "<WBXML Version=%d.%d/>", (int)major, (int)minor);
+ tmpBufOutLen = smlLibStrlen(wbxmlVer);
+ smlLibStrncpy((String_t)tmpBufOut, (String_t)wbxmlVer, tmpBufOutLen);
+ tmpBufOut += tmpBufOutLen;
+ Debug("wbxml2xmlInternal 7.1,%s\n", wbxmlVer);
+ smlLibFree(wbxmlVer);
+ tmpBufOut[0] = '\n';
+ tmpBufOut++;
+ tmpBufOut[0] = '\0';
+ //Debug("wbxml2xmlInternal 8\n");
+ if (!readBytes(pScanner, 1))
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+
+ Debug("wbxml2xmlInternal 9\n");
+ /*decode public ID*/
+ if ((rc = wbxmlPublicID(pScanner)) != SML_ERR_OK)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return rc;
+ }
+ /*decode charset*/
+ if ((rc = wbxmlCharset(pScanner)) != SML_ERR_OK)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return rc;
+ }
+ /*decode string table*/
+ if ((rc = wbxmlStrtbl(pScanner)) != SML_ERR_OK)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return rc;
+ }
+
+ //Debug("wbxml2xmlInternal 10\n");
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ String_t tmpStr = smlLibMalloc(50);
+ if(tmpStr == NULL)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ //Debug("wbxml2xmlInternal 11\n");
+ smlLibMemset(tmpStr, 0, 50);
+ char startBracket[2];
+ startBracket[0] = '\<';
+ startBracket[1] = '\0';
+ char endBracket[2];
+ endBracket[0]='\>';
+ endBracket[1]='\0';
+ char forwardSlash[2];
+ forwardSlash[0] = '\/';
+ forwardSlash[1] = '\0';
+
+ Debug("wbxml2xmlInternal 12\n");
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ int tagStartFlag = 0;
+ /* keep going until we find a "supported" element */
+ rc = SML_ERR_OK;
+ while (rc == SML_ERR_OK) {
+ /* skip PIs, extensions and entities... */
+ if (IS_PI(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 13, PI\n");
+ rc = wbxmlSkipPI(pScanner);
+ //Debug("wbxml2xmlInternal 13, PI end\n");
+ } else if (IS_EXTENSION(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 14, Extension\n");
+ rc = wbxmlSkipExtension(pScanner);
+ //Debug("wbxml2xmlInternal 14, Extension End\n");
+ } else if (IS_ENTITY(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 15, ENTITY\n");
+ rc = wbxmlSkipEntity(pScanner);
+ //Debug("wbxml2xmlInternal 15, ENTITY End\n");
+
+ /* ... decode strings, opaque data and tags */
+ } else if (IS_STRING(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 16, STRING\n");
+ rc = wbxmlStringToken(pScanner);
+ if(rc == SML_ERR_OK)
+ {
+ SmlPcdataPtr_t pcdata = pScanner->curtok->pcdata;
+ smlLibMemcpy(tmpBufOut, pcdata->content, pcdata->length);
+ tmpBufOut+=pcdata->length;
+ }
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ //Debug("wbxml2xmlInternal 16, STRING end\n");
+ } else if (IS_OPAQUE(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 17, OPAQUE\n");
+ rc = wbxmlOpaqueToken(pScanner);
+ if(rc == SML_ERR_OK)
+ {
+ SmlPcdataPtr_t pcdata = pScanner->curtok->pcdata;
+ smlLibMemcpy(tmpBufOut, pcdata->content, pcdata->length);
+ tmpBufOut+=pcdata->length;
+ }
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ //Debug("wbxml2xmlInternal 17, OPAQUE End\n");
+ //break;
+ } else {
+ Debug("wbxml2xmlInternal 18, TAG\n");
+ rc = wbxmlTagToken(pScanner);
+ if(rc != SML_ERR_OK)
+ {
+ break;
+ }
+ //Debug("wbxml2xmlInternal 18.1, TAG\n");
+ //Generate string for the token.
+ String_t _tagString = smlLibMalloc(50);
+ if (_tagString == NULL)
+ {
+ //Debug("wbxml2xmlInternal 18.1.1, TAG\n");
+ smlLibFree(tmpStr);
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ //Debug("wbxml2xmlInternal 18.1.2, TAG\n");
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(_tagString, 0, 50);
+ Debug("wbxml2xmlInternal 18.2, TAG\n");
+ //Debug("tagid=%d, ext=%d\n",pScanner->curtok->tagid, pScanner->curtok->ext);
+ if ((rc = getTagString(pScanner->curtok->tagid, _tagString, pScanner->activeExt)) != SML_ERR_OK)
+ {
+ if(pScanner->curtok->type == TOK_TAG_END)
+ {
+ SmlPcdataExtension_t tmpExt = SML_EXT_UNDEFINED;
+ if(tmpExt == pScanner->activeExt)
+ {
+ tmpExt = SML_EXT_METINF;
+ }
+ smlLibMemset(_tagString, 0, 50);
+ rc =getTagString(pScanner->curtok->tagid, _tagString, tmpExt);
+ }
+ if(rc != SML_ERR_OK)
+ {
+ Debug("wbxml2xmlInternal 18.2.1, TAG, rc=%d\n", rc);
+ smlLibFree(_tagString);
+ break;
+ }
+ }
+ smlLibMemset(tmpStr, 0, 50);
+ if(pScanner->curtok->type == TOK_TAG_START)
+ {
+ Debug("wbxml2xmlInternal 18.6, TAG\n");
+ if(tagStartFlag == 1)
+ {
+ sprintf(tmpStr, "\n%s%s%s", startBracket, _tagString, endBracket);
+ }
+ else
+ {
+ sprintf(tmpStr, "%s%s%s", startBracket, _tagString, endBracket);
+ }
+ smlLibStrcpy((String_t)tmpBufOut, tmpStr);
+ tmpBufOut += smlLibStrlen(tmpStr);
+ tagStartFlag = 1;
+ }
+ else if(pScanner->curtok->type == TOK_TAG_END)
+ {
+ Debug("wbxml2xmlInternal 18.7, TAG\n");
+ sprintf(tmpStr, "%s%s%s%s\n", startBracket, forwardSlash, _tagString, endBracket);
+ Debug("tmpStr=%s\n", tmpStr);
+ smlLibStrcpy((String_t)tmpBufOut, tmpStr);
+ tmpBufOut += smlLibStrlen(tmpStr);
+ tagStartFlag = 0;
+ }
+ else if(pScanner->curtok->type == TOK_TAG_EMPTY)
+ {
+ }
+ smlLibFree(_tagString);
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ //break;
+ }
+ }
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ //Debug("wbxml2xmlInternal 20\n");
+ tmpBufOut[0]='\0';
+ *bufOutLen = (int)tmpBufOut - (int)bufOut;
+ smlLibFree(tmpStr);
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ //Debug("Output buffer is: \n%s\n", (char*)bufOut);
+ Debug("wbxml2xmlInternal 21, bufOutLen=%d\n", *bufOutLen);
+ if(rc == SML_ERR_XLT_END_OF_BUFFER)
+ {
+ rc = SML_ERR_OK;
+ }
+ return rc;
+}
+/*Added by w21034 end*/
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecwbxml.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecwbxml.h
new file mode 100644
index 0000000..37b0846
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecwbxml.h
@@ -0,0 +1,59 @@
+/*************************************************************************/
+/* module: internal WBXML decoder header file */
+/* file: XLTDecWbxml.h */
+/* target system: - */
+/* target OS: - */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#ifndef _XLT_DEC_WBXML_H
+#define _XLT_DEC_WBXML_H
+
+#include "XLTDecAll.h"
+
+xltDecScanner_t*
+xltDecWbxmlScannerCreate(unsigned char *buf, long buflen);
+
+void
+xltDecWbxmlScannerDestroy(xltDecScanner_t *p);
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecxml.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecxml.c
new file mode 100644
index 0000000..d2ed4c2
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdecxml.c
@@ -0,0 +1,1370 @@
+/*************************************************************************/
+/* module: XML scanner */
+/* file: XLTDecXml.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * The XML scanner/tokenizer. Used by the SyncML parser.
+ */
+
+#include <define.h>
+#ifdef __SML_XML__
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#include "xltdeccom.h"
+#include "xlttags.h"
+
+#include <libmem.h>
+#include <libstr.h>
+
+#include <smlerr.h>
+#include "xpl_dm_Manager.h"
+
+/**
+ * Private Interface for the XML scanner.
+ */
+typedef struct xmlScannerPriv_s xmlScannerPriv_t, *xmlScannerPrivPtr_t;
+struct xmlScannerPriv_s
+{
+ /* public */
+ Ret_t (*nextTok)(XltDecScannerPtr_t);
+ Ret_t (*destroy)(XltDecScannerPtr_t);
+ Ret_t (*pushTok)(XltDecScannerPtr_t);
+ void (*setBuf)(XltDecScannerPtr_t pScanner, const MemPtr_t pBufStart, const MemPtr_t pBufEnd);
+ MemPtr_t (*getPos)(XltDecScannerPtr_t pScanner);
+
+ XltDecTokenPtr_t curtok; /* current token */
+ Long_t charset; /* 0 */
+ String_t charsetStr; /* character set */
+ Long_t pubID; /* 0 */
+ String_t pubIDStr; /* document public identifier */
+ SmlPcdataExtension_t ext; /* which is the actual open namespace ? */
+ SmlPcdataExtension_t prev_ext; /* which is the previous open namespace ? */
+ XltTagID_t ext_tag; /* which tag started the actual namespace ? */
+ XltTagID_t prev_ext_tag; /* which tag started the previous open namespace ? */
+ String_t nsprefix; /* prefix used for active namespace (if any) */
+ Byte_t nsprelen; /* how long is the prefix ? (to save smlLibStrlen calls) */
+ Flag_t finished;
+
+ /* private */
+ MemPtr_t pos; /* current position */
+ MemPtr_t bufend; /* end of buffer */
+};
+
+const ESCAPE_CHAR_TABLE_T escape_char_table[] =
+{
+ {'&', (String_t)"amp;"},
+ {'&', (String_t)"amp"},
+ {'<', (String_t)"lt;"},
+ {'<', (String_t)"lt"},
+ {'>', (String_t)"gt;"},
+ {'>', (String_t)"gt"},
+ {'\\', (String_t)"apos;"},
+ {'\\', (String_t)"apos"},
+ {'"', (String_t)"quot;"},
+ {'"', (String_t)"quot"},
+ {' ', NULL}
+};
+
+
+/**
+ * Public methods of the scanner interface.
+ *
+ * Description see XLTDecCom.h.
+ */
+static Ret_t _destroy(XltDecScannerPtr_t);
+static Ret_t _nextTok(XltDecScannerPtr_t);
+static Ret_t _pushTok(XltDecScannerPtr_t);
+static void _setBuf(XltDecScannerPtr_t, const MemPtr_t, const MemPtr_t);
+static MemPtr_t _getPos(XltDecScannerPtr_t);
+
+/**
+ * FUNCTION: readBytes
+ *
+ * Advance the current position pointer after checking whether the end of
+ * the buffer has been reached. If the end of the buffer has been reached
+ * the scanner's finished flag is set.
+ *
+ * PRE-Condition:
+ * POST-Condition:
+ *
+ * IN: bytes, read this many bytes
+ *
+ * IN/OUT: pScanner, the scanner
+ *
+ * RETURNS: 1, if end of buffer has not been reached
+ * 0 otherwise
+ */
+static Boolean_t readBytes(xmlScannerPrivPtr_t pScanner, Long_t bytes);
+
+/**
+ * Skip whitespaces.
+ */
+static void skipS(xmlScannerPrivPtr_t pScanner);
+
+static Ret_t xmlTag(xmlScannerPrivPtr_t pScanner, Byte_t endtag);
+static Ret_t xmlName(xmlScannerPrivPtr_t pScanner, String_t *name);
+static Ret_t xmlCharData(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlProlog(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlDocTypeDecl(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlXMLDecl(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlAttribute(xmlScannerPrivPtr_t pScanner, String_t *name, String_t *value);
+static Ret_t xmlStringConst(xmlScannerPrivPtr_t pScanner, String_t *value);
+
+static Ret_t xmlSkipPCDATA(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlSkipComment(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlSkipAttributes(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlSkipPI(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlCDATA(xmlScannerPrivPtr_t pScanner);
+Boolean_t isPcdata(XltTagID_t tagid);
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+
+Ret_t
+xltDecXmlInit(const MemPtr_t pBufEnd, MemPtr_t *ppBufStart, XltDecScannerPtr_t *ppScanner)
+{
+ xmlScannerPrivPtr_t pScanner;
+ Ret_t rc;
+
+ pScanner = (xmlScannerPrivPtr_t)smlLibMalloc(sizeof(xmlScannerPriv_t));
+ if (pScanner == NULL) {
+ *ppScanner = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ pScanner->finished = 0;
+ pScanner->pos = *ppBufStart;
+ pScanner->bufend = pBufEnd;
+ pScanner->curtok = (XltDecTokenPtr_t)smlLibMalloc(sizeof(XltDecToken_t));
+ if (pScanner->curtok == NULL) {
+ smlLibFree(pScanner);
+ *ppScanner = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ pScanner->curtok->pcdata = NULL;
+ pScanner->curtok->tagid = TN_UNDEF;
+ pScanner->pubID = 0;
+ pScanner->pubIDStr = NULL;
+ pScanner->charset = 0;
+ pScanner->charsetStr = NULL;
+ pScanner->ext = SML_EXT_UNDEFINED;
+ pScanner->prev_ext = (SmlPcdataExtension_t)255;
+ pScanner->ext_tag = TN_UNDEF;
+ pScanner->prev_ext_tag = TN_UNDEF;
+ pScanner->nsprelen = 0;
+ pScanner->nsprefix = NULL;
+
+
+ /* point public/private methods to the right implementation */
+ pScanner->nextTok = _nextTok;
+ pScanner->destroy = _destroy;
+ pScanner->pushTok = _pushTok;
+ pScanner->setBuf = _setBuf;
+ pScanner->getPos = _getPos;
+
+ if ((rc = xmlProlog(pScanner)) != SML_ERR_OK) {
+ smlLibFree(pScanner->curtok);
+ smlLibFree(pScanner);
+ *ppScanner = NULL;
+ return rc;
+ }
+
+ *ppScanner = (XltDecScannerPtr_t)pScanner;
+
+
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: destroy
+ *
+ * Free memory. Description see XltDecAll.h.
+ */
+static Ret_t
+_destroy(XltDecScannerPtr_t pScanner)
+{
+ xmlScannerPrivPtr_t pScannerPriv;
+
+ if (pScanner == NULL)
+ return SML_ERR_OK;
+
+ pScannerPriv = (xmlScannerPrivPtr_t)pScanner;
+ smlLibFree(pScannerPriv->curtok);
+ smlLibFree(pScannerPriv->charsetStr);
+ smlLibFree(pScannerPriv->pubIDStr);
+ smlLibFree(pScannerPriv);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: nextTok
+ *
+ * Get next token. Description see XltDecAll.h.
+ */
+static Ret_t
+_nextTok(XltDecScannerPtr_t pScanner)
+{
+ xmlScannerPrivPtr_t pScannerPriv;
+ Ret_t rc;
+
+ pScannerPriv = (xmlScannerPrivPtr_t)pScanner;
+
+ pScannerPriv->curtok->start = pScannerPriv->pos;
+
+ skipS(pScannerPriv);
+
+ /* skip unsupported elements until we find a supported one */
+ rc = 0;
+
+
+ while (!rc) {
+ if (smlLibStrncmp((String_t)pScannerPriv->pos, "<!--", 4) == 0) {
+ rc = xmlSkipComment(pScannerPriv);
+ } else if (smlLibStrncmp((String_t)pScannerPriv->pos, "<?", 2) == 0) {
+ rc = xmlSkipPI(pScannerPriv);
+ } else if (smlLibStrncmp((String_t)pScannerPriv->pos, "</", 2) == 0) {
+ rc = xmlTag(pScannerPriv, 1);
+ break;
+ } else if (smlLibStrncmp((String_t)pScannerPriv->pos, "<![CDATA[", 9) == 0) {
+ rc = xmlCDATA(pScannerPriv);
+ break;
+ } else if ((isPcdata(pScannerPriv->curtok->tagid)) && (pScannerPriv->curtok->type != TOK_TAG_END)) {
+ rc = xmlSkipPCDATA(pScannerPriv);
+ break;
+ } else if (smlLibStrncmp((String_t)pScannerPriv->pos, "<", 1) == 0) {
+ rc = xmlTag(pScannerPriv, 0);
+ break;
+ } else {
+ rc = xmlCharData(pScannerPriv);
+ break;
+ }
+ }
+ if (rc)
+ return rc;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: pushTok
+ *
+ * Reset the scanner to the starting position of the current token within
+ * the buffer. Description see XltDecAll.h.
+ */
+static Ret_t _pushTok(XltDecScannerPtr_t pScanner)
+{
+ xmlScannerPrivPtr_t pScannerPriv;
+
+ pScannerPriv = (xmlScannerPrivPtr_t)pScanner;
+ pScannerPriv->pos = pScannerPriv->curtok->start;
+
+ /* invalidate curtok */
+ /* T.K. Possible Error. pScannerPriv->curtok is of type XltDecToken_t NOT ...Ptr_t */
+ // OrigLine:
+ // smlLibMemset(pScannerPriv->curtok, 0, sizeof(XltDecTokenPtr_t));
+ pScannerPriv->curtok->type = (XltTokType_t)0;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: setBuf
+ *
+ * Set the working buffer of the scanner.
+ */
+static void
+_setBuf(XltDecScannerPtr_t pScanner, const MemPtr_t pBufStart,
+ const MemPtr_t pBufEnd)
+{
+ xmlScannerPrivPtr_t pScannerPriv = (xmlScannerPrivPtr_t)pScanner;
+ pScannerPriv->pos = pBufStart;
+ pScannerPriv->bufend = pBufEnd;
+}
+
+/**
+ * FUNCTION: getPos
+ *
+ * Get the current position of the scanner within its working buffer.
+ */
+static MemPtr_t
+_getPos(XltDecScannerPtr_t pScanner)
+{
+ return ((xmlScannerPrivPtr_t)pScanner)->pos;
+}
+
+
+
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+/**
+ * FUNCTION: readBytes
+ *
+ * Advance the position pointer. Description see above.
+ */
+static Boolean_t
+readBytes(xmlScannerPrivPtr_t pScanner, Long_t bytes)
+{
+ if (pScanner->pos + bytes > pScanner->bufend) {
+ pScanner->finished = 1;
+ return 0;
+ }
+ pScanner->pos += bytes;
+ return 1;
+}
+
+/**
+ * FUNCTION: skipS
+ *
+ * Skip whitespace.
+ */
+static void skipS(xmlScannerPrivPtr_t pScanner)
+{
+ for (;;) {
+ switch (*pScanner->pos) {
+ case 9: /* tab stop */
+ case 10: /* line feed */
+ case 13: /* carriage return */
+ case 32: /* space */
+ // %%% luz: 2001-07-03: added exit from loop if no more bytes
+ if (!readBytes(pScanner, 1)) return;
+ break;
+ default:
+ return;
+ }
+ }
+}
+
+/**
+ * FUNCTION: xmlProlog
+ *
+ * Scan the XML prolog (might be empty...).
+ */
+static Ret_t
+xmlProlog(xmlScannerPrivPtr_t pScanner)
+{
+ Ret_t rc;
+
+ skipS(pScanner);
+
+ if (pScanner->pos + 5 > pScanner->bufend)
+ return SML_ERR_OK;
+ if (smlLibStrncmp((String_t)pScanner->pos, "<?xml", 5) == 0)
+ if ((rc = xmlXMLDecl(pScanner)) != SML_ERR_OK)
+ return rc;
+
+ skipS(pScanner);
+
+ while ((pScanner->pos + 4 <= pScanner->bufend) &&
+ ((smlLibStrncmp((String_t)pScanner->pos, "<!--", 4) == 0) ||
+ (smlLibStrncmp((String_t)pScanner->pos, "<?", 2) == 0))) {
+ if (smlLibStrncmp((String_t)pScanner->pos, "<!--", 4) == 0)
+ rc = xmlSkipComment(pScanner);
+ else
+ rc = xmlSkipPI(pScanner);
+ if (rc != SML_ERR_OK)
+ return rc;
+ skipS(pScanner);
+ }
+
+ if ((pScanner->pos + 9 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "<!DOCTYPE", 9) == 0))
+ if ((rc = xmlDocTypeDecl(pScanner)) != SML_ERR_OK)
+ return rc;
+
+ skipS(pScanner);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlDocTypeDecl
+ *
+ * Part of the Prolog scanning
+ */
+static Ret_t
+xmlDocTypeDecl(xmlScannerPrivPtr_t pScanner)
+{
+ Ret_t rc;
+ String_t name = NULL;
+ String_t syslit = NULL;
+ String_t publit = NULL;
+
+ readBytes(pScanner, 9);
+ skipS(pScanner);
+ if ((rc = xmlName(pScanner, &name)) != SML_ERR_OK) {
+ smlLibFree(name);
+ return rc;
+ }
+ skipS(pScanner);
+
+ /* parse ExternalID */
+ if ((pScanner->pos + 6 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "SYSTEM", 6) == 0)) {
+ readBytes(pScanner, 6);
+ skipS(pScanner);
+ if ((rc = xmlStringConst(pScanner, &syslit)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(syslit);
+ return rc;
+ }
+ } else if ((pScanner->pos + 6 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "PUBLIC", 6) == 0)) {
+ readBytes(pScanner, 6);
+ skipS(pScanner);
+ if ((rc = xmlStringConst(pScanner, &publit)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(publit);
+ return rc;
+ }
+ skipS(pScanner);
+ if ((rc = xmlStringConst(pScanner, &syslit)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(syslit);
+ smlLibFree(publit);
+ return rc;
+ }
+ }
+
+ smlLibFree(name);
+ smlLibFree(syslit);
+ smlLibFree(publit);
+
+ skipS(pScanner);
+
+ if (*pScanner->pos != '>')
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ readBytes(pScanner, 1);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlXMLDecl
+ *
+ * Part of the Prolog scanning
+ */
+static Ret_t
+xmlXMLDecl(xmlScannerPrivPtr_t pScanner)
+{
+ String_t name, value;
+ Ret_t rc;
+
+ readBytes(pScanner, 5);
+ skipS(pScanner);
+
+ /* mandatory version info */
+ if ((rc = xmlAttribute(pScanner, &name, &value)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(value);
+ return rc;
+ }
+ if (smlLibStrcmp(name, "version") != 0) {
+ smlLibFree(name);
+ smlLibFree(value);
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ smlLibFree(name);
+ smlLibFree(value);
+
+ skipS(pScanner);
+
+ /* optional attributes are encoding and standalone */
+ while ((pScanner->pos + 2 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "?>", 2) != 0)) {
+ if ((rc = xmlAttribute(pScanner, &name, &value)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(value);
+ return rc;
+ }
+ smlLibFree(name);
+ smlLibFree(value);
+ skipS(pScanner);
+ }
+
+ if (pScanner->pos + 2 > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ readBytes(pScanner, 2);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlAttribute
+ *
+ * Handle Attributes //function can be used if attributes get necessary
+ */
+static Ret_t
+xmlAttribute(xmlScannerPrivPtr_t pScanner, String_t *name, String_t *value)
+{
+ Ret_t rc;
+
+ skipS(pScanner);
+
+ if ((rc = xmlName(pScanner, name)) != SML_ERR_OK)
+ return rc;
+
+ skipS(pScanner);
+
+ /* no attributes found, because this tag has none -> bail out */
+ if (*pScanner->pos == '>') {
+ return SML_ERR_XLT_MISSING_CONT;
+ }
+ if (smlLibStrncmp((String_t)pScanner->pos, "/>", 2) == 0) {
+ return SML_ERR_XLT_MISSING_CONT;
+ }
+
+ if (*pScanner->pos != '=') {
+ smlLibFree(*name);
+ *name = NULL;
+ *value = NULL;
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ readBytes(pScanner, 1);
+
+ skipS(pScanner);
+
+ if ((rc = xmlStringConst(pScanner, value)) != SML_ERR_OK) {
+ smlLibFree(*name);
+ *name = NULL;
+ *value = NULL;
+ return rc;
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlStringConst
+ *
+ * Handle Pcdata String Constants
+ */
+static Ret_t
+xmlStringConst(xmlScannerPrivPtr_t pScanner, String_t *value)
+{
+ String_t end;
+ int len;
+ char del;
+
+ if ((*pScanner->pos != '"') && (*pScanner->pos != '\'')) {
+ *value = NULL;
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ del = *pScanner->pos;
+ readBytes(pScanner, 1);
+
+ if ((end = smlLibStrchr((String_t)pScanner->pos, del)) == NULL) {
+ *value = NULL;
+
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ len = end - (String_t)pScanner->pos;
+ if ((*value = (String_t)smlLibMalloc(len + 1)) == NULL)
+ {
+
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(*value, 0, len + 1);
+ smlLibStrncpy(*value, (String_t)pScanner->pos, len);
+ readBytes(pScanner, len + 1);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlStringConst
+ *
+ * Handle escaped characters
+ */
+static void
+xmlReadEscape(String_t buffer, MemPtr_t instring, int *instr_len)
+{
+int len= *instr_len;
+
+ while (len !=0)
+ {
+ if(*instring != '&')
+ { *buffer ++ = *instring++;
+ len--;
+ }
+ else
+ {
+ instring++;
+ len--;
+
+ if(len>1)
+ {
+
+ Boolean_t found =0;
+ unsigned int i=0;
+ for (i = 0; escape_char_table[i].escape_str != NULL; i++)
+ {
+ unsigned int str_len=smlLibStrlen( escape_char_table[i].escape_str);
+ if (smlLibStrncmp((String_t)instring, escape_char_table[i].escape_str, str_len) == 0)
+ {
+ *buffer++ =escape_char_table[i].token;
+ instring += str_len;
+ len -=str_len;
+ found = 1;
+ *instr_len-= str_len;
+ break;
+ }
+ }
+ if(found==0)
+ {
+ *buffer++ = '&';
+ }
+ }
+ else
+ {
+ *buffer++ = '&';
+ }
+
+ }
+ }
+}
+
+/**
+ * FUNCTION: xmlCharData
+ *
+ * Handle Pcdata character data content
+ */
+static Ret_t
+xmlCharData(xmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPCData;
+ MemPtr_t begin;
+ int len;
+
+
+ pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+ if (pPCData == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ pPCData->contentType = SML_PCDATA_UNDEFINED;
+ pPCData->length = 0;
+ pPCData->content = NULL;
+
+ begin = pScanner->pos;
+
+ if (pScanner->pos >= pScanner->bufend) {
+ pPCData->content = NULL;
+ pPCData->contentType = SML_PCDATA_UNDEFINED;
+ pPCData->extension = SML_EXT_UNDEFINED;
+ pPCData->length = 0;
+ pScanner->curtok->type = TOK_CONT;
+ pScanner->curtok->pcdata = pPCData;
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+
+ while (*pScanner->pos != '<') /* && (*pScanner->pos != '&') */
+ {
+ if (pScanner->pos >= pScanner->bufend)
+ {
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (!readBytes(pScanner, 1)) {
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+
+ }
+ len = pScanner->pos - begin;
+ pPCData->content = smlLibMalloc(len + 1);
+ if (pPCData->content == NULL){
+ smlLibFree(pPCData);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pPCData->content, 0, len + 1);
+ xmlReadEscape(pPCData->content, begin, &len);
+ pPCData->contentType = SML_PCDATA_STRING;
+ pPCData->length = len;
+
+ pScanner->curtok->type = TOK_CONT;
+ pScanner->curtok->pcdata = pPCData;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlName
+ *
+ * Handle Name Elements
+ */
+static Ret_t
+xmlName(xmlScannerPrivPtr_t pScanner, String_t *name)
+{
+ MemPtr_t begin;
+ String_t tmp;
+ int len;
+
+ begin = pScanner->pos;
+ while (((*pScanner->pos >= 'a') && (*pScanner->pos <= 'z')) ||
+ ((*pScanner->pos >= 'A') && (*pScanner->pos <= 'Z')) ||
+ ((*pScanner->pos >= '0') && (*pScanner->pos <= '9')) ||
+ (*pScanner->pos == '.') || (*pScanner->pos == '-') ||
+ (*pScanner->pos == '_') || (*pScanner->pos == ':'))
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ len = pScanner->pos - begin;
+ /* T.K. bail out if len is zero without modifying name */
+ if (len == 0) return SML_ERR_OK;
+
+
+ tmp = (String_t)smlLibMalloc(len + 1);
+ if (tmp == NULL) {
+ *name = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(tmp, 0, len + 1);
+ smlLibStrncpy(tmp, (String_t)begin, len);
+ *name = tmp;
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlTag
+ *
+ * Handle XML Tags
+ */
+static Ret_t
+xmlTag(xmlScannerPrivPtr_t pScanner, Byte_t endtag)
+{
+ Ret_t rc;
+ String_t name = NULL, attname=NULL, value = NULL, nsprefix = NULL;
+ Byte_t nsprelen = 0;
+ XltTagID_t tagid;
+ SmlPcdataExtension_t ext;
+
+
+ if (endtag) {
+ if (!readBytes(pScanner, 2))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ } else {
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+
+ if ((rc = xmlName(pScanner, &name)) != SML_ERR_OK)
+ {
+ if (rc != SML_ERR_NOT_ENOUGH_SPACE)
+ {
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ else
+ {
+ return rc;
+ }
+
+ }
+
+ //DP: case for corrupted xml file
+ if ( !name )
+ return SML_ERR_XLT_INVAL_XML_DOC;
+
+ ext = pScanner->ext;
+ if (!endtag) {
+ /* Namespaces can only be defined on start, never on endtags
+ * but we have to make sure we close a namespace on the corrsponding endtag.
+ * Thats why we a) only open a namespace when it differs from the previous one, and
+ * b) record the tag_id that opend the namespace so we can close it when the
+ * corresponding endtag is reached.
+ */
+
+ if ((rc = xmlAttribute(pScanner, &attname, &value)) == SML_ERR_OK)
+ {
+ if (smlLibStrncmp(attname, "xmlns", 5) == 0) {
+ /* Heureka we found a Namespace :-) */
+ /* It's save to check attname[5] here, as it contains at least the terminating '\000' */
+ if (attname[5] == ':') { /* we found a namespace prefixdefinition */
+ nsprelen = (Byte_t)smlLibStrlen(&attname[6]);
+ nsprefix = smlLibMalloc(nsprelen+1);
+ if (nsprefix == NULL) {
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibStrcpy(nsprefix,&attname[6]);
+ }
+ ext = getExtByName(value);
+ if (ext == 255) {
+ smlLibFree(nsprefix); /* doesn't harm, even when empty */
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ return SML_ERR_XLT_INVALID_CODEPAGE;
+ }
+ else
+ {
+ if (smlLibStrncmp(value, "SYNCML:", 7) == 0)
+ {
+ if ( smlLibStrcmp(XPL_DM_GetEnv(SYNCML_DM_VERSION), "1.2")==0)
+ {
+ if (smlLibStrncmp(value+7, "SYNCML1.2", 9) != 0)
+ {
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ smlLibFree(nsprefix);
+
+ return SML_ERR_XLT_INVALID_CODEPAGE;
+ }
+ }
+ else if (smlLibStrncmp(value+7, "SYNCML1.1", 9) != 0)
+ {
+ if (smlLibStrncmp(value+7, "SYNCML1.1", 9) != 0)
+ {
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ smlLibFree(nsprefix);
+ return SML_ERR_XLT_INVALID_CODEPAGE;
+ }
+ }
+ }
+ }
+ } else {
+ if (rc == SML_ERR_NOT_ENOUGH_SPACE){
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ else{
+ /* we found an unknown attribute -> bail out */
+ smlLibFree(attname);
+ smlLibFree(value);
+ /* nsprefix is empty here so we save us a function call */
+ smlLibFree(name);
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ }
+
+ }
+ else if ( rc != SML_ERR_XLT_MISSING_CONT)
+ {
+ /* xmlAttribute returns an SML_ERR_XLT_MISSING_CONT error when
+ * no attribute was found. This is not an error, but everything else is.
+ */
+ smlLibFree(value);
+ smlLibFree(name);
+ return rc;
+ }
+
+
+ }
+
+
+ if (pScanner->ext == ext) {
+ /* no new Namespace found - lets proceed with the active one */
+
+ /* first lets check wether a tag is in the right namespace, in case
+ * we are using namespaces with prefix notation ('mi:Format' instead of
+ * 'Format nsattr="...").
+ * If we are and the token is not in this namespace -> bail out
+ */
+ if (pScanner->nsprelen > 0 && smlLibStrlen(name) > pScanner->nsprelen+1) {
+ if (name[pScanner->nsprelen] != ':' || smlLibStrncmp(name,pScanner->nsprefix, pScanner->nsprelen) != 0) {
+ smlLibFree(name);
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(nsprefix);
+ return SML_ERR_XLT_NO_MATCHING_CODEPAGE;
+ }
+ }
+ /* Strip off namespace prefixes and ':' to find the tag.
+ * If no prefix is defined (pScanner->nsprelen == 0) take the whole tagname.
+ */
+ if (pScanner->nsprelen > 0)
+ rc = getTagIDByStringAndExt(&name[0+pScanner->nsprelen+1], pScanner->ext, &tagid);
+ else
+ rc = getTagIDByStringAndExt(name, pScanner->ext, &tagid);
+ } else {
+ /* we have a new Namespace */
+ if (nsprelen > 0 && smlLibStrlen(name) > nsprelen+1) {
+ if (name[nsprelen] != ':' || smlLibStrncmp(name,nsprefix, nsprelen) != 0) {
+ smlLibFree(name);
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(nsprefix);
+ return SML_ERR_XLT_NO_MATCHING_CODEPAGE;
+ }
+ }
+ /* Strip off namespace prefixes and ':' to find the tag.
+ * If no prefix is defined (pScanner->nsprelen == 0) take the whole tagname.
+ */
+ if (nsprelen > 0)
+ rc = getTagIDByStringAndExt(&name[nsprelen+1], ext, &tagid);
+ else
+ rc = getTagIDByStringAndExt(name, ext, &tagid);
+ }
+ /* free temporary buffers */
+ smlLibFree(name);
+ smlLibFree(attname);
+ smlLibFree(value);
+
+ if ((tagid == TN_UNDEF) || (rc != SML_ERR_OK)) {
+ smlLibFree(nsprefix);
+ return rc;
+ }
+
+ /* remember the old extension including the corresponding start tag if we found a new one */
+ if (ext != pScanner->ext) { /* namespace changed */
+ pScanner->prev_ext = pScanner->ext; /* remember the old ext */
+ pScanner->prev_ext_tag = pScanner->ext_tag; /* and the corresponding start tag */
+ pScanner->ext = ext;
+ pScanner->ext_tag = tagid;
+ smlLibFree(pScanner->nsprefix);
+ pScanner->nsprefix = nsprefix;
+ pScanner->nsprelen = nsprelen;
+ }
+
+
+ pScanner->curtok->tagid = tagid;
+ pScanner->curtok->ext = pScanner->ext;
+ skipS(pScanner);
+
+ if (endtag) {
+ /* found end tag */
+ if (smlLibStrncmp((String_t)pScanner->pos, ">", 1) != 0)
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ pScanner->curtok->type = TOK_TAG_END;
+ readBytes(pScanner, 1);
+ /* in case of an endtag we might need to close the current CP */
+ if (tagid == pScanner->ext_tag) {
+ pScanner->ext_tag = pScanner->prev_ext_tag;
+ pScanner->ext = pScanner->prev_ext;
+ pScanner->prev_ext = SML_EXT_UNDEFINED;
+ pScanner->prev_ext_tag = TN_UNDEF;
+ pScanner->nsprelen = 0;
+ smlLibFree(pScanner->nsprefix);
+ pScanner->nsprefix = NULL;
+ }
+ } else {
+ /* Attributes are not supported in SyncML -> skip them*/
+ if ((rc = xmlSkipAttributes(pScanner)) != SML_ERR_OK) return rc;
+
+ if (smlLibStrncmp((String_t)pScanner->pos, "/>", 2) == 0) {
+ /* found empty tag */
+ pScanner->curtok->type = TOK_TAG_EMPTY;
+ readBytes(pScanner, 2);
+ } else if (smlLibStrncmp((String_t)pScanner->pos, ">", 1) == 0) {
+ pScanner->curtok->type = TOK_TAG_START;
+ readBytes(pScanner, 1);
+ } else {
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlSkipPI
+ *
+ * Skip PI elements
+ */
+static Ret_t
+xmlSkipPI(xmlScannerPrivPtr_t pScanner)
+{
+ if (pScanner) { /* Get rid of warning, this should not be called anyway */
+ }
+
+ return SML_ERR_UNSPECIFIC;
+}
+
+/**
+ * FUNCTION: xmlSkipComment
+ *
+ * Skip comments
+ */
+static Ret_t
+xmlSkipComment(xmlScannerPrivPtr_t pScanner)
+{
+ readBytes(pScanner, 4);
+
+ while ((pScanner->pos + 3 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "-->", 3) != 0))
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+
+ if (pScanner->pos + 3 > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ if (!readBytes(pScanner, 3))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ skipS(pScanner);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlSkipAttributes
+ *
+ * Skip attributes -> they are not supported in SyncML
+ */
+static Ret_t
+xmlSkipAttributes(xmlScannerPrivPtr_t pScanner)
+{
+
+ while ((pScanner->pos + 1 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, ">", 1)) && (smlLibStrncmp((String_t)pScanner->pos, "/>", 2)))
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+
+ if (pScanner->pos + 1 > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlCDATA
+ *
+ * Handle a CDATA content
+ */
+static Ret_t
+xmlCDATA(xmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPCData;
+ MemPtr_t begin;
+ int len;
+
+ readBytes(pScanner, 9);
+
+ pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+ if (pPCData == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ pPCData->contentType = SML_PCDATA_UNDEFINED;
+ pPCData->length = 0;
+ pPCData->content = NULL;
+
+ begin = pScanner->pos;
+ while (!((pScanner->pos[0] == ']') && (pScanner->pos[1] == ']') && (pScanner->pos[2] == '>')))
+ {
+ if (!readBytes(pScanner, 1))
+ {
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ }
+
+ len = pScanner->pos - begin;
+ pPCData->content = smlLibMalloc(len + 1);
+ if (pPCData->content == NULL) {
+ smlLibFree(pPCData);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ smlLibMemset(pPCData->content, 0, len + 1);
+ smlLibMemcpy(pPCData->content, begin, len);
+ pPCData->contentType = SML_PCDATA_CDATA;
+ pPCData->length = len;
+
+ pScanner->curtok->type = TOK_CONT;
+ pScanner->curtok->pcdata = pPCData;
+
+ readBytes(pScanner, 3);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlSkipPCDATA
+ *
+ * Read over a Pcdata content
+ */
+static Ret_t
+xmlSkipPCDATA(xmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPCData;
+ MemPtr_t begin;
+ int len;
+ Ret_t rc;
+ String_t _tagString = NULL;
+ String_t _tagString2 = NULL;
+
+ /* Check wether this PCData might contain a subdtd.
+ ** We assume a Sub DTD starts with '<' as first char.
+ ** If this char is present start further processing else
+ ** take it as pure String data. If the scanning returns an
+ ** error we reject the file, as '<' is not a valid char inside
+ ** PCData elements.
+ */
+ if (smlLibStrncmp((String_t)pScanner->pos, "<", 1) == 0) {
+ rc = xmlTag(pScanner, 0);
+ return rc;
+ }
+
+ _tagString = smlLibMalloc(XML_MAX_TAGLEN);
+ if (_tagString == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ if ((rc = getTagString(pScanner->curtok->tagid, _tagString, pScanner->curtok->ext)) != SML_ERR_OK)
+ {
+ smlLibFree(_tagString);
+ return rc;
+ }
+
+ _tagString2 = smlLibMalloc(smlLibStrlen(_tagString) + 4 + (pScanner->nsprelen +1));
+
+ // build a end tag String to compate (e.g. </Meta>)
+ // beware of possible namespace prefixes
+ if (_tagString2 == NULL)
+ {
+ smlLibFree(_tagString);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ _tagString2 = smlLibStrcpy(_tagString2,"</");
+ if (pScanner->nsprelen > 0) {
+ _tagString2 = smlLibStrcat(_tagString2,pScanner->nsprefix);
+ _tagString2 = smlLibStrcat(_tagString2,":");
+ }
+ _tagString2 = smlLibStrcat(_tagString2,_tagString);
+ _tagString2 = smlLibStrcat(_tagString2,">");
+ smlLibFree(_tagString);
+
+ pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+
+
+
+ if (pPCData == NULL)
+ {
+ smlLibFree(_tagString2);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ pPCData->contentType = SML_PCDATA_UNDEFINED;
+ pPCData->extension = SML_EXT_UNDEFINED;
+ pPCData->length = 0;
+ pPCData->content = NULL;
+
+ begin = pScanner->pos;
+
+ // read Pcdata content until end tag appears
+ len = smlLibStrlen(_tagString2);
+ while (smlLibStrncmp((String_t)pScanner->pos, _tagString2, len) != 0)
+ {
+ if ((pScanner->pos + len) >= pScanner->bufend)
+ {
+ smlLibFree(_tagString2);
+ smlLibFree(pPCData);
+ pScanner->curtok->pcdata = NULL;
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (!readBytes(pScanner, 1))
+ {
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ }
+
+ smlLibFree(_tagString2);
+
+ len = pScanner->pos - begin;
+ pPCData->content = smlLibMalloc(len + 1);
+ if (pPCData->content == NULL)
+ {
+ smlLibFree(pPCData);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+
+ smlLibMemset(pPCData->content, 0, len + 1);
+ xmlReadEscape(pPCData->content, begin, &len);
+
+ pPCData->contentType = SML_PCDATA_STRING;
+ pPCData->length = len;
+
+ pScanner->curtok->type = TOK_CONT;
+ pScanner->curtok->pcdata = pPCData;
+
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: isPcdata
+ *
+ * Check if the current tag id represents a Pcdata element
+ */
+Boolean_t isPcdata(XltTagID_t tagid)
+{
+ switch (tagid)
+ {
+ case TN_CMD:
+ case TN_CMDID:
+ case TN_CORRELATOR:
+ case TN_CMDREF:
+ case TN_LANG:
+ case TN_LOCNAME:
+ case TN_LOCURI:
+ case TN_MSGID:
+ case TN_MSGREF:
+ case TN_RESPURI:
+ case TN_SESSIONID:
+ case TN_SOURCEREF:
+ case TN_TARGETREF:
+ case TN_VERSION:
+ case TN_PROTO:
+ case TN_DATA:
+ case TN_META:
+ case TN_NUMBEROFCHANGES:
+#ifdef __USE_METINF__
+ case TN_METINF_EMI:
+ case TN_METINF_FORMAT:
+ case TN_METINF_FREEID:
+ case TN_METINF_FREEMEM:
+ case TN_METINF_LAST:
+ case TN_METINF_MARK:
+ case TN_METINF_MAXMSGSIZE:
+ /* SCTSTK - 18/03/2002 S.H. 2002-04-05 : SyncML 1.1 */
+ case TN_METINF_MAXOBJSIZE:
+ case TN_METINF_NEXT:
+ case TN_METINF_NEXTNONCE:
+ case TN_METINF_SIZE:
+ case TN_METINF_TYPE:
+ case TN_METINF_VERSION:
+#endif
+#ifdef __USE_DEVINF__
+ case TN_DEVINF_MAN:
+ case TN_DEVINF_MOD:
+ case TN_DEVINF_OEM:
+ case TN_DEVINF_FWV:
+ case TN_DEVINF_SWV:
+ case TN_DEVINF_HWV:
+ case TN_DEVINF_DEVID:
+ case TN_DEVINF_DEVTYP:
+ case TN_DEVINF_MAXGUIDSIZE:
+ case TN_DEVINF_SOURCEREF:
+ case TN_DEVINF_DISPLAYNAME:
+ case TN_DEVINF_CTTYPE:
+ case TN_DEVINF_DATATYPE:
+ case TN_DEVINF_SIZE:
+ case TN_DEVINF_PROPNAME:
+ case TN_DEVINF_VALENUM:
+ case TN_DEVINF_PARAMNAME:
+ case TN_DEVINF_SYNCTYPE:
+ case TN_DEVINF_XNAM:
+ case TN_DEVINF_XVAL:
+ case TN_DEVINF_MAXMEM:
+ case TN_DEVINF_MAXID:
+ case TN_DEVINF_VERCT:
+ case TN_DEVINF_VERDTD:
+#endif
+#ifdef __USE_DMTND__
+ case TN_DMTND_AccessType: // TND->Node->DFProps
+ case TN_DMTND_ACL: // TND->Node->RTProps
+ case TN_DMTND_Add: // TND->Node->DFProps->AccessType
+ case TN_DMTND_b64: // TND->Node->RTProps->Format
+ case TN_DMTND_bin: // TND->Node->RTProps->Format
+ case TN_DMTND_bool: // TND->Node->RTProps->Format
+ case TN_DMTND_chr: // TND->Node->RTProps->Format
+ // case TN_DMTND_CaseSense: // TND->Node->DFProps
+ case TN_DMTND_CIS: // TND->Node->DFProps->CaseSense
+ case TN_DMTND_Copy: // TND->Node->DFProps->AccessType
+ case TN_DMTND_CS: // TND->Node->DFProps->CaseSense
+ case TN_DMTND_date: // TND->Node->RTProps->Format
+ case TN_DMTND_DDFName: // TND->Node->RTProps->Type
+ case TN_DMTND_DefaultValue: // TND->Node->DFProps
+ case TN_DMTND_Delete: // TND->Node->DFProps->AccessType
+ case TN_DMTND_Description: // TND->Node->DFProps
+ case TN_DMTND_DFFormat: // TND->Node->DFProps
+ // case TN_DMTND_DFProperties: // TND->Node
+ case TN_DMTND_DFTitle: // TND->Node->DFProps
+ case TN_DMTND_DFType: // TND->Node->DFProps
+ // case TN_DMTND_Dynamic: // TND->Node->DFProps->Scope
+ case TN_DMTND_Exec: // TND->Node->DFProps->AccessType
+ case TN_DMTND_float: // TND->Node->RTProps->Format
+ // case TN_DMTND_Format: // TND->Node->RTProps:
+ case TN_DMTND_Get: // TND->Node->DFProps->AccessType
+ case TN_DMTND_int: // TND->Node->RTProps->Format
+ case TN_DMTND_Man: // TND
+ // case TN_DMTND_MgmtTree:
+ case TN_DMTND_MIME: // TND->Node->RTProps->Type
+ case TN_DMTND_Mod: // TND
+ case TN_DMTND_Name: // TND->Node->RTProps
+ // case TN_DMTND_Node: // TND
+ case TN_DMTND_node: // TND->Node->RTProps->Format
+ case TN_DMTND_NodeName: // TND->Node
+ case TN_DMTND_null: // TND->Node->RTProps->Format
+ // case TN_DMTND_Occurrence: // TND->Node->DFProps
+ case TN_DMTND_One: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_OneOrMore: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_OneOrN: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_Path: // TND->Node
+ case TN_DMTND_Permanent: // TND->Node->DFProps->Scope
+ case TN_DMTND_Replace: // TND->Node->DFProps->AccessType
+ // case TN_DMTND_RTProperties: // TND->Node
+ // case TN_DMTND_Scope: // TND->Node->DFProps
+ case TN_DMTND_Size: // TND->Node->RTProps
+ case TN_DMTND_time: // TND->Node->RTProps->Format
+ case TN_DMTND_Title: // TND->Node->RTProps
+ case TN_DMTND_TStamp: // TND->Node->RTProps
+ // case TN_DMTND_Type: // TND->Node->RTProps->Type
+ case TN_DMTND_Value: // TND
+ case TN_DMTND_VerDTD: // TND
+ case TN_DMTND_VerNo: // TND->Node->RTProps
+ case TN_DMTND_xml: // TND->Node->RTProps->Format
+ case TN_DMTND_ZeroOrMore: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_ZeroOrN: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_ZeroOrOne:// TND->Node->DFProps->Occurrence
+#endif
+ return 1;
+ default:
+ return 0;
+ }
+}
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdevinf.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdevinf.c
new file mode 100644
index 0000000..6903615
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdevinf.c
@@ -0,0 +1,987 @@
+/*************************************************************************/
+/* module: DeviceInf DTD related functions for the en-/decoder */
+/* file: xltdevinf.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#include "define.h"
+#ifdef __USE_DEVINF__
+
+#include "smldevinfdtd.h"
+#include "xlttags.h"
+#include "xltdevinf.h"
+#include "xlttagtbl.h"
+#include "xltenc.h"
+#include "xltencwbxml.h"
+
+#include <libstr.h>
+#include <smlerr.h>
+#include <smldtd.h>
+#include <libmem.h>
+#include <libutil.h>
+
+/* decoder callbacks */
+Ret_t buildDevInfDevInfContent(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+
+
+Ret_t buildDevInfDevInfCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfDevInfPtr_t pElem = NULL;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_DEVINF:
+ rc = buildDevInfDevInfContent(pDecoder, (VoidPtr_t)&pElem);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfDevInfContent(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfDevInfPtr_t pElem;
+ Ret_t rc;
+ /* Modified by Tomy to allow <UTC></UTC>, <SupportNumberOfChanges></SupportNumberOfChanges> and <SupportLargeObjs></SupportLargeObjs> */
+ SmlPcdataPtr_t tmp_ptr;
+ /* End modified by Tomy */
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfDevInfPtr_t)smlLibMalloc(sizeof(SmlDevInfDevInf_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfDevInf_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_VERDTD:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->verdtd);
+ break;
+ case TN_DEVINF_MAN:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->man);
+ break;
+ case TN_DEVINF_MOD:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->mod);
+ break;
+ case TN_DEVINF_OEM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->oem);
+ break;
+ case TN_DEVINF_FWV:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->fwv);
+ break;
+ case TN_DEVINF_SWV:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->swv);
+ break;
+ case TN_DEVINF_HWV:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->hwv);
+ break;
+ case TN_DEVINF_DEVID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->devid);
+ break;
+ case TN_DEVINF_DEVTYP:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->devtyp);
+ break;
+ case TN_DEVINF_DATASTORE:
+ rc = buildDevInfDataStoreList(pDecoder, (VoidPtr_t)&pElem->datastore);
+ break;
+ case TN_DEVINF_CTCAP:
+ rc = buildDevInfCtcap(pDecoder, (VoidPtr_t)&pElem->ctcap);
+ break;
+ case TN_DEVINF_EXT:
+ rc = buildDevInfExtList(pDecoder, (VoidPtr_t)&pElem->ext);
+ break;
+ /* SCTSTK - 18/03/2002 S.H. 2002-04-05 : SyncML 1.1 */
+ case TN_DEVINF_UTC:
+ pElem->flags |= SmlDevInfUTC_f;
+ /* Modified by Tomy to allow <UTC></UTC> */
+ tmp_ptr = NULL;
+ rc = buildPCData(pDecoder, (VoidPtr_t)&tmp_ptr);
+ if (tmp_ptr->contentType != SML_PCDATA_UNDEFINED && tmp_ptr->extension != SML_EXT_UNDEFINED && tmp_ptr->length != 0 && tmp_ptr->content != NULL) rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ /* End modified by Tomy */
+ break;
+ case TN_DEVINF_NOFM:
+ pElem->flags |= SmlDevInfNOfM_f;
+ /* Modified by Tomy to allow <SupportNumberOfChanges></SupportNumberOfChanges> */
+ tmp_ptr = NULL;
+ rc = buildPCData(pDecoder, (VoidPtr_t)&tmp_ptr);
+ if (tmp_ptr->contentType != SML_PCDATA_UNDEFINED && tmp_ptr->extension != SML_EXT_UNDEFINED && tmp_ptr->length != 0 && tmp_ptr->content != NULL) rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ /* End modified by Tomy */
+ break;
+ case TN_DEVINF_LARGEOBJECT:
+ pElem->flags |= SmlDevInfLargeObject_f;
+ /* Modified by Tomy to allow <SupportLargeObjs></SupportLargeObjs> */
+ tmp_ptr = NULL;
+ rc = buildPCData(pDecoder, (VoidPtr_t)&tmp_ptr);
+ if (tmp_ptr->contentType != SML_PCDATA_UNDEFINED && tmp_ptr->extension != SML_EXT_UNDEFINED && tmp_ptr->length != 0 && tmp_ptr->content != NULL) rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ /* End modified by Tomy */
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfDataStoreCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfDatastorePtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfDatastorePtr_t)smlLibMalloc(sizeof(SmlDevInfDatastore_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfDatastore_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_DEVINF_SOURCEREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->sourceref);
+ break;
+ case TN_DEVINF_DISPLAYNAME:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->displayname);
+ break;
+ case TN_DEVINF_MAXGUIDSIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxguidsize);
+ break;
+ case TN_DEVINF_RXPREF:
+ rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->rxpref);
+ break;
+ case TN_DEVINF_TXPREF:
+ rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->txpref);
+ break;
+ case TN_DEVINF_RX:
+ rc = buildDevInfXmitList(pDecoder, (VoidPtr_t)&pElem->rx);
+ break;
+ case TN_DEVINF_TX:
+ rc = buildDevInfXmitList(pDecoder, (VoidPtr_t)&pElem->tx);
+ break;
+ case TN_DEVINF_DSMEM:
+ rc = buildDevInfDSMemCmd(pDecoder, (VoidPtr_t)&pElem->dsmem);
+ break;
+ case TN_DEVINF_SYNCCAP:
+ rc = buildDevInfSyncCapCmd(pDecoder, (VoidPtr_t)&pElem->synccap);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfXmitCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfXmitPtr_t pXmit;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pXmit = (SmlDevInfXmitPtr_t)smlLibMalloc(sizeof(SmlDevInfXmit_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pXmit, 0, sizeof(SmlDevInfXmit_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pXmit;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pXmit);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_DEVINF_CTTYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->cttype);
+ break;
+ case TN_DEVINF_VERCT:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->verct);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pXmit);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pXmit);
+ return rc;
+ }
+ }
+ *ppElem = pXmit;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfXmitList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ SmlDevInfXmitListPtr_t pElem = NULL, pPrev = NULL;
+
+ pElem = (SmlDevInfXmitListPtr_t) *ppElem;
+
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pElem != NULL) {
+ pPrev = pElem;
+ pElem = pPrev->next;
+ }
+ if ((pElem = (SmlDevInfXmitListPtr_t)smlLibMalloc(sizeof(SmlDevInfXmitList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfXmitList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pElem;
+ else /* nope we created a new list */
+ *ppElem = pElem;
+ pElem->data = NULL;
+ /* at this point pElem should point to an valid list element */
+ return buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->data);
+}
+
+Ret_t buildDevInfDataStoreList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ SmlDevInfDatastoreListPtr_t pElem = NULL, pPrev = NULL;
+
+ pElem = (SmlDevInfDatastoreListPtr_t) *ppElem;
+
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pElem != NULL) {
+ pPrev = pElem;
+ pElem = pPrev->next;
+ }
+ if ((pElem = (SmlDevInfDatastoreListPtr_t)smlLibMalloc(sizeof(SmlDevInfDatastoreList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfDatastoreList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pElem;
+ else /* nope we created a new list */
+ *ppElem = pElem;
+ pElem->data = NULL;
+ /* at this point pElem should point to an valid list element */
+ return buildDevInfDataStoreCmd(pDecoder, (VoidPtr_t)&pElem->data);
+}
+
+Ret_t buildDevInfExtList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ SmlDevInfExtListPtr_t pElem = NULL, pPrev = NULL;
+
+ pElem = (SmlDevInfExtListPtr_t) *ppElem;
+
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pElem != NULL) {
+ pPrev = pElem;
+ pElem = pPrev->next;
+ }
+ if ((pElem = (SmlDevInfExtListPtr_t)smlLibMalloc(sizeof(SmlDevInfExtList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfExtList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pElem;
+ else /* nope we created a new list */
+ *ppElem = pElem;
+ pElem->data = NULL;
+ /* at this point pElem should point to an valid list element */
+ return buildDevInfExtCmd(pDecoder, (VoidPtr_t)&pElem->data);
+}
+
+
+Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ SmlDevInfCtcapListPtr_t pCtcap = NULL, pPrev = NULL;
+ SmlDevInfCTDataPropListPtr_t pOldProp = NULL, pProp = NULL;
+ SmlDevInfCTDataListPtr_t pOldParam = NULL, pParam = NULL;
+ SmlDevInfCtcapListPtr_t pElem = NULL;
+ XltDecScannerPtr_t pScanner;
+ Ret_t rc;
+
+ pElem = (SmlDevInfCtcapListPtr_t) *ppElem;
+ pScanner = pDecoder->scanner;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_CTTYPE:
+ pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pCtcap != NULL) {
+ pPrev = pCtcap;
+ pCtcap = pPrev->next;
+ }
+ if ((pCtcap = (SmlDevInfCtcapListPtr_t)smlLibMalloc(sizeof(SmlDevInfCtcapList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pCtcap, 0, sizeof(SmlDevInfCtcapList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pCtcap;
+ else /* nope we created a new list */
+ *ppElem = pCtcap;
+ pCtcap->data = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t));
+ if (pCtcap->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pCtcap->data, 0, sizeof(SmlDevInfCTCap_t));
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pCtcap->data->cttype);
+ break;
+ case TN_DEVINF_PROPNAME:
+ pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;
+ if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pCtcap->next != NULL) {
+ pPrev = pCtcap;
+ pCtcap = pCtcap->next;
+ }
+ /* here we are at the latest defined DevInfCTCapPtr_t */
+ /* now we need to create a new DevInfCTDataPtr_t element, tostore the properties name */
+ pOldProp = NULL;
+ pProp = pCtcap->data->prop;
+ while (pProp != NULL) {
+ pOldProp = pProp;
+ pProp = pProp->next;
+ }
+ pProp = (SmlDevInfCTDataPropListPtr_t) smlLibMalloc(sizeof(SmlDevInfCTDataPropList_t));
+ if (pProp == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pProp, 0, sizeof(SmlDevInfCTDataPropList_t));
+ if (pOldProp != NULL)
+ pOldProp->next = pProp;
+ else
+ pCtcap->data->prop = pProp;
+ pProp->data = (SmlDevInfCTDataPropPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataProp_t));
+ if (pProp->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pProp->data, 0, sizeof(SmlDevInfCTDataProp_t));
+ pProp->data->prop = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));
+ if (pProp->data->prop == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pProp->data->prop, 0, sizeof(SmlDevInfCTData_t));
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->name);
+ break;
+ case TN_DEVINF_PARAMNAME:
+ pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;
+ if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pCtcap->next != NULL) {
+ pPrev = pCtcap;
+ pCtcap = pCtcap->next;
+ }
+ /* here we are at the latest defined DevInfCTCapPtr_t */
+ pProp = pCtcap->data->prop;
+ if (pProp == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pProp->next != NULL) {
+ pProp = pProp->next;
+ }
+ /* here we are at the latest defined PropList Element in the latest defined CTCap element */
+ /* now lets insert a new Param element into this property */
+ pOldParam = NULL;
+ pParam = pProp->data->param;
+ while (pParam != NULL) {
+ pOldParam = pParam;
+ pParam = pParam->next;
+ }
+ pParam = (SmlDevInfCTDataListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataList_t));
+ if (pParam == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pParam, 0, sizeof(SmlDevInfCTDataList_t));
+ if (pOldParam != NULL)
+ pOldParam->next = pParam;
+ else
+ pProp->data->param = pParam;
+ pParam->data = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));
+ if (pParam->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pParam->data, 0, sizeof(SmlDevInfCTData_t));
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->name);
+ break;
+ case TN_DEVINF_DISPLAYNAME:
+ case TN_DEVINF_VALENUM:
+ case TN_DEVINF_DATATYPE:
+ case TN_DEVINF_SIZE:
+ /* The code for the above 4 is basically the same.
+ * The hardpart is finding the right SmlDevInfCTDataPtr_t
+ * struct, as it can be either within a Property or an Parameter.
+ */
+ pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;
+ if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pCtcap->next != NULL) {
+ pCtcap = pCtcap->next;
+ }
+ /* here we are at the latest defined DevInfCTCapPtr_t */
+ pProp = pCtcap->data->prop;
+ if (pProp == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pProp->next != NULL) {
+ pProp = pProp->next;
+ }
+
+ if (pProp->data == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ if (pProp->data->prop == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ if (pProp->data->param == NULL) {
+ /* No Param's yet so we have Property fields to fill */
+ switch(pScanner->curtok->tagid) {
+ case TN_DEVINF_DISPLAYNAME:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->dname);
+ break;
+ case TN_DEVINF_VALENUM:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pProp->data->prop->valenum);
+ break;
+ case TN_DEVINF_DATATYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->datatype);
+ break;
+ case TN_DEVINF_SIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->size);
+ break;
+ default:
+ break;
+ }
+ } else {
+ pParam = pProp->data->param;
+ while (pParam->next != NULL) {
+ pParam = pParam->next;
+ }
+ if (pParam->data == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ switch(pScanner->curtok->tagid) {
+ case TN_DEVINF_DISPLAYNAME:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->dname);
+ break;
+ case TN_DEVINF_VALENUM:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pParam->data->valenum);
+ break;
+ case TN_DEVINF_DATATYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->datatype);
+ break;
+ case TN_DEVINF_SIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->size);
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ } /* eof while */
+ pElem = *ppElem;
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfDSMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfDSMemPtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfDSMemPtr_t)smlLibMalloc(sizeof(SmlDevInfDSMem_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfDSMem_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_DEVINF_SHAREDMEM:
+ // %%% luz:2003-04-28: made work as a flag
+ pElem->flags |= SmlDevInfSharedMem_f;
+ // rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->shared);
+ break;
+ case TN_DEVINF_MAXMEM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxmem);
+ break;
+ case TN_DEVINF_MAXID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxid);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfCTCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfCTCapPtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfCTCap_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_CTTYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->cttype);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfSyncCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfSyncCapPtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfSyncCapPtr_t)smlLibMalloc(sizeof(SmlDevInfSyncCap_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfSyncCap_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_SYNCTYPE:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pElem->synctype);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfExtCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfExtPtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfExtPtr_t)smlLibMalloc(sizeof(SmlDevInfExt_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfExt_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_XNAM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->xnam);
+ break;
+ case TN_DEVINF_XVAL:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pElem->xval);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+
+/* see xltenc.c:XltEncBlock for description of parameters */
+Ret_t devinfEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag) {
+ //Return variable
+ Ret_t _err;
+ SmlPcdataListPtr_t pList = NULL, p2List = NULL;
+ SmlDevInfDatastoreListPtr_t dsList = NULL;
+ SmlDevInfCtcapListPtr_t ctList = NULL;
+ SmlDevInfExtListPtr_t exList = NULL;
+ SmlDevInfXmitListPtr_t xmList = NULL;
+ SmlDevInfCTDataPropListPtr_t propList = NULL;
+ SmlDevInfCTDataListPtr_t paramList = NULL;
+
+ //Check if pContent of a required field is missing
+ if ((reqOptFlag == REQUIRED) && (pContent == NULL))
+ return SML_ERR_XLT_MISSING_CONT;
+ //Check if pContent of a optional field is missing -> if yes we are done
+ else if (pContent == NULL)
+ return SML_ERR_OK;
+
+ //Generate the commands -> see DTD
+ switch (tagId) {
+ case TN_DEVINF_EXT:
+ if ((_err = xltGenerateTag(TN_DEVINF_EXT, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_XNAM, REQUIRED, ((SmlDevInfExtPtr_t) pContent)->xnam, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = ((SmlDevInfExtPtr_t)pContent)->xval;
+ while (pList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_XVAL, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = pList->next;
+ };
+ if ((_err = xltGenerateTag(TN_DEVINF_EXT, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_SYNCCAP:
+ if ((_err = xltGenerateTag(TN_DEVINF_SYNCCAP, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = ((SmlDevInfSyncCapPtr_t)pContent)->synctype;
+ while (pList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_SYNCTYPE, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = pList->next;
+ };
+ if ((_err = xltGenerateTag(TN_DEVINF_SYNCCAP, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_SHAREDMEM:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlDevInfSharedMem_f))
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ // %%% luz:2003-04-28 added missing 1.1 devinf tags here
+ case TN_DEVINF_UTC:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlDevInfUTC_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_DEVINF_NOFM:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlDevInfNOfM_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_DEVINF_LARGEOBJECT:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlDevInfLargeObject_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ break;
+ // %%% end luz
+ case TN_DEVINF_CTCAP:
+ if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ ctList = ((SmlDevInfCtcapListPtr_t)pContent);
+ if (ctList == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ while (ctList != NULL) {
+ if (ctList->data == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if ((_err = devinfEncBlock(TN_DEVINF_CTTYPE, OPTIONAL, ctList->data->cttype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ /* now the propList */
+ // %%% luz 2002-11-27: made property list optional (e.g. text/message of P800 has none)
+ propList = ctList->data->prop;
+ // %%% original: if (propList == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ while (propList != NULL) {
+ if (propList->data == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (propList->data->prop == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ /* -- Propname */
+ if ((_err = devinfEncBlock(TN_DEVINF_PROPNAME, REQUIRED, propList->data->prop->name, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ /* -- (ValEnum+ | (Datatype, Size?))? */
+ //if (propList->data->prop->valenum == NULL && propList->data->prop->datatype == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (propList->data->prop->valenum != NULL && propList->data->prop->datatype != NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (propList->data->prop->valenum != NULL) {
+ // ValEnum+
+ pList = propList->data->prop->valenum;
+ while (pList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_VALENUM, REQUIRED, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = pList->next;
+ };
+ } else if (propList->data->prop->datatype != NULL) {
+ // Datatype, Size?
+ if ((_err = devinfEncBlock(TN_DEVINF_DATATYPE, REQUIRED, propList->data->prop->datatype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SIZE, OPTIONAL, propList->data->prop->size, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ /* -- DisplayName ? */
+ if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, propList->data->prop->dname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ /* -- now the paramList */
+ paramList = propList->data->param;
+ while (paramList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_PARAMNAME, REQUIRED, paramList->data->name, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ /* -- (ValEnum+ | (Datatype, Size?))? */
+ //if (paramList->data->valenum == NULL && paramList->data->datatype == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (paramList->data->valenum != NULL && paramList->data->datatype != NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (paramList->data->valenum != NULL) {
+ // ValEnum+
+ p2List = paramList->data->valenum;
+ while (p2List != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_VALENUM, REQUIRED, p2List->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ p2List = p2List->next;
+ };
+ } else if (paramList->data->datatype != NULL) {
+ // Datatype, Size?
+ if ((_err = devinfEncBlock(TN_DEVINF_DATATYPE, REQUIRED, paramList->data->datatype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SIZE, OPTIONAL, paramList->data->size, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ /* -- DisplayName ? */
+ if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, paramList->data->dname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ paramList = paramList->next;
+ }
+ propList = propList->next;
+ }
+ /* eof propList */
+ ctList = ctList->next;
+ };
+
+ if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_DSMEM:
+ if ((_err = xltGenerateTag(TN_DEVINF_DSMEM, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SHAREDMEM, OPTIONAL, &(((SmlDevInfDSMemPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MAXMEM, OPTIONAL, ((SmlDevInfDSMemPtr_t) pContent)->maxmem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MAXID, OPTIONAL, ((SmlDevInfDSMemPtr_t) pContent)->maxid, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_DEVINF_DSMEM, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ // special case, the following 4 have the same structure, only the tag name differs
+ case TN_DEVINF_RX:
+ case TN_DEVINF_TX:
+ case TN_DEVINF_RXPREF:
+ case TN_DEVINF_TXPREF:
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_CTTYPE, REQUIRED, ((SmlDevInfXmitPtr_t) pContent)->cttype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_VERCT, REQUIRED, ((SmlDevInfXmitPtr_t) pContent)->verct, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_DATASTORE:
+ if ((_err = xltGenerateTag(TN_DEVINF_DATASTORE, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SOURCEREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->sourceref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->displayname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MAXGUIDSIZE, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->maxguidsize, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_RXPREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->rxpref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ xmList = ((SmlDevInfDatastorePtr_t)pContent)->rx;
+ while (xmList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_RX, OPTIONAL, xmList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ xmList = xmList->next;
+ };
+ if ((_err = devinfEncBlock(TN_DEVINF_TXPREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->txpref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ xmList = ((SmlDevInfDatastorePtr_t)pContent)->tx;
+ while (xmList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_TX, OPTIONAL, xmList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ xmList = xmList->next;
+ };
+ if ((_err = devinfEncBlock(TN_DEVINF_DSMEM, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->dsmem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SYNCCAP, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->synccap, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_DEVINF_DATASTORE, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_DEVINF:
+ if ((_err = xltGenerateTag(TN_DEVINF_DEVINF, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_VERDTD, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->verdtd, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MAN, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->man, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MOD, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->mod, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_OEM, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->oem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_FWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->fwv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->swv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_HWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->hwv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_DEVID, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->devid, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_DEVTYP, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->devtyp, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ // %%% luz:2003-04-28 added missing SyncML 1.1 devinf tags
+ if ((_err = devinfEncBlock(TN_DEVINF_UTC, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_NOFM, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_LARGEOBJECT, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ // %%% end luz
+
+ dsList = ((SmlDevInfDevInfPtr_t)pContent)->datastore;
+ if (dsList == NULL) return SML_ERR_XLT_MISSING_CONT;
+ if ((_err = devinfEncBlock(TN_DEVINF_DATASTORE, REQUIRED, dsList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ dsList = dsList->next;
+ while (dsList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_DATASTORE, OPTIONAL, dsList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ dsList = dsList->next;
+ };
+ if ((_err = devinfEncBlock(TN_DEVINF_CTCAP, OPTIONAL, ((SmlDevInfDevInfPtr_t)pContent)->ctcap, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ exList = ((SmlDevInfDevInfPtr_t)pContent)->ext;
+ while (exList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_EXT, OPTIONAL, exList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ exList = exList->next;
+ };
+
+
+ if ((_err = xltGenerateTag(TN_DEVINF_DEVINF, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+
+ default: { // all leaf nodes (PCDATA#)
+ return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag);
+ } //* eof default statement from switch tagid
+ } // eof switch tagid
+ return SML_ERR_OK;
+}
+#endif /* __USE_DEVINF__ */
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdevinf.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdevinf.h
new file mode 100644
index 0000000..4e91718
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdevinf.h
@@ -0,0 +1,75 @@
+/*************************************************************************/
+/* module: Definition of DevInf DTD prototypefunctions */
+/* for the en-/decoder */
+/* file: xltdevinf.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#ifndef _XLT_DEVINF_H
+#define _XLT_DEVINF_H
+
+/* process only if we really use DevInf DTD */
+#ifdef __USE_DEVINF__
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xlttagtbl.h"
+#include "xltenc.h"
+
+Ret_t buildDevInfDevInfCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfDataStoreCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfXmitCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfXmitList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfDSMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfCTCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfSyncCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfExtCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfDataStoreList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfExtList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfCTCapList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+
+
+Ret_t devinfEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+#endif /* __USE_DEVINF__ */
+#endif /* _XLT_DEVINF_H */
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdmtnd.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdmtnd.c
new file mode 100644
index 0000000..7fb8173
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdmtnd.c
@@ -0,0 +1,755 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*--------------------------------------------------------------------------------------------------
+
+ Header Name: xltdmtnd.c
+
+ General Description: XLT DM TND related functions
+
+--------------------------------------------------------------------------------------------------*/
+
+#include "define.h"
+
+#ifdef __USE_DMTND__
+#include "smldmtnddtd.h"
+
+#include "xlttags.h"
+#include "xltdmtnd.h"
+#include "xlttagtbl.h"
+#include "xltenc.h"
+#include "xltencwbxml.h"
+
+#include <define.h>
+#include <libstr.h>
+#include <smlerr.h>
+#include <libmem.h>
+#include <libutil.h>
+/* extern */
+extern SML_API void smlFreeDmTndFormat(SmlDmTndFormatPtr_t data);
+extern SML_API void smlFreeDmTndType(SmlDmTndTypePtr_t data);
+extern SML_API void smlFreeDmTndDFElement(SmlDmTndDFElementPtr_t data);
+extern SML_API void smlFreeDmTndRTProps(SmlDmTndRTPropsPtr_t data);
+extern SML_API void smlFreeDmTndDFProps(SmlDmTndDFPropsPtr_t data);
+extern SML_API void smlFreeDmTndNode(SmlDmTndNodePtr_t data);
+extern SML_API void smlFreeDmTndNodeList(SmlDmTndNodeListPtr_t data);
+extern SML_API void smlFreeDmTnd(SmlDmTndPtr_t data);
+
+Ret_t buildDmTndNodeCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+
+/* decoder callbacks */
+Ret_t buildDmTndFormatCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndFormatPtr_t pDmTndFormat;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndFormat = (SmlDmTndFormatPtr_t)smlLibMalloc(sizeof(SmlDmTndFormat_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndFormat, 0, sizeof(SmlDmTndFormat_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndFormat;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndFormat(pDmTndFormat);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ VoidPtr_t pContent = smlLibMalloc(6);
+ if ( pContent == NULL )
+ {
+ smlFreeDmTndFormat(pDmTndFormat);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pContent, 0, 6);
+
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_b64:
+ smlLibStrcpy(pContent, "b64");
+ break;
+ case TN_DMTND_bin:
+ smlLibStrcpy(pContent, "bin");
+ break;
+ case TN_DMTND_bool:
+ smlLibStrcpy(pContent, "bool");
+ break;
+ case TN_DMTND_chr:
+ smlLibStrcpy(pContent, "chr");
+ break;
+ case TN_DMTND_int:
+ smlLibStrcpy(pContent, "int");
+ break;
+ case TN_DMTND_node:
+ smlLibStrcpy(pContent, "node");
+ break;
+ case TN_DMTND_null:
+ smlLibStrcpy(pContent, "null");
+ break;
+ case TN_DMTND_xml:
+ smlLibStrcpy(pContent, "xml");
+ break;
+ case TN_DMTND_date:
+ smlLibStrcpy(pContent, "date");
+ break;
+ case TN_DMTND_time:
+ smlLibStrcpy(pContent, "time");
+ break;
+ case TN_DMTND_float:
+ smlLibStrcpy(pContent, "float");
+ break;
+ default:
+ KCDBG(">>>>> Unkown token: %d <<<<<\n", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pContent);
+ smlFreeDmTndFormat(pDmTndFormat);
+ return rc;
+ }
+
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndFormat->value);
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pContent);
+ smlFreeDmTndFormat(pDmTndFormat);
+ return rc;
+ }
+ pDmTndFormat->value->content = pContent;
+ pDmTndFormat->value->length = smlLibStrlen(pContent);
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pContent);
+ smlFreeDmTndFormat(pDmTndFormat);
+ return rc;
+ }
+ if (pScanner->curtok->type != TOK_TAG_END) {
+ smlLibFree(pContent);
+ smlFreeDmTndFormat(pDmTndFormat);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+
+ *ppElem = pDmTndFormat;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndTypeCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndTypePtr_t pDmTndType;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndType = (SmlDmTndTypePtr_t)smlLibMalloc(sizeof(SmlDmTndType_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndType, 0, sizeof(SmlDmTndType_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndType;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndType(pDmTndType);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_MIME:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndType->mime);
+ break;
+ case TN_DMTND_DDFName:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndType->ddfname);
+ break;
+ default:
+ KCDBG(">>>>> Unkown token: %d <<<<<\n", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTndType(pDmTndType);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndType(pDmTndType);
+ return rc;
+ }
+ if (pScanner->curtok->type != TOK_TAG_END) {
+ smlFreeDmTndType(pDmTndType);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+
+ *ppElem = pDmTndType;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndDFElementCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndDFElementPtr_t pDmTndDFElement;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndDFElement = (SmlDmTndDFElementPtr_t)smlLibMalloc(sizeof(SmlDmTndDFElement_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndDFElement, 0, sizeof(SmlDmTndDFElement_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndDFElement;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ VoidPtr_t pContent = smlLibMalloc(10);
+ if ( pContent == NULL )
+ {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pContent, 0, 10);
+
+ switch (pScanner->curtok->tagid) {
+ /* AccessType Elements */
+ case TN_DMTND_Add:
+ smlLibStrcpy(pContent, "Add");
+ break;
+ case TN_DMTND_Copy:
+ smlLibStrcpy(pContent, "Copy");
+ break;
+ case TN_DMTND_Delete:
+ smlLibStrcpy(pContent, "Delete");
+ break;
+ case TN_DMTND_Exec:
+ smlLibStrcpy(pContent, "Exec");
+ break;
+ case TN_DMTND_Get:
+ smlLibStrcpy(pContent, "Get");
+ break;
+ case TN_DMTND_Replace:
+ smlLibStrcpy(pContent, "Replace");
+ break;
+ /* Occurrence Elements */
+ case TN_DMTND_One:
+ smlLibStrcpy(pContent, "One");
+ break;
+ case TN_DMTND_ZeroOrOne:
+ smlLibStrcpy(pContent, "ZeroOrOne");
+ break;
+ case TN_DMTND_ZeroOrMore:
+ smlLibStrcpy(pContent, "ZeroOrMore");
+ break;
+ case TN_DMTND_OneOrMore:
+ smlLibStrcpy(pContent, "OneOrMore");
+ break;
+ case TN_DMTND_ZeroOrN:
+ smlLibStrcpy(pContent, "ZeroOrN");
+ break;
+ case TN_DMTND_OneOrN:
+ smlLibStrcpy(pContent, "OneOrN");
+ break;
+ /* Scope Elements */
+ case TN_DMTND_Permanent:
+ smlLibStrcpy(pContent, "Permanent");
+ break;
+ case TN_DMTND_Dynamic:
+ smlLibStrcpy(pContent, "Dynamic");
+ break;
+ /* CaseSense Elements */
+ case TN_DMTND_CS:
+ smlLibStrcpy(pContent, "CS");
+ break;
+ case TN_DMTND_CIS:
+ smlLibStrcpy(pContent, "CIS");
+ break;
+ default:
+ KCDBG(">>>>> buildDmTndDFElementCmd: Unkown token: %d <<<<<\n", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return rc;
+ }
+ if (pScanner->curtok->type != TOK_TAG_END) {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+
+ *ppElem = pDmTndDFElement;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndRTPropsCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndRTPropsPtr_t pDmTndRTProps;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndRTProps = (SmlDmTndRTPropsPtr_t)smlLibMalloc(sizeof(SmlDmTndRTProps_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndRTProps, 0, sizeof(SmlDmTndRTProps_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndRTProps;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndRTProps(pDmTndRTProps);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_ACL:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->acl);
+ break;
+ case TN_DMTND_Format:
+ rc = buildDmTndFormatCmd(pDecoder, (VoidPtr_t)&pDmTndRTProps->format);
+ break;
+ case TN_DMTND_Name:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->name);
+ break;
+ case TN_DMTND_Size:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->size);
+ break;
+ case TN_DMTND_Title:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->title);
+ break;
+ case TN_DMTND_TStamp:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->tstamp);
+ break;
+ case TN_DMTND_Type:
+ rc = buildDmTndTypeCmd(pDecoder, (VoidPtr_t)&pDmTndRTProps->type);
+ break;
+ case TN_DMTND_VerNo:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->verno);
+ break;
+ default:
+ KCDBG(">>>>> buildDmTndRTPropsCmd: Unkown token: %d <<<<<\n", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTndRTProps(pDmTndRTProps);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndRTProps(pDmTndRTProps);
+ return rc;
+ }
+ }
+
+ *ppElem = pDmTndRTProps;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndDFPropsCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndDFPropsPtr_t pDmTndDFProps;
+ Ret_t rc = SML_ERR_OK;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndDFProps = (SmlDmTndDFPropsPtr_t)smlLibMalloc(sizeof(SmlDmTndDFProps_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndDFProps, 0, sizeof(SmlDmTndDFProps_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndDFProps;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndDFProps(pDmTndDFProps);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_AccessType:
+ rc = buildDmTndDFElementCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->accesstype);
+ break;
+ case TN_DMTND_DefaultValue:
+ rc = buildDmTndFormatCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->defaultvalue);
+ break;
+ case TN_DMTND_Description:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndDFProps->description);
+ break;
+ case TN_DMTND_DFFormat:
+ rc = buildDmTndFormatCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->dfformat);
+ break;
+ case TN_DMTND_Occurrence:
+ rc = buildDmTndDFElementCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->occurrence);
+ break;
+ case TN_DMTND_Scope:
+ rc = buildDmTndDFElementCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->scope);
+ break;
+ case TN_DMTND_DFTitle:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndDFProps->dftitle);
+ break;
+ case TN_DMTND_DFType:
+ rc = buildDmTndTypeCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->dftype);
+ break;
+ case TN_DMTND_CaseSense:
+ rc = buildDmTndDFElementCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->casesense);
+ break;
+ default:
+ KCDBG(">>>>> buildDmTndDFPropsCmd: Unkown token: %d <<<<<\n", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTndDFProps(pDmTndDFProps);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndDFProps(pDmTndDFProps);
+ return rc;
+ }
+ }
+
+ *ppElem = pDmTndDFProps;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDmTndNodeList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ SmlDmTndNodeListPtr_t pElem = NULL, pPrev = NULL;
+
+ pElem = (SmlDmTndNodeListPtr_t) *ppElem;
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pElem != NULL) {
+ pPrev = pElem;
+ pElem = pPrev->next;
+ }
+ if ((pElem = (SmlDmTndNodeListPtr_t)smlLibMalloc(sizeof(SmlDmTndNodeListPtr_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDmTndNodeListPtr_t));
+ pElem->next = NULL;
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pElem;
+ else /* nope we created a new list */
+ *ppElem = pElem;
+ pElem->node = NULL;
+ /* at this point pElem should point to an valid list element */
+ return buildDmTndNodeCmd(pDecoder, (VoidPtr_t)&pElem->node);
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndNodeCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndNodePtr_t pDmTndNode;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndNode = (SmlDmTndNodePtr_t)smlLibMalloc(sizeof(SmlDmTndNode_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndNode, 0, sizeof(SmlDmTndNode_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndNode;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndNode(pDmTndNode);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_NodeName:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndNode->nodename);
+ break;
+ case TN_DMTND_Path:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndNode->path);
+ break;
+ case TN_DMTND_RTProperties:
+ rc = buildDmTndRTPropsCmd(pDecoder, (VoidPtr_t)&pDmTndNode->rtprops);
+ break;
+ case TN_DMTND_DFProperties:
+ rc = buildDmTndDFPropsCmd(pDecoder, (VoidPtr_t)&pDmTndNode->dfprops);
+ break;
+ case TN_DMTND_Value:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndNode->value);
+ break;
+ case TN_DMTND_Node:
+ rc = buildDmTndNodeList(pDecoder, (VoidPtr_t)&pDmTndNode->nodelist);
+ break;
+ default:
+ KCDBG(">>>>> buildDmTndDFPropsCmd: Unkown token: %d <<<<<\n", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ if ( NULL != pDmTndNode->nodename && NULL != pDmTndNode->nodename->content )
+ {
+ KCDBG(">>>>> buildDmTndDFPropsCmd: Node %s corrupted <<<<<\n", (char *)pDmTndNode->nodename->content);
+ }
+ smlFreeDmTndNode(pDmTndNode);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndNode(pDmTndNode);
+ return rc;
+ }
+ }
+
+ *ppElem = pDmTndNode;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndPtr_t pDmTnd;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTnd = (SmlDmTndPtr_t)smlLibMalloc(sizeof(SmlDmTnd_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTnd, 0, sizeof(SmlDmTnd_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTnd;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTnd(pDmTnd);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_MgmtTree:
+ break;
+ case TN_DMTND_VerDTD:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTnd->verdtd);
+ break;
+ case TN_DMTND_Man:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTnd->man);
+ break;
+ case TN_DMTND_Mod:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTnd->mod);
+ break;
+ case TN_DMTND_Node:
+ rc = buildDmTndNodeList(pDecoder, (VoidPtr_t)&pDmTnd->nodelist);
+ break;
+ default:
+ KCDBG(">>>>> buildDmTndDFPropsCmd: Unkown token: %d <<<<<\n", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTnd(pDmTnd);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTnd(pDmTnd);
+ return rc;
+ }
+ }
+
+ *ppElem = pDmTnd;
+
+ return SML_ERR_OK;
+}
+
+/* see xltenc.c:XltEncBlock for description of parameters */
+Ret_t dmtndEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+ if ((reqOptFlag == REQUIRED) && (pContent == NULL))
+ {
+ KCDBG(">>>>> TNDS required tag: %d missed ! <<<<<\n", tagId);
+ return SML_ERR_XLT_MISSING_CONT;
+ }
+ //Check if pContent of a optional field is missing -> if yes we are done
+ else if (pContent == NULL)
+ return SML_ERR_OK;
+
+ Ret_t _err;
+ SmlDmTndNodeListPtr_t nodeList = NULL;
+
+ //Generate the commands -> see DTD
+ switch (tagId)
+ {
+ case TN_DMTND_MgmtTree:
+ if ((_err = xltGenerateTag(TN_DMTND_MgmtTree, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_VerDTD, REQUIRED, ((SmlDmTndPtr_t) pContent)->verdtd, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Man, OPTIONAL, ((SmlDmTndPtr_t) pContent)->man, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Mod, OPTIONAL, ((SmlDmTndPtr_t) pContent)->mod, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ nodeList = ((SmlDmTndPtr_t)pContent)->nodelist;
+ while (nodeList != NULL)
+ {
+ if ((_err = dmtndEncBlock(TN_DMTND_Node, OPTIONAL, nodeList->node, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ nodeList = nodeList->next;
+ };
+ if ((_err = xltGenerateTag(TN_DMTND_MgmtTree, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DMTND_Node:
+ if ((_err = xltGenerateTag(TN_DMTND_Node, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_NodeName, REQUIRED, ((SmlDmTndNodePtr_t) pContent)->nodename, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Path, OPTIONAL, ((SmlDmTndNodePtr_t) pContent)->path, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_RTProperties, OPTIONAL, ((SmlDmTndNodePtr_t) pContent)->rtprops, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Value, OPTIONAL, ((SmlDmTndNodePtr_t) pContent)->value, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ nodeList = ((SmlDmTndNodePtr_t)pContent)->nodelist;
+ while (nodeList != NULL)
+ {
+ if ((_err = dmtndEncBlock(TN_DMTND_Node, OPTIONAL, nodeList->node, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ nodeList = nodeList->next;
+ };
+ if ((_err = xltGenerateTag(TN_DMTND_Node, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DMTND_RTProperties:
+ if ((_err = xltGenerateTag(TN_DMTND_RTProperties, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_ACL, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->acl, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Format, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->format, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Name, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->name, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Size, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->size, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Title, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->title, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_TStamp, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->tstamp, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Type, REQUIRED, ((SmlDmTndRTPropsPtr_t) pContent)->type, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_VerNo, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->verno, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_DMTND_RTProperties, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DMTND_Format:
+ if ( NULL == pContent || NULL == ((SmlDmTndFormatPtr_t) pContent)->value || NULL == ((SmlDmTndFormatPtr_t) pContent)->value->content )
+ break;
+ if ((_err = xltGenerateTag(TN_DMTND_Format, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ( !strcmp("b64", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_b64, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("bin", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_bin, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("bool", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_bool, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("chr", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_chr, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("int", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_int, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("node", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_node, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("null", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_null, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("xml", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_xml, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("date", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_date, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("time", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_time, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("float", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_float, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else
+ {
+ KCDBG(">>>>> Unkown format: %s <<<<<\n", (char *)(((SmlDmTndFormatPtr_t)pContent)->value->content));
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if ((_err = xltGenerateTag(TN_DMTND_Format, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DMTND_Type:
+ if ((_err = xltGenerateTag(TN_DMTND_Type, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ( ((SmlDmTndTypePtr_t) pContent)->mime )
+ {
+ if ((_err = dmtndEncBlock(TN_DMTND_MIME, OPTIONAL, ((SmlDmTndTypePtr_t) pContent)->mime, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( ((SmlDmTndTypePtr_t) pContent)->ddfname )
+ {
+ if ((_err = dmtndEncBlock(TN_DMTND_DDFName, OPTIONAL, ((SmlDmTndTypePtr_t) pContent)->ddfname, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ if ((_err = xltGenerateTag(TN_DMTND_Type, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ default: // all leaf nodes (PCDATA#)
+ return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag);
+ } /* eof switch tagid */
+ return SML_ERR_OK;
+}
+
+#endif /* __USE_DMTND__ */
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdmtnd.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdmtnd.h
new file mode 100644
index 0000000..19fdac0
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltdmtnd.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*--------------------------------------------------------------------------------------------------
+
+ Header Name: smldmtnd.h
+
+ General Description: OMA DM TND specific type definitions
+
+--------------------------------------------------------------------------------------------------*/
+
+#ifndef _XLT_DMTND_H
+#define _XLT_DMTND_H
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xlttagtbl.h"
+#include "xltdec.h"
+#include "xltenc.h"
+
+Ret_t buildDmTndNodesCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDmTndCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildMgmtTreeCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t dmtndEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+
+#endif /* _XLT_DMTND_H */
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenc.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenc.c
new file mode 100644
index 0000000..439d88f
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenc.c
@@ -0,0 +1,1502 @@
+/*************************************************************************/
+/* module: Encoder source file */
+/* file: xltenc.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include <xltenc.h>
+#ifdef __SML_WBXML__
+ #include "xltencwbxml.h"
+#endif
+#ifdef __SML_XML__
+ #include "xltencxml.h"
+#endif
+#include "xlttags.h"
+#include "xltmetinf.h"
+#include "xltdevinf.h"
+#include "xltdmtnd.h"
+#include "smlmetinfdtd.h"
+#include "smldevinfdtd.h"
+#include <libstr.h>
+#include <libmem.h>
+#include <smldtd.h>
+#include <smldef.h>
+
+Ret_t getTNbyPE(SmlProtoElement_t, XltTagID_t*);
+Ret_t xltEncBlock(XltTagID_t, XltRO_t, const VoidPtr_t, SmlEncoding_t, BufferMgmtPtr_t, SmlPcdataExtension_t);
+Ret_t xltEncList(XltListType_t, XltRO_t, VoidPtr_t, SmlEncoding_t, BufferMgmtPtr_t, SmlPcdataExtension_t);
+#ifndef __SML_LITE__
+Ret_t xltBuildExtention(SmlPcdataExtension_t, XltRO_t, VoidPtr_t, SmlEncoding_t, BufferMgmtPtr_t);
+#endif
+
+typedef struct PEEnc_s
+{
+ XltTagID_t tagid;
+ SmlProtoElement_t type;
+} PEEnc_t, *PEEncPtr_t;
+
+PEEncPtr_t getPEEncTable(void);
+
+PEEncPtr_t getPEEncTable(void)
+{
+ PEEncPtr_t _tmpPEEncPtr;
+ PEEnc_t const PE[] =
+ {
+ { TN_ADD, SML_PE_ADD },
+ { TN_ALERT, SML_PE_ALERT },
+ { TN_ATOMIC, SML_PE_ATOMIC_START },
+ { TN_ATOMIC_END, SML_PE_ATOMIC_END },
+ { TN_COPY, SML_PE_COPY },
+ { TN_DELETE, SML_PE_DELETE },
+ { TN_EXEC, SML_PE_EXEC },
+ { TN_GET, SML_PE_GET },
+ { TN_MAP, SML_PE_MAP },
+ { TN_PUT, SML_PE_PUT },
+ { TN_RESULTS, SML_PE_RESULTS },
+ { TN_SEARCH, SML_PE_SEARCH },
+ { TN_SEQUENCE, SML_PE_SEQUENCE_START },
+ { TN_SEQUENCE_END, SML_PE_SEQUENCE_END },
+ { TN_STATUS, SML_PE_STATUS },
+ { TN_SYNC, SML_PE_SYNC_START },
+ { TN_SYNC_END, SML_PE_SYNC_END },
+ { TN_REPLACE, SML_PE_REPLACE },
+ { TN_UNDEF, SML_PE_UNDEF }
+ };
+ _tmpPEEncPtr = (PEEncPtr_t)smlLibMalloc(sizeof(PE));
+ if (_tmpPEEncPtr == NULL) return NULL;
+ smlLibMemcpy(_tmpPEEncPtr, &PE, sizeof(PE));
+ return _tmpPEEncPtr;
+}
+
+Ret_t getTNbyPE(SmlProtoElement_t pE, XltTagID_t *tagID)
+{
+ int i = 0;
+ PEEncPtr_t pPETbl = getPEEncTable();
+ if (pPETbl == NULL)
+ {
+ smlLibFree(pPETbl);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pPETbl+i)->type) != SML_PE_UNDEF)
+ {
+ if (((pPETbl+i)->type) == pE)
+ {
+ *tagID = (pPETbl+i)->tagid;
+ smlLibFree(pPETbl);
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ smlLibFree(pPETbl);
+ *tagID = TN_UNDEF;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+
+/**
+ * FUNCTION: smlXltEncInit
+ *
+ * Initializes an XML buffer; Creates XML code for the SyncHdr
+ * and appends it to the buffer.
+ * Returns 0 if operation was successful.
+ *
+ * PRE-Condition: no memory should be allocated for ppEncoder (should be NULL)
+ * pHeader has to contain a valid SyncHdr structure
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: enc, the encoding constant (SML_WBXML or SML_XML)
+ * pHeader, the SyncML header structure
+ * pBufEnd, pointer to the end of the buffer to write on
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ * ppEncoder, the encoder object
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncInit(SmlEncoding_t enc,
+ const SmlSyncHdrPtr_t pHeader,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ XltEncoderPtr_t *ppEncoder,
+ SmlVersion_t vers)
+{
+ // Return variable
+ Ret_t _err;
+
+ XltEncoderPtr_t _pEncoder;
+
+ //Structure containing buffer pointers, length and written bytes
+ BufferMgmtPtr_t _pBufMgr;
+
+#ifdef __SML_XML__
+ MemPtr_t _tmpStr;
+ MemPtr_t _xmlver = (MemPtr_t)XML_VERSION;
+ MemPtr_t _xmlenc = (MemPtr_t)XML_ENCODING;
+ MemByte_t _begpar = XML_BEGPAR;
+ MemByte_t _endpar = XML_ENDPAR;
+#endif
+
+#ifdef __SML_WBXML__
+ MemByte_t _stablen = 0x1D; //XLT_STABLEN;
+ MemByte_t _wbxmlver = XLT_WBXMLVER;
+ MemByte_t _charset = XLT_CHARSET;
+ MemByte_t _pubident1 = XLT_PUBIDENT1;
+ MemByte_t _pubident2 = XLT_PUBIDENT2;
+ char * _syncmldtd = "<error>";
+
+ switch( vers )
+ {
+ case SML_VERS_1_0:
+ {
+ _syncmldtd = "-//SYNCML//DTD SyncML 1.0//EN";
+ break;
+ }
+ case SML_VERS_1_1:
+ {
+ _syncmldtd = "-//SYNCML//DTD SyncML 1.1//EN";
+ break;
+ }
+ case SML_VERS_1_2:
+ {
+ _syncmldtd = "-//SYNCML//DTD SyncML 1.2//EN";
+ break;
+ }
+ default:
+ {
+ return SML_ERR_WRONG_PARAM;
+ }
+ }
+
+#endif
+
+ if ((_pEncoder = (XltEncoderPtr_t)smlLibMalloc(sizeof(XltEncoder_t))) == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ if ((_pBufMgr = (BufferMgmtPtr_t)smlLibMalloc(sizeof(BufferMgmt_t))) == NULL) {
+ smlLibFree(_pEncoder);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ //set the encoding
+ _pEncoder->enc = enc;
+
+ // %%% luz:2003-07-31: added version
+ _pEncoder->vers = vers;
+
+ _pEncoder->cur_ext = (SmlPcdataExtension_t)SML_EXT_UNDEFINED;
+ _pEncoder->last_ext = (SmlPcdataExtension_t)SML_EXT_UNDEFINED;
+ _pEncoder->end_tag_size = 0;
+ _pEncoder->space_evaluation = NULL;
+
+
+ _pBufMgr->smlXltBufferP = *ppBufPos;
+ _pBufMgr->smlXltBufferLen = pBufEnd - *ppBufPos;
+ _pBufMgr->smlXltStoreBufP = _pBufMgr->smlXltBufferP;
+ _pBufMgr->smlXltWrittenBytes = 0;
+ _pBufMgr->smlCurExt = _pEncoder->cur_ext;
+ _pBufMgr->smlLastExt = _pEncoder->last_ext;
+ _pBufMgr->smlActiveExt = SML_EXT_UNDEFINED;
+ _pBufMgr->switchExtTag = TN_UNDEF;
+ _pBufMgr->spaceEvaluation = 0;
+ _pBufMgr->vers = vers;
+ _pBufMgr->endTagSize = 0;
+
+ switch (enc)
+ {
+
+#ifdef __SML_WBXML__
+ case SML_WBXML:
+ {
+
+ // Set the WBXML Header Values
+ // WBXML Version
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_wbxmlver), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ // Public Idetifier - default unknown
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_pubident1), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_pubident2), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ // Character set - not yet implemented
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_charset), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ // Sting table length - not yet implemented
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_stablen), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ // FPI - %%% luz:2003-07-31: not constant any more, varies according to SyncML version
+ if ((_err = xltAddToBuffer((MemPtr_t) (_syncmldtd) , smlLibStrlen((String_t)_syncmldtd), _pBufMgr)) != SML_ERR_OK) break;
+
+ break;
+ }
+#endif
+
+#ifdef __SML_XML__
+ case SML_XML:
+ {
+
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = (MemPtr_t)"?xml version=\"";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = _xmlver;
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = (MemPtr_t)"\" encoding=\"";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = _xmlenc;
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = (MemPtr_t)"\"?";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, _pBufMgr)) != SML_ERR_OK) break;
+
+ break;
+ }
+#endif
+
+ default:
+ {
+ _err = SML_ERR_XLT_ENC_UNK;
+ }
+ }
+ if (_err != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ smlLibFree(_pEncoder);
+ return _err;
+ }
+
+ // SyncML Tag
+ if ((_err = xltGenerateTag(TN_SYNCML, TT_BEG, enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ smlLibFree(_pEncoder);
+ return _err;
+ }
+
+ // Generate SmlSyncHdr
+
+ if ((_err = xltEncBlock(TN_SYNCHDR, REQUIRED, pHeader, enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ smlLibFree(_pEncoder);
+ return _err;
+ }
+
+ // SyncBody Tag
+ if ((_err = xltGenerateTag(TN_SYNCBODY, TT_BEG, enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ smlLibFree(_pEncoder);
+ return _err;
+ }
+
+ _pEncoder->cur_ext = _pBufMgr->smlCurExt;
+ _pEncoder->last_ext = _pBufMgr->smlLastExt;
+ _pEncoder->end_tag_size = _pBufMgr->endTagSize;
+
+ *ppBufPos = _pBufMgr->smlXltBufferP;
+
+ smlLibFree(_pBufMgr);
+
+ _pEncoder->final = 0;
+
+ *ppEncoder = (XltEncoderPtr_t)_pEncoder;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: smlXltEncAppend
+ *
+ * Generates (WB)XML code and appends it to the XML buffer.
+ *
+ * PRE-Condition: pEncoder holds the initialized encoder structure.
+ * the initialization takes place in the xltEncAppend function
+ * pContent has to contain a valid content structure structure
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: pEncoder, the encoder object
+ * pe, the protocol element (PE_ADD, ...)
+ * pBufEnd, pointer to the end of the buffer to write on
+ * pContent, the content to append to the SyncML document
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncAppend(const XltEncoderPtr_t pEncoder,
+ SmlProtoElement_t pe,
+ const MemPtr_t pBufEnd,
+ const VoidPtr_t pContent,
+ MemPtr_t *ppBufPos)
+{
+ // Return variable
+ Ret_t _err;
+
+ XltTagID_t tagID = TN_UNDEF;
+
+ // encoding type
+ SmlEncoding_t _enc;
+
+ //Structure containing buffer pointers, length and written bytes
+ BufferMgmtPtr_t _pBufMgr;
+
+ if ((_pBufMgr = (BufferMgmtPtr_t)smlLibMalloc(sizeof(BufferMgmt_t))) == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(_pBufMgr, 0, sizeof(BufferMgmt_t));
+
+ //get the encoding type
+ _enc = pEncoder->enc;
+
+ _pBufMgr->vers = pEncoder->vers; // %%% luz:2003-07-31: pass SyncML version to bufmgr
+ _pBufMgr->smlXltBufferP = *ppBufPos;
+ _pBufMgr->smlXltBufferLen = pBufEnd - *ppBufPos;
+ _pBufMgr->smlXltStoreBufP = _pBufMgr->smlXltBufferP;
+ _pBufMgr->smlXltWrittenBytes = 0;
+ _pBufMgr->smlActiveExt = SML_EXT_UNDEFINED;
+ _pBufMgr->switchExtTag = TN_UNDEF;
+ _pBufMgr->spaceEvaluation = ((pEncoder->space_evaluation == NULL) ? 0 : 1);
+ // %%% luz 2002-09-03: evaluation may not mess with encoder state
+ if ( _pBufMgr->spaceEvaluation) {
+ // spaceEval state
+ _pBufMgr->smlCurExt = pEncoder->space_evaluation->cur_ext;
+ _pBufMgr->smlLastExt = pEncoder->space_evaluation->last_ext;
+ }
+ else {
+ // normal encoder state
+ _pBufMgr->smlCurExt = pEncoder->cur_ext;
+ _pBufMgr->smlLastExt = pEncoder->last_ext;
+ }
+
+ _pBufMgr->endTagSize =0;
+
+ _err = getTNbyPE(pe, &tagID);
+
+ _err = xltEncBlock(tagID, REQUIRED, pContent, _enc, _pBufMgr, SML_EXT_UNDEFINED);
+ if (_err != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ return _err;
+ }
+
+
+ if (pEncoder->space_evaluation != NULL) {
+ // Only calculating size
+ pEncoder->space_evaluation->written_bytes += _pBufMgr->smlXltWrittenBytes;
+ pEncoder->space_evaluation->end_tag_size += _pBufMgr->endTagSize;
+ // save it only into evaluation state
+ pEncoder->space_evaluation->cur_ext = _pBufMgr->smlCurExt;
+ pEncoder->space_evaluation->last_ext = _pBufMgr->smlLastExt;
+ } else {
+ // really generating data
+ pEncoder->end_tag_size += _pBufMgr->endTagSize;
+ // save it into encoder state
+ pEncoder->cur_ext = _pBufMgr->smlCurExt;
+ pEncoder->last_ext = _pBufMgr->smlLastExt;
+ }
+
+ *ppBufPos = _pBufMgr->smlXltBufferP;
+
+ smlLibFree(_pBufMgr);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: smlXltEncTerminate
+ *
+ * Filnalizes the (WB)XML document and returns the size of written bytes to
+ * the workspace module
+ *
+ * PRE-Condition: pEncoder holds the initialized encoder structure.
+ * the initialization takes place in the xltEncAppend function
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: pEncoder, the encoder object
+ * pBufEnd, pointer to the end of the buffer to write on
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncTerminate(const XltEncoderPtr_t pEncoder,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos)
+{
+ // Return variable
+ Ret_t _err;
+
+ // encoding type
+ SmlEncoding_t _enc;
+
+ //Structure containing buffer pointers, length and written bytes
+ BufferMgmtPtr_t _pBufMgr;
+
+ //get the encoding type
+ _enc = pEncoder->enc;
+
+ //Initialize buffer variables
+ if ((_pBufMgr = smlLibMalloc(sizeof(BufferMgmt_t))) == NULL) {
+ smlLibFree(pEncoder);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ _pBufMgr->vers = pEncoder->vers; // %%% luz:2003-07-31: pass SyncML version to bufmgr
+ _pBufMgr->smlXltWrittenBytes = 0;
+ _pBufMgr->smlXltBufferP = *ppBufPos;
+ _pBufMgr->smlXltStoreBufP = _pBufMgr->smlXltBufferP;
+ _pBufMgr->smlXltBufferLen = pBufEnd - *ppBufPos;
+ _pBufMgr->smlCurExt = pEncoder->cur_ext;
+ _pBufMgr->smlLastExt = pEncoder->last_ext;
+ _pBufMgr->smlActiveExt = pEncoder->cur_ext;
+ _pBufMgr->switchExtTag = TN_UNDEF;
+ _pBufMgr->spaceEvaluation = ((pEncoder->space_evaluation == NULL) ? 0 : 1);
+ _pBufMgr->endTagSize =0;
+
+ if (pEncoder->final == 1)
+ {
+ // Final Flag
+ if ((_err = xltGenerateTag(TN_FINAL, TT_ALL, _enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ xltEncReset(pEncoder);
+ return _err;
+ }
+ }
+
+ // SyncBody End Tag
+ if ((_err = xltGenerateTag(TN_SYNCBODY, TT_END, _enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ xltEncReset(pEncoder);
+ return _err;
+ }
+
+ // SyncML End Tag
+ if ((_err = xltGenerateTag(TN_SYNCML, TT_END, _enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ xltEncReset(pEncoder);
+ return _err;
+ }
+
+ pEncoder->cur_ext = _pBufMgr->smlCurExt;
+ pEncoder->last_ext = _pBufMgr->smlLastExt;
+
+ *ppBufPos = _pBufMgr->smlXltBufferP;
+
+ smlLibFree(_pBufMgr);
+
+ xltEncReset(pEncoder);
+
+ return SML_ERR_OK;
+}
+
+Ret_t xltEncReset(XltEncoderPtr_t pEncoder)
+{
+ if ((pEncoder) && (pEncoder->space_evaluation)) {
+ smlLibFree(pEncoder->space_evaluation);
+ pEncoder->space_evaluation = NULL;
+ }
+ smlLibFree(pEncoder);
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlXltStartEvaluation
+ *
+ * Starts an evaluation run which prevents further API-Calls to write tags -
+ * just the tag-sizes are calculated. Must be sopped via smlEndEvaluation
+ *
+ * IN: XltEncoderPtr_t
+ * the encoder object
+ *
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t xltStartEvaluation(XltEncoderPtr_t pEncoder)
+{
+ XltSpaceEvaluationPtr_t _pSpaceEvaluation;
+
+ if (pEncoder->space_evaluation != NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ if ((_pSpaceEvaluation = (XltSpaceEvaluationPtr_t)smlLibMalloc(sizeof(XltSpaceEvaluation_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(_pSpaceEvaluation, 0, sizeof(XltSpaceEvaluation_t));
+ // %%% luz 2002-09-03: init encoder state shadow copies for evaluation from real encoder
+ _pSpaceEvaluation->cur_ext = pEncoder->cur_ext;
+ _pSpaceEvaluation->last_ext = pEncoder->last_ext;
+
+ pEncoder->space_evaluation = _pSpaceEvaluation;
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlXltEndEvaluation
+ *
+ * Stops an evaluation run which prevents further API-Calls to write tags -
+ * the remaining free buffer size after all Tags are written is returned
+ *
+ * IN: XltEncoderPtr_t
+ * the encoder object
+ *
+ * IN/OUT: MemSize_t
+ * Size of free buffer for data after all tags are written
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t xltEndEvaluation(InstanceID_t id, XltEncoderPtr_t pEncoder, MemSize_t *freemem)
+{
+
+ MemSize_t _free;
+ XltSpaceEvaluationPtr_t _evaluation;
+
+ _evaluation = pEncoder->space_evaluation;
+
+ if (_evaluation == NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ _free = smlGetFreeBuffer(id);
+ _free -= _evaluation->written_bytes;
+ _free -= _evaluation->end_tag_size;
+ _free -= pEncoder->end_tag_size;
+
+ *freemem = _free;
+
+ smlLibFree(_evaluation);
+ pEncoder->space_evaluation = NULL;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: xltEncBlock
+ *
+ * Generates a (WB)XML Block for a given tag ID and a given content
+ *
+ * PRE-Condition: pContent holds a valid content structure
+ * tagId contains a valid SyncML tag ID
+ *
+ * POST-Condition: the (WB)XML buffer in the pBufMgr structure contains the
+ * encoded (WB)XML block
+ *
+ * IN: tagId, the ID for the tag to generate (TN_ADD, ...)
+ * reqOptFlag, flag if the block is required or optional
+ * pContent, the content structure of the block
+ * enc, the encoding constant (SML_WBXML or SML_XML)
+ * attFlag, indicates if the encoded tag contain Attributes in namespace extensions
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xltEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+
+ //Return variable
+ Ret_t _err;
+
+
+ //Check if pContent of a required field is missing
+ if ((reqOptFlag == REQUIRED) && (pContent == NULL)) {
+ switch ((int)tagId) {
+ case TN_ATOMIC_END:
+ case TN_SYNC_END:
+ case TN_SEQUENCE_END:
+ break;
+ default:
+ return SML_ERR_XLT_MISSING_CONT;
+ }
+ }
+ //Check if pContent of a optional field is missing
+ else if ((pContent == NULL) && (tagId != TN_SYNC_END) && (tagId != TN_ATOMIC_END) && (tagId != TN_SEQUENCE_END))
+ return SML_ERR_OK;
+
+ //Generate the commands -> see DTD
+ switch ((int)tagId){
+ case TN_SYNCHDR:
+ // SyncHdr Begin Tag
+ if ((_err = xltGenerateTag(TN_SYNCHDR, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Version
+ if ((_err = xltEncBlock(TN_VERSION, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->version, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Proto
+ if ((_err = xltEncBlock(TN_PROTO, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->proto, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SessionID
+ if ((_err = xltEncBlock(TN_SESSIONID, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->sessionID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // MsgID
+ if ((_err = xltEncBlock(TN_MSGID, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->msgID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target
+ if ((_err = xltEncBlock(TN_TARGET, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source
+ if ((_err = xltEncBlock(TN_SOURCE, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // RespURI?
+ if ((_err = xltEncBlock(TN_RESPURI, OPTIONAL, ((SmlSyncHdrPtr_t) pContent)->respURI, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlSyncHdrPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlSyncHdrPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlSyncHdrPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SyncHdr End Tag
+ if ((_err = xltGenerateTag(TN_SYNCHDR, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_CRED:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_CRED, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlCredPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Data
+ if ((_err = xltEncBlock(TN_DATA, REQUIRED, ((SmlCredPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_CRED, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_SOURCE:
+ case TN_TARGET:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // LocURI
+ if ((_err = xltEncBlock(TN_LOCURI, REQUIRED, ((SmlSourcePtr_t) pContent)->locURI, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // LocName?
+ if ((_err = xltEncBlock(TN_LOCNAME, OPTIONAL, ((SmlSourcePtr_t) pContent)->locName, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_ITEM:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_ITEM, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target?
+ if ((_err = xltEncBlock(TN_TARGET, OPTIONAL, ((SmlItemPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source?
+ if ((_err = xltEncBlock(TN_SOURCE, OPTIONAL, ((SmlItemPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlItemPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Data?
+ if ((_err = xltEncBlock(TN_DATA, OPTIONAL, ((SmlItemPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // MoreData?
+ if ((_err = xltEncBlock(TN_MOREDATA, OPTIONAL, &(((SmlItemPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_ITEM, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#if (defined ADD_SEND || defined COPY_SEND)
+ case TN_ADD:
+ case TN_COPY:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlGenericCmdPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlGenericCmdPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlGenericCmdPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlGenericCmdPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlGenericCmdPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#endif
+ case TN_ALERT:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_ALERT, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlAlertPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlAlertPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlAlertPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Data?
+ if ((_err = xltEncBlock(TN_DATA, OPTIONAL, ((SmlAlertPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Correlator?
+ if ((_err = xltEncBlock(TN_CORRELATOR, OPTIONAL, ((SmlAlertPtr_t) pContent)->correlator, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item*
+ if ((_err = xltEncList(ITEM_LIST, OPTIONAL, ((SmlAlertPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_ALERT, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#if (defined ATOMIC_SEND || defined SEQUENCE_SEND)
+ case TN_ATOMIC:
+ case TN_SEQUENCE:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlAtomicPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlAtomicPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlAtomicPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ //End tag in TN_ATOMIC_END
+
+ break;
+ case TN_ATOMIC_END:
+ // End tag
+ if ((_err = xltGenerateTag(TN_ATOMIC, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ break;
+ case TN_SEQUENCE_END:
+ // End tag
+ if ((_err = xltGenerateTag(TN_SEQUENCE, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ break;
+#endif
+ case TN_DELETE:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_DELETE, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlDeletePtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlDeletePtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Archive?
+ if ((_err = xltEncBlock(TN_ARCHIVE, OPTIONAL, &(((SmlDeletePtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SftDel?
+ if ((_err = xltEncBlock(TN_SFTDEL, OPTIONAL, &(((SmlDeletePtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlDeletePtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlDeletePtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlDeletePtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_DELETE, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#ifdef EXEC_SEND
+ case TN_EXEC:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_EXEC, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlExecPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlExecPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlExecPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlExecPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Correlator?
+ if ((_err = xltEncBlock(TN_CORRELATOR, OPTIONAL, ((SmlExecPtr_t) pContent)->correlator, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item
+ if ((_err = xltEncBlock(TN_ITEM, REQUIRED, ((SmlExecPtr_t) pContent)->item, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_EXEC, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#endif
+ case TN_GET:
+ case TN_PUT:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlGetPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlGetPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Lang?
+ if ((_err = xltEncBlock(TN_LANG, OPTIONAL, ((SmlGetPtr_t) pContent)->lang, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlGetPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlGetPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlGetPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_MAP:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_MAP, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlMapPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target
+ if ((_err = xltEncBlock(TN_TARGET, REQUIRED, ((SmlMapPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source
+ if ((_err = xltEncBlock(TN_SOURCE, REQUIRED, ((SmlMapPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlMapPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlMapPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Mapitemlist
+ if ((_err = xltEncList(MAPITEM_LIST, REQUIRED, ((SmlMapPtr_t) pContent)->mapItemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_MAP, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_MAPITEM:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_MAPITEM, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target
+ if ((_err = xltEncBlock(TN_TARGET, REQUIRED, ((SmlMapItemPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source
+ if ((_err = xltEncBlock(TN_SOURCE, REQUIRED, ((SmlMapItemPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_MAPITEM, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_RESULTS:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_RESULTS, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlResultsPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // MsgRef?
+ if ((_err = xltEncBlock(TN_MSGREF, OPTIONAL, ((SmlResultsPtr_t) pContent)->msgRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdRef
+ if ((_err = xltEncBlock(TN_CMDREF, REQUIRED, ((SmlResultsPtr_t) pContent)->cmdRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlResultsPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // TargetRef?
+ if ((_err = xltEncBlock(TN_TARGETREF, OPTIONAL, ((SmlResultsPtr_t) pContent)->targetRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SourceRef?
+ if ((_err = xltEncBlock(TN_SOURCEREF, OPTIONAL, ((SmlResultsPtr_t) pContent)->sourceRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlResultsPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_RESULTS, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_CHAL:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_CHAL, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta
+ if ((_err = xltEncBlock(TN_META, REQUIRED, ((SmlChalPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_CHAL, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#ifdef SEARCH_SEND
+ case TN_SEARCH:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_SEARCH, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlSearchPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlSearchPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResults?
+ if ((_err = xltEncBlock(TN_NORESULTS, OPTIONAL, &((SmlSearchPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlSearchPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target?
+ if ((_err = xltEncBlock(TN_TARGET, OPTIONAL, ((SmlSearchPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source List
+ if ((_err = xltEncList(SOURCE_LIST, REQUIRED, ((SmlSearchPtr_t) pContent)->sourceList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Lang?
+ if ((_err = xltEncBlock(TN_LANG, OPTIONAL, ((SmlSearchPtr_t) pContent)->lang, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta
+ if ((_err = xltEncBlock(TN_META, REQUIRED, ((SmlSearchPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Dsta
+ if ((_err = xltEncBlock(TN_DATA, REQUIRED, ((SmlSearchPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_SEARCH, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#endif
+ case TN_STATUS:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_STATUS, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlStatusPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // MsgRef?
+ if ((_err = xltEncBlock(TN_MSGREF, REQUIRED, ((SmlStatusPtr_t) pContent)->msgRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdRef
+ if ((_err = xltEncBlock(TN_CMDREF, REQUIRED, ((SmlStatusPtr_t) pContent)->cmdRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cmd
+ if ((_err = xltEncBlock(TN_CMD, REQUIRED, ((SmlStatusPtr_t) pContent)->cmd, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // TargetRefList?
+ if ((_err = xltEncList(TARGETREF_LIST, OPTIONAL, ((SmlStatusPtr_t) pContent)->targetRefList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SourceRefList?
+ if ((_err = xltEncList(SOURCEREF_LIST, OPTIONAL, ((SmlStatusPtr_t) pContent)->sourceRefList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlStatusPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Chal?
+ if ((_err = xltEncBlock(TN_CHAL, OPTIONAL, ((SmlStatusPtr_t) pContent)->chal, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Data
+ if ((_err = xltEncBlock(TN_DATA, REQUIRED, ((SmlStatusPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item*
+ if ((_err = xltEncList(ITEM_LIST, OPTIONAL, ((SmlStatusPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_STATUS, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_SYNC:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_SYNC, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlSyncPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlSyncPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlSyncPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target?
+ if ((_err = xltEncBlock(TN_TARGET, OPTIONAL, ((SmlSyncPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source?
+ if ((_err = xltEncBlock(TN_SOURCE, OPTIONAL, ((SmlSyncPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlSyncPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NumberOfChanges?
+ if ((_err = xltEncBlock(TN_NUMBEROFCHANGES, OPTIONAL, ((SmlSyncPtr_t) pContent)->noc, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag in TN_SYNC_END
+
+ break;
+ case TN_SYNC_END:
+ //End tag
+ if ((_err = xltGenerateTag(TN_SYNC, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_REPLACE:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlGenericCmdPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlGenericCmdPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlGenericCmdPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlGenericCmdPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlGenericCmdPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_ARCHIVE:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t*)pContent)) & (SmlArchive_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_SFTDEL:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlSftDel_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ break;
+ case TN_MOREDATA:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlMoreData_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_NORESULTS:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlNoResults_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_NORESP:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlNoResp_f)){
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_FINAL:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlFinal_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ default: // all leaf nodes (PCDATA#)
+ return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag);
+ }
+ }
+ return SML_ERR_OK;
+}
+
+Ret_t xltEncPcdata(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag) {
+ //Return variable
+ Ret_t _err;
+
+ //generate PCDATA begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+
+ //write the pContent to the buffer according the encoding type
+ switch ((int)enc) {
+#ifdef __SML_WBXML__
+ case SML_WBXML:
+ switch (((SmlPcdataPtr_t)pContent)->contentType) {
+ case SML_PCDATA_STRING:
+ if ((_err = wbxmlWriteTypeToBuffer(((SmlPcdataPtr_t)pContent)->content, STR_I, ((SmlPcdataPtr_t)pContent)->length, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+ // Note: SML_PCDATA_CDATA case added by luz to allow direct translation from XML to WBXML
+ case SML_PCDATA_CDATA:
+ case SML_PCDATA_OPAQUE:
+ if ((_err = wbxmlWriteTypeToBuffer(((SmlPcdataPtr_t)pContent)->content, OPAQUE, ((SmlPcdataPtr_t)pContent)->length, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+#ifdef __USE_EXTENSIONS__
+ case SML_PCDATA_EXTENSION:
+ if ((_err = xltBuildExtention(((SmlPcdataPtr_t)pContent)->extension, reqOptFlag, ((SmlPcdataPtr_t)pContent)->content, enc, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+#endif
+ default:
+ // 2003-11-24: Tomy to deal with pcdata empty extensions (for example <Meta></Meta> which is valid)
+ // refer to xltdec.c to see that empty extensions result in SmlPcdataPtr_t with all fields (data) set to 0
+ if (((SmlPcdataPtr_t)pContent)->contentType != SML_PCDATA_UNDEFINED ||
+ ((SmlPcdataPtr_t)pContent)->extension != SML_EXT_UNDEFINED ||
+ ((SmlPcdataPtr_t)pContent)->length != 0 ||
+ ((SmlPcdataPtr_t)pContent)->content != NULL)
+ return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ // return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ // end modified by Tomy
+ }; // eof switch(contenttype)
+ break;
+#endif // eof WBXML
+
+#ifdef __SML_XML__
+ case SML_XML:
+ switch (((SmlPcdataPtr_t)pContent)->contentType) {
+ // Note: SML_PCDATA_OPAQUE case added by luz to allow direct translation from WBXML to XML
+ #ifdef PCDATA_OPAQUE_AS_CDATA
+ case SML_PCDATA_OPAQUE:
+ #endif
+ case SML_PCDATA_CDATA: {
+ MemPtr_t _tmpStr;
+ _tmpStr = (MemPtr_t) "<![CDATA[";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), pBufMgr)) != SML_ERR_OK) return _err;
+ if ((_err = xltAddToBuffer(((SmlPcdataPtr_t)pContent)->content, ((SmlPcdataPtr_t)pContent)->length, pBufMgr)) != SML_ERR_OK) return _err;
+ _tmpStr = (MemPtr_t) "]]>";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+ }
+ // Note: SyncFest #5 shows that <![CDATA[ is not correctly parsed by the RTK
+ // so we don't use it and risk the danger of failing on payload which has
+ // XML in it.
+ #ifndef PCDATA_OPAQUE_AS_CDATA
+ case SML_PCDATA_OPAQUE:
+ #endif
+ case SML_PCDATA_STRING:
+ if ((_err = xltAddToBuffer(((SmlPcdataPtr_t)pContent)->content, ((SmlPcdataPtr_t)pContent)->length, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+#ifdef __USE_EXTENSIONS__
+ case SML_PCDATA_EXTENSION:
+ if ((_err = xltBuildExtention(((SmlPcdataPtr_t)pContent)->extension, reqOptFlag, ((SmlPcdataPtr_t)pContent)->content, enc, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+#endif
+ default:
+ // 2003-11-24: Tomy to deal with pcdata empty extensions (for example <Meta></Meta> which is valid)
+ // refer to xltdec.c to see that empty extensions result in SmlPcdataPtr_t with all fields (data) set to 0
+ if (((SmlPcdataPtr_t)pContent)->contentType != SML_PCDATA_UNDEFINED ||
+ ((SmlPcdataPtr_t)pContent)->extension != SML_EXT_UNDEFINED ||
+ ((SmlPcdataPtr_t)pContent)->length != 0 ||
+ ((SmlPcdataPtr_t)pContent)->content != NULL)
+ return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ // return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ // end modified by Tomy
+ }
+ break;
+#endif // eof XML
+
+ default:
+ return SML_ERR_XLT_ENC_UNK;
+ } // eof switch(enc)
+
+ //generate PCDATA END tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xltEncList
+ *
+ * Generates a list element which is not directly related to a tag
+ *
+ * PRE-Condition: pList holds a valid list structure
+ * listId contains a valid SyncML list ID
+ *
+ * POST-Condition: the (WB)XML buffer in the pBufMgr structure contains the
+ * encoded (WB)XML list
+ *
+ * IN: listId, the ID of the list to generate (e.g. TARGET_LIST, ...)
+ * pList, reference to the list to process
+ * enc, the encoding constant (SML_WBXML or SML_XML)
+ * attFlag, indicates if the encoded tag contain Attributes in namespace extensions
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xltEncList(XltListType_t listId, XltRO_t reqOptFlag, VoidPtr_t pList, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+ //Return variable
+ Ret_t _err;
+
+ //check if list is required or not
+ if ((reqOptFlag == REQUIRED) && (pList == NULL))
+ return SML_ERR_XLT_MISSING_CONT;
+ else if (pList == NULL)
+ return SML_ERR_OK;
+
+ //encode the different list types
+ switch ((int)listId)
+ {
+ case ITEM_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_ITEM, OPTIONAL, ((SmlItemListPtr_t)pList)->item, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlItemListPtr_t)pList)->next;
+ } while ((SmlItemListPtr_t)pList != NULL);
+
+ break;
+ }
+ case SOURCE_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_SOURCE, OPTIONAL, ((SmlSourceListPtr_t)pList)->source, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlSourceListPtr_t)pList)->next;
+ } while ((SmlSourceListPtr_t)pList != NULL);
+
+ break;
+ }
+ case TARGETREF_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_TARGETREF, OPTIONAL, ((SmlTargetRefListPtr_t)pList)->targetRef, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlTargetRefListPtr_t)pList)->next;
+ } while ((SmlTargetRefListPtr_t)pList != NULL);
+
+ break;
+ }
+ case SOURCEREF_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_SOURCEREF, OPTIONAL, ((SmlSourceRefListPtr_t)pList)->sourceRef, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlSourceRefListPtr_t)pList)->next;
+ } while ((SmlSourceRefListPtr_t)pList != NULL);
+
+ break;
+ }
+ case MAPITEM_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_MAPITEM, OPTIONAL, ((SmlMapItemListPtr_t)pList)->mapItem, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlMapItemListPtr_t)pList)->next;
+ } while ((SmlMapItemListPtr_t)pList != NULL);
+
+ break;
+ }
+ default:
+ return SML_ERR_XLT_INVAL_LIST_TYPE;
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xltGenerateTag
+ *
+ * Generates a (WB)XML tag
+ *
+ * PRE-Condition: valis parameters
+ *
+ * POST-Condition: the buffer contains a new tag
+ *
+ * IN: tagId, the tag ID
+ * TagType, the tag type (begin tag, end tag, ...)
+ * enc, the encoding constant (SML_WBXML or SML_XML)
+ * attFlag, indicates if the encoded tag contain Attributes in namespace extensions
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xltGenerateTag(XltTagID_t tagId, XltTagType_t TagType, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+
+ Ret_t _err;
+#ifdef __SML_WBXML__
+ MemByte_t _switchpage = XLT_SWITCHPAGE;
+#endif
+
+ switch ((int)enc) {
+#ifdef __SML_WBXML__
+ case SML_WBXML:
+ /* in WBXML codepage switches are done for starting tags only */
+ if (TagType != TT_END) {
+ //codepage switching with wbxml instead of namespace
+ if (getCodePage(attFlag) != getCodePage(pBufMgr->smlCurExt)) {
+ MemByte_t _newcp = getCodePage(attFlag);
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_switchpage), TAG, 1, pBufMgr)) != SML_ERR_OK) return _err;
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_newcp), TAG, 1, pBufMgr)) != SML_ERR_OK) return _err;
+ }
+
+ if (attFlag != pBufMgr->smlCurExt) {
+ pBufMgr->switchExtTag = tagId;
+ pBufMgr->smlLastExt = pBufMgr->smlCurExt;
+ pBufMgr->smlCurExt = attFlag;
+ }
+ } // for TagType
+ return wbxmlGenerateTag(tagId, TagType, pBufMgr);
+#endif
+#ifdef __SML_XML__
+ case SML_XML:
+
+ if (attFlag != pBufMgr->smlCurExt) {
+ pBufMgr->switchExtTag = tagId;
+ pBufMgr->smlLastExt = pBufMgr->smlCurExt;
+ pBufMgr->smlCurExt = attFlag;
+ }
+ return xmlGenerateTag(tagId, TagType, pBufMgr, attFlag);
+#endif
+ default:
+ return SML_ERR_XLT_ENC_UNK;
+ }
+
+ //return SML_ERR_XLT_ENC_UNK;NOT NEEDED
+}
+
+#ifdef __USE_EXTENSIONS__
+/* Entrypoint for SubDTD's. If we reached this point we already know
+ * a) we have data fora sub-DTD to encode and
+ * b) we know which sub-DTD should be encoded.
+ * So just call the appropriate sub-DTD encoder and thats it.
+ */
+Ret_t xltBuildExtention(SmlPcdataExtension_t extId, XltRO_t reqOptFlag, VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr) {
+
+ switch (extId) {
+#ifdef __USE_METINF__
+ case SML_EXT_METINF:
+ /* a metaInf DTD always starts with this token */
+ return metinfEncBlock(TN_METINF_METINF,reqOptFlag,pContent,enc,pBufMgr,SML_EXT_METINF);
+ break;
+#endif
+#ifdef __USE_DEVINF__
+ case SML_EXT_DEVINF:
+ /* a deviceInf DTD always starts with this token */
+ /* we have to choose, wether we have to encode the DevInf as XML or WBXML */
+ /* in the latter case, we need a special treatment of this sub-dtd, as we have */
+ /* to put it into a SML_PCDATA_OPAQUE field ... */
+ if (enc == SML_XML)
+ return devinfEncBlock(TN_DEVINF_DEVINF,reqOptFlag,pContent,enc,pBufMgr,SML_EXT_DEVINF);
+ else
+ return subdtdEncWBXML(TN_DEVINF_DEVINF,reqOptFlag,pContent,SML_WBXML,pBufMgr,SML_EXT_DEVINF);
+ break;
+#endif
+#ifdef __USE_DMTND__
+ case SML_EXT_DMTND:
+ /* a DMTND DTD always starts with this token */
+ return dmtndEncBlock(TN_DMTND_MgmtTree, reqOptFlag,pContent,enc,pBufMgr,SML_EXT_DMTND);
+ break;
+#endif
+ /* oops - we don not know about that extension -> bail out */
+ default:
+ return SML_ERR_XLT_INVAL_EXT;
+ }
+ //return SML_ERR_OK;CAN NOT BE REACHED
+}
+
+
+/* Sub DTD's need a special treatment when used together with WBXML.
+ * We need to eoncode them as a complete WBXML message including headers and stuff
+ * and store the result within an SML_PCDATA_OPAQUE datafield.
+ * To archieve this we create a new encoder, encode the message and finally
+ * copy the result into the allready existing encoder.
+ */
+#ifdef __SML_WBXML__
+Ret_t subdtdEncWBXML(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+ #ifdef __USE_DEVINF__
+ Ret_t _err = SML_ERR_OK;
+ #endif
+
+ Short_t SubBufSize = 12000; // for starters we use 12kB for each sub DTD to encode in WBXML
+ BufferMgmtPtr_t pSubBufMgr = NULL;
+ char *FPIstring = "<error>";
+ Short_t FPIsize = 0;
+
+ if( !pBufMgr ) return SML_ERR_WRONG_PARAM;
+
+
+ switch( pBufMgr->vers )
+ {
+ case SML_VERS_1_0:
+ {
+ FPIstring = "-//SYNCML//DTD DevInf 1.0//EN";
+ break;
+ }
+ case SML_VERS_1_1:
+ case SML_VERS_1_2:
+ {
+ FPIstring = "-//SYNCML//DTD DevInf 1.1//EN";
+ break;
+ }
+ default:
+ {
+ return SML_ERR_WRONG_PARAM;
+ }
+ }
+
+ FPIsize = smlLibStrlen(FPIstring);
+
+ // first create a sub buffer
+ pSubBufMgr = (BufferMgmtPtr_t)smlLibMalloc(sizeof(BufferMgmt_t));
+ if (pSubBufMgr == NULL) {
+ if (enc && pContent && reqOptFlag && tagId) {
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;}
+
+ smlLibMemset(pSubBufMgr, 0,sizeof(BufferMgmt_t));
+ pSubBufMgr->smlXltBufferLen = SubBufSize;
+ pSubBufMgr->smlXltBufferP = (MemPtr_t)smlLibMalloc(SubBufSize);
+ if (pSubBufMgr->smlXltBufferP == NULL) {
+ smlLibFree(pSubBufMgr);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ smlLibMemset(pSubBufMgr->smlXltBufferP, 0, SubBufSize);
+ pSubBufMgr->smlXltStoreBufP = pSubBufMgr->smlXltBufferP;
+ pSubBufMgr->smlXltWrittenBytes = 0;
+ pSubBufMgr->smlActiveExt = pBufMgr->smlActiveExt;
+ pSubBufMgr->smlCurExt = pBufMgr->smlCurExt;
+ pSubBufMgr->smlLastExt = pBufMgr->smlLastExt;
+ pSubBufMgr->spaceEvaluation = pBufMgr->spaceEvaluation;
+
+ // in case of space evaluation, just count the number of written bytes
+ if (pSubBufMgr->spaceEvaluation == 0) {
+ // create the WBXML header
+ pSubBufMgr->smlXltBufferP[0] = 0x02; // WBXML Version 1.2
+ pSubBufMgr->smlXltBufferP[1] = 0x00; // use Stringtable for ID
+ pSubBufMgr->smlXltBufferP[2] = 0x00; // empty/unknown public ID
+ pSubBufMgr->smlXltBufferP[3] = 0x6A; // charset encoding UTF-8
+ pSubBufMgr->smlXltBufferP[4] = 0x1D; // lenght of stringtable
+ pSubBufMgr->smlXltBufferP += 5;
+ // Generate FPI
+ // %%% luz 2003-07-31: ensured that we send the right version here!
+ smlLibMemmove(pSubBufMgr->smlXltBufferP, FPIstring, FPIsize);
+ pSubBufMgr->smlXltBufferP += FPIsize;
+ }
+ pSubBufMgr->smlXltWrittenBytes = 5 + FPIsize;
+
+ // do the encoding
+ switch (attFlag) {
+#ifdef __USE_DEVINF__
+ case SML_EXT_DEVINF:
+ if ((_err = devinfEncBlock(TN_DEVINF_DEVINF,reqOptFlag,pContent,enc,pSubBufMgr,SML_EXT_DEVINF)) != SML_ERR_OK) {
+ smlLibFree(pSubBufMgr->smlXltStoreBufP);
+ smlLibFree(pSubBufMgr);
+ return _err;
+ }
+ break;
+#endif
+ /* oops - we don not know about that extension -> bail out */
+ default:
+ smlLibFree(pSubBufMgr->smlXltStoreBufP);
+ smlLibFree(pSubBufMgr);
+ return SML_ERR_XLT_INVAL_EXT;
+ }
+
+#ifdef __USE_DEVINF__
+ // move it to the 'real' encoder buffer
+ // now set up the OPAQUE field
+ if (pBufMgr->spaceEvaluation == 0) {
+ pBufMgr->smlXltBufferP[0] = 0xC3; // OPAQUE data identifier
+ pBufMgr->smlXltBufferP += 1;
+
+ wbxmlOpaqueSize2Buf(pSubBufMgr->smlXltWrittenBytes, pBufMgr);
+
+ smlLibMemmove(pBufMgr->smlXltBufferP, pSubBufMgr->smlXltStoreBufP, pSubBufMgr->smlXltWrittenBytes);
+ pBufMgr->smlXltBufferP += pSubBufMgr->smlXltWrittenBytes;
+ pBufMgr->smlXltWrittenBytes += pSubBufMgr->smlXltWrittenBytes;
+ } else {
+ pBufMgr->smlXltWrittenBytes++;
+ wbxmlOpaqueSize2Buf(pSubBufMgr->smlXltWrittenBytes, pBufMgr);
+ pBufMgr->smlXltWrittenBytes += pSubBufMgr->smlXltWrittenBytes;
+ }
+
+ // clean up the temporary stuff
+ smlLibFree(pSubBufMgr->smlXltStoreBufP);
+ smlLibFree(pSubBufMgr);
+
+ return _err;
+#endif
+}
+#endif
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenccom.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenccom.c
new file mode 100644
index 0000000..161e64d
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenccom.c
@@ -0,0 +1,106 @@
+/*************************************************************************/
+/* module: Encoder utils file */
+/* file: xltenccom.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+
+#include "xltenccom.h"
+#include <smlerr.h>
+#include <libmem.h>
+
+/**
+ * FUNCTION: xltAddToBuffer
+ *
+ * Add a string to the global buffer
+ *
+ * PRE-Condition: pContent contains some content bytes to write to the (WB) XML buffer
+ *
+ * POST-Condition: content is written to the buffer
+ *
+ * IN: pContent, the character pointer referencing the content to
+ * write to the buffer
+ * size, the content length
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xltAddToBuffer(const MemPtr_t pContent, MemSize_t size, BufferMgmtPtr_t pBufMgr)
+{
+ // if we are doing a space evaluation, do not write the data physically - just remember its length
+ if (!pBufMgr->spaceEvaluation) {
+ //check if buffersize is to small to write the content
+ if ((size + pBufMgr->smlXltWrittenBytes) > pBufMgr->smlXltBufferLen) {
+ #ifdef NCDEBUGPRINTFX
+ #warning "%%%%% delete that message later"
+ NCDEBUGPRINTFX(DBG_SYNCML,(
+ "xltAddToBuffer: buffer too small, pContent='%0.30s', size=%ld, pBufMgr->smlXltWrittenBytes=%ld, pBufMgr->smlXltBufferLen=%ld",
+ pContent,
+ size,
+ pBufMgr->smlXltWrittenBytes,
+ pBufMgr->smlXltBufferLen
+ ));
+ #endif
+ return SML_ERR_XLT_BUF_ERR;
+ }
+
+ if (!(smlLibMemcpy((void*) pBufMgr->smlXltBufferP, (void*) pContent, (MemSize_t) size))) {
+ #ifdef NCDEBUGPRINTFX
+ #warning "%%%%% delete that message later"
+ NCDEBUGPRINTFX(DBG_SYNCML,(
+ "xltAddToBuffer: memCpy failed, pBufMgr->smlXltBufferP=%lX, size=%ld",
+ (long)pBufMgr->smlXltBufferP,
+ size
+ ));
+ #endif
+ return SML_ERR_XLT_BUF_ERR;
+ }
+ pBufMgr->smlXltBufferP += size;
+ }
+ pBufMgr->smlXltWrittenBytes += size;
+
+ return SML_ERR_OK;
+}
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenccom.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenccom.h
new file mode 100644
index 0000000..7f4925a
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltenccom.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#ifndef _XLT_ENC_COM_H
+#define _XLT_ENC_COM_H
+
+#include <smldef.h>
+#include <smldtd.h>
+#include <sml.h>
+
+#include "xlttags.h"
+
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+// flags if a (WB)XML block is required or optional
+typedef enum {
+ OPTIONAL = 0,
+ REQUIRED
+} XltRO_t;
+
+/* Tag Types (TT) - begin tags, end tags, ...
+ */
+typedef enum {
+ TT_END = 0,
+ TT_BEG,
+ TT_ALL
+} XltTagType_t;
+
+/* Structure elements which are not directly relied to a tag
+*/
+typedef enum {
+ ITEM_LIST,
+ TARGET_LIST,
+ SOURCE_LIST,
+ META_LIST,
+ MAPITEM_LIST,
+ TARGETREF_LIST,
+ SOURCEREF_LIST
+} XltListType_t;
+
+// Type for storing free mem size evaluation information
+typedef struct XltSpaceEvaluation_s
+{
+ MemSize_t written_bytes;
+ MemSize_t end_tag_size;
+ // %%% luz 2002-09-03: evaluation needs private shadow copies of these:
+ SmlPcdataExtension_t cur_ext;
+ SmlPcdataExtension_t last_ext;
+} XltSpaceEvaluation_t, *XltSpaceEvaluationPtr_t;
+
+
+typedef struct bufferMgmt_s
+{
+ MemPtr_t smlXltBufferP;
+ MemPtr_t smlXltStoreBufP;
+ MemSize_t smlXltWrittenBytes;
+ MemSize_t smlXltBufferLen;
+ XltTagID_t switchExtTag;
+ SmlPcdataExtension_t smlCurExt;
+ SmlPcdataExtension_t smlLastExt;
+ SmlPcdataExtension_t smlActiveExt;
+ MemSize_t endTagSize;
+ Boolean_t spaceEvaluation;
+ // %%% luz:2003-04-24: added syncmlvers
+ // %%% luz:2003-07-31: made it an enum, now called vers
+ SmlVersion_t vers;
+} BufferMgmt_t, *BufferMgmtPtr_t;
+
+/**
+ * FUNCTION: xltAddToBuffer
+ *
+ * Add a string to the global buffer
+ *
+ * PRE-Condition: pContent contains some content bytes to write to the (WB) XML buffer
+ *
+ * POST-Condition: content is written to the buffer
+ *
+ * IN: pContent, the character pointer referencing the content to
+ * write to the buffer
+ * size, the content length
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xltAddToBuffer(const MemPtr_t pContent, MemSize_t size, BufferMgmtPtr_t pBufMgr);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencwbxml.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencwbxml.c
new file mode 100644
index 0000000..6f4595d
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencwbxml.c
@@ -0,0 +1,311 @@
+/*************************************************************************/
+/* module: The WBXML Encoder source file */
+/* file: xltencwbxml.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#include <define.h>
+#ifdef __SML_WBXML__
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xltencwbxml.h"
+#include <libmem.h>
+#include <libstr.h>
+#include "xlttags.h"
+
+
+/**
+ * FUNCTION: wbxmlGetGlobToken
+ *
+ * Converts a element type into its wbxml token
+ *
+ * PRE-Condition: valid element type
+ *
+ * POST-Condition: return of wbxml token
+ *
+ * IN: elType, element type
+ *
+ * OUT: wbxml token
+ *
+ * RETURN: wbxml token
+ * 0, if no matching wbxml token
+ */
+MemByte_t wbxmlGetGlobToken(XltElementType_t elType)
+{
+
+ typedef struct GlobTok_s
+ {
+ XltElementType_t id;
+ MemByte_t wbxml;
+ } GlobTok_t;
+
+ // encoding of global tokens; related to the type XML_ElementType_t
+ GlobTok_t globtoken[] =
+ {
+ { END, 0x01 }, //Tag End
+ { STR_I, 0x03 }, //Inline string
+ { OPAQUE, 0xC3 }, //Opaque Data
+ { UNDEF, 0x00 }
+ };
+
+ int i = -1;
+ while (globtoken[++i].id != UNDEF)
+ if (globtoken[i].id == elType)
+ return globtoken[i].wbxml;
+ return 0;
+
+}
+
+/**
+ * FUNCTION: wbxmlOpaqueSize2Buf
+ *
+ * Converts a Long_t opaque size to a wbxml mb_u_int32 and adds it to the buffer
+ *
+ * PRE-Condition: size of the content to be written as opaque datatype
+ *
+ * POST-Condition: the size is converted to the mb_u_int32 representation and added
+ * to the buffer
+ *
+ * IN: size, length of the opaque data
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t wbxmlOpaqueSize2Buf(Long_t size, BufferMgmtPtr_t pBufMgr)
+{
+ Long_t _thresholdcount = 1;
+ Long_t _bytesNeeded = 0;
+ MemPtr_t _byteArray;
+ MemPtr_t _tmpByteArray;
+ int i, j;
+ Ret_t _err = SML_ERR_OK;
+
+ //j max = number of bytes of size
+ for (j=1; j<=sizeof(size); j++)
+ {
+ //if the size of the content is smaller than the power of 128,j ->
+ //one more byte is needed in the mb_u_int32 representation of WBXML
+ _thresholdcount = _thresholdcount * 128;
+ if(size < _thresholdcount)
+ {
+ _bytesNeeded = j;
+ break;
+ }
+ }
+
+ if (pBufMgr->spaceEvaluation == 0)
+ {
+ //allocate number of bytes needed by the mb_u_int32 data type
+ if ((_byteArray = smlLibMalloc(_bytesNeeded)) == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+
+ _tmpByteArray = _byteArray;
+
+ //process al bytes in the mb_u_int32 data type
+ for (i=1; i<=_bytesNeeded; i++)
+ {
+ // the lowest byte needs a 0 in its highest bit -> no | 0x80
+ if ((_bytesNeeded - i) == 0)
+ {
+ *_tmpByteArray = ((unsigned char)(size & 0x7F));
+ }
+ // all the other byte needs a 1 in its highest bit -> | 0x80
+ else
+ {
+ // only the seven lower bits contain the size value -> >> 7
+ *_tmpByteArray = ((unsigned char)(((size >> (7 * (_bytesNeeded - i))) & 0x7F) | 0x80));
+ _tmpByteArray++;
+ }
+ }
+
+ _err = xltAddToBuffer(_byteArray, _bytesNeeded, pBufMgr);
+
+ smlLibFree(_byteArray);
+ } else {
+ pBufMgr->smlXltWrittenBytes += _bytesNeeded;
+ // %%% luz 2002-09-03: return value was missing here.
+ _err=SML_ERR_OK;
+ }
+
+ return _err;
+}
+
+/**
+ * FUNCTION: wbxmlGenerateTag
+ *
+ * Generates a tag for a given tag ID and a given tag type
+ *
+ * PRE-Condition: valid parameters
+ *
+ * POST-Condition: a new wbxml tag is written to the buffer
+ *
+ * IN: tagId, the ID for the tag to generate (TN_ADD, ...)
+ * tagType, the tag type (e.g. Begin Tag -> TT_BEG, ...)
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t wbxmlGenerateTag(XltTagID_t tagId, XltTagType_t tagType, BufferMgmtPtr_t pBufMgr )
+{
+
+ Ret_t _err = SML_ERR_OK;
+ MemByte_t _tmp = 0x00;
+
+ //check if content byte has to be added to the tag
+ switch (tagType)
+ {
+ //set the end tag
+ case TT_END:
+ {
+ _tmp = (MemByte_t)wbxmlGetGlobToken(END);
+ if (!_tmp) return SML_ERR_XLT_INVAL_TAG_TYPE;
+ _err = xltAddToBuffer((&_tmp), 1, pBufMgr);
+ // remember the number of byte that must follow for the according end-tag
+ if (_err == SML_ERR_OK) pBufMgr->endTagSize -= 1;
+ return _err;
+ }
+ //Begin and End Tag in one
+ case TT_ALL:
+ {
+ _err = (MemByte_t)getTagByte(tagId, pBufMgr->smlCurExt, &_tmp);
+ if ((!_tmp) || (_err != SML_ERR_OK)) return _err;
+ return xltAddToBuffer((MemPtr_t)(&_tmp), 1, pBufMgr);
+ }
+ //Only Begin Tag -> content follows -> content byte has to be added
+ case TT_BEG:
+ {
+ _err = (MemByte_t)getTagByte(tagId, pBufMgr->smlCurExt, &_tmp);
+ if ((!_tmp) || (_err != SML_ERR_OK)) return _err;
+
+ _tmp = ((MemByte_t)(_tmp | XLT_CONTBYTE));
+ _err = xltAddToBuffer(&_tmp, 1, pBufMgr);
+ // remember the number of byte that must follow for the according end-tag
+ if (_err == SML_ERR_OK) pBufMgr->endTagSize += 1;
+ return _err;
+ }
+ default:
+ return SML_ERR_XLT_INVAL_TAG_TYPE;
+ }
+
+ // return SML_ERR_OK;Unreachable
+}
+
+/**
+ * FUNCTION: wbxmlWriteTypeToBuffer
+ *
+ * Write a content of a certain WBXML element type (e.g. STR_I) to the global buffer
+ *
+ * PRE-Condition: valid parameters
+ *
+ * POST-Condition: the content is written to the wbxml buffer with the leading
+ * bytes for the opaque data type or the STR_I data type
+ *
+ * IN: pContent, the character pointer referencing the content to
+ * write to the buffer
+ * elType, the element type to write to the buffer (e.g. STR_I)
+ * size, the content length
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t wbxmlWriteTypeToBuffer(const MemPtr_t pContent, XltElementType_t elType, Long_t size, BufferMgmtPtr_t pBufMgr)
+{
+ Ret_t _err;
+
+ MemByte_t _termstr = XLT_TERMSTR;
+ MemByte_t _tmp;
+
+ switch((int)elType)
+ {
+ case TAG:
+ {
+
+ return (xltAddToBuffer(pContent, size, pBufMgr));
+
+ }
+ case STR_I:
+ {
+ _tmp = (MemByte_t)wbxmlGetGlobToken(STR_I);
+ if (!_tmp) return SML_ERR_XLT_WBXML_UKN_TOK;
+
+ //add the STR_I identifier
+ if ((_err = xltAddToBuffer(&_tmp, 1, pBufMgr)) != SML_ERR_OK) return _err;
+
+ //add the string to the buffer
+ if ((_err = xltAddToBuffer(pContent, (!pContent) ? 0 : smlLibStrlen((String_t)pContent), pBufMgr)) != SML_ERR_OK) return _err;
+
+ //add the string terminator '\0'
+ if ((_err = xltAddToBuffer(&_termstr, 1, pBufMgr)) != SML_ERR_OK) return _err;
+
+ return SML_ERR_OK;
+ }
+ case OPAQUE:
+ {
+ _tmp = (MemByte_t)wbxmlGetGlobToken(OPAQUE);
+ if (!_tmp) return SML_ERR_XLT_WBXML_UKN_TOK;
+
+
+
+ //add the OPAQUE identifier
+ if ((_err = xltAddToBuffer(&_tmp, 1, pBufMgr)) != SML_ERR_OK) return _err;
+
+ //add the pContent length
+ if ((_err = wbxmlOpaqueSize2Buf(size, pBufMgr)) != SML_ERR_OK) return _err;
+
+ //add the string buffer
+ if ((_err = xltAddToBuffer(pContent, size, pBufMgr)) != SML_ERR_OK) return _err;
+
+ return SML_ERR_OK;
+ }
+ default:
+ return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ }
+
+// return SML_ERR_OK;unreachable
+}
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencwbxml.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencwbxml.h
new file mode 100644
index 0000000..1c46ada
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencwbxml.h
@@ -0,0 +1,181 @@
+/*************************************************************************/
+/* module: The WBXML Encoder header file */
+/* file: xltencwbxml.h */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#ifndef _XLT_ENC_WBXML_H
+#define _XLT_ENC_WBXML_H
+
+#include <smlerr.h>
+#include <smldef.h>
+#include <smldtd.h>
+#include "xlttags.h"
+#include "xltenccom.h"
+
+#define test 1
+
+// byte for WBXML String Table Length - not yet implemented yet -> 0x00
+#define XLT_STABLEN 0x00
+
+// byte for WBXML charset - not yet implemented - default UTF-8
+#define XLT_CHARSET 0x6A
+
+// byte for WBXML Version Number
+#define XLT_WBXMLVER 0x02
+
+// byte to add to a tag if a content follows
+#define XLT_CONTBYTE 0x40
+
+// byte to add to a tag if an attribute follows
+#define XLT_ATTRBYTE 0x80
+
+// termination character for certain WBXML element types (e.g. STR_I)
+#define XLT_TERMSTR 0x00
+
+// public identifier 0x00,0x00 -> unknown, use stringtable
+#define XLT_PUBIDENT1 0x00
+#define XLT_PUBIDENT2 0x00
+
+// switch page tag 0x00
+#define XLT_SWITCHPAGE 0x00
+
+// default codepage
+#define XLT_DEFAULTCODEPAGE 0x00
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+// global tokens in WBXML
+typedef enum {
+ UNDEF = 0,
+ END,
+ STR_I,
+ OPAQUE,
+ TAG
+} XltElementType_t;
+
+/**
+ * FUNCTION: wbxmlGenerateTag
+ *
+ * Generates a tag for a given tag ID and a given tag type
+ *
+ * PRE-Condition: valid parameters
+ *
+ * POST-Condition: a new wbxml tag is written to the buffer
+ *
+ * IN: tagId, the ID for the tag to generate (TN_ADD, ...)
+ * tagType, the tag type (e.g. Begin Tag -> TT_BEG, ...)
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t wbxmlGenerateTag(XltTagID_t tagId, XltTagType_t tagType, BufferMgmtPtr_t pBufMgr);
+
+/**
+ * FUNCTION: wbxmlWriteTypeToBuffer
+ *
+ * Write a content of a certain WBXML element type (e.g. STR_I) to the global buffer
+ *
+ * PRE-Condition: valid parameters
+ *
+ * POST-Condition: the content is written to the wbxml buffer with the leading
+ * bytes for the opaque data type or the STR_I data type
+ *
+ * IN: pContent, the character pointer referencing the content to
+ * write to the buffer
+ * elType, the element type to write to the buffer (e.g. STR_I)
+ * size, the content length
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t wbxmlWriteTypeToBuffer(const MemPtr_t pContent, XltElementType_t elType, Long_t size, BufferMgmtPtr_t pBufMgr);
+
+/**
+ * FUNCTION: wbxmlOpaqueSize2Buf
+ *
+ * Converts a Long_t opaque size to a wbxml mb_u_int32 and adds it to the buffer
+ *
+ * PRE-Condition: size of the content to be written as opaque datatype
+ *
+ * POST-Condition: the size is converted to the mb_u_int32 representation and added
+ * to the buffer
+ *
+ * IN: size, length of the opaque data
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t wbxmlOpaqueSize2Buf(Long_t size, BufferMgmtPtr_t pBufMgr);
+
+/**
+ * FUNCTION: wbxmlGetGlobToken
+ *
+ * Converts a element type into its wbxml token
+ *
+ * PRE-Condition: valid element type
+ *
+ * POST-Condition: return of wbxml token
+ *
+ * IN: elType, element type
+ *
+ * OUT: wbxml token
+ *
+ * RETURN: wbxml token
+ * 0, if no matching wbxml token
+ */
+MemByte_t wbxmlGetGlobToken(XltElementType_t elType);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencxml.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencxml.c
new file mode 100644
index 0000000..0f88f9a
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencxml.c
@@ -0,0 +1,170 @@
+/*************************************************************************/
+/* module: The XML Encoder source file */
+/* file: xltencxml.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#include <define.h>
+#ifdef __SML_XML__
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xltencxml.h"
+#include <libstr.h>
+#include "xlttags.h"
+#include <libmem.h>
+
+/**
+ * FUNCTION: xmlGenerateTag
+ *
+ * Generates a XML tag
+ *
+ * PRE-Condition: valid parameters
+ *
+ * POST-Condition: the XML tag is written to the XML buffer
+ *
+ * IN: tagId, the ID for the tag to generate (TN_ADD, ...)
+ * tagType, the tag type (e.g. Begin Tag -> TT_BEG, ...)
+ * attFlag, indicates if the encoded tag contain Attributes in namespace extensions
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xmlGenerateTag(XltTagID_t tagId, XltTagType_t tagType, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+ Ret_t _err;
+
+ MemByte_t _begpar = XML_BEGPAR;
+ MemByte_t _tagdel = XML_TAGDEL;
+ MemByte_t _endpar = XML_ENDPAR;
+ MemByte_t _nstagstart[] = XML_NSSTART;
+ MemByte_t _nstagend[] = XML_NSEND;
+
+
+ String_t _tagstr;
+ String_t _tagnsattr = NULL;
+
+ if ((_tagstr = (String_t)smlLibMalloc(XML_MAX_TAGLEN)) == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+
+ if ((_err = getTagString(tagId, _tagstr, attFlag)) != SML_ERR_OK) {
+ smlLibFree(_tagstr);
+ return _err;
+ }
+
+ if (!_tagstr) { // check again as _tagstr might be alterd in getTagString
+ smlLibFree(_tagstr);
+ return SML_ERR_XLT_INVAL_TAG_TYPE;
+ }
+
+ /* the <SyncML> tag _must_ have an xmlns attribute */
+ if (attFlag != pBufMgr->smlActiveExt || tagId == TN_SYNCML) {
+ // %%% luz:2003-07-31: now uses namespace from table according to version
+ if (getExtName(attFlag, &_tagnsattr, pBufMgr->vers) != SML_ERR_OK) {
+ smlLibFree(_tagstr);
+ return SML_ERR_XLT_INVAL_TAG_TYPE;
+ }
+ }
+ pBufMgr->smlActiveExt = attFlag;
+ //check if content byte has to be added to the tag
+ switch (tagType)
+ {
+ // set the end tag
+ case TT_END:
+ {
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_tagdel), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagstr, smlLibStrlen(_tagstr), pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, pBufMgr)) != SML_ERR_OK) break;
+ if (tagId == pBufMgr->switchExtTag) {
+ pBufMgr->smlActiveExt = pBufMgr->smlLastExt;
+ pBufMgr->smlCurExt = pBufMgr->smlLastExt;
+ pBufMgr->smlLastExt = attFlag;
+ }
+ // just forget the stored number ob bytes for this end-tag since written now
+ pBufMgr->endTagSize -= (3 + smlLibStrlen(_tagstr));
+ break;
+ }
+ //Empty tag
+ case TT_ALL:
+ {
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagstr, smlLibStrlen(_tagstr), pBufMgr)) != SML_ERR_OK) break;
+ if (_tagnsattr) {
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_nstagstart), 8, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagnsattr, smlLibStrlen(_tagnsattr), pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)&_nstagend, 1, pBufMgr)) != SML_ERR_OK) break;
+ }
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_tagdel), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, pBufMgr)) != SML_ERR_OK) break;
+
+ break;
+ }
+ //Only Begin Tag -> content follows -> content byte has to be added
+ case TT_BEG:
+ {
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagstr, smlLibStrlen(_tagstr), pBufMgr)) != SML_ERR_OK) break;
+ if (_tagnsattr) {
+ if ((_err = xltAddToBuffer((MemPtr_t)&_nstagstart, 8, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagnsattr, smlLibStrlen(_tagnsattr), pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)&_nstagend, 1, pBufMgr)) != SML_ERR_OK) break;
+ }
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, pBufMgr)) != SML_ERR_OK) break;
+
+ // remember the number of byte that must follow for the according end-tag
+ pBufMgr->endTagSize += (3 + smlLibStrlen(_tagstr));
+ break;
+ }
+ default:
+ {
+ smlLibFree(_tagstr);
+ smlLibFree(_tagnsattr);
+ return SML_ERR_XLT_INVAL_TAG_TYPE;
+ }
+ }
+ smlLibFree(_tagstr);
+ smlLibFree(_tagnsattr);
+ return _err;
+}
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencxml.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencxml.h
new file mode 100644
index 0000000..1b6a5f5
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltencxml.h
@@ -0,0 +1,102 @@
+/*************************************************************************/
+/* module: The XML Encoder header file */
+/* file: xltencxml.h */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#ifdef __SML_XML__
+#ifndef _XLT_ENC_XML_H
+#define _XLT_ENC_XML_H
+
+#include <smlerr.h>
+#include "xlttags.h"
+#include "xltenccom.h"
+
+// byte for XML tag begin parentheses
+#define XML_BEGPAR '<'
+
+// byte for XML tag end parentheses
+#define XML_ENDPAR '>'
+
+// byte for XML tag del
+#define XML_TAGDEL '/'
+
+// XML version
+#define XML_VERSION "1.0"
+
+// XML encoding
+#define XML_ENCODING "UTF-8"
+
+// XML namespaceattribute
+#define XML_NSSTART " xmlns='"
+#define XML_NSEND "'"
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+/**
+ * FUNCTION: xmlGenerateTag
+ *
+ * Generates a XML tag
+ *
+ * PRE-Condition: valid parameters
+ *
+ * POST-Condition: the XML tag is written to the XML buffer
+ *
+ * IN: tagId, the ID for the tag to generate (TN_ADD, ...)
+ * tagType, the tag type (e.g. Begin Tag -> TT_BEG, ...)
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xmlGenerateTag(XltTagID_t tagId, XltTagType_t tagType, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltmetinf.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltmetinf.c
new file mode 100644
index 0000000..70966bf
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltmetinf.c
@@ -0,0 +1,354 @@
+/*************************************************************************/
+/* module: MetaInf DTD related functions for the en-/decoder */
+/* file: xltmetinf.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#include "define.h"
+#ifdef __USE_METINF__
+
+#include "smlmetinfdtd.h"
+#include "xlttags.h"
+#include "xltmetinf.h"
+#include "xlttagtbl.h"
+#include "xltenc.h"
+#include "xltencwbxml.h"
+
+#include <define.h>
+#include <libstr.h>
+#include <smlerr.h>
+#include <smldtd.h>
+#include <libmem.h>
+#include <libutil.h>
+/* extern */
+ extern SML_API void smlFreeMetinfAnchor(SmlMetInfAnchorPtr_t data);
+ extern SML_API void smlFreeMetinfMem(SmlMetInfMemPtr_t data);
+ extern SML_API void smlFreeMetinfMetinf(SmlMetInfMetInfPtr_t data);
+
+
+/* decoder callbacks */
+Ret_t buildMetInfAnchorCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlMetInfAnchorPtr_t pAnchor;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pAnchor = (SmlMetInfAnchorPtr_t)smlLibMalloc(sizeof(SmlMetInfAnchor_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pAnchor, 0, sizeof(SmlMetInfAnchor_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pAnchor;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfAnchor(pAnchor);
+ //smlLibFree(pAnchor);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_METINF_LAST:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAnchor->last);
+ break;
+ case TN_METINF_NEXT:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAnchor->next);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMetinfAnchor(pAnchor);
+ //smlLibFree(pAnchor);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfAnchor(pAnchor);
+ //smlLibFree(pAnchor);
+ return rc;
+ }
+ }
+ *ppElem = pAnchor;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildMetInfMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlMetInfMemPtr_t pMem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pMem = (SmlMetInfMemPtr_t)smlLibMalloc(sizeof(SmlMetInfMem_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pMem, 0, sizeof(SmlMetInfMem_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pMem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMem(pMem);
+ //smlLibFree(pMem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_METINF_SHAREDMEM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMem->shared);
+ break;
+ case TN_METINF_FREEMEM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMem->free);
+ break;
+ case TN_METINF_FREEID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMem->freeid);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMetinfMem(pMem);
+ //smlLibFree(pMem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMem(pMem);
+ //smlLibFree(pMem);
+ return rc;
+ }
+ }
+ *ppElem = pMem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildMetInfMetInfCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlMetInfMetInfPtr_t pMeta;
+ Ret_t rc;
+ int foundWrapper = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pMeta = (SmlMetInfMetInfPtr_t)smlLibMalloc(sizeof(SmlMetInfMetInf_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pMeta, 0, sizeof(SmlMetInfMetInf_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pMeta;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMetinf(pMeta);
+ //smlLibFree(pMeta);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_METINF_METINF: /* ignore - it's just the wrapper tag */
+ foundWrapper = 1;
+ break;
+ case TN_METINF_FORMAT:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->format);
+ break;
+ case TN_METINF_TYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->type);
+#ifdef __USE_DMTND__
+ if ( NULL != pMeta->type && NULL != pMeta->type->content )
+ {
+ if ( !smlLibStrcmp(pMeta->type->content, META_TYPE_TNDS_XML ) )
+ {
+ pDecoder->tndsEncoding = SML_XML;
+ }
+ else if ( !smlLibStrcmp(pMeta->type->content, META_TYPE_TNDS_XML ) )
+ {
+ pDecoder->tndsEncoding = SML_WBXML;
+ }
+ if ( pDecoder->smlEncoding != pDecoder->tndsEncoding )
+ {
+ KCDBG("Mismatching SML and TNDS encoding schema!");
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+#endif
+ break;
+ case TN_METINF_MARK:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->mark);
+ break;
+ case TN_METINF_SIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->size);
+ break;
+ case TN_METINF_VERSION:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->version);
+ break;
+ case TN_METINF_NEXTNONCE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->nextnonce);
+ break;
+ case TN_METINF_ANCHOR:
+ rc = buildMetInfAnchorCmd(pDecoder, (VoidPtr_t)&pMeta->anchor);
+ break;
+ case TN_METINF_MAXMSGSIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->maxmsgsize);
+ break;
+ /* SCTSTK - 18/03/2002 S.H. 2002-04-05: SyncML 1.1 */
+ case TN_METINF_MAXOBJSIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->maxobjsize);
+ break;
+ case TN_METINF_MEM:
+ rc = buildMetInfMemCmd(pDecoder, (VoidPtr_t)&pMeta->mem);
+ break;
+ case TN_METINF_EMI:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pMeta->emi);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMetinfMetinf(pMeta);
+ //smlLibFree(pMeta);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMetinf(pMeta);
+ //smlLibFree(pMeta);
+ return rc;
+ }
+ }
+
+ if (foundWrapper) {
+ /* Optional Metinf root tag was used in this message.
+ * The actual token is the closing root tag.
+ * It is required that the scanner points to the first tag _after_
+ * <MetInf>...</MetInf>, so we just skip to the next token and continue.
+ */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMetinf(pMeta);
+ //smlLibFree(pMeta);
+ return rc;
+ }
+ }
+ *ppElem = pMeta;
+
+ return SML_ERR_OK;
+}
+
+
+
+/* see xltenc.c:XltEncBlock for description of parameters */
+Ret_t metinfEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag) {
+ //Return variable
+ Ret_t _err;
+ SmlPcdataListPtr_t pList = NULL;
+ //Check if pContent of a required field is missing
+ if ((reqOptFlag == REQUIRED) && (pContent == NULL))
+ return SML_ERR_XLT_MISSING_CONT;
+ //Check if pContent of a optional field is missing -> if yes we are done
+ else if (pContent == NULL)
+ return SML_ERR_OK;
+
+ //Generate the commands -> see DTD
+ switch (tagId) {
+ case TN_METINF_ANCHOR:
+ if ((_err = xltGenerateTag(TN_METINF_ANCHOR, TT_BEG, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_LAST, OPTIONAL, ((SmlMetInfAnchorPtr_t) pContent)->last, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_NEXT, REQUIRED, ((SmlMetInfAnchorPtr_t) pContent)->next, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_METINF_ANCHOR, TT_END, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_METINF_MEM:
+ if ((_err = xltGenerateTag(TN_METINF_MEM, TT_BEG, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_SHAREDMEM, OPTIONAL, ((SmlMetInfMemPtr_t) pContent)->shared, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_FREEMEM, REQUIRED, ((SmlMetInfMemPtr_t) pContent)->free, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_FREEID, REQUIRED, ((SmlMetInfMemPtr_t) pContent)->freeid, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_METINF_MEM, TT_END, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_METINF_SHAREDMEM:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlMetInfSharedMem_f))
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_METINF_METINF:
+ //if ((_err = xltGenerateTag(TN_METINF_METINF, TT_BEG, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_FORMAT, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->format, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_TYPE, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->type, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_MARK, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->mark, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_SIZE, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->size, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_ANCHOR, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->anchor, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_VERSION, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->version, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_NEXTNONCE, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->nextnonce, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_MAXMSGSIZE,OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->maxmsgsize, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ // %%% luz 2003-04-24: added maxobjsize generation (was missing = bug in original RTK 4.1)
+ if ((_err = metinfEncBlock(TN_METINF_MAXOBJSIZE,OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->maxobjsize, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ pList = ((SmlMetInfMetInfPtr_t)pContent)->emi;
+ while (pList != NULL) {
+ if ((_err = xltEncBlock(TN_METINF_EMI, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ pList = pList->next;
+ };
+
+ if ((_err = metinfEncBlock(TN_METINF_MEM, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->mem, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ //if ((_err = xltGenerateTag(TN_METINF_METINF, TT_END, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ break;
+ default: { // all leaf nodes (PCDATA#)
+ return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag);
+ } /* eof default statement from switch tagid */
+ } /* eof switch tagid */
+ return SML_ERR_OK;
+}
+
+#endif /* __USE_METINF__ */
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltmetinf.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltmetinf.h
new file mode 100644
index 0000000..2337566
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltmetinf.h
@@ -0,0 +1,69 @@
+/*************************************************************************/
+/* module: Definition of MetaInf DTD prototypefunctions */
+/* for the en-/decoder */
+/* file: xltmetinf.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#ifndef _XLT_METINF_H
+#define _XLT_METINF_H
+
+/* process only if we really use MetInf DTD */
+#ifdef __USE_METINF__
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xlttagtbl.h"
+#include "xltenc.h"
+
+#ifdef __USE_DMTND__
+#define META_TYPE_TNDS_XML "application/vnd.syncml.dmtnds+xml"
+#define META_TYPE_TNDS_WBXML "application/vnd.syncml.dmtnds+wbxml"
+#endif
+
+Ret_t buildMetInfAnchorCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildMetInfMetInfCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildMetInfMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t metinfEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag);
+#endif /* __USE_METINF__ */
+#endif /* _XLT_METINF_H */
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttags.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttags.c
new file mode 100644
index 0000000..79b8a38
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttags.c
@@ -0,0 +1,780 @@
+/*************************************************************************/
+/* module: Definition of WBXML/XML tags for the en-/decoder */
+/* file: XLTTags.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#include "xlttags.h"
+
+#include <libstr.h>
+#include <smlerr.h>
+#include <libmem.h>
+#include <libutil.h>
+#include <mgr.h>
+
+#include "xltmetinf.h"
+#include "xltdevinf.h"
+#include "xlttagtbl.h"
+
+
+// %%% luz:2003-07-31: added SyncML namespace tables
+const char * const SyncMLNamespaces[SML_NUM_VERS] = {
+ "???",
+ "SYNCML:SYNCML1.0",
+ "SYNCML:SYNCML1.1",
+ "SYNCML:SYNCML1.2"
+};
+
+/* local prototypes */
+#ifdef NOWSM
+const // without WSM, the tag table is a global read-only constant
+#endif
+TagPtr_t getTagTable(SmlPcdataExtension_t ext);
+
+//SmlPcdataExtension_t getByName(String_t ns);
+void freeDtdTable(DtdPtr_t tbl);
+
+#ifdef NOWSM
+const // without WSM, the DTD table is a global read-only constant
+#endif
+DtdPtr_t getDtdTable();
+
+
+// free table obtained with getDtdTable()
+void freeDtdTable(DtdPtr_t tbl)
+{
+ #ifndef NOWSM
+ // only with WSM this is an allocated table
+ smlLibFree(tbl);
+ #endif
+}
+
+/**
+ * FUNCTION: getDtdTable
+ *
+ * Returns a copy of the table containing all known (sub) dtd's
+ * On error a NULL pointer is returned
+ */
+#ifdef NOWSM
+const // without WSM, the DTD table is a global read-only constant
+#endif
+DtdPtr_t getDtdTable() {
+ #ifdef NOWSM
+ // NOWSM method, table is const, just return a pointer
+ static const Dtd_t XltDtdTbl[] = {
+ { "SYNCML:SYNCML1.0", SML_EXT_UNDEFINED}, // %%% note that this is the default, will be override by syncml version specific string from
+ { "syncml:metinf", SML_EXT_METINF},
+ { "syncml:devinf", SML_EXT_DEVINF},
+ { "syncml:dmddf1.2", SML_EXT_DMTND},
+ { NULL, SML_EXT_LAST}
+ };
+ return (DtdPtr_t)XltDtdTbl;
+ #else
+ // WSM method wasting a lot of memory
+ DtdPtr_t _tmpPtr;
+
+ Dtd_t XltDtdTbl[] = {
+ { "SYNCML:SYNCML1.0", SML_EXT_UNDEFINED},
+ { "syncml:metinf", SML_EXT_METINF},
+ { "syncml:devinf", SML_EXT_DEVINF},
+ { "syncml:dmddf1.2", SML_EXT_DMTND},
+ { NULL, SML_EXT_LAST}
+ };
+ _tmpPtr = NULL;
+ _tmpPtr = (DtdPtr_t)smlLibMalloc(sizeof(XltDtdTbl));
+ if (_tmpPtr == NULL) return NULL;
+ smlLibMemcpy(_tmpPtr, &XltDtdTbl, sizeof(XltDtdTbl));
+ return _tmpPtr;
+ #endif
+}
+
+
+/**
+ * FUNCTION: getExtName
+ *
+ * Returns the official name for a given extention/sub-DTD
+ * and stored it in 'name'. If not found name isn't modified
+ */
+// %%% luz:2003-04-24: added syncmlvers parameter
+// %%% luz:2003-07-31: changed to vers enum
+Ret_t getExtName(SmlPcdataExtension_t ext, String_t *name, SmlVersion_t vers) {
+ DtdPtr_t dtdhead = getDtdTable();
+ DtdPtr_t dtd = dtdhead;
+ const char *dtdname;
+ if (!dtdhead) return -1;
+ for (;dtd->ext != SML_EXT_LAST; dtd++) {
+ if (!dtd->name) continue; /* skip empty names (should not appear but better be on the safe side) */
+ if (dtd->ext == ext) {
+ String_t _tmp;
+ // this is the default
+ dtdname=dtd->name;
+ // %%% luz:2003-04-24: added dynamic generation of namespace according to SyncML version
+ if (ext==SML_EXT_UNDEFINED && vers!=SML_VERS_UNDEF) {
+ // this requests SyncML namespace
+ if (vers >= SML_NUM_VERS )
+ {
+ freeDtdTable(dtdhead);
+ return SML_ERR_INVALID_SIZE;
+ }
+ dtdname=SyncMLNamespaces[vers];
+ }
+ _tmp = smlLibMalloc(smlLibStrlen(dtdname)+1);
+ if (!_tmp) {
+ freeDtdTable(dtdhead);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibStrcpy(_tmp, dtdname);
+ freeDtdTable(dtdhead);
+ *name = _tmp;
+ return SML_ERR_OK;
+ }
+ }
+ freeDtdTable(dtdhead);
+ return -1;
+}
+
+/**
+ * FUNCTION: getCpByName
+ *
+ * Returns the codepage constant assoziated with the name stored in 'ns'
+ *
+ * RETURN: a SmlPcdataExtension_t representing the corresponding codepage id.
+ * If no corresponding codepage is found -1 is returned.
+ */
+SmlPcdataExtension_t getExtByName(String_t ns) {
+ DtdPtr_t dtdhead = getDtdTable();
+ DtdPtr_t dtd = dtdhead;
+ SmlPcdataExtension_t ext = (SmlPcdataExtension_t) 255;
+ if (!dtdhead) return SML_EXT_UNDEFINED;
+ for (;dtd->ext != SML_EXT_LAST; dtd++) {
+ const char *dtdname=dtd->name;
+ if (!dtdname) continue; /* skip empty names (should not appear but better be on the safe side) */
+ if (dtd->ext==SML_EXT_UNDEFINED && smlLibStrncmp("SYNCML:SYNCML",ns,13)==0) {
+ // SyncML namespace is ok without checking version!
+ ext = SML_EXT_UNDEFINED;
+ break;
+ }
+ else if (smlLibStrcmp(dtdname,ns) == 0) {
+ ext = dtd->ext;
+ break;
+ }
+ }
+ freeDtdTable(dtdhead);
+ return ext;
+}
+
+
+
+/* if the commands are not defined we let the functions point to NULL */
+#ifndef RESULT_RECEIVE
+#define buildResults NULL
+#endif
+
+#ifndef MAP_RECEIVE
+#define buildMap NULL
+#endif
+
+#ifndef EXEC_RECEIVE
+#define buildExec NULL
+#endif
+
+#if !defined(ATOM_RECEIVE) && !defined(SEQUENCE_RECEIVE)
+#define buildAtomOrSeq NULL
+#endif
+
+#ifndef SEARCH_RECEIVE
+#define buildSearch NULL
+#endif
+
+
+/**
+ * FUNCTION: getTagTable
+ *
+ * Returns the tag table - this function is used to avoid a global
+ * tag table variable
+ *
+ * RETURN: a pointer to the tag table containing tag ids,
+ * codepages, wbxml tags and xml tags
+ */
+/* T.K. initialized the structure via _TOKEN Macro, to take
+ * out the XML name tags when not compiled with XML support.
+ * In addtion removed the (unused) pointer for the build functions
+ */
+#ifdef __SML_XML__
+#define _TOKEN(id, wbxml, xml) (id), (wbxml), (xml)
+#else
+#define _TOKEN(id, wbxml, xml) (id), (wbxml), ""
+#endif
+
+#ifdef NOWSM
+const // without WSM, the tag table is a global read-only constant
+#endif
+TagPtr_t getTagTable(SmlPcdataExtension_t ext)
+{
+ #ifndef NOWSM
+ int mySize = 0;
+ TagPtr_t _tmpTagPtr;
+ SyncMLInfoPtr_t pGA = NULL;
+ #else
+ TagPtr_t _tmpTagPtr=NULL;
+ #endif
+ /* standard SyncML codepage */
+ static const Tag_t syncml[] =
+ {
+ { _TOKEN(TN_ADD, 0x05, "Add")},
+ { _TOKEN(TN_ALERT, 0x06, "Alert")},
+ { _TOKEN(TN_ARCHIVE, 0x07, "Archive")},
+ { _TOKEN(TN_ATOMIC, 0x08, "Atomic")},
+ { _TOKEN(TN_CHAL, 0x09, "Chal")},
+ { _TOKEN(TN_CMD, 0x0A, "Cmd")},
+ { _TOKEN(TN_CMDID, 0x0B, "CmdID")},
+ { _TOKEN(TN_CMDREF, 0x0C, "CmdRef")},
+ { _TOKEN(TN_COPY, 0x0D, "Copy")},
+ { _TOKEN(TN_CRED, 0x0E, "Cred")},
+ { _TOKEN(TN_DATA, 0x0F, "Data")},
+ { _TOKEN(TN_DELETE, 0x10, "Delete")},
+ { _TOKEN(TN_EXEC, 0x11, "Exec")},
+ { _TOKEN(TN_FINAL, 0x12, "Final")},
+ { _TOKEN(TN_GET, 0x13, "Get")},
+ { _TOKEN(TN_ITEM, 0x14, "Item")},
+ { _TOKEN(TN_LANG, 0x15, "Lang")},
+ { _TOKEN(TN_LOCNAME, 0x16, "LocName")},
+ { _TOKEN(TN_LOCURI, 0x17, "LocURI")},
+ { _TOKEN(TN_MAP, 0x18, "Map")},
+ { _TOKEN(TN_MAPITEM, 0x19, "MapItem")},
+ { _TOKEN(TN_META, 0x1A, "Meta")},
+ { _TOKEN(TN_MSGID, 0x1B, "MsgID")},
+ { _TOKEN(TN_MSGREF, 0x1C, "MsgRef")},
+ { _TOKEN(TN_NORESP, 0x1D, "NoResp")},
+ { _TOKEN(TN_NORESULTS, 0x1E, "NoResults")},
+ { _TOKEN(TN_PUT, 0x1F, "Put")},
+ { _TOKEN(TN_REPLACE, 0x20, "Replace")},
+ { _TOKEN(TN_RESPURI, 0x21, "RespURI")},
+ { _TOKEN(TN_RESULTS, 0x22, "Results")},
+ { _TOKEN(TN_SEARCH, 0x23, "Search")},
+ { _TOKEN(TN_SEQUENCE, 0x24, "Sequence")},
+ { _TOKEN(TN_SESSIONID, 0x25, "SessionID")},
+ { _TOKEN(TN_SFTDEL, 0x26, "SftDel")},
+ { _TOKEN(TN_SOURCE, 0x27, "Source")},
+ { _TOKEN(TN_SOURCEREF, 0x28, "SourceRef")},
+ { _TOKEN(TN_STATUS, 0x29, "Status")},
+ { _TOKEN(TN_SYNC, 0x2A, "Sync")},
+ { _TOKEN(TN_SYNCBODY, 0x2B, "SyncBody")},
+ { _TOKEN(TN_SYNCHDR, 0x2C, "SyncHdr")},
+ { _TOKEN(TN_SYNCML, 0x2D, "SyncML")},
+ { _TOKEN(TN_TARGET, 0x2E, "Target")},
+ { _TOKEN(TN_TARGETREF, 0x2F, "TargetRef")},
+ { _TOKEN(TN_VERSION, 0x31, "VerDTD")},
+ { _TOKEN(TN_PROTO, 0x32, "VerProto")},
+ { _TOKEN(TN_NUMBEROFCHANGES,0x33, "NumberOfChanges")},
+ { _TOKEN(TN_MOREDATA, 0x34, "MoreData")},
+ /* from version 1.2 */
+ { _TOKEN(TN_CORRELATOR, 0x3C, "Correlator")},
+
+ { _TOKEN(TN_UNDEF, 0x00, NULL)}
+ };
+
+ #ifdef __USE_METINF__
+ static const Tag_t metinf[] = {
+ { _TOKEN(TN_METINF_ANCHOR, 0x05, "Anchor")},
+ { _TOKEN(TN_METINF_EMI, 0x06, "EMI")},
+ { _TOKEN(TN_METINF_FORMAT, 0x07, "Format")},
+ { _TOKEN(TN_METINF_FREEID, 0x08, "FreeID")},
+ { _TOKEN(TN_METINF_FREEMEM, 0x09, "FreeMem")},
+ { _TOKEN(TN_METINF_LAST, 0x0A, "Last")},
+ { _TOKEN(TN_METINF_MARK, 0x0B, "Mark")},
+ { _TOKEN(TN_METINF_MAXMSGSIZE, 0x0C, "MaxMsgSize")},
+ { _TOKEN(TN_METINF_MEM, 0x0D, "Mem")},
+ { _TOKEN(TN_METINF_METINF, 0x0E, "MetInf")},
+ { _TOKEN(TN_METINF_NEXT, 0x0F, "Next")},
+ { _TOKEN(TN_METINF_NEXTNONCE, 0x10, "NextNonce")},
+ { _TOKEN(TN_METINF_SHAREDMEM, 0x11, "SharedMem")},
+ { _TOKEN(TN_METINF_SIZE, 0x12, "Size")},
+ { _TOKEN(TN_METINF_TYPE, 0x13, "Type")},
+ { _TOKEN(TN_METINF_VERSION, 0x14, "Version")},
+ /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+ { _TOKEN(TN_METINF_MAXOBJSIZE, 0x15, "MaxObjSize")},
+ { _TOKEN(TN_UNDEF, 0x00, NULL)}
+ };
+ #endif
+
+
+ #ifdef __USE_DEVINF__
+ static const Tag_t devinf[] = {
+ {_TOKEN(TN_DEVINF_CTCAP, 0x05, "CTCap")},
+ {_TOKEN(TN_DEVINF_CTTYPE, 0x06, "CTType")},
+ {_TOKEN(TN_DEVINF_DATASTORE, 0x07, "DataStore")},
+ {_TOKEN(TN_DEVINF_DATATYPE, 0x08, "DataType")},
+ {_TOKEN(TN_DEVINF_DEVID, 0x09, "DevID")},
+ {_TOKEN(TN_DEVINF_DEVINF, 0x0A, "DevInf")},
+ {_TOKEN(TN_DEVINF_DEVTYP, 0x0B, "DevTyp")},
+ {_TOKEN(TN_DEVINF_DISPLAYNAME, 0x0C, "DisplayName")},
+ {_TOKEN(TN_DEVINF_DSMEM, 0x0D, "DSMem")},
+ {_TOKEN(TN_DEVINF_EXT, 0x0E, "Ext")},
+ {_TOKEN(TN_DEVINF_FWV, 0x0F, "FwV")},
+ {_TOKEN(TN_DEVINF_HWV, 0x10, "HwV")},
+ {_TOKEN(TN_DEVINF_MAN, 0x11, "Man")},
+ {_TOKEN(TN_DEVINF_MAXGUIDSIZE, 0x12, "MaxGUIDSize")},
+ {_TOKEN(TN_DEVINF_MAXID, 0x13, "MaxID")},
+ {_TOKEN(TN_DEVINF_MAXMEM, 0x14, "MaxMem")},
+ {_TOKEN(TN_DEVINF_MOD, 0x15, "Mod")},
+ {_TOKEN(TN_DEVINF_OEM, 0x16, "OEM")},
+ {_TOKEN(TN_DEVINF_PARAMNAME, 0x17, "ParamName")},
+ {_TOKEN(TN_DEVINF_PROPNAME, 0x18, "PropName")},
+ {_TOKEN(TN_DEVINF_RX, 0x19, "Rx")},
+ {_TOKEN(TN_DEVINF_RXPREF, 0x1A, "Rx-Pref")},
+ {_TOKEN(TN_DEVINF_SHAREDMEM, 0x1B, "SharedMem")},
+ {_TOKEN(TN_DEVINF_SIZE, 0x1C, "Size")},
+ {_TOKEN(TN_DEVINF_SOURCEREF, 0x1D, "SourceRef")},
+ {_TOKEN(TN_DEVINF_SWV, 0x1E, "SwV")},
+ {_TOKEN(TN_DEVINF_SYNCCAP, 0x1F, "SyncCap")},
+ {_TOKEN(TN_DEVINF_SYNCTYPE, 0x20, "SyncType")},
+ {_TOKEN(TN_DEVINF_TX, 0x21, "Tx")},
+ {_TOKEN(TN_DEVINF_TXPREF, 0x22, "Tx-Pref")},
+ {_TOKEN(TN_DEVINF_VALENUM, 0x23, "ValEnum")},
+ {_TOKEN(TN_DEVINF_VERCT, 0x24, "VerCT")},
+ {_TOKEN(TN_DEVINF_VERDTD, 0x25, "VerDTD")},
+ {_TOKEN(TN_DEVINF_XNAM, 0x26, "XNam")},
+ {_TOKEN(TN_DEVINF_XVAL, 0x27, "XVal")},
+ // %%% luz:2003-04-28 : added these, they were missing
+ {_TOKEN(TN_DEVINF_UTC, 0x28, "UTC")},
+ {_TOKEN(TN_DEVINF_NOFM, 0x29, "SupportNumberOfChanges")},
+ {_TOKEN(TN_DEVINF_LARGEOBJECT, 0x2A, "SupportLargeObjs")},
+ // %%% end luz
+ { _TOKEN(TN_UNDEF, 0x00, NULL)}
+ };
+ #endif
+
+ #ifdef __USE_DMTND__
+ static const Tag_t dmtnd[] = {
+ { _TOKEN(TN_DMTND_AccessType, 0x05, "AccessType")},
+ { _TOKEN(TN_DMTND_ACL, 0x06, "ACL")},
+ { _TOKEN(TN_DMTND_Add, 0x07, "Add")},
+ { _TOKEN(TN_DMTND_b64, 0x08, "b64")},
+ { _TOKEN(TN_DMTND_bin, 0x09, "bin")},
+ { _TOKEN(TN_DMTND_bool, 0x0A, "bool")},
+ { _TOKEN(TN_DMTND_chr, 0x0B, "chr")},
+ { _TOKEN(TN_DMTND_CaseSense, 0x0C, "CaseSense")},
+ { _TOKEN(TN_DMTND_CIS, 0x0D, "CIS")},
+ { _TOKEN(TN_DMTND_Copy, 0x0E, "Copy")},
+ { _TOKEN(TN_DMTND_CS, 0x0F, "CS")},
+ { _TOKEN(TN_DMTND_date, 0x10, "date")},
+ { _TOKEN(TN_DMTND_DDFName, 0x11, "DDFName")},
+ { _TOKEN(TN_DMTND_DefaultValue, 0x12, "DefaultValue")},
+ { _TOKEN(TN_DMTND_Delete, 0x13, "Delete")},
+ { _TOKEN(TN_DMTND_Description, 0x14, "Description")},
+ { _TOKEN(TN_DMTND_DFFormat, 0x15, "DFFormat")},
+ { _TOKEN(TN_DMTND_DFProperties, 0x16, "DFProperties")},
+ { _TOKEN(TN_DMTND_DFTitle, 0x17, "DFTitle")},
+ { _TOKEN(TN_DMTND_DFType, 0x18, "DFType")},
+ { _TOKEN(TN_DMTND_Dynamic, 0x19, "Dynamic")},
+ { _TOKEN(TN_DMTND_Exec, 0x1A, "Exec")},
+ { _TOKEN(TN_DMTND_float, 0x1B, "float")},
+ { _TOKEN(TN_DMTND_Format, 0x1C, "Format")},
+ { _TOKEN(TN_DMTND_Get, 0x1D, "Get")},
+ { _TOKEN(TN_DMTND_int, 0x1E, "int")},
+ { _TOKEN(TN_DMTND_Man, 0x1F, "Man")},
+ { _TOKEN(TN_DMTND_MgmtTree, 0x20, "MgmtTree")},
+ { _TOKEN(TN_DMTND_MIME, 0x21, "MIME")},
+ { _TOKEN(TN_DMTND_Mod, 0x22, "Mod")},
+ { _TOKEN(TN_DMTND_Name, 0x23, "Name")},
+ { _TOKEN(TN_DMTND_Node, 0x24, "Node")},
+ { _TOKEN(TN_DMTND_node, 0x25, "node")},
+ { _TOKEN(TN_DMTND_NodeName, 0x26, "NodeName")},
+ { _TOKEN(TN_DMTND_null, 0x27, "null")},
+ { _TOKEN(TN_DMTND_Occurrence, 0x28, "Occurrence")},
+ { _TOKEN(TN_DMTND_One, 0x29, "One")},
+ { _TOKEN(TN_DMTND_OneOrMore, 0x2A, "OneOrMore")},
+ { _TOKEN(TN_DMTND_OneOrN, 0x2B, "OneOrN")},
+ { _TOKEN(TN_DMTND_Path, 0x2C, "Path")},
+ { _TOKEN(TN_DMTND_Permanent, 0x2D, "Permanent")},
+ { _TOKEN(TN_DMTND_Replace, 0x2E, "Replace")},
+ { _TOKEN(TN_DMTND_RTProperties, 0x2F, "RTProperties")},
+ { _TOKEN(TN_DMTND_Scope, 0x30, "Scope")},
+ { _TOKEN(TN_DMTND_Size, 0x31, "Size")},
+ { _TOKEN(TN_DMTND_time, 0x32, "time")},
+ { _TOKEN(TN_DMTND_Title, 0x33, "Title")},
+ { _TOKEN(TN_DMTND_TStamp, 0x34, "TStamp")},
+ { _TOKEN(TN_DMTND_Type, 0x35, "Type")},
+ { _TOKEN(TN_DMTND_Value, 0x36, "Value")},
+ { _TOKEN(TN_DMTND_VerDTD, 0x37, "VerDTD")},
+ { _TOKEN(TN_DMTND_VerNo, 0x38, "VerNo")},
+ { _TOKEN(TN_DMTND_xml, 0x39, "xml")},
+ { _TOKEN(TN_DMTND_ZeroOrMore, 0x3A, "ZeroOrMore")},
+ { _TOKEN(TN_DMTND_ZeroOrN, 0x3B, "ZeroOrN")},
+ { _TOKEN(TN_DMTND_ZeroOrOne, 0x3C, "ZeroOrOne") }
+ };
+ #endif
+
+ #ifndef NOWSM
+ _tmpTagPtr = NULL;
+ pGA = mgrGetSyncMLAnchor();
+ if (pGA == NULL) return NULL;
+ #endif
+
+ /* get the correct codepage */
+ if (ext == SML_EXT_UNDEFINED) {
+ #ifndef NOWSM
+ _tmpTagPtr = pGA->tokTbl->SyncML;
+ if (_tmpTagPtr == NULL) {
+ mySize = sizeof(syncml);
+ pGA->tokTbl->SyncML = (TagPtr_t)smlLibMalloc(mySize);
+ if (pGA->tokTbl->SyncML == NULL) return NULL;
+ smlLibMemcpy(pGA->tokTbl->SyncML, &syncml, mySize);
+ _tmpTagPtr = pGA->tokTbl->SyncML;
+ }
+ #else
+ _tmpTagPtr=(TagPtr_t)syncml;
+ #endif
+ }
+
+ #ifdef __USE_METINF__
+ else if (ext == SML_EXT_METINF) {
+ #ifndef NOWSM
+ _tmpTagPtr = pGA->tokTbl->MetInf;
+ if (_tmpTagPtr == NULL) {
+ mySize = sizeof(metinf);
+ pGA->tokTbl->MetInf = (TagPtr_t)smlLibMalloc(mySize);
+ if (pGA->tokTbl->MetInf == NULL) return NULL;
+ smlLibMemcpy(pGA->tokTbl->MetInf, &metinf, mySize);
+ _tmpTagPtr = pGA->tokTbl->MetInf;
+ }
+ #else
+ _tmpTagPtr=(TagPtr_t)metinf;
+ #endif
+ }
+ #endif
+
+ #ifdef __USE_DEVINF__
+ else if (ext == SML_EXT_DEVINF) {
+ #ifndef NOWSM
+ _tmpTagPtr = pGA->tokTbl->DevInf;
+ if (_tmpTagPtr == NULL) {
+ mySize = sizeof(devinf);
+ pGA->tokTbl->DevInf = (TagPtr_t)smlLibMalloc(mySize);
+ if (pGA->tokTbl->DevInf == NULL) return NULL;
+ smlLibMemcpy(pGA->tokTbl->DevInf, &devinf, mySize);
+ _tmpTagPtr = pGA->tokTbl->DevInf;
+ }
+ #else
+ _tmpTagPtr=(TagPtr_t)devinf;
+ #endif
+ }
+ #endif
+
+ #ifdef __USE_DMTND__
+ else if (ext == SML_EXT_DMTND) {
+ #ifndef NOWSM
+ _tmpTagPtr = pGA->tokTbl->DmTnd;
+ if (_tmpTagPtr == NULL) {
+ mySize = sizeof(dmtnd);
+ pGA->tokTbl->DmTnd = (TagPtr_t)smlLibMalloc(mySize);
+ if (pGA->tokTbl->DmTnd == NULL) return NULL;
+ smlLibMemcpy(pGA->tokTbl->DmTnd, &dmtnd, mySize);
+ _tmpTagPtr = pGA->tokTbl->DmTnd;
+ }
+ #else
+ _tmpTagPtr=(TagPtr_t)dmtnd;
+ #endif
+ }
+ #endif
+
+ return _tmpTagPtr;
+}
+
+#undef _TOKEN // we don't need that macro any longer
+
+/**
+ * FUNCTION: getTagString
+ *
+ * Returns a tag string which belongs to a tag ID.
+ * This function is needed for the XML encoding
+ *
+ * PRE-Condition: valid tag ID, the tagSring has to be allocated
+ *
+ * POST-Condition: tag string is returned
+ *
+ * IN: tagId, the ID for the tag
+ *
+ * IN/OUT: tagString, allocated string into which the XML
+ * tag string will be written
+ *
+ * RETURN: 0,if OK
+ */
+#ifdef __SML_XML__
+Ret_t getTagString(XltTagID_t tagID, String_t tagString, SmlPcdataExtension_t ext)
+{
+ int i = 0;
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL) {
+ tagString[0] = '\0';
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pTags+i)->id) != TN_UNDEF) {
+ if ((((pTags+i)->id) == tagID)) {
+ String_t _tmp = (pTags+i)->xml;
+ smlLibStrcpy(tagString, _tmp);
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ //smlLibStrcpy(tagString, '\0');
+ tagString[0] = '\0';
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+#endif
+
+/**
+ * FUNCTION: getTagByte
+ *
+ * Returns a WBXML byte which belongs to a tag ID in a defined codepage.
+ * This function is needed for the WBXML encoding
+ *
+ * PRE-Condition: valid tag ID, valid code page
+ *
+ * POST-Condition: tag byte is returned
+ *
+ * IN: tagId, the ID for the tag
+ * cp, code page group for the tag
+ * pTagByte, the byte representation of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getTagByte(XltTagID_t tagID, SmlPcdataExtension_t ext, Byte_t *pTagByte)
+{
+ int i = 0;
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL)
+ {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pTags+i)->id) != TN_UNDEF)
+ {
+ if (((pTags+i)->id) == tagID)
+ {
+ *pTagByte = (pTags+i)->wbxml;
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ *pTagByte = 0;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+/**
+ * FUNCTION: getCodePage
+ *
+ * Returns the code page which belongs to a certain PCDATA extension type.
+ *
+ * PRE-Condition: valid PCDATA extension type
+ *
+ * POST-Condition: the code page is returned
+ *
+ * IN: ext, the PCDATA extension type
+ *
+ * RETURN: the code page
+ */
+Byte_t getCodePage(SmlPcdataExtension_t ext)
+{
+ #ifdef __USE_DMTND__
+ if (ext == SML_EXT_DMTND)
+ return 2;
+ #endif
+ #ifdef __USE_METINF__
+ if (ext == SML_EXT_METINF)
+ return 1;
+ #endif
+ #ifdef __USE_DEVINF__
+ if (ext == SML_EXT_DEVINF)
+ return 0;
+ #endif
+ return 0;
+}
+
+/**
+ * FUNCTION: getCodePageById
+ *
+ * Returns the codepage which belongs to a certain tag ID
+ *
+ * PRE-Condition: valid tag ID
+ *
+ * POST-Condition: the code page is returned
+ *
+ * IN: tagID, the ID of the tag
+ * pCp, the codepage/extention of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getExtById(XltTagID_t tagID, SmlPcdataExtension_t *pExt)
+{
+ int i = 0;
+ SmlPcdataExtension_t ext;
+ /* Iterate over all defined extensions to find the corresponding TAG.
+ * Empty extensions, e.g. not defined numbers will be skipped.
+ */
+ for (ext = SML_EXT_UNDEFINED; ext < SML_EXT_LAST; ext++) {
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL) {
+ continue; /* skip empty codepage */
+ }
+ i = 0;
+ while (((pTags+i)->id) != TN_UNDEF) {
+ if ((((pTags+i)->id) == tagID)){
+ *pExt = ext;
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ }
+ /* tag not found in any extension */
+ *pExt = (SmlPcdataExtension_t)255;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+/**
+ * FUNCTION: getTagIDByStringAndCodepage
+ *
+ * Returns the tag ID which belongs to a tag string in a certain codepage
+ *
+ * PRE-Condition: valid tag string, valid code page
+ *
+ * POST-Condition: tag id is returned
+ *
+ * IN: tag, the string representation of the tag
+ * cp, code page group for the tag
+ * pTagID, the tag id of the tag
+ *
+ * RETURN: 0, if OK
+ */
+
+Ret_t getTagIDByStringAndExt(String_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID)
+{
+ int i = 0;
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ for (i=0;((pTags+i)->id) != TN_UNDEF; i++) {
+ if (*(pTags+i)->xml != *tag) continue; // if the first char doesn't match we skip the strcmp to speed things up
+ if (smlLibStrcmp(((pTags+i)->xml), tag) == 0) {
+ *pTagID = (pTags+i)->id;
+ return SML_ERR_OK;
+ }
+ }
+ *pTagID = TN_UNDEF;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+/**
+ * FUNCTION: getTagIDByByteAndCodepage
+ *
+ * Returns the tag ID which belongs to a tag byte in a certain codepage
+ *
+ * PRE-Condition: valid tag byte, valid code page
+ *
+ * POST-Condition: tag id is returned
+ *
+ * IN: tag, the byte representation of the tag
+ * cp, code page group for the tag
+ * pTagID, the tag id of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getTagIDByByteAndExt(Byte_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID)
+{
+
+ int i = 0;
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL)
+ {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pTags+i)->id) != TN_UNDEF)
+ {
+ if (((pTags+i)->wbxml) == tag)
+ {
+ *pTagID = (pTags+i)->id;
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ *pTagID = TN_UNDEF;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+/**
+ * FUNCTION: getTagIDByStringAndNamespace
+ *
+ * Returns the tag ID which belongs to a tag string in a certain namespace
+ *
+ * PRE-Condition: valid tag string, valid namespace
+ *
+ * POST-Condition: tag id is returned
+ *
+ * IN: tag, the string representation of the tag
+ * ns, namespace group for the tag
+ * pTagID, the tag id of the tag
+ *
+ * RETURN: 0, if OK
+ */
+#ifdef __SML_XML__
+Ret_t getTagIDByStringAndNamespace(String_t tag, String_t ns, XltTagID_t *pTagID)
+{
+ int i = 0;
+ TagPtr_t pTags = getTagTable(getExtByName(ns));
+ if (pTags == NULL)
+ {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pTags+i)->id) != TN_UNDEF)
+ {
+ if ((smlLibStrcmp(((pTags+i)->xml), tag) == 0))
+ {
+ *pTagID = (pTags+i)->id;
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ *pTagID = TN_UNDEF;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttags.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttags.h
new file mode 100644
index 0000000..6108b60
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttags.h
@@ -0,0 +1,376 @@
+/*************************************************************************/
+/* module: Definition of WBXML/XML tags for the en-/decoder */
+/* file: XLTTags.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#ifndef _XLT_TAGS_H
+#define _XLT_TAGS_H
+
+#include <smldtd.h>
+#include <smldef.h>
+
+#define XML_MAX_TAGLEN 35
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+// Tag IDs
+typedef enum {
+ TN_UNDEF = 0,
+
+ TN_ADD,
+ TN_ALERT,
+ TN_ARCHIVE,
+ TN_ATOMIC,
+ TN_ATOMIC_END, /* 5 */
+ TN_CHAL,
+ TN_CMD,
+ TN_CMDID,
+ TN_CMDREF,
+ TN_COPY, /* 10 */
+ TN_CRED,
+ TN_DATA,
+ TN_DELETE,
+ TN_EXEC,
+ TN_FINAL, /* 15 */
+ TN_GET,
+ TN_ITEM,
+ TN_LANG,
+ TN_LOCNAME,
+ TN_LOCURI, /* 20 */
+ TN_MAP,
+ TN_MAPITEM,
+ TN_META,
+ TN_MSGID,
+ TN_MSGREF, /* 25 */
+ TN_NORESP,
+ TN_NORESULTS,
+ TN_PUT,
+ TN_REPLACE,
+ TN_RESPURI, /* 30 */
+ TN_RESULTS,
+ TN_SEARCH,
+ TN_SEQUENCE,
+ TN_SEQUENCE_END,
+ TN_SESSIONID, /* 35 */
+ TN_SFTDEL,
+ TN_SOURCE,
+ TN_SOURCEREF,
+ TN_STATUS,
+ TN_SYNC, /* 40 */
+ TN_SYNCBODY,
+ TN_SYNCHDR,
+ TN_SYNCML,
+ TN_SYNC_END,
+ TN_TARGET, /* 45 */
+ TN_TARGETREF,
+ TN_VERSION,
+ TN_PROTO,
+ TN_METINF_ANCHOR,
+ TN_METINF_EMI, /* 50 */
+ TN_METINF_FORMAT,
+ TN_METINF_FREEID,
+ TN_METINF_FREEMEM,
+ TN_METINF_LAST,
+ TN_METINF_MARK, /* 55 */
+ TN_METINF_MAXMSGSIZE,
+ TN_METINF_MEM,
+ TN_METINF_METINF,
+ TN_METINF_NEXT,
+ TN_METINF_NEXTNONCE, /* 60 */
+ TN_METINF_SHAREDMEM,
+ TN_METINF_SIZE,
+ TN_METINF_TYPE,
+ TN_METINF_VERSION,
+ TN_DEVINF_CTCAP, /* 65 */
+ TN_DEVINF_CTTYPE,
+ TN_DEVINF_DATASTORE,
+ TN_DEVINF_DATATYPE,
+ TN_DEVINF_DEVID,
+ TN_DEVINF_DEVINF, /* 70 */
+ TN_DEVINF_DEVTYP,
+ TN_DEVINF_DISPLAYNAME,
+ TN_DEVINF_DSMEM,
+ TN_DEVINF_EXT,
+ TN_DEVINF_FWV, /* 75 */
+ TN_DEVINF_HWV,
+ TN_DEVINF_MAN,
+ TN_DEVINF_MAXGUIDSIZE,
+ TN_DEVINF_MAXID,
+ TN_DEVINF_MAXMEM, /* 80 */
+ TN_DEVINF_MOD,
+ TN_DEVINF_OEM,
+ TN_DEVINF_PARAMNAME,
+ TN_DEVINF_PROPNAME,
+ TN_DEVINF_RX, /* 85 */
+ TN_DEVINF_RXPREF,
+ TN_DEVINF_SHAREDMEM,
+ TN_DEVINF_SIZE,
+ TN_DEVINF_SOURCEREF,
+ TN_DEVINF_SWV, /* 90 */
+ TN_DEVINF_SYNCCAP,
+ TN_DEVINF_SYNCTYPE,
+ TN_DEVINF_TX,
+ TN_DEVINF_TXPREF,
+ TN_DEVINF_VALENUM, /* 95 */
+ TN_DEVINF_VERCT,
+ TN_DEVINF_VERDTD,
+ TN_DEVINF_XNAM,
+ TN_DEVINF_XVAL,
+ /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+ TN_NUMBEROFCHANGES, /* 100 */
+ TN_MOREDATA,
+ TN_METINF_MAXOBJSIZE,
+ TN_DEVINF_UTC,
+ TN_DEVINF_NOFM,
+ TN_DEVINF_LARGEOBJECT,
+ TN_CORRELATOR,
+ /* TNDS - 08/05/2008, Ken Chen(e50324) Motorola Inc., OMA-TS-DM_TND-V1_2_1-20080617-A */
+ TN_DMTND_AccessType, /* 107 */
+ TN_DMTND_ACL,
+ TN_DMTND_Add,
+ TN_DMTND_b64, /* 110 */
+ TN_DMTND_bin,
+ TN_DMTND_bool,
+ TN_DMTND_chr,
+ TN_DMTND_CaseSense,
+ TN_DMTND_CIS,
+ TN_DMTND_Copy,
+ TN_DMTND_CS,
+ TN_DMTND_date,
+ TN_DMTND_DDFName,
+ TN_DMTND_DefaultValue, /* 120 */
+ TN_DMTND_Delete,
+ TN_DMTND_Description,
+ TN_DMTND_DFFormat,
+ TN_DMTND_DFProperties,
+ TN_DMTND_DFTitle,
+ TN_DMTND_DFType,
+ TN_DMTND_Dynamic,
+ TN_DMTND_Exec,
+ TN_DMTND_float,
+ TN_DMTND_Format, /* 130 */
+ TN_DMTND_Get,
+ TN_DMTND_int,
+ TN_DMTND_Man,
+ TN_DMTND_MgmtTree,
+ TN_DMTND_MIME,
+ TN_DMTND_Mod,
+ TN_DMTND_Name,
+ TN_DMTND_Node,
+ TN_DMTND_node,
+ TN_DMTND_NodeName, /* 140 */
+ TN_DMTND_null,
+ TN_DMTND_Occurrence,
+ TN_DMTND_One,
+ TN_DMTND_OneOrMore,
+ TN_DMTND_OneOrN,
+ TN_DMTND_Path,
+ TN_DMTND_Permanent,
+ TN_DMTND_Replace,
+ TN_DMTND_RTProperties,
+ TN_DMTND_Scope, /* 150 */
+ TN_DMTND_Size,
+ TN_DMTND_time,
+ TN_DMTND_Title,
+ TN_DMTND_TStamp,
+ TN_DMTND_Type,
+ TN_DMTND_Value,
+ TN_DMTND_VerDTD,
+ TN_DMTND_VerNo,
+ TN_DMTND_xml,
+ TN_DMTND_ZeroOrMore, /* 160 */
+ TN_DMTND_ZeroOrN,
+ TN_DMTND_ZeroOrOne
+} XltTagID_t;
+
+
+extern const char * const SyncMLNamespaces[SML_NUM_VERS];
+
+typedef struct Dtd_s
+{
+ String_t name;
+ SmlPcdataExtension_t ext;
+} Dtd_t, *DtdPtr_t;
+
+
+/**
+ * FUNCTION: getTagString
+ *
+ * Returns a tag string which belongs to a tag ID.
+ * This function is needed for the XML encoding
+ *
+ * PRE-Condition: valid tag ID, the tagSring has to be allocated
+ *
+ * POST-Condition: tag string is returned
+ *
+ * IN: tagId, the ID for the tag
+ *
+ * IN/OUT: tagString, allocated string into which the XML
+ * tag string will be written
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getTagString(XltTagID_t tagID, String_t tagString, SmlPcdataExtension_t ext);
+
+#ifdef __SML_WBXML__
+/**
+ * FUNCTION: getTagByte
+ *
+ * Returns a WBXML byte which belongs to a tag ID in a defined codepage.
+ * This function is needed for the WBXML encoding
+ *
+ * PRE-Condition: valid tag ID, valid code page
+ *
+ * POST-Condition: tag byte is returned
+ *
+ * IN: tagId, the ID for the tag
+ * cp, code page group for the tag
+ * tagByte, the byte representation of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getTagByte(XltTagID_t tagID, SmlPcdataExtension_t ext, Byte_t *tagByte);
+#endif
+
+/**
+ * FUNCTION: getCodePage
+ *
+ * Returns the code page which belongs to a certain PCDATA extension type.
+ *
+ * PRE-Condition: valid PCDATA extension type
+ *
+ * POST-Condition: the code page is returned
+ *
+ * IN: ext, the PCDATA extension type
+ *
+ * RETURN: the code page
+ */
+Byte_t getCodePage(SmlPcdataExtension_t ext);
+
+/**
+ * FUNCTION: getTagIDByStringAndCodepage
+ *
+ * Returns the tag ID which belongs to a tag string in a certain codepage
+ *
+ * PRE-Condition: valid tag string, valid code page
+ *
+ * POST-Condition: tag id is returned
+ *
+ * IN: tag, the string representation of the tag
+ * cp, code page group for the tag
+ * pTagID, the tag id of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getTagIDByStringAndExt(String_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID);
+
+#ifdef __SML_WBXML__
+/**
+ * FUNCTION: getTagIDByByteAndCodepage
+ *
+ * Returns the tag ID which belongs to a tag byte in a certain codepage
+ *
+ * PRE-Condition: valid tag byte, valid code page
+ *
+ * POST-Condition: tag id is returned
+ *
+ * IN: tag, the byte representation of the tag
+ * cp, code page group for the tag
+ * pTagID, the tag id of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getTagIDByByteAndExt(Byte_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID);
+#endif
+
+
+#ifdef __SML_XML__
+/**
+ * FUNCTION: getTagIDByStringAndNamespace
+ *
+ * Returns the tag ID which belongs to a tag string in a certain namespace
+ *
+ * PRE-Condition: valid tag string, valid namespace
+ *
+ * POST-Condition: tag id is returned
+ *
+ * IN: tag, the string representation of the tag
+ * ns, namespace group for the tag
+ * pTagID, the tag id of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getTagIDByStringAndNamespace(String_t tag, String_t ns, XltTagID_t *pTagID);
+#endif
+
+/**
+ * FUNCTION: getCodePageById
+ *
+ * Returns the codepage which belongs to a certain tag ID
+ *
+ * PRE-Condition: valid tag ID
+ *
+ * POST-Condition: the code page is returned
+ *
+ * IN: tagID, the ID of the tag
+ * pCp, the codepage of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getExtById(XltTagID_t tagID, SmlPcdataExtension_t *pExt);
+
+// %%% luz:2003-07-31: added vers parameter
+Ret_t getExtName(SmlPcdataExtension_t ext, String_t *name, SmlVersion_t vers);
+Ret_t getTagIDByStringAndExt(String_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID);
+SmlPcdataExtension_t getExtByName(String_t ns);
+
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttagtbl.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttagtbl.h
new file mode 100644
index 0000000..4f5251a
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xlttagtbl.h
@@ -0,0 +1,116 @@
+/*************************************************************************/
+/* module: Definition of en-/decoder tagtable data */
+/* file: XLTTagtbl.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#ifndef _XLT_TAGTBL_H
+#define _XLT_TAGTBL_H
+
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xlttags.h"
+#include "xltdec.h"
+#include "xltdeccom.h"
+
+typedef struct Tag_s
+{
+ XltTagID_t id;
+ Byte_t wbxml;
+ String_t xml;
+} Tag_t, *TagPtr_t;
+
+/**
+ * FUNCTION: buildXXX
+ *
+ * These functions each decode one single SyncML element starting at the
+ * current position within the SyncML document. Child elements are build
+ * recursively.
+ * The functions check that the pointer to the memory structures are
+ * NULL when called and return an error otherwise. This will only happen
+ * when a SyncML element contains several child elements of the same type
+ * for which this is not allowed according to the SyncML DTD; e.g. a
+ * SyncHdr with two or more MsgID tags. Items and other list types
+ * are handled separately by the appendXXXList functions (see below).
+ *
+ * PRE-Condition:
+ * ppElem is NULL
+ * The scanner's current token is the start tag (may be
+ * empty) of the SyncML element to be decoded.
+ *
+ * POST-Condition:
+ * The scanner's current token is the end tag (or empty
+ * start tag) of the SyncML element to be decoded.
+ */
+/* implemented in xltdec.c! */
+Ret_t buildAlert(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+#if (defined ATOMIC_RECEIVE || defined SEQUENCE_RECEIVE)
+Ret_t buildAtomOrSeq(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+#endif
+Ret_t buildChal(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildCred(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDelete(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildExec(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildGenericCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildItem(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildMap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildMapItem(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildPCData(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildPCDataList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppPCData);
+Ret_t buildPutOrGet(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildResults(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+#ifdef SEARCH_RECEIVE
+Ret_t buildSearch(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+#endif
+Ret_t buildStatus(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildSync(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildSyncHdr(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildTargetOrSource(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+
+#ifdef NOWSM
+const // without WSM, the tag table is a global read-only constant
+#endif
+TagPtr_t getTagTable(SmlPcdataExtension_t cp);
+
+#endif /* _XLT_TAGTBL_H */
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltutilstack.c b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltutilstack.c
new file mode 100644
index 0000000..1172379
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltutilstack.c
@@ -0,0 +1,205 @@
+/*************************************************************************/
+/* module: XLT Decoder Stack */
+/* file: XLTUtilStack.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * A simple array-based stack implementation.
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xltdeccom.h"
+#include "xltutilstack.h"
+
+#include <smlerr.h>
+
+#include <libmem.h>
+
+struct ArrayStack_s;
+typedef struct ArrayStack_s *ArrayStackPtr_t, ArrayStack_t;
+struct ArrayStack_s
+{
+ /* public */
+ Ret_t (*top)(const XltUtilStackPtr_t, XltUtilStackItem_t *);
+ Ret_t (*pop)(XltUtilStackPtr_t, XltUtilStackItem_t *);
+ Ret_t (*push)(XltUtilStackPtr_t, const XltUtilStackItem_t);
+ Ret_t (*destroy)(XltUtilStackPtr_t);
+
+ /* private */
+ Long_t topidx; // index of the top of the stack
+ Long_t size; // size of the stack (multiple of chunksize)
+ Long_t chunksize; // size of memory chunks allocated at a time
+ XltUtilStackItem_t *array; // the stack itself
+};
+
+static Ret_t _top(const XltUtilStackPtr_t, XltUtilStackItem_t *);
+static Ret_t _pop(XltUtilStackPtr_t, XltUtilStackItem_t *);
+static Ret_t _push(XltUtilStackPtr_t, const XltUtilStackItem_t);
+static Ret_t _destroy(XltUtilStackPtr_t);
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+Ret_t
+xltUtilCreateStack(XltUtilStackPtr_t *ppStack, const Long_t size)
+{
+ ArrayStackPtr_t pStack;
+
+ if (size <= 0)
+ return SML_ERR_WRONG_PARAM;
+ if ((pStack = (ArrayStackPtr_t)smlLibMalloc(sizeof(ArrayStack_t))) == NULL) {
+ *ppStack = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ pStack->top = _top;
+ pStack->pop = _pop;
+ pStack->push = _push;
+ pStack->destroy = _destroy;
+ pStack->topidx = -1;
+ pStack->size = size;
+ pStack->chunksize = size;
+ pStack->array = NULL;
+ if ((pStack->array = (XltUtilStackItem_t*)smlLibMalloc(size * sizeof(XltUtilStackItem_t))) == NULL) {
+ *ppStack = NULL;
+ smlLibFree(pStack);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ *ppStack = (XltUtilStackPtr_t)pStack;
+
+
+
+ return SML_ERR_OK;
+}
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+static Ret_t
+_top(const XltUtilStackPtr_t pStack, XltUtilStackItem_t *itemPtr)
+{
+ ArrayStackPtr_t pStackPriv = (ArrayStackPtr_t)pStack;
+
+ if (pStackPriv->topidx == -1)
+ return SML_ERR_WRONG_USAGE;
+
+ *itemPtr = pStackPriv->array[pStackPriv->topidx];
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+_pop(XltUtilStackPtr_t pStack, XltUtilStackItem_t *itemPtr)
+{
+ ArrayStackPtr_t pStackPriv = (ArrayStackPtr_t)pStack;
+ XltUtilStackItem_t item;
+
+ if (pStackPriv->topidx == -1)
+ return SML_ERR_WRONG_USAGE;
+
+ item = pStackPriv->array[pStackPriv->topidx];
+ pStackPriv->topidx--;
+
+ if ((pStackPriv->topidx >= 0) &&
+ (pStackPriv->topidx < pStackPriv->size - pStackPriv->chunksize)) {
+ Long_t newsize;
+ XltUtilStackItem_t *newarray;
+
+ newsize = pStackPriv->size - pStackPriv->chunksize;
+ if ((newarray = (XltUtilStackItem_t*)smlLibRealloc(pStackPriv->array,
+ newsize * sizeof(XltUtilStackItem_t))) != NULL) {
+ pStackPriv->size = newsize;
+ pStackPriv->array = newarray;
+ } else {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ }
+
+ *itemPtr = item;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+_push(XltUtilStackPtr_t pStack, const XltUtilStackItem_t item)
+{
+ ArrayStackPtr_t pStackPriv = (ArrayStackPtr_t)pStack;
+
+ if (pStackPriv->topidx == pStackPriv->size - 1) {
+ Long_t newsize;
+ XltUtilStackItem_t *newarray;
+
+ newsize = pStackPriv->size + pStackPriv->chunksize;
+ if ((newarray = (XltUtilStackItem_t*)smlLibRealloc(pStackPriv->array,
+ newsize * sizeof(XltUtilStackItem_t))) != NULL) {
+ pStackPriv->size = newsize;
+ pStackPriv->array = newarray;
+ } else {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ }
+
+ pStackPriv->topidx++;
+ pStackPriv->array[pStackPriv->topidx] = item;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+_destroy(XltUtilStackPtr_t pStack)
+{
+ ArrayStackPtr_t pStackPriv;
+
+ if (pStack == NULL)
+ return SML_ERR_OK;
+
+ pStackPriv = (ArrayStackPtr_t)pStack;
+
+ smlLibFree(pStackPriv->array);
+ smlLibFree(pStackPriv);
+ return SML_ERR_OK;
+}
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltutilstack.h b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltutilstack.h
new file mode 100644
index 0000000..1e48646
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xlt/src/xltutilstack.h
@@ -0,0 +1,174 @@
+/*************************************************************************/
+/* module: XLT Decoder Util */
+/* file: XLTUtilStack.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * Header file for a simple stack implementation used by the WBXML scanner
+ * and the SyncML parser.
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#ifndef _XLT_UTIL_STACK_H
+#define _XLT_UTIL_STACK_H
+
+#include "xlttags.h"
+#include <smldef.h>
+
+/* type for stack elements */
+typedef XltTagID_t XltUtilStackItem_t;
+
+/**
+ * XLTUtilStack interface
+ *
+ * Like the WBXML/XML scanner, this stack implementation tries to emulate
+ * an object-oriented interface. It consist of one stack structure that
+ * contains the public methods and attributes and another private stack
+ * structure that is not visible to the users of the stack. A stack object
+ * has the following public methods:
+ *
+ * FUNCTION: top
+ *
+ * Returns the top element of the stack.
+ *
+ * PRE-Condition:
+ * the stack contains at least one element
+ *
+ * POST-Condition:
+ *
+ * IN: the stack
+ *
+ * OUT: the top element of the stack
+ *
+ * IN/OUT:
+ *
+ * RETURNS: SML_ERR_WRONG_USAGE, if the stack is empty
+ * SML_ERR_OK, else
+ *
+ * FUNCTION: pop
+ *
+ * Returns the top element and takes it off the stack.
+ *
+ * PRE-Condition:
+* the stack contains at least one element
+*
+* POST-Condition:
+* the top element of the stack is removed
+*
+* IN:
+*
+* OUT: the top element of the stack
+*
+* IN/OUT: the stack
+*
+* RETURNS: SML_ERR_WRONG_USAGE, if the stack is empty
+* SML_ERR_NOT_ENOUGH_SPACE, if memory reallocation failed
+* SML_ERR_OK, else
+*
+* FUNCTION: push
+*
+* Put a new element on top of the stack.
+*
+* PRE-Condition:
+*
+* POST-Condition:
+* popping the stack yields the same stack as before
+* the push
+*
+* IN: the new stack element
+*
+* OUT:
+*
+* IN/OUT: the stack
+*
+* RETURNS: SML_ERR_NOT_ENOUGH_SPACE, if memory reallocation failed
+* SML_ERR_OK, else
+*
+* FUNCTION: destroy
+*
+* Free the memory used by the stack.
+*
+* PRE-Condition:
+* POST-Condition:
+*
+* IN:
+*
+* OUT:
+*
+* IN/OUT: the stack
+*
+* RETURNS: SML_ERR_OK
+*/
+typedef struct XltUtilStack_s *XltUtilStackPtr_t, XltUtilStack_t;
+struct XltUtilStack_s
+{
+ Ret_t (*top)(const XltUtilStackPtr_t, XltUtilStackItem_t *);
+ Ret_t (*pop)(XltUtilStackPtr_t, XltUtilStackItem_t *);
+ Ret_t (*push)(XltUtilStackPtr_t, const XltUtilStackItem_t);
+ Ret_t (*destroy)(XltUtilStackPtr_t);
+};
+
+/**
+ * FUNCTION: xltUtilCreateStack
+ *
+ * Creates a new stack. The size parameter indicates for how many elements
+ * memory should be allocated initially. This does _not_ mean that you can
+ * not push more than that many element onto the stack - in that case
+ * memory for another size elements is allocated.
+ *
+ * PRE-Condition:
+ * POST-Condition:
+ * the stack pointer points to a new, empty stack
+ *
+ * IN: size, the initial size of the stack
+ *
+ * OUT: a new stack
+ *
+ * IN/OUT:
+ *
+ * RETURNS: SML_ERR_NOT_ENOUGH_SPACE, if memory allocation failed
+ * SML_ERR_OK, else
+ */
+Ret_t xltUtilCreateStack(XltUtilStackPtr_t *, const Long_t size);
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/md5.h b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/md5.h
new file mode 100644
index 0000000..71f00d1
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/md5.h
@@ -0,0 +1,51 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+ */
+
+/* POINTER defines a generic pointer type */
+typedef unsigned char *POINTER;
+
+/* UINT2 defines a two byte word */
+typedef unsigned short int UINT2;
+
+/* UINT4 defines a four byte word */
+typedef unsigned int UINT4;
+
+
+/* MD5 context. */
+typedef struct {
+ UINT4 state[4]; /* state (ABCD) */
+ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ unsigned char buffer[64]; /* input buffer */
+} MD5_CTX;
+
+void smlMD5Init (MD5_CTX *);
+void smlMD5Update (MD5_CTX *, unsigned char *, unsigned int);
+void smlMD5Final (unsigned char [16], MD5_CTX *);
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xpt-b64.h b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xpt-b64.h
new file mode 100644
index 0000000..a5cfbec
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xpt-b64.h
@@ -0,0 +1,169 @@
+/*************************************************************************/
+/* module: Communication Services, base64 encoding/decoding fns.*/
+/* file: /src/xpt/all/xpt-b64.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * function prototypes and return codes
+ * for base64 encoding/ decoding functions.
+ *
+ */
+
+#ifndef XPT_B64_H
+#define XPT_B64_H
+
+#include "xpttypes.h"
+
+/**
+ * FUNCTION: base64GetSize
+ *
+ * Precalculates the size of an encoded document with the given size
+ *
+ * PRE-Condition:
+ * The function is called to get the size of the document that
+ * will be encoded with the base64Encode() service.
+ *
+ * POST-Condition:
+ *
+ * IN: cbRealDataSize, the size of the non-encoded document.
+ *
+ * RETURN: BufferSize_t, the size of the encoded document that will be
+ * generated using the base64Encode() service.
+ *
+ */
+
+BufferSize_t base64GetSize (BufferSize_t cbRealDataSize);
+
+/**
+ * FUNCTION: base64Encode
+ *
+ * Encodes a chunk of data according to the base64 encoding rules
+ *
+ * PRE-Condition:
+ * A chunk of data os copied to the source data buffer pbData, and the
+ * length of the data chunk is specified in *pcbDataLength;
+ *
+ * POST-Condition:
+ * A block of encoded data is available in the specified target buffer.
+ * The length of the encoded data is returned by the function.
+ *
+ *
+ * IN: pbTarget, pointer to an allocated chunk of memory that receives the
+ * encoded data block.
+ * cbTargetSize, size of the data buffer above.
+ * bLast, flag that indicates if the specified block is the last
+ * part of the document. If the value is 0, the funciton expects
+ * that other blocks will follow, a value of 1 indicates that
+ * the data block that is presented in the input buffer is the
+ * last data block to be encoded.
+ * pbSaveBytes, pointer to a block of at least 3 Bytes. When this function
+ * is invoked the first time, the first byte of this buffer MUST
+ * be set to 0.
+ * IN/OUT:
+ * pbData, pointer to a data block that contains the clear data that
+ * are to be encoded. On return, the remaining piece of the
+ * input data block that could not be encoded is copied to
+ * the memory that pbData points at.
+ * pcbDataLength, pointer to a variable that denotes the length of
+ * the data block that is to be encoded, The function updates
+ * this value with the size of the data block that could not
+ * be processed. If all data were able to be encoded, the
+ * value will be 0.
+ * pcbOffset, pointer to a variable that is internally used by the
+ * function. before the first call of base64encode() for a
+ * certain document is made, the variable that pcbOffset points
+ * at must be set to 0. The variable will be updated by the
+ * function, and should not be modified by the caller.
+ * RETURN: BufferSize_t, the size of the data block that are available in
+ * pbTarget.
+ *
+ */
+
+BufferSize_t base64Encode (DataBuffer_t pbTarget,
+ BufferSize_t cbTargetSize,
+ DataBuffer_t pbData,
+ BufferSize_t *pcbDataLength,
+ BufferSize_t *pcbOffset,
+ unsigned int bLast,
+ unsigned char *pbSavebytes);
+/**
+ * FUNCTION: base64Decode
+ *
+ * Decodes a chunk of data according to the base64 encoding rules
+ *
+ * PRE-Condition:
+ * A chunk of data os copied to the source data buffer pbData, and the
+ * length of the data chunk is specified in *pcbDataLength;
+ *
+ * POST-Condition:
+ * A block of decoded data is available in the specified target buffer.
+ * The length of the decoded data is returned by the function.
+ *
+ *
+ * IN: pbTarget, pointer to an allocated chunk of memory that receives the
+ * decoded data block.
+ * cbTargetSize, size of the data buffer above.
+ * IN/OUT:
+ * pbData, pointer to a data block that contains the clear data that
+ * are to be decoded. On return, the remaining piece of the
+ * input data block that could not be decoded is copied to
+ * the memory that pbData points at.
+ * pcbDataLength, pointer to a variable that denotes the length of
+ * the data block that is to be decoded, The function updates
+ * this value with the size of the data block that could not
+ * be processed. If all data were able to be decoded, the
+ * value will be 0.
+ * RETURN: BufferSize_t, the size of the data block that are available in
+ * pbTarget. If some invalid data were detected in the input
+ * data buffer, or if cbTargetSize is less than 3,
+ * the function returns 0. The caller should treat this as an
+ * error condition.
+ *
+ */
+
+BufferSize_t base64Decode (DataBuffer_t pbTarget,
+ BufferSize_t cbTargetSize,
+ DataBuffer_t pbData,
+ BufferSize_t *pcbDataLength);
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xptdef.h b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xptdef.h
new file mode 100644
index 0000000..7d27f47
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xptdef.h
@@ -0,0 +1,93 @@
+/*************************************************************************/
+/* module: SyncML Communication Protocol include file (Windows) */
+/* file: src/xpt/win/xptdef.h */
+/* target system: win */
+/* target OS: win */
+/* Purpose: Define platform-specific values for public header */
+/* files. */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#ifndef XPTDEF_H
+#define XPTDEF_H
+
+#include <stdlib.h> /* For NULL and size_t */
+
+#define XPT_SECTION
+#define XPT_DATA_SECTION
+
+
+
+/* TK: to improve interoperability and handling we
+ * switched to using .def files instead of compiler
+ * specific per function definitions. As long as we only
+ * use C this is the easiest and cleanes way
+ */
+#define XPT_API
+#define XPT_API_DEF
+#define XPTAPI
+#define XPTEXP1 //__declspec(dllexport)
+#define XPTEXP2
+#define XPTDECLEXP1 //__declspec(dllexport)
+
+/* TK: Old, now obsolete code follows here */
+#ifdef FOOBAZZBUMMBAGGEL
+
+#if defined(__IBMC__) || defined(__IBMCPP__)
+ #define XPTAPI __stdcall
+ #define XPTEXP1
+ #define XPTEXP2 _Export
+ #define XPTDECLEXP1
+#else
+ #define XPTAPI __stdcall
+ #define XPTEXP1 __declspec(dllexport)
+ #define XPTEXP2
+
+// #ifdef BUILDING_XPT
+ #ifdef BUILDING_DLL
+ #define XPTDECLEXP1 XPTEXP1
+ #else
+ #define XPTDECLEXP1 __declspec(dllimport)
+ #endif
+#endif
+#endif // FOBAZZBUMMBAGGEL
+
+#define stricmp _stricmp
+#define memicmp _memicmp
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xptport.h b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xptport.h
new file mode 100644
index 0000000..3602be6
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xptport.h
@@ -0,0 +1,183 @@
+/*************************************************************************/
+/* module: SyncML xpt portability header file */
+/* file: src/xpt/inc/xptport.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Isolate here the differences between ANSI string and memory functions and
+ * Palm string and memory functions. Note the sml tree contains similar
+ * mappings, but we avoid those for two reasons:
+ *
+ * 1. They are all implemented as functions, which makes calling them less
+ * efficient, especially on the Palm. Also, if they are implemented as
+ * functions, then the xpt DLL and the DLLs of all transport
+ * implementations must be linked to the sml DLL, which seems unnecessary.
+ *
+ * 2. Even on the Palm, the libstr.h and libmem.h header files include ANSI C
+ * header files like string.h and stdlib.h. These shouldn't be included
+ * on the Palm, because with some compilers, the introduced typedefs
+ * conflict with typedefs from the Palm SDK, causing compilation errors.
+ *
+ * We start the names of these functions with a different prefix so they are
+ * not confused with functions of the official xpt interface. We use "xpp"
+ * here instead of "xpt".
+ */
+
+#ifndef XPTPORT_H
+#define XPTPORT_H
+
+#include <xptdef.h>
+
+/*
+ * If we neglect some of the return values, most of the functions have simple
+ * mappings.
+ */
+#ifdef __PALM_OS__
+
+ /* Palm mappings */
+
+ #include <StringMgr.h>
+ #include <MemoryMgr.h>
+
+ #define xppStrcpy(target, source) StrCopy(target, source)
+ #define xppStrncpy(target, source, cnt) StrNCopy(target, source, cnt)
+ #define xppStrcat(target, source) StrCat(target, source)
+ #define xppStrncat(target, source, cnt) StrNCat(target, source, cnt)
+ #define xppStrcmp(first, second) StrCompare(first, second)
+ #define xppStrncmp(first, second, cnt) StrNCompare(first, second, cnt)
+ #define xppStrchr(string, c) StrChr(string, c)
+ #define xppStrstr(string, substr) StrStr(string, substr)
+ #define xppStrlen(string) StrLen(string)
+ #define xppAtoi(string) StrAToI(string)
+
+ #define xppMemset(s, c, n) MemSet(s, n, c)
+ #define xppMemcpy(target, source, cnt) MemMove(target, source, cnt)
+ #define xppMemmove(target, source, cnt) MemMove(target, source, cnt)
+ #define xppMemcmp(target, source, cnt) MemCmp(target, source, cnt)
+ #define xppMalloc(size) MemPtrNew(size)
+ XPTDECLEXP1 void * XPTAPI xppRealloc(void *ptr, size_t size) XPT_SECTION;
+ #define xppFree(ptr) MemPtrFree(ptr)
+
+ #define xppStricmp(first, second) StrCaselessCompare(first, second)
+ #define xppMemicmp(first, second, cnt) StrNCaselessCompare(first, second, cnt)
+
+#endif
+#if !defined(__EPOC_OS__) && !defined(__PALM_OS__)
+
+ /* ANSI C mappings */
+
+ #include <string.h>
+ #include <stdlib.h>
+
+ #define xppStrcpy(target, source) strcpy(target, source)
+ #define xppStrncpy(target, source, cnt) strncpy(target, source, cnt)
+ #define xppStrcat(target, source) strcat(target, source)
+ #define xppStrncat(target, source, cnt) strncat(target, source, cnt)
+ #define xppStrcmp(first, second) strcmp(first, second)
+ #define xppStrncmp(first, second, cnt) strncmp(first, second, cnt)
+ #define xppStrchr(string, c) strchr(string, c)
+ #define xppStrstr(string, substr) strstr(string, substr)
+ #define xppStrlen(string) strlen(string)
+ #define xppAtoi(string) atoi(string)
+
+ #define xppMemset(s, c, n) memset(s, c, n)
+ #define xppMemcpy(target, source, cnt) memcpy(target, source, cnt)
+ #define xppMemmove(target, source, cnt) memmove(target, source, cnt)
+ #define xppMemcmp(target, source, cnt) memcmp(target, source, cnt)
+ #define xppMalloc(size) malloc(size)
+ #define xppRealloc(ptr, size) realloc(ptr, size)
+ #define xppFree(ptr) free(ptr)
+
+ /* These aren't ANSI C functions, but they're pretty common */
+
+ #ifdef _WIN32
+ #define xppStricmp(first, second) stricmp(first, second)
+ #endif
+
+ /* Most other systems call it strcasecmp */
+ #ifndef xppStricmp
+ #define xppStricmp(first, second) strcasecmp(first, second)
+ #endif
+
+ #ifdef _WIN32
+ #define xppMemicmp(first, second, cnt) memicmp(first, second, cnt)
+ #endif
+
+ #ifndef xppMemicmp
+ #define xppMemicmp(first, second, cnt) strncasecmp(first, second, cnt)
+ #endif
+
+#endif
+
+#if defined(__EPOC_OS__)
+
+/* EPOC mappings */
+
+#include <string.h>
+#include <stdlib.h>
+
+#define xppStrcpy(target, source) strcpy(target, source)
+#define xppStrncpy(target, source, cnt) strncpy(target, source, cnt)
+#define xppStrcat(target, source) strcat(target, source)
+#define xppStrncat(target, source, cnt) strncat(target, source, cnt)
+#define xppStrcmp(first, second) strcmp(first, second)
+#define xppStrncmp(first, second, cnt) strncmp(first, second, cnt)
+#define xppStrchr(string, c) strchr(string, c)
+#define xppStrstr(string, substr) strstr(string, substr)
+#define xppStrlen(string) strlen(string)
+#define xppAtoi(string) atoi(string)
+
+#define xppMemset(s, c, n) memset(s, c, n)
+#define xppMemcpy(target, source, cnt) memcpy(target, source, cnt)
+#define xppMemmove(target, source, cnt) memmove(target, source, cnt)
+#define xppMemcmp(target, source, cnt) memcmp(target, source, cnt)
+#define xppMalloc(size) malloc(size)
+#define xppRealloc(ptr, size) realloc(ptr, size)
+#define xppFree(ptr) free(ptr)
+
+#define xppStricmp(first, second) strcasecmp(first, second)
+#define xppMemicmp(first, second, cnt) strncasecmp(first, second, cnt)
+
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xpttypes.h b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xpttypes.h
new file mode 100644
index 0000000..bc96619
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/hdr/xpttypes.h
@@ -0,0 +1,80 @@
+/*************************************************************************/
+/* module: Communication Services, standard type definitions */
+/* file: src/xpt/all/xpttypes.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Definition of several basic datatypes.
+ *
+ */
+
+#ifndef XPTTYPES_H
+#define XPTTYPES_H
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+
+#ifndef Bool_t
+typedef int Bool_t;
+#endif
+
+typedef unsigned char *DataBuffer_t;
+typedef DataBuffer_t *DataPtr_t;
+typedef unsigned long BufferSize_t;
+typedef BufferSize_t *BufferSizePtr_t;
+
+typedef const char *CString_t;
+typedef char *Ptr_t;
+typedef char *StringBuffer_t;
+typedef CString_t *StringPtr_t;
+typedef StringBuffer_t *StringBufferPtr_t;
+typedef unsigned short StringLength_t;
+
+
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xpt/src/md5c.c b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/src/md5c.c
new file mode 100644
index 0000000..2ff98ed
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/src/md5c.c
@@ -0,0 +1,299 @@
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+ */
+
+#include "md5.h"
+#include "libmem.h"
+
+/* Constants for MD5Transform routine. */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+static void MD5Transform (UINT4 [4], unsigned char [64]);
+static void Encode (unsigned char *, UINT4 *, unsigned int);
+static void Decode (UINT4 *, unsigned char *, unsigned int);
+static void MD5_memcpy (POINTER, POINTER, unsigned int);
+static void MD5_memset (POINTER, int, unsigned int);
+
+static unsigned char PADDING[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* F, G, H and I are basic MD5 functions. */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/* ROTATE_LEFT rotates x left n bits. */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+Rotation is separate from addition to prevent recomputation.
+ */
+#define FF(a, b, c, d, x, s, ac) { \
+ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) { \
+ (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) { \
+ (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) { \
+ (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+
+/* MD5 initialization. Begins an MD5 operation, writing a new context.
+ */
+void smlMD5Init (MD5_CTX *context)
+{
+ context->count[0] = context->count[1] = 0;
+ /* Load magic initialization constants. */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xefcdab89;
+ context->state[2] = 0x98badcfe;
+ context->state[3] = 0x10325476;
+}
+
+/* MD5 block update operation. Continues an MD5 message-digest
+ operation, processing another message block, and updating the
+ context.
+ */
+
+ /* context */
+ /* input block */
+ /* length of input block */
+void smlMD5Update (MD5_CTX *context, unsigned char *input, unsigned int inputLen)
+{
+ unsigned int i, index, partLen;
+
+ /* Compute number of bytes mod 64 */
+ index = (unsigned int)((context->count[0] >> 3) & 0x3F);
+
+ /* Update number of bits */
+ if ((context->count[0] += ((UINT4)inputLen << 3))
+ < ((UINT4)inputLen << 3))
+ context->count[1]++;
+ context->count[1] += ((UINT4)inputLen >> 29);
+
+ partLen = 64 - index;
+
+ /* Transform as many times as possible. */
+ if (inputLen >= partLen) {
+ MD5_memcpy
+ ((POINTER)&context->buffer[index], (POINTER)input, partLen);
+ MD5Transform (context->state, context->buffer);
+
+ for (i = partLen; i + 63 < inputLen; i += 64)
+ MD5Transform (context->state, &input[i]);
+
+ index = 0;
+ }
+ else
+ i = 0;
+
+ /* Buffer remaining input */
+ MD5_memcpy
+ ((POINTER)&context->buffer[index], (POINTER)&input[i],
+ inputLen-i);
+}
+
+/* MD5 finalization. Ends an MD5 message-digest operation, writing the
+ the message digest and zeroizing the context.
+ */
+ /* message digest */
+ /* context */
+void smlMD5Final (unsigned char digest[16], MD5_CTX *context)
+{
+ unsigned char bits[8];
+ unsigned int index, padLen;
+
+ /* Save number of bits */
+ Encode (bits, context->count, 8);
+
+ /* Pad out to 56 mod 64. */
+ index = (unsigned int)((context->count[0] >> 3) & 0x3f);
+ padLen = (index < 56) ? (56 - index) : (120 - index);
+ smlMD5Update (context, PADDING, padLen);
+
+ /* Append length (before padding) */
+ smlMD5Update (context, bits, 8);
+ /* Store state in digest */
+ Encode (digest, context->state, 16);
+
+ /* Zeroize sensitive information. */
+ MD5_memset ((POINTER)context, 0, sizeof (*context));
+}
+
+/* MD5 basic transformation. Transforms state based on block. */
+static void MD5Transform (UINT4 state[4], unsigned char block[64])
+{
+ UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+
+ Decode (x, block, 64);
+
+ /* Round 1 */
+ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
+ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
+ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
+ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
+ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
+ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
+ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
+ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
+ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
+ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
+ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
+ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
+ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
+ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
+ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
+ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
+ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
+ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
+ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
+ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
+ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
+ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
+ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
+ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
+ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
+ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
+ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
+ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
+ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
+ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
+ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
+ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
+ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
+ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
+ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
+ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
+ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
+ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
+ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+ /* Zeroize sensitive information. */
+ MD5_memset ((POINTER)x, 0, sizeof (x));
+}
+
+/* Encodes input (UINT4) into output (unsigned char). Assumes len is
+ a multiple of 4.
+ */
+static void Encode (unsigned char *output, UINT4 *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4) {
+ output[j] = (unsigned char)(input[i] & 0xff);
+ output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
+ output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
+ output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
+ }
+}
+
+/* Decodes input (unsigned char) into output (UINT4). Assumes len is
+ a multiple of 4.
+ */
+static void Decode (UINT4 *output, unsigned char *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4)
+ output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
+ (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
+}
+
+/* Note: Replace "for loop" with standard memcpy if possible.
+ */
+
+static void MD5_memcpy (POINTER output, POINTER input, unsigned int len)
+{
+ smlLibMemcpy(output, input, len);
+}
+
+/* Note: Replace "for loop" with standard memset if possible.
+ */
+static void MD5_memset (POINTER output, int value, unsigned int len)
+{
+ smlLibMemset(output, value, len);
+}
diff --git a/engine/dmlib/dmengine/oma_toolkit/sml/xpt/src/xpt-b64.c b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/src/xpt-b64.c
new file mode 100644
index 0000000..d7c7f82
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/sml/xpt/src/xpt-b64.c
@@ -0,0 +1,365 @@
+
+/*************************************************************************/
+/* module: Communication Services, base64 encoding/decoding fns.*/
+/* file: src/xpt/all/xpt-b64.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#include "xptport.h"
+#include "xpttypes.h"
+#include "xpt-b64.h"
+
+
+#define MAX_COLUMNS 45
+
+
+/***************************************************************************/
+/* The function decodes the next character of the input buffer and updates */
+/* the pointers to the input buffer. The function skips CRLF characters */
+/* and whitespace characters. */
+/* Returns: 0..63, the logical value of the next valid character in the */
+/* input buffer */
+/* 64, padding character */
+/* -1, No more characters to read */
+/* -2, an error occurred: invalid characters in the data stream*/
+/***************************************************************************/
+
+int nextBase64Char (DataBuffer_t *ppbData, BufferSize_t *pcbDataLength)
+ {
+ int r = -1;
+ DataBuffer_t pbData = *ppbData;
+ BufferSize_t cbDataLength = *pcbDataLength;
+#ifndef __EPOC_OS__
+ static char *pszSkipChars = "\t\r\n ";
+#endif
+#ifdef __EPOC_OS__
+ char *pszSkipChars = "\t\r\n ";
+#endif
+ char ch;
+
+ if (cbDataLength == 0) return r;
+
+ do {
+ ch = *pbData;
+ if ((ch>='0')&&(ch<='9')) r = (int)ch+4; // |
+ else if ((ch>='A')&&(ch<='Z')) r = (int)ch-65; // |
+ else if ((ch>='a')&&(ch<='z')) r = (int)ch-71; // | Valid characters
+ else if (ch == '/') r = 63; // |
+ else if (ch == '+') r = 62; // |
+ else if (ch == '=') r = 64; // padding character
+ else if (!xppStrchr (pszSkipChars, ch)) r = -2; // invalid character
+ cbDataLength --;
+ pbData ++;
+ } while ((r == -1) && (cbDataLength > 0));
+
+ /***************************************************/
+ /* Pass the updated parameter values to the caller */
+ /***************************************************/
+ if (r != -1)
+ {
+ *ppbData = pbData;
+ *pcbDataLength = cbDataLength;
+ }
+ return r;
+ }
+
+BufferSize_t base64GetSize (BufferSize_t cbRealDataSize)
+ {
+ int iMod = cbRealDataSize % 3;
+ /* The encoded data size ... */
+ BufferSize_t cbEncodedSize = ((cbRealDataSize - iMod) / 3 ) * 4;
+ if (iMod != 0) cbEncodedSize += 4;
+ /* ... and the # of CRLF characters */
+ cbEncodedSize += ((cbEncodedSize-1) / ((MAX_COLUMNS*4)/3)) * 2;
+ return cbEncodedSize;
+ }
+
+
+/*****************************************************************/
+/* Function: pre-compute the size of the base64 encoded document */
+/****************************************************************/
+
+BufferSize_t base64Encode (DataBuffer_t pbTarget, // o: target buffer
+ BufferSize_t cbTargetSize, // i: target buffer size
+ DataBuffer_t pbData, // i: Data buffer
+ BufferSize_t *pcbDataLength, // i/o: Data buffer size
+ BufferSize_t *pcbOffset, // i/o: absolute # of bytes encoded so far
+ unsigned int bLast, // i: 0=first block, 1= next block, 2=last block
+ unsigned char *pbSaveBytes) // i/o: last incomplete data block
+ {
+ DataBuffer_t pbSourceData = pbData;
+ BufferSize_t cbCopySize = 0;
+ BufferSize_t cbDataProcessed = *pcbDataLength;
+ unsigned int i0, i1, i2, i3;
+ unsigned int byt;
+ int iSave = 1;
+#ifndef __EPOC_OS__
+ static char t [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // 26
+ "abcdefghijklmnopqrstuvwxyz" // 26
+ "0123456789+/" // 12
+ "="; // 1
+#endif
+#ifdef __EPOC_OS__
+char t [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // 26
+ "abcdefghijklmnopqrstuvwxyz" // 26
+ "0123456789+/" // 12
+ "="; // 1
+#endif
+ // Check for NULL data buffer,
+ if (pbData == NULL ) {
+ // See if last block and there is any "saved" data that needs to go now.
+ if ( bLast && ( pbSaveBytes && pbSaveBytes [0] )) {
+ /**************************************/
+ /* Check if it is time to send a CRLF */
+ /**************************************/
+ if ((*pcbOffset) > 0 && ((*pcbOffset) % MAX_COLUMNS == 0))
+ {
+ //if (cbTargetSize < 6) // there is not enough space in the target buffer:
+ // break; // return to the caller.
+ *pbTarget = '\r';
+ *(pbTarget+1) = '\n';
+ cbCopySize += 2;
+ cbTargetSize -= 2;
+ pbTarget += 2;
+ }
+
+ byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --;
+
+ i0 = byt >> 2;
+ i1 = (byt & 0x0003) << 4;
+
+ (*pcbOffset) ++;
+
+ if (pbSaveBytes && pbSaveBytes [0]) {
+ byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --;
+ i1 += (byt >> 4);
+ i2 = i3 = (byt & 0x000F) << 2;
+ } else {
+ i2 = i3 = 64; // index to the padding char '=';
+ }
+
+ pbTarget [0] = t[i0];
+ pbTarget [1] = t[i1];
+ pbTarget [2] = t[i2];
+ pbTarget [3] = t[i3];
+
+ cbCopySize += 4;
+ cbTargetSize -= 4;
+ pbTarget += 4;
+ }
+
+ } else {
+ while ((cbTargetSize >= 4) && (cbDataProcessed > 0))
+ /*
+ * AZ: We do not need to divide the data into multiple blocks, nor do we enforce
+ * MAX_COLUMNS. So commenting out the code block below for now.
+ *
+ * &&
+ * ( ((cbDataProcessed >= 3) && (bLast == 0)) ||
+ * ((cbDataProcessed > 0) && (bLast == 1)) ))
+ */
+ {
+ /**************************************/
+ /* Check if it is time to send a CRLF */
+ /**************************************/
+ /*
+ if ((*pcbOffset) > 0 && ((*pcbOffset) % MAX_COLUMNS == 0))
+ {
+ if (cbTargetSize < 6) // there is not enough space in the target buffer:
+ break; // return to the caller.
+ *pbTarget = '\r';
+ *(pbTarget+1) = '\n';
+ cbCopySize += 2;
+ cbTargetSize -= 2;
+ pbTarget += 2;
+ }
+ */
+ if (pbSaveBytes && pbSaveBytes [0])
+ { byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --; }
+ else
+ { byt = (unsigned int) *pbSourceData; pbSourceData ++; cbDataProcessed --;}
+
+ i0 = byt >> 2;
+ i1 = (byt & 0x0003) << 4;
+
+ (*pcbOffset) ++;
+
+ if (cbDataProcessed > 0)
+ {
+ if (pbSaveBytes && pbSaveBytes [0])
+ { byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --; }
+ else
+ { byt = (unsigned int) *pbSourceData; pbSourceData ++; cbDataProcessed --;}
+
+ i1 += (byt >> 4);
+ i2 = (byt & 0x000F) << 2;
+
+ (*pcbOffset) ++;
+
+ if (cbDataProcessed > 0)
+ {
+ if (pbSaveBytes && pbSaveBytes [0])
+ { byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --; }
+ else
+ { byt = (unsigned int) *pbSourceData; pbSourceData ++; cbDataProcessed --;}
+
+ i2 += (byt & 0x00C0) >> 6;
+ i3 = byt & 0x003F;
+ (*pcbOffset) ++;
+ }
+ else
+ i3 = 64; // index to the padding char '=';
+ }
+ else
+ i2 = i3 = 64; // index to the padding char '=';
+ pbTarget [0] = t[i0];
+ pbTarget [1] = t[i1];
+ pbTarget [2] = t[i2];
+ pbTarget [3] = t[i3];
+
+ cbCopySize += 4;
+ cbTargetSize -= 4;
+ pbTarget += 4;
+ }
+ }
+
+
+
+ /*************************************************************/
+ /* Save the bytes that must be processed in the following */
+ /* call (max. 2 Bytes). */
+ /*************************************************************/
+ if(pbSourceData!=NULL){
+ if ((bLast == 0) && (cbDataProcessed <= 2) && (pbSaveBytes != NULL))
+ {
+ pbSaveBytes[0] = cbDataProcessed;
+ while (cbDataProcessed)
+ {
+ *(++pbSaveBytes) = pbSourceData[0];
+ cbDataProcessed --; pbSourceData ++;
+ }
+ }
+
+ /*****************************************************************/
+ /* Shift all non-processed data to the start of the input buffer */
+ /*****************************************************************/
+
+ if (cbDataProcessed > 0)
+ {
+ xppMemmove (pbData, pbSourceData, cbDataProcessed);
+ }
+ *pcbDataLength = cbDataProcessed;
+ }
+ return cbCopySize;
+ }
+
+/***************************************************************/
+/* Function: decode a base64- encoded block of data. */
+/* The function returns the count of data that are decoded, or */
+/* 0 in case of a data error, or if cbTargetSize < 4 */
+/***************************************************************/
+
+BufferSize_t base64Decode (DataBuffer_t pbTarget, // o: target buffer
+ BufferSize_t cbTargetSize, // i: target buffer size
+ DataBuffer_t pbData, // i: data buffer
+ BufferSize_t *pcbDataLength) // i/o: Data buffer size
+ {
+ DataBuffer_t pbSource = pbData;
+ BufferSize_t cbDataCopied = 0L;
+ BufferSize_t cbRemaining = *pcbDataLength; // remaining source data
+ int i0 = 0, i1 = 0, i2 = 0, i3 = 0;
+
+ while (cbTargetSize > 0)
+ {
+ BufferSize_t cbNext = cbRemaining;
+ DataBuffer_t pbNext = pbSource;
+
+ i0 = nextBase64Char (&pbNext, &cbNext);
+ i1 = nextBase64Char (&pbNext, &cbNext);
+ i2 = nextBase64Char (&pbNext, &cbNext);
+ i3 = nextBase64Char (&pbNext, &cbNext);
+ if ((i0 < 0) || (i1 < 0) || (i2 < 0) || (i3 < 0))
+ break; // end-of-block, or data error.
+
+ else if ( ((cbTargetSize <= 2) && (i3 != 64)) ||
+ ((cbTargetSize <= 1) && (i2 != 64)) )
+ break; // end of transmission.
+
+ else
+ {
+ pbSource = pbNext;
+ cbRemaining = cbNext;
+ /************************/
+ /* decode the quadruple */
+ /************************/
+ *pbTarget = (i0 << 2) + (i1 >> 4);
+ pbTarget ++; cbDataCopied ++; cbTargetSize --;
+ if (i2 != 64)
+ {
+ *pbTarget = ((i1 & 0x000f) << 4) + (i2 >> 2);
+ pbTarget ++; cbDataCopied ++; cbTargetSize --;
+ if (i3 != 64)
+ {
+ *pbTarget = ((i2 & 0x0003) << 6) + i3;
+ pbTarget ++; cbDataCopied ++; cbTargetSize --;
+ }
+ }
+ }
+ }
+
+ /*******************************/
+ /* Handle invalid data errors! */
+ /*******************************/
+
+ if ((i0 == -2) || (i1 == -2) || (i2 == -2) || (i3 == -2))
+ cbDataCopied = 0;
+
+ /*****************************************************************/
+ /* Shift all non-processed data to the start of the input buffer */
+ /*****************************************************************/
+ if (cbRemaining > 0)
+ xppMemmove (pbData, pbSource, cbRemaining);
+ *pcbDataLength = cbRemaining;
+ return cbDataCopied;
+ }
+
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/libmem.c b/engine/dmlib/dmengine/oma_toolkit/src/libmem.c
new file mode 100644
index 0000000..2cd9f6a
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/libmem.c
@@ -0,0 +1,175 @@
+/*************************************************************************/
+/* module: Library for Memory Functions */
+/* */
+/* file: libmem.c */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Header for the implementation of common memory handling functions */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <smldef.h>
+#include "dmMemory.h"
+#include "libmem.h"
+#ifdef __PALM_OS__
+#include "MemoryMgr.h"
+#endif
+
+#ifdef MEMORY_PROFILING
+ // %%% luz 2002-10-02
+ #include "profiling.h"
+#endif
+
+/*************************************************************************
+ * External Functions for all TOOLKIT Versions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlLibFree
+ *
+ * Deallocates the memory of object "pObject", which has been allocated
+ * previously.
+ * If "pObject" is a NULL pointer nothing happens.
+ * If "pObject" is a pointer to memory which has not been allocated
+ * previouly, the behaviour is undefined.
+ * The contents of the deallocated memory object is destroyed.
+ */
+SML_API void smlLibFree(void *pObject)
+{
+ if (! pObject) return;
+ #ifdef __PALM_OS__
+ MemPtrFree(pObject);
+ #else
+ DmFreeMem(pObject);
+ #endif
+}
+
+
+/**
+ * FUNCTION: smlLibRealloc
+ *
+ * Changes size of preallocated space for memory object "pObject"
+ * to the new size specified by "constSize".
+ *
+ * If the new size is larger than the old size, the old contents
+ * is not changed. Additionally space is added at the the end of
+ * "pObject". The new allocated space is not initialized
+ * to any special value.
+ * If the new size is smaller than the old size, the unused space
+ * is discarded.
+ *
+ * If "pObject" is a NULL pointer, this function behaves just like
+ * smlLibMalloc().
+ * If "pObject" does not point to a previously allocated memory area,
+ * the behavior is undefined.
+ * If "constSize" is 0, a NULL pointer is returned and the space
+ * which "pObject" points to is freed up.
+ *
+ * Returns a pointer to the first byte of the resized object.
+ * If no new memory could be allocated, a NULL Pointer is returned
+ * without changing the memory object "pObject" (Nothing happens to the content).
+ *
+ * IN/OUT void *pObject, memory object, which size should be changed
+ * IN: MemSize_t constSize new size the memory object shall use
+ * RETURN: void* Pointer to memory object, which size has been
+ * be changed
+ * NULL, if not successfull or
+ * if constSize==0
+ */
+SML_API void *smlLibRealloc(void *pObject, MemSize_t constSize)
+{
+#ifdef __PALM_OS__
+ VoidPtr_t _new_object;
+ MemSize_t _old_size;
+
+ // It's a malloc!
+ if (pObject == NULL)
+ return smlLibMalloc(constSize);
+
+ _old_size = MemPtrSize(pObject);
+ if (constSize <= _old_size) {
+ // make it smaller
+ MemPtrResize(pObject, constSize);
+ _new_object = pObject;
+ } else {
+ // maker it larger (we need to allocate new memory somewhere else)
+ _new_object = smlLibMalloc(constSize);
+ if (_new_object != NULL) {
+ smlLibMemmove(_new_object, pObject, _old_size);
+ smlLibFree(pObject);
+ }
+ }
+
+ return _new_object;
+#else
+ return DmReallocMem(pObject, (UINT32)constSize);
+
+#endif
+}
+
+
+#ifndef __PALM_OS__
+/* If not Palm OS we use the Standard ANSI C functions */
+SML_API void *smlLibMemset(void *pObject, int value, MemSize_t count){
+ return memset(pObject, value, count);
+}
+SML_API void *smlLibMemcpy(void *pTarget, const void *pSource, MemSize_t count){
+ return memcpy(pTarget, pSource, count);
+}
+SML_API void *smlLibMemmove(void *pTarget, const void *pSource, MemSize_t count){
+ return memmove(pTarget, pSource, count);
+}
+SML_API int smlLibMemcmp(const void *pTarget, const void *pSource, MemSize_t count){
+ return memcmp(pTarget, pSource, count);
+}
+/*SML_API void *smlLibMalloc(MemSize_t size) {
+ return (void *)DmAllocMem((UINT32)size);
+
+}*/
+#endif
+
+
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/libstr.c b/engine/dmlib/dmengine/oma_toolkit/src/libstr.c
new file mode 100644
index 0000000..319dd0b
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/libstr.c
@@ -0,0 +1,138 @@
+/*************************************************************************/
+/* module: Library for String Functions */
+/* */
+/* file: libstr.c */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* implementation of common string-handling functions */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <smldef.h>
+#include "libstr.h"
+#include "libmem.h"
+#ifdef __ANSI_C__
+#include <string.h>
+#endif
+#ifdef __PALM_OS__
+#include <StringMgr.h>
+#endif
+
+
+
+/*************************************************************************
+ * External Functions for all TOOLKIT Versions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlLibStrdup
+ *
+ * Duplicates the String "constStringP".
+ * Returns a pointer to the new copy of "constStringP".
+ *
+ * IN: String_t constStringP string, which is duplicated
+ * RETURN: String_t pointer to the new copy,
+ * null, if no copy could be allocated
+ */
+SML_API String_t smlLibStrdup (const char *constStringP)
+{
+ String_t _new_str;
+
+ // allocate memory for new copy
+ _new_str = (String_t)smlLibMalloc(smlLibStrlen(constStringP) + 1);
+
+ // Copy the string into the new memory
+ if (_new_str != NULL)
+ smlLibStrcpy(_new_str, constStringP);
+
+ return _new_str;
+}
+
+
+#ifndef __PALM_OS__
+/* If not Palm OS we use the Standard ANSI C functions */
+SML_API String_t smlLibStrcpy(const char *pTarget, const char *pSource) {
+ return strcpy((char *)pTarget, (char *)pSource);
+}
+SML_API String_t smlLibStrncpy(const char *pTarget, const char *pSource, int count){
+ return strncpy((char *)pTarget, (char *)pSource, count);
+}
+SML_API String_t smlLibStrcat(const char *pTarget, const char *pSource){
+ return strcat((char *)pTarget, (char *)pSource);
+}
+SML_API int smlLibStrcmp(const char *pTarget, const char *pSource){
+ return strcmp((char *)pTarget, (char *)pSource);
+}
+SML_API int smlLibStrncmp(const char *pTarget, const char *pSource, int count){
+ return strncmp((char *)pTarget, (char *)pSource, count);
+}
+SML_API String_t smlLibStrchr(const char *pString, char character){
+ return strchr((char *)pString, character);
+}
+SML_API int smlLibStrlen(const char *pString){
+ return strlen((char *)pString);
+}
+
+
+#endif
+
+
+
+/*************************************************************************
+ * Additional External Functions for Full Size TOOLKIT ONLY
+ *************************************************************************/
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+#ifndef __PALM_OS__ /* we use #define to reduce heap usage */
+SML_API String_t smlLibStrncat(const char *pTarget, const char *pSource, int count){
+ return strncat((char *)pTarget, (char *)pSource, count);
+}
+SML_API String_t smlLibStrstr(const char *pString, const char *pSubString){
+ return strstr((char *)pString, (char *)pSubString);
+}
+#endif
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/libutil.c b/engine/dmlib/dmengine/oma_toolkit/src/libutil.c
new file mode 100644
index 0000000..82351aa
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/libutil.c
@@ -0,0 +1,206 @@
+/*************************************************************************/
+/* module: Library for IO Functions */
+/* */
+/* file: libio.c */
+/* target system: ALL */
+/* target OS: ALL */
+/* */
+/* Description: */
+/* Utility I/O functions */
+/*************************************************************************/
+
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#ifndef NOWSM
+// Note: in NOWSM case, these routines must be implemented in the
+// calling main code.
+
+#include <smldef.h>
+#include <smlerr.h>
+
+#ifdef __ANSI_C__
+#include <stdarg.h>
+#include <stdio.h>
+#endif
+
+#ifdef __PALM_OS__
+#include <Pilot.h>
+#include <unix_stdarg.h>
+#endif
+
+#ifdef __EPOC_OS__
+#include <stdarg.h>
+#include <stdio.h>
+#endif
+
+#include "define.h"
+#include "libmem.h"
+#include "mgr.h"
+#include "libutil.h"
+
+
+// size of output buffer
+#define BUFFERSIZE 128
+
+
+/* Used external functions */
+extern SyncMLInfoPtr_t mgrGetSyncMLAnchor();
+
+
+/*************************************************************************
+ * External Functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlLibPrint
+ *
+ * Assembles a formatted textstring out of a list of argument. This string is
+ * passed to a callback function, which is implementated by the application
+ * for output to the user
+ *
+ * IN: A printf like format text string with multiple
+ * arguments to be formatted as specified
+ * Supported are:
+ * %d, %i, %u, %x, %s, %c
+ * +, -, <space>, *, <number>, h, l, L
+ *
+ * RETURN: - - -
+ */
+
+
+SML_API void smlLibPrint(const char *text, ...)
+{
+ char pBuffer[BUFFERSIZE];
+ va_list args;
+ SyncMLInfoPtr_t pSyncMLInfo;
+
+ if ((pSyncMLInfo = mgrGetSyncMLAnchor()) != NULL) {
+
+ pBuffer[0] = '\0';
+
+ va_start(args, text);
+
+ // assemble the text string out of the single arguments
+ #ifdef __ANSI_C__
+ vsprintf(pBuffer, text, args);
+ #endif
+
+ #ifdef __PALM_OS__
+ StrVPrintF(pBuffer, text, args);
+ #endif
+
+ #ifdef __EPOC_OS__
+ vsprintf(pBuffer, text, args);
+ #endif
+
+ va_end(args);
+
+ // use the application callback function,
+ // which implements the output.
+ if (pSyncMLInfo &&
+ pSyncMLInfo->syncmlOptions &&
+ pSyncMLInfo->syncmlOptions->defaultPrintFunc)
+ ((smlPrintFunc)(pSyncMLInfo->syncmlOptions->defaultPrintFunc))(pBuffer);
+ }
+}
+
+SML_API void smlLibVprintf(const char *format, va_list args)
+{
+ char pBuffer[BUFFERSIZE];
+ SyncMLInfoPtr_t pSyncMLInfo;
+
+ if ((pSyncMLInfo = mgrGetSyncMLAnchor()) != NULL) {
+
+ pBuffer[0] = '\0';
+
+ // assemble the text string out of the single arguments
+ #ifdef __ANSI_C__
+ vsprintf(pBuffer, format, args);
+ #endif
+
+ #ifdef __PALM_OS__
+ StrVPrintF(pBuffer, format, args);
+ #endif
+
+ #ifdef __EPOC_OS__
+ vsprintf(pBuffer, format, args);
+ #endif
+
+ // use the application callback function,
+ // which implements the output.
+ if (pSyncMLInfo &&
+ pSyncMLInfo->syncmlOptions &&
+ pSyncMLInfo->syncmlOptions->defaultPrintFunc)
+ ((smlPrintFunc)(pSyncMLInfo->syncmlOptions->defaultPrintFunc))(pBuffer);
+ }
+}
+
+#endif // !defined(NOWSM)
+
+
+#ifdef MOT_OTK_DEBUG
+#include <stdarg.h>
+
+void __kcdbg__(char *fmt, ...)
+{
+ FILE *fp = fopen("/data/data/tmp/dm_otk.log", "a+");
+ if (NULL == fp)
+ return;
+
+ va_list ap;
+
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ vfprintf(fp, fmt, ap);
+ va_end(ap);
+
+ fclose(fp);
+}
+
+#endif
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/md5c.c b/engine/dmlib/dmengine/oma_toolkit/src/md5c.c
new file mode 100644
index 0000000..2ff98ed
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/md5c.c
@@ -0,0 +1,299 @@
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+ */
+
+#include "md5.h"
+#include "libmem.h"
+
+/* Constants for MD5Transform routine. */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+static void MD5Transform (UINT4 [4], unsigned char [64]);
+static void Encode (unsigned char *, UINT4 *, unsigned int);
+static void Decode (UINT4 *, unsigned char *, unsigned int);
+static void MD5_memcpy (POINTER, POINTER, unsigned int);
+static void MD5_memset (POINTER, int, unsigned int);
+
+static unsigned char PADDING[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* F, G, H and I are basic MD5 functions. */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/* ROTATE_LEFT rotates x left n bits. */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+Rotation is separate from addition to prevent recomputation.
+ */
+#define FF(a, b, c, d, x, s, ac) { \
+ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) { \
+ (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) { \
+ (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) { \
+ (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+
+/* MD5 initialization. Begins an MD5 operation, writing a new context.
+ */
+void smlMD5Init (MD5_CTX *context)
+{
+ context->count[0] = context->count[1] = 0;
+ /* Load magic initialization constants. */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xefcdab89;
+ context->state[2] = 0x98badcfe;
+ context->state[3] = 0x10325476;
+}
+
+/* MD5 block update operation. Continues an MD5 message-digest
+ operation, processing another message block, and updating the
+ context.
+ */
+
+ /* context */
+ /* input block */
+ /* length of input block */
+void smlMD5Update (MD5_CTX *context, unsigned char *input, unsigned int inputLen)
+{
+ unsigned int i, index, partLen;
+
+ /* Compute number of bytes mod 64 */
+ index = (unsigned int)((context->count[0] >> 3) & 0x3F);
+
+ /* Update number of bits */
+ if ((context->count[0] += ((UINT4)inputLen << 3))
+ < ((UINT4)inputLen << 3))
+ context->count[1]++;
+ context->count[1] += ((UINT4)inputLen >> 29);
+
+ partLen = 64 - index;
+
+ /* Transform as many times as possible. */
+ if (inputLen >= partLen) {
+ MD5_memcpy
+ ((POINTER)&context->buffer[index], (POINTER)input, partLen);
+ MD5Transform (context->state, context->buffer);
+
+ for (i = partLen; i + 63 < inputLen; i += 64)
+ MD5Transform (context->state, &input[i]);
+
+ index = 0;
+ }
+ else
+ i = 0;
+
+ /* Buffer remaining input */
+ MD5_memcpy
+ ((POINTER)&context->buffer[index], (POINTER)&input[i],
+ inputLen-i);
+}
+
+/* MD5 finalization. Ends an MD5 message-digest operation, writing the
+ the message digest and zeroizing the context.
+ */
+ /* message digest */
+ /* context */
+void smlMD5Final (unsigned char digest[16], MD5_CTX *context)
+{
+ unsigned char bits[8];
+ unsigned int index, padLen;
+
+ /* Save number of bits */
+ Encode (bits, context->count, 8);
+
+ /* Pad out to 56 mod 64. */
+ index = (unsigned int)((context->count[0] >> 3) & 0x3f);
+ padLen = (index < 56) ? (56 - index) : (120 - index);
+ smlMD5Update (context, PADDING, padLen);
+
+ /* Append length (before padding) */
+ smlMD5Update (context, bits, 8);
+ /* Store state in digest */
+ Encode (digest, context->state, 16);
+
+ /* Zeroize sensitive information. */
+ MD5_memset ((POINTER)context, 0, sizeof (*context));
+}
+
+/* MD5 basic transformation. Transforms state based on block. */
+static void MD5Transform (UINT4 state[4], unsigned char block[64])
+{
+ UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+
+ Decode (x, block, 64);
+
+ /* Round 1 */
+ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
+ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
+ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
+ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
+ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
+ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
+ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
+ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
+ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
+ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
+ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
+ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
+ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
+ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
+ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
+ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
+ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
+ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
+ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
+ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
+ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
+ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
+ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
+ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
+ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
+ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
+ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
+ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
+ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
+ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
+ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
+ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
+ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
+ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
+ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
+ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
+ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
+ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
+ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+ /* Zeroize sensitive information. */
+ MD5_memset ((POINTER)x, 0, sizeof (x));
+}
+
+/* Encodes input (UINT4) into output (unsigned char). Assumes len is
+ a multiple of 4.
+ */
+static void Encode (unsigned char *output, UINT4 *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4) {
+ output[j] = (unsigned char)(input[i] & 0xff);
+ output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
+ output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
+ output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
+ }
+}
+
+/* Decodes input (unsigned char) into output (UINT4). Assumes len is
+ a multiple of 4.
+ */
+static void Decode (UINT4 *output, unsigned char *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4)
+ output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
+ (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
+}
+
+/* Note: Replace "for loop" with standard memcpy if possible.
+ */
+
+static void MD5_memcpy (POINTER output, POINTER input, unsigned int len)
+{
+ smlLibMemcpy(output, input, len);
+}
+
+/* Note: Replace "for loop" with standard memset if possible.
+ */
+static void MD5_memset (POINTER output, int value, unsigned int len)
+{
+ smlLibMemset(output, value, len);
+}
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/mgr.c b/engine/dmlib/dmengine/oma_toolkit/src/mgr.c
new file mode 100644
index 0000000..a72c160
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/mgr.c
@@ -0,0 +1,306 @@
+/*************************************************************************/
+/* module: Managing SyncML */
+/* */
+/* file: mgr.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Core Module managing the life-cycle of a syncML Process itself */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <sml.h>
+#include <smldef.h>
+#include <smlerr.h>
+
+#if defined(NOWSM) && !__LINK_TOOLKIT_STATIC__
+// we need dummies of these as they are listed in the SyncML.def file
+SML_API_DEF Ret_t smlInit(SmlOptionsPtr_t pOptions) { return SML_ERR_OK; }
+SML_API_DEF Ret_t smlSetSyncMLOptions (SmlOptionsPtr_t pOptions) { return SML_ERR_OK; }
+SML_API_DEF Ret_t smlTerminate(void) { return SML_ERR_OK; }
+#endif
+
+#ifndef NOWSM
+
+#include "libmem.h"
+#include "liblock.h"
+#include "wsm.h"
+#include "mgr.h"
+
+#ifdef __EPOC_OS__
+#include "core_globals_epoc.h"
+#endif
+
+/* Prototypes of exported SyncML API functions */
+SML_API Ret_t smlInit(SmlOptionsPtr_t pOptions);
+SML_API Ret_t smlSetSyncMLOptions (SmlOptionsPtr_t pOptions);
+SML_API Ret_t smlTerminate(void);
+
+/* SyncML internal function prototypes */
+InstanceInfoPtr_t mgrGetInstanceListAnchor(void);
+void mgrSetInstanceListAnchor(InstanceInfoPtr_t newListAnchor);
+SyncMLInfoPtr_t mgrGetSyncMLAnchor(void);
+
+
+/**
+ * Anchor of the global syncML info structure
+ */
+#ifndef __EPOC_OS__
+static SyncMLInfoPtr_t pGlobalAnchor=NULL; // this global pointer is used to access ALL globals within syncml
+#endif // This is the ONLY global varible of SyncML!
+
+#ifdef __EPOC_OS__
+#define pGlobalAnchor TheCoreGlobalsEpoc()->pGlobalAnchor
+#endif
+
+/*************************************************************************
+ * Exported SyncML API functions
+ *************************************************************************/
+
+
+
+
+/**
+ * FUNCTION: smlInit
+ *
+ * Initializes the SyncML Reference Tookit. This is required, before any
+ * other function can be used.
+ *
+ * IN: SyncMLOptionsPtr_t
+ * options to be applied for the toolkit
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlInit(SmlOptionsPtr_t pCoreOptions)
+{
+
+ /* ---- Definitions --- */
+ WsmOptions_t* pWorkspaceOptions;
+ Ret_t rc;
+
+
+ /* --- check, if SyncML has already been initialized --- */
+ if (pGlobalAnchor!=NULL) return SML_ERR_ALREADY_INITIALIZED;
+
+ /* --- Check pOptions, which have been passed by the application --- */
+ if (!pCoreOptions)
+ return SML_ERR_WRONG_USAGE;
+
+
+ /* --- Create a SyncML info memory object to store all globals --- */
+ TOOLKITLOCK_INIT("smlInit");
+ pGlobalAnchor = (SyncMLInfoPtr_t)smlLibMalloc((MemSize_t)sizeof(SyncMLInfo_t));
+ if (pGlobalAnchor==NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pGlobalAnchor,0,(MemSize_t)sizeof(SyncMLInfo_t));
+
+
+ /* --- Set SyncML settings and options --- */
+ pGlobalAnchor->instanceListAnchor = NULL; // no instance exists at the beginning
+ rc = smlSetSyncMLOptions (pCoreOptions); // store the options in the global structure
+ if (rc!=SML_ERR_OK){
+ smlLibFree(pGlobalAnchor);
+ pGlobalAnchor = NULL;
+ return rc;
+ }
+
+ pGlobalAnchor->tokTbl = (TokenInfoPtr_t)smlLibMalloc(sizeof(TokenInfo_t));
+ if (pGlobalAnchor->tokTbl == NULL)
+ {
+ smlLibFree(pGlobalAnchor);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pGlobalAnchor->tokTbl, 0, sizeof(TokenInfo_t));
+ /* --- Init all modules ---*/
+
+ /* Init Workspace Module */
+ pWorkspaceOptions=(WsmOptions_t*)smlLibMalloc((MemSize_t)sizeof(WsmOptions_t)); // create workspace options
+ if (pWorkspaceOptions == NULL) {
+ smlLibFree(pGlobalAnchor->syncmlOptions);
+ smlLibFree(pGlobalAnchor->tokTbl);
+ smlLibFree(pGlobalAnchor);
+ pGlobalAnchor = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ smlLibMemset(pWorkspaceOptions,0,(MemSize_t)sizeof(WsmOptions_t));
+ pWorkspaceOptions->maxAvailMem=(MemSize_t)pGlobalAnchor->syncmlOptions->maxWorkspaceAvailMem;
+
+ rc = wsmInit (pWorkspaceOptions);
+ if (rc!=SML_ERR_OK){
+ smlLibFree(pGlobalAnchor->syncmlOptions);
+ smlLibFree(pGlobalAnchor->tokTbl);
+ smlLibFree(pGlobalAnchor);
+ pGlobalAnchor = NULL;
+ smlLibFree(pWorkspaceOptions);
+ return rc;
+ }
+ smlLibFree(pWorkspaceOptions);
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlTerminate
+ *
+ * Terminate SyncML. Frees all memory and other ressources used by
+ * SyncML. This function must be called when terminating SyncML
+ *
+ * PRE-Condition: All instances must have been terminated
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlTerminate(void) {
+ // Have all Instances been terminated?
+ if (pGlobalAnchor->instanceListAnchor!=NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ /* --- Make sure, the workspace is destroyed --*/
+ LOCKTOOLKIT("smlTerminate");
+ wsmTerminate();
+
+ /* --- Free the global structure --*/
+ smlLibFree(pGlobalAnchor->tokTbl->SyncML);
+ smlLibFree(pGlobalAnchor->tokTbl->MetInf);
+ smlLibFree(pGlobalAnchor->tokTbl->DevInf);
+ smlLibFree(pGlobalAnchor->tokTbl->DmTnd);
+ smlLibFree(pGlobalAnchor->tokTbl);
+ smlLibFree(pGlobalAnchor->syncmlOptions);
+ smlLibFree(pGlobalAnchor);
+ pGlobalAnchor=NULL;
+
+ TOOLKITLOCK_FREE("smlTerminate");
+
+ return SML_ERR_OK;
+
+}
+
+
+
+/**
+ * FUNCTION: smlSetSyncMLOptions
+ *
+ * change the option settings for syncML
+ *
+ * IN: SyncMLOptionsPtr_t
+ * options to be applied for the toolkit
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlSetSyncMLOptions(SmlOptionsPtr_t pCoreOptions) {
+
+
+ /* ---- Definitions --- */
+ SmlOptionsPtr_t pCoreOptionsCopy;
+
+
+ /* --- Check pOptions, which have been passed by the application --- */
+ if (!pCoreOptions)
+ return SML_ERR_WRONG_USAGE;
+
+
+ /* --- free SyncML options --- */
+ smlLibFree(pGlobalAnchor->syncmlOptions);
+ pGlobalAnchor->syncmlOptions = NULL;
+ /* --- Use a copy of pCoreOptions --- */
+ pCoreOptionsCopy = (SmlOptionsPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlOptions_t));
+ if (pCoreOptionsCopy==NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemcpy(pCoreOptionsCopy,pCoreOptions,(MemSize_t)sizeof(SmlOptions_t));
+
+
+ /* --- set new SyncML options --- */
+ pGlobalAnchor->syncmlOptions = pCoreOptionsCopy; // set the options,passed from the application
+
+ return SML_ERR_OK;
+
+}
+
+/*************************************************************************
+ * SyncML internal functions
+ *************************************************************************/
+/**
+ * FUNCTION: mgrGetSyncMLInfo
+ * Retrieves a pointer to the structure holding all global informations within SyncML
+ *
+ * RETURN: SyncMLInfoPtr_t
+ * Pointer to the pGlobalAnchor
+ */
+SyncMLInfoPtr_t mgrGetSyncMLAnchor(void)
+{
+ return pGlobalAnchor;
+}
+
+/**
+ * FUNCTION: mgrGetInstanceListAnchor
+ * Retrieves a pointer to the list holding all instance informations
+ *
+ * RETURN: InstanceInfoPtr_t
+ * Pointer to the pInstanceListAnchor
+ */
+InstanceInfoPtr_t mgrGetInstanceListAnchor(void)
+{
+ return pGlobalAnchor->instanceListAnchor;
+}
+
+/**
+ * FUNCTION: mgrSetInstanceListAnchor
+ * Set the pointer to the list holding all instance informations
+ *
+ * IN: InstanceInfoPtr_t
+ * Pointer to the pInstanceListAnchor
+ */
+void mgrSetInstanceListAnchor(InstanceInfoPtr_t newListAnchor)
+{
+ pGlobalAnchor->instanceListAnchor=newListAnchor;
+}
+
+
+#endif // !defined(NOWSM)
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/mgrcmdbuilder.c b/engine/dmlib/dmengine/oma_toolkit/src/mgrcmdbuilder.c
new file mode 100644
index 0000000..7cc0bbf
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/mgrcmdbuilder.c
@@ -0,0 +1,901 @@
+/*************************************************************************/
+/* module: SyncML Command Builder */
+/* */
+/* file: mgrcmdbuilder.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Core Module for assembling SyncML compliant documents */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <smldef.h>
+#include "xltenc.h"
+#include "xltdec.h"
+#include "libmem.h"
+#include "mgr.h"
+
+
+/* Used external functions */
+extern Ret_t smlLockWriteBuffer(InstanceID_t id, MemPtr_t *pWritePosition, MemSize_t *freeSize);
+extern Ret_t smlUnlockWriteBuffer(InstanceID_t id, MemSize_t writtenBytes);
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ extern Ret_t addInfo(InstanceInfoPtr_t pInfo);
+ extern InstanceInfoPtr_t findInfo(InstanceID_t id);
+ extern Ret_t removeInfo(InstanceID_t id);
+#endif
+
+/* Prototypes of exported SyncML API functions */
+SML_API Ret_t smlStartMessage(InstanceID_t id, SmlSyncHdrPtr_t pContent);
+SML_API Ret_t smlStartMessageExt(InstanceID_t id, SmlSyncHdrPtr_t pContent, SmlVersion_t vers);
+SML_API Ret_t smlEndMessage(InstanceID_t id, Boolean_t final);
+SML_API Ret_t smlStartSync(InstanceID_t id, SmlSyncPtr_t pContent);
+SML_API Ret_t smlEndSync(InstanceID_t id);
+
+#ifdef ATOMIC_SEND /* these API calls are NOT included in the Toolkit lite version */
+ SML_API Ret_t smlStartAtomic(InstanceID_t id, SmlAtomicPtr_t pContent);
+ SML_API Ret_t smlEndAtomic(InstanceID_t id);
+#endif
+#ifdef SEQUENCE_SEND
+ SML_API Ret_t smlStartSequence(InstanceID_t id, SmlSequencePtr_t pContent);
+ SML_API Ret_t smlEndSequence(InstanceID_t id);
+#endif
+
+#ifdef ADD_SEND
+ SML_API Ret_t smlAddCmd(InstanceID_t id, SmlAddPtr_t pContent);
+#endif
+SML_API Ret_t smlAlertCmd(InstanceID_t id, SmlAlertPtr_t pContent);
+SML_API Ret_t smlDeleteCmd(InstanceID_t id, SmlDeletePtr_t pContent);
+#ifdef GET_SEND
+ SML_API Ret_t smlGetCmd(InstanceID_t id, SmlGetPtr_t pContent);
+#endif
+SML_API Ret_t smlPutCmd(InstanceID_t id, SmlPutPtr_t pContent);
+SML_API Ret_t smlMapCmd(InstanceID_t id, SmlMapPtr_t pContent);
+SML_API Ret_t smlResultsCmd(InstanceID_t id, SmlResultsPtr_t pContent);
+SML_API Ret_t smlStatusCmd(InstanceID_t id, SmlStatusPtr_t pContent);
+SML_API Ret_t smlReplaceCmd(InstanceID_t id, SmlReplacePtr_t pContent);
+
+#ifdef COPY_SEND /* these API calls are NOT included in the Toolkit lite version */
+ SML_API Ret_t smlCopyCmd(InstanceID_t id, SmlCopyPtr_t pContent);
+#endif
+#ifdef EXEC_SEND
+ SML_API Ret_t smlExecCmd(InstanceID_t id, SmlExecPtr_t pContent);
+#endif
+#ifdef SEARCH_SEND
+ SML_API Ret_t smlSearchCmd(InstanceID_t id, SmlSearchPtr_t pContent);
+#endif
+
+/* Private function prototypes */
+static Ret_t mgrCreateNextCommand(InstanceID_t id, SmlProtoElement_t cmdType, VoidPtr_t pContent);
+Ret_t mgrResetWorkspace (InstanceID_t id);
+
+
+
+
+/*************************************************************************
+ * Exported SyncML API functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlStartMessage
+ *
+ * Start a SyncML Message
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlSyncHdrPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ *
+ * NOTE: (%%% luz 2003-08-06) this entry point is for compatibilty reasons only
+ * and works for SyncML 1.0 only
+ * please use smlStartMessageExt() instead in new projects.
+ */
+SML_API Ret_t smlStartMessage(InstanceID_t id, SmlSyncHdrPtr_t pContent)
+{
+ /* just call smlStartMessageExt with vers set to SyncML 1.0 */
+ return smlStartMessageExt(id,pContent,SML_VERS_1_1);
+}
+
+
+/**
+ * FUNCTION: smlStartMessageExt
+ * (%%% added by luz 2003-08-06 to support SyncML versions other than
+ * 1.0 with new vers parameter)
+ *
+ * Start a SyncML Message
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ * SyncML version
+ *
+ * IN: SmlSyncHdrPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartMessageExt(InstanceID_t id, SmlSyncHdrPtr_t pContent, SmlVersion_t vers)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+ MemPtr_t pCurrentWritePosition; // current Position from to which to write
+ MemPtr_t pBeginPosition; // saves the first position which has been written
+ MemSize_t freeSize; // size of free memory for writing
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- Get Write Access to the workspace --- */
+ rc = smlLockWriteBuffer(id, &pCurrentWritePosition, &freeSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+ #ifdef NOWSM
+ // remember where outgoing message starts in buffer
+ smlSetOutgoingBegin(id);
+ #endif
+
+ /* Remember the position we have started writing */
+ pBeginPosition=pCurrentWritePosition;
+
+ /* --- Call the encoder module --- */
+ /* (Saves the returned encoder state to the corresponding instanceInfo structure */
+ rc = xltEncInit(pInstanceInfo->instanceOptions->encoding, pContent,
+ pCurrentWritePosition+freeSize, &pCurrentWritePosition,
+ (XltEncoderPtr_t *)&(pInstanceInfo->encoderState),
+ vers);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // Reset the encoder module (free the encoding object)
+ xltEncReset(pInstanceInfo->encoderState);
+ // this encoding job is over! reset instanceInfo pointer
+ pInstanceInfo->encoderState=NULL;
+
+ return rc;
+ }
+
+ /* --- End Write Access to the workspace --- */
+ rc = smlUnlockWriteBuffer(id, (MemSize_t)pCurrentWritePosition-(MemSize_t)pBeginPosition);
+ return rc;
+}
+
+/**
+ * FUNCTION: smlEndMessage
+ *
+ * End a SyncML Message
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: Boolean_t
+ * Final Flag indicates last message within a package
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndMessage(InstanceID_t id, Boolean_t final)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+ MemPtr_t pCurrentWritePosition; // current Position from to which to write
+ MemPtr_t pBeginPosition; // saves the first position which has been written
+ MemSize_t freeSize; // size of free memory for writing
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // %%% luz 2003-08-19: added NULL check as previously failed encoding will delete encoder
+ if (pInstanceInfo->encoderState==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- Get Write Access to the workspace --- */
+ rc = smlLockWriteBuffer(id, &pCurrentWritePosition, &freeSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+
+ /* Remember the position we have started writing */
+ pBeginPosition=pCurrentWritePosition;
+
+ /* -- set Final Flag --*/
+ ((XltEncoderPtr_t)(pInstanceInfo->encoderState))->final = final;
+
+ /* --- Call the encoder module --- */
+ rc = xltEncTerminate(pInstanceInfo->encoderState, pCurrentWritePosition+freeSize,&pCurrentWritePosition);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // this encoding job is over! reset instanceInfo pointer
+ pInstanceInfo->encoderState=NULL;
+
+ return rc;
+ }
+
+ // this encoding job is over! reset instanceInfo pointer
+ // (the decoding object itself has been freed by the decoder)
+ pInstanceInfo->encoderState=NULL;
+
+ /* --- End Write Access to the workspace --- */
+ rc = smlUnlockWriteBuffer(id, (MemSize_t)pCurrentWritePosition-(MemSize_t)pBeginPosition);
+
+
+ return rc;
+}
+
+
+
+
+
+/**
+ * FUNCTION: smlStartSync
+ *
+ * Start synchronizing
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SyncPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartSync(InstanceID_t id, SmlSyncPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_SYNC_START, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlEndSync
+ *
+ * End synchronizing
+ *
+ * IN: InstanceID_t
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndSync(InstanceID_t id)
+{
+ return mgrCreateNextCommand(id, SML_PE_SYNC_END, NULL);
+}
+
+
+#ifdef ATOMIC_SEND /* these API calls are NOT included in the Toolkit lite version */
+
+/**
+ * FUNCTION: smlStartAtomic
+ *
+ * Start an atomic sequence
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlAtomicPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartAtomic(InstanceID_t id, SmlAtomicPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_ATOMIC_START, pContent);
+}
+
+
+/**
+ * FUNCTION: smlEndAtomic
+ *
+ * End an atomic sequence
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndAtomic(InstanceID_t id)
+{
+ return mgrCreateNextCommand(id, SML_PE_ATOMIC_END, NULL);
+}
+
+#endif
+
+#ifdef SEQUENCE_SEND
+
+/**
+ * FUNCTION: smlStartSequence
+ *
+ * Start a sequence
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SequencePtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartSequence(InstanceID_t id, SmlSequencePtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_SEQUENCE_START, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlEndSequence
+ *
+ * End a sequence
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndSequence(InstanceID_t id)
+{
+ return mgrCreateNextCommand(id, SML_PE_SEQUENCE_END, NULL);
+}
+
+#endif
+
+
+#ifdef ADD_SEND
+/**
+ * FUNCTION: smlAddCmd
+ *
+ * Create a Add Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlAddPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlAddCmd(InstanceID_t id, SmlAddPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_ADD, pContent);
+}
+#endif
+
+
+/**
+ * FUNCTION: smlAlertCmd
+ *
+ * Create a Alert Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlAlertPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlAlertCmd(InstanceID_t id, SmlAlertPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_ALERT, pContent);
+}
+
+
+
+
+/**
+ * FUNCTION: smlDeleteCmd
+ *
+ * Create a Start Message Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: DeletePtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlDeleteCmd(InstanceID_t id, SmlDeletePtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_DELETE, pContent);
+}
+
+
+
+#ifdef GET_SEND
+
+
+/**
+ * FUNCTION: smlGetCmd
+ *
+ * Create a Get Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: GetPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlGetCmd(InstanceID_t id, SmlGetPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_GET, pContent);
+}
+
+#endif
+
+
+/**
+ * FUNCTION: smlPutCmd
+ *
+ * Create a Put Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: PutPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlPutCmd(InstanceID_t id, SmlPutPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_PUT, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlMapCmd
+ *
+ * Create a Map Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: MapPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlMapCmd(InstanceID_t id, SmlMapPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_MAP, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlResultsCmd
+ *
+ * Create a Results Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: ResultsPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlResultsCmd(InstanceID_t id, SmlResultsPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_RESULTS, pContent);
+}
+
+
+
+
+
+/**
+ * FUNCTION: smlStatusCmd
+ *
+ * Create a Status Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: StatusPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStatusCmd(InstanceID_t id, SmlStatusPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_STATUS, pContent);
+}
+
+
+
+/**
+ * FUNCTION: smlReplaceCmd
+ *
+ * Create a Replace Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SmlReplacePtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlReplaceCmd(InstanceID_t id, SmlReplacePtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_REPLACE, pContent);
+}
+
+
+
+#ifdef COPY_SEND /* these API calls are NOT included in the Toolkit lite version */
+
+
+/**
+ * FUNCTION: smlCopyCmd
+ *
+ * Create a Copy Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: CopyPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlCopyCmd(InstanceID_t id, SmlCopyPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_COPY, pContent);
+}
+
+#endif
+
+#ifdef EXEC_SEND
+
+/**
+ * FUNCTION: smlExecCmd
+ *
+ * Create a Exec Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: ExecPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlExecCmd(InstanceID_t id, SmlExecPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_EXEC, pContent);
+}
+
+#endif
+
+#ifdef SEARCH_SEND
+
+/**
+ * FUNCTION: smlSearchCmd
+ *
+ * Create a Search Command
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN: SearchPtr_t
+ * Data to pass along with that SyncML command
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlSearchCmd(InstanceID_t id, SmlSearchPtr_t pContent)
+{
+ return mgrCreateNextCommand(id, SML_PE_SEARCH, pContent);
+}
+
+
+#endif
+
+
+/*************************************************************************
+ * Exported SyncML API functions (FULL-SIZE TOOLKIT ONLY)
+ *************************************************************************/
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+/**
+ * FUNCTION: smlStartEvaluation
+ *
+ * Starts an evaluation run which prevents further API-Calls to write tags -
+ * just the tag-sizes are calculated. Must be sopped via smlEndEvaluation
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlStartEvaluation(InstanceID_t id)
+{
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- Initialize Encoder for evaluation mode --- */
+
+ rc = xltStartEvaluation((XltEncoderPtr_t)(pInstanceInfo->encoderState));
+
+ return rc;
+}
+
+
+/**
+ * FUNCTION: smlEndEvaluation
+ *
+ * Stops an evaluation run which prevents further API-Calls to write tags -
+ * the remaining free buffer size after all Tags are written is returned
+ *
+ * IN: InstanceID_t
+ * ID of the used instance
+ *
+ * IN/OUT: MemSize_t
+ * Size of free buffer for data after all tags are written
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlEndEvaluation(InstanceID_t id, MemSize_t *freemem)
+{
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ // %%% luz 2002-09-03: encoder can be null here if fatal error occurred before
+ if (pInstanceInfo->encoderState==NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ rc = xltEndEvaluation(id, (XltEncoderPtr_t)(pInstanceInfo->encoderState), freemem);
+ return SML_ERR_OK;
+}
+
+#endif
+
+
+/*************************************************************************
+ * Private Functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION:
+ * Calls the encoding routines of the Encoder Module for a given Command Type
+ * and Command Content
+ *
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: ProtoElement_t
+ * Type of the command (defined by the Proto Element Enumeration)
+ *
+ * IN: VoidPtr_t
+ * Content of the command to encode
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if command has been encoded successfully
+ */
+static Ret_t mgrCreateNextCommand(InstanceID_t id, SmlProtoElement_t cmdType, VoidPtr_t pContent)
+{
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo; // pointer the the instance info structure for this id
+ Ret_t rc;
+ MemPtr_t pCurrentWritePosition; // current Position from to which to write
+ MemPtr_t pBeginPosition; // saves the first position which has been written
+ MemSize_t freeSize; // size of free memory for writing
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Retrieve the corresponding instanceInfo structure --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // %%% luz 2002-11-27: added NULL check as previously failed encoding will delete encoder
+ if (pInstanceInfo->encoderState==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ /* --- Get Write Access to the workspace --- */
+ rc = smlLockWriteBuffer(id, &pCurrentWritePosition, &freeSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+
+ // Remember the position we have started writing
+ pBeginPosition=pCurrentWritePosition;
+
+
+ /* --- Call the encoder module --- */
+ rc = xltEncAppend(pInstanceInfo->encoderState, cmdType, pCurrentWritePosition+freeSize, pContent, &pCurrentWritePosition);
+
+ if (rc!=SML_ERR_OK) {
+ /* check for full buffer and call TransmitChunk */
+ if (rc == SML_ERR_XLT_BUF_ERR) {
+ // first check wether callback is defined
+ if (pInstanceInfo->callbacks->transmitChunkFunc!= NULL) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // call the callback
+ pInstanceInfo->callbacks->transmitChunkFunc(id,NULL);
+ // lock -> returns the amount of free buffer space
+ smlLockWriteBuffer(id, &pCurrentWritePosition, &freeSize);
+ pBeginPosition = pCurrentWritePosition;
+ // now try again to encode and see wether we now have enough mem available
+ rc = xltEncAppend(pInstanceInfo->encoderState, cmdType, pCurrentWritePosition+freeSize, pContent, &pCurrentWritePosition);
+ // if rc == SML_ERR_OK continue else
+ // return the errorcode
+ if( rc != SML_ERR_OK)
+ {
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // Reset the encoder module (free the encoding object)
+ xltEncReset(pInstanceInfo->encoderState);
+ // this encoding job is over! reset instanceInfo pointer
+ pInstanceInfo->encoderState=NULL;
+ return rc;
+ }
+ }
+ } else {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockWriteBuffer(id, (MemSize_t)0);
+ // Reset the encoder module (free the encoding object)
+ xltEncReset(pInstanceInfo->encoderState);
+ // this encoding job is over! reset instanceInfo pointer
+ pInstanceInfo->encoderState=NULL;
+ return rc;
+ }
+ }
+ /* --- End Write Access to the workspace --- */
+ rc = smlUnlockWriteBuffer(id, (MemSize_t)pCurrentWritePosition-(MemSize_t)pBeginPosition);
+ return rc;
+}
+
+/* eof */
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/mgrcmddispatcher.c b/engine/dmlib/dmengine/oma_toolkit/src/mgrcmddispatcher.c
new file mode 100644
index 0000000..b49d787
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/mgrcmddispatcher.c
@@ -0,0 +1,504 @@
+/*************************************************************************/
+/* module: SyncML Command Dispatcher */
+/* */
+/* file: mgrcmddispatcher.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Core module for dispatching parsed commands and invoking callback */
+/* functions of the application */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+#include <define.h>
+/* Include Headers */
+#include <smldef.h>
+#include <smldtd.h>
+#include <smlerr.h>
+
+#include "libmem.h"
+#include "xltdec.h"
+#include "mgr.h"
+
+
+
+/* Used external functions */
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ extern Ret_t addInfo(InstanceInfoPtr_t pInfo);
+ extern InstanceInfoPtr_t findInfo(InstanceID_t id);
+ extern Ret_t removeInfo(InstanceID_t id);
+#endif
+Ret_t smlLockReadBuffer(InstanceID_t id, MemPtr_t *pReadPosition, MemSize_t *usedSize);
+Ret_t smlUnlockReadBuffer(InstanceID_t id, MemSize_t processedBytes);
+
+/* Prototypes of exported SyncML API functions */
+extern Ret_t smlProcessData(InstanceID_t id, SmlProcessMode_t mode);
+
+/* Private function prototypes */
+static Ret_t mgrProcessNextCommand(InstanceID_t id, InstanceInfoPtr_t pInstanceInfo);
+static Ret_t mgrProcessStartMessage(InstanceID_t id, InstanceInfoPtr_t pInstanceInfo);
+Ret_t mgrResetWorkspace (InstanceID_t id);
+
+
+
+/*************************************************************************
+ * Exported SyncML API functions
+ *************************************************************************/
+
+
+
+
+/**
+ * FUNCTION: smlProcessData
+ *
+ * Start the parsing of the XML code in the workspace buffer,
+ * dispatches the interpreted command and calls the corresponding callback
+ * functions provided by the application.
+ *
+ * IN: InstanceID_t
+ * The SyncML instance id is used for referencing the
+ * workspace buffer from the XML content is parsed
+ *
+ * IN: ProcessMode_t
+ * Mode of processing, Defines, if only the first or next
+ * XML command is parsed or if all commands are processed
+ * subsequently until the end of the entire workspace buffer
+ * is reached. The NEXT_COMMAND flag defines the blocking mode,
+ * the ALL_COMMANDS tag defines the non-blocking mode.
+ *
+ * RETURN: Ret_t
+ */
+SML_API Ret_t smlProcessData(InstanceID_t id, SmlProcessMode_t mode)
+{
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo; // state info for the given instanceID
+ Ret_t rc; // Temporary return code saver
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ /* --- Are callback functions defined? --- */
+ if (pInstanceInfo->callbacks==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+
+ /* --- Is parsing already in progress? --- */
+ if (pInstanceInfo->decoderState==NULL)
+ {
+ /* No! Parse the Message header section first */
+ rc = mgrProcessStartMessage(id, pInstanceInfo);
+
+ if (rc!=SML_ERR_OK) return rc;
+ }
+
+
+ /* --- Parse now the Message body section! --- */
+ do {
+ rc=mgrProcessNextCommand(id, pInstanceInfo);
+ } while (
+ // keep processing while no error occurs,
+ // AND the document end was not reached (decoderState has been invalidated),
+ // AND the ALL_COMMAND mode is used
+ (rc==SML_ERR_OK)
+ &&((pInstanceInfo->decoderState)!=NULL)
+ &&(mode==SML_ALL_COMMANDS)
+ );
+
+ if (rc != SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ }
+
+ return rc;
+}
+
+
+/*************************************************************************
+ * Private Functions
+ *************************************************************************/
+
+
+
+
+/**
+ * FUNCTION:
+ * Parses the header information at the beginning of an SyncML document.
+ *
+ * IN: InstanceID
+ * current InstanceID to pass to callback functions
+ *
+ * IN/OUT: InstanceInfo
+ * state information of the given InstanceID (decoder state will be changed)
+ *
+ * RETURN: Return value of the Parser,
+ * SML_ERR_OK if next command was handled successfully
+ */
+static Ret_t mgrProcessStartMessage(InstanceID_t id, InstanceInfoPtr_t pInstanceInfo)
+{
+
+
+ /* --- Definitions --- */
+ Ret_t rc; // Temporary return code saver
+ SmlSyncHdrPtr_t pContent=NULL; // data of the command to process
+ MemPtr_t pCurrentReadPosition ; // current Position from which is read
+ MemPtr_t pBeginPosition; // saves the first position which has been reading
+ MemSize_t usedSize ; // size of used memory to be read
+
+
+ /* --- Get Read Access to the workspace --- */
+ rc = smlLockReadBuffer(id, &pCurrentReadPosition, &usedSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+ // Remember the position we have started reading
+ pBeginPosition=pCurrentReadPosition;
+
+ /* --- Start new decoding sequence and pass returned decoder status structure to instanceInfo --- */
+ rc = xltDecInit(pInstanceInfo->instanceOptions->encoding,
+ pCurrentReadPosition+usedSize-1, &pCurrentReadPosition,
+ (XltDecoderPtr_t *)&(pInstanceInfo->decoderState), &pContent);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ return rc;
+ }
+
+ /* --- End Read Access to the workspace --- */
+ rc = smlUnlockReadBuffer(id, (MemSize_t)pCurrentReadPosition-(MemSize_t)pBeginPosition);
+ if (rc!=SML_ERR_OK) return rc;
+
+ /* --- Perform callback to handle the beginning of a new message --- */
+ if (pInstanceInfo->callbacks->startMessageFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ rc=pInstanceInfo->callbacks->startMessageFunc(id, pInstanceInfo->userData, pContent);
+
+ if (rc != SML_ERR_OK)
+ {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ }
+
+ return rc;
+}
+
+
+
+/**
+ * FUNCTION:
+ * Parses the next Sync Command in the sync document.
+ *
+ * IN: InstanceID
+ * current InstanceID to pass to callback functions
+ *
+ * IN: InstanceInfo
+ * state information of the given InstanceID
+ *
+ * RETURN: Return value of the Parser of the called application callback,
+ * SML_ERR_OK if next command was handled successfully
+ */
+static Ret_t mgrProcessNextCommand(InstanceID_t id, InstanceInfoPtr_t pInstanceInfo)
+{
+
+ /* --- Definitions --- */
+ Ret_t rc; // Temporary return code saver
+ SmlProtoElement_t cmdType; // ID of the command to process
+ VoidPtr_t pContent=NULL; // data of the command to process
+ MemPtr_t pCurrentReadPosition; // current Position from which is read
+ MemPtr_t pBeginPosition; // saves the first position which has been reading
+ MemSize_t usedSize; // size of used memory to be read
+ Boolean_t final; // flag indicates last message within a package
+
+
+ /* --- Get Read Access to the workspace --- */
+ rc = smlLockReadBuffer(id, &pCurrentReadPosition, &usedSize);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+ // Remember the position we have started reading
+ pBeginPosition=pCurrentReadPosition;
+
+
+ /* --- Parse next Command --- */
+ rc = xltDecNext(pInstanceInfo->decoderState, pCurrentReadPosition+usedSize, &pCurrentReadPosition, &cmdType, &pContent);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ return rc;
+ }
+
+ /* --- End Read Access to the workspace --- */
+ rc = smlUnlockReadBuffer(id, (MemSize_t)pCurrentReadPosition-(MemSize_t)pBeginPosition);
+
+ if (rc!=SML_ERR_OK) {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ return rc;
+ }
+
+ /* --- Did we reach end of synchronization document? --- */
+ if (((XltDecoderPtr_t)(pInstanceInfo->decoderState))->finished!=0) {
+ final = ((XltDecoderPtr_t)(pInstanceInfo->decoderState))->final; // flag is returned to appl. with callback
+ rc=xltDecTerminate(pInstanceInfo->decoderState);
+
+ if (rc!=SML_ERR_OK)
+ {
+ // abort, unlock the buffer again without changing it's current position
+ smlUnlockReadBuffer(id, (MemSize_t)0);
+ // Reset the decoder module (free the decoding object)
+ xltDecReset(pInstanceInfo->decoderState);
+ // this decoding job is over! reset Instance Info pointer
+ pInstanceInfo->decoderState=NULL;
+ // Reset the Workspace (the remaining unparsed document fragment will be lost)
+ mgrResetWorkspace(id);
+ return rc;
+ }
+
+ // this decoding job is over! reset Instance Info pointer
+ // (the decoding object itself has been freed by the decoder)
+ pInstanceInfo->decoderState=NULL;
+
+ // Call the callback for handling an message ending
+ if (pInstanceInfo->callbacks->endMessageFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+
+ rc=pInstanceInfo->callbacks->endMessageFunc(id, pInstanceInfo->userData, final);
+ return rc;
+ }
+
+ /* --- Dispatch parsed command (and call the applications command handler function)--- */
+ switch (cmdType)
+ {
+ /* Handle ADD Command */
+ case SML_PE_ADD:
+ if (pInstanceInfo->callbacks->addCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->addCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle ALERT Command */
+ case SML_PE_ALERT:
+ if (pInstanceInfo->callbacks->alertCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->alertCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle DELETE Command */
+ case SML_PE_DELETE:
+ if (pInstanceInfo->callbacks->deleteCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->deleteCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle PUT Command */
+ case SML_PE_PUT:
+ if (pInstanceInfo->callbacks->putCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->putCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle GET Command */
+ case SML_PE_GET:
+ if (pInstanceInfo->callbacks->getCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->getCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ #ifdef MAP_RECEIVE
+ /* Handle MAP Command */
+ case SML_PE_MAP:
+ if (pInstanceInfo->callbacks->mapCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->mapCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+ #endif
+
+ #ifdef RESULT_RECEIVE
+ /* Handle RESULTS Command */
+ case SML_PE_RESULTS:
+ if (pInstanceInfo->callbacks->resultsCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->resultsCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+ #endif
+
+ /* Handle STATUS Command */
+ case SML_PE_STATUS:
+ if (pInstanceInfo->callbacks->statusCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->statusCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle START SYNC Command */
+ case SML_PE_SYNC_START:
+ if (pInstanceInfo->callbacks->startSyncFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->startSyncFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle END SYNC Command */
+ case SML_PE_SYNC_END:
+ if (pInstanceInfo->callbacks->endSyncFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->endSyncFunc (id, pInstanceInfo->userData);
+ break;
+
+ /* Handle REPLACE Command */
+ case SML_PE_REPLACE:
+ if (pInstanceInfo->callbacks->replaceCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->replaceCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle Final Flag */
+ case SML_PE_FINAL:
+ // if a FINAL Flag appears do nothing
+ return SML_ERR_OK;
+ break;
+
+
+ #ifdef SEARCH_RECEIVE /* these API calls are NOT included in the Toolkit lite version */
+
+ /* Handle SEARCH Command */
+ case SML_PE_SEARCH:
+ if (pInstanceInfo->callbacks->searchCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->searchCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+ #endif
+
+ #ifdef SEQUENCE_RECEIVE
+ /* Handle START SEQUENCE Command */
+ case SML_PE_SEQUENCE_START:
+ if (pInstanceInfo->callbacks->startSequenceFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->startSequenceFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle END SEQUENCE Command */
+ case SML_PE_SEQUENCE_END:
+ if (pInstanceInfo->callbacks->endSequenceFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->endSequenceFunc (id, pInstanceInfo->userData);
+ break;
+ #endif
+
+ #ifdef ATOMIC_RECEIVE
+
+ /* Handle START ATOMIC Command */
+ case SML_PE_ATOMIC_START:
+ if (pInstanceInfo->callbacks->startAtomicFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->startAtomicFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ /* Handle END ATOMIC Command */
+ case SML_PE_ATOMIC_END:
+ if (pInstanceInfo->callbacks->endAtomicFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->endAtomicFunc (id, pInstanceInfo->userData);
+ break;
+ #endif
+
+ #ifdef COPY_RECEIVE
+
+ /* Handle COPY Command */
+ case SML_PE_COPY:
+ if (pInstanceInfo->callbacks->copyCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->copyCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+ #endif
+
+ #ifdef EXEC_RECEIVE
+
+ /* Handle EXEC Command */
+ case SML_PE_EXEC:
+ if (pInstanceInfo->callbacks->execCmdFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ return pInstanceInfo->callbacks->execCmdFunc (id, pInstanceInfo->userData, pContent);
+ break;
+
+ #endif
+
+ /* Handle ERROR DETECTED */
+ //case SML_PE_ERROR:
+ // if (pInstanceInfo->callbacks->handleErrorFunc==NULL) return SML_ERR_COMMAND_NOT_HANDLED;
+ // return pInstanceInfo->callbacks->handleErrorFunc (id, pInstanceInfo->userData);
+ // break;
+
+ /* --- Invalid Command Element --- */
+ default:
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+ break;
+ } // switch
+}
+
+/* eof */
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/mgrinstancelist.c b/engine/dmlib/dmengine/oma_toolkit/src/mgrinstancelist.c
new file mode 100644
index 0000000..6d38341
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/mgrinstancelist.c
@@ -0,0 +1,233 @@
+/*************************************************************************/
+/* module: List of SyncML Instances */
+/* */
+/* file: mgrinstancelist.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* This module handles an element list of type InstanceInfo. Each */
+/* element is identified by the InstanceID. There are functions provided */
+/* to add, find and remove InstanceInfo elements. */
+/* This file is private to the core module. The InstanceInfo list is */
+/* used by the Modules MGR, MGRCmdDispatcher, MGRCmdBuilder */
+/* and MGRInstanceMgr. */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <smlerr.h>
+#include "libmem.h"
+#include "liblock.h"
+#include "mgr.h"
+
+#ifndef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+
+#ifndef NOWSM /* only need if we are using workspace manager */
+
+
+/* Used external functions */
+SyncMLInfoPtr_t mgrGetSyncMLAnchor(void);
+InstanceInfoPtr_t mgrGetInstanceListAnchor(void);
+void mgrSetInstanceListAnchor(InstanceInfoPtr_t newListAnchor);
+
+
+/* SyncML internal function prototypes */
+Ret_t addInfo(InstanceInfoPtr_t pInfo);
+InstanceInfoPtr_t findInfo(InstanceID_t id);
+Ret_t removeInfo(InstanceID_t id);
+
+
+/* Private function prototypes */
+
+
+
+
+
+
+/*************************************************************************
+ * SyncML internal functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION:
+ * Adds a new element to the list
+ *
+ * IN: InstanceInfoPtr_t
+ * pointer to the structure to be be added to list
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if element was added successfully
+ */
+Ret_t addInfo(InstanceInfoPtr_t pInfo)
+{
+
+ if (pInfo!=NULL)
+ {
+ InstanceInfoPtr_t _pTmp;
+
+ LOCKTOOLKIT("addInfo");
+ /* Remember old beginning of the list */
+ _pTmp=mgrGetInstanceListAnchor();
+
+ /* insert element immediately after anchor */
+ mgrSetInstanceListAnchor(pInfo); // anchor of list points now to new info element
+ pInfo->nextInfo=_pTmp; // Next info element is the prior first one.
+ RELEASETOOLKIT("addInfo");
+ return SML_ERR_OK;
+
+ } else { // Invalid InstanceInfo pointer was used (NULL)
+
+ return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ }
+
+}
+
+
+
+
+
+/**
+ * FUNCTION:
+ * Searches an element with the given InstanceID in the list
+ *
+ * IN: InstanceID_t
+ * ID of the InstanceInfo structure to be retrieved
+ *
+ * RETURN: InstanceInfoPtr_t
+ * Pointer to the InstanceInfo structure with the given ID
+ * NULL, if no InstanceInfo with the given ID has been found
+ */
+InstanceInfoPtr_t findInfo(InstanceID_t id)
+{
+
+ InstanceInfoPtr_t _pTmp; // A helper pointer
+
+ /* go through the list until end */
+ LOCKTOOLKIT("findInfo");
+ for (_pTmp=mgrGetInstanceListAnchor(); _pTmp!=NULL; _pTmp=_pTmp->nextInfo)
+ {
+ if (_pTmp->id == id) {
+ RELEASETOOLKIT("findInfo");
+ return _pTmp; // STOP, we've found the info, return!
+ }
+ }
+ RELEASETOOLKIT("findInfo");
+ return NULL; // Info was not found, return NULL
+
+}
+
+
+
+
+
+/**
+ * FUNCTION:
+ * Removes an element with the given InstanceID from the list
+ *
+ * IN: InstanceID_t
+ * ID of the InstanceInfo structure to be removed
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if element was removed successfully
+ */
+Ret_t removeInfo(InstanceID_t id)
+{
+
+ InstanceInfoPtr_t _pTmp; // A helper pointer
+ InstanceInfoPtr_t _pRemember; // A helper pointer
+
+
+ LOCKTOOLKIT("removeInfo");
+ /* Remember current anchor */
+ _pRemember=mgrGetInstanceListAnchor();
+
+ /* special check, if list is empty */
+ if (_pRemember==NULL ) {
+ RELEASETOOLKIT("removeInfo");
+ return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ }
+
+ /* special check, if first element should be removed */
+ if (_pRemember->id == id)
+ {
+ // It's the first element, update anchor!
+ mgrSetInstanceListAnchor(_pRemember->nextInfo);
+ //freeInfo(_pRemember); // Delete structure, free memory
+ RELEASETOOLKIT("removeInfo");
+ return SML_ERR_OK; // return
+ }
+
+
+ /* go through the list until end */
+ for (_pTmp=_pRemember->nextInfo; _pTmp!=NULL; _pTmp=_pTmp->nextInfo)
+ {
+ if (_pTmp->id == id) // STOP, we've found the info
+ {
+ _pRemember->nextInfo=_pTmp->nextInfo;
+ //freeInfo(_pTmp); // Delete structure, free memory
+ RELEASETOOLKIT("removeInfo");
+ return SML_ERR_OK; // return
+
+ } else {
+
+ _pRemember=_pTmp; // update helper pointer
+ }
+ }
+
+ RELEASETOOLKIT("removeInfo");
+ return SML_ERR_MGR_INVALID_INSTANCE_INFO; // Info wasn't found
+
+}
+
+
+
+
+#endif // !defined(NOWSM)
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/mgrinstancemgr.c b/engine/dmlib/dmengine/oma_toolkit/src/mgrinstancemgr.c
new file mode 100644
index 0000000..95a82d9
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/mgrinstancemgr.c
@@ -0,0 +1,1080 @@
+/*************************************************************************/
+/* module: Managing SyncML Instances */
+/* */
+/* file: mgrinstancemgr.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/* Core module for managing creation and usage of instances */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <smldef.h>
+#include <sml.h>
+#include <smlerr.h>
+#include "libmem.h"
+#include "libstr.h"
+#include "liblock.h"
+#include "wsm.h"
+#include "mgr.h"
+
+
+
+/* Used external functions */
+#ifndef NOWSM
+ #ifndef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ extern Ret_t addInfo(InstanceInfoPtr_t pInfo);
+ extern InstanceInfoPtr_t findInfo(InstanceID_t id);
+ extern Ret_t removeInfo(InstanceID_t id);
+ #endif
+ SyncMLInfoPtr_t mgrGetSyncMLAnchor(void);
+#endif
+
+/* Prototypes of exported SyncML API functions */
+SML_API Ret_t smlInitInstance(SmlCallbacksPtr_t callbacks, SmlInstanceOptionsPtr_t pOptions, VoidPtr_t pUserData, InstanceID_t *pInstanceID);
+SML_API Ret_t smlTerminateInstance (InstanceID_t id);
+SML_API Ret_t smlLockReadBuffer(InstanceID_t id, MemPtr_t *pReadPosition, MemSize_t *usedSize);
+SML_API Ret_t smlUnlockReadBuffer(InstanceID_t id, MemSize_t processedBytes);
+#ifdef NOWSM
+SML_API Ret_t smlSetMaxOutgoingSize(InstanceID_t id, MemSize_t maxOutgoingSize);
+SML_API Ret_t smlSetOutgoingBegin(InstanceID_t id);
+#endif
+SML_API Ret_t smlLockWriteBuffer(InstanceID_t id, MemPtr_t *pWritePosition, MemSize_t *freeSize);
+SML_API Ret_t smlUnlockWriteBuffer(InstanceID_t id, MemSize_t writtenBytes);
+SML_API Ret_t smlSetCallbacks (InstanceID_t id, SmlCallbacksPtr_t pCallbacks);
+SML_API Ret_t smlSetUserData (InstanceID_t id, VoidPtr_t pUserData);
+// added by luz %%%:
+SML_API Ret_t smlGetUserData(InstanceID_t id, VoidPtr_t *ppUserData);
+SML_API Ret_t smlGetEncoding(InstanceID_t id, SmlEncoding_t *pEncoding);
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+ SML_API Ret_t smlSetEncoding (InstanceID_t id, SmlEncoding_t encoding);
+#endif
+
+
+
+/* Private function prototypes */
+Ret_t freeInstanceOptions (InstanceInfoPtr_t pInstanceInfo);
+static Ret_t freeInstanceInfo (InstanceInfoPtr_t pInfo);
+Ret_t mgrResetWorkspace (InstanceID_t id);
+Ret_t setInstanceOptions (InstanceID_t id, SmlInstanceOptionsPtr_t pOptions);
+
+
+/*************************************************************************
+ * Public SyncML API Functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: smlInitInstance
+ *
+ * Creates a SyncML instance and assigns a corresponding workspace buffer in
+ * which XML documents are assembled or parsed.
+ * All callback functions implemented by a particular application are defined.
+ * Instance specific options can be passed. This function has to be called
+ * before the first synchronization tasks can be performed. A reference valid
+ * for a SyncML instance is returned.
+ * An instance is active when processing a synchronization request
+ * otherwise it is idle. An instance is terminated when smlTerminateInstance
+ * is called.
+ *
+ * IN: SmlCallbacks_t
+ * A structure holding references to the callback functions
+ * implemented by the application
+ *
+ * IN: SmlInstanceOptionsPtr_t
+ * Option settings of a particular SyncML instance
+ *
+ * IN: VoidPtr_t
+ * UserData is a pointer to a void structure the application
+ * can pass into the SyncML Toolkit instance info.
+ * It will be returned to the application with every called
+ * callback function call!
+ * NOTE: This is only a pointer, the memory object itself
+ * remains within the responsibility of the calling application.
+ * The memory object will not be copied, moved or freed by the
+ * Toolkit.
+ *
+ * OUT: InstanceID_t
+ * Instance ID assigned to the initialized instance
+ *
+ * RETURN: Ret_t
+ * Error Code
+ */
+SML_API Ret_t smlInitInstance(SmlCallbacksPtr_t pCallbacks, SmlInstanceOptionsPtr_t pOptions, VoidPtr_t pUserData, InstanceID_t *pInstanceID)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+ Ret_t rc;
+
+
+ #ifndef NOWSM
+ /* --- Check pOptions, which have been passed by the application --- */
+ if (!pOptions || !pOptions->workspaceName)
+ return SML_ERR_WRONG_USAGE;
+
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ /* if ONE instance is already initialized */
+ if (mgrGetInstanceListAnchor()!=NULL)
+ return SML_ERR_WRONG_USAGE;
+ #endif
+
+ /* --- check wether we already know about this instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(*pInstanceID);
+ #endif
+
+ /* --- bail outh when we already have a instance with that id --- */
+ if (pInstanceInfo != NULL) return SML_ERR_WRONG_USAGE;
+
+
+ /* --- Create a workspace for this instance --- */
+ LOCKTOOLKIT("smlInitInstance");
+ if ((rc = wsmCreate(pOptions->workspaceName, pOptions->workspaceSize, pInstanceID)) != SML_ERR_OK) {
+ RELEASETOOLKIT("smlInitInstance after wsmCreate failure");
+ return rc;
+ }
+ RELEASETOOLKIT("smlInitInstance");
+ #else // NOWSM
+ /* --- Check pOptions, which have been passed by the application --- */
+ if (!pOptions || !pOptions->workspaceSize)
+ return SML_ERR_WRONG_USAGE;
+ // ok so far
+ rc=SML_ERR_OK;
+ #endif
+
+ /* --- Create an instance info memory object --- */
+ pInstanceInfo = (InstanceInfoPtr_t)smlLibMalloc((MemSize_t)sizeof(InstanceInfo_t));
+ if (pInstanceInfo==NULL) {
+ #ifndef NOWSM
+ wsmDestroy(pOptions->workspaceName);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ #endif
+ }
+ #ifdef NOWSM
+ else {
+ // instance info created, return pointer as instanceID
+ *pInstanceID = (InstanceID_t)pInstanceInfo;
+ }
+ #endif
+
+ smlLibMemset(pInstanceInfo,0,(MemSize_t)sizeof(InstanceInfo_t));
+
+
+
+ /* --- Set mandatory instance infos for this instance to defaults --- */
+ pInstanceInfo->status=MGR_IDLE;
+ pInstanceInfo->encoderState=NULL; // no encoding in progress, currently not used
+ pInstanceInfo->decoderState=NULL; // no decoding in progress, currently not used
+ #ifndef NOWSM
+ pInstanceInfo->id=*pInstanceID;
+ pInstanceInfo->workspaceState=NULL; // to do: some workspace status info
+ pInstanceInfo->nextInfo=NULL;
+ #else
+ // create a instance buffer
+ pInstanceInfo->instanceBufSiz=pOptions->workspaceSize; // get requested size for the buffer
+ pInstanceInfo->maxOutgoingSize=pOptions->maxOutgoingSize; // set max outgoing message size
+ pInstanceInfo->instanceBuffer=smlLibMalloc(pInstanceInfo->instanceBufSiz);
+ if (pInstanceInfo->instanceBuffer==NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ // init buffer pointers
+ pInstanceInfo->readPointer=pInstanceInfo->instanceBuffer;
+ pInstanceInfo->writePointer=pInstanceInfo->instanceBuffer;
+ pInstanceInfo->readLocked=0;
+ pInstanceInfo->writeLocked=0;
+ pInstanceInfo->outgoingMsgStart=NULL;
+ #endif
+
+
+ #ifndef NOWSM
+ /* --- Add instance infos memory object to the instance info list --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ mgrSetInstanceListAnchor(pInstanceInfo);
+ #else
+ rc = addInfo( pInstanceInfo );
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+ #endif
+
+
+ /* --- Set the values of instance Infos as defined by the calling application ---*/
+
+ /* Set user data pointer */
+ pInstanceInfo->userData=pUserData;
+ /* Set callback functions implemented by applications */
+ if (smlSetCallbacks(*pInstanceID, pCallbacks) != SML_ERR_OK) {
+ #ifndef NOWSM
+ wsmDestroy(pOptions->workspaceName);
+ #endif
+ return rc;
+ }
+
+ // luz: %%% this was called twice, probably this is a bug, so I disabled the second call
+ //smlSetCallbacks(*pInstanceID, pCallbacks);
+
+ /* Set other application defined options for that instance */
+ if (setInstanceOptions (*pInstanceID, pOptions) != SML_ERR_OK) {
+ #ifndef NOWSM
+ wsmDestroy(pOptions->workspaceName);
+ #endif
+ return rc;
+ }
+
+ return SML_ERR_OK;
+
+}
+
+
+
+/**
+ * FUNCTION: smlTerminateInstance
+ *
+ * Terminates a SyncML instance. The instance info is removed from the instances
+ * list. Allmemory allocated for the workspace and the options variables is freed.
+ *
+ * IN: InstanceID_t
+ * ID of the instance to be terminated
+ *
+ * RETURN: Ret_t
+ * Error Code
+ */
+SML_API Ret_t smlTerminateInstance (InstanceID_t id)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ Ret_t rc;
+
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ #ifndef NOWSM
+ /* --- Close the workspace --- */
+ if (pInstanceInfo->instanceOptions != NULL) {
+ LOCKTOOLKIT("smlTerminateInstance");
+ rc = wsmDestroy(pInstanceInfo->instanceOptions->workspaceName);
+ RELEASETOOLKIT("smlTerminateInstance");
+ if (rc!=SML_ERR_OK) {
+ // freeInstanceInfo(pInstanceInfo);
+ return rc;
+ }
+ }
+
+ /* --- Delete instance info and options --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ mgrSetInstanceListAnchor(NULL);
+ #else
+ removeInfo(id);
+ #endif
+ #endif
+
+ freeInstanceInfo (pInstanceInfo);
+
+ return SML_ERR_OK;
+}
+
+
+
+/**
+ * FUNCTION: smlSetCallbacks
+ *
+ * Sets new callback functions to an instance
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: SmlCallbacksPtr_t
+ * A structure holding references to the callback functions
+ * implemented by the application
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlSetCallbacks(InstanceID_t id, SmlCallbacksPtr_t pCallbacks)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+ SmlCallbacksPtr_t pCallbacksCopy;
+
+ /* --- Check pCallbacks, which have been passed by the application --- */
+ if (!pCallbacks)
+ return SML_ERR_WRONG_USAGE;
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ #endif
+
+ /* --- free old callback structure ---*/
+ smlLibFree(pInstanceInfo->callbacks);
+
+
+ /* --- Use a copy of pCallbacksCopy --- */
+ pCallbacksCopy = (SmlCallbacksPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlCallbacks_t));
+ if (pCallbacksCopy==NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemcpy(pCallbacksCopy,pCallbacks,(MemSize_t)sizeof(SmlCallbacks_t));
+
+
+ /* --- set new Callbacks --- */
+ pInstanceInfo->callbacks = pCallbacksCopy;
+
+ return SML_ERR_OK;
+}
+
+
+
+/**
+ * FUNCTION: smlSetUserData
+ *
+ * Sets a new Pointer to application specific user data,
+ * which is passed to all invoked callback functions
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: VoidPtr_t
+ * UserData is a pointer to a void structure the application
+ * can pass into the SyncML Toolkit instance info.
+ * It will be returned to the application with every called
+ * callback function call!
+ * NOTE: This is only a pointer, the memory object itself
+ * remains within the responsibility of the calling application.
+ * The memory object will not be copied, moved or freed by the
+ * Toolkit.
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlSetUserData(InstanceID_t id, VoidPtr_t pUserData)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- set new user data pointer ---*/
+ pInstanceInfo->userData=pUserData;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlGetUserData (added by luz %%%)
+ *
+ * Returns Pointer to application specific user data,
+ * which is passed to all invoked callback functions
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: *VoidPtr_t
+ * Receives current Userdata pointer
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlGetUserData(InstanceID_t id, VoidPtr_t *ppUserData)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- get userdata pointer ---*/
+ *ppUserData = pInstanceInfo->userData;
+
+ return SML_ERR_OK;
+} // smlGetUserData
+
+
+/**
+ * FUNCTION: smlGetEncoding (added by luz %%%)
+ *
+ * Returns Currently set encoding type
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: *SmlEncoding_t
+ * Receives current encoding
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlGetEncoding(InstanceID_t id, SmlEncoding_t *pEncoding)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ /* --- get encoding ---*/
+ *pEncoding = pInstanceInfo->instanceOptions->encoding;
+
+ return SML_ERR_OK;
+} // smlGetEncoding
+
+
+/**
+ * FUNCTION: smlSetEncoding
+ *
+ * Sets new encoding type for this Instance
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: SmlEncoding_t
+ * Type of Encoding to be used within this Instance
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+SML_API Ret_t smlSetEncoding(InstanceID_t id, SmlEncoding_t encoding)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+
+ /* --- Check pCallbacks, which have been passed by the application --- */
+ if (encoding==SML_UNDEF)
+ return SML_ERR_WRONG_USAGE;
+
+
+ #ifdef NOWSM
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+
+ /* --- free old callback structure ---*/
+ pInstanceInfo->instanceOptions->encoding = encoding;
+
+ return SML_ERR_OK;
+}
+#endif
+
+
+
+
+/**
+ * FUNCTION: smlLockReadBuffer
+ *
+ * Locks the workspace buffer, which is assigned to the given instance
+ * for reading. After this function is called, the application has
+ * access to the workspace buffer, beginning at the address pReadPosition which
+ * is returned by this function. SyncML will not change the workspace
+ * buffer until smlUnlockReadBuffer is called.
+ * pReadPosition returns a pointer to a valid position in the SyncML workspace
+ * buffer. The pointer can be used by the application for copying outgoing
+ * synchronization data from the buffer into some transport layer. usedSize
+ * retrieves the size of synchronization data currently stored in the
+ * workspace buffer beginning from the address to which pReadPosition points to.
+ * This information is needed by the application when copying XML code out
+ * of the buffer (while sending synchronization data)
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * OUT: MemPtr_t
+ * Workspace Pointer from which data can be read
+ *
+ * OUT: MemSize_t
+ * Size of used data in workspace which may be read
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlLockReadBuffer(InstanceID_t id, MemPtr_t *pReadPosition, MemSize_t *usedSize)
+{
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // must not be already locked here
+ if (pInstanceInfo->readLocked)
+ return SML_ERR_WRONG_USAGE;
+ // everything that is already written can also be read
+ *pReadPosition = pInstanceInfo->readPointer;
+ // used portion is what is between read and write pointers
+ *usedSize = pInstanceInfo->writePointer-pInstanceInfo->readPointer;
+ // lock
+ pInstanceInfo->readLocked=1;
+ #else
+ Ret_t rc;
+
+ LOCKTOOLKIT("smlLockReadBuffer");
+ /* --- Lock Workspace exclusively for reading and get a "Read" pointer --- */
+ rc = wsmLockH(id, SML_FIRST_DATA_ITEM, pReadPosition);
+ RELEASETOOLKIT("smlLockReadBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+
+ /* --- Check, how much data has to be read ---*/
+ LOCKTOOLKIT("smlLockReadBuffer");
+ rc = wsmGetUsedSize(id,usedSize);
+ RELEASETOOLKIT("smlLockReadBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+
+ return SML_ERR_OK;
+}
+
+
+
+
+/**
+ * FUNCTION: smlUnlockReadBuffer
+ *
+ * End the read access of the application to the workspace buffer.
+ * SyncML is now owner of the buffer again and is able to manipulate its contents.
+ * processedBytes passes the number of bytes, which the application has
+ * successfully read and processed (e.g. when the application has copied
+ * outgoing synchronization data from the workspace into a communication module).
+ * SyncML removes the given number of bytes from the workspace!
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: MemSize_t
+ * Actually read and processed bytes
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlUnlockReadBuffer(InstanceID_t id, MemSize_t processedBytes)
+{
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // must be already locked here
+ if (!pInstanceInfo->readLocked)
+ return SML_ERR_WRONG_USAGE;
+ // advance read pointer by number of bytes processed
+ if (pInstanceInfo->readPointer+processedBytes>pInstanceInfo->writePointer)
+ return SML_ERR_WRONG_USAGE; // too many bytes processed
+ // update read pointer
+ pInstanceInfo->readPointer+=processedBytes;
+ // auto-reset pointers if we have now read everything
+ if (pInstanceInfo->readPointer == pInstanceInfo->writePointer) {
+ // clear the buffer
+ mgrResetWorkspace(pInstanceInfo);
+ }
+ // unlock
+ pInstanceInfo->readLocked=0;
+ #else
+ Ret_t rc;
+
+ /* --- Pass the number of bytes which have been read --- */
+ LOCKTOOLKIT("smlUnlockReadBuffer");
+ rc = wsmProcessedBytes (id,processedBytes);
+ RELEASETOOLKIT("smlUnlockReadBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+
+ /* --- Unlock Workspace --- */
+ LOCKTOOLKIT("smlUnlockReadBuffer");
+ rc = wsmUnlockH(id);
+ RELEASETOOLKIT("smlUnlockReadBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+
+ return SML_ERR_OK;
+}
+
+
+#ifdef NOWSM
+
+/**
+ * FUNCTION: smlSetMaxOutgoingSize
+ *
+ * marks the current write pointer position as beginning of a new outgoing
+ * message. This is used to track outgoing message size while writing it
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: MemSize_t
+ * maximum size of outgoing message (0=no limit except buffer size)
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlSetMaxOutgoingSize(InstanceID_t id, MemSize_t maxOutgoingSize)
+{
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ // set max outgoing message size
+ pInstanceInfo->maxOutgoingSize = maxOutgoingSize;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlSetOutgoingBegin
+ *
+ * marks the current write pointer position as beginning of a new outgoing
+ * message. This is used to track outgoing message size while writing it
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlSetOutgoingBegin(InstanceID_t id)
+{
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ // remember current write pointer
+ pInstanceInfo->outgoingMsgStart=pInstanceInfo->writePointer;
+
+ return SML_ERR_OK;
+}
+
+#endif
+
+/**
+ * FUNCTION: smlLockWriteBuffer
+ *
+ * Locks the workspace buffer, which is assigned to the given
+ * instance for writing. After this function is called, the
+ * application has access to the workspace buffer, beginning
+ * at the address pWritePosition which is returned by this
+ * function. SyncML will not change the workspace buffer until
+ * smlUnlockWriteBuffer is called.
+ * pWritePosition returns a pointer to a valid position in the
+ * SyncML workspace buffer. The pointer can be used by the application
+ * for copying incoming synchronization data from some transport
+ * layer into the buffer. freeSize retrieves the maximum usable
+ * size of the workspace buffer beginning from the address to
+ * which pWritePosition points to. This information is needed by
+ * the application when copying XML code into the buffer (while
+ * receiving synchronization data)
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * OUT: MemPtr_t
+ * Workspace Pointer to which data can be written
+ *
+ * OUT: MemSize_t
+ * Max free Size of available space for data
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlLockWriteBuffer(InstanceID_t id, MemPtr_t *pWritePosition, MemSize_t *freeSize)
+{
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // must not be already locked here
+ if (pInstanceInfo->writeLocked)
+ return SML_ERR_WRONG_USAGE;
+ // return current write pointer
+ *pWritePosition = pInstanceInfo->writePointer;
+ // free portion is either determined by actual room in buffer, or maximum outgoing size if set
+ if (
+ pInstanceInfo->maxOutgoingSize &&
+ pInstanceInfo->outgoingMsgStart &&
+ pInstanceInfo->outgoingMsgStart<pInstanceInfo->writePointer
+ ) {
+ // calculate what is allowed according to maxOutgoingSize
+ *freeSize =
+ (pInstanceInfo->maxOutgoingSize) - // maximum outgoing size
+ (pInstanceInfo->writePointer-pInstanceInfo->outgoingMsgStart); // size of outgoing message so far
+ if (pInstanceInfo->writePointer+*freeSize > pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz) {
+ // actual space in buffer is smaller
+ *freeSize =
+ (pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz) - // end of buffer
+ pInstanceInfo->writePointer; // current write position
+ }
+ }
+ else {
+ // simply return available size in buffer
+ *freeSize =
+ (pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz) - // end of buffer
+ pInstanceInfo->writePointer; // current write position
+ }
+ // lock
+ pInstanceInfo->writeLocked=1;
+ #else
+ Ret_t rc;
+
+ /* --- Lock Workspace exclusively for writing and get a "Write" pointer --- */
+ LOCKTOOLKIT("smlLockWriteBuffer");
+ rc = wsmLockH(id, SML_FIRST_FREE_ITEM, pWritePosition);
+ RELEASETOOLKIT("smlLockWriteBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+
+ /* --- Check, how much free space is available for writing --- */
+ LOCKTOOLKIT("smlLockWriteBuffer");
+ rc = wsmGetFreeSize(id, freeSize);
+ RELEASETOOLKIT("smlLockWriteBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+
+ return SML_ERR_OK;
+}
+
+
+
+
+/**
+ * FUNCTION: smlUnlockWriteBuffer
+ *
+ * End the write access of the application to the workspace buffer.
+ * SyncML is now owner of the buffer again and is able to manipulate its
+ * contents. writtenBytes passes the number of bytes which have been
+ * written into the workspace buffer (e.g. when the application has copied
+ * incoming synchronization data from a communication module into the
+ * workspace). This information is needed by SyncML when processing received
+ * synchronization data.
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ *
+ * IN: MemSize_t
+ * Actually written bytes
+ *
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+SML_API Ret_t smlUnlockWriteBuffer(InstanceID_t id, MemSize_t writtenBytes)
+{
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+ // must be already locked here
+ if (!pInstanceInfo->writeLocked)
+ return SML_ERR_WRONG_USAGE;
+ if (writtenBytes > 0) {
+ // advance write pointer by number of bytes written
+ if (pInstanceInfo->writePointer+writtenBytes>pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz)
+ return SML_ERR_WRONG_USAGE; // too many bytes written
+ // update write pointer
+ pInstanceInfo->writePointer+=writtenBytes;
+ }
+ // unlock
+ pInstanceInfo->writeLocked=0;
+ #else
+ Ret_t rc;
+
+ if (writtenBytes > 0)
+ {
+ /* --- Pass the number of bytes which have been written --- */
+ LOCKTOOLKIT("smlUnlockWriteBuffer");
+ rc = wsmSetUsedSize(id,writtenBytes);
+ RELEASETOOLKIT("smlUnlockWriteBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ }
+ /* --- Unlock Workspace --- */
+ LOCKTOOLKIT("smlUnlockWriteBuffer");
+ rc = wsmUnlockH(id);
+ RELEASETOOLKIT("smlUnlockWriteBuffer");
+ if (rc!=SML_ERR_OK) return rc;
+ #endif
+
+ return SML_ERR_OK;
+}
+
+
+
+
+/*************************************************************************
+ * SyncML internal functions
+ *************************************************************************/
+
+
+/**
+ * FUNCTION: mgrResetWorkspace
+ * Reset the Workspace Buffer position to the beginning of the workspace
+ * (clears all data in the buffer)
+ *
+ * IN: InstanceID_t
+ * ID of the Instance
+ * RETURN: Return value,
+ * SML_ERR_OK if successful
+ */
+Ret_t mgrResetWorkspace (InstanceID_t id) {
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ pInstanceInfo->readPointer=pInstanceInfo->instanceBuffer;
+ pInstanceInfo->writePointer=pInstanceInfo->instanceBuffer;
+ pInstanceInfo->outgoingMsgStart=NULL; // no outgoing message in the buffer
+ return SML_ERR_OK; // ok
+ #else
+ Ret_t rc;
+ LOCKTOOLKIT("mgrResetWorkspace");
+ rc=wsmReset (id);
+ RELEASETOOLKIT("mgrResetWorkspace");
+ return rc;
+ #endif
+}
+
+
+
+/**
+ * FUNCTION: setInstanceOptions
+ *
+ * the options settings of an instance are set to a new value
+ *
+ * IN: InstanceID_t
+ * Instance ID assigned to the instance
+ *
+ * IN: SmlInstanceOptionsPtr_t
+ * New option settings of that particular SyncML instance
+ * NOTE: only the encoding can be changed during life-time
+ * of an instance
+ * The other parameters of the instance options
+ * (workspace size and name cannot be changed)
+ *
+ * RETURN: Ret_t
+ * Error Code
+ */
+Ret_t setInstanceOptions (InstanceID_t id, SmlInstanceOptionsPtr_t pOptions)
+{
+
+ /* --- Definitions --- */
+ InstanceInfoPtr_t pInstanceInfo;
+ SmlInstanceOptionsPtr_t pOptionsCopy;
+
+
+ #ifdef NOWSM
+ /* --- Ckeck pOptions, which have been passed by the application --- */
+ if (!pOptions || (pOptions->encoding==SML_UNDEF))
+ return SML_ERR_WRONG_USAGE;
+
+ pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ #else
+ /* --- Ckeck pOptions, which have been passed by the application --- */
+ if (!pOptions || !pOptions->workspaceName|| (pOptions->encoding==SML_UNDEF))
+ return SML_ERR_WRONG_USAGE;
+
+ /* --- Find that instance --- */
+ #ifdef __SML_LITE__ /* Only ONE instance is supported in the Toolkit lite version */
+ pInstanceInfo = mgrGetInstanceListAnchor();
+ #else
+ pInstanceInfo = (InstanceInfoPtr_t) findInfo(id);
+ #endif
+ #endif
+
+ if (pInstanceInfo==NULL) return SML_ERR_MGR_INVALID_INSTANCE_INFO;
+
+ /* --- free old instance options ---*/
+ freeInstanceOptions(pInstanceInfo);
+
+ /* --- Use a copy of pOptionsCopy --- */
+ pOptionsCopy = (SmlInstanceOptionsPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlInstanceOptions_t));
+ if (pOptionsCopy==NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemcpy(pOptionsCopy,pOptions,(MemSize_t)sizeof(SmlInstanceOptions_t));
+
+ #ifndef NOWSM
+ pOptionsCopy->workspaceName=smlLibStrdup(pOptions->workspaceName);
+
+ if (pOptionsCopy->workspaceName == NULL) {
+ pInstanceInfo->instanceOptions=NULL;
+ smlLibFree(pOptionsCopy);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ #endif
+
+ /* --- Assign the new options --- */
+ pInstanceInfo->instanceOptions=pOptionsCopy;
+
+
+ /* --- Let the new settingds take effect --- */
+ /* --- Adjust workspace size ---*/
+ /* --- Change workspace name ---*/
+ // NOT SUPPORTED FOR YELLOW
+
+ return SML_ERR_OK;
+}
+
+
+
+/**
+ * FUNCTION: freeInstanceOptions
+ * Free Instances Options
+ *
+ * RETURN: InstanceInfoPtr_t
+ * Pointer to the pInstance Info, which options should be freed
+ */
+Ret_t freeInstanceOptions (InstanceInfoPtr_t pInfo) {
+
+ /* --- Delete instance options (if there are any) --- */
+ if (pInfo->instanceOptions!=NULL) {
+ #ifndef NOWSM
+ if (pInfo->instanceOptions->workspaceName!=NULL)
+ smlLibFree(pInfo->instanceOptions->workspaceName); // don't forget the substructures
+ #endif
+ smlLibFree(pInfo->instanceOptions);
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION:
+ * Free the memory of an removed Instance Info (including referenced sub structures)
+ *
+ * IN: InstanceID_t
+ * ID of the InstanceInfo structure to be freed
+ */
+static Ret_t freeInstanceInfo(InstanceInfoPtr_t pInfo) {
+
+ if (pInfo) {
+
+ #ifdef NOWSM
+ // return the instance buffer
+ if (pInfo->instanceBuffer)
+ smlLibFree(pInfo->instanceBuffer);
+ #else
+ if (pInfo->workspaceState)
+ smlLibFree(pInfo->workspaceState);
+ #endif
+ if (pInfo->encoderState)
+ smlLibFree(pInfo->encoderState);
+ if (pInfo->decoderState)
+ smlLibFree(pInfo->decoderState);
+ if (pInfo->callbacks)
+ smlLibFree(pInfo->callbacks);
+
+ freeInstanceOptions(pInfo);
+
+ smlLibFree(pInfo);
+ }
+
+ return SML_ERR_OK;
+}
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/mgrutil.c b/engine/dmlib/dmengine/oma_toolkit/src/mgrutil.c
new file mode 100644
index 0000000..70df177
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/mgrutil.c
@@ -0,0 +1,1694 @@
+/*************************************************************************/
+/* module: some helper functions */
+/* */
+/* file: mgrutil.c */
+/* target system: all */
+/* target OS: all */
+/* */
+/* Description: */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************
+ * Definitions
+ *************************************************************************/
+
+
+/* Include Headers */
+#include <sml.h>
+#include <smldtd.h>
+#include <smldef.h>
+#include <smlerr.h>
+#include <smlmetinfdtd.h>
+#include <smldevinfdtd.h>
+#include <smldmtnddtd.h>
+#include "libmem.h"
+#include "libstr.h"
+#include "liblock.h"
+#include "mgr.h"
+#include "mgrutil.h"
+
+
+/*************************************************************************
+ * Exported SyncML API functions
+ *************************************************************************/
+
+/**
+ * FUNCTION: smlFreeProtoElement
+ *
+ * frees all allocated memory of a smlProtoElement
+ *
+ * IN: VoidPtr_t
+ * Element to free
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t smlFreeProtoElement(VoidPtr_t pProtoElement)
+{
+ if (! pProtoElement)
+ return(SML_ERR_OK);
+
+ switch (((SmlUnknownProtoElementPtr_t)pProtoElement)->elementType) {
+
+ case SML_PE_HEADER:
+ smlFreeSyncHdr((SmlSyncHdrPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_SYNC_START:
+ smlFreeSync((SmlSyncPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_ADD:
+ case SML_PE_COPY:
+ case SML_PE_REPLACE:
+ case SML_PE_DELETE:
+ case SML_PE_GENERIC:
+ smlFreeGeneric((SmlGenericCmdPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_ALERT:
+ smlFreeAlert((SmlAlertPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_ATOMIC_START:
+ case SML_PE_SEQUENCE_START:
+ case SML_PE_CMD_GROUP:
+ smlFreeAtomic((SmlAtomicPtr_t)pProtoElement);
+ break;
+
+#if (defined EXEC_SEND || defined EXEC_RECEIVE)
+ case SML_PE_EXEC:
+ smlFreeExec((SmlExecPtr_t)pProtoElement);
+ break;
+#endif
+
+ case SML_PE_PUT:
+ case SML_PE_GET:
+ case SML_PE_PUT_GET:
+ smlFreeGetPut((SmlPutPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_MAP:
+ smlFreeMap((SmlMapPtr_t)pProtoElement);
+ break;
+
+ case SML_PE_RESULTS:
+ smlFreeResults((SmlResultsPtr_t)pProtoElement);
+ break;
+
+#if (defined SEARCH_SEND || defined SEARCH_RECEIVE)
+ case SML_PE_SEARCH:
+ smlFreeSearch((SmlSearchPtr_t)pProtoElement);
+ break;
+#endif
+ case SML_PE_STATUS:
+ smlFreeStatus((SmlStatusPtr_t)pProtoElement);
+ break;
+
+ default:
+ return(SML_ERR_A_UTI_UNKNOWN_PROTO_ELEMENT);
+ }
+
+ return(SML_ERR_OK);
+}
+
+
+/**
+ * FUNCTION: smlFreePcdata
+ *
+ * frees the Memory of an allocated Pcdata memory object
+ *
+ * IN: SmlPcdataPtr_t
+ * A Pointer to a PcData structure, which should be freed
+ *
+ * RETURN: ---
+ *
+ */
+SML_API void smlFreePcdata(SmlPcdataPtr_t pPcdata)
+{
+ if (! pPcdata)
+ return;
+
+ if (pPcdata->contentType == SML_PCDATA_EXTENSION) {
+ switch ((int)pPcdata->extension) {
+#ifdef __USE_METINF__
+ case SML_EXT_METINF:
+ smlFreeMetinfMetinf(pPcdata->content);
+ smlLibFree(pPcdata);
+ break;
+#endif
+#ifdef __USE_DEVINF__
+ case SML_EXT_DEVINF:
+ smlFreeDevInfDevInf(pPcdata->content);
+ smlLibFree(pPcdata);
+ break;
+#endif
+#ifdef __USE_DMTND__
+ case SML_EXT_DMTND:
+ smlFreeDmTnd(pPcdata->content);
+ smlLibFree(pPcdata);
+ break;
+#endif
+ }
+ return;
+ }
+
+ if (pPcdata->content)
+ smlLibFree(pPcdata->content);
+
+ smlLibFree(pPcdata);
+}
+
+
+SML_API void smlFreePcdataList(SmlPcdataListPtr_t list) {
+ if (!list) return;
+ smlFreePcdataList(list->next);
+ smlFreePcdata(list->data);
+ smlLibFree(list);
+ return;
+}
+
+#ifdef __USE_METINF__
+/** Subfunctions to smlFreePcdata, to freeup MetaInf DTD structures **/
+SML_API void smlFreeMetinfMetinf(SmlMetInfMetInfPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->format);
+ smlFreePcdata(data->type);
+ smlFreePcdata(data->mark);
+ smlFreePcdata(data->size);
+ smlFreePcdata(data->version);
+ smlFreePcdata(data->nextnonce);
+ smlFreePcdata(data->maxmsgsize);
+ /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+ smlFreePcdata(data->maxobjsize);
+ smlFreeMetinfAnchor(data->anchor);
+ smlFreeMetinfMem(data->mem);
+ smlFreePcdataList(data->emi);
+ smlLibFree(data);
+ return;
+}
+SML_API void smlFreeMetinfAnchor(SmlMetInfAnchorPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->last);
+ smlFreePcdata(data->next);
+ smlLibFree(data);
+ return;
+}
+SML_API void smlFreeMetinfMem(SmlMetInfMemPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->shared);
+ smlFreePcdata(data->free);
+ smlFreePcdata(data->freeid);
+ smlLibFree(data);
+ return;
+}
+#endif
+
+#ifdef __USE_DEVINF__
+/** Subfunctions to smlFreePcdata, to freeup DevInf DTD structures **/
+SML_API void smlFreeDevInfDevInf(SmlDevInfDevInfPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->verdtd);
+ smlFreePcdata(data->man);
+ smlFreePcdata(data->mod);
+ smlFreePcdata(data->oem);
+ smlFreePcdata(data->fwv);
+ smlFreePcdata(data->hwv);
+ smlFreePcdata(data->swv);
+ smlFreePcdata(data->devid);
+ smlFreePcdata(data->devtyp);
+ smlFreeDevInfDatastoreList(data->datastore);
+ smlFreeDevInfExtList(data->ext);
+ smlFreeDevInfCtcapList(data->ctcap);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfDatastore(SmlDevInfDatastorePtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->sourceref);
+ smlFreePcdata(data->displayname);
+ smlFreePcdata(data->maxguidsize);
+ smlFreeDevInfXmit(data->rxpref);
+ smlFreeDevInfXmit(data->txpref);
+ smlFreeDevInfXmitList(data->rx);
+ smlFreeDevInfXmitList(data->tx);
+ smlFreeDevInfDSMem(data->dsmem);
+ smlFreeDevInfSynccap(data->synccap);
+ smlLibFree(data);
+ return;
+}
+SML_API void smlFreeDevInfDatastoreList(SmlDevInfDatastoreListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfDatastore(data->data);
+ smlFreeDevInfDatastoreList(data->next);
+ smlLibFree(data);
+ return;
+}
+SML_API void smlFreeDevInfXmitList(SmlDevInfXmitListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfXmit(data->data);
+ smlFreeDevInfXmitList(data->next);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfXmit(SmlDevInfXmitPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->cttype);
+ smlFreePcdata(data->verct);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfDSMem(SmlDevInfDSMemPtr_t data) {
+ if (!data) return;
+ // %%%luz:2003-04-28: this is now a flag! smlFreePcdata(data->shared);
+ smlFreePcdata(data->maxmem);
+ smlFreePcdata(data->maxid);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfSynccap(SmlDevInfSyncCapPtr_t data) {
+ if (!data) return;
+ smlFreePcdataList(data->synctype);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfExt(SmlDevInfExtPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->xnam);
+ smlFreePcdataList(data->xval);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfExtList(SmlDevInfExtListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfExt(data->data);
+ smlFreeDevInfExtList(data->next);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfCTData(SmlDevInfCTDataPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->name);
+ smlFreePcdata(data->dname);
+ smlFreePcdataList(data->valenum);
+ smlFreePcdata(data->datatype);
+ smlFreePcdata(data->size);
+ smlLibFree(data);
+}
+SML_API void smlFreeDevInfCTDataProp(SmlDevInfCTDataPropPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfCTData(data->prop);
+ smlFreeDevInfCTDataList(data->param);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDevInfCTDataList(SmlDevInfCTDataListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfCTData(data->data);
+ smlFreeDevInfCTDataList(data->next);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDevInfCTDataPropList(SmlDevInfCTDataPropListPtr_t data) {
+ if (!data) return;
+ smlFreeDevInfCTDataProp(data->data);
+ smlFreeDevInfCTDataPropList(data->next);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDevInfCTCap(SmlDevInfCTCapPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->cttype);
+ smlFreeDevInfCTDataPropList(data->prop);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDevInfCtcapList(SmlDevInfCtcapListPtr_t data) {
+ if (!data) return;
+
+ smlFreeDevInfCTCap(data->data);
+ smlFreeDevInfCtcapList(data->next);
+ smlLibFree(data);
+}
+#endif
+
+#ifdef __USE_DMTND__
+/** Subfunctions to smlFreePcdata, to freeup DM TND DTD structures **/
+SML_API void smlFreeDmTndFormat(SmlDmTndFormatPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->value);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndType(SmlDmTndTypePtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->mime);
+ smlFreePcdata(data->ddfname);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndDFElement(SmlDmTndDFElementPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->value);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndRTProps(SmlDmTndRTPropsPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->acl);
+ smlFreeDmTndFormat(data->format);
+ smlFreePcdata(data->name);
+ smlFreePcdata(data->size);
+ smlFreePcdata(data->title);
+ smlFreePcdata(data->tstamp);
+ smlFreeDmTndType(data->type);
+ smlFreePcdata(data->verno);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndDFProps(SmlDmTndDFPropsPtr_t data) {
+ if (!data) return;
+ smlFreeDmTndDFElement(data->accesstype);
+ smlFreePcdata(data->defaultvalue);
+ smlFreePcdata(data->description);
+ smlFreeDmTndFormat(data->dfformat);
+ smlFreeDmTndDFElement(data->occurrence);
+ smlFreeDmTndDFElement(data->scope);
+ smlFreePcdata(data->dftitle);
+ smlFreeDmTndType(data->dftype);
+ smlFreeDmTndDFElement(data->casesense);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndNodeList(SmlDmTndNodeListPtr_t data);
+
+SML_API void smlFreeDmTndNode(SmlDmTndNodePtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->nodename);
+ smlFreePcdata(data->path);
+ smlFreeDmTndRTProps(data->rtprops);
+ smlFreeDmTndDFProps(data->dfprops);
+ smlFreePcdata(data->value);
+ smlFreeDmTndNodeList(data->nodelist);
+ smlLibFree(data);
+}
+
+SML_API void smlFreeDmTndNodeList(SmlDmTndNodeListPtr_t data) {
+ if (!data) return;
+ smlFreeDmTndNode(data->node);
+ smlFreeDmTndNodeList(data->next);
+ smlLibFree(data);
+ return;
+}
+
+SML_API void smlFreeDmTnd(SmlDmTndPtr_t data) {
+ if (!data) return;
+ smlFreePcdata(data->verdtd);
+ smlFreePcdata(data->man);
+ smlFreePcdata(data->mod);
+ smlFreeDmTndNodeList(data->nodelist);
+ smlLibFree(data);
+ return;
+}
+#endif
+
+/*************************************************************************
+ * Exported SyncML API functions (FULL-SIZE TOOLKIT ONLY)
+ *************************************************************************/
+
+#ifndef __SML_LITE__ /* these API calls are NOT included in the Toolkit lite version */
+
+/**
+ * FUNCTION: smlGetFreeBuffer
+ *
+ * Return amount of unused Workspace memory
+ *
+ * RETURN: MemSize_t
+ * Amount of unused Workspace memory
+ *
+ */
+SML_API MemSize_t smlGetFreeBuffer(InstanceID_t id)
+{
+ /* Definitions */
+ MemSize_t freeMem=0;
+
+ #ifdef NOWSM
+ InstanceInfoPtr_t pInstanceInfo = (InstanceInfoPtr_t)id; // ID is the instance info pointer
+ if (pInstanceInfo==NULL) return 0; // no buffer if no instance there
+ freeMem =
+ (pInstanceInfo->instanceBuffer+pInstanceInfo->instanceBufSiz) - // end of buffer
+ pInstanceInfo->writePointer; // current write pointer
+ #else
+ /* ask the Workspace Buffer */
+ LOCKTOOLKIT("smlGetFreeBuffer");
+ wsmGetFreeSize(id, &freeMem);
+ RELEASETOOLKIT("smlGetFreeBuffer");
+ #endif
+
+ return (MemSize_t)freeMem;
+}
+
+
+/**
+ * FUNCTION: smlString2Pcdata
+ *
+ * copy a string into a Pcdata structure
+ *
+ * IN: String_t
+ * Input String
+ *
+ * RETURN: SmlPcdataPtr_t
+ * A Pointer to a PcData structure
+ *
+ */
+SML_API SmlPcdataPtr_t smlString2Pcdata(String_t str)
+{
+ /* Definitions */
+ SmlPcdataPtr_t pcdata;
+
+ /* Invalid Input */
+ if (! str)
+ return NULL;
+
+ /* Allocate the PcData Structure */
+ pcdata = (SmlPcdataPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlPcdata_t));
+ if (! pcdata)
+ return NULL;
+ smlLibMemset (pcdata, 0, (MemSize_t)sizeof(SmlPcdata_t));
+
+ /* Set the PcData Structure */
+ pcdata->contentType = SML_PCDATA_STRING;
+ pcdata->length = smlLibStrlen( str );
+ pcdata->content = (VoidPtr_t)smlLibStrdup(str);
+
+ return pcdata;
+}
+
+
+/**
+ * FUNCTION: smlPcdata2String
+ *
+ * copy a Pcdata structure into a string
+ *
+ * IN: SmlPcdataPtr_t
+ * A Pointer to a PcData structure
+ * RETURN: String_t
+ * Input String
+ *
+ */
+SML_API String_t smlPcdata2String(SmlPcdataPtr_t pcdata)
+{
+ /* Definitions */
+ String_t str;
+
+ /* Invalid Input */
+ if (! pcdata)
+ return NULL;
+
+ /* Allocate the String */
+ str = (String_t)smlLibMalloc((MemSize_t)(pcdata->length+1));
+ if (str == NULL)
+ return NULL;
+
+ /* Copy the string into the allocated data structure */
+ smlLibMemcpy((MemPtr_t)str, (MemPtr_t)pcdata->content, pcdata->length);
+ *(str + pcdata->length) = '\0';
+
+ return str;
+}
+
+
+/**
+ * FUNCTION: smlPcdataDup
+ *
+ * Duplicates a Pcdata memory object
+ *
+ * IN: SmlPcdataPtr_t
+ * A Pointer to the original PcData structure
+ *
+ * RETURN: SmlPcdataPtr_t
+ * A Pointer to the copy of the PcData structure
+ *
+ */
+SML_API SmlPcdataPtr_t smlPcdataDup(SmlPcdataPtr_t pcdata)
+{
+ /* Definitions */
+ SmlPcdataPtr_t newPcdata;
+
+ /* Invalid Input */
+ if (! pcdata)
+ return NULL;
+
+ /* Allocate the new pcdata memory object */
+ newPcdata = (SmlPcdataPtr_t)smlLibMalloc((MemSize_t)sizeof(SmlPcdata_t));
+ if (! newPcdata)
+ return NULL;
+ smlLibMemset (newPcdata, 0, (MemSize_t)sizeof(SmlPcdata_t));
+
+ /* Set the PcData Structure */
+ newPcdata->contentType = pcdata->contentType;
+ newPcdata->length = pcdata->length;
+ newPcdata->content =(VoidPtr_t)smlLibMalloc((MemSize_t)pcdata->length+1);
+ if (newPcdata->content ==NULL)
+ {
+ smlLibFree(newPcdata->content);
+ smlLibFree(newPcdata);
+ return NULL;
+ }
+ smlLibMemset(newPcdata->content, 0, (MemSize_t)((pcdata->length)+1));
+ smlLibMemcpy(newPcdata->content, pcdata->content, (MemSize_t)pcdata->length);
+
+ return newPcdata;
+}
+
+#endif
+
+SML_API void smlFreeSyncHdr(SmlSyncHdrPtr_t pSyncHdr)
+{
+ if (! pSyncHdr)
+ return;
+
+ smlFreePcdata(pSyncHdr->version);
+ smlFreePcdata(pSyncHdr->proto);
+ smlFreePcdata(pSyncHdr->sessionID);
+ smlFreePcdata(pSyncHdr->msgID);
+ smlFreePcdata(pSyncHdr->respURI);
+ smlFreePcdata(pSyncHdr->meta);
+
+ smlFreeSourceTargetPtr(pSyncHdr->source);
+ smlFreeSourceTargetPtr(pSyncHdr->target);
+
+ smlFreeCredPtr(pSyncHdr->cred);
+
+ smlLibFree(pSyncHdr);
+}
+
+
+SML_API void smlFreeSync(SmlSyncPtr_t pSync)
+{
+ if (! pSync)
+ return;
+
+ smlFreePcdata(pSync->cmdID);
+ smlFreePcdata(pSync->meta);
+
+ smlFreeSourceTargetPtr(pSync->source);
+ smlFreeSourceTargetPtr(pSync->target);
+
+ smlFreeCredPtr(pSync->cred);
+
+ smlLibFree(pSync);
+}
+
+
+SML_API void smlFreeGeneric(SmlGenericCmdPtr_t pGenericCmd)
+{
+ if (! pGenericCmd)
+ return;
+
+ smlFreePcdata(pGenericCmd->cmdID);
+ smlFreePcdata(pGenericCmd->meta);
+
+ smlFreeCredPtr(pGenericCmd->cred);
+
+ smlFreeItemList(pGenericCmd->itemList);
+
+ smlLibFree(pGenericCmd);
+}
+
+
+SML_API void smlFreeAlert(SmlAlertPtr_t pAlert)
+{
+ if (! pAlert)
+ return;
+
+ smlFreePcdata(pAlert->cmdID);
+ smlFreePcdata(pAlert->data);
+
+ smlFreeCredPtr(pAlert->cred);
+
+ smlFreeItemList(pAlert->itemList);
+ smlFreePcdata(pAlert->correlator);
+
+ smlLibFree(pAlert);
+}
+
+
+SML_API void smlFreeAtomic(SmlAtomicPtr_t pAtomic)
+{
+ if (! pAtomic)
+ return;
+
+ smlFreePcdata(pAtomic->cmdID);
+ smlFreePcdata(pAtomic->meta);
+
+ smlLibFree(pAtomic);
+}
+
+#if (defined EXEC_SEND || defined EXEC_RECEIVE)
+
+SML_API void smlFreeExec(SmlExecPtr_t pExec)
+{
+ if (! pExec)
+ return;
+
+ smlFreePcdata(pExec->cmdID);
+
+ smlFreeCredPtr(pExec->cred);
+
+ smlFreeItemPtr(pExec->item);
+
+ smlFreePcdata(pExec->correlator);
+
+ smlLibFree(pExec);
+}
+
+#endif
+
+SML_API void smlFreeGetPut(SmlPutPtr_t pGetPut)
+{
+ if (! pGetPut)
+ return;
+
+ smlFreePcdata(pGetPut->cmdID);
+ smlFreePcdata(pGetPut->meta);
+ smlFreePcdata(pGetPut->lang);
+
+ smlFreeCredPtr(pGetPut->cred);
+
+ smlFreeItemList(pGetPut->itemList);
+
+ smlLibFree(pGetPut);
+}
+
+
+SML_API void smlFreeMap(SmlMapPtr_t pMap)
+{
+ if (! pMap)
+ return;
+
+ smlFreePcdata(pMap->cmdID);
+ smlFreePcdata(pMap->meta);
+
+ smlFreeCredPtr(pMap->cred);
+
+ smlFreeSourceTargetPtr(pMap->source);
+ smlFreeSourceTargetPtr(pMap->target);
+
+ smlFreeMapItemList(pMap->mapItemList);
+
+ smlLibFree(pMap);
+}
+
+
+SML_API void smlFreeResults(SmlResultsPtr_t pResults)
+{
+ if (! pResults)
+ return;
+
+ smlFreePcdata(pResults->cmdID);
+ smlFreePcdata(pResults->msgRef);
+ smlFreePcdata(pResults->cmdRef);
+ smlFreePcdata(pResults->meta);
+ smlFreePcdata(pResults->targetRef);
+ smlFreePcdata(pResults->sourceRef);
+
+ smlFreeItemList(pResults->itemList);
+
+ smlLibFree(pResults);
+}
+
+#if (defined SEARCH_SEND || defined SEARCH_RECEIVE)
+
+SML_API void smlFreeSearch(SmlSearchPtr_t pSearch)
+{
+ if (! pSearch)
+ return;
+
+ smlFreePcdata(pSearch->cmdID);
+ smlFreePcdata(pSearch->lang);
+ smlFreePcdata(pSearch->meta);
+ smlFreePcdata(pSearch->data);
+
+ smlFreeCredPtr(pSearch->cred);
+
+ smlFreeSourceTargetPtr(pSearch->target);
+
+ smlFreeSourceList(pSearch->sourceList);
+
+ smlLibFree(pSearch);
+}
+
+#endif
+
+SML_API void smlFreeStatus(SmlStatusPtr_t pStatus)
+{
+ if (! pStatus)
+ return;
+
+ smlFreePcdata(pStatus->cmdID);
+ smlFreePcdata(pStatus->msgRef);
+ smlFreePcdata(pStatus->cmdRef);
+ smlFreePcdata(pStatus->cmd);
+ smlFreePcdata(pStatus->data);
+
+ smlFreeCredPtr(pStatus->cred);
+ smlFreeChalPtr(pStatus->chal);
+
+ smlFreeTargetRefList(pStatus->targetRefList);
+ smlFreeSourceRefList(pStatus->sourceRefList);
+
+ smlFreeItemList(pStatus->itemList);
+
+ smlLibFree(pStatus);
+}
+
+
+SML_API void smlFreeCredPtr(SmlCredPtr_t pCred)
+{
+ if (! pCred)
+ return;
+
+ smlFreePcdata(pCred->meta);
+ smlFreePcdata(pCred->data);
+
+ smlLibFree(pCred);
+}
+
+
+SML_API void smlFreeChalPtr(SmlChalPtr_t pChal)
+{
+ if (! pChal)
+ return;
+
+ smlFreePcdata(pChal->meta);
+
+ smlLibFree(pChal);
+}
+
+
+SML_API void smlFreeSourceTargetPtr(SmlSourcePtr_t pSourceTarget)
+{
+ if (! pSourceTarget)
+ return;
+
+ smlFreePcdata(pSourceTarget->locURI);
+ smlFreePcdata(pSourceTarget->locName);
+
+ smlLibFree(pSourceTarget);
+}
+
+
+SML_API void smlFreeSourceList(SmlSourceListPtr_t pSourceList)
+{
+ SmlSourceListPtr_t pTmp;
+
+ while (pSourceList) {
+ pTmp = pSourceList->next;
+ smlFreeSourceTargetPtr(pSourceList->source);
+ smlLibFree(pSourceList);
+ pSourceList = pTmp;
+ }
+}
+
+
+SML_API void smlFreeSourceRefList(SmlSourceRefListPtr_t pSourceRefList)
+{
+ SmlSourceRefListPtr_t pTmp;
+
+ while (pSourceRefList) {
+ pTmp = pSourceRefList->next;
+ smlFreePcdata(pSourceRefList->sourceRef);
+ smlLibFree(pSourceRefList);
+ pSourceRefList = pTmp;
+ }
+}
+
+
+SML_API void smlFreeTargetRefList(SmlTargetRefListPtr_t pTargetRefList)
+{
+ SmlTargetRefListPtr_t pTmp;
+
+ while (pTargetRefList) {
+ pTmp = pTargetRefList->next;
+ smlFreePcdata(pTargetRefList->targetRef);
+ smlLibFree(pTargetRefList);
+ pTargetRefList = pTmp;
+ }
+}
+
+
+SML_API void smlFreeItemPtr(SmlItemPtr_t pItem)
+{
+ if (! pItem)
+ return;
+
+ smlFreePcdata(pItem->meta);
+ smlFreePcdata(pItem->data);
+
+ smlFreeSourceTargetPtr(pItem->source);
+ smlFreeSourceTargetPtr(pItem->target);
+
+ smlLibFree(pItem);
+}
+
+
+SML_API void smlFreeItemList(SmlItemListPtr_t pItemList)
+{
+ SmlItemListPtr_t pTmp;
+
+ while (pItemList) {
+ pTmp = pItemList->next;
+ smlFreeItemPtr(pItemList->item);
+ smlLibFree(pItemList);
+ pItemList = pTmp;
+ }
+}
+
+
+SML_API void smlFreeMapItemPtr(SmlMapItemPtr_t pMapItem)
+{
+ if (! pMapItem)
+ return;
+
+ smlFreeSourceTargetPtr(pMapItem->source);
+ smlFreeSourceTargetPtr(pMapItem->target);
+
+ smlLibFree(pMapItem);
+}
+
+
+SML_API void smlFreeMapItemList(SmlMapItemListPtr_t pMapItemList)
+{
+ SmlMapItemListPtr_t pTmp;
+
+ while (pMapItemList) {
+ pTmp = pMapItemList->next;
+ smlFreeMapItemPtr(pMapItemList->mapItem);
+ smlLibFree(pMapItemList);
+ pMapItemList = pTmp;
+ }
+}
+
+#ifdef __USE_ALLOCFUNCS__
+/* Helperfunctions, that allocate and preset SyncML C structs */
+SML_API SmlPcdataPtr_t smlAllocPcdata() {
+ SmlPcdataPtr_t p = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlPcdata_t));
+ return p;
+}
+
+SML_API SmlPcdataListPtr_t smlAllocPcdataList() {
+ SmlPcdataListPtr_t p = (SmlPcdataListPtr_t)smlLibMalloc(sizeof(SmlPcdataList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlPcdataList_t));
+ p->data = smlAllocPcdata();
+ if (p->data == NULL) {
+ smlFreePcdataList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlChalPtr_t smlAllocChal() {
+ SmlChalPtr_t p = (SmlChalPtr_t)smlLibMalloc(sizeof(SmlChal_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlChal_t));
+ p->meta = smlAllocPcdata();
+ if (p->meta == NULL) {
+ smlFreeChalPtr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlCredPtr_t smlAllocCred() {
+ SmlCredPtr_t p = (SmlCredPtr_t)smlLibMalloc(sizeof(SmlCred_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlCred_t));
+ p->data = smlAllocPcdata();
+ if (p->data == NULL) {
+ smlFreeCredPtr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlSourcePtr_t smlAllocSource() {
+ SmlSourcePtr_t p = (SmlSourcePtr_t)smlLibMalloc(sizeof(SmlSource_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSource_t));
+ p->locURI = smlAllocPcdata();
+ if (p->locURI == NULL) {
+ smlFreeSourceTargetPtr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlTargetPtr_t smlAllocTarget() {
+ return smlAllocSource();
+}
+
+SML_API SmlSourceListPtr_t smlAllocSourceList() {
+ SmlSourceListPtr_t p = (SmlSourceListPtr_t)smlLibMalloc(sizeof(SmlSourceList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSourceList_t));
+ p->source = smlAllocSource();
+ if (p->source == NULL) {
+ smlFreeSourceList(p);
+ return NULL;
+ }
+ return p;
+}
+
+
+SML_API SmlSyncHdrPtr_t smlAllocSyncHdr() {
+ SmlSyncHdrPtr_t p = (SmlSyncHdrPtr_t)smlLibMalloc(sizeof(SmlSyncHdr_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSyncHdr_t));
+ p->elementType = SML_PE_HEADER;
+ p->version = smlAllocPcdata();
+ if (p->version == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->proto = smlAllocPcdata();
+ if (p->proto == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->sessionID = smlAllocPcdata();
+ if (p->sessionID == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->msgID = smlAllocPcdata();
+ if (p->msgID == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->target = smlAllocTarget();
+ if (p->target == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ p->source = smlAllocSource();
+ if (p->source == NULL) {
+ smlFreeSyncHdr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlItemPtr_t smlAllocItem() {
+ SmlItemPtr_t p = (SmlItemPtr_t)smlLibMalloc(sizeof(SmlItem_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlItem_t));
+ return p;
+}
+
+SML_API SmlItemListPtr_t smlAllocItemList() {
+ SmlItemListPtr_t p = (SmlItemListPtr_t)smlLibMalloc(sizeof(SmlItemList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlItemList_t));
+ p->item = smlAllocItem();
+ if (p->item == NULL) {
+ smlFreeItemList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlGenericCmdPtr_t smlAllocGeneric() {
+ SmlGenericCmdPtr_t p = (SmlGenericCmdPtr_t)smlLibMalloc(sizeof(SmlGenericCmd_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlGenericCmd_t));
+ p->elementType = SML_PE_GENERIC;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeGeneric(p);
+ return NULL;
+ }
+ p->itemList = smlAllocItemList();
+ if (p->itemList == NULL) {
+ smlFreeGeneric(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlAddPtr_t smlAllocAdd() {
+ SmlAddPtr_t p = smlAllocGeneric();
+ if (p == NULL) return p;
+ p->elementType = SML_PE_ADD;
+ return p;
+}
+
+SML_API SmlCopyPtr_t smlAllocCopy() {
+ SmlCopyPtr_t p = smlAllocGeneric();
+ if (p == NULL) return p;
+ p->elementType = SML_PE_COPY;
+ return p;
+}
+
+SML_API SmlReplacePtr_t smlAllocReplace() {
+ SmlReplacePtr_t p = smlAllocGeneric();
+ if (p == NULL) return p;
+ p->elementType = SML_PE_REPLACE;
+ return p;
+}
+
+SML_API SmlDeletePtr_t smlAllocDelete() {
+ SmlDeletePtr_t p = smlAllocGeneric();
+ if (p == NULL) return p;
+ p->elementType = SML_PE_DELETE;
+ return p;
+}
+
+SML_API SmlAlertPtr_t smlAllocAlert() {
+ SmlAlertPtr_t p = (SmlAlertPtr_t)smlLibMalloc(sizeof(SmlAlert_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlAlert_t));
+ p->elementType = SML_PE_ALERT;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeAlert(p);
+ return NULL;
+ }
+ p->itemList = smlAllocItemList();
+ if (p->itemList == NULL) {
+ smlFreeAlert(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlAtomicPtr_t smlAllocAtomic() {
+ SmlAtomicPtr_t p = (SmlAtomicPtr_t)smlLibMalloc(sizeof(SmlAtomic_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlAtomic_t));
+ p->elementType = SML_PE_ATOMIC_START;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeAtomic(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlSequencePtr_t smlAllocSequence() {
+ SmlSequencePtr_t p = smlAllocAtomic();
+ if (p == NULL) return NULL;
+ p->elementType = SML_PE_SEQUENCE_START;
+ return p;
+}
+
+SML_API SmlSyncPtr_t smlAllocSync() {
+ SmlSyncPtr_t p = (SmlSyncPtr_t)smlLibMalloc(sizeof(SmlSync_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSync_t));
+ p->elementType = SML_PE_SYNC_START;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeSync(p);
+ return NULL;
+ }
+ return p;
+}
+
+#if defined(EXEC_SEND) || defined(EXEC_RECEIVE)
+SML_API SmlExecPtr_t smlAllocExec() {
+ SmlExecPtr_t p = (SmlExecPtr_t)smlLibMalloc(sizeof(SmlExec_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlExec_t));
+ p->elementType = SML_PE_EXEC;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeExec(p);
+ return NULL;
+ }
+ p->item = smlAllocItem();
+ if (p->item == NULL) {
+ smlFreeExec(p);
+ return NULL;
+ }
+ return p;
+}
+#endif
+
+SML_API SmlGetPtr_t smlAllocGet() {
+ SmlGetPtr_t p = (SmlGetPtr_t)smlLibMalloc(sizeof(SmlGet_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlGet_t));
+ p->elementType = SML_PE_GET;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeGetPut(p);
+ return NULL;
+ }
+ p->itemList = smlAllocItemList();
+ if (p->itemList == NULL) {
+ smlFreeGetPut(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlPutPtr_t smlAllocPut() {
+ SmlPutPtr_t p = smlAllocGet();
+ if (p == NULL) return NULL;
+ p->elementType = SML_PE_PUT;
+ return p;
+}
+
+SML_API SmlMapItemPtr_t smlAllocMapItem() {
+ SmlMapItemPtr_t p = (SmlMapItemPtr_t)smlLibMalloc(sizeof(SmlMapItem_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMapItem_t));
+ p->target = smlAllocTarget();
+ if (p->target == NULL) {
+ smlFreeMapItemPtr(p);
+ return NULL;
+ }
+ p->source = smlAllocSource();
+ if (p->source == NULL) {
+ smlFreeMapItemPtr(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlMapItemListPtr_t smlAllocMapItemList() {
+ SmlMapItemListPtr_t p = (SmlMapItemListPtr_t)smlLibMalloc(sizeof(SmlMapItemList_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMapItemList_t));
+ p->mapItem = smlAllocMapItem();
+ if (p->mapItem == NULL) {
+ smlFreeMapItemList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlMapPtr_t smlAllocMap() {
+ SmlMapPtr_t p = (SmlMapPtr_t)smlLibMalloc(sizeof(SmlMap_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMap_t));
+ p->elementType = SML_PE_MAP;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeMap(p);
+ return NULL;
+ }
+ p->target = smlAllocTarget();
+ if (p->target == NULL) {
+ smlFreeMap(p);
+ return NULL;
+ }
+ p->source = smlAllocSource();
+ if (p->source == NULL) {
+ smlFreeMap(p);
+ return NULL;
+ }
+ p->mapItemList = smlAllocMapItemList();
+ if (p->mapItemList == NULL) {
+ smlFreeMap(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlResultsPtr_t smlAllocResults() {
+ SmlResultsPtr_t p = (SmlResultsPtr_t)smlLibMalloc(sizeof(SmlResults_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlResults_t));
+ p->elementType = SML_PE_RESULTS;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeResults(p);
+ return NULL;
+ }
+ p->cmdRef = smlAllocPcdata();
+ if (p->cmdRef == NULL) {
+ smlFreeResults(p);
+ return NULL;
+ }
+ p->itemList = smlAllocItemList();
+ if (p->itemList == NULL) {
+ smlFreeResults(p);
+ return NULL;
+ }
+ return p;
+}
+
+#if (defined SEARCH_SEND || defined SEARCH_RECEIVE)
+
+SML_API SmlSearchPtr_t smlAllocSearch() {
+ SmlSearchPtr_t p = (SmlSearchPtr_t)smlLibMalloc(sizeof(SmlSearch_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSearch_t));
+ p->elementType = SML_PE_SEARCH;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeSearch(p);
+ return NULL;
+ }
+ p->meta = smlAllocPcdata();
+ if (p->meta == NULL) {
+ smlFreeSearch(p);
+ return NULL;
+ }
+ p->data = smlAllocPcdata();
+ if (p->data == NULL) {
+ smlFreeSearch(p);
+ return NULL;
+ }
+ p->sourceList = smlAllocSourceList();
+ if (p->sourceList == NULL) {
+ smlFreeSearch(p);
+ return NULL;
+ }
+ return p;
+}
+#endif
+
+SML_API SmlTargetRefListPtr_t smlAllocTargetRefList() {
+ SmlTargetRefListPtr_t p = (SmlTargetRefListPtr_t)smlLibMalloc(sizeof(SmlTargetRefList_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlTargetRefList_t));
+ p->targetRef = smlAllocPcdata();
+ if (p->targetRef == NULL) {
+ smlFreeTargetRefList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlSourceRefListPtr_t smlAllocSourceRefList() {
+ SmlSourceRefListPtr_t p = (SmlSourceRefListPtr_t)smlLibMalloc(sizeof(SmlSourceRefList_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlSourceRefList_t));
+ p->sourceRef = smlAllocPcdata();
+ if (p->sourceRef == NULL) {
+ smlFreeSourceRefList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlStatusPtr_t smlAllocStatus() {
+ SmlStatusPtr_t p = (SmlStatusPtr_t)smlLibMalloc(sizeof(SmlStatus_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlStatus_t));
+ p->elementType = SML_PE_STATUS;
+ p->cmdID = smlAllocPcdata();
+ if (p->cmdID == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ p->msgRef = smlAllocPcdata();
+ if (p->msgRef == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ p->cmdRef = smlAllocPcdata();
+ if (p->cmdRef == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ p->cmd = smlAllocPcdata();
+ if (p->cmd == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ p->data = smlAllocPcdata();
+ if (p->data == NULL) {
+ smlFreeStatus(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlUnknownProtoElementPtr_t smlAllocUnknownProtoElement() {
+ SmlUnknownProtoElementPtr_t p = (SmlUnknownProtoElementPtr_t)smlLibMalloc(sizeof(SmlUnknownProtoElement_t));
+ if (p == 0) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlUnknownProtoElement_t));
+ p->elementType = SML_PE_UNDEF;
+ return p;
+}
+
+#ifdef __USE_METINF__
+SML_API SmlMetInfMetInfPtr_t smlAllocMetInfMetInf() {
+ SmlMetInfMetInfPtr_t p = (SmlMetInfMetInfPtr_t)smlLibMalloc(sizeof(SmlMetInfMetInf_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMetInfMetInf_t));
+ return p;
+}
+
+SML_API SmlMetInfAnchorPtr_t smlAllocMetInfAnchor() {
+ SmlMetInfAnchorPtr_t p = (SmlMetInfAnchorPtr_t)smlLibMalloc(sizeof(SmlMetInfAnchor_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMetInfAnchor_t));
+ p->next = smlAllocPcdata();
+ if (p->next == NULL) {
+ smlFreeMetinfAnchor(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlMetInfMemPtr_t smlAllocMetInfMem() {
+ SmlMetInfMemPtr_t p = (SmlMetInfMemPtr_t)smlLibMalloc(sizeof(SmlMetInfMem_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlMetInfMem_t));
+ p->free = smlAllocPcdata();
+ if (p->free == NULL) {
+ smlFreeMetinfMem(p);
+ return NULL;
+ }
+ p->freeid = smlAllocPcdata();
+ if (p->freeid == NULL) {
+ smlFreeMetinfMem(p);
+ return NULL;
+ }
+ return p;
+}
+#endif
+
+#ifdef __USE_DEVINF__
+SML_API SmlDevInfExtPtr_t smlAllocDevInfExt() {
+ SmlDevInfExtPtr_t p = (SmlDevInfExtPtr_t)smlLibMalloc(sizeof(SmlDevInfExt_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfExt_t));
+ p->xnam = smlAllocPcdata();
+ if (p->xnam == NULL) {
+ smlFreeDevInfExt(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfExtListPtr_t smlAllocDevInfExtList() {
+ SmlDevInfExtListPtr_t p = (SmlDevInfExtListPtr_t)smlLibMalloc(sizeof(SmlDevInfExtList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfExtList_t));
+ p->data = smlAllocDevInfExt();
+ if (p->data == NULL) {
+ smlFreeDevInfExtList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfSyncCapPtr_t smlAllocDevInfSyncCap() {
+ SmlDevInfSyncCapPtr_t p = (SmlDevInfSyncCapPtr_t)smlLibMalloc(sizeof(SmlDevInfSyncCap_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfSyncCap_t));
+ p->synctype = smlAllocPcdataList();
+ if (p->synctype == NULL) {
+ smlFreeDevInfSynccap(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTDataPtr_t smlAllocDevInfCTData() {
+ SmlDevInfCTDataPtr_t p = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTData_t));
+ p->name = smlAllocPcdata();
+ if (p->name == NULL) {
+ smlFreeDevInfCTData(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTDataListPtr_t smlAllocDevInfCTDataList() {
+ SmlDevInfCTDataListPtr_t p = (SmlDevInfCTDataListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTDataList_t));
+ p->data = smlAllocDevInfCTData();
+ if (p->data == NULL) {
+ smlFreeDevInfCTDataList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTDataPropPtr_t smlAllocDevInfCTDataProp() {
+ SmlDevInfCTDataPropPtr_t p = (SmlDevInfCTDataPropPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataProp_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTDataProp_t));
+ p->prop = smlAllocDevInfCTData();
+ if (p->prop == NULL) {
+ smlFreeDevInfCTDataProp(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTDataPropListPtr_t smlAllocDevInfCTDataPropList() {
+ SmlDevInfCTDataPropListPtr_t p = (SmlDevInfCTDataPropListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataPropList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTDataPropList_t));
+ p->data = smlAllocDevInfCTDataProp();
+ if (p->data == NULL) {
+ smlFreeDevInfCTDataPropList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCTCapPtr_t smlAllocDevInfCTCap() {
+ SmlDevInfCTCapPtr_t p = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCTCap_t));
+ p->cttype = smlAllocPcdata();
+ if (p->cttype == NULL) {
+ smlFreeDevInfCTCap(p);
+ return NULL;
+ }
+ p->prop = smlAllocDevInfCTDataPropList();
+ if (p->prop == NULL) {
+ smlFreeDevInfCTCap(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfCtcapListPtr_t smlAllocDevInfCtcapList() {
+ SmlDevInfCtcapListPtr_t p = (SmlDevInfCtcapListPtr_t)smlLibMalloc(sizeof(SmlDevInfCtcapList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfCtcapList_t));
+ p->data = smlAllocDevInfCTCap();
+ if (p->data == NULL) {
+ smlFreeDevInfCtcapList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfDSMemPtr_t smlAllocDevInfDSMem() {
+ SmlDevInfDSMemPtr_t p = (SmlDevInfDSMemPtr_t)smlLibMalloc(sizeof(SmlDevInfDSMem_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfDSMem_t));
+ return p;
+}
+
+SML_API SmlDevInfXmitPtr_t smlAllocDevInfXmit() {
+ SmlDevInfXmitPtr_t p = (SmlDevInfXmitPtr_t)smlLibMalloc(sizeof(SmlDevInfXmit_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfXmit_t));
+ p->cttype = smlAllocPcdata();
+ if (p->cttype == NULL) {
+ smlFreeDevInfXmit(p);
+ return NULL;
+ }
+ p->verct = smlAllocPcdata();
+ if (p->verct == NULL) {
+ smlFreeDevInfXmit(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfXmitListPtr_t smlAllocDevInfXmitList() {
+ SmlDevInfXmitListPtr_t p = (SmlDevInfXmitListPtr_t)smlLibMalloc(sizeof(SmlDevInfXmitList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfXmitList_t));
+ p->data = smlAllocDevInfXmit();
+ if (p->data == NULL) {
+ smlFreeDevInfXmitList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfDatastorePtr_t smlAllocDevInfDatastore() {
+ SmlDevInfDatastorePtr_t p = (SmlDevInfDatastorePtr_t)smlLibMalloc(sizeof(SmlDevInfDatastore_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfDatastore_t));
+ p->sourceref = smlAllocPcdata();
+ if (p->sourceref == NULL) {
+ smlFreeDevInfDatastore(p);
+ return NULL;
+ }
+ p->rxpref = smlAllocDevInfXmit();
+ if (p->rxpref == NULL) {
+ smlFreeDevInfDatastore(p);
+ return NULL;
+ }
+ p->txpref = smlAllocDevInfXmit();
+ if (p->txpref == NULL) {
+ smlFreeDevInfDatastore(p);
+ return NULL;
+ }
+ p->synccap = smlAllocDevInfSyncCap();
+ if (p->synccap == NULL) {
+ smlFreeDevInfDatastore(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfDatastoreListPtr_t smlAllocDevInfDatastoreList() {
+ SmlDevInfDatastoreListPtr_t p = (SmlDevInfDatastoreListPtr_t)smlLibMalloc(sizeof(SmlDevInfDatastoreList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfDatastoreList_t));
+ p->data = smlAllocDevInfDatastore();
+ if (p->data == NULL) {
+ smlFreeDevInfDatastoreList(p);
+ return NULL;
+ }
+ return p;
+}
+
+SML_API SmlDevInfDevInfPtr_t smlAllocDevInfDevInf() {
+ SmlDevInfDevInfPtr_t p = (SmlDevInfDevInfPtr_t)smlLibMalloc(sizeof(SmlDevInfDevInf_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDevInfDevInf_t));
+ p->verdtd = smlAllocPcdata();
+ if (p->verdtd == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ p->devid = smlAllocPcdata();
+ if (p->devid == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ p->devtyp = smlAllocPcdata();
+ if (p->devtyp == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+
+ p->datastore = smlAllocDevInfDatastoreList();
+ /* Fixed error checking. 3/07/03 Emily Bernotas */
+ if (p->datastore == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ /* When developing the DS Stack, testing showed that the RTK was depending on these
+ * two optional DevInf element to have valid data when encoding the SyncML document.
+ * Although the phone does use the CTCAP element, it does NOT use the Ext element and
+ * not having valid data in the Ext was causing a PANIC.
+ * The design decision was made to fix the RTK here to follow the original philosophy
+ * not allocating memory of optional elements. For example, memory for other optional
+ * elements like Man, FwV, etc is not allocated here. It is now the responsibility of
+ * the DS Stack to allocate memory for CTCAP. 04/02/03 Emily Bernotas
+ */
+ /*
+ p->ctcap = smlAllocDevInfCtcapList();
+ if (p->ctcap == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ p->ext = smlAllocDevInfExtList();
+ if (p->ext == NULL) {
+ smlFreeDevInfDevInf(p);
+ return NULL;
+ }
+ */
+ return p;
+}
+
+#endif // DevInf
+
+#ifdef __USE_DMTND__
+SML_API SmlDmTndPtr_t smlAllocDmTnd() {
+ SmlDmTndPtr_t p = (SmlDmTndPtr_t)smlLibMalloc(sizeof(SmlDmTnd_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTnd_t));
+ return p;
+}
+
+SML_API SmlDmTndNodeListPtr_t smlAllocDmTndNodeList() {
+ SmlDmTndNodeListPtr_t p = (SmlDmTndNodeListPtr_t)smlLibMalloc(sizeof(SmlDmTndNodeList_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndNodeList_t));
+ return p;
+}
+
+SML_API SmlDmTndNodePtr_t smlAllocDmTndNode() {
+ SmlDmTndNodePtr_t p = (SmlDmTndNodePtr_t)smlLibMalloc(sizeof(SmlDmTndNode_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndNode_t));
+ return p;
+}
+
+SML_API SmlDmTndRTPropsPtr_t smlAllocDmTndRTProps() {
+ SmlDmTndRTPropsPtr_t p = (SmlDmTndRTPropsPtr_t)smlLibMalloc(sizeof(SmlDmTndRTProps_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndRTProps_t));
+ return p;
+}
+
+SML_API SmlDmTndFormatPtr_t smlAllocDmTndFormat() {
+ SmlDmTndFormatPtr_t p = (SmlDmTndFormatPtr_t)smlLibMalloc(sizeof(SmlDmTndFormatPtr_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndFormat_t));
+ return p;
+}
+
+SML_API SmlDmTndTypePtr_t smlAllocDmTndType() {
+ SmlDmTndTypePtr_t p = (SmlDmTndTypePtr_t)smlLibMalloc(sizeof(SmlDmTndRTProps_t));
+ if (p == NULL) return NULL;
+ smlLibMemset(p, 0, sizeof(SmlDmTndType_t));
+ return p;
+}
+#endif // AllocDmTnd
+
+#endif // AllocFuncs
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/wsm.c b/engine/dmlib/dmengine/oma_toolkit/src/wsm.c
new file mode 100644
index 0000000..760cbad
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/wsm.c
@@ -0,0 +1,1612 @@
+/*************************************************************************/
+/* module: SyncML WorkSpace Manager */
+/* file: WSM.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Workspace Manager API <BR>
+ * Manages the SyncML document in memory.
+ *
+ * @version @label
+ *
+ *
+ */
+
+
+#ifndef NOWSM
+// if no WSM, we can leave this one out completely
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "wsm.h"
+
+#include "wsm_sm.h"
+#include "smldef.h"
+#include "libmem.h"
+#include "libstr.h"
+#include "liblock.h" // for THREADDEBUGPRINTF %%% luz
+#include "mgr.h" // for global anchor
+
+
+/** WSM buffer flags */
+#define WSM_VALID_F (Byte_t) 0x01
+#define WSM_LOCKED_F (Byte_t) 0x02
+
+#define WSM_MEMH_UNUSED -1
+
+#ifndef __SML_LITE__
+
+/* Global Vars */
+/* =========== */
+
+/* defines for convient use of global anchor */
+
+#define wsmRet (mgrGetSyncMLAnchor())->wsmGlobals->wsmRet
+#define initWasCalled (mgrGetSyncMLAnchor())->wsmGlobals->initWasCalled
+#define maxWsmAvailMem (mgrGetSyncMLAnchor())->syncmlOptions->maxWorkspaceAvailMem
+#define wsmBuf (mgrGetSyncMLAnchor())->wsmGlobals->wsmBuf
+#define wsmIndex (mgrGetSyncMLAnchor())->wsmGlobals->wsmIndex
+
+void createDataStructs(void);
+
+void createDataStructs() {
+ if ( (mgrGetSyncMLAnchor())->wsmGlobals == NULL ) {
+ if ( ((mgrGetSyncMLAnchor())->wsmGlobals=smlLibMalloc(sizeof(WsmGlobals_t))) == 0 ) {
+ return;
+ }
+ smlLibMemset((mgrGetSyncMLAnchor())->wsmGlobals, 0, sizeof(WsmGlobals_t));
+ wsmRet = 0;
+ initWasCalled = 0;
+ wsmIndex = 0;
+#ifdef __ANSI_C__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm = NULL;
+#endif
+#ifdef __PALM_OS__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm.smMemH = 0;
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm.smLocked = 0;
+#endif
+#ifdef __EPOC_OS__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm = NULL;
+#endif
+ }
+}
+#define freeDataStructs() smlLibFree((mgrGetSyncMLAnchor())->wsmGlobals)
+
+
+/* private functions prototypes */
+static Short_t getNextFreeEntry();
+static Short_t lookup(MemHandle_t memH);
+static MemHandle_t nameToHandle(String_t name);
+static Short_t deleteBufferHandle(MemHandle_t memH);
+static Short_t resetBufferGlobals(MemHandle_t memH);
+static Byte_t isValidMemH(MemHandle_t memH);
+static Byte_t isLockedMemH(MemHandle_t memH);
+static Byte_t isMemAvailable(MemSize_t memToAlloc);
+
+
+
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+
+
+/**
+ * Get next free buffer entry.
+ * Returns index of next free entry, or -1 if buffer table is full.
+ */
+static Short_t getNextFreeEntry() {
+ Short_t i;
+
+ for ( i=0; i < MAX_WSM_BUFFERS; ++i )
+ if ( wsmBuf[i].memH == WSM_MEMH_UNUSED )
+ return i;
+
+ return -1;
+}
+
+
+
+/**
+ * Get buffer table index for memH.
+ * Returns -1 if memH not found.
+ */
+static Short_t lookup(MemHandle_t memH) {
+ Short_t i;
+
+ // first check cache
+ if ( wsmBuf[wsmIndex].memH == memH )
+ return wsmIndex;
+
+ // search through buffer
+ for ( i=0; (i < MAX_WSM_BUFFERS) && (wsmBuf[i].memH != memH); ++i )
+ ;
+ if ( i < MAX_WSM_BUFFERS ) {
+ wsmIndex = i;
+ return i;
+ }
+ else {
+ return -1; // memH not found
+ }
+}
+
+
+/**
+ * Find memory handle corresponding to name.
+ * Return WSM_MEMH_UNUSED, if name not found in wsmBuf.
+ */
+static MemHandle_t nameToHandle(String_t name) {
+ int i;
+
+ // first check cache
+ if ( (wsmBuf[wsmIndex].bufName != NULL) &&
+ (smlLibStrcmp(wsmBuf[wsmIndex].bufName, name) == 0) )
+ return wsmBuf[wsmIndex].memH;
+
+ // search through buffer
+ for ( i=0; ((i < MAX_WSM_BUFFERS) &&
+ (wsmBuf[i].bufName == NULL ? 1 :
+ smlLibStrcmp(wsmBuf[i].bufName, name) != 0)); ++i )
+ ;
+ if ( i < MAX_WSM_BUFFERS )
+ return wsmBuf[i].memH;
+ else {
+ return WSM_MEMH_UNUSED; // name not found
+ }
+}
+
+
+
+/**
+ * Delete memory handle from buffer.
+ * Return -1, if handle not found.
+ */
+static Short_t deleteBufferHandle(MemHandle_t memH) {
+ if ( (wsmIndex = lookup(memH)) < 0 )
+ return -1; // handle not found
+
+ // reset the values
+ wsmBuf[wsmIndex].memH = WSM_MEMH_UNUSED;
+ wsmBuf[wsmIndex].pFirstFree = NULL;
+ wsmBuf[wsmIndex].pFirstData = NULL;
+ wsmBuf[wsmIndex].size = 0;
+ wsmBuf[wsmIndex].usedBytes = 0;
+ //wsmBuf[wsmIndex].flags = ~WSM_VALID_F;
+ wsmBuf[wsmIndex].flags = ((Byte_t) ~WSM_VALID_F);
+ smlLibFree(wsmBuf[wsmIndex].bufName); // free mem
+ wsmBuf[wsmIndex].bufName = NULL;
+
+ return 0;
+}
+
+
+/**
+ * Reset values in buffer table for entry memH.
+ * If memH doesn't exist create an entry.
+ * Return index to memH in buffer table,
+ * or -1 if table is full
+ */
+static Short_t resetBufferGlobals(MemHandle_t memH) {
+ if ( (wsmIndex = lookup(memH)) < 0 ) {
+ // create new one
+ if ( (wsmIndex = getNextFreeEntry()) < 0 )
+ return -1; // buffer table full
+ wsmBuf[wsmIndex].memH = memH;
+ } else
+ // use existing one, which has to be reset prior usage
+ smlLibFree(wsmBuf[wsmIndex].bufName); // free mem
+
+ // reset the values
+ wsmBuf[wsmIndex].pFirstFree = NULL;
+ wsmBuf[wsmIndex].pFirstData = NULL;
+ wsmBuf[wsmIndex].size = 0;
+ wsmBuf[wsmIndex].usedBytes = 0;
+ wsmBuf[wsmIndex].flags = WSM_VALID_F;
+ wsmBuf[wsmIndex].bufName = NULL;
+
+ return wsmIndex;
+}
+
+
+static Byte_t isValidMemH(MemHandle_t memH) {
+ Short_t i;
+ i = lookup(memH);
+ if (i < 0)
+ {
+ return 0;
+ }else{
+ return (Byte_t) (wsmBuf[i].flags & WSM_VALID_F);
+ }
+}
+
+static Byte_t isLockedMemH(MemHandle_t memH) {
+ Short_t i;
+ i = lookup(memH);
+ if (i < 0)
+ {
+ return 0;
+ }else{
+ return (Byte_t) (wsmBuf[i].flags & WSM_LOCKED_F);
+ }
+}
+
+static Byte_t isMemAvailable(MemSize_t memToAlloc) {
+ int i;
+ MemSize_t actMem = memToAlloc;
+ if ( maxWsmAvailMem == 0 )
+ return 1; // no memsize restrictions
+ for (i=0; i < MAX_WSM_BUFFERS; ++i) {
+ if ( wsmBuf[i].memH != WSM_MEMH_UNUSED )
+ actMem += wsmBuf[i].size;
+ }
+ return ((Byte_t)(actMem <= maxWsmAvailMem));
+}
+
+
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+
+
+/**
+ * FUNCTION: wsmInit
+ *
+ * Initializes all Workspace Manager related resources.<BR>
+ * Should only be called once!
+ *
+ * PRE-Condition: This is the first function call to WSM
+ *
+ * POST-Condition: All WSM resources are initialized
+ *
+ * IN: wsmOpts
+ * WSM options, valid options are:
+ * <UL>
+ * <LI> maxAvailMem<BR>
+ * Maximal amount of memory which wsm can use for the buffers<BR>
+ * 0 == no limitation
+ * </UL>
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_OPTIONS, if wsmOpts is not valid
+ * SML_ERR_NOT_ENOUGH_SPACE, if not enough available memory
+ * SML_ERR_WRONG_USAGE, if wsmInit was already called
+ */
+Ret_t wsmInit (const WsmOptions_t *wsmOpts) {
+ int i;
+
+ // create global datastructs
+ createDataStructs();
+
+ if (NULL == mgrGetSyncMLAnchor()->wsmGlobals) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // check if init was already called
+ if ( initWasCalled )
+ return SML_ERR_WRONG_USAGE;
+
+ // check options
+ if ( wsmOpts != NULL ) {
+ if ( wsmOpts->maxAvailMem > 0 ) {
+ maxWsmAvailMem = wsmOpts->maxAvailMem;
+ }
+ }
+
+ // init resources
+ for ( i=0; i < MAX_WSM_BUFFERS; ++i )
+ wsmBuf[i].memH = WSM_MEMH_UNUSED;
+ wsmIndex = 0;
+ initWasCalled = (Byte_t) 1;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmCreate
+ *
+ * Creates and opens a new buffer with name bufName and size bufSize.<BR>
+ * If a buffer with name bufName already exists, the existing buffer
+ * is resized to bufSize.
+ *
+ * PRE-Condition: bufSize > 0
+ *
+ * POST-Condition: handle refers to buffer bufName; BufferSize = size
+ *
+ * IN: bufName
+ * Name of buffer to be created
+ * IN: bufSize
+ * Size of buffer to be created
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_SIZE, if bufSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < bufSize
+ * SML_ERR_WSM_BUF_TABLE_FULL, if buffer table is full
+ * SML_ERR_WRONG_USAGE, if wsmInit wasn't called before
+ *
+ * @see wsmDestroy
+ */
+Ret_t wsmCreate (String_t bufName, MemSize_t bufSize, MemHandle_t *wsmH) {
+
+ *wsmH = 0; // 0 in case of error
+
+ if ( ! initWasCalled )
+ return SML_ERR_WRONG_USAGE;
+
+ // check buffer space
+ if ( getNextFreeEntry() == -1 ) {
+ return wsmRet=SML_ERR_WSM_BUF_TABLE_FULL;
+ }
+ // check for maxMemAvailable
+ if ( ! isMemAvailable(bufSize) ) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // create buffer
+ if ( (wsmRet = smCreate(bufName, bufSize, wsmH)) != SML_ERR_OK ) {
+ if ( wsmRet == SML_ERR_WRONG_USAGE ) { // buffer already exists
+ // resize existing buffer
+ // open buffer
+ if ( (wsmRet = smOpen(bufName, wsmH)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ // resize buffer
+ if ( (wsmRet = smSetSize(*wsmH, bufSize)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ }
+ else {
+ return wsmRet;
+ }
+ }
+
+ // reset buffer vars
+ wsmIndex = resetBufferGlobals(*wsmH);
+
+ // set buffer vars
+ wsmBuf[wsmIndex].size = bufSize;
+ wsmBuf[wsmIndex].bufName = smlLibStrdup(bufName);
+
+ if (wsmBuf[wsmIndex].bufName == NULL) {
+ smClose(*wsmH);
+ smDestroy(bufName);
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmOpen
+ *
+ * Open existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName
+ *
+ * POST-Condition: wsmH refers to buffer bufName
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_WRONG_PARAM, if bufName is unknown
+ *
+ * @see wsmClose
+ */
+Ret_t wsmOpen (String_t bufName, MemHandle_t *wsmH){
+
+ // open buffer
+ if ( (wsmRet = smOpen(bufName, wsmH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ // reset buffer vars
+ wsmIndex = resetBufferGlobals(*wsmH);
+
+ // set buf vars
+ wsmRet = smGetSize(*wsmH, &wsmBuf[wsmIndex].size);
+ wsmBuf[wsmIndex].bufName = smlLibStrdup(bufName);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmClose
+ *
+ * Close an open buffer.
+ *
+ * PRE-Condition: handle is valid; handle is unlocked
+ *
+ * POST-Condition: handle is not known to WSM any more
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmOpen
+ */
+Ret_t wsmClose (MemHandle_t wsmH) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ // close handle
+ if ( (wsmRet = smClose(wsmH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+ wsmRet = deleteBufferHandle(wsmH);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmDestroy
+ *
+ * Destroy existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName; handle is unlocked
+ *
+ * POST-Condition: buffer is not known to WSM any more; all resources
+ * connected to this buffer are freed
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if bufName is unknown to WSM
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmCreate
+ */
+Ret_t wsmDestroy (String_t bufName) {
+
+ // free resources
+ if ( (wsmRet = wsmClose(nameToHandle(bufName))) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ // free buffer
+ if ( (wsmRet = smDestroy(bufName)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmTerminate
+ *
+ * Terminate WSM; free all buffers and resources.
+ *
+ * PRE-Condition: all handles must be unlocked
+ *
+ * POST-Condition: all resources are freed
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if a handle was still locked
+ *
+ */
+Ret_t wsmTerminate (void) {
+ int i;
+
+ // free all WSM resources
+ for (i=0; i < MAX_WSM_BUFFERS; ++i) {
+ if ( wsmBuf[i].memH != WSM_MEMH_UNUSED )
+ if ( wsmDestroy(wsmBuf[i].bufName) == SML_ERR_WRONG_USAGE ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+ }
+
+ // free global DataStructs
+ freeDataStructs();
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmProcessedBytes
+ *
+ * Tell Workspace Manager the number of bytes already processed.
+ *
+ * PRE-Condition: handle is locked; handle is valid;
+ * noBytes <= wsmGetUsedSize
+ *
+ * POST-Condition: noBytes starting at wsmGetPtr() position are deleted;
+ * remaining bytes are copied to
+ * wsmGetPtr(SML_FIRST_FREE_ITEM) position;
+ * wsmGetUsedSize -= noBytes; wsmGetFreeSize += noBytes
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: noBytes
+ * Number of bytes already processed from buffer.
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_INVALID_SIZE, if noBytes > wsmGetUsedSize
+ *
+ * @see wsmGetFreeSize
+ */
+Ret_t wsmProcessedBytes (MemHandle_t wsmH, MemSize_t noBytes) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is unlocked
+ if ( ! isLockedMemH(wsmH) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ wsmIndex = lookup(wsmH);
+
+ if ( noBytes > wsmBuf[wsmIndex].usedBytes ) {
+ return wsmRet=SML_ERR_INVALID_SIZE;
+ }
+
+ // adapt usedSize
+ wsmBuf[wsmIndex].usedBytes -= noBytes;
+
+ // move memory
+ // check return ?????
+ smlLibMemmove(wsmBuf[wsmIndex].pFirstData,
+ (wsmBuf[wsmIndex].pFirstData + noBytes),
+ wsmBuf[wsmIndex].usedBytes);
+
+ // move pFirstFree
+ wsmBuf[wsmIndex].pFirstFree -= noBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmLockH
+ *
+ * Locks handle wsmH and get a pointer to the contents of wsmH. <BR>
+ * RequestedPos describes the position in the buffer to which the returned
+ * pointer should point. Valid values are:
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM
+ * <LI> SML_FIRST_FREE_ITEM
+ * </UL>
+ *
+ * PRE-Condition: handle is unlocked; handle is valid
+ *
+ * POST-Condition: handle is locked; points to first data item,
+ * or first free item.
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: requestedPos
+ * Requested position of the returned pointer
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM : points to first data entry
+ * <LI> SML_FIRST_FREE_ITEM : points to first free entry
+ * </UL>
+ *
+ * OUT: pMem
+ * Pointer to requested memory
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ * SML_ERR_UNSPECIFIC, if requested position is unknown, or lock failed
+ *
+ * @see wsmUnlockH
+ */
+Ret_t wsmLockH (MemHandle_t wsmH, SmlBufPtrPos_t requestedPos,
+ MemPtr_t *pMem) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is locked
+ if ( isLockedMemH(wsmH) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // lock
+ if ( (wsmRet = smLock(wsmH, pMem)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ // set local pointers
+ wsmIndex = lookup(wsmH);
+ wsmBuf[wsmIndex].pFirstData = *pMem;
+ wsmBuf[wsmIndex].pFirstFree = *pMem + wsmBuf[wsmIndex].usedBytes;
+ wsmBuf[wsmIndex].flags |= WSM_LOCKED_F;
+
+ switch (requestedPos) {
+ case SML_FIRST_DATA_ITEM:
+ *pMem = wsmBuf[wsmIndex].pFirstData;
+ break;
+ case SML_FIRST_FREE_ITEM:
+ *pMem = wsmBuf[wsmIndex].pFirstFree;
+ break;
+ default:
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmGetFreeSize
+ *
+ * Returns the remaining unused bytes in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: wsmGetFreeSize = BufferSize - wsmGetUsedSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: freeSize
+ * Number of bytes which are unused in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetUsedSize
+ * @see wsmProcessedBytes
+ */
+Ret_t wsmGetFreeSize(MemHandle_t wsmH, MemSize_t *freeSize) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ wsmIndex = lookup(wsmH);
+
+ *freeSize = wsmBuf[wsmIndex].size - wsmBuf[wsmIndex].usedBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmGetUsedSize
+ *
+ * Returns the number of bytes used in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: usedSize = BufferSize - wsmGetFreeSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: usedSize
+ * Number of bytes which are already used in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetFreeSize
+ * @see wsmSetUsedSize
+ */
+Ret_t wsmGetUsedSize(MemHandle_t wsmH, MemSize_t *usedSize) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ wsmIndex = lookup(wsmH);
+
+ *usedSize = wsmBuf[wsmIndex].usedBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmUnlockH
+ *
+ * Unlock handle wsmH. <BR>
+ * After this call all pointers to this memory handle are invalid
+ * and should no longer be used.
+ *
+ * PRE-Condition: handle is locked; handle is valid
+ *
+ * POST-Condition: handle is unlocked
+ *
+ * OUT: wsmH
+ * Handle to unlock
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_UNSPECIFIC, unlock failed
+ *
+ * @see wsmLockH
+ */
+Ret_t wsmUnlockH (MemHandle_t wsmH) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is already unlocked
+ if ( ! isLockedMemH(wsmH) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // unlock
+ if ( (wsmRet = smUnlock(wsmH)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ // set local pointers
+ wsmIndex = lookup(wsmH);
+ wsmBuf[wsmIndex].pFirstData = NULL;
+ wsmBuf[wsmIndex].pFirstFree = NULL;
+ wsmBuf[wsmIndex].flags &= ~WSM_LOCKED_F;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmSetUsedSize
+ *
+ * Tell Workspace how many data were written into buffer.
+ *
+ * PRE-Condition: handle is valid; usedSize <= wsmGetFreeSize; handle is
+ * locked
+ *
+ * POST-Condition: wsmGetUsedSize += usedSize; wsmGetFreeSize -= usedSize;
+ * instancePtr += usedSize;
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: usedSize
+ * Number of bytes which were written into buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_INVALID_SIZE, if usedSize <= wsmGetFreeSize
+ *
+ * @see wsmGetUsedSize
+ */
+Ret_t wsmSetUsedSize (MemHandle_t wsmH, MemSize_t usedSize) {
+
+ // check if handle is invalid
+ if ( ! isValidMemH(wsmH) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is unlocked
+ if ( ! isLockedMemH(wsmH) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ wsmIndex = lookup(wsmH);
+
+ // usedSize > freeSize?
+ if ( usedSize >
+ (wsmBuf[wsmIndex].size - wsmBuf[wsmIndex].usedBytes) ) {
+ return wsmRet=SML_ERR_INVALID_SIZE;
+ }
+
+ // adapt usedSize
+ wsmBuf[wsmIndex].usedBytes += usedSize;
+
+ // move pFirstFree
+ wsmBuf[wsmIndex].pFirstFree += usedSize;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wsmReset
+ *
+ * Reset the Workspace
+ *
+ * PRE-Condition: -
+ *
+ * POST-Condition: all data is lost. The FirstFree Position equals
+ * the First Data position
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ *
+ */
+Ret_t wsmReset (MemHandle_t wsmH) {
+
+ wsmIndex = lookup(wsmH);
+ wsmBuf[wsmIndex].pFirstFree = wsmBuf[wsmIndex].pFirstFree - wsmBuf[wsmIndex].usedBytes ;
+ wsmBuf[wsmIndex].pFirstData = wsmBuf[wsmIndex].pFirstFree;
+ wsmBuf[wsmIndex].usedBytes = 0;
+
+ return SML_ERR_OK;
+}
+
+/*======================================================================================*/
+#else
+/* WSM_LITE Version - uses only one buffer*/
+/*======================================================================================*/
+
+
+/* Global Vars */
+/* =========== */
+
+/* defines for convient use of global anchor */
+#define wsmRet (mgrGetSyncMLAnchor())->wsmGlobals->wsmRet
+#define initWasCalled (mgrGetSyncMLAnchor())->wsmGlobals->initWasCalled
+#define maxWsmAvailMem (mgrGetSyncMLAnchor())->syncmlOptions->maxWorkspaceAvailMem
+#define wsmBuf (mgrGetSyncMLAnchor())->wsmGlobals->wsmBuf
+#define wsmIndex (mgrGetSyncMLAnchor())->wsmGlobals->wsmIndex
+
+void createDataStructs(void);
+
+void createDataStructs() {
+ if ( (mgrGetSyncMLAnchor())->wsmGlobals == NULL ) {
+ if ( ((mgrGetSyncMLAnchor())->wsmGlobals=smlLibMalloc(sizeof(WsmGlobals_t))) == 0 ) {
+ return;
+ }
+ wsmRet = 0;
+ initWasCalled = 0;
+ wsmIndex = 0;
+#ifdef __ANSI_C__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm = NULL;
+#endif
+#ifdef __PALM_OS__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm.smMemH = 0;
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm.smLocked = 0;
+#endif
+#ifdef __EPOC_OS__
+ (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm = NULL;
+#endif
+ }
+}
+#define freeDataStructs() smlLibFree((mgrGetSyncMLAnchor())->wsmGlobals)
+
+
+
+/* private functions prototypes */
+static Short_t getNextFreeEntry();
+static Short_t deleteBufferHandle(MemHandle_t memH);
+static Short_t resetBufferGlobals(MemHandle_t memH);
+static Byte_t isMemAvailable(MemSize_t memToAlloc);
+
+
+
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+
+
+
+/**
+ * Delete memory handle from buffer.
+ * Return -1, if handle not found.
+ */
+static Short_t deleteBufferHandle(MemHandle_t memH) {
+ // reset the values
+ wsmBuf[0].memH = WSM_MEMH_UNUSED;
+ wsmBuf[0].pFirstFree = NULL;
+ wsmBuf[0].pFirstData = NULL;
+ wsmBuf[0].size = 0;
+ wsmBuf[0].usedBytes = 0;
+ wsmBuf[0].flags = ~WSM_VALID_F;
+ smlLibFree(wsmBuf[0].bufName); // free mem
+ wsmBuf[0].bufName = NULL;
+
+ return 0;
+}
+
+
+/**
+ * Reset values in buffer table for entry memH.
+ * If memH doesn't exist create an entry.
+ * Return index to memH in buffer table,
+ * or -1 if table is full
+ */
+static Short_t resetBufferGlobals(MemHandle_t memH) {
+ if ( (wsmBuf[0].memH != memH) && (wsmBuf[0].memH == WSM_MEMH_UNUSED)) {
+ // create new one
+ wsmBuf[0].memH = memH;
+ } else {
+ // use existing one, which has to be reset prior usage
+ smlLibFree(wsmBuf[0].bufName); // free mem
+ }
+ // reset the values
+ wsmBuf[0].pFirstFree = NULL;
+ wsmBuf[0].pFirstData = NULL;
+ wsmBuf[0].size = 0;
+ wsmBuf[0].usedBytes = 0;
+ wsmBuf[0].flags = WSM_VALID_F;
+ wsmBuf[0].bufName = NULL;
+
+ return 0;
+}
+
+
+static Byte_t isMemAvailable(MemSize_t memToAlloc) {
+ MemSize_t actMem = memToAlloc;
+ if ( maxWsmAvailMem == 0 )
+ return 1; // no memsize restrictions
+ if ( wsmBuf[0].memH != WSM_MEMH_UNUSED )
+ actMem += wsmBuf[0].size;
+ return (actMem <= maxWsmAvailMem);
+}
+
+
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+
+
+/**
+ * FUNCTION: wsmInit
+ *
+ * Initializes all Workspace Manager related resources.<BR>
+ * Should only be called once!
+ *
+ * PRE-Condition: This is the first function call to WSM
+ *
+ * POST-Condition: All WSM resources are initialized
+ *
+ * IN: wsmOpts
+ * WSM options, valid options are:
+ * <UL>
+ * <LI> maxAvailMem<BR>
+ * Maximal amount of memory which wsm can use for the buffers<BR>
+ * 0 == no limitation
+ * </UL>
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_OPTIONS, if wsmOpts is not valid
+ * SML_ERR_NOT_ENOUGH_SPACE, if not enough available memory
+ * SML_ERR_WRONG_USAGE, if wsmInit was already called
+ */
+Ret_t wsmInit (const WsmOptions_t *wsmOpts) {
+ // create global datastructs
+ createDataStructs();
+
+ if (NULL == mgrGetSyncMLAnchor()->wsmGlobals) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+
+ // check if init was already called
+ if ( initWasCalled )
+ return SML_ERR_WRONG_USAGE;
+
+ // check options
+ if ( wsmOpts != NULL ) {
+ if ( wsmOpts->maxAvailMem > 0 ) {
+ maxWsmAvailMem = wsmOpts->maxAvailMem;
+ }
+ }
+
+ // init resources
+ wsmBuf[0].memH = WSM_MEMH_UNUSED;
+ wsmIndex = 0;
+ initWasCalled = (Byte_t) 1;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmCreate
+ *
+ * Creates and opens a new buffer with name bufName and size bufSize.<BR>
+ * If a buffer with name bufName already exists, the existing buffer
+ * is resized to bufSize.
+ *
+ * PRE-Condition: bufSize > 0
+ *
+ * POST-Condition: handle refers to buffer bufName; BufferSize = size
+ *
+ * IN: bufName
+ * Name of buffer to be created
+ * IN: bufSize
+ * Size of buffer to be created
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_SIZE, if bufSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < bufSize
+ * SML_ERR_WSM_BUF_TABLE_FULL, if buffer table is full
+ * SML_ERR_WRONG_USAGE, if wsmInit wasn't called before
+ *
+ * @see wsmDestroy
+ */
+Ret_t wsmCreate (String_t bufName, MemSize_t bufSize, MemHandle_t *wsmH) {
+
+ *wsmH = 0; // 0 in case of error
+
+ if ( ! initWasCalled )
+ return SML_ERR_WRONG_USAGE;
+
+ // check buffer space
+ if ( wsmBuf[0].memH != WSM_MEMH_UNUSED ) {
+ return wsmRet=SML_ERR_WSM_BUF_TABLE_FULL;
+ }
+ // check for maxMemAvailable
+ if ( ! isMemAvailable(bufSize) ) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // create buffer
+ if ( (wsmRet = smCreate(bufName, bufSize, wsmH)) != SML_ERR_OK ) {
+ if ( wsmRet == SML_ERR_WRONG_USAGE ) { // buffer already exists
+ // resize existing buffer
+ // open buffer
+ if ( (wsmRet = smOpen(bufName, wsmH)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ // resize buffer
+ if ( (wsmRet = smSetSize(*wsmH, bufSize)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ }
+ else {
+ return wsmRet;
+ }
+ }
+
+ // reset buffer vars
+ resetBufferGlobals(*wsmH);
+
+ // set buffer vars
+ wsmBuf[0].size = bufSize;
+ wsmBuf[0].bufName = smlLibStrdup(bufName);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmOpen
+ *
+ * Open existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName
+ *
+ * POST-Condition: wsmH refers to buffer bufName
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * OUT: wsmH
+ * Handle to new buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_WRONG_PARAM, if bufName is unknown
+ *
+ * @see wsmClose
+ */
+Ret_t wsmOpen (String_t bufName, MemHandle_t *wsmH){
+
+ // open buffer
+ if ( (wsmRet = smOpen(bufName, wsmH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ // reset buffer vars
+ resetBufferGlobals(*wsmH);
+
+ // set buf vars
+ wsmRet = smGetSize(*wsmH, &wsmBuf[0].size);
+ wsmBuf[0].bufName = smlLibStrdup(bufName);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmClose
+ *
+ * Close an open buffer.
+ *
+ * PRE-Condition: handle is valid; handle is unlocked
+ *
+ * POST-Condition: handle is not known to WSM any more
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmOpen
+ */
+Ret_t wsmClose (MemHandle_t wsmH) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ // close handle
+ if ( (wsmRet = smClose(wsmH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+ wsmRet = deleteBufferHandle(wsmH);
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmDestroy
+ *
+ * Destroy existing buffer with name bufName.
+ *
+ * PRE-Condition: WSM knows bufName; handle is unlocked
+ *
+ * POST-Condition: buffer is not known to WSM any more; all resources
+ * connected to this buffer are freed
+ *
+ * IN: bufName
+ * Name of buffer to be opened
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if bufName is unknown to WSM
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ *
+ * @see wsmCreate
+ */
+Ret_t wsmDestroy (String_t bufName) {
+
+ // free resources
+ if ( (wsmRet = wsmClose(wsmBuf[0].memH)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ // free buffer
+ if ( (wsmRet = smDestroy(bufName)) != SML_ERR_OK ) {
+ return wsmRet;
+ }
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmTerminate
+ *
+ * Terminate WSM; free all buffers and resources.
+ *
+ * PRE-Condition: all handles must be unlocked
+ *
+ * POST-Condition: all resources are freed
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if a handle was still locked
+ *
+ */
+Ret_t wsmTerminate () {
+ int i;
+
+ // free all WSM resources
+ for (i=0; i < MAX_WSM_BUFFERS; ++i) {
+ if ( wsmBuf[i].memH != WSM_MEMH_UNUSED )
+ if ( wsmDestroy(wsmBuf[i].bufName) == SML_ERR_WRONG_USAGE ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+ }
+
+ // free global DataStructs
+ freeDataStructs();
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmProcessedBytes
+ *
+ * Tell Workspace Manager the number of bytes already processed.
+ *
+ * PRE-Condition: handle is locked; handle is valid;
+ * noBytes <= wsmGetUsedSize
+ *
+ * POST-Condition: noBytes starting at wsmGetPtr() position are deleted;
+ * remaining bytes are copied to
+ * wsmGetPtr(SML_FIRST_FREE_ITEM) position;
+ * wsmGetUsedSize -= noBytes; wsmGetFreeSize += noBytes
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: noBytes
+ * Number of bytes already processed from buffer.
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_INVALID_SIZE, if noBytes > wsmGetUsedSize
+ *
+ * @see wsmGetFreeSize
+ */
+Ret_t wsmProcessedBytes (MemHandle_t wsmH, MemSize_t noBytes) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is unlocked
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_LOCKED_F)) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ if ( noBytes > wsmBuf[0].usedBytes ) {
+ return wsmRet=SML_ERR_INVALID_SIZE;
+ }
+
+ // adapt usedSize
+ wsmBuf[0].usedBytes -= noBytes;
+
+ // move memory
+ // check return ?????
+ smlLibMemmove(wsmBuf[0].pFirstData,
+ (wsmBuf[0].pFirstData + noBytes),
+ wsmBuf[0].usedBytes);
+
+ // move pFirstFree
+ wsmBuf[0].pFirstFree -= noBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmLockH
+ *
+ * Locks handle wsmH and get a pointer to the contents of wsmH. <BR>
+ * RequestedPos describes the position in the buffer to which the returned
+ * pointer should point. Valid values are:
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM
+ * <LI> SML_FIRST_FREE_ITEM
+ * </UL>
+ *
+ * PRE-Condition: handle is unlocked; handle is valid
+ *
+ * POST-Condition: handle is locked; points to first data item,
+ * or first free item.
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: requestedPos
+ * Requested position of the returned pointer
+ * <UL>
+ * <LI> SML_FIRST_DATA_ITEM : points to first data entry
+ * <LI> SML_FIRST_FREE_ITEM : points to first free entry
+ * </UL>
+ *
+ * OUT: pMem
+ * Pointer to requested memory
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was still locked
+ * SML_ERR_UNSPECIFIC, if requested position is unknown, or lock failed
+ *
+ * @see wsmUnlockH
+ */
+Ret_t wsmLockH (MemHandle_t wsmH, SmlBufPtrPos_t requestedPos,
+ MemPtr_t *pMem) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is locked
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_LOCKED_F)) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // lock
+ if ( (wsmRet = smLock(wsmH, pMem)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ // set local pointers
+ wsmBuf[0].pFirstData = *pMem;
+ wsmBuf[0].pFirstFree = *pMem + wsmBuf[0].usedBytes;
+ wsmBuf[0].flags |= WSM_LOCKED_F;
+
+ switch (requestedPos) {
+ case SML_FIRST_DATA_ITEM:
+ *pMem = wsmBuf[0].pFirstData;
+ break;
+ case SML_FIRST_FREE_ITEM:
+ *pMem = wsmBuf[0].pFirstFree;
+ break;
+ default:
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmGetFreeSize
+ *
+ * Returns the remaining unused bytes in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: wsmGetFreeSize = BufferSize - wsmGetUsedSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: freeSize
+ * Number of bytes which are unused in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetUsedSize
+ * @see wsmProcessedBytes
+ */
+Ret_t wsmGetFreeSize(MemHandle_t wsmH, MemSize_t *freeSize) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ *freeSize = wsmBuf[0].size - wsmBuf[0].usedBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmGetUsedSize
+ *
+ * Returns the number of bytes used in the buffer.
+ *
+ * PRE-Condition: handle is valid
+ *
+ * POST-Condition: usedSize = BufferSize - wsmGetFreeSize
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * OUT: usedSize
+ * Number of bytes which are already used in this buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ *
+ * @see wsmGetFreeSize
+ * @see wsmSetUsedSize
+ */
+Ret_t wsmGetUsedSize(MemHandle_t wsmH, MemSize_t *usedSize) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+
+ *usedSize = wsmBuf[0].usedBytes;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmUnlockH
+ *
+ * Unlock handle wsmH. <BR>
+ * After this call all pointers to this memory handle are invalid
+ * and should no longer be used.
+ *
+ * PRE-Condition: handle is locked; handle is valid
+ *
+ * POST-Condition: handle is unlocked
+ *
+ * OUT: wsmH
+ * Handle to unlock
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_WRONG_USAGE, if handle was not locked
+ * SML_ERR_UNSPECIFIC, unlock failed
+ *
+ * @see wsmLockH
+ */
+Ret_t wsmUnlockH (MemHandle_t wsmH) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is already unlocked
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_LOCKED_F)) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // unlock
+ if ( (wsmRet = smUnlock(wsmH)) != SML_ERR_OK ) {
+ return wsmRet=SML_ERR_UNSPECIFIC;
+ }
+
+ // set local pointers
+ wsmBuf[0].pFirstData = NULL;
+ wsmBuf[0].pFirstFree = NULL;
+ wsmBuf[0].flags &= ~WSM_LOCKED_F;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wsmSetUsedSize
+ *
+ * Tell Workspace how many data were written into buffer.
+ *
+ * PRE-Condition: handle is valid; usedSize <= wsmGetFreeSize; handle is
+ * locked
+ *
+ * POST-Condition: wsmGetUsedSize += usedSize; wsmGetFreeSize -= usedSize;
+ * instancePtr += usedSize;
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ * IN: usedSize
+ * Number of bytes which were written into buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_INVALID_HANDLE, if handle was invalid
+ * SML_ERR_INVALID_SIZE, if usedSize <= wsmGetFreeSize
+ *
+ * @see wsmGetUsedSize
+ */
+Ret_t wsmSetUsedSize (MemHandle_t wsmH, MemSize_t usedSize) {
+
+ // check if handle is invalid
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_VALID_F)) ) {
+ return wsmRet=SML_ERR_INVALID_HANDLE;
+ }
+ // check if handle is unlocked
+ // must be buffer 0, as only this one exists
+ if ( ! ((wsmBuf[0].memH == wsmH) || (wsmBuf[0].flags & WSM_LOCKED_F)) ) {
+ return wsmRet=SML_ERR_WRONG_USAGE;
+ }
+
+ // usedSize > freeSize?
+ if ( usedSize >
+ (wsmBuf[0].size - wsmBuf[0].usedBytes) ) {
+ return wsmRet=SML_ERR_INVALID_SIZE;
+ }
+
+ // adapt usedSize
+ wsmBuf[0].usedBytes += usedSize;
+
+ // move pFirstFree
+ wsmBuf[0].pFirstFree += usedSize;
+
+ return wsmRet=SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wsmReset
+ *
+ * Reset the Workspace
+ *
+ * PRE-Condition: -
+ *
+ * POST-Condition: all data is lost. The FirstFree Position equals
+ * the First Data position
+ *
+ * IN: wsmH
+ * Handle to the open buffer
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ *
+ */
+Ret_t wsmReset (MemHandle_t wsmH) {
+ wsmBuf[0].pFirstFree = wsmBuf[0].pFirstFree - wsmBuf[0].usedBytes ;
+ wsmBuf[0].pFirstData = wsmBuf[0].pFirstFree;
+ wsmBuf[0].usedBytes = 0;
+
+ return SML_ERR_OK;
+}
+
+
+#endif // #ifndef __SML_LITE__
+
+#endif // #idndef NOWSM
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/wsm_sm.c b/engine/dmlib/dmengine/oma_toolkit/src/wsm_sm.c
new file mode 100644
index 0000000..b59c17d
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/wsm_sm.c
@@ -0,0 +1,510 @@
+/*************************************************************************/
+/* module: SyncML WorkSpace Manager */
+/* file: WSM_SM.c */
+/* target system: MS Windows */
+/* target OS: Windows 98 / NT */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Storage Management for Workspace Manager API. <BR>
+ * MS Windows version.
+ *
+ * @version @label
+ *
+ */
+
+#ifndef NOWSM
+// if no WSM, we can leave this one out completely
+
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "wsm_sm.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include "libmem.h"
+#include "liblock.h" // for THREADDEBUGPRINTF %%% luz
+#include "smldef.h"
+#include "smlerr.h"
+
+
+/* Global Vars */
+/* =========== */
+
+/** root of buffer list */
+
+#include "mgr.h"
+#define root (mgrGetSyncMLAnchor())->wsmGlobals->wsmSm
+
+/* private functions prototypes */
+static Byte_t newListEle(const char *name, smWinList_t **newEle, MemHandle_t *newHandle);
+static Byte_t locateEle(const char *eleName, smWinList_t **p);
+static Byte_t locateH(MemHandle_t memH, smWinList_t **p);
+static void removeEle(const char *eleName);
+
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+/** create new buffer element and assign name to it
+ * return pointer to new element and handle of new element
+ */
+/*
+ SCTSTK - 16/03/2002 S.H. 2002-04-05 : fixed so that it works even if the sequence of buffer termination
+ is not in the reverse order of buffer creation
+ */
+
+// luz %%% NOTE: called only from routines which lock the toolkit already,
+// no separate lock required here
+static Byte_t newListEle(const char *name,
+ smWinList_t **newEle,
+ MemHandle_t *newHandle
+)
+{
+ smWinList_t *p;
+ int i;
+ for ( i=0; *newHandle < MAX_WSM_BUFFERS && (mgrGetSyncMLAnchor())->wsmGlobals->wsmBuf[i].memH != -1; ++i ) {};
+ if (i == MAX_WSM_BUFFERS) return 0;
+ *newHandle=i+1;
+
+ if ( ((*newEle) = smlLibMalloc(sizeof(smWinList_t))) == 0 )
+ return 0; // no more memory
+ if ( ((*newEle)->memName = smlLibMalloc(strlen(name)+1)) == 0 ){
+ smlLibFree(*newEle);
+ return 0; // no more memory
+ }
+ memcpy((*newEle)->memName, name, strlen(name));
+ (*newEle)->memName[strlen(name)] = '\0';
+ if ( root == 0 )
+ root = *newEle;
+ else {
+ p=root;
+ while ( p->next != NULL) p = p->next;
+ p->next = *newEle;
+ }
+ return 1;
+}
+
+
+/**
+ * search for buffer with name eleName and return pointer to it in p.
+ * return == 0 if not found; 1 if found
+ */
+// luz %%% NOTE: called only from routines which lock the toolkit already,
+// no separate lock required here
+static Byte_t locateEle(const char *eleName, smWinList_t **p) {
+ *p = root;
+ while ( (*p != NULL) && (strcmp((*p)->memName, eleName) != 0) ) {
+ *p = (*p)->next;
+ }
+ if ( *p == NULL )
+ return 0;
+ else
+ return 1;
+}
+
+/**
+ * search for buffer with memHandle memH and return pointer to it in p.
+ * return == 0 if not found; 1 if found
+ */
+// luz %%% NOTE: called only from routines which lock the toolkit already,
+// no separate lock required here
+static Byte_t locateH(MemHandle_t memH, smWinList_t **p) {
+ *p = root;
+ while ( (*p != NULL) && ((*p)->memH != memH) ) {
+ *p = (*p)->next;
+ }
+ if ( *p == NULL )
+ return 0;
+ else
+ return 1;
+}
+
+/**
+ * remove buffer with name eleName from smWinList.
+ */
+// luz %%% NOTE: called only from routines which lock the toolkit already,
+// no separate lock required here
+static void removeEle(const char *eleName) {
+ smWinList_t *act, *old;
+
+ old = act = root;
+ while ( (act != NULL) && (strcmp(act->memName, eleName) != 0) ) {
+ old = act;
+ act = act->next;
+ }
+ if ( act != NULL ) {
+ if ( old == act ) // delete first list ele
+ root = act->next;
+ else
+ old->next = act->next;
+ smlLibFree(act->memName);
+ smlLibFree(act);
+ }
+}
+
+
+
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+
+/**
+ * FUNCTION: smCreate
+ *
+ * Creates a new memory block with name memName and size memSize.
+ *
+ * PRE-Condition: OS does not know memName; memSize > 0
+ *
+ * POST-Condition: memName exists with size memSize;
+ * memH refers to new memory block.
+ *
+ * IN: memName
+ * Name of new memory block
+ * IN: memSize
+ * Size of new memory block
+ *
+ * OUT: memH
+ * Handle to new memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if memName is already known to the OS
+ * SML_ERR_INVALID_SIZE, if memSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < memSize
+ *
+ * @see smDestroy
+ */
+Ret_t smCreate (String_t memName, MemSize_t memSize, MemHandle_t *memH) {
+ smWinList_t *pEle; // pointer to new buffer
+
+ if ( memSize <= 0 ) {
+ return SML_ERR_INVALID_SIZE;
+ }
+ if ( locateEle(memName, &pEle) ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ // create new element in buffer list
+ if ( ! newListEle(memName, &pEle, memH) ) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // create memory
+ if ( (pEle->winH=smlLibMalloc(memSize)) == 0 ) {
+ smlLibFree(pEle->memName);
+ smlLibFree(pEle);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ // set new values
+ pEle->locked = 0;
+ pEle->memH = *memH;
+ pEle->memSize = memSize;
+ pEle->next = NULL;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smOpen
+ *
+ * Open connection to memory block with name memName.
+ *
+ * PRE-Condition: OS does know memName
+ *
+ * POST-Condition: memH refers to memory block memName
+ *
+ * IN: memName
+ * Name of memory block to open<BR>
+ * Windows version: Name is ignored
+ *
+ * OUT: memH
+ * Handle to opened memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memName is unknown
+ *
+ * @see smClose
+ */
+Ret_t smOpen (String_t memName, MemHandle_t *memH) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateEle(memName, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+
+ *memH = pEle->memH;
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smClose
+ *
+ * Close link to memory block.
+ *
+ * PRE-Condition: memH is a valid memory block handle; memH is unlocked;
+ * no pointers to records are in use
+ *
+ * POST-Condition: memH is not valid anymore
+ *
+ * IN: memH
+ * Handle to close
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_USAGE, if memH is locked or unknown
+ *
+ * @see smOpen
+ */
+Ret_t smClose (MemHandle_t memH) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ // reset handle
+ smlLibFree(pEle->winH);
+ pEle->memH = 0;
+ pEle->locked = 0;
+ pEle->memSize = 0;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smDestroy
+ *
+ * Remove memory block memName within OS.
+ *
+ * PRE-Condition: memName is a valid memory block name;
+ * memory block is not in use (i.e. no handles and
+ * pointers to this memory block are in use)
+ *
+ * POST-Condition: memName is not a valid memory block name anymore
+ *
+ * IN: memName
+ * Name of memory block to remove
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memName is unknown
+ * SML_ERR_WRONG_USAGE, if memory block is still locked
+ *
+ * @see smCreate
+ */
+Ret_t smDestroy (String_t memName) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateEle(memName, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+ if ( pEle->locked ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ // remove memory buffer
+ removeEle(memName);
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smLock
+ *
+ * Map memory block memH to local address space.
+ *
+ * PRE-Condition: memH is a valid handle; memory block is not locked
+ *
+ * POST-Condition: pMem points to memory block memH;
+ * memory block is locked
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * OUT: pMem
+ * Pointer to memory block memH mapped in local address space
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH was already locked
+ * SML_ERR_UNSPECIFIC, if lock failed
+ *
+ * @see smUnlock
+ */
+Ret_t smLock (MemHandle_t memH, MemPtr_t *pMem) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+ if ( pEle->locked ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ *pMem = (MemPtr_t)pEle->winH;
+ pEle->locked = 1;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smUnlock
+ *
+ * Free pointer mapped to memH memory block.
+ *
+ * PRE-Condition: memH is a valid handle; memory block is locked
+ *
+ * POST-Condition: memory block is unlocked
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH was already unlocked
+ * SML_ERR_UNSPECIFIC, if unlock failed
+ *
+ * @see smLock
+ */
+Ret_t smUnlock (MemHandle_t memH) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+ if ( ! pEle->locked ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+
+ pEle->locked = 0;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smSetSize
+ *
+ * Set size of memory block memH to newSize.
+ *
+ * PRE-Condition: memH is a valid handle; newSize > 0;
+ * memory block is unlocked
+ *
+ * POST-Condition: memory block size = newSize
+ *
+ * IN: memH
+ * Handle to memory block
+ * IN: newSize
+ * New size of memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ * SML_ERR_WRONG_USAGE, if memH is locked
+ * SML_ERR_INVALID_SIZE, if newSize <= 0
+ * SML_ERR_NOT_ENOUGH_SPACE, if available memory < newSize
+ *
+ * @see smGetSize
+ */
+Ret_t smSetSize (MemHandle_t memH, MemSize_t newSize) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+ if ( pEle->locked ) {
+ return SML_ERR_WRONG_USAGE;
+ }
+ if ( newSize <= 0 ) {
+ return SML_ERR_INVALID_SIZE;
+ }
+
+ smlLibFree(pEle->winH);
+ if ( (pEle->winH=smlLibMalloc(newSize)) == 0 ) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ pEle->memSize = newSize;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smGetSize
+ *
+ * Get size of memory block memH.
+ *
+ * PRE-Condition: memH is a valid handle
+ *
+ * POST-Condition: actSize = memory block size
+ *
+ * IN: memH
+ * Handle to memory block
+ *
+ * OUT: actSize
+ * Actual size of memory block
+ *
+ * RETURN: SML_ERR_OK, if O.K.
+ * SML_ERR_WRONG_PARAM, if memH is unknown
+ *
+ * @see smSetSize
+ */
+Ret_t smGetSize (MemHandle_t memH, MemSize_t *actSize) {
+ smWinList_t *pEle; // pointer to buffer element
+
+ if ( ! locateH(memH, &pEle) ) {
+ return SML_ERR_WRONG_PARAM;
+ }
+
+ *actSize = pEle->memSize;
+
+ return SML_ERR_OK;
+}
+
+#endif // #ifndef NOWSM
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltdec.c b/engine/dmlib/dmengine/oma_toolkit/src/xltdec.c
new file mode 100644
index 0000000..005246d
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltdec.c
@@ -0,0 +1,2205 @@
+/*************************************************************************/
+/* module: SyncmML Decoder */
+/* file: XLTDec.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * The SyncML parser.
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#include "xltdec.h"
+#include "xltdeccom.h"
+#include "xlttags.h"
+#include "xltutilstack.h"
+#include "xlttagtbl.h"
+#include "xltmetinf.h"
+#include "xltdevinf.h"
+#include "xltdmtnd.h"
+
+#include <smldef.h>
+#include <smldtd.h>
+#include <smlmetinfdtd.h>
+#include <smldevinfdtd.h>
+#include <smldmtnddtd.h>
+#include <smlerr.h>
+
+#include <libmem.h>
+#include <libstr.h>
+#include <mgrutil.h>
+
+#ifdef __USE_EXTENSIONS__
+/* prototype for function in xltdecwbxml.c */
+void subdtdDecodeWbxml(XltDecoderPtr_t pDecoder,SmlPcdataPtr_t *ppPcdata);
+#endif
+
+/**
+ * FUNCTION: concatPCData
+ *
+ * Tries to concatenate two Pcdata elements. Only works when the two
+ * elements are of the same type (e.g. SML_PCDATA_STRING). Returns a
+ * pointer to the new Pcdata element or NULL if concatenation failed.
+ */
+static SmlPcdataPtr_t concatPCData(SmlPcdataPtr_t pDat1, const SmlPcdataPtr_t pDat2);
+
+
+/**
+ * FUNCTION: appendXXXList
+ *
+ * These are auxiliary functions for building SyncML elements that contain
+ * lists of certain other data structures (e.g. Items). They take an
+ * existing list (e.g. of type ItemListPtr_t) and append an appropriate
+ * element at the end. If the ListPtr points to NULL a new list is created.
+ *
+ * PRE-Condition:
+ * The scanner's current token is the start tag (may be
+ * empty) of the SyncML element to be appended to the list.
+ *
+ * POST-Condition:
+ * The scanner's current token is the end tag (or empty
+ * start tag) of the SyncML element that was added to the
+ * list.
+ *
+ * IN/OUT: pDecoder, the decoder
+ * ppXXXList, NULL or an initialized list, to which element
+ * will be appended
+ *
+ * RETURNS: SML_ERR_OK, if an element was successfully appended
+ * else error code
+ */
+static Ret_t appendItemList(XltDecoderPtr_t pDecoder, SmlItemListPtr_t *ppItemList);
+static Ret_t appendSourceList(XltDecoderPtr_t pDecoder, SmlSourceListPtr_t *ppSourceList);
+#ifdef MAPITEM_RECEIVE
+ static Ret_t appendMapItemList(XltDecoderPtr_t pDecoder, SmlMapItemListPtr_t *ppMapItemList);
+#endif
+static Ret_t appendTargetRefList(XltDecoderPtr_t pDecoder, SmlTargetRefListPtr_t *ppTargetRefList);
+static Ret_t appendSourceRefList(XltDecoderPtr_t pDecoder, SmlSourceRefListPtr_t *ppSourceRefList);
+
+/* if the commands are not defined we let the functions point to NULL */
+#ifndef RESULT_RECEIVE
+#define buildResults NULL
+#endif
+
+#ifndef MAP_RECEIVE
+#define buildMap NULL
+#endif
+
+#ifndef EXEC_RECEIVE
+#define buildExec NULL
+#endif
+
+#if !defined(ATOM_RECEIVE) && !defined(SEQUENCE_RECEIVE)
+#define buildAtomOrSeq NULL
+#endif
+
+#ifndef SEARCH_RECEIVE
+#define buildSearch NULL
+#endif
+
+
+typedef struct PEBuilder_s
+{
+ XltTagID_t tagid;
+ SmlProtoElement_t type;
+ Ret_t (*build)(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+} PEBuilder_t, *PEBuilderPtr_t;
+
+PEBuilderPtr_t getPETable(void);
+
+PEBuilderPtr_t getPETable(void)
+{
+ PEBuilderPtr_t _tmpPEPtr;
+ PEBuilder_t PE[] = {
+ { TN_ADD, SML_PE_ADD, buildGenericCmd },
+ { TN_ALERT, SML_PE_ALERT, buildAlert },
+ { TN_ATOMIC, SML_PE_ATOMIC_START, buildAtomOrSeq },
+ { TN_COPY, SML_PE_COPY, buildGenericCmd },
+ { TN_DELETE, SML_PE_DELETE, buildGenericCmd },
+ { TN_EXEC, SML_PE_EXEC, buildExec },
+ { TN_GET, SML_PE_GET, buildPutOrGet },
+ { TN_MAP, SML_PE_MAP, buildMap },
+ { TN_PUT, SML_PE_PUT, buildPutOrGet },
+ { TN_RESULTS, SML_PE_RESULTS, buildResults },
+ { TN_SEARCH, SML_PE_SEARCH, buildSearch },
+ { TN_SEQUENCE, SML_PE_SEQUENCE_START, buildAtomOrSeq },
+ { TN_STATUS, SML_PE_STATUS, buildStatus },
+ { TN_SYNC, SML_PE_SYNC_START, buildSync },
+ { TN_REPLACE, SML_PE_REPLACE, buildGenericCmd },
+ { TN_UNDEF, SML_PE_UNDEF, 0 }
+ };
+
+ _tmpPEPtr = smlLibMalloc(sizeof(PE));
+ if (_tmpPEPtr == NULL) return NULL;
+ smlLibMemcpy(_tmpPEPtr, &PE, sizeof(PE));
+ return _tmpPEPtr;
+}
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+/**
+ * Description see XLTDec.h header file.
+ */
+Ret_t
+xltDecInit(const SmlEncoding_t enc,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ XltDecoderPtr_t *ppDecoder,
+ SmlSyncHdrPtr_t *ppSyncHdr)
+{
+ XltDecoderPtr_t pDecoder;
+ Ret_t rc;
+
+
+ /* create new decoder object */
+ if ((pDecoder = (XltDecoderPtr_t)smlLibMalloc(sizeof(XltDecoder_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ pDecoder->finished = 0;
+ pDecoder->final = 0;
+ pDecoder->scanner = NULL;
+ if ((rc = xltUtilCreateStack(&pDecoder->tagstack, 10)) != SML_ERR_OK) {
+ xltDecTerminate(pDecoder);
+ return rc;
+ }
+
+#ifdef __SML_WBXML__
+ if (enc == SML_WBXML)
+ {
+ rc = xltDecWbxmlInit(pBufEnd, ppBufPos, &pDecoder->scanner);
+ if (rc == SML_ERR_OK)
+ {
+ pDecoder->charset = pDecoder->scanner->charset;
+ pDecoder->charsetStr = NULL;
+ }
+ } else
+#endif
+
+#ifdef __SML_XML__
+ if (enc == SML_XML)
+ {
+
+ rc = xltDecXmlInit(pBufEnd, ppBufPos, &pDecoder->scanner);
+ if (rc == SML_ERR_OK)
+ {
+ pDecoder->charset = 0;
+ pDecoder->charsetStr = pDecoder->scanner->charsetStr;
+ }
+ } else
+#endif
+
+ {
+ rc = SML_ERR_XLT_ENC_UNK;
+ }
+
+ if (rc != SML_ERR_OK)
+ {
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return rc;
+ }
+
+ /* try to find SyncHdr element, first comes the SyncML tag... */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return rc;
+ }
+ if (!IS_START(pDecoder->scanner->curtok) ||
+ (pDecoder->scanner->curtok->tagid != TN_SYNCML)) {
+ smlFreePcdata(pDecoder->scanner->curtok->pcdata);
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ /* ... then the SyncHdr */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return rc;
+ }
+ if ((rc = buildSyncHdr(pDecoder, (VoidPtr_t)ppSyncHdr)) != SML_ERR_OK) {
+ xltDecTerminate((XltDecoderPtr_t)pDecoder);
+ return rc;
+ }
+
+ *ppBufPos = pDecoder->scanner->getPos(pDecoder->scanner);
+
+#ifdef __DM_TND__
+ pDecoder->smlEncoding = enc;
+ pDecoder->tndsEncoding = pDecoder->smlEncoding;
+#endif
+ *ppDecoder = (XltDecoderPtr_t)pDecoder;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * Description see XLTDec.h header file.
+ */
+Ret_t
+xltDecNext(XltDecoderPtr_t pDecoder,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ SmlProtoElement_t *pe,
+ VoidPtr_t *ppContent)
+{
+ XltDecoderPtr_t pDecPriv = (XltDecoderPtr_t)pDecoder;
+ XltDecScannerPtr_t pScanner = pDecPriv->scanner;
+ XltTagID_t tagid;
+ Ret_t rc;
+ int i;
+
+ pScanner->setBuf(pScanner, *ppBufPos, pBufEnd);
+
+ /* if we are still outside the SyncBody, look for SyncBody start tag */
+ if ((rc = pDecPriv->tagstack->top(pDecPriv->tagstack, &tagid)) != SML_ERR_OK)
+ return rc;
+ if (tagid == TN_SYNCML) {
+ if (((rc = nextToken(pDecPriv)) != SML_ERR_OK)) {
+ return rc;
+ }
+ if (!((IS_START(pScanner->curtok)) &&
+ (pScanner->curtok->tagid == TN_SYNCBODY))) {
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+ }
+ }
+
+ if ((rc = nextToken(pDecPriv)) != SML_ERR_OK)
+ return rc;
+
+ /* if we find a SyncML protocol element build the corresponding
+ data structure */
+ if ((IS_START_OR_EMPTY(pScanner->curtok)) && (pScanner->curtok->tagid != TN_FINAL)) {
+
+ PEBuilderPtr_t pPEs = getPETable();
+ if (pPEs == NULL)
+ {
+ smlLibFree(pPEs);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ i = 0;
+ while (((pPEs+i)->tagid) != TN_UNDEF)
+ {
+ if (((pPEs+i)->tagid) == pScanner->curtok->tagid)
+ {
+ *pe = ((pPEs+i)->type);
+ if ((rc = (pPEs+i)->build(pDecPriv, ppContent)) != SML_ERR_OK)
+ {
+ smlLibFree(pPEs);
+ return rc;
+ }
+ /* T.K. adjust the SML_PE_ for 'generic' structures */
+ if (*pe == SML_PE_GENERIC) {
+ SmlGenericCmdPtr_t g = *ppContent;
+ switch ((int) ((pPEs+i)->tagid)) {
+ case TN_ADD : g->elementType = SML_PE_ADD; break;
+ case TN_COPY : g->elementType = SML_PE_COPY; break;
+ case TN_DELETE : g->elementType = SML_PE_DELETE; break;
+ case TN_REPLACE: g->elementType = SML_PE_REPLACE; break;
+ }
+ }
+ break;
+ }
+ i++;
+ }
+ if (((pPEs+i)->tagid) == TN_UNDEF)
+ {
+ *pe = SML_PE_UNDEF;
+ *ppContent = NULL;
+ smlLibFree(pPEs);
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+ }
+ smlLibFree(pPEs);
+ } else {
+
+ /* found end tag */
+ switch (pScanner->curtok->tagid) {
+ case TN_ATOMIC:
+ *pe = SML_PE_ATOMIC_END;
+ *ppContent = NULL;
+ break;
+ case TN_SEQUENCE:
+ *pe = SML_PE_SEQUENCE_END;
+ *ppContent = NULL;
+ break;
+ case TN_SYNC:
+ *pe = SML_PE_SYNC_END;
+ *ppContent = NULL;
+ break;
+ case TN_FINAL:
+ *pe = SML_PE_FINAL;
+ *ppContent = NULL;
+ pDecPriv->final = 1;
+ break;
+ case TN_SYNCBODY:
+ /* next comes the SyncML end tag, then we're done */
+ if ((rc = nextToken(pDecPriv)) != SML_ERR_OK)
+ return rc;
+ if ((pScanner->curtok->type == TOK_TAG_END) &&
+ (pScanner->curtok->tagid == TN_SYNCML)) {
+ *pe = SML_PE_UNDEF;
+ *ppContent = NULL;
+ pDecPriv->finished = 1;
+ } else {
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ break;
+ default:
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+ }
+ }
+
+ *ppBufPos = pScanner->getPos(pScanner);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * Description see XLTDec.h header file.
+ */
+Ret_t
+xltDecTerminate(XltDecoderPtr_t pDecoder)
+{
+ XltDecoderPtr_t pDecPriv;
+
+ if (pDecoder == NULL)
+ return SML_ERR_OK;
+
+ pDecPriv = (XltDecoderPtr_t)pDecoder;
+ if (pDecPriv->scanner != NULL)
+ pDecPriv->scanner->destroy(pDecPriv->scanner);
+ if (pDecPriv->tagstack != NULL)
+ pDecPriv->tagstack->destroy(pDecPriv->tagstack);
+ smlLibFree(pDecPriv);
+
+ return SML_ERR_OK;
+}
+
+
+Ret_t xltDecReset(XltDecoderPtr_t pDecoder)
+{
+ return xltDecTerminate(pDecoder);
+}
+
+/**
+ * Gets the next token from the scanner.
+ * Checks if the current tag is an end tag and if so, whether the last
+ * open start tag has the same tag id as the current end tag. An open start
+ * tag is one which matching end tag has not been seen yet.
+ * If the current tag is a start tag its tag ID will be pushed onto the
+ * tag stack.
+ * If the current tag is an empty tag or not a tag at all nothing will be
+ * done.
+ */
+Ret_t
+nextToken(XltDecoderPtr_t pDecoder)
+{
+ XltUtilStackPtr_t pTagStack;
+ XltDecTokenPtr_t pToken;
+ Ret_t rc;
+
+#ifdef __USE_DMTND__
+ // TODO
+ if ( pDecoder->smlEncoding != pDecoder->tndsEncoding )
+ {
+ KCDBG("pDecoder->smlEncoding != pDecoder->tndsEncoding\n");
+ return SML_ERR_OK;
+ }
+#endif
+
+ if ((rc = pDecoder->scanner->nextTok(pDecoder->scanner)) != SML_ERR_OK)
+ return rc;
+
+ pToken = pDecoder->scanner->curtok;
+ pTagStack = pDecoder->tagstack;
+
+ if (IS_START(pToken)) {
+ if (pTagStack->push(pTagStack, pToken->tagid))
+ return SML_ERR_UNSPECIFIC;
+ } else if (IS_END(pToken)) {
+ XltTagID_t lastopen;
+ if (pTagStack->pop(pTagStack, &lastopen))
+ return SML_ERR_UNSPECIFIC;
+ if (pToken->tagid != lastopen)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ return SML_ERR_OK;
+}
+
+Ret_t discardToken(XltDecoderPtr_t pDecoder)
+
+{
+ Ret_t rc;
+ XltTagID_t tmp;
+ if ((rc = pDecoder->scanner->pushTok(pDecoder->scanner)) != SML_ERR_OK)
+ return rc;
+ if ((rc = pDecoder->tagstack->pop(pDecoder->tagstack, &tmp)) != SML_ERR_OK)
+ return rc;
+ return SML_ERR_OK;
+}
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+static SmlPcdataPtr_t
+concatPCData(SmlPcdataPtr_t pDat1, const SmlPcdataPtr_t pDat2)
+{
+ if (pDat1->contentType != pDat2->contentType)
+ return NULL;
+
+ switch (pDat1->contentType) {
+ case SML_PCDATA_STRING:
+ pDat1->content = (VoidPtr_t)smlLibStrcat(pDat1->content, pDat2->content);
+ pDat1->length += pDat2->length;
+ break;
+ case SML_PCDATA_OPAQUE:
+ if ((pDat1->content = smlLibRealloc(pDat1->content, pDat1->length + pDat2->length)) == NULL)
+ return NULL;
+ smlLibMemmove(((Byte_t*)pDat1->content) + pDat1->length, pDat2->content, pDat2->length);
+ pDat1->length += pDat2->length;
+ break;
+ default:
+ return NULL;
+ }
+ return pDat1;
+}
+
+Ret_t
+buildSyncHdr(XltDecoderPtr_t pDecoder, VoidPtr_t *ppSyncHdr)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlSyncHdrPtr_t pSyncHdr;
+ Ret_t rc;
+ Long_t sessionid = 0, msgid = 0, source = 0, target = 0, version = 0, proto = 0;
+
+ /* shortcut to the scanner object */
+ pScanner = pDecoder->scanner;
+
+ /* if ppSyncHdr is not NULL we've already
+ found a SyncHdr before! */
+ if (*ppSyncHdr != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ /* initialize new SmlSyncHdr */
+ if ((pSyncHdr = (SmlSyncHdrPtr_t)smlLibMalloc(sizeof(SmlSyncHdr_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pSyncHdr, 0, sizeof(SmlSyncHdr_t));
+
+ /* initialize the element type field */
+ pSyncHdr->elementType = SML_PE_HEADER;
+
+ /* empty SmlSyncHdr is possible */
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppSyncHdr = pSyncHdr;
+ return SML_ERR_OK;
+ }
+
+ /* get next Token */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pSyncHdr);
+ return rc;
+ }
+
+ /* parse child elements until we find a matching end tag */
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_VERSION:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->version);
+ version++;
+ break;
+ case TN_PROTO:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->proto);
+ proto++;
+ break;
+ case TN_SESSIONID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->sessionID);
+ sessionid++;
+ break;
+ case TN_MSGID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->msgID);
+ msgid++;
+ break;
+ case TN_RESPURI:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->respURI);
+ break;
+
+ /* child tags */
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSyncHdr->target);
+ target++;
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSyncHdr->source);
+ source++;
+ break;
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pSyncHdr->cred);
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSyncHdr->meta);
+ break;
+
+ /* flags (empty tags) */
+ case TN_NORESP:
+ pSyncHdr->flags |= SmlNoResp_f;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ /* decoding of child element went ok? */
+ if (rc != SML_ERR_OK) {
+ smlFreeSyncHdr(pSyncHdr);
+
+ return rc;
+ }
+
+ /* get next token */
+ if ((rc = nextToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeSyncHdr(pSyncHdr);
+ return rc;
+ }
+ }
+
+ if ((sessionid == 0) || (msgid == 0) || (target == 0) || (source == 0) || (version == 0) || (proto == 0))
+ {
+ smlFreeSyncHdr(pSyncHdr);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppSyncHdr = pSyncHdr;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildSync(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlSyncPtr_t pSync;
+ Ret_t rc;
+ Long_t cmdid = 0;
+
+ /* stop decoding the Sync when we find a SyncML command */
+ Byte_t break_sync = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ /* initialize a new Sync */
+ if ((pSync = (SmlSyncPtr_t)smlLibMalloc(sizeof(SmlSync_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pSync, 0, sizeof(SmlSync_t));
+
+ /* initialize the element type field */
+ pSync->elementType = SML_PE_SYNC_START;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+
+ smlLibFree(pSync);
+ return SML_ERR_OK;
+ }
+
+ /* get next token */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pSync);
+ return rc;
+ }
+
+ /* parse child elements until we find a matching end tag
+ or until we find a TN_ADD, TN_ATOMIC, etc. start tag */
+ while ((pScanner->curtok->type != TOK_TAG_END) && !break_sync) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSync->cmdID);
+ cmdid++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSync->meta);
+ break;
+ case TN_NUMBEROFCHANGES:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSync->noc);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pSync->cred);
+ break;
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSync->target);
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSync->source);
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pSync->flags |= SmlNoResp_f;
+ break;
+
+ /* quit if we find an Add, Atomic, etc.
+ element */
+ case TN_ADD:
+ case TN_ATOMIC:
+ case TN_COPY:
+ case TN_DELETE:
+ case TN_SEQUENCE:
+ case TN_REPLACE:
+ break_sync = 1;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeSync(pSync);
+ return rc;
+ }
+ if (!break_sync) {
+ /* get next token and continue as usual */
+ if ((rc = nextToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeSync(pSync);
+ return rc;
+ }
+ } else {
+ /* we've found a SyncML command - we need to go
+ back one token and correct the tagstack */
+ if ((rc = discardToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeSync(pSync);
+ return rc;
+ }
+ }
+ }
+
+ if (!break_sync) {
+ if ((pScanner->curtok->tagid) != TN_SYNC)
+ {
+ smlFreeSync(pSync);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ else
+ {
+ if (pDecoder->tagstack->push(pDecoder->tagstack, pScanner->curtok->tagid))
+ {
+ smlFreeSync(pSync);
+ return SML_ERR_UNSPECIFIC;
+ }
+ if ((rc = pDecoder->scanner->pushTok(pDecoder->scanner)) != SML_ERR_OK)
+ {
+ smlFreeSync(pSync);
+ return rc;
+ }
+ }
+ }
+
+ *ppElem = pSync;
+
+ return SML_ERR_OK;
+}
+
+#if (defined ATOMIC_RECEIVE || defined SEQUENCE_RECEIVE)
+Ret_t
+buildAtomOrSeq(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlAtomicPtr_t pAoS; /* SmlAtomicPtr_t and SequencePtr_t are pointer
+ to the same structure! */
+ Ret_t rc;
+ Byte_t break_aos = 0; /* stop decoding the Atomic when we find a
+ SyncML command */
+ Long_t cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pAoS = (SmlAtomicPtr_t)smlLibMalloc(sizeof(SmlAtomic_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pAoS, 0, sizeof(SmlAtomic_t));
+
+ /* initialize the element type field */
+ pAoS->elementType = SML_PE_CMD_GROUP;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pAoS);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ /* get next token */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree (pAoS);
+ return rc;
+ }
+
+ /* parse child elements until we find a matching end tag
+ or until we find a TN_ADD, TN_ATOMIC, etc. start tag */
+ while ((pScanner->curtok->type != TOK_TAG_END) && !break_aos) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAoS->cmdID);
+ cmdid++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAoS->meta);
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pAoS->flags |= SmlNoResp_f;
+ break;
+
+ /* quit if we find an Add, Atomic, etc.
+ element */
+ case TN_ADD:
+ case TN_REPLACE:
+ case TN_DELETE:
+ case TN_COPY:
+ case TN_ATOMIC:
+ case TN_MAP:
+ case TN_SYNC:
+ case TN_GET:
+ case TN_ALERT:
+ case TN_EXEC:
+ break_aos = 1;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeAtomic(pAoS);
+ return rc;
+ }
+ if (!break_aos) {
+ if ((rc = nextToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeAtomic(pAoS);
+ return rc;
+ }
+ } else {
+ /* we've found a SyncML command - we need to go
+ back one token and correct the tagstack */
+ if ((rc = discardToken(pDecoder)) != SML_ERR_OK) {
+ smlFreeAtomic(pAoS);
+ return rc;
+ }
+ }
+ }
+
+ if (!break_aos) {
+ /* Atomic/Sequence must contain at least one SyncML command */
+ smlFreeAtomic(pAoS);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (cmdid == 0)
+ {
+ smlFreeAtomic(pAoS);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pAoS;
+
+ return SML_ERR_OK;
+}
+#endif
+
+#ifdef EXEC_RECEIVE
+Ret_t
+buildExec(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlExecPtr_t pExec;
+ Ret_t rc;
+ Long_t items = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pExec = (SmlExecPtr_t)smlLibMalloc(sizeof(SmlExec_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pExec, 0, sizeof(SmlExec_t));
+
+ /* initialize the element type field */
+ pExec->elementType = SML_PE_EXEC;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pExec);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pExec);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCData */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pExec->cmdID);
+ cmdid++;
+ break;
+
+ case TN_CORRELATOR:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pExec->correlator);
+ break;
+
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pExec->meta);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pExec->cred);
+ break;
+
+ case TN_ITEM:
+ rc = buildItem(pDecoder, (VoidPtr_t)&pExec->item);
+ items++;
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pExec->flags |= SmlNoResp_f;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeExec(pExec);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeExec(pExec);
+ return rc;
+ }
+ }
+
+ if ((items == 0) || (cmdid == 0)) {
+ smlFreeExec(pExec);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pExec;
+
+ return SML_ERR_OK;
+}
+#endif
+
+Ret_t
+buildGenericCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlGenericCmdPtr_t pGenCmd;
+ Ret_t rc;
+ Long_t items = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ /* initialize a new GenericCmd */
+ if ((pGenCmd = (SmlGenericCmdPtr_t)smlLibMalloc(sizeof(SmlGenericCmd_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pGenCmd, 0, sizeof(SmlGenericCmd_t));
+
+ /* initialize the element type field */
+ pGenCmd->elementType = SML_PE_GENERIC;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pGenCmd);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pGenCmd);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGenCmd->cmdID);
+ cmdid++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGenCmd->meta);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pGenCmd->cred);
+ break;
+
+ /* flags (empty tags) */
+ case TN_NORESP:
+ pGenCmd->flags |= SmlNoResp_f;
+ break;
+ case TN_ARCHIVE:
+ pGenCmd->flags |= SmlArchive_f;
+ break;
+ case TN_SFTDEL:
+ pGenCmd->flags |= SmlSftDel_f;
+ break;
+
+ /* Lists */
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, &pGenCmd->itemList);
+ items++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeGeneric(pGenCmd);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeGeneric(pGenCmd);
+ return rc;
+ }
+ }
+
+ if ((items == 0) || (cmdid == 0))
+ {
+ smlFreeGeneric(pGenCmd);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pGenCmd;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildAlert(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlAlertPtr_t pAlert;
+ Ret_t rc;
+ Long_t cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pAlert = (SmlAlertPtr_t)smlLibMalloc(sizeof(SmlAlert_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pAlert, 0, sizeof(SmlAlert_t));
+
+ /* initialize the element type field */
+ pAlert->elementType = SML_PE_ALERT;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pAlert);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pAlert);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAlert->cmdID);
+ cmdid++;
+ break;
+
+ case TN_CORRELATOR:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAlert->correlator);
+ break;
+
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAlert->data);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pAlert->cred);
+ break;
+
+ /* flags (empty tags) */
+ case TN_NORESP:
+ pAlert->flags |= SmlNoResp_f;
+ break;
+
+ /* Lists */
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, &pAlert->itemList);
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeAlert(pAlert);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeAlert(pAlert);
+ return rc;
+ }
+ }
+
+ if (cmdid == 0)
+ {
+ smlFreeAlert(pAlert);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pAlert;
+
+ return SML_ERR_OK;
+}
+
+#ifdef MAP_RECEIVE
+Ret_t
+buildMap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlMapPtr_t pMap;
+ Ret_t rc;
+ Long_t target = 0, source = 0, mapitems = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pMap = (SmlMapPtr_t)smlLibMalloc(sizeof(SmlMap_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pMap, 0, sizeof(SmlMap_t));
+
+ /* initialize the element type field */
+ pMap->elementType = SML_PE_MAP;
+
+ /* Source is required */
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pMap);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pMap);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMap->cmdID);
+ cmdid++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMap->meta);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pMap->cred);
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pMap->source);
+ source++;
+ break;
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pMap->target);
+ target++;
+ break;
+#ifdef MAPITEM_RECEIVE
+ /* Lists */
+ case TN_MAPITEM:
+ rc = appendMapItemList(pDecoder, &pMap->mapItemList);
+ mapitems++;
+ break;
+#endif
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMap(pMap);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMap(pMap);
+ return rc;
+ }
+ }
+
+ if ((source == 0) || (mapitems == 0) || (target == 0) || (cmdid == 0)) {
+ smlFreeMap(pMap);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pMap;
+
+ return SML_ERR_OK;
+}
+#endif
+
+#ifdef SEARCH_RECEIVE
+Ret_t
+buildSearch(XltDecoderPtr_t pDecoder, VoidPtr_t *ppSearch)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlSearchPtr_t pSearch;
+ Ret_t rc;
+ Long_t source = 0, meta = 0, data = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppSearch != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pSearch = (SmlSearchPtr_t)smlLibMalloc(sizeof(SmlSearch_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pSearch, 0, sizeof(SmlSearch_t));
+
+ /* initialize the element type field */
+ pSearch->elementType = SML_PE_SEARCH;
+
+ /* Meta is required */
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pSearch);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pSearch);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSearch->cmdID);
+ cmdid++;
+ break;
+ case TN_LANG:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSearch->lang);
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSearch->meta);
+ meta++;
+ break;
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pSearch->data);
+ data++;
+ break;
+
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pSearch->cred);
+ break;
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pSearch->target);
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pSearch->flags |= SmlNoResp_f;
+ break;
+ case TN_NORESULTS:
+ pSearch->flags |= SmlNoResults_f;
+ break;
+
+ /* Lists */
+ case TN_SOURCE:
+ rc = appendSourceList(pDecoder, &pSearch->sourceList);
+ source++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeSearch(pSearch);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeSearch(pSearch);
+ return rc;
+ }
+ }
+
+ if ((source == 0) || (meta == 0) || (data == 0) || (cmdid == 0)) {
+ smlFreeSearch(pSearch);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppSearch = pSearch;
+
+ return SML_ERR_OK;
+}
+#endif
+
+Ret_t
+buildPutOrGet(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlGetPtr_t pGet;
+ Ret_t rc;
+ Long_t items = 0, cmdid = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pGet = (SmlGetPtr_t)smlLibMalloc(sizeof(SmlGet_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pGet, 0, sizeof(SmlGet_t));
+
+ /* initialize the element type field */
+ pGet->elementType = SML_PE_PUT_GET;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pGet);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pGet);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGet->cmdID);
+ cmdid++;
+ break;
+ case TN_LANG:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGet->lang);
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pGet->meta);
+ break;
+
+ /* child tags */
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pGet->cred);
+ break;
+
+ /* flags */
+ case TN_NORESP:
+ pGet->flags |= SmlNoResp_f;
+ break;
+
+ /* Lists */
+
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, &pGet->itemList);
+ items++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeGetPut(pGet);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeGetPut(pGet);
+ return rc;
+ }
+ }
+
+ if ((items == 0) || (cmdid == 0))
+ {
+ smlFreeGetPut(pGet);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pGet;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildTargetOrSource(XltDecoderPtr_t pDecoder, VoidPtr_t *ppTarget)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlTargetPtr_t pTarget;
+ Long_t locuri = 0;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppTarget != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pTarget = (SmlTargetPtr_t)smlLibMalloc(sizeof(SmlTarget_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pTarget, 0, sizeof(SmlTarget_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pTarget);
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pTarget);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_LOCURI:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pTarget->locURI);
+ locuri++;
+ break;
+ case TN_LOCNAME:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pTarget->locName);
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ if(pScanner->curtok->pcdata != NULL)
+ smlLibFree(pScanner->curtok->pcdata->content);
+ smlLibFree(pScanner->curtok->pcdata);
+ smlFreeSourceTargetPtr(pTarget);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeSourceTargetPtr(pTarget);
+ return rc;
+ }
+ }
+
+ if (locuri == 0)
+ {
+ smlFreeSourceTargetPtr(pTarget);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppTarget = pTarget;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildChal(XltDecoderPtr_t pDecoder, VoidPtr_t *ppChal)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlChalPtr_t pChal;
+ Long_t meta = 0;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppChal != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pChal = (SmlChalPtr_t)smlLibMalloc(sizeof(SmlChal_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pChal, 0, sizeof(SmlChal_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppChal = pChal;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pChal);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pChal->meta);
+ meta++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeChalPtr(pChal);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeChalPtr(pChal);
+ return rc;
+ }
+ }
+
+ if (meta == 0)
+ {
+ smlFreeChalPtr(pChal);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppChal = pChal;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildCred(XltDecoderPtr_t pDecoder, VoidPtr_t *ppCred)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlCredPtr_t pCred;
+ Ret_t rc;
+ Long_t data = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppCred != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pCred = (SmlCredPtr_t)smlLibMalloc(sizeof(SmlCred_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pCred, 0, sizeof(SmlCred_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppCred = pCred;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pCred);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pCred->data);
+ data++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pCred->meta);
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeCredPtr(pCred);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeCredPtr(pCred);
+ return rc;
+ }
+ }
+
+ if (data == 0)
+ {
+ smlFreeCredPtr(pCred);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppCred = pCred;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildItem(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlItemPtr_t pItem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pItem = (SmlItemPtr_t)smlLibMalloc(sizeof(SmlItem_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pItem, 0, sizeof(SmlItem_t));
+
+ /* Item might be empty */
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pItem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pItem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pItem->meta);
+ break;
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pItem->data);
+#ifdef __USE_EXTENSIONS__
+#ifdef __SML_WBXML__
+ if (pItem->data && pItem->data->contentType == SML_PCDATA_OPAQUE)
+ subdtdDecodeWbxml(pDecoder, (SmlPcdataPtr_t*)&pItem->data);
+#endif
+#endif
+ break;
+ /* child tags */
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pItem->target);
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pItem->source);
+ break;
+
+ /* flags */
+ case TN_MOREDATA:
+ pItem->flags |= SmlMoreData_f;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeItemPtr(pItem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeItemPtr(pItem);
+ return rc;
+ }
+ }
+
+ *ppElem = pItem;
+
+ return SML_ERR_OK;
+}
+
+#ifdef MAPITEM_RECEIVE
+Ret_t
+buildMapItem(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlMapItemPtr_t pMapItem;
+ Long_t target = 0, source = 0;
+ Ret_t rc;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ pScanner = pDecoder->scanner;
+
+ if ((pMapItem = (SmlMapItemPtr_t)smlLibMalloc(sizeof(SmlMapItem_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pMapItem, 0, sizeof(SmlMapItem_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pMapItem);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pMapItem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* child tags */
+ case TN_TARGET:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pMapItem->target);
+ target++;
+ break;
+ case TN_SOURCE:
+ rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pMapItem->source);
+ source++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMapItemPtr(pMapItem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMapItemPtr(pMapItem);
+ return rc;
+ }
+ }
+
+ if ((target == 0) || (source == 0)) {
+ smlFreeMapItemPtr(pMapItem);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pMapItem;
+
+ return SML_ERR_OK;
+}
+
+#endif
+
+Ret_t
+buildStatus(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlStatusPtr_t pStatus;
+ Ret_t rc;
+ Long_t cmd = 0, data = 0, cmdid = 0;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ pScanner = pDecoder->scanner;
+
+ if ((pStatus = (SmlStatusPtr_t)smlLibMalloc(sizeof(SmlStatus_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pStatus, 0, sizeof(SmlStatus_t));
+
+ /* initialize the element type field */
+ pStatus->elementType = SML_PE_STATUS;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pStatus);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pStatus);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCData elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->cmdID);
+ cmdid++;
+ break;
+ case TN_MSGREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->msgRef);
+ break;
+ case TN_CMDREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->cmdRef);
+ break;
+ case TN_CMD:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->cmd);
+ cmd++;
+ break;
+ case TN_DATA:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pStatus->data);
+ data++;
+ break;
+ case TN_CHAL:
+ rc = buildChal(pDecoder, (VoidPtr_t)&pStatus->chal);
+ break;
+ case TN_CRED:
+ rc = buildCred(pDecoder, (VoidPtr_t)&pStatus->cred);
+ break;
+
+ /* Lists */
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, (VoidPtr_t)&pStatus->itemList);
+ break;
+ case TN_TARGETREF:
+ rc = appendTargetRefList(pDecoder, (VoidPtr_t)&pStatus->targetRefList);
+ break;
+ case TN_SOURCEREF:
+ rc = appendSourceRefList(pDecoder, (VoidPtr_t)&pStatus->sourceRefList);
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeStatus(pStatus);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeStatus(pStatus);
+ return rc;
+ }
+ }
+
+ if ((cmd == 0) || (data == 0) || (cmdid == 0))
+ {
+ smlFreeStatus(pStatus);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppElem = pStatus;
+
+ return SML_ERR_OK;
+}
+
+#ifdef RESULT_RECEIVE
+Ret_t
+buildResults(XltDecoderPtr_t pDecoder, VoidPtr_t *ppResults)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlResultsPtr_t pResults;
+ Ret_t rc;
+ Long_t cmdref = 0, items = 0, cmdid = 0;
+
+ if (*ppResults != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ pScanner = pDecoder->scanner;
+
+ if ((pResults = (SmlResultsPtr_t)smlLibMalloc(sizeof(SmlResults_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pResults, 0, sizeof(SmlResults_t));
+
+ /* initialize the element type field */
+ pResults->elementType = SML_PE_RESULTS;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ smlLibFree(pResults);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pResults);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+
+ /* PCDATA elements */
+ case TN_CMDID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->cmdID);
+ cmdid++;
+ break;
+ case TN_MSGREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->msgRef);
+ break;
+ case TN_CMDREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->cmdRef);
+ cmdref++;
+ break;
+ case TN_META:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->meta);
+ break;
+ case TN_TARGETREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->targetRef);
+ break;
+ case TN_SOURCEREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pResults->sourceRef);
+ break;
+
+ /* Lists */
+ case TN_ITEM:
+ rc = appendItemList(pDecoder, &pResults->itemList);
+ items++;
+ break;
+
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeResults(pResults);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeResults(pResults);
+ return rc;
+ }
+ }
+
+ if ((cmdref == 0) || (items == 0) || (cmdid == 0))
+ {
+ smlFreeResults(pResults);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ *ppResults = pResults;
+
+ return SML_ERR_OK;
+}
+
+#endif
+
+Ret_t
+buildPCData(XltDecoderPtr_t pDecoder, VoidPtr_t *ppPCData)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlPcdataPtr_t pPCData = 0;
+ SmlPcdataExtension_t ext;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppPCData != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ if ((pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+
+ smlLibMemset(pPCData, 0, sizeof(SmlPcdata_t));
+
+ *ppPCData = pPCData;
+ return SML_ERR_OK;
+ }
+
+ pPCData = NULL;
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ if (rc == SML_ERR_XLT_INVAL_SYNCML_DOC) { /* leaks if dtd failed */
+ pPCData = pScanner->curtok->pcdata;
+ *ppPCData = pPCData;
+ }
+
+ return rc;
+ }
+
+ if (IS_CONTENT(pScanner->curtok)) {
+ /* PCData element has a regular string or opaque content */
+ while (pScanner->curtok->type == TOK_CONT) {
+ if (pPCData == NULL)
+ pPCData = pScanner->curtok->pcdata;
+ else {
+ pPCData = concatPCData(pPCData, pScanner->curtok->pcdata);
+ smlLibFree(pScanner->curtok->pcdata->content);
+ smlLibFree(pScanner->curtok->pcdata);
+
+ if (pPCData == NULL)
+ return SML_ERR_XLT_INVAL_PCDATA;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ *ppPCData = pPCData;
+ return rc;
+ }
+ }
+ } else if (IS_START_OR_EMPTY(pScanner->curtok)) {
+ /* PCData element contains an XML dokument that is handled by an
+ extension mechanism */
+ ext = pScanner->curtok->ext;
+ if ((rc = discardToken(pDecoder)) != SML_ERR_OK) return rc;
+ if ((pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pPCData, 0, sizeof(SmlPcdata_t));
+ pPCData->contentType = SML_PCDATA_EXTENSION;
+ pPCData->extension = ext;
+ switch (ext) {
+#ifdef __USE_METINF__
+ case SML_EXT_METINF:
+
+ if ((rc = buildMetInfMetInfCmd(pDecoder, (VoidPtr_t)&pPCData->content)) != SML_ERR_OK) {
+ smlLibFree(pPCData);
+ return rc;
+ }
+ break;
+#endif
+#ifdef __USE_DEVINF__
+ case SML_EXT_DEVINF:
+
+ if ((rc = buildDevInfDevInfCmd(pDecoder, (VoidPtr_t)&pPCData->content)) != SML_ERR_OK) {
+
+ smlLibFree(pPCData);
+ return rc;
+ }
+
+ /* the scanner must point to the closing PCDATA tag */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pPCData);
+ return rc;
+ }
+ break;
+#endif
+#ifdef __USE_DMTND__
+ case SML_EXT_DMTND:
+
+ if ((rc = buildDmTndCmd(pDecoder, (VoidPtr_t)&pPCData->content)) != SML_ERR_OK) {
+
+ smlLibFree(pPCData);
+ return rc;
+ }
+
+ /* the scanner must point to the closing PCDATA tag */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pPCData);
+ return rc;
+ }
+ break;
+#endif
+ default:
+ smlFreePcdata(pPCData);
+ return SML_ERR_XLT_INVAL_EXT;
+ }
+
+ } else if (IS_END(pScanner->curtok)) {
+ /* PCData element is empty */
+ } else {
+ return SML_ERR_XLT_INVAL_PCDATA;
+ }
+
+
+ if (pScanner->curtok->type != TOK_TAG_END){
+ smlFreePcdata(pPCData);
+ return SML_ERR_XLT_INVAL_PCDATA;
+ }
+
+ if (pPCData == NULL) {
+ if ((pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pPCData, 0, sizeof(SmlPcdata_t));
+ }
+
+ *ppPCData = pPCData;
+
+ return SML_ERR_OK;
+}
+
+Ret_t
+buildPCDataList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppPCData)
+{
+ SmlPcdataListPtr_t pPCDataList = NULL, pPrev = NULL;
+
+ pPCDataList = (SmlPcdataListPtr_t) *ppPCData;
+
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pPCDataList != NULL) {
+ pPrev = pPCDataList;
+ pPCDataList = pPrev->next;
+ }
+ if ((pPCDataList = (SmlPcdataListPtr_t)smlLibMalloc(sizeof(SmlPcdataList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pPCDataList, 0, sizeof(SmlPcdataList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pPCDataList;
+ else /* nope we created a new list */
+ *ppPCData = pPCDataList;
+ pPCDataList->data = NULL;
+ /* at this point pPCDataList should point to an valid list element */
+ return buildPCData(pDecoder, (VoidPtr_t)&pPCDataList->data);
+}
+
+
+static Ret_t
+appendItemList(XltDecoderPtr_t pDecoder, SmlItemListPtr_t *ppItemList)
+{
+ SmlItemListPtr_t pNewItemList;
+ SmlItemListPtr_t pItemList;
+ Ret_t rc;
+
+ pItemList = *ppItemList;
+ if (pItemList != NULL)
+ while (pItemList->next != NULL)
+ pItemList = pItemList->next;
+
+ if ((pNewItemList = (SmlItemListPtr_t)smlLibMalloc(sizeof(SmlItemList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewItemList, 0, sizeof(SmlItemList_t));
+
+ if ((rc = buildItem(pDecoder, (VoidPtr_t)&pNewItemList->item)) != SML_ERR_OK) {
+ smlLibFree(pNewItemList);
+ return rc;
+ }
+
+ if (pItemList == NULL)
+ *ppItemList = pNewItemList;
+ else
+ pItemList->next = pNewItemList;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+appendSourceList(XltDecoderPtr_t pDecoder, SmlSourceListPtr_t *ppSourceList)
+{
+ SmlSourceListPtr_t pNewSourceList;
+ SmlSourceListPtr_t pSourceList;
+ Ret_t rc;
+
+ pSourceList = *ppSourceList;
+ if (pSourceList != NULL)
+ while (pSourceList->next != NULL)
+ pSourceList = pSourceList->next;
+
+ if ((pNewSourceList = (SmlSourceListPtr_t)smlLibMalloc(sizeof(SmlSourceList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewSourceList, 0, sizeof(SmlSourceList_t));
+
+ if ((rc = buildTargetOrSource(pDecoder, (VoidPtr_t)&pNewSourceList->source)) != SML_ERR_OK) {
+ smlLibFree(pNewSourceList);
+ return rc;
+ }
+
+ if (pSourceList == NULL)
+ *ppSourceList = pNewSourceList;
+ else
+ pSourceList->next = pNewSourceList;
+
+ return SML_ERR_OK;
+}
+
+#ifdef MAPITEM_RECEIVE
+
+static Ret_t
+appendMapItemList(XltDecoderPtr_t pDecoder, SmlMapItemListPtr_t *ppMapItemList)
+{
+ SmlMapItemListPtr_t pNewMapItemList;
+ SmlMapItemListPtr_t pMapItemList;
+ Ret_t rc;
+
+ pMapItemList = *ppMapItemList;
+ if (pMapItemList != NULL)
+ while (pMapItemList->next != NULL)
+ pMapItemList = pMapItemList->next;
+
+ if ((pNewMapItemList = (SmlMapItemListPtr_t)smlLibMalloc(sizeof(SmlMapItemList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewMapItemList, 0, sizeof(SmlMapItemList_t));
+
+ if ((rc = buildMapItem(pDecoder, (VoidPtr_t)&pNewMapItemList->mapItem)) != SML_ERR_OK) {
+ smlLibFree(pNewMapItemList);
+ return rc;
+ }
+
+ if (pMapItemList == NULL)
+ *ppMapItemList = pNewMapItemList;
+ else
+ pMapItemList->next = pNewMapItemList;
+
+ return SML_ERR_OK;
+}
+#endif
+
+static Ret_t
+appendTargetRefList(XltDecoderPtr_t pDecoder, SmlTargetRefListPtr_t *ppTargetRefList)
+{
+ SmlTargetRefListPtr_t pNewTargetRefList;
+ SmlTargetRefListPtr_t pTargetRefList;
+ Ret_t rc;
+
+ pTargetRefList = *ppTargetRefList;
+ if (pTargetRefList != NULL)
+ while (pTargetRefList->next != NULL)
+ pTargetRefList = pTargetRefList->next;
+
+ if ((pNewTargetRefList = (SmlTargetRefListPtr_t)smlLibMalloc(sizeof(SmlTargetRefList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewTargetRefList, 0, sizeof(SmlTargetRefList_t));
+
+ if ((rc = buildPCData(pDecoder, (VoidPtr_t)&pNewTargetRefList->targetRef)) != SML_ERR_OK) {
+ smlFreePcdata(pNewTargetRefList->targetRef);
+ smlLibFree(pNewTargetRefList);
+ return rc;
+ }
+
+ if (pTargetRefList == NULL)
+ *ppTargetRefList = pNewTargetRefList;
+ else
+ pTargetRefList->next = pNewTargetRefList;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+appendSourceRefList(XltDecoderPtr_t pDecoder, SmlSourceRefListPtr_t *ppSourceRefList)
+{
+ SmlSourceRefListPtr_t pNewSourceRefList;
+ SmlSourceRefListPtr_t pSourceRefList;
+ Ret_t rc;
+
+ pSourceRefList = *ppSourceRefList;
+ if (pSourceRefList != NULL)
+ while (pSourceRefList->next != NULL)
+ pSourceRefList = pSourceRefList->next;
+
+ if ((pNewSourceRefList = (SmlSourceRefListPtr_t)smlLibMalloc(sizeof(SmlSourceRefList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pNewSourceRefList, 0, sizeof(SmlSourceRefList_t));
+
+ if ((rc = buildPCData(pDecoder, (VoidPtr_t)&pNewSourceRefList->sourceRef)) != SML_ERR_OK) {
+ smlFreePcdata(pNewSourceRefList->sourceRef);
+ smlLibFree(pNewSourceRefList);
+ return rc;
+ }
+
+ if (pSourceRefList == NULL)
+ *ppSourceRefList = pNewSourceRefList;
+ else
+ pSourceRefList->next = pNewSourceRefList;
+
+ return SML_ERR_OK;
+}
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltdecwbxml.c b/engine/dmlib/dmengine/oma_toolkit/src/xltdecwbxml.c
new file mode 100644
index 0000000..ccce259
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltdecwbxml.c
@@ -0,0 +1,1516 @@
+/*************************************************************************/
+/* module: WBXML decoder */
+/* file: XLTDecWbxml.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * The WBXML scanner/tokenizer. Used by the SyncML parser.
+ */
+
+
+#include <define.h>
+#ifdef __SML_WBXML__
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#include "xltdevinf.h"
+#include "xltdmtnd.h"
+#include "xltdeccom.h"
+#include "xlttags.h"
+#include "xltutilstack.h"
+#include "xltdec.h"
+
+#include <smldtd.h>
+#include <smldevinfdtd.h>
+#include <smlmetinfdtd.h>
+#include <smldmtnddtd.h>
+#include "mgrutil.h"
+
+#include <libmem.h>
+#include <libstr.h>
+
+#include <sml.h>
+#include <smlerr.h>
+#include <mgr.h>
+
+#ifdef IS_END /* to avoid redefinition of this macro */
+#undef IS_END
+#endif
+
+void
+subdtdDecodeWbxml(XltDecoderPtr_t pDecoder,SmlPcdataPtr_t *ppPcdata);
+
+
+/* WBXML version that this parser knows */
+#define _MAJOR_VERSION 1
+#define _MINOR_VERSION 2
+
+#define TAG_STATE 0
+#define ATTRIBUTE_STATE 1
+
+/* various checks about wbxml token */
+#define HAS_ATTRIBUTES(tag) (*tag & 0x80)
+#define HAS_CONTENT(tag) (*tag & 0x40)
+#define IDENTITY(tag) (*tag & 0x3F)
+
+#define IS_SWITCH(tok) (*(tok) == 0x00)
+#define IS_END(tok) (*(tok) == 0x01)
+#define IS_ENTITY(tok) (*(tok) == 0x02)
+#define IS_STR_I(tok) (*(tok) == 0x03)
+#define IS_LITERAL(tok) (IDENTITY(tok) == 0x04)
+// Note: gcc cannot parse multi-line macros when file has DOS line ends
+#define IS_EXT_I(tok) ((*(tok) == 0x40) || (*(tok) == 0x41) || (*(tok) == 0x42))
+#define IS_PI(tok) (*(tok) == 0x43)
+#define IS_EXT_T(tok) ((*(tok) == 0x80) || (*(tok) == 0x81) || (*(tok) == 0x82))
+#define IS_STR_T(tok) (*(tok) == 0x83)
+#define IS_EXT(tok) ((*(tok) == 0xC0) || (*(tok) == 0xC1) || (*(tok) == 0xC2))
+#define IS_OPAQUE(tok) (*(tok) == 0xC3)
+#define IS_STRING(tok) (IS_STR_I(tok) || IS_STR_T(tok))
+#define IS_EXTENSION(tok) (IS_EXT_I(tok) || IS_EXT_T(tok) || IS_EXT(tok))
+
+#define IS_ATTRIBUTE_VALUE(tok) (*(tok) & 0x80)
+#define IS_ATTRIBUTE_START(tok) (~IS_ATTRIBUTE_VALUE(tok))
+
+
+/**
+ * Private Interface for the WBXML scanner.
+ *
+ * The private scanner interface contains some additional member attributes
+ * that are not listed in the public interface, e.g. a copy of the string
+ * table and some other items that do not need to be known outside the
+ * scanner module.
+ */
+typedef struct wbxmlScannerPriv_s wbxmlScannerPriv_t, *wbxmlScannerPrivPtr_t;
+struct wbxmlScannerPriv_s
+{
+ /* public methods */
+ Ret_t (*nextTok)(XltDecScannerPtr_t);
+ Ret_t (*destroy)(XltDecScannerPtr_t);
+ Ret_t (*pushTok)(XltDecScannerPtr_t);
+ void (*setBuf)(XltDecScannerPtr_t pScanner, const MemPtr_t pBufStart, const MemPtr_t pBufEnd);
+ MemPtr_t (*getPos)(XltDecScannerPtr_t pScanner);
+
+ /* public attributes */
+ XltDecTokenPtr_t curtok; /* current token */
+ Long_t charset; /* character set as specified in the
+ WBXML header */
+ String_t charsetStr; /* NULL */
+ Long_t pubID; /* document public identifier as
+ specified in the WBXML header */
+ String_t pubIDStr; /* pubID as a string - valid only when
+ pubID == 0 */
+ Flag_t finished; /* set when end of buffer is reached */
+
+ /* private attributes */
+ MemPtr_t pos; /* current buffer position */
+ MemPtr_t bufend; /* end of buffer */
+ Long_t pubIDIdx; /* strtbl index of the string
+ version of the pubID - valid only
+ when pubID == 0 */
+
+ XltUtilStackPtr_t tagstack; /* stack of open start tags */
+
+ MemPtr_t strtbl; /* copy of the string table */
+ Long_t strtbllen; /* length of the string table */
+
+ Byte_t state; /* tag state or attribute state */
+ SmlPcdataExtension_t cptag; /* current codepage for tags */
+ Byte_t cpattr; /* current codepage for attributes */
+ SmlPcdataExtension_t activeExt; /* the active Sub DTD */
+};
+
+/* typedef for multi-byte unsigned integers as specified in the
+ WAP Binary XML Content Format specification */
+typedef Long_t MBINT;
+
+/**
+ * Public methods of the scanner interface.
+ *
+ * Description see XLTDecCom.h.
+ */
+static Ret_t _destroy(XltDecScannerPtr_t);
+static Ret_t _nextTok(XltDecScannerPtr_t);
+static Ret_t _pushTok(XltDecScannerPtr_t);
+static void _setBuf(XltDecScannerPtr_t, const MemPtr_t, const MemPtr_t);
+static MemPtr_t _getPos(XltDecScannerPtr_t);
+
+/**
+ * FUNCTION: readBytes
+ *
+ * Advance the current position pointer after checking whether the end of
+ * the buffer has been reached. If the end of the buffer has been reached
+ * the scanner's finished flag is set.
+
+ * RETURNS: 0, if end of buffer has been reached
+ * 1 otherwise
+ */
+static Boolean_t readBytes(wbxmlScannerPrivPtr_t pScanner, Long_t bytes);
+
+/**
+ * FUNCTION: parseInt
+ *
+ * Decodes multi-byte integers.
+ *
+ * PRE-Condition:
+ * pScanner->pos points to the first byte of the mb_int.
+ *
+ * POST-Condition:
+ * pScanner->pos points to the last byte of the mb_int.
+ */
+static Ret_t parseInt(wbxmlScannerPrivPtr_t pScanner, MBINT *mbi);
+
+/**
+ * FUNCTION: wbxmlHeader, wbxmlVersion, wbxmlPublicID, wbxmlCharset
+ *
+ * These functions are used for decoding the WBXML document header.
+ * wbxmlHeader is a short wrapper that calls the other four functions in
+ * the right order to scan the header. wbxmlStrtbl makes a copy of the
+ * string table.
+ */
+static Ret_t wbxmlHeader(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlVersion(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlPublicID(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlCharset(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlStrtbl(wbxmlScannerPrivPtr_t pScanner);
+
+/**
+ * FUNCTION: wbxmlSwitchPage
+ *
+ * Switch WBXML code page
+ */
+static Ret_t wbxmlSwitchPage(wbxmlScannerPrivPtr_t pScanner);
+
+/**
+ * FUNCTION: wbxmlXXXToken
+ *
+ * Scan the document for the next valid XML/WBXML token as defined in the
+ * XLTDecCom header file (e.g. TOK_TAG_START).
+ *
+ * PRE-Condition:
+ * pScanner->pos points to the first byte of a valid WBXML
+ * element (String, Tag, etc.)
+ *
+ * POST-Condition:
+ * pScanner->pos points to the last byte of the WBXML
+ * element;
+ * pScanner->curtok contains type and tagid or pcdata of
+ * the token
+ */
+static Ret_t wbxmlStringToken(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlOpaqueToken(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlTagToken(wbxmlScannerPrivPtr_t pScanner);
+
+/**
+ * FUNCTION: wbxmlXXXToken
+ *
+ * WBXML extensions, entities, processing instructions and attributes are
+ * not supported by this scanner. If one is found it is skipped and
+ * processing continues afterwards.
+ */
+static Ret_t wbxmlSkipExtension(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlSkipEntity(wbxmlScannerPrivPtr_t pScanner);
+static Ret_t wbxmlSkipPI(wbxmlScannerPrivPtr_t);
+static Ret_t wbxmlSkipAttribute(wbxmlScannerPrivPtr_t);
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+/**
+ * FUNCTION: XltDecWbxmlInit
+ *
+ * Create and initialize a new WBXML scanner. Description see XLTDec.h.
+ */
+Ret_t
+xltDecWbxmlInit(const MemPtr_t pBufEnd, MemPtr_t *ppBufPos,
+ XltDecScannerPtr_t *ppScanner)
+{
+ wbxmlScannerPrivPtr_t pScanner;
+ Ret_t rc;
+
+ /* initialize new WBXML scanner */
+ if ((pScanner = (wbxmlScannerPrivPtr_t)smlLibMalloc(sizeof(wbxmlScannerPriv_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pScanner, 0, sizeof(wbxmlScannerPriv_t));
+ pScanner->bufend = pBufEnd;
+ pScanner->pos = *ppBufPos;
+ if ((pScanner->curtok = (XltDecTokenPtr_t)smlLibMalloc(sizeof(XltDecToken_t))) == NULL) {
+ smlLibFree(pScanner);
+ *ppScanner = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ pScanner->curtok->pcdata = NULL;
+ if ((rc = xltUtilCreateStack(&pScanner->tagstack, 10)) != SML_ERR_OK) {
+ smlLibFree(pScanner->curtok);
+ smlLibFree(pScanner);
+ *ppScanner = NULL;
+ return rc;
+ }
+ pScanner->state = TAG_STATE;
+
+ /* point public/private methods to the right implementation */
+ pScanner->nextTok = _nextTok;
+ pScanner->destroy = _destroy;
+ pScanner->pushTok = _pushTok;
+ pScanner->setBuf = _setBuf;
+ pScanner->getPos = _getPos;
+
+ /* decode WBXML header */
+ if ((rc = wbxmlHeader(pScanner)) != SML_ERR_OK) {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ *ppScanner = NULL;
+ return rc;
+ }
+
+ *ppScanner = (XltDecScannerPtr_t)pScanner;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: destroy
+ *
+ * Free memory. Description see XltDecAll.h.
+ */
+static Ret_t
+_destroy(XltDecScannerPtr_t pScanner)
+{
+ wbxmlScannerPrivPtr_t pScannerPriv;
+
+ if (pScanner == NULL)
+ return SML_ERR_OK;
+
+ pScannerPriv = (wbxmlScannerPrivPtr_t)pScanner;
+ if (pScannerPriv->tagstack != NULL)
+ pScannerPriv->tagstack->destroy(pScannerPriv->tagstack);
+ smlLibFree(pScannerPriv->curtok);
+ smlLibFree(pScannerPriv->strtbl);
+ smlLibFree(pScannerPriv);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: nextTok
+ *
+ * Get next token.
+ */
+static Ret_t
+_nextTok(XltDecScannerPtr_t pScanner)
+{
+ wbxmlScannerPrivPtr_t pScannerPriv;
+ Ret_t rc;
+
+ pScannerPriv = (wbxmlScannerPrivPtr_t)pScanner;
+ // T.K.: chanched Ptr_t to _t
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScannerPriv->curtok->start = pScannerPriv->pos;
+
+ /* keep going until we find a "supported" element */
+ rc = SML_ERR_OK;
+ while (rc == SML_ERR_OK) {
+ /* skip PIs, extensions and entities... */
+ if (IS_PI(pScannerPriv->pos)) {
+ rc = wbxmlSkipPI(pScannerPriv);
+ } else if (IS_EXTENSION(pScannerPriv->pos)) {
+ rc = wbxmlSkipExtension(pScannerPriv);
+ } else if (IS_ENTITY(pScannerPriv->pos)) {
+ rc = wbxmlSkipEntity(pScannerPriv);
+
+ /* ... decode strings, opaque data and tags */
+ } else if (IS_STRING(pScannerPriv->pos)) {
+ rc = wbxmlStringToken(pScannerPriv);
+ break;
+ } else if (IS_OPAQUE(pScannerPriv->pos)) {
+ rc = wbxmlOpaqueToken(pScannerPriv);
+ break;
+ } else {
+ rc = wbxmlTagToken(pScannerPriv);
+ break;
+ }
+ }
+
+ return rc;
+}
+
+/**
+ * FUNCTION: pushTok
+ *
+ * Reset the scanner to the starting position of the current token within
+ * the buffer.
+ */
+static Ret_t
+_pushTok(XltDecScannerPtr_t pScanner)
+{
+ wbxmlScannerPrivPtr_t pScannerPriv;
+ XltUtilStackPtr_t pTagStack;
+ XltTagID_t tagid;
+ Ret_t rc = 0;
+
+ pScannerPriv = (wbxmlScannerPrivPtr_t)pScanner;
+ pTagStack = pScannerPriv->tagstack;
+
+ if (pScannerPriv->curtok->start == NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ /* reset scanner to position where tok begins */
+ pScannerPriv->pos = pScannerPriv->curtok->start;
+
+ /* correct the tag stack */
+ if (pScannerPriv->curtok->type == TOK_TAG_START) {
+ rc = pTagStack->pop(pTagStack, &tagid);
+ } else if (pScannerPriv->curtok->type == TOK_TAG_END) {
+ tagid = pScannerPriv->curtok->tagid;
+ rc = pTagStack->push(pTagStack, tagid);
+ }
+ if (rc) return rc;
+
+ /* invalidate curtok */
+ /* T.K. Possible Error. pScannerPriv->curtok is of type XltDecToken_t NOT ...Ptr_t */
+ // OrigLine:
+ // smlLibMemset(pScannerPriv->curtok, 0, sizeof(XltDecTokenPtr_t));
+ pScannerPriv->curtok->type = (XltTokType_t)0;
+
+ return SML_ERR_OK;
+}
+
+static void
+_setBuf(XltDecScannerPtr_t pScanner, const MemPtr_t pBufStart,
+ const MemPtr_t pBufEnd)
+{
+ wbxmlScannerPrivPtr_t pScannerPriv = (wbxmlScannerPrivPtr_t)pScanner;
+ pScannerPriv->pos = pBufStart;
+ pScannerPriv->bufend = pBufEnd;
+}
+
+static MemPtr_t
+_getPos(XltDecScannerPtr_t pScanner)
+{
+ return ((wbxmlScannerPrivPtr_t)pScanner)->pos;
+}
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+/**
+ * FUNCTION: readBytes
+ *
+ * Advance the position pointer. Description see above.
+ */
+static Boolean_t
+readBytes(wbxmlScannerPrivPtr_t pScanner, Long_t bytes)
+{
+ if (pScanner->pos + bytes > pScanner->bufend) {
+ pScanner->finished = 1;
+ return 0;
+ }
+ pScanner->pos += bytes;
+ return 1;
+}
+
+/**
+ * NOTICE: Entities, Extensions, Processing Instructions and Attributes
+ * are not supported by the WBXML scanner.
+ *
+ * Extensions and Attributes are document-specific and are as such not used
+ * by the SyncML specification.
+ * The scanner will just ignore and skip over them. Neither
+ * this scanner nor the parser use processing instructions so they are
+ * skipped as well.
+ */
+
+/**
+ * FUNCTION: wbxmlHeader
+ *
+ * Decode the WBXML header containing version number, document public
+ * identifier, character set and a string table.
+ */
+static Ret_t
+wbxmlHeader(wbxmlScannerPrivPtr_t pScanner)
+{
+ Ret_t rc;
+
+ /* decode the WBXML header */
+ if ((rc = wbxmlVersion(pScanner)) != SML_ERR_OK)
+ return rc;
+ if ((rc = wbxmlPublicID(pScanner)) != SML_ERR_OK)
+ return rc;
+ if ((rc = wbxmlCharset(pScanner)) != SML_ERR_OK)
+ return rc;
+ if ((rc = wbxmlStrtbl(pScanner)) != SML_ERR_OK)
+ return rc;
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlVersion
+ *
+ * Decode WBXML version. The scanner returns an error if the major version
+ * of the document differs from the major version this scanner supports or
+ * if the minor version of the document is larger than the minor version
+ * the scanner supports.
+ */
+static Ret_t
+wbxmlVersion(wbxmlScannerPrivPtr_t pScanner)
+{
+ Byte_t major, minor;
+
+ minor = ((Byte_t)(*pScanner->pos & 0x0F));
+ major = ((Byte_t)((*pScanner->pos >> 4) + 1));
+
+
+
+ if (major != _MAJOR_VERSION || minor > _MINOR_VERSION)
+ return SML_ERR_XLT_INCOMP_WBXML_VERS;
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlPublicID
+ *
+ * Decodes WBXML Document Public Identifier.
+ */
+static Ret_t
+wbxmlPublicID(wbxmlScannerPrivPtr_t pScanner)
+{
+ MBINT tmp;
+ Ret_t rc;
+
+ if (*pScanner->pos != 0) {
+ /* pre-defined numeric identifier */
+ if ((rc = parseInt(pScanner, &tmp)) != SML_ERR_OK)
+ return rc;
+ pScanner->pubID = tmp;
+ pScanner->pubIDIdx = 0;
+ } else {
+ /* public id is given as string table entry (which we
+ haven't read at this point so we'll save the reference
+ for later) */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((rc = parseInt(pScanner, &tmp)) != SML_ERR_OK)
+ return rc;
+ pScanner->pubID = 0;
+ pScanner->pubIDIdx = tmp;
+ }
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlCharset
+ *
+ * Decode WBXML Charset.
+ */
+static Ret_t
+wbxmlCharset(wbxmlScannerPrivPtr_t pScanner)
+{
+ /* TODO: if charset iformation has to be processed
+ it can be done here. For the moment only UTF-8 is used by SyncML */
+ MBINT mibenum;
+ Ret_t rc;
+
+ /* charset is given as a single IANA assigned MIBEnum value */
+ if ((rc = parseInt(pScanner, &mibenum)) != SML_ERR_OK)
+ return rc;
+ pScanner->charset = mibenum;
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlStrtbl
+ *
+ * Keep a copy of the string table.
+ */
+static Ret_t
+wbxmlStrtbl(wbxmlScannerPrivPtr_t pScanner)
+{
+ MBINT len;
+ Ret_t rc;
+
+ if ((rc = parseInt(pScanner, &len)) != SML_ERR_OK)
+ return rc;
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ pScanner->strtbllen = len;
+ if (len > 0) {
+ if (pScanner->pos + len > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((pScanner->strtbl = smlLibMalloc(len)) == NULL)
+ {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemcpy(pScanner->strtbl, pScanner->pos, len);
+ readBytes(pScanner, len);
+ } else {
+ pScanner->strtbl = NULL;
+ }
+
+ /* if the public ID was given as a string table reference save a
+ reference to the corresponding string for later */
+ if (pScanner->pubID == 0) {
+ if (pScanner->pubIDIdx > pScanner->strtbllen)
+ return SML_ERR_XLT_INVAL_WBXML_DOC;
+ pScanner->pubIDStr = (String_t)(pScanner->strtbl + pScanner->pubIDIdx);
+ }
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+parseInt(wbxmlScannerPrivPtr_t pScanner, MBINT *mbi)
+{
+ *mbi = 0;
+ /* accumulate byte value until continuation flag (MSB) is zero */
+ for (;;) {
+ *mbi = *mbi << 7;
+ *mbi += *(pScanner->pos) & 0x7F;
+ if (!(*pScanner->pos & 0x80)) break;
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ return SML_ERR_OK;
+}
+
+static Ret_t
+wbxmlStringToken(wbxmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPcdata;
+ Ret_t rc;
+
+ if ((pPcdata = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ /* copy the string into the new PCdata struct */
+ if (IS_STR_I(pScanner->pos)) {
+ /* inline string */
+ if (!readBytes(pScanner, 1))
+ {
+ /* LIBnn25123 Fix*/
+ if(pPcdata != NULL) { smlLibFree(pPcdata); pPcdata = NULL; }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ pPcdata->extension = SML_EXT_UNDEFINED;
+ pPcdata->contentType = SML_PCDATA_STRING;
+ pPcdata->length = smlLibStrlen((String_t)pScanner->pos);
+ if (pScanner->pos + pPcdata->length + 1 > pScanner->bufend) {
+ smlLibFree(pPcdata);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ if ((pPcdata->content = smlLibMalloc(pPcdata->length + 1)) == NULL) {
+ smlLibFree(pPcdata);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibStrncpy(pPcdata->content, (String_t)pScanner->pos, pPcdata->length + 1);
+ readBytes(pScanner, pPcdata->length + 1);
+
+ } else {
+ /* string table reference */
+ MBINT offset; /* offset into string table */
+ if (!readBytes(pScanner, 1))
+ {
+ /* LIBnn25123 Fix*/
+ if(pPcdata != NULL) { smlLibFree(pPcdata); pPcdata = NULL;}
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ if ((rc = parseInt(pScanner, &offset)) != SML_ERR_OK)
+ {
+ smlLibFree(pPcdata);
+ return rc;
+ }
+ if (offset >= pScanner->strtbllen) {
+ smlLibFree(pPcdata);
+ return SML_ERR_XLT_INVAL_WBXML_DOC;
+ }
+ pPcdata->contentType = SML_PCDATA_STRING;
+ pPcdata->length = smlLibStrlen((String_t)(pScanner->strtbl + offset));
+ if ((pPcdata->content = smlLibMalloc(pPcdata->length + 1)) == NULL) {
+ smlLibFree(pPcdata);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibStrncpy(pPcdata->content, (String_t)(pScanner->strtbl + offset), pPcdata->length + 1);
+ readBytes(pScanner, 1);
+ }
+
+ pScanner->curtok->pcdata = pPcdata;
+
+ pScanner->curtok->type = TOK_CONT;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+wbxmlOpaqueToken(wbxmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPcdata = NULL;
+ MBINT len;
+ Ret_t rc;
+
+ KCDBG("wbxmlOpaqueToken: Enter\n");
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ /* a mbi indicates the length of the opaque data block that we'll
+ copy into new PCdata struct */
+ if ((rc = parseInt(pScanner, &len)) != SML_ERR_OK)
+ return rc;
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if (pScanner->pos + len > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((pPcdata = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ pPcdata->extension = SML_EXT_UNDEFINED;
+ pPcdata->contentType = SML_PCDATA_OPAQUE;
+ pPcdata->length = len;
+ /* Modification 2001-07-03 by Luz %%%%%:
+ * made sure that content is one null byte longer
+ * than indicated opaque content, such that strings that are coded as
+ * opaque (happens to be the case with Nokia 9210) can still be read
+ * as C-string without need for an intermediate buffer
+ */
+ /* original:
+ if ((pPcdata->content = smlLibMalloc(len)) == NULL) {
+ smlLibFree(pPcdata);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ */
+ /* modified: */
+ if ((pPcdata->content = smlLibMalloc(len+1)) == NULL) {
+ smlLibFree(pPcdata);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ ((char *)pPcdata->content)[len]=0; /* make sure there is a c-string terminator */
+ /* end modification */
+
+ smlLibMemcpy(pPcdata->content, pScanner->pos, len);
+ pScanner->curtok->pcdata = pPcdata;
+
+ readBytes(pScanner, len);
+
+ pScanner->curtok->type = TOK_CONT;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+wbxmlTagToken(wbxmlScannerPrivPtr_t pScanner)
+{
+ XltTagID_t tagid;
+ Boolean_t has_cont, has_attr;
+ Ret_t rc;
+
+ if (IS_SWITCH(pScanner->pos)) {
+ if ((rc = wbxmlSwitchPage(pScanner)) != SML_ERR_OK)
+ return rc;
+ }
+
+ /* we have to look at the top of the tagstack to see which
+ start tag an end tag belongs to */
+ if (IS_END(pScanner->pos)) {
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ pScanner->curtok->type = TOK_TAG_END;
+ rc = pScanner->tagstack->pop(pScanner->tagstack, &tagid);
+ if (rc == SML_ERR_WRONG_USAGE)
+ return SML_ERR_XLT_INVAL_WBXML_DOC;
+ else if (rc)
+ return rc;
+ pScanner->curtok->tagid = tagid;
+ return SML_ERR_OK;
+ }
+
+
+ /* look at the two MSB: does this tag have content or attributes? */
+
+ has_cont = ((Boolean_t)(HAS_CONTENT(pScanner->pos)));
+ has_attr = ((Boolean_t)(HAS_ATTRIBUTES(pScanner->pos)));
+
+
+ /* look up tag ID either by string or by number */
+ if (IS_LITERAL(pScanner->pos)) {
+ MBINT offset; /* offset into the string table */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((rc = parseInt(pScanner, &offset)) != SML_ERR_OK)
+ return rc;
+ if (offset > pScanner->strtbllen)
+ return SML_ERR_XLT_INVAL_WBXML_DOC;
+
+ rc = (Ret_t)getTagIDByStringAndExt((String_t)(pScanner->strtbl + offset), pScanner->activeExt, &tagid);
+ if ((tagid == TN_UNDEF) || (rc != SML_ERR_OK)) return rc;
+
+ } else {
+ rc = (Ret_t)getTagIDByByteAndExt((Byte_t)IDENTITY(pScanner->pos), pScanner->activeExt, &tagid);
+ if ((tagid == TN_UNDEF) || (rc != SML_ERR_OK)) return rc;
+
+ }
+
+ /* we know everything we need to know */
+ pScanner->curtok->tagid = tagid;
+ pScanner->curtok->type = has_cont ? TOK_TAG_START : TOK_TAG_EMPTY;
+ switch ( pScanner->cptag )
+ {
+ case 0x00 :
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+ break;
+ case 0x01 :
+#ifdef __USE_METINF__
+ pScanner->curtok->ext = SML_EXT_METINF;
+#else
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+#endif
+ break;
+ case 0x02 :
+#ifdef __USE_DMTND__
+ pScanner->curtok->ext = SML_EXT_DMTND;
+#else
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+#endif
+ break;
+ case 0xFD2 :
+#ifdef __USE_DEVINF__
+ pScanner->curtok->ext = SML_EXT_DEVINF;
+#else
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+#endif
+ break;
+ default:
+ pScanner->curtok->ext = SML_EXT_UNDEFINED;
+ break;
+ }
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ /* push tag onto tagstack unless this tag is empty */
+ if (has_cont) {
+ if ((rc = pScanner->tagstack->push(pScanner->tagstack, tagid)) != SML_ERR_OK)
+ return rc;
+ }
+
+ /* skip attributes */
+ if (has_attr) {
+ pScanner->state = ATTRIBUTE_STATE;
+ if ((rc = wbxmlSkipAttribute(pScanner)) != SML_ERR_OK)
+ return rc;
+ pScanner->state = TAG_STATE;
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlSwitchPage
+ *
+ * Switch WBXML code page.
+ */
+/* T.K. 06.02.01
+ * We need to enhance this as soon as we introduce
+ * Sub DTD's with more than one WBXML codepage. But till then
+ * there is only one case where WBXML codepages can occure, and
+ * this is the MetInf Sub DTD. So in case we find a codepage switch
+ * to something other than codepage zero, we set the active extension
+ * to metinf.
+ * In future versions the pScanner needs to be enhanced, to translate
+ * codepageswitches context sensitive to the active extension.
+ */
+static Ret_t
+wbxmlSwitchPage(wbxmlScannerPrivPtr_t pScanner)
+{
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if (pScanner->state == TAG_STATE)
+ pScanner->cptag = (SmlPcdataExtension_t)*pScanner->pos;
+ else
+ pScanner->cpattr = *pScanner->pos;
+ readBytes(pScanner, 1);
+ /* T.K. this needs to be adjusted as described above */
+ /* Ken Chen/Motorola, switch WBXML switch page accordingly */
+
+ switch ( pScanner->cptag )
+ {
+ case 0x00 :
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+ break;
+ case 0x01 :
+#ifdef __USE_METINF__
+ pScanner->activeExt = SML_EXT_METINF;
+#else
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+#endif
+ break;
+ case 0x02 :
+#ifdef __USE_DMTND__
+ pScanner->activeExt = SML_EXT_DMTND;
+#else
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+#endif
+ break;
+ case 0xFD2 :
+#ifdef __USE_DEVINF__
+ pScanner->activeExt = SML_EXT_DEVINF;
+#else
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+#endif
+ break;
+ default:
+ pScanner->activeExt = SML_EXT_UNDEFINED;
+ break;
+ }
+
+ return SML_ERR_OK;
+}
+
+
+/******************************/
+/* Unsupported WBXML elements */
+/******************************/
+
+/**
+ * FUNCTION: wbxmlSkipEntity
+ *
+ * Skips entities but doesn't do anything useful yet.
+ */
+static Ret_t
+wbxmlSkipEntity(wbxmlScannerPrivPtr_t pScanner)
+{
+ MBINT tmp;
+ Ret_t rc;
+
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((rc = parseInt(pScanner, &tmp)) != SML_ERR_OK)
+ return rc;
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: wbxmlSkipExtension
+ *
+ * Decode WBXML extensions. Skips the extension but doesn't do anything
+ * useful with it.
+ */
+static Ret_t
+wbxmlSkipExtension(wbxmlScannerPrivPtr_t pScanner)
+{
+ MBINT tmp;
+ Ret_t rc;
+
+ if (IS_EXT(pScanner->pos)) {
+ /* single byte extension token */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ } else if (IS_EXT_I(pScanner->pos)) {
+ /* inline string extension token */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if (!readBytes(pScanner, smlLibStrlen((String_t)pScanner->pos) + 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ } else {
+ /* inline integer extension token */
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ if ((rc = parseInt(pScanner, &tmp)) != SML_ERR_OK)
+ return rc;
+ if (!readBytes(pScanner, tmp + 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: wbxmlSkipPI
+ *
+ * Handle XML processing instructions. PIs are not supported but the
+ * scanner recognizes and skips over them.
+ */
+static Ret_t
+wbxmlSkipPI(wbxmlScannerPrivPtr_t pScanner)
+{
+ /* PIs are just like tag attributes with a special PI token instead
+ * of the attribute start token */
+ return wbxmlSkipAttribute(pScanner);
+}
+
+/**
+ * FUNCTION: wbxmlSkipAttribute
+ *
+ * Handle attributes. Attributes are not supported but the
+ * scanner recognizes and skips over them.
+ */
+static Ret_t
+wbxmlSkipAttribute(wbxmlScannerPrivPtr_t pScanner)
+{
+ XltDecTokenPtr_t oldtok;
+ MBINT tmp;
+ Ret_t rc = 0;
+
+ /* skipping attributes shouldn't change the current token so we
+ make a copy... */
+ if ((oldtok = (XltDecTokenPtr_t)smlLibMalloc(sizeof(XltDecToken_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemcpy(oldtok, pScanner->curtok, sizeof(XltDecToken_t));
+
+ /* ... skip until attribute end tag... */
+ while (!IS_END(pScanner->pos)) {
+ if (IS_STRING(pScanner->pos)) {
+ rc = wbxmlStringToken(pScanner);
+ /* avoid memory leak due to this ugly workaround of
+ skipping attributes */
+ smlLibFree(pScanner->curtok->pcdata);
+ } else if (IS_EXTENSION(pScanner->pos)) {
+ rc = wbxmlSkipExtension(pScanner);
+ } else if (IS_ENTITY(pScanner->pos)) {
+ rc = wbxmlSkipEntity(pScanner);
+ } else if (IS_OPAQUE(pScanner->pos)) {
+ rc = wbxmlOpaqueToken(pScanner);
+ /* avoid memory leak due to this ugly workaround of
+ skipping attributes */
+ smlLibFree(pScanner->curtok->pcdata);
+ } else if (IS_LITERAL(pScanner->pos)) {
+ if (!readBytes(pScanner, 1))
+ {
+ if(oldtok) { smlLibFree(oldtok); oldtok= NULL; }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ rc = parseInt(pScanner, &tmp);
+ if (!readBytes(pScanner, 1))
+ {
+ if(oldtok) { smlLibFree(oldtok); oldtok= NULL; }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ } else if (IS_SWITCH(pScanner->pos)) {
+ rc = wbxmlSwitchPage(pScanner);
+ } else {
+ if (!readBytes(pScanner, 1))
+ {
+ if(oldtok) { smlLibFree(oldtok); oldtok= NULL; }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ }
+
+ if (rc != SML_ERR_OK) {
+ smlLibFree(oldtok);
+ return rc;
+ }
+
+ }
+ /* ... then skip the end tag itself... */
+ readBytes(pScanner, 1);
+
+ /* ... and finaly restore our copy of curtok */
+ smlLibMemcpy(pScanner->curtok, oldtok, sizeof(XltDecToken_t));
+ smlLibFree(oldtok);
+
+ return SML_ERR_OK;
+}
+
+#ifdef __USE_EXTENSIONS__
+/*
+ * This function tries to decode an inlined WBXML document inside
+ * an PCDATA element.
+ * In case of failing to decode it the PCDATA element isn't changed
+ * at all.
+ */
+
+void
+subdtdDecodeWbxml(XltDecoderPtr_t pDecoder,SmlPcdataPtr_t *ppPcdata) {
+ Ret_t _err = SML_ERR_OK;
+ MemPtr_t pSubBuf = NULL;
+ SmlPcdataPtr_t pSubPcdata = NULL;
+ XltDecoderPtr_t pSubDecoder = NULL;
+ SmlPcdataExtension_t ext = 0;
+#ifdef __USE_DEVINF__
+ wbxmlScannerPrivPtr_t pScannerPriv = NULL;
+#endif
+
+ KCDBG("subdtdDecodeWbxml: Enter\n");
+
+ /* some sanity checks at first */
+
+ if (*ppPcdata == NULL) {
+ if (pDecoder) /* use this rare case to remove warning */
+ {
+ }
+ return;
+ }
+
+ if ((*ppPcdata)->contentType != SML_PCDATA_OPAQUE) return;
+
+ // now create a sub buffer
+ pSubBuf = (MemPtr_t)smlLibMalloc((*ppPcdata)->length);
+ if (pSubBuf == NULL) return;
+ smlLibMemset(pSubBuf, 0x00, (*ppPcdata)->length);
+ smlLibMemmove(pSubBuf, (*ppPcdata)->content, (*ppPcdata)->length);
+
+ /* ok looks fine sofar - now lets decode the rest */
+ /* now lets create a decoder, but without parsing the SyncML
+ * start tags (because it's not there) and skip the XML
+ * part as we don't need it.
+ */
+ pSubDecoder = (XltDecoderPtr_t)smlLibMalloc(sizeof(XltDecoder_t));
+ if (pSubDecoder == NULL) {
+ smlLibFree(pSubBuf);
+ return;
+ }
+
+ KCDBG("subdtdDecodeWbxml: allocated decoder\n");
+
+ pSubDecoder->finished = 0;
+ pSubDecoder->final = 0;
+ pSubDecoder->scanner = NULL;
+ if (xltUtilCreateStack(&pSubDecoder->tagstack, 10) != SML_ERR_OK) {
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubBuf);
+ return;
+ }
+ if (xltDecWbxmlInit(pSubBuf+(*ppPcdata)->length,&pSubBuf, &pSubDecoder->scanner) != SML_ERR_OK) {
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubBuf);
+ return;
+ }
+ pSubDecoder->charset = pSubDecoder->scanner->charset;
+ pSubDecoder->charsetStr = NULL;
+
+ pSubPcdata = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+ if (pSubPcdata == NULL) {
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubPcdata);
+ smlLibFree(pSubBuf);
+ return;
+ }
+ smlLibMemset(pSubPcdata, 0, sizeof(SmlPcdata_t));
+
+ _err = SML_ERR_UNSPECIFIC;
+
+ // detect document type and parse
+ pScannerPriv = (wbxmlScannerPrivPtr_t)pSubDecoder->scanner;
+ pScannerPriv->activeExt = 0;
+ pScannerPriv->cpattr = 0;
+ pScannerPriv->cptag = (SmlPcdataExtension_t)0;
+ smlLibMemset(pScannerPriv->curtok, 0,sizeof(XltDecToken_t));
+
+ if (((_err = nextToken(pSubDecoder)) == SML_ERR_OK)) {
+
+ if (IS_START(pSubDecoder->scanner->curtok)) {
+ ext = pSubDecoder->scanner->curtok->ext;
+ if ((_err = discardToken(pSubDecoder)) == SML_ERR_OK) {
+
+ pSubPcdata->contentType = SML_PCDATA_EXTENSION;
+ pSubPcdata->extension = ext;
+
+ pScannerPriv->activeExt = ext;
+
+ switch (ext) {
+#ifdef __USE_DEVINF__
+ case SML_EXT_DEVINF:
+ KCDBG("subdtdDecodeWbxml: EXT_DEVINF detected\n");
+ _err = buildDevInfDevInfCmd(pSubDecoder, (VoidPtr_t)&pSubPcdata->content);
+ break;
+#endif
+#ifdef __USE_DMTND__
+ case SML_EXT_DMTND:
+ KCDBG("subdtdDecodeWbxml: EXT_DMTND detected\n");
+ _err = buildDmTndCmd(pSubDecoder, (VoidPtr_t)&pSubPcdata->content);
+ break;
+#endif
+ default:
+ KCDBG("subdtdDecodeWbxml: unknown extension detected\n");
+ _err = SML_ERR_XLT_INVAL_EXT;
+ break;
+ }
+ }
+
+ }
+
+ }
+
+ if (_err != SML_ERR_OK) {
+ KCDBG("subdtdDecodeWbxml: failed to parse\n");
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubPcdata);
+ smlLibFree(pSubBuf);
+ return;
+ }
+
+ /* parsing is done, now lets anchor it within the original PCDATA element */
+ smlFreePcdata(*ppPcdata);
+ *ppPcdata = pSubPcdata;
+
+ /* we are done */
+ xltDecTerminate(pSubDecoder);
+ smlLibFree(pSubBuf);
+
+ KCDBG("subdtdDecodeWbxml: Leave\n");
+
+ return;
+}
+
+#endif
+
+/*Added by w21034 begin*/
+Ret_t wbxml2xmlInternal(unsigned char *bufIn, int bufInLen, unsigned char *bufOut, int * bufOutLen)
+{
+ #define Debug printf
+ Debug("Enter wbxml2xmlInternal\n");
+ wbxmlScannerPrivPtr_t pScanner;
+ Ret_t rc;
+
+ //check
+ int smlInitByMe = 0;
+ if(mgrGetSyncMLAnchor()== NULL)
+ {
+ Debug("Init syncML\n");
+ SmlOptions_t smlOptions;
+ memset(&smlOptions, 0, sizeof(smlOptions));
+ smlOptions.defaultPrintFunc = NULL;
+ smlOptions.maxWorkspaceAvailMem = 40000;
+ rc = smlInit(&smlOptions);
+ if(rc!=SML_ERR_OK)
+ {
+ return rc;
+ }
+ smlInitByMe = 1;
+ }
+
+ /* initialize new WBXML scanner */
+ if ((pScanner = (wbxmlScannerPrivPtr_t)smlLibMalloc(sizeof(wbxmlScannerPriv_t))) == NULL)
+ {
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pScanner, 0, sizeof(wbxmlScannerPriv_t));
+ //Debug("wbxml2xmlInternal 2\n");
+ pScanner->bufend = bufIn + bufInLen;
+ pScanner->pos = bufIn;
+ if ((pScanner->curtok = (XltDecTokenPtr_t)smlLibMalloc(sizeof(XltDecToken_t))) == NULL) {
+ smlLibFree(pScanner);
+ pScanner = NULL;
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ //Debug("wbxml2xmlInternal 3\n");
+ pScanner->curtok->pcdata = NULL;
+ if ((rc = xltUtilCreateStack(&pScanner->tagstack, 10)) != SML_ERR_OK) {
+ smlLibFree(pScanner->curtok);
+ smlLibFree(pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return rc;
+ }
+ pScanner->state = TAG_STATE;
+
+ //Debug("wbxml2xmlInternal 4\n");
+ /* point public/private methods to the right implementation */
+ pScanner->nextTok = _nextTok;
+ pScanner->destroy = _destroy;
+ pScanner->pushTok = _pushTok;
+ pScanner->setBuf = _setBuf;
+ pScanner->getPos = _getPos;
+
+ //Debug("wbxml2xmlInternal 5\n");
+ unsigned char* tmpBufOut = bufOut;
+ int tmpBufOutLen = 0;
+
+ Debug("wbxml2xmlInternal 6\n");
+ /* decode the WBXML header */
+ /*decode wbxml verson*/
+ Byte_t major, minor;
+ minor = ((Byte_t)(*pScanner->pos & 0x0F));
+ major = ((Byte_t)((*pScanner->pos >> 4) + 1));
+ String_t wbxmlVer = NULL;
+ if((wbxmlVer = smlLibMalloc(50))== NULL)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ Debug("wbxml2xmlInternal 7\n");
+ smlLibMemset(wbxmlVer, 0, 50);
+ sprintf(wbxmlVer, "<WBXML Version=%d.%d/>", (int)major, (int)minor);
+ tmpBufOutLen = smlLibStrlen(wbxmlVer);
+ smlLibStrncpy((String_t)tmpBufOut, (String_t)wbxmlVer, tmpBufOutLen);
+ tmpBufOut += tmpBufOutLen;
+ Debug("wbxml2xmlInternal 7.1,%s\n", wbxmlVer);
+ smlLibFree(wbxmlVer);
+ tmpBufOut[0] = '\n';
+ tmpBufOut++;
+ tmpBufOut[0] = '\0';
+ //Debug("wbxml2xmlInternal 8\n");
+ if (!readBytes(pScanner, 1))
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+
+ Debug("wbxml2xmlInternal 9\n");
+ /*decode public ID*/
+ if ((rc = wbxmlPublicID(pScanner)) != SML_ERR_OK)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return rc;
+ }
+ /*decode charset*/
+ if ((rc = wbxmlCharset(pScanner)) != SML_ERR_OK)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return rc;
+ }
+ /*decode string table*/
+ if ((rc = wbxmlStrtbl(pScanner)) != SML_ERR_OK)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return rc;
+ }
+
+ //Debug("wbxml2xmlInternal 10\n");
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ String_t tmpStr = smlLibMalloc(50);
+ if(tmpStr == NULL)
+ {
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ //Debug("wbxml2xmlInternal 11\n");
+ smlLibMemset(tmpStr, 0, 50);
+ char startBracket[2];
+ startBracket[0] = '\<';
+ startBracket[1] = '\0';
+ char endBracket[2];
+ endBracket[0]='\>';
+ endBracket[1]='\0';
+ char forwardSlash[2];
+ forwardSlash[0] = '\/';
+ forwardSlash[1] = '\0';
+
+ Debug("wbxml2xmlInternal 12\n");
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ int tagStartFlag = 0;
+ /* keep going until we find a "supported" element */
+ rc = SML_ERR_OK;
+ while (rc == SML_ERR_OK) {
+ /* skip PIs, extensions and entities... */
+ if (IS_PI(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 13, PI\n");
+ rc = wbxmlSkipPI(pScanner);
+ //Debug("wbxml2xmlInternal 13, PI end\n");
+ } else if (IS_EXTENSION(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 14, Extension\n");
+ rc = wbxmlSkipExtension(pScanner);
+ //Debug("wbxml2xmlInternal 14, Extension End\n");
+ } else if (IS_ENTITY(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 15, ENTITY\n");
+ rc = wbxmlSkipEntity(pScanner);
+ //Debug("wbxml2xmlInternal 15, ENTITY End\n");
+
+ /* ... decode strings, opaque data and tags */
+ } else if (IS_STRING(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 16, STRING\n");
+ rc = wbxmlStringToken(pScanner);
+ if(rc == SML_ERR_OK)
+ {
+ SmlPcdataPtr_t pcdata = pScanner->curtok->pcdata;
+ smlLibMemcpy(tmpBufOut, pcdata->content, pcdata->length);
+ tmpBufOut+=pcdata->length;
+ }
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ //Debug("wbxml2xmlInternal 16, STRING end\n");
+ } else if (IS_OPAQUE(pScanner->pos)) {
+ //Debug("wbxml2xmlInternal 17, OPAQUE\n");
+ rc = wbxmlOpaqueToken(pScanner);
+ if(rc == SML_ERR_OK)
+ {
+ SmlPcdataPtr_t pcdata = pScanner->curtok->pcdata;
+ smlLibMemcpy(tmpBufOut, pcdata->content, pcdata->length);
+ tmpBufOut+=pcdata->length;
+ }
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ //Debug("wbxml2xmlInternal 17, OPAQUE End\n");
+ //break;
+ } else {
+ Debug("wbxml2xmlInternal 18, TAG\n");
+ rc = wbxmlTagToken(pScanner);
+ if(rc != SML_ERR_OK)
+ {
+ break;
+ }
+ //Debug("wbxml2xmlInternal 18.1, TAG\n");
+ //Generate string for the token.
+ String_t _tagString = smlLibMalloc(50);
+ if (_tagString == NULL)
+ {
+ //Debug("wbxml2xmlInternal 18.1.1, TAG\n");
+ smlLibFree(tmpStr);
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ //Debug("wbxml2xmlInternal 18.1.2, TAG\n");
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(_tagString, 0, 50);
+ Debug("wbxml2xmlInternal 18.2, TAG\n");
+ //Debug("tagid=%d, ext=%d\n",pScanner->curtok->tagid, pScanner->curtok->ext);
+ if ((rc = getTagString(pScanner->curtok->tagid, _tagString, pScanner->activeExt)) != SML_ERR_OK)
+ {
+ if(pScanner->curtok->type == TOK_TAG_END)
+ {
+ SmlPcdataExtension_t tmpExt = SML_EXT_UNDEFINED;
+ if(tmpExt == pScanner->activeExt)
+ {
+ tmpExt = SML_EXT_METINF;
+ }
+ smlLibMemset(_tagString, 0, 50);
+ rc =getTagString(pScanner->curtok->tagid, _tagString, tmpExt);
+ }
+ if(rc != SML_ERR_OK)
+ {
+ Debug("wbxml2xmlInternal 18.2.1, TAG, rc=%d\n", rc);
+ smlLibFree(_tagString);
+ break;
+ }
+ }
+ smlLibMemset(tmpStr, 0, 50);
+ if(pScanner->curtok->type == TOK_TAG_START)
+ {
+ Debug("wbxml2xmlInternal 18.6, TAG\n");
+ if(tagStartFlag == 1)
+ {
+ sprintf(tmpStr, "\n%s%s%s", startBracket, _tagString, endBracket);
+ }
+ else
+ {
+ sprintf(tmpStr, "%s%s%s", startBracket, _tagString, endBracket);
+ }
+ smlLibStrcpy((String_t)tmpBufOut, tmpStr);
+ tmpBufOut += smlLibStrlen(tmpStr);
+ tagStartFlag = 1;
+ }
+ else if(pScanner->curtok->type == TOK_TAG_END)
+ {
+ Debug("wbxml2xmlInternal 18.7, TAG\n");
+ sprintf(tmpStr, "%s%s%s%s\n", startBracket, forwardSlash, _tagString, endBracket);
+ Debug("tmpStr=%s\n", tmpStr);
+ smlLibStrcpy((String_t)tmpBufOut, tmpStr);
+ tmpBufOut += smlLibStrlen(tmpStr);
+ tagStartFlag = 0;
+ }
+ else if(pScanner->curtok->type == TOK_TAG_EMPTY)
+ {
+ }
+ smlLibFree(_tagString);
+ smlLibMemset(pScanner->curtok, 0, sizeof(XltDecToken_t));
+ pScanner->curtok->start = pScanner->pos;
+ //break;
+ }
+ }
+ if(smlInitByMe == 1)
+ {
+ smlTerminate();
+ }
+ //Debug("wbxml2xmlInternal 20\n");
+ tmpBufOut[0]='\0';
+ *bufOutLen = (int)tmpBufOut - (int)bufOut;
+ smlLibFree(tmpStr);
+ pScanner->destroy((XltDecScannerPtr_t)pScanner);
+ //Debug("Output buffer is: \n%s\n", (char*)bufOut);
+ Debug("wbxml2xmlInternal 21, bufOutLen=%d\n", *bufOutLen);
+ if(rc == SML_ERR_XLT_END_OF_BUFFER)
+ {
+ rc = SML_ERR_OK;
+ }
+ return rc;
+}
+/*Added by w21034 end*/
+
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltdecxml.c b/engine/dmlib/dmengine/oma_toolkit/src/xltdecxml.c
new file mode 100644
index 0000000..d2ed4c2
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltdecxml.c
@@ -0,0 +1,1370 @@
+/*************************************************************************/
+/* module: XML scanner */
+/* file: XLTDecXml.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * The XML scanner/tokenizer. Used by the SyncML parser.
+ */
+
+#include <define.h>
+#ifdef __SML_XML__
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+#include "xltdeccom.h"
+#include "xlttags.h"
+
+#include <libmem.h>
+#include <libstr.h>
+
+#include <smlerr.h>
+#include "xpl_dm_Manager.h"
+
+/**
+ * Private Interface for the XML scanner.
+ */
+typedef struct xmlScannerPriv_s xmlScannerPriv_t, *xmlScannerPrivPtr_t;
+struct xmlScannerPriv_s
+{
+ /* public */
+ Ret_t (*nextTok)(XltDecScannerPtr_t);
+ Ret_t (*destroy)(XltDecScannerPtr_t);
+ Ret_t (*pushTok)(XltDecScannerPtr_t);
+ void (*setBuf)(XltDecScannerPtr_t pScanner, const MemPtr_t pBufStart, const MemPtr_t pBufEnd);
+ MemPtr_t (*getPos)(XltDecScannerPtr_t pScanner);
+
+ XltDecTokenPtr_t curtok; /* current token */
+ Long_t charset; /* 0 */
+ String_t charsetStr; /* character set */
+ Long_t pubID; /* 0 */
+ String_t pubIDStr; /* document public identifier */
+ SmlPcdataExtension_t ext; /* which is the actual open namespace ? */
+ SmlPcdataExtension_t prev_ext; /* which is the previous open namespace ? */
+ XltTagID_t ext_tag; /* which tag started the actual namespace ? */
+ XltTagID_t prev_ext_tag; /* which tag started the previous open namespace ? */
+ String_t nsprefix; /* prefix used for active namespace (if any) */
+ Byte_t nsprelen; /* how long is the prefix ? (to save smlLibStrlen calls) */
+ Flag_t finished;
+
+ /* private */
+ MemPtr_t pos; /* current position */
+ MemPtr_t bufend; /* end of buffer */
+};
+
+const ESCAPE_CHAR_TABLE_T escape_char_table[] =
+{
+ {'&', (String_t)"amp;"},
+ {'&', (String_t)"amp"},
+ {'<', (String_t)"lt;"},
+ {'<', (String_t)"lt"},
+ {'>', (String_t)"gt;"},
+ {'>', (String_t)"gt"},
+ {'\\', (String_t)"apos;"},
+ {'\\', (String_t)"apos"},
+ {'"', (String_t)"quot;"},
+ {'"', (String_t)"quot"},
+ {' ', NULL}
+};
+
+
+/**
+ * Public methods of the scanner interface.
+ *
+ * Description see XLTDecCom.h.
+ */
+static Ret_t _destroy(XltDecScannerPtr_t);
+static Ret_t _nextTok(XltDecScannerPtr_t);
+static Ret_t _pushTok(XltDecScannerPtr_t);
+static void _setBuf(XltDecScannerPtr_t, const MemPtr_t, const MemPtr_t);
+static MemPtr_t _getPos(XltDecScannerPtr_t);
+
+/**
+ * FUNCTION: readBytes
+ *
+ * Advance the current position pointer after checking whether the end of
+ * the buffer has been reached. If the end of the buffer has been reached
+ * the scanner's finished flag is set.
+ *
+ * PRE-Condition:
+ * POST-Condition:
+ *
+ * IN: bytes, read this many bytes
+ *
+ * IN/OUT: pScanner, the scanner
+ *
+ * RETURNS: 1, if end of buffer has not been reached
+ * 0 otherwise
+ */
+static Boolean_t readBytes(xmlScannerPrivPtr_t pScanner, Long_t bytes);
+
+/**
+ * Skip whitespaces.
+ */
+static void skipS(xmlScannerPrivPtr_t pScanner);
+
+static Ret_t xmlTag(xmlScannerPrivPtr_t pScanner, Byte_t endtag);
+static Ret_t xmlName(xmlScannerPrivPtr_t pScanner, String_t *name);
+static Ret_t xmlCharData(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlProlog(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlDocTypeDecl(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlXMLDecl(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlAttribute(xmlScannerPrivPtr_t pScanner, String_t *name, String_t *value);
+static Ret_t xmlStringConst(xmlScannerPrivPtr_t pScanner, String_t *value);
+
+static Ret_t xmlSkipPCDATA(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlSkipComment(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlSkipAttributes(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlSkipPI(xmlScannerPrivPtr_t pScanner);
+static Ret_t xmlCDATA(xmlScannerPrivPtr_t pScanner);
+Boolean_t isPcdata(XltTagID_t tagid);
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+
+Ret_t
+xltDecXmlInit(const MemPtr_t pBufEnd, MemPtr_t *ppBufStart, XltDecScannerPtr_t *ppScanner)
+{
+ xmlScannerPrivPtr_t pScanner;
+ Ret_t rc;
+
+ pScanner = (xmlScannerPrivPtr_t)smlLibMalloc(sizeof(xmlScannerPriv_t));
+ if (pScanner == NULL) {
+ *ppScanner = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ pScanner->finished = 0;
+ pScanner->pos = *ppBufStart;
+ pScanner->bufend = pBufEnd;
+ pScanner->curtok = (XltDecTokenPtr_t)smlLibMalloc(sizeof(XltDecToken_t));
+ if (pScanner->curtok == NULL) {
+ smlLibFree(pScanner);
+ *ppScanner = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ pScanner->curtok->pcdata = NULL;
+ pScanner->curtok->tagid = TN_UNDEF;
+ pScanner->pubID = 0;
+ pScanner->pubIDStr = NULL;
+ pScanner->charset = 0;
+ pScanner->charsetStr = NULL;
+ pScanner->ext = SML_EXT_UNDEFINED;
+ pScanner->prev_ext = (SmlPcdataExtension_t)255;
+ pScanner->ext_tag = TN_UNDEF;
+ pScanner->prev_ext_tag = TN_UNDEF;
+ pScanner->nsprelen = 0;
+ pScanner->nsprefix = NULL;
+
+
+ /* point public/private methods to the right implementation */
+ pScanner->nextTok = _nextTok;
+ pScanner->destroy = _destroy;
+ pScanner->pushTok = _pushTok;
+ pScanner->setBuf = _setBuf;
+ pScanner->getPos = _getPos;
+
+ if ((rc = xmlProlog(pScanner)) != SML_ERR_OK) {
+ smlLibFree(pScanner->curtok);
+ smlLibFree(pScanner);
+ *ppScanner = NULL;
+ return rc;
+ }
+
+ *ppScanner = (XltDecScannerPtr_t)pScanner;
+
+
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: destroy
+ *
+ * Free memory. Description see XltDecAll.h.
+ */
+static Ret_t
+_destroy(XltDecScannerPtr_t pScanner)
+{
+ xmlScannerPrivPtr_t pScannerPriv;
+
+ if (pScanner == NULL)
+ return SML_ERR_OK;
+
+ pScannerPriv = (xmlScannerPrivPtr_t)pScanner;
+ smlLibFree(pScannerPriv->curtok);
+ smlLibFree(pScannerPriv->charsetStr);
+ smlLibFree(pScannerPriv->pubIDStr);
+ smlLibFree(pScannerPriv);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: nextTok
+ *
+ * Get next token. Description see XltDecAll.h.
+ */
+static Ret_t
+_nextTok(XltDecScannerPtr_t pScanner)
+{
+ xmlScannerPrivPtr_t pScannerPriv;
+ Ret_t rc;
+
+ pScannerPriv = (xmlScannerPrivPtr_t)pScanner;
+
+ pScannerPriv->curtok->start = pScannerPriv->pos;
+
+ skipS(pScannerPriv);
+
+ /* skip unsupported elements until we find a supported one */
+ rc = 0;
+
+
+ while (!rc) {
+ if (smlLibStrncmp((String_t)pScannerPriv->pos, "<!--", 4) == 0) {
+ rc = xmlSkipComment(pScannerPriv);
+ } else if (smlLibStrncmp((String_t)pScannerPriv->pos, "<?", 2) == 0) {
+ rc = xmlSkipPI(pScannerPriv);
+ } else if (smlLibStrncmp((String_t)pScannerPriv->pos, "</", 2) == 0) {
+ rc = xmlTag(pScannerPriv, 1);
+ break;
+ } else if (smlLibStrncmp((String_t)pScannerPriv->pos, "<![CDATA[", 9) == 0) {
+ rc = xmlCDATA(pScannerPriv);
+ break;
+ } else if ((isPcdata(pScannerPriv->curtok->tagid)) && (pScannerPriv->curtok->type != TOK_TAG_END)) {
+ rc = xmlSkipPCDATA(pScannerPriv);
+ break;
+ } else if (smlLibStrncmp((String_t)pScannerPriv->pos, "<", 1) == 0) {
+ rc = xmlTag(pScannerPriv, 0);
+ break;
+ } else {
+ rc = xmlCharData(pScannerPriv);
+ break;
+ }
+ }
+ if (rc)
+ return rc;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: pushTok
+ *
+ * Reset the scanner to the starting position of the current token within
+ * the buffer. Description see XltDecAll.h.
+ */
+static Ret_t _pushTok(XltDecScannerPtr_t pScanner)
+{
+ xmlScannerPrivPtr_t pScannerPriv;
+
+ pScannerPriv = (xmlScannerPrivPtr_t)pScanner;
+ pScannerPriv->pos = pScannerPriv->curtok->start;
+
+ /* invalidate curtok */
+ /* T.K. Possible Error. pScannerPriv->curtok is of type XltDecToken_t NOT ...Ptr_t */
+ // OrigLine:
+ // smlLibMemset(pScannerPriv->curtok, 0, sizeof(XltDecTokenPtr_t));
+ pScannerPriv->curtok->type = (XltTokType_t)0;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: setBuf
+ *
+ * Set the working buffer of the scanner.
+ */
+static void
+_setBuf(XltDecScannerPtr_t pScanner, const MemPtr_t pBufStart,
+ const MemPtr_t pBufEnd)
+{
+ xmlScannerPrivPtr_t pScannerPriv = (xmlScannerPrivPtr_t)pScanner;
+ pScannerPriv->pos = pBufStart;
+ pScannerPriv->bufend = pBufEnd;
+}
+
+/**
+ * FUNCTION: getPos
+ *
+ * Get the current position of the scanner within its working buffer.
+ */
+static MemPtr_t
+_getPos(XltDecScannerPtr_t pScanner)
+{
+ return ((xmlScannerPrivPtr_t)pScanner)->pos;
+}
+
+
+
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+/**
+ * FUNCTION: readBytes
+ *
+ * Advance the position pointer. Description see above.
+ */
+static Boolean_t
+readBytes(xmlScannerPrivPtr_t pScanner, Long_t bytes)
+{
+ if (pScanner->pos + bytes > pScanner->bufend) {
+ pScanner->finished = 1;
+ return 0;
+ }
+ pScanner->pos += bytes;
+ return 1;
+}
+
+/**
+ * FUNCTION: skipS
+ *
+ * Skip whitespace.
+ */
+static void skipS(xmlScannerPrivPtr_t pScanner)
+{
+ for (;;) {
+ switch (*pScanner->pos) {
+ case 9: /* tab stop */
+ case 10: /* line feed */
+ case 13: /* carriage return */
+ case 32: /* space */
+ // %%% luz: 2001-07-03: added exit from loop if no more bytes
+ if (!readBytes(pScanner, 1)) return;
+ break;
+ default:
+ return;
+ }
+ }
+}
+
+/**
+ * FUNCTION: xmlProlog
+ *
+ * Scan the XML prolog (might be empty...).
+ */
+static Ret_t
+xmlProlog(xmlScannerPrivPtr_t pScanner)
+{
+ Ret_t rc;
+
+ skipS(pScanner);
+
+ if (pScanner->pos + 5 > pScanner->bufend)
+ return SML_ERR_OK;
+ if (smlLibStrncmp((String_t)pScanner->pos, "<?xml", 5) == 0)
+ if ((rc = xmlXMLDecl(pScanner)) != SML_ERR_OK)
+ return rc;
+
+ skipS(pScanner);
+
+ while ((pScanner->pos + 4 <= pScanner->bufend) &&
+ ((smlLibStrncmp((String_t)pScanner->pos, "<!--", 4) == 0) ||
+ (smlLibStrncmp((String_t)pScanner->pos, "<?", 2) == 0))) {
+ if (smlLibStrncmp((String_t)pScanner->pos, "<!--", 4) == 0)
+ rc = xmlSkipComment(pScanner);
+ else
+ rc = xmlSkipPI(pScanner);
+ if (rc != SML_ERR_OK)
+ return rc;
+ skipS(pScanner);
+ }
+
+ if ((pScanner->pos + 9 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "<!DOCTYPE", 9) == 0))
+ if ((rc = xmlDocTypeDecl(pScanner)) != SML_ERR_OK)
+ return rc;
+
+ skipS(pScanner);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlDocTypeDecl
+ *
+ * Part of the Prolog scanning
+ */
+static Ret_t
+xmlDocTypeDecl(xmlScannerPrivPtr_t pScanner)
+{
+ Ret_t rc;
+ String_t name = NULL;
+ String_t syslit = NULL;
+ String_t publit = NULL;
+
+ readBytes(pScanner, 9);
+ skipS(pScanner);
+ if ((rc = xmlName(pScanner, &name)) != SML_ERR_OK) {
+ smlLibFree(name);
+ return rc;
+ }
+ skipS(pScanner);
+
+ /* parse ExternalID */
+ if ((pScanner->pos + 6 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "SYSTEM", 6) == 0)) {
+ readBytes(pScanner, 6);
+ skipS(pScanner);
+ if ((rc = xmlStringConst(pScanner, &syslit)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(syslit);
+ return rc;
+ }
+ } else if ((pScanner->pos + 6 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "PUBLIC", 6) == 0)) {
+ readBytes(pScanner, 6);
+ skipS(pScanner);
+ if ((rc = xmlStringConst(pScanner, &publit)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(publit);
+ return rc;
+ }
+ skipS(pScanner);
+ if ((rc = xmlStringConst(pScanner, &syslit)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(syslit);
+ smlLibFree(publit);
+ return rc;
+ }
+ }
+
+ smlLibFree(name);
+ smlLibFree(syslit);
+ smlLibFree(publit);
+
+ skipS(pScanner);
+
+ if (*pScanner->pos != '>')
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ readBytes(pScanner, 1);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlXMLDecl
+ *
+ * Part of the Prolog scanning
+ */
+static Ret_t
+xmlXMLDecl(xmlScannerPrivPtr_t pScanner)
+{
+ String_t name, value;
+ Ret_t rc;
+
+ readBytes(pScanner, 5);
+ skipS(pScanner);
+
+ /* mandatory version info */
+ if ((rc = xmlAttribute(pScanner, &name, &value)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(value);
+ return rc;
+ }
+ if (smlLibStrcmp(name, "version") != 0) {
+ smlLibFree(name);
+ smlLibFree(value);
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ smlLibFree(name);
+ smlLibFree(value);
+
+ skipS(pScanner);
+
+ /* optional attributes are encoding and standalone */
+ while ((pScanner->pos + 2 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "?>", 2) != 0)) {
+ if ((rc = xmlAttribute(pScanner, &name, &value)) != SML_ERR_OK) {
+ smlLibFree(name);
+ smlLibFree(value);
+ return rc;
+ }
+ smlLibFree(name);
+ smlLibFree(value);
+ skipS(pScanner);
+ }
+
+ if (pScanner->pos + 2 > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ readBytes(pScanner, 2);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlAttribute
+ *
+ * Handle Attributes //function can be used if attributes get necessary
+ */
+static Ret_t
+xmlAttribute(xmlScannerPrivPtr_t pScanner, String_t *name, String_t *value)
+{
+ Ret_t rc;
+
+ skipS(pScanner);
+
+ if ((rc = xmlName(pScanner, name)) != SML_ERR_OK)
+ return rc;
+
+ skipS(pScanner);
+
+ /* no attributes found, because this tag has none -> bail out */
+ if (*pScanner->pos == '>') {
+ return SML_ERR_XLT_MISSING_CONT;
+ }
+ if (smlLibStrncmp((String_t)pScanner->pos, "/>", 2) == 0) {
+ return SML_ERR_XLT_MISSING_CONT;
+ }
+
+ if (*pScanner->pos != '=') {
+ smlLibFree(*name);
+ *name = NULL;
+ *value = NULL;
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ readBytes(pScanner, 1);
+
+ skipS(pScanner);
+
+ if ((rc = xmlStringConst(pScanner, value)) != SML_ERR_OK) {
+ smlLibFree(*name);
+ *name = NULL;
+ *value = NULL;
+ return rc;
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlStringConst
+ *
+ * Handle Pcdata String Constants
+ */
+static Ret_t
+xmlStringConst(xmlScannerPrivPtr_t pScanner, String_t *value)
+{
+ String_t end;
+ int len;
+ char del;
+
+ if ((*pScanner->pos != '"') && (*pScanner->pos != '\'')) {
+ *value = NULL;
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ del = *pScanner->pos;
+ readBytes(pScanner, 1);
+
+ if ((end = smlLibStrchr((String_t)pScanner->pos, del)) == NULL) {
+ *value = NULL;
+
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ len = end - (String_t)pScanner->pos;
+ if ((*value = (String_t)smlLibMalloc(len + 1)) == NULL)
+ {
+
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(*value, 0, len + 1);
+ smlLibStrncpy(*value, (String_t)pScanner->pos, len);
+ readBytes(pScanner, len + 1);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlStringConst
+ *
+ * Handle escaped characters
+ */
+static void
+xmlReadEscape(String_t buffer, MemPtr_t instring, int *instr_len)
+{
+int len= *instr_len;
+
+ while (len !=0)
+ {
+ if(*instring != '&')
+ { *buffer ++ = *instring++;
+ len--;
+ }
+ else
+ {
+ instring++;
+ len--;
+
+ if(len>1)
+ {
+
+ Boolean_t found =0;
+ unsigned int i=0;
+ for (i = 0; escape_char_table[i].escape_str != NULL; i++)
+ {
+ unsigned int str_len=smlLibStrlen( escape_char_table[i].escape_str);
+ if (smlLibStrncmp((String_t)instring, escape_char_table[i].escape_str, str_len) == 0)
+ {
+ *buffer++ =escape_char_table[i].token;
+ instring += str_len;
+ len -=str_len;
+ found = 1;
+ *instr_len-= str_len;
+ break;
+ }
+ }
+ if(found==0)
+ {
+ *buffer++ = '&';
+ }
+ }
+ else
+ {
+ *buffer++ = '&';
+ }
+
+ }
+ }
+}
+
+/**
+ * FUNCTION: xmlCharData
+ *
+ * Handle Pcdata character data content
+ */
+static Ret_t
+xmlCharData(xmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPCData;
+ MemPtr_t begin;
+ int len;
+
+
+ pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+ if (pPCData == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ pPCData->contentType = SML_PCDATA_UNDEFINED;
+ pPCData->length = 0;
+ pPCData->content = NULL;
+
+ begin = pScanner->pos;
+
+ if (pScanner->pos >= pScanner->bufend) {
+ pPCData->content = NULL;
+ pPCData->contentType = SML_PCDATA_UNDEFINED;
+ pPCData->extension = SML_EXT_UNDEFINED;
+ pPCData->length = 0;
+ pScanner->curtok->type = TOK_CONT;
+ pScanner->curtok->pcdata = pPCData;
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+
+ while (*pScanner->pos != '<') /* && (*pScanner->pos != '&') */
+ {
+ if (pScanner->pos >= pScanner->bufend)
+ {
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (!readBytes(pScanner, 1)) {
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+
+ }
+ len = pScanner->pos - begin;
+ pPCData->content = smlLibMalloc(len + 1);
+ if (pPCData->content == NULL){
+ smlLibFree(pPCData);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pPCData->content, 0, len + 1);
+ xmlReadEscape(pPCData->content, begin, &len);
+ pPCData->contentType = SML_PCDATA_STRING;
+ pPCData->length = len;
+
+ pScanner->curtok->type = TOK_CONT;
+ pScanner->curtok->pcdata = pPCData;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlName
+ *
+ * Handle Name Elements
+ */
+static Ret_t
+xmlName(xmlScannerPrivPtr_t pScanner, String_t *name)
+{
+ MemPtr_t begin;
+ String_t tmp;
+ int len;
+
+ begin = pScanner->pos;
+ while (((*pScanner->pos >= 'a') && (*pScanner->pos <= 'z')) ||
+ ((*pScanner->pos >= 'A') && (*pScanner->pos <= 'Z')) ||
+ ((*pScanner->pos >= '0') && (*pScanner->pos <= '9')) ||
+ (*pScanner->pos == '.') || (*pScanner->pos == '-') ||
+ (*pScanner->pos == '_') || (*pScanner->pos == ':'))
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ len = pScanner->pos - begin;
+ /* T.K. bail out if len is zero without modifying name */
+ if (len == 0) return SML_ERR_OK;
+
+
+ tmp = (String_t)smlLibMalloc(len + 1);
+ if (tmp == NULL) {
+ *name = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(tmp, 0, len + 1);
+ smlLibStrncpy(tmp, (String_t)begin, len);
+ *name = tmp;
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlTag
+ *
+ * Handle XML Tags
+ */
+static Ret_t
+xmlTag(xmlScannerPrivPtr_t pScanner, Byte_t endtag)
+{
+ Ret_t rc;
+ String_t name = NULL, attname=NULL, value = NULL, nsprefix = NULL;
+ Byte_t nsprelen = 0;
+ XltTagID_t tagid;
+ SmlPcdataExtension_t ext;
+
+
+ if (endtag) {
+ if (!readBytes(pScanner, 2))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ } else {
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+
+ if ((rc = xmlName(pScanner, &name)) != SML_ERR_OK)
+ {
+ if (rc != SML_ERR_NOT_ENOUGH_SPACE)
+ {
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ else
+ {
+ return rc;
+ }
+
+ }
+
+ //DP: case for corrupted xml file
+ if ( !name )
+ return SML_ERR_XLT_INVAL_XML_DOC;
+
+ ext = pScanner->ext;
+ if (!endtag) {
+ /* Namespaces can only be defined on start, never on endtags
+ * but we have to make sure we close a namespace on the corrsponding endtag.
+ * Thats why we a) only open a namespace when it differs from the previous one, and
+ * b) record the tag_id that opend the namespace so we can close it when the
+ * corresponding endtag is reached.
+ */
+
+ if ((rc = xmlAttribute(pScanner, &attname, &value)) == SML_ERR_OK)
+ {
+ if (smlLibStrncmp(attname, "xmlns", 5) == 0) {
+ /* Heureka we found a Namespace :-) */
+ /* It's save to check attname[5] here, as it contains at least the terminating '\000' */
+ if (attname[5] == ':') { /* we found a namespace prefixdefinition */
+ nsprelen = (Byte_t)smlLibStrlen(&attname[6]);
+ nsprefix = smlLibMalloc(nsprelen+1);
+ if (nsprefix == NULL) {
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibStrcpy(nsprefix,&attname[6]);
+ }
+ ext = getExtByName(value);
+ if (ext == 255) {
+ smlLibFree(nsprefix); /* doesn't harm, even when empty */
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ return SML_ERR_XLT_INVALID_CODEPAGE;
+ }
+ else
+ {
+ if (smlLibStrncmp(value, "SYNCML:", 7) == 0)
+ {
+ if ( smlLibStrcmp(XPL_DM_GetEnv(SYNCML_DM_VERSION), "1.2")==0)
+ {
+ if (smlLibStrncmp(value+7, "SYNCML1.2", 9) != 0)
+ {
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ smlLibFree(nsprefix);
+
+ return SML_ERR_XLT_INVALID_CODEPAGE;
+ }
+ }
+ else if (smlLibStrncmp(value+7, "SYNCML1.1", 9) != 0)
+ {
+ if (smlLibStrncmp(value+7, "SYNCML1.1", 9) != 0)
+ {
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ smlLibFree(nsprefix);
+ return SML_ERR_XLT_INVALID_CODEPAGE;
+ }
+ }
+ }
+ }
+ } else {
+ if (rc == SML_ERR_NOT_ENOUGH_SPACE){
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(name);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ else{
+ /* we found an unknown attribute -> bail out */
+ smlLibFree(attname);
+ smlLibFree(value);
+ /* nsprefix is empty here so we save us a function call */
+ smlLibFree(name);
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ }
+
+ }
+ else if ( rc != SML_ERR_XLT_MISSING_CONT)
+ {
+ /* xmlAttribute returns an SML_ERR_XLT_MISSING_CONT error when
+ * no attribute was found. This is not an error, but everything else is.
+ */
+ smlLibFree(value);
+ smlLibFree(name);
+ return rc;
+ }
+
+
+ }
+
+
+ if (pScanner->ext == ext) {
+ /* no new Namespace found - lets proceed with the active one */
+
+ /* first lets check wether a tag is in the right namespace, in case
+ * we are using namespaces with prefix notation ('mi:Format' instead of
+ * 'Format nsattr="...").
+ * If we are and the token is not in this namespace -> bail out
+ */
+ if (pScanner->nsprelen > 0 && smlLibStrlen(name) > pScanner->nsprelen+1) {
+ if (name[pScanner->nsprelen] != ':' || smlLibStrncmp(name,pScanner->nsprefix, pScanner->nsprelen) != 0) {
+ smlLibFree(name);
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(nsprefix);
+ return SML_ERR_XLT_NO_MATCHING_CODEPAGE;
+ }
+ }
+ /* Strip off namespace prefixes and ':' to find the tag.
+ * If no prefix is defined (pScanner->nsprelen == 0) take the whole tagname.
+ */
+ if (pScanner->nsprelen > 0)
+ rc = getTagIDByStringAndExt(&name[0+pScanner->nsprelen+1], pScanner->ext, &tagid);
+ else
+ rc = getTagIDByStringAndExt(name, pScanner->ext, &tagid);
+ } else {
+ /* we have a new Namespace */
+ if (nsprelen > 0 && smlLibStrlen(name) > nsprelen+1) {
+ if (name[nsprelen] != ':' || smlLibStrncmp(name,nsprefix, nsprelen) != 0) {
+ smlLibFree(name);
+ smlLibFree(attname);
+ smlLibFree(value);
+ smlLibFree(nsprefix);
+ return SML_ERR_XLT_NO_MATCHING_CODEPAGE;
+ }
+ }
+ /* Strip off namespace prefixes and ':' to find the tag.
+ * If no prefix is defined (pScanner->nsprelen == 0) take the whole tagname.
+ */
+ if (nsprelen > 0)
+ rc = getTagIDByStringAndExt(&name[nsprelen+1], ext, &tagid);
+ else
+ rc = getTagIDByStringAndExt(name, ext, &tagid);
+ }
+ /* free temporary buffers */
+ smlLibFree(name);
+ smlLibFree(attname);
+ smlLibFree(value);
+
+ if ((tagid == TN_UNDEF) || (rc != SML_ERR_OK)) {
+ smlLibFree(nsprefix);
+ return rc;
+ }
+
+ /* remember the old extension including the corresponding start tag if we found a new one */
+ if (ext != pScanner->ext) { /* namespace changed */
+ pScanner->prev_ext = pScanner->ext; /* remember the old ext */
+ pScanner->prev_ext_tag = pScanner->ext_tag; /* and the corresponding start tag */
+ pScanner->ext = ext;
+ pScanner->ext_tag = tagid;
+ smlLibFree(pScanner->nsprefix);
+ pScanner->nsprefix = nsprefix;
+ pScanner->nsprelen = nsprelen;
+ }
+
+
+ pScanner->curtok->tagid = tagid;
+ pScanner->curtok->ext = pScanner->ext;
+ skipS(pScanner);
+
+ if (endtag) {
+ /* found end tag */
+ if (smlLibStrncmp((String_t)pScanner->pos, ">", 1) != 0)
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ pScanner->curtok->type = TOK_TAG_END;
+ readBytes(pScanner, 1);
+ /* in case of an endtag we might need to close the current CP */
+ if (tagid == pScanner->ext_tag) {
+ pScanner->ext_tag = pScanner->prev_ext_tag;
+ pScanner->ext = pScanner->prev_ext;
+ pScanner->prev_ext = SML_EXT_UNDEFINED;
+ pScanner->prev_ext_tag = TN_UNDEF;
+ pScanner->nsprelen = 0;
+ smlLibFree(pScanner->nsprefix);
+ pScanner->nsprefix = NULL;
+ }
+ } else {
+ /* Attributes are not supported in SyncML -> skip them*/
+ if ((rc = xmlSkipAttributes(pScanner)) != SML_ERR_OK) return rc;
+
+ if (smlLibStrncmp((String_t)pScanner->pos, "/>", 2) == 0) {
+ /* found empty tag */
+ pScanner->curtok->type = TOK_TAG_EMPTY;
+ readBytes(pScanner, 2);
+ } else if (smlLibStrncmp((String_t)pScanner->pos, ">", 1) == 0) {
+ pScanner->curtok->type = TOK_TAG_START;
+ readBytes(pScanner, 1);
+ } else {
+ return SML_ERR_XLT_INVAL_XML_DOC;
+ }
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlSkipPI
+ *
+ * Skip PI elements
+ */
+static Ret_t
+xmlSkipPI(xmlScannerPrivPtr_t pScanner)
+{
+ if (pScanner) { /* Get rid of warning, this should not be called anyway */
+ }
+
+ return SML_ERR_UNSPECIFIC;
+}
+
+/**
+ * FUNCTION: xmlSkipComment
+ *
+ * Skip comments
+ */
+static Ret_t
+xmlSkipComment(xmlScannerPrivPtr_t pScanner)
+{
+ readBytes(pScanner, 4);
+
+ while ((pScanner->pos + 3 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, "-->", 3) != 0))
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+
+ if (pScanner->pos + 3 > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ if (!readBytes(pScanner, 3))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ skipS(pScanner);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlSkipAttributes
+ *
+ * Skip attributes -> they are not supported in SyncML
+ */
+static Ret_t
+xmlSkipAttributes(xmlScannerPrivPtr_t pScanner)
+{
+
+ while ((pScanner->pos + 1 <= pScanner->bufend) &&
+ (smlLibStrncmp((String_t)pScanner->pos, ">", 1)) && (smlLibStrncmp((String_t)pScanner->pos, "/>", 2)))
+ if (!readBytes(pScanner, 1))
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+
+ if (pScanner->pos + 1 > pScanner->bufend)
+ return SML_ERR_XLT_END_OF_BUFFER;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlCDATA
+ *
+ * Handle a CDATA content
+ */
+static Ret_t
+xmlCDATA(xmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPCData;
+ MemPtr_t begin;
+ int len;
+
+ readBytes(pScanner, 9);
+
+ pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+ if (pPCData == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ pPCData->contentType = SML_PCDATA_UNDEFINED;
+ pPCData->length = 0;
+ pPCData->content = NULL;
+
+ begin = pScanner->pos;
+ while (!((pScanner->pos[0] == ']') && (pScanner->pos[1] == ']') && (pScanner->pos[2] == '>')))
+ {
+ if (!readBytes(pScanner, 1))
+ {
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ }
+
+ len = pScanner->pos - begin;
+ pPCData->content = smlLibMalloc(len + 1);
+ if (pPCData->content == NULL) {
+ smlLibFree(pPCData);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ smlLibMemset(pPCData->content, 0, len + 1);
+ smlLibMemcpy(pPCData->content, begin, len);
+ pPCData->contentType = SML_PCDATA_CDATA;
+ pPCData->length = len;
+
+ pScanner->curtok->type = TOK_CONT;
+ pScanner->curtok->pcdata = pPCData;
+
+ readBytes(pScanner, 3);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xmlSkipPCDATA
+ *
+ * Read over a Pcdata content
+ */
+static Ret_t
+xmlSkipPCDATA(xmlScannerPrivPtr_t pScanner)
+{
+ SmlPcdataPtr_t pPCData;
+ MemPtr_t begin;
+ int len;
+ Ret_t rc;
+ String_t _tagString = NULL;
+ String_t _tagString2 = NULL;
+
+ /* Check wether this PCData might contain a subdtd.
+ ** We assume a Sub DTD starts with '<' as first char.
+ ** If this char is present start further processing else
+ ** take it as pure String data. If the scanning returns an
+ ** error we reject the file, as '<' is not a valid char inside
+ ** PCData elements.
+ */
+ if (smlLibStrncmp((String_t)pScanner->pos, "<", 1) == 0) {
+ rc = xmlTag(pScanner, 0);
+ return rc;
+ }
+
+ _tagString = smlLibMalloc(XML_MAX_TAGLEN);
+ if (_tagString == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ if ((rc = getTagString(pScanner->curtok->tagid, _tagString, pScanner->curtok->ext)) != SML_ERR_OK)
+ {
+ smlLibFree(_tagString);
+ return rc;
+ }
+
+ _tagString2 = smlLibMalloc(smlLibStrlen(_tagString) + 4 + (pScanner->nsprelen +1));
+
+ // build a end tag String to compate (e.g. </Meta>)
+ // beware of possible namespace prefixes
+ if (_tagString2 == NULL)
+ {
+ smlLibFree(_tagString);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ _tagString2 = smlLibStrcpy(_tagString2,"</");
+ if (pScanner->nsprelen > 0) {
+ _tagString2 = smlLibStrcat(_tagString2,pScanner->nsprefix);
+ _tagString2 = smlLibStrcat(_tagString2,":");
+ }
+ _tagString2 = smlLibStrcat(_tagString2,_tagString);
+ _tagString2 = smlLibStrcat(_tagString2,">");
+ smlLibFree(_tagString);
+
+ pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t));
+
+
+
+ if (pPCData == NULL)
+ {
+ smlLibFree(_tagString2);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ pPCData->contentType = SML_PCDATA_UNDEFINED;
+ pPCData->extension = SML_EXT_UNDEFINED;
+ pPCData->length = 0;
+ pPCData->content = NULL;
+
+ begin = pScanner->pos;
+
+ // read Pcdata content until end tag appears
+ len = smlLibStrlen(_tagString2);
+ while (smlLibStrncmp((String_t)pScanner->pos, _tagString2, len) != 0)
+ {
+ if ((pScanner->pos + len) >= pScanner->bufend)
+ {
+ smlLibFree(_tagString2);
+ smlLibFree(pPCData);
+ pScanner->curtok->pcdata = NULL;
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (!readBytes(pScanner, 1))
+ {
+ smlLibFree(pPCData);
+ return SML_ERR_XLT_END_OF_BUFFER;
+ }
+ }
+
+ smlLibFree(_tagString2);
+
+ len = pScanner->pos - begin;
+ pPCData->content = smlLibMalloc(len + 1);
+ if (pPCData->content == NULL)
+ {
+ smlLibFree(pPCData);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+
+ smlLibMemset(pPCData->content, 0, len + 1);
+ xmlReadEscape(pPCData->content, begin, &len);
+
+ pPCData->contentType = SML_PCDATA_STRING;
+ pPCData->length = len;
+
+ pScanner->curtok->type = TOK_CONT;
+ pScanner->curtok->pcdata = pPCData;
+
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: isPcdata
+ *
+ * Check if the current tag id represents a Pcdata element
+ */
+Boolean_t isPcdata(XltTagID_t tagid)
+{
+ switch (tagid)
+ {
+ case TN_CMD:
+ case TN_CMDID:
+ case TN_CORRELATOR:
+ case TN_CMDREF:
+ case TN_LANG:
+ case TN_LOCNAME:
+ case TN_LOCURI:
+ case TN_MSGID:
+ case TN_MSGREF:
+ case TN_RESPURI:
+ case TN_SESSIONID:
+ case TN_SOURCEREF:
+ case TN_TARGETREF:
+ case TN_VERSION:
+ case TN_PROTO:
+ case TN_DATA:
+ case TN_META:
+ case TN_NUMBEROFCHANGES:
+#ifdef __USE_METINF__
+ case TN_METINF_EMI:
+ case TN_METINF_FORMAT:
+ case TN_METINF_FREEID:
+ case TN_METINF_FREEMEM:
+ case TN_METINF_LAST:
+ case TN_METINF_MARK:
+ case TN_METINF_MAXMSGSIZE:
+ /* SCTSTK - 18/03/2002 S.H. 2002-04-05 : SyncML 1.1 */
+ case TN_METINF_MAXOBJSIZE:
+ case TN_METINF_NEXT:
+ case TN_METINF_NEXTNONCE:
+ case TN_METINF_SIZE:
+ case TN_METINF_TYPE:
+ case TN_METINF_VERSION:
+#endif
+#ifdef __USE_DEVINF__
+ case TN_DEVINF_MAN:
+ case TN_DEVINF_MOD:
+ case TN_DEVINF_OEM:
+ case TN_DEVINF_FWV:
+ case TN_DEVINF_SWV:
+ case TN_DEVINF_HWV:
+ case TN_DEVINF_DEVID:
+ case TN_DEVINF_DEVTYP:
+ case TN_DEVINF_MAXGUIDSIZE:
+ case TN_DEVINF_SOURCEREF:
+ case TN_DEVINF_DISPLAYNAME:
+ case TN_DEVINF_CTTYPE:
+ case TN_DEVINF_DATATYPE:
+ case TN_DEVINF_SIZE:
+ case TN_DEVINF_PROPNAME:
+ case TN_DEVINF_VALENUM:
+ case TN_DEVINF_PARAMNAME:
+ case TN_DEVINF_SYNCTYPE:
+ case TN_DEVINF_XNAM:
+ case TN_DEVINF_XVAL:
+ case TN_DEVINF_MAXMEM:
+ case TN_DEVINF_MAXID:
+ case TN_DEVINF_VERCT:
+ case TN_DEVINF_VERDTD:
+#endif
+#ifdef __USE_DMTND__
+ case TN_DMTND_AccessType: // TND->Node->DFProps
+ case TN_DMTND_ACL: // TND->Node->RTProps
+ case TN_DMTND_Add: // TND->Node->DFProps->AccessType
+ case TN_DMTND_b64: // TND->Node->RTProps->Format
+ case TN_DMTND_bin: // TND->Node->RTProps->Format
+ case TN_DMTND_bool: // TND->Node->RTProps->Format
+ case TN_DMTND_chr: // TND->Node->RTProps->Format
+ // case TN_DMTND_CaseSense: // TND->Node->DFProps
+ case TN_DMTND_CIS: // TND->Node->DFProps->CaseSense
+ case TN_DMTND_Copy: // TND->Node->DFProps->AccessType
+ case TN_DMTND_CS: // TND->Node->DFProps->CaseSense
+ case TN_DMTND_date: // TND->Node->RTProps->Format
+ case TN_DMTND_DDFName: // TND->Node->RTProps->Type
+ case TN_DMTND_DefaultValue: // TND->Node->DFProps
+ case TN_DMTND_Delete: // TND->Node->DFProps->AccessType
+ case TN_DMTND_Description: // TND->Node->DFProps
+ case TN_DMTND_DFFormat: // TND->Node->DFProps
+ // case TN_DMTND_DFProperties: // TND->Node
+ case TN_DMTND_DFTitle: // TND->Node->DFProps
+ case TN_DMTND_DFType: // TND->Node->DFProps
+ // case TN_DMTND_Dynamic: // TND->Node->DFProps->Scope
+ case TN_DMTND_Exec: // TND->Node->DFProps->AccessType
+ case TN_DMTND_float: // TND->Node->RTProps->Format
+ // case TN_DMTND_Format: // TND->Node->RTProps:
+ case TN_DMTND_Get: // TND->Node->DFProps->AccessType
+ case TN_DMTND_int: // TND->Node->RTProps->Format
+ case TN_DMTND_Man: // TND
+ // case TN_DMTND_MgmtTree:
+ case TN_DMTND_MIME: // TND->Node->RTProps->Type
+ case TN_DMTND_Mod: // TND
+ case TN_DMTND_Name: // TND->Node->RTProps
+ // case TN_DMTND_Node: // TND
+ case TN_DMTND_node: // TND->Node->RTProps->Format
+ case TN_DMTND_NodeName: // TND->Node
+ case TN_DMTND_null: // TND->Node->RTProps->Format
+ // case TN_DMTND_Occurrence: // TND->Node->DFProps
+ case TN_DMTND_One: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_OneOrMore: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_OneOrN: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_Path: // TND->Node
+ case TN_DMTND_Permanent: // TND->Node->DFProps->Scope
+ case TN_DMTND_Replace: // TND->Node->DFProps->AccessType
+ // case TN_DMTND_RTProperties: // TND->Node
+ // case TN_DMTND_Scope: // TND->Node->DFProps
+ case TN_DMTND_Size: // TND->Node->RTProps
+ case TN_DMTND_time: // TND->Node->RTProps->Format
+ case TN_DMTND_Title: // TND->Node->RTProps
+ case TN_DMTND_TStamp: // TND->Node->RTProps
+ // case TN_DMTND_Type: // TND->Node->RTProps->Type
+ case TN_DMTND_Value: // TND
+ case TN_DMTND_VerDTD: // TND
+ case TN_DMTND_VerNo: // TND->Node->RTProps
+ case TN_DMTND_xml: // TND->Node->RTProps->Format
+ case TN_DMTND_ZeroOrMore: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_ZeroOrN: // TND->Node->DFProps->Occurrence
+ case TN_DMTND_ZeroOrOne:// TND->Node->DFProps->Occurrence
+#endif
+ return 1;
+ default:
+ return 0;
+ }
+}
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltdevinf.c b/engine/dmlib/dmengine/oma_toolkit/src/xltdevinf.c
new file mode 100644
index 0000000..2099b18
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltdevinf.c
@@ -0,0 +1,991 @@
+/*************************************************************************/
+/* module: DeviceInf DTD related functions for the en-/decoder */
+/* file: xltdevinf.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#include "define.h"
+#ifdef __USE_DEVINF__
+
+#include "smldevinfdtd.h"
+#include "xlttags.h"
+#include "xltdevinf.h"
+#include "xlttagtbl.h"
+#include "xltenc.h"
+#include "xltencwbxml.h"
+
+#include <libstr.h>
+#include <smlerr.h>
+#include <smldtd.h>
+#include <libmem.h>
+#include <libutil.h>
+
+/* decoder callbacks */
+Ret_t buildDevInfDevInfContent(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+
+
+Ret_t buildDevInfDevInfCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ KCDBG("buildDevInfDevInfCmd: Enter\n");
+
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfDevInfPtr_t pElem = NULL;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_DEVINF:
+ rc = buildDevInfDevInfContent(pDecoder, (VoidPtr_t)&pElem);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ *ppElem = pElem;
+
+ KCDBG("buildDevInfDevInfCmd: Leave\n");
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfDevInfContent(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfDevInfPtr_t pElem;
+ Ret_t rc;
+ /* Modified by Tomy to allow <UTC></UTC>, <SupportNumberOfChanges></SupportNumberOfChanges> and <SupportLargeObjs></SupportLargeObjs> */
+ SmlPcdataPtr_t tmp_ptr;
+ /* End modified by Tomy */
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfDevInfPtr_t)smlLibMalloc(sizeof(SmlDevInfDevInf_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfDevInf_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_VERDTD:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->verdtd);
+ break;
+ case TN_DEVINF_MAN:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->man);
+ break;
+ case TN_DEVINF_MOD:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->mod);
+ break;
+ case TN_DEVINF_OEM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->oem);
+ break;
+ case TN_DEVINF_FWV:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->fwv);
+ break;
+ case TN_DEVINF_SWV:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->swv);
+ break;
+ case TN_DEVINF_HWV:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->hwv);
+ break;
+ case TN_DEVINF_DEVID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->devid);
+ break;
+ case TN_DEVINF_DEVTYP:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->devtyp);
+ break;
+ case TN_DEVINF_DATASTORE:
+ rc = buildDevInfDataStoreList(pDecoder, (VoidPtr_t)&pElem->datastore);
+ break;
+ case TN_DEVINF_CTCAP:
+ rc = buildDevInfCtcap(pDecoder, (VoidPtr_t)&pElem->ctcap);
+ break;
+ case TN_DEVINF_EXT:
+ rc = buildDevInfExtList(pDecoder, (VoidPtr_t)&pElem->ext);
+ break;
+ /* SCTSTK - 18/03/2002 S.H. 2002-04-05 : SyncML 1.1 */
+ case TN_DEVINF_UTC:
+ pElem->flags |= SmlDevInfUTC_f;
+ /* Modified by Tomy to allow <UTC></UTC> */
+ tmp_ptr = NULL;
+ rc = buildPCData(pDecoder, (VoidPtr_t)&tmp_ptr);
+ if (tmp_ptr->contentType != SML_PCDATA_UNDEFINED && tmp_ptr->extension != SML_EXT_UNDEFINED && tmp_ptr->length != 0 && tmp_ptr->content != NULL) rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ /* End modified by Tomy */
+ break;
+ case TN_DEVINF_NOFM:
+ pElem->flags |= SmlDevInfNOfM_f;
+ /* Modified by Tomy to allow <SupportNumberOfChanges></SupportNumberOfChanges> */
+ tmp_ptr = NULL;
+ rc = buildPCData(pDecoder, (VoidPtr_t)&tmp_ptr);
+ if (tmp_ptr->contentType != SML_PCDATA_UNDEFINED && tmp_ptr->extension != SML_EXT_UNDEFINED && tmp_ptr->length != 0 && tmp_ptr->content != NULL) rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ /* End modified by Tomy */
+ break;
+ case TN_DEVINF_LARGEOBJECT:
+ pElem->flags |= SmlDevInfLargeObject_f;
+ /* Modified by Tomy to allow <SupportLargeObjs></SupportLargeObjs> */
+ tmp_ptr = NULL;
+ rc = buildPCData(pDecoder, (VoidPtr_t)&tmp_ptr);
+ if (tmp_ptr->contentType != SML_PCDATA_UNDEFINED && tmp_ptr->extension != SML_EXT_UNDEFINED && tmp_ptr->length != 0 && tmp_ptr->content != NULL) rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ /* End modified by Tomy */
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfDataStoreCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfDatastorePtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfDatastorePtr_t)smlLibMalloc(sizeof(SmlDevInfDatastore_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfDatastore_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_DEVINF_SOURCEREF:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->sourceref);
+ break;
+ case TN_DEVINF_DISPLAYNAME:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->displayname);
+ break;
+ case TN_DEVINF_MAXGUIDSIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxguidsize);
+ break;
+ case TN_DEVINF_RXPREF:
+ rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->rxpref);
+ break;
+ case TN_DEVINF_TXPREF:
+ rc = buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->txpref);
+ break;
+ case TN_DEVINF_RX:
+ rc = buildDevInfXmitList(pDecoder, (VoidPtr_t)&pElem->rx);
+ break;
+ case TN_DEVINF_TX:
+ rc = buildDevInfXmitList(pDecoder, (VoidPtr_t)&pElem->tx);
+ break;
+ case TN_DEVINF_DSMEM:
+ rc = buildDevInfDSMemCmd(pDecoder, (VoidPtr_t)&pElem->dsmem);
+ break;
+ case TN_DEVINF_SYNCCAP:
+ rc = buildDevInfSyncCapCmd(pDecoder, (VoidPtr_t)&pElem->synccap);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfXmitCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfXmitPtr_t pXmit;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pXmit = (SmlDevInfXmitPtr_t)smlLibMalloc(sizeof(SmlDevInfXmit_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pXmit, 0, sizeof(SmlDevInfXmit_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pXmit;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pXmit);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_DEVINF_CTTYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->cttype);
+ break;
+ case TN_DEVINF_VERCT:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pXmit->verct);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pXmit);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pXmit);
+ return rc;
+ }
+ }
+ *ppElem = pXmit;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfXmitList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ SmlDevInfXmitListPtr_t pElem = NULL, pPrev = NULL;
+
+ pElem = (SmlDevInfXmitListPtr_t) *ppElem;
+
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pElem != NULL) {
+ pPrev = pElem;
+ pElem = pPrev->next;
+ }
+ if ((pElem = (SmlDevInfXmitListPtr_t)smlLibMalloc(sizeof(SmlDevInfXmitList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfXmitList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pElem;
+ else /* nope we created a new list */
+ *ppElem = pElem;
+ pElem->data = NULL;
+ /* at this point pElem should point to an valid list element */
+ return buildDevInfXmitCmd(pDecoder, (VoidPtr_t)&pElem->data);
+}
+
+Ret_t buildDevInfDataStoreList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ SmlDevInfDatastoreListPtr_t pElem = NULL, pPrev = NULL;
+
+ pElem = (SmlDevInfDatastoreListPtr_t) *ppElem;
+
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pElem != NULL) {
+ pPrev = pElem;
+ pElem = pPrev->next;
+ }
+ if ((pElem = (SmlDevInfDatastoreListPtr_t)smlLibMalloc(sizeof(SmlDevInfDatastoreList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfDatastoreList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pElem;
+ else /* nope we created a new list */
+ *ppElem = pElem;
+ pElem->data = NULL;
+ /* at this point pElem should point to an valid list element */
+ return buildDevInfDataStoreCmd(pDecoder, (VoidPtr_t)&pElem->data);
+}
+
+Ret_t buildDevInfExtList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ SmlDevInfExtListPtr_t pElem = NULL, pPrev = NULL;
+
+ pElem = (SmlDevInfExtListPtr_t) *ppElem;
+
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pElem != NULL) {
+ pPrev = pElem;
+ pElem = pPrev->next;
+ }
+ if ((pElem = (SmlDevInfExtListPtr_t)smlLibMalloc(sizeof(SmlDevInfExtList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfExtList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pElem;
+ else /* nope we created a new list */
+ *ppElem = pElem;
+ pElem->data = NULL;
+ /* at this point pElem should point to an valid list element */
+ return buildDevInfExtCmd(pDecoder, (VoidPtr_t)&pElem->data);
+}
+
+
+Ret_t buildDevInfCtcap(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ SmlDevInfCtcapListPtr_t pCtcap = NULL, pPrev = NULL;
+ SmlDevInfCTDataPropListPtr_t pOldProp = NULL, pProp = NULL;
+ SmlDevInfCTDataListPtr_t pOldParam = NULL, pParam = NULL;
+ SmlDevInfCtcapListPtr_t pElem = NULL;
+ XltDecScannerPtr_t pScanner;
+ Ret_t rc;
+
+ pElem = (SmlDevInfCtcapListPtr_t) *ppElem;
+ pScanner = pDecoder->scanner;
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_CTTYPE:
+ pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pCtcap != NULL) {
+ pPrev = pCtcap;
+ pCtcap = pPrev->next;
+ }
+ if ((pCtcap = (SmlDevInfCtcapListPtr_t)smlLibMalloc(sizeof(SmlDevInfCtcapList_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pCtcap, 0, sizeof(SmlDevInfCtcapList_t));
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pCtcap;
+ else /* nope we created a new list */
+ *ppElem = pCtcap;
+ pCtcap->data = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t));
+ if (pCtcap->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pCtcap->data, 0, sizeof(SmlDevInfCTCap_t));
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pCtcap->data->cttype);
+ break;
+ case TN_DEVINF_PROPNAME:
+ pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;
+ if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pCtcap->next != NULL) {
+ pPrev = pCtcap;
+ pCtcap = pCtcap->next;
+ }
+ /* here we are at the latest defined DevInfCTCapPtr_t */
+ /* now we need to create a new DevInfCTDataPtr_t element, tostore the properties name */
+ pOldProp = NULL;
+ pProp = pCtcap->data->prop;
+ while (pProp != NULL) {
+ pOldProp = pProp;
+ pProp = pProp->next;
+ }
+ pProp = (SmlDevInfCTDataPropListPtr_t) smlLibMalloc(sizeof(SmlDevInfCTDataPropList_t));
+ if (pProp == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pProp, 0, sizeof(SmlDevInfCTDataPropList_t));
+ if (pOldProp != NULL)
+ pOldProp->next = pProp;
+ else
+ pCtcap->data->prop = pProp;
+ pProp->data = (SmlDevInfCTDataPropPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataProp_t));
+ if (pProp->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pProp->data, 0, sizeof(SmlDevInfCTDataProp_t));
+ pProp->data->prop = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));
+ if (pProp->data->prop == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pProp->data->prop, 0, sizeof(SmlDevInfCTData_t));
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->name);
+ break;
+ case TN_DEVINF_PARAMNAME:
+ pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;
+ if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pCtcap->next != NULL) {
+ pPrev = pCtcap;
+ pCtcap = pCtcap->next;
+ }
+ /* here we are at the latest defined DevInfCTCapPtr_t */
+ pProp = pCtcap->data->prop;
+ if (pProp == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pProp->next != NULL) {
+ pProp = pProp->next;
+ }
+ /* here we are at the latest defined PropList Element in the latest defined CTCap element */
+ /* now lets insert a new Param element into this property */
+ pOldParam = NULL;
+ pParam = pProp->data->param;
+ while (pParam != NULL) {
+ pOldParam = pParam;
+ pParam = pParam->next;
+ }
+ pParam = (SmlDevInfCTDataListPtr_t)smlLibMalloc(sizeof(SmlDevInfCTDataList_t));
+ if (pParam == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pParam, 0, sizeof(SmlDevInfCTDataList_t));
+ if (pOldParam != NULL)
+ pOldParam->next = pParam;
+ else
+ pProp->data->param = pParam;
+ pParam->data = (SmlDevInfCTDataPtr_t)smlLibMalloc(sizeof(SmlDevInfCTData_t));
+ if (pParam->data == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pParam->data, 0, sizeof(SmlDevInfCTData_t));
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->name);
+ break;
+ case TN_DEVINF_DISPLAYNAME:
+ case TN_DEVINF_VALENUM:
+ case TN_DEVINF_DATATYPE:
+ case TN_DEVINF_SIZE:
+ /* The code for the above 4 is basically the same.
+ * The hardpart is finding the right SmlDevInfCTDataPtr_t
+ * struct, as it can be either within a Property or an Parameter.
+ */
+ pCtcap = (SmlDevInfCtcapListPtr_t) *ppElem;
+ if (pCtcap == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pCtcap->next != NULL) {
+ pCtcap = pCtcap->next;
+ }
+ /* here we are at the latest defined DevInfCTCapPtr_t */
+ pProp = pCtcap->data->prop;
+ if (pProp == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ while (pProp->next != NULL) {
+ pProp = pProp->next;
+ }
+
+ if (pProp->data == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ if (pProp->data->prop == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ if (pProp->data->param == NULL) {
+ /* No Param's yet so we have Property fields to fill */
+ switch(pScanner->curtok->tagid) {
+ case TN_DEVINF_DISPLAYNAME:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->dname);
+ break;
+ case TN_DEVINF_VALENUM:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pProp->data->prop->valenum);
+ break;
+ case TN_DEVINF_DATATYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->datatype);
+ break;
+ case TN_DEVINF_SIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pProp->data->prop->size);
+ break;
+ default:
+ break;
+ }
+ } else {
+ pParam = pProp->data->param;
+ while (pParam->next != NULL) {
+ pParam = pParam->next;
+ }
+ if (pParam->data == NULL) return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ switch(pScanner->curtok->tagid) {
+ case TN_DEVINF_DISPLAYNAME:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->dname);
+ break;
+ case TN_DEVINF_VALENUM:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pParam->data->valenum);
+ break;
+ case TN_DEVINF_DATATYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->datatype);
+ break;
+ case TN_DEVINF_SIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pParam->data->size);
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ } /* eof while */
+ pElem = *ppElem;
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfDSMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfDSMemPtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfDSMemPtr_t)smlLibMalloc(sizeof(SmlDevInfDSMem_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfDSMem_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_DEVINF_SHAREDMEM:
+ // %%% luz:2003-04-28: made work as a flag
+ pElem->flags |= SmlDevInfSharedMem_f;
+ // rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->shared);
+ break;
+ case TN_DEVINF_MAXMEM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxmem);
+ break;
+ case TN_DEVINF_MAXID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->maxid);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfCTCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfCTCapPtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfCTCapPtr_t)smlLibMalloc(sizeof(SmlDevInfCTCap_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfCTCap_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_CTTYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->cttype);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfSyncCapCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfSyncCapPtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfSyncCapPtr_t)smlLibMalloc(sizeof(SmlDevInfSyncCap_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfSyncCap_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_SYNCTYPE:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pElem->synctype);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDevInfExtCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlDevInfExtPtr_t pElem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pElem = (SmlDevInfExtPtr_t)smlLibMalloc(sizeof(SmlDevInfExt_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDevInfExt_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pElem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DEVINF_XNAM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pElem->xnam);
+ break;
+ case TN_DEVINF_XVAL:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pElem->xval);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pElem);
+ return rc;
+ }
+ }
+ *ppElem = pElem;
+
+ return SML_ERR_OK;
+}
+
+
+/* see xltenc.c:XltEncBlock for description of parameters */
+Ret_t devinfEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag) {
+ //Return variable
+ Ret_t _err;
+ SmlPcdataListPtr_t pList = NULL, p2List = NULL;
+ SmlDevInfDatastoreListPtr_t dsList = NULL;
+ SmlDevInfCtcapListPtr_t ctList = NULL;
+ SmlDevInfExtListPtr_t exList = NULL;
+ SmlDevInfXmitListPtr_t xmList = NULL;
+ SmlDevInfCTDataPropListPtr_t propList = NULL;
+ SmlDevInfCTDataListPtr_t paramList = NULL;
+
+ //Check if pContent of a required field is missing
+ if ((reqOptFlag == REQUIRED) && (pContent == NULL))
+ return SML_ERR_XLT_MISSING_CONT;
+ //Check if pContent of a optional field is missing -> if yes we are done
+ else if (pContent == NULL)
+ return SML_ERR_OK;
+
+ //Generate the commands -> see DTD
+ switch (tagId) {
+ case TN_DEVINF_EXT:
+ if ((_err = xltGenerateTag(TN_DEVINF_EXT, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_XNAM, REQUIRED, ((SmlDevInfExtPtr_t) pContent)->xnam, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = ((SmlDevInfExtPtr_t)pContent)->xval;
+ while (pList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_XVAL, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = pList->next;
+ };
+ if ((_err = xltGenerateTag(TN_DEVINF_EXT, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_SYNCCAP:
+ if ((_err = xltGenerateTag(TN_DEVINF_SYNCCAP, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = ((SmlDevInfSyncCapPtr_t)pContent)->synctype;
+ while (pList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_SYNCTYPE, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = pList->next;
+ };
+ if ((_err = xltGenerateTag(TN_DEVINF_SYNCCAP, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_SHAREDMEM:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlDevInfSharedMem_f))
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ // %%% luz:2003-04-28 added missing 1.1 devinf tags here
+ case TN_DEVINF_UTC:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlDevInfUTC_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_DEVINF_NOFM:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlDevInfNOfM_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_DEVINF_LARGEOBJECT:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlDevInfLargeObject_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ break;
+ // %%% end luz
+ case TN_DEVINF_CTCAP:
+ if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ ctList = ((SmlDevInfCtcapListPtr_t)pContent);
+ if (ctList == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ while (ctList != NULL) {
+ if (ctList->data == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if ((_err = devinfEncBlock(TN_DEVINF_CTTYPE, OPTIONAL, ctList->data->cttype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ /* now the propList */
+ // %%% luz 2002-11-27: made property list optional (e.g. text/message of P800 has none)
+ propList = ctList->data->prop;
+ // %%% original: if (propList == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ while (propList != NULL) {
+ if (propList->data == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (propList->data->prop == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ /* -- Propname */
+ if ((_err = devinfEncBlock(TN_DEVINF_PROPNAME, REQUIRED, propList->data->prop->name, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ /* -- (ValEnum+ | (Datatype, Size?))? */
+ //if (propList->data->prop->valenum == NULL && propList->data->prop->datatype == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (propList->data->prop->valenum != NULL && propList->data->prop->datatype != NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (propList->data->prop->valenum != NULL) {
+ // ValEnum+
+ pList = propList->data->prop->valenum;
+ while (pList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_VALENUM, REQUIRED, pList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ pList = pList->next;
+ };
+ } else if (propList->data->prop->datatype != NULL) {
+ // Datatype, Size?
+ if ((_err = devinfEncBlock(TN_DEVINF_DATATYPE, REQUIRED, propList->data->prop->datatype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SIZE, OPTIONAL, propList->data->prop->size, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ /* -- DisplayName ? */
+ if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, propList->data->prop->dname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ /* -- now the paramList */
+ paramList = propList->data->param;
+ while (paramList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_PARAMNAME, REQUIRED, paramList->data->name, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ /* -- (ValEnum+ | (Datatype, Size?))? */
+ //if (paramList->data->valenum == NULL && paramList->data->datatype == NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (paramList->data->valenum != NULL && paramList->data->datatype != NULL) return SML_ERR_XLT_INVAL_INPUT_DATA;
+ if (paramList->data->valenum != NULL) {
+ // ValEnum+
+ p2List = paramList->data->valenum;
+ while (p2List != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_VALENUM, REQUIRED, p2List->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ p2List = p2List->next;
+ };
+ } else if (paramList->data->datatype != NULL) {
+ // Datatype, Size?
+ if ((_err = devinfEncBlock(TN_DEVINF_DATATYPE, REQUIRED, paramList->data->datatype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SIZE, OPTIONAL, paramList->data->size, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ }
+ /* -- DisplayName ? */
+ if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, paramList->data->dname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ paramList = paramList->next;
+ }
+ propList = propList->next;
+ }
+ /* eof propList */
+ ctList = ctList->next;
+ };
+
+ if ((_err = xltGenerateTag(TN_DEVINF_CTCAP, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_DSMEM:
+ if ((_err = xltGenerateTag(TN_DEVINF_DSMEM, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SHAREDMEM, OPTIONAL, &(((SmlDevInfDSMemPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MAXMEM, OPTIONAL, ((SmlDevInfDSMemPtr_t) pContent)->maxmem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MAXID, OPTIONAL, ((SmlDevInfDSMemPtr_t) pContent)->maxid, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_DEVINF_DSMEM, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ // special case, the following 4 have the same structure, only the tag name differs
+ case TN_DEVINF_RX:
+ case TN_DEVINF_TX:
+ case TN_DEVINF_RXPREF:
+ case TN_DEVINF_TXPREF:
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_CTTYPE, REQUIRED, ((SmlDevInfXmitPtr_t) pContent)->cttype, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_VERCT, REQUIRED, ((SmlDevInfXmitPtr_t) pContent)->verct, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_DATASTORE:
+ if ((_err = xltGenerateTag(TN_DEVINF_DATASTORE, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SOURCEREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->sourceref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_DISPLAYNAME, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->displayname, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MAXGUIDSIZE, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->maxguidsize, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_RXPREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->rxpref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ xmList = ((SmlDevInfDatastorePtr_t)pContent)->rx;
+ while (xmList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_RX, OPTIONAL, xmList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ xmList = xmList->next;
+ };
+ if ((_err = devinfEncBlock(TN_DEVINF_TXPREF, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->txpref, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ xmList = ((SmlDevInfDatastorePtr_t)pContent)->tx;
+ while (xmList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_TX, OPTIONAL, xmList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ xmList = xmList->next;
+ };
+ if ((_err = devinfEncBlock(TN_DEVINF_DSMEM, OPTIONAL, ((SmlDevInfDatastorePtr_t) pContent)->dsmem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SYNCCAP, REQUIRED, ((SmlDevInfDatastorePtr_t) pContent)->synccap, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_DEVINF_DATASTORE, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DEVINF_DEVINF:
+ if ((_err = xltGenerateTag(TN_DEVINF_DEVINF, TT_BEG, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_VERDTD, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->verdtd, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MAN, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->man, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_MOD, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->mod, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_OEM, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->oem, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_FWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->fwv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_SWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->swv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_HWV, OPTIONAL, ((SmlDevInfDevInfPtr_t) pContent)->hwv, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_DEVID, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->devid, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_DEVTYP, REQUIRED, ((SmlDevInfDevInfPtr_t) pContent)->devtyp, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ // %%% luz:2003-04-28 added missing SyncML 1.1 devinf tags
+ if ((_err = devinfEncBlock(TN_DEVINF_UTC, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_NOFM, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ if ((_err = devinfEncBlock(TN_DEVINF_LARGEOBJECT, OPTIONAL, &(((SmlDevInfDevInfPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ // %%% end luz
+
+ dsList = ((SmlDevInfDevInfPtr_t)pContent)->datastore;
+ if (dsList == NULL) return SML_ERR_XLT_MISSING_CONT;
+ if ((_err = devinfEncBlock(TN_DEVINF_DATASTORE, REQUIRED, dsList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ dsList = dsList->next;
+ while (dsList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_DATASTORE, OPTIONAL, dsList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ dsList = dsList->next;
+ };
+ if ((_err = devinfEncBlock(TN_DEVINF_CTCAP, OPTIONAL, ((SmlDevInfDevInfPtr_t)pContent)->ctcap, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ exList = ((SmlDevInfDevInfPtr_t)pContent)->ext;
+ while (exList != NULL) {
+ if ((_err = devinfEncBlock(TN_DEVINF_EXT, OPTIONAL, exList->data, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ exList = exList->next;
+ };
+
+
+ if ((_err = xltGenerateTag(TN_DEVINF_DEVINF, TT_END, enc, pBufMgr, SML_EXT_DEVINF)) != SML_ERR_OK) return _err;
+ break;
+
+ default: { // all leaf nodes (PCDATA#)
+ return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag);
+ } //* eof default statement from switch tagid
+ } // eof switch tagid
+ return SML_ERR_OK;
+}
+#endif /* __USE_DEVINF__ */
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltdmtnd.c b/engine/dmlib/dmengine/oma_toolkit/src/xltdmtnd.c
new file mode 100644
index 0000000..29cc0cc
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltdmtnd.c
@@ -0,0 +1,869 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*--------------------------------------------------------------------------------------------------
+
+ Header Name: xltdmtnd.c
+
+ General Description: XLT DM TND related functions
+
+--------------------------------------------------------------------------------------------------*/
+
+#include "define.h"
+
+#ifdef __USE_DMTND__
+#include "smldmtnddtd.h"
+
+#include "xlttags.h"
+#include "xltdmtnd.h"
+#include "xlttagtbl.h"
+#include "xltenc.h"
+#include "xltencwbxml.h"
+
+#include <define.h>
+#include <libstr.h>
+#include <smlerr.h>
+#include <libmem.h>
+#include <libutil.h>
+
+/* extern */
+extern SML_API void smlFreeDmTndFormat(SmlDmTndFormatPtr_t data);
+extern SML_API void smlFreeDmTndType(SmlDmTndTypePtr_t data);
+extern SML_API void smlFreeDmTndDFElement(SmlDmTndDFElementPtr_t data);
+extern SML_API void smlFreeDmTndRTProps(SmlDmTndRTPropsPtr_t data);
+extern SML_API void smlFreeDmTndDFProps(SmlDmTndDFPropsPtr_t data);
+extern SML_API void smlFreeDmTndNode(SmlDmTndNodePtr_t data);
+extern SML_API void smlFreeDmTndNodeList(SmlDmTndNodeListPtr_t data);
+extern SML_API void smlFreeDmTnd(SmlDmTndPtr_t data);
+
+Ret_t buildDmTndNodeCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem);
+
+/* decoder callbacks */
+Ret_t buildDmTndFormatCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndFormatPtr_t pDmTndFormat;
+ Ret_t rc;
+
+ KCDBG("buildDmTndFormatCmd: Enter");
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndFormat = (SmlDmTndFormatPtr_t)smlLibMalloc(sizeof(SmlDmTndFormat_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndFormat, 0, sizeof(SmlDmTndFormat_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndFormat;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndFormat(pDmTndFormat);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ VoidPtr_t pContent = smlLibMalloc(6);
+ if ( pContent == NULL )
+ {
+ smlFreeDmTndFormat(pDmTndFormat);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pContent, 0, 6);
+
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_b64:
+ KCDBG("buildDmTndFormatCmd: b64");
+ smlLibStrcpy(pContent, "b64");
+ break;
+ case TN_DMTND_bin:
+ KCDBG("buildDmTndFormatCmd: bin");
+ smlLibStrcpy(pContent, "bin");
+ break;
+ case TN_DMTND_bool:
+ KCDBG("buildDmTndFormatCmd: bool");
+ smlLibStrcpy(pContent, "bool");
+ break;
+ case TN_DMTND_chr:
+ KCDBG("buildDmTndFormatCmd: chr");
+ smlLibStrcpy(pContent, "chr");
+ break;
+ case TN_DMTND_int:
+ KCDBG("buildDmTndFormatCmd: int");
+ smlLibStrcpy(pContent, "int");
+ break;
+ case TN_DMTND_node:
+ KCDBG("buildDmTndFormatCmd: node");
+ smlLibStrcpy(pContent, "node");
+ break;
+ case TN_DMTND_null:
+ KCDBG("buildDmTndFormatCmd: null");
+ smlLibStrcpy(pContent, "null");
+ break;
+ case TN_DMTND_xml:
+ KCDBG("buildDmTndFormatCmd: xml");
+ smlLibStrcpy(pContent, "xml");
+ break;
+ case TN_DMTND_date:
+ KCDBG("buildDmTndFormatCmd: date");
+ smlLibStrcpy(pContent, "date");
+ break;
+ case TN_DMTND_time:
+ KCDBG("buildDmTndFormatCmd: time");
+ smlLibStrcpy(pContent, "time");
+ break;
+ case TN_DMTND_float:
+ KCDBG("buildDmTndFormatCmd: float");
+ smlLibStrcpy(pContent, "float");
+ break;
+ default:
+ KCDBG(">>>>> Unkown token: %d <<<<<", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pContent);
+ smlFreeDmTndFormat(pDmTndFormat);
+ return rc;
+ }
+
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndFormat->value);
+ if (rc != SML_ERR_OK) {
+ smlLibFree(pContent);
+ smlFreeDmTndFormat(pDmTndFormat);
+ return rc;
+ }
+ pDmTndFormat->value->content = pContent;
+ pDmTndFormat->value->length = smlLibStrlen(pContent);
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlLibFree(pContent);
+ smlFreeDmTndFormat(pDmTndFormat);
+ return rc;
+ }
+ if (pScanner->curtok->type != TOK_TAG_END) {
+ smlLibFree(pContent);
+ smlFreeDmTndFormat(pDmTndFormat);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+
+ *ppElem = pDmTndFormat;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndTypeCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner = NULL;
+ SmlDmTndTypePtr_t pDmTndType = NULL;
+ SmlPcdataPtr_t pPCData = NULL;
+ Ret_t rc = SML_ERR_OK;
+
+ KCDBG("buildDmTndTypeCmd: Enter");
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndType = (SmlDmTndTypePtr_t)smlLibMalloc(sizeof(SmlDmTndType_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndType, 0, sizeof(SmlDmTndType_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndType;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndType(pDmTndType);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ if (IS_CONTENT(pScanner->curtok)) {
+ // detected PCDATA instead of <MIME> or <DDFName> tags
+ // need to copy it to pDmTndType->mime
+ if ((pPCData = (SmlPcdataPtr_t)smlLibMalloc(sizeof(SmlPcdata_t))) != NULL) {
+ smlLibMemset(pPCData, 0, sizeof(SmlPcdata_t));
+ if ((pPCData->content = (VoidPtr_t)smlLibMalloc(pScanner->curtok->pcdata->length)) != NULL) {
+ smlLibMemmove(((Byte_t*)pPCData->content), pScanner->curtok->pcdata->content, pScanner->curtok->pcdata->length);
+ pPCData->length = pScanner->curtok->pcdata->length;
+ pDmTndType->mime = pPCData;
+ } else {
+ smlLibFree(pPCData);
+ pPCData = NULL;
+ rc = SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ } else {
+ rc = SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndTypeCmd: %s", pDmTndType->mime->content);
+ }
+ } else {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_MIME:
+ KCDBG("buildDmTndTypeCmd: MIME");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndType->mime);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndTypeCmd: %s", pDmTndType->mime->content);
+ }
+ break;
+ case TN_DMTND_DDFName:
+ KCDBG("buildDmTndTypeCmd: DDFName");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndType->ddfname);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndTypeCmd: %s", pDmTndType->ddfname->content);
+ }
+ break;
+ default:
+ KCDBG("buildDmTndTypeCmd: Error: Unkown token: %d", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTndType(pDmTndType);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndType(pDmTndType);
+ return rc;
+ }
+ if (pScanner->curtok->type != TOK_TAG_END) {
+ smlFreeDmTndType(pDmTndType);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+
+ *ppElem = pDmTndType;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndDFElementCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndDFElementPtr_t pDmTndDFElement;
+ Ret_t rc;
+
+ KCDBG("buildDmTndDFElementCmd: Enter");
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndDFElement = (SmlDmTndDFElementPtr_t)smlLibMalloc(sizeof(SmlDmTndDFElement_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndDFElement, 0, sizeof(SmlDmTndDFElement_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndDFElement;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ VoidPtr_t pContent = smlLibMalloc(12);
+ if ( pContent == NULL )
+ {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibMemset(pContent, 0, 12);
+
+ switch (pScanner->curtok->tagid) {
+ /* AccessType Elements */
+ case TN_DMTND_Add:
+ smlLibStrcpy(pContent, "Add");
+ break;
+ case TN_DMTND_Copy:
+ smlLibStrcpy(pContent, "Copy");
+ break;
+ case TN_DMTND_Delete:
+ smlLibStrcpy(pContent, "Delete");
+ break;
+ case TN_DMTND_Exec:
+ smlLibStrcpy(pContent, "Exec");
+ break;
+ case TN_DMTND_Get:
+ smlLibStrcpy(pContent, "Get");
+ break;
+ case TN_DMTND_Replace:
+ smlLibStrcpy(pContent, "Replace");
+ break;
+ /* Occurrence Elements */
+ case TN_DMTND_One:
+ smlLibStrcpy(pContent, "One");
+ break;
+ case TN_DMTND_ZeroOrOne:
+ smlLibStrcpy(pContent, "ZeroOrOne");
+ break;
+ case TN_DMTND_ZeroOrMore:
+ smlLibStrcpy(pContent, "ZeroOrMore");
+ break;
+ case TN_DMTND_OneOrMore:
+ smlLibStrcpy(pContent, "OneOrMore");
+ break;
+ case TN_DMTND_ZeroOrN:
+ smlLibStrcpy(pContent, "ZeroOrN");
+ break;
+ case TN_DMTND_OneOrN:
+ smlLibStrcpy(pContent, "OneOrN");
+ break;
+ /* Scope Elements */
+ case TN_DMTND_Permanent:
+ smlLibStrcpy(pContent, "Permanent");
+ break;
+ case TN_DMTND_Dynamic:
+ smlLibStrcpy(pContent, "Dynamic");
+ break;
+ /* CaseSense Elements */
+ case TN_DMTND_CS:
+ smlLibStrcpy(pContent, "CS");
+ break;
+ case TN_DMTND_CIS:
+ smlLibStrcpy(pContent, "CIS");
+ break;
+ default:
+ KCDBG(">>>>> buildDmTndDFElementCmd: Unkown token: %d <<<<<", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return rc;
+ }
+ if (pScanner->curtok->type != TOK_TAG_END) {
+ smlFreeDmTndDFElement(pDmTndDFElement);
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+
+ *ppElem = pDmTndDFElement;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndRTPropsCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndRTPropsPtr_t pDmTndRTProps;
+ Ret_t rc;
+
+ KCDBG("buildDmTndRTPropsCmd: Enter");
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndRTProps = (SmlDmTndRTPropsPtr_t)smlLibMalloc(sizeof(SmlDmTndRTProps_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndRTProps, 0, sizeof(SmlDmTndRTProps_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndRTProps;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndRTProps(pDmTndRTProps);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_ACL:
+ KCDBG("buildDmTndRTPropsCmd: ACL");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->acl);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndRTPropsCmd: ACL = %s", pDmTndRTProps->acl->content);
+ }
+ break;
+ case TN_DMTND_Format:
+ KCDBG("buildDmTndRTPropsCmd: Format");
+ rc = buildDmTndFormatCmd(pDecoder, (VoidPtr_t)&pDmTndRTProps->format);
+ break;
+ case TN_DMTND_Name:
+ KCDBG("buildDmTndRTPropsCmd: Name");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->name);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndRTPropsCmd: Name = %s", pDmTndRTProps->name->content);
+ }
+ break;
+ case TN_DMTND_Size:
+ KCDBG("buildDmTndRTPropsCmd: Size");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->size);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndRTPropsCmd: Size = %s", pDmTndRTProps->size->content);
+ }
+ break;
+ case TN_DMTND_Title:
+ KCDBG("buildDmTndRTPropsCmd: Title");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->title);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndRTPropsCmd: Title = %s", pDmTndRTProps->title->content);
+ }
+ break;
+ case TN_DMTND_TStamp:
+ KCDBG("buildDmTndRTPropsCmd: TStampt");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->tstamp);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndRTPropsCmd: TStampt = %s", pDmTndRTProps->tstamp->content);
+ }
+ break;
+ case TN_DMTND_Type:
+ KCDBG("buildDmTndRTPropsCmd: Type");
+ rc = buildDmTndTypeCmd(pDecoder, (VoidPtr_t)&pDmTndRTProps->type);
+ break;
+ case TN_DMTND_VerNo:
+ KCDBG("buildDmTndRTPropsCmd: VerNo");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndRTProps->verno);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndRTPropsCmd: VerNo = %s", pDmTndRTProps->verno->content);
+ }
+ break;
+ default:
+ KCDBG("buildDmTndRTPropsCmd: Error: Unkown token: %d", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTndRTProps(pDmTndRTProps);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndRTProps(pDmTndRTProps);
+ return rc;
+ }
+ }
+
+ *ppElem = pDmTndRTProps;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndDFPropsCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndDFPropsPtr_t pDmTndDFProps;
+ Ret_t rc = SML_ERR_OK;
+
+ KCDBG("buildDmTndDFPropsCmd: Enter");
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndDFProps = (SmlDmTndDFPropsPtr_t)smlLibMalloc(sizeof(SmlDmTndDFProps_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndDFProps, 0, sizeof(SmlDmTndDFProps_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndDFProps;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndDFProps(pDmTndDFProps);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_AccessType:
+ KCDBG("buildDmTndDFPropsCmd: AccessType");
+ rc = buildDmTndDFElementCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->accesstype);
+ break;
+ case TN_DMTND_DefaultValue:
+ KCDBG("buildDmTndDFPropsCmd: DefaultValue");
+ rc = buildDmTndFormatCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->defaultvalue);
+ break;
+ case TN_DMTND_Description:
+ KCDBG("buildDmTndDFPropsCmd: Description");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndDFProps->description);
+ break;
+ case TN_DMTND_DFFormat:
+ KCDBG("buildDmTndDFPropsCmd: DFFormat");
+ rc = buildDmTndFormatCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->dfformat);
+ break;
+ case TN_DMTND_Occurrence:
+ KCDBG("buildDmTndDFPropsCmd: Occurrence");
+ rc = buildDmTndDFElementCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->occurrence);
+ break;
+ case TN_DMTND_Scope:
+ KCDBG("buildDmTndDFPropsCmd: Scope");
+ rc = buildDmTndDFElementCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->scope);
+ break;
+ case TN_DMTND_DFTitle:
+ KCDBG("buildDmTndDFPropsCmd: DFTitle");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndDFProps->dftitle);
+ break;
+ case TN_DMTND_DFType:
+ KCDBG("buildDmTndDFPropsCmd: DFType");
+ rc = buildDmTndTypeCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->dftype);
+ break;
+ case TN_DMTND_CaseSense:
+ KCDBG("buildDmTndDFPropsCmd: CaseSense");
+ rc = buildDmTndDFElementCmd(pDecoder, (VoidPtr_t)&pDmTndDFProps->casesense);
+ break;
+ default:
+ KCDBG("buildDmTndDFPropsCmd: Error: Unkown token: %d", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTndDFProps(pDmTndDFProps);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndDFProps(pDmTndDFProps);
+ return rc;
+ }
+ }
+
+ *ppElem = pDmTndDFProps;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildDmTndNodeList(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ SmlDmTndNodeListPtr_t pElem = NULL, pPrev = NULL;
+
+ KCDBG("buildDmTndNodeList: Enter");
+
+ pElem = (SmlDmTndNodeListPtr_t) *ppElem;
+ /* advance to the end of the list, and create ther an empty list element */
+ while (pElem != NULL) {
+ pPrev = pElem;
+ pElem = pPrev->next;
+ }
+ if ((pElem = (SmlDmTndNodeListPtr_t)smlLibMalloc(sizeof(SmlDmTndNodeListPtr_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pElem, 0, sizeof(SmlDmTndNodeListPtr_t));
+ pElem->next = NULL;
+ if (pPrev != NULL) /* we already had some entries in the list */
+ pPrev->next = pElem;
+ else /* nope we created a new list */
+ *ppElem = pElem;
+ pElem->node = NULL;
+ /* at this point pElem should point to an valid list element */
+ return buildDmTndNodeCmd(pDecoder, (VoidPtr_t)&pElem->node);
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndNodeCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndNodePtr_t pDmTndNode;
+ Ret_t rc;
+
+ KCDBG("buildDmTndNodeCmd: Enter");
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTndNode = (SmlDmTndNodePtr_t)smlLibMalloc(sizeof(SmlDmTndNode_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTndNode, 0, sizeof(SmlDmTndNode_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTndNode;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndNode(pDmTndNode);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_NodeName:
+ KCDBG("buildDmTndNodeCmd: NodeName");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndNode->nodename);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndNodeCmd: Node name = %s", pDmTndNode->nodename->content);
+ }
+ break;
+ case TN_DMTND_Path:
+ KCDBG("buildDmTndNodeCmd: Path\n");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndNode->path);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndNodeCmd: path = %s", pDmTndNode->path->content);
+ }
+ break;
+ case TN_DMTND_RTProperties:
+ KCDBG("buildDmTndNodeCmd: RTProperties");
+ rc = buildDmTndRTPropsCmd(pDecoder, (VoidPtr_t)&pDmTndNode->rtprops);
+ break;
+ case TN_DMTND_DFProperties:
+ KCDBG("buildDmTndNodeCmd: DFProperties");
+ rc = buildDmTndDFPropsCmd(pDecoder, (VoidPtr_t)&pDmTndNode->dfprops);
+ break;
+ case TN_DMTND_Value:
+ KCDBG("buildDmTndNodeCmd: Value");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTndNode->value);
+ if (rc == SML_ERR_OK) {
+ KCDBG("buildDmTndNodeCmd: Value = %s", pDmTndNode->value->content);
+ }
+ break;
+ case TN_DMTND_Node:
+ KCDBG("buildDmTndNodeCmd: Node");
+ rc = buildDmTndNodeList(pDecoder, (VoidPtr_t)&pDmTndNode->nodelist);
+ break;
+ default:
+ KCDBG("buildDmTndNodeCmd: Unkown token: %d", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ if ( NULL != pDmTndNode->nodename && NULL != pDmTndNode->nodename->content )
+ {
+ KCDBG("buildDmTndNodeCmd: Error: Node %s corrupted", (char *)pDmTndNode->nodename->content);
+ }
+ smlFreeDmTndNode(pDmTndNode);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTndNode(pDmTndNode);
+ return rc;
+ }
+ }
+
+ *ppElem = pDmTndNode;
+
+ return SML_ERR_OK;
+}
+
+/* decoder callbacks */
+Ret_t buildDmTndCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem)
+{
+ XltDecScannerPtr_t pScanner;
+ SmlDmTndPtr_t pDmTnd;
+ Ret_t rc;
+
+ KCDBG("buildDmTndCmd: Enter");
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pDmTnd = (SmlDmTndPtr_t)smlLibMalloc(sizeof(SmlDmTnd_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pDmTnd, 0, sizeof(SmlDmTnd_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pDmTnd;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTnd(pDmTnd);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_DMTND_MgmtTree:
+ KCDBG("buildDmTndCmd: MgmtTree tag");
+ break;
+ case TN_DMTND_VerDTD:
+ KCDBG("buildDmTndCmd: VerDTD tag");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTnd->verdtd);
+ break;
+ case TN_DMTND_Man:
+ KCDBG("buildDmTndCmd: Man tag");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTnd->man);
+ break;
+ case TN_DMTND_Mod:
+ KCDBG("buildDmTndCmd: Mod tag");
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pDmTnd->mod);
+ break;
+ case TN_DMTND_Node:
+ KCDBG("buildDmTndCmd: Node tag");
+ rc = buildDmTndNodeList(pDecoder, (VoidPtr_t)&pDmTnd->nodelist);
+ break;
+ default:
+ KCDBG(">>>>> buildDmTndDFPropsCmd: Unkown token: %d <<<<<", pScanner->curtok->tagid);
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeDmTnd(pDmTnd);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeDmTnd(pDmTnd);
+ return rc;
+ }
+ }
+
+ *ppElem = pDmTnd;
+
+ return SML_ERR_OK;
+}
+
+/* see xltenc.c:XltEncBlock for description of parameters */
+Ret_t dmtndEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+ if ((reqOptFlag == REQUIRED) && (pContent == NULL))
+ {
+ KCDBG(">>>>> TNDS required tag: %d missed ! <<<<<", tagId);
+ return SML_ERR_XLT_MISSING_CONT;
+ }
+ //Check if pContent of a optional field is missing -> if yes we are done
+ else if (pContent == NULL)
+ return SML_ERR_OK;
+
+ Ret_t _err;
+ SmlDmTndNodeListPtr_t nodeList = NULL;
+
+ //Generate the commands -> see DTD
+ switch (tagId)
+ {
+ case TN_DMTND_MgmtTree:
+ if ((_err = xltGenerateTag(TN_DMTND_MgmtTree, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_VerDTD, REQUIRED, ((SmlDmTndPtr_t) pContent)->verdtd, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Man, OPTIONAL, ((SmlDmTndPtr_t) pContent)->man, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Mod, OPTIONAL, ((SmlDmTndPtr_t) pContent)->mod, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ nodeList = ((SmlDmTndPtr_t)pContent)->nodelist;
+ while (nodeList != NULL)
+ {
+ if ((_err = dmtndEncBlock(TN_DMTND_Node, OPTIONAL, nodeList->node, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ nodeList = nodeList->next;
+ };
+ if ((_err = xltGenerateTag(TN_DMTND_MgmtTree, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DMTND_Node:
+ if ((_err = xltGenerateTag(TN_DMTND_Node, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_NodeName, REQUIRED, ((SmlDmTndNodePtr_t) pContent)->nodename, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Path, OPTIONAL, ((SmlDmTndNodePtr_t) pContent)->path, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_RTProperties, OPTIONAL, ((SmlDmTndNodePtr_t) pContent)->rtprops, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Value, OPTIONAL, ((SmlDmTndNodePtr_t) pContent)->value, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ nodeList = ((SmlDmTndNodePtr_t)pContent)->nodelist;
+ while (nodeList != NULL)
+ {
+ if ((_err = dmtndEncBlock(TN_DMTND_Node, OPTIONAL, nodeList->node, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ nodeList = nodeList->next;
+ };
+ if ((_err = xltGenerateTag(TN_DMTND_Node, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DMTND_RTProperties:
+ if ((_err = xltGenerateTag(TN_DMTND_RTProperties, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_ACL, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->acl, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Format, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->format, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Name, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->name, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Size, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->size, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Title, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->title, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_TStamp, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->tstamp, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_Type, REQUIRED, ((SmlDmTndRTPropsPtr_t) pContent)->type, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = dmtndEncBlock(TN_DMTND_VerNo, OPTIONAL, ((SmlDmTndRTPropsPtr_t) pContent)->verno, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_DMTND_RTProperties, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DMTND_Format:
+ if ( NULL == pContent || NULL == ((SmlDmTndFormatPtr_t) pContent)->value || NULL == ((SmlDmTndFormatPtr_t) pContent)->value->content )
+ break;
+ if ((_err = xltGenerateTag(TN_DMTND_Format, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ( !strcmp("b64", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_b64, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("bin", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_bin, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("bool", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_bool, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("chr", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_chr, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("int", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_int, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("node", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_node, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("null", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_null, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("xml", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_xml, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("date", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_date, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("time", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_time, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( !strcmp("float", (char *)(((SmlDmTndFormatPtr_t) pContent)->value->content)) )
+ {
+ if ((_err = xltGenerateTag(TN_DMTND_float, TT_ALL, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else
+ {
+ KCDBG(">>>>> Unkown format: %s <<<<<\n", (char *)(((SmlDmTndFormatPtr_t)pContent)->value->content));
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if ((_err = xltGenerateTag(TN_DMTND_Format, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ case TN_DMTND_Type:
+ if ((_err = xltGenerateTag(TN_DMTND_Type, TT_BEG, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ if ( ((SmlDmTndTypePtr_t) pContent)->mime )
+ {
+ if ((_err = dmtndEncBlock(TN_DMTND_MIME, OPTIONAL, ((SmlDmTndTypePtr_t) pContent)->mime, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ else if ( ((SmlDmTndTypePtr_t) pContent)->ddfname )
+ {
+ if ((_err = dmtndEncBlock(TN_DMTND_DDFName, OPTIONAL, ((SmlDmTndTypePtr_t) pContent)->ddfname, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ }
+ if ((_err = xltGenerateTag(TN_DMTND_Type, TT_END, enc, pBufMgr, SML_EXT_DMTND)) != SML_ERR_OK) return _err;
+ break;
+ default: // all leaf nodes (PCDATA#)
+ return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag);
+ } /* eof switch tagid */
+ return SML_ERR_OK;
+}
+
+#endif /* __USE_DMTND__ */
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltenc.c b/engine/dmlib/dmengine/oma_toolkit/src/xltenc.c
new file mode 100644
index 0000000..439d88f
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltenc.c
@@ -0,0 +1,1502 @@
+/*************************************************************************/
+/* module: Encoder source file */
+/* file: xltenc.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include <xltenc.h>
+#ifdef __SML_WBXML__
+ #include "xltencwbxml.h"
+#endif
+#ifdef __SML_XML__
+ #include "xltencxml.h"
+#endif
+#include "xlttags.h"
+#include "xltmetinf.h"
+#include "xltdevinf.h"
+#include "xltdmtnd.h"
+#include "smlmetinfdtd.h"
+#include "smldevinfdtd.h"
+#include <libstr.h>
+#include <libmem.h>
+#include <smldtd.h>
+#include <smldef.h>
+
+Ret_t getTNbyPE(SmlProtoElement_t, XltTagID_t*);
+Ret_t xltEncBlock(XltTagID_t, XltRO_t, const VoidPtr_t, SmlEncoding_t, BufferMgmtPtr_t, SmlPcdataExtension_t);
+Ret_t xltEncList(XltListType_t, XltRO_t, VoidPtr_t, SmlEncoding_t, BufferMgmtPtr_t, SmlPcdataExtension_t);
+#ifndef __SML_LITE__
+Ret_t xltBuildExtention(SmlPcdataExtension_t, XltRO_t, VoidPtr_t, SmlEncoding_t, BufferMgmtPtr_t);
+#endif
+
+typedef struct PEEnc_s
+{
+ XltTagID_t tagid;
+ SmlProtoElement_t type;
+} PEEnc_t, *PEEncPtr_t;
+
+PEEncPtr_t getPEEncTable(void);
+
+PEEncPtr_t getPEEncTable(void)
+{
+ PEEncPtr_t _tmpPEEncPtr;
+ PEEnc_t const PE[] =
+ {
+ { TN_ADD, SML_PE_ADD },
+ { TN_ALERT, SML_PE_ALERT },
+ { TN_ATOMIC, SML_PE_ATOMIC_START },
+ { TN_ATOMIC_END, SML_PE_ATOMIC_END },
+ { TN_COPY, SML_PE_COPY },
+ { TN_DELETE, SML_PE_DELETE },
+ { TN_EXEC, SML_PE_EXEC },
+ { TN_GET, SML_PE_GET },
+ { TN_MAP, SML_PE_MAP },
+ { TN_PUT, SML_PE_PUT },
+ { TN_RESULTS, SML_PE_RESULTS },
+ { TN_SEARCH, SML_PE_SEARCH },
+ { TN_SEQUENCE, SML_PE_SEQUENCE_START },
+ { TN_SEQUENCE_END, SML_PE_SEQUENCE_END },
+ { TN_STATUS, SML_PE_STATUS },
+ { TN_SYNC, SML_PE_SYNC_START },
+ { TN_SYNC_END, SML_PE_SYNC_END },
+ { TN_REPLACE, SML_PE_REPLACE },
+ { TN_UNDEF, SML_PE_UNDEF }
+ };
+ _tmpPEEncPtr = (PEEncPtr_t)smlLibMalloc(sizeof(PE));
+ if (_tmpPEEncPtr == NULL) return NULL;
+ smlLibMemcpy(_tmpPEEncPtr, &PE, sizeof(PE));
+ return _tmpPEEncPtr;
+}
+
+Ret_t getTNbyPE(SmlProtoElement_t pE, XltTagID_t *tagID)
+{
+ int i = 0;
+ PEEncPtr_t pPETbl = getPEEncTable();
+ if (pPETbl == NULL)
+ {
+ smlLibFree(pPETbl);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pPETbl+i)->type) != SML_PE_UNDEF)
+ {
+ if (((pPETbl+i)->type) == pE)
+ {
+ *tagID = (pPETbl+i)->tagid;
+ smlLibFree(pPETbl);
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ smlLibFree(pPETbl);
+ *tagID = TN_UNDEF;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+
+/**
+ * FUNCTION: smlXltEncInit
+ *
+ * Initializes an XML buffer; Creates XML code for the SyncHdr
+ * and appends it to the buffer.
+ * Returns 0 if operation was successful.
+ *
+ * PRE-Condition: no memory should be allocated for ppEncoder (should be NULL)
+ * pHeader has to contain a valid SyncHdr structure
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: enc, the encoding constant (SML_WBXML or SML_XML)
+ * pHeader, the SyncML header structure
+ * pBufEnd, pointer to the end of the buffer to write on
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ * ppEncoder, the encoder object
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncInit(SmlEncoding_t enc,
+ const SmlSyncHdrPtr_t pHeader,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos,
+ XltEncoderPtr_t *ppEncoder,
+ SmlVersion_t vers)
+{
+ // Return variable
+ Ret_t _err;
+
+ XltEncoderPtr_t _pEncoder;
+
+ //Structure containing buffer pointers, length and written bytes
+ BufferMgmtPtr_t _pBufMgr;
+
+#ifdef __SML_XML__
+ MemPtr_t _tmpStr;
+ MemPtr_t _xmlver = (MemPtr_t)XML_VERSION;
+ MemPtr_t _xmlenc = (MemPtr_t)XML_ENCODING;
+ MemByte_t _begpar = XML_BEGPAR;
+ MemByte_t _endpar = XML_ENDPAR;
+#endif
+
+#ifdef __SML_WBXML__
+ MemByte_t _stablen = 0x1D; //XLT_STABLEN;
+ MemByte_t _wbxmlver = XLT_WBXMLVER;
+ MemByte_t _charset = XLT_CHARSET;
+ MemByte_t _pubident1 = XLT_PUBIDENT1;
+ MemByte_t _pubident2 = XLT_PUBIDENT2;
+ char * _syncmldtd = "<error>";
+
+ switch( vers )
+ {
+ case SML_VERS_1_0:
+ {
+ _syncmldtd = "-//SYNCML//DTD SyncML 1.0//EN";
+ break;
+ }
+ case SML_VERS_1_1:
+ {
+ _syncmldtd = "-//SYNCML//DTD SyncML 1.1//EN";
+ break;
+ }
+ case SML_VERS_1_2:
+ {
+ _syncmldtd = "-//SYNCML//DTD SyncML 1.2//EN";
+ break;
+ }
+ default:
+ {
+ return SML_ERR_WRONG_PARAM;
+ }
+ }
+
+#endif
+
+ if ((_pEncoder = (XltEncoderPtr_t)smlLibMalloc(sizeof(XltEncoder_t))) == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ if ((_pBufMgr = (BufferMgmtPtr_t)smlLibMalloc(sizeof(BufferMgmt_t))) == NULL) {
+ smlLibFree(_pEncoder);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ //set the encoding
+ _pEncoder->enc = enc;
+
+ // %%% luz:2003-07-31: added version
+ _pEncoder->vers = vers;
+
+ _pEncoder->cur_ext = (SmlPcdataExtension_t)SML_EXT_UNDEFINED;
+ _pEncoder->last_ext = (SmlPcdataExtension_t)SML_EXT_UNDEFINED;
+ _pEncoder->end_tag_size = 0;
+ _pEncoder->space_evaluation = NULL;
+
+
+ _pBufMgr->smlXltBufferP = *ppBufPos;
+ _pBufMgr->smlXltBufferLen = pBufEnd - *ppBufPos;
+ _pBufMgr->smlXltStoreBufP = _pBufMgr->smlXltBufferP;
+ _pBufMgr->smlXltWrittenBytes = 0;
+ _pBufMgr->smlCurExt = _pEncoder->cur_ext;
+ _pBufMgr->smlLastExt = _pEncoder->last_ext;
+ _pBufMgr->smlActiveExt = SML_EXT_UNDEFINED;
+ _pBufMgr->switchExtTag = TN_UNDEF;
+ _pBufMgr->spaceEvaluation = 0;
+ _pBufMgr->vers = vers;
+ _pBufMgr->endTagSize = 0;
+
+ switch (enc)
+ {
+
+#ifdef __SML_WBXML__
+ case SML_WBXML:
+ {
+
+ // Set the WBXML Header Values
+ // WBXML Version
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_wbxmlver), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ // Public Idetifier - default unknown
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_pubident1), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_pubident2), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ // Character set - not yet implemented
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_charset), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ // Sting table length - not yet implemented
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_stablen), TAG, 1, _pBufMgr)) != SML_ERR_OK) break;
+ // FPI - %%% luz:2003-07-31: not constant any more, varies according to SyncML version
+ if ((_err = xltAddToBuffer((MemPtr_t) (_syncmldtd) , smlLibStrlen((String_t)_syncmldtd), _pBufMgr)) != SML_ERR_OK) break;
+
+ break;
+ }
+#endif
+
+#ifdef __SML_XML__
+ case SML_XML:
+ {
+
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = (MemPtr_t)"?xml version=\"";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = _xmlver;
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = (MemPtr_t)"\" encoding=\"";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = _xmlenc;
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ _tmpStr = (MemPtr_t)"\"?";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), _pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, _pBufMgr)) != SML_ERR_OK) break;
+
+ break;
+ }
+#endif
+
+ default:
+ {
+ _err = SML_ERR_XLT_ENC_UNK;
+ }
+ }
+ if (_err != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ smlLibFree(_pEncoder);
+ return _err;
+ }
+
+ // SyncML Tag
+ if ((_err = xltGenerateTag(TN_SYNCML, TT_BEG, enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ smlLibFree(_pEncoder);
+ return _err;
+ }
+
+ // Generate SmlSyncHdr
+
+ if ((_err = xltEncBlock(TN_SYNCHDR, REQUIRED, pHeader, enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ smlLibFree(_pEncoder);
+ return _err;
+ }
+
+ // SyncBody Tag
+ if ((_err = xltGenerateTag(TN_SYNCBODY, TT_BEG, enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ smlLibFree(_pEncoder);
+ return _err;
+ }
+
+ _pEncoder->cur_ext = _pBufMgr->smlCurExt;
+ _pEncoder->last_ext = _pBufMgr->smlLastExt;
+ _pEncoder->end_tag_size = _pBufMgr->endTagSize;
+
+ *ppBufPos = _pBufMgr->smlXltBufferP;
+
+ smlLibFree(_pBufMgr);
+
+ _pEncoder->final = 0;
+
+ *ppEncoder = (XltEncoderPtr_t)_pEncoder;
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: smlXltEncAppend
+ *
+ * Generates (WB)XML code and appends it to the XML buffer.
+ *
+ * PRE-Condition: pEncoder holds the initialized encoder structure.
+ * the initialization takes place in the xltEncAppend function
+ * pContent has to contain a valid content structure structure
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: pEncoder, the encoder object
+ * pe, the protocol element (PE_ADD, ...)
+ * pBufEnd, pointer to the end of the buffer to write on
+ * pContent, the content to append to the SyncML document
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncAppend(const XltEncoderPtr_t pEncoder,
+ SmlProtoElement_t pe,
+ const MemPtr_t pBufEnd,
+ const VoidPtr_t pContent,
+ MemPtr_t *ppBufPos)
+{
+ // Return variable
+ Ret_t _err;
+
+ XltTagID_t tagID = TN_UNDEF;
+
+ // encoding type
+ SmlEncoding_t _enc;
+
+ //Structure containing buffer pointers, length and written bytes
+ BufferMgmtPtr_t _pBufMgr;
+
+ if ((_pBufMgr = (BufferMgmtPtr_t)smlLibMalloc(sizeof(BufferMgmt_t))) == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(_pBufMgr, 0, sizeof(BufferMgmt_t));
+
+ //get the encoding type
+ _enc = pEncoder->enc;
+
+ _pBufMgr->vers = pEncoder->vers; // %%% luz:2003-07-31: pass SyncML version to bufmgr
+ _pBufMgr->smlXltBufferP = *ppBufPos;
+ _pBufMgr->smlXltBufferLen = pBufEnd - *ppBufPos;
+ _pBufMgr->smlXltStoreBufP = _pBufMgr->smlXltBufferP;
+ _pBufMgr->smlXltWrittenBytes = 0;
+ _pBufMgr->smlActiveExt = SML_EXT_UNDEFINED;
+ _pBufMgr->switchExtTag = TN_UNDEF;
+ _pBufMgr->spaceEvaluation = ((pEncoder->space_evaluation == NULL) ? 0 : 1);
+ // %%% luz 2002-09-03: evaluation may not mess with encoder state
+ if ( _pBufMgr->spaceEvaluation) {
+ // spaceEval state
+ _pBufMgr->smlCurExt = pEncoder->space_evaluation->cur_ext;
+ _pBufMgr->smlLastExt = pEncoder->space_evaluation->last_ext;
+ }
+ else {
+ // normal encoder state
+ _pBufMgr->smlCurExt = pEncoder->cur_ext;
+ _pBufMgr->smlLastExt = pEncoder->last_ext;
+ }
+
+ _pBufMgr->endTagSize =0;
+
+ _err = getTNbyPE(pe, &tagID);
+
+ _err = xltEncBlock(tagID, REQUIRED, pContent, _enc, _pBufMgr, SML_EXT_UNDEFINED);
+ if (_err != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ return _err;
+ }
+
+
+ if (pEncoder->space_evaluation != NULL) {
+ // Only calculating size
+ pEncoder->space_evaluation->written_bytes += _pBufMgr->smlXltWrittenBytes;
+ pEncoder->space_evaluation->end_tag_size += _pBufMgr->endTagSize;
+ // save it only into evaluation state
+ pEncoder->space_evaluation->cur_ext = _pBufMgr->smlCurExt;
+ pEncoder->space_evaluation->last_ext = _pBufMgr->smlLastExt;
+ } else {
+ // really generating data
+ pEncoder->end_tag_size += _pBufMgr->endTagSize;
+ // save it into encoder state
+ pEncoder->cur_ext = _pBufMgr->smlCurExt;
+ pEncoder->last_ext = _pBufMgr->smlLastExt;
+ }
+
+ *ppBufPos = _pBufMgr->smlXltBufferP;
+
+ smlLibFree(_pBufMgr);
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: smlXltEncTerminate
+ *
+ * Filnalizes the (WB)XML document and returns the size of written bytes to
+ * the workspace module
+ *
+ * PRE-Condition: pEncoder holds the initialized encoder structure.
+ * the initialization takes place in the xltEncAppend function
+ * pBufEnd must point to the end of the (WB)XML buffer
+ * ppBufPos has to be initialized to the start point of the
+ * (WB)XML buffer.
+ *
+ * POST-Condition: After the function call ppBufPos points to the
+ * first free byte in the buffer behind the (WB)XML document
+ *
+ * IN: pEncoder, the encoder object
+ * pBufEnd, pointer to the end of the buffer to write on
+ *
+ * IN/OUT: ppBufPos, current position of the bufferpointer
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ * Possible Error Codes:
+ * SML_ERR_XLT_BUF_ERR
+ * SML_ERR_XLT_MISSING_CONT
+ * SML_ERR_XLT_INVAL_ELEM_TYPE
+ * SML_ERR_XLT_INVAL_LIST_TYPE
+ * SML_ERR_XLT_INVAL_TAG_TYPE
+ * SML_ERR_XLT_ENC_UNK
+ * SML_ERR_XLT_INVAL_PROTO_ELEM
+ */
+Ret_t xltEncTerminate(const XltEncoderPtr_t pEncoder,
+ const MemPtr_t pBufEnd,
+ MemPtr_t *ppBufPos)
+{
+ // Return variable
+ Ret_t _err;
+
+ // encoding type
+ SmlEncoding_t _enc;
+
+ //Structure containing buffer pointers, length and written bytes
+ BufferMgmtPtr_t _pBufMgr;
+
+ //get the encoding type
+ _enc = pEncoder->enc;
+
+ //Initialize buffer variables
+ if ((_pBufMgr = smlLibMalloc(sizeof(BufferMgmt_t))) == NULL) {
+ smlLibFree(pEncoder);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ _pBufMgr->vers = pEncoder->vers; // %%% luz:2003-07-31: pass SyncML version to bufmgr
+ _pBufMgr->smlXltWrittenBytes = 0;
+ _pBufMgr->smlXltBufferP = *ppBufPos;
+ _pBufMgr->smlXltStoreBufP = _pBufMgr->smlXltBufferP;
+ _pBufMgr->smlXltBufferLen = pBufEnd - *ppBufPos;
+ _pBufMgr->smlCurExt = pEncoder->cur_ext;
+ _pBufMgr->smlLastExt = pEncoder->last_ext;
+ _pBufMgr->smlActiveExt = pEncoder->cur_ext;
+ _pBufMgr->switchExtTag = TN_UNDEF;
+ _pBufMgr->spaceEvaluation = ((pEncoder->space_evaluation == NULL) ? 0 : 1);
+ _pBufMgr->endTagSize =0;
+
+ if (pEncoder->final == 1)
+ {
+ // Final Flag
+ if ((_err = xltGenerateTag(TN_FINAL, TT_ALL, _enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ xltEncReset(pEncoder);
+ return _err;
+ }
+ }
+
+ // SyncBody End Tag
+ if ((_err = xltGenerateTag(TN_SYNCBODY, TT_END, _enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ xltEncReset(pEncoder);
+ return _err;
+ }
+
+ // SyncML End Tag
+ if ((_err = xltGenerateTag(TN_SYNCML, TT_END, _enc, _pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK)
+ {
+ smlLibFree(_pBufMgr);
+ xltEncReset(pEncoder);
+ return _err;
+ }
+
+ pEncoder->cur_ext = _pBufMgr->smlCurExt;
+ pEncoder->last_ext = _pBufMgr->smlLastExt;
+
+ *ppBufPos = _pBufMgr->smlXltBufferP;
+
+ smlLibFree(_pBufMgr);
+
+ xltEncReset(pEncoder);
+
+ return SML_ERR_OK;
+}
+
+Ret_t xltEncReset(XltEncoderPtr_t pEncoder)
+{
+ if ((pEncoder) && (pEncoder->space_evaluation)) {
+ smlLibFree(pEncoder->space_evaluation);
+ pEncoder->space_evaluation = NULL;
+ }
+ smlLibFree(pEncoder);
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlXltStartEvaluation
+ *
+ * Starts an evaluation run which prevents further API-Calls to write tags -
+ * just the tag-sizes are calculated. Must be sopped via smlEndEvaluation
+ *
+ * IN: XltEncoderPtr_t
+ * the encoder object
+ *
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t xltStartEvaluation(XltEncoderPtr_t pEncoder)
+{
+ XltSpaceEvaluationPtr_t _pSpaceEvaluation;
+
+ if (pEncoder->space_evaluation != NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ if ((_pSpaceEvaluation = (XltSpaceEvaluationPtr_t)smlLibMalloc(sizeof(XltSpaceEvaluation_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(_pSpaceEvaluation, 0, sizeof(XltSpaceEvaluation_t));
+ // %%% luz 2002-09-03: init encoder state shadow copies for evaluation from real encoder
+ _pSpaceEvaluation->cur_ext = pEncoder->cur_ext;
+ _pSpaceEvaluation->last_ext = pEncoder->last_ext;
+
+ pEncoder->space_evaluation = _pSpaceEvaluation;
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: smlXltEndEvaluation
+ *
+ * Stops an evaluation run which prevents further API-Calls to write tags -
+ * the remaining free buffer size after all Tags are written is returned
+ *
+ * IN: XltEncoderPtr_t
+ * the encoder object
+ *
+ * IN/OUT: MemSize_t
+ * Size of free buffer for data after all tags are written
+ *
+ * RETURN: Ret_t
+ * Return Code
+ */
+SML_API Ret_t xltEndEvaluation(InstanceID_t id, XltEncoderPtr_t pEncoder, MemSize_t *freemem)
+{
+
+ MemSize_t _free;
+ XltSpaceEvaluationPtr_t _evaluation;
+
+ _evaluation = pEncoder->space_evaluation;
+
+ if (_evaluation == NULL)
+ return SML_ERR_WRONG_USAGE;
+
+ _free = smlGetFreeBuffer(id);
+ _free -= _evaluation->written_bytes;
+ _free -= _evaluation->end_tag_size;
+ _free -= pEncoder->end_tag_size;
+
+ *freemem = _free;
+
+ smlLibFree(_evaluation);
+ pEncoder->space_evaluation = NULL;
+
+ return SML_ERR_OK;
+}
+
+
+/**
+ * FUNCTION: xltEncBlock
+ *
+ * Generates a (WB)XML Block for a given tag ID and a given content
+ *
+ * PRE-Condition: pContent holds a valid content structure
+ * tagId contains a valid SyncML tag ID
+ *
+ * POST-Condition: the (WB)XML buffer in the pBufMgr structure contains the
+ * encoded (WB)XML block
+ *
+ * IN: tagId, the ID for the tag to generate (TN_ADD, ...)
+ * reqOptFlag, flag if the block is required or optional
+ * pContent, the content structure of the block
+ * enc, the encoding constant (SML_WBXML or SML_XML)
+ * attFlag, indicates if the encoded tag contain Attributes in namespace extensions
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xltEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+
+ //Return variable
+ Ret_t _err;
+
+
+ //Check if pContent of a required field is missing
+ if ((reqOptFlag == REQUIRED) && (pContent == NULL)) {
+ switch ((int)tagId) {
+ case TN_ATOMIC_END:
+ case TN_SYNC_END:
+ case TN_SEQUENCE_END:
+ break;
+ default:
+ return SML_ERR_XLT_MISSING_CONT;
+ }
+ }
+ //Check if pContent of a optional field is missing
+ else if ((pContent == NULL) && (tagId != TN_SYNC_END) && (tagId != TN_ATOMIC_END) && (tagId != TN_SEQUENCE_END))
+ return SML_ERR_OK;
+
+ //Generate the commands -> see DTD
+ switch ((int)tagId){
+ case TN_SYNCHDR:
+ // SyncHdr Begin Tag
+ if ((_err = xltGenerateTag(TN_SYNCHDR, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Version
+ if ((_err = xltEncBlock(TN_VERSION, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->version, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Proto
+ if ((_err = xltEncBlock(TN_PROTO, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->proto, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SessionID
+ if ((_err = xltEncBlock(TN_SESSIONID, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->sessionID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // MsgID
+ if ((_err = xltEncBlock(TN_MSGID, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->msgID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target
+ if ((_err = xltEncBlock(TN_TARGET, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source
+ if ((_err = xltEncBlock(TN_SOURCE, REQUIRED, ((SmlSyncHdrPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // RespURI?
+ if ((_err = xltEncBlock(TN_RESPURI, OPTIONAL, ((SmlSyncHdrPtr_t) pContent)->respURI, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlSyncHdrPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlSyncHdrPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlSyncHdrPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SyncHdr End Tag
+ if ((_err = xltGenerateTag(TN_SYNCHDR, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_CRED:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_CRED, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlCredPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Data
+ if ((_err = xltEncBlock(TN_DATA, REQUIRED, ((SmlCredPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_CRED, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_SOURCE:
+ case TN_TARGET:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // LocURI
+ if ((_err = xltEncBlock(TN_LOCURI, REQUIRED, ((SmlSourcePtr_t) pContent)->locURI, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // LocName?
+ if ((_err = xltEncBlock(TN_LOCNAME, OPTIONAL, ((SmlSourcePtr_t) pContent)->locName, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_ITEM:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_ITEM, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target?
+ if ((_err = xltEncBlock(TN_TARGET, OPTIONAL, ((SmlItemPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source?
+ if ((_err = xltEncBlock(TN_SOURCE, OPTIONAL, ((SmlItemPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlItemPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Data?
+ if ((_err = xltEncBlock(TN_DATA, OPTIONAL, ((SmlItemPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // MoreData?
+ if ((_err = xltEncBlock(TN_MOREDATA, OPTIONAL, &(((SmlItemPtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_ITEM, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#if (defined ADD_SEND || defined COPY_SEND)
+ case TN_ADD:
+ case TN_COPY:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlGenericCmdPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlGenericCmdPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlGenericCmdPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlGenericCmdPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlGenericCmdPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#endif
+ case TN_ALERT:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_ALERT, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlAlertPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlAlertPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlAlertPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Data?
+ if ((_err = xltEncBlock(TN_DATA, OPTIONAL, ((SmlAlertPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Correlator?
+ if ((_err = xltEncBlock(TN_CORRELATOR, OPTIONAL, ((SmlAlertPtr_t) pContent)->correlator, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item*
+ if ((_err = xltEncList(ITEM_LIST, OPTIONAL, ((SmlAlertPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_ALERT, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#if (defined ATOMIC_SEND || defined SEQUENCE_SEND)
+ case TN_ATOMIC:
+ case TN_SEQUENCE:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlAtomicPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlAtomicPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlAtomicPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ //End tag in TN_ATOMIC_END
+
+ break;
+ case TN_ATOMIC_END:
+ // End tag
+ if ((_err = xltGenerateTag(TN_ATOMIC, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ break;
+ case TN_SEQUENCE_END:
+ // End tag
+ if ((_err = xltGenerateTag(TN_SEQUENCE, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ break;
+#endif
+ case TN_DELETE:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_DELETE, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlDeletePtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlDeletePtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Archive?
+ if ((_err = xltEncBlock(TN_ARCHIVE, OPTIONAL, &(((SmlDeletePtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SftDel?
+ if ((_err = xltEncBlock(TN_SFTDEL, OPTIONAL, &(((SmlDeletePtr_t) pContent)->flags), enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlDeletePtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlDeletePtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlDeletePtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_DELETE, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#ifdef EXEC_SEND
+ case TN_EXEC:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_EXEC, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlExecPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlExecPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlExecPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlExecPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Correlator?
+ if ((_err = xltEncBlock(TN_CORRELATOR, OPTIONAL, ((SmlExecPtr_t) pContent)->correlator, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item
+ if ((_err = xltEncBlock(TN_ITEM, REQUIRED, ((SmlExecPtr_t) pContent)->item, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_EXEC, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#endif
+ case TN_GET:
+ case TN_PUT:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlGetPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlGetPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Lang?
+ if ((_err = xltEncBlock(TN_LANG, OPTIONAL, ((SmlGetPtr_t) pContent)->lang, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlGetPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlGetPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlGetPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_MAP:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_MAP, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlMapPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target
+ if ((_err = xltEncBlock(TN_TARGET, REQUIRED, ((SmlMapPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source
+ if ((_err = xltEncBlock(TN_SOURCE, REQUIRED, ((SmlMapPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlMapPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlMapPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Mapitemlist
+ if ((_err = xltEncList(MAPITEM_LIST, REQUIRED, ((SmlMapPtr_t) pContent)->mapItemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_MAP, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_MAPITEM:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_MAPITEM, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target
+ if ((_err = xltEncBlock(TN_TARGET, REQUIRED, ((SmlMapItemPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source
+ if ((_err = xltEncBlock(TN_SOURCE, REQUIRED, ((SmlMapItemPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_MAPITEM, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_RESULTS:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_RESULTS, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlResultsPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // MsgRef?
+ if ((_err = xltEncBlock(TN_MSGREF, OPTIONAL, ((SmlResultsPtr_t) pContent)->msgRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdRef
+ if ((_err = xltEncBlock(TN_CMDREF, REQUIRED, ((SmlResultsPtr_t) pContent)->cmdRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlResultsPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // TargetRef?
+ if ((_err = xltEncBlock(TN_TARGETREF, OPTIONAL, ((SmlResultsPtr_t) pContent)->targetRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SourceRef?
+ if ((_err = xltEncBlock(TN_SOURCEREF, OPTIONAL, ((SmlResultsPtr_t) pContent)->sourceRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlResultsPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_RESULTS, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_CHAL:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_CHAL, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta
+ if ((_err = xltEncBlock(TN_META, REQUIRED, ((SmlChalPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_CHAL, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#ifdef SEARCH_SEND
+ case TN_SEARCH:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_SEARCH, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlSearchPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlSearchPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResults?
+ if ((_err = xltEncBlock(TN_NORESULTS, OPTIONAL, &((SmlSearchPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlSearchPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target?
+ if ((_err = xltEncBlock(TN_TARGET, OPTIONAL, ((SmlSearchPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source List
+ if ((_err = xltEncList(SOURCE_LIST, REQUIRED, ((SmlSearchPtr_t) pContent)->sourceList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Lang?
+ if ((_err = xltEncBlock(TN_LANG, OPTIONAL, ((SmlSearchPtr_t) pContent)->lang, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta
+ if ((_err = xltEncBlock(TN_META, REQUIRED, ((SmlSearchPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Dsta
+ if ((_err = xltEncBlock(TN_DATA, REQUIRED, ((SmlSearchPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_SEARCH, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+#endif
+ case TN_STATUS:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_STATUS, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlStatusPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // MsgRef?
+ if ((_err = xltEncBlock(TN_MSGREF, REQUIRED, ((SmlStatusPtr_t) pContent)->msgRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdRef
+ if ((_err = xltEncBlock(TN_CMDREF, REQUIRED, ((SmlStatusPtr_t) pContent)->cmdRef, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cmd
+ if ((_err = xltEncBlock(TN_CMD, REQUIRED, ((SmlStatusPtr_t) pContent)->cmd, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // TargetRefList?
+ if ((_err = xltEncList(TARGETREF_LIST, OPTIONAL, ((SmlStatusPtr_t) pContent)->targetRefList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // SourceRefList?
+ if ((_err = xltEncList(SOURCEREF_LIST, OPTIONAL, ((SmlStatusPtr_t) pContent)->sourceRefList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlStatusPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Chal?
+ if ((_err = xltEncBlock(TN_CHAL, OPTIONAL, ((SmlStatusPtr_t) pContent)->chal, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Data
+ if ((_err = xltEncBlock(TN_DATA, REQUIRED, ((SmlStatusPtr_t) pContent)->data, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item*
+ if ((_err = xltEncList(ITEM_LIST, OPTIONAL, ((SmlStatusPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(TN_STATUS, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_SYNC:
+ // Begin tag
+ if ((_err = xltGenerateTag(TN_SYNC, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlSyncPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlSyncPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlSyncPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Target?
+ if ((_err = xltEncBlock(TN_TARGET, OPTIONAL, ((SmlSyncPtr_t) pContent)->target, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Source?
+ if ((_err = xltEncBlock(TN_SOURCE, OPTIONAL, ((SmlSyncPtr_t) pContent)->source, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlSyncPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NumberOfChanges?
+ if ((_err = xltEncBlock(TN_NUMBEROFCHANGES, OPTIONAL, ((SmlSyncPtr_t) pContent)->noc, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag in TN_SYNC_END
+
+ break;
+ case TN_SYNC_END:
+ //End tag
+ if ((_err = xltGenerateTag(TN_SYNC, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_REPLACE:
+ // Begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // CmdID
+ if ((_err = xltEncBlock(TN_CMDID, REQUIRED, ((SmlGenericCmdPtr_t) pContent)->cmdID, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // NoResp?
+ if ((_err = xltEncBlock(TN_NORESP, OPTIONAL, &((SmlGenericCmdPtr_t) pContent)->flags, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Cred?
+ if ((_err = xltEncBlock(TN_CRED, OPTIONAL, ((SmlGenericCmdPtr_t) pContent)->cred, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Meta?
+ if ((_err = xltEncBlock(TN_META, OPTIONAL, ((SmlGenericCmdPtr_t) pContent)->meta, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // Item+
+ if ((_err = xltEncList(ITEM_LIST, REQUIRED, ((SmlGenericCmdPtr_t) pContent)->itemList, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ // End tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+
+ break;
+ case TN_ARCHIVE:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t*)pContent)) & (SmlArchive_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_SFTDEL:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlSftDel_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ break;
+ case TN_MOREDATA:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlMoreData_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_NORESULTS:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlNoResults_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_NORESP:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlNoResp_f)){
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ case TN_FINAL:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlFinal_f)) {
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_UNDEFINED)) != SML_ERR_OK) return _err;
+ }
+ break;
+ default: // all leaf nodes (PCDATA#)
+ return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag);
+ }
+ }
+ return SML_ERR_OK;
+}
+
+Ret_t xltEncPcdata(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag) {
+ //Return variable
+ Ret_t _err;
+
+ //generate PCDATA begin tag
+ if ((_err = xltGenerateTag(tagId, TT_BEG, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+
+ //write the pContent to the buffer according the encoding type
+ switch ((int)enc) {
+#ifdef __SML_WBXML__
+ case SML_WBXML:
+ switch (((SmlPcdataPtr_t)pContent)->contentType) {
+ case SML_PCDATA_STRING:
+ if ((_err = wbxmlWriteTypeToBuffer(((SmlPcdataPtr_t)pContent)->content, STR_I, ((SmlPcdataPtr_t)pContent)->length, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+ // Note: SML_PCDATA_CDATA case added by luz to allow direct translation from XML to WBXML
+ case SML_PCDATA_CDATA:
+ case SML_PCDATA_OPAQUE:
+ if ((_err = wbxmlWriteTypeToBuffer(((SmlPcdataPtr_t)pContent)->content, OPAQUE, ((SmlPcdataPtr_t)pContent)->length, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+#ifdef __USE_EXTENSIONS__
+ case SML_PCDATA_EXTENSION:
+ if ((_err = xltBuildExtention(((SmlPcdataPtr_t)pContent)->extension, reqOptFlag, ((SmlPcdataPtr_t)pContent)->content, enc, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+#endif
+ default:
+ // 2003-11-24: Tomy to deal with pcdata empty extensions (for example <Meta></Meta> which is valid)
+ // refer to xltdec.c to see that empty extensions result in SmlPcdataPtr_t with all fields (data) set to 0
+ if (((SmlPcdataPtr_t)pContent)->contentType != SML_PCDATA_UNDEFINED ||
+ ((SmlPcdataPtr_t)pContent)->extension != SML_EXT_UNDEFINED ||
+ ((SmlPcdataPtr_t)pContent)->length != 0 ||
+ ((SmlPcdataPtr_t)pContent)->content != NULL)
+ return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ // return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ // end modified by Tomy
+ }; // eof switch(contenttype)
+ break;
+#endif // eof WBXML
+
+#ifdef __SML_XML__
+ case SML_XML:
+ switch (((SmlPcdataPtr_t)pContent)->contentType) {
+ // Note: SML_PCDATA_OPAQUE case added by luz to allow direct translation from WBXML to XML
+ #ifdef PCDATA_OPAQUE_AS_CDATA
+ case SML_PCDATA_OPAQUE:
+ #endif
+ case SML_PCDATA_CDATA: {
+ MemPtr_t _tmpStr;
+ _tmpStr = (MemPtr_t) "<![CDATA[";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), pBufMgr)) != SML_ERR_OK) return _err;
+ if ((_err = xltAddToBuffer(((SmlPcdataPtr_t)pContent)->content, ((SmlPcdataPtr_t)pContent)->length, pBufMgr)) != SML_ERR_OK) return _err;
+ _tmpStr = (MemPtr_t) "]]>";
+ if ((_err = xltAddToBuffer(_tmpStr, smlLibStrlen((String_t)_tmpStr), pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+ }
+ // Note: SyncFest #5 shows that <![CDATA[ is not correctly parsed by the RTK
+ // so we don't use it and risk the danger of failing on payload which has
+ // XML in it.
+ #ifndef PCDATA_OPAQUE_AS_CDATA
+ case SML_PCDATA_OPAQUE:
+ #endif
+ case SML_PCDATA_STRING:
+ if ((_err = xltAddToBuffer(((SmlPcdataPtr_t)pContent)->content, ((SmlPcdataPtr_t)pContent)->length, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+#ifdef __USE_EXTENSIONS__
+ case SML_PCDATA_EXTENSION:
+ if ((_err = xltBuildExtention(((SmlPcdataPtr_t)pContent)->extension, reqOptFlag, ((SmlPcdataPtr_t)pContent)->content, enc, pBufMgr)) != SML_ERR_OK) return _err;
+ break;
+#endif
+ default:
+ // 2003-11-24: Tomy to deal with pcdata empty extensions (for example <Meta></Meta> which is valid)
+ // refer to xltdec.c to see that empty extensions result in SmlPcdataPtr_t with all fields (data) set to 0
+ if (((SmlPcdataPtr_t)pContent)->contentType != SML_PCDATA_UNDEFINED ||
+ ((SmlPcdataPtr_t)pContent)->extension != SML_EXT_UNDEFINED ||
+ ((SmlPcdataPtr_t)pContent)->length != 0 ||
+ ((SmlPcdataPtr_t)pContent)->content != NULL)
+ return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ // return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ // end modified by Tomy
+ }
+ break;
+#endif // eof XML
+
+ default:
+ return SML_ERR_XLT_ENC_UNK;
+ } // eof switch(enc)
+
+ //generate PCDATA END tag
+ if ((_err = xltGenerateTag(tagId, TT_END, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xltEncList
+ *
+ * Generates a list element which is not directly related to a tag
+ *
+ * PRE-Condition: pList holds a valid list structure
+ * listId contains a valid SyncML list ID
+ *
+ * POST-Condition: the (WB)XML buffer in the pBufMgr structure contains the
+ * encoded (WB)XML list
+ *
+ * IN: listId, the ID of the list to generate (e.g. TARGET_LIST, ...)
+ * pList, reference to the list to process
+ * enc, the encoding constant (SML_WBXML or SML_XML)
+ * attFlag, indicates if the encoded tag contain Attributes in namespace extensions
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xltEncList(XltListType_t listId, XltRO_t reqOptFlag, VoidPtr_t pList, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+ //Return variable
+ Ret_t _err;
+
+ //check if list is required or not
+ if ((reqOptFlag == REQUIRED) && (pList == NULL))
+ return SML_ERR_XLT_MISSING_CONT;
+ else if (pList == NULL)
+ return SML_ERR_OK;
+
+ //encode the different list types
+ switch ((int)listId)
+ {
+ case ITEM_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_ITEM, OPTIONAL, ((SmlItemListPtr_t)pList)->item, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlItemListPtr_t)pList)->next;
+ } while ((SmlItemListPtr_t)pList != NULL);
+
+ break;
+ }
+ case SOURCE_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_SOURCE, OPTIONAL, ((SmlSourceListPtr_t)pList)->source, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlSourceListPtr_t)pList)->next;
+ } while ((SmlSourceListPtr_t)pList != NULL);
+
+ break;
+ }
+ case TARGETREF_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_TARGETREF, OPTIONAL, ((SmlTargetRefListPtr_t)pList)->targetRef, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlTargetRefListPtr_t)pList)->next;
+ } while ((SmlTargetRefListPtr_t)pList != NULL);
+
+ break;
+ }
+ case SOURCEREF_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_SOURCEREF, OPTIONAL, ((SmlSourceRefListPtr_t)pList)->sourceRef, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlSourceRefListPtr_t)pList)->next;
+ } while ((SmlSourceRefListPtr_t)pList != NULL);
+
+ break;
+ }
+ case MAPITEM_LIST:
+ {
+ do
+ {
+ if ((_err = xltEncBlock(TN_MAPITEM, OPTIONAL, ((SmlMapItemListPtr_t)pList)->mapItem, enc, pBufMgr, attFlag)) != SML_ERR_OK) return _err;
+ pList = ((SmlMapItemListPtr_t)pList)->next;
+ } while ((SmlMapItemListPtr_t)pList != NULL);
+
+ break;
+ }
+ default:
+ return SML_ERR_XLT_INVAL_LIST_TYPE;
+ }
+
+ return SML_ERR_OK;
+}
+
+/**
+ * FUNCTION: xltGenerateTag
+ *
+ * Generates a (WB)XML tag
+ *
+ * PRE-Condition: valis parameters
+ *
+ * POST-Condition: the buffer contains a new tag
+ *
+ * IN: tagId, the tag ID
+ * TagType, the tag type (begin tag, end tag, ...)
+ * enc, the encoding constant (SML_WBXML or SML_XML)
+ * attFlag, indicates if the encoded tag contain Attributes in namespace extensions
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xltGenerateTag(XltTagID_t tagId, XltTagType_t TagType, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+
+ Ret_t _err;
+#ifdef __SML_WBXML__
+ MemByte_t _switchpage = XLT_SWITCHPAGE;
+#endif
+
+ switch ((int)enc) {
+#ifdef __SML_WBXML__
+ case SML_WBXML:
+ /* in WBXML codepage switches are done for starting tags only */
+ if (TagType != TT_END) {
+ //codepage switching with wbxml instead of namespace
+ if (getCodePage(attFlag) != getCodePage(pBufMgr->smlCurExt)) {
+ MemByte_t _newcp = getCodePage(attFlag);
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_switchpage), TAG, 1, pBufMgr)) != SML_ERR_OK) return _err;
+ if ((_err = wbxmlWriteTypeToBuffer((MemPtr_t)(&_newcp), TAG, 1, pBufMgr)) != SML_ERR_OK) return _err;
+ }
+
+ if (attFlag != pBufMgr->smlCurExt) {
+ pBufMgr->switchExtTag = tagId;
+ pBufMgr->smlLastExt = pBufMgr->smlCurExt;
+ pBufMgr->smlCurExt = attFlag;
+ }
+ } // for TagType
+ return wbxmlGenerateTag(tagId, TagType, pBufMgr);
+#endif
+#ifdef __SML_XML__
+ case SML_XML:
+
+ if (attFlag != pBufMgr->smlCurExt) {
+ pBufMgr->switchExtTag = tagId;
+ pBufMgr->smlLastExt = pBufMgr->smlCurExt;
+ pBufMgr->smlCurExt = attFlag;
+ }
+ return xmlGenerateTag(tagId, TagType, pBufMgr, attFlag);
+#endif
+ default:
+ return SML_ERR_XLT_ENC_UNK;
+ }
+
+ //return SML_ERR_XLT_ENC_UNK;NOT NEEDED
+}
+
+#ifdef __USE_EXTENSIONS__
+/* Entrypoint for SubDTD's. If we reached this point we already know
+ * a) we have data fora sub-DTD to encode and
+ * b) we know which sub-DTD should be encoded.
+ * So just call the appropriate sub-DTD encoder and thats it.
+ */
+Ret_t xltBuildExtention(SmlPcdataExtension_t extId, XltRO_t reqOptFlag, VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr) {
+
+ switch (extId) {
+#ifdef __USE_METINF__
+ case SML_EXT_METINF:
+ /* a metaInf DTD always starts with this token */
+ return metinfEncBlock(TN_METINF_METINF,reqOptFlag,pContent,enc,pBufMgr,SML_EXT_METINF);
+ break;
+#endif
+#ifdef __USE_DEVINF__
+ case SML_EXT_DEVINF:
+ /* a deviceInf DTD always starts with this token */
+ /* we have to choose, wether we have to encode the DevInf as XML or WBXML */
+ /* in the latter case, we need a special treatment of this sub-dtd, as we have */
+ /* to put it into a SML_PCDATA_OPAQUE field ... */
+ if (enc == SML_XML)
+ return devinfEncBlock(TN_DEVINF_DEVINF,reqOptFlag,pContent,enc,pBufMgr,SML_EXT_DEVINF);
+ else
+ return subdtdEncWBXML(TN_DEVINF_DEVINF,reqOptFlag,pContent,SML_WBXML,pBufMgr,SML_EXT_DEVINF);
+ break;
+#endif
+#ifdef __USE_DMTND__
+ case SML_EXT_DMTND:
+ /* a DMTND DTD always starts with this token */
+ return dmtndEncBlock(TN_DMTND_MgmtTree, reqOptFlag,pContent,enc,pBufMgr,SML_EXT_DMTND);
+ break;
+#endif
+ /* oops - we don not know about that extension -> bail out */
+ default:
+ return SML_ERR_XLT_INVAL_EXT;
+ }
+ //return SML_ERR_OK;CAN NOT BE REACHED
+}
+
+
+/* Sub DTD's need a special treatment when used together with WBXML.
+ * We need to eoncode them as a complete WBXML message including headers and stuff
+ * and store the result within an SML_PCDATA_OPAQUE datafield.
+ * To archieve this we create a new encoder, encode the message and finally
+ * copy the result into the allready existing encoder.
+ */
+#ifdef __SML_WBXML__
+Ret_t subdtdEncWBXML(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+ #ifdef __USE_DEVINF__
+ Ret_t _err = SML_ERR_OK;
+ #endif
+
+ Short_t SubBufSize = 12000; // for starters we use 12kB for each sub DTD to encode in WBXML
+ BufferMgmtPtr_t pSubBufMgr = NULL;
+ char *FPIstring = "<error>";
+ Short_t FPIsize = 0;
+
+ if( !pBufMgr ) return SML_ERR_WRONG_PARAM;
+
+
+ switch( pBufMgr->vers )
+ {
+ case SML_VERS_1_0:
+ {
+ FPIstring = "-//SYNCML//DTD DevInf 1.0//EN";
+ break;
+ }
+ case SML_VERS_1_1:
+ case SML_VERS_1_2:
+ {
+ FPIstring = "-//SYNCML//DTD DevInf 1.1//EN";
+ break;
+ }
+ default:
+ {
+ return SML_ERR_WRONG_PARAM;
+ }
+ }
+
+ FPIsize = smlLibStrlen(FPIstring);
+
+ // first create a sub buffer
+ pSubBufMgr = (BufferMgmtPtr_t)smlLibMalloc(sizeof(BufferMgmt_t));
+ if (pSubBufMgr == NULL) {
+ if (enc && pContent && reqOptFlag && tagId) {
+ }
+ return SML_ERR_NOT_ENOUGH_SPACE;}
+
+ smlLibMemset(pSubBufMgr, 0,sizeof(BufferMgmt_t));
+ pSubBufMgr->smlXltBufferLen = SubBufSize;
+ pSubBufMgr->smlXltBufferP = (MemPtr_t)smlLibMalloc(SubBufSize);
+ if (pSubBufMgr->smlXltBufferP == NULL) {
+ smlLibFree(pSubBufMgr);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ smlLibMemset(pSubBufMgr->smlXltBufferP, 0, SubBufSize);
+ pSubBufMgr->smlXltStoreBufP = pSubBufMgr->smlXltBufferP;
+ pSubBufMgr->smlXltWrittenBytes = 0;
+ pSubBufMgr->smlActiveExt = pBufMgr->smlActiveExt;
+ pSubBufMgr->smlCurExt = pBufMgr->smlCurExt;
+ pSubBufMgr->smlLastExt = pBufMgr->smlLastExt;
+ pSubBufMgr->spaceEvaluation = pBufMgr->spaceEvaluation;
+
+ // in case of space evaluation, just count the number of written bytes
+ if (pSubBufMgr->spaceEvaluation == 0) {
+ // create the WBXML header
+ pSubBufMgr->smlXltBufferP[0] = 0x02; // WBXML Version 1.2
+ pSubBufMgr->smlXltBufferP[1] = 0x00; // use Stringtable for ID
+ pSubBufMgr->smlXltBufferP[2] = 0x00; // empty/unknown public ID
+ pSubBufMgr->smlXltBufferP[3] = 0x6A; // charset encoding UTF-8
+ pSubBufMgr->smlXltBufferP[4] = 0x1D; // lenght of stringtable
+ pSubBufMgr->smlXltBufferP += 5;
+ // Generate FPI
+ // %%% luz 2003-07-31: ensured that we send the right version here!
+ smlLibMemmove(pSubBufMgr->smlXltBufferP, FPIstring, FPIsize);
+ pSubBufMgr->smlXltBufferP += FPIsize;
+ }
+ pSubBufMgr->smlXltWrittenBytes = 5 + FPIsize;
+
+ // do the encoding
+ switch (attFlag) {
+#ifdef __USE_DEVINF__
+ case SML_EXT_DEVINF:
+ if ((_err = devinfEncBlock(TN_DEVINF_DEVINF,reqOptFlag,pContent,enc,pSubBufMgr,SML_EXT_DEVINF)) != SML_ERR_OK) {
+ smlLibFree(pSubBufMgr->smlXltStoreBufP);
+ smlLibFree(pSubBufMgr);
+ return _err;
+ }
+ break;
+#endif
+ /* oops - we don not know about that extension -> bail out */
+ default:
+ smlLibFree(pSubBufMgr->smlXltStoreBufP);
+ smlLibFree(pSubBufMgr);
+ return SML_ERR_XLT_INVAL_EXT;
+ }
+
+#ifdef __USE_DEVINF__
+ // move it to the 'real' encoder buffer
+ // now set up the OPAQUE field
+ if (pBufMgr->spaceEvaluation == 0) {
+ pBufMgr->smlXltBufferP[0] = 0xC3; // OPAQUE data identifier
+ pBufMgr->smlXltBufferP += 1;
+
+ wbxmlOpaqueSize2Buf(pSubBufMgr->smlXltWrittenBytes, pBufMgr);
+
+ smlLibMemmove(pBufMgr->smlXltBufferP, pSubBufMgr->smlXltStoreBufP, pSubBufMgr->smlXltWrittenBytes);
+ pBufMgr->smlXltBufferP += pSubBufMgr->smlXltWrittenBytes;
+ pBufMgr->smlXltWrittenBytes += pSubBufMgr->smlXltWrittenBytes;
+ } else {
+ pBufMgr->smlXltWrittenBytes++;
+ wbxmlOpaqueSize2Buf(pSubBufMgr->smlXltWrittenBytes, pBufMgr);
+ pBufMgr->smlXltWrittenBytes += pSubBufMgr->smlXltWrittenBytes;
+ }
+
+ // clean up the temporary stuff
+ smlLibFree(pSubBufMgr->smlXltStoreBufP);
+ smlLibFree(pSubBufMgr);
+
+ return _err;
+#endif
+}
+#endif
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltenccom.c b/engine/dmlib/dmengine/oma_toolkit/src/xltenccom.c
new file mode 100644
index 0000000..161e64d
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltenccom.c
@@ -0,0 +1,106 @@
+/*************************************************************************/
+/* module: Encoder utils file */
+/* file: xltenccom.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+
+#include "xltenccom.h"
+#include <smlerr.h>
+#include <libmem.h>
+
+/**
+ * FUNCTION: xltAddToBuffer
+ *
+ * Add a string to the global buffer
+ *
+ * PRE-Condition: pContent contains some content bytes to write to the (WB) XML buffer
+ *
+ * POST-Condition: content is written to the buffer
+ *
+ * IN: pContent, the character pointer referencing the content to
+ * write to the buffer
+ * size, the content length
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xltAddToBuffer(const MemPtr_t pContent, MemSize_t size, BufferMgmtPtr_t pBufMgr)
+{
+ // if we are doing a space evaluation, do not write the data physically - just remember its length
+ if (!pBufMgr->spaceEvaluation) {
+ //check if buffersize is to small to write the content
+ if ((size + pBufMgr->smlXltWrittenBytes) > pBufMgr->smlXltBufferLen) {
+ #ifdef NCDEBUGPRINTFX
+ #warning "%%%%% delete that message later"
+ NCDEBUGPRINTFX(DBG_SYNCML,(
+ "xltAddToBuffer: buffer too small, pContent='%0.30s', size=%ld, pBufMgr->smlXltWrittenBytes=%ld, pBufMgr->smlXltBufferLen=%ld",
+ pContent,
+ size,
+ pBufMgr->smlXltWrittenBytes,
+ pBufMgr->smlXltBufferLen
+ ));
+ #endif
+ return SML_ERR_XLT_BUF_ERR;
+ }
+
+ if (!(smlLibMemcpy((void*) pBufMgr->smlXltBufferP, (void*) pContent, (MemSize_t) size))) {
+ #ifdef NCDEBUGPRINTFX
+ #warning "%%%%% delete that message later"
+ NCDEBUGPRINTFX(DBG_SYNCML,(
+ "xltAddToBuffer: memCpy failed, pBufMgr->smlXltBufferP=%lX, size=%ld",
+ (long)pBufMgr->smlXltBufferP,
+ size
+ ));
+ #endif
+ return SML_ERR_XLT_BUF_ERR;
+ }
+ pBufMgr->smlXltBufferP += size;
+ }
+ pBufMgr->smlXltWrittenBytes += size;
+
+ return SML_ERR_OK;
+}
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltencwbxml.c b/engine/dmlib/dmengine/oma_toolkit/src/xltencwbxml.c
new file mode 100644
index 0000000..6f4595d
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltencwbxml.c
@@ -0,0 +1,311 @@
+/*************************************************************************/
+/* module: The WBXML Encoder source file */
+/* file: xltencwbxml.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#include <define.h>
+#ifdef __SML_WBXML__
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xltencwbxml.h"
+#include <libmem.h>
+#include <libstr.h>
+#include "xlttags.h"
+
+
+/**
+ * FUNCTION: wbxmlGetGlobToken
+ *
+ * Converts a element type into its wbxml token
+ *
+ * PRE-Condition: valid element type
+ *
+ * POST-Condition: return of wbxml token
+ *
+ * IN: elType, element type
+ *
+ * OUT: wbxml token
+ *
+ * RETURN: wbxml token
+ * 0, if no matching wbxml token
+ */
+MemByte_t wbxmlGetGlobToken(XltElementType_t elType)
+{
+
+ typedef struct GlobTok_s
+ {
+ XltElementType_t id;
+ MemByte_t wbxml;
+ } GlobTok_t;
+
+ // encoding of global tokens; related to the type XML_ElementType_t
+ GlobTok_t globtoken[] =
+ {
+ { END, 0x01 }, //Tag End
+ { STR_I, 0x03 }, //Inline string
+ { OPAQUE, 0xC3 }, //Opaque Data
+ { UNDEF, 0x00 }
+ };
+
+ int i = -1;
+ while (globtoken[++i].id != UNDEF)
+ if (globtoken[i].id == elType)
+ return globtoken[i].wbxml;
+ return 0;
+
+}
+
+/**
+ * FUNCTION: wbxmlOpaqueSize2Buf
+ *
+ * Converts a Long_t opaque size to a wbxml mb_u_int32 and adds it to the buffer
+ *
+ * PRE-Condition: size of the content to be written as opaque datatype
+ *
+ * POST-Condition: the size is converted to the mb_u_int32 representation and added
+ * to the buffer
+ *
+ * IN: size, length of the opaque data
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t wbxmlOpaqueSize2Buf(Long_t size, BufferMgmtPtr_t pBufMgr)
+{
+ Long_t _thresholdcount = 1;
+ Long_t _bytesNeeded = 0;
+ MemPtr_t _byteArray;
+ MemPtr_t _tmpByteArray;
+ int i, j;
+ Ret_t _err = SML_ERR_OK;
+
+ //j max = number of bytes of size
+ for (j=1; j<=sizeof(size); j++)
+ {
+ //if the size of the content is smaller than the power of 128,j ->
+ //one more byte is needed in the mb_u_int32 representation of WBXML
+ _thresholdcount = _thresholdcount * 128;
+ if(size < _thresholdcount)
+ {
+ _bytesNeeded = j;
+ break;
+ }
+ }
+
+ if (pBufMgr->spaceEvaluation == 0)
+ {
+ //allocate number of bytes needed by the mb_u_int32 data type
+ if ((_byteArray = smlLibMalloc(_bytesNeeded)) == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+
+ _tmpByteArray = _byteArray;
+
+ //process al bytes in the mb_u_int32 data type
+ for (i=1; i<=_bytesNeeded; i++)
+ {
+ // the lowest byte needs a 0 in its highest bit -> no | 0x80
+ if ((_bytesNeeded - i) == 0)
+ {
+ *_tmpByteArray = ((unsigned char)(size & 0x7F));
+ }
+ // all the other byte needs a 1 in its highest bit -> | 0x80
+ else
+ {
+ // only the seven lower bits contain the size value -> >> 7
+ *_tmpByteArray = ((unsigned char)(((size >> (7 * (_bytesNeeded - i))) & 0x7F) | 0x80));
+ _tmpByteArray++;
+ }
+ }
+
+ _err = xltAddToBuffer(_byteArray, _bytesNeeded, pBufMgr);
+
+ smlLibFree(_byteArray);
+ } else {
+ pBufMgr->smlXltWrittenBytes += _bytesNeeded;
+ // %%% luz 2002-09-03: return value was missing here.
+ _err=SML_ERR_OK;
+ }
+
+ return _err;
+}
+
+/**
+ * FUNCTION: wbxmlGenerateTag
+ *
+ * Generates a tag for a given tag ID and a given tag type
+ *
+ * PRE-Condition: valid parameters
+ *
+ * POST-Condition: a new wbxml tag is written to the buffer
+ *
+ * IN: tagId, the ID for the tag to generate (TN_ADD, ...)
+ * tagType, the tag type (e.g. Begin Tag -> TT_BEG, ...)
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t wbxmlGenerateTag(XltTagID_t tagId, XltTagType_t tagType, BufferMgmtPtr_t pBufMgr )
+{
+
+ Ret_t _err = SML_ERR_OK;
+ MemByte_t _tmp = 0x00;
+
+ //check if content byte has to be added to the tag
+ switch (tagType)
+ {
+ //set the end tag
+ case TT_END:
+ {
+ _tmp = (MemByte_t)wbxmlGetGlobToken(END);
+ if (!_tmp) return SML_ERR_XLT_INVAL_TAG_TYPE;
+ _err = xltAddToBuffer((&_tmp), 1, pBufMgr);
+ // remember the number of byte that must follow for the according end-tag
+ if (_err == SML_ERR_OK) pBufMgr->endTagSize -= 1;
+ return _err;
+ }
+ //Begin and End Tag in one
+ case TT_ALL:
+ {
+ _err = (MemByte_t)getTagByte(tagId, pBufMgr->smlCurExt, &_tmp);
+ if ((!_tmp) || (_err != SML_ERR_OK)) return _err;
+ return xltAddToBuffer((MemPtr_t)(&_tmp), 1, pBufMgr);
+ }
+ //Only Begin Tag -> content follows -> content byte has to be added
+ case TT_BEG:
+ {
+ _err = (MemByte_t)getTagByte(tagId, pBufMgr->smlCurExt, &_tmp);
+ if ((!_tmp) || (_err != SML_ERR_OK)) return _err;
+
+ _tmp = ((MemByte_t)(_tmp | XLT_CONTBYTE));
+ _err = xltAddToBuffer(&_tmp, 1, pBufMgr);
+ // remember the number of byte that must follow for the according end-tag
+ if (_err == SML_ERR_OK) pBufMgr->endTagSize += 1;
+ return _err;
+ }
+ default:
+ return SML_ERR_XLT_INVAL_TAG_TYPE;
+ }
+
+ // return SML_ERR_OK;Unreachable
+}
+
+/**
+ * FUNCTION: wbxmlWriteTypeToBuffer
+ *
+ * Write a content of a certain WBXML element type (e.g. STR_I) to the global buffer
+ *
+ * PRE-Condition: valid parameters
+ *
+ * POST-Condition: the content is written to the wbxml buffer with the leading
+ * bytes for the opaque data type or the STR_I data type
+ *
+ * IN: pContent, the character pointer referencing the content to
+ * write to the buffer
+ * elType, the element type to write to the buffer (e.g. STR_I)
+ * size, the content length
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t wbxmlWriteTypeToBuffer(const MemPtr_t pContent, XltElementType_t elType, Long_t size, BufferMgmtPtr_t pBufMgr)
+{
+ Ret_t _err;
+
+ MemByte_t _termstr = XLT_TERMSTR;
+ MemByte_t _tmp;
+
+ switch((int)elType)
+ {
+ case TAG:
+ {
+
+ return (xltAddToBuffer(pContent, size, pBufMgr));
+
+ }
+ case STR_I:
+ {
+ _tmp = (MemByte_t)wbxmlGetGlobToken(STR_I);
+ if (!_tmp) return SML_ERR_XLT_WBXML_UKN_TOK;
+
+ //add the STR_I identifier
+ if ((_err = xltAddToBuffer(&_tmp, 1, pBufMgr)) != SML_ERR_OK) return _err;
+
+ //add the string to the buffer
+ if ((_err = xltAddToBuffer(pContent, (!pContent) ? 0 : smlLibStrlen((String_t)pContent), pBufMgr)) != SML_ERR_OK) return _err;
+
+ //add the string terminator '\0'
+ if ((_err = xltAddToBuffer(&_termstr, 1, pBufMgr)) != SML_ERR_OK) return _err;
+
+ return SML_ERR_OK;
+ }
+ case OPAQUE:
+ {
+ _tmp = (MemByte_t)wbxmlGetGlobToken(OPAQUE);
+ if (!_tmp) return SML_ERR_XLT_WBXML_UKN_TOK;
+
+
+
+ //add the OPAQUE identifier
+ if ((_err = xltAddToBuffer(&_tmp, 1, pBufMgr)) != SML_ERR_OK) return _err;
+
+ //add the pContent length
+ if ((_err = wbxmlOpaqueSize2Buf(size, pBufMgr)) != SML_ERR_OK) return _err;
+
+ //add the string buffer
+ if ((_err = xltAddToBuffer(pContent, size, pBufMgr)) != SML_ERR_OK) return _err;
+
+ return SML_ERR_OK;
+ }
+ default:
+ return SML_ERR_XLT_INVAL_PCDATA_TYPE;
+ }
+
+// return SML_ERR_OK;unreachable
+}
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltencxml.c b/engine/dmlib/dmengine/oma_toolkit/src/xltencxml.c
new file mode 100644
index 0000000..0f88f9a
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltencxml.c
@@ -0,0 +1,170 @@
+/*************************************************************************/
+/* module: The XML Encoder source file */
+/* file: xltencxml.c */
+/* target system: All */
+/* target OS: All */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#include <define.h>
+#ifdef __SML_XML__
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xltencxml.h"
+#include <libstr.h>
+#include "xlttags.h"
+#include <libmem.h>
+
+/**
+ * FUNCTION: xmlGenerateTag
+ *
+ * Generates a XML tag
+ *
+ * PRE-Condition: valid parameters
+ *
+ * POST-Condition: the XML tag is written to the XML buffer
+ *
+ * IN: tagId, the ID for the tag to generate (TN_ADD, ...)
+ * tagType, the tag type (e.g. Begin Tag -> TT_BEG, ...)
+ * attFlag, indicates if the encoded tag contain Attributes in namespace extensions
+ *
+ * IN/OUT: pBufMgr, pointer to a structure containing buffer management elements
+ *
+ * RETURN: shows error codes of function,
+ * 0, if OK
+ */
+Ret_t xmlGenerateTag(XltTagID_t tagId, XltTagType_t tagType, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag)
+{
+ Ret_t _err;
+
+ MemByte_t _begpar = XML_BEGPAR;
+ MemByte_t _tagdel = XML_TAGDEL;
+ MemByte_t _endpar = XML_ENDPAR;
+ MemByte_t _nstagstart[] = XML_NSSTART;
+ MemByte_t _nstagend[] = XML_NSEND;
+
+
+ String_t _tagstr;
+ String_t _tagnsattr = NULL;
+
+ if ((_tagstr = (String_t)smlLibMalloc(XML_MAX_TAGLEN)) == NULL) return SML_ERR_NOT_ENOUGH_SPACE;
+
+ if ((_err = getTagString(tagId, _tagstr, attFlag)) != SML_ERR_OK) {
+ smlLibFree(_tagstr);
+ return _err;
+ }
+
+ if (!_tagstr) { // check again as _tagstr might be alterd in getTagString
+ smlLibFree(_tagstr);
+ return SML_ERR_XLT_INVAL_TAG_TYPE;
+ }
+
+ /* the <SyncML> tag _must_ have an xmlns attribute */
+ if (attFlag != pBufMgr->smlActiveExt || tagId == TN_SYNCML) {
+ // %%% luz:2003-07-31: now uses namespace from table according to version
+ if (getExtName(attFlag, &_tagnsattr, pBufMgr->vers) != SML_ERR_OK) {
+ smlLibFree(_tagstr);
+ return SML_ERR_XLT_INVAL_TAG_TYPE;
+ }
+ }
+ pBufMgr->smlActiveExt = attFlag;
+ //check if content byte has to be added to the tag
+ switch (tagType)
+ {
+ // set the end tag
+ case TT_END:
+ {
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_tagdel), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagstr, smlLibStrlen(_tagstr), pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, pBufMgr)) != SML_ERR_OK) break;
+ if (tagId == pBufMgr->switchExtTag) {
+ pBufMgr->smlActiveExt = pBufMgr->smlLastExt;
+ pBufMgr->smlCurExt = pBufMgr->smlLastExt;
+ pBufMgr->smlLastExt = attFlag;
+ }
+ // just forget the stored number ob bytes for this end-tag since written now
+ pBufMgr->endTagSize -= (3 + smlLibStrlen(_tagstr));
+ break;
+ }
+ //Empty tag
+ case TT_ALL:
+ {
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagstr, smlLibStrlen(_tagstr), pBufMgr)) != SML_ERR_OK) break;
+ if (_tagnsattr) {
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_nstagstart), 8, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagnsattr, smlLibStrlen(_tagnsattr), pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)&_nstagend, 1, pBufMgr)) != SML_ERR_OK) break;
+ }
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_tagdel), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, pBufMgr)) != SML_ERR_OK) break;
+
+ break;
+ }
+ //Only Begin Tag -> content follows -> content byte has to be added
+ case TT_BEG:
+ {
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_begpar), 1, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagstr, smlLibStrlen(_tagstr), pBufMgr)) != SML_ERR_OK) break;
+ if (_tagnsattr) {
+ if ((_err = xltAddToBuffer((MemPtr_t)&_nstagstart, 8, pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)_tagnsattr, smlLibStrlen(_tagnsattr), pBufMgr)) != SML_ERR_OK) break;
+ if ((_err = xltAddToBuffer((MemPtr_t)&_nstagend, 1, pBufMgr)) != SML_ERR_OK) break;
+ }
+ if ((_err = xltAddToBuffer((MemPtr_t)(&_endpar), 1, pBufMgr)) != SML_ERR_OK) break;
+
+ // remember the number of byte that must follow for the according end-tag
+ pBufMgr->endTagSize += (3 + smlLibStrlen(_tagstr));
+ break;
+ }
+ default:
+ {
+ smlLibFree(_tagstr);
+ smlLibFree(_tagnsattr);
+ return SML_ERR_XLT_INVAL_TAG_TYPE;
+ }
+ }
+ smlLibFree(_tagstr);
+ smlLibFree(_tagnsattr);
+ return _err;
+}
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltmetinf.c b/engine/dmlib/dmengine/oma_toolkit/src/xltmetinf.c
new file mode 100644
index 0000000..70966bf
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltmetinf.c
@@ -0,0 +1,354 @@
+/*************************************************************************/
+/* module: MetaInf DTD related functions for the en-/decoder */
+/* file: xltmetinf.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#include "define.h"
+#ifdef __USE_METINF__
+
+#include "smlmetinfdtd.h"
+#include "xlttags.h"
+#include "xltmetinf.h"
+#include "xlttagtbl.h"
+#include "xltenc.h"
+#include "xltencwbxml.h"
+
+#include <define.h>
+#include <libstr.h>
+#include <smlerr.h>
+#include <smldtd.h>
+#include <libmem.h>
+#include <libutil.h>
+/* extern */
+ extern SML_API void smlFreeMetinfAnchor(SmlMetInfAnchorPtr_t data);
+ extern SML_API void smlFreeMetinfMem(SmlMetInfMemPtr_t data);
+ extern SML_API void smlFreeMetinfMetinf(SmlMetInfMetInfPtr_t data);
+
+
+/* decoder callbacks */
+Ret_t buildMetInfAnchorCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlMetInfAnchorPtr_t pAnchor;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pAnchor = (SmlMetInfAnchorPtr_t)smlLibMalloc(sizeof(SmlMetInfAnchor_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pAnchor, 0, sizeof(SmlMetInfAnchor_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pAnchor;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfAnchor(pAnchor);
+ //smlLibFree(pAnchor);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_METINF_LAST:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAnchor->last);
+ break;
+ case TN_METINF_NEXT:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pAnchor->next);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMetinfAnchor(pAnchor);
+ //smlLibFree(pAnchor);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfAnchor(pAnchor);
+ //smlLibFree(pAnchor);
+ return rc;
+ }
+ }
+ *ppElem = pAnchor;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildMetInfMemCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlMetInfMemPtr_t pMem;
+ Ret_t rc;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pMem = (SmlMetInfMemPtr_t)smlLibMalloc(sizeof(SmlMetInfMem_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pMem, 0, sizeof(SmlMetInfMem_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pMem;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMem(pMem);
+ //smlLibFree(pMem);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ /* PCDATA elements */
+ case TN_METINF_SHAREDMEM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMem->shared);
+ break;
+ case TN_METINF_FREEMEM:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMem->free);
+ break;
+ case TN_METINF_FREEID:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMem->freeid);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMetinfMem(pMem);
+ //smlLibFree(pMem);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMem(pMem);
+ //smlLibFree(pMem);
+ return rc;
+ }
+ }
+ *ppElem = pMem;
+
+ return SML_ERR_OK;
+}
+
+Ret_t buildMetInfMetInfCmd(XltDecoderPtr_t pDecoder, VoidPtr_t *ppElem) {
+ XltDecScannerPtr_t pScanner;
+ SmlMetInfMetInfPtr_t pMeta;
+ Ret_t rc;
+ int foundWrapper = 0;
+
+ pScanner = pDecoder->scanner;
+
+ if (*ppElem != NULL)
+ return SML_ERR_XLT_INVAL_SYNCML_DOC;
+
+ if ((pMeta = (SmlMetInfMetInfPtr_t)smlLibMalloc(sizeof(SmlMetInfMetInf_t))) == NULL)
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ smlLibMemset(pMeta, 0, sizeof(SmlMetInfMetInf_t));
+
+ if (IS_EMPTY(pScanner->curtok)) {
+ *ppElem = pMeta;
+ return SML_ERR_OK;
+ }
+
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMetinf(pMeta);
+ //smlLibFree(pMeta);
+ return rc;
+ }
+
+ while (pScanner->curtok->type != TOK_TAG_END) {
+ switch (pScanner->curtok->tagid) {
+ case TN_METINF_METINF: /* ignore - it's just the wrapper tag */
+ foundWrapper = 1;
+ break;
+ case TN_METINF_FORMAT:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->format);
+ break;
+ case TN_METINF_TYPE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->type);
+#ifdef __USE_DMTND__
+ if ( NULL != pMeta->type && NULL != pMeta->type->content )
+ {
+ if ( !smlLibStrcmp(pMeta->type->content, META_TYPE_TNDS_XML ) )
+ {
+ pDecoder->tndsEncoding = SML_XML;
+ }
+ else if ( !smlLibStrcmp(pMeta->type->content, META_TYPE_TNDS_XML ) )
+ {
+ pDecoder->tndsEncoding = SML_WBXML;
+ }
+ if ( pDecoder->smlEncoding != pDecoder->tndsEncoding )
+ {
+ KCDBG("Mismatching SML and TNDS encoding schema!");
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ }
+#endif
+ break;
+ case TN_METINF_MARK:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->mark);
+ break;
+ case TN_METINF_SIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->size);
+ break;
+ case TN_METINF_VERSION:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->version);
+ break;
+ case TN_METINF_NEXTNONCE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->nextnonce);
+ break;
+ case TN_METINF_ANCHOR:
+ rc = buildMetInfAnchorCmd(pDecoder, (VoidPtr_t)&pMeta->anchor);
+ break;
+ case TN_METINF_MAXMSGSIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->maxmsgsize);
+ break;
+ /* SCTSTK - 18/03/2002 S.H. 2002-04-05: SyncML 1.1 */
+ case TN_METINF_MAXOBJSIZE:
+ rc = buildPCData(pDecoder, (VoidPtr_t)&pMeta->maxobjsize);
+ break;
+ case TN_METINF_MEM:
+ rc = buildMetInfMemCmd(pDecoder, (VoidPtr_t)&pMeta->mem);
+ break;
+ case TN_METINF_EMI:
+ rc = buildPCDataList(pDecoder, (VoidPtr_t)&pMeta->emi);
+ break;
+ default:
+ rc = SML_ERR_XLT_INVAL_SYNCML_DOC;
+ }
+ if (rc != SML_ERR_OK) {
+ smlFreeMetinfMetinf(pMeta);
+ //smlLibFree(pMeta);
+ return rc;
+ }
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMetinf(pMeta);
+ //smlLibFree(pMeta);
+ return rc;
+ }
+ }
+
+ if (foundWrapper) {
+ /* Optional Metinf root tag was used in this message.
+ * The actual token is the closing root tag.
+ * It is required that the scanner points to the first tag _after_
+ * <MetInf>...</MetInf>, so we just skip to the next token and continue.
+ */
+ if (((rc = nextToken(pDecoder)) != SML_ERR_OK)) {
+ smlFreeMetinfMetinf(pMeta);
+ //smlLibFree(pMeta);
+ return rc;
+ }
+ }
+ *ppElem = pMeta;
+
+ return SML_ERR_OK;
+}
+
+
+
+/* see xltenc.c:XltEncBlock for description of parameters */
+Ret_t metinfEncBlock(XltTagID_t tagId, XltRO_t reqOptFlag, const VoidPtr_t pContent, SmlEncoding_t enc, BufferMgmtPtr_t pBufMgr, SmlPcdataExtension_t attFlag) {
+ //Return variable
+ Ret_t _err;
+ SmlPcdataListPtr_t pList = NULL;
+ //Check if pContent of a required field is missing
+ if ((reqOptFlag == REQUIRED) && (pContent == NULL))
+ return SML_ERR_XLT_MISSING_CONT;
+ //Check if pContent of a optional field is missing -> if yes we are done
+ else if (pContent == NULL)
+ return SML_ERR_OK;
+
+ //Generate the commands -> see DTD
+ switch (tagId) {
+ case TN_METINF_ANCHOR:
+ if ((_err = xltGenerateTag(TN_METINF_ANCHOR, TT_BEG, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_LAST, OPTIONAL, ((SmlMetInfAnchorPtr_t) pContent)->last, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_NEXT, REQUIRED, ((SmlMetInfAnchorPtr_t) pContent)->next, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_METINF_ANCHOR, TT_END, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_METINF_MEM:
+ if ((_err = xltGenerateTag(TN_METINF_MEM, TT_BEG, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_SHAREDMEM, OPTIONAL, ((SmlMetInfMemPtr_t) pContent)->shared, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_FREEMEM, REQUIRED, ((SmlMetInfMemPtr_t) pContent)->free, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_FREEID, REQUIRED, ((SmlMetInfMemPtr_t) pContent)->freeid, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = xltGenerateTag(TN_METINF_MEM, TT_END, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_METINF_SHAREDMEM:
+ //set the flag in the (WB)XML document if the flag is in the pContent
+ if ((*((Flag_t *) pContent)) & (SmlMetInfSharedMem_f))
+ if ((_err = xltGenerateTag(tagId, TT_ALL, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ break;
+ case TN_METINF_METINF:
+ //if ((_err = xltGenerateTag(TN_METINF_METINF, TT_BEG, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_FORMAT, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->format, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_TYPE, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->type, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_MARK, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->mark, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_SIZE, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->size, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_ANCHOR, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->anchor, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_VERSION, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->version, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_NEXTNONCE, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->nextnonce, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ if ((_err = metinfEncBlock(TN_METINF_MAXMSGSIZE,OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->maxmsgsize, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ // %%% luz 2003-04-24: added maxobjsize generation (was missing = bug in original RTK 4.1)
+ if ((_err = metinfEncBlock(TN_METINF_MAXOBJSIZE,OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->maxobjsize, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ pList = ((SmlMetInfMetInfPtr_t)pContent)->emi;
+ while (pList != NULL) {
+ if ((_err = xltEncBlock(TN_METINF_EMI, OPTIONAL, pList->data, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ pList = pList->next;
+ };
+
+ if ((_err = metinfEncBlock(TN_METINF_MEM, OPTIONAL, ((SmlMetInfMetInfPtr_t) pContent)->mem, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ //if ((_err = xltGenerateTag(TN_METINF_METINF, TT_END, enc, pBufMgr, SML_EXT_METINF)) != SML_ERR_OK) return _err;
+ break;
+ default: { // all leaf nodes (PCDATA#)
+ return xltEncPcdata(tagId, reqOptFlag, pContent, enc, pBufMgr, attFlag);
+ } /* eof default statement from switch tagid */
+ } /* eof switch tagid */
+ return SML_ERR_OK;
+}
+
+#endif /* __USE_METINF__ */
+
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xlttags.c b/engine/dmlib/dmengine/oma_toolkit/src/xlttags.c
new file mode 100644
index 0000000..758d4ec
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xlttags.c
@@ -0,0 +1,779 @@
+/*************************************************************************/
+/* module: Definition of WBXML/XML tags for the en-/decoder */
+/* file: XLTTags.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#include "xlttags.h"
+
+#include <libstr.h>
+#include <smlerr.h>
+#include <libmem.h>
+#include <libutil.h>
+#include <mgr.h>
+
+#include "xltmetinf.h"
+#include "xltdevinf.h"
+#include "xlttagtbl.h"
+
+
+// %%% luz:2003-07-31: added SyncML namespace tables
+const char * const SyncMLNamespaces[SML_NUM_VERS] = {
+ "???",
+ "SYNCML:SYNCML1.0",
+ "SYNCML:SYNCML1.1",
+ "SYNCML:SYNCML1.2"
+};
+
+/* local prototypes */
+#ifdef NOWSM
+const // without WSM, the tag table is a global read-only constant
+#endif
+TagPtr_t getTagTable(SmlPcdataExtension_t ext);
+
+//SmlPcdataExtension_t getByName(String_t ns);
+void freeDtdTable(DtdPtr_t tbl);
+
+#ifdef NOWSM
+const // without WSM, the DTD table is a global read-only constant
+#endif
+DtdPtr_t getDtdTable();
+
+
+// free table obtained with getDtdTable()
+void freeDtdTable(DtdPtr_t tbl)
+{
+ #ifndef NOWSM
+ // only with WSM this is an allocated table
+ smlLibFree(tbl);
+ #endif
+}
+
+/**
+ * FUNCTION: getDtdTable
+ *
+ * Returns a copy of the table containing all known (sub) dtd's
+ * On error a NULL pointer is returned
+ */
+#ifdef NOWSM
+const // without WSM, the DTD table is a global read-only constant
+#endif
+DtdPtr_t getDtdTable() {
+ #ifdef NOWSM
+ // NOWSM method, table is const, just return a pointer
+ static const Dtd_t XltDtdTbl[] = {
+ { "SYNCML:SYNCML1.0", SML_EXT_UNDEFINED}, // %%% note that this is the default, will be override by syncml version specific string from
+ { "syncml:metinf", SML_EXT_METINF},
+ { "syncml:devinf", SML_EXT_DEVINF},
+ { "syncml:dmddf1.2", SML_EXT_DMTND},
+ { NULL, SML_EXT_LAST}
+ };
+ return (DtdPtr_t)XltDtdTbl;
+ #else
+ // WSM method wasting a lot of memory
+ DtdPtr_t _tmpPtr;
+
+ Dtd_t XltDtdTbl[] = {
+ { "SYNCML:SYNCML1.0", SML_EXT_UNDEFINED},
+ { "syncml:metinf", SML_EXT_METINF},
+ { "syncml:devinf", SML_EXT_DEVINF},
+ { "syncml:dmddf1.2", SML_EXT_DMTND},
+ { NULL, SML_EXT_LAST}
+ };
+ _tmpPtr = NULL;
+ _tmpPtr = (DtdPtr_t)smlLibMalloc(sizeof(XltDtdTbl));
+ if (_tmpPtr == NULL) return NULL;
+ smlLibMemcpy(_tmpPtr, &XltDtdTbl, sizeof(XltDtdTbl));
+ return _tmpPtr;
+ #endif
+}
+
+
+/**
+ * FUNCTION: getExtName
+ *
+ * Returns the official name for a given extention/sub-DTD
+ * and stored it in 'name'. If not found name isn't modified
+ */
+// %%% luz:2003-04-24: added syncmlvers parameter
+// %%% luz:2003-07-31: changed to vers enum
+Ret_t getExtName(SmlPcdataExtension_t ext, String_t *name, SmlVersion_t vers) {
+ DtdPtr_t dtdhead = getDtdTable();
+ DtdPtr_t dtd = dtdhead;
+ const char *dtdname;
+ if (!dtdhead) return -1;
+ for (;dtd->ext != SML_EXT_LAST; dtd++) {
+ if (!dtd->name) continue; /* skip empty names (should not appear but better be on the safe side) */
+ if (dtd->ext == ext) {
+ String_t _tmp;
+ // this is the default
+ dtdname=dtd->name;
+ // %%% luz:2003-04-24: added dynamic generation of namespace according to SyncML version
+ if (ext==SML_EXT_UNDEFINED && vers!=SML_VERS_UNDEF) {
+ // this requests SyncML namespace
+ if (vers >= SML_NUM_VERS )
+ {
+ return SML_ERR_INVALID_SIZE;
+ }
+ dtdname=SyncMLNamespaces[vers];
+ }
+ _tmp = smlLibMalloc(smlLibStrlen(dtdname)+1);
+ if (!_tmp) {
+ freeDtdTable(dtdhead);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ smlLibStrcpy(_tmp, dtdname);
+ freeDtdTable(dtdhead);
+ *name = _tmp;
+ return SML_ERR_OK;
+ }
+ }
+ freeDtdTable(dtdhead);
+ return -1;
+}
+
+/**
+ * FUNCTION: getCpByName
+ *
+ * Returns the codepage constant assoziated with the name stored in 'ns'
+ *
+ * RETURN: a SmlPcdataExtension_t representing the corresponding codepage id.
+ * If no corresponding codepage is found -1 is returned.
+ */
+SmlPcdataExtension_t getExtByName(String_t ns) {
+ DtdPtr_t dtdhead = getDtdTable();
+ DtdPtr_t dtd = dtdhead;
+ SmlPcdataExtension_t ext = (SmlPcdataExtension_t) 255;
+ if (!dtdhead) return SML_EXT_UNDEFINED;
+ for (;dtd->ext != SML_EXT_LAST; dtd++) {
+ const char *dtdname=dtd->name;
+ if (!dtdname) continue; /* skip empty names (should not appear but better be on the safe side) */
+ if (dtd->ext==SML_EXT_UNDEFINED && smlLibStrncmp("SYNCML:SYNCML",ns,13)==0) {
+ // SyncML namespace is ok without checking version!
+ ext = SML_EXT_UNDEFINED;
+ break;
+ }
+ else if (smlLibStrcmp(dtdname,ns) == 0) {
+ ext = dtd->ext;
+ break;
+ }
+ }
+ freeDtdTable(dtdhead);
+ return ext;
+}
+
+
+
+/* if the commands are not defined we let the functions point to NULL */
+#ifndef RESULT_RECEIVE
+#define buildResults NULL
+#endif
+
+#ifndef MAP_RECEIVE
+#define buildMap NULL
+#endif
+
+#ifndef EXEC_RECEIVE
+#define buildExec NULL
+#endif
+
+#if !defined(ATOM_RECEIVE) && !defined(SEQUENCE_RECEIVE)
+#define buildAtomOrSeq NULL
+#endif
+
+#ifndef SEARCH_RECEIVE
+#define buildSearch NULL
+#endif
+
+
+/**
+ * FUNCTION: getTagTable
+ *
+ * Returns the tag table - this function is used to avoid a global
+ * tag table variable
+ *
+ * RETURN: a pointer to the tag table containing tag ids,
+ * codepages, wbxml tags and xml tags
+ */
+/* T.K. initialized the structure via _TOKEN Macro, to take
+ * out the XML name tags when not compiled with XML support.
+ * In addtion removed the (unused) pointer for the build functions
+ */
+#ifdef __SML_XML__
+#define _TOKEN(id, wbxml, xml) (id), (wbxml), (xml)
+#else
+#define _TOKEN(id, wbxml, xml) (id), (wbxml), ""
+#endif
+
+#ifdef NOWSM
+const // without WSM, the tag table is a global read-only constant
+#endif
+TagPtr_t getTagTable(SmlPcdataExtension_t ext)
+{
+ #ifndef NOWSM
+ int mySize = 0;
+ TagPtr_t _tmpTagPtr;
+ SyncMLInfoPtr_t pGA = NULL;
+ #else
+ TagPtr_t _tmpTagPtr=NULL;
+ #endif
+ /* standard SyncML codepage */
+ static const Tag_t syncml[] =
+ {
+ { _TOKEN(TN_ADD, 0x05, "Add")},
+ { _TOKEN(TN_ALERT, 0x06, "Alert")},
+ { _TOKEN(TN_ARCHIVE, 0x07, "Archive")},
+ { _TOKEN(TN_ATOMIC, 0x08, "Atomic")},
+ { _TOKEN(TN_CHAL, 0x09, "Chal")},
+ { _TOKEN(TN_CMD, 0x0A, "Cmd")},
+ { _TOKEN(TN_CMDID, 0x0B, "CmdID")},
+ { _TOKEN(TN_CMDREF, 0x0C, "CmdRef")},
+ { _TOKEN(TN_COPY, 0x0D, "Copy")},
+ { _TOKEN(TN_CRED, 0x0E, "Cred")},
+ { _TOKEN(TN_DATA, 0x0F, "Data")},
+ { _TOKEN(TN_DELETE, 0x10, "Delete")},
+ { _TOKEN(TN_EXEC, 0x11, "Exec")},
+ { _TOKEN(TN_FINAL, 0x12, "Final")},
+ { _TOKEN(TN_GET, 0x13, "Get")},
+ { _TOKEN(TN_ITEM, 0x14, "Item")},
+ { _TOKEN(TN_LANG, 0x15, "Lang")},
+ { _TOKEN(TN_LOCNAME, 0x16, "LocName")},
+ { _TOKEN(TN_LOCURI, 0x17, "LocURI")},
+ { _TOKEN(TN_MAP, 0x18, "Map")},
+ { _TOKEN(TN_MAPITEM, 0x19, "MapItem")},
+ { _TOKEN(TN_META, 0x1A, "Meta")},
+ { _TOKEN(TN_MSGID, 0x1B, "MsgID")},
+ { _TOKEN(TN_MSGREF, 0x1C, "MsgRef")},
+ { _TOKEN(TN_NORESP, 0x1D, "NoResp")},
+ { _TOKEN(TN_NORESULTS, 0x1E, "NoResults")},
+ { _TOKEN(TN_PUT, 0x1F, "Put")},
+ { _TOKEN(TN_REPLACE, 0x20, "Replace")},
+ { _TOKEN(TN_RESPURI, 0x21, "RespURI")},
+ { _TOKEN(TN_RESULTS, 0x22, "Results")},
+ { _TOKEN(TN_SEARCH, 0x23, "Search")},
+ { _TOKEN(TN_SEQUENCE, 0x24, "Sequence")},
+ { _TOKEN(TN_SESSIONID, 0x25, "SessionID")},
+ { _TOKEN(TN_SFTDEL, 0x26, "SftDel")},
+ { _TOKEN(TN_SOURCE, 0x27, "Source")},
+ { _TOKEN(TN_SOURCEREF, 0x28, "SourceRef")},
+ { _TOKEN(TN_STATUS, 0x29, "Status")},
+ { _TOKEN(TN_SYNC, 0x2A, "Sync")},
+ { _TOKEN(TN_SYNCBODY, 0x2B, "SyncBody")},
+ { _TOKEN(TN_SYNCHDR, 0x2C, "SyncHdr")},
+ { _TOKEN(TN_SYNCML, 0x2D, "SyncML")},
+ { _TOKEN(TN_TARGET, 0x2E, "Target")},
+ { _TOKEN(TN_TARGETREF, 0x2F, "TargetRef")},
+ { _TOKEN(TN_VERSION, 0x31, "VerDTD")},
+ { _TOKEN(TN_PROTO, 0x32, "VerProto")},
+ { _TOKEN(TN_NUMBEROFCHANGES,0x33, "NumberOfChanges")},
+ { _TOKEN(TN_MOREDATA, 0x34, "MoreData")},
+ /* from version 1.2 */
+ { _TOKEN(TN_CORRELATOR, 0x3C, "Correlator")},
+
+ { _TOKEN(TN_UNDEF, 0x00, NULL)}
+ };
+
+ #ifdef __USE_METINF__
+ static const Tag_t metinf[] = {
+ { _TOKEN(TN_METINF_ANCHOR, 0x05, "Anchor")},
+ { _TOKEN(TN_METINF_EMI, 0x06, "EMI")},
+ { _TOKEN(TN_METINF_FORMAT, 0x07, "Format")},
+ { _TOKEN(TN_METINF_FREEID, 0x08, "FreeID")},
+ { _TOKEN(TN_METINF_FREEMEM, 0x09, "FreeMem")},
+ { _TOKEN(TN_METINF_LAST, 0x0A, "Last")},
+ { _TOKEN(TN_METINF_MARK, 0x0B, "Mark")},
+ { _TOKEN(TN_METINF_MAXMSGSIZE, 0x0C, "MaxMsgSize")},
+ { _TOKEN(TN_METINF_MEM, 0x0D, "Mem")},
+ { _TOKEN(TN_METINF_METINF, 0x0E, "MetInf")},
+ { _TOKEN(TN_METINF_NEXT, 0x0F, "Next")},
+ { _TOKEN(TN_METINF_NEXTNONCE, 0x10, "NextNonce")},
+ { _TOKEN(TN_METINF_SHAREDMEM, 0x11, "SharedMem")},
+ { _TOKEN(TN_METINF_SIZE, 0x12, "Size")},
+ { _TOKEN(TN_METINF_TYPE, 0x13, "Type")},
+ { _TOKEN(TN_METINF_VERSION, 0x14, "Version")},
+ /* SCTSTK - 18/03/2002, S.H. 2002-04-05 : SyncML 1.1 */
+ { _TOKEN(TN_METINF_MAXOBJSIZE, 0x15, "MaxObjSize")},
+ { _TOKEN(TN_UNDEF, 0x00, NULL)}
+ };
+ #endif
+
+
+ #ifdef __USE_DEVINF__
+ static const Tag_t devinf[] = {
+ {_TOKEN(TN_DEVINF_CTCAP, 0x05, "CTCap")},
+ {_TOKEN(TN_DEVINF_CTTYPE, 0x06, "CTType")},
+ {_TOKEN(TN_DEVINF_DATASTORE, 0x07, "DataStore")},
+ {_TOKEN(TN_DEVINF_DATATYPE, 0x08, "DataType")},
+ {_TOKEN(TN_DEVINF_DEVID, 0x09, "DevID")},
+ {_TOKEN(TN_DEVINF_DEVINF, 0x0A, "DevInf")},
+ {_TOKEN(TN_DEVINF_DEVTYP, 0x0B, "DevTyp")},
+ {_TOKEN(TN_DEVINF_DISPLAYNAME, 0x0C, "DisplayName")},
+ {_TOKEN(TN_DEVINF_DSMEM, 0x0D, "DSMem")},
+ {_TOKEN(TN_DEVINF_EXT, 0x0E, "Ext")},
+ {_TOKEN(TN_DEVINF_FWV, 0x0F, "FwV")},
+ {_TOKEN(TN_DEVINF_HWV, 0x10, "HwV")},
+ {_TOKEN(TN_DEVINF_MAN, 0x11, "Man")},
+ {_TOKEN(TN_DEVINF_MAXGUIDSIZE, 0x12, "MaxGUIDSize")},
+ {_TOKEN(TN_DEVINF_MAXID, 0x13, "MaxID")},
+ {_TOKEN(TN_DEVINF_MAXMEM, 0x14, "MaxMem")},
+ {_TOKEN(TN_DEVINF_MOD, 0x15, "Mod")},
+ {_TOKEN(TN_DEVINF_OEM, 0x16, "OEM")},
+ {_TOKEN(TN_DEVINF_PARAMNAME, 0x17, "ParamName")},
+ {_TOKEN(TN_DEVINF_PROPNAME, 0x18, "PropName")},
+ {_TOKEN(TN_DEVINF_RX, 0x19, "Rx")},
+ {_TOKEN(TN_DEVINF_RXPREF, 0x1A, "Rx-Pref")},
+ {_TOKEN(TN_DEVINF_SHAREDMEM, 0x1B, "SharedMem")},
+ {_TOKEN(TN_DEVINF_SIZE, 0x1C, "Size")},
+ {_TOKEN(TN_DEVINF_SOURCEREF, 0x1D, "SourceRef")},
+ {_TOKEN(TN_DEVINF_SWV, 0x1E, "SwV")},
+ {_TOKEN(TN_DEVINF_SYNCCAP, 0x1F, "SyncCap")},
+ {_TOKEN(TN_DEVINF_SYNCTYPE, 0x20, "SyncType")},
+ {_TOKEN(TN_DEVINF_TX, 0x21, "Tx")},
+ {_TOKEN(TN_DEVINF_TXPREF, 0x22, "Tx-Pref")},
+ {_TOKEN(TN_DEVINF_VALENUM, 0x23, "ValEnum")},
+ {_TOKEN(TN_DEVINF_VERCT, 0x24, "VerCT")},
+ {_TOKEN(TN_DEVINF_VERDTD, 0x25, "VerDTD")},
+ {_TOKEN(TN_DEVINF_XNAM, 0x26, "XNam")},
+ {_TOKEN(TN_DEVINF_XVAL, 0x27, "XVal")},
+ // %%% luz:2003-04-28 : added these, they were missing
+ {_TOKEN(TN_DEVINF_UTC, 0x28, "UTC")},
+ {_TOKEN(TN_DEVINF_NOFM, 0x29, "SupportNumberOfChanges")},
+ {_TOKEN(TN_DEVINF_LARGEOBJECT, 0x2A, "SupportLargeObjs")},
+ // %%% end luz
+ { _TOKEN(TN_UNDEF, 0x00, NULL)}
+ };
+ #endif
+
+ #ifdef __USE_DMTND__
+ static const Tag_t dmtnd[] = {
+ { _TOKEN(TN_DMTND_AccessType, 0x05, "AccessType")},
+ { _TOKEN(TN_DMTND_ACL, 0x06, "ACL")},
+ { _TOKEN(TN_DMTND_Add, 0x07, "Add")},
+ { _TOKEN(TN_DMTND_b64, 0x08, "b64")},
+ { _TOKEN(TN_DMTND_bin, 0x09, "bin")},
+ { _TOKEN(TN_DMTND_bool, 0x0A, "bool")},
+ { _TOKEN(TN_DMTND_chr, 0x0B, "chr")},
+ { _TOKEN(TN_DMTND_CaseSense, 0x0C, "CaseSense")},
+ { _TOKEN(TN_DMTND_CIS, 0x0D, "CIS")},
+ { _TOKEN(TN_DMTND_Copy, 0x0E, "Copy")},
+ { _TOKEN(TN_DMTND_CS, 0x0F, "CS")},
+ { _TOKEN(TN_DMTND_date, 0x10, "date")},
+ { _TOKEN(TN_DMTND_DDFName, 0x11, "DDFName")},
+ { _TOKEN(TN_DMTND_DefaultValue, 0x12, "DefaultValue")},
+ { _TOKEN(TN_DMTND_Delete, 0x13, "Delete")},
+ { _TOKEN(TN_DMTND_Description, 0x14, "Description")},
+ { _TOKEN(TN_DMTND_DFFormat, 0x15, "DFFormat")},
+ { _TOKEN(TN_DMTND_DFProperties, 0x16, "DFProperties")},
+ { _TOKEN(TN_DMTND_DFTitle, 0x17, "DFTitle")},
+ { _TOKEN(TN_DMTND_DFType, 0x18, "DFType")},
+ { _TOKEN(TN_DMTND_Dynamic, 0x19, "Dynamic")},
+ { _TOKEN(TN_DMTND_Exec, 0x1A, "Exec")},
+ { _TOKEN(TN_DMTND_float, 0x1B, "float")},
+ { _TOKEN(TN_DMTND_Format, 0x1C, "Format")},
+ { _TOKEN(TN_DMTND_Get, 0x1D, "Get")},
+ { _TOKEN(TN_DMTND_int, 0x1E, "int")},
+ { _TOKEN(TN_DMTND_Man, 0x1F, "Man")},
+ { _TOKEN(TN_DMTND_MgmtTree, 0x20, "MgmtTree")},
+ { _TOKEN(TN_DMTND_MIME, 0x21, "MIME")},
+ { _TOKEN(TN_DMTND_Mod, 0x22, "Mod")},
+ { _TOKEN(TN_DMTND_Name, 0x23, "Name")},
+ { _TOKEN(TN_DMTND_Node, 0x24, "Node")},
+ { _TOKEN(TN_DMTND_node, 0x25, "node")},
+ { _TOKEN(TN_DMTND_NodeName, 0x26, "NodeName")},
+ { _TOKEN(TN_DMTND_null, 0x27, "null")},
+ { _TOKEN(TN_DMTND_Occurrence, 0x28, "Occurrence")},
+ { _TOKEN(TN_DMTND_One, 0x29, "One")},
+ { _TOKEN(TN_DMTND_OneOrMore, 0x2A, "OneOrMore")},
+ { _TOKEN(TN_DMTND_OneOrN, 0x2B, "OneOrN")},
+ { _TOKEN(TN_DMTND_Path, 0x2C, "Path")},
+ { _TOKEN(TN_DMTND_Permanent, 0x2D, "Permanent")},
+ { _TOKEN(TN_DMTND_Replace, 0x2E, "Replace")},
+ { _TOKEN(TN_DMTND_RTProperties, 0x2F, "RTProperties")},
+ { _TOKEN(TN_DMTND_Scope, 0x30, "Scope")},
+ { _TOKEN(TN_DMTND_Size, 0x31, "Size")},
+ { _TOKEN(TN_DMTND_time, 0x32, "time")},
+ { _TOKEN(TN_DMTND_Title, 0x33, "Title")},
+ { _TOKEN(TN_DMTND_TStamp, 0x34, "TStamp")},
+ { _TOKEN(TN_DMTND_Type, 0x35, "Type")},
+ { _TOKEN(TN_DMTND_Value, 0x36, "Value")},
+ { _TOKEN(TN_DMTND_VerDTD, 0x37, "VerDTD")},
+ { _TOKEN(TN_DMTND_VerNo, 0x38, "VerNo")},
+ { _TOKEN(TN_DMTND_xml, 0x39, "xml")},
+ { _TOKEN(TN_DMTND_ZeroOrMore, 0x3A, "ZeroOrMore")},
+ { _TOKEN(TN_DMTND_ZeroOrN, 0x3B, "ZeroOrN")},
+ { _TOKEN(TN_DMTND_ZeroOrOne, 0x3C, "ZeroOrOne") }
+ };
+ #endif
+
+ #ifndef NOWSM
+ _tmpTagPtr = NULL;
+ pGA = mgrGetSyncMLAnchor();
+ if (pGA == NULL) return NULL;
+ #endif
+
+ /* get the correct codepage */
+ if (ext == SML_EXT_UNDEFINED) {
+ #ifndef NOWSM
+ _tmpTagPtr = pGA->tokTbl->SyncML;
+ if (_tmpTagPtr == NULL) {
+ mySize = sizeof(syncml);
+ pGA->tokTbl->SyncML = (TagPtr_t)smlLibMalloc(mySize);
+ if (pGA->tokTbl->SyncML == NULL) return NULL;
+ smlLibMemcpy(pGA->tokTbl->SyncML, &syncml, mySize);
+ _tmpTagPtr = pGA->tokTbl->SyncML;
+ }
+ #else
+ _tmpTagPtr=(TagPtr_t)syncml;
+ #endif
+ }
+
+ #ifdef __USE_METINF__
+ else if (ext == SML_EXT_METINF) {
+ #ifndef NOWSM
+ _tmpTagPtr = pGA->tokTbl->MetInf;
+ if (_tmpTagPtr == NULL) {
+ mySize = sizeof(metinf);
+ pGA->tokTbl->MetInf = (TagPtr_t)smlLibMalloc(mySize);
+ if (pGA->tokTbl->MetInf == NULL) return NULL;
+ smlLibMemcpy(pGA->tokTbl->MetInf, &metinf, mySize);
+ _tmpTagPtr = pGA->tokTbl->MetInf;
+ }
+ #else
+ _tmpTagPtr=(TagPtr_t)metinf;
+ #endif
+ }
+ #endif
+
+ #ifdef __USE_DEVINF__
+ else if (ext == SML_EXT_DEVINF) {
+ #ifndef NOWSM
+ _tmpTagPtr = pGA->tokTbl->DevInf;
+ if (_tmpTagPtr == NULL) {
+ mySize = sizeof(devinf);
+ pGA->tokTbl->DevInf = (TagPtr_t)smlLibMalloc(mySize);
+ if (pGA->tokTbl->DevInf == NULL) return NULL;
+ smlLibMemcpy(pGA->tokTbl->DevInf, &devinf, mySize);
+ _tmpTagPtr = pGA->tokTbl->DevInf;
+ }
+ #else
+ _tmpTagPtr=(TagPtr_t)devinf;
+ #endif
+ }
+ #endif
+
+ #ifdef __USE_DMTND__
+ else if (ext == SML_EXT_DMTND) {
+ #ifndef NOWSM
+ _tmpTagPtr = pGA->tokTbl->DmTnd;
+ if (_tmpTagPtr == NULL) {
+ mySize = sizeof(dmtnd);
+ pGA->tokTbl->DmTnd = (TagPtr_t)smlLibMalloc(mySize);
+ if (pGA->tokTbl->DmTnd == NULL) return NULL;
+ smlLibMemcpy(pGA->tokTbl->DmTnd, &dmtnd, mySize);
+ _tmpTagPtr = pGA->tokTbl->DmTnd;
+ }
+ #else
+ _tmpTagPtr=(TagPtr_t)dmtnd;
+ #endif
+ }
+ #endif
+
+ return _tmpTagPtr;
+}
+
+#undef _TOKEN // we don't need that macro any longer
+
+/**
+ * FUNCTION: getTagString
+ *
+ * Returns a tag string which belongs to a tag ID.
+ * This function is needed for the XML encoding
+ *
+ * PRE-Condition: valid tag ID, the tagSring has to be allocated
+ *
+ * POST-Condition: tag string is returned
+ *
+ * IN: tagId, the ID for the tag
+ *
+ * IN/OUT: tagString, allocated string into which the XML
+ * tag string will be written
+ *
+ * RETURN: 0,if OK
+ */
+#ifdef __SML_XML__
+Ret_t getTagString(XltTagID_t tagID, String_t tagString, SmlPcdataExtension_t ext)
+{
+ int i = 0;
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL) {
+ tagString[0] = '\0';
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pTags+i)->id) != TN_UNDEF) {
+ if ((((pTags+i)->id) == tagID)) {
+ String_t _tmp = (pTags+i)->xml;
+ smlLibStrcpy(tagString, _tmp);
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ //smlLibStrcpy(tagString, '\0');
+ tagString[0] = '\0';
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+#endif
+
+/**
+ * FUNCTION: getTagByte
+ *
+ * Returns a WBXML byte which belongs to a tag ID in a defined codepage.
+ * This function is needed for the WBXML encoding
+ *
+ * PRE-Condition: valid tag ID, valid code page
+ *
+ * POST-Condition: tag byte is returned
+ *
+ * IN: tagId, the ID for the tag
+ * cp, code page group for the tag
+ * pTagByte, the byte representation of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getTagByte(XltTagID_t tagID, SmlPcdataExtension_t ext, Byte_t *pTagByte)
+{
+ int i = 0;
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL)
+ {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pTags+i)->id) != TN_UNDEF)
+ {
+ if (((pTags+i)->id) == tagID)
+ {
+ *pTagByte = (pTags+i)->wbxml;
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ *pTagByte = 0;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+/**
+ * FUNCTION: getCodePage
+ *
+ * Returns the code page which belongs to a certain PCDATA extension type.
+ *
+ * PRE-Condition: valid PCDATA extension type
+ *
+ * POST-Condition: the code page is returned
+ *
+ * IN: ext, the PCDATA extension type
+ *
+ * RETURN: the code page
+ */
+Byte_t getCodePage(SmlPcdataExtension_t ext)
+{
+ #ifdef __USE_DMTND__
+ if (ext == SML_EXT_DMTND)
+ return 2;
+ #endif
+ #ifdef __USE_METINF__
+ if (ext == SML_EXT_METINF)
+ return 1;
+ #endif
+ #ifdef __USE_DEVINF__
+ if (ext == SML_EXT_DEVINF)
+ return 0;
+ #endif
+ return 0;
+}
+
+/**
+ * FUNCTION: getCodePageById
+ *
+ * Returns the codepage which belongs to a certain tag ID
+ *
+ * PRE-Condition: valid tag ID
+ *
+ * POST-Condition: the code page is returned
+ *
+ * IN: tagID, the ID of the tag
+ * pCp, the codepage/extention of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getExtById(XltTagID_t tagID, SmlPcdataExtension_t *pExt)
+{
+ int i = 0;
+ SmlPcdataExtension_t ext;
+ /* Iterate over all defined extensions to find the corresponding TAG.
+ * Empty extensions, e.g. not defined numbers will be skipped.
+ */
+ for (ext = SML_EXT_UNDEFINED; ext < SML_EXT_LAST; ext++) {
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL) {
+ continue; /* skip empty codepage */
+ }
+ i = 0;
+ while (((pTags+i)->id) != TN_UNDEF) {
+ if ((((pTags+i)->id) == tagID)){
+ *pExt = ext;
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ }
+ /* tag not found in any extension */
+ *pExt = (SmlPcdataExtension_t)255;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+/**
+ * FUNCTION: getTagIDByStringAndCodepage
+ *
+ * Returns the tag ID which belongs to a tag string in a certain codepage
+ *
+ * PRE-Condition: valid tag string, valid code page
+ *
+ * POST-Condition: tag id is returned
+ *
+ * IN: tag, the string representation of the tag
+ * cp, code page group for the tag
+ * pTagID, the tag id of the tag
+ *
+ * RETURN: 0, if OK
+ */
+
+Ret_t getTagIDByStringAndExt(String_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID)
+{
+ int i = 0;
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL) {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ for (i=0;((pTags+i)->id) != TN_UNDEF; i++) {
+ if (*(pTags+i)->xml != *tag) continue; // if the first char doesn't match we skip the strcmp to speed things up
+ if (smlLibStrcmp(((pTags+i)->xml), tag) == 0) {
+ *pTagID = (pTags+i)->id;
+ return SML_ERR_OK;
+ }
+ }
+ *pTagID = TN_UNDEF;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+/**
+ * FUNCTION: getTagIDByByteAndCodepage
+ *
+ * Returns the tag ID which belongs to a tag byte in a certain codepage
+ *
+ * PRE-Condition: valid tag byte, valid code page
+ *
+ * POST-Condition: tag id is returned
+ *
+ * IN: tag, the byte representation of the tag
+ * cp, code page group for the tag
+ * pTagID, the tag id of the tag
+ *
+ * RETURN: 0, if OK
+ */
+Ret_t getTagIDByByteAndExt(Byte_t tag, SmlPcdataExtension_t ext, XltTagID_t *pTagID)
+{
+
+ int i = 0;
+ TagPtr_t pTags = getTagTable(ext);
+ if (pTags == NULL)
+ {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pTags+i)->id) != TN_UNDEF)
+ {
+ if (((pTags+i)->wbxml) == tag)
+ {
+ *pTagID = (pTags+i)->id;
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ *pTagID = TN_UNDEF;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+/**
+ * FUNCTION: getTagIDByStringAndNamespace
+ *
+ * Returns the tag ID which belongs to a tag string in a certain namespace
+ *
+ * PRE-Condition: valid tag string, valid namespace
+ *
+ * POST-Condition: tag id is returned
+ *
+ * IN: tag, the string representation of the tag
+ * ns, namespace group for the tag
+ * pTagID, the tag id of the tag
+ *
+ * RETURN: 0, if OK
+ */
+#ifdef __SML_XML__
+Ret_t getTagIDByStringAndNamespace(String_t tag, String_t ns, XltTagID_t *pTagID)
+{
+ int i = 0;
+ TagPtr_t pTags = getTagTable(getExtByName(ns));
+ if (pTags == NULL)
+ {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ while (((pTags+i)->id) != TN_UNDEF)
+ {
+ if ((smlLibStrcmp(((pTags+i)->xml), tag) == 0))
+ {
+ *pTagID = (pTags+i)->id;
+ return SML_ERR_OK;
+ }
+ i++;
+ }
+ *pTagID = TN_UNDEF;
+ return SML_ERR_XLT_INVAL_PROTO_ELEM;
+}
+
+#endif
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xltutilstack.c b/engine/dmlib/dmengine/oma_toolkit/src/xltutilstack.c
new file mode 100644
index 0000000..1172379
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xltutilstack.c
@@ -0,0 +1,205 @@
+/*************************************************************************/
+/* module: XLT Decoder Stack */
+/* file: XLTUtilStack.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * A simple array-based stack implementation.
+ */
+
+/*************************************************************************/
+/* Definitions */
+/*************************************************************************/
+
+#include "xltdeccom.h"
+#include "xltutilstack.h"
+
+#include <smlerr.h>
+
+#include <libmem.h>
+
+struct ArrayStack_s;
+typedef struct ArrayStack_s *ArrayStackPtr_t, ArrayStack_t;
+struct ArrayStack_s
+{
+ /* public */
+ Ret_t (*top)(const XltUtilStackPtr_t, XltUtilStackItem_t *);
+ Ret_t (*pop)(XltUtilStackPtr_t, XltUtilStackItem_t *);
+ Ret_t (*push)(XltUtilStackPtr_t, const XltUtilStackItem_t);
+ Ret_t (*destroy)(XltUtilStackPtr_t);
+
+ /* private */
+ Long_t topidx; // index of the top of the stack
+ Long_t size; // size of the stack (multiple of chunksize)
+ Long_t chunksize; // size of memory chunks allocated at a time
+ XltUtilStackItem_t *array; // the stack itself
+};
+
+static Ret_t _top(const XltUtilStackPtr_t, XltUtilStackItem_t *);
+static Ret_t _pop(XltUtilStackPtr_t, XltUtilStackItem_t *);
+static Ret_t _push(XltUtilStackPtr_t, const XltUtilStackItem_t);
+static Ret_t _destroy(XltUtilStackPtr_t);
+
+/*************************************************************************/
+/* External Functions */
+/*************************************************************************/
+
+Ret_t
+xltUtilCreateStack(XltUtilStackPtr_t *ppStack, const Long_t size)
+{
+ ArrayStackPtr_t pStack;
+
+ if (size <= 0)
+ return SML_ERR_WRONG_PARAM;
+ if ((pStack = (ArrayStackPtr_t)smlLibMalloc(sizeof(ArrayStack_t))) == NULL) {
+ *ppStack = NULL;
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ pStack->top = _top;
+ pStack->pop = _pop;
+ pStack->push = _push;
+ pStack->destroy = _destroy;
+ pStack->topidx = -1;
+ pStack->size = size;
+ pStack->chunksize = size;
+ pStack->array = NULL;
+ if ((pStack->array = (XltUtilStackItem_t*)smlLibMalloc(size * sizeof(XltUtilStackItem_t))) == NULL) {
+ *ppStack = NULL;
+ smlLibFree(pStack);
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+
+ *ppStack = (XltUtilStackPtr_t)pStack;
+
+
+
+ return SML_ERR_OK;
+}
+
+/*************************************************************************/
+/* Internal Functions */
+/*************************************************************************/
+
+static Ret_t
+_top(const XltUtilStackPtr_t pStack, XltUtilStackItem_t *itemPtr)
+{
+ ArrayStackPtr_t pStackPriv = (ArrayStackPtr_t)pStack;
+
+ if (pStackPriv->topidx == -1)
+ return SML_ERR_WRONG_USAGE;
+
+ *itemPtr = pStackPriv->array[pStackPriv->topidx];
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+_pop(XltUtilStackPtr_t pStack, XltUtilStackItem_t *itemPtr)
+{
+ ArrayStackPtr_t pStackPriv = (ArrayStackPtr_t)pStack;
+ XltUtilStackItem_t item;
+
+ if (pStackPriv->topidx == -1)
+ return SML_ERR_WRONG_USAGE;
+
+ item = pStackPriv->array[pStackPriv->topidx];
+ pStackPriv->topidx--;
+
+ if ((pStackPriv->topidx >= 0) &&
+ (pStackPriv->topidx < pStackPriv->size - pStackPriv->chunksize)) {
+ Long_t newsize;
+ XltUtilStackItem_t *newarray;
+
+ newsize = pStackPriv->size - pStackPriv->chunksize;
+ if ((newarray = (XltUtilStackItem_t*)smlLibRealloc(pStackPriv->array,
+ newsize * sizeof(XltUtilStackItem_t))) != NULL) {
+ pStackPriv->size = newsize;
+ pStackPriv->array = newarray;
+ } else {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ }
+
+ *itemPtr = item;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+_push(XltUtilStackPtr_t pStack, const XltUtilStackItem_t item)
+{
+ ArrayStackPtr_t pStackPriv = (ArrayStackPtr_t)pStack;
+
+ if (pStackPriv->topidx == pStackPriv->size - 1) {
+ Long_t newsize;
+ XltUtilStackItem_t *newarray;
+
+ newsize = pStackPriv->size + pStackPriv->chunksize;
+ if ((newarray = (XltUtilStackItem_t*)smlLibRealloc(pStackPriv->array,
+ newsize * sizeof(XltUtilStackItem_t))) != NULL) {
+ pStackPriv->size = newsize;
+ pStackPriv->array = newarray;
+ } else {
+ return SML_ERR_NOT_ENOUGH_SPACE;
+ }
+ }
+
+ pStackPriv->topidx++;
+ pStackPriv->array[pStackPriv->topidx] = item;
+
+ return SML_ERR_OK;
+}
+
+static Ret_t
+_destroy(XltUtilStackPtr_t pStack)
+{
+ ArrayStackPtr_t pStackPriv;
+
+ if (pStack == NULL)
+ return SML_ERR_OK;
+
+ pStackPriv = (ArrayStackPtr_t)pStack;
+
+ smlLibFree(pStackPriv->array);
+ smlLibFree(pStackPriv);
+ return SML_ERR_OK;
+}
diff --git a/engine/dmlib/dmengine/oma_toolkit/src/xpt-b64.c b/engine/dmlib/dmengine/oma_toolkit/src/xpt-b64.c
new file mode 100644
index 0000000..d7c7f82
--- /dev/null
+++ b/engine/dmlib/dmengine/oma_toolkit/src/xpt-b64.c
@@ -0,0 +1,365 @@
+
+/*************************************************************************/
+/* module: Communication Services, base64 encoding/decoding fns.*/
+/* file: src/xpt/all/xpt-b64.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#include "xptport.h"
+#include "xpttypes.h"
+#include "xpt-b64.h"
+
+
+#define MAX_COLUMNS 45
+
+
+/***************************************************************************/
+/* The function decodes the next character of the input buffer and updates */
+/* the pointers to the input buffer. The function skips CRLF characters */
+/* and whitespace characters. */
+/* Returns: 0..63, the logical value of the next valid character in the */
+/* input buffer */
+/* 64, padding character */
+/* -1, No more characters to read */
+/* -2, an error occurred: invalid characters in the data stream*/
+/***************************************************************************/
+
+int nextBase64Char (DataBuffer_t *ppbData, BufferSize_t *pcbDataLength)
+ {
+ int r = -1;
+ DataBuffer_t pbData = *ppbData;
+ BufferSize_t cbDataLength = *pcbDataLength;
+#ifndef __EPOC_OS__
+ static char *pszSkipChars = "\t\r\n ";
+#endif
+#ifdef __EPOC_OS__
+ char *pszSkipChars = "\t\r\n ";
+#endif
+ char ch;
+
+ if (cbDataLength == 0) return r;
+
+ do {
+ ch = *pbData;
+ if ((ch>='0')&&(ch<='9')) r = (int)ch+4; // |
+ else if ((ch>='A')&&(ch<='Z')) r = (int)ch-65; // |
+ else if ((ch>='a')&&(ch<='z')) r = (int)ch-71; // | Valid characters
+ else if (ch == '/') r = 63; // |
+ else if (ch == '+') r = 62; // |
+ else if (ch == '=') r = 64; // padding character
+ else if (!xppStrchr (pszSkipChars, ch)) r = -2; // invalid character
+ cbDataLength --;
+ pbData ++;
+ } while ((r == -1) && (cbDataLength > 0));
+
+ /***************************************************/
+ /* Pass the updated parameter values to the caller */
+ /***************************************************/
+ if (r != -1)
+ {
+ *ppbData = pbData;
+ *pcbDataLength = cbDataLength;
+ }
+ return r;
+ }
+
+BufferSize_t base64GetSize (BufferSize_t cbRealDataSize)
+ {
+ int iMod = cbRealDataSize % 3;
+ /* The encoded data size ... */
+ BufferSize_t cbEncodedSize = ((cbRealDataSize - iMod) / 3 ) * 4;
+ if (iMod != 0) cbEncodedSize += 4;
+ /* ... and the # of CRLF characters */
+ cbEncodedSize += ((cbEncodedSize-1) / ((MAX_COLUMNS*4)/3)) * 2;
+ return cbEncodedSize;
+ }
+
+
+/*****************************************************************/
+/* Function: pre-compute the size of the base64 encoded document */
+/****************************************************************/
+
+BufferSize_t base64Encode (DataBuffer_t pbTarget, // o: target buffer
+ BufferSize_t cbTargetSize, // i: target buffer size
+ DataBuffer_t pbData, // i: Data buffer
+ BufferSize_t *pcbDataLength, // i/o: Data buffer size
+ BufferSize_t *pcbOffset, // i/o: absolute # of bytes encoded so far
+ unsigned int bLast, // i: 0=first block, 1= next block, 2=last block
+ unsigned char *pbSaveBytes) // i/o: last incomplete data block
+ {
+ DataBuffer_t pbSourceData = pbData;
+ BufferSize_t cbCopySize = 0;
+ BufferSize_t cbDataProcessed = *pcbDataLength;
+ unsigned int i0, i1, i2, i3;
+ unsigned int byt;
+ int iSave = 1;
+#ifndef __EPOC_OS__
+ static char t [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // 26
+ "abcdefghijklmnopqrstuvwxyz" // 26
+ "0123456789+/" // 12
+ "="; // 1
+#endif
+#ifdef __EPOC_OS__
+char t [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // 26
+ "abcdefghijklmnopqrstuvwxyz" // 26
+ "0123456789+/" // 12
+ "="; // 1
+#endif
+ // Check for NULL data buffer,
+ if (pbData == NULL ) {
+ // See if last block and there is any "saved" data that needs to go now.
+ if ( bLast && ( pbSaveBytes && pbSaveBytes [0] )) {
+ /**************************************/
+ /* Check if it is time to send a CRLF */
+ /**************************************/
+ if ((*pcbOffset) > 0 && ((*pcbOffset) % MAX_COLUMNS == 0))
+ {
+ //if (cbTargetSize < 6) // there is not enough space in the target buffer:
+ // break; // return to the caller.
+ *pbTarget = '\r';
+ *(pbTarget+1) = '\n';
+ cbCopySize += 2;
+ cbTargetSize -= 2;
+ pbTarget += 2;
+ }
+
+ byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --;
+
+ i0 = byt >> 2;
+ i1 = (byt & 0x0003) << 4;
+
+ (*pcbOffset) ++;
+
+ if (pbSaveBytes && pbSaveBytes [0]) {
+ byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --;
+ i1 += (byt >> 4);
+ i2 = i3 = (byt & 0x000F) << 2;
+ } else {
+ i2 = i3 = 64; // index to the padding char '=';
+ }
+
+ pbTarget [0] = t[i0];
+ pbTarget [1] = t[i1];
+ pbTarget [2] = t[i2];
+ pbTarget [3] = t[i3];
+
+ cbCopySize += 4;
+ cbTargetSize -= 4;
+ pbTarget += 4;
+ }
+
+ } else {
+ while ((cbTargetSize >= 4) && (cbDataProcessed > 0))
+ /*
+ * AZ: We do not need to divide the data into multiple blocks, nor do we enforce
+ * MAX_COLUMNS. So commenting out the code block below for now.
+ *
+ * &&
+ * ( ((cbDataProcessed >= 3) && (bLast == 0)) ||
+ * ((cbDataProcessed > 0) && (bLast == 1)) ))
+ */
+ {
+ /**************************************/
+ /* Check if it is time to send a CRLF */
+ /**************************************/
+ /*
+ if ((*pcbOffset) > 0 && ((*pcbOffset) % MAX_COLUMNS == 0))
+ {
+ if (cbTargetSize < 6) // there is not enough space in the target buffer:
+ break; // return to the caller.
+ *pbTarget = '\r';
+ *(pbTarget+1) = '\n';
+ cbCopySize += 2;
+ cbTargetSize -= 2;
+ pbTarget += 2;
+ }
+ */
+ if (pbSaveBytes && pbSaveBytes [0])
+ { byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --; }
+ else
+ { byt = (unsigned int) *pbSourceData; pbSourceData ++; cbDataProcessed --;}
+
+ i0 = byt >> 2;
+ i1 = (byt & 0x0003) << 4;
+
+ (*pcbOffset) ++;
+
+ if (cbDataProcessed > 0)
+ {
+ if (pbSaveBytes && pbSaveBytes [0])
+ { byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --; }
+ else
+ { byt = (unsigned int) *pbSourceData; pbSourceData ++; cbDataProcessed --;}
+
+ i1 += (byt >> 4);
+ i2 = (byt & 0x000F) << 2;
+
+ (*pcbOffset) ++;
+
+ if (cbDataProcessed > 0)
+ {
+ if (pbSaveBytes && pbSaveBytes [0])
+ { byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --; }
+ else
+ { byt = (unsigned int) *pbSourceData; pbSourceData ++; cbDataProcessed --;}
+
+ i2 += (byt & 0x00C0) >> 6;
+ i3 = byt & 0x003F;
+ (*pcbOffset) ++;
+ }
+ else
+ i3 = 64; // index to the padding char '=';
+ }
+ else
+ i2 = i3 = 64; // index to the padding char '=';
+ pbTarget [0] = t[i0];
+ pbTarget [1] = t[i1];
+ pbTarget [2] = t[i2];
+ pbTarget [3] = t[i3];
+
+ cbCopySize += 4;
+ cbTargetSize -= 4;
+ pbTarget += 4;
+ }
+ }
+
+
+
+ /*************************************************************/
+ /* Save the bytes that must be processed in the following */
+ /* call (max. 2 Bytes). */
+ /*************************************************************/
+ if(pbSourceData!=NULL){
+ if ((bLast == 0) && (cbDataProcessed <= 2) && (pbSaveBytes != NULL))
+ {
+ pbSaveBytes[0] = cbDataProcessed;
+ while (cbDataProcessed)
+ {
+ *(++pbSaveBytes) = pbSourceData[0];
+ cbDataProcessed --; pbSourceData ++;
+ }
+ }
+
+ /*****************************************************************/
+ /* Shift all non-processed data to the start of the input buffer */
+ /*****************************************************************/
+
+ if (cbDataProcessed > 0)
+ {
+ xppMemmove (pbData, pbSourceData, cbDataProcessed);
+ }
+ *pcbDataLength = cbDataProcessed;
+ }
+ return cbCopySize;
+ }
+
+/***************************************************************/
+/* Function: decode a base64- encoded block of data. */
+/* The function returns the count of data that are decoded, or */
+/* 0 in case of a data error, or if cbTargetSize < 4 */
+/***************************************************************/
+
+BufferSize_t base64Decode (DataBuffer_t pbTarget, // o: target buffer
+ BufferSize_t cbTargetSize, // i: target buffer size
+ DataBuffer_t pbData, // i: data buffer
+ BufferSize_t *pcbDataLength) // i/o: Data buffer size
+ {
+ DataBuffer_t pbSource = pbData;
+ BufferSize_t cbDataCopied = 0L;
+ BufferSize_t cbRemaining = *pcbDataLength; // remaining source data
+ int i0 = 0, i1 = 0, i2 = 0, i3 = 0;
+
+ while (cbTargetSize > 0)
+ {
+ BufferSize_t cbNext = cbRemaining;
+ DataBuffer_t pbNext = pbSource;
+
+ i0 = nextBase64Char (&pbNext, &cbNext);
+ i1 = nextBase64Char (&pbNext, &cbNext);
+ i2 = nextBase64Char (&pbNext, &cbNext);
+ i3 = nextBase64Char (&pbNext, &cbNext);
+ if ((i0 < 0) || (i1 < 0) || (i2 < 0) || (i3 < 0))
+ break; // end-of-block, or data error.
+
+ else if ( ((cbTargetSize <= 2) && (i3 != 64)) ||
+ ((cbTargetSize <= 1) && (i2 != 64)) )
+ break; // end of transmission.
+
+ else
+ {
+ pbSource = pbNext;
+ cbRemaining = cbNext;
+ /************************/
+ /* decode the quadruple */
+ /************************/
+ *pbTarget = (i0 << 2) + (i1 >> 4);
+ pbTarget ++; cbDataCopied ++; cbTargetSize --;
+ if (i2 != 64)
+ {
+ *pbTarget = ((i1 & 0x000f) << 4) + (i2 >> 2);
+ pbTarget ++; cbDataCopied ++; cbTargetSize --;
+ if (i3 != 64)
+ {
+ *pbTarget = ((i2 & 0x0003) << 6) + i3;
+ pbTarget ++; cbDataCopied ++; cbTargetSize --;
+ }
+ }
+ }
+ }
+
+ /*******************************/
+ /* Handle invalid data errors! */
+ /*******************************/
+
+ if ((i0 == -2) || (i1 == -2) || (i2 == -2) || (i3 == -2))
+ cbDataCopied = 0;
+
+ /*****************************************************************/
+ /* Shift all non-processed data to the start of the input buffer */
+ /*****************************************************************/
+ if (cbRemaining > 0)
+ xppMemmove (pbData, pbSource, cbRemaining);
+ *pcbDataLength = cbRemaining;
+ return cbDataCopied;
+ }
+
+
diff --git a/engine/dmlib/dmt-tools/DMTConv b/engine/dmlib/dmt-tools/DMTConv
new file mode 100644
index 0000000..cac574e
--- /dev/null
+++ b/engine/dmlib/dmt-tools/DMTConv
@@ -0,0 +1,97 @@
+#!/bin/bash
+#====================================================================================================
+#
+# Script Name: DMTConv
+#
+# General Description: This script converts DMT from .zip to .dmts formats and visa versa.
+#
+#====================================================================================================
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#====================================================================================================
+usage () {
+ echo ""
+ echo "========================================================================================="
+ echo ""
+ echo "Usage: "
+ echo " DMTConv [-verbose] <fileFrom> <fileTo>"
+ echo ""
+ echo "Where:"
+ echo " <fileFrom> DMT source in the .zip or .dmts format, required parm"
+ echo " <fileTo> DMT target in the .zip or .dmts format, required parm"
+ echo " -verbose enable verbose output, optional parm"
+ echo ""
+ echo "=========================================================================================="
+ echo ""
+}
+
+errorExit() {
+ echo ""
+ echo "$1"
+ usage
+ exit 1
+}
+
+
+# validate parameters
+if [ "$#" -eq 2 ]
+then
+ DMT1="$1"
+ DMT2="$2"
+elif [ "$#" -eq 3 ]
+then
+ VERBOSE="$1"
+ DMT1="$2"
+ DMT2="$3"
+else
+ usage
+ exit 1
+fi
+
+# validate input files format
+echo "$DMT1" | egrep "(.zip\$)|(.ZIP\$)|(.dmts\$)|(.DMTS\$)" >/dev/null || errorExit "Parameter <fileFrom> has wrong format"
+echo "$DMT2" | egrep "(.zip\$)|(.ZIP\$)|(.dmts\$)|(.DMTS\$)" >/dev/null || errorExit "Parameter <fileTo> has wrong format"
+
+
+# Do some checking on our environment - we need JAVA_HOME present
+if [ -z "$JAVA_HOME" ]
+then
+ echo "Environment variable JAVA_HOME needs to be set first!"
+ exit 1
+fi
+
+
+# check if the parms files are exist and readable
+if [ ! -r $DMT1 ]
+then
+ echo "Cannot find <fileFrom> with path: $DMT1"
+ exit 1
+fi
+
+
+#Call the com.mot.dm.tool.DMTSTool to perform conversion
+
+echo "Begin conversion..."
+
+$JAVA_HOME/bin/java -classpath lib/GenTool.jar com.mot.dm.tool.DMTSTool $VERBOSE -conversion $DMT1 $DMT2
+
+if [ $? -ne 1 ]
+then
+ echo "Error occured ..."
+ exit 1
+fi
+
+
+
+
diff --git a/engine/dmlib/dmt-tools/DMTDiff b/engine/dmlib/dmt-tools/DMTDiff
new file mode 100644
index 0000000..36dec26
--- /dev/null
+++ b/engine/dmlib/dmt-tools/DMTDiff
@@ -0,0 +1,90 @@
+#!/bin/bash
+#====================================================================================================
+#
+# Script Name: DMTDiff
+#
+# General Description: This script helps to find difference between two DM Trees. The script receives
+# two parameters (DMT files in .zip or .dmts format) and can compare:
+# zip -> zip or zip -> dmts or dmts -> zip or dmts -> dmts.
+#====================================================================================================
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#====================================================================================================
+usage () {
+ echo ""
+ echo "========================================================================================="
+ echo ""
+ echo "Usage: "
+ echo " DMTDiff [-verbose] <fileDMT1> <fileDMT2>"
+ echo ""
+ echo "Where:"
+ echo " <fileDMT1> and <fileDMT2> two DMTs that should be compared "
+ echo " in .zip or .dmts format"
+ echo " -verbose enable verbose output"
+ echo ""
+ echo "=========================================================================================="
+ echo ""
+}
+# validate parameters
+if [ "$#" -eq 2 ]
+then
+ DMT1="$1"
+ DMT2="$2"
+elif [ "$#" -eq 3 ]
+then
+ VERBOSE="$1"
+ DMT1="$2"
+ DMT2="$3"
+else
+ usage
+ exit 1
+fi
+
+# Do some checking on our environment - we need JAVA_HOME present
+if [ -z "$JAVA_HOME" ]
+then
+ echo "Environment variable JAVA_HOME needs to be set first!"
+ exit 1
+fi
+
+
+# check if the parms files are exist and readable
+if [ ! -r $DMT1 ]
+then
+ echo "Cannot find fist DMT file with path: $DMT1"
+ exit 1
+fi
+
+if [ ! -r $DMT2 ]
+then
+ echo "Cannot find second DMT file with path: $DMT2"
+ exit 1
+fi
+
+
+#Call the com.mot.dm.tool.DMTSTool to to find difference
+
+echo "Begin comparison ..."
+
+$JAVA_HOME/bin/java -classpath lib/GenTool.jar com.mot.dm.tool.DMTSTool $VERBOSE -difference $DMT1 $DMT2
+
+if [ $? -ne 1 ]
+then
+ echo "Error occured ..."
+ exit 1
+fi
+
+
+
+
diff --git a/engine/dmlib/dmt-tools/README b/engine/dmlib/dmt-tools/README
new file mode 100644
index 0000000..14fbcb3
--- /dev/null
+++ b/engine/dmlib/dmt-tools/README
@@ -0,0 +1,49 @@
+DMT Standalone manipulation tools:
+----------------------------------
+
+There are two tools provided here to manipulate DMT data/meta-data:
+
+convertMDF - this tool converts from the older text-based meta data
+ file (root.mdf) to the new binary format (root.bmdf).
+
+ It takes a single argument, for example:
+
+ convertMDF test.mdf
+
+ After completion, a file called 'test.bmdf' will be
+ created in this directory.
+
+generateDMT - This tool calls the necessary 'Gen tool' and python
+ script to build the data and meta-data for a DMT
+ represented by a .zip file. For more information on
+ on how to manipulate the Dmt.zip file, see the document
+ entitled 'DMTreeGeneration.doc' in the docs directory.
+
+ NOTE: This script requires that you set the environment
+ variable JAVA_HOME to the location where your Java
+ runtime is installed.
+
+ It takes one required and one optional argument, for example:
+
+ generateDMT ../path/to/Dmt.zip (this creates output dir 'treedata')
+
+ OR
+
+ generateDMT ../path/to/Dmt.zip /tmp (creates 'treedata' dir in /tmp)
+
+ Inside the 'treedata' directory are all of the wbxml files that
+ represent the DMT data (the source xml files are also included
+ for debugging), as well as the necessary support files (acl.txt,
+ fstab, root.bmdf). The text-based root.mdf is included for
+ debugging purposes.
+
+ NOTE: The fstab file included in this directory is a SAMPLE only.
+ Please edit this file (it must be named 'fstab') to suit
+ your own tree structure.
+
+ There is a subdirectory called 'docs' inside of 'treedata' which
+ contains the javadoc-style html documentation for the tree
+ schema.
+
+The other subdirectories in this directory (bin and lib) contain necessary support
+files/programs for the two tools above.
diff --git a/engine/dmlib/dmt-tools/ReleaseNotes b/engine/dmlib/dmt-tools/ReleaseNotes
new file mode 100644
index 0000000..cdaac47
--- /dev/null
+++ b/engine/dmlib/dmt-tools/ReleaseNotes
@@ -0,0 +1,56 @@
+01.17.2007 by Victor Havin CR LIBll09785
+ 1. Created and added ReleaseNotes file.
+ 2. Change Gen.java (and GenTool.jar) to fix phone model setting in ddf file (take from tree).
+ 3. Remove validation for an empty string for the attribute "value" in the DMTValidator.java.
+ 4. Fixing (ignoring) default values for the nodes with type "bin". DM engine doesn't support it.
+
+02.12.2007 by Victor Havin CR LIBll35212
+ 1. Bug fixing: supporting empty spaces in the attribute "values:"
+ 2. Add tree auto test tools to the vobs
+
+05.01.2007 by Victor Havin CR LIBmm11410
+ 1. Add error messages to the DMTValidator.java
+ 2. Add more validation for the nodes with "bin" type.
+ 3. Add support for new access type: "Local".
+ 4. Fix DMT test tool (access "Add" from parent and for multi nodes from definition ../../[]/..)
+
+05.22.2007 by Victor Havin CR LIBmm07206
+ 1. Replace File... with NodeLoader... and add com/mot/io package for integration with FlexML
+ (developed by by James Wylder-jwylder1).
+ 2. Add suppert for Dmt directory as a parameter instead of Dmt.zip.
+ 3. Fixing bug: close file handlers after using.
+
+07.24.2007 by Victor Havin CR LIBmm82940 (Gen tool version 1.5)
+ 1. Remove Python.
+ 2. Add file name validation, error code return from Gen, separate .err with .out, add debug option
+ 3. Remove generateDMT_v, change script for support flex settings file with name "FlexEnvSetting"
+
+08.09.2007 by Victor Havin CR LIBnn08212 (Gen tool version 1.6)
+ 1. Add support "!" and "&" as a part of node name
+ 2. Move Gen.java and DMTValidator.java to com/mot/dm/core
+ 3. Change way validating Java version.
+
+08.31.2007 by Victor Havin CR LIBnn24894 (Gen tool version 1.7)
+ 1. Add support for attribute "event:"
+ 2. Generate event.txt and event.dat.
+ 3. Write <Path> to DDF file and format it according to dtd.
+ 4. Add method genTree() for FlexML (move logic from main() to genTree().
+
+10.19.2007 by Victor Havin CR LIBnn57278 (Gen tool version 1.8)
+ 1. Add default value and constarins to DDF file.
+ 2. Add encoding/decoding UTF-8 for reading /writing files (by Jesse).
+ 3. Add hex string encoding for factory bootstrap using FactBootEnc.java.
+
+02.14.2008 by Victor Havin CR LIBnn57278 (Gen tool version 1.9)
+ 1. Fix nodes types in the Xml2Wbxml.java: date, time, float.
+
+06.03.2008 by Victor Havin CR LIBpp89940 (Gen tool version 1.10)
+ 1. Add sorting for DMT nodes (by node's name)
+
+06.30.2008 by Victor Havin CR LIBqq22458 (Gen tool version 1.11)
+ 1. Fix factory bootstrap. Now value taken from NodeLoader (not from file directly).
+ The tool supports only HEX presentation for special nodes (not row bytes).
+
+
+
+
diff --git a/engine/dmlib/dmt-tools/convertMDF b/engine/dmlib/dmt-tools/convertMDF
new file mode 100644
index 0000000..342138d
--- /dev/null
+++ b/engine/dmlib/dmt-tools/convertMDF
@@ -0,0 +1,112 @@
+#!/bin/bash
+#====================================================================================================
+#
+# Script Name: convertMDF
+#
+# General Description: This script calls the necessary tools to convert between the old (text-based)
+# meta-data format and the new (binary) format.
+#
+#====================================================================================================
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#====================================================================================================
+
+# Do some checking on our environment - we need Java present
+
+if [ -z "$JAVA_HOME" ]
+then
+ echo "Environment variable JAVA_HOME needs to be set!"
+ exit 1
+fi
+
+# Define our root dir and make a dummy parm.txt
+
+BASEFILE=`basename $1 .mdf`
+ROOTDIR=./Dmt
+mkdir $ROOTDIR
+CURRPARM=$ROOTDIR/parm.txt
+cp -f /dev/null $CURRPARM
+echo "type:node" >> $CURRPARM
+echo "access:Get,Add,Replace,Delete" >> $CURRPARM
+
+# Make sure we have a Unix mdf file, not a DOS one!
+
+dos2unix $1 2> /dev/null
+
+# Begin building the Dmt file structure
+
+echo "Building tree from $1..."
+
+exec < $1
+
+while read line
+do
+ # Check for comment lines
+
+ echo $line | grep -E '^[[:space:]]*#' > /dev/null
+ COMMENTLINE=$?
+
+ # Check for parens
+
+ if echo $line | grep '^\[' > /dev/null
+ then
+ # We've encountered a new node - begin node creation
+
+ CURRDIR=`echo $line | sed "s/\[//g" | sed "s/\]//g" | sed "s/*/[]/g"`
+ if [ "$CURRDIR" = "." ]
+ then
+ CURRDIR=$ROOTDIR
+ else
+ CURRDIR=$ROOTDIR$CURRDIR
+ #echo "Making dir: $CURRDIR"
+ mkdir -p "$CURRDIR"
+ fi
+
+ CURRPARM=$CURRDIR/parm.txt
+ cp -f /dev/null "$CURRPARM"
+ elif [ "$line" != "" -a "$COMMENTLINE" -ne 0 ]
+ then
+ # Populate the parm.txt file with data
+
+ echo "$line" >> "$CURRPARM"
+ fi
+
+done
+
+# Call the DMTValidator to make sure we have good data
+
+echo "Validating DMT structure..."
+
+$JAVA_HOME/bin/java -classpath lib/GenTool.jar:lib/joda-time-1.1.jar:lib/jakarta-regexp-1.4.jar DMTValidator -d Dmt
+
+if [ $? -eq 1 ]
+then
+ echo "Please fix the errors above before continuing..."
+ echo "Cleaning up on abort..."
+ rm -rf $ROOTDIR
+ exit 1
+fi
+
+# Now call the Gen tool to build the binary MDF
+
+echo "Calling Gen tool to convert to binary MDF..."
+
+$JAVA_HOME/bin/java -classpath lib/GenTool.jar:lib/joda-time-1.1.jar:lib/jakarta-regexp-1.4.jar Gen -d Dmt -mdfconvert 2> /tmp/java.run.out.$$
+
+# Cleanup our Dmt directory
+
+echo "Cleaning up..."
+
+rm -rf $ROOTDIR
+mv -f root.bmdf $BASEFILE.bmdf
diff --git a/engine/dmlib/dmt-tools/generateDMT b/engine/dmlib/dmt-tools/generateDMT
new file mode 100644
index 0000000..305cf45
--- /dev/null
+++ b/engine/dmlib/dmt-tools/generateDMT
@@ -0,0 +1,327 @@
+#!/bin/bash
+#====================================================================================================
+#
+# Script Name: generateDMT
+#
+# General Description: This script controls the building/generation of all DMT data files. It takes
+# care of unzipping the Dmt.zip file, running the DMTValidator, and then running
+# the DMT Generation tool.
+#
+#====================================================================================================
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#====================================================================================================
+
+#set variables for the Flex
+FLEX_SETTING_FILE="FlexEnvSetting"
+if [ -f $FLEX_SETTING_FILE ]
+then
+ source $FLEX_SETTING_FILE
+fi
+
+usage () {
+ echo ""
+ echo "========================================================================================="
+ echo ""
+ echo "Usage of the new version: "
+ echo ""
+ echo " generateDMT [-output <dir path>]"
+ echo " [-fstab <file path>]"
+ echo " [-inipath <ini file(dir) path (P2K only)>]"
+ echo " [-debug]"
+ echo " [-ddfext]"
+ echo " [-dmt <path to Dmt directory>]"
+ echo " or"
+ echo " <file>.zip or <file>.dmts [<file1>.zip, <file2>.zip, ...]"
+ echo ""
+ echo "Where options are including:"
+ echo ""
+ echo " -output path to output 'treedata' directory"
+ echo " using current ('./treedata') if not set"
+ echo " -fstab path to fstab file"
+ echo " looking in the current ('.') directory"
+ echo " if not set"
+ echo " -inipath path to sysplugins.ini file(s) for P2K only."
+ echo " The required files will be converted to .c and .h"
+ echo " files if this parameter is presenting"
+ echo " -debug option to add output debug info from Gen java into"
+ echo " /tmp/java.run.out.<ProcessID>"
+ echo " -ddfext option to generate Extended DDF with values and"
+ echo " file DDFValues.txt with all possible values"
+ echo " -dmt path to Dmt directory."
+ echo " Use this option instead of Dmt.zip (not together)"
+ echo ""
+ echo "New version support as a data input both <file>.zip and <file>.dmts formats"
+ echo ""
+ echo "Samples:"
+ echo " ./generateDMT -fstab ../../settings/fstab -output abcd -dmt ../../settings/Dmt"
+ echo " ./generateDMT -fstab ../../settings/fstab -output abcd ../../settings/Dmt.zip (or more then one)"
+ echo " ./generateDMT -fstab ../../settings/fstab -output abcd ../../settings/Dmt.dmts (or more then one)"
+ echo ""
+ echo "Usage of the old version: "
+ echo " generateDMT <file>.zip [<dir path>]"
+ echo ""
+ echo "Option '-novalidation' use for developing only!!!"
+ echo ""
+ echo "=========================================================================================="
+ echo ""
+}
+
+#print out messages
+printOut () {
+ if [ "$DEBUG" == "yes" ]
+ then
+ echo "$1"
+ fi
+}
+
+export LANG=en_US
+export LANGVAR=en_US
+unset LC_ALL
+export LC_CTYPE="en_US.UTF-8"
+
+# validate parameters
+if [ "$#" -eq 0 ]
+then
+ echo ""
+ echo "Error: Missing path to Dmt.zip file !!! "
+ echo "Use flag -h or --help for the help"
+ echo ""
+ exit 1
+fi
+
+# Do some checking on our environment - we need java & unzip present
+if [ -z "$JAVA_HOME" ]
+then
+ echo "Error: Environment variable JAVA_HOME must be set to jdk 1.4 and latest!"
+ exit 1
+fi
+
+JAVA_VERSION=`$JAVA_HOME/bin/java -version 2> /dev/stdout | grep ver | sed -e 's/.*\"\([1-9]\.[0-9][0-9]*\)\..*/\1/'`
+if [ "$JAVA_VERSION" \< "1.4" ]
+then
+ echo "Error: Java vesion is not correct"
+ echo "The tool supports java version from 1.4 and latest"
+ echo "Please set environment variable JAVA_HOME to the correct java version"
+ exit 1
+fi
+
+unzip > /dev/null
+
+if [ "$?" -ne 0 ]
+then
+ echo "Error: Couldn't find unzip - please install it, or put it on your PATH."
+ exit 1
+fi
+
+# Remove temporary ./Dmt if exists
+if [ -d Dmt ]
+then
+ rm -rf Dmt
+fi
+
+
+# Set default values for the required variables
+FSTAB_FILE=fstab
+OUTPUTDIR=./treedata
+NOVALIDATION=no
+DEBUG=no
+OUT=null
+DEBUG_INFO_DIR=/dev/null
+#Provide Dmt directory instead of Dmt.zip
+DMTDIR=Dmt
+#Flag fo Gen tool to generate DDF
+GENDDF=genddf
+
+# Parse parameters
+while [ $# -gt 1 ]; do
+ case "$1" in
+ -novalidation ) NOVALIDATION=yes;
+ printOut "No validation option has been set"
+ shift ;;
+ -debug ) DEBUG=yes
+ shift ;;
+ -ddfext ) GENDDF=genextddf
+ shift ;;
+ -output ) OUTPUTDIR=$2/treedata ;
+ printOut "OUTPUTDIR: $OUTPUTDIR"
+ shift 2 ;;
+ -fstab ) FSTAB_FILE=$2 ;
+ printOut "FSTAB_FILE: $FSTAB_FILE"
+ shift 2 ;;
+ -dmt ) DMTDIR=$2 ;
+ printOut "Dmt directiry has been provided: $DMTDIR"
+ shift 2 ;;
+ -inipath ) INI_PATH="-i $2" ;
+ printOut "INI_PATH: $INI_PATH"
+ shift 2 ;;
+ *.zip ) printOut "Unzipping file $1 ...";
+ unzip -o $1 > /dev/null;
+ shift ;;
+ *.dmts ) printOut "Convert file $1 to dir Dmt ...";
+ $JAVA_HOME/bin/java -classpath lib/GenTool.jar com.mot.dm.tool.DMTSTool -conversion "$1" .
+ shift ;;
+ esac
+done
+
+# parse the last argument, can be .zip or output directory( for old versions )
+case "$1" in
+ -h|--help ) usage
+ exit 1;;
+ -debug ) DEBUG=yes
+ shift ;;
+ -ddfext ) GENDDF=genextddf
+ shift ;;
+ *.zip ) printOut "Unzipping file $1 ...";
+ unzip -o $1 > /dev/null;
+ shift ;;
+ *.dmts ) printOut "Convert file $1 to dir Dmt ...";
+ $JAVA_HOME/bin/java -classpath lib/GenTool.jar com.mot.dm.tool.DMTSTool -conversion "$1" .
+ shift ;;
+ * )
+ if [ "$DMTDIR" == "Dmt" ]
+ then
+ OUTPUTDIR=$1/treedata ;
+ printOut "OUTPUTDIR: $OUTPUTDIR"
+ fi
+ shift ;;
+esac
+
+# set output directory for Gen debug and for mv
+if [ "$DEBUG" == "yes" ]
+then
+ DEBUG_INFO_DIR=/tmp/java.run.out.$$
+ printOut "Debug info can be found in the $DEBUG_INFO_DIR"
+ OUT=stdout
+fi
+
+# fstab is reduered file, test if fstab exists and readable
+if [ ! -r $FSTAB_FILE ]
+then
+ echo "Cannot find fstab file with path: $FSTAB_FILE"
+ echo "Cleaning up on abort..."
+ if [ -d Dmt ]
+ then
+ rm -rf Dmt
+ fi
+ rm -rf $OUTPUTDIR
+ exit 1
+fi
+
+# Remove output directory if exists
+if [ -d "$OUTPUTDIR" ]
+then
+ printOut "Removing output directory ..."
+ rm -rf $OUTPUTDIR
+fi
+
+mkdir -p $OUTPUTDIR/docs
+
+#add support for the relative Dmt path
+cd ..
+if [ -d $DMTDIR ]
+then
+ cd -
+else
+ cd -
+ DMTDIR=`pwd`/$DMTDIR
+ if [ ! -d $DMTDIR ]
+ then
+ echo "Cannot find $DMTDIR"
+ exit 1
+ fi
+fi
+
+#file for the error messages
+ERR_FILE=err_`whoami`
+
+if [ "$NOVALIDATION" == "yes" ]
+then
+ printOut "Attantion!!! DMT will be generated without validation!!!"
+else
+ # Call the DMT Validator
+ printOut "Validating DMT structure..."
+
+ $JAVA_HOME/bin/java -classpath lib/GenTool.jar:lib/joda-time-1.1.jar:lib/jakarta-regexp-1.4.jar com.mot.dm.core.DMTValidator -d $DMTDIR 2> $ERR_FILE > $DEBUG_INFO_DIR
+
+ if [ $? -eq 1 ]
+ then
+ cat $ERR_FILE 2> /dev/null
+
+ printOut "Validation failed!!! Please fix the errors above before continuing..."
+ printOut "Cleaning up on abort..."
+ rm -f $ERR_FILE 2> /dev/null
+ rm -rf Dmt 2> /dev/null
+ rm -rf $OUTPUTDIR 2> /dev/null
+ exit 1
+ else
+ printOut "DMT validation passed..."
+ fi
+fi
+
+# Now call the Gen tool to build the tree data
+printOut "Calling Gen tool to build tree data..."
+
+$JAVA_HOME/bin/java -classpath lib/GenTool.jar:lib/joda-time-1.1.jar:lib/jakarta-regexp-1.4.jar com.mot.dm.core.Gen -d $DMTDIR -f $FSTAB_FILE $INI_PATH -gendoc -$GENDDF -sv 1.0 2> $ERR_FILE > $DEBUG_INFO_DIR
+
+if [ $? -eq 1 ]
+then
+ cat $ERR_FILE 2> /dev/null
+
+ printOut "Please fix the errors above before continuing..."
+ printOut "Cleaning up on abort..."
+ rm -f $ERR_FILE 2> /dev/null
+ rm -rf Dmt 2> /dev/null
+ rm -rf $OUTPUTDIR 2> /dev/null
+ rm -f *.*xml 2> /dev/null
+ rm -f *.html 2> /dev/null
+ rm -f acl.* 2> /dev/null
+ rm -f event.* 2> /dev/null
+ rm -f *.ddf 2> /dev/null
+ rm -f *.*mdf 2> /dev/null
+ rm -f ddfvalues.txt 2> /dev/null
+ if [ "$INI_PATH" != "" ]
+ then
+ rm -f *.c 2> /dev/null
+ rm -f *.h 2> /dev/null
+ fi
+ exit 1
+fi
+
+rm -f $ERR_FILE 2> /dev/null
+
+# Cleanup our Dmt directory and move files to the output dir
+printOut "Cleaning up..."
+
+if [ -d Dmt ]
+then
+ rm -rf Dmt
+fi
+
+mv -f *.xml $OUTPUTDIR 2> /dev/$OUT
+mv -f *.wbxml $OUTPUTDIR 2> /dev/$OUT
+mv -f *.html $OUTPUTDIR/docs 2> /dev/$OUT
+mv -f acl.* $OUTPUTDIR 2> /dev/$OUT
+mv -f event.* $OUTPUTDIR 2> /dev/$OUT
+mv -f *.ddf $OUTPUTDIR 2> /dev/$OUT
+mv -f *.*mdf* $OUTPUTDIR 2> /dev/$OUT
+mv -f ddfvalues.txt $OUTPUTDIR 2> /dev/$OUT
+cp -f $FSTAB_FILE $OUTPUTDIR 2> /dev/$OUT
+if [ "$INI_PATH" != "" ]
+then
+ mv -f *.c $OUTPUTDIR
+ mv -f *.h $OUTPUTDIR
+fi
+
+
diff --git a/engine/dmlib/dmt-tools/lib/DMTTest.jar b/engine/dmlib/dmt-tools/lib/DMTTest.jar
new file mode 100644
index 0000000..fe23950
--- /dev/null
+++ b/engine/dmlib/dmt-tools/lib/DMTTest.jar
Binary files differ
diff --git a/engine/dmlib/dmt-tools/lib/GenTool.jar b/engine/dmlib/dmt-tools/lib/GenTool.jar
new file mode 100644
index 0000000..c3ace11
--- /dev/null
+++ b/engine/dmlib/dmt-tools/lib/GenTool.jar
Binary files differ
diff --git a/engine/dmlib/dmt-tools/lib/jakarta-regexp-1.4.jar b/engine/dmlib/dmt-tools/lib/jakarta-regexp-1.4.jar
new file mode 100644
index 0000000..5d70c35
--- /dev/null
+++ b/engine/dmlib/dmt-tools/lib/jakarta-regexp-1.4.jar
Binary files differ
diff --git a/engine/dmlib/dmt-tools/lib/joda-time-1.1.jar b/engine/dmlib/dmt-tools/lib/joda-time-1.1.jar
new file mode 100644
index 0000000..10c3dca
--- /dev/null
+++ b/engine/dmlib/dmt-tools/lib/joda-time-1.1.jar
Binary files differ
diff --git a/engine/dmlib/dmt-tools/runDMTTest b/engine/dmlib/dmt-tools/runDMTTest
new file mode 100644
index 0000000..7c843c0
--- /dev/null
+++ b/engine/dmlib/dmt-tools/runDMTTest
@@ -0,0 +1,161 @@
+#!/bin/bash
+#====================================================================================================
+#
+# Script Name: runDMTTest
+#
+# General Description: This script generate general test cases, create test directory, execute all
+# test cases and provide result
+#
+#====================================================================================================
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#====================================================================================================
+usage () {
+ echo ""
+ echo "========================================================================================="
+ echo ""
+ echo "Usage : "
+ echo ""
+ echo " runDMTTest fstab Dmt.zip"
+ echo ""
+ echo "Sample:"
+ echo ""
+ echo " ./runDMTTest /home/e32569/DMT/fstab /home/e32569/DMT/Dmt.zip"
+ echo "=========================================================================================="
+ echo ""
+}
+# validate parameters
+if [ "$#" -ne 2 ]
+then
+ echo ""
+ echo " Missing requered parameters!!! "
+ usage
+ exit 1
+fi
+
+export LANG=en_US
+export LANGVAR=en_US
+unset LC_ALL
+export LC_CTYPE="en_US.UTF-8"
+
+
+FSTAB_FILE="$1"
+DMT_ZIP="$2"
+CURRENTDIR=`pwd`
+OUTPUTDIR=$CURRENTDIR/test
+TEST_FILE=$OUTPUTDIR/tests.txt
+ERRORS_FILE=$OUTPUTDIR/errors.txt
+RESULT_FILE=$OUTPUTDIR/result.txt
+
+CREATEPKGDIR=/vobs/linuxjava/device_mgmt/dm/core/src/linux_java/buildscripts
+TMP_FOLDER=/tmp/pckg.lj.`whoami`
+TEST_TREE_PATH=$TMP_FOLDER/samples/dmt_data
+TEST_RUN_PATH=$TMP_FOLDER/samples
+
+
+# Do some checking on our environment - we need java & unzip present
+
+if [ -z "$JAVA_HOME" ]
+then
+ echo "Environment variable JAVA_HOME needs to be set!"
+ exit 1
+fi
+
+unzip > /dev/null
+
+if [ "$?" -ne 0 ]
+then
+ echo "Couldn't find unzip - please install it, or put it on your PATH."
+ exit 1
+fi
+
+
+# fstab is reduered file, test if fstab exists and readable
+if [ ! -r $FSTAB_FILE ]
+then
+ echo "Cannot find fstab file with path: $FSTAB_FILE"
+ exit 1
+fi
+
+# fstab is reduered file, test if fstab exists and readable
+if [ ! -r $DMT_ZIP ]
+then
+ echo "Cannot find Dmt.zip file with path: $DMT_ZIP"
+ exit 1
+fi
+
+# Remove output directory if exists
+if [ -d "$OUTPUTDIR" ]
+then
+ echo "Removing output directory ..."
+ rm -rf $OUTPUTDIR
+fi
+
+mkdir $OUTPUTDIR
+
+echo "Unzipping files. Please wait..."
+rm -rf Dmt
+unzip -o $DMT_ZIP > /dev/null;
+
+echo ""
+echo "Generate test file..."
+$JAVA_HOME/bin/java -classpath lib/DMTTest.jar com.mot.treetest.TreeTest testgen `pwd`/Dmt $TEST_FILE
+
+if [ $? -eq 1 ]
+ then
+ echo "An error occured during generation test file..."
+ echo "Cleaning on abort..."
+ rm -rf Dmt
+ rm -rf $OUTPUTDIR
+ exit 1
+fi
+
+#read $dummy
+
+echo ""
+echo "Create package..."
+cd $CREATEPKGDIR
+./createPackage -d
+
+#read $dummy
+
+echo "Generate DM tree ... "
+cd $CURRENTDIR
+./generateDMT -fstab $FSTAB_FILE $DMT_ZIP
+
+#read $dummy
+
+echo ""
+echo "Replace DM tree in the test package ... "
+rm -f $TEST_TREE_PATH/*
+cp -f $CURRENTDIR/treedata/* $TEST_TREE_PATH
+
+echo "Run DMT test..."
+cd $TEST_RUN_PATH
+./run_test <$TEST_FILE >$RESULT_FILE
+
+#read $dummy
+
+echo "Parse and analyze test result..."
+cd $CURRENTDIR
+$JAVA_HOME/bin/java -classpath lib/DMTTest.jar com.mot.treetest.TreeTest testrun $RESULT_FILE $ERRORS_FILE
+
+echo "Cleaning all temporary files..."
+rm -rf Dmt
+
+exit 0
+
+
+
+
diff --git a/engine/dmlib/dmtapi/native/hdr/dmtNodeImpl.hpp b/engine/dmlib/dmtapi/native/hdr/dmtNodeImpl.hpp
new file mode 100644
index 0000000..7af7eb7
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/hdr/dmtNodeImpl.hpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTNODEIMPL_H__
+#define __DMTNODEIMPL_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "dmt.hpp"
+
+class DmtTreeImpl;
+
+class DmtNodeImpl : public DmtNode
+{
+protected:
+ virtual ~DmtNodeImpl();
+
+public:
+#ifdef LOB_SUPPORT
+ DmtNodeImpl( BOOLEAN bLeaf, BOOLEAN bESN, DmtTree * pTree, CPCHAR oPath, CPCHAR strName );
+#else
+ DmtNodeImpl( BOOLEAN bLeaf, DmtTree * pTree, CPCHAR oPath, CPCHAR strName );
+#endif
+ virtual SYNCML_DM_RET_STATUS_T GetTree( PDmtTree& ptrTree ) const;
+
+ virtual SYNCML_DM_RET_STATUS_T GetPath(DMString & path) const;
+
+ virtual SYNCML_DM_RET_STATUS_T GetAttributes( DmtAttributes& oAttr ) const;
+
+ virtual SYNCML_DM_RET_STATUS_T SetTitle( CPCHAR szTitle );
+
+ virtual SYNCML_DM_RET_STATUS_T SetAcl( const DmtAcl& oAcl );
+
+ virtual SYNCML_DM_RET_STATUS_T GetValue( DmtData& oData ) const;
+
+ virtual SYNCML_DM_RET_STATUS_T SetValue( const DmtData& value );
+
+ virtual SYNCML_DM_RET_STATUS_T GetChildNodes( DMVector<PDmtNode>& oChildren ) const;
+
+ virtual BOOLEAN IsLeaf() const;
+
+ virtual SYNCML_DM_RET_STATUS_T GetChildNode( CPCHAR szPath, PDmtNode& ptrNode );
+
+ virtual SYNCML_DM_RET_STATUS_T Execute( CPCHAR strData, DMString& result );
+
+ virtual SYNCML_DM_RET_STATUS_T GetNodeName(DMString & name) const;
+
+ virtual DMString GetNodeName() const { return m_strName;};
+
+ SYNCML_DM_RET_STATUS_T GetChildNodes( DMVector<PDmtNode>& oChildren, DMStringVector& oChildNames ) const;
+
+ SYNCML_DM_RET_STATUS_T Rename( CPCHAR szNewName );
+ SYNCML_DM_RET_STATUS_T GetFirstChunk(DmtDataChunk& dmtChunkData);
+
+ SYNCML_DM_RET_STATUS_T GetNextChunk(DmtDataChunk& dmtChunkData);
+
+ SYNCML_DM_RET_STATUS_T SetFirstChunk(DmtDataChunk& dmtChunkData);
+
+ SYNCML_DM_RET_STATUS_T SetNextChunk(DmtDataChunk& dmtChunkData);
+
+ SYNCML_DM_RET_STATUS_T SetLastChunk(DmtDataChunk& dmtChunkData);
+
+ boolean IsExternalStorageNode(void) const;
+
+private:
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T SetEngineChunkData(BOOLEAN isLastChunk);
+ SYNCML_DM_RET_STATUS_T GetEngineChunkData(void);
+#endif
+ DmtTreeImpl* GetTree() const;
+ BOOLEAN m_bLeaf;
+ DMString m_oPath;
+ PDmtTree m_ptrTree;
+ DMString m_strName;
+#ifdef LOB_SUPPORT
+ BOOLEAN m_bESN;
+ BOOLEAN m_LobSetComplete;
+ UINT32 m_chunkOffset; // offset
+ DmtDataChunk*chunkData;
+#endif
+};
+
+#endif
diff --git a/engine/dmlib/dmtapi/native/hdr/dmtTreeImpl.hpp b/engine/dmlib/dmtapi/native/hdr/dmtTreeImpl.hpp
new file mode 100644
index 0000000..556e4af
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/hdr/dmtTreeImpl.hpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTTREEIMPL_H__
+#define __DMTTREEIMPL_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "jem_defs.hpp"
+#include "dmt.hpp"
+#include "dm_tree_typedef.h"
+
+class DMLockingHelper;
+
+class DmtTreeImpl : public DmtTree
+{
+protected:
+ virtual ~DmtTreeImpl();
+
+public:
+ DmtTreeImpl();
+ DmtTreeImpl( BOOLEAN bReadonly ); // creates "nolocking" object for internal use only
+
+ virtual SYNCML_DM_RET_STATUS_T GetNode( CPCHAR path, PDmtNode& ptrNode );
+
+ virtual SYNCML_DM_RET_STATUS_T DeleteNode( CPCHAR path );
+
+ virtual SYNCML_DM_RET_STATUS_T Clone( CPCHAR path, CPCHAR szNewNodeName );
+
+ virtual SYNCML_DM_RET_STATUS_T RenameNode( CPCHAR path, CPCHAR szNewNodeName );
+
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode( CPCHAR path, PDmtNode& ptrCreatedNode, const DmtData& value );
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode(CPCHAR path, PDmtNode& ptrCreatedNode, const DmtData& value , BOOLEAN isESN);
+
+ virtual SYNCML_DM_RET_STATUS_T CreateInteriorNode( CPCHAR path, PDmtNode& ptrCreatedNode );
+
+ virtual SYNCML_DM_RET_STATUS_T GetChildValuesMap( CPCHAR path, DMMap<DMString, DmtData>& mapNodes ) ;
+
+ virtual SYNCML_DM_RET_STATUS_T SetChildValuesMap( CPCHAR path, const DMMap<DMString, DmtData>& mapNodes );
+
+ virtual SYNCML_DM_RET_STATUS_T GetChildNodeNames( CPCHAR path, DMStringVector& mapNodes ) ;
+
+ virtual SYNCML_DM_RET_STATUS_T Flush();
+
+ virtual SYNCML_DM_RET_STATUS_T Commit();
+
+ virtual SYNCML_DM_RET_STATUS_T Rollback();
+
+ virtual SYNCML_DM_RET_STATUS_T Begin();
+
+ virtual BOOLEAN IsAtomic() const ;
+
+ virtual DmtPrincipal GetPrincipal() const ;
+
+ SYNCML_DM_RET_STATUS_T StartSession( const DmtPrincipal& oPrincipal,
+ CPCHAR szSubtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType );
+
+ SYNCML_DM_RET_STATUS_T SetNodeStringProp(CPCHAR path,
+ CPCHAR propName,
+ CPCHAR szValue );
+
+ SYNCML_DM_RET_STATUS_T GetNodeByFullPath( CPCHAR path, PDmtNode& ptrNode );
+
+private:
+ SYNCML_DM_RET_STATUS_T GetNodeProp(CPCHAR path,
+ CPCHAR propName,
+ DMGetData & oData,
+ BOOLEAN isNotCheckACL = FALSE);
+
+ SYNCML_DM_RET_STATUS_T GetFullPath( CPCHAR path, DMString & fullPath ) const;
+
+ SYNCML_DM_RET_STATUS_T HelperCreateLeafNode( CPCHAR szFullpath, const DmtData& value );
+
+ SYNCML_DM_RET_STATUS_T CloneRecurseInteriorNode( PDmtNode origNode, CPCHAR newnodeuri );
+
+ SYNCML_DM_RET_STATUS_T ReleaseTree( SYNCML_DM_COMMAND_T command );
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T CloneESN(PDmtNode origNode, PDmtNode newNode);
+#endif
+ friend class DmtNodeImpl;
+ friend class DMLockingHelper;
+
+private:
+ DMString m_strServerID;
+ DMString m_strRootPath;
+ SYNCML_DM_TREE_LOCK_TYPE_T m_nLockType;
+ INT32 m_nLockID;
+ BOOLEAN m_isAtmoic;
+};
+
+#endif
diff --git a/engine/dmlib/dmtapi/native/src/dmVersion.cc b/engine/dmlib/dmtapi/native/src/dmVersion.cc
new file mode 100644
index 0000000..95254e2
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmVersion.cc
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include "dmVersion.h"
+
+#define DMSyncMLPackageName "Device Management SyncML Engine"
+#define DMSyncMLCopyright "Copyright (C) 2014 The Android Open Source Project"
+
+#ifndef DMSyncMLLibVersion
+#define DMSyncMLLibVersion "Development"
+#endif
+
+#define DMSyncMLVersion DMSyncMLPackageName " " DMSyncMLLibVersion " " DMSyncMLCopyright
+
+const char *GetDMSyncMLVersion(unsigned long *version)
+{
+ const char *p = DMSyncMLLibVersion;
+ int i = 0;
+ if (version != (unsigned long *)NULL)
+ {
+ *version = 0;
+ while (p[i] != '\0')
+ {
+ if (p[i] < '0' || p[i] > '9')
+ {
+ ++i;
+ continue;
+ }
+ *version <<= 4;
+ (*version) |= (unsigned long)(p[i] - '0');
+ ++i;
+ }
+ }
+ return DMSyncMLVersion;
+}
diff --git a/engine/dmlib/dmtapi/native/src/dmstring.cc b/engine/dmlib/dmtapi/native/src/dmstring.cc
new file mode 100644
index 0000000..4e2607e
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmstring.cc
@@ -0,0 +1,349 @@
+#include "dmdefs.h"
+#include "xpl_Logger.h"
+#include "dmstring.h"
+#include "xpl_StringUtil.h"
+#include <ctype.h>
+
+#define DM_STR_ALIGN_BY 16
+
+static inline int GetAdjustedLen( int nLen )
+{
+ int nRes = (nLen + DM_STR_ALIGN_BY - 1) / DM_STR_ALIGN_BY * DM_STR_ALIGN_BY;
+ return nRes;
+}
+
+DMString::DMString(CPCHAR szStr)
+{
+ m_pStr = NULL;
+ (*this) = szStr;
+}
+
+DMString::DMString(CPCHAR szStr, INT32 nLen)
+{
+ m_pStr = NULL;
+ assign( szStr, nLen );
+}
+
+DMString::DMString(const DMString& str)
+{
+ m_pStr = NULL;
+ (*this) = str;
+}
+
+
+DMString& DMString::operator=( CPCHAR szStr )
+{
+ int nTrgLen = szStr ? DmStrlen(szStr) : 0;
+ assign(szStr, nTrgLen);
+ return *this;
+}
+
+DMString::~DMString()
+{
+ DmFreeMem(m_pStr);
+}
+
+
+BOOLEAN DMString::operator==(CPCHAR szStr) const
+{
+ if ( m_pStr == szStr )
+ return TRUE;
+
+ if ( !szStr )
+ return FALSE;
+
+ return DmStrcmp( c_str(), szStr ) == 0;
+}
+
+DMString& DMString::operator += (CPCHAR szStr)
+{
+ INT32 nLen2 = szStr ? DmStrlen( szStr ) : 0;
+
+ if ( nLen2 == 0 )
+ return *this; // x + null sill x
+
+ INT32 nLen1 = DmStrlen( *this );
+ INT32 nCurBuffer = m_pStr ? GetAdjustedLen(nLen1+1) : 0;
+
+ if ( nCurBuffer > (nLen1 + nLen2) )
+ {
+ DmStrcat(m_pStr, szStr);
+ }
+ else
+ {
+ char* pNewStr = (char*)DmAllocMem( GetAdjustedLen(nLen1 + nLen2 + 1));
+
+ if ( pNewStr ) {
+ DmStrcpy( pNewStr, c_str() );
+ DmStrcat( pNewStr, szStr );
+ }
+ FreeAndSetNull(m_pStr);
+ m_pStr = pNewStr;
+ }
+ return *this;
+}
+
+// append a single character
+DMString& DMString::operator += (char c)
+{
+ INT32 nLen1 = DmStrlen( *this );
+ INT32 nCurBuffer = m_pStr ? GetAdjustedLen(nLen1+1) : 0;
+
+ if (nCurBuffer > (nLen1 + 1))
+ {
+ m_pStr[nLen1] = c;
+ m_pStr[nLen1 + 1] = '\0';
+ }
+ else
+ {
+ char* pNewStr = (char*)DmAllocMem( GetAdjustedLen(nLen1 + 1 + 1));
+
+ if (pNewStr) {
+ DmStrcpy(pNewStr, c_str());
+ pNewStr[nLen1] = c;
+ pNewStr[nLen1 + 1] = '\0';
+ }
+ FreeAndSetNull(m_pStr);
+ m_pStr = pNewStr;
+ }
+ return *this;
+}
+
+void DMString::SetAt( INT32 nPos, char c )
+{
+ if ( nPos < 0 || nPos >= (INT32)DmStrlen(c_str()) ) {
+ XPL_LOG_DM_API_Error(("Invalid pos in DMString::SetAt function: pos %d in string %s\n",nPos,c_str()));
+ return;
+ }
+
+ m_pStr[ nPos ] = c;
+}
+
+void DMString::replaceAll(char oldCh, char newCh) {
+
+ char * pch = NULL;
+
+ if (m_pStr != NULL) {
+ pch = DmStrchr(m_pStr, oldCh);
+
+ while (pch!=NULL) {
+ SetAt(pch - m_pStr, newCh);
+ pch=DmStrchr(pch+1, oldCh);
+ }
+ }
+}
+BOOLEAN DMString::Encode()
+{
+ const static char s_cHexDigits[] = "0123456789ABCDEF";
+ if ( !m_pStr )
+ return TRUE; // nothing to encode
+
+ char* pNewBuf = (char*)DmAllocMem( GetAdjustedLen(DmStrlen(m_pStr) * 3 + 1) );
+
+ if ( !pNewBuf )
+ return FALSE; // out of memory
+
+ CPCHAR szSrc = m_pStr;
+ char* szTrg = pNewBuf;
+
+ // keep intact reserved and unreserved characters, encode all others
+ // reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ","
+ // unreserved = alphanum | mark
+ // mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
+
+ while ( *szSrc ) {
+ if ( (*szSrc >= '&' && *szSrc <= ';') ||
+ (*szSrc >= '?' && *szSrc <= 'Z') ||
+ (*szSrc >= 'a' && *szSrc <= 'z') ||
+ (*szSrc == '!' ) ||
+ (*szSrc == '=' ) ||
+ (*szSrc == '$' ) ||
+ (*szSrc == '_' ) ||
+ (*szSrc == '~' )
+ )
+ *szTrg++ = *szSrc++;
+ else {
+// *szTrg++ = '\\'; // Using bask slash + x instead of %
+// *szTrg++ = 'x';
+// Fllow RFC 2396
+ *szTrg++ = '%';
+
+ *szTrg++ = s_cHexDigits[ ((*szSrc) >> 4) & 0xF ];
+ *szTrg++ = s_cHexDigits[ (*szSrc) & 0xF ];
+ szSrc++;
+ }
+ }
+
+ *szTrg = 0;
+
+ FreeAndSetNull(m_pStr);
+ m_pStr = pNewBuf;
+ return TRUE;
+}
+
+inline INT32 HexDigit2N( char c ) {
+ if ( c >= '0' && c <= '9' )
+ return c-'0';
+
+ if ( c >= 'A' && c <= 'F' )
+ return c - 'A' + 10;
+
+ if ( c >= 'a' && c <= 'f' )
+ return c - 'a' + 10;
+
+ return -1;
+}
+
+BOOLEAN DMString::Decode()
+{
+ CPCHAR szSrc = m_pStr;
+ char* szTrg = m_pStr;
+
+ while ( *szSrc ) {
+ if ( *szSrc != '%' && *szSrc != '\\' )
+ *szTrg++ = *szSrc++;
+ else {
+ if( *szSrc == '\\' )
+ szSrc++; // skip back splash
+ szSrc++; // skip % or x
+ INT32 n1 = HexDigit2N( *szSrc++ );
+
+ if ( n1 < 0 )
+ return FALSE;
+
+ INT32 n2 = HexDigit2N( *szSrc++ );
+
+ if ( n2 < 0 )
+ return FALSE;
+
+ *szTrg++ = (unsigned char)((n1 << 4) + n2);
+ }
+ }
+ *szTrg++ = 0;
+
+ return TRUE;
+}
+
+BOOLEAN DMString::assign( CPCHAR pStr, INT32 nLen )
+{
+ if (!pStr || !pStr[0] || nLen <= 0) {
+ FreeAndSetNull(m_pStr);
+ return TRUE;
+ }
+
+ INT32 nCurBuffer = m_pStr ? GetAdjustedLen(length()+1) : 0;
+
+ if ( nCurBuffer <= nLen ) {
+ FreeAndSetNull(m_pStr);
+ m_pStr = (char *)DmAllocMem( GetAdjustedLen(nLen+1));
+ }
+
+ if ( !m_pStr )
+ return FALSE;
+
+ DmStrncpy( m_pStr, pStr, nLen );
+ m_pStr[nLen] = 0;
+ return TRUE;
+}
+
+void DMString::trim()
+{
+ if (length() > 0 )
+ {
+ char *pStr = m_pStr;
+ while (*pStr == ' ') ++pStr ;
+ INT32 len = DmStrlen(pStr);
+ if (len > 0)
+ {
+ while (*(pStr + len - 1) ==' ') --len ;
+ *((char *)(memmove(m_pStr, pStr, len)) + len) = 0;
+ }
+ }
+}
+
+INT32 DMString::length() const
+{
+ return m_pStr ? DmStrlen(m_pStr) : 0;
+}
+
+void DMString::clear()
+{
+ FreeAndSetNull(m_pStr);
+}
+
+CPCHAR DMString::detach()
+{
+ CPCHAR pStr = GetBuffer();
+ m_pStr = NULL;
+ return pStr;
+}
+
+void DMString::attach(CPCHAR pStr)
+{
+ DmFreeMem(m_pStr);
+ m_pStr = (char*)pStr;
+}
+
+char* DMString::AllocateBuffer( int nLen )
+{
+ INT32 nCurBuffer = m_pStr ? GetAdjustedLen(length()+1) : 0;
+
+ if ( nCurBuffer >= nLen )
+ return m_pStr;
+
+ DmFreeMem(m_pStr);
+ m_pStr = (char *)DmAllocMem( GetAdjustedLen(nLen));
+
+ if ( m_pStr )
+ m_pStr[0]=0;
+
+ return m_pStr;
+}
+//------------------------------------------------------------------------
+// FUNCTION : RemoveSufix
+//
+// DESCRIPTION : This function remove the suffix of one string and assigns to a new string
+//
+// RETURN VALUE :
+// POST-CONDITIONS :
+// IMPORTANT NOTES :
+//------------------------------------------------------------------------
+void DMString::RemoveSufix(CPCHAR sourceStr, int seperator)
+{
+ if(sourceStr != NULL)
+ {
+ INT32 len=0;
+ CPCHAR ptr = DmStrrchr(sourceStr, seperator);
+ if (ptr != NULL)
+ len=(INT32)(ptr-sourceStr);
+ assign(sourceStr, len);
+ }
+}
+
+INT32
+DMString::CompareNoCase( const DMString& str2 ) const
+{
+ INT32 val1 = 0;
+ INT32 val2 = 0;
+ const char* p1 = m_pStr;
+ const char* p2 = str2.m_pStr;
+
+ if( p1 && p2 )
+ {
+ do
+ {
+ val1 = xplTolower(*(p1++));
+ val2 = xplTolower(*(p2++));
+ }
+ while( val1 && val2 && ( val1 == val2 ) );
+ }
+ else
+ {
+ val1 = p1 ? 1 : 0;
+ val2 = p2 ? 1 : 0;
+ }
+
+ return (val2 - val1);
+}
+
+
diff --git a/engine/dmlib/dmtapi/native/src/dmt.cc b/engine/dmlib/dmtapi/native/src/dmt.cc
new file mode 100644
index 0000000..e0bcea4
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmt.cc
@@ -0,0 +1,529 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmt.cc
+
+ General Description: Implementation of DmtTreeFactory class.
+
+==================================================================================================*/
+
+#include "dmt.hpp"
+#include "dmtTreeImpl.hpp"
+#include "dm_tree_class.H"
+#include "dmSessionFactory.h"
+#include "xpl_Logger.h"
+#include "dmNotification.h"
+#include "dmprofile.h"
+#include "dmLockingHelper.h"
+
+//------------------------------------------------------------------------
+// Source Name: dmt.cpp
+// General Description: This file contains External API for DMTree C++ API
+//------------------------------------------------------------------------
+
+BOOLTYPE DmtTreeFactory::Initialize()
+{
+
+ DM_PERFORMANCE(DM_INITIALIZE_ENTER);
+
+ BOOLTYPE dm_stat = true;
+ if ( dmTreeObj.Init() == SYNCML_DM_SUCCESS )
+ dm_stat = true;
+ else
+ dm_stat = false;
+
+ DM_PERFORMANCE(DM_INITIALIZE_EXIT);
+ return dm_stat;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T DmtTreeFactory::Uninitialize()
+{
+ DM_PERFORMANCE(DM_UNINITIALIZE_ENTER);
+ SYNCML_DM_RET_STATUS_T dm_stat = dmTreeObj.DeInit(FALSE);
+ DM_PERFORMANCE(DM_UNINITIALIZE_EXIT);
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeFactory::GetTree(
+ const DmtPrincipal& principal,
+ PDmtTree& ptrTree
+ )
+{
+ return GetSubtree( principal, NULL, ptrTree );
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtTreeFactory::GetSubtree(
+ const DmtPrincipal& principal,
+ CPCHAR szSubtreeRoot,
+ PDmtTree& ptrTree
+ )
+{
+ return GetSubtreeEx( principal, szSubtreeRoot, SYNCML_DM_LOCK_TYPE_AUTOMATIC, ptrTree );
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeFactory::GetSubtreeEx(
+ const DmtPrincipal& principal,
+ CPCHAR szSubtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType,
+ PDmtTree& ptrTree
+ )
+{
+ DM_PERFORMANCE(DM_GET_TREE_ENTER);
+
+ ptrTree = NULL;
+
+ if ( !dmTreeObj.IsInitialized() ) {
+ return SYNCML_DM_FAIL;
+ }
+
+ XPL_LOG_DM_API_Debug(("GetSubtreeEx path=%s, nLockType=%dn", szSubtreeRoot, nLockType));
+
+#ifdef DM_NO_LOCKING
+ if ( IsLocked() )
+ return SYNCML_DM_SESSION_BUSY;
+#endif
+
+ PDmtTree ptrNewTree;
+
+ DmtTreeImpl* pNewTree = new DmtTreeImpl;
+ ptrNewTree = pNewTree;
+
+ if ( !pNewTree )
+ return SYNCML_DM_DEVICE_FULL;
+
+ SYNCML_DM_RET_STATUS_T ret_status = pNewTree->StartSession( principal, szSubtreeRoot, nLockType );
+
+ if ( ret_status == SYNCML_DM_SUCCESS )
+ {
+ ptrTree = ptrNewTree;
+#ifdef DM_NO_LOCKING
+ // dmTreeObj.GetLockContextManager().Lock();
+#endif
+ }
+
+ DM_PERFORMANCE(DM_GET_TREE_EXIT);
+
+ return ret_status;
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeFactory::ProcessScript(const DmtPrincipal& principal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ DMString& oResult)
+{
+
+ if ( !dmTreeObj.IsInitialized() )
+ return SYNCML_DM_FAIL;
+
+ if ( !buf || len <= 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+#ifdef DM_NO_LOCKING
+ if ( IsLocked() )
+ return SYNCML_DM_SESSION_BUSY;
+#endif
+
+
+ DMGlobalOMAWorkspaceSharing oOMAWorkspaceLock; // global lock for OMA workspace
+
+
+ SYNCML_DM_RET_STATUS_T ret_status;
+
+ XPL_FS_HANDLE_T hLockFile;
+ XPL_FS_RET_STATUS_T xpl_status;
+
+ hLockFile = XPL_FS_Open(DM_ISP_LOCK, XPL_FS_FILE_WRITE, &xpl_status);
+
+ INT32 nLock = 0;
+
+ {
+ DMLockingHelper oLock( 0, ".", principal.getName().c_str(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE );
+ nLock = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() ){
+ return oLock.GetError();
+ }
+
+
+ DMBuffer oResultDoc;
+
+ ret_status = DmProcessScriptData( buf ,(UINT32)len, isWBXML, oResultDoc);
+
+ if( ret_status == SYNCML_DM_SUCCESS )
+ oResultDoc.copyTo(oResult);
+ }
+
+ dmTreeObj.ReleaseLock( nLock );
+
+ XPL_FS_Remove(DM_ISP_LOCK);
+
+ return ret_status;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtTreeFactory::ProcessScript(const DmtPrincipal& principal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ DMVector<UINT8> & oResult)
+{
+
+ if ( !dmTreeObj.IsInitialized() )
+ return SYNCML_DM_FAIL;
+
+ if ( !buf || len <= 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+#ifdef DM_NO_LOCKING
+ if ( IsLocked() )
+ return SYNCML_DM_SESSION_BUSY;
+#endif
+
+
+ DMGlobalOMAWorkspaceSharing oOMAWorkspaceLock; // global lock for OMA workspace
+
+ XPL_FS_HANDLE_T hLockFile;
+ XPL_FS_RET_STATUS_T xpl_status;
+ hLockFile = XPL_FS_Open(DM_ISP_LOCK, XPL_FS_FILE_WRITE, &xpl_status);
+
+
+ INT32 nLock = 0;
+ SYNCML_DM_RET_STATUS_T ret_status;
+ {
+ DMLockingHelper oLock( 0, ".", principal.getName().c_str(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE );
+ nLock = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() ){
+ return oLock.GetError();
+ }
+
+
+ DMBuffer oResultDoc;
+
+ ret_status = DmProcessScriptData( buf ,(UINT32)len, isWBXML, oResultDoc);
+
+ XPL_LOG_DM_SESS_Debug(("DmtTreeFactory::ProcessScript before release lock, ret_status=%d, result-size=%d\n", ret_status, oResultDoc.getSize()));
+
+ if( ret_status == SYNCML_DM_SUCCESS ) {
+
+ oResult.set_size(oResultDoc.getSize());
+
+ memcpy(oResult.get_data(), oResultDoc.getBuffer(), oResultDoc.getSize());
+ }
+
+ if (oResultDoc.getSize() > 0 ) {
+ char *szResult = new char[oResultDoc.getSize()+1];
+ memcpy(szResult, oResultDoc.getBuffer(), oResultDoc.getSize());
+ szResult[oResultDoc.getSize()] = 0;
+ XPL_LOG_DM_SESS_Debug(("DmtTreeFactory::ProcessScript szResult=%s\n", szResult));
+ delete [] szResult;
+ }
+
+ }
+
+
+
+
+ dmTreeObj.ReleaseLock( nLock );
+
+ XPL_FS_Remove(DM_ISP_LOCK);
+
+ return ret_status;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtTreeFactory::Bootstrap(const DmtPrincipal& principal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMString & serverID)
+{
+
+ if ( !dmTreeObj.IsInitialized() )
+ return SYNCML_DM_FAIL;
+
+ if ( !buf || len <= 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+#ifdef DM_NO_LOCKING
+ if ( IsLocked() )
+ return SYNCML_DM_SESSION_BUSY;
+#endif
+
+
+ DMGlobalOMAWorkspaceSharing oOMAWorkspaceLock; // global lock for OMA workspace
+
+
+ INT32 nLock = 0;
+ SYNCML_DM_RET_STATUS_T ret_status;
+ {
+ DMLockingHelper oLock( 0, ".", principal.getName().c_str(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE );
+ nLock = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ ret_status = DmBootstrap( buf ,(UINT32)len, isWBXML, isProcess, serverID);
+ }
+
+ dmTreeObj.ReleaseLock( nLock );
+
+ return ret_status;
+}
+
+
+
+/**
+* Starts server session based on principal information
+*/
+SYNCML_DM_RET_STATUS_T DmtTreeFactory::StartServerSession( const DmtPrincipal& principal,
+ const DmtSessionProp& sessionProp)
+{
+
+ if ( !dmTreeObj.IsInitialized() )
+ return SYNCML_DM_FAIL;
+
+#ifdef DM_NO_LOCKING
+ if ( IsLocked() ) {
+ XPL_LOG_DM_SESS_Error(("StartServerSession locked\n"));
+ //return SYNCML_DM_SESSION_BUSY;
+ }
+#endif
+
+
+ DMGlobalOMAWorkspaceSharing oOMAWorkspaceLock; // global lock for OMA workspace
+
+ XPL_LOG_DM_SESS_Debug(("Opening session lock file\n"));
+
+ XPL_FS_HANDLE_T hLockFile;
+ XPL_FS_RET_STATUS_T xpl_status;
+ hLockFile = XPL_FS_Open(DM_ISP_LOCK, XPL_FS_FILE_WRITE, &xpl_status);
+
+ SYNCML_DM_RET_STATUS_T ret_status;
+ INT32 nLock = 0;
+ {
+ DMLockingHelper oLock( 0, ".", principal.getName().c_str(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE );
+ nLock = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() ) {
+ XPL_LOG_DM_SESS_Error(("Opening session lock file failed reason=%d\n", oLock.GetError()));
+ return oLock.GetError();
+ }
+ }
+
+
+#ifndef DM_NO_LOCKING
+ dmTreeObj.ReleaseLock( nLock );
+#endif
+
+ ret_status = DmProcessServerData(principal.getName().c_str(), sessionProp);
+#ifdef DM_NO_LOCKING
+ dmTreeObj.ReleaseLock( nLock );
+#endif
+
+ XPL_FS_Remove(DM_ISP_LOCK);
+
+ DM_MEMORY_STATISTICS_WRITE("ServerSession done\n");
+ XPL_LOG_DM_SESS_Debug(("Returning from StartServerSession status=%d\n", ret_status));
+
+ return ret_status;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtTreeFactory::ProcessNotification(
+ const DmtPrincipal& principal,
+ const UINT8 *buf,
+ INT32 len,
+ DmtNotification & notification)
+{
+
+ if ( !dmTreeObj.IsInitialized() )
+ return SYNCML_DM_FAIL;
+
+#ifdef DM_NO_LOCKING
+ if ( IsLocked() )
+ return SYNCML_DM_SESSION_BUSY;
+#endif
+
+
+ SYNCML_DM_RET_STATUS_T ret_status;
+ INT32 nLock = 0;
+ {
+ DMLockingHelper oLock( 0, ".", principal.getName().c_str(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE );
+ nLock = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ }
+
+ ret_status = DmProcessNotification((const UINT8*)buf,len,notification);
+
+ dmTreeObj.ReleaseLock( nLock );
+
+ return ret_status;
+}
+
+
+BOOLEAN DmtTreeFactory::IsLocked()
+{
+#ifdef DM_NO_LOCKING
+ BOOLEAN result = dmTreeObj.GetLockContextManager().IsLocked();
+ XPL_LOG_DM_SESS_Debug(("isLocked() returning=%d\n", result));
+ return result;
+#else
+ XPL_LOG_DM_SESS_Debug(("isLocked() returning false\n"));
+ return FALSE;
+#endif
+}
+
+
+BOOLEAN DmtTreeFactory::IsSessionInProgress()
+{
+ return XPL_FS_Exist(DM_ISP_LOCK);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DmtTreeFactory::SubscribeEvent(CPCHAR szPath,
+ const DmtEventSubscription & oEvent)
+{
+
+ if ( !dmTreeObj.IsInitialized() )
+ return SYNCML_DM_FAIL;
+
+ if ( !szPath )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+
+ INT32 nLockID = 0;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ {
+ DMLockingHelper oLock( 0, ".", "localhost", SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE );
+ nLockID = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return SYNCML_DM_FAIL;
+
+ DMSubscriptionManager & oEventManager = dmTreeObj.GetSubscriptionManager();
+
+ dm_stat = oEventManager.EnableEvent(szPath, oEvent);
+ }
+
+ dmTreeObj.ReleaseLock( nLockID );
+
+ return dm_stat;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DmtTreeFactory::UnSubscribeEvent(CPCHAR szPath)
+{
+ if ( !dmTreeObj.IsInitialized() )
+ return SYNCML_DM_FAIL;
+
+ if ( !szPath )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ INT32 nLockID = 0;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ {
+ DMLockingHelper oLock( 0, ".", "localhost", SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE );
+ nLockID = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return SYNCML_DM_FAIL;
+
+ DMSubscriptionManager & oEventManager = dmTreeObj.GetSubscriptionManager();
+
+ dm_stat = oEventManager.Delete(szPath);
+ }
+
+ dmTreeObj.ReleaseLock( nLockID );
+
+ return dm_stat;
+
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DmtTreeFactory::GetEventSubscription(CPCHAR szPath,
+ DmtEventSubscription & oEvent)
+{
+ if ( !dmTreeObj.IsInitialized() )
+ return SYNCML_DM_FAIL;
+
+ if ( !szPath )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ INT32 nLockID = 0;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ {
+ DMLockingHelper oLock( 0, ".", "localhost", SYNCML_DM_LOCK_TYPE_EXCLUSIVE, FALSE );
+ nLockID = oLock.GetID();
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return SYNCML_DM_FAIL;
+
+ DMSubscriptionManager & oEventManager = dmTreeObj.GetSubscriptionManager();
+
+ dm_stat = oEventManager.GetEvent(szPath, oEvent);
+
+ }
+ dmTreeObj.ReleaseLock( nLockID );
+
+ return dm_stat;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DmtTreeFactory::ParseUpdateEvent(UINT8 * pBuffer,
+ UINT32 size,
+ DmtEventMap & aEventMap)
+{
+ if ( pBuffer == NULL || size == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ DMBufferReader oBuffer(pBuffer,size);
+ dm_stat = DMEventLogger::Deserialize(oBuffer,aEventMap);
+
+ return dm_stat;
+
+}
+
+
+
+
+void* DmtMemAllocEx( size_t nSize, CPCHAR szFile, INT32 nLine )
+{
+ return DmAllocMemEx( nSize, szFile, nLine );
+}
+
+void DmtMemFree( void* p )
+{
+ DmFreeMem( p );
+}
diff --git a/engine/dmlib/dmtapi/native/src/dmtAcl.cc b/engine/dmlib/dmtapi/native/src/dmtAcl.cc
new file mode 100644
index 0000000..5e46488
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmtAcl.cc
@@ -0,0 +1,140 @@
+#include "dmt.hpp"
+#include "dm_uri_utils.h"
+#include "dmConfigItem.h"
+
+DmtAcl::DmtAcl()
+{
+}
+
+
+DmtAcl::DmtAcl(CPCHAR szAcl )
+{
+ if ( !szAcl )
+ return; // empty
+
+ // parse incoming string
+ DMString strAcl, strAclReminder = szAcl;
+
+ while ( DmStringParserGetItem( strAcl, strAclReminder, '&' ) )
+ {
+ DMString strCmd;
+ if ( !DmStringParserGetItem( strCmd, strAcl, '=' ) )
+ continue;
+
+ SYNCML_DM_ACL_PERMISSIONS_T nPermision = 0;
+
+ if ( strCmd == "Add" )
+ nPermision = SYNCML_DM_ACL_ADD;
+ else if ( strCmd == "Delete" )
+ nPermision = SYNCML_DM_ACL_DELETE;
+ else if ( strCmd == "Exec" )
+ nPermision = SYNCML_DM_ACL_EXEC;
+ else if ( strCmd == "Get" )
+ nPermision = SYNCML_DM_ACL_GET;
+ else if ( strCmd == "Replace" )
+ nPermision = SYNCML_DM_ACL_REPLACE;
+ else
+ continue; // unknown cmd
+
+ DMString strHost;
+
+ while ( DmStringParserGetItem( strHost, strAcl, '+' ) )
+ AddPermission( DmtPrincipal( strHost.c_str() ), nPermision );
+
+ }
+}
+
+
+static inline void AddCommand( DMString& str, CPCHAR szCmd, const DMString& strPrincipals )
+{
+ if ( strPrincipals[0] == 0 )
+ return;
+
+ if ( !str[0] == 0 )
+ str += "&";
+ str += szCmd;
+ str += strPrincipals;
+}
+
+DMString DmtAcl::toString() const
+{
+ DMString strAdd, strDelete, strExec, strGet, strReplace;
+
+ for ( DMMap<DmtPrincipal, int>::POS it = m_mapAcls.begin();
+ it != m_mapAcls.end(); it++ ){
+
+ const DmtPrincipal& first = m_mapAcls.get_key( it );
+ SYNCML_DM_ACL_PERMISSIONS_T second = m_mapAcls.get_value( it );
+
+ if ( second & SYNCML_DM_ACL_ADD )
+ DMConfigItem::AttachProperty( strAdd, '+', first.getName() );
+
+ if ( second & SYNCML_DM_ACL_DELETE )
+ DMConfigItem::AttachProperty( strDelete, '+', first.getName() );
+
+ if ( second & SYNCML_DM_ACL_EXEC )
+ DMConfigItem::AttachProperty( strExec, '+', first.getName() );
+
+ if ( second & SYNCML_DM_ACL_GET )
+ DMConfigItem::AttachProperty( strGet, '+', first.getName() );
+
+ if ( second & SYNCML_DM_ACL_REPLACE )
+ DMConfigItem::AttachProperty( strReplace, '+', first.getName() );
+ }
+
+ DMString str;
+
+ AddCommand( str, "Add=", strAdd );
+ AddCommand( str, "Delete=", strDelete );
+ AddCommand( str, "Exec=", strExec );
+ AddCommand( str, "Get=", strGet );
+ AddCommand( str, "Replace=", strReplace );
+
+ return str;
+}
+
+
+void DmtAcl::GetPrincipals( DMVector<DmtPrincipal>& aPrincipals )const
+{
+ for ( DMMap<DmtPrincipal, int>::POS it = m_mapAcls.begin();
+ it != m_mapAcls.end(); it++ )
+ aPrincipals.push_back( m_mapAcls.get_key( it ) );
+}
+
+
+SYNCML_DM_ACL_PERMISSIONS_T DmtAcl::GetPermissions( const DmtPrincipal& principal) const
+{
+ SYNCML_DM_ACL_PERMISSIONS_T n = 0;
+
+ if ( m_mapAcls.lookup( principal, n ) )
+ return n;
+
+ return 0; // not found
+}
+
+void DmtAcl::SetPermission( const DmtPrincipal& principal, SYNCML_DM_ACL_PERMISSIONS_T permissions)
+{
+ m_mapAcls.put( principal, permissions );
+}
+
+void DmtAcl::AddPermission( const DmtPrincipal& principal, SYNCML_DM_ACL_PERMISSIONS_T permissions )
+{
+ UINT16 nCurPermission = GetPermissions( principal );
+
+ m_mapAcls.put( principal ,permissions | nCurPermission);
+}
+
+void DmtAcl::DeletePermission( const DmtPrincipal& principal, SYNCML_DM_ACL_PERMISSIONS_T permissions )
+{
+ SYNCML_DM_ACL_PERMISSIONS_T nCurPermission = GetPermissions( principal );
+
+ m_mapAcls.put( principal ,nCurPermission & (~permissions ) );
+}
+
+BOOLEAN DmtAcl::IsPermitted( const DmtPrincipal& principal, SYNCML_DM_ACL_PERMISSIONS_T permissions ) const
+{
+ BOOLEAN retValue = (GetPermissions( principal ) & permissions ) != 0 ;
+ return retValue;
+}
+
+
diff --git a/engine/dmlib/dmtapi/native/src/dmtAttributes.cc b/engine/dmlib/dmtapi/native/src/dmtAttributes.cc
new file mode 100644
index 0000000..8a7e880
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmtAttributes.cc
@@ -0,0 +1,147 @@
+#include "dmt.hpp"
+
+
+DmtAttributes::DmtAttributes()
+{
+ m_nVersion = -1;
+ m_nSize = -1;
+ m_nTimestamp = -1;
+}
+
+DmtAttributes::DmtAttributes( CPCHAR name,
+ CPCHAR format,
+ CPCHAR title,
+ CPCHAR type,
+ INT32 version,
+ INT32 size,
+ const JemDate& timestamp,
+ const DmtAcl& acl)
+{
+ Set(name,format,title,type,version,size,timestamp,acl);
+}
+
+
+
+SYNCML_DM_RET_STATUS_T DmtAttributes::Set( const DmtAttributes & oAttr )
+{
+ return Set( oAttr.GetName(),
+ oAttr.GetFormat(),
+ oAttr.GetTitle(),
+ oAttr.GetType(),
+ oAttr.GetVersion(),
+ oAttr.GetSize(),
+ oAttr.GetTimestamp(),
+ oAttr.GetAcl());
+}
+
+SYNCML_DM_RET_STATUS_T DmtAttributes::Set( CPCHAR name,
+ CPCHAR format,
+ CPCHAR title,
+ CPCHAR type,
+ INT32 version,
+ INT32 size,
+ const JemDate& timestamp,
+ const DmtAcl& acl)
+{
+ m_nVersion = version;
+ m_nSize = size;
+ m_nTimestamp = timestamp;
+ m_oAcl = acl;
+
+ if(SetName(name) !=SYNCML_DM_SUCCESS )
+ return SYNCML_DM_DEVICE_FULL;
+
+ if(SetFormat(format) !=SYNCML_DM_SUCCESS )
+ return SYNCML_DM_DEVICE_FULL;
+
+ if(SetTitle(title) !=SYNCML_DM_SUCCESS )
+ return SYNCML_DM_DEVICE_FULL;
+
+
+ if ( type && type[0] )
+ {
+ m_strType = type;
+ if ( m_strType == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ else
+ m_strType = NULL;
+
+ return SYNCML_DM_SUCCESS;
+
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtAttributes::SetName
+// DESCRIPTION : Set name of the Node
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtAttributes::SetName( CPCHAR name)
+{
+ if ( name && name[0] )
+ {
+ m_strName = name;
+ if ( m_strName == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ else
+ m_strName = NULL;
+
+ return SYNCML_DM_SUCCESS;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtAttributes::SetFormat
+// DESCRIPTION : Set format of the Node
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtAttributes::SetFormat( CPCHAR format)
+{
+ if ( format && format[0] )
+ {
+ m_strFormat = format;
+ if ( m_strFormat == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ else
+ m_strFormat = NULL;
+ return SYNCML_DM_SUCCESS;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtAttributes::SetTitle
+// DESCRIPTION : Set title of the Node
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtAttributes::SetTitle( CPCHAR title)
+{
+ if ( title && title[0] )
+ {
+ m_strTitle = title;
+ if ( m_strTitle == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ else
+ m_strTitle = NULL;
+ return SYNCML_DM_SUCCESS;
+
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtAttributes::SetSize
+// DESCRIPTION : Set size of the Node
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : None
+//
+//--------------------------------------------------------------------------------------------
+void DmtAttributes::SetSize( INT32 size)
+{
+ m_nSize = size;
+}
+
diff --git a/engine/dmlib/dmtapi/native/src/dmtData.cc b/engine/dmlib/dmtapi/native/src/dmtData.cc
new file mode 100644
index 0000000..f5429bf
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmtData.cc
@@ -0,0 +1,408 @@
+#include "dmStringUtil.h"
+#include "xpl_Logger.h"
+#include "dmt.hpp"
+#include "dmMemory.h"
+
+extern "C" {
+#include "xpt-b64.h"
+}
+
+DmtData::DmtData()
+{
+ metaFormat = SYNCML_DM_DATAFORMAT_UNDEFINED;
+}
+
+/**
+* Combine STRING, DATE and TIME type objects through a single
+* contructor
+*/
+DmtData::DmtData(CPCHAR szStr):metaFormat(SYNCML_DM_DATAFORMAT_STRING)
+{
+ SetString(szStr, SYNCML_DM_DATAFORMAT_STRING);
+}
+
+DmtData::DmtData(CPCHAR szStr, SYNCML_DM_DATAFORMAT_T type):
+ metaFormat(type)
+{
+ SetString(szStr, type);
+}
+
+DmtData::DmtData(INT32 integer)
+{
+ SetInt(integer);
+}
+
+DmtData::DmtData(BOOLEAN b)
+{
+ SetBoolean(b);
+}
+
+DmtData::DmtData(BOOLTYPE b)
+{
+ SetBoolean(b?1:0);
+}
+
+DmtData::DmtData( const UINT8 * bin, INT32 len)
+{
+ SetBinary(bin,len);
+}
+
+DmtData::DmtData( const DMStringVector& aChildren )
+{
+ SetNodeValue(aChildren);
+}
+
+DmtData::~DmtData()
+{
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::SetString(CPCHAR szStr,
+ SYNCML_DM_DATAFORMAT_T type)
+{
+ // Extend this method to initialize other text/plain type
+ // DM data.
+ //
+ if (szStr==NULL)
+ {
+ metaFormat = SYNCML_DM_DATAFORMAT_NULL;
+ } else
+ {
+ m_strValue = szStr;
+ if ( szStr[0] && m_strValue.GetBuffer() == NULL )
+ {
+ XPL_LOG_DM_API_Error(("DmtData::SetString : unable allocate memory\n"));
+ metaFormat = SYNCML_DM_DATAFORMAT_UNDEFINED;
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ else if ( type == SYNCML_DM_DATAFORMAT_INT )
+ {
+ m_nValue = DmAtoi(szStr);
+ }
+ else if ( type == SYNCML_DM_DATAFORMAT_BOOL )
+ {
+ m_bValue = DmStrcasecmp(szStr, "false");
+ }
+ else if ( type == SYNCML_DM_DATAFORMAT_FLOAT ||
+ type == SYNCML_DM_DATAFORMAT_DATE ||
+ type == SYNCML_DM_DATAFORMAT_TIME )
+ {
+ m_strValue.trim();
+ }
+ metaFormat = type;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::SetBoolean(BOOLEAN bValue)
+{
+ m_bValue = bValue;
+ metaFormat = SYNCML_DM_DATAFORMAT_BOOL;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::SetInt(INT32 nValue)
+{
+ m_nValue = nValue;
+ char numbuf[MAX_INT_STRING_LENGTH];
+ DmSprintf( numbuf, "%d", m_nValue );
+ m_strValue = numbuf;
+ metaFormat = SYNCML_DM_DATAFORMAT_INT;
+ return SYNCML_DM_SUCCESS;
+
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::SetFloat(CPCHAR sFloat)
+{
+ return SetString(sFloat, SYNCML_DM_DATAFORMAT_FLOAT);
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtData::SetDate(CPCHAR sDate)
+{
+ return SetString(sDate, SYNCML_DM_DATAFORMAT_DATE);
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::SetTime(CPCHAR sTime)
+{
+ return SetString(sTime, SYNCML_DM_DATAFORMAT_TIME);
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::SetBinary(const UINT8 * buf, INT32 len)
+{
+ if ( buf && len > 0 )
+ {
+ m_pBinValue.set_size( len );
+ if ( m_pBinValue.size() != len )
+ {
+ XPL_LOG_DM_API_Error(("DmtData::SetBinary : unable allocate memory\n"));
+ m_pBinValue.clear();
+ metaFormat = SYNCML_DM_DATAFORMAT_UNDEFINED;
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ memcpy( m_pBinValue.get_data(), buf, len );
+ }
+ else
+ m_pBinValue.clear();
+
+ metaFormat = SYNCML_DM_DATAFORMAT_BIN;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::SetNodeValue( const DMStringVector& aChildren )
+{
+
+ m_astrNodeValue = aChildren;
+ if ( m_astrNodeValue.size() != aChildren.size() )
+ {
+ XPL_LOG_DM_API_Error(("DmtData::SetNodeValue : unable allocate memory\n"));
+ metaFormat = SYNCML_DM_DATAFORMAT_UNDEFINED;
+ m_astrNodeValue.clear();
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ metaFormat = SYNCML_DM_DATAFORMAT_NODE;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtData::Set( const DmtData & oData )
+{
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+ switch (oData.GetType())
+ {
+ case SYNCML_DM_DATAFORMAT_STRING:
+ case SYNCML_DM_DATAFORMAT_DATE:
+ case SYNCML_DM_DATAFORMAT_TIME:
+ res = SetString(oData.GetStringValue(), oData.GetType());
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BIN:
+ {
+ const DMVector<UINT8> & value = oData.GetBinaryValue();
+ res = SetBinary(((DMVector<UINT8> &)value).get_data(),value.size());
+ }
+ break;
+
+ case SYNCML_DM_DATAFORMAT_NODE:
+ res = SetNodeValue(oData.GetNodeValue());
+ break;
+
+ case SYNCML_DM_DATAFORMAT_FLOAT:
+ case SYNCML_DM_DATAFORMAT_BOOL:
+ case SYNCML_DM_DATAFORMAT_INT:
+ case SYNCML_DM_DATAFORMAT_NULL:
+ case SYNCML_DM_DATAFORMAT_UNDEFINED:
+ *this = oData;
+ break;
+
+ }
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::AddNodeValue( const DMString & sChild )
+{
+
+ INT32 size = m_astrNodeValue.size() + 1;
+ m_astrNodeValue.push_back(sChild);
+ if ( size != m_astrNodeValue.size() )
+ {
+ XPL_LOG_DM_API_Error(("DmtData::SetNodeValue : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ metaFormat = SYNCML_DM_DATAFORMAT_NODE;
+ return SYNCML_DM_SUCCESS;
+}
+
+const DMString & DmtData::GetStringValue() const
+{
+ return m_strValue;
+}
+
+const DMVector<UINT8> & DmtData::GetBinaryValue() const
+{
+ return m_pBinValue;
+}
+
+const DMStringVector & DmtData::GetNodeValue() const
+{
+ return m_astrNodeValue;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::GetString( DMString& str ) const
+{
+ if (metaFormat == SYNCML_DM_DATAFORMAT_BIN)
+ {
+ /* Base64 encode for the ./CSIM/Provobj node. */
+ UINT32 dataSize = m_pBinValue.size();
+
+ if (dataSize == 0) {
+ str = "";
+ XPL_LOG_DM_API_Error(("DmtData::GetString() on empty BIN node returning empty string"));
+ return SYNCML_DM_SUCCESS;
+ }
+
+ UINT32 encLen = base64GetSize(dataSize);
+ XPL_LOG_DM_API_Error(("DmtData::GetString() dataSize=%d encLen=%d\n", dataSize, encLen));
+ XPL_LOG_DM_API_Error(("DmtData::GetString() [0]=%02x [1]=%02x [%d]=%02x\n", m_pBinValue.get_data()[0],
+ m_pBinValue.get_data()[1], dataSize - 1, m_pBinValue.get_data()[dataSize - 1]));
+
+ UINT8* pEncData = (UINT8 *)DmAllocMem(encLen+1);
+ memset(pEncData, 0, encLen+1);
+ UINT32 offset = 0;
+ int totalSize = base64Encode(pEncData, encLen, (DataBuffer_t)m_pBinValue.get_data(),
+ (BufferSize_t *)&dataSize, (BufferSize_t *)&offset, 0, NULL);
+
+ str = DMString( reinterpret_cast<CPCHAR>(pEncData) );
+ DmFreeMem(pEncData);
+ XPL_LOG_DM_API_Error(("DmtData::GetString() on BIN node returning: %s\n", str.c_str()));
+ return SYNCML_DM_SUCCESS;
+ }
+
+ if (metaFormat == SYNCML_DM_DATAFORMAT_NODE)
+ {
+ /* NODE conversion to String not allowed */
+ return SYNCML_DM_INVALID_PARAMETER;
+ }
+
+ if ( (metaFormat == SYNCML_DM_DATAFORMAT_STRING) ||
+ (metaFormat == SYNCML_DM_DATAFORMAT_INT) ||
+ (metaFormat == SYNCML_DM_DATAFORMAT_FLOAT) ||
+ (metaFormat == SYNCML_DM_DATAFORMAT_DATE) ||
+ (metaFormat == SYNCML_DM_DATAFORMAT_TIME) )
+ {
+ str = m_strValue;
+ return SYNCML_DM_SUCCESS;
+ }
+
+ if (metaFormat == SYNCML_DM_DATAFORMAT_BOOL)
+ {
+ str = m_bValue ? "true" : "false";
+ return SYNCML_DM_SUCCESS;
+ }
+
+ if (metaFormat == SYNCML_DM_DATAFORMAT_NULL)
+ {
+ str = "";
+ return SYNCML_DM_SUCCESS;
+ }
+
+
+ /* unknown type - string conversiob is not allowed */
+ return SYNCML_DM_INVALID_PARAMETER;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::GetBoolean( BOOLEAN& bValue ) const
+{
+ bValue = FALSE;
+ if (metaFormat != SYNCML_DM_DATAFORMAT_BOOL)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ bValue = m_bValue;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::GetBoolean( BOOLTYPE& bValue ) const
+{
+ bValue = FALSE;
+ if (metaFormat != SYNCML_DM_DATAFORMAT_BOOL)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ bValue = m_bValue?TRUE:FALSE;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::GetInt( INT32& nValue ) const
+{
+ if (metaFormat != SYNCML_DM_DATAFORMAT_INT)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ nValue = m_nValue;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::GetFloat( DMString& sFloat ) const
+{
+ if (metaFormat != SYNCML_DM_DATAFORMAT_FLOAT)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ sFloat = m_strValue;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::GetDate( DMString& sDate ) const
+{
+ if (metaFormat != SYNCML_DM_DATAFORMAT_DATE)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ sDate = m_strValue;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::GetTime( DMString& sTime ) const
+{
+ if (metaFormat != SYNCML_DM_DATAFORMAT_TIME)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ sTime = m_strValue;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::GetBinary(DMVector<UINT8>& buffer ) const
+{
+ if (metaFormat != SYNCML_DM_DATAFORMAT_BIN)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ buffer = m_pBinValue;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtData::GetNodeValue( DMStringVector& aChildren ) const
+{
+ if (metaFormat != SYNCML_DM_DATAFORMAT_NODE)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ aChildren = m_astrNodeValue;
+ return SYNCML_DM_SUCCESS;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtData::GetSize
+// DESCRIPTION : Get data size
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtData::GetSize(INT32 &dataSize) const
+{
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+ switch(metaFormat)
+ {
+ case SYNCML_DM_DATAFORMAT_STRING:
+ dataSize = m_strValue.length();
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BIN:
+ dataSize = m_pBinValue.size();
+ break;
+
+ case SYNCML_DM_DATAFORMAT_NODE:
+ dataSize = m_astrNodeValue.size();
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BOOL:
+ case SYNCML_DM_DATAFORMAT_INT:
+ case SYNCML_DM_DATAFORMAT_NULL:
+ case SYNCML_DM_DATAFORMAT_FLOAT:
+ case SYNCML_DM_DATAFORMAT_DATE:
+ case SYNCML_DM_DATAFORMAT_TIME:
+ case SYNCML_DM_DATAFORMAT_UNDEFINED:
+ { DMString strValue;
+ res = GetString(strValue);
+ if(res == SYNCML_DM_SUCCESS)
+ dataSize = strValue.length();
+ }
+ break;
+
+ }
+ return res;
+}
+
diff --git a/engine/dmlib/dmtapi/native/src/dmtDataChunk.cc b/engine/dmlib/dmtapi/native/src/dmtDataChunk.cc
new file mode 100644
index 0000000..173f290
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmtDataChunk.cc
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*=============================================================================
+
+ Module Name: dmtDataChunk.cc
+
+ General Description: Implementation of DmtDataChunk class.
+
+=============================================================================*/
+
+#include "dmt.hpp"
+#include "xpl_dm_Manager.h"
+#include "dmMemory.h"
+
+/*=============================================================================
+*Function called: DmtDataChunk
+*Parameters :
+*Returns:
+*Synopsis: The constructor of DmtDataChunk
+*Pre-conditions:
+*Post-Conditions:
+
+=============================================================================*/
+DmtDataChunk::DmtDataChunk()
+{
+ chunkBuffer = NULL;
+ dataSize = 0L;
+ returnLen = 0L;
+ maxDataSize = XPL_DM_GetChunkSize();
+}
+
+/*=============================================================================
+*Function called: DmtDataChunk::attach
+*Parameters :
+*Returns:
+*Synopsis: Attach chunk buffer
+*Pre-conditions:
+*Post-Conditions:
+
+=============================================================================*/
+void DmtDataChunk::attach(UINT8 *chunkBuffer, UINT32 dataSize)
+{
+ this->chunkBuffer = chunkBuffer;
+ this->dataSize = dataSize;
+ returnLen = 0L;
+ maxDataSize = XPL_DM_GetChunkSize();
+}
+
+/*=============================================================================
+*Function called: DmtDataChunk::detach
+*Parameters :
+*Returns:
+*Synopsis: Detach chunk buffer
+*Pre-conditions:
+*Post-Conditions:
+
+=============================================================================*/
+UINT8 * DmtDataChunk::detach()
+{
+ UINT8 *pBuffer = this->chunkBuffer;
+ this->chunkBuffer = NULL;
+ this->dataSize = 0;
+ returnLen = 0L;
+ return pBuffer;
+}
+
+/*=============================================================================
+*Function called: ~DmtDataChunk
+*Parameters :
+*Returns:
+*Synopsis: The destructor of DmtDataChunk
+*Pre-conditions:
+*Post-Conditions:
+
+=============================================================================*/
+DmtDataChunk::~DmtDataChunk()
+{
+ if(chunkBuffer != NULL)
+ DmFreeMem(chunkBuffer);
+}
+
+/*=============================================================================
+*Function called: GetChunkSize
+*Parameters :
+*Returns: Return chunk buffer size to acess ESN data
+*Synopsis:
+*Pre-conditions:
+*Post-Conditions:
+
+=============================================================================*/
+ UINT32 DmtDataChunk::GetChunkSize()
+{
+ return XPL_DM_GetChunkSize();
+}
+
+/*=============================================================================
+*Function called: GetChunkData
+*Parameters :
+* bufp --Pointer to the pointer of chunk data
+*Returns:
+* return SYNCML_DM_SUCCESS if get data successfully
+* return other in case of error
+
+*Synopsis:
+
+*Pre-conditions:
+*Post-Conditions:
+=============================================================================*/
+ SYNCML_DM_RET_STATUS_T DmtDataChunk::GetChunkData( UINT8 **bufp)
+ {
+ *bufp = chunkBuffer;
+ return SYNCML_DM_SUCCESS;
+ }
+
+/*=============================================================================
+*Function called: GetChunkDataSize
+*Parameters :
+* dataSize - return data size
+*Returns:
+* return SYNCML_DM_SUCCESS if get data size successfully
+* return other in case of error
+
+*Synopsis:
+
+*Pre-conditions:
+*Post-Conditions:
+=============================================================================*/
+ SYNCML_DM_RET_STATUS_T DmtDataChunk::GetChunkDataSize( UINT32& dataSize)
+{
+ dataSize = this->dataSize;
+ return SYNCML_DM_SUCCESS;
+}
+
+/*=============================================================================
+*Function called: GetReturnLen
+*Parameters :
+* len --Reference to return data size in chunk buffer
+*Returns:
+* return SYNCML_DM_SUCCESS if get return size successfully
+* return other in case of error
+
+*Synopsis:
+
+*Pre-conditions:
+*Post-Conditions:
+=============================================================================*/
+
+ SYNCML_DM_RET_STATUS_T DmtDataChunk::GetReturnLen( UINT32& len ) const
+{
+ len = returnLen;
+ return SYNCML_DM_SUCCESS;
+}
+/*=============================================================================
+*Function called: SetReturnLen
+*Parameters :
+* len --Reference to return data size in chunk buffer
+*Returns:
+* return SYNCML_DM_SUCCESS if set return length successfully
+* return other in case of error
+
+*Synopsis:
+
+*Pre-conditions:
+*Post-Conditions:
+=============================================================================*/
+ SYNCML_DM_RET_STATUS_T DmtDataChunk::SetReturnLen( UINT32& len )
+{
+ returnLen = len;
+ return SYNCML_DM_SUCCESS;
+}
+
+/*=============================================================================
+*Function called: SetChunkData
+*Parameters :
+ buf --Pointer to data buffer need to copy to chunk buffer
+ dataSize -- Data size in the buf
+*Returns:
+* return SYNCML_DM_SUCCESS if if set chunk data successfully
+* return other in case of error
+
+*Synopsis:
+
+*Pre-conditions:
+*Post-Conditions:
+=============================================================================*/
+
+SYNCML_DM_RET_STATUS_T DmtDataChunk::SetChunkData(const UINT8 *buf, UINT32 dataSize)
+{
+SYNCML_DM_RET_STATUS_T resStatus = SYNCML_DM_SUCCESS;
+ if( buf != NULL)
+ {
+ if(dataSize > maxDataSize)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ if(chunkBuffer == NULL)
+ { chunkBuffer = (UINT8*)DmAllocMem(maxDataSize);
+ if(chunkBuffer == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ memcpy(chunkBuffer, buf , dataSize);
+ }
+ this->dataSize = dataSize;
+ return resStatus;
+}
+/*=============================================================================
+*Function called: AllocateChunkBuffer
+*Parameters :
+*Returns:
+* return SYNCML_DM_SUCCESS if if allocate chunk buffer successfully
+* return other in case of error
+
+*Synopsis:
+
+*Pre-conditions:
+*Post-Conditions:
+=============================================================================*/
+SYNCML_DM_RET_STATUS_T DmtDataChunk::AllocateChunkBuffer()
+{
+ if (chunkBuffer == NULL)
+ {
+ chunkBuffer = (UINT8*)DmAllocMem(maxDataSize);
+ if (chunkBuffer == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+/*=============================================================================
+*Function called: FreeChunkBuffer
+*Parameters :
+*Returns:
+* return SYNCML_DM_SUCCESS if if free chunk buffer successfully
+* return other in case of error
+
+*Synopsis:
+
+*Pre-conditions:
+*Post-Conditions:
+=============================================================================*/
+SYNCML_DM_RET_STATUS_T DmtDataChunk::FreeChunkBuffer()
+{
+ if (chunkBuffer != NULL)
+ {
+ DmFreeMem(chunkBuffer);
+ chunkBuffer = NULL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/dmlib/dmtapi/native/src/dmtEvent.cc b/engine/dmlib/dmtapi/native/src/dmtEvent.cc
new file mode 100644
index 0000000..1f010ec
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmtEvent.cc
@@ -0,0 +1,33 @@
+#include "dmt.hpp"
+
+#ifndef NO_CAF
+#ifndef DM_NO_LOCKING
+#include "datainputstream.h"
+
+
+DmtEvent::DmtEvent( DataInputStream* pInputStream )
+{
+ if ( !pInputStream )
+ return;
+
+ char* pStr; pInputStream->readUTF(pStr);
+ m_strURI = pStr;
+
+
+ free( pStr );
+
+ int nKeyNum;
+ for ( pInputStream->readInt(nKeyNum); nKeyNum > 0; nKeyNum-- ) {
+ pInputStream->readUTF(pStr);
+ int nValue; pInputStream->readInt(nValue);
+
+ m_mapKeys.put( pStr, nValue );
+
+ free( pStr );
+ }
+
+ pInputStream->readLongLong( m_llCommitID );
+}
+
+#endif
+#endif
diff --git a/engine/dmlib/dmtapi/native/src/dmtEventSubscription.cc b/engine/dmlib/dmtapi/native/src/dmtEventSubscription.cc
new file mode 100644
index 0000000..f80470e
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmtEventSubscription.cc
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmtEvent.cc
+
+ General Description: Implementation of DmtEvent class.
+
+==================================================================================================*/
+
+#include "dmtEvent.hpp"
+
+SYNCML_DM_RET_STATUS_T
+DmtEventSubscription::Set(SYNCML_DM_EVENT_ACTION_T eAction,
+ SYNCML_DM_EVENT_TYPE_T nType)
+{
+ m_eAction = eAction;
+ m_nType = nType;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DmtEventSubscription::Set(SYNCML_DM_EVENT_ACTION_T eAction,
+ SYNCML_DM_EVENT_TYPE_T nType,
+ CPCHAR szTopic,
+ const DMVector<DmtPrincipal> & aIgnorePrincipals,
+ const DMVector<DmtPrincipal> & aNotifyPrincipals)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ Set(eAction,nType);
+ dm_stat = SetTopic(szTopic);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ m_aIgnorePrincipals = aIgnorePrincipals;
+ m_aNotifyPrincipals = aNotifyPrincipals;
+ return SYNCML_DM_SUCCESS;
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DmtEventSubscription::SetTopic(CPCHAR szTopic)
+{
+ m_strTopic = szTopic;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DmtEventSubscription::AddPrincipal(const DmtPrincipal & oPrincipal, BOOLEAN bIsIgnore)
+{
+ if ( bIsIgnore )
+ m_aIgnorePrincipals.push_back(oPrincipal);
+ else
+ m_aNotifyPrincipals.push_back(oPrincipal);
+ return SYNCML_DM_SUCCESS;
+}
+
+
+const DMVector<DmtPrincipal> &
+DmtEventSubscription::GetPrincipals(BOOLEAN bIsIgnore) const
+{
+ if ( bIsIgnore )
+ return m_aIgnorePrincipals;
+ else
+ return m_aNotifyPrincipals;
+}
diff --git a/engine/dmlib/dmtapi/native/src/dmtNode.cc b/engine/dmlib/dmtapi/native/src/dmtNode.cc
new file mode 100644
index 0000000..77ecd49
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmtNode.cc
@@ -0,0 +1,473 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Name: dmtNode.cc
+
+ General Description: Implementation of the DmtTreeImpl class
+
+==================================================================================================*/
+
+#include "dmt.hpp"
+#include "dmtTreeImpl.hpp"
+#include "dmtNodeImpl.hpp"
+#include "dm_tree_util.h"
+#include "dm_tree_plugin_util.H"
+#include "dmLockingHelper.h"
+
+DmtNodeImpl::~DmtNodeImpl()
+{
+}
+#ifdef LOB_SUPPORT
+DmtNodeImpl::DmtNodeImpl( BOOLEAN bLeaf,BOOLEAN bESN, DmtTree *ptrTree, CPCHAR oPath, CPCHAR strName )
+{
+ m_bLeaf = bLeaf;
+ m_ptrTree = ptrTree;
+ m_oPath = DmtGetSafeStrPtr( oPath );
+ m_strName = strName;
+ m_bESN = bESN;
+ m_chunkOffset = 0L; // offset
+ chunkData = NULL;
+}
+#else
+DmtNodeImpl::DmtNodeImpl( BOOLEAN bLeaf, DmtTree *ptrTree, CPCHAR oPath, CPCHAR strName )
+{
+ m_bLeaf = bLeaf;
+ m_ptrTree = ptrTree;
+ m_oPath = DmtGetSafeStrPtr( oPath );
+ m_strName = strName;
+}
+#endif
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetTree( PDmtTree& ptrTree ) const
+{
+ ptrTree = m_ptrTree;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetPath(DMString & path) const
+{
+ path = m_oPath;
+ if ( m_oPath != NULL && path == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetNodeName(DMString & name) const
+{
+ name = m_strName;
+ if ( m_strName != NULL && name == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetAttributes( DmtAttributes& oAttr ) const
+{
+ DMLockingHelper oLock( GetTree(), GetTree()->m_nLockType );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ return dmTreeObj.GetAttributes(m_oPath.c_str(), oAttr, SYNCML_DM_REQUEST_TYPE_API);
+
+}
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::SetTitle( CPCHAR szTitle )
+{
+ if ( GetTree()->m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DMLockingHelper oLock( GetTree(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ return GetTree()->SetNodeStringProp( m_oPath.c_str(), "Title", szTitle );
+}
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::SetAcl( const DmtAcl& oAcl )
+{
+ if ( GetTree()->m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DMLockingHelper oLock( GetTree(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ return GetTree()->SetNodeStringProp( m_oPath.c_str(), "ACL", oAcl.toString().c_str());
+}
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::Rename( CPCHAR szNewName )
+{
+ if ( GetTree()->m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DMLockingHelper oLock( GetTree(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ return GetTree()->SetNodeStringProp( m_oPath.c_str(), "Name", szNewName );
+}
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetValue( DmtData& oData ) const
+{
+#ifdef LOB_SUPPORT
+if (m_bESN)
+ return SYNCML_DM_RESULTS_TOO_LARGE;
+#endif
+
+ DMLockingHelper oLock( GetTree(), GetTree()->m_nLockType );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMGetData getData;
+
+ dm_stat = dmTreeObj.Get(m_oPath.c_str(),getData,SYNCML_DM_REQUEST_TYPE_API);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if (getData.m_nFormat == SYNCML_DM_FORMAT_NODE )
+ {
+ DMStringVector aChildren;
+ DMURI ptr(FALSE,getData.getCharData());
+ CPCHAR pSegment = NULL;
+
+ oData = DmtData( aChildren ); // set type to "node" for case of empty parent
+
+ // we got list of nodes, divided by '/'
+ while ( (pSegment = ptr.nextSegment()) != NULL )
+ {
+ dm_stat = oData.AddNodeValue(pSegment);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+ }
+ else
+ dm_stat = dmBuildData(getData.m_nFormat, getData.m_oData, oData);
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::SetValue( const DmtData& value )
+{
+#ifdef LOB_SUPPORT
+if (m_bESN)
+ return SYNCML_DM_RESULTS_TOO_LARGE;
+#endif
+
+ if ( GetTree()->m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DMLockingHelper oLock( GetTree(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMAddData oReplace;
+
+ dm_stat = oReplace.set(m_oPath.c_str(),value,"text/plain");
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ return dmTreeObj.Replace(oReplace,SYNCML_DM_REQUEST_TYPE_API);
+}
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetChildNodes( DMVector<PDmtNode>& oChildren ) const
+{
+ DMStringVector aChildren;
+ return GetChildNodes( oChildren, aChildren );
+}
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetChildNodes( DMVector<PDmtNode>& oChildren, DMStringVector& aChildren ) const
+{
+ // cache current time for last access time updates
+ DMTreeCacheCurrentTime cacheTime(&dmTreeObj);
+
+ oChildren.clear(); // remove all previous items from array
+
+ if ( m_bLeaf )
+ return SYNCML_DM_FAIL;
+
+ DmtData oData;
+
+ SYNCML_DM_RET_STATUS_T dm_stat = GetValue( oData );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = oData.GetNodeValue( aChildren );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ for ( int i = 0; i < aChildren.size(); i++ )
+ {
+ DMString oPath = m_oPath;
+
+ oPath += "/";
+ oPath += aChildren[i];
+
+ PDmtNode ptrNode;
+
+ dm_stat = GetTree()->GetNodeByFullPath( oPath.c_str(), ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ oChildren.push_back( ptrNode );
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+BOOLEAN DmtNodeImpl::IsLeaf() const
+{
+ return m_bLeaf;
+}
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetChildNode( CPCHAR szPath, PDmtNode& ptrNode )
+{
+ DMString oPath = m_oPath;
+
+ oPath += "/";
+ oPath += DmtGetSafeStrPtr( szPath );
+
+ return GetTree()->GetNodeByFullPath( oPath.c_str(), ptrNode );
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::Execute( CPCHAR strData, DMString& result )
+{
+
+ if ( GetTree()->m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ return dmTreeObj.Exec(m_oPath.c_str(),strData,result);
+}
+
+// implementation helpers
+DmtTreeImpl* DmtNodeImpl::GetTree() const
+{
+ return (DmtTreeImpl*)m_ptrTree.GetPtr();
+}
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T DmtNodeImpl:: GetEngineChunkData(void)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ DMGetData getData;
+
+ retStatus = getData.set(chunkData, m_chunkOffset);
+
+ if ( retStatus != SYNCML_DM_SUCCESS )
+ return retStatus;
+
+ retStatus = dmTreeObj.Get(m_oPath.c_str(),getData,SYNCML_DM_REQUEST_TYPE_API);
+
+ if ( retStatus != SYNCML_DM_SUCCESS )
+ return retStatus;
+
+ UINT32 returnLen;
+ retStatus = chunkData->GetReturnLen(returnLen);
+ m_chunkOffset += returnLen;
+
+ return retStatus;
+}
+ SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetFirstChunk(DmtDataChunk& dmtChunkData)
+ {
+ DMLockingHelper oLock( GetTree(), GetTree()->m_nLockType );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ if (!m_bESN)
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+
+ if( chunkData != NULL)
+ {
+ if(chunkData != &dmtChunkData)
+ { retStatus = chunkData->FreeChunkBuffer();
+ if(retStatus!= SYNCML_DM_SUCCESS)
+ return retStatus;
+ }
+ }
+ retStatus = dmtChunkData.AllocateChunkBuffer();
+ if(retStatus!= SYNCML_DM_SUCCESS)
+ return retStatus;
+ chunkData = &dmtChunkData;
+ m_chunkOffset = 0L;
+
+ retStatus = GetEngineChunkData();
+ return retStatus;
+ }
+ SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetNextChunk(DmtDataChunk& dmtChunkData)
+ {
+ DMLockingHelper oLock( GetTree(), GetTree()->m_nLockType );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ if (!m_bESN)
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+
+ if(( chunkData == NULL) ||(chunkData != &dmtChunkData))
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ retStatus = GetEngineChunkData();
+ return retStatus;
+ }
+
+ SYNCML_DM_RET_STATUS_T DmtNodeImpl:: SetEngineChunkData(BOOLEAN isLastChunk)
+ {
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ DMAddData oReplace;
+
+ retStatus = oReplace.set(m_oPath.c_str(), chunkData, m_chunkOffset, isLastChunk);
+
+ if ( retStatus != SYNCML_DM_SUCCESS )
+ return retStatus;
+
+ retStatus = dmTreeObj.Replace(oReplace,SYNCML_DM_REQUEST_TYPE_API);
+ if ( retStatus != SYNCML_DM_SUCCESS )
+ return retStatus;
+
+ UINT32 dataLen;
+ retStatus = chunkData->GetChunkDataSize(dataLen);
+ m_chunkOffset += dataLen;
+ return retStatus;
+ }
+
+ SYNCML_DM_RET_STATUS_T DmtNodeImpl:: SetFirstChunk(DmtDataChunk& dmtChunkData)
+ {
+ if (!m_bESN)
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+
+ if ( GetTree()->m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DMLockingHelper oLock( GetTree(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ if (!m_bESN)
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+
+
+ if (chunkData != NULL)
+ {
+ if(chunkData != &dmtChunkData)
+ { retStatus = chunkData->FreeChunkBuffer();
+ if(retStatus!= SYNCML_DM_SUCCESS)
+ return retStatus;
+ }
+ }
+ retStatus = dmtChunkData.AllocateChunkBuffer();
+ if(retStatus!= SYNCML_DM_SUCCESS)
+ return retStatus;
+ chunkData = &dmtChunkData;
+ m_chunkOffset = 0L;
+
+ retStatus = SetEngineChunkData(FALSE);
+ return retStatus;
+
+ }
+
+ SYNCML_DM_RET_STATUS_T DmtNodeImpl::SetNextChunk(DmtDataChunk& dmtChunkData)
+ {
+ if (!m_bESN)
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+
+ if ( GetTree()->m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DMLockingHelper oLock( GetTree(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ if (!m_bESN)
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ if(( chunkData == NULL) ||(chunkData != &dmtChunkData))
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ retStatus = SetEngineChunkData(FALSE);
+
+ return retStatus;
+
+ }
+ SYNCML_DM_RET_STATUS_T DmtNodeImpl::SetLastChunk(DmtDataChunk& dmtChunkData)
+ {
+ if (!m_bESN)
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+
+ if ( GetTree()->m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DMLockingHelper oLock( GetTree(), SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ if (!m_bESN)
+ return SYNCML_DM_UNSUPPORTED_MEDIATYPE_FORMAT;
+ if(( chunkData == NULL) ||(chunkData != &dmtChunkData))
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ retStatus = SetEngineChunkData(TRUE);
+ return retStatus;
+
+}
+boolean DmtNodeImpl::IsExternalStorageNode(void) const
+{ return m_bESN;
+}
+
+#else
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetFirstChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::GetNextChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::SetFirstChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::SetNextChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+SYNCML_DM_RET_STATUS_T DmtNodeImpl::SetLastChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+boolean DmtNodeImpl::IsExternalStorageNode(void) const { return FALSE;}
+
+#endif
diff --git a/engine/dmlib/dmtapi/native/src/dmtSessionProp.cc b/engine/dmlib/dmtapi/native/src/dmtSessionProp.cc
new file mode 100644
index 0000000..b09e42f
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmtSessionProp.cc
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+#include "xpl_Time.h"
+#include "dmtSessionProp.hpp"
+
+
+void DmtSessionProp::generateSessionID()
+{
+ if ( m_nDirection == SYNCML_DM_CLIENT_INITIATED_SESSION )
+ {
+ XPL_CLK_CLOCK_T t = XPL_CLK_GetClock();
+
+ /* The current time is given as seed for generating
+ * pseudo random numbers */
+ srand((UINT32)t);
+ m_nSessionID = rand (); // engine generated session ID
+ if( !m_nSessionID )
+ m_nSessionID = 1;
+ }
+}
diff --git a/engine/dmlib/dmtapi/native/src/dmtTree.cc b/engine/dmlib/dmtapi/native/src/dmtTree.cc
new file mode 100644
index 0000000..948171d
--- /dev/null
+++ b/engine/dmlib/dmtapi/native/src/dmtTree.cc
@@ -0,0 +1,811 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Name: dmtTree.cc
+
+ General Description: Implementation of the DmtTreeImpl class
+
+==================================================================================================*/
+
+#include "dmt.hpp"
+#include "xpl_Logger.h"
+#include "dmtTreeImpl.hpp"
+#include "dmtNodeImpl.hpp"
+#include "dmLockingHelper.h"
+#include "dmprofile.h"
+#include "dm_tree_util.h"
+
+DmtTreeImpl::DmtTreeImpl()
+{
+ m_nLockType = SYNCML_DM_LOCK_TYPE_AUTOMATIC; // automatic
+ m_nLockID = 0; // not acquired
+ m_isAtmoic = FALSE;
+}
+
+DmtTreeImpl::DmtTreeImpl( BOOLEAN bReadonly )
+{
+ m_strServerID = dmTreeObj.GetServerId();
+ m_nLockType = bReadonly ? SYNCML_DM_LOCK_TYPE_SHARED : SYNCML_DM_LOCK_TYPE_EXCLUSIVE;
+ m_nLockID = SYNCML_DM_LOCKID_IGNORE;
+ m_isAtmoic = FALSE;
+}
+
+DmtTreeImpl::~DmtTreeImpl()
+{
+ dmTreeObj.ReleaseLock( m_nLockID );
+#ifdef DM_NO_LOCKING
+ dmTreeObj.GetLockContextManager().UnLock();
+#endif
+
+ DM_MEMORY_STATISTICS_WRITE("tree is released\n");
+
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::GetFullPath( CPCHAR path, DMString & fullPath ) const
+{
+ path = DmtGetSafeStrPtr( path );
+ fullPath = m_strRootPath;
+
+ // KC: Backward GetSubTree(Ex) behavior compatiable
+ INT32 nLen = fullPath.length();
+ if ( fullPath[nLen-1] == '/' )
+ {
+ fullPath.SetAt(nLen-1,0);
+ }
+
+ DMString strTmpPath;
+ {
+ if ( path != NULL && path[0] != '.' && path[0] != '/')
+ {
+ strTmpPath = "/";
+ strTmpPath += path;
+ }
+ else
+ {
+ strTmpPath = path;
+ }
+ }
+ fullPath += strTmpPath.c_str();
+
+ XPL_LOG_DM_TMN_Debug(("GetFullPath: rootpath:%s, path:%s, fullPath:%s, len:%d\n", m_strRootPath.c_str(), path, fullPath.c_str(), fullPath.length()));
+ if ( path[0] != 0 )
+ {
+ return SYNCML_DM_SUCCESS;
+ }
+
+ nLen = fullPath.length();
+ if ( nLen == 0 )
+ {
+ fullPath = ".";
+ return SYNCML_DM_SUCCESS;
+ }
+
+ if ( fullPath[nLen-1] == '/' )
+ {
+ fullPath.SetAt(nLen-1,0);
+ }
+
+ XPL_LOG_DM_TMN_Debug(("GetFullPath: rootpath:%s, path:%s, fullPath:%s, len:%d\n", m_strRootPath.c_str(), path, fullPath.c_str(), fullPath.length()));
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::GetNode( CPCHAR path, PDmtNode& ptrNode )
+{
+ DM_PERFORMANCE(DM_GET_NODE_ENTER);
+
+ path = DmtGetSafeStrPtr( path );
+ DMString strFullPath;
+
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ dm_stat = GetFullPath( path, strFullPath );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("GetFullPath failed: path:%s, full path:%s\n", path, strFullPath.c_str()));
+ return dm_stat;
+ }
+
+#ifdef DM_PROFILER_ENABLED
+ char str[1024];
+ sprintf(str, "GetNode:Native - %s", strFullPath.c_str());
+ DM_PROFILE(str);
+#endif
+
+ dm_stat = GetNodeByFullPath( strFullPath.c_str(), ptrNode );
+
+ DM_PERFORMANCE(DM_GET_NODE_EXIT);
+ return dm_stat;
+
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::GetNodeByFullPath( CPCHAR path, PDmtNode& ptrNode )
+{
+ // cache current time for last access time updates
+ DMTreeCacheCurrentTime cacheTime(&dmTreeObj);
+
+ ptrNode = NULL; // make sure to free prev tree/node if any
+
+ DMLockingHelper oLock( this, m_nLockType );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ {
+ XPL_LOG_DM_TMN_Error(("GetNodeByFullPath failded, cannot apply lock\n"));
+ return oLock.GetError();
+ }
+
+ path = DmtGetSafeStrPtr( path );
+
+ DMGetData oNameData;
+ DMGetData oFormatData;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ dm_stat = GetNodeProp( path, "Name", oNameData, TRUE );
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = GetNodeProp( path, "Format", oFormatData, TRUE );
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_TMN_Debug(("GetNode Property failed :%s\n", path));
+ return dm_stat;
+ }
+
+ BOOLEAN bIsLeaf = (oFormatData.m_oData.compare("node") ? FALSE : TRUE);
+#ifdef LOB_SUPPORT
+ dm_stat = GetNodeProp( path, "ESN", oFormatData, TRUE );
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_TMN_Debug(("GetNode Property failed :%s\n", path));
+ return dm_stat;
+ }
+
+ BOOLEAN bESN = (oFormatData.m_oData.compare("no") ? FALSE : TRUE);
+ // An ESN should be a leaf node
+ if(!bIsLeaf && bESN)
+ return SYNCML_DM_INVALID_PARAMETER;
+ ptrNode = new DmtNodeImpl( bIsLeaf, bESN, this, path, oNameData.getCharData() );
+#else
+ ptrNode = new DmtNodeImpl( bIsLeaf, this, path, oNameData.getCharData() );
+#endif
+
+ if ( ptrNode == NULL )
+ {
+ XPL_LOG_DM_TMN_Error(("low memory\n"));
+ return dm_stat;
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("GetNodeByFullPath succeeded :%s\n", path));
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::RenameNode( CPCHAR path, CPCHAR szNewNodeName )
+{
+ DM_PROFILE("RenameNode:Native");
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = GetNode( path, ptrNode );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ return ((DmtNodeImpl*)ptrNode.GetPtr())->Rename( szNewNodeName );
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::DeleteNode( CPCHAR path )
+{
+ if ( m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DM_PROFILE("DeleteNode:Native");
+ DMLockingHelper oLock( this, SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ path = DmtGetSafeStrPtr( path );
+
+ DMString strFullPath;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ dm_stat = GetFullPath( path, strFullPath );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ return dmTreeObj.Delete ( strFullPath, SYNCML_DM_REQUEST_TYPE_API );
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::CreateLeafNode(CPCHAR path, PDmtNode& ptrCreatedNode, const DmtData& value , BOOLEAN isESN)
+{
+ return SYNCML_DM_COMMAND_NOT_IMPLEMENTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::CreateLeafNode( CPCHAR path, PDmtNode& ptrCreatedNode, const DmtData& value )
+{
+ if ( m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DM_PROFILE("CreateLeafNode:Native");
+ {
+ DMLockingHelper oLock( this, SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ path = DmtGetSafeStrPtr( path );
+ DMString strFullPath;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ dm_stat = GetFullPath( path, strFullPath );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = HelperCreateLeafNode( strFullPath.c_str(), value );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+ return GetNode( path, ptrCreatedNode );
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::CreateInteriorNode( CPCHAR path, PDmtNode& ptrCreatedNode )
+{
+ if ( m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ {
+ return SYNCML_DM_TREE_READONLY;
+ }
+
+ DM_PROFILE("CreateInteriorNode:Native");
+ {
+ DMLockingHelper oLock( this, SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ {
+ XPL_LOG_DM_TMN_Debug(("CreateInteriorNode !oLock.IsLockedSuccessfully\n"));
+ return oLock.GetError();
+ }
+
+ path = DmtGetSafeStrPtr( path );
+ DMString strFullPath;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ dm_stat = GetFullPath( path, strFullPath );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("CreateInteriorNode GetFullPath, path:%s, full path:%s\n", path, strFullPath.c_str()));
+ return dm_stat;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("W21034:CreateInteriorNode GetFullPath, path:%s, full path:%s\n", path, strFullPath.c_str()));
+ dm_stat = SYNCML_DM_INCOMPLETE_COMMAND;
+ DMAddData oAdd;
+
+ dm_stat = oAdd.set(strFullPath,SYNCML_DM_FORMAT_NODE,NULL,0,"text/plain");
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("CreateInteriorNode Set: path:%s, full path:%s\n", path, strFullPath.c_str()));
+ return dm_stat;
+ }
+
+ XPL_LOG_DM_TMN_Debug(("Calling Add API to add the node:%s\n",strFullPath.c_str()));
+ dm_stat=dmTreeObj.Add( oAdd, SYNCML_DM_REQUEST_TYPE_API );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_TMN_Debug(("Failed: CreateInteriorNode Add: path:%s, full path:%s\n", path, strFullPath.c_str()));
+ return dm_stat;
+ }
+ }
+ return GetNode( path, ptrCreatedNode );
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::GetChildValuesMap( CPCHAR path, DMMap<DMString, DmtData>& mapNodes )
+{
+ mapNodes.clear();
+ PDmtNode ptrNode;
+
+ // cache current time for last access time updates
+ DMTreeCacheCurrentTime cacheTime(&dmTreeObj);
+
+ SYNCML_DM_RET_STATUS_T dm_stat = GetNode( path, ptrNode );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DMVector<PDmtNode> oChildren;
+
+ dm_stat = ptrNode->GetChildNodes( oChildren );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ for ( INT32 i = 0; i < oChildren.size(); i++ )
+ {
+ if ( !oChildren[i]->IsLeaf() )
+ continue; // skip interior nodes
+
+#ifdef LOB_SUPPORT
+ // No support for External Storage Node
+ if (oChildren[i]->IsExternalStorageNode() )
+ return SYNCML_DM_RESULTS_TOO_LARGE;
+#endif
+ DmtData data;
+ DMString nodeName;
+
+ dm_stat = oChildren[i]->GetValue( data );
+ if ( dm_stat == SYNCML_DM_COMMAND_NOT_ALLOWED )
+ continue;
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = oChildren[i]->GetNodeName(nodeName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ mapNodes.put( nodeName, data );
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+/**
+ * Set the leaf children with the new set of leaf children. If the children already
+ * exist, replace them. If the children are new, add them. If the children were not
+ * in the new set of leaf children, remove them. Since this is a atomic operation,
+ * it will roll back to the original state if any of above operations failed,
+ *
+ * @author Andy
+ * @param path the path to a node E.g. ./DevInfo
+ * @param mapNodes the new set of leaf children
+ * @return the status of the operation
+ */
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::SetChildValuesMap( CPCHAR path, const DMMap<DMString, DmtData>& mapNodes )
+{
+ DM_PROFILE("SetChildValuesMap:Native");
+
+ // cache current time for last access time updates
+ DMTreeCacheCurrentTime cacheTime(&dmTreeObj);
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if ( m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ DMLockingHelper oLock( this, SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+
+ path = DmtGetSafeStrPtr( path );
+ DMString strFullPath;
+
+ dm_stat = GetFullPath( path, strFullPath );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ // convert data type and call TNM to setLeafChildren
+ DMMap<DMString, UINT32> newChildrenMap;
+
+ dm_stat = dmConvertDataMap(strFullPath.c_str(), mapNodes, newChildrenMap);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = dmTreeObj.setLeafChildren(strFullPath.c_str(), newChildrenMap);
+
+ dmFreeAddMap(newChildrenMap);
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::GetChildNodeNames( CPCHAR path, DMStringVector& aNodes )
+{
+ DM_PROFILE("GetChildNodeNames:Native");
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T dm_stat = GetNode( path, ptrNode );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DMVector<PDmtNode> oChildren;
+
+ return ((DmtNodeImpl*)ptrNode.GetPtr())->GetChildNodes(oChildren, aNodes );
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::Flush()
+{
+ DM_PROFILE("Flush:Native");
+
+ if ( m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+ return ReleaseTree(SYNCML_DM_RELEASE);
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::Commit()
+{
+ DM_PROFILE("Commit:Native");
+ if ( m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+#ifdef DM_ATOMIC_SUPPORTED
+ return ReleaseTree(SYNCML_DM_COMMIT);
+#else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+#endif
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::Rollback()
+{
+ DM_PROFILE("Rollback:Native");
+ if ( m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+#ifdef DM_ATOMIC_SUPPORTED
+ return ReleaseTree(SYNCML_DM_ROLLBACK);
+#else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+#endif
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::Begin()
+{
+ DM_PROFILE("Begin:Native");
+
+ if ( m_nLockType == SYNCML_DM_LOCK_TYPE_SHARED )
+ return SYNCML_DM_TREE_READONLY;
+
+#ifdef DM_ATOMIC_SUPPORTED
+ if ( m_isAtmoic )
+ return SYNCML_DM_COMMAND_FAILED;
+
+ {
+ DMLockingHelper oLock( this, SYNCML_DM_LOCK_TYPE_EXCLUSIVE );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ return oLock.GetError();
+ }
+
+ SYNCML_DM_RET_STATUS_T dm_stat = ReleaseTree(SYNCML_DM_ATOMIC);
+
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ m_isAtmoic = TRUE;
+
+ return dm_stat;
+#else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+#endif
+}
+
+BOOLEAN DmtTreeImpl::IsAtomic() const
+{
+ return m_isAtmoic;
+}
+
+/**
+ * @return the DmtPrincipal object that the session was created with.
+ */
+DmtPrincipal DmtTreeImpl::GetPrincipal() const
+{
+ return DmtPrincipal(m_strServerID.c_str());
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::StartSession( const DmtPrincipal& oPrincipal,
+ CPCHAR szSubtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType )
+{
+ m_strServerID = oPrincipal.getName();
+ m_strRootPath = DmtGetSafeStrPtr( szSubtreeRoot );
+ m_nLockType = nLockType;
+
+ XPL_LOG_DM_TMN_Debug(("StartSession, principal: %s, root:%s\n", m_strServerID.c_str(), m_strRootPath.c_str()));
+
+ if ( !m_strRootPath.empty() )
+ m_strRootPath += "/";
+
+ {
+ DMLockingHelper oLock( this, m_nLockType );
+
+ if ( !oLock.IsLockedSuccessfully() )
+ {
+ XPL_LOG_DM_TMN_Error(("StartSession failed, cannot apply lock\n"));
+ return oLock.GetError();
+ }
+ }
+
+ // if gets subtree only, make sure the path is correct!
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if ( !m_strRootPath.empty() )
+ {
+ PDmtNode ptrNode;
+ dm_stat = GetNode( NULL, ptrNode );
+ }
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::GetNodeProp(
+ CPCHAR path,
+ CPCHAR propName,
+ DMGetData & oData,
+ BOOLEAN isNotCheckACL)
+{
+ path = DmtGetSafeStrPtr( path );
+
+ DMString propPath(path);
+ propPath += "?prop=";
+ propPath += propName;
+
+ return dmTreeObj.Get(propPath, oData,SYNCML_DM_REQUEST_TYPE_API);
+
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::SetNodeStringProp(
+ CPCHAR path,
+ CPCHAR propName,
+ CPCHAR szValue )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if (szValue==NULL)
+ return dm_stat;
+
+ path = DmtGetSafeStrPtr( path );
+ propName = DmtGetSafeStrPtr( propName );
+
+ DMAddData oReplace;
+ DMString propPath(path);
+
+ propPath += "?prop=";
+ propPath += propName;
+
+ dm_stat = oReplace.set(propPath,SYNCML_DM_FORMAT_INVALID,szValue,DmStrlen(szValue),"text/plain");
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ return dmTreeObj.Replace( oReplace,SYNCML_DM_REQUEST_TYPE_API );
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::HelperCreateLeafNode( CPCHAR szFullpath, const DmtData& value )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_INCOMPLETE_COMMAND;
+ DMAddData oAdd;
+
+ dm_stat = oAdd.set(szFullpath,value,"text/plain");
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ return dmTreeObj.Add( oAdd, SYNCML_DM_REQUEST_TYPE_API );
+}
+#ifdef LOB_SUPPORT
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::CloneESN(PDmtNode origNode, PDmtNode newNode)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DmtDataChunk chunkData;
+ UINT32 getLen;
+ dm_stat = origNode->GetFirstChunk(chunkData);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = chunkData.GetReturnLen(getLen);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = chunkData.SetChunkData(NULL, getLen);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = newNode->SetFirstChunk(chunkData);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ while (true)
+ {
+ if (getLen == 0)
+ {
+ dm_stat = newNode->SetLastChunk(chunkData);
+ break;
+ }
+ else
+ {
+ dm_stat = origNode->GetNextChunk(chunkData);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = chunkData.GetReturnLen(getLen);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ if(getLen == 0)
+ continue;
+
+ dm_stat = chunkData.SetChunkData(NULL, getLen);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = newNode->SetNextChunk(chunkData);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ }
+
+ }
+ return dm_stat;
+}
+#endif
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::Clone( CPCHAR path, CPCHAR szNewNodeName )
+{
+ PDmtNode origNode;
+ PDmtNode newNode;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ if (szNewNodeName == NULL)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ dm_stat = GetNode(path, origNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ path = DmtGetSafeStrPtr( path );
+
+ DMString strFullPath;
+
+ dm_stat = GetFullPath( path, strFullPath );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ char* npath;
+ char* newnodeuri = NULL;
+ char* parentnodeuri;
+ char* ec;
+
+ npath = (char*)DmAllocMem(strFullPath.length() + 1);
+ if (npath == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ DmStrcpy(npath, strFullPath.c_str());
+
+ if ((ec = DmStrrchr(npath, '/')) == NULL)
+ {
+ DmFreeMem(npath);
+ return SYNCML_DM_INVALID_PARAMETER;
+ }
+
+ *ec = '\0';
+ parentnodeuri = (char*)npath;
+
+ newnodeuri = (char*) DmAllocMem(DmStrlen(parentnodeuri) + DmStrlen(szNewNodeName) + 2);
+ if (newnodeuri == NULL)
+ {
+ DmFreeMem(npath);
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ DmStrcpy(newnodeuri, parentnodeuri);
+ DmStrcat(newnodeuri, "/");
+ DmStrcat(newnodeuri, szNewNodeName);
+ *ec = '/';
+
+ if (IsValidNode(newnodeuri))
+ {
+ DmFreeMem(npath);
+ DmFreeMem(newnodeuri);
+ return SYNCML_DM_TARGET_ALREADY_EXISTS;
+ }
+
+ if (origNode->IsLeaf())
+ {
+ DmtData data;
+ // Get node data
+ if (!origNode->IsExternalStorageNode())
+ dm_stat = origNode->GetValue(data);
+ // Create leaf node
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ { dm_stat = CreateLeafNode(newnodeuri, newNode, data);
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ DmFreeMem(npath);
+ DmFreeMem(newnodeuri);
+ return dm_stat;
+ }
+ }
+
+#ifdef LOB_SUPPORT
+ // Clone ESN
+ if(origNode->IsExternalStorageNode())
+ {
+ if (newNode->IsExternalStorageNode())
+ dm_stat = CloneESN(origNode, newNode);
+ else
+ dm_stat = SYNCML_DM_INVALID_PARAMETER;
+ }
+#endif
+ }
+ else
+ {
+ dm_stat = CreateInteriorNode(newnodeuri, newNode);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = CloneRecurseInteriorNode(origNode, newnodeuri);
+ }
+ DmFreeMem(npath);
+ DmFreeMem(newnodeuri);
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::CloneRecurseInteriorNode(PDmtNode origNode, CPCHAR newNodeUri)
+{
+ DMVector<PDmtNode> childNodes;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ PDmtNode newNode;
+
+ dm_stat = origNode->GetChildNodes(childNodes);
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ for (int i = 0; i < childNodes.size(); i++)
+ {
+ PDmtNode node = childNodes[i];
+ DMString nodeName;
+ dm_stat = node->GetNodeName(nodeName);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DMString newName = newNodeUri;
+
+ newName += "/";
+ newName += nodeName;
+
+ if (node->IsLeaf())
+ {
+ DmtData data;
+
+ if (!node->IsExternalStorageNode())
+ dm_stat = node->GetValue(data);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = CreateLeafNode(newName.c_str(), newNode, data);
+#ifdef LOB_SUPPORT
+ // Clone ESN
+ if(node->IsExternalStorageNode())
+ {
+ if (newNode->IsExternalStorageNode())
+ dm_stat = CloneESN(node, newNode);
+ else
+ dm_stat = SYNCML_DM_INVALID_PARAMETER;
+ }
+#endif
+ }
+ else
+ {
+ dm_stat = CreateInteriorNode(newName.c_str(), newNode);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = CloneRecurseInteriorNode(node, newName.c_str());
+ }
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtTreeImpl::ReleaseTree( SYNCML_DM_COMMAND_T command )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = dmTreeObj.ReleaseLock( m_nLockID, command );
+
+ m_isAtmoic = FALSE;
+
+ return dm_stat;
+}
diff --git a/engine/dmlib/dmtapi/native_async/hdr/dmtAsyncData.h b/engine/dmlib/dmtapi/native_async/hdr/dmtAsyncData.h
new file mode 100644
index 0000000..1970381
--- /dev/null
+++ b/engine/dmlib/dmtapi/native_async/hdr/dmtAsyncData.h
@@ -0,0 +1,345 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================================================================
+
+ Header Name: dmtAsyncData.h
+
+ General Description: This file contains declaration of structures for
+ async APIs
+
+==============================================================================*/
+
+#ifndef DMT_ASYNC_STRUCT_H
+#define DMT_ASYNC_STRUCT_H
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include "dmtAsyncAPI.h"
+#include "dmbuffer.h"
+#include "dmMemory.h"
+#include "dmt.hpp"
+
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+class DMAsyncMessage
+{
+
+public:
+
+ UINT32 messageID;
+ UINT32 pUserData;
+
+ DMAsyncMessage()
+ {
+ messageID = 0;
+ pUserData = 0;
+
+ }
+
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+
+ SYNCML_DM_RET_STATUS_T set(UINT32 messageID, UINT32 pUserData)
+ {
+ this->messageID = messageID;
+ this->pUserData = pUserData;
+ return SYNCML_DM_SUCCESS;
+ }
+
+};
+
+
+
+
+class DMPrincipalMessage : public DMAsyncMessage
+{
+
+public:
+
+ DmtPrincipal principal;
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR szPrincipal,
+ UINT32 messageID,
+ UINT32 pUserData);
+};
+
+
+class DMGetSubTreeMessage : public DMPrincipalMessage
+{
+
+public:
+
+
+ DMString subtreeRoot;
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType;
+ DMT_CallbackGetTree callback;
+
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR szPrincipal,
+ CPCHAR subtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType,
+ DMT_CallbackGetTree callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+
+class DMScriptMessage : public DMPrincipalMessage
+{
+
+public:
+ DMBuffer buf;
+ BOOLEAN isWBXML;
+
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMProcessScriptMessage : public DMScriptMessage
+{
+
+public:
+ DMT_CallbackProcessScript callback;
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ DMT_CallbackProcessScript callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+class DMBootstrapMessage : public DMScriptMessage
+{
+public:
+ DMT_CallbackBootstrap callback;
+ BOOLEAN isProcess;
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMT_CallbackBootstrap callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMStartServerSessionMessage : public DMPrincipalMessage
+{
+public:
+ DmtSessionProp sessionProp;
+ DMT_CallbackStatusCode callback;
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR szPrincipal,
+ const DMT_SESSION_PROP_T * pSessionProp,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+class DMProcessNotificationMessage : public DMPrincipalMessage
+{
+public:
+ DMBuffer buf;
+ DMT_CallbackProcessNotification callback;
+
+ SYNCML_DM_RET_STATUS_T set(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ DMT_CallbackProcessNotification callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMTreeMessage : public DMAsyncMessage
+{
+public:
+ DMT_H_TREE htree;
+ DMString path;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMGetNodeMessage : public DMTreeMessage
+{
+public:
+ DMT_CallbackGetNode callback;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetNode callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMTreeNodeMessage : public DMTreeMessage
+{
+public:
+ DMT_CallbackStatusCode callback;
+ DMString str;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_TREE htree,
+ CPCHAR path,
+ CPCHAR str,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+
+class DMCreateLeafNodeMessage : public DMTreeMessage
+{
+public:
+ DmtData data;
+ DMT_CallbackStatusCode callback;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMGetChildNodeNamesMessage : public DMTreeMessage
+{
+public:
+ DMT_CallbackGetChildNodeNames callback;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildNodeNames callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+
+};
+
+class DMGetChildValuesMapMessage : public DMTreeMessage
+{
+public:
+ DMT_CallbackGetChildValuesMap callback;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildValuesMap callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMSetChildValuesMapMessage : public DMTreeMessage
+{
+public:
+ DMMap<DMString, DmtData> data;
+ DMT_CallbackStatusCode callback;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_LEAF_CHILDREN_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMSetValueMessage : public DMAsyncMessage
+{
+public:
+ DMT_H_NODE hnode;
+ DmtData data;
+ DMT_CallbackStatusCode callback;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_NODE hnode,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMNodeMessage : public DMAsyncMessage
+{
+public:
+ DMString str;
+ DMT_H_NODE hnode;
+ DMT_CallbackStatusCode callback;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_NODE hnode,
+ CPCHAR str,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+
+class DMExecuteMessage : public DMNodeMessage
+{
+public:
+ DMString params;
+ DMT_CallbackExecute callback;
+
+ SYNCML_DM_RET_STATUS_T set(DMT_H_NODE hnode,
+ CPCHAR params,
+ DMT_CallbackExecute callback,
+ UINT32 messageID,
+ UINT32 pUserData);
+
+};
+
+#endif
diff --git a/engine/dmlib/dmtapi/native_async/hdr/dmtAsyncMessage.h b/engine/dmlib/dmtapi/native_async/hdr/dmtAsyncMessage.h
new file mode 100644
index 0000000..4b17f58
--- /dev/null
+++ b/engine/dmlib/dmtapi/native_async/hdr/dmtAsyncMessage.h
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================================================================
+
+ Header Name: dmtAsyncMessage.h
+
+ General Description: This file contains declaration of structures for
+ async APIs
+
+==============================================================================*/
+
+#ifndef DMT_ASYNC_MESSAGE_H
+#define DMT_ASYNC_MESSAGE_H
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include "dmtAsyncData.h"
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+typedef struct
+{
+ DMT_CallbackStatusCode callback;
+ UINT32 messageID;
+ UINT32 pUserData;
+} SYNCML_DM_ENGINE_MESSAGE_T;
+
+
+typedef struct
+{
+ DMT_CallbackNotifyOnIdle callback;
+ UINT32 messageID;
+ UINT32 pUserData;
+} SYNCML_DM_NOTIFY_MESSAGE_T;
+
+typedef struct
+{
+ DMGetSubTreeMessage * pMsg;
+} SYNCML_DM_GET_SUB_TREE_MESSAGE_T;
+
+
+typedef struct
+{
+ DMProcessScriptMessage * pMsg;
+} SYNCML_DM_PROCESS_SCRIPT_MESSAGE_T;
+
+typedef struct
+{
+ DMBootstrapMessage * pMsg;
+} SYNCML_DM_BOOTSTRAP_MESSAGE_T;
+
+
+typedef struct
+{
+ DMStartServerSessionMessage * pMsg;
+} SYNCML_DM_START_SERVER_SESSION_MESSAGE_T;
+
+typedef struct
+{
+ DMProcessNotificationMessage * pMsg;
+} SYNCML_DM_PROCESS_NOTIFICATION_MESSAGE_T;
+
+typedef struct
+{
+ DMGetNodeMessage * pMsg;
+} SYNCML_DM_GET_NODE_MESSAGE_T;
+
+
+typedef struct
+{
+ DMTreeNodeMessage * pMsg;
+} SYNCML_DM_TREENODE_MESSAGE_T;
+
+
+typedef struct
+{
+ DMCreateLeafNodeMessage * pMsg;
+} SYNCML_DM_CREATE_LEAF_NODE_MESSAGE_T;
+
+
+typedef struct
+{
+ DMGetChildNodeNamesMessage * pMsg;
+} SYNCML_DM_GET_CHILD_NODE_NAMES_MESSAGE_T;
+
+
+typedef struct
+{
+ DMT_H_TREE htree;
+ DMT_CallbackStatusCode callback;
+ UINT32 messageID;
+ UINT32 pUserData;
+} SYNCML_DM_TREE_MESSAGE_T;
+
+
+
+typedef struct
+{
+ DMGetChildValuesMapMessage * pMsg;
+} SYNCML_DM_GET_CHILD_VALUES_MAP_MESSAGE_T;
+
+
+typedef struct
+{
+ DMSetChildValuesMapMessage * pMsg;
+} SYNCML_DM_SET_CHILD_VALUES_MAP_MESSAGE_T;
+
+
+typedef struct
+{
+ DMT_H_NODE hnode;
+ DMT_CallbackGetAttributes callback;
+ UINT32 messageID;
+ UINT32 pUserData;
+} SYNCML_DM_GET_ATTRIBUTES_MESSAGE_T;
+
+
+typedef struct
+{
+ DMT_H_NODE hnode;
+ DMT_CallbackGetValue callback;
+ UINT32 messageID;
+ UINT32 pUserData;
+} SYNCML_DM_GET_VALUE_MESSAGE_T;
+
+typedef struct
+{
+ DMSetValueMessage * pMsg;
+} SYNCML_DM_SET_VALUE_MESSAGE_T;
+
+typedef struct
+{
+ DMNodeMessage * pMsg;
+} SYNCML_DM_NODE_MESSAGE_T;
+
+
+typedef struct
+{
+ DMExecuteMessage * pMsg;
+} SYNCML_DM_EXECUTE_MESSAGE_T;
+
+#ifdef LOB_SUPPORT
+typedef struct
+{
+ DMT_H_NODE hnode;
+ DMT_DATACHUNK_T *datachunk;
+ DMT_CallbackDataChunk callback;
+ UINT32 messageID;
+ UINT32 pUserData;
+} SYNCML_DM_DATA_CHUNK_MESSAGE_T;
+#endif
+
+#endif
diff --git a/engine/dmlib/dmtapi/native_async/src/dmtAsyncAPI.cc b/engine/dmlib/dmtapi/native_async/src/dmtAsyncAPI.cc
new file mode 100644
index 0000000..2a7e4ef
--- /dev/null
+++ b/engine/dmlib/dmtapi/native_async/src/dmtAsyncAPI.cc
@@ -0,0 +1,2712 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*============================================================================
+
+ Header Name: dmtAsyncAPI.cc
+
+ General Description: This file contains implementation of the DMT async APIs
+
+==============================================================================*/
+
+#include "dmtAsyncMessage.h"
+#include "xpl_Message.h"
+#include "xpl_Time.h"
+#include "dmAsyncMessageID.h"
+#include "dm_tree_util.h"
+#include "dmt.hpp"
+#include "dmMemory.h"
+#include "xpl_Logger.h"
+
+static DMVector<PDmtTree> treeHandlerVector;
+static DMVector<PDmtNode> nodeHandlerVector;
+
+void dmtBuildCallbackData(DMT_DATA_T * pCallbackData, const DmtData & oDmtData)
+{
+ SYNCML_DM_DATAFORMAT_T format;
+ DMString & strData = (DMString&)oDmtData.GetStringValue();
+ DMVector<UINT8> & binData = (DMVector<UINT8>&)oDmtData.GetBinaryValue();
+
+ pCallbackData->meta_format = SYNCML_DM_DATAFORMAT_UNDEFINED;
+ format = oDmtData.GetType();
+ switch ( format )
+ {
+ case SYNCML_DM_DATAFORMAT_STRING:
+ case SYNCML_DM_DATAFORMAT_FLOAT:
+ case SYNCML_DM_DATAFORMAT_DATE:
+ case SYNCML_DM_DATAFORMAT_TIME:
+ pCallbackData->meta_format = format;
+ pCallbackData->data.str_value = strData.detach();
+ break;
+
+ case SYNCML_DM_DATAFORMAT_INT:
+ pCallbackData->meta_format = format;
+ oDmtData.GetInt(pCallbackData->data.int_value);
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BOOL:
+ pCallbackData->meta_format = format;
+ oDmtData.GetBoolean((BOOLEAN&)pCallbackData->data.int_value);
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BIN:
+ pCallbackData->meta_format = format;
+ pCallbackData->data.bin.bin_value = binData.get_data();
+ pCallbackData->data.bin.len_bin_data = binData.size();
+ binData.detach();
+ break;
+ }
+
+}
+
+
+void dmtBuildStatusStruct(DMT_CALLBACK_STRUCT_STATUS_T *pStruct,
+ UINT32 pUserData,
+ DMT_OPERATION_TYPE_T nCallbackType,
+ SYNCML_DM_RET_STATUS_T nStatusCode)
+{
+ pStruct->pUserData = (void*)pUserData;
+ pStruct->nCallbackType = nCallbackType;
+ pStruct->nStatusCode = nStatusCode;
+}
+
+
+void dmtSendStatusStruct(DMT_CALLBACK_STRUCT_STATUS_T *pStruct,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID)
+{
+ if ( callback )
+ callback(pStruct);
+ else
+ if ( messageID )
+ XPL_MSG_Send(XPL_PORT_DM,messageID,pStruct,sizeof(DMT_CALLBACK_STRUCT_STATUS_T));
+}
+
+
+
+INT32 dmtFindTreeHandler(DMT_H_TREE htree)
+{
+ INT32 size = treeHandlerVector.size();
+ for (INT32 index=0; index<size; index++)
+ {
+ PDmtTree & tree = treeHandlerVector[index];
+ if ( tree == (DmtTree*)htree )
+ return index;
+ }
+ return -1;
+}
+
+
+INT32 dmtFindNodeHandler(DMT_H_NODE hnode)
+{
+ INT32 size = nodeHandlerVector.size();
+ for (INT32 index=0; index<size; index++)
+ {
+ PDmtNode & node = nodeHandlerVector[index];
+ if ( node == (DmtNode*)hnode )
+ return index;
+ }
+ return -1;
+}
+
+DmtTree * dmtGetTreeHandler(DMT_H_TREE htree)
+{
+ if ( dmtFindTreeHandler(htree) == -1 )
+ return NULL;
+ else
+ return (DmtTree*)htree;
+}
+
+
+DmtNode * dmtGetNodeHandler(DMT_H_NODE hnode)
+{
+ if ( dmtFindNodeHandler(hnode) == -1 )
+ return NULL;
+ else
+ return (DmtNode*)hnode;
+}
+
+
+void dmtNotifyHandler(void *data)
+{
+ SYNCML_DM_NOTIFY_MESSAGE_T *pMessage = (SYNCML_DM_NOTIFY_MESSAGE_T *)data;
+
+ if ( pMessage->callback )
+ pMessage->callback();
+ else
+ if ( pMessage->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->messageID,NULL,0);
+}
+
+
+#ifdef DM_NO_LOCKING
+void dmtHandleTimer(void * data)
+{
+ SYNCML_DM_TIMER_MSG_T *pMessage = (SYNCML_DM_TIMER_MSG_T *)data;
+
+ //XPL_CLK_StopTimer(pMessage->timerHandle);
+ pMessage->callback();
+}
+#endif
+
+
+void dmtEngineHandler(SYNCML_DM_TASK_MESSAGE_ID operation, void *data)
+{
+ SYNCML_DM_ENGINE_MESSAGE_T *pMessage = (SYNCML_DM_ENGINE_MESSAGE_T *)data;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+ SYNCML_DM_RET_STATUS_T res;
+
+ treeHandlerVector.clear();
+ nodeHandlerVector.clear();
+
+ if ( operation == SYNCML_DM_INIT_MSG_ID )
+ res = DmtTreeFactory::Initialize();
+ else
+ res = DmtTreeFactory::Uninitialize();
+
+ dmtBuildStatusStruct(&statusStruct,pMessage->pUserData,operation,res);
+ dmtSendStatusStruct(&statusStruct,pMessage->callback,pMessage->messageID);
+}
+
+
+
+void dmtGetSubtreeExHandler(void * data)
+{
+
+ SYNCML_DM_GET_SUB_TREE_MESSAGE_T *pMessage = (SYNCML_DM_GET_SUB_TREE_MESSAGE_T *)data;
+ PDmtTree ptrTree;
+
+ DMT_CALLBACK_STRUCT_GETTREE_T treeStruct;
+
+ treeStruct.pUserData = (void*)pMessage->pMsg->pUserData;
+ treeStruct.htree = 0;
+
+ treeStruct.nStatusCode = DmtTreeFactory::GetSubtreeEx(pMessage->pMsg->principal,
+ pMessage->pMsg->subtreeRoot,
+ pMessage->pMsg->nLockType,
+ ptrTree);
+
+ if ( treeStruct.nStatusCode == SYNCML_DM_SUCCESS )
+ {
+ treeHandlerVector.push_back(ptrTree);
+ treeStruct.htree = (DMT_H_TREE)ptrTree.GetPtr();
+ }
+ if ( pMessage->pMsg->callback )
+ pMessage->pMsg->callback(&treeStruct);
+ else
+ if ( pMessage->pMsg->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->pMsg->messageID,&treeStruct,sizeof(DMT_CALLBACK_STRUCT_GETTREE_T));
+ delete pMessage->pMsg;
+
+}
+
+
+void dmtTreeReleaseHandler(void * data)
+{
+
+ SYNCML_DM_TREE_MESSAGE_T *pMessage = (SYNCML_DM_TREE_MESSAGE_T*)data;
+ INT32 pos;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+
+ pos = dmtFindTreeHandler(pMessage->htree);
+
+ if ( pos != -1 )
+ {
+ treeHandlerVector.remove(pos);
+ dmtBuildStatusStruct(&statusStruct,pMessage->pUserData,DMT_OPERATION_RELEASE_TREE,SYNCML_DM_SUCCESS);
+ }
+ else
+ dmtBuildStatusStruct(&statusStruct,pMessage->pUserData,DMT_OPERATION_RELEASE_TREE,SYNCML_DM_FAIL);
+
+ dmtSendStatusStruct(&statusStruct,pMessage->callback,pMessage->messageID);
+}
+
+
+
+void dmtProcessScriptHandler(void * data)
+{
+
+ SYNCML_DM_PROCESS_SCRIPT_MESSAGE_T *pMessage = (SYNCML_DM_PROCESS_SCRIPT_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_PROCESS_SCRIPT_T scriptStruct;
+ DMString oResult;
+
+ scriptStruct.nStatusCode = DmtTreeFactory::ProcessScript(pMessage->pMsg->principal,
+ pMessage->pMsg->buf.getBuffer(),
+ pMessage->pMsg->buf.getSize(),
+ pMessage->pMsg->isWBXML,
+ oResult);
+
+ scriptStruct.pUserData = (void*)pMessage->pMsg->pUserData;
+ scriptStruct.result_len = oResult.length();
+ scriptStruct.result = oResult.detach();
+
+ if ( pMessage->pMsg->callback )
+ {
+ pMessage->pMsg->callback(&scriptStruct);
+ DMT_Free_ProcessScriptStruct(&scriptStruct);
+ }
+ else
+ if ( pMessage->pMsg->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->pMsg->messageID,&scriptStruct,sizeof(DMT_CALLBACK_STRUCT_PROCESS_SCRIPT_T));
+ delete pMessage->pMsg;
+
+}
+
+
+
+void dmtBootstrapHandler(void * data)
+{
+
+ SYNCML_DM_BOOTSTRAP_MESSAGE_T *pMessage = (SYNCML_DM_BOOTSTRAP_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_BOOTSTRAP_T scriptStruct;
+ DMString serverID;
+
+ scriptStruct.nStatusCode = DmtTreeFactory::Bootstrap(pMessage->pMsg->principal,
+ pMessage->pMsg->buf.getBuffer(),
+ pMessage->pMsg->buf.getSize(),
+ pMessage->pMsg->isWBXML,
+ pMessage->pMsg->isProcess,
+ serverID);
+
+ scriptStruct.pUserData = (void*)pMessage->pMsg->pUserData;
+ scriptStruct.serverID = serverID.detach();
+ if ( pMessage->pMsg->callback )
+ {
+ pMessage->pMsg->callback(&scriptStruct);
+ DMT_Free_BootstrapStruct(&scriptStruct);
+ }
+ else
+ if ( pMessage->pMsg->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->pMsg->messageID,&scriptStruct,sizeof(DMT_CALLBACK_STRUCT_BOOTSTRAP_T));
+ delete pMessage->pMsg;
+
+}
+
+
+#ifdef DM_NOTIFICATION_AGENT
+void dmtProcessNotificationHandler(void * data)
+{
+
+ SYNCML_DM_PROCESS_NOTIFICATION_MESSAGE_T *pMessage = (SYNCML_DM_PROCESS_NOTIFICATION_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_PROCESS_NOTIFICATION_T notifStruct;
+ DmtNotification notification;
+
+ notifStruct.nStatusCode = DmtTreeFactory::ProcessNotification(pMessage->pMsg->principal,
+ pMessage->pMsg->buf.getBuffer(),
+ pMessage->pMsg->buf.getSize(),
+ notification);
+
+ notifStruct.pUserData = (void*)pMessage->pMsg->pUserData;
+
+ notifStruct.notification.uiMode = notification.getUIMode();
+ notifStruct.notification.initiator = notification.getInitiator();
+ notifStruct.notification.sessionID = notification.getSessionID();
+ notifStruct.notification.authFlag = notification.getAuthFlag();
+ DMString & serverID = (DMString&)notification.getServerID();
+
+ notifStruct.notification.serverID = serverID.detach();
+
+ if ( pMessage->pMsg->callback )
+ {
+ pMessage->pMsg->callback(&notifStruct);
+ DMT_Free_ProcessNotificationStruct(&notifStruct);
+ }
+ else
+ if ( pMessage->pMsg->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->pMsg->messageID,&notifStruct,sizeof(DMT_CALLBACK_STRUCT_PROCESS_NOTIFICATION_T));
+ delete pMessage->pMsg;
+
+}
+#endif
+
+void dmtStartServerSessionHandler(void * data)
+{
+ SYNCML_DM_START_SERVER_SESSION_MESSAGE_T *pMessage = (SYNCML_DM_START_SERVER_SESSION_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+ SYNCML_DM_RET_STATUS_T res;
+
+ res = DmtTreeFactory::StartServerSession(pMessage->pMsg->principal,pMessage->pMsg->sessionProp);
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,DMT_OPERATION_START_SRV_SESSION,res);
+ dmtSendStatusStruct(&statusStruct,pMessage->pMsg->callback,pMessage->pMsg->messageID);
+ delete pMessage->pMsg;
+}
+
+void dmtGetNodeHandler(void * data)
+{
+
+ SYNCML_DM_GET_NODE_MESSAGE_T *pMessage = (SYNCML_DM_GET_NODE_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_GETNODE_T nodeStruct;
+ DmtTree * pTree = dmtGetTreeHandler(pMessage->pMsg->htree);
+ PDmtNode ptrNode;
+
+ nodeStruct.hnode = 0;
+ nodeStruct.pUserData = (void*)pMessage->pMsg->pUserData;
+ if ( pTree == NULL )
+ nodeStruct.nStatusCode = SYNCML_DM_INVALID_PARAMETER;
+ else
+ {
+
+ nodeStruct.nStatusCode = pTree->GetNode(pMessage->pMsg->path, ptrNode);
+ if ( nodeStruct.nStatusCode == SYNCML_DM_SUCCESS )
+ {
+ nodeHandlerVector.push_back(ptrNode);
+ nodeStruct.hnode = (DMT_H_NODE)ptrNode.GetPtr();
+ nodeStruct.leaf_node = ptrNode->IsLeaf();
+ nodeStruct.external_storage_node = ptrNode->IsExternalStorageNode();
+ }
+ }
+ if ( pMessage->pMsg->callback )
+ pMessage->pMsg->callback(&nodeStruct);
+ else
+ if ( pMessage->pMsg->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->pMsg->messageID,&nodeStruct,sizeof(DMT_CALLBACK_STRUCT_GETNODE_T));
+ delete pMessage->pMsg;
+}
+
+void dmtNodeReleaseHandler(void * data)
+{
+ SYNCML_DM_NODE_MESSAGE_T *pMessage = (SYNCML_DM_NODE_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+ INT32 pos;
+
+ pos = dmtFindNodeHandler(pMessage->pMsg->hnode);
+ if ( pos != -1 )
+ {
+ nodeHandlerVector.remove(pos);
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,DMT_OPERATION_RELEASE_NODE,SYNCML_DM_SUCCESS);
+ }
+ else
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,DMT_OPERATION_RELEASE_NODE,SYNCML_DM_FAIL);
+
+ dmtSendStatusStruct(&statusStruct,pMessage->pMsg->callback,pMessage->pMsg->messageID);
+ delete pMessage->pMsg;
+
+}
+
+
+void dmtTreeNodeHandler(SYNCML_DM_TASK_MESSAGE_ID operation, void * data)
+{
+ SYNCML_DM_TREENODE_MESSAGE_T *pMessage = (SYNCML_DM_TREENODE_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+ DmtTree * pTree = dmtGetTreeHandler(pMessage->pMsg->htree);
+
+ if ( pTree == NULL )
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,operation,SYNCML_DM_INVALID_PARAMETER);
+ else
+ {
+ SYNCML_DM_RET_STATUS_T res;
+ switch ( operation )
+ {
+ case SYNCML_DM_DELETE_NODE_MSG_ID:
+ res = pTree->DeleteNode(pMessage->pMsg->path);
+ break;
+ case SYNCML_DM_RENAME_NODE_MSG_ID:
+ res = pTree->RenameNode(pMessage->pMsg->path,pMessage->pMsg->str);
+ break;
+ case SYNCML_DM_CREATE_INTERIOR_NODE_MSG_ID:
+ {
+ PDmtNode ptrNode;
+ res = pTree->CreateInteriorNode(pMessage->pMsg->path, ptrNode);
+ }
+ break;
+ }
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,operation,res);
+ }
+ dmtSendStatusStruct(&statusStruct,pMessage->pMsg->callback,pMessage->pMsg->messageID);
+ delete pMessage->pMsg;
+}
+
+
+
+void dmtCreateLeafNodeHandler(void * data)
+{
+
+ SYNCML_DM_CREATE_LEAF_NODE_MESSAGE_T *pMessage = (SYNCML_DM_CREATE_LEAF_NODE_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+
+ DmtTree * pTree = dmtGetTreeHandler(pMessage->pMsg->htree);
+
+ if ( pTree == NULL )
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,DMT_OPERATION_CREATEL_NODE,SYNCML_DM_INVALID_PARAMETER);
+ else
+ {
+
+ SYNCML_DM_RET_STATUS_T res;
+ PDmtNode ptrNode;
+
+ res = pTree->CreateLeafNode(pMessage->pMsg->path, ptrNode,pMessage->pMsg->data);
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,DMT_OPERATION_CREATEL_NODE,res);
+ }
+ dmtSendStatusStruct(&statusStruct,pMessage->pMsg->callback,pMessage->pMsg->messageID);
+ delete pMessage->pMsg;
+
+}
+
+
+void dmtGetChildNodeNamesHandler(void * data)
+{
+
+ SYNCML_DM_GET_CHILD_NODE_NAMES_MESSAGE_T *pMessage = (SYNCML_DM_GET_CHILD_NODE_NAMES_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_GET_CHILDNODE_NAMES_T nodeStruct;
+ DMStringVector mapNodes;
+
+ memset(&nodeStruct,0,sizeof(DMT_CALLBACK_STRUCT_GET_CHILDNODE_NAMES_T));
+ nodeStruct.pUserData = (void*)pMessage->pMsg->pUserData;
+
+
+ DmtTree * pTree = dmtGetTreeHandler(pMessage->pMsg->htree);
+
+ if ( pTree == NULL )
+ nodeStruct.nStatusCode = SYNCML_DM_INVALID_PARAMETER;
+ else
+ {
+
+ nodeStruct.nStatusCode = pTree->GetChildNodeNames(pMessage->pMsg->path, mapNodes);
+ if ( nodeStruct.nStatusCode == SYNCML_DM_SUCCESS )
+ {
+ INT32 size = mapNodes.size();
+ nodeStruct.ppChildren = (CPCHAR*)DmAllocMem(size*sizeof(CPCHAR));
+ if ( nodeStruct.ppChildren == NULL )
+ nodeStruct.nStatusCode = SYNCML_DM_DEVICE_FULL;
+ else
+ {
+ nodeStruct.num_children = size;
+ for (int index=0; index<size; index++)
+ {
+ DMString & str = mapNodes[index];
+ nodeStruct.ppChildren[index] = str.detach();
+ }
+ }
+ }
+ }
+ if ( pMessage->pMsg->callback )
+ {
+ pMessage->pMsg->callback(&nodeStruct);
+ DMT_Free_GetChildNodeNamesStruct(&nodeStruct);
+ }
+ else
+ if ( pMessage->pMsg->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->pMsg->messageID,&nodeStruct,sizeof(DMT_CALLBACK_STRUCT_GET_CHILDNODE_NAMES_T));
+ delete pMessage->pMsg;
+
+
+}
+
+
+void dmtTreeHandler(SYNCML_DM_TASK_MESSAGE_ID operation, void * data)
+{
+ SYNCML_DM_TREE_MESSAGE_T *pMessage = (SYNCML_DM_TREE_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+
+ DmtTree * pTree = dmtGetTreeHandler(pMessage->htree);
+
+ if ( pTree == NULL )
+ dmtBuildStatusStruct(&statusStruct,pMessage->pUserData,operation,SYNCML_DM_INVALID_PARAMETER);
+ else
+ {
+ SYNCML_DM_RET_STATUS_T res;
+ switch ( operation )
+ {
+ case SYNCML_DM_FLUSH_MSG_ID:
+ res = pTree->Flush();
+ break;
+
+ case SYNCML_DM_COMMIT_MSG_ID:
+ res = pTree->Commit();
+ break;
+
+ case SYNCML_DM_ROLLBACK_MSG_ID:
+ res = pTree->Rollback();
+ break;
+
+ case SYNCML_DM_BEGIN_MSG_ID:
+ res = pTree->Begin();
+ break;
+ }
+ dmtBuildStatusStruct(&statusStruct,pMessage->pUserData,operation,res);
+ }
+ dmtSendStatusStruct(&statusStruct,pMessage->callback,pMessage->messageID);
+
+}
+
+
+
+void dmtGetChildValuesMapHandler(void * data)
+{
+
+ SYNCML_DM_GET_CHILD_VALUES_MAP_MESSAGE_T *pMessage = (SYNCML_DM_GET_CHILD_VALUES_MAP_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_GET_CHILDVALUES_MAP_T nodeStruct;
+ DMMap<DMString, DmtData> mapNodes;
+
+
+ memset(&nodeStruct,0,sizeof(DMT_CALLBACK_STRUCT_GET_CHILDVALUES_MAP_T));
+ nodeStruct.pUserData = (void*)pMessage->pMsg->pUserData;
+
+ DmtTree * pTree = dmtGetTreeHandler(pMessage->pMsg->htree);
+
+ if ( pTree == NULL )
+ nodeStruct.nStatusCode = SYNCML_DM_INVALID_PARAMETER;
+ else
+ {
+ nodeStruct.nStatusCode = pTree->GetChildValuesMap(pMessage->pMsg->path, mapNodes);
+ if ( nodeStruct.nStatusCode == SYNCML_DM_SUCCESS )
+ {
+ BOOLEAN isMemFailed = FALSE;
+ INT32 size = mapNodes.size();
+
+ nodeStruct.data.ppChildren = (CPCHAR*)DmAllocMem(size*sizeof(CPCHAR));
+ if ( nodeStruct.data.ppChildren == NULL )
+ isMemFailed = TRUE;
+ else
+ {
+ nodeStruct.data.pData = (DMT_DATA_T*)DmAllocMem(size*sizeof(DMT_DATA_T));
+ if ( nodeStruct.data.pData == NULL )
+ isMemFailed = TRUE;
+ }
+
+ if ( isMemFailed == FALSE )
+ {
+ nodeStruct.data.num_children = mapNodes.size();
+ for (int POS=mapNodes.begin(); POS<mapNodes.end(); POS++)
+ {
+ nodeStruct.data.ppChildren[POS] = (CPCHAR)mapNodes.get_key(POS);
+ const DmtData & oData = mapNodes.get_value(POS);
+ dmtBuildCallbackData((DMT_DATA_T*)&nodeStruct.data.pData[POS], oData);
+ }
+
+ }
+ else
+ {
+ nodeStruct.nStatusCode = SYNCML_DM_DEVICE_FULL;
+ XPL_LOG_DM_API_Error(("dmtGetChildValuesMapHandler : unable allocate memory\n"));
+ }
+ }
+
+ }
+
+ if ( pMessage->pMsg->callback )
+ {
+ pMessage->pMsg->callback(&nodeStruct);
+ DMT_Free_GetChildValuesStruct(&nodeStruct);
+ }
+ else
+ if ( pMessage->pMsg->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->pMsg->messageID,&nodeStruct,sizeof(DMT_CALLBACK_STRUCT_GET_CHILDVALUES_MAP_T));
+ delete pMessage->pMsg;
+
+}
+
+
+void dmtSetChildValuesMapHandler(void * data)
+{
+
+ SYNCML_DM_SET_CHILD_VALUES_MAP_MESSAGE_T *pMessage = (SYNCML_DM_SET_CHILD_VALUES_MAP_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+ DmtTree * pTree = dmtGetTreeHandler(pMessage->pMsg->htree);
+
+ if ( pTree == NULL )
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,DMT_OPERATION_SET_CHILDVALUES_MAP,SYNCML_DM_INVALID_PARAMETER);
+ else
+ {
+
+ SYNCML_DM_RET_STATUS_T res;
+
+ res = pTree->SetChildValuesMap(pMessage->pMsg->path, pMessage->pMsg->data);
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,DMT_OPERATION_SET_CHILDVALUES_MAP,res);
+ }
+ dmtSendStatusStruct(&statusStruct,pMessage->pMsg->callback,pMessage->pMsg->messageID);
+ delete pMessage->pMsg;
+}
+
+
+
+
+void dmtGetAttributesHandler(void * data)
+{
+
+ SYNCML_DM_GET_ATTRIBUTES_MESSAGE_T *pMessage = (SYNCML_DM_GET_ATTRIBUTES_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_GET_ATTRIBUTES_T attrStruct;
+ DmtAttributes oAttr;
+
+ memset(&attrStruct,0,sizeof(DMT_CALLBACK_STRUCT_GET_ATTRIBUTES_T));
+ attrStruct.pUserData = (void*)pMessage->pUserData;
+
+ DmtNode * pNode = dmtGetNodeHandler(pMessage->hnode);
+
+ if ( pNode == NULL )
+ attrStruct.nStatusCode = SYNCML_DM_INVALID_PARAMETER;
+ else
+ {
+ attrStruct.nStatusCode = pNode->GetAttributes(oAttr);
+ if ( attrStruct.nStatusCode == SYNCML_DM_SUCCESS )
+ {
+ DMString aclStr;
+ DMString & name = (DMString&)oAttr.GetName();
+ DMString & format = (DMString&)oAttr.GetFormat();
+ DMString & title = (DMString&)oAttr.GetTitle();
+ DMString & type = (DMString&)oAttr.GetType();
+
+ attrStruct.attributes.name = name.detach();
+ attrStruct.attributes.format = format.detach();
+ attrStruct.attributes.title = title.detach();
+ attrStruct.attributes.type = type.detach();
+ const DmtAcl & oAcl = oAttr.GetAcl();
+ aclStr = oAcl.toString();
+ attrStruct.attributes.acl = aclStr.detach();
+ attrStruct.attributes.version = oAttr.GetVersion();
+ attrStruct.attributes.size = oAttr.GetSize();
+ attrStruct.attributes.timestamp = oAttr.GetTimestamp();
+ }
+ }
+
+ if ( pMessage->callback )
+ {
+ pMessage->callback(&attrStruct);
+ DMT_Free_GetAttributesStruct(&attrStruct);
+ }
+ else
+ if ( pMessage->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->messageID,&attrStruct,sizeof(DMT_CALLBACK_STRUCT_GET_ATTRIBUTES_T));
+
+}
+
+
+
+void dmtGetValueHandler(void * data)
+{
+
+ SYNCML_DM_GET_VALUE_MESSAGE_T *pMessage = (SYNCML_DM_GET_VALUE_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_GET_VALUE_T valueStruct;
+ static DmtData oData;
+
+ memset(&valueStruct,0,sizeof(DMT_CALLBACK_STRUCT_GET_VALUE_T));
+ valueStruct.pUserData = (void*)pMessage->pUserData;
+
+ DmtNode * pNode = dmtGetNodeHandler(pMessage->hnode);
+
+ if ( pNode == NULL )
+ valueStruct.nStatusCode = SYNCML_DM_INVALID_PARAMETER;
+ else
+ {
+
+ valueStruct.nStatusCode = pNode->GetValue(oData);
+ if ( valueStruct.nStatusCode == SYNCML_DM_SUCCESS )
+ dmtBuildCallbackData(&valueStruct.data, oData);
+ }
+
+ if ( pMessage->callback )
+ {
+ pMessage->callback(&valueStruct);
+ DMT_Free_GetValueStruct(&valueStruct);
+ }
+ else
+ if ( pMessage->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->messageID,&valueStruct,sizeof(DMT_CALLBACK_STRUCT_GET_VALUE_T));
+
+
+}
+
+void dmtSetValueHandler(void * data)
+{
+ SYNCML_DM_SET_VALUE_MESSAGE_T *pMessage = (SYNCML_DM_SET_VALUE_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+
+ DmtNode * pNode = dmtGetNodeHandler(pMessage->pMsg->hnode);
+
+ if ( pNode == NULL )
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,DMT_OPERATION_SET_VALUE,SYNCML_DM_INVALID_PARAMETER);
+ else
+ {
+ SYNCML_DM_RET_STATUS_T res;
+
+ res = pNode->SetValue(pMessage->pMsg->data);
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,DMT_OPERATION_SET_VALUE,res);
+ }
+ dmtSendStatusStruct(&statusStruct,pMessage->pMsg->callback,pMessage->pMsg->messageID);
+ delete pMessage->pMsg;
+
+}
+
+
+void dmtNodeHandler(SYNCML_DM_TASK_MESSAGE_ID operation, void * data)
+{
+ SYNCML_DM_NODE_MESSAGE_T *pMessage = (SYNCML_DM_NODE_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_STATUS_T statusStruct;
+
+ DmtNode * pNode = dmtGetNodeHandler(pMessage->pMsg->hnode);
+
+ if ( pNode == NULL )
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,operation,SYNCML_DM_INVALID_PARAMETER);
+ else
+ {
+ SYNCML_DM_RET_STATUS_T res;
+ switch ( operation )
+ {
+ case SYNCML_DM_SET_TITLE_MSG_ID:
+ res = pNode->SetTitle(pMessage->pMsg->str);
+ break;
+
+ case SYNCML_DM_SET_ACL_MSG_ID:
+ {
+ DmtAcl oAcl(pMessage->pMsg->str);
+ res = pNode->SetAcl(oAcl);
+ }
+ break;
+ }
+ dmtBuildStatusStruct(&statusStruct,pMessage->pMsg->pUserData,operation,res);
+ }
+ dmtSendStatusStruct(&statusStruct,pMessage->pMsg->callback,pMessage->pMsg->messageID);
+ delete pMessage->pMsg;
+}
+
+
+void dmtExecuteHandler(void * data)
+{
+ SYNCML_DM_EXECUTE_MESSAGE_T *pMessage = (SYNCML_DM_EXECUTE_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_EXECUTE_T execStruct;
+ DMString result;
+
+ execStruct.result = NULL;
+ execStruct.pUserData = (void*)pMessage->pMsg->pUserData;
+
+ DmtNode * pNode = dmtGetNodeHandler(pMessage->pMsg->hnode);
+
+ if ( pNode == NULL )
+ execStruct.nStatusCode = SYNCML_DM_INVALID_PARAMETER;
+ else
+ {
+ execStruct.nStatusCode = pNode->Execute(pMessage->pMsg->params,result);
+ if ( execStruct.nStatusCode == SYNCML_DM_SUCCESS )
+ execStruct.result = result.detach();
+ }
+
+ if ( pMessage->pMsg->callback )
+ {
+ pMessage->pMsg->callback(&execStruct);
+ DMT_Free_ExecuteStruct(&execStruct);
+ }
+ else
+ if ( pMessage->pMsg->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->pMsg->messageID,&execStruct,sizeof(DMT_CALLBACK_STRUCT_EXECUTE_T));
+ delete pMessage->pMsg;
+}
+
+#ifdef LOB_SUPPORT
+void dmtDataChunkHandler(void * data, UINT32 msgtype)
+{
+ SYNCML_DM_DATA_CHUNK_MESSAGE_T *pMessage = ( SYNCML_DM_DATA_CHUNK_MESSAGE_T*)data;
+ DMT_CALLBACK_STRUCT_DATA_CHUNK_T chunkStruct;
+
+ memset(&chunkStruct,0,sizeof(DMT_CALLBACK_STRUCT_DATA_CHUNK_T));
+ chunkStruct.pUserData = (void*)pMessage->pUserData;
+ chunkStruct.datachunk = pMessage->datachunk;
+ DmtNode * pNode = dmtGetNodeHandler(pMessage->hnode);
+
+ if ( pNode == NULL )
+ chunkStruct.nStatusCode = SYNCML_DM_INVALID_PARAMETER;
+ else
+ {
+ if(pMessage->datachunk != NULL && pMessage->datachunk->chunkBuffer != NULL )
+ {
+ DmtDataChunk chunkData;
+ chunkData.attach(pMessage->datachunk->chunkBuffer, pMessage->datachunk->dataSize);
+ switch ( msgtype )
+ {
+ case SYNCML_DM_GET_FIRST_CHUNK_MSG_ID:
+ chunkStruct.nStatusCode = pNode->GetFirstChunk(chunkData);
+ break;
+ case SYNCML_DM_GET_NEXT_CHUNK_MSG_ID:
+ chunkStruct.nStatusCode = pNode->GetNextChunk(chunkData);
+ break;
+ case SYNCML_DM_SET_FIRST_CHUNK_MSG_ID:
+ chunkStruct.nStatusCode = pNode->SetFirstChunk(chunkData);
+ break;
+
+ case SYNCML_DM_SET_NEXT_CHUNK_MSG_ID:
+ chunkStruct.nStatusCode = pNode->SetNextChunk(chunkData);
+ break;
+ case SYNCML_DM_SET_LAST_CHUNK_MSG_ID:
+ chunkStruct.nStatusCode = pNode->SetLastChunk(chunkData);
+ break;
+ }
+ if ( chunkStruct.nStatusCode == SYNCML_DM_SUCCESS )
+ {
+ UINT32 dataLen;
+ // Get return len
+ chunkStruct.nStatusCode = chunkData.GetReturnLen(dataLen);
+ if( chunkStruct.nStatusCode == SYNCML_DM_SUCCESS)
+ chunkStruct.datachunk->returnLen = dataLen;
+ }
+ chunkData.detach();
+ }
+ else
+ chunkStruct.nStatusCode = SYNCML_DM_INVALID_PARAMETER;
+ }
+ if ( pMessage->callback )
+ {
+ pMessage->callback(&chunkStruct);
+ }
+ else
+ if ( pMessage->messageID )
+ XPL_MSG_Send(XPL_PORT_DM,pMessage->messageID,&chunkStruct,sizeof(DMT_CALLBACK_STRUCT_DATA_CHUNK_T));
+}
+#endif
+
+void DMT_MessageHandler(UINT32 msgtype, void *data)
+{
+
+ if ( data == NULL )
+ return;
+
+ switch ( msgtype )
+ {
+ case SYNCML_DM_TIMER_MSG_ID:
+#ifdef DM_NO_LOCKING
+ dmtHandleTimer(data);
+#endif
+ break;
+
+
+ case SYNCML_DM_NOTIFY_ON_IDLE_MSG_ID:
+ dmtNotifyHandler(data);
+ break;
+
+ case SYNCML_DM_INIT_MSG_ID:
+ case SYNCML_DM_UNINIT_MSG_ID:
+ dmtEngineHandler(msgtype,data);
+ break;
+
+ case SYNCML_DM_GET_SUBTREE_MSG_ID:
+ dmtGetSubtreeExHandler(data);
+ break;
+
+ case SYNCML_DM_RELEASE_TREE_ID:
+ dmtTreeReleaseHandler(data);
+ break;
+
+ case SYNCML_DM_START_SERVER_SESSION_MSG_ID:
+ dmtStartServerSessionHandler(data);
+ break;
+
+ case SYNCML_DM_PROCESS_SCRIPT_MSG_ID:
+ dmtProcessScriptHandler(data);
+ break;
+
+ case SYNCML_DM_BOOTSTRAP_MSG_ID:
+ dmtBootstrapHandler(data);
+ break;
+
+#ifdef DM_NOTIFICATION_AGENT
+ case SYNCML_DM_PROCESS_NOTIFICATION_MSG_ID:
+ dmtProcessNotificationHandler(data);
+ break;
+#endif
+
+ case SYNCML_DM_GET_NODE_MSG_ID:
+ dmtGetNodeHandler(data);
+ break;
+
+ case SYNCML_DM_RELEASE_NODE_MSG_ID:
+ dmtNodeReleaseHandler(data);
+ break;
+
+ case SYNCML_DM_DELETE_NODE_MSG_ID:
+ case SYNCML_DM_RENAME_NODE_MSG_ID:
+ case SYNCML_DM_CREATE_INTERIOR_NODE_MSG_ID:
+ dmtTreeNodeHandler(msgtype,data);
+ break;
+
+ case SYNCML_DM_CREATE_LEAF_NODE_MSG_ID:
+ dmtCreateLeafNodeHandler(data);
+ break;
+
+ case SYNCML_DM_GET_CHULD_NODE_NAMES_MSG_ID:
+ dmtGetChildNodeNamesHandler(data);
+ break;
+
+ case SYNCML_DM_FLUSH_MSG_ID:
+ case SYNCML_DM_COMMIT_MSG_ID:
+ case SYNCML_DM_ROLLBACK_MSG_ID:
+ case SYNCML_DM_BEGIN_MSG_ID:
+ dmtTreeHandler(msgtype,data);
+ break;
+
+ case SYNCML_DM_GET_CHILD_VALUES_MAP_MSG_ID:
+ dmtGetChildValuesMapHandler(data);
+ break;
+
+ case SYNCML_DM_SET_CHILD_VALUES_MAP_MSG_ID:
+ dmtSetChildValuesMapHandler(data);
+ break;
+
+ case SYNCML_DM_GET_ATTRIBUTES_MSG_ID:
+ dmtGetAttributesHandler(data);
+ break;
+
+ case SYNCML_DM_GET_VALUE_MSG_ID:
+ dmtGetValueHandler(data);
+ break;
+
+ case SYNCML_DM_SET_VALUE_MSG_ID:
+ dmtSetValueHandler(data);
+ break;
+
+ case SYNCML_DM_SET_TITLE_MSG_ID:
+ case SYNCML_DM_SET_ACL_MSG_ID:
+ dmtNodeHandler(msgtype,data);
+ break;
+
+ case SYNCML_DM_EXECUTE_MSG_ID:
+ dmtExecuteHandler(data);
+ break;
+#ifdef LOB_SUPPORT
+ case SYNCML_DM_GET_FIRST_CHUNK_MSG_ID:
+ case SYNCML_DM_GET_NEXT_CHUNK_MSG_ID:
+ case SYNCML_DM_SET_FIRST_CHUNK_MSG_ID:
+ case SYNCML_DM_SET_NEXT_CHUNK_MSG_ID:
+ case SYNCML_DM_SET_LAST_CHUNK_MSG_ID:
+ dmtDataChunkHandler(data, msgtype);
+ break;
+#endif
+ }
+
+}
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+SYNCML_DM_RET_STATUS_T
+dmtNotifyOnIdle_Post(DMT_CallbackNotifyOnIdle callback,
+ void* pUserData,
+ UINT32 messageID)
+{
+
+ SYNCML_DM_NOTIFY_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+
+ message.callback = callback;
+ message.messageID = messageID;
+ message.pUserData = (UINT32)pUserData;
+
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_NOTIFY_ON_IDLE_MSG_ID,&message,sizeof(SYNCML_DM_NOTIFY_MESSAGE_T));
+ if ( res == XPL_MSG_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_FAIL;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+dmtEngine_Post(DMT_CallbackStatusCode callback,
+ void* pUserData,
+ UINT32 messageID,
+ UINT32 apiMessageID)
+{
+
+ SYNCML_DM_ENGINE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+
+ message.callback = callback;
+ message.messageID = messageID;
+ message.pUserData = (UINT32)pUserData;
+
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,apiMessageID,&message,sizeof(SYNCML_DM_ENGINE_MESSAGE_T));
+ if ( res == XPL_MSG_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_FAIL;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+dmtGetSubtreeEx_Post(CPCHAR szPrincipal,
+ CPCHAR szSubtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType,
+ DMT_CallbackGetTree callback,
+ void* pUserData,
+ UINT32 messageID )
+{
+
+ if ( szPrincipal == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_GET_SUB_TREE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMGetSubTreeMessage*) new DMGetSubTreeMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtGetSubtreeEx_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(szPrincipal, szSubtreeRoot, nLockType, callback,messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_GET_SUBTREE_MSG_ID,&message,sizeof( SYNCML_DM_GET_SUB_TREE_MESSAGE_T));
+
+ if ( res != XPL_MSG_RET_SUCCESS || status != SYNCML_DM_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ return status;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtTree_Post(DMT_H_TREE htree,
+ DMT_CallbackStatusCode callback,
+ void* pUserData,
+ UINT32 messageID,
+ UINT32 apiMessageID)
+{
+ if ( htree == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_TREE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+
+ message.htree = htree;
+ message.callback = callback;
+ message.messageID = messageID;
+ message.pUserData = (UINT32)pUserData;
+
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,apiMessageID,&message,sizeof(SYNCML_DM_TREE_MESSAGE_T));
+ if ( res == XPL_MSG_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_FAIL;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+dmtProcessScript_Post(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ DMT_CallbackProcessScript callback,
+ void* pUserData,
+ UINT32 messageID )
+{
+
+ if ( szPrincipal == 0 || buf == NULL || len == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_PROCESS_SCRIPT_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMProcessScriptMessage*)new DMProcessScriptMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtProcessScript_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(szPrincipal, buf, len, isWBXML, callback,messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_PROCESS_SCRIPT_MSG_ID,&message,sizeof(SYNCML_DM_PROCESS_SCRIPT_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+dmtStartServerSession_Post(CPCHAR szPrincipal,
+ const DMT_SESSION_PROP_T * pSessionProp,
+ DMT_CallbackStatusCode callback,
+ void* pUserData,
+ UINT32 messageID )
+{
+
+ if ( szPrincipal == 0 || pSessionProp == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_START_SERVER_SESSION_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMStartServerSessionMessage*)new DMStartServerSessionMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtStartServerSession_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(szPrincipal, pSessionProp, callback,messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_START_SERVER_SESSION_MSG_ID,&message,sizeof(SYNCML_DM_START_SERVER_SESSION_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtBootstrap_Post(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMT_CallbackBootstrap callback,
+ void* pUserData,
+ UINT32 messageID )
+{
+
+ if ( szPrincipal == 0 || buf == NULL || len == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_BOOTSTRAP_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMBootstrapMessage*)new DMBootstrapMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtExtractServerID_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(szPrincipal, buf, len, isWBXML, isProcess, callback,messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_BOOTSTRAP_MSG_ID,&message,sizeof(SYNCML_DM_BOOTSTRAP_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtProcessNotification_Post(CPCHAR szPrincipal,
+ const UINT8 *buf,
+ INT32 len,
+ DMT_CallbackProcessNotification callback,
+ void* pUserData,
+ UINT32 messageID )
+{
+
+#ifdef DM_NOTIFICATION_AGENT
+ if ( szPrincipal == 0 || buf == NULL || len == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_PROCESS_NOTIFICATION_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMProcessNotificationMessage*)new DMProcessNotificationMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtProcessNotification_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(szPrincipal, buf, len, callback, messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_PROCESS_NOTIFICATION_MSG_ID,&message,sizeof(SYNCML_DM_PROCESS_NOTIFICATION_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+#else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+#endif
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtGetNode_Post(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetNode callback,
+ void* pUserData, UINT32 messageID )
+{
+
+ if ( htree == 0 || path == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+
+ SYNCML_DM_GET_NODE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMGetNodeMessage*)new DMGetNodeMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtGetNode_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(htree, path, callback, messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_GET_NODE_MSG_ID,&message,sizeof(SYNCML_DM_GET_NODE_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtTreeNode_Post(DMT_H_TREE htree,
+ CPCHAR path,
+ CPCHAR str,
+ DMT_CallbackStatusCode callback,
+ void* pUserData,
+ UINT32 messageID,
+ UINT32 apiMessageID)
+{
+ if ( htree == 0 || path == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_TREENODE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMTreeNodeMessage*)new DMTreeNodeMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtDeleteNode_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(htree, path,str,callback,messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,apiMessageID,&message,sizeof(SYNCML_DM_TREENODE_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtRenameNode_Post(DMT_H_TREE htree,
+ CPCHAR path,
+ CPCHAR new_node_name,
+ DMT_CallbackStatusCode callback,
+ void* pUserData,
+ UINT32 messageID )
+{
+ if ( new_node_name == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtTreeNode_Post(htree, path, new_node_name, callback, pUserData, messageID,SYNCML_DM_RENAME_NODE_MSG_ID);
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+dmtCreateLeafNode_Post(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ void* pUserData,
+ UINT32 messageID )
+{
+
+ if ( htree == 0 || path == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ if ( data && data->meta_format == SYNCML_DM_DATAFORMAT_NODE )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_CREATE_LEAF_NODE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMCreateLeafNodeMessage*)new DMCreateLeafNodeMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtCreateLeafNode_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(htree, path, data, callback,messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_CREATE_LEAF_NODE_MSG_ID,&message,sizeof(SYNCML_DM_CREATE_LEAF_NODE_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtGetChildNodeNames_Post(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildNodeNames callback,
+ void* pUserData,
+ UINT32 messageID)
+{
+
+ if ( htree == 0 || path == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+
+ SYNCML_DM_GET_CHILD_NODE_NAMES_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMGetChildNodeNamesMessage*)new DMGetChildNodeNamesMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtGetChildNodeNames_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(htree, path, callback,messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_GET_CHULD_NODE_NAMES_MSG_ID,&message,sizeof(SYNCML_DM_GET_CHILD_NODE_NAMES_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+
+
+SYNCML_DM_RET_STATUS_T
+dmtGetChildValuesMap_Post(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildValuesMap callback,
+ void* pUserData,
+ UINT32 messageID)
+{
+ if ( htree == 0 || path == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_GET_CHILD_VALUES_MAP_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMGetChildValuesMapMessage*)new DMGetChildValuesMapMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtGetChildValuesMap_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(htree, path, callback, messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_GET_CHILD_VALUES_MAP_MSG_ID,&message,sizeof(SYNCML_DM_GET_CHILD_VALUES_MAP_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtSetChildValuesMap_Post(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_LEAF_CHILDREN_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ void* pUserData, UINT32 messageID)
+{
+ if ( htree == 0 || path == NULL || data == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ if ( data->ppChildren == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_SET_CHILD_VALUES_MAP_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMSetChildValuesMapMessage*)new DMSetChildValuesMapMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtSetChildValuesMap_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(htree, path, data, callback, messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_SET_CHILD_VALUES_MAP_MSG_ID,&message,sizeof(SYNCML_DM_SET_CHILD_VALUES_MAP_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+dmtGetAttributes_Post(DMT_H_NODE hnode,
+ DMT_CallbackGetAttributes callback,
+ void* pUserData, UINT32 messageID)
+{
+ if ( hnode == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_GET_ATTRIBUTES_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+
+ message.hnode = hnode;
+ message.callback = callback;
+ message.messageID = messageID;
+ message.pUserData = (UINT32)pUserData;
+
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_GET_ATTRIBUTES_MSG_ID,&message,sizeof(SYNCML_DM_GET_ATTRIBUTES_MESSAGE_T));
+ if ( res == XPL_MSG_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_FAIL;
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+dmtGetValue_Post(DMT_H_NODE hnode,
+ DMT_CallbackGetValue callback,
+ void* pUserData, UINT32 messageID)
+{
+ if ( hnode == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+
+ SYNCML_DM_GET_VALUE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+
+ message.hnode = hnode;
+ message.callback = callback;
+ message.messageID = messageID;
+ message.pUserData = (UINT32)pUserData;
+
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_GET_VALUE_MSG_ID,&message,sizeof(SYNCML_DM_GET_VALUE_MESSAGE_T));
+ if ( res == XPL_MSG_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_FAIL;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtSetValue_Post(DMT_H_NODE hnode,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ void* pUserData, UINT32 messageID)
+{
+ if ( hnode == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+
+ SYNCML_DM_SET_VALUE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMSetValueMessage*)new DMSetValueMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtSetValue_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(hnode, data, callback, messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_SET_VALUE_MSG_ID,&message,sizeof(SYNCML_DM_SET_VALUE_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtNode_Post(DMT_H_NODE hnode,
+ CPCHAR str,
+ DMT_CallbackStatusCode callback,
+ void* pUserData,
+ UINT32 messageID,
+ UINT32 apiMessageID)
+{
+ if ( hnode == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_NODE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMNodeMessage*)new DMNodeMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtNode_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(hnode, str, callback,messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,apiMessageID,&message,sizeof(SYNCML_DM_NODE_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtNodeRelease_Post(DMT_H_NODE hnode,
+ DMT_CallbackStatusCode callback,
+ void* pUserData,
+ UINT32 messageID,
+ UINT32 apiMessageID)
+{
+ return dmtNode_Post(hnode,NULL,callback,pUserData,messageID,apiMessageID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+dmtExecute_Post(DMT_H_NODE hnode,
+ CPCHAR params,
+ DMT_CallbackExecute callback,
+ void* pUserData, UINT32 messageID)
+{
+ if ( hnode == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ SYNCML_DM_EXECUTE_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+ SYNCML_DM_RET_STATUS_T status;
+
+ message.pMsg = (DMExecuteMessage*)new DMExecuteMessage();
+ if ( message.pMsg == NULL )
+ {
+ XPL_LOG_DM_API_Error(("dmtExecute_Post : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ status = message.pMsg->set(hnode, params, callback,messageID,(UINT32)pUserData);
+
+ if ( status == SYNCML_DM_SUCCESS )
+ {
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,SYNCML_DM_EXECUTE_MSG_ID,&message,sizeof(SYNCML_DM_EXECUTE_MESSAGE_T));
+ if ( res != XPL_MSG_RET_SUCCESS )
+ {
+ delete message.pMsg;
+ return SYNCML_DM_FAIL;
+ }
+ }
+ return status;
+
+}
+#ifdef LOB_SUPPORT
+SYNCML_DM_RET_STATUS_T
+dmtDataChunk_Post(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData, UINT32 messageID,UINT32 msgtype)
+{
+ if ( hnode == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+
+ SYNCML_DM_DATA_CHUNK_MESSAGE_T message;
+ XPL_MSG_RET_STATUS_T res;
+
+ message.hnode = hnode;
+ message.datachunk = datachunk;
+ message.callback = callback;
+ message.messageID = messageID;
+ message.pUserData = (UINT32)pUserData;
+
+ res = XPL_MSG_Send(XPL_PORT_DM_TASK,msgtype, &message,sizeof(SYNCML_DM_DATA_CHUNK_MESSAGE_T));
+ if ( res == XPL_MSG_RET_SUCCESS )
+ return SYNCML_DM_SUCCESS;
+ else
+ return SYNCML_DM_FAIL;
+}
+SYNCML_DM_RET_STATUS_T
+dmtGetFirstChunk_Post(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData, UINT32 messageID)
+{
+ return dmtDataChunk_Post(hnode, datachunk,callback, pUserData, messageID, SYNCML_DM_GET_FIRST_CHUNK_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+dmtGetNextChunk_Post(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData, UINT32 messageID)
+{
+ return dmtDataChunk_Post(hnode, datachunk,callback, pUserData, messageID, SYNCML_DM_GET_NEXT_CHUNK_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+dmtSetFirstChunk_Post(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData, UINT32 messageID)
+{
+ return dmtDataChunk_Post(hnode, datachunk,callback, pUserData, messageID, SYNCML_DM_SET_FIRST_CHUNK_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+dmtSetNextChunk_Post(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData, UINT32 messageID)
+{
+ return dmtDataChunk_Post(hnode, datachunk,callback, pUserData, messageID, SYNCML_DM_SET_NEXT_CHUNK_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+dmtSetLastChunk_Post(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData, UINT32 messageID)
+{
+ return dmtDataChunk_Post(hnode, datachunk,callback, pUserData, messageID, SYNCML_DM_SET_LAST_CHUNK_MSG_ID);
+}
+#endif
+
+SYNCML_DM_ACL_PERMISSIONS_T
+DMT_AclGetPermissions(CPCHAR acl,CPCHAR principal )
+{
+ if ( acl == NULL || principal == NULL )
+ return 0;
+
+ DmtAcl oAcl(acl);
+
+ return oAcl.GetPermissions(DmtPrincipal(principal));
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_AclSetPermissions(char* acl,
+ INT32 * buf_len,
+ CPCHAR principal,
+ SYNCML_DM_ACL_PERMISSIONS_T permissions )
+{
+ if ( buf_len == NULL || acl == NULL || principal == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ if ( *buf_len == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ DmtAcl oAcl(acl);
+ DMString result;
+ oAcl.SetPermission(DmtPrincipal(principal),permissions);
+
+ result = oAcl.toString();
+ if ( result == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ INT32 len = result.length();
+ if ( len < *buf_len )
+ {
+ DmStrcpy(acl,result.c_str());
+ return SYNCML_DM_SUCCESS;
+ }
+ else
+ {
+ *buf_len = len;
+ return SYNCML_DM_FAIL;
+ }
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_NotifyOnIdle(DMT_CallbackNotifyOnIdle callback, void* pUserData )
+{
+
+ return dmtNotifyOnIdle_Post(callback, pUserData, 0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Init(DMT_CallbackStatusCode callback, void* pUserData )
+{
+ return dmtEngine_Post(callback, pUserData, 0,SYNCML_DM_INIT_MSG_ID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_Uninit(DMT_CallbackStatusCode callback, void* pUserData)
+{
+ return dmtEngine_Post(callback, pUserData, 0,SYNCML_DM_UNINIT_MSG_ID);
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetTree(CPCHAR szPrincipal,
+ DMT_CallbackGetTree callback,
+ void* pUserData )
+{
+ return DMT_GetSubtree(szPrincipal,NULL,callback,pUserData);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetSubtree(CPCHAR szPrincipal,
+ CPCHAR szSubtreeRoot,
+ DMT_CallbackGetTree callback,
+ void* pUserData )
+{
+
+ return DMT_GetSubtreeEx(szPrincipal,szSubtreeRoot,SYNCML_DM_LOCK_TYPE_AUTOMATIC,callback,pUserData);
+
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetSubtreeEx(CPCHAR szPrincipal,
+ CPCHAR szSubtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType,
+ DMT_CallbackGetTree callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtGetSubtreeEx_Post(szPrincipal,szSubtreeRoot,nLockType,callback,pUserData,0);
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_TreeRelease(DMT_H_TREE htree,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtTree_Post(htree,callback,pUserData,0,SYNCML_DM_RELEASE_TREE_ID);
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_ProcessScript(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ DMT_CallbackProcessScript callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtProcessScript_Post(szPrincipal,buf,len,isWBXML,callback,pUserData,0);
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_StartServerSession(CPCHAR szPrincipal,
+ const DMT_SESSION_PROP_T * pSessionProp,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtStartServerSession_Post(szPrincipal,pSessionProp,callback,pUserData,0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Bootstrap(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMT_CallbackBootstrap callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtBootstrap_Post(szPrincipal,buf,len,isWBXML,isProcess,callback,pUserData,0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_ProcessNotification(CPCHAR szPrincipal,
+ const UINT8 *buf,
+ INT32 len,
+ DMT_CallbackProcessNotification callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtProcessNotification_Post(szPrincipal,buf,len,callback,pUserData,0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetNode(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetNode callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtGetNode_Post(htree,path,callback,pUserData,0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_NodeRelease(DMT_H_NODE hnode,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtNodeRelease_Post(hnode,callback,pUserData,0,SYNCML_DM_RELEASE_NODE_MSG_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_DeleteNode(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtTreeNode_Post(htree,path,NULL,callback,pUserData,0,SYNCML_DM_DELETE_NODE_MSG_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_RenameNode(DMT_H_TREE htree,
+ CPCHAR path,
+ CPCHAR new_node_name,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtRenameNode_Post(htree,path,new_node_name,callback,pUserData,0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_CreateInteriorNode(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtTreeNode_Post(htree,path,NULL,callback,pUserData,0,SYNCML_DM_CREATE_INTERIOR_NODE_MSG_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_CreateLeafNode(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtCreateLeafNode_Post(htree,path,data,callback,pUserData,0);
+
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetChildNodeNames(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildNodeNames callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtGetChildNodeNames_Post(htree,path,callback,pUserData,0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Flush(DMT_H_TREE htree, DMT_CallbackStatusCode callback, void* pUserData )
+{
+ return dmtTree_Post(htree,callback,pUserData,0,SYNCML_DM_FLUSH_MSG_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Commit(DMT_H_TREE htree, DMT_CallbackStatusCode callback, void* pUserData )
+{
+ return dmtTree_Post(htree,callback,pUserData,0,SYNCML_DM_COMMIT_MSG_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Rollback(DMT_H_TREE htree, DMT_CallbackStatusCode callback, void* pUserData )
+{
+ return dmtTree_Post(htree,callback,pUserData,0,SYNCML_DM_ROLLBACK_MSG_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Begin(DMT_H_TREE htree, DMT_CallbackStatusCode callback, void* pUserData )
+{
+ return dmtTree_Post(htree,callback,pUserData,0,SYNCML_DM_BEGIN_MSG_ID);
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetChildValuesMap(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildValuesMap callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtGetChildValuesMap_Post(htree,path,callback,pUserData,0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetChildValuesMap(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_LEAF_CHILDREN_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtSetChildValuesMap_Post(htree,path,data,callback,pUserData,0);
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetAttributes(DMT_H_NODE hnode,
+ DMT_CallbackGetAttributes callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtGetAttributes_Post(hnode,callback,pUserData,0);
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetValue(DMT_H_NODE hnode,
+ DMT_CallbackGetValue callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtGetValue_Post(hnode,callback,pUserData,0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetValue(DMT_H_NODE hnode,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtSetValue_Post(hnode,data,callback,pUserData,0);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetTitle(DMT_H_NODE hnode,
+ CPCHAR title,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtNode_Post(hnode,title,callback,pUserData,0,SYNCML_DM_SET_TITLE_MSG_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetACL(DMT_H_NODE hnode,
+ CPCHAR acl,
+ DMT_CallbackStatusCode callback,
+ void* pUserData )
+{
+ return dmtNode_Post(hnode,acl,callback,pUserData,0,SYNCML_DM_SET_ACL_MSG_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Execute(DMT_H_NODE hnode,
+ CPCHAR params,
+ DMT_CallbackExecute callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtExecute_Post(hnode,params,callback,pUserData,0);
+}
+#ifdef LOB_SUPPORT
+SYNCML_DM_RET_STATUS_T
+DMT_GetFirstChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtGetFirstChunk_Post(hnode, datachunk, callback,pUserData,0);
+}
+SYNCML_DM_RET_STATUS_T
+DMT_GetNextChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtGetNextChunk_Post(hnode, datachunk, callback,pUserData,0);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetFirstChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtSetFirstChunk_Post(hnode, datachunk, callback,pUserData,0);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetNextChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtSetNextChunk_Post(hnode, datachunk ,callback,pUserData,0);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetLastChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ if ( callback == NULL )
+ return SYNCML_DM_INVALID_PARAMETER;
+ return dmtSetLastChunk_Post(hnode, datachunk, callback,pUserData,0);
+}
+
+INT32 DMT_GetChunkSize()
+{
+ return DmtDataChunk::GetChunkSize();
+}
+#else
+SYNCML_DM_RET_STATUS_T
+DMT_GetFirstChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+SYNCML_DM_RET_STATUS_T
+DMT_GetNextChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetFirstChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetNextChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetLastChunk(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ DMT_CallbackDataChunk callback,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+INT32 DMT_GetChunkSize()
+{
+ return 0;
+}
+#endif
+
+SYNCML_DM_RET_STATUS_T
+DMT_NotifyOnIdle_Msg(UINT32 messageID, void* pUserData )
+{
+
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtNotifyOnIdle_Post(NULL, pUserData, messageID);
+}
+
+
+/* Async APIs used message posting instead of callback */
+SYNCML_DM_RET_STATUS_T
+DMT_Init_Msg(UINT32 messageID, void* pUserData)
+{
+
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtEngine_Post(NULL, pUserData, messageID,SYNCML_DM_INIT_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_Uninit_Msg(UINT32 messageID, void* pUserData)
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtEngine_Post(NULL, pUserData, messageID,SYNCML_DM_UNINIT_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetTree_Msg(CPCHAR szPrincipal,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return DMT_GetSubtree_Msg(szPrincipal,NULL,messageID,pUserData);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetSubtree_Msg(CPCHAR szPrincipal,
+ CPCHAR szSubtreeRoot,
+ UINT32 messageID,
+ void* pUserData )
+{
+
+ return DMT_GetSubtreeEx_Msg(szPrincipal,szSubtreeRoot,SYNCML_DM_LOCK_TYPE_AUTOMATIC,messageID,pUserData);
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetSubtreeEx_Msg(CPCHAR szPrincipal,
+ CPCHAR szSubtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtGetSubtreeEx_Post(szPrincipal,szSubtreeRoot,nLockType,NULL,pUserData,messageID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_TreeRelease_Msg(DMT_H_TREE htree,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtTree_Post(htree,NULL,pUserData,messageID,SYNCML_DM_RELEASE_TREE_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_ProcessScript_Msg(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ UINT32 messageID,
+ void* pUserData )
+{
+
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtProcessScript_Post(szPrincipal,buf,len,isWBXML,NULL,pUserData,messageID);
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_StartServerSession_Msg(CPCHAR szPrincipal,
+ const DMT_SESSION_PROP_T * pSessionProp,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtStartServerSession_Post(szPrincipal,pSessionProp,NULL,pUserData,messageID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_ProcessNotification_Msg(CPCHAR szPrincipal,
+ const UINT8 *buf,
+ INT32 len,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtProcessNotification_Post(szPrincipal,buf,len,NULL,pUserData,messageID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_Bootstrap_Msg(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtBootstrap_Post(szPrincipal,buf,len,isWBXML,isProcess, NULL,pUserData,messageID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtGetNode_Post(htree,path,NULL,pUserData,messageID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_NodeRelease_Msg(DMT_H_NODE hnode,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtNodeRelease_Post(hnode,NULL,pUserData,messageID,SYNCML_DM_RELEASE_NODE_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_DeleteNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtTreeNode_Post(htree,path,NULL,NULL,pUserData,messageID,SYNCML_DM_DELETE_NODE_MSG_ID);
+
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_RenameNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ CPCHAR new_node_name,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtRenameNode_Post(htree,path,new_node_name,NULL,pUserData,messageID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_CreateInteriorNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtTreeNode_Post(htree,path,NULL,NULL,pUserData,messageID,SYNCML_DM_CREATE_INTERIOR_NODE_MSG_ID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_CreateLeafNode_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_DATA_T* data,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtCreateLeafNode_Post(htree,path,data,NULL,pUserData,messageID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetChildNodeNames_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtGetChildNodeNames_Post(htree,path,NULL,pUserData,messageID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_Flush_Msg(DMT_H_TREE htree, UINT32 messageID, void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtTree_Post(htree,NULL,pUserData,messageID,SYNCML_DM_FLUSH_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_Commit_Msg(DMT_H_TREE htree, UINT32 messageID, void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtTree_Post(htree,NULL,pUserData,messageID,SYNCML_DM_COMMIT_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_Rollback_Msg(DMT_H_TREE htree, UINT32 messageID, void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtTree_Post(htree,NULL,pUserData,messageID,SYNCML_DM_ROLLBACK_MSG_ID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_Begin_Msg(DMT_H_TREE htree, UINT32 messageID, void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtTree_Post(htree,NULL,pUserData,messageID,SYNCML_DM_BEGIN_MSG_ID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetChildValuesMap_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtGetChildValuesMap_Post(htree,path,NULL,pUserData,messageID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetChildValuesMap_Msg(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_LEAF_CHILDREN_DATA_T* data,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtSetChildValuesMap_Post(htree,path,data,NULL,pUserData,messageID);
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetAttributes_Msg(DMT_H_NODE hnode, UINT32 messageID, void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtGetAttributes_Post(hnode,NULL,pUserData,messageID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetValue_Msg(DMT_H_NODE hnode, UINT32 messageID, void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtGetValue_Post(hnode,NULL,pUserData,messageID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetValue_Msg(DMT_H_NODE hnode,
+ const DMT_DATA_T* data,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtSetValue_Post(hnode,data,NULL,pUserData,messageID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetTitle_Msg(DMT_H_NODE hnode,
+ CPCHAR title,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtNode_Post(hnode,title,NULL,pUserData,messageID,SYNCML_DM_SET_TITLE_MSG_ID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetACL_Msg(DMT_H_NODE hnode,
+ CPCHAR acl,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtNode_Post(hnode,acl,NULL,pUserData,messageID,SYNCML_DM_SET_ACL_MSG_ID);
+
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_Execute_Msg(DMT_H_NODE hnode,
+ CPCHAR params,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtExecute_Post(hnode,params,NULL,pUserData,messageID);
+}
+
+#ifdef LOB_SUPPORT
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetFirstChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtGetFirstChunk_Post(hnode, datachunk, NULL,pUserData,messageID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetNextChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtGetNextChunk_Post(hnode, datachunk, NULL,pUserData,messageID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetFirstChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtSetFirstChunk_Post(hnode, datachunk, NULL,pUserData,messageID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetNextChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtSetNextChunk_Post(hnode, datachunk, NULL,pUserData,messageID);
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetLastChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ if ( messageID == 0 )
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ return dmtSetLastChunk_Post(hnode, datachunk, NULL,pUserData,messageID);
+}
+
+#else // LOB_SUPPORT
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetFirstChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_GetNextChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetFirstChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetNextChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMT_SetLastChunk_Msg(DMT_H_NODE hnode,
+ DMT_DATACHUNK_T *datachunk,
+ UINT32 messageID,
+ void* pUserData )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+#endif // LOB_SUPPORT
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/dmtapi/native_async/src/dmtAsyncData.cc b/engine/dmlib/dmtapi/native_async/src/dmtAsyncData.cc
new file mode 100644
index 0000000..7616540
--- /dev/null
+++ b/engine/dmlib/dmtapi/native_async/src/dmtAsyncData.cc
@@ -0,0 +1,577 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dmtAsyncData.h"
+#include "dm_tree_util.h"
+#include "dmt.hpp"
+#include "dmMemory.h"
+#include "xpl_Logger.h"
+
+static SYNCML_DM_RET_STATUS_T dmtBuildData(const DMT_DATA_T * pData, DmtData & oDmtData)
+{
+
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+ if ( pData == NULL )
+ {
+ oDmtData = DmtData();
+ }
+ else
+ switch ( pData->meta_format )
+ {
+ case SYNCML_DM_DATAFORMAT_STRING:
+ case SYNCML_DM_DATAFORMAT_FLOAT:
+ case SYNCML_DM_DATAFORMAT_TIME:
+ case SYNCML_DM_DATAFORMAT_DATE:
+ res = oDmtData.SetString(pData->data.str_value, pData->meta_format);
+ break;
+
+ case SYNCML_DM_DATAFORMAT_INT:
+ res = oDmtData.SetInt(pData->data.int_value);
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BOOL:
+ res = oDmtData.SetBoolean((BOOLEAN)pData->data.int_value);
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BIN:
+ res = oDmtData.SetBinary(pData->data.bin.bin_value,pData->data.bin.len_bin_data);
+ break;
+
+ default:
+ oDmtData = DmtData();
+ break;
+ }
+ return res;
+
+}
+
+
+static SYNCML_DM_RET_STATUS_T dmtBuildMap(const DMT_LEAF_CHILDREN_DATA_T* pData, DMMap<DMString, DmtData> & oMapNodes)
+{
+ SYNCML_DM_RET_STATUS_T res = SYNCML_DM_SUCCESS;
+
+ if ( pData )
+ {
+ for (int index = 0; index<pData->num_children; index++)
+ {
+ DmtData oData;
+ res = dmtBuildData((DMT_DATA_T*)&pData->pData[index],oData);
+ if ( res == SYNCML_DM_SUCCESS )
+ oMapNodes.put(DMString(pData->ppChildren[index]),oData);
+ else
+ break;
+ }
+ }
+ else
+ return SYNCML_DM_FAIL;
+
+ return res;
+}
+
+
+
+static void dmtFreeCharPtr(CPCHAR str)
+{
+ char * ptr = (char*)str;
+ if ( ptr )
+ DmFreeMem(ptr);
+}
+
+
+static void dmtFreeBytePtr(const UINT8 * byte)
+{
+ UINT8 * ptr = (UINT8*)byte;
+ if ( ptr )
+ DmFreeMem(ptr);
+}
+
+static void dmtFreeDataStruct(DMT_DATA_T * pData)
+{
+ if ( pData == NULL )
+ return;
+
+ switch ( pData->meta_format )
+ {
+ case SYNCML_DM_DATAFORMAT_STRING:
+ case SYNCML_DM_DATAFORMAT_FLOAT:
+ case SYNCML_DM_DATAFORMAT_TIME:
+ case SYNCML_DM_DATAFORMAT_DATE:
+ dmtFreeCharPtr(pData->data.str_value);
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BIN:
+ dmtFreeBytePtr(pData->data.bin.bin_value);
+ break;
+ }
+ memset(pData,0,sizeof(DMT_DATA_T));
+}
+
+
+SYNCML_DM_RET_STATUS_T DMPrincipalMessage::set(CPCHAR szPrincipal,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ DMAsyncMessage::set(messageID,pUserData);
+ principal.assign(szPrincipal);
+ if ( principal.getName() == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T DMGetSubTreeMessage::set(CPCHAR szPrincipal,
+ CPCHAR subtreeRoot,
+ SYNCML_DM_TREE_LOCK_TYPE_T nLockType,
+ DMT_CallbackGetTree callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ SYNCML_DM_RET_STATUS_T res;
+ res = DMPrincipalMessage::set(szPrincipal,messageID,pUserData);
+ if ( res == SYNCML_DM_SUCCESS )
+ {
+ if ( subtreeRoot )
+ {
+ this->subtreeRoot = subtreeRoot;
+ if ( subtreeRoot[0] && this->subtreeRoot == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ }
+ this->nLockType = nLockType;
+ this->callback = callback;
+ return res;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T DMScriptMessage::set(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ SYNCML_DM_RET_STATUS_T res;
+ res = DMPrincipalMessage::set(szPrincipal,messageID,pUserData);
+ if ( res == SYNCML_DM_SUCCESS )
+ {
+ this->buf.assign(buf,len);
+ if ( this->buf.getBuffer() == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ this->isWBXML = isWBXML;
+ return res;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMProcessScriptMessage::set(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ DMT_CallbackProcessScript callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ this->callback = callback;
+ return DMScriptMessage::set(szPrincipal,buf,len,isWBXML,messageID,pUserData);
+}
+
+
+SYNCML_DM_RET_STATUS_T DMBootstrapMessage::set(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ BOOLEAN isWBXML,
+ BOOLEAN isProcess,
+ DMT_CallbackBootstrap callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ this->callback = callback;
+ this->isProcess = isProcess;
+ return DMScriptMessage::set(szPrincipal,buf,len,isWBXML,messageID,pUserData);
+}
+
+
+
+SYNCML_DM_RET_STATUS_T DMStartServerSessionMessage::set(CPCHAR szPrincipal,
+ const DMT_SESSION_PROP_T * pSessionProp,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ sessionProp.setWBXML(pSessionProp->isWBXML);
+
+ if ( pSessionProp->direction == SYNCML_DM_SERVER_INITIATED_SESSION )
+ sessionProp.setSessionID(pSessionProp->sessionID);
+ if ( pSessionProp->num_alerts )
+ {
+ if ( !pSessionProp->alerts )
+ return SYNCML_DM_INVALID_PARAMETER;
+ for (INT32 i=0; i<pSessionProp->num_alerts; i++)
+ {
+ DmtFirmAlert alert;
+ SYNCML_DM_RET_STATUS_T res;
+ INT32 count;
+
+ res = alert.setAlertType(((pSessionProp->alerts)+i)->strAlertType);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ res = alert.setAlertFormat(((pSessionProp->alerts)+i)->strAlertFormat);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ res = alert.setAlertMark(((pSessionProp->alerts)+i)->strAlertMark);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ res = alert.setResultData(((pSessionProp->alerts)+i)->strResultData);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ res = alert.setCorrelator(((pSessionProp->alerts)+i)->strCorrelator);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+
+ if ( ((pSessionProp->alerts)+i)->strPackageURI != NULL )
+ {
+ res = alert.setPackageURI(((pSessionProp->alerts)+i)->strPackageURI);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+ }
+
+ count = sessionProp.addFirmAlert(alert);
+ if ( count != i+1 )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ this->callback = callback;
+ return DMPrincipalMessage::set(szPrincipal,messageID,pUserData);
+}
+
+
+
+
+SYNCML_DM_RET_STATUS_T DMProcessNotificationMessage::set(CPCHAR szPrincipal,
+ const UINT8 * buf,
+ INT32 len,
+ DMT_CallbackProcessNotification callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ SYNCML_DM_RET_STATUS_T res;
+ res = DMPrincipalMessage::set(szPrincipal,messageID,pUserData);
+ if ( res == SYNCML_DM_SUCCESS )
+ {
+ this->buf.assign(buf,len);
+ if ( this->buf.getBuffer() == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ this->callback = callback;
+ return res;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMTreeMessage::set(DMT_H_TREE htree,
+ CPCHAR path,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ DMAsyncMessage::set(messageID,pUserData);
+ if ( path )
+ {
+ this->path = path;
+ if ( path[0] && this->path == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ this->htree = htree;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T DMGetNodeMessage::set(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetNode callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ this->callback = callback;
+ return DMTreeMessage::set(htree,path,messageID,pUserData);
+}
+
+
+SYNCML_DM_RET_STATUS_T DMTreeNodeMessage::set(DMT_H_TREE htree,
+ CPCHAR path,
+ CPCHAR str,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ SYNCML_DM_RET_STATUS_T res;
+ res = DMTreeMessage::set(htree,path,messageID,pUserData);
+ if ( res == SYNCML_DM_SUCCESS )
+ {
+ if ( str )
+ {
+ this->str = str;
+ if ( str[0] && this->str == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ this->callback = callback;
+ }
+ return res;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T DMCreateLeafNodeMessage::set(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ SYNCML_DM_RET_STATUS_T res;
+ this->callback = callback;
+ res = DMTreeMessage::set(htree,path,messageID,pUserData);
+ if ( res == SYNCML_DM_SUCCESS )
+ res = dmtBuildData(data, this->data);
+ return res;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMGetChildNodeNamesMessage::set(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildNodeNames callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ this->callback = callback;
+ return DMTreeMessage::set(htree,path,messageID,pUserData);
+}
+
+
+SYNCML_DM_RET_STATUS_T DMGetChildValuesMapMessage::set(DMT_H_TREE htree,
+ CPCHAR path,
+ DMT_CallbackGetChildValuesMap callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ this->callback = callback;
+ return DMTreeMessage::set(htree,path,messageID,pUserData);
+}
+
+
+SYNCML_DM_RET_STATUS_T DMSetChildValuesMapMessage::set(DMT_H_TREE htree,
+ CPCHAR path,
+ const DMT_LEAF_CHILDREN_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ SYNCML_DM_RET_STATUS_T res;
+ this->callback = callback;
+ res = DMTreeMessage::set(htree,path,messageID,pUserData);
+ if ( res == SYNCML_DM_SUCCESS )
+ res = dmtBuildMap(data, this->data);
+ return res;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMSetValueMessage::set(DMT_H_NODE hnode,
+ const DMT_DATA_T* data,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ DMAsyncMessage::set(messageID,pUserData);
+ this->hnode = hnode;
+ this->callback = callback;
+ return dmtBuildData(data, this->data);
+}
+
+
+
+SYNCML_DM_RET_STATUS_T DMNodeMessage::set(DMT_H_NODE hnode,
+ CPCHAR str,
+ DMT_CallbackStatusCode callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ DMAsyncMessage::set(messageID,pUserData);
+ this->hnode = hnode;
+ this->callback = callback;
+ if ( str )
+ {
+ this->str = str;
+ if ( str[0] && this->str == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T DMExecuteMessage::set(DMT_H_NODE hnode,
+ CPCHAR params,
+ DMT_CallbackExecute callback,
+ UINT32 messageID,
+ UINT32 pUserData)
+{
+ DMAsyncMessage::set(messageID,pUserData);
+ this->hnode = hnode;
+ this->callback = callback;
+ this->params = params;
+ if ( params )
+ {
+ if ( params[0] && this->params == NULL )
+ {
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+
+void DMT_Free_GetChildNodeNamesStruct(DMT_CALLBACK_STRUCT_GET_CHILDNODE_NAMES_T *pStruct)
+{
+ if ( pStruct == NULL )
+ return;
+
+ if ( pStruct->ppChildren )
+ {
+ for (INT32 index=0; index<pStruct->num_children; index++)
+ {
+ if ( pStruct->ppChildren[index] )
+ dmtFreeCharPtr(pStruct->ppChildren[index]);
+ }
+ char ** ptr = (char**)pStruct->ppChildren;
+ DmFreeMem(ptr);
+ }
+ memset(pStruct,0,sizeof(DMT_CALLBACK_STRUCT_GET_CHILDNODE_NAMES_T));
+}
+
+
+void DMT_Free_GetChildValuesStruct(DMT_CALLBACK_STRUCT_GET_CHILDVALUES_MAP_T *pStruct)
+{
+
+ if ( pStruct == NULL )
+ return;
+
+ if ( pStruct->data.ppChildren )
+ {
+ for (INT32 index=0; index<pStruct->data.num_children; index++)
+ {
+ if ( pStruct->data.ppChildren[index] )
+ dmtFreeCharPtr(pStruct->data.ppChildren[index]);
+ }
+ char ** ptr = (char**)pStruct->data.ppChildren;
+ DmFreeMem(ptr);
+ }
+
+ if ( pStruct->data.pData )
+ {
+ for (INT32 index=0; index<pStruct->data.num_children; index++)
+ {
+ dmtFreeDataStruct((DMT_DATA_T*)&pStruct->data.pData[index]);
+ }
+ DMT_DATA_T * ptr = (DMT_DATA_T*)(pStruct->data.pData);
+ DmFreeMem(ptr);
+ }
+ memset(pStruct,0,sizeof(DMT_CALLBACK_STRUCT_GET_CHILDVALUES_MAP_T));
+
+
+}
+
+void DMT_Free_GetAttributesStruct(DMT_CALLBACK_STRUCT_GET_ATTRIBUTES_T *pStruct)
+{
+ if ( pStruct == NULL )
+ return;
+
+ dmtFreeCharPtr(pStruct->attributes.name);
+ dmtFreeCharPtr(pStruct->attributes.format);
+ dmtFreeCharPtr(pStruct->attributes.title);
+ dmtFreeCharPtr(pStruct->attributes.type);
+ dmtFreeCharPtr(pStruct->attributes.acl);
+
+ memset(pStruct,0,sizeof(DMT_CALLBACK_STRUCT_GET_ATTRIBUTES_T));
+}
+
+
+void DMT_Free_GetValueStruct(DMT_CALLBACK_STRUCT_GET_VALUE_T *pStruct)
+{
+ if ( pStruct == NULL )
+ return;
+
+ dmtFreeDataStruct(&pStruct->data);
+ memset(pStruct,0,sizeof(DMT_CALLBACK_STRUCT_GET_VALUE_T));
+
+}
+
+void DMT_Free_ExecuteStruct(DMT_CALLBACK_STRUCT_EXECUTE_T *pStruct)
+{
+ if ( pStruct == NULL )
+ return;
+
+ dmtFreeCharPtr(pStruct->result);
+ memset(pStruct,0,sizeof(DMT_CALLBACK_STRUCT_EXECUTE_T));
+
+}
+
+
+void DMT_Free_ProcessScriptStruct(DMT_CALLBACK_STRUCT_PROCESS_SCRIPT_T *pStruct)
+{
+ if ( pStruct == NULL )
+ return;
+
+ dmtFreeCharPtr(pStruct->result);
+ memset(pStruct,0,sizeof(DMT_CALLBACK_STRUCT_PROCESS_SCRIPT_T));
+
+}
+
+void DMT_Free_BootstrapStruct(DMT_CALLBACK_STRUCT_BOOTSTRAP_T *pStruct)
+{
+ if ( pStruct == NULL )
+ return;
+
+ dmtFreeCharPtr(pStruct->serverID);
+ memset(pStruct,0,sizeof(DMT_CALLBACK_STRUCT_BOOTSTRAP_T));
+
+}
+
+void DMT_Free_ProcessNotificationStruct(DMT_CALLBACK_STRUCT_PROCESS_NOTIFICATION_T *pStruct)
+{
+ if ( pStruct == NULL )
+ return;
+
+ dmtFreeCharPtr(pStruct->notification.serverID);
+ memset(pStruct,0,sizeof(DMT_NOTIFICATION_T));
+}
diff --git a/engine/dmlib/linux_java/buildscripts/createPackage b/engine/dmlib/linux_java/buildscripts/createPackage
new file mode 100644
index 0000000..8527901
--- /dev/null
+++ b/engine/dmlib/linux_java/buildscripts/createPackage
@@ -0,0 +1,244 @@
+#!/bin/bash
+
+# usage: [-test -nobuild]
+function usage
+{
+ echo "usage: $0 [-test] [-nobuild] [-incremental | -clearmake] [-display] [[[[build-top dir] param1] param2] ....]"
+ echo " -test - include test tar in final package"
+ echo " -nobuild - do not compile - just create package"
+ echo " -clearmake | -cm - use clearmake instead of make. Automatically tracks dependencies and can use DO to speed up build."
+ echo " -display - displays compilation output instead of redirecting it to log/errors files"
+ echo " -bo | -buildonly - only compiles library files; don't recompile unittest and DMT files"
+ echo " -debug - only compiles x86 debug library files"
+ exit 1
+}
+
+# global flag
+ADDTEST=0
+BUILDPKG=1
+BUILD_MODE="default"
+BUILD_ONLY=0
+DEBUG_ONLY=0
+
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -test ) ADDTEST=1 ; shift ;;
+ -nobuild ) BUILDPKG=0 ; shift ;;
+ -cm | -clearmake ) BUILD_MODE="cm" ; shift ;;
+ -bo | -buildonly ) BUILD_ONLY=1 ; shift ;;
+ -debug ) DEBUG_ONLY=1 ; shift ;;
+ -d | -display ) DISPLAY="y" ; shift ;;
+ -? | -h | -help | --help ) usage ; shift ;;
+ * ) break ;;
+ -* ) echo "unknown option $1; try -? for list of supported options"; exit 1 ;;
+ * ) break ;;
+ esac
+done
+
+export BUILD_MODE DEBUG_ONLY
+
+DM_SRC=/vobs/linuxjava/device_mgmt/dm/core/src
+DM_XPL=/vobs/linuxjava/device_mgmt/dm/xpl
+
+read VERSION < release_version.txt
+echo "VERSION is $VERSION"
+MAJOR_VERSION=`cat release_version.txt | sed 's/^\([0-9][0-9]*\).*/\1/'`
+echo "MAJOR VERSION is $MAJOR_VERSION"
+
+BTOP=/tmp/build2.lj.`whoami`
+
+if [ "$BUILD_MODE-" == "cm-" ] ; then
+ BTOP=../../../build
+fi
+
+echo "BTOP=$BTOP"
+
+LOG_FILE=`pwd`/log-lj-`whoami`-pkg-`date "+%Y-%m-%d"`
+
+ echo "write log to $LOG_FILE"
+
+ date > $LOG_FILE
+
+#cleartool catcs >> $LOG_FILE
+
+echo "compiling..."
+rm -f errors.txt
+
+SUPER_AGEN="LJAgent"
+
+if [ "$BUILDPKG" == "1" ] ; then
+# Building now...
+ if [ "$BUILD_MODE-" == "default-" ] ; then
+ rm -rf $BTOP
+ fi
+
+ if [ "$DISPLAY" == "y" ] ; then
+ $DM_SRC/linux_java/buildscripts/buildLib.sh $BTOP -DDMSyncMLLibVersion=\\\"$VERSION\\\" -DDMSyncMLLibVersionMajor=\\\"$MAJOR_VERSION\\\" -DDM_SUPER_AGENT=\\\"$SUPER_AGEN\\\" $1 $2 $3 $4 || exit 1
+ else
+ $DM_SRC/linux_java/buildscripts/buildLib.sh $BTOP -DDMSyncMLLibVersion=\\\"$VERSION\\\" -DDMSyncMLLibVersionMajor=\\\"$MAJOR_VERSION\\\" -DDM_SUPER_AGENT=\\\"$SUPER_AGEN\\\" $1 $2 $3 $4 >> $LOG_FILE 2>> errors.txt || exit 1
+ fi
+fi
+
+
+TMP_FOLDER=/tmp/pckg.lj.`whoami`
+echo "TMP_FOLDER=$TMP_FOLDER"
+
+if [ "$BUILD_ONLY" == "0" ] ; then
+ rm -rf $TMP_FOLDER
+else
+ rm -rf $TMP_FOLDER/lib
+fi
+
+mkdir $TMP_FOLDER
+mkdir -p $TMP_FOLDER/lib/x86.r
+mkdir -p $TMP_FOLDER/lib/xscale.r
+mkdir -p $TMP_FOLDER/lib/x86.d
+mkdir -p $TMP_FOLDER/lib/xscale.d
+
+#copy lib .so files
+if [ "$DEBUG_ONLY" == "0" ] ; then
+ cp -v $BTOP/xscale/release-staging/usr/local/motorola/lib/*.a $TMP_FOLDER/lib/xscale.r/ >> $LOG_FILE
+ cp -v $BTOP/xscale/release-staging/usr/local/motorola/lib/*.so $TMP_FOLDER/lib/xscale.r/ >> $LOG_FILE
+ cp -v $BTOP/x86-Redhat/release-staging/usr/local/motorola/lib/*.a $TMP_FOLDER/lib/x86.r/ >> $LOG_FILE
+ cp -v $BTOP/x86-Redhat/release-staging/usr/local/motorola/lib/*.so $TMP_FOLDER/lib/x86.r/ >> $LOG_FILE
+
+ cp -v $BTOP/xscale/staging/lib/*.a $TMP_FOLDER/lib/xscale.d/ >> $LOG_FILE
+ cp -v $BTOP/xscale/staging/lib/*.so $TMP_FOLDER/lib/xscale.d/ >> $LOG_FILE
+fi
+
+cp -v $BTOP/x86-Redhat/staging/lib/*.a $TMP_FOLDER/lib/x86.d/ >> $LOG_FILE
+cp -v $BTOP/x86-Redhat/staging/lib/*.so $TMP_FOLDER/lib/x86.d/ >> $LOG_FILE
+
+function create_links
+{
+ DIR=$1
+ pushd $DIR >> $LOG_FILE
+ mv libdmnative.so libdmnative.so.$VERSION
+ mv libdmssession.so libdmssession.so.$VERSION
+ ln -s libdmnative.so.$VERSION libdmnative.so
+ ln -s libdmssession.so.$VERSION libdmssession.so
+ ln -s libdmnative.so.$VERSION libdmnative.so.$MAJOR_VERSION
+ ln -s libdmssession.so.$VERSION libdmssession.so.$MAJOR_VERSION
+
+ popd >> $LOG_FILE
+}
+
+if [ "$DEBUG_ONLY" == "0" ] ; then
+ create_links $TMP_FOLDER/lib/xscale.r/
+ create_links $TMP_FOLDER/lib/x86.r/
+ create_links $TMP_FOLDER/lib/xscale.d/
+fi
+create_links $TMP_FOLDER/lib/x86.d/
+
+if [ "$BUILD_ONLY" == "1" ] ; then
+ echo "Incremental build is done; unit-test skipped"
+ exit 0
+fi
+
+#copy public include files
+cp -rv $DM_SRC/api/native $TMP_FOLDER/include >> $LOG_FILE
+cp -rv $DM_SRC/api/common/* $TMP_FOLDER/include >> $LOG_FILE
+cp $DM_SRC/portlib/generic/xpl_dm_Manager.h $TMP_FOLDER/include >> $LOG_FILE
+cp -rv $DM_SRC/dmengine/dm_persist/hdr/SyncML_DM_FileHandle.H $TMP_FOLDER/include >> $LOG_FILE
+cp -rv $DM_SRC/dmengine/dm_util/hdr/syncml_dm_data_types.h $TMP_FOLDER/include >> $LOG_FILE
+
+
+#copy portlib header files needed by LJ
+mkdir -p $TMP_FOLDER/portlib
+cp -rv $DM_SRC/portlib/generic/xpl_dm_ServerAlert.h $TMP_FOLDER/portlib >> $LOG_FILE
+cp -rv $DM_SRC/portlib/generic/xpl_dm_ServerAlertDef.h $TMP_FOLDER/portlib >> $LOG_FILE
+cp -rv $DM_SRC/portlib/generic/dmMemory.h $TMP_FOLDER/portlib >> $LOG_FILE
+cp -rv $DM_SRC/portlib/lj/hdr/dmStringUtil.h $TMP_FOLDER/portlib >> $LOG_FILE
+cp -rv $DM_XPL/code/portlib/linux/hdr/xpl_Types.h $TMP_FOLDER/portlib >> $LOG_FILE
+cp -rv $DM_XPL/code/portlib/hdr/xpl_File.h $TMP_FOLDER/portlib >> $LOG_FILE
+cp -rv $DM_XPL/code/portlib/hdr/xpl_Port.h $TMP_FOLDER/portlib >> $LOG_FILE
+cp -rv $DM_XPL/code/portlib/hdr/xpl_Time.h $TMP_FOLDER/portlib >> $LOG_FILE
+
+#copy docs, not send doc files, only pdf files if any...
+mkdir -p $TMP_FOLDER/docs/apidocs
+#cp -rv $DM_SRC/../docs/apidocs/* $TMP_FOLDER/docs/apidocs >> $LOG_FILE
+#cp -rv $DM_SRC/../docs/*.pdf $TMP_FOLDER/docs >> $LOG_FILE
+
+#create tools
+mkdir -p $TMP_FOLDER/tools
+
+#create dmt tools
+mkdir -p $TMP_FOLDER/tools/dmt-tools
+cp -rv $DM_SRC/dmt-tools/* $TMP_FOLDER/tools/dmt-tools >> $LOG_FILE
+cp -rv $DM_SRC/linux_java/samples/settings/fstab $TMP_FOLDER/tools/dmt-tools >> $LOG_FILE
+
+#create server credential tools
+mkdir -p $TMP_FOLDER/tools/servercred
+pushd $DM_SRC/tool/servercred >> $LOG_FILE
+./build.sh || exit 1
+popd >> $LOG_FILE
+cp -rv $DM_SRC/tool/servercred/*.txt $TMP_FOLDER/tools/servercred/ >> $LOG_FILE
+cp -rv $DM_SRC/tool/servercred/bin $TMP_FOLDER/tools/servercred/bin >> $LOG_FILE
+
+chmod -x $TMP_FOLDER/portlib/*
+chmod -x $TMP_FOLDER/include/*.h*
+chmod -x $TMP_FOLDER/include/plugin/*
+
+# create samples
+echo "Prepare samples"
+DM_SAMPLES=$DM_SRC/linux_java/samples
+echo "samples dir=$DM_SAMPLES"
+
+mkdir $TMP_FOLDER/samples
+cp -rv $DM_SAMPLES/compile $TMP_FOLDER/samples/ >> $LOG_FILE
+cp -rv $DM_SAMPLES/run_test $TMP_FOLDER/samples/ >> $LOG_FILE
+cp -rv $DM_SAMPLES/ddd_test $TMP_FOLDER/samples/ >> $LOG_FILE
+chmod +x $TMP_FOLDER/samples/compile
+chmod +x $TMP_FOLDER/samples/run_test
+chmod +x $TMP_FOLDER/samples/ddd_test
+
+#cp source files
+mkdir $TMP_FOLDER/samples/src
+cp -rv $DM_SAMPLES/unittest/src/*.cc $TMP_FOLDER/samples/src >> $LOG_FILE
+cp -v $DM_SRC/linux_java/samples/plugins/test*/src/*.cc $TMP_FOLDER/samples/src >> $LOG_FILE
+
+#cp settings
+mkdir $TMP_FOLDER/samples/settings
+cp -v $DM_SAMPLES/plugins/settings/testplugins.ini $TMP_FOLDER/samples/settings/testplugins.ini >> $LOG_FILE
+cp -v $DM_SAMPLES/settings/Dmt.zip $TMP_FOLDER/samples/settings/ >> $LOG_FILE
+
+chmod +w $TMP_FOLDER/samples/*
+
+# create packages
+ZIPFILE=DM-v$VERSION-`date "+%Y-%m-%d"`.tgz
+pushd $TMP_FOLDER
+tar zcvf $ZIPFILE * >> $LOG_FILE
+popd
+
+cp -r $DM_SRC/linux_java/test $TMP_FOLDER/samples/unittest
+pushd $TMP_FOLDER
+
+echo "compiling unit test..."
+cd samples
+./compile both || exit 1 >> $LOG_FILE
+
+
+#run unit test
+export DM_NOPRINTF=1
+
+export dm_setting_root=$PWD/dmt_data
+export dm_setting_version="1.1.2"
+export PLATFORM=x86
+export LD_LIBRARY_PATH=$PWD/../lib/x86.d:$PWD/lib/../x86
+export dm_setting_plugin=$PWD/plugins/x86
+
+
+echo "running unit test for DM 1.1.2..."
+./bin/x86/testexe < unittest/dm11/testinput11 > unittest/dm11/output11 || exit 1
+diff -q unittest/dm11/output11 unittest/dm11/testoutput11 || echo "DM 1.1 unit test failed!"
+
+export dm_setting_version="1.2"
+
+echo "running unit test for DM 1.2..."
+./bin/x86/testexe < unittest/dm12/testinput12 > unittest/dm12/output12 || exit 1
+diff -q unittest/dm12/output12 unittest/dm12/testoutput12 || echo "DM 1.2 unit test failed!"
+popd
+
+echo "done; result file is $TMP_FOLDER/$ZIPFILE"
+
diff --git a/engine/dmlib/linux_java/buildscripts/release_version.txt b/engine/dmlib/linux_java/buildscripts/release_version.txt
new file mode 100644
index 0000000..4d2d738
--- /dev/null
+++ b/engine/dmlib/linux_java/buildscripts/release_version.txt
@@ -0,0 +1 @@
+02.00.00
diff --git a/engine/dmlib/linux_java/mkfiles/GenericMake b/engine/dmlib/linux_java/mkfiles/GenericMake
new file mode 100644
index 0000000..d8950dd
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/GenericMake
@@ -0,0 +1,200 @@
+
+#
+# DESCRIPTION:
+# Template Makefile for DM tests, jni so and engine
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+# 03-06-27 fdp101 dbg_ca69_fdp101_dm_dev,
+# Initial draft
+# 03-08-07 fdp101 Master reorganization, convert to template-based
+# 06-08-07 ehb005 Vob migration
+# 06-20-07 ehb005 LIBmm61881 - Added DM_UNITTEST
+#
+#####################################################################
+#
+# Input parameters:
+# Targets:
+# all - build the the code
+#
+# Platforms (TARGET variable)
+# x86-Redhat
+# EzX
+#
+# Comilation options (DM_BUILD_TARGET)
+# build - debug build
+# release - final release with optimizations
+#
+######################################################################
+
+#GLOBAL_VOBS_PREFIX := $(subst /vobs/jem/caf/dm/src/linux_java/mkfiles,,$(shell pwd))
+
+# purify target support
+ifndef PURIFY
+PURIFY=/rational2/releases/purify.i386_linux2.2003a.06.00/purify
+endif
+
+ifneq ($(DM_BUILD_TARGET),release)
+ifdef USE_PURIFY
+ifdef GLOBAL_EXECUTABLE
+LINKER := $(PURIFY) -INUSE_AT_EXIT=yes -CHAIN_LENGTH="10"
+endif
+endif
+endif
+
+CC := ${COMPILERTOOLPATH}/${COMPILERTOOLPREFIX}gcc
+CCP := ${COMPILERTOOLPATH}/${COMPILERTOOLPREFIX}gcc
+LINKER += ${COMPILERTOOLPATH}/${COMPILERTOOLPREFIX}gcc
+AR := ${COMPILERTOOLPATH}/${COMPILERTOOLPREFIX}ar
+
+
+ifndef TARGET
+TARGET := x86-Redhat
+endif
+
+ifndef DM_BUILD_TARGET
+# assume debug as default
+DM_BUILD_TARGET := build
+endif
+
+ifndef DMBUILDTOP
+DMBUILDTOP=/vobs/linuxjava/device_mgmt/dm/core/build/x86-Redhat
+endif
+
+
+DIR_CORE := /vobs/linuxjava/device_mgmt/dm/core
+DIR_DM :=/vobs/linuxjava/device_mgmt/dm/core/src
+DIR_XPL :=/vobs/linuxjava/device_mgmt/dm/xpl
+
+
+# default value only, also used when no variables are provided
+STAGING=$(DMBUILDTOP)/release-staging
+OUT_DIR=$(STAGING)/$(GLOBAL_TARGET_SUBDIR)
+
+#ARCH=$(TARGET).$(DM_BUILD_TARGET)
+ARCH=$(TARGET)
+
+ifeq ($(DM_BUILD_TARGET),release)
+OBJ_DIR = obj_release_$(ARCH)
+else
+OBJ_DIR = obj_debug_$(ARCH)
+endif
+
+DEPSOURCE = $(subst $(DMBUILDTOP),$(DIR_DM),$(subst $(OBJ_DIR),src,$(basename $@)))
+
+FINALTARGET=$(OUT_DIR)/$(GLOBAL_TARGET_FILENAME)
+
+# include each subdirs Makefile.objects
+include $(foreach dir,$(GLOBAL_SUBDIRS_A),$(DIR_DM)/$(dir)/Makefile.objects)
+
+OBJS = $(foreach dir1,$(GLOBAL_SUBDIRS_A),$(foreach object,$($(notdir $(subst /src,,$(dir1)))_OBJECTS),$(DMBUILDTOP)/$(dir $(dir1))/$(OBJ_DIR)/$(object)) )
+ALL_SOURCES = $(foreach dir1,$(GLOBAL_SUBDIRS_A),$(foreach object,$($(notdir $(subst /src,,$(dir1)))_OBJECTS),$(dir1)/$(subst .o,.c,$(subst .oo,.cc,$(object)))))
+
+
+# Flags
+CC_INCLUDE_FLAGS=
+
+
+ifeq ($(DM_BUILD_TARGET),release)
+CC_GENERIC_FLAGS = -Os -fcheck-new -Wall -Wno-deprecated \
+ -DNDEBUG -DNO_DEBUG
+C_GENERIC_FLAGS = -Os -Wall -DNDEBUG -DNO_DEBUG
+
+ifdef RELEASESTAGING
+STAGING=$(RELEASESTAGING)
+endif
+
+else
+CC_GENERIC_FLAGS += -g -fcheck-new -Wall -Wno-deprecated -DDEBUG
+
+ifdef DEVSTAGING
+STAGING=$(DEVSTAGING)
+endif
+
+endif
+
+ifeq ($(TARGET),x86-Redhat)
+CC_GENERIC_FLAGS += -DPLATFORM_X86
+C_GENERIC_FLAGS += -DPLATFORM_X86 -g -Wall -DDEBUG
+else
+CC_GENERIC_FLAGS += -DEZX_PLATFORM_arm11 -DEZX_PRODUCT_SCMA11REF
+C_GENERIC_FLAGS += -DEZX_PLATFORM_arm11 -DEZX_PRODUCT_SCMA11REF
+endif
+
+ifdef USE_GCOV
+CC_GENERIC_FLAGS += -fprofile-arcs -ftest-coverage
+C_GENERIC_FLAGS += -fprofile-arcs -ftest-coverage
+endif
+
+
+ALL_CCFLAGS = -fno-rtti -fno-exceptions -fPIC \
+ -DVRTXMC \
+ -DSYNCML_DM_DBG_USING_XML \
+ -DDM_SUPPORT_AUTHPREF \
+ -DDM_ATOMIC_SUPPORTED \
+ -DLOB_SUPPORT \
+ -DNO_OTHER_PLUGIN \
+ -DDM_UNITTEST \
+ $(CC_GENERIC_FLAGS) $(CC_INCLUDE_FLAGS) $(GLOBAL_EXTRA_CC_FLAGS) $(GLOBAL_EXTRA_CC_FLAGS.$(TARGET)) \
+ $(CMD_EXTRA_CC_FLAGS)
+
+
+ALL_CFLAGS = -fno-exceptions -fPIC \
+ -DVRTXMC \
+ -DSYNCML_DM_DBG_USING_XML \
+ -DDM_SUPPORT_AUTHPREF \
+ -DDM_ATOMIC_SUPPORTED \
+ -DLOB_SUPPORT \
+ -DNO_CAF \
+ -DNO_CAF \
+ -DNO_OTHER_PLUGIN \
+ -DDM_UNITTEST \
+ $(C_GENERIC_FLAGS) $(CC_INCLUDE_FLAGS) $(GLOBAL_EXTRA_CC_FLAGS) $(GLOBAL_EXTRA_CC_FLAGS.$(TARGET)) \
+ $(CMD_EXTRA_CC_FLAGS)
+
+CCFLAGS = -c $(ALL_CCFLAGS)
+CFLAGS = -c $(ALL_CFLAGS)
+
+ifeq ($(TARGET), linux-arm-familiar)
+ GFLAG = -msoft-float
+else
+ GFLAG =
+endif
+
+
+CC_LINK_FLAGS=$(CC_GENERIC_FLAGS) $(GLOBAL_EXTRA_LINK_FLAGS) \
+ -lpthread -ldl -lstdc++ -L$(STAGING)/lib -L$(STAGING)/api -L$(OUT_DIR)\
+ -Wl,--no-undefined \
+ $(CMD_EXTRA_LINK_FLAGS)
+
+all:: BUILD_PREPARE $(OBJS) $(FINALTARGET)
+ @echo -n ""
+
+BUILD_PREPARE:
+# @for dir in $(GLOBAL_SUBDIRS_A); do \
+# (test -d $(subst $(GLOBAL_VOBS_PREFIX)/vobs,$(DMBUILDTOP),$(DIR_DM)/$$dir/../obj.$(ARCH)) || (echo "mkdir -p $(subst $(GLOBAL_VOBS_PREFIX)/vobs,$(DMBUILDTOP),$(DIR_DM)/$$dir/../obj.$(ARCH))" && mkdir -p $(subst $(GLOBAL_VOBS_PREFIX)/vobs,$(DMBUILDTOP),$(DIR_DM)/$$dir/../obj.$(ARCH)) )); \
+# done
+
+ @(test -d $(OUT_DIR) || (mkdir -p $(OUT_DIR) && echo "created $(OUT_DIR)" ))
+
+##### Compile rules #####
+%.o:
+ mkdir -p $(@D)
+ $(CC) $(CFLAGS) $(DEPSOURCE).c -o $@
+
+%.oo:
+ mkdir -p $(@D)
+ $(CCP) $(CCFLAGS) $(DEPSOURCE).cc -o $@
+
+
+ifdef GLOBAL_CREATE_LIB
+$(FINALTARGET): $(OBJS)
+ $(AR) rc $(FINALTARGET) $(OBJS)
+else
+## Linker
+$(FINALTARGET): $(OBJS)
+ $(LINKER) $(CC_LINK_FLAGS) -o $(FINALTARGET) $(OBJS)
+endif
+
diff --git a/engine/dmlib/linux_java/mkfiles/dm_make.a2so b/engine/dmlib/linux_java/mkfiles/dm_make.a2so
new file mode 100644
index 0000000..f679e14
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/dm_make.a2so
@@ -0,0 +1,36 @@
+# SIMPLE make file to create 4 so from 8 .a files.
+DEBUG_TARGETS := $(DEVSTAGING)/lib/libdmnative.so \
+ $(DEVSTAGING)/lib/libdmssession.so
+
+FINALTARGETS := $(RELEASESTAGING)/lib/libdmnative.so $(RELEASESTAGING)/lib/libdmssession.so \
+ $(DEVSTAGING)/lib/libdmnative.so \
+ $(DEVSTAGING)/lib/libdmssession.so
+
+LINKER := $(COMPILERTOOLPATH)/${COMPILERTOOLPREFIX}gcc
+
+OPTIONS := -fcheck-new -Wno-deprecated -shared -Xlinker -O -Xlinker 5 -lpthread -ldl -lstdc++
+
+DM_TOP := /vobs/linuxjava/device_mgmt/dm
+
+$(RELEASESTAGING)/lib/libdmnative.so: $(RELEASESTAGING)/lib/libdmnative_static.a $(RELEASESTAGING)/lib/libxpl.a $(RELEASESTAGING)/lib/libconui.a
+ $(LINKER) $(OPTIONS) -Xlinker --version-script=$(DM_TOP)/lib/dmnative/versionscript -Xlinker -soname=libdmnative.so.$(MAJOR_VERSION) -o $@ -Xlinker --whole-archive -L$(RELEASESTAGING)/lib -ldmnative_static -lxpl -lconui -Xlinker -no-whole-archive
+
+$(DEVSTAGING)/lib/libdmnative.so: $(DEVSTAGING)/lib/libdmnative_static.a $(DEVSTAGING)/lib/libxpl.a $(DEVSTAGING)/lib/libconui.a
+ $(LINKER) $(OPTIONS) -Xlinker --version-script=$(DM_TOP)/lib/dmnative/versionscript -Xlinker -soname=libdmnative.so.$(MAJOR_VERSION) -o $@ -Xlinker --whole-archive -L$(DEVSTAGING)/lib -ldmnative_static -lxpl -lconui -Xlinker -no-whole-archive
+
+
+$(RELEASESTAGING)/lib/libdmssession.so: $(RELEASESTAGING)/lib/libdmssession_static.a $(RELEASESTAGING)/lib/libdmnative.so
+ $(LINKER) $(OPTIONS) -L$(RELEASESTAGING)/lib -ldmnative -Xlinker --version-script=$(DM_TOP)/lib/dmssession/dmssession.map -Xlinker -soname=libdmssession.so.$(MAJOR_VERSION) -o $@ -Xlinker --whole-archive -L$(RELEASESTAGING)/lib -ldmssession_static -Xlinker -no-whole-archive
+
+
+$(DEVSTAGING)/lib/libdmssession.so: $(DEVSTAGING)/lib/libdmssession_static.a $(DEVSTAGING)/lib/libdmnative.so
+ $(LINKER) $(OPTIONS) -L$(DEVSTAGING)/lib -ldmnative -Xlinker --version-script=$(DM_TOP)/lib/dmssession/dmssession.map -Xlinker -soname=libdmssession.so.$(MAJOR_VERSION) -o $@ -Xlinker --whole-archive -L$(DEVSTAGING)/lib -ldmssession_static -Xlinker -no-whole-archive
+
+COMPILE_SO: $(FINALTARGETS)
+
+all:: COMPILE_SO
+ @echo -n ""
+
+debug: $(DEBUG_TARGETS)
+ @echo -n ""
+
diff --git a/engine/dmlib/linux_java/mkfiles/dm_make.con b/engine/dmlib/linux_java/mkfiles/dm_make.con
new file mode 100644
index 0000000..5ad4675
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/dm_make.con
@@ -0,0 +1,38 @@
+#
+# DESCRIPTION:
+# Makefile for jni shared object
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+# 03-08-07 fdp101 initial draft
+#
+#####################################################################
+
+# java home
+ifndef JAVA_HOME
+JAVA_HOME := /opt/jdk1.3.1
+endif
+
+GLOBAL_TARGET_SUBDIR := lib
+GLOBAL_TARGET_FILENAME := libconui.a
+
+GLOBAL_SUBDIRS_A = linux_java/samples/conui/src
+
+GLOBAL_EXTRA_CC_FLAGS = \
+ -I$(DIR_DM)/portlib/generic \
+ -I$(DIR_DM)/api/common \
+ -I$(DIR_DM)/api/native \
+ -I$(DIR_DM)/linux_java/samples/conui/hdr \
+ -I$(DIR_XPL)/code/portlib/hdr \
+ -I$(DIR_XPL)/code/portlib/linux/hdr \
+ -DEZX_PORT
+
+GLOBAL_CREATE_LIB = 1
+
+GLOBAL_DEP_FILENAME = deps_xpl
+
+include /vobs/linuxjava/device_mgmt/dm/core/src/linux_java/mkfiles/GenericMake
+
+
diff --git a/engine/dmlib/linux_java/mkfiles/dm_make.native b/engine/dmlib/linux_java/mkfiles/dm_make.native
new file mode 100644
index 0000000..b5be66e
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/dm_make.native
@@ -0,0 +1,73 @@
+#
+# DESCRIPTION:
+# Makefile for jni shared object
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+# 03-08-07 fdp101 initial draft
+#
+#####################################################################
+
+# java home
+ifndef JAVA_HOME
+JAVA_HOME := /opt/jdk1.3.1
+endif
+
+DIR_DM := /vobs/linuxjava/device_mgmt/dm/core/src
+DM_XPL := /vobs/linuxjava/device_mgmt/dm/xpl
+
+GLOBAL_TARGET_SUBDIR := lib
+GLOBAL_TARGET_FILENAME := libdmnative_static.a
+
+GLOBAL_SUBDIRS_A = \
+dmengine/dm_ua/src \
+dmengine/dm_persist/src \
+dmengine/dm_tnm/src \
+dmengine/dm_util/src \
+dmtapi/native/src \
+plugin/src \
+notification_agent/src
+
+GLOBAL_EXTRA_CC_FLAGS = \
+ -I$(DIR_DM)/plugin/hdr \
+ -I$(DIR_DM)/dmengine/hdr \
+ -I$(DIR_DM)/dmengine/dm_util/hdr \
+ -I$(DIR_DM)/dmengine/dm_persist/hdr \
+ -I$(DIR_DM)/dmengine/dm_security/hdr \
+ -I$(DIR_DM)/dmengine/dm_tnm/hdr \
+ -I$(DIR_DM)/dmengine/dm_ssession/hdr \
+ -I$(DIR_DM)/dmengine/dm_transport/hdr \
+ -I$(DIR_DM)/dmengine/dm_ua/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/xpt/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/mgr/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/ghdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/lib/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/wsm/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/xlt/src \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/xlt/hdr \
+ -I$(DIR_DM)/portlib/lj/hdr \
+ -I$(DIR_DM)/portlib/generic \
+ -I$(DIR_DM)/api/common \
+ -I$(DIR_DM)/api/native \
+ -I$(DIR_DM)/api/native/plugin \
+ -I$(DIR_DM)/dmtapi/native/hdr \
+ -I$(DIR_XPL)/code/portlib/hdr \
+ -I$(DIR_XPL)/code/portlib/linux/hdr \
+ -I$(DIR_XPL)/code/utility/hdr \
+ -I$(DIR_DM)/notification_agent/hdr \
+ -DEZX_PORT
+
+
+GLOBAL_CREATE_LIB = 1
+
+#GLOBAL_EXTRA_LINK_FLAGS := -shared -ldmportlib \
+ -Xlinker -O -Xlinker 5 \
+ -Xlinker --version-script=versionscript
+
+GLOBAL_DEP_FILENAME = deps_dmnative
+
+include /vobs/linuxjava/device_mgmt/dm/core/src/linux_java/mkfiles/GenericMake
+
+
diff --git a/engine/dmlib/linux_java/mkfiles/dm_make.poccommit b/engine/dmlib/linux_java/mkfiles/dm_make.poccommit
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/dm_make.poccommit
diff --git a/engine/dmlib/linux_java/mkfiles/dm_make.pocconstraint b/engine/dmlib/linux_java/mkfiles/dm_make.pocconstraint
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/dm_make.pocconstraint
diff --git a/engine/dmlib/linux_java/mkfiles/dm_make.ssession b/engine/dmlib/linux_java/mkfiles/dm_make.ssession
new file mode 100644
index 0000000..2ed0728
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/dm_make.ssession
@@ -0,0 +1,70 @@
+#
+# DESCRIPTION:
+# Makefile for jni shared object
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+# 03-08-07 fdp101 initial draft
+#
+#####################################################################
+
+# java home
+ifndef JAVA_HOME
+JAVA_HOME := /opt/jdk1.3.1
+endif
+
+GLOBAL_TARGET_SUBDIR := lib
+GLOBAL_TARGET_FILENAME := libdmssession_static.a
+
+GLOBAL_SUBDIRS_A = \
+dmengine/oma_toolkit/src \
+dmengine/dm_ssession/src \
+dmengine/dm_transport/src \
+dmengine/dm_security/src
+
+
+GLOBAL_EXTRA_CC_FLAGS = \
+ -I$(DIR_DM)/portlib/hdr \
+ -I$(DIR_DM)/portlib/generic \
+ -I$(DIR_DM)/portlib/lj/hdr \
+ -I$(DIR_DM)/dmengine/hdr \
+ -I$(DIR_DM)/dmengine/dm_util/hdr \
+ -I$(DIR_DM)/dmengine/dm_persist/hdr \
+ -I$(DIR_DM)/dmengine/dm_security/hdr \
+ -I$(DIR_DM)/dmengine/dm_ssession/hdr \
+ -I$(DIR_DM)/dmengine/dm_tnm/hdr \
+ -I$(DIR_DM)/dmengine/dm_transport/hdr \
+ -I$(DIR_DM)/dmengine/dm_ua/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/xpt/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/mgr/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/ghdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/lib/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/wsm/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/xlt/src \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/xlt/hdr \
+ -I$(DIR_DM)/api/common \
+ -I$(DIR_DM)/api/native \
+ -I$(DIR_DM)/dmtapi/native/hdr \
+ -I$(DIR_DM)/plugin/hdr \
+ -I$(DIR_XPL)/code/portlib/hdr \
+ -I$(DIR_XPL)/code/portlib/linux/hdr \
+ -I$(DIR_XPL)/code/utility/hdr \
+ -I$(DIR_DM)/api/native/plugin \
+ -DEZX_PORT \
+ -DDM_DUMP_SYNCML_PACKAGE
+
+
+
+GLOBAL_CREATE_LIB = 1
+
+#GLOBAL_EXTRA_LINK_FLAGS := -shared -ldmnative -ldmportlib \
+ -Xlinker -O -Xlinker 5 \
+ -Xlinker --version-script=versionsc_ssesion
+
+GLOBAL_DEP_FILENAME = deps_ssession
+
+include /vobs/linuxjava/device_mgmt/dm/core/src/linux_java/mkfiles/GenericMake
+
+
diff --git a/engine/dmlib/linux_java/mkfiles/dm_make.xpl b/engine/dmlib/linux_java/mkfiles/dm_make.xpl
new file mode 100644
index 0000000..a3a84b5
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/dm_make.xpl
@@ -0,0 +1,59 @@
+#
+# DESCRIPTION:
+# Makefile for jni shared object
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+# 03-08-07 fdp101 initial draft
+#
+#####################################################################
+
+# java home
+ifndef JAVA_HOME
+JAVA_HOME := /opt/jdk1.3.1
+endif
+
+GLOBAL_TARGET_SUBDIR := lib
+GLOBAL_TARGET_FILENAME := libxpl.a
+
+GLOBAL_SUBDIRS_A = portlib/lj/src \
+ linux_java/samples/portlib/src
+
+GLOBAL_EXTRA_CC_FLAGS = \
+ -I$(DIR_DM)/plugin/hdr \
+ -I$(DIR_DM)/dmengine/hdr \
+ -I$(DIR_DM)/dmengine/dm_util/hdr \
+ -I$(DIR_DM)/dmengine/dm_persist/hdr \
+ -I$(DIR_DM)/dmengine/dm_security/hdr \
+ -I$(DIR_DM)/dmengine/dm_tnm/hdr \
+ -I$(DIR_DM)/dmengine/dm_ssession/hdr \
+ -I$(DIR_DM)/dmengine/dm_transport/hdr \
+ -I$(DIR_DM)/dmengine/dm_ua/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/xpt/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/mgr/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/ghdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/lib/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/wsm/hdr \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/xlt/src \
+ -I$(DIR_DM)/dmengine/oma_toolkit/sml/xlt/hdr \
+ -I$(DIR_DM)/portlib/lj/hdr \
+ -I$(DIR_DM)/portlib/generic \
+ -I$(DIR_DM)/api/common \
+ -I$(DIR_DM)/api/native \
+ -I$(DIR_DM)/api/native/plugin \
+ -I$(DIR_DM)/dmtapi/native/hdr \
+ -I$(DIR_XPL)/code/portlib/hdr \
+ -I$(DIR_XPL)/code/portlib/linux/hdr \
+ -I$(DIR_XPL)/code/utility/hdr \
+ -I$(DIR_DM)/linux_java/samples/logger/hdr \
+ -I$(DIR_DM)/api/native/plugin \
+ -DEZX_PORT
+
+GLOBAL_CREATE_LIB = 1
+
+GLOBAL_DEP_FILENAME = deps_xpl
+
+include /vobs/linuxjava/device_mgmt/dm/core/src/linux_java/mkfiles/GenericMake
+
diff --git a/engine/dmlib/linux_java/mkfiles/versionsc_ssesion b/engine/dmlib/linux_java/mkfiles/versionsc_ssesion
new file mode 100644
index 0000000..1f95bf4
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/versionsc_ssesion
@@ -0,0 +1,14 @@
+{
+ global:
+ DmProcessServerDataInternal;
+ DmProcessScriptDataInternal;
+ DmBootstrapInternal;
+
+ syncmldm_sec_build_hmac_cred;
+ base64Decode;
+ *GetServerAuthValues*;
+ *GetDeviceID*;
+ local:
+ *;
+};
+
diff --git a/engine/dmlib/linux_java/mkfiles/versionscr_plugin b/engine/dmlib/linux_java/mkfiles/versionscr_plugin
new file mode 100644
index 0000000..6e1d0d7
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/versionscr_plugin
@@ -0,0 +1,7 @@
+{
+ global:
+ DMT_PluginLib*;
+ local:
+ *;
+};
+
diff --git a/engine/dmlib/linux_java/mkfiles/versionscript b/engine/dmlib/linux_java/mkfiles/versionscript
new file mode 100644
index 0000000..ac7f7ec
--- /dev/null
+++ b/engine/dmlib/linux_java/mkfiles/versionscript
@@ -0,0 +1,101 @@
+{
+ global:
+ extern "C++"{
+ DM_Event::*;
+ DMFileHandler::*;
+ SyncML_Log::*;
+ SyncML_Commit_Log::*;
+ DMLockingHelper::*;
+ DmtAcl::*;
+ DMString::*;
+ DMBuffer::*;
+ DMAddData::*;
+ DmSocketConnector::*;
+ DmtTreeFactory::*;
+ DmtErrorDescription::*;
+ DmtData::*;
+ DmtAttributes::*;
+ DmtEvent::*;
+ DmtPluginStatus::*;
+ DmtAPIPluginTree::*;
+ DmtPluginTree::*;
+ DmtPluginNode::*;
+ DmtRWPluginTree::*;
+ DmtRWPluginNode::*;
+ DMThread::*;
+ DMParser::*;
+ DMToken::*;
+ DmtDataChunk::*;
+ DMLockContextManager::*;
+ DmtSessionProp::*;
+ DmtEventSubscription::*;
+
+ DMTree::ConvertFormat*;
+ DMTree::GetClientAuthInfo*;
+ DMTree::GetServerAuthInfo*;
+ DMTree::ReleaseLock*;
+ DMTree::GetMetaDataManager*;
+ DMTree::GetPluginManager*;
+ DMTree::GetArchiver*;
+ DMTree::GetLockContextManager*;
+ DMTree::Flush*;
+ DMTree::GetWritableFileSystemFullPath*;
+ DMTree::IsInitialized*;
+ DMTree::GetMaxPathDepth*;
+ DMTree::GetMaxTotalPathLength*;
+ DMTree::GetMaxPathSegmentLength*;
+ DMTree::SetServerId*;
+ DMTree::SetConRef*;
+ DMTree::Replace*;
+ DMTree::Exec*;
+ DMTree::InitListAndGetListFirstItem*;
+ DMTree::Add*;
+ DMTree::GetListNextItem*;
+ DMTree::Commit*;
+ DMTree::Atomic*;
+ DMTree::SetLastClientAuthType*;
+ DMTree::GetAccNodeValue*;
+ DMTree::Delete*;
+ DMTree::URIValidateAndParse*;
+ DMTree::Get*;
+ DMTree::readOneWordFromTree*;
+ DMTree::FindNodeByURI*;
+ DMTree::IsESN*;
+ DMTree::GetLastClientAuthType*;
+ DMTree::ConvertFormatStr*;
+ DMTree::GetParentOfKeyValue*;
+ DMTree::GetDefAccountAddrInfo*;
+ DMTree::GetLockContextManager*;
+ DMTree::GetWritableFileSystemFullPath*;
+ DMTree::getChildren*;
+ dmFreeGetMap*;
+
+
+ };
+
+ DmtMemAlloc*;
+ DmtMemFree;
+ DmStrToStringVector;
+ DmStringParserGetItem;
+ GetDMSyncMLVersion;
+ DmAllocMem*;
+ DmReallocMem;
+ DmFreeMem*;
+ _*SYNCML_DM_Session*;
+
+ dmGetNodeValue*;
+ DmtGetCachedOPINodeData*;
+ DmtSetOPINodeData*;
+
+ XPL_*;
+
+ _ZTV*;
+
+ s_nBlocks;
+ s_nSize;
+ s_nCnt;
+ dmTreeObj;
+ local:
+ *;
+};
+
diff --git a/engine/dmlib/linux_java/samples/compile b/engine/dmlib/linux_java/samples/compile
new file mode 100644
index 0000000..545c19f
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/compile
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+PLATFORM=$1
+
+if [ "-$PLATFORM" == "-" ]; then
+ PLATFORM=both
+fi
+
+function build
+{
+ PLTM=$1
+ if [ "$PLTM" == "x86" ]; then
+ CC=/usr/bin/gcc
+ else
+ CC=/vobs/jem/cee4_lsp/mobilinux/devkit/arm/v6_vfp_le/bin/arm_v6_vfp_le-g++
+ fi
+
+ #make clean
+ rm -rf plugins/$PLTM
+ rm -rf lib/$PLTM
+ rm -rf bin/$PLTM
+ #create subdirs
+ mkdir -p plugins/$PLTM
+ mkdir -p lib/$PLTM
+ mkdir -p bin/$PLTM
+ #make
+ CC_FLAGS="-fno-rtti -fno-exceptions -fPIC -g -DLOB_SUPPORT"
+ CC_LINKS="-L../lib/$PLTM.d -ldmnative -ldmssession -ldl -lpthread"
+ CC_INCLUDES="-I../include/ -I../portlib"
+ $CC -L./lib/$PLTM -o bin/$PLTM/testexe src/dmt_test.cc src/dmt_stress.cc $CC_LINKS $CC_INCLUDES $CC_FLAGS || exit 1
+ $CC -shared $CC_INCLUDES -o plugins/$PLTM/libmandatoryconstplugin.so src/plugin_dll_test_constraint.cc $CC_FLAGS $CC_LINKS || exit
+ $CC -shared $CC_INCLUDES -o plugins/$PLTM/libtestexecplugin.so src/plugin_dll_test_exec.cc $CC_FLAGS $CC_LINKS || exit 1
+ $CC -shared $CC_INCLUDES -o plugins/$PLTM/libtestrwplugin.so src/test_rwplugin.cc $CC_FLAGS $CC_LINKS || exit 1
+ $CC -shared $CC_INCLUDES -o plugins/$PLTM/libtestdataplugin.so src/plugin_dll_test_data.cc $CC_FLAGS $CC_LINKS || exit 1
+ $CC -shared $CC_INCLUDES -o plugins/$PLTM/libtestcommitplugin.so src/plugin_dll_test_commit.cc $CC_FLAGS $CC_LINKS || exit 1
+
+ #link file system plugin .so
+ pushd plugins/x86
+ ln -s ../../../lib/x86.d/libdmfsplugin.so libdmfsplugin.so
+ popd
+
+ cp -f settings/*.ini plugins/$PLTM
+}
+
+
+if [ "$PLATFORM" == "x86" ] || [ "$PLATFORM" == "both" ]; then
+ echo build unittest for x86...
+ build x86
+fi
+
+if [ "$PLATFORM" == "xscale" ] || [ "$PLATFORM" == "both" ]; then
+ echo build unitttest for xscale
+ build xscale
+fi
+
+# create sample tree
+cd ../tools/dmt-tools
+./generateDMT $PWD/../../samples/settings/Dmt.zip || exit 1
+cd ../../samples
+mkdir -p dmt_data
+cp -f ../tools/dmt-tools/treedata/* $PWD/dmt_data/
+cp -f ../tools/dmt-tools/fstab dmt_data/
diff --git a/engine/dmlib/linux_java/samples/conui/hdr/dmSocketConnector.h b/engine/dmlib/linux_java/samples/conui/hdr/dmSocketConnector.h
new file mode 100644
index 0000000..7d258b2
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/conui/hdr/dmSocketConnector.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMSOCKETCONNECTOR_H
+#define DMSOCKETCONNECTOR_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+//--------------------------------------------------------------------------------------------------
+//
+// Module Name: dmSocketConnector.cc
+//
+// General Description: DmBrwConnector socket implementation class implementation file.
+//
+//--------------------------------------------------------------------------------------------------
+
+#include <sys/types.h> // Needed for system defined identifiers.
+#include <netinet/in.h> // Needed for internet address structure.
+#include <sys/socket.h> // Needed for socket(), bind(), etc...
+
+#include "dmvector.h"
+#include "dmt.hpp"
+#include "xpl_HTTP.h"
+
+class DmSocketConnector
+{
+ public :
+ DmSocketConnector() {
+ proxy_auth = NULL;
+ proxy_enable_check = true;
+ new_session = true;
+ portNum = "80";
+ socket_portNum = "80";
+ responseData = NULL;
+ proxy_url = NULL;
+ }
+
+ ~DmSocketConnector() {
+ if ( responseData != NULL ) {
+ free(responseData);
+ responseData = NULL;
+ }
+ }
+
+
+ SYNCML_DM_RET_STATUS_T Open(CPCHAR url, CPCHAR ConRef, int AddrType);
+
+ SYNCML_DM_RET_STATUS_T SetRequestMethod(XPL_HTTP_METHOD_T method);
+
+ SYNCML_DM_RET_STATUS_T SetRequestProperty(CPCHAR props);
+
+ SYNCML_DM_RET_STATUS_T Send(CPCHAR data, UINT32 size);
+
+ UINT32 GetResponseLength();
+
+ SYNCML_DM_RET_STATUS_T GetResponse(char * data, UINT32 size);
+
+ SYNCML_DM_RET_STATUS_T GetHeaderField(CPCHAR field, char ** value);
+
+ XPL_HTTP_CODE_T GetResponseCode();
+
+ SYNCML_DM_RET_STATUS_T Close();
+ SYNCML_DM_RET_STATUS_T CloseReq();
+ SYNCML_DM_RET_STATUS_T SetUrl(CPCHAR url, CPCHAR ConRef, int AddrType);
+
+ bool DmStringParserGetItem( DMString& strItem, DMString& strReminder, char cDelim );
+
+ bool DmParseHTTPHeader( char* strBuffer, int dataBufSize, char** strRemaining, int& lenRemaining);
+ bool SetResponseData(unsigned char* dataReceived, int len);
+
+ bool parseURL(DMString strURI, DMString& strAddrPort, DMString& strURIPath);
+ bool parseAddrPort(DMString strAddrPort, DMString& strAddr, DMString& strPort);
+ SYNCML_DM_RET_STATUS_T doSend(CPCHAR data, UINT32 size);
+ SYNCML_DM_RET_STATUS_T getResponse();
+
+ private:
+ unsigned int server_s; // Server socket descriptor
+ struct sockaddr_in server_addr; // Server Internet address
+ DMString sentBuf; // Sent buffer
+ DMString urlPath; // The path part of a URL
+ DMString portNum;
+ DMString ipAddress;
+ DMString responseCode;
+ DMString responseBody;
+ DMMap<DMString, DMString> responseHeaders;
+ UINT32 responseLength;
+ const char * proxy_auth;
+ bool proxy_enable_check;
+ bool new_session;
+ DMString socket_ipAddress;
+ DMString socket_portNum;
+ XPL_HTTP_METHOD_T requestMethod;
+ unsigned char* responseData;
+ const char * proxy_url;
+
+};
+
+DmSocketConnector * DmBrwCreateConnector();
+SYNCML_DM_RET_STATUS_T DmBrwDestroyConnector(DmSocketConnector * browser_handler);
+
+#endif
diff --git a/engine/dmlib/linux_java/samples/conui/src/dmSocketConnector.cc b/engine/dmlib/linux_java/samples/conui/src/dmSocketConnector.cc
new file mode 100644
index 0000000..c5c2e5d
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/conui/src/dmSocketConnector.cc
@@ -0,0 +1,577 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//--------------------------------------------------------------------------------------------------
+//
+// Module Name: dmSocketConnector.cpp
+//
+// General Description: DmBrwConnector socket implementation class implementation file. This allow
+// DM sent and recieve SYNCML data through HTTP protocol. This implementation is platform independent.
+//
+// Proxy Usage:
+//
+// setenv DM_PROXY_URL=123.567.28.167:1080 // please use IP address
+// setenv DM_PROXY_AUTH="Basic ZTExNjdadsfagewwer"
+//
+// Note: The sequences of letters after Basic is the B64 encoding of your
+// userID:userPW.
+//
+// Hint: Here is a web site to do B64 encoding:
+// http://www.ericphelps.com/scripting/samples/Decode.htm
+//
+//--------------------------------------------------------------------------------------------------
+
+#include <stdlib.h> // Needed for exit()
+#include <string.h> // Needed for strcpy() and strlen()
+#include <sys/types.h> // Needed for system defined identifiers.
+#include <netinet/in.h> // Needed for internet address structure.
+#include <sys/socket.h> // Needed for socket(), bind(), etc...
+#include <arpa/inet.h> // Needed for inet_ntoa()
+#include <unistd.h> // Needed for close()
+#include <stdio.h>
+
+#include "dmSocketConnector.h"
+
+#define BUF_SIZE 50000 // Buffer size
+
+static int g_nPrintfEnabled = getenv("DM_NOPRINTF") == NULL;
+
+/*
+ * Creates a socket connector.
+ *
+ * @return a socket connector.
+ */
+DmSocketConnector * DmBrwCreateConnector() {
+ if ( g_nPrintfEnabled ) printf("\nCreate Socket Connector\n");
+ DmSocketConnector * socketHandler = NULL;
+ socketHandler = new DmSocketConnector();
+ return socketHandler;
+}
+
+/*
+ * Destroy a socket connector.
+ *
+ * @param the handler to a socket connector.
+ * @return success if no error, otherwise return fail
+ */
+SYNCML_DM_RET_STATUS_T DmBrwDestroyConnector(DmSocketConnector * browser_handler) {
+ if ( g_nPrintfEnabled ) printf("Destroy Socket Connector\n");
+ if (browser_handler != NULL) {
+ delete browser_handler;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Prepare a socket connection by parsing the URL to get information such
+ * as host, port, and path.
+ *
+ * @param url the URL to be parse
+ * @param ConRef the connection reference
+ * @param AddrType the type of a host address
+ * @return success if get all connection information, otherwise return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::Open(CPCHAR url, CPCHAR ConRef, int AddrType) {
+ if ( g_nPrintfEnabled ) printf("Open URL: %s\n", url);
+ DMString strURI = url;
+ DMString strAddrPort;
+ DMString strURIPath;
+
+ if (parseURL(strURI, strAddrPort, strURIPath)) {
+ if (parseAddrPort(strAddrPort, ipAddress, portNum)) {
+ proxy_url = getenv("DM_PROXY_URL");
+ if (proxy_url != NULL) {
+ urlPath = url;
+ DMString tmpURL = proxy_url;
+ if (!parseAddrPort(tmpURL, socket_ipAddress, socket_portNum)) {
+ return SYNCML_DM_FAIL;
+ }
+ } else {
+ urlPath += "/";
+ urlPath += strURIPath;
+ socket_ipAddress = ipAddress;
+ socket_portNum = portNum;
+ }
+ return SYNCML_DM_SUCCESS;
+ }
+ }
+ return SYNCML_DM_FAIL;
+}
+
+/*
+ * Dynamically change a socket connection by parsing a new URL to get information such
+ * as host, port, and path.
+ *
+ * @param url the URL to be parse
+ * @param ConRef the connection reference
+ * @param AddrType the type of a host address
+ * @return success if get all connection information, otherwise return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::SetUrl(CPCHAR url, CPCHAR ConRef, int AddrType) {
+ if ( g_nPrintfEnabled ) printf("Set URL: %s\n", url);
+ DMString strURI = url;
+ DMString strAddrPort;
+ DMString strURIPath;
+
+ if (parseURL(strURI, strAddrPort, strURIPath)) {
+ if (proxy_url != NULL) {
+ urlPath = url;
+ } else {
+ urlPath = "/";
+ urlPath += strURIPath;
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Sets the HTTP request method such as GET and POST.
+ *
+ * @param method the method to be set
+ * @return success if the method is supported, else return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::SetRequestMethod(XPL_HTTP_METHOD_T method) {
+ requestMethod = method;
+ if ( method == XPL_HTTP_METHOD_POST ) {
+ if ( g_nPrintfEnabled ) printf("Request Method: POST CODE: %d\n\n", method);
+ sentBuf = "POST ";
+ sentBuf += urlPath;
+ sentBuf += " HTTP/1.0\r\n";
+ sentBuf += "Host: ";
+ sentBuf += socket_ipAddress;
+ sentBuf += "\r\n";
+ } else if ( method == XPL_HTTP_METHOD_GET ) {
+ if ( g_nPrintfEnabled ) printf("Request Method: GET CODE: %d\n", method);
+ sentBuf = "GET ";
+ sentBuf += urlPath;
+ sentBuf += " HTTP/1.1\r\n";
+ } else {
+ if ( g_nPrintfEnabled ) printf("Error: Request method not supported\n");
+ return SYNCML_DM_FAIL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Sets HTTP request property by appending to the sent buffer.
+ * If DM_PROXY_AUTH enviornment variable was set, it will add
+ * a proxy authorization properties in every new session.
+ *
+ * @param header_start the name of a property
+ * @param value_start_prt the value of the property
+ * @return success after append to the sent buffer.
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::SetRequestProperty(CPCHAR props) {
+ if ( g_nPrintfEnabled ) printf("Property header: %s\n", props);
+ sentBuf += props;
+
+ if (proxy_auth == NULL && proxy_enable_check) {
+ proxy_auth = getenv("DM_PROXY_AUTH"); // proxy_auth=Basic userid:passwd
+ proxy_enable_check = false;
+ }
+
+ if (proxy_auth != NULL && new_session) {
+ if ( g_nPrintfEnabled ) printf ("Property header: Proxy-Authorization=%s\n", proxy_auth);
+ sentBuf += "Proxy-Authorization";
+ sentBuf += ": ";
+ sentBuf += proxy_auth;
+ sentBuf += "\r\n";
+ new_session = false;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Send the data through socket and get the response back.
+ *
+ * @data the data to be sent
+ * @size the size of the data to be sent
+ * @return success if no error when sending and getting response, else return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::Send(CPCHAR data, UINT32 size) {
+ if (doSend(data, size) == SYNCML_DM_SUCCESS) {
+ return getResponse();
+ }
+ return SYNCML_DM_FAIL;
+}
+
+/*
+ * Return the length of the response data.
+ *
+ * @return the response data length
+ */
+UINT32 DmSocketConnector::GetResponseLength() {
+ if ( g_nPrintfEnabled ) printf("Get response data length: %d\n", responseLength);
+ return responseLength;
+}
+
+/*
+ * Get the response data.
+ *
+ * @param data the data to be fill with response data
+ * @param size the size of the data
+ * @return success if the data is filled, else return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::GetResponse(char * data, UINT32 size) {
+ char tmpBuf[50000];
+ memcpy(data, responseData, responseLength);
+ if ( requestMethod == XPL_HTTP_METHOD_POST && size < 50000 ) {
+ memcpy(tmpBuf, responseData, responseLength);
+ tmpBuf[responseLength]=0;
+ if ( g_nPrintfEnabled ) printf("\nResponse Body: %s\n", tmpBuf);
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Get the value of a HTTP header feild based on header field name.
+ *
+ * @param field the header field name
+ * @param value the value of the header field
+ * @return success if found the header field, else fail
+ *
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::GetHeaderField(CPCHAR field, char ** value) {
+ bool found = false;
+
+ for (int i = responseHeaders.begin(); i < responseHeaders.end(); i++) {
+ if (responseHeaders.get_key(i) == field) {
+ found = true;
+ break;
+ }
+ }
+
+ if (found == true) {
+ const DMString& s = responseHeaders.get(field).c_str();
+ *value = (char*)DmtMemAlloc( s.length() + 1 );
+ strcpy( *value, s );
+
+ if ( g_nPrintfEnabled ) printf("\nGet HeaderField %s : %s\n", field, *value);
+ } else {
+ if ( g_nPrintfEnabled ) printf("INFO: Can not find %s\n", field);
+ return SYNCML_DM_FAIL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Return HTTP response code such as 200, 404, and etc.
+ *
+ * @return the HTTP response code
+ */
+XPL_HTTP_CODE_T DmSocketConnector::GetResponseCode() {
+ if ( g_nPrintfEnabled ) printf("\nGet Response Code: %s \n\n", responseCode.c_str());
+ return atoi(responseCode.c_str());
+}
+
+/*
+ * Close the socket connection.
+ *
+ * @return success if socket closed, else fail.
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::Close() {
+ if ( g_nPrintfEnabled ) printf("Close Socket Connector\n");
+ int ret = close(server_s);
+ if (ret != 0) {
+ if ( g_nPrintfEnabled ) printf("ERROR: Can not close the socket.\n");
+ return SYNCML_DM_FAIL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Close current session, but leave the connection open.
+ *
+ * @return success after closed the session
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::CloseReq() {
+ if ( g_nPrintfEnabled ) printf("Close Socket Session\n");
+ new_session = true;
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Giving string and delimiter, the function will store the section of the string until the delimiter
+ * in a string item. This is similar to string tokenizer.
+ *
+ * Ex: abc:123:xyz abc,123,and xyz are tokens seperated by a delimiter ':'
+ *
+ * @param strItem the first section of the string until the delimiter
+ * @param strReminder the rest of the string without the delimiter
+ * @param cDelim the delimiter
+ *
+ */
+bool DmSocketConnector::DmStringParserGetItem( DMString& strItem, DMString& strReminder, char cDelim ) {
+ if ( strReminder[0] == 0 ) {
+ return false;
+ }
+ const char* s = strchr( strReminder, cDelim );
+ int nPos = s ? s - strReminder : -1;
+ if ( nPos < 0 ) {
+ strItem = strReminder;
+ strReminder = "";
+ } else {
+ strItem.assign( strReminder, nPos );
+ strReminder = DMString(s+1);
+ }
+ return true;
+}
+
+/*
+ * Parse a HTTP response header.
+ *
+ * @param strBuffer the received data buffer from server that may contain the entire HTTP header
+ * @param dataBufSize number of bytes contained in strBuffer
+ * @param strBufRemaining the updated buffer containging HTTP body (i.e. strBuffer - HTTP header)
+ * @param lenRemaining number of bytes in strBufRemaining
+ * @return true if HTTP header marker "\r\n\r\n" is found in strBuffer, false otherwise
+ *
+ */
+bool DmSocketConnector::DmParseHTTPHeader( char* strBuffer, int dataBufSize, char** strBufRemaining, int& lenRemaining) {
+ // Let's get the response code first
+ // If we do not see end of HTTP header, do not bother to parse
+ char* entireHeaderEnd = strstr( strBuffer, "\r\n\r\n" );
+ if ( !entireHeaderEnd )
+ return false;
+
+ // Let's get the response code by looking for first space in response
+ char* pFirstSpace = strstr( strBuffer, " ");
+ pFirstSpace++;
+ char tmpBuf[10];
+ strncpy(tmpBuf, pFirstSpace, 3);
+ tmpBuf[3]=0;
+ responseCode = tmpBuf;
+ char* curPos = strBuffer;
+ // skip one \r\n
+ char *headerEnd = strstr(curPos, "\r\n");
+ curPos = headerEnd + strlen("\r\n");
+ headerEnd = strstr(curPos, "\r\n");
+
+ // Found an HTTP Header, let's get the name and value pair
+ while ( headerEnd != NULL ) {
+ char* pColon = strchr(curPos, ':');
+ char name[256];
+ char value[256];
+ strncpy(name, curPos, pColon-curPos);
+ name[pColon-curPos]=0;
+ strncpy(value, pColon+2, headerEnd-pColon-2);
+ value[headerEnd-pColon-2]=0;
+ responseHeaders.put(name, value);
+ if ( headerEnd == entireHeaderEnd )
+ break;
+ curPos = headerEnd + strlen("\r\n");
+ headerEnd = strstr(curPos, "\r\n");
+ }
+ *strBufRemaining = entireHeaderEnd + strlen("\r\n\r\n");
+ lenRemaining = dataBufSize - (*strBufRemaining - strBuffer);
+ return true;
+}
+
+/*
+ * Parse a HTTP response header.
+ *
+ * @param newData pointer to the buffer containing data from server
+ * @param len the size of the data in the buffer
+ * @return true if data is set successfully, false if memory can not be allocated
+ */
+bool DmSocketConnector::SetResponseData(unsigned char* newData, int len) {
+ if (len == 0) {
+ return true;
+ }
+
+ if ( responseData == NULL ) {
+ responseData = (unsigned char*)malloc(len);
+ memcpy( responseData, newData, len);
+ } else {
+ unsigned char* newPtr = (unsigned char*)malloc(len + responseLength);
+ memcpy((void*)newPtr, (void*)responseData, responseLength);
+ memcpy((void*)(newPtr+responseLength), (void*)newData, len);
+ free(responseData);
+ responseData = newPtr;
+ }
+ return true;
+}
+
+/*
+ * Parse the URL into address:port and URL path.
+ *
+ * @param strURI the URI to be parse
+ * @param strAddrPort the string to store the address:port
+ * @param strURIPath the string to store the path of the URI
+ *
+ * @return true if URI was in right format, else false
+ */
+bool DmSocketConnector::parseURL(DMString strURI, DMString& strAddrPort, DMString& strURIPath) {
+ int counter = 0;
+ DMString tmpStr;
+
+ while(DmStringParserGetItem(tmpStr, strURI, '/')) {
+ if (counter == 0) {
+ if (strcmp(tmpStr.c_str(), "http:") != 0) {
+ return false;
+ }
+ } else if (counter == 1) {
+ if (tmpStr.c_str()[0]!=0/*strcmp(tmpStr.c_str(), "") !=0*/) {
+ return false;
+ }
+ } else if (counter == 2) {
+ strAddrPort = tmpStr;
+ strURIPath = strURI;
+ return true;
+ }
+ counter++;
+ }
+ return false;
+}
+
+/*
+ * Parse the address:port into address and port.
+ *
+ * @param strAddrPort the string that holds address:port
+ * @param strAddr the string that store address
+ * @param strPort the string that store port
+ *
+ * @return true after parsing
+ */
+bool DmSocketConnector::parseAddrPort(DMString strAddrPort, DMString& strAddr, DMString& strPort) {
+ int j = 0;
+ DMString tmpStr;
+ while(DmStringParserGetItem(tmpStr, strAddrPort, ':')) {
+ if (j == 0) {
+ strAddr = tmpStr;
+ } else if (j == 1) {
+ strPort = tmpStr;
+ }
+ j++;
+ }
+ return true;
+}
+
+/*
+ * Prepair HTTP sent with sent data and sent it out through socket.
+ *
+ * @param data the body of the request
+ * @param size the size of the request body
+ *
+ * @return success if it sent all data through socket, else fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::doSend(CPCHAR data, UINT32 size) {
+ unsigned int retcode; // Return code
+
+ if ( g_nPrintfEnabled ) printf("\n[Header: %d bytes]\n%s\n", strlen(sentBuf.c_str()), sentBuf.c_str());
+ if ( g_nPrintfEnabled ) printf("[Data: %d bytes]\n%s\n\n", strlen(data), data);
+
+ if (size != 0) {
+ sentBuf += "Content-length: ";
+
+ char size_str[10];
+ sprintf(size_str, "%d", size);
+
+ sentBuf += size_str;
+ sentBuf += "\r\n\r\n";
+ } else {
+ sentBuf += "Host: ";
+ sentBuf += socket_ipAddress;
+ sentBuf += "\r\n\r\n";
+ }
+
+ server_s = socket(AF_INET, SOCK_STREAM, 0);
+ server_addr.sin_family = AF_INET; // Address family to use
+
+ // Port num to use
+ server_addr.sin_port = htons(atoi(socket_portNum.c_str()));
+ // IP address to use
+ server_addr.sin_addr.s_addr = inet_addr(socket_ipAddress);
+
+ if ( g_nPrintfEnabled ) printf("Host: %s Port: %s\n", socket_ipAddress.c_str(), socket_portNum.c_str());
+
+ // Do a connect (connect() blocks)
+ retcode = connect(server_s, (struct sockaddr *)&server_addr,
+ sizeof(server_addr));
+
+ if (retcode != 0) {
+ if ( g_nPrintfEnabled ) printf("ERROR: connect() failed \n");
+ return SYNCML_DM_FAIL;
+ }
+
+ //memset(out_buf, 0, BUF_SIZE);
+ //strcpy(out_buf, sentBuf.c_str());
+
+ if ( g_nPrintfEnabled ) printf("Send Size: %d\n", size);
+ if ( g_nPrintfEnabled ) printf("\nSend\n>>> >>> >>>\n%s%s<<< <<< <<<\n", sentBuf.c_str(), data);
+
+ // Send a request to the server
+ int ret = send(server_s, sentBuf.c_str(), strlen(sentBuf.c_str()), 0);
+ ret = send(server_s, data, size, 0);
+
+ if ( g_nPrintfEnabled ) printf("Send Size: %d\n", ret);
+
+ if (ret != -1) {
+ return SYNCML_DM_SUCCESS;
+ }
+ return SYNCML_DM_FAIL;
+}
+
+/*
+ * Get HTTP response by parsing the header information and body.
+ *
+ * @return success if the response size is greater than zero, else fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::getResponse() {
+ if ( g_nPrintfEnabled ) printf("\nGet Response\n");
+ char in_buf[BUF_SIZE]; // Input buffer for response
+ bool handleHeader = true;
+ int retcode;
+ int nBufUsed = 0;
+ responseBody = "";
+ responseLength = 0;
+
+ if ( responseData != NULL ) {
+ free(responseData);
+ responseData = NULL;
+ }
+
+ retcode = recv(server_s, in_buf, BUF_SIZE, 0);
+ if ( g_nPrintfEnabled ) printf("Size: %d\n", retcode);
+
+ while ((retcode > 0) && (retcode != -1)) {
+ int lenRemaining;
+ bool bEndHeader;
+ char* strRemaining;
+
+ if ( handleHeader ) {
+ bEndHeader = DmParseHTTPHeader( in_buf, retcode, &strRemaining, lenRemaining);
+ if ( bEndHeader ) {
+ handleHeader = false;
+ SetResponseData((unsigned char*)strRemaining,lenRemaining);
+ responseLength = lenRemaining;
+ nBufUsed = 0;
+ }
+ else
+ nBufUsed += retcode;
+ } else {
+ SetResponseData((unsigned char*)in_buf,retcode);
+ responseLength += retcode;
+ }
+ retcode = recv(server_s, in_buf + nBufUsed, BUF_SIZE-nBufUsed, 0);
+ }
+
+ if ( responseLength > 0 ) {
+ return SYNCML_DM_SUCCESS;
+ } else {
+ return SYNCML_DM_FAIL;
+ }
+}
diff --git a/engine/dmlib/linux_java/samples/conui/src/xpl_HTTP.cc b/engine/dmlib/linux_java/samples/conui/src/xpl_HTTP.cc
new file mode 100644
index 0000000..6e23858
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/conui/src/xpl_HTTP.cc
@@ -0,0 +1,223 @@
+
+#include "xpl_HTTP.h"
+#include "dmSocketConnector.h"
+
+
+/* Activetes HTTP transport and set specified URL to connect with server.
+* Do not establish actual connection with server */
+XPL_HTTP_HANDLE_T XPL_HTTP_Open(CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType,
+ XPL_HTTP_RET_STATUS_T * result)
+{
+ DmSocketConnector * p = DmBrwCreateConnector();
+
+ if ( !p ) {
+ if ( result )
+ *result = XPL_HTTP_RET_FAIL;
+ return 0;
+ }
+
+ if ( p->Open(url, ConRef, addrType) != SYNCML_DM_SUCCESS ){
+ delete p;
+
+ if ( result )
+ *result = XPL_HTTP_RET_FAIL;
+
+ return 0;
+ }
+
+ if ( result )
+ *result = XPL_HTTP_RET_SUCCESS;
+
+ return (XPL_HTTP_HANDLE_T)p;
+}
+
+/* Sets method for URL request. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_SetRequestMethod(XPL_HTTP_HANDLE_T handler,
+ XPL_HTTP_METHOD_T method)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->SetRequestMethod(method) == SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+
+/* Sets a general request property.
+* This method is called before Send method */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_SetRequestProperty(XPL_HTTP_HANDLE_T handler,
+ CPCHAR buffer)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->SetRequestProperty(buffer) == SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Sends data to the resource pointed to by the URL.
+* Size specifies size of content to be sent. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_Send(XPL_HTTP_HANDLE_T handler,
+ CPCHAR buffer,
+ UINT32 size)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->Send(buffer, size) == SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Returns the response length */
+UINT32 XPL_HTTP_GetResponseLength(XPL_HTTP_HANDLE_T handler)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return 0;
+
+ return p->GetResponseLength();
+}
+
+/* Downloads the contents from the resource. The downloaded content is
+* stored in a buffer. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetResponse(XPL_HTTP_HANDLE_T handler,
+ char * buffer,
+ UINT32 size)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->GetResponse(buffer, size)== SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Method returns the value of the header for given header field. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetHeaderField(XPL_HTTP_HANDLE_T handler,
+ CPCHAR field,
+ char ** value)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->GetHeaderField(field, value)== SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Method returns the complete response header as sent by server. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetRespHeader(XPL_HTTP_HANDLE_T handler,
+ char ** header)
+{
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Method returns value of content-type in the response header. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetType(XPL_HTTP_HANDLE_T handler,
+ char ** content_type)
+{
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Gets status code from HTTP/WAP response message. Returns -1, if no code be
+* discerned from the response (i.e., the response is not valid HTTP/WAP) */
+XPL_HTTP_CODE_T XPL_HTTP_GetResponseCode(XPL_HTTP_HANDLE_T handler)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return 0;
+
+ return p->GetResponseCode();
+}
+
+/* Closes connection with server. */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_Close(XPL_HTTP_HANDLE_T handler)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ p->Close();
+ delete p;
+
+ return XPL_HTTP_RET_SUCCESS;
+}
+
+/* Closes request transaction without closing connection with server. */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_CloseReq(XPL_HTTP_HANDLE_T handler)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ p->CloseReq();
+
+ return XPL_HTTP_RET_SUCCESS;
+}
+
+/* Sets URL for new request */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_SetUrl(XPL_HTTP_HANDLE_T handler ,
+ CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->SetUrl(url, ConRef, addrType)== SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+
+/* Dowloads content from the resource. The read content is stored in the file */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DowloadByFile(XPL_HTTP_HANDLE_T handler,
+ CPCHAR file_name)
+{
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Dowloads content from the resource. The downloaded content is stored in a buffer */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DownloadByBuffer(XPL_HTTP_HANDLE_T handler,
+ UINT8 * buffer,
+ UINT32 size)
+{
+ return XPL_HTTP_RET_FAIL;
+}
+
+
+
diff --git a/engine/dmlib/linux_java/samples/conui/src/xpl_dm_ServerAlerts.cc b/engine/dmlib/linux_java/samples/conui/src/xpl_dm_ServerAlerts.cc
new file mode 100644
index 0000000..4317225
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/conui/src/xpl_dm_ServerAlerts.cc
@@ -0,0 +1,52 @@
+#include "xpl_dm_ServerAlert.h"
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowConfirmAlert(INT32 maxDisplayTime, CPCHAR msg, XPL_DM_ALERT_RES_T defaultResponse, XPL_DM_ALERT_RES_T * responseCode)
+{
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowDisplayAlert(INT32 minDisplayTime, CPCHAR msg)
+{
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowTextInputAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ CPCHAR defaultResponse,
+ INT32 maxLength,
+ XPL_DM_ALERT_INPUT_T inputType,
+ XPL_DM_ALERT_ECHO_T echoType,
+ XPL_DM_ALERT_TEXTINPUT_RES_T * userResponse )
+{
+
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowSingleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ INT32 defaultResponse,
+ XPL_DM_ALERT_SCHOICE_RES_T * userResponse )
+{
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowMultipleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ DMStringVector & defaultResponses,
+ XPL_DM_ALERT_MCHOICE_RES_T * userResponse)
+{
+
+ return SYNCML_DM_SUCCESS;
+}
+
diff --git a/engine/dmlib/linux_java/samples/ddd_test b/engine/dmlib/linux_java/samples/ddd_test
new file mode 100644
index 0000000..d5f6207
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/ddd_test
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+export dm_setting_root=$PWD/dmt_data
+export dm_setting_version="1.2"
+
+PLATFORM=$1
+if [ ".$PLATFORM" = ".xscale" ]; then
+ export LD_LIBRARY_PATH=$PWD/../lib/xscale.d:$PWD/../lib/xscale.r
+ export dm_setting_plugin=$PWD/plugins/xscale
+else
+ PLATFORM=x86
+ export LD_LIBRARY_PATH=$PWD/../lib/x86.d:$PWD/lib/../x86
+ export dm_setting_plugin=$PWD/plugins/x86
+fi
+
+ddd $PWD/bin/$PLATFORM/testexe $2
+
+
diff --git a/engine/dmlib/linux_java/samples/plugins/mandatoryconstplugin/src/plugin_dll_mandatory_constraint.cc b/engine/dmlib/linux_java/samples/plugins/mandatoryconstplugin/src/plugin_dll_mandatory_constraint.cc
new file mode 100644
index 0000000..8d59ae2
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/mandatoryconstplugin/src/plugin_dll_mandatory_constraint.cc
@@ -0,0 +1,121 @@
+#include "dmt.hpp"
+
+#include "dmMemory.h"
+#include "dmDebug.h" // debug macroses
+
+#include <stdlib.h>
+#include <string>
+#include <map>
+#include <stdio.h>
+
+#include "plugin/dmtPlugin.hpp"
+
+#define Debug printf
+
+//---------------------------Declaration----------------------
+
+PDmtErrorDescription
+DMCheckMandatoryForSingleNode(
+ const char * szPath, //Single path (removed *)
+ DMStringMap & mapParameters,
+ PDmtTree tree //Global Tree with same access rights for current session
+ )
+{
+ bool nodeExist=false;
+ int numNodes=0;
+
+ Debug("Checking single node=%s\n", szPath);
+ nodeExist=tree->IsValidNode(szPath);
+ if (nodeExist)
+ numNodes ++; //Including myself
+
+ int numPaths=0;
+ for ( DMMap<DMString, DMString>::POS it = mapParameters.begin();
+ it != mapParameters.end(); it++ )
+ {
+ DMString name = mapParameters.get_key( it );
+ //ignore value = it->second;
+
+ DMString childPath=name;
+
+ //For Relative path, start with /. Absolute path start with .
+ if (name[0] == '/')
+ {
+ childPath=szPath;
+ //childPath +="/";
+ childPath += name;
+ numPaths ++;
+ } else
+ if (name[0] != '.')
+ {
+ //other parameters, ignore for now...
+ continue;
+ }
+
+ const char * szName;
+ szName=childPath.c_str();
+ nodeExist=tree->IsValidNode(szName);
+ Debug(" Check for existence of %s=%d\n", szName, nodeExist);
+ if (nodeExist)
+ numNodes ++;
+ }
+ Debug("numNodes=%d\n", numNodes);
+ Debug("numPaths=%d\n", numPaths);
+
+ if (numNodes ==0 || numNodes== 1+ numPaths)
+ {
+ Debug("constraint Succeed\n");
+ return PDmtErrorDescription();
+ }
+ Debug("constraint Failed !!!!!!\n");
+ return PDmtErrorDescription( new DmtErrorDescription(enumDmtResult_ConstraintFailed) );
+}
+
+extern "C"
+PDmtErrorDescription DMT_PluginLib_CheckConstraint(
+ const char * path, //Node that was invoked on for that was changed
+ DMStringMap & mapParameters,
+ PDmtTree tree //Global Tree with same access rights for current session
+ )
+{
+ Debug("CheckConstraint [%s]\n", path);
+
+ if (tree == NULL)
+ {
+ //When tree is NULL, means we cannot get session/lock?
+ return PDmtErrorDescription( new DmtErrorDescription(enumDmtResult_UnableStartSession) );
+ }
+
+#if 0
+ //Test if DmtTree is OK
+ PDmtNode node;
+ PDmtErrorDescription e=tree->GetNode(
+ ".", //const char* path,
+ node //PDmtNode& ptrNode
+ );
+ if (e!=NULL)
+ {
+ printf( "Can't get node from DmtTree for %s, err=%s\n", ".", (const char*)e->GetErrorText().c_str() );
+ }
+ nodeExist=tree->IsValidNode(".");
+ Debug( " nodeExist for %s=%d\n", ".", nodeExist );
+ nodeExist=tree->IsValidNode("./SyncML");
+ Debug( " nodeExist for %s=%d\n", "./SyncML", nodeExist );
+
+#endif
+
+ //No multi node
+ return DMCheckMandatoryForSingleNode(
+ path,
+ mapParameters,
+ tree
+ );
+}
+
+
+extern "C"
+int DMT_PluginLib_GetAPIVersion(void)
+{
+ return DMT_PLUGIN_VERSION_1_1;
+}
+
diff --git a/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.mandatoryconstplugin b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.mandatoryconstplugin
new file mode 100644
index 0000000..0797781
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.mandatoryconstplugin
@@ -0,0 +1,32 @@
+#
+# DESCRIPTION:
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+#
+#####################################################################
+
+GLOBAL_DONOT_USE_SYNCML_PORT = 1
+GLOBAL_TARGET_SUBDIR := lib/dmplugins
+GLOBAL_TARGET_FILENAME := libmandatoryconstplugin.so
+GLOBAL_DIR_A=$(GLOBAL_VOBS_PREFIX)/vobs/jem/caf/dm/src
+
+GLOBAL_SUBDIRS_A = \
+plugindll/mandatoryconstplugin/src \
+
+GLOBAL_EXTRA_CC_FLAGS = \
+ -I$(DIR_DM)/api/native \
+ -I$(DIR_DM)/portlib/juix/hdr \
+ -I$(DIR_DM)/portlib/generic \
+ -I$(DIR_DM)/portlib/hdr \
+ -I$(DIR_DM)/dmengine/dm_util/hdr
+
+GLOBAL_EXTRA_LINK_FLAGS := -shared -ldmnative \
+ -Xlinker --version-script=versionscr_plugin
+
+GLOBAL_DEP_FILENAME = deps_mandatoryconstplugin
+
+include GenericMake
+
diff --git a/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testconstplugin b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testconstplugin
new file mode 100644
index 0000000..c7cac00
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testconstplugin
@@ -0,0 +1,33 @@
+#
+# DESCRIPTION:
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+#
+#####################################################################
+
+GLOBAL_DONOT_USE_SYNCML_PORT = 1
+GLOBAL_TARGET_SUBDIR := lib/dmplugins
+GLOBAL_TARGET_FILENAME := libtestconstplugin.so
+GLOBAL_DIR_A=$(GLOBAL_VOBS_PREFIX)/vobs/jem/caf/dm/src
+
+GLOBAL_SUBDIRS_A = \
+plugindll/testconstplugin/src \
+
+GLOBAL_EXTRA_CC_FLAGS = \
+ -I$(DIR_DM)/api/native \
+ -I$(DIR_DM)/portlib/hdr \
+ -I$(DIR_DM)/portlib/generic \
+ -I$(DIR_DM)/dmengine/dm_util/hdr \
+ -I$(DIR_DM)/portlib/juix/hdr
+
+
+GLOBAL_EXTRA_LINK_FLAGS := -shared -ldmnative \
+ -Xlinker --version-script=versionscr_plugin
+
+GLOBAL_DEP_FILENAME = deps_testconstplugin
+
+include GenericMake
+
diff --git a/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testdataplugin b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testdataplugin
new file mode 100644
index 0000000..6716115
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testdataplugin
@@ -0,0 +1,33 @@
+#
+# DESCRIPTION:
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+#
+#####################################################################
+
+GLOBAL_DONOT_USE_SYNCML_PORT = 1
+GLOBAL_TARGET_SUBDIR := lib/dmplugins
+GLOBAL_TARGET_FILENAME := libtestdataplugin.so
+GLOBAL_DIR_A=$(GLOBAL_VOBS_PREFIX)/vobs/jem/caf/dm/src
+
+GLOBAL_SUBDIRS_A = \
+plugindll/testdataplugin/src \
+
+GLOBAL_EXTRA_CC_FLAGS = \
+ -I$(DIR_DM)/api/native \
+ -I$(DIR_DM)/portlib/hdr \
+ -I$(DIR_DM)/portlib/generic \
+ -I$(DIR_DM)/portlib/juix/hdr \
+ -I$(DIR_DM)/dmengine/dm_util/hdr
+
+
+GLOBAL_EXTRA_LINK_FLAGS := -shared -ldmnative \
+ -Xlinker --version-script=versionscr_plugin
+
+GLOBAL_DEP_FILENAME = deps_testdataplugin
+
+include GenericMake
+
diff --git a/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testexecplugin b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testexecplugin
new file mode 100644
index 0000000..96c4198
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testexecplugin
@@ -0,0 +1,33 @@
+#
+# DESCRIPTION:
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+#
+#####################################################################
+
+GLOBAL_DONOT_USE_SYNCML_PORT = 1
+GLOBAL_TARGET_SUBDIR := lib/dmplugins
+GLOBAL_TARGET_FILENAME := libtestexecplugin.so
+GLOBAL_DIR_A=/vobs/jem/caf/dm/src
+
+GLOBAL_SUBDIRS_A = \
+plugindll/testexecplugin/src \
+
+GLOBAL_EXTRA_CC_FLAGS = \
+ -I$(DIR_DM)/api/native \
+ -I$(DIR_DM)/portlib/juix/hdr \
+ -I$(DIR_DM)/portlib/generic \
+ -I$(DIR_DM)/portlib/hdr \
+ -I$(DIR_DM)/dmengine/dm_util/hdr
+
+
+GLOBAL_EXTRA_LINK_FLAGS := -shared -ldmnative \
+ -Xlinker --version-script=versionscr_plugin
+
+GLOBAL_DEP_FILENAME = deps_testexecplugin
+
+include GenericMake
+
diff --git a/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testrwplugin b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testrwplugin
new file mode 100644
index 0000000..bb83be4
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/mkfiles/dm_make.testrwplugin
@@ -0,0 +1,60 @@
+#
+# DESCRIPTION:
+#
+########### Revision History ########################################
+#
+# Date Author Reference
+# ======== ======== ================================
+#
+#####################################################################
+
+GLOBAL_DONOT_USE_SYNCML_PORT = 1
+GLOBAL_TARGET_SUBDIR := lib/dmplugins
+GLOBAL_TARGET_FILENAME := libtestrwplugin.so
+GLOBAL_DIR_A=$(GLOBAL_VOBS_PREFIX)/vobs/jem/caf/dm/src
+
+GLOBAL_SUBDIRS_A = \
+plugindll/testrwplugin/src \
+
+GLOBAL_EXTRA_CC_FLAGS = \
+ -I$(DIR_DM)/api/native \
+ -I$(DIR_DM)/portlib/hdr \
+ -I$(DIR_DM)/portlib/generic \
+ -I$(DIR_DM)/portlib/juix/hdr \
+ -I$(DIR_DM)/dmengine/dm_util/hdr\
+ -Iportlib/hdr \
+ -Iplugin/hdr \
+ -Idmengine/hdr \
+ -Idmengine/dm_util/hdr \
+ -Idmengine/dm_persist/hdr \
+ -Idmengine/dm_security/hdr \
+ -Idmengine/dm_tnm/hdr \
+ -Idmengine/dm_ssession/hdr \
+ -Idmengine/dm_transport/hdr \
+ -Idmengine/dm_ua/hdr \
+ -Idmengine/oma_toolkit/sml/xpt/hdr \
+ -Idmengine/oma_toolkit/sml/mgr/hdr \
+ -Idmengine/oma_toolkit/sml/ghdr \
+ -Idmengine/oma_toolkit/sml/lib/hdr \
+ -Idmengine/oma_toolkit/sml/wsm/hdr \
+ -Idmengine/oma_toolkit/sml/xlt/src \
+ -Idmengine/oma_toolkit/sml/xlt/hdr \
+ -Iportlib/juix/hdr \
+ -Iportlib/generic \
+ -I$(GLOBAL_VOBS_PREFIX)/vobs/jem/caf/caf/src/api/native/include \
+ -I$(GLOBAL_VOBS_PREFIX)/vobs/jem/caf/browser/src/stackapi/impl/client/native/hdr \
+ -I$(GLOBAL_VOBS_PREFIX)/vobs/jem/caf/browser/src/stackapi/api/native \
+ -I$(GLOBAL_VOBS_PREFIX)/vobs/jem/caf/browser/src/stackapi/impl/server/hdr \
+ -Ijni/hdr \
+ -Iapi/native \
+ -Idmtapi/hdr \
+ -I$(JAVA_HOME)/include \
+ -I$(JAVA_HOME)/include/linux
+
+GLOBAL_EXTRA_LINK_FLAGS := -shared -ldmnative \
+ -Xlinker --version-script=versionscr_plugin
+
+GLOBAL_DEP_FILENAME = deps_testrwplugin
+
+include GenericMake
+
diff --git a/engine/dmlib/linux_java/samples/plugins/settings/sysplugins.ini b/engine/dmlib/linux_java/samples/plugins/settings/sysplugins.ini
new file mode 100644
index 0000000..7e05852
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/settings/sysplugins.ini
@@ -0,0 +1,31 @@
+[./DevDetail/Ext/SIMDirect]
+_data=libsimdirect_plugin.so
+
+[./DevDetail/Ext/Readings/Radio]
+_data=libradiodata_plugin.so
+
+[./DevDetail/Ext/Conf/Log/LogAcc]
+_exec=liblogaccess_plugin.so
+
+[./DevDetail/Ext/Software/SwUpdate/*/DownloadAndUpdate]
+_exec=libsrexec_plugin.so
+
+[./DevDetail/Ext/Software/SwUpdate/*/Download]
+_exec=libsrexec_plugin.so
+
+[./DevDetail/Ext/Software/SwUpdate/*/Update]
+_exec=libsrexec_plugin.so
+
+[./DevDetail/Ext/Software/FwUpdate/*/DownloadAndUpdate]
+_exec=libsrexec_plugin.so
+
+[./DevDetail/Ext/Software/FwUpdate/*/Download]
+_exec=libsrexec_plugin.so
+
+[./DevDetail/Ext/Software/FwUpdate/*/Update]
+_exec=libsrexec_plugin.so
+
+[./DevDetail/Ext/Software/JUIX]
+_data=libjavaplugin.so
+_uid=com.motorola.wireless.dm.dmt.plugin.impl.InstalledServices.InstalledServicesPlugin
+
diff --git a/engine/dmlib/linux_java/samples/plugins/settings/testplugins.ini b/engine/dmlib/linux_java/samples/plugins/settings/testplugins.ini
new file mode 100644
index 0000000..3f86d19
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/settings/testplugins.ini
@@ -0,0 +1,43 @@
+[./TestPluginNode]
+_data=libtestdataplugin.so
+/=[a|b]
+/a=leaf1
+/b=leaf2
+
+[.]
+_exec=libtestexecplugin.so
+
+
+# Test Contraint plugins means:
+# all dependent node must either ALL exist or NON-exist, i.e. current node CAN exist alone
+[./SyncML/Con/*]
+_const=libmandatoryconstplugin.so
+/PX
+/NAP
+
+[./TestRWPluginNode]
+_data=libtestrwplugin.so
+
+
+# Test for commit plug-in - for leaf node, interior node and indirect update
+[./SyncML/DMAcc/*]
+_commit=libtestcommitplugin.so
+print=on
+id=root
+
+# Test for commit plug-in - for leaf node, interior node and indirect update
+[./DMAcc/*]
+_commit=libtestcommitplugin.so
+print=on
+id=root
+
+[./UnitTest/Profiles/*/CurProfile]
+_commit=libtestcommitplugin.so
+print=on
+id=profile
+
+[./UnitTest/Profiles11/*/CurProfile]
+_commit=libtestcommitplugin.so
+print=on
+id=profile11
+
diff --git a/engine/dmlib/linux_java/samples/plugins/settings/testrwplugin.ini b/engine/dmlib/linux_java/samples/plugins/settings/testrwplugin.ini
new file mode 100644
index 0000000..94f98a7
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/settings/testrwplugin.ini
@@ -0,0 +1,6 @@
+[./TestRWPluginNode]
+_data=libtestrwplugin.so
+/=[a|b]
+/a=leaf1
+/b=leaf2
+
diff --git a/engine/dmlib/linux_java/samples/plugins/testcommitplugin/src/plugin_dll_test_commit.cc b/engine/dmlib/linux_java/samples/plugins/testcommitplugin/src/plugin_dll_test_commit.cc
new file mode 100644
index 0000000..7b1adc1
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/testcommitplugin/src/plugin_dll_test_commit.cc
@@ -0,0 +1,88 @@
+#include "dmt.hpp"
+
+#include <stdlib.h>
+#include <string>
+#include <map>
+#include <stdio.h>
+
+#include "plugin/dmtCommitPlugin.hpp"
+#include "plugin/dmtPlugin.hpp"
+
+
+#define DIM(array) (sizeof(array)/sizeof((array)[0]))
+
+
+extern "C"
+void DMT_PluginLib_OnCommit(const DmtEventMap & updatedNodes,
+ DMStringMap & mapParameters,
+ PDmtTree tree )
+{
+
+ DMString strParam;
+ int bPrint = (mapParameters.lookup("print", strParam) && strParam == "on" );
+
+ if ( !bPrint )
+ return;
+
+ mapParameters.lookup("id", strParam);
+ printf( "Commit plug-in: OnCommit [%s]<START> \n", strParam.c_str() );
+
+ for (DmtEventMap::POS nPos = 0; nPos < updatedNodes.end(); nPos++ )
+ {
+ const DMString & eventPath = updatedNodes.get_key(nPos);
+ const DmtEventDataVector & aVector = updatedNodes.get_value(nPos);
+
+ for (INT32 index=0; index<aVector.size(); index++)
+ {
+
+ DMString szActions;
+ if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_ADD) == SYNCML_DM_EVENT_ADD )
+ {
+ szActions = "ADD";
+ printf( "notification for uri [%s/%s], [%s]\n",
+ eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() );
+ }
+
+ if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_REPLACE) == SYNCML_DM_EVENT_REPLACE )
+ {
+ szActions = "REPLACE";
+ printf( "notification for uri [%s/%s], [%s]\n",
+ eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() );
+ }
+
+ if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_DELETE) == SYNCML_DM_EVENT_DELETE )
+ {
+ szActions = "DELETE";
+ printf( "notification for uri [%s/%s], [%s]\n",
+ eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() );
+ }
+
+ if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_RENAME) == SYNCML_DM_EVENT_RENAME )
+ {
+ szActions = "RENAME";
+ printf( "notification for uri [%s/%s], [%s]\n",
+ eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() );
+ }
+
+ if ( (aVector[index]->GetAction() & SYNCML_DM_EVENT_INDIRECT) == SYNCML_DM_EVENT_INDIRECT )
+ {
+ szActions = "INDIRECT UPDATE";
+ printf( "notification for uri [%s/%s], [%s]\n",
+ eventPath.c_str(), (aVector[index]->GetName()).c_str(), szActions.c_str() );
+ }
+
+ };
+
+
+ }
+ printf( "Commit plug-in: OnCommit <END> \n");
+}
+
+
+extern "C"
+int DMT_PluginLib_GetAPIVersion(void)
+{
+ return DMT_PLUGIN_VERSION_1_1;
+}
+
+
diff --git a/engine/dmlib/linux_java/samples/plugins/testconstplugin/src/plugin_dll_test_constraint.cc b/engine/dmlib/linux_java/samples/plugins/testconstplugin/src/plugin_dll_test_constraint.cc
new file mode 100644
index 0000000..08fb235
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/testconstplugin/src/plugin_dll_test_constraint.cc
@@ -0,0 +1,110 @@
+#include "dmt.hpp"
+
+#include <stdlib.h>
+#include <string>
+#include <map>
+#include <stdio.h>
+
+#include "plugin/dmtPlugin.hpp"
+
+#define Debug printf
+
+/*
+Plugin Ini Format:
+
+
+[./DevDetail/xxx/Node Path]
+constraint=xxxx.so
+
+./DevDetail/interiornode=
+/interiornode/leafnode2=
+
+*/
+
+extern "C"
+SYNCML_DM_RET_STATUS_T DMT_PluginLib_CheckConstraint(
+ CPCHAR path, //This is the path that matches the ini file parameter
+ DMStringMap& mapParameters,
+ PDmtTree tree //Global Tree with same access rights for current session
+ )
+{
+ if (tree == NULL)
+ {
+ //When tree is NULL, means we cannot get session/lock?
+ return (SYNCML_DM_FAIL);
+ }
+ bool nodeExist=false;
+
+#if 0
+ //Test if DmtTree is OK
+ PDmtNode node;
+ PDmtErrorDescription e=tree->GetNode(
+ ".", //const char* path,
+ node //PDmtNode& ptrNode
+ );
+ if (e!=NULL)
+ {
+ printf( "Can't get node from DmtTree for %s, err=%s\n", ".", (const char*)e->GetErrorText().c_str() );
+ }
+ nodeExist=tree->IsValidNode(".");
+ Debug( " nodeExist for %s=%d\n", ".", nodeExist );
+ nodeExist=tree->IsValidNode("./SyncML");
+ Debug( " nodeExist for %s=%d\n", "./SyncML", nodeExist );
+
+#endif
+
+ Debug("CheckConstraint for path %s tree=0x%x\n", path, tree.GetPtr() );
+
+ int numPaths=0; //How many in parameters
+ int numNodes=0; //How many exists
+
+ for ( DMMap<DMString, DMString>::POS it = mapParameters.begin(); it != mapParameters.end(); it++ )
+ {
+ DMString paramName = mapParameters.get_key( it );
+ DMString paramValue= mapParameters.get_value( it );
+
+ const char * pName=paramName.c_str();
+
+ if (* pName !='.' && * pName !='/' )
+ continue;
+
+ numPaths++;
+
+ DMString strPath;
+ if (* pName =='.')
+ strPath=paramName; //Absolute path
+ else //(* pName =='/') //Relative path
+ {
+ strPath +=path;
+ if ( (* (pName+1)) !='\0' )
+ strPath +=pName; // pName already started with "/", no need for
+ }
+ const char * szPath=strPath.c_str();
+
+ //Debug("szPath.len=%d\n", strlen(szPath));
+ nodeExist=tree->IsValidNode(szPath);
+ Debug("check for isValidNode of %s nodeExist=%d\n", szPath, nodeExist);
+
+ if (nodeExist)
+ {
+ Debug(" %s isValidNode\n", szPath);
+ numNodes++;
+ }
+ }
+ Debug("numNodes=%d\n", numNodes);
+ if (numNodes ==0 || numNodes== numPaths)
+ {
+ Debug("constraint Succeed\n");
+ return (SYNCML_DM_SUCCESS);
+ }
+ Debug("constraint Failed !!!!!!\n");
+ return (SYNCML_DM_CONSTRAINT_FAIL);
+}
+
+
+extern "C"
+int DMT_PluginLib_GetAPIVersion(void)
+{
+ return DMT_PLUGIN_VERSION_1_1;
+}
+
diff --git a/engine/dmlib/linux_java/samples/plugins/testdataplugin/src/plugin_dll_test_data.cc b/engine/dmlib/linux_java/samples/plugins/testdataplugin/src/plugin_dll_test_data.cc
new file mode 100644
index 0000000..c07a79d
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/testdataplugin/src/plugin_dll_test_data.cc
@@ -0,0 +1,169 @@
+#include "dmt.hpp"
+
+#include <stdio.h>
+
+#include "jem_defs.hpp"
+#include "dmt.hpp"
+
+#include "plugin/dmtPlugin.hpp"
+
+//#define Debug printf
+#define Debug //
+
+//
+// Plugin DLL
+//
+
+/*
+Plugin Ini Format:
+
+
+[./DevDetail/xxx/Node Path]
+data=xxxx.so
+
+/=[interiornode|leafnode]
+/interiornode=[leafnode2|leafnode3]
+/interiornode/leafnode2=123
+/interiornode/leafnode3=abc
+/leafnode=my leaf node
+
+*/
+
+static bool DmStringParserGetItem( DMString& strItem, DMString& strReminder, char cDelim )
+{
+ if ( strReminder[0] == 0 )
+ return false;
+
+ const char* s = strchr( strReminder, cDelim );
+ int nPos = s ? s - strReminder : -1; //strReminder.find( cDelim );
+
+ if ( nPos < 0 ){
+ strItem = strReminder;
+ strReminder = "";
+ }
+ else {
+ strItem.assign( strReminder, nPos );
+ //strReminder.erase( 0, nPos+1 );
+ strReminder = DMString(s+1);
+ }
+ return true;
+}
+
+static int DmStrToStringVector(const char * pStr, int nLen, DMStringVector& oVector, char cDelim )
+{
+ DMString strChild, strList; // = (const char*)pStr;
+ if (nLen >0)
+ {
+ strChild= DMString((const char*)pStr, nLen);
+ strList= DMString((const char*)pStr, nLen);
+ } else
+ {
+ strChild= (const char*)pStr;
+ strList = (const char*)pStr;
+ }
+
+ int i=0;
+ while ( DmStringParserGetItem( strChild, strList, cDelim ) )
+ {
+ oVector.push_back(strChild);
+ i++;
+ }
+ return i;
+}
+
+extern "C"
+SYNCML_DM_RET_STATUS_T DMT_PluginLib_Data_GetPluginTree(
+ CPCHAR pluginRootNodePath,
+ DMStringMap & mapParameters, //For the Tree
+ PDmtAPIPluginTree & pPluginTree //root tree for the current path
+)
+{
+ SYNCML_DM_RET_STATUS_T status = SYNCML_DM_SUCCESS;
+
+ Debug("DMT_PluginLib_Data_GetTree, pluginRootNodePath=%s\n", pluginRootNodePath);
+
+ PDmtPluginTree pMyTree=new DmtPluginTree();
+ pMyTree->Init(pluginRootNodePath);
+ int numNodes=0;
+
+ for ( DMMap<DMString, DMString>::POS it = mapParameters.begin(); it != mapParameters.end(); it++ )
+ {
+ DMString paramName = mapParameters.get_key( it );
+ DMString paramValue= mapParameters.get_value( it );
+
+ const char * pName=paramName.c_str();
+
+ //In parameter file, node name MUST start with /
+ PDmtPluginNode pNode;
+ Debug("parameter %s=%s\n", pName, paramValue.c_str());
+
+ if (pName[0]=='/')
+ {
+ pName++; //Plugin Node path is still relative path when created.
+
+ const char * pValue=paramValue.c_str();
+ if (pValue[0]=='[')
+ {
+ //Interior node
+ pValue++;
+ int len=strlen(pValue);
+ if ( pValue[len-1]==']')
+ {
+ len--;
+ }
+
+ DMStringVector oChildren;
+ DmStrToStringVector( pValue, //const char * pStr,
+ len,
+ oChildren, //DMStringVector oVector,
+ '|' //char cDelim
+ );
+
+ pNode=PDmtPluginNode(new DmtPluginNode());
+
+ pNode->Init(pMyTree, pName, oChildren);
+ Debug("Add Interior Plugin Node %s\n", pName);
+ pMyTree->SetNode(pName,
+ PDmtNode(pNode.GetPtr())
+ );
+ numNodes++;
+ } else
+ {
+ //leaf node
+
+ pNode=PDmtPluginNode(new DmtPluginNode());
+ pNode->Init(pMyTree, pName, DmtData(paramValue.c_str()));
+
+ Debug("Add Leaf Plugin Node %s\n", pName);
+ pMyTree->SetNode(pName,
+ PDmtNode(pNode.GetPtr())
+ );
+ numNodes++;
+ }
+ }
+ }
+
+ if (numNodes==0)
+ {
+ const char * pName="";
+ PDmtPluginNode pNode;
+
+ DMStringVector oChildren;
+ pNode=PDmtPluginNode(new DmtPluginNode());
+ pNode->Init(pMyTree, pName, oChildren);
+
+ Debug("No parameters found, Add a default Root Plugin Node %s\n", pName);
+ pMyTree->SetNode(pName,
+ PDmtNode(pNode.GetPtr())
+ );
+ }
+
+ pPluginTree=pMyTree;
+ return status;
+}
+
+extern "C"
+int DMT_PluginLib_GetAPIVersion(void)
+{
+ return DMT_PLUGIN_VERSION_1_1;
+}
diff --git a/engine/dmlib/linux_java/samples/plugins/testexecplugin/src/plugin_dll_test_exec.cc b/engine/dmlib/linux_java/samples/plugins/testexecplugin/src/plugin_dll_test_exec.cc
new file mode 100644
index 0000000..3234971
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/testexecplugin/src/plugin_dll_test_exec.cc
@@ -0,0 +1,86 @@
+#include "dmt.hpp"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+#include "plugin/dmtPlugin.hpp"
+
+#define Debug printf
+//#define Debug //
+
+//---------------------------Declaration----------------------
+
+extern "C"
+SYNCML_DM_RET_STATUS_T DMT_PluginLib_Execute2(
+ const char * path,
+ DMMap<DMString, DMString> & mapParameters,
+ const char * args,
+ CPCHAR szCorrelator,
+ PDmtTree tree,
+ DMString & results
+)
+{
+ if (args==NULL || strlen(args)==0 )
+ {
+ Debug("No arguments\n");
+ results += ("No argument specified");
+ return SYNCML_DM_SUCCESS;
+ }
+
+ Debug("execute path=%s args=%s\n", path, args);
+
+ DMString cmd;
+ cmd=args;
+ cmd += " > ";
+
+ //cmd += "/tmp/dmt_execute_result.txt";
+ char tmpn[100]="/tmp/dmt_execute_";
+ //strcat(tmpn,tmpnam(NULL));
+ tmpnam(tmpn);
+ //Debug("tmpn=%s\n", tmpn);
+
+ cmd += tmpn;
+
+ //int res=system(args);
+ int res=system(cmd.c_str());
+ //Debug("res=%d\n", res);
+
+ //char resstr[20];
+ //sprintf(resstr, "res=%d\n", res);
+ //results.append(resstr);
+
+ FILE * fp=fopen(tmpn, "r+b");
+ if (fp!=NULL)
+ {
+ //Debug("fp=0x%x\n", fp);
+ char buf[1024];
+ int n=fread(buf, 1, sizeof(buf)-1, fp);
+ buf[n]=0;
+ //Debug("bytes read=%d\n", n);
+ if (n>=0)
+ {
+ results += (buf);
+ //std::string s(buf);
+ //results=s;
+ }
+ fclose(fp);
+
+ //
+ unlink(tmpn);
+ } else
+ {
+ results += ("No result");
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+
+extern "C"
+int DMT_PluginLib_GetAPIVersion(void)
+{
+ return DMT_PLUGIN_VERSION_1_1;
+}
+
diff --git a/engine/dmlib/linux_java/samples/plugins/testrwplugin/src/test_rwplugin.cc b/engine/dmlib/linux_java/samples/plugins/testrwplugin/src/test_rwplugin.cc
new file mode 100644
index 0000000..9036e8f
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/plugins/testrwplugin/src/test_rwplugin.cc
@@ -0,0 +1,615 @@
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include "stdio.h"
+#include "dmt.hpp"
+
+#include "jem_defs.hpp"
+#include "dmt.hpp"
+
+#include "plugin/dmtRWPlugin.hpp"
+#include "SyncML_DM_FileHandle.H"
+#include "xpl_File.h"
+
+
+//---------------------------Declaration----------------------
+class testRWPluginTree;
+class testRWPluginNode;
+
+typedef JemSmartPtr< testRWPluginTree > PtestRWPluginTree;
+typedef JemSmartPtr< testRWPluginNode >PtestRWPluginNode;
+
+// PlugIn Tree
+class testRWPluginTree : public DmtRWPluginTree
+{
+
+public:
+ testRWPluginTree(const char * rootPath);
+ ~testRWPluginTree();
+ SYNCML_DM_RET_STATUS_T DeleteNode( const char* path );
+ SYNCML_DM_RET_STATUS_T CreateInteriorNode( const char* path, PDmtNode& ptrCreatedNode );
+ SYNCML_DM_RET_STATUS_T CreateLeafNode( const char* path, PDmtNode& ptrCreatedNode, const DmtData& value, BOOLEAN isESN);
+ SYNCML_DM_RET_STATUS_T CreateInteriorNodeInternal( const char* path, PDmtNode& ptrCreatedNode, const DMStringVector & childNodeNames);
+ SYNCML_DM_RET_STATUS_T CreateLeafNodeInternal( const char* path, PDmtNode& ptrCreatedNode, const DmtData& value, BOOLEAN isESN );
+
+};
+
+class testRWPluginNode : public DmtRWPluginNode
+{
+public:
+ testRWPluginNode( //Leaf Node
+ PDmtPluginTree ptrTree,
+ const char* path,
+ const DmtData & oData,
+ BOOLEAN isESN
+ );
+
+ testRWPluginNode( //Interior Node
+ PDmtPluginTree ptrTree,
+ const char* path,
+ const DMStringVector & childNodeNames
+ );
+ SYNCML_DM_RET_STATUS_T GetValue( DmtData& oData ) const;
+ SYNCML_DM_RET_STATUS_T SetValue( const DmtData& value );
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T GetFirstChunk(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T GetNextChunk(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T SetFirstChunk(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T SetNextChunk(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T SetLastChunk(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T Delete();
+ SYNCML_DM_RET_STATUS_T Commit();
+#endif
+protected:
+ ~testRWPluginNode();
+ private:
+#ifdef LOB_SUPPORT
+ SYNCML_DM_RET_STATUS_T SetChunkData(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T GetChunkData(DmtDataChunk& chunkData);
+ SYNCML_DM_RET_STATUS_T OpenInternalStorageFile();
+ SYNCML_DM_RET_STATUS_T CloseInternalFile();
+ DMString abStorageName;
+ UINT32 totalSize;
+ DMFileHandler *fileHandle;
+ UINT32 offset;
+#endif
+};
+
+testRWPluginTree::testRWPluginTree(const char * rootPath):DmtRWPluginTree()
+{
+ Init(rootPath);
+}
+testRWPluginTree::~testRWPluginTree()
+{
+}
+
+SYNCML_DM_RET_STATUS_T testRWPluginTree::DeleteNode( const char* path )
+{
+ PDmtErrorDescription e= DmtRWPluginTree::DeleteNode(path);
+ return e.GetErrorCode();
+}
+
+SYNCML_DM_RET_STATUS_T testRWPluginTree::CreateInteriorNodeInternal( const char* path, PDmtNode& ptrCreatedNode, const DMStringVector & childNodeNames )
+{
+ PtestRWPluginNode pNode;
+//Interior node
+ pNode=new testRWPluginNode(this,
+ path, //RootNode is interior node
+ childNodeNames
+ );
+ PDmtErrorDescription e = this->SetNode(path,
+ PDmtNode(pNode.GetPtr())
+ );
+ ptrCreatedNode = pNode;
+ return e.GetErrorCode();
+}
+
+SYNCML_DM_RET_STATUS_T testRWPluginTree::CreateLeafNodeInternal( const char* path, PDmtNode& ptrCreatedNode, const DmtData& value, BOOLEAN isESN )
+{
+ PtestRWPluginNode pNode;
+//Leaf node
+ pNode=new testRWPluginNode(
+ this,
+ path,
+ value,
+ isESN
+ );
+ PDmtErrorDescription e = this->SetNode(path,
+ PDmtNode(pNode.GetPtr())
+ );
+// return GetNode( path, ptrCreatedNode );
+ ptrCreatedNode = pNode;
+ return e.GetErrorCode();
+
+}
+
+SYNCML_DM_RET_STATUS_T testRWPluginTree::CreateInteriorNode( const char* path, PDmtNode& ptrCreatedNode )
+{
+ return DmtRWPluginTree::CreateInteriorNode(path, ptrCreatedNode);
+}
+SYNCML_DM_RET_STATUS_T testRWPluginTree::CreateLeafNode( const char* path, PDmtNode& ptrCreatedNode, const DmtData& value, BOOLEAN isESN )
+{
+ return DmtRWPluginTree::CreateLeafNode(path, ptrCreatedNode, value, isESN);
+
+}
+
+/*testRWPluginNode::testRWPluginNode(
+ PDmtPluginTree ptrTree,
+ const char* path
+) : DmtRWPluginNode((DmtRWPluginTree *) ((DmtPluginTree *)(ptrTree)), path, DmtData(""))
+{
+}
+*/
+testRWPluginNode::testRWPluginNode(
+ PDmtPluginTree ptrTree,
+ const char* path,
+ const DmtData & oData,
+ BOOLEAN isESN
+)
+{
+ Init(ptrTree, path, oData, isESN);
+#ifdef LOB_SUPPORT
+ abStorageName = NULL;
+ totalSize = 0L;
+ fileHandle = NULL;
+ offset = 0;
+#endif
+}
+testRWPluginNode::testRWPluginNode( //Interior Node
+ PDmtPluginTree ptrTree,
+ const char* path,
+ const DMStringVector & childNodeNames
+)
+{
+ Init(ptrTree, path, childNodeNames);
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::~destructor
+// DESCRIPTION :
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+testRWPluginNode::~testRWPluginNode()
+{
+#ifdef LOB_SUPPORT
+ CloseInternalFile();
+ abStorageName = NULL;
+#endif
+}
+SYNCML_DM_RET_STATUS_T testRWPluginNode::GetValue( DmtData& oData ) const
+{
+ return DmtPluginNode::GetValue(oData);
+}
+
+SYNCML_DM_RET_STATUS_T testRWPluginNode::SetValue( const DmtData& value )
+{
+ return DmtRWPluginNode::SetValue(value);
+}
+#ifdef LOB_SUPPORT
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::GetChunkData
+// DESCRIPTION : Get chunk data
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::GetChunkData(DmtDataChunk& chunkData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ UINT32 remainlLen = totalSize- offset;
+ UINT32 getLen = 0L;
+ UINT8 *bufp;
+
+ retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ if(fileHandle == NULL)
+ {
+ chunkData.SetChunkData(NULL, 0L);
+ chunkData.SetReturnLen(getLen);
+ return retStatus;
+ }
+ chunkData.GetChunkData(&bufp);
+ if(remainlLen <0|| bufp == NULL)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ if(remainlLen == 0)
+ {
+ chunkData.SetChunkData(NULL, 0L);
+ chunkData.SetReturnLen(remainlLen);
+ CloseInternalFile();
+ return SYNCML_DM_SUCCESS;
+ }
+
+ getLen = chunkData.GetChunkSize();
+ if(getLen > remainlLen)
+ getLen = remainlLen;
+
+ chunkData.GetChunkData(&bufp); // the chunk data is available
+ if(bufp == NULL)
+ return SYNCML_DM_INVALID_PARAMETER;
+ if(fileHandle->seek(XPL_FS_SEEK_SET, offset) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ if(fileHandle->read(bufp, getLen) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ chunkData.SetReturnLen(getLen);
+ offset += getLen;
+
+ return retStatus;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::GetFirstChunk
+// DESCRIPTION : Get next chunk
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::GetFirstChunk(DmtDataChunk& chunkData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = DmtRWPluginNode::GetFirstChunk(chunkData);
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ return GetChunkData(chunkData);
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::GetNextChunk
+// DESCRIPTION : Get next chunk
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::GetNextChunk(DmtDataChunk& chunkData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = DmtRWPluginNode::GetNextChunk(chunkData);
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ return GetChunkData(chunkData);
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::SetChunkData
+// DESCRIPTION : Set chunk data for an ESN
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::SetChunkData(DmtDataChunk& chunkData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ UINT32 dataLen;
+ UINT8 *bufp;
+
+ chunkData.GetChunkDataSize(dataLen);
+
+ // No internal file created yet
+ if(abStorageName.length() == 0) {
+ retStatus = DMFileHandler::createTempESNFileName(abStorageName);
+ abStorageName += ".lob";
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ }
+ else// Replace previous data
+ {
+ // Set first trunk
+ if(offset == 0)
+ { totalSize = 0L;
+
+ // Remove the current data file
+ retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ retStatus = fileHandle->deleteFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ delete fileHandle;
+ fileHandle = NULL;
+
+ }
+ }
+
+ if(dataLen != 0)
+ {
+ retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ chunkData.GetChunkData(&bufp); // the chunk data is available
+ if(fileHandle == NULL ||bufp == NULL)
+ return SYNCML_DM_INVALID_PARAMETER;
+
+ if(fileHandle->seek(XPL_FS_SEEK_SET, offset) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ if(fileHandle->write(bufp, dataLen) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ }
+ totalSize = offset + dataLen;
+ offset += dataLen;
+
+ m_oAttr.SetSize(totalSize);
+ chunkData.SetReturnLen(dataLen);
+ return retStatus;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::SetFirstChunk
+// DESCRIPTION : Set first chunk
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::SetFirstChunk(DmtDataChunk& chunkData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = DmtRWPluginNode::SetFirstChunk(chunkData);
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ return SetChunkData(chunkData);
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::SetNextChunk
+// DESCRIPTION : Get first chunk
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::SetNextChunk(DmtDataChunk& chunkData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = DmtRWPluginNode::SetNextChunk(chunkData);
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ return SetChunkData(chunkData);
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::SetLastChunk
+// DESCRIPTION : Set last chunk of data
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::SetLastChunk(DmtDataChunk& chunkData)
+{
+ SYNCML_DM_RET_STATUS_T retStatus = DmtRWPluginNode::SetLastChunk(chunkData);
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ retStatus = SetChunkData(chunkData);;
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ retStatus = CloseInternalFile();
+ return retStatus;
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::CloseInternalFile
+// DESCRIPTION : Open intenal storage file
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::CloseInternalFile()
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ if (fileHandle != NULL)
+ {
+ fileHandle->close();
+ delete fileHandle;
+ fileHandle = NULL;
+ }
+ offset = 0;
+ return retStatus;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::Commit
+// DESCRIPTION : Commit changes of the node
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::Commit()
+{
+ SYNCML_DM_RET_STATUS_T retStatus = DmtRWPluginNode::Commit();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ return CloseInternalFile();
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : testRWPluginNode::Delete
+// DESCRIPTION : Delete the node
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T testRWPluginNode::Delete()
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ if(abStorageName.length() != 0)
+ {
+ retStatus = OpenInternalStorageFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+
+ retStatus = fileHandle->deleteFile();
+ if(retStatus != SYNCML_DM_SUCCESS)
+ return retStatus;
+ delete fileHandle;
+ fileHandle = NULL;
+ abStorageName = NULL;
+ }
+ return retStatus;
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginTree::IsESNSetComplete
+// DESCRIPTION : Open intenal storage file
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+//
+SYNCML_DM_RET_STATUS_T testRWPluginNode::OpenInternalStorageFile()
+{
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+ struct stat st;
+
+ // If the file is not opened before
+ if(fileHandle == NULL)
+ {
+ if(abStorageName.length() != 0) {
+
+ INT32 modeFlag = XPL_FS_FILE_RDWR;
+ // If file does not exist use write mode instead of read/write to prevent file I/O error
+// if (!XPL_FS_Exist(abStorageName.c_str()))
+ if(stat(abStorageName.c_str(), &st) < 0)
+ {
+ modeFlag = XPL_FS_FILE_WRITE;
+ }
+ fileHandle = new DMFileHandler(abStorageName.c_str());
+ if (fileHandle->open(modeFlag) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ totalSize = fileHandle->size();
+ }
+ else
+ totalSize = 0;
+ }
+ return retStatus;
+}
+#endif
+
+
+extern "C"
+SYNCML_DM_RET_STATUS_T DMT_PluginLib_Data_GetPluginTree(
+ CPCHAR pluginRootNodePath,
+ DMStringMap & mapParameters, //For the Tree
+ PDmtAPIPluginTree & pPluginTree //root tree for the current path
+)
+{
+// PDmtPluginTree pMyTree=PDmtRWPluginTree(new DmtRWPluginTree(pluginRootNodePath));
+ PDmtPluginTree pMyTree= PDmtPluginTree (new testRWPluginTree(pluginRootNodePath));
+
+ PtestRWPluginNode pNode;
+
+ DMStringVector oChildren;
+ oChildren.push_back("branch1");
+// oChildren.push_back("branch2");
+
+//Interior node
+ pNode=new testRWPluginNode(pMyTree,
+ "", //RootNode is interior node
+ oChildren
+ );
+ pMyTree->SetNode("",
+ PDmtNode(pNode.GetPtr())
+ );
+ DMStringVector oChildren1;
+ oChildren1.push_back("char");
+ oChildren1.push_back("int");
+ oChildren1.push_back("lob");
+ oChildren1.push_back("lobbin");
+ oChildren1.push_back("FloatLeaf");
+ oChildren1.push_back("DateLeaf");
+ oChildren1.push_back("TimeLeaf");
+
+//Interior node
+ pNode=new testRWPluginNode(pMyTree,
+ "branch1", //RootNode is interior node
+ oChildren1
+ );
+ pMyTree->SetNode("branch1",
+ PDmtNode(pNode.GetPtr())
+ );
+
+//Leaf node
+ pNode=new testRWPluginNode(
+ pMyTree,
+ "branch1/char",
+ DmtData("char_value"),
+ false
+ );
+ pMyTree->SetNode("branch1/char",
+ PDmtNode(pNode.GetPtr())
+ );
+ // Integer node
+ pNode=new testRWPluginNode(
+ pMyTree,
+ "branch1/int",
+ DmtData(1234),
+ false
+ );
+ pMyTree->SetNode("branch1/int",
+ PDmtNode(pNode.GetPtr())
+ );
+//ESN node of char type
+ pNode=new testRWPluginNode(
+ pMyTree,
+ "branch1/lob",
+ DmtData(),
+ true
+ );
+ pMyTree->SetNode("branch1/lob",
+ PDmtNode(pNode.GetPtr())
+ );
+ // Binary ESN node
+ pNode=new testRWPluginNode(
+ pMyTree,
+ "branch1/lobbin",
+ DmtData(NULL, 0),
+ true
+ );
+ pMyTree->SetNode("branch1/lobbin",
+ PDmtNode(pNode.GetPtr())
+ );
+
+ pNode=new testRWPluginNode(
+ pMyTree,
+ "branch1/FloatLeaf",
+ DmtData("-1.23456e+2", SYNCML_DM_DATAFORMAT_FLOAT),
+ false
+ );
+ pMyTree->SetNode("branch1/FloatLeaf",
+ PDmtNode(pNode.GetPtr())
+ );
+
+ pNode=new testRWPluginNode(
+ pMyTree,
+ "branch1/DateLeaf",
+ DmtData("2005-10-18", SYNCML_DM_DATAFORMAT_DATE),
+ false
+ );
+ pMyTree->SetNode("branch1/DateLeaf",
+ PDmtNode(pNode.GetPtr())
+ );
+
+ pNode=new testRWPluginNode(
+ pMyTree,
+ "branch1/TimeLeaf",
+ DmtData("11:38:58", SYNCML_DM_DATAFORMAT_TIME),
+ false
+ );
+ pMyTree->SetNode("branch1/TimeLeaf",
+ PDmtNode(pNode.GetPtr())
+ );
+
+ pPluginTree=pMyTree;
+ return SYNCML_DM_SUCCESS;
+}
+
+extern "C"
+int DMT_PluginLib_GetAPIVersion(void)
+{
+ return DMT_PLUGIN_VERSION_1_1;
+}
+
diff --git a/engine/dmlib/linux_java/samples/portlib/src/xpl_Logger.cc b/engine/dmlib/linux_java/samples/portlib/src/xpl_Logger.cc
new file mode 100644
index 0000000..67caa75
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/portlib/src/xpl_Logger.cc
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <syslog.h>
+
+#include "xpl_Logger.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static int logIndex;
+static bool logOpened;
+
+static const char *const logName[] = {
+ "DM_API",
+ "DM_TMN",
+ "DM_PLG",
+ "DM_SESS",
+ "DM_CONN",
+ "DM_XPL",
+ "DM_CP"
+};
+
+static void _log(int level, CPCHAR format, va_list ap);
+
+
+
+void XPL_LOG_Startup()
+{
+}
+
+void XPL_LOG_Shutdown()
+{
+}
+
+void XPL_LOG_Debug(XPL_LOGS_PORT_T logPort,CPCHAR format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ _log(LOG_DEBUG, format, ap);
+ va_end(ap);
+}
+
+void XPL_LOG_Warn(XPL_LOGS_PORT_T logPort,CPCHAR format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ _log(LOG_WARNING, format, ap);
+ va_end(ap);
+}
+
+void XPL_LOG_Error(XPL_LOGS_PORT_T logPort,CPCHAR format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ _log(LOG_ERR, format, ap);
+ va_end(ap);
+}
+
+
+void XPL_LOG_Add(XPL_PORT_T logPort)
+{
+ logIndex = logPort;
+}
+
+void _log(int level, CPCHAR format, va_list ap) {
+ vprintf(format, ap);
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/linux_java/samples/portlib/src/xpl_dm_Notifications.cc b/engine/dmlib/linux_java/samples/portlib/src/xpl_dm_Notifications.cc
new file mode 100644
index 0000000..9aaf592
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/portlib/src/xpl_dm_Notifications.cc
@@ -0,0 +1,43 @@
+#include "xpl_dm_Notifications.h"
+#include "dmt.hpp"
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void XPL_DM_NotifyTreeUpdate(CPCHAR szTopic,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_TYPE_T nType,
+ UINT8 * pData,
+ UINT32 size)
+{
+ DmtEventMap aEventMap;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ dm_stat = DmtTreeFactory::ParseUpdateEvent(pData,size,aEventMap);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return;
+ for ( DmtEventMap::POS nPos = 0; nPos < aEventMap.end(); nPos++ )
+ {
+ const DMString & pParent = aEventMap.get_key(nPos);
+ printf( "OnTreeSaved, parent uri %s\n", pParent.c_str() );
+ }
+}
+
+void XPL_DM_NotifySessionProgress(BOOLEAN bIsStarted)
+{
+ if (bIsStarted)
+ printf("Server Session started\n");
+ else
+ printf("Server Session stopped\n");
+
+}
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/dmlib/linux_java/samples/run_test b/engine/dmlib/linux_java/samples/run_test
new file mode 100644
index 0000000..b3ee7a1
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/run_test
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+export dm_setting_root=$PWD/dmt_data
+export dm_setting_version="1.2"
+
+PLATFORM=$1
+if [ ".$PLATFORM" = ".xscale" ]; then
+ export LD_LIBRARY_PATH=$PWD/../lib/xscale.d:$PWD/../lib/xscale.r
+ export dm_setting_plugin=$PWD/plugins/xscale
+else
+ PLATFORM=x86
+ export LD_LIBRARY_PATH=$PWD/../lib/x86.d:$PWD/lib/../x86
+ export dm_setting_plugin=$PWD/plugins/x86
+fi
+
+$PWD/bin/$PLATFORM/testexe $2 || exit 1
+
+
diff --git a/engine/dmlib/linux_java/samples/settings/Dmt.zip b/engine/dmlib/linux_java/samples/settings/Dmt.zip
new file mode 100644
index 0000000..5aab741
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/settings/Dmt.zip
Binary files differ
diff --git a/engine/dmlib/linux_java/samples/settings/fstab b/engine/dmlib/linux_java/samples/settings/fstab
new file mode 100644
index 0000000..1d8d40f
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/settings/fstab
@@ -0,0 +1,10 @@
+#PATH FILENAME (MUST END WITH .WBXML) fOR NOW, ALL subfile do not overlap
+# first file always is .
+#
+# Also parent URI must be BEFORE child URI
+#
+# This is a sample fstab - PLEASE EDIT this file to match your own tree!!!
+#
+. root.wbxml
+./DevDetail/Ext devdetail_ext.wbxml
+./DevDetail/URI devdetail_uri.wbxml
diff --git a/engine/dmlib/linux_java/samples/socketCon/compilePortlib b/engine/dmlib/linux_java/samples/socketCon/compilePortlib
new file mode 100644
index 0000000..0605830
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/socketCon/compilePortlib
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+mkdir -p lib
+mkdir -p lib/x86
+mkdir -p lib/xscale
+
+#build for x86
+gcc -shared -I../../api/native -g -I../../portlib/generic/ -I../../portlib/ezx/hdr -I../../portlib/p2k/hdr -I../../dmengine/dm_util/hdr -I./hdr -o ./lib/x86/libdmportlib.so ./src/dmSocketConnector.cpp ./src/port_layer.cc
+
+# build for xscale
+COMPILERTOOLPATH=/vobs/ezx_tools/linux/toolchain/toolchain-3.3/devkit/arm/iwmmxt_le/bin
+COMPILERTOOLPREFIX=${COMPILERTOOLPATH}/arm-linux-
+
+${COMPILERTOOLPREFIX}gcc -shared -I../../api/native -I../../portlib/generic/ -I../../portlib/ezx/hdr -I../../portlib/p2k/hdr -I../../dmengine/dm_util/hdr -I./hdr -o ./lib/xscale/libdmportlib.so ./src/dmSocketConnector.cpp ./src/port_layer.cc
+
+
+
diff --git a/engine/dmlib/linux_java/samples/socketCon/src/port_layer.cc b/engine/dmlib/linux_java/samples/socketCon/src/port_layer.cc
new file mode 100644
index 0000000..8f8b7fd
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/socketCon/src/port_layer.cc
@@ -0,0 +1,70 @@
+#include "dmConnection.h"
+#include "xpl_dm_ServerAlert.h"
+#include "xpl_dm_Notifications.h"
+
+// empty function impls from dmConnection_impl.cc
+
+/*
+DmBrwConnector * DmBrwCreateConnector()
+{
+ printf("Connector creator called- return null\n");
+ return NULL;
+}
+
+SYNCML_DM_RET_STATUS_T DmBrwDestroyConnector(DmBrwConnector * browser_handler)
+{
+ return SYNCML_DM_SUCCESS;
+
+}
+*/
+
+// empty function impls from dmUIAlert.cc
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowConfirmAlert(INT32 maxDisplayTime, CPCHAR msg, XPL_DM_ALERT_RES_T defaultResponse, XPL_DM_ALERT_RES_T * responseCode)
+{
+ static int i = 0;
+ i++;
+ *responseCode = (i%2) ? XPL_DM_ALERT_RES_YES : XPL_DM_ALERT_RES_NO;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowDisplayAlert(INT32 minDisplayTime, CPCHAR msg)
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowTextInputAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ CPCHAR defaultResponse,
+ INT32 maxLength,
+ XPL_DM_ALERT_INPUT_T inputType,
+ XPL_DM_ALERT_ECHO_T echoType,
+ XPL_DM_ALERT_TEXTINPUT_RES_T * userResponse )
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowSingleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ INT32 defaultResponse,
+ XPL_DM_ALERT_SCHOICE_RES_T * userResponse )
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowMultipleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ DMStringVector & defaultResponses,
+ XPL_DM_ALERT_MCHOICE_RES_T * userResponse)
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+
diff --git a/engine/dmlib/linux_java/samples/unittest/src/dmt_stress.cc b/engine/dmlib/linux_java/samples/unittest/src/dmt_stress.cc
new file mode 100644
index 0000000..cd55cd0
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/unittest/src/dmt_stress.cc
@@ -0,0 +1,201 @@
+#include <iostream>
+#include <stdio.h>
+#include <stdarg.h>
+#include <dlfcn.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+#include "dmt.hpp"
+
+
+const char* c_szURI = "./DevDetail/FwV";
+DMString g_strValue;
+const int c_nProcesses = 3;
+const int c_nThreads = 3;
+const int c_nLoops = 3;
+int g_nProcess = 0;
+int g_nCurProcess = 0;
+
+static int Setup( void )
+{
+ {
+ PDmtTree ptrTree;
+ PDmtNode ptrNode;
+ char s[15]; sprintf( s, "-%d", c_nLoops * c_nProcesses * c_nThreads );
+
+ if ( !DmtTreeFactory::Initialize() ||
+ DmtTreeFactory::GetTree( "localhost", ptrTree ) ||
+ ptrTree->GetNode( c_szURI, ptrNode ) ||
+ ptrNode->GetStringValue( g_strValue ) ||
+ ptrNode->SetStringValue( s )
+ )
+ return 0;
+ }
+
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DmtEventSubscription oEvent;
+
+ UINT8 event = SYNCML_DM_EVENT_ADD | SYNCML_DM_EVENT_REPLACE |
+ SYNCML_DM_EVENT_DELETE | SYNCML_DM_EVENT_INDIRECT;
+
+
+ oEvent.Set(event,SYNCML_DM_EVENT_DETAIL);
+
+ DmtTreeFactory::SubscribeEvent("./DevDetail", oEvent);
+
+ DmtTreeFactory::Uninitialize();
+ return 1;
+}
+
+static int Restore( void )
+{
+ {
+ PDmtTree ptrTree;
+ PDmtNode ptrNode;
+ DMString str;
+
+ if ( !DmtTreeFactory::Initialize() ||
+ DmtTreeFactory::GetTree( "localhost", ptrTree ) ||
+ ptrTree->GetNode( c_szURI, ptrNode ) ||
+ ptrNode->GetStringValue( str ) ||
+ ptrNode->SetStringValue( g_strValue )
+ )
+ return 0;
+
+ if ( str != "0" )
+ printf( "Doesnot match expected value!!! %s instead of 0; (%d)\n\n", str.c_str(), c_nLoops * c_nProcesses * c_nThreads);
+ else
+ printf("Done with no errors\n");
+ }
+
+ DmtTreeFactory::Uninitialize();
+ return 1;
+}
+
+static void PlayLoop( int n )
+{
+ n = 1;
+ for ( int i = 0; i < c_nLoops; i++ )
+ {
+ PDmtTree ptrTree;
+ PDmtNode ptrNode;
+ DMString s;
+
+ if ( DmtTreeFactory::GetTree( "localhost", ptrTree ) ||
+ ptrTree->GetNode( c_szURI, ptrNode ) ||
+ ptrNode->GetStringValue( s ) ) {
+ printf( "operation failed!\n");
+ exit (1);
+ }
+
+ ptrTree = NULL; ptrNode = NULL;
+ //usleep( 10000 );
+ sleep(1);
+
+ DMString s2;
+ if ( DmtTreeFactory::GetSubtreeEx( "localhost", NULL, SYNCML_DM_LOCK_TYPE_EXCLUSIVE, ptrTree ) ||
+ ptrTree->GetNode( c_szURI, ptrNode ) ||
+ ptrNode->GetStringValue( s2 ) ) {
+ printf( "operation failed!\n");
+ exit (1);
+ }
+
+ int nV = atoi( s2 );
+
+ char sz[10]; sprintf( sz, "%d", nV + n );
+ if ( ptrNode->SetStringValue( sz ) ) {
+ printf( "operation failed!\n");
+ exit (1);
+ }
+
+ //if ( s != s2 )
+ //printf( "%d-%d: values are not the same: %s,%s (%d) {%s}\n", g_nCurProcess, (int)getpid(), s.c_str(), s2.c_str(), n, sz );
+
+ //usleep( 10000 );
+sleep(2);
+ }
+}
+
+static void* ThreadProc( void* p )
+{
+ int n = (int )p;
+
+ if ( n% 2 )
+ {
+ //PlayLoop( n );
+ PlayLoop( -n );
+ }
+ else
+ {
+ //PlayLoop( -n );
+ PlayLoop( n );
+ }
+
+ return NULL;
+}
+
+static int RunTests( void )
+{
+ if ( !DmtTreeFactory::Initialize() ){
+ printf("failed to init tree\n");
+ return 1;
+ }
+
+ pthread_t ids[ c_nThreads ];
+
+ for ( int i = 0; i < c_nThreads; i++ )
+ {
+ int nRes = pthread_create( &ids[i], 0, ThreadProc, (void*)i );
+
+ if ( nRes ){
+ printf( "Failed to create thread %d!\n", nRes);
+ return 1;
+ }
+ }
+
+ for ( int i = 0; i < c_nThreads; i++ )
+ {
+ pthread_join( ids[i], NULL );
+ }
+
+ DmtTreeFactory::Uninitialize();
+ return 0;
+}
+
+extern "C" int MultiProcessTest( void )
+{
+ if ( !Setup() )
+ return 1;
+
+ pid_t ids[ c_nProcesses ] ;
+
+ for ( int g_nProcess = 0; g_nProcess < c_nProcesses; g_nProcess++ )
+ {
+ ids[g_nProcess] = fork();
+
+ if ( ids[g_nProcess] == -1 ){
+ printf( "fork failed!\n");
+ return 2;
+ }
+
+ if ( !ids[g_nProcess] ){
+ g_nCurProcess = g_nProcess;
+ return RunTests();
+ }
+ }
+
+ int nStat = -1;
+
+ for ( int i = 0; i < c_nProcesses; i++ )
+ {
+ waitpid( ids[i], &nStat, 0 );
+
+ if ( nStat != 0 )
+ printf( "%d: Child returned status %d\n", i, nStat );
+ }
+
+ Restore();
+ return 0;
+}
+
diff --git a/engine/dmlib/linux_java/samples/unittest/src/dmt_test.cc b/engine/dmlib/linux_java/samples/unittest/src/dmt_test.cc
new file mode 100644
index 0000000..2ef90c5
--- /dev/null
+++ b/engine/dmlib/linux_java/samples/unittest/src/dmt_test.cc
@@ -0,0 +1,1961 @@
+#include <iostream>
+#include <stdio.h>
+#include <stdarg.h>
+#include <dlfcn.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <string.h>
+#include "dmt.hpp"
+//#include "dm_security.h"
+#include "dmVersion.h"
+#include "xpl_dm_Manager.h"
+
+extern "C" int MultiProcessTest( void );
+
+using namespace std;
+static const char* c_szErrorText = "\033[31mError!\033[0m";
+
+static DmtPrincipal principal("localhost");
+static PDmtTree ptrTree;
+static PDmtErrorDescription e;
+static DMString s_strRootPath = "";
+
+static DMString s_strCurLine;
+static bool s_bDone = false;
+static bool s_bAtomic = false;
+static bool s_bShowTimestamp = false;
+static bool s_bAutoReleaseTree = true;
+static bool s_bShowProfileTime = false;
+static int counter = 0;
+static bool countTestCase = false;
+
+//helper class for profiling
+struct TestProfile
+{
+ TestProfile( const char* sHeader )
+ {
+ gettimeofday( &m_tvStart, NULL );
+ m_szHeader = sHeader;
+
+ }
+ ~TestProfile()
+ {
+ struct timeval tv2;
+ gettimeofday( &tv2, NULL );
+ long long n1 = m_tvStart.tv_usec + (m_tvStart.tv_sec * 1000000 );
+ long long n2 = tv2.tv_usec + (tv2.tv_sec * 1000000 );
+ long long elapsed = n2 - n1;
+
+ if ( s_bShowProfileTime )
+ printf( "DMProfile: %s, time is %d.%d ms\n", m_szHeader.c_str(), (int)(elapsed/1000), (int)(elapsed%1000/100) );
+ }
+
+ DMString m_szHeader;
+ struct timeval m_tvStart;
+};
+
+static void Error(char *fmt, ...)
+{
+ va_list argp;
+ va_start(argp, fmt);
+ if ( e.GetErrorCode() == SYNCML_DM_SUCCESS)
+ return;
+ printf("%s ", c_szErrorText);
+ vprintf(fmt, argp);
+ printf(", DmtException: %d\n", e->GetErrorCode() );
+}
+
+static DMString GetLine()
+{
+ DMString s = "";
+ int nC;
+ while ( (nC = getchar() ) != EOF )
+ {
+ if ( nC == '\r' || nC == '\n') {
+ return s;
+ }
+ char sz[2] = {nC, 0};
+ s += sz;
+ }
+
+ s_bDone = true;
+ return s;
+}
+
+static BOOLEAN StrToBin(DMString &binStr, INT32 *len)
+{
+ char *pivot_w;
+ char *pivot_r;
+ char digits[4];
+ UINT8 vbin;
+ INT32 i;
+
+ *len = binStr.length();
+ if (*len & 1 )
+ {
+ printf("Error Input: Uneven string length.\n");
+ return FALSE;
+ }
+ *len >>= 1;
+ pivot_w = binStr.GetBuffer();
+
+
+ pivot_r = pivot_w;
+ digits[3] = '\0';
+ for (i=0; i<*len; i++)
+ {
+ strncpy(digits, pivot_r, 2);
+ sscanf(digits, "%x", &vbin);
+ pivot_w[i] = vbin;
+ pivot_r += 2;
+ }
+
+ return TRUE;
+}
+
+static DMString ConvertEscape(DMString strInput)
+{
+ DMString s;
+ const char* szBuf = strInput.c_str();
+ char ch;
+ unsigned int code;
+
+ while (true) {
+ ch = szBuf[0];
+ if (ch == '\\') {
+ szBuf++;
+ ch = szBuf[0];
+ if (ch == 't') {
+ code = '\t';
+ } else if (ch == 'r') {
+ code = '\r';
+ } else if (ch == 'n') {
+ code = '\n';
+ } else if (ch == 'f') {
+ code = '\f';
+ } else if (ch == 'x') {
+ code = 0;
+ for (int i = 0; i < 2; i++) {
+ szBuf++;
+ ch = szBuf[0];
+ switch (ch) {
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ code = (code << 4) + (ch - '0');
+ break;
+ case 'a': case 'b': case 'c': case 'd':
+ case 'e': case 'f':
+ code = (code << 4) + (ch - 'a' + 10);
+ break;
+ case 'A': case 'B': case 'C': case 'D':
+ case 'E': case 'F':
+ code = (code << 4) + (ch - 'A' + 10);
+ break;
+ default:
+ printf("%s malformed \\xXX encoding.\n", c_szErrorText);
+ return "";
+ }
+ }
+ } else {
+ code = ch;
+ }
+ } else {
+ code = ch;
+ }
+
+ if (code <= 0) {
+ break;
+ } else if (code > 0 && code <= 0xFF) {
+ char sz[2] = { (char)code, 0 };
+ s += sz;
+ } else {
+ printf("%s in input string: %x.\n", c_szErrorText, code);
+ return "";
+ }
+ szBuf++;
+ }
+ return s;
+}
+
+static DMString GetParam()
+{
+ DMString s;
+
+ const char* szBuf = s_strCurLine.c_str();
+
+ while ( szBuf[0] == ' ' )
+ szBuf++;
+
+ bool bEscaped = false;
+ char ch;
+ while ( true ) {
+ ch = szBuf[0];
+ if ( ch == 0 || (!bEscaped && ch == ' ')) {
+ break;
+ }
+ if ( !bEscaped && ch == '\\') {
+ bEscaped = true;
+ } else {
+ bEscaped = false;
+ }
+
+ char sz[2] = {ch, 0};
+ s += sz;
+ szBuf++;
+ }
+
+ DMString strTmp = szBuf;
+ s_strCurLine = strTmp;
+
+ return ConvertEscape(s);
+}
+
+static DMString GetCmd()
+{
+ if (s_bDone) {
+ return "quit";
+ }
+
+ if (countTestCase) {
+ counter++;
+ }
+
+ s_strCurLine = GetLine();
+ return GetParam();
+}
+
+static void startCounter()
+{
+ printf("Counter started!\n");
+ countTestCase = true;
+}
+
+static void endCounter()
+{
+ if (counter > 0)
+ {
+ counter--;
+ }
+ printf("Counter ended!\n");
+ countTestCase = false;
+}
+
+static void displayCountStatus()
+{
+ if (counter > 0)
+ {
+ counter--;
+ }
+ printf("Count is ");
+ if (countTestCase) {
+ printf("ON\n");
+ } else {
+ printf("OFF\n");
+ }
+}
+
+static void resetCounter()
+{
+ printf("Counter has reseted!\n");
+ counter = 0;
+}
+
+static void getCounter()
+{
+ if (counter > 0)
+ {
+ counter--;
+ }
+ printf("Number of tested cases: %d\n", counter);
+ return;
+}
+
+
+static DMString GetInputString(const char * szPrompt, const char * szDefault)
+{
+ printf("%s (default=%s): ", szPrompt, szDefault);
+ DMString strIn = GetLine();
+ printf("get: %s\n", strIn.c_str());
+ if (strIn == "") {
+ strIn = szDefault;
+ }
+ return ConvertEscape(strIn);
+}
+
+
+/**
+ * Get DM tree to global tree variable (ptrTree)
+ */
+static PDmtTree GetTree()
+{
+ if (ptrTree != NULL) return ptrTree;
+ if ( (e=DmtTreeFactory::GetSubtree(principal, s_strRootPath.c_str(), ptrTree)) != NULL ) {
+ Error("can't get tree");
+ }
+ return ptrTree;
+}
+
+static PDmtNode GetNode( const char* szNodeName )
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree != NULL ){
+ if ( (e=ptrTree->GetNode( szNodeName, ptrNode)) != NULL ) {
+ Error("can't get node %s", szNodeName);
+
+ }
+ }
+ return ptrNode;
+}
+static void printESNChunk(const char * buffer, int size )
+{
+ int offset=0;
+ int line =0;
+ while(offset < size)
+ {
+ putchar(buffer[offset++]);
+ line++;
+ if(line>64)
+ { line =0;
+ printf( "\n");
+ }
+ }
+ printf( "\n");
+}
+
+static void displayESN(PDmtNode ptrNode)
+{
+ SYNCML_DM_RET_STATUS_T retStatus;
+ if (ptrNode->IsExternalStorageNode())
+ {
+ DmtDataChunk chunkData;
+ UINT32 getLen;
+ UINT8 *bufp;
+ retStatus = ptrNode->GetFirstChunk(chunkData);
+ if( retStatus != SYNCML_DM_SUCCESS)
+ return;
+ chunkData.GetReturnLen(getLen);
+ chunkData.GetChunkData(&bufp); // the chunk data is available
+ while (true)
+ {
+ printESNChunk((const char*)bufp, getLen);
+ if (getLen == 0)
+ break;
+ else
+ {
+ // save or process the data in *bufp
+ retStatus = ptrNode->GetNextChunk(chunkData);
+ if( retStatus != SYNCML_DM_SUCCESS)
+ return;
+ chunkData.GetReturnLen(getLen);
+ chunkData.GetChunkData(&bufp);
+ }
+ }
+
+ } else {
+ DMString path;
+ ptrNode->GetPath(path);
+
+ Error("It's not a External Storage Node \n", path.c_str());
+ }
+}
+
+static void PrintNode( PDmtNode ptrNode )
+{
+ DmtAttributes oAttr;
+ DMString path;
+
+ if( (e=ptrNode->GetPath(path)) != NULL )
+ {
+ Error("can't get attributes of node %d", e.GetErrorCode());
+ }
+
+ if ( (e=ptrNode->GetAttributes( oAttr )) != NULL) {
+ Error("can't get attributes of node %s", path.c_str());
+ return;
+ }
+
+ DmtData oData;
+ if (!ptrNode->IsExternalStorageNode())
+ {
+ if ( (e=ptrNode->GetValue( oData )) != NULL ) {
+ Error("can't get value of node %s", path.c_str());
+ return;
+ }
+ }
+ printf("path=%s\n", (const char*)path.c_str());
+ printf("isLeaf=%s\n", (ptrNode->IsLeaf()?"true":"false") );
+ printf("name=%s\n", (const char*)oAttr.GetName().c_str() );
+ printf("format=%s\n", (const char*)oAttr.GetFormat().c_str() );
+ printf("type=%s\n", (const char*)oAttr.GetType().c_str() );
+ printf("title=%s\n", (const char*)oAttr.GetTitle().c_str() );
+ printf("acl=%s\n", (const char*)oAttr.GetAcl().toString().c_str() );
+ printf("size=%d\n", (const char*)oAttr.GetSize() );
+ if ( s_bShowTimestamp ) {
+ if ( oAttr.GetTimestamp() == 0 ) {
+ printf("timestamp=(Unknown)\n");
+ } else {
+ // convert msec to sec
+ time_t timestamp = (time_t)(oAttr.GetTimestamp()/1000L);
+ printf("timestamp=%s", ctime(&timestamp) );
+ }
+ }
+ printf("version=%d\n", oAttr.GetVersion() );
+ if ( !ptrNode->IsLeaf() ) {
+ DMStringVector aChildren;
+ oData.GetNodeValue( aChildren );
+ printf("children:");
+ if ( aChildren.size() == 0 ) {
+ printf("null");
+ }
+ for (int i=0; i < aChildren.size(); i++) {
+ printf("%s/", aChildren[i].c_str());
+ }
+ printf("\n");
+ } else {
+ if (ptrNode->IsExternalStorageNode())
+ {
+ printf("value=\n");
+ displayESN(ptrNode);
+ }
+ else {
+ if ( strcasecmp(oAttr.GetFormat(), "bin") == 0 ) {
+ printf("Binary value: [");
+ for ( int i = 0 ; i < oData.GetBinaryValue().size(); i++ ){
+ printf( "%02x ", oData.GetBinaryValue().get_data()[i]);
+ }
+ printf( "]\n" );
+ }
+ else
+ {
+ DMString s;
+ oData.GetString(s);
+ printf("value=%s\n", s.c_str());
+ }
+
+
+ }
+}
+}
+
+static void Get( const char* szNodeName )
+{
+ PDmtNode ptrNode = GetNode( szNodeName );
+
+ if ( ptrNode == NULL )
+ return;
+
+ PrintNode(ptrNode);
+}
+
+static void CreateInterior( const char * szNode )
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrTree->CreateInteriorNode( szNode, ptrNode )) == NULL ) {
+ printf( "node %s created successfully\n", szNode );
+ } else {
+ Error("can't create a node %s", szNode);
+ }
+}
+
+static void CreateLeaf( const char * szNode, const char* szData )
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrTree->CreateLeafNode( szNode, ptrNode, DmtData( szData ) )) == NULL ) {
+ printf( "node %s (%s) created successfully\n", szNode, szData );
+ } else {
+ Error("can't create a node %s", szNode);
+ }
+}
+
+static void CreateLeafInteger( const char * szNode, const char* szData )
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ int intValue = atoi(szData);
+
+ if ( (e=ptrTree->CreateLeafNode( szNode, ptrNode, DmtData( intValue ) )) == NULL ) {
+ printf( "node %s (%d) created successfully\n", szNode, intValue );
+ } else {
+ Error("can't create a node %s", szNode);
+ }
+}
+
+static void CreateLeafBoolean( const char * szNode, const char* szData )
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ bool bValue = ((strcasecmp(szData, "true") == 0) ? true : false);
+
+ if ( (e=ptrTree->CreateLeafNode( szNode, ptrNode, DmtData( bValue ) )) == NULL ) {
+ printf( "node %s (%s) created successfully\n",
+ szNode, (bValue?"true":"false") );
+ } else {
+ Error("can't create a node %s", szNode);
+ }
+}
+
+
+
+static void CreateLeafBinary( const char * szNode, const char* szData )
+{
+ INT32 len;
+ DMString binStr = szData;
+
+ if ( StrToBin( binStr, &len) == FALSE)
+ return;
+
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrTree->CreateLeafNode( szNode, ptrNode, DmtData( (const byte*)binStr.c_str(), len ) )) == NULL ) {
+ printf( "node %s (%s) created successfully\n", szNode, szData );
+ } else {
+ Error("can't create a node %s", szNode);
+ }
+}
+
+static void CreateLeafBinaryE( const char * szNode )
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrTree->CreateLeafNode( szNode, ptrNode, DmtData( ) )) == NULL ) {
+ printf( "node %s () created successfully\n", szNode );
+ } else {
+ Error("can't create a node %s", szNode);
+ }
+}
+
+
+static void CreateLeafFloat( const char * szNode, const char* szData )
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrTree->CreateLeafNode( szNode, ptrNode, DmtData( szData, SYNCML_DM_DATAFORMAT_FLOAT) ) ) == NULL ) {
+ printf( "node %s (%s) created successfully\n", szNode, szData );
+ } else {
+ Error("can't create a node %s", szNode);
+ }
+}
+
+static void CreateLeafDate( const char * szNode, const char* szData )
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrTree->CreateLeafNode( szNode, ptrNode, DmtData( szData, SYNCML_DM_DATAFORMAT_DATE) ) ) == NULL ) {
+ printf( "node %s (%s) created successfully\n", szNode, szData );
+ } else {
+ Error("can't create a node %s", szNode);
+ }
+}
+
+static void CreateLeafTime( const char * szNode, const char* szData )
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrTree->CreateLeafNode( szNode, ptrNode, DmtData( szData, SYNCML_DM_DATAFORMAT_TIME) ) ) == NULL ) {
+ printf( "node %s (%s) created successfully\n", szNode, szData );
+ } else {
+ Error("can't create a node %s", szNode);
+ }
+}
+
+static void Delete(const char* szNode )
+{
+ GetTree();
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrTree->DeleteNode( szNode )) == NULL ) {
+ printf( "node %s deleted successfully\n", szNode );
+ } else {
+ Error("can't delete node %s", szNode);
+ }
+}
+
+static void Rename(const char* szNode, const char* szNewName)
+{
+ GetTree();
+ if ( ptrTree == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrTree->RenameNode( szNode, szNewName )) == NULL ) {
+ printf( "node %s renamed to %s successfully\n", szNode, szNewName);
+ } else {
+ Error("can't rename node %s to %s", szNode, szNewName);
+ }
+}
+
+static void setESN(const char * szNode, const char * szFile)
+{
+ FILE* f = fopen( szFile, "r" );
+ if ( !f ) {
+ printf("%s can't open file %s\n",c_szErrorText, szFile);
+ return;
+ }
+
+ // assume 100k is enough
+ const int c_nSize = 100 * 1024;
+ char* szBuf = new char [c_nSize];
+
+ int n = fread(szBuf, 1, c_nSize, f );
+
+ printf("read %d bytes\n", n);
+ if ( n > 0 ) {
+ SYNCML_DM_RET_STATUS_T retStatus;
+ PDmtNode ptrNode = GetNode(szNode);
+ if ( ptrNode == NULL ) {
+ return;
+ }
+
+ szBuf[n] = 0;
+
+ if (ptrNode->IsExternalStorageNode())
+ {
+ DmtDataChunk chunkData;
+ int setLen = 0;
+ int offset = 0;
+ bool isFirstChunk = true;
+ bool isLastChunk = false;
+ int chunksize = chunkData.GetChunkSize();
+
+ while(!isLastChunk)
+ { setLen = n - offset;
+ if(setLen > 0)
+ {
+ if(setLen > chunksize)
+ setLen = chunksize;
+ }
+ else
+ isLastChunk = true;
+
+ printESNChunk(&szBuf[offset], setLen);
+ chunkData.SetChunkData((const UINT8 *)&szBuf[offset], setLen);
+ if(isFirstChunk)
+ {
+ retStatus = ptrNode->SetFirstChunk(chunkData);
+ isFirstChunk = false;
+ }
+ else
+ { if(!isLastChunk)
+ retStatus = ptrNode->SetNextChunk(chunkData);
+ else
+ retStatus = ptrNode->SetLastChunk(chunkData);
+ }
+
+ offset += setLen;
+ }
+
+ } else {
+ Error("It's not a External Storage Node \n", szNode);
+ }
+ }
+
+ delete [] szBuf;
+ fclose( f );
+}
+static void SetTitle(const char * szNode, const char * szTitle)
+{
+ PDmtNode ptrNode = GetNode(szNode);
+ if ( ptrNode == NULL ) {
+ return;
+ }
+
+ if ( (e=ptrNode->SetTitle(szTitle)) == NULL ) {
+ printf("set title of node %s to %s successfully\n",
+ szNode, szTitle);
+ PrintNode(ptrNode);
+ } else {
+ Error("can't set title of node %s to %s", szNode, szTitle);
+ }
+}
+
+static void SetAcl(const char * szNode, const char * szAcl)
+{
+ PDmtNode ptrNode = GetNode(szNode);
+ if (ptrNode == NULL) {
+ return;
+ }
+
+ DmtAcl oAcl(szAcl);
+ if ( (e=ptrNode->SetAcl(oAcl)) == NULL ) {
+ printf("set acl of node %s to %s successfully\n",
+ szNode, szAcl);
+ PrintNode(ptrNode);
+ } else {
+ Error("can't set acl of node %s to %s", szNode, szAcl);
+ }
+}
+
+static void ReplaceString( const char * szNode, const char * szValue)
+{
+ PDmtNode ptrNode = GetNode(szNode);
+ if (ptrNode == NULL) {
+ return;
+ }
+
+ if ( (e=ptrNode->SetStringValue(szValue)) == NULL ) {
+ printf("set value of node %s to %s successfully\n", szNode, szValue);
+ PrintNode(ptrNode);
+ } else {
+ Error("can't set value of node %s to %s", szNode, szValue);
+ }
+}
+
+static void ReplaceInteger( const char * szNode, const char * szValue)
+{
+ PDmtNode ptrNode = GetNode(szNode);
+ if (ptrNode == NULL) {
+ return;
+ }
+ //int intValue = atoi(szValue);
+ int intValue = 0;
+ //store the sscanf result;
+ int int_item_converted = 0;
+ int_item_converted = sscanf(szValue, "%d", &intValue);
+ //printf("data is %s \n", szValue);
+ printf("INT_ITEM_CONVERTED is %d \n", int_item_converted);
+ if(int_item_converted==0) {
+ printf("The input %s is not an integer\n", szValue);
+ return;
+ }
+ if ( (e=ptrNode->SetIntValue( intValue )) == NULL ) {
+ printf("set value of node %s to %d successfully\n", szNode, intValue);
+ PrintNode(ptrNode);
+ } else {
+ Error("can't set value of node %s to %d", szNode, intValue);
+ }
+}
+
+static void ReplaceBoolean( const char * szNode, const char * szValue)
+{
+ PDmtNode ptrNode = GetNode(szNode);
+ if (ptrNode == NULL) {
+ return;
+ }
+ bool boolValue = ((strcasecmp(szValue, "true") == 0) ? true : false);
+ if ( (e=ptrNode->SetBooleanValue( boolValue )) == NULL ) {
+ printf("set value of node %s to %s successfully\n",
+ szNode, (boolValue?"true":"false"));
+ PrintNode(ptrNode);
+ } else {
+ Error("can't set value of node %s to %s",
+ szNode, (boolValue?"true":"false"));
+ }
+}
+
+static void ReplaceFloat( const char * szNode, const char * szValue)
+{
+ PDmtNode ptrNode = GetNode(szNode);
+ if (ptrNode == NULL) {
+ return;
+ }
+
+ if ( (e=ptrNode->SetFloatValue( szValue )) == NULL ) {
+ printf("set value of node %s to %s successfully\n", szNode, szValue);
+ PrintNode(ptrNode);
+ } else {
+ Error("can't set value of node %s to %s", szNode, szValue);
+ }
+}
+
+static void ReplaceDate( const char * szNode, const char * szValue)
+{
+ PDmtNode ptrNode = GetNode(szNode);
+ if (ptrNode == NULL) {
+ return;
+ }
+ if ( (e=ptrNode->SetDateValue( szValue )) == NULL ) {
+ printf("set value of node %s to %s successfully\n", szNode, szValue);
+ PrintNode(ptrNode);
+ } else {
+ Error("can't set value of node %s to %s", szNode, szValue);
+ }
+}
+
+static void ReplaceTime( const char * szNode, const char * szValue)
+{
+ PDmtNode ptrNode = GetNode(szNode);
+ if (ptrNode == NULL) {
+ return;
+ }
+
+ if ( (e=ptrNode->SetTimeValue( szValue )) == NULL ) {
+ printf("set value of node %s to %s successfully\n", szNode, szValue);
+ PrintNode(ptrNode);
+ } else {
+ Error("can't set value of node %s to %s", szNode, szValue);
+ }
+}
+
+static void ReplaceBytes( const char * szNode, const char * szValue)
+{
+ INT32 len;
+ DMString binStr = szValue;
+
+ if ( StrToBin(binStr, &len) == FALSE)
+ return;
+
+ PDmtNode ptrNode = GetNode(szNode);
+ if (ptrNode == NULL) {
+ return;
+ }
+
+ if ( (e=ptrNode->SetBinaryValue( (const byte*)binStr.c_str(), len )) == NULL ) {
+ printf("set value of node %s to %s successfully\n", szNode, szValue);
+ PrintNode(ptrNode);
+ } else {
+ Error("can't set value of node %s to %s", szNode, szValue);
+ }
+}
+
+static void DumpSubTree( PDmtNode ptrNode )
+{
+ PrintNode(ptrNode);
+ printf("\n");
+ if ( e != NULL ) return;
+
+ if ( !ptrNode->IsLeaf() ) {
+ DMVector<PDmtNode> aChildren;
+ if ( (e=ptrNode->GetChildNodes( aChildren )) != NULL ) {
+ DMString path;
+ ptrNode->GetPath(path);
+ Error("can't get child nodes of %s", path.c_str());
+ return;
+ }
+ for (int i=0; i < aChildren.size(); i++) {
+ DumpSubTree( aChildren[i] );
+ }
+ }
+}
+
+static void DumpTree( const char * szNode )
+{
+ PDmtNode ptrNode = GetNode( szNode );
+ if ( ptrNode == NULL ) {
+ return;
+ }
+
+ DumpSubTree( ptrNode );
+}
+
+static void Execute( const char * szNode, const char * szData )
+{
+ PDmtNode ptrNode = GetNode(szNode);
+ if (ptrNode == NULL) {
+ return;
+ }
+ DMString strResult;
+ if ( (e=ptrNode->Execute(szData, strResult)) == NULL ) {
+ printf("execute node %s successfully, result=%s\n",
+ szNode, strResult.c_str() );
+ } else {
+ Error("can't execute node %s", szNode);
+ }
+}
+
+static void Open( const char * szNode)
+{
+ if ( strcmp(szNode, ".") == 0) {
+ s_strRootPath = "";
+ } else {
+ s_strRootPath = szNode;
+ }
+ s_bAtomic = false;
+ ptrTree = NULL;
+ printf("Open tree: %s\n", s_strRootPath.c_str());
+}
+
+static void GetExclusiveTree( const char * szNode)
+{
+ if ( strcmp(szNode, ".") == 0) {
+ s_strRootPath = "";
+ } else {
+ s_strRootPath = szNode;
+ }
+ s_bAtomic = false;
+ ptrTree = NULL;
+
+ if ( (e=DmtTreeFactory::GetSubtreeEx(principal, s_strRootPath.c_str(), DmtTreeFactory::LOCK_TYPE_EXCLUSIVE, ptrTree)) != NULL ) {
+ Error("can't get tree");
+ }
+
+ printf("GetExclusiveTree: %s\n", s_strRootPath.c_str());
+}
+
+static void Release()
+{
+ s_bAtomic = false;
+ ptrTree = NULL;
+ s_strRootPath = "";
+ printf("release tree successfully\n");
+}
+
+static void Flush()
+{
+ if (ptrTree != NULL) {
+ if ((e=ptrTree->Flush()) == NULL) {
+ printf("flush tree successfully\n");
+ } else {
+ Error("can't flush tree");
+ }
+ } else {
+ printf("tree is already released\n");
+ }
+ s_bAtomic = false;
+}
+
+static void Begin()
+{
+ GetTree();
+ if (ptrTree == NULL) {
+ return;
+ }
+ if ( (e=ptrTree->Begin()) == NULL ) {
+ s_bAtomic = true;
+ printf("begin an atomic operation successfully\n");
+ } else {
+ Error("can't begin an atomic operation");
+ }
+}
+
+static void Commit()
+{
+ if (!s_bAtomic || ptrTree == NULL) {
+ printf("not in the middle of atomic operations\n");
+ } else if ( (e=ptrTree->Commit()) == NULL) {
+ printf("commit atomic operations successfully\n");
+ } else {
+ Error("can't commit atomic operations");
+ }
+ s_bAtomic = false;
+}
+
+static void Rollback()
+{
+ if ( !s_bAtomic || ptrTree == NULL) {
+ printf("not in the middle of the atomic operations\n");
+ } else if ( (e=ptrTree->Rollback()) == NULL) {
+ printf("rollback atomic operations successfully\n");
+ } else {
+ Error("can't rollback atomic oeprations");
+ }
+ s_bAtomic = false;
+}
+
+static void Clone(const char * szNode, const char * szNewNode)
+{
+ GetTree();
+ if (ptrTree == NULL) {
+ return;
+ }
+
+ if ( (e=ptrTree->Clone(szNode, szNewNode)) == NULL) {
+ printf("clone %s to %s successfully\n", szNode, szNewNode);
+ } else {
+ Error("can't clone %s to %s", szNode, szNewNode);
+ }
+}
+
+static void GetMap( const char * szNode)
+{
+ GetTree();
+ if (ptrTree == NULL) {
+ return;
+ }
+
+ DMMap<DMString, DmtData> oMap;
+ if ( (e=ptrTree->GetChildValuesMap(szNode, oMap)) == NULL) {
+ printf("map table size=%d\n", oMap.size());
+ for (DMMap<DMString, DmtData>::POS it = oMap.begin(); it != oMap.end(); it++) {
+ DMString strKey = oMap.get_key(it);
+ DmtData oData = oMap.get_value(it);
+ DMString strData;
+ if ( (e=oData.GetString(strData)) == NULL) {
+ printf("%s=%s\n", strKey.c_str(), strData.c_str());
+ } else {
+ Error("can't get value of node %s", strKey.c_str() );
+ }
+ }
+ } else {
+ Error("can't get map of node %s", szNode);
+ }
+}
+
+static void SetMap( const char * szNode )
+{
+ GetTree();
+ if (ptrTree == NULL) {
+ return;
+ }
+
+ DMMap<DMString, DmtData> oMap;
+ while (true) {
+ DMString strKey = GetParam();
+ DMString strData = GetParam();
+
+ if (strKey == "" || strData == "") {
+ break;
+ }
+ DmtData oData(strData);
+ oMap.put(strKey, oData);
+ }
+ if ( (e=ptrTree->SetChildValuesMap(szNode, oMap)) == NULL ) {
+ printf("set map for %s succesfully, size = %d\n",
+ szNode, oMap.size());
+ } else {
+ Error("can't set map of node %s", szNode);
+ }
+}
+
+
+static void Dump( const char* buf, int size )
+{
+ int nOffset = 0;
+
+ while ( size > 0){
+ int nLine = size > 16 ? 16: size;
+
+ char s[250];
+ int pos = 0;
+
+ pos += sprintf( s+pos, "%04x:", nOffset );
+
+ for ( int i = 0; i < nLine; i++ ){
+ pos += sprintf( s+pos, " %02x", (unsigned int)((unsigned char)buf[i]) );
+ }
+ for ( int i = nLine; i < 16; i++ ){
+ pos += sprintf( s+pos, " " );
+ }
+
+ pos += sprintf( s+pos, " " );
+ for ( int i = 0; i < nLine; i++ ){
+ pos += sprintf( s+pos, "%c", (buf[i] > 31 ? buf[i] : '.') );
+ }
+
+ printf( "%s\n", s );
+ buf += nLine;
+ size -= nLine;
+ nOffset += nLine;
+ }
+}
+
+static void ProcessScript( const char* szFile, const char* isBinary )
+{
+ FILE* f = fopen( szFile, "r" );
+ if ( !f ) {
+ printf("%s can't open file %s\n",c_szErrorText, szFile);
+ return;
+ }
+
+ bool bBinary = (isBinary[0] == '1');
+
+ printf("Process WBXML script: %s\n", bBinary? "true" : "false");
+
+ // assume 100k is enough
+ const int c_nSize = 100 * 1024;
+ char* szBuf = new char [c_nSize];
+
+ int n = fread(szBuf, 1, c_nSize, f );
+
+
+ printf("Read %d bytes\n", n);
+ if ( n > 0 ) {
+ szBuf[n] = 0;
+
+ DMString oResult;
+ DMVector<UINT8> bResult;
+ DmtPrincipal p("localhost");
+ SYNCML_DM_RET_STATUS_T res = DmtTreeFactory::ProcessScript( p, (const byte*)szBuf, n, bBinary, bResult);
+
+ if (bBinary == true)
+ {
+ printf( "\nPrint result in HEX mode: \n\n" );
+ // Dump(oResult.c_str(), oResult.length());
+
+ printf( "Result Size: %d\n", bResult.size());
+
+ int resultSize = bResult.size();
+ char* resultBuf = new char [resultSize];
+
+ for (int i = 0; i < bResult.size(); i++) {
+ resultBuf[i] = (char)bResult[i];
+ }
+
+ Dump(resultBuf, resultSize);
+
+ } else
+ {
+
+ int resultSize = bResult.size();
+ char* resultBuf = new char [resultSize+1];
+
+ for (int i = 0; i < bResult.size(); i++) {
+ resultBuf[i] = (char)bResult[i];
+ }
+ resultBuf[resultSize] = '\0';
+
+ printf( "The test Script error code %d; text:\n\n%s\n\n",
+ (int)res,
+ (const char*)resultBuf );
+ }
+ }
+
+ delete [] szBuf;
+ fclose( f );
+}
+
+static void StartServerSession( const char* szServerID, const char* szParam2 )
+{
+ bool bBinary = (szParam2[0] == '1');
+
+ printf("start server session, %s, bin = %s\n",
+ szServerID, bBinary? "true" : "false");
+ e = DmtTreeFactory::StartServerSession( szServerID, bBinary );
+
+ if ( e != NULL ) {
+ Error("can't start server session");
+ }
+}
+
+static void StartServerSessionEx( const char* szServerID, const char* szBin, const char* szCorrelator1, const char* szCorrelator2 )
+{
+ bool bBinary = (szBin[0] == '1');
+
+ printf("start server session, %s, bin = %s, correlator(s) %s, %s\n",
+ szServerID, bBinary? "true" : "false",
+ szCorrelator1, szCorrelator2 );
+
+ DmtSessionProp oProps( DmtFirmAlert( "./DevDetail", "200",
+ "org.openmobilealliance.firmwareupdate.download", "int",
+ "critical", szCorrelator1 ), bBinary );
+
+ if ( szCorrelator2 && *szCorrelator2 ){
+ oProps.addFirmAlert(DmtFirmAlert("./DevInfo", "402",
+ NULL, NULL, NULL, szCorrelator2) );
+
+ oProps.addFirmAlert(DmtFirmAlert("./DevInfo/somewhere", NULL,
+ NULL, NULL, "NULL", NULL) );
+
+ oProps.addFirmAlert(DmtFirmAlert("./DevInfo/somewhere", "data",
+ NULL, NULL, "NULL", NULL) );
+ }
+
+ e = DmtTreeFactory::StartServerSession( szServerID, oProps );
+
+ if ( e.GetErrorCode() != SYNCML_DM_SUCCESS ) {
+ Error("can't start server session");
+ }
+}
+
+
+//typedef SYNCMLDM_SEC_CREDENTIALS_T * (* hmac_callback)
+// (const SYNCMLDM_HMAC_SEC_INFO_T *ps_hmac_sec_info);
+
+static void BuildCredHMAC(const char * server_Id)
+{
+ /***
+ SYNCMLDM_SEC_CREDENTIALS_T *pHmacCreds = NULL;
+ SYNCMLDM_HMAC_SEC_INFO_T hmacSecInfo;
+
+ printf("Build the credentials for HMAC authentication scheme.\n");
+
+ void *dllhandle=dlopen("libdmssession.so", RTLD_NOW);
+ if (dllhandle==NULL)
+ {
+ dlclose( dllhandle );
+ return;
+ }
+ hmacSecInfo.pb_syncml_document = NULL;
+ hmac_callback pFunc=(hmac_callback)dlsym(dllhandle, "syncmldm_sec_build_hmac_cred");
+ pHmacCreds = pFunc((const SYNCMLDM_HMAC_SEC_INFO_T *)&hmacSecInfo);
+ if ( dllhandle != NULL)
+ dlclose(dllhandle);
+ printf("credhmac end.\n");
+ */
+}
+
+
+static DMString CreateServerId(const char * szServerIP)
+{
+ DMString strServerID = "";
+ DMString strPath = "./SyncML/DMAcc/";
+ DMString strPath2;
+ DMString strInput;
+ PDmtNode ptrNode;
+
+ if (s_bAtomic) {
+ s_bAtomic = false;
+ ptrTree = NULL;
+ }
+
+ if ( (e=DmtTreeFactory::GetTree(principal, ptrTree)) != NULL) {
+ Error("can't get tree");
+ return "";
+ }
+
+ // if ( (e=ptrTree->Begin()) != NULL) {
+// Error("can't begin atomic operations");
+// ptrTree = NULL;
+// return "";
+ // }
+
+// strInput = GetInputString("Enter account/profile name:", "test");
+ strPath += "SampleServer";
+
+ if ( ptrTree->IsValidNode( strPath.c_str() ) ) {
+ if ( (e=ptrTree->DeleteNode(strPath.c_str())) != NULL) {
+ Error("can't delete existing node %s", strPath.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+ }
+
+ // Interior node
+ if ( (e=ptrTree->CreateInteriorNode(strPath.c_str(), ptrNode)) != NULL) {
+ Error("can't create node %s", strPath.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // PortNbr
+ //strInput = GetInputString("Enter port no:", "80");
+ strPath2 = strPath;
+ strPath2 += "/PortNbr";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData("80")) ) != NULL) {
+ Error("can't create node %s", strPath2.c_str() );
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // AddrType
+ strPath2 = strPath;
+ strPath2 += "/Name";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData("SampleServer")) ) == NULL) {
+ printf("Stored name=SampleServer\n");
+ } else {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // AddrType
+ strPath2 = strPath;
+ strPath2 += "/AddrType";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData("1")) ) == NULL) {
+ printf("Stored AddrType=1\n");
+ } else {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // Address
+ //DMString strAddr = "http://";
+ //strAddr += szServerIP;
+ //strAddr += "/Manage";
+
+ //strInput = GetInputString("Enter Addr:", strAddr.c_str());
+ strPath2 = strPath;
+ strPath2 += "/Addr";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData("http://10.72.34.36/Manage")) ) != NULL) {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // AuthPref
+// strInput = GetInputString("Enter AuthPref:", "syncml:auth-Basic");
+ strPath2 = strPath;
+ strPath2 += "/AuthPref";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData("syncml:auth-Basic")) ) != NULL) {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // User name
+///// strInput = GetInputString("Enter UserName:", "SampleServer");
+ strPath2 = strPath;
+ strPath2 += "/UserName";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData((CPCHAR)"àåçêëë")) ) != NULL) {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // Client Password
+ // strInput = GetInputString("Enter ClientPW:", "SampleServer");
+ strPath2 = strPath;
+ strPath2 += "/ClientPW";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData((CPCHAR)"ëèïîìì")) ) != NULL) {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // Client Nonce
+// strInput = GetInputString("Enter ClientNonce:", "MTIzNDU=");
+ strPath2 = strPath;
+ strPath2 += "/ClientNonce";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData("123abc")) ) != NULL) {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // ServerID
+// strInput = GetInputString("Enter ServerId:", "sid");
+ strPath2 = strPath;
+ strPath2 += "/ServerId";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData("Scts")) ) == NULL) {
+ strServerID = strInput;
+ } else {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // Server Password
+ // strInput = GetInputString("Enter ServerPW:", "SampleClient");
+ strPath2 = strPath;
+ strPath2 += "/ServerPW";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData((CPCHAR)"üéâäàà")) ) != NULL) {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // Server Nonce
+ // strInput = GetInputString("Enter ServerNonce:", "MTIzNDU=");
+ strPath2 = strPath;
+ strPath2 += "/ServerNonce";
+ if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData("MTIzNDEyMzQxMjM0MTIzNA==")) ) != NULL) {
+ Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ ptrTree = NULL;
+ return "";
+ }
+
+ // ConRef
+ //strPath2 = strPath;
+ //strPath2 += "/ConRef";
+ // if ( (e=ptrTree->CreateLeafNode(strPath2.c_str(), ptrNode, DmtData("1")) ) == NULL) {
+ // printf("Stored ConRef=1\n");
+ //} else {
+ // Error("can't create node %s", strPath2.c_str());
+ // ptrTree->Rollback();
+ // ptrTree = NULL;
+ // return "";
+ // }
+
+// ptrTree->Commit();
+ ptrTree = NULL;
+ return strServerID;
+}
+
+static void CreateAndStartServerSession(const char * szAddr, const char * szParam2)
+{
+ printf("Create Server ID\n");
+ DMString strServerID = CreateServerId(szAddr);
+ if (strServerID="") {
+ printf("Failed to create server id\n");
+ } else {
+ StartServerSession(strServerID.c_str(), szParam2);
+ }
+}
+
+static void ShowTimestamp(const char * sParam)
+{
+ s_bShowTimestamp = (sParam[0] == '1');
+ if (s_bShowTimestamp) {
+ printf("now show timestamp of nodes\n");
+ } else {
+ printf("now don't show timestamp of nodes\n");
+ }
+}
+
+static void ShowProfileTime(const char * sParam)
+{
+ s_bShowProfileTime = (sParam[0] == '1');
+ if (s_bShowProfileTime) {
+ printf("now show profile time\n");
+ } else {
+ printf("now don't show profile time\n");
+ }
+}
+
+static void DMVersion()
+{
+
+ unsigned long libVersion = 0;
+ const char *version = GetDMSyncMLVersion(&libVersion);
+ CPCHAR dm_ver = XPL_DM_GetEnv(SYNCML_DM_VERSION);
+ printf("DM Version: %s\n", dm_ver);
+ printf("LIB Version = 0x%06x \nDMSyncMLVersion = %s\n", libVersion, version);
+
+}
+
+static void SuperAgent()
+{
+
+ CPCHAR dm_ver = XPL_DM_GetEnv(SYNCML_DM_VERSION);
+ PDmtNode ptrNode;
+ if (strcmp(dm_ver, "1.1.2") == 0) {
+ CreateInterior("./SyncML/DMAcc/SuperAgent");
+ CreateLeaf("./SyncML/DMAcc/SuperAgent/ServerId", "LJAgent");
+ if (e != NULL) {
+ return;
+ }
+ ptrNode = GetNode("./SyncML/DMAcc/SuperAgent/ServerId");
+ } else if (strcmp(dm_ver, "1.2") == 0) {
+ CreateInterior("./DMAcc/SuperAgent");
+ CreateLeaf("./DMAcc/SuperAgent/ServerID", "LJAgent");
+ if (e != NULL) {
+ return;
+ }
+ ptrNode = GetNode("./DMAcc/SuperAgent/ServerID");
+ } else {
+ Error("DM Version not supported!\n");
+ return;
+ }
+
+ if ( ptrNode == NULL ) {
+ if (strcmp(dm_ver, "1.1.2") == 0) {
+ Error("can't get Node ./SyncML/DMAcc/SuperAgent/ServerId");
+ return;
+ } else if (strcmp(dm_ver, "1.2") == 0) {
+ Error("can't get Node ./DMAcc/SuperAgent/ServerID");
+ return;
+ }
+ }
+
+
+ DmtAcl oAcl( "Replace=*");
+ if ( (e=ptrNode->SetAcl(oAcl)) != NULL )
+ {
+ if (strcmp(dm_ver, "1.1.2") == 0) {
+ Error("can't set acl of node ./SyncML/DMAcc/SuperAgent/ServerId to Replace=*");
+ return;
+ } else if (strcmp(dm_ver, "1.2") == 0) {
+ Error("can't set acl of node ./DMAcc/SuperAgent/ServerID to Replace=*");
+ return;
+ }
+ }
+
+ DmtData dmData;
+ if( (e=ptrNode->GetValue(dmData)) == NULL )
+ {
+ Error("Get node value even if don't have get permission");
+ return;
+ }
+ ptrNode = NULL;
+ ptrTree = NULL;
+
+
+ DmtPrincipal lj("LJAgent");
+
+ PDmtTree tree;
+ if ( (e=DmtTreeFactory::GetSubtree(lj, s_strRootPath.c_str(), tree)) != NULL )
+ {
+ Error("can't get tree for LJAgent");
+ return;
+ }
+
+ if( tree != NULL )
+ {
+ if (strcmp(dm_ver, "1.1.2") == 0) {
+ if( (e=tree->GetNode("./SyncML/DMAcc/SuperAgent/ServerId", ptrNode)) != NULL )
+ {
+ Error("can't get node for LJAgent");
+ }
+
+ } else if (strcmp(dm_ver, "1.2") == 0) {
+ if( (e=tree->GetNode("./DMAcc/SuperAgent/ServerID", ptrNode)) != NULL )
+ {
+ Error("can't get node for LJAgent");
+ }
+ }
+
+ if( ptrNode != NULL )
+ {
+ PrintNode(ptrNode);
+ if (strcmp(dm_ver, "1.1.2") == 0) {
+ if( (e=tree->DeleteNode("./SyncML/DMAcc/SuperAgent")) != NULL )
+ {
+ Error("can't delete ./SyncML/DMAcc/SuperAgent by LJAgent");
+ }
+ } else if (strcmp(dm_ver, "1.2") == 0) {
+ if( (e=tree->DeleteNode("./DMAcc/SuperAgent")) != NULL )
+ {
+ Error("can't delete ./DMAcc/SuperAgent by LJAgent");
+ }
+ }
+ }
+ }
+}
+
+
+static void SubTreeStruct(PDmtNode ptrNode, int depth)
+{
+ for (int i=0; i < depth; i++) {
+ if (i == (depth-1)) {
+ printf("^---");
+ } else {
+ printf(" ");
+ }
+ }
+
+ DMString strName;
+ ptrNode->GetNodeName(strName);
+ if (ptrNode->IsLeaf() ) {
+ DMString strValue;
+ DMString strName;
+ ptrNode->GetStringValue(strValue);
+ printf("%s: %s\n", strName.c_str(), strValue.c_str());
+ } else {
+ printf("%s(node)\n", strName.c_str());
+ DMVector<PDmtNode> aChildren;
+ if ( (e=ptrNode->GetChildNodes( aChildren )) != NULL ) {
+ DMString strPath;
+ ptrNode->GetPath(strPath);
+ Error("can't get child nodes of %s\n", strPath.c_str());
+ return;
+ }
+ for (int i=0; i < aChildren.size(); i++) {
+ SubTreeStruct(aChildren[i], depth+1);
+ }
+ }
+}
+
+static void TreeStruct(const char * sParam)
+{
+ PDmtNode ptrNode = GetNode( sParam );
+ if ( ptrNode == NULL ) {
+ return;
+ }
+ SubTreeStruct( ptrNode, 0 );
+}
+
+
+static void SubscribeOnEvents()
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+
+ DmtEventSubscription oEvent;
+ DmtEventSubscription oEvent1;
+
+ UINT8 event = SYNCML_DM_EVENT_ADD | SYNCML_DM_EVENT_REPLACE |
+ SYNCML_DM_EVENT_DELETE | SYNCML_DM_EVENT_INDIRECT;
+
+
+ oEvent.Set(event,SYNCML_DM_EVENT_DETAIL);
+
+ dm_stat = DmtTreeFactory::SubscribeEvent("./UnitTest", oEvent);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return;
+
+ dm_stat = DmtTreeFactory::SubscribeEvent("./TEST", oEvent);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return;
+
+ dm_stat = DmtTreeFactory::SubscribeEvent("./CLONE", oEvent);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return;
+
+ dm_stat = DmtTreeFactory::SubscribeEvent("./TestRWPluginNode", oEvent);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return;
+
+ GetTree();
+
+ PDmtNode ptrNode;
+ DmtData oData("server");
+
+
+ ptrTree->DeleteNode("./DMAcc/Test");
+ ptrTree->DeleteNode("./DMAcc/Test1");
+ ptrTree->DeleteNode("./DMAcc/Test2");
+ ptrTree->DeleteNode("./DMAcc/Test3");
+ ptrTree->CreateInteriorNode( "./DMAcc/Test", ptrNode );
+ ptrTree->CreateInteriorNode( "./DMAcc/Test1", ptrNode );
+ ptrTree->CreateInteriorNode( "./DMAcc/Test2", ptrNode );
+ ptrTree->CreateLeafNode( "./DMAcc/Test/ServerID", ptrNode, oData );
+ ptrTree->CreateLeafNode( "./DMAcc/Test1/ServerID", ptrNode, oData );
+ ptrTree->CreateLeafNode( "./DMAcc/Test2/ServerID", ptrNode, oData );
+ if ( ptrNode )
+ {
+ ptrNode->SetValue(oData);
+ ptrNode->SetValue(oData);
+ ptrNode->SetValue(oData);
+ }
+ ptrTree->RenameNode("./DMAcc/Test", "Test3");
+ ptrTree->DeleteNode( "./DMAcc/Test3" );
+ ptrTree->DeleteNode("./DMAcc/Test1");
+ ptrTree->DeleteNode("./DMAcc/Test2");
+
+}
+
+
+static void Usage()
+{
+ printf( "Supported commands:\n"
+ "exit, quit, q - exit\n"
+ "? - help screen\n"
+ "get <node> - print node info\n"
+ "createi <node> - create interior node\n"
+ "createl <node> <string> - create string leaf node\n"
+ "createli <node> <integer> - create integer leaf node\n"
+ "createlz <node> true|false - create boolean leaf node\n"
+ "createlb <node> <binary> - create binary leaf node\n"
+ "createlbe <node> - create binary leaf node with default value\n"
+ "createlf <node> <float> - create float leaf node\n"
+ "createld <node> <date> - create date leaf node\n"
+ "createlt <node> <time> - create time leaf node\n"
+ "delete <node> - delete node\n"
+ "rename <node> <new name> - rename node name\n"
+ "setESN <node> <file> - set External Storage Node data\n"
+ "settitle <node> <title> - set node title\n"
+ "setacl <node> <acl> - set node acl\n"
+ "set|replace <node> <string>- set string value\n"
+ "seti <node> <integer> - set integer value\n"
+ "setz <node> true|false - set boolean value\n"
+ "setf <node> <float> - set float value\n"
+ "setd <node> <date> - set date value\n"
+ "sett <node> <time> - set time value\n"
+ "setb <node> <bytes> - set bytes value\n"
+ "dump <node> - dump the subtree from the node\n"
+ "exec <node> - execute node\n"
+ "getmap <node> - \n"
+ "hmaccred <string> - build the credentials for HMAC \n"
+/* "setmap <node> - \n" */
+ "ProcessScript <file> | <using binary xml [0/1]> - reads file and calls ProcessScript\n"
+ "tree|open <node> - open subtree\n"
+ "GetExclusiveTree <node> - get exclusive subtree subtree\n"
+ "release - release the tree\n"
+ "flush - flush the tree\n"
+/* "reset <mode> - reset tree\n" */
+ "begin - begin atomic operations\n"
+ "rollback - rollback atomic operations\n"
+ "commit - commit atmoic operations\n"
+/* "alert - \n" */
+ "clone <node> <new node> - clone a new node\n"
+ "StartServerSession|connectsid <server ID> <using binary xml [0/1]> - starts server session\n"
+ "sss <server ID> <using binary xml [0/1]> <correlator 1> <correlator 2> - starts server session\n"
+ "connect <server_ip> <using binary xml [0/1]> - create new server ID and start server session\n"
+ "createsid <server ip> - create new server ID\n"
+ "showtimestamp [0/1] - toggle showing timestamp\n"
+ "showprofiletime [0/1] - toggle showing profiling time\n"
+ "version - show version of DM engine\n"
+ "superagent - test SuperAgent function\n"
+ "SetAutoRelease on|off - turn on/off autorelease of the tree\n"
+ "struct - Show tree struct\n"
+ "startCounter - Start counter for executed command\n"
+ "endCounter - End counter for command\n"
+ "displayCountStatus - Display count status ON/OFF\n"
+ "resetCounter - Reset the counter back to zero\n"
+ "getCounter - Get the number of executed command\n"
+ );
+}
+
+int InteractiveMode(int argc, char** argv)
+{
+ if ( !DmtTreeFactory::Initialize() ) {
+ printf("Fail to init DM tree\n");
+ return 1;
+ }
+
+ if ( GetTree() == NULL ) {
+ return 1;
+ }
+ ptrTree = NULL;
+
+ SubscribeOnEvents();
+
+ printf( "Interaction mode, type \"exit\" to exit, ? for help\n");
+
+ while ( true ) {
+ printf("\n] ");
+
+ DMString sOperation = GetCmd();
+ const char* szOperation = sOperation.c_str();
+
+ if ( strcasecmp(szOperation, "") == 0 || szOperation[0] == '#') {
+ continue;
+ }
+
+ printf("Cmd: %s%s\n", szOperation, s_strCurLine.c_str());
+
+ DMString sParam1 = GetParam();
+ if ( strcasecmp( szOperation, "setmap" ) == 0 ) {
+ SetMap(sParam1);
+ if ( !s_bAtomic ) {
+ //ptrTree = NULL;
+ }
+ continue;
+ }
+ DMString sParam2 = GetParam();
+ DMString sParam3 = GetParam();
+ DMString sParam4 = GetParam();
+
+ TestProfile oProf( szOperation );
+
+
+ if ( strcasecmp( szOperation, "exit" ) == 0 ||
+ strcasecmp( szOperation, "quit" ) == 0 ||
+ strcasecmp( szOperation, "q" ) == 0) {
+ break;
+ } else if ( strcasecmp( szOperation, "get" ) == 0 ) {
+ Get( sParam1 );
+ } else if ( strcasecmp( szOperation, "delete" ) == 0 ) {
+ Delete( sParam1 );
+ } else if ( strcasecmp( szOperation, "createi" ) == 0 ) {
+ CreateInterior( sParam1 );
+ } else if ( strcasecmp( szOperation, "createl" ) == 0 ) {
+ CreateLeaf( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "createli" ) == 0 ) {
+ CreateLeafInteger( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "createlz" ) == 0 ) {
+ CreateLeafBoolean( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "createlb" ) == 0 ) {
+ CreateLeafBinary( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "createlbe" ) == 0 ) {
+ CreateLeafBinaryE( sParam1 );
+ } else if ( strcasecmp( szOperation, "createlf" ) == 0 ) {
+ CreateLeafFloat( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "createld" ) == 0 ) {
+ CreateLeafDate( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "createlt" ) == 0 ) {
+ CreateLeafTime( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "rename") == 0 ) {
+ Rename( sParam1, sParam2);
+ } else if ( strcasecmp( szOperation, "settitle") == 0 ) {
+ SetTitle( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "setESN") == 0 ) {
+ setESN( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "setacl" ) == 0 ) {
+ SetAcl( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "set") == 0 ||
+ strcasecmp( szOperation, "replace" ) == 0 ) {
+ ReplaceString( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "seti" ) == 0 ) {
+ ReplaceInteger( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "setz" ) == 0 ) {
+ ReplaceBoolean( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "setb" ) == 0 ) {
+ ReplaceBytes( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "setf" ) == 0 ) {
+ ReplaceFloat( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "setd" ) == 0 ) {
+ ReplaceDate( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "sett" ) == 0 ) {
+ ReplaceTime( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "hmaccred" ) == 0 ) {
+ BuildCredHMAC( sParam1 );
+ } else if ( strcasecmp( szOperation, "dump" ) == 0 ) {
+ DumpTree( sParam1 );
+ } else if (strcasecmp( szOperation, "exec") == 0 ||
+ strcasecmp(szOperation, "execute") == 0 ) {
+ Execute( sParam1, sParam2 );
+ } else if (strcasecmp( szOperation, "getmap") == 0) {
+ GetMap(sParam1);
+ } else if (strcasecmp( szOperation, "open") == 0 ||
+ strcasecmp(szOperation, "tree") == 0 ) {
+ Open( sParam1 );
+ } else if (strcasecmp(szOperation, "GetExclusiveTree") == 0 ) {
+ GetExclusiveTree( sParam1 );
+ } else if (strcasecmp( szOperation, "release") == 0) {
+ Release();
+ } else if (strcasecmp( szOperation, "flush") == 0) {
+ Flush();
+ } else if (strcasecmp( szOperation, "begin") == 0) {
+ Begin();
+ } else if (strcasecmp( szOperation, "commit") == 0) {
+ Commit();
+ } else if (strcasecmp( szOperation, "rollback") == 0) {
+ Rollback();
+ } else if (strcasecmp( szOperation, "clone") == 0) {
+ Clone( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "ProcessScript" ) == 0 ) {
+ ProcessScript( sParam1 , sParam2);
+ } else if ( strcasecmp( szOperation, "connectsid" ) == 0 ||
+ strcasecmp(szOperation, "StartServerSession") == 0 ) {
+ StartServerSession( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "sss" ) == 0 ) {
+ StartServerSessionEx( sParam1, sParam2, sParam3, sParam4 );
+ } else if ( strcasecmp( szOperation, "createsid" ) == 0 ) {
+ CreateServerId( sParam1 );
+ } else if ( strcasecmp( szOperation, "connect") == 0) {
+ CreateAndStartServerSession( sParam1, sParam2 );
+ } else if ( strcasecmp( szOperation, "showtimestamp") == 0) {
+ ShowTimestamp( sParam1 );
+ } else if ( strcasecmp( szOperation, "showprofiletime") == 0) {
+ ShowProfileTime( sParam1 );
+ } else if ( strcasecmp( szOperation, "version") == 0) {
+ DMVersion();
+ } else if ( strcasecmp( szOperation, "superagent") == 0) {
+ SuperAgent();
+ } else if ( strcasecmp( szOperation, "SetAutoRelease" ) == 0 ) {
+ s_bAutoReleaseTree =
+ (strcasecmp(sParam1, "on") == 0 ||
+ strcasecmp(sParam1, "yes") == 0 ||
+ strcasecmp(sParam1, "true") == 0 ||
+ strcasecmp(sParam1, "1") == 0);
+ printf("Autorelease is now %s\n", s_bAutoReleaseTree ? "ON" : "OFF");
+ } else if ( strcasecmp( szOperation, "struct") == 0) {
+ TreeStruct( sParam1 );
+
+ } else if ( strcasecmp( szOperation, "startCounter") == 0) {
+ startCounter();
+ } else if ( strcasecmp( szOperation, "endCounter") == 0) {
+ endCounter();
+ } else if ( strcasecmp( szOperation, "displayCountStatus") == 0) {
+ displayCountStatus();
+ } else if ( strcasecmp( szOperation, "resetCounter") == 0) {
+ resetCounter();
+ } else if ( strcasecmp( szOperation, "getCounter") == 0) {
+ getCounter();
+ } else if ( strcasecmp( szOperation, "?" ) == 0 ||
+ strcasecmp( szOperation, "help" ) == 0) {
+ Usage();
+ } else {
+ printf( "Unknown option %s.\n", szOperation );
+ Usage();
+ }
+ if (!s_bAtomic && s_bAutoReleaseTree) {
+ ptrTree = NULL;
+ }
+ }
+
+ DmtTreeFactory::Uninitialize();
+ return 0;
+}
+
+int defaultFunction()
+{
+ if ( !DmtTreeFactory::Initialize() ) {
+ printf("Fail to init DM tree\n");
+ return 1;
+ }
+
+ if ( (e=DmtTreeFactory::GetTree(principal, ptrTree)) != NULL ) {
+ printf( "%s can't get tree, %d\n", c_szErrorText, e->GetErrorCode() );
+ return 1;
+ }
+
+ PDmtNode ptrNode;
+ DMString strNode = "./DevDetail/Bearer/GSM";
+
+ if ( (e=ptrTree->GetNode( strNode, ptrNode )) != NULL )
+ printf( "can't get node %s, error %s\n", strNode.c_str(), (const char*)e->GetErrorText().c_str() );
+ else {
+ e = ptrNode->SetValue( DmtData("123"));
+ if ( e != NULL )
+ printf( "can't set node value [%s], error %s\n", strNode.c_str(), (const char*)e->GetErrorText().c_str() );
+
+ }
+
+ ptrNode = NULL;
+ ptrTree = NULL;
+
+ printf(" start server session\n");
+ e = DmtTreeFactory::StartServerSession( "Scts", false );
+
+ if ( e != NULL ) {
+ printf( "error %d\n", e->GetErrorCode());
+ }
+
+ DmtTreeFactory::Uninitialize();
+
+ printf("Done.\n");
+ return 0;
+}
+
+static void isVersionOn(int argc, char** argv)
+{
+ for(int i=1; i<argc; i++)
+ {
+ if(strcmp(argv[i], "-version") == 0 )
+ {
+ DMVersion();
+ break;
+ }
+ }
+}
+
+int main(int argc, char** argv)
+{
+ isVersionOn(argc, argv);
+ const char* szParam1 = argc > 1 ? argv[1] : "";
+ if ( strcmp( szParam1, "unittest" ) == 0 ) {
+ return defaultFunction();
+ }
+ else if ( strcmp( szParam1, "mt" ) == 0 ) {
+ return MultiProcessTest();
+ }
+
+ return InteractiveMode(argc, argv);
+}
diff --git a/engine/dmlib/linux_java/test/dm11/testadd.wbxml b/engine/dmlib/linux_java/test/dm11/testadd.wbxml
new file mode 100644
index 0000000..b88e428
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testadd.wbxml
Binary files differ
diff --git a/engine/dmlib/linux_java/test/dm11/testalertconfirm.xml b/engine/dmlib/linux_java/test/dm11/testalertconfirm.xml
new file mode 100644
index 0000000..1a4c470
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testalertconfirm.xml
@@ -0,0 +1,32 @@
+ <SyncML xmlns="SYNCML:SYNCML1.1">
+ <SyncHdr>
+ <VerDTD>1.1</VerDTD>
+ <VerProto>DM/1.1</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+
+
+ <Alert>
+ <CmdID>2</CmdID>
+ <Data>1101</Data>
+ <Item><Data>MAXDT=15&DR=1</Data></Item>
+ <Item>
+ <Data>Testing Confirmation Alert</Data>
+ </Item>
+ </Alert>
+
+ <Final/>
+ </SyncBody>
+ </SyncML>
diff --git a/engine/dmlib/linux_java/test/dm11/testalertconfirmatomic.xml b/engine/dmlib/linux_java/test/dm11/testalertconfirmatomic.xml
new file mode 100644
index 0000000..680fce4
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testalertconfirmatomic.xml
@@ -0,0 +1,48 @@
+ <SyncML xmlns="SYNCML:SYNCML1.1">
+ <SyncHdr>
+ <VerDTD>1.1</VerDTD>
+ <VerProto>DM/1.1</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+
+<Atomic>
+<CmdID>1</CmdID>
+
+ <Alert>
+ <CmdID>2</CmdID>
+ <Data>1101</Data>
+ <Item><Data>MAXDT=15DR=1</Data></Item>
+ <Item>
+ <Data>Testing Confirmation Alert</Data>
+ </Item>
+ </Alert>
+
+ <Replace>
+ <CmdID>3</CmdID>
+ <Meta>
+ <Format xmlns="syncml:metinf">chr</Format>
+ <Type xmlns="syncml:metinf">text/plain</Type>
+ </Meta>
+ <Item>
+ <Target><LocURI>./DevDetail/Bearer/GSM</LocURI></Target>
+ <Data>test</Data>
+ </Item>
+ </Replace>
+
+</Atomic>
+
+ <Final/>
+ </SyncBody>
+ </SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm11/testalertdisplay.xml b/engine/dmlib/linux_java/test/dm11/testalertdisplay.xml
new file mode 100644
index 0000000..7f64a16
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testalertdisplay.xml
@@ -0,0 +1,29 @@
+ <SyncML xmlns="SYNCML:SYNCML1.1">
+ <SyncHdr>
+ <VerDTD>1.1</VerDTD>
+ <VerProto>DM/1.1</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+ <Alert>
+ <CmdID>1</CmdID>
+ <Data>1100</Data>
+ <Item><Data>MINDT=15</Data></Item>
+ <Item>
+ <Data>Testing Display Alert</Data>
+ </Item>
+ </Alert>
+ <Final/>
+ </SyncBody>
+ </SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm11/testalertmultiplechoice.xml b/engine/dmlib/linux_java/test/dm11/testalertmultiplechoice.xml
new file mode 100644
index 0000000..3299e47
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testalertmultiplechoice.xml
@@ -0,0 +1,47 @@
+ <SyncML xmlns="SYNCML:SYNCML1.1">
+ <SyncHdr>
+ <VerDTD>1.1</VerDTD>
+ <VerProto>DM/1.1</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+ <Alert>
+ <CmdID>1</CmdID>
+ <Data>1104</Data>
+ <Item><Data>MAXDT=20&DR=1-3,6</Data></Item>
+ <Item>
+ <Data>Testing Multiple Choice Alert</Data>
+ </Item>
+ <Item>
+ <Data>choice one</Data>
+ </Item>
+ <Item>
+ <Data>choice two</Data>
+ </Item>
+ <Item>
+ <Data>choice three</Data>
+ </Item>
+ <Item>
+ <Data>choice four</Data>
+ </Item>
+ <Item>
+ <Data>choice five</Data>
+ </Item>
+ <Item>
+ <Data>choice six</Data>
+ </Item>
+ </Alert>
+ <Final/>
+ </SyncBody>
+ </SyncML>
diff --git a/engine/dmlib/linux_java/test/dm11/testalertsinglechoice.xml b/engine/dmlib/linux_java/test/dm11/testalertsinglechoice.xml
new file mode 100644
index 0000000..dd768c5
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testalertsinglechoice.xml
@@ -0,0 +1,47 @@
+ <SyncML xmlns="SYNCML:SYNCML1.1">
+ <SyncHdr>
+ <VerDTD>1.1</VerDTD>
+ <VerProto>DM/1.1</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+ <Alert>
+ <CmdID>1</CmdID>
+ <Data>1103</Data>
+ <Item><Data>MAXDT=20&DR=2</Data></Item>
+ <Item>
+ <Data>Testing Single Choice Alert</Data>
+ </Item>
+ <Item>
+ <Data>choice one</Data>
+ </Item>
+ <Item>
+ <Data>choice two</Data>
+ </Item>
+ <Item>
+ <Data>choice three</Data>
+ </Item>
+ <Item>
+ <Data>choice four</Data>
+ </Item>
+ <Item>
+ <Data>choice five</Data>
+ </Item>
+ <Item>
+ <Data>choice six</Data>
+ </Item>
+ </Alert>
+ <Final/>
+ </SyncBody>
+ </SyncML>
diff --git a/engine/dmlib/linux_java/test/dm11/testalerttextinput.xml b/engine/dmlib/linux_java/test/dm11/testalerttextinput.xml
new file mode 100644
index 0000000..e1c29fc
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testalerttextinput.xml
@@ -0,0 +1,29 @@
+ <SyncML xmlns="SYNCML:SYNCML1.1">
+ <SyncHdr>
+ <VerDTD>1.1</VerDTD>
+ <VerProto>DM/1.1</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+ <Alert>
+ <CmdID>1</CmdID>
+ <Data>1102</Data>
+ <Item><Data>MAXDT=20&DR=hello+andy!&MAXLEN=30&IT=I&ET=P</Data></Item>
+ <Item>
+ <Data>Testing Text Input Alert</Data>
+ </Item>
+ </Alert>
+ <Final/>
+ </SyncBody>
+ </SyncML>
diff --git a/engine/dmlib/linux_java/test/dm11/testdelete.wbxml b/engine/dmlib/linux_java/test/dm11/testdelete.wbxml
new file mode 100644
index 0000000..feab96e
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testdelete.wbxml
Binary files differ
diff --git a/engine/dmlib/linux_java/test/dm11/testexecscript.xml b/engine/dmlib/linux_java/test/dm11/testexecscript.xml
new file mode 100644
index 0000000..da35c2d
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testexecscript.xml
@@ -0,0 +1,30 @@
+<SyncML xmlns="SYNCML:SYNCML1.1">
+<SyncHdr>
+<VerDTD>1.1</VerDTD>
+<VerProto>DM/1.1</VerProto>
+<SessionID>11</SessionID>
+<MsgID>1</MsgID>
+<Target>
+<LocURI>SampleClient</LocURI>
+</Target>
+<Source>
+<LocURI>mot.manage</LocURI>
+</Source>
+<RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+<Meta>
+<MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+</Meta>
+</SyncHdr>
+<SyncBody>
+<Exec>
+<CmdID>1</CmdID>
+<Item>
+<Target>
+<LocURI>.</LocURI>
+</Target>
+<Data>uname</Data>
+</Item>
+</Exec>
+<Final/>
+</SyncBody>
+</SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm11/testexecscript2.xml b/engine/dmlib/linux_java/test/dm11/testexecscript2.xml
new file mode 100644
index 0000000..eb15742
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testexecscript2.xml
@@ -0,0 +1,30 @@
+<SyncML xmlns="SYNCML:SYNCML1.1">
+<SyncHdr>
+<VerDTD>1.1</VerDTD>
+<VerProto>DM/1.1</VerProto>
+<SessionID>11</SessionID>
+<MsgID>1</MsgID>
+<Target>
+<LocURI>SampleClient</LocURI>
+</Target>
+<Source>
+<LocURI>mot.manage</LocURI>
+</Source>
+<RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+<Meta>
+<MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+</Meta>
+</SyncHdr>
+<SyncBody>
+<Exec>
+<CmdID>1</CmdID>
+<Item>
+<Target>
+<LocURI>.</LocURI>
+</Target>
+<Data>ls</Data>
+</Item>
+</Exec>
+<Final/>
+</SyncBody>
+</SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm11/testget.wbxml b/engine/dmlib/linux_java/test/dm11/testget.wbxml
new file mode 100644
index 0000000..51cda4d
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testget.wbxml
Binary files differ
diff --git a/engine/dmlib/linux_java/test/dm11/testgetscript.xml b/engine/dmlib/linux_java/test/dm11/testgetscript.xml
new file mode 100644
index 0000000..013e1c6
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testgetscript.xml
@@ -0,0 +1,29 @@
+<SyncML xmlns="SYNCML:SYNCML1.1">
+<SyncHdr>
+<VerDTD>1.1</VerDTD>
+<VerProto>DM/1.1</VerProto>
+<SessionID>11</SessionID>
+<MsgID>1</MsgID>
+<Target>
+<LocURI>SampleClient</LocURI>
+</Target>
+<Source>
+<LocURI>mot.manage</LocURI>
+</Source>
+<RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+<Meta>
+<MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+</Meta>
+</SyncHdr>
+<SyncBody>
+<Get>
+<CmdID>1</CmdID>
+<Item>
+<Target>
+<LocURI>./DevInfo/DevId</LocURI>
+</Target>
+</Item>
+</Get>
+<Final/>
+</SyncBody>
+</SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm11/testinput11 b/engine/dmlib/linux_java/test/dm11/testinput11
new file mode 100644
index 0000000..2897035
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testinput11
@@ -0,0 +1,280 @@
+########################################
+# Test Get
+########################################
+
+startCounter
+
+get .
+get ./DevInfo/DevId
+
+createi ./SyncML/DMAcc/UniTest
+createl ./SyncML/DMAcc/UniTest/ServerId 1.1.1.1
+get ./SyncML/DMAcc/UniTest/ServerId
+replace ./SyncML/DMAcc/UniTest/ServerId 2.2.2.2
+delete ./SyncML/DMAcc/UniTest
+get .
+
+########################################
+# Test dump tree
+########################################
+
+dump ./DevInfo
+dump ./SyncML
+dump ./DevDetail
+
+########################################
+# Test rollback
+# 1 failure
+########################################
+
+begin
+createi ./SyncML/Con/x
+get ./SyncML/Con/x
+rollback
+
+# Next should fail
+get ./SyncML/Con/x
+
+########################################
+# Plugin Tests
+########################################
+
+# data plugin
+# 0 failure
+
+get ./TestPluginNode
+get ./TestPluginNode/a
+get ./TestPluginNode/b
+dump ./TestPluginNode
+
+########################################
+# Script tests
+########################################
+
+processscript unittest/dm11/testgetscript.xml
+processscript unittest/dm11/testexecscript.xml
+processscript unittest/dm11/testexecscript2.xml
+
+processscript unittest/dm11/testalertconfirmatomic.xml
+processscript unittest/dm11/testalertmultiplechoice.xml
+processscript unittest/dm11/testalertconfirm.xml
+processscript unittest/dm11/testalertsinglechoice.xml
+processscript unittest/dm11/testalertdisplay.xml
+processscript unittest/dm11/testalerttextinput.xml
+
+########################################
+# Binary Script tests
+########################################
+processscript unittest/dm11/testget.wbxml 1
+processscript unittest/dm11/testadd.wbxml 1
+processscript unittest/dm11/testdelete.wbxml 1
+processscript unittest/dm11/testreplace.wbxml 1
+
+########################################
+# SuperAgent Test and Build HMAC Cred
+########################################
+hmaccred scts
+
+########################################
+# Factory Boostrap Credential Generation for 1.1.2
+########################################
+createi ./SyncML/DMAcc/SampleServer
+createl ./SyncML/DMAcc/SampleServer/ServerId Scts
+createl ./SyncML/DMAcc/SampleServer/Addr http://127.0.0.1:80/Manage
+createl ./SyncML/DMAcc/SampleServer/AddrType 1
+createl ./SyncML/DMAcc/SampleServer/ConRef
+createl ./SyncML/DMAcc/SampleServer/Name SampleServer
+createl ./SyncML/DMAcc/SampleServer/ServerPW SampleServer
+createl ./SyncML/DMAcc/SampleServer/UserName SampleServer
+createl ./SyncML/DMAcc/SampleServer/ClientPW SampleServer
+createl ./SyncML/DMAcc/SampleServer/PortNbr 80
+createl ./SyncML/DMAcc/SampleServer/ServerNonce MTIzNDEyMzQxMjM0MTIzNA==
+createl ./SyncML/DMAcc/SampleServer/ClientNonce 123abc
+createl ./SyncML/DMAcc/SampleServer/AuthPref syncml:auth-basic
+
+connectsid Scts
+
+dump ./SyncML/DMAcc/SampleServer
+
+delete ./SyncML/DMAcc/SampleServer
+
+########################################
+# Exec test
+########################################
+Exec . ls
+
+########################################
+# Commit plug-in test for indirect update
+# and for fk: and child: MA
+########################################
+createi ./UnitTest/Profiles11/1
+createl ./UnitTest/Profiles11/1/CurProfile 12
+createi ./UnitTest/Profiles11/2
+createl ./UnitTest/Profiles11/2/CurProfile 12
+
+createi ./SyncML/DMAcc/12
+createl ./SyncML/DMAcc/12/ServerId some
+
+createl ./UnitTest/Profiles11/1/CurProfile 12
+createl ./UnitTest/Profiles11/2/CurProfile 12
+
+replace ./SyncML/DMAcc/12/ServerId some3
+createl ./SyncML/DMAcc/12/AppID some
+
+# should fail since child: constraint
+delete ./SyncML/DMAcc/12
+
+# clean-up
+delete ./UnitTest/Profiles11/1
+delete ./UnitTest/Profiles11/2
+delete ./SyncML/DMAcc/12
+
+dump ./TestRWPluginNode
+
+########################################
+# Create a char type ESN
+########################################
+createl ./TEST/lob
+setESN ./TEST/lob unittest/dm11/testlobdata1.dat
+get ./TEST/lob
+
+########################################
+# Replace a char type ESN data
+########################################
+
+setESN ./TEST/lob unittest/dm11/testlobdata2.dat
+get ./TEST/lob
+
+########################################
+# Clone a char type ESN
+########################################
+delete ./CLONE
+clone ./TEST CLONE
+get ./CLONE/lob
+
+########################################
+# Remove a char type ESN
+########################################
+
+delete ./TEST/lob
+delete ./CLONE/lob
+get ./TEST/lob
+
+########################################
+# Rollback an char type ESN
+########################################
+begin
+createl ./TEST/lob
+setESN ./TEST/lob unittest/dm11/testlobdata1.dat
+rollback
+get ./TEST/lob
+
+########################################
+# Create a binary type ESN
+########################################
+createlb ./TEST/lobbin
+setESN ./TEST/lob unittest/dm11/testlobdata1.dat
+get ./TEST/lobbin
+
+########################################
+# Replace a binary type ESN data
+########################################
+
+setESN ./TEST/lobbin unittest/dm11/testlobdata2.dat
+get ./TEST/lobbin
+
+########################################
+# Clone a binary type ESN
+########################################
+delete ./CLONE
+clone ./TEST CLONE
+get ./CLONE/lobbin
+
+########################################
+# Remove a binary type ESN
+########################################
+
+delete ./TEST/lobbin
+delete ./CLONE/lobbin
+get ./TEST/lobbin
+
+########################################
+# Rollback an binary type ESN
+########################################
+begin
+createlb ./TEST/lobbin
+setESN ./TEST/lobbin unittest/dm11/testlobdata1.dat
+rollback
+get ./TEST/lobbin
+
+########################################
+# Create a char type ESN
+########################################
+delete ./TestRWPluginNode/branch1/lob
+createl ./TestRWPluginNode/branch1/lob
+setESN ./TestRWPluginNode/branch1/lob unittest/dm11/testlobdata1.dat
+get ./TestRWPluginNode/branch1/lob
+
+########################################
+# Replace a char type ESN data
+########################################
+
+setESN ./TestRWPluginNode/branch1/lob unittest/dm11/testlobdata2.dat
+get ./TestRWPluginNode/branch1/lob
+
+########################################
+# Create a binary type ESN
+########################################
+delete ./TestRWPluginNode/branch1/lobbin
+createlb ./TestRWPluginNode/branch1/lobbin
+setESN ./TestRWPluginNode/branch1/lobbin unittest/dm11/testlobdata1.dat
+get ./TestRWPluginNode/branch1/lobbin
+
+########################################
+# Replace a binary type ESN data
+########################################
+
+setESN ./TestRWPluginNode/branch1/lobbin unittest/dm11/testlobdata2.dat
+get ./TestRWPluginNode/branch1/lobbin
+
+
+########################################
+# Clone a char type ESN
+########################################
+delete ./TestRWPluginNode/clone
+clone ./TestRWPluginNode/branch1 clone
+get ./TestRWPluginNode/clone/lob
+get ./TestRWPluginNode/clone/lobbin
+
+########################################
+# Remove a char type ESN
+########################################
+
+delete ./TestRWPluginNode/clone
+delete ./TestRWPluginNode/branch1/lob
+delete ./TestRWPluginNode/branch1/lobbin
+get ./TestRWPluginNode/clone/lobbin
+get ./TestRWPluginNode/branch1/lob
+get ./TestRWPluginNode/branch1/lobbin
+
+########################################
+# Rollback an char type ESN
+########################################
+begin
+createl ./TestRWPluginNode/branch1/lob
+setESN ./TestRWPluginNode/branch1/lob unittest/dm11/testlobdata1.dat
+rollback
+get ./TestRWPluginNode/branch1/lob
+
+########################################
+# Rollback an binary type ESN
+########################################
+begin
+createlb ./TestRWPluginNode/branch1/lobbin
+setESN ./TestRWPluginNode/branch1/lobbin unittest/dm11/testlobdata1.dat
+rollback
+get ./TestRWPluginNode/branch1/lobbin
+
+getCounter
+
+quit
diff --git a/engine/dmlib/linux_java/test/dm11/testlobdata1.dat b/engine/dmlib/linux_java/test/dm11/testlobdata1.dat
new file mode 100644
index 0000000..11f11f9
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testlobdata1.dat
@@ -0,0 +1 @@
+0123456789
diff --git a/engine/dmlib/linux_java/test/dm11/testlobdata2.dat b/engine/dmlib/linux_java/test/dm11/testlobdata2.dat
new file mode 100644
index 0000000..be7024b
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testlobdata2.dat
@@ -0,0 +1 @@
+abcdefghijklmnopqrstunwxyz
diff --git a/engine/dmlib/linux_java/test/dm11/testoutput11 b/engine/dmlib/linux_java/test/dm11/testoutput11
new file mode 100644
index 0000000..2afca65
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testoutput11
@@ -0,0 +1,1741 @@
+Interaction mode, type "exit" to exit, ? for help
+
+]
+]
+]
+]
+] Cmd: startCounter
+Counter started!
+
+]
+] Cmd: get .
+path=.
+isLeaf=false
+name=.
+format=node
+type=
+title=
+acl=Add=*&Delete=*&Exec=*&Get=*&Replace=*
+size=0
+version=0
+children:TestRWPluginNode/TestPluginNode/TEST/CLONE/DMAcc/UnitTest/SyncML/DevInfo/DevDetail/
+
+] Cmd: get ./DevInfo/DevId
+path=./DevInfo/DevId
+isLeaf=true
+name=DevId
+format=chr
+type=text/plain
+title=
+acl=
+size=15
+version=0
+value=000000011234564
+
+]
+] Cmd: createi ./SyncML/DMAcc/UniTest
+node ./SyncML/DMAcc/UniTest created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/UniTest], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/UniTest/ServerId 1.1.1.1
+node ./SyncML/DMAcc/UniTest/ServerId (1.1.1.1) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/UniTest/ServerId], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: get ./SyncML/DMAcc/UniTest/ServerId
+path=./SyncML/DMAcc/UniTest/ServerId
+isLeaf=true
+name=ServerId
+format=chr
+type=text/plain
+title=
+acl=
+size=7
+version=0
+value=1.1.1.1
+
+] Cmd: replace ./SyncML/DMAcc/UniTest/ServerId 2.2.2.2
+set value of node ./SyncML/DMAcc/UniTest/ServerId to 2.2.2.2 successfully
+path=./SyncML/DMAcc/UniTest/ServerId
+isLeaf=true
+name=ServerId
+format=chr
+type=text/plain
+title=
+acl=
+size=7
+version=1
+value=2.2.2.2
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/UniTest/ServerId], [REPLACE]
+Commit plug-in: OnCommit <END>
+
+] Cmd: delete ./SyncML/DMAcc/UniTest
+node ./SyncML/DMAcc/UniTest deleted successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/UniTest], [DELETE]
+Commit plug-in: OnCommit <END>
+
+] Cmd: get .
+path=.
+isLeaf=false
+name=.
+format=node
+type=
+title=
+acl=Add=*&Delete=*&Exec=*&Get=*&Replace=*
+size=0
+version=0
+children:TestRWPluginNode/TestPluginNode/TEST/CLONE/DMAcc/UnitTest/SyncML/DevInfo/DevDetail/
+
+]
+]
+]
+]
+]
+] Cmd: dump ./DevInfo
+path=./DevInfo
+isLeaf=false
+name=DevInfo
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:LangAuto/Loc/Sort/Ext/Bearer/Mod/Man/Lang/DmV/DevId/
+
+path=./DevInfo/LangAuto
+isLeaf=true
+name=LangAuto
+format=bool
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=false
+
+path=./DevInfo/Loc
+isLeaf=true
+name=Loc
+format=chr
+type=text/plain
+title=
+acl=
+size=2
+version=0
+value=US
+
+path=./DevInfo/Sort
+isLeaf=true
+name=Sort
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=Latin
+
+path=./DevInfo/Ext
+isLeaf=false
+name=Ext
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:null
+
+path=./DevInfo/Bearer
+isLeaf=false
+name=Bearer
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:GSM/
+
+path=./DevInfo/Bearer/GSM
+isLeaf=true
+name=GSM
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+path=./DevInfo/Mod
+isLeaf=true
+name=Mod
+format=chr
+type=text/plain
+title=
+acl=
+size=4
+version=0
+value=A780
+
+path=./DevInfo/Man
+isLeaf=true
+name=Man
+format=chr
+type=text/plain
+title=
+acl=
+size=24
+version=0
+value=Motorola, Copyright 2005
+
+path=./DevInfo/Lang
+isLeaf=true
+name=Lang
+format=chr
+type=text/plain
+title=
+acl=
+size=2
+version=0
+value=en
+
+path=./DevInfo/DmV
+isLeaf=true
+name=DmV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.2
+
+path=./DevInfo/DevId
+isLeaf=true
+name=DevId
+format=chr
+type=text/plain
+title=
+acl=
+size=15
+version=0
+value=000000011234564
+
+
+] Cmd: dump ./SyncML
+path=./SyncML
+isLeaf=false
+name=SyncML
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:DMAcc/Con/
+
+path=./SyncML/DMAcc
+isLeaf=false
+name=DMAcc
+format=node
+type=
+title=
+acl=
+size=0
+version=2
+children:null
+
+path=./SyncML/Con
+isLeaf=false
+name=Con
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:null
+
+
+] Cmd: dump ./DevDetail
+path=./DevDetail
+isLeaf=false
+name=DevDetail
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:Ext/PRIChecksum/PRLV/ESNV/FlexV/URI/Bearer/SwV/OEM/LrgObj/HwV/FwV/DevTyp/
+
+path=./DevDetail/Ext
+isLeaf=false
+name=Ext
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:null
+
+path=./DevDetail/PRIChecksum
+isLeaf=true
+name=PRIChecksum
+format=chr
+type=text/plain
+title=
+acl=
+size=6
+version=0
+value=111111
+
+path=./DevDetail/PRLV
+isLeaf=true
+name=PRLV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/ESNV
+isLeaf=true
+name=ESNV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/FlexV
+isLeaf=true
+name=FlexV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/URI
+isLeaf=false
+name=URI
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:MaxTotLen/MaxSegLen/MaxDepth/
+
+path=./DevDetail/URI/MaxTotLen
+isLeaf=true
+name=MaxTotLen
+format=int
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=255
+
+path=./DevDetail/URI/MaxSegLen
+isLeaf=true
+name=MaxSegLen
+format=int
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=128
+
+path=./DevDetail/URI/MaxDepth
+isLeaf=true
+name=MaxDepth
+format=int
+type=text/plain
+title=
+acl=
+size=2
+version=0
+value=20
+
+path=./DevDetail/Bearer
+isLeaf=false
+name=Bearer
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:GSM/CDMA/
+
+path=./DevDetail/Bearer/GSM
+isLeaf=true
+name=GSM
+format=chr
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=1900-GSM
+
+path=./DevDetail/Bearer/CDMA
+isLeaf=true
+name=CDMA
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+path=./DevDetail/SwV
+isLeaf=true
+name=SwV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/OEM
+isLeaf=true
+name=OEM
+format=chr
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=Motorola
+
+path=./DevDetail/LrgObj
+isLeaf=true
+name=LrgObj
+format=bool
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=false
+
+path=./DevDetail/HwV
+isLeaf=true
+name=HwV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/FwV
+isLeaf=true
+name=FwV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/DevTyp
+isLeaf=true
+name=DevTyp
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+
+]
+]
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createi ./SyncML/Con/x
+node ./SyncML/Con/x created successfully
+
+] Cmd: get ./SyncML/Con/x
+path=./SyncML/Con/x
+isLeaf=false
+name=x
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:null
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+]
+]
+] Cmd: get ./SyncML/Con/x
+Error! can't get node ./SyncML/Con/x, DmtException: 404
+
+]
+]
+]
+]
+]
+]
+]
+]
+] Cmd: get ./TestPluginNode
+path=./TestPluginNode
+isLeaf=false
+name=TestPluginNode
+format=node
+type=text/plain
+title=
+acl=
+size=0
+version=0
+children:a/b/
+
+] Cmd: get ./TestPluginNode/a
+path=./TestPluginNode/a
+isLeaf=true
+name=a
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=leaf1
+
+] Cmd: get ./TestPluginNode/b
+path=./TestPluginNode/b
+isLeaf=true
+name=b
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=leaf2
+
+] Cmd: dump ./TestPluginNode
+path=./TestPluginNode
+isLeaf=false
+name=TestPluginNode
+format=node
+type=text/plain
+title=
+acl=
+size=0
+version=0
+children:a/b/
+
+path=./TestPluginNode/a
+isLeaf=true
+name=a
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=leaf1
+
+path=./TestPluginNode/b
+isLeaf=true
+name=b
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=leaf2
+
+
+]
+]
+]
+]
+]
+] Cmd: processscript unittest/dm11/testgetscript.xml
+Process WBXML script: false
+Read 501 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.1'><SyncHdr><VerDTD>1.1</VerDTD><VerProto>DM/1.1</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Get</Cmd><TargetRef>./DevInfo/DevId</TargetRef><Data>200</Data></Status><Results><CmdID>2</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Item><Source><LocURI>./DevInfo/DevId</LocURI></Source><Meta><Size xmlns='syncml:metinf'>15</Size></Meta><Data>000000011234564</Data></Item></Results><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm11/testexecscript.xml
+Process WBXML script: false
+Read 508 bytes
+execute path=. args=uname
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.1'><SyncHdr><VerDTD>1.1</VerDTD><VerProto>DM/1.1</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Exec</Cmd><Data>200</Data></Status><Results><CmdID>2</CmdID><CmdRef>1</CmdRef><Item><Source><LocURI>.</LocURI></Source><Meta><Size xmlns='syncml:metinf'>6</Size></Meta><Data>Linux
+</Data></Item></Results><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm11/testexecscript2.xml
+Process WBXML script: false
+Read 505 bytes
+execute path=. args=ls
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.1'><SyncHdr><VerDTD>1.1</VerDTD><VerProto>DM/1.1</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Exec</Cmd><Data>200</Data></Status><Results><CmdID>2</CmdID><CmdRef>1</CmdRef><Item><Source><LocURI>.</LocURI></Source><Meta><Size xmlns='syncml:metinf'>64</Size></Meta><Data>bin
+compile
+dmt_data
+lib
+plugins
+run_test
+settings
+src
+unittest
+</Data></Item></Results><Final/></SyncBody></SyncML>
+
+
+]
+] Cmd: processscript unittest/dm11/testalertconfirmatomic.xml
+Process WBXML script: false
+Read 884 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.1'><SyncHdr><VerDTD>1.1</VerDTD><VerProto>DM/1.1</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Atomic</Cmd><Data>507</Data></Status><Status><CmdID>2</CmdID><MsgRef>1</MsgRef><CmdRef>2</CmdRef><Cmd>Alert</Cmd><TargetRef></TargetRef><Data>408</Data></Status><Status><CmdID>3</CmdID><MsgRef>1</MsgRef><CmdRef>3</CmdRef><Cmd>Replace</Cmd><TargetRef>./DevDetail/Bearer/GSM</TargetRef><Data>215</Data></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm11/testalertmultiplechoice.xml
+Process WBXML script: false
+Read 844 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.1'><SyncHdr><VerDTD>1.1</VerDTD><VerProto>DM/1.1</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Alert</Cmd><Data>408</Data><Item><Data>1</Data></Item><Item><Data>3,6</Data></Item></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm11/testalertconfirm.xml
+Process WBXML script: false
+Read 584 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.1'><SyncHdr><VerDTD>1.1</VerDTD><VerProto>DM/1.1</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>2</CmdRef><Cmd>Alert</Cmd><Data>408</Data></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm11/testalertsinglechoice.xml
+Process WBXML script: false
+Read 838 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.1'><SyncHdr><VerDTD>1.1</VerDTD><VerProto>DM/1.1</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Alert</Cmd><Data>408</Data><Item><Data>2</Data></Item></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm11/testalertdisplay.xml
+Process WBXML script: false
+Read 570 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.1'><SyncHdr><VerDTD>1.1</VerDTD><VerProto>DM/1.1</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Alert</Cmd><Data>200</Data></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm11/testalerttextinput.xml
+Process WBXML script: false
+Read 609 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.1'><SyncHdr><VerDTD>1.1</VerDTD><VerProto>DM/1.1</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Alert</Cmd><Data>408</Data><Item><Data>hello+andy!</Data></Item></Status><Final/></SyncBody></SyncML>
+
+
+]
+]
+]
+]
+] Cmd: processscript unittest/dm11/testget.wbxml 1
+Process WBXML script: true
+Read 380 bytes
+
+Print result in HEX mode:
+
+Result Size: 327
+0000: 02 00 00 6a 1d 2d 2f 2f 53 59 4e 43 4d 4c 2f 2f ...j.-//SYNCML//
+0010: 44 54 44 20 53 79 6e 63 4d 4c 20 31 2e 31 2f 2f DTD SyncML 1.1//
+0020: 45 4e 6d 6c 71 03 31 2e 31 00 01 72 03 44 4d 2f ENmlq.1.1..r.DM/
+0030: 31 2e 31 00 01 65 03 32 32 31 30 30 00 01 5b 03 1.1..e.22100..[.
+0040: 31 00 01 6e 57 03 68 74 74 70 3a 2f 2f 31 30 2e 1..nW.http://10.
+0050: 37 32 2e 33 34 2e 32 31 37 2f 53 63 74 73 3f 30 72.34.217/Scts?0
+0060: 4a 54 49 41 41 3d 3d 00 01 01 67 57 03 30 30 30 JTIAA==...gW.000
+0070: 30 30 30 30 31 31 32 33 34 35 36 34 00 01 01 5a 000011234564...Z
+0080: 00 01 4c 03 33 35 30 30 00 01 01 01 00 00 6b 69 ..L.3500......ki
+0090: 4b 03 31 00 01 5c 03 31 00 01 4c 03 30 00 01 4a K.1..\.1..L.0..J
+00a0: 03 53 79 6e 63 48 64 72 00 01 4f 03 32 30 30 00 .SyncHdr..O.200.
+00b0: 01 01 69 4b 03 32 00 01 5c 03 31 00 01 4c 03 34 ..iK.2..\.1..L.4
+00c0: 00 01 4a 03 47 65 74 00 01 6f 03 2e 2f 44 65 76 ..J.Get..o../Dev
+00d0: 44 65 74 61 69 6c 2f 55 52 49 2f 4d 61 78 44 65 Detail/URI/MaxDe
+00e0: 70 74 68 00 01 4f 03 32 30 30 00 01 01 62 4b 03 pth..O.200...bK.
+00f0: 33 00 01 5c 03 31 00 01 4c 03 34 00 01 54 67 57 3..\.1..L.4..TgW
+0100: 03 2e 2f 44 65 76 44 65 74 61 69 6c 2f 55 52 49 ../DevDetail/URI
+0110: 2f 4d 61 78 44 65 70 74 68 00 01 01 5a 00 01 47 /MaxDepth...Z..G
+0120: 03 69 6e 74 00 01 53 03 74 65 78 74 2f 70 6c 61 .int..S.text/pla
+0130: 69 6e 00 01 52 03 32 00 01 01 00 00 4f 03 32 30 in..R.2.....O.20
+0140: 00 01 01 01 12 01 01 .......
+
+] Cmd: processscript unittest/dm11/testadd.wbxml 1
+Process WBXML script: true
+Read 385 bytes
+
+Print result in HEX mode:
+
+Result Size: 230
+0000: 02 00 00 6a 1d 2d 2f 2f 53 59 4e 43 4d 4c 2f 2f ...j.-//SYNCML//
+0010: 44 54 44 20 53 79 6e 63 4d 4c 20 31 2e 31 2f 2f DTD SyncML 1.1//
+0020: 45 4e 6d 6c 71 03 31 2e 31 00 01 72 03 44 4d 2f ENmlq.1.1..r.DM/
+0030: 31 2e 31 00 01 65 03 33 30 34 38 33 00 01 5b 03 1.1..e.30483..[.
+0040: 31 00 01 6e 57 03 68 74 74 70 3a 2f 2f 31 30 2e 1..nW.http://10.
+0050: 37 32 2e 33 34 2e 32 31 37 2f 53 63 74 73 3f 34 72.34.217/Scts?4
+0060: 45 4c 49 41 41 3d 3d 00 01 01 67 57 03 30 30 30 ELIAA==...gW.000
+0070: 30 30 30 30 31 31 32 33 34 35 36 34 00 01 01 5a 000011234564...Z
+0080: 00 01 4c 03 33 35 30 30 00 01 01 01 00 00 6b 69 ..L.3500......ki
+0090: 4b 03 31 00 01 5c 03 31 00 01 4c 03 30 00 01 4a K.1..\.1..L.0..J
+00a0: 03 53 79 6e 63 48 64 72 00 01 4f 03 32 30 30 00 .SyncHdr..O.200.
+00b0: 01 01 69 4b 03 32 00 01 5c 03 31 00 01 4c 03 34 ..iK.2..\.1..L.4
+00c0: 00 01 4a 03 41 64 64 00 01 6f 03 2e 2f 54 65 73 ..J.Add..o../Tes
+00d0: 74 4c 65 61 66 4e 6f 64 65 00 01 4f 03 35 30 30 tLeafNode..O.500
+00e0: 00 01 01 12 01 01 ......
+
+] Cmd: processscript unittest/dm11/testdelete.wbxml 1
+Process WBXML script: true
+Read 395 bytes
+
+Print result in HEX mode:
+
+Result Size: 281
+0000: 02 00 00 6a 1d 2d 2f 2f 53 59 4e 43 4d 4c 2f 2f ...j.-//SYNCML//
+0010: 44 54 44 20 53 79 6e 63 4d 4c 20 31 2e 31 2f 2f DTD SyncML 1.1//
+0020: 45 4e 6d 6c 71 03 31 2e 31 00 01 72 03 44 4d 2f ENmlq.1.1..r.DM/
+0030: 31 2e 31 00 01 65 03 31 32 34 36 33 00 01 5b 03 1.1..e.12463..[.
+0040: 31 00 01 6e 57 03 68 74 74 70 3a 2f 2f 31 30 2e 1..nW.http://10.
+0050: 37 32 2e 33 34 2e 32 31 37 2f 53 63 74 73 3f 41 72.34.217/Scts?A
+0060: 4c 76 48 41 41 3d 3d 00 01 01 67 57 03 30 30 30 LvHAA==...gW.000
+0070: 30 30 30 30 31 31 32 33 34 35 36 34 00 01 01 5a 000011234564...Z
+0080: 00 01 4c 03 33 35 30 30 00 01 01 01 00 00 6b 69 ..L.3500......ki
+0090: 4b 03 31 00 01 5c 03 31 00 01 4c 03 30 00 01 4a K.1..\.1..L.0..J
+00a0: 03 53 79 6e 63 48 64 72 00 01 4f 03 32 30 30 00 .SyncHdr..O.200.
+00b0: 01 01 69 4b 03 32 00 01 5c 03 31 00 01 4c 03 34 ..iK.2..\.1..L.4
+00c0: 00 01 4a 03 44 65 6c 65 74 65 00 01 6f 03 2e 2f ..J.Delete..o../
+00d0: 54 65 73 74 4c 65 61 66 4e 6f 64 65 00 01 4f 03 TestLeafNode..O.
+00e0: 34 30 34 00 01 01 69 4b 03 33 00 01 5c 03 31 00 404...iK.3..\.1.
+00f0: 01 4c 03 35 00 01 4a 03 44 65 6c 65 74 65 00 01 .L.5..J.Delete..
+0100: 6f 03 2e 2f 54 65 73 74 4c 65 61 66 00 01 4f 03 o../TestLeaf..O.
+0110: 34 30 34 00 01 01 12 01 01 404......
+
+] Cmd: processscript unittest/dm11/testreplace.wbxml 1
+Process WBXML script: true
+Read 662 bytes
+
+Print result in HEX mode:
+
+Result Size: 684
+0000: 02 00 00 6a 1d 2d 2f 2f 53 59 4e 43 4d 4c 2f 2f ...j.-//SYNCML//
+0010: 44 54 44 20 53 79 6e 63 4d 4c 20 31 2e 31 2f 2f DTD SyncML 1.1//
+0020: 45 4e 6d 6c 71 03 31 2e 31 00 01 72 03 44 4d 2f ENmlq.1.1..r.DM/
+0030: 31 2e 31 00 01 65 03 32 34 36 37 33 00 01 5b 03 1.1..e.24673..[.
+0040: 31 00 01 6e 57 03 30 30 30 30 30 30 30 31 31 32 1..nW.0000000112
+0050: 33 34 35 36 34 00 01 56 03 53 61 6d 70 6c 65 53 34564..V.SampleS
+0060: 65 72 76 65 72 00 01 01 67 57 03 68 74 74 70 3a erver...gW.http:
+0070: 2f 2f 31 30 2e 37 32 2e 34 31 2e 31 38 32 3a 38 //10.72.41.182:8
+0080: 30 2f 4d 61 6e 61 67 65 00 01 56 03 53 63 74 73 0/Manage..V.Scts
+0090: 00 01 01 5a 00 01 4c 03 33 35 30 30 00 01 01 01 ...Z..L.3500....
+00a0: 00 00 6b 69 4b 03 31 00 01 5c 03 31 00 01 4c 03 ..kiK.1..\.1..L.
+00b0: 31 00 01 4a 03 41 6c 65 72 74 00 01 4f 03 32 30 1..J.Alert..O.20
+00c0: 30 00 01 01 69 4b 03 32 00 01 5c 03 31 00 01 4c 0...iK.2..\.1..L
+00d0: 03 32 00 01 4a 03 52 65 70 6c 61 63 65 00 01 68 .2..J.Replace..h
+00e0: 03 2e 2f 44 65 76 49 6e 66 6f 2f 44 65 76 49 64 ../DevInfo/DevId
+00f0: 00 01 4f 03 34 30 30 00 01 01 69 4b 03 33 00 01 ..O.400...iK.3..
+0100: 5c 03 31 00 01 4c 03 32 00 01 4a 03 52 65 70 6c \.1..L.2..J.Repl
+0110: 61 63 65 00 01 68 03 2e 2f 44 65 76 49 6e 66 6f ace..h../DevInfo
+0120: 2f 44 6d 56 00 01 4f 03 34 30 30 00 01 01 69 4b /DmV..O.400...iK
+0130: 03 34 00 01 5c 03 31 00 01 4c 03 32 00 01 4a 03 .4..\.1..L.2..J.
+0140: 52 65 70 6c 61 63 65 00 01 68 03 2e 2f 44 65 76 Replace..h../Dev
+0150: 49 6e 66 6f 2f 4c 61 6e 67 00 01 4f 03 34 30 30 Info/Lang..O.400
+0160: 00 01 01 69 4b 03 35 00 01 5c 03 31 00 01 4c 03 ...iK.5..\.1..L.
+0170: 32 00 01 4a 03 52 65 70 6c 61 63 65 00 01 68 03 2..J.Replace..h.
+0180: 2e 2f 44 65 76 49 6e 66 6f 2f 4d 61 6e 00 01 4f ./DevInfo/Man..O
+0190: 03 34 30 30 00 01 01 69 4b 03 36 00 01 5c 03 31 .400...iK.6..\.1
+01a0: 00 01 4c 03 32 00 01 4a 03 52 65 70 6c 61 63 65 ..L.2..J.Replace
+01b0: 00 01 68 03 2e 2f 44 65 76 49 6e 66 6f 2f 4d 6f ..h../DevInfo/Mo
+01c0: 64 00 01 4f 03 34 30 30 00 01 01 69 4b 03 37 00 d..O.400...iK.7.
+01d0: 01 5c 03 31 00 01 4c 03 32 00 01 4a 03 52 65 70 .\.1..L.2..J.Rep
+01e0: 6c 61 63 65 00 01 68 03 2e 2f 44 65 76 49 6e 66 lace..h../DevInf
+01f0: 6f 2f 42 65 61 72 65 72 2f 47 53 4d 00 01 4f 03 o/Bearer/GSM..O.
+0200: 34 30 30 00 01 01 69 4b 03 38 00 01 5c 03 31 00 400...iK.8..\.1.
+0210: 01 4c 03 32 00 01 4a 03 52 65 70 6c 61 63 65 00 .L.2..J.Replace.
+0220: 01 68 03 2e 2f 44 65 76 49 6e 66 6f 2f 53 6f 72 .h../DevInfo/Sor
+0230: 74 00 01 4f 03 34 30 30 00 01 01 69 4b 03 39 00 t..O.400...iK.9.
+0240: 01 5c 03 31 00 01 4c 03 32 00 01 4a 03 52 65 70 .\.1..L.2..J.Rep
+0250: 6c 61 63 65 00 01 68 03 2e 2f 44 65 76 49 6e 66 lace..h../DevInf
+0260: 6f 2f 4c 6f 63 00 01 4f 03 34 30 30 00 01 01 69 o/Loc..O.400...i
+0270: 4b 03 31 30 00 01 5c 03 31 00 01 4c 03 32 00 01 K.10..\.1..L.2..
+0280: 4a 03 52 65 70 6c 61 63 65 00 01 68 03 2e 2f 44 J.Replace..h../D
+0290: 65 76 49 6e 66 6f 2f 4c 61 6e 67 41 75 74 6f 00 evInfo/LangAuto.
+02a0: 01 4f 03 34 30 30 00 01 01 12 01 01 .O.400......
+
+]
+]
+]
+]
+] Cmd: hmaccred scts
+
+]
+]
+]
+]
+] Cmd: createi ./SyncML/DMAcc/SampleServer
+node ./SyncML/DMAcc/SampleServer created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/ServerId Scts
+node ./SyncML/DMAcc/SampleServer/ServerId (Scts) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/ServerId], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/Addr http://127.0.0.1:80/Manage
+node ./SyncML/DMAcc/SampleServer/Addr (http://127.0.0.1:80/Manage) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/Addr], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/AddrType 1
+node ./SyncML/DMAcc/SampleServer/AddrType (1) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/AddrType], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/ConRef
+node ./SyncML/DMAcc/SampleServer/ConRef () created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/ConRef], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/Name SampleServer
+node ./SyncML/DMAcc/SampleServer/Name (SampleServer) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/Name], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/ServerPW SampleServer
+node ./SyncML/DMAcc/SampleServer/ServerPW (SampleServer) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/ServerPW], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/UserName SampleServer
+node ./SyncML/DMAcc/SampleServer/UserName (SampleServer) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/UserName], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/ClientPW SampleServer
+node ./SyncML/DMAcc/SampleServer/ClientPW (SampleServer) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/ClientPW], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/PortNbr 80
+node ./SyncML/DMAcc/SampleServer/PortNbr (80) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/PortNbr], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/ServerNonce MTIzNDEyMzQxMjM0MTIzNA==
+node ./SyncML/DMAcc/SampleServer/ServerNonce (MTIzNDEyMzQxMjM0MTIzNA==) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/ServerNonce], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/ClientNonce 123abc
+node ./SyncML/DMAcc/SampleServer/ClientNonce (123abc) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/ClientNonce], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/SampleServer/AuthPref syncml:auth-basic
+node ./SyncML/DMAcc/SampleServer/AuthPref (syncml:auth-basic) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/AuthPref], [ADD]
+Commit plug-in: OnCommit <END>
+
+]
+] Cmd: connectsid Scts
+start server session, Scts, bin = false
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer/UserName], [REPLACE]
+notification for uri [./SyncML/DMAcc/SampleServer/ClientPW], [REPLACE]
+Commit plug-in: OnCommit <END>
+Error! can't start server session, DmtException: 1
+
+]
+] Cmd: dump ./SyncML/DMAcc/SampleServer
+path=./SyncML/DMAcc/SampleServer
+isLeaf=false
+name=SampleServer
+format=node
+type=
+title=
+acl=
+size=0
+version=12
+children:ServerId/Addr/AddrType/ConRef/Name/ServerPW/UserName/ClientPW/PortNbr/ServerNonce/ClientNonce/AuthPref/
+
+path=./SyncML/DMAcc/SampleServer/ServerId
+isLeaf=true
+name=ServerId
+format=chr
+type=text/plain
+title=
+acl=
+size=4
+version=0
+value=Scts
+
+path=./SyncML/DMAcc/SampleServer/Addr
+isLeaf=true
+name=Addr
+format=chr
+type=text/plain
+title=
+acl=
+size=26
+version=0
+value=http://127.0.0.1:80/Manage
+
+path=./SyncML/DMAcc/SampleServer/AddrType
+isLeaf=true
+name=AddrType
+format=chr
+type=text/plain
+title=
+acl=
+size=1
+version=0
+value=1
+
+path=./SyncML/DMAcc/SampleServer/ConRef
+isLeaf=true
+name=ConRef
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+path=./SyncML/DMAcc/SampleServer/Name
+isLeaf=true
+name=Name
+format=chr
+type=text/plain
+title=
+acl=
+size=12
+version=0
+value=SampleServer
+
+path=./SyncML/DMAcc/SampleServer/ServerPW
+isLeaf=true
+name=ServerPW
+format=chr
+type=text/plain
+title=
+acl=
+size=12
+version=0
+value=SampleServer
+
+path=./SyncML/DMAcc/SampleServer/UserName
+isLeaf=true
+name=UserName
+format=chr
+type=text/plain
+title=
+acl=
+size=12
+version=1
+value=SampleServer
+
+path=./SyncML/DMAcc/SampleServer/ClientPW
+isLeaf=true
+name=ClientPW
+format=chr
+type=text/plain
+title=
+acl=
+size=12
+version=1
+value=SampleServer
+
+path=./SyncML/DMAcc/SampleServer/PortNbr
+isLeaf=true
+name=PortNbr
+format=chr
+type=text/plain
+title=
+acl=
+size=2
+version=0
+value=80
+
+path=./SyncML/DMAcc/SampleServer/ServerNonce
+isLeaf=true
+name=ServerNonce
+format=chr
+type=text/plain
+title=
+acl=
+size=24
+version=0
+value=MTIzNDEyMzQxMjM0MTIzNA==
+
+path=./SyncML/DMAcc/SampleServer/ClientNonce
+isLeaf=true
+name=ClientNonce
+format=chr
+type=text/plain
+title=
+acl=
+size=6
+version=0
+value=123abc
+
+path=./SyncML/DMAcc/SampleServer/AuthPref
+isLeaf=true
+name=AuthPref
+format=chr
+type=text/plain
+title=
+acl=
+size=17
+version=0
+value=syncml:auth-basic
+
+
+]
+] Cmd: delete ./SyncML/DMAcc/SampleServer
+node ./SyncML/DMAcc/SampleServer deleted successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/SampleServer], [DELETE]
+Commit plug-in: OnCommit <END>
+
+]
+]
+]
+]
+] Cmd: Exec . ls
+execute path=. args=ls
+execute node . successfully, result=bin
+compile
+dmt_data
+lib
+plugins
+run_test
+settings
+src
+unittest
+
+
+]
+]
+]
+]
+]
+] Cmd: createi ./UnitTest/Profiles11/1
+node ./UnitTest/Profiles11/1 created successfully
+OnTreeSaved, parent uri ./UnitTest/Profiles11
+
+] Cmd: createl ./UnitTest/Profiles11/1/CurProfile 12
+Error! can't create a node ./UnitTest/Profiles11/1/CurProfile, DmtException: 500
+
+] Cmd: createi ./UnitTest/Profiles11/2
+node ./UnitTest/Profiles11/2 created successfully
+OnTreeSaved, parent uri ./UnitTest/Profiles11
+
+] Cmd: createl ./UnitTest/Profiles11/2/CurProfile 12
+Error! can't create a node ./UnitTest/Profiles11/2/CurProfile, DmtException: 500
+
+]
+] Cmd: createi ./SyncML/DMAcc/12
+node ./SyncML/DMAcc/12 created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/12], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./SyncML/DMAcc/12/ServerId some
+node ./SyncML/DMAcc/12/ServerId (some) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/12/ServerId], [ADD]
+Commit plug-in: OnCommit <END>
+
+]
+] Cmd: createl ./UnitTest/Profiles11/1/CurProfile 12
+node ./UnitTest/Profiles11/1/CurProfile (12) created successfully
+Commit plug-in: OnCommit [profile11]<START>
+notification for uri [./UnitTest/Profiles11/1/CurProfile], [ADD]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles11/1
+
+] Cmd: createl ./UnitTest/Profiles11/2/CurProfile 12
+node ./UnitTest/Profiles11/2/CurProfile (12) created successfully
+Commit plug-in: OnCommit [profile11]<START>
+notification for uri [./UnitTest/Profiles11/2/CurProfile], [ADD]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles11/2
+
+]
+] Cmd: replace ./SyncML/DMAcc/12/ServerId some3
+set value of node ./SyncML/DMAcc/12/ServerId to some3 successfully
+path=./SyncML/DMAcc/12/ServerId
+isLeaf=true
+name=ServerId
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=1
+value=some3
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/12/ServerId], [REPLACE]
+Commit plug-in: OnCommit <END>
+Commit plug-in: OnCommit [profile11]<START>
+notification for uri [./UnitTest/Profiles11/1/CurProfile], [INDIRECT UPDATE]
+notification for uri [./UnitTest/Profiles11/2/CurProfile], [INDIRECT UPDATE]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles11/1
+OnTreeSaved, parent uri ./UnitTest/Profiles11/2
+
+] Cmd: createl ./SyncML/DMAcc/12/AppID some
+Error! can't create a node ./SyncML/DMAcc/12/AppID, DmtException: 500
+
+]
+]
+] Cmd: delete ./SyncML/DMAcc/12
+Error! can't delete node ./SyncML/DMAcc/12, DmtException: 500
+
+]
+]
+] Cmd: delete ./UnitTest/Profiles11/1
+node ./UnitTest/Profiles11/1 deleted successfully
+Commit plug-in: OnCommit [profile11]<START>
+notification for uri [./UnitTest/Profiles11/1/CurProfile], [DELETE]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles11
+
+] Cmd: delete ./UnitTest/Profiles11/2
+node ./UnitTest/Profiles11/2 deleted successfully
+Commit plug-in: OnCommit [profile11]<START>
+notification for uri [./UnitTest/Profiles11/2/CurProfile], [DELETE]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles11
+
+] Cmd: delete ./SyncML/DMAcc/12
+node ./SyncML/DMAcc/12 deleted successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./SyncML/DMAcc/12], [DELETE]
+Commit plug-in: OnCommit <END>
+
+]
+] Cmd: dump ./TestRWPluginNode
+path=./TestRWPluginNode
+isLeaf=false
+name=TestRWPluginNode
+format=node
+type=text/plain
+title=
+acl=
+size=0
+version=0
+children:branch1/
+
+path=./TestRWPluginNode/branch1
+isLeaf=false
+name=branch1
+format=node
+type=text/plain
+title=
+acl=
+size=0
+version=0
+children:char/int/lob/lobbin/FloatLeaf/DateLeaf/TimeLeaf/
+
+path=./TestRWPluginNode/branch1/char
+isLeaf=true
+name=char
+format=chr
+type=text/plain
+title=
+acl=
+size=10
+version=0
+value=char_value
+
+path=./TestRWPluginNode/branch1/int
+isLeaf=true
+name=int
+format=int
+type=text/plain
+title=
+acl=
+size=4
+version=0
+value=1234
+
+path=./TestRWPluginNode/branch1/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+
+path=./TestRWPluginNode/branch1/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+
+path=./TestRWPluginNode/branch1/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=11
+version=0
+value=-1.23456e+2
+
+path=./TestRWPluginNode/branch1/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=10
+version=0
+value=2005-10-18
+
+path=./TestRWPluginNode/branch1/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=11:38:58
+
+
+]
+]
+]
+]
+] Cmd: createl ./TEST/lob
+node ./TEST/lob () created successfully
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: setESN ./TEST/lob unittest/dm11/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: get ./TEST/lob
+path=./TEST/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=11
+version=2
+value=
+0123456789
+
+
+
+]
+]
+]
+]
+]
+] Cmd: setESN ./TEST/lob unittest/dm11/testlobdata2.dat
+read 27 bytes
+abcdefghijklmnopqrstunwxyz
+
+
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: get ./TEST/lob
+path=./TEST/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=27
+version=4
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+] Cmd: delete ./CLONE
+node ./CLONE deleted successfully
+OnTreeSaved, parent uri .
+
+] Cmd: clone ./TEST CLONE
+clone ./TEST to CLONE successfully
+OnTreeSaved, parent uri .
+OnTreeSaved, parent uri ./CLONE
+
+] Cmd: get ./CLONE/lob
+path=./CLONE/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=27
+version=2
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+]
+] Cmd: delete ./TEST/lob
+node ./TEST/lob deleted successfully
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: delete ./CLONE/lob
+node ./CLONE/lob deleted successfully
+OnTreeSaved, parent uri ./CLONE
+
+] Cmd: get ./TEST/lob
+Error! can't get node ./TEST/lob, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createl ./TEST/lob
+node ./TEST/lob () created successfully
+
+] Cmd: setESN ./TEST/lob unittest/dm11/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+] Cmd: get ./TEST/lob
+Error! can't get node ./TEST/lob, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: createlb ./TEST/lobbin
+node ./TEST/lobbin () created successfully
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: setESN ./TEST/lob unittest/dm11/testlobdata1.dat
+read 11 bytes
+Error! can't get node ./TEST/lob, DmtException: 404
+
+] Cmd: get ./TEST/lobbin
+path=./TEST/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+
+]
+]
+]
+]
+]
+] Cmd: setESN ./TEST/lobbin unittest/dm11/testlobdata2.dat
+read 27 bytes
+abcdefghijklmnopqrstunwxyz
+
+
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: get ./TEST/lobbin
+path=./TEST/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=27
+version=2
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+] Cmd: delete ./CLONE
+node ./CLONE deleted successfully
+OnTreeSaved, parent uri .
+
+] Cmd: clone ./TEST CLONE
+clone ./TEST to CLONE successfully
+OnTreeSaved, parent uri .
+OnTreeSaved, parent uri ./CLONE
+
+] Cmd: get ./CLONE/lobbin
+path=./CLONE/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=27
+version=2
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+]
+] Cmd: delete ./TEST/lobbin
+node ./TEST/lobbin deleted successfully
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: delete ./CLONE/lobbin
+node ./CLONE/lobbin deleted successfully
+OnTreeSaved, parent uri ./CLONE
+
+] Cmd: get ./TEST/lobbin
+Error! can't get node ./TEST/lobbin, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createlb ./TEST/lobbin
+node ./TEST/lobbin () created successfully
+
+] Cmd: setESN ./TEST/lobbin unittest/dm11/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+] Cmd: get ./TEST/lobbin
+Error! can't get node ./TEST/lobbin, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: delete ./TestRWPluginNode/branch1/lob
+node ./TestRWPluginNode/branch1/lob deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: createl ./TestRWPluginNode/branch1/lob
+node ./TestRWPluginNode/branch1/lob () created successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: setESN ./TestRWPluginNode/branch1/lob unittest/dm11/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/branch1/lob
+path=./TestRWPluginNode/branch1/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=11
+version=0
+value=
+0123456789
+
+
+
+]
+]
+]
+]
+]
+] Cmd: setESN ./TestRWPluginNode/branch1/lob unittest/dm11/testlobdata2.dat
+read 27 bytes
+abcdefghijklmnopqrstunwxyz
+
+
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/branch1/lob
+path=./TestRWPluginNode/branch1/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=27
+version=0
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+] Cmd: delete ./TestRWPluginNode/branch1/lobbin
+node ./TestRWPluginNode/branch1/lobbin deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: createlb ./TestRWPluginNode/branch1/lobbin
+node ./TestRWPluginNode/branch1/lobbin () created successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: setESN ./TestRWPluginNode/branch1/lobbin unittest/dm11/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/branch1/lobbin
+path=./TestRWPluginNode/branch1/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=11
+version=0
+value=
+0123456789
+
+
+
+]
+]
+]
+]
+]
+] Cmd: setESN ./TestRWPluginNode/branch1/lobbin unittest/dm11/testlobdata2.dat
+read 27 bytes
+abcdefghijklmnopqrstunwxyz
+
+
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/branch1/lobbin
+path=./TestRWPluginNode/branch1/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=27
+version=0
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+]
+] Cmd: delete ./TestRWPluginNode/clone
+Error! can't delete node ./TestRWPluginNode/clone, DmtException: 404
+
+] Cmd: clone ./TestRWPluginNode/branch1 clone
+Error! can't clone ./TestRWPluginNode/branch1 to clone, DmtException: 415
+OnTreeSaved, parent uri ./TestRWPluginNode
+OnTreeSaved, parent uri ./TestRWPluginNode/clone
+
+] Cmd: get ./TestRWPluginNode/clone/lob
+Error! can't get node ./TestRWPluginNode/clone/lob, DmtException: 404
+
+] Cmd: get ./TestRWPluginNode/clone/lobbin
+Error! can't get node ./TestRWPluginNode/clone/lobbin, DmtException: 404
+
+]
+]
+]
+]
+]
+] Cmd: delete ./TestRWPluginNode/clone
+node ./TestRWPluginNode/clone deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode
+
+] Cmd: delete ./TestRWPluginNode/branch1/lob
+node ./TestRWPluginNode/branch1/lob deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: delete ./TestRWPluginNode/branch1/lobbin
+node ./TestRWPluginNode/branch1/lobbin deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/clone/lobbin
+Error! can't get node ./TestRWPluginNode/clone/lobbin, DmtException: 404
+
+] Cmd: get ./TestRWPluginNode/branch1/lob
+Error! can't get node ./TestRWPluginNode/branch1/lob, DmtException: 404
+
+] Cmd: get ./TestRWPluginNode/branch1/lobbin
+Error! can't get node ./TestRWPluginNode/branch1/lobbin, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createl ./TestRWPluginNode/branch1/lob
+node ./TestRWPluginNode/branch1/lob () created successfully
+
+] Cmd: setESN ./TestRWPluginNode/branch1/lob unittest/dm11/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+] Cmd: get ./TestRWPluginNode/branch1/lob
+Error! can't get node ./TestRWPluginNode/branch1/lob, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createlb ./TestRWPluginNode/branch1/lobbin
+node ./TestRWPluginNode/branch1/lobbin () created successfully
+
+] Cmd: setESN ./TestRWPluginNode/branch1/lobbin unittest/dm11/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+] Cmd: get ./TestRWPluginNode/branch1/lobbin
+Error! can't get node ./TestRWPluginNode/branch1/lobbin, DmtException: 404
+
+]
+] Cmd: getCounter
+Number of tested cases: 272
+
+]
+] Cmd: quit
diff --git a/engine/dmlib/linux_java/test/dm11/testreplace.wbxml b/engine/dmlib/linux_java/test/dm11/testreplace.wbxml
new file mode 100644
index 0000000..7e72340
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm11/testreplace.wbxml
Binary files differ
diff --git a/engine/dmlib/linux_java/test/dm12/testadd.wbxml b/engine/dmlib/linux_java/test/dm12/testadd.wbxml
new file mode 100644
index 0000000..6b8bdbf
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testadd.wbxml
Binary files differ
diff --git a/engine/dmlib/linux_java/test/dm12/testalertconfirm.xml b/engine/dmlib/linux_java/test/dm12/testalertconfirm.xml
new file mode 100644
index 0000000..ebb5a40
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testalertconfirm.xml
@@ -0,0 +1,32 @@
+ <SyncML xmlns="SYNCML:SYNCML1.2">
+ <SyncHdr>
+ <VerDTD>1.2</VerDTD>
+ <VerProto>DM/1.2</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+
+
+ <Alert>
+ <CmdID>2</CmdID>
+ <Data>1101</Data>
+ <Item><Data>MAXDT=15&DR=1</Data></Item>
+ <Item>
+ <Data>Testing Confirmation Alert</Data>
+ </Item>
+ </Alert>
+
+ <Final/>
+ </SyncBody>
+ </SyncML>
diff --git a/engine/dmlib/linux_java/test/dm12/testalertconfirmatomic.xml b/engine/dmlib/linux_java/test/dm12/testalertconfirmatomic.xml
new file mode 100644
index 0000000..1079e5f
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testalertconfirmatomic.xml
@@ -0,0 +1,48 @@
+ <SyncML xmlns="SYNCML:SYNCML1.2">
+ <SyncHdr>
+ <VerDTD>1.2</VerDTD>
+ <VerProto>DM/1.2</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+
+<Atomic>
+<CmdID>1</CmdID>
+
+ <Alert>
+ <CmdID>2</CmdID>
+ <Data>1101</Data>
+ <Item><Data>MAXDT=15DR=1</Data></Item>
+ <Item>
+ <Data>Testing Confirmation Alert</Data>
+ </Item>
+ </Alert>
+
+ <Replace>
+ <CmdID>3</CmdID>
+ <Meta>
+ <Format xmlns="syncml:metinf">chr</Format>
+ <Type xmlns="syncml:metinf">text/plain</Type>
+ </Meta>
+ <Item>
+ <Target><LocURI>./DevDetail/Bearer/GSM</LocURI></Target>
+ <Data>test</Data>
+ </Item>
+ </Replace>
+
+</Atomic>
+
+ <Final/>
+ </SyncBody>
+ </SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm12/testalertdisplay.xml b/engine/dmlib/linux_java/test/dm12/testalertdisplay.xml
new file mode 100644
index 0000000..06898b8
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testalertdisplay.xml
@@ -0,0 +1,29 @@
+ <SyncML xmlns="SYNCML:SYNCML1.2">
+ <SyncHdr>
+ <VerDTD>1.2</VerDTD>
+ <VerProto>DM/1.2</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+ <Alert>
+ <CmdID>1</CmdID>
+ <Data>1100</Data>
+ <Item><Data>MINDT=15</Data></Item>
+ <Item>
+ <Data>Testing Display Alert</Data>
+ </Item>
+ </Alert>
+ <Final/>
+ </SyncBody>
+ </SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm12/testalertmultiplechoice.xml b/engine/dmlib/linux_java/test/dm12/testalertmultiplechoice.xml
new file mode 100644
index 0000000..9a32a03
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testalertmultiplechoice.xml
@@ -0,0 +1,47 @@
+ <SyncML xmlns="SYNCML:SYNCML1.2">
+ <SyncHdr>
+ <VerDTD>1.2</VerDTD>
+ <VerProto>DM/1.2</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+ <Alert>
+ <CmdID>1</CmdID>
+ <Data>1104</Data>
+ <Item><Data>MAXDT=20&DR=1-3,6</Data></Item>
+ <Item>
+ <Data>Testing Multiple Choice Alert</Data>
+ </Item>
+ <Item>
+ <Data>choice one</Data>
+ </Item>
+ <Item>
+ <Data>choice two</Data>
+ </Item>
+ <Item>
+ <Data>choice three</Data>
+ </Item>
+ <Item>
+ <Data>choice four</Data>
+ </Item>
+ <Item>
+ <Data>choice five</Data>
+ </Item>
+ <Item>
+ <Data>choice six</Data>
+ </Item>
+ </Alert>
+ <Final/>
+ </SyncBody>
+ </SyncML>
diff --git a/engine/dmlib/linux_java/test/dm12/testalertsinglechoice.xml b/engine/dmlib/linux_java/test/dm12/testalertsinglechoice.xml
new file mode 100644
index 0000000..2997224
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testalertsinglechoice.xml
@@ -0,0 +1,47 @@
+ <SyncML xmlns="SYNCML:SYNCML1.2">
+ <SyncHdr>
+ <VerDTD>1.2</VerDTD>
+ <VerProto>DM/1.2</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+ <Alert>
+ <CmdID>1</CmdID>
+ <Data>1103</Data>
+ <Item><Data>MAXDT=20&DR=2</Data></Item>
+ <Item>
+ <Data>Testing Single Choice Alert</Data>
+ </Item>
+ <Item>
+ <Data>choice one</Data>
+ </Item>
+ <Item>
+ <Data>choice two</Data>
+ </Item>
+ <Item>
+ <Data>choice three</Data>
+ </Item>
+ <Item>
+ <Data>choice four</Data>
+ </Item>
+ <Item>
+ <Data>choice five</Data>
+ </Item>
+ <Item>
+ <Data>choice six</Data>
+ </Item>
+ </Alert>
+ <Final/>
+ </SyncBody>
+ </SyncML>
diff --git a/engine/dmlib/linux_java/test/dm12/testalerttextinput.xml b/engine/dmlib/linux_java/test/dm12/testalerttextinput.xml
new file mode 100644
index 0000000..239d6e1
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testalerttextinput.xml
@@ -0,0 +1,29 @@
+ <SyncML xmlns="SYNCML:SYNCML1.2">
+ <SyncHdr>
+ <VerDTD>1.2</VerDTD>
+ <VerProto>DM/1.2</VerProto>
+ <SessionID>11</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>SampleClient</LocURI>
+ </Target>
+ <Source>
+ <LocURI>mot.manage</LocURI>
+ </Source>
+ <RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+ <Alert>
+ <CmdID>1</CmdID>
+ <Data>1102</Data>
+ <Item><Data>MAXDT=20&DR=hello+andy!&MAXLEN=30&IT=I&ET=P</Data></Item>
+ <Item>
+ <Data>Testing Text Input Alert</Data>
+ </Item>
+ </Alert>
+ <Final/>
+ </SyncBody>
+ </SyncML>
diff --git a/engine/dmlib/linux_java/test/dm12/testdelete.wbxml b/engine/dmlib/linux_java/test/dm12/testdelete.wbxml
new file mode 100644
index 0000000..6dd6182
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testdelete.wbxml
Binary files differ
diff --git a/engine/dmlib/linux_java/test/dm12/testexecscript.xml b/engine/dmlib/linux_java/test/dm12/testexecscript.xml
new file mode 100644
index 0000000..2e6ec1e
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testexecscript.xml
@@ -0,0 +1,30 @@
+<SyncML xmlns="SYNCML:SYNCML1.2">
+<SyncHdr>
+<VerDTD>1.2</VerDTD>
+<VerProto>DM/1.2</VerProto>
+<SessionID>11</SessionID>
+<MsgID>1</MsgID>
+<Target>
+<LocURI>SampleClient</LocURI>
+</Target>
+<Source>
+<LocURI>mot.manage</LocURI>
+</Source>
+<RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+<Meta>
+<MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+</Meta>
+</SyncHdr>
+<SyncBody>
+<Exec>
+<CmdID>1</CmdID>
+<Item>
+<Target>
+<LocURI>.</LocURI>
+</Target>
+<Data>uname</Data>
+</Item>
+</Exec>
+<Final/>
+</SyncBody>
+</SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm12/testexecscript2.xml b/engine/dmlib/linux_java/test/dm12/testexecscript2.xml
new file mode 100644
index 0000000..a8bcde5
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testexecscript2.xml
@@ -0,0 +1,30 @@
+<SyncML xmlns="SYNCML:SYNCML1.2">
+<SyncHdr>
+<VerDTD>1.2</VerDTD>
+<VerProto>DM/1.2</VerProto>
+<SessionID>11</SessionID>
+<MsgID>1</MsgID>
+<Target>
+<LocURI>SampleClient</LocURI>
+</Target>
+<Source>
+<LocURI>mot.manage</LocURI>
+</Source>
+<RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+<Meta>
+<MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+</Meta>
+</SyncHdr>
+<SyncBody>
+<Exec>
+<CmdID>1</CmdID>
+<Item>
+<Target>
+<LocURI>.</LocURI>
+</Target>
+<Data>ls</Data>
+</Item>
+</Exec>
+<Final/>
+</SyncBody>
+</SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm12/testget.wbxml b/engine/dmlib/linux_java/test/dm12/testget.wbxml
new file mode 100644
index 0000000..d53d338
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testget.wbxml
Binary files differ
diff --git a/engine/dmlib/linux_java/test/dm12/testgetscript.xml b/engine/dmlib/linux_java/test/dm12/testgetscript.xml
new file mode 100644
index 0000000..8851443
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testgetscript.xml
@@ -0,0 +1,29 @@
+<SyncML xmlns="SYNCML:SYNCML1.2">
+<SyncHdr>
+<VerDTD>1.2</VerDTD>
+<VerProto>DM/1.2</VerProto>
+<SessionID>11</SessionID>
+<MsgID>1</MsgID>
+<Target>
+<LocURI>SampleClient</LocURI>
+</Target>
+<Source>
+<LocURI>mot.manage</LocURI>
+</Source>
+<RespURI>http://199.1.88.66/Scts?4Eq5AA==</RespURI>
+<Meta>
+<MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+</Meta>
+</SyncHdr>
+<SyncBody>
+<Get>
+<CmdID>1</CmdID>
+<Item>
+<Target>
+<LocURI>./DevInfo/DevId</LocURI>
+</Target>
+</Item>
+</Get>
+<Final/>
+</SyncBody>
+</SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm12/testinput12 b/engine/dmlib/linux_java/test/dm12/testinput12
new file mode 100644
index 0000000..bbed989
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testinput12
@@ -0,0 +1,511 @@
+########################################
+# Test Get
+########################################
+
+startCounter
+
+get .
+get ./DevInfo/DevId
+
+createi ./DMAcc/UniTest
+createl ./DMAcc/UniTest/ServerID 1.1.1.1
+get ./DMAcc/UniTest/ServerID
+replace ./DMAcc/UniTest/ServerID 2.2.2.2
+delete ./DMAcc/UniTest
+get .
+
+########################################
+# Test dump tree
+########################################
+
+dump ./DevInfo
+dump ./SyncML
+dump ./DevDetail
+
+########################################
+# Test rollback
+# 1 failure
+########################################
+
+begin
+createi ./SyncML/Con/x
+get ./SyncML/Con/x
+rollback
+
+# Next should fail
+get ./SyncML/Con/x
+
+########################################
+# Plugin Tests
+########################################
+
+# data plugin
+# 0 failure
+
+get ./TestPluginNode
+get ./TestPluginNode/a
+get ./TestPluginNode/b
+dump ./TestPluginNode
+
+########################################
+# Script tests
+########################################
+
+processscript unittest/dm12/testgetscript.xml
+processscript unittest/dm12/testexecscript.xml
+processscript unittest/dm12/testexecscript2.xml
+
+processscript unittest/dm12/testalertconfirmatomic.xml
+processscript unittest/dm12/testalertmultiplechoice.xml
+processscript unittest/dm12/testalertconfirm.xml
+processscript unittest/dm12/testalertsinglechoice.xml
+processscript unittest/dm12/testalertdisplay.xml
+processscript unittest/dm12/testalerttextinput.xml
+
+########################################
+# Binary Script tests
+########################################
+processscript unittest/dm12/testget.wbxml 1
+processscript unittest/dm12/testadd.wbxml 1
+processscript unittest/dm12/testdelete.wbxml 1
+processscript unittest/dm12/testreplace.wbxml 1
+
+########################################
+# SuperAgent Test and Build HMAC Cred
+########################################
+hmaccred scts
+
+########################################
+# Factory Boostrap Credential Generation
+########################################
+createi ./DMAcc/SampleServer
+createl ./DMAcc/SampleServer/ServerID Scts
+createi ./DMAcc/SampleServer/AppAddr
+createi ./DMAcc/SampleServer/AppAddr/1
+createl ./DMAcc/SampleServer/AppAddr/1/Addr http://127.0.0.1:80/Manage
+createl ./DMAcc/SampleServer/AppAddr/1/AddrType 1
+createl ./DMAcc/SampleServer/Name SampleServer
+createl ./DMAcc/SampleServer/PrefConRef
+
+#client
+createl ./DMAcc/SampleServer/AAuthPref DIGEST
+createi ./DMAcc/SampleServer/AppAuth
+createi ./DMAcc/SampleServer/AppAuth/1
+createl ./DMAcc/SampleServer/AppAuth/1/AAuthLevel CLCRED
+createl ./DMAcc/SampleServer/AppAuth/1/AAuthType DIGEST
+createl ./DMAcc/SampleServer/AppAuth/1/AAuthName \xE0\xE5\xE7\xEA\xEB
+createl ./DMAcc/SampleServer/AppAuth/1/AAuthSecret \xEB\xE8\xEF\xEE\xEC
+createl ./DMAcc/SampleServer/AppAuth/1/AAuthData 123abc
+
+#server
+createi ./DMAcc/SampleServer/AppAuth/3
+createl ./DMAcc/SampleServer/AppAuth/3/AAuthLevel SRVCRED
+createl ./DMAcc/SampleServer/AppAuth/3/AAuthType BASIC
+createl ./DMAcc/SampleServer/AppAuth/3/AAuthName SampleServer
+createl ./DMAcc/SampleServer/AppAuth/3/AAuthSecret \xFC\xE9\xE2\xE4\xE0
+createl ./DMAcc/SampleServer/AppAuth/3/AAuthData MTIzNDEyMzQxMjM0MTIzNA==
+
+connectsid Scts
+
+dump ./DMAcc/SampleServer
+
+delete ./DMAcc/SampleServer
+
+########################################
+# Exec test
+########################################
+Exec . ls
+
+########################################
+# Commit plug-in test for indirect update
+# and for fk: and child: MA
+########################################
+createi ./UnitTest/Profiles/1
+createl ./UnitTest/Profiles/1/CurProfile 12
+createi ./UnitTest/Profiles/2
+createl ./UnitTest/Profiles/2/CurProfile 12
+
+createi ./DMAcc/12
+createl ./DMAcc/12/ServerID some
+
+createl ./UnitTest/Profiles/1/CurProfile 12
+createl ./UnitTest/Profiles/2/CurProfile 12
+
+replace ./DMAcc/12/ServerID some3
+createl ./DMAcc/12/AppID some
+
+# should fail since child: constraint
+delete ./DMAcc/12
+
+# clean-up
+delete ./UnitTest/Profiles/1
+delete ./UnitTest/Profiles/2
+delete ./DMAcc/12
+
+
+########################################
+# DM 1.2 new data type positive smoke test.
+########################################
+createi ./UnitTest/NewDataType/MyApp
+
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.2345e+3
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -1.2345e+3
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -1.2345e+03
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -1.2345e-03
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.456
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -123.456
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 0
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+
+
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-15
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-258
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-W12-5
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-W02
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 20050125
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 200502
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005016
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005W205
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+delete ./UnitTest/NewDataType/MyApp/DateLeaf
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005W15
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15:25
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 231525
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 2315
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15:25Z
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15:59+01:20
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15:59-01:20
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf +3.2145e+3
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf -3.2145e+3
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf -3.2145e+03
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf -3.2145e-03
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf 103.456
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf -103.456
+get ./UnitTest/NewDataType/MyApp/FloatLeaf
+
+
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-10-15
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-10
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-258
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-W12-5
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-W02
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 20030125
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 200302
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003016
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003W205
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003W15
+get ./UnitTest/NewDataType/MyApp/DateLeaf
+
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15:25
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 031525
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 0315
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15:25Z
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15:59+01:20
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15:59-01:20
+get ./UnitTest/NewDataType/MyApp/TimeLeaf
+
+dump ./UnitTest/NewDataType/MyApp
+
+dump ./TestRWPluginNode
+
+processscript unittest/dm12/testnewdatatype.xml
+
+delete ./UnitTest/NewDataType/MyApp
+
+########################################
+# DM 1.2 new data type negative smoke test.
+########################################
+createi ./UnitTest/NewDataType/MyApp
+
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45+
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45-
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45E
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45e
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 1+1
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 1-1
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1+1
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -1+1
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf E
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf e
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf .
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45.5
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45a
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf ++123.5
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf --1234.5
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.3e_5
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.23.45e+5-5
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 1s23.45
+
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-1-10
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-00-10
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-00
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-00-30
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-32
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 24:03
+
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 5:63
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:63
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:63:01
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+01
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+01:52:23
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30-01:52:23
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+0152
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+0152Z
+
+
+createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.2345e+3
+createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-15
+createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15
+
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45.5
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45a
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf ++123.5
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf --1234.5
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.3e_5
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.23.45e+5-5
+setf ./UnitTest/NewDataType/MyApp/FloatLeaf 1s23.45
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-1-10
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-00-10
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-00
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-00-30
+setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-32
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 24:03
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 5:63
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:63
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:63:01
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+01
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+01:52:23
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30-01:52:23
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+0152
+sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+0152Z
+
+########################################
+# Create a char type ESN
+########################################
+createl ./TEST/lob
+setESN ./TEST/lob unittest/dm12/testlobdata1.dat
+get ./TEST/lob
+
+########################################
+# Replace a char type ESN data
+########################################
+
+setESN ./TEST/lob unittest/dm12/testlobdata2.dat
+get ./TEST/lob
+
+########################################
+# Clone a char type ESN
+########################################
+delete ./CLONE
+clone ./TEST CLONE
+get ./CLONE/lob
+
+########################################
+# Remove a char type ESN
+########################################
+
+delete ./TEST/lob
+delete ./CLONE/lob
+get ./TEST/lob
+
+########################################
+# Rollback an char type ESN
+########################################
+begin
+createl ./TEST/lob
+setESN ./TEST/lob unittest/dm12/testlobdata1.dat
+rollback
+get ./TEST/lob
+
+########################################
+# Create a binary type ESN
+########################################
+createlb ./TEST/lobbin
+setESN ./TEST/lob unittest/dm12/testlobdata1.dat
+get ./TEST/lobbin
+
+########################################
+# Replace a binary type ESN data
+########################################
+
+setESN ./TEST/lobbin unittest/dm12/testlobdata2.dat
+get ./TEST/lobbin
+
+########################################
+# Clone a binary type ESN
+########################################
+delete ./CLONE
+clone ./TEST CLONE
+get ./CLONE/lobbin
+
+########################################
+# Remove a binary type ESN
+########################################
+
+delete ./TEST/lobbin
+delete ./CLONE/lobbin
+get ./TEST/lobbin
+
+########################################
+# Rollback an binary type ESN
+########################################
+begin
+createlb ./TEST/lobbin
+setESN ./TEST/lobbin unittest/dm12/testlobdata1.dat
+rollback
+get ./TEST/lobbin
+
+########################################
+# Create a char type ESN
+########################################
+delete ./TestRWPluginNode/branch1/lob
+createl ./TestRWPluginNode/branch1/lob
+setESN ./TestRWPluginNode/branch1/lob unittest/dm12/testlobdata1.dat
+get ./TestRWPluginNode/branch1/lob
+
+########################################
+# Replace a char type ESN data
+########################################
+
+setESN ./TestRWPluginNode/branch1/lob unittest/dm12/testlobdata2.dat
+get ./TestRWPluginNode/branch1/lob
+
+########################################
+# Create a binary type ESN
+########################################
+delete ./TestRWPluginNode/branch1/lobbin
+createlb ./TestRWPluginNode/branch1/lobbin
+setESN ./TestRWPluginNode/branch1/lobbin unittest/dm12/testlobdata1.dat
+get ./TestRWPluginNode/branch1/lobbin
+
+########################################
+# Replace a binary type ESN data
+########################################
+
+setESN ./TestRWPluginNode/branch1/lobbin unittest/dm12/testlobdata2.dat
+get ./TestRWPluginNode/branch1/lobbin
+
+
+########################################
+# Clone a char type ESN
+########################################
+delete ./TestRWPluginNode/clone
+clone ./TestRWPluginNode/branch1 clone
+get ./TestRWPluginNode/clone/lob
+get ./TestRWPluginNode/clone/lobbin
+
+########################################
+# Remove a char type ESN
+########################################
+
+delete ./TestRWPluginNode/clone
+delete ./TestRWPluginNode/branch1/lob
+delete ./TestRWPluginNode/branch1/lobbin
+get ./TestRWPluginNode/clone/lobbin
+get ./TestRWPluginNode/branch1/lob
+get ./TestRWPluginNode/branch1/lobbin
+
+########################################
+# Rollback an char type ESN
+########################################
+begin
+createl ./TestRWPluginNode/branch1/lob
+setESN ./TestRWPluginNode/branch1/lob unittest/dm12/testlobdata1.dat
+rollback
+get ./TestRWPluginNode/branch1/lob
+
+########################################
+# Rollback an binary type ESN
+########################################
+begin
+createlb ./TestRWPluginNode/branch1/lobbin
+setESN ./TestRWPluginNode/branch1/lobbin unittest/dm12/testlobdata1.dat
+rollback
+get ./TestRWPluginNode/branch1/lobbin
+
+getCounter
+
+quit
diff --git a/engine/dmlib/linux_java/test/dm12/testlobdata1.dat b/engine/dmlib/linux_java/test/dm12/testlobdata1.dat
new file mode 100644
index 0000000..11f11f9
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testlobdata1.dat
@@ -0,0 +1 @@
+0123456789
diff --git a/engine/dmlib/linux_java/test/dm12/testlobdata2.dat b/engine/dmlib/linux_java/test/dm12/testlobdata2.dat
new file mode 100644
index 0000000..be7024b
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testlobdata2.dat
@@ -0,0 +1 @@
+abcdefghijklmnopqrstunwxyz
diff --git a/engine/dmlib/linux_java/test/dm12/testnewdatatype.xml b/engine/dmlib/linux_java/test/dm12/testnewdatatype.xml
new file mode 100644
index 0000000..7785466
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testnewdatatype.xml
@@ -0,0 +1,165 @@
+<SyncML xmlns="SYNCML:SYNCML1.2">
+ <SyncHdr>
+ <VerDTD>1.2</VerDTD>
+ <VerProto>DM/1.2</VerProto>
+ <SessionID>18629</SessionID>
+ <MsgID>1</MsgID>
+ <Target>
+ <LocURI>000000011234564</LocURI>
+ </Target>
+ <Source>
+ <LocURI>http://10.72.35.166/Manage</LocURI>
+ </Source>
+ <RespURI>http://10.72.35.166/Scts?YDjHAA==</RespURI>
+ <Cred>
+ <Meta>
+ <Format xmlns="syncml:metinf">b64</Format>
+ <Type xmlns="syncml:metinf">syncml:auth-basic</Type>
+ </Meta>
+ <Data>U2N0czpTYW1wbGVDbGllbnQ=</Data>
+ </Cred>
+ <Meta>
+ <MaxMsgSize xmlns="syncml:metinf">20000</MaxMsgSize>
+ </Meta>
+ </SyncHdr>
+ <SyncBody>
+ <Add>
+ <CmdID>1</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp</LocURI>
+ </Target>
+ <Meta>
+ <Format xmlns="syncml:metinf">node</Format>
+ <Type xmlns="syncml:metinf">text/plain</Type>
+ </Meta>
+ </Item>
+ </Add>
+ <Add>
+ <CmdID>2</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/FloatLeaf</LocURI>
+ </Target>
+ <Meta>
+ <Format xmlns="syncml:metinf">float</Format>
+ <Type xmlns="syncml:metinf">text/plain</Type>
+ </Meta>
+ <Data>+1.23e+01</Data>
+ </Item>
+ </Add>
+ <Add>
+ <CmdID>3</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/DateLeaf</LocURI>
+ </Target>
+ <Meta>
+ <Format xmlns="syncml:metinf">date</Format>
+ <Type xmlns="syncml:metinf">text/plain</Type>
+ </Meta>
+ <Data>2005-10-18</Data>
+ </Item>
+ </Add>
+ <Add>
+ <CmdID>4</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/TimeLeaf</LocURI>
+ </Target>
+ <Meta>
+ <Format xmlns="syncml:metinf">time</Format>
+ <Type xmlns="syncml:metinf">text/plain</Type>
+ </Meta>
+ <Data>23:18:23</Data>
+ </Item>
+ </Add>
+ <Replace>
+ <CmdID>5</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/FloatLeaf</LocURI>
+ </Target>
+ <Meta><Format xmlns="syncml:metinf">float</Format></Meta>
+ <Data>1.2345</Data>
+ </Item>
+ </Replace>
+ <Replace>
+ <CmdID>6</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/DateLeaf</LocURI>
+ </Target>
+ <Meta><Format xmlns="syncml:metinf">date</Format></Meta>
+ <Data>2005-345</Data>
+ </Item>
+ </Replace>
+ <Replace>
+ <CmdID>7</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/TimeLeaf</LocURI>
+ </Target>
+ <Meta><Format xmlns="syncml:metinf">time</Format></Meta>
+ <Data>11:20:35+01:20</Data>
+ </Item>
+ </Replace>
+ <Get>
+ <CmdID>8</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/FloatLeaf</LocURI>
+ </Target>
+ </Item>
+ </Get>
+ <Get>
+ <CmdID>9</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/DateLeaf</LocURI>
+ </Target>
+ </Item>
+ </Get>
+ <Get>
+ <CmdID>10</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/TimeLeaf</LocURI>
+ </Target>
+ </Item>
+ </Get>
+ <Delete>
+ <CmdID>11</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/FloatLeaf</LocURI>
+ </Target>
+ </Item>
+ </Delete>
+ <Delete>
+ <CmdID>12</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/DateLeaf</LocURI>
+ </Target>
+ </Item>
+ </Delete>
+ <Delete>
+ <CmdID>13</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp/TimeLeaf</LocURI>
+ </Target>
+ </Item>
+ </Delete>
+ <Delete>
+ <CmdID>14</CmdID>
+ <Item>
+ <Target>
+ <LocURI>./Test/MyApp</LocURI>
+ </Target>
+ </Item>
+ </Delete>
+ <Final/>
+ </SyncBody>
+</SyncML> \ No newline at end of file
diff --git a/engine/dmlib/linux_java/test/dm12/testoutput12 b/engine/dmlib/linux_java/test/dm12/testoutput12
new file mode 100644
index 0000000..89e4603
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testoutput12
@@ -0,0 +1,3360 @@
+Interaction mode, type "exit" to exit, ? for help
+
+]
+]
+]
+]
+] Cmd: startCounter
+Counter started!
+
+]
+] Cmd: get .
+path=.
+isLeaf=false
+name=.
+format=node
+type=
+title=
+acl=Add=*&Delete=*&Exec=*&Get=*&Replace=*
+size=0
+version=4
+children:TestRWPluginNode/TestPluginNode/DevDetail/TEST/DMAcc/UnitTest/SyncML/DevInfo/CLONE/
+
+] Cmd: get ./DevInfo/DevId
+path=./DevInfo/DevId
+isLeaf=true
+name=DevId
+format=chr
+type=text/plain
+title=
+acl=
+size=15
+version=0
+value=000000011234564
+
+]
+] Cmd: createi ./DMAcc/UniTest
+node ./DMAcc/UniTest created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/UniTest], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/UniTest/ServerID 1.1.1.1
+node ./DMAcc/UniTest/ServerID (1.1.1.1) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/UniTest/ServerID], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: get ./DMAcc/UniTest/ServerID
+path=./DMAcc/UniTest/ServerID
+isLeaf=true
+name=ServerID
+format=chr
+type=text/plain
+title=
+acl=
+size=7
+version=0
+value=1.1.1.1
+
+] Cmd: replace ./DMAcc/UniTest/ServerID 2.2.2.2
+set value of node ./DMAcc/UniTest/ServerID to 2.2.2.2 successfully
+path=./DMAcc/UniTest/ServerID
+isLeaf=true
+name=ServerID
+format=chr
+type=text/plain
+title=
+acl=
+size=7
+version=1
+value=2.2.2.2
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/UniTest/ServerID], [REPLACE]
+Commit plug-in: OnCommit <END>
+
+] Cmd: delete ./DMAcc/UniTest
+node ./DMAcc/UniTest deleted successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/UniTest], [DELETE]
+Commit plug-in: OnCommit <END>
+
+] Cmd: get .
+path=.
+isLeaf=false
+name=.
+format=node
+type=
+title=
+acl=Add=*&Delete=*&Exec=*&Get=*&Replace=*
+size=0
+version=4
+children:TestRWPluginNode/TestPluginNode/DevDetail/TEST/DMAcc/UnitTest/SyncML/DevInfo/CLONE/
+
+]
+]
+]
+]
+]
+] Cmd: dump ./DevInfo
+path=./DevInfo
+isLeaf=false
+name=DevInfo
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:LangAuto/Loc/Sort/Ext/Bearer/Mod/Man/Lang/DmV/DevId/
+
+path=./DevInfo/LangAuto
+isLeaf=true
+name=LangAuto
+format=bool
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=false
+
+path=./DevInfo/Loc
+isLeaf=true
+name=Loc
+format=chr
+type=text/plain
+title=
+acl=
+size=2
+version=0
+value=US
+
+path=./DevInfo/Sort
+isLeaf=true
+name=Sort
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=Latin
+
+path=./DevInfo/Ext
+isLeaf=false
+name=Ext
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:null
+
+path=./DevInfo/Bearer
+isLeaf=false
+name=Bearer
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:GSM/
+
+path=./DevInfo/Bearer/GSM
+isLeaf=true
+name=GSM
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+path=./DevInfo/Mod
+isLeaf=true
+name=Mod
+format=chr
+type=text/plain
+title=
+acl=
+size=4
+version=0
+value=A780
+
+path=./DevInfo/Man
+isLeaf=true
+name=Man
+format=chr
+type=text/plain
+title=
+acl=
+size=24
+version=0
+value=Motorola, Copyright 2005
+
+path=./DevInfo/Lang
+isLeaf=true
+name=Lang
+format=chr
+type=text/plain
+title=
+acl=
+size=2
+version=0
+value=en
+
+path=./DevInfo/DmV
+isLeaf=true
+name=DmV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.2
+
+path=./DevInfo/DevId
+isLeaf=true
+name=DevId
+format=chr
+type=text/plain
+title=
+acl=
+size=15
+version=0
+value=000000011234564
+
+
+] Cmd: dump ./SyncML
+path=./SyncML
+isLeaf=false
+name=SyncML
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:DMAcc/Con/
+
+Error! can't get child nodes of ./SyncML, DmtException: 406
+
+] Cmd: dump ./DevDetail
+path=./DevDetail
+isLeaf=false
+name=DevDetail
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:Ext/PRIChecksum/PRLV/ESNV/FlexV/URI/Bearer/SwV/OEM/LrgObj/HwV/FwV/DevTyp/
+
+path=./DevDetail/Ext
+isLeaf=false
+name=Ext
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:null
+
+path=./DevDetail/PRIChecksum
+isLeaf=true
+name=PRIChecksum
+format=chr
+type=text/plain
+title=
+acl=
+size=6
+version=0
+value=111111
+
+path=./DevDetail/PRLV
+isLeaf=true
+name=PRLV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/ESNV
+isLeaf=true
+name=ESNV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/FlexV
+isLeaf=true
+name=FlexV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/URI
+isLeaf=false
+name=URI
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:MaxTotLen/MaxSegLen/MaxDepth/
+
+path=./DevDetail/URI/MaxTotLen
+isLeaf=true
+name=MaxTotLen
+format=int
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=255
+
+path=./DevDetail/URI/MaxSegLen
+isLeaf=true
+name=MaxSegLen
+format=int
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=128
+
+path=./DevDetail/URI/MaxDepth
+isLeaf=true
+name=MaxDepth
+format=int
+type=text/plain
+title=
+acl=
+size=2
+version=0
+value=20
+
+path=./DevDetail/Bearer
+isLeaf=false
+name=Bearer
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:GSM/CDMA/
+
+path=./DevDetail/Bearer/GSM
+isLeaf=true
+name=GSM
+format=chr
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=1900-GSM
+
+path=./DevDetail/Bearer/CDMA
+isLeaf=true
+name=CDMA
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+path=./DevDetail/SwV
+isLeaf=true
+name=SwV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/OEM
+isLeaf=true
+name=OEM
+format=chr
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=Motorola
+
+path=./DevDetail/LrgObj
+isLeaf=true
+name=LrgObj
+format=bool
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=false
+
+path=./DevDetail/HwV
+isLeaf=true
+name=HwV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/FwV
+isLeaf=true
+name=FwV
+format=chr
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=1.0
+
+path=./DevDetail/DevTyp
+isLeaf=true
+name=DevTyp
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+
+]
+]
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createi ./SyncML/Con/x
+node ./SyncML/Con/x created successfully
+
+] Cmd: get ./SyncML/Con/x
+path=./SyncML/Con/x
+isLeaf=false
+name=x
+format=node
+type=
+title=
+acl=
+size=0
+version=0
+children:null
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+]
+]
+] Cmd: get ./SyncML/Con/x
+Error! can't get node ./SyncML/Con/x, DmtException: 404
+
+]
+]
+]
+]
+]
+]
+]
+]
+] Cmd: get ./TestPluginNode
+path=./TestPluginNode
+isLeaf=false
+name=TestPluginNode
+format=node
+type=text/plain
+title=
+acl=
+size=0
+version=0
+children:a/b/
+
+] Cmd: get ./TestPluginNode/a
+path=./TestPluginNode/a
+isLeaf=true
+name=a
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=leaf1
+
+] Cmd: get ./TestPluginNode/b
+path=./TestPluginNode/b
+isLeaf=true
+name=b
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=leaf2
+
+] Cmd: dump ./TestPluginNode
+path=./TestPluginNode
+isLeaf=false
+name=TestPluginNode
+format=node
+type=text/plain
+title=
+acl=
+size=0
+version=0
+children:a/b/
+
+path=./TestPluginNode/a
+isLeaf=true
+name=a
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=leaf1
+
+path=./TestPluginNode/b
+isLeaf=true
+name=b
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=leaf2
+
+
+]
+]
+]
+]
+]
+] Cmd: processscript unittest/dm12/testgetscript.xml
+Process WBXML script: false
+Read 501 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Get</Cmd><TargetRef>./DevInfo/DevId</TargetRef><Data>200</Data></Status><Results><CmdID>2</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Item><Source><LocURI>./DevInfo/DevId</LocURI></Source><Meta><Size xmlns='syncml:metinf'>15</Size></Meta><Data>000000011234564</Data></Item></Results><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm12/testexecscript.xml
+Process WBXML script: false
+Read 508 bytes
+execute path=. args=uname
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Exec</Cmd><Data>200</Data></Status><Results><CmdID>2</CmdID><CmdRef>1</CmdRef><Item><Source><LocURI>.</LocURI></Source><Meta><Size xmlns='syncml:metinf'>6</Size></Meta><Data>Linux
+</Data></Item></Results><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm12/testexecscript2.xml
+Process WBXML script: false
+Read 505 bytes
+execute path=. args=ls
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Exec</Cmd><Data>200</Data></Status><Results><CmdID>2</CmdID><CmdRef>1</CmdRef><Item><Source><LocURI>.</LocURI></Source><Meta><Size xmlns='syncml:metinf'>64</Size></Meta><Data>bin
+compile
+dmt_data
+lib
+plugins
+run_test
+settings
+src
+unittest
+</Data></Item></Results><Final/></SyncBody></SyncML>
+
+
+]
+] Cmd: processscript unittest/dm12/testalertconfirmatomic.xml
+Process WBXML script: false
+Read 884 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Atomic</Cmd><Data>507</Data></Status><Status><CmdID>2</CmdID><MsgRef>1</MsgRef><CmdRef>2</CmdRef><Cmd>Alert</Cmd><TargetRef></TargetRef><Data>408</Data></Status><Status><CmdID>3</CmdID><MsgRef>1</MsgRef><CmdRef>3</CmdRef><Cmd>Replace</Cmd><TargetRef>./DevDetail/Bearer/GSM</TargetRef><Data>215</Data></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm12/testalertmultiplechoice.xml
+Process WBXML script: false
+Read 844 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Alert</Cmd><Data>408</Data><Item><Data>1</Data></Item><Item><Data>3,6</Data></Item></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm12/testalertconfirm.xml
+Process WBXML script: false
+Read 584 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>2</CmdRef><Cmd>Alert</Cmd><Data>408</Data></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm12/testalertsinglechoice.xml
+Process WBXML script: false
+Read 838 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Alert</Cmd><Data>408</Data><Item><Data>2</Data></Item></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm12/testalertdisplay.xml
+Process WBXML script: false
+Read 570 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Alert</Cmd><Data>200</Data></Status><Final/></SyncBody></SyncML>
+
+
+] Cmd: processscript unittest/dm12/testalerttextinput.xml
+Process WBXML script: false
+Read 609 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>11</SessionID><MsgID>1</MsgID><Target><LocURI>http://199.1.88.66/Scts?4Eq5AA==</LocURI></Target><Source><LocURI>SampleClient</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Alert</Cmd><Data>408</Data><Item><Data>hello+andy!</Data></Item></Status><Final/></SyncBody></SyncML>
+
+
+]
+]
+]
+]
+] Cmd: processscript unittest/dm12/testget.wbxml 1
+Process WBXML script: true
+Read 437 bytes
+
+Print result in HEX mode:
+
+Result Size: 327
+0000: 02 00 00 6a 1d 2d 2f 2f 53 59 4e 43 4d 4c 2f 2f ...j.-//SYNCML//
+0010: 44 54 44 20 53 79 6e 63 4d 4c 20 31 2e 32 2f 2f DTD SyncML 1.2//
+0020: 45 4e 6d 6c 71 03 31 2e 32 00 01 72 03 44 4d 2f ENmlq.1.2..r.DM/
+0030: 31 2e 32 00 01 65 03 32 32 31 30 30 00 01 5b 03 1.2..e.22100..[.
+0040: 31 00 01 6e 57 03 68 74 74 70 3a 2f 2f 31 30 2e 1..nW.http://10.
+0050: 37 32 2e 33 34 2e 32 31 37 2f 53 63 74 73 3f 30 72.34.217/Scts?0
+0060: 4a 54 49 41 41 3d 3d 00 01 01 67 57 03 30 30 30 JTIAA==...gW.000
+0070: 30 30 30 30 31 31 32 33 34 35 36 34 00 01 01 5a 000011234564...Z
+0080: 00 01 4c 03 33 35 30 30 00 01 01 01 00 00 6b 69 ..L.3500......ki
+0090: 4b 03 31 00 01 5c 03 31 00 01 4c 03 30 00 01 4a K.1..\.1..L.0..J
+00a0: 03 53 79 6e 63 48 64 72 00 01 4f 03 32 30 30 00 .SyncHdr..O.200.
+00b0: 01 01 69 4b 03 32 00 01 5c 03 31 00 01 4c 03 34 ..iK.2..\.1..L.4
+00c0: 00 01 4a 03 47 65 74 00 01 6f 03 2e 2f 44 65 76 ..J.Get..o../Dev
+00d0: 44 65 74 61 69 6c 2f 55 52 49 2f 4d 61 78 44 65 Detail/URI/MaxDe
+00e0: 70 74 68 00 01 4f 03 32 30 30 00 01 01 62 4b 03 pth..O.200...bK.
+00f0: 33 00 01 5c 03 31 00 01 4c 03 34 00 01 54 67 57 3..\.1..L.4..TgW
+0100: 03 2e 2f 44 65 76 44 65 74 61 69 6c 2f 55 52 49 ../DevDetail/URI
+0110: 2f 4d 61 78 44 65 70 74 68 00 01 01 5a 00 01 47 /MaxDepth...Z..G
+0120: 03 69 6e 74 00 01 53 03 74 65 78 74 2f 70 6c 61 .int..S.text/pla
+0130: 69 6e 00 01 52 03 32 00 01 01 00 00 4f 03 32 30 in..R.2.....O.20
+0140: 00 01 01 01 12 01 01 .......
+
+] Cmd: processscript unittest/dm12/testadd.wbxml 1
+Process WBXML script: true
+Read 445 bytes
+
+Print result in HEX mode:
+
+Result Size: 230
+0000: 02 00 00 6a 1d 2d 2f 2f 53 59 4e 43 4d 4c 2f 2f ...j.-//SYNCML//
+0010: 44 54 44 20 53 79 6e 63 4d 4c 20 31 2e 32 2f 2f DTD SyncML 1.2//
+0020: 45 4e 6d 6c 71 03 31 2e 32 00 01 72 03 44 4d 2f ENmlq.1.2..r.DM/
+0030: 31 2e 32 00 01 65 03 33 30 34 38 33 00 01 5b 03 1.2..e.30483..[.
+0040: 31 00 01 6e 57 03 68 74 74 70 3a 2f 2f 31 30 2e 1..nW.http://10.
+0050: 37 32 2e 33 34 2e 32 31 37 2f 53 63 74 73 3f 34 72.34.217/Scts?4
+0060: 45 4c 49 41 41 3d 3d 00 01 01 67 57 03 30 30 30 ELIAA==...gW.000
+0070: 30 30 30 30 31 31 32 33 34 35 36 34 00 01 01 5a 000011234564...Z
+0080: 00 01 4c 03 33 35 30 30 00 01 01 01 00 00 6b 69 ..L.3500......ki
+0090: 4b 03 31 00 01 5c 03 31 00 01 4c 03 30 00 01 4a K.1..\.1..L.0..J
+00a0: 03 53 79 6e 63 48 64 72 00 01 4f 03 32 30 30 00 .SyncHdr..O.200.
+00b0: 01 01 69 4b 03 32 00 01 5c 03 31 00 01 4c 03 34 ..iK.2..\.1..L.4
+00c0: 00 01 4a 03 41 64 64 00 01 6f 03 2e 2f 54 65 73 ..J.Add..o../Tes
+00d0: 74 4c 65 61 66 4e 6f 64 65 00 01 4f 03 35 30 30 tLeafNode..O.500
+00e0: 00 01 01 12 01 01 ......
+
+] Cmd: processscript unittest/dm12/testdelete.wbxml 1
+Process WBXML script: true
+Read 452 bytes
+
+Print result in HEX mode:
+
+Result Size: 281
+0000: 02 00 00 6a 1d 2d 2f 2f 53 59 4e 43 4d 4c 2f 2f ...j.-//SYNCML//
+0010: 44 54 44 20 53 79 6e 63 4d 4c 20 31 2e 32 2f 2f DTD SyncML 1.2//
+0020: 45 4e 6d 6c 71 03 31 2e 32 00 01 72 03 44 4d 2f ENmlq.1.2..r.DM/
+0030: 31 2e 32 00 01 65 03 31 32 34 36 33 00 01 5b 03 1.2..e.12463..[.
+0040: 31 00 01 6e 57 03 68 74 74 70 3a 2f 2f 31 30 2e 1..nW.http://10.
+0050: 37 32 2e 33 34 2e 32 31 37 2f 53 63 74 73 3f 41 72.34.217/Scts?A
+0060: 4c 76 48 41 41 3d 3d 00 01 01 67 57 03 30 30 30 LvHAA==...gW.000
+0070: 30 30 30 30 31 31 32 33 34 35 36 34 00 01 01 5a 000011234564...Z
+0080: 00 01 4c 03 33 35 30 30 00 01 01 01 00 00 6b 69 ..L.3500......ki
+0090: 4b 03 31 00 01 5c 03 31 00 01 4c 03 30 00 01 4a K.1..\.1..L.0..J
+00a0: 03 53 79 6e 63 48 64 72 00 01 4f 03 32 30 30 00 .SyncHdr..O.200.
+00b0: 01 01 69 4b 03 32 00 01 5c 03 31 00 01 4c 03 34 ..iK.2..\.1..L.4
+00c0: 00 01 4a 03 44 65 6c 65 74 65 00 01 6f 03 2e 2f ..J.Delete..o../
+00d0: 54 65 73 74 4c 65 61 66 4e 6f 64 65 00 01 4f 03 TestLeafNode..O.
+00e0: 34 30 34 00 01 01 69 4b 03 33 00 01 5c 03 31 00 404...iK.3..\.1.
+00f0: 01 4c 03 35 00 01 4a 03 44 65 6c 65 74 65 00 01 .L.5..J.Delete..
+0100: 6f 03 2e 2f 54 65 73 74 4c 65 61 66 00 01 4f 03 o../TestLeaf..O.
+0110: 34 30 34 00 01 01 12 01 01 404......
+
+] Cmd: processscript unittest/dm12/testreplace.wbxml 1
+Process WBXML script: true
+Read 565 bytes
+
+Print result in HEX mode:
+
+Result Size: 684
+0000: 02 00 00 6a 1d 2d 2f 2f 53 59 4e 43 4d 4c 2f 2f ...j.-//SYNCML//
+0010: 44 54 44 20 53 79 6e 63 4d 4c 20 31 2e 32 2f 2f DTD SyncML 1.2//
+0020: 45 4e 6d 6c 71 03 31 2e 32 00 01 72 03 44 4d 2f ENmlq.1.2..r.DM/
+0030: 31 2e 32 00 01 65 03 32 34 36 37 33 00 01 5b 03 1.2..e.24673..[.
+0040: 31 00 01 6e 57 03 30 30 30 30 30 30 30 31 31 32 1..nW.0000000112
+0050: 33 34 35 36 34 00 01 56 03 53 61 6d 70 6c 65 53 34564..V.SampleS
+0060: 65 72 76 65 72 00 01 01 67 57 03 68 74 74 70 3a erver...gW.http:
+0070: 2f 2f 31 30 2e 37 32 2e 34 31 2e 31 38 32 3a 38 //10.72.41.182:8
+0080: 30 2f 4d 61 6e 61 67 65 00 01 56 03 53 63 74 73 0/Manage..V.Scts
+0090: 00 01 01 5a 00 01 4c 03 33 35 30 30 00 01 01 01 ...Z..L.3500....
+00a0: 00 00 6b 69 4b 03 31 00 01 5c 03 31 00 01 4c 03 ..kiK.1..\.1..L.
+00b0: 31 00 01 4a 03 41 6c 65 72 74 00 01 4f 03 32 30 1..J.Alert..O.20
+00c0: 30 00 01 01 69 4b 03 32 00 01 5c 03 31 00 01 4c 0...iK.2..\.1..L
+00d0: 03 32 00 01 4a 03 52 65 70 6c 61 63 65 00 01 68 .2..J.Replace..h
+00e0: 03 2e 2f 44 65 76 49 6e 66 6f 2f 44 65 76 49 64 ../DevInfo/DevId
+00f0: 00 01 4f 03 34 30 30 00 01 01 69 4b 03 33 00 01 ..O.400...iK.3..
+0100: 5c 03 31 00 01 4c 03 32 00 01 4a 03 52 65 70 6c \.1..L.2..J.Repl
+0110: 61 63 65 00 01 68 03 2e 2f 44 65 76 49 6e 66 6f ace..h../DevInfo
+0120: 2f 44 6d 56 00 01 4f 03 34 30 30 00 01 01 69 4b /DmV..O.400...iK
+0130: 03 34 00 01 5c 03 31 00 01 4c 03 32 00 01 4a 03 .4..\.1..L.2..J.
+0140: 52 65 70 6c 61 63 65 00 01 68 03 2e 2f 44 65 76 Replace..h../Dev
+0150: 49 6e 66 6f 2f 4c 61 6e 67 00 01 4f 03 34 30 30 Info/Lang..O.400
+0160: 00 01 01 69 4b 03 35 00 01 5c 03 31 00 01 4c 03 ...iK.5..\.1..L.
+0170: 32 00 01 4a 03 52 65 70 6c 61 63 65 00 01 68 03 2..J.Replace..h.
+0180: 2e 2f 44 65 76 49 6e 66 6f 2f 4d 61 6e 00 01 4f ./DevInfo/Man..O
+0190: 03 34 30 30 00 01 01 69 4b 03 36 00 01 5c 03 31 .400...iK.6..\.1
+01a0: 00 01 4c 03 32 00 01 4a 03 52 65 70 6c 61 63 65 ..L.2..J.Replace
+01b0: 00 01 68 03 2e 2f 44 65 76 49 6e 66 6f 2f 4d 6f ..h../DevInfo/Mo
+01c0: 64 00 01 4f 03 34 30 30 00 01 01 69 4b 03 37 00 d..O.400...iK.7.
+01d0: 01 5c 03 31 00 01 4c 03 32 00 01 4a 03 52 65 70 .\.1..L.2..J.Rep
+01e0: 6c 61 63 65 00 01 68 03 2e 2f 44 65 76 49 6e 66 lace..h../DevInf
+01f0: 6f 2f 42 65 61 72 65 72 2f 47 53 4d 00 01 4f 03 o/Bearer/GSM..O.
+0200: 34 30 30 00 01 01 69 4b 03 38 00 01 5c 03 31 00 400...iK.8..\.1.
+0210: 01 4c 03 32 00 01 4a 03 52 65 70 6c 61 63 65 00 .L.2..J.Replace.
+0220: 01 68 03 2e 2f 44 65 76 49 6e 66 6f 2f 53 6f 72 .h../DevInfo/Sor
+0230: 74 00 01 4f 03 34 30 30 00 01 01 69 4b 03 39 00 t..O.400...iK.9.
+0240: 01 5c 03 31 00 01 4c 03 32 00 01 4a 03 52 65 70 .\.1..L.2..J.Rep
+0250: 6c 61 63 65 00 01 68 03 2e 2f 44 65 76 49 6e 66 lace..h../DevInf
+0260: 6f 2f 4c 6f 63 00 01 4f 03 34 30 30 00 01 01 69 o/Loc..O.400...i
+0270: 4b 03 31 30 00 01 5c 03 31 00 01 4c 03 32 00 01 K.10..\.1..L.2..
+0280: 4a 03 52 65 70 6c 61 63 65 00 01 68 03 2e 2f 44 J.Replace..h../D
+0290: 65 76 49 6e 66 6f 2f 4c 61 6e 67 41 75 74 6f 00 evInfo/LangAuto.
+02a0: 01 4f 03 34 30 30 00 01 01 12 01 01 .O.400......
+
+]
+]
+]
+]
+] Cmd: hmaccred scts
+
+]
+]
+]
+]
+] Cmd: createi ./DMAcc/SampleServer
+node ./DMAcc/SampleServer created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/ServerID Scts
+node ./DMAcc/SampleServer/ServerID (Scts) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/ServerID], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createi ./DMAcc/SampleServer/AppAddr
+node ./DMAcc/SampleServer/AppAddr created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAddr], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createi ./DMAcc/SampleServer/AppAddr/1
+node ./DMAcc/SampleServer/AppAddr/1 created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAddr/1], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAddr/1/Addr http://127.0.0.1:80/Manage
+node ./DMAcc/SampleServer/AppAddr/1/Addr (http://127.0.0.1:80/Manage) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAddr/1/Addr], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAddr/1/AddrType 1
+node ./DMAcc/SampleServer/AppAddr/1/AddrType (1) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAddr/1/AddrType], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/Name SampleServer
+node ./DMAcc/SampleServer/Name (SampleServer) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/Name], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/PrefConRef
+node ./DMAcc/SampleServer/PrefConRef () created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/PrefConRef], [ADD]
+Commit plug-in: OnCommit <END>
+
+]
+]
+] Cmd: createl ./DMAcc/SampleServer/AAuthPref DIGEST
+node ./DMAcc/SampleServer/AAuthPref (DIGEST) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AAuthPref], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createi ./DMAcc/SampleServer/AppAuth
+node ./DMAcc/SampleServer/AppAuth created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createi ./DMAcc/SampleServer/AppAuth/1
+node ./DMAcc/SampleServer/AppAuth/1 created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/1], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/1/AAuthLevel CLCRED
+node ./DMAcc/SampleServer/AppAuth/1/AAuthLevel (CLCRED) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/1/AAuthLevel], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/1/AAuthType DIGEST
+node ./DMAcc/SampleServer/AppAuth/1/AAuthType (DIGEST) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/1/AAuthType], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/1/AAuthName \xE0\xE5\xE7\xEA\xEB
+node ./DMAcc/SampleServer/AppAuth/1/AAuthName (àåçêë) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/1/AAuthName], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/1/AAuthSecret \xEB\xE8\xEF\xEE\xEC
+node ./DMAcc/SampleServer/AppAuth/1/AAuthSecret (ëèïîì) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/1/AAuthSecret], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/1/AAuthData 123abc
+node ./DMAcc/SampleServer/AppAuth/1/AAuthData (123abc) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/1/AAuthData], [ADD]
+Commit plug-in: OnCommit <END>
+
+]
+]
+] Cmd: createi ./DMAcc/SampleServer/AppAuth/3
+node ./DMAcc/SampleServer/AppAuth/3 created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/3], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/3/AAuthLevel SRVCRED
+node ./DMAcc/SampleServer/AppAuth/3/AAuthLevel (SRVCRED) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/3/AAuthLevel], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/3/AAuthType BASIC
+node ./DMAcc/SampleServer/AppAuth/3/AAuthType (BASIC) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/3/AAuthType], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/3/AAuthName SampleServer
+node ./DMAcc/SampleServer/AppAuth/3/AAuthName (SampleServer) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/3/AAuthName], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/3/AAuthSecret \xFC\xE9\xE2\xE4\xE0
+node ./DMAcc/SampleServer/AppAuth/3/AAuthSecret (üéâäà) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/3/AAuthSecret], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/SampleServer/AppAuth/3/AAuthData MTIzNDEyMzQxMjM0MTIzNA==
+node ./DMAcc/SampleServer/AppAuth/3/AAuthData (MTIzNDEyMzQxMjM0MTIzNA==) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/3/AAuthData], [ADD]
+Commit plug-in: OnCommit <END>
+
+]
+] Cmd: connectsid Scts
+start server session, Scts, bin = false
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer/AppAuth/1/AAuthName], [REPLACE]
+notification for uri [./DMAcc/SampleServer/AppAuth/1/AAuthSecret], [REPLACE]
+Commit plug-in: OnCommit <END>
+Error! can't start server session, DmtException: 1
+
+]
+] Cmd: dump ./DMAcc/SampleServer
+path=./DMAcc/SampleServer
+isLeaf=false
+name=SampleServer
+format=node
+type=
+title=
+acl=
+size=0
+version=6
+children:ServerID/AppAddr/Name/PrefConRef/AAuthPref/AppAuth/
+
+path=./DMAcc/SampleServer/ServerID
+isLeaf=true
+name=ServerID
+format=chr
+type=text/plain
+title=
+acl=
+size=4
+version=0
+value=Scts
+
+path=./DMAcc/SampleServer/AppAddr
+isLeaf=false
+name=AppAddr
+format=node
+type=
+title=
+acl=
+size=0
+version=1
+children:1/
+
+path=./DMAcc/SampleServer/AppAddr/1
+isLeaf=false
+name=1
+format=node
+type=
+title=
+acl=
+size=0
+version=2
+children:Addr/AddrType/
+
+path=./DMAcc/SampleServer/AppAddr/1/Addr
+isLeaf=true
+name=Addr
+format=chr
+type=text/plain
+title=
+acl=
+size=26
+version=0
+value=http://127.0.0.1:80/Manage
+
+path=./DMAcc/SampleServer/AppAddr/1/AddrType
+isLeaf=true
+name=AddrType
+format=chr
+type=text/plain
+title=
+acl=
+size=1
+version=0
+value=1
+
+path=./DMAcc/SampleServer/Name
+isLeaf=true
+name=Name
+format=chr
+type=text/plain
+title=
+acl=
+size=12
+version=0
+value=SampleServer
+
+path=./DMAcc/SampleServer/PrefConRef
+isLeaf=true
+name=PrefConRef
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+path=./DMAcc/SampleServer/AAuthPref
+isLeaf=true
+name=AAuthPref
+format=chr
+type=text/plain
+title=
+acl=
+size=6
+version=0
+value=DIGEST
+
+path=./DMAcc/SampleServer/AppAuth
+isLeaf=false
+name=AppAuth
+format=node
+type=
+title=
+acl=
+size=0
+version=2
+children:1/3/
+
+path=./DMAcc/SampleServer/AppAuth/1
+isLeaf=false
+name=1
+format=node
+type=
+title=
+acl=
+size=0
+version=5
+children:AAuthLevel/AAuthType/AAuthName/AAuthSecret/AAuthData/
+
+path=./DMAcc/SampleServer/AppAuth/1/AAuthLevel
+isLeaf=true
+name=AAuthLevel
+format=chr
+type=text/plain
+title=
+acl=
+size=6
+version=0
+value=CLCRED
+
+path=./DMAcc/SampleServer/AppAuth/1/AAuthType
+isLeaf=true
+name=AAuthType
+format=chr
+type=text/plain
+title=
+acl=
+size=6
+version=0
+value=DIGEST
+
+path=./DMAcc/SampleServer/AppAuth/1/AAuthName
+isLeaf=true
+name=AAuthName
+format=chr
+type=text/plain
+title=
+acl=
+size=24
+version=1
+value=4lmq7z+KqXgva6EQuQmCTA==
+
+path=./DMAcc/SampleServer/AppAuth/1/AAuthSecret
+isLeaf=true
+name=AAuthSecret
+format=chr
+type=text/plain
+title=
+acl=
+size=24
+version=1
+value=tbME064FdtQlr+l9B7pFfA==
+
+path=./DMAcc/SampleServer/AppAuth/1/AAuthData
+isLeaf=true
+name=AAuthData
+format=chr
+type=text/plain
+title=
+acl=
+size=6
+version=0
+value=123abc
+
+path=./DMAcc/SampleServer/AppAuth/3
+isLeaf=false
+name=3
+format=node
+type=
+title=
+acl=
+size=0
+version=5
+children:AAuthLevel/AAuthType/AAuthName/AAuthSecret/AAuthData/
+
+path=./DMAcc/SampleServer/AppAuth/3/AAuthLevel
+isLeaf=true
+name=AAuthLevel
+format=chr
+type=text/plain
+title=
+acl=
+size=7
+version=0
+value=SRVCRED
+
+path=./DMAcc/SampleServer/AppAuth/3/AAuthType
+isLeaf=true
+name=AAuthType
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=BASIC
+
+path=./DMAcc/SampleServer/AppAuth/3/AAuthName
+isLeaf=true
+name=AAuthName
+format=chr
+type=text/plain
+title=
+acl=
+size=12
+version=0
+value=SampleServer
+
+path=./DMAcc/SampleServer/AppAuth/3/AAuthSecret
+isLeaf=true
+name=AAuthSecret
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=üéâäà
+
+path=./DMAcc/SampleServer/AppAuth/3/AAuthData
+isLeaf=true
+name=AAuthData
+format=chr
+type=text/plain
+title=
+acl=
+size=24
+version=0
+value=MTIzNDEyMzQxMjM0MTIzNA==
+
+
+]
+] Cmd: delete ./DMAcc/SampleServer
+node ./DMAcc/SampleServer deleted successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/SampleServer], [DELETE]
+Commit plug-in: OnCommit <END>
+
+]
+]
+]
+]
+] Cmd: Exec . ls
+execute path=. args=ls
+execute node . successfully, result=bin
+compile
+dmt_data
+lib
+plugins
+run_test
+settings
+src
+unittest
+
+
+]
+]
+]
+]
+]
+] Cmd: createi ./UnitTest/Profiles/1
+node ./UnitTest/Profiles/1 created successfully
+OnTreeSaved, parent uri ./UnitTest/Profiles
+
+] Cmd: createl ./UnitTest/Profiles/1/CurProfile 12
+Error! can't create a node ./UnitTest/Profiles/1/CurProfile, DmtException: 500
+
+] Cmd: createi ./UnitTest/Profiles/2
+node ./UnitTest/Profiles/2 created successfully
+OnTreeSaved, parent uri ./UnitTest/Profiles
+
+] Cmd: createl ./UnitTest/Profiles/2/CurProfile 12
+Error! can't create a node ./UnitTest/Profiles/2/CurProfile, DmtException: 500
+
+]
+] Cmd: createi ./DMAcc/12
+node ./DMAcc/12 created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/12], [ADD]
+Commit plug-in: OnCommit <END>
+
+] Cmd: createl ./DMAcc/12/ServerID some
+node ./DMAcc/12/ServerID (some) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/12/ServerID], [ADD]
+Commit plug-in: OnCommit <END>
+
+]
+] Cmd: createl ./UnitTest/Profiles/1/CurProfile 12
+node ./UnitTest/Profiles/1/CurProfile (12) created successfully
+Commit plug-in: OnCommit [profile]<START>
+notification for uri [./UnitTest/Profiles/1/CurProfile], [ADD]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles/1
+
+] Cmd: createl ./UnitTest/Profiles/2/CurProfile 12
+node ./UnitTest/Profiles/2/CurProfile (12) created successfully
+Commit plug-in: OnCommit [profile]<START>
+notification for uri [./UnitTest/Profiles/2/CurProfile], [ADD]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles/2
+
+]
+] Cmd: replace ./DMAcc/12/ServerID some3
+set value of node ./DMAcc/12/ServerID to some3 successfully
+path=./DMAcc/12/ServerID
+isLeaf=true
+name=ServerID
+format=chr
+type=text/plain
+title=
+acl=
+size=5
+version=1
+value=some3
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/12/ServerID], [REPLACE]
+Commit plug-in: OnCommit <END>
+Commit plug-in: OnCommit [profile]<START>
+notification for uri [./UnitTest/Profiles/1/CurProfile], [INDIRECT UPDATE]
+notification for uri [./UnitTest/Profiles/2/CurProfile], [INDIRECT UPDATE]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles/1
+OnTreeSaved, parent uri ./UnitTest/Profiles/2
+
+] Cmd: createl ./DMAcc/12/AppID some
+node ./DMAcc/12/AppID (some) created successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/12/AppID], [ADD]
+Commit plug-in: OnCommit <END>
+Commit plug-in: OnCommit [profile]<START>
+notification for uri [./UnitTest/Profiles/1/CurProfile], [INDIRECT UPDATE]
+notification for uri [./UnitTest/Profiles/2/CurProfile], [INDIRECT UPDATE]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles/1
+OnTreeSaved, parent uri ./UnitTest/Profiles/2
+
+]
+]
+] Cmd: delete ./DMAcc/12
+Error! can't delete node ./DMAcc/12, DmtException: 500
+
+]
+]
+] Cmd: delete ./UnitTest/Profiles/1
+node ./UnitTest/Profiles/1 deleted successfully
+Commit plug-in: OnCommit [profile]<START>
+notification for uri [./UnitTest/Profiles/1/CurProfile], [DELETE]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles
+
+] Cmd: delete ./UnitTest/Profiles/2
+node ./UnitTest/Profiles/2 deleted successfully
+Commit plug-in: OnCommit [profile]<START>
+notification for uri [./UnitTest/Profiles/2/CurProfile], [DELETE]
+Commit plug-in: OnCommit <END>
+OnTreeSaved, parent uri ./UnitTest/Profiles
+
+] Cmd: delete ./DMAcc/12
+node ./DMAcc/12 deleted successfully
+Commit plug-in: OnCommit [root]<START>
+notification for uri [./DMAcc/12], [DELETE]
+Commit plug-in: OnCommit <END>
+
+]
+]
+]
+]
+]
+] Cmd: createi ./UnitTest/NewDataType/MyApp
+node ./UnitTest/NewDataType/MyApp created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType
+
+]
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.2345e+3
+node ./UnitTest/NewDataType/MyApp/FloatLeaf (+1.2345e+3) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=10
+version=0
+value=+1.2345e+3
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+node ./UnitTest/NewDataType/MyApp/FloatLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -1.2345e+3
+node ./UnitTest/NewDataType/MyApp/FloatLeaf (-1.2345e+3) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=10
+version=0
+value=-1.2345e+3
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+node ./UnitTest/NewDataType/MyApp/FloatLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -1.2345e+03
+node ./UnitTest/NewDataType/MyApp/FloatLeaf (-1.2345e+03) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=11
+version=0
+value=-1.2345e+03
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+node ./UnitTest/NewDataType/MyApp/FloatLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -1.2345e-03
+node ./UnitTest/NewDataType/MyApp/FloatLeaf (-1.2345e-03) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=11
+version=0
+value=-1.2345e-03
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+node ./UnitTest/NewDataType/MyApp/FloatLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.456
+node ./UnitTest/NewDataType/MyApp/FloatLeaf (123.456) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=7
+version=0
+value=123.456
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+node ./UnitTest/NewDataType/MyApp/FloatLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -123.456
+node ./UnitTest/NewDataType/MyApp/FloatLeaf (-123.456) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=-123.456
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+node ./UnitTest/NewDataType/MyApp/FloatLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123
+node ./UnitTest/NewDataType/MyApp/FloatLeaf (123) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=3
+version=0
+value=123
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/FloatLeaf
+node ./UnitTest/NewDataType/MyApp/FloatLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 0
+node ./UnitTest/NewDataType/MyApp/FloatLeaf (0) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=1
+version=0
+value=0
+
+]
+]
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-15
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005-10-15) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=10
+version=0
+value=2005-10-15
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005-10) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=0
+value=2005-10
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-258
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005-258) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=2005-258
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-W12-5
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005-W12-5) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=10
+version=0
+value=2005-W12-5
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-W02
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005-W02) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=2005-W02
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 20050125
+node ./UnitTest/NewDataType/MyApp/DateLeaf (20050125) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=20050125
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 200502
+node ./UnitTest/NewDataType/MyApp/DateLeaf (200502) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=6
+version=0
+value=200502
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005016
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005016) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=0
+value=2005016
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=4
+version=0
+value=2005
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005W205
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005W205) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=2005W205
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/DateLeaf
+node ./UnitTest/NewDataType/MyApp/DateLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005W15
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005W15) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=0
+value=2005W15
+
+]
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15:25
+node ./UnitTest/NewDataType/MyApp/TimeLeaf (23:15:25) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=23:15:25
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+node ./UnitTest/NewDataType/MyApp/TimeLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15
+node ./UnitTest/NewDataType/MyApp/TimeLeaf (23:15) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=5
+version=0
+value=23:15
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+node ./UnitTest/NewDataType/MyApp/TimeLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 231525
+node ./UnitTest/NewDataType/MyApp/TimeLeaf (231525) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=6
+version=0
+value=231525
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+node ./UnitTest/NewDataType/MyApp/TimeLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 2315
+node ./UnitTest/NewDataType/MyApp/TimeLeaf (2315) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=4
+version=0
+value=2315
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+node ./UnitTest/NewDataType/MyApp/TimeLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23
+node ./UnitTest/NewDataType/MyApp/TimeLeaf (23) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=2
+version=0
+value=23
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+node ./UnitTest/NewDataType/MyApp/TimeLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15:25Z
+node ./UnitTest/NewDataType/MyApp/TimeLeaf (23:15:25Z) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=9
+version=0
+value=23:15:25Z
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+node ./UnitTest/NewDataType/MyApp/TimeLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15:59+01:20
+node ./UnitTest/NewDataType/MyApp/TimeLeaf (23:15:59+01:20) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=14
+version=0
+value=23:15:59+01:20
+
+] Cmd: delete ./UnitTest/NewDataType/MyApp/TimeLeaf
+node ./UnitTest/NewDataType/MyApp/TimeLeaf deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15:59-01:20
+node ./UnitTest/NewDataType/MyApp/TimeLeaf (23:15:59-01:20) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=14
+version=0
+value=23:15:59-01:20
+
+]
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf +3.2145e+3
+set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to +3.2145e+3 successfully
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=10
+version=1
+value=+3.2145e+3
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=10
+version=1
+value=+3.2145e+3
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf -3.2145e+3
+set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to -3.2145e+3 successfully
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=10
+version=2
+value=-3.2145e+3
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=10
+version=2
+value=-3.2145e+3
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf -3.2145e+03
+set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to -3.2145e+03 successfully
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=11
+version=3
+value=-3.2145e+03
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=11
+version=3
+value=-3.2145e+03
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf -3.2145e-03
+set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to -3.2145e-03 successfully
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=11
+version=4
+value=-3.2145e-03
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=11
+version=4
+value=-3.2145e-03
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf 103.456
+set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to 103.456 successfully
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=7
+version=5
+value=103.456
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=7
+version=5
+value=103.456
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf -103.456
+set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to -103.456 successfully
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=8
+version=6
+value=-103.456
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/FloatLeaf
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=8
+version=6
+value=-103.456
+
+]
+]
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-10-15
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2003-10-15 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=10
+version=1
+value=2003-10-15
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=10
+version=1
+value=2003-10-15
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-10
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2003-10 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=2
+value=2003-10
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=2
+value=2003-10
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-258
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2003-258 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=3
+value=2003-258
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=3
+value=2003-258
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-W12-5
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2003-W12-5 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=10
+version=4
+value=2003-W12-5
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=10
+version=4
+value=2003-W12-5
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003-W02
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2003-W02 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=5
+value=2003-W02
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=5
+value=2003-W02
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 20030125
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 20030125 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=6
+value=20030125
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=6
+value=20030125
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 200302
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 200302 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=6
+version=7
+value=200302
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=6
+version=7
+value=200302
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003016
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2003016 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=8
+value=2003016
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=8
+value=2003016
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2003 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=4
+version=9
+value=2003
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=4
+version=9
+value=2003
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003W205
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2003W205 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=10
+value=2003W205
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=8
+version=10
+value=2003W205
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2003W15
+set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2003W15 successfully
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=11
+value=2003W15
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/DateLeaf
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=11
+value=2003W15
+
+]
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15:25
+set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 03:15:25 successfully
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=8
+version=1
+value=03:15:25
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=8
+version=1
+value=03:15:25
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15
+set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 03:15 successfully
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=5
+version=2
+value=03:15
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=5
+version=2
+value=03:15
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 031525
+set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 031525 successfully
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=6
+version=3
+value=031525
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=6
+version=3
+value=031525
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 0315
+set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 0315 successfully
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=4
+version=4
+value=0315
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=4
+version=4
+value=0315
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03
+set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 03 successfully
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=2
+version=5
+value=03
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=2
+version=5
+value=03
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15:25Z
+set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 03:15:25Z successfully
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=9
+version=6
+value=03:15:25Z
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=9
+version=6
+value=03:15:25Z
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15:59+01:20
+set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 03:15:59+01:20 successfully
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=14
+version=7
+value=03:15:59+01:20
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=14
+version=7
+value=03:15:59+01:20
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 03:15:59-01:20
+set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 03:15:59-01:20 successfully
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=14
+version=8
+value=03:15:59-01:20
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: get ./UnitTest/NewDataType/MyApp/TimeLeaf
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=14
+version=8
+value=03:15:59-01:20
+
+]
+] Cmd: dump ./UnitTest/NewDataType/MyApp
+path=./UnitTest/NewDataType/MyApp
+isLeaf=false
+name=MyApp
+format=node
+type=
+title=
+acl=
+size=0
+version=51
+children:FloatLeaf/DateLeaf/TimeLeaf/
+
+path=./UnitTest/NewDataType/MyApp/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=8
+version=6
+value=-103.456
+
+path=./UnitTest/NewDataType/MyApp/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=7
+version=11
+value=2003W15
+
+path=./UnitTest/NewDataType/MyApp/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=14
+version=8
+value=03:15:59-01:20
+
+
+]
+] Cmd: dump ./TestRWPluginNode
+path=./TestRWPluginNode
+isLeaf=false
+name=TestRWPluginNode
+format=node
+type=text/plain
+title=
+acl=
+size=0
+version=0
+children:branch1/
+
+path=./TestRWPluginNode/branch1
+isLeaf=false
+name=branch1
+format=node
+type=text/plain
+title=
+acl=
+size=0
+version=0
+children:char/int/lob/lobbin/FloatLeaf/DateLeaf/TimeLeaf/
+
+path=./TestRWPluginNode/branch1/char
+isLeaf=true
+name=char
+format=chr
+type=text/plain
+title=
+acl=
+size=10
+version=0
+value=char_value
+
+path=./TestRWPluginNode/branch1/int
+isLeaf=true
+name=int
+format=int
+type=text/plain
+title=
+acl=
+size=4
+version=0
+value=1234
+
+path=./TestRWPluginNode/branch1/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+
+path=./TestRWPluginNode/branch1/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+
+path=./TestRWPluginNode/branch1/FloatLeaf
+isLeaf=true
+name=FloatLeaf
+format=float
+type=text/plain
+title=
+acl=
+size=11
+version=0
+value=-1.23456e+2
+
+path=./TestRWPluginNode/branch1/DateLeaf
+isLeaf=true
+name=DateLeaf
+format=date
+type=text/plain
+title=
+acl=
+size=10
+version=0
+value=2005-10-18
+
+path=./TestRWPluginNode/branch1/TimeLeaf
+isLeaf=true
+name=TimeLeaf
+format=time
+type=text/plain
+title=
+acl=
+size=8
+version=0
+value=11:38:58
+
+
+]
+] Cmd: processscript unittest/dm12/testnewdatatype.xml
+Process WBXML script: false
+Read 3158 bytes
+The test Script error code 0; text:
+
+<?xml version="1.0" encoding="UTF-8"?><SyncML xmlns='SYNCML:SYNCML1.2'><SyncHdr><VerDTD>1.2</VerDTD><VerProto>DM/1.2</VerProto><SessionID>18629</SessionID><MsgID>1</MsgID><Target><LocURI>http://10.72.35.166/Scts?YDjHAA==</LocURI></Target><Source><LocURI>000000011234564</LocURI></Source><Meta><MaxMsgSize xmlns='syncml:metinf'>20000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Add</Cmd><TargetRef>./Test/MyApp</TargetRef><Data>405</Data></Status><Status><CmdID>2</CmdID><MsgRef>1</MsgRef><CmdRef>2</CmdRef><Cmd>Add</Cmd><TargetRef>./Test/MyApp/FloatLeaf</TargetRef><Data>405</Data></Status><Status><CmdID>3</CmdID><MsgRef>1</MsgRef><CmdRef>3</CmdRef><Cmd>Add</Cmd><TargetRef>./Test/MyApp/DateLeaf</TargetRef><Data>405</Data></Status><Status><CmdID>4</CmdID><MsgRef>1</MsgRef><CmdRef>4</CmdRef><Cmd>Add</Cmd><TargetRef>./Test/MyApp/TimeLeaf</TargetRef><Data>405</Data></Status><Status><CmdID>5</CmdID><MsgRef>1</MsgRef><CmdRef>5</CmdRef><Cmd>Replace</Cmd><TargetRef>./Test/MyApp/FloatLeaf</TargetRef><Data>404</Data></Status><Status><CmdID>6</CmdID><MsgRef>1</MsgRef><CmdRef>6</CmdRef><Cmd>Replace</Cmd><TargetRef>./Test/MyApp/DateLeaf</TargetRef><Data>404</Data></Status><Status><CmdID>7</CmdID><MsgRef>1</MsgRef><CmdRef>7</CmdRef><Cmd>Replace</Cmd><TargetRef>./Test/MyApp/TimeLeaf</TargetRef><Data>404</Data></Status><Status><CmdID>8</CmdID><MsgRef>1</MsgRef><CmdRef>8</CmdRef><Cmd>Get</Cmd><TargetRef>./Test/MyApp/FloatLeaf</TargetRef><Data>404</Data></Status><Status><CmdID>9</CmdID><MsgRef>1</MsgRef><CmdRef>9</CmdRef><Cmd>Get</Cmd><TargetRef>./Test/MyApp/DateLeaf</TargetRef><Data>404</Data></Status><Status><CmdID>10</CmdID><MsgRef>1</MsgRef><CmdRef>10</CmdRef><Cmd>Get</Cmd><TargetRef>./Test/MyApp/TimeLeaf</TargetRef><Data>404</Data></Status><Status><CmdID>11</CmdID><MsgRef>1</MsgRef><CmdRef>11</CmdRef><Cmd>Delete</Cmd><TargetRef>./Test/MyApp/FloatLeaf</TargetRef><Data>404</Data></Status><Status><CmdID>12</CmdID><MsgRef>1</MsgRef><CmdRef>12</CmdRef><Cmd>Delete</Cmd><TargetRef>./Test/MyApp/DateLeaf</TargetRef><Data>404</Data></Status><Status><CmdID>13</CmdID><MsgRef>1</MsgRef><CmdRef>13</CmdRef><Cmd>Delete</Cmd><TargetRef>./Test/MyApp/TimeLeaf</TargetRef><Data>404</Data></Status><Status><CmdID>14</CmdID><MsgRef>1</MsgRef><CmdRef>14</CmdRef><Cmd>Delete</Cmd><TargetRef>./Test/MyApp</TargetRef><Data>404</Data></Status><Final/></SyncBody></SyncML>
+
+
+]
+] Cmd: delete ./UnitTest/NewDataType/MyApp
+node ./UnitTest/NewDataType/MyApp deleted successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType
+
+]
+]
+]
+]
+] Cmd: createi ./UnitTest/NewDataType/MyApp
+node ./UnitTest/NewDataType/MyApp created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType
+
+]
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45+
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45-
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45E
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45e
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 1+1
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 1-1
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1+1
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -1+1
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf -
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf E
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf e
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf .
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45.5
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45a
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf ++123.5
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf --1234.5
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.3e_5
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.23.45e+5-5
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf 1s23.45
+Error! can't create a node ./UnitTest/NewDataType/MyApp/FloatLeaf, DmtException: 415
+
+]
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-1-10
+Error! can't create a node ./UnitTest/NewDataType/MyApp/DateLeaf, DmtException: 415
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-00-10
+Error! can't create a node ./UnitTest/NewDataType/MyApp/DateLeaf, DmtException: 415
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-00
+Error! can't create a node ./UnitTest/NewDataType/MyApp/DateLeaf, DmtException: 415
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-00-30
+Error! can't create a node ./UnitTest/NewDataType/MyApp/DateLeaf, DmtException: 415
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-32
+Error! can't create a node ./UnitTest/NewDataType/MyApp/DateLeaf, DmtException: 415
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 24:03
+Error! can't create a node ./UnitTest/NewDataType/MyApp/TimeLeaf, DmtException: 415
+
+]
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 5:63
+Error! can't create a node ./UnitTest/NewDataType/MyApp/TimeLeaf, DmtException: 415
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:63
+Error! can't create a node ./UnitTest/NewDataType/MyApp/TimeLeaf, DmtException: 415
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:63:01
+Error! can't create a node ./UnitTest/NewDataType/MyApp/TimeLeaf, DmtException: 415
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+01
+Error! can't create a node ./UnitTest/NewDataType/MyApp/TimeLeaf, DmtException: 415
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+01:52:23
+Error! can't create a node ./UnitTest/NewDataType/MyApp/TimeLeaf, DmtException: 415
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30-01:52:23
+Error! can't create a node ./UnitTest/NewDataType/MyApp/TimeLeaf, DmtException: 415
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+0152
+Error! can't create a node ./UnitTest/NewDataType/MyApp/TimeLeaf, DmtException: 415
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+0152Z
+Error! can't create a node ./UnitTest/NewDataType/MyApp/TimeLeaf, DmtException: 415
+
+]
+]
+] Cmd: createlf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.2345e+3
+node ./UnitTest/NewDataType/MyApp/FloatLeaf (+1.2345e+3) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createld ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-15
+node ./UnitTest/NewDataType/MyApp/DateLeaf (2005-10-15) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+] Cmd: createlt ./UnitTest/NewDataType/MyApp/TimeLeaf 23:15
+node ./UnitTest/NewDataType/MyApp/TimeLeaf (23:15) created successfully
+OnTreeSaved, parent uri ./UnitTest/NewDataType/MyApp
+
+]
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45.5
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to 123.45.5, DmtException: 415
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf 123.45a
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to 123.45a, DmtException: 415
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf ++123.5
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to ++123.5, DmtException: 415
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf --1234.5
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to --1234.5, DmtException: 415
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.3e_5
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to +1.3e_5, DmtException: 415
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf +1.23.45e+5-5
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to +1.23.45e+5-5, DmtException: 415
+
+] Cmd: setf ./UnitTest/NewDataType/MyApp/FloatLeaf 1s23.45
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/FloatLeaf to 1s23.45, DmtException: 415
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-1-10
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2005-1-10, DmtException: 415
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-00-10
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2005-00-10, DmtException: 415
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-00
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2005-10-00, DmtException: 415
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-00-30
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2005-00-30, DmtException: 415
+
+] Cmd: setd ./UnitTest/NewDataType/MyApp/DateLeaf 2005-10-32
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/DateLeaf to 2005-10-32, DmtException: 415
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 24:03
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 24:03, DmtException: 415
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 5:63
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 5:63, DmtException: 415
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:63
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 23:63, DmtException: 415
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:63:01
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 23:63:01, DmtException: 415
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+01
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 23:33:30+01, DmtException: 415
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+01:52:23
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 23:33:30+01:52:23, DmtException: 415
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30-01:52:23
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 23:33:30-01:52:23, DmtException: 415
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+0152
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 23:33:30+0152, DmtException: 415
+
+] Cmd: sett ./UnitTest/NewDataType/MyApp/TimeLeaf 23:33:30+0152Z
+Error! can't set value of node ./UnitTest/NewDataType/MyApp/TimeLeaf to 23:33:30+0152Z, DmtException: 415
+
+]
+]
+]
+]
+] Cmd: createl ./TEST/lob
+node ./TEST/lob () created successfully
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: setESN ./TEST/lob unittest/dm12/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: get ./TEST/lob
+path=./TEST/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=11
+version=2
+value=
+0123456789
+
+
+
+]
+]
+]
+]
+]
+] Cmd: setESN ./TEST/lob unittest/dm12/testlobdata2.dat
+read 27 bytes
+abcdefghijklmnopqrstunwxyz
+
+
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: get ./TEST/lob
+path=./TEST/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=27
+version=4
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+] Cmd: delete ./CLONE
+node ./CLONE deleted successfully
+OnTreeSaved, parent uri .
+
+] Cmd: clone ./TEST CLONE
+clone ./TEST to CLONE successfully
+OnTreeSaved, parent uri .
+OnTreeSaved, parent uri ./CLONE
+
+] Cmd: get ./CLONE/lob
+path=./CLONE/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=27
+version=2
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+]
+] Cmd: delete ./TEST/lob
+node ./TEST/lob deleted successfully
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: delete ./CLONE/lob
+node ./CLONE/lob deleted successfully
+OnTreeSaved, parent uri ./CLONE
+
+] Cmd: get ./TEST/lob
+Error! can't get node ./TEST/lob, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createl ./TEST/lob
+node ./TEST/lob () created successfully
+
+] Cmd: setESN ./TEST/lob unittest/dm12/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+] Cmd: get ./TEST/lob
+Error! can't get node ./TEST/lob, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: createlb ./TEST/lobbin
+node ./TEST/lobbin () created successfully
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: setESN ./TEST/lob unittest/dm12/testlobdata1.dat
+read 11 bytes
+Error! can't get node ./TEST/lob, DmtException: 404
+
+] Cmd: get ./TEST/lobbin
+path=./TEST/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=0
+version=0
+value=
+
+
+]
+]
+]
+]
+]
+] Cmd: setESN ./TEST/lobbin unittest/dm12/testlobdata2.dat
+read 27 bytes
+abcdefghijklmnopqrstunwxyz
+
+
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: get ./TEST/lobbin
+path=./TEST/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=27
+version=2
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+] Cmd: delete ./CLONE
+node ./CLONE deleted successfully
+OnTreeSaved, parent uri .
+
+] Cmd: clone ./TEST CLONE
+clone ./TEST to CLONE successfully
+OnTreeSaved, parent uri .
+OnTreeSaved, parent uri ./CLONE
+
+] Cmd: get ./CLONE/lobbin
+path=./CLONE/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=27
+version=2
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+]
+] Cmd: delete ./TEST/lobbin
+node ./TEST/lobbin deleted successfully
+OnTreeSaved, parent uri ./TEST
+
+] Cmd: delete ./CLONE/lobbin
+node ./CLONE/lobbin deleted successfully
+OnTreeSaved, parent uri ./CLONE
+
+] Cmd: get ./TEST/lobbin
+Error! can't get node ./TEST/lobbin, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createlb ./TEST/lobbin
+node ./TEST/lobbin () created successfully
+
+] Cmd: setESN ./TEST/lobbin unittest/dm12/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+] Cmd: get ./TEST/lobbin
+Error! can't get node ./TEST/lobbin, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: delete ./TestRWPluginNode/branch1/lob
+node ./TestRWPluginNode/branch1/lob deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: createl ./TestRWPluginNode/branch1/lob
+node ./TestRWPluginNode/branch1/lob () created successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: setESN ./TestRWPluginNode/branch1/lob unittest/dm12/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/branch1/lob
+path=./TestRWPluginNode/branch1/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=11
+version=0
+value=
+0123456789
+
+
+
+]
+]
+]
+]
+]
+] Cmd: setESN ./TestRWPluginNode/branch1/lob unittest/dm12/testlobdata2.dat
+read 27 bytes
+abcdefghijklmnopqrstunwxyz
+
+
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/branch1/lob
+path=./TestRWPluginNode/branch1/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=27
+version=0
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+] Cmd: delete ./TestRWPluginNode/branch1/lobbin
+node ./TestRWPluginNode/branch1/lobbin deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: createlb ./TestRWPluginNode/branch1/lobbin
+node ./TestRWPluginNode/branch1/lobbin () created successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: setESN ./TestRWPluginNode/branch1/lobbin unittest/dm12/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/branch1/lobbin
+path=./TestRWPluginNode/branch1/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=11
+version=0
+value=
+0123456789
+
+
+
+]
+]
+]
+]
+]
+] Cmd: setESN ./TestRWPluginNode/branch1/lobbin unittest/dm12/testlobdata2.dat
+read 27 bytes
+abcdefghijklmnopqrstunwxyz
+
+
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/branch1/lobbin
+path=./TestRWPluginNode/branch1/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=27
+version=0
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+]
+] Cmd: delete ./TestRWPluginNode/clone
+Error! can't delete node ./TestRWPluginNode/clone, DmtException: 404
+
+] Cmd: clone ./TestRWPluginNode/branch1 clone
+clone ./TestRWPluginNode/branch1 to clone successfully
+OnTreeSaved, parent uri ./TestRWPluginNode
+OnTreeSaved, parent uri ./TestRWPluginNode/clone
+
+] Cmd: get ./TestRWPluginNode/clone/lob
+path=./TestRWPluginNode/clone/lob
+isLeaf=true
+name=lob
+format=chr
+type=text/plain
+title=
+acl=
+size=27
+version=0
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+] Cmd: get ./TestRWPluginNode/clone/lobbin
+path=./TestRWPluginNode/clone/lobbin
+isLeaf=true
+name=lobbin
+format=bin
+type=text/plain
+title=
+acl=
+size=27
+version=0
+value=
+abcdefghijklmnopqrstunwxyz
+
+
+
+]
+]
+]
+]
+]
+] Cmd: delete ./TestRWPluginNode/clone
+node ./TestRWPluginNode/clone deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode
+
+] Cmd: delete ./TestRWPluginNode/branch1/lob
+node ./TestRWPluginNode/branch1/lob deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: delete ./TestRWPluginNode/branch1/lobbin
+node ./TestRWPluginNode/branch1/lobbin deleted successfully
+OnTreeSaved, parent uri ./TestRWPluginNode/branch1
+
+] Cmd: get ./TestRWPluginNode/clone/lobbin
+Error! can't get node ./TestRWPluginNode/clone/lobbin, DmtException: 404
+
+] Cmd: get ./TestRWPluginNode/branch1/lob
+Error! can't get node ./TestRWPluginNode/branch1/lob, DmtException: 404
+
+] Cmd: get ./TestRWPluginNode/branch1/lobbin
+Error! can't get node ./TestRWPluginNode/branch1/lobbin, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createl ./TestRWPluginNode/branch1/lob
+node ./TestRWPluginNode/branch1/lob () created successfully
+
+] Cmd: setESN ./TestRWPluginNode/branch1/lob unittest/dm12/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+] Cmd: get ./TestRWPluginNode/branch1/lob
+Error! can't get node ./TestRWPluginNode/branch1/lob, DmtException: 404
+
+]
+]
+]
+]
+] Cmd: begin
+begin an atomic operation successfully
+
+] Cmd: createlb ./TestRWPluginNode/branch1/lobbin
+node ./TestRWPluginNode/branch1/lobbin () created successfully
+
+] Cmd: setESN ./TestRWPluginNode/branch1/lobbin unittest/dm12/testlobdata1.dat
+read 11 bytes
+0123456789
+
+
+
+] Cmd: rollback
+rollback atomic operations successfully
+
+] Cmd: get ./TestRWPluginNode/branch1/lobbin
+Error! can't get node ./TestRWPluginNode/branch1/lobbin, DmtException: 404
+
+]
+] Cmd: getCounter
+Number of tested cases: 503
+
+]
+] Cmd: quit
diff --git a/engine/dmlib/linux_java/test/dm12/testreplace.wbxml b/engine/dmlib/linux_java/test/dm12/testreplace.wbxml
new file mode 100644
index 0000000..f257592
--- /dev/null
+++ b/engine/dmlib/linux_java/test/dm12/testreplace.wbxml
Binary files differ
diff --git a/engine/dmlib/notification_agent/hdr/dmNotification.h b/engine/dmlib/notification_agent/hdr/dmNotification.h
new file mode 100644
index 0000000..b3e73b2
--- /dev/null
+++ b/engine/dmlib/notification_agent/hdr/dmNotification.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DM_NOTIFICATION_H_INCLUDED
+#define _DM_NOTIFICATION_H_INCLUDED
+
+/*==================================================================================================
+
+ Header Name: dmNotification.h
+
+ General Description: Declaration of notification agent (parsing package0) .
+
+==================================================================================================*/
+
+#include "dmtNotification.hpp"
+
+SYNCML_DM_RET_STATUS_T DmProcessNotification(const UINT8 *pk0Data,
+ UINT32 pk0Size,
+ DmtNotification & notification);
+
+#endif /* _DM_NOTIFICATION_H_INCLUDED */
diff --git a/engine/dmlib/notification_agent/src/dmNotification.cc b/engine/dmlib/notification_agent/src/dmNotification.cc
new file mode 100644
index 0000000..bf6fd42
--- /dev/null
+++ b/engine/dmlib/notification_agent/src/dmNotification.cc
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmNotification.cc
+
+ General Description: Implementation of the notification agent interface
+
+==================================================================================================*/
+
+#include "dmt.hpp"
+#include "dmStringUtil.h"
+#include "dmNotification.h"
+#include "dmSessionFactory.h"
+#include "xpl_Logger.h"
+
+/*==============================================================================================
+Function: dmProcessNotification
+
+Description: This method is called to parse out the individual bits from the received Package0
+ and store their values into the defined structure.
+ This method will also allocate memory as needed for the string values.
+
+NOTE: To simplify the logic of this method, it has knowledge of the various bit-field sizes. So
+ if the Spec ever changes the bit-field sizes or order of Package0, this method must be
+ updated. Using #defines for the various bit-field sizes would greatly increase the
+ complexity of this method and make it more difficult to maintain.
+
+==============================================================================================*/
+SYNCML_DM_RET_STATUS_T
+DmProcessNotification(const UINT8 *pk0Data,
+ UINT32 pk0Size,
+ DmtNotification & notification)
+{
+ UINT8 *pCurrData;
+ UINT8 *pTrigger;
+ UINT8 triggerLen;
+ UINT16 tempData16;
+ UINT8 serverIdLen;
+ UINT32 usedSize;
+ UINT8 md5Digest[DM_MD5_DIGEST_LENGTH];
+ DMBuffer vendorData;
+ char server_data[24];
+
+ SYNCML_DM_RET_STATUS_T retStatus = SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_SESS_Debug(("DMProcessNotification Enter\n"));
+
+ // The Package0 MUST have at least 192 bits(24 Bytes) for this function to avoid bus errors.
+ if (pk0Size < 24)
+ {
+ return (SYNCML_DM_FAIL);
+ }
+
+ // Start the current data pointer.
+ pCurrData = (UINT8*)pk0Data;
+
+ // The MD5 (HMAC) digest is 128 bits(16 Bytes).
+ memcpy(md5Digest, pCurrData, DM_MD5_DIGEST_LENGTH);
+ pCurrData = pCurrData + DM_MD5_DIGEST_LENGTH;
+
+ // Save off the rest of the Pk0 since this is the Trigger portion used for the Digest.
+ pTrigger = pCurrData;
+ triggerLen = pk0Size - DM_MD5_DIGEST_LENGTH;
+
+ // Grab the next 16 bits being careful to avoid endian problems.
+ tempData16 = (pCurrData[0] << 8) | (pCurrData[1]);
+ pCurrData = pCurrData + 2;
+
+ // The DM Version is the top 10 bits.
+ // DM: initialized but never used warning by ARM compiler
+ // dmVersion = ((tempData16 & 0xFFC0) >> 6);
+
+ // The UI Mode is the next 2 bits.
+ notification.setUIMode((UINT8)((tempData16 & 0x0030) >> 4));
+
+ // The Initiator is the next 1 bit.
+ notification.setInitiator((UINT8)((tempData16 & 0x0008) >> 3));
+
+
+ // The Future Reserved is 27 bits. 3 of those bits are in tempData16. So skip 24 bits.
+ pCurrData = pCurrData + 3;
+
+ // The SessionID is 16 bits being careful to avoid endian problems.
+ tempData16 = (pCurrData[0] << 8) | (pCurrData[1]);
+ pCurrData = pCurrData + 2;
+ notification.setSessionID(tempData16);
+
+ // The ServerID Length is 8 bits.
+ serverIdLen = *pCurrData;
+ pCurrData = pCurrData + 1;
+
+
+ if (serverIdLen > 0 && serverIdLen < sizeof(server_data))
+ {
+ // The ServerID string is <length>*8 bits.
+ memcpy(server_data, pCurrData, serverIdLen);
+ server_data[serverIdLen] = '\0';
+ notification.setServerID(server_data);
+ pCurrData = pCurrData + serverIdLen;
+ }
+ else
+ return SYNCML_DM_FAIL;
+
+
+ // Calculate the amount of data we've read so far.
+ usedSize = pCurrData - pk0Data;
+
+ // The Vendor Specific portion is n bits. Check if there is anything left in the buffer.
+ if (pk0Size > usedSize)
+ {
+ // There's still information left. Copy it into the pVendorData.
+ vendorData.assign(pCurrData, pk0Size - usedSize);
+ if ( vendorData.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ SYNCML_DM_AuthContext_T AuthContext;
+
+ AuthContext._AuthFlag = TRUE;
+ AuthContext._pServerId = server_data;
+ AuthContext._md5Digest = md5Digest;
+ AuthContext._pTrigger = pTrigger;
+ AuthContext._triggerLen = triggerLen;
+
+#ifndef DM_NOTIFICATION_AGENT_NO_AUTH
+ retStatus = DmAuthenticateServer( AuthContext );
+#endif
+
+ notification.setAuthFlag( AuthContext._AuthFlag );
+ XPL_LOG_DM_SESS_Debug(("DMProcessNotification Exit\n"));
+ return retStatus;
+}
diff --git a/engine/dmlib/plugin/hdr/SyncML_PlugIn_Log.H b/engine/dmlib/plugin/hdr/SyncML_PlugIn_Log.H
new file mode 100644
index 0000000..b66f7d2
--- /dev/null
+++ b/engine/dmlib/plugin/hdr/SyncML_PlugIn_Log.H
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_PlugIn_Log_H
+#define SYNCML_PlugIn_Log_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+ Header Name: SyncML_PlugIn_Log.H
+
+ General Description: This class provides an ABC (Abstract Base Class) for concrete
+ implementations of a SyncML_PlugIn_Log.
+
+==================================================================================================*/
+
+#include "syncml_dm_data_types.h"
+#include "dmMemory.h"
+#include "SyncML_DM_Reader.H"
+#include "SyncML_DM_Writer.H"
+#include "SyncML_DM_FileHandle.H"
+
+class DmtNode;
+class DMFileHandler;
+
+/*==================================================================================================
+CLASS DECLARATION
+==================================================================================================*/
+class SyncML_PlugIn_Log
+{
+ public:
+ /* Class constructor */
+ SyncML_PlugIn_Log();
+
+ /* Class destructor */
+ virtual ~SyncML_PlugIn_Log();
+
+ /* Method for logging a command into the log entity represented by the
+ * concrete implementation of this class.
+ */
+ virtual SYNCML_DM_RET_STATUS_T logCommand(SYNCML_DM_PLUGIN_COMMAND_T commandType,
+ CPCHAR pbURI,
+ SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T attribute,
+ const DmtNode* inNode) = 0;
+
+ /* Take each entry in the log file and play it on the tree (by passing to
+ * the tree and node manager) according to logic based on flags in the log entry
+ */
+ virtual SYNCML_DM_RET_STATUS_T playLog() = 0;
+
+ /* Accessors for the file handle associated with this log */
+ virtual DMFileHandler* getLogFileHandle();
+ virtual void setLogFileHandle(DMFileHandler *fileHandle);
+
+ inline void* operator new(size_t sz)
+ {
+ return (DmAllocMem(sz));
+ }
+
+ inline void operator delete(void* buf)
+ {
+ DmFreeMem(buf);
+ }
+
+ protected:
+ DMFileHandler *fileHandle;
+
+};
+
+#endif /* SYNCML_PlugIn_Log_H */
diff --git a/engine/dmlib/plugin/hdr/SyncML_PlugIn_WBXMLLog.H b/engine/dmlib/plugin/hdr/SyncML_PlugIn_WBXMLLog.H
new file mode 100644
index 0000000..8ddec40
--- /dev/null
+++ b/engine/dmlib/plugin/hdr/SyncML_PlugIn_WBXMLLog.H
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_PlugIn_WBXMLLog_H
+#define SYNCML_PlugIn_WBXMLLog_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "SyncML_DM_Archive.H"
+#include "SyncML_DM_WBXMLWriter.H"
+#include "SyncML_DM_WBXMLReader.H"
+#include "SyncML_Log.H"
+#include "dmt.hpp"
+
+#include "dmtRWPlugin.hpp"
+
+class SyncML_PlugIn_WBXMLLog : public SyncML_Log
+{
+
+ public:
+
+ /* Class constructor */
+ SyncML_PlugIn_WBXMLLog(const DmtRWPluginTree *pluginTree, CPCHAR rootPath);
+
+ /* Class destructor */
+ virtual ~SyncML_PlugIn_WBXMLLog();
+
+ // Open log file and create one if the file doesn't exist
+ SYNCML_DM_RET_STATUS_T InitLog(CPCHAR logFileName);
+ // Uninitialize log
+ SYNCML_DM_RET_STATUS_T UnInitLog();
+ /* Log one command */
+ SYNCML_DM_RET_STATUS_T logCommand(SYNCML_DM_PLUGIN_COMMAND_T commandType,
+ CPCHAR pbURI,
+ SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T attribute,
+ const DmtNode* inNode);
+
+ /* Playback log file */
+ SYNCML_DM_RET_STATUS_T playLog();
+ SYNCML_DM_RET_STATUS_T playLog(CPCHAR logFileName);
+
+
+ private:
+
+ /* Performs the actual recovery function calls */
+ SYNCML_DM_RET_STATUS_T playbackOneRecord(SYNCML_DM_PLUGIN_COMMAND_T commandType,
+ CPCHAR pbURI,
+ SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T attribute,
+ DMAddNodeProp* props);
+
+ SYNCML_DM_RET_STATUS_T gotoLastRecord(SyncML_DM_WBXMLReader* reader,
+ UINT8 *lastByte,
+ INT32 *currentPos );
+
+ SYNCML_DM_RET_STATUS_T writeLogHeader(SyncML_DM_WBXMLWriter* writer);
+ SYNCML_DM_RET_STATUS_T writeURIInfo(SYNCML_DM_PLUGIN_COMMAND_T commandType,
+ CPCHAR pbURI,
+ SyncML_DM_WBXMLWriter* writer);
+
+ SYNCML_DM_RET_STATUS_T writePluginNode(CPCHAR pbURI,
+ SyncML_DM_WBXMLWriter* writer,
+ const DmtNode* ptrNode);
+
+ SYNCML_DM_RET_STATUS_T updatePosition(SyncML_DM_WBXMLWriter* writer);
+
+ DMString m_strRootPath;
+ INT32 prevRecord;
+ const DmtRWPluginTree *pluginTree;
+ SyncML_DM_WBXMLWriter* writer;
+ SyncML_DM_WBXMLReader* reader;
+
+};
+
+#endif /* SYNCML_PlugIn_WBXMLLog_H */
diff --git a/engine/dmlib/plugin/hdr/dmPlugin.h b/engine/dmlib/plugin/hdr/dmPlugin.h
new file mode 100644
index 0000000..e50769b
--- /dev/null
+++ b/engine/dmlib/plugin/hdr/dmPlugin.h
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMPLUGIN_H
+#define DMPLUGIN_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmPlugin.h
+
+General Description: This file contains the declaration of DMPlugin.
+
+==================================================================================================*/
+
+#include "dmt.hpp"
+#include "xpl_dm_Manager.h"
+#include "dmtPlugin.hpp"
+#include "dmtEventData.hpp"
+#include "xpl_Lib.h"
+#include "xpl_Time.h"
+#include "dmEventSubscription.h"
+
+#define PLUGIN_DATA_NAME "_data"
+#define PLUGIN_DATA_OVERLAY_NAME "_dataExt"
+#define PLUGIN_EXECUTE_NAME "_exec"
+#define PLUGIN_CONSTRAINT_NAME "_const"
+#define PLUGIN_COMMIT_NAME "_commit"
+
+enum
+{
+ SYNCML_DM_UNKNOWN_PLUGIN = 0,
+ SYNCML_DM_DATA_PLUGIN = 1, //Can be ORed
+ SYNCML_DM_EXECUTE_PLUGIN = 2,
+ SYNCML_DM_CONSTRAINT_PLUGIN = 4,
+ SYNCML_DM_COMMIT_PLUGIN = 8
+};
+typedef UINT8 SYNCML_DM_PLUGIN_TYPE_T;
+
+#define MAX_PLUGINTYPES 4
+
+
+/**
+ * Represents a basic class for all plug-ins managed by Plugin Manager.
+ */
+class DMPlugin: public DMEventSubscription, public JemBaseObject
+{
+ public:
+ /**
+ * Constructor that initializes plug-in object
+ * \param type [in] - type of a plug-in
+ * \param bOverlayPlugin [in] - specifies if data plug-in as an overlay one
+ * \param path [in] - plug-in root path (mounting point)
+ * \param aParameters [in] - plug-in parameters from config file
+ */
+ DMPlugin(SYNCML_DM_PLUGIN_TYPE_T type,
+ BOOLEAN bOverlayPlugin,
+ const DMString & path,
+ DMStringMap & aParameters);
+
+ /**
+ * Destructor
+ */
+ virtual ~DMPlugin();
+
+ /**
+ * Retrieves a plug-in type
+ * \return Return Type (SYNCML_DM_PLUGIN_TYPE_T)
+ */
+ SYNCML_DM_PLUGIN_TYPE_T GetPluginType() const { return m_type; }
+
+ /**
+ * Verifies if plugin is an overlay plug-in
+ * \return TRUE if it is an overlay plug-in
+ */
+ BOOLEAN IsOveralyPlugin() const { return m_bOverlayPlugin; }
+
+ /**
+ * Retrieves a plug-in root path
+ * \return Return Type (DMString &)
+ */
+ const DMString & GetPath() const { return m_strPath; }
+
+ /**
+ * Retrieves plug-in parameters
+ * \return Return Type (DMStringMap &)
+ */
+ const DMStringMap & GetParameters() const { return m_mapParameters; }
+
+ /**
+ * Retrieves a plug-in tree for data plug-in
+ * \param szPath [in] - root path of plug-in tree
+ * \param pTree [out] - plug-in tree created in the plug-in
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T GetTree(CPCHAR szPath,
+ PDmtAPIPluginTree & pTree);
+
+ /**
+ * Verifies if plug-in tree is empty
+ * \return TRUE if is empty
+ */
+ BOOLEAN IsTreeEmpty() { return ((m_pTree==NULL) ?TRUE:FALSE); }
+
+ /**
+ * Performs "Execute" command on a plug-in node
+ * \param szPath [in] - node path
+ * \param szArgs [in] - exec plug-in arguments
+ * \param szCorrelator [in] - correlator
+ * \param pTree [in] - current DM session tree
+ * \param results [out] - result of execute plug-in
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Execute(CPCHAR szPath,
+ CPCHAR szArgs,
+ CPCHAR szCorrelator,
+ PDmtTree pTree,
+ DMString& results);
+
+
+ /**
+ * Checks constraints on sub tree
+ * \param szPath [in] - root path of a sub tree
+ * \param pTree [in] - current DM session tree
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T CheckConstraint(CPCHAR szPath,
+ PDmtTree pTree);
+
+ /**
+ * Notifies about changes in the DM tree
+ * \param szPath [in] - root path of a sub tree
+ * \param pTree [in] - current DM session tree
+ */
+ void OnCommit(const DmtEventMap &aUpdatedNodes,
+ PDmtTree pTree);
+
+
+ /**
+ * Releases data plug-in tree and resets values of an object
+ */
+ void UnloadSymbols();
+
+ /**
+ * Verifies if any shared libraries are loaded
+ * \return TRUE if shared libs are loaded
+ */
+ BOOLEAN IsSymbolsLoaded();
+
+ /**
+ * Verifies if handler on specified shared library is realeased
+ * \param handler [in] - shared library handler
+ * \return TRUE if released
+ */
+ BOOLEAN IsLibReleased(XPL_DL_HANDLE_T handler);
+
+ /**
+ * Retrieves plug-in last accessed time
+ * \return Return Type (XPL_CLK_CLOCK_T)
+ */
+ XPL_CLK_CLOCK_T GetLastAccessedTime();
+
+private:
+ /* Plug-in root path */
+ DMString m_strPath;
+ /* Parameters from config file */
+ DMStringMap m_mapParameters;
+
+ /* Dynamic library handler for data plug-in */
+ XPL_DL_HANDLE_T m_hLibData;
+ /* Dynamic library handler for exec plug-in */
+ XPL_DL_HANDLE_T m_hLibExec;
+ /* Dynamic library handler for constraint plug-in */
+ XPL_DL_HANDLE_T m_hLibConstraint;
+ /* Dynamic library handler for commit plug-in */
+ XPL_DL_HANDLE_T m_hLibCommit;
+
+ /* Plug-in tree */
+ PDmtAPIPluginTree m_pTree;
+
+ /* Pointer on exported function that retrieves plug-in tree */
+ SYNCML_DM_RET_STATUS_T (* pfGetTree) (CPCHAR szPath,
+ DMStringMap & mapParameters,
+ PDmtAPIPluginTree & pPluginTree);
+
+ /* Pointer on exported function that performs "Execute" command on a plug-in node */
+ SYNCML_DM_RET_STATUS_T (* pfExecute2) (CPCHAR szPath,
+ DMStringMap & mapParameters,
+ CPCHAR szArgs,
+ CPCHAR szCorrelator,
+ PDmtTree pTree,
+ DMString & results);
+
+ /* Pointer on exported function that checks constraints */
+ SYNCML_DM_RET_STATUS_T (* pfCheckConstraint) (CPCHAR szPath,
+ DMStringMap & mapParameters,
+ PDmtTree pTree);
+
+ /* Pointer on exported function that inform about DMT updates */
+ void (*pfOnCommit) (const DmtEventMap &aUpdatedNodes,
+ DMStringMap& mapParameters,
+ PDmtTree pTree);
+
+ /* Last accessed time */
+ XPL_CLK_CLOCK_T m_lastAccessedTime;
+ /* Plug-in type */
+ SYNCML_DM_PLUGIN_TYPE_T m_type;
+ /* Specifies if plug-in is an overlay */
+ BOOLEAN m_bOverlayPlugin;
+
+
+ /**
+ * Loads dynamic library and retrieves pointer on plug-in fuction
+ * \param szType [in] - suffix for the type of plug-in
+ * \param szName [in] - name of exported function
+ * \param phLibHandle [out] - pointer on dynamic library handler
+ * \param ppFunc [out] - pointer on function exported from dynamic library
+ */
+ void LoadSymbol(CPCHAR szType,
+ CPCHAR szName,
+ XPL_DL_HANDLE_T * phLibHandle,
+ void ** ppFunc);
+
+ /**
+ * Updates the last accessed time
+ */
+ void UpdateLastAccessedTime();
+};
+
+typedef JemSmartPtr<DMPlugin> PDMPlugin;
+
+#endif //End of file
diff --git a/engine/dmlib/plugin/hdr/dmPluginManager.h b/engine/dmlib/plugin/hdr/dmPluginManager.h
new file mode 100644
index 0000000..34eb273
--- /dev/null
+++ b/engine/dmlib/plugin/hdr/dmPluginManager.h
@@ -0,0 +1,288 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMPLUGINMANAGER_H
+#define DMPLUGINMANAGER_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/*==================================================================================================
+
+Header Name: dmPluginManager.h
+
+General Description: This file contains the declaration of DMPluginManager.
+
+==================================================================================================*/
+
+#include "syncml_dm_data_types.h"
+#include "dmt.hpp"
+#include "dmtPlugin.hpp"
+#include "dmPlugin.h"
+#include "dm_tree_typedef.h"
+#include "xpl_Lib.h"
+
+typedef DMVector<PDMPlugin> DMPluginVector;
+
+class CEnv;
+class DMTree;
+
+/**
+ * Plugin Manager represents a manager to handle plug-ins registration
+ */
+class DMPluginManager
+{
+public:
+
+ /**
+ * Default constructor
+ */
+ DMPluginManager();
+
+ /**
+ * Destructor
+ */
+ ~DMPluginManager();
+
+
+ /**
+ * Initializes plug-in manager
+ * \param env [in] - pointer on env object
+ * \param pTree [in] - pointer on DM tree object
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T Init( CEnv* env, DMTree* tree );
+
+
+ /**
+ * Deinitializes plug-in manager
+ */
+ void DeInit();
+
+
+ /**
+ * Loads plug-in shared library
+ * \param libName [in] - name of shared library
+ * \return Return Type (XPL_DL_HANDLE_T)
+ * - handler on shared library if operation is completed successfully,
+ * - XPL_DL_HANDLE_INVALID otherwise
+ */
+ XPL_DL_HANDLE_T LoadLib(CPCHAR libName);
+
+
+ /**
+ * Finds suitable plug-in by specified path (exact match)
+ * \param type [in] - plug-in type
+ * \param szPath [in] - plug-in path
+ * \return Return Type (PDMPlugin)
+ * - smart pointer on plug-in object if operation is completed successfully,
+ * - NULL otherwise
+ */
+ PDMPlugin FindPlugin(SYNCML_DM_PLUGIN_TYPE_T type, CPCHAR szPath);
+
+
+ /**
+ * Finds suitable commit plug-in by specified path (exact match)
+ * \param path [in] - plug-in path
+ * \return Return Type (PDMPlugin)
+ * - smart pointer on plug-in object if operation is completed successfully,
+ * - NULL otherwise
+ */
+ PDMPlugin FindCommitPlugin(CPCHAR szPath);
+
+
+ /**
+ * Retrieves all plug-in of specified path
+ * \param type [in] - plug-in path
+ * \return Return Type (DMPluginVector *)
+ * - pointer on plug-in vector if operation is completed successfully,
+ * - NULL otherwise
+ */
+ DMPluginVector * GetPlugins(SYNCML_DM_PLUGIN_TYPE_T type);
+
+
+ /**
+ * Verifies if plug-in path is not blocked
+ * \param type [in] - plug-in type
+ * \param szPath [in] - plug-in path
+ * \return TRUE if path is enabled
+ */
+ BOOLEAN IsMountPointEnabled(CPCHAR szPath) const;
+
+
+ /**
+ * Mounts plug-in nodes
+ * \param szRootPath [in] - root path of plug-ins to mount
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T UpdatePluginNodes(CPCHAR szRootPath);
+
+
+
+ /**
+ * Retrieves list of plug-ins registered on sub tree
+ * \param szPath [in] - root path of sub tree
+ * \param type [in] - plug-in type
+ * \param aPlugins [out] - list of requested plug-ins
+ */
+ void GetPlugins(CPCHAR szPath,
+ SYNCML_DM_PLUGIN_TYPE_T type,
+ DMPluginVector& aPlugins );
+
+#ifndef DM_STATIC_PLUGINS
+ /**
+ * Loads plug-in configuration file
+ * \param fileName [in] - name of a file
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T LoadPluginFile(CPCHAR fileName);
+
+#endif
+ /**
+ * Checks plug-in shared objects aging timeout
+ * \param nAgingTime [in] - aging timeout
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T CheckPluginAging(INT32 nAgingTime);
+
+private:
+ /* Pointer on DM tree */
+ DMTree *m_pTree;
+
+#ifndef DM_STATIC_PLUGINS
+ /* Collection of plug-in config files */
+ DMMap<DMString, DMPluginVector> m_mapFilePluginVectors;
+#endif
+
+ /* Data plug-ins vector */
+ DMPluginVector m_dataPlugins;
+ /* Constraint plug-ins vector */
+ DMPluginVector m_constPlugins;
+ /* Executable plug-ins vector */
+ DMPluginVector m_execPlugins;
+ /* Commit plug-ins vector */
+ DMPluginVector m_commPlugins;
+ /* Blocked plug-ins vector */
+ DMStringVector m_oBlockedPlugins;
+
+ /* Map of loaded shared libraries */
+ DMMap<DMString,XPL_DL_HANDLE_T> m_pluginLibs;
+
+ /* Index array */
+ static const SYNCML_DM_PLUGIN_TYPE_T m_nIndex[MAX_PLUGINTYPES];
+
+
+ /**
+ * Checks plug-in type from config file
+ * \param aMap [in/out] - map of plug-in parameters
+ * \param filePath [in] - path to a config file
+ * \param pluginName [in] - mask to verify type of a plug-in
+ * \param type [in] - plug-in type to verify against
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_PLUGIN_TYPE_T CheckPlugin(DMStringMap & aMap,
+ CPCHAR filePath,
+ CPCHAR pluginName,
+ SYNCML_DM_PLUGIN_TYPE_T type);
+
+ /**
+ * Creates plug-in object and adds it into internal storage according to config record
+ * \param fileName [in] - name of a config file
+ * \param strPath [in] - plug-in path
+ * \param aMap [in] - map of plug-in parameters from a config file
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T AddPlugin(CPCHAR fileName,
+ DMString & strPath,
+ DMStringMap & aMap);
+
+ /**
+ * Creates DM plug-in proxy node and mounts it to DM tree
+ * \param pPlugin [in] - smart pointer on data plug-in
+ * \param oNodeProps [in] - property of a plug-in proxy node
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T MountNode(PDMPlugin & pPlugin,
+ DMAddNodeProp & oNodeProps);
+
+
+ /**
+ * Matches node path and plun-in path (due to multinode support)
+ * \param szNodePath [in] - DM node path
+ * \param szPluginPath [in] - plug-in path
+ * \return TRUE if paths are matched
+ */
+ static BOOLEAN PathMatch(CPCHAR szNodePath,
+ CPCHAR szPluginPath);
+
+ /**
+ * Parses line from a config file
+ * \param fileName [in] - name of a config file
+ * \param szLine [in] - line to parse
+ * \param strSectionName [in] - name of currect block (plug-in path)
+ * \param aMap [in] - map of plug-in parameters from a config file
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T ParseLine(CPCHAR szFileName,
+ CPCHAR szLine,
+ DMString &strSectionName,
+ DMStringMap &aMap);
+
+
+#ifndef DM_STATIC_PLUGINS
+ /**
+ * Searches all config file in the specified folder
+ * \param szPath [in] - name of directory to search
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T LoadDirectory(CPCHAR szPath);
+#endif
+
+#ifdef DM_STATIC_FILES
+
+ /**
+ * Loads static config file
+ * \param pBuffer [in] - static buffer
+ * \param size [in] - size of a buffer
+ * \return Return Type (SYNCML_DM_RET_STATUS_T)
+ * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
+ * - All other codes indicate failure.
+ */
+ SYNCML_DM_RET_STATUS_T LoadPluginFile(UINT8 *pBuffer,
+ UINT32 size);
+#endif
+};
+
+#endif
diff --git a/engine/dmlib/plugin/src/SyncML_PlugIn_Log.cc b/engine/dmlib/plugin/src/SyncML_PlugIn_Log.cc
new file mode 100644
index 0000000..4d62486
--- /dev/null
+++ b/engine/dmlib/plugin/src/SyncML_PlugIn_Log.cc
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: SyncML_PlugIn_Log.cc
+
+ General Description: This contains function implementations of the Log class.
+
+==================================================================================================*/
+
+#include "SyncML_PlugIn_Log.H"
+
+/*==================================================================================================
+
+Function: SyncML_PlugIn_Log::SyncML_PlugIn_Log
+
+Description: Constructor for the Log object
+
+==================================================================================================*/
+SyncML_PlugIn_Log::SyncML_PlugIn_Log()
+{
+ this->fileHandle = NULL;
+}
+
+/*==================================================================================================
+
+Function: SyncML_DM_Log::~SyncML_PlugIn_Log
+
+Description: Destructor for the Log object
+
+==================================================================================================*/
+SyncML_PlugIn_Log::~SyncML_PlugIn_Log()
+{
+ /* The fileHandle reference is deleted by the calling class */
+}
+/*==================================================================================================
+
+Function: SyncML_PlugIn_Log::setLogFileHandle
+
+Description: Accessor method for the file reader
+
+==================================================================================================*/
+void
+SyncML_PlugIn_Log::setLogFileHandle(DMFileHandler* fileHandle)
+{
+ this->fileHandle = fileHandle;
+}
+
+/*==================================================================================================
+
+Function: SyncML_PlunIn_Log::getLogFileHandle
+
+Description: Accessor method for the file reader
+
+==================================================================================================*/
+DMFileHandler*
+SyncML_PlugIn_Log::getLogFileHandle()
+{
+ return this->fileHandle;
+}
diff --git a/engine/dmlib/plugin/src/SyncML_PlugIn_WBXMLLog.cc b/engine/dmlib/plugin/src/SyncML_PlugIn_WBXMLLog.cc
new file mode 100644
index 0000000..e01b5df
--- /dev/null
+++ b/engine/dmlib/plugin/src/SyncML_PlugIn_WBXMLLog.cc
@@ -0,0 +1,976 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ File Name: SyncML_PlugIn_WBXMLLog.cc
+
+ General Description: This contains function implementations of the WBXMLLog class.
+
+==================================================================================================*/
+
+#include "dmStringUtil.h"
+#include "SyncML_PlugIn_WBXMLLog.H"
+#include "SyncML_DM_WBXMLArchive.H"
+#include "dmtRWPlugin.hpp"
+#include "dm_tree_plugin_util.H"
+#include "dm_uri_utils.h"
+#include "dm_tree_util.h"
+
+#ifdef TEST_DM_RECOVERY
+extern char power_fail_point[];
+#endif
+
+/*==================================================================================================
+
+Function: SyncML_PlugIn_WBXMLLog::SyncML_PlugIn_WBXMLLog
+
+Description: Constructor for the Log object
+
+==================================================================================================*/
+
+SyncML_PlugIn_WBXMLLog::SyncML_PlugIn_WBXMLLog(const DmtRWPluginTree *pluginTree, const char * rootPath):SyncML_Log()
+{
+ m_strRootPath=rootPath;
+ prevRecord = 0;
+ this->pluginTree = pluginTree;
+}
+/*==================================================================================================
+
+Function: SyncML_PlugIn_WBXMLLog::~SyncML_PlugIn_WBXMLLog
+
+Description: Destructor for the Log object
+
+==================================================================================================*/
+SyncML_PlugIn_WBXMLLog::~SyncML_PlugIn_WBXMLLog()
+{
+ UnInitLog();
+}
+/*==================================================================================================
+
+Function: SyncML_PlugIn_WBXMLLog::UnInitLog
+
+Description: Uninitialize log
+
+==================================================================================================*/
+ SYNCML_DM_RET_STATUS_T SyncML_PlugIn_WBXMLLog::UnInitLog()
+{
+ if(reader != NULL)
+ {
+ delete reader;
+ reader = NULL;
+ }
+
+ if(writer != NULL)
+ {
+ delete writer;
+ writer = NULL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+/*==================================================================================================
+
+Function: SyncML_PlugIn_WBXMLLog::InitLog
+
+Description: Open/Create log file
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_PlugIn_WBXMLLog::InitLog(CPCHAR logFileName)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = UnInitLog();;
+ BOOLEAN m_WriteHeader = FALSE;
+
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ if (!XPL_FS_Exist(logFileName))
+ m_WriteHeader = TRUE;
+
+ dm_stat = SyncML_Log::InitLog(logFileName);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ // Write log file file header
+ if(m_WriteHeader)
+ {
+ // Go to end of log file
+ if(this->fileHandle->seek(XPL_FS_SEEK_END, 0) != SYNCML_DM_SUCCESS)
+ {
+ CloseLog();
+ dm_stat = SYNCML_DM_IO_FAILURE;
+ }
+ // Write log header
+ prevRecord = this->fileHandle->position();
+ if(prevRecord == 0)
+ {
+ if(writer == NULL)
+ { writer = new SyncML_DM_WBXMLWriter(this->fileHandle);
+ if( writer == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ if(this->writeLogHeader(writer) != SYNCML_DM_SUCCESS)
+ {
+ CloseLog();
+ dm_stat = SYNCML_DM_IO_FAILURE;
+ }
+ }
+ }
+ return dm_stat;
+}
+
+/*============================================================================n
+
+Function: SyncML_PlugIn_WBXMLLog::updatePosition
+
+Description: Update position information
+
+Memory: The caller is responsible for freeing the SyncML_DM_Command object
+
+Notes:
+
+================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_PlugIn_WBXMLLog::updatePosition(SyncML_DM_WBXMLWriter* writer)
+{
+ INT32 tempPos = 0;
+ INT32 currentPos = 0;
+
+
+ // Write previous record position
+ if(writer->writeData((const UINT8*)&this->prevRecord, sizeof(this->prevRecord)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ // Place holder for next record pointer
+ if(writer->writeData((const UINT8*)&tempPos, sizeof(tempPos)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ // Go to end of log file
+ if(this->fileHandle->seek(XPL_FS_SEEK_END, 0) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ currentPos = this->fileHandle->position();
+
+ // Go to the previous place holder
+ if(this->fileHandle->seek(XPL_FS_SEEK_SET, this->prevRecord - sizeof(INT32)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ tempPos = this->fileHandle->position();
+
+ if(writer->writeData((const UINT8*)&currentPos, sizeof(currentPos)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ // Go to end of log file
+ if(this->fileHandle->seek(XPL_FS_SEEK_END, 0) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ this->prevRecord = currentPos;
+
+ return SYNCML_DM_SUCCESS;
+
+}
+/*============================================================================n
+
+Function: SyncML_PlugIn_WBXMLLog::writeLogHeader
+
+Description: Write log header information
+
+Notes:
+
+================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_PlugIn_WBXMLLog::writeLogHeader(SyncML_DM_WBXMLWriter* writer)
+{
+ INT32 tempPos = 0;
+ prevRecord = 3 * sizeof(INT32) + m_strRootPath.length() + 4;
+
+ if(writer->writeData((const UINT8*)&prevRecord, sizeof(prevRecord)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::URI_START_TAG
+ | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(writer->writeString(m_strRootPath.c_str()) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(this->fileHandle->seek(XPL_FS_SEEK_END, 0) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(writer->writeData((const UINT8*)&tempPos, sizeof(tempPos)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(writer->writeData((const UINT8*)&tempPos, sizeof(tempPos)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ return SYNCML_DM_SUCCESS;
+}
+/*============================================================================n
+
+Function: SyncML_PlugIn_WBXMLLog::writeLogHeader
+
+Description: Write log header information
+
+Notes:
+
+================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_PlugIn_WBXMLLog::writePluginNode(CPCHAR pbURI, SyncML_DM_WBXMLWriter* writer, const DmtNode* ptrNode)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMString strVal;
+ DMGetData oGetData;
+ BOOLEAN m_bESN = FALSE;
+ CPCHAR tmpStr = NULL;
+
+
+ DmtAttributes oAttr;
+ dm_stat = ptrNode->GetAttributes( oAttr );
+ if( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if (ptrNode->IsLeaf())
+ {
+ DmtData data;
+ dm_stat = ptrNode->GetValue(data);
+
+ if (dm_stat == SYNCML_DM_SUCCESS)
+ dm_stat = oGetData.set(data,oAttr.GetType());
+#ifdef LOB_SUPPORT
+ if(ptrNode->IsExternalStorageNode())
+ {
+ PDmtRWPluginNode pRWNode = (DmtRWPluginNode *) ((DmtNode *)ptrNode);
+ m_bESN = TRUE;
+ tmpStr = pRWNode->GetESNBackupFileName();
+ }
+#endif
+ }
+ else
+ {
+ DMStringVector mapNodeNames;
+
+ dm_stat = ((DmtPluginTree *)this->pluginTree)->GetChildNodeNames( pbURI, mapNodeNames );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ for ( int i = 0; i < mapNodeNames.size(); i++ )
+ {
+ if (i >0)
+ strVal += "/";
+
+ strVal += mapNodeNames[i];
+ }
+ dm_stat = oGetData.set(SYNCML_DM_FORMAT_NODE,strVal,strVal.length(),"text/plain");
+ }
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ DMNode * psNodeObject = dmTreeObj.CreateNodeObj(oGetData.m_nFormat, m_bESN, tmpStr);
+ if(psNodeObject == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+
+ DMString nodeName;
+
+ dm_stat = ptrNode->GetNodeName(nodeName);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ dm_stat = psNodeObject->set(nodeName,oAttr.GetTitle(),&oGetData);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ { dm_stat = writer->writeNode((const DMNode*)psNodeObject);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ // Write interior node information
+ if (!ptrNode->IsLeaf())
+ {
+ if(strVal.length()!= 0)
+ {
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::DATA_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writer->writeOpaque((const UINT8*)strVal.c_str(), strVal.length()) != SYNCML_DM_SUCCESS ||
+ writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ dm_stat = SYNCML_DM_IO_FAILURE;
+
+ }
+ }
+
+ }
+
+ }
+ }
+
+ delete psNodeObject;
+
+ return dm_stat;
+}
+/*============================================================================n
+
+Function: SyncML_PlugIn_WBXMLLog::writeURIInfo
+
+Description:Log URI information
+
+Memory:
+
+Notes:
+
+================================================================================*/
+
+SYNCML_DM_RET_STATUS_T
+SyncML_PlugIn_WBXMLLog::writeURIInfo(SYNCML_DM_PLUGIN_COMMAND_T commandType, CPCHAR pbURI, SyncML_DM_WBXMLWriter* writer)
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ UINT8 ioArray[5] = { SyncML_DM_WBXMLArchive::ENTRY_START_TAG |
+ SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK,
+ SyncML_DM_WBXMLArchive::CMDTYPE_START_TAG |
+ SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK,
+ commandType,
+ SyncML_DM_WBXMLArchive::END_TAG,
+ SyncML_DM_WBXMLArchive::URI_START_TAG |
+ SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK};
+
+ if(writer == NULL || fileHandle == NULL)
+ return SYNCML_DM_FAIL;
+
+ // Go to end of log file
+ if(this->fileHandle->seek(XPL_FS_SEEK_END, 0) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto URIWriteFailed;
+ }
+
+
+ if(writer->writeData(ioArray, sizeof(ioArray)) != SYNCML_DM_SUCCESS){
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto URIWriteFailed;
+ }
+
+ if(writer->writeString(pbURI) != SYNCML_DM_SUCCESS){
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto URIWriteFailed;
+ }
+
+ /* End of the URI field */
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS){
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto URIWriteFailed;
+ }
+ return ret_code;
+
+ URIWriteFailed:
+ delete writer;
+ writer = NULL;
+ this->fileHandle->close();
+ return ret_code;
+}
+
+/*============================================================================n
+
+Function: SyncML_PlugIn_WBXMLLog::logCommand
+
+Description: logs the command type, URI, node properties and recovery field for
+ a command in the log file.
+
+Memory: The caller is responsible for freeing the SyncML_DM_Command object
+
+Notes:
+
+================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_PlugIn_WBXMLLog::logCommand(SYNCML_DM_PLUGIN_COMMAND_T commandType,
+ CPCHAR pbURI,
+ SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T attribute,
+ const DmtNode* node)
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ INT32 tempPos = 0;
+ INT32 currentPos = 0;
+ DMVector<PDmtNode> oChildren;
+ PDmtRWPluginNode ptrTempNode = (DmtRWPluginNode *) ((DmtPluginNode *)node);
+
+ if(commandType != SYNCML_DM_PLUGIN_ADD &&
+ commandType != SYNCML_DM_PLUGIN_ADD_CHILD &&
+ commandType != SYNCML_DM_PLUGIN_DELETE &&
+ commandType != SYNCML_DM_PLUGIN_REPLACE)
+ {
+ return SYNCML_DM_FAIL;
+ }
+ if(writer == NULL)
+ { writer = new SyncML_DM_WBXMLWriter(this->fileHandle);
+ if( writer == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ if(commandType != SYNCML_DM_PLUGIN_ADD)
+ {
+ ret_code = writeURIInfo(commandType, pbURI, writer);
+ if(ret_code != SYNCML_DM_SUCCESS)
+ goto WriteFailed;
+ }
+
+ INT32 i;
+ switch ( commandType )
+ {
+ case SYNCML_DM_PLUGIN_ADD:
+ {
+ if(node == NULL)
+ return SYNCML_DM_FAIL;
+
+ // Serialize the subtree
+ ret_code = ptrTempNode->GetChildNodes( oChildren );
+ DMString nodePath;
+ for (i = 0; i < oChildren.size(); i++ )
+ {
+ ret_code = oChildren[i]->GetPath(nodePath);
+ if(ret_code != SYNCML_DM_SUCCESS)
+ goto WriteFailed;
+
+ ret_code = logCommand(SYNCML_DM_PLUGIN_ADD,
+ nodePath.c_str(),
+ attribute,
+ (const DmtNode*)oChildren[i]);
+ if(ret_code != SYNCML_DM_SUCCESS)
+ goto WriteFailed;
+ }
+ ret_code = writeURIInfo(commandType, pbURI, writer);
+ if(ret_code != SYNCML_DM_SUCCESS)
+ goto WriteFailed;
+
+ if(writePluginNode(pbURI, writer, node) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+
+ if(updatePosition(writer) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ }
+ break;
+
+ case SYNCML_DM_PLUGIN_REPLACE:
+ if(writer->writeByte(attribute) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+
+ switch(attribute)
+ {
+ case SYNCML_DM_PLUGIN_COMMAND_ON_NODE:
+ if (node->IsLeaf())
+ {
+ DmtData data;
+ DMString strVal;
+ ret_code = node->GetValue(data);
+ if(ret_code == SYNCML_DM_SUCCESS)
+ {
+ if ( data.GetType() != SYNCML_DM_DATAFORMAT_NULL )
+ ret_code = data.GetString(strVal);
+ if (ret_code == SYNCML_DM_SUCCESS && strVal.length() != 0)
+ {
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::DATA_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writer->writeOpaque((UINT8*)strVal.c_str(),strVal.length()) != SYNCML_DM_SUCCESS ||
+ writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ }
+
+ }
+ }
+ else
+ {
+ ret_code = SYNCML_DM_FAIL;
+ goto WriteFailed;
+ }
+ break;
+
+ case SYNCML_DM_PLUGIN_COMMAND_ON_NAME_PROPERTY:
+ {
+ DMString nodeName;
+
+ ret_code = node->GetNodeName(nodeName);
+ if ( ret_code == SYNCML_DM_SUCCESS )
+ {
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::NAME_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writer->writeString(nodeName.c_str()) != SYNCML_DM_SUCCESS ||
+ writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ }
+ }
+ break;
+
+ case SYNCML_DM_PLUGIN_COMMAND_ON_TITLE_PROPERTY:
+ {
+ DmtAttributes oAttr;
+ ret_code = node->GetAttributes( oAttr );
+ if ( ret_code == SYNCML_DM_SUCCESS )
+ {
+ const DMString & title = oAttr.GetTitle();
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::TITLE_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writer->writeString(title.c_str()) != SYNCML_DM_SUCCESS ||
+ writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ }
+ else
+ {
+ ret_code = SYNCML_DM_FAIL;
+ goto WriteFailed;
+ }
+ }
+ break;
+#ifdef LOB_SUPPORT
+ case SYNCML_DM_PLUGIN_COMMAND_ON_LOB_PROPERTY:
+ {
+ CPCHAR tmpStr = ptrTempNode->GetESNBackupFileName();
+
+ if ( tmpStr != NULL)
+ {
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::ESN_File_NAME_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK) != SYNCML_DM_SUCCESS ||
+ writer->writeString(tmpStr) != SYNCML_DM_SUCCESS ||
+ writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ }
+ else
+ {
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ }
+ }
+ break;
+#endif
+ default:
+ ret_code = SYNCML_DM_INVALID_PARAMETER;
+ goto WriteFailed;
+
+ }
+
+ if(updatePosition(writer) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ break;
+
+ case SYNCML_DM_PLUGIN_DELETE:
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ if(updatePosition(writer) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ break;
+
+ case SYNCML_DM_PLUGIN_ADD_CHILD:
+ if(writer->writeByte(SyncML_DM_WBXMLArchive::END_TAG) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ if(updatePosition(writer) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto WriteFailed;
+ }
+ break;
+ }
+
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "PLUGIN_PF4") == 0))
+ {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+
+ return ret_code;
+
+
+ WriteFailed:
+ delete writer;
+ writer = NULL;
+ this->fileHandle->close();
+ return ret_code;
+
+}
+
+/*==============================================================================
+====================
+
+Function: SyncML_PlugIn_WBXMLLog::gotoLastRecord
+
+Description: Goto last log entry position
+
+Returns: SYNCML_DM_IO_FAILURE - could not perform an I/O operation
+ SYNCML_DM_LOG_CORRUPT - there was an invalid byte read
+ SYNCML_DM_SUCCESS
+ SYNCML_DM_FILE_NOT_FOUND - could not find the log file
+
+================================================================================
+==================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_PlugIn_WBXMLLog::gotoLastRecord(SyncML_DM_WBXMLReader* reader,
+ UINT8 *lastByte,
+ INT32 *currentPos )
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ INT32 tempPos = 0;
+ INT32 currentRecordPos = 0;
+ INT32 nextRecordPos = 0;
+
+ *currentPos = 0;
+
+ // Go to end of log file
+ if(this->fileHandle->seek(XPL_FS_SEEK_SET, prevRecord - 2*sizeof(INT32)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if(this->fileHandle->read((UINT8 *)currentPos, sizeof(INT32)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ // No log entry
+ if(*currentPos == 0)
+ return SYNCML_DM_SUCCESS;
+
+ // Point to last log entry
+ ret_code = this->fileHandle->seek(XPL_FS_SEEK_SET, (int)*currentPos);
+
+ // If it is valid log entry
+ if(reader->readByte(lastByte) != SYNCML_DM_SUCCESS ||
+ *lastByte != (SyncML_DM_WBXMLArchive::ENTRY_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ {
+ // Point to last log entry
+
+ if(this->fileHandle->seek(XPL_FS_SEEK_SET, 0) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ if ((ret_code = this->fileHandle->read((UINT8 *)&currentRecordPos, sizeof(INT32))) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ nextRecordPos = currentRecordPos;
+
+ while((ret_code == SYNCML_DM_SUCCESS))
+ {
+ // Read next entry until the pointer is 0
+ tempPos = currentRecordPos;
+ this->fileHandle->seek(XPL_FS_SEEK_SET, tempPos-sizeof(INT32));
+
+ ret_code= this->fileHandle->read((UINT8 *)&currentRecordPos, sizeof(INT32));
+ if((currentRecordPos == 0) || (ret_code != SYNCML_DM_SUCCESS))
+ break;
+ nextRecordPos = tempPos;
+ }
+ *currentPos = nextRecordPos;
+ // Read last entry
+ this->fileHandle->seek(XPL_FS_SEEK_SET, (int)*currentPos);
+
+ // If it is valid log entry
+ if(reader->readByte(lastByte) != SYNCML_DM_SUCCESS ||
+ *lastByte != (SyncML_DM_WBXMLArchive::ENTRY_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ {
+ //Read previous entry
+ if(this->fileHandle->seek(XPL_FS_SEEK_SET, nextRecordPos-2*sizeof(INT32)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ if(this->fileHandle->read((UINT8 *)currentPos, sizeof(INT32)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ // No log entry
+ if(*currentPos == 0)
+ return SYNCML_DM_SUCCESS;
+ // Point to last log entry
+ this->fileHandle->seek(XPL_FS_SEEK_SET, (int)*currentPos);
+ ret_code = reader->readByte(lastByte);
+ }
+ }
+ return ret_code;
+}
+/*==================================================================================================
+
+Function: SyncML_PlugIn_WBXMLLog::playLog
+
+Description: Log file playback and remove
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T SyncML_PlugIn_WBXMLLog::playLog(CPCHAR logFileName)
+{
+ return SyncML_Log::playLog(logFileName);
+}
+
+/*===============================================================================================
+
+Function: SyncML_PlugIn_WBXMLLog::playLog
+
+Description: This function provides log looping for log playback and recovery
+ purposes. If the isRecovery field is set the function performs
+ calls to recovery functions for the log entries in the log file.
+ Otherwise, the function does log playback to the Tree and node
+ manager.
+
+Returns: SYNCML_DM_IO_FAILURE - could not perform an I/O operation
+ SYNCML_DM_LOG_CORRUPT - there was an invalid byte read
+ SYNCML_DM_SUCCESS
+ SYNCML_DM_FILE_NOT_FOUND - could not find the log file
+
+==================================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_PlugIn_WBXMLLog::playLog()
+{
+ SYNCML_DM_RET_STATUS_T ret_code = SYNCML_DM_SUCCESS;
+ SYNCML_DM_COMMAND_T cmdType = SYNCML_DM_NO_COMMAND;
+ DMBuffer cmdURI;
+ BOOLEAN isLast = TRUE;
+ DMAddNodeProp props;
+ INT32 currentRecordPos = 0;
+
+ UINT8 bYte;
+ SYNCML_DM_URI_RESULT_T attribute;
+
+ if((fileHandle == NULL))
+ return SYNCML_DM_FAIL;
+
+ if(reader == NULL)
+ { reader = new SyncML_DM_WBXMLReader(this->fileHandle);
+
+ if(reader == NULL)
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ if(this->fileHandle->seek(XPL_FS_SEEK_END, 0) != SYNCML_DM_SUCCESS)
+ ret_code = SYNCML_DM_IO_FAILURE;
+
+ prevRecord = this->fileHandle->position();
+
+ if((ret_code=gotoLastRecord(reader,&bYte, &currentRecordPos)) != SYNCML_DM_SUCCESS)
+ return ret_code;
+
+ // No log entry
+ if(currentRecordPos == 0)
+ return SYNCML_DM_SUCCESS;
+
+ while(1)
+ {
+ if(bYte == SyncML_DM_WBXMLArchive::END_TAG)
+ {
+ /* Signifies the end of the log file */
+ break;
+ }
+ else
+ if(bYte == (SyncML_DM_WBXMLArchive::ENTRY_START_TAG | SyncML_DM_WBXMLArchive::TAG_CONTENT_MASK))
+ {
+ if(reader->readOneLogRecord(&cmdType, &cmdURI, &attribute,&props,&bYte) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto PlayFinished;
+ }
+
+ ret_code = playbackOneRecord(cmdType,(const char *)cmdURI.getBuffer(),attribute,&props);
+
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "PLUGIN_PF5") == 0))
+ {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+
+ if(ret_code == SYNCML_DM_IO_FAILURE)
+ {
+ if(!isLast)
+ break;
+ }
+ isLast = FALSE;
+ // Go to previous entry
+ if(this->fileHandle->seek(XPL_FS_SEEK_SET, currentRecordPos-2 * sizeof(INT32)) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto PlayFinished;
+ }
+ // Last log entry position
+ if(this->fileHandle->read((UINT8 *)&currentRecordPos, sizeof(INT32)) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ // No more log entry
+ if(currentRecordPos == 0)
+ break;
+
+ // Goto the entry
+ if(this->fileHandle->seek(XPL_FS_SEEK_SET, currentRecordPos) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto PlayFinished;
+ }
+ // Read the first byte of data looking for an ENTRY_START_TAG
+ if(reader->readByte(&bYte) != SYNCML_DM_SUCCESS)
+ {
+ ret_code = SYNCML_DM_IO_FAILURE;
+ goto PlayFinished;
+ }
+
+ }
+ }
+
+ PlayFinished:
+
+ UnInitLog();
+ return ret_code;
+}
+/*=============================================================================================
+
+Function: SyncML_DM_WBXMLLog::performRecovery
+
+Description: The function arguments are the command type and the full URI
+ including the query and special case extensions (e.g. http://hi.com?ACL=*).
+
+Returns: SYNCML_DM_SUCCES
+ SYNCML_DM_FAIL
+ SYNCML_DM_IO_FAILURE
+
+Notes:
+
+=============================================================================================*/
+SYNCML_DM_RET_STATUS_T
+SyncML_PlugIn_WBXMLLog::playbackOneRecord(SYNCML_DM_PLUGIN_COMMAND_T commandType,
+ CPCHAR pbURI,
+ SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T attribute,
+ DMAddNodeProp* props)
+
+{
+ PDmtRWPluginNode ptrNode = NULL;
+ PDmtNode ptrDmtNode;
+ DmtData oData;
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ if(pluginTree == NULL)
+ return SYNCML_DM_FAIL;
+
+ /* Call the recovery functions */
+ switch(commandType)
+ {
+ case SYNCML_DM_PLUGIN_ADD:
+ {
+ dm_stat = dmBuildData(props->m_nFormat, props->m_oData, oData);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ if (props->m_nFormat == SYNCML_DM_FORMAT_NODE)
+ {
+ DMStringVector oChildren;
+ DmStrToStringVector((CPCHAR)props->m_oData.getBuffer(),props->m_oData.getSize(), oChildren, '/');
+
+ dm_stat = ((DmtRWPluginTree *)this->pluginTree)->CreateInteriorNodeInternal(pbURI, ptrDmtNode, oChildren);
+ }
+ else
+ {
+#ifdef LOB_SUPPORT
+ boolean isESN = (props->m_nFlags & DMNode::enum_NodeESN) != 0;
+ dm_stat = ((DmtRWPluginTree *)this->pluginTree)->CreateLeafNodeInternal(pbURI, ptrDmtNode, oData, isESN);
+ if(dm_stat == SYNCML_DM_SUCCESS)
+ {
+ // Restore ESN data
+ if(isESN)
+ {
+ ptrNode = (DmtRWPluginNode *) ((DmtNode *)ptrDmtNode);
+ dm_stat = ptrNode->RestoreESNData(props->getESNFileName());
+ }
+ }
+#else
+ dm_stat = ((DmtRWPluginTree *)this->pluginTree)->CreateLeafNodeInternal(pbURI, ptrDmtNode, oData);
+#endif
+ }
+ break;
+ }
+
+ case SYNCML_DM_PLUGIN_ADD_CHILD:
+ dm_stat = ((DmtRWPluginTree *)this->pluginTree)->LinkToParentNode(pbURI);
+ break;
+
+ case SYNCML_DM_PLUGIN_DELETE:
+ dm_stat = ((DmtRWPluginTree *)this->pluginTree)->DeleteNode(pbURI);
+ break;
+
+ case SYNCML_DM_PLUGIN_REPLACE:
+ dm_stat = ((DmtRWPluginTree *)this->pluginTree)->GetNode(pbURI, ptrDmtNode);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ ptrNode = (DmtRWPluginNode *) ((DmtNode *)ptrDmtNode);
+ if(ptrNode != NULL)
+ {
+
+ switch( attribute)
+ {
+ case SYNCML_DM_PLUGIN_COMMAND_ON_NODE:
+ {
+ DmtData curData;
+ dm_stat = ptrNode->GetValue(curData);
+ dm_stat = dmBuildData(curData.GetType(), props->m_oData, oData);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = ptrNode->SetValue(oData);
+ }
+ break;
+
+ case SYNCML_DM_PLUGIN_COMMAND_ON_NAME_PROPERTY:
+ dm_stat = ptrNode->Rename(props->getName());
+ break;
+
+ case SYNCML_DM_PLUGIN_COMMAND_ON_TITLE_PROPERTY:
+ dm_stat = ptrNode->SetTitle(props->getTitle());
+ break;
+#ifdef LOB_SUPPORT
+ case SYNCML_DM_PLUGIN_COMMAND_ON_LOB_PROPERTY:
+ dm_stat = ptrNode->RestoreESNData(props->getESNFileName());
+ break;
+#endif
+ default:
+ break;
+ }
+ }
+ }
+ break;
+
+ default:
+ /* recovery_status has already been initialized to fail */
+ break;
+ }
+
+ return dm_stat;
+
+}
diff --git a/engine/dmlib/plugin/src/dmPlugin.cc b/engine/dmlib/plugin/src/dmPlugin.cc
new file mode 100644
index 0000000..fc7688c
--- /dev/null
+++ b/engine/dmlib/plugin/src/dmPlugin.cc
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmPlugin.cc
+
+ General Description: Implementation of the DMPlugin class
+
+==================================================================================================*/
+
+#include "dmt.hpp"
+#include "dmdefs.h"
+#include "xpl_Logger.h"
+#include "dm_tree_class.H"
+#include "dmPluginManager.h"
+
+DMPlugin::DMPlugin(SYNCML_DM_PLUGIN_TYPE_T type,
+ BOOLEAN bOverlayPlugin,
+ const DMString & strPath,
+ DMStringMap & mapParameters)
+{
+
+ m_type=type;
+ m_bOverlayPlugin = bOverlayPlugin;
+ m_strPath=strPath;
+ m_mapParameters=mapParameters;
+
+ pfGetTree = NULL;
+ pfExecute2 = NULL;
+ pfCheckConstraint = NULL;
+ pfOnCommit = NULL;
+
+ m_hLibData = NULL;
+ m_hLibExec = NULL;
+ m_hLibConstraint = NULL;
+ m_hLibCommit = NULL;
+
+ m_pTree=NULL;
+
+ UpdateLastAccessedTime();
+}
+
+
+DMPlugin::~DMPlugin()
+{
+
+ UnloadSymbols();
+}
+
+void
+DMPlugin::UnloadSymbols()
+{
+ if (m_pTree!=NULL)
+ {
+ XPL_LOG_DM_PLG_Debug(("Release m_pTree: %s\n", m_strPath.c_str()));
+ m_pTree->Release();
+ }
+
+ pfGetTree = NULL;
+ pfExecute2 = NULL;
+ pfCheckConstraint = NULL;
+ pfOnCommit = NULL;
+ m_pTree=NULL;
+
+ m_hLibData = NULL;
+ m_hLibExec = NULL;
+ m_hLibConstraint = NULL;
+ m_hLibCommit = NULL;
+}
+
+BOOLEAN
+DMPlugin::IsSymbolsLoaded()
+{
+ return (m_pTree!=NULL) || (m_hLibData!=NULL) ||
+ (m_hLibExec) || (m_hLibConstraint) || (m_hLibCommit);
+}
+
+
+BOOLEAN
+DMPlugin::IsLibReleased(XPL_DL_HANDLE_T handler)
+{
+ if ( handler == m_hLibData || handler == m_hLibExec ||
+ handler == m_hLibConstraint || handler == m_hLibCommit )
+ return TRUE;
+ return FALSE;
+}
+
+
+void
+DMPlugin::LoadSymbol(CPCHAR szType,
+ CPCHAR szName,
+ XPL_DL_HANDLE_T * phLibHandle,
+ void ** ppFunc)
+{
+
+ if (*phLibHandle == 0)
+ {
+ DMString strKey = szType;
+ DMString value;
+ if (m_mapParameters.lookup(strKey, value))
+ {
+ DMPluginManager & oPluginManager = dmTreeObj.GetPluginManager();
+ *phLibHandle = oPluginManager.LoadLib(value.c_str());
+ }
+ XPL_LOG_DM_PLG_Debug(("lookedup %s=%s\n", strKey.c_str(), value.c_str()));
+ }
+
+ if (*phLibHandle != 0)
+ {
+ *ppFunc = XPL_DL_GetFunction(*phLibHandle, szName);
+ }
+ XPL_LOG_DM_PLG_Debug(("loadSymbol lib=0x%x, func=0x%x\n", *phLibHandle, *ppFunc));
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMPlugin::GetTree(CPCHAR szPath,
+ PDmtAPIPluginTree & pTree)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+
+ UpdateLastAccessedTime();
+
+ if ( m_pTree!=NULL )
+ {
+ pTree=m_pTree;
+ return dm_stat;
+ }
+
+ if ( pfGetTree==NULL)
+ LoadSymbol( m_bOverlayPlugin ? PLUGIN_DATA_OVERLAY_NAME : PLUGIN_DATA_NAME,
+ "DMT_PluginLib_Data_GetPluginTree",&m_hLibData,(void **) &pfGetTree);
+
+ if (pfGetTree != NULL)
+ dm_stat = pfGetTree(szPath,m_mapParameters,pTree);
+
+ m_pTree = pTree;
+
+ XPL_LOG_DM_PLG_Debug(("DMPlugin::GetTree(%s)=0x%x\n", szPath, (void *)pTree));
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMPlugin::Execute(CPCHAR szPath,
+ CPCHAR szArgs,
+ CPCHAR szCorrelator,
+ PDmtTree pTree,
+ DMString & results)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ UpdateLastAccessedTime();
+
+ if ( pfExecute2==NULL)
+ LoadSymbol(PLUGIN_EXECUTE_NAME,"DMT_PluginLib_Execute2",&m_hLibExec,(void **)&pfExecute2);
+
+ if (pfExecute2 != NULL)
+ {
+ dm_stat = pfExecute2(szPath,m_mapParameters,szArgs,szCorrelator,pTree,results);
+ return dm_stat;
+ }
+
+ return SYNCML_DM_FAIL;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMPlugin::CheckConstraint(CPCHAR szPath,
+ PDmtTree pTree)
+{
+ UpdateLastAccessedTime();
+
+ if ( pfCheckConstraint==NULL)
+ LoadSymbol(PLUGIN_CONSTRAINT_NAME,"DMT_PluginLib_CheckConstraint",&m_hLibConstraint,(void **)&pfCheckConstraint);
+
+ if ( pfCheckConstraint != NULL )
+ return pfCheckConstraint(szPath,m_mapParameters,pTree);
+ else
+ return SYNCML_DM_FAIL;
+}
+
+
+void
+DMPlugin::OnCommit(const DmtEventMap &aUpdatedNodes,
+ PDmtTree pTree)
+{
+
+ UpdateLastAccessedTime();
+
+ if ( pfOnCommit==NULL)
+ LoadSymbol(PLUGIN_COMMIT_NAME,"DMT_PluginLib_OnCommit",&m_hLibCommit,(void **)&pfOnCommit);
+
+ if ( pfOnCommit != NULL )
+ pfOnCommit(aUpdatedNodes,m_mapParameters,pTree);
+}
+
+void DMPlugin::UpdateLastAccessedTime()
+{
+ m_lastAccessedTime = XPL_CLK_GetClock();
+}
+
+XPL_CLK_CLOCK_T DMPlugin::GetLastAccessedTime()
+{
+ return m_lastAccessedTime;
+}
diff --git a/engine/dmlib/plugin/src/dmPluginManager.cc b/engine/dmlib/plugin/src/dmPluginManager.cc
new file mode 100644
index 0000000..6d28319
--- /dev/null
+++ b/engine/dmlib/plugin/src/dmPluginManager.cc
@@ -0,0 +1,758 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmPluginManager.cc
+
+ General Description: Implementation of the DMPluginManager class
+
+==================================================================================================*/
+
+#include "dmt.hpp"
+#include "xpl_Logger.h"
+#include "xpl_dm_Manager.h"
+#include "dmBufferReader.h"
+#include "dm_uri_utils.h"
+#include "dm_tree_class.H"
+#include "SyncML_DM_FileHandle.H"
+#include "dm_tree_plugin_root_node_class.H"
+#include "dmPluginManager.h"
+#include "dm_tree_default_interior_node_class.H"
+
+#ifndef min
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+const SYNCML_DM_PLUGIN_TYPE_T DMPluginManager::m_nIndex[] =
+ { SYNCML_DM_DATA_PLUGIN,
+ SYNCML_DM_EXECUTE_PLUGIN,
+ SYNCML_DM_CONSTRAINT_PLUGIN,
+ SYNCML_DM_COMMIT_PLUGIN
+ };
+
+DMPluginManager::DMPluginManager()
+ : m_pTree( NULL )
+{
+}
+
+DMPluginManager::~DMPluginManager()
+{
+ for( DMMap<DMString,XPL_DL_HANDLE_T>::POS pos = m_pluginLibs.begin();
+ pos != m_pluginLibs.end(); pos++ )
+ {
+ XPL_DL_Unload(m_pluginLibs.get_value(pos));
+ }
+}
+
+
+XPL_DL_HANDLE_T
+DMPluginManager::LoadLib(CPCHAR libName)
+{
+ XPL_DL_HANDLE_T handle;
+ if ( m_pluginLibs.lookup(libName, handle) == TRUE )
+ return handle;
+
+ handle = XPL_DL_Load(libName);
+ m_pluginLibs.put(DMString(libName), handle);
+
+ return handle;
+}
+
+
+#ifndef DM_STATIC_PLUGINS
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::LoadDirectory(CPCHAR szPath)
+{
+ SYNCML_DM_RET_STATUS_T status=SYNCML_DM_SUCCESS;
+
+ XPL_FS_SHANDLE_T search_handle;
+ XPL_FS_RET_STATUS_T fs_result;
+ char file_name[XPL_FS_MAX_FILE_NAME_LENGTH];
+
+ XPL_LOG_DM_PLG_Debug(("Loading %s\n", szPath));
+ search_handle = XPL_FS_StartSearch(szPath, "ini", TRUE, &fs_result);
+ if ( search_handle == XPL_FS_SHANDLE_INVALID)
+ return SYNCML_DM_IO_FAILURE;
+
+ //Loop through all .ini files in the directory
+ while ( XPL_FS_GetSearchResult(search_handle,file_name) != XPL_FS_RET_NOT_FOUND )
+ {
+ status=LoadPluginFile(file_name);
+ }
+ XPL_FS_EndSearch(search_handle);
+ return status;
+}
+#endif
+
+
+SYNCML_DM_PLUGIN_TYPE_T
+DMPluginManager::CheckPlugin(DMStringMap & aMap,
+ CPCHAR filePath,
+ CPCHAR pluginName,
+ SYNCML_DM_PLUGIN_TYPE_T type)
+{
+ SYNCML_DM_PLUGIN_TYPE_T mask = 0;
+
+ DMString strName;
+
+ if (aMap.lookup(pluginName, strName))
+ {
+#ifndef DM_STATIC_PLUGINS
+ /* CPCHAR szName=strName.c_str();
+ DMString newPath;
+ if ( *szName != '/') //only relative path
+ {
+ newPath=filePath;
+ newPath +="/";
+ newPath +=strName;
+ aMap.put(pluginName, newPath);
+ szName=newPath.c_str();
+ } */
+ mask = mask | type;
+#else
+ mask = mask | type;
+#endif
+ }
+ return mask;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::UpdatePluginNodes(CPCHAR szRootPath)
+{
+ SYNCML_DM_RET_STATUS_T res=SYNCML_DM_SUCCESS;
+ XPL_LOG_DM_PLG_Debug(("UpdatePluginNodes subTreeRootPath=%s\n", szRootPath));
+
+ INT32 size = m_dataPlugins.size();
+
+ DMAddNodeProp props;
+ for ( int i=0; i<size; i++ )
+ {
+ CPCHAR pluginPath = m_dataPlugins[i]->GetPath();
+
+ SyncML_DM_Archive* archive =m_pTree->GetArchiver().getArchiveByURI(pluginPath);
+ if ( DmStrcmp(szRootPath,archive->getURI()) == 0 )
+ {
+ res=MountNode(m_dataPlugins[i],props);
+ if ( res != SYNCML_DM_SUCCESS )
+ return res;
+ }
+ }
+ return res;
+}
+
+
+BOOLEAN
+DMPluginManager::IsMountPointEnabled(CPCHAR szPath) const
+{
+ INT32 size = m_oBlockedPlugins.size();
+ for (INT32 index = 0; index < size; index++)
+ {
+ const DMString & str = m_oBlockedPlugins[index];
+ if ( DmIsParentURI( str.c_str(), szPath ) )
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::AddPlugin(CPCHAR filename,
+ DMString & strPath,
+ DMStringMap & aMap)
+{
+ SYNCML_DM_RET_STATUS_T status=SYNCML_DM_SUCCESS;
+ PDMPlugin pPlugin;
+
+ BOOLEAN bFeatureEnabled = TRUE;
+ bFeatureEnabled = this->IsMountPointEnabled(strPath);
+ if ( bFeatureEnabled == TRUE )
+ bFeatureEnabled = DmIsEnabledURI(strPath);
+
+ if ( bFeatureEnabled == FALSE )
+ {
+ m_oBlockedPlugins.push_back(strPath);
+ return SYNCML_DM_SUCCESS;
+ }
+
+#ifndef DM_STATIC_PLUGINS
+ CPCHAR ptr = NULL;
+ INT32 len=0;
+
+ if( !m_pTree ) return SYNCML_DM_FAIL;
+
+ ptr=DmStrrchr(filename, '/');
+ if (ptr != NULL)
+ len=(INT32)(ptr-filename);
+ DMString strFilePath(filename, len);
+#else
+ CPCHAR strFilePath = NULL;
+#endif
+
+
+ SYNCML_DM_PLUGIN_TYPE_T type=0;
+ BOOLEAN bOverlayPlugin = FALSE;
+
+ type = CheckPlugin(aMap, strFilePath, PLUGIN_DATA_NAME, SYNCML_DM_DATA_PLUGIN);
+
+ if ( CheckPlugin(aMap, strFilePath, PLUGIN_DATA_OVERLAY_NAME, SYNCML_DM_DATA_PLUGIN) ){
+ // check if it's already a data
+ if ( (type & SYNCML_DM_DATA_PLUGIN) != 0 ){
+ XPL_LOG_DM_PLG_Error(("Plugin can be either data or overlay but not both"));
+ return SYNCML_DM_INVALID_PARAMETER;
+ }
+
+ type = type | SYNCML_DM_DATA_PLUGIN;
+ bOverlayPlugin = TRUE;
+ }
+
+ type = type | CheckPlugin(aMap, strFilePath, PLUGIN_EXECUTE_NAME, SYNCML_DM_EXECUTE_PLUGIN);
+ type = type | CheckPlugin(aMap, strFilePath, PLUGIN_CONSTRAINT_NAME, SYNCML_DM_CONSTRAINT_PLUGIN);
+ type = type | CheckPlugin(aMap, strFilePath, PLUGIN_COMMIT_NAME, SYNCML_DM_COMMIT_PLUGIN);
+
+ if (type == 0)
+ return status;
+
+ /*
+ DMString strKeyTmp = "_exec";
+ DMString strValueTmp;
+ if (aMap.lookup(strKeyTmp, strValueTmp))
+ {
+ XPL_LOG_DM_PLG_Debug(("new plugin %s=%s\n", strKeyTmp.c_str(), strValueTmp.c_str()));
+ }
+ strKeyTmp = "_data";
+ if (aMap.lookup(strKeyTmp, strValueTmp))
+ {
+ XPL_LOG_DM_PLG_Debug(("new plugin %s=%s\n", strKeyTmp.c_str(), strValueTmp.c_str()));
+ }
+ */
+ pPlugin=new DMPlugin(type, bOverlayPlugin, strPath, aMap);
+
+ if ( pPlugin == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+#ifndef DM_STATIC_PLUGINS
+ //Add plugin into file collections
+ DMString strFilename(filename);
+ DMPluginVector vector;
+ if ( m_mapFilePluginVectors.lookup(strFilename, vector))
+ {
+ vector.push_back(pPlugin);
+ } else
+ {
+ vector.push_back(pPlugin);
+ m_mapFilePluginVectors.put(strFilename, vector);
+ }
+#endif
+
+
+ XPL_LOG_DM_PLG_Debug(("Add plug-in %s\n",strPath.c_str()));
+ //Add plugin into all typed collections
+ for (int i=0; i<MAX_PLUGINTYPES;i++)
+ {
+ if ((type & (1<<i)) != 0 )
+ {
+ DMPluginVector * pPlugins = GetPlugins(m_nIndex[i]);
+ pPlugins->push_back(pPlugin);
+ }
+ }
+
+#ifndef DM_STATIC_PLUGINS
+// if ((type & SYNCML_DM_DATA_PLUGIN) != 0)
+// {
+// if (m_pTree->GetRootNode() )
+// {
+// DMAddNodeProp props;
+// MountNode(pPlugin,props);
+// }
+// }
+
+ if ((type & SYNCML_DM_COMMIT_PLUGIN) != 0)
+ {
+ DMString strEvent;
+ if (!aMap.lookup("_event", strEvent))
+ strEvent = "Add&Replace&Delete&Indirect&Detail";
+ pPlugin->Set(strEvent);
+ }
+#endif
+ return status;
+}
+
+
+/*
+#ifndef DM_STATIC_PLUGINS
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::removePlugin(PDMPlugin & plugin)
+{
+ SYNCML_DM_RET_STATUS_T status=SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_PLG_Debug(("DMPluginManager::removePlugin %s\n", (CPCHAR)plugin->GetPath()));
+
+ for (int i=0; i<MAX_PLUGINTYPES;i++)
+ {
+ DMPluginVector * pPlugins = GetPlugins(m_nIndex[i]);
+ INT32 index = pPlugins->find(plugin);
+ if ( index != -1 )
+ pPlugins->remove(index);
+ }
+
+ SYNCML_DM_PLUGIN_TYPE_T type = plugin->GetPluginType();
+
+ if ((type & SYNCML_DM_DATA_PLUGIN) != 0)
+ UnmountNode(plugin);
+
+ return status;
+}
+#endif
+*/
+
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::LoadPluginFile(CPCHAR filename)
+{
+ SYNCML_DM_RET_STATUS_T ret_status=SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_PLG_Debug(("DMPluginManager::LoadPluginFile %s\n", filename));
+
+ DMFileHandler fileHandler(filename);
+ ret_status = fileHandler.open(XPL_FS_FILE_READ);
+ if ( ret_status != SYNCML_DM_SUCCESS)
+ return ret_status;
+
+ DMString strLineBuffer;
+ char *line = strLineBuffer.AllocateBuffer(DM_MAX_CONFIG_LINE);
+ DMString strSectionName;
+ DMStringMap nvMap;
+
+ if ( !line )
+ return SYNCML_DM_DEVICE_FULL;
+
+ while(!fileHandler.iseof())
+ {
+ fileHandler.fgets((char *)line, DM_MAX_CONFIG_LINE);
+
+ //Skip '#' and empty string
+ if ( line[0]=='#' || line[0] == '\0' )
+ continue;
+
+ ret_status = ParseLine(filename, line, strSectionName, nvMap);
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+
+ }
+
+ if ( strSectionName.length() >0 )
+ {
+ AddPlugin( filename, strSectionName, nvMap );
+ nvMap.clear();
+ }
+ fileHandler.close();
+
+ return ret_status;
+}
+
+
+#ifdef DM_STATIC_FILES
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::LoadPluginFile(UINT8 * pBuffer, UINT32 size)
+{
+ SYNCML_DM_RET_STATUS_T ret_status=SYNCML_DM_SUCCESS;
+
+ XPL_LOG_DM_PLG_Debug(("DMPluginManager::LoadPluginFile\n"));
+
+ DMBufferReader bufferHandler(pBuffer,size);
+
+ char * line;
+ DMString strSectionName;
+ DMStringMap nvMap;
+
+ while(!bufferHandler.iseof())
+ {
+ line = bufferHandler.fgets();
+ if ( line == NULL )
+ return SYNCML_DM_FAIL;
+
+ ret_status = ParseLine(NULL, line, strSectionName, nvMap);
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+ }
+
+ if ( strSectionName.length() >0 )
+ {
+ DMAddNodeProp props;
+ AddPlugin(NULL, strSectionName, nvMap );
+ nvMap.clear();
+ }
+ return ret_status;
+}
+#endif
+
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::ParseLine(CPCHAR szFileName,
+ CPCHAR szLine,
+ DMString &strSectionName,
+ DMStringMap &aMap)
+{
+ SYNCML_DM_RET_STATUS_T ret_status;
+ INT32 len = 0;
+
+ if ( szLine[0] == '[' )
+ {
+ // Finish previous section
+ if ( strSectionName.length() >0 )
+ {
+ ret_status = AddPlugin(szFileName, strSectionName, aMap );
+ aMap.clear();
+ strSectionName="";
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+ }
+
+ len = DmStrlen(szLine);
+ if ( len == 0 || szLine[len-1] != ']' || len == 2 )
+ return SYNCML_DM_FAIL;
+
+ strSectionName.assign(&szLine[1],len-2);
+ }
+ else //read a line not starting with [
+ {
+ if ( strSectionName.length() == 0 )
+ return SYNCML_DM_SUCCESS;
+
+ DMString name;
+ DMString value;
+
+ char * ptr = (char*)DmStrchr(szLine,'=');
+
+ if ( ptr != NULL )
+ {
+ if ( ptr == szLine )
+ return SYNCML_DM_FAIL;
+
+ len = ptr-szLine;
+ while ( len > 0 && szLine[len-1] == ' ' )
+ len--;
+
+ name.assign(szLine,len);
+
+ ptr++;
+ while (*ptr == ' ' && *ptr != '\0' )
+ ptr++;
+
+ if ( *ptr == '\0' )
+ return SYNCML_DM_FAIL;
+
+ value = ptr;
+ }
+ else
+ name = szLine;
+
+
+ aMap.put(name, value);
+ }
+
+ return SYNCML_DM_SUCCESS;
+ }
+
+
+void
+DMPluginManager::DeInit()
+{
+ XPL_LOG_DM_PLG_Debug(("DMPluginManager::DeInit\n"));
+
+ m_dataPlugins.clear();
+ m_constPlugins.clear();
+ m_execPlugins.clear();
+ m_commPlugins.clear();
+
+#ifndef DM_STATIC_PLUGINS
+ m_mapFilePluginVectors.clear();
+#endif
+ m_pTree = NULL;
+}
+
+
+DMPluginVector *
+DMPluginManager::GetPlugins(SYNCML_DM_PLUGIN_TYPE_T type)
+{
+ switch ( type )
+ {
+ case SYNCML_DM_DATA_PLUGIN:
+ return &m_dataPlugins;
+
+ case SYNCML_DM_EXECUTE_PLUGIN:
+ return &m_execPlugins;
+
+ case SYNCML_DM_CONSTRAINT_PLUGIN:
+ return &m_constPlugins;
+
+ case SYNCML_DM_COMMIT_PLUGIN:
+ return &m_commPlugins;
+
+ default:
+ return NULL;
+ }
+}
+
+
+BOOLEAN
+DMPluginManager::PathMatch(CPCHAR szNodePath, CPCHAR szPluginPath)
+{
+ /* szNodePath must NOT contain "*"
+ * szPluginPath may contain "*" */
+ BOOLEAN matched=FALSE;
+
+ CPCHAR ptr = szNodePath;
+ CPCHAR ptr1 = szPluginPath;
+
+ while ( TRUE )
+ {
+ if ( *ptr1 == '\0' )
+ {
+ matched = TRUE;
+ return matched;
+ }
+
+ if ( *ptr1 == '*')
+ break;
+
+ if (* ptr == '\0' || *ptr != * ptr1)
+ {
+ matched = FALSE;
+ return matched;
+ }
+ ptr++;
+ ptr1++;
+ }
+
+ //Now there is * in ptr1;
+ ptr1++;
+ if ( DmStrstr(ptr, ptr1) != NULL)
+ {
+ matched = TRUE;
+ return matched;
+ }
+
+ return matched;
+}
+
+PDMPlugin
+DMPluginManager::FindPlugin(SYNCML_DM_PLUGIN_TYPE_T type, CPCHAR szPath)
+{
+ XPL_LOG_DM_PLG_Debug(("DMPluginManager::FindPlugin, type=%d path=%s\n", type, szPath));
+ DMPluginVector * pPlugins = GetPlugins(type);
+ INT32 size = pPlugins->size();
+ for (int i = 0; i<size; i++)
+ {
+ CPCHAR szPluginPath = (*pPlugins)[i]->GetPath();
+ if ( PathMatch(szPath, szPluginPath ) )
+ return (*pPlugins)[i];
+ }
+ return NULL;
+}
+
+
+PDMPlugin
+DMPluginManager::FindCommitPlugin(CPCHAR szPath)
+{
+ for (int i = 0; i<m_commPlugins.size(); i++)
+ {
+ if ( (m_commPlugins[i])->GetPath() == szPath )
+ return m_commPlugins[i];
+ }
+ return NULL;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::MountNode(PDMPlugin & plugin, DMAddNodeProp & oNodeProps)
+{
+ SYNCML_DM_RET_STATUS_T ret=SYNCML_DM_SUCCESS;
+
+ if( !m_pTree ) return SYNCML_DM_FAIL;
+
+ CPCHAR szRootPath = plugin->GetPath();
+ DMNode *pParent = m_pTree->FindNodeByURI(szRootPath);
+
+ if ( plugin->IsOveralyPlugin() )
+ {
+ if ( !pParent || pParent->getFormat() != SYNCML_DM_FORMAT_NODE || pParent->IsOverlayPI())
+ return SYNCML_DM_SUCCESS; // no mount point or invalid type
+
+ DMOverlayPINode* pNewNode = new DMOverlayPINode( plugin, pParent );
+
+ if ( !pNewNode )
+ return SYNCML_DM_DEVICE_FULL;
+
+ m_pTree->SubstituteNode( pParent, pNewNode );
+
+ delete pParent;
+
+ return SYNCML_DM_SUCCESS;
+ }
+
+ if ( pParent )
+ return SYNCML_DM_SUCCESS;
+
+ DMURI oURI(TRUE,szRootPath);
+
+ if ( oURI.getBuffer() == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ CPCHAR lastSegtment = oURI.getLastSegment();
+ CPCHAR parentURI = oURI.getParentURI();
+
+ if ( parentURI == NULL )
+ {
+ XPL_LOG_DM_PLG_Error(("MountNode : unable to get parent\n"));
+ return SYNCML_DM_FAIL;
+ }
+
+ ret = oNodeProps.set(lastSegtment,NULL,SYNCML_DM_FORMAT_INVALID,NULL,0,NULL,DMNode::enum_NodePlugin);
+
+
+ DMNode* node = new DMPluginRootNode(plugin);
+
+ if ( node == NULL )
+ {
+ XPL_LOG_DM_PLG_Error(("MountNode : unable allocate memory\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ pParent = m_pTree->FindNodeByURI( parentURI );
+
+ if ( !pParent )
+ {
+ XPL_LOG_DM_PLG_Error(("MountNode : cannot find node by URI: %s\n",parentURI));
+ delete node;
+ return SYNCML_DM_FAIL;
+ }
+
+ /* Add the node to the tree */
+ /* the format of the node is unknown here */
+ ret = m_pTree->AddNode( &pParent, oNodeProps, node);
+ if ( ret != SYNCML_DM_SUCCESS )
+ {
+ XPL_LOG_DM_PLG_Error(("Add plugin node failed for %s, ret=%d\n", szRootPath, ret));
+ }
+
+ return ret;
+}
+
+
+
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::Init( CEnv* env, DMTree* tree )
+{
+ SYNCML_DM_RET_STATUS_T ret_status=SYNCML_DM_SUCCESS;
+
+ if( !env || !tree ) return SYNCML_DM_FAIL;
+
+ m_pTree = tree;
+
+#ifndef DM_STATIC_PLUGINS
+ DMString dstdir = XPL_DM_GetEnv(SYNCML_DM_PLUGINS_PATH);
+ if (dstdir == NULL)
+ dstdir=".";
+
+ ret_status = LoadDirectory(dstdir);
+ if ( ret_status != SYNCML_DM_SUCCESS )
+ return ret_status;
+
+ env->GetWFSFullPath("plugins",dstdir);
+ LoadDirectory(dstdir);
+#else
+#ifdef DM_STATIC_FILES
+ UINT32 size;
+ UINT8 *pBuffer = (UINT8*)XPL_DM_GetPluginsConfig(&size);
+ if ( pBuffer )
+ ret_status = LoadPluginFile(pBuffer,size);
+#else
+ DMString sPluginsINI;
+
+ env->GetMainRFSFullPath(DM_PLUGINS_INI_FILENAME,sPluginsINI);
+ LoadPluginFile(sPluginsINI);
+#endif
+#endif
+
+ return ret_status;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMPluginManager::CheckPluginAging(INT32 nAgingTime)
+{
+ XPL_LOG_DM_PLG_Debug(("CheckPluginAging: nAgingTime: %d\n", nAgingTime));
+ XPL_CLK_CLOCK_T currentTime = XPL_CLK_GetClock();
+ INT32 j,i = 0;
+
+ for (j=0; j<MAX_PLUGINTYPES; j++)
+ {
+ DMPluginVector * pPlugins = GetPlugins(m_nIndex[j]);
+ for (i = 0; i < pPlugins->size(); i++)
+ {
+ XPL_CLK_CLOCK_T lastAccessed = (*pPlugins)[i]->GetLastAccessedTime();
+ if ( (currentTime - lastAccessed) >= (XPL_CLK_CLOCK_T)nAgingTime && (*pPlugins)[i]->IsSymbolsLoaded() )
+ {
+ (*pPlugins)[i]->UnloadSymbols();
+ }
+ }
+ }
+
+
+ for( DMMap<DMString,XPL_DL_HANDLE_T>::POS pos = m_pluginLibs.end()-1;
+ pos >= m_pluginLibs.begin(); pos-- )
+ {
+ BOOLEAN bIsFound = FALSE;
+ for (j=0; j<MAX_PLUGINTYPES; j++)
+ {
+ DMPluginVector * pPlugins = GetPlugins(m_nIndex[j]);
+
+ for (i = 0; i < pPlugins->size(); i++)
+ {
+ if ( (*pPlugins)[i]->IsLibReleased(m_pluginLibs.get_value(pos)) == TRUE )
+ bIsFound = TRUE;
+ }
+ }
+ if ( bIsFound == FALSE )
+ {
+ XPL_DL_Unload(m_pluginLibs.get_value(pos));
+ m_pluginLibs.remove(m_pluginLibs.get_key(pos));
+ }
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+void
+DMPluginManager::GetPlugins(CPCHAR szPath,
+ SYNCML_DM_PLUGIN_TYPE_T type,
+ DMPluginVector& aPlugins )
+{
+ const DMPluginVector* pArray = GetPlugins(type);
+
+ DMString strURI = szPath;
+ for (INT32 i = 0; i < pArray->size(); i++ )
+ {
+ if ( DmIsParentURI(strURI.c_str(), (*pArray)[i]->GetPath() ) )
+ {
+ aPlugins.push_back( (*pArray)[i] );
+ }
+ }
+ XPL_LOG_DM_PLG_Debug(("GetPlugins, szURI:%s\n", szPath));
+}
diff --git a/engine/dmlib/plugin/src/dmtPlugin.cc b/engine/dmlib/plugin/src/dmtPlugin.cc
new file mode 100644
index 0000000..dc7e392
--- /dev/null
+++ b/engine/dmlib/plugin/src/dmtPlugin.cc
@@ -0,0 +1,715 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The dmtPlugin.cc file contains helper classes implementation
+ * of plug-in API
+ */
+
+#include "jem_defs.hpp"
+#include "dmt.hpp"
+#include "dmMemory.h"
+#include "xpl_Logger.h"
+#include "dmtPlugin.hpp"
+#include "dm_tree_class.H"
+
+//////////////////////////////////////////////////////////////////
+// overlay plug-in support
+SYNCML_DM_RET_STATUS_T DmtAPIPluginTree::OnAdd( CPCHAR path, DmtOverlayPluginData& data )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtAPIPluginTree::OnDelete( CPCHAR path )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtAPIPluginTree::Synchronize( const char* path, DMVector<DmtOverlayPluginSyncData>& data )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+void DmtAPIPluginTree::Release()
+{
+ m_oAddedNodes.clear();
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtAPIPluginTree::Flush()
+{
+ m_oAddedNodes.clear();
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtAPIPluginTree::FindAddedNode(CPCHAR path)
+{
+ INT32 index;
+ DMString pathTmp;
+
+ for (index = 0; index < m_oAddedNodes.size(); index++)
+ {
+ m_oAddedNodes[index]->GetPath(pathTmp);
+ if ( pathTmp == path )
+ return SYNCML_DM_SUCCESS;
+ }
+
+ return SYNCML_DM_NOT_FOUND;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtAPIPluginTree::FindAddedParentNode(CPCHAR path)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_NOT_FOUND;
+
+ if ( path == NULL)
+ return dm_stat;
+
+ DMString pStr = path;
+ char * pParent = (char*)DmStrrchr(pStr,'/');
+ if ( pParent != 0 )
+ {
+ *pParent = '\0';
+ while ( pParent != NULL )
+ {
+ dm_stat = FindAddedNode(pStr);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ return dm_stat;
+ pParent = (char*)DmStrrchr(pStr,'/');
+ if ( pParent )
+ *pParent = '\0';
+ }
+ }
+ return dm_stat;
+
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtAPIPluginTree::SetAddedNode(PDmtNode ptrNode)
+{
+ m_oAddedNodes.push_back(ptrNode);
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtAPIPluginTree::RemoveAddedNode(CPCHAR path)
+{
+ INT32 index;
+ INT32 size = m_oAddedNodes.size();
+ INT32 length = DmStrlen(path);
+ DMString pathTmp;
+
+ for (index = size-1; index >= 0; index--)
+ {
+ m_oAddedNodes[index]->GetPath(pathTmp);
+ if ( DmStrncmp(path,pathTmp,length) == 0 )
+ m_oAddedNodes.remove(index);
+ }
+ return SYNCML_DM_SUCCESS;
+
+}
+
+BOOLEAN DmtAPIPluginTree::SetPrincipal(CPCHAR strPrincipal)
+{
+ m_Principal.assign(strPrincipal);
+ return TRUE;
+}
+
+DmtPrincipal DmtAPIPluginTree::GetPrincipal() const
+{
+ return m_Principal;
+}
+
+// this function should be called only from the plug-in "getNode" function;
+// returns cached PDs and metaNodeID (or -1 if not set) for the current node.
+extern "C" const DmtOPINodeData* DmtGetCachedOPINodeData()
+{
+ return dmTreeObj.GetCachedOPINodeData();
+}
+
+extern "C" SYNCML_DM_RET_STATUS_T DmtSetOPINodeData( CPCHAR szURI, const DmtOverlayPluginData& oData )
+{
+ return dmTreeObj.SetOPINodeData(szURI, oData);
+}
+
+
+
+//////////////////////////////////////////////////////////////////
+//
+// DmtPluginTree
+// In this Plugin Tree, we main tain code relationship
+//
+// All path are local
+// node paths are
+//
+// "" -- root node
+// "L1" -- child node under root node
+// "L1/L2" -- sub children
+//
+DmtPluginTree::DmtPluginTree()
+{
+ XPL_LOG_DM_PLG_Debug(("DmtPluginTree::DmtPluginTree()"));
+}
+
+DmtPluginTree::~DmtPluginTree()
+{
+ Release();
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::Init( CPCHAR rootNodePath )
+{
+ m_strRootPath=rootNodePath;
+ if ( rootNodePath && rootNodePath[0] )
+ {
+ if ( m_strRootPath == NULL )
+ {
+ XPL_LOG_DM_PLG_Debug(("DmtPluginTree::Init() SYNCML_DM_DEVICE_FULL\n"));
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::GetFullPath(CPCHAR path, DMString & fullPath) const
+{
+ path = DmtGetSafeStrPtr( path );
+ fullPath = m_strRootPath;
+
+ if ( path[0] == '/' )
+ fullPath += path;
+ else
+ {
+ fullPath += "/";
+ fullPath += path;
+ }
+
+ if ( path[0] != 0 )
+ return SYNCML_DM_SUCCESS;
+
+ // remove trailing '/'
+ INT32 nLen = fullPath.length();
+
+ if ( nLen == 0 )
+ {
+ fullPath = ".";
+ return SYNCML_DM_SUCCESS;
+ }
+
+ if ( fullPath[nLen-1] == '/' )
+ fullPath.SetAt(nLen-1,0);
+
+ return SYNCML_DM_SUCCESS;
+}
+
+//
+//DmtPluginTree and DmtPluginNode all uses DmtPluginTree::GetNode
+//
+SYNCML_DM_RET_STATUS_T DmtPluginTree::GetNode(CPCHAR path,
+ PDmtNode& ptrNode )
+{
+ DMString strPath(path);
+
+ BOOLEAN result= FALSE;
+
+ result= m_Nodes.lookup(strPath, ptrNode);
+ XPL_LOG_DM_PLG_Debug(("GetNode lookup for %s=%d\n", path, result));
+ if (!result)
+ return SYNCML_DM_NOT_FOUND;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::GetChildNodeNames(
+ CPCHAR path,
+ DMStringVector & aChildren )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ XPL_LOG_DM_PLG_Debug(("GetChildNodeNames lookup for %s\n", path));
+ PDmtNode ptrNode;
+ DmtData oData;
+
+ dm_stat = GetNode( path, ptrNode);
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_PLG_Debug(("GetNode err=%d\n", dm_stat));
+ return dm_stat;
+ }
+
+ dm_stat = ptrNode->GetValue( oData );
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ XPL_LOG_DM_PLG_Debug(("GetValue err=%d\n", dm_stat));
+ return dm_stat;
+ }
+
+ if (oData.GetType() != SYNCML_DM_DATAFORMAT_NODE )
+ return SYNCML_DM_FAIL;
+
+ dm_stat = oData.GetNodeValue( aChildren );
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::DeleteNode( CPCHAR path )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::RenameNode( CPCHAR path,
+ CPCHAR szNewNodeName )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::CreateLeafNode( CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+SYNCML_DM_RET_STATUS_T DmtPluginTree::CreateLeafNode(CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value ,
+ BOOLEAN isESN)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::CreateInteriorNode( CPCHAR path,
+ PDmtNode& ptrCreatedNode )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::Clone(CPCHAR path,
+ CPCHAR szNewNodename)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::GetChildValuesMap( CPCHAR path,
+ DMMap<DMString, DmtData>& mapNodes )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::SetChildValuesMap( CPCHAR path,
+ const DMMap<DMString, DmtData>& mapNodes )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::Flush()
+{
+ return DmtAPIPluginTree::Flush();
+}
+
+BOOLEAN DmtPluginTree::IsAtomic() const
+{
+ return FALSE;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::Begin()
+{
+ #ifdef DM_ATOMIC_SUPPORTED
+ return SYNCML_DM_SUCCESS;
+ #else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ #endif
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::Commit()
+{
+ #ifdef DM_ATOMIC_SUPPORTED
+ return SYNCML_DM_SUCCESS;
+ #else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ #endif
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::Rollback()
+{
+ #ifdef DM_ATOMIC_SUPPORTED
+ return SYNCML_DM_SUCCESS;
+ #else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ #endif
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::Verify()
+{
+ //For future expansion. Currently not used
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::GetParameter(CPCHAR name,
+ DMString & value)
+{
+ DMPluginManager & oPluginManager = dmTreeObj.GetPluginManager();
+
+ PDMPlugin pPlugin = oPluginManager.FindPlugin(SYNCML_DM_DATA_PLUGIN, m_strRootPath.c_str());
+ XPL_LOG_DM_PLG_Debug(("GetParameter name=%s\n", name));
+
+ DMStringMap maps=pPlugin->GetParameters();
+ DMString strName=name;
+
+ return maps.lookup(strName, value) ? SYNCML_DM_SUCCESS : SYNCML_DM_NOT_FOUND;
+}
+
+//
+// Helper set Functions for shared library developer to use
+//
+SYNCML_DM_RET_STATUS_T DmtPluginTree::SetNode(CPCHAR path,
+ PDmtNode node)
+{
+ m_Nodes.put(path, node);
+ XPL_LOG_DM_PLG_Debug(("Set Node for %s\n", path));
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::RemoveNode(CPCHAR path)
+{
+ m_Nodes.remove(path);
+ XPL_LOG_DM_PLG_Debug(("Remove Node %s\n", path));
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginTree::ClearNodes()
+{
+ m_Nodes.clear();
+ return SYNCML_DM_SUCCESS;
+}
+
+void DmtPluginTree::Release()
+{
+ DmtAPIPluginTree::Release();
+ m_Nodes.clear();
+}
+
+//
+// DmtPluginNode
+//
+
+DmtPluginNode::DmtPluginNode()
+{
+ m_bLeaf = FALSE;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::InitAttributes(SYNCML_DM_DATAFORMAT_T type)
+{
+
+ if (type == SYNCML_DM_DATAFORMAT_NODE)
+ m_bLeaf = FALSE;
+ else
+ m_bLeaf = TRUE;
+
+ DMString strFormat;
+ if (type<0 ||DMTree::ConvertFormat(type, strFormat) != SYNCML_DM_SUCCESS)
+ {
+ strFormat = "node";
+ }
+
+ return m_oAttr.Set(m_strName,strFormat.c_str(),"","text/plain",0,0,JemDate(),DmtAcl());
+}
+
+
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::Init(PDmtPluginTree ptrTree,
+ CPCHAR path)
+{
+ DMString fullPath; // DP: since this string is used all over the function ('name' pointer), moved declaration to the up
+
+ m_ptrTree=ptrTree;
+ m_strName = NULL;
+ m_strPath = NULL;
+ m_bESN = FALSE;
+ if ( path && path[0] )
+ {
+ m_strPath=path;
+ if ( m_strPath == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ m_bLeaf=FALSE;
+
+ //Name starts with relative PATH ONLY ?
+ if ( path )
+ {
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ CPCHAR name = DmStrrchr(m_strPath.c_str(), '/');
+
+ if (name != NULL)
+ name++;
+ else
+ {
+ if (path[0] != 0)
+ name=m_strPath.c_str();
+ else // relative path is NULL, use last part of root node name
+ {
+ dm_stat = ptrTree->GetFullPath(path,fullPath);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ name=DmStrrchr(fullPath.c_str(), '/');
+ if (name != NULL)
+ name++;
+ }
+ }
+ }
+ if ( name )
+ {
+ m_strName = name;
+ if ( m_strName == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::Init(PDmtPluginTree ptrTree,
+ CPCHAR path,
+ BOOLEAN isleaf)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ dm_stat = Init(ptrTree,path);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ XPL_LOG_DM_PLG_Debug(("DmtPluginNode::Init, %s, type=%d\n", m_strPath.c_str(), m_oData.GetType()));
+
+ if (isleaf) // derived class needs to override this for special formats (INT, BINARY, etc)
+ return InitAttributes(SYNCML_DM_DATAFORMAT_STRING);
+ else
+ return InitAttributes(SYNCML_DM_DATAFORMAT_NODE);
+
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::Init(PDmtPluginTree ptrTree,
+ CPCHAR path,
+ const DmtData & oData,
+ BOOLEAN isESN)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ INT32 dataSize = 0;
+ SYNCML_DM_DATAFORMAT_T type = oData.GetType();
+
+ dm_stat = Init(ptrTree,path);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ m_bESN = isESN;
+
+ if(m_bESN)
+ {
+ if (type == SYNCML_DM_DATAFORMAT_NULL ||
+ type == SYNCML_DM_DATAFORMAT_INT ||
+ type == SYNCML_DM_DATAFORMAT_UNDEFINED)
+ type = SYNCML_DM_DATAFORMAT_STRING;
+ }
+
+ dm_stat = m_oData.Set(oData);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ XPL_LOG_DM_PLG_Debug(("DmtPluginNode::Init, %s, type=%d\n", m_strPath.c_str(), m_oData.GetType()));
+ dm_stat = InitAttributes(type);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ // Get data size
+ if(!m_bESN)
+ {
+ dm_stat = m_oData.GetSize(dataSize);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+ m_oAttr.SetSize(dataSize);
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::Init(PDmtPluginTree ptrTree,
+ CPCHAR path,
+ const DMStringVector & childNodeNames)
+{
+
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ dm_stat = Init(ptrTree,path);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+
+ dm_stat = m_oData.SetNodeValue(childNodeNames);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ XPL_LOG_DM_PLG_Debug(("DmtPluginNode::Init, %s, type=%d\n", m_strPath.c_str(), m_oData.GetType()));
+
+ return InitAttributes(m_oData.GetType());
+
+}
+
+
+DmtPluginNode::~DmtPluginNode()
+{
+// XPL_LOG_DM_PLG_Debug(("DmtPluginNode::~DmtPluginNode, %s, type=%d\n", m_strPath.c_str(), m_oData.GetType()));
+ m_ptrTree =NULL;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::GetTree( PDmtTree& ptrTree ) const
+{
+ ptrTree = PDmtTree(m_ptrTree.GetPtr());
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::GetPath(DMString & path) const
+{
+ path = m_strPath;
+ if ( m_strPath != NULL && path == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::GetAttributes( DmtAttributes& oAttr ) const
+{
+ return oAttr.Set(m_oAttr);
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::SetTitle( CPCHAR szTitle )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::SetAcl( const DmtAcl& oAcl )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::GetValue( DmtData& oData ) const
+{
+ XPL_LOG_DM_PLG_Debug(("DmtPluginNode::GetValue, this=0x%x %s, type=%d\n", this, m_strPath.c_str(), m_oData.GetType()));
+ return oData.Set(m_oData);
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::SetValue( const DmtData& value )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+BOOLEAN DmtPluginNode::IsLeaf() const
+{
+ return m_bLeaf;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::GetChildNode( CPCHAR szPath, PDmtNode& ptrNode )
+{
+ if ( m_bLeaf )
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+
+ DMString oChildPath(m_strPath);
+ oChildPath +="/";
+ oChildPath += DmtGetSafeStrPtr( szPath );
+ return m_ptrTree->GetNode(oChildPath.c_str(), ptrNode);
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::Execute( CPCHAR strData, DMString& result )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::GetNodeName(DMString & name) const
+{
+ name = m_strName;
+ if ( m_strName != NULL && name == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::Rename( CPCHAR szNewName )
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::GetChildNodes( DMVector<PDmtNode>& oChildren ) const
+{
+ XPL_LOG_DM_PLG_Debug(("GetChildNodes for %s\n", m_strPath.c_str()));
+
+ oChildren.clear(); // remove all previous items from array
+
+ if ( m_bLeaf )
+ return SYNCML_DM_FAIL;
+
+ DmtData oData;
+
+ SYNCML_DM_RET_STATUS_T dm_stat = GetValue( oData );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ const DMStringVector & aChildren = oData.GetNodeValue();
+
+ XPL_LOG_DM_PLG_Debug(("aChildren.size()=%d\n", aChildren.size()));
+
+ for ( INT32 i = 0; i < aChildren.size(); i++ )
+ {
+ DMString strChildPath = m_strPath;
+
+ if (strChildPath.length() != 0)
+ strChildPath += "/";
+ strChildPath += aChildren[i];
+
+ PDmtNode ptrNode;
+
+ XPL_LOG_DM_PLG_Debug(("Get child[%d], path=%s\n", i, strChildPath.c_str()));
+ dm_stat = m_ptrTree->GetNode( strChildPath.c_str(), ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ oChildren.push_back( ptrNode );
+ }
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::GetFirstChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::GetNextChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::SetFirstChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::SetNextChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtPluginNode::SetLastChunk(DmtDataChunk& dmtChunkData)
+{
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
diff --git a/engine/dmlib/plugin/src/dmtRWPlugin.cc b/engine/dmlib/plugin/src/dmtRWPlugin.cc
new file mode 100644
index 0000000..23e4d4c
--- /dev/null
+++ b/engine/dmlib/plugin/src/dmtRWPlugin.cc
@@ -0,0 +1,1334 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dmMemory.h"
+#include "dmdefs.h"
+#include "dmt.hpp"
+#include "SyncML_PlugIn_WBXMLLog.H"
+#include "dmtRWPlugin.hpp"
+#include "xpl_File.h"
+#include "dm_uri_utils.h"
+#include "dm_tree_class.H"
+
+#ifdef TEST_DM_RECOVERY
+#include <unistd.h>
+extern char power_fail_point[];
+#endif
+
+DmtRWPluginTree::DmtRWPluginTree()
+{
+ fpLog = NULL;
+ log = NULL;
+ m_Playback = FALSE;
+ m_strLogPath = NULL;
+ m_ESNDirty = FALSE;
+ m_bIsAtomic = FALSE;
+}
+
+DmtRWPluginTree::~DmtRWPluginTree()
+{
+ if(fpLog != NULL)
+ delete fpLog;
+
+ if(this->log != NULL)
+ delete this->log;
+}
+
+SYNCML_DM_RET_STATUS_T
+DmtRWPluginTree::setLogFileHandle(DMFileHandler* fileHandle)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ if(this->log != NULL)
+ {
+ delete this->log;
+ this->log = NULL;
+ }
+ if(fpLog != NULL)
+ delete fpLog;
+
+ fpLog = fileHandle;
+ this->log = new SyncML_PlugIn_WBXMLLog(this,(CPCHAR) m_strRootPath.c_str());
+ if(this->log != NULL)
+ dm_stat = this->log->setLogFileHandle(fpLog);
+ else
+ dm_stat = SYNCML_DM_FAIL;
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T
+DmtRWPluginTree::InitLog ()
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ if(this->log != NULL)
+ return SYNCML_DM_SUCCESS;
+
+ if(m_strLogPath == NULL)
+ {
+ DMString file_name;
+ char uniqueStr[20];
+ XPL_CLK_LONG_CLOCK_T curTime = XPL_CLK_GetClockMs();
+ DmSprintf(uniqueStr, "%lld", curTime);
+ if(uniqueStr[0] == '-')
+ uniqueStr[0]='L';
+
+ dmTreeObj.GetWritableFileSystemFullPath( m_strLogPath );
+
+ CPCHAR pT = m_strLogPath.c_str();
+ if (pT[m_strLogPath.length()-1] != '/')
+ m_strLogPath += "/";
+
+ XPL_FS_MkDir(m_strLogPath);
+ m_strLogPath += uniqueStr;
+ m_strLogPath += ".log";
+ }
+ this->log = new SyncML_PlugIn_WBXMLLog(this,(CPCHAR) m_strRootPath.c_str());
+ if(this->log == NULL)
+ return SYNCML_DM_FAIL;
+ dm_stat = this->log->InitLog(m_strLogPath.c_str());
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DmtRWPluginTree::LogCommand(SYNCML_DM_PLUGIN_COMMAND_T type,
+ CPCHAR pbURI,
+ SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T attribute,
+ const DmtNode * inNode)
+{
+ if(m_Playback == TRUE)
+ return SYNCML_DM_SUCCESS;
+
+ SYNCML_DM_RET_STATUS_T dm_stat = InitLog();
+ if(this->log == NULL)
+ return dm_stat;
+
+ switch ( type )
+ {
+ case SYNCML_DM_PLUGIN_ADD:
+ dm_stat = log->logCommand(SYNCML_DM_PLUGIN_DELETE, pbURI, attribute, inNode);
+ break;
+
+ case SYNCML_DM_PLUGIN_REPLACE:
+ dm_stat = log->logCommand(SYNCML_DM_PLUGIN_REPLACE, pbURI, attribute, inNode);
+ break;
+
+ case SYNCML_DM_PLUGIN_DELETE:
+ if(DmStrlen(pbURI) != 0)
+ log->logCommand(SYNCML_DM_PLUGIN_ADD_CHILD, pbURI, attribute, inNode);
+ dm_stat = log->logCommand(SYNCML_DM_PLUGIN_ADD, pbURI, attribute, inNode);
+ break;
+ }
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::Verify()
+{
+ //@@@TODO
+ return SYNCML_DM_SUCCESS;
+}
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::CreateInteriorNodeInternal( CPCHAR path, PDmtNode& ptrCreatedNode, const DMStringVector & childNodeNames)
+{
+ PDmtRWPluginNode pNode;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ pNode = new DmtRWPluginNode();
+ if ( pNode == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ dm_stat = pNode->Init(this, path, childNodeNames);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = this->SetNode(path, PDmtNode(pNode));
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = GetNode( path, ptrCreatedNode );
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::CreateLeafNodeInternal( CPCHAR path, PDmtNode& ptrCreatedNode, const DmtData& value )
+{
+ PDmtRWPluginNode pNode;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ pNode=new DmtRWPluginNode();
+ if ( pNode == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ dm_stat = pNode->Init(this, path, value);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = this->SetNode(path, PDmtNode(pNode));
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = GetNode( path, ptrCreatedNode );
+
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::DeleteSubTree( PDmtNode ptrNode)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMString nodePath;
+ if(!ptrNode->IsLeaf())
+ {
+ DMVector<PDmtNode> oChildren;
+ dm_stat = ptrNode->GetChildNodes( oChildren );
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ for ( int i = 0; i < oChildren.size(); i++ )
+ {
+ if (oChildren[i]->IsLeaf() )
+ {
+ dm_stat = oChildren[i]->GetPath(nodePath);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ {
+ dm_stat = this->RemoveNode(nodePath);
+ oChildren[i] = NULL;
+ }
+ }
+ else
+ dm_stat =DeleteSubTree(oChildren[i]);
+
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ }
+ }
+
+ dm_stat = ptrNode->GetPath(nodePath);
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = this->RemoveNode(nodePath);
+ ptrNode = NULL;
+
+ return dm_stat;
+
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::DeleteNode( CPCHAR path )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtNode ptrNode;
+
+ dm_stat = GetNode( path, ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+#ifdef LOB_SUPPORT
+ // Create temporary storage for ESN
+ dm_stat = BackupESNdata(path);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+#endif
+
+ dm_stat = LogCommand(SYNCML_DM_PLUGIN_DELETE, path, SYNCML_DM_PLUGIN_COMMAND_ON_NODE, ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = DeleteSubTree(ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ // Is it the root node ?
+ if(DmStrlen(path) == 0)
+ return dm_stat;
+
+ DMString strURI;
+ DMString strKey;
+ DmParseURI( path, strURI, strKey );
+
+
+ DMStringVector oChildren;
+ dm_stat = this->GetChildNodeNames(strURI.c_str(), oChildren);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ // Is the plugin root node?
+ if(strURI.length() == 0)
+ {
+ for (INT32 i = 0; i < oChildren.size(); i++ )
+ {
+ if (!DmStrcmp(oChildren[i].c_str() , path))
+ oChildren.remove(i);
+ }
+ }
+ else
+ {
+ for ( INT32 i = 0; i < oChildren.size(); i++ )
+ {
+ if (!DmStrcmp(oChildren[i].c_str() , strKey.c_str()))
+ oChildren.remove(i);
+ }
+ }
+
+ // Remove link to parent node
+ dm_stat = GetNode( strURI.c_str(), ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+
+ DmtData m_value;
+ dm_stat = m_value.SetNodeValue(oChildren);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ // Turn off logging temporarilly
+ BOOLEAN needLogging= m_Playback;
+ m_Playback = TRUE;
+ dm_stat = ptrNode->SetValue(m_value);
+ m_Playback = needLogging;
+
+ return dm_stat;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::RemoveNode
+// DESCRIPTION : Remove a node from memory
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::RemoveNode(CPCHAR path)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtNode ptrNode;
+
+ dm_stat = GetNode( path, ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+#ifdef LOB_SUPPORT
+ if(ptrNode->IsExternalStorageNode())
+ {
+ PDmtRWPluginNode pRWNode = (DmtRWPluginNode *) ((DmtNode *)ptrNode);
+ dm_stat = pRWNode->Delete();
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ }
+#endif
+ return DmtPluginTree::RemoveNode(path);
+
+}
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::RenameNode( CPCHAR path, CPCHAR szNewNodeName )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtNode ptrNode;
+
+ dm_stat = GetNode( path, ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ PDmtRWPluginNode pRWNode = (DmtRWPluginNode *) ((DmtNode *)ptrNode);
+
+ return pRWNode->Rename(szNewNodeName);
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::LinkToParentNode( CPCHAR path)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMString strURI;
+ DMString strKey;
+ PDmtNode ptrNode;
+ DmParseURI( path, strURI, strKey );
+ DMStringVector oChildren;
+
+ dm_stat = this->GetChildNodeNames( strURI.c_str(), oChildren);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ if(strURI.length() != 0)
+ oChildren.push_back(strKey.c_str());
+ else
+ oChildren.push_back(path);
+
+ DmtData m_value;
+ dm_stat = m_value.SetNodeValue(oChildren);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+
+ dm_stat = GetNode( strURI.c_str(), ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ // Turn off logging temporarilly
+ BOOLEAN needLogging= m_Playback;
+ m_Playback = TRUE;
+ dm_stat = ptrNode->SetValue(m_value);
+ m_Playback = needLogging;
+ return dm_stat;
+
+ }
+#ifdef LOB_SUPPORT
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginTree::BackupESNdata
+// DESCRIPTION : Create temporary storage for ESN
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::BackupESNdata( CPCHAR path)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtNode ptrNode;
+
+ dm_stat = GetNode( path, ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ if (ptrNode->IsLeaf())
+{
+ if(ptrNode->IsExternalStorageNode())
+ {
+ PDmtRWPluginNode pRWNode = (DmtRWPluginNode *) ((DmtNode *)ptrNode);
+
+ // Backup file already exist?
+ if(pRWNode->GetESNBackupFileName() != NULL)
+ return SYNCML_DM_SUCCESS;
+
+ // Backup ESN data
+ dm_stat = pRWNode->BackupESNData();
+ }
+ }
+ else
+ {
+ DMStringVector mapNodeNames;
+ DMString strVal;
+
+ dm_stat = GetChildNodeNames( path, mapNodeNames );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ for ( int i = 0; i < mapNodeNames.size(); i++ )
+ {
+ DMString strVal = path;
+ // Is root node?
+ if(strVal.length() != 0)
+ strVal += "/";
+ // Construct child node name
+ strVal += mapNodeNames[i];
+ dm_stat = BackupESNdata(strVal.c_str());
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+ }
+ return dm_stat;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginTree::CommitESN
+// DESCRIPTION : Commit changes for ESN
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::CommitESN( CPCHAR path)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtNode ptrNode;
+
+ // Any ESN data modified?
+ if(!m_ESNDirty)
+ return dm_stat;
+
+ dm_stat = GetNode( path, ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ if (ptrNode->IsLeaf())
+{
+ if(ptrNode->IsExternalStorageNode())
+ {
+ PDmtRWPluginNode pRWNode = (DmtRWPluginNode *) ((DmtNode *)ptrNode);
+
+ // Backup ESN data
+ dm_stat = pRWNode->Commit();
+ }
+ }
+ else
+ {
+ DMStringVector mapNodeNames;
+ DMString strVal;
+
+ dm_stat = GetChildNodeNames( path, mapNodeNames );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ for ( int i = 0; i < mapNodeNames.size(); i++ )
+ {
+ DMString strVal = path;
+ // Is root node?
+ if(strVal.length() != 0)
+ strVal += "/";
+ // Construct child node name
+ strVal += mapNodeNames[i];
+ dm_stat = CommitESN(strVal.c_str());
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+ }
+ }
+ return dm_stat;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginTree::IsESNSetComplete
+// DESCRIPTION : Check if all the ESN setting are done
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE :
+//--------------------------------------------------------------------------------------------
+BOOLEAN DmtRWPluginTree::IsESNSetComplete(CPCHAR pbURI)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtNode ptrNode;
+ // Any ESN data modified?
+ if(!m_ESNDirty)
+ return TRUE;
+
+ dm_stat = GetNode( pbURI, ptrNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return TRUE;
+
+ if (ptrNode->IsLeaf())
+{
+ PDmtRWPluginNode pRWNode = (DmtRWPluginNode *) ((DmtNode *)ptrNode);
+ if(ptrNode->IsExternalStorageNode() && !pRWNode->IsESNSetComplete())
+ return FALSE;
+ else
+ return TRUE;
+ }
+ else
+ {
+ DMStringVector mapNodeNames;
+ DMString strVal;
+
+ dm_stat = GetChildNodeNames( pbURI, mapNodeNames );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return TRUE;
+
+ for ( int i = 0; i < mapNodeNames.size(); i++ )
+ {
+ DMString strVal = pbURI;
+ strVal += "/";
+ // Construct child node name
+ strVal += mapNodeNames[i];
+ if(IsESNSetComplete(strVal.c_str()) == FALSE)
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+#endif
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::CreateLeafNodeInternal( CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value ,
+ BOOLEAN isESN)
+{
+ PDmtRWPluginNode pNode;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ pNode=new DmtRWPluginNode();
+ if ( pNode == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+
+ dm_stat = pNode->Init(this, path, value, isESN);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ dm_stat = this->SetNode(path, PDmtNode(pNode));
+ if ( dm_stat == SYNCML_DM_SUCCESS )
+ dm_stat = GetNode( path, ptrCreatedNode );
+
+ return dm_stat;
+}
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::CreateLeafNode(CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value ,
+ BOOLEAN isESN)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ dm_stat = LogCommand(SYNCML_DM_PLUGIN_ADD, path, SYNCML_DM_PLUGIN_COMMAND_ON_NODE, NULL);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = this ->CreateLeafNodeInternal(path, ptrCreatedNode, value, isESN );
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ if ( dm_stat == SYNCML_DM_FEATURE_NOT_SUPPORTED )
+ return SYNCML_DM_SUCCESS;
+ else
+ return dm_stat;
+ }
+
+ dm_stat = LinkToParentNode(path);
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::CreateLeafNode( CPCHAR path,
+ PDmtNode& ptrCreatedNode,
+ const DmtData& value )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ dm_stat = LogCommand(SYNCML_DM_PLUGIN_ADD, path, SYNCML_DM_PLUGIN_COMMAND_ON_NODE, NULL);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = this ->CreateLeafNodeInternal(path, ptrCreatedNode, value );
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ if ( dm_stat == SYNCML_DM_FEATURE_NOT_SUPPORTED )
+ return SYNCML_DM_SUCCESS;
+ else
+ return dm_stat;
+ }
+
+ dm_stat = LinkToParentNode(path);
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::CreateInteriorNode( CPCHAR path, PDmtNode& ptrCreatedNode )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ dm_stat = LogCommand(SYNCML_DM_PLUGIN_ADD, path, SYNCML_DM_PLUGIN_COMMAND_ON_NODE, NULL);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ DMStringVector oChildren;
+ dm_stat = this->CreateInteriorNodeInternal(path, ptrCreatedNode, oChildren);
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ {
+ if ( dm_stat == SYNCML_DM_FEATURE_NOT_SUPPORTED )
+ return SYNCML_DM_SUCCESS;
+ else
+ return dm_stat;
+ }
+
+ dm_stat = LinkToParentNode(path);
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::Begin()
+{
+ #ifdef DM_ATOMIC_SUPPORTED
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+ m_bIsAtomic = TRUE;
+ ret_stat = this->Flush();
+ return ret_stat;
+ #else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ #endif
+ }
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::Commit()
+{
+ #ifdef DM_ATOMIC_SUPPORTED
+ SYNCML_DM_RET_STATUS_T ret_stat = SYNCML_DM_SUCCESS;
+
+ ret_stat = this->Flush();
+ m_bIsAtomic = FALSE;
+ return ret_stat;
+ #else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ #endif
+
+}
+
+BOOLEAN DmtRWPluginTree::IsAtomic() const
+{
+ return m_bIsAtomic;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::Flush()
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+#ifdef LOB_SUPPORT
+ // Verify if all ESN setting are complete.
+ if(IsESNSetComplete("") == FALSE)
+ return SYNCML_DM_ESN_SET_NOT_COMPLETE;
+#endif
+ if(this->log != NULL)
+ {
+ this->log->RemoveLog();
+
+ delete this->log;
+ this->log = NULL;
+
+ }
+ if(m_strLogPath != NULL)
+ m_strLogPath = NULL;
+
+#ifdef LOB_SUPPORT
+ // Commit all ESN changes.
+ dm_stat = CommitESN("");
+ m_ESNDirty = FALSE;
+#endif
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::Rollback()
+{
+ #ifdef DM_ATOMIC_SUPPORTED
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ m_Playback = TRUE;
+
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "PLUGIN_PF2") == 0))
+ {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+ if(this->log != NULL)
+ {
+ if(fpLog == NULL)
+ dm_stat = log->playLog(m_strLogPath.c_str());
+ else
+ { dm_stat = log->playLog();
+ this->log->RemoveLog();
+ fpLog = NULL;
+ }
+ delete this->log;
+ this->log = NULL;
+ }
+ if(m_strLogPath != NULL)
+ m_strLogPath = NULL;
+
+#ifdef TEST_DM_RECOVERY
+ if ((power_fail_point != NULL) && (DmStrcmp(power_fail_point, "PLUGIN_PF3") == 0))
+ {
+ printf("Type Ctrl-C to simulate Power Fail ...\n");
+ sleep(30);
+ }
+#endif
+
+ m_Playback = FALSE;
+ m_ESNDirty = FALSE;
+ m_bIsAtomic = FALSE;
+ m_oAddedNodes.clear();
+ return dm_stat;
+ #else
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+ #endif
+}
+
+
+BOOLEAN DmtRWPluginTree::IsPlaybackMode()
+{
+ return m_Playback;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginTree::SetPlaybackMode(boolean bPlayback)
+{
+ m_Playback = bPlayback;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+DmtRWPluginNode::~DmtRWPluginNode()
+{
+}
+
+DmtRWPluginNode::DmtRWPluginNode()
+{
+#ifdef LOB_SUPPORT
+ m_LobComplete = TRUE;
+ m_LobDirty = FALSE;
+ m_LobLogging = FALSE;
+ abStorageName = NULL;
+#endif
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::SetTitle( CPCHAR szTitle )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtRWPluginTree ptrTree = (DmtRWPluginTree *) ((DmtPluginTree *)m_ptrTree);
+
+ dm_stat = ptrTree->LogCommand(SYNCML_DM_PLUGIN_REPLACE,
+ m_strPath.c_str(),
+ SYNCML_DM_PLUGIN_COMMAND_ON_TITLE_PROPERTY,
+ (const DmtNode*)this);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ DmtAttributes oAttr;
+ dm_stat =this->GetAttributes( oAttr );
+
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ return m_oAttr.SetTitle(szTitle);
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::SetValueInternal( const DmtData& value )
+{
+ m_oData = value;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::SetValue( const DmtData& value )
+{
+ XPL_LOG_DM_PLG_Debug(("Enter DmtRWPluginNode::SetValue..."));
+ PDmtRWPluginTree ptrTree = (DmtRWPluginTree *) ((DmtPluginTree *)m_ptrTree);
+ SYNCML_DM_RET_STATUS_T dm_stat;
+
+ dm_stat= ptrTree->LogCommand(SYNCML_DM_PLUGIN_REPLACE,
+ m_strPath.c_str(),
+ SYNCML_DM_PLUGIN_COMMAND_ON_NODE,
+ (const DmtNode *)this);
+ XPL_LOG_DM_PLG_Debug(("LogCommand returns dm_stat=%d", dm_stat));
+
+ if(dm_stat == SYNCML_DM_SUCCESS)
+ {
+ INT32 dataSize;
+ m_oData = value;
+
+ // Get data size
+ dm_stat = m_oData.GetSize(dataSize);
+ XPL_LOG_DM_PLG_Debug(("DmtRWPluginNode::SetValue m_oData.getSize() returns dataSize=%d dm_stat=%d", dataSize, dm_stat));
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return dm_stat;
+
+ XPL_LOG_DM_PLG_Debug(("calling m_oAttr.SetSize(%d)", dataSize));
+ m_oAttr.SetSize(dataSize);
+ }
+
+ XPL_LOG_DM_PLG_Debug(("DmtRWPluginNode::SetValue returns dm_stat=%d", dm_stat));
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::Rename( CPCHAR szNewName )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtRWPluginTree ptrTree = (DmtRWPluginTree *) ((DmtPluginTree *)m_ptrTree);
+
+ DMString strURI;
+ DMString strKey;
+ DmParseURI( m_strPath.c_str(), strURI, strKey );
+
+ DMString strNewURI = strURI;
+ if(strNewURI.length() != 0)
+ strNewURI += "/";
+ strNewURI += szNewName;
+
+ dm_stat = ptrTree->LogCommand(SYNCML_DM_PLUGIN_REPLACE,
+ (CPCHAR)strNewURI.c_str(),
+ SYNCML_DM_PLUGIN_COMMAND_ON_NAME_PROPERTY,
+ (const DmtNode*)this);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ DMStringVector oChildren;
+
+ dm_stat = m_ptrTree->GetChildNodeNames( strURI.c_str(), oChildren);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ // Is the plugin root node?
+ if(strURI.length() == 0)
+ {
+ for ( INT32 i = 0; i < oChildren.size(); i++ )
+ {
+ if (!DmStrcmp(oChildren[i].c_str() , m_strPath.c_str()))
+ {
+ oChildren.remove(i);
+ break;
+ }
+ }
+ }
+ else
+ {
+ for ( INT32 i = 0; i < oChildren.size(); i++ )
+ {
+ if (!DmStrcmp(oChildren[i].c_str() , strKey.c_str()))
+ {
+ oChildren.remove(i);
+ break;
+ }
+ }
+ }
+
+ oChildren.push_back(szNewName);
+ PDmtNode ptrParentNode;
+ DmtData m_value;
+
+ dm_stat = m_value.SetNodeValue(oChildren);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = m_ptrTree->GetNode( strURI.c_str(), ptrParentNode);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ PDmtRWPluginNode pRWParentNode = (DmtRWPluginNode *) ((DmtNode *)ptrParentNode);
+
+ DmtData oData;
+ dm_stat = pRWParentNode->GetValue( oData );
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ // Turn off logging temporarilly
+ BOOLEAN needLogging= ptrTree->IsPlaybackMode();
+ ptrTree->SetPlaybackMode(TRUE);
+ dm_stat = pRWParentNode->SetValue(m_value);
+ ptrTree->SetPlaybackMode(needLogging);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = pRWParentNode->GetValue( oData );
+
+ m_strName = szNewName;
+ if ( szNewName && szNewName[0] )
+ {
+ if ( m_strName == NULL )
+ return SYNCML_DM_DEVICE_FULL;
+ }
+
+ DmtAttributes oAttr;
+ dm_stat = this->GetAttributes( oAttr );
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = m_oAttr.SetName(szNewName);
+
+ if (dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = RenameChildNodes(strURI.c_str(), szNewName);
+ return dm_stat;
+}
+
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::RenameChildNodes( CPCHAR szParentPath, CPCHAR szNodeName )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ DMString strURI = szParentPath;
+
+ if(strURI.length() != 0)
+ strURI += "/";
+ strURI += szNodeName;
+
+ dm_stat = m_ptrTree->RemoveNode(m_strPath.c_str());
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+
+ dm_stat = m_ptrTree->SetNode(strURI.c_str(), this);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ if ( m_bLeaf )
+ {
+ m_strPath = strURI;
+ return SYNCML_DM_SUCCESS;
+ }
+
+
+ DMStringVector oChildren;
+ dm_stat = m_ptrTree->GetChildNodeNames( strURI.c_str(), oChildren);
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ for ( int i = 0; i < oChildren.size(); i++ )
+ {
+ DMString strChildPath = m_strPath;
+
+ if (strChildPath.length() !=0)
+ strChildPath += "/";
+
+ strChildPath += oChildren[i];
+
+ PDmtNode ptrNode;
+
+ dm_stat = m_ptrTree->GetNode( strChildPath.c_str(), ptrNode );
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ PDmtRWPluginNode pRWNode = (DmtRWPluginNode *) ((DmtNode *)ptrNode);
+
+ dm_stat = pRWNode->RenameChildNodes(strURI.c_str(), oChildren[i].c_str());
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ }
+ m_strPath = strURI;
+
+ return dm_stat;
+}
+
+#ifdef LOB_SUPPORT
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::GetFirstChunk
+// DESCRIPTION :
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::GetFirstChunk(DmtDataChunk& dmtChunkData)
+{
+ // Only for ESN
+ if(!m_bESN)
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+ if(m_LobComplete == FALSE)
+ return SYNCML_DM_ESN_SET_NOT_COMPLETE;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::GetNextChunk
+// DESCRIPTION :
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::GetNextChunk(DmtDataChunk& dmtChunkData)
+{
+ // Only for ESN
+ if(!m_bESN)
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+ if(m_LobComplete == FALSE)
+ return SYNCML_DM_ESN_SET_NOT_COMPLETE;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::SetFirstChunk
+// DESCRIPTION :
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::SetFirstChunk(DmtDataChunk& dmtChunkData)
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtRWPluginTree ptrTree = (DmtRWPluginTree *) ((DmtPluginTree *)m_ptrTree);
+ // Only for ESN
+ if(!m_bESN)
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+
+ // Need to log the command ?
+ if(!ptrTree->IsPlaybackMode())
+ {
+ if(!m_LobLogging)
+ {
+ dm_stat = BackupESNData();
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ dm_stat = ptrTree->LogCommand(SYNCML_DM_PLUGIN_REPLACE,
+ m_strPath.c_str(),
+ SYNCML_DM_PLUGIN_COMMAND_ON_LOB_PROPERTY,
+ (const DmtNode*)this);
+
+ if ( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ m_LobLogging = TRUE;
+ }
+
+ m_LobComplete = FALSE;
+ m_LobDirty = TRUE;
+ //Set flag in the plugin tree
+ ptrTree->SetESNDirty();
+ }
+ return dm_stat;
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::SetNextChunk
+// DESCRIPTION :
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::SetNextChunk(DmtDataChunk& dmtChunkData)
+{
+ PDmtRWPluginTree ptrTree = (DmtRWPluginTree *) ((DmtPluginTree *)m_ptrTree);
+ // Only for ESN and SetFirstChunk() is invoked.
+ if(!m_bESN )
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+ // Need to log the command ?
+ if(!ptrTree->IsPlaybackMode())
+ {
+ if(!m_LobDirty ||m_LobComplete)
+ return SYNCML_DM_INCOMPLETE_COMMAND;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::SetLastChunk
+// DESCRIPTION :
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::SetLastChunk(DmtDataChunk& dmtChunkData)
+{
+ PDmtRWPluginTree ptrTree = (DmtRWPluginTree *) ((DmtPluginTree *)m_ptrTree);
+ // Only for ESN and SetFirstChunk() is invoked.
+ if(!m_bESN )
+ return SYNCML_DM_COMMAND_NOT_ALLOWED;
+
+ if(!ptrTree->IsPlaybackMode())
+ {
+ if(!m_LobDirty ||m_LobComplete)
+ return SYNCML_DM_INCOMPLETE_COMMAND;
+
+ m_LobComplete = TRUE;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::Commit
+// DESCRIPTION : Commit changes for an ESN
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::Commit()
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ // Only for ESN
+ if(m_bESN)
+ {
+ m_LobComplete = TRUE;
+ m_LobDirty = FALSE;
+ m_LobLogging = FALSE;
+ // Remove temporary storage file
+ if(abStorageName.length() != 0)
+ {
+ DMFileHandler sourceHandle(abStorageName);
+ dm_stat = sourceHandle.open(XPL_FS_FILE_RDWR);
+ if(dm_stat == SYNCML_DM_SUCCESS)
+ sourceHandle.deleteFile();
+ abStorageName = NULL;
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::Delete
+// DESCRIPTION : Delete the node
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::Delete()
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::BackupESNData
+// DESCRIPTION : Backup ESN data to temporary file
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::BackupESNData()
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ PDmtRWPluginTree ptrTree = (DmtRWPluginTree *) ((DmtPluginTree *)m_ptrTree);
+ DmtDataChunk chunkData;
+ UINT32 getLen;
+ UINT8 *bufp;
+
+ if(!m_bESN || m_LobLogging)
+ return SYNCML_DM_SUCCESS;
+
+ DmtAttributes oAttr;
+ dm_stat =this->GetAttributes( oAttr );
+ // Is the ESN empty
+ if(oAttr.GetSize() == 0)
+ {
+ abStorageName = NULL;
+ return SYNCML_DM_SUCCESS;
+ }
+
+ // No internal file created yet
+ if(abStorageName.length() == 0) {
+ dm_stat = DMFileHandler::createTempESNFileName(abStorageName);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ }
+ DMFileHandler tempLogFileHandler(abStorageName);
+ dm_stat = tempLogFileHandler.open(XPL_FS_FILE_WRITE);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ // Allocate chunk buffer
+ if(chunkData.AllocateChunkBuffer() != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_DEVICE_FULL;
+
+ dm_stat = GetFirstChunk(chunkData);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ chunkData.GetReturnLen(getLen);
+ chunkData.GetChunkData(&bufp); // the chunk data is available
+
+ while (true)
+ {
+ // Get the last chunk of data
+ if (getLen == 0)
+ break;
+ if(tempLogFileHandler.seek(XPL_FS_SEEK_END, 0) != SYNCML_DM_SUCCESS)
+ {
+ dm_stat = SYNCML_DM_IO_FAILURE;
+ break;
+ }
+ if(tempLogFileHandler.write((CPCHAR)bufp, getLen) != SYNCML_DM_SUCCESS)
+ {
+ dm_stat = SYNCML_DM_IO_FAILURE;
+ break;
+ }
+ dm_stat = GetNextChunk(chunkData);
+ if( dm_stat != SYNCML_DM_SUCCESS)
+ break;
+ chunkData.GetReturnLen(getLen);
+ chunkData.GetChunkData(&bufp);
+ }
+
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ { tempLogFileHandler.deleteFile();
+ abStorageName = NULL;
+ }
+ else
+ tempLogFileHandler.close();
+
+ //Set flag in the plugin tree
+ ptrTree->SetESNDirty();
+ return dm_stat;
+}
+//--------------------------------------------------------------------------------------------
+// FUNCTION : DmtRWPluginNode::RestoreESNData
+// DESCRIPTION : Restore ESN data from temporary file
+// ARGUMENTS PASSED:
+//
+// RETURN VALUE : SYNCML_DM_RET_STATUS_T : Returns SYNCML_DM_SUCCESS if success, otherwise fails
+//
+//--------------------------------------------------------------------------------------------
+SYNCML_DM_RET_STATUS_T DmtRWPluginNode::RestoreESNData( CPCHAR szBackupFileName )
+{
+ SYNCML_DM_RET_STATUS_T dm_stat = SYNCML_DM_SUCCESS;
+ UINT32 totalSize;
+ DmtDataChunk chunkData;
+ int setLen = 0;
+ int offset = 0;
+ bool isFirstChunk = true;
+ bool isLastChunk = false;
+ UINT8 *bufp;
+
+ if(!m_bESN )
+ return SYNCML_DM_SUCCESS;
+
+ int chunksize = chunkData.GetChunkSize();
+
+ m_LobComplete = TRUE;
+ m_LobDirty = FALSE;
+ m_LobLogging = FALSE;
+
+ // No internal storage file
+ if(DmStrlen(szBackupFileName) == 0)
+ {
+ dm_stat = SetFirstChunk(chunkData);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+ dm_stat = SetLastChunk(chunkData);
+ abStorageName = NULL;
+
+ return dm_stat;
+ }
+
+ if(!XPL_FS_Exist(szBackupFileName))
+ return SYNCML_DM_SUCCESS;
+
+
+ DMFileHandler tempFileHandler(szBackupFileName);
+ dm_stat = tempFileHandler.open(XPL_FS_FILE_RDWR);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ totalSize = tempFileHandler.size();
+
+ // Allocate chunk buffer
+ if(chunkData.AllocateChunkBuffer() != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_DEVICE_FULL;
+
+ chunkData.GetChunkData(&bufp); // the chunk data is available
+
+
+ while(!isLastChunk)
+ { setLen = totalSize- offset;
+ if(setLen > 0)
+ {
+ if(setLen > chunksize)
+ setLen = chunksize;
+ }
+ else
+ isLastChunk = true;
+
+ if(tempFileHandler.seek(XPL_FS_SEEK_SET, offset) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+ if(tempFileHandler.read(bufp, setLen) != SYNCML_DM_SUCCESS)
+ return SYNCML_DM_IO_FAILURE;
+
+ dm_stat = chunkData.SetChunkData((const UINT8 *)bufp, setLen);
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ if(isFirstChunk)
+ {
+ dm_stat = SetFirstChunk(chunkData);
+ isFirstChunk = false;
+ }
+ else
+ { if(!isLastChunk)
+ dm_stat = SetNextChunk(chunkData);
+ else
+ dm_stat = SetLastChunk(chunkData);
+ }
+ if(dm_stat != SYNCML_DM_SUCCESS)
+ return dm_stat;
+
+ offset += setLen;
+ }
+
+ totalSize = tempFileHandler.deleteFile();
+ abStorageName = NULL;
+ return dm_stat;
+}
+
+#endif
diff --git a/engine/dmlib/portlib/generic/dmAsyncMessageID.h b/engine/dmlib/portlib/generic/dmAsyncMessageID.h
new file mode 100644
index 0000000..265277c
--- /dev/null
+++ b/engine/dmlib/portlib/generic/dmAsyncMessageID.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The dmAsyncMessageID.h header file
+ */
+
+#ifndef DM_ASYNC_MESSAGEID_H
+#define DM_ASYNC_MESSAGEID_H
+
+#include "xpl_Message.h"
+#include "xpl_Time.h"
+
+enum {
+ SYNCML_DM_INIT_MSG_ID = XPL_DM_TASK_MESSAGE_CATEGORY,
+ SYNCML_DM_UNINIT_MSG_ID,
+ SYNCML_DM_GET_SUBTREE_MSG_ID,
+ SYNCML_DM_RELEASE_TREE_ID,
+ SYNCML_DM_START_SERVER_SESSION_MSG_ID,
+ SYNCML_DM_PROCESS_SCRIPT_MSG_ID,
+ SYNCML_DM_BOOTSTRAP_MSG_ID,
+ SYNCML_DM_PROCESS_NOTIFICATION_MSG_ID,
+ SYNCML_DM_GET_NODE_MSG_ID,
+ SYNCML_DM_RELEASE_NODE_MSG_ID,
+ SYNCML_DM_DELETE_NODE_MSG_ID,
+ SYNCML_DM_RENAME_NODE_MSG_ID,
+ SYNCML_DM_CREATE_INTERIOR_NODE_MSG_ID,
+ SYNCML_DM_CREATE_LEAF_NODE_MSG_ID,
+ SYNCML_DM_GET_CHULD_NODE_NAMES_MSG_ID,
+ SYNCML_DM_FLUSH_MSG_ID,
+ SYNCML_DM_COMMIT_MSG_ID,
+ SYNCML_DM_ROLLBACK_MSG_ID,
+ SYNCML_DM_BEGIN_MSG_ID,
+ SYNCML_DM_GET_CHILD_VALUES_MAP_MSG_ID,
+ SYNCML_DM_SET_CHILD_VALUES_MAP_MSG_ID,
+ SYNCML_DM_GET_ATTRIBUTES_MSG_ID,
+ SYNCML_DM_GET_VALUE_MSG_ID,
+ SYNCML_DM_SET_VALUE_MSG_ID,
+ SYNCML_DM_SET_TITLE_MSG_ID,
+ SYNCML_DM_SET_ACL_MSG_ID,
+ SYNCML_DM_EXECUTE_MSG_ID,
+ SYNCML_DM_NOTIFY_ON_IDLE_MSG_ID,
+ SYNCML_DM_TIMER_MSG_ID,
+ SYNCML_DM_TIMER_MSG_ID_LAST,
+ SYNCML_DM_TREE_AVAILABLE_MSG_ID,
+ SYNCML_DM_GET_FIRST_CHUNK_MSG_ID,
+ SYNCML_DM_GET_NEXT_CHUNK_MSG_ID,
+ SYNCML_DM_SET_FIRST_CHUNK_MSG_ID,
+ SYNCML_DM_SET_NEXT_CHUNK_MSG_ID,
+ SYNCML_DM_SET_LAST_CHUNK_MSG_ID
+};
+typedef UINT32 SYNCML_DM_TASK_MESSAGE_ID;
+
+
+#define SYNCML_DM_ASYNC_API_MESSAGE_COUNT (SYNCML_DM_SET_LAST_CHUNK_MSG_ID - SYNCML_DM_INIT_MSG_ID)
+
+typedef struct
+{
+ XPL_CLK_TIMER_CBACK callback;
+ XPL_TIMER_HANDLE_T timerHandle;
+} SYNCML_DM_TIMER_MSG_T;
+
+#endif
diff --git a/engine/dmlib/portlib/generic/dmMemory.h b/engine/dmlib/portlib/generic/dmMemory.h
new file mode 100644
index 0000000..8a49c6a
--- /dev/null
+++ b/engine/dmlib/portlib/generic/dmMemory.h
@@ -0,0 +1,43 @@
+#ifndef DMMEMORY_H
+#define DMMEMORY_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include "xpl_Types.h"
+#include "dmStringUtil.h"
+
+
+#define DmAllocMem(bufsize) DmAllocMemEx(bufsize,__FILE__,__LINE__)
+#define DmFreeMem(buf) { DmFreeMemEx(buf,__FILE__,__LINE__); (buf) = NULL; }
+
+void * DmAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine );
+void DmFreeMemEx(void *ptr, CPCHAR szFile, int nLine);
+void* DmReallocMem( void* ptr, int nSize );
+
+/* Low memory helpers */
+int DmGetMemFailedFlag( void );
+void DmResetMemFailedFlag( void );
+
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+
+#define DM_MEMORY_STATISTICS_WRITE(header) DmMemoryStatisticsWrite(header)
+void DmMemoryStatisticsWrite(const char* header);
+
+#define DM_MEMORY_STATISTICS_REPORT_LEAKS DmMemoryStatisticsReportLeaks();
+void DmMemoryStatisticsReportLeaks( void );
+
+#else /*DM_MEMORY_STATISTICS_ENABLED*/
+
+#define DM_MEMORY_STATISTICS_WRITE(header)
+#define DM_MEMORY_STATISTICS_REPORT_LEAKS
+
+#endif /*DM_MEMORY_STATISTICS_ENABLED*/
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* DMMEMORY_H */
+
diff --git a/engine/dmlib/portlib/generic/xpl_dm_Manager.h b/engine/dmlib/portlib/generic/xpl_dm_Manager.h
new file mode 100644
index 0000000..58c375a
--- /dev/null
+++ b/engine/dmlib/portlib/generic/xpl_dm_Manager.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_dm_manager.h header file contains constants and function prototypes
+ * for dm specific functions
+ */
+
+#ifndef XPL_DMMANAGER_H
+#define XPL_DMMANAGER_H
+
+#include "dmtDefs.h"
+
+enum {
+ SYNCML_DM_SETTINGS_PATH,
+ SYNCML_DM_PLUGINS_PATH,
+ SYNCML_DM_SECURITY_LEVEL,
+ SYNCML_DM_ESCAPE_CHAR,
+ SYNCML_DM_MEMORY_AGING_INTERVAL,
+ SYNCML_DM_MEMORY_AGING_TIME,
+ SYNCML_DM_POWER_FAIL_IJECTION,
+ SYNCML_DM_DUMP_SESSION_PACKAGE_PATH,
+ SYNCML_DM_SESSION_LIB,
+ SYNCML_DM_VERSION,
+ SYNCML_DM_DMACC_ROOT_PATH,
+ SYNCML_DM_NODENAME_SERVERID,
+ SYNCML_DM_FEATURE_ID_POC_PROVISION_VIA_OMADM,
+ SYNCML_DM_SESSION_ID,
+};
+typedef INT8 SYNCML_DM_ENVIRONMENT_T;
+
+#define SYNCML_REP_PROTOCOL_VERSION_1_1 "1.1"
+#define SYNCML_REP_PROTOCOL_VERSION_1_2 "1.2"
+
+
+// DM: file, which contains one of SYNCML_REP_PROTOCOL_VERSION_* constants
+#define XPL_VERSION_FILENAME "version.txt"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SYNCML_DM_RET_STATUS_T XPL_DM_Init(void);
+SYNCML_DM_RET_STATUS_T XPL_DM_DeInit(void);
+CPCHAR XPL_DM_GetEnv(SYNCML_DM_ENVIRONMENT_T env_var);
+BOOLEAN XPL_DM_IsFeatureEnabled(CPCHAR pUri);
+
+#ifdef DM_STATIC_FILES
+const UINT8 * XPL_DM_GetPluginsConfig(UINT32 *pSize);
+const UINT8 * XPL_DM_GetFstab(UINT32 *pSize);
+UINT8 XPL_DM_GetMDFCount();
+const UINT8 * XPL_DM_GetMDF(UINT8 index, UINT32 *pSize);
+#endif
+
+UINT32 XPL_DM_GetChunkSize();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_DMMANAGER_H */
diff --git a/engine/dmlib/portlib/generic/xpl_dm_Notifications.h b/engine/dmlib/portlib/generic/xpl_dm_Notifications.h
new file mode 100644
index 0000000..01e1c00
--- /dev/null
+++ b/engine/dmlib/portlib/generic/xpl_dm_Notifications.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_Notifications.h header file contains constants and function prototypes
+ * for dm specific notification functions
+ */
+
+#ifndef XPL_DM_NOTIFICATIONS_H
+#define XPL_DM_NOTIFICATIONS_H
+
+#include "dmtDefs.h"
+#include "dmtEventData.hpp"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void XPL_DM_NotifyTreeUpdate(CPCHAR szTopic,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_TYPE_T nType,
+ UINT8 * pData,
+ UINT32 size);
+
+void XPL_DM_NotifySessionProgress(BOOLEAN bIsStarted);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_NOTIFICATIONS_H */
diff --git a/engine/dmlib/portlib/generic/xpl_dm_ServerAlert.h b/engine/dmlib/portlib/generic/xpl_dm_ServerAlert.h
new file mode 100644
index 0000000..a0e30c2
--- /dev/null
+++ b/engine/dmlib/portlib/generic/xpl_dm_ServerAlert.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_dm_ServerAlert.h header file contains definition and function prototypes
+ * for server alerts/prompts
+ */
+
+#ifndef XPL_DMSERVERALERT_H
+#define XPL_DMSERVERALERT_H
+
+#include "xpl_dm_ServerAlertDef.h"
+#include "dmtError.h"
+#include "dmstring.h"
+#include "dmvector.h"
+
+typedef struct
+{
+ XPL_DM_ALERT_RES_T action;
+ DMString response;
+} XPL_DM_ALERT_TEXTINPUT_RES_T;
+
+typedef struct
+{
+ XPL_DM_ALERT_RES_T action;
+ INT32 response;
+} XPL_DM_ALERT_SCHOICE_RES_T;
+
+typedef struct
+{
+ XPL_DM_ALERT_RES_T action;
+ DMStringVector responses;
+} XPL_DM_ALERT_MCHOICE_RES_T;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Display a confirm alert message box, user can confirm or cancel the action
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param defaultResponse default user action when timeout
+ * @param responseCode user's action will be returned here.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowConfirmAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ XPL_DM_ALERT_RES_T defaultResponse,
+ XPL_DM_ALERT_RES_T * responseCode);
+
+/**
+ * Display a text messages
+ *
+ * @param minDisplayTime minimum display time, in seconds.
+ * @param msg messages to display
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowDisplayAlert(INT32 minDisplayTime,
+ CPCHAR msg);
+
+
+/**
+ * Display a text input message box for user to enter input.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param defaultResponse default user action when timeout
+ * @param maxLength length allowed in user input
+ * @param inputType data format as specified in DM_ALERT_INPUT_T
+ * @param echoType whether to echo user input (hidden for password ) as specified in DM_ALERT_ECHO_T
+ * @param response hold user's response action and input data.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowTextInputAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ CPCHAR defaultResponse,
+ INT32 maxLength,
+ XPL_DM_ALERT_INPUT_T inputType,
+ XPL_DM_ALERT_ECHO_T echoType,
+ XPL_DM_ALERT_TEXTINPUT_RES_T * response );
+
+
+
+/**
+ * Display a single choice message box for user to pick up one entry.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param choices a string vector to hold text for each choice
+ * @param defaultResponse default user action when timeout
+ * @param response hold user's response action and selected choice.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowSingleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ INT32 defaultResponse,
+ XPL_DM_ALERT_SCHOICE_RES_T * response );
+
+
+
+/**
+ * Display a multiple choice message box for user to pick up zero to many entry.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param choices a string vector to hold text for each choice
+ * @param defaultResponse default user action when timeout
+ * @param defaultResponses holds default response in an array of string representation of
+ * selected indexes (starting from 1)
+ * @param response hold user's response action and selected choice.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowMultipleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ DMStringVector & defaultResponses,
+ XPL_DM_ALERT_MCHOICE_RES_T * response);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/portlib/generic/xpl_dm_ServerAlertDef.h b/engine/dmlib/portlib/generic/xpl_dm_ServerAlertDef.h
new file mode 100644
index 0000000..fbb3374
--- /dev/null
+++ b/engine/dmlib/portlib/generic/xpl_dm_ServerAlertDef.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_dm_ServerAlertDef.h header file contains definitions for server
+ * alerts/prompts
+ */
+
+#ifndef XPL_DMSERVERALERTDEF_H
+#define XPL_DMSERVERALERTDEF_H
+
+#include "xpl_Types.h"
+
+enum
+{
+ XPL_DM_ALERT_RES_NONE,
+ XPL_DM_ALERT_RES_NO,
+ XPL_DM_ALERT_RES_YES,
+ XPL_DM_ALERT_RES_CANCEL,
+ XPL_DM_ALERT_RES_TIMEOUT,
+};
+typedef UINT8 XPL_DM_ALERT_RES_T;
+
+enum
+{
+ XPL_DM_ALERT_I_ALPHA, // Alphanumeric
+ XPL_DM_ALERT_I_NUMERIC, // Numeric
+ XPL_DM_ALERT_I_DATE, // Date
+ XPL_DM_ALERT_I_TIME, // Time
+ XPL_DM_ALERT_I_PHONE_NUM, // Phone Number
+ XPL_DM_ALERT_I_IP_ADDR, // IP Address
+};
+typedef UINT8 XPL_DM_ALERT_INPUT_T;
+
+enum
+{
+ XPL_DM_ALERT_E_TEXT, // Text
+ XPL_DM_ALERT_E_PASSWD, // Password
+};
+typedef UINT8 XPL_DM_ALERT_ECHO_T;
+
+#endif
diff --git a/engine/dmlib/portlib/lj/hdr/dmAllocatedPointersPool.h b/engine/dmlib/portlib/lj/hdr/dmAllocatedPointersPool.h
new file mode 100644
index 0000000..f9564b3
--- /dev/null
+++ b/engine/dmlib/portlib/lj/hdr/dmAllocatedPointersPool.h
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMALLOCATED_POINTERS_POOL_INCLUDE
+#define DMALLOCATED_POINTERS_POOL_INCLUDE
+
+/*==================================================================================================
+
+ Header Name: dmAllocatedPointersPool.h
+
+ General Description: This file contains declaration of the DDMAllocatedPointersPool class
+
+==================================================================================================*/
+
+#include "dmThreadQueue.h"
+#include "dmThreadHelper.h"
+#include <malloc.h>
+#include <stdio.h>
+#include <time.h>
+#include <sys/time.h>
+
+#include "dmstring.h"
+#include "dmvector.h"
+
+#define DM_MAX_TIMERS 10
+
+#ifdef DEBUG
+#include <map>
+
+
+class DMAllocatedPointersPool
+{
+public:
+ enum { c_nExtraBytes = 16 };
+
+ /**
+ * Default constructor
+ */
+ DMAllocatedPointersPool(){}
+
+ /**
+ * Destructor
+ */
+ ~DMAllocatedPointersPool();
+
+ /**
+ * Checks if pointer exist in the pool
+ * \param ptr [in] - pointer
+ * \return TRUE if pointer is found
+ */
+ bool exists(void* ptr);
+
+ /**
+ * Appends pointer to the pool
+ * \param ptr [in] - pointer
+ */
+ void append(void* ptr);
+
+ /**
+ * Removes pointer from the pool
+ * \param ptr [in] - pointer
+ */
+ bool remove(void* ptr);
+
+ /**
+ * Prints unreleased pointers
+ */
+ void PrintUnreleased();
+
+
+private:
+ /** Critical section */
+ DMCriticalSection m_csPointerPoolLock;
+ /** Pool of allocated pointers */
+ std::map<void*, int> m_listOfAllocatedPointers;
+};
+
+
+/*====================================================================================================
+ Inline functions implementation
+==================================================================================================*/
+inline bool DMAllocatedPointersPool::exists(void* ptr)
+{
+ DMSingleLock oLock( m_csPointerPoolLock );
+
+ return m_listOfAllocatedPointers.find( ptr ) != m_listOfAllocatedPointers.end();
+}
+
+
+inline void DMAllocatedPointersPool::append(void* ptr)
+{
+ DMSingleLock oLock( m_csPointerPoolLock );
+
+ m_listOfAllocatedPointers[ptr] = 0; // add new pointer
+}
+
+inline bool DMAllocatedPointersPool::remove(void* ptr)
+{
+ DMSingleLock oLock( m_csPointerPoolLock );
+
+ std::map<void*, int>::iterator it = m_listOfAllocatedPointers.find(ptr);
+
+ if ( it == m_listOfAllocatedPointers.end() )
+ return false;
+
+ m_listOfAllocatedPointers.erase( it );
+ return true;
+}
+
+#endif //DEBUG
+
+#endif
diff --git a/engine/dmlib/portlib/lj/hdr/dmStringUtil.h b/engine/dmlib/portlib/lj/hdr/dmStringUtil.h
new file mode 100644
index 0000000..81dbd01
--- /dev/null
+++ b/engine/dmlib/portlib/lj/hdr/dmStringUtil.h
@@ -0,0 +1,55 @@
+#ifndef DMSTRINGUTIL_H
+#define DMSTRINGUTIL_H
+
+
+/************** HEADER FILE INCLUDES *****************************************/
+#include "stdlib.h"
+#include "string.h"
+#include "stdio.h"
+
+//#define DmStrlen(str) strlen(str)
+#define DmStrlen(str) ((str!=NULL)? strlen(str):0)
+
+#define DmStrcpy(target, source) strcpy(target, source)
+
+#define DmStrncpy(target, source, count) strncpy(target, source, count)
+
+#define DmStrcat(target, source) strcat(target, source)
+
+#define DmStrncat(target, source, count) strncat(target, source, count)
+
+#define DmStrcmp(target, source) strcmp(target, source)
+
+#define DmStrncmp(target, source, count) strncmp(target, source, count)
+
+#define DmStrchr(source, target) strchr(source, target)
+
+#define DmStrrchr(source, target) strrchr(source, target)
+
+#define DmStrstr(source, target) strstr(source, target)
+
+#define DmTolower(source) tolower(source)
+
+#define DmAtoi(source) atoi(source)
+
+#define DmAtol(source) atol(source)
+
+#define DmAtoll(source) atoll(source)
+
+#define DmAtof(source) atof(source)
+
+#define DmStrtol(source, end_ptr, radix) strtol( source, end_ptr, radix )
+
+#define DmSprintf sprintf
+
+#define DmSnprintf snprintf
+
+#define DmSscanf sscanf
+
+#define MAX_INT_STRING_LENGTH 14
+
+#define MAX_FLOAT_STRING_LENGTH 20
+
+#endif /* DMSTRINGUTIL_H */
+
+
diff --git a/engine/dmlib/portlib/lj/hdr/dmThreadHelper.h b/engine/dmlib/portlib/lj/hdr/dmThreadHelper.h
new file mode 100644
index 0000000..123d2d7
--- /dev/null
+++ b/engine/dmlib/portlib/lj/hdr/dmThreadHelper.h
@@ -0,0 +1,196 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMTHREADHELPER_INCLUDE
+#define DMTHREADHELPER_INCLUDE
+
+/*==================================================================================================
+
+ Header Name: dmThreadHelper.h
+
+ General Description: Declarations for DMCritcalSection, DMThread and DMSingleLock classes.
+
+==================================================================================================*/
+
+#include <pthread.h>
+#include <unistd.h>
+#include <assert.h>
+#include <memory.h>
+#include <errno.h>
+
+#ifdef DEBUG
+ #define IMASSERT(expression) assert(expression)
+ //#define NRES int nRes=
+ #define NRES(foo) int nRes=(foo)
+#else
+ #define IMASSERT(expression)
+ //#define NRES
+ #define NRES(foo) foo
+#endif
+
+
+class DMCriticalSection
+{
+public:
+ /**
+ * Default constructor
+ */
+ DMCriticalSection();
+
+ /**
+ * Destructor
+ */
+ ~DMCriticalSection();
+
+ /**
+ * Locks mutex object
+ */
+ void Enter();
+
+ /**
+ * Unlocks mutex object
+ */
+ void Leave();
+
+ /**
+ * Tries to lock mutex object
+ * \return TRUE if mutex object is locked
+ */
+ bool TryEnter();
+
+ /**
+ * Retrieves handler on mutex object
+ */
+ pthread_mutex_t& GetHandle() { return m_section;}
+
+private:
+ /* handler */
+ pthread_mutex_t m_section;
+};
+
+
+class DMThread
+{
+ public:
+
+ /**
+ * Default constructor
+ */
+ DMThread()
+ {
+ m_bRunning = false;
+ memset(&m_hThread, 0, sizeof(m_hThread));
+ }
+
+ /**
+ * Destructor
+ */
+ virtual ~DMThread(){}
+
+ /**
+ * Starts thread
+ * \return TRUE if success
+ */
+ bool StartThread();
+
+ /**
+ * Stops thread
+ * \return TRUE if success
+ */
+ bool StopThread();
+
+ protected:
+ /**
+ * Run method to be implemented in an inherited class
+ */
+ virtual void* Run() = 0;
+ private:
+
+ /**
+ * Thread callback function
+ */
+ static void* ThreadProc(void *pArg);
+
+protected:
+ /** Flag to specify if thread is running */
+ bool m_bRunning;
+ /** Thread handler */
+ pthread_t m_hThread;
+};
+
+
+inline DMCriticalSection::DMCriticalSection( )
+{
+ memset( &m_section, 0, sizeof( m_section ) );
+
+ NRES(pthread_mutex_init( &m_section, 0 ));
+ IMASSERT( nRes == 0 );
+}
+
+inline DMCriticalSection::~DMCriticalSection()
+{
+ NRES(pthread_mutex_destroy( &m_section ));
+ IMASSERT( nRes == 0 );
+}
+
+inline void DMCriticalSection::Enter()
+{
+ NRES(pthread_mutex_lock( &m_section ));
+ IMASSERT( nRes == 0 );
+}
+
+inline void DMCriticalSection::Leave()
+{
+ NRES(pthread_mutex_unlock( &m_section ));
+
+ IMASSERT( nRes == 0 );
+}
+
+inline bool DMCriticalSection::TryEnter()
+{
+ int nRes = pthread_mutex_trylock( &m_section );
+
+ IMASSERT( nRes == 0 || nRes == EBUSY );
+
+ return nRes == 0;
+}
+
+
+class DMSingleLock
+{
+ DMCriticalSection& m_oSection;
+public:
+ /**
+ * Constructor
+ * \param oSection [in] - critical section(mutex)
+ */
+ DMSingleLock( DMCriticalSection& oSection ): m_oSection( oSection )
+ {
+ m_oSection.Enter();
+ }
+
+ /**
+ * Destructor
+ */
+ ~DMSingleLock()
+ {
+ m_oSection.Leave();
+ }
+};
+
+ #define DmThSleep(a) usleep(a)
+
+#endif
diff --git a/engine/dmlib/portlib/lj/hdr/dmThreadQueue.h b/engine/dmlib/portlib/lj/hdr/dmThreadQueue.h
new file mode 100644
index 0000000..6084c54
--- /dev/null
+++ b/engine/dmlib/portlib/lj/hdr/dmThreadQueue.h
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMTHREADQUEUE_INCLUDE
+#define DMTHREADQUEUE_INCLUDE
+
+/*==================================================================================================
+
+ Header Name: dmThreadQueue.h
+
+ General Description: This file contains declaration of the DMThread and DMThreadQueue classes
+
+==================================================================================================*/
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <limits.h>
+#include <time.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#include "jem_defs.hpp"
+#include "dmdefs.h"
+#include "dmThreadHelper.h"
+
+#define DM_WAIT_FOREVER LONG_MAX
+
+enum {
+ SYNCML_DM_THREAD_EVENT_TYPE_NONE,
+ SYNCML_DM_THREAD_EVENT_TYPE_TIMEOUT,
+ SYNCML_DM_THREAD_EVENT_TYPE_SHUTDOWN,
+ SYNCML_DM_THREAD_EVENT_TYPE_FILELOCK
+};
+typedef UINT8 SYNCML_DM_THREAD_EVENT_TYPE_T;
+
+
+class DMThreadEvent {
+public:
+
+ /**
+ * Constructor
+ * \param nID [in] - event type to be sent
+ * \param pData [in] - pointer on data to be sent
+ */
+ DMThreadEvent(SYNCML_DM_THREAD_EVENT_TYPE_T nID = SYNCML_DM_THREAD_EVENT_TYPE_NONE,
+ void* pData = NULL ) : m_nID( nID ), m_pUserData(pData) {}
+
+ /**
+ * Retrieves event type
+ */
+ SYNCML_DM_THREAD_EVENT_TYPE_T GetEventType() const {return m_nID;}
+
+ /**
+ * Retrieves event data
+ */
+ void* GetData() const {return m_pUserData;}
+
+protected:
+ /** Event type */
+ SYNCML_DM_THREAD_EVENT_TYPE_T m_nID;
+ /** Event data */
+ void* m_pUserData;
+};
+
+// maximum number of events in the queue
+#define DM_EVENT_QUEUE_MAX_LEN 50
+
+class DMThreadQueue : public JemBaseObject {
+
+public:
+ /**
+ * Default constructor
+ */
+ DMThreadQueue() ;
+
+ /**
+ * Constructor
+ * \param nID [in] - event type to be sent
+ * \param pData [in] - pointer on data to be sent
+ * \return TRUE if success
+ */
+ bool Post(SYNCML_DM_THREAD_EVENT_TYPE_T nID,
+ void* pData = NULL ) ;
+
+ /**
+ * Stops timer
+ */
+ void KillTimer() ;
+
+ /**
+ * Sets timer
+ * \param nTimeoutMS [in] - time out in mseconds
+ */
+ void SetTimer( int nTimeoutMS ) ;
+
+ /**
+ * Waits event to arrive
+ * \param nTimeoutMS [in] - time out in mseconds
+ * \return TRUE if event received
+ */
+ bool Wait(long nTimeoutMS,
+ DMThreadEvent& event );
+
+ /**
+ * Checks if timer is set
+ * \return TRUE if timer is set
+ */
+ bool IsTimerSet() const { return m_bTimerSet; }
+
+protected:
+ /**
+ * Destructor
+ */
+ ~DMThreadQueue() ;
+
+
+private:
+ /**
+ * Retrives time adjusted on timeout
+ * \param stimeout [out] - time
+ * \param nTimeoutMS [in] - time out in mseconds
+ */
+ void GetTimeWithinTimeout(struct timespec &stimeout,
+ long nTimeoutMS ) const ;
+
+ /**
+ * Calculates remaining wait time
+ * \param sWaitTo [out] - time to wait
+ * \param nTimeoutMS [in] - time out in mseconds
+ */
+ void GetWaitTime(struct timespec &sWaitTo,
+ const struct timespec &stimeout ) const ;
+
+ /**
+ * Verifies if timer is ready
+ * \return TRUE if timer is ready
+ */
+ bool TimerReady() const ;
+
+ /* Events placeholder */
+ DMThreadEvent m_aEvents[DM_EVENT_QUEUE_MAX_LEN];
+ /** Queue Index */
+ int m_nHead;
+ /** Event count */
+ int m_nSize;
+ /** threas condition */
+ pthread_cond_t m_oCond;
+ /** Critical section */
+ DMCriticalSection m_csMutex;
+ /** Time when timer is started */
+ struct timespec m_sTimerFireTime;
+ /** Flag to verify if timer is set */
+ bool m_bTimerSet;
+};
+
+typedef JemSmartPtr<DMThreadQueue> PDMThreadQueue;
+
+#endif
diff --git a/engine/dmlib/portlib/lj/hdr/dmprofile.h b/engine/dmlib/portlib/lj/hdr/dmprofile.h
new file mode 100644
index 0000000..287da01
--- /dev/null
+++ b/engine/dmlib/portlib/lj/hdr/dmprofile.h
@@ -0,0 +1,200 @@
+#ifndef __DMPROFILE_H__
+#define __DMPROFILE_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#ifdef DM_PERFORMANCE_ENABLED
+
+#include "trace_perf.h"
+
+#endif
+
+enum {
+ DM_INITIALIZE_ENTER = 18000000,
+ DM_INITIALIZE_EXIT = 18000001,
+ DM_GET_TREE_ENTER = 18000002,
+ DM_GET_TREE_EXIT = 18000003,
+ DM_GET_NODE_ENTER = 18000004,
+ DM_GET_NODE_EXIT = 18000005,
+ DM_UNINITIALIZE_ENTER = 18000006,
+ DM_UNINITIALIZE_EXIT = 18000007,
+ DM_INITIALIZE_MOUNT = 18000008,
+ DM_INITIALIZE_MDF = 18000009,
+ DM_INITIALIZE_PLUGIN = 18000010,
+ DM_INITIALIZE_ACRHIVER = 18000011,
+ DM_INITIALIZE_FILE = 18000012,
+ DM_INITIALIZE_LOCK = 18000013,
+ DM_INITIALIZE_ACL = 18000014,
+ DM_INITIALIZE_EVENT = 18000015,
+ DM_INITIALIZE_LOAD = 18000016,
+
+};
+
+
+#ifdef DM_PERFORMANCE_ENABLED
+#define DM_PERFORMANCE(event) TRACE_PERF(event)
+#else
+#define DM_PERFORMANCE(event)
+#endif
+
+
+#ifdef DM_PROFILER_ENABLED
+#include <sys/time.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef DEBUG
+extern int s_nBlocks , s_nSize, s_nCnt;
+#endif
+
+// static storage for performance statistic
+#define PROF_CELL_NUM 20000
+struct CDMProfCell {
+ const char* _s;
+ long long _elapsed, _from;
+};
+
+extern CDMProfCell g_aProfStorage[PROF_CELL_NUM];
+extern int g_nProfCurCell;
+
+struct CDMProfile {
+
+ CDMProfile( const char* s) {
+ _s = s;
+ gettimeofday( &_tv1, NULL );
+#ifdef DEBUG
+ _nasBlocks = s_nBlocks;
+ _nWasSize = s_nSize;
+ _nWasTotal = s_nCnt;
+#endif
+ }
+ ~CDMProfile() {
+ struct timeval tv2;
+ gettimeofday( &tv2, NULL );
+ long long n1 = _tv1.tv_usec + (_tv1.tv_sec * 1000000 );
+ long long n2 = tv2.tv_usec + (tv2.tv_sec * 1000000 );
+ long long elapsed = n2 - n1;
+ //printf( "DMProfile: %s, time is %lld usec, from %lld to %lld\n", _s, elapsed, n1, n2 );
+ int nCurCell = g_nProfCurCell++ % PROF_CELL_NUM;
+ g_aProfStorage[nCurCell]._s = strdup( _s );
+ g_aProfStorage[nCurCell]._elapsed = elapsed;
+ g_aProfStorage[nCurCell]._from = n1;
+
+#ifdef DEBUG
+#ifdef DM_DM_MEMORY_USAGE_ENABLED
+ printf( "DMProfile: %s, time is %lld usec, from %lld to %lld\n", _s, elapsed, n1, n2 );
+
+ printf( "Total Blocks %d (delta is %d), size %d (delta is %d), total allocated (including deallocated) %d, (d %d)\n\n",
+ s_nBlocks, s_nBlocks - _nasBlocks,
+ s_nSize, s_nSize - _nWasSize,
+ s_nCnt, s_nCnt - _nWasTotal );
+#endif
+#endif
+ }
+
+ struct timeval _tv1;
+ const char* _s;
+#ifdef DEBUG
+ int _nasBlocks, _nWasSize, _nWasTotal;
+#endif
+};
+
+#define DM_PROFILE_EXT(msg,num) CDMProfile __oProf##num(msg );
+#define DM_PROFILE(msg) CDMProfile __oProf(msg );
+
+#else
+#define DM_PROFILE(msg)
+#define DM_PROFILE_EXT(msg,num)
+#endif
+
+
+#ifdef DM_PROFILER_STACK
+
+#include <sys/time.h>
+#include <stdio.h>
+#include <string.h>
+#include "dmvector.h"
+
+// static storage for performance statistic
+#define PROF_STACK_NUM 20000
+struct DMProfileData {
+ const char* _s;
+ long long _elapsed, _from;
+};
+
+extern DMProfileData __aProfStackStorage[PROF_STACK_NUM];
+extern int g_nProfCurCell;
+
+struct CDMProfileCapture {
+
+ CDMProfileCapture(DMStringVector itemNames, DMStringVector itemValues) {
+ _itemNames = itemNames;
+ _itemValues = itemValues;
+ gettimeofday( &_tv1, NULL );
+ }
+
+ ~CDMProfileCapture() {
+ struct timeval tv2;
+ gettimeofday( &tv2, NULL );
+ long long n1 = _tv1.tv_usec + (_tv1.tv_sec * 1000000 );
+ long long n2 = tv2.tv_usec + (tv2.tv_sec * 1000000 );
+ long long elapsed = n2 - n1;
+
+ DMString tmp = "";
+ DMString tmpValue = "";
+
+ for (int i = 0; i < _itemNames.size(); i++) {
+ tmp += " <";
+ tmp += _itemNames[i];
+ tmp += ">";
+ tmpValue = _itemValues[i];
+
+ tmpValue.replaceAll('<', '#');
+ tmpValue.replaceAll('>', '#');
+
+ tmp += tmpValue;
+
+ const char* ch = _itemValues[i].c_str();
+
+ int size = strlen(ch);
+
+ if (ch[size - 1] == '\n') {
+ tmp += " </";
+ } else {
+ tmp += "</";
+ }
+
+ tmp += _itemNames[i];
+ tmp += ">\n";
+ }
+
+ int nCurCell = g_nProfCurCell++ % PROF_STACK_NUM;
+ __aProfStackStorage[nCurCell]._s = strdup(tmp.c_str());
+
+ __aProfStackStorage[nCurCell]._elapsed = elapsed;
+ __aProfStackStorage[nCurCell]._from = n1;
+ }
+
+ struct timeval _tv1;
+ const char* _s;
+ DMStringVector _itemNames;
+ DMStringVector _itemValues;
+};
+
+#define DM_PROFILE_STACK(itemNames, itemValues) CDMProfileCapture __oProfStack(itemNames, itemValues);
+
+#else
+#define DM_PROFILE_STACK(itemNames, itemValues)
+#endif
+
+
+#ifdef DM_FILE_OUTPUT
+void DMFileOutput( const char* szFormat, ... );
+#else
+#define DMFileOutput
+#endif
+
+#endif // __DMPROFILE_H__
+
diff --git a/engine/dmlib/portlib/lj/src/dmAllocatedPointersPool.cc b/engine/dmlib/portlib/lj/src/dmAllocatedPointersPool.cc
new file mode 100644
index 0000000..cfc4704
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/dmAllocatedPointersPool.cc
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmAllocatedPointersPool.cc
+
+ General Description: Implementation of the DMAllocatedPointersPool class
+
+==================================================================================================*/
+
+#include "dmMemory.h"
+#include "dmThreadHelper.h"
+#include <stdio.h>
+#include <sys/time.h>
+#include <signal.h>
+#include "dmAllocatedPointersPool.h"
+
+#ifdef DEBUG
+DMAllocatedPointersPool::~DMAllocatedPointersPool()
+{
+#ifdef DEBUG
+ //PrintUnreleased();
+#endif
+}
+
+void DMAllocatedPointersPool::PrintUnreleased()
+{
+ DMSingleLock oLock( m_csPointerPoolLock );
+
+ std::map<void*, int>::const_iterator vli = m_listOfAllocatedPointers.begin();
+ int nBlockNum = 1;
+
+ while (vli != m_listOfAllocatedPointers.end())
+ {
+ const char *ptr = (const char*)(const void*)vli->first;
+ CPCHAR* ppStr = (CPCHAR*)ptr;
+
+ ptr += 3*sizeof(const char*) + DMAllocatedPointersPool::c_nExtraBytes;
+
+ printf( "%d. block (%d bytes) with addr %p was not deallocated; file %s, line %d\n",
+ nBlockNum++, (int)ppStr[2], ptr, ppStr[0], (int)ppStr[1] );
+ vli++;
+ }
+ if ( nBlockNum > 1 )
+ printf( "\n" );
+
+ //m_listOfAllocatedPointers.clear();
+}
+#endif //DEBUG
diff --git a/engine/dmlib/portlib/lj/src/dmMemory.cc b/engine/dmlib/portlib/lj/src/dmMemory.cc
new file mode 100644
index 0000000..2a8c2a0
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/dmMemory.cc
@@ -0,0 +1,223 @@
+#include "dmAllocatedPointersPool.h"
+#include <malloc.h>
+#include <stdio.h>
+#include "xpl_Logger.h"
+#include "dmMemory.h"
+
+#ifdef DEBUG
+DMAllocatedPointersPool *s_pAllocatedPool = new DMAllocatedPointersPool;
+
+// SU API functions - only used in SyncML DM code
+const int c_nMemPrefix = 3*sizeof(const char*) + DMAllocatedPointersPool::c_nExtraBytes;
+const int c_nMemPostfix = DMAllocatedPointersPool::c_nExtraBytes;
+#endif
+
+//#define MEASURE_MEMORY
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+int g_nMaxMem = 0;
+int g_nCurMem = 0;
+int g_nNumber = 0;
+
+void DmMemoryStatisticsWrite(const char* header)
+{
+}
+
+void DmMemoryStatisticsReportLeaks( void )
+{
+}
+
+#endif
+
+int DmGetMemFailedFlag( void )
+{
+ return 0;
+}
+void DmResetMemFailedFlag( void )
+{
+}
+
+#ifdef DEBUG
+
+int s_nBlocks = 0, s_nSize = 0;
+int s_nCnt = 0;
+
+
+
+void* DmAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine )
+{
+ s_nBlocks ++;
+ s_nSize += (bufsize + 3) / 4 * 4;
+
+ // emulate low memory case
+ static int s_nFirstBlocks = 4*1024 +1;
+
+ s_nCnt++;
+
+ if ( !s_nFirstBlocks ) {
+ if ( (s_nCnt % 1024) == 0)
+ ; //return NULL;
+ }
+ else
+ s_nFirstBlocks--;
+
+
+ if ( (s_nCnt % 102400) == 0 )
+ {
+ XPL_LOG_DM_TMN_Debug(("Total blocks %d, Blocks %d, size %d\n\n", s_nCnt, s_nBlocks, s_nSize ));
+ }
+
+
+ char* ptr = (char*)malloc(bufsize + c_nMemPrefix + c_nMemPostfix);
+ if (ptr == 0)
+ {
+ XPL_LOG_DM_TMN_Debug(("Malloc failed. Memory not available. %d asked by %s In %d. \n",
+ bufsize,szFile, nLine));
+ }
+ else
+ {
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+ g_nCurMem += (bufsize + 3) / 4 * 4;
+ g_nMaxMem = (g_nMaxMem > g_nCurMem ? g_nMaxMem : g_nCurMem);
+ g_nNumber++;
+#endif
+
+ s_pAllocatedPool->append(ptr);
+ memset(ptr,0xcd,bufsize + c_nMemPrefix + c_nMemPostfix);
+
+ CPCHAR* ppStr = (CPCHAR*)ptr;
+ ppStr[0] = strdup( szFile );
+ ppStr[1] = (CPCHAR)nLine;
+ ppStr[2] = (CPCHAR)(long)bufsize;
+
+ ptr += c_nMemPrefix;
+ memset(ptr,0,bufsize);
+ XPL_LOG_DM_TMN_Debug(("Allocating %d memory at %p in file %s In %d. \n",
+ bufsize, ptr, szFile, nLine));
+ }
+ return(ptr);
+}
+
+void DmFreeMemEx(void *ptr, CPCHAR szFile, int nLine)
+{
+ unsigned char* bufptr = (unsigned char*)ptr;
+ if(bufptr != 0 ){
+ bufptr -= c_nMemPrefix;
+
+ if ( s_pAllocatedPool->remove(bufptr)) {
+ // check over/under run of the buffer
+ bool bCorrupted = false;
+ CPCHAR* ppStr = (CPCHAR*)bufptr;
+ for ( int i = 1; i <= DMAllocatedPointersPool::c_nExtraBytes; i++ )
+ {
+ if ( bufptr[c_nMemPrefix-i] != 0xcd ||
+ bufptr[c_nMemPrefix + (int)ppStr[2] + i - 1] != 0xcd )
+ bCorrupted = true;
+ }
+
+ s_nBlocks --;
+ s_nSize -= ((int)ppStr[2] + 3) / 4 * 4;
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+ g_nCurMem -= ((int)ppStr[2] + 3) / 4 * 4;
+ g_nNumber--;
+#endif
+
+ if ( bCorrupted )
+ {
+ XPL_LOG_DM_TMN_Debug(("Block has been corrupted with writing before/after the allocated block; pointer %p; file %c ln. %d size %d \n",
+ (void*) (bufptr + c_nMemPrefix), ppStr[0], (int) ppStr[1], (int) ppStr[2]));
+ }
+ free( (void*)ppStr[0] );
+ memset(ptr, 0xcd, (int)ppStr[2] );
+ free(bufptr);
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Debug(("Invalid or duplicate freeing %p memory. infile %s ln. %d \n",
+ (void*) (bufptr + c_nMemPrefix), szFile, nLine));
+ }
+ }
+}
+
+void* DmReallocMem( void* ptr, int nSize )
+{
+ // debug version:
+
+ if ( nSize <= 0 ){
+ DmFreeMem( ptr );
+ return NULL;
+ }
+
+ if ( !ptr )
+ return DmAllocMem( nSize );
+
+ // check for buf size - if it registered...
+ unsigned char* bufptr = (unsigned char*)ptr;
+ if(bufptr != 0 )
+ bufptr -= c_nMemPrefix;
+
+ if ( !s_pAllocatedPool->exists(bufptr))
+ {
+ // invalid input parameter!!!
+ XPL_LOG_DM_TMN_Debug(("Realloc is called with invalid input parameter: block %p was not allocated or already was freed \n",
+ (void*) (bufptr + c_nMemPrefix)));
+ return DmAllocMem( nSize );
+ }
+
+ CPCHAR* ppStr = (CPCHAR*)bufptr;
+ int nBlockSize = (int)ppStr[2];
+
+ if ( nBlockSize >= nSize )
+ return ptr; // nothing to do - current block is large enough
+
+ void* pNewBlock = DmAllocMem( nSize );
+
+ if ( pNewBlock )
+ memcpy( pNewBlock, ptr,(nBlockSize < nSize ? nBlockSize : nSize) );
+
+ DmFreeMem(ptr);
+ return pNewBlock;
+}
+
+#else //!DEBUG
+
+void* DmReallocMem(void *ptr, int nSize)
+{
+ return realloc(ptr,nSize);
+}
+
+void * DmAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine )
+{
+ char* ptr = (char*)malloc(bufsize);
+ if (ptr != 0) {
+ memset(ptr,0,bufsize);
+ }
+ return ptr;
+}
+
+void DmFreeMemEx(void *ptr, CPCHAR szFile, int nLine)
+{
+ if (ptr) {
+ free( ptr );
+ }
+}
+
+#endif //DEBUG
+
+
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+extern "C" void suPrintMemoryUsage()
+{
+ XPL_LOG_DM_TMN_Debug(("Memory usage summary: allocated %d block(s) with total %d bytes. Max usage was %d \n",
+ g_nNumber, g_nCurMem, g_nMaxMem));
+}
+#endif
+
+#ifdef DEBUG
+struct CMemoryStatusPrint
+{
+ ~CMemoryStatusPrint() {
+ s_pAllocatedPool->PrintUnreleased();
+ }
+}s_oMemoryStatus;
+#endif
+
diff --git a/engine/dmlib/portlib/lj/src/dmThreadHelper.cc b/engine/dmlib/portlib/lj/src/dmThreadHelper.cc
new file mode 100644
index 0000000..31f9d49
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/dmThreadHelper.cc
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmThreadHelper.cc
+
+ General Description: Implementation of the DMThread class
+
+==================================================================================================*/
+
+#include "dmThreadHelper.h"
+#include "dmMemory.h"
+#include "xpl_Logger.h"
+
+bool DMThread::StartThread()
+{
+ if ( m_bRunning )
+ return false;
+
+ m_bRunning = true;
+
+ int nRes = pthread_create( &m_hThread, 0, ThreadProc, (void*)this );
+
+ if ( nRes != 0 )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMThread: can't create a thread; error %d \n", nRes));
+
+ m_bRunning = false;
+ return false;
+ }
+ return true;
+}
+
+bool DMThread::StopThread()
+{
+ if ( !m_bRunning )
+ return false;
+
+ m_bRunning = false;
+
+ bool bRet = (pthread_join( m_hThread, NULL ) == 0);
+
+ return bRet;
+}
+
+void* DMThread::ThreadProc(void *pArg)
+{
+ DMThread* pThis = (DMThread*)pArg;
+ void* pRes = 0;
+
+ if ( pThis->m_bRunning )
+ pRes = pThis->Run();
+
+ return pRes;
+}
diff --git a/engine/dmlib/portlib/lj/src/dmThreadQueue.cc b/engine/dmlib/portlib/lj/src/dmThreadQueue.cc
new file mode 100644
index 0000000..1e865bf
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/dmThreadQueue.cc
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*==================================================================================================
+
+ Source Name: dmThreadQueue.cc
+
+ General Description: Implementation of the DMThreadQueue class
+
+==================================================================================================*/
+
+#include "dmprofile.h"
+#include "dmAllocatedPointersPool.h"
+#include <stdio.h>
+
+DMThreadQueue::~DMThreadQueue()
+{
+ pthread_cond_destroy( &m_oCond );
+}
+
+DMThreadQueue::DMThreadQueue() :
+ m_nHead(0), m_nSize(0)
+{
+ pthread_cond_t t = PTHREAD_COND_INITIALIZER;
+ m_oCond = t;
+ m_bTimerSet = false;
+}
+
+bool DMThreadQueue::Post( SYNCML_DM_THREAD_EVENT_TYPE_T nID, void* pData /*= NULL*/ )
+{
+ DMSingleLock oLock( m_csMutex );
+
+ if ( m_nSize == DIM(m_aEvents) ) { // overflow - wait a little bit
+ m_csMutex.Leave();
+ sleep( 5 );
+ m_csMutex.Enter();
+ }
+
+ if ( m_nSize == DIM(m_aEvents) ) // still overflow - something unexpected happen
+ return false;
+
+ m_aEvents[m_nHead] = DMThreadEvent( nID, pData );
+ m_nHead ++; m_nHead %= DIM(m_aEvents);
+ m_nSize++;
+
+ pthread_cond_signal( &m_oCond );
+ return true;
+}
+
+void DMThreadQueue::KillTimer()
+{
+ DMSingleLock oLock( m_csMutex );
+
+ m_bTimerSet = false;
+}
+
+void DMThreadQueue::SetTimer( int nTimeoutMS )
+{
+ DMSingleLock oLock( m_csMutex );
+
+ GetTimeWithinTimeout( m_sTimerFireTime, nTimeoutMS );
+ m_bTimerSet = true;
+
+ pthread_cond_signal( &m_oCond );
+}
+
+bool DMThreadQueue::Wait( long nTimeoutMS, DMThreadEvent& event )
+{
+ DMSingleLock oLock( m_csMutex );
+ struct timespec stimeout;
+ GetTimeWithinTimeout( stimeout, nTimeoutMS );
+
+ while ( !m_nSize && nTimeoutMS ) { // wait if empty
+ struct timespec swaitTo;
+
+ GetWaitTime( swaitTo, stimeout );
+
+ pthread_cond_timedwait( &m_oCond, &m_csMutex.GetHandle(), &swaitTo);
+
+ if ( TimerReady() ||(memcmp( &swaitTo, &stimeout, sizeof(swaitTo) ) ==0) )
+ break;
+ }
+
+ if ( TimerReady() ) {
+ m_bTimerSet = false;
+ event = DMThreadEvent( SYNCML_DM_THREAD_EVENT_TYPE_TIMEOUT );
+ return true;
+ }
+
+ if ( !m_nSize ) //
+ return false;
+
+ int nIndex = (m_nHead + DIM(m_aEvents) - m_nSize) % DIM(m_aEvents);
+ m_nSize--;
+ event = m_aEvents[nIndex];
+ return true;
+}
+
+void DMThreadQueue::GetTimeWithinTimeout( struct timespec &stimeout, long nTimeoutMS ) const
+{
+ struct timeval now;
+ gettimeofday(&now,0);
+ stimeout.tv_nsec = now.tv_usec + (nTimeoutMS % 1000) * 1000; // store usec
+ stimeout.tv_sec = now.tv_sec + (nTimeoutMS / 1000) + (stimeout.tv_nsec / 10000000);
+ stimeout.tv_nsec %= 10000000;
+ stimeout.tv_nsec *= 1000; // convert to nsec
+}
+
+void DMThreadQueue::GetWaitTime(struct timespec &sWaitTo, const struct timespec &stimeout ) const
+{
+ if ( m_bTimerSet &&
+ ( (m_sTimerFireTime.tv_sec < stimeout.tv_sec) ||
+ ( (m_sTimerFireTime.tv_sec == stimeout.tv_sec) && (m_sTimerFireTime.tv_nsec < stimeout.tv_nsec) ) ) )
+ sWaitTo = m_sTimerFireTime;
+ else
+ sWaitTo = stimeout;
+}
+
+bool DMThreadQueue::TimerReady() const
+{
+ if ( !m_bTimerSet )
+ return false;
+
+ struct timespec tm;
+ GetTimeWithinTimeout( tm, 0 );
+
+ return (tm.tv_sec > m_sTimerFireTime.tv_sec) ||
+ ( (tm.tv_sec == m_sTimerFireTime.tv_sec) && (tm.tv_nsec > m_sTimerFireTime.tv_nsec) );
+
+}
diff --git a/engine/dmlib/portlib/lj/src/dmprofile.cc b/engine/dmlib/portlib/lj/src/dmprofile.cc
new file mode 100644
index 0000000..a559beb
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/dmprofile.cc
@@ -0,0 +1,452 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdarg.h>
+#include <time.h>
+#include "dmStringUtil.h"
+#include "dmprofile.h"
+#include "dmThreadHelper.h"
+#include "dmstring.h"
+
+#ifdef DM_FILE_OUTPUT
+
+void DMFileOutput( const char* szFormat, ... )
+{
+ static int s_nFirstCall = 1; // mark first access to write some additional info
+ static char filename[255];
+
+ FILE * fp=NULL;
+
+ if ( s_nFirstCall ){
+ s_nFirstCall = 0;
+
+ const char* dm_settings_env = getenv("dm_setting_root");
+
+ if ( !dm_settings_env )
+ dm_settings_env = "";
+
+ DmStrcpy (filename, dm_settings_env);
+ DmStrcat( filename, "/a/motorola/settings/DMOUTPUT.txt" );
+
+ fp=fopen(filename, "a+");
+ if (!fp)
+ return;
+
+ time_t elapstime;
+ time(&elapstime);
+
+ fprintf(fp, "\nLog started at %s \n",
+ ctime(&elapstime));
+ fclose(fp);
+ fp=NULL;
+ }
+
+ fp=fopen(filename, "a+");
+ if (!fp)
+ return;
+
+ va_list ap;
+ va_start(ap, szFormat);
+ vfprintf( fp, szFormat, ap );
+ va_end(ap);
+
+ fclose(fp);
+ fp=NULL;
+}
+
+#endif
+
+#ifdef DM_PROFILER_ENABLED
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+CDMProfCell g_aProfStorage[PROF_CELL_NUM];
+int g_nProfCurCell = 0;
+
+class CProfileCmdListener : public DMThread{
+public:
+ CProfileCmdListener() {
+ StartThread();
+ }
+ ~CProfileCmdListener() {
+ StopThread();
+ }
+
+ enum { eNone, eError, eReset, ePrint, ePrintPipe};
+ virtual void* Run();
+ int GetCommand( int nPipe );
+ void PrintResult( int nFile );
+
+ DMString _sOutPipe;
+};
+
+#define PROF_CMD_PIPE_NAME "/tmp/dmprof"
+
+void* CProfileCmdListener::Run()
+{
+printf("DM profile command listener is started\n"
+ "use file " PROF_CMD_PIPE_NAME " to manipulate it\n");
+
+{
+ // check for cvm
+ char szFile[1024];
+
+ sprintf( szFile, "/proc/%d/cmdline", (int)getpid() );
+ int nF = open( szFile, O_RDONLY );
+ if ( nF >= 0 ){
+ read( nF, szFile, sizeof(szFile ) );
+ close (nF);
+
+ if ( strstr( szFile, "cvm") == NULL )
+ return NULL;
+ }
+}
+
+ if (mkfifo(PROF_CMD_PIPE_NAME, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
+ printf("Failed to create pipe\n");
+
+ int nPipe = open(PROF_CMD_PIPE_NAME, O_NONBLOCK );
+
+ if ( nPipe < 0 ){
+ printf( "Failed to open pipe - cmd listener terminated\n");
+ return 0;
+ }
+
+ while (m_bRunning)
+ {
+ int nCmd = GetCommand( nPipe );
+
+ if ( nCmd != eNone )
+ printf( "Cmd received %d\n\n\n", nCmd );
+
+ //printf("Stat %d:\n", g_nProfCurCell);
+
+ switch ( nCmd ){
+ case eReset:
+ printf("Reset\n");
+ g_nProfCurCell = 0;
+ break;
+
+ case ePrint:
+ PrintResult(-1);
+ break;
+
+ case ePrintPipe:
+ {
+ int nFile = open( _sOutPipe, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
+ PrintResult(nFile);
+ if ( nFile > -1 )
+ close( nFile );
+ }
+ break;
+ };
+ }
+
+ close( nPipe );
+
+ return 0;
+}
+
+int CProfileCmdListener::GetCommand( int nPipe )
+{
+ if ( nPipe < 0 | nPipe > 1023 )
+ return -1;
+
+ int rc;
+ fd_set fds;
+ struct timeval tv;
+
+ FD_ZERO(&fds);
+ FD_SET(nPipe,&fds);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+
+ rc = select(nPipe+1, &fds, NULL, NULL, &tv);
+ if (rc < 0)
+ return eError;
+
+ if (!FD_ISSET(nPipe,&fds) )
+ return eNone;
+
+ char szCmd[50] = "";
+
+ int nBytes = read( nPipe, szCmd, sizeof(szCmd));
+
+ if ( nBytes == 0 ){
+ sleep(1);
+ return eNone;
+ }
+
+ if ( strncmp( szCmd, "reset", 5) == 0 )
+ return eReset;
+
+ if ( strncmp( szCmd, "print", 5) == 0 )
+ return ePrint;
+
+ if ( strncmp( szCmd, "out", 3) == 0 ){
+ _sOutPipe.assign(szCmd + 4, nBytes - 4);
+ printf( "out to [%s]\n", _sOutPipe.c_str() );
+ return ePrintPipe;
+ }
+
+ return eError;
+
+}
+
+void CProfileCmdListener::PrintResult( int nFile )
+{
+ int n = 0;
+ long long nTot = 0;
+ char szBuf[10096];
+
+ while ( n < g_nProfCurCell ){
+
+ if ( g_aProfStorage[n % PROF_CELL_NUM]._s ) {
+ int nLen = sprintf( szBuf, "%d: DMProfile: %s, time is %lld usec, from %lld to %lld\n",
+ n+1,
+ g_aProfStorage[n % PROF_CELL_NUM]._s,
+ g_aProfStorage[n % PROF_CELL_NUM]._elapsed,
+ g_aProfStorage[n % PROF_CELL_NUM]._from,
+ g_aProfStorage[n % PROF_CELL_NUM]._elapsed + g_aProfStorage[n % PROF_CELL_NUM]._from );
+
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ nTot += g_aProfStorage[n % PROF_CELL_NUM]._elapsed;
+ }
+
+ free( (void*)g_aProfStorage[n % PROF_CELL_NUM]._s );
+ g_aProfStorage[n % PROF_CELL_NUM]._s = NULL;
+ n++;
+ }
+
+ int nLen = sprintf( szBuf, "Total time is %lld\n", nTot );
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ g_nProfCurCell = 0;
+}
+
+CProfileCmdListener g_oProfileCmdListener;
+
+#endif
+
+#ifdef DM_PROFILER_STACK
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+
+DMProfileData __aProfStackStorage[PROF_STACK_NUM];
+
+int g_nProfCurCell = 0;
+
+
+class CProfileStackCmdListener : public DMThread{
+public:
+ CProfileStackCmdListener() {
+ StartThread();
+ }
+ ~CProfileStackCmdListener() {
+ StopThread();
+ }
+
+ enum { eNone, eError, eReset, ePrint, ePrintPipe};
+ virtual void* Run();
+ int GetCommand( int nPipe );
+ void PrintResult( int nFile );
+
+ DMString _sOutPipe;
+};
+
+#define PROF_CMD_PIPE_NAME "/tmp/dmprofstack"
+
+void* CProfileStackCmdListener::Run()
+{
+ printf("DM profile STACK command listener is started\n"
+ "use file " PROF_CMD_PIPE_NAME " to manipulate it\n");
+
+ {
+ // check for cvm
+ char szFile[1024];
+
+ sprintf( szFile, "/proc/%d/cmdline", (int)getpid() );
+ int nF = open( szFile, O_RDONLY );
+ if ( nF >= 0 ){
+ read( nF, szFile, sizeof(szFile ) );
+ close (nF);
+
+ if ( strstr( szFile, "cvm") == NULL )
+ return NULL;
+ }
+ }
+
+ if (mkfifo(PROF_CMD_PIPE_NAME, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
+ printf("Failed to create pipe\n");
+
+ int nPipe = open(PROF_CMD_PIPE_NAME, O_NONBLOCK );
+
+ if ( nPipe < 0 ){
+ printf( "Failed to open pipe - cmd listener terminated\n");
+ return 0;
+ }
+
+ while (m_bRunning)
+ {
+ int nCmd = GetCommand( nPipe );
+
+ if ( nCmd != eNone )
+ printf( "Cmd received %d\n\n\n", nCmd );
+
+ switch ( nCmd ){
+ case eReset:
+ printf("Reset\n");
+ g_nProfCurCell = 0;
+ break;
+
+ case ePrint:
+ PrintResult(-1);
+ break;
+
+ case ePrintPipe:
+ {
+ int nFile = open( _sOutPipe, O_WRONLY | O_CREAT | O_APPEND );
+ PrintResult(nFile);
+ if ( nFile > -1 )
+ close( nFile );
+ }
+ break;
+ };
+ }
+
+ close( nPipe );
+
+ return 0;
+}
+
+int CProfileStackCmdListener::GetCommand( int nPipe )
+{
+ if ( nPipe < 0 | nPipe > 1023 )
+ return -1;
+
+ int rc;
+ fd_set fds;
+ struct timeval tv;
+
+ FD_ZERO(&fds);
+ FD_SET(nPipe,&fds);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+
+ rc = select(nPipe+1, &fds, NULL, NULL, &tv);
+ if (rc < 0)
+ return eError;
+
+ if (!FD_ISSET(nPipe,&fds) )
+ return eNone;
+
+ char szCmd[50] = "";
+
+ int nBytes = read( nPipe, szCmd, sizeof(szCmd));
+
+ if ( nBytes == 0 ){
+ sleep(1);
+ return eNone;
+ }
+
+ if ( strncmp( szCmd, "reset", 5) == 0 )
+ return eReset;
+
+ if ( strncmp( szCmd, "print", 5) == 0 )
+ return ePrint;
+
+ if ( strncmp( szCmd, "out", 3) == 0 ){
+ _sOutPipe.assign(szCmd + 4, nBytes - 4);
+ printf( "out to [%s]\n", _sOutPipe.c_str() );
+ return ePrintPipe;
+ }
+
+ return eError;
+}
+
+void CProfileStackCmdListener::PrintResult( int nFile )
+{
+ int n = 0;
+ long long nTot = 0;
+ char szBuf[10096];
+
+ int nLen = sprintf( szBuf, "<DMProfiles>\n");
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ while ( n < g_nProfCurCell ){
+
+ if ( __aProfStackStorage[n % PROF_STACK_NUM]._elapsed ) {
+
+ nLen = sprintf( szBuf, " <DMProfile>\n");
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ nLen = sprintf( szBuf, " <ID>%d</ID>\n <ElapseTime>%lld</ElapseTime>\n <BeginTime>%lld</BeginTime>\n <EndTime>%lld</EndTime>\n%s",
+ n+1,
+ __aProfStackStorage[n % PROF_STACK_NUM]._elapsed,
+ __aProfStackStorage[n % PROF_STACK_NUM]._from,
+ __aProfStackStorage[n % PROF_STACK_NUM]._elapsed + __aProfStackStorage[n % PROF_STACK_NUM]._from,
+ __aProfStackStorage[n % PROF_STACK_NUM]._s);
+
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+
+ nLen = sprintf( szBuf, " </DMProfile>\n");
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ nTot += __aProfStackStorage[n % PROF_STACK_NUM]._elapsed;
+ }
+
+ free( (void*)__aProfStackStorage[n % PROF_STACK_NUM]._s );
+ __aProfStackStorage[n % PROF_STACK_NUM]._s = NULL;
+ n++;
+ }
+
+ nLen = sprintf( szBuf, "</DMProfiles>\n");
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ g_nProfCurCell = 0;
+}
+
+CProfileStackCmdListener g_oProfileStackCmdListener;
+
+#endif
diff --git a/engine/dmlib/portlib/lj/src/xpl_Alert.cc b/engine/dmlib/portlib/lj/src/xpl_Alert.cc
new file mode 100644
index 0000000..a4cf6c0
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/xpl_Alert.cc
@@ -0,0 +1,67 @@
+#include "xpl_dm_ServerAlert.h"
+#include <DM_DisplayAlert.h>
+#include <DM_ConfirmAlert.h>
+#include <DM_SingleChoiceAlert.h>
+#include <DM_MultipleChoiceAlert.h>
+#include <DM_TextInputAlert.h>
+
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowConfirmAlert(INT32 maxDisplayTime, CPCHAR msg, XPL_DM_ALERT_RES_T defaultResponse, XPL_DM_ALERT_RES_T * responseCode)
+{
+ return DmShowConfirmAlert(maxDisplayTime, msg, (DM_ALERT_RES_T)defaultResponse, (DM_ALERT_RES_T *)responseCode);
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowDisplayAlert(INT32 minDisplayTime, CPCHAR msg)
+{
+ return DmShowDisplayAlert(minDisplayTime, msg);
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowTextInputAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ CPCHAR defaultResponse,
+ INT32 maxLength,
+ XPL_DM_ALERT_INPUT_T inputType,
+ XPL_DM_ALERT_ECHO_T echoType,
+ XPL_DM_ALERT_TEXTINPUT_RES_T * userResponse )
+{
+ return DmShowTextInputAlert(maxDisplayTime,
+ msg,
+ defaultResponse,
+ maxLength,
+ (DM_ALERT_INPUT_T)inputType,
+ (DM_ALERT_ECHO_T)echoType,
+ (DM_ALERT_TEXTINPUT_RESPONSE_T *)userResponse );
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowSingleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ INT32 defaultResponse,
+ XPL_DM_ALERT_SCHOICE_RES_T * userResponse )
+{
+ return DmShowSingleChoiceAlert(maxDisplayTime,
+ msg,
+ choices,
+ defaultResponse,
+ (DM_ALERT_SINGLECHOICE_RESPONSE_T *)userResponse);
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowMultipleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ DMStringVector & defaultResponses,
+ XPL_DM_ALERT_MCHOICE_RES_T * userResponse)
+{
+
+ return DmShowMultipleChoiceAlert(maxDisplayTime,
+ msg,
+ choices,
+ defaultResponses,
+ (DM_ALERT_MULTIPLECHOICE_RESPONSE_T *)userResponse);
+}
+
diff --git a/engine/dmlib/portlib/lj/src/xpl_File.cc b/engine/dmlib/portlib/lj/src/xpl_File.cc
new file mode 100644
index 0000000..acc4f6f
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/xpl_File.cc
@@ -0,0 +1,477 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/vfs.h>
+#include <sys/mman.h>
+#include "xpl_Memory.h"
+#include "xpl_File.h"
+#include "xpl_Logger.h"
+#include "dmvector.h"
+
+
+class DMDirHandler
+{
+public :
+ DMDirHandler()
+ {
+ m_nIndex = 0;
+ m_bFullPath = FALSE;
+ m_pDir = XPL_NULL;
+
+ }
+ ~DMDirHandler()
+ {
+ if (m_pDir)
+ closedir(m_pDir);
+ }
+
+ void* operator new(size_t dwSize)
+ {
+ return (xplAllocMem(dwSize));
+ }
+
+ void operator delete(void *pvBuf)
+ {
+ xplFreeMem(pvBuf);
+ }
+
+ DMString m_szDirectory;
+ DMString m_szExtension;
+ INT32 m_nIndex;
+ BOOLEAN m_bFullPath;
+ DIR *m_pDir;
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+XPL_FS_HANDLE_T XPL_FS_Open(CPCHAR file_uri,
+ const XPL_FS_OPEN_MODE_T open_mode,
+ XPL_FS_RET_STATUS_T * result)
+{
+ int flags = 0;
+ XPL_FS_HANDLE_T nFileHandle;
+
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+
+ switch ( open_mode) {
+ case XPL_FS_FILE_READ:
+ flags = O_RDONLY; /* read-only at current position */
+ break;
+
+ case XPL_FS_FILE_WRITE:
+ flags = O_WRONLY | O_TRUNC | O_CREAT; /* write-only truncate file */
+ break;
+
+ case XPL_FS_FILE_RDWR:
+ flags = O_RDWR| O_CREAT; /* read and write at current position */
+ break;
+
+ case XPL_FS_FILE_APPEND:
+ flags = O_WRONLY | O_APPEND | O_CREAT; /* read and write at current position */
+ break;
+ }
+
+ nFileHandle = (XPL_FS_HANDLE_T)open(file_uri, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IRWXO);
+ // XPL_LOG_DM_XPL_Debug(("DMFileHandler::open: opening file %s with mode flag %d, errno is %d, handle = %d\n",file_uri,(int)open_mode, errno, nFileHandle));
+ if ( result && nFileHandle == -1 )
+ {
+ if (errno == EPERM) { // permission failure
+ *result = XPL_FS_RET_PERM_FAIL;
+ }
+ else {
+ *result = XPL_FS_RET_FAIL;
+ }
+ XPL_LOG_DM_XPL_Error(("DMFileHandler::open: can't open file %s with mode flag %d errno is %d\n",file_uri,(int)open_mode,errno));
+ }
+
+ if ( nFileHandle > 0 && open_mode != XPL_FS_FILE_READ )
+ {
+ chmod(file_uri,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IRWXO);
+ }
+ return nFileHandle;
+
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_Close(XPL_FS_HANDLE_T file_handle)
+{
+ int result = close((int)file_handle);
+ if ( result < 0 )
+ return XPL_FS_RET_FAIL;
+ else
+ return XPL_FS_RET_SUCCESS;
+}
+
+
+XPL_FS_COUNT_T XPL_FS_Read(XPL_FS_HANDLE_T file_handle,
+ void* buffer,
+ const XPL_FS_COUNT_T count,
+ XPL_FS_RET_STATUS_T * result)
+{
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+ XPL_FS_COUNT_T nRead = (XPL_FS_COUNT_T)read((int)file_handle,buffer,(int)count);
+ if ( result && nRead == -1 )
+ *result = XPL_FS_RET_FAIL;
+ return nRead;
+}
+
+
+XPL_FS_COUNT_T XPL_FS_Write(XPL_FS_HANDLE_T file_handle,
+ void* buffer,
+ const XPL_FS_COUNT_T count,
+ XPL_FS_RET_STATUS_T * result)
+{
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+
+ XPL_FS_COUNT_T nWrite = (XPL_FS_COUNT_T)write((int)file_handle,buffer,(int)count);
+ if ( result && nWrite == -1 ) {
+ XPL_LOG_DM_XPL_Error(("XPL_FS_Write: file_handle %d, nWrite = %d errno is %d\n",file_handle, nWrite, errno));
+ *result = XPL_FS_RET_FAIL;
+ }
+ return nWrite;
+}
+
+
+XPL_FS_SEEK_OFFSET_T XPL_FS_Seek(XPL_FS_HANDLE_T file_handle,
+ XPL_FS_SEEK_OFFSET_T offset,
+ XPL_FS_SEEK_MODE_T whence,
+ XPL_FS_RET_STATUS_T * result)
+{
+ int whence_posix;
+ XPL_FS_SEEK_OFFSET_T result_offset;
+
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+ switch(whence)
+ {
+ case XPL_FS_SEEK_SET:
+ whence_posix = SEEK_SET;
+ break;
+ case XPL_FS_SEEK_CUR:
+ whence_posix = SEEK_CUR;
+ break;
+ case XPL_FS_SEEK_END:
+ whence_posix = SEEK_END;
+ break;
+ }
+ result_offset = lseek(file_handle,offset,whence_posix);
+ if ( result && result_offset == -1)
+ *result = XPL_FS_RET_FAIL;
+ return result_offset;
+
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_Remove(CPCHAR path)
+{
+ int result = remove(path);
+ if ( result < 0 )
+ return XPL_FS_RET_FAIL;
+ else
+ return XPL_FS_RET_SUCCESS;
+}
+
+XPL_FS_RET_STATUS_T XPL_FS_Rename(CPCHAR old_name, CPCHAR new_name)
+{
+ int result = rename(old_name, new_name);
+
+ // XPL_LOG_DM_XPL_Debug(("XPL_FS_Rename: old name %s new name %s result = %d, errno is %d%d\n",old_name,new_name, errno, result));
+
+ if ( result < 0 ) {
+ XPL_LOG_DM_XPL_Error(("XPL_FS_Rename error: old name %s new name %s result = %d, errno is %d%d\n",old_name,new_name, errno, result));
+ return XPL_FS_RET_FAIL;
+ }
+ else
+ return XPL_FS_RET_SUCCESS;
+}
+
+BOOLEAN XPL_FS_Exist(CPCHAR match_uri)
+{
+ struct stat st;
+ bool result;
+
+
+ errno = 0; // reset to 0
+
+ if(stat(match_uri, &st) < 0)
+ result = FALSE;
+ else
+ result = TRUE;
+
+ // XPL_LOG_DM_XPL_Debug(("XPL_FS_Exists: match uri %s, errno is %d result = %d\n",match_uri, errno, result));
+
+ return result;
+}
+
+BOOLEAN XPL_FS_CheckPermission(CPCHAR match_uri, XPL_FS_OPEN_MODE_T permission)
+{
+ bool result = FALSE;
+ int mode = 0;
+
+ switch (permission) {
+ case XPL_FS_RDONLY_MODE:
+ mode = R_OK;
+ break;
+ case XPL_FS_WRONLY_MODE:
+ case XPL_FS_RDWR_MODE:
+ case XPL_FS_CREAT_MODE:
+ case XPL_FS_TRUNC_MODE:
+ case XPL_FS_APPEND_MODE:
+ mode = R_OK | W_OK;
+ break;
+ default:
+ break;
+ }
+
+ errno = 0; // reset to 0
+ if (access(match_uri, mode) == 0) {
+ result = TRUE;
+ }
+ // XPL_LOG_DM_XPL_Debug(("XPL_FS_CheckPermission: match uri %s, errno is %d result = %d\n",match_uri, errno, result));
+
+ return result;
+}
+
+
+XPL_CLK_CLOCK_T XPL_FS_GetModTime(CPCHAR file_uri)
+{
+ struct stat st;
+
+ if(stat( file_uri, &st) < 0)
+ return 0; // like it was never modified
+ else
+ return (XPL_CLK_CLOCK_T)st.st_mtime;
+ }
+
+XPL_FS_SIZE_T XPL_FS_GetSize(XPL_FS_HANDLE_T file_handle)
+{
+ struct stat st;
+
+ if(fstat(file_handle, &st) < 0)
+ return XPL_FS_SIZE_INVALID;
+ return st.st_size;
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_MkDir(CPCHAR dir_uri)
+{
+ mkdir(dir_uri, S_IRWXU|S_IRWXG|S_IRWXO);
+ return XPL_FS_RET_SUCCESS;
+}
+
+XPL_FS_RET_STATUS_T XPL_FS_Lock(XPL_FS_HANDLE_T file_handle, BOOLEAN bLockExclusive )
+{
+ struct flock fl;
+
+ fl.l_type = bLockExclusive ? F_WRLCK : F_RDLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_pid = getpid();
+
+ if (fcntl(file_handle, F_SETLK, &fl) != -1)
+ return XPL_FS_RET_SUCCESS;
+ else
+ return (errno == EAGAIN ? XPL_FS_RET_TRYAGAIN : XPL_FS_RET_FAIL);
+}
+
+XPL_FS_RET_STATUS_T XPL_FS_Unlock(XPL_FS_HANDLE_T file_handle)
+{
+ struct flock fl;
+
+ fl.l_type = F_UNLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_pid = getpid();
+
+ if (fcntl(file_handle, F_SETLK, &fl) != -1)
+ return XPL_FS_RET_SUCCESS;
+ else
+ return XPL_FS_RET_FAIL;
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_Unlink(CPCHAR file_name)
+{
+ if ( unlink(file_name) == 0 )
+ return XPL_FS_RET_SUCCESS;
+ else
+ return XPL_FS_RET_FAIL;
+}
+
+
+
+XPL_FS_SHANDLE_T XPL_FS_StartSearch(CPCHAR dir_uri, CPCHAR extension, BOOLEAN bFullName, XPL_FS_RET_STATUS_T * result)
+{
+ DIR *dir = XPL_NULL;
+
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+
+ dir = opendir(dir_uri);
+ if ( dir == NULL )
+ {
+ if ( result )
+ *result = XPL_FS_RET_FAIL;
+
+ return XPL_FS_SHANDLE_INVALID;
+ }
+
+ DMDirHandler * pDirHandler = NULL;
+ pDirHandler = new DMDirHandler;
+
+ if ( pDirHandler == NULL )
+ {
+ if ( result )
+ *result = XPL_FS_RET_FAIL;
+
+ closedir( dir );
+ return XPL_FS_SHANDLE_INVALID;
+ }
+
+ if ( bFullName )
+ {
+ pDirHandler->m_szDirectory = dir_uri;
+ pDirHandler->m_bFullPath = TRUE;
+ }
+
+ pDirHandler->m_szExtension = extension;
+ pDirHandler->m_pDir = dir;
+
+ return (XPL_FS_SHANDLE_T)(pDirHandler);
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_GetSearchResult(XPL_FS_SHANDLE_T search_handle, XPL_FS_SEARCH_FILE file_name)
+{
+ DMDirHandler * pDirHandler = (DMDirHandler*)search_handle;
+ struct dirent *de = NULL;
+
+ if ( !pDirHandler || search_handle == XPL_FS_SHANDLE_INVALID )
+ return XPL_FS_RET_FAIL;
+
+ int nNameLen = 0, nDirLen = 0;
+ int nExtensionLen = strlen(pDirHandler->m_szExtension);
+ de = readdir(pDirHandler->m_pDir);
+ while ( de )
+ {
+ nNameLen = strlen(de->d_name);
+ if (nNameLen > nExtensionLen && !strncmp((de->d_name + nNameLen - nExtensionLen), pDirHandler->m_szExtension, nExtensionLen))
+ {
+ if ( pDirHandler->m_bFullPath )
+ {
+ nDirLen = strlen(pDirHandler->m_szDirectory);
+ if ( nDirLen <= 0 || nDirLen > XPL_FS_MAX_FILE_NAME_LENGTH )
+ {
+ return XPL_FS_RET_FAIL;
+ }
+
+ strcpy(file_name,pDirHandler->m_szDirectory);
+ if ( file_name[nDirLen-1] != '/' )
+ {
+ strcat(file_name,"/");
+ }
+ strcat(file_name,(CPCHAR)de->d_name);
+ }
+ else
+ strcpy(file_name,(CPCHAR)de->d_name);
+ return XPL_FS_RET_SUCCESS;
+ }
+ else
+ {
+ de = readdir(pDirHandler->m_pDir);
+ }
+ }
+
+ return XPL_FS_RET_NOT_FOUND;
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_EndSearch(XPL_FS_SHANDLE_T search_handle)
+{
+ DMDirHandler * pDirHandler = (DMDirHandler*)search_handle;
+ // DO not call closedir(...); since it's called from DirHandle destructor...
+ delete pDirHandler;
+ return XPL_FS_RET_SUCCESS;
+}
+
+
+UINT8 * XPL_FS_MemMap(XPL_FS_HANDLE_T file_handle, UINT32 size, UINT32 offset, XPL_FS_RET_STATUS_T * result)
+{
+ UINT8 * pBuffer = NULL;
+
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+
+ pBuffer = (UINT8*)mmap(0,size,PROT_READ,MAP_PRIVATE,file_handle,offset);
+ if ( pBuffer == MAP_FAILED )
+ {
+ *result = XPL_FS_RET_FAIL;
+ return NULL;
+ }
+
+ return pBuffer;
+
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_MemUnMap(UINT8 * pBuffer, UINT32 size)
+{
+ int res = munmap(pBuffer,size);
+ if ( res == 0 )
+ return XPL_FS_RET_SUCCESS;
+ else
+ return XPL_FS_RET_FAIL;
+}
+#ifdef LOB_SUPPORT
+static const char TEMP_ESN_DIR_NAME[]= "/tmp/";
+CPCHAR XPL_FS_TempEsnDir()
+{
+ return TEMP_ESN_DIR_NAME;
+}
+XPL_FS_SIZE_T XPL_FS_FreeDiskSpace(CPCHAR pEsnDir)
+{
+ struct statfs sf;
+ XPL_FS_SIZE_T retSize = 0;
+
+ if(statfs(pEsnDir, &sf) == 0)
+ {
+ retSize = sf.f_bfree * sf.f_bsize;
+ }
+ return retSize;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/portlib/lj/src/xpl_HTTP.cc b/engine/dmlib/portlib/lj/src/xpl_HTTP.cc
new file mode 100644
index 0000000..8bfc8df
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/xpl_HTTP.cc
@@ -0,0 +1,181 @@
+#include <stdio.h>
+#include "xpl_HTTP.h"
+#include "dmConnection.h"
+#include "dmStringUtil.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+static DmBrwConnector *stDmBrwConnector = NULL;
+
+XPL_HTTP_HANDLE_T XPL_HTTP_Open(CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType,
+ XPL_HTTP_RET_STATUS_T * result)
+{
+ if(stDmBrwConnector == NULL)
+ {
+ stDmBrwConnector = DmBrwCreateConnector();
+
+ if ( stDmBrwConnector == NULL )
+ {
+ if ( result )
+ *result = XPL_HTTP_RET_FAIL;
+ return XPL_HTTP_HANDLE_INVALID;
+ }
+ }
+
+
+ XPL_HTTP_RET_STATUS_T res;
+ res = stDmBrwConnector->Open(url, ConRef, (UINT32)addrType);
+ if ( res == XPL_HTTP_RET_SUCCESS )
+ {
+ if ( result )
+ *result = res;
+ return (XPL_HTTP_HANDLE_T)stDmBrwConnector;
+ }
+ else
+ {
+ if ( result )
+ *result = XPL_HTTP_RET_FAIL;
+ return XPL_HTTP_HANDLE_INVALID;
+ }
+}
+
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_SetUrl(XPL_HTTP_HANDLE_T handler,
+ CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType)
+{
+ DmBrwConnector * brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->SetUrl(url, ConRef, (UINT32)addrType);
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_SetRequestMethod(XPL_HTTP_HANDLE_T handler, XPL_HTTP_METHOD_T method)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->SetRequestMethod(method);
+}
+
+
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_SetRequestProperty(XPL_HTTP_HANDLE_T handler, CPCHAR buffer)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->SetRequestProperty((CPCHAR)"header_start", buffer);
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_Send(XPL_HTTP_HANDLE_T handler, CPCHAR data, UINT32 size)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->Send(data,size);
+}
+
+UINT32 XPL_HTTP_GetResponseLength(XPL_HTTP_HANDLE_T handler)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->GetResponseLength();
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_GetResponse(XPL_HTTP_HANDLE_T handler, char * data, UINT32 size)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->GetResponse(data,size);
+}
+
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_GetHeaderField(XPL_HTTP_HANDLE_T handler, CPCHAR field, char **value)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ DMString strValue;
+ SYNCML_DM_RET_STATUS_T ret=brwConnector->GetHeaderField(field,strValue);
+ DmStrcpy(*value, strValue.c_str());
+ return (XPL_HTTP_RET_STATUS_T)ret;
+}
+
+XPL_HTTP_CODE_T XPL_HTTP_GetResponseCode(XPL_HTTP_HANDLE_T handler)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->GetResponseCode();
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_Close(XPL_HTTP_HANDLE_T handler)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ brwConnector->Close();
+
+ DmBrwDestroyConnector(brwConnector);
+ stDmBrwConnector = NULL;
+ return XPL_HTTP_RET_SUCCESS;
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_CloseReq(XPL_HTTP_HANDLE_T handler)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->CloseReq();
+}
+
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DowloadByFile(XPL_HTTP_HANDLE_T handler, CPCHAR file_name)
+{
+ return XPL_HTTP_RET_NOT_SUPPORTED;
+
+}
+
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DownloadByBuffer(XPL_HTTP_HANDLE_T handler, UINT8 * buffer, UINT32 size)
+{
+ return XPL_HTTP_RET_NOT_SUPPORTED;
+
+}
+
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetRespHeader(XPL_HTTP_HANDLE_T handler, char ** header)
+{
+ return XPL_HTTP_RET_NOT_SUPPORTED;
+}
+
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetType(XPL_HTTP_HANDLE_T handler, char ** content_type)
+{
+ return XPL_HTTP_RET_NOT_SUPPORTED;
+
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/dmlib/portlib/lj/src/xpl_Lib.cc b/engine/dmlib/portlib/lj/src/xpl_Lib.cc
new file mode 100644
index 0000000..2d2a1b6
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/xpl_Lib.cc
@@ -0,0 +1,66 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include "xpl_Lib.h"
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static XPL_DL_HANDLE_T dllhandle_browser = NULL;
+static XPL_DL_HANDLE_T dllhandle_session = NULL;
+
+
+XPL_DL_HANDLE_T XPL_DL_Load(CPCHAR dllib_name)
+{
+ //!!! DP needs attention; ignore for now...
+ if ( 0 && !strcmp(dllib_name,"libdmssession.so") )
+ {
+ // load browser stack lib
+ dllhandle_browser = dlopen("libdmportlib.so", RTLD_NOW | RTLD_GLOBAL );
+ if ( dllhandle_browser )
+ dllhandle_session = dlopen("libdmssession.so", RTLD_NOW );
+ if ( dllhandle_session == NULL )
+ dlclose(dllhandle_browser);
+ else
+ return dllhandle_session;
+ }
+ else // plugins;
+ {
+ void * handle=dlopen(dllib_name, RTLD_LAZY );
+ return handle;
+ }
+
+}
+
+/* Gets function pointer */
+void * XPL_DL_GetFunction (XPL_DL_HANDLE_T lib_handle, CPCHAR name)
+{
+ void * pFunc=NULL;
+ pFunc=dlsym(lib_handle, name);
+ return pFunc;
+
+}
+
+/* Nnloads shared objects */
+void XPL_DL_Unload(XPL_DL_HANDLE_T lib_handle)
+{
+ if ( lib_handle == dllhandle_session && dllhandle_browser != NULL )
+ {
+ dlclose(dllhandle_browser);
+ dlclose(dllhandle_session);
+ dllhandle_browser = NULL;
+ dllhandle_session = NULL;
+ }
+ else
+ dlclose(lib_handle);
+ return;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/dmlib/portlib/lj/src/xpl_Memory.cc b/engine/dmlib/portlib/lj/src/xpl_Memory.cc
new file mode 100644
index 0000000..c452cb4
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/xpl_Memory.cc
@@ -0,0 +1,31 @@
+#include <malloc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "xpl_Memory.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void * xplAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine )
+{
+ char* ptr = (char*)malloc(bufsize);
+ if (ptr != 0) {
+ memset(ptr,0,bufsize);
+ }
+ return ptr;
+}
+
+void xplFreeMemEx(void *ptr, CPCHAR szFile, int nLine)
+{
+ if (ptr) {
+ free( ptr );
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/dmlib/portlib/lj/src/xpl_Regex.cc b/engine/dmlib/portlib/lj/src/xpl_Regex.cc
new file mode 100644
index 0000000..317b742
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/xpl_Regex.cc
@@ -0,0 +1,31 @@
+#include <ctype.h>
+#include <limits.h>
+#include "xpl_Regex.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+BOOLEAN XPL_RG_Comp(CPCHAR pattern, CPCHAR str)
+{
+ int status;
+ regex_t re;
+
+ status = regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB);
+ if ( status == 0 )
+ {
+ status = regexec(&re, str, (size_t) 0, XPL_NULL, 0);
+ }
+ regfree(&re);
+ if ( status != 0 )
+ return FALSE;
+ else
+ return TRUE;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/dmlib/portlib/lj/src/xpl_Time.cc b/engine/dmlib/portlib/lj/src/xpl_Time.cc
new file mode 100644
index 0000000..700e8e2
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/xpl_Time.cc
@@ -0,0 +1,89 @@
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+#include "xpl_Time.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+XPL_CLK_CLOCK_T XPL_CLK_GetClock()
+{
+ return (XPL_CLK_CLOCK_T)time(NULL);
+}
+
+XPL_CLK_LONG_CLOCK_T XPL_CLK_GetClockMs()
+{
+ struct timeval tv1;
+ gettimeofday( &tv1, NULL );
+ return (XPL_CLK_LONG_CLOCK_T)(tv1.tv_usec + (tv1.tv_sec * 1000000 ));
+}
+
+
+XPL_CLK_RET_STATUS_T XPL_CLK_GetTime(XPL_CLK_TM_T *parsed_time)
+{
+ return XPL_CLK_RET_SUCCESS;
+}
+
+XPL_CLK_RET_STATUS_T XPL_CLK_UnpackTime(XPL_CLK_CLOCK_T clock, XPL_CLK_TM_T *parsed_clock)
+{
+ struct tm t;
+ time_t tt = clock;
+ if ( gmtime_r(&tt, &t) != NULL )
+ {
+ parsed_clock->tm_sec = t.tm_sec;
+ parsed_clock->tm_min = t.tm_min;
+ parsed_clock->tm_hour = t.tm_hour;
+ parsed_clock->tm_mday = t.tm_mday;
+ parsed_clock->tm_mon = t.tm_mon;
+ parsed_clock->tm_year = t.tm_year;
+ parsed_clock->tm_wday = t.tm_wday;
+ parsed_clock->tm_yday = t.tm_yday;
+ parsed_clock->tm_isdst = t.tm_isdst;
+ return XPL_CLK_RET_SUCCESS;
+ }
+ return XPL_CLK_RET_FAIL;
+
+}
+
+XPL_CLK_CLOCK_T XPL_CLK_PackTime(XPL_CLK_TM_T *parsed_clock)
+{
+
+ struct tm t;
+ memset(&t, 0, sizeof(struct tm));
+ t.tm_sec = parsed_clock->tm_sec;
+ t.tm_min = parsed_clock->tm_min;
+ t.tm_hour = parsed_clock->tm_hour;
+ t.tm_mday = parsed_clock->tm_mday;
+ t.tm_mon = parsed_clock->tm_mon;
+ t.tm_year = parsed_clock->tm_year;
+ t.tm_wday = parsed_clock->tm_wday;
+ t.tm_yday = parsed_clock->tm_yday;
+ t.tm_isdst = parsed_clock->tm_isdst;
+
+ return (XPL_CLK_CLOCK_T)mktime(&t);
+}
+
+INT32 XPL_CLK_GetTimeZone(void)
+{
+ tzset();
+ return (INT32)timezone;
+}
+
+
+/* Starts timer */
+XPL_TIMER_HANDLE_T XPL_CLK_StartTimer(XPL_PORT_T port, UINT32 interval, XPL_CLK_TIMER_CBACK reply_timer)
+{
+ return XPL_CLK_HANDLE_INVALID;
+}
+
+/* Stops timer */
+XPL_CLK_RET_STATUS_T XPL_CLK_StopTimer(XPL_TIMER_HANDLE_T handle)
+{
+ return XPL_CLK_RET_SUCCESS;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/dmlib/portlib/lj/src/xpl_dm_Manager.cc b/engine/dmlib/portlib/lj/src/xpl_dm_Manager.cc
new file mode 100644
index 0000000..45a538c
--- /dev/null
+++ b/engine/dmlib/portlib/lj/src/xpl_dm_Manager.cc
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_dm_manager.cc file contains implementation
+ * for dm specific functions
+ */
+
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include "dmprofile.h"
+#include "xpl_dm_Manager.h"
+#include "dm_uri_utils.h"
+#include "xpl_Logger.h"
+#include "dmtTreeImpl.hpp"
+
+
+#ifdef FEAT_DM_VERSION_FLEX
+#include "SETUP_GetFlex.h"
+#endif
+/********************************************************************************************************************/
+
+static DMString dm_version;
+static CPCHAR dm_poc_enabled = NULL;
+
+SYNCML_DM_RET_STATUS_T XPL_DM_Init()
+{
+ if( 0 == dm_version.length() )
+ {
+#ifdef FEAT_DM_VERSION_FLEX
+ CPCHAR ver = getenv("dm_setting_version");
+ if ( ver == NULL )
+ {
+ BOOLEAN bIsVersion12;
+ getFlexBit_setupflex(DL_DB_FEATURE_ID_DM_PROTOCOL_VERSION_12_AVAILABLE,&bIsVersion12);
+ if ( bIsVersion12 )
+ {
+ dm_version = SYNCML_REP_PROTOCOL_VERSION_1_2;
+ }
+ else
+ {
+ dm_version = "1.1.2";
+ }
+ }
+ else
+ {
+ dm_version = ver;
+ }
+#else
+ CPCHAR ver = getenv("dm_setting_version");
+ if ( ver == NULL )
+ {
+ dm_version = SYNCML_REP_PROTOCOL_VERSION_1_2;
+ }
+ else
+ {
+ dm_version = ver;
+ }
+#endif
+ }
+#ifdef FEAT_DM_VERSION_FLEX
+ if ( dm_poc_enabled == NULL )
+ {
+ BOOLEAN bIsEnabled = TRUE;
+ getFlexBit_setupflex(DL_DB_FEATURE_ID_POC_PROVISION_VIA_OMADM__AVAILABLE,&bIsEnabled);
+ dm_poc_enabled = (bIsEnabled)?"1":"0";
+ }
+#endif
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T XPL_DM_DeInit()
+{
+ dm_version = NULL;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+BOOLEAN XPL_DM_IsFeatureEnabled(CPCHAR pUri)
+{
+ return TRUE;
+}
+
+
+static const char * session_lib = "libdmssession.so";
+
+CPCHAR XPL_DM_GetEnv(SYNCML_DM_ENVIRONMENT_T env_var)
+{
+
+ switch ( env_var )
+ {
+ case SYNCML_DM_SETTINGS_PATH :
+ return getenv("dm_setting_root");
+
+ case SYNCML_DM_PLUGINS_PATH :
+ return getenv("dm_setting_plugin");
+
+ case SYNCML_DM_SECURITY_LEVEL :
+ return getenv("DM_SRV_SEC_LEVEL");
+
+ case SYNCML_DM_ESCAPE_CHAR :
+ return getenv("DM_ESCAPE_CHAR");
+
+ case SYNCML_DM_MEMORY_AGING_INTERVAL :
+ return getenv("DM_AGING_CHECK_INTERVAL");
+
+ case SYNCML_DM_MEMORY_AGING_TIME :
+ return getenv("DM_AGING_TIME");
+
+ case SYNCML_DM_POWER_FAIL_IJECTION :
+ return getenv("power_fail");
+
+ case SYNCML_DM_DUMP_SESSION_PACKAGE_PATH :
+ return getenv("DUMP_SYNCML_PATH");
+
+ case SYNCML_DM_SESSION_LIB :
+ return session_lib;
+
+ case SYNCML_DM_VERSION:
+ return dm_version.GetBuffer();
+
+ case SYNCML_DM_DMACC_ROOT_PATH:
+ return ( dm_version == SYNCML_REP_PROTOCOL_VERSION_1_2 )
+ ? DM_DMACC_1_2_URI
+ : DM_DMACC_1_1_URI;
+
+ case SYNCML_DM_NODENAME_SERVERID:
+ return ( dm_version == SYNCML_REP_PROTOCOL_VERSION_1_2 )
+ ? DM_SERVERID_1_2
+ : DM_SERVERID_1_1;
+
+ case SYNCML_DM_SESSION_ID:
+ return "./DevDetail/Ext/Conf/PMF/Agents/syncmldm/Sessionid";
+
+ case SYNCML_DM_FEATURE_ID_POC_PROVISION_VIA_OMADM:
+ return dm_poc_enabled;
+
+ }
+
+ return NULL;
+
+}
+
+#define DM_CHUNK_BUFFER_LJ 8192
+
+/*==================================================================================================
+ FUNCTION : XPL_DM_GetChunkSize
+
+ DESCRIPTION : Get chunk buffer size for Linux-Java platform
+ ARGUMENT PASSED :
+
+ OUTPUT PARAMETER:
+ RETURN VALUE :
+ IMPORTANT NOTES :
+ ==================================================================================================*/
+UINT32 XPL_DM_GetChunkSize()
+{
+ return DM_CHUNK_BUFFER_LJ;
+}
diff --git a/engine/dmlib/portlib/lj/test/port_layer.cc b/engine/dmlib/portlib/lj/test/port_layer.cc
new file mode 100644
index 0000000..6f8c3ce
--- /dev/null
+++ b/engine/dmlib/portlib/lj/test/port_layer.cc
@@ -0,0 +1,63 @@
+#include "dmConnection.h"
+#include "xpl_dm_ServerAlert.h"
+#include "dmManager.h"
+#include "xpl_Notifications.h"
+
+// empty function impls from dmConnection_impl.cc
+
+DmBrwConnector * DmBrwCreateConnector()
+{
+ return NULL;
+}
+
+SYNCML_DM_RET_STATUS_T DmBrwDestroyConnector(DmBrwConnector * browser_handler)
+{
+ return SYNCML_DM_SUCCESS;
+
+}
+
+// empty function impls from dmUIAlert.cc
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowConfirmAlert(INT32 maxDisplayTime, CPCHAR msg, XPL_DM_ALERT_RES_T defaultResponse, XPL_DM_ALERT_RES_T * responseCode)
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowDisplayAlert(INT32 minDisplayTime, CPCHAR msg)
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowTextInputAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ CPCHAR defaultResponse,
+ INT32 maxLength,
+ XPL_DM_ALERT_INPUT_T inputType,
+ XPL_DM_ALERT_ECHO_T echoType,
+ XPL_DM_ALERT_TEXTINPUT_RES_T * userResponse )
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowSingleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ INT32 defaultResponse,
+ XPL_DM_ALERT_SCHOICE_RES_T * userResponse )
+{
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowMultipleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ DMStringVector & defaultResponses,
+ XPL_DM_ALERT_MCHOICE_RES_T * userResponse)
+{
+ return SYNCML_DM_SUCCESS;
+}
+
diff --git a/engine/dmlib/tool-src/bmdf_reader/reader.cpp b/engine/dmlib/tool-src/bmdf_reader/reader.cpp
new file mode 100644
index 0000000..e4eb2db
--- /dev/null
+++ b/engine/dmlib/tool-src/bmdf_reader/reader.cpp
@@ -0,0 +1,375 @@
+#include <stdio.h>
+#include <string.h>
+
+///////////////////////////////////////////////////////////////
+// global data
+enum EnumMode { enum_Mode_Quiet, enum_Mode_Default, enum_Mode_MDF } g_eMode = enum_Mode_Default;
+
+const char* c_szType[] = {
+ "null", "chr", "int", "bool",
+ "bin", "node", "", "",
+ "", "test", "", "",
+ "", "", "", ""
+};
+
+const char* c_szAccess[] = {
+ "", // 0
+ "access:Add", // 1
+ "access:Delete", // 2
+ "access:Add,Delete", // 2 + 1
+ "access:Get", // 4
+ "access:Get,Add", // 1+4
+ "access:Get,Delete", // 2 + 4
+ "access:Get,Add,Delete", // 1 +2+4
+ "access:Replace", // 8
+ "access:Add,Replace", // 1 + 8
+ "access:Delete,Replace", // 2 + 8
+ "access:Add,Delete,Replace", // 1 +2+8
+ "access:Get,Replace", // 4 + 8
+ "access:Add,Get,Replace", // 1+ 4 +8
+ "access:Delete,Get,Replace", // 2 + 4 + 8
+ "access:Add,Delete,Get,Replace", // 1+ 2 + 4 + 8
+
+ "access:Exec", // 0
+ "access:Exec,Add", // 1
+ "access:Exec,Delete", // 2
+ "access:Exec,Add,Delete", // 2 + 1
+ "access:Exec,Get", // 4
+ "access:Exec,Get,Add", // 1+4
+ "access:Exec,Get,Delete", // 2 + 4
+ "access:Exec,Get,Add,Delete", // 1 +2+4
+ "access:Exec,Replace", // 8
+ "access:Exec,Add,Replace", // 1 + 8
+ "access:Exec,Delete,Replace", // 2 + 8
+ "access:Exec,Add,Delete,Replace", // 1 +2+8
+ "access:Exec,Get,Replace", // 4 + 8
+ "access:Exec,Add,Get,Replace", // 1+ 4 +8
+ "access:Exec,Delete,Get,Replace", // 2 + 4 + 8
+ "access:Exec,Add,Delete,Get,Replace", // 1+ 2 + 4 + 8
+
+};
+
+///////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////
+static int GetInt( const unsigned char* buf, int& nOffset )
+{
+ int value = 0;
+
+ for (int i=0; i < 4; i++)
+ {
+ value |= (*(buf+nOffset)) << (i*8);
+ nOffset++;
+ }
+ return value;
+}
+
+///////////////////////////////////////////////////////////////
+static int GetInt16( const unsigned char* buf, int& nOffset )
+{
+ int value = 0;
+
+ for (int i=0; i < 2; i++)
+ {
+ value |= (*(buf+nOffset)) << (i*8);
+ nOffset++;
+ }
+ return value;
+}
+
+
+///////////////////////////////////////////////////////////////
+static int GetPrintItem( const unsigned char* buf, int& nOffset, long nSize, int nLevel, const char* szParentURI )
+{
+ int nRes = 0;
+ char szIndent[100];
+ int nStartOffset = nOffset;
+ char szCurrentURI[1024];
+
+ strcpy( szCurrentURI, szParentURI );
+
+ for ( int i = 0; i < nLevel; i++ ){
+ szIndent[i] = '\t';
+ }
+ szIndent[nLevel]=0;
+
+ if ( nOffset + 11 >= nSize ){
+ if ( g_eMode != enum_Mode_Quiet )
+ printf( "Item does not fit buffer completelly, offset %d, \n", nOffset);
+
+ return 6;
+ }
+
+ int nNameOffset = GetInt( buf, nOffset );
+
+ const unsigned char* szName = buf + nNameOffset;
+
+ if ( nNameOffset >= nSize ){
+ szName = (const unsigned char*)"<<out of the buffer>>";
+ nRes = 7;
+ }
+
+ strcat( szCurrentURI, (const char*)szName );
+
+ int nType = GetInt16( buf, nOffset );
+ int nIDOffset = 0;
+
+ if ( nType & 0x400 )
+ nIDOffset = GetInt( buf, nOffset );
+
+ const unsigned char* szID = nIDOffset ? buf + nIDOffset :(const unsigned char*)"<unset>";
+
+ if ( nIDOffset >= nSize ){
+ szID = (const unsigned char*)"<<out of the buffer>>";
+ nRes = 7;
+ }
+
+ int nAccess = buf[nOffset++];
+ int nMimeType = buf[nOffset++];
+ int nChildren = GetInt16( buf, nOffset );
+
+ int aChildren[500];
+
+ if ( nOffset + nChildren * 4 >= nSize ){
+ if ( g_eMode != enum_Mode_Quiet )
+ printf( "Item does not fit buffer completelly, offset %d, \n", nOffset);
+
+ return 6;
+ }
+
+ for( int i = 0; i < nChildren; i++ ){
+ aChildren[i] = GetInt(buf, nOffset );
+ }
+
+ int nConst = buf[nOffset++];
+
+ if ( g_eMode == enum_Mode_Default)
+ printf( "%s%04x-%04x: Name (%03x): \"%s\", type %x\tid %s\taccess %x,\tmime %x,\tchildren count %x,\t constr %x\n",
+ szIndent, nStartOffset, nOffset-1, nNameOffset,
+ szName,
+ /*szIndent,*/ nType, szID,
+ nAccess, nMimeType, nChildren, nConst );
+ else if ( g_eMode == enum_Mode_MDF) {
+ printf( "[%s]\n"
+ "type:%s\n%s\n",
+ szCurrentURI,
+ c_szType[nType &0x0f],
+ c_szAccess[nAccess &0x1f] );
+
+ if ( nType & 0x400 )
+ printf( "ID:%s\n", szID );
+
+ if ( nType & 0x200 )
+ printf( "HandledByPlugin:1\n" );
+
+ if ( nType & 0x100 )
+ printf( "storesPD:1\n" );
+ }
+
+ if ( strcmp( (const char*)szName, "." ) ==0 )
+ szCurrentURI[0]=0;
+
+ strcat(szCurrentURI, "/" );
+
+
+ // constraints
+ for ( int i = 0; i < nConst; i++ ){
+ int nConstType = buf[nOffset++];
+
+ const char* sz_Const[] = {
+ "",
+ "min",
+ "max",
+ "values",
+ "default",
+ "minLen",
+ "maxLen",
+ "regexp",
+ "nMaxLen",
+ "nValues",
+ "nRegexp",
+ "auto",
+ "recur-after-segment",
+ "max-recurrence",
+ "fk",
+ "child",
+ "depend",
+ "maxChild"
+ };
+
+ if ( nOffset + 4 >= nSize ){
+ if ( g_eMode != enum_Mode_Quiet )
+ printf( "Item does not fit buffer completelly, offset %d, \n", nOffset);
+
+ return 6;
+ }
+
+ int nValue = 0;
+ char szStrValue[30] = "";
+ const unsigned char* szValue = (const unsigned char*)szStrValue;
+
+ switch ( nConstType ){
+ default:
+ if ( g_eMode != enum_Mode_Quiet )
+ printf( "Invalid constraint type %d, offset %d, \n", nConstType, nOffset);
+ return 6;
+ case 3: case 7: case 9: case 10: case 11: case 12: case 14: case 15: case 16:
+ nValue = GetInt( buf, nOffset );
+
+ if ( nValue >= nSize ){
+ szValue = (const unsigned char*)"<<out of the buffer>>";
+ nRes = 7;
+ }
+ else
+ szValue = buf + nValue;
+ break;
+
+ case 1: case 2:
+ nValue = GetInt( buf, nOffset );
+ sprintf(szStrValue, "%d", nValue);
+ break;
+ case 5: case 6: case 8: case 13: case 17:
+ nValue = GetInt16( buf, nOffset );
+ sprintf(szStrValue, "%d", nValue);
+ break;
+ case 4:
+ if ( (nType & 0x7f) == 3 ) {// bool
+ nValue = buf[nOffset++];
+ sprintf(szStrValue, "%s", nValue ? "true": "false");
+ }
+ else {
+ nValue = GetInt( buf, nOffset );
+
+ if( (nType & 0x7f) == 2 ) // int
+ sprintf(szStrValue, "%d", nValue);
+ else {
+ if ( nValue >= nSize ){
+ szValue = (const unsigned char*)"<<out of the buffer>>";
+ nRes = 7;
+ }
+ else
+ szValue = buf + nValue;
+ }
+
+ }
+
+ break;
+ }
+
+ if ( g_eMode == enum_Mode_Default)
+ printf("%s constraint type %s, value %x \"%s\"\n", szIndent, sz_Const[nConstType], nValue, szValue );
+ else if ( g_eMode == enum_Mode_MDF)
+ printf("%s:%s\n", sz_Const[nConstType], szValue );
+
+
+ }
+
+ for ( int i = 0; i < nChildren; i++ ){
+ int n = aChildren[i];
+
+ int nResFromChildren = GetPrintItem( buf, n, nSize, nLevel + 1, szCurrentURI );
+
+ if ( nResFromChildren )
+ nRes = nResFromChildren;
+ }
+ return nRes;
+}
+
+///////////////////////////////////////////////////////////////
+static int ProcessBuffer( FILE* f, unsigned char* buf, long nSize )
+{
+ if ( fread( buf, 1, nSize, f ) != nSize )
+ return 6;
+
+ if ( g_eMode == enum_Mode_Default )
+ printf("buffer loaded...\n");
+
+ int nOffset = 0;
+
+ int n = GetInt( buf, nOffset );
+ int nVer = GetInt16( buf, nOffset );
+
+ if ( g_eMode == enum_Mode_Default )
+ printf( "%x: fsize %x; ver %x (%s)\n", nOffset - 6, n, nVer, n == nSize ? "valid" : "invalid");
+
+ return GetPrintItem( buf, nOffset, nSize, 0, "" );
+}
+
+///////////////////////////////////////////////////////////////
+static int ProcessFile( FILE* f )
+{
+ fseek( f, 0, SEEK_END );
+ long nSize = ftell( f );
+ fseek( f, 0, SEEK_SET );
+
+ if ( nSize <= 0 )
+ return 3;
+
+ if ( g_eMode == enum_Mode_Default )
+ printf( "File size is %d (dec)\n", nSize );
+
+ unsigned char* buf = new unsigned char[nSize+1];
+ if ( !buf )
+ return 4;
+
+ buf[nSize]=0;
+ int nRet = ProcessBuffer( f, buf, nSize );
+
+ delete buf;
+ return nRet;
+}
+
+///////////////////////////////////////////////////////////////
+static void Usage()
+{
+ printf("Simple reader and verifier for binary MDF files\n"
+ "always return 0 code for valid file and non zero for corrupted file\n"
+ "usage: bmdf_reader [-q] [-mdf] <bmdf file name>\n"
+ "-q -- quiet mode, return only error code (0 valid file, not 0 - invalid file)\n"
+ "-mdf -- generate text mdf\n"
+ );
+}
+
+///////////////////////////////////////////////////////////////
+static const char* ParseCmdLineOptions(int argc, char** argv)
+{
+ const char* szFileName = NULL;
+
+ for ( int i = 1; i < argc; i++ ){
+ if ( strcasecmp( argv[i], "-q") == 0 )
+ g_eMode = enum_Mode_Quiet;
+ else if ( strcasecmp( argv[i], "-mdf") == 0 )
+ g_eMode = enum_Mode_MDF;
+ else {
+ szFileName = argv[i];
+ break;
+ }
+ }
+
+ return szFileName;
+}
+
+///////////////////////////////////////////////////////////////
+int main(int argc, char** argv)
+{
+ const char* szFileName = ParseCmdLineOptions( argc, argv );
+
+ if ( !szFileName ){
+ Usage();
+ return 1;
+ }
+
+ FILE* f = fopen( szFileName, "r" );
+
+ if ( !f ){
+ printf("unable to open file %s\n", szFileName );
+ return 2;
+ }
+
+ int nRet = ProcessFile( f );
+ fclose( f );
+
+ if ( g_eMode == enum_Mode_Default )
+ printf( "\ndone, file is %s\n", nRet ? "invalid" : "ok");
+
+ return nRet;
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/BlockTable.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/BlockTable.java
new file mode 100644
index 0000000..7a7005a
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/BlockTable.java
@@ -0,0 +1,22 @@
+package com.mot.dm.dbtool;
+
+public class BlockTable {
+ public int byteCount = 0;
+ public int bitCount = 0;
+ public byte[] data;
+ public final int length;
+
+ public BlockTable(int size) {
+ data = new byte[size];
+ for(int i=0; i< size; i++){
+ data[i] = 0;
+ }
+ this.length = size;
+ }
+
+ public void appendData(byte[] newData) throws Exception{
+ for(int i=0; i< newData.length; i++){
+ this.data[byteCount++] = newData[i];
+ }
+ }
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Browser.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Browser.java
new file mode 100644
index 0000000..8311066
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Browser.java
@@ -0,0 +1,187 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+
+public class Browser {
+ public static int colsNum = 0; //number of columns in the comma sep file.
+ public static ArrayList arrBrowserFromLines = new ArrayList();
+ public static ArrayList arrBrowserLineHeaders = new ArrayList();
+
+ public Value mcc = new Value();
+ public Value mnc = new Value();
+ public Value operator_name = new Value();
+ public Value country_name = new Value();
+ public Value ap_requires_auth = new Value();
+ public Value ppp_auth_type = new Value();
+ public Value ppp_auth_name = new Value();
+ public Value ppp_auth_secret = new Value();
+ public Value service_name = new Value();
+ public Value nap_addr_type = new Value();
+ public Value gprs_access_point_name = new Value();
+ public Value dns_1 = new Value();
+ public Value dns_2 = new Value();
+ public Value bearer = new Value();
+ public Value proxy = new Value();
+ public Value proxy_addr_type = new Value();
+ public Value port = new Value();
+ public Value proxy_type = new Value();
+ public Value proxy_requires_auth = new Value();
+ public Value proxy_auth_name = new Value();
+ public Value proxy_auth_secret = new Value();
+ public Value proxy_auth_type = new Value();
+ public Value account_type = new Value();
+ public Value homepage_url = new Value();
+ public String id_name = "";
+
+ // Data validation
+ public String validateData() {
+ boolean isProxyEmpty = Validator.isValEmpty(proxy);
+ StringBuffer err = new StringBuffer();
+ err.append(Validator.validateMCC(mcc));
+ err.append(Validator.validateMNC(mnc));
+ err.append(Validator.validateStringValue(operator_name, true, -1,
+ Const.OPERATOR_NAME_MAX_LENGTH,
+ "operator_name"));
+ err.append(Validator.validateApRequiresAuth(ap_requires_auth));
+ err.append(Validator.validatePppAuthType(ppp_auth_type,
+ ap_requires_auth.val));
+ err.append(Validator.validatePppAuthName(ppp_auth_name,
+ ap_requires_auth.val));
+ err.append(Validator.validatePppAuthSecret(ppp_auth_secret,
+ ap_requires_auth.val));
+ err.append(Validator.validateStringValue(service_name, true, -1,
+ Const.SERVICE_NAME_MAX_LENGTH,
+ "service_name"));
+ err.append(Validator.validateNAPAddrType(nap_addr_type));
+ err.append(Validator.validateGprsAccessPoint(gprs_access_point_name,
+ nap_addr_type.val));
+ err.append(Validator.validateDNS(dns_1));
+ err.append(Validator.validateDNS(dns_2));
+ err.append(Validator.validateBearer(bearer));
+ err.append(Validator.validateProxy(proxy, proxy_addr_type.val));
+ err.append(Validator.validateProxyAddrType(proxy_addr_type, isProxyEmpty));
+ err.append(Validator.validatePort(port, isProxyEmpty));
+ err.append(Validator.validateProxyType(proxy_type, isProxyEmpty));
+ err.append(Validator.validateProxyRequiresAuth(proxy_requires_auth,
+ isProxyEmpty));
+ err.append(Validator.validateProxyAuthName(proxy_auth_name, isProxyEmpty,
+ proxy_requires_auth.val));
+ err.append(Validator.validateProxyAuthSecret(proxy_auth_secret,
+ isProxyEmpty,
+ proxy_requires_auth.val));
+ err.append(Validator.validateProxyAuthType(proxy_auth_type, isProxyEmpty,
+ proxy_requires_auth.val));
+ err.append(Validator.validateAccountType(account_type));
+
+ return err.toString();
+ }
+
+ public static void createXmlMessages() throws Exception {
+ for (int i = 0; i < arrBrowserFromLines.size(); i++) {
+ createXml((Browser) arrBrowserFromLines.get(i));
+ }
+ }
+
+ public static void createXml(Browser browser) throws Exception {
+ String xml;
+ // String key = browser.mcc.val + ":" + browser.mnc.val + ":" + browser.operator_name.val +
+ // ":" + browser.account_type.val.toUpperCase();
+ String key = Record.createKey(browser.mcc.val, browser.mnc.val,
+ browser.operator_name.val,
+ browser.account_type.val.toUpperCase());
+
+ browser.id_name = Util.getIdNameFromRecords(browser.service_name.val, key);
+ // APPLICATION
+ xml = " <characteristic type=\"APPLICATION\">\n";
+ xml += " <parm name=\"APPID\" value=\"w2\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + browser.id_name + "\"/>\n";
+ if (browser.proxy.val.length() > 0) {
+ xml += " <parm name=\"TO-PROXY\" value=\"PX_" + browser.id_name + "\"/>\n";
+ }
+ else {
+ xml += " <parm name=\"TO-NAPID\" value=\"NAP_" + browser.id_name + "\"/>\n";
+ }
+ // RESOURCE
+ xml += " <characteristic type=\"RESOURCE\">\n";
+ xml += " <parm name=\"URI\" value=\"" + browser.homepage_url.val +
+ "\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"RES_" + browser.id_name + "\"/>\n";
+ xml += " <parm name=\"STARTPAGE\" value=\"" + browser.homepage_url.val +
+ "\"/>\n";
+ xml += " </characteristic>\n"; ///// RESOURCE
+ xml += " </characteristic>\n\n"; ///// APPLICATION
+
+ if (browser.proxy.val.length() > 0) {
+ // PXLOGICAL
+ xml += " <characteristic type=\"PXLOGICAL\">\n";
+ xml += " <parm name=\"PROXY-ID\" value=\"PX_" + browser.id_name + "\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + browser.id_name + "\"/>\n";
+ // PXPHYSICAL
+ xml += " <characteristic type=\"PXPHYSICAL\">\n";
+ xml += " <parm name=\"PHYSICAL-PROXY-ID\" value=\"PXPH_" + browser.id_name +
+ "\"/>\n";
+ xml += " <parm name=\"PXADDR\" value=\"" + browser.proxy.val +
+ "\"/>\n";
+ xml += " <parm name=\"PXADDRTYPE\" value=\"" +
+ browser.proxy_addr_type.val + "\"/>\n";
+ xml += " <parm name=\"TO-NAPID\" value=\"NAP_" + browser.id_name + "\"/>\n";
+ if (browser.port.val.length() > 0) {
+ //PORT
+ xml += " <characteristic type=\"PORT\">\n";
+ xml += " <parm name=\"PORTNBR\" value=\"" + browser.port.val +
+ "\"/>\n";
+ if (browser.proxy_type.val.length() > 0) {
+ xml += " <parm name=\"SERVICE\" value=\"" +
+ browser.proxy_type.val +
+ "\"/>\n";
+ }
+ xml += " </characteristic>\n"; /////PORT
+ }
+ xml += " </characteristic>\n"; ///// PXPHYSICAL
+ if (Util.strToBool(browser.proxy_requires_auth.val)) {
+ // PXAUTHINFO
+ xml += " <characteristic type=\"PXAUTHINFO\">\n";
+ xml += " <parm name=\"PXAUTH-TYPE\" value=\"" +
+ browser.proxy_auth_type.val + "\"/>\n";
+ xml += " <parm name=\"PXAUTH-ID\" value=\"" +
+ browser.proxy_auth_name.val + "\"/>\n";
+ xml += " <parm name=\"PXAUTH-PW\" value=\"" +
+ browser.proxy_auth_secret.val + "\"/>\n";
+ xml += " </characteristic>\n"; ///// PXAUTHINFO
+ }
+ xml += " </characteristic>\n\n"; ///// PXLOGICAL
+ }
+ // NAPDEF
+ xml += " <characteristic type=\"NAPDEF\">\n";
+ xml += " <parm name=\"NAPID\" value=\"NAP_" + browser.id_name + "\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + browser.id_name + "\"/>\n";
+ xml += " <parm name=\"BEARER\" value=\"" + browser.bearer.val + "\"/>\n";
+ xml += " <parm name=\"NAP-ADDRESS\" value=\"" +
+ browser.gprs_access_point_name.val + "\"/>\n";
+ xml += " <parm name=\"NAP-ADDRTYPE\" value=\"" +
+ browser.nap_addr_type.val + "\"/>\n";
+ if (browser.dns_1.val.length() > 0) {
+ xml += " <parm name=\"DNS-ADDR\" value=\"" + browser.dns_1.val +
+ "\"/>\n";
+ }
+ if (browser.dns_2.val.length() > 0) {
+ xml += " <parm name=\"DNS-ADDR\" value=\"" + browser.dns_2.val +
+ "\"/>\n";
+ }
+ if (Util.strToBool(browser.ap_requires_auth.val)) {
+ // NAPAUTHINFO
+ xml += " <characteristic type=\"NAPAUTHINFO\">\n";
+ xml += " <parm name=\"AUTHTYPE\" value=\"" +
+ browser.ppp_auth_type.val +
+ "\"/>\n";
+ xml += " <parm name=\"AUTHNAME\" value=\"" +
+ browser.ppp_auth_name.val +
+ "\"/>\n";
+ xml += " <parm name=\"AUTHSECRET\" value=\"" +
+ browser.ppp_auth_secret.val + "\"/>\n";
+ xml += " </characteristic>\n"; ///// NAPAUTHINFO
+ }
+ xml += " </characteristic>\n\n"; ///// NAPDEF
+ Util.addXmlToRecord(xml, key, browser.id_name, "Browser");
+ }
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/ByteArray.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/ByteArray.java
new file mode 100644
index 0000000..8efccfb
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/ByteArray.java
@@ -0,0 +1,34 @@
+package com.mot.dm.dbtool;
+
+public class ByteArray {
+ byte[] bytes = new byte[0];
+ public ByteArray() {
+ }
+
+ public void addByte(byte b) throws Exception {
+ byte[] arr = {
+ b};
+ addBytes(arr);
+ }
+
+ public void addBytes(byte[] b) throws Exception {
+ int count = 0;
+ byte[] newBytes = new byte[bytes.length + b.length];
+ for (int i = 0; i < bytes.length; i++) {
+ newBytes[count++] = bytes[i];
+ }
+ for (int i = 0; i < b.length; i++) {
+ newBytes[count++] = b[i];
+ }
+ bytes = newBytes;
+ }
+
+ public byte[] getBytes() throws Exception {
+ return bytes;
+ }
+
+ public int length() throws Exception {
+ return bytes.length;
+ }
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Const.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Const.java
new file mode 100644
index 0000000..ba4e78f
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Const.java
@@ -0,0 +1,138 @@
+package com.mot.dm.dbtool;
+
+public class Const {
+ public static int HEAD_DB_VERSION = 1;
+ public static final String TRUE = "true";
+ public static final String FALSE = "false";
+
+ // max length for DB file
+ public static final int ALIICATION_SETTINGS_MAX_SIZE = 2 * 1024 * 1024; // 2M
+
+ // masks for Application availability bitmap (max 8)
+ public static int BROWSER_MASK = 0x0001;
+ public static int IM_MASK = 0x0002;
+ public static int JAVA_MASK = 0x0004;
+ public static int MMS_MASK = 0x0008;
+
+ //size for the fields for carrier index table in bits
+ public static int MCC_BITS = 10;
+ public static int MNC_LENGTH_BITS = 1;
+ public static int MNC_BITS = 10;
+ public static int OPERATOR_NAME_OFFSET_BITS = 17;
+ public static int ACC_TYPE_BITS = 2;
+ public static int APP_AVAIL_BITMAP_BITS = 8;
+ public static int APP_SETTINGS_OFFSET_BITS = 3 * 8; //3 bytes
+
+ //size for the application settings block in bits
+ public static int APP_BLOCK_LENGTH = 23;
+ public static int APP_COMPRESSWD_FLAG = 1;
+
+ //size for operator names and service name in bytes
+ public static int OPERATOR_NAME_MAX_LENGTH = 128;
+ public static int SERVICE_NAME_MAX_LENGTH = 128;
+
+ // === IM related fields and constrains ===
+ public static int BRAND_INSTANCE_NAME_MAX_LENGTH = 128;
+ public static int ISP_PROFILE_NAME_MAX_LENGTH = 128;
+ public static int SERVER_ADDR_MAX_LENGTH = 127;
+ public static int CLIENT_ID_MAX_LENGTH = 200;
+ public static int PRIVATE_KEY_MAX_LENGTH = 120;
+ public static int SRV_POST_URL_MAX_LENGTH = 200;
+ public static int SRV_PROXY_ADDR_MAX_LENGTH = 200;
+ public static int SRV_PROXY_PWD_MAX_LENGTH = 64;
+ public static int SRV_PROXY_USR_NAME_MAX_LENGTH = 64;
+ public static int SRV_SMS_DEST_ADDR_MAX_LENGTH = 76;
+
+
+ // supported Server Login Methods for IM
+ public static String[] SERVER_LOGIN_METHODS = {
+ "2WAY", "4WAY", "AOL"};
+ // supported Server Transport Types for IM
+ public static String[] SERVER_TRANSPORT_TYPES = {
+ "HTTP", "SMS"};
+
+ // === end IM related definitions ===
+
+ // size for NAP and Proxy UserID and Password
+ public static int USER_NAME_MAX_LENGTH = 32;
+ public static int PASWORD_MAX_LENGTH = 32;
+
+ //sizes for header table in bits
+ public static int HEAD_HEAD_SISE = 1 * 8; //one byte
+ public static int HEAD_OPERATOR_NAMES_TAB_SISE = 4 * 8; //4 byte
+ public static int HEAD_CARRIER_INDEX_TAB_SISE = 4 * 8; //4 byte
+ public static int HEAD_APP_SETTINGS_TAB_SIZE = 4 * 8; //4 byte
+ public static int HEAD_DB_VERSION_TAB_SIZE = 1 * 8; //1 byte
+
+ // files names
+ public static String WORKING_DIR = "db_xml_wbxml_files";
+ public static String DB_FILE_NAME = "lj_dmwizard.dat";
+ public static String ERROR_FILE_NAME = "db_errors.txt";
+
+ public static String PATH_SEP = java.io.File.separator;
+
+ //account type
+ public static String PREPAID = "prepaid";
+ public static int PREPAID_INT = 0;
+ public static String POSTPAID = "postpaid";
+ public static int POSTPAID_INT = 1;
+ public static String BOTH = "both";
+ public static int BOTH_INT = 2;
+
+ // supported authentication type for NAPAUTHINFO.AUTHTYPE
+ public static String[] NAPAUTHINFO_AUTHTYPE = {
+ "PAP"};
+
+ // supported NAPDEF address type NAPDEF.NAP-ADDRTYPE
+ public static String[] NAPDEF_NAPADDRTYPE = {
+ "IPV4", "IPV6", "E164", "ALPHA", "APN"};
+
+ // supported BEARER
+ public static String[] BEARER = {
+ "GSM-GPRS"};
+
+ // supported PROXY address type PXPHYSICAL.PXADDRTYPE
+ public static String[] PXPHYSICAL_PXADDRTYPE = {
+ "IPV4", "IPV6", "E164", "ALPHA"};
+
+ // supported proxy_type mapped to PORT.SERVICE
+ public static String[] PORT_SERVICE = {
+ "CL-WSP", "CO-WSP", "CL-SEC-WSP", "CO-SEC-WSP", "CO-SEC-WTA",
+ "CL-SEC-WTA", "OTA-HTTP-TO", "OTA-HTTP-TLS-TO", "OTA-HTTP-PO",
+ "OTA-HTTP-TLS-PO"};
+
+ // supported proxy_auth_type authentication type for PXAUTHINFO.PXAUTH-TYPE
+ public static String[] PXAUTHINFO_PXAUTHTYPE = {
+ "HTTP-BASIC"};
+
+////////////////// Mapping //////////////////////////////
+ /*
+ 1. mcc: n/a
+ 2. mnc: n/a
+ 3. account_type: n/a
+ 4. operator_name: n/a
+ 5. country_name: n/a
+ 6. ppp_auth_type: NAPAUTHINFO.AUTHTYPE
+ 7. ppp_auth_name: NAPAUTHINFO.AUTHNAME
+ 8. ppp_auth_secret: NAPAUTHINFO.AUTHSECRET
+ 9. ap_requires_auth: n/a
+ 10. service_name: APPLICATION.NAME, PXLOGICAL.NAME, NAPDEF.NAME
+ 11. gprs_access_point_name: NAPDEF.NAP-ADDRESS
+ 12. dns_1: NAPDEF.DNS-ADDR
+ 13. dns_2: NAPDEF.DNS-ADDR
+ 14. nap_addr_type: NAPDEF.NAP-ADDRTYPE
+ 15. bearer: NAPDEF.BEARER
+ 16. proxy: PXPHYSICAL.PXADDR
+ 17. proxy_addr_type: PXPHYSICAL.PXADDRTYPE
+ 18. port: PORT.NUMBER
+ 19. proxy_auth_name: PXAUTHINFO.PXAUTH-ID
+ 20. proxy_auth_secret: PXAUTHINFO.PXAUTH-PW
+ 21. proxy_auth_type: PXAUTHINFO.PXAUTH-TYPE
+ 22. proxy_type: PORT.SERVICE
+ 23. proxy_requires_auth: n/a
+ 24. mms_url: APPLICATION.ADDR
+ 25. homepage_url: APPLICATION.RESOUCE.STARTPAGE
+
+ */
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/DBDumper.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/DBDumper.java
new file mode 100644
index 0000000..c47a5af
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/DBDumper.java
@@ -0,0 +1,174 @@
+package com.mot.dm.dbtool;
+
+import java.io.*;
+
+public class DBDumper {
+ byte[] buffer;
+ byte[] header;
+ byte[] operatorNames;
+ byte[] carrierIndexTable;
+
+// input counters - # bits/bytes
+ int byteCount = 0;
+ int bitCount = 0;
+
+//output counters: #bits/bytes
+ int outBytes = 0;
+ int outBits = 0;
+
+ public void dump(String dbPath) {
+ try {
+ buffer = readFile(dbPath);
+ initByteArrays();
+ printRecords();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void printRecords() throws Exception {
+
+ int recordsNum = carrierIndexTable.length / 9;
+
+ for (int i = 0; i < recordsNum; i++) {
+ String mcc;
+ int mncLengthFlag;
+ String mnc;
+ int nameOffset;
+ int nameLength;
+ String name;
+ int paymentType;
+ String paymentTypeStr;
+ int applicationAvailability;
+ String usedApplications = "";
+
+ mcc = getBits(Const.MCC_BITS, carrierIndexTable) + "";
+ mncLengthFlag = getBits(Const.MNC_LENGTH_BITS, carrierIndexTable);
+ mnc = getBits(Const.MNC_BITS, carrierIndexTable) + "";
+ nameOffset = getBits(Const.OPERATOR_NAME_OFFSET_BITS, carrierIndexTable) *
+ 2;
+ paymentType = getBits(Const.ACC_TYPE_BITS, carrierIndexTable);
+ applicationAvailability = getBits(Const.APP_AVAIL_BITMAP_BITS,
+ carrierIndexTable);
+ getBits(Const.APP_SETTINGS_OFFSET_BITS, carrierIndexTable); //dummy call to shift counters
+
+ //padding "0" to mnc if required
+ int mncLength = (mncLengthFlag == 1) ? 3 : 2;
+ while (mnc.length() < mncLength) {
+ mnc = "0" + mnc;
+ }
+
+ //get operator name
+ nameLength = ( ( (int) operatorNames[nameOffset]) & 0xFF);
+ nameOffset++; //move to the begining of name
+ nameLength--; // remove one (first) byte which contains size info
+ byte[] byteName = new byte[nameLength];
+ for (int j = 0; j < nameLength; j++) {
+ byteName[j] = operatorNames[nameOffset + j];
+ }
+ name = new String(byteName, "UTF-8");
+
+ //set payment type
+ if (paymentType == Const.PREPAID_INT) {
+ paymentTypeStr = Const.PREPAID;
+ }
+ else if (paymentType == Const.POSTPAID_INT) {
+ paymentTypeStr = Const.POSTPAID;
+ }
+ else {
+ paymentTypeStr = Const.BOTH;
+ }
+
+ //set applications availability
+ if ( (applicationAvailability & Const.BROWSER_MASK) != 0) {
+ usedApplications += "Browser ";
+ }
+ if ( (applicationAvailability & Const.MMS_MASK) != 0) {
+ usedApplications += "MMS ";
+ }
+
+ if ( (applicationAvailability & Const.JAVA_MASK) != 0) {
+ usedApplications += "Java ";
+ }
+
+ if ( (applicationAvailability & Const.IM_MASK) != 0) {
+ usedApplications += "IM ";
+ }
+
+ //print one line
+ System.out.println(
+ "mcc: " + mcc + " " +
+ "mnc: " + mnc + " " +
+ "operator: " + name + " " +
+ "payment: " + paymentTypeStr + " " +
+ "applications: " + usedApplications
+ );
+ }
+ }
+
+ public void initByteArrays() throws Exception {
+ int counter = 0;
+ int max = 14;
+ int index = 0;
+ header = new byte[max];
+ for (int i = 0; i < max; i++) {
+ header[index++] = buffer[i];
+ counter++;
+ }
+
+ int operatorTableSize = ( ( ( (int) header[1]) & 0xFF) << 24) +
+ ( ( ( (int) header[2]) & 0xFF) << 16) +
+ ( ( ( (int) header[3]) & 0xFF) << 8) +
+ ( ( (int) header[4]) & 0xFF);
+
+ operatorNames = new byte[operatorTableSize];
+ max = counter + operatorTableSize;
+ index = 0;
+ for (int i = counter; i < max; i++) {
+ operatorNames[index++] = buffer[i];
+ counter++;
+ }
+ //String s = new String(operatorNames);
+ //System.out.println(s);
+
+ int carrierIndexTableSize = ( ( ( (int) header[5]) & 0xFF) << 24) +
+ ( ( ( (int) header[6]) & 0xFF) << 16) +
+ ( ( ( (int) header[7]) & 0xFF) << 8) +
+ ( ( (int) header[8]) & 0xFF);
+ carrierIndexTable = new byte[carrierIndexTableSize];
+ max = counter + carrierIndexTableSize;
+ index = 0;
+ for (int i = counter; i < max; i++) {
+ carrierIndexTable[index++] = buffer[i];
+ counter++;
+ }
+ if ( (carrierIndexTableSize % 9) != 0) {
+ throw new Exception(
+ "One record in the Carrier Index Table has incorrect length.");
+ }
+
+ }
+
+ public int getBits(int nBits, byte[] byteArr) {
+ int res = 0;
+
+ for (int i = nBits - 1; i >= 0; i--) {
+ res |= (byteArr[outBytes] & (1 << (7 - outBits))) == 0 ? 0 : 1 << i;
+ outBits++;
+ if (outBits == 8) {
+ outBits = 0;
+ outBytes++;
+ }
+ }
+ return res;
+ }
+
+ public byte[] readFile(String dbPath) throws Exception {
+ FileInputStream is = new FileInputStream(dbPath);
+ byte[] bytes = new byte[is.available()];
+ is.read(bytes);
+ is.close();
+ return bytes;
+ }
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Generator.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Generator.java
new file mode 100644
index 0000000..858705c
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Generator.java
@@ -0,0 +1,493 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+import java.io.*;
+
+public class Generator {
+
+ public static boolean REMOVE_WORKING_DIR = true;
+ public static boolean USE_ZIP = true;
+ public static boolean IS_INPUT_TXT_FILE;
+ public static String ENCODING; // UTF-8 for csv and UTF-16 for txt
+
+ public static String pathMMSFile = null;
+ public static String pathBrowserFile = null;
+ public static String pathJavaAppFile = null;
+ public static String pathIMFile = null;
+
+ public static ArrayList arrMMSLines = new ArrayList();
+ public static ArrayList arrBrowserLines = new ArrayList();
+ public static ArrayList arrJavaAppLines = new ArrayList();
+ public static ArrayList arrIMLines = new ArrayList();
+
+ //for one combine primary key for all settings
+ public static HashMap hashXmlRecords = new HashMap();
+ public static Record[] arraySortedRecords;
+ public static StringBuffer operatorsNamesBuffer = new StringBuffer();
+ public static ByteArray operatorsNamesBytes = new ByteArray();
+
+ //### tables
+ public static BlockTable operatorsNamesTable;
+ public static BlockTable applicationsSettingsTable;
+ public static BlockTable carrierIndexTable;
+ public static BlockTable headerTable;
+
+ public void proceed() throws Exception {
+ Util.deleteDir(Const.WORKING_DIR);
+ Util.deleteFile(Const.DB_FILE_NAME);
+ Util.deleteFile(Const.ERROR_FILE_NAME);
+
+ if (! (new File(Const.WORKING_DIR)).mkdir()) {
+ throw new Exception(
+ "Error! Cannot create working directory for xml, wbxml and zip files");
+ }
+
+ fillArrLines();
+ validateArrLines();
+ createXmlMessages();
+ Util.writeRecordsToFiles();
+ Util.sortAllRecordsIntoArray();
+ genenerateOperatorsNamesTable();
+ Arrays.sort(arraySortedRecords); //re-sort again including newlly generated names offset
+ // Util.printRecords(); // for debugging !!!!!!!!!!!!!
+ genenerateApplicationsSettingsTable();
+ genenerateCarrierIndexTable();
+ genenerateHeaderTable();
+ Validator.postValidate();
+ writeTablesToFile();
+
+ //clean working directory
+ if (REMOVE_WORKING_DIR) {
+ Util.deleteDir(Const.WORKING_DIR);
+ }
+
+ /// ------------- test --------------
+ // Util.printRecords();
+ }
+
+ public void validateArrLines() throws Exception {
+
+ String err = "";
+ err += Worker.validateAndCreateMMSs(arrMMSLines);
+ err += Worker.validateAndCreateBrowsers(arrBrowserLines);
+ err += Worker.validateAndCreateJavaApps(arrJavaAppLines);
+ err += Worker.validateAndCreateIMs(arrIMLines);
+
+ if (err.length() > 0) {
+ throw new Exception(err);
+ }
+ }
+
+ public void createXmlMessages() throws Exception {
+ Browser.createXmlMessages();
+ MMS.createXmlMessages();
+ JavaApp.createXmlMessages();
+
+ // IM should be last to generate id_name for all other applications!!!
+ // set flag to avoid duplicationNAP names before calling createXmlMessages()
+ // The method setNAPFlagForIMAndValidate() should be changed for new applications
+ Validator.setNAPFlagForIMAndValidate();
+ IM.createXmlMessages();
+ }
+
+ public void fillArrLines() throws Exception {
+ if (pathMMSFile != null) {
+ arrMMSLines = Util.readFile(pathMMSFile);
+ }
+ if (pathBrowserFile != null) {
+ arrBrowserLines = Util.readFile(pathBrowserFile);
+ }
+ if (pathJavaAppFile != null) {
+ arrJavaAppLines = Util.readFile(pathJavaAppFile);
+ }
+ if (pathIMFile != null) {
+ arrIMLines = Util.readFile(pathIMFile);
+ }
+ }
+
+ // set offset for Applications Settings for each record and generate Applications Setting Table
+ public void genenerateApplicationsSettingsTable() throws Exception {
+ int totalDataLength = 0;
+ String err = ""; // collected all errors for setBlockApplicationsForOneRecord();
+
+ // set offset and binary data for Applications Settings for each record
+ for (int i = 0; i < arraySortedRecords.length; i++) {
+ try {
+ arraySortedRecords[i].application_settings_offset = totalDataLength;
+ int currDataLength = setBlockApplicationsForOneRecord(
+ arraySortedRecords[
+ i]);
+ totalDataLength += currDataLength;
+ }
+ catch (Exception ex) {
+ err += ex.getMessage() + "\n";
+ }
+ }
+ if (err.length() > 0) {
+ throw new Exception(err);
+ }
+
+ // create appl settings table
+ byte[] b;
+ applicationsSettingsTable = new BlockTable(totalDataLength);
+ for (int i = 0; i < arraySortedRecords.length; i++) {
+ b = arraySortedRecords[i].application_settings;
+ applicationsSettingsTable.appendData(b);
+ arraySortedRecords[i].application_settings = null; // release memory !!!!
+
+ ////////////////-- test --///////////////////
+ /* int iii = ( ( ( (int) b[0]) & 0xff) << 16) +
+ ( ( ( (int) b[1]) & 0xff) << 8) + ( ( (int) b[2]) & 0xff);
+ System.out.println(arraySortedRecords[i].key.replaceAll(":", "_") +
+ " : " + b.length + " iii= " + (iii >>> 1) +
+ " flag: " + (iii & 1));*/
+ /////////////////////-- end test-- ///////////////////
+
+ }
+
+ Validator.validateMaxAppsSettingsLength(applicationsSettingsTable.length);
+ int lastOffset = arraySortedRecords[arraySortedRecords.length -
+ 1].application_settings_offset;
+ Validator.validateMaxAppsSettingsOffset(lastOffset);
+ }
+
+ // Choose between wbxml or zip (the smallest one) to be used;
+ // adds 3 additional bytes with metadata and set binary data for the record
+ // returns length for the application settings + 3 bytes
+ public int setBlockApplicationsForOneRecord(Record record) throws Exception {
+ String key = record.key;
+ //String generalPath = Const.WORKING_DIR + Const.PATH_SEP +
+ // key.replaceAll(":", "_");
+ String generalPath = Const.WORKING_DIR + Const.PATH_SEP +
+ Util.generateFileNameFromKey(key);
+
+ File w = new File(generalPath + ".wbxml");
+ if (!w.exists()) {
+ throw new Exception("Error: The file " + generalPath +
+ ".wbxml doesn't exist!");
+ }
+
+ FileInputStream in;
+ boolean usedZip;
+ // Choose between wbxml or zip (the smallest one) to be used in case if USE_ZIP
+ // has not been set to false in function main().
+ if (USE_ZIP) { //zip wbxml files
+ File z = new File(generalPath + ".zip");
+ if (!z.exists()) {
+ throw new Exception("Error: The file " + generalPath +
+ ".zip doesn't exist!");
+ }
+ FileInputStream inw = new FileInputStream(w);
+ FileInputStream inz = new FileInputStream(z);
+ usedZip = inz.available() < inw.available();
+ in = (usedZip) ? inz : inw;
+ }
+ else { // do not zip wbxml files
+ usedZip = false;
+ in = new FileInputStream(w);
+ }
+
+ byte[] appWbxmlSettings = new byte[in.available()];
+ in.read(appWbxmlSettings);
+ in.close();
+
+ //get 3 bytes that provide info: for data length (23 bits) and compressed flag (1 bit)
+ //and write it into metaInfo
+ BlockTable metaInfo = new BlockTable( (Const.APP_BLOCK_LENGTH +
+ Const.APP_COMPRESSWD_FLAG) / 8); // 3 bytes
+ int appBlockSettingsLength = metaInfo.data.length + appWbxmlSettings.length;
+ int compressFlag = (usedZip) ? 1 : 0;
+ Util.addBitsToTable(metaInfo, appBlockSettingsLength,
+ Const.APP_BLOCK_LENGTH);
+ Util.addBitsToTable(metaInfo, compressFlag,
+ Const.APP_COMPRESSWD_FLAG);
+ record.setBlockApplicationSettings(metaInfo.data, appWbxmlSettings);
+
+ Validator.validateAppBlockSettingsLength(appBlockSettingsLength,
+ generalPath);
+
+ return appBlockSettingsLength;
+ }
+
+ // generate operators names table with name length. assign offset for each record
+ public static void genenerateOperatorsNamesTable() throws Exception {
+ //operatorsNamesBytes
+ HashMap hashNames = new HashMap();
+ String name;
+
+ for (int i = 0; i < arraySortedRecords.length; i++) {
+ name = arraySortedRecords[i].operator_name;
+
+ if (hashNames.containsKey(name)) {
+ Integer offset = (Integer) hashNames.get(name);
+ arraySortedRecords[i].operator_name_offset = offset.intValue();
+ }
+ else {
+
+ byte[] nameByteArr = name.getBytes();
+ // since operatorsNamesBytes.length are always even...
+ int half_offset = operatorsNamesBytes.length() / 2;
+ Validator.validateOperatorNameOffset(half_offset); //validate half_offset
+ arraySortedRecords[i].operator_name_offset = half_offset;
+
+ int nameLength = nameByteArr.length + 1; //length of name + one byte to present this length.
+ operatorsNamesBytes.addByte( (byte) nameLength);
+ operatorsNamesBytes.addBytes(nameByteArr);
+ if ( (operatorsNamesBytes.length() % 2) > 0) {
+ //add one dummy byte to make it even
+ operatorsNamesBytes.addByte( (byte) 0);
+ }
+ hashNames.put(name, new Integer(half_offset));
+ }
+ }
+
+ //create operators Names Table
+ operatorsNamesTable = new BlockTable(operatorsNamesBytes.length());
+ operatorsNamesTable.appendData(operatorsNamesBytes.getBytes());
+
+ Validator.validateOperatorNamesTableSize(operatorsNamesTable.length);
+
+ }
+
+ /*
+//generate operators names table with name length. assign offset for each record
+ public static void genenerateOperatorsNamesTable() throws Exception {
+ HashMap hashNames = new HashMap();
+ String name;
+ boolean needAddDummyChar;
+ for (int i = 0; i < arraySortedRecords.length; i++) {
+ needAddDummyChar = false;
+ name = arraySortedRecords[i].operator_name;
+
+ if (hashNames.containsKey(name)) {
+ Integer offset = (Integer) hashNames.get(name);
+ arraySortedRecords[i].operator_name_offset = offset.intValue();
+ }
+ else {
+ //length of name should be odd since we need to addd one byte which will
+ //present this length. so length of name + one byte will be even.
+ //then offset will be stored as half offset/2
+
+ int half_offset = operatorsNamesBuffer.toString().getBytes(ENCODING).length / 2;
+ arraySortedRecords[i].operator_name_offset = half_offset;
+ int nameLength = name.getBytes(ENCODING).length;
+ if((nameLength % 2) == 0){
+ //add one dummy char to make it odd
+ needAddDummyChar = true;
+ nameLength++;
+ }
+ // char c = (char) (name.getBytes().length + 1); //length of name + one byte to present this length.
+ char c = (char) (nameLength + 1); //length of name + one byte to present this length.
+ operatorsNamesBuffer.append(c);
+ operatorsNamesBuffer.append(name);
+ if(needAddDummyChar){
+ operatorsNamesBuffer.append(0);
+ }
+ hashNames.put(name, new Integer(half_offset));
+ }
+ //validate real offset (half_offset * 2)
+ Validator.validateOperatorNameOffset(arraySortedRecords[i].operator_name_offset * 2);
+ }
+
+ //create operators Names Table
+ operatorsNamesTable = new BlockTable(operatorsNamesBuffer.toString().
+ getBytes(ENCODING).length);
+ operatorsNamesTable.appendData(operatorsNamesBuffer.toString().getBytes(ENCODING));
+
+ Validator.validateOperatorNamesTableSize(operatorsNamesTable.length);
+
+ }
+ */
+
+// generate carrier index table
+ public static void genenerateCarrierIndexTable() throws Exception {
+ //get size for all records and init carrierIndexTable
+ int recordLengthBits = Const.MCC_BITS + Const.MNC_BITS +
+ Const.OPERATOR_NAME_OFFSET_BITS + Const.ACC_TYPE_BITS +
+ Const.APP_AVAIL_BITMAP_BITS + Const.APP_SETTINGS_OFFSET_BITS;
+ int oneRecordLengthBytes = (recordLengthBits + 7) / 8;
+ int tableLengthBytes = oneRecordLengthBytes * arraySortedRecords.length;
+ carrierIndexTable = new BlockTable(tableLengthBytes);
+
+ //write data from each record into arrier index table
+ Record record;
+ for (int i = 0; i < arraySortedRecords.length; i++) {
+ record = arraySortedRecords[i];
+ int appAvailBitmap = 0;
+ //set mask for available applications
+ if (record.containsBrowser) {
+ appAvailBitmap |= Const.BROWSER_MASK;
+ }
+ if (record.containsIM) {
+ appAvailBitmap |= Const.IM_MASK;
+ }
+ if (record.containsJavaApp) {
+ appAvailBitmap |= Const.JAVA_MASK;
+ }
+ if (record.containsMMS) {
+ appAvailBitmap |= Const.MMS_MASK;
+ }
+ //find value for mnc length: if mns 3 digits it is 1, otherwise - it is 0
+ int mncLengthBitValue = (record.mncLen == 3) ? 1 : 0;
+
+ Util.addBitsToTable(carrierIndexTable, record.mcc,
+ Const.MCC_BITS);
+ Util.addBitsToTable(carrierIndexTable, mncLengthBitValue,
+ Const.MNC_LENGTH_BITS);
+ Util.addBitsToTable(carrierIndexTable, record.mnc,
+ Const.MNC_BITS);
+ Util.addBitsToTable(carrierIndexTable,
+ record.operator_name_offset,
+ Const.OPERATOR_NAME_OFFSET_BITS);
+ Util.addBitsToTable(carrierIndexTable, record.account_type,
+ Const.ACC_TYPE_BITS);
+ Util.addBitsToTable(carrierIndexTable, appAvailBitmap,
+ Const.APP_AVAIL_BITMAP_BITS);
+ Util.addBitsToTable(carrierIndexTable,
+ record.application_settings_offset,
+ Const.APP_SETTINGS_OFFSET_BITS);
+ }
+ }
+
+//### ========== generate Header table ============ ###########
+ public static void genenerateHeaderTable() throws Exception {
+ int tableLengthBytes = (
+ Const.HEAD_HEAD_SISE + Const.HEAD_OPERATOR_NAMES_TAB_SISE +
+ Const.HEAD_CARRIER_INDEX_TAB_SISE + Const.HEAD_APP_SETTINGS_TAB_SIZE +
+ Const.HEAD_DB_VERSION + 7) / 8;
+ headerTable = new BlockTable(tableLengthBytes);
+ //write header table
+ Util.addBitsToTable(headerTable, tableLengthBytes,
+ Const.HEAD_HEAD_SISE);
+ Util.addBitsToTable(headerTable, operatorsNamesTable.length,
+ Const.HEAD_OPERATOR_NAMES_TAB_SISE);
+ Util.addBitsToTable(headerTable, carrierIndexTable.length,
+ Const.HEAD_CARRIER_INDEX_TAB_SISE);
+ Util.addBitsToTable(headerTable,
+ applicationsSettingsTable.length,
+ Const.HEAD_APP_SETTINGS_TAB_SIZE);
+ Util.addBitsToTable(headerTable, Const.HEAD_DB_VERSION,
+ Const.HEAD_DB_VERSION_TAB_SIZE);
+ }
+
+//### ========== write main DB File and all tables ============ ###########
+ public static void writeTablesToFile() throws Exception {
+ // write sepparate files for the future testing
+ Util.writeFile(Const.WORKING_DIR + Const.PATH_SEP + "header.dat",
+ headerTable.data);
+ Util.writeFile(Const.WORKING_DIR + Const.PATH_SEP + "operators_names.dat",
+ operatorsNamesTable.data);
+ Util.writeFile(Const.WORKING_DIR + Const.PATH_SEP + "app_settings.dat",
+ applicationsSettingsTable.data);
+ Util.writeFile(Const.WORKING_DIR + Const.PATH_SEP + "carrier_index.dat",
+ carrierIndexTable.data);
+ // write main DB file
+ Util.writeDBFile();
+ }
+
+ public static void main(String[] args) {
+ Const.HEAD_DB_VERSION = 1;
+
+ for (int i = 0; i < args.length; i++) {
+ if ("-mms".equals(args[i]) && args.length > i + 1) {
+ pathMMSFile = args[++i];
+ if (! (pathMMSFile.endsWith(".txt") || pathMMSFile.endsWith(".csv"))) {
+ System.out.println(
+ "Wrong input file type with MMS setting. Supported types: .txt or .csv");
+ System.exit(1);
+ }
+ }
+ else if ("-browser".equals(args[i]) && args.length > i + 1) {
+ pathBrowserFile = args[++i];
+ if (! (pathBrowserFile.endsWith(".txt") ||
+ pathBrowserFile.endsWith(".csv"))) {
+ System.out.println(
+ "Wrong input file type with Browser setting. Supported types: .txt or .csv");
+ System.exit(1);
+ }
+ }
+ else if ("-java".equals(args[i]) && args.length > i + 1) {
+ pathJavaAppFile = args[++i];
+ if (! (pathJavaAppFile.endsWith(".txt") ||
+ pathJavaAppFile.endsWith(".csv"))) {
+ System.out.println(
+ "Wrong input file type with Java setting. Supported types: .txt or .csv");
+ System.exit(1);
+ }
+ }
+ else if ("-im".equals(args[i]) && args.length > i + 1) {
+ pathIMFile = args[++i];
+ if (! (pathIMFile.endsWith(".txt") || pathIMFile.endsWith(".csv"))) {
+ System.out.println(
+ "Wrong input file type with IM setting. Supported types: .txt or .csv");
+ System.exit(1);
+ }
+ }
+ else if ("-nozip".equals(args[i])) {
+ USE_ZIP = false;
+ }
+ else if ("-debug".equals(args[i])) {
+ REMOVE_WORKING_DIR = false;
+ }
+ else if ("-dump".equals(args[i]) && args.length == 2) {
+ DBDumper dbdumper = new DBDumper();
+ System.out.println("============== Dumping DB File ============== ");
+ dbdumper.dump(args[i + 1]);
+ System.out.println(
+ "============== End dumping DB File ============== \n");
+ System.exit(0);
+ }
+ else {
+ System.out.println(" Wrong parameters...");
+ usage();
+ System.exit(1);
+ }
+ }
+
+ // validate input files and set file type (IS_INPUT_TXT_FILE)
+ String err = Util.validateAndSetInputParms();
+ if (err != null) {
+ System.out.println(err);
+ usage();
+ System.exit(1);
+ }
+
+ Generator g = new Generator();
+ try {
+ g.proceed();
+ System.out.println(
+ "\n========================================================\n" +
+ "DB generation finished successfully.\n" +
+ "File '" + Const.DB_FILE_NAME + "' has been created.\n" +
+ "========================================================\n");
+ }
+ catch (Exception e) {
+ Util.deleteFile(Const.DB_FILE_NAME);
+
+ System.out.println(
+ "\n===================== Error ===============================");
+ System.out.println(" DB generation failed.\n" +
+ " Please check file '" + Const.ERROR_FILE_NAME +
+ "' for more details\n");
+ //System.out.println(e.getMessage());
+ System.out.println(
+ "===========================================================\n");
+ //e.printStackTrace();
+ try {
+ Util.writeFile(Const.ERROR_FILE_NAME, e.getMessage());
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ public static void usage() {
+ System.out.println("\n usage:\n" +
+ "java com.mot.dm.dbtool.Generator [-mms <path>] [-browser <path>] [-java <path>] [-im <path>] \n" +
+ "or for test\n" +
+ "java com.mot.dm.dbtool.Generator -dump <path>/" +
+ Const.DB_FILE_NAME
+ );
+ }
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Helper.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Helper.java
new file mode 100644
index 0000000..4ecd140
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Helper.java
@@ -0,0 +1,52 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+
+public class Helper {
+ // not used all class!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ public static String getPXAddrType(String addr) throws Exception {
+ if (isAddrTypeIPV4(addr)) {
+ return "IPV4";
+ }
+ else if (isAddrTypeIPV6(addr)) {
+ return "IPV6";
+ }
+ else if (isAddrTypeE164(addr)) {
+ return "E164";
+ }
+ return null;
+
+ }
+
+ private static boolean isAddrTypeIPV4(String addr) {
+ //123.211.1.3
+ String tmp;
+ StringTokenizer st = new StringTokenizer(addr, ".");
+ if (st.countTokens() != 4) {
+ return false;
+ }
+ try {
+ while (st.hasMoreTokens()) {
+ tmp = st.nextToken();
+ Integer.parseInt(tmp);
+ }
+ return true;
+ }
+ catch (Exception ex) {
+ return false;
+ }
+ }
+
+ private static boolean isAddrTypeIPV6(String addr) {
+ //??????
+
+ return false;
+
+ }
+
+ private static boolean isAddrTypeE164(String addr) {
+ // 9870981 or +30945984732
+ return false;
+ }
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/IM.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/IM.java
new file mode 100644
index 0000000..3640aaa
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/IM.java
@@ -0,0 +1,234 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+
+public class IM {
+ public static int colsNum = 0; //number of columns in the comma sep file.
+ public static ArrayList arrIMFromLines = new ArrayList();
+ public static ArrayList arrIMLineHeaders = new ArrayList();
+
+ public Value mcc = new Value();
+ public Value mnc = new Value();
+ public Value operator_name = new Value();
+ public Value account_type = new Value();
+ public Value country_name = new Value();
+ public Value Brand_instance_name = new Value();
+ public Value IspProfileName = new Value();
+ public Value gprs_access_point_name = new Value();
+ public Value ap_requires_auth = new Value();
+ public Value ppp_auth_type = new Value();
+ public Value ppp_auth_name = new Value();
+ public Value ppp_auth_secret = new Value();
+ public Value nap_addr_type = new Value();
+ public Value bearer = new Value();
+
+ public Value ServerAddr = new Value();
+ public Value ServerPort = new Value();
+ public Value ClientID = new Value();
+ public Value PrivateKey1 = new Value();
+ public Value PrivateKey2 = new Value();
+ public Value ServerPostURL = new Value();
+ public Value LoginAutoResetConversation = new Value();
+ public Value ServerCirSupported = new Value();
+ public Value ServerLoginMethod = new Value();
+ public Value ServerProxyAddress = new Value();
+ public Value ServerProxyPassword = new Value();
+ public Value ServerProxyUserName = new Value();
+ public Value ServerTransportType = new Value();
+ public Value ServerSMSDestinationAddress = new Value();
+ public Value ServSMSCirSup = new Value();
+ public Value SvTCPCIRKeepTim = new Value();
+ public Value SvTCPCIRSup = new Value();
+ public Value ServerCloseSocketAfterResponse = new Value();
+ public Value AutoRefreshContactList = new Value();
+ public Value FrbdUnauthoMsgs = new Value();
+ public boolean generateNAPXmlReq = true;
+
+ // Data validation
+ public String validateData() {
+ StringBuffer err = new StringBuffer();
+ err.append(Validator.validateMCC(mcc));
+ err.append(Validator.validateMNC(mnc));
+ err.append(Validator.validateStringValue(operator_name, true, -1,
+ Const.OPERATOR_NAME_MAX_LENGTH,
+ "operator_name"));
+ err.append(Validator.validateAccountType(account_type));
+ err.append(Validator.validateStringValue(Brand_instance_name, true, -1,
+ Const.
+ BRAND_INSTANCE_NAME_MAX_LENGTH,
+ "Brand_instance_name"));
+ err.append(Validator.validateStringValue(IspProfileName, true, -1,
+ Const.ISP_PROFILE_NAME_MAX_LENGTH,
+ "IspProfileName"));
+ err.append(Validator.validateGprsAccessPoint(gprs_access_point_name,
+ nap_addr_type.val));
+ err.append(Validator.validateApRequiresAuth(ap_requires_auth));
+ err.append(Validator.validatePppAuthType(ppp_auth_type,
+ ap_requires_auth.val));
+ err.append(Validator.validatePppAuthName(ppp_auth_name,
+ ap_requires_auth.val));
+ err.append(Validator.validatePppAuthSecret(ppp_auth_secret,
+ ap_requires_auth.val));
+ err.append(Validator.validateNAPAddrType(nap_addr_type));
+ err.append(Validator.validateBearer(bearer));
+
+ // IM specific
+ err.append(Validator.validateStringValue(ServerAddr, false, 0,
+ Const.SERVER_ADDR_MAX_LENGTH,
+ "ServerAddr")); ////ServerAddr
+ err.append(Validator.validateIMServerPort(ServerPort)); ////ServerPort
+ err.append(Validator.validateStringValue(ClientID, false, 0,
+ Const.CLIENT_ID_MAX_LENGTH,
+ "ClientID")); ////ClientID
+ err.append(Validator.validateStringValue(PrivateKey1, false, 0,
+ Const.PRIVATE_KEY_MAX_LENGTH,
+ "PrivateKey1")); ////PrivateKey1
+ err.append(Validator.validateStringValue(PrivateKey2, false, 0,
+ Const.PRIVATE_KEY_MAX_LENGTH,
+ "PrivateKey2")); ////PrivateKey2
+ err.append(Validator.validateStringValue(ServerPostURL, false, 0,
+ Const.SRV_POST_URL_MAX_LENGTH,
+ "ServerPostURL")); ////ServerPostURL
+ err.append(Validator.validateBoolValue(LoginAutoResetConversation, true,
+ "LoginAutoResetConversation")); ////LoginAutoResetConversation
+ err.append(Validator.validateBoolValue(ServerCirSupported, true,
+ "ServerCirSupported")); ////ServerCirSupported
+ err.append(Validator.validateValueFromDefinedList(ServerLoginMethod,
+ Const.SERVER_LOGIN_METHODS, true, "ServerLoginMethod")); ////ServerLoginMethod
+ err.append(Validator.validateStringValue(ServerProxyAddress, false, 0,
+ Const.SRV_PROXY_ADDR_MAX_LENGTH,
+ "ServerProxyAddress")); ////ServerProxyAddress
+ err.append(Validator.validateStringValue(ServerProxyPassword, false, 0,
+ Const.SRV_PROXY_PWD_MAX_LENGTH,
+ "ServerProxyPassword")); ////ServerProxyPassword
+ err.append(Validator.validateStringValue(ServerProxyUserName, false, 0,
+ Const.
+ SRV_PROXY_USR_NAME_MAX_LENGTH,
+ "ServerProxyUserName")); ////ServerProxyUserName
+ err.append(Validator.validateValueFromDefinedList(ServerTransportType,
+ Const.SERVER_TRANSPORT_TYPES, true, "ServerTransportType")); ////ServerTransportType
+ err.append(Validator.validateStringValue(ServerSMSDestinationAddress, false,
+ 0,
+ Const.SRV_SMS_DEST_ADDR_MAX_LENGTH,
+ "ServerSMSDestinationAddress")); ////ServerSMSDestinationAddress
+ err.append(Validator.validateBoolValue(ServSMSCirSup, true, "ServSMSCirSup")); ////ServSMSCirSup
+ err.append(Validator.validateIntegerValue(SvTCPCIRKeepTim, 0, 2147483647, true,
+ "SvTCPCIRKeepTim")); ////SvTCPCIRKeepTim
+ err.append(Validator.validateBoolValue(SvTCPCIRSup, true, "SvTCPCIRSup")); ////SvTCPCIRSup
+ err.append(Validator.validateBoolValue(ServerCloseSocketAfterResponse, true,
+ "ServerCloseSocketAfterResponse")); ////ServerCloseSocketAfterResponse
+ err.append(Validator.validateBoolValue(AutoRefreshContactList, true,
+ "AutoRefreshContactList")); ////AutoRefreshContactList
+ err.append(Validator.validateBoolValue(FrbdUnauthoMsgs, true,
+ "FrbdUnauthoMsgs")); ////FrbdUnauthoMsgs
+ return err.toString();
+ }
+
+ public static void createXmlMessages() throws Exception {
+ for (int i = 0; i < arrIMFromLines.size(); i++) {
+ createXml((IM) arrIMFromLines.get(i));
+ }
+ }
+
+ public static void createXml(IM im) throws Exception {
+ String xml = "";
+ //String key = im.mcc.val + ":" + im.mnc.val + ":" + im.operator_name.val +
+ // ":" + im.account_type.val.toUpperCase();
+ String key = Record.createKey(im.mcc.val, im.mnc.val,
+ im.operator_name.val,
+ im.account_type.val.toUpperCase());
+
+ // NAPDEF
+ if (im.generateNAPXmlReq) {
+ xml += " <characteristic type=\"NAPDEF\">\n";
+ xml += " <parm name=\"NAPID\" value=\"" + im.IspProfileName.val +
+ "\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + im.IspProfileName.val +
+ "\"/>\n";
+ xml += " <parm name=\"BEARER\" value=\"" + im.bearer.val + "\"/>\n";
+ xml += " <parm name=\"NAP-ADDRESS\" value=\"" +
+ im.gprs_access_point_name.val + "\"/>\n";
+ xml += " <parm name=\"NAP-ADDRTYPE\" value=\"" + im.nap_addr_type.val +
+ "\"/>\n";
+ // NAPAUTHINFO
+ if (Util.strToBool(im.ap_requires_auth.val)) {
+ xml += " <characteristic type=\"NAPAUTHINFO\">\n";
+ xml += " <parm name=\"AUTHTYPE\" value=\"" + im.ppp_auth_type.val +
+ "\"/>\n";
+ xml += " <parm name=\"AUTHNAME\" value=\"" + im.ppp_auth_name.val +
+ "\"/>\n";
+ xml += " <parm name=\"AUTHSECRET\" value=\"" +
+ im.ppp_auth_secret.val + "\"/>\n";
+ xml += " </characteristic>\n"; ///// NAPAUTHINFO
+ }
+ xml += " </characteristic>\n\n"; ///// NAPDEF
+ }
+
+ // APPLICATION
+ xml += " <characteristic type=\"APPLICATION\">\n";
+ xml += " <parm name=\"APPID\" value=\"wA\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + im.Brand_instance_name.val +
+ "\"/>\n";
+ xml += " <parm name=\"TO-NAPID\" value=\"" + im.IspProfileName.val +
+ "\"/>\n";
+
+ xml += " <characteristic type=\"APPADDR\">\n"; //APPADDR
+ xml += " <parm name=\"ADDR\" value=\"" + im.ServerAddr.val + "\"/>\n";
+ xml += " <characteristic type=\"PORT\">\n"; //PORT
+ xml += " <parm name=\"PORTNBR\" value=\"" + im.ServerPort.val +
+ "\"/>\n";
+ xml += " </characteristic>\n"; ///// PORT
+ xml += " </characteristic>\n"; ///// APPADDR
+
+ xml += " <characteristic type=\"APPAUTH\">\n"; //APPAUTH
+ xml += " <parm name=\"AAUTHLEVEL\" value=\"APPSRV\"/>\n";
+ xml += " <parm name=\"AAUTHNAME\" value=\"" + im.ClientID.val + "\"/>\n";
+ xml += " <parm name=\"AAUTHSECRET\" value=\"" + im.PrivateKey1.val +
+ "\"/>\n";
+ xml += " </characteristic>\n"; ///// APPAUTH
+
+ xml += " <characteristic type=\"APPAUTH\">\n"; //APPAUTH
+ xml += " <parm name=\"AAUTHLEVEL\" value=\"CLIENT\"/>\n";
+ xml += " <parm name=\"AAUTHNAME\" value=\"no in use\"/>\n";
+ xml += " <parm name=\"AAUTHSECRET\" value=\"" + im.PrivateKey2.val +
+ "\"/>\n";
+ xml += " </characteristic>\n"; ///// APPAUTH
+
+ xml += " <characteristic type=\"PROPRIETARY\">\n"; //PROPRIETARY
+ xml += " <parm name=\"ServerPostURL\" value=\"" + im.ServerPostURL.val +
+ "\"/>\n";
+ xml += " <parm name=\"LoginAutoResetConversation\" value=\"" +
+ im.LoginAutoResetConversation.val + "\"/>\n";
+ xml += " <parm name=\"ServerCirSupported\" value=\"" +
+ im.ServerCirSupported.val + "\"/>\n";
+ xml += " <parm name=\"ServerLoginMethod\" value=\"" +
+ im.ServerLoginMethod.val + "\"/>\n";
+ xml += " <parm name=\"ServerProxyAddress\" value=\"" +
+ im.ServerProxyAddress.val + "\"/>\n";
+ xml += " <parm name=\"ServerProxyPassword\" value=\"" +
+ im.ServerProxyPassword.val + "\"/>\n";
+ xml += " <parm name=\"ServerProxyUserName\" value=\"" +
+ im.ServerProxyUserName.val + "\"/>\n";
+ xml += " <parm name=\"ServerTransportType\" value=\"" +
+ im.ServerTransportType.val + "\"/>\n";
+ xml += " <parm name=\"ServerSMSDestinationAddress\" value=\"" +
+ im.ServerSMSDestinationAddress.val + "\"/>\n";
+ xml += " <parm name=\"ServSMSCirSup\" value=\"" + im.ServSMSCirSup.val +
+ "\"/>\n";
+ xml += " <parm name=\"SvTCPCIRKeepTim\" value=\"" +
+ im.SvTCPCIRKeepTim.val + "\"/>\n";
+ xml += " <parm name=\"SvTCPCIRSup\" value=\"" + im.SvTCPCIRSup.val +
+ "\"/>\n";
+ xml += " <parm name=\"ServerCloseSocketAfterResponse\" value=\"" +
+ im.ServerCloseSocketAfterResponse.val + "\"/>\n";
+ xml += " <parm name=\"AutoRefreshContactList\" value=\"" +
+ im.AutoRefreshContactList.val + "\"/>\n";
+ xml += " <parm name=\"FrbdUnauthoMsgs\" value=\"" +
+ im.FrbdUnauthoMsgs.val + "\"/>\n";
+ xml += " </characteristic>\n"; ///// PROPRIETARY
+ xml += " </characteristic>\n\n"; ///// APPLICATION
+
+ Util.addXmlToRecord(xml, key, im.Brand_instance_name.val, "IM");
+ }
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/JavaApp.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/JavaApp.java
new file mode 100644
index 0000000..ae0879e
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/JavaApp.java
@@ -0,0 +1,178 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+
+public class JavaApp {
+ public static int colsNum = 0; //number of columns in the comma sep file.
+ public static ArrayList arrJavaAppFromLines = new ArrayList();
+ public static ArrayList arrJavaAppLineHeaders = new ArrayList();
+
+ public Value mcc = new Value();
+ public Value mnc = new Value();
+ public Value operator_name = new Value();
+ public Value account_type = new Value();
+ public Value country_name = new Value();
+ public Value ppp_auth_type = new Value();
+ public Value ppp_auth_name = new Value();
+ public Value ppp_auth_secret = new Value();
+ public Value ap_requires_auth = new Value();
+ public Value service_name = new Value();
+ public Value gprs_access_point_name = new Value();
+ public Value dns_1 = new Value();
+ public Value dns_2 = new Value();
+ public Value nap_addr_type = new Value();
+ public Value bearer = new Value();
+ public Value proxy = new Value();
+ public Value proxy_addr_type = new Value();
+ public Value port = new Value();
+ public Value proxy_type = new Value();
+ public Value proxy_requires_auth = new Value();
+ public Value proxy_auth_name = new Value();
+ public Value proxy_auth_secret = new Value();
+ public Value proxy_auth_type = new Value();
+ public String id_name = "";
+
+ // Data validation
+ public String validateData() {
+ boolean isProxyEmpty = Validator.isValEmpty(proxy);
+ StringBuffer err = new StringBuffer();
+ err.append(Validator.validateMCC(mcc));
+ err.append(Validator.validateMNC(mnc));
+ err.append(Validator.validateAccountType(account_type));
+ err.append(Validator.validateStringValue(operator_name, true, -1,
+ Const.OPERATOR_NAME_MAX_LENGTH,
+ "operator_name"));
+ err.append(Validator.validateApRequiresAuth(ap_requires_auth));
+ err.append(Validator.validatePppAuthType(ppp_auth_type,
+ ap_requires_auth.val));
+ err.append(Validator.validatePppAuthName(ppp_auth_name,
+ ap_requires_auth.val));
+ err.append(Validator.validatePppAuthSecret(ppp_auth_secret,
+ ap_requires_auth.val));
+ err.append(Validator.validateStringValue(service_name, true, -1,
+ Const.SERVICE_NAME_MAX_LENGTH,
+ "service_name"));
+ err.append(Validator.validateNAPAddrType(nap_addr_type));
+ err.append(Validator.validateGprsAccessPoint(gprs_access_point_name,
+ nap_addr_type.val));
+ err.append(Validator.validateDNS(dns_1));
+ err.append(Validator.validateDNS(dns_2));
+ err.append(Validator.validateBearer(bearer));
+ err.append(Validator.validateProxy(proxy, proxy_addr_type.val));
+ err.append(Validator.validateProxyAddrType(proxy_addr_type, isProxyEmpty));
+ err.append(Validator.validatePort(port, isProxyEmpty));
+ err.append(Validator.validateProxyType(proxy_type, isProxyEmpty));
+ err.append(Validator.validateProxyRequiresAuth(proxy_requires_auth,
+ isProxyEmpty));
+ err.append(Validator.validateProxyAuthName(proxy_auth_name, isProxyEmpty,
+ proxy_requires_auth.val));
+ err.append(Validator.validateProxyAuthSecret(proxy_auth_secret,
+ isProxyEmpty,
+ proxy_requires_auth.val));
+ err.append(Validator.validateProxyAuthType(proxy_auth_type, isProxyEmpty,
+ proxy_requires_auth.val));
+ return err.toString();
+ }
+
+ public static void createXmlMessages() throws Exception {
+ for (int i = 0; i < arrJavaAppFromLines.size(); i++) {
+ createXml( (JavaApp) arrJavaAppFromLines.get(i));
+ }
+ }
+
+ public static void createXml(JavaApp java) throws Exception {
+ String xml;
+ //String key = mms.mcc.val + ":" + mms.mnc.val + ":" + mms.operator_name.val +
+ // ":" + mms.account_type.val.toUpperCase();
+ String key = Record.createKey(java.mcc.val, java.mnc.val,
+ java.operator_name.val,
+ java.account_type.val.toUpperCase());
+
+ java.id_name = Util.getIdNameFromRecords(java.service_name.val, key);
+
+ // APPLICATION
+ xml = " <characteristic type=\"APPLICATION\">\n";
+ xml += " <parm name=\"APPID\" value=\"DmWizardJavaAppID\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + java.id_name + "\"/>\n";
+ if (java.proxy.val.length() > 0) {
+ xml += " <parm name=\"TO-PROXY\" value=\"PX_" + java.id_name + "\"/>\n";
+ }
+ else {
+ xml += " <parm name=\"TO-NAPID\" value=\"NAP_" + java.id_name +
+ "\"/>\n";
+ }
+ xml += " </characteristic>\n\n"; ///// APPLICATION
+
+ if (java.proxy.val.length() > 0) {
+ // PXLOGICAL
+ xml += " <characteristic type=\"PXLOGICAL\">\n";
+ xml += " <parm name=\"PROXY-ID\" value=\"PX_" + java.id_name + "\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + java.id_name + "\"/>\n";
+ // PXPHYSICAL
+ xml += " <characteristic type=\"PXPHYSICAL\">\n";
+ xml += " <parm name=\"PHYSICAL-PROXY-ID\" value=\"PXPH_" +
+ java.id_name +
+ "\"/>\n";
+ xml += " <parm name=\"PXADDR\" value=\"" + java.proxy.val + "\"/>\n";
+ xml += " <parm name=\"PXADDRTYPE\" value=\"" +
+ java.proxy_addr_type.val + "\"/>\n";
+ xml += " <parm name=\"TO-NAPID\" value=\"NAP_" + java.id_name +
+ "\"/>\n";
+ if (java.port.val.length() > 0) {
+ //PORT
+ xml += " <characteristic type=\"PORT\">\n";
+ xml += " <parm name=\"PORTNBR\" value=\"" + java.port.val +
+ "\"/>\n";
+ if (java.proxy_type.val.length() > 0) {
+ xml += " <parm name=\"SERVICE\" value=\"" + java.proxy_type.val +
+ "\"/>\n";
+ }
+ xml += " </characteristic>\n"; /////PORT
+ }
+ xml += " </characteristic>\n"; ///// PXPHYSICAL
+ if (Util.strToBool(java.proxy_requires_auth.val)) {
+ // PXAUTHINFO
+ xml += " <characteristic type=\"PXAUTHINFO\">\n";
+ xml += " <parm name=\"PXAUTH-TYPE\" value=\"" +
+ java.proxy_auth_type.val + "\"/>\n";
+ xml += " <parm name=\"PXAUTH-ID\" value=\"" +
+ java.proxy_auth_name.val + "\"/>\n";
+ xml += " <parm name=\"PXAUTH-PW\" value=\"" +
+ java.proxy_auth_secret.val + "\"/>\n";
+ xml += " </characteristic>\n"; ///// PXAUTHINFO
+ }
+ xml += " </characteristic>\n\n"; ///// PXLOGICAL
+ }
+
+ // NAPDEF
+ xml += " <characteristic type=\"NAPDEF\">\n";
+ xml += " <parm name=\"NAPID\" value=\"NAP_" + java.id_name + "\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + java.id_name + "\"/>\n";
+ xml += " <parm name=\"BEARER\" value=\"" + java.bearer.val + "\"/>\n";
+ xml += " <parm name=\"NAP-ADDRESS\" value=\"" +
+ java.gprs_access_point_name.val + "\"/>\n";
+ xml += " <parm name=\"NAP-ADDRTYPE\" value=\"" + java.nap_addr_type.val +
+ "\"/>\n";
+ if (java.dns_1.val.length() > 0) {
+ xml += " <parm name=\"DNS-ADDR\" value=\"" + java.dns_1.val + "\"/>\n";
+ }
+ if (java.dns_2.val.length() > 0) {
+ xml += " <parm name=\"DNS-ADDR\" value=\"" + java.dns_2.val + "\"/>\n";
+ }
+ if (Util.strToBool(java.ap_requires_auth.val)) {
+ // NAPAUTHINFO
+ xml += " <characteristic type=\"NAPAUTHINFO\">\n";
+ xml += " <parm name=\"AUTHTYPE\" value=\"" + java.ppp_auth_type.val +
+ "\"/>\n";
+ xml += " <parm name=\"AUTHNAME\" value=\"" + java.ppp_auth_name.val +
+ "\"/>\n";
+ xml += " <parm name=\"AUTHSECRET\" value=\"" +
+ java.ppp_auth_secret.val + "\"/>\n";
+ xml += " </characteristic>\n"; ///// NAPAUTHINFO
+ }
+ xml += " </characteristic>\n\n"; ///// NAPDEF
+
+ Util.addXmlToRecord(xml, key, java.id_name, "JAVA");
+ }
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/MMS.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/MMS.java
new file mode 100644
index 0000000..2a3031d
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/MMS.java
@@ -0,0 +1,176 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+
+public class MMS {
+ public static int colsNum = 0; //number of columns in the comma sep file.
+ public static ArrayList arrMMSFromLines = new ArrayList();
+ public static ArrayList arrMMSLineHeaders = new ArrayList();
+
+ public Value mcc = new Value();
+ public Value mnc = new Value();
+ public Value operator_name = new Value();
+ public Value country_name = new Value();
+ public Value ppp_auth_type = new Value();
+ public Value ppp_auth_name = new Value();
+ public Value ppp_auth_secret = new Value();
+ public Value ap_requires_auth = new Value();
+ public Value service_name = new Value();
+ public Value nap_addr_type = new Value();
+ public Value gprs_access_point_name = new Value();
+ public Value dns_1 = new Value();
+ public Value dns_2 = new Value();
+ public Value proxy = new Value();
+ public Value proxy_addr_type = new Value();
+ public Value port = new Value();
+ public Value proxy_type = new Value();
+ public Value proxy_requires_auth = new Value();
+ public Value proxy_auth_name = new Value();
+ public Value proxy_auth_secret = new Value();
+ public Value proxy_auth_type = new Value();
+ public Value account_type = new Value();
+ public Value bearer = new Value();
+ public Value mms_url = new Value();
+
+ public String id_name = "";
+
+ // Data validation
+ public String validateData() {
+ boolean isProxyEmpty = Validator.isValEmpty(proxy);
+ StringBuffer err = new StringBuffer();
+ err.append(Validator.validateMCC(mcc));
+ err.append(Validator.validateMNC(mnc));
+ err.append(Validator.validateStringValue(operator_name, true, -1,
+ Const.OPERATOR_NAME_MAX_LENGTH,
+ "operator_name"));
+ err.append(Validator.validateApRequiresAuth(ap_requires_auth));
+ err.append(Validator.validatePppAuthType(ppp_auth_type,
+ ap_requires_auth.val));
+ err.append(Validator.validatePppAuthName(ppp_auth_name,
+ ap_requires_auth.val));
+ err.append(Validator.validatePppAuthSecret(ppp_auth_secret,
+ ap_requires_auth.val));
+ err.append(Validator.validateStringValue(service_name, true, -1,
+ Const.SERVICE_NAME_MAX_LENGTH,
+ "service_name"));
+ err.append(Validator.validateNAPAddrType(nap_addr_type));
+ err.append(Validator.validateGprsAccessPoint(gprs_access_point_name,
+ nap_addr_type.val));
+ err.append(Validator.validateDNS(dns_1));
+ err.append(Validator.validateDNS(dns_2));
+ err.append(Validator.validateBearer(bearer));
+ err.append(Validator.validateProxy(proxy, proxy_addr_type.val));
+ err.append(Validator.validateProxyAddrType(proxy_addr_type, isProxyEmpty));
+ err.append(Validator.validatePort(port, isProxyEmpty));
+ err.append(Validator.validateProxyType(proxy_type, isProxyEmpty));
+ err.append(Validator.validateProxyRequiresAuth(proxy_requires_auth,
+ isProxyEmpty));
+ err.append(Validator.validateProxyAuthName(proxy_auth_name, isProxyEmpty,
+ proxy_requires_auth.val));
+ err.append(Validator.validateProxyAuthSecret(proxy_auth_secret,
+ isProxyEmpty,
+ proxy_requires_auth.val));
+ err.append(Validator.validateProxyAuthType(proxy_auth_type, isProxyEmpty,
+ proxy_requires_auth.val));
+ err.append(Validator.validateAccountType(account_type));
+ err.append(Validator.validateMMSUrl(mms_url));
+
+ return err.toString();
+ }
+
+ public static void createXmlMessages() throws Exception {
+ for (int i = 0; i < arrMMSFromLines.size(); i++) {
+ createXml( (MMS) arrMMSFromLines.get(i));
+ }
+ }
+
+ public static void createXml(MMS mms) throws Exception {
+ String xml;
+ //String key = mms.mcc.val + ":" + mms.mnc.val + ":" + mms.operator_name.val +
+ // ":" + mms.account_type.val.toUpperCase();
+ String key = Record.createKey(mms.mcc.val, mms.mnc.val,
+ mms.operator_name.val,
+ mms.account_type.val.toUpperCase());
+
+ mms.id_name = Util.getIdNameFromRecords(mms.service_name.val, key);
+
+ // APPLICATION
+ xml = " <characteristic type=\"APPLICATION\">\n";
+ xml += " <parm name=\"APPID\" value=\"w4\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + mms.id_name + "\"/>\n";
+ if (mms.proxy.val.length() > 0) {
+ xml += " <parm name=\"TO-PROXY\" value=\"PX_" + mms.id_name + "\"/>\n";
+ }
+ else {
+ xml += " <parm name=\"TO-NAPID\" value=\"NAP_" + mms.id_name + "\"/>\n";
+ }
+ xml += " <parm name=\"ADDR\" value=\"" + mms.mms_url.val + "\"/>\n";
+ xml += " </characteristic>\n\n"; ///// APPLICATION
+ if (mms.proxy.val.length() > 0) {
+ // PXLOGICAL
+ xml += " <characteristic type=\"PXLOGICAL\">\n";
+ xml += " <parm name=\"PROXY-ID\" value=\"PX_" + mms.id_name + "\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + mms.id_name + "\"/>\n";
+ // PXPHYSICAL
+ xml += " <characteristic type=\"PXPHYSICAL\">\n";
+ xml += " <parm name=\"PHYSICAL-PROXY-ID\" value=\"PXPH_" + mms.id_name +
+ "\"/>\n";
+ xml += " <parm name=\"PXADDR\" value=\"" + mms.proxy.val + "\"/>\n";
+ xml += " <parm name=\"PXADDRTYPE\" value=\"" +
+ mms.proxy_addr_type.val + "\"/>\n";
+ xml += " <parm name=\"TO-NAPID\" value=\"NAP_" + mms.id_name + "\"/>\n";
+ if (mms.port.val.length() > 0) {
+ //PORT
+ xml += " <characteristic type=\"PORT\">\n";
+ xml += " <parm name=\"PORTNBR\" value=\"" + mms.port.val +
+ "\"/>\n";
+ if (mms.proxy_type.val.length() > 0) {
+ xml += " <parm name=\"SERVICE\" value=\"" + mms.proxy_type.val +
+ "\"/>\n";
+ }
+ xml += " </characteristic>\n"; /////PORT
+ }
+ xml += " </characteristic>\n"; ///// PXPHYSICAL
+ if (Util.strToBool(mms.proxy_requires_auth.val)) {
+ // PXAUTHINFO
+ xml += " <characteristic type=\"PXAUTHINFO\">\n";
+ xml += " <parm name=\"PXAUTH-TYPE\" value=\"" +
+ mms.proxy_auth_type.val + "\"/>\n";
+ xml += " <parm name=\"PXAUTH-ID\" value=\"" +
+ mms.proxy_auth_name.val + "\"/>\n";
+ xml += " <parm name=\"PXAUTH-PW\" value=\"" +
+ mms.proxy_auth_secret.val + "\"/>\n";
+ xml += " </characteristic>\n"; ///// PXAUTHINFO
+ }
+ xml += " </characteristic>\n\n"; ///// PXLOGICAL
+ }
+ // NAPDEF
+ xml += " <characteristic type=\"NAPDEF\">\n";
+ xml += " <parm name=\"NAPID\" value=\"NAP_" + mms.id_name + "\"/>\n";
+ xml += " <parm name=\"NAME\" value=\"" + mms.id_name + "\"/>\n";
+ xml += " <parm name=\"BEARER\" value=\"" + mms.bearer.val + "\"/>\n";
+ xml += " <parm name=\"NAP-ADDRESS\" value=\"" +
+ mms.gprs_access_point_name.val + "\"/>\n";
+ xml += " <parm name=\"NAP-ADDRTYPE\" value=\"" + mms.nap_addr_type.val +
+ "\"/>\n";
+ if (mms.dns_1.val.length() > 0) {
+ xml += " <parm name=\"DNS-ADDR\" value=\"" + mms.dns_1.val + "\"/>\n";
+ }
+ if (mms.dns_2.val.length() > 0) {
+ xml += " <parm name=\"DNS-ADDR\" value=\"" + mms.dns_2.val + "\"/>\n";
+ }
+ if (Util.strToBool(mms.ap_requires_auth.val)) {
+ // NAPAUTHINFO
+ xml += " <characteristic type=\"NAPAUTHINFO\">\n";
+ xml += " <parm name=\"AUTHTYPE\" value=\"" + mms.ppp_auth_type.val +
+ "\"/>\n";
+ xml += " <parm name=\"AUTHNAME\" value=\"" + mms.ppp_auth_name.val +
+ "\"/>\n";
+ xml += " <parm name=\"AUTHSECRET\" value=\"" +
+ mms.ppp_auth_secret.val + "\"/>\n";
+ xml += " </characteristic>\n"; ///// NAPAUTHINFO
+ }
+ xml += " </characteristic>\n\n"; ///// NAPDEF
+ Util.addXmlToRecord(xml, key, mms.id_name, "MMS");
+ }
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/OMACP.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/OMACP.java
new file mode 100644
index 0000000..f79f651
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/OMACP.java
@@ -0,0 +1,434 @@
+package com.mot.dm.dbtool;
+
+/** This class contains the OMACP coding tables for elements
+ * and attributes needed by the OMACPParser.
+ */
+
+public class OMACP {
+
+ public static int TAG = 1;
+ public static int VAL = 2;
+ public static int ATTR = 3;
+
+ public static ValTab encode(String value, int tabName, int shift) throws Exception {
+
+ int index;
+ if (tabName == TAG) {
+ return encodeTag(value, shift);
+ }
+ else if (tabName == VAL) {
+ return encodeVal(value);
+ }
+ else if (tabName == ATTR) {
+ return encodeAttr(value);
+ }
+ else {
+ throw new Exception("Error: Unsupported table name...");
+ }
+ }
+
+ public static ValTab encodeTag(String value, int shift) {
+ ValTab result = new ValTab();
+ int offset;
+ //First table for tags
+ offset = 0x05;
+ for (int i = 0; i < TAG_TABLE_0.length; i++) {
+ if (value.equals(TAG_TABLE_0[i])) {
+ result.encVal = new Byte( (byte) ((offset + i) | shift));
+ return result;
+ }
+ }
+ //Second table for tags
+ offset = 0x06;
+ for (int i = 0; i < TAG_TABLE_1.length; i++) {
+ if (value.equals(TAG_TABLE_1[i])) {
+ result.encVal = new Byte( (byte) ((offset + i) | shift));
+ result.table = result.table + 1;
+ return result;
+ }
+ }
+ return result;
+ }
+
+ public static ValTab encodeVal(String value) {
+ ValTab result = new ValTab();
+ int offset;
+ //First table for values
+ offset = 0x85;
+ for (int i = 0; i < ATTR_VALUE_TABLE_0.length; i++) {
+ if (value.equals(ATTR_VALUE_TABLE_0[i])) {
+ result.encVal = new Byte( (byte) (offset + i));
+ return result;
+ }
+ }
+ //Second table for values
+ offset = 0x85;
+ for (int i = 0; i < ATTR_VALUE_TABLE_1.length; i++) {
+ if (value.equals(ATTR_VALUE_TABLE_1[i])) {
+ result.encVal = new Byte( (byte) (offset + i));
+ result.table = result.table + 1;
+ return result;
+ }
+ }
+ return result;
+ }
+
+ public static ValTab encodeAttr(String value) {
+ ValTab result = new ValTab();
+ int offset;
+ //First table for attributes
+ offset = 0x05;
+ for (int i = 0; i < ATTR_START_TABLE_0.length; i++) {
+ if (value.equals(ATTR_START_TABLE_0[i])) {
+ result.encVal = new Byte( (byte) (offset + i));
+ return result;
+ }
+ }
+ //Second table for attributes
+ offset = 0x05;
+ for (int i = 0; i < ATTR_START_TABLE_1.length; i++) {
+ if (value.equals(ATTR_START_TABLE_1[i])) {
+ result.encVal = new Byte( (byte) (offset + i));
+ result.table = result.table + 1;
+ return result;
+ }
+ }
+ return result;
+ }
+
+
+ public static final String[] TAG_TABLE_0 = {
+ // page 0
+ "wap-provisioningdoc", // 05
+ "characteristic", // 06
+ "parm" // 07
+ };
+
+ public static final String[] TAG_TABLE_1 = {
+ // page 1
+ "characteristic", // 06
+ "parm" // 07
+ };
+
+ public static final String[] ATTR_VALUE_TABLE_0 = {
+ // ADDRTYPE //
+ "IPV4", // 85
+ "IPV6", // 86
+ "E164", // 87
+ "ALPHA", // 88
+ "APN", // 89
+ "SCODE", // 8a
+ "TETRA-ITSI", // 8b
+ "MAN", // 8c
+ null, // 8d
+ null, // 8e
+ null, // 8f
+ // CALLTYPE //
+ "ANALOG-MODEM", // 90
+ "V.120", // 91
+ "V.110", // 92
+ "X.31", // 93
+ "BIT-TRANSPARENT", // 94
+ "DIRECT-ASYNCHRONOUS-DATA-SERVICE", // 95
+ null, // 96
+ null, // 97
+ null, // 98
+ null, // 99
+ // AUTHTYPE/PXAUTH-TYPE //
+ "PAP", // 9a
+ "CHAP", // 9b
+ "HTTP-BASIC", // 9c
+ "HTTP-DIGEST", // 9d
+ "WTLS-SS", // 9e
+ "MD5", // 9f // OMA //
+ // BEARER //
+ null, // a0
+ null, // a1
+ "GSM-USSD", // a2
+ "GSM-SMS", // a3
+ "ANSI-136-GUTS", // a4
+ "IS-95-CDMA-SMS", // a5
+ "IS-95-CDMA-CSD", // a6
+ "IS-95-CDMA-PACKET", // a7
+ "ANSI-136-CSD", // a8
+ "ANSI-136-GPRS", // a9
+ "GSM-CSD", // aa
+ "GSM-GPRS", // ab
+ "AMPS-CDPD", // ac
+ "PDC-CSD", // ad
+ "PDC-PACKET", // ae
+ "IDEN-SMS", // af
+ "IDEN-CSD", // b0
+ "IDEN-PACKET", // b1
+ "FLEX/REFLEX", // b2
+ "PHS-SMS", // b3
+ "PHS-CSD", // b4
+ "TRETRA-SDS", // b5
+ "TRETRA-PACKET", // b6
+ "ANSI-136-GHOST", // b7
+ "MOBITEX-MPAK", // b8
+ "CDMA2000-1X-SIMPLE-IP", // b9 // OMA //
+ "CDMA2000-1X-MOBILE-IP", // ba // OMA //
+ null, // bb
+ null, // bc
+ null, // bd
+ null, // be
+ null, // bf
+ null, // c0
+ null, // c1
+ null, // c2
+ null, // c3
+ null, // c4
+ // LINKSPEED //
+ "AUTOBAUDING", // c5
+ null, // c6
+ null, // c7
+ null, // c8
+ null, // c9
+ // SERVICE //
+ "CL-WSP", // ca
+ "CO-WSP", // cb
+ "CL-SEC-WSP", // cc
+ "CO-SEC-WSP", // cd
+ "CL-SEC-WTA", // ce
+ "CO-SEC-WTA", // cf
+ "OTA-HTTP-TO", // d0 // OMA //
+ "OTA-HTTP-TLS-TO", // d1 // OMA //
+ "OTA-HTTP-PO", // d2 // OMA //
+ "OTA-HTTP-TLS-PO", // d3 // OMA //
+ null, // d4
+ null, // d5
+ null, // d6
+ null, // d7
+ null, // d8
+ null, // d9
+ null, // da
+ null, // db
+ null, // dc
+ null, // dd
+ null, // de
+ null, // df
+ // AUTH-ENTITY //
+ "AAA", // e0 // OMA //
+ "HA" // e1 // OMA //
+ };
+
+ public static final String[] ATTR_VALUE_TABLE_1 = {
+
+ /* // AAUTHTYPE //
+ ",", // 80 // OMA //
+ "HTTP-", // 81 // OMA //
+ "BASIC", // 82 // OMA //
+ "DIGEST", // 83 // OMA //
+ null, // 84
+ null, // 85
+ */
+ null, // 85
+ // ADDRTYPE //
+ "IPV6", // 86 // OMA //
+ "E164", // 87 // OMA //
+ "ALPHA", // 88 // OMA //
+ null, // 89
+ null, // 8a
+ null, // 8b
+ null, // 8c
+ "APPSRV", // 8d // OMA //
+ "OBEX", // 8e // OMA //
+ null, // 8f
+ // AAUTHTYPE //
+ ",", // 90 // OMA //
+ "HTTP-", // 81 // OMA //
+ "BASIC", // 82 // OMA //
+ "DIGEST" // 83 // OMA //
+ };
+
+ public static final String[] ATTR_START_TABLE_0 = {
+
+ // Parm //
+ "name", // 05
+ "value", // 06
+ "name=NAME", // 07
+ "name=NAP-ADDRESS", // 08
+ "name=NAP-ADDRTYPE", // 09
+ "name=CALLTYPE", // 0a
+ "name=VALIDUNTIL", // 0b
+ "name=AUTHTYPE", // 0c
+ "name=AUTHNAME", // 0d
+ "name=AUTHSECRET", // 0e
+ "name=LINGER", // 0f
+ "name=BEARER", // 10
+ "name=NAPID", // 11
+ "name=COUNTRY", // 12
+ "name=NETWORK", // 13
+ "name=INTERNET", // 14
+ "name=PROXY-ID", // 15
+ "name=PROXY-PROVIDER-ID", //16
+ "name=DOMAIN", // 17
+ "name=PROVURL", // 18
+ "name=PXAUTH-TYPE", // 19
+ "name=PXAUTH-ID", // 1a
+ "name=PXAUTH-PW", // 1b
+ "name=STARTPAGE", // 1c
+ "name=BASAUTH-ID", // 1d
+ "name=BASAUTH-PW", // 1e
+ "name=PUSHENABLED", // 1f
+ "name=PXADDR", // 20
+ "name=PXADDRTYPE", // 21
+ "name=TO-NAPID", // 22
+ "name=PORTNBR", // 23
+ "name=SERVICE", // 24
+ "name=LINKSPEED", // 25
+ "name=DNLINKSPEED", // 26
+ "name=LOCAL-ADDR", // 27
+ "name=LOCAL-ADDRTYPE", // 28
+ "name=CONTEXT-ALLOW", // 29
+ "name=TRUST", // 2a
+ "name=MASTER", // 2b
+ "name=SID", // 2c
+ "name=SOC", // 2d
+ "name=WSP-VERSION", // 2e
+ "name=PHYSICAL-PROXY-ID", //2f
+ "name=CLIENT-ID", // 30
+ "name=DELIVERY-ERR-SDU", // 31
+ "name=DELIVERY-ORDER", // 32
+ "name=TRAFFIC-CLASS", // 33
+ "name=MAX-SDU-SIZE", // 34
+ "name=MAX-BITRATE-UPLINK", //35
+ "name=MAX-BITRATE-DNLINK", //36
+ "name=RESIDUAL-BER", // 37
+ "name=SDU-ERROR-RATIO", // 38
+ "name=TRAFFIC-HANDL-PRIO", //39
+ "name=TRANSFER-DELAY", // 3a
+ "name=GUARANTEED-BITRATE-UPLINK", //3b
+ "name=GUARANTEED-BITRATE-DNLINK", //3c
+ "name=PXADDR-FQDN", //3d // OMA //
+ "name=PROXY-PW", //3e // OMA //
+ "name=PPGAUTH-TYPE", //3f // OMA //
+ null, // 40
+ null, // 41
+ null, // 42
+ null, // 43
+ null, // 44
+ "version", // 45
+ "version=1.0", // 46
+ "name=PULLENABLED", // 47 // OMA //
+ "name=DNS-ADDR", // 48 // OMA //
+ "name=MAX-NUM-RETRY", // 49 // OMA //
+ "name=FIRST-RETRY-TIMEOUT", //4a // OMA //
+ "name=REREG-THRESHOLD", // 4b // OMA //
+ "name=T-BIT", // 4c // OMA //
+ null, // 4d
+ "name=AUTH-ENTITY", // 4e // OMA //
+ "name=SPI", // 4f // OMA //
+ // Characteristic //
+ "type", //50
+ "type=PXLOGICAL", // 51
+ "type=PXPHYSICAL", // 52
+ "type=PORT", // 53
+ "type=VALIDITY", // 54
+ "type=NAPDEF", // 55
+ "type=BOOTSTRAP", // 56
+ "type=VENDORCONFIG", // 57
+ "type=CLIENTIDENTITY", // 58
+ "type=PXAUTHINFO", // 59
+ "type=NAPAUTHINFO", // 5a
+ "type=ACCESS", // 5b // OMA //
+ };
+
+ public static final String[] ATTR_START_TABLE_1 = {
+
+ // Parm //
+ "name", // 05 // OMA //
+ "value", // 06 // OMA //
+ "name=NAME", // 07 // OMA //
+ null, // 08
+ null, // 09
+ null, // 0a
+ null, // 0b
+ null, // 0c
+ null, // 0d
+ null, // 0e
+ null, // 0f
+ null, // 10
+ null, // 11
+ null, // 12
+ null, // 13
+ "name=INTERNET", // 14 // OMA //
+ null, // 15
+ null, // 16
+ null, // 17
+ null, // 18
+ null, // 19
+ null, // 1a
+ null, // 1b
+
+ "name=STARTPAGE", // 1c // OMA //
+ null, // 1d
+ null, // 1e
+ null, // 1f
+ null, // 20
+ null, // 21
+
+ "name=TO-NAPID", // 22 // OMA //
+ "name=PORTNBR", // 23 // OMA //
+ "name=SERVICE", // 24 // OMA //
+ null, // 25
+ null, // 26
+ null, // 27
+ null, // 28
+ null, // 29
+ null, // 2a
+ null, // 2b
+
+ null, // 2c // OMA //
+ null, // 2d
+
+ "name=AACCEPT", // 2e // OMA //
+ "name=AAUTHDATA", // 2f // OMA //
+ "name=AAUTHLEVEL", // 30 // OMA //
+ "name=AAUTHNAME", // 31 // OMA //
+ "name=AAUTHSECRET", // 32 // OMA //
+ "name=AAUTHTYPE", // 33 // OMA //
+ "name=ADDR", // 34 // OMA //
+ "name=ADDRTYPE", // 35 // OMA //
+ "name=APPID", // 36 // OMA //
+ "name=APROTOCOL", // 37 // OMA //
+ "name=PROVIDER-ID", // 38 // OMA //
+ "name=TO-PROXY", // 39 // OMA //
+ "name=URI", // 3a // OMA //
+ "name=RULE", // 3b // OMA //
+ null, // 3c
+ null, // 3d
+ null, // 3e
+ null, // 3f
+ null, // 40
+ null, // 41
+ null, // 42
+ null, // 43
+ null, // 44
+ null, // 45
+ null, // 46
+ null, // 47
+ null, // 48
+ null, // 49
+ null, // 4a
+ null, // 4b
+ null, // 4c
+ null, // 4d
+ null, // 4e
+ null, // 4f
+ "type", // 50 // OMA //
+ null, // 51
+ null, // 52
+ "type=PORT", // 53 // OMA //
+ null, //54
+
+ "type=APPLICATION", // 55 // OMA //
+ "type=APPADDR", // 56 // OMA //
+ "type=APPAUTH", // 57 // OMA //
+ "type=CLIENTIDENTITY", // 58 // OMA //
+ "type=RESOURCE", // 59 // OMA //
+
+ };
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Record.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Record.java
new file mode 100644
index 0000000..b948065
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Record.java
@@ -0,0 +1,95 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+
+public class Record
+ implements Comparable {
+ public boolean containsMMS = false;
+ public boolean containsBrowser = false;
+ public boolean containsJavaApp = false;
+ public boolean containsIM = false;
+
+ public int mcc = 0;
+ public int mnc = 0;
+ public int mncLen;
+ public int account_type;
+ public String operator_name;
+ public String key;
+ public int operator_name_offset;
+ public byte[] application_settings;
+ public int application_settings_offset;
+
+ public ArrayList arrXMLs = new ArrayList();
+ public ArrayList arrIDs = new ArrayList();
+
+ /* public void genCompareStr() {
+ String str_mcc = paddingToSize(this.mcc + "");
+ String str_mnc = paddingToSize(this.mnc + "");
+ compareStr = str_mcc + str_mnc + operator_name + account_type;
+ }*/
+
+ private static String paddingToSize(String str) {
+ int len = str.length();
+ for (int i = len; i < 5; i++) {
+ str = "0" + str;
+ }
+ return str;
+ }
+
+ public int setBlockApplicationSettings(byte[] metaInfo, byte[] data) throws
+ Exception {
+ application_settings = new byte[metaInfo.length + data.length];
+ for (int i = 0; i < metaInfo.length; i++) {
+ application_settings[i] = metaInfo[i];
+ }
+ int metaLength = metaInfo.length;
+ for (int i = 0; i < data.length; i++) {
+ application_settings[metaLength + i] = data[i];
+ }
+ return application_settings.length;
+ }
+// change here KEy generation.....
+ public final static String createKey(String mcc, String mnc, String name,
+ String type) throws
+ Exception {
+ StringBuffer sb_key = new StringBuffer();
+ //sb_key.append(paddingToSize(mcc + ""));
+ sb_key.append(mcc);
+ sb_key.append(":");
+ //sb_key.append(paddingToSize(mnc + ""));
+ sb_key.append(mnc);
+ sb_key.append(":");
+ sb_key.append(name);
+ sb_key.append(":");
+ sb_key.append(type);
+ return sb_key.toString();
+ }
+
+ public int compareTo(Object o) throws ClassCastException {
+
+ Record record = (Record) o;
+ if (mcc != record.mcc) {
+ return mcc < record.mcc ? -1 : 1;
+ }
+
+ int currMnc = (mncLen == 3) ? (mnc + 1000) : mnc;
+ int recordMnc = (record.mncLen == 3) ? (record.mnc + 1000) : record.mnc;
+
+ if (currMnc != recordMnc) {
+ return currMnc < recordMnc ? -1 : 1;
+ }
+
+ //int i = operator_name.compareTo(record.operator_name);
+ // if( i != 0 )
+ // return i;
+ if (this.operator_name_offset != record.operator_name_offset) {
+ return operator_name_offset < record.operator_name_offset ? -1 : 1;
+ }
+
+ if (this.account_type != record.account_type) {
+ return account_type < record.account_type ? -1 : 1;
+ }
+
+ return 0;
+ }
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Util.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Util.java
new file mode 100644
index 0000000..a83fd05
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Util.java
@@ -0,0 +1,451 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+import java.io.*;
+import java.util.zip.*;
+
+public class Util {
+
+ public static Value[] attStrToArrValue(String[] result_str) {
+ Value[] vals = new Value[result_str.length];
+ for (int i = 0; i < vals.length; i++) {
+ Value val = new Value(result_str[i], i);
+ vals[i] = val;
+ }
+ return vals;
+ }
+
+ public static String getIdNameFromRecords(String id, String key) throws
+ Exception {
+ int count = 0;
+ String tmp;
+ String tmp_id = id;
+ boolean isUnique = false;
+ Record rec = (Record) Generator.hashXmlRecords.get(key);
+ if (rec == null) {
+ return id;
+ }
+ // add count to the end of id to make it unique.
+ while (!isUnique) {
+ isUnique = true;
+ for (int i = 0; i < rec.arrIDs.size(); i++) {
+ tmp = (String) (rec.arrIDs.get(i));
+ if (tmp.equalsIgnoreCase(tmp_id)) {
+ isUnique = false;
+ tmp_id = id + ++count;
+ break;
+ }
+ }
+ }
+ return tmp_id;
+ }
+
+ public static void addXmlToRecord(String xml, String key, String id_name,
+ String source) throws Exception {
+ Record rec = (Record) Generator.hashXmlRecords.get(key);
+ if (rec == null) {
+ rec = new Record();
+ rec.key = key;
+ parseKeyToRecord(key, rec);
+ // rec.genCompareStr();
+ }
+ rec.arrIDs.add(id_name);
+ rec.arrXMLs.add(xml);
+ if ("BROWSER".equalsIgnoreCase(source)) {
+ rec.containsBrowser = true;
+ }
+ else if ("MMS".equalsIgnoreCase(source)) {
+ rec.containsMMS = true;
+ }
+ else if ("JAVA".equalsIgnoreCase(source)) {
+ rec.containsJavaApp = true;
+ }
+ else if ("IM".equalsIgnoreCase(source)) {
+ rec.containsIM = true;
+ }
+ else {
+ throw new Exception(
+ "Error! Unsupported application type during record creation.");
+ }
+ Generator.hashXmlRecords.put(key, rec);
+ }
+
+ //set mnc, mcc, provider_name and prepaid values for a record from combine key
+ public static void parseKeyToRecord(String key, Record record) throws
+ Exception {
+ StringTokenizer st = new StringTokenizer(key, ":");
+ if (st.countTokens() != 4) {
+ throw new Exception("Error: The key '" + key + "' is wrong.");
+ }
+ String tmp;
+ tmp = st.nextToken().trim();
+ record.mcc = Integer.parseInt(tmp);
+ tmp = st.nextToken().trim();
+ record.mncLen = tmp.length();
+ record.mnc = Integer.parseInt(tmp);
+ tmp = st.nextToken().trim();
+ record.operator_name = tmp;
+ tmp = st.nextToken().trim();
+ if (Const.PREPAID.equalsIgnoreCase(tmp)) {
+ record.account_type = Const.PREPAID_INT;
+ }
+ else if (Const.POSTPAID.equalsIgnoreCase(tmp)) {
+ record.account_type = Const.POSTPAID_INT;
+ }
+ else {
+ record.account_type = Const.BOTH_INT;
+ }
+ }
+
+ //creates xml, wbxml, zip files
+ public static void writeRecordsToFiles() throws Exception {
+ String omacp_xml;
+ byte[] omacp_wbxml;
+ Iterator keys = Generator.hashXmlRecords.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = (String) keys.next();
+ // create file name
+ //String fileGenName = key.replaceAll(":", "_"); ///rem
+ //fileGenName = key.replaceAll(" ", "_"); ///rem
+ String fileGenName = generateFileNameFromKey(key);
+
+ String fileXml = fileGenName + ".xml";
+ String fileWbxml = fileGenName + ".wbxml";
+ String fileZip = fileGenName + ".zip";
+
+ omacp_xml = recordToXml(key);
+ writeFile(fileXml, omacp_xml);
+
+
+ WbxmlEncoder encoder = new WbxmlEncoder();
+ //omacp_wbxml = encoder.encode(omacp_xml); //old usage
+ omacp_wbxml = encoder.encode(new File(fileXml));
+ writeFile(fileWbxml, omacp_wbxml);
+
+ copyFile(fileXml, Const.WORKING_DIR + Const.PATH_SEP + fileXml);
+ copyFile(fileWbxml, Const.WORKING_DIR + Const.PATH_SEP + fileWbxml);
+
+ if (Generator.USE_ZIP) {
+ writeZipFile(fileWbxml, fileZip);
+ copyFile(fileZip, Const.WORKING_DIR + Const.PATH_SEP + fileZip);
+ (new File(fileZip)).delete();
+ }
+
+ (new File(fileXml)).delete();
+ (new File(fileWbxml)).delete();
+ }
+ }
+
+ public static String recordToXml(String key) throws Exception {
+ StringBuffer allXmlForKey = new StringBuffer();
+ Record record = (Record) Generator.hashXmlRecords.get(key);
+ if (record != null) {
+ for (int i = 0; i < record.arrXMLs.size(); i++) {
+ allXmlForKey.append( (String) record.arrXMLs.get(i));
+ }
+ }
+ String validXml = "<wap-provisioningdoc version=\"1.1\">\n" +
+ allXmlForKey.toString() + "</wap-provisioningdoc>\n";
+ return validXml;
+ }
+
+///############################################################################
+ public static void sortAllRecordsIntoArray() throws Exception {
+ Generator.arraySortedRecords = new Record[Generator.hashXmlRecords.size()];
+ Iterator iterator = Generator.hashXmlRecords.keySet().iterator();
+ Record record;
+ int count = 0;
+ while (iterator.hasNext()) {
+ record = (Record) Generator.hashXmlRecords.get(iterator.next());
+ Generator.arraySortedRecords[count] = record;
+ count++;
+ }
+ Arrays.sort(Generator.arraySortedRecords);
+ }
+
+ public static void addBitsToTable(BlockTable table, int value,
+ int bitsSize) {
+ for (int i = bitsSize - 1; i >= 0; i--) {
+ table.data[table.byteCount] |=
+ (value & (1 << i)) != 0 ? 1 << (7 - table.bitCount) : 0;
+
+ table.bitCount++;
+
+ if (table.bitCount == 8) {
+ table.bitCount = 0;
+ table.byteCount++;
+ }
+ }
+ }
+
+ public static ArrayList readFile(String path) throws Exception {
+ ArrayList arr = new ArrayList();
+ File f = new File(path);
+ if (!f.exists()) {
+ throw new Exception("Error: The file " + f.getAbsolutePath() +
+ " doesn't exist!");
+ }
+ // txt files should be encoded with UTF-16; csv - with UTF-8
+ Reader fr = new InputStreamReader(new FileInputStream(f),
+ Generator.ENCODING);
+
+ BufferedReader br = new BufferedReader(fr);
+ String line;
+ int count = 0;
+ while ( (line = br.readLine()) != null) {
+ count++;
+ line = new String(line.getBytes("UTF-8"));
+ line = line.trim();
+ if (line.length() > 0) {
+ if (Generator.IS_INPUT_TXT_FILE) { //validate and replace tabs with ","
+ if (line.indexOf(',') >= 0) {
+ throw new Exception("Error: The line#" + count +
+ " in the text file " + f.getAbsolutePath() +
+ " cannot contains comma ',' as a value.");
+ }
+ line = line.replaceAll("\t", ",");
+ }
+ else if (line.indexOf('\t') >= 0) {
+ throw new Exception("Error: The line#" + count +
+ " in the csv file " + f.getAbsolutePath() +
+ " contains tabulation as a value.");
+ }
+ arr.add(line);
+ }
+ }
+ br.close();
+ fr.close();
+ return arr;
+ }
+
+///WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
+/* public static void writeFile(String path, String content) throws
+ Exception {
+ Writer fw = new OutputStreamWriter(new FileOutputStream(path), "UTF-8"); //Generator.ENCODING
+ fw.write(content);
+ fw.flush();
+ fw.close();
+ }*/
+
+ //old function
+ public static void writeFile(String path, String content) throws Exception {
+ writeFile(path, content.getBytes());
+ }
+
+ public static void writeFile(String path, byte[] content) throws Exception {
+ File f = new File(path);
+ FileOutputStream fos = new FileOutputStream(f);
+ fos.write(content);
+ fos.flush();
+ fos.close();
+ }
+
+ public static void writeDBFile() throws Exception {
+ File f = new File(Const.DB_FILE_NAME);
+ FileOutputStream fos = new FileOutputStream(f);
+ // write header
+ fos.write(Generator.headerTable.data);
+ // write operators names table
+ fos.write(Generator.operatorsNamesTable.data);
+ // write carrier index table
+ fos.write(Generator.carrierIndexTable.data);
+ // write applications settings table
+ fos.write(Generator.applicationsSettingsTable.data);
+
+ fos.flush();
+ fos.close();
+ }
+
+ public static void deleteFile(String path) {
+ File f = new File(path);
+ if (f.exists()) {
+ f.delete();
+ }
+ }
+
+ public static void writeZipFile(String inputFileName,
+ String outputZipFileName) throws Exception {
+
+ FileInputStream in = new FileInputStream(inputFileName);
+ int wbxmlLen = in.available();
+ byte[] wbxml_content = new byte[wbxmlLen];
+ in.read(wbxml_content);
+ in.close();
+
+ Deflater compressor = new Deflater();
+ compressor.setLevel(Deflater.BEST_COMPRESSION);
+ compressor.setInput(wbxml_content);
+ compressor.finish();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(wbxmlLen);
+ byte[] buf = new byte[1024];
+ while (!compressor.finished()) {
+ int count = compressor.deflate(buf);
+ bos.write(buf, 0, count);
+ }
+ bos.close();
+ byte[] wbxml_zip = bos.toByteArray();
+ FileOutputStream fos = new FileOutputStream(outputZipFileName);
+ fos.write(wbxml_zip);
+ fos.flush();
+ fos.close();
+ //System.out.println("in: " + wbxmlLen + " out: " + wbxml_zip.length);
+ }
+
+
+ public static void copyFile(String fromFile, String toFile) throws Exception {
+ FileInputStream fis = new FileInputStream(fromFile);
+ FileOutputStream fos = new FileOutputStream(toFile);
+ byte[] buf = new byte[1024];
+ int i = 0;
+ while ( (i = fis.read(buf)) != -1) {
+ fos.write(buf, 0, i);
+ }
+ if (fis != null) {
+ fis.close();
+ }
+ if (fos != null) {
+ fos.close();
+ }
+ }
+
+ public static void deleteDir(String path) throws Exception {
+ File f = new File(path);
+ if (f.exists() && f.isDirectory()) {
+ File[] files = f.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ files[i].delete();
+ }
+ f.delete();
+ }
+ }
+
+ public static String str(String s) {
+ return (s != null) ? s : "";
+ }
+
+ public static boolean strToBool(String s) {
+ s = (str(s)).toUpperCase();
+ if (s.equals("YES") || s.equals("TRUE") || s.equals("1")) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isFileExists(String path) {
+ return (path == null) ? false : ( (new File(path)).exists());
+ }
+
+ // validate input files and set Encoding
+ public static String validateAndSetInputParms() {
+ String mms = Generator.pathMMSFile;
+ String browser = Generator.pathBrowserFile;
+ String java = Generator.pathJavaAppFile;
+ String im = Generator.pathIMFile;
+ String fileExtention = "";
+ String tmp;
+ //check that at least one file is presenting
+ if (!isFileExists(mms) && !isFileExists(browser) && !isFileExists(java) &&
+ !isFileExists(im)) {
+ return "Error: At least one correct file (mms or browser or java or IM) must be provided !!!";
+ }
+ //set files type
+ if (mms != null) {
+ tmp = mms.substring(mms.length() - 4);
+ if (fileExtention.length() > 0 && !fileExtention.equals(tmp)) {
+ return
+ "Error: All input files should have the same type: txt or csv !!!";
+ }
+ fileExtention = tmp;
+ }
+ if (browser != null) {
+ tmp = browser.substring(browser.length() - 4);
+ if (fileExtention.length() > 0 && !fileExtention.equals(tmp)) {
+ return
+ "Error: All input files should have the same type: txt or csv !!!";
+ }
+ fileExtention = tmp;
+ }
+ if (java != null) {
+ tmp = java.substring(java.length() - 4);
+ if (fileExtention.length() > 0 && !fileExtention.equals(tmp)) {
+ return
+ "Error: All input files should have the same type: txt or csv !!!";
+ }
+ fileExtention = tmp;
+ }
+
+ if (im != null) {
+ tmp = im.substring(im.length() - 4);
+ if (fileExtention.length() > 0 && !fileExtention.equals(tmp)) {
+ return
+ "Error: All input files should have the same type: txt or csv !!!";
+ }
+ fileExtention = tmp;
+ }
+ if (fileExtention.equals(".txt")) {
+ Generator.IS_INPUT_TXT_FILE = true;
+ Generator.ENCODING = "UTF-16";
+ }
+ else {
+ Generator.ENCODING = "UTF-8";
+ Generator.IS_INPUT_TXT_FILE = false;
+ }
+ return null;
+ }
+
+ public static String generateFileNameFromKey(String key) throws Exception{
+ //byte[] bb = key.getBytes("UTF-8");
+ //for (int i = 0; i < bb.length; i++) {
+ // System.out.print(Integer.toHexString(bb[i]) + " ");
+ //}
+ StringTokenizer st = new StringTokenizer(key, ":");
+ StringBuffer fileName = new StringBuffer();
+ String tmp;
+ tmp = st.nextToken(); //mnc
+ fileName.append(tmp).append("_");
+
+ tmp = st.nextToken(); //mcc
+ fileName.append(tmp).append("_");
+
+ //carrier name... replace unicode to hex if required.
+ tmp = st.nextToken();
+ byte b;
+ String hex = "";
+ String tmpHex;
+ boolean hexRequired = false;
+ byte[] bytes = tmp.getBytes();
+ for (int i = 0; i < bytes.length; i++) {
+ b = bytes[i];
+ if (! ( (b >= 48 && b <= 57) || (b >= 65 && b <= 90) ||
+ (b >= 97 && b <= 122))) {
+ hexRequired = true;
+ }
+ tmpHex = Integer.toHexString(((int)b) & 0xff ).toUpperCase();
+ hex += tmpHex;
+ }
+
+ tmp = (hexRequired) ? hex.replaceAll(" ", "_") : tmp.replaceAll(" ", "_"); //carrier name...
+ fileName.append(tmp).append("_");
+ tmp = st.nextToken(); //payment type
+ fileName.append(tmp);
+//System.out.println(">" + fileName.toString() + "<");
+ return fileName.toString();
+ }
+
+ ///// ================== for test only..... ===========================
+ public static void printRecords() {
+ for (int i = 0; i < Generator.arraySortedRecords.length; i++) {
+ System.out.println(
+ " mcc=" + Generator.arraySortedRecords[i].mcc +
+ " mnc=" + Generator.arraySortedRecords[i].mnc +
+ " mncLen=" + Generator.arraySortedRecords[i].mncLen +
+ " offset=" +
+ Generator.arraySortedRecords[i].operator_name_offset +
+ " payment=" +
+ Generator.arraySortedRecords[i].account_type);
+ }
+
+ }
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/ValTab.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/ValTab.java
new file mode 100644
index 0000000..65f7815
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/ValTab.java
@@ -0,0 +1,6 @@
+package com.mot.dm.dbtool;
+
+public class ValTab {
+ public Byte encVal = null;
+ public int table = 0x00;
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Validator.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Validator.java
new file mode 100644
index 0000000..82a255f
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Validator.java
@@ -0,0 +1,687 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+
+public class Validator {
+
+ // Validate that applications settings table length doesn't exceed max size
+ // defined in the Const.java as ALIICATION_SETTINGS_MAX_SIZE in bytes
+ public static void validateMaxAppsSettingsLength(int appsSettingsLength) throws
+ Exception {
+ if (appsSettingsLength >= Const.ALIICATION_SETTINGS_MAX_SIZE) {
+ throw new Exception(
+ "Error: Applications Settings Table length exceed " +
+ (Const.ALIICATION_SETTINGS_MAX_SIZE / 8) + " bytes.");
+ }
+ }
+
+ // Validate that last applications settings block offset (since it is the biggest)
+ // doesn't exceed max size defined in the Const.java as APP_SETTINGS_OFFSET_BITS in bits
+ public static void validateMaxAppsSettingsOffset(int appsSettingsOffset) throws
+ Exception {
+ if (appsSettingsOffset >= Math.pow(2, Const.APP_SETTINGS_OFFSET_BITS)) {
+ throw new Exception(
+ "Error: Applications Settings block offset exceeds " +
+ (Const.APP_SETTINGS_OFFSET_BITS / 8) + " bytes");
+ }
+ }
+
+ // Validate that Data length for one Applications doesn't exceed max size
+ // defined in the Const.java as Const.APP_BLOCK_LENGTH in bits
+ public static void validateAppBlockSettingsLength(int appBlockSettingsLength,
+ String generalPath) throws
+ Exception {
+ if (appBlockSettingsLength >= Math.pow(2, Const.APP_BLOCK_LENGTH)) {
+ throw new Exception(
+ "Error: Applications Data length exceeds " + Const.APP_BLOCK_LENGTH +
+ " bits for the " + generalPath);
+ }
+ }
+
+ // Validate that operators names offset doesn't exceed max size
+ // defined in the Const.java as Const.OPERATOR_NAME_OFFSET_BITS in bits
+ public static void validateOperatorNameOffset(int operatorNameOffset) throws
+ Exception {
+ if (operatorNameOffset >= Math.pow(2, Const.OPERATOR_NAME_OFFSET_BITS)) {
+ throw new Exception("Error: Operators Names offset exceeds " +
+ Const.OPERATOR_NAME_OFFSET_BITS + " bits");
+ }
+ }
+
+ // Validate that operators names table size doesn't exceed max size
+ // defined in the Const.java as Const.HEAD_OPERATOR_NAMES_TAB_SISE in bits
+ public static void validateOperatorNamesTableSize(int operatorNamesTableSize) throws
+ Exception {
+ if (operatorNamesTableSize >=
+ Math.pow(2, Const.HEAD_OPERATOR_NAMES_TAB_SISE)) {
+ throw new Exception("Error: Operators Names Table size exceeds " +
+ (Const.HEAD_OPERATOR_NAMES_TAB_SISE / 8) + " bytes");
+ }
+ }
+
+ // performs post validation (after all processes before generating files.
+ public static void postValidate() throws Exception {
+ String err = "";
+ err += validateAccountTypesCompatibility_Post();
+
+ // add more post validation here....
+
+ if (err.length() > 0) {
+ throw new Exception(err);
+ }
+ }
+
+ // Validate that operators may have only (RPEPAID or/and POSTPAID) or (BOTH).
+ // The BOTH cannot we with any other types.
+ public static String validateAccountTypesCompatibility_Post() {
+
+ String err = "";
+ Record rec;
+ int tmp;
+ int acc_type;
+ Map map = new HashMap();
+
+ for (int i = 0; i < Generator.arraySortedRecords.length; i++) {
+ rec = Generator.arraySortedRecords[i];
+
+ String mnc = rec.mnc + "";
+ while (mnc.length() < rec.mncLen) {
+ mnc = "0" + mnc; // pedding with "0"
+ }
+ String key_tmp = rec.mcc + ":" + mnc + ":" + rec.operator_name;
+ acc_type = rec.account_type;
+ if (map.containsKey(key_tmp)) {
+ tmp = ( (Integer) map.get(key_tmp)).intValue();
+ acc_type += tmp;
+ if (acc_type >= 2) {
+ err += "mcc: " + rec.mcc + " mnc: " + rec.mnc + " operator name: " +
+ rec.operator_name + "\n";
+ }
+ }
+ map.put(key_tmp, new Integer(acc_type));
+ }
+ if (err.length() > 0) {
+ err = "The following records has incompatible account (payment) types;\n" +
+ "'Prepaid' and/or 'Postpaid' cannot be with 'Both' for the following carriers:\n" +
+ err;
+ }
+ return err;
+ }
+
+ //validate mcc: required, int, 0-999
+ public static String validateMCC(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'mcc' is required and cannot be empty\n";
+ }
+ if (!isIntValid(parm, 0, 999)) {
+ return " field 'mcc' must be integer between 0 and 999\n";
+ }
+ if (parm.val.length() < 2 || parm.val.length() > 3) {
+ return " value in the field 'mcc' must have 2 or 3 digits\n";
+ }
+
+ return "";
+ }
+
+ //validate mnc: required, int, 0-999
+ public static String validateMNC(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'mnc' is required and cannot be empty\n";
+ }
+ if (!isIntValid(parm, 0, 999)) {
+ return " field 'mnc' must be integer between 1 and 999\n";
+ }
+ if (parm.val.length() < 2 || parm.val.length() > 3) {
+ return " value in the field 'mnc' must have 2 or 3 digits\n";
+ }
+
+ return "";
+ }
+
+ //validate account_type: required, String, values: prepaid, postpaid or both
+ public static String validateAccountType(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'account_type' is required and cannot be empty\n";
+ }
+ if (! (Const.PREPAID.equals(parm.val) || Const.POSTPAID.equals(parm.val) ||
+ Const.BOTH.equals(parm.val))) {
+ return " field 'account_type' contains incorect value'" + parm.val +
+ "'; the value can be '" + Const.PREPAID + "', '" + Const.POSTPAID +
+ "' or '" + Const.BOTH + "'\n";
+ }
+ return "";
+ }
+
+ //validate string : required or not, max/min length.
+ public static String validateStringValue(Value parm, boolean isRequired,
+ int minLength, int maxLength,
+ String fieldName) {
+ if (!isRequired && isValEmpty(parm)) {
+ return ""; //OK, value can be empty
+ }
+
+ if (isRequired && isValEmpty(parm)) {
+ return " field '" + fieldName + "' is required and cannot be empty\n";
+ }
+ if (maxLength > 0 && parm.val.getBytes().length > maxLength) {
+ return " field '" + fieldName + "' exceed max length: " + maxLength +
+ " bytes\n";
+ }
+ if (minLength > 0 && parm.val.getBytes().length < minLength) {
+ return " field '" + fieldName + "' has value shorter then min length: " +
+ minLength +
+ " bytes\n";
+ }
+ return "";
+ }
+
+ //validate boolean : required or not, correct value.
+ public static String validateBoolValue(Value parm, boolean isRequired,
+ String fieldName) {
+ if (isRequired && isValEmpty(parm)) {
+ return " field '" + fieldName + "' is required and cannot be empty\n";
+ }
+ if (!Const.TRUE.equals(parm.val) && !Const.FALSE.equals(parm.val)) {
+ return " field '" + fieldName +
+ "' accept only values 'true' or 'false'\n";
+ }
+ return "";
+ }
+
+ public static String validateIntegerValue(Value parm, int min, int max,
+ boolean isRequired,
+ String fieldName) {
+ boolean isParmValEmpty = isValEmpty(parm);
+
+ if (isRequired && isParmValEmpty) {
+ return
+ " field '" + fieldName + "' is required and cannot be empty\n";
+ }
+ if (!isParmValEmpty && !isIntValid(parm, min, max)) {
+ return " field '" + fieldName + "' contains invalid value'" + parm.val +
+ "'\n";
+ }
+ return "";
+ }
+
+//validate value from predefined list (array)
+ public static String validateValueFromDefinedList(Value parm,
+ String[] listValues, boolean isRequired, String fieldName) {
+ boolean isParmValEmpty = isValEmpty(parm);
+
+ if (isParmValEmpty && isRequired) {
+ return " field '" + fieldName + "' is required and cannot be empty\n";
+ }
+ if (!isParmValEmpty && !isElementValid(listValues, parm.val)) {
+ return " field '" + fieldName + "' contains invalid value'" + parm.val +
+ "'\n";
+ }
+ return "";
+ }
+
+ //validate operator_name: required, String, max length 128 (OPERATOR_NAME_MAX_LENGTH)
+ /* public static String validateOperatorName(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'operator_name' is required and cannot be empty\n";
+ }
+ if (parm.val.getBytes().length > Const.OPERATOR_NAME_MAX_LENGTH) {
+ return " field 'operator_name' exceed max length " +
+ Const.OPERATOR_NAME_MAX_LENGTH + " bytes\n";
+ }
+ return "";
+ }*/
+
+ //validate service_name: required, String, max length 128 (SERVICE_NAME_MAX_LENGTH)
+ /* public static String validateServiceName(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'service_name' is required and cannot be empty\n";
+ }
+ if (!checkMaxLength(parm, Const.SERVICE_NAME_MAX_LENGTH)) {
+ return " field 'service_name' exceed max length " +
+ Const.SERVICE_NAME_MAX_LENGTH + " bytes\n";
+ }
+ return "";
+ }*/
+
+ //validate ap_requires_auth: required, int, can be 0 or 1 wwwwwww
+ public static String validateApRequiresAuth(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'ap_requires_auth' is required and cannot be empty\n";
+ }
+ if (!isIntValid(parm, 0, 1)) {
+ return " field 'ap_requires_auth' must be integer 0 or 1\n";
+ }
+ return "";
+ }
+
+ //validate ppp_auth_type: required if ap_requires_auth=1, String, can have only
+ //values from array Const.NAPAUTHINFO_AUTHTYPE
+ public static String validatePppAuthType(Value parm, String authReq) {
+ boolean isParmValEmpty = isValEmpty(parm);
+
+ if (authReq.equals("0") && !isParmValEmpty) {
+ return " field 'ppp_auth_type' can't have value if ap_requires_auth=0\n";
+ }
+ if (authReq.equals("1") && isParmValEmpty) {
+ return " field 'ppp_auth_type' can't be empty if ap_requires_auth=1\n";
+ }
+ if (!isParmValEmpty && !isElementValid(Const.NAPAUTHINFO_AUTHTYPE, parm.val)) {
+ return " field 'ppp_auth_type' contains invalid value'" + parm.val +
+ "'\n";
+ }
+ return "";
+ }
+
+ //validate ppp_auth_name: can be set only if ap_requires_auth=1, String, max length 30 bytes
+ public static String validatePppAuthName(Value parm, String authReq) {
+ if (authReq.equals("0") && !isValEmpty(parm)) {
+ return " field 'ppp_auth_name' can't have value if ap_requires_auth=0\n";
+ }
+ if (!checkMaxLength(parm, Const.USER_NAME_MAX_LENGTH)) {
+ return " field 'ppp_auth_name' exceed max length " +
+ Const.USER_NAME_MAX_LENGTH + "\n";
+ }
+ return "";
+ }
+
+ //validate ppp_auth_secret: can be set only if ap_requires_auth=1, String, max length 30 bytes
+ public static String validatePppAuthSecret(Value val, String authReq) {
+ if (authReq.equals("0") && !isValEmpty(val)) {
+ return
+ " field 'ppp_auth_secret' can't have value if ap_requires_auth=0\n";
+ }
+ if (!checkMaxLength(val, Const.PASWORD_MAX_LENGTH)) {
+ return " field 'ppp_auth_secret' exceed max length " +
+ Const.PASWORD_MAX_LENGTH + "\n";
+ }
+ return "";
+ }
+
+ //validate nap_addr_type: required, String, can have only values from array
+ //Const.NAPDEF_NAPADDRTYPE
+ public static String validateNAPAddrType(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'nap_addr_type' is required and cannot be empty\n";
+ }
+ if (!isElementValid(Const.NAPDEF_NAPADDRTYPE, parm.val)) {
+ return " field 'nap_addr_type' contains invalid value'" + parm.val +
+ "'\n";
+ }
+ return "";
+ }
+
+ //validate bearer: required , String, can have only values from array
+ //Const.BEARER
+ public static String validateBearer(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'bearer' is required and cannot be empty\n";
+ }
+ if (!isElementValid(Const.BEARER, parm.val)) {
+ return " field 'bearer' contains invalid value'" + parm.val + "'\n";
+ }
+ return "";
+ }
+
+ //validate gprs_access_point_name: required , String, should match nap_addr_type
+ //(NAPDEF.NAP-ADDRESS)
+ public static String validateGprsAccessPoint(Value parm, String napAddrType) {
+ if (isValEmpty(parm)) {
+ return
+ " field 'gprs_access_point_name' is required and cannot be empty\n";
+ }
+ if (napAddrType.equals("IPV4") && !isValidIPV4Format(parm)) {
+ return
+ " field 'gprs_access_point_name' contains invalid IPV4 format value: '" +
+ parm.val + "'\n";
+ }
+ return "";
+ }
+
+ //validate dns: optional, String, should be in IPV4 format
+ //(NAPDEF.NAP-ADDRESS)
+ public static String validateDNS(Value parm) {
+ if (!isValEmpty(parm)) {
+ if (!isValidIPV4Format(parm)) {
+ return
+ " field 'dns' contains invalid IPV4 format value: '" + parm.val +
+ "'\n";
+ }
+ }
+ return "";
+ }
+
+ //validate proxy: optional , String, should match proxy_addr_type
+ //(PXPHYSICAL.PXADDR)
+ public static String validateProxy(Value parm, String addrType) {
+ if (!isValEmpty(parm)) {
+ if (addrType.equals("IPV4") && !isValidIPV4Format(parm)) {
+ return
+ " field 'proxy' contains invalid IPV4 format value: '" + parm.val +
+ "'\n";
+ }
+ }
+ return "";
+ }
+
+ //validate proxy_addr_type: can be set only if field "proxy" is not empty ,
+ // String, can have only values from array Const.PXPHYSICAL_PXADDRTYPE
+ public static String validateProxyAddrType(Value parm, boolean isProxyEmpty) {
+ boolean isParmValEmpty = isValEmpty(parm);
+
+ if (isProxyEmpty && !isParmValEmpty) {
+ return
+ " field 'proxy_addr_type' can't have value if field proxy is empty\n";
+ }
+ if (!isParmValEmpty &&
+ !isElementValid(Const.PXPHYSICAL_PXADDRTYPE, parm.val)) {
+ return " field 'proxy_addr_type' contains invalid value'" + parm.val +
+ "'\n";
+ }
+ return "";
+ }
+
+//validate ServerPort for IM: is not empty, int, 0 - 65535 ===================================================
+ public static String validateIMServerPort(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'port' required and can't be empty\n";
+ }
+ if (!isIntValid(parm, 0, 65535)) {
+ return " field 'port' contains invalid value'" + parm.val + "'\n";
+ }
+ return "";
+ }
+
+//================================================================================================
+ //validate port: can be set only if field "proxy" is not empty, int, 0 - 65535
+ public static String validatePort(Value parm, boolean isProxyEmpty) {
+ boolean isParmValEmpty = isValEmpty(parm);
+
+ if (isProxyEmpty && !isParmValEmpty) {
+ return
+ " field 'port' can't have value if field proxy is empty\n";
+ }
+ if (!isParmValEmpty && !isIntValid(parm, 0, 65535)) {
+ return " field 'port' contains invalid value'" + parm.val +
+ "'\n";
+ }
+ return "";
+ }
+
+ //validate proxy_type: can be set only if field "proxy" is not empty ,
+ // String, can have only values from array Const.PORT_SERVICE
+ public static String validateProxyType(Value parm, boolean isProxyEmpty) {
+ boolean isParmValEmpty = isValEmpty(parm);
+
+ if (isProxyEmpty && !isParmValEmpty) {
+ return
+ " field 'proxy_type' can't have value if field proxy is empty\n";
+ }
+ if (!isParmValEmpty && !isElementValid(Const.PORT_SERVICE, parm.val)) {
+ return " field 'proxy_type' contains invalid value'" + parm.val +
+ "'\n";
+ }
+ return "";
+ }
+
+ //validate proxy_requires_auth: must set only if field "proxy" is not empty,
+ // int, can be 0 or 1
+ public static String validateProxyRequiresAuth(Value parm,
+ boolean isProxyEmpty) {
+ boolean isParmValEmpty = isValEmpty(parm);
+
+ if (isProxyEmpty && !isParmValEmpty) {
+ return
+ " field 'proxy_requires_auth' can't have value if field proxy is empty\n";
+ }
+ if (!isProxyEmpty && isParmValEmpty) {
+ return " field 'proxy_requires_auth' is required and cannot be empty if field proxy has been set\n";
+ }
+ if (!isProxyEmpty && !isIntValid(parm, 0, 1)) {
+ return " field 'proxy_requires_auth' must be integer 0 or 1\n";
+ }
+ return "";
+ }
+
+ //validate proxy_auth_type: required if field "proxy" is not empty and
+ //proxy_requires_auth=1, String, can have only values from
+ // array Const.PXAUTHINFO_PXAUTHTYPE
+ public static String validateProxyAuthType(Value parm, boolean isProxyEmpty,
+ String authReq) {
+ boolean isParmValEmpty = isValEmpty(parm);
+
+ if (isProxyEmpty && !isParmValEmpty) {
+ return
+ " field 'proxy_requires_auth' can't have value if field proxy is empty\n";
+ }
+ if (authReq.equals("0") && !isParmValEmpty) {
+ return
+ " field 'proxy_auth_type' can't have value if proxy_requires_auth=0\n";
+ }
+ if (authReq.equals("1") && isParmValEmpty) {
+ return
+ " field 'proxy_auth_type' can't be empty if proxy_requires_auth=1\n";
+ }
+
+ if (!isParmValEmpty &&
+ !isElementValid(Const.PXAUTHINFO_PXAUTHTYPE, parm.val)) {
+ return " field 'proxy_auth_type' contains invalid value'" + parm.val +
+ "'\n";
+ }
+ return "";
+ }
+
+ //validate proxy_auth_name: can be set only if proxy_requires_auth=1, String, max length 32 bytes
+ public static String validateProxyAuthName(Value parm, boolean isProxyEmpty,
+ String authReq) {
+ boolean isParmValEmpty = isValEmpty(parm);
+
+ if (isProxyEmpty && !isParmValEmpty) {
+ return
+ " field 'proxy_auth_name' can't have value if field proxy is empty\n";
+ }
+ if (authReq.equals("0") && !isParmValEmpty) {
+ return
+ " field 'proxy_auth_name' can't have value if proxy_requires_auth=0\n";
+ }
+ if (!isParmValEmpty && !checkMaxLength(parm, Const.USER_NAME_MAX_LENGTH)) {
+ return " field 'proxy_auth_name' exceed max length " +
+ Const.USER_NAME_MAX_LENGTH + "\n";
+ }
+ return "";
+ }
+
+ //validate proxy_auth_secret: can be set only if proxy_requires_auth=1, String, max length 32 bytes
+ public static String validateProxyAuthSecret(Value parm, boolean isProxyEmpty,
+ String authReq) {
+ boolean isParmValEmpty = isValEmpty(parm);
+ if (isProxyEmpty && !isParmValEmpty) {
+ return
+ " field 'proxy_auth_secret' can't have value if field proxy is empty\n";
+ }
+
+ if (authReq.equals("0") && !isParmValEmpty) {
+ return
+ " field 'proxy_auth_secret' can't have value if proxy_requires_auth=0\n";
+ }
+ if (!isParmValEmpty && !checkMaxLength(parm, Const.PASWORD_MAX_LENGTH)) {
+ return " field 'proxy_auth_secret' exceed max length " +
+ Const.PASWORD_MAX_LENGTH + "\n";
+ }
+ return "";
+ }
+
+ //validate mms_url: required for MMS settings only, String
+ public static String validateMMSUrl(Value parm) {
+ if (isValEmpty(parm)) {
+ return " field 'mms_url' is required and cannot be empty\n";
+ }
+ return "";
+ }
+
+ // set flag to avoid duplication NAP names before calling createXmlMessages()
+ // for IM. Also validate NAP names against other application settings.
+ public static void setNAPFlagForIMAndValidate() throws Exception {
+ String napId;
+ String err = "";
+ IM im;
+ Browser br;
+ MMS mms;
+ JavaApp java;
+
+ // Validate IspProfileName IM with id_name (service_name) for other settings
+ // Browser
+ for (int i = 0; i < Browser.arrBrowserFromLines.size(); i++) {
+ br = (Browser) Browser.arrBrowserFromLines.get(i);
+ napId = "NAP_" + br.id_name;
+ for (int j = 0; j < IM.arrIMFromLines.size(); j++) {
+ im = (IM) IM.arrIMFromLines.get(j);
+ if (im.IspProfileName.val.equals(napId) && br.mcc.val.equals(im.mcc.val) &&
+ br.mnc.val.equals(im.mnc.val) &&
+ br.operator_name.val.equals(im.operator_name.val) &&
+ br.account_type.val.equals(im.account_type.val)) {
+
+ err += "Browser with mcc=" + br.mcc + " mnc=" + br.mnc +
+ " operator_name=" + br.operator_name + " and IM with mcc=" +
+ im.mcc + " mnc=" + im.mnc + " operator_name=" + im.operator_name +
+ "\n";
+ }
+ }
+ }
+
+ //MMS
+ for (int i = 0; i < MMS.arrMMSFromLines.size(); i++) {
+ mms = (MMS) MMS.arrMMSFromLines.get(i);
+ napId = "NAP_" + mms.id_name;
+ for (int j = 0; j < IM.arrIMFromLines.size(); j++) {
+ im = (IM) IM.arrIMFromLines.get(j);
+ if (im.IspProfileName.val.equals(napId) &&
+ mms.mcc.val.equals(im.mcc.val) && mms.mnc.val.equals(im.mnc.val) &&
+ mms.operator_name.val.equals(im.operator_name.val) &&
+ mms.account_type.val.equals(im.account_type.val)) {
+
+ err += "MMS with mcc=" + mms.mcc + " mnc=" + mms.mnc +
+ " operator_name=" + mms.operator_name + " and IM with mcc=" +
+ im.mcc + " mnc=" + im.mnc + " operator_name=" + im.operator_name +
+ "\n";
+ }
+ }
+ }
+
+ //Java
+ for (int i = 0; i < JavaApp.arrJavaAppFromLines.size(); i++) {
+ java = (JavaApp) JavaApp.arrJavaAppFromLines.get(i);
+ napId = "NAP_" + java.id_name;
+ for (int j = 0; j < IM.arrIMFromLines.size(); j++) {
+ im = (IM) IM.arrIMFromLines.get(j);
+ if (im.IspProfileName.val.equals(napId) &&
+ java.mcc.val.equals(im.mcc.val) && java.mnc.val.equals(im.mnc.val) &&
+ java.operator_name.val.equals(im.operator_name.val) &&
+ java.account_type.val.equals(im.account_type.val)) {
+
+ err += "Java with mcc=" + java.mcc + " mnc=" + java.mnc +
+ " operator_name=" + java.operator_name + " and IM with mcc=" +
+ im.mcc + " mnc=" + im.mnc + " operator_name=" + im.operator_name +
+ "\n";
+ }
+ }
+ }
+
+ if (err.length() > 0) {
+ err =
+ "Field 'IspProfileName' from IM settings conflicts with 'service_name' for:\n" +
+ err;
+ throw new Exception(err);
+ }
+
+ //set flag to avoid duplication NAP names for IM. checking all gprs (NAP) setting for
+ //the same combin. key and IspProfileName.
+ ArrayList arrTmpIM = new ArrayList();
+ TreeMap map = new TreeMap();
+
+ for (int i = 0; i < IM.arrIMFromLines.size(); i++) {
+ IM imTmp = (IM) IM.arrIMFromLines.get(i);
+ for (int j = 0; j < arrTmpIM.size(); j++) {
+ im = (IM) arrTmpIM.get(j);
+ //check if match found
+ if (imTmp.mcc.val.equals(im.mcc.val) && imTmp.mnc.val.equals(im.mnc.val) &&
+ imTmp.operator_name.val.equals(im.operator_name.val) &&
+ imTmp.account_type.val.equals(im.account_type.val) &&
+ imTmp.IspProfileName.val.equals(im.IspProfileName.val)) {
+ //check NAP settings for match
+ if (imTmp.gprs_access_point_name.val.equals(im.gprs_access_point_name.
+ val) &&
+ imTmp.ap_requires_auth.val.equals(im.ap_requires_auth.val) &&
+ imTmp.ppp_auth_type.val.equals(im.ppp_auth_type.val) &&
+ imTmp.ppp_auth_name.val.equals(im.ppp_auth_name.val) &&
+ imTmp.ppp_auth_secret.val.equals(im.ppp_auth_secret.val) &&
+ imTmp.nap_addr_type.val.equals(im.nap_addr_type.val) &&
+ imTmp.bearer.val.equals(im.bearer.val)) {
+ // match found with the same NAP settings.
+ ( (IM) IM.arrIMFromLines.get(i)).generateNAPXmlReq = false;
+ }
+ else {
+ throw new Exception("IM dataset(s) are incorrect in the lines " +
+ im.mcc.pos + " and " + imTmp.mcc.pos +
+ ": \nGPRS (NAP) use the same name (field 'IspProfileName') with different settings.\n");
+
+ } //end check NAP settings for match
+ } //end match found
+
+ }
+ arrTmpIM.add(imTmp);
+ }
+ }
+
+//////////////////////// General /////////////////////
+ public static boolean isValEmpty(Value parm) {
+ return (parm == null || parm.val.trim().equals("")) ? true : false;
+ }
+
+ public static boolean isIntValid(Value parm, int minPossible, int maxPossible) {
+ try {
+ int i = Integer.parseInt(parm.val);
+ if (minPossible > -1 && i < minPossible) {
+ return false;
+ }
+ if (maxPossible > -1 && i > maxPossible) {
+ return false;
+ }
+ }
+ catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean checkMaxLength(Value parm, int maxLen) {
+ if (parm.val.getBytes().length > maxLen) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean isElementValid(String[] arr, String element) {
+ for (int i = 0; i < arr.length; i++) {
+ if (arr[i].equals(element)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean isValidIPV4Format(Value parm) {
+ StringTokenizer st = new StringTokenizer(parm.val, ".");
+ Value tmp;
+ if (st.countTokens() > 4) {
+ return false;
+ }
+ while (st.hasMoreTokens()) {
+ tmp = new Value(Util.str(st.nextToken()));
+ if (!isIntValid(tmp, 0, 255)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Value.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Value.java
new file mode 100644
index 0000000..acd3a33
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Value.java
@@ -0,0 +1,29 @@
+package com.mot.dm.dbtool;
+
+public class Value {
+ public String val;
+ public int pos;
+
+ public Value(){
+ val = null;
+ pos = -1;
+ }
+
+ public Value(String val){
+ this.val = val;
+ }
+
+ public Value(int pos){
+ this.pos = pos;
+ }
+
+ public Value(String val, int pos){
+ this.val = val;
+ this.pos = pos;
+ }
+
+ public String toString(){
+ return val;
+ }
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/WbxmlEncoder.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/WbxmlEncoder.java
new file mode 100644
index 0000000..f3ae485
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/WbxmlEncoder.java
@@ -0,0 +1,177 @@
+package com.mot.dm.dbtool;
+
+import java.io.*;
+import java.util.*;
+
+import javax.xml.parsers.*;
+import org.w3c.dom.*;
+import org.xml.sax.InputSource;
+
+public class WbxmlEncoder {
+
+ public int currentTab = 0x00;
+ public ArrayList arrBytes = new ArrayList();
+
+ public WbxmlEncoder() {
+ arrBytes.add(new Byte( (byte) 0x03));
+ arrBytes.add(new Byte( (byte) 0x0b));
+ arrBytes.add(new Byte( (byte) 0x6a));
+ arrBytes.add(new Byte( (byte) 0x00));
+ }
+
+ public byte[] encode(File fileXml) throws Exception {
+ FileInputStream streamer = new FileInputStream(fileXml);
+ byte[] byteArray = new byte[streamer.available()];
+ streamer.read(byteArray);
+ streamer.close();
+ streamer=null;
+ return encode(new String(byteArray));
+ }
+
+ public byte[] encode(String xml) throws Exception {
+ NodeList list;
+ Document document = getDocument("<root>\n" + xml + "\n</root>");
+ list = document.getDocumentElement().getChildNodes();
+
+ for (int i = 0; i < list.getLength(); i++) {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ proceedNode(node);
+ }
+ }
+ return listToByteArr();
+ }
+
+ public void proceedNode(Node node) throws Exception {
+ String nodeName = node.getNodeName();
+ NamedNodeMap attributes = node.getAttributes();
+ NodeList list = node.getChildNodes();
+
+ // proceed tag.
+ proceedTag(nodeName, node.hasAttributes(), node.hasChildNodes());
+
+ //proceed all attributes
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Node attribute = attributes.item(i);
+ proceedAttribute(attribute.getNodeName(), attribute.getNodeValue());
+ }
+ // close tag after all attributes if required...
+ if (node.hasAttributes()) {
+ arrBytes.add(new Byte( (byte) 0x01));
+ }
+
+ //procced all children
+ Node n;
+ for (int i = 0; i < list.getLength(); i++) {
+ n = list.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE) {
+ proceedNode(list.item(i));
+ }
+ }
+ // close tag after all childrens if required...
+ if (node.hasChildNodes()) {
+ arrBytes.add(new Byte( (byte) 0x01));
+ }
+ }
+
+ public void proceedTag(String nodeName, boolean hasAttrs, boolean hasChildren) throws
+ Exception {
+ int shift = 0;
+ if (hasAttrs) {
+ shift = shift | 0x80;
+ }
+ if (hasChildren) {
+ shift = shift | 0x40;
+ }
+ ValTab tag = OMACP.encodeTag(nodeName, shift);
+ if (tag.encVal == null) {
+ throw new Exception(" Error: Unsupported tag '" + nodeName +
+ "' has been used.");
+ }
+ // check for table
+ checkTablesSetting(tag);
+ //add encoded tag
+ arrBytes.add(tag.encVal);
+ }
+
+ public void proceedAttribute(String attrName, String attrValue) throws
+ Exception {
+
+ //get encoded "attribute=value" if exists
+ ValTab attrVal = OMACP.encodeAttr(attrName + "=" + attrValue);
+ if (attrVal.encVal != null) {
+ checkTablesSetting(attrVal);
+ //add encoded attribute and value
+ arrBytes.add(attrVal.encVal);
+ return;
+ }
+
+ //get encoded attribute
+ ValTab attrN = OMACP.encodeAttr(attrName);
+ if (attrN.encVal == null) {
+ throw new Exception(" Error: Unsupported attribute '" + attrName +
+ "' has been used.");
+ }
+ checkTablesSetting(attrN);
+ arrBytes.add(attrN.encVal);
+
+ //get encoded value if exists
+ ValTab attrV = OMACP.encodeVal(attrValue);
+ if (attrV.encVal != null) {
+ checkTablesSetting(attrV);
+ arrBytes.add(attrV.encVal);
+ return;
+ }
+ else {
+ // add string value
+ arrBytes.add(new Byte( (byte) 0x03));
+ //convert string to bytes
+ byte[] b = attrValue.getBytes();
+ for (int i = 0; i < b.length; i++) {
+ arrBytes.add(new Byte(b[i]));
+ }
+ //end string
+ arrBytes.add(new Byte( (byte) 0x00));
+ }
+
+ }
+
+ public void checkTablesSetting(ValTab tag) {
+ if (tag.table != currentTab) {
+ arrBytes.add(new Byte( (byte) 0x00));
+ arrBytes.add(new Byte( (byte) tag.table));
+ currentTab = tag.table;
+ }
+ }
+
+ private Document getDocument(String xml) throws Exception {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ byte[] utf8_bytes = xml.getBytes("UTF-8");
+ return factory.newDocumentBuilder().parse(new InputSource(new
+ ByteArrayInputStream(utf8_bytes)));
+ }
+
+ public byte[] listToByteArr() {
+ Byte b;
+ byte[] wbxml = new byte[arrBytes.size()];
+ for (int i = 0; i < arrBytes.size(); i++) {
+ b = (Byte) arrBytes.get(i);
+ wbxml[i] = b.byteValue();
+ }
+ return wbxml;
+ }
+
+ public static void main(String[] args) throws Exception {
+ FileInputStream fs = new FileInputStream("WAP.xml");
+ byte[] arr = new byte[fs.available()];
+ fs.read(arr);
+ String s = new String(arr);
+
+ WbxmlEncoder encoder = new WbxmlEncoder();
+ byte[] wbxml = encoder.encode(s);
+ FileOutputStream fos = new FileOutputStream("WAP.wbxml");
+ fos.write(wbxml);
+ fos.flush();
+ }
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Worker.java b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Worker.java
new file mode 100644
index 0000000..9427d8b
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/com/mot/dm/dbtool/Worker.java
@@ -0,0 +1,901 @@
+package com.mot.dm.dbtool;
+
+import java.util.*;
+
+public class Worker {
+ public static String validateAndCreateMMSs(ArrayList arrMMSLines) throws
+ Exception {
+ String err = "";
+ String line;
+ String[] result_str;
+ int colIndex;
+ //set array with headers
+ if (arrMMSLines.size() > 0) {
+ line = (String) arrMMSLines.get(0); // get headers
+ line += ",dummy"; //for supporting method split.
+ result_str = line.split(",");
+ MMS.colsNum = result_str.length;
+ for (int i = 0; i < result_str.length; i++) {
+ MMS.arrMMSLineHeaders.add(result_str[i]);
+ }
+ }
+
+ for (int i = 1; i < arrMMSLines.size(); i++) { //start from 1 to skip header
+ line = (String) arrMMSLines.get(i);
+ if ( (Util.str(line)).length() == 0) {
+ continue;
+ }
+ line += ",dummy"; //for supporting method split.
+ result_str = line.split(",");
+ Value[] result = Util.attStrToArrValue(result_str);
+
+ //checlk for length
+ if (result.length != MMS.colsNum) {
+ err += "MMS, line#" + (i + 1) + ": The number of tokens should be " +
+ MMS.colsNum + "\n";
+ continue;
+ }
+ MMS mms = new MMS();
+ colIndex = MMS.arrMMSLineHeaders.indexOf("mcc");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'mcc' is missing in the MMS file");
+ }
+ mms.mcc = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("mnc");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'mnc' is missing in the MMS file");
+ }
+ mms.mnc = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("operator_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'operator_name' is missing in the MMS file");
+ }
+ mms.operator_name = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("country_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'country_name' is missing in the MMS file");
+ }
+ mms.country_name = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("ppp_auth_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_type' is missing in the MMS file");
+ }
+ mms.ppp_auth_type = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("ppp_auth_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_name' is missing in the MMS file");
+ }
+ mms.ppp_auth_name = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("ppp_auth_secret");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_secret' is missing in the MMS file");
+ }
+ mms.ppp_auth_secret = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("ap_requires_auth");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ap_requires_auth' is missing in the MMS file");
+ }
+ mms.ap_requires_auth = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("service_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'service_name' is missing in the MMS file");
+ }
+ mms.service_name = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("gprs_access_point_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'gprs_access_point_name' is missing in the MMS file");
+ }
+ mms.gprs_access_point_name = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("dns_1");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'dns_1' is missing in the MMS file");
+ }
+ mms.dns_1 = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("dns_2");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'dns_2' is missing in the MMS file");
+ }
+ mms.dns_2 = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("proxy");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'proxy' is missing in the MMS file");
+ }
+ mms.proxy = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("port");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'port' is missing in the MMS file");
+ }
+ mms.port = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("proxy_auth_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_auth_name' is missing in the MMS file");
+ }
+ mms.proxy_auth_name = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("proxy_auth_secret");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_auth_secret' is missing in the MMS file");
+ }
+ mms.proxy_auth_secret = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("proxy_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_type' is missing in the MMS file");
+ }
+ mms.proxy_type = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("proxy_requires_auth");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_requires_auth' is missing in the MMS file");
+ }
+ mms.proxy_requires_auth = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("mms_url");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'mms_url' is missing in the MMS file");
+ }
+ mms.mms_url = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("account_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'account_type' is missing in the MMS file");
+ }
+ mms.account_type = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("bearer");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'bearer' is missing in the MMS file");
+ }
+ mms.bearer = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("proxy_auth_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_auth_type' is missing in the MMS file");
+ }
+ mms.proxy_auth_type = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("proxy_addr_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_addr_type' is missing in the MMS file");
+ }
+ mms.proxy_addr_type = result[colIndex];
+
+ colIndex = MMS.arrMMSLineHeaders.indexOf("nap_addr_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'nap_addr_type' is missing in the MMS file");
+ }
+ mms.nap_addr_type = result[colIndex];
+
+ //validate all data
+ String lineErr = mms.validateData();
+ if (lineErr.length() > 0) {
+ err += "MMS, data not valid, line #" + (i + 1) +
+ ": \n" + lineErr + "\n";
+ }
+ MMS.arrMMSFromLines.add(mms);
+ }
+ return err;
+ }
+
+ public static String validateAndCreateBrowsers(ArrayList arrBrowserLines) throws
+ Exception {
+ String err = "";
+ String line;
+ String[] result_str;
+ int colIndex;
+ //set array with headers
+ if (arrBrowserLines.size() > 0) {
+ line = (String) arrBrowserLines.get(0); // get headers
+ line += ",dummy"; //for supporting method split.
+ result_str = line.split(",");
+ Browser.colsNum = result_str.length;
+ for (int i = 0; i < result_str.length; i++) {
+ Browser.arrBrowserLineHeaders.add(result_str[i]);
+ }
+ }
+
+ for (int i = 1; i < arrBrowserLines.size(); i++) { //start from 1 to skip header
+ line = (String) arrBrowserLines.get(i);
+ if ( (Util.str(line)).length() == 0) {
+ continue;
+ }
+ line += ",dummy"; //for supporting method split.
+ result_str = line.split(",");
+ Value[] result = Util.attStrToArrValue(result_str);
+
+ //checlk for length
+ if (result.length != Browser.colsNum) {
+ err += "Browser, line#" + (i + 1) +
+ ": The number of tokens should be " + Browser.colsNum + "\n";
+ continue;
+ }
+
+ Browser browser = new Browser();
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("mcc");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'mcc' is missing in the Browser file");
+ }
+ browser.mcc = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("mnc");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'mnc' is missing in the Browser file");
+ }
+ browser.mnc = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("operator_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'operator_name' is missing in the Browser file");
+ }
+ browser.operator_name = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("country_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'country_name' is missing in the Browser file");
+ }
+ browser.country_name = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("ppp_auth_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_type' is missing in the Browser file");
+ }
+ browser.ppp_auth_type = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("ppp_auth_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_name' is missing in the Browser file");
+ }
+ browser.ppp_auth_name = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("ppp_auth_secret");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_secret' is missing in the Browser file");
+ }
+ browser.ppp_auth_secret = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("ap_requires_auth");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ap_requires_auth' is missing in the Browser file");
+ }
+ browser.ap_requires_auth = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("service_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'service_name' is missing in the Browser file");
+ }
+ browser.service_name = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("gprs_access_point_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'gprs_access_point_name' is missing in the Browser file");
+ }
+ browser.gprs_access_point_name = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("dns_1");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'dns_1' is missing in the Browser file");
+ }
+ browser.dns_1 = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("dns_2");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'dns_2' is missing in the Browser file");
+ }
+ browser.dns_2 = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("homepage_url");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'homepage_url' is missing in the Browser file");
+ }
+ browser.homepage_url = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("proxy");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'proxy' is missing in the Browser file");
+ }
+ browser.proxy = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("port");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'port' is missing in the Browser file");
+ }
+ browser.port = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("proxy_auth_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_auth_name' is missing in the Browser file");
+ }
+ browser.proxy_auth_name = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("proxy_auth_secret");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_auth_secret' is missing in the Browser file");
+ }
+ browser.proxy_auth_secret = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("proxy_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_type' is missing in the Browser file");
+ }
+ browser.proxy_type = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("proxy_requires_auth");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_requires_auth' is missing in the Browser file");
+ }
+ browser.proxy_requires_auth = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("account_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'account_type' is missing in the Browser file");
+ }
+ browser.account_type = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("bearer");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'bearer' is missing in the Browser file");
+ }
+ browser.bearer = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("proxy_auth_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_auth_type' is missing in the Browser file");
+ }
+ browser.proxy_auth_type = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("proxy_addr_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_addr_type' is missing in the Browser file");
+ }
+ browser.proxy_addr_type = result[colIndex];
+
+ colIndex = Browser.arrBrowserLineHeaders.indexOf("nap_addr_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'nap_addr_type' is missing in the Browser file");
+ }
+ browser.nap_addr_type = result[colIndex];
+
+ //validate all data
+ String lineErr = browser.validateData();
+ if (lineErr.length() > 0) {
+ err += "Browser, data not valid, line #" + (i + 1) +
+ ": \n" + lineErr + "\n";
+ }
+ Browser.arrBrowserFromLines.add(browser);
+ }
+ return err;
+ }
+
+ public static String validateAndCreateJavaApps(ArrayList arrJavaAppLines) throws
+ Exception {
+ String err = "";
+ String line;
+ String[] result_str;
+ int colIndex;
+ //set array with headers
+ if (arrJavaAppLines.size() > 0) {
+ line = (String) arrJavaAppLines.get(0); // get headers
+ line += ",dummy"; //for supporting method split.
+ result_str = line.split(",");
+ JavaApp.colsNum = result_str.length;
+ for (int i = 0; i < result_str.length; i++) {
+ JavaApp.arrJavaAppLineHeaders.add(result_str[i]);
+ }
+ }
+
+ for (int i = 1; i < arrJavaAppLines.size(); i++) { //start from 1 to skip header
+ line = (String) arrJavaAppLines.get(i);
+ if ( (Util.str(line)).length() == 0) {
+ continue;
+ }
+ line += ",dummy"; //for supporting method split.
+ result_str = line.split(",");
+ Value[] result = Util.attStrToArrValue(result_str);
+
+ //checlk for length
+ if (result.length != JavaApp.colsNum) {
+ err += "JavaApp, line#" + (i + 1) +
+ ": The number of tokens should be " + JavaApp.colsNum + "\n";
+ continue;
+ }
+
+ JavaApp javaApp = new JavaApp();
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("mcc");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'mcc' is missing in the JavaApp file");
+ }
+ javaApp.mcc = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("mnc");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'mnc' is missing in the JavaApp file");
+ }
+ javaApp.mnc = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("operator_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'operator_name' is missing in the JavaApp file");
+ }
+ javaApp.operator_name = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("account_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'account_type' is missing in the JavaApp file");
+ }
+ javaApp.account_type = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("country_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'country_name' is missing in the JavaApp file");
+ }
+ javaApp.country_name = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("ppp_auth_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_type' is missing in the JavaApp file");
+ }
+ javaApp.ppp_auth_type = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("ppp_auth_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_name' is missing in the JavaApp file");
+ }
+ javaApp.ppp_auth_name = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("ppp_auth_secret");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_secret' is missing in the JavaApp file");
+ }
+ javaApp.ppp_auth_secret = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("ap_requires_auth");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ap_requires_auth' is missing in the JavaApp file");
+ }
+ javaApp.ap_requires_auth = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("service_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'service_name' is missing in the JavaApp file");
+ }
+ javaApp.service_name = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("gprs_access_point_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'gprs_access_point_name' is missing in the JavaApp file");
+ }
+ javaApp.gprs_access_point_name = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("dns_1");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'dns_1' is missing in the JavaApp file");
+ }
+ javaApp.dns_1 = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("dns_2");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'dns_2' is missing in the JavaApp file");
+ }
+ javaApp.dns_2 = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("nap_addr_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'nap_addr_type' is missing in the JavaApp file");
+ }
+ javaApp.nap_addr_type = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("bearer");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'bearer' is missing in the JavaApp file");
+ }
+ javaApp.bearer = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("proxy");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'proxy' is missing in the Java file");
+ }
+ javaApp.proxy = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("proxy_addr_type");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'proxy_addr_type' is missing in the Java file");
+ }
+ javaApp.proxy_addr_type = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("port");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'port' is missing in the Java file");
+ }
+ javaApp.port = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("proxy_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_type' is missing in the Java file");
+ }
+ javaApp.proxy_type = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("proxy_requires_auth");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_requires_auth' is missing in the Java file");
+ }
+ javaApp.proxy_requires_auth = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("proxy_auth_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_auth_name' is missing in the Java file");
+ }
+ javaApp.proxy_auth_name = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("proxy_auth_secret");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_auth_secret' is missing in the Java file");
+ }
+ javaApp.proxy_auth_secret = result[colIndex];
+
+ colIndex = JavaApp.arrJavaAppLineHeaders.indexOf("proxy_auth_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'proxy_auth_type' is missing in the Java file");
+ }
+ javaApp.proxy_auth_type = result[colIndex];
+
+ //validate all data
+ String lineErr = javaApp.validateData();
+ if (lineErr.length() > 0) {
+ err += "JavaApp, data not valid, line #" + (i + 1) +
+ ": \n" + lineErr + "\n";
+ }
+ JavaApp.arrJavaAppFromLines.add(javaApp);
+ }
+ return err;
+ }
+
+ public static String validateAndCreateIMs(ArrayList arrIMLines) throws
+ Exception {
+ String err = "";
+ String line;
+ String[] result_str;
+ int colIndex;
+ //set array with headers
+ if (arrIMLines.size() > 0) {
+ line = (String) arrIMLines.get(0); // get headers
+ line += ",dummy"; //for supporting method split.
+ result_str = line.split(",");
+ IM.colsNum = result_str.length;
+ for (int i = 0; i < result_str.length; i++) {
+ IM.arrIMLineHeaders.add(result_str[i]);
+ }
+ }
+
+ for (int i = 1; i < arrIMLines.size(); i++) { //start from 1 to skip header
+ line = (String) arrIMLines.get(i);
+ if ( (Util.str(line)).length() == 0) {
+ continue;
+ }
+ line += ",dummy"; //for supporting method split.
+ result_str = line.split(",");
+ Value[] result = Util.attStrToArrValue(result_str);
+
+ //checlk for length
+ if (result.length != IM.colsNum) {
+ err += "IM, line#" + (i + 1) +
+ ": The number of tokens should be " + IM.colsNum + "\n";
+ continue;
+ }
+
+ IM im = new IM();
+
+ colIndex = IM.arrIMLineHeaders.indexOf("mcc");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'mcc' is missing in the IM file");
+ }
+ im.mcc = result[colIndex];
+ im.mcc.pos = i+1;
+
+ colIndex = IM.arrIMLineHeaders.indexOf("mnc");
+ if (colIndex == -1) {
+ throw new Exception("The colomn 'mnc' is missing in the IM file");
+ }
+ im.mnc = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("operator_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'operator_name' is missing in the IM file");
+ }
+ im.operator_name = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("account_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'account_type' is missing in the IM file");
+ }
+ im.account_type = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("country_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'country_name' is missing in the IM file");
+ }
+ im.country_name = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("Brand_instance_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'Brand_instance_name' is missing in the IM file");
+ }
+ im.Brand_instance_name = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("IspProfileName");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'IspProfileName' is missing in the IM file");
+ }
+ im.IspProfileName = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("gprs_access_point_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'gprs_access_point_name' is missing in the IM file");
+ }
+ im.gprs_access_point_name = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ap_requires_auth");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ap_requires_auth' is missing in the IM file");
+ }
+ im.ap_requires_auth = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ppp_auth_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_type' is missing in the IM file");
+ }
+ im.ppp_auth_type = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ppp_auth_name");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_name' is missing in the IM file");
+ }
+ im.ppp_auth_name = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ppp_auth_secret");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ppp_auth_secret' is missing in the IM file");
+ }
+ im.ppp_auth_secret = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("nap_addr_type");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'nap_addr_type' is missing in the IM file");
+ }
+ im.nap_addr_type = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("bearer");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'bearer' is missing in the IM file");
+ }
+ im.bearer = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerAddr");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerAddr' is missing in the IM file");
+ }
+ im.ServerAddr = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerPort");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerPort' is missing in the IM file");
+ }
+ im.ServerPort = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ClientID");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ClientID' is missing in the IM file");
+ }
+ im.ClientID = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("PrivateKey1");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'PrivateKey1' is missing in the IM file");
+ }
+ im.PrivateKey1 = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("PrivateKey2");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'PrivateKey2' is missing in the IM file");
+ }
+ im.PrivateKey2 = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerPostURL");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerPostURL' is missing in the IM file");
+ }
+ im.ServerPostURL = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("LoginAutoResetConversation");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'LoginAutoResetConversation' is missing in the IM file");
+ }
+ im.LoginAutoResetConversation = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerCirSupported");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerCirSupported' is missing in the IM file");
+ }
+ im.ServerCirSupported = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerLoginMethod");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerLoginMethod' is missing in the IM file");
+ }
+ im.ServerLoginMethod = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerProxyAddress");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerProxyAddress' is missing in the IM file");
+ }
+ im.ServerProxyAddress = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerProxyPassword");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerProxyPassword' is missing in the IM file");
+ }
+ im.ServerProxyPassword = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerProxyUserName");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerProxyUserName' is missing in the IM file");
+ }
+ im.ServerProxyUserName = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerTransportType");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerTransportType' is missing in the IM file");
+ }
+ im.ServerTransportType = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerSMSDestinationAddress");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerSMSDestinationAddress' is missing in the IM file");
+ }
+ im.ServerSMSDestinationAddress = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServSMSCirSup");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServSMSCirSup' is missing in the IM file");
+ }
+ im.ServSMSCirSup = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("SvTCPCIRKeepTim");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'SvTCPCIRKeepTim' is missing in the IM file");
+ }
+ im.SvTCPCIRKeepTim = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("SvTCPCIRSup");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'SvTCPCIRSup' is missing in the IM file");
+ }
+ im.SvTCPCIRSup = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("ServerCloseSocketAfterResponse");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'ServerCloseSocketAfterResponse' is missing in the IM file");
+ }
+ im.ServerCloseSocketAfterResponse = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("AutoRefreshContactList");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'AutoRefreshContactList' is missing in the IM file");
+ }
+ im.AutoRefreshContactList = result[colIndex];
+
+ colIndex = IM.arrIMLineHeaders.indexOf("FrbdUnauthoMsgs");
+ if (colIndex == -1) {
+ throw new Exception(
+ "The colomn 'FrbdUnauthoMsgs' is missing in the IM file");
+ }
+ im.FrbdUnauthoMsgs = result[colIndex];
+
+ //validate all data
+ String lineErr = im.validateData();
+ if (lineErr.length() > 0) {
+ err += "IM, data not valid, line #" + (i + 1) +
+ ": \n" + lineErr + "\n";
+ }
+ IM.arrIMFromLines.add(im);
+ }
+ return err;
+ }
+
+}
diff --git a/engine/dmlib/tool-src/db_wizard_tool/compileDBProvTool b/engine/dmlib/tool-src/db_wizard_tool/compileDBProvTool
new file mode 100644
index 0000000..826ecc9
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/compileDBProvTool
@@ -0,0 +1,42 @@
+
+
+
+# Check environment variable JAVA_HOME
+if [ -z "$JAVA_HOME" ]
+then
+ echo "Error: Environment variable JAVA_HOME must be set to jdk 1.4 and latest!"
+ exit 1
+fi
+
+JAVA_VERSION=`$JAVA_HOME/bin/java -version 2> /dev/stdout | grep ver | sed -e 's/.*\"\([1-9]\.[0-9][0-9]*\)\..*/\1/'`
+if [ "$JAVA_VERSION" \< "1.4" ]
+then
+ echo "Error: Java vesion is not correct"
+ echo "The tool supports java version from 1.4 and latest"
+ echo "Please set environment variable JAVA_HOME to the correct java version"
+ exit 1
+fi
+
+
+echo JAVA_HOME=$JAVA_HOME
+
+$JAVA_HOME/bin/javac com/mot/dm/dbtool/*.java
+
+echo Please check compilation result
+echo press Enter if OK or Ctrl+C
+read $dummy
+
+
+echo Creating jar ...
+
+$JAVA_HOME/bin/jar cvf DBProvTool.jar com/mot/dm/dbtool/*.class
+
+echo Removing classes ...
+
+rm -f com/mot/dm/dbtool/*.class
+
+
+#mv "$WORKING_DIR"/DBProvTool.jar lib
+
+echo done
+
diff --git a/engine/dmlib/tool-src/db_wizard_tool/generateDBProv b/engine/dmlib/tool-src/db_wizard_tool/generateDBProv
new file mode 100644
index 0000000..17ae990
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/generateDBProv
@@ -0,0 +1,114 @@
+#!/bin/bash
+
+#====================================================================================================
+#
+# Script Name: generateDBProv
+#
+# General Description: Generate Provisioning Database wizard.
+#
+#====================================================================================================
+#
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#====================================================================================================
+
+usage () {
+ echo ""
+ echo "========================================================================================="
+ echo ""
+ echo " This tool accepts sources in the .csv or .txt formats. These two formats"
+ echo " cannot be mixed together. At least one source file is required."
+ echo ""
+ echo " Usage of the version: "
+ echo ""
+ echo " generateDBProv [-mms <path>/mms.csv]"
+ echo " [-browser <path>/browser.csv]"
+ echo " [-java <path>/java.csv]"
+ echo " [-im <path>/im.csv]"
+ echo " [-debug]"
+ echo " [-nozip]"
+ echo ""
+ echo " -- or --"
+ echo ""
+ echo " generateDBProv [-mms <path>/mms.txt]"
+ echo " [-browser <path>/browser.txt]"
+ echo " [-java <path>/java.txt]"
+ echo " [-im <path>/im.txt]"
+ echo " [-debug]"
+ echo " [-nozip]"
+ echo ""
+ echo " Where options are including:"
+ echo ""
+ echo " -mms <path>/mms.* - path to the file with settings for the MMS"
+ echo " -browser <path>/browser.* - path to the file with settings for the Browser"
+ echo " -java <path>/java .* - path to the file with settings for the Java"
+ echo " -im <path>/im.* - path to the file with settings for the IM"
+ echo " -debug - do not remove temporary .xml, .wbxml and .zip files"
+ echo " -nozip - do not zip wbxml settings"
+ echo ""
+ echo ""
+ echo " For dumping DB: "
+ echo ""
+ echo " generateDBProv -dump <path>/lj_dmwizard.dat"
+ echo ""
+ echo "=========================================================================================="
+ echo ""
+}
+
+export LANG=en_US
+export LANGVAR=en_US
+unset LC_ALL
+export LC_CTYPE="en_US.UTF-8"
+
+if [ -z "$JAVA_HOME" ]
+then
+ echo "Error: Environment variable JAVA_HOME must be set to jdk 1.4 and latest!"
+ exit 1
+fi
+
+JAVA_VERSION=`$JAVA_HOME/bin/java -version 2> /dev/stdout | grep ver | sed -e 's/.*\"\([1-9]\.[0-9][0-9]*\)\..*/\1/'`
+if [ "$JAVA_VERSION" \< "1.4" ]
+then
+ echo "Error: Java vesion is not correct"
+ echo "The tool supports java version from 1.4 and latest"
+ echo "Please set environment variable JAVA_HOME to the correct java version"
+ exit 1
+fi
+
+# validate parameters
+if [ "$#" -eq 0 ]
+then
+ echo ""
+ echo "Error! Required parameters are missing!!!"
+ echo "Use flag --help for the help"
+ echo ""
+ exit 1
+fi
+
+PARMS=""
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --help ) usage
+ exit 1
+ shift ;;
+ * ) PARMS="$PARMS $1"
+ shift ;;
+ esac
+done
+
+$JAVA_HOME/bin/java -classpath lib/DBProvTool.jar com.mot.dm.dbtool.Generator $PARMS
+
+
diff --git a/engine/dmlib/tool-src/db_wizard_tool/lib/DBProvTool.jar b/engine/dmlib/tool-src/db_wizard_tool/lib/DBProvTool.jar
new file mode 100644
index 0000000..0dd678c
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/lib/DBProvTool.jar
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/BROWSER.xml b/engine/dmlib/tool-src/db_wizard_tool/samples/BROWSER.xml
new file mode 100644
index 0000000..0fa0003
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/BROWSER.xml
@@ -0,0 +1,57 @@
+
+<wap-provisioningdoc version="1.1">
+
+ <characteristic type="APPLICATION" >
+ <parm name="APPID" value="w2" ></parm>
+ <parm name="NAME" value="VH_WAP" ></parm>
+ <parm name="TO-PROXY" value="100.100.100.100"></parm>
+
+ <characteristic type="RESOURCE">
+ <parm name="URI" value="http://www.VH_WAP.com/startpage.wml"/>
+ <parm name="NAME" value="VH_WAP"/>
+ <parm name="STARTPAGE" value="http://www.VH_WAP.com/startpage.wml"/>
+ </characteristic>
+
+ </characteristic>
+
+ <characteristic type="PXLOGICAL" >
+ <parm name="PROXY-ID" value="100.100.100.100" ></parm>
+ <parm name="NAME" value="VH_WAP_Proxy_Name" ></parm>
+
+ <characteristic type="PXPHYSICAL" >
+ <parm name="PHYSICAL-PROXY-ID" value="VH_WAP_PxPhys" ></parm>
+ <parm name="PXADDR" value="100.100.100.100" ></parm>
+ <parm name="PXADDRTYPE" value="IPV4"></parm>
+ <parm name="TO-NAPID" value="VH_WAP_NAP" ></parm>
+
+ <characteristic type="PORT" >
+ <parm name="PORTNBR" value="9999"></parm>
+ <parm name="SERVICE" value="CO-WSP"></parm>
+ </characteristic>
+ </characteristic>
+
+ <characteristic type="PXAUTHINFO">
+ <parm name="PXAUTH-TYPE" value="HTTP-BASIC"/>
+ <parm name="PXAUTH-ID" value="VH_WAP_PXUID"/>
+ <parm name="PXAUTH-PW" value="VH_WAP_PXPWD"/>
+ </characteristic>
+
+ </characteristic>
+
+ <characteristic type="NAPDEF" >
+ <parm name="NAPID" value="VH_WAP_NAP" ></parm>
+ <parm name="NAME" value="VH_WAP_NAP" ></parm>
+ <parm name="BEARER" value="GSM-GPRS" ></parm>
+ <parm name="NAP-ADDRESS" value="204.204.204.3"></parm>
+ <parm name="DNS-ADDR" value="203.203.203.203" ></parm>
+ <parm name="DNS-ADDR" value="204.204.204.204" ></parm>
+ <parm name="NAP-ADDRTYPE" value="IPv4">
+
+ <characteristic type="NAPAUTHINFO" >
+ <parm name="AUTHTYPE" value="PAP" ></parm>
+ <parm name="AUTHNAME" value="VH_WAP_NAPUID" ></parm>
+ <parm name="AUTHSECRET" value="VH_WAP_NAPPWD" ></parm>
+ </characteristic>
+ </characteristic>
+
+</wap-provisioningdoc>
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/IM.xml b/engine/dmlib/tool-src/db_wizard_tool/samples/IM.xml
new file mode 100644
index 0000000..0578206
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/IM.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0"?>
+<!DOCTYPE wap-provisioningdoc PUBLIC "-//WAPFORUM//DTD PROV 1.0//EN" "http://www.wapforum.org/DTD/prov.dtd">
+<wap-provisioningdoc version="1.0">
+ <characteristic type="NAPDEF">
+ <parm name="NAPID" value="IM_NAP_PRE1"></parm>
+ <parm name="NAME" value="IM_NAP_PRE1"></parm>
+ <parm name="BEARER" value="GSM-GPRS"></parm>
+ <parm name="NAP-ADDRESS" value="wap.cingular"></parm>
+ <parm name="NAP-ADDRTYPE" value="APN"></parm>
+ <characteristic type="NAPAUTHINFO">
+ <parm name="AUTHTYPE" value="PAP"></parm>
+ <parm name="AUTHNAME" value="wap"></parm>
+ <parm name="AUTHSECRET" value="wap"></parm>
+ </characteristic>
+ </characteristic>
+ <characteristic type="APPLICATION">
+ <parm name="APPID" value="wA">
+ </parm>
+ <parm name="NAME" value="IM_Prepaid1">
+ </parm>
+ <characteristic type="APPADDR">
+ <parm name="ADDR" value="http://aoltest.cwmim.com">
+ </parm>
+ <characteristic type="PORT">
+ <parm name="PORTNBR" value="0">
+ </parm>
+ </characteristic>
+ </characteristic>
+
+ <characteristic type="APPAUTH">
+ <parm name="AAUTHLEVEL" value="APPSRV">
+ </parm>
+ <parm name="AAUTHNAME" value="">
+ </parm>
+ <parm name="AAUTHSECRET" value="">
+ </parm>
+ </characteristic>
+ <characteristic type="APPAUTH">
+ <parm name="AAUTHLEVEL" value="CLIENT">
+ </parm>
+ <parm name="AAUTHNAME" value="no in use">
+ </parm>
+ <parm name="AAUTHSECRET" value="">
+ </parm>
+ </characteristic>
+ <characteristic type="PROPRIETARY">
+ <parm name="ServerPostURL" value="">
+ </parm>
+ <parm name="LoginAutoResetConversation" value="false">
+ </parm>
+ <parm name="ServerCirSupported" value="false">
+ </parm>
+ <parm name="ServerLoginMethod" value="2WAY">
+ </parm>
+ <parm name="ServerProxyAddress" value="">
+ </parm>
+ <parm name="ServerProxyPassword" value="">
+ </parm>
+ <parm name="ServerProxyUserName" value="">
+ </parm>
+ <parm name="ServerTransportType" value="HTTP">
+ </parm>
+ <parm name="ServerSMSDestinationAddress" value="">
+ </parm>
+ <parm name="ServSMSCirSup" value="false">
+ </parm>
+ <parm name="SvTCPCIRKeepTim" value="0">
+ </parm>
+ <parm name="SvTCPCIRSup" value="false">
+ </parm>
+ <parm name="ServerCloseSocketAfterResponse" value="true">
+ </parm>
+ <parm name="AutoRefreshContactList" value="false">
+ </parm>
+ <parm name="FrbdUnauthoMsgs" value="false">
+ </parm>
+ </characteristic>
+ <parm name="TO-NAPID" value="IM_NAP_PRE1">
+ </parm>
+ </characteristic>
+</wap-provisioningdoc>
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/JAVA.xml b/engine/dmlib/tool-src/db_wizard_tool/samples/JAVA.xml
new file mode 100644
index 0000000..ad51912
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/JAVA.xml
@@ -0,0 +1,25 @@
+
+<wap-provisioningdoc version="1.1">
+
+ <characteristic type="APPLICATION" >
+ <parm name="APPID" value="DmWizardJavaAppID" ></parm>
+ <parm name="NAME" value="JAVA_SETTINGS1" ></parm>
+ <parm name="TO-NAPID" value="JAVA_SETTINGS1"></parm>
+ </characteristic>
+
+ <characteristic type="NAPDEF" >
+ <parm name="NAPID" value="JAVA_SETTINGS1" ></parm>
+ <parm name="NAME" value="JAVA_SETTINGS1" ></parm>
+ <parm name="BEARER" value="GSM-GPRS" ></parm>
+ <parm name="NAP-ADDRESS" value="203.203.203.1"></parm>
+ <parm name="DNS-ADDR" value="203.203.203.203" ></parm>
+ <parm name="NAP-ADDRTYPE" value="IPv4">
+
+ <characteristic type="NAPAUTHINFO" >
+ <parm name="AUTHTYPE" value="PAP" ></parm>
+ <parm name="AUTHNAME" value="VH_WAP_NAPUID" ></parm>
+ <parm name="AUTHSECRET" value="VH_WAP_NAPPWD" ></parm>
+ </characteristic>
+ </characteristic>
+
+</wap-provisioningdoc>
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/MMS.xml b/engine/dmlib/tool-src/db_wizard_tool/samples/MMS.xml
new file mode 100644
index 0000000..18e4c08
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/MMS.xml
@@ -0,0 +1,53 @@
+
+<wap-provisioningdoc version="1.1">
+
+ <characteristic type="APPLICATION" >
+ <parm name="APPID" value="w4" ></parm>
+ <parm name="NAME" value="VH_MMS" ></parm>
+ <parm name="TO-PROXY" value="101.101.101.101"></parm>
+ <parm name="ADDR" value="VH_MMS_url "></parm>
+ </characteristic>
+
+ <characteristic type="PXLOGICAL" >
+ <parm name="PROXY-ID" value="101.101.101.101" ></parm>
+ <parm name="NAME" value="VH_MMS_Proxy_Name" ></parm>
+
+ <characteristic type="PXPHYSICAL" >
+ <parm name="PHYSICAL-PROXY-ID" value="VH_MMS_PxPhys" ></parm>
+ <parm name="PXADDR" value="101.101.101.101" ></parm>
+ <parm name="PXADDRTYPE" value="IPV4"></parm>
+ <parm name="TO-NAPID" value="VH_MMS_NAP" ></parm>
+
+ <characteristic type="PORT" >
+ <parm name="PORTNBR" value="9999"></parm>
+ <parm name="SERVICE" value="CO-WSP"></parm>
+ </characteristic>
+ </characteristic>
+
+ <characteristic type="PXAUTHINFO">
+ <parm name="PXAUTH-TYPE" value="HTTP-BASIC"/>
+ <parm name="PXAUTH-ID" value="VH_MMS_PXUID"/>
+ <parm name="PXAUTH-PW" value="VH_MMS_PXPWD"/>
+ </characteristic>
+
+ </characteristic>
+
+
+ <characteristic type="NAPDEF" >
+ <parm name="NAPID" value="VH_MMS_NAP" ></parm>
+ <parm name="NAME" value="VH_MMS_NAP" ></parm>
+ <parm name="BEARER" value="GSM-GPRS" ></parm>
+ <parm name="NAP-ADDRESS" value="201.201.201.11"></parm>
+ <parm name="DNS-ADDR" value="201.201.201.201" ></parm>
+ <parm name="DNS-ADDR" value="202.202.202.202" ></parm>
+ <parm name="NAP-ADDRTYPE" value="IPv4">
+
+
+ <characteristic type="NAPAUTHINFO" >
+ <parm name="AUTHTYPE" value="PAP" ></parm>
+ <parm name="AUTHNAME" value="VH_MMS_NAPUID" ></parm>
+ <parm name="AUTHSECRET" value="VH_MMS_NAPPWD" ></parm>
+ </characteristic>
+ </characteristic>
+
+</wap-provisioningdoc>
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/browser.csv b/engine/dmlib/tool-src/db_wizard_tool/samples/browser.csv
new file mode 100644
index 0000000..74cbe49
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/browser.csv
@@ -0,0 +1,9 @@
+mcc,mnc,operator_name,country_name,account_type,service_name,gprs_access_point_name,ap_requires_auth,ppp_auth_type,ppp_auth_name,ppp_auth_secret,dns_1,dns_2,nap_addr_type,bearer,proxy,proxy_addr_type,port,proxy_type,proxy_requires_auth,proxy_auth_name,proxy_auth_secret,proxy_auth_type,homepage_url
+310,170,Cingular,USA,prepaid,Br_Cingular_Service,mms.base.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,9201,CO-WSP,0,,,,http://wap.base.com/
+310,170,Cingular,USA,postpaid,Br_Cingular_Service,mms.base.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,5080,OTA-HTTP-TO,0,,,,http://wap.base.com/
+310,170,T-Mobile,Canada,prepaid,Br_T_Mobile_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,9201,CO-WSP,0,,,,http://ztar.clearmode.com/
+310,170,T-Mobile,Canada,postpaid,Br_T_Mobile_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,80,OTA-HTTP-TO,0,,,,http://ztar.clearmode.com/
+311,015,T-Mobile1,Canada,prepaid,Br_T_Mobile1_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,9201,CO-WSP,0,,,,http://ztar.clearmode.com/
+311,15,T-Mobile1,Canada,postpaid,Br_T_Mobile1_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,80,OTA-HTTP-TO,0,,,,http://ztar.clearmode.com/
+312,00,CMCC,Canada,prepaid,Br_CMCC_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,80,OTA-HTTP-TO,0,,,,http://ztar.clearmode.com/
+312,00,CMCC,Canada,postpaid,Br_CMCC_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,80,OTA-HTTP-TO,0,,,,http://ztar.clearmode.com/
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/browser_template.xls b/engine/dmlib/tool-src/db_wizard_tool/samples/browser_template.xls
new file mode 100644
index 0000000..1d0125f
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/browser_template.xls
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/im.csv b/engine/dmlib/tool-src/db_wizard_tool/samples/im.csv
new file mode 100644
index 0000000..e1ac62c
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/im.csv
@@ -0,0 +1,7 @@
+mcc,mnc,operator_name,country_name,account_type,Brand_instance_name,IspProfileName,gprs_access_point_name,ap_requires_auth,ppp_auth_type,ppp_auth_name,ppp_auth_secret,nap_addr_type,bearer,ServerAddr,ServerPort,ClientID,PrivateKey1,PrivateKey2,ServerPostURL,LoginAutoResetConversation,ServerCirSupported,ServerLoginMethod,ServerProxyAddress,ServerProxyPassword,ServerProxyUserName,ServerTransportType,ServerSMSDestinationAddress,ServSMSCirSup,SvTCPCIRKeepTim,SvTCPCIRSup,ServerCloseSocketAfterResponse,AutoRefreshContactList,FrbdUnauthoMsgs
+310,170,Cingular,USA,prepaid,ICQ,Cingular1,wap.cingular,1,PAP,WAP@CINGULARGPRS.COM,CINGULAR1,ALPHA,GSM-GPRS,207.245.49.131,80,250043000000,,,/wv/csp,false,false,2WAY,,,,HTTP,,false,0,false,true,false,false
+310,170,Cingular,USA,postpaid,Default,Cingular2,wap.cingular,1,PAP,WAP@CINGULARGPRS.COM,CINGULAR2,ALPHA,GSM-GPRS,207.245.49.131,80,250043000000,,,/wv/csp,false,false,2WAY,,,,HTTP,,false,0,false,true,false,false
+300,180,TIM,USA,prepaid,AOL,Tim,http://www.tim.com,1,PAP,base,base,ALPHA,GSM-GPRS,194.143.13.120,2380,250043000000,,,/wv,true,false,2WAY,,,,HTTP,,false,0,false,true,false,false
+300,180,TIM,USA,postpaid,MSN,Tim,http://www.tim.com,1,PAP,base,base,ALPHA,GSM-GPRS,207.245.49.131,80,250043000000,,,/wv/csp,false,false,2WAY,,,,HTTP,,false,0,false,true,false,false
+300,180,TIM,USA,prepaid,Yahoo,Tim,http://www.tim.com,1,PAP,base,base,ALPHA,GSM-GPRS,207.245.49.131,80,250043000000,,,/wv/csp,false,false,2WAY,,,,HTTP,,false,0,false,true,false,false
+300,180,TIM,USA,postpaid,Default,Tim,http://www.tim.com,1,PAP,base,base,ALPHA,GSM-GPRS,194.143.13.120,2380,250043000000,,,/wv,true,false,2WAY,,,,HTTP,,false,0,false,true,false,false
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/im_template.xls b/engine/dmlib/tool-src/db_wizard_tool/samples/im_template.xls
new file mode 100644
index 0000000..9ae74bc
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/im_template.xls
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/java.csv b/engine/dmlib/tool-src/db_wizard_tool/samples/java.csv
new file mode 100644
index 0000000..84866b7
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/java.csv
@@ -0,0 +1,9 @@
+mcc,mnc,operator_name,country_name,account_type,service_name,gprs_access_point_name,ap_requires_auth,ppp_auth_type,ppp_auth_name,ppp_auth_secret,dns_1,dns_2,nap_addr_type,bearer,proxy,proxy_addr_type,port,proxy_type,proxy_requires_auth,proxy_auth_name,proxy_auth_secret,proxy_auth_type
+310,170,Cingular,USA,prepaid,Java_Cingular_Service,mms.base.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,9201,CO-WSP,0,,,
+310,170,Cingular,USA,postpaid,Java_Cingular_Service,mms.base.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,5080,OTA-HTTP-TO,0,,,
+310,170,T-Mobile,Canada,prepaid,Java_T_Mobile_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,9201,CO-WSP,0,,,
+310,170,T-Mobile,Canada,postpaid,Java_T_Mobile_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,80,OTA-HTTP-TO,0,,,
+311,015,T-Mobile1,Canada,prepaid,Java_T_Mobile1_Service,media.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,9201,CO-WSP,0,,,
+311,15,T-Mobile1,Canada,postpaid,Java_T_Mobile1_Service,media.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,5080,OTA-HTTP-TO,0,,,
+312,00,CMCC,Canada,prepaid,Java_CMCC_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,9201,CO-WSP,0,,,
+312,00,CMCC,Canada,postpaid,Java_CMCC_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,80,OTA-HTTP-TO,0,,,
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/java_template.xls b/engine/dmlib/tool-src/db_wizard_tool/samples/java_template.xls
new file mode 100644
index 0000000..8e0108f
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/java_template.xls
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/mms.csv b/engine/dmlib/tool-src/db_wizard_tool/samples/mms.csv
new file mode 100644
index 0000000..a0da1ca
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/mms.csv
@@ -0,0 +1,9 @@
+mcc,mnc,operator_name,country_name,account_type,service_name,gprs_access_point_name,ap_requires_auth,ppp_auth_type,ppp_auth_name,ppp_auth_secret,dns_1,dns_2,nap_addr_type,bearer,proxy,proxy_addr_type,port,proxy_type,proxy_requires_auth,proxy_auth_name,proxy_auth_secret,proxy_auth_type,mms_url
+310,170,Cingular,USA,prepaid,MMS_Cingular_Service,mms.base.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,9201,CO-WSP,0,,,,http://mmsc.base.com
+310,170,Cingular,USA,postpaid,MMS_Cingular_Service,mms.base.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,5080,OTA-HTTP-TO,0,,,,http://mmsc.base.com
+310,170,T-Mobile,Canada,prepaid,MMS_T_Mobile_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,9201,CO-WSP,0,,,,http://mms.gprs.rogers.com/
+310,170,T-Mobile,Canada,postpaid,MMS_T_Mobile_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,80,OTA-HTTP-TO,0,,,,http://mms.gprs.rogers.com/
+311,015,T-Mobile1,Canada,prepaid,MMS_T_Mobile1_Service,media.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,9201,CO-WSP,0,,,,http://mmsc.base.com
+311,15,T-Mobile1,Canada,postpaid,MMS_T_Mobile1_Service,media.com,1,PAP,base,base,,,ALPHA,GSM-GPRS,172.031.198.037,IPV4,5080,OTA-HTTP-TO,0,,,,http://mmsc.base.com
+312,00,CMCC,Canada,prepaid,MMS_CMCC_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,9201,CO-WSP,0,,,,http://mms.gprs.rogers.com/
+312,00,CMCC,Canada,postpaid,MMS_CMCC_Service,media.com,1,PAP,wapuser1,wap,,,ALPHA,GSM-GPRS,010.128.001.069,IPV4,80,OTA-HTTP-TO,0,,,,http://mms.gprs.rogers.com/
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/mms.txt b/engine/dmlib/tool-src/db_wizard_tool/samples/mms.txt
new file mode 100644
index 0000000..6b613c6
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/mms.txt
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/mms_template.xls b/engine/dmlib/tool-src/db_wizard_tool/samples/mms_template.xls
new file mode 100644
index 0000000..93f5ddc
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/mms_template.xls
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/samples/mms_unicode_template.xls b/engine/dmlib/tool-src/db_wizard_tool/samples/mms_unicode_template.xls
new file mode 100644
index 0000000..7fb4a4c
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/samples/mms_unicode_template.xls
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/templates/browser_template.xls b/engine/dmlib/tool-src/db_wizard_tool/templates/browser_template.xls
new file mode 100644
index 0000000..bd7e2cf
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/templates/browser_template.xls
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/templates/im_template.xls b/engine/dmlib/tool-src/db_wizard_tool/templates/im_template.xls
new file mode 100644
index 0000000..210563a
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/templates/im_template.xls
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/templates/java_template.xls b/engine/dmlib/tool-src/db_wizard_tool/templates/java_template.xls
new file mode 100644
index 0000000..b9e936c
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/templates/java_template.xls
Binary files differ
diff --git a/engine/dmlib/tool-src/db_wizard_tool/templates/mms_template.xls b/engine/dmlib/tool-src/db_wizard_tool/templates/mms_template.xls
new file mode 100644
index 0000000..7efafad
--- /dev/null
+++ b/engine/dmlib/tool-src/db_wizard_tool/templates/mms_template.xls
Binary files differ
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/DMTValidator.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/DMTValidator.java
new file mode 100644
index 0000000..aa2fd28
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/DMTValidator.java
@@ -0,0 +1,1438 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//==================================================================================================
+//
+// Module Name: DMTValidator
+//
+// General Description: The classes contained here provide a depth first recursive traversal of the
+// Dmt.zip directory heirarchy, and have numerous sanity checks built in which
+// validate the contents of the parm.txt files that make up the DMT.
+//
+//==================================================================================================
+
+package com.mot.dm.core;
+
+import java.io.BufferedReader;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import java.util.ListIterator;
+
+// Joda is an Open Source date/time parsing library (used to parse ISO8601 date/time formats)
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.ISODateTimeFormat;
+import org.joda.time.DateTime;
+
+// Jakarta regexp is an Open Source regular expression parsing library.
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+
+import java.io.Reader;
+import com.mot.dm.io.Node;
+import com.mot.dm.io.NodeLoader;
+
+// Main DMTValidator class
+public class DMTValidator
+{
+ private final String[] illegalCharsForNodeName = {"#", "$", "\\", "/", "?", "<", ">", "%", "\"", "|", ":"}; //"&", "!"
+ private int depth = 1;
+ final static private String parm = "parm.txt";
+ static private String initDir = "D:\\Dmt";
+ static private ArrayList problemsList = new ArrayList();
+ private String [] path = new String [20];
+
+ private static void usage()
+ {
+ System.err.println("Usage: java DMTValidator -d dirName \n" +
+ "\t\t -d : dirName points to the directory where Dmt is located\n");
+ }
+
+ public static void main(String [] args) throws Exception
+ {
+ if (args.length != 2)
+ {
+ System.err.println("Error: Incorrect number of arguments!");
+ usage();
+ System.exit(1);
+ }
+ else
+ {
+ if (args[0].equals("-d"))
+ {
+ initDir = args[1];
+ }
+ else
+ {
+ System.err.println("Error: No directory specified!");
+ usage();
+ System.exit(1);
+ }
+ }
+
+ // Check to make sure the directory we are passed is valid
+ if (!NodeLoader.getInstance(initDir).exists())
+ {
+ System.err.println("Error: Invalid directory specified!");
+ usage();
+ System.exit(1);
+ }
+
+ // Run the validator on our dir structure
+
+ DMTValidator validator = new DMTValidator();
+ validator.analyzeDir(initDir);
+
+ // Exit with the proper return code, and print out any problems
+
+ if (problemsList.isEmpty())
+ {
+ //System.out.println("DMT validation passed...");
+ System.exit(0);
+ }
+ else
+ {
+ ListIterator iterator = problemsList.listIterator();
+
+ //System.out.println("DM Tree cannot be generated: validation failed!");
+
+ while (iterator.hasNext())
+ {
+ System.err.println("Error: " + iterator.next());
+ }
+
+ System.exit(1);
+ }
+ }
+
+ // Starting point for our tree traversal - called recursively to process the tree
+ public void analyzeDir(String dirName) throws Exception
+ {
+ boolean isLeaf=false;
+ boolean isMultiNode = false;
+
+ // Increment our depth
+
+ depth += 1;
+
+ // Remove leading (leaf) and trailing (reserved name) "#"
+
+ String nodeName;
+
+ if (depth <= 2)
+ {
+ nodeName = ".";
+ }
+ else
+ {
+ nodeName = dirName.substring(dirName.lastIndexOf(System.getProperty("file.separator")) + 1);
+
+ if (nodeName.startsWith("#"))
+ {
+ isLeaf=true;
+ }
+
+ nodeName = nodeName.replace('#', ' ');
+
+ if (nodeName.startsWith("@"))
+ {
+ nodeName = nodeName.substring(1);
+ }
+
+ nodeName = nodeName.trim();
+
+ if (nodeName.charAt(0) == '[')
+ {
+ nodeName = "*";
+ isMultiNode = true;
+ }
+ path [depth - 2] = nodeName;
+ }
+
+ // Get the current node path
+
+ String nodepath=".";
+
+ for (int i=1; i<depth-1; i++)
+ {
+ nodepath=nodepath+"/"+path[i];
+ }
+
+ // Process the directory
+
+ Node directory = NodeLoader.getInstance(dirName);
+ Node[] children = directory.listNodes();
+
+ // Create our parameters HashMap and access ArrayList
+
+ HashMap parameters = new HashMap();
+ ArrayList access = new ArrayList();
+
+ String filename = dirName+"/"+parm;
+
+ // Does the parm file exist? If not, flag it, and continue
+
+ if (NodeLoader.getInstance(filename).exists())
+ {
+ // Get parameters from the current branch
+
+ try
+ {
+ getParms(filename, parameters, access);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ problemsList.add("Malformed parm.txt file for node: " + nodepath);
+ }
+
+ // DMT VALIDATIONS GO HERE
+ // =======================
+
+ // -----------------------------------------------------
+ // Check to see if a valid type is defined for this node
+ // -----------------------------------------------------
+
+ String nodeType = (String) parameters.get("Type");
+
+ if (nodeType == null)
+ {
+ problemsList.add("No type defined for node: " + nodepath);
+ }
+ else if (!nodeType.equalsIgnoreCase("int") && !nodeType.equalsIgnoreCase("bool") &&
+ !nodeType.equalsIgnoreCase("bin") && !nodeType.equalsIgnoreCase("node") &&
+ !nodeType.equalsIgnoreCase("chr") && !nodeType.equalsIgnoreCase("null") &&
+ !nodeType.equalsIgnoreCase("test") && !nodeType.equalsIgnoreCase("date") &&
+ !nodeType.equalsIgnoreCase("time") && !nodeType.equalsIgnoreCase("float"))
+
+ {
+ problemsList.add("Invalid node type '" + nodeType + "' for the node: " + nodepath +
+ ". The valid types are: 'node', 'int', 'bin', 'chr', 'bool', 'float', 'time', 'date'.");
+
+ }
+
+ // -------------------------------------------------------
+ // Sanity checks for 'default' MA (format,constraints, etc)
+ // -------------------------------------------------------
+
+ String defValue = (String) parameters.get("Default");
+
+ if (defValue != null)
+ {
+ // -----------------------------------------------------
+ // Do not allow default values for node types:
+ // 'test', 'null', 'node'
+ // -----------------------------------------------------
+
+ if (nodeType != null && (nodeType.equalsIgnoreCase("test") || nodeType.equalsIgnoreCase("null") ||
+ nodeType.equalsIgnoreCase("node")))
+ {
+ problemsList.add("Default values are not allowed for nodes with type '" + nodeType + "' for the node: " + nodepath +
+ ". The attribute 'default' should be removed");
+ }
+
+ // Check these values for min/max and other constraints
+
+ checkValues(defValue,parameters,nodepath,nodeType,"Default");
+ }
+
+ // -------------------------------------------------------
+ // Make sure that only multi-nodes have storesPD parameter
+ // -------------------------------------------------------
+
+ if (!isMultiNode && (parameters.get("storesPD") != null))
+ {
+ problemsList.add("The 'storesPD' attribute is not allowed for the non-multinode: " + nodepath +
+ ". This attribute should be removed.");
+ }
+
+ // --------------------------------------------------------------
+ // Make sure that 'auto' MA is only used on interior & test nodes
+ // --------------------------------------------------------------
+
+ if ((parameters.get("auto") != null) && (nodeType != null && !nodeType.equalsIgnoreCase("node")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("test")))
+ {
+ problemsList.add("The 'auto' attribute is not allowed for the non-interior node: " + nodepath +
+ ". This attribute should be removed.");
+ }
+
+ // ------------------------------------------------------
+ // Sanity checks for 'fk' MA (format,constraints, etc)
+ // ------------------------------------------------------
+
+ String fkStr = (String) parameters.get("fk");
+
+ if (fkStr != null && (nodeType != null && nodeType.equalsIgnoreCase("node")))
+ {
+ problemsList.add("The 'fk' attribute is not allowed for the interior node: " + nodepath +
+ ". This attribute should be removed.");
+ }
+
+ if (fkStr != null && fkStr.length() == 0)
+ {
+ problemsList.add("The 'fk' attribute can not be an empty string for the node: " + nodepath +
+ ". This attribute should be removed or value for 'fk' should be set.");
+ }
+
+ // -------------------------------------------------------
+ // Sanity checks for 'value' MA (format,constraints, etc)
+ // -------------------------------------------------------
+
+ String value = (String) parameters.get("Value");
+
+ if (value != null)
+ {
+ if (nodeType != null && nodeType.equalsIgnoreCase("node"))
+ {
+ problemsList.add("The 'value' attribute is not allowed for the interior node: " + nodepath +
+ ". This attribute should be removed.");
+ }
+
+ // Check these values for min/max and other constraints
+
+ checkValues(value,parameters,nodepath,nodeType,"Value");
+ }
+
+ // --------------------------------------------------------
+ // Sanity checks for 'values' MA (format,constraints, etc)
+ // --------------------------------------------------------
+
+ String values = (String) parameters.get("values");
+
+ if (values != null)
+ {
+ if (nodeType != null && nodeType.equalsIgnoreCase("node"))
+ {
+ problemsList.add("The 'values' attribute is not allowed for the interior node: " + nodepath +
+ ". This attribute should be removed.");
+ }
+
+ // Check these values for min/max and other constraints
+
+ checkValues(values,parameters,nodepath,nodeType,"Values");
+
+ // Check values and default values against possible values
+
+ if (value != null)
+ {
+ if (values.indexOf(value) == -1)
+ {
+ problemsList.add("Initial value '" + value +
+ "' is not one of the valid values in 'values' constraint '" +
+ values + "' for the node: " + nodepath +
+ ". The attribute 'value' should be set to one of the valid values.");
+ }
+ }
+
+ if (defValue != null)
+ {
+ if (values.indexOf(defValue) == -1)
+ {
+ problemsList.add("Default value '" + defValue +
+ "' is not one of the valid values in 'values' constraint '" +
+ values + "' for node: " + nodepath +
+ ". The attribute 'default' should be set to one of the valid values.");
+ }
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // Make sure that 'min' MA is only used on int/float/date/time/test nodes
+ // ----------------------------------------------------------------------
+
+ if ((parameters.get("min") != null) && (nodeType != null && !nodeType.equalsIgnoreCase("int")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("test")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("float")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("date")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("time")))
+ {
+ problemsList.add("The 'min' attribute is not allowed for nodes with type '" + nodeType + "' at the node: " + nodepath +
+ ". This attribute should be removed.");
+ }
+
+ // ----------------------------------------------------------------------
+ // Make sure that 'max' MA is only used on int/float/date/time/test nodes
+ // ----------------------------------------------------------------------
+
+ if ((parameters.get("max") != null) && (nodeType != null && !nodeType.equalsIgnoreCase("int")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("test")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("float")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("date")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("time")))
+ {
+ problemsList.add("The 'max' attribute is not allowed for nodes with type '" + nodeType + "' at the node: " + nodepath +
+ ". This attribute should be removed.");
+ }
+
+ // ---------------------------------------------------------
+ // Make sure that 'minLen' MA is only used on chr/bin/test nodes
+ // ---------------------------------------------------------
+
+ if ((parameters.get("minLen") != null) && (nodeType != null && !nodeType.equalsIgnoreCase("chr")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("bin")) && (nodeType != null && !nodeType.equalsIgnoreCase("test")))
+ {
+ problemsList.add("The 'minLen' attribute not allowed for nodes with type '" + nodeType + "' at the node: " + nodepath +
+ ". This attribute should be removed.");
+ }
+
+ // ---------------------------------------------------------
+ // Make sure that 'maxLen' MA is only used on chr/bin/test nodes
+ // ---------------------------------------------------------
+
+ if ((parameters.get("maxLen") != null) && (nodeType != null && !nodeType.equalsIgnoreCase("chr")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("bin")) && (nodeType != null && !nodeType.equalsIgnoreCase("test")))
+ {
+ problemsList.add("The 'maxLen' attribute not allowed for nodes with type '" + nodeType + "' at the node: " + nodepath +
+ ". This attribute should be removed.");
+ }
+
+ // ---------------------------------------------------------
+ // Sanity checks for 'regexp' MA (format,constraints, etc)
+ // ---------------------------------------------------------
+
+ String regexpStr = (String) parameters.get("regexp");
+
+ if (regexpStr != null && (nodeType != null && !nodeType.equalsIgnoreCase("chr")) &&
+ (nodeType != null && !nodeType.equalsIgnoreCase("test")))
+ {
+ problemsList.add("The 'regexp' attribute not allowed for the non-character node: " + nodepath+
+ ". This attribute should be removed.");
+ }
+ else if (regexpStr != null && regexpStr.length() == 0)
+ {
+ problemsList.add("The 'regexp' attribute may not be an empty string for the node: " + nodepath +
+ ". This attribute should be removed or value for 'regexp' should be set.");
+ }
+ else if (regexpStr != null)
+ {
+ try
+ {
+ RE regexpValue = new RE(regexpStr);
+
+ // Check default and value MA's against this regular expression
+
+ if (value != null)
+ {
+ if (!regexpValue.match(value))
+ {
+ problemsList.add("Value attribute '" + value + "' does not match regular expression '" + regexpStr + "' for node: " + nodepath);
+ }
+ }
+
+ if (defValue != null)
+ {
+ if (!regexpValue.match(defValue))
+ {
+ problemsList.add("Default attribute '" + defValue + "' does not match regular expression '" + regexpStr + "' for node: " + nodepath);
+ }
+ }
+ }
+ catch (RESyntaxException e)
+ {
+ problemsList.add("Invalid regular expression string '" + regexpStr + "' for the node: " + nodepath);
+ }
+ }
+
+ // ----------------------------------------------------
+ // Checks for 'nMaxLen' MA (format,current nodename)
+ // ----------------------------------------------------
+
+ String nMaxLenStr = (String) parameters.get("nMaxLen");
+
+ if (nMaxLenStr != null)
+ {
+ if (nMaxLenStr.length() != 0)
+ {
+ try
+ {
+ int maxIntValue = Integer.parseInt(nMaxLenStr);
+
+ if (nodeName.length() > maxIntValue)
+ {
+ problemsList.add("Node name '" + nodeName +
+ "' is longer than the maximum node name length constraint '" +
+ maxIntValue + "' for the node: " + nodepath);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add("The attribute nMaxLen has invalid value '" + nMaxLenStr + "' for the node: " + nodepath +
+ ". This attribute should be valid integer from 1 to 2147483647.");
+ }
+ }
+ else
+ {
+ problemsList.add("The attribute nMaxLen may not be an empty string for the node: " + nodepath);
+ }
+ }
+
+ // ----------------------------------------------------
+ // Checks for 'nValues' MA (format,current nodename)
+ // ----------------------------------------------------
+
+ String nValuesStr = (String) parameters.get("nValues");
+
+ if (nValuesStr != null)
+ {
+ if (nValuesStr.length() != 0)
+ {
+ if (nValuesStr.indexOf(nodeName) == -1 && !nodeName.equals("*"))
+ {
+ problemsList.add("Node name '" + nodeName +
+ "' is not one of the valid values in the attribute nValues constraint '" +
+ nValuesStr + "' for the node: " + nodepath);
+ }
+ }
+ else
+ {
+ problemsList.add("The attribute nValues may not be an empty string for node: " + nodepath);
+ }
+ }
+
+ // ----------------------------------------------------
+ // Checks that file name (current nodename) doesn't contain illegal chars
+ // ----------------------------------------------------
+ for(int i=0; i<illegalCharsForNodeName.length; i++){
+ if(nodeName.indexOf(illegalCharsForNodeName[i]) > -1){
+ problemsList.add("The node name contains illegal char '" + illegalCharsForNodeName[i] + "' for the " + nodepath);
+ }
+ }
+
+ // ----------------------------------------------------
+ // Checks for 'nRegexp' MA (format,current nodename)
+ // ----------------------------------------------------
+
+ String nRegexpStr = (String) parameters.get("nRegexp");
+
+ /*
+ if (nRegexpStr != null && nodeName != "*")
+ {
+ if (nRegexpStr.length() != 0)
+ {
+ try
+ {
+ RE nRegexpValue = new RE(nRegexpStr);
+
+ // Check the nodename against this regular expression
+
+ if (!nRegexpValue.match(nodeName))
+ {
+ problemsList.add("Node name '" + nodeName + "' does not match regular expression '" + nRegexpStr + "' for node: " + nodepath);
+ }
+ }
+ catch (RESyntaxException e)
+ {
+ problemsList.add("Invalid regular expression string '" + nRegexpStr + "' for node: " + nodepath);
+ }
+ }
+ else
+ {
+ problemsList.add("nRegexp attribute may not be an empty string for node: " + nodepath);
+ }
+ }*/
+
+ // ---------------------------------------------------------
+ // Make sure that 'access' MA has valid values
+ // ---------------------------------------------------------
+
+ ArrayList accessType = (ArrayList) parameters.get("AccessType");
+
+ if (accessType == null || accessType.isEmpty())
+ {
+ problemsList.add("The attribute 'access' is not present for the node: " + nodepath
+ + ". This attribute is required");
+ }
+ else
+ {
+ Object accessTokens[] = accessType.toArray();
+
+ for (int i=0;i<accessTokens.length;i++)
+ {
+ if (!((String)accessTokens[i]).equalsIgnoreCase("Add") &&
+ !((String)accessTokens[i]).equalsIgnoreCase("Delete") &&
+ !((String)accessTokens[i]).equalsIgnoreCase("Get") &&
+ !((String)accessTokens[i]).equalsIgnoreCase("Exec")&&
+ !((String)accessTokens[i]).equalsIgnoreCase("Replace")&&
+ !((String)accessTokens[i]).equalsIgnoreCase("Local"))
+ {
+ problemsList.add("Invalid access type '" + accessTokens[i] + "' for node: " + nodepath
+ + ". The valid types are: 'Add', 'Delete', 'Get', 'Replace', 'Exec', 'Local'");
+ }
+ }
+ }
+
+ //----------------------------------------------------
+ // Checks for 'store' values (true,false,1,0) and that parms 'default' and 'value' hasn't been set
+ // ----------------------------------------------------
+ String storeStr = (String) parameters.get("store");
+
+ if (storeStr != null)
+ {
+ //validate that parms 'default' and 'value' hasn't been set
+ if(parameters.get("Default") != null){
+ problemsList.add("Attribute 'default' cannot be set with attribute 'store' for the node: " + nodepath);
+ }
+ if(parameters.get("Value") != null){
+ problemsList.add("Attribute 'value' cannot be set with attribute 'store' for the node: " + nodepath);
+ }
+
+ if (storeStr.length() != 0)
+ {
+ if (!storeStr.equalsIgnoreCase("true") && !storeStr.equalsIgnoreCase("false") &&
+ !storeStr.equalsIgnoreCase("1") && !storeStr.equalsIgnoreCase("0"))
+ {
+ problemsList.add("The value '" + storeStr + "' for parm 'store' is not one of the valid values for node: " + nodepath
+ + ". The valid values are: 'true', 'false'");
+ }
+ }
+ else
+ {
+ problemsList.add("The 'store' attribute may not be an empty string for the node: " + nodepath);
+ }
+ }
+
+ //----------------------------------------------------
+ // Checks for 'LOBProgressBAR' values (true,false,1,0) and that parm "store" is presented
+ // ----------------------------------------------------
+ String LOBProgressBARStr = (String) parameters.get("LOBProgressBAR");
+
+ if (LOBProgressBARStr != null)
+ {
+ //parm 'store' is required and should be true or false
+ if(parameters.get("store") == null){
+ problemsList.add("The attribute 'LOBProgressBAR' cannot be specified without attribute 'store' for the node: " + nodepath);
+ }
+ else if(!((String) parameters.get("store")).trim().equalsIgnoreCase("true") &&
+ !((String) parameters.get("store")).trim().equalsIgnoreCase("1")){
+ problemsList.add("The attribute 'LOBProgressBAR' can be specified only if attribute 'store' equals 'true' or '1' for the node: " + nodepath);
+ }
+
+ if (LOBProgressBARStr.length() != 0)
+ {
+ if (!LOBProgressBARStr.equalsIgnoreCase("true") && !LOBProgressBARStr.equalsIgnoreCase("false") &&
+ !LOBProgressBARStr.equalsIgnoreCase("1") && !LOBProgressBARStr.equalsIgnoreCase("0"))
+ {
+ problemsList.add("The value '" + LOBProgressBARStr + "' for parm 'LOBProgressBAR' is not one of the valid values for the node: " + nodepath
+ + ". The valid values are: 'true', 'false'");
+ }
+ }
+ else
+ {
+ problemsList.add("The LOBProgressBAR attribute may not be an empty string for node: " + nodepath);
+ }
+ }
+
+ // ---------------------------------------------------------
+ // Make sure that parameter 'event' has valid values
+ // ---------------------------------------------------------
+ ArrayList arrEvents = (ArrayList) parameters.get("Event");
+
+ if (arrEvents != null && !arrEvents.isEmpty())
+ {
+ String event;
+ HashMap mapNotifyAndIgnoreVals = new HashMap(); //keeps values for "Notify" and " Ignore"
+ for (int i=0;i<arrEvents.size();i++)
+ {
+ event = (String)arrEvents.get(i);
+ if (!validateEventValues(event, arrEvents, isLeaf, mapNotifyAndIgnoreVals))
+ {
+ problemsList.add("The attribute 'event' contains invalid value for the node: " + nodepath
+ + ". The valid operations are: 'Add', 'Delete', 'Replace', 'Indirect'. "
+ + " The valid format can be 'Node' or 'Detail' or 'Cumulative' (for interior nodes only)."
+ + " The keys in key=value(s) pairs can be 'Topic' (single), 'Ignore' (list), 'Notify' (list)."
+ + "Sample: Topic=AAA&Notify=BBB&CCC. 'Ignore' and 'Notify' cannot have the same values.");
+ break;
+ }
+ }
+ }
+
+
+
+
+ // --- END OF DMT VALIDATIONS ---
+ }
+ else
+ {
+ problemsList.add("Missing parm.txt file for node: " + nodepath);
+ }
+
+ // Process child directories
+
+ if (children == null)
+ {
+ // Either dir does not exist or is not a directory
+ }
+ else
+ {
+ // process any directories
+
+ for (int ii=0; ii<children.length; ii++)
+ {
+ if (children[ii].isDirectory())
+ {
+ analyzeDir(children[ii].getAbsolutePath());
+ }
+ }
+ }
+
+ depth -= 1;
+ }
+
+ // Validate passed in value against empty string criteria, as well as violation of any constraints
+ private void checkValues(String value,HashMap parameters,String nodepath,String nodeType,String type)
+ {
+ if (value.length() != 0)
+ {
+ StringTokenizer valueTokens = new StringTokenizer(value,",");
+ String valueToken;
+
+ while (valueTokens.hasMoreTokens())
+ {
+ valueToken = valueTokens.nextToken();
+
+ if (nodeType != null && nodeType.equalsIgnoreCase("int"))
+ {
+ // Attempt to parse this value into an int - if we get a NumberFormat Exception, flag this
+ // as an invalid value.
+
+ boolean validValue = true;
+ int intValue = 0;
+
+ try
+ {
+ intValue = Integer.parseInt(valueToken);
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add(" The '" + valueToken + "' is an invalid integer value for the attribute '"+ type
+ + "' for node: " + nodepath + ". The valid value should be an integer from -2147483648 to 2147483647");
+ validValue = false;
+ }
+
+ // Check this value against any min/max constraints specified for this node
+
+ String minStrValue = (String) parameters.get("min");
+
+ if (minStrValue != null)
+ {
+ try
+ {
+ int minIntValue = Integer.parseInt(minStrValue);
+
+ if (validValue && intValue < minIntValue)
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is less than minimum value constraint '" +
+ minStrValue + "' for node: " + nodepath);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add("Invalid min value '" + minStrValue + "' for node: " + nodepath
+ + ". The valid value should be an integer from -2147483648 to 2147483647");
+ }
+ }
+
+ String maxStrValue = (String) parameters.get("max");
+
+ if (maxStrValue != null)
+ {
+ try
+ {
+ int maxIntValue = Integer.parseInt(maxStrValue);
+
+ if (validValue && intValue > maxIntValue)
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is greater than maximum value constraint '" +
+ maxStrValue + "' for node: " + nodepath);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add("Invalid max value '" + maxStrValue + "' for node: " + nodepath
+ + ". The valid value should be an integer from -2147483648 to 2147483647");
+ }
+ }
+ }
+ else if (nodeType != null && nodeType.equalsIgnoreCase("float"))
+ {
+ // Attempt to parse this value into a float - if we get a NumberFormat Exception, flag this
+ // as an invalid value.
+
+ boolean validValue = true;
+ float floatValue = 0;
+
+ try
+ {
+ floatValue = Float.parseFloat(valueToken);
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add(type + " attribute '" + valueToken + "' is an invalid float value for node: " + nodepath);
+ validValue = false;
+ }
+
+ // Check this value against any min/max constraints specified for this node
+
+ String minStrValue = (String) parameters.get("min");
+
+ if (minStrValue != null)
+ {
+ try
+ {
+ float minFloatValue = Float.parseFloat(minStrValue);
+
+ if (validValue && floatValue < minFloatValue)
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is less than minimum value constraint '" +
+ minStrValue + "' for node: " + nodepath);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add("The attribute 'min' contains invalid float value '" + minStrValue + "' for the node: " + nodepath);
+ }
+ }
+
+ String maxStrValue = (String) parameters.get("max");
+
+ if (maxStrValue != null)
+ {
+ try
+ {
+ float maxFloatValue = Float.parseFloat(maxStrValue);
+
+ if (validValue && floatValue > maxFloatValue)
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is greater than maximum value constraint '" +
+ maxStrValue + "' for node: " + nodepath);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add("The attribute 'max' contains invalid float value '" + maxStrValue + "' for the node: " + nodepath);
+ }
+ }
+ }
+ else if (nodeType != null && nodeType.equalsIgnoreCase("date"))
+ {
+ // Attempt to parse this value into a date - if we get an IllegalArgument Exception, flag this
+ // as an invalid value.
+
+ boolean validValue = true;
+ DateTimeFormatter fmt = ISODateTimeFormat.dateParser();
+ DateTime dateValue = null;
+
+ try
+ {
+ dateValue = fmt.parseDateTime(valueToken);
+ }
+ catch (IllegalArgumentException e)
+ {
+ problemsList.add(type + " attribute '" + valueToken + "' is an invalid date value for node: " + nodepath
+ + ". The valid value type 'date' should be in the one of valid ISO8601 formats, for example 'YYYY-MM-DD', 'YYYY-MM', 'YYY-DDD', 'YYYY-Wxx-d', 'YYYYMMDD', etc.");
+ validValue = false;
+ }
+
+ // Check this value against any min/max constraints specified for this node
+
+ String minStrValue = (String) parameters.get("min");
+
+ if (minStrValue != null)
+ {
+ try
+ {
+ DateTime minDateValue = fmt.parseDateTime(minStrValue);
+
+ if (validValue && dateValue.isBefore(minDateValue))
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is less than minimum value constraint '" +
+ minStrValue + "' for node: " + nodepath);
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ problemsList.add("The attribute 'min' contains invalid value '" + minStrValue + "' for the node: " + nodepath
+ + ". The valid value type 'date' should be in the one of valid ISO8601 formats, for example 'YYYY-MM-DD', 'YYYY-MM', 'YYY-DDD', 'YYYY-Wxx-d', 'YYYYMMDD', etc.");
+ }
+ }
+
+ String maxStrValue = (String) parameters.get("max");
+
+ if (maxStrValue != null)
+ {
+ try
+ {
+ DateTime maxDateValue = fmt.parseDateTime(maxStrValue);
+
+ if (validValue && dateValue.isAfter(maxDateValue))
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is greater than maximum value constraint '" +
+ maxStrValue + "' for node: " + nodepath);
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ problemsList.add("The attribute 'max' contains invalid value '" + maxStrValue + "' for the node: " + nodepath
+ + ". The valid value type 'date' should be in the one of valid ISO8601 formats, for example 'YYYY-MM-DD', 'YYYY-MM', 'YYY-DDD', 'YYYY-Wxx-d', 'YYYYMMDD', etc.");
+ }
+ }
+ }
+ else if (nodeType != null && nodeType.equalsIgnoreCase("time"))
+ {
+ // Attempt to parse this value into a time - if we get an IllegalArgument Exception, flag this
+ // as an invalid value.
+
+ boolean validValue = true;
+ DateTimeFormatter fmt = ISODateTimeFormat.timeParser();
+ DateTime timeValue = null;
+
+ try
+ {
+ timeValue = fmt.parseDateTime(valueToken);
+ }
+ catch (IllegalArgumentException e)
+ {
+ problemsList.add(type + " attribute '" + valueToken + "' is an invalid time value for node: " + nodepath
+ + ". The valid value type 'time' should be in the one of valid ISO8601 formats, for example 'hh:mm:ss', 'hh:mm', 'hhmmss', 'hhmm', 'hh', etc.");
+ validValue = false;
+ }
+
+ // Check this value against any min/max constraints specified for this node
+
+ String minStrValue = (String) parameters.get("min");
+
+ if (minStrValue != null)
+ {
+ try
+ {
+ DateTime minTimeValue = fmt.parseDateTime(minStrValue);
+
+ if (validValue && timeValue.isBefore(minTimeValue))
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is less than minimum value constraint '" +
+ minStrValue + "' for node: " + nodepath);
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ problemsList.add("The attribute 'min' contains invalid value '" + minStrValue + "' for the node: " + nodepath
+ + ". The valid value type 'time' should be in the one of valid ISO8601 formats, for example 'hh:mm:ss', 'hh:mm', 'hhmmss', 'hhmm', 'hh', etc.");
+ }
+ }
+
+ String maxStrValue = (String) parameters.get("max");
+
+ if (maxStrValue != null)
+ {
+ try
+ {
+ DateTime maxTimeValue = fmt.parseDateTime(maxStrValue);
+
+ if (validValue && timeValue.isAfter(maxTimeValue))
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is greater than maximum value constraint '" +
+ maxStrValue + "' for node: " + nodepath);
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ problemsList.add("The attribute 'min' contains invalid value '" + maxStrValue + "' for the node: " + nodepath
+ + ". The valid value type 'time' should be in the one of valid ISO8601 formats, for example 'hh:mm:ss', 'hh:mm', 'hhmmss', 'hhmm', 'hh', etc.");
+ }
+ }
+ }
+ else if (nodeType != null && nodeType.equalsIgnoreCase("chr"))
+ {
+ // Checks for min/maxLength violations
+
+ String minLenValue = (String) parameters.get("minLen");
+
+ if (minLenValue != null)
+ {
+ try
+ {
+ int minLenIntValue = Integer.parseInt(minLenValue);
+
+ if (valueToken.length() < minLenIntValue)
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is less than minimum length value constraint '" +
+ minLenValue + "' for node: " + nodepath);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add("Invalid minLen value '" + minLenValue + "' for node: " + nodepath);
+ }
+ }
+
+ String maxLenValue = (String) parameters.get("maxLen");
+
+ if (maxLenValue != null)
+ {
+ try
+ {
+ int maxLenIntValue = Integer.parseInt(maxLenValue);
+
+ if (valueToken.length() > maxLenIntValue)
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is greater than maximum length value constraint: '" +
+ maxLenValue + "' for node: " + nodepath);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add("Invalid maxLen value '" + maxLenValue + "' for node: " + nodepath);
+ }
+ }
+ }
+ else if (nodeType != null && nodeType.equalsIgnoreCase("bin"))
+ {
+ //Check for the correct binary value
+
+ if (valueToken.length() % 2 > 0) {
+ problemsList.add("The attribute '" + type.toLowerCase() + "' for the node " + nodepath
+ + " contains invalid binary value '" + valueToken + "'. \n"
+ + "The valid value should be a string with the following constrains: \n"
+ + " - No empty spaces and leadings '0x' and '%'; \n"
+ + " - The length of the value should be even number; \n"
+ + " - Value may contain only digits form '0' to '9' and letters from 'A' to 'F' ('a' to 'f'); \n"
+ + "Sample: 0130AB0fc33d");
+ }else{
+ try
+ {
+ String tmp;
+ for (int i = 0; i < valueToken.length() - 1; i++) {
+ tmp = valueToken.substring(i, i+2);
+ Integer.parseInt(tmp, 16);
+ i++;
+ }
+ }catch(NumberFormatException e){
+ problemsList.add("The attribute '" + type.toLowerCase() + "' for the node " + nodepath
+ + " contains invalid binary value '" + valueToken + "'. \n"
+ + "The valid value should be a string with the following constrains: \n"
+ + " - No empty spaces and leadings '0x' and '%'; \n"
+ + " - The length of the value should be even number; \n"
+ + " - Value may contain only digits form '0' to '9' and letters from 'A' to 'F' ('a' to 'f'); \n"
+ + "Sample: 0130AB0fc33d");
+ }
+ }
+ // Checks for min/maxLength violations. Compare with 1/2 length of the string representation
+
+ String minLenValue = (String) parameters.get("minLen");
+
+ if (minLenValue != null)
+ {
+ try
+ {
+ int minLenIntValue = Integer.parseInt(minLenValue);
+
+ if ((valueToken.length())/2 < minLenIntValue)
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is less than minimum length value constraint '" +
+ minLenValue + "' for node: " + nodepath);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add("Invalid minLen value '" + minLenValue + "' for node: " + nodepath);
+ }
+ }
+
+ String maxLenValue = (String) parameters.get("maxLen");
+
+ if (maxLenValue != null)
+ {
+ try
+ {
+ int maxLenIntValue = Integer.parseInt(maxLenValue);
+
+ if ((valueToken.length())/2 > maxLenIntValue)
+ {
+ problemsList.add(type + " attribute '" + valueToken +
+ "' is greater than maximum length value constraint: '" +
+ maxLenValue + "' for node: " + nodepath);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ problemsList.add("Invalid maxLen value '" + maxLenValue + "' for node: " + nodepath);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if(!"Value".equalsIgnoreCase(type)){
+ problemsList.add(type + " attribute may not be an empty string for the node: " + nodepath);
+ }
+ }
+ }
+
+ // Utility function to remove spaces in a comma-seperated list (for values MA)
+ private String removeSpaces(String line)
+ {
+ int i = 0;
+
+ if ((i = line.indexOf(' ', i)) >= 0)
+ {
+ char [] line2 = line.toCharArray();
+ StringBuffer buf = new StringBuffer(line2.length);
+ buf.append(line2, 0, i).append("");
+
+ i++;
+ int j = i;
+
+ while ((i = line.indexOf(' ', i)) > 0)
+ {
+ buf.append(line2, j, i - j).append("");
+ i++;
+ j = i;
+ }
+
+ buf.append(line2, j, line2.length - j);
+ return buf.toString();
+ }
+
+ return line;
+ }
+
+ // Utility function to parse the contents of parm.txt files in each DMT directory
+ private void getParms(String fileName,HashMap parameters,ArrayList access) throws Exception
+ {
+ Reader reader = NodeLoader.getReader(fileName);
+ BufferedReader in = new BufferedReader(reader);
+ String line;
+
+ try
+ {
+ while ((line = in.readLine()) != null)
+ {
+ if(line.trim().length() == 0 || line.trim().startsWith("#")){
+ continue;
+ }
+
+ int nameBoundary = line.indexOf(":");
+ if(nameBoundary <= 0){
+ problemsList.add("The line '"+line+"' doesn't contain ':' simbol in the file " + fileName
+ + ". The valid attribute/value pair should be separated by ':'.");
+ continue;
+ }
+
+ String parmName = line.substring(0,nameBoundary);
+ String parmValue = line.substring(nameBoundary + 1);
+
+ // if(parmValue == null || parmValue.trim().length() == 0){
+ // problemsList.add("The line '"+line+"' doesn't contain any value after simbol ':' in the file " + fileName + ". Please add value or remove unused parameter.");
+ // }
+ if (parmName.equalsIgnoreCase("type"))
+ {
+ if (parmValue.equalsIgnoreCase("boolean"))
+ {
+ parmValue="bool";
+ }
+
+ parameters.put("Type", parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("storesPD"))
+ {
+ parameters.put("storesPD",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("HandledByPlugin"))
+ {
+ parameters.put("HandledByPlugin",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("ID"))
+ {
+ parameters.put("ID",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("minLen"))
+ {
+ parameters.put("minLen",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("maxLen"))
+ {
+ parameters.put("maxLen",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("maxChild"))
+ {
+ parameters.put("maxChild",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("min"))
+ {
+ parameters.put("min",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("max"))
+ {
+ parameters.put("max",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("values"))
+ {
+ parameters.put("values",trimSepSpaces(parmValue));
+ }
+
+ else if (parmName.equalsIgnoreCase("regexp"))
+ {
+ parameters.put("regexp",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("nMaxLen"))
+ {
+ parameters.put("nMaxLen",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("nValues"))
+ {
+ parameters.put("nValues",removeSpaces(parmValue.trim()));
+ }
+
+ else if (parmName.equalsIgnoreCase("nRegexp"))
+ {
+ parameters.put("nRegexp",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("auto"))
+ {
+ parameters.put("auto",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("fk"))
+ {
+ parameters.put("fk",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("child"))
+ {
+ parameters.put("child",removeSpaces(parmValue.trim()));
+ }
+
+ else if (parmName.equalsIgnoreCase("depend"))
+ {
+ parameters.put("depend",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("recur-after-segment"))
+ {
+ parameters.put("recur-after-segment",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("max-recurrence"))
+ {
+ parameters.put("max-recurrence",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("acl"))
+ {
+ parameters.put("Acl", parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("event"))
+ {
+ ArrayList arrEvents = new ArrayList();
+ if(parmValue.trim().indexOf(' ') > -1){
+ arrEvents.add(parmValue.trim()); //error... cannot contain empty space... will be handled later
+ }
+ else{
+ StringTokenizer tok = new StringTokenizer(parmValue.trim(), "&");
+ while (tok.hasMoreTokens())
+ {
+ String event = tok.nextToken().trim();
+ arrEvents.add(event);
+ }
+ }
+ parameters.put("Event", arrEvents);
+ }
+
+ else if (parmName.equalsIgnoreCase("default"))
+ {
+ parameters.put("Default", parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("value"))
+ {
+ parameters.put("Value", parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("mime"))
+ {
+ parameters.put("Mime", parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("access"))
+ {
+ StringTokenizer tok = new StringTokenizer(parmValue, ",");
+ ArrayList tmpAccess = new ArrayList();
+
+ while (tok.hasMoreTokens())
+ {
+ String accessType = tok.nextToken().trim();
+ tmpAccess.add(accessType);
+ }
+ parameters.put("AccessType", tmpAccess);
+ }
+
+ else if (parmName.equalsIgnoreCase("nodatagen"))
+ {
+ parameters.put("DataGen", new Boolean(false));
+ }
+
+ else if (parmName.equalsIgnoreCase("nometagen"))
+ {
+ parameters.put("MetaGen", new Boolean(false));
+ }
+
+ else if (parmName.equalsIgnoreCase("store"))
+ {
+ parameters.put("store",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("LOBProgressBAR"))
+ {
+ parameters.put("LOBProgressBAR",parmValue.trim());
+ }
+
+ else if (parmName.equalsIgnoreCase("description"))
+ {
+ String docstr = parmValue;
+ while ((line = in.readLine()) != null)
+ docstr += line;
+ parameters.put("Description", docstr);
+ continue;
+ }
+ else{
+ problemsList.add("The attribute name '" + parmName + "' is not supported in the file: " + fileName);
+ }
+ }// while loop
+ }finally{
+ try
+ {
+ in.close();
+ }catch(Exception e){}
+ try
+ {
+ reader.close();
+ }catch(Exception e){}
+
+ in = null;
+ reader = null;
+ }
+ }
+
+ private String trimSepSpaces(String parmValue) throws Exception {
+ String sep = ",";
+ StringTokenizer tok = new StringTokenizer(parmValue, sep);
+ StringBuffer sb = new StringBuffer();
+ String tmp;
+ while (tok.hasMoreTokens())
+ {
+ tmp = tok.nextToken().trim();
+ if(sb.length() > 0){
+ tmp = sep + tmp;
+ }
+ sb.append(tmp);
+
+ }
+ return sb.toString();
+ }
+
+ //validate values from attribute event
+ private boolean validateEventValues(String event, ArrayList arrEvents,
+ boolean isLeaf, HashMap mapNotifyAndIgnoreVals){
+
+ if(event.indexOf(' ') > -1){
+ return false; //not allow empty spaces...
+ }
+ else if("Add".equals(event) || "Delete".equals(event) ||
+ "Replace".equals(event) || "Indirect".equals(event) ){
+ return true;
+ }
+ else if("Node".equals(event)){
+ if(arrEvents.contains("Detail") || arrEvents.contains("Cumulative")){ // cannot be together with "Node"
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+ else if("Detail".equals(event)){
+ if(arrEvents.contains("Node") || arrEvents.contains("Cumulative")){ // cannot be together with "Detail"
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+ else if("Cumulative".equals(event)){
+ if(arrEvents.contains("Detail") || arrEvents.contains("Node") || isLeaf){ // cannot be together with "Cumulative" and interior nodes only
+ return false;
+ }
+ else{
+ return true;
+ }
+ }
+ else if(event.startsWith("Topic=")){
+ if (event.length() > "Topic=".length()){
+ return true; // check if has value like Topic=ABC
+ }else{
+ return false;
+ }
+ }
+ else if(event.startsWith("Ignore=") || event.startsWith("Notify=")){
+ // !!! length of "Ignore=" and "Notify=" is the same and equals 7 !!!!
+ if (event.length() == 7){
+ return false; // check that value is not empty like Ignore=
+ }else{
+ String vals = event.substring(7);
+ StringTokenizer tok = new StringTokenizer(vals, "+");
+ String tmp;
+ while (tok.hasMoreTokens()){
+ tmp = tok.nextToken();
+ if(mapNotifyAndIgnoreVals.containsKey(tmp.toUpperCase())){
+ return false; // This value for key "Ignore" or "Notify" already has been used
+ }
+ else{
+ mapNotifyAndIgnoreVals.put(tmp.toUpperCase(), tmp.toUpperCase());
+ }
+ }
+ return true;
+ }
+ }
+ else {
+ return false; // unsupported parameter for attribute 'event'
+ }
+ }
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/FactBootEnc.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/FactBootEnc.java
new file mode 100644
index 0000000..a7f107f
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/FactBootEnc.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//==================================================================================================
+//
+// Module Name: FactBootEnc
+//
+// General Description: Factory bootstrap encoder. Converts special bytes from parm.txt to their HEX
+// presentation for the factory bootstrap.
+//
+//==================================================================================================
+
+package com.mot.dm.core;
+
+import java.io.*;
+import com.mot.dm.io.Node;
+import com.mot.dm.io.NodeLoader;
+import com.mot.dm.tool.Util;
+
+
+public class FactBootEnc {
+ //GUID
+ public static final String GUID_HEX_BOOTSTRAP =
+ "Factory_bootstrap_settings_encoding_HEX:";
+
+ public static final String SEP = File.separator;
+
+ // HEX encoding
+ public static final String DMACC_FACTORY_BOOTSTRAP_CLIENTPW_HEX =
+ "EBE8EFEEECEC";
+ public static final String DMACC_FACTORY_BOOTSTRAP_SERVERPW_HEX =
+ "FCE9E2E4E0E0";
+ public static final String DMACC_FACTORY_BOOTSTRAP_USERNAME_HEX =
+ "E0E5E7EAEBEB";
+
+ //for DM 1.1.2 ./SyncML/DMAcc/[]/....
+ public static String BOOTSTRAP_ROOT_112 = SEP.concat("Dmt").concat(SEP).concat("SyncML").concat(SEP).concat("DMAcc").concat(SEP);
+ public static String CLIENTPW_NODE_112 = "ClientPW".concat(SEP).concat("parm.txt");
+ public static String SERVERPW_NODE_112 = "ServerPW".concat(SEP).concat("parm.txt");
+ public static String USERNAME_NODE_112 = "UserName".concat(SEP).concat("parm.txt");
+
+ //for DM 1.2 ./DMAcc/[]/AppAuth/[]/....
+ public static String BOOTSTRAP_ROOT_12 = SEP.concat("Dmt").concat(SEP).concat("DMAcc").concat(SEP);
+ public static String BOOTSTRAP_MID_12 = "AppAuth".concat(SEP);
+ public static String CLIENTPW_NODE_12 = "AAuthSecret".concat(SEP).concat("parm.txt");
+ public static String SERVERPW_NODE_12 = "AAuthSecret".concat(SEP).concat("parm.txt");
+ public static String USERNAME_NODE_12 = "AAuthName".concat(SEP).concat("parm.txt");
+
+ //returns GUID_HEX_BOOTSTRAP + HEX factory bootstrap value or null in case if
+ //it is not factory bootstrap
+ public static final String checkForBootstrapValue(String path) throws
+ Exception {
+
+ //for DM 1.1.2
+ if ( path.indexOf(BOOTSTRAP_ROOT_112) > -1) {
+ if (path.endsWith(CLIENTPW_NODE_112) ||
+ path.endsWith(SERVERPW_NODE_112) ||
+ path.endsWith(USERNAME_NODE_112)) {
+ return hexBootstrapValue(path);
+ }
+ }
+ //for DM 1.2
+ else if (path.indexOf(BOOTSTRAP_ROOT_12) > -1 &&
+ path.indexOf(BOOTSTRAP_MID_12) > -1) {
+ if (path.endsWith(CLIENTPW_NODE_12) ||
+ path.endsWith(SERVERPW_NODE_12) ||
+ path.endsWith(USERNAME_NODE_12)) {
+ return hexBootstrapValue(path);
+ }
+ }
+
+ return null;
+ }
+
+ //returns GUID_HEX_BOOTSTRAP + HEX factory bootstrap value or null in case if
+ //it is not a factory bootstrap
+ public static final String hexBootstrapValue(String path) throws Exception {
+ Reader reader = null;
+ BufferedReader br = null;
+ String hexEncodedValue = null;
+ try
+ {
+ Node node = NodeLoader.getInstance(path);
+ reader = NodeLoader.getReader(node);
+ br = new BufferedReader(reader);
+ String line;
+ //Read lines from parm.txt
+ while ( (line = br.readLine()) != null) {
+ line = line.toUpperCase();
+ //check for ClientPW
+ if (line.indexOf(DMACC_FACTORY_BOOTSTRAP_CLIENTPW_HEX) != -1) {
+ hexEncodedValue = DMACC_FACTORY_BOOTSTRAP_CLIENTPW_HEX;
+ break;
+ } //check for ServerPW
+ else if (line.indexOf(DMACC_FACTORY_BOOTSTRAP_SERVERPW_HEX) != -1) {
+ hexEncodedValue = DMACC_FACTORY_BOOTSTRAP_SERVERPW_HEX;
+ break;
+ } //check for UserName
+ else if (line.indexOf(DMACC_FACTORY_BOOTSTRAP_USERNAME_HEX) != -1) {
+ hexEncodedValue = DMACC_FACTORY_BOOTSTRAP_USERNAME_HEX;
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ throw e;
+ }
+ finally {
+ try {
+ br.close();
+ }
+ catch (Exception e) {}
+
+ try {
+ reader.close();
+ }
+ catch (Exception e) {}
+ }
+
+
+
+
+ if (hexEncodedValue != null) {
+ //factory bootstrap profile found
+ hexEncodedValue = GUID_HEX_BOOTSTRAP.concat(hexEncodedValue);
+ }
+
+ return hexEncodedValue;
+ }
+
+
+ // Test for the functions checkForBootstrapValue() and hexBootstrapValue()
+ public void testMe(String path) throws Exception {
+ File f = new File(path);
+ if (f.isDirectory()) {
+ File[] listFiles = f.listFiles();
+ for (int i = 0; i < listFiles.length; i++) {
+ if (listFiles[i].isDirectory()) {
+ testMe(listFiles[i].getAbsolutePath());
+ }
+ else {
+ String val = checkForBootstrapValue(listFiles[i].getAbsolutePath());
+ if (val != null) {
+ System.out.println("path: " + listFiles[i].getAbsolutePath());
+ System.out.println("val: " + val + "\n");
+ }
+ }
+ }
+ }
+ else {
+ String val = checkForBootstrapValue(f.getAbsolutePath());
+ if (val != null) {
+ System.out.println("path: " + f.getAbsolutePath());
+ System.out.println("val: " + val + "\n");
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ if (args.length != 1) {
+ System.out.println("usage: java FactBootEnc <path>/Dmt");
+ System.exit(1);
+ }
+ FactBootEnc t = new FactBootEnc();
+ t.testMe(args[0]);
+ }
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/Gen.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/Gen.java
new file mode 100644
index 0000000..4de63a9
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/Gen.java
@@ -0,0 +1,2992 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//==================================================================================================
+//
+// Module Name: Gen
+//
+// General Description: The classes contained here provide a depth first recursive traversal of the
+// Dmt.zip directory heirarchy, and generate the necessary data and meta data
+// files that make up the data store for the DMT on the device.
+//
+//==================================================================================================
+
+package com.mot.dm.core;
+
+//Necessary Java language imports
+import java.io.File;
+import java.io.Reader;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.PrintWriter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.DataOutputStream;
+
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import com.mot.dm.io.Node;
+import com.mot.dm.io.NodeLoader;
+import com.mot.dm.tool.Util;
+
+//Encapsulate multiple data files
+class Archives {
+ HashMap archivesMap; //path, printWriter
+ public Archives(String fstabname) throws Exception {
+ archivesMap = new HashMap();
+ BufferedReader reader = new BufferedReader(Util.openUtf8FileReader(fstabname));
+
+ String line = null;
+ while ( (line = reader.readLine()) != null) {
+ if (line.length() == 0 || line.startsWith("#")) {
+ continue;
+ }
+ StringTokenizer tokener = new StringTokenizer(line);
+ String path = tokener.nextToken();
+ String filename = tokener.nextToken();
+ int index = filename.lastIndexOf(".wbxml");
+ filename = filename.substring(0, index) + ".xml";
+ PrintWriter fwriter = new PrintWriter(Util.openUtf8FileWriter(filename));
+ archivesMap.put(path, fwriter);
+ }
+ reader.close();
+ reader = null;
+ }
+
+ //print to all nodes
+ public void printAll(String s) throws IOException {
+ Iterator it = archivesMap.values().iterator();
+ while (it.hasNext()) {
+ PrintWriter writer = (PrintWriter) it.next();
+ writer.print(s);
+ }
+ }
+
+ public void print(String path, String s) throws IOException {
+ Iterator it = archivesMap.entrySet().iterator();
+ String myfilerootpath = null;
+ PrintWriter myfilewriter = null;
+ int longestmatch = 0;
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry) it.next();
+ String rootpath = (String) entry.getKey();
+ PrintWriter writer = (PrintWriter) entry.getValue();
+
+ //See which directory contains the path
+ int len = rootpath.length();
+ if (path.indexOf(rootpath) == 0 && longestmatch < len) {
+ longestmatch = len;
+ myfilerootpath = rootpath;
+ myfilewriter = writer;
+ }
+ }
+
+ if (myfilerootpath != null) {
+ myfilewriter.print(s);
+ }
+ }
+
+ public void close() throws IOException {
+ Iterator it = archivesMap.values().iterator();
+ while (it.hasNext()) {
+ PrintWriter writer = (PrintWriter) it.next();
+ writer.close();
+ }
+ archivesMap.clear();
+ }
+}
+
+class DocumentationIndexObject {
+ public String nodeName;
+ public String nodeType;
+ public String nodeDesc;
+ public String linkToNode;
+
+ public DocumentationIndexObject() {
+ }
+}
+
+class Documentation {
+ final static private String dmtdoc = "index.html";
+ final static private String dmttoc = "toc.html";
+ final static private String dmtdesc = "desc.html";
+ final static private String dmtindex = "index-all.html";
+ private PrintWriter docWriter = null;
+ private PrintWriter tocWriter = null;
+ private PrintWriter descWriter = null;
+ private PrintWriter indexWriter = null;
+ private SortedMap indexMap = null;
+ private int indexDupCtr = 0;
+ private StringBuffer indexHdrFtr = null;
+ private StringBuffer descHdrFtr = null;
+
+ public Documentation() throws Exception {
+ // Setup our index and desc HdrFtr buffers
+ indexHdrFtr = new StringBuffer();
+ descHdrFtr = new StringBuffer();
+
+ // Setup sortedMap (TreeMap) to store our index objects
+ indexMap = new TreeMap();
+
+ // main page
+ generateMainPage();
+
+ tocWriter = new PrintWriter(Util.openUtf8FileWriter(dmttoc));
+ descWriter = new PrintWriter(Util.openUtf8FileWriter(dmtdesc));
+ indexWriter = new PrintWriter(Util.openUtf8FileWriter(dmtindex));
+
+ // initial toc page
+ generateTocHeader();
+
+ // initial description page
+ generateDescHeader();
+ }
+
+ private void generateHeader(PrintWriter writer, String title) throws
+ IOException {
+ writer.println("<HTML>");
+ writer.println("<HEAD>");
+ writer.println("<TITLE>");
+ writer.println(title);
+ writer.println("</TITLE>");
+ writer.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
+ writer.println("</HEAD>");
+ }
+
+ private void generateTrailer(PrintWriter writer) throws IOException {
+ writer.println("</HTML>");
+ }
+
+ private void generateMainPage() throws IOException {
+ docWriter = new PrintWriter(Util.openUtf8FileWriter(dmtdoc));
+ generateHeader(docWriter, "Device Management Tree Documentation");
+
+ docWriter.println("<FRAMESET cols=\"40%,60%\">");
+ docWriter.println("<FRAME src=\"toc.html\" name=\"tocFrame\">");
+ docWriter.println("<FRAME src=\"desc.html\" name=\"descFrame\">");
+ docWriter.println("</FRAMESET>");
+
+ generateTrailer(docWriter);
+ docWriter.close();
+ }
+
+ private void generateTocHeader() throws IOException {
+ generateHeader(tocWriter, "TOC");
+ tocWriter.println("<BODY BGCOLOR=\"white\">");
+ tocWriter.println("<TABLE BORDER=\"0\" WIDTH=\"100%\">");
+ tocWriter.println("<TR>");
+ tocWriter.println("<TD NOWRAP>");
+ }
+
+ private void generateTocTrailer() throws IOException {
+ tocWriter.println("</TD>");
+ tocWriter.println("</TR>");
+ tocWriter.println("</TABLE>");
+ tocWriter.println("</BODY>");
+ generateTrailer(tocWriter);
+ }
+
+ private void generateDescHeader() throws IOException {
+ descWriter.println("<HTML>");
+ descWriter.println("<HEAD>");
+ descWriter.println("<TITLE>");
+ descWriter.println("Description");
+ descWriter.println("</TITLE>");
+ descWriter.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
+ descWriter.println("<LINK REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"stylesheet.css\" TITLE=\"Style\">");
+ descWriter.println("</HEAD>");
+
+ descHdrFtr.append(
+ "<TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"1\" CELLSPACING=\"0\">");
+ descHdrFtr.append("<TR>");
+ descHdrFtr.append(
+ "<TD COLSPAN=2 BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\">");
+ descHdrFtr.append("<A NAME=\"navbar_top_firstrow\"><!-- --></A>");
+ descHdrFtr.append(
+ "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"3\">");
+ descHdrFtr.append("<TR ALIGN=\"center\" VALIGN=\"top\">");
+ descHdrFtr.append("<TD BGCOLOR=\"#FFFFFF\" CLASS=\"NavBarCell1Rev\"> &nbsp;<FONT CLASS=\"NavBarFont1Rev\"><B>Node List</B></FONT>&nbsp;</TD>");
+ descHdrFtr.append("<TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"><A HREF=\"index-all.html\"><FONT CLASS=\"NavBarFont1\"><B>Index</B></FONT></A>&nbsp;</TD>");
+ //descHdrFtr.append("<TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"><A HREF=\"help-doc.html\"><FONT CLASS=\"NavBarFont1\"><B>Help</B></FONT></A>&nbsp;</TD>");
+ descHdrFtr.append("</TR>");
+ descHdrFtr.append("</TABLE>");
+ descHdrFtr.append("</TD>");
+ descHdrFtr.append("<TD ALIGN=\"right\" VALIGN=\"top\" ROWSPAN=3><EM>");
+ descHdrFtr.append("</EM>");
+ descHdrFtr.append("</TD>");
+ descHdrFtr.append("</TR>");
+ descHdrFtr.append("</TABLE>");
+
+ descWriter.println(descHdrFtr.toString());
+ descWriter.println("<HR>");
+ }
+
+ private void generateDescTrailer() throws IOException {
+ descWriter.println(descHdrFtr.toString());
+ generateTrailer(descWriter);
+ }
+
+ private void generateIndex() {
+ // Write out our header info
+
+ indexWriter.println("<HTML>");
+ indexWriter.println("<HEAD>");
+ indexWriter.println("<TITLE>");
+ indexWriter.println("Index");
+ indexWriter.println("</TITLE>");
+ indexWriter.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
+ indexWriter.println("<LINK REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"stylesheet.css\" TITLE=\"Style\">");
+ indexWriter.println("</HEAD>");
+
+ indexHdrFtr.append(
+ "<TABLE BORDER=\"0\" WIDTH=\"100%\" CELLPADDING=\"1\" CELLSPACING=\"0\">");
+ indexHdrFtr.append("<TR>");
+ indexHdrFtr.append(
+ "<TD COLSPAN=2 BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\">");
+ indexHdrFtr.append("<A NAME=\"navbar_top_firstrow\"><!-- --></A>");
+ indexHdrFtr.append(
+ "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"3\">");
+ indexHdrFtr.append("<TR ALIGN=\"center\" VALIGN=\"top\">");
+ indexHdrFtr.append("<TD BGCOLOR=\"#FFFFFF\" CLASS=\"NavBarCell1\"> &nbsp;<A HREF=\"desc.html\"><FONT CLASS=\"NavBarFont1\"><B>Node List</B></FONT></A>&nbsp;</TD>");
+ indexHdrFtr.append("<TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1Rev\"><FONT CLASS=\"NavBarFont1Rev\"><B>Index</B></FONT>&nbsp;</TD>");
+ //indexHdrFtr.append("<TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"><A HREF=\"help-doc.html\"><FONT CLASS=\"NavBarFont1\"><B>Help</B></FONT></A>&nbsp;</TD>");
+ indexHdrFtr.append("</TR>");
+ indexHdrFtr.append("</TABLE>");
+ indexHdrFtr.append("</TD>");
+ indexHdrFtr.append("<TD ALIGN=\"right\" VALIGN=\"top\" ROWSPAN=3><EM>");
+ indexHdrFtr.append("</EM>");
+ indexHdrFtr.append("</TD>");
+ indexHdrFtr.append("</TR>");
+ indexHdrFtr.append("</TABLE>");
+
+ Set keys = indexMap.keySet();
+ Iterator indexShortcutKeys = keys.iterator();
+ String firstLetter = "";
+
+ // Build set of first letter shortcuts to index pages
+
+ while (indexShortcutKeys.hasNext()) {
+ String tmpKey = (String) indexShortcutKeys.next();
+
+ if (!tmpKey.substring(0, 1).equalsIgnoreCase(firstLetter)) {
+ firstLetter = tmpKey.substring(0, 1);
+ indexHdrFtr.append("<A HREF=\"#_" + firstLetter.toUpperCase() + "_\">" +
+ firstLetter.toUpperCase() + "</A>&nbsp;&nbsp;");
+ }
+ }
+
+ // Build our list of indexed items
+
+ indexWriter.println(indexHdrFtr.toString());
+ indexWriter.println("<DL>");
+
+ Iterator indexListKeys = keys.iterator();
+ firstLetter = "";
+
+ while (indexListKeys.hasNext()) {
+ String tmpKey = (String) indexListKeys.next();
+
+ if (!tmpKey.substring(0, 1).equalsIgnoreCase(firstLetter)) {
+ firstLetter = tmpKey.substring(0, 1);
+ indexWriter.println("<HR><BR><A NAME=\"_" + firstLetter.toUpperCase() +
+ "_\"><!-- --></A>");
+ }
+
+ DocumentationIndexObject tmpIndex = (DocumentationIndexObject) indexMap.
+ get(tmpKey);
+ indexWriter.println("<DT><A HREF=\"desc.html#" + tmpIndex.linkToNode +
+ "\"><B>" + Gen.xmlEscapeNode(tmpIndex.nodeName) + "</B></A>" +
+ ( (tmpIndex.nodeType.equals("node")) ?
+ " - Interior Node" : " - Leaf Node") +
+ ( (tmpIndex.nodeDesc != null) ?
+ ": " + tmpIndex.nodeDesc : "") + "<BR><BR>");
+ }
+
+ indexWriter.println("</DL>");
+ indexWriter.println(indexHdrFtr.toString());
+ }
+
+ private void generateIndexTrailer() throws IOException {
+ generateTrailer(indexWriter);
+ }
+
+ public void addIndexEntry(String tocEntry, HashMap parms) {
+ DocumentationIndexObject tmpIndex = new DocumentationIndexObject();
+ String tmpKey;
+
+ if (!tocEntry.equals(".")) {
+ tmpKey = tocEntry.substring(tocEntry.lastIndexOf("/") + 1);
+
+ if (!tmpKey.equals("*") && !Character.isDigit(tmpKey.charAt(0))) {
+ tmpIndex.nodeName = tmpKey;
+ tmpIndex.nodeType = (String) parms.get("Type");
+
+ if (tocEntry.length() > 1) {
+ tmpIndex.linkToNode = tocEntry.substring(1);
+ }
+ else {
+ tmpIndex.linkToNode = tocEntry;
+
+ }
+ if (parms.get("Description") != null) {
+ tmpIndex.nodeDesc = (String) parms.get("Description");
+ }
+
+ if (!indexMap.containsKey(tmpKey.toLowerCase())) {
+ indexMap.put(tmpKey.toLowerCase(), tmpIndex);
+ }
+ else {
+ indexMap.put(tmpKey.toLowerCase() + indexDupCtr++, tmpIndex);
+ }
+ }
+ }
+ }
+
+ public void addTocEntry(String tocEntry) throws IOException {
+ String nodeName;
+
+ if (tocEntry.equals(".")) {
+ nodeName = tocEntry;
+ }
+ else if (tocEntry.length() > 1) {
+ nodeName = tocEntry.substring(1);
+ }
+ else {
+ nodeName = tocEntry;
+
+ }
+ tocWriter.println("<A HREF=\"desc.html#" + Gen.xmlEscapeNode(nodeName) +
+ "\" TARGET=\"descFrame\">" + Gen.xmlEscapeNode(nodeName) + "</A>");
+ tocWriter.println("<BR>");
+ }
+
+ public void addDescEntry(HashMap parms) throws IOException {
+ String nodeName;
+ String uri = null;
+
+ if (parms.get("URI") != null) {
+ uri = (String) parms.get("URI");
+ }
+ else {
+ return;
+ }
+
+ if (uri.equals(".")) {
+ nodeName = uri;
+ }
+ else if (uri.length() > 1) {
+ nodeName = uri.substring(1);
+ }
+ else {
+ nodeName = uri;
+
+ }
+ descWriter.println("<A NAME=\"" + Gen.xmlEscapeNode(nodeName) + "\" </A>");
+ descWriter.println("<p><b>" + Gen.xmlEscapeNode(nodeName) + "</b></p>");
+ descWriter.println("<p></p>");
+
+ if (parms.get("Description") != null) {
+ descWriter.println("<p>" + (String) parms.get("Description") + "</p>");
+ descWriter.println("<p></p>");
+ }
+
+ descWriter.println("<ul type=disc>");
+
+ if (parms.get("Type") != null) {
+ descWriter.println("<li>Format : " + (String) parms.get("Type") + "</li>");
+
+ }
+ if (parms.get("Mime") != null) {
+ descWriter.println("<li>Mime Type : " + (String) parms.get("Mime") +
+ "</li>");
+
+ }
+ if (parms.get("Acl") != null) {
+ descWriter.println("<li>ACL : " + (String) parms.get("Acl") + "</li>");
+
+ }
+ if (parms.get("Event") != null) {
+ descWriter.println("<li>Event : " + (String) parms.get("Event") + "</li>");
+
+ }
+ if (parms.get("AccessType") != null) {
+ ArrayList access = (ArrayList) parms.get("AccessType");
+ descWriter.print("<li>Access Types : ");
+ for (int i = 0; i < access.size(); i++) {
+ if (i > 0) {
+ descWriter.print(", ");
+ }
+ descWriter.print( (String) access.get(i));
+ }
+
+ descWriter.println("</li>");
+ }
+
+ if (parms.get("Default") != null) {
+ descWriter.println("<li>Default : " + (String) parms.get("Default") +
+ "</li>");
+
+ }
+ if (parms.get("Value") != null) {
+ descWriter.println("<li>Initial Value : " + (String) parms.get("Value") +
+ "</li>");
+
+ }
+ if (parms.get("values") != null) {
+ descWriter.println("<li>Possible Values : " + (String) parms.get("values") +
+ "</li>");
+
+ }
+ if (parms.get("minLen") != null) {
+ descWriter.println("<li>Min Length : " + (String) parms.get("minLen") +
+ "</li>");
+
+ }
+ if (parms.get("maxLen") != null) {
+ descWriter.println("<li>Max Length : " + (String) parms.get("maxLen") +
+ "</li>");
+
+ }
+ if (parms.get("HandledByPlugin") != null) {
+ descWriter.println("<li>Handled By Plugin : " +
+ (String) parms.get("HandledByPlugin") + "</li>");
+
+ }
+ if (parms.get("store") != null) {
+ descWriter.println("<li>LOB Store : " + (String) parms.get("store") +
+ "</li>");
+
+ }
+ if (parms.get("LOBProgressBAR") != null) {
+ descWriter.println("<li>LOB Progress Bar : " +
+ (String) parms.get("LOBProgressBAR") + "</li>");
+
+ }
+ if (parms.get("min") != null) {
+ descWriter.println("<li>Minimum Value : " + (String) parms.get("min") +
+ "</li>");
+
+ }
+ if (parms.get("max") != null) {
+ descWriter.println("<li>Maximum Value : " + (String) parms.get("max") +
+ "</li>");
+
+ }
+ if (parms.get("regexp") != null) {
+ descWriter.println("<li>RegExp : " + (String) parms.get("regexp") +
+ "</li>");
+
+ }
+ if (parms.get("nMaxLen") != null) {
+ descWriter.println("<li>Node Name Max Len : " +
+ (String) parms.get("nMaxLen") + "</li>");
+
+ }
+ if (parms.get("nValues") != null) {
+ descWriter.println("<li>Node Name Possible Values : " +
+ (String) parms.get("nValues") + "</li>");
+
+ }
+ if (parms.get("nRegexp") != null) {
+ descWriter.println("<li>Node Name Regexp : " +
+ (String) parms.get("nRegexp") + "</li>");
+
+ }
+ if (parms.get("auto") != null) {
+ descWriter.println("<li>Auto Node Creation : " +
+ (String) parms.get("auto") + "</li>");
+
+ }
+ if (parms.get("fk") != null) {
+ descWriter.println("<li>Foreign Key : " + (String) parms.get("fk") +
+ "</li>");
+
+ }
+ if (parms.get("child") != null) {
+ descWriter.println("<li>Child Node Deletion : " +
+ (String) parms.get("child") + "</li>");
+
+ }
+ if (parms.get("depend") != null) {
+ descWriter.println("<li>Deletion Dependency : " +
+ (String) parms.get("depend") + "</li>");
+
+ }
+ if (parms.get("recur-after-segment") != null) {
+ descWriter.println("<li>Recurse After Segment : " +
+ (String) parms.get("recur-after-segment") + "</li>");
+
+ }
+ if (parms.get("max-recurrence") != null) {
+ descWriter.println("<li>Maximum Recurrence : " +
+ (String) parms.get("max-recurrence") + "</li>");
+
+ }
+ descWriter.println("</ul>");
+ }
+
+ public void close() throws IOException {
+ generateTocTrailer();
+ tocWriter.close();
+
+ generateDescTrailer();
+ descWriter.close();
+
+ generateIndex();
+ generateIndexTrailer();
+ indexWriter.close();
+ }
+}
+
+class ByteSwapper {
+ public static long swapLong(long value) {
+ long b1 = (value >> 0) & 0xff;
+ long b2 = (value >> 8) & 0xff;
+ long b3 = (value >> 16) & 0xff;
+ long b4 = (value >> 24) & 0xff;
+ long b5 = (value >> 32) & 0xff;
+ long b6 = (value >> 40) & 0xff;
+ long b7 = (value >> 48) & 0xff;
+ long b8 = (value >> 56) & 0xff;
+
+ return b1 << 56 | b2 << 48 | b3 << 40 | b4 << 32 |
+ b5 << 24 | b6 << 16 | b7 << 8 | b8 << 0;
+ }
+
+ public static int swapInt(int value) {
+ int b1 = (value >> 0) & 0xff;
+ int b2 = (value >> 8) & 0xff;
+ int b3 = (value >> 16) & 0xff;
+ int b4 = (value >> 24) & 0xff;
+
+ return b1 << 24 | b2 << 16 | b3 << 8 | b4 << 0;
+ }
+
+ public static float swapFloat(float value) {
+ int intValue = Float.floatToIntBits(value);
+ intValue = swapInt(intValue);
+ return Float.intBitsToFloat(intValue);
+ }
+
+ public static short swapShort(short value) {
+ int b1 = value & 0xff;
+ int b2 = (value >> 8) & 0xff;
+
+ return (short) (b1 << 8 | b2 << 0);
+ }
+}
+
+class MDFNode {
+ public String nodeName;
+ public int nodeNameOffset;
+ public int nodeOffset;
+
+ public short nodeType;
+ public static final short NULL_TYPE = 0;
+ public static final short NULL_MN_TYPE = 128;
+ public static final short CHR_TYPE = 1;
+ public static final short CHR_MN_TYPE = 129;
+ public static final short INT_TYPE = 2;
+ public static final short INT_MN_TYPE = 130;
+ public static final short BOOL_TYPE = 3;
+ public static final short BOOL_MN_TYPE = 131;
+ public static final short BIN_TYPE = 4;
+ public static final short BIN_MN_TYPE = 132;
+ public static final short NODE_TYPE = 5;
+ public static final short NODE_MN_TYPE = 133;
+ public static final short DATE_TYPE = 8;
+ public static final short DATE_MN_TYPE = 136;
+ public static final short TEST_TYPE = 9;
+ public static final short TEST_MN_TYPE = 137;
+ public static final short TIME_TYPE = 10;
+ public static final short TIME_MN_TYPE = 138;
+ public static final short FLOAT_TYPE = 11;
+ public static final short FLOAT_MN_TYPE = 139;
+ public static final short STORES_PD = 256;
+ public static final short HANDLE_BY_PLUGIN = 512;
+ public static final short USE_NODE_ID = 1024;
+ public static final short LOB_STORE = 2048;
+ public static final short LOB_PROGRESS_BAR = 4096;
+
+ public String metaNodeID;
+ public int metaNodeIDOffset;
+
+ public byte accessType;
+ public static final byte ADD_ACCESS = 0x1;
+ public static final byte DELETE_ACCESS = 0x2;
+ public static final byte GET_ACCESS = 0x4;
+ public static final byte REPLACE_ACCESS = 0x8;
+ public static final byte EXEC_ACCESS = 0x10;
+ public static final byte LOCAL_ACCESS = 0x20;
+
+ public byte mimeType;
+ public static final byte TEXT_PLAIN = 0;
+
+ public byte numConstraints;
+ public List constraints;
+ public SortedMap children;
+
+ public MDFNode() {
+ constraints = new ArrayList();
+ children = new TreeMap();
+ }
+
+ public void addConstraint(MDFConstraint constraint) {
+ constraints.add(constraint);
+ }
+
+ public void addChild(String key, MDFNode node) {
+ children.put(key, node);
+ }
+
+ public void toBinary(DataOutputStream out) throws IOException {
+ out.writeInt(ByteSwapper.swapInt(nodeNameOffset));
+ out.writeShort(ByteSwapper.swapShort(nodeType));
+
+ if ( (nodeType & MDFNode.USE_NODE_ID) == MDFNode.USE_NODE_ID) {
+ out.writeInt(ByteSwapper.swapInt(metaNodeIDOffset));
+ }
+
+ out.writeByte(accessType);
+ out.writeByte(mimeType);
+ out.writeShort(ByteSwapper.swapShort( (short) children.size()));
+
+ if (children.size() > 0) {
+ Set childKeys = children.keySet();
+ Iterator childIterator = childKeys.iterator();
+
+ while (childIterator.hasNext()) {
+ out.writeInt(ByteSwapper.swapInt( ( (MDFNode) children.get(
+ childIterator.next())).nodeOffset));
+ }
+ }
+
+ out.writeByte(numConstraints);
+
+ if (numConstraints > 0) {
+ Iterator tmpConstraints = constraints.iterator();
+
+ while (tmpConstraints.hasNext()) {
+ ( (MDFConstraint) tmpConstraints.next()).toBinary(out);
+ }
+ }
+
+ if (children.size() > 0) {
+ Set childKeys = children.keySet();
+ Iterator childIterator = childKeys.iterator();
+
+ while (childIterator.hasNext()) {
+ ( (MDFNode) children.get(childIterator.next())).toBinary(out);
+ }
+ }
+ }
+
+ public String toString() {
+ StringBuffer tmpBuf = new StringBuffer();
+
+ tmpBuf.append("Node Name: " + nodeName);
+ tmpBuf.append("\nNode Name offset: " + nodeNameOffset);
+ tmpBuf.append("\nNode Offset: " + nodeOffset);
+ tmpBuf.append("\nNode Type: " + nodeType);
+
+ if ( (nodeType & MDFNode.USE_NODE_ID) == MDFNode.USE_NODE_ID) {
+ tmpBuf.append("\nMeta Node ID:" + metaNodeID);
+ tmpBuf.append("\nMeta Node ID offset:" + metaNodeIDOffset);
+ }
+
+ tmpBuf.append("\nNode Access Type: " + accessType);
+ tmpBuf.append("\nNode Mime Type: " + mimeType);
+ tmpBuf.append("\nNumber of Constraints: " + numConstraints);
+
+ if (children.size() > 0) {
+ tmpBuf.append("\nNumber of Children: " + children.size());
+ tmpBuf.append("\n============================================\n");
+
+ Set childKeys = children.keySet();
+ Iterator childIterator = childKeys.iterator();
+
+ while (childIterator.hasNext()) {
+ tmpBuf.append(children.get(childIterator.next()));
+ }
+
+ tmpBuf.append("\n---------------------------------------------");
+ tmpBuf.append("\n\n");
+ }
+
+ tmpBuf.append("\n---------------------------------------------\n");
+
+ Iterator tmpConstraints = constraints.iterator();
+
+ while (tmpConstraints.hasNext()) {
+ tmpBuf.append(tmpConstraints.next().toString());
+ }
+
+ tmpBuf.append("\n=============================================\n\n");
+
+ return tmpBuf.toString();
+ }
+}
+
+class MDFConstraint {
+ public byte constraintType;
+ public static final byte MIN_VALUE_CONSTRAINT = 1;
+ public static final byte MAX_VALUE_CONSTRAINT = 2;
+ public static final byte VALUES_CONSTRAINT = 3;
+ public static final byte DEFAULT_VALUE_CONSTRAINT = 4;
+ public static final byte MIN_LENGTH_CONSTRAINT = 5;
+ public static final byte MAX_LENGTH_CONSTRAINT = 6;
+ public static final byte REGEXP_CONSTRAINT = 7;
+ public static final byte NAME_MAX_LENGTH_CONSTRAINT = 8;
+ public static final byte NAME_VALUES_CONSTRAINT = 9;
+ public static final byte NAME_REGEXP_CONSTRAINT = 10;
+ public static final byte AUTONODE_CONSTRAINT = 11;
+ public static final byte RECUR_AFTER_CONSTRAINT = 12;
+ public static final byte MAX_RECUR_CONSTRAINT = 13;
+ public static final byte FOREIGN_KEY_CONSTRAINT = 14;
+ public static final byte DELETE_CHILD_CONSTRAINT = 15;
+ public static final byte DEPEND_CHILD_CONSTRAINT = 16;
+ public static final byte MAX_CHILD_CONSTRAINT = 17;
+
+ public byte defaultValueType;
+ public static final byte DEFAULT_INT_TYPE = 18;
+ public static final byte DEFAULT_CHR_TYPE = 19;
+ public static final byte DEFAULT_BYTE_TYPE = 20;
+ public static final byte DEFAULT_FLOAT_TYPE = 21;
+
+ public byte byteData;
+ public short shortData;
+ public int intData;
+ public float floatData;
+ public String chrData;
+ public int strDataOffset;
+
+ public MDFConstraint() {
+ }
+
+ public void toBinary(DataOutputStream out) throws IOException {
+ out.writeByte(constraintType);
+
+ switch (constraintType) {
+ case MDFConstraint.MIN_VALUE_CONSTRAINT:
+ case MDFConstraint.MAX_VALUE_CONSTRAINT:
+ out.writeInt(ByteSwapper.swapInt(intData));
+ break;
+
+ case MDFConstraint.VALUES_CONSTRAINT:
+ case MDFConstraint.REGEXP_CONSTRAINT:
+ case MDFConstraint.NAME_VALUES_CONSTRAINT:
+ case MDFConstraint.NAME_REGEXP_CONSTRAINT:
+ case MDFConstraint.AUTONODE_CONSTRAINT:
+ case MDFConstraint.RECUR_AFTER_CONSTRAINT:
+ case MDFConstraint.FOREIGN_KEY_CONSTRAINT:
+ case MDFConstraint.DELETE_CHILD_CONSTRAINT:
+ case MDFConstraint.DEPEND_CHILD_CONSTRAINT:
+ out.writeInt(ByteSwapper.swapInt(strDataOffset));
+ break;
+
+ case MDFConstraint.MIN_LENGTH_CONSTRAINT:
+ case MDFConstraint.MAX_LENGTH_CONSTRAINT:
+ case MDFConstraint.NAME_MAX_LENGTH_CONSTRAINT:
+ case MDFConstraint.MAX_CHILD_CONSTRAINT:
+ case MDFConstraint.MAX_RECUR_CONSTRAINT:
+ out.writeShort(ByteSwapper.swapShort(shortData));
+ break;
+
+ case MDFConstraint.DEFAULT_VALUE_CONSTRAINT:
+ switch (defaultValueType) {
+ case DEFAULT_INT_TYPE:
+ out.writeInt(ByteSwapper.swapInt(intData));
+ break;
+
+ case DEFAULT_FLOAT_TYPE:
+ out.writeFloat(ByteSwapper.swapFloat(floatData));
+ break;
+
+ case DEFAULT_BYTE_TYPE:
+ out.writeByte(byteData);
+ break;
+
+ case DEFAULT_CHR_TYPE:
+ out.writeInt(ByteSwapper.swapInt(strDataOffset));
+ break;
+ }
+ break;
+ }
+ }
+
+ public String toString() {
+ StringBuffer tmpBuf = new StringBuffer();
+
+ tmpBuf.append("Constraint Type: " + constraintType);
+ tmpBuf.append("\nConstraint Value: ");
+
+ switch (constraintType) {
+ case MDFConstraint.MIN_VALUE_CONSTRAINT:
+ case MDFConstraint.MAX_VALUE_CONSTRAINT:
+ tmpBuf.append(intData);
+ break;
+
+ case MDFConstraint.VALUES_CONSTRAINT:
+ case MDFConstraint.REGEXP_CONSTRAINT:
+ case MDFConstraint.NAME_VALUES_CONSTRAINT:
+ case MDFConstraint.NAME_REGEXP_CONSTRAINT:
+ case MDFConstraint.AUTONODE_CONSTRAINT:
+ case MDFConstraint.RECUR_AFTER_CONSTRAINT:
+ case MDFConstraint.FOREIGN_KEY_CONSTRAINT:
+ case MDFConstraint.DELETE_CHILD_CONSTRAINT:
+ case MDFConstraint.DEPEND_CHILD_CONSTRAINT:
+ tmpBuf.append(chrData + " - Offset: " + strDataOffset);
+ break;
+
+ case MDFConstraint.MIN_LENGTH_CONSTRAINT:
+ case MDFConstraint.MAX_LENGTH_CONSTRAINT:
+ case MDFConstraint.NAME_MAX_LENGTH_CONSTRAINT:
+ case MDFConstraint.MAX_CHILD_CONSTRAINT:
+ case MDFConstraint.MAX_RECUR_CONSTRAINT:
+ tmpBuf.append(shortData);
+ break;
+
+ case MDFConstraint.DEFAULT_VALUE_CONSTRAINT:
+ switch (defaultValueType) {
+ case DEFAULT_INT_TYPE:
+ tmpBuf.append(intData);
+ break;
+
+ case DEFAULT_FLOAT_TYPE:
+ tmpBuf.append(floatData);
+ break;
+
+ case DEFAULT_BYTE_TYPE:
+ tmpBuf.append(byteData);
+ break;
+
+ case DEFAULT_CHR_TYPE:
+ tmpBuf.append(chrData + " - Offset: " + strDataOffset);
+ break;
+ }
+ break;
+ }
+
+ tmpBuf.append("\n");
+ return tmpBuf.toString();
+ }
+}
+
+class DDFGen {
+ private static final String ddffile = "syncmldm.ddf";
+ private static final String shift = " ";
+ private PrintWriter ddfWriter = null;
+ private StringBuffer valuesForDDF = new StringBuffer();
+
+ public DDFGen() throws Exception {
+ ddfWriter = new PrintWriter(Util.openUtf8FileWriter(ddffile));
+
+ ddfWriter.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ ddfWriter.println("<!DOCTYPE MgmtTree SYSTEM \"http://www.openmobilealliance.com/tech/DTD/dm_ddf-v1_2.dtd\">");
+ ddfWriter.println("<MgmtTree>");
+ ddfWriter.println(shift + "<VerDTD>1.2</VerDTD>");
+ ddfWriter.println(shift + "<Man>Motorola</Man>");
+ ddfWriter.println(shift + "<Mod>" + Gen.phoneModel + "</Mod>");
+ }
+
+ public void addDDFForNode(HashMap parms, String indent) throws IOException {
+ ddfWriter.println(indent + "<Node>");
+ String nodeName = (String) parms.get("NodeName");
+ boolean multinode = false;
+
+ if (nodeName.equals("*")) {
+ multinode = true;
+
+ }
+ if (multinode) {
+ ddfWriter.println(indent + shift + "<NodeName/>");
+ }
+ else {
+ ddfWriter.println(indent + shift + "<NodeName>" +
+ Gen.xmlEscapeNode((String) parms.get("NodeName")) + "</NodeName>");
+ }
+ String path = (String) parms.get("URI");
+ if (path !=null){
+ String fileSep = System.getProperty("file.separator");
+ if(path.indexOf(fileSep) > 0){
+ path=path.substring(0, path.lastIndexOf(fileSep));
+ }else{
+ path="";
+ }
+ ddfWriter.println(indent + shift + "<Path>" +
+ Gen.xmlEscapeNode(path) + "</Path>");
+ }
+ ddfWriter.println(indent + shift + "<DFProperties>");
+
+ ddfWriter.println(indent + shift + shift + "<AccessType>");
+ ArrayList access = (ArrayList) parms.get("AccessType");
+ if(access.contains("Add")){
+ ddfWriter.println(indent + shift + shift + shift + "<Add/>");
+ }
+ if(access.contains("Delete")){
+ ddfWriter.println(indent + shift + shift + shift + "<Delete/>");
+ }
+ if(access.contains("Exec")){
+ ddfWriter.println(indent + shift + shift + shift + "<Exec/>");
+ }
+ if(access.contains("Get")){
+ ddfWriter.println(indent + shift + shift + shift + "<Get/>");
+ }
+ if(access.contains("Replace")){
+ ddfWriter.println(indent + shift + shift + shift + "<Replace/>");
+ }
+ ddfWriter.println(indent + shift + shift + "</AccessType>");
+
+ if(Gen.generateExtDDF){
+ //get value or default value if presents
+ String tmp = (String)parms.get("Value");
+ if(tmp != null){
+ tmp = (String)parms.get("Default");
+ }
+ if(tmp != null){
+ ddfWriter.println(indent + shift + shift + "<DefaultValue>" + Gen.xmlEscape(tmp) + "</DefaultValue>");
+ }
+ //add main constarins under <Description>
+ StringBuffer sbDescription = new StringBuffer();
+ tmp = (String)parms.get("values");
+ if(tmp != null){
+ valuesForDDF.append("[" + (String) parms.get("URI") + "]\n");
+ valuesForDDF.append(Gen.xmlEscape(tmp) +"\n\n");
+ sbDescription.append(indent + shift + shift + shift + "List of allowed values: " + tmp + "\n");
+ }
+ tmp = (String)parms.get("min");
+ if(tmp != null){
+ sbDescription.append(indent + shift + shift + shift + "Minimum value: " + tmp + "\n");
+ }
+ tmp = (String)parms.get("max");
+ if(tmp != null){
+ sbDescription.append(indent + shift + shift + shift + "Maximum value: " + tmp + "\n");
+ }
+ tmp = (String)parms.get("minLen");
+ if(tmp != null){
+ sbDescription.append(indent + shift + shift + shift + "Minimum length: " + tmp + "\n");
+ }
+ tmp = (String)parms.get("maxLen");
+ if(tmp != null){
+ sbDescription.append(indent + shift + shift + shift + "Maximum length: " + tmp + "\n");
+ }
+ if(sbDescription.length() > 0){
+ ddfWriter.println(indent + shift + shift + "<Description>");
+ ddfWriter.print(sbDescription.toString());
+ ddfWriter.println(indent + shift + shift + "</Description>");
+ }
+ }
+
+ ddfWriter.println(indent + shift + shift + "<DFFormat>");
+ ddfWriter.println(indent + shift + shift + shift +
+ "<" + (String) parms.get("Type") + "/>");
+ ddfWriter.println(indent + shift + shift + "</DFFormat>");
+
+ if (multinode) {
+ ddfWriter.println(indent + shift + shift + "<Occurrence>");
+ ddfWriter.println(indent + shift + shift + shift + "<ZeroOrMore/>");
+ ddfWriter.println(indent + shift + shift + "</Occurrence>");
+ }
+
+ if (parms.get("Mime") != null) {
+ ddfWriter.println(indent + shift + shift + "<DFType>");
+ ddfWriter.println(indent + shift + shift + shift + "<MIME>" +
+ parms.get("Mime") + "</MIME>");
+ ddfWriter.println(indent + shift + shift + "</DFType>");
+ }
+ ddfWriter.println(indent + shift + shift + "<CaseSense>");
+ ddfWriter.println(indent + shift + shift + shift + "<CS/>");
+ ddfWriter.println(indent + shift + shift + "</CaseSense>");
+
+ ddfWriter.println(indent + shift + "</DFProperties>");
+
+ }
+
+ public void nodeDelim(String indent) throws IOException {
+ ddfWriter.println(indent + "</Node>");
+ }
+
+ public void close() throws IOException {
+ ddfWriter.println("</MgmtTree>");
+ ddfWriter.close();
+ if(Gen.generateExtDDF){
+ writeValuesTxt();
+ }
+ }
+
+
+ //write values.txt for DDF file
+ private final void writeValuesTxt() throws IOException{
+ if(valuesForDDF.length() > 0){
+ PrintWriter ddfValsWriter = new PrintWriter(Util.openUtf8FileWriter("ddfvalues.txt"));
+ ddfValsWriter.println(valuesForDDF.toString());
+ ddfValsWriter.close();
+ ddfValsWriter = null;
+ }
+ }
+}
+
+// class convert .bmdf, fstab, .ini to .c and .h files (for P2K)
+
+class File2C {
+ String outputDir = "";
+ final String BODY = "<BODY>";
+ final String SIZE = "<SIZE>";
+
+ public File2C() {}
+
+ public File2C(String outputDir) {
+ outputDir += (outputDir.endsWith("/")) ? "" : "/";
+ this.outputDir = outputDir;
+ }
+
+ public void convert(String filePath) throws Exception {
+ boolean isTextFile = !filePath.toLowerCase().endsWith(".bmdf");
+ convert(filePath, isTextFile);
+ }
+
+ public void convert(String filePath, boolean isTextFile) throws Exception {
+ File file = new File(filePath);
+ if (!file.exists()) {
+ throw new Exception("File does not exist");
+ }
+
+ String name = replaceStr(file.getName(), ".", "_");
+ String strNewFile;
+ if (isTextFile) {
+ strNewFile = convertText2C(file, name);
+ }
+ else {
+ strNewFile = convertBytes2C(file, name);
+ }
+ writeFile(outputDir + name + ".c", strNewFile);
+
+ strNewFile = convert2H(name);
+ writeFile(outputDir + name + ".h", strNewFile);
+ }
+
+ public String convertText2C(File file, String name) throws Exception {
+ StringBuffer body = new StringBuffer();
+ Reader fr = Util.openUtf8FileReader(file);
+ BufferedReader br = new BufferedReader(fr);
+ int fileSize = 0;
+ String line;
+ String str;
+ while ( (line = br.readLine()) != null) {
+ line = line.trim();
+ if (line.startsWith("#") || line.length() == 0) {
+ continue;
+ }
+ if (name.equalsIgnoreCase("fstab")) {
+ line = replaceStr(line, "\t", " ");
+ String strTmp = null;
+ while (!line.equals(strTmp)) {
+ strTmp = line;
+ line = replaceStr(line, " ", " ");
+ }
+ }
+
+ fileSize += line.length() + 1;
+ line = "\n \"" + line + "\" \"\\0\"";
+ body.append(line);
+ }
+ body.append("\n;\n");
+ String result = getCTemplate(name, false);
+ String strBody = body.toString();
+ result = replaceStr(result, BODY, strBody);
+ result = replaceStr(result, SIZE, fileSize + "");
+ try {
+ br.close();
+ }
+ catch (Exception e) {}
+ try {
+ fr.close();
+ }
+ catch (Exception e) {}
+
+ br = null;
+ fr = null;
+
+ return result;
+ }
+
+ public String convertBytes2C(File file, String name) throws Exception {
+ StringBuffer body = new StringBuffer();
+
+ FileInputStream fstream = new FileInputStream(file);
+ byte[] bytes = new byte[fstream.available()];
+ if (bytes.length == 0) {
+ throw new Exception("File is empty. Path: " + file.getPath());
+ }
+ fstream.read(bytes);
+ fstream.close();
+ String str;
+
+ if (file.getName().toLowerCase().endsWith(".bmdf")) {
+ validateBMDFfile(bytes);
+ }
+
+ for (int i = 0; i < bytes.length; i++) {
+ str = "0x" + Integer.toHexString( ( (int) bytes[i]) & 0xff);
+ str += ( (i + 1) == bytes.length) ? "" :
+ ( (str.length() < 4) ? " , " : ", ");
+ str += ( ( (i + 1) % 25) == 0) ? "\n" : "";
+ body.append(str);
+ }
+ String result = getCTemplate(name, true);
+ result = replaceStr(result, BODY, body.toString());
+ result = replaceStr(result, SIZE, bytes.length + "");
+
+ return result;
+ }
+
+ public void validateBMDFfile(byte[] bytes) throws Exception {
+ if (bytes.length <= 4) {
+ throw new Exception("File size less then 4 chars.\n");
+ }
+ int values[] = {
+ ( (int) bytes[0]) & 0xff,
+ ( (int) bytes[1]) & 0xff,
+ ( (int) bytes[2]) & 0xff,
+ ( (int) bytes[3]) & 0xff
+ };
+ int value = 0;
+
+ if (values[0] == '[' && (values[1] == '/' || values[2] == '.')) {
+ throw new Exception("BMDF: file not recognized as a bmdf file.\n");
+ }
+
+ for (int i = 0; i < 4; i++) {
+ value |= values[i] << (i * 8);
+ }
+ if (value != bytes.length) {
+ throw new Exception("Corrupted mdf file: size not match");
+ }
+ }
+
+ public String convert2H(String name) throws Exception {
+
+ StringBuffer sb = new StringBuffer();
+ sb.append("#ifndef " + name + "_H\n");
+ sb.append("#define " + name + "_H\n\n");
+ sb.append("#include \"xpl_Types.h\"\n\n");
+ sb.append("#ifdef __cplusplus \n extern \"C\" {\n#endif\n\n");
+ sb.append("const UINT8 * dmGet_" + name + "(UINT32 * size);\n\n");
+ sb.append("#ifdef __cplusplus \n}\n#endif\n\n");
+ sb.append("#endif\n");
+
+ return sb.toString();
+ }
+
+ private String getCTemplate(String name, boolean isBinary) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("#include \"" + name + ".h\"\n\n");
+ sb.append("#ifdef __cplusplus \n extern \"C\" {\n#endif\n\n");
+ sb.append("static UINT8 " + name + "[] = ");
+ if (isBinary) {
+ sb.append("{\n");
+ }
+ sb.append(BODY);
+ sb.append("\n");
+ if (isBinary) {
+ sb.append("};\n\n");
+ }
+ sb.append("const UINT8 * dmGet_" + name + "(UINT32 * size)\n");
+ sb.append("{\n");
+ sb.append(" if ( size )\n");
+ sb.append(" {\n");
+ sb.append(" *size = " + SIZE + ";\n");
+ sb.append(" return " + name + ";\n");
+ sb.append(" }\n");
+ sb.append(" else\n");
+ sb.append(" {\n");
+ sb.append(" return NULL;\n");
+ sb.append(" }\n");
+ sb.append("}\n\n");
+ sb.append("#ifdef __cplusplus \n}\n#endif\n\n");
+ return sb.toString();
+ }
+
+ private String replaceStr(String str, String oldPat, String newPat) {
+ String result = str;
+ int from = 0;
+ while ( (from = str.indexOf(oldPat, from)) >= 0) {
+ result = str.substring(0, from);
+ result += newPat;
+ result += str.substring(from + oldPat.length(), str.length());
+ str = result;
+ }
+ return result;
+ }
+
+ public void writeFile(String path, String body) throws Exception {
+ PrintWriter fileWriter = new PrintWriter(Util.openUtf8FileWriter(path));
+
+ fileWriter.print(body);
+ fileWriter.flush();
+ fileWriter.close();
+ fileWriter = null;
+ }
+}
+
+// Main public class
+public class Gen {
+ public final static String GEN_TOOL_VERSION = "1.11";
+ private static short BMDF_VERSION = 1;
+ private int depth = 1;
+ final static private String shift = " ";
+ final static private String multi = "[ ]";
+ final static private String parm = "parm.txt";
+ static private String initDir = "D:\\Dmt";
+ final static private String dataFile = "d_dmtree.xml";
+ final static private String metaDataFile = "root.mdf";
+ final static private String binaryMetaDataFile = "root.bmdf";
+ final static private String aclFile = "acl.txt";
+ final static private String aclFileDat = "acl.dat";
+ final static private String eventFile = "event.txt";
+ final static private String eventFileDat = "event.dat";
+ static private String fstabFile = "fstab";
+ static private Archives dataOut = null;
+ static private PrintWriter metaDataOut = null;
+ static private FileOutputStream binaryMetaDataOut = null;
+ static private PrintWriter aclOut = null;
+ static private PrintWriter eventOut = null;
+ static private StringWriter metaDataSW = null;
+ static private PrintWriter metaDataBuffer = null;
+ private String[] path = new String[20];
+ static private String softwareVersion = "";
+ static private Documentation docs = null;
+ static private DDFGen ddfgen = null;
+ static private boolean generateDocs = false;
+ static private boolean generateDDF = false;
+ static private boolean MDFconversion = false;
+ static private MDFNode rootMDF = new MDFNode();
+ private static int totalMDFBytes = 0;
+ private static int nodeConstraintBytes = 0;
+ private static Map stringTable = new HashMap();
+ private static SortedMap revStringTable = new TreeMap();
+ private static StringBuffer sbAclData = new StringBuffer();
+ private static StringBuffer sbEventData = new StringBuffer();
+ private static StringBuffer sbEventDataFromParms = new StringBuffer();
+ private static ArrayList arrAclData = new ArrayList();
+ private static ArrayList arrEventData = new ArrayList();
+ private static String iniPath = null;
+ public static String phoneModel = "unknown";
+ public static boolean generateExtDDF = false;
+ private String factoryBootstrapEncodeValue = null;
+
+ private static void usage() {
+ System.err.println(
+ "java Gen -d dirName -f fstab [-gendoc] [-genddf | -genextddf] [-sv version] \n" +
+ "\t -d : dirName points to the directory where Dmt is located\n" +
+ "\t -f : location of fstab file\n" +
+ "\t -i : location of ini file(s)\n" +
+ "\t -gendoc : optional argument to generate documentation\n" +
+ "\t -genddf : optional argument to generate standard DDF file\n" +
+ "\t -genextddf : optional argument to generate DDF file with values and DDFValues.txt\n" +
+ "\t -sv : optional argument specifies software version to be\n" +
+ "\t\t included in the DM tree\n");
+ }
+
+ // take string and make sure that each < > & etc are escaped properly
+ public static String xmlEscape(String s) {
+ StringTokenizer st = new StringTokenizer(s, "<>&\"$#*", true);
+ StringBuffer sb = new StringBuffer(s.length());
+ if (!st.hasMoreTokens()) {
+ return s;
+ }
+
+ while (st.hasMoreTokens()) {
+ s = st.nextToken();
+ if (s.equals("<")) {
+ sb.append("&lt;");
+ }
+ else if (s.equals(">")) {
+ sb.append("&gt;");
+ }
+ else if (s.equals("&")) {
+ sb.append("&amp;");
+ }
+ else if (s.equals("$")) {
+ sb.append("&#36;");
+ }
+ else if (s.equals("\"")) {
+ sb.append("&#34;");
+ }
+ else if (s.equals("#")) {
+ sb.append("&#35;");
+ }
+ else if (s.equals("*")) {
+ sb.append("&#42;");
+ }
+ else {
+ sb.append(s);
+ }
+ }
+ return sb.toString();
+ }
+
+ //escape illigal chars in the node name or uri
+ public static final String xmlEscapeNode(String nodeNameOrUri) {
+ return (nodeNameOrUri == null) ? "" : nodeNameOrUri.replaceAll("&", "&#38;");
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Gen Tool version " + Gen.GEN_TOOL_VERSION);
+ try {
+ Gen.genTree(args);
+ }catch (Exception e){
+ System.err.println(e.getMessage());
+ System.exit(1);
+ }
+ System.exit(0);
+ }
+
+ // This function replaced main() for compatibility with LV flexlib
+ public static void genTree(String[] args) throws Exception {
+ //parse arguments
+ for (int ac = 0; ac < args.length; ac++) {
+ if (args[ac].equals("-mdfconvert")) {
+ MDFconversion = true;
+ ac++;
+ }
+ else if (args[ac].equals("-d")) {
+ if (args.length < ac + 2) {
+ usage();
+ throw new Exception("Error: Dmt location has not been specified");
+ }
+ initDir = args[++ac];
+ }
+ else if (args[ac].equals("-f")) {
+ if (args.length < ac + 2) {
+ usage();
+ throw new Exception("Error: fstab file location has not been specified");
+ }
+ fstabFile = args[++ac];
+ }
+ else if (args[ac].equals("-i")) {
+ if (args.length < ac + 2) {
+ usage();
+ throw new Exception("Error: 'ini' file location has not been specified");
+ }
+ iniPath = args[++ac];
+ }
+ else if (args[ac].equals("-gendoc")) {
+ generateDocs = true;
+ }
+ else if (args[ac].equals("-genddf")) {
+ generateDDF = true;
+ }
+ else if (args[ac].equals("-genextddf")) {
+ generateDDF = true;
+ generateExtDDF = true;
+ }
+ else if (args[ac].equals("-sv")) {
+ if (args.length < ac + 2) {
+ usage();
+ throw new Exception("Error: software version is not specified");
+ }
+ softwareVersion = args[++ac];
+ }
+ }
+
+ //set phone model... read from parm.txt
+ try {
+ setPhoneModel(initDir);
+ }catch (Exception e){
+ throw new Exception("Error: can not read phone model from /DevInfo/#Mod/parm.txt. " + e.getMessage());
+ }
+
+ // writing acl, event, metadata, ddf, ...
+ try
+ {
+ if (!MDFconversion) {
+ dataOut = new Archives(fstabFile);
+ metaDataOut = new PrintWriter(new BufferedWriter(Util.openUtf8FileWriter(metaDataFile)));
+ aclOut = new PrintWriter(new BufferedWriter(Util.openUtf8FileWriter(aclFile)));
+ }
+
+ if (generateDocs) {
+ docs = new Documentation();
+ }
+
+ if (generateDDF) {
+ ddfgen = new DDFGen();
+ }
+
+ if (!MDFconversion) {
+ dataOut.printAll("<MgmtTree>\n");
+ dataOut.printAll(shift + "<VerDTD>1.1.2</VerDTD>\n");
+ dataOut.printAll(shift + "<Man>Motorola</Man>\n");
+ dataOut.printAll(shift + "<Mod>" + Gen.phoneModel + "</Mod>\n");
+ }
+
+ Gen gen = new Gen();
+ gen.analyzeDir(initDir, rootMDF, true, false, false, false);
+
+ if (!MDFconversion) {
+ dataOut.printAll("</MgmtTree>\n");
+ aclOut.close();
+ metaDataOut.close();
+ dataOut.close();
+ writeAclDatFile();
+ // write event.dat and event.txt files
+ if(sbEventDataFromParms.length() > 0){
+ eventOut = new PrintWriter(new BufferedWriter(Util.openUtf8FileWriter(eventFile)));
+ eventOut.print(sbEventDataFromParms.toString());
+ eventOut.close();
+ writeEventDatFile();
+ }
+ }
+
+ if (generateDocs) {
+ docs.close();
+ }
+
+ if (generateDDF) {
+ ddfgen.close();
+ }
+
+ gen.processMDFStrings(rootMDF);
+ gen.processNodeAndConstraintOffsets(rootMDF);
+ totalMDFBytes += 6;
+
+ System.out.println(rootMDF.toString());
+ System.out.println("String table (raw) = " + stringTable);
+ System.out.println("String table (output order) = " + revStringTable);
+ System.out.println();
+ System.out.println("Total Number of Bytes = " + totalMDFBytes);
+
+ }catch (Exception e){
+ throw new Exception("Error: " + e.getMessage());
+ }
+
+ // Now actually write out the bytes to bmdf file
+ DataOutputStream bmdfOut = null;
+ try {
+ binaryMetaDataOut = new FileOutputStream(binaryMetaDataFile);
+ bmdfOut = new DataOutputStream(binaryMetaDataOut);
+
+ // Write out the total # of bytes to the file
+ bmdfOut.writeInt(ByteSwapper.swapInt(totalMDFBytes));
+
+ // Write out the BMDF file version
+ bmdfOut.writeShort(ByteSwapper.swapShort(BMDF_VERSION));
+
+ // Put the MDF data into the buffer
+ rootMDF.toBinary(bmdfOut);
+
+ // Put the string table into the buffer
+ Set stKeys = revStringTable.keySet();
+ Iterator stIterator = stKeys.iterator();
+
+ while (stIterator.hasNext()) {
+ bmdfOut.writeBytes( ( (String) revStringTable.get(stIterator.next()) + "\0"));
+ }
+
+ bmdfOut.flush();
+ }
+ catch (Exception e) {
+ throw new Exception("Error: unable to create binary metadata file. " + e.getMessage());
+ }
+ finally{
+ try {
+ binaryMetaDataOut.close();
+ }catch (Exception ex){}
+
+ try {
+ bmdfOut.close();
+ }catch (Exception ex){}
+
+ binaryMetaDataOut=null;
+ bmdfOut=null;
+ }
+
+ // For P2K only... Generate .c and .h files from sysplagins.ini (if presents)
+ if (iniPath != null) {
+ try {
+ convertToCAndH();
+ }catch (Exception e){
+ throw new Exception("Error: fail to convert files to .c and .h. " + e.getMessage());
+ }
+ }
+
+ //Convert all XML files to WBXML
+ try {
+ convert2WBXML();
+ }catch (Exception e){
+ throw new Exception("Error: during conversion xml to wbxml. " + e.getMessage());
+ }
+ }
+
+ //Convert all XML files from current directory to WBXML (replace Python script).
+ private static void convert2WBXML() throws Exception {
+ boolean isXmlFileFound = false;
+ Xml2WBXml x2b = new Xml2WBXml();
+ File top = new File(".");
+ File f;
+ for (int i = 0; i < top.listFiles().length; i++) {
+ f = top.listFiles()[i];
+ if (f.getName().toUpperCase().endsWith(".XML")) {
+ isXmlFileFound = true;
+ x2b.convert(f);
+ }
+ }
+ if (!isXmlFileFound){
+ throw new Exception("There are no single xml files have been created.");
+ }
+ }
+
+ //set phone model global variable which will be used for ddf and MDF
+ public static void setPhoneModel(String initDir) throws Exception{
+ BufferedReader br = null;
+ Reader reader = null;
+ try {
+ Node f = NodeLoader.getInstance(initDir + "/DevInfo/#Mod/parm.txt"); // changed to support FlexML, replace new File()
+ reader = NodeLoader.getReader(f);
+ br = new BufferedReader(reader); // changed to support FlexML, replaced File()
+ String line;
+ while ( (line = br.readLine()) != null) {
+ if (line.startsWith("value:")) {
+ phoneModel = line.substring(6, line.length());
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ throw e;
+ }
+ finally {
+ try {
+ br.close();
+ }
+ catch (Exception e) {}
+
+ try {
+ reader.close();
+ }
+ catch (Exception e) {}
+
+ br = null;
+ reader = null;
+ }
+ }
+
+ public boolean analyzeDir(String dirName, MDFNode mdf, boolean metaData,
+ boolean noMetaDataGen, boolean parmNoMetaData,
+ boolean foundMultiNode) throws Exception {
+
+ // Create the indentation string
+
+ //YXU Add
+ boolean isLeaf = false;
+ boolean notMultiNode = true;
+ // this variable used as a flag for ddfgen.nodeDelim() method to close node with "</Node>"
+ // has been introduced to avoid adding multi node's instances into ddf file
+ boolean bAddDDFCalled = false;
+
+ String indent = "";
+ depth += 1;
+
+ for (int ii = 0; ii < depth; ii++) {
+ indent += shift;
+ }
+
+ // Remove leading (leaf) and trailing (reserved name) "#"
+ String nodeName;
+ if (depth <= 2) {
+ nodeName = ".";
+ }
+ else {
+ nodeName = dirName.substring(dirName.lastIndexOf(System.getProperty(
+ "file.separator")) + 1);
+ //YXU Add
+ if (nodeName.startsWith("#")) {
+ isLeaf = true;
+ }
+ nodeName = nodeName.replace('#', ' ');
+ if (nodeName.startsWith("@")) {
+ nodeName = nodeName.substring(1);
+ }
+ nodeName = nodeName.trim();
+ if (nodeName.charAt(0) == '[') {
+ nodeName = "*";
+ metaData = false; // Indicate that data part of the tree is
+ // not to be generated underneath this node
+ notMultiNode = false;
+ }
+ path[depth - 2] = nodeName;
+ }
+
+ //Get the current node path
+ String nodepath = ".";
+ for (int i = 1; i < depth - 1; i++) {
+ nodepath = nodepath + "/" + path[i];
+ }
+ System.out.println("nodepath = " + nodepath);
+
+ metaDataSW = new StringWriter();
+ metaDataBuffer = new PrintWriter(metaDataSW);
+
+ if (!noMetaDataGen) {
+ if (depth > 2) {
+ metaDataBuffer.print("[");
+ for (int ii = 1; ii < depth - 1; ii++) {
+ metaDataBuffer.print("/" + path[ii].trim());
+ }
+ metaDataBuffer.print("]\n");
+ }
+ else {
+ metaDataBuffer.println("[.]");
+ }
+ }
+ Node directory = NodeLoader.getInstance(dirName); //changed to support FlexML, replaced File()
+ Node[] children = directory.listNodes(); //changed to support FlexML, replaced listFiles().
+
+ //sorting nodes
+ Util.quickSort(children);
+
+ //YXU else
+ //type:chr
+ //maxLen:31
+ //access:Get
+ //mime:text/plain
+ //default:1.0
+ { // *** bracket uses for scope separation only
+ // Setting the default parameter values
+ HashMap parameters = new HashMap();
+ //YXU parameters.put("Format", "node");
+ if (isLeaf) {
+ parameters.put("Type", "chr");
+ }
+ else {
+ parameters.put("Type", "node");
+ }
+
+ parameters.put("Mime", "text/plain");
+ ArrayList access = new ArrayList();
+ access.add("Get");
+ access.add("Add");
+ access.add("Replace");
+ access.add("Delete");
+ parameters.put("AccessType", access); //YXU "text/plain");
+
+ parameters.put("URI", nodepath);
+ parameters.put("NodeName", nodeName);
+
+ String filename = dirName + "/" + parm;
+
+ // Get parameters from the current branch
+
+ if (mdf != null) {
+ mdf.nodeName = nodeName;
+ }
+
+ getParms(filename, parameters, access, mdf, notMultiNode, noMetaDataGen);
+
+ if (generateDocs) {
+ docs.addTocEntry(nodepath);
+ docs.addDescEntry(parameters);
+ docs.addIndexEntry(nodepath, parameters);
+ }
+
+ // Get parameters from the parallel meta-data branch, if any
+ String metaBranch = "";
+ int index;
+ int curr = 0;
+ boolean meta = false;
+ while ( (index = filename.substring(curr).indexOf("/")) > 0) {
+ if (filename.charAt(curr) == '@') {
+ metaBranch += "/" + multi;
+ meta = true;
+ }
+ else {
+ metaBranch += "/" + metaBranch + filename.substring(curr, index);
+ }
+ curr = index + 1;
+ }
+ if (meta) {
+ getParms(metaBranch, parameters, access, null, notMultiNode,
+ noMetaDataGen);
+ }
+
+ if (parameters.get("DataGen") != null) {
+ System.out.println("-No Data tree generation flag is set");
+ metaData = false;
+ }
+
+ if (parameters.get("MetaGen") != null) {
+ System.out.println("-No meta data generation flag is set");
+ noMetaDataGen = true;
+ parmNoMetaData = true;
+ }
+
+ if (!noMetaDataGen) {
+ if (!MDFconversion) {
+ metaDataOut.print(metaDataSW.toString());
+ metaDataSW.flush();
+ }
+
+ totalMDFBytes += 11;
+ }
+
+ if (generateDDF && !foundMultiNode) {
+ ddfgen.addDDFForNode(parameters, indent);
+ bAddDDFCalled = true;
+ }
+
+ if (metaData && !MDFconversion) {
+ dataOut.print(nodepath, "\n" + indent + "<Node>\n");
+ dataOut.print(nodepath,
+ indent + shift + "<NodeName>" + Gen.xmlEscapeNode(nodeName) +
+ "</NodeName>\n");
+ }
+
+ // Generate the entries into the xml string
+ if (metaData && !MDFconversion) {
+ //YXU dataOut.print(indent + shift + "<RTProperties>\n");
+ dataOut.print(nodepath, indent + shift + "<DFProperties>\n");
+
+ //YXU
+ //dataOut.print(indent + shift + shift + "<Type>");
+ //dataOut.print(//YXU indent + shift + shift + shift +
+ //YXU "<DDFName>" +
+ //(String)parameters.get("Type") +
+ //YXU "</DDFName>"+
+ //"");
+ //dataOut.print(//YXU indent + shift + shift +
+ // "</Type>\n");
+
+ //YXU dataOut.print(indent + shift + shift + "<Format>\n");
+ dataOut.print(nodepath, indent + shift + shift + "<DFFormat>\n");
+ dataOut.print(nodepath, indent + shift + shift + shift +
+ //"<" + (String)parameters.get("Format") + "/>\n");
+ "<" + (String) parameters.get("Type") + "/>\n");
+ //dataOut.print(indent + shift + shift + "</Format>\n");
+ dataOut.print(nodepath, indent + shift + shift + "</DFFormat>\n");
+
+ //GWM
+ dataOut.print(nodepath, indent + shift + shift + "<AccessType>\n");
+ ArrayList tmpAccess = (ArrayList) parameters.get("AccessType");
+ for (int i = 0; i < tmpAccess.size(); i++) {
+ dataOut.print(nodepath, indent + shift + shift + shift +
+ "<" + (String) tmpAccess.get(i) + "/>\n");
+ }
+ dataOut.print(nodepath, indent + shift + shift + "</AccessType>\n");
+
+ //YXU dataOut.print(indent + shift + "</RTProperties>\n");
+ dataOut.print(nodepath, indent + shift + "</DFProperties>\n");
+
+ //YXU
+ /*
+ if (parameters.get("Acl") !=null )
+ {
+ dataOut.print(indent + shift + "<RTProperties>\n");
+ dataOut.print(indent + shift + shift + "<ACL>");
+ dataOut.print( (String)parameters.get("Acl") );
+ dataOut.print("</ACL>\n");
+ dataOut.print(indent + shift + "</RTProperties>\n");
+ }
+ */
+ //YXU
+ dataOut.print(nodepath, indent + shift + shift + "<Type>");
+ dataOut.print(nodepath, (String) parameters.get("Mime"));
+ dataOut.print(nodepath, "</Type>\n");
+
+ if (nodepath.equals("./DevDetail/SwV")) {
+ dataOut.print(nodepath, indent + shift + shift + "<Data>");
+ dataOut.print(nodepath, softwareVersion);
+ dataOut.print(nodepath, "</Data>\n");
+ }
+ else if (parameters.get("Value") != null) {
+ dataOut.print(nodepath, indent + shift + shift + "<Data>");
+ dataOut.print(nodepath, xmlEscape( (String) parameters.get("Value")));
+ dataOut.print(nodepath, "</Data>\n");
+ }
+ }
+ if (parameters.get("Acl") != null) {
+ aclOut.print("[");
+ sbAclData.append("[");
+ if (depth <= 2) {
+ aclOut.print(".");
+ sbAclData.append(".");
+ }
+ else {
+ for (int ii = 1; ii < depth - 1; ii++) {
+ aclOut.print("/" + path[ii].trim());
+ sbAclData.append("/" + path[ii].trim());
+ }
+ }
+ aclOut.println("]");
+ sbAclData.append("]\n");
+ aclOut.println( (String) parameters.get("Acl"));
+ addAclParmsToDat( (String) parameters.get("Acl"));
+ }
+ if (parameters.get("Event") != null) {
+ sbEventDataFromParms.append("[");
+ sbEventData.append("[");
+ if (depth <= 2) {
+ sbEventDataFromParms.append(".");
+ sbEventData.append(".");
+ }
+ else {
+ for (int ii = 1; ii < depth - 1; ii++) {
+ sbEventDataFromParms.append("/" + path[ii].trim());
+ sbEventData.append("/" + path[ii].trim());
+ }
+ }
+ sbEventDataFromParms.append("]\n");
+ sbEventData.append("]\n");
+ sbEventDataFromParms.append( (String) parameters.get("Event") + "\n");
+ addEventParmsToDat( (String) parameters.get("Event"));
+ }
+
+ } // *** end bracket uses for scope separation only
+
+ if (children == null) {
+ // Either dir does not exist or is not a directory
+ }
+ else {
+ // first check if there is a multi node directory and generate subtree
+ for (int ii = 0; ii < children.length; ii++) {
+ if (children[ii].isDirectory() &&
+ (children[ii].getName().charAt(0) == '[')) {
+ String filename = children[ii].getAbsolutePath();
+ MDFNode tmpMDF = new MDFNode();
+
+ if (analyzeDir(filename, tmpMDF, metaData, noMetaDataGen,
+ parmNoMetaData, foundMultiNode) && !foundMultiNode) {
+ mdf.addChild(children[ii].getName(), tmpMDF);
+ totalMDFBytes += 4;
+ }
+
+ noMetaDataGen = true;
+ foundMultiNode = true;
+
+ System.out.println("Do not generate meta-data for sibling of : " +
+ nodepath);
+ }
+ }
+ // if data branch of a multinode, then do not generate meta data
+ for (int ii = 0; ii < children.length; ii++) {
+ if (children[ii].isDirectory() &&
+ (children[ii].getName().charAt(0) != '[')) {
+ String filename = children[ii].getAbsolutePath();
+ // If it's not the parm file, call the method recursively
+ MDFNode tmpMDF = new MDFNode();
+
+ if (analyzeDir(filename, tmpMDF, metaData, noMetaDataGen,
+ parmNoMetaData, foundMultiNode) && !foundMultiNode) {
+ mdf.addChild(children[ii].getName(), tmpMDF);
+ totalMDFBytes += 4;
+ }
+ }
+ }
+
+ if (!parmNoMetaData) {
+ noMetaDataGen = false;
+ }
+ }
+
+ if (metaData && !MDFconversion) {
+ dataOut.print(nodepath, indent + "</Node>\n");
+ }
+
+ if (generateDDF && bAddDDFCalled) {
+ ddfgen.nodeDelim(indent);
+
+ }
+ depth -= 1;
+
+ if (!noMetaDataGen) {
+ return true;
+ }
+ else {
+ return false;
+ }
+
+ }
+
+ //converts acl parms to dat and create/update acl tables
+ private void addAclParmsToDat(String parms) throws Exception {
+ String strOnePerm, action, names, name;
+ StringTokenizer stAnd, stEqual, stPlus;
+ stAnd = new StringTokenizer(parms, "&");
+ StringBuffer sb = new StringBuffer();
+
+ while (stAnd.hasMoreTokens()) {
+ strOnePerm = stAnd.nextToken();
+ if (strOnePerm == null) {
+ throw new Exception("ERROR: Wrong acl parameters (parsing \"&\").");
+ }
+ stEqual = new StringTokenizer(strOnePerm, "=");
+ if (stEqual.countTokens() != 2) {
+ throw new Exception("ERROR: Wrong acl parameters (parsing \"=\").");
+ }
+ action = stEqual.nextToken();
+ names = stEqual.nextToken();
+ if (action == null || names == null) {
+ throw new Exception(
+ "ERROR: Wrong acl parameters: action or names cannot be null.");
+ }
+
+ if (! (action.equals("Add") ||
+ action.equals("Get") ||
+ action.equals("Delete") ||
+ action.equals("Replace") ||
+ action.equals("Exec"))) {
+ throw new Exception("ERROR: Not supported acl action: " + action);
+ }
+ action = action.substring(0, 1); // take first letter.
+
+ if (sb.length() > 0) {
+ sb.append("&");
+ }
+ sb.append(action + "=");
+
+ stPlus = new StringTokenizer(names, "+");
+ String s = "";
+ while (stPlus.hasMoreTokens()) {
+ name = stPlus.nextToken();
+ if (name == null) {
+ throw new Exception("ERROR: Wrong acl parameters (parsing \"+\").");
+ }
+ s += (s.length() > 0) ? "+" : "";
+ s += getTabIndexFromArray(arrAclData, name);
+ }
+ sb.append(s);
+ }
+ sbAclData.append(sb.toString() + "\n");
+ }
+
+ //get index from mapping or add new name (for acl and event) to create data dictionary for .dat file
+ private static int getTabIndexFromArray(ArrayList array, String name) {
+ for (int i = 0; i < array.size(); i++) {
+ if (name.equals( (String) array.get(i))) {
+ return i + 1;
+ }
+ }
+ array.add(name);
+ return array.size();
+ }
+
+ //convert acl and event mapping to string (for data dictionary for .dat file)
+ private static String dictionaryToString(ArrayList array) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < array.size(); i++) {
+ sb.append( (i + 1) + ":" + (String) array.get(i) + "\n");
+ }
+ return sb.toString();
+ }
+
+ // write acl.dat file
+ private static void writeAclDatFile() throws Exception {
+ String maps = dictionaryToString(arrAclData);
+ if (maps.length() == 0 && sbAclData.length() == 0) {
+ return;
+ }
+ else if ( (maps.length() == 0 && sbAclData.length() > 0) ||
+ (maps.length() > 0 && sbAclData.length() == 0)) {
+ throw new Exception("Error: wrong acl index tab size or data length.");
+ }
+ PrintWriter aclOutDat = new PrintWriter(new BufferedWriter(Util.openUtf8FileWriter(
+ aclFileDat)));
+ aclOutDat.print(maps + "\n");
+ aclOutDat.print(sbAclData.toString() + "\n");
+ aclOutDat.close();
+ aclOutDat = null;
+ }
+
+
+ //converts event parms to dat and create/update event tables
+ private void addEventParmsToDat(String parms) throws Exception {
+ String strEvent, isEventKey, strAbbrev, paramKey, paramVals;
+ StringTokenizer stAnd, stEqual, stPlus;
+
+ stAnd = new StringTokenizer(parms, "&");
+ StringBuffer sb = new StringBuffer();
+
+ while (stAnd.hasMoreTokens()) {
+ strEvent = stAnd.nextToken();
+ if (strEvent == null) {
+ continue;
+ }
+ HashMap mapResult = getEventAbbreviation(strEvent);
+ if(mapResult.get("ERROR") != null){
+ throw new Exception("ERROR: Unsupported name for the parameter event.");
+ }
+ isEventKey = (String)mapResult.get("ISKEY");
+ strAbbrev = (String)mapResult.get("ABBREV");
+
+ if (isEventKey.equals("FALSE")){ // for operations and formats
+ if (sb.length() > 0) {
+ sb.append("&");
+ }
+ sb.append(strAbbrev);
+ }else{ // for parameters (key=values pairs)
+ stEqual = new StringTokenizer(strEvent, "=");
+ if (stEqual.countTokens() != 2) {
+ throw new Exception("ERROR: Wrong event parameters (parsing \"=\").");
+ }
+ paramKey = stEqual.nextToken(); //we already have Abbreviation for this key
+ paramVals = stEqual.nextToken();
+
+ if (paramVals == null || paramVals.length() == 0) {
+ throw new Exception("ERROR: Wrong event parameters: values cannot be empty string.");
+ }
+ if (sb.length() > 0) {
+ sb.append("&");
+ }
+ sb.append(strAbbrev + "=");
+ if("Topic".equals(paramKey)){
+ sb.append(paramVals);
+ }
+ else{
+ stPlus = new StringTokenizer(paramVals, "+");
+ String s = "";
+ String val;
+ while (stPlus.hasMoreTokens()) {
+ val = stPlus.nextToken();
+ if (val == null) {
+ throw new Exception("ERROR: Wrong event parameters value (parsing \"+\").");
+ }
+ s += (s.length() > 0) ? "+" : "";
+ s += getTabIndexFromArray(arrEventData, val);
+ }
+ sb.append(s);
+ }
+ }
+ }// while loop
+ sbEventData.append(sb.toString() + "\n");
+ }
+
+ //get abbriviation for an Event operation, format and keys for Parameters
+ private final HashMap getEventAbbreviation(String eventName){
+ HashMap mapResult = new HashMap(3);
+ if(eventName.equals("Add")){
+ mapResult.put("ISKEY", "FALSE");
+ mapResult.put("ABBREV", "A");
+ }
+ else if(eventName.equals("Replace")){
+ mapResult.put("ISKEY", "FALSE");
+ mapResult.put("ABBREV", "R");
+ }
+ else if(eventName.equals("Delete")){
+ mapResult.put("ISKEY", "FALSE");
+ mapResult.put("ABBREV", "D");
+ }
+ else if(eventName.equals("Indirect")){
+ mapResult.put("ISKEY", "FALSE");
+ mapResult.put("ABBREV", "I");
+ }
+ else if(eventName.equals("Node")){
+ mapResult.put("ISKEY", "FALSE");
+ mapResult.put("ABBREV", "N");
+ }
+ else if(eventName.equals("Cumulative")){
+ mapResult.put("ISKEY", "FALSE");
+ mapResult.put("ABBREV", "C");
+ }
+ else if(eventName.equals("Detail")){
+ mapResult.put("ISKEY", "FALSE");
+ mapResult.put("ABBREV", "F");
+ }
+ else if(eventName.startsWith("Topic=")){
+ mapResult.put("ISKEY", "TRUE");
+ mapResult.put("ABBREV", "T");
+ }
+ else if(eventName.startsWith("Notify")){
+ mapResult.put("ISKEY", "TRUE");
+ mapResult.put("ABBREV", "S");
+ }
+ else if(eventName.startsWith("Ignore")){
+ mapResult.put("ISKEY", "TRUE");
+ mapResult.put("ABBREV", "P");
+ }
+ else{
+ mapResult.put("ERROR", "ERROR");
+ }
+ return mapResult;
+ }
+
+ // write event.dat file
+ private static void writeEventDatFile() throws Exception {
+ String maps = dictionaryToString(arrEventData);
+ if (maps.length() == 0 && sbEventData.length() == 0) {
+ return;
+ }
+ else if (maps.length() > 0 && sbEventData.length() == 0) {
+ throw new Exception("Error: wrong event index tab size or data length.");
+ }
+ PrintWriter eventOutDat = new PrintWriter(new BufferedWriter(Util.openUtf8FileWriter(
+ eventFileDat)));
+ eventOutDat.print(maps + "\n");
+ eventOutDat.print(sbEventData.toString() + "\n");
+ eventOutDat.close();
+ eventOutDat = null;
+ }
+
+ private void processNodeAndConstraintOffsets(MDFNode mdfNode) {
+ // Setup this node's offset value (account for file size bytes (4) and version bytes (2)
+ // at beginning of file)
+
+ mdfNode.nodeOffset = nodeConstraintBytes + 6;
+
+ // Add total size of this node to running total
+
+ nodeConstraintBytes += (11 + (mdfNode.children.size() * 4));
+
+ // Account for extra four bytes of offset to meta-node ID (if required)
+
+ if ( (mdfNode.nodeType & MDFNode.USE_NODE_ID) == MDFNode.USE_NODE_ID) {
+ nodeConstraintBytes += 4;
+ }
+
+ // Check to see if we have constraints
+
+ if (mdfNode.constraints.size() > 0) {
+ Iterator tmpConstraints = mdfNode.constraints.iterator();
+
+ while (tmpConstraints.hasNext()) {
+ MDFConstraint tmpConstraint = (MDFConstraint) tmpConstraints.next();
+
+ switch (tmpConstraint.constraintType) {
+ case MDFConstraint.AUTONODE_CONSTRAINT:
+ case MDFConstraint.DELETE_CHILD_CONSTRAINT:
+ case MDFConstraint.DEPEND_CHILD_CONSTRAINT:
+ case MDFConstraint.FOREIGN_KEY_CONSTRAINT:
+ case MDFConstraint.NAME_REGEXP_CONSTRAINT:
+ case MDFConstraint.NAME_VALUES_CONSTRAINT:
+ case MDFConstraint.RECUR_AFTER_CONSTRAINT:
+ case MDFConstraint.REGEXP_CONSTRAINT:
+ case MDFConstraint.MIN_VALUE_CONSTRAINT:
+ case MDFConstraint.MAX_VALUE_CONSTRAINT:
+ case MDFConstraint.VALUES_CONSTRAINT:
+ nodeConstraintBytes += 5;
+ break;
+
+ case MDFConstraint.MIN_LENGTH_CONSTRAINT:
+ case MDFConstraint.MAX_LENGTH_CONSTRAINT:
+ case MDFConstraint.MAX_CHILD_CONSTRAINT:
+ case MDFConstraint.NAME_MAX_LENGTH_CONSTRAINT:
+ case MDFConstraint.MAX_RECUR_CONSTRAINT:
+ nodeConstraintBytes += 3;
+
+ case MDFConstraint.DEFAULT_VALUE_CONSTRAINT:
+ switch (tmpConstraint.defaultValueType) {
+ case MDFConstraint.DEFAULT_BYTE_TYPE:
+ nodeConstraintBytes += 2;
+ break;
+
+ case MDFConstraint.DEFAULT_INT_TYPE:
+ case MDFConstraint.DEFAULT_FLOAT_TYPE:
+ case MDFConstraint.DEFAULT_CHR_TYPE:
+ nodeConstraintBytes += 5;
+ break;
+ }
+ break;
+ }
+ }
+ }
+
+ // recursively call ourselves for each of our children
+
+ if (mdfNode.children.size() > 0) {
+ Set childKeys = mdfNode.children.keySet();
+ Iterator childIterator = childKeys.iterator();
+
+ while (childIterator.hasNext()) {
+ processNodeAndConstraintOffsets( (MDFNode) mdfNode.children.get(
+ childIterator.next()));
+ }
+ }
+
+ }
+
+ private void processMDFStrings(MDFNode mdfNode) {
+ // Process the NodeName (add 6 bytes to every string value to account for file size/version bytes)
+
+ if (stringTable.containsKey(mdfNode.nodeName)) {
+ mdfNode.nodeNameOffset = ( (Integer) stringTable.get(mdfNode.nodeName)).
+ intValue();
+ }
+ else {
+ stringTable.put(mdfNode.nodeName, new Integer(totalMDFBytes + 6));
+ revStringTable.put(new Integer(totalMDFBytes + 6), mdfNode.nodeName);
+ mdfNode.nodeNameOffset = totalMDFBytes + 6;
+
+ // increment totalMDFBytes by length of the nodename+1 (for \0 character)
+ totalMDFBytes += (mdfNode.nodeName.length() + 1);
+ }
+
+ // Process the Meta Node ID (if present)
+
+ if ( (mdfNode.nodeType & MDFNode.USE_NODE_ID) == MDFNode.USE_NODE_ID) {
+ // Process the meta Node ID
+
+ if (stringTable.containsKey(mdfNode.metaNodeID)) {
+ mdfNode.metaNodeIDOffset = ( (Integer) stringTable.get(mdfNode.
+ metaNodeID)).intValue();
+ }
+ else {
+ stringTable.put(mdfNode.metaNodeID, new Integer(totalMDFBytes + 6));
+ revStringTable.put(new Integer(totalMDFBytes + 6), mdfNode.metaNodeID);
+ mdfNode.metaNodeIDOffset = totalMDFBytes + 6;
+
+ // increment totalMDFBytes by length of the nodename+1 (for \0 character)
+ totalMDFBytes += (mdfNode.metaNodeID.length() + 1);
+ }
+ }
+
+ // Process the constraints for str values
+
+ Iterator tmpConstraints = mdfNode.constraints.iterator();
+
+ while (tmpConstraints.hasNext()) {
+ MDFConstraint tmpConstraint = (MDFConstraint) tmpConstraints.next();
+
+ switch (tmpConstraint.constraintType) {
+ case MDFConstraint.AUTONODE_CONSTRAINT:
+ case MDFConstraint.DELETE_CHILD_CONSTRAINT:
+ case MDFConstraint.DEPEND_CHILD_CONSTRAINT:
+ case MDFConstraint.FOREIGN_KEY_CONSTRAINT:
+ case MDFConstraint.NAME_REGEXP_CONSTRAINT:
+ case MDFConstraint.NAME_VALUES_CONSTRAINT:
+ case MDFConstraint.RECUR_AFTER_CONSTRAINT:
+ case MDFConstraint.REGEXP_CONSTRAINT:
+ case MDFConstraint.VALUES_CONSTRAINT:
+ if (stringTable.containsKey(tmpConstraint.chrData)) {
+ tmpConstraint.strDataOffset = ( (Integer) stringTable.get(
+ tmpConstraint.chrData)).intValue();
+ }
+ else {
+ stringTable.put(tmpConstraint.chrData,
+ new Integer(totalMDFBytes + 6));
+ revStringTable.put(new Integer(totalMDFBytes + 6),
+ tmpConstraint.chrData);
+ tmpConstraint.strDataOffset = totalMDFBytes + 6;
+
+ // increment totalMDFBytes by length of the nodename+1 (for \0 character)
+ totalMDFBytes += (tmpConstraint.chrData.length() + 1);
+ }
+ break;
+
+ case MDFConstraint.DEFAULT_VALUE_CONSTRAINT:
+ if (tmpConstraint.defaultValueType == MDFConstraint.DEFAULT_CHR_TYPE) {
+ if (stringTable.containsKey(tmpConstraint.chrData)) {
+ tmpConstraint.strDataOffset = ( (Integer) stringTable.get(
+ tmpConstraint.chrData)).intValue();
+ }
+ else {
+ stringTable.put(tmpConstraint.chrData,
+ new Integer(totalMDFBytes + 6));
+ revStringTable.put(new Integer(totalMDFBytes + 6),
+ tmpConstraint.chrData);
+ tmpConstraint.strDataOffset = totalMDFBytes + 6;
+
+ // increment totalMDFBytes by length of the nodename+1 (for \0 character)
+ totalMDFBytes += (tmpConstraint.chrData.length() + 1);
+ }
+ }
+ break;
+ }
+ }
+
+ // recursively call ourselves for each of our children
+
+ if (mdfNode.children.size() > 0) {
+ Set childKeys = mdfNode.children.keySet();
+ Iterator childIterator = childKeys.iterator();
+
+ while (childIterator.hasNext()) {
+ processMDFStrings( (MDFNode) mdfNode.children.get(childIterator.next()));
+ }
+ }
+ }
+
+ private String removeSpaces(String line) {
+ int i = 0;
+
+ if ( (i = line.indexOf(' ', i)) >= 0) {
+ char[] line2 = line.toCharArray();
+ StringBuffer buf = new StringBuffer(line2.length);
+ buf.append(line2, 0, i).append("");
+
+ i++;
+ int j = i;
+
+ while ( (i = line.indexOf(' ', i)) > 0) {
+ buf.append(line2, j, i - j).append("");
+ i++;
+ j = i;
+ }
+
+ buf.append(line2, j, line2.length - j);
+ return buf.toString();
+ }
+
+ return line;
+ }
+
+ //Convert .bmdf, ini, fstab to .c and .h files. Using for P2K
+ private static void convertToCAndH() throws Exception {
+
+ Node f; //changed to support FlexML, replaced File
+ Node[] files; //changed to support FlexML, replaced File[]
+ File2C convertor = new File2C();
+ //convert fstab file
+ convertor.convert(fstabFile, true);
+ //convert ini files
+ f = NodeLoader.getInstance(iniPath); //changed to support FlexML, replaced File()
+ if (!f.exists()) {
+ throw new Exception("File not exist: " + iniPath);
+ }
+ else if (f.isFile()) {
+ convertor.convert(f.getAbsolutePath(), true);
+ }
+ else { //directory
+ String path;
+ files = f.listNodes(); //changed to support FlexML, replaced listFiles ()
+ for (int i = 0; i < files.length; i++) {
+ path = files[i].getAbsolutePath();
+ if (path.endsWith("ini")) {
+ convertor.convert(path, true);
+ }
+ }
+ }
+ //convert bmdf files
+ f = NodeLoader.getInstance("."); //changed to support FlexML, replaced File()
+ String path;
+ files = f.listNodes(); //changed to support FlexML, replaced listFiles ()
+ for (int i = 0; i < files.length; i++) {
+ path = files[i].getAbsolutePath();
+ if (path.endsWith("bmdf")) {
+ convertor.convert(path, false);
+ }
+ }
+ }
+
+ private void getParms(String fileName,
+ HashMap parameters,
+ ArrayList access,
+ MDFNode mdf,
+ boolean notMultiNode,
+ boolean noMetaData) throws Exception {
+
+ Reader reader = NodeLoader.getReader(fileName);
+ BufferedReader in = new BufferedReader(reader); //changed to support FlexML, replaced File()
+ String line;
+ byte numConstraints = 0;
+ int constraintBytes = 0;
+ boolean noMetaGen = false;
+
+ try {
+ while ( (line = in.readLine()) != null) {
+ if (line.trim().length() == 0 || line.trim().startsWith("#")) {
+ continue;
+ }
+ int nameBoundary = line.indexOf(":");
+ String parmName = line.substring(0, nameBoundary);
+ String parmValue = line.substring(nameBoundary + 1);
+
+ if (parmName.equalsIgnoreCase("type")) {
+ //YXU
+ if (parmValue.equalsIgnoreCase("boolean")) {
+ parmValue = "bool";
+ }
+ parameters.put("Type", parmValue.trim());
+
+ if (mdf != null) {
+ if (parmValue.trim().equalsIgnoreCase("int")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.INT_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.INT_MN_TYPE;
+ }
+ }
+
+ if (parmValue.trim().equalsIgnoreCase("bool")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.BOOL_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.BOOL_MN_TYPE;
+ }
+ }
+
+ if (parmValue.trim().equalsIgnoreCase("bin")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.BIN_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.BIN_MN_TYPE;
+ }
+ }
+
+ if (parmValue.trim().equalsIgnoreCase("node")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.NODE_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.NODE_MN_TYPE;
+ }
+ }
+
+ if (parmValue.trim().equalsIgnoreCase("chr")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.CHR_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.CHR_MN_TYPE;
+ }
+ }
+
+ if (parmValue.trim().equalsIgnoreCase("null")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.NULL_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.NULL_MN_TYPE;
+ }
+ }
+
+ if (parmValue.trim().equalsIgnoreCase("test")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.TEST_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.TEST_MN_TYPE;
+ }
+ }
+
+ if (parmValue.trim().equalsIgnoreCase("date")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.DATE_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.DATE_MN_TYPE;
+ }
+ }
+
+ if (parmValue.trim().equalsIgnoreCase("time")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.TIME_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.TIME_MN_TYPE;
+ }
+ }
+
+ if (parmValue.trim().equalsIgnoreCase("float")) {
+ if (notMultiNode) {
+ mdf.nodeType = MDFNode.FLOAT_TYPE;
+ }
+ else {
+ mdf.nodeType = MDFNode.FLOAT_MN_TYPE;
+ }
+ }
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("storesPD")) {
+ parameters.put("storesPD", parmValue.trim());
+
+ if (mdf != null) {
+ mdf.nodeType |= MDFNode.STORES_PD;
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("HandledByPlugin")) {
+ parameters.put("HandledByPlugin", parmValue.trim());
+
+ if (mdf != null) {
+ mdf.nodeType |= MDFNode.HANDLE_BY_PLUGIN;
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("store")) {
+ String pv = parmValue.trim();
+ parameters.put("store", pv);
+
+ if (mdf != null &&
+ (pv.equalsIgnoreCase("true") || pv.equalsIgnoreCase("1"))) {
+ mdf.nodeType |= MDFNode.LOB_STORE;
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("LOBProgressBAR")) {
+ String pv = parmValue.trim();
+ parameters.put("LOBProgressBAR", pv);
+
+ if (mdf != null &&
+ (pv.equalsIgnoreCase("true") || pv.equalsIgnoreCase("1"))) {
+ mdf.nodeType |= MDFNode.LOB_PROGRESS_BAR;
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("ID")) {
+ parameters.put("ID", parmValue.trim());
+
+ // Adjust the totalMDFBytes by 4 for the offset
+
+ totalMDFBytes += 4;
+
+ if (mdf != null) {
+ mdf.nodeType |= MDFNode.USE_NODE_ID;
+ mdf.metaNodeID = parmValue.trim();
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("minLen")) {
+ parameters.put("minLen", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 3;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.MIN_LENGTH_CONSTRAINT;
+ tmpConstraint.shortData = Short.parseShort(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("maxLen")) {
+ parameters.put("maxLen", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 3;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.MAX_LENGTH_CONSTRAINT;
+ tmpConstraint.shortData = Short.parseShort(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("maxChild")) {
+ parameters.put("maxChild", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 3;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.MAX_CHILD_CONSTRAINT;
+ tmpConstraint.shortData = Short.parseShort(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("min")) {
+ parameters.put("min", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.MIN_VALUE_CONSTRAINT;
+ tmpConstraint.intData = Integer.parseInt(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("max")) {
+ parameters.put("max", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.MAX_VALUE_CONSTRAINT;
+ tmpConstraint.intData = Integer.parseInt(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("values")) {
+ parameters.put("values", trimSepSpaces(parmValue));
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.VALUES_CONSTRAINT;
+ tmpConstraint.chrData = trimSepSpaces(parmValue);
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("regexp")) {
+ parameters.put("regexp", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.REGEXP_CONSTRAINT;
+ tmpConstraint.chrData = parmValue.trim();
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("nMaxLen")) {
+ parameters.put("nMaxLen", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 3;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.
+ NAME_MAX_LENGTH_CONSTRAINT;
+ tmpConstraint.shortData = Short.parseShort(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("nValues")) {
+ parameters.put("nValues", removeSpaces(parmValue.trim()));
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.NAME_VALUES_CONSTRAINT;
+ tmpConstraint.chrData = removeSpaces(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("nRegexp")) {
+ parameters.put("nRegexp", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.NAME_REGEXP_CONSTRAINT;
+ tmpConstraint.chrData = parmValue.trim();
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("auto")) {
+ parameters.put("auto", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.AUTONODE_CONSTRAINT;
+ tmpConstraint.chrData = parmValue.trim();
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("fk")) {
+ parameters.put("fk", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.FOREIGN_KEY_CONSTRAINT;
+ tmpConstraint.chrData = parmValue.trim();
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("child")) {
+ parameters.put("child", removeSpaces(parmValue.trim()));
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.
+ DELETE_CHILD_CONSTRAINT;
+ tmpConstraint.chrData = removeSpaces(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("depend")) {
+ parameters.put("depend", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.
+ DEPEND_CHILD_CONSTRAINT;
+ tmpConstraint.chrData = removeSpaces(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("recur-after-segment")) {
+ parameters.put("recur-after-segment", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 5;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.RECUR_AFTER_CONSTRAINT;
+ tmpConstraint.chrData = parmValue.trim();
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("max-recurrence")) {
+ parameters.put("max-recurrence", parmValue.trim());
+
+ if (mdf != null) {
+ numConstraints++;
+ constraintBytes += 3;
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.MAX_RECUR_CONSTRAINT;
+ tmpConstraint.shortData = Short.parseShort(parmValue.trim());
+ mdf.addConstraint(tmpConstraint);
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("acl")) {
+ //YXU
+ parameters.put("Acl", parmValue.trim());
+ // ACL does not go into MDF
+ continue;
+ }
+
+ if (parmName.equalsIgnoreCase("event")) {
+ parameters.put("Event", parmValue.trim());
+ // Event does not go into MDF
+ continue;
+ }
+
+ //YXU either default or Value cause --> Value
+ if (parmName.equalsIgnoreCase("default")) {
+ parameters.put("Default", parmValue.trim());
+ // later, after this while loop, we are checking and add "default" constraint
+ continue;
+ }
+
+ if (parmName.equalsIgnoreCase("value")) {
+ //check if it is a factory bootstrap then HEX encode it.
+ factoryBootstrapEncodeValue = FactBootEnc.checkForBootstrapValue(fileName);
+
+ if(factoryBootstrapEncodeValue == null){
+ parameters.put("Value", parmValue.trim());
+ }
+ else{
+ parameters.put("Value", factoryBootstrapEncodeValue);
+ }
+
+ continue; //Do not send to meta file
+ }
+
+ if (parmName.equalsIgnoreCase("mime")) {
+ parameters.put("Mime", parmValue.trim());
+
+ if (mdf != null) {
+ if (parmValue.trim().equalsIgnoreCase("text/plain")) {
+ mdf.mimeType = MDFNode.TEXT_PLAIN;
+ }
+ }
+ }
+
+ if (parmName.equalsIgnoreCase("access")) {
+ StringTokenizer tok = new StringTokenizer(parmValue, ",");
+ ArrayList tmpAccess = new ArrayList();
+
+ while (tok.hasMoreTokens()) {
+ String accessType = tok.nextToken().trim();
+ tmpAccess.add(accessType);
+
+ if (mdf != null) {
+ if (accessType.equalsIgnoreCase("Add")) {
+ mdf.accessType |= MDFNode.ADD_ACCESS;
+ }
+ else if (accessType.equalsIgnoreCase("Delete")) {
+ mdf.accessType |= MDFNode.DELETE_ACCESS;
+ }
+ else if (accessType.equalsIgnoreCase("Get")) {
+ mdf.accessType |= MDFNode.GET_ACCESS;
+ }
+ else if (accessType.equalsIgnoreCase("Replace")) {
+ mdf.accessType |= MDFNode.REPLACE_ACCESS;
+ }
+ else if (accessType.equalsIgnoreCase("Exec")) {
+ mdf.accessType |= MDFNode.EXEC_ACCESS;
+ }
+ else if (accessType.equalsIgnoreCase("Local")) {
+ mdf.accessType |= MDFNode.LOCAL_ACCESS;
+ }
+ }
+ }
+ parameters.put("AccessType", tmpAccess);
+ }
+
+ if (parmName.equalsIgnoreCase("nodatagen")) {
+ parameters.put("DataGen", new Boolean(false));
+ continue;
+ }
+ if (parmName.equalsIgnoreCase("nometagen")) {
+ parameters.put("MetaGen", new Boolean(false));
+ noMetaGen = true;
+ continue;
+ }
+
+ if (parmName.equalsIgnoreCase("description")) {
+ String docstr = parmValue;
+ while ( (line = in.readLine()) != null) {
+ docstr += line;
+ }
+ parameters.put("Description", docstr);
+ continue;
+ }
+
+ //write to meta data buffer
+ if (!noMetaData) {
+ metaDataBuffer.print(line + "\n");
+ }
+ else {
+ System.out.println("Didn't print: " + line + " for node: " +
+ mdf.nodeName);
+ }
+ } // while loop
+ }
+ catch (Exception e) {
+ throw e;
+ }
+ finally {
+ try {
+ in.close();
+ }
+ catch (Exception e) {}
+
+ try {
+ reader.close();
+ }
+ catch (Exception e) {}
+
+ in = null;
+ reader = null;
+ }
+
+ // Add "default" constraint. It should be separate since it is depended on a node type.
+ // We have to change it by parsing parm.txt first into map and checking all constraint after it...
+ String defParmVal = (String) parameters.get("Default"); // value from parm.txt for "default:..."
+ boolean isAddConstraintReq = true; // flag to add/ignore "default" constraint
+ if (mdf != null && defParmVal != null) {
+ MDFConstraint tmpConstraint = new MDFConstraint();
+ tmpConstraint.constraintType = MDFConstraint.DEFAULT_VALUE_CONSTRAINT;
+ switch (mdf.nodeType) {
+ case MDFNode.INT_MN_TYPE:
+ case MDFNode.INT_TYPE:
+ tmpConstraint.intData = Integer.parseInt(defParmVal);
+ tmpConstraint.defaultValueType = MDFConstraint.DEFAULT_INT_TYPE;
+ constraintBytes += 5;
+ break;
+
+ case MDFNode.FLOAT_MN_TYPE:
+ case MDFNode.FLOAT_TYPE:
+ tmpConstraint.floatData = Float.parseFloat(defParmVal);
+ tmpConstraint.defaultValueType = MDFConstraint.DEFAULT_FLOAT_TYPE;
+ constraintBytes += 5;
+ break;
+
+ case MDFNode.BOOL_MN_TYPE:
+ case MDFNode.BOOL_TYPE:
+ tmpConstraint.byteData = (defParmVal.equals("true") ? (byte) 1 :
+ (byte) 0);
+ tmpConstraint.defaultValueType = MDFConstraint.DEFAULT_BYTE_TYPE;
+ constraintBytes += 2;
+ break;
+
+ case MDFNode.DATE_MN_TYPE:
+ case MDFNode.DATE_TYPE:
+ case MDFNode.TIME_MN_TYPE:
+ case MDFNode.TIME_TYPE:
+ case MDFNode.CHR_MN_TYPE:
+ case MDFNode.CHR_TYPE:
+ tmpConstraint.chrData = defParmVal;
+ tmpConstraint.defaultValueType = MDFConstraint.DEFAULT_CHR_TYPE;
+ constraintBytes += 5;
+ break;
+
+ case MDFNode.BIN_TYPE:
+ case MDFNode.BIN_MN_TYPE:
+
+ // Currently default constraint for node with type "bin" is not supported by tool and by Engine.
+ isAddConstraintReq = false;
+ break;
+
+ default:
+ throw new Exception("Unsupported MDF node type found: " + mdf.nodeType);
+ //System.err.println(
+ // "Warning!!! Unsupported node type found and ignored : " +
+ // mdf.nodeType);
+ // isAddConstraintReq = false;
+ }
+
+ if (isAddConstraintReq) {
+ numConstraints++;
+ mdf.addConstraint(tmpConstraint);
+ }
+
+ if (!noMetaData && isAddConstraintReq && defParmVal != null && mdf != null) {
+ metaDataBuffer.print("default:" + defParmVal + "\n");
+ }
+ else {
+ System.out.println("Didn't print: " + "default:" + defParmVal +
+ " for node: " + mdf.nodeName);
+ }
+ }
+
+ if (mdf != null) {
+ mdf.numConstraints = numConstraints;
+ if (numConstraints > 0 && !noMetaGen && !noMetaData) {
+ totalMDFBytes += constraintBytes;
+ }
+ }
+ }
+
+ private static String trimSepSpaces(String parmValue) throws Exception {
+ String sep = ",";
+ StringTokenizer tok = new StringTokenizer(parmValue.trim(), sep);
+ StringBuffer sb = new StringBuffer();
+ String tmp;
+ while (tok.hasMoreTokens()) {
+ tmp = tok.nextToken().trim();
+ if (tmp != null && tmp.length() > 0) {
+ if (sb.length() > 0) {
+ tmp = sep + tmp;
+ }
+ sb.append(tmp);
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/Xml2WBXml.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/Xml2WBXml.java
new file mode 100644
index 0000000..eb04325
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/core/Xml2WBXml.java
@@ -0,0 +1,514 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//==================================================================================================
+//
+// Module Name: Xml2WBXml
+//
+// General Description: Convert XML file to WBXML
+//
+//==================================================================================================
+
+package com.mot.dm.core;
+
+import java.util.*;
+import java.io.*;
+import javax.xml.parsers.*;
+import org.w3c.dom.*;
+import org.xml.sax.InputSource;
+
+public class Xml2WBXml {
+ HashMap accessMap = null;
+ HashMap formatMap = null;
+ ArrayList arrResult = new ArrayList();
+ String gformat = null;
+
+ public Xml2WBXml() {
+ initAccessMap();
+ initFormatMap();
+ resetArrResult();
+
+ }
+
+ private void resetArrResult() {
+ //Emit WBXML header with version number, doc ID, charset, and string table.
+ //['\x01\x01\x6A\x00']
+ arrResult.clear();
+ arrResult.add(new Character( (char) 0x01));
+ arrResult.add(new Character( (char) 0x01));
+ arrResult.add(new Character( (char) 0x6A));
+ arrResult.add(new Character( (char) 0x00));
+ }
+
+ //Access Types.
+ //TODO: Should add "Local" later...
+ private void initAccessMap() {
+ accessMap = new HashMap();
+ accessMap.put("Add", new Integer(0x01));
+ accessMap.put("Delete", new Integer(0x02));
+ accessMap.put("Exec", new Integer(0x04));
+ accessMap.put("Get", new Integer(0x08));
+ accessMap.put("Replace", new Integer(0x10));
+ }
+
+ private void initFormatMap() {
+ formatMap = new HashMap();
+ formatMap.put("bin", new Character( (char) 0));
+ formatMap.put("bool", new Character( (char) 1));
+ formatMap.put("b64", new Character( (char) 2));
+ formatMap.put("chr", new Character( (char) 3));
+ formatMap.put("int", new Character( (char) 4));
+ formatMap.put("node", new Character( (char) 5));
+ formatMap.put("null", new Character( (char) 6));
+ formatMap.put("xml", new Character( (char) 7));
+ formatMap.put("test", new Character( (char) 9));
+ formatMap.put("float", new Character( (char) 10));
+ formatMap.put("date", new Character( (char) 11));
+ formatMap.put("time", new Character( (char) 12));
+ }
+
+ private Document getDocument(String filename) throws Exception {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+
+ // The following if way around (ugly but working) to support chinese chars for DOM parser:
+ // - read file to string
+ // - get UTF8 byte array
+ // - send this array to xmp parser.
+
+ FileInputStream fis = new FileInputStream(filename);
+ int x = fis.available();
+ byte raw_bytes[] = new byte[x];
+ fis.read(raw_bytes);
+ String content = new String(raw_bytes);
+ raw_bytes = null;
+ byte[] utf8_bytes = content.getBytes("UTF8");
+
+ return factory.newDocumentBuilder().parse(new InputSource(new
+ ByteArrayInputStream(utf8_bytes)));
+ }
+
+ public void convert(File file) throws Exception {
+ resetArrResult();
+
+ ArrayList arrNodes = new ArrayList();
+ Document document = getDocument(file.getCanonicalPath());
+ NodeList list;
+ list = document.getDocumentElement().getChildNodes();
+
+ for (int i = 0; i < list.getLength(); i++) {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE &&
+ node.getNodeName().equals("Node")) {
+ arrNodes.add(node);
+ }
+ }
+
+ if (arrNodes.size() > 0) {
+ this.arrResult.add(new Character( (char) 0x5E));
+
+ for (int i = 0; i < arrNodes.size(); i++) {
+ Node node = (Node) arrNodes.get(i);
+ arrResult.addAll(processNode(node));
+ }
+ this.arrResult.add(new Character( (char) 0x01));
+ }
+ else {
+ this.arrResult.add(new Character( (char) 0x1E));
+ }
+
+ // write to file wbxml from arrResult
+ String wbxmlPath = file.getCanonicalPath();
+ wbxmlPath = (wbxmlPath.substring(0, wbxmlPath.length() - 3)).concat(
+ "wbxml");
+ byte[] arrByte = new byte[arrResult.size()];
+ //convert chars to bytes
+ for (int i = 0; i < arrResult.size(); i++) {
+ char c = ( (Character) arrResult.get(i)).charValue();
+ arrByte[i] = (byte) c;
+ }
+ // write
+ FileOutputStream binaryMetaDataOut = new FileOutputStream(wbxmlPath);
+ DataOutputStream bmdfOut = new DataOutputStream(binaryMetaDataOut);
+ bmdfOut.write(arrByte);
+ bmdfOut.close();
+ }
+
+ private ArrayList processNode(Node node) throws Exception {
+ ArrayList arrCurrResult = new ArrayList();
+ NodeList list = node.getChildNodes();
+ ArrayList arrNodes = new ArrayList();
+
+ for (int i = 0; i < list.getLength(); i++) {
+ Node n = list.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE) { ///@@@ add node validation here NodeChildren
+ arrNodes.add(n);
+ }
+ }
+
+ if (arrNodes.size() > 0) {
+ arrCurrResult.add(new Character( (char) 0x5D));
+
+ for (int i = 0; i < arrNodes.size(); i++) {
+ Node n = (Node) arrNodes.get(i);
+
+ // result.append(NodeChildren[child.tagName](child))
+ if (n.getNodeName().equals("Node")) {
+ arrCurrResult.addAll(processNode(n));
+ }
+ else if (n.getNodeName().equals("Type")) {
+ arrCurrResult.addAll(processNodeType(n));
+ }
+ else if (n.getNodeName().equals("Data")) {
+ arrCurrResult.addAll(processNodeData(n));
+ }
+ else if (n.getNodeName().equals("Plural")) {
+ arrCurrResult.addAll(processNodePlural(n));
+ }
+ else if (n.getNodeName().equals("ClassID")) {
+ arrCurrResult.addAll(processClassID(n));
+ }
+ else if (n.getNodeName().equals("NodeName")) {
+ arrCurrResult.addAll(processNodeName(n));
+ }
+ else if (n.getNodeName().equals("Path")) {
+ arrCurrResult.addAll(processNodePath(n));
+ }
+ else if (n.getNodeName().equals("RTProperties")) {
+ arrCurrResult.addAll(processRTProperties(n));
+ }
+ else if (n.getNodeName().equals("DFProperties")) {
+ arrCurrResult.addAll(processDFProperties(n));
+ }
+ else {
+ throw new Exception("Unsupported node: " + n.getNodeName());
+ }
+ }
+ arrCurrResult.add(new Character( (char) 0x01));
+ }
+ else {
+ arrCurrResult.add(new Character( (char) 0x1D));
+ }
+ return arrCurrResult;
+ }
+
+ private ArrayList processNodeType(Node node) throws Exception {
+ ArrayList arrCurrResult = new ArrayList();
+ String text = getText(node);
+ arrCurrResult.add(new Character( (char) 0x56));
+ arrCurrResult.addAll(opaqueStringData(text));
+ arrCurrResult.add(new Character( (char) 0x01));
+ return arrCurrResult;
+ }
+
+ private ArrayList processNodeData(Node node) throws Exception {
+ ArrayList arrCurrResult = new ArrayList();
+ String nodeData = getText(node);
+ arrCurrResult.add(new Character( (char) 0x48));
+ if ("bin".equals(gformat)) {
+ arrCurrResult.addAll(opaqueHexData(nodeData));
+ }
+ else {
+ arrCurrResult.addAll(opaqueStringData(nodeData));
+ }
+ arrCurrResult.add(new Character( (char) 0x01));
+ return arrCurrResult;
+ }
+
+ private ArrayList processNodePlural(Node node) throws Exception {
+ ArrayList arrCurrResult = new ArrayList();
+ Node nodeYesNo = null;
+ NodeList list = node.getChildNodes();
+
+ for (int i = 0; i < list.getLength(); i++) {
+ Node n = list.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE &&
+ (n.getNodeName().equals("Yes") || n.getNodeName().equals("No"))) {
+ nodeYesNo = n;
+ break;
+ }
+ }
+
+ if (nodeYesNo == null) {
+ throw new Exception("Plural element missing Yes or No tag");
+ }
+ else {
+ char yesOrNo = (nodeYesNo.getNodeName().equals("Yes")) ? (char) 1 :
+ (char) 0;
+ arrCurrResult.add(new Character( (char) 0x49));
+ arrCurrResult.addAll(opaqueCharData(yesOrNo));
+ arrCurrResult.add(new Character( (char) 0x01));
+ }
+ return arrCurrResult;
+ }
+
+ private ArrayList processClassID(Node node) throws Exception {
+ ArrayList arrCurrResult = new ArrayList();
+ String strClassId = getText(node);
+ int intClassId = Integer.parseInt(strClassId);
+ arrCurrResult.add(new Character( (char) (0x18 | 0x40)));
+ arrCurrResult.addAll(opaquePackedData(intClassId));
+ arrCurrResult.add(new Character( (char) 0x01));
+ return arrCurrResult;
+ }
+
+ private ArrayList processNodeName(Node node) throws Exception {
+ //text = getText(element)
+ //element.parentNode.SyncMLDM_URI += '/' + text
+ return processTextElement(node, 0x1C);
+ }
+
+ private ArrayList processNodePath(Node node) throws Exception {
+ return processTextElement(node, 0x12);
+ }
+
+ private ArrayList processRTProperties(Node node) throws Exception {
+ throw new Exception("Support for RTProperties not implemented !!!");
+ }
+
+ private ArrayList processDFProperties(Node node) throws Exception {
+ ArrayList arrCurrResult = new ArrayList();
+
+ NodeList list = node.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node n = list.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE) {
+ if (n.getNodeName().equals("AccessType")) {
+ arrCurrResult.addAll(processAccessType(n));
+ }
+ else if (n.getNodeName().equals("DFFormat")) {
+ arrCurrResult.addAll(processDFFormat(n));
+ }
+ else if (n.getNodeName().equals("Scope")) {
+ arrCurrResult.addAll(processScope(n));
+ }
+ else {
+ throw new Exception("The tag " + n.getNodeName() +
+ " not supprted for DFProperties !!!");
+ }
+ }
+ }
+ return arrCurrResult;
+ }
+
+ private ArrayList processAccessType(Node node) throws Exception {
+ ArrayList arrCurrResult = new ArrayList();
+ NodeList list = node.getChildNodes();
+ int access = 0;
+ int nodeHasGetAccess = 0;
+ Integer integer;
+ for (int i = 0; i < list.getLength(); i++) {
+ Node n = list.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE) {
+ integer = (Integer) accessMap.get(n.getNodeName());
+ if (integer != null) {
+ access |= integer.intValue();
+ if ("Get".equalsIgnoreCase(n.getNodeName())) {
+ nodeHasGetAccess = 1;
+ }
+ }
+ }
+ }
+ arrCurrResult.add(new Character( (char) 0x5A));
+ arrCurrResult.addAll(opaquePackedData(access));
+ arrCurrResult.add(new Character( (char) 0x01));
+ if (nodeHasGetAccess == 0) {
+ //result = result + '\x55'+ opaqueData(chr(180)) + '\x01'
+ arrCurrResult.add(new Character( (char) 0x55));
+ arrCurrResult.addAll(opaqueCharData( (char) 180));
+ arrCurrResult.add(new Character( (char) 0x01));
+ }
+ return arrCurrResult;
+ }
+
+ private ArrayList processDFFormat(Node node) throws Exception {
+ ArrayList arrCurrResult = new ArrayList();
+ Character format = null;
+ NodeList list = node.getChildNodes();
+
+ for (int i = 0; i < list.getLength(); i++) {
+ Node n = list.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE) {
+ format = (Character) formatMap.get(n.getNodeName());
+ if (format != null) {
+ gformat = n.getNodeName();
+ //WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
+ //System.out.println("format: " + gformat + " value: " + format.charValue() + " opaq: " + opaqueCharData(format.charValue()));
+
+ //@@@@@ py ??? gformat = format
+ //@@@@@ py ??? element.parentNode.parentNode.SyncMLDM_Format = format;
+ break;
+ }
+ }
+ }
+
+ if (format == null) {
+ throw new Exception("DFFormat is an unknown or missing format tag");
+ }
+ else {
+ arrCurrResult.add(new Character( (char) 0x57));
+ arrCurrResult.addAll(opaqueCharData(format.charValue()));
+ arrCurrResult.add(new Character( (char) 0x01));
+ }
+ return arrCurrResult;
+ }
+
+ private ArrayList processScope(Node node) throws Exception {
+ ArrayList arrCurrResult = new ArrayList();
+ Node scope = null;
+ NodeList list = node.getChildNodes();
+
+ for (int i = 0; i < list.getLength(); i++) {
+ Node n = list.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE &&
+ (n.getNodeName().equals("Permanent") ||
+ n.getNodeName().equals("Dynamic"))) {
+ scope = n;
+ break;
+ }
+ }
+
+ if (scope == null) {
+ throw new Exception("Scope element missing Permanent or Dynamic tag");
+ }
+ else {
+ char charScope = (scope.getNodeName().equals("Permanent")) ? (char) 1 :
+ (char) 2;
+ arrCurrResult.add(new Character( (char) 0x59));
+ arrCurrResult.addAll(opaqueCharData(charScope));
+ arrCurrResult.add(new Character( (char) 0x01));
+ }
+ return arrCurrResult;
+ }
+
+ private String getText(Node node) throws Exception {
+ NodeList list = node.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++) {
+ Node n = list.item(i);
+ if (n.getNodeType() == Node.TEXT_NODE) {
+ return n.getNodeValue();
+ }
+ }
+ return "";
+ }
+
+ public ArrayList opaqueStringData(String data) throws Exception {
+ if(data.startsWith(FactBootEnc.GUID_HEX_BOOTSTRAP)){
+ return opaqueHexData(data.replaceFirst(FactBootEnc.GUID_HEX_BOOTSTRAP, ""));
+ }
+ byte[] utf8_bytes = data.getBytes("UTF8");
+ ArrayList arrOpaqueDate = new ArrayList();
+ arrOpaqueDate.add(new Character( (char) 0xC3));
+ arrOpaqueDate.addAll(multiByte(utf8_bytes.length));
+ for (int i = 0; i < utf8_bytes.length; i++) {
+ arrOpaqueDate.add(new Character( (char) (((int)utf8_bytes[i]) & 0xFF) ) );
+ }
+ return arrOpaqueDate;
+
+ /* ArrayList arrOpaqueDate = new ArrayList();
+ arrOpaqueDate.add(new Character( (char) 0xC3));
+ arrOpaqueDate.addAll(multiByte(data.length()));
+ char[] arrChar = data.toCharArray();
+ for (int i = 0; i < arrChar.length; i++) {
+ arrOpaqueDate.add(new Character(arrChar[i]));
+ }
+ return arrOpaqueDate;*/
+ }
+
+ public ArrayList opaqueCharData(char data) throws Exception {
+ ArrayList arrOpaqueDate = new ArrayList();
+ arrOpaqueDate.add(new Character( (char) 0xC3));
+ arrOpaqueDate.addAll(multiByte(1));
+ arrOpaqueDate.add(new Character(data));
+ return arrOpaqueDate;
+ }
+
+ public ArrayList opaquePackedData(int data) throws Exception {
+ ArrayList arrOpaqueDate = new ArrayList();
+ arrOpaqueDate.add(new Character( (char) 0xC3));
+ arrOpaqueDate.addAll(multiByte(2));
+ arrOpaqueDate.add(new Character( (char) (data / 256)));
+ arrOpaqueDate.add(new Character( (char) (data % 256)));
+ return arrOpaqueDate;
+ }
+
+ public ArrayList opaqueHexData(String data) throws Exception {
+ if (data.length() % 2 != 0) {
+ throw new Exception(
+ "HEX-encoded data has incorrect format: data length is not even number.");
+ }
+ ArrayList arrOpaqueDate = new ArrayList();
+ arrOpaqueDate.add(new Character( (char) 0xC3));
+ arrOpaqueDate.addAll(multiByte(data.length() / 2));
+ arrOpaqueDate.addAll(hexToBin(data));
+ return arrOpaqueDate;
+ }
+
+ public ArrayList hexToBin(String data) {
+ ArrayList arrBinDate = new ArrayList();
+ int tmp;
+ for (int i = 0; i < data.length(); i += 2) {
+ tmp = Integer.decode("0x" + data.substring(i, i + 2)).intValue();
+ arrBinDate.add(new Character( (char) tmp));
+ }
+ return arrBinDate;
+ }
+
+ public ArrayList multiByte(int value) throws Exception {
+ ArrayList result = new ArrayList();
+ int continuation = 0;
+ int bits = 0;
+
+ for (int shift = 28; shift > 0; shift -= 7) {
+ bits = (value >> shift) & 0x7F;
+ if (bits > 0 || continuation > 0) {
+ result.add(new Character( (char) (bits | 0x80)));
+ }
+ if (bits > 0) {
+ continuation = 1;
+ }
+ }
+ result.add(new Character( (char) (value & 0x7F)));
+ return result;
+ }
+
+ //Return the WBXML representation of a element with text content
+ // Takes a node and the value of the WBXML tag without content.
+ public ArrayList processTextElement(Node node, int wbxmlTag) throws Exception {
+ ArrayList arrText = new ArrayList();
+ String text = getText(node);
+ if (text.length() > 0) {
+ arrText.add(new Character( (char) (wbxmlTag | 0x40)));
+ arrText.addAll(opaqueStringData(text));
+ arrText.add(new Character( (char) 0x01));
+ }
+ else {
+ arrText.add(new Character( (char) wbxmlTag));
+ }
+ return arrText;
+ }
+
+ public static void main(String[] args) {
+ try {
+ Xml2WBXml x2b = new Xml2WBXml();
+ File file = new File(args[0]);
+ x2b.convert(file);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/FNode.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/FNode.java
new file mode 100644
index 0000000..6a1d206
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/FNode.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//==================================================================================================
+//
+// Module Name: FNode
+//
+// General Description: Provides redirection to FNode (the default File
+// implementation).
+//
+//==================================================================================================
+
+package com.mot.dm.io;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.Reader;
+
+
+/**
+ * Default implementation to redirect to File class
+ * @author jwylder1
+ */
+public class FNode implements Node {
+
+ private final File file;
+
+ /** Creates a new instance of FNode */
+ protected FNode(String path) {
+ file = new File(path);
+ }
+ /** ctor */
+ protected FNode(File file) {
+ this.file = file;
+ }
+
+ protected File getFile() {
+ return this.file;
+ }
+
+ /**
+ * equivalent to listFiles()
+ */
+ public Node[] listNodes() {
+ Node[] nodes = null;
+ File[] children = file.listFiles();
+ if (children != null) {
+ nodes = new FNode[children.length];
+ for (int i = 0; i < children.length; i++) {
+ nodes[i] = (Node) new FNode(children[i]);
+ }
+ }
+ return nodes;
+ }
+
+ /**
+ * redirects to File.isDirectory()
+ */
+ public boolean isDirectory() {
+ return file.isDirectory();
+ }
+
+ /**
+ * get the name of the Node/File
+ */
+ public String getName() {
+ return file.getName();
+ }
+
+ /**
+ * get the absolute path of the
+ * file
+ */
+ public String getAbsolutePath() {
+ return file.getAbsolutePath();
+ }
+
+ /**
+ * @return true if the file
+ * exists
+ */
+ public boolean exists() {
+ return file.exists();
+ }
+
+ /**
+ * @return true if this is a File
+ */
+ public boolean isFile() {
+ return file.isFile();
+ }
+
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/FNodeLoader.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/FNodeLoader.java
new file mode 100644
index 0000000..4c6cc6d
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/FNodeLoader.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//==================================================================================================
+//
+// Module Name: FNodeLoader
+//
+// General Description: Provides redirection to FNode (the default File
+// implementation).
+//
+//==================================================================================================
+
+package com.mot.dm.io;
+
+import java.io.FileNotFoundException;
+import java.io.Reader;
+
+import com.mot.dm.tool.Util;
+
+/**
+ * Default implementation
+ * @author jwylder1
+ */
+public class FNodeLoader extends NodeLoader {
+
+ /** Creates a new instance of FNodeLoader */
+ public FNodeLoader() {
+ }
+
+ public Reader getReaderImpl(String name) throws FileNotFoundException {
+ return Util.openUtf8FileReader(name);
+ }
+
+ public Reader getReaderImpl(Node node) throws FileNotFoundException {
+ FNode fnode = (FNode) node;
+ return Util.openUtf8FileReader(fnode.getFile());
+ }
+
+ protected Node getInstanceImpl(String path) {
+ return (Node) new FNode(path);
+ }
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/Node.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/Node.java
new file mode 100644
index 0000000..852ae7b
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/Node.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//==================================================================================================
+//
+// Module Name: NodeLoader
+//
+// General Description: Abstract node functionality (subset of functions from File)
+//
+//==================================================================================================
+
+package com.mot.dm.io;
+
+/**
+ * Node interface is a subset of the File class
+ * @author jwylder1
+ */
+public interface Node {
+ public Node[] listNodes();
+ public boolean isDirectory();
+ public String getName();
+ public String getAbsolutePath();
+ public boolean exists();
+ public boolean isFile();
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/NodeLoader.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/NodeLoader.java
new file mode 100644
index 0000000..47570af
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/io/NodeLoader.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//==================================================================================================
+//
+// Module Name: NodeLoader
+//
+// General Description: Provides basic factory for accessing a Node. Nodes roughly approximate
+// a files functionality which by default is what actually happens.
+// If special behavior is needed, then the ldr variable can be replaced
+// before any of the modules are called.
+//==================================================================================================
+
+package com.mot.dm.io;
+
+import java.io.FileNotFoundException;
+import java.io.Reader;
+
+/**
+ * NodeLoader provides access to a node and access to the associated reader.
+ * @author jwylder1
+ */
+public abstract class NodeLoader {
+
+ public static NodeLoader ldr = new FNodeLoader(); // default = use files
+
+ protected abstract Node getInstanceImpl(String path) ;
+ protected abstract Reader getReaderImpl(String path) throws FileNotFoundException;
+ protected abstract Reader getReaderImpl(Node node) throws FileNotFoundException;
+
+ /**
+ * get a created node (use instead of File Create
+ */
+ public static Node getInstance(String path) {
+ return ldr.getInstanceImpl(path);
+ }
+
+ /**
+ * @return an associated Reader for this io type
+ */
+ public static Reader getReader(String path) throws FileNotFoundException {
+ return ldr.getReaderImpl(path);
+ }
+
+ /**
+ * @return an associated Reader for this io type
+ */
+ public static Reader getReader(Node node) throws FileNotFoundException {
+ return ldr.getReaderImpl(node);
+ }
+
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/DMTS.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/DMTS.java
new file mode 100644
index 0000000..af71e83
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/DMTS.java
@@ -0,0 +1,288 @@
+package com.mot.dm.tool;
+
+import java.io.*;
+import java.util.*;
+
+public class DMTS {
+ private StringBuffer sb = null;
+ private String topPath = null;
+
+ public void convert(String pathFrom, String pathTo) throws Exception {
+ if (! (pathFrom.toUpperCase().endsWith(".ZIP") ||
+ pathFrom.toUpperCase().endsWith(".DMTS"))) {
+ throw new Exception("\nFormat not supported for parameter <pathFrom>...");
+ }
+ else if (! (pathTo.toUpperCase().endsWith(".ZIP") ||
+ pathTo.toUpperCase().endsWith(".DMTS"))) {
+ throw new Exception("\nFormat not supported for parameter <fileFrom>...");
+ }
+
+ File f;
+ f = new File(pathFrom);
+ if (!f.exists()) {
+ throw new Exception("File doesn't exists: " + pathFrom);
+ }
+ f = new File(pathTo);
+ if (f.exists()) {
+ Util.verbose("Removing file: " + pathTo + "...");
+ f.delete();
+ }
+ if (pathFrom.toUpperCase().endsWith(".ZIP") &&
+ pathTo.toUpperCase().endsWith(".DMTS")) {
+ zip2dmts(pathFrom, pathTo);
+ }
+ else if (pathFrom.toUpperCase().endsWith(".DMTS") &&
+ pathTo.toUpperCase().endsWith(".ZIP")) {
+ dmts2zip(pathFrom, pathTo);
+ }
+ else {
+ throw new Exception("Unsupported format for conversion. \nFormat should be \".zip -> .dmts\" or \".dmts -> .zip\"");
+ }
+ System.out.println("Done");
+ }
+
+ public void dmts2zip(String dmtsPath, String zipPath) throws Exception {
+ String tmpDirPath = "tmp_s2z_" + Calendar.getInstance().getTime().getTime();
+ try {
+ Util.verbose("Converting dmts file to directory Dmt ...");
+ dmts2dir(dmtsPath, tmpDirPath);
+
+ Util.verbose("Zipping directory Dmt ...");
+ Zip zip = new Zip();
+ zip.zip(tmpDirPath + "/Dmt", zipPath);
+ }
+ finally {
+ File f = new File(tmpDirPath);
+ if (f.exists()) {
+ Util.deleteDir(f);
+ }
+ }
+ }
+
+ public void zip2dmts(String zipPath, String dmtsPath) throws Exception {
+ String tmpDirPath = "tmp_z2s_" + Calendar.getInstance().getTime().getTime();
+ try {
+ Util.verbose("Unzipping file to directory Dmt ...");
+ Zip zip = new Zip();
+ zip.unzip(zipPath, tmpDirPath);
+
+ Util.verbose("Converting directory Dmt to dmts file...");
+ dir2dmts(tmpDirPath + "/Dmt", dmtsPath);
+ }
+ finally {
+ File f = new File(tmpDirPath);
+ if (f.exists()) {
+ Util.deleteDir(f);
+ }
+ }
+ }
+
+ public void dmts2dir(String dmtsPath, String outputDir) throws Exception {
+
+ File dmts = new File(dmtsPath);
+ if (!dmts.exists()) {
+ throw new Exception("DMTS file doesn't exist: " + dmtsPath);
+ }
+ else if (dmts.isDirectory()) {
+ throw new Exception("Dmts file cannot be directory : " + dmtsPath);
+ }
+
+ if (outputDir.length() == 0) {
+ outputDir = ".";
+ }
+
+ File output = new File(outputDir);
+
+ if (!output.exists() && !output.mkdirs()) {
+ throw new Exception("Cannot create directory : " + topPath);
+ }
+
+ topPath = output.getPath() + "/Dmt";
+ FileReader fr = new FileReader(dmts);
+ BufferedReader br = new BufferedReader(fr);
+ String line;
+ String currPath = null;
+ String tmp;
+ StringBuffer sbParm = new StringBuffer();
+ try {
+ while ( (line = br.readLine()) != null) {
+ if (line.startsWith("[")) {
+ line = line.trim();
+ tmp = line.substring(1, line.length() - 1);
+ tmp = (tmp.equals(".")) ? "" : Util.replaceStr(tmp, "*", "[]");
+ // if (currPath != null && sbParm.length() > 0) {
+ if (currPath != null) {
+ writeParm(currPath, sbParm.toString());
+ }
+ currPath = topPath + tmp;
+ sbParm = new StringBuffer();
+ }
+ else {
+ sbParm.append(line + "\n");
+ }
+ }
+ }
+ finally {
+ br.close();
+ fr.close();
+ }
+ //if (currPath != null && sbParm.length() > 0) {
+ if (currPath != null) {
+ writeParm(currPath, sbParm.toString());
+ }
+ }
+
+ public void dir2dmtsDir(String dmtDir, String outputDir) throws Exception {
+
+ if(outputDir.toUpperCase().endsWith(".DMTS")){
+ dir2dmts(dmtDir, outputDir);
+ }
+ else{
+
+ if (outputDir.length() > 0) {
+ outputDir += (outputDir.endsWith("/")) ? "" : "/";
+ }
+
+ File f = new File(dmtDir);
+ String dmtsName = f.getName() + ".dmts";
+
+ File dmts = new File(outputDir + dmtsName);
+ if (dmts.exists() && !dmts.canWrite()) {
+ throw new Exception("DMTS file in read only mode: " + outputDir +
+ dmtsName);
+ }
+ dir2dmts(dmtDir, outputDir + dmtsName);
+ }
+ }
+
+ public void dir2dmts(String dmtDir, String dmtsPath) throws Exception {
+ sb = new StringBuffer();
+ topPath = "";
+
+ File top = new File(dmtDir);
+ if (!top.exists()) {
+ throw new Exception("Dmt dir doesn't exist: " + dmtDir);
+ }
+ else if (!top.isDirectory()) {
+ throw new Exception("Dmt dir not directory: " + dmtDir);
+ }
+
+ File dmts = new File(dmtsPath);
+ if (dmts.exists() && !dmts.canWrite()) {
+ throw new Exception("DMTS file in read only mode: " + dmtsPath);
+ }
+
+ File dmtsParent = dmts.getParentFile();
+ if (dmtsParent != null && !dmtsParent.exists()) {
+ dmtsParent.mkdirs();
+ }
+
+ sb.append("[.]\n");
+ topPath = top.getAbsolutePath();
+
+ File[] files = top.listFiles();
+ File parm = getParmFile(files);
+ // if (parm == null) {
+ // throw new Exception("The parm.txt doesn't exists: " + top.getAbsolutePath());
+ // }
+ if (parm != null) {
+ readParm(parm);
+ }
+
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory()) {
+ readDir(files[i]);
+ }
+ }
+ Util.writeFile(dmts.getAbsolutePath(), sb.toString());
+ }
+
+ private void readDir(File f) throws Exception {
+ String path = Util.replaceStr(f.getAbsolutePath(), this.topPath, "");
+ path = Util.replaceStr(path, "\\", "/");
+ path = Util.replaceStr(path, "[]", "*");
+ sb.append("[" + path + "]\n");
+
+ File[] files = f.listFiles();
+ File parm = getParmFile(files);
+ // if (parm == null) {
+ // throw new Exception("The parm.txt doesn't exists: " + f.getAbsolutePath());
+ // }
+ if (parm != null) {
+ readParm(parm);
+ }
+
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory()) {
+ readDir(files[i]);
+ }
+ }
+ }
+
+ private void readParm(File f) throws Exception {
+ FileInputStream in = new FileInputStream(f);
+ byte[] b = new byte[in.available()];
+ in.read(b);
+ String s = new String(b);
+ /* while (s.endsWith("\n")) {
+ s = s.substring(0, s.length() - 1);
+ }
+ sb.append(s + "\n\n");
+ */
+ // add additional
+ sb.append(s + "\n");
+ in.close();
+ }
+
+ private void writeParm(String dirPath, String text) throws Exception {
+ File dir = new File(dirPath);
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ throw new Exception("Cannot create directorie(s) " + dirPath);
+ }
+ }
+ if (text.length() > 0) {
+ if (text.endsWith("\n")) {
+ text = text.substring(0, text.length() - 1);
+ }
+ Util.writeFile(dirPath + "/parm.txt", text);
+ }
+ }
+
+ private File getParmFile(File[] files) {
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isFile() && files[i].getName().equals("parm.txt")) {
+ return files[i];
+ }
+ }
+ return null;
+ }
+
+ public static void main(String[] args) {
+ try {
+ if (args.length != 3) {
+ System.out.println("Wrong arguments");
+ DMTSTool.usage(true);
+ System.exit( -1);
+ }
+
+ Util.VERBOSE = true;
+ DMTS dmts = new DMTS();
+ if (args[0].equals("-sd")) {
+ dmts.dmts2dir(args[1], args[2]);
+ }
+ else if (args[0].equals("-ds")) {
+ dmts.dir2dmtsDir(args[1], args[2]);
+ }
+ else {
+ System.out.println("Wrong arguments");
+ DMTSTool.usage(true);
+ System.exit( -1);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/DMTSTool.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/DMTSTool.java
new file mode 100644
index 0000000..9023093
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/DMTSTool.java
@@ -0,0 +1,137 @@
+package com.mot.dm.tool;
+
+import java.io.File;
+
+public class DMTSTool {
+ private static String fileFrom = null;
+ private static String fileTo = null;
+ private static boolean conversion = false;
+ private static boolean difference = false;
+
+ public static void usage(boolean isForDev) {
+ System.out.println("");
+ System.out.println(
+ "Usage: java com.mot.dm.tool.DMTSTool [-options] <fileFrom> <fileTo>");
+ System.out.println("where options include:");
+ System.out.println(
+ " -conversion perform conversion process for given files ");
+ System.out.println(" file formats: zip or dmts");
+ System.out.println(
+ " -difference find difference between given files ");
+ System.out.println(" file formats: zip or dmts");
+ System.out.println(" -?|-h|--help print this help message");
+ System.out.println(" -verbose enable verbose output");
+ System.out.println(" <fileFrom> path to source file (from)");
+ System.out.println(" <fileTo> path to source file (to)");
+ System.out.println( "");
+
+ if(isForDev){
+ System.out.println("Usage for developers only !!!");
+ System.out.println("\njava com.mot.dm.tool.Diff <fileFrom> <fileTo>");
+ System.out.println(" file formats: dir, zip, dmts");
+ System.out.println("\njava com.mot.dm.tool.DMTS -ds|-sd <fileFrom> <fileTo>");
+ System.out.println(" file formats: dir, dmts");
+ System.out.println(" options: -ds dir to dmts");
+ System.out.println(" -sd dmts to dir");
+ System.out.println("\njava com.mot.dm.tool.Zip -zip|-unzip <fileFrom> <fileTo>");
+ System.out.println(" -zip : dir to .zip");
+ System.out.println(" -unzip : .zip to dir");
+ System.out.println( "");
+ }
+ }
+
+ public static void main(String[] args) {
+ String arg;
+ for (int i = 0; i < args.length; i++) {
+ arg = args[i];
+ if (arg.equals("-?") || arg.equals("-h") || arg.equals("--help")) {
+ usage(false);
+ System.exit( -1);
+ }
+ else if (arg.equals("--helpdev")) {
+ usage(true);
+ System.exit( -1);
+ }
+ else if (arg.equals("-verbose")) {
+ Util.VERBOSE = true;
+ }
+ else if (arg.equals("-conversion")) {
+ conversion = true;
+ }
+ else if (arg.equals("-difference")) {
+ difference = true;
+ }
+ else {
+ if (fileFrom == null) {
+ fileFrom = arg;
+ }
+ else if (fileTo == null) {
+ fileTo = arg;
+ }
+ else {
+ System.out.println("\nWrong parameters...");
+ usage(false);
+ System.exit( -1);
+ }
+ }
+ }
+ if (!validateParms()) {
+ usage(false);
+ System.exit( -1);
+ }
+
+ try {
+ if (difference) {
+ Diff diff = new Diff();
+ diff.getDiff(fileFrom, fileTo);
+ }
+ else if (conversion) {
+ boolean fileFromIsFile = fileFrom.toUpperCase().endsWith(".ZIP") || fileFrom.toUpperCase().endsWith(".DMTS");
+ boolean fileToIsFile = fileTo.toUpperCase().endsWith(".ZIP") || fileTo.toUpperCase().endsWith(".DMTS");
+
+ DMTS dmts = new DMTS();
+ if(fileFromIsFile && fileToIsFile){
+ dmts.convert(fileFrom, fileTo);
+ }
+ else if(fileFromIsFile){
+ dmts.dmts2dir(fileFrom, fileTo);
+ }
+ else if(fileToIsFile){
+ dmts.dir2dmts(fileFrom, fileTo);
+ }
+ else{
+ System.out.println("\nConversion Error!!! Unsupported file format(s) or file combinations");
+ System.exit(-1);
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+ System.exit(1);
+ }
+
+ private static boolean validateParms() {
+
+ if (!conversion && !difference ) {
+ System.out.println(
+ "\nRequired parameter (-conversion or -difference) is missing...");
+ return false;
+ }
+ else if (conversion && difference) {
+ System.out.println(
+ "\nParameters -conversion and -difference cannot be used together...");
+ return false;
+ }
+ if (fileFrom == null) {
+ System.out.println("\nRequired parameter <fileFrom> not set...");
+ return false;
+ }
+ if (fileTo == null) {
+ System.out.println("\nRequired parameter <fileTo> not set...");
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Diff.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Diff.java
new file mode 100644
index 0000000..02a9583
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Diff.java
@@ -0,0 +1,291 @@
+package com.mot.dm.tool;
+
+import java.io.*;
+import java.util.*;
+
+public class Diff {
+ public static boolean VERBOSE = false;
+ private final String NULL = "NULL";
+ private File tmpDir = null;
+ private String path1, path2;
+
+ private ArrayList presentInFirstOnly = new ArrayList();
+ private ArrayList presentInSecondOnly = new ArrayList();
+ private HashMap differentValues = new HashMap();
+
+ public void getDiff(String path1, String path2) throws Exception {
+ this.path1 = path1;
+ this.path2 = path2;
+ tmpDir = new File("tmp_" + Calendar.getInstance().getTime().getTime());
+ try {
+ tmpDir.mkdirs();
+
+ File f;
+ f = new File(path1);
+ if (!f.exists()) {
+ throw new Exception("File doesn't exists: " + path1);
+ }
+ f = new File(path2);
+ if (!f.exists()) {
+ throw new Exception("File doesn't exists: " + path2);
+ }
+
+ String dmtsPath1 = prepareFile(path1, 1);
+ String dmtsPath2 = prepareFile(path2, 2);
+
+ diff(dmtsPath1, dmtsPath2);
+ }
+ finally {
+ if (tmpDir.exists()) {
+ Util.deleteDir(tmpDir);
+ }
+ }
+
+ }
+
+ private String prepareFile(String path, int num) throws Exception {
+ String tmpPath = tmpDir.getAbsolutePath() + "/" + num;
+ File f = new File(tmpPath);
+ if (!f.exists()) {
+ f.mkdirs();
+ }
+ f = new File(path);
+ if (f.isDirectory()) {
+ String dmtsName = f.getName() + ".dmts";
+ DMTS dmts = new DMTS();
+ dmts.dir2dmtsDir(path, tmpPath);
+ return tmpPath + "/" + dmtsName;
+ }
+ else if (path.toUpperCase().endsWith(".DMTS")) {
+ return path;
+ }
+ else if (path.toUpperCase().endsWith(".ZIP")) {
+ Zip z = new Zip();
+ z.unzip(path, tmpPath);
+ DMTS dmts = new DMTS();
+ dmts.dir2dmtsDir(tmpPath + "/Dmt", tmpPath);
+ return tmpPath + "/Dmt.dmts";
+ }
+ else {
+ throw new Exception("Diff doesn't support file format: " + path);
+ }
+ }
+
+ private void diff(String dmtsPath1, String dmtsPath2) throws Exception {
+ HashMap map1 = dmtsToMap(dmtsPath1);
+ HashMap map2 = dmtsToMap(dmtsPath2);
+
+ HashMap parms1, parms2;
+
+ Object[] keys = map1.keySet().toArray();
+
+ for (int i = 0; i < keys.length; i++) {
+ String nodePath = (String) keys[i];
+
+ if (!map2.containsKey(nodePath)) {
+ presentInFirstOnly.add(nodePath);
+ continue;
+ }
+ parms1 = (HashMap) map1.get(nodePath);
+ parms2 = (HashMap) map2.get(nodePath);
+
+ ArrayList arr = compareParms(parms1, parms2);
+ if (arr.size() > 0) {
+ differentValues.put(nodePath, arr);
+ }
+ map2.remove(nodePath);
+ }
+
+ keys = map2.keySet().toArray();
+ for (int i = 0; i < keys.length; i++) {
+ presentInSecondOnly.add(keys[i]);
+ }
+ displayDiff();
+ }
+
+ private HashMap dmtsToMap(String dmtsPath) throws Exception {
+ HashMap map = new HashMap();
+ HashMap hashParms = new HashMap();
+ FileReader fr = new FileReader(dmtsPath);
+ BufferedReader br = new BufferedReader(fr);
+ String line;
+ String currPath = null;
+ String err;
+ try
+ {
+ while ( (line = br.readLine()) != null) {
+ if (line.startsWith("#")) {
+ continue;
+ }
+ if (line.startsWith("[")) {
+ if (currPath != null && !hashParms.isEmpty()) {
+ map.put(currPath, hashParms);
+ }
+ currPath = line;
+ hashParms = new HashMap();
+ }
+ else {
+ if (line.trim().length() > 0) {
+ err = addParmToHash(hashParms, line);
+ if (err != null) {
+ throw new Exception(err + "\n Path: :" + currPath);
+ }
+ }
+ }
+ }
+ }finally{
+ br.close();
+ fr.close();
+ }
+ return map;
+ }
+
+ private ArrayList compareParms(HashMap parms1, HashMap parms2) throws
+ Exception {
+ ArrayList arr = new ArrayList();
+ String v1, v2;
+ Object[] keys = parms1.keySet().toArray();
+ for (int i = 0; i < keys.length; i++) {
+ String name = (String) keys[i];
+ if (!parms2.containsKey(name)) {
+ Parm p = new Parm();
+ p.name = name;
+ p.value1 = (String) parms1.get(name);
+ arr.add(p);
+ continue;
+ }
+ v1 = (String) parms1.get(name);
+ v2 = (String) parms2.get(name);
+ if (v1.equals(v2)) {
+ parms2.remove(name);
+ }
+ else {
+ Parm p = new Parm();
+ p.name = name;
+ p.value1 = (String) parms1.get(name);
+ p.value2 = (String) parms2.get(name);
+ arr.add(p);
+ parms2.remove(name);
+ }
+ }
+ // check rest of second parameters
+ if (!parms2.isEmpty()) {
+ keys = parms2.keySet().toArray();
+ for (int i = 0; i < keys.length; i++) {
+ String name = (String) keys[i];
+ Parm p = new Parm();
+ p.name = name;
+ p.value2 = (String) parms2.get(name);
+ arr.add(p);
+ }
+ }
+
+ return arr;
+ }
+
+ private String addParmToHash(HashMap hashParms, String line) throws Exception {
+ String name = "";
+ String value = "";
+ int i = line.indexOf(":");
+ if (i <= 0) {
+ name = line;
+ value = NULL;
+ //return "Error: attribute doesn't contain \":\".";
+ }else{
+ name = line.substring(0, i);
+ value = line.substring(i + 1, line.length());
+ }
+/* if (name.length() == 0) {
+ return "Error: attribute name in a parm.txt cannot have 0 length.";
+ }
+ else if (value.length() == 0) {
+ return "Error: value cannot have 0 length.";
+ }
+*/
+ hashParms.put(name, value);
+ return null;
+ }
+
+ private void displayDiff() {
+ boolean diffFound = false;
+ System.out.println("\n*********************************** Diff Result ***********************************\n");
+ if (presentInFirstOnly.size() > 0) {
+ diffFound = true;
+ System.out.println("=================== Nodes are presenting in the FIST file only ===================");
+ System.out.println("== ( " + path1 + " ) ==");
+ for (int i = 0; i < presentInFirstOnly.size(); i++) {
+ System.out.println(" " + (String) presentInFirstOnly.get(i));
+ }
+ System.out.println("====================================== END ========================================\n");
+ }
+
+ if (presentInSecondOnly.size() > 0) {
+ diffFound = true;
+ System.out.println("=================== Nodes are presenting in the SECOND file only ===================");
+ System.out.println("== ( " + path2 + " ) ==");
+ for (int i = 0; i < presentInSecondOnly.size(); i++) {
+ System.out.println(" " + (String) presentInSecondOnly.get(i));
+ }
+ System.out.println("====================================== END ========================================\n");
+ }
+
+ if (!differentValues.isEmpty()) {
+ diffFound = true;
+ String diffPath;
+ System.out.println("============ The following nodes has different values for attribute(s) ============");
+ System.out.println("== f1 : " + path1);
+ System.out.println("== f2 : " + path2);
+ System.out.println("===================================================================================");
+
+ Object[] keys = differentValues.keySet().toArray();
+ for (int i = 0; i < keys.length; i++) {
+ StringBuffer sb1 = new StringBuffer();
+ StringBuffer sb2 = new StringBuffer();
+ Parm p;
+ diffPath = (String) keys[i];
+ System.out.println("\n--> " + diffPath);
+ ArrayList arr = (ArrayList) differentValues.get(diffPath);
+ for (int j = 0; j < arr.size(); j++) {
+ p = (Parm) arr.get(j);
+ sb1.append(" f1 -> " + p.name + ":" + p.value1 + "\n");
+ sb2.append(" f2 -> " + p.name + ":" + p.value2 + "\n");
+ }
+ System.out.print(sb1.toString());
+ System.out.println("--------------------");
+ System.out.print(sb2.toString());
+
+ }
+ System.out.println("====================================== END ========================================\n");
+ }
+ if (!diffFound) {
+ System.out.println("============================= The files are identical =============================\n");
+ System.out.println("====================================== END ========================================\n");
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ if (args.length != 2) {
+ System.out.println("Wrong arguments");
+ DMTSTool.usage(true);
+ System.exit( -1);
+ }
+ Util.VERBOSE = true;
+ Diff d = new Diff();
+ d.getDiff(args[0], args[1]);
+ //d.getDiff("Dmt.dmts", "Dmt.dmts");
+ //d.getDiff("I:/tmp/Dmt", "I:/tmp/Dmt.zip");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ class Parm {
+ public String name = "";
+ public String value1 = "";
+ public String value2 = "";
+
+ }
+
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Util.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Util.java
new file mode 100644
index 0000000..a982350
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Util.java
@@ -0,0 +1,152 @@
+package com.mot.dm.tool;
+
+import java.io.*;
+import com.mot.dm.io.Node;
+
+public class Util {
+
+ public static boolean VERBOSE = false;
+
+ // The following 4 functions are using in all classes to read/write files with UTF-8 encoding
+
+ public static Reader openUtf8FileReader( String filename ) throws java.io.FileNotFoundException
+ {
+ try {
+ return new InputStreamReader( new FileInputStream( filename ), "UTF-8" );
+ } catch( java.io.UnsupportedEncodingException e ) {
+ throw new Error( "UTF-8 encoding is unsupported !!?", e );
+ }
+ }
+
+ public static Writer openUtf8FileWriter( String filename ) throws java.io.FileNotFoundException
+ {
+ try {
+ return new OutputStreamWriter( new FileOutputStream( filename ), "UTF-8" );
+ } catch( java.io.UnsupportedEncodingException e ) {
+ throw new Error( "UTF-8 encoding is unsupported !!?", e );
+ }
+ }
+
+ public static Reader openUtf8FileReader( File filename ) throws java.io.FileNotFoundException
+ {
+ try {
+ return new InputStreamReader( new FileInputStream( filename ), "UTF-8" );
+ } catch( java.io.UnsupportedEncodingException e ) {
+ throw new Error( "UTF-8 encoding is unsupported !!?", e );
+ }
+ }
+
+ public static Writer openUtf8FileWriter( File filename ) throws java.io.FileNotFoundException
+ {
+ try {
+ return new OutputStreamWriter( new FileOutputStream( filename ), "UTF-8" );
+ } catch( java.io.UnsupportedEncodingException e ) {
+ throw new Error( "UTF-8 encoding is unsupported !!?", e );
+ }
+ }
+
+ public static String replaceStr(String str, String oldPat, String newPat) {
+ String result = str;
+ int from = 0;
+ while ( (from = str.indexOf(oldPat, from)) >= 0) {
+ result = str.substring(0, from);
+ result += newPat;
+ result += str.substring(from + oldPat.length(), str.length());
+ str = result;
+ }
+ return result;
+ }
+
+ public static void writeFile(String path, String body) throws Exception {
+ PrintWriter fileWriter = new PrintWriter(new FileWriter(path));
+ fileWriter.print(body);
+ fileWriter.flush();
+ fileWriter.close();
+ }
+
+ public static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+ return dir.delete();
+ }
+
+ public static void quickSort(Node children[]) {
+ q_sort(children, 0, children.length - 1);
+ }
+
+ private static void q_sort(Node a[], int low, int high) {
+ int lo = low;
+ int hi = high;
+ Node mid;
+
+ if (high > low) {
+ mid = a[(low + high) / 2];
+
+ while (lo <= hi) {
+
+ while ((lo < high)
+ && (compareStringMultiNodeFirst(a[lo].getName(), mid
+ .getName()) < 0))
+ ++lo;
+
+ while ((hi > low)
+ && (compareStringMultiNodeFirst(a[hi].getName(), mid
+ .getName()) > 0))
+ --hi;
+
+ if (lo <= hi) {
+ Node n = a[hi];
+ a[hi] = a[lo];
+ a[lo] = n;
+
+ ++lo;
+ --hi;
+ }
+ }
+
+ if (low < hi)
+ q_sort(a, low, hi);
+
+ if (lo < high)
+ q_sort(a, lo, high);
+
+ }
+ }
+
+ private static int compareStringMultiNodeFirst(String str1, String str2) {
+ if (str1 == null) {
+ if (str2 == null) {
+ return 0;
+ } else {
+ return -1;
+ }
+
+ } else if (str2 == null) {
+ return 1;
+ }
+ // Check first for multinode definition "[]". The file "[]" should be always first.
+ if (str1.equals("[]") && str2.equals("[]")) {
+ return 0;
+ } else if (str1.equals("[]")) {
+ return -1;
+ } else if (str2.equals("[]")) {
+ return 1;
+ }
+
+ return str1.compareToIgnoreCase(str2);
+ }
+
+ public static void verbose(String msg) {
+ if (VERBOSE) {
+ System.out.println(msg);
+ }
+ }
+
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Zip.java b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Zip.java
new file mode 100644
index 0000000..839ac2e
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/com/mot/dm/tool/Zip.java
@@ -0,0 +1,174 @@
+package com.mot.dm.tool;
+
+import java.io.*;
+import java.util.zip.*;
+import java.util.Enumeration;
+
+public class Zip {
+ private final int BUFFER = 1024;
+ private String topPath;
+
+ public void zip(String inputDir, String outputFile) throws Exception {
+ File input = new File(inputDir);
+
+ if (!input.exists()) {
+ throw new Exception("Input directory doesn't exist: " + inputDir);
+ }
+ else if (!input.isDirectory()) {
+ throw new Exception("Input file doesn't directory: " + inputDir);
+ }
+
+ File output = new File(outputFile);
+ if (!output.getName().toUpperCase().endsWith(".ZIP")) {
+ throw new Exception("Output file is not zip: " + outputFile);
+ }
+ if (!output.exists()) {
+ File parentDir = output.getParentFile();
+ if (parentDir != null && !parentDir.exists()) {
+ parentDir.mkdirs();
+ }
+ }
+ FileOutputStream dest = new FileOutputStream(output);
+ ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
+
+ topPath = input.getParentFile().getAbsolutePath() + File.separator;
+ addFileToZip(input, out);
+ parseDirectory(input, out);
+
+ /*
+ File files[] = input.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory()) {
+ addFileToZip(files[i], out);
+ parseDirectory(files[i], out);
+ }
+ else {
+ addFileToZip(files[i], out);
+ }
+ }
+ }
+ */
+ out.close();
+ }
+
+ public void unzip(String zipFilePath, String outputDir) throws Exception {
+ BufferedOutputStream dest = null;
+ BufferedInputStream is = null;
+ ZipEntry entry;
+
+ ZipFile zipfile = new ZipFile(zipFilePath);
+ Enumeration e = zipfile.entries();
+
+ while (e.hasMoreElements()) {
+ try {
+ entry = (ZipEntry) e.nextElement();
+
+ Util.verbose("Extracting: " + entry);
+
+ is = new BufferedInputStream(zipfile.getInputStream(entry));
+ int count;
+ byte data[] = new byte[BUFFER];
+ outputDir +=
+ (outputDir.length() > 0 && !outputDir.endsWith(File.separator)) ?
+ "/" : "";
+
+ File newFile = new File(outputDir + entry);
+ if (entry.isDirectory()) {
+ if (!newFile.exists()) {
+ newFile.mkdirs();
+ }
+ }
+ else {
+ File parent = newFile.getParentFile();
+ if (parent != null && !parent.exists()) {
+ parent.mkdirs();
+ }
+ }
+
+ FileOutputStream fos = new FileOutputStream(newFile.getAbsolutePath());
+ dest = new BufferedOutputStream(fos, BUFFER);
+ while ( (count = is.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, count);
+ }
+ dest.flush();
+ dest.close();
+ is.close();
+ }
+ catch (Exception ee) {
+//ee.printStackTrace();
+ }
+ }
+ }
+
+ private void parseDirectory(File dir, ZipOutputStream out) throws Exception {
+ File files[] = dir.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory()) {
+ addFileToZip(files[i], out);
+ parseDirectory(files[i], out);
+ }
+ else {
+ addFileToZip(files[i], out);
+ }
+ }
+ }
+
+ private void addFileToZip(File file, ZipOutputStream out) throws Exception {
+
+ BufferedInputStream origin = null;
+ byte data[] = new byte[BUFFER];
+
+ Util.verbose("Adding: " + file);
+
+ String zipEntryName = file.getAbsolutePath();
+ zipEntryName = Util.replaceStr(zipEntryName, topPath, "");
+ zipEntryName = Util.replaceStr(zipEntryName, "\\", "/");
+ if (file.isDirectory() && !zipEntryName.endsWith("/")) {
+ zipEntryName += "/";
+ }
+ ZipEntry entry = new ZipEntry(zipEntryName);
+ out.putNextEntry(entry);
+ if (file.isFile()) {
+ FileInputStream fi = new FileInputStream(file);
+ origin = new BufferedInputStream(fi, BUFFER);
+ int count;
+ while ( (count = origin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ }
+ origin.close();
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ if (args.length != 3) {
+ System.out.println("Wrong arguments");
+ DMTSTool.usage(true);
+ System.exit( -1);
+ }
+
+ Util.VERBOSE = true;
+ Zip zip = new Zip();
+ if(args[0].equals("-zip")){
+ zip.zip(args[1], args[2]);
+ }
+ else if(args[0].equals("-unzip")){
+ zip.unzip(args[1], args[2]);
+ }
+ else{
+ System.out.println("Wrong arguments");
+ DMTSTool.usage(true);
+ System.exit(-1);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ //z.zip("I:\\tmp\\Dmt", "R_NewZIP.zip");
+ // z.unzip("NewZIP.zip", "");
+ // z.unzip("D:/Profiles/E32569/jbproject/Dmt.zip", "");
+ // z.unzip("I:/tmp/Dmt.zip", "");
+ // z.unzip("D:/Profiles/E32569/jbproject/Dmt.zip", "D:\\Profiles\\E32569\\jbproject\\XML2WBXMLPrj\\tmp_1129935212004\\2");
+ }
+}
diff --git a/engine/dmlib/tool-src/dmt_gen_tool/compileTool b/engine/dmlib/tool-src/dmt_gen_tool/compileTool
new file mode 100644
index 0000000..f0f1827
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_gen_tool/compileTool
@@ -0,0 +1,38 @@
+echo JAVA_HOME=$JAVA_HOME
+
+$JAVA_HOME/bin/javac com/mot/dm/io/*.java
+
+echo Please check compilation result for com/mot/dm/io/*.java
+echo press Enter if OK or Ctrl+C
+read $dummy
+
+$JAVA_HOME/bin/javac -classpath .:../dmt-tools/lib/joda-time-1.1.jar:../dmt-tools/lib/jakarta-regexp-1.4.jar com/mot/dm/core/*.java
+
+echo Please check compilation result for com/mot/dm/core/*.java
+echo press Enter if OK or Ctrl+C
+read $dummy
+
+$JAVA_HOME/bin/javac com/mot/dm/tool/*.java
+
+echo Please check compilation result for com/mot/dm/tool/*.java
+echo press Enter if OK or Ctrl+C
+read $dummy
+
+rm -f GenTool.jar
+
+echo Creating jar ...
+
+$JAVA_HOME/bin/jar cvf GenTool.jar com/mot/dm/core/*.class
+
+$JAVA_HOME/bin/jar uvf GenTool.jar com/mot/dm/tool/*.class
+
+$JAVA_HOME/bin/jar uvf GenTool.jar com/mot/dm/io/*.class
+
+echo Removing classes ...
+
+rm -f com/mot/dm/core/*.class
+rm -f com/mot/dm/tool/*.class
+rm -f com/mot/dm/io/*.class
+
+echo done
+
diff --git a/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Access.java b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Access.java
new file mode 100644
index 0000000..721130c
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Access.java
@@ -0,0 +1,12 @@
+package com.mot.treetest;
+
+public class Access {
+ public int get = 0;
+ public int replace = 0;
+ public int delete = 0;
+ public int add = 0;
+
+ public String toString(){
+ return "Get:"+get+"; Add:"+add+"; Replace:"+replace+"; Delete:"+delete;
+ }
+}
diff --git a/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Content.java b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Content.java
new file mode 100644
index 0000000..5006b79
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Content.java
@@ -0,0 +1,6 @@
+package com.mot.treetest;
+
+public class Content {
+ int lines = 0;
+ String tests = "";
+}
diff --git a/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Node.java b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Node.java
new file mode 100644
index 0000000..e2068b4
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Node.java
@@ -0,0 +1,15 @@
+package com.mot.treetest;
+
+import java.util.*;
+
+public class Node {
+ public String path = "not_defined_xxx";
+ public String name = "not_defined_xxx";
+ HashMap parameters = new HashMap();
+ public boolean isLeaf = false;
+ public boolean isMultiNode = false;
+ public boolean isPartOfMultinode = false;
+ String value = "NULL";
+ public Access access = new Access();
+ ArrayList children = new ArrayList();
+}
diff --git a/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/TreeTest.java b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/TreeTest.java
new file mode 100644
index 0000000..5dec3da
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/TreeTest.java
@@ -0,0 +1,491 @@
+package com.mot.treetest;
+
+import java.util.*;
+import java.io.*;
+
+public class TreeTest {
+ private Node rootNode;
+ private String dmtDir;
+ private int counter = 1;
+ private Util u = new Util();
+ private Validator v = new Validator();
+
+ public void createTestFile(String dmtDir, String testFile) throws Exception {
+ this.dmtDir = (new File(dmtDir)).getAbsolutePath();
+ createNodes();
+ Content c = validateNode(rootNode);
+ writeFile(testFile, "SetAutoRelease off \n" + c.tests);
+ System.out.println("Test file has been created...");
+ }
+
+ public Content validateNode(Node n) throws Exception {
+
+ if (n.isLeaf) {
+ return validateLeafNode(n);
+ }
+ else {
+ Content cin = new Content(); //content for interior node
+ Content tmp = null;
+ for (int i = 0; i < n.children.size(); i++) {
+ tmp = validateNode( (Node) n.children.get(i));
+ cin.lines += tmp.lines;
+ cin.tests += tmp.tests;
+ }
+ return validateInteriorNode(n, cin);
+ }
+ }
+
+ public Content validateLeafNode(Node n) throws Exception {
+ // for the future development use line count ...
+ // Content c = new Content();
+ // c.lines = 2;
+ // c.tests = "leaf test: " + n.path + " 0" + "\n" + "leaf test: " + n.path + " 0" + "\n";
+
+ Content c;
+ c = v.validateLeafAccess(n);
+
+ //This MUST execute last before return statment !!!
+ if (n.isPartOfMultinode) {
+ if(n.access.add == 1){
+ String suffix = u.getTypeSuffixForCommand(n);
+ String testVal = u.getTestValue(n);
+ // !!! For the future developmentchange to use use line count, ...
+ String command = "createl" + suffix + " " + n.path + " " + testVal +
+ "\n";
+ c.tests = command + c.tests;
+ c.lines++;
+ return c;
+ }else{
+ return new Content();
+ }
+ }
+ return c;
+ }
+
+ public Content validateInteriorNode(Node n, Content cin) throws Exception {
+ //c.lines = cin.lines + 1;
+ //c.tests = "node test: " + n.path + " " + cin.lines + "\n";
+ //c.tests += cin.tests;
+
+ Content c = v.validateInteriorAccess(n);
+ c.lines = cin.lines;
+ c.tests += cin.tests;
+ if (n.isPartOfMultinode) {
+ // !!! For the future developmentchange to use use line count, ...
+ String command = "createi" + " " + n.path + "\n";
+ c.tests = command + c.tests;
+ c.lines++;
+ }
+ return c;
+ }
+
+ public void createNodes() throws Exception {
+ File rootFile = new File(dmtDir);
+ rootNode = new Node();
+ rootNode.name = ".";
+ rootNode.path = ".";
+ rootNode.parameters = getParms(rootFile.getAbsolutePath());
+ rootNode.access = Util.getAccess(rootNode);
+ File[] fileChildren = rootFile.listFiles();
+ for (int i = 0; i < fileChildren.length; i++) {
+ createChildrenNodes(fileChildren[i], rootNode);
+ }
+ }
+
+ private void createChildrenNodes(File f, Node parentNode) throws Exception {
+ String tmp;
+ Object nodatagen = parentNode.parameters.get("nodatagen");
+ Object storesPD = parentNode.parameters.get("storesPD");
+
+ // ignore all children handled by plugins
+ if (nodatagen != null || storesPD != null) {
+ return;
+ }
+
+ //return from the level parm.txt and ignore settings for Opera
+ if (f.isFile() || f.getName().equals("Opera") || f.getName().equals("Con#")) {
+ return;
+ }
+
+ Node node = new Node();
+
+ tmp = f.getName();
+
+ //tmp = tmp.replaceAll("#", "");
+ tmp = u.replaceAll(tmp, "#", "");
+ //tmp = tmp.replaceAll("@", "");
+ tmp = u.replaceAll(tmp, "@", "");
+ node.name = tmp.trim();
+
+ node.parameters = getParms(f.getAbsolutePath());
+ node.access = Util.getAccess(node);
+ tmp = (String) node.parameters.get("type");
+ if (!tmp.equals("node")) {
+ node.isLeaf = true;
+ }
+
+ nodatagen = node.parameters.get("nodatagen");
+ storesPD = node.parameters.get("storesPD");
+
+ // ignore this child handled by plugins
+ if (nodatagen != null || storesPD != null) {
+ return;
+ }
+
+ // Access a = u.getAccess(parentNode);
+
+ if (node.name.equals("[]")) {
+ //ignore multinodes without access "Add"
+ if (node.access.add == 0) {
+ return;
+ }
+ node.isMultiNode = true;
+ node.isPartOfMultinode = true;
+ String nValues = (String) node.parameters.get("nValues");
+ if (nValues == null) {
+ node.name = "VH_multi" + (counter++);
+ }
+ else {
+ StringTokenizer tok = new StringTokenizer(nValues, ",");
+ while (tok.hasMoreTokens()) {
+ //take the latest name
+ node.name = tok.nextToken().trim();
+ }
+ }
+ }
+ else {
+ node.isPartOfMultinode = parentNode.isPartOfMultinode;
+ //ignore multinodes without access "Add"
+ if (node.isPartOfMultinode && node.access.add == 0) {
+ return;
+ }
+ }
+ node.path = parentNode.path + "/" + node.name;
+
+ // ignore ./SyncML/DMAcc since it should be only for DM 1.2
+ if ("./SyncML/DMAcc".equals(node.path)) {
+ return;
+ }
+
+ File[] fileChildren = f.listFiles();
+ for (int i = 0; i < fileChildren.length; i++) {
+ createChildrenNodes(fileChildren[i], node);
+ }
+
+ parentNode.children.add(node);
+ }
+
+// Utility function to parse the contents of parm.txt files in each DMT directory
+ private HashMap getParms(String fileName) throws
+ Exception {
+ //correct path for multi nodes ( /[]/ )
+ String modifiedFileName = getFileNameForOwnAttributes(fileName);
+
+ HashMap parameters = new HashMap();
+
+ //Get all attributes for the node
+ BufferedReader in = new BufferedReader(new FileReader(modifiedFileName +
+ "/parm.txt"));
+ String line;
+
+ while ( (line = in.readLine()) != null) {
+ //skip empty lines and comments
+ if (line.trim().length() == 0 || line.trim().startsWith("#")) {
+ continue;
+ }
+
+ int nameBoundary = line.indexOf(":");
+ if (nameBoundary <= 0) {
+ continue;
+ }
+
+ String parmName = line.substring(0, nameBoundary);
+ String parmValue = line.substring(nameBoundary + 1);
+
+ if (parmName.equalsIgnoreCase("type")) {
+ if (parmValue.equalsIgnoreCase("boolean")) {
+ parmValue = "bool";
+ }
+ parameters.put("type", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("storesPD")) {
+ parameters.put("storesPD", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("handledByPlugin")) {
+ parameters.put("handledByPlugin", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("id")) {
+ parameters.put("id", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("minLen")) {
+ parameters.put("minLen", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("maxLen")) {
+ parameters.put("maxLen", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("maxChild")) {
+ parameters.put("maxChild", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("min")) {
+ parameters.put("min", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("max")) {
+ parameters.put("max", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("values")) {
+ //parameters.put("values", parmValue.trim().replaceAll(" ", ""));
+ parmValue = u.replaceAll(parmValue, " ", "");
+ parameters.put("values", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("regexp")) {
+ parameters.put("regexp", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("nMaxLen")) {
+ parameters.put("nMaxLen", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("nValues")) {
+ //parameters.put("nValues", parmValue.trim().replaceAll(" ", ""));
+ parmValue = u.replaceAll(parmValue, " ", "");
+ parameters.put("nValues", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("nRegexp")) {
+ parameters.put("nRegexp", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("auto")) {
+ parameters.put("auto", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("fk")) {
+ parameters.put("fk", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("child")) {
+ //parameters.put("child", parmValue.trim().replaceAll(" ", ""));
+ parmValue = u.replaceAll(parmValue, " ", "");
+ parameters.put("child", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("depend")) {
+ parameters.put("depend", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("recur-after-segment")) {
+ parameters.put("recur-after-segment", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("max-recurrence")) {
+ parameters.put("max-recurrence", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("acl")) {
+ parameters.put("acl", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("default")) {
+ parameters.put("default", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("value")) {
+ parameters.put("value", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("mime")) {
+ parameters.put("mime", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("access")) {
+ //parameters.put("access", parmValue.trim().replaceAll(" ", ""));
+ parmValue = u.replaceAll(parmValue, " ", "");
+ parameters.put("access", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("nodatagen")) {
+ parameters.put("nodatagen", new Boolean(true));
+ }
+ else if (parmName.equalsIgnoreCase("nometagen")) {
+ parameters.put("nometagen", new Boolean(true));
+ }
+ else if (parmName.equalsIgnoreCase("store")) {
+ parameters.put("store", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("LOBProgressBAR")) {
+ parameters.put("LOBProgressBAR", parmValue.trim());
+ }
+ else if (parmName.equalsIgnoreCase("description")) {
+ //return parameters;
+ break;
+ }
+ else {
+ //ignore unsupported attributes
+ continue;
+ }
+ }
+
+ in.close();
+//System.out.println(modifiedFileName + " modifiedFileName.length()=" +modifiedFileName.length() + "dmtDir.length()="+dmtDir.length());
+ if (modifiedFileName.length() > dmtDir.length()) {
+ // get attribute "Add" from the parent node for the modifiedFileName
+ in = new BufferedReader(new FileReader( (new File(
+ modifiedFileName)).getParentFile().getAbsolutePath() + "/parm.txt"));
+
+ while ( (line = in.readLine()) != null) {
+ //skip empty lines and comments
+ if (line.trim().length() == 0 || line.trim().startsWith("#")) {
+ continue;
+ }
+
+ int nameBoundary = line.indexOf(":");
+ if (nameBoundary <= 0) {
+ continue;
+ }
+
+ String parmName = line.substring(0, nameBoundary);
+ String parmValue = line.substring(nameBoundary + 1);
+
+ if (parmName.equalsIgnoreCase("access")) {
+ //parameters.put("access", parmValue.trim().replaceAll(" ", ""));
+ parmValue = u.replaceAll(parmValue, " ", "");
+ parameters.put("parentAccess", parmValue.trim());
+ break;
+ }
+ }
+
+ in.close();
+ }
+
+ return parameters;
+ }
+
+ private void writeFile(String path, String data) throws
+ Exception {
+ BufferedWriter out = new BufferedWriter(new FileWriter(path));
+ out.write(data);
+ out.close();
+ }
+
+ public void parseResult(String resultFile, String errorFile) throws Exception {
+ BufferedReader in = new BufferedReader(new FileReader(resultFile));
+ String line;
+ String str;
+ StringBuffer tmp = new StringBuffer();
+ StringBuffer err = new StringBuffer();
+
+ while ( (line = in.readLine()) != null) {
+ if (line.trim().length() == 0) {
+ str = tmp.toString();
+ if (str.indexOf("[31mError!") > 0) {
+ err.append(str + "\n");
+ }
+ tmp = new StringBuffer();
+ }
+ else {
+ tmp.append(line + "\n");
+ }
+ }
+
+ str = tmp.toString();
+ if (str.indexOf("[31mError!") > 0) {
+ err.append(str + "\n");
+ }
+
+ if (err.length() > 0) {
+ System.out.println(
+ "\n!!!An error occurred!!! Please check file with all errors:\n " +
+ errorFile + "\n");
+ System.out.println(err.toString());
+ writeFile(errorFile, err.toString());
+ System.exit(1);
+ }
+ else {
+ System.out.println("\n-Test completed successfully...");
+ }
+ }
+
+ public static void usage() {
+ System.out.println(
+ "Usage: java com.mot.treetest.TreeTest testgen <path/Dmt> <path/test.txt>\n" +
+ " or java com.mot.treetest.TreeTest testrun <path/result.txt>");
+ }
+
+ //replace all file names to [] if required (for multi nodes)
+ private String getFileNameForOwnAttributes(String fileName) throws Exception {
+ if (fileName.length() == dmtDir.length()) {
+ return fileName; // root node
+ }
+ String path = dmtDir; // new path including multi nodes ./a/[]/f/[]/#s
+ String tmpPath = dmtDir; //real path for requested file ./a/b/f/c/#s
+ String uniquePath = fileName.substring(dmtDir.length(), fileName.length());
+ String delim = File.separator;
+ String tmpFolderName;
+ boolean multiNodeFound;
+ StringTokenizer st = new StringTokenizer(uniquePath, delim);
+ while (st.hasMoreTokens()) {
+ tmpFolderName = st.nextToken();
+ multiNodeFound = false;
+
+ //System.out.println("tmpFolderName = " + tmpFolderName);
+ //if(true){
+ // continue;
+ // }
+
+ if (tmpFolderName.equals("[]")) {
+ path = path.concat(File.separator).concat(tmpFolderName);
+ }
+ else {
+ File currentParentDir = new File(path);
+ File[] childrens = currentParentDir.listFiles();
+ for (int i = 0; i < childrens.length; i++) {
+ if (childrens[i].getName().equals("[]")) {
+ multiNodeFound = true;
+ break;
+ }
+ }
+
+ // this is the real path for requested file
+ tmpPath = tmpPath.concat(File.separator).concat(tmpFolderName);
+ if (multiNodeFound) {
+ path = path.concat(File.separator).concat("[]");
+ }
+ else {
+ path = path.concat(File.separator).concat(tmpFolderName);
+ }
+ }
+ }
+ //System.out.println("fileName = " + fileName);
+ //System.out.println("path = " + path +"\n");
+ return path;
+ }
+
+ public static void main(String[] args) {
+ try {
+ TreeTest tt = new TreeTest();
+
+ /*
+ tt.createTestFile("path/Dmt", "path/tests.txt"); //test
+ // tt.createTestFile("I:\\remove_later\\access_Local\\Dmt", "path/tests.txt"); //test
+ if (true) { //test
+ return; //test
+ } //test
+*/
+ if (args.length == 0) {
+ usage();
+ System.exit(1);
+ }
+
+ String action = args[0];
+ if ("testgen".equals(action)) {
+ if (args.length != 3) {
+ usage();
+ System.exit(1);
+ }
+ tt.createTestFile(args[1], args[2]);
+ }
+ else if ("testrun".equals(action)) {
+ if (args.length != 3) {
+ usage();
+ System.exit(1);
+ }
+ tt.parseResult(args[1], args[2]);
+ }
+ else {
+ usage();
+ System.exit(1);
+ }
+ System.exit(0);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+}
diff --git a/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Util.java b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Util.java
new file mode 100644
index 0000000..77bdd90
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Util.java
@@ -0,0 +1,193 @@
+package com.mot.treetest;
+
+import java.util.*;
+
+public class Util {
+
+ public String getCreateCommand(String nodeType) {
+ if (nodeType.equals("node")) {
+ return "createi";
+ }
+ else if (nodeType.equals("chr")) {
+ return "createl";
+ }
+ else if (nodeType.equals("bin")) {
+ return "createlb";
+ }
+ else if (nodeType.equals("bool")) {
+ return "createlz";
+ }
+ else if (nodeType.equals("int")) {
+ return "createli";
+ }
+ else if (nodeType.equals("date")) {
+ return "createld";
+ }
+ else if (nodeType.equals("time")) {
+ return "createlt";
+ }
+ else if (nodeType.equals("float")) {
+ return "createlf";
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String getSetCommand(String nodeType) {
+ if (nodeType.equals("chr")) {
+ return "set";
+ }
+ else if (nodeType.equals("bin")) {
+ return "setb";
+ }
+ else if (nodeType.equals("bool")) {
+ return "setz";
+ }
+ else if (nodeType.equals("int")) {
+ return "seti";
+ }
+ else if (nodeType.equals("date")) {
+ return "setd";
+ }
+ else if (nodeType.equals("time")) {
+ return "sett";
+ }
+ else if (nodeType.equals("float")) {
+ return "setf";
+ }
+ else {
+ return null;
+ }
+ }
+
+ public static Access getAccess(Node n) {
+ Access a = new Access();
+ String parmValue = (String) n.parameters.get("access");
+ if (parmValue != null) {
+ StringTokenizer tok = new StringTokenizer(parmValue, ",");
+ String accessType;
+ while (tok.hasMoreTokens()) {
+ accessType = tok.nextToken().trim();
+ if ("Get".equals(accessType)) {
+ a.get = 1;
+ }
+ else if ("Add".equals(accessType)) {
+ a.add = 1;
+ }
+ else if ("Replace".equals(accessType)) {
+ a.replace = 1;
+ }
+ else if ("Delete".equals(accessType)) {
+ a.delete = 1;
+ }
+ }
+ }
+
+ // get access "Add" from parent
+ parmValue = (String) n.parameters.get("parentAccess");
+ if (parmValue != null) {
+ a.add = 0;
+ StringTokenizer tok = new StringTokenizer(parmValue, ",");
+ String accessType;
+ while (tok.hasMoreTokens()) {
+ accessType = tok.nextToken().trim();
+ if ("Add".equals(accessType)) {
+ a.add = 1;
+ }
+ }
+ }
+ return a;
+ }
+
+ public String getTypeSuffixForCommand(Node n) {
+ String type = (String) n.parameters.get("type");
+ if ("int".equals(type)) {
+ return "i";
+ }
+ else if ("bool".equals(type)) {
+ return "z";
+ }
+ else if ("bin".equals(type)) {
+ return "b";
+ }
+ else if ("date".equals(type)) {
+ return "d";
+ }
+ else if ("time".equals(type)) {
+ return "t";
+ }
+ else if ("float".equals(type)) {
+ return "f";
+ }
+ else {
+ return "";
+ }
+ }
+
+ public String getTestValue(Node n) throws Exception {
+ String values = (String) n.parameters.get("values");
+ //take first from the predefined values
+ if (values != null) {
+ StringTokenizer tok = new StringTokenizer(values, ",");
+ if (tok.hasMoreTokens()) {
+ return tok.nextToken().trim();
+ }
+ }
+
+ String type = (String) n.parameters.get("type");
+ if ("int".equals(type)) {
+ String min = (String) n.parameters.get("min");
+ if (min == null) {
+ return "1";
+ }
+ else {
+ return (Integer.parseInt(min) + 1) + "";
+ }
+
+ }
+ else if ("bool".equals(type)) {
+ return "true";
+ }
+ else if ("bin".equals(type)) {
+ return "1A";
+ }
+ else if ("date".equals(type)) {
+ return "1962-02-06";
+ }
+ else if ("time".equals(type)) {
+ return "07:40";
+ }
+ else if ("float".equals(type)) {
+ return "1.1";
+ }
+ else {
+ return "VH";
+ }
+
+ }
+
+// use this function instead .replaceAll() to support java 1.3.x.x
+ public String replaceAll(String line, String oldStr, String newStr) {
+ int i = 0;
+
+ if ( (i = line.indexOf(oldStr, i)) >= 0) {
+ char[] line2 = line.toCharArray();
+ StringBuffer buf = new StringBuffer(line2.length);
+ buf.append(line2, 0, i).append(newStr);
+
+ i++;
+ int j = i;
+
+ while ( (i = line.indexOf(oldStr, i)) > 0) {
+ buf.append(line2, j, i - j).append(newStr);
+ i++;
+ j = i;
+ }
+ buf.append(line2, j, line2.length - j);
+ return buf.toString();
+ }
+ return line;
+ }
+
+}
diff --git a/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Validator.java b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Validator.java
new file mode 100644
index 0000000..46c4ed7
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_validate/com/mot/treetest/Validator.java
@@ -0,0 +1,59 @@
+package com.mot.treetest;
+
+public class Validator {
+ Util u = new Util();
+
+ public Content validateLeafAccess(Node n) throws Exception {
+ //For the future development: command + path + value + lineCount + retCode
+ String command = "";
+ int count = 0;
+ String suffix = u.getTypeSuffixForCommand(n);
+ String testVal = u.getTestValue(n);
+ Access a = u.getAccess(n);
+ // Get, Replace, Delete, Add
+ // start from the bottom "Add". check that we can delete it before
+ if (a.add == 1 && a.delete == 1) {
+ //command = "createl" + suffix + " " + n.path + " " + testVal + count + " 0\n";
+ command = "createl" + suffix + " " + n.path + " " + testVal + "\n";
+ //count++;
+ }
+ // Next from the bottom "Delete"
+ if (a.delete == 1) {
+ command = "delete " + n.path + "\n" + command;
+ //count++;
+ }
+ // Next from the bottom "Replace"
+ if (a.replace == 1) {
+ //command = "set" + suffix + " " + n.path + " " + testVal + count + " 0\n";
+ command = "set" + suffix + " " + n.path + " " + testVal + "\n" + command;
+ //count++;
+ }
+ // Next from the bottom "Get"
+ if (a.get == 1) {
+ command = "get " + n.path + "\n" + command;
+ //count++;
+ }
+
+ Content c = new Content();
+ c.tests = command;
+ c.lines = count;
+
+ return c;
+ }
+
+ public Content validateInteriorAccess(Node n) {
+ //For the future development: command + path + value + lineCount + retCode
+ String command = "";
+ int count = 0;
+
+ command = "get " + n.path + "\n";
+ count++;
+
+ Content c = new Content();
+ c.tests = command;
+ c.lines = count;
+
+ return c;
+ }
+
+}
diff --git a/engine/dmlib/tool-src/dmt_validate/compileTestTool b/engine/dmlib/tool-src/dmt_validate/compileTestTool
new file mode 100644
index 0000000..049a4ef
--- /dev/null
+++ b/engine/dmlib/tool-src/dmt_validate/compileTestTool
@@ -0,0 +1,16 @@
+
+
+$JAVA_HOME/bin/javac com/mot/treetest/*.java
+echo Please check result and press Enter
+read $dummy
+
+rm -f DMTTest.jar
+
+echo Creating jar ...
+$JAVA_HOME/bin/jar cvf DMTTest.jar com/mot/treetest/*.class
+
+echo Removing classes ...
+rm -f com/mot/treetest/*.class
+
+echo
+
diff --git a/engine/dmlib/tool-src/file_convertor/file_convertor b/engine/dmlib/tool-src/file_convertor/file_convertor
new file mode 100644
index 0000000..468f645
--- /dev/null
+++ b/engine/dmlib/tool-src/file_convertor/file_convertor
Binary files differ
diff --git a/engine/dmlib/tool-src/file_convertor/src/file_convertor.cc b/engine/dmlib/tool-src/file_convertor/src/file_convertor.cc
new file mode 100644
index 0000000..87fc83a
--- /dev/null
+++ b/engine/dmlib/tool-src/file_convertor/src/file_convertor.cc
@@ -0,0 +1,350 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <dirent.h>
+
+#define MAX_STRING_LENGTH 255
+
+
+bool IsEnd(int handler)
+{
+ int nPos;
+
+ nPos = lseek(handler,0,SEEK_CUR);
+
+ if ( nPos < 0 )
+ return true; // means some error
+
+ struct stat st;
+ if(fstat(handler, &st) < 0)
+ return true;
+
+ if ( st.st_size == nPos )
+ return true;
+ else
+ return false;
+}
+
+
+char* ReadLine(int handler, char* s, int size )
+{
+
+ char c = 0;
+ int nPos = 0;
+
+ while ( read(handler, &c, 1 ) != -1 && !IsEnd(handler) )
+ {
+ s[nPos] = c;
+ nPos++;
+
+ if ( c == '\n' )
+ break;
+ }
+ s[nPos] = 0;
+ return s;
+}
+
+
+void ConvertFile(const char * pPath, const char * pFileName, const char * pExtension, bool bTextFile)
+{
+
+
+ char full_path_in[MAX_STRING_LENGTH];
+ char full_path_out_c[MAX_STRING_LENGTH];
+ char full_path_out_h[MAX_STRING_LENGTH];
+ char signature[MAX_STRING_LENGTH];
+ char str[MAX_STRING_LENGTH];
+ char str_size[20];
+ int size;
+
+ int len = pExtension == NULL ? 0 : strlen(pExtension)+1;
+
+ strcpy(full_path_in,pPath);
+ strcat(full_path_in,"/");
+ strcat(full_path_in,pFileName);
+
+ memset(signature,0,MAX_STRING_LENGTH);
+ memset(str,0,MAX_STRING_LENGTH);
+
+ strncpy(signature,pFileName,strlen(pFileName)-len);
+
+ int file_handler_in;
+ file_handler_in = open(full_path_in, O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
+ if ( file_handler_in == -1 )
+ {
+ printf("Unable open file %s\n",full_path_in);
+ return;
+ }
+
+ struct stat st;
+ if(fstat(file_handler_in, &st) < 0)
+ {
+ printf("Unable get size of file %s\n",full_path_in);
+ return;
+ }
+
+ size = st.st_size;
+
+ if ( pExtension )
+ {
+ strcat(signature,"_");
+ strcat(signature,pExtension);
+ }
+
+ strcpy(full_path_out_c,signature);
+ strcpy(full_path_out_h,signature);
+
+ strcat(full_path_out_c,".c");
+ strcat(full_path_out_h,".h");
+
+ strcpy(str,"#include \"");
+ strcat(str,signature);
+ strcat(str,".h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n");
+ strcat(str,"static UINT8 ");
+ strcat(str,signature);
+ strcat(str,"[] = {\n");
+
+ int file_handler_c;
+ int file_handler_h;
+
+ file_handler_c = open(full_path_out_c, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
+ if ( file_handler_c == -1 )
+ {
+ printf("Unable open file %s\n",full_path_out_c);
+ return;
+ }
+
+
+ file_handler_h = open(full_path_out_h, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
+ if ( file_handler_h == -1 )
+ {
+ printf("Unable open file %s\n",full_path_out_h);
+ return;
+ }
+
+ write(file_handler_c,str,strlen(str));
+
+ int current_byte_in_line = 0;
+ int current_byte = 0;
+ char hex_byte[20];
+ int i;
+
+ if ( pExtension && strcmp(pExtension,"bmdf") == 0 )
+ {
+ int value = 0;
+ unsigned char value1[4];
+
+ read(file_handler_in,(unsigned char*)value1,4);
+ if ( value1[0] == '[' && (value1[1] == '/' || value1[2] == '.') )
+ {
+ printf("BMDF: file %s not recognized as a bmdf file\n",full_path_in);
+ return;
+ }
+
+ for (i=0; i<4; i++)
+ {
+ value |= value1[i] << (i*8);
+ }
+ if ( value != size )
+ {
+ printf("corrupted mdf file %s ,size %d\n",full_path_in,value);
+ return;
+ }
+ printf("mdf file %s ,size %d\n",full_path_in,value);
+ lseek(file_handler_in,0,SEEK_SET);
+ }
+
+
+ if ( bTextFile == true )
+ {
+ char line[300];
+ int new_size = 0;
+ int line_len = 0;
+ while ( !IsEnd(file_handler_in) )
+ {
+ ReadLine(file_handler_in,line,300);
+ if ( line[0] == '#' )
+ continue;
+
+ line_len = strlen(line);
+ while ( line_len > 0 && (line[line_len-1]=='\r' || line[line_len-1]=='\n' ||
+ line[line_len-1]==' ' || line[line_len-1]=='\t' ) )
+ line[--line_len]='\0';
+
+ if ( line_len == 0 )
+ continue;
+
+ char * new_line = line;
+
+ while ( ( *new_line == ' ' || *new_line == '\t') && *new_line != '\0' )
+ new_line ++;
+
+ line_len = strlen(new_line);
+
+ if ( line_len == 0 )
+ continue;
+
+ line[line_len] = '\0';
+ for (i = 0; i<=line_len; i++)
+ {
+ if ( line[i] == '\t' )
+ line[i] = ' ';
+ current_byte_in_line++;
+ new_size++;
+ if ( i < line_len )
+ {
+ if ( current_byte_in_line != 30 )
+ sprintf(hex_byte,"%#4x,",line[i]);
+ else
+ {
+ sprintf(hex_byte,"%#4x,\n",line[i]);
+ current_byte_in_line = 0;
+ }
+ }
+ else
+ {
+ if ( IsEnd(file_handler_in) )
+ sprintf(hex_byte,"%#4x\n",line[i]);
+ else
+ {
+ if ( current_byte_in_line != 30 )
+ sprintf(hex_byte,"%#4x,",line[i]);
+ else
+ {
+ sprintf(hex_byte,"%#4x,\n",line[i]);
+ current_byte_in_line = 0;
+ }
+ }
+ }
+ write(file_handler_c,hex_byte,strlen(hex_byte));
+ }
+ }
+ size = new_size;
+ }
+ else
+ {
+
+ for (int i=0; i<size; i++)
+ {
+ read(file_handler_in,&current_byte,1);
+ current_byte_in_line++;
+ if ( i != size - 1 )
+ {
+ if ( current_byte_in_line != 30 )
+ sprintf(hex_byte,"%#4x,",current_byte);
+ else
+ {
+ sprintf(hex_byte,"%#4x,\n",current_byte);
+ current_byte_in_line = 0;
+ }
+ }
+ else
+ sprintf(hex_byte,"%#4x\n",current_byte);
+ write(file_handler_c,hex_byte,strlen(hex_byte));
+ }
+ }
+
+ strcpy(str,"};\n\n");
+
+ write(file_handler_c,str,strlen(str));
+
+ sprintf(str_size,"%d",size);
+
+ strcpy(str,"#ifndef ");
+ strcat(str,signature);
+ strcat(str,"_H\n#define ");
+ strcat(str,signature);
+ strcat(str,"_H\n\n#include \"xpl_Types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n");
+
+ write(file_handler_h,str,strlen(str));
+
+
+ strcpy(str,"const UINT8 * dmGet_");
+ strcat(str,signature);
+ strcat(str,"(UINT32 * size)");
+
+ write(file_handler_h,str,strlen(str));
+ write(file_handler_c,str,strlen(str));
+
+ strcpy(str,";\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n");
+
+ write(file_handler_h,str,strlen(str));
+
+ strcpy(str,"\n{\n if ( size )\n {\n *size = ");
+ strcat(str,str_size);
+ strcat(str,";\n return ");
+ strcat(str,signature);
+ strcat(str,";\n }\n else\n {\n return NULL;\n }\n}\n\n#ifdef __cplusplus\n}\n#endif\n\n");
+
+ write(file_handler_c,str,strlen(str));
+
+ close(file_handler_c);
+ close(file_handler_h);
+ close(file_handler_in);
+
+}
+
+
+void ConvertFiles(const char * pPath, const char * pExtension, bool bTextFile)
+{
+
+ DIR *dir = NULL;
+ struct dirent *de = NULL;
+
+
+ dir = opendir(pPath);
+ if ( dir == NULL )
+ {
+ printf("cannot open dir : %s\n",pPath);
+ return;
+ }
+
+ int nExtensionLen = pExtension == NULL ? 0 : strlen(pExtension);
+ while ( de = readdir(dir) )
+ {
+ int nNameLen = strlen(de->d_name);
+ if (nNameLen > nExtensionLen && !strncmp((de->d_name + nNameLen - nExtensionLen), pExtension, nExtensionLen))
+ {
+ ConvertFile(pPath,de->d_name,pExtension,bTextFile);
+ }
+ }
+ closedir(dir);
+
+}
+
+int main(int argc, char** argv)
+{
+
+
+ char * settings_path = getenv("dm_setting_root");
+ char * plugin_path = getenv("dm_setting_plugin");
+
+ if ( settings_path == NULL && plugin_path == NULL )
+ {
+ printf("env variables are not set :dm_setting_root, dm_setting_plugin\n");
+ return 0;
+ }
+
+ if ( settings_path )
+ {
+ printf("dm settings : %s\n",settings_path);
+
+ char * s = (char*)strchr( (const char *)settings_path, ':' );
+ if ( s )
+ s = '\0';
+
+ ConvertFiles(settings_path,"bmdf",false);
+ ConvertFile(settings_path,"fstab",NULL,true);
+ }
+ if ( plugin_path )
+ {
+ printf("plugin settings : %s\n",plugin_path );
+ ConvertFiles(plugin_path,"ini",true);
+ }
+ return 0;
+}
diff --git a/engine/dmlib/tool-src/servercred/Server_Cred_users_guide.txt b/engine/dmlib/tool-src/servercred/Server_Cred_users_guide.txt
new file mode 100644
index 0000000..668d96a
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/Server_Cred_users_guide.txt
@@ -0,0 +1,54 @@
+================================================================================
+Server credential autogeneration tool users guide
+================================================================================
+
+1. Prepare a plain text file containing all the IMEIs that you are going to
+ process.
+
+ For example, the text file named IMEI.txt might contain the following text:
+
+ 354358001352586
+
+2. The syntax for the command is:
+
+ servercred <input_file_path> <input_file_name>.txt
+
+ A file will be created in the <input_file_path> directory. The format of the
+ file name is:
+
+ <input_file_name>_Cred-<time_date_stamp>.txt
+
+3. As an example, enter:
+
+ servercred . IMEI.txt
+
+ The program will print out:
+
+ file fd_IMEI opened
+
+ ENTER THE SERVER ID
+
+ Enter the Server Id that you need to generate.
+ For example, the server id might be: ibm
+
+ The program will print out:
+
+ filew fd_Cred opened
+
+ GENERATED CRED VALUES EACH SEPARATED BY SPACE CHAR IN IMEI_Cred-14.32.19-18-02-2005.txt
+
+ IMEI ServerPW ClientPW UserName ServerNonce ClientNonce
+
+ ENTER A KEY TO EXIT
+
+ Press any key to exit.
+
+ The file IMEI_Cred-14.32.19-18-02-2005.txt will contains the following info:
+
+ 354358001352586 EtYTmcmXUPjteHV8i+4f1g== 6DEU6GduEznJfqD08puMyA== LXgpyGcdtADjNX9EsgBwpg== MTRZSjU1Tkk2NVJTMjVXQQ== NTNMSTYyTUkyM0hFMzNTVA==
+
+ This is the credentials in the following order:
+
+ IMEI ServerPW ClientPW UserName ServerNonce ClientNonce
+
+
diff --git a/engine/dmlib/tool-src/servercred/hdr/DeviceInfo.H b/engine/dmlib/tool-src/servercred/hdr/DeviceInfo.H
new file mode 100644
index 0000000..2131c39
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/hdr/DeviceInfo.H
@@ -0,0 +1,37 @@
+#ifndef DEVICEINFO_H
+#define DEVICEINFO_H
+
+class DeviceInfo
+{
+
+ public:
+
+ DeviceInfo();
+ ~DeviceInfo();
+
+ void setIMEI(char * aIMEI);
+ void setDeviceId(char * did);
+ void setServerId(char * sid);
+ void setUserName(char * aUserName);
+ void setClientPassword(char * aClientPassword);
+ void setServerPassword(char * aServerPassword);
+
+ char * getIMEI();
+ char * getDeviceId();
+ char * getServerId();
+ char * getUserName();
+ char * getClientPassword();
+ char * getServerPassword();
+
+ private:
+
+ char * imei;
+ char * deviceId;
+ char * serverId;
+ char * userName;
+ char * clientPassword;
+ char * serverPassword;
+ char * DEVICE_ID_PREFIX;
+};
+
+#endif
diff --git a/engine/dmlib/tool-src/servercred/hdr/GeneratePassword.H b/engine/dmlib/tool-src/servercred/hdr/GeneratePassword.H
new file mode 100644
index 0000000..4378b71
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/hdr/GeneratePassword.H
@@ -0,0 +1,57 @@
+#ifndef GENERATEPASSWORD_H
+#define GENERATEPASSWORD_H
+
+class GeneratePassword
+{
+
+ public:
+
+ GeneratePassword();
+
+ ~GeneratePassword();
+
+ char * generateClientPasswordKey(char * deviceId);
+
+ char * generateKeyFromDict(char * deviceId, char dict[]);
+
+ char * generateServerPasswordKey(char * deviceId);
+
+ char * generateClientPassword(char * deviceId, char * serverId);
+
+ char * generateServerPassword(char * deviceId, char * serverId);
+
+ char * generateClientPassword();
+
+ char * generateServerPassword();
+
+ char * encodeDeviceId(char * deviceId);
+
+ char * get36BasedIMEI(char * deviceId);
+
+ char * generatePassword(char * deviceId, char * serverId, char * key);
+
+ char * encodeHex(char data[]);
+
+ long long convertChar2Long(char * input);
+
+ void shuffle(char & buffer);
+
+ void setServerId(const char * sid);
+
+ void setIMEI(const char * did);
+
+ char * getIMEI();
+
+ char * getServerId();
+
+ private:
+
+ char * serverId;
+ char * imei;
+ char clientPasswordDict [15];
+ char serverPasswordDict[15];
+ char hexTable[16];
+ int MD5_HASH_LENGTH;
+};
+
+#endif
diff --git a/engine/dmlib/tool-src/servercred/hdr/md5.h b/engine/dmlib/tool-src/servercred/hdr/md5.h
new file mode 100644
index 0000000..71f00d1
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/hdr/md5.h
@@ -0,0 +1,51 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+ */
+
+/* POINTER defines a generic pointer type */
+typedef unsigned char *POINTER;
+
+/* UINT2 defines a two byte word */
+typedef unsigned short int UINT2;
+
+/* UINT4 defines a four byte word */
+typedef unsigned int UINT4;
+
+
+/* MD5 context. */
+typedef struct {
+ UINT4 state[4]; /* state (ABCD) */
+ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ unsigned char buffer[64]; /* input buffer */
+} MD5_CTX;
+
+void smlMD5Init (MD5_CTX *);
+void smlMD5Update (MD5_CTX *, unsigned char *, unsigned int);
+void smlMD5Final (unsigned char [16], MD5_CTX *);
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/dmlib/tool-src/servercred/hdr/xpt-b64.h b/engine/dmlib/tool-src/servercred/hdr/xpt-b64.h
new file mode 100644
index 0000000..a5cfbec
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/hdr/xpt-b64.h
@@ -0,0 +1,169 @@
+/*************************************************************************/
+/* module: Communication Services, base64 encoding/decoding fns.*/
+/* file: /src/xpt/all/xpt-b64.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+/**
+ * function prototypes and return codes
+ * for base64 encoding/ decoding functions.
+ *
+ */
+
+#ifndef XPT_B64_H
+#define XPT_B64_H
+
+#include "xpttypes.h"
+
+/**
+ * FUNCTION: base64GetSize
+ *
+ * Precalculates the size of an encoded document with the given size
+ *
+ * PRE-Condition:
+ * The function is called to get the size of the document that
+ * will be encoded with the base64Encode() service.
+ *
+ * POST-Condition:
+ *
+ * IN: cbRealDataSize, the size of the non-encoded document.
+ *
+ * RETURN: BufferSize_t, the size of the encoded document that will be
+ * generated using the base64Encode() service.
+ *
+ */
+
+BufferSize_t base64GetSize (BufferSize_t cbRealDataSize);
+
+/**
+ * FUNCTION: base64Encode
+ *
+ * Encodes a chunk of data according to the base64 encoding rules
+ *
+ * PRE-Condition:
+ * A chunk of data os copied to the source data buffer pbData, and the
+ * length of the data chunk is specified in *pcbDataLength;
+ *
+ * POST-Condition:
+ * A block of encoded data is available in the specified target buffer.
+ * The length of the encoded data is returned by the function.
+ *
+ *
+ * IN: pbTarget, pointer to an allocated chunk of memory that receives the
+ * encoded data block.
+ * cbTargetSize, size of the data buffer above.
+ * bLast, flag that indicates if the specified block is the last
+ * part of the document. If the value is 0, the funciton expects
+ * that other blocks will follow, a value of 1 indicates that
+ * the data block that is presented in the input buffer is the
+ * last data block to be encoded.
+ * pbSaveBytes, pointer to a block of at least 3 Bytes. When this function
+ * is invoked the first time, the first byte of this buffer MUST
+ * be set to 0.
+ * IN/OUT:
+ * pbData, pointer to a data block that contains the clear data that
+ * are to be encoded. On return, the remaining piece of the
+ * input data block that could not be encoded is copied to
+ * the memory that pbData points at.
+ * pcbDataLength, pointer to a variable that denotes the length of
+ * the data block that is to be encoded, The function updates
+ * this value with the size of the data block that could not
+ * be processed. If all data were able to be encoded, the
+ * value will be 0.
+ * pcbOffset, pointer to a variable that is internally used by the
+ * function. before the first call of base64encode() for a
+ * certain document is made, the variable that pcbOffset points
+ * at must be set to 0. The variable will be updated by the
+ * function, and should not be modified by the caller.
+ * RETURN: BufferSize_t, the size of the data block that are available in
+ * pbTarget.
+ *
+ */
+
+BufferSize_t base64Encode (DataBuffer_t pbTarget,
+ BufferSize_t cbTargetSize,
+ DataBuffer_t pbData,
+ BufferSize_t *pcbDataLength,
+ BufferSize_t *pcbOffset,
+ unsigned int bLast,
+ unsigned char *pbSavebytes);
+/**
+ * FUNCTION: base64Decode
+ *
+ * Decodes a chunk of data according to the base64 encoding rules
+ *
+ * PRE-Condition:
+ * A chunk of data os copied to the source data buffer pbData, and the
+ * length of the data chunk is specified in *pcbDataLength;
+ *
+ * POST-Condition:
+ * A block of decoded data is available in the specified target buffer.
+ * The length of the decoded data is returned by the function.
+ *
+ *
+ * IN: pbTarget, pointer to an allocated chunk of memory that receives the
+ * decoded data block.
+ * cbTargetSize, size of the data buffer above.
+ * IN/OUT:
+ * pbData, pointer to a data block that contains the clear data that
+ * are to be decoded. On return, the remaining piece of the
+ * input data block that could not be decoded is copied to
+ * the memory that pbData points at.
+ * pcbDataLength, pointer to a variable that denotes the length of
+ * the data block that is to be decoded, The function updates
+ * this value with the size of the data block that could not
+ * be processed. If all data were able to be decoded, the
+ * value will be 0.
+ * RETURN: BufferSize_t, the size of the data block that are available in
+ * pbTarget. If some invalid data were detected in the input
+ * data buffer, or if cbTargetSize is less than 3,
+ * the function returns 0. The caller should treat this as an
+ * error condition.
+ *
+ */
+
+BufferSize_t base64Decode (DataBuffer_t pbTarget,
+ BufferSize_t cbTargetSize,
+ DataBuffer_t pbData,
+ BufferSize_t *pcbDataLength);
+
+
+#endif
diff --git a/engine/dmlib/tool-src/servercred/hdr/xptdef.h b/engine/dmlib/tool-src/servercred/hdr/xptdef.h
new file mode 100644
index 0000000..7d27f47
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/hdr/xptdef.h
@@ -0,0 +1,93 @@
+/*************************************************************************/
+/* module: SyncML Communication Protocol include file (Windows) */
+/* file: src/xpt/win/xptdef.h */
+/* target system: win */
+/* target OS: win */
+/* Purpose: Define platform-specific values for public header */
+/* files. */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+#ifndef XPTDEF_H
+#define XPTDEF_H
+
+#include <stdlib.h> /* For NULL and size_t */
+
+#define XPT_SECTION
+#define XPT_DATA_SECTION
+
+
+
+/* TK: to improve interoperability and handling we
+ * switched to using .def files instead of compiler
+ * specific per function definitions. As long as we only
+ * use C this is the easiest and cleanes way
+ */
+#define XPT_API
+#define XPT_API_DEF
+#define XPTAPI
+#define XPTEXP1 //__declspec(dllexport)
+#define XPTEXP2
+#define XPTDECLEXP1 //__declspec(dllexport)
+
+/* TK: Old, now obsolete code follows here */
+#ifdef FOOBAZZBUMMBAGGEL
+
+#if defined(__IBMC__) || defined(__IBMCPP__)
+ #define XPTAPI __stdcall
+ #define XPTEXP1
+ #define XPTEXP2 _Export
+ #define XPTDECLEXP1
+#else
+ #define XPTAPI __stdcall
+ #define XPTEXP1 __declspec(dllexport)
+ #define XPTEXP2
+
+// #ifdef BUILDING_XPT
+ #ifdef BUILDING_DLL
+ #define XPTDECLEXP1 XPTEXP1
+ #else
+ #define XPTDECLEXP1 __declspec(dllimport)
+ #endif
+#endif
+#endif // FOBAZZBUMMBAGGEL
+
+#define stricmp _stricmp
+#define memicmp _memicmp
+
+#endif
diff --git a/engine/dmlib/tool-src/servercred/hdr/xptport.h b/engine/dmlib/tool-src/servercred/hdr/xptport.h
new file mode 100644
index 0000000..3602be6
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/hdr/xptport.h
@@ -0,0 +1,183 @@
+/*************************************************************************/
+/* module: SyncML xpt portability header file */
+/* file: src/xpt/inc/xptport.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Isolate here the differences between ANSI string and memory functions and
+ * Palm string and memory functions. Note the sml tree contains similar
+ * mappings, but we avoid those for two reasons:
+ *
+ * 1. They are all implemented as functions, which makes calling them less
+ * efficient, especially on the Palm. Also, if they are implemented as
+ * functions, then the xpt DLL and the DLLs of all transport
+ * implementations must be linked to the sml DLL, which seems unnecessary.
+ *
+ * 2. Even on the Palm, the libstr.h and libmem.h header files include ANSI C
+ * header files like string.h and stdlib.h. These shouldn't be included
+ * on the Palm, because with some compilers, the introduced typedefs
+ * conflict with typedefs from the Palm SDK, causing compilation errors.
+ *
+ * We start the names of these functions with a different prefix so they are
+ * not confused with functions of the official xpt interface. We use "xpp"
+ * here instead of "xpt".
+ */
+
+#ifndef XPTPORT_H
+#define XPTPORT_H
+
+#include <xptdef.h>
+
+/*
+ * If we neglect some of the return values, most of the functions have simple
+ * mappings.
+ */
+#ifdef __PALM_OS__
+
+ /* Palm mappings */
+
+ #include <StringMgr.h>
+ #include <MemoryMgr.h>
+
+ #define xppStrcpy(target, source) StrCopy(target, source)
+ #define xppStrncpy(target, source, cnt) StrNCopy(target, source, cnt)
+ #define xppStrcat(target, source) StrCat(target, source)
+ #define xppStrncat(target, source, cnt) StrNCat(target, source, cnt)
+ #define xppStrcmp(first, second) StrCompare(first, second)
+ #define xppStrncmp(first, second, cnt) StrNCompare(first, second, cnt)
+ #define xppStrchr(string, c) StrChr(string, c)
+ #define xppStrstr(string, substr) StrStr(string, substr)
+ #define xppStrlen(string) StrLen(string)
+ #define xppAtoi(string) StrAToI(string)
+
+ #define xppMemset(s, c, n) MemSet(s, n, c)
+ #define xppMemcpy(target, source, cnt) MemMove(target, source, cnt)
+ #define xppMemmove(target, source, cnt) MemMove(target, source, cnt)
+ #define xppMemcmp(target, source, cnt) MemCmp(target, source, cnt)
+ #define xppMalloc(size) MemPtrNew(size)
+ XPTDECLEXP1 void * XPTAPI xppRealloc(void *ptr, size_t size) XPT_SECTION;
+ #define xppFree(ptr) MemPtrFree(ptr)
+
+ #define xppStricmp(first, second) StrCaselessCompare(first, second)
+ #define xppMemicmp(first, second, cnt) StrNCaselessCompare(first, second, cnt)
+
+#endif
+#if !defined(__EPOC_OS__) && !defined(__PALM_OS__)
+
+ /* ANSI C mappings */
+
+ #include <string.h>
+ #include <stdlib.h>
+
+ #define xppStrcpy(target, source) strcpy(target, source)
+ #define xppStrncpy(target, source, cnt) strncpy(target, source, cnt)
+ #define xppStrcat(target, source) strcat(target, source)
+ #define xppStrncat(target, source, cnt) strncat(target, source, cnt)
+ #define xppStrcmp(first, second) strcmp(first, second)
+ #define xppStrncmp(first, second, cnt) strncmp(first, second, cnt)
+ #define xppStrchr(string, c) strchr(string, c)
+ #define xppStrstr(string, substr) strstr(string, substr)
+ #define xppStrlen(string) strlen(string)
+ #define xppAtoi(string) atoi(string)
+
+ #define xppMemset(s, c, n) memset(s, c, n)
+ #define xppMemcpy(target, source, cnt) memcpy(target, source, cnt)
+ #define xppMemmove(target, source, cnt) memmove(target, source, cnt)
+ #define xppMemcmp(target, source, cnt) memcmp(target, source, cnt)
+ #define xppMalloc(size) malloc(size)
+ #define xppRealloc(ptr, size) realloc(ptr, size)
+ #define xppFree(ptr) free(ptr)
+
+ /* These aren't ANSI C functions, but they're pretty common */
+
+ #ifdef _WIN32
+ #define xppStricmp(first, second) stricmp(first, second)
+ #endif
+
+ /* Most other systems call it strcasecmp */
+ #ifndef xppStricmp
+ #define xppStricmp(first, second) strcasecmp(first, second)
+ #endif
+
+ #ifdef _WIN32
+ #define xppMemicmp(first, second, cnt) memicmp(first, second, cnt)
+ #endif
+
+ #ifndef xppMemicmp
+ #define xppMemicmp(first, second, cnt) strncasecmp(first, second, cnt)
+ #endif
+
+#endif
+
+#if defined(__EPOC_OS__)
+
+/* EPOC mappings */
+
+#include <string.h>
+#include <stdlib.h>
+
+#define xppStrcpy(target, source) strcpy(target, source)
+#define xppStrncpy(target, source, cnt) strncpy(target, source, cnt)
+#define xppStrcat(target, source) strcat(target, source)
+#define xppStrncat(target, source, cnt) strncat(target, source, cnt)
+#define xppStrcmp(first, second) strcmp(first, second)
+#define xppStrncmp(first, second, cnt) strncmp(first, second, cnt)
+#define xppStrchr(string, c) strchr(string, c)
+#define xppStrstr(string, substr) strstr(string, substr)
+#define xppStrlen(string) strlen(string)
+#define xppAtoi(string) atoi(string)
+
+#define xppMemset(s, c, n) memset(s, c, n)
+#define xppMemcpy(target, source, cnt) memcpy(target, source, cnt)
+#define xppMemmove(target, source, cnt) memmove(target, source, cnt)
+#define xppMemcmp(target, source, cnt) memcmp(target, source, cnt)
+#define xppMalloc(size) malloc(size)
+#define xppRealloc(ptr, size) realloc(ptr, size)
+#define xppFree(ptr) free(ptr)
+
+#define xppStricmp(first, second) strcasecmp(first, second)
+#define xppMemicmp(first, second, cnt) strncasecmp(first, second, cnt)
+
+#endif
+
+#endif
diff --git a/engine/dmlib/tool-src/servercred/hdr/xpttypes.h b/engine/dmlib/tool-src/servercred/hdr/xpttypes.h
new file mode 100644
index 0000000..bc96619
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/hdr/xpttypes.h
@@ -0,0 +1,80 @@
+/*************************************************************************/
+/* module: Communication Services, standard type definitions */
+/* file: src/xpt/all/xpttypes.h */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+/**
+ * Definition of several basic datatypes.
+ *
+ */
+
+#ifndef XPTTYPES_H
+#define XPTTYPES_H
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+
+#ifndef Bool_t
+typedef int Bool_t;
+#endif
+
+typedef unsigned char *DataBuffer_t;
+typedef DataBuffer_t *DataPtr_t;
+typedef unsigned long BufferSize_t;
+typedef BufferSize_t *BufferSizePtr_t;
+
+typedef const char *CString_t;
+typedef char *Ptr_t;
+typedef char *StringBuffer_t;
+typedef CString_t *StringPtr_t;
+typedef StringBuffer_t *StringBufferPtr_t;
+typedef unsigned short StringLength_t;
+
+
+
+#ifdef _cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/dmlib/tool-src/servercred/src/DeviceInfo.cc b/engine/dmlib/tool-src/servercred/src/DeviceInfo.cc
new file mode 100644
index 0000000..6a8273d
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/src/DeviceInfo.cc
@@ -0,0 +1,168 @@
+
+#include <stdlib.h> // exit() malloc()
+#include <string.h> // strcpy() strlen()
+
+#include "DeviceInfo.H"
+
+DeviceInfo::DeviceInfo() {
+ imei = NULL;
+ deviceId = NULL;
+ serverId = NULL;
+ userName = NULL;
+ clientPassword = NULL;
+ serverPassword = NULL;
+ DEVICE_ID_PREFIX = "IMEI:";
+}
+
+DeviceInfo::~DeviceInfo() {
+ if (imei != NULL) {
+ free(imei);
+ imei = NULL;
+ }
+
+ if (deviceId != NULL) {
+ free(deviceId);
+ deviceId = NULL;
+ }
+
+ if (serverId != NULL) {
+ free(serverId);
+ serverId = NULL;
+ }
+
+ if (userName != NULL) {
+ free(userName);
+ userName = NULL;
+ }
+
+ if (clientPassword != NULL) {
+ free(clientPassword);
+ clientPassword = NULL;
+ }
+
+ if (serverPassword != NULL) {
+ free(serverPassword);
+ serverPassword = NULL;
+ }
+}
+
+void DeviceInfo::setIMEI(char * aIMEI) {
+
+ if (aIMEI == NULL) {
+ return;
+ }
+
+ if (imei != NULL) {
+ free(imei);
+ imei = NULL;
+ }
+
+ int len = sizeof(char) * strlen(aIMEI) + 1;
+
+ imei = (char *) malloc(len);
+ memset(imei, '\0', len);
+
+ strcpy(imei, aIMEI);
+
+ userName = (char *) malloc(len);
+ memset(userName, '\0', len);
+
+ strcpy(userName, imei);
+
+ len = sizeof(char) * (strlen(DEVICE_ID_PREFIX) + len) + 1;
+
+ deviceId = (char *) malloc(len);
+ memset(deviceId, '\0', len);
+
+ strcpy(deviceId, DEVICE_ID_PREFIX);
+ strcat(deviceId, imei);
+
+}
+
+void DeviceInfo::setDeviceId(char * aDeviceId) {
+ if (deviceId != NULL) {
+ free(deviceId);
+ deviceId = NULL;
+ }
+
+ int len = sizeof(char) * strlen(aDeviceId) + 1;
+ deviceId = (char *) malloc(len);
+ memset(deviceId, '\0', len);
+ deviceId = aDeviceId;
+}
+
+void DeviceInfo::setServerId(char * aServerId) {
+
+ if (serverId != NULL) {
+ free(serverId);
+ serverId = NULL;
+ }
+
+ int len = sizeof(char) * strlen(aServerId) + 1;
+ serverId = (char *) malloc(len);
+ memset(serverId, '\0', len);
+ serverId = aServerId;
+}
+
+void DeviceInfo::setUserName(char * aUserName) {
+ if (userName != NULL) {
+ free(userName);
+ userName = NULL;
+ }
+
+ int len = sizeof(char) * strlen(aUserName) + 1;
+ userName = (char *) malloc(len);
+ memset(userName, '\0', len);
+ userName = aUserName;
+}
+
+void DeviceInfo::setClientPassword(char * aClientPassword) {
+ if (clientPassword != NULL) {
+ free(clientPassword);
+ clientPassword = NULL;
+ }
+
+ int len = sizeof(char) * strlen(aClientPassword) + 1;
+ clientPassword = (char *) malloc(len);
+ memset(clientPassword, '\0', len);
+ clientPassword = aClientPassword;
+}
+
+void DeviceInfo::setServerPassword(char * aServerPassword) {
+
+ if (serverPassword != NULL) {
+ free(serverPassword);
+ serverPassword = NULL;
+ }
+
+ int len = sizeof(char) * strlen(aServerPassword) + 1;
+ serverPassword = (char *) malloc(len);
+ memset(serverPassword, '\0', len);
+ serverPassword = aServerPassword;
+}
+
+char * DeviceInfo::getIMEI() {
+ return imei;
+}
+
+char * DeviceInfo::getDeviceId() {
+ return deviceId;
+}
+
+char * DeviceInfo::getServerId() {
+ return serverId;
+}
+
+char * DeviceInfo::getUserName() {
+ return userName;
+}
+
+char * DeviceInfo::getClientPassword() {
+ return clientPassword;
+}
+
+char * DeviceInfo::getServerPassword() {
+ return serverPassword;
+}
+
+
diff --git a/engine/dmlib/tool-src/servercred/src/GeneratePassword.cc b/engine/dmlib/tool-src/servercred/src/GeneratePassword.cc
new file mode 100644
index 0000000..09d4fcb
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/src/GeneratePassword.cc
@@ -0,0 +1,568 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//--------------------------------------------------------------------------------------------------
+//
+// Module Name: GeneratePassword.cc
+//
+// Based on an IMEI and serverId input, the algorithm for generating the OMADM client password
+// and server password actually has following three steps,
+//
+// Step 1 Generate the client password key and server password key:
+// char[] clientPasswordDict = new char[] { 0x0e, 0x06, 0x10,0x0c, 0x0a, 0x0e, 0x05, 0x0c,
+// 0x12, 0x0a, 0x0b, 0x06, 0x0d, 0x0e, 0x05 };
+// char[] serverPasswordDict = new char[] { 0x0a, 0x06, 0x0e,0x0e, 0x0a, 0x0b, 0x06, 0x0e,
+// 0x0b, 0x04, 0x04, 0x07, 0x11, 0x0c, 0x0c };
+//
+// It defines a client password dictionary and a server password dictionary which contain
+// 15 numbers, we use client password dictionary to generate client password key and server
+// password dictionary to generate server password key. Suppose IMEI string length is n, for
+// each character in IMEI string {imei[i], 0<= i <n-3}, we generate two serial numbers using
+// following calculation,
+//
+// Serial1 += imei[i + 3] * dict[i];
+// Serial2 += imei[i + 3] * imei[i + 2]*dict[i];
+//
+// Note: Serial numbers are in decimal.
+// Hence we get a password KEY which is Serial1+"-"+Serial2.
+//
+// Step 2 Generate Temporary passwords:
+// We generate a MD5 digest from IMEI+KEY+serverId, then we pick No. 2,7,8,12,25,30 characters
+// from MD5 DigestStr , let is be md5key. Convert IMEI to 36 radix number, let it be newImei
+// which is always 10 characters, then we get a temporary password which is md5key+newImei.
+//
+// Step 3 Shuffle the temporary password:
+// The last step is to shuffle the temporary password got from Step 2.
+// Since the password length is 16 and n is the length which is equal to 16,
+// let P1,P2,P3,P4,...,P[n/2]-1, P[n/2], P[n/2]+1 , ... , Pn are the characters in the
+// temporary password string, we do following shuffle,
+//
+// move P[n/2]+1 between P[n/2]-1 and P[n/2],
+// ....
+// move Pn before P1.
+// Then we get Pn,P1,Pn-1,P2,....,P[n/2]-1,P[n/2]+1,P[n/2].
+// Do the same shuffle three times, then after third time shuffle we get the password which
+// is 16 characters string.
+//
+// Usage: GeneratePassword [IMEI] [SERVER_ID]
+//
+// Example: GeneratePassword 000000011234564 motorola
+//
+// Default: IMEI = 123456789012345
+// SERVER_ID = openwave.com
+//
+
+#include <stdio.h> // printf()
+#include <stdlib.h> // exit() malloc()
+#include <string.h> // strcpy() strlen()
+#include "md5.h"
+
+#include "GeneratePassword.H"
+
+/**
+ * Initialize all the client/server password dictionaries and other values.
+ */
+GeneratePassword::GeneratePassword() {
+
+ clientPasswordDict[0] = 0x0e;
+ clientPasswordDict[1] = 0x06;
+ clientPasswordDict[2] = 0x10;
+ clientPasswordDict[3] = 0x0c;
+ clientPasswordDict[4] = 0x0a;
+ clientPasswordDict[5] = 0x0e;
+ clientPasswordDict[6] = 0x05;
+ clientPasswordDict[7] = 0x0c;
+ clientPasswordDict[8] = 0x12;
+ clientPasswordDict[9] = 0x0a;
+ clientPasswordDict[10] = 0x0b;
+ clientPasswordDict[11] = 0x06;
+ clientPasswordDict[12] = 0x0d;
+ clientPasswordDict[13] = 0x0e;
+ clientPasswordDict[14] = 0x05;
+
+ serverPasswordDict[0] = 0x0a;
+ serverPasswordDict[1] = 0x06;
+ serverPasswordDict[2] = 0x0e;
+ serverPasswordDict[3] = 0x0e;
+ serverPasswordDict[4] = 0x0a;
+ serverPasswordDict[5] = 0x0b;
+ serverPasswordDict[6] = 0x06;
+ serverPasswordDict[7] = 0x0e;
+ serverPasswordDict[8] = 0x0b;
+ serverPasswordDict[9] = 0x04;
+ serverPasswordDict[10] = 0x04;
+ serverPasswordDict[11] = 0x07;
+ serverPasswordDict[12] = 0x11;
+ serverPasswordDict[13] = 0x0c;
+ serverPasswordDict[14] = 0x0c;
+
+ hexTable[0] = '0';
+ hexTable[1] = '1';
+ hexTable[2] = '2';
+ hexTable[3] = '3';
+ hexTable[4] = '4';
+ hexTable[5] = '5';
+ hexTable[6] = '6';
+ hexTable[7] = '7';
+ hexTable[8] = '8';
+ hexTable[9] = '9';
+ hexTable[10] = 'a';
+ hexTable[11] = 'b';
+ hexTable[12] = 'c';
+ hexTable[13] = 'd';
+ hexTable[14] = 'e';
+ hexTable[15] = 'f';
+
+ imei = "123456789012345";
+ serverId = "openwave.com";
+
+ char * tmpIMEI = "123456789012345";
+ char * tmpServerId = "openwave.com";
+
+ int len = sizeof(char) * strlen(tmpIMEI) + 1;
+ imei = (char *) malloc(len);
+ memset(imei, '\0', (len));
+ strcpy(imei, tmpIMEI);
+
+ len = sizeof(char) * strlen(tmpServerId) + 1;
+ serverId = (char *) malloc(len);
+ memset(serverId, '\0', (len));
+ strcpy(serverId, tmpServerId);
+
+ MD5_HASH_LENGTH = 16;
+}
+
+/**
+ * Free all dynamic allocated memories.
+ */
+GeneratePassword::~GeneratePassword() {
+
+ if (imei != NULL) {
+ free(imei);
+ imei = NULL;
+ }
+
+ if (serverId != NULL) {
+ free(serverId);
+ serverId = NULL;
+ }
+}
+
+/**
+ * Sets the sever ID for password generation
+ *
+ * @param serverId the serverId that represent a DM server
+ */
+void GeneratePassword::setServerId(const char * sid) {
+ if (serverId != NULL) {
+ free(serverId);
+ serverId = NULL;
+ }
+
+ int len = sizeof(char) * strlen(sid) + 1;
+ serverId = (char *) malloc(len);
+ memset(serverId, '\0', len);
+ strcpy(serverId, sid);
+}
+
+/**
+ * Sets the IMEI for password generation
+ *
+ * @param aIMEI a phone identification number
+ */
+void GeneratePassword::setIMEI(const char * aIMEI) {
+
+ if (imei != NULL) {
+ free(imei);
+ imei = NULL;
+ }
+
+ int len = sizeof(char) * strlen(aIMEI) + 1;
+ imei = (char *) malloc(len);
+ memset(imei, '\0', len);
+ strcpy(imei, aIMEI);
+}
+
+/**
+ * Returns the IMEI number.
+ *
+ * @return a phone identification number
+ */
+char * GeneratePassword::getIMEI() {
+ return imei;
+}
+
+/**
+ * Returns the server ID
+ *
+ * @return serverId the serverId that represent a DM server
+ */
+char * GeneratePassword::getServerId() {
+ return serverId;
+}
+
+/**
+ * Generate a client password key with a predefined client password dictionary
+ * based on the IMEI.
+ *
+ * @param imei the imei use to generate the key
+ * @return the client password key
+ */
+char * GeneratePassword::generateClientPasswordKey(char * imei) {
+ return generateKeyFromDict(imei, clientPasswordDict);
+}
+
+/**
+ * Generate a server password key with a predefined server password dictionary
+ * based on the IMEI.
+ *
+ * @param imei the imei use to generate the key
+ * @return the server password key
+ */
+char * GeneratePassword::generateServerPasswordKey(char * imei) {
+ return generateKeyFromDict(imei, serverPasswordDict);
+}
+
+/**
+ * Generate a client password using a generated client password key, the IMEI, and
+ * the server ID.
+ *
+ * @return the client password
+ */
+char * GeneratePassword::generateClientPassword() {
+ char * key = generateClientPasswordKey(imei);
+ return generatePassword(imei, serverId, key);
+}
+
+/**
+ * Generate a server password using a generated server password key, the IMEI, and
+ * the server ID.
+ *
+ * @return the server password
+ */
+char * GeneratePassword::generateServerPassword() {
+ char * key = generateServerPasswordKey(imei);
+ return generatePassword(imei, serverId, key);
+}
+
+/**
+ * Generate a client password using a generated client password key, the IMEI, and
+ * the server ID.
+ *
+ * @param imei a phone identification number
+ * @param serverId the serverId that represent a DM server
+ * @return the client password
+ */
+char * GeneratePassword::generateClientPassword(char * imei, char * serverId) {
+ char * key = generateClientPasswordKey(imei);
+ return generatePassword(imei, serverId, key);
+}
+
+/**
+ * Generate a server password using a generated server password key, the IMEI, and
+ * the server ID.
+ *
+ * @param imei a phone identification number
+ * @param serverId the serverId that represent a DM server
+ * @return the server password
+ */
+char * GeneratePassword::generateServerPassword(char * imei, char * serverId) {
+ char * key = generateServerPasswordKey(imei);
+ return generatePassword(imei, serverId, key);
+}
+
+/**
+ * Generate a key with given IMEI and password dictionary.
+ * Suppose IMEI string length is n, for each character in IMEI string {imei[i], 0<= i <n-3},
+ * we generate two serial numbers using following calculation,
+ *
+ * Serial1 += imei[i + 3] * dict[i];
+ * Serial2 += imei[i + 3] * imei[i + 2]*dict[i];
+ *
+ * Note: Serial numbers are in decimal.
+ * Hence we get a password KEY which is Serial1+"-"+Serial2.
+ *
+ * @param imei a phone indentification number
+ * @param dict[] a password dictionary
+ * @return a password key
+ */
+char * GeneratePassword::generateKeyFromDict(char * imei, char dict[]) {
+ int i;
+ int length;
+ long serial1 = 0;
+ long serial2 = 0;
+ char * serial1_str;
+ char * serial2_str;
+ char * key;
+
+ length = strlen(imei);
+
+ for (i = 0; i < length - 3; i++) {
+ serial1 += imei[i + 3] * dict[i];
+ serial2 += imei[i + 3] * imei[i + 2] * dict[i];
+ }
+
+ serial1_str = (char *) malloc(sizeof(char) * (24));
+ serial2_str = (char *) malloc(sizeof(char) * (24));
+ sprintf(serial1_str, "%d", serial1);
+ sprintf(serial2_str, "%d", serial2);
+
+ key = (char *) malloc(sizeof(char) * (strlen(serial1_str) + strlen(serial2_str) + 2));
+ memset(key, '\0', (sizeof(char) * (strlen(serial1_str) + strlen(serial2_str) + 2)));
+
+ strcat(key, (const char *)serial1_str );
+ strcat(key, "-");
+ strcat(key, (const char *)serial2_str );
+
+ free(serial1_str);
+ serial1_str = NULL;
+ free(serial2_str);
+ serial2_str = NULL;
+
+ return key;
+}
+
+/**
+ * Convert an array of characters that represents a large number to a decimal number type
+ *
+ * @param input the array of characters thar represents a large number
+ * @return the decimal number
+ */
+long long GeneratePassword::convertChar2Long(char * input)
+{
+ char ch[2];
+ int i;
+ long long tmp;
+ tmp = 0;
+
+ for (i=0 ; i < strlen((const char *)input) ; i++ ) {
+ ch[0]=*(input+i);
+ ch[1]='\0';
+ tmp = (long long) ( ( (tmp) * 10) + atol((const char *)ch) );
+ }
+ return tmp;
+}
+
+/**
+ * Convert an array of characters that represents a number in decimal based to 36 based.
+ *
+ * @param target_imei the array of characters thar represents a number in decimal based
+ * @param the 36 based number represented by array of characters.
+ */
+char * GeneratePassword::get36BasedIMEI(char * target_imei) {
+
+ char NumericBaseData[]= "0123456789abcdefghijklmnopqrstuvwxyz";
+ char tmp_IMEI[11];
+ long long Quotient;
+ long Remainder;
+ int i;
+ char tmpchar;
+
+ char * IMEI36 = (char *) malloc(sizeof(char) * ( 10 + 1 ));
+ memset(IMEI36, '\0', (sizeof(char) * (10 + 1)));
+
+ long long IMEI = 0;
+ IMEI = convertChar2Long(target_imei);
+
+ i=0;
+ while ( IMEI > 0 ) {
+ Quotient = (long long)(IMEI/36);
+ Remainder = (long)(IMEI%36);
+ tmp_IMEI[i++] = NumericBaseData[Remainder];
+ IMEI = Quotient;
+ }
+ tmp_IMEI[i]='\0';
+
+ //If the length is <10 pad the remaining chracter to '0' to make the length 10
+ if( strlen(tmp_IMEI) < 10 ) {
+ for (i=strlen(tmp_IMEI); i<10 ; i++) {
+ tmp_IMEI[i]='0';
+ }
+ tmp_IMEI[i]='\0';
+ }
+
+ for( i=0 ; i < strlen(tmp_IMEI)/2 ; i++ ) {
+ tmpchar = tmp_IMEI[i];
+ tmp_IMEI[i] = tmp_IMEI[ strlen(tmp_IMEI)-i-1];
+ tmp_IMEI[ strlen(tmp_IMEI)-i-1] = tmpchar;
+ }
+
+ memcpy(IMEI36,tmp_IMEI,strlen(tmp_IMEI));
+ return IMEI36;
+}
+
+/**
+ * Shuffle an array of characters.
+ *
+ * let P1,P2,P3,P4,...,P[n/2]-1, P[n/2], P[n/2]+1 , ... , Pn
+ * are the characters in the string, we do following shuffle,
+ *
+ * move P[n/2]+1 between P[n/2]-1 and P[n/2],
+ * ....
+ * move Pn before P1.
+ * Then we get
+ * Pn,P1,Pn-1,P2,....,P[n/2]-1,P[n/2]+1,P[n/2].
+ *
+ * @param buffer the string to be shuffle
+ */
+void GeneratePassword::shuffle(char & buffer) {
+
+ int length;
+ int secondHalfPos;
+ int insertPos;
+ char * buf;
+ char tmpchar;
+ int i;
+ int j;
+
+ insertPos = 0;
+ i=0;
+ j=0;
+ buf = & buffer;
+ length = strlen((char *)buf);
+ secondHalfPos = (length / 2);
+
+ for ( i= secondHalfPos ; i < length ; i++ ) {
+ tmpchar = (char)buf[i];
+ insertPos = (length - i - 1);
+ for ( j = i ; j > insertPos ; j-- ) {
+ buf[j] = buf[j-1];
+ }
+ buf[j] = tmpchar;
+ }
+}
+
+/**
+ * Convert the input data from a decimal based number to Heximal based number.
+ *
+ * @param data the decimal based number to be covert
+ * @return the Heximal based number
+ */
+char * GeneratePassword::encodeHex(char data[]) {
+
+ int i;
+ char tmpChar;
+ int len = MD5_HASH_LENGTH;
+ printf("LEN: %d\n", len);
+ int size = len * 2 + 1;
+ char * output = (char *) malloc(sizeof(char) * size);
+ memset(output, '\0', (sizeof(char) * size));
+
+ for ( i = 0; i < len ; i++) {
+ tmpChar = data[i];
+ output[2*i] = hexTable[ (tmpChar & 0x0F) ]; // Get low 4 bits
+ output[(2*i)+1] = hexTable[ ((tmpChar >> 4) & 0x0F ) ]; // Get high 4 bits
+ }
+ output[2*i] = '\0';
+
+ return output;
+}
+
+
+/**
+ * Generate a password with given IMEI, serverID, and key.
+ * We generate a MD5 digest from IMEI+KEY+serverId, then we pick No. 2,7,8,12,25,30 characters
+ * from MD5 DigestStr , let is be md5key. Convert IMEI to 36 radix number, let it be newImei
+ * which is always 10 characters, then we get a temporary password which is md5key+newImei.
+ * Finally, we shuffle the temporary password three time.
+ *
+ * @param imei the phone identification number
+ * @param serverId the server ID of a DM server.
+ * @param key the key needs to generate password
+ * @return a password
+ */
+char * GeneratePassword::generatePassword(char * imei, char * serverId, char * key) {
+
+ char * MD5DigestStr = (char *) malloc(sizeof(char) * (strlen ((const char *)imei) + strlen(key) + strlen(serverId) +1));
+ memset( MD5DigestStr , '\0', (sizeof(char) * ( strlen ((const char *)imei) + strlen(key) + strlen(serverId) +1 ) ) );
+
+ strcpy( MD5DigestStr , (const char *)imei );
+ strcat( MD5DigestStr , key );
+ strcat( MD5DigestStr , serverId );
+
+ printf("Before MD5: %s\n", MD5DigestStr);
+
+ MD5_CTX md5_context;
+
+ char md5hash[MD5_HASH_LENGTH + 1]; /* Add 1 character for NULL */
+ memset(md5hash, '\0', (sizeof(char) * (MD5_HASH_LENGTH + 1)));
+
+ smlMD5Init(&md5_context);
+ smlMD5Update(&md5_context, (unsigned char *)MD5DigestStr,strlen(MD5DigestStr));
+ smlMD5Final((unsigned char*)md5hash, &md5_context);
+ md5hash[MD5_HASH_LENGTH] = 0;
+
+ free(MD5DigestStr );
+ MD5DigestStr =NULL;
+
+ printf("MD5 HASH: %s\n", md5hash);
+
+ char * MD5DigestStr32 = encodeHex(md5hash);
+
+ printf("Digest Str: %s\n", MD5DigestStr32);
+
+ // Pick only no. 2,7,8,12,25,30 characters from MD5 Digest String
+
+ MD5DigestStr = (char *) malloc(sizeof(char) * ( 6 + 1 ));
+ memset(MD5DigestStr, '\0', (sizeof(char) * ( 6 + 1)));
+
+ MD5DigestStr[0] = MD5DigestStr32[2];
+ MD5DigestStr[1] = MD5DigestStr32[7];
+ MD5DigestStr[2] = MD5DigestStr32[8];
+ MD5DigestStr[3] = MD5DigestStr32[12];
+ MD5DigestStr[4] = MD5DigestStr32[25];
+ MD5DigestStr[5] = MD5DigestStr32[30];
+
+ free(MD5DigestStr32 );
+ MD5DigestStr32 =NULL;
+
+ //Convert IMEI to 36(base) radixnumber to generate NewIMEI
+
+ char * IMEI36 = (char *) malloc(sizeof(char) * ( 10 + 1 ));
+ memset(IMEI36, '\0', (sizeof(char) * (10 + 1)));
+
+ IMEI36 = get36BasedIMEI(imei);
+
+ //Create Password
+
+ int PWLength = strlen (MD5DigestStr) + strlen((const char *)IMEI36); //Length will be 16
+
+ char * password = (char *) malloc(sizeof(char) * ( PWLength + 1));
+ memset( password , '\0', (sizeof(char) * ( PWLength + 1 ) ) ); //this will be of 16 + 1
+
+ strcpy( password , MD5DigestStr );
+ strcat( password , (const char *)IMEI36 );
+
+ free(MD5DigestStr );
+ MD5DigestStr =NULL;
+
+ free(IMEI36);
+ IMEI36 =NULL;
+
+ free(MD5DigestStr32 );
+ MD5DigestStr32 =NULL;
+
+ printf("BUFFER: %s\n", password);
+
+ shuffle(*password);
+ shuffle(*password);
+ shuffle(*password);
+
+ free( key );
+ key=NULL;
+
+ return password;
+}
diff --git a/engine/dmlib/tool-src/servercred/src/TestGenPasswd.cc b/engine/dmlib/tool-src/servercred/src/TestGenPasswd.cc
new file mode 100644
index 0000000..1a44629
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/src/TestGenPasswd.cc
@@ -0,0 +1,47 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include "DeviceInfo.H"
+#include "GeneratePassword.H"
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+ GeneratePassword gp;
+
+ if (argv[1] != NULL) {
+
+ if (strcmp(argv[1], "--help") == 0) {
+ printf("Usage: GeneratePassword [IMEI] [SERVER_ID]\n\n");
+ printf("Example: GeneratePassword 000000011234564 motorola\n\n");
+ printf("Default: IMEI = 123456789012345\n");
+ printf(" SERVER_ID = openwave.com\n");
+ exit(0);
+ }
+
+ char * imei = argv[1];
+ gp.setIMEI((const char *)imei);
+
+ if (argv[2] != NULL) {
+ char * serverId = argv[2];
+ gp.setServerId((const char *)serverId);
+ }
+ }
+
+ DeviceInfo deviceInfo;
+ deviceInfo.setIMEI(gp.getIMEI());
+ deviceInfo.setServerId(gp.getServerId());
+ deviceInfo.setClientPassword(gp.generateClientPassword());
+ deviceInfo.setServerPassword(gp.generateServerPassword());
+
+ printf("[Device Info]\n");
+ printf("IMEI: %s\n", deviceInfo.getIMEI());
+ printf("Device ID: %s\n", deviceInfo.getDeviceId());
+ printf("Server ID: %s\n", deviceInfo.getServerId());
+ printf("User Name: %s\n", deviceInfo.getUserName());
+ printf("Client Password: %s\n", deviceInfo.getClientPassword());
+ printf("Server Password: %s\n", deviceInfo.getServerPassword());
+
+ return 0;
+}
diff --git a/engine/dmlib/tool-src/servercred/src/main.c b/engine/dmlib/tool-src/servercred/src/main.c
new file mode 100644
index 0000000..a9855e3
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/src/main.c
@@ -0,0 +1,398 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//--------------------------------------------------------------------------------------------------
+//
+// Module Name:main.c
+//
+// General Description: This file contains the main function for the SyncML factory boot strap credential generator tool
+//
+//--------------------------------------------------------------------------------------------------
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <time.h>
+#include "xptport.h"
+#include "xpttypes.h"
+#include "xpt-b64.h"
+#include "md5.h"
+#define MD5_HASH_LENGTH 16
+#define ENCODED_MD5_CRED_LENGTH (MD5_HASH_LENGTH + (MD5_HASH_LENGTH/2) + 1)
+
+#define getch getchar
+
+void SyncML_DM_CombineCredDataAndIMEI(char *p_CreadData_IMEI,const char *p_CreadData,const char *p_IMEI);
+void SyncML_DM_BuildB64EncodedMD5_Factory_Bootstrap_CredData(char **pp_credential_data,const char *p_CredData,const char *p_IMEI );
+void SyncML_DM_BuildB64EncodedCredData_Factory_Bootstrap(char **pp_credential_data,const char *pCread_Input);
+void user_help(void);
+
+const char DM_STR_SLASH[] = "/";
+
+/*==================================================================================================
+
+FUNCTION:SyncML_DM_BuildB64EncodedMD5_Factory_Bootstrap_CredData
+
+DESCRIPTION:
+ This function builds the B64 encoded MD5 credential information.
+ The credential string is credential data:IMEI number . That string is then b64 encoded.
+
+ARGUMENTS PASSED:
+
+REFERENCE ARGUMENTS PASSED:
+ char **pp_credential_data - Output variable containing the encoded credential data
+ const char *p_CredData - credential_data .
+ const char *p_IMEI - Phone IMEI number.
+
+
+RETURN VALUE:
+ N/A
+
+PRE-CONDITIONS:
+
+POST-CONDITIONS:
+
+==================================================================================================*/
+
+
+
+void SyncML_DM_BuildB64EncodedMD5_Factory_Bootstrap_CredData(char **pp_credential_data,const char *p_CredData,const char *p_IMEI )
+ {
+ char *p_CreadData_IMEI;
+
+ MD5_CTX md5_context;
+ char md5hash[MD5_HASH_LENGTH + 1]; /* Add 1 character for NULL */
+ BufferSize_t offset = 0;
+ BufferSize_t md5_hash_length = MD5_HASH_LENGTH;
+ BufferSize_t total_length;
+
+ memset(md5hash, '\0', (sizeof(char) * (MD5_HASH_LENGTH + 1)));
+
+ *pp_credential_data = (char *)malloc(sizeof(char) * (ENCODED_MD5_CRED_LENGTH));
+ memset(*pp_credential_data, '\0', (sizeof(char) * ENCODED_MD5_CRED_LENGTH));
+ /* Add space for the ":" and NULL character */
+ total_length= strlen(p_CredData) + strlen(p_IMEI) + 2;
+ p_CreadData_IMEI = (char *) malloc(sizeof(char) * (total_length));
+ memset(p_CreadData_IMEI, '\0', (sizeof(char) * total_length));
+ SyncML_DM_CombineCredDataAndIMEI(p_CreadData_IMEI, p_CredData,p_IMEI);
+
+ smlMD5Init(&md5_context);
+ smlMD5Update(&md5_context, (unsigned char *)p_CreadData_IMEI,strlen(p_CreadData_IMEI));
+ smlMD5Final((unsigned char*)md5hash, &md5_context);
+ md5hash[MD5_HASH_LENGTH] = 0;
+ free(p_CreadData_IMEI);
+ p_CreadData_IMEI=NULL;
+ base64Encode((unsigned char *)*pp_credential_data, ENCODED_MD5_CRED_LENGTH,
+ (unsigned char *)md5hash,&md5_hash_length,&offset,
+ 1, /* Encode as single block */
+ NULL); /* No incomplete bl*/
+
+ }
+
+/*==================================================================================================
+
+FUNCTION: SyncML_DM_CombineCredDataAndIMEI
+
+DESCRIPTION:
+ This function combines the credential data and IMEI strings
+ The credential string is CreadData:IMEI.
+
+ARGUMENTS PASSED:
+
+REFERENCE ARGUMENTS PASSED:
+ char *p_CreadData_IMEI - Output variable containing the combined credential data and IMEI
+ string "CreadData:IMEI"
+ const char *p_CreadData - credential data
+ const char *p_IMEI - phone IMEI no.
+
+RETURN VALUE:
+ N/A
+
+PRE-CONDITIONS:
+
+POST-CONDITIONS:
+
+INVARIANTS:
+==================================================================================================*/
+ void SyncML_DM_CombineCredDataAndIMEI(char *p_CreadData_IMEI,const char *p_CreadData,const char *p_IMEI)
+ {
+ strcpy(p_CreadData_IMEI, p_CreadData);
+ strcat(p_CreadData_IMEI, ":");
+ strcat(p_CreadData_IMEI, p_IMEI);
+}
+/*==================================================================================================
+
+FUNCTION: SyncML_DM_BuildB64EncodedCredData_Factory_Bootstrap
+
+DESCRIPTION:
+ This function builds the B64 encoded basic credential information.
+ The credential string is username:password. That string is then
+ B64 encoded.
+
+ARGUMENTS PASSED:
+
+REFERENCE ARGUMENTS PASSED:
+ char **p_credential_data - Output variable containing the encoded credential data
+
+
+ const char *pCread_Input
+RETURN VALUE:
+ N/A
+
+PRE-CONDITIONS:
+
+POST-CONDITIONS:
+
+INVARIANTS:
+ None
+==================================================================================================*/
+
+
+void SyncML_DM_BuildB64EncodedCredData_Factory_Bootstrap(char **pp_credential_data,const char *pCread_Input)
+
+{
+
+ BufferSize_t offset = 0;
+ BufferSize_t combined_length = 0;
+ long total_length;
+ long estimated_basic_cred_length;
+
+ /* Add space for the ":" and NULL character */
+ total_length = strlen(pCread_Input) + 1;
+ /* RFC 2045 (First paragraph of Section 6.8)
+ * "The encoding and decoding algorithms are simple, but the
+ * encoded data are consistently only about 33% larger than the
+ * unencoded data.". Calculate the estimated credential length
+ * by dw_length + (dw_length/2)
+ */
+ estimated_basic_cred_length = total_length + (total_length/2);
+
+ *pp_credential_data = (char *)malloc(sizeof(char) * estimated_basic_cred_length);
+ memset(*pp_credential_data, '\0', (sizeof(char) * estimated_basic_cred_length));
+
+
+ combined_length = strlen(pCread_Input);
+
+ base64Encode((unsigned char *)*pp_credential_data, estimated_basic_cred_length,
+ (unsigned char *)pCread_Input, &combined_length, &offset,
+ 1, /* Encode as single block */
+ NULL); /* No incomplete blocks */
+
+ }
+
+void user_help(void)
+{
+
+ printf("\nGen_Cred < Input File Path> < Input Filename> \n\n");
+
+}
+
+
+ int main(int argc, char *argv[])
+ {
+ int bytes_read;
+ int total_length;
+ int filepath_length;
+ char *p_Output_string;
+ char pServerID[150];
+ char pServer_Nonce[]="14YJ55NI65RS25WA";
+ char pClient_Nonce[]="53LI62MI23HE33ST";
+ char pUsername_text[]="UserName";
+ char *pUsername;
+ char *pFilepath;
+ char pOutputFile[40];
+ char *ptemp_input;
+ char pcred[]="_Cred-";
+
+ struct tm *stTm = NULL;
+ time_t Time;
+ // int err = noError;*/
+
+
+
+ FILE *fd_IMEI,*fd_Cred;
+
+ unsigned char pIMEI[16];
+
+ if(argc < 3)
+ {
+ user_help();
+ printf("\n ENTER A KEY TO EXIT \n");
+ getch();
+ return 0;
+ }
+ else
+ {
+
+ filepath_length=strlen(argv[1])+ strlen(argv[2]);
+ pFilepath=(char *)malloc((filepath_length * sizeof(char ))+2);
+ sprintf(pFilepath, "%s%s%s", argv[1],DM_STR_SLASH, argv[2]);
+
+ }
+
+ //fd_IMEI=fopen("IMEI.txt","r");
+ fd_IMEI=fopen(pFilepath,"r");
+ if(fd_IMEI == NULL)
+ {
+ printf("file fd_IMEI not opened\n");
+ printf("\n ENTER A KEY TO EXIT \n");
+ getch();
+ free(pFilepath);
+ return 0;
+
+ }
+ else
+ {
+ printf ("\nfile fd_IMEI opened \n");
+ printf(" \n\nENTER THE SERVER ID \n\n");
+ scanf("%s",pServerID);
+ /* printf(" \n\nENTER THE SERVER NONCE \n\n");
+ scanf("%s",pServer_Nonce);
+ printf(" \n\nENTER THE CLIENT NONCE \n\n");
+ scanf("%s",pClient_Nonce);*/
+
+ if(strlen(pServerID) >= 136)
+ {
+ printf("\n\nLENGTH OF SERVERID IS GRETER THAN 135 IT SHOULD BE LTE 135 \n\n");
+ printf("\n\nSERVER ID ENTERED == %s length == %d\n\n",pServerID,strlen(pServerID));
+ printf("\n ENTER A KEY TO EXIT \n");
+ getch();
+ free(pFilepath);
+ return 0;
+ }
+
+ printf("\n\nSERVER ID ENTERED == %s length == %d\n\n",pServerID,strlen(pServerID));
+
+ }
+
+
+ time(&Time);
+ stTm = localtime(&Time);
+
+
+ // filepath_length=(strlen(argv[2])-4)+ (sizeof(int) * 6)+1;
+ ptemp_input=(char *)malloc(((strlen(argv[2])-4) * sizeof(char))+1);
+ // memset(ptemp_input, '\0', (sizeof(char) * estimated_basic_cred_length));
+ memcpy(ptemp_input,argv[2],(strlen(argv[2])-4));
+ ptemp_input[strlen(argv[2])-4]='\0';
+ // pOutputFile=(char *)malloc(filepath_length * sizeof(char));
+
+ sprintf(pOutputFile,"%s%s%02d.%02d.%02d-%02d-%02d-%04d.txt",ptemp_input,pcred,stTm->tm_hour,stTm->tm_min,
+ stTm->tm_sec,stTm->tm_mday,stTm->tm_mon+1,stTm->tm_year+1900);
+ free(ptemp_input);
+
+
+ fd_Cred=fopen(pOutputFile,"w+");
+
+ if(fd_Cred == NULL )
+
+ {
+ printf("file fd_Cred not opened\n");
+ printf("\n ENTER A KEY TO EXIT \n");
+ free(pFilepath);
+ //free(pOutputFile);
+
+
+ getch();
+
+ return 0;
+
+ }
+ else
+ printf ("\nfilew fd_Cred opened \n");
+
+
+
+ while(!feof(fd_IMEI))
+ {
+ bytes_read=fread(pIMEI,sizeof(char),16,fd_IMEI); //read from file
+
+ pIMEI[15]='\0';
+
+ /* WRITE IMEI TO THE FILE */
+ fwrite(pIMEI,sizeof(char),strlen(pIMEI),fd_Cred);
+ fwrite(" ",sizeof(char),1,fd_Cred);
+
+ SyncML_DM_BuildB64EncodedMD5_Factory_Bootstrap_CredData(&p_Output_string, (const char *)pServerID,(const char *)pIMEI);
+
+ /* Generate Server PW */
+
+
+
+ //x.EncodeBuffer((char *)digest,sizeof(digest) /*strlen((char *)digest)*/,output_string);
+
+ fwrite(p_Output_string,sizeof(char),strlen(p_Output_string),fd_Cred);
+
+ fwrite(" ",sizeof(char),1,fd_Cred);
+ free(p_Output_string);
+
+
+ /* Generate Client PW */
+
+ SyncML_DM_BuildB64EncodedMD5_Factory_Bootstrap_CredData(&p_Output_string, (const char *)pIMEI,(const char *)pServerID);
+
+
+ fwrite(p_Output_string,sizeof(char),strlen(p_Output_string),fd_Cred);
+
+ fwrite(" ",sizeof(char),1,fd_Cred);
+ free(p_Output_string);
+
+ /*Generate UserName */
+ total_length=strlen(pUsername_text)+strlen(pServerID)+2;
+
+
+ pUsername=(char *)malloc(total_length * sizeof(char));
+ memset(pUsername,'\0',total_length);
+ strcpy(pUsername,pServerID);
+ strcat(pUsername,":");
+ strcat(pUsername,pUsername_text);
+
+ SyncML_DM_BuildB64EncodedMD5_Factory_Bootstrap_CredData(&p_Output_string, (const char *)pIMEI,(const char *)pUsername);
+
+ fwrite(p_Output_string,sizeof(char),strlen(p_Output_string),fd_Cred);
+
+ free(p_Output_string);
+ free(pUsername);
+ /* NONCE CALCULATION */
+
+
+ fwrite(" ",sizeof(char),1,fd_Cred);
+ SyncML_DM_BuildB64EncodedCredData_Factory_Bootstrap(&p_Output_string,(const char *)pServer_Nonce);
+ fwrite(p_Output_string,sizeof(char),strlen(p_Output_string),fd_Cred);
+ fwrite(" ",sizeof(char),1,fd_Cred);
+ free(p_Output_string);
+ SyncML_DM_BuildB64EncodedCredData_Factory_Bootstrap(&p_Output_string,(const char *)pClient_Nonce);
+ fwrite(p_Output_string,sizeof(char),strlen(p_Output_string),fd_Cred);
+ free(p_Output_string);
+
+ fwrite("\n",sizeof(char),1 ,fd_Cred);
+
+
+ }
+
+ printf("\n\nGENERATED CRED VALUES EACH SEPARATED BY SPACE CHAR IN %s \n",pOutputFile);
+ printf("\nIMEI ServerPW ClientPW UserName ServerNonce ClientNonce \n\n\n\n");
+ fclose(fd_Cred);
+ fclose(fd_IMEI);
+
+ printf("\n ENTER A KEY TO EXIT \n");
+ free(pFilepath);
+ //free(pOutputFile);
+
+ getch();
+
+ return 0 ;
+}
diff --git a/engine/dmlib/tool-src/servercred/src/md5c.c b/engine/dmlib/tool-src/servercred/src/md5c.c
new file mode 100644
index 0000000..6278f66
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/src/md5c.c
@@ -0,0 +1,299 @@
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+ */
+
+#include "md5.h"
+//#include "libmem.h"
+
+/* Constants for MD5Transform routine. */
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+static void MD5Transform (UINT4 [4], unsigned char [64]);
+static void Encode (unsigned char *, UINT4 *, unsigned int);
+static void Decode (UINT4 *, unsigned char *, unsigned int);
+static void MD5_memcpy (POINTER, POINTER, unsigned int);
+static void MD5_memset (POINTER, int, unsigned int);
+
+static unsigned char PADDING[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* F, G, H and I are basic MD5 functions. */
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+/* ROTATE_LEFT rotates x left n bits. */
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+Rotation is separate from addition to prevent recomputation.
+ */
+#define FF(a, b, c, d, x, s, ac) { \
+ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define GG(a, b, c, d, x, s, ac) { \
+ (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define HH(a, b, c, d, x, s, ac) { \
+ (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+#define II(a, b, c, d, x, s, ac) { \
+ (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
+ (a) = ROTATE_LEFT ((a), (s)); \
+ (a) += (b); \
+ }
+
+/* MD5 initialization. Begins an MD5 operation, writing a new context.
+ */
+void smlMD5Init (MD5_CTX *context)
+{
+ context->count[0] = context->count[1] = 0;
+ /* Load magic initialization constants. */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xefcdab89;
+ context->state[2] = 0x98badcfe;
+ context->state[3] = 0x10325476;
+}
+
+/* MD5 block update operation. Continues an MD5 message-digest
+ operation, processing another message block, and updating the
+ context.
+ */
+
+ /* context */
+ /* input block */
+ /* length of input block */
+void smlMD5Update (MD5_CTX *context, unsigned char *input, unsigned int inputLen)
+{
+ unsigned int i, index, partLen;
+
+ /* Compute number of bytes mod 64 */
+ index = (unsigned int)((context->count[0] >> 3) & 0x3F);
+
+ /* Update number of bits */
+ if ((context->count[0] += ((UINT4)inputLen << 3))
+ < ((UINT4)inputLen << 3))
+ context->count[1]++;
+ context->count[1] += ((UINT4)inputLen >> 29);
+
+ partLen = 64 - index;
+
+ /* Transform as many times as possible. */
+ if (inputLen >= partLen) {
+ MD5_memcpy
+ ((POINTER)&context->buffer[index], (POINTER)input, partLen);
+ MD5Transform (context->state, context->buffer);
+
+ for (i = partLen; i + 63 < inputLen; i += 64)
+ MD5Transform (context->state, &input[i]);
+
+ index = 0;
+ }
+ else
+ i = 0;
+
+ /* Buffer remaining input */
+ MD5_memcpy
+ ((POINTER)&context->buffer[index], (POINTER)&input[i],
+ inputLen-i);
+}
+
+/* MD5 finalization. Ends an MD5 message-digest operation, writing the
+ the message digest and zeroizing the context.
+ */
+ /* message digest */
+ /* context */
+void smlMD5Final (unsigned char digest[16], MD5_CTX *context)
+{
+ unsigned char bits[8];
+ unsigned int index, padLen;
+
+ /* Save number of bits */
+ Encode (bits, context->count, 8);
+
+ /* Pad out to 56 mod 64. */
+ index = (unsigned int)((context->count[0] >> 3) & 0x3f);
+ padLen = (index < 56) ? (56 - index) : (120 - index);
+ smlMD5Update (context, PADDING, padLen);
+
+ /* Append length (before padding) */
+ smlMD5Update (context, bits, 8);
+ /* Store state in digest */
+ Encode (digest, context->state, 16);
+
+ /* Zeroize sensitive information. */
+ MD5_memset ((POINTER)context, 0, sizeof (*context));
+}
+
+/* MD5 basic transformation. Transforms state based on block. */
+static void MD5Transform (UINT4 state[4], unsigned char block[64])
+{
+ UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
+
+ Decode (x, block, 64);
+
+ /* Round 1 */
+ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
+ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
+ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
+ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
+ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
+ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
+ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
+ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
+ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
+ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
+ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+ /* Round 2 */
+ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
+ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
+ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
+ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
+ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
+ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
+ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
+ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
+ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
+ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
+ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
+ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+ /* Round 3 */
+ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
+ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
+ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
+ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
+ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
+ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
+ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
+ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
+ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
+ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
+
+ /* Round 4 */
+ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
+ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
+ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
+ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
+ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
+ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
+ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
+ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
+ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
+ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
+
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+
+ /* Zeroize sensitive information. */
+ MD5_memset ((POINTER)x, 0, sizeof (x));
+}
+
+/* Encodes input (UINT4) into output (unsigned char). Assumes len is
+ a multiple of 4.
+ */
+static void Encode (unsigned char *output, UINT4 *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4) {
+ output[j] = (unsigned char)(input[i] & 0xff);
+ output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
+ output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
+ output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
+ }
+}
+
+/* Decodes input (unsigned char) into output (UINT4). Assumes len is
+ a multiple of 4.
+ */
+static void Decode (UINT4 *output, unsigned char *input, unsigned int len)
+{
+ unsigned int i, j;
+
+ for (i = 0, j = 0; j < len; i++, j += 4)
+ output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
+ (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
+}
+
+/* Note: Replace "for loop" with standard memcpy if possible.
+ */
+
+static void MD5_memcpy (POINTER output, POINTER input, unsigned int len)
+{
+ memcpy(output, input, len);
+}
+
+/* Note: Replace "for loop" with standard memset if possible.
+ */
+static void MD5_memset (POINTER output, int value, unsigned int len)
+{
+ memset(output, value, len);
+}
diff --git a/engine/dmlib/tool-src/servercred/src/xpt-b64.c b/engine/dmlib/tool-src/servercred/src/xpt-b64.c
new file mode 100644
index 0000000..c0128d6
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/src/xpt-b64.c
@@ -0,0 +1,358 @@
+
+/*************************************************************************/
+/* module: Communication Services, base64 encoding/decoding fns.*/
+/* file: src/xpt/all/xpt-b64.c */
+/* target system: all */
+/* target OS: all */
+/*************************************************************************/
+
+
+/*
+ * Copyright Notice
+ * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication
+ * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,
+ * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001).
+ * All Rights Reserved.
+ * Implementation of all or part of any Specification may require
+ * licenses under third party intellectual property rights,
+ * including without limitation, patent rights (such a third party
+ * may or may not be a Supporter). The Sponsors of the Specification
+ * are not responsible and shall not be held responsible in any
+ * manner for identifying or failing to identify any or all such
+ * third party intellectual property rights.
+ *
+ * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED
+ * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,
+ * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,
+ * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML
+ * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,
+ * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY
+ * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF
+ * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF
+ * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,
+ * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH
+ * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
+ *
+ * The above notice and this paragraph must be included on all copies
+ * of this document that are made.
+ *
+ */
+
+
+#include "xptport.h"
+#include "xpttypes.h"
+#include "xpt-b64.h"
+
+
+#define MAX_COLUMNS 45
+
+
+/***************************************************************************/
+/* The function decodes the next character of the input buffer and updates */
+/* the pointers to the input buffer. The function skips CRLF characters */
+/* and whitespace characters. */
+/* Returns: 0..63, the logical value of the next valid character in the */
+/* input buffer */
+/* 64, padding character */
+/* -1, No more characters to read */
+/* -2, an error occurred: invalid characters in the data stream*/
+/***************************************************************************/
+
+int nextBase64Char (DataBuffer_t *ppbData, BufferSize_t *pcbDataLength)
+ {
+ int r = -1;
+ DataBuffer_t pbData = *ppbData;
+ BufferSize_t cbDataLength = *pcbDataLength;
+#ifndef __EPOC_OS__
+ static char *pszSkipChars = "\t\r\n ";
+#endif
+#ifdef __EPOC_OS__
+ char *pszSkipChars = "\t\r\n ";
+#endif
+ char ch;
+
+ if (cbDataLength == 0) return r;
+
+ do {
+ ch = *pbData;
+ if ((ch>='0')&&(ch<='9')) r = (int)ch+4; // |
+ else if ((ch>='A')&&(ch<='Z')) r = (int)ch-65; // |
+ else if ((ch>='a')&&(ch<='z')) r = (int)ch-71; // | Valid characters
+ else if (ch == '/') r = 63; // |
+ else if (ch == '+') r = 62; // |
+ else if (ch == '=') r = 64; // padding character
+ else if (!xppStrchr (pszSkipChars, ch)) r = -2; // invalid character
+ cbDataLength --;
+ pbData ++;
+ } while ((r == -1) && (cbDataLength > 0));
+
+ /***************************************************/
+ /* Pass the updated parameter values to the caller */
+ /***************************************************/
+ if (r != -1)
+ {
+ *ppbData = pbData;
+ *pcbDataLength = cbDataLength;
+ }
+ return r;
+ }
+
+BufferSize_t base64GetSize (BufferSize_t cbRealDataSize)
+ {
+ int iMod = cbRealDataSize % 3;
+ /* The encoded data size ... */
+ BufferSize_t cbEncodedSize = ((cbRealDataSize - iMod) / 3 ) * 4;
+ if (iMod != 0) cbEncodedSize += 4;
+ /* ... and the # of CRLF characters */
+ cbEncodedSize += ((cbEncodedSize-1) / ((MAX_COLUMNS*4)/3)) * 2;
+ return cbEncodedSize;
+ }
+
+
+/*****************************************************************/
+/* Function: pre-compute the size of the base64 encoded document */
+/****************************************************************/
+
+BufferSize_t base64Encode (DataBuffer_t pbTarget, // o: target buffer
+ BufferSize_t cbTargetSize, // i: target buffer size
+ DataBuffer_t pbData, // i: Data buffer
+ BufferSize_t *pcbDataLength, // i/o: Data buffer size
+ BufferSize_t *pcbOffset, // i/o: absolute # of bytes encoded so far
+ unsigned int bLast, // i: 0=first block, 1= next block, 2=last block
+ unsigned char *pbSaveBytes) // i/o: last incomplete data block
+ {
+ DataBuffer_t pbSourceData = pbData;
+ BufferSize_t cbCopySize = 0;
+ BufferSize_t cbDataProcessed = *pcbDataLength;
+ unsigned int i0, i1, i2, i3;
+ unsigned int byt;
+ int iSave = 1;
+#ifndef __EPOC_OS__
+ static char t [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // 26
+ "abcdefghijklmnopqrstuvwxyz" // 26
+ "0123456789+/" // 12
+ "="; // 1
+#endif
+#ifdef __EPOC_OS__
+char t [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // 26
+ "abcdefghijklmnopqrstuvwxyz" // 26
+ "0123456789+/" // 12
+ "="; // 1
+#endif
+ // Check for NULL data buffer,
+ if (pbData == NULL ) {
+ // See if last block and there is any "saved" data that needs to go now.
+ if ( bLast && ( pbSaveBytes && pbSaveBytes [0] )) {
+ /**************************************/
+ /* Check if it is time to send a CRLF */
+ /**************************************/
+ if ((*pcbOffset) > 0 && ((*pcbOffset) % MAX_COLUMNS == 0))
+ {
+ //if (cbTargetSize < 6) // there is not enough space in the target buffer:
+ // break; // return to the caller.
+ *pbTarget = '\r';
+ *(pbTarget+1) = '\n';
+ cbCopySize += 2;
+ cbTargetSize -= 2;
+ pbTarget += 2;
+ }
+
+ byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --;
+
+ i0 = byt >> 2;
+ i1 = (byt & 0x0003) << 4;
+
+ (*pcbOffset) ++;
+
+ if (pbSaveBytes && pbSaveBytes [0]) {
+ byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --;
+ i1 += (byt >> 4);
+ i2 = (byt & 0x000F) << 2;
+ } else {
+ i2 = i3 = 64; // index to the padding char '=';
+ }
+
+ pbTarget [0] = t[i0];
+ pbTarget [1] = t[i1];
+ pbTarget [2] = t[i2];
+ pbTarget [3] = t[i3];
+
+ cbCopySize += 4;
+ cbTargetSize -= 4;
+ pbTarget += 4;
+ }
+
+ } else {
+ while ((cbTargetSize >= 4) &&
+ ( ((cbDataProcessed >= 3) && (bLast == 0)) ||
+ ((cbDataProcessed > 0) && (bLast == 1)) ))
+ {
+ /**************************************/
+ /* Check if it is time to send a CRLF */
+ /**************************************/
+ if ((*pcbOffset) > 0 && ((*pcbOffset) % MAX_COLUMNS == 0))
+ {
+ if (cbTargetSize < 6) // there is not enough space in the target buffer:
+ break; // return to the caller.
+ *pbTarget = '\r';
+ *(pbTarget+1) = '\n';
+ cbCopySize += 2;
+ cbTargetSize -= 2;
+ pbTarget += 2;
+ }
+
+ if (pbSaveBytes && pbSaveBytes [0])
+ { byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --; }
+ else
+ { byt = (unsigned int) *pbSourceData; pbSourceData ++; cbDataProcessed --;}
+
+ i0 = byt >> 2;
+ i1 = (byt & 0x0003) << 4;
+
+ (*pcbOffset) ++;
+
+ if (cbDataProcessed > 0)
+ {
+ if (pbSaveBytes && pbSaveBytes [0])
+ { byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --; }
+ else
+ { byt = (unsigned int) *pbSourceData; pbSourceData ++; cbDataProcessed --;}
+
+ i1 += (byt >> 4);
+ i2 = (byt & 0x000F) << 2;
+
+ (*pcbOffset) ++;
+
+ if (cbDataProcessed > 0)
+ {
+ if (pbSaveBytes && pbSaveBytes [0])
+ { byt = (unsigned int) pbSaveBytes [iSave]; iSave ++; pbSaveBytes [0] --; }
+ else
+ { byt = (unsigned int) *pbSourceData; pbSourceData ++; cbDataProcessed --;}
+
+ i2 += (byt & 0x00C0) >> 6;
+ i3 = byt & 0x003F;
+ (*pcbOffset) ++;
+ }
+ else
+ i3 = 64; // index to the padding char '=';
+ }
+ else
+ i2 = i3 = 64; // index to the padding char '=';
+ pbTarget [0] = t[i0];
+ pbTarget [1] = t[i1];
+ pbTarget [2] = t[i2];
+ pbTarget [3] = t[i3];
+
+ cbCopySize += 4;
+ cbTargetSize -= 4;
+ pbTarget += 4;
+ }
+ }
+
+
+
+ /*************************************************************/
+ /* Save the bytes that must be processed in the following */
+ /* call (max. 2 Bytes). */
+ /*************************************************************/
+ if ((bLast == 0) && (cbDataProcessed <= 2) && (pbSaveBytes != NULL))
+ {
+ pbSaveBytes[0] = cbDataProcessed;
+ while (cbDataProcessed)
+ {
+ *(++pbSaveBytes) = pbSourceData[0];
+ cbDataProcessed --; pbSourceData ++;
+ }
+ }
+
+ /*****************************************************************/
+ /* Shift all non-processed data to the start of the input buffer */
+ /*****************************************************************/
+
+ if (cbDataProcessed > 0)
+ {
+ xppMemmove (pbData, pbSourceData, cbDataProcessed);
+ }
+ *pcbDataLength = cbDataProcessed;
+
+ return cbCopySize;
+ }
+
+
+/***************************************************************/
+/* Function: decode a base64- encoded block of data. */
+/* The function returns the count of data that are decoded, or */
+/* 0 in case of a data error, or if cbTargetSize < 4 */
+/***************************************************************/
+
+BufferSize_t base64Decode (DataBuffer_t pbTarget, // o: target buffer
+ BufferSize_t cbTargetSize, // i: target buffer size
+ DataBuffer_t pbData, // i: data buffer
+ BufferSize_t *pcbDataLength) // i/o: Data buffer size
+ {
+ DataBuffer_t pbSource = pbData;
+ BufferSize_t cbDataCopied = 0L;
+ BufferSize_t cbRemaining = *pcbDataLength; // remaining source data
+ int i0 = 0, i1 = 0, i2 = 0, i3 = 0;
+
+ while (cbTargetSize > 0)
+ {
+ BufferSize_t cbNext = cbRemaining;
+ DataBuffer_t pbNext = pbSource;
+
+ i0 = nextBase64Char (&pbNext, &cbNext);
+ i1 = nextBase64Char (&pbNext, &cbNext);
+ i2 = nextBase64Char (&pbNext, &cbNext);
+ i3 = nextBase64Char (&pbNext, &cbNext);
+ if ((i0 < 0) || (i1 < 0) || (i2 < 0) || (i3 < 0))
+ break; // end-of-block, or data error.
+
+ else if ( ((cbTargetSize <= 2) && (i3 != 64)) ||
+ ((cbTargetSize <= 1) && (i2 != 64)) )
+ break; // end of transmission.
+
+ else
+ {
+ pbSource = pbNext;
+ cbRemaining = cbNext;
+ /************************/
+ /* decode the quadruple */
+ /************************/
+ *pbTarget = (i0 << 2) + (i1 >> 4);
+ pbTarget ++; cbDataCopied ++; cbTargetSize --;
+ if (i2 != 64)
+ {
+ *pbTarget = ((i1 & 0x000f) << 4) + (i2 >> 2);
+ pbTarget ++; cbDataCopied ++; cbTargetSize --;
+ if (i3 != 64)
+ {
+ *pbTarget = ((i2 & 0x0003) << 6) + i3;
+ pbTarget ++; cbDataCopied ++; cbTargetSize --;
+ }
+ }
+ }
+ }
+
+ /*******************************/
+ /* Handle invalid data errors! */
+ /*******************************/
+
+ if ((i0 == -2) || (i1 == -2) || (i2 == -2) || (i3 == -2))
+ cbDataCopied = 0;
+
+ /*****************************************************************/
+ /* Shift all non-processed data to the start of the input buffer */
+ /*****************************************************************/
+ if (cbRemaining > 0)
+ xppMemmove (pbData, pbSource, cbRemaining);
+ *pcbDataLength = cbRemaining;
+ return cbDataCopied;
+ }
+
+
diff --git a/engine/dmlib/tool-src/servercred/win32.bat b/engine/dmlib/tool-src/servercred/win32.bat
new file mode 100644
index 0000000..ea356a9
--- /dev/null
+++ b/engine/dmlib/tool-src/servercred/win32.bat
@@ -0,0 +1,3 @@
+:: requires Microsoft Visual C++, run vcvars32 to set env first
+cl src/main.c src/md5c.c src/xpt-b64.c /I ./hdr /o ./bin/servercred.exe
+
diff --git a/engine/javaplugin/Android.mk b/engine/javaplugin/Android.mk
new file mode 100644
index 0000000..c8e411c
--- /dev/null
+++ b/engine/javaplugin/Android.mk
@@ -0,0 +1,10 @@
+# Copyright 2007-2008 The Android Open Source Project
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+# This finds and builds the test apk as well, so a single make does both.
+include $(CLEAR_VARS)
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/engine/javaplugin/api/Android.mk b/engine/javaplugin/api/Android.mk
new file mode 100644
index 0000000..42f17ce
--- /dev/null
+++ b/engine/javaplugin/api/Android.mk
@@ -0,0 +1,21 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files) \
+ com/android/omadm/plugin/IDMClientService.aidl \
+ com/android/omadm/plugin/IDmtPlugin.aidl
+
+#LOCAL_JAVA_RESOURCE_DIRS := resources
+
+#LOCAL_JAVA_LIBRARIES := com.android.omadm.plugin
+#LOCAL_STATIC_JAVA_LIBRARIES := com.android.omadm.plugin
+
+LOCAL_MODULE:= com.android.omadm.plugin
+
+#LOCAL_DX_FLAGS := --core-library
+
+#include $(BUILD_JAVA_LIBRARY)
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/DmtBasePlugin.java b/engine/javaplugin/api/com/android/omadm/plugin/DmtBasePlugin.java
new file mode 100644
index 0000000..0030138
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/DmtBasePlugin.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+import android.os.RemoteException;
+
+import java.util.Map;
+
+public abstract class DmtBasePlugin extends IDmtPlugin.Stub {
+
+ private String mServerId;
+ protected static final boolean DEBUG = false;
+
+ private int mOperationResult; // = ErrorCodes.SYNCML_DM_SUCCESS;
+
+ protected int setOperationResult(int result) {
+ mOperationResult = result;
+ return result;
+ }
+
+ @Override
+ public int getOperationResult() {
+ return mOperationResult;
+ }
+
+ @Override
+ public void setServerID(String serverID) {
+ mServerId = serverID;
+ }
+
+ @Override
+ public String getServerID() {
+ return mServerId;
+ }
+
+ @Override
+ public DmtPluginNode getNode(String arg0) throws RemoteException {
+ setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ return null;
+ }
+
+ @Override
+ public Map getNodes(String arg0) throws RemoteException {
+ setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ return null;
+ }
+
+ @Override
+ public DmtData getNodeValue(String path) throws RemoteException {
+ setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ return null;
+ }
+
+ @Override
+ public int createInteriorNode(String arg0) throws RemoteException {
+ return setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public int createLeafNode(String arg0, DmtData arg1) throws RemoteException {
+ return setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public int updateLeafNode(String path, DmtData newValue) throws RemoteException {
+ return setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public int deleteNode(String arg0) throws RemoteException {
+ return setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public int clone(String arg0, String arg1) throws RemoteException {
+ return setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public int renameNode(String arg0, String arg1) throws RemoteException {
+ return setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public int exec(String path, String args, String correlator) throws RemoteException {
+ return setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public int commit() throws RemoteException {
+ return setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public String getServerPW(String aiServerPW) {
+ return null;
+ }
+
+ @Override
+ public String getClientPW(String aiClientPW) {
+ return null;
+ }
+
+ @Override
+ public String getUsername(String aiUsername) {
+ return null;
+ }
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/DmtData.aidl b/engine/javaplugin/api/com/android/omadm/plugin/DmtData.aidl
new file mode 100644
index 0000000..b4e23fd
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/DmtData.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+parcelable DmtData;
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/DmtData.java b/engine/javaplugin/api/com/android/omadm/plugin/DmtData.java
new file mode 100644
index 0000000..6cbf908
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/DmtData.java
@@ -0,0 +1,546 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.text.TextUtils;
+import android.util.Log;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * DmtData encapsulates various DMT node data formats.
+ *
+ * <pre>
+ * Data formats includes:
+ * NULL
+ * String
+ * Integer
+ * Boolean
+ * Binary
+ * Date
+ * Time
+ * Float
+ * NODE
+ * </pre>
+ */
+public class DmtData implements Parcelable {
+ private static final String TAG = "DmtData";
+
+ /**
+ * NULL Data type.
+ */
+ public static final int NULL = 0;
+
+ /**
+ * Undefined.
+ */
+ public static final int UNDEFINED = NULL;
+
+ /**
+ * String Data
+ */
+ public static final int STRING = 1;
+
+ /**
+ * Integer Data
+ */
+ public static final int INT = 2;
+
+ /**
+ * Boolean Data
+ */
+ public static final int BOOL = 3;
+
+ /**
+ * Binary Data
+ */
+ public static final int BIN = 4;
+
+ /**
+ * Interior Node
+ */
+ public static final int NODE = 5;
+
+ /**
+ * Base 64 Node
+ */
+ public static final int B64 = 6;
+
+ /**
+ * XML Node
+ */
+ public static final int XML = 7;
+
+ /**
+ * Date data
+ */
+ public static final int DATE = 8;
+
+ /**
+ * Time data
+ */
+ public static final int TIME = 10;
+
+ /**
+ * Float data
+ */
+ public static final int FLOAT = 11;
+
+ /*
+ * Used to create a DmtData((String)null)
+ */
+ public static final String NULLVALUE = null;
+
+ private int type;
+
+ private String stringValue;
+
+ private int intValue;
+
+ private boolean boolValue;
+
+ private byte[] binValue;
+
+ private String dateValue;
+
+ private String timeValue;
+
+ private float floatValue;
+
+ private final LinkedHashMap<String, DmtData> childNodes = new LinkedHashMap<String, DmtData>();
+
+ /**
+ * Data represent a default value, it is only used for setting default value
+ * to a node. if the node does not have a default value, a null value is
+ * used instead.
+ */
+ public DmtData() {
+ }
+
+ public DmtData(String str, int dataType) {
+ init(str, dataType);
+ }
+
+ private void init(String str, int dataType) {
+ type = dataType;
+ if (str == null) {
+ return;
+ }
+ switch (dataType) {
+ case NULL:
+ break;
+ case STRING:
+ stringValue = str;
+ break;
+ case INT:
+ try {
+ intValue = Integer.parseInt(str);
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "can't parse init value as integer", e);
+ }
+ break;
+ case BOOL:
+ boolValue = Boolean.parseBoolean(str);
+ break;
+ case BIN:
+ binValue = str.getBytes();
+ break;
+ case DATE:
+ dateValue = str;
+ break;
+ case TIME:
+ timeValue = str;
+ break;
+ case FLOAT:
+ try {
+ floatValue = Float.parseFloat(str);
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "can't parse init value as float", e);
+ }
+ break;
+ case NODE:
+ childNodes.clear();
+ String[] strArray = str.split("\\|");
+ int cnt = strArray.length;
+ if (cnt > 0 && !strArray[0].isEmpty()) {
+ for (String name : strArray) {
+ childNodes.put(name, new DmtData());
+ }
+ }
+ break;
+ default:
+ type = UNDEFINED;
+ break;
+ }
+ }
+
+ /**
+ * Data represent an String type.
+ *
+ * @param str String type data. The size may be restricted by MDF.
+ */
+ public DmtData(String str) {
+ stringValue = str;
+ type = STRING;
+ }
+
+ /**
+ * Data represent an integer type Data range may be restricted by MDF
+ */
+ public DmtData(int integer) {
+ intValue = integer;
+ type = INT;
+ }
+
+ /**
+ * Data represent a boolean type
+ */
+ public DmtData(boolean bool) {
+ boolValue = bool;
+ type = BOOL;
+ }
+
+ /**
+ * Data represent a binary type Data size may be restricted by MDF. Data may
+ * be null.
+ */
+ public DmtData(byte[] bin) {
+ binValue = bin;
+ type = BIN;
+ }
+
+ public DmtData(float value) {
+ floatValue = value;
+ type = FLOAT;
+ }
+
+ @Override
+ public String toString() {
+ return getString();
+ }
+
+ /**
+ * Get string representation of the value. It will automatically convert to
+ * string value from other types. for NULL value, return empty String. for
+ * Default value, return null.
+ */
+ public String getString() {
+ switch (type) {
+ case NULL:
+ return "";
+ case STRING:
+ return stringValue;
+ case INT:
+ return String.valueOf(intValue);
+ case BOOL:
+ return String.valueOf(boolValue);
+ case BIN:
+ return (binValue == null) ? null : (new String(binValue));
+ case DATE:
+ return dateValue;
+ case TIME:
+ return timeValue;
+ case FLOAT:
+ return String.valueOf(floatValue);
+ case NODE:
+ StringBuilder tmpValue = new StringBuilder();
+ try {
+ for (String node : childNodes.keySet()) {
+ tmpValue.append(node).append('|');
+ }
+ if (tmpValue.length() != 0) {
+ tmpValue.deleteCharAt(tmpValue.length() - 1);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "getString() failed for node object", e);
+ }
+ return tmpValue.toString();
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Get Boolean value.
+ *
+ * @return boolean value.
+ */
+ public boolean getBoolean() throws DmtException {
+ if (type != BOOL) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_INVALID_PARAMETER,
+ "The value requested is not boolean");
+ }
+ return boolValue;
+ }
+
+ /**
+ * Get Integer value.
+ *
+ * @return integer value
+ */
+ public int getInt() throws DmtException {
+ if (type != INT) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_INVALID_PARAMETER,
+ "The value requested is not integer");
+ }
+ return intValue;
+ }
+
+ /**
+ * Get binary value.
+ *
+ * @return binary value in byte[].
+ */
+ public byte[] getBinary() throws DmtException {
+ if (type != BIN) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_INVALID_PARAMETER,
+ "The value requested is not binary");
+ }
+ return binValue;
+ }
+
+ /**
+ * Adds the specified child node to this interior node.
+ * @param name the name of the node to add
+ * @param child the node data to add
+ * @throws DmtException if this is not an interior node
+ */
+ public void addChildNode(String name, DmtData child) throws DmtException {
+ if (type != NODE) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_INVALID_PARAMETER,
+ "can't add children to leaf node");
+ }
+ childNodes.put(name, child);
+ }
+
+ public void removeChildNode(String name) throws DmtException {
+ if (type != NODE) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_INVALID_PARAMETER,
+ "can't add children to leaf node");
+ }
+ childNodes.remove(name);
+ }
+
+ /**
+ * Returns the specified child of this interior node.
+ * @return the specified node data, or null if not found
+ * @throws DmtException if this is not an interior node
+ */
+ public DmtData getChild(String name) throws DmtException {
+ if (type != NODE) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_INVALID_PARAMETER,
+ "can't get children of leaf node");
+ }
+ return childNodes.get(name);
+ }
+
+ /**
+ * Returns all children of this interior node.
+ * @return a map from node names to node data
+ * @throws DmtException if this is not an interior node
+ */
+ public Map<String, DmtData> getChildNodeMap() throws DmtException {
+ if (type != NODE) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_INVALID_PARAMETER,
+ "can't get children of leaf node");
+ }
+ return Collections.unmodifiableMap(childNodes);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof DmtData)) {
+ return false;
+ }
+ DmtData data = (DmtData) obj;
+
+ if (getType() != data.getType()) {
+ return false;
+ }
+
+ try {
+ switch (getType()) {
+ case NULL:
+ return true;
+
+ case DATE:
+ case TIME:
+ case FLOAT:
+ case STRING:
+ case NODE:
+ String str1 = getString();
+ String str2 = data.getString();
+ return TextUtils.equals(str1, str2);
+
+ case INT:
+ return getInt() == data.getInt();
+
+ case BOOL:
+ return getBoolean() == data.getBoolean();
+
+ case BIN:
+ byte[] bytes1 = getBinary();
+ byte[] bytes2 = data.getBinary();
+ return Arrays.equals(bytes1, bytes2);
+
+ default:
+ return false;
+ }
+ } catch (DmtException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Return the Type associated with the data This information is to be used
+ * by the persistence layer. Persistence does NOT need to use meta info to
+ * get the data
+ */
+ public int getType() {
+ return type;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeInt(type);
+ switch (type) {
+ case NULL:
+ break;
+
+ case STRING:
+ out.writeString(stringValue);
+ break;
+
+ case INT:
+ out.writeInt(intValue);
+ break;
+
+ case BOOL:
+ out.writeInt(boolValue ? 1 : 0);
+ break;
+
+ case BIN:
+ if (binValue == null || binValue.length == 0) {
+ out.writeInt(0);
+ } else {
+ out.writeInt(binValue.length);
+ out.writeByteArray(binValue);
+ }
+ break;
+
+ case DATE:
+ out.writeString(dateValue);
+ break;
+
+ case TIME:
+ out.writeString(timeValue);
+ break;
+
+ case FLOAT:
+ out.writeFloat(floatValue);
+ break;
+
+ case NODE:
+ out.writeInt(childNodes.size());
+ for (Map.Entry<String, DmtData> entry : childNodes.entrySet()) {
+ out.writeString(entry.getKey());
+ entry.getValue().writeToParcel(out, flags);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public static final Creator<DmtData> CREATOR = new Creator<DmtData>() {
+ @Override
+ public DmtData createFromParcel(Parcel in) {
+ return new DmtData(in);
+ }
+
+ @Override
+ public DmtData[] newArray(int size) {
+ return new DmtData[size];
+ }
+ };
+
+ DmtData(Parcel in) {
+ type = in.readInt();
+ switch (type) {
+ case NULL:
+ break;
+
+ case STRING:
+ stringValue = in.readString();
+ break;
+
+ case INT:
+ intValue = in.readInt();
+ break;
+
+ case BOOL:
+ boolValue = (in.readInt() != 0);
+ break;
+
+ case BIN:
+ int length = in.readInt();
+ if (length == 0) {
+ binValue = null;
+ } else {
+ binValue = new byte[length];
+ in.readByteArray(binValue);
+ }
+ break;
+
+ case DATE:
+ dateValue = in.readString();
+ break;
+
+ case TIME:
+ timeValue = in.readString();
+ break;
+
+ case FLOAT:
+ floatValue = in.readFloat();
+ break;
+
+ case NODE:
+ childNodes.clear();
+ int childNodeCount = in.readInt();
+ for (int i = 0; i < childNodeCount; i++) {
+ String name = in.readString();
+ DmtData value = new DmtData(in);
+ childNodes.put(name, value);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/DmtException.java b/engine/javaplugin/api/com/android/omadm/plugin/DmtException.java
new file mode 100644
index 0000000..aa113a5
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/DmtException.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+/**
+ * DmtException is the base for all DMT exceptions.
+ */
+public class DmtException extends Exception {
+
+ private final int code;
+
+ /**
+ * Default Constructor for unspecified message. Not recommended to use.
+ */
+ public DmtException() {
+ code = ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ /**
+ * Exception with only message without error code, for backwards
+ * compatibility, not recommended to use.
+ *
+ * @param message the detail message. null means unspecified.
+ */
+ public DmtException(String message) {
+ super(message);
+ code = ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ /**
+ * Recommended DmtException constructor.
+ *
+ * @param code error code specified in <A
+ * href="ErrorCodes.html">ErrorCodes</A>. 0 means unspecified.
+ * @param message the detail message. null means unspecified.
+ */
+ public DmtException(int code, String message) {
+ super(message);
+ this.code = code;
+ }
+
+ /**
+ * Return error code. if it is 0 it means has not been specified.
+ *
+ * @return Error code,
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /**
+ * Returns the error message string. null means unspecified message
+ *
+ * @return Error message string.
+ */
+ @Override
+ public String getMessage() {
+ String s = super.getMessage();
+ if (s == null) {
+ s = "Unspecified Message";
+ }
+ return s;
+ }
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/DmtManagementObject.java b/engine/javaplugin/api/com/android/omadm/plugin/DmtManagementObject.java
new file mode 100644
index 0000000..24f206a
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/DmtManagementObject.java
@@ -0,0 +1,498 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+import android.text.TextUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class DmtManagementObject implements IDmtSubTree {
+
+ private final String mPath;
+
+ private boolean mIsUpdated;
+
+ protected final Map<String, DmtPluginNode> mNodes = new HashMap<String, DmtPluginNode>();
+
+ private final IDmtRootPlugin mRootPlugin; // FIXME: assigned but never accessed
+
+ public DmtManagementObject(String path, IDmtRootPlugin rootPlugin) throws DmtException {
+ if (!DmtPathUtils.isValidPath(path)) {
+ throw new DmtException("Invalid URI");
+ }
+
+ mPath = path;
+ mRootPlugin = rootPlugin;
+
+ mNodes.put(path, new DmtPluginNode(mPath, new DmtData(null, DmtData.NODE)));
+ }
+
+ /**
+ * Checks if a node by given path exists in the subtree.
+ *
+ * @param nodePath path to the node.
+ * @return true if the node is exist otherwise false.
+ */
+ protected boolean isNodeExist(String nodePath) {
+ return (mNodes.get(nodePath) != null);
+ }
+
+ /**
+ * Creates new leaf node in the subtree. The parent node is updated automatically.
+ *
+ * @param nodePath path to the new node.
+ * @param nodeValue new node value.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} in success case otherwise an error.
+ */
+ protected final int createLeafNode_(String nodePath, DmtData nodeValue) {
+ if (nodeValue == null) {
+ return ErrorCodes.SYNCML_DM_INVALID_PARAMETER;
+ }
+
+ String[] data = DmtPathUtils.splitPath(nodePath);
+
+ String rootNodePath = data[0];
+ String nodeName = data[1];
+
+ if (TextUtils.isEmpty(rootNodePath) || TextUtils.isEmpty(nodeName)) {
+ return ErrorCodes.SYNCML_DM_INVALID_URI;
+ }
+
+ if (isNodeExist(nodePath)) {
+ return updateLeafNode_(nodePath, nodeValue);
+ }
+
+ int retcode = createInteriorNode_(rootNodePath);
+ if (retcode != ErrorCodes.SYNCML_DM_SUCCESS) {
+ return retcode;
+ }
+
+ retcode = addNameToInteriorNode(rootNodePath, nodeName);
+ if (retcode != ErrorCodes.SYNCML_DM_SUCCESS) {
+ return retcode;
+ }
+
+ mNodes.put(nodePath, new DmtPluginNode(nodePath, nodeValue));
+
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Creates a new interior node in the subtree. The parent node is updated automatically.
+ *
+ * @param nodePath path to the new node.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} in success case otherwise an error.
+ */
+ protected final int createInteriorNode_(String nodePath) {
+ String[] data = DmtPathUtils.splitPath(nodePath);
+
+ String rootNodePath = data[0];
+ String nodeName = data[1];
+
+ if (TextUtils.isEmpty(rootNodePath) || TextUtils.isEmpty(nodeName)) {
+ return ErrorCodes.SYNCML_DM_INVALID_URI;
+ }
+
+ if (!DmtPathUtils.isSubPath(mPath, nodePath)) {
+ return ErrorCodes.SYNCML_DM_INVALID_URI;
+ }
+
+ /* Check that exist node is an interior node and engine tries to set interior node too */
+ DmtPluginNode node = mNodes.get(nodePath);
+ if (node != null) {
+ return node.isLeaf() ? ErrorCodes.SYNCML_DM_ENTRY_EXIST
+ : ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+ int retcode = createInteriorNode_(rootNodePath);
+ if (retcode != ErrorCodes.SYNCML_DM_SUCCESS) {
+ return retcode;
+ }
+
+ retcode = addNameToInteriorNode(rootNodePath, nodeName);
+ if (retcode != ErrorCodes.SYNCML_DM_SUCCESS) {
+ return retcode;
+ }
+
+ mNodes.put(nodePath, new DmtPluginNode(nodePath, new DmtData(null, DmtData.NODE)));
+
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+
+ private int addNameToInteriorNode(String rootNodePath, String nodeName) {
+ DmtPluginNode rootNode = mNodes.get(rootNodePath);
+
+ if (rootNode == null || rootNode.isLeaf()) {
+ return ErrorCodes.SYNCML_DM_INVALID_URI;
+ }
+
+ try {
+ rootNode.getValue().addChildNode(nodeName, new DmtData());
+ } catch (DmtException e) {
+ return e.getCode();
+ }
+
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Updates a leaf node value.
+ *
+ * @param nodePath full path to the node.
+ * @param nodeValue new node value.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} in success case otherwise an error.
+ */
+ protected final int updateLeafNode_(String nodePath, DmtData nodeValue) {
+ if (nodeValue == null) {
+ return ErrorCodes.SYNCML_DM_INVALID_PARAMETER;
+ }
+
+ DmtPluginNode node = mNodes.get(nodePath);
+ if (node == null) {
+ return ErrorCodes.SYNCML_DM_ENTRY_NOT_FOUND;
+ }
+
+ if (node.getType() == DmtData.NODE || nodeValue.getType() == DmtData.NODE) {
+ return ErrorCodes.SYNCML_DM_COMMAND_NOT_ALLOWED;
+ }
+
+ node.setValue(nodeValue);
+
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Removes a node. If the node is an inner node, the root node of it is
+ * updated automatically.
+ *
+ * @param nodePath path to the node.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} in success case otherwise an error.
+ */
+ protected final int deleteNode_(String nodePath) {
+ DmtPluginNode node = mNodes.get(nodePath);
+ if (node == null) {
+ return ErrorCodes.SYNCML_DM_ENTRY_NOT_FOUND;
+ }
+
+ if (mPath.equals(nodePath)) {
+ mNodes.clear();
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+ String[] data = DmtPathUtils.splitPath(nodePath);
+ if (TextUtils.isEmpty(data[0]) || TextUtils.isEmpty(data[1])) {
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ DmtPluginNode rootNode = mNodes.get(data[0]);
+ if (rootNode == null) {
+ return ErrorCodes.SYNCML_DM_TREE_CORRUPT;
+ }
+
+ /* Remove the node name from root node's list */
+ Map<String, DmtData> children;
+ try {
+ children = rootNode.getValue().getChildNodeMap();
+ } catch (DmtException e) {
+ return e.getCode();
+ }
+
+ if (children == null) {
+ return ErrorCodes.SYNCML_DM_TREE_CORRUPT;
+ }
+
+ children.remove(data[1]);
+
+ /*
+ * Since getNodeValue() returns reference to
+ * its own object we can change it without creating
+ * of new DmtData object
+ */
+ // rootNode.setValue(new DmtData(children));
+
+ /* Remove the node from the sub tree */
+ mNodes.remove(nodePath);
+
+ /* Remove all sub nodes for the interior node */
+ if (!node.isLeaf()) {
+ String subPath = nodePath + '/';
+
+ String[] paths = mNodes.keySet().toArray(new String[mNodes.size()]);
+ for (String path : paths) {
+ if (path.startsWith(subPath)) {
+ mNodes.remove(path);
+ }
+ }
+ }
+
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Performs mapping of a given node path tag to relative node path.
+ *
+ * @param tag arbitrary tag that defines the node.
+ * @param getSemantics true if GET semantics; false if SET semantics.
+ * @return DMT node path.
+ */
+ protected abstract String resolve(String tag, boolean getSemantics) throws DmtException;
+
+ /**
+ * Returns a node value by given path. The method uses
+ * resolve() method which should be implemented on successor side
+ * to get full path to the node by tag.
+ *
+ * @param tag arbitrary tag that defines the node.
+ * @throws DmtException if the node is not present.
+ * @return DmtData. It can be null if value is not set.
+ */
+ public final DmtData getLeafNodeDmtValue(String tag) throws DmtException {
+ String nodePath;
+ try {
+ nodePath = resolve(tag, true);
+ } catch (Exception e) {
+ throw new DmtException("Resolver throws an exception");
+ }
+
+ if (TextUtils.isEmpty(nodePath)) {
+ throw new DmtException("Resolver returns empty string");
+ }
+ nodePath = mPath + '/' + nodePath;
+
+ return getNodeValue(nodePath);
+ }
+
+ /**
+ * Returns a string node value by given tag. The method uses
+ * resolve() method which should be implemented on successor side
+ * to get full path to the node by tag.
+ *
+ * @param tag arbitrary tag that defines the node.
+ * @throws DmtException if the node is not present or node type is not String.
+ * @return string. It can be null if value is not set.
+ */
+ public final String getLeafNodeStringValue(String tag) throws DmtException {
+ DmtData data = getLeafNodeDmtValue(tag);
+ if (data == null) {
+ throw new DmtException("Data is not set for the node. Tag = " + tag);
+ }
+
+ if (data.getType() == DmtData.NULL) {
+ return "";
+ }
+
+ if (data.getType() != DmtData.STRING) {
+ throw new DmtException("Node type is not STRING");
+ }
+
+ return data.getString();
+ }
+
+ /**
+ * Returns a integer node value by given tag. The method uses
+ * resolve() method which should be implemented on successor side
+ * to get full path to the node by tag.
+ *
+ * @param tag arbitrary tag that defines the node.
+ * @throws DmtException if the node is not present or node type is not String.
+ * @return value of integer node.
+ */
+ public final int getLeafNodeIntegerValue(String tag) throws DmtException {
+ DmtData data = getLeafNodeDmtValue(tag);
+ if (data == null) {
+ throw new DmtException("Data is not set for the node. Tag = " + tag);
+ }
+
+ if (data.getType() != DmtData.INT) {
+ throw new DmtException("Node type is not INT");
+ }
+
+ return data.getInt();
+ }
+
+ /**
+ * Sets value of node specified by given tag. Creates the node and any
+ * necessary intermediate nodes that lie within the node path if necessary.
+ *
+ * @param tag MO-defined string that describes the node.
+ * @param value node value.
+ * @throws DmtException if an error occurred.
+ */
+ public final void setLeafNodeValue(String tag, DmtData value) throws DmtException {
+ String nodePath;
+ try {
+ nodePath = resolve(tag, false);
+ } catch (Exception e) {
+ throw new DmtException("Resolver throws an exception");
+ }
+
+ if (TextUtils.isEmpty(nodePath)) {
+ throw new DmtException("Resolver returns empty string");
+ }
+ nodePath = mPath + '/' + nodePath;
+
+ if (isNodeExist(nodePath)) {
+ if (updateLeafNode_(nodePath, value) != ErrorCodes.SYNCML_DM_SUCCESS) {
+ throw new DmtException("Cannot update node");
+ }
+ return;
+ }
+
+ if (createLeafNode_(nodePath, value) != ErrorCodes.SYNCML_DM_SUCCESS) {
+ throw new DmtException("Cannot create node");
+ }
+ }
+
+ /**
+ * Sets the string value of node specified by given tag. Creates the node
+ * and any necessary intermediate nodes that lie within the node path if
+ * necessary.
+ *
+ * @param tag MO-defined string that describes the node.
+ * @param value node value.
+ * @throws DmtException if an error occurred.
+ */
+ public final void setLeafNodeValue(String tag, String value) throws DmtException {
+ setLeafNodeValue(tag, new DmtData(value));
+ }
+
+ /**
+ * Marks the management object as updated.
+ */
+ public void setNodeUpdatedState() {
+ mIsUpdated = true;
+ }
+
+ @Override
+ public int createInteriorNode(String path) {
+ String[] data = DmtPathUtils.splitPath(path);
+ if (TextUtils.isEmpty(data[0]) || !isNodeExist(data[0])) {
+ return ErrorCodes.SYNCML_DM_NOT_FOUND;
+ }
+
+ int retcode = createInteriorNode_(path);
+ if (retcode == ErrorCodes.SYNCML_DM_SUCCESS) {
+ mIsUpdated = true;
+ }
+ return retcode;
+ }
+
+ @Override
+ public int createLeafNode(String path, DmtData value) {
+ String[] data = DmtPathUtils.splitPath(path);
+ if (TextUtils.isEmpty(data[0]) || !isNodeExist(data[0])) {
+ return ErrorCodes.SYNCML_DM_NOT_FOUND;
+ }
+
+ int retcode = createLeafNode_(path, value);
+ if (retcode == ErrorCodes.SYNCML_DM_SUCCESS) {
+ mIsUpdated = true;
+ }
+ return retcode;
+ }
+
+ @Override
+ public int updateLeafNode(String path, DmtData newValue) {
+ int retcode = updateLeafNode_(path, newValue);
+ if (retcode == ErrorCodes.SYNCML_DM_SUCCESS) {
+ mIsUpdated = true;
+ }
+ return retcode;
+ }
+
+ @Override
+ public int renameNode(String path, String newName) {
+ return ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION;
+ }
+
+ @Override
+ public int deleteNode(String path) {
+ int retcode = deleteNode_(path);
+ if (retcode == ErrorCodes.SYNCML_DM_SUCCESS) {
+ mIsUpdated = true;
+ }
+ return retcode;
+ }
+
+ @Override
+ public boolean isNodeUpdated() {
+ return mIsUpdated;
+ }
+
+ @Override
+ public void resetUpdated() {
+ mIsUpdated = false;
+ }
+
+ @Override
+ public Map<String, DmtPluginNode> getNodes(String nodePath) throws DmtException {
+ if (!DmtPathUtils.isSubPath(mPath, nodePath)) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_NOT_FOUND,
+ "Cannot get nodes for given path");
+ }
+
+ if (nodePath.equals(mPath)) {
+ return mNodes;
+ }
+
+ Map<String, DmtPluginNode> nodes = new HashMap<String, DmtPluginNode>();
+
+ for (Map.Entry<String, DmtPluginNode> nodeEntry : mNodes.entrySet()) {
+ if (DmtPathUtils.isSubPath(nodePath, nodeEntry.getKey())) {
+ nodes.put(nodeEntry.getKey(), nodeEntry.getValue());
+ }
+ }
+ return nodes;
+ }
+
+ @Override
+ public DmtPluginNode getNode(String nodePath) throws DmtException {
+ DmtPluginNode node = mNodes.get(nodePath);
+ if (node == null) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_NOT_FOUND,
+ "The requested node doesn't exist");
+ }
+ return node;
+ }
+
+ @Override
+ public DmtData getNodeValue(String nodePath) throws DmtException {
+ DmtPluginNode node = mNodes.get(nodePath);
+ if (node == null) {
+ throw new DmtException(ErrorCodes.SYNCML_DM_NOT_FOUND,
+ "The requested node doesn't exist");
+ }
+ return node.getValue();
+ }
+
+ @Override
+ public String getNodePath() {
+ return mPath;
+ }
+
+ /**
+ * Returns the name of the root node.
+ *
+ * @return node name.
+ */
+ public String getNodeName() {
+ return DmtPathUtils.getNodeName(mPath);
+ }
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/DmtPathUtils.java b/engine/javaplugin/api/com/android/omadm/plugin/DmtPathUtils.java
new file mode 100644
index 0000000..fc581fc
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/DmtPathUtils.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+import android.text.TextUtils;
+
+import java.util.Arrays;
+
+public final class DmtPathUtils {
+
+ public static final String ROOTNODE = "__ROOT__";
+
+ private DmtPathUtils() {}
+
+ /**
+ * Checks whether the given path is valid or not.
+ *
+ * @param path full path.
+ * @return true if this is valid path, otherwise false.
+ */
+ public static boolean isValidPath(String path) {
+ return (!TextUtils.isEmpty(path)) && (".".equals(path) || path.startsWith("./"));
+ }
+
+ /**
+ * Parses path and returns name of the end node.
+ *
+ * @param nodePath path to the node.
+ * @return node name or null in bad case.
+ */
+ public static String getNodeName(String nodePath) {
+ String[] data = splitPath(nodePath);
+ return data[1];
+ }
+
+ /**
+ * Parses passed path and returns name of the first node
+ * after root path.
+ *
+ * @param rootPath root path.
+ * @param nodePath full path to the node.
+ * @return name of the node or null in bad case.
+ */
+ public static String getSubNodeName(String rootPath, String nodePath) {
+ if (!isValidPath(rootPath) || !isValidPath(nodePath)) {
+ return null;
+ }
+
+ String prefix = rootPath + '/';
+
+ if (!nodePath.startsWith(prefix)) {
+ return null;
+ }
+
+ int nameEnd = nodePath.indexOf('/', prefix.length());
+ if (nameEnd == -1) {
+ return nodePath.substring(prefix.length());
+ }
+ return nodePath.substring(prefix.length(), nameEnd);
+ }
+
+ /**
+ * Parses path and returns name of the end node and its root path.
+ *
+ * @param nodePath path to the node.
+ * @return root path (String[0]) and name node (String[1]).
+ */
+ public static String[] splitPath(String nodePath) {
+ String[] data = new String[2];
+ Arrays.fill(data, null);
+
+ if (!isValidPath(nodePath)) {
+ return data;
+ }
+
+ int index = nodePath.lastIndexOf('/');
+ if (index == -1) {
+ data[1] = nodePath;
+ return data;
+ }
+
+ if (nodePath.length() == 1) {
+ return data;
+ }
+
+ if (index == 0) {
+ data[1] = nodePath.substring(1);
+ return data;
+ }
+
+ if (index == nodePath.length() - 1) {
+ data[0] = nodePath.substring(0, index);
+ return data;
+ }
+
+ data[0] = nodePath.substring(0, index);
+ data[1] = nodePath.substring(index + 1);
+
+ return data;
+ }
+
+ /**
+ * Checks whether the root path is a part of the node path.
+ *
+ * @param rootPath root path.
+ * @param nodePath path to some node.
+ * @return true if these paths are equal or nodePath starts with rootPath.
+ */
+ public static boolean isSubPath(String rootPath, String nodePath) {
+ if (!isValidPath(rootPath) || !isValidPath(nodePath)) {
+ return false;
+ }
+
+ if (nodePath.equals(rootPath)) {
+ return true;
+ }
+
+ return nodePath.startsWith(rootPath + '/');
+ }
+
+ public static String toRelativePath(String rootPath, String path) {
+ String r = path;
+
+ // deal with the root path of plugin tree
+ if (rootPath.equals(path) || path.isEmpty()) {
+ r = ROOTNODE;
+ }
+ else if (path.startsWith(rootPath)) {
+ r = path.substring(rootPath.length() + 1);
+ }
+// Log.i(TAG, "'" + path + "' -> '" + r + "'");
+ return r;
+ }
+
+ /**
+ * convert to the absolute path
+ */
+ public static String toAbsolutePath(String rootPath, String path) {
+ String a = path;
+ if (path.isEmpty() || path.equals(ROOTNODE)) {
+ a = rootPath;
+ }
+ else if (!path.startsWith(rootPath)) {
+ a = rootPath + '/' + path;
+ }
+// Log.i(TAG, "'" + path + "' -> '" + a + "'");
+ return a;
+ }
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/DmtPluginNode.aidl b/engine/javaplugin/api/com/android/omadm/plugin/DmtPluginNode.aidl
new file mode 100644
index 0000000..a92541d
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/DmtPluginNode.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+parcelable DmtPluginNode;
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/DmtPluginNode.java b/engine/javaplugin/api/com/android/omadm/plugin/DmtPluginNode.java
new file mode 100644
index 0000000..c01e648
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/DmtPluginNode.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+public class DmtPluginNode implements Parcelable {
+ private static final String TAG = "DM_DmtPluginNode";
+
+ private String mPath;
+
+ private DmtData mValue;
+
+ private int mType; // 0 == DmtData.UNDEFINED
+
+ public DmtPluginNode() {
+ }
+
+ public DmtPluginNode(String path, int type) {
+ mPath = path;
+ mType = type;
+ mValue = null;
+ }
+
+ public DmtPluginNode(String path, DmtData value) {
+ mPath = path;
+ setValue(value);
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public DmtData getValue() {
+ if (mValue == null) {
+ mValue = new DmtData("xxxyyyzz");
+ }
+ return mValue;
+ }
+
+ public void setValue(DmtData value) {
+ if (value != null) {
+ int oldType = mType;
+ int newType = value.getType();
+ if (oldType == DmtData.UNDEFINED || newType == DmtData.NULL || oldType == newType) {
+ mValue = value;
+ mType = newType;
+ }
+ }
+ }
+
+ public boolean isLeaf() {
+ return (mType != DmtData.NODE);
+ }
+
+ public int getType() {
+ return mType;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mPath);
+ dest.writeInt(mType);
+ if (mValue != null) {
+ dest.writeString(mValue.getString());
+ }
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public static final Creator<DmtPluginNode> CREATOR = new Creator<DmtPluginNode>() {
+ @Override
+ public DmtPluginNode createFromParcel(Parcel source) {
+ return new DmtPluginNode(source);
+ }
+
+ @Override
+ public DmtPluginNode[] newArray(int size) {
+ return new DmtPluginNode[size];
+ }
+ };
+
+ DmtPluginNode(Parcel in) {
+ mPath = in.readString();
+ mType = in.readInt();
+ if (mType <= DmtData.NULL || mType > DmtData.NODE) {
+ if (mType != DmtData.NULL) {
+ mType = DmtData.UNDEFINED;
+ }
+ mValue = null;
+ } else {
+ try {
+ String tmpValue = in.readString();
+ mValue = null;
+ if (tmpValue != null) {
+ mValue = new DmtData(tmpValue, mType);
+ }
+ } catch (RuntimeException e) {
+ Log.e(TAG, "caught RuntimeException", e);
+ mValue = null;
+ }
+ }
+ }
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/ErrorCodes.java b/engine/javaplugin/api/com/android/omadm/plugin/ErrorCodes.java
new file mode 100644
index 0000000..6e2cf2f
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/ErrorCodes.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+public interface ErrorCodes {
+
+ /** Success. */
+ int SYNCML_DM_SUCCESS = 0;
+
+ /** Unknown error (EXT). */
+ int SYNCML_DM_FAIL = 1;
+
+ /** Entry for tree mount point or transport already exists in the registry (EXT). */
+ int SYNCML_DM_ENTRY_EXIST = 2;
+
+ /** Entry for tree mount point or transport not found in the registry (EXT). */
+ int SYNCML_DM_ENTRY_NOT_FOUND = 3;
+
+ /** Another session is in progress (EXT). */
+ int SYNCML_DM_SESSION_BUSY = 4;
+
+ /** URI is invalid (EXT). */
+ int SYNCML_DM_INVALID_URI = 5;
+
+ /** Session authentication failed. */
+ int SYNCML_DM_SESSION_AUTH_FAIL = 6;
+
+ /** Second connection is not available (EXT). */
+ int SYNCML_DM_SESSION_NW_NOT_AVAILABLE = 7;
+
+ /** Session not connected. */
+ int SYNCML_DM_SESSION_NOT_CONNECTED = 8;
+
+ /** Session canceled. */
+ int SYNCML_DM_SESSION_CANCELED = 9;
+
+ /** File operation failure (EXT). */
+ int SYNCML_DM_IO_FAILURE = 10;
+
+ /** File not found (EXT). */
+ int SYNCML_DM_FILE_NOT_FOUND = 11;
+
+ /** URI is too long (EXT). */
+ int SYNCML_DM_URI_CONFLICT = 12;
+
+ /** Tree file is corrupted (EXT). */
+ int SYNCML_DM_TREE_CORRUPT = 13;
+
+ /** Internal error (EXT). */
+ int SYNCML_DM_SKIP_SUBTREE = 14;
+
+ /** Result is too large (EXT). */
+ int SYNCML_DM_RESULT_TOO_LARGE = 15;
+
+ /** Lock context is invalid (EXT). */
+ int SYNCML_DM_LOCK_CONTEXT_NOT_FOUND = 16;
+
+ /** Unable to create thread (EXT). */
+ int SYNCML_DM_UNABLE_START_THREAD = 17;
+
+ /** Too many data files: invalid configuration (EXT). */
+ int SYNCML_DM_TOO_MANY_DATA_FILES = 18;
+
+ /** File is locked; try again later (EXT). */
+ int SYNCML_DM_LOCK_TRY_AGAIN = 19;
+
+ /** Constraint failed (EXT). */
+ int SYNCML_DM_CONSTRAINT_FAILED = 20;
+
+ /** Unable to load Access Control List file (EXT). */
+ int SYNCML_DM_LOAD_ACL_FILE_FAILED = 21;
+
+ /** Tree is read-only (EXT). */
+ int SYNCML_DM_READ_ONLY_TREE = 22;
+
+ /** At least one of the parameters is invalid (EXT). */
+ int SYNCML_DM_INVALID_PARAMETER = 23;
+
+ /** LAWMO exec status code to the server. */
+ int SYNCML_DM_ACCEPTED_FOR_PROCESSING = 202;
+
+ /** Authentication accepted. */
+ int SYNCML_DM_AUTHENTICATION_ACCEPTED = 212;
+
+ /** Chunked item accepted and buffered. */
+ int SYNCML_DM_CHUNK_BUFFERED = 213;
+
+ /** Operation canceled. */
+ int SYNCML_DM_OPERATION_CANCELED = 214;
+
+ /** DM engine not executed. TODO: remove if unused. */
+ int SYNCML_DM_NOT_EXECUTED = 215;
+
+ /** Atomic rollback success. TODO: remove if unused. */
+ int SYNCML_DM_ATOMIC_ROLLBACK_SUCCESS = 216;
+
+ /** DM tree not modified. */
+ int SYNCML_DM_TREE_NOT_MODIFIED = 304;
+
+ /** Bad request. */
+ int SYNCML_DM_BAD_REQUEST = 400;
+
+ /** Unauthorized access. */
+ int SYNCML_DM_UNAUTHORIZED = 401;
+
+ /** Not found. */
+ int SYNCML_DM_NOT_FOUND = 404;
+
+ /** Command not allowed. */
+ int SYNCML_DM_COMMAND_NOT_ALLOWED = 405;
+
+ /** Requested operation not supported. */
+ int SYNCML_DM_UNSUPPORTED_OPERATION = 406;
+
+ /** Authentication required. */
+ int SYNCML_DM_AUTHENTICATION_REQUIRED = 407;
+
+ /** Request timeout. */
+ int SYNCML_DM_REQUEST_TIMEOUT = 408;
+
+ /** Incomplete command. */
+ int SYNCML_DM_INCOMPLETE_COMMAND = 412;
+
+ /** Request entity too large. */
+ int SYNCML_DM_REQUEST_ENTITY_TOO_LARGE = 413;
+
+ /** URI too long. */
+ int SYNCML_DM_URI_TOO_LONG = 414;
+
+ /** Unsupported media type format. TODO: remove if unused. */
+ int SYNCML_DM_UNSUPPORTED_MEDIA_TYPE_FORMAT = 415;
+
+ /** Request range not found. TODO: remove if unused. */
+ int SYNCML_DM_REQUESTED_RANGE_NOT_FOUND = 416;
+
+ /** The target already exists. */
+ int SYNCML_DM_TARGET_ALREADY_EXISTS = 418;
+
+ /** The device storage is full. */
+ int SYNCML_DM_DEVICE_FULL = 420;
+
+ /** Size mismatch. */
+ int SYNCML_DM_SIZE_MISMATCH = 424;
+
+ /** Permission verification failed. */
+ int SYNCML_DM_PERMISSION_FAILED = 425;
+
+ /** Command failed. */
+ int SYNCML_DM_COMMAND_FAILED = 500;
+
+ /** Command not implemented. */
+ int SYNCML_DM_COMMAND_NOT_IMPLEMENTED = 501;
+
+ /** Processing error. */
+ int SYNCML_DM_PROCESSING_ERROR = 506;
+
+ /** Atomic failed. TODO: remove if unused. */
+ int SYNCML_DM_ATOMIC_FAILED = 507;
+
+ /** Data store failure. */
+ int SYNCML_DM_DATA_STORE_FAILURE = 510;
+
+ /** Operation canceled failure. TODO: remove if unused. */
+ int SYNCML_DM_OPERATION_CANCELED_FAILURE = 514;
+
+ /** Atomic rollback failed. */
+ int SYNCML_DM_ATOMIC_ROLLBACK_FAILED = 516;
+
+ /** Atomic response too large. */
+ int SYNCML_DM_ATOMIC_RESPONSE_TOO_LARGE = 517;
+
+ /** Data set not complete for an ESN. TODO: remove if unused. */
+ int SYNCML_DM_ESN_SET_NOT_COMPLETE = 518;
+
+ /** Socket timeout error. TODO: remove if unused. */
+ int SYNCML_DM_SOCKET_TIMEOUT = 700;
+
+ /** Socket connect error. TODO: remove if unused. */
+ int SYNCML_DM_SOCKET_CONNECT_ERROR = 701;
+
+ /** Factory Data Reset result code. TODO: remove if unused. */
+ int SYNCML_DM_PROCESS_ACCEPTED = 1200;
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/IDMClientService.aidl b/engine/javaplugin/api/com/android/omadm/plugin/IDMClientService.aidl
new file mode 100644
index 0000000..a4c730c
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/IDMClientService.aidl
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.DmtPluginNode;
+
+interface IDMClientService
+{
+ /**
+ * Gets DM tree node value by specified path.
+ *
+ * If DM tree doesn't contain the value, null value shall be returned by
+ * the method and DM engine will use the getOperationResult() method
+ * to get result of the operation.
+ *
+ * @param path full path to the node.
+ * @param recursive whether to return the child nodes recursively.
+ * @return node value object in success case, otherwise null.
+ */
+ DmtData getDMTree(String path, boolean recursive);
+
+ /**
+ * Starts a client session for the specified server ID.
+ *
+ * @param path full path to the node.
+ * @param clientCert URI of the client cert to use, or null
+ * @param privateKey private key to use, or null
+ * @param alertType the alert 1226 command
+ * @param redirectURI the redirect URI
+ * @param username the username for digest authentication, or null
+ * @param password the password for digest authentication, or null
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int startClientSession(String path, String clientCert, String privateKey,
+ String alertType, String redirectURI, String username, String password);
+
+ /**
+ * Notifies that the exec callback operation completed.
+ * @param path the path for the exec call
+ */
+ int notifyExecFinished(String path);
+
+ /**
+ * Inject the specified SOAP-XML package into the DM tree.
+ *
+ * @param path node path
+ * @param command the command to pass
+ * @param payload the SyncML payload to process
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int injectSoapPackage(String path, String command, String payload);
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/IDmtPlugin.aidl b/engine/javaplugin/api/com/android/omadm/plugin/IDmtPlugin.aidl
new file mode 100644
index 0000000..4469204
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/IDmtPlugin.aidl
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.DmtPluginNode;
+
+interface IDmtPlugin
+{
+ /**
+ * Initializes the plug-in.
+ *
+ * @param rootPath the root path of the plug-in.
+ * @param parameters initial parameters of the plug-in. Type of the parameter is Map<String, String> type.
+ * @return true in success case, otherwise false.
+ */
+ boolean init(String rootPath, in Map parameters);
+
+ /**
+ * This method returns result of the last operation which has requested by DM engine.
+ * It is required because each plug-in is a content provider and it is impossible to
+ * throw the DmtException with an error code to the DM engine.
+ *
+ * @return operation result of the last operation.
+ */
+ int getOperationResult();
+
+ /**
+ * Sets Server ID of the plug-in.
+ *
+ * @param serverID service ID
+ */
+ void setServerID(String serverID);
+
+ /**
+ * Returns Server ID.
+ *
+ * @return Server ID which has been set by DM engine for the plug-in.
+ */
+ String getServerID();
+
+ /**
+ * The method is called to release plug-in resource when the plug-in is no longer used.
+ *
+ * @return true in success case, otherwise false.
+ */
+ boolean release();
+
+ /**
+ * Gets node by given path.
+ *
+ * If plug-in cannot return the node null value shall be returned by
+ * the method and DM engine will use the getOperationResult() method
+ * to get result of the operation.
+ *
+ * @param path full path to the node.
+ * @return node object in success case, otherwise null.
+ */
+ DmtPluginNode getNode(String path);
+
+ /**
+ * Gets node value by given path.
+ *
+ * If plug-in cannot return the value null value shall be returned by
+ * the method and DM engine will use the getOperationResult() method
+ * to get result of the operation.
+ *
+ * @param path full path to the node.
+ * @return node value object in success case, otherwise null.
+ */
+ DmtData getNodeValue(String path);
+
+ /**
+ * Gets a set of nodes by given path.
+ *
+ * If plug-in cannot return the set null value shall be returned by
+ * the method and DM engine will use the getOperationResult() method
+ * to get result of the operation.
+ *
+ * @param path full path to the node.
+ * @return a set of nodes in success case otherwise null.
+ * Type of returned value shall be Map<String, DmtPluginNode>.
+ * Where the first parameter is full path to the node and the
+ * second is node object.
+ */
+ Map getNodes(String path);
+
+ /**
+ * Creates an interior node in the tree by given path.
+ *
+ * @param path full path to the node.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int createInteriorNode(String path);
+
+ /**
+ * Creates a leaf node in the tree by given path.
+ *
+ * @param path full path to the node.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int createLeafNode(String path, in DmtData value);
+
+ /**
+ * Creates a sibling of the node specified by its URI "path".
+ * This new node's name is user-specified as "newNodename".
+ * An error shall be returned in following cases:
+ * - If either path or new node name are null
+ * - If node to be copied does not exist
+ * - If a sibling node with the user-specified name already exists
+ * - If the new node cannot be created for some other reason
+ *
+ * NOTE: This is optional command of OMA DM protocol.
+ * Currently java plug-ins do not support the command.
+ *
+ * @param path full path to node to be cloned.
+ * @param newNodename New node name as specified by user.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int clone(String path, String newNodename);
+
+ /**
+ * Renames a node.
+ *
+ * NOTE: This is optional command of OMA DM protocol.
+ * Currently java plug-ins do not support the command.
+ *
+ * @param path full path to node to be renamed.
+ * @param newName new node name.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int renameNode(String path, String newName);
+
+ /**
+ * Updates a leaf node value by given path.
+ *
+ * @param path full path to the leaf node.
+ * @param newValue new value of the leaf node.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int updateLeafNode(String path, in DmtData newValue);
+
+ /**
+ * Deletes a node by given path.
+ * @param path full path to the leaf node.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int deleteNode(String path);
+
+ /**
+ * Performs "Execute" command on a plug-in node.
+ *
+ * @param path node path
+ * @param args exec plug-in arguments
+ * @param correlator correlator
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int exec(String path, String args, String correlator);
+
+ /**
+ * Performs commit operation under current DMT.
+ *
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case, otherwise an error.
+ */
+ int commit();
+
+ /**
+ * Returns DM account server PW. This is not lookup from the DM tree; this function generates it.
+ *
+ * @return String. null if plugin is not carrier specific
+ */
+ String getServerPW(String aiServerPW);
+
+ /**
+ * Returns DM account client PW. This is not lookup from the DM tree; this function generates it.
+ *
+ * @return String. null if plugin is not carrier specific
+ */
+ String getClientPW(String aiClientPW);
+
+ /**
+ * Returns DM account user name. This is not lookup from the DM tree; this function generates it.
+ *
+ * @return String. null if plugin is not carrier specific
+ */
+ String getUsername(String aiUsername);
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/IDmtRootPlugin.java b/engine/javaplugin/api/com/android/omadm/plugin/IDmtRootPlugin.java
new file mode 100644
index 0000000..a3a6650
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/IDmtRootPlugin.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+public interface IDmtRootPlugin extends IDmtSubTree {
+
+ /**
+ * Returns a management object specified by path.
+ *
+ * @param path path to the management object.
+ * @return object in success case, otherwise null.
+ */
+ DmtManagementObject getManagementObject(String path);
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/IDmtSubTree.java b/engine/javaplugin/api/com/android/omadm/plugin/IDmtSubTree.java
new file mode 100644
index 0000000..60c6227
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/IDmtSubTree.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin;
+
+import java.util.Map;
+
+public interface IDmtSubTree {
+
+ interface Creator<T> {
+
+ /**
+ * This method shall be called when a new instance of
+ * subtree is created by a component.
+ * (FIXME comment: For example com.android.omadm.plugin.DmtMultiNode class)
+ *
+ * @param path path to the new node.
+ * @param pluginRoot object of the plug-in.
+ * @return subtree object.
+ */
+ T createFromPath(String path, IDmtRootPlugin pluginRoot);
+ }
+
+ /**
+ * Returns a node specified by path.
+ *
+ * @param path full path to the node.
+ * @throws DmtException if the node is not present.
+ * @return the node object.
+ */
+ DmtPluginNode getNode(String path) throws DmtException;
+
+ /**
+ * Returns a node value specified by path.
+ *
+ * @param path full path to the node.
+ * @throws DmtException if the node is not present.
+ * @return the node value object.
+ */
+ DmtData getNodeValue(String path) throws DmtException;
+
+ /**
+ * Returns a set of nodes specified by path.
+ *
+ * @param rootPath full path to the node.
+ * @throws DmtException if the node is not present.
+ * @return the map of paths and node objects.
+ */
+ Map<String, DmtPluginNode> getNodes(String rootPath) throws DmtException;
+
+ /**
+ * Creates an interior node in the tree.
+ *
+ * @param path full path to the new node.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case otherwise an error.
+ */
+ int createInteriorNode(String path);
+
+ /**
+ * Creates a leaf node in the tree.
+ *
+ * @param path full path to the node.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case otherwise an error.
+ */
+ int createLeafNode(String path, DmtData value);
+
+ /**
+ * Renames a node which has PlaceHolder type.
+ *
+ * @param path full path to the node.
+ * @param newName new node name.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case otherwise an error.
+ */
+ int renameNode(String path, String newName);
+
+ /**
+ * Updates a leaf node value.
+ *
+ * @param path full path to the leaf node.
+ * @param newValue new value of the leaf node.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case otherwise an error.
+ */
+ int updateLeafNode(String path, DmtData newValue);
+
+ /**
+ * Deletes a node specified by path.
+ *
+ * @param path full path to the leaf node.
+ * @return ErrorCodes.SYNCML_DM_SUCCESS in success case otherwise an error.
+ */
+ int deleteNode(String path);
+
+ /**
+ * Checks if the current node or its sub nodes were updated.
+ *
+ * @return true in updated case, otherwise false.
+ */
+ boolean isNodeUpdated();
+
+ /**
+ * Resets updated flag.
+ */
+ void resetUpdated();
+
+ /**
+ * Returns the node path.
+ *
+ * @return node path.
+ */
+ String getNodePath();
+}
diff --git a/engine/javaplugin/api/com/android/omadm/plugin/impl/DmtPluginManager.java b/engine/javaplugin/api/com/android/omadm/plugin/impl/DmtPluginManager.java
new file mode 100644
index 0000000..f8cedad
--- /dev/null
+++ b/engine/javaplugin/api/com/android/omadm/plugin/impl/DmtPluginManager.java
@@ -0,0 +1,682 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin.impl;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.content.pm.ResolveInfo;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.DmtException;
+import com.android.omadm.plugin.DmtPluginNode;
+import com.android.omadm.plugin.ErrorCodes;
+import com.android.omadm.plugin.IDmtPlugin;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class does not manage DMT plugins. It is a proxy between native plugin and java plugins.
+ * An instance of the class is created for each plugin.
+ */
+public final class DmtPluginManager {
+
+ private static final String TAG = "DM_DmtPluginManager";
+ private static final boolean DBG = false;
+
+ private static Context sContext;
+
+ /* Parameters of the plug-in */
+ private String mPath;
+ private String mUid;
+ private String mServerID; // FIXME: mServerID is never set, remove?
+ private Map<String, String> mParameters;
+
+ private final class DmtServiceConnection implements ServiceConnection {
+
+ DmtServiceConnection() {
+ }
+
+ @Override
+ public synchronized void onServiceConnected(ComponentName className, IBinder service) {
+ logd("Enter onServiceConnected...");
+ logd("Class:" + className + " service:" + service);
+
+ mPluginConnection = IDmtPlugin.Stub.asInterface(service);
+
+ try {
+ notifyAll();
+ } catch (Exception e) {
+ loge("onServiceConnected(): exception", e);
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName className) {
+ logd("Plug-in service disconnected. className:" + className);
+ mPluginConnection = null;
+ }
+
+ public synchronized void waitForConnection() {
+ try {
+ Intent intent = new Intent(mUid);
+ intent.putExtra("rootPath", mPath);
+ boolean currentPackageMatch = false;
+ List<ResolveInfo> intentServices = sContext.getPackageManager()
+ .queryIntentServices(intent, 0);
+ if (intentServices != null) {
+ for (ResolveInfo resolveInfo : intentServices) {
+ logd("getPackageName is: " + sContext.getPackageName());
+ logd("resolveInfo.serviceInfo.packageName is: "
+ + resolveInfo.serviceInfo.packageName);
+ if(resolveInfo.serviceInfo.packageName.equals(sContext.getPackageName())) {
+ try {
+ Class.forName(mUid);
+ } catch (ClassNotFoundException e1) {
+ loge("ClassNotFoundException in waitForConnection", e1);
+ currentPackageMatch = true;
+ }
+ }
+ }
+ }
+
+ if (currentPackageMatch) {
+ return;
+ }
+
+ if (DBG) logd("Calling bindService: uid=\"" + mUid + "\" path=\"" + mPath + '"');
+ sContext.bindService(intent, mConnector,Context.BIND_AUTO_CREATE);
+
+ wait(10000); // FIXME: wait not in loop!
+ if (DBG) logd("Waiting is finished");
+ } catch (Exception e) {
+ loge("exception in waitForConnection", e);
+ }
+ }
+ }
+
+ private final DmtServiceConnection mConnector = new DmtServiceConnection();
+
+ private IDmtPlugin mPluginConnection;
+
+ public DmtPluginManager() {
+ logd("DmtPluginManager.java constructor...");
+ }
+
+ public static void setContext(Context context) {
+ if (DBG) logd("Enter setContext(" + context + ')');
+
+ if (context == null) {
+ logd("Context is null!");
+ return;
+ }
+
+ Context appContext = context.getApplicationContext();
+
+ if (DBG) logd("app context is: " + appContext);
+
+ sContext = appContext;
+ }
+
+ /**
+ * Initialize Java plugin. Called from JNI in:
+ * engine/javaplugin/nativelib/src/DmtJavaPluginManager.cc
+ *
+ * @param path the root path of the plug-in.
+ * @param parameters initial parameters of the plug-in, as an array of strings.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success, error code on failure.
+ */
+ public boolean initJavaPlugin(String path, String[] parameters) {
+ if (DBG) logd("Enter initJavaPlugin: path = " + path);
+ if (DBG) logd("parameters are: " + Arrays.toString(parameters));
+
+ if (TextUtils.isEmpty(path)) {
+ loge("Invalid path!....");
+ return false;
+ }
+
+ if (mPath != null) {
+ loge("Plugin already loaded!....");
+ return false;
+ }
+
+ if (DBG) logd("Parameters count is " + parameters.length);
+ if (parameters.length % 2 != 0) {
+ loge("Parameter count is not right.");
+ return false;
+ }
+
+ // FIXME: replace HashTable with HashMap
+ Map<String, String> params = new HashMap<String, String>();
+ for (int i = 0; i < parameters.length; i += 2 ) {
+ params.put(parameters[i], parameters[i + 1]);
+
+ if ("_uid".equals(parameters[i])) {
+ mUid = parameters[i + 1];
+ }
+ }
+
+ if (TextUtils.isEmpty(mUid)) {
+ loge("uid is empty...");
+ return false;
+ }
+
+ mParameters = params;
+ mPath = path;
+
+ return bindPluginService();
+ }
+
+ /**
+ * Performs "Execute" command on a plug-in node.
+ * Called from JNI.
+ *
+ * @param args exec plug-in arguments.
+ * @param correlator correlator.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success, error code on failure.
+ */
+ public int executeNode(String args, String correlator) {
+ if (DBG) logd("Enter executeNode(\"" + args + "\", \"" + correlator + "\")");
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ try {
+ return mPluginConnection.exec(mPath, args, correlator);
+ } catch (Exception e) {
+ loge("Exception in executeNode", e);
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+ }
+
+ /**
+ * Performs commit operation under current DMT.
+ * Called from JNI.
+ *
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success, error code on failure.
+ */
+ public int commit() {
+ loge("Enter commit... " + mPath);
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ try {
+ return mPluginConnection.commit();
+ } catch (Exception e) {
+ loge("Exception in commit", e);
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+ }
+
+ /**
+ * Sets Server ID of the plug-in.
+ * Called from JNI.
+ *
+ * @param serverID service ID.
+ */
+ public void setServerID(String serverID) {
+ if (DBG) logd("Enter setServerID(\"" + serverID + "\")");
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ return;
+ }
+
+ try {
+ mPluginConnection.setServerID(serverID);
+ } catch (Exception e) {
+ loge("Exception in setServerID", e);
+ }
+ }
+
+ /**
+ * Creates an interior node in the tree for the specified path.
+ * Called from JNI.
+ *
+ * @param path full path to the node.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success, error code on failure.
+ */
+ public int createInteriorNode(String path) {
+ if (DBG) logd("Enter createInteriorNode(\"" + path + "\")");
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ try {
+ return mPluginConnection.createInteriorNode(getFullPath(path));
+ } catch (Exception e) {
+ loge("Exception in createInteriorNode", e);
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+ }
+
+ /**
+ * Creates a leaf node in the tree by given path.
+ * Called from JNI.
+ *
+ * @param path full path to the node.
+ * @param type type of node, defined as constants in {@link DmtData}.
+ * @param value the new value to set.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success, error code on failure.
+ */
+ public int createLeafNode(String path, int type, String value) {
+ if (DBG) logd("Enter createLeafNode(\"" + path + "\", " + type + ", \"" + value + "\")");
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ if (type < DmtData.NULL || type >= DmtData.NODE) {
+ loge("Invalid data type: " + type);
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ DmtData data = new DmtData(value, type);
+
+ try {
+ return mPluginConnection.createLeafNode(getFullPath(path), data);
+ } catch (Exception e) {
+ loge("Exception in createLeafNode", e);
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+ }
+
+ /**
+ * Renames a node.
+ * Called from JNI.
+ *
+ * NOTE: This is an optional command of the OMA DM protocol.
+ * Currently java plug-ins do not support the command.
+ *
+ * @param path full path to node to be renamed.
+ * @param newNodeName new node name.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success, error code on failure.
+ */
+ public int renameNode(String path, String newNodeName) {
+ if (DBG) logd("Enter renameNode(\"" + path + "\", \"" + newNodeName + "\")");
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ if (TextUtils.isEmpty(newNodeName)) {
+ loge("Invalid new node name!");
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ try {
+ return mPluginConnection.renameNode(getFullPath(path), newNodeName);
+ } catch (Exception e) {
+ loge("Exception in renameNode", e);
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+ }
+
+ /**
+ * Deletes a node with the specified path.
+ * Called from JNI.
+ *
+ * @param path full path to the node.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success, error code on failure.
+ */
+ public int deleteNode(String path) {
+ if (DBG) logd("Enter deleteNode(\"" + path + "\")");
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ try {
+ return mPluginConnection.deleteNode(getFullPath(path));
+ } catch (Exception e) {
+ loge("Exception in deleteNode", e);
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+ }
+
+ /**
+ * Set new value for the specified node.
+ * Called from JNI.
+ *
+ * @param path full path to the node.
+ * @param type type of node, defined as constants in {@link DmtData}.
+ * @param value the new value to set.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success, error code on failure.
+ */
+ public int setNodeValue(String path, int type, String value) {
+ if (DBG) logd("Enter setNodeValue(\"" + path + "\", " + type + ", \"" + value + "\")");
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ if (type < DmtData.NULL || type >= DmtData.NODE) {
+ loge("Invalid data type: " + type);
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+
+ DmtData data = new DmtData(value, type);
+
+ try {
+ logd("Update leaf node: path = " + path + ", data = " + data.getString());
+ return mPluginConnection.updateLeafNode(getFullPath(path), data);
+ } catch (Exception e) {
+ loge("Exception in setNodeValue", e);
+ return ErrorCodes.SYNCML_DM_FAIL;
+ }
+ }
+
+ /**
+ * Returns value of leaf node for the specified path.
+ * Called from JNI.
+ *
+ * @param path path to the leaf node.
+ * @return String array where the first element is value type and the second is the value.
+ * @throws DmtException in case of error.
+ */
+ public String[] getNodeValue(String path) throws DmtException {
+ if (DBG) logd("Enter getNodeValue(\"" + path + "\")");
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ throw new DmtException("There is no bound plug-in");
+ }
+
+ DmtData data;
+ try {
+ data = mPluginConnection.getNodeValue(getFullPath(path));
+ } catch (Exception e) {
+ loge("Exception in getNodeValue", e);
+ throw new DmtException(e.getMessage());
+ }
+
+ if (data == null) {
+ int retcode;
+ try {
+ retcode = mPluginConnection.getOperationResult();
+ } catch (Exception e) {
+ loge("Exception in getNodeValue", e);
+ throw new DmtException(e.getMessage());
+ }
+
+ if (retcode == ErrorCodes.SYNCML_DM_SUCCESS) {
+ loge("Invalid plug-in implementation!");
+ throw new DmtException("Invalid plug-in implementation!");
+ }
+ /*
+ * Added this block to return Error code to DM Engine since
+ * throwing an exception is causing a VM error and aborting
+ * the app.
+ */
+ else if (retcode == ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION) {
+ loge("Get feature not implemented on this node");
+ String[] errString = new String[1];
+ errString[0] = Integer.toString(retcode);
+ return errString;
+ }
+
+ else {
+ loge("Error occurred while doing a get on this node");
+ String[] errString = new String[1];
+ errString[0] = Integer.toString(retcode);
+ return errString;
+ }
+
+ //throw new DmtException(retcode, "Value is not set");
+ }
+
+ int dataType = data.getType();
+
+ switch (dataType) {
+ case DmtData.NULL:
+ case DmtData.STRING:
+ case DmtData.INT:
+ case DmtData.BOOL:
+ case DmtData.BIN:
+ case DmtData.DATE:
+ case DmtData.TIME:
+ case DmtData.FLOAT:
+ String value = data.getString();
+ String[] resStrArr = new String[2];
+ resStrArr[0] = Integer.toString(dataType);
+ resStrArr[1] = TextUtils.isEmpty(value) ? "" : value;
+ return resStrArr;
+
+ case DmtData.NODE:
+ throw new DmtException("Operation not allowed for interior node!");
+
+ default:
+ throw new DmtException("Invalid node type");
+ }
+ }
+
+ /**
+ * Gets a set of nodes for the specified path.
+ * Called from JNI.
+ *
+ * If the plug-in cannot return the set, null value shall be returned by
+ * the method and DM engine will use the getOperationResult() method
+ * to get result of the operation.
+ *
+ * @return a String array containing triples of (key, type, value) as Strings
+ * @throws DmtException on any exception
+ */
+ public String[] getNodes() throws DmtException {
+ if (DBG) logd("Enter getNodes...");
+
+ if (mPluginConnection == null) {
+ loge("There is no bound plug-in");
+ throw new DmtException("There is no bound plug-in");
+ }
+
+ Map<String, DmtPluginNode> pluginNodes;
+ try {
+ pluginNodes = (Map<String, DmtPluginNode>) mPluginConnection.getNodes(mPath);
+ } catch (RemoteException e) {
+ loge("RemoteException in getNodes", e);
+ throw new DmtException(e.getMessage());
+ }
+
+ if (pluginNodes == null) {
+ int retcode;
+ try {
+ retcode = mPluginConnection.getOperationResult();
+ } catch (Exception e) {
+ loge("Exception in getNodes", e);
+ throw new DmtException(e.getMessage());
+ }
+
+ if (retcode == ErrorCodes.SYNCML_DM_SUCCESS) {
+ loge("Invalid plug-in implementation!");
+ throw new DmtException("Invalid plug-in implementation!");
+ }
+
+ throw new DmtException(retcode, "Value is not set");
+ }
+
+ if (pluginNodes.isEmpty()) {
+ // FIXME: zero-length array constructed
+ return new String[0];
+ }
+
+ if (DBG) logd("Data plugin has " + pluginNodes.size() + " nodes.");
+ String[] resStrArr = new String[pluginNodes.size() * 3];
+
+ int i = 0;
+ for (String key : pluginNodes.keySet()) {
+ if (DBG) logd("No." + i + " : " + key);
+ DmtPluginNode tmpNode = pluginNodes.get(key);
+ if (tmpNode == null) {
+ throw new DmtException("Invalid map of all nodes");
+ }
+ resStrArr[i] = getRelativePath(key);
+ resStrArr[i + 1] = Integer.toString(tmpNode.getType());
+ switch (tmpNode.getType()) {
+ case DmtData.NODE:
+ StringBuilder tmpSB = new StringBuilder("");
+ DmtData data = tmpNode.getValue();
+ if (data != null) {
+ Map<String, DmtData> childNodes = data.getChildNodeMap();
+ for (String subNodeName : childNodes.keySet()) {
+ if (TextUtils.isEmpty(subNodeName)) {
+ loge("invalid interior node value for " + subNodeName + "!!!");
+ throw new DmtException("Invalid interior node value");
+ } else {
+ tmpSB.append(subNodeName).append('\n');
+ }
+ }
+ }
+ resStrArr[i + 2] = tmpSB.toString();
+ break;
+
+ case DmtData.NULL:
+ case DmtData.STRING:
+ case DmtData.INT:
+ case DmtData.BOOL:
+ case DmtData.BIN:
+ case DmtData.DATE:
+ case DmtData.TIME:
+ case DmtData.FLOAT:
+ resStrArr[i + 2] = "";
+ break;
+
+ default:
+ loge("invalid node type " + tmpNode.getType() + "!!!!");
+ throw new DmtException("Invalid node type");
+ }
+ i += 3;
+ }
+ return resStrArr;
+ }
+
+ public void release() {
+ if (DBG) logd("Enter release... " + mPath);
+
+ if (mPluginConnection == null) {
+ return;
+ }
+
+ try {
+ mPluginConnection.release();
+ } catch (Exception e) {
+ loge("exception releasing plugin", e);
+ }
+
+ mPluginConnection = null;
+
+ try {
+ sContext.unbindService(mConnector);
+ } catch (Exception e) {
+ loge("unbindService exception in release", e);
+ }
+ }
+
+ private boolean bindPluginService() {
+ if (DBG) logd("Enter bindPluginService...");
+
+ if (sContext == null) {
+ loge("Undefined context!");
+ return false;
+ }
+
+ if (mPluginConnection != null) {
+ loge("Already bound!");
+ return true;
+ }
+
+ try {
+ logd("uid = " + mUid);
+ logd("rootPath = " + mPath);
+
+ mConnector.waitForConnection();
+
+ if (mPluginConnection == null) {
+ loge("Impossible to bind to plug-in!...");
+ sContext.unbindService(mConnector);
+ return false;
+ }
+
+ if (DBG) logd("context = " + sContext.toString());
+
+ // FIXME: mServerID is never set, remove this?
+ if (mServerID != null) {
+ mPluginConnection.setServerID(mServerID);
+ }
+
+ return mPluginConnection.init(mPath, mParameters);
+ } catch (Exception e) {
+ loge("bindPluginService: Unable to get service " + mUid, e);
+ return false;
+ }
+ }
+
+ private String getRelativePath(String path) {
+ if (TextUtils.isEmpty(path) || path.equals(mPath)) {
+ return "";
+ }
+
+ if (path.startsWith(mPath + '/')) {
+ return path.substring(mPath.length() + 1);
+ }
+
+ return path;
+ }
+
+ private String getFullPath(String path) {
+ if (TextUtils.isEmpty(path)) {
+ return mPath;
+ }
+
+ if (path.startsWith("./")) {
+ return path;
+ }
+
+ return mPath + '/' + path;
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+
+ private static void loge(String msg) {
+ Log.e(TAG, msg);
+ }
+
+ private static void loge(String msg, Throwable tr) {
+ Log.e(TAG, msg, tr);
+ }
+}
diff --git a/engine/javaplugin/nativelib/Android.mk b/engine/javaplugin/nativelib/Android.mk
new file mode 100644
index 0000000..251c75d
--- /dev/null
+++ b/engine/javaplugin/nativelib/Android.mk
@@ -0,0 +1,59 @@
+# Copyright 2007-2008 The Android Open Source Project
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+# DM plugin source files
+DM_PLUGIN_SRC_FILES := \
+ src/DmtJavaPlugin.cc \
+ src/DmtJavaPluginManager.cc \
+ src/DmtJavaPluginTree.cc \
+ src/DmtJavaPluginNode.cc
+
+#javaplugin.h
+#javapluginmgr.h
+
+DM_PLUGIN_INCLUDES := \
+ $(LOCAL_PATH)/../../dmlib/api/common \
+ $(LOCAL_PATH)/../../dmlib/api/native \
+ $(LOCAL_PATH)/../../dmlib/api/native/plugin \
+ $(LOCAL_PATH)/../../xpl/hdr \
+ $(JNI_H_INCLUDE)
+
+############################################
+# DM source files
+LOCAL_SRC_FILES += $(DM_PLUGIN_SRC_FILES)
+
+
+############################################
+# DM unittest include files
+LOCAL_C_INCLUDES += $(DM_PLUGIN_INCLUDES)
+
+############################################
+# general DM flags
+DM_CFLAGS := \
+-DLOB_SUPPORT
+
+# compile flags
+LOCAL_CFLAGS += $(DM_CFLAGS)
+
+LOCAL_SHARED_LIBRARIES += \
+ liblog \
+ libdmengine \
+ libandroid_runtime \
+ libnativehelper
+
+LOCAL_MODULE := libdmjavaplugin
+LOCAL_PRELINK_MODULE := false
+#TARGET_BUILD_TYPE=debug
+LOCAL_STRIP_MODULE=false
+
+LOCAL_CPP_EXTENSION := .cc
+
+LOCAL_MULTILIB := 32
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/engine/javaplugin/nativelib/src/DmtJavaItem.h b/engine/javaplugin/nativelib/src/DmtJavaItem.h
new file mode 100644
index 0000000..91e79e8
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaItem.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTJAVAITEM_H__
+#define __DMTJAVAITEM_H__
+
+#include "jni.h"
+
+#include <stdlib.h>
+
+#if defined (__cplusplus)
+
+template <class T> class DmtJavaItem
+{
+public:
+ DmtJavaItem(JNIEnv*& env) : mEnv(env), mItem(NULL), mIsGlobalRef(false) {};
+ DmtJavaItem(JNIEnv*& env, T item) : mEnv(env), mItem(item), mIsGlobalRef(false) {};
+ ~DmtJavaItem()
+ {
+ if (mEnv != NULL && mItem != NULL)
+ {
+ if (mIsGlobalRef)
+ {
+ mEnv->DeleteGlobalRef(mItem);
+ }
+ else
+ {
+ mEnv->DeleteLocalRef(mItem);
+ }
+ }
+ }
+
+ void assignValue(jobject obj, JNIEnv*& env)
+ {
+ mEnv = env;
+ mIsGlobalRef = true;
+ mItem = mEnv->NewGlobalRef(obj);
+ }
+
+ T getValue() { return mItem; }
+
+ DmtJavaItem& operator=(const T& item)
+ {
+ mItem = item;
+ return *this;
+ }
+
+ operator T() const { return mItem; }
+
+private:
+ JNIEnv*& mEnv;
+ T mItem;
+ bool mIsGlobalRef;
+};
+
+typedef DmtJavaItem<jobject> DmtJObject;
+typedef DmtJavaItem<jclass> DmtJClass;
+typedef DmtJavaItem<jstring> DmtJString;
+typedef DmtJavaItem<jobjectArray> DmtJObjectArray;
+
+#endif // __cplusplus
+
+#endif // __DMTJAVAITEM_H__
diff --git a/engine/javaplugin/nativelib/src/DmtJavaMethod.h b/engine/javaplugin/nativelib/src/DmtJavaMethod.h
new file mode 100644
index 0000000..3f2f19c
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaMethod.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTJAVAMETHOD_H__
+#define __DMTJAVAMETHOD_H__
+
+#include "jni.h"
+#include "DmtJavaItem.h"
+
+class DmtJavaMethod
+{
+public:
+ DmtJavaMethod(JNIEnv*& env, jobject object, const char* methodName, const char* methodParam)
+ : mEnv(env), mClass(env), mMethodID(NULL)
+ {
+ if (mEnv == NULL || object == NULL || methodName == NULL || methodParam == NULL)
+ {
+ DmtJavaPlugin_Debug("DmtJavaMethod::DmtJavaMethod -> invalid params\n");
+ return;
+ }
+
+ mClass = mEnv->GetObjectClass(object);
+ if (mClass) {
+ mMethodID = mEnv->GetMethodID(mClass, methodName, methodParam);
+ }
+ };
+
+ DmtJavaMethod(JNIEnv*& env, const char* classPath, const char* methodName, const char* methodParam)
+ : mEnv(env), mClass(env), mMethodID(NULL)
+ {
+ if (mEnv == NULL || classPath == NULL || methodName == NULL || methodParam == NULL)
+ {
+ DmtJavaPlugin_Debug("DmtJavaMethod::DmtJavaMethod -> invalid params\n");
+ return;
+ }
+
+ mClass = mEnv->FindClass(classPath);
+ if (mClass) {
+ mMethodID = mEnv->GetMethodID(mClass, methodName, methodParam);
+ }
+ };
+
+ ~DmtJavaMethod() {};
+
+ bool isFound() { return mMethodID != NULL; };
+
+ jmethodID getMethodID() { return mMethodID; }
+ jclass getClass() { return mClass; }
+
+ operator jmethodID() const { return mMethodID; }
+
+private:
+ JNIEnv*& mEnv;
+ DmtJClass mClass;
+ jmethodID mMethodID;
+};
+
+#endif //__DMTJAVAMETHOD_H__
diff --git a/engine/javaplugin/nativelib/src/DmtJavaPlugin.cc b/engine/javaplugin/nativelib/src/DmtJavaPlugin.cc
new file mode 100644
index 0000000..8affe74
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaPlugin.cc
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "plugin/dmtPlugin.hpp"
+#include "DmtJavaPluginTree.h"
+#include "DmtJavaPluginManager.h"
+#include "DmtJavaPluginCommon.h"
+
+// Support exec plugin
+extern "C"
+SYNCML_DM_RET_STATUS_T DMT_PluginLib_Execute2(
+ const char* pPath,
+ DMMap<DMString, DMString>& mapParameters,
+ const char* pArgs,
+ const char* pCorrelator,
+ PDmtTree pTree,
+ DMString& results
+)
+{
+ DmtJavaPlugin_Debug("Enter DMT_PluginLib_Execute2...\n");
+ DmtJavaPlugin_Debug("Plugin path = %s\n", pPath);
+
+ results = "";
+
+ PDmtJavaPluginManager pJavaPluginManager(new DmtJavaPluginManager(pPath, mapParameters));
+ if (pJavaPluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Fail to create DmtJavaPluginManager\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DmtJavaPlugin_Debug("Calling DmtJavaPluginManager::ExecuteNode...\n");
+ SYNCML_DM_RET_STATUS_T retcode = pJavaPluginManager->ExecuteNode(pArgs, pCorrelator, pTree, results);
+ DmtJavaPlugin_Debug("DmtJavaPluginManager::ExecuteNode -> retcode = %d\n", retcode);
+
+ return retcode;
+}
+
+//Support read write data plugin
+extern "C"
+SYNCML_DM_RET_STATUS_T DMT_PluginLib_Data_GetPluginTree(
+ const char* pPath,
+ DMMap<DMString, DMString>& mapParameters,
+ PDmtAPIPluginTree& pPluginTree
+)
+{
+ DmtJavaPlugin_Debug("Enter DMT_PluginLib_Data_GetPluginTree...\n");
+ DmtJavaPlugin_Debug("Plugin path = %s\n", pPath);
+
+ PDmtJavaPluginTree pJavaPluginTree = new DmtJavaPluginTree(pPath, mapParameters);
+ if (pJavaPluginTree == NULL)
+ {
+ DmtJavaPlugin_Debug("Fail to create DmtJavaPluginTree\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DmtJavaPlugin_Debug("Calling DmtJavaPluginTree::BuildPluginTree...\n");
+ SYNCML_DM_RET_STATUS_T retcode = pJavaPluginTree->BuildPluginTree();
+ DmtJavaPlugin_Debug("DmtJavaPluginManager::BuildPluginTree -> retcode = %d\n", retcode);
+
+ pPluginTree = (retcode != SYNCML_DM_SUCCESS ? NULL : pJavaPluginTree);
+
+ return retcode;
+}
+
+extern "C"
+int DMT_PluginLib_GetAPIVersion(void)
+{
+ return DMT_PLUGIN_VERSION_1_1;
+}
diff --git a/engine/javaplugin/nativelib/src/DmtJavaPluginCommon.h b/engine/javaplugin/nativelib/src/DmtJavaPluginCommon.h
new file mode 100644
index 0000000..f4f1c9e
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaPluginCommon.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTJAVAPLUGINCOMMON_H__
+#define __DMTJAVAPLUGINCOMMON_H__
+
+#include "cutils/log.h"
+
+#define DmtJavaPlugin_Debug(args...) ALOGD(args)
+#define DmtJavaPlugin_Error(args...) ALOGE(args)
+#define DmtJavaPlugin_Info(args...) ALOGI(args)
+
+#endif //__DMTJAVAPLUGINCOMMON_H__
diff --git a/engine/javaplugin/nativelib/src/DmtJavaPluginManager.cc b/engine/javaplugin/nativelib/src/DmtJavaPluginManager.cc
new file mode 100644
index 0000000..8fd351d
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaPluginManager.cc
@@ -0,0 +1,615 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "DmtJavaPluginManager.h"
+#include "DmtJavaPluginNode.h"
+#include "DmtJavaPluginCommon.h"
+#include "DmtJavaMethod.h"
+
+#include <android_runtime/AndroidRuntime.h>
+
+#include <stdlib.h>
+
+#define DECLARE_METHOD(method, methodName, methodParam) \
+ DmtJavaMethod method(mEnv, mJavaPluginManager, (methodName), (methodParam)); \
+ if (!method.isFound()) \
+ { \
+ DmtJavaPlugin_Debug("Failed to get %s() method\n", (methodName)); \
+ return SYNCML_DM_FAIL; \
+ }
+
+#define DECLARE_STRING(obj, str) \
+ DmtJString obj(mEnv, mEnv->NewStringUTF(str)); \
+ if (!obj) \
+ { \
+ DmtJavaPlugin_Debug("Failed to create jstring %s\n", (!str ? "" : str)); \
+ return SYNCML_DM_FAIL; \
+ }
+
+#define CHECK_EXCEPTION(retcode) \
+ if (mEnv->ExceptionCheck()) \
+ { \
+ DmtJavaPlugin_Debug("An exception is thrown\n"); \
+ (retcode) = SYNCML_DM_FAIL; \
+ }
+
+DmtJavaPluginManager::DmtJavaPluginManager(const char* pPath, DMStringMap& mapParameters)
+ : mEnv(NULL), mJavaPluginManager(mEnv), mIsInitialized(false)
+{
+ if (!InitJNIEnv() ||
+ !InitJavaPluginManager() ||
+ !InitJavaPlugin(pPath, mapParameters))
+ {
+ DmtJavaPlugin_Debug("Fail to init DmtJavaPluginManager!\n");
+ return;
+ }
+
+ mIsInitialized = true;
+}
+
+DmtJavaPluginManager::~DmtJavaPluginManager()
+{
+ if (InitJNIEnv() && mEnv != NULL && mJavaPluginManager != NULL)
+ {
+ ReleasePluginManager();
+ }
+}
+
+bool DmtJavaPluginManager::InitJNIEnv()
+{
+ JavaVM* jvm = android::AndroidRuntime::getJavaVM();
+ if (jvm != NULL)
+ {
+ return jvm->GetEnv((void**)&mEnv, JNI_VERSION_1_6) == JNI_OK;
+ }
+
+ JavaVMOption options[1];
+ memset(&options, 0, sizeof(options));
+
+ options[0].optionString = "-Djava.class.path=/system/framework/com.android.omadm.plugin.jar:/system/framework/com.android.omadm.plugin.dev.jar";
+
+ JavaVMInitArgs initArgs;
+ memset(&initArgs, 0, sizeof(initArgs));
+
+ initArgs.version = JNI_VERSION_1_6;
+ initArgs.options = options;
+ initArgs.nOptions = 1;
+ initArgs.ignoreUnrecognized = JNI_TRUE;
+
+ DmtJavaPlugin_Debug("Create new JVM\n");
+ return JNI_CreateJavaVM(&jvm, &mEnv, &initArgs) == JNI_OK;
+}
+
+bool DmtJavaPluginManager::InitJavaPluginManager()
+{
+ DmtJavaMethod constructor(mEnv,"com/android/omadm/plugin/impl/DmtPluginManager", "<init>", "()V");
+ if (!constructor.isFound())
+ {
+ return false;
+ }
+
+ DmtJObject localPluginManager(mEnv, mEnv->NewObject(constructor.getClass(), constructor.getMethodID()));
+ if (!localPluginManager)
+ {
+ DmtJavaPlugin_Debug("Failed to create new object for DmtPluginManager!\n");
+ return false;
+ }
+
+ mJavaPluginManager.assignValue(localPluginManager.getValue(), mEnv);
+
+ return (mJavaPluginManager != NULL);
+}
+
+bool DmtJavaPluginManager::InitJavaPlugin(const char* pPath, DMStringMap& mapParameters)
+{
+ if (pPath == NULL)
+ {
+ DmtJavaPlugin_Debug("Path is null\n");
+ return false;
+ }
+
+ DmtJavaMethod javaMethod(mEnv, mJavaPluginManager, "initJavaPlugin", "(Ljava/lang/String;[Ljava/lang/String;)Z");
+ if (!javaMethod.isFound())
+ {
+ DmtJavaPlugin_Debug("Failed to get loadJavaPlugin()\n");
+ return false;
+ }
+
+ DmtJString objPath(mEnv, mEnv->NewStringUTF(pPath));
+ DmtJClass classString(mEnv, mEnv->FindClass("java/lang/String"));
+ DmtJObjectArray objStrArray(mEnv, mEnv->NewObjectArray(mapParameters.size() * 2, classString, NULL));
+ if (!objPath || !classString || !objStrArray)
+ {
+ DmtJavaPlugin_Debug("Failed to create jstring or jobjectArray\n");
+ return false;
+ }
+
+ int i = 0;
+ for (DMStringMap::POS it = mapParameters.begin(); it != mapParameters.end(); it++)
+ {
+ DmtJString name(mEnv, mEnv->NewStringUTF(mapParameters.get_key(it).c_str()));
+ DmtJString value(mEnv, mEnv->NewStringUTF(mapParameters.get_value(it).c_str()));
+ if (!name || !value)
+ {
+ DmtJavaPlugin_Debug("Failed to create string for name or value\n");
+ return false;
+ }
+ mEnv->SetObjectArrayElement(objStrArray, i , name);
+ mEnv->SetObjectArrayElement(objStrArray, i + 1, value);
+
+ i += 2;
+ }
+
+ jboolean isInitialized = mEnv->CallBooleanMethod(mJavaPluginManager, javaMethod,
+ objPath.getValue(), objStrArray.getValue());
+ return (!mEnv->ExceptionCheck() && isInitialized);
+}
+
+void DmtJavaPluginManager::ReleasePluginManager()
+{
+ DmtJavaMethod javaMethod(mEnv, mJavaPluginManager, "release", "()V");
+ if (!javaMethod.isFound()) {
+ DmtJavaPlugin_Debug("Fail to get release() method\n");
+ return;
+ }
+
+ mEnv->CallVoidMethod(mJavaPluginManager, javaMethod);
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::GetDmtNodeValue(jint& type,
+ char*& pValue,
+ const DmtData& data)
+{
+ DMString dmStringValue;
+
+ SYNCML_DM_RET_STATUS_T retcode = data.GetString(dmStringValue);
+ if (retcode != SYNCML_DM_SUCCESS)
+ {
+ DmtJavaPlugin_Debug("Fail to get string value\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ const char* pStringValue = dmStringValue.c_str();
+
+ size_t size = strlen(pStringValue) + 1;
+
+ pValue = new char[size];
+ if (!pValue) {
+ DmtJavaPlugin_Debug("Fail to allocate memory\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ strcpy(pValue, pStringValue);
+
+ switch (data.GetType())
+ {
+ case SYNCML_DM_DATAFORMAT_NULL:
+ type = JAVA_SYNCML_DM_DATAFORMAT_NULL;
+ break;
+
+ case SYNCML_DM_DATAFORMAT_STRING:
+ type = JAVA_SYNCML_DM_DATAFORMAT_STRING;
+ break;
+
+ case SYNCML_DM_DATAFORMAT_INT:
+ type = JAVA_SYNCML_DM_DATAFORMAT_INT;
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BOOL:
+ type = JAVA_SYNCML_DM_DATAFORMAT_BOOL;
+ break;
+
+ case SYNCML_DM_DATAFORMAT_BIN:
+ type = JAVA_SYNCML_DM_DATAFORMAT_BIN;
+ break;
+
+ case SYNCML_DM_DATAFORMAT_DATE:
+ type = JAVA_SYNCML_DM_DATAFORMAT_DATE;
+ break;
+
+ case SYNCML_DM_DATAFORMAT_TIME:
+ type = JAVA_SYNCML_DM_DATAFORMAT_TIME;
+ break;
+
+ case SYNCML_DM_DATAFORMAT_FLOAT:
+ type = JAVA_SYNCML_DM_DATAFORMAT_FLOAT;
+ break;
+
+ default:
+ DmtJavaPlugin_Debug("Unsupported DmtData type=%d!\n", data.GetType());
+ delete[] pValue;
+ pValue = NULL;
+ return SYNCML_DM_FAIL;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::SetDmtNodeValue(const char* pType,
+ const char* pValue,
+ DmtData& data)
+{
+ if (pType == NULL)
+ {
+ DmtJavaPlugin_Debug("Failed to get value type\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ switch (atoi(pType))
+ {
+ case JAVA_SYNCML_DM_DATAFORMAT_NULL:
+ data.SetString(NULL, SYNCML_DM_DATAFORMAT_NULL);
+ break;
+
+ case JAVA_SYNCML_DM_DATAFORMAT_STRING:
+ data.SetString(pValue, SYNCML_DM_DATAFORMAT_STRING);
+ break;
+
+ case JAVA_SYNCML_DM_DATAFORMAT_INT:
+ data.SetString(pValue, SYNCML_DM_DATAFORMAT_INT);
+ break;
+
+ case JAVA_SYNCML_DM_DATAFORMAT_BOOL:
+ data.SetString(pValue, SYNCML_DM_DATAFORMAT_BOOL);
+ break;
+
+ case JAVA_SYNCML_DM_DATAFORMAT_BIN:
+ data.SetBinary((UINT8*)pValue, strlen(pValue));
+ break;
+
+ case JAVA_SYNCML_DM_DATAFORMAT_DATE:
+ data.SetString(pValue, SYNCML_DM_DATAFORMAT_DATE);
+ break;
+
+ case JAVA_SYNCML_DM_DATAFORMAT_TIME:
+ data.SetString(pValue, SYNCML_DM_DATAFORMAT_TIME);
+ break;
+
+ case JAVA_SYNCML_DM_DATAFORMAT_FLOAT:
+ data.SetString(pValue, SYNCML_DM_DATAFORMAT_FLOAT);
+ break;
+
+ case JAVA_SYNCML_DM_DATAFORMAT_NODE:
+ {
+ DMStringVector vec;
+ if (pValue != NULL && *pValue != 0)
+ {
+ const char* nodeNameBegin = pValue;
+ const char* nodeNameEnd = strchr(nodeNameBegin, '\n');
+ while (nodeNameEnd != NULL)
+ {
+ DMString dmNodeName(nodeNameBegin, nodeNameEnd - nodeNameBegin);
+ vec.push_back(dmNodeName);
+ nodeNameBegin = nodeNameEnd + 1;
+ nodeNameEnd = strchr(nodeNameBegin, '\n');
+ }
+ }
+ data.SetNodeValue(vec);
+ }
+ break;
+
+ default:
+ DmtJavaPlugin_Debug("Unsupported value type\n");
+ return SYNCML_DM_FAIL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::SetServerID(PDmtTree pTree)
+{
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "setServerID", "(Ljava/lang/String;)V");
+ DECLARE_STRING(objServerID, pTree->GetPrincipal().getName().c_str());
+
+ mEnv->CallVoidMethod(mJavaPluginManager, javaMethod, objServerID.getValue());
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::SetNodeValue(const char* pPath, const DmtData& data)
+{
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "setNodeValue", "(Ljava/lang/String;ILjava/lang/String;)I");
+
+ jint type = 0;
+ char* pValue = NULL;
+ SYNCML_DM_RET_STATUS_T retcode = GetDmtNodeValue(type, pValue, data);
+ if (retcode != SYNCML_DM_SUCCESS)
+ {
+ DmtJavaPlugin_Debug("Failed to get node value\n");
+ return retcode;
+ }
+
+ DECLARE_STRING(objPath , pPath);
+ DECLARE_STRING(objValue, (pValue == NULL ? "" : pValue));
+ if (pValue == NULL) {
+ delete[] pValue;
+ pValue = NULL;
+ }
+
+ retcode = mEnv->CallIntMethod(mJavaPluginManager, javaMethod, objPath.getValue(), type, objValue.getValue());
+ CHECK_EXCEPTION(retcode);
+ return retcode;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::GetNodeValue(const char* pPath, DmtData& data)
+{
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "getNodeValue", "(Ljava/lang/String;)[Ljava/lang/String;");
+ DECLARE_STRING(objPath, pPath);
+
+ /* The getNodeValue return objStrArray with 2 elements. */
+ /* The first element is value type and the second is the value. */
+ DmtJObjectArray objStrArray(mEnv);
+ objStrArray = static_cast<jobjectArray>(mEnv->CallObjectMethod(mJavaPluginManager,
+ javaMethod,
+ (jstring)objPath));
+ if (mEnv->ExceptionCheck() || !objStrArray)
+ {
+ DmtJavaPlugin_Debug("Got an error for getNodeValue()\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ if (mEnv->GetArrayLength(objStrArray) != 2)
+ {
+ if (mEnv->GetArrayLength(objStrArray) == 1) {
+ DmtJObject objStatus(mEnv, mEnv->GetObjectArrayElement(objStrArray, 0));
+ if (!objStatus)
+ return SYNCML_DM_FAIL;
+ const char* pStatus = mEnv->GetStringUTFChars((jstring)objStatus.getValue(), NULL);
+ SYNCML_DM_RET_STATUS_T retcode = atoi(pStatus);
+ return retcode;
+ }
+ DmtJavaPlugin_Debug("Array size is not 2!\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DmtJObject objType(mEnv, mEnv->GetObjectArrayElement(objStrArray, 0));
+ DmtJObject objValue(mEnv, mEnv->GetObjectArrayElement(objStrArray, 1));
+ if (!objType || !objValue)
+ {
+ DmtJavaPlugin_Debug("Failed to get value type or value object\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ const char* pType = mEnv->GetStringUTFChars((jstring)objType.getValue(), NULL);
+ const char* pValue = mEnv->GetStringUTFChars((jstring)objValue.getValue(), NULL);
+
+ return SetDmtNodeValue(pType, pValue, data);
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::CreateInteriorNode(const char* pPath)
+{
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "createInteriorNode", "(Ljava/lang/String;)I");
+ DECLARE_STRING(objPath, pPath);
+
+ SYNCML_DM_RET_STATUS_T retcode = mEnv->CallIntMethod(mJavaPluginManager, javaMethod, objPath.getValue());
+ CHECK_EXCEPTION(retcode);
+ return retcode;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::CreateLeafNode(const char* pPath, const DmtData& data)
+{
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "createLeafNode", "(Ljava/lang/String;ILjava/lang/String;)I");
+
+ jint type = 0;
+ char* pValue = NULL;
+ SYNCML_DM_RET_STATUS_T retcode = GetDmtNodeValue(type, pValue, data);
+ if (retcode != SYNCML_DM_SUCCESS)
+ {
+ DmtJavaPlugin_Debug("Failed to get node value\n");
+ return retcode;
+ }
+
+ DECLARE_STRING(objPath, pPath);
+ DECLARE_STRING(objValue, (pValue == NULL ? "" : pValue));
+ if (pValue != NULL) {
+ delete[] pValue;
+ pValue = NULL;
+ }
+
+ retcode = mEnv->CallIntMethod(mJavaPluginManager, javaMethod, objPath.getValue(), type, objValue.getValue());
+ CHECK_EXCEPTION(retcode);
+ return retcode;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::RenameNode(const char* pPath, const char* pNewNodeName)
+{
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "renameNode", "(Ljava/lang/String;Ljava/lang/String;)I");
+ DECLARE_STRING(objPath, pPath);
+ DECLARE_STRING(objNewNodeName, pNewNodeName);
+
+ SYNCML_DM_RET_STATUS_T retcode = mEnv->CallIntMethod(mJavaPluginManager, javaMethod,
+ objPath.getValue(), objNewNodeName.getValue());
+ CHECK_EXCEPTION(retcode);
+ return retcode;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::DeleteNode(const char* pPath)
+{
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "deleteNode", "(Ljava/lang/String;)I");
+ DECLARE_STRING(objPath, pPath);
+
+ SYNCML_DM_RET_STATUS_T retcode = mEnv->CallIntMethod(mJavaPluginManager, javaMethod, objPath.getValue());
+ CHECK_EXCEPTION(retcode);
+ return retcode;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::Commit()
+{
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "commit", "()I");
+
+ SYNCML_DM_RET_STATUS_T retcode = mEnv->CallIntMethod(mJavaPluginManager, javaMethod);
+ CHECK_EXCEPTION(retcode);
+ return retcode;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::ExecuteNode(const char* pArgs,
+ const char* pCorrelator,
+ PDmtTree pTree,
+ DMString& results)
+{
+ results = "";
+
+ if (pArgs == NULL || pTree == NULL) /*|| pCorrelator == NULL*/
+ {
+ DmtJavaPlugin_Debug("A parameter is null\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ if (!mIsInitialized)
+ {
+ DmtJavaPlugin_Debug("Plug-in is not initialized\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ SYNCML_DM_RET_STATUS_T retcode = SetServerID(pTree);
+ if (retcode != SYNCML_DM_SUCCESS)
+ {
+ DmtJavaPlugin_Debug("Fail to set ServerID\n");
+ return retcode;
+ }
+
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "executeNode", "(Ljava/lang/String;Ljava/lang/String;)I");
+ DECLARE_STRING(objArgs, pArgs);
+ DECLARE_STRING(objCorrelator, (pCorrelator == NULL ? "" : pCorrelator) );
+
+ retcode = mEnv->CallIntMethod(mJavaPluginManager, javaMethod, objArgs.getValue(), objCorrelator.getValue());
+ CHECK_EXCEPTION(retcode);
+ return retcode;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginManager::BuildPluginTree(PDmtJavaPluginTree pTree)
+{
+ if (pTree == NULL)
+ {
+ DmtJavaPlugin_Debug("Tree is NULL\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ if (!mIsInitialized)
+ {
+ DmtJavaPlugin_Debug("Plug-in is not initialized\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ if(!InitJNIEnv())
+ {
+ DmtJavaPlugin_Debug("Init JNI Env failed...\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ DECLARE_METHOD(javaMethod, "getNodes", "()[Ljava/lang/String;");
+
+ DmtJObjectArray objStrArray(mEnv);
+ objStrArray = (jobjectArray)(mEnv->CallObjectMethod(mJavaPluginManager, javaMethod));
+ if (!objStrArray)
+ {
+ DmtJavaPlugin_Debug("Fail to get nodes\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ if ((mEnv->GetArrayLength(objStrArray) % 3) != 0)
+ {
+ DmtJavaPlugin_Debug("Array count is invalid!\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ for (int i = 0; i < mEnv->GetArrayLength(objStrArray); i += 3)
+ {
+ DmtJObject objPath(mEnv, mEnv->GetObjectArrayElement(objStrArray, i));
+ DmtJObject objType(mEnv, mEnv->GetObjectArrayElement(objStrArray, i + 1));
+ DmtJObject objValue(mEnv, mEnv->GetObjectArrayElement(objStrArray, i + 2));
+ if (!objPath || !objType || !objValue)
+ {
+ DmtJavaPlugin_Debug("Failed to parse array, iteration:%d\n", i);
+ return SYNCML_DM_FAIL;
+ }
+
+ const char* pPath = mEnv->GetStringUTFChars((jstring)objPath.getValue(), NULL);
+ const char* pType = mEnv->GetStringUTFChars((jstring)objType.getValue(), NULL);
+ const char* pValue = mEnv->GetStringUTFChars((jstring)objValue.getValue(), NULL);
+ if (pPath == NULL || pType == NULL || pValue == NULL)
+ {
+ DmtJavaPlugin_Debug("Failed to convert to string, iteration:%d\n", i);
+ return SYNCML_DM_FAIL;
+ }
+
+ DmtData data;
+
+ SYNCML_DM_RET_STATUS_T retcode = SetDmtNodeValue(pType, pValue, data);
+ if (retcode != SYNCML_DM_SUCCESS)
+ {
+ return retcode;
+ }
+
+ PDmtJavaPluginNode pNode = new DmtJavaPluginNode(pTree, pPath, data);
+
+ pTree->SetNode(pPath, static_cast<PDmtNode>(pNode));
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/javaplugin/nativelib/src/DmtJavaPluginManager.h b/engine/javaplugin/nativelib/src/DmtJavaPluginManager.h
new file mode 100644
index 0000000..daa5ef2
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaPluginManager.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTJAVAPLUGINMANAGER_H__
+#define __DMTJAVAPLUGINMANAGER_H__
+
+#include "DmtJavaItem.h"
+#include "DmtJavaPluginTree.h"
+
+#include "jem_defs.hpp"
+
+#include "dmt.hpp"
+
+/* NOTE: These constants have to be equal to corresponding */
+/* constants in com.android.omadm.plugin.DmtData class. */
+enum {
+ JAVA_SYNCML_DM_DATAFORMAT_NULL = 0,
+ JAVA_SYNCML_DM_DATAFORMAT_STRING = 1,
+ JAVA_SYNCML_DM_DATAFORMAT_INT = 2,
+ JAVA_SYNCML_DM_DATAFORMAT_BOOL = 3,
+ JAVA_SYNCML_DM_DATAFORMAT_BIN = 4,
+ JAVA_SYNCML_DM_DATAFORMAT_NODE = 5,
+ JAVA_SYNCML_DM_DATAFORMAT_B64 = 6,
+ JAVA_SYNCML_DM_DATAFORMAT_XML = 7,
+ JAVA_SYNCML_DM_DATAFORMAT_DATE = 8,
+ JAVA_SYNCML_DM_DATAFORMAT_TIME = 10,
+ JAVA_SYNCML_DM_DATAFORMAT_FLOAT = 11
+};
+
+class DmtJavaPluginManager : public JemBaseObject
+{
+public:
+ DmtJavaPluginManager(const char* pPath, DMStringMap& mapParameters);
+ ~DmtJavaPluginManager();
+
+ SYNCML_DM_RET_STATUS_T GetNodeValue(
+ const char* pPath,
+ DmtData& data);
+
+ SYNCML_DM_RET_STATUS_T SetNodeValue(
+ const char* pPath,
+ const DmtData& data);
+
+ SYNCML_DM_RET_STATUS_T CreateInteriorNode(
+ const char* pPath);
+
+ SYNCML_DM_RET_STATUS_T CreateLeafNode(
+ const char* pPath,
+ const DmtData& data);
+
+ SYNCML_DM_RET_STATUS_T RenameNode(
+ const char* pPath,
+ const char* pNewNodeName);
+
+ SYNCML_DM_RET_STATUS_T DeleteNode(
+ const char* pPath);
+
+ SYNCML_DM_RET_STATUS_T Commit();
+
+ SYNCML_DM_RET_STATUS_T ExecuteNode(
+ const char* pArgs,
+ const char* pCorrelator,
+ PDmtTree pTree,
+ DMString& result);
+
+ SYNCML_DM_RET_STATUS_T BuildPluginTree(
+ PDmtJavaPluginTree pTree);
+
+private:
+ bool InitJNIEnv();
+ bool InitJavaPluginManager();
+ bool InitJavaPlugin(const char* pPath, DMStringMap& mapParameters);
+
+ void ReleasePluginManager();
+
+ SYNCML_DM_RET_STATUS_T GetDmtNodeValue(
+ jint& type,
+ char*& pValue,
+ const DmtData& data);
+
+ SYNCML_DM_RET_STATUS_T SetDmtNodeValue(
+ const char* pType,
+ const char* pValue,
+ DmtData& data);
+
+ SYNCML_DM_RET_STATUS_T SetServerID(
+ PDmtTree pTree);
+
+ JNIEnv* mEnv;
+ DmtJObject mJavaPluginManager;
+ bool mIsInitialized;
+};
+
+typedef JemSmartPtr<DmtJavaPluginManager> PDmtJavaPluginManager;
+
+#endif //__DMTJAVAPLUGINMANAGER_H___
diff --git a/engine/javaplugin/nativelib/src/DmtJavaPluginNode.cc b/engine/javaplugin/nativelib/src/DmtJavaPluginNode.cc
new file mode 100644
index 0000000..0572cc3
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaPluginNode.cc
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dmt.hpp"
+#include "plugin/dmtPlugin.hpp"
+#include "DmtJavaPluginNode.h"
+#include "DmtJavaPluginTree.h"
+#include "DmtJavaPluginCommon.h"
+
+DmtJavaPluginNode::DmtJavaPluginNode(PDmtJavaPluginTree ptrTree, const char* path,
+ const DmtData& data):DmtRWPluginNode()
+{
+ Init(static_cast<PDmtPluginTree>(ptrTree), path, data);
+ m_javaPluginTree = ptrTree;
+}
+
+DmtJavaPluginNode::~DmtJavaPluginNode()
+{
+ m_javaPluginTree = NULL;
+}
+
+DmtJavaPluginNode::DmtJavaPluginNode(PDmtJavaPluginTree ptrTree, const char* path,
+ const DMStringVector& childNodeNames):DmtRWPluginNode()
+{
+ Init(static_cast<PDmtPluginTree>(ptrTree), path, childNodeNames);
+ m_javaPluginTree = ptrTree;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginNode::GetValue(DmtData& oData) const
+{
+ DmtJavaPlugin_Debug("Inside DmtJavaPluginNode::GetValue: oData-->\n");
+ DmtJavaPlugin_Debug("m_strPath.c_str() is %s\n", m_strPath.c_str());
+ if(!IsLeaf())
+ {
+ DmtJavaPlugin_Debug("This is a interior node!\n");
+ return DmtPluginNode::GetValue(oData);
+ }
+ return m_javaPluginTree->GetNodeValueInternal(m_strPath.c_str(), oData);
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginNode::SetValue(const DmtData& oData)
+{
+ DmtJavaPlugin_Debug("Inside DmtJavaPluginNode::SetValue:\n");
+ if(!IsLeaf())
+ {
+ DmtJavaPlugin_Debug("This is a interior node!\n");
+ return DmtRWPluginNode::SetValue(oData);
+ }
+ SYNCML_DM_RET_STATUS_T res = DmtRWPluginNode::SetValue(oData);
+ if(res != SYNCML_DM_SUCCESS)
+ {
+ DmtJavaPlugin_Debug("update memory tree failed...\n");
+ return res;
+ }
+ DmtJavaPlugin_Debug("m_strPath.c_str() is %s\n", m_strPath.c_str());
+ return m_javaPluginTree->SetNodeValueInternal(m_strPath.c_str(), oData);
+}
diff --git a/engine/javaplugin/nativelib/src/DmtJavaPluginNode.h b/engine/javaplugin/nativelib/src/DmtJavaPluginNode.h
new file mode 100644
index 0000000..c8493fd
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaPluginNode.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTJAVAPLUGINNODE_H__
+#define __DMTJAVAPLUGINNODE_H__
+
+#include "jem_defs.hpp"
+#include "dmt.hpp"
+#include "plugin/dmtRWPlugin.hpp"
+
+class DmtJavaPluginTree;
+
+class DmtJavaPluginNode : public DmtRWPluginNode
+{
+public:
+ DmtJavaPluginNode(JemSmartPtr<DmtJavaPluginTree> ptrTree, const char* path, const DmtData& data);
+ DmtJavaPluginNode(JemSmartPtr<DmtJavaPluginTree> ptrTree, const char* path, const DMStringVector & childNodeNames);
+ virtual SYNCML_DM_RET_STATUS_T GetValue(DmtData& oData) const;
+ virtual SYNCML_DM_RET_STATUS_T SetValue(const DmtData& value);
+
+protected:
+ virtual ~DmtJavaPluginNode();
+ JemSmartPtr<DmtJavaPluginTree> m_javaPluginTree;
+private:
+
+};
+
+typedef JemSmartPtr<DmtJavaPluginNode> PDmtJavaPluginNode;
+
+#endif //__DMTJAVAPLUGINNODE_H__
diff --git a/engine/javaplugin/nativelib/src/DmtJavaPluginTree.cc b/engine/javaplugin/nativelib/src/DmtJavaPluginTree.cc
new file mode 100644
index 0000000..99c2e3a
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaPluginTree.cc
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "DmtJavaPluginTree.h"
+#include "DmtJavaPluginNode.h"
+#include "DmtJavaPluginManager.h"
+#include "DmtJavaPluginCommon.h"
+
+DmtJavaPluginTree::DmtJavaPluginTree(const char* rootPath, DMMap<DMString, DMString>& mapParameters)
+ : DmtRWPluginTree(), mIsAtomic(FALSE)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree constructor...\n");
+ Init(rootPath);
+ DmtJavaPlugin_Debug("Finish init rootPath, and begin create new instance of DmtJavaPluginManager..\n");
+ m_pluginManager = new DmtJavaPluginManager(rootPath, mapParameters);
+ DmtJavaPlugin_Debug("Finish create new instance of DmtJavaPluginManager..\n");
+ m_parameters = mapParameters;
+}
+
+DmtJavaPluginTree::~DmtJavaPluginTree()
+{
+ m_pluginManager = NULL;
+ m_parameters.clear();
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::DeleteNode(const char* path)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::DeleteNode, path = %s\n", path);
+ if (m_pluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Plugin manager is not created\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ SYNCML_DM_RET_STATUS_T res = DmtRWPluginTree::DeleteNode(path);
+ DmtJavaPlugin_Debug("DmtJavaPluginTree::DeleteNode: DmtRWPluginTree::DeleteNode res = %d\n", res);
+ if (res == SYNCML_DM_SUCCESS)
+ {
+ res = m_pluginManager->DeleteNode(path);
+ }
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::DeleteNode, res = %d\n", res);
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::CreateInteriorNode(const char* path, PDmtNode& ptrCreatedNode)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::CreateInteriorNode, path = %s \n", path);
+
+ if (m_pluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Plugin manager is not created\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ SYNCML_DM_RET_STATUS_T res = DmtRWPluginTree::CreateInteriorNode(path, ptrCreatedNode);
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::CreateInteriorNode, res = %d\n", res);
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::CreateInteriorNodeInternal(const char* path,
+ PDmtNode& ptrCreatedNode,
+ const DMStringVector& childNodeNames)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::CreateInteriorNodeInternal, path = %s\n", path);
+
+ SYNCML_DM_RET_STATUS_T res = m_pluginManager->CreateInteriorNode(path);
+ if (res == SYNCML_DM_SUCCESS)
+ {
+ PDmtJavaPluginNode pNode = new DmtJavaPluginNode(this, path, childNodeNames);
+ res = this->SetNode(path, static_cast<PDmtNode>(pNode));
+ if (res != SYNCML_DM_SUCCESS)
+ {
+ m_pluginManager->DeleteNode(path);
+ }
+ ptrCreatedNode = pNode;
+ }
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::CreateInteriorNodeInternal, path = %s\n", path);
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::CreateLeafNode(const char* path, PDmtNode& ptrCreatedNode, const DmtData& value)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::CreateLeafNode, path = %s\n", path);
+ if (m_pluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Plugin manager is not created\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ SYNCML_DM_RET_STATUS_T res = DmtRWPluginTree::CreateLeafNode(path, ptrCreatedNode, value);
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::CreateLeafNode, res = %d\n", res);
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::CreateLeafNode(const char* path, PDmtNode& ptrCreatedNode, const DmtData& value, BOOLEAN isESN)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::CreateLeafNode, path = %s\n", path);
+ if (m_pluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Plugin manager is not created\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ SYNCML_DM_RET_STATUS_T res = DmtRWPluginTree::CreateLeafNode(path, ptrCreatedNode, value, isESN);
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::CreateLeafNode, res = %d\n", res);
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::CreateLeafNodeInternal(const char* path, PDmtNode& ptrCreatedNode, const DmtData& value)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::CreateLeafNodeInternal, path = %s\n", path);
+
+ SYNCML_DM_RET_STATUS_T res = m_pluginManager->CreateLeafNode(path, value);
+ if (res == SYNCML_DM_SUCCESS)
+ {
+ PDmtJavaPluginNode pNode = new DmtJavaPluginNode(this, path, value);
+ res = this->SetNode(path, static_cast<PDmtNode>(pNode));
+ if (res != SYNCML_DM_SUCCESS)
+ {
+ m_pluginManager->DeleteNode(path);
+ }
+ ptrCreatedNode = pNode;
+ }
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::CreateLeafNodeInternal, path = %s\n", path);
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::CreateLeafNodeInternal(const char* path, PDmtNode& ptrCreatedNode, const DmtData& value, BOOLEAN isESN)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::CreateLeafNodeInternal, path = %s, isESN = %d\n", path, isESN);
+ return CreateLeafNodeInternal(path, ptrCreatedNode, value);
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::RenameNode(const char* path, const char* szNewNodeName)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::RenameNode, path = %s\n", path);
+
+ if (m_pluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Plugin manager is not created\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ // This method is not supported by DmtPluginTree so we don't call java plug-in
+ // SYNCML_DM_RET_STATUS_T res = m_pluginManager->RenameNode(path, szNewNodeName);
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::GetNode(const char* szPath, PDmtNode& ptrNode)
+{
+ if (!szPath)
+ {
+ szPath = "";
+ }
+ DmtJavaPlugin_Debug("DmtJavaPluginTree::GetNode(%s)\n", szPath);
+ return DmtPluginTree::GetNode(szPath, ptrNode);
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::BuildPluginTree()
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::BuildPluginTree\n");
+ if (m_pluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Plugin manager is not created\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ SYNCML_DM_RET_STATUS_T res = m_pluginManager->BuildPluginTree(this);
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::BuildPluginTree, res = %d\n", res);
+ return res;
+}
+
+DMMap<DMString, DMString>& DmtJavaPluginTree::GetParameters()
+{
+ return m_parameters;
+}
+
+DMString& DmtJavaPluginTree::GetRootPath()
+{
+ return m_strRootPath;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::GetNodeValueInternal(const char* path, DmtData& value)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::GetNodeValueInternal, path = %s\n", path);
+ if (m_pluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Plugin manager is not created\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ SYNCML_DM_RET_STATUS_T res = m_pluginManager->GetNodeValue(path, value);
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::GetNodeValueInternal, res = %d\n", res);
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::SetNodeValueInternal(const char* path, const DmtData& value)
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::SetNodeValueInternal, path = %s\n", path);
+ if (m_pluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Plugin manager is not created\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ SYNCML_DM_RET_STATUS_T res = m_pluginManager->SetNodeValue(path, value);
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::SetNodeValueInternal, res = %d\n", res);
+ return res;
+}
+
+BOOLEAN DmtJavaPluginTree::IsAtomic()
+{
+ DmtJavaPlugin_Debug("DmtJavaPluginTree::IsAtomic\n");
+ return mIsAtomic;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::Flush()
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::Flush\n");
+
+ //TODO: Workaround. Commit will be called by engine in any case.
+ Commit();
+
+ // ehb005:should not set this NULL because tree could be accessed again after flush
+ //m_pluginManager = NULL;
+
+ SYNCML_DM_RET_STATUS_T res = DmtRWPluginTree::Flush();
+
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::Flush, res = %d\n", res);
+
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::Commit()
+{
+ DmtJavaPlugin_Debug("Inside: DmtJavaPluginTree::Commit\n");
+ if (m_pluginManager == NULL)
+ {
+ DmtJavaPlugin_Debug("Plugin manager is not created\n");
+ return SYNCML_DM_FAIL;
+ }
+
+ mIsAtomic = FALSE;
+
+ SYNCML_DM_RET_STATUS_T res = m_pluginManager->Commit();
+ DmtJavaPlugin_Debug("Leave: DmtJavaPluginTree::Commit, res = %d\n", res);
+ return res;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::Begin()
+{
+ DmtJavaPlugin_Debug("DmtJavaPluginTree::Begin\n");
+ mIsAtomic = TRUE;
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T DmtJavaPluginTree::Rollback()
+{
+ DmtJavaPlugin_Debug("DmtJavaPluginTree::Rollback\n");
+ mIsAtomic = FALSE;
+ return SYNCML_DM_FEATURE_NOT_SUPPORTED;
+}
diff --git a/engine/javaplugin/nativelib/src/DmtJavaPluginTree.h b/engine/javaplugin/nativelib/src/DmtJavaPluginTree.h
new file mode 100644
index 0000000..0e5d1fb
--- /dev/null
+++ b/engine/javaplugin/nativelib/src/DmtJavaPluginTree.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMTJAVAPLUGINTREE_H__
+#define __DMTJAVAPLUGINTREE_H__
+
+#include "dmt.hpp"
+#include "jem_defs.hpp"
+#include "plugin/dmtRWPlugin.hpp"
+
+class DmtJavaPluginManager;
+
+class DmtJavaPluginTree : public DmtRWPluginTree
+{
+public:
+ DmtJavaPluginTree(const char* rootPath, DMMap<DMString, DMString>& mapParameters);
+ virtual SYNCML_DM_RET_STATUS_T DeleteNode(const char* path);
+ virtual SYNCML_DM_RET_STATUS_T CreateInteriorNode(const char* path, PDmtNode& ptrCreatedNode);
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode(const char* path, PDmtNode& ptrCreatedNode, const DmtData& value);
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNode(const char* path, PDmtNode& ptrCreatedNode, const DmtData& value, BOOLEAN isESN);
+ virtual SYNCML_DM_RET_STATUS_T CreateInteriorNodeInternal(const char* path, PDmtNode& ptrCreatedNode, const DMStringVector& childNodeNames);
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNodeInternal(const char* path, PDmtNode& ptrCreatedNode, const DmtData& value);
+ virtual SYNCML_DM_RET_STATUS_T CreateLeafNodeInternal(const char* path, PDmtNode& ptrCreatedNode, const DmtData& value, BOOLEAN isESN);
+ virtual SYNCML_DM_RET_STATUS_T RenameNode(const char* path, const char* szNewNodeName);
+ virtual SYNCML_DM_RET_STATUS_T GetNode(const char* path, PDmtNode& ptrNode);
+ SYNCML_DM_RET_STATUS_T BuildPluginTree();
+ DMMap<DMString, DMString>& GetParameters();
+ DMString& GetRootPath();
+ SYNCML_DM_RET_STATUS_T GetNodeValueInternal(const char* path, DmtData& value);
+ SYNCML_DM_RET_STATUS_T SetNodeValueInternal(const char* path, const DmtData& value);
+ virtual BOOLEAN IsAtomic();
+ virtual SYNCML_DM_RET_STATUS_T Flush();
+ virtual SYNCML_DM_RET_STATUS_T Commit();
+ virtual SYNCML_DM_RET_STATUS_T Begin();
+ virtual SYNCML_DM_RET_STATUS_T Rollback();
+
+protected:
+ virtual ~DmtJavaPluginTree();
+
+private:
+ JemSmartPtr<DmtJavaPluginManager> m_pluginManager;
+ DMMap<DMString, DMString> m_parameters;
+ BOOLEAN mIsAtomic;
+};
+
+typedef JemSmartPtr<DmtJavaPluginTree> PDmtJavaPluginTree;
+
+#endif //__DMTJAVAPLUGINTREE_H__
diff --git a/engine/jni/DMServiceAlert.cc b/engine/jni/DMServiceAlert.cc
new file mode 100644
index 0000000..9b606b2
--- /dev/null
+++ b/engine/jni/DMServiceAlert.cc
@@ -0,0 +1,397 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "DMServiceAlert.h"
+#include "xpl_dm_ServerAlert.h"
+
+#include <android_runtime/AndroidRuntime.h>
+
+/**
+ * Constructor
+ *
+ **/
+DMServiceAlert::DMServiceAlert() : m_jDmEnv(NULL), m_jDmAlertCls(NULL), m_jDmAlertObj(NULL)
+{
+ LOGD("DMServiceAlert: enter DMServiceAlert::DMServiceAlert()");
+ m_jDmEnv = android::AndroidRuntime::getJNIEnv();
+ if ( NULL == m_jDmEnv ) {
+ LOGE("DMServiceAlert: android::AndroidRuntime::getJNIEnv() failed!");
+ return;
+ }
+ LOGD("DMServiceAlert: Get JNI Env success.");
+
+ m_jDmAlertObj = getDMAlert(m_jDmEnv);
+ if ( NULL == m_jDmAlertObj) {
+ LOGE("DMServiceAlert: m_jDmEnv->CallObjectMethod failed!");
+ return;
+ }
+ LOGD("DMServiceAlert: Get DmAlert Object success");
+
+ m_jDmAlertCls = m_jDmEnv->GetObjectClass(m_jDmAlertObj);
+ if ( NULL == m_jDmAlertCls ) {
+ LOGE("DMServiceAlert: m_jDmEnv->GetObjectClass failed!");
+ return;
+ }
+ LOGD("DMServiceAlert: Get DmAlert Class success.");
+}
+
+/**
+ * De-Constructor
+ *
+ **/
+DMServiceAlert::~DMServiceAlert()
+{
+ if ( !m_jDmEnv ) {
+ return;
+ }
+
+ if ( m_jDmAlertCls ) {
+ m_jDmEnv->DeleteLocalRef(m_jDmAlertCls);
+ }
+
+ if ( m_jDmAlertObj ) {
+ m_jDmEnv->DeleteLocalRef(m_jDmAlertObj);
+ }
+}
+
+/**
+ * Display a text messages
+ *
+ * @param minDisplayTime minimum display time, in seconds.
+ * @param msg messages to display
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T
+DMServiceAlert::showDisplayAlert(INT32 minDisplayTime, const DMString& msg, INT32 title, INT32 icon)
+{
+ LOGD("DMServiceAlert: enter showDisplayAlert()");
+
+ if (isJvmNull()) {
+ LOGE("DMServiceAlert: JVM validation failed!");
+ return SYNCML_DM_FAIL;
+ }
+
+ m_jDmAlertMID = m_jDmEnv->GetMethodID(m_jDmAlertCls,
+ "showDisplayAlert",
+ "(ILjava/lang/String;II)I");
+ if (NULL == m_jDmAlertMID) {
+ LOGE("DMServiceAlert: m_jDmEnv->GetMethodID(showDisplayAlert) failed");
+ return SYNCML_DM_FAIL;
+ }
+
+ LOGD("DMServiceAlert: m_jDmEnv->GetMethodID(showDisplayAlert) success.");
+ jint t = minDisplayTime;
+ jstring m = m_jDmEnv->NewStringUTF(msg.c_str());
+ jint tl = title;
+ jint ic = icon;
+
+ jint r = m_jDmEnv->CallIntMethod(m_jDmAlertObj, m_jDmAlertMID, t, m, tl, ic);
+ m_jDmEnv->DeleteLocalRef(m);
+ LOGD("DMServiceAlert: DisplayAlert result: %d", r);
+
+ return (r != DM_SERVICE_ALERT_RESP_FAIL)
+ ? SYNCML_DM_SUCCESS : SYNCML_DM_FAIL;
+};
+
+/**
+ * Display a confirm alert message box, user can confirm or cancel the action
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param defaultResponse default user action when timeout
+ * @param responseCode user's action will be returned here.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T
+DMServiceAlert::showConfirmAlert(INT32 maxDisplayTime, const DMString& msg,
+ XPL_DM_ALERT_RES_T defaultResponse,
+ XPL_DM_ALERT_RES_T *response,
+ INT32 title,
+ INT32 icon)
+{
+ LOGD("DMServiceAlert: enter showConfirmAlert()");
+
+ if (isJvmNull()) {
+ LOGE("DMServiceAlert: JVM validation failed!");
+ return SYNCML_DM_FAIL;
+ }
+
+ #ifdef DM_SDMSERVICES
+ if (strlen(msg) > DM_SERVICE_ALERT_MAX_MSG_SIZE) {
+ LOGD("DMServiceAlert: showConfirmAlert MAX UI ALERT STRING SIZE is 250");
+ return SYNCML_DM_BAD_REQUEST;
+ }
+
+ for(int i=0; i<strlen(msg); i++){
+ if( msg[i]=='$' || msg[i]=='%' || msg[i]=='^' || msg[i]=='&' || msg[i]=='_' ) {
+ LOGD("DMServiceAlert: Confirm Alert message contains unacceptable character");
+ return SYNCML_DM_BAD_REQUEST;
+ }
+ }
+ #endif
+
+ m_jDmAlertMID = m_jDmEnv->GetMethodID(m_jDmAlertCls,
+ "showConfirmAlert",
+ "(ILjava/lang/String;II)I");
+ if ( NULL == m_jDmAlertMID ) {
+ LOGE("DMServiceAlert: m_jDmEnv->GetMethodID(showConfirmAlert) failed");
+ return SYNCML_DM_FAIL;
+ }
+
+ LOGD("DMServiceAlert: m_jDmEnv->GetMethodID(showConfirmAlert) success.");
+ jint t = maxDisplayTime;
+ jstring m = m_jDmEnv->NewStringUTF(msg.c_str());
+ jint tl = title;
+ jint ic = icon;
+
+ jint r = m_jDmEnv->CallIntMethod(m_jDmAlertObj, m_jDmAlertMID, t, m, tl, ic);
+ m_jDmEnv->DeleteLocalRef(m);
+ LOGD("DMServiceAlert: ConfirmAlert result: %d", r);
+
+ if (r == DM_SERVICE_ALERT_RESP_TIMEOUT) {
+ *response = defaultResponse;
+ }
+ else {
+ *response = (XPL_DM_ALERT_RES_T) r;
+ }
+
+ return (r != DM_SERVICE_ALERT_RESP_FAIL)
+ ? SYNCML_DM_SUCCESS : SYNCML_DM_FAIL;
+}
+
+/**
+ * Display a text input message box for user to enter input.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param defaultResponse default user action when timeout
+ * @param maxLength length allowed in user input
+ * @param inputType data format as specified in DM_ALERT_INPUT_T
+ * @param echoType whether to echo user input (hidden for password ) as specified in DM_ALERT_ECHO_T
+ * @param response hold user's response action and input data.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T
+DMServiceAlert::showTextInputAlert( INT32 maxDisplayTime,
+ const DMString& msg,
+ const DMString& defaultResponse,
+ INT32 maxLength,
+ XPL_DM_ALERT_INPUT_T inputType,
+ XPL_DM_ALERT_ECHO_T echoType,
+ XPL_DM_ALERT_TEXTINPUT_RES_T * response,
+ INT32 title,
+ INT32 icon)
+{
+ LOGD("DMServiceAlert: enter showTextInputAlert()");
+
+ if (isJvmNull()) {
+ LOGE("DMServiceAlert: JVM validation failed!");
+ return SYNCML_DM_FAIL;
+ }
+
+ m_jDmAlertMID = m_jDmEnv->GetMethodID(m_jDmAlertCls,
+ "showTextInputAlert",
+ "(ILjava/lang/String;Ljava/lang/String;IIIII)Ljava/lang/String;");
+ if ( NULL == m_jDmAlertMID ) {
+ LOGE("DMServiceAlert: m_jDmEnv->GetMethodID(showTextInputAlert) failed");
+ return SYNCML_DM_FAIL;
+ }
+
+ LOGD("DMServiceAlert: m_jDmEnv->GetMethodID(showTextInputAlert) success.");
+ jint t = maxDisplayTime;
+ jstring m = m_jDmEnv->NewStringUTF(msg.c_str());
+ jstring d = m_jDmEnv->NewStringUTF(defaultResponse.c_str());
+ jint l = maxLength;
+ jint i = (int)inputType;
+ jint e = (int)echoType;
+ jint tl = title;
+ jint ic = icon;
+
+ jstring r = (jstring)m_jDmEnv->CallObjectMethod(m_jDmAlertObj, m_jDmAlertMID, t, m, d, l, i, e, tl, ic);
+ m_jDmEnv->DeleteLocalRef(m);
+
+ const char *rlt = m_jDmEnv->GetStringUTFChars(r, 0);
+ if ( NULL == rlt || '-' == rlt[0] ) {
+ LOGE("DMServiceAlert: TextInputAlert return NULL or FAIL !");
+ return SYNCML_DM_FAIL;
+ }
+
+ LOGD("DMServiceAlert: TextInputAlert result: %s", rlt);
+
+ int a = rlt[0] - '0';
+ if ( a == DM_SERVICE_ALERT_RESP_FAIL ) {
+ LOGE("DMServiceAlert: TextInputAlert return fail!");
+ return SYNCML_DM_FAIL;
+ }
+
+ response->action = (XPL_DM_ALERT_RES_T) a;
+ if (a == DM_SERVICE_ALERT_RESP_TIMEOUT) {
+ response->response = defaultResponse;
+ }
+ else {
+ response->response = DMString(rlt+2);
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+DMServiceAlert::showSingleChoiceAlert(INT32 maxDisplayTime, const DMString& msg,
+ const DMStringVector& choices, INT32 defaultResponse,
+ XPL_DM_ALERT_SCHOICE_RES_T* response, INT32 title, INT32 icon)
+{
+ LOGD("DMServiceAlert: enter showSingleChoiceAlert()");
+
+ if (isJvmNull()) {
+ LOGE("DMServiceAlert: JVM validation failed!");
+ return SYNCML_DM_FAIL;
+ }
+
+ m_jDmAlertMID = m_jDmEnv->GetMethodID(m_jDmAlertCls,
+ "showSingleChoiceAlert",
+ "(ILjava/lang/String;[Ljava/lang/String;III)Ljava/lang/String;");
+ if ( NULL == m_jDmAlertMID ) {
+ LOGE("DMServiceAlert: m_jDmEnv->GetMethodID(showSingleChoiceAlert) failed");
+ return SYNCML_DM_FAIL;
+ }
+
+ LOGD("DMServiceAlert: m_jDmEnv->GetMethodID(showSingleChoiceAlert) success.");
+ jint t = maxDisplayTime;
+ jstring m = m_jDmEnv->NewStringUTF(msg.c_str());
+ int size = choices.size();
+ jobjectArray c = m_jDmEnv->NewObjectArray(size, m_jDmEnv->FindClass("java/lang/String"), NULL);
+ for ( int i = 0; i < size; i ++ ) {
+ m_jDmEnv->SetObjectArrayElement(c, i, m_jDmEnv->NewStringUTF(choices[i].c_str()));
+ }
+ jint d = defaultResponse - 1;
+ jint tl = title;
+ jint ic = icon;
+
+ jstring r = (jstring)m_jDmEnv->CallObjectMethod(m_jDmAlertObj, m_jDmAlertMID, t, m, c, d, tl, ic);
+ // FIXME: delete local refs to object array strings
+ m_jDmEnv->DeleteLocalRef(m);
+
+ const char *rlt = m_jDmEnv->GetStringUTFChars(r, 0);
+ if ( NULL == rlt || '-' == rlt[0] ) {
+ LOGE("DMServiceAlert: TextInputAlert return NULL or FAIL !");
+ return SYNCML_DM_FAIL;
+ }
+
+ LOGD("DMServiceAlert: SingleChoiceAlert result: %s", rlt);
+
+ int a = rlt[0] - '0';
+ if (a == DM_SERVICE_ALERT_RESP_FAIL) {
+ LOGE("DMServiceAlert: SingleChoiceAlert return fail!");
+ return SYNCML_DM_FAIL;
+ }
+
+ response->action = (XPL_DM_ALERT_RES_T)a;
+ if (a == DM_SERVICE_ALERT_RESP_TIMEOUT) {
+ response->response = defaultResponse;
+ }
+ else {
+ response->response = atoi(rlt+2) + 1;
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
+
+
+SYNCML_DM_RET_STATUS_T
+DMServiceAlert::showMultipleChoiceAlert(INT32 maxDisplayTime, const DMString& msg,
+ const DMStringVector& choices, const DMStringVector& defaultResponses,
+ XPL_DM_ALERT_MCHOICE_RES_T* response, INT32 title, INT32 icon)
+{
+ LOGD("DMServiceAlert: enter showMultipleChoiceAlert()");
+
+ if (isJvmNull()) {
+ LOGE("DMServiceAlert: JVM validation failed!");
+ return SYNCML_DM_FAIL;
+ }
+
+ m_jDmAlertMID = m_jDmEnv->GetMethodID(m_jDmAlertCls,
+ "showMultipleChoiceAlert",
+ "(ILjava/lang/String;[Ljava/lang/String;[ZII)I");
+ if ( NULL == m_jDmAlertMID ) {
+ LOGE("DMServiceAlert: m_jDmEnv->GetMethodID(showMultipleChoiceAlert) failed");
+ return SYNCML_DM_FAIL;
+ }
+
+ LOGD("DMServiceAlert: m_jDmEnv->GetMethodID(showMultipleChoiceAlert) success.");
+ jint t = maxDisplayTime;
+ jstring m = m_jDmEnv->NewStringUTF(msg.c_str());
+
+ int size = choices.size();
+ LOGD("DMServiceAlert: showMultipleChoiceAlert choices size: %d", size);
+ jclass s = m_jDmEnv->FindClass("java/lang/String");
+ jobjectArray c = m_jDmEnv->NewObjectArray(size, s, NULL);
+ for (int i = 0; i < size; ++i) {
+ m_jDmEnv->SetObjectArrayElement(c, i, m_jDmEnv->NewStringUTF(choices[i].c_str()));
+ }
+
+ jbooleanArray d = m_jDmEnv->NewBooleanArray(size);
+ jboolean ds[size];
+ int dsize = defaultResponses.size();
+ LOGD("DMServiceAlert: showMultipleChoiceAlert default choices size: %d", dsize);
+ for (int i = 0; i < size; ++i) {
+ ds[i] = false;
+ }
+ int idx = 0;
+ for (int i = 0; i < dsize; ++i) {
+ idx = atoi(defaultResponses[i].c_str()) - 1;
+ if ( idx < size ) {
+ ds[idx] = true;
+ }
+ }
+ m_jDmEnv->SetBooleanArrayRegion(d, (jsize)0, (jsize)size, (const jboolean *)ds);
+
+ jint tl = title;
+ jint ic = icon;
+
+ jint r = m_jDmEnv->CallIntMethod(m_jDmAlertObj, m_jDmAlertMID, t, m, c, d, tl, ic);
+ // FIXME: delete local refs to object array strings
+ m_jDmEnv->DeleteLocalRef(m);
+
+ if ( r == DM_SERVICE_ALERT_RESP_FAIL ) {
+ LOGE("DMServiceAlert: m_jDmEnv->CallIntMethod(showMultipleChoiceAlert) failed");
+ return SYNCML_DM_FAIL;
+ }
+ LOGD("DMServiceAlert: MultiChoiceAlert result: %d", r);
+
+ response->action = (XPL_DM_ALERT_RES_T) r;
+ if (r == DM_SERVICE_ALERT_RESP_TIMEOUT) {
+ for ( int i = 0; i < dsize; i++ ) {
+ response->responses.push_back(defaultResponses[i].c_str());
+ }
+ }
+ else {
+
+ char idx[4]; // Max 3 digits index by default;
+ for ( int i = 0; i < size; i++) {
+ m_jDmEnv->GetBooleanArrayRegion(d, (jsize)0, (jsize)size, (jboolean *)ds);
+ LOGD("DMServiceAlert: showMultipleChoiceAlert %d response: %d", i, ds[i]);
+ if ( ds[i] ) {
+ snprintf(idx, 4, "%d", i + 1);
+ response->responses.push_back(idx);
+ }
+ }
+ }
+
+ return SYNCML_DM_SUCCESS;
+}
diff --git a/engine/jni/DMServiceAlert.h b/engine/jni/DMServiceAlert.h
new file mode 100644
index 0000000..140be51
--- /dev/null
+++ b/engine/jni/DMServiceAlert.h
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMSERVICE_ALERT_H
+#define DMSERVICE_ALERT_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ * \file DMServiceAlert.h
+ * \brief Declaration of JNI implementation of DMServiceAlert.
+ */
+
+#include <DMServiceMain.h>
+#include "xpl_dm_ServerAlert.h"
+
+// DMServiceAlert Response Code
+static const int DM_SERVICE_ALERT_RESP_FAIL = -1;
+static const int DM_SERVICE_ALERT_RESP_NONE = 0;
+static const int DM_SERVICE_ALERT_RESP_NO = 1;
+static const int DM_SERVICE_ALERT_RESP_YES = 2;
+static const int DM_SERVICE_ALERT_RESP_CANCEL = 3;
+static const int DM_SERVICE_ALERT_RESP_TIMEOUT = 4;
+
+#ifdef DM_SDMSERVICES
+static const int DM_SERVICE_ALERT_MAX_MSG_SIZE = 250;
+#endif
+
+// DMServiceAlert Input Type
+static const int DM_SERVICE_ALERT_INPUT_ALPHA = 0;
+static const int DM_SERVICE_ALERT_INPUT_NUMERIC = 1;
+static const int DM_SERVICE_ALERT_INPUT_DATE = 2;
+static const int DM_SERVICE_ALERT_INPUT_TIME = 3;
+static const int DM_SERVICE_ALERT_INPUT_PHONE_NUM = 4;
+static const int DM_SERVICE_ALERT_INPUT_IP_ADDR = 5;
+
+// DMServiceAlert Echo Type
+static const int DM_SERVICE_ALERT_ECHO_TEXT = 0;
+static const int DM_SERVICE_ALERT_ECHO_PASSWD = 1;
+
+// DMServiceAlert Icon Type
+static const int DM_SERVICE_ALERT_ICON_GENERIC = 0;
+static const int DM_SERVICE_ALERT_ICON_PROGRESS = 1;
+static const int DM_SERVICE_ALERT_ICON_OK = 2;
+static const int DM_SERVICE_ALERT_ICON_ERROR = 3;
+static const int DM_SERVICE_ALERT_ICON_CONFIRM = 4;
+static const int DM_SERVICE_ALERT_ICON_ACTION = 5;
+static const int DM_SERVICE_ALERT_ICON_INFO = 6;
+
+// DMServiceAlert Title Type
+static const int DM_SERVICE_ALERT_TITLE_NULL = 0;
+static const int PMF_RESOURCE_ID_TITLE_SYSTEM_UPDATE = 1;
+static const int PMF_RESOURCE_ID_TITLE_NEED_AUTHENTICATION = 2;
+static const int PMF_RESOURCE_ID_TITLE_UPDATE_COMPLETE = 3;
+static const int PMF_RESOURCE_ID_TITLE_SYSTEM_MESSAGE = 4;
+static const int PMF_RESOURCE_ID_TITLE_AUTHENTICATION_FAILED = 5;
+static const int PMF_RESOURCE_ID_TITLE_UPDATE_ERROR = 6;
+static const int PMF_RESOURCE_ID_TITLE_UPDATE_CANCELLED = 7;
+static const int PMF_RESOURCE_ID_TITLE_PROFILE_FOR_BROWSER = 8;
+static const int PMF_RESOURCE_ID_TITLE_PROFILE_FOR_MMS = 9;
+static const int PMF_RESOURCE_ID_TITLE_CONNECTION_FAILED = 10;
+static const int PMF_RESOURCE_ID_TITLE_CONNECTION_FAILURE = 11;
+static const int PMF_RESOURCE_ID_TITLE_SW_UPDATE = 12;
+static const int PMF_RESOURCE_ID_14674_TITLE_REGISTRATION = 13;
+static const int PMF_RESOURCE_ID_CONTEXT_SYSTEM_UPDATE_SEVERAL_MINUTES_NO_PROCEED = 14;
+static const int PMF_RESOURCE_ID_CONTEXT_SYSTEM_UPDATE_NOTICE = 15;
+static const int PMF_RESOURCE_ID_CONTEXT_SYSTEM_UPDATE = 16;
+static const int PMF_RESOURCE_ID_CONTEXT_ENTER_PIN_CARRIER = 17;
+static const int PMF_RESOURCE_ID_CONTEXT_SYSTEM_UPDATE_IN_PROGRESS = 18;
+static const int PMF_RESOURCE_ID_CONTEXT_DO_YOU_WANT_TO_ACCEPT_UPDATE = 19;
+static const int PMF_RESOURCE_ID_CONNECTING_TO_UPDATE_SERVICE = 20;
+static const int PMF_RESOURCE_ID_CONTEXT_SYSTEM_UPDATE_COMPLETED = 21;
+static const int PMF_RESOURCE_ID_CONTEXT_CONNECTION_SUCCEEDED = 22;
+static const int PMF_RESOURCE_ID_CONTEXT_PIN_FAILED_TRY_AGAIN = 23;
+static const int PMF_RESOURCE_ID_CONTEXT_PIN_FAILED_CONTACT_CARRIER = 24;
+static const int PMF_RESOURCE_ID_CONTEXT_SYSTEM_UPDATE_FAILED_CONTACT_CARRIER = 25;
+static const int PMF_RESOURCE_ID_CONTEXT_CONNECTION_FAILED = 26;
+static const int PMF_RESOURCE_ID_CONTEXT_SYSTEM_UPDATE_CANCELLED = 27;
+static const int PMF_RESOURCE_ID_CONTEXT_PLEASE_SELECT_BROWSER_PROFILE = 28;
+static const int PMF_RESOURCE_ID_CONTEXT_PLEASE_SELECT_MMS_PROFILE = 29;
+static const int PMF_RESOURCE_ID_CONTEXT_AUTH_FAILED_CONTACT_CARRIER = 30;
+static const int PMF_RESOURCE_ID_CONTEXT_NWNOT_AVAILABLE = 31;
+static const int PMF_RESOURCE_ID_CONTEXT_CONNECT_ERROR = 32;
+static const int PMF_RESOURCE_ID_CONTEXT_SW_UPDATE = 33;
+static const int PMF_RESOURCE_ID_CONTEXT_CONNECTING = 34;
+
+class DMServiceAlert
+{
+public:
+
+ /**
+ * Constructor.
+ */
+ DMServiceAlert();
+
+ /**
+ * Destructor
+ */
+ ~DMServiceAlert();
+
+ /**
+ * Display a text message alert.
+ *
+ * \param[in] minDisplayTime minimum display time, in seconds.
+ * \param[in] msg message to display
+ * \return SYNCML_DM_STATUS_T::SUCCESS on success; otherwise returns error code.
+ */
+ SYNCML_DM_RET_STATUS_T showDisplayAlert(INT32 minDisplayTime, const DMString& msg,
+ INT32 title = DM_SERVICE_ALERT_TITLE_NULL, INT32 icon = DM_SERVICE_ALERT_ICON_GENERIC);
+
+ /**
+ * Display a confirm alert message box; user can confirm or cancel the action.
+ *
+ * \param[in] maxDisplayTime maximum display time (for timeout), in seconds.
+ * \param[in] msg message to display
+ * \param[in] defaultResponse default user action when timeout
+ * \param[out] response user's action will be returned here.
+ * \return SYNCML_DM_STATUS_T::SUCCESS on success; otherwise returns error code.
+ */
+ SYNCML_DM_RET_STATUS_T showConfirmAlert(INT32 maxDisplayTime, const DMString& msg,
+ XPL_DM_ALERT_RES_T defaultResponse, XPL_DM_ALERT_RES_T* response,
+ INT32 title = DM_SERVICE_ALERT_TITLE_NULL, INT32 icon = DM_SERVICE_ALERT_ICON_GENERIC);
+
+ /**
+ * Display a text input message box for user to enter input.
+ *
+ * \param[in] maxDisplayTime maximum display time (for timeout), in seconds.
+ * \param[in] msg message to display
+ * \param[in] defaultResponse default user action when timeout
+ * \param[in] maxLength length allowed in user input
+ * \param[in] inputType data format as specified in DM_ALERT_INPUT_T
+ * \param[in] echoType whether to echo user input (hidden for password)
+ * \param[out] response hold user's response action and input data.
+ * \return SYNCML_DM_STATUS_T::SUCCESS on success; otherwise returns error code.
+ */
+ SYNCML_DM_RET_STATUS_T showTextInputAlert(INT32 maxDisplayTime, const DMString& msg,
+ const DMString& defaultResponse, INT32 maxLength, XPL_DM_ALERT_INPUT_T inputType,
+ XPL_DM_ALERT_ECHO_T echoType, XPL_DM_ALERT_TEXTINPUT_RES_T* response,
+ INT32 title = DM_SERVICE_ALERT_TITLE_NULL, INT32 icon = DM_SERVICE_ALERT_ICON_GENERIC);
+
+ /**
+ * Display a single choice message box for user to select one entry.
+ *
+ * \param[in] maxDisplayTime maximum display time (for timeout), in seconds.
+ * \param[in] msg message to display
+ * \param[in] choices a string vector to hold text for each choice
+ * \param[in] defaultResponse default user action when timeout
+ * \param[out] response hold user's response action and selected choice.
+ * \return SYNCML_DM_STATUS_T::SUCCESS on success; otherwise returns error code.
+ */
+ SYNCML_DM_RET_STATUS_T showSingleChoiceAlert(INT32 maxDisplayTime, const DMString& msg,
+ const DMStringVector& choices, INT32 defaultResponse,
+ XPL_DM_ALERT_SCHOICE_RES_T* response, INT32 title = DM_SERVICE_ALERT_TITLE_NULL,
+ INT32 icon = DM_SERVICE_ALERT_ICON_GENERIC);
+
+ /**
+ * Display a multiple choice message box for user to select zero to many entries.
+ *
+ * \param[in] maxDisplayTime maximum display time (for timeout), in seconds.
+ * \param[in] msg message to display
+ * \param[in] choices a string vector to hold text for each choice
+ * \param[in] defaultResponses holds default responses in an array of string representation of
+ * selected indexes (starting from 1)
+ * \param[out] response hold user's response action and selected choice.
+ * \return SYNCML_DM_STATUS_T::SUCCESS on success; otherwise returns error code.
+ */
+ SYNCML_DM_RET_STATUS_T showMultipleChoiceAlert(INT32 maxDisplayTime, const DMString& msg,
+ const DMStringVector& choices, const DMStringVector& defaultResponses,
+ XPL_DM_ALERT_MCHOICE_RES_T* response, INT32 title = DM_SERVICE_ALERT_TITLE_NULL,
+ INT32 icon = DM_SERVICE_ALERT_ICON_GENERIC);
+
+private:
+
+ JNIEnv* m_jDmEnv;
+ jclass m_jDmAlertCls;
+ jobject m_jDmAlertObj;
+ jmethodID m_jDmAlertMID;
+
+ bool isJvmNull() {
+ return (m_jDmEnv == NULL || m_jDmAlertCls == NULL || m_jDmAlertObj == NULL);
+ }
+};
+
+#endif /* DMSERVICEALERT_H */
diff --git a/engine/jni/DMServiceConnection.cc b/engine/jni/DMServiceConnection.cc
new file mode 100644
index 0000000..e143859
--- /dev/null
+++ b/engine/jni/DMServiceConnection.cc
@@ -0,0 +1,324 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef PLATFORM_ANDROID
+
+#include "dm_tpt_connection.H"
+#include "dm_tpt_utils.h"
+#include "DMServiceMain.h"
+#include <android_runtime/AndroidRuntime.h>
+
+SYNCML_DM_OTAConnection::SYNCML_DM_OTAConnection() : m_maxAcptSize(0), m_szURL()
+{
+ JNIEnv* jEnv = NULL;
+
+ if (android::AndroidRuntime::getJavaVM()) {
+ jEnv = android::AndroidRuntime::getJNIEnv();
+ m_jNetConnObj = getNetConnector();
+ } else {
+ return;
+ }
+
+ jclass jNetConnCls = jEnv->GetObjectClass(m_jNetConnObj);
+ if (jNetConnCls == NULL) {
+ LOGD(("FindClass return Error"));
+ goto end;
+ }
+
+ m_jSendRequest = jEnv->GetMethodID(jNetConnCls, "sendRequest",
+ "(Ljava/lang/String;[BLjava/lang/String;)I");
+ if (m_jSendRequest == NULL) {
+ LOGD(("GetMethod 'sendRequest' return Error"));
+ goto end;
+ }
+
+ m_jGetRespLength = jEnv->GetMethodID(jNetConnCls, "getResponseLength", "()J");
+ if (m_jGetRespLength == NULL) {
+ LOGD(("GetMethod 'getResponseLength' return Error"));
+ goto end;
+ }
+
+ m_jGetRespData = jEnv->GetMethodID(jNetConnCls, "getResponseData", "()[B");
+ if (m_jGetRespData == NULL) {
+ LOGD(("GetMethod 'getResponseData' return Error"));
+ goto end;
+ }
+
+ m_jSetContentType = jEnv->GetMethodID(jNetConnCls, "setContentType", "(Ljava/lang/String;)V");
+ if (m_jSetContentType == NULL) {
+ LOGD(("GetMethod 'setContentType' return Error"));
+ goto end;
+ }
+
+ m_jEnbleApnByName = jEnv->GetMethodID(jNetConnCls, "enableApnByName", "(Ljava/lang/String;)V");
+ if (m_jEnbleApnByName == NULL) {
+ LOGD(("GetMethod 'enableApnByName' return Error"));
+ goto end;
+ }
+
+ LOGD("constructed successfully");
+end:
+ return;
+}
+
+SYNCML_DM_OTAConnection::~SYNCML_DM_OTAConnection()
+{
+ LOGD("~SYNCML_DM_OTAConnection()");
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_OTAConnection::Init(UINT32 dwMaxAcptSize, XPL_ADDR_TYPE_T AddressType,
+ CPCHAR ConRef)
+{
+ LOGD("dwMaxAcptSize=%d, AddressType=%d", dwMaxAcptSize, AddressType);
+
+ if (ConRef != NULL) {
+ LOGD("ConRef=%s", ConRef);
+ JNIEnv* jEnv = android::AndroidRuntime::getJNIEnv();
+ jstring jConRef = jEnv->NewStringUTF(ConRef);
+ jEnv->CallVoidMethod(m_jNetConnObj, m_jEnbleApnByName, jConRef);
+ }
+
+ m_maxAcptSize = dwMaxAcptSize;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_OTAConnection::Send(const SYNCML_DM_INDIRECT_BUFFER_T* psSendSyncMLDocument,
+ SYNCML_DM_INDIRECT_BUFFER_T* psRecvSyncMLDocument, const UINT8* pbContType,
+ const DMCredHeaders* psCredHdr)
+{
+ LOGD("Send=%d", psSendSyncMLDocument->dataSize);
+
+ if ((psSendSyncMLDocument == NULL) ||
+ (psSendSyncMLDocument->pData == NULL) ||
+ (psSendSyncMLDocument->dataSize == 0 ))
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+ if ((psRecvSyncMLDocument == NULL) ||
+ (psRecvSyncMLDocument->pData == NULL))
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+ if ((pbContType == NULL) || (pbContType[0] == '\0'))
+ {
+ return SYNCML_DM_FAIL;
+ }
+
+ // Check whether psCredHdr is valid
+ if (!psCredHdr->isCorrect())
+ return SYNCML_DM_FAIL;
+
+ JNIEnv* jEnv = android::AndroidRuntime::getJNIEnv();
+
+ jstring jContentType = jEnv->NewStringUTF((const char*)pbContType);
+ jEnv->CallVoidMethod(m_jNetConnObj, m_jSetContentType, jContentType);
+
+ CPCHAR strUrl = m_szURL.c_str();
+ LOGD("url=%s", strUrl);
+ jstring jurl = jEnv->NewStringUTF(strUrl);
+ jbyteArray jDataArray = jEnv->NewByteArray(psSendSyncMLDocument->dataSize);
+ jEnv->SetByteArrayRegion(jDataArray,
+ 0, psSendSyncMLDocument->dataSize,
+ (const jbyte*)psSendSyncMLDocument->pData);
+
+ int wNumRetries = 0;
+
+ jstring jstrMac = NULL;
+ if (psCredHdr->empty() == FALSE) {
+ DMString strHMAC;
+ strHMAC += "algorithm=MD5,username=\"";
+ strHMAC += reinterpret_cast<CPCHAR>(psCredHdr->m_oUserName.getBuffer());
+ strHMAC += "\",mac=";
+ strHMAC += reinterpret_cast<CPCHAR>(psCredHdr->m_oMac.getBuffer());
+ LOGD("mac length=%d", psCredHdr->m_oMac.getSize());
+ //LOGD("mac value in hex:%x", psCredHdr->m_oMac.getBuffer());
+ LOGD("hmac value=%s", strHMAC.c_str());
+ jstrMac = jEnv->NewStringUTF(strHMAC.c_str());
+ }
+
+ SYNCML_DM_RET_STATUS_T jResult = SYNCML_DM_FAIL;
+
+ while (wNumRetries < DMTPT_MAX_RETRIES)
+ {
+ jResult = static_cast<SYNCML_DM_RET_STATUS_T>(jEnv->CallIntMethod(
+ m_jNetConnObj, m_jSendRequest, jurl, jDataArray, jstrMac /*hmac*/));
+
+ LOGD("Send result=%d", static_cast<int>(jResult));
+
+ // retry for timeout or general connection errors
+ if (jResult == SYNCML_DM_SOCKET_TIMEOUT
+ || jResult == SYNCML_DM_SOCKET_CONNECT_ERR
+ || jResult == SYNCML_DM_UNKNOWN_HOST
+ || jResult == SYNCML_DM_NO_HTTP_RESPONSE
+ || jResult == SYNCML_DM_REQUEST_TIMEOUT
+ || jResult == SYNCML_DM_INTERRUPTED
+ || jResult == SYNCML_DM_SERVICE_UNAVAILABLE
+ || jResult == SYNCML_DM_GATEWAY_TIMEOUT)
+ {
+ wNumRetries++;
+
+ // FIXME: thread blocks here on sleep for 10 seconds
+ ::sleep(15); // sleep a little bit before trying again
+ continue;
+ }
+
+ if (static_cast<int>(jResult) == 200) {
+ jlong jResponseLen = jEnv->CallLongMethod(m_jNetConnObj, m_jGetRespLength);
+ LOGD("response length=%lld", jResponseLen);
+ if(jResponseLen > 0 && jResponseLen <= m_maxAcptSize){
+ jbyteArray jData = (jbyteArray)jEnv->CallObjectMethod(m_jNetConnObj, m_jGetRespData);
+ jEnv->GetByteArrayRegion(jData, 0, jResponseLen, (jbyte*)psRecvSyncMLDocument->pData);
+ psRecvSyncMLDocument->dataSize = jResponseLen;
+ //Get header:x-syncml-hmac
+ m_pCredHeaders = (DMCredHeaders*)psCredHdr;
+ m_pCredHeaders->clear();
+ jstring jstrHMAC = jEnv->NewStringUTF("x-syncml-hmac");
+ jobject jobjHMACValue = NULL;
+ jclass jNetConnCls = jEnv->GetObjectClass(m_jNetConnObj);
+ jmethodID jmethodGetHeader = jEnv->GetMethodID(jNetConnCls, "getResponseHeader","(Ljava/lang/String;)Ljava/lang/String;");
+ jobjHMACValue = jEnv->CallObjectMethod(m_jNetConnObj, jmethodGetHeader, jstrHMAC);
+ if(jobjHMACValue != NULL)
+ {
+ LOGD("Get hmac header successfully!");
+ const char * strHMACValue = jEnv->GetStringUTFChars(static_cast<jstring>(jobjHMACValue), NULL);
+ LOGD("hmac value=%s", strHMACValue);
+ if(strHMACValue != NULL && strlen(strHMACValue) > 0)
+ {
+ ProcessCredHeaders(strHMACValue);
+ }
+ LOGD("Finish process hmac header!");
+ LOGD("m_pCredHeaders: algorithm:%s", ((CPCHAR)m_pCredHeaders->m_oAlgorithm.getBuffer()));
+ LOGD("m_pCredHeaders: username:%s", ((CPCHAR)m_pCredHeaders->m_oUserName.getBuffer()));
+ LOGD("m_oRecvCredHeaders: mac:%s", ((CPCHAR)m_pCredHeaders->m_oMac.getBuffer()));
+
+ jEnv->ReleaseStringUTFChars(static_cast<jstring>(jobjHMACValue), strHMACValue);
+ }
+ LOGD("Return OK");
+ return SYNCML_DM_SUCCESS;
+ }
+ LOGD("Too much data was received!");
+ return SYNCML_DM_FAIL;
+ } else {
+ LOGD("Not retryable network error!");
+ break;
+ }
+ }
+
+ LOGD("Server or Net issue. return code=%d", static_cast<int>(jResult));
+ return jResult;
+}
+
+SYNCML_DM_RET_STATUS_T SYNCML_DM_OTAConnection::SetURI(CPCHAR szURL)
+{
+ LOGD("szURL=%s", szURL);
+ m_szURL = szURL;
+
+ return SYNCML_DM_SUCCESS;
+}
+
+//==============================================================================
+// FUNCTION: SYNCML_DM_OTAConnection::ProcessCredHeaders
+//
+// DESCRIPTION: This method extracts the Credential headers from the
+// Response headers
+//
+// ARGUMENTS PASSED: the HMAC string
+// RETURN VALUE:
+// SYNCML_DM_SUCCESS on success
+// SYNCML_DM_FAIL on any failure
+//
+// IMPORTANT NOTES: The HandleOTARedirect method calls this method.
+//==============================================================================
+SYNCML_DM_RET_STATUS_T
+SYNCML_DM_OTAConnection::ProcessCredHeaders(CPCHAR origHmacStr)
+{
+ LOGD(("Enter SYNCML_DM_OTAConnection::ProcessCredHeaders"));
+
+ if (origHmacStr == NULL)
+ return SYNCML_DM_FAIL;
+
+ // Trim the blank space and tabs
+ DMString hmacString;
+ size_t origHmacStrLen = ::strlen(origHmacStr);
+ for (size_t i = 0; i < origHmacStrLen; ++i)
+ {
+ char c = origHmacStr[i];
+ if (c != ' ' && c != '\t')
+ hmacString += c;
+ }
+
+ // make R/W copy of hmac string and clear the C++ string.
+ // TODO: convert this logic to use C++ strings.
+ char* initialHmacString = new char[hmacString.length() + 1];
+ memcpy(initialHmacString, hmacString.c_str(), (hmacString.length() + 1));
+ hmacString.clear();
+
+ UINT8* pbParam = NULL;
+ UINT8* pbValue = NULL;
+ char* pbAlgo = NULL;
+ char* pbUname = NULL;
+ char* pbMAC = NULL;
+
+ UINT8* pbHmacString = reinterpret_cast<UINT8*>(DmStrstr(initialHmacString, "algorithm"));
+
+ if (pbHmacString == NULL)
+ pbHmacString = reinterpret_cast<UINT8*>(DmStrstr(initialHmacString, "username"));
+
+ // Extract the algorithm, Username and mac from the x-syncml-hmac header
+ while (pbHmacString != NULL)
+ {
+ pbHmacString = DM_TPT_splitParamValue(pbHmacString, &pbParam, &pbValue);
+
+ if ((pbParam != NULL) && (pbParam[0] != '\0'))
+ {
+ if (!strcmp((CPCHAR)pbParam, "algorithm"))
+ {
+ pbAlgo = reinterpret_cast<char*>(pbValue);
+ }
+ else if (!strcmp((CPCHAR)pbParam, "username"))
+ {
+ pbUname = reinterpret_cast<char*>(pbValue);
+ }
+ else if (!strcmp((CPCHAR)pbParam, "mac"))
+ {
+ pbMAC = reinterpret_cast<char*>(pbValue);
+ }
+ }
+ }
+
+ // Allocate memory to hold username, mac, algorithm
+ if (pbUname == NULL || pbMAC == NULL)
+ {
+ delete[] initialHmacString;
+ return SYNCML_DM_FAIL;
+ }
+
+ m_pCredHeaders->m_oAlgorithm.assign((pbAlgo != NULL) ? pbAlgo : "MD5");
+ m_pCredHeaders->m_oUserName.assign(pbUname);
+ m_pCredHeaders->m_oMac.assign(pbMAC);
+
+ delete[] initialHmacString;
+
+ LOGD(("Leave SYNCML_DM_OTAConnection::ProcessCredHeaders"));
+ return SYNCML_DM_SUCCESS;
+}
+
+#endif
diff --git a/engine/jni/DMServiceMain.cc b/engine/jni/DMServiceMain.cc
new file mode 100644
index 0000000..e06010b
--- /dev/null
+++ b/engine/jni/DMServiceMain.cc
@@ -0,0 +1,567 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// don't strip logging from release builds
+#define LOG_NDEBUG 0
+
+#include <android_runtime/AndroidRuntime.h>
+#include "utils/Log.h"
+#include "DMServiceMain.h"
+#include "dmt.hpp"
+#include "DMTreeManager.h"
+static jobject g_sessionObj;
+int g_cancelSession;
+
+//#define LOGV printf
+//#define LOGD printf
+
+
+#define SET_RET_STATUS_BUF \
+ jResult = jenv->NewByteArray(5); char szResult[5]; memset(szResult, 0, 5); \
+ ::snprintf(szResult, 5, "%4d", ret_status); \
+ jenv->SetByteArrayRegion(jResult, 0, 5, (const jbyte*)szResult)
+
+static void Dump(const char* buf, int size, boolean isBinary)
+{
+ if (!isBinary) {
+ // just print the string
+ char* szBuf = new char[size + 1];
+
+ memcpy(szBuf, buf, size);
+ szBuf[size] = 0;
+
+ LOGE("The test script error text:\n\n%s\n\n", szBuf);
+ } else {
+ int nOffset = 0;
+
+ while (size > 0) {
+ int nLine = size > 16 ? 16 : size;
+
+ char s[250];
+ int pos = 0;
+
+ pos += ::snprintf(s + pos, (250 - pos), "%04x:", nOffset);
+
+ for (int i = 0; i < nLine; i++) {
+ pos += ::snprintf(s + pos, (250 - pos), " %02x", (unsigned int)((unsigned char) buf[i]) );
+ }
+ for (int i = nLine; i < 16; i++) {
+ pos += ::snprintf(s + pos, (250 - pos), " ");
+ }
+
+ pos += ::snprintf(s + pos, (250 - pos), " ");
+ for (int i = 0; i < nLine; i++) {
+ pos += ::snprintf(s + pos, (250 - pos), "%c", (buf[i] > 31 ? buf[i] : '.') );
+ }
+
+ LOGE("%s\n", s);
+ buf += nLine;
+ size -= nLine;
+ nOffset += nLine;
+ }
+ }
+}
+
+/**
+ * check the input string is a a valid UTF-8 string or not
+ * 1 -- valid, 0 -- invalid
+ */
+static jint isUtf8Valid(const char* bytes) {
+ while (*bytes != '\0') {
+ uint8_t utf8 = *(bytes++);
+ // Switch on the high four bits.
+ switch (utf8 >> 4) {
+ case 0x00:
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07:
+ // Bit pattern 0xxx. No need for any extra bytes.
+ break;
+ case 0x08:
+ case 0x09:
+ case 0x0a:
+ case 0x0b:
+ case 0x0f:
+ /*
+ * Bit pattern 10xx or 1111, which are illegal start bytes.
+ * Note: 1111 is valid for normal UTF-8, but not the
+ * Modified UTF-8 used here.
+ */
+ return 0;
+ case 0x0e:
+ // Bit pattern 1110, so there are two additional bytes.
+ utf8 = *(bytes++);
+ if ((utf8 & 0xc0) != 0x80) {
+ return 0;
+ }
+ // Fall through to take care of the final byte.
+ case 0x0c:
+ case 0x0d:
+ // Bit pattern 110x, so there is one additional byte.
+ utf8 = *(bytes++);
+ if ((utf8 & 0xc0) != 0x80) {
+ return 0;
+ }
+ break;
+ }
+ }
+ return 1;
+}
+
+
+JNIEXPORT jint
+initialize(JNIEnv* /*env*/, jobject /*jobj*/)
+{
+ LOGD("native initialize");
+ if (!DmtTreeFactory::Initialize()) {
+ LOGE("Failed to initialize DM\n");
+ return static_cast<jint>(SYNCML_DM_FAIL);
+ }
+
+ return static_cast<jint>(SYNCML_DM_SUCCESS);
+}
+
+JNIEXPORT jint
+destroy(JNIEnv* /*env*/, jobject /*jobj*/)
+{
+ LOGD("Enter destroy");
+ if (DmtTreeFactory::Uninitialize() != SYNCML_DM_SUCCESS) {
+ LOGE("Failed to uninitialize DM\n");
+ return static_cast<jint>(SYNCML_DM_FAIL);
+ }
+
+ LOGD("Leave destroy");
+ return static_cast<jint>(SYNCML_DM_SUCCESS);
+}
+
+JNIEXPORT jint
+parsePkg0(JNIEnv* env, jclass, jbyteArray jPkg0, jobject jNotification)
+{
+ LOGD("Enter parsePkg0");
+ jclass notifClass = env->GetObjectClass(jNotification);
+
+ if (jPkg0 == NULL) {
+ return static_cast<jint>(SYNCML_DM_FAIL);
+ }
+
+ jbyte* pkg0Buf = env->GetByteArrayElements(jPkg0, NULL);
+ jsize pkg0Len = env->GetArrayLength(jPkg0);
+
+ DmtNotification notif;
+ DmtPrincipal p("localhost");
+
+ SYNCML_DM_RET_STATUS_T ret = DmtTreeFactory::ProcessNotification(p, (UINT8*)pkg0Buf, (INT32)pkg0Len, notif);
+
+ if(ret == SYNCML_DM_FAIL) {
+ return static_cast<jint>(SYNCML_DM_FAIL);
+ }
+
+ jmethodID jSetServerID = env->GetMethodID( notifClass, "setServerID", "(Ljava/lang/String;)V");
+
+ if(isUtf8Valid(notif.getServerID().c_str())) {
+ jstring jServerID = env->NewStringUTF(notif.getServerID().c_str());
+ env->CallVoidMethod(jNotification, jSetServerID, jServerID);
+ } else {
+ LOGE("Invalid Server ID, not legal UTF8");
+ return static_cast<jint>(SYNCML_DM_FAIL);
+ }
+
+
+ jmethodID jSetSessionID = env->GetMethodID( notifClass, "setSessionID", "(I)V");
+ env->CallVoidMethod(jNotification, jSetSessionID, (jint)notif.getSessionID());
+
+ jmethodID jSetUIMode = env->GetMethodID( notifClass, "setUIMode", "(I)V");
+ env->CallVoidMethod(jNotification, jSetUIMode, (jint)notif.getUIMode());
+
+ jmethodID jSetInitiator = env->GetMethodID( notifClass, "setInitiator", "(I)V");
+ env->CallVoidMethod(jNotification, jSetInitiator, (jint)notif.getInitiator());
+
+ jmethodID jSetAuthFlag = env->GetMethodID( notifClass, "setAuthFlag", "(I)V");
+ env->CallVoidMethod(jNotification, jSetAuthFlag, (jint)notif.getAuthFlag());
+
+ env->ReleaseByteArrayElements(jPkg0, pkg0Buf, 0);
+
+ LOGD("Leave parsePkg0, ret: %d", ret);
+ return static_cast<jint>(ret);
+}
+
+
+JNIEXPORT jint JNICALL startFotaClientSession(JNIEnv* jenv, jclass,
+ jstring jServerId, jstring jAlertStr, jobject jdmobj)
+{
+ LOGV("In native startFotaClientSession\n");
+
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_FAIL;
+ DMString serverID;
+
+ g_sessionObj = jdmobj;
+
+ const char* szDmServerId = jenv->GetStringUTFChars(jServerId, NULL);
+ const char* szDMAlertStr = NULL;
+ if (jAlertStr != NULL) {
+ szDMAlertStr = jenv->GetStringUTFChars(jAlertStr, NULL);
+ }
+
+ DmtPrincipal principal(szDmServerId);
+
+ DMString alertURI("./DevDetail/Ext/SystemUpdate");
+ DMString strEmpty;
+ DmtFirmAlert alert(alertURI, strEmpty, szDMAlertStr, "chr", strEmpty, strEmpty);
+ DmtSessionProp prop(alert, true);
+
+ g_cancelSession = 0;
+
+ ret_status = DmtTreeFactory::StartServerSession(principal, prop);
+
+ if (jAlertStr != NULL) {
+ jenv->ReleaseStringUTFChars(jAlertStr, szDMAlertStr);
+ }
+
+ g_sessionObj = NULL;
+ if (ret_status == SYNCML_DM_SUCCESS) {
+ LOGV("Native startFotaClientSession return successfully\n");
+ return static_cast<jint>(SYNCML_DM_SUCCESS);
+ } else {
+ LOGE("Native startFotaClientSession return error %d\n", ret_status);
+ return static_cast<jint>(ret_status);
+ }
+}
+
+JNIEXPORT jint JNICALL startClientSession(JNIEnv* jenv, jclass,
+ jstring jServerId, jobject jdmobj)
+{
+ LOGV("In native startClientSession\n");
+
+ SYNCML_DM_RET_STATUS_T ret_status = SYNCML_DM_FAIL;
+ DMString serverID;
+
+ g_sessionObj = jdmobj;
+ const char* szDmServerId = jenv->GetStringUTFChars(jServerId, NULL);
+ DmtPrincipal principal(szDmServerId);
+
+ DmtSessionProp prop(true);
+
+ g_cancelSession = 0;
+
+ ret_status = DmtTreeFactory::StartServerSession(principal, prop);
+
+ jenv->ReleaseStringUTFChars(jServerId, szDmServerId);
+
+ g_sessionObj = NULL;
+ if (ret_status == SYNCML_DM_SUCCESS) {
+ LOGV("Native startClientSession return successfully\n");
+ } else {
+ LOGV("Native startClientSession return error %d\n", ret_status);
+ }
+ return static_cast<jint>(ret_status);
+}
+
+JNIEXPORT jint JNICALL startFotaServerSession(JNIEnv* jenv, jclass,
+ jstring jServerId, jint sessionID, jobject jdmobj)
+{
+ LOGV("In native startFotaServerSession\n");
+
+ g_sessionObj = jdmobj;
+
+ const char* szDmServerId = jenv->GetStringUTFChars(jServerId, NULL);
+ DmtPrincipal principal(szDmServerId);
+ DmtSessionProp prop(static_cast<UINT16>(sessionID), true);
+
+ g_cancelSession = 0;
+
+ SYNCML_DM_RET_STATUS_T ret_status = DmtTreeFactory::StartServerSession(principal, prop);
+
+ jenv->ReleaseStringUTFChars(jServerId, szDmServerId);
+
+ g_sessionObj = NULL;
+
+ if (ret_status == SYNCML_DM_SUCCESS) {
+ LOGV("Native startFotaServerSession return successfully\n");
+ } else {
+ LOGV("Native startFotaServerSession return error %d\n", ret_status);
+ }
+ return static_cast<jint>(ret_status);
+}
+
+JNIEXPORT jint JNICALL startFotaNotifySession(JNIEnv* jenv, jclass,
+ jstring result, jstring pkgURI, jstring alertType,
+ jstring serverID, jstring correlator, jobject jdmobj)
+{
+ g_sessionObj = jdmobj;
+
+ const char* szResult = jenv->GetStringUTFChars(result, NULL);
+ const char* szPkgURI = jenv->GetStringUTFChars(pkgURI, NULL);
+ const char* szAlertType = jenv->GetStringUTFChars(alertType, NULL);
+ const char* szDmServerId = jenv->GetStringUTFChars(serverID, NULL);
+ const char* szCorrelator = jenv->GetStringUTFChars(correlator, NULL);
+
+ DmtPrincipal principal(szDmServerId);
+ DmtFirmAlert alert(szPkgURI, szResult, szAlertType, "chr", NULL, szCorrelator);
+ DmtSessionProp prop(alert, true);
+
+ SYNCML_DM_RET_STATUS_T dm_result = SYNCML_DM_SUCCESS;
+ g_cancelSession = 0;
+
+ dm_result = DmtTreeFactory::StartServerSession(principal, prop);
+
+ jenv->ReleaseStringUTFChars(result, szResult);
+ jenv->ReleaseStringUTFChars(pkgURI, szPkgURI);
+ jenv->ReleaseStringUTFChars(alertType, szAlertType);
+ jenv->ReleaseStringUTFChars(serverID, szDmServerId);
+ jenv->ReleaseStringUTFChars(correlator, szCorrelator);
+
+ g_sessionObj = NULL;
+ if (dm_result == SYNCML_DM_SUCCESS) {
+ LOGV("Native startFotaNotifySession return successfully\n");
+ } else {
+ LOGV("Native startFotaNotifySession return error %d\n", dm_result);
+ }
+ return static_cast<jint>(dm_result);
+}
+
+jobject getNetConnector()
+{
+ JNIEnv* env = android::AndroidRuntime::getJNIEnv();
+
+ jclass jdmSessionClz = env->GetObjectClass(g_sessionObj);
+ jmethodID jgetNet = env->GetMethodID(jdmSessionClz,
+ "getNetConnector",
+ "()Lcom/android/omadm/service/DMHttpConnector;");
+ return env->CallObjectMethod(g_sessionObj, jgetNet);
+}
+
+jobject getDMAlert(JNIEnv* env)
+{
+ LOGD(("DM Alert: enter getDMAlert()"));
+ if (NULL == g_sessionObj) {
+ LOGE(("DM Alert: g_sessionObj is NULL!"));
+ return NULL;
+ }
+
+ jclass jdmSessionClz = env->GetObjectClass(g_sessionObj);
+ if (NULL == jdmSessionClz) {
+ LOGE(("DM Alert: env->GetObjectClass(g_sessionObj) failed!"));
+ return NULL;
+ }
+ LOGD(("DM Alert: success env->GetObjectClass(...)"));
+
+ jmethodID jdmGetDMAlert = env->GetMethodID(jdmSessionClz,
+ "getDMAlert",
+ "()Lcom/android/omadm/service/DMAlert;");
+ if ( NULL == jdmGetDMAlert ) {
+ LOGE(("DM Alert: env->GetMethodID(jdmSessionClz) failed!"));
+ return NULL;
+ }
+ LOGD(("DM Alert: success env->GetMethodID(...)"));
+
+ return env->CallObjectMethod(g_sessionObj, jdmGetDMAlert);
+}
+
+JNIEXPORT jint JNICALL cancelSession(JNIEnv*, jclass)
+{
+ g_cancelSession = 1;
+ return static_cast<jint>(SYNCML_DM_SUCCESS);
+}
+
+JNIEXPORT jstring JNICALL parseBootstrapServerId(JNIEnv* jenv, jclass, jbyteArray jMsgBuf,
+ jboolean isWbxml)
+{
+ jint retCode = 0;
+ jstring jServerId = NULL;
+
+ SYNCML_DM_RET_STATUS_T dm_ret_status;
+
+ jbyte* jBuf = jenv->GetByteArrayElements(jMsgBuf, NULL);
+ jsize jBufSize = jenv->GetArrayLength(jMsgBuf);
+
+ DmtPrincipal principal("DM_BOOTSTRAP");
+ DMString strServerId;
+ dm_ret_status = DmtTreeFactory::Bootstrap(principal, (const UINT8*)jBuf, jBufSize, isWbxml,
+ false, strServerId);
+
+ LOGD("parseBootstrapServerId dm_ret_status: %d", dm_ret_status);
+
+ if (dm_ret_status == SYNCML_DM_SUCCESS && !strServerId.empty()) {
+ LOGD("parseBootstrapServerId returns strServerId: %s", strServerId.c_str());
+ jServerId = jenv->NewStringUTF(strServerId.c_str());
+ }
+
+ return jServerId;
+}
+
+JNIEXPORT jint JNICALL processBootstrapScript(JNIEnv* jenv, jclass, jbyteArray jMsgBuf, jboolean isWbxml, jstring jServerId)
+{
+ SYNCML_DM_RET_STATUS_T dm_ret_status;
+ const char* szDmServerId = jenv->GetStringUTFChars(jServerId, NULL);
+
+ jbyte* jBuf = jenv->GetByteArrayElements(jMsgBuf, NULL);
+ jsize jBufSize = jenv->GetArrayLength(jMsgBuf);
+
+ DmtPrincipal principal("DM_BOOTSTRAP");
+ DMString strServerId(szDmServerId);
+ dm_ret_status = DmtTreeFactory::Bootstrap(
+ principal, (const UINT8*)jBuf, jBufSize, isWbxml, true, strServerId);
+
+ LOGD("processBootstrapScript dm_ret_status: %d", static_cast<jint>(dm_ret_status));
+
+ return static_cast<jint>(dm_ret_status);
+}
+
+
+JNIEXPORT jbyteArray JNICALL processScript(JNIEnv* jenv, jclass, jstring jServerId,
+ jstring jFileName, jboolean jIsBinary, jint /*jRetCode*/, jobject jdmobj)
+{
+ LOGV("In native processScript\n");
+ g_sessionObj = jdmobj;
+
+ jbyteArray jResult = NULL;
+ SYNCML_DM_RET_STATUS_T ret_status;
+
+ const char* szDmServerId = jenv->GetStringUTFChars(jServerId, NULL);
+
+ if (szDmServerId == NULL) {
+ ret_status = SYNCML_DM_DEVICE_FULL;
+ SET_RET_STATUS_BUF;
+ return jResult;
+ }
+
+ const char* szFileName = jenv->GetStringUTFChars(jFileName, NULL);
+ if (szFileName == NULL) {
+ jenv->ReleaseStringUTFChars(jServerId, szDmServerId);
+ ret_status = SYNCML_DM_DEVICE_FULL;
+ SET_RET_STATUS_BUF;
+ return jResult;
+ }
+
+ LOGV("native processScript reading file <%s>\n", szFileName);
+
+ FILE *fd = fopen(szFileName, "r");
+ if (!fd) {
+ LOGV("native processScript can't open file %s", szFileName);
+ ret_status = SYNCML_DM_FILE_NOT_FOUND;
+ SET_RET_STATUS_BUF;
+ return jResult;
+ }
+
+ // assume 100k is enough
+ const int c_nSize = 100 * 1024;
+ char* szBuf = new char[c_nSize];
+
+ if (szBuf == NULL) {
+ ret_status = SYNCML_DM_DEVICE_FULL;
+ SET_RET_STATUS_BUF;
+ return jResult;
+ }
+
+ int buf_size = fread(szBuf, 1, c_nSize, fd );
+ LOGE("native processScript read %d bytes, jIsBinary=%d\n", buf_size, jIsBinary);
+
+
+ if (buf_size > 0) {
+ DmtPrincipal principal(szDmServerId);
+ DMVector<UINT8> bResult;
+
+ ret_status = DmtTreeFactory::ProcessScript(principal, (const UINT8*)szBuf, buf_size, jIsBinary, bResult);
+
+ // copy bResult to jResult
+ int resultSize = bResult.size();
+
+ if (resultSize > 0) {
+ //Dump((const char*)&bResult.front(), resultSize, jIsBinary);
+ Dump((const char*)bResult.get_data(), resultSize, jIsBinary);
+
+ jResult = jenv->NewByteArray(resultSize);
+
+ //jenv->SetByteArrayRegion(jResult, 0, resultSize, (const jbyte*)&bResult.front());
+ jenv->SetByteArrayRegion(jResult, 0, resultSize, (const jbyte*)bResult.get_data());
+ }
+ else {
+ SET_RET_STATUS_BUF;
+ }
+ }
+ else {
+ // read 0 bytes from script file
+ ret_status = SYNCML_DM_IO_FAILURE;
+ SET_RET_STATUS_BUF;
+ }
+
+ // release memory allocated from GetStringUTFChars
+ jenv->ReleaseStringUTFChars(jServerId, szDmServerId);
+ jenv->ReleaseStringUTFChars(jFileName, szFileName);
+
+
+ LOGV("Native processScript return code %d\n", static_cast<jint>(ret_status));
+ g_sessionObj = NULL;
+
+ return jResult;
+}
+
+
+static JNINativeMethod gMethods[] = {
+ {"initialize", "()I", (void*)initialize},
+ {"destroy", "()I", (void*)destroy},
+ {"parsePkg0", "([BLcom/android/omadm/service/DMPkg0Notification;)I", (void*)parsePkg0},
+ {"startFotaClientSession",
+ "(Ljava/lang/String;Ljava/lang/String;Lcom/android/omadm/service/DMSession;)I",
+ (void*)startFotaClientSession},
+ {"startFotaServerSession", "(Ljava/lang/String;ILcom/android/omadm/service/DMSession;)I",
+ (void*)startFotaServerSession},
+ {"startClientSession", "(Ljava/lang/String;Lcom/android/omadm/service/DMSession;)I",
+ (void*)startClientSession},
+
+ {"startFotaNotifySession",
+ "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/android/omadm/service/DMSession;)I",
+ (void*)startFotaNotifySession},
+
+ {"cancelSession", "()I", (void*)cancelSession},
+
+ {"processScript",
+ "(Ljava/lang/String;Ljava/lang/String;ZILcom/android/omadm/service/DMSession;)[B",
+ (void*)processScript},
+};
+
+int registerNatives(JNIEnv* env)
+{
+ jclass clazz = env->FindClass(javaDMEnginePackage);
+ if (clazz == NULL)
+ return JNI_FALSE;
+
+ if (env->RegisterNatives(clazz, gMethods, sizeof(gMethods)/sizeof(gMethods[0])) < 0) {
+ LOGE("registerNatives return ERROR");
+ return JNI_FALSE;
+ }
+
+ registerDMTreeNatives(env);
+ return JNI_TRUE;
+}
+
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM* /*vm*/, void* /*reserved*/)
+{
+ LOGD("In JNI_OnLoad");
+ JNIEnv* env = android::AndroidRuntime::getJNIEnv();
+
+ if (env == NULL) {
+ LOGE("Get Environment Error");
+ return -1;
+ }
+
+ return (registerNatives(env) == JNI_TRUE) ? JNI_VERSION_1_6 : -1;
+}
diff --git a/engine/jni/DMServiceMain.h b/engine/jni/DMServiceMain.h
new file mode 100644
index 0000000..045dd5a
--- /dev/null
+++ b/engine/jni/DMServiceMain.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Header for class DMServiceMain.cc */
+
+#ifndef DM_SERVICE_HEADER__
+#define DM_SERVICE_HEADER__
+
+#include <jni.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <cutils/log.h>
+
+#ifndef LOGD
+#define LOGD(args...) ALOGD(args)
+#endif
+
+#ifndef LOGE
+#define LOGE(args...) ALOGE(args)
+#endif
+
+#ifndef LOGI
+#define LOGI(args...) ALOGI(args)
+#endif
+
+#ifndef LOGV
+#define LOGV(args...) ALOGV(args)
+#endif
+
+#ifndef LOGW
+#define LOGW(args...) ALOGW(args)
+#endif
+
+static const char* const javaDMEnginePackage = "com/android/omadm/service/NativeDM";
+
+jobject getNetConnector();
+jobject getDMAlert(JNIEnv *env);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/engine/jni/DMTreeManager.cc b/engine/jni/DMTreeManager.cc
new file mode 100755
index 0000000..2cfed39
--- /dev/null
+++ b/engine/jni/DMTreeManager.cc
@@ -0,0 +1,575 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android_runtime/AndroidRuntime.h>
+#include "utils/Log.h"
+#include "DMServiceMain.h"
+#include "dmt.hpp"
+#include <stdarg.h>
+#include <dmMemory.h>
+
+extern "C" {
+#include "xltdec.h"
+}
+
+static const int RESULT_BUF_SIZE = 8192; /*2048*/
+
+// FIXME: get rid of these static variables!
+static PDmtTree ptrTree = NULL;
+static DMString s_strRootPath;
+static DmtPrincipal principal("localhost");
+static bool bShowTimestamp = false;
+
+static PDmtTree GetTree();
+static SYNCML_DM_RET_STATUS_T PrintNode(PDmtNode ptrNode);
+static void DumpSubTree(PDmtNode ptrNode);
+
+static char resultBuf[RESULT_BUF_SIZE];
+static void strcatEx(const char * format, ...)
+{
+ if (!format) {
+ return;
+ }
+
+ int len = strlen(resultBuf);
+ if (len < RESULT_BUF_SIZE - 1) {
+ va_list args;
+ va_start(args, format);
+ int ret = vsnprintf(&resultBuf[len], RESULT_BUF_SIZE - len - 1, format, args);
+ if (ret == -1) {
+ resultBuf[RESULT_BUF_SIZE - 1] = 0x0;
+ }
+ va_end(args);
+ }
+}
+
+static PDmtNode GetNode(const DMString& strNodeName)
+{
+ PDmtNode ptrNode;
+ GetTree();
+
+ if (ptrTree) {
+ if (ptrTree->GetNode(strNodeName, ptrNode) != SYNCML_DM_SUCCESS) {
+ strcatEx("can't get node %s", strNodeName.c_str());
+ }
+ }
+
+ return ptrNode;
+}
+
+JNIEXPORT jstring JNICALL setStringNode(JNIEnv* jenv, jclass, jstring nodePath, jstring value)
+{
+ resultBuf[0] = 0x0;
+
+ const char* szNodePath = jenv->GetStringUTFChars(nodePath, NULL);
+ const char* szValue = jenv->GetStringUTFChars(value, NULL);
+
+ DMString strNodePath(szNodePath);
+ DMString strValue(szValue);
+
+ jenv->ReleaseStringUTFChars(nodePath, szNodePath);
+ jenv->ReleaseStringUTFChars(value, szValue);
+
+ PDmtNode ptrNode = GetNode(strNodePath);
+ if (!ptrNode) {
+ goto end;
+ }
+
+ if (ptrNode->SetStringValue(strValue) == SYNCML_DM_SUCCESS) {
+ strcatEx("set value of node %s to %s successfully\n", strNodePath.c_str(), strValue.c_str());
+ PrintNode(ptrNode);
+ } else {
+ strcatEx("can't set value of node %s to %s", strNodePath.c_str(), strValue.c_str());
+ }
+
+end:
+ jstring ret = jenv->NewStringUTF(resultBuf);
+ return ret;
+}
+
+JNIEXPORT jstring JNICALL getNodeInfo(JNIEnv* jenv, jclass, jstring jszNode)
+{
+ resultBuf[0] = 0x0;
+
+ const char* szNode = jenv->GetStringUTFChars(jszNode, NULL);
+ DMString strNode(szNode);
+ jenv->ReleaseStringUTFChars(jszNode, szNode);
+
+ PDmtNode ptrNode = GetNode(strNode);
+ if (ptrNode) {
+ PrintNode(ptrNode);
+ }
+
+ jstring ret = jenv->NewStringUTF(resultBuf);
+ return ret;
+}
+
+JNIEXPORT jint JNICALL getNodeType(JNIEnv* jenv, jclass, jstring jszNode)
+{
+ const char* szNode = jenv->GetStringUTFChars(jszNode, NULL);
+ DMString strNode(szNode);
+ jenv->ReleaseStringUTFChars(jszNode, szNode);
+
+ PDmtNode ptrNode = GetNode(strNode);
+ if (ptrNode && !ptrNode->IsExternalStorageNode())
+ {
+ DmtData oData;
+ LOGD("Enter get value...\n");
+ SYNCML_DM_RET_STATUS_T ret = ptrNode->GetValue(oData);
+ if (ret != SYNCML_DM_SUCCESS) {
+ LOGD("Value is null");
+ return 0; // return NULL type on error
+ }
+ return oData.GetType();
+ }
+
+ return 0; // return NULL type on error
+}
+
+JNIEXPORT jstring JNICALL getNodeValue(JNIEnv* jenv, jclass, jstring jszNode)
+{
+ const char* szNode = jenv->GetStringUTFChars(jszNode, NULL);
+ DMString strNode(szNode);
+ jenv->ReleaseStringUTFChars(jszNode, szNode);
+
+ PDmtNode ptrNode = GetNode(strNode);
+ if (ptrNode && !ptrNode->IsExternalStorageNode())
+ {
+ LOGD("Enter get value...\n");
+ DmtData oData;
+ DMString value;
+
+ if (!ptrNode->IsLeaf()) {
+ SYNCML_DM_RET_STATUS_T ret = ptrNode->GetValue(oData);
+ if (ret != SYNCML_DM_SUCCESS) {
+ LOGE("can't get child nodes");
+ return NULL; // return NULL reference on error
+ }
+ DMStringVector aChildren;
+ ret = oData.GetNodeValue(aChildren);
+ if (ret != SYNCML_DM_SUCCESS) {
+ LOGE("oData.getNodeValue() failed");
+ return NULL; // return NULL reference on error
+ }
+ UINT32 childLength = aChildren.size();
+ for (UINT32 i = 0; i < childLength; ++i) {
+ if (i != 0) {
+ value += '|';
+ }
+ value += aChildren[i];
+ }
+ }
+ else
+ {
+ SYNCML_DM_RET_STATUS_T ret = ptrNode->GetValue(oData);
+ if (ret != SYNCML_DM_SUCCESS) {
+ LOGE("Value is null");
+ return NULL; // return NULL reference on error
+ }
+ if (oData.GetString(value) != SYNCML_DM_SUCCESS) {
+ LOGE("oData.GetString() failed");
+ return NULL; // return NULL reference on error
+ }
+ }
+
+ return jenv->NewStringUTF(value.c_str());
+ }
+
+ return NULL; // return NULL reference on error
+}
+
+JNIEXPORT jstring JNICALL executePlugin(JNIEnv* jenv, jclass, jstring jszNode, jstring jszData)
+{
+ resultBuf[0] = 0x0;
+
+ const char* szNode = jenv->GetStringUTFChars(jszNode, NULL);
+ DMString strNode(szNode);
+ jenv->ReleaseStringUTFChars(jszNode, szNode);
+
+ const char* szData = jenv->GetStringUTFChars(jszData, NULL);
+ DMString strData(szData);
+ jenv->ReleaseStringUTFChars(jszData, szData);
+
+ PDmtNode ptrNode = GetNode(strNode);
+ if (ptrNode) {
+ DMString strResult;
+ if (ptrNode->Execute(strData, strResult) == SYNCML_DM_SUCCESS) {
+ strcatEx("execute node %s successfully, result=%s\n", strNode.c_str(), strResult.c_str());
+ } else {
+ strcatEx("can't execute node %s", strNode.c_str());
+ }
+ }
+
+ jstring ret = jenv->NewStringUTF(resultBuf);
+ return ret;
+}
+
+JNIEXPORT jstring JNICALL dumpTree(JNIEnv *jenv, jclass, jstring jszNode)
+{
+ resultBuf[0] = 0x0;
+
+ const char* szNode = jenv->GetStringUTFChars(jszNode, NULL);
+ DMString strNode(szNode);
+ jenv->ReleaseStringUTFChars(jszNode, szNode);
+
+ PDmtNode ptrNode = GetNode(strNode);
+ if (ptrNode) {
+ DumpSubTree(ptrNode);
+ }
+
+ jstring ret = jenv->NewStringUTF(resultBuf);
+ return ret;
+}
+
+JNIEXPORT jint JNICALL createInterior(JNIEnv *jenv, jclass, jstring jszNode)
+{
+ GetTree();
+ if (!ptrTree) {
+ return static_cast<jint>(SYNCML_DM_FAIL);
+ }
+
+ const char* szNode = jenv->GetStringUTFChars(jszNode, NULL);
+ DMString strNode(szNode);
+ jenv->ReleaseStringUTFChars(jszNode, szNode);
+
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T ret = ptrTree->CreateInteriorNode(strNode, ptrNode);
+ if (ret == SYNCML_DM_SUCCESS) {
+ LOGI("node %s created successfully\n", strNode.c_str());
+ } else {
+ LOGE("can't create node %s", strNode.c_str());
+ }
+ return static_cast<jint>(ret);
+}
+
+JNIEXPORT jint JNICALL createLeaf(JNIEnv *jenv, jclass, jstring jszNode, jstring jszData)
+{
+ if (jszNode == NULL) {
+ return static_cast<jint>(SYNCML_DM_FAIL);
+ }
+
+ GetTree();
+ if (!ptrTree) {
+ return static_cast<jint>(SYNCML_DM_FAIL);
+ }
+
+ const char* szNode = jenv->GetStringUTFChars(jszNode, NULL);
+ const char* szData = NULL;
+
+ if (jszData != NULL) {
+ szData = jenv->GetStringUTFChars(jszData, NULL);
+ }
+
+ PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T ret = ptrTree->CreateLeafNode(szNode, ptrNode, DmtData(szData));
+ if (ret == SYNCML_DM_SUCCESS) {
+ LOGI("node %s (%s) created successfully\n", szNode, szData);
+ } else {
+ LOGE("can't create node %s", szNode);
+ }
+
+ jenv->ReleaseStringUTFChars(jszNode, szNode);
+ jenv->ReleaseStringUTFChars(jszData, szData);
+
+ return static_cast<jint>(ret);
+}
+
+
+JNIEXPORT jint JNICALL createLeafByte(JNIEnv *jenv, jclass clz, jstring jszNode,
+ jbyteArray bDataArray)
+{
+ const char* szNode = jenv->GetStringUTFChars(jszNode, NULL);
+ jbyte* jData = (jbyte*)jenv->GetByteArrayElements(bDataArray, NULL);
+ jsize arraySize = jenv->GetArrayLength(bDataArray);
+
+ char* pData = (char*)DmAllocMem(arraySize+1);
+ memcpy(pData, jData, arraySize);
+ pData[arraySize] = '\0';
+
+ PDmtNode ptrNode;
+ GetTree();
+
+ jenv->ReleaseByteArrayElements(bDataArray, jData, 0);
+
+ if ( ptrTree == NULL ) {
+ DmFreeMem(pData);
+ return SYNCML_DM_FAIL;
+ }
+
+ LOGI("NodePath=%s,Byte Data=0x%X,0x%X,0x%X,0x%X,0x%X,0x%X,0x%X\n", szNode, pData[0], pData[1],
+ pData[2], pData[3], pData[4], pData[5], pData[6]);
+
+ DMString strNode(szNode);
+
+ //PDmtNode ptrNode;
+ SYNCML_DM_RET_STATUS_T ret = ptrTree->CreateLeafNode(szNode, ptrNode, DmtData( pData ));
+ if (ret == SYNCML_DM_SUCCESS) {
+ LOGI("node %s created successfully\n", strNode.c_str());
+ } else {
+ LOGE("can't create node %s", strNode.c_str());
+ }
+ return static_cast<jint>(ret);
+}
+
+JNIEXPORT jint JNICALL deleteNode(JNIEnv *jenv, jclass, jstring jszNode)
+{
+ GetTree();
+ if (!ptrTree) {
+ return static_cast<jint>(SYNCML_DM_FAIL);
+ }
+
+ const char* szNode = jenv->GetStringUTFChars(jszNode, NULL);
+ DMString strNode(szNode);
+ jenv->ReleaseStringUTFChars(jszNode, szNode);
+
+ SYNCML_DM_RET_STATUS_T ret = ptrTree->DeleteNode(strNode);
+ if (ret == SYNCML_DM_SUCCESS) {
+ LOGI("node %s deleted successfully\n", strNode.c_str());
+ } else {
+ LOGE("can't delete node %s", strNode.c_str());
+ }
+ return static_cast<jint>(ret);
+}
+
+static PDmtTree GetTree()
+{
+ if (ptrTree) return ptrTree;
+
+ if (DmtTreeFactory::GetSubtree(principal, s_strRootPath, ptrTree) != SYNCML_DM_SUCCESS) {
+ strcatEx("Can't get tree '%s'.", s_strRootPath.c_str());
+ }
+
+ return ptrTree;
+}
+
+static void DumpSubTree(PDmtNode ptrNode)
+{
+ SYNCML_DM_RET_STATUS_T ret = PrintNode(ptrNode);
+ strcatEx("\n");
+ if (ret != SYNCML_DM_SUCCESS) return;
+
+ if (!ptrNode->IsLeaf()) {
+ DMVector<PDmtNode> aChildren;
+ ret = ptrNode->GetChildNodes(aChildren);
+ if (ret != SYNCML_DM_SUCCESS) {
+ DMString path;
+ ptrNode->GetPath(path);
+ strcatEx("can't get child nodes of %s", path.c_str());
+ return;
+ }
+ UINT32 childLength = aChildren.size();
+ for (UINT32 i = 0; i < childLength; ++i) {
+ DumpSubTree(aChildren[i]);
+ }
+ }
+}
+
+static SYNCML_DM_RET_STATUS_T PrintNode(PDmtNode ptrNode)
+{
+ LOGD("Enter PrintNode\n");
+ DmtAttributes oAttr;
+ DMString path;
+
+ SYNCML_DM_RET_STATUS_T ret = ptrNode->GetPath(path);
+ if (ret != SYNCML_DM_SUCCESS)
+ {
+ strcatEx("can't get attributes of node %d", ret);
+ }
+
+ LOGD("Get attributes\n");
+ if ((ret = ptrNode->GetAttributes(oAttr)) != ptrNode->GetPath(path)) {
+ strcatEx("can't get attributes of node %s", path.c_str());
+ return ret;
+ }
+
+ LOGD("Check storage mode...\n");
+ DmtData oData;
+ if (!ptrNode->IsExternalStorageNode())
+ {
+ LOGD("Enter get value...\n");
+ SYNCML_DM_RET_STATUS_T ret1 = ptrNode->GetValue(oData);
+ if (ret1 != SYNCML_DM_SUCCESS) {
+ LOGD("Value is null");
+ strcatEx("can't get value of node %s", path.c_str());
+ return ret1;
+ }
+ }
+
+ LOGD("Compose string begin...\n");
+ strcatEx("path=%s\n", (const char*)path.c_str());
+ strcatEx("isLeaf=%s\n", (ptrNode->IsLeaf()?"true":"false") );
+ strcatEx("name=%s\n", (const char*)oAttr.GetName().c_str() );
+ strcatEx("format=%s\n", (const char*)oAttr.GetFormat().c_str() );
+ strcatEx("type=%s\n", (const char*)oAttr.GetType().c_str() );
+ strcatEx("title=%s\n", (const char*)oAttr.GetTitle().c_str() );
+ strcatEx("acl=%s\n", (const char*)oAttr.GetAcl().toString().c_str() );
+ strcatEx("size=%d\n", oAttr.GetSize());
+ if (bShowTimestamp) {
+ time_t timestamp = (time_t)(oAttr.GetTimestamp()/1000L);
+ if (timestamp == 0) {
+ strcatEx("timestamp=(Unknown)\n");
+ } else {
+ char timestampbuf[27];
+ ctime_r(&timestamp, timestampbuf);
+ strcatEx("timestamp=%s", timestampbuf);
+ }
+ }
+
+ strcatEx("version=%d\n", oAttr.GetVersion() );
+ if ( !ptrNode->IsLeaf() ) {
+ DMStringVector aChildren;
+ oData.GetNodeValue(aChildren);
+ strcatEx("children:");
+ if ( aChildren.size() == 0 ) {
+ strcatEx("null");
+ }
+ UINT32 childLength = aChildren.size();
+ for (UINT32 i = 0; i < childLength; ++i) {
+ const DMString& child = aChildren[i];
+ strcatEx("%s/", child.c_str());
+ }
+ strcatEx("\n");
+ } else {
+ if (ptrNode->IsExternalStorageNode())
+ {
+ strcatEx("value=\n");
+ strcatEx("It is an ESN node, not supported now");
+ //displayESN(ptrNode);
+ }
+ else {
+ if (oAttr.GetFormat() == "bin") {
+ strcatEx("Binary value: [");
+ const DMVector<UINT8>& val = oData.GetBinaryValue();
+ UINT32 valLength = val.size();
+ for (UINT32 i = 0; i < valLength; ++i) {
+ UINT8 byte = val[i];
+ strcatEx("%02x ", byte);
+ }
+ strcatEx("]\n");
+ }
+ else
+ {
+ DMString s;
+ oData.GetString(s);
+ strcatEx("value=%s\n", s.c_str());
+ }
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+short wbxml2xml(unsigned char *bufIn, int bufInLen, unsigned char *bufOut, int * bufOutLen)
+{
+ short ret = 0;
+#ifdef __SML_WBXML__
+ ret = wbxml2xmlInternal(bufIn, bufInLen, bufOut,bufOutLen);
+#endif
+ return ret;
+}
+
+JNIEXPORT jbyteArray JNICALL ConvertWbxml2Xml(JNIEnv* env, jclass, jbyteArray bArray)
+{
+ unsigned char* xmlBuf = NULL;
+ int xmlLen = 0;
+
+ jbyte* wbxmlBuf = env->GetByteArrayElements(bArray, NULL);
+ jsize wbxmlLen = env->GetArrayLength(bArray);
+ LOGD("ConvertWbxml2Xml: wbxml length = %d\n", wbxmlLen);
+
+ if (wbxmlBuf == NULL || wbxmlLen <= 0)
+ {
+ LOGD("ConvertWbxml2Xml: nothing to convert\n");
+ return NULL;
+ }
+
+ xmlLen = wbxmlLen * 6;
+ xmlBuf = new unsigned char[xmlLen];
+ if (xmlBuf == NULL)
+ {
+ LOGE("ConvertWbxml2Xml: failed to allocate memory\n");
+ return NULL;
+ }
+ LOGD("ConvertWbxml2Xml: allocated xml length = %d\n", xmlLen);
+
+#ifdef __SML_WBXML__
+ short ret = wbxml2xmlInternal((unsigned char*)wbxmlBuf, wbxmlLen, xmlBuf, &xmlLen);
+#else
+ short ret = -1;
+#endif
+
+ if (ret != 0) {
+ LOGE("ConvertWbxml2Xml: wbxml2xml failed: %d\n", ret);
+ delete [] xmlBuf;
+ return NULL;
+ }
+
+ jbyteArray jb = env->NewByteArray(xmlLen);
+ env->SetByteArrayRegion(jb, 0, xmlLen, (jbyte*)xmlBuf);
+ LOGD("ConvertWbxml2Xml: result xml length = %d\n", xmlLen);
+ delete [] xmlBuf;
+ return jb;
+}
+
+static JNINativeMethod gMethods[] = {
+ {"setStringNode",
+ "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
+ (void*)setStringNode},
+ {"getNodeInfo",
+ "(Ljava/lang/String;)Ljava/lang/String;",
+ (void*)getNodeInfo},
+ {"executePlugin",
+ "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
+ (void*)executePlugin},
+ {"dumpTree",
+ "(Ljava/lang/String;)Ljava/lang/String;",
+ (void*)dumpTree},
+ {"createInterior",
+ "(Ljava/lang/String;)I",
+ (void*)createInterior},
+ {"createLeaf",
+ "(Ljava/lang/String;Ljava/lang/String;)I",
+ (void*)createLeaf},
+ {"createLeaf",
+ "(Ljava/lang/String;[B)I",
+ (void*)createLeafByte},
+ {"deleteNode",
+ "(Ljava/lang/String;)I",
+ (void*)deleteNode},
+ {"nativeWbxmlToXml",
+ "([B)[B",
+ (void*)ConvertWbxml2Xml},
+ {"getNodeType",
+ "(Ljava/lang/String;)I",
+ (void*)getNodeType},
+ {"getNodeValue",
+ "(Ljava/lang/String;)Ljava/lang/String;",
+ (void*)getNodeValue},
+};
+
+int registerDMTreeNatives(JNIEnv *env)
+{
+ jclass clazz = env->FindClass(javaDMEnginePackage);
+ if (clazz == NULL)
+ return JNI_FALSE;
+
+ if (env->RegisterNatives(clazz, gMethods, sizeof(gMethods)/sizeof(gMethods[0])) < 0)
+ {
+ LOGE("registerDMTreeNatives return ERROR");
+ return JNI_FALSE;
+ }
+
+ return JNI_TRUE;
+}
diff --git a/engine/jni/DMTreeManager.h b/engine/jni/DMTreeManager.h
new file mode 100644
index 0000000..c25bb88
--- /dev/null
+++ b/engine/jni/DMTreeManager.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_TREE_ANDROID_HEADER
+#define DM_TREE_ANDROID_HEADER
+
+#include <android_runtime/AndroidRuntime.h>
+
+int registerDMTreeNatives(JNIEnv*);
+
+short wbxml2xml(unsigned char *bufIn, int bufInLen, unsigned char *bufOut, int * bufOutLen);
+
+#endif
diff --git a/engine/xpl/hdr/dmAllocatedPointersPool.h b/engine/xpl/hdr/dmAllocatedPointersPool.h
new file mode 100644
index 0000000..bceffe8
--- /dev/null
+++ b/engine/xpl/hdr/dmAllocatedPointersPool.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMALLOCATED_POINTERS_POOL_INCLUDE
+#define DMALLOCATED_POINTERS_POOL_INCLUDE
+
+#include "dmThreadQueue.h"
+#include "dmThreadHelper.h"
+#include <malloc.h>
+#include <stdio.h>
+#include <time.h>
+#include <sys/time.h>
+
+#include "dmstring.h"
+#include "dmvector.h"
+
+#define DM_MAX_TIMERS 10
+
+#ifdef DEBUG
+#include <map>
+
+class DMAllocatedPointersPool
+{
+public:
+ enum { c_nExtraBytes = 16 };
+
+ /**
+ * Default constructor
+ */
+ DMAllocatedPointersPool(){}
+
+ /**
+ * Destructor
+ */
+ ~DMAllocatedPointersPool();
+
+ /**
+ * Checks if pointer exist in the pool
+ * \param ptr [in] - pointer
+ * \return TRUE if pointer is found
+ */
+ bool exists(void* ptr);
+
+ /**
+ * Appends pointer to the pool
+ * \param ptr [in] - pointer
+ */
+ void append(void* ptr);
+
+ /**
+ * Removes pointer from the pool
+ * \param ptr [in] - pointer
+ */
+ bool remove(void* ptr);
+
+ /**
+ * Prints unreleased pointers
+ */
+ void PrintUnreleased();
+
+
+private:
+ /** Critical section */
+ DMCriticalSection m_csPointerPoolLock;
+ /** Pool of allocated pointers */
+ std::map<void*, int> m_listOfAllocatedPointers;
+};
+
+
+/*====================================================================================================
+ Inline functions implementation
+==================================================================================================*/
+inline bool DMAllocatedPointersPool::exists(void* ptr)
+{
+ DMSingleLock oLock( m_csPointerPoolLock );
+
+ return m_listOfAllocatedPointers.find( ptr ) != m_listOfAllocatedPointers.end();
+}
+
+
+inline void DMAllocatedPointersPool::append(void* ptr)
+{
+ DMSingleLock oLock( m_csPointerPoolLock );
+
+ m_listOfAllocatedPointers[ptr] = 0; // add new pointer
+}
+
+inline bool DMAllocatedPointersPool::remove(void* ptr)
+{
+ DMSingleLock oLock( m_csPointerPoolLock );
+
+ std::map<void*, int>::iterator it = m_listOfAllocatedPointers.find(ptr);
+
+ if ( it == m_listOfAllocatedPointers.end() )
+ return false;
+
+ m_listOfAllocatedPointers.erase( it );
+ return true;
+}
+
+#endif //DEBUG
+
+#endif
diff --git a/engine/xpl/hdr/dmAsyncMessageID.h b/engine/xpl/hdr/dmAsyncMessageID.h
new file mode 100644
index 0000000..ca1617a
--- /dev/null
+++ b/engine/xpl/hdr/dmAsyncMessageID.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_ASYNC_MESSAGEID_H
+#define DM_ASYNC_MESSAGEID_H
+
+#include "xpl_Message.h"
+#include "xpl_Time.h"
+
+
+enum {
+ SYNCML_DM_INIT_MSG_ID = XPL_DM_TASK_MESSAGE_CATEGORY,
+ SYNCML_DM_UNINIT_MSG_ID,
+ SYNCML_DM_GET_SUBTREE_MSG_ID,
+ SYNCML_DM_RELEASE_TREE_ID,
+ SYNCML_DM_START_SERVER_SESSION_MSG_ID,
+ SYNCML_DM_PROCESS_SCRIPT_MSG_ID,
+ SYNCML_DM_BOOTSTRAP_MSG_ID,
+ SYNCML_DM_PROCESS_NOTIFICATION_MSG_ID,
+ SYNCML_DM_GET_NODE_MSG_ID,
+ SYNCML_DM_RELEASE_NODE_MSG_ID,
+ SYNCML_DM_DELETE_NODE_MSG_ID,
+ SYNCML_DM_RENAME_NODE_MSG_ID,
+ SYNCML_DM_CREATE_INTERIOR_NODE_MSG_ID,
+ SYNCML_DM_CREATE_LEAF_NODE_MSG_ID,
+ SYNCML_DM_GET_CHULD_NODE_NAMES_MSG_ID,
+ SYNCML_DM_FLUSH_MSG_ID,
+ SYNCML_DM_COMMIT_MSG_ID,
+ SYNCML_DM_ROLLBACK_MSG_ID,
+ SYNCML_DM_BEGIN_MSG_ID,
+ SYNCML_DM_GET_CHILD_VALUES_MAP_MSG_ID,
+ SYNCML_DM_SET_CHILD_VALUES_MAP_MSG_ID,
+ SYNCML_DM_GET_ATTRIBUTES_MSG_ID,
+ SYNCML_DM_GET_VALUE_MSG_ID,
+ SYNCML_DM_SET_VALUE_MSG_ID,
+ SYNCML_DM_SET_TITLE_MSG_ID,
+ SYNCML_DM_SET_ACL_MSG_ID,
+ SYNCML_DM_EXECUTE_MSG_ID,
+ SYNCML_DM_NOTIFY_ON_IDLE_MSG_ID,
+ SYNCML_DM_TIMER_MSG_ID,
+ SYNCML_DM_TIMER_MSG_ID_LAST,
+ SYNCML_DM_TREE_AVAILABLE_MSG_ID,
+ SYNCML_DM_GET_FIRST_CHUNK_MSG_ID,
+ SYNCML_DM_GET_NEXT_CHUNK_MSG_ID,
+ SYNCML_DM_SET_FIRST_CHUNK_MSG_ID,
+ SYNCML_DM_SET_NEXT_CHUNK_MSG_ID,
+ SYNCML_DM_SET_LAST_CHUNK_MSG_ID
+};
+typedef UINT32 SYNCML_DM_TASK_MESSAGE_ID;
+
+#define SYNCML_DM_ASYNC_API_MESSAGE_COUNT (SYNCML_DM_SET_LAST_CHUNK_MSG_ID - SYNCML_DM_INIT_MSG_ID)
+
+typedef struct
+{
+ XPL_CLK_TIMER_CBACK callback;
+ XPL_TIMER_HANDLE_T timerHandle;
+} SYNCML_DM_TIMER_MSG_T;
+
+#endif
diff --git a/engine/xpl/hdr/dmMemory.h b/engine/xpl/hdr/dmMemory.h
new file mode 100644
index 0000000..8a49c6a
--- /dev/null
+++ b/engine/xpl/hdr/dmMemory.h
@@ -0,0 +1,43 @@
+#ifndef DMMEMORY_H
+#define DMMEMORY_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include "xpl_Types.h"
+#include "dmStringUtil.h"
+
+
+#define DmAllocMem(bufsize) DmAllocMemEx(bufsize,__FILE__,__LINE__)
+#define DmFreeMem(buf) { DmFreeMemEx(buf,__FILE__,__LINE__); (buf) = NULL; }
+
+void * DmAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine );
+void DmFreeMemEx(void *ptr, CPCHAR szFile, int nLine);
+void* DmReallocMem( void* ptr, int nSize );
+
+/* Low memory helpers */
+int DmGetMemFailedFlag( void );
+void DmResetMemFailedFlag( void );
+
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+
+#define DM_MEMORY_STATISTICS_WRITE(header) DmMemoryStatisticsWrite(header)
+void DmMemoryStatisticsWrite(const char* header);
+
+#define DM_MEMORY_STATISTICS_REPORT_LEAKS DmMemoryStatisticsReportLeaks();
+void DmMemoryStatisticsReportLeaks( void );
+
+#else /*DM_MEMORY_STATISTICS_ENABLED*/
+
+#define DM_MEMORY_STATISTICS_WRITE(header)
+#define DM_MEMORY_STATISTICS_REPORT_LEAKS
+
+#endif /*DM_MEMORY_STATISTICS_ENABLED*/
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* DMMEMORY_H */
+
diff --git a/engine/xpl/hdr/dmNewDataTypesValidation.h b/engine/xpl/hdr/dmNewDataTypesValidation.h
new file mode 100644
index 0000000..0cad591
--- /dev/null
+++ b/engine/xpl/hdr/dmNewDataTypesValidation.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DM_NEW_DATA_TYPES_VALIDATION_H
+#define SYNCML_DM_NEW_DATA_TYPES_VALIDATION_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include "dmstring.h"
+
+BOOLEAN
+is_float( const DMString& str );
+
+BOOLEAN
+is_date( const DMString& str );
+
+BOOLEAN
+is_time( const DMString& str );
+
+#endif // SYNCML_DM_NEW_DATA_TYPES_VALIDATION_H
diff --git a/engine/xpl/hdr/dmSocketConnector.h b/engine/xpl/hdr/dmSocketConnector.h
new file mode 100644
index 0000000..d41a65a
--- /dev/null
+++ b/engine/xpl/hdr/dmSocketConnector.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMSOCKETCONNECTOR_H
+#define DMSOCKETCONNECTOR_H
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#include <sys/types.h> // Needed for system defined identifiers.
+#include <netinet/in.h> // Needed for internet address structure.
+#include <sys/socket.h> // Needed for socket(), bind(), etc...
+
+#include "dmvector.h"
+#include "dmt.hpp"
+#include "xpl_HTTP.h"
+
+class DmSocketConnector
+{
+ public :
+ DmSocketConnector() {
+ proxy_auth = NULL;
+ proxy_enable_check = true;
+ new_session = true;
+ portNum = "80";
+ socket_portNum = "80";
+ responseData = NULL;
+ proxy_url = NULL;
+ }
+
+ ~DmSocketConnector() {
+ if ( responseData != NULL ) {
+ free(responseData);
+ responseData = NULL;
+ }
+ }
+
+
+ SYNCML_DM_RET_STATUS_T Open(CPCHAR url, CPCHAR ConRef, int AddrType);
+
+ SYNCML_DM_RET_STATUS_T SetRequestMethod(XPL_HTTP_METHOD_T method);
+
+ SYNCML_DM_RET_STATUS_T SetRequestProperty(CPCHAR props);
+
+ SYNCML_DM_RET_STATUS_T Send(CPCHAR data, UINT32 size);
+
+ UINT32 GetResponseLength();
+
+ SYNCML_DM_RET_STATUS_T GetResponse(char * data, UINT32 size);
+
+ SYNCML_DM_RET_STATUS_T GetHeaderField(CPCHAR field, char ** value);
+
+ XPL_HTTP_CODE_T GetResponseCode();
+
+ SYNCML_DM_RET_STATUS_T Close();
+ SYNCML_DM_RET_STATUS_T CloseReq();
+ SYNCML_DM_RET_STATUS_T SetUrl(CPCHAR url, CPCHAR ConRef, int AddrType);
+
+ bool DmStringParserGetItem( DMString& strItem, DMString& strReminder, char cDelim );
+
+ bool DmParseHTTPHeader( char* strBuffer, int dataBufSize, char** strRemaining, int& lenRemaining);
+ bool SetResponseData(unsigned char* dataReceived, int len);
+
+ bool parseURL(DMString strURI, DMString& strAddrPort, DMString& strURIPath);
+ bool parseAddrPort(DMString strAddrPort, DMString& strAddr, DMString& strPort);
+ SYNCML_DM_RET_STATUS_T doSend(CPCHAR data, UINT32 size);
+ SYNCML_DM_RET_STATUS_T getResponse();
+
+ private:
+ unsigned int server_s; // Server socket descriptor
+ struct sockaddr_in server_addr; // Server Internet address
+ DMString sentBuf; // Sent buffer
+ DMString urlPath; // The path part of a URL
+ DMString portNum;
+ DMString ipAddress;
+ DMString responseCode;
+ DMString responseBody;
+ DMMap<DMString, DMString> responseHeaders;
+ UINT32 responseLength;
+ const char * proxy_auth;
+ bool proxy_enable_check;
+ bool new_session;
+ DMString socket_ipAddress;
+ DMString socket_portNum;
+ XPL_HTTP_METHOD_T requestMethod;
+ unsigned char* responseData;
+ const char * proxy_url;
+
+};
+
+DmSocketConnector * DmBrwCreateConnector();
+SYNCML_DM_RET_STATUS_T DmBrwDestroyConnector(DmSocketConnector * browser_handler);
+
+#endif
diff --git a/engine/xpl/hdr/dmStringUtil.h b/engine/xpl/hdr/dmStringUtil.h
new file mode 100644
index 0000000..a4da021
--- /dev/null
+++ b/engine/xpl/hdr/dmStringUtil.h
@@ -0,0 +1,57 @@
+#ifndef DMSTRINGUTIL_H
+#define DMSTRINGUTIL_H
+
+
+/************** HEADER FILE INCLUDES *****************************************/
+#include "stdlib.h"
+#include "string.h"
+#include "stdio.h"
+
+//#define DmStrlen(str) strlen(str)
+#define DmStrlen(str) ((str!=NULL)? strlen(str):0)
+
+#define DmStrcpy(target, source) strcpy(target, source)
+
+#define DmStrncpy(target, source, count) strncpy(target, source, count)
+
+#define DmStrcat(target, source) strcat(target, source)
+
+#define DmStrncat(target, source, count) strncat(target, source, count)
+
+#define DmStrcmp(target, source) strcmp(target, source)
+
+#define DmStrcasecmp(target, source) strcasecmp(target, source)
+
+#define DmStrncmp(target, source, count) strncmp(target, source, count)
+
+#define DmStrchr(source, target) strchr(source, target)
+
+#define DmStrrchr(source, target) strrchr(source, target)
+
+#define DmStrstr(source, target) strstr(source, target)
+
+#define DmTolower(source) tolower(source)
+
+#define DmAtoi(source) atoi(source)
+
+#define DmAtol(source) atol(source)
+
+#define DmAtoll(source) atoll(source)
+
+#define DmAtof(source) atof(source)
+
+#define DmStrtol(source, end_ptr, radix) strtol( source, end_ptr, radix )
+
+#define DmSprintf sprintf
+
+#define DmSnprintf snprintf
+
+#define DmSscanf sscanf
+
+#define MAX_INT_STRING_LENGTH 14
+
+#define MAX_FLOAT_STRING_LENGTH 20
+
+#endif /* DMSTRINGUTIL_H */
+
+
diff --git a/engine/xpl/hdr/dmThreadHelper.h b/engine/xpl/hdr/dmThreadHelper.h
new file mode 100644
index 0000000..070ec08
--- /dev/null
+++ b/engine/xpl/hdr/dmThreadHelper.h
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMTHREADHELPER_INCLUDE
+#define DMTHREADHELPER_INCLUDE
+
+#include <pthread.h>
+#include <unistd.h>
+#include <assert.h>
+#include <memory.h>
+#include <errno.h>
+
+#ifdef DEBUG
+ #define IMASSERT(expression) assert(expression)
+ //#define NRES int nRes=
+ #define NRES(foo) int nRes=(foo)
+#else
+ #define IMASSERT(expression)
+ //#define NRES
+ #define NRES(foo) foo
+#endif
+
+
+class DMCriticalSection
+{
+public:
+ /**
+ * Default constructor
+ */
+ DMCriticalSection();
+
+ /**
+ * Destructor
+ */
+ ~DMCriticalSection();
+
+ /**
+ * Locks mutex object
+ */
+ void Enter();
+
+ /**
+ * Unlocks mutex object
+ */
+ void Leave();
+
+ /**
+ * Tries to lock mutex object
+ * \return TRUE if mutex object is locked
+ */
+ bool TryEnter();
+
+ /**
+ * Retrieves handler on mutex object
+ */
+ pthread_mutex_t& GetHandle() { return m_section;}
+
+private:
+ /* handler */
+ pthread_mutex_t m_section;
+};
+
+
+class DMThread
+{
+ public:
+
+ /**
+ * Default constructor
+ */
+ DMThread()
+ {
+ m_bRunning = false;
+ memset(&m_hThread, 0, sizeof(m_hThread));
+ }
+
+ /**
+ * Destructor
+ */
+ virtual ~DMThread(){}
+
+ /**
+ * Starts thread
+ * \return TRUE if success
+ */
+ bool StartThread();
+
+ /**
+ * Stops thread
+ * \return TRUE if success
+ */
+ bool StopThread();
+
+ protected:
+ /**
+ * Run method to be implemented in an inherited class
+ */
+ virtual void* Run() = 0;
+ private:
+
+ /**
+ * Thread callback function
+ */
+ static void* ThreadProc(void *pArg);
+
+protected:
+ /** Flag to specify if thread is running */
+ bool m_bRunning;
+ /** Thread handler */
+ pthread_t m_hThread;
+};
+
+
+inline DMCriticalSection::DMCriticalSection( )
+{
+ memset( &m_section, 0, sizeof( m_section ) );
+
+ NRES(pthread_mutex_init( &m_section, 0 ));
+ IMASSERT( nRes == 0 );
+}
+
+inline DMCriticalSection::~DMCriticalSection()
+{
+ NRES(pthread_mutex_destroy( &m_section ));
+ IMASSERT( nRes == 0 );
+}
+
+inline void DMCriticalSection::Enter()
+{
+ NRES(pthread_mutex_lock( &m_section ));
+ IMASSERT( nRes == 0 );
+}
+
+inline void DMCriticalSection::Leave()
+{
+ NRES(pthread_mutex_unlock( &m_section ));
+
+ IMASSERT( nRes == 0 );
+}
+
+inline bool DMCriticalSection::TryEnter()
+{
+ int nRes = pthread_mutex_trylock( &m_section );
+
+ IMASSERT( nRes == 0 || nRes == EBUSY );
+
+ return nRes == 0;
+}
+
+
+class DMSingleLock
+{
+ DMCriticalSection& m_oSection;
+public:
+ /**
+ * Constructor
+ * \param oSection [in] - critical section(mutex)
+ */
+ DMSingleLock( DMCriticalSection& oSection ): m_oSection( oSection )
+ {
+ m_oSection.Enter();
+ }
+
+ /**
+ * Destructor
+ */
+ ~DMSingleLock()
+ {
+ m_oSection.Leave();
+ }
+};
+
+#define DmThSleep(a) usleep(a)
+
+#endif
diff --git a/engine/xpl/hdr/dmThreadQueue.h b/engine/xpl/hdr/dmThreadQueue.h
new file mode 100644
index 0000000..6084c54
--- /dev/null
+++ b/engine/xpl/hdr/dmThreadQueue.h
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DMTHREADQUEUE_INCLUDE
+#define DMTHREADQUEUE_INCLUDE
+
+/*==================================================================================================
+
+ Header Name: dmThreadQueue.h
+
+ General Description: This file contains declaration of the DMThread and DMThreadQueue classes
+
+==================================================================================================*/
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <limits.h>
+#include <time.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#include "jem_defs.hpp"
+#include "dmdefs.h"
+#include "dmThreadHelper.h"
+
+#define DM_WAIT_FOREVER LONG_MAX
+
+enum {
+ SYNCML_DM_THREAD_EVENT_TYPE_NONE,
+ SYNCML_DM_THREAD_EVENT_TYPE_TIMEOUT,
+ SYNCML_DM_THREAD_EVENT_TYPE_SHUTDOWN,
+ SYNCML_DM_THREAD_EVENT_TYPE_FILELOCK
+};
+typedef UINT8 SYNCML_DM_THREAD_EVENT_TYPE_T;
+
+
+class DMThreadEvent {
+public:
+
+ /**
+ * Constructor
+ * \param nID [in] - event type to be sent
+ * \param pData [in] - pointer on data to be sent
+ */
+ DMThreadEvent(SYNCML_DM_THREAD_EVENT_TYPE_T nID = SYNCML_DM_THREAD_EVENT_TYPE_NONE,
+ void* pData = NULL ) : m_nID( nID ), m_pUserData(pData) {}
+
+ /**
+ * Retrieves event type
+ */
+ SYNCML_DM_THREAD_EVENT_TYPE_T GetEventType() const {return m_nID;}
+
+ /**
+ * Retrieves event data
+ */
+ void* GetData() const {return m_pUserData;}
+
+protected:
+ /** Event type */
+ SYNCML_DM_THREAD_EVENT_TYPE_T m_nID;
+ /** Event data */
+ void* m_pUserData;
+};
+
+// maximum number of events in the queue
+#define DM_EVENT_QUEUE_MAX_LEN 50
+
+class DMThreadQueue : public JemBaseObject {
+
+public:
+ /**
+ * Default constructor
+ */
+ DMThreadQueue() ;
+
+ /**
+ * Constructor
+ * \param nID [in] - event type to be sent
+ * \param pData [in] - pointer on data to be sent
+ * \return TRUE if success
+ */
+ bool Post(SYNCML_DM_THREAD_EVENT_TYPE_T nID,
+ void* pData = NULL ) ;
+
+ /**
+ * Stops timer
+ */
+ void KillTimer() ;
+
+ /**
+ * Sets timer
+ * \param nTimeoutMS [in] - time out in mseconds
+ */
+ void SetTimer( int nTimeoutMS ) ;
+
+ /**
+ * Waits event to arrive
+ * \param nTimeoutMS [in] - time out in mseconds
+ * \return TRUE if event received
+ */
+ bool Wait(long nTimeoutMS,
+ DMThreadEvent& event );
+
+ /**
+ * Checks if timer is set
+ * \return TRUE if timer is set
+ */
+ bool IsTimerSet() const { return m_bTimerSet; }
+
+protected:
+ /**
+ * Destructor
+ */
+ ~DMThreadQueue() ;
+
+
+private:
+ /**
+ * Retrives time adjusted on timeout
+ * \param stimeout [out] - time
+ * \param nTimeoutMS [in] - time out in mseconds
+ */
+ void GetTimeWithinTimeout(struct timespec &stimeout,
+ long nTimeoutMS ) const ;
+
+ /**
+ * Calculates remaining wait time
+ * \param sWaitTo [out] - time to wait
+ * \param nTimeoutMS [in] - time out in mseconds
+ */
+ void GetWaitTime(struct timespec &sWaitTo,
+ const struct timespec &stimeout ) const ;
+
+ /**
+ * Verifies if timer is ready
+ * \return TRUE if timer is ready
+ */
+ bool TimerReady() const ;
+
+ /* Events placeholder */
+ DMThreadEvent m_aEvents[DM_EVENT_QUEUE_MAX_LEN];
+ /** Queue Index */
+ int m_nHead;
+ /** Event count */
+ int m_nSize;
+ /** threas condition */
+ pthread_cond_t m_oCond;
+ /** Critical section */
+ DMCriticalSection m_csMutex;
+ /** Time when timer is started */
+ struct timespec m_sTimerFireTime;
+ /** Flag to verify if timer is set */
+ bool m_bTimerSet;
+};
+
+typedef JemSmartPtr<DMThreadQueue> PDMThreadQueue;
+
+#endif
diff --git a/engine/xpl/hdr/dmdefs.h b/engine/xpl/hdr/dmdefs.h
new file mode 100644
index 0000000..137b0da
--- /dev/null
+++ b/engine/xpl/hdr/dmdefs.h
@@ -0,0 +1,16 @@
+#ifndef DM_DEFS_H
+#define DM_DEFS_H
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include "dmMemory.h"
+
+
+#define DIM(array) (sizeof(array)/sizeof((array)[0]))
+
+#define FreeAndSetNull(_x) \
+ if ((_x)!=NULL) { DmFreeMem(_x); (_x)=NULL; }
+
+
+#endif /* DMDEFS_H */
+
diff --git a/engine/xpl/hdr/dmprofile.h b/engine/xpl/hdr/dmprofile.h
new file mode 100644
index 0000000..287da01
--- /dev/null
+++ b/engine/xpl/hdr/dmprofile.h
@@ -0,0 +1,200 @@
+#ifndef __DMPROFILE_H__
+#define __DMPROFILE_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+#ifdef DM_PERFORMANCE_ENABLED
+
+#include "trace_perf.h"
+
+#endif
+
+enum {
+ DM_INITIALIZE_ENTER = 18000000,
+ DM_INITIALIZE_EXIT = 18000001,
+ DM_GET_TREE_ENTER = 18000002,
+ DM_GET_TREE_EXIT = 18000003,
+ DM_GET_NODE_ENTER = 18000004,
+ DM_GET_NODE_EXIT = 18000005,
+ DM_UNINITIALIZE_ENTER = 18000006,
+ DM_UNINITIALIZE_EXIT = 18000007,
+ DM_INITIALIZE_MOUNT = 18000008,
+ DM_INITIALIZE_MDF = 18000009,
+ DM_INITIALIZE_PLUGIN = 18000010,
+ DM_INITIALIZE_ACRHIVER = 18000011,
+ DM_INITIALIZE_FILE = 18000012,
+ DM_INITIALIZE_LOCK = 18000013,
+ DM_INITIALIZE_ACL = 18000014,
+ DM_INITIALIZE_EVENT = 18000015,
+ DM_INITIALIZE_LOAD = 18000016,
+
+};
+
+
+#ifdef DM_PERFORMANCE_ENABLED
+#define DM_PERFORMANCE(event) TRACE_PERF(event)
+#else
+#define DM_PERFORMANCE(event)
+#endif
+
+
+#ifdef DM_PROFILER_ENABLED
+#include <sys/time.h>
+#include <stdio.h>
+#include <string.h>
+
+#ifdef DEBUG
+extern int s_nBlocks , s_nSize, s_nCnt;
+#endif
+
+// static storage for performance statistic
+#define PROF_CELL_NUM 20000
+struct CDMProfCell {
+ const char* _s;
+ long long _elapsed, _from;
+};
+
+extern CDMProfCell g_aProfStorage[PROF_CELL_NUM];
+extern int g_nProfCurCell;
+
+struct CDMProfile {
+
+ CDMProfile( const char* s) {
+ _s = s;
+ gettimeofday( &_tv1, NULL );
+#ifdef DEBUG
+ _nasBlocks = s_nBlocks;
+ _nWasSize = s_nSize;
+ _nWasTotal = s_nCnt;
+#endif
+ }
+ ~CDMProfile() {
+ struct timeval tv2;
+ gettimeofday( &tv2, NULL );
+ long long n1 = _tv1.tv_usec + (_tv1.tv_sec * 1000000 );
+ long long n2 = tv2.tv_usec + (tv2.tv_sec * 1000000 );
+ long long elapsed = n2 - n1;
+ //printf( "DMProfile: %s, time is %lld usec, from %lld to %lld\n", _s, elapsed, n1, n2 );
+ int nCurCell = g_nProfCurCell++ % PROF_CELL_NUM;
+ g_aProfStorage[nCurCell]._s = strdup( _s );
+ g_aProfStorage[nCurCell]._elapsed = elapsed;
+ g_aProfStorage[nCurCell]._from = n1;
+
+#ifdef DEBUG
+#ifdef DM_DM_MEMORY_USAGE_ENABLED
+ printf( "DMProfile: %s, time is %lld usec, from %lld to %lld\n", _s, elapsed, n1, n2 );
+
+ printf( "Total Blocks %d (delta is %d), size %d (delta is %d), total allocated (including deallocated) %d, (d %d)\n\n",
+ s_nBlocks, s_nBlocks - _nasBlocks,
+ s_nSize, s_nSize - _nWasSize,
+ s_nCnt, s_nCnt - _nWasTotal );
+#endif
+#endif
+ }
+
+ struct timeval _tv1;
+ const char* _s;
+#ifdef DEBUG
+ int _nasBlocks, _nWasSize, _nWasTotal;
+#endif
+};
+
+#define DM_PROFILE_EXT(msg,num) CDMProfile __oProf##num(msg );
+#define DM_PROFILE(msg) CDMProfile __oProf(msg );
+
+#else
+#define DM_PROFILE(msg)
+#define DM_PROFILE_EXT(msg,num)
+#endif
+
+
+#ifdef DM_PROFILER_STACK
+
+#include <sys/time.h>
+#include <stdio.h>
+#include <string.h>
+#include "dmvector.h"
+
+// static storage for performance statistic
+#define PROF_STACK_NUM 20000
+struct DMProfileData {
+ const char* _s;
+ long long _elapsed, _from;
+};
+
+extern DMProfileData __aProfStackStorage[PROF_STACK_NUM];
+extern int g_nProfCurCell;
+
+struct CDMProfileCapture {
+
+ CDMProfileCapture(DMStringVector itemNames, DMStringVector itemValues) {
+ _itemNames = itemNames;
+ _itemValues = itemValues;
+ gettimeofday( &_tv1, NULL );
+ }
+
+ ~CDMProfileCapture() {
+ struct timeval tv2;
+ gettimeofday( &tv2, NULL );
+ long long n1 = _tv1.tv_usec + (_tv1.tv_sec * 1000000 );
+ long long n2 = tv2.tv_usec + (tv2.tv_sec * 1000000 );
+ long long elapsed = n2 - n1;
+
+ DMString tmp = "";
+ DMString tmpValue = "";
+
+ for (int i = 0; i < _itemNames.size(); i++) {
+ tmp += " <";
+ tmp += _itemNames[i];
+ tmp += ">";
+ tmpValue = _itemValues[i];
+
+ tmpValue.replaceAll('<', '#');
+ tmpValue.replaceAll('>', '#');
+
+ tmp += tmpValue;
+
+ const char* ch = _itemValues[i].c_str();
+
+ int size = strlen(ch);
+
+ if (ch[size - 1] == '\n') {
+ tmp += " </";
+ } else {
+ tmp += "</";
+ }
+
+ tmp += _itemNames[i];
+ tmp += ">\n";
+ }
+
+ int nCurCell = g_nProfCurCell++ % PROF_STACK_NUM;
+ __aProfStackStorage[nCurCell]._s = strdup(tmp.c_str());
+
+ __aProfStackStorage[nCurCell]._elapsed = elapsed;
+ __aProfStackStorage[nCurCell]._from = n1;
+ }
+
+ struct timeval _tv1;
+ const char* _s;
+ DMStringVector _itemNames;
+ DMStringVector _itemValues;
+};
+
+#define DM_PROFILE_STACK(itemNames, itemValues) CDMProfileCapture __oProfStack(itemNames, itemValues);
+
+#else
+#define DM_PROFILE_STACK(itemNames, itemValues)
+#endif
+
+
+#ifdef DM_FILE_OUTPUT
+void DMFileOutput( const char* szFormat, ... );
+#else
+#define DMFileOutput
+#endif
+
+#endif // __DMPROFILE_H__
+
diff --git a/engine/xpl/hdr/dmvector.h b/engine/xpl/hdr/dmvector.h
new file mode 100644
index 0000000..2c31200
--- /dev/null
+++ b/engine/xpl/hdr/dmvector.h
@@ -0,0 +1,954 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DMVECTOR_H__
+#define __DMVECTOR_H__
+
+#ifndef __cplusplus
+#error "This is a C++ header file; it requires C++ to compile."
+#endif
+
+/**
+ \file dmvector.h
+ \brief Contains DMVector and DMMap template classes definition
+
+ The dmvector.hpp header file contains DMVector and DMMap template classes definition.
+ <b>DMVector</b> template class is simple Collection Class without overhead of STL or QT
+ and id similar to Java's ArrayList
+ <b>DMMap</b> template class is simple Collection Class without overhead of STL or QT
+ DMMap template class is similar to Java's HashMap. Potentially can be slow, especially with
+ large number of keys, since linear search is used.
+*/
+
+#include <string.h>
+#include "dmstring.h"
+#include <new>
+
+
+#ifdef PLATFORM_X86
+#include <assert.h>
+/** Definition for DMASSERT for platform compatibility*/
+#define DMASSERT(expression) assert(expression)
+#else
+/** Definition for DMASSERT for platform compatibility*/
+#define DMASSERT(expression)
+#endif
+
+ /**
+ * Memory allocation routine. Used for the debug purpose
+ * \warning This method for internal usage only!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Migration State: FINAL
+ * \param nSize [in] - buffer size as an integer
+ * \param szFile [in] - file name
+ * \param nLine [in] - line number
+ * \return void pointer or null if no memory available
+ * \par Prospective Clients:
+ * For internal usage only
+ */
+extern "C" void* DmtMemAllocEx( size_t nSize, const char* szFile, int nLine );
+
+/**
+ * Memory deallocation routine
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Migration State: FINAL
+ * \param p [in] - pointer to memory that should be freed
+ * \par Prospective Clients:
+ * For internal usage only
+ */
+extern "C" void DmtMemFree( void* p );
+
+/**
+ * Memory allocation macro.
+ * \warning This method for internal usage only!
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Migration State: FINAL
+ * \param size buffer size as an integer
+ * \par Prospective Clients:
+ * For internal usage only
+ */
+#define DmtMemAlloc(size) DmtMemAllocEx(size,__FILE__,__LINE__)
+
+
+/**
+* Simple Collection Class without overhead of STL or QT
+* DMVector template class is similar to Java's ArrayList
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+template<class type>
+class DMVector
+{
+ public:
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DMVector();
+
+ /**
+ * Construct a DMVector object as copy of a given one as a parameter. The memory for the size of parameter "oCopyFrom" will be allocated.
+ * \param oCopyFrom [in] - pointer to the DMVector that should be copied.
+ */
+ DMVector( const DMVector& oCopyFrom );
+
+ /* *
+ * Destructor - freeing all dynamic resources
+ */
+ ~DMVector();
+
+ /*
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param str [in] - constant reference to DMVector
+ * \return reference to the DMVector object (itself)
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ DMVector& operator = ( const DMVector& oCopyFrom );
+
+ /**
+ * Retrieve number of elements in the vector
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return number of elements
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int size() const { return m_nCount; }
+
+ /*
+ * Sets size of the vector
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return number of elements
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int set_size( int nNewSize );
+
+ /**
+ * Appends a new element to array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - new element to add
+ * \return index of a new element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int push_back(const type& ptr);
+
+ /**
+ * Removes element from array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param index - element index; must be valid index.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void remove(int index);
+
+ /**
+ * Looks for an element in array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - reference to element
+ * \return index of an element if found, otherwise (-1) .
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int find(const type& ptr) const;
+
+
+ /**
+ * Detaches element.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to allocated element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ type* detach();
+
+ /**
+ * Const version of [] operator; allows to access any const method of element without making a copy of it.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nIndex [in] - element index
+ * \return element of a vector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const type& operator [] (int nIndex ) const;
+
+ /**
+ * Non const version of [] operator; allows to access any method of element without making a copy of it and assign a new value.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nIndex [in] - element index
+ * \return element of a vector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ type& operator [] (int nIndex );
+
+ /**
+ * Retrieves element
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to the element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ type* get_data() {return m_ptrs;}
+
+ /**
+ * Retrieves element
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return constant pointer to element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const type* get_data() const {return m_ptrs;}
+
+ /**
+ * Erases all elements from the collection
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void clear() {set_size(0);}
+
+
+private:
+ // helper functions
+ int Reallocate( int nNewSize );
+ void Destroy() {set_size(0);}
+
+ void DestructElement( int nIndex );
+ void ConstructElement( int nIndex );
+
+ int m_nAllocated, m_nCount;
+ type * m_ptrs;
+};
+
+
+/**
+* Simples Collection Class without overhead of STL or QT
+* DMMap template class is similar to Java's HashMap
+* Potentially can be slow, especially with large number of keys,
+* since linear search is used.
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+template<class Key, class Value>
+class DMMap
+{
+ public:
+/** Definition for position in DMMap*/
+ typedef int POS;
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+ DMMap();
+
+ /* *
+ * Destructor - freeing all dynamic resources
+ */
+ ~DMMap();
+
+/**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oCopyFrom [in] - constant reference to DMMap
+ * \return reference to the DMMap object (itself)
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+ DMMap& operator = ( const DMMap& oCopyFrom );
+
+ /**
+ * Retrieves number of elements in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return number of elements
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ int size() const;
+
+ /**
+ * Looks up for the element for the given key. Set value if an element has been found.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \param rValue [out] -element value
+ * \return "true" if element has been found otherwise - "false"
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ bool lookup( const Key & key, Value& rValue) const;
+
+/**
+ * Retrieves a value based on key. The key must exist in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] - element key
+ * \return constant value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const Value& get(const Key & key) const;
+
+ /**
+ * Retrieves a value based on key. The key must exist in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] - element key
+ * \return value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ Value& get(const Key & key);
+
+ /**
+ * Adds or replaces value for the given key.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \param value [in] -element value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void put(const Key & key, const Value & value);
+
+ /**
+ * Removes element for the given key
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \return "true" in case of success, otherwise - "false"
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ bool remove(const Key & key);
+
+ /**
+ * Erases all elements from the collection
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ void clear() { m_aKeys.set_size( 0 ); m_aValues.set_size( 0);}
+
+ /**
+ * Retrieves first position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return first position; can be "end()" if map is empty
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ POS begin() const {return 0;}
+
+ /**
+ * Retrieves "end" of the map position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return "end" position
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ POS end() const {return m_aKeys.size();}
+
+ /**
+ * Returns constant value by given position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param n [in] - given position
+ * \return position value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const Value& get_value(POS n) const {return m_aValues[n];}
+
+ /**
+ * Returns value by given position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param n [in] - given position
+ * \return position value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ Value& get_value(POS n) {return m_aValues[n];}
+
+ /**
+ * Returns key for given position
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param n [in] - given position
+ * \return key for the given position
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+ const Key& get_key(POS n) const {return m_aKeys[n];}
+
+
+ private:
+ DMVector<Key> m_aKeys;
+ DMVector<Value> m_aValues;
+};
+
+
+
+////////////////////////////////////////////////////////////
+// implementation DMVector
+//----------------------------------------------
+/**
+* Default constructor - constructs empty array. No memory alllocation is performed.
+*/
+template<class type>
+inline DMVector<type>::DMVector()
+{
+ m_nAllocated = m_nCount = 0;
+ m_ptrs = NULL;
+}
+
+ /**
+ * Copy constructor; makes exact copy of the source array. The memory for the size of parameter "oCopyFrom" will be allocated.
+ * \param oCopyFrom - source object
+ */
+template<class type>
+inline DMVector<type>::DMVector( const DMVector<type>& oCopyFrom )
+{
+ m_nCount = 0;
+ m_ptrs = NULL;
+
+ *this = oCopyFrom;
+}
+
+ /**
+ * Destructor - freeing all dynamic resources
+ */
+template<class type>
+inline DMVector<type>::~DMVector()
+{
+ Destroy();
+}
+
+ /**
+ * Const version of [] operator; allows to access any const method of element without making a copy of it.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nIndex [in] - element index
+ * \return element of a vector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+inline const type& DMVector<type>::operator [] (int nIndex ) const
+{
+ DMASSERT( nIndex >= 0 && nIndex < m_nCount );
+ return m_ptrs[nIndex];
+}
+
+ /**
+ * Non const version of [] operator; allows to access any method of element without making a copy of it and assign a new value.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nIndex [in] - element index
+ * \return element of a vector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+inline type& DMVector<type>::operator [] (int nIndex )
+{
+ DMASSERT( nIndex >= 0 && nIndex < m_nCount );
+ return m_ptrs[nIndex];
+}
+
+ /**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oCopyFrom [in] - reference to DMVector instance
+ * \return reference to DMVector
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+DMVector<type>& DMVector<type>::operator = ( const DMVector& oCopyFrom )
+{
+ // free current
+ Destroy();
+ if ( !set_size( oCopyFrom.m_nCount ) )
+ return *this;
+
+
+ for ( int i = 0; i < oCopyFrom.m_nCount; i++ )
+ (*this)[i] = oCopyFrom[i];
+
+ return *this;
+}
+
+template<class type>
+inline void DMVector<type>::DestructElement( int nIndex )
+{
+ m_ptrs[nIndex].~type();
+}
+
+template<class type>
+inline void DMVector<type>::ConstructElement( int nIndex )
+{
+ ::new((void*)(m_ptrs + nIndex)) type;
+}
+
+ /**
+ * Resizes the array. This function actually construct elements calling default constructor. Elements can be reassign via [] operator.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param nNewSize [in] - new array size. If new size is greater than current, new elements are constructed.
+ * If new size is smaller than current, extra elements are destructed.
+ * \return success (1) or failure (0)
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+int DMVector<type>::set_size( int nNewSize )
+{
+ // validate parameter
+ if ( nNewSize < 0 )
+ return 0;
+
+ // destroy deleted elements
+ int nIndex = 0;
+ for ( nIndex = m_nCount - 1; nIndex >= nNewSize; nIndex-- )
+ DestructElement( nIndex );
+
+ if ( !Reallocate( nNewSize ) )
+ { // out of memory case
+ if ( m_nCount > nNewSize )
+ m_nCount = nNewSize;
+
+ return 0;
+ }
+
+ // construct new elements
+ for ( nIndex = m_nCount; nIndex < nNewSize; nIndex++ )
+ ConstructElement( nIndex );
+
+ m_nCount = nNewSize;
+
+ return 1;
+}
+
+
+/*
+ * Private function
+ * Reallocates main storage, doesn't shrink the storage except when called with 0
+ */
+template<class type>
+int DMVector<type>::Reallocate( int nNewSize )
+{
+ // reallocate main storage
+ // don't shrink the storage except when called with 0
+
+ if ( !nNewSize )
+ {
+ if ( m_ptrs )
+ DmtMemFree( m_ptrs );
+ m_ptrs = NULL;
+ m_nAllocated = 0;
+ return 1;
+ }
+
+ if ( nNewSize < m_nAllocated )
+ return 1; // nothing to do
+
+ int nNewAlloc = (nNewSize + 3) /4 * 4;
+
+ type* pNewPtr = (type*)DmtMemAlloc( nNewAlloc* sizeof(type) );
+
+ if ( !pNewPtr )
+ return 0;
+
+ memcpy( pNewPtr, m_ptrs, sizeof(type) * m_nCount );
+
+ DmtMemFree( m_ptrs ); m_ptrs = pNewPtr;
+ m_nAllocated = nNewAlloc;
+
+ return 1;
+}
+
+ /**
+ * Appends a new element to array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - new element to add
+ * \return index of a new element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+int DMVector<type>::push_back(const type& ptr)
+{
+ if ( !set_size( m_nCount + 1 ) )
+ return m_nCount-1;
+
+ (*this)[m_nCount-1] = ptr;
+ return m_nCount-1;
+}
+
+
+ /**
+ * Detaches element.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return pointer to allocated element
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+type* DMVector<type>::detach()
+{
+ type* ptr = m_ptrs;
+ m_nCount = 0;
+ m_nAllocated = 0;
+ m_ptrs = NULL;
+ return ptr;
+}
+
+ /**
+ * Removes element from array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param index - element index; must be valid index.
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+
+template<class type>
+void DMVector<type>::remove(int index)
+{
+ if ( index < 0 || index >= m_nCount )
+ return; // invlaid index - ignore it
+
+ DestructElement( index );
+ memmove( m_ptrs + index, m_ptrs + index + 1, (m_nCount - index - 1) * sizeof(type) );
+ m_nCount--;
+}
+
+ /**
+ * Looks for an element in array.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param ptr [in] - reference to element
+ * \return index of an element if found, otherwise (-1) .
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class type>
+int DMVector<type>::find(const type& ptr) const
+{
+ for ( int nPos = 0; nPos < m_nCount; nPos++ )
+ {
+ if ( (*this)[nPos] == ptr )
+ return nPos;
+ }
+ return -1;
+}
+
+
+
+////////////////////////////////////////////////////////////
+// implementation DMMap
+//----------------------------------------------
+
+ /**
+ * Default constructor - no memory allocation performed.
+ */
+template<class Key, class Value>
+inline DMMap<Key,Value>::DMMap()
+{
+}
+ /**
+ * Destructor - freeing all dynamic resources
+ */
+template<class Key, class Value>
+inline DMMap<Key,Value>::~DMMap()
+{
+}
+
+
+/**
+ * Assignment operator
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param oCopyFrom [in] - constant reference to DMMap
+ * \return reference to the DMMap object (itself)
+ * \par Prospective Clients:
+ * Internal Classes.
+ */
+
+template<class Key, class Value>
+DMMap<Key,Value>& DMMap<Key,Value>::operator = ( const DMMap& oCopyFrom )
+{
+ m_aKeys = oCopyFrom.m_aKeys;
+ m_aValues = oCopyFrom.m_aValues;
+ return *this;
+}
+
+
+ /**
+ * Retrieves number of elements in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \return number of elements
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline int DMMap<Key,Value>::size() const
+{
+ return m_aKeys.size();
+}
+
+ /**
+ * Retrieves a value based on key. The key must exist in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] - element key
+ * \return constant value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline const Value& DMMap<Key,Value>::get(const Key & key) const
+{
+ int index=m_aKeys.find(key);
+ DMASSERT( index >= 0 );
+
+ return m_aValues[index];
+}
+
+ /**
+ * Retrieves a value based on key. The key must exist in the map.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] - element key
+ * \return value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline Value& DMMap<Key,Value>::get(const Key & key)
+{
+ int index=m_aKeys.find(key);
+ DMASSERT( index >= 0 );
+
+ return m_aValues[index];
+}
+
+ /**
+ * Adds or replaces value for the given key.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \param value [in] -element value
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline void DMMap<Key,Value>::put(const Key & key, const Value & value)
+{
+ int index=m_aKeys.find(key);
+ if (index<0)
+ {
+ int nSize = m_aKeys.size();
+
+ if ( m_aKeys.push_back(key) != nSize )
+ return;
+
+ if ( m_aValues.push_back(value) != nSize )
+ {
+ m_aKeys.remove(nSize);
+ return;
+ }
+ }
+ else
+ {
+ m_aValues[index] = value;
+ }
+}
+
+/**
+ * Removes element for the given key
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \return "true" in case of success, otherwise - "false"
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline bool DMMap<Key,Value>::remove(const Key & key)
+{
+ int index=m_aKeys.find(key);
+ if (index>=0)
+ {
+ m_aKeys.remove(index);
+ m_aValues.remove(index);
+ return true;
+ }
+ return false;
+}
+
+ /**
+ * Looks up for the element for the given key. Set value if an element has been found.
+ * \par Sync (or) Async:
+ * This is a Synchronous function.
+ * \par Secure (or) Non-Secure (or) N/A:
+ * This is a Non-Secure function.
+ * \param key [in] -element key
+ * \param rValue [out] -element value
+ * \return "true" if element has been found otherwise - "false"
+ * \par Prospective Clients:
+ * All potential applications that require configuration settings and Internal Classes.
+ */
+template<class Key, class Value>
+inline bool DMMap<Key,Value>::lookup( const Key & key, Value& rValue) const
+{
+ int index=m_aKeys.find(key);
+
+ if (index < 0)
+ return false;
+
+ rValue = m_aValues[index];
+ return true;
+}
+
+/**
+* This is a helper class. Due to gcc limitations, declaring separate class instead of typedef
+* produces smaller binary
+* \par Category: General
+* \par Persistence: Transient
+* \par Security: Non-Secure
+* \par Migration State: FINAL
+*/
+class DMStringVector : public DMVector<DMString>
+{
+};
+
+#endif
diff --git a/engine/xpl/hdr/xpl_File.h b/engine/xpl/hdr/xpl_File.h
new file mode 100644
index 0000000..effb705
--- /dev/null
+++ b/engine/xpl/hdr/xpl_File.h
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_File.h header file contains constants and function prototypes
+ * for filesystem operations
+ */
+
+#ifndef XPL_FILE_H
+#define XPL_FILE_H
+
+#include "xpl_Time.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************** CONSTANTS ****************************************************/
+
+#define XPL_FS_MAX_FILE_NAME_LENGTH 255
+#define XPL_FS_SIZE_INVALID (0)
+#define XPL_FS_HANDLE_INVALID (-1)
+#define XPL_FS_SHANDLE_INVALID (-1)
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+typedef INT32 XPL_FS_HANDLE_T;
+typedef INT32 XPL_FS_SHANDLE_T;
+typedef INT32 XPL_FS_COUNT_T;
+typedef INT32 XPL_FS_SEEK_OFFSET_T;
+typedef UINT32 XPL_FS_SIZE_T;
+typedef char XPL_FS_SEARCH_FILE[XPL_FS_MAX_FILE_NAME_LENGTH];
+
+/* This are internal flags */
+enum
+{
+ XPL_FS_RDONLY_MODE = 1, /* open for reading only */
+ XPL_FS_WRONLY_MODE = 2, /* open for writing only */
+ XPL_FS_TRUNC_MODE = 4, /* length is truncated to 0 */
+ XPL_FS_CREAT_MODE = 8, /* create if file doesn't exist */
+ XPL_FS_RDWR_MODE = 16, /* open for reading and writing */
+ XPL_FS_APPEND_MODE= 32 /* offeset is set to the end of the file
+ * prior each write */
+};
+typedef UINT8 XPL_FS_OPEN_MODE_T;
+
+enum
+{
+ XPL_FS_SEEK_SET =0, /* set offset to offset */
+ XPL_FS_SEEK_CUR, /* set offset to current plus offset */
+ XPL_FS_SEEK_END /* set fileoffset to EOF plus offset */
+ };
+typedef UINT8 XPL_FS_SEEK_MODE_T;
+
+enum
+{
+ XPL_FS_RET_SUCCESS = 0, /* operation successfully completed */
+ XPL_FS_RET_FAIL = 1, /* operation failed */
+ XPL_FS_RET_TRYAGAIN = 2, /* try later */
+ XPL_FS_RET_NOT_FOUND = 3, /* not found */
+ XPL_FS_RET_BADARGUMENT = 4, /* bad argument */
+ XPL_FS_RET_NOT_SUPPORTED = 5,/* not supported */
+ XPL_FS_RET_PERM_FAIL = 6 /* permission failed */
+
+};
+typedef UINT8 XPL_FS_RET_STATUS_T;
+
+/************** CONSTANTS ****************************************************/
+
+/*Thise are public used flags passed to XPL_FS_OpenFile */
+#define XPL_FS_FILE_READ XPL_FS_RDONLY_MODE
+#define XPL_FS_FILE_WRITE (XPL_FS_WRONLY_MODE|XPL_FS_TRUNC_MODE|XPL_FS_CREAT_MODE)
+#define XPL_FS_FILE_RDWR (XPL_FS_RDWR_MODE|XPL_FS_CREAT_MODE)
+#define XPL_FS_FILE_APPEND (XPL_FS_WRONLY_MODE|XPL_FS_APPEND_MODE|XPL_FS_CREAT_MODE)
+
+/*=================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================*/
+/* Function returns an integer value, which is used to refer to the file.
+ * If un- successful, it returns -1, and sets the result to
+ * indicate the error type. */
+XPL_FS_HANDLE_T XPL_FS_Open(CPCHAR file_uri,
+ const XPL_FS_OPEN_MODE_T open_mode,
+ XPL_FS_RET_STATUS_T * result);
+
+
+/* Function closes the file associated with handle.
+* The function returns 0 if successful, or error code set appropriately. */
+XPL_FS_RET_STATUS_T XPL_FS_Close(XPL_FS_HANDLE_T file_handle);
+
+/* Function deletes file */
+XPL_FS_RET_STATUS_T XPL_FS_Remove(CPCHAR path);
+
+/* Attempts to change name of a file */
+XPL_FS_RET_STATUS_T XPL_FS_Rename(CPCHAR old_name, CPCHAR new_name);
+
+/* Returns TRUE if file with specified name exist */
+BOOLEAN XPL_FS_Exist(CPCHAR match_uri);
+
+/* Returns TRUE if file has permission */
+BOOLEAN XPL_FS_CheckPermission(CPCHAR match_uri, XPL_FS_OPEN_MODE_T permission);
+
+/* Returns file size */
+XPL_FS_SIZE_T XPL_FS_GetSize(XPL_FS_HANDLE_T file_handle);
+
+/* Returns time of last modifiction */
+XPL_CLK_CLOCK_T XPL_FS_GetModTime(CPCHAR file_uri);
+
+/*Function attempts to read count from the file associated with file_handle,
+* and places the characters read into buffer.
+* The function returns the number of bytes read. On end-of-file, 0 is returned, on error it returns -1
+* setting result to indicate the type of error that occurred */
+XPL_FS_COUNT_T XPL_FS_Read(XPL_FS_HANDLE_T file_handle,
+ void* buffer,
+ const XPL_FS_COUNT_T count,
+ XPL_FS_RET_STATUS_T * result);
+
+/* Function attempts to write count of byte from buffer to the file associated with handle.
+* The function returns the count of bytes written to the file.
+* A return value of -1 indicates an error, with result set appropriately. */
+XPL_FS_COUNT_T XPL_FS_Write(XPL_FS_HANDLE_T file_handle,
+ void* buffer,
+ const XPL_FS_COUNT_T count,
+ XPL_FS_RET_STATUS_T * result);
+
+/* Function shall set the file offset for the open file description associated with file_handle
+* Upon successful completion, the resulting offset, as measured in bytes from the beginning of
+* the file, shall be returned. Otherwise, -1 shall be returned, result shall be set to indicate the error. */
+XPL_FS_SEEK_OFFSET_T XPL_FS_Seek(XPL_FS_HANDLE_T file_handle,
+ XPL_FS_SEEK_OFFSET_T offset,
+ XPL_FS_SEEK_MODE_T whence,
+ XPL_FS_RET_STATUS_T * result);
+
+
+/* Functionon search files in the directory and returns handler of search results */
+XPL_FS_SHANDLE_T XPL_FS_StartSearch(CPCHAR dir_uri,
+ CPCHAR extension,
+ BOOLEAN bFullName,
+ XPL_FS_RET_STATUS_T * result);
+
+/* Returns result of search. */
+XPL_FS_RET_STATUS_T XPL_FS_GetSearchResult(XPL_FS_SHANDLE_T search_handle,
+ XPL_FS_SEARCH_FILE file_name);
+
+/* Closes search */
+XPL_FS_RET_STATUS_T XPL_FS_EndSearch(XPL_FS_SHANDLE_T dir_handle);
+
+/* Attempts to create the directory. */
+XPL_FS_RET_STATUS_T XPL_FS_MkDir(CPCHAR dir_uri);
+
+/* locks the open file */
+XPL_FS_RET_STATUS_T XPL_FS_Lock(XPL_FS_HANDLE_T file_handle, BOOLEAN bLockExclusive );
+
+/* unlocks file */
+XPL_FS_RET_STATUS_T XPL_FS_Unlock(XPL_FS_HANDLE_T file_handle);
+
+/* unlinks file */
+XPL_FS_RET_STATUS_T XPL_FS_Unlink(CPCHAR name);
+
+
+/* establishes a mapping between a process address space and a file for read only operation. */
+UINT8 * XPL_FS_MemMap(XPL_FS_HANDLE_T file_handle, UINT32 size, UINT32 offset, XPL_FS_RET_STATUS_T * result);
+
+/* cancel mapping between a process address space and a file */
+XPL_FS_RET_STATUS_T XPL_FS_MemUnMap(UINT8 * pBuffer, UINT32 size);
+#ifdef LOB_SUPPORT
+/* Return the temporary ESN file directory */
+CPCHAR XPL_FS_TempEsnDir();
+/* Return free disk space */
+XPL_FS_SIZE_T XPL_FS_FreeDiskSpace(CPCHAR pEsnDir);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_FILE_H */
diff --git a/engine/xpl/hdr/xpl_HTTP.h b/engine/xpl/hdr/xpl_HTTP.h
new file mode 100644
index 0000000..f3c44e8
--- /dev/null
+++ b/engine/xpl/hdr/xpl_HTTP.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_HTTP.h header file contains constants and function prototypes
+ * for making HTTP connections.
+ */
+
+#ifndef XPL_HTTP_H
+#define XPL_HTTP_H
+
+#include "xpl_Port.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************** CONSTANTS ****************************************************/
+
+#define XPL_HTTP_HANDLE_INVALID (0)
+
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+typedef INT32 XPL_HTTP_HANDLE_T;
+
+enum {
+ XPL_HTTP_BAD_REQUEST_400 = 400,
+ XPL_HTTP_UNAUTHORIZED_401 = 401,
+ XPL_HTTP_FORBIDDEN_403 = 403,
+ XPL_HTTP_NOT_FOUND_404 = 404,
+ XPL_HTTP_BAD_METHOD_405 = 405,
+ XPL_HTTP_NOT_ACCEPTABLE_405 = 406,
+ XPL_HTTP_REQUEST_TIMEOUT_408 = 408,
+ XPL_HTTP_REQUEST_CONFLICT_409 = 409,
+ XPL_HTTP_REQUEST_CONTENT_TOO_LARGE_413 = 413,
+ XPL_HTTP_REQUEST_URI_TOO_LARGE_414 = 414,
+ XPL_HTTP_UNSUPPORTED_TYPE_415 = 415,
+ XPL_HTTP_INTERNAL_SERVER_ERROR_500 = 500,
+ XPL_HTTP_NOT_IMPLEMENTED_501 = 501,
+ XPL_HTTP_BAD_GATEWAY_502 = 502,
+ XPL_HTTP_SERVICE_UNAVAILABLE_503 = 503,
+ XPL_HTTP_GATEWAY_TIMEOUT_504 = 504,
+ XPL_HTTP_OK_200 = 200
+};
+typedef INT32 XPL_HTTP_CODE_T;
+
+enum {
+ XPL_HTTP_METHOD_POST = 0,
+ XPL_HTTP_METHOD_GET = 1,
+ XPL_HTTP_METHOD_HEAD = 2,
+};
+typedef UINT8 XPL_HTTP_METHOD_T;
+
+
+enum{
+ XPL_ADDR_DEFAULT = 0,
+ XPL_ADDR_HTTP = 1,
+ XPL_ADDR_WSP = 2,
+};
+typedef UINT16 XPL_ADDR_TYPE_T;
+
+
+enum
+{
+ XPL_HTTP_RET_SUCCESS = 0,
+ XPL_HTTP_RET_FAIL = 1,
+ XPL_HTTP_RET_CANCELLED = 2,
+ XPL_HTTP_RET_BADARGUMENT = 3,
+ XPL_HTTP_RET_NOT_SUPPORTED = 4,
+ XPL_HTTP_RET_NW_NOT_AVAILABLE = 5,
+ XPL_HTTP_RET_NO_CONNECT = 6
+
+};
+typedef UINT8 XPL_HTTP_RET_STATUS_T;
+
+/*=============================================================================
+ FUNCTION PROTOTYPES
+===============================================================================*/
+
+/* Activetes HTTP transport and set specified URL to connect with server.
+* Do not establish actual connection with server */
+XPL_HTTP_HANDLE_T XPL_HTTP_Open(CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType,
+ XPL_HTTP_RET_STATUS_T * result);
+
+/* Sets method for URL request. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_SetRequestMethod(XPL_HTTP_HANDLE_T handler,
+ XPL_HTTP_METHOD_T method);
+
+
+/* Sets a general request property.
+* This method is called before Send method */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_SetRequestProperty(XPL_HTTP_HANDLE_T handler,
+ CPCHAR buffer);
+
+/* Sends data to the resource pointed to by the URL.
+* Size specifies size of content to be sent. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_Send(XPL_HTTP_HANDLE_T handler,
+ CPCHAR buffer,
+ UINT32 size);
+
+/* Returns the response length */
+UINT32 XPL_HTTP_GetResponseLength(XPL_HTTP_HANDLE_T handler);
+
+/* Downloads the contents from the resource. The downloaded content is
+* stored in a buffer. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetResponse(XPL_HTTP_HANDLE_T handler,
+ char * buffer,
+ UINT32 size);
+
+/* Method returns the value of the header for given header field. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetHeaderField(XPL_HTTP_HANDLE_T handler,
+ CPCHAR field,
+ char ** value);
+
+/* Method returns the complete response header as sent by server. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetRespHeader(XPL_HTTP_HANDLE_T handler,
+ char ** header);
+
+/* Method returns value of content-type in the response header. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetType(XPL_HTTP_HANDLE_T handler,
+ char ** content_type);
+
+/* Gets status code from HTTP/WAP response message. Returns -1 if no code was
+ * received from the response (i.e., the response is not valid HTTP/WAP) */
+XPL_HTTP_CODE_T XPL_HTTP_GetResponseCode(XPL_HTTP_HANDLE_T handler);
+
+/* Closes connection with server. */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_Close(XPL_HTTP_HANDLE_T handler);
+
+/* Closes request transaction without closing connection with server. */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_CloseReq(XPL_HTTP_HANDLE_T handler);
+
+/* Sets URL for new request */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_SetUrl(XPL_HTTP_HANDLE_T handler ,
+ CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType);
+
+
+/* Dowloads content from the resource. The read content is stored in the file */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DowloadByFile(XPL_HTTP_HANDLE_T handler,
+ CPCHAR file_name);
+
+/* Dowloads content from the resource. The downloaded content is stored in a buffer */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DownloadByBuffer(XPL_HTTP_HANDLE_T handler,
+ UINT8 * buffer,
+ UINT32 size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_HTTP_H */
diff --git a/engine/xpl/hdr/xpl_Lib.h b/engine/xpl/hdr/xpl_Lib.h
new file mode 100644
index 0000000..7e6d2e1
--- /dev/null
+++ b/engine/xpl/hdr/xpl_Lib.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_Lib.h header file contains constants and function prototypes
+ * for loading dynamic libraries
+ */
+
+#ifndef XPL_LIB_H
+#define XPL_LIB_H
+
+#include "xpl_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************** CONSTANTS ****************************************************/
+
+#define XPL_DL_HANDLE_INVALID (0)
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+typedef void * XPL_DL_HANDLE_T;
+
+/*=============================================================================
+ FUNCTION PROTOTYPES
+===============================================================================*/
+
+/* Loads dynamic library */
+XPL_DL_HANDLE_T XPL_DL_Load(CPCHAR dllib_name);
+
+/* Gets function pointer */
+void * XPL_DL_GetFunction (XPL_DL_HANDLE_T lib_handle, CPCHAR name);
+
+/* Unloads shared objects */
+void XPL_DL_Unload(XPL_DL_HANDLE_T lib_handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_LIB_H */
diff --git a/engine/xpl/hdr/xpl_Logger.h b/engine/xpl/hdr/xpl_Logger.h
new file mode 100644
index 0000000..d065682
--- /dev/null
+++ b/engine/xpl/hdr/xpl_Logger.h
@@ -0,0 +1,252 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef XPL_LOGGER_H
+#define XPL_LOGGER_H
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include "xpl_Port.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************** CONSTANTS ****************************************************/
+
+#define MAX_LOG_STRING_SIZE 255
+
+#define XPL_LOG_NOLOGS 0
+#define XPL_LOG_DEBUG 1
+#define XPL_LOG_WARN 2
+#define XPL_LOG_ERROR 3
+#define XPL_LOG_ALL 4
+
+// DM: for each XPL_LOG_Startup call there must be a corresponding XPL_LOG_Shutdown call
+void XPL_LOG_Startup();
+void XPL_LOG_Shutdown();
+
+#if defined(PLATFORM_X86) || defined(EZX_PRODUCT_SCMA11REF)
+
+#if defined(PLATFORM_ANDROID)
+ #define LOG_TAG "libdmengine"
+ #include <utils/Log.h>
+
+ #ifndef LOGD
+ #define LOGD(args...) ALOGD(args)
+ #endif
+
+ #ifndef LOGE
+ #define LOGE(args...) ALOGE(args)
+ #endif
+
+ #ifndef LOGI
+ #define LOGI(args...) ALOGI(args)
+ #endif
+
+ #ifndef LOGV
+ #define LOGV(args...) ALOGV(args)
+ #endif
+
+ #ifndef LOGW
+ #define LOGW(args...) ALOGW(args)
+ #endif
+
+ #define XPL_LOG_Error(logPortId, format, args...) \
+ LOGE(format, ##args )
+
+ #define XPL_LOG_Warn(logPortId, format, args...) \
+ LOGW(format, ##args )
+
+ #define XPL_LOG_Debug(logPortId, format, args...) \
+ LOGD(format, ##args )
+
+ #define XPL_LOG_Enter(logPortId, format, args...) \
+ LOGD(format, ##args )
+
+ #define XPL_LOG_Leave(logPortId, format, args...) \
+ LOGD(format, ##args )
+
+ #define XPL_LOG_Startup()
+ #define XPL_LOG_Shutdown()
+
+ // define XPL_LOG_LEVEL in makefile; don't define it here.
+// #define XPL_LOG_LEVEL XPL_LOG_ALL
+
+ // DM: use DM log if building standalone DM engine on Redhat linux machine
+#elif ( XPL_LOG_LEVEL == XPL_LOG_DEBUG ) || ( XPL_LOG_LEVEL == XPL_LOG_WARN ) || ( XPL_LOG_LEVEL == XPL_LOG_ERROR ) || ( XPL_LOG_LEVEL == XPL_LOG_ALL )
+ void XPL_LOG_Error(XPL_LOGS_PORT_T logPort, CPCHAR format, ...);
+ void XPL_LOG_Warn(XPL_LOGS_PORT_T logPort, CPCHAR format, ...);
+ void XPL_LOG_Debug(XPL_LOGS_PORT_T logPort, CPCHAR format, ...);
+ void XPL_LOG_Enter(XPL_LOGS_PORT_T logPort, CPCHAR format, ...);
+ void XPL_LOG_Leave(XPL_LOGS_PORT_T logPort, CPCHAR format, ...);
+#endif
+
+#else
+ // DM: use LJ system log if this is a LJ phone build
+ #include <libaplog.h>
+
+ struct aplog_port_struct* XPL_GetPortPtr( XPL_LOGS_PORT_T logPort );
+
+ #define XPL_LOG_Error(logPortId, format, args...) \
+ aplog_port_err_fileline( XPL_GetPortPtr( logPortId ), format, ##args )
+
+ #define XPL_LOG_Warn(logPortId, format, args...) \
+ aplog_port_warning_fileline( XPL_GetPortPtr( logPortId ), format, ##args )
+
+ #define XPL_LOG_Debug(logPortId, format, args...) \
+ aplog_port_debug_fileline( XPL_GetPortPtr( logPortId ), format, ##args )
+
+ #define XPL_LOG_Enter(logPortId, format, args...) \
+ aplog_port_func_enter_print( XPL_GetPortPtr( logPortId ), format, ##args )
+
+ #define XPL_LOG_Leave(logPortId, format, args...) \
+ aplog_port_func_exit_print( XPL_GetPortPtr( logPortId ), format, ##args )
+
+ #define XPL_LOG_LEVEL XPL_LOG_ALL
+#endif
+
+#if ( XPL_LOG_LEVEL == XPL_LOG_DEBUG ) || ( XPL_LOG_LEVEL == XPL_LOG_WARN ) || ( XPL_LOG_LEVEL == XPL_LOG_ERROR ) || ( XPL_LOG_LEVEL == XPL_LOG_ALL )
+ #define XPL_LOG_DM_API_Error2( args... ) XPL_LOG_Error(XPL_LOG_PORT_DM_API, args)
+ #define XPL_LOG_DM_PLG_Error2( args... ) XPL_LOG_Error(XPL_LOG_PORT_DM_PLG, args)
+ #define XPL_LOG_DM_TMN_Error2( args... ) XPL_LOG_Error(XPL_LOG_PORT_DM_TMN, args)
+ #define XPL_LOG_DM_SESS_Error2( args... ) XPL_LOG_Error(XPL_LOG_PORT_DM_SESS, args)
+ #define XPL_LOG_DM_CONN_Error2( args... ) XPL_LOG_Error(XPL_LOG_PORT_DM_CONN, args)
+ #define XPL_LOG_DM_XPL_Error2( args... ) XPL_LOG_Error(XPL_LOG_PORT_DM_XPL, args)
+ #define XPL_LOG_DM_CP_Error2( args... ) XPL_LOG_Error(XPL_LOG_PORT_DM_CP, args)
+
+ #define XPL_LOG_DM_API_Error( args... ) XPL_LOG_DM_API_Error2 args
+ #define XPL_LOG_DM_PLG_Error( args... ) XPL_LOG_DM_PLG_Error2 args
+ #define XPL_LOG_DM_TMN_Error( args... ) XPL_LOG_DM_TMN_Error2 args
+ #define XPL_LOG_DM_SESS_Error( args... ) XPL_LOG_DM_SESS_Error2 args
+ #define XPL_LOG_DM_CONN_Error( args... ) XPL_LOG_DM_CONN_Error2 args
+ #define XPL_LOG_DM_XPL_Error( args... ) XPL_LOG_DM_XPL_Error2 args
+ #define XPL_LOG_DM_CP_Error( args... ) XPL_LOG_DM_CP_Error2 args
+#else
+ #define XPL_LOG_DM_API_Error( args... )
+ #define XPL_LOG_DM_PLG_Error( args... )
+ #define XPL_LOG_DM_TMN_Error( args... )
+ #define XPL_LOG_DM_SESS_Error( args... )
+ #define XPL_LOG_DM_CONN_Error( args... )
+ #define XPL_LOG_DM_XPL_Error( args... )
+ #define XPL_LOG_DM_CP_Error( args... )
+#endif
+
+#if ( XPL_LOG_LEVEL == XPL_LOG_DEBUG ) || ( XPL_LOG_LEVEL == XPL_LOG_WARN ) || ( XPL_LOG_LEVEL == XPL_LOG_ALL )
+ #define XPL_LOG_DM_API_Warn2( args... ) XPL_LOG_Warn(XPL_LOG_PORT_DM_API, args)
+ #define XPL_LOG_DM_PLG_Warn2( args... ) XPL_LOG_Warn(XPL_LOG_PORT_DM_PLG, args)
+ #define XPL_LOG_DM_TMN_Warn2( args... ) XPL_LOG_Warn(XPL_LOG_PORT_DM_TMN, args)
+ #define XPL_LOG_DM_SESS_Warn2( args... ) XPL_LOG_Warn(XPL_LOG_PORT_DM_SESS, args)
+ #define XPL_LOG_DM_CONN_Warn2( args... ) XPL_LOG_Warn(XPL_LOG_PORT_DM_CONN, args)
+ #define XPL_LOG_DM_XPL_Warn2( args... ) XPL_LOG_Warn(XPL_LOG_PORT_DM_XPL, args)
+ #define XPL_LOG_DM_CP_Warn2( args... ) XPL_LOG_Warn(XPL_LOG_PORT_DM_CP, args)
+
+ #define XPL_LOG_DM_API_Warn( args... ) XPL_LOG_DM_API_Warn2 args
+ #define XPL_LOG_DM_PLG_Warn( args... ) XPL_LOG_DM_PLG_Warn2 args
+ #define XPL_LOG_DM_TMN_Warn( args... ) XPL_LOG_DM_TMN_Warn2 args
+ #define XPL_LOG_DM_SESS_Warn( args... ) XPL_LOG_DM_SESS_Warn2 args
+ #define XPL_LOG_DM_CONN_Warn( args... ) XPL_LOG_DM_CONN_Warn2 args
+ #define XPL_LOG_DM_XPL_Warn( args... ) XPL_LOG_DM_XPL_Warn2 args
+ #define XPL_LOG_DM_CP_Warn( args... ) XPL_LOG_DM_CP_Warn2 args
+#else
+ #define XPL_LOG_DM_API_Warn( args... )
+ #define XPL_LOG_DM_PLG_Warn( args... )
+ #define XPL_LOG_DM_TMN_Warn( args... )
+ #define XPL_LOG_DM_SESS_Warn( args... )
+ #define XPL_LOG_DM_CONN_Warn( args... )
+ #define XPL_LOG_DM_XPL_Warn( args... )
+ #define XPL_LOG_DM_CP_Warn( args... )
+#endif
+
+#if ( XPL_LOG_LEVEL == XPL_LOG_DEBUG ) || ( XPL_LOG_LEVEL == XPL_LOG_ALL )
+ #define XPL_LOG_DM_API_Debug2( args... ) XPL_LOG_Debug(XPL_LOG_PORT_DM_API, args)
+ #define XPL_LOG_DM_PLG_Debug2( args... ) XPL_LOG_Debug(XPL_LOG_PORT_DM_PLG, args)
+ #define XPL_LOG_DM_TMN_Debug2( args... ) XPL_LOG_Debug(XPL_LOG_PORT_DM_TMN, args)
+ #define XPL_LOG_DM_SESS_Debug2( args... ) XPL_LOG_Debug(XPL_LOG_PORT_DM_SESS, args)
+ #define XPL_LOG_DM_CONN_Debug2( args... ) XPL_LOG_Debug(XPL_LOG_PORT_DM_CONN, args)
+ #define XPL_LOG_DM_XPL_Debug2( args... ) XPL_LOG_Debug(XPL_LOG_PORT_DM_XPL, args)
+ #define XPL_LOG_DM_CP_Debug2( args... ) XPL_LOG_Debug(XPL_LOG_PORT_DM_CP, args)
+
+ #define XPL_LOG_DM_API_Enter2( args... ) XPL_LOG_Enter(XPL_LOG_PORT_DM_API, args)
+ #define XPL_LOG_DM_PLG_Enter2( args... ) XPL_LOG_Enter(XPL_LOG_PORT_DM_PLG, args)
+ #define XPL_LOG_DM_TMN_Enter2( args... ) XPL_LOG_Enter(XPL_LOG_PORT_DM_TMN, args)
+ #define XPL_LOG_DM_SESS_Enter2( args... ) XPL_LOG_Enter(XPL_LOG_PORT_DM_SESS, args)
+ #define XPL_LOG_DM_CONN_Enter2( args... ) XPL_LOG_Enter(XPL_LOG_PORT_DM_CONN, args)
+ #define XPL_LOG_DM_XPL_Enter2( args... ) XPL_LOG_Enter(XPL_LOG_PORT_DM_XPL, args)
+ #define XPL_LOG_DM_CP_Enter2( args... ) XPL_LOG_Enter(XPL_LOG_PORT_DM_CP, args)
+
+ #define XPL_LOG_DM_API_Leave2( args... ) XPL_LOG_Leave(XPL_LOG_PORT_DM_API, args)
+ #define XPL_LOG_DM_PLG_Leave2( args... ) XPL_LOG_Leave(XPL_LOG_PORT_DM_PLG, args)
+ #define XPL_LOG_DM_TMN_Leave2( args... ) XPL_LOG_Leave(XPL_LOG_PORT_DM_TMN, args)
+ #define XPL_LOG_DM_SESS_Leave2( args... ) XPL_LOG_Leave(XPL_LOG_PORT_DM_SESS, args)
+ #define XPL_LOG_DM_CONN_Leave2( args... ) XPL_LOG_Leave(XPL_LOG_PORT_DM_CONN, args)
+ #define XPL_LOG_DM_XPL_Leave2( args... ) XPL_LOG_Leave(XPL_LOG_PORT_DM_XPL, args)
+ #define XPL_LOG_DM_CP_Leave2( args... ) XPL_LOG_Leave(XPL_LOG_PORT_DM_CP, args)
+
+ #define XPL_LOG_DM_API_Debug( args... ) XPL_LOG_DM_API_Debug2 args
+ #define XPL_LOG_DM_PLG_Debug( args... ) XPL_LOG_DM_PLG_Debug2 args
+ #define XPL_LOG_DM_TMN_Debug( args... ) XPL_LOG_DM_TMN_Debug2 args
+ #define XPL_LOG_DM_SESS_Debug( args... ) XPL_LOG_DM_SESS_Debug2 args
+ #define XPL_LOG_DM_CONN_Debug( args... ) XPL_LOG_DM_CONN_Debug2 args
+ #define XPL_LOG_DM_XPL_Debug( args... ) XPL_LOG_DM_XPL_Debug2 args
+ #define XPL_LOG_DM_CP_Debug( args... ) XPL_LOG_DM_CP_Debug2 args
+
+ #define XPL_LOG_DM_API_Enter( args... ) XPL_LOG_DM_API_Enter2 args
+ #define XPL_LOG_DM_PLG_Enter( args... ) XPL_LOG_DM_PLG_Enter2 args
+ #define XPL_LOG_DM_TMN_Enter( args... ) XPL_LOG_DM_TMN_Enter2 args
+ #define XPL_LOG_DM_SESS_Enter( args... ) XPL_LOG_DM_SESS_Enter2 args
+ #define XPL_LOG_DM_CONN_Enter( args... ) XPL_LOG_DM_CONN_Enter2 args
+ #define XPL_LOG_DM_XPL_Enter( args... ) XPL_LOG_DM_XPL_Enter2 args
+ #define XPL_LOG_DM_CP_Enter( args... ) XPL_LOG_DM_CP_Enter2 args
+
+ #define XPL_LOG_DM_API_Leave( args... ) XPL_LOG_DM_API_Leave2 args
+ #define XPL_LOG_DM_PLG_Leave( args... ) XPL_LOG_DM_PLG_Leave2 args
+ #define XPL_LOG_DM_TMN_Leave( args... ) XPL_LOG_DM_TMN_Leave2 args
+ #define XPL_LOG_DM_SESS_Leave( args... ) XPL_LOG_DM_SESS_Leave2 args
+ #define XPL_LOG_DM_CONN_Leave( args... ) XPL_LOG_DM_CONN_Leave2 args
+ #define XPL_LOG_DM_XPL_Leave( args... ) XPL_LOG_DM_XPL_Leave2 args
+ #define XPL_LOG_DM_CP_Leave( args... ) XPL_LOG_DM_CP_Leave2 args
+#else
+ #define XPL_LOG_DM_API_Debug( args... )
+ #define XPL_LOG_DM_PLG_Debug( args... )
+ #define XPL_LOG_DM_TMN_Debug( args... )
+ #define XPL_LOG_DM_SESS_Debug( args... )
+ #define XPL_LOG_DM_CONN_Debug( args... )
+ #define XPL_LOG_DM_XPL_Debug( args... )
+ #define XPL_LOG_DM_CP_Debug( args... )
+
+ #define XPL_LOG_DM_API_Enter( args... )
+ #define XPL_LOG_DM_PLG_Enter( args... )
+ #define XPL_LOG_DM_TMN_Enter( args... )
+ #define XPL_LOG_DM_SESS_Enter( args... )
+ #define XPL_LOG_DM_CONN_Enter( args... )
+ #define XPL_LOG_DM_XPL_Enter( args... )
+ #define XPL_LOG_DM_CP_Enter( args... )
+
+ #define XPL_LOG_DM_API_Leave( args... )
+ #define XPL_LOG_DM_PLG_Leave( args... )
+ #define XPL_LOG_DM_TMN_Leave( args... )
+ #define XPL_LOG_DM_SESS_Leave( args... )
+ #define XPL_LOG_DM_CONN_Leave( args... )
+ #define XPL_LOG_DM_XPL_Leave( args... )
+ #define XPL_LOG_DM_CP_Leave( args... )
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_LOGGER_H */
diff --git a/engine/xpl/hdr/xpl_Memory.h b/engine/xpl/hdr/xpl_Memory.h
new file mode 100644
index 0000000..7ca7740
--- /dev/null
+++ b/engine/xpl/hdr/xpl_Memory.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The XPL_Memory.h header file contains constants and function prototypes
+ * for memory management
+ */
+
+#ifndef XPL_MEMORY_H
+#define XPL_MEMORY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include <stddef.h>
+#include <string.h>
+#include "xpl_Types.h"
+
+/************** CONSTANTS ****************************************************/
+
+#define xplAllocMem(bufsize) xplAllocMemEx(bufsize,__FILE__,__LINE__)
+#define xplFreeMem(buf) { xplFreeMemEx(buf,__FILE__,__LINE__); (buf) = XPL_NULL; }
+
+
+#define XPL_FreeAndSetNull(_x) \
+ if ((_x)!=NULL) { xplFreeMem(_x); (_x)=XPL_NULL; }
+
+
+/*==============================================================================
+ FUNCTION PROTOTYPES
+================================================================================*/
+
+/* Allocates memory buffer */
+void * xplAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine );
+
+/* Deallocate memory buffer */
+void xplFreeMemEx(void *ptr, CPCHAR szFile, int nLine);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_MEMORY_H */
diff --git a/engine/xpl/hdr/xpl_Message.h b/engine/xpl/hdr/xpl_Message.h
new file mode 100644
index 0000000..0496ef1
--- /dev/null
+++ b/engine/xpl/hdr/xpl_Message.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef XPL_MESSAGE_H
+#define XPL_MESSAGE_H
+
+#include "xpl_Port.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************** CONSTANTS ****************************************************/
+
+#define XPL_DM_TASK_MESSAGE_CATEGORY 0
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+enum
+{
+ XPL_MSG_RET_SUCCESS = 0, /* operation successfully completed */
+ XPL_MSG_RET_FAIL = 1, /* operation failed */
+ XPL_MSG_RET_BADARGUMENT = 2, /* bad argument */
+};
+typedef UINT8 XPL_MSG_RET_STATUS_T;
+
+
+/*=================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================*/
+
+/* Sends asyncronyous message/event. Callback may be incorporated into message body if required */
+XPL_MSG_RET_STATUS_T XPL_MSG_Send(XPL_PORT_T port,
+ UINT32 msgtype,
+ void *data,
+ UINT32 size);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_MESSAGE_H */
diff --git a/engine/xpl/hdr/xpl_Port.h b/engine/xpl/hdr/xpl_Port.h
new file mode 100644
index 0000000..3572c15
--- /dev/null
+++ b/engine/xpl/hdr/xpl_Port.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef XPL_PORT_H
+#define XPL_PORT_H
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include "xpl_Types.h"
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+enum {
+ XPL_PORT_DM = 0, /* Device management APPs */
+ XPL_PORT_DM_TASK /* Device management task port is used for async API messaging only */
+};
+typedef UINT8 XPL_PORT_T;
+
+enum {
+ XPL_LOG_PORT_DM_FIRST = 0,
+ XPL_LOG_PORT_DM_API = XPL_LOG_PORT_DM_FIRST, /* Log DM API */
+ XPL_LOG_PORT_DM_TMN, /* Log Tree management */
+ XPL_LOG_PORT_DM_PLG, /* Log Plugin */
+ XPL_LOG_PORT_DM_SESS, /* Log Session */
+ XPL_LOG_PORT_DM_CONN, /* Log Connectivity */
+ XPL_LOG_PORT_DM_XPL, /* Log Portlib */
+ XPL_LOG_PORT_DM_CP, /* Client provisioning */
+
+ /* DM: Insert new log ports here */
+
+ XPL_LOG_PORT_DM_LAST
+
+};
+
+typedef UINT8 XPL_LOGS_PORT_T;
+
+#endif /* XPL_PORT_H */
diff --git a/engine/xpl/hdr/xpl_Prompt.h b/engine/xpl/hdr/xpl_Prompt.h
new file mode 100644
index 0000000..1c16095
--- /dev/null
+++ b/engine/xpl/hdr/xpl_Prompt.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_Prompt.h header file defines prompt IDs used across E2E
+ * components.
+ */
+
+#ifndef XPL_PROMPT_H
+#define XPL_PROMPT_H
+
+/************** HEADER FILE INCLUDES *****************************************/
+
+#include "xpl_Types.h"
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+enum {
+ XPL_PROMPT_DM_ALERT_DISPLAY = 0, /* DisplayAlert */
+ XPL_PROMPT_DM_ALERT_CONFIRM, /* ConfirmAlert */
+ XPL_PROMPT_DM_ALERT_TEXT_INPUT, /* TextInputAlert */
+ XPL_PROMPT_DM_ALERT_SINGLE_CHOICE, /* SingleChoiceAlert */
+ XPL_PROMPT_DM_ALERT_MULTIPLE_CHOICE, /* MultipleChoiceAlert */
+
+ /* all new prompt IDs should be added before XPL_PROMPT_LAST */
+ XPL_PROMPT_LAST
+};
+typedef UINT32 XPL_PROMPT_ID_T;
+
+#endif /* XPL_PROMPT_H */
diff --git a/engine/xpl/hdr/xpl_Regex.h b/engine/xpl/hdr/xpl_Regex.h
new file mode 100644
index 0000000..d767bb5
--- /dev/null
+++ b/engine/xpl/hdr/xpl_Regex.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef XPL_REGEX_H
+#define XPL_REGEX_H
+
+#include "xpl_Types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*===================================================================================
+ FUNCTION PROTOTYPES
+=====================================================================================*/
+
+// DM: pseudo pattern for P2K implementation
+#define XPL_RG_PATTERN_IS_DATE "<date>"
+#define XPL_RG_PATTERN_IS_TIME "<time>"
+#define XPL_RG_PATTERN_IS_FLOAT "<float>"
+
+
+/* Function shall compile the regular expression contained in the string pointed to
+ * by the pattern argument and compare with string pointed by str. */
+BOOLEAN XPL_RG_Comp(CPCHAR pattern, CPCHAR str);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* XPL_REGEX_H */
diff --git a/engine/xpl/hdr/xpl_StringUtil.h b/engine/xpl/hdr/xpl_StringUtil.h
new file mode 100644
index 0000000..f14e1b3
--- /dev/null
+++ b/engine/xpl/hdr/xpl_StringUtil.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef XPL_STRINGUTIL_H
+#define XPL_STRINGUTIL_H
+
+/**
+ \file xpl_StringUtil.h
+ \brief The xpl_StringUtil.h header file contains function prototypes for basic string operations.
+ <b>Warning:</b> All functions, structures, and classes from this header file are for internal usage only!!!
+*/
+
+/************** HEADER FILE INCLUDES *****************************************/
+#include "stdlib.h"
+#include "string.h"
+#include "stdio.h"
+#include "xpl_Types.h"
+
+/************** FUNCTIONS ****************************************************/
+
+/** Definition function xplStrlen for cross platform support*/
+#define xplStrlen(str) ((str!=XPL_NULL)? strlen(str):0)
+
+/** Definition function xplStrcpy for cross platform support*/
+#define xplStrcpy(target, source) strcpy(target, source)
+
+/** Definition function xplStrncpy for cross platform support*/
+#define xplStrncpy(target, source, count) strncpy(target, source, count)
+
+/** Definition function xplStrcat for cross platform support*/
+#define xplStrcat(target, source) strcat(target, source)
+
+/** Definition function xplStrncat for cross platform support*/
+#define xplStrncat(target, source, count) strncat(target, source, count)
+
+/** Definition function xplStrcmp for cross platform support*/
+#define xplStrcmp(target, source) strcmp(target, source)
+
+/** Definition function xplStrncmp for cross platform support*/
+#define xplStrncmp(target, source, count) strncmp(target, source, count)
+
+/** Definition function xplStrchr for cross platform support*/
+#define xplStrchr(source, target) strchr(source, target)
+
+/** Definition function xplStrrchr for cross platform support*/
+#define xplStrrchr(source, target) strrchr(source, target)
+
+/** Definition function xplStrstr for cross platform support*/
+#define xplStrstr(source, target) strstr(source, target)
+
+/** Definition function xplTolower for cross platform support*/
+#define xplTolower(source) tolower(source)
+
+/** Definition function xplAtoi for cross platform support*/
+#define xplAtoi(source) atoi(source)
+
+/** Definition function xplAtol for cross platform support*/
+#define xplAtol(source) atol(source)
+
+/** Definition function xplAtoll for cross platform support*/
+#define xplAtoll(source) atoll(source)
+
+/** Definition function xplSprintf for cross platform support*/
+#define xplSprintf sprintf
+
+/** Definition function xplSnprintf for cross platform support*/
+#define xplSnprintf snprintf
+
+/** Definition function xplSscanf for cross platform support*/
+#define xplSscanf sscanf
+
+#endif /* XPL_STRINGUTIL_H */
diff --git a/engine/xpl/hdr/xpl_Time.h b/engine/xpl/hdr/xpl_Time.h
new file mode 100644
index 0000000..02433d1
--- /dev/null
+++ b/engine/xpl/hdr/xpl_Time.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef XPL_TIME_H
+#define XPL_TIME_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/************** HEADER FILE INCLUDES *****************************************/
+#include "xpl_Port.h"
+
+/************** CONSTANTS ****************************************************/
+#define XPL_CLK_INVALID_CLOCK (0xffffffff)
+#define XPL_CLK_HANDLE_INVALID (-1)
+
+
+#define XPL_DM_TIMER_CATEGORY 0
+
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+typedef UINT32 XPL_CLK_CLOCK_T;
+typedef UINT64 XPL_CLK_LONG_CLOCK_T;
+typedef INT32 XPL_TIMER_HANDLE_T;
+
+typedef struct
+{
+ INT32 tm_sec; /* valid range for seconds is from 0 to 61.*/
+ INT32 tm_min; /* minute of the hour. Valid range is from 0 to 59. */
+ INT32 tm_hour; /* hour of the day. Valid range is from 0 to 23. */
+
+ INT32 tm_mday; /* day of the month. Valid range is from 1 to 31. */
+ INT32 tm_mon; /* month of the year. Valid range is from 0 to 11. */
+ INT32 tm_year; /* the year since 1900 */
+ INT32 tm_wday; /* days since Sunday. Valid range is 0 to 6. */
+ INT32 tm_yday; /* days since January 1. Valid range is 0 to 365 */
+ INT32 tm_isdst;/* flag for alternate daylight savings time.
+ 1 indicates DST active, 0 indicates DST inactive */
+
+} XPL_CLK_TM_T;
+
+
+enum
+{
+ XPL_CLK_RET_SUCCESS = 0, /* operation successfully completed */
+ XPL_CLK_RET_FAIL = 1, /* operation failed */
+ XPL_CLK_RET_BADARGUMENT = 2 /* bad argument */
+};
+typedef UINT8 XPL_CLK_RET_STATUS_T;
+
+typedef void (*XPL_CLK_TIMER_CBACK)(void);
+
+/*=================================================================================
+ FUNCTION PROTOTYPES
+===================================================================================*/
+
+/* Returns the value of time in seconds since the Epoch */
+XPL_CLK_CLOCK_T XPL_CLK_GetClock();
+
+/* Returns the value of time in microseconds since Epoch */
+XPL_CLK_LONG_CLOCK_T XPL_CLK_GetClockMs();
+
+/* Returns a broken-down time expressed as
+* Coordinated Universal Time (UTC). The broken-down time is stored in the
+* structure referred to by parsed_clock. */
+XPL_CLK_RET_STATUS_T XPL_CLK_GetTime(XPL_CLK_TM_T *parsed_time);
+
+/*Converts the calendar time pointed to by clock into a broken-down time expressed as
+* Coordinated Universal Time (UTC). The broken-down time is stored in the
+ structure referred to by parsed_clock. */
+XPL_CLK_RET_STATUS_T XPL_CLK_UnpackTime(XPL_CLK_CLOCK_T clock, XPL_CLK_TM_T *parsed_clock);
+
+/* Converts the broken-down time, expressed as local time, in the structure pointed
+ to by parsed_clock, into a time since the Epoch value with the same encoding as that
+ of the values returned by XPL_CLK_Time(). */
+XPL_CLK_CLOCK_T XPL_CLK_PackTime(XPL_CLK_TM_T *parsed_clock);
+
+/* Returs timezone */
+INT32 XPL_CLK_GetTimeZone(void);
+
+/* Starts timer */
+XPL_TIMER_HANDLE_T XPL_CLK_StartTimer(XPL_PORT_T port, UINT32 interval, XPL_CLK_TIMER_CBACK reply_timer);
+
+/* Stops timer */
+XPL_CLK_RET_STATUS_T XPL_CLK_StopTimer(XPL_TIMER_HANDLE_T handle);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_TIME_H */
diff --git a/engine/xpl/hdr/xpl_Types.h b/engine/xpl/hdr/xpl_Types.h
new file mode 100644
index 0000000..f28aef4
--- /dev/null
+++ b/engine/xpl/hdr/xpl_Types.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef XPL_TYPES_H
+#define XPL_TYPES_H
+
+/**
+ \file xpl_Types.h
+ \brief The xpl_Types.h header file contains constants and basic types definition
+*/
+
+#include <stdbool.h>
+
+/************** CONSTANTS ****************************************************/
+
+#ifndef TRUE
+/** Define TRUE */
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+/** Define FALSE */
+#define FALSE 0
+#endif
+
+#ifndef XPL_NULL
+/** Define XPL_NULL */
+ #define XPL_NULL (0)
+#endif
+
+#ifndef NULL
+/** Define NULL */
+ #define NULL ((void*) 0)
+#endif
+
+
+/************** STRUCTURES, ENUMS, AND TYPEDEFS ******************************/
+
+#ifndef INT8
+/** Definition INT8 as signed char */
+typedef signed char INT8;
+#endif
+
+#ifndef UINT8
+/** Definition UINT8 as unsigned char */
+typedef unsigned char UINT8;
+#endif
+
+#ifndef INT16
+/** Definition INT16 as short integer */
+typedef short int INT16;
+#endif
+
+#ifndef UINT16
+/** Definition UINT16 as unsigned short integer*/
+typedef unsigned short int UINT16;
+#endif
+
+#ifndef INT32
+/** Definition INT32 as integer*/
+typedef int INT32;
+#endif
+
+#ifndef UINT32
+/** Definition UINT32 as unsigned integer */
+typedef unsigned int UINT32;
+#endif
+
+#ifndef INT64
+/** Definition INT64 as long integer */
+typedef long long int INT64;
+#endif
+
+#ifndef UINT64
+/** Definition UINT64 as unsigned long integer */
+typedef unsigned long long int UINT64;
+#endif
+
+
+#ifndef BOOLEAN
+/** Definition BOOLEAN as unsigned char*/
+typedef unsigned char BOOLEAN;
+#endif
+
+#ifndef BOOLTYPE
+/**
+* BOOLTYPE introduced for EZX backward compatibility .
+* It should be used in DmtData and DmtNode constructor and access methods only.
+*/
+typedef bool BOOLTYPE;
+#endif
+
+/** Definition CPCHAR as c onstant character pointer */
+typedef const char* CPCHAR;
+
+#ifndef FLOAT
+/** Definition FLOAT as float*/
+typedef float FLOAT;
+#endif
+
+#endif /* XPL_TYPES_H */
diff --git a/engine/xpl/hdr/xpl_dm_Manager.h b/engine/xpl/hdr/xpl_dm_Manager.h
new file mode 100644
index 0000000..8b48bf4
--- /dev/null
+++ b/engine/xpl/hdr/xpl_dm_Manager.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_dm_manager.h header file contains constants and function prototypes
+ * for dm specific functions
+ */
+
+#ifndef XPL_DMMANAGER_H
+#define XPL_DMMANAGER_H
+
+/************** HEADER FILE INCLUDES *****************************************/
+#include "dmtDefs.h"
+
+enum {
+ SYNCML_DM_SETTINGS_PATH,
+ SYNCML_DM_PLUGINS_PATH,
+ SYNCML_DM_SECURITY_LEVEL,
+ SYNCML_DM_ESCAPE_CHAR,
+ SYNCML_DM_MEMORY_AGING_INTERVAL,
+ SYNCML_DM_MEMORY_AGING_TIME,
+ SYNCML_DM_POWER_FAIL_IJECTION,
+ SYNCML_DM_DUMP_SESSION_PACKAGE_PATH,
+ SYNCML_DM_SESSION_LIB,
+ SYNCML_DM_VERSION,
+ SYNCML_DM_DMACC_ROOT_PATH,
+ SYNCML_DM_NODENAME_SERVERID,
+ SYNCML_DM_FEATURE_ID_POC_PROVISION_VIA_OMADM,
+ SYNCML_DM_SESSION_ID,
+};
+typedef INT8 SYNCML_DM_ENVIRONMENT_T;
+
+#define SYNCML_REP_PROTOCOL_VERSION_1_1 "1.1"
+#define SYNCML_REP_PROTOCOL_VERSION_1_2 "1.2"
+
+
+// DM: file, which contains one of SYNCML_REP_PROTOCOL_VERSION_* constants
+#define XPL_VERSION_FILENAME "version.txt"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SYNCML_DM_RET_STATUS_T XPL_DM_Init(void);
+SYNCML_DM_RET_STATUS_T XPL_DM_DeInit(void);
+CPCHAR XPL_DM_GetEnv(SYNCML_DM_ENVIRONMENT_T env_var);
+BOOLEAN XPL_DM_IsFeatureEnabled(CPCHAR pUri);
+
+#ifdef DM_STATIC_FILES
+const UINT8 * XPL_DM_GetPluginsConfig(UINT32 *pSize);
+const UINT8 * XPL_DM_GetFstab(UINT32 *pSize);
+UINT8 XPL_DM_GetMDFCount();
+const UINT8 * XPL_DM_GetMDF(UINT8 index, UINT32 *pSize);
+#endif
+
+UINT32 XPL_DM_GetChunkSize();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_DMMANAGER_H */
diff --git a/engine/xpl/hdr/xpl_dm_Notifications.h b/engine/xpl/hdr/xpl_dm_Notifications.h
new file mode 100644
index 0000000..01e1c00
--- /dev/null
+++ b/engine/xpl/hdr/xpl_dm_Notifications.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_Notifications.h header file contains constants and function prototypes
+ * for dm specific notification functions
+ */
+
+#ifndef XPL_DM_NOTIFICATIONS_H
+#define XPL_DM_NOTIFICATIONS_H
+
+#include "dmtDefs.h"
+#include "dmtEventData.hpp"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void XPL_DM_NotifyTreeUpdate(CPCHAR szTopic,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_TYPE_T nType,
+ UINT8 * pData,
+ UINT32 size);
+
+void XPL_DM_NotifySessionProgress(BOOLEAN bIsStarted);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* XPL_NOTIFICATIONS_H */
diff --git a/engine/xpl/hdr/xpl_dm_ServerAlert.h b/engine/xpl/hdr/xpl_dm_ServerAlert.h
new file mode 100644
index 0000000..83e6627
--- /dev/null
+++ b/engine/xpl/hdr/xpl_dm_ServerAlert.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef XPL_DMSERVERALERT_H
+#define XPL_DMSERVERALERT_H
+
+/************** HEADER FILE INCLUDES *****************************************/
+#include "xpl_dm_ServerAlertDef.h"
+#include "dmtError.h"
+#include "dmstring.h"
+#include "dmvector.h"
+
+
+typedef struct
+{
+ XPL_DM_ALERT_RES_T action;
+ DMString response;
+} XPL_DM_ALERT_TEXTINPUT_RES_T;
+
+typedef struct
+{
+ XPL_DM_ALERT_RES_T action;
+ INT32 response;
+} XPL_DM_ALERT_SCHOICE_RES_T;
+
+typedef struct
+{
+ XPL_DM_ALERT_RES_T action;
+ DMStringVector responses;
+} XPL_DM_ALERT_MCHOICE_RES_T;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Display a confirm alert message box, user can confirm or cancel the action
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param defaultResponse default user action when timeout
+ * @param responseCode user's action will be returned here.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowConfirmAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ XPL_DM_ALERT_RES_T defaultResponse,
+ XPL_DM_ALERT_RES_T * responseCode);
+
+/**
+ * Display a text messages
+ *
+ * @param minDisplayTime minimum display time, in seconds.
+ * @param msg messages to display
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowDisplayAlert(INT32 minDisplayTime,
+ CPCHAR msg);
+
+
+/**
+ * Display a text input message box for user to enter input.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param defaultResponse default user action when timeout
+ * @param maxLength length allowed in user input
+ * @param inputType data format as specified in DM_ALERT_INPUT_T
+ * @param echoType whether to echo user input (hidden for password ) as specified in DM_ALERT_ECHO_T
+ * @param response hold user's response action and input data.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowTextInputAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ CPCHAR defaultResponse,
+ INT32 maxLength,
+ XPL_DM_ALERT_INPUT_T inputType,
+ XPL_DM_ALERT_ECHO_T echoType,
+ XPL_DM_ALERT_TEXTINPUT_RES_T * response );
+
+
+
+/**
+ * Display a single choice message box for user to pick up one entry.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param choices a string vector to hold text for each choice
+ * @param defaultResponse default user action when timeout
+ * @param response hold user's response action and selected choice.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowSingleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ INT32 defaultResponse,
+ XPL_DM_ALERT_SCHOICE_RES_T * response );
+
+
+
+/**
+ * Display a multiple choice message box for user to pick up zero to many entry.
+ *
+ * @param maxDisplayTime maximum display time (for timeout), in seconds.
+ * @param msg messages to display
+ * @param choices a string vector to hold text for each choice
+ * @param defaultResponse default user action when timeout
+ * @param defaultResponses holds default response in an array of string representation of
+ * selected indexes (starting from 1)
+ * @param response hold user's response action and selected choice.
+ * @return Upon successful completion, the SYNCML_DM_SUCCESS is returned, otherwise
+ * SYNCML_DM_FAIL or other more specific error codes.
+ **/
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowMultipleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ DMStringVector & defaultResponses,
+ XPL_DM_ALERT_MCHOICE_RES_T * response);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/engine/xpl/hdr/xpl_dm_ServerAlertDef.h b/engine/xpl/hdr/xpl_dm_ServerAlertDef.h
new file mode 100644
index 0000000..a246702
--- /dev/null
+++ b/engine/xpl/hdr/xpl_dm_ServerAlertDef.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * DESCRIPTION:
+ * The xpl_dm_ServerAlertDef.h header file contains defenition for server
+ * alerts/prompts
+ */
+
+#ifndef XPL_DMSERVERALERTDEF_H
+#define XPL_DMSERVERALERTDEF_H
+
+#include "xpl_Types.h"
+
+enum
+{
+ XPL_DM_ALERT_RES_NONE,
+ XPL_DM_ALERT_RES_NO,
+ XPL_DM_ALERT_RES_YES,
+ XPL_DM_ALERT_RES_CANCEL,
+ XPL_DM_ALERT_RES_TIMEOUT,
+};
+typedef UINT8 XPL_DM_ALERT_RES_T;
+
+enum
+{
+ XPL_DM_ALERT_I_ALPHA, // Alphanumeric
+ XPL_DM_ALERT_I_NUMERIC, // Numeric
+ XPL_DM_ALERT_I_DATE, // Date
+ XPL_DM_ALERT_I_TIME, // Time
+ XPL_DM_ALERT_I_PHONE_NUM, // Phone Number
+ XPL_DM_ALERT_I_IP_ADDR, // IP Address
+};
+typedef UINT8 XPL_DM_ALERT_INPUT_T;
+
+enum
+{
+ XPL_DM_ALERT_E_TEXT, // Text
+ XPL_DM_ALERT_E_PASSWD, // Password
+};
+typedef UINT8 XPL_DM_ALERT_ECHO_T;
+
+#endif
diff --git a/engine/xpl/src/dmAllocatedPointersPool.cc b/engine/xpl/src/dmAllocatedPointersPool.cc
new file mode 100644
index 0000000..b58888c
--- /dev/null
+++ b/engine/xpl/src/dmAllocatedPointersPool.cc
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dmMemory.h"
+#include "dmThreadHelper.h"
+#include <stdio.h>
+#include <sys/time.h>
+#include <signal.h>
+#include "dmAllocatedPointersPool.h"
+
+#ifdef DEBUG
+DMAllocatedPointersPool::~DMAllocatedPointersPool()
+{
+#ifdef DEBUG
+ //PrintUnreleased();
+#endif
+}
+
+void DMAllocatedPointersPool::PrintUnreleased()
+{
+ DMSingleLock oLock( m_csPointerPoolLock );
+
+ std::map<void*, int>::const_iterator vli = m_listOfAllocatedPointers.begin();
+ int nBlockNum = 1;
+
+ while (vli != m_listOfAllocatedPointers.end())
+ {
+ const char *ptr = (const char*)(const void*)vli->first;
+ CPCHAR* ppStr = (CPCHAR*)ptr;
+
+ ptr += 3*sizeof(const char*) + DMAllocatedPointersPool::c_nExtraBytes;
+
+ printf( "%d. block (%d bytes) with addr %p was not deallocated; file %s, line %d\n",
+ nBlockNum++, (int)ppStr[2], ptr, ppStr[0], (int)ppStr[1] );
+ vli++;
+ }
+ if ( nBlockNum > 1 )
+ printf( "\n" );
+
+ //m_listOfAllocatedPointers.clear();
+}
+#endif //DEBUG
diff --git a/engine/xpl/src/dmMemory.cc b/engine/xpl/src/dmMemory.cc
new file mode 100644
index 0000000..1b05c60
--- /dev/null
+++ b/engine/xpl/src/dmMemory.cc
@@ -0,0 +1,240 @@
+#include "dmAllocatedPointersPool.h"
+#include <malloc.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <stdio.h>
+#include "xpl_Logger.h"
+#include "dmMemory.h"
+
+/*
+void* DmtMemAllocEx( size_t nSize, CPCHAR szFile, INT32 nLine )
+{
+ return DmAllocMemEx( nSize, szFile, nLine );
+}
+
+void DmtMemFree( void* p )
+{
+ DmFreeMem( p );
+}
+*/
+
+#ifdef DEBUG
+DMAllocatedPointersPool *s_pAllocatedPool = new DMAllocatedPointersPool;
+
+// SU API functions - only used in SyncML DM code
+const int c_nMemPrefix = 3*sizeof(const char*) + DMAllocatedPointersPool::c_nExtraBytes;
+const int c_nMemPostfix = DMAllocatedPointersPool::c_nExtraBytes;
+#endif
+
+//#define MEASURE_MEMORY
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+int g_nMaxMem = 0;
+int g_nCurMem = 0;
+int g_nNumber = 0;
+
+void DmMemoryStatisticsWrite(const char* header)
+{
+}
+
+void DmMemoryStatisticsReportLeaks( void )
+{
+}
+
+#endif
+
+int DmGetMemFailedFlag( void )
+{
+ return 0;
+}
+void DmResetMemFailedFlag( void )
+{
+}
+
+#ifdef DEBUG
+
+int s_nBlocks = 0, s_nSize = 0;
+int s_nCnt = 0;
+
+
+
+void* DmAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine )
+{
+ s_nBlocks ++;
+ s_nSize += (bufsize + 3) / 4 * 4;
+
+ // emulate low memory case
+ static int s_nFirstBlocks = 4*1024 +1;
+
+ s_nCnt++;
+
+ if ( !s_nFirstBlocks ) {
+ if ( (s_nCnt % 1024) == 0)
+ ; //return NULL;
+ }
+ else
+ s_nFirstBlocks--;
+
+
+ if ( (s_nCnt % 102400) == 0 )
+ {
+ XPL_LOG_DM_TMN_Debug(("Total blocks %d, Blocks %d, size %d\n\n", s_nCnt, s_nBlocks, s_nSize ));
+ }
+
+
+ char* ptr = (char*)malloc(bufsize + c_nMemPrefix + c_nMemPostfix);
+ if (ptr == 0)
+ {
+ XPL_LOG_DM_TMN_Debug(("Malloc failed. Memory not available. %d asked by %s In %d. \n",
+ bufsize,szFile, nLine));
+ assert(0);
+ }
+ else
+ {
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+ g_nCurMem += (bufsize + 3) / 4 * 4;
+ g_nMaxMem = (g_nMaxMem > g_nCurMem ? g_nMaxMem : g_nCurMem);
+ g_nNumber++;
+#endif
+
+ s_pAllocatedPool->append(ptr);
+ memset(ptr,0xcd,bufsize + c_nMemPrefix + c_nMemPostfix);
+
+ CPCHAR* ppStr = (CPCHAR*)ptr;
+ ppStr[0] = strdup( szFile );
+ ppStr[1] = (CPCHAR)nLine;
+ ppStr[2] = (CPCHAR)(long)bufsize;
+
+ ptr += c_nMemPrefix;
+ memset(ptr,0,bufsize);
+ XPL_LOG_DM_TMN_Debug(("Allocating %d memory at %p in file %s In %d. \n",
+ bufsize, ptr, szFile, nLine));
+ }
+ return(ptr);
+}
+
+void DmFreeMemEx(void *ptr, CPCHAR szFile, int nLine)
+{
+ unsigned char* bufptr = (unsigned char*)ptr;
+ if(bufptr != 0 ){
+ bufptr -= c_nMemPrefix;
+
+ if ( s_pAllocatedPool->remove(bufptr)) {
+ // check over/under run of the buffer
+ bool bCorrupted = false;
+ CPCHAR* ppStr = (CPCHAR*)bufptr;
+ for ( int i = 1; i <= DMAllocatedPointersPool::c_nExtraBytes; i++ )
+ {
+ if ( bufptr[c_nMemPrefix-i] != 0xcd ||
+ bufptr[c_nMemPrefix + (int)ppStr[2] + i - 1] != 0xcd )
+ bCorrupted = true;
+ }
+
+ s_nBlocks --;
+ s_nSize -= ((int)ppStr[2] + 3) / 4 * 4;
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+ g_nCurMem -= ((int)ppStr[2] + 3) / 4 * 4;
+ g_nNumber--;
+#endif
+
+ if ( bCorrupted )
+ {
+ XPL_LOG_DM_TMN_Debug(("Block has been corrupted with writing before/after the allocated block; pointer %p; file %c ln. %d size %d \n",
+ (void*) (bufptr + c_nMemPrefix), ppStr[0], (int) ppStr[1], (int) ppStr[2]));
+ }
+ free( (void*)ppStr[0] );
+ memset(ptr, 0xcd, (int)ppStr[2] );
+ free(bufptr);
+ }
+ else
+ {
+ XPL_LOG_DM_TMN_Debug(("Invalid or duplicate freeing %p memory. infile %s ln. %d \n",
+ (void*) (bufptr + c_nMemPrefix), szFile, nLine));
+ }
+ }
+}
+
+void* DmReallocMem( void* ptr, int nSize )
+{
+ // debug version:
+
+ if ( nSize <= 0 ){
+ DmFreeMem( ptr );
+ return NULL;
+ }
+
+ if ( !ptr )
+ return DmAllocMem( nSize );
+
+ // check for buf size - if it registered...
+ unsigned char* bufptr = (unsigned char*)ptr;
+ if(bufptr != 0 )
+ bufptr -= c_nMemPrefix;
+
+ if ( !s_pAllocatedPool->exists(bufptr))
+ {
+ // invalid input parameter!!!
+ XPL_LOG_DM_TMN_Debug(("Realloc is called with invalid input parameter: block %p was not allocated or already was freed \n",
+ (void*) (bufptr + c_nMemPrefix)));
+ return DmAllocMem( nSize );
+ }
+
+ CPCHAR* ppStr = (CPCHAR*)bufptr;
+ int nBlockSize = (int)ppStr[2];
+
+ if ( nBlockSize >= nSize )
+ return ptr; // nothing to do - current block is large enough
+
+ void* pNewBlock = DmAllocMem( nSize );
+
+ if ( pNewBlock )
+ memcpy( pNewBlock, ptr,(nBlockSize < nSize ? nBlockSize : nSize) );
+
+ DmFreeMem(ptr);
+ return pNewBlock;
+}
+
+#else //!DEBUG
+
+void* DmReallocMem(void *ptr, int nSize)
+{
+ return realloc(ptr,nSize);
+}
+
+void * DmAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine )
+{
+ char* ptr = (char*)malloc(bufsize);
+ if (ptr != 0) {
+ memset(ptr,0,bufsize);
+ } else {
+ abort();
+ }
+ return ptr;
+}
+
+void DmFreeMemEx(void *ptr, CPCHAR szFile, int nLine)
+{
+ if (ptr) {
+ free( ptr );
+ }
+}
+
+#endif //DEBUG
+
+
+#ifdef DM_MEMORY_STATISTICS_ENABLED
+extern "C" void suPrintMemoryUsage()
+{
+ XPL_LOG_DM_TMN_Debug(("Memory usage summary: allocated %d block(s) with total %d bytes. Max usage was %d \n",
+ g_nNumber, g_nCurMem, g_nMaxMem));
+}
+#endif
+
+#ifdef DEBUG
+struct CMemoryStatusPrint
+{
+ ~CMemoryStatusPrint() {
+ s_pAllocatedPool->PrintUnreleased();
+ }
+}s_oMemoryStatus;
+#endif
+
diff --git a/engine/xpl/src/dmNewDataTypesValidation.cc b/engine/xpl/src/dmNewDataTypesValidation.cc
new file mode 100644
index 0000000..c12e53b
--- /dev/null
+++ b/engine/xpl/src/dmNewDataTypesValidation.cc
@@ -0,0 +1,751 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ctype.h>
+#include "dmStringUtil.h"
+#include "dmNewDataTypesValidation.h"
+#include "xpl_Logger.h"
+
+//----------------------------------------------------------------------------------------------
+
+typedef int position_t;
+typedef int offset_t;
+
+//----------------------------------------------------------------------------------------------
+
+class matcher_t
+{
+public:
+ matcher_t( const DMString& str );
+ matcher_t( const matcher_t& matcher );
+ BOOLEAN get_char( char& curr_char, offset_t offset ) const;
+ BOOLEAN advance( offset_t offset );
+ offset_t get_offset() const;
+ position_t get_size() const;
+
+private:
+ position_t _position;
+ position_t _initial_position;
+ const DMString& _str;
+};
+
+typedef offset_t (*check_format_fn_t)( matcher_t matcher );
+
+//----------------------------------------------------------------------------------------------
+
+matcher_t::matcher_t( const DMString& str )
+ : _position( 0 ),
+ _initial_position( 0 ),
+ _str( str )
+{
+}
+
+matcher_t::matcher_t( const matcher_t& matcher )
+ : _position( matcher._position ),
+ _initial_position( matcher._position ),
+ _str( matcher._str )
+{
+}
+
+BOOLEAN
+matcher_t::advance( offset_t offset )
+{
+ BOOLEAN result = FALSE;
+
+ if( ( offset > 0 ) &&
+ ( _position + offset <= get_size() ) )
+ {
+ _position += offset;
+ result = TRUE;
+ }
+
+ return result;
+}
+
+BOOLEAN
+matcher_t::get_char( char& curr_char, offset_t offset ) const
+{
+ BOOLEAN result = FALSE;
+
+ if( _position + offset < get_size() )
+ {
+ curr_char = _str[ _position + offset ];
+ result = TRUE;
+ }
+
+ return result;
+}
+
+offset_t
+matcher_t::get_offset() const
+{
+ return _position - _initial_position;
+}
+
+position_t
+matcher_t::get_size() const
+{
+ return static_cast<position_t>( _str.length() );
+}
+
+//----------------------------------------------------------------------------------------------
+
+static
+offset_t
+is_literal( matcher_t matcher, char literal )
+{
+ char curr_char = '\0';
+ return ( matcher.get_char( curr_char, 0 ) && ( curr_char == literal ) ) ? 1 : 0;
+}
+
+static
+offset_t
+is_sign( matcher_t matcher )
+{
+ offset_t offset = is_literal( matcher, '-' );
+
+ if( !offset )
+ {
+ offset = is_literal( matcher, '+' );
+ }
+
+ return offset;
+}
+
+static
+offset_t
+is_digit( matcher_t matcher )
+{
+ char curr_char = '\0';
+ return ( matcher.get_char( curr_char, 0 ) && isdigit( curr_char ) ) ? 1 : 0;
+}
+
+static
+offset_t
+is_number( matcher_t matcher, int min_length, int max_length )
+{
+ for( int i = 0; i < min_length; ++i )
+ {
+ if( !matcher.advance( is_digit( matcher ) ) )
+ {
+ return 0;
+ }
+ }
+
+ for( int i = min_length; i < max_length; ++i )
+ {
+ if( !matcher.advance( is_digit( matcher ) ) )
+ {
+ return matcher.get_offset();
+ }
+ }
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_integer_part( matcher_t matcher )
+{
+ return is_number( matcher, 1, 10 );
+}
+
+static
+offset_t
+is_fractional_part( matcher_t matcher )
+{
+ if( !matcher.advance( is_literal( matcher, '.' ) ) ) return 0;
+ if( !matcher.advance( is_number( matcher, 1, 10 ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_Ee( matcher_t matcher )
+{
+ offset_t offset = is_literal( matcher, 'E' );
+
+ if( !offset )
+ {
+ offset = is_literal( matcher, 'e' );
+ }
+
+ return offset;
+}
+
+static
+offset_t
+is_exponent( matcher_t matcher )
+{
+ if( !matcher.advance( is_Ee( matcher ) ) ) return 0;
+
+ matcher.advance( is_sign( matcher ) );
+ if( !matcher.advance( is_number( matcher, 1, 10 ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_mantissa( matcher_t matcher )
+{
+ matcher.advance( is_sign( matcher ) );
+
+ if( !matcher.advance( is_integer_part( matcher ) ) ) return 0;
+
+ matcher.advance( is_fractional_part( matcher ) );
+
+ return matcher.get_offset();
+}
+
+BOOLEAN
+is_float( const DMString& str )
+{
+ XPL_LOG_DM_TMN_Debug(("dmNewDataTypesValidation::is_float str=%s\n", str.c_str()));
+ matcher_t matcher( str );
+
+ if( matcher.get_size() == 0 ) return FALSE;
+ if( !matcher.advance( is_mantissa( matcher ) ) ) return FALSE;
+ matcher.advance( is_exponent( matcher ) );
+
+ return matcher.get_offset() == str.length();
+}
+
+static
+offset_t
+is_year( matcher_t matcher )
+{
+ return is_number( matcher, 4, 4 );
+}
+
+static
+offset_t
+is_number_in_range( matcher_t matcher, int num_digits, int min_value, int max_value )
+{
+ offset_t offset = is_number( matcher, num_digits, num_digits );
+
+ if( offset == 0 ) return 0;
+
+ int value = 0;
+
+ for( int i = 0; i < num_digits; ++i )
+ {
+ char curr_char = '\0';
+
+ if( !matcher.get_char( curr_char, i ) ) return 0;
+
+ value = 10 * value + ( curr_char - '0' );
+ }
+
+ return ( min_value <= value ) && ( value <= max_value ) ? offset : 0;
+}
+
+static
+offset_t
+is_month( matcher_t matcher )
+{
+ return is_number_in_range( matcher, 2, 1, 12 );
+}
+
+static
+offset_t
+is_day_of_month( matcher_t matcher )
+{
+ return is_number_in_range( matcher, 2, 1, 31 );
+}
+
+static
+offset_t
+is_day_of_year( matcher_t matcher )
+{
+ return is_number_in_range( matcher, 3, 1, 366 );
+}
+
+static
+offset_t
+is_day_of_week( matcher_t matcher )
+{
+ return is_number_in_range( matcher, 1, 1, 7 );
+}
+
+static
+offset_t
+is_week_number( matcher_t matcher )
+{
+ return is_number_in_range( matcher, 2, 1, 52 );
+}
+
+static
+offset_t
+is_YYYY( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYY_MM_DD( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, '-' ) ) ) return 0;
+ if( !matcher.advance( is_month( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, '-' ) ) ) return 0;
+ if( !matcher.advance( is_day_of_month( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYY_MM( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, '-' ) ) ) return 0;
+ if( !matcher.advance( is_month( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYY_DDD( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, '-' ) ) ) return 0;
+ if( !matcher.advance( is_day_of_year( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYY_Wxx( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, '-' ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, 'W' ) ) ) return 0;
+ if( !matcher.advance( is_week_number( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYY_Wxx_d( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, '-' ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, 'W' ) ) ) return 0;
+ if( !matcher.advance( is_week_number( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, '-' ) ) ) return 0;
+ if( !matcher.advance( is_day_of_week( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYYMMDD( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_month( matcher ) ) ) return 0;
+ if( !matcher.advance( is_day_of_month( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYYMM( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_month( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYYDDD( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_day_of_year( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYYWxx( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, 'W' ) ) ) return 0;
+ if( !matcher.advance( is_week_number( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_YYYYWxxd( matcher_t matcher )
+{
+ if( !matcher.advance( is_year( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, 'W' ) ) ) return 0;
+ if( !matcher.advance( is_week_number( matcher ) ) ) return 0;
+ if( !matcher.advance( is_day_of_week( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+BOOLEAN
+is_format( matcher_t matcher, check_format_fn_t fn )
+{
+ return (*fn)( matcher ) == matcher.get_size();
+}
+
+BOOLEAN
+is_date( const DMString& str )
+{
+ matcher_t matcher( str );
+ BOOLEAN result = TRUE;
+
+ if( matcher.get_size() == 0 ) return FALSE;
+
+ for( ; ; )
+ {
+ if( is_format( matcher, is_YYYY ) ) break;
+ if( is_format( matcher, is_YYYY_MM_DD ) ) break;
+ if( is_format( matcher, is_YYYY_MM ) ) break;
+ if( is_format( matcher, is_YYYY_DDD ) ) break;
+ if( is_format( matcher, is_YYYY_Wxx ) ) break;
+ if( is_format( matcher, is_YYYY_Wxx_d ) ) break;
+ if( is_format( matcher, is_YYYYMMDD ) ) break;
+ if( is_format( matcher, is_YYYYMM ) ) break;
+ if( is_format( matcher, is_YYYYDDD ) ) break;
+ if( is_format( matcher, is_YYYYWxx ) ) break;
+ if( is_format( matcher, is_YYYYWxxd ) ) break;
+
+ result = FALSE;
+ break;
+ }
+
+ return result;
+}
+
+static
+offset_t
+is_hours( matcher_t matcher )
+{
+ return is_number_in_range( matcher, 2, 0, 23 );
+}
+
+static
+offset_t
+is_minutes( matcher_t matcher )
+{
+ return is_number_in_range( matcher, 2, 0, 59 );
+}
+
+static
+offset_t
+is_seconds( matcher_t matcher )
+{
+ return is_number_in_range( matcher, 2, 0, 59 );
+}
+
+static
+offset_t
+is_hh_mm_ss( matcher_t matcher )
+{
+ if( !matcher.advance( is_hours( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, ':' ) ) ) return 0;
+ if( !matcher.advance( is_minutes( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, ':' ) ) ) return 0;
+ if( !matcher.advance( is_seconds( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_hh_mm( matcher_t matcher )
+{
+ if( !matcher.advance( is_hours( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, ':' ) ) ) return 0;
+ if( !matcher.advance( is_minutes( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_hhmmss( matcher_t matcher )
+{
+ if( !matcher.advance( is_hours( matcher ) ) ) return 0;
+ if( !matcher.advance( is_minutes( matcher ) ) ) return 0;
+ if( !matcher.advance( is_seconds( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_hhmm( matcher_t matcher )
+{
+ if( !matcher.advance( is_hours( matcher ) ) ) return 0;
+ if( !matcher.advance( is_minutes( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_hh( matcher_t matcher )
+{
+ if( !matcher.advance( is_hours( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_hh_mm_ssZ( matcher_t matcher )
+{
+ if( !matcher.advance( is_hours( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, ':' ) ) ) return 0;
+ if( !matcher.advance( is_minutes( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, ':' ) ) ) return 0;
+ if( !matcher.advance( is_seconds( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, 'Z' ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+static
+offset_t
+is_hh_mm_ss_utc_hh_mm( matcher_t matcher )
+{
+ if( !matcher.advance( is_hours( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, ':' ) ) ) return 0;
+ if( !matcher.advance( is_minutes( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, ':' ) ) ) return 0;
+ if( !matcher.advance( is_seconds( matcher ) ) ) return 0;
+ if( !matcher.advance( is_sign( matcher ) ) ) return 0;
+ if( !matcher.advance( is_hours( matcher ) ) ) return 0;
+ if( !matcher.advance( is_literal( matcher, ':' ) ) ) return 0;
+ if( !matcher.advance( is_minutes( matcher ) ) ) return 0;
+
+ return matcher.get_offset();
+}
+
+BOOLEAN
+is_time( const DMString& str )
+{
+ matcher_t matcher( str );
+ BOOLEAN result = TRUE;
+
+ if( matcher.get_size() == 0 ) return FALSE;
+
+ for( ; ; )
+ {
+ if( is_format( matcher, is_hh_mm_ss ) ) break;
+ if( is_format( matcher, is_hh_mm ) ) break;
+ if( is_format( matcher, is_hhmmss ) ) break;
+ if( is_format( matcher, is_hhmm ) ) break;
+ if( is_format( matcher, is_hh ) ) break;
+ if( is_format( matcher, is_hh_mm_ssZ ) ) break;
+ if( is_format( matcher, is_hh_mm_ss_utc_hh_mm ) ) break;
+
+ result = FALSE;
+ break;
+ }
+
+ return result;
+}
+
+/* DM: Unit tests for is_time, is_data, is_float
+
+
+struct test_t
+{
+ test_t( const char* pattern, BOOLEAN expeted_result )
+ : _pattern( pattern ),
+ _expected_result( expeted_result )
+ {
+ }
+
+ const char* _pattern;
+ BOOLEAN _expected_result;
+};
+
+void test_float()
+{
+ test_t tests[] =
+ {
+ test_t( "1", TRUE ),
+ test_t( "123", TRUE ),
+ test_t( "+523", TRUE ),
+ test_t( "-66544", TRUE ),
+ test_t( "6.0", TRUE ),
+ test_t( "-64.55", TRUE ),
+ test_t( "+66.544", TRUE ),
+ test_t( "1e12", TRUE ),
+ test_t( "123e12", TRUE ),
+ test_t( "+523e-12", TRUE ),
+ test_t( "-66544e1", TRUE ),
+ test_t( "6.0E+01", TRUE ),
+ test_t( "-64.55E12", TRUE ),
+ test_t( "+66.544e-44", TRUE ),
+
+ test_t( "", FALSE ),
+ test_t( "+66.544e-", FALSE ),
+ test_t( "-66.544e", FALSE ),
+ test_t( "+66.", FALSE ),
+ test_t( "+x6.5", FALSE ),
+ test_t( "++6.0E+01", FALSE ),
+ test_t( "--6.0E+01", FALSE ),
+ test_t( "--6.0E+-01", FALSE ),
+ test_t( "633.45.40E+01", FALSE ),
+ test_t( "633.40E+2.1", FALSE ),
+ };
+
+ for( int i = 0; i < sizeof( tests ) / sizeof( tests[ 0 ] ); ++i )
+ {
+ std::cout << ( ( is_float( tests[ i ]._pattern ) == tests[ i ]._expected_result )
+ ? "OK "
+ : "Failed" );
+ std::cout << " - float( " << tests[ i ]._pattern << " )";
+ std::cout << std::endl;
+ }
+}
+
+void test_date()
+{
+ test_t tests[] =
+ {
+ test_t( "2005-11-23", TRUE ),
+ test_t( "1243-04", TRUE ),
+ test_t( "1990-123", TRUE ),
+ test_t( "1322-W12-3", TRUE ),
+ test_t( "1600-W05", TRUE ),
+ test_t( "19121103", TRUE ),
+ test_t( "200001", TRUE ),
+ test_t( "2001222", TRUE ),
+ test_t( "000001", TRUE ),
+ test_t( "0000001", TRUE ),
+ test_t( "1555", TRUE ),
+ test_t( "2210W116", TRUE ),
+ test_t( "1203W12", TRUE ),
+
+ test_t( "20Z5-11-23", FALSE ),
+ test_t( "205-11-23", FALSE ),
+ test_t( "2025-11-2", FALSE ),
+ test_t( "2025-11-", FALSE ),
+ test_t( "2025-1-12", FALSE ),
+ test_t( "2025--12", FALSE ),
+ test_t( "2025-00-12", FALSE ),
+ test_t( "2025-44-12", FALSE ),
+ test_t( "2025-11-00", FALSE ),
+ test_t( "2025-11-65", FALSE ),
+ test_t( "1990-0", FALSE ),
+ test_t( "1990-000", FALSE ),
+ test_t( "1990-367", FALSE ),
+ test_t( "990-367", FALSE ),
+ test_t( "123-04", FALSE ),
+ test_t( "1322-W12-0", FALSE ),
+ test_t( "1322-W12-8", FALSE ),
+ test_t( "1322-W00-3", FALSE ),
+ test_t( "1322-W0-3", FALSE ),
+ test_t( "1322-W-3", FALSE ),
+ test_t( "1322-W66-3", FALSE ),
+ test_t( "155", FALSE ),
+ test_t( "1", FALSE ),
+ test_t( "", FALSE ),
+ test_t( "15522", FALSE ),
+ test_t( "1552q", FALSE ),
+ test_t( "1552-", FALSE ),
+ test_t( "1552-W", FALSE ),
+ test_t( "1552W", FALSE ),
+ test_t( "2210W1163", FALSE ),
+ test_t( "1203w12", FALSE ),
+ };
+
+ for( int i = 0; i < sizeof( tests ) / sizeof( tests[ 0 ] ); ++i )
+ {
+ std::cout << ( ( is_date( tests[ i ]._pattern ) == tests[ i ]._expected_result )
+ ? "OK "
+ : "Failed" );
+ std::cout << " - date( " << tests[ i ]._pattern << " )";
+ std::cout << std::endl;
+ }
+}
+
+void test_time()
+{
+ test_t tests[] =
+ {
+ test_t( "12:11:23", TRUE ),
+ test_t( "12:11", TRUE ),
+ test_t( "121123", TRUE ),
+ test_t( "1211", TRUE ),
+ test_t( "12", TRUE ),
+ test_t( "12:11:23Z", TRUE ),
+ test_t( "12:11:23+08:00", TRUE ),
+ test_t( "12:11:23-11:30", TRUE ),
+
+ test_t( "", FALSE ),
+ test_t( "1", FALSE ),
+ test_t( "Z", FALSE ),
+ test_t( "+1", FALSE ),
+ test_t( "25:11:23", FALSE ),
+ test_t( "15:81:23", FALSE ),
+ test_t( "15:11:73", FALSE ),
+ test_t( "::", FALSE ),
+ test_t( "1:2:3", FALSE ),
+ test_t( "12112", FALSE ),
+ test_t( "121", FALSE ),
+ test_t( "12:11:23+33:00", FALSE ),
+ test_t( "12:11:23-08:99", FALSE ),
+ test_t( "12:11:23 08:12", FALSE ),
+ test_t( "12:11:23 08:12", FALSE ),
+ test_t( "12:11:23-08:", FALSE ),
+ test_t( "12:11:23-08:1", FALSE ),
+ test_t( "12:11:23:08:11", FALSE ),
+ };
+
+ for( int i = 0; i < sizeof( tests ) / sizeof( tests[ 0 ] ); ++i )
+ {
+ std::cout << ( ( is_time( tests[ i ]._pattern ) == tests[ i ]._expected_result )
+ ? "OK "
+ : "Failed" );
+ std::cout << " - time( " << tests[ i ]._pattern << " )";
+ std::cout << std::endl;
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ test_float();
+ test_date();
+ test_time();
+
+ return 0;
+}
+*/
diff --git a/engine/xpl/src/dmSocketConnector.cc b/engine/xpl/src/dmSocketConnector.cc
new file mode 100644
index 0000000..08e90f4
--- /dev/null
+++ b/engine/xpl/src/dmSocketConnector.cc
@@ -0,0 +1,577 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//--------------------------------------------------------------------------------------------------
+//
+// Module Name: dmSocketConnector.cpp
+//
+// General Description: DmBrwConnector socket implementation class implementation file. This allows
+// DM to send and receive SYNCML data through HTTP protocol. This implementation is platform independent.
+// It can be used in any UNIX or LINUX machine. It can allow use under Windows provided that Windows
+// has the unix socket libraries. This implementation also supports go through proxy server.
+//
+// Proxy Usage:
+//
+// setenv DM_PROXY_URL=123.567.28.167:1080 // please use IP address
+// setenv DM_PROXY_AUTH="Basic ZTExNjdadsfagewwer"
+//
+// Note: The sequences of letters after Basic is the B64 encoding of your
+// userID:userPW.
+//
+// Hint: Here is a web site to do B64 encoding:
+// http://www.ericphelps.com/scripting/samples/Decode.htm
+
+#include <stdlib.h> // Needed for exit()
+#include <string.h> // Needed for strcpy() and strlen()
+#include <sys/types.h> // Needed for system defined identifiers.
+#include <netinet/in.h> // Needed for internet address structure.
+#include <sys/socket.h> // Needed for socket(), bind(), etc...
+#include <arpa/inet.h> // Needed for inet_ntoa()
+#include <unistd.h> // Needed for close()
+#include <stdio.h>
+
+#include "dmSocketConnector.h"
+
+#define BUF_SIZE 50000 // Buffer size
+
+static int g_nPrintfEnabled = getenv("DM_NOPRINTF") == NULL;
+
+/*
+ * Creates a socket connector.
+ *
+ * @return a socket connector.
+ */
+DmSocketConnector * DmBrwCreateConnector() {
+ if ( g_nPrintfEnabled ) printf("\nCreate Socket Connector\n");
+ DmSocketConnector * socketHandler = NULL;
+ socketHandler = new DmSocketConnector();
+ return socketHandler;
+}
+
+/*
+ * Destroy a socket connector.
+ *
+ * @param the handler to a socket connector.
+ * @return success if no error, otherwise return fail
+ */
+SYNCML_DM_RET_STATUS_T DmBrwDestroyConnector(DmSocketConnector * browser_handler) {
+ if ( g_nPrintfEnabled ) printf("Destroy Socket Connector\n");
+ if (browser_handler != NULL) {
+ delete browser_handler;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Prepair a socket connection by parsing the URL to get information such
+ * as host, port, and path.
+ *
+ * @param url the URL to be parse
+ * @param ConRef the connection reference
+ * @param AddrType the type of a host address
+ * @return success if get all connection information, otherwise return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::Open(CPCHAR url, CPCHAR ConRef, int AddrType) {
+ if ( g_nPrintfEnabled ) printf("Open URL: %s\n", url);
+ DMString strURI = url;
+ DMString strAddrPort;
+ DMString strURIPath;
+
+ if (parseURL(strURI, strAddrPort, strURIPath)) {
+ if (parseAddrPort(strAddrPort, ipAddress, portNum)) {
+ proxy_url = getenv("DM_PROXY_URL");
+ if (proxy_url != NULL) {
+ urlPath = url;
+ DMString tmpURL = proxy_url;
+ if (!parseAddrPort(tmpURL, socket_ipAddress, socket_portNum)) {
+ return SYNCML_DM_FAIL;
+ }
+ } else {
+ urlPath += "/";
+ urlPath += strURIPath;
+ socket_ipAddress = ipAddress;
+ socket_portNum = portNum;
+ }
+ return SYNCML_DM_SUCCESS;
+ }
+ }
+ return SYNCML_DM_FAIL;
+}
+
+/*
+ * Dynamically change a socket connection by parsing a new URL to get information such
+ * as host, port, and path.
+ *
+ * @param url the URL to be parse
+ * @param ConRef the connection reference
+ * @param AddrType the type of a host address
+ * @return success if get all connection information, otherwise return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::SetUrl(CPCHAR url, CPCHAR ConRef, int AddrType) {
+ if ( g_nPrintfEnabled ) printf("Set URL: %s\n", url);
+ DMString strURI = url;
+ DMString strAddrPort;
+ DMString strURIPath;
+
+ if (parseURL(strURI, strAddrPort, strURIPath)) {
+ if (proxy_url != NULL) {
+ urlPath = url;
+ } else {
+ urlPath = "/";
+ urlPath += strURIPath;
+ }
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Sets the HTTP request method such as GET and POST.
+ *
+ * @param method the method to be set
+ * @return success if the method is supported, else return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::SetRequestMethod(XPL_HTTP_METHOD_T method) {
+ requestMethod = method;
+ if ( method == XPL_HTTP_METHOD_POST ) {
+ if ( g_nPrintfEnabled ) printf("Request Method: POST CODE: %d\n\n", method);
+ sentBuf = "POST ";
+ sentBuf += urlPath;
+ sentBuf += " HTTP/1.0\r\n";
+ sentBuf += "Host: ";
+ sentBuf += socket_ipAddress;
+ sentBuf += "\r\n";
+ } else if ( method == XPL_HTTP_METHOD_GET ) {
+ if ( g_nPrintfEnabled ) printf("Request Method: GET CODE: %d\n", method);
+ sentBuf = "GET ";
+ sentBuf += urlPath;
+ sentBuf += " HTTP/1.1\r\n";
+ } else {
+ if ( g_nPrintfEnabled ) printf("Error: Request method not supported\n");
+ return SYNCML_DM_FAIL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Sets HTTP request property by appending to the sent buffer.
+ * If DM_PROXY_AUTH enviornment variable was set, it will add
+ * a proxy authorization properties in every new session.
+ *
+ * @param header_start the name of a property
+ * @param value_start_prt the value of the property
+ * @return success after append to the sent buffer.
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::SetRequestProperty(CPCHAR props) {
+ if ( g_nPrintfEnabled ) printf("Property header: %s\n", props);
+ sentBuf += props;
+
+ if (proxy_auth == NULL && proxy_enable_check) {
+ proxy_auth = getenv("DM_PROXY_AUTH"); // proxy_auth=Basic userid:passwd
+ proxy_enable_check = false;
+ }
+
+ if (proxy_auth != NULL && new_session) {
+ if ( g_nPrintfEnabled ) printf ("Property header: Proxy-Authorization=%s\n", proxy_auth);
+ sentBuf += "Proxy-Authorization";
+ sentBuf += ": ";
+ sentBuf += proxy_auth;
+ sentBuf += "\r\n";
+ new_session = false;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Send the data through socket and get the response back.
+ *
+ * @data the data to be sent
+ * @size the size of the data to be sent
+ * @return success if no error when sending and getting response, else return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::Send(CPCHAR data, UINT32 size) {
+ if (doSend(data, size) == SYNCML_DM_SUCCESS) {
+ return getResponse();
+ }
+ return SYNCML_DM_FAIL;
+}
+
+/*
+ * Return the length of the response data.
+ *
+ * @return the response data length
+ */
+UINT32 DmSocketConnector::GetResponseLength() {
+ if ( g_nPrintfEnabled ) printf("Get response data length: %d\n", responseLength);
+ return responseLength;
+}
+
+/*
+ * Get the response data.
+ *
+ * @param data the data to be fill with response data
+ * @param size the size of the data
+ * @return success if the data is filled, else return fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::GetResponse(char * data, UINT32 size) {
+ char tmpBuf[50000];
+ memcpy(data, responseData, responseLength);
+ if ( requestMethod == XPL_HTTP_METHOD_POST && size < 50000 ) {
+ memcpy(tmpBuf, responseData, responseLength);
+ tmpBuf[responseLength]=0;
+ if ( g_nPrintfEnabled ) printf("\nResponse Body: %s\n", tmpBuf);
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Get the value of a HTTP header feild based on header field name.
+ *
+ * @param field the header field name
+ * @param value the value of the header field
+ * @return success if found the header field, else fail
+ *
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::GetHeaderField(CPCHAR field, char ** value) {
+ bool found = false;
+
+ for (int i = responseHeaders.begin(); i < responseHeaders.end(); i++) {
+ if (responseHeaders.get_key(i) == field) {
+ found = true;
+ break;
+ }
+ }
+
+ if (found == true) {
+ const DMString& s = responseHeaders.get(field).c_str();
+ *value = (char*)DmtMemAlloc( s.length() + 1 );
+ strcpy( *value, s );
+
+ if ( g_nPrintfEnabled ) printf("\nGet HeaderField %s : %s\n", field, *value);
+ } else {
+ if ( g_nPrintfEnabled ) printf("INFO: Can not find %s\n", field);
+ return SYNCML_DM_FAIL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Return HTTP response code such as 200, 404, and etc.
+ *
+ * @return the HTTP response code
+ */
+XPL_HTTP_CODE_T DmSocketConnector::GetResponseCode() {
+ if ( g_nPrintfEnabled ) printf("\nGet Response Code: %s \n\n", responseCode.c_str());
+ return atoi(responseCode.c_str());
+}
+
+/*
+ * Close the socket connection.
+ *
+ * @return success if socket closed, else fail.
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::Close() {
+ if ( g_nPrintfEnabled ) printf("Close Socket Connector\n");
+ int ret = close(server_s);
+ if (ret != 0) {
+ if ( g_nPrintfEnabled ) printf("ERROR: Can not close the socket.\n");
+ return SYNCML_DM_FAIL;
+ }
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Close current session, but leave the connection open.
+ *
+ * @return success after closed the session
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::CloseReq() {
+ if ( g_nPrintfEnabled ) printf("Close Socket Session\n");
+ new_session = true;
+ return SYNCML_DM_SUCCESS;
+}
+
+/*
+ * Giving string and delimiter, the function will store the section of the string until the delimiter
+ * in a string item. This is similar to string tokenizer.
+ *
+ * Ex: abc:123:xyz abc,123,and xyz are tokens seperated by a delimiter ':'
+ *
+ * @param strItem the first section of the string until the delimiter
+ * @param strReminder the rest of the string without the delimiter
+ * @param cDelim the delimiter
+ *
+ */
+bool DmSocketConnector::DmStringParserGetItem( DMString& strItem, DMString& strReminder, char cDelim ) {
+ if ( strReminder[0] == 0 ) {
+ return false;
+ }
+ const char* s = strchr( strReminder, cDelim );
+ int nPos = s ? s - strReminder : -1;
+ if ( nPos < 0 ) {
+ strItem = strReminder;
+ strReminder = "";
+ } else {
+ strItem.assign( strReminder, nPos );
+ strReminder = DMString(s+1);
+ }
+ return true;
+}
+
+/*
+ * Parse a HTTP response header.
+ *
+ * @param strBuffer the received data buffer from server that may contain the entire HTTP header
+ * @param dataBufSize number of bytes contained in strBuffer
+ * @param strBufRemaining the updated buffer containging HTTP body (i.e. strBuffer - HTTP header)
+ * @param lenRemaining number of bytes in strBufRemaining
+ * @return true if HTTP header marker "\r\n\r\n" is found in strBuffer, false otherwise
+ *
+ */
+bool DmSocketConnector::DmParseHTTPHeader( char* strBuffer, int dataBufSize, char** strBufRemaining, int& lenRemaining) {
+ // Let's get the response code first
+ // If we do not see end of HTTP header, do not bother to parse
+ char* entireHeaderEnd = strstr( strBuffer, "\r\n\r\n" );
+ if ( !entireHeaderEnd )
+ return false;
+
+ // Let's get the response code by looking for first space in response
+ char* pFirstSpace = strstr( strBuffer, " ");
+ pFirstSpace++;
+ char tmpBuf[10];
+ strncpy(tmpBuf, pFirstSpace, 3);
+ tmpBuf[3]=0;
+ responseCode = tmpBuf;
+ char* curPos = strBuffer;
+ // skip one \r\n
+ char *headerEnd = strstr(curPos, "\r\n");
+ curPos = headerEnd + strlen("\r\n");
+ headerEnd = strstr(curPos, "\r\n");
+
+ // Found an HTTP Header, let's get the name and value pair
+ while ( headerEnd != NULL ) {
+ char* pColon = strchr(curPos, ':');
+ char name[256];
+ char value[256];
+ strncpy(name, curPos, pColon-curPos);
+ name[pColon-curPos]=0;
+ strncpy(value, pColon+2, headerEnd-pColon-2);
+ value[headerEnd-pColon-2]=0;
+ responseHeaders.put(name, value);
+ if ( headerEnd == entireHeaderEnd )
+ break;
+ curPos = headerEnd + strlen("\r\n");
+ headerEnd = strstr(curPos, "\r\n");
+ }
+ *strBufRemaining = entireHeaderEnd + strlen("\r\n\r\n");
+ lenRemaining = dataBufSize - (*strBufRemaining - strBuffer);
+ return true;
+}
+
+/*
+ * Parse a HTTP response header.
+ *
+ * @param newData pointer to the buffer containing data from server
+ * @param len the size of the data in the buffer
+ * @return true if data is set successfully, false if memory can not be allocated
+ */
+bool DmSocketConnector::SetResponseData(unsigned char* newData, int len) {
+ if (len == 0) {
+ return true;
+ }
+
+ if ( responseData == NULL ) {
+ responseData = (unsigned char*)malloc(len);
+ memcpy( responseData, newData, len);
+ } else {
+ unsigned char* newPtr = (unsigned char*)malloc(len + responseLength);
+ memcpy((void*)newPtr, (void*)responseData, responseLength);
+ memcpy((void*)(newPtr+responseLength), (void*)newData, len);
+ free(responseData);
+ responseData = newPtr;
+ }
+ return true;
+}
+
+/*
+ * Parse the URL into address:port and URL path.
+ *
+ * @param strURI the URI to be parse
+ * @param strAddrPort the string to store the address:port
+ * @param strURIPath the string to store the path of the URI
+ *
+ * @return true if URI was in right format, else false
+ */
+bool DmSocketConnector::parseURL(DMString strURI, DMString& strAddrPort, DMString& strURIPath) {
+ int counter = 0;
+ DMString tmpStr;
+
+ while(DmStringParserGetItem(tmpStr, strURI, '/')) {
+ if (counter == 0) {
+ if (strcmp(tmpStr.c_str(), "http:") != 0) {
+ return false;
+ }
+ } else if (counter == 1) {
+ if (tmpStr.c_str()[0]!=0/*strcmp(tmpStr.c_str(), "") !=0*/) {
+ return false;
+ }
+ } else if (counter == 2) {
+ strAddrPort = tmpStr;
+ strURIPath = strURI;
+ return true;
+ }
+ counter++;
+ }
+ return false;
+}
+
+/*
+ * Parse the address:port into address and port.
+ *
+ * @param strAddrPort the string that holds address:port
+ * @param strAddr the string that store address
+ * @param strPort the string that store port
+ *
+ * @return true after parsing
+ */
+bool DmSocketConnector::parseAddrPort(DMString strAddrPort, DMString& strAddr, DMString& strPort) {
+ int j = 0;
+ DMString tmpStr;
+ while(DmStringParserGetItem(tmpStr, strAddrPort, ':')) {
+ if (j == 0) {
+ strAddr = tmpStr;
+ } else if (j == 1) {
+ strPort = tmpStr;
+ }
+ j++;
+ }
+ return true;
+}
+
+/*
+ * Prepair HTTP sent with sent data and sent it out through socket.
+ *
+ * @param data the body of the request
+ * @param size the size of the request body
+ *
+ * @return success if it sent all data through socket, else fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::doSend(CPCHAR data, UINT32 size) {
+ unsigned int retcode; // Return code
+
+ if ( g_nPrintfEnabled ) printf("\n[Header: %d bytes]\n%s\n", strlen(sentBuf.c_str()), sentBuf.c_str());
+ if ( g_nPrintfEnabled ) printf("[Data: %d bytes]\n%s\n\n", strlen(data), data);
+
+ if (size != 0) {
+ sentBuf += "Content-length: ";
+
+ char size_str[10];
+ sprintf(size_str, "%d", size);
+
+ sentBuf += size_str;
+ sentBuf += "\r\n\r\n";
+ } else {
+ sentBuf += "Host: ";
+ sentBuf += socket_ipAddress;
+ sentBuf += "\r\n\r\n";
+ }
+
+ server_s = socket(AF_INET, SOCK_STREAM, 0);
+ server_addr.sin_family = AF_INET; // Address family to use
+
+ // Port num to use
+ server_addr.sin_port = htons(atoi(socket_portNum.c_str()));
+ // IP address to use
+ server_addr.sin_addr.s_addr = inet_addr(socket_ipAddress);
+
+ if ( g_nPrintfEnabled ) printf("Host: %s Port: %s\n", socket_ipAddress.c_str(), socket_portNum.c_str());
+
+ // Do a connect (connect() blocks)
+ retcode = connect(server_s, (struct sockaddr *)&server_addr,
+ sizeof(server_addr));
+
+ if (retcode != 0) {
+ if ( g_nPrintfEnabled ) printf("ERROR: connect() failed \n");
+ return SYNCML_DM_FAIL;
+ }
+
+ //memset(out_buf, 0, BUF_SIZE);
+ //strcpy(out_buf, sentBuf.c_str());
+
+ if ( g_nPrintfEnabled ) printf("Send Size: %d\n", size);
+ if ( g_nPrintfEnabled ) printf("\nSend\n>>> >>> >>>\n%s%s<<< <<< <<<\n", sentBuf.c_str(), data);
+
+ // Send a request to the server
+ int ret = send(server_s, sentBuf.c_str(), strlen(sentBuf.c_str()), 0);
+ ret = send(server_s, data, size, 0);
+
+ if ( g_nPrintfEnabled ) printf("Send Size: %d\n", ret);
+
+ if (ret != -1) {
+ return SYNCML_DM_SUCCESS;
+ }
+ return SYNCML_DM_FAIL;
+}
+
+/*
+ * Get HTTP response by parsing the header information and body.
+ *
+ * @return success if the response size is greater than zero, else fail
+ */
+SYNCML_DM_RET_STATUS_T DmSocketConnector::getResponse() {
+ if ( g_nPrintfEnabled ) printf("\nGet Response\n");
+ char in_buf[BUF_SIZE]; // Input buffer for response
+ bool handleHeader = true;
+ int retcode;
+ int nBufUsed = 0;
+ responseBody = "";
+ responseLength = 0;
+
+ if ( responseData != NULL ) {
+ free(responseData);
+ responseData = NULL;
+ }
+
+ retcode = recv(server_s, in_buf, BUF_SIZE, 0);
+ if ( g_nPrintfEnabled ) printf("Size: %d\n", retcode);
+
+ while ((retcode > 0) && (retcode != -1)) {
+ int lenRemaining;
+ bool bEndHeader;
+ char* strRemaining;
+
+ if ( handleHeader ) {
+ bEndHeader = DmParseHTTPHeader( in_buf, retcode, &strRemaining, lenRemaining);
+ if ( bEndHeader ) {
+ handleHeader = false;
+ SetResponseData((unsigned char*)strRemaining,lenRemaining);
+ responseLength = lenRemaining;
+ nBufUsed = 0;
+ }
+ else
+ nBufUsed += retcode;
+ } else {
+ SetResponseData((unsigned char*)in_buf,retcode);
+ responseLength += retcode;
+ }
+ retcode = recv(server_s, in_buf + nBufUsed, BUF_SIZE-nBufUsed, 0);
+ }
+
+ if ( responseLength > 0 ) {
+ return SYNCML_DM_SUCCESS;
+ } else {
+ return SYNCML_DM_FAIL;
+ }
+}
diff --git a/engine/xpl/src/dmThreadHelper.cc b/engine/xpl/src/dmThreadHelper.cc
new file mode 100644
index 0000000..4da6a37
--- /dev/null
+++ b/engine/xpl/src/dmThreadHelper.cc
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dmThreadHelper.h"
+#include "dmMemory.h"
+#include "xpl_Logger.h"
+
+bool DMThread::StartThread()
+{
+ if ( m_bRunning )
+ return false;
+
+ m_bRunning = true;
+
+ int nRes = pthread_create( &m_hThread, 0, ThreadProc, (void*)this );
+
+ if ( nRes != 0 )
+ {
+ XPL_LOG_DM_TMN_Debug(("DMThread: can't create a thread; error %d \n", nRes));
+
+ m_bRunning = false;
+ return false;
+ }
+ return true;
+}
+
+bool DMThread::StopThread()
+{
+ if ( !m_bRunning )
+ return false;
+
+ m_bRunning = false;
+
+ bool bRet = (pthread_join( m_hThread, NULL ) == 0);
+
+ return bRet;
+}
+
+void* DMThread::ThreadProc(void *pArg)
+{
+ DMThread* pThis = (DMThread*)pArg;
+ void* pRes = 0;
+
+ if ( pThis->m_bRunning )
+ pRes = pThis->Run();
+
+ return pRes;
+}
diff --git a/engine/xpl/src/dmThreadQueue.cc b/engine/xpl/src/dmThreadQueue.cc
new file mode 100644
index 0000000..c6160cb
--- /dev/null
+++ b/engine/xpl/src/dmThreadQueue.cc
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dmprofile.h"
+#include "dmAllocatedPointersPool.h"
+#include <stdio.h>
+
+DMThreadQueue::~DMThreadQueue()
+{
+ pthread_cond_destroy( &m_oCond );
+}
+
+DMThreadQueue::DMThreadQueue() :
+ m_nHead(0), m_nSize(0)
+{
+ pthread_cond_t t = PTHREAD_COND_INITIALIZER;
+ m_oCond = t;
+ m_bTimerSet = false;
+}
+
+bool DMThreadQueue::Post( SYNCML_DM_THREAD_EVENT_TYPE_T nID, void* pData /*= NULL*/ )
+{
+ DMSingleLock oLock( m_csMutex );
+
+ if ( m_nSize == DIM(m_aEvents) ) { // overflow - wait a little bit
+ m_csMutex.Leave();
+ sleep( 5 );
+ m_csMutex.Enter();
+ }
+
+ if ( m_nSize == DIM(m_aEvents) ) // still overflow - something unexpected happen
+ return false;
+
+ m_aEvents[m_nHead] = DMThreadEvent( nID, pData );
+ m_nHead ++; m_nHead %= DIM(m_aEvents);
+ m_nSize++;
+
+ pthread_cond_signal( &m_oCond );
+ return true;
+}
+
+void DMThreadQueue::KillTimer()
+{
+ DMSingleLock oLock( m_csMutex );
+
+ m_bTimerSet = false;
+}
+
+void DMThreadQueue::SetTimer( int nTimeoutMS )
+{
+ DMSingleLock oLock( m_csMutex );
+
+ GetTimeWithinTimeout( m_sTimerFireTime, nTimeoutMS );
+ m_bTimerSet = true;
+
+ pthread_cond_signal( &m_oCond );
+}
+
+bool DMThreadQueue::Wait( long nTimeoutMS, DMThreadEvent& event )
+{
+ DMSingleLock oLock( m_csMutex );
+ struct timespec stimeout;
+ GetTimeWithinTimeout( stimeout, nTimeoutMS );
+
+ while ( !m_nSize && nTimeoutMS ) { // wait if empty
+ struct timespec swaitTo;
+
+ GetWaitTime( swaitTo, stimeout );
+
+ pthread_cond_timedwait( &m_oCond, &m_csMutex.GetHandle(), &swaitTo);
+
+ if ( TimerReady() ||(memcmp( &swaitTo, &stimeout, sizeof(swaitTo) ) ==0) )
+ break;
+ }
+
+ if ( TimerReady() ) {
+ m_bTimerSet = false;
+ event = DMThreadEvent( SYNCML_DM_THREAD_EVENT_TYPE_TIMEOUT );
+ return true;
+ }
+
+ if ( !m_nSize ) //
+ return false;
+
+ int nIndex = (m_nHead + DIM(m_aEvents) - m_nSize) % DIM(m_aEvents);
+ m_nSize--;
+ event = m_aEvents[nIndex];
+ return true;
+}
+
+void DMThreadQueue::GetTimeWithinTimeout( struct timespec &stimeout, long nTimeoutMS ) const
+{
+ struct timeval now;
+ gettimeofday(&now,0);
+ stimeout.tv_nsec = now.tv_usec + (nTimeoutMS % 1000) * 1000; // store usec
+ stimeout.tv_sec = now.tv_sec + (nTimeoutMS / 1000) + (stimeout.tv_nsec / 10000000);
+ stimeout.tv_nsec %= 10000000;
+ stimeout.tv_nsec *= 1000; // convert to nsec
+}
+
+void DMThreadQueue::GetWaitTime(struct timespec &sWaitTo, const struct timespec &stimeout ) const
+{
+ if ( m_bTimerSet &&
+ ( (m_sTimerFireTime.tv_sec < stimeout.tv_sec) ||
+ ( (m_sTimerFireTime.tv_sec == stimeout.tv_sec) && (m_sTimerFireTime.tv_nsec < stimeout.tv_nsec) ) ) )
+ sWaitTo = m_sTimerFireTime;
+ else
+ sWaitTo = stimeout;
+}
+
+bool DMThreadQueue::TimerReady() const
+{
+ if ( !m_bTimerSet )
+ return false;
+
+ struct timespec tm;
+ GetTimeWithinTimeout( tm, 0 );
+
+ return (tm.tv_sec > m_sTimerFireTime.tv_sec) ||
+ ( (tm.tv_sec == m_sTimerFireTime.tv_sec) && (tm.tv_nsec > m_sTimerFireTime.tv_nsec) );
+
+}
diff --git a/engine/xpl/src/dmprofile.cc b/engine/xpl/src/dmprofile.cc
new file mode 100644
index 0000000..a559beb
--- /dev/null
+++ b/engine/xpl/src/dmprofile.cc
@@ -0,0 +1,452 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdarg.h>
+#include <time.h>
+#include "dmStringUtil.h"
+#include "dmprofile.h"
+#include "dmThreadHelper.h"
+#include "dmstring.h"
+
+#ifdef DM_FILE_OUTPUT
+
+void DMFileOutput( const char* szFormat, ... )
+{
+ static int s_nFirstCall = 1; // mark first access to write some additional info
+ static char filename[255];
+
+ FILE * fp=NULL;
+
+ if ( s_nFirstCall ){
+ s_nFirstCall = 0;
+
+ const char* dm_settings_env = getenv("dm_setting_root");
+
+ if ( !dm_settings_env )
+ dm_settings_env = "";
+
+ DmStrcpy (filename, dm_settings_env);
+ DmStrcat( filename, "/a/motorola/settings/DMOUTPUT.txt" );
+
+ fp=fopen(filename, "a+");
+ if (!fp)
+ return;
+
+ time_t elapstime;
+ time(&elapstime);
+
+ fprintf(fp, "\nLog started at %s \n",
+ ctime(&elapstime));
+ fclose(fp);
+ fp=NULL;
+ }
+
+ fp=fopen(filename, "a+");
+ if (!fp)
+ return;
+
+ va_list ap;
+ va_start(ap, szFormat);
+ vfprintf( fp, szFormat, ap );
+ va_end(ap);
+
+ fclose(fp);
+ fp=NULL;
+}
+
+#endif
+
+#ifdef DM_PROFILER_ENABLED
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+CDMProfCell g_aProfStorage[PROF_CELL_NUM];
+int g_nProfCurCell = 0;
+
+class CProfileCmdListener : public DMThread{
+public:
+ CProfileCmdListener() {
+ StartThread();
+ }
+ ~CProfileCmdListener() {
+ StopThread();
+ }
+
+ enum { eNone, eError, eReset, ePrint, ePrintPipe};
+ virtual void* Run();
+ int GetCommand( int nPipe );
+ void PrintResult( int nFile );
+
+ DMString _sOutPipe;
+};
+
+#define PROF_CMD_PIPE_NAME "/tmp/dmprof"
+
+void* CProfileCmdListener::Run()
+{
+printf("DM profile command listener is started\n"
+ "use file " PROF_CMD_PIPE_NAME " to manipulate it\n");
+
+{
+ // check for cvm
+ char szFile[1024];
+
+ sprintf( szFile, "/proc/%d/cmdline", (int)getpid() );
+ int nF = open( szFile, O_RDONLY );
+ if ( nF >= 0 ){
+ read( nF, szFile, sizeof(szFile ) );
+ close (nF);
+
+ if ( strstr( szFile, "cvm") == NULL )
+ return NULL;
+ }
+}
+
+ if (mkfifo(PROF_CMD_PIPE_NAME, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
+ printf("Failed to create pipe\n");
+
+ int nPipe = open(PROF_CMD_PIPE_NAME, O_NONBLOCK );
+
+ if ( nPipe < 0 ){
+ printf( "Failed to open pipe - cmd listener terminated\n");
+ return 0;
+ }
+
+ while (m_bRunning)
+ {
+ int nCmd = GetCommand( nPipe );
+
+ if ( nCmd != eNone )
+ printf( "Cmd received %d\n\n\n", nCmd );
+
+ //printf("Stat %d:\n", g_nProfCurCell);
+
+ switch ( nCmd ){
+ case eReset:
+ printf("Reset\n");
+ g_nProfCurCell = 0;
+ break;
+
+ case ePrint:
+ PrintResult(-1);
+ break;
+
+ case ePrintPipe:
+ {
+ int nFile = open( _sOutPipe, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
+ PrintResult(nFile);
+ if ( nFile > -1 )
+ close( nFile );
+ }
+ break;
+ };
+ }
+
+ close( nPipe );
+
+ return 0;
+}
+
+int CProfileCmdListener::GetCommand( int nPipe )
+{
+ if ( nPipe < 0 | nPipe > 1023 )
+ return -1;
+
+ int rc;
+ fd_set fds;
+ struct timeval tv;
+
+ FD_ZERO(&fds);
+ FD_SET(nPipe,&fds);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+
+ rc = select(nPipe+1, &fds, NULL, NULL, &tv);
+ if (rc < 0)
+ return eError;
+
+ if (!FD_ISSET(nPipe,&fds) )
+ return eNone;
+
+ char szCmd[50] = "";
+
+ int nBytes = read( nPipe, szCmd, sizeof(szCmd));
+
+ if ( nBytes == 0 ){
+ sleep(1);
+ return eNone;
+ }
+
+ if ( strncmp( szCmd, "reset", 5) == 0 )
+ return eReset;
+
+ if ( strncmp( szCmd, "print", 5) == 0 )
+ return ePrint;
+
+ if ( strncmp( szCmd, "out", 3) == 0 ){
+ _sOutPipe.assign(szCmd + 4, nBytes - 4);
+ printf( "out to [%s]\n", _sOutPipe.c_str() );
+ return ePrintPipe;
+ }
+
+ return eError;
+
+}
+
+void CProfileCmdListener::PrintResult( int nFile )
+{
+ int n = 0;
+ long long nTot = 0;
+ char szBuf[10096];
+
+ while ( n < g_nProfCurCell ){
+
+ if ( g_aProfStorage[n % PROF_CELL_NUM]._s ) {
+ int nLen = sprintf( szBuf, "%d: DMProfile: %s, time is %lld usec, from %lld to %lld\n",
+ n+1,
+ g_aProfStorage[n % PROF_CELL_NUM]._s,
+ g_aProfStorage[n % PROF_CELL_NUM]._elapsed,
+ g_aProfStorage[n % PROF_CELL_NUM]._from,
+ g_aProfStorage[n % PROF_CELL_NUM]._elapsed + g_aProfStorage[n % PROF_CELL_NUM]._from );
+
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ nTot += g_aProfStorage[n % PROF_CELL_NUM]._elapsed;
+ }
+
+ free( (void*)g_aProfStorage[n % PROF_CELL_NUM]._s );
+ g_aProfStorage[n % PROF_CELL_NUM]._s = NULL;
+ n++;
+ }
+
+ int nLen = sprintf( szBuf, "Total time is %lld\n", nTot );
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ g_nProfCurCell = 0;
+}
+
+CProfileCmdListener g_oProfileCmdListener;
+
+#endif
+
+#ifdef DM_PROFILER_STACK
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+
+DMProfileData __aProfStackStorage[PROF_STACK_NUM];
+
+int g_nProfCurCell = 0;
+
+
+class CProfileStackCmdListener : public DMThread{
+public:
+ CProfileStackCmdListener() {
+ StartThread();
+ }
+ ~CProfileStackCmdListener() {
+ StopThread();
+ }
+
+ enum { eNone, eError, eReset, ePrint, ePrintPipe};
+ virtual void* Run();
+ int GetCommand( int nPipe );
+ void PrintResult( int nFile );
+
+ DMString _sOutPipe;
+};
+
+#define PROF_CMD_PIPE_NAME "/tmp/dmprofstack"
+
+void* CProfileStackCmdListener::Run()
+{
+ printf("DM profile STACK command listener is started\n"
+ "use file " PROF_CMD_PIPE_NAME " to manipulate it\n");
+
+ {
+ // check for cvm
+ char szFile[1024];
+
+ sprintf( szFile, "/proc/%d/cmdline", (int)getpid() );
+ int nF = open( szFile, O_RDONLY );
+ if ( nF >= 0 ){
+ read( nF, szFile, sizeof(szFile ) );
+ close (nF);
+
+ if ( strstr( szFile, "cvm") == NULL )
+ return NULL;
+ }
+ }
+
+ if (mkfifo(PROF_CMD_PIPE_NAME, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP))
+ printf("Failed to create pipe\n");
+
+ int nPipe = open(PROF_CMD_PIPE_NAME, O_NONBLOCK );
+
+ if ( nPipe < 0 ){
+ printf( "Failed to open pipe - cmd listener terminated\n");
+ return 0;
+ }
+
+ while (m_bRunning)
+ {
+ int nCmd = GetCommand( nPipe );
+
+ if ( nCmd != eNone )
+ printf( "Cmd received %d\n\n\n", nCmd );
+
+ switch ( nCmd ){
+ case eReset:
+ printf("Reset\n");
+ g_nProfCurCell = 0;
+ break;
+
+ case ePrint:
+ PrintResult(-1);
+ break;
+
+ case ePrintPipe:
+ {
+ int nFile = open( _sOutPipe, O_WRONLY | O_CREAT | O_APPEND );
+ PrintResult(nFile);
+ if ( nFile > -1 )
+ close( nFile );
+ }
+ break;
+ };
+ }
+
+ close( nPipe );
+
+ return 0;
+}
+
+int CProfileStackCmdListener::GetCommand( int nPipe )
+{
+ if ( nPipe < 0 | nPipe > 1023 )
+ return -1;
+
+ int rc;
+ fd_set fds;
+ struct timeval tv;
+
+ FD_ZERO(&fds);
+ FD_SET(nPipe,&fds);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+
+ rc = select(nPipe+1, &fds, NULL, NULL, &tv);
+ if (rc < 0)
+ return eError;
+
+ if (!FD_ISSET(nPipe,&fds) )
+ return eNone;
+
+ char szCmd[50] = "";
+
+ int nBytes = read( nPipe, szCmd, sizeof(szCmd));
+
+ if ( nBytes == 0 ){
+ sleep(1);
+ return eNone;
+ }
+
+ if ( strncmp( szCmd, "reset", 5) == 0 )
+ return eReset;
+
+ if ( strncmp( szCmd, "print", 5) == 0 )
+ return ePrint;
+
+ if ( strncmp( szCmd, "out", 3) == 0 ){
+ _sOutPipe.assign(szCmd + 4, nBytes - 4);
+ printf( "out to [%s]\n", _sOutPipe.c_str() );
+ return ePrintPipe;
+ }
+
+ return eError;
+}
+
+void CProfileStackCmdListener::PrintResult( int nFile )
+{
+ int n = 0;
+ long long nTot = 0;
+ char szBuf[10096];
+
+ int nLen = sprintf( szBuf, "<DMProfiles>\n");
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ while ( n < g_nProfCurCell ){
+
+ if ( __aProfStackStorage[n % PROF_STACK_NUM]._elapsed ) {
+
+ nLen = sprintf( szBuf, " <DMProfile>\n");
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ nLen = sprintf( szBuf, " <ID>%d</ID>\n <ElapseTime>%lld</ElapseTime>\n <BeginTime>%lld</BeginTime>\n <EndTime>%lld</EndTime>\n%s",
+ n+1,
+ __aProfStackStorage[n % PROF_STACK_NUM]._elapsed,
+ __aProfStackStorage[n % PROF_STACK_NUM]._from,
+ __aProfStackStorage[n % PROF_STACK_NUM]._elapsed + __aProfStackStorage[n % PROF_STACK_NUM]._from,
+ __aProfStackStorage[n % PROF_STACK_NUM]._s);
+
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+
+ nLen = sprintf( szBuf, " </DMProfile>\n");
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ nTot += __aProfStackStorage[n % PROF_STACK_NUM]._elapsed;
+ }
+
+ free( (void*)__aProfStackStorage[n % PROF_STACK_NUM]._s );
+ __aProfStackStorage[n % PROF_STACK_NUM]._s = NULL;
+ n++;
+ }
+
+ nLen = sprintf( szBuf, "</DMProfiles>\n");
+ if ( nFile >= 0 )
+ write( nFile, szBuf, nLen );
+ else
+ printf( "%s", szBuf );
+
+ g_nProfCurCell = 0;
+}
+
+CProfileStackCmdListener g_oProfileStackCmdListener;
+
+#endif
diff --git a/engine/xpl/src/xpl_Alert.cc b/engine/xpl/src/xpl_Alert.cc
new file mode 100644
index 0000000..ca3373a
--- /dev/null
+++ b/engine/xpl/src/xpl_Alert.cc
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xpl_dm_ServerAlert.h"
+#include <DMServiceAlert.h>
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowDisplayAlert(INT32 minDisplayTime, CPCHAR msg)
+{
+ DMServiceAlert alert;
+ return alert.showDisplayAlert(minDisplayTime, msg);
+}
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowConfirmAlert(INT32 maxDisplayTime, CPCHAR msg, XPL_DM_ALERT_RES_T defaultResponse, XPL_DM_ALERT_RES_T * responseCode)
+{
+ DMServiceAlert alert;
+ return alert.showConfirmAlert(maxDisplayTime, msg, defaultResponse, responseCode);
+}
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowTextInputAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ CPCHAR defaultResponse,
+ INT32 maxLength,
+ XPL_DM_ALERT_INPUT_T inputType,
+ XPL_DM_ALERT_ECHO_T echoType,
+ XPL_DM_ALERT_TEXTINPUT_RES_T * userResponse )
+{
+ DMServiceAlert alert;
+ return alert.showTextInputAlert(maxDisplayTime,
+ msg,
+ defaultResponse,
+ maxLength,
+ inputType,
+ echoType,
+ userResponse );
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowSingleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ INT32 defaultResponse,
+ XPL_DM_ALERT_SCHOICE_RES_T * userResponse )
+{
+ DMServiceAlert alert;
+ return alert.showSingleChoiceAlert(maxDisplayTime,
+ msg,
+ choices,
+ defaultResponse,
+ userResponse);
+}
+
+
+SYNCML_DM_RET_STATUS_T XPL_DM_ShowMultipleChoiceAlert(INT32 maxDisplayTime,
+ CPCHAR msg,
+ DMStringVector & choices,
+ DMStringVector & defaultResponses,
+ XPL_DM_ALERT_MCHOICE_RES_T * userResponse)
+{
+ DMServiceAlert alert;
+ return alert.showMultipleChoiceAlert(maxDisplayTime,
+ msg,
+ choices,
+ defaultResponses,
+ userResponse);
+}
diff --git a/engine/xpl/src/xpl_File.cc b/engine/xpl/src/xpl_File.cc
new file mode 100644
index 0000000..d7bd8ab
--- /dev/null
+++ b/engine/xpl/src/xpl_File.cc
@@ -0,0 +1,482 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/vfs.h>
+#include <sys/mman.h>
+#include "xpl_Memory.h"
+#include "xpl_File.h"
+#include "xpl_Logger.h"
+#include "dmvector.h"
+
+class DMDirHandler
+{
+public :
+ DMDirHandler()
+ {
+ m_nIndex = 0;
+ m_nDirLen = 0;
+ m_pDir = XPL_NULL;
+
+ }
+ ~DMDirHandler()
+ {
+ if (m_pDir)
+ closedir(m_pDir);
+ }
+
+ void* operator new(size_t dwSize)
+ {
+ return (xplAllocMem(dwSize));
+ }
+
+ void operator delete(void *pvBuf)
+ {
+ xplFreeMem(pvBuf);
+ }
+
+ DMString m_szDirectory;
+ DMString m_szExtension;
+ INT32 m_nIndex;
+ INT32 m_nDirLen;
+ DIR *m_pDir;
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+XPL_FS_HANDLE_T XPL_FS_Open(CPCHAR file_uri,
+ const XPL_FS_OPEN_MODE_T open_mode,
+ XPL_FS_RET_STATUS_T * result)
+{
+ int flags = 0;
+ XPL_FS_HANDLE_T nFileHandle;
+
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+
+ switch ( open_mode) {
+ case XPL_FS_FILE_READ:
+ flags = O_RDONLY; /* read-only at current position */
+ break;
+
+ case XPL_FS_FILE_WRITE:
+ flags = O_WRONLY | O_TRUNC | O_CREAT; /* write-only truncate file */
+ break;
+
+ case XPL_FS_FILE_RDWR:
+ flags = O_RDWR| O_CREAT; /* read and write at current position */
+ break;
+
+ case XPL_FS_FILE_APPEND:
+ flags = O_WRONLY | O_APPEND | O_CREAT; /* read and write at current position */
+ break;
+ }
+
+ nFileHandle = (XPL_FS_HANDLE_T)open(file_uri, flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ // XPL_LOG_DM_XPL_Debug(("DMFileHandler::open: opening file %s with mode flag %d, errno is %d, handle = %d\n",file_uri,(int)open_mode, errno, nFileHandle));
+ if ( result && nFileHandle == -1 )
+ {
+ if (errno == EPERM) { // permission failure
+ *result = XPL_FS_RET_PERM_FAIL;
+ }
+ else {
+ *result = XPL_FS_RET_FAIL;
+ }
+ XPL_LOG_DM_XPL_Error(("DMFileHandler::open: can't open file %s with mode flag %d errno is %d\n",file_uri,(int)open_mode,errno));
+ }
+
+ if ( nFileHandle > 0 && open_mode != XPL_FS_FILE_READ )
+ {
+ chmod(file_uri,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ }
+ return nFileHandle;
+
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_Close(XPL_FS_HANDLE_T file_handle)
+{
+ int result = close((int)file_handle);
+ if ( result < 0 )
+ return XPL_FS_RET_FAIL;
+ else
+ return XPL_FS_RET_SUCCESS;
+}
+
+
+XPL_FS_COUNT_T XPL_FS_Read(XPL_FS_HANDLE_T file_handle,
+ void* buffer,
+ const XPL_FS_COUNT_T count,
+ XPL_FS_RET_STATUS_T * result)
+{
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+ XPL_FS_COUNT_T nRead = (XPL_FS_COUNT_T)read((int)file_handle,buffer,(int)count);
+ if ( result && nRead == -1 )
+ *result = XPL_FS_RET_FAIL;
+ return nRead;
+}
+
+
+XPL_FS_COUNT_T XPL_FS_Write(XPL_FS_HANDLE_T file_handle,
+ void* buffer,
+ const XPL_FS_COUNT_T count,
+ XPL_FS_RET_STATUS_T * result)
+{
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+
+ XPL_FS_COUNT_T nWrite = (XPL_FS_COUNT_T)write((int)file_handle,buffer,(int)count);
+ if ( result && nWrite == -1 ) {
+ XPL_LOG_DM_XPL_Error(("XPL_FS_Write: file_handle %d, nWrite = %d errno is %d\n",file_handle, nWrite, errno));
+ *result = XPL_FS_RET_FAIL;
+ }
+ return nWrite;
+}
+
+
+XPL_FS_SEEK_OFFSET_T XPL_FS_Seek(XPL_FS_HANDLE_T file_handle,
+ XPL_FS_SEEK_OFFSET_T offset,
+ XPL_FS_SEEK_MODE_T whence,
+ XPL_FS_RET_STATUS_T * result)
+{
+ int whence_posix;
+ XPL_FS_SEEK_OFFSET_T result_offset;
+
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+ switch(whence)
+ {
+ case XPL_FS_SEEK_SET:
+ whence_posix = SEEK_SET;
+ break;
+ case XPL_FS_SEEK_CUR:
+ whence_posix = SEEK_CUR;
+ break;
+ case XPL_FS_SEEK_END:
+ whence_posix = SEEK_END;
+ break;
+ }
+ result_offset = lseek(file_handle,offset,whence_posix);
+ if ( result && result_offset == -1)
+ *result = XPL_FS_RET_FAIL;
+ return result_offset;
+
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_Remove(CPCHAR path)
+{
+ int result = remove(path);
+ if ( result < 0 )
+ return XPL_FS_RET_FAIL;
+ else
+ return XPL_FS_RET_SUCCESS;
+}
+
+XPL_FS_RET_STATUS_T XPL_FS_Rename(CPCHAR old_name, CPCHAR new_name)
+{
+ int result = rename(old_name, new_name);
+
+ // XPL_LOG_DM_XPL_Debug(("XPL_FS_Rename: old name %s new name %s result = %d, errno is %d%d\n",old_name,new_name, errno, result));
+
+ if ( result < 0 ) {
+ XPL_LOG_DM_XPL_Error(("XPL_FS_Rename error: old name %s new name %s result = %d, errno is %d\n",old_name,new_name, errno, result));
+ return XPL_FS_RET_FAIL;
+ }
+ else
+ return XPL_FS_RET_SUCCESS;
+}
+
+BOOLEAN XPL_FS_Exist(CPCHAR match_uri)
+{
+ struct stat st;
+ bool result;
+
+
+ errno = 0; // reset to 0
+
+ if(stat(match_uri, &st) < 0)
+ result = FALSE;
+ else
+ result = TRUE;
+
+ // XPL_LOG_DM_XPL_Debug(("XPL_FS_Exists: match uri %s, errno is %d result = %d\n",match_uri, errno, result));
+
+ return result;
+}
+
+BOOLEAN XPL_FS_CheckPermission(CPCHAR match_uri, XPL_FS_OPEN_MODE_T permission)
+{
+ bool result = FALSE;
+ int mode = 0;
+
+ switch (permission) {
+ case XPL_FS_RDONLY_MODE:
+ mode = R_OK;
+ break;
+ case XPL_FS_WRONLY_MODE:
+ case XPL_FS_RDWR_MODE:
+ case XPL_FS_CREAT_MODE:
+ case XPL_FS_TRUNC_MODE:
+ case XPL_FS_APPEND_MODE:
+ mode = R_OK | W_OK;
+ break;
+ default:
+ break;
+ }
+
+ errno = 0; // reset to 0
+ if (access(match_uri, mode) == 0) {
+ result = TRUE;
+ }
+ // XPL_LOG_DM_XPL_Debug(("XPL_FS_CheckPermission: match uri %s, errno is %d result = %d\n",match_uri, errno, result));
+
+ return result;
+}
+
+
+XPL_CLK_CLOCK_T XPL_FS_GetModTime(CPCHAR file_uri)
+{
+ struct stat st;
+
+ if(stat( file_uri, &st) < 0)
+ return 0; // like it was never modified
+ else
+ return (XPL_CLK_CLOCK_T)st.st_mtime;
+ }
+
+XPL_FS_SIZE_T XPL_FS_GetSize(XPL_FS_HANDLE_T file_handle)
+{
+ struct stat st;
+
+ if(fstat(file_handle, &st) < 0)
+ return XPL_FS_SIZE_INVALID;
+ return st.st_size;
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_MkDir(CPCHAR dir_uri)
+{
+ mkdir(dir_uri, S_IRWXU|S_IRWXG|S_IRWXO);
+ return XPL_FS_RET_SUCCESS;
+}
+
+XPL_FS_RET_STATUS_T XPL_FS_Lock(XPL_FS_HANDLE_T file_handle, BOOLEAN bLockExclusive )
+{
+ struct flock fl;
+
+ fl.l_type = bLockExclusive ? F_WRLCK : F_RDLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_pid = getpid();
+
+ if (fcntl(file_handle, F_SETLK, &fl) != -1)
+ return XPL_FS_RET_SUCCESS;
+ else
+ return (errno == EAGAIN ? XPL_FS_RET_TRYAGAIN : XPL_FS_RET_FAIL);
+}
+
+XPL_FS_RET_STATUS_T XPL_FS_Unlock(XPL_FS_HANDLE_T file_handle)
+{
+ struct flock fl;
+
+ fl.l_type = F_UNLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_pid = getpid();
+
+ if (fcntl(file_handle, F_SETLK, &fl) != -1)
+ return XPL_FS_RET_SUCCESS;
+ else
+ return XPL_FS_RET_FAIL;
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_Unlink(CPCHAR file_name)
+{
+ if ( unlink(file_name) == 0 )
+ return XPL_FS_RET_SUCCESS;
+ else
+ return XPL_FS_RET_FAIL;
+}
+
+
+
+XPL_FS_SHANDLE_T XPL_FS_StartSearch(CPCHAR dir_uri, CPCHAR extension, BOOLEAN bFullName, XPL_FS_RET_STATUS_T * result)
+{
+ DIR *dir = XPL_NULL;
+
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+
+ dir = opendir(dir_uri);
+ if ( dir == NULL )
+ {
+ if ( result )
+ *result = XPL_FS_RET_FAIL;
+
+ return XPL_FS_SHANDLE_INVALID;
+ }
+
+ DMDirHandler * pDirHandler = NULL;
+ pDirHandler = new DMDirHandler;
+
+ if ( pDirHandler == NULL )
+ {
+ if ( result )
+ *result = XPL_FS_RET_FAIL;
+
+ closedir( dir );
+ return XPL_FS_SHANDLE_INVALID;
+ }
+
+ if ( bFullName )
+ {
+ int nDirLen = strlen(dir_uri);
+ if ( nDirLen >= XPL_FS_MAX_FILE_NAME_LENGTH )
+ {
+ return XPL_FS_SHANDLE_INVALID;
+ }
+ if (nDirLen>0)
+ {
+ pDirHandler->m_szDirectory = dir_uri;
+ if ( dir_uri[nDirLen-1] != '/' )
+ {
+ pDirHandler->m_szDirectory += "/";
+ ++nDirLen;
+ }
+ pDirHandler->m_nDirLen = nDirLen;
+ }
+ }
+
+ pDirHandler->m_szExtension = extension;
+ pDirHandler->m_pDir = dir;
+
+ return (XPL_FS_SHANDLE_T)(pDirHandler);
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_GetSearchResult(XPL_FS_SHANDLE_T search_handle, XPL_FS_SEARCH_FILE file_name)
+{
+ DMDirHandler * pDirHandler = (DMDirHandler*)search_handle;
+ struct dirent *de = NULL;
+
+ if ( !pDirHandler || search_handle == XPL_FS_SHANDLE_INVALID )
+ return XPL_FS_RET_FAIL;
+
+ int nNameLen = 0;
+ int nExtensionLen = strlen(pDirHandler->m_szExtension);
+ de = readdir(pDirHandler->m_pDir);
+ while ( de )
+ {
+ nNameLen = strlen(de->d_name);
+ if (nNameLen > nExtensionLen && !strncmp((de->d_name + nNameLen - nExtensionLen), pDirHandler->m_szExtension, nExtensionLen))
+ {
+ if ( pDirHandler->m_nDirLen+nNameLen >= XPL_FS_MAX_FILE_NAME_LENGTH )
+ {
+ return XPL_FS_RET_FAIL;
+ }
+ if ( pDirHandler->m_nDirLen>0 )
+ {
+ strcpy(file_name,pDirHandler->m_szDirectory);
+ }
+ strcpy(file_name+pDirHandler->m_nDirLen,(CPCHAR)de->d_name);
+ return XPL_FS_RET_SUCCESS;
+ }
+ else
+ {
+ de = readdir(pDirHandler->m_pDir);
+ }
+ }
+
+ return XPL_FS_RET_NOT_FOUND;
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_EndSearch(XPL_FS_SHANDLE_T search_handle)
+{
+ DMDirHandler * pDirHandler = (DMDirHandler*)search_handle;
+ // DO not call closedir(...); since it's called from DirHandle destructor...
+ delete pDirHandler;
+ return XPL_FS_RET_SUCCESS;
+}
+
+
+UINT8 * XPL_FS_MemMap(XPL_FS_HANDLE_T file_handle, UINT32 size, UINT32 offset, XPL_FS_RET_STATUS_T * result)
+{
+ UINT8 * pBuffer = NULL;
+
+ if ( result )
+ *result = XPL_FS_RET_SUCCESS;
+
+ pBuffer = (UINT8*)mmap(0,size,PROT_READ,MAP_PRIVATE,file_handle,offset);
+ if ( pBuffer == MAP_FAILED )
+ {
+ if ( result)
+ *result = XPL_FS_RET_FAIL;
+ return NULL;
+ }
+
+ return pBuffer;
+
+}
+
+
+XPL_FS_RET_STATUS_T XPL_FS_MemUnMap(UINT8 * pBuffer, UINT32 size)
+{
+ int res = munmap(pBuffer,size);
+ if ( res == 0 )
+ return XPL_FS_RET_SUCCESS;
+ else
+ return XPL_FS_RET_FAIL;
+}
+#ifdef LOB_SUPPORT
+static const char TEMP_ESN_DIR_NAME[]= "/data/data/com.android.omadm.service/tmp/";
+CPCHAR XPL_FS_TempEsnDir()
+{
+ return TEMP_ESN_DIR_NAME;
+}
+XPL_FS_SIZE_T XPL_FS_FreeDiskSpace(CPCHAR pEsnDir)
+{
+ struct statfs sf;
+ XPL_FS_SIZE_T retSize = 0;
+
+ if(statfs(pEsnDir, &sf) == 0)
+ {
+ retSize = sf.f_bfree * sf.f_bsize;
+ }
+ return retSize;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/xpl/src/xpl_HTTP.cc b/engine/xpl/src/xpl_HTTP.cc
new file mode 100644
index 0000000..8bfc8df
--- /dev/null
+++ b/engine/xpl/src/xpl_HTTP.cc
@@ -0,0 +1,181 @@
+#include <stdio.h>
+#include "xpl_HTTP.h"
+#include "dmConnection.h"
+#include "dmStringUtil.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+static DmBrwConnector *stDmBrwConnector = NULL;
+
+XPL_HTTP_HANDLE_T XPL_HTTP_Open(CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType,
+ XPL_HTTP_RET_STATUS_T * result)
+{
+ if(stDmBrwConnector == NULL)
+ {
+ stDmBrwConnector = DmBrwCreateConnector();
+
+ if ( stDmBrwConnector == NULL )
+ {
+ if ( result )
+ *result = XPL_HTTP_RET_FAIL;
+ return XPL_HTTP_HANDLE_INVALID;
+ }
+ }
+
+
+ XPL_HTTP_RET_STATUS_T res;
+ res = stDmBrwConnector->Open(url, ConRef, (UINT32)addrType);
+ if ( res == XPL_HTTP_RET_SUCCESS )
+ {
+ if ( result )
+ *result = res;
+ return (XPL_HTTP_HANDLE_T)stDmBrwConnector;
+ }
+ else
+ {
+ if ( result )
+ *result = XPL_HTTP_RET_FAIL;
+ return XPL_HTTP_HANDLE_INVALID;
+ }
+}
+
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_SetUrl(XPL_HTTP_HANDLE_T handler,
+ CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType)
+{
+ DmBrwConnector * brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->SetUrl(url, ConRef, (UINT32)addrType);
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_SetRequestMethod(XPL_HTTP_HANDLE_T handler, XPL_HTTP_METHOD_T method)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->SetRequestMethod(method);
+}
+
+
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_SetRequestProperty(XPL_HTTP_HANDLE_T handler, CPCHAR buffer)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->SetRequestProperty((CPCHAR)"header_start", buffer);
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_Send(XPL_HTTP_HANDLE_T handler, CPCHAR data, UINT32 size)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->Send(data,size);
+}
+
+UINT32 XPL_HTTP_GetResponseLength(XPL_HTTP_HANDLE_T handler)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->GetResponseLength();
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_GetResponse(XPL_HTTP_HANDLE_T handler, char * data, UINT32 size)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->GetResponse(data,size);
+}
+
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_GetHeaderField(XPL_HTTP_HANDLE_T handler, CPCHAR field, char **value)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ DMString strValue;
+ SYNCML_DM_RET_STATUS_T ret=brwConnector->GetHeaderField(field,strValue);
+ DmStrcpy(*value, strValue.c_str());
+ return (XPL_HTTP_RET_STATUS_T)ret;
+}
+
+XPL_HTTP_CODE_T XPL_HTTP_GetResponseCode(XPL_HTTP_HANDLE_T handler)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->GetResponseCode();
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_Close(XPL_HTTP_HANDLE_T handler)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ brwConnector->Close();
+
+ DmBrwDestroyConnector(brwConnector);
+ stDmBrwConnector = NULL;
+ return XPL_HTTP_RET_SUCCESS;
+}
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_CloseReq(XPL_HTTP_HANDLE_T handler)
+{
+ DmBrwConnector* brwConnector = (DmBrwConnector*)handler;
+ if ( brwConnector != stDmBrwConnector )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ return brwConnector->CloseReq();
+}
+
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DowloadByFile(XPL_HTTP_HANDLE_T handler, CPCHAR file_name)
+{
+ return XPL_HTTP_RET_NOT_SUPPORTED;
+
+}
+
+
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DownloadByBuffer(XPL_HTTP_HANDLE_T handler, UINT8 * buffer, UINT32 size)
+{
+ return XPL_HTTP_RET_NOT_SUPPORTED;
+
+}
+
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetRespHeader(XPL_HTTP_HANDLE_T handler, char ** header)
+{
+ return XPL_HTTP_RET_NOT_SUPPORTED;
+}
+
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetType(XPL_HTTP_HANDLE_T handler, char ** content_type)
+{
+ return XPL_HTTP_RET_NOT_SUPPORTED;
+
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/xpl/src/xpl_HTTP_socket.cc b/engine/xpl/src/xpl_HTTP_socket.cc
new file mode 100644
index 0000000..6e23858
--- /dev/null
+++ b/engine/xpl/src/xpl_HTTP_socket.cc
@@ -0,0 +1,223 @@
+
+#include "xpl_HTTP.h"
+#include "dmSocketConnector.h"
+
+
+/* Activetes HTTP transport and set specified URL to connect with server.
+* Do not establish actual connection with server */
+XPL_HTTP_HANDLE_T XPL_HTTP_Open(CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType,
+ XPL_HTTP_RET_STATUS_T * result)
+{
+ DmSocketConnector * p = DmBrwCreateConnector();
+
+ if ( !p ) {
+ if ( result )
+ *result = XPL_HTTP_RET_FAIL;
+ return 0;
+ }
+
+ if ( p->Open(url, ConRef, addrType) != SYNCML_DM_SUCCESS ){
+ delete p;
+
+ if ( result )
+ *result = XPL_HTTP_RET_FAIL;
+
+ return 0;
+ }
+
+ if ( result )
+ *result = XPL_HTTP_RET_SUCCESS;
+
+ return (XPL_HTTP_HANDLE_T)p;
+}
+
+/* Sets method for URL request. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_SetRequestMethod(XPL_HTTP_HANDLE_T handler,
+ XPL_HTTP_METHOD_T method)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->SetRequestMethod(method) == SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+
+/* Sets a general request property.
+* This method is called before Send method */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_SetRequestProperty(XPL_HTTP_HANDLE_T handler,
+ CPCHAR buffer)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->SetRequestProperty(buffer) == SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Sends data to the resource pointed to by the URL.
+* Size specifies size of content to be sent. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_Send(XPL_HTTP_HANDLE_T handler,
+ CPCHAR buffer,
+ UINT32 size)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->Send(buffer, size) == SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Returns the response length */
+UINT32 XPL_HTTP_GetResponseLength(XPL_HTTP_HANDLE_T handler)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return 0;
+
+ return p->GetResponseLength();
+}
+
+/* Downloads the contents from the resource. The downloaded content is
+* stored in a buffer. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetResponse(XPL_HTTP_HANDLE_T handler,
+ char * buffer,
+ UINT32 size)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->GetResponse(buffer, size)== SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Method returns the value of the header for given header field. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetHeaderField(XPL_HTTP_HANDLE_T handler,
+ CPCHAR field,
+ char ** value)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->GetHeaderField(field, value)== SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Method returns the complete response header as sent by server. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetRespHeader(XPL_HTTP_HANDLE_T handler,
+ char ** header)
+{
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Method returns value of content-type in the response header. */
+XPL_HTTP_RET_STATUS_T
+XPL_HTTP_GetType(XPL_HTTP_HANDLE_T handler,
+ char ** content_type)
+{
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Gets status code from HTTP/WAP response message. Returns -1, if no code be
+* discerned from the response (i.e., the response is not valid HTTP/WAP) */
+XPL_HTTP_CODE_T XPL_HTTP_GetResponseCode(XPL_HTTP_HANDLE_T handler)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return 0;
+
+ return p->GetResponseCode();
+}
+
+/* Closes connection with server. */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_Close(XPL_HTTP_HANDLE_T handler)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ p->Close();
+ delete p;
+
+ return XPL_HTTP_RET_SUCCESS;
+}
+
+/* Closes request transaction without closing connection with server. */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_CloseReq(XPL_HTTP_HANDLE_T handler)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ p->CloseReq();
+
+ return XPL_HTTP_RET_SUCCESS;
+}
+
+/* Sets URL for new request */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_SetUrl(XPL_HTTP_HANDLE_T handler ,
+ CPCHAR url,
+ CPCHAR ConRef,
+ XPL_ADDR_TYPE_T addrType)
+{
+ DmSocketConnector * p = (DmSocketConnector*) handler;
+
+ if ( !p )
+ return XPL_HTTP_RET_BADARGUMENT;
+
+ if ( p->SetUrl(url, ConRef, addrType)== SYNCML_DM_SUCCESS )
+ return XPL_HTTP_RET_SUCCESS;
+
+ return XPL_HTTP_RET_FAIL;
+}
+
+
+/* Dowloads content from the resource. The read content is stored in the file */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DowloadByFile(XPL_HTTP_HANDLE_T handler,
+ CPCHAR file_name)
+{
+ return XPL_HTTP_RET_FAIL;
+}
+
+/* Dowloads content from the resource. The downloaded content is stored in a buffer */
+XPL_HTTP_RET_STATUS_T XPL_HTTP_DownloadByBuffer(XPL_HTTP_HANDLE_T handler,
+ UINT8 * buffer,
+ UINT32 size)
+{
+ return XPL_HTTP_RET_FAIL;
+}
+
+
+
diff --git a/engine/xpl/src/xpl_Lib.cc b/engine/xpl/src/xpl_Lib.cc
new file mode 100644
index 0000000..2d2a1b6
--- /dev/null
+++ b/engine/xpl/src/xpl_Lib.cc
@@ -0,0 +1,66 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include "xpl_Lib.h"
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static XPL_DL_HANDLE_T dllhandle_browser = NULL;
+static XPL_DL_HANDLE_T dllhandle_session = NULL;
+
+
+XPL_DL_HANDLE_T XPL_DL_Load(CPCHAR dllib_name)
+{
+ //!!! DP needs attention; ignore for now...
+ if ( 0 && !strcmp(dllib_name,"libdmssession.so") )
+ {
+ // load browser stack lib
+ dllhandle_browser = dlopen("libdmportlib.so", RTLD_NOW | RTLD_GLOBAL );
+ if ( dllhandle_browser )
+ dllhandle_session = dlopen("libdmssession.so", RTLD_NOW );
+ if ( dllhandle_session == NULL )
+ dlclose(dllhandle_browser);
+ else
+ return dllhandle_session;
+ }
+ else // plugins;
+ {
+ void * handle=dlopen(dllib_name, RTLD_LAZY );
+ return handle;
+ }
+
+}
+
+/* Gets function pointer */
+void * XPL_DL_GetFunction (XPL_DL_HANDLE_T lib_handle, CPCHAR name)
+{
+ void * pFunc=NULL;
+ pFunc=dlsym(lib_handle, name);
+ return pFunc;
+
+}
+
+/* Nnloads shared objects */
+void XPL_DL_Unload(XPL_DL_HANDLE_T lib_handle)
+{
+ if ( lib_handle == dllhandle_session && dllhandle_browser != NULL )
+ {
+ dlclose(dllhandle_browser);
+ dlclose(dllhandle_session);
+ dllhandle_browser = NULL;
+ dllhandle_session = NULL;
+ }
+ else
+ dlclose(lib_handle);
+ return;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/xpl/src/xpl_Logger.cc b/engine/xpl/src/xpl_Logger.cc
new file mode 100644
index 0000000..67caa75
--- /dev/null
+++ b/engine/xpl/src/xpl_Logger.cc
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <syslog.h>
+
+#include "xpl_Logger.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static int logIndex;
+static bool logOpened;
+
+static const char *const logName[] = {
+ "DM_API",
+ "DM_TMN",
+ "DM_PLG",
+ "DM_SESS",
+ "DM_CONN",
+ "DM_XPL",
+ "DM_CP"
+};
+
+static void _log(int level, CPCHAR format, va_list ap);
+
+
+
+void XPL_LOG_Startup()
+{
+}
+
+void XPL_LOG_Shutdown()
+{
+}
+
+void XPL_LOG_Debug(XPL_LOGS_PORT_T logPort,CPCHAR format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ _log(LOG_DEBUG, format, ap);
+ va_end(ap);
+}
+
+void XPL_LOG_Warn(XPL_LOGS_PORT_T logPort,CPCHAR format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ _log(LOG_WARNING, format, ap);
+ va_end(ap);
+}
+
+void XPL_LOG_Error(XPL_LOGS_PORT_T logPort,CPCHAR format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ _log(LOG_ERR, format, ap);
+ va_end(ap);
+}
+
+
+void XPL_LOG_Add(XPL_PORT_T logPort)
+{
+ logIndex = logPort;
+}
+
+void _log(int level, CPCHAR format, va_list ap) {
+ vprintf(format, ap);
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/xpl/src/xpl_Memory.cc b/engine/xpl/src/xpl_Memory.cc
new file mode 100644
index 0000000..c452cb4
--- /dev/null
+++ b/engine/xpl/src/xpl_Memory.cc
@@ -0,0 +1,31 @@
+#include <malloc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "xpl_Memory.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void * xplAllocMemEx(UINT32 bufsize, CPCHAR szFile, int nLine )
+{
+ char* ptr = (char*)malloc(bufsize);
+ if (ptr != 0) {
+ memset(ptr,0,bufsize);
+ }
+ return ptr;
+}
+
+void xplFreeMemEx(void *ptr, CPCHAR szFile, int nLine)
+{
+ if (ptr) {
+ free( ptr );
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/xpl/src/xpl_Regex.cc b/engine/xpl/src/xpl_Regex.cc
new file mode 100644
index 0000000..24a08b2
--- /dev/null
+++ b/engine/xpl/src/xpl_Regex.cc
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include "xpl_Regex.h"
+#include "dmStringUtil.h"
+
+#include "dmNewDataTypesValidation.h"
+#include "dmStringUtil.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//==============================================================================
+// FUNCTION: XPL_RG_Comp
+//
+// DESCRIPTION: Compare the Regular Expression
+//
+// ARGUMENTS PASSED:
+// INPUT : CPCHAR pattern Regular Expression Pattern
+// CPCHAR str Parameter's data
+//
+// RETURN VALUE: True or False
+//
+// IMPORTANT NOTES:
+//==============================================================================
+
+BOOLEAN XPL_RG_Comp(CPCHAR pattern, CPCHAR str)
+{
+ int i;
+ BOOLEAN result = FALSE;
+ DMString value( str );
+
+
+
+ if(strcmp(pattern, "[1-65535]") == 0)
+ {
+ i = atoi(str);
+ if( i < 1 || i > 65535)
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ else if( 0 == DmStrcmp( pattern, XPL_RG_PATTERN_IS_DATE ) )
+
+ {
+
+ result = ::is_date( value );
+
+ }
+
+ else if( 0 == DmStrcmp( pattern, XPL_RG_PATTERN_IS_TIME ) )
+
+ {
+
+ result = ::is_time( value );
+
+ }
+
+ else if( 0 == DmStrcmp( pattern, XPL_RG_PATTERN_IS_FLOAT ) )
+
+ {
+
+ result = ::is_float( value );
+
+ }
+
+
+
+ return result;
+
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/engine/xpl/src/xpl_Time.cc b/engine/xpl/src/xpl_Time.cc
new file mode 100644
index 0000000..6971665
--- /dev/null
+++ b/engine/xpl/src/xpl_Time.cc
@@ -0,0 +1,90 @@
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+#include "xpl_Time.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+XPL_CLK_CLOCK_T XPL_CLK_GetClock()
+{
+ return (XPL_CLK_CLOCK_T)time(NULL);
+}
+
+XPL_CLK_LONG_CLOCK_T XPL_CLK_GetClockMs()
+{
+ struct timeval tv1;
+ gettimeofday( &tv1, NULL );
+ return (XPL_CLK_LONG_CLOCK_T)(tv1.tv_usec + (tv1.tv_sec * 1000000 ));
+}
+
+
+XPL_CLK_RET_STATUS_T XPL_CLK_GetTime(XPL_CLK_TM_T *parsed_time)
+{
+ return XPL_CLK_RET_SUCCESS;
+}
+
+XPL_CLK_RET_STATUS_T XPL_CLK_UnpackTime(XPL_CLK_CLOCK_T clock, XPL_CLK_TM_T *parsed_clock)
+{
+ struct tm t;
+ time_t tt = clock;
+ if ( gmtime_r(&tt, &t) != NULL )
+ {
+ parsed_clock->tm_sec = t.tm_sec;
+ parsed_clock->tm_min = t.tm_min;
+ parsed_clock->tm_hour = t.tm_hour;
+ parsed_clock->tm_mday = t.tm_mday;
+ parsed_clock->tm_mon = t.tm_mon;
+ parsed_clock->tm_year = t.tm_year;
+ parsed_clock->tm_wday = t.tm_wday;
+ parsed_clock->tm_yday = t.tm_yday;
+ parsed_clock->tm_isdst = t.tm_isdst;
+ return XPL_CLK_RET_SUCCESS;
+ }
+ return XPL_CLK_RET_FAIL;
+
+}
+
+XPL_CLK_CLOCK_T XPL_CLK_PackTime(XPL_CLK_TM_T *parsed_clock)
+{
+
+ struct tm t;
+ memset(&t, 0, sizeof(struct tm));
+ t.tm_sec = parsed_clock->tm_sec;
+ t.tm_min = parsed_clock->tm_min;
+ t.tm_hour = parsed_clock->tm_hour;
+ t.tm_mday = parsed_clock->tm_mday;
+ t.tm_mon = parsed_clock->tm_mon;
+ t.tm_year = parsed_clock->tm_year;
+ t.tm_wday = parsed_clock->tm_wday;
+ t.tm_yday = parsed_clock->tm_yday;
+ t.tm_isdst = parsed_clock->tm_isdst;
+
+ return (XPL_CLK_CLOCK_T)mktime(&t);
+}
+
+INT32 XPL_CLK_GetTimeZone(void)
+{
+ //tzset();
+ //return (INT32)timezone;
+ return 0;
+}
+
+
+/* Starts timer */
+XPL_TIMER_HANDLE_T XPL_CLK_StartTimer(XPL_PORT_T port, UINT32 interval, XPL_CLK_TIMER_CBACK reply_timer)
+{
+ return XPL_CLK_HANDLE_INVALID;
+}
+
+/* Stops timer */
+XPL_CLK_RET_STATUS_T XPL_CLK_StopTimer(XPL_TIMER_HANDLE_T handle)
+{
+ return XPL_CLK_RET_SUCCESS;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/engine/xpl/src/xpl_dm_Manager.cc b/engine/xpl/src/xpl_dm_Manager.cc
new file mode 100644
index 0000000..a55d968
--- /dev/null
+++ b/engine/xpl/src/xpl_dm_Manager.cc
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include "dmprofile.h"
+#include "xpl_dm_Manager.h"
+#include "dm_uri_utils.h"
+#include "xpl_Logger.h"
+#include "dmtTreeImpl.hpp"
+
+#ifdef FEAT_DM_VERSION_FLEX
+#include "SETUP_GetFlex.h"
+#endif
+
+static DMString dm_version;
+static CPCHAR dm_poc_enabled = NULL;
+
+SYNCML_DM_RET_STATUS_T XPL_DM_Init()
+{
+ if( 0 == dm_version.length() )
+ {
+#ifdef FEAT_DM_VERSION_FLEX
+ CPCHAR ver = getenv("dm_setting_version");
+ if ( ver == NULL )
+ {
+ BOOLEAN bIsVersion12;
+ getFlexBit_setupflex(DL_DB_FEATURE_ID_DM_PROTOCOL_VERSION_12_AVAILABLE,&bIsVersion12);
+ if ( bIsVersion12 )
+ {
+ dm_version = SYNCML_REP_PROTOCOL_VERSION_1_2;
+ }
+ else
+ {
+ dm_version = "1.1.2";
+ }
+ }
+ else
+ {
+ dm_version = ver;
+ }
+#else
+ CPCHAR ver = getenv("dm_setting_version");
+ if ( ver == NULL )
+ {
+ dm_version = SYNCML_REP_PROTOCOL_VERSION_1_2;
+ }
+ else
+ {
+ dm_version = ver;
+ }
+#endif
+ }
+#ifdef FEAT_DM_VERSION_FLEX
+ if ( dm_poc_enabled == NULL )
+ {
+ BOOLEAN bIsEnabled = TRUE;
+ getFlexBit_setupflex(DL_DB_FEATURE_ID_POC_PROVISION_VIA_OMADM__AVAILABLE,&bIsEnabled);
+ dm_poc_enabled = (bIsEnabled)?"1":"0";
+ }
+#endif
+ return SYNCML_DM_SUCCESS;
+}
+
+SYNCML_DM_RET_STATUS_T XPL_DM_DeInit()
+{
+ dm_version = NULL;
+ return SYNCML_DM_SUCCESS;
+}
+
+
+BOOLEAN XPL_DM_IsFeatureEnabled(CPCHAR pUri)
+{
+ return TRUE;
+}
+
+
+static const char * session_lib = "libdmssession.so";
+//static const char * dm_android_setting_root = "/data/dm/dmt_data";
+static const char * dm_android_setting_root = "/data/data/com.android.omadm.service/files/dm/dmt_data";
+//static const char * dm_android_setting_plugin = "/data/dm/plugin";
+static const char * dm_android_setting_plugin = "/data/data/com.android.omadm.service/files/dm/plugin";
+
+CPCHAR XPL_DM_GetEnv(SYNCML_DM_ENVIRONMENT_T env_var)
+{
+
+
+ switch ( env_var )
+ {
+ case SYNCML_DM_SETTINGS_PATH :
+ if (getenv("dm_setting_root") == NULL) {
+ return dm_android_setting_root;
+ }
+ else {
+ return getenv("dm_setting_root");
+ }
+ case SYNCML_DM_PLUGINS_PATH :
+ if (getenv("dm_setting_plugin") == NULL) {
+ return dm_android_setting_plugin;
+ }
+ else {
+ return getenv("dm_setting_plugin");
+ }
+ case SYNCML_DM_SECURITY_LEVEL :
+ return getenv("DM_SRV_SEC_LEVEL");
+ case SYNCML_DM_ESCAPE_CHAR :
+ return getenv("DM_ESCAPE_CHAR");
+ case SYNCML_DM_MEMORY_AGING_INTERVAL :
+ return getenv("DM_AGING_CHECK_INTERVAL");
+ case SYNCML_DM_MEMORY_AGING_TIME :
+ return getenv("DM_AGING_TIME");
+ case SYNCML_DM_POWER_FAIL_IJECTION :
+ return getenv("power_fail");
+
+ case SYNCML_DM_DUMP_SESSION_PACKAGE_PATH :
+ return getenv("DUMP_SYNCML_PATH");
+
+ case SYNCML_DM_SESSION_LIB :
+ return session_lib;
+
+ case SYNCML_DM_VERSION:
+ return dm_version.GetBuffer();
+
+ case SYNCML_DM_DMACC_ROOT_PATH:
+ return ( dm_version == SYNCML_REP_PROTOCOL_VERSION_1_2 )
+ ? DM_DMACC_1_2_URI
+ : DM_DMACC_1_1_URI;
+
+ case SYNCML_DM_NODENAME_SERVERID:
+ return ( dm_version == SYNCML_REP_PROTOCOL_VERSION_1_2 )
+ ? DM_SERVERID_1_2
+ : DM_SERVERID_1_1;
+
+ case SYNCML_DM_SESSION_ID:
+ return "./DevDetail/Ext/Conf/PMF/Agents/syncmldm/Sessionid";
+
+ case SYNCML_DM_FEATURE_ID_POC_PROVISION_VIA_OMADM:
+ return dm_poc_enabled;
+
+ }
+
+ return NULL;
+
+}
+
+#define DM_CHUNK_BUFFER_LJ 8192
+
+/*==================================================================================================
+ FUNCTION : XPL_DM_GetChunkSize
+
+ DESCRIPTION : Get chunk buffer size for Linux-Java platform
+ ARGUMENT PASSED :
+
+ OUTPUT PARAMETER:
+ RETURN VALUE :
+ IMPORTANT NOTES :
+ ==================================================================================================*/
+UINT32 XPL_DM_GetChunkSize()
+{
+ return DM_CHUNK_BUFFER_LJ;
+}
diff --git a/engine/xpl/src/xpl_dm_Notifications.cc b/engine/xpl/src/xpl_dm_Notifications.cc
new file mode 100644
index 0000000..9aaf592
--- /dev/null
+++ b/engine/xpl/src/xpl_dm_Notifications.cc
@@ -0,0 +1,43 @@
+#include "xpl_dm_Notifications.h"
+#include "dmt.hpp"
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void XPL_DM_NotifyTreeUpdate(CPCHAR szTopic,
+ CPCHAR szPath,
+ SYNCML_DM_EVENT_TYPE_T nType,
+ UINT8 * pData,
+ UINT32 size)
+{
+ DmtEventMap aEventMap;
+ SYNCML_DM_RET_STATUS_T dm_stat;
+ dm_stat = DmtTreeFactory::ParseUpdateEvent(pData,size,aEventMap);
+ if ( dm_stat != SYNCML_DM_SUCCESS )
+ return;
+ for ( DmtEventMap::POS nPos = 0; nPos < aEventMap.end(); nPos++ )
+ {
+ const DMString & pParent = aEventMap.get_key(nPos);
+ printf( "OnTreeSaved, parent uri %s\n", pParent.c_str() );
+ }
+}
+
+void XPL_DM_NotifySessionProgress(BOOLEAN bIsStarted)
+{
+ if (bIsStarted)
+ printf("Server Session started\n");
+ else
+ printf("Server Session stopped\n");
+
+}
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/plugins/Android.mk b/plugins/Android.mk
new file mode 100644
index 0000000..c8e411c
--- /dev/null
+++ b/plugins/Android.mk
@@ -0,0 +1,10 @@
+# Copyright 2007-2008 The Android Open Source Project
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+# This finds and builds the test apk as well, so a single make does both.
+include $(CLEAR_VARS)
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/plugins/devplugin/Android.mk b/plugins/devplugin/Android.mk
new file mode 100644
index 0000000..53e4c04
--- /dev/null
+++ b/plugins/devplugin/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_JAVA_LIBRARIES := com.android.omadm.plugin telephony-common
+
+LOCAL_MODULE:= com.android.omadm.plugin.dev
+
+LOCAL_STATIC_JAVA_LIBRARIES := com.android.omadm.service.api
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/plugins/devplugin/com/android/omadm/plugin/dev/DevPlugin.java b/plugins/devplugin/com/android/omadm/plugin/dev/DevPlugin.java
new file mode 100644
index 0000000..79d9767
--- /dev/null
+++ b/plugins/devplugin/com/android/omadm/plugin/dev/DevPlugin.java
@@ -0,0 +1,472 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin.dev;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.RemoteException;
+import android.os.SystemProperties;
+import android.provider.Settings;
+import android.provider.Settings.SettingNotFoundException;
+import android.telephony.TelephonyManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.omadm.plugin.DmtBasePlugin;
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.DmtException;
+import com.android.omadm.plugin.DmtPluginNode;
+import com.android.omadm.plugin.ErrorCodes;
+import com.android.omadm.service.DMSettingsHelper;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+public class DevPlugin extends DmtBasePlugin {
+
+ static final String TAG = "DM_DevPlugin";
+
+ private String mRootPath;
+
+ private Context mContext;
+
+ public static final String DEV_DETAIL = "devdetail";
+
+ public static final String WIFI_MAC_ADDR = "wifimacaddr";
+
+ public static final String PRE_FW_VER = "prefwversion";
+
+ public static final String LAST_UPD_TIME = "lastupdatetime";
+
+// public static final Uri DMFLEXS_CONTENT_URI = Uri
+// .parse("content://com.android.omadm.service/flexs");
+
+ public DevPlugin(Context ctx) {
+ mContext = ctx;
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public boolean init(String rootPath, Map parameters) {
+ logd("Enter DevPlugin.init(\"" + rootPath + "\", " + parameters + "\")");
+ mRootPath = rootPath;
+ return true;
+ }
+
+ @Override
+ public DmtPluginNode getNode(String path) {
+ logd("getNode(\"" + path + "\")");
+ DmtPluginNode node = new DmtPluginNode("", new DmtData("abc"));
+ setOperationResult(node == null ?
+ ErrorCodes.SYNCML_DM_FAIL :
+ ErrorCodes.SYNCML_DM_SUCCESS);
+ return node;
+ }
+
+ @Override
+ public DmtData getNodeValue(String path) {
+ logd("getNodeValue: rootPath=" + mRootPath + " path=" + path);
+
+ //mContext.enforceCallingPermission("com.android.permission.READ_OMADM_SETTINGS", "Insufficient Permissions");
+ DmtData data = null;
+
+ if (path.equals("./DevDetail/SwV") || path.equals("./DevDetail/FwV")) {
+ String SwV;
+ try {
+ if (!isSprint() && path.equals("./DevDetail/SwV")) {
+ SwV = "Android " + SystemProperties.get("ro.build.version.release");
+ } else {
+ SwV = SystemProperties.get("ro.build.version.full");
+ if (null == SwV || SwV.equals("")) {
+ SwV = SystemProperties.get("ro.build.id", null) + "~"
+ + SystemProperties.get("ro.build.config.version", null) + "~"
+ + SystemProperties.get("gsm.version.baseband", null) + "~"
+ + SystemProperties.get("ro.gsm.flexversion", null);
+ }
+ }
+ } catch (RuntimeException e) {
+ SwV = "Unknown";
+ }
+ data = new DmtData(SwV);
+ } else if ("./DevDetail/HwV".equals(path)) {
+ String HwV;
+ try {
+ HwV = SystemProperties.get("ro.hardware", "Unknown")
+ + "." + SystemProperties.get("ro.revision", "Unknown");
+ } catch (RuntimeException e) {
+ HwV = "Unknown";
+ }
+ logd("get ./DevDetail/HwV = " + HwV);
+ data = new DmtData(HwV);
+ } else if ("./DevDetail/DevTyp".equals(path)) {
+ String DevTyp = getDeviceType();
+ logd("get ./DevDetail/DevTyp = " + DevTyp);
+ data = new DmtData(DevTyp);
+ } else if ("./DevInfo/DevId".equals(path)) {
+ TelephonyManager tm = (TelephonyManager) mContext
+ .getSystemService(Context.TELEPHONY_SERVICE);
+ String simOperator = tm.getSimOperator();
+ String imsi = tm.getSubscriberId();
+ logd("simOperator: " + simOperator + " IMSI: " + imsi);
+ /* Use MEID for sprint */
+ if ("310120".equals(simOperator) || (imsi != null && imsi.startsWith("310120"))) {
+ /* MEID is 14 digits. If IMEI is returned as DevId, MEID can be extracted by taking
+ * first 14 characters. This is not always true but should be the case for sprint */
+ String strDevId = tm.getDeviceId();
+ strDevId = strDevId.toUpperCase(Locale.US);
+ logd("DeviceId from telemgr: " + strDevId);
+ if (strDevId != null && strDevId.length() >= 14) {
+ strDevId = strDevId.substring(0, 14);
+ logd("MEID (from DeviceId): " + strDevId);
+ data = new DmtData("MEID:" + strDevId);
+ } else {
+ loge("MEID cannot be extracted from DeviceId " + strDevId);
+ }
+ } else {
+ String strDevId;
+ if (isPhoneTypeLTE()) {
+ strDevId = tm.getImei();
+ } else {
+ strDevId = tm.getDeviceId();
+ }
+ strDevId = strDevId.toUpperCase(Locale.US);
+ logd("DevId from telemgr: " + strDevId);
+
+ if (isPhoneTypeLTE()) {
+ data = new DmtData("IMEI:" + strDevId);
+ } else {
+ data = new DmtData("MEID:" + strDevId.substring(0, 14));
+ }
+ }
+ } else if (path.equals("./DevInfo/DmV")) {
+ data = new DmtData("1.2");
+ } else if (path.equals("./DevInfo/Lang")) {
+ String strLang = readValueFromFile("Lang");
+ logd("Language from shared file:" + strLang);
+ if (strLang == null) {
+ strLang = Locale.getDefault().toString();
+ logd("Language from system is:" + strLang);
+ }
+ data = new DmtData(strLang);
+ } else if (path.equals("./DevInfo/Man")) {
+ String strMan = readValueFromFile("Man");
+ logd("Manufacturer got from shared file:" + strMan);
+ if (strMan == null) {
+ strMan = SystemProperties.get("ro.product.manufacturer", "unknown");
+ logd("Manufacturer from system properties:" + strMan);
+ }
+ data = new DmtData(strMan.toLowerCase(Locale.US));
+ } else if (path.equals("./DevInfo/Mod")) {
+ String strMod = readValueFromFile("Mod");
+ logd("Mod got from shared file:" + strMod);
+ if (strMod == null) {
+ strMod = SystemProperties.get("ro.product.model", "generic");
+ logd("Mod got from system properties:" + strMod);
+ }
+ data = new DmtData(strMod);
+ } else if (path.equals("./DevDetail/Bearer/GSM")) {
+ data = new DmtData("GSM_1900");
+ } else if (path.equals("./DevDetail/Bearer/CDMA")) {
+ data = new DmtData("CDMA_2000");
+ } else if (path.equals("./DevDetail/Ext/SystemSettings/AllowUnknownSources")) {
+ if (!isThisForATT()) {
+ logd("Not Supported for non ATT carriers");
+ data = new DmtData("Not Supported");
+ } else {
+ boolean mUnknownSources = false;
+
+ try {
+ if (Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.INSTALL_NON_MARKET_APPS) > 0) {
+ logd("install from non-market -- allowed");
+ mUnknownSources = true;
+ data = new DmtData(mUnknownSources);
+ } else {
+ logd("install from non-market -- not allowed");
+ mUnknownSources = false;
+ data = new DmtData(mUnknownSources);
+ }
+ } catch (SettingNotFoundException e) {
+ loge("Exception while reading Settings.Global.INSTALL_NON_MARKET_APPS", e);
+ }
+ }
+ } else if (path.equals("./DevDetail/Ext/WLANMacAddr")) {
+ if (!isThisForATT()) {
+ logd("Not Supported for non ATT carriers");
+ data = new DmtData("Not Supported");
+ } else {
+ String wMac = "";
+ SharedPreferences p = mContext.getSharedPreferences(DEV_DETAIL, 0);
+
+ if (p.contains(WIFI_MAC_ADDR)) {
+ wMac = p.getString(DevPlugin.WIFI_MAC_ADDR, null);
+ logd("Read WiFi Mac address from shared file: " + wMac);
+ data = new DmtData(wMac);
+ } else {
+ WifiManager wm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
+ WifiInfo wi = wm.getConnectionInfo();
+ wMac = wi == null ? null : wi.getMacAddress();
+ logd("WiFi Mac address" + wMac);
+ if (!TextUtils.isEmpty(wMac)) {
+ SharedPreferences.Editor ed = p.edit();
+ ed.putString(DevPlugin.WIFI_MAC_ADDR, wMac);
+ ed.apply();
+
+ data = new DmtData(wMac);
+ } else {
+ data = new DmtData("Unavailable");
+ }
+ }
+ }
+ } else if (path.equals("./DevDetail/Ext/PreFwV")) {
+ if (!isThisForATT()) {
+ logd("Not Supported for non ATT carriers");
+ data = new DmtData("Not Supported");
+ } else {
+ String preFwV = "";
+ SharedPreferences p = mContext.getSharedPreferences(DEV_DETAIL, 0);
+
+ if (p.contains(PRE_FW_VER)) {
+ preFwV = p.getString(DevPlugin.PRE_FW_VER, null);
+ logd("Read Previous Firmware Version from shared file" + preFwV);
+ data = new DmtData(preFwV);
+ } else {
+ String SwV;
+ try {
+ SwV = SystemProperties.get("ro.build.version.full");
+ } catch (Exception e) {
+ SwV = "Unknown";
+ }
+ data = new DmtData(SwV);
+ }
+ }
+ } else if (path.equals("./DevDetail/Ext/LastUpdateTime")) {
+ if (!isThisForATT()) {
+ logd("Not Supported for non ATT carriers");
+ data = new DmtData("Not Supported");
+ } else {
+ String lastUpd = "";
+ SharedPreferences p = mContext.getSharedPreferences(DevPlugin.DEV_DETAIL, 0);
+
+ if (p.contains(LAST_UPD_TIME)) {
+ lastUpd = p.getString(DevPlugin.LAST_UPD_TIME, null);
+ logd("Read date stamp for the last update from shared file: " + lastUpd);
+ data = new DmtData(lastUpd);
+ } else {
+ data = new DmtData("No Known Update");
+ }
+ }
+ } else if (path.equals("./DevDetail/Ext/DateTime/Date")) {
+ if (!isPhoneTypeLTE()) {
+ logd("Not Supported for non VZW carriers");
+ data = new DmtData("Not Supported");
+ } else {
+ String updateDateTime = "";
+ SharedPreferences p = mContext.getSharedPreferences(DevPlugin.DEV_DETAIL, 0);
+
+ if (p.contains(LAST_UPD_TIME)) {
+ updateDateTime = p.getString(DevPlugin.LAST_UPD_TIME, null);
+ logd("Read date and time stamp for the last update from shared file: "
+ + updateDateTime);
+ String[] updateDate = updateDateTime.split("\\:");
+ try {
+ data = new DmtData(
+ updateDate[0] + ":" + updateDate[1] + ":" + updateDate[2]);
+ } catch (Exception e) {
+ data = new DmtData("No Known Update");
+ e.printStackTrace();
+ }
+ } else {
+ data = new DmtData("No Known Update");
+ }
+ }
+ } else if (path.equals("./DevDetail/Ext/DateTime/TimeUTC")) {
+ if (!isPhoneTypeLTE()) {
+ logd("Not Supported for non VZW carriers");
+ data = new DmtData("Not Supported");
+ } else {
+ String updateDateTime = "";
+ SharedPreferences p = mContext.getSharedPreferences(DevPlugin.DEV_DETAIL, 0);
+
+ if (p.contains(LAST_UPD_TIME)) {
+ updateDateTime = p.getString(DevPlugin.LAST_UPD_TIME, null);
+ logd("Read date and time stamp for the last update from shared file: "
+ + updateDateTime);
+ String[] updateTime = updateDateTime.split("\\:");
+ try {
+ data = new DmtData(updateTime[3] + ":" + updateTime[4]);
+ } catch (Exception e) {
+ data = new DmtData("No Known Update");
+ e.printStackTrace();
+ }
+ } else {
+ data = new DmtData("No Known Update");
+ }
+ }
+ } else if (path.equals("./DevDetail/Ext/DateTime/DLS")) {
+ setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ }
+
+ setOperationResult(data == null ?
+ ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION :
+ ErrorCodes.SYNCML_DM_SUCCESS);
+
+ return data;
+ }
+
+ @Override
+ public int updateLeafNode(String path, DmtData newValue) throws RemoteException {
+ logd("updateLeafNode: rootPath=" + mRootPath + " path=" + path + " newValue=" + newValue);
+ //mContext.enforceCallingPermission("com.android.permission.WRITE_OMADM_SETTINGS", "Insufficient Permissions");
+
+ if (path.equals("./DevDetail/Ext/SystemSettings/AllowUnknownSources")) {
+ if (!isThisForATT()) {
+ logd("Not Supported for non ATT carriers");
+ return setOperationResult(ErrorCodes.SYNCML_DM_UNSUPPORTED_OPERATION);
+ } else {
+ // enable/disable install from non market
+ try {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.INSTALL_NON_MARKET_APPS,
+ ((newValue.getBoolean()) ? 1 : 0));
+ if ((Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.INSTALL_NON_MARKET_APPS))
+ == (newValue.getBoolean() ? 1 : 0)) {
+ logd("Update to settings.db for install_non_market_apps -- success");
+ return setOperationResult(ErrorCodes.SYNCML_DM_SUCCESS);
+ } else {
+ logd("Update to settings.db for install_non_market_apps -- failed");
+ return setOperationResult(ErrorCodes.SYNCML_DM_FAIL);
+ }
+ } catch (DmtException e) {
+ loge("Exception during parsing the newValue.getBoolean()", e);
+ return setOperationResult(ErrorCodes.SYNCML_DM_FAIL);
+ } catch (SettingNotFoundException e) {
+ loge("Exception retrieving Settings.Global.INSTALL_NON_MARKET_APPS", e);
+ return setOperationResult(ErrorCodes.SYNCML_DM_FAIL);
+ }
+ }
+ } else {
+ return setOperationResult(ErrorCodes.SYNCML_DM_FAIL);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Map getNodes(String rootPath) {
+ logd("Enter DevPlugin.getNodes(\"" + rootPath + "\")");
+ Map<String, DmtPluginNode> hMap = new HashMap<String, DmtPluginNode>();
+ DmtPluginNode node1;
+ node1 = new DmtPluginNode("", new DmtData("abc"));
+ hMap.put("", node1);
+ logd("Leave DevPlugin::getNodes()");
+ return hMap;
+ }
+
+ public boolean release() {
+ return true;
+ }
+
+ private String readValueFromFile(String propName) {
+ String ret = null;
+ // use preference instead of the system property
+ SharedPreferences prefs = mContext.getSharedPreferences("dmconfig", 0);
+ if (prefs.contains(propName)) {
+ ret = prefs.getString(propName, "");
+ if (ret.length() == 0) {
+ ret = null;
+ }
+ }
+ return ret;
+ }
+
+ private boolean isThisForATT() {
+ boolean carrierATT = false;
+ Cursor cr = null;
+ try {
+ String DATABASE_NAME = "DmConfigure.db";
+ SQLiteDatabase mdb = mContext.openOrCreateDatabase(DATABASE_NAME, 0, null);
+ cr = mdb.query("dmFlexs", null, "name='CarrierName'", null, null, null, null);
+ String value = null;
+
+ if (cr != null) {
+ if (cr.moveToFirst() == true) {
+ int index = cr.getColumnIndex("value");
+ value = cr.getString(index);
+ logd("CarrierName = " + value);
+ }
+ if ("ATT".equals(value) || "Att".equals(value) || "att".equals(value)) {
+ carrierATT = true;
+ }
+ }
+
+ } catch (Exception e) {
+ loge("Not able to get CarrierName from database, return false", e);
+ } finally {
+ if (cr != null) {
+ cr.close();
+ }
+ }
+ return carrierATT;
+ }
+
+ private boolean isPhoneTypeLTE() {
+ return DMSettingsHelper.isPhoneTypeLTE();
+ }
+
+ private String getDeviceType() {
+ String devicetype = SystemProperties.get("ro.build.characteristics");
+ if (((!TextUtils.isEmpty(devicetype)) && (devicetype.equals("tablet")))) {
+ logd("Device Type is Tablet");
+ } else {
+ devicetype = "phone";
+ logd("Device Type is Phone");
+ }
+ return devicetype;
+ }
+
+ private static void logd(String s) {
+ Log.d(TAG, s);
+ }
+
+ private static void loge(String s) {
+ Log.e(TAG, s);
+ }
+
+ private static void loge(String s, Throwable tr) {
+ Log.e(TAG, s, tr);
+ }
+
+ private boolean isSprint() {
+ TelephonyManager tm = (TelephonyManager) mContext
+ .getSystemService(Context.TELEPHONY_SERVICE);
+ String simOperator = tm.getSimOperator();
+ String imsi = tm.getSubscriberId();
+ logd("simOperator: " + simOperator + " IMSI: " + imsi);
+ /* Use MEID for sprint */
+ if ("310120".equals(simOperator) || (imsi != null && imsi.startsWith("310120"))) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/plugins/devplugin/com/android/omadm/plugin/dev/DevService.java b/plugins/devplugin/com/android/omadm/plugin/dev/DevService.java
new file mode 100644
index 0000000..d25d6c2
--- /dev/null
+++ b/plugins/devplugin/com/android/omadm/plugin/dev/DevService.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin.dev;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.util.Log;
+
+import com.android.omadm.plugin.IDmtPlugin;
+
+public class DevService extends Service {
+ private static final String TAG = "DM_DevService";
+ private static final boolean DBG = true;
+
+ private IDmtPlugin.Stub mBinder;
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ String action = intent.getAction();
+ if (DevPlugin.class.getName().equals(action)) {
+ String rootPath = intent.getStringExtra("rootPath");
+ if (DBG) logd("rootPath: " + rootPath);
+ IDmtPlugin.Stub binder = mBinder;
+ if (binder == null) {
+ if (DBG) logd("mBinder is null, create it!");
+ binder = new DevPlugin(this);
+ mBinder = binder;
+ } else {
+ if (DBG) logd("mBinder already exists");
+ }
+ return binder;
+ }
+ if (DBG) logd("onBind(): unknown action: " + action + " for intent: " + intent);
+ return null;
+ }
+
+ @Override
+ public boolean onUnbind(Intent intent) {
+ super.onUnbind(intent);
+ if (DBG) logd("enter onUnbind()");
+ mBinder = null;
+ return true;
+ }
+
+ private static void logd(String msg) {
+ Log.d(TAG, msg);
+ }
+}
diff --git a/plugins/diagmon/Android.mk b/plugins/diagmon/Android.mk
new file mode 100644
index 0000000..568c24e
--- /dev/null
+++ b/plugins/diagmon/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_JAVA_LIBRARIES := com.android.omadm.plugin
+
+LOCAL_MODULE:= com.android.omadm.plugin.diagmon
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/plugins/diagmon/com/android/omadm/plugin/diagmon/DiagmonPlugin.java b/plugins/diagmon/com/android/omadm/plugin/diagmon/DiagmonPlugin.java
new file mode 100644
index 0000000..e57237e
--- /dev/null
+++ b/plugins/diagmon/com/android/omadm/plugin/diagmon/DiagmonPlugin.java
@@ -0,0 +1,296 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin.diagmon;
+
+import android.content.Context;
+import android.telephony.PhoneStateListener;
+import android.telephony.ServiceState;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+
+import com.android.omadm.plugin.DmtBasePlugin;
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.DmtPathUtils;
+import com.android.omadm.plugin.DmtPluginNode;
+import com.android.omadm.plugin.ErrorCodes;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+public class DiagmonPlugin extends DmtBasePlugin {
+ private static final String TAG = "DiagmonPlugin";
+ private static final boolean DBG = true;
+
+ private String mRootPath;
+
+ private Context mContext;
+
+ private Map<String, DmtData> nodeValues;
+
+ private boolean mHomeRoam = false;
+
+ private RFPhoneStateListener mRFPhoneStateListener;
+
+ public TelephonyManager mTelephonyManager;
+
+ public static final String DIAGMON_ROOT = DmtPathUtils.ROOTNODE;
+
+ public static final String DIAGMON_PATH = "./ManagedObjects/DiagMon";
+
+
+ public DiagmonPlugin(Context ctx) {
+ mContext = ctx;
+
+ mTelephonyManager = (TelephonyManager) mContext
+ .getSystemService(Context.TELEPHONY_SERVICE);
+ mRFPhoneStateListener = new RFPhoneStateListener();
+ mTelephonyManager.listen(mRFPhoneStateListener,
+ PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
+ mTelephonyManager.listen(mRFPhoneStateListener,
+ PhoneStateListener.LISTEN_SERVICE_STATE);
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean init(String rootPath, Map parameters) {
+ if (DiagmonPlugin.DBG) {
+ Log.i(TAG, "Enter DiagmonPlugin.init");
+ }
+ mRootPath = rootPath;
+ nodeValues = new HashMap<String, DmtData>();
+ String tmpPath = DIAGMON_ROOT;
+ DmtData tmpNodeData = new DmtData("RF", DmtData.NODE);
+ nodeValues.put(tmpPath, tmpNodeData);
+ tmpPath = "RF";
+ tmpNodeData = new DmtData("CurrentSystem|HomeRoam", DmtData.NODE);
+ nodeValues.put(tmpPath, tmpNodeData);
+ tmpPath = "RF/CurrentSystem";
+ tmpNodeData = new DmtData("Data|Voice", DmtData.NODE);
+ nodeValues.put(tmpPath, tmpNodeData);
+ tmpPath = "RF/CurrentSystem/Data";
+ tmpNodeData = new DmtData(null, DmtData.STRING);
+ nodeValues.put(tmpPath, tmpNodeData);
+ tmpPath = "RF/CurrentSystem/Voice";
+ tmpNodeData = new DmtData(null, DmtData.STRING);
+ nodeValues.put(tmpPath, tmpNodeData);
+ tmpPath = "RF/HomeRoam";
+ tmpNodeData = new DmtData(null, DmtData.STRING);
+ nodeValues.put(tmpPath, tmpNodeData);
+
+ return true;
+ }
+
+ //@Override
+ public DmtPluginNode getNode(String path) {
+ DmtPluginNode node = new DmtPluginNode("", new DmtData("abc"));
+ setOperationResult(ErrorCodes.SYNCML_DM_SUCCESS);
+ return node;
+ }
+
+ //@Override
+ public DmtData getNodeValue(String path) {
+ if (DiagmonPlugin.DBG) {
+ Log.i(TAG, "rootPath=" + mRootPath);
+ }
+ if (DiagmonPlugin.DBG) {
+ Log.i(TAG, "path=" + path);
+ }
+ //mContext.enforceCallingPermission("com.android.permission.READ_OMADM_SETTINGS", "Insufficient Permissions");
+
+ DmtData data = null;
+
+ if (path.equals("./ManagedObjects/DiagMon/RF/CurrentSystem/Data")) {
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Get on CurrentSystem Value");
+ }
+ String mCurrentSystem;
+ try {
+ mCurrentSystem = getCurrentSystem();
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Current System Value: " + mCurrentSystem);
+ }
+ } catch (Exception e) {
+ mCurrentSystem = "Unknown";
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Get on Current System Value failed");
+ }
+ e.printStackTrace();
+ }
+ data = new DmtData(mCurrentSystem);
+ setOperationResult(ErrorCodes.SYNCML_DM_SUCCESS);
+ } else if (path.equals("./ManagedObjects/DiagMon/RF/CurrentSystem/Voice")) {
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Get on CurrentSystem Voice Value");
+ }
+ String mCurrentSystemVoice;
+ if (isVoiceCapable(mContext)) {
+ mCurrentSystemVoice = "1xRTT"; //As per VZW (36953) requirement value is 1xRTT
+ } else {
+ mCurrentSystemVoice = "Voice not available";
+ }
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Current System Voice Value: " + mCurrentSystemVoice);
+ }
+ data = new DmtData(mCurrentSystemVoice);
+ setOperationResult(ErrorCodes.SYNCML_DM_SUCCESS);
+ } else if (path.equals("./ManagedObjects/DiagMon/RF/HomeRoam")) {
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Get on HomeRoam Value");
+ }
+ String sHomeRoam;
+ try {
+ sHomeRoam = getHomeRoam();
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "HomeRoam Value: " + sHomeRoam);
+ }
+ } catch (Exception e) {
+ sHomeRoam = "Unknown";
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Get on HomeRoam Value failed");
+ }
+ e.printStackTrace();
+ }
+ data = new DmtData(sHomeRoam);
+ setOperationResult(ErrorCodes.SYNCML_DM_SUCCESS);
+ } else {
+ setOperationResult(ErrorCodes.SYNCML_DM_FAIL);
+ }
+
+ return data;
+ }
+
+ @SuppressWarnings("unchecked")
+ //@Override
+ public Map getNodes(String rootPath) {
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Enter DiagmonPlugin::getNodes()");
+ }
+ Map<String, DmtPluginNode> hMap = new HashMap<String, DmtPluginNode>();
+ DmtPluginNode node;
+
+ Map<String, DmtData> nodes = getNodeMap(DmtPathUtils.toRelativePath(DIAGMON_PATH,
+ mRootPath));
+
+ for (String diagPath : nodes.keySet()) {
+ DmtData data = nodes.get(diagPath);
+ if (diagPath.equals(DIAGMON_ROOT)) {
+ diagPath = "";
+ }
+ if (DiagmonPlugin.DBG) {
+ Log.i(TAG, "put node = '" + diagPath + "'");
+ }
+ node = new DmtPluginNode(diagPath, data);
+ hMap.put(diagPath, node);
+ }
+
+ if (DiagmonPlugin.DBG) {
+ Log.i(TAG, "created the nodes.");
+ }
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Leave DiagmonPlugin::getNodes()");
+ }
+ return hMap;
+ }
+
+ public Map<String, DmtData> getNodeMap(String rootPath) {
+
+ Map<String, DmtData> nodeMap = new HashMap<String, DmtData>();
+ if (rootPath.equals(DIAGMON_ROOT)) {
+ nodeMap.putAll(nodeValues);
+ } else {
+ for (String key : nodeValues.keySet()) {
+ if (key.startsWith(rootPath)) {
+ if ((key.substring(rootPath.length(), (rootPath.length() + 1))).equals("/")) {
+ nodeMap.put(key, nodeValues.get(key));
+ }
+ }
+ }
+ }
+ return nodeMap;
+ }
+
+ public boolean release() {
+ mTelephonyManager.listen(mRFPhoneStateListener, PhoneStateListener.LISTEN_NONE);
+ return true;
+ }
+
+ private final class RFPhoneStateListener extends PhoneStateListener {
+
+ @Override
+ public void onServiceStateChanged(ServiceState serviceState) {
+ mHomeRoam = serviceState.getRoaming();
+ if (DiagmonPlugin.DBG) {
+ Log.v(TAG, "Service State intent received: " + mHomeRoam);
+ }
+ }
+ }
+
+ private String getCurrentSystem() {
+ int mNetworkType = mTelephonyManager.getNetworkType();
+ if (DiagmonPlugin.DBG) {
+ Log.d(TAG, "Network Type value : " + mNetworkType);
+ }
+ if (mNetworkType == TelephonyManager.NETWORK_TYPE_UNKNOWN) {
+ return ("Unknown");
+ } else if (mNetworkType == TelephonyManager.NETWORK_TYPE_1xRTT) {
+ return ("1xRTT");
+ } else if (mNetworkType == TelephonyManager.NETWORK_TYPE_EVDO_0
+ || mNetworkType == TelephonyManager.NETWORK_TYPE_EVDO_A) {
+ return ("EVDO");
+ } else if (mNetworkType == TelephonyManager.NETWORK_TYPE_LTE) {
+ return ("LTE");
+ } else if (mNetworkType == TelephonyManager.NETWORK_TYPE_EHRPD) {
+ return ("eHRPD");
+ } else {
+ return ("Unknown");
+ }
+ }
+
+ private String getHomeRoam() {
+ if (mHomeRoam) {
+ return ("Roam");
+ } else {
+ return ("Home");
+ }
+ }
+
+ private static boolean isVoiceCapable(Context context) {
+ TelephonyManager telephonyManager =
+ (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+ if (telephonyManager == null) {
+ return false;
+ }
+ try {
+ Class partypes[] = new Class[0];
+ Method sIsVoiceCapable = TelephonyManager.class.getMethod("isVoiceCapable", partypes);
+ Object arglist[] = new Object[0];
+ Object retobj = sIsVoiceCapable.invoke(telephonyManager, arglist);
+ return (Boolean) retobj;
+ } catch (java.lang.reflect.InvocationTargetException e) {
+ // Failure, must be another device.
+ // Assume that it is voice capable.
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // Failure, must be an other device.
+ // Assume that it is voice capable.
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+}
diff --git a/plugins/diagmon/com/android/omadm/plugin/diagmon/DiagmonService.java b/plugins/diagmon/com/android/omadm/plugin/diagmon/DiagmonService.java
new file mode 100644
index 0000000..ac3fa06
--- /dev/null
+++ b/plugins/diagmon/com/android/omadm/plugin/diagmon/DiagmonService.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.plugin.diagmon;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.util.Log;
+
+import com.android.omadm.plugin.IDmtPlugin;
+
+public class DiagmonService extends Service {
+ private static final String TAG = "DiagmonService";
+
+ private IDmtPlugin.Stub mBinder;
+
+ @Override
+ public IBinder onBind(Intent intent) {
+
+ if (DiagmonPlugin.class.getName().equals(intent.getAction()))
+ {
+ String rootPath = intent.getStringExtra("rootPath");
+ Log.d(TAG, "rootPath =" + rootPath);
+ if (mBinder == null)
+ {
+ Log.d(TAG, "mBinder is null, create it!");
+ mBinder = new DiagmonPlugin(this);
+ }else
+ {
+ Log.d(TAG, "mBinder already exists!");
+ }
+ return mBinder;
+ }
+ Log.d(TAG, "Invalid action name, return null!");
+ return null;
+ }
+
+ @Override
+ public boolean onUnbind(Intent intent)
+ {
+ super.onUnbind(intent);
+ Log.d(TAG, "Enter onUnbind");
+ mBinder = null;
+ return true;
+ }
+}
diff --git a/plugins/pluginhelper/Android.mk b/plugins/pluginhelper/Android.mk
new file mode 100644
index 0000000..966fe6b
--- /dev/null
+++ b/plugins/pluginhelper/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_JAVA_LIBRARIES := \
+ com.android.omadm.plugin \
+ com.android.omadm.service.api
+
+LOCAL_MODULE := com.android.omadm.pluginhelper
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
diff --git a/plugins/pluginhelper/com/android/omadm/pluginhelper/DmtMoBuilder.java b/plugins/pluginhelper/com/android/omadm/pluginhelper/DmtMoBuilder.java
new file mode 100644
index 0000000..bda59b8
--- /dev/null
+++ b/plugins/pluginhelper/com/android/omadm/pluginhelper/DmtMoBuilder.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.pluginhelper;
+
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.DmtException;
+import com.android.omadm.plugin.DmtPathUtils;
+import com.android.omadm.plugin.DmtPluginNode;
+import com.android.omadm.plugin.ErrorCodes;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DmtMoBuilder {
+ protected static final String TAG = DmtPluginFacade.TAG;
+
+ protected String mPath;
+
+ protected Map<String, DmtPluginNode> mNodes = new HashMap<String, DmtPluginNode>();
+
+ public DmtMoBuilder(String path, Map<String, DmtPluginNode> nodes) {
+ Log.d(TAG, "--ENTER-- DmtMoBuilder constructor()");
+ mPath = path;
+ mNodes = nodes;
+
+ }
+
+ /**
+ * Checks if a node by given path exists in the subtree.
+ *
+ * @param nodePath path to the node.
+ * @return true if the node is exist otherwise false.
+ */
+ public boolean isNodeExist(String nodePath) {
+ Log.d(TAG, "--ENTER-- DmtMoBuilder.isNodeExist()");
+ return (mNodes.get(nodePath) != null);
+ }
+
+ /**
+ * Creates new leaf node in the subtree. The parent node is updated automatically.
+ *
+ * @param nodePath path to the new node.
+ * @param nodeValue new node value.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} in success case otherwise an error.
+ */
+ public int createLeafNode(String nodePath, DmtData nodeValue) {
+
+ if (nodeValue == null) {
+ return ErrorCodes.SYNCML_DM_INVALID_PARAMETER;
+ }
+
+ Log.d(TAG, "--ENTER-- DmtMoBuilder.createLeafNode(" + nodePath + "," + nodeValue.getString() + ")");
+
+ String[] data = DmtPathUtils.splitPath(nodePath);
+
+ String rootNodePath = data[0];
+ String nodeName = data[1];
+
+ if (TextUtils.isEmpty(rootNodePath) || TextUtils.isEmpty(nodeName)) {
+ return ErrorCodes.SYNCML_DM_INVALID_URI;
+ }
+
+ if (isNodeExist(nodePath)) {
+ return updateLeafNode(nodePath, nodeValue);
+ }
+
+ int retcode = createInteriorNode(rootNodePath);
+ if (retcode != ErrorCodes.SYNCML_DM_SUCCESS) {
+ return retcode;
+ }
+
+ retcode = addNameToInteriorNode(rootNodePath, nodeName);
+ if (retcode != ErrorCodes.SYNCML_DM_SUCCESS) {
+ return retcode;
+ }
+
+ mNodes.put(nodePath, new DmtPluginNode(nodePath, nodeValue));
+
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Utility wrapper to create DmtData, before calling createLeafNode().
+ *
+ * @param nodePath path to the new node.
+ * @param nodeValue new node value.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success; otherwise, an error code.
+ */
+ public int createLeafNode(String nodePath, boolean nodeValue) {
+ Log.d(TAG, String.format("DmtMoBuilder.createLeafNode(%s, %b)", nodePath, nodeValue));
+ return createLeafNode(nodePath, new DmtData(nodeValue));
+ }
+
+ /**
+ * Utility wrapper to create DmtData, before calling createLeafNode().
+ *
+ * @param nodePath path to the new node.
+ * @param nodeValue new node value.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success; otherwise, an error code.
+ */
+ public int createLeafNode(String nodePath, int nodeValue) {
+ Log.d(TAG, String.format("DmtMoBuilder.createLeafNode(%s, %d)", nodePath, nodeValue));
+ return createLeafNode(nodePath, new DmtData(nodeValue));
+ }
+
+ /**
+ * Utility wrapper to create DmtData, before calling createLeafNode().
+ *
+ * @param nodePath path to the new node.
+ * @param nodeValue new node value.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success; otherwise, an error code.
+ */
+ public int createLeafNode(String nodePath, String nodeValue) {
+ Log.d(TAG, String.format("DmtMoBuilder.createLeafNode(%s, %s)", nodePath, nodeValue));
+ return createLeafNode(nodePath, new DmtData(nodeValue));
+ }
+
+ /**
+ * Creates a new interior node in the subtree. The parent node is updated automatically.
+ *
+ * @param nodePath path to the new node.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success; otherwise, an error code.
+ */
+ public int createInteriorNode(String nodePath) {
+ Log.d(TAG, "--ENTER-- DmtMoBuilder.createInteriorNode(" + nodePath + ")");
+ String[] data = DmtPathUtils.splitPath(nodePath);
+
+ String rootNodePath = data[0];
+ String nodeName = data[1];
+
+ if (TextUtils.isEmpty(rootNodePath) || TextUtils.isEmpty(nodeName)) {
+ return ErrorCodes.SYNCML_DM_INVALID_URI;
+ }
+
+ if (!DmtPathUtils.isSubPath(mPath, nodePath)) {
+ return ErrorCodes.SYNCML_DM_INVALID_URI;
+ }
+
+ /* Check that exist node is an interior node and engine tries to set interior node too */
+ DmtPluginNode node = mNodes.get(nodePath);
+ if (node != null) {
+ return node.isLeaf() ? ErrorCodes.SYNCML_DM_ENTRY_EXIST : ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+ int retcode = createInteriorNode(rootNodePath);
+ if (retcode != ErrorCodes.SYNCML_DM_SUCCESS) {
+ return retcode;
+ }
+
+ retcode = addNameToInteriorNode(rootNodePath, nodeName);
+ if (retcode != ErrorCodes.SYNCML_DM_SUCCESS) {
+ return retcode;
+ }
+
+ mNodes.put(nodePath, new DmtPluginNode(nodePath, new DmtData(null, DmtData.NODE)));
+
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+
+ public int addNameToInteriorNode(String rootNodePath, String nodeName) {
+ Log.d(TAG, "--ENTER-- DmtMoBuilder.addNameToInteriorNode()");
+ DmtPluginNode rootNode = mNodes.get(rootNodePath);
+
+ if (rootNode == null || rootNode.isLeaf()) {
+ return ErrorCodes.SYNCML_DM_INVALID_URI;
+ }
+
+ try {
+ rootNode.getValue().addChildNode(nodeName, new DmtData());
+ } catch (DmtException e) {
+ return e.getCode();
+ }
+
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+
+ /**
+ * Updates a leaf node value.
+ *
+ * @param nodePath full path to the node.
+ * @param nodeValue new node value.
+ * @return {@link ErrorCodes#SYNCML_DM_SUCCESS} on success; otherwise, an error code.
+ */
+ public int updateLeafNode(String nodePath, DmtData nodeValue) {
+ Log.d(TAG, "--ENTER-- DmtMoBuilder.updateLeafNode()");
+ if (nodeValue == null) {
+ return ErrorCodes.SYNCML_DM_INVALID_PARAMETER;
+ }
+
+ DmtPluginNode node = mNodes.get(nodePath);
+ if (node == null) {
+ return ErrorCodes.SYNCML_DM_ENTRY_NOT_FOUND;
+ }
+
+ if (node.getType() == DmtData.NODE || nodeValue.getType() == DmtData.NODE) {
+ return ErrorCodes.SYNCML_DM_COMMAND_NOT_ALLOWED;
+ }
+
+ node.setValue(nodeValue);
+
+ return ErrorCodes.SYNCML_DM_SUCCESS;
+ }
+} \ No newline at end of file
diff --git a/plugins/pluginhelper/com/android/omadm/pluginhelper/DmtPluginFacade.java b/plugins/pluginhelper/com/android/omadm/pluginhelper/DmtPluginFacade.java
new file mode 100644
index 0000000..b0030a2
--- /dev/null
+++ b/plugins/pluginhelper/com/android/omadm/pluginhelper/DmtPluginFacade.java
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.pluginhelper;
+
+import android.util.Log;
+
+import com.android.omadm.plugin.DmtBasePlugin;
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.DmtException;
+import com.android.omadm.plugin.DmtManagementObject;
+import com.android.omadm.plugin.DmtPluginNode;
+
+import java.util.Map;
+
+public class DmtPluginFacade extends DmtBasePlugin {
+
+ protected static final String TAG = "DmtPluginFacade";
+
+ static class GenericDmtManagementObject extends DmtManagementObject {
+
+ /**
+ * @param path path to the base of the management object
+ */
+ GenericDmtManagementObject(String path) throws DmtException {
+ super(path, null);
+ }
+
+ public Map<String, DmtPluginNode> getData() {
+ return mNodes;
+ }
+
+ @Override
+ protected String resolve(String tag, boolean getSemantics) throws DmtException {
+ if (tag != null) {
+ return tag;
+ }
+ throw new DmtException("Invalid tag was provided");
+ }
+ }
+
+ private GenericDmtManagementObject mManagementObject;
+
+ private IDmtPluginAdaptor mAdaptor = null;
+
+ /**
+ * Plug-in facade constructor.
+ *
+ * @param adaptor the plugin adaptor object
+ */
+ public DmtPluginFacade(IDmtPluginAdaptor adaptor) {
+ Log.d(TAG, "DmtPluginFacade.ctor()");
+ mAdaptor = adaptor;
+ try {
+ mManagementObject = new GenericDmtManagementObject(adaptor.getPath());
+ } catch (DmtException e) {
+ Log.e(TAG, "DmtPluginFacade.ctor() - EXCEPTION: " + e.getMessage());
+ setOperationResult(e.getCode());
+ }
+ Log.d(TAG, "DmtPluginFacade.ctor() " + mAdaptor.toString());
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean init(String rootPath, Map parameters) {
+ Log.d(TAG, String.format("DmtPluginFacade.init(%s, ...) - enter", rootPath));
+ for (Object key : parameters.keySet()) {
+ Log.d(TAG, String.format("parameters(%s) = %s", key.toString(),
+ parameters.get(key).toString()));
+ }
+ boolean status;
+ try {
+ Map<String, DmtPluginNode> nodes = mManagementObject.getData();
+ Log.d(TAG, "DmtPluginFacade.init() - before load nodes.size() = " + nodes.size());
+ mAdaptor.load(nodes);
+ status = true;
+ Log.d(TAG, "DmtPluginFacade.init() - after load nodes.size() = " + nodes.size());
+ } catch (Exception e) {
+ Log.e(TAG, "DmtPluginFacade.init(): EXCEPTION = " + e.getMessage());
+ status = false;
+ }
+ Log.d(TAG, "DmtPluginFacade.init() - return " + status);
+ return status;
+ }
+
+ public boolean release() {
+ Log.d(TAG, "DmtPluginFacade.release() - enter");
+ mAdaptor.release();
+ return true;
+ }
+
+ public int createInteriorNode(String path) {
+ int status;
+ Log.d(TAG, "DmtPluginFacade.createInteriorNode() - enter");
+ status = setOperationResult(mManagementObject.createInteriorNode(path));
+ Log.d(TAG, "DmtPluginFacade.createInteriorNode() - return " + status);
+ return status;
+ }
+
+ public int createLeafNode(String path, DmtData value) {
+ Log.d(TAG, String.format("DmtPluginFacade.createLeafNode(%s)", path));
+ int status;
+ status = setOperationResult(mManagementObject.createLeafNode(path, value));
+ return status;
+ }
+
+ public int updateLeafNode(String path, DmtData newValue) {
+ Log.d(TAG, String.format("DmtPluginFacade.updateLeafNode(%s)", path));
+ int status;
+ status = setOperationResult(mManagementObject.updateLeafNode(path, newValue));
+ return status;
+ }
+
+ public int renameNode(String path, String newName) {
+ Log.d(TAG, String.format("DmtPluginFacade.renameNode(%s, %s)", path, newName));
+ int status;
+ status = setOperationResult(mManagementObject.renameNode(path, newName));
+ return status;
+ }
+
+ public int deleteNode(String path) {
+ Log.d(TAG, String.format("DmtPluginFacade.deleteNode(%s)", path));
+ int status;
+ status = setOperationResult(mManagementObject.deleteNode(path));
+ return status;
+ }
+
+ public DmtPluginNode getNode(String path) {
+ Log.d(TAG, String.format("DmtPluginFacade.getNode(%s)", path));
+ DmtPluginNode node = null;
+ try {
+ node = mManagementObject.getNode(path);
+ } catch (DmtException de) {
+ Log.e(TAG, "DmtPluginNode.getNode(): " + path + " e = " + de);
+ setOperationResult(de.getCode());
+ }
+ return node;
+ }
+
+ public Map<String, DmtPluginNode> getNodes(String path) {
+ Log.d(TAG, String.format("DmtPluginFacade.getNodes(%s)", path));
+ Map<String, DmtPluginNode> nodes;
+ try {
+ nodes = mManagementObject.getNodes(path);
+ } catch (DmtException de) {
+ Log.e(TAG, "DmtPluginNode.getNodes(): " + path + " e = " + de);
+ setOperationResult(de.getCode());
+ nodes = null;
+ }
+ return nodes;
+ }
+
+ public DmtData getNodeValue(String path) {
+ Log.d(TAG, String.format("DmtPluginFacade.getNodeValue(%s)", path));
+ DmtData datum = null;
+ try {
+ datum = mManagementObject.getNodeValue(path);
+ } catch (DmtException de) {
+ Log.e(TAG, "getNodeValue(): " + path + " e = " + de);
+ setOperationResult(de.getCode());
+ }
+ return datum;
+ }
+
+ public int commit() {
+ Log.d(TAG, String.format("DmtPluginFacade.commit()"));
+ if (getOperationResult() == 0) {
+ int status;
+ status = setOperationResult(mAdaptor.commit(mManagementObject.getData()));
+ return status;
+ } else {
+ return getOperationResult();
+ }
+ }
+}
diff --git a/plugins/pluginhelper/com/android/omadm/pluginhelper/IDmtPluginAdaptor.java b/plugins/pluginhelper/com/android/omadm/pluginhelper/IDmtPluginAdaptor.java
new file mode 100644
index 0000000..3240b27
--- /dev/null
+++ b/plugins/pluginhelper/com/android/omadm/pluginhelper/IDmtPluginAdaptor.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.omadm.pluginhelper;
+
+import com.android.omadm.plugin.DmtPluginNode;
+
+import java.util.Map;
+
+/**
+ * FIXME: Is this used by JNI or something?
+ */
+public interface IDmtPluginAdaptor {
+
+ /**
+ * Get the root path for the adaptor.
+ */
+ String getPath();
+
+ void load(Map<String, DmtPluginNode> data) throws Exception;
+
+ int commit(Map<String, DmtPluginNode> data);
+
+ void release();
+}
diff --git a/plugins/testplugin/Android.mk b/plugins/testplugin/Android.mk
new file mode 100644
index 0000000..f0d7270
--- /dev/null
+++ b/plugins/testplugin/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_STATIC_JAVA_LIBRARIES := com.android.omadm.plugin com.android.omadm.service.api
+
+LOCAL_PACKAGE_NAME := DMTestPlugin
+LOCAL_CERTIFICATE := platform
+
+include $(BUILD_PACKAGE)
diff --git a/plugins/testplugin/AndroidManifest.xml b/plugins/testplugin/AndroidManifest.xml
new file mode 100644
index 0000000..bc64c6b
--- /dev/null
+++ b/plugins/testplugin/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.example.testplugin"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="19"
+ android:targetSdkVersion="19"/>
+
+ <uses-permission android:name="com.android.permission.INJECT_OMADM_SETTINGS"/>
+ <uses-permission android:name="com.android.permission.WRITE_OMADM_SETTINGS"/>
+
+ <application
+ android:label="@string/app_name"
+ android:allowBackup="false">
+
+ <!-- Main launcher activity for test menu. -->
+ <activity
+ android:name=".DMTestPluginActivity"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity
+ android:name=".GetDMTreeActivity"
+ android:exported="false"/>
+
+ <activity
+ android:name=".InjectSoapPackageActivity"
+ android:exported="false"/>
+
+ <activity
+ android:name=".StartClientSessionActivity"
+ android:exported="false"/>
+
+ </application>
+
+</manifest>
diff --git a/plugins/testplugin/res/layout/get_dm_tree_activity.xml b/plugins/testplugin/res/layout/get_dm_tree_activity.xml
new file mode 100644
index 0000000..049af6b
--- /dev/null
+++ b/plugins/testplugin/res/layout/get_dm_tree_activity.xml
@@ -0,0 +1,15 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin">
+
+ <TextView
+ android:text="@string/get_dm_tree_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+</RelativeLayout>
diff --git a/plugins/testplugin/res/layout/inject_soap_package_activity.xml b/plugins/testplugin/res/layout/inject_soap_package_activity.xml
new file mode 100644
index 0000000..a224f39
--- /dev/null
+++ b/plugins/testplugin/res/layout/inject_soap_package_activity.xml
@@ -0,0 +1,15 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin">
+
+ <TextView
+ android:text="@string/inject_soap_package_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+</RelativeLayout>
diff --git a/plugins/testplugin/res/layout/start_client_session_activity.xml b/plugins/testplugin/res/layout/start_client_session_activity.xml
new file mode 100644
index 0000000..e1c1944
--- /dev/null
+++ b/plugins/testplugin/res/layout/start_client_session_activity.xml
@@ -0,0 +1,15 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin">
+
+ <TextView
+ android:text="@string/start_client_session_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+</RelativeLayout>
diff --git a/plugins/testplugin/res/values/dimens.xml b/plugins/testplugin/res/values/dimens.xml
new file mode 100644
index 0000000..a0171a7
--- /dev/null
+++ b/plugins/testplugin/res/values/dimens.xml
@@ -0,0 +1,6 @@
+<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+
+ </resources>
diff --git a/plugins/testplugin/res/values/strings.xml b/plugins/testplugin/res/values/strings.xml
new file mode 100644
index 0000000..95b896a
--- /dev/null
+++ b/plugins/testplugin/res/values/strings.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">DMTestPlugin</string>
+
+ <string name="get_dm_tree_label">Get DM Tree</string>
+ <string name="inject_soap_package_label">Inject test SOAP package</string>
+ <string name="start_client_session_label">Start client session</string>
+</resources>
diff --git a/plugins/testplugin/res/xml/test_menu_settings.xml b/plugins/testplugin/res/xml/test_menu_settings.xml
new file mode 100644
index 0000000..a3b07cb
--- /dev/null
+++ b/plugins/testplugin/res/xml/test_menu_settings.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/app_name" >
+
+ <PreferenceScreen
+ android:title="@string/get_dm_tree_label">
+ <intent android:action="android.intent.action.MAIN"
+ android:targetPackage="com.android.example.testplugin"
+ android:targetClass="com.android.example.testplugin.GetDMTreeActivity" />
+ </PreferenceScreen>
+
+ <PreferenceScreen
+ android:title="@string/inject_soap_package_label">
+ <intent android:action="android.intent.action.MAIN"
+ android:targetPackage="com.android.example.testplugin"
+ android:targetClass="com.android.example.testplugin.InjectSoapPackageActivity" />
+ </PreferenceScreen>
+
+ <PreferenceScreen
+ android:title="@string/start_client_session_label">
+ <intent android:action="android.intent.action.MAIN"
+ android:targetPackage="com.android.example.testplugin"
+ android:targetClass="com.android.example.testplugin.StartClientSessionActivity" />
+ </PreferenceScreen>
+
+</PreferenceScreen>
diff --git a/plugins/testplugin/src/com/android/example/testplugin/DMTestPluginActivity.java b/plugins/testplugin/src/com/android/example/testplugin/DMTestPluginActivity.java
new file mode 100644
index 0000000..71d6479
--- /dev/null
+++ b/plugins/testplugin/src/com/android/example/testplugin/DMTestPluginActivity.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.example.testplugin;
+
+import android.app.Activity;
+import android.app.FragmentTransaction;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+public class DMTestPluginActivity extends Activity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ PreferenceFragment prefFragment = new TestMenuPreferenceFragment();
+
+ FragmentTransaction transaction = getFragmentManager().beginTransaction()
+ .replace(android.R.id.content, prefFragment);
+ transaction.commit();
+ }
+
+ public static class TestMenuPreferenceFragment extends PreferenceFragment {
+ TestMenuPreferenceFragment() {
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.test_menu_settings);
+ }
+ }
+}
diff --git a/plugins/testplugin/src/com/android/example/testplugin/GetDMTreeActivity.java b/plugins/testplugin/src/com/android/example/testplugin/GetDMTreeActivity.java
new file mode 100644
index 0000000..e30e906
--- /dev/null
+++ b/plugins/testplugin/src/com/android/example/testplugin/GetDMTreeActivity.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.example.testplugin;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.DmtException;
+import com.android.omadm.plugin.IDMClientService;
+
+import java.util.Arrays;
+import java.util.Map;
+
+public class GetDMTreeActivity extends Activity {
+ static final String TAG = "GetDMTreeActivity";
+
+ // Binder interface to client service
+ IDMClientService mDMClientService;
+
+ // Service connector object to attach/detach binder interface
+ private final DMClientServiceConnector mDMServiceConnector = new DMClientServiceConnector();
+
+ private class DMClientServiceConnector implements ServiceConnection {
+ // package local constructor (called by outer class)
+ DMClientServiceConnector() {}
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ Log.d(TAG, "onServiceConnected for " + name + " service " + service);
+ mDMClientService = IDMClientService.Stub.asInterface(service);
+
+ try {
+ Log.d(TAG, "getting DM tree and dumping to log");
+
+ DmtData swVersion = mDMClientService.getDMTree("./DevDetail/SwV", false);
+ Log.d(TAG, "node \"./DevDetail/SwV\" type: " + swVersion.getType() + " value: "
+ + swVersion.getString());
+
+ DmtData treeRoot = mDMClientService.getDMTree(".", true);
+ Log.d(TAG, "tree root: type " + treeRoot.getType() + ": " + treeRoot.getString());
+ if (treeRoot.getType() == DmtData.NODE) {
+ printChildren(treeRoot, " ");
+ }
+
+ DmtData wifiNode = mDMClientService.getDMTree("./Wi-Fi", true);
+ Log.d(TAG, "HotSpot wifi node root is " + wifiNode);
+ if (wifiNode.getType() == DmtData.NODE) {
+ printChildren(wifiNode, " ");
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "remote exception", e);
+ }
+
+ Log.d(TAG, "finishing activity");
+ finish();
+ }
+
+ private void printChildren(DmtData node, String indent) {
+ try {
+ Map<String, DmtData> childNodeMap = node.getChildNodeMap();
+ for (Map.Entry<String, DmtData> entry : childNodeMap.entrySet()) {
+ DmtData value = entry.getValue();
+ Log.d(TAG, indent + " name: " + entry.getKey() + " type: " + value.getType()
+ + ": " + value.getString());
+ if (value.getType() == DmtData.NODE) {
+ printChildren(value, indent + " ");
+ }
+ }
+ } catch (DmtException e) {
+ Log.e(TAG, "DmtException", e);
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ Log.d(TAG, "onServiceDisconnected for " + name);
+ mDMClientService = null;
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.get_dm_tree_activity);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ // bind to the OMA DM client service
+ Intent intent = new Intent();
+ intent.setClassName("com.android.omadm.service", "com.android.omadm.service.DMClientService");
+ bindService(intent, mDMServiceConnector,
+ Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT);
+ }
+
+ @Override
+ protected void onPause() {
+ // unbind the OMA DM client service
+ unbindService(mDMServiceConnector);
+ super.onPause();
+ }
+}
diff --git a/plugins/testplugin/src/com/android/example/testplugin/InjectSoapPackageActivity.java b/plugins/testplugin/src/com/android/example/testplugin/InjectSoapPackageActivity.java
new file mode 100644
index 0000000..141f08e
--- /dev/null
+++ b/plugins/testplugin/src/com/android/example/testplugin/InjectSoapPackageActivity.java
@@ -0,0 +1,239 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.example.testplugin;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.android.omadm.plugin.DmtData;
+import com.android.omadm.plugin.IDMClientService;
+
+public class InjectSoapPackageActivity extends Activity {
+ static final String TAG = "InjectSoapPackageActivity";
+
+ // example serialized MO from SOAP-XML SPP package
+ private static final String SAMPLE_PAYLOAD
+ = "<MgmtTree xmlns=\"syncml:dmddf1.2\">\n"
+ + " <VerDTD>1.2</VerDTD>\n"
+ + " <Node>\n"
+ + " <NodeName>PerProviderSubscription</NodeName>\n"
+ + " <RTProperties>\n"
+ + " <Type>\n"
+ + " <DDFName>urn:wfa:mo:hotspot2dot0-perprovidersubscription:1.0</DDFName>\n"
+ + " </Type>\n"
+ + " </RTProperties>\n"
+ + " <Node>\n"
+ + " <NodeName>x1</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>CredentialPriority</NodeName>\n"
+ + " <Value>1</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>SubscriptionRemediation</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>URI</NodeName>\n"
+ + " <Value>remediation-server.R2-testbed.wi-fi.org</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>certURL</NodeName>\n"
+ + " <Value>http://remediation-server.R2-testbed.wi-fi.org/server.cer</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>certSHA256Fingerprint</NodeName>\n"
+ + " <Value>abcdef01234567899876543210fedcbaabcdef01234567899876543210fedcba</Value>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>SubscriptionUpdate</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>UpdateInterval</NodeName>\n"
+ + " <Value>4294967295</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>UpdateMethod</NodeName>\n"
+ + " <Value>ClientInitiated</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>Restriction</NodeName>\n"
+ + " <Value>HomeSP</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>URI</NodeName>\n"
+ + " <Value>subscription-server.R2-testbed.wi-fi.org</Value>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>HomeSP</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>FriendlyName</NodeName>\n"
+ + " <Value>Wi-Fi Alliance</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>FQDN</NodeName>\n"
+ + " <Value>wi-fi.org</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>HomeOIList</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>x1</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>HomeOI</NodeName>\n"
+ + " <Value>506f9a</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>HomeOIRequired</NodeName>\n"
+ + " <Value>FALSE</Value>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>x2</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>HomeOI</NodeName>\n"
+ + " <Value>004096</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>HomeOIRequired</NodeName>\n"
+ + " <Value>FALSE</Value>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>SubscriptionParameters</NodeName>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>Credential</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>CreationDate</NodeName>\n"
+ + " <Value>2012-12-01T12:00:00Z</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>UsernamePassword</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>Username</NodeName>\n"
+ + " <Value>test01</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>Password</NodeName>\n"
+ + " <Value>Q2hhbmdlTWU=</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>MachineManaged</NodeName>\n"
+ + " <Value>TRUE</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>EAPMethod</NodeName>\n"
+ + " <Node>\n"
+ + " <NodeName>EAPType</NodeName>\n"
+ + " <Value>21</Value>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>InnerMethod</NodeName>\n"
+ + " <Value>MS-CHAP-V2</Value>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " <Node>\n"
+ + " <NodeName>Realm</NodeName>\n"
+ + " <Value>wi-fi.org</Value>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + " </Node>\n"
+ + "</MgmtTree>";
+
+ // Binder interface to client service
+ IDMClientService mDMClientService;
+
+ class InjectPayloadTask extends AsyncTask<Void, Void, Void> {
+ protected Void doInBackground(Void... ignored) {
+ try {
+ Log.d(TAG, "injecting SOAP package");
+
+ // service will add the package synchronously then return result.
+ int ret = mDMClientService.injectSoapPackage("./Wi-Fi/R2-testbed.wi-fi.org",
+ "ADD", SAMPLE_PAYLOAD);
+
+ Log.d(TAG, "session result was " + ret + ", dumping tree");
+ // TODO
+
+ Log.d(TAG, "finishing activity");
+ finish();
+ } catch (RemoteException e) {
+ Log.e(TAG, "remote exception", e);
+ }
+ return null;
+ }
+
+ protected void onPostExecute(Void result) {
+ Log.d(TAG, "closing activity");
+ finish();
+ }
+ }
+
+ // Service connector object to attach/detach binder interface
+ private final DMClientServiceConnector mDMServiceConnector = new DMClientServiceConnector();
+
+ private class DMClientServiceConnector implements ServiceConnection {
+ // package local constructor (called by outer class)
+ DMClientServiceConnector() {}
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ Log.d(TAG, "onServiceConnected for " + name + " service " + service);
+ mDMClientService = IDMClientService.Stub.asInterface(service);
+ new InjectPayloadTask().execute();
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ Log.d(TAG, "onServiceDisconnected for " + name);
+ mDMClientService = null;
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.inject_soap_package_activity);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ // bind to the OMA DM client service
+ Intent intent = new Intent();
+ intent.setClassName("com.android.omadm.service", "com.android.omadm.service.DMClientService");
+ bindService(intent, mDMServiceConnector,
+ Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT);
+ }
+
+ @Override
+ protected void onPause() {
+ // unbind the OMA DM client service
+ unbindService(mDMServiceConnector);
+ super.onPause();
+ }
+}
diff --git a/plugins/testplugin/src/com/android/example/testplugin/StartClientSessionActivity.java b/plugins/testplugin/src/com/android/example/testplugin/StartClientSessionActivity.java
new file mode 100644
index 0000000..874a6b2
--- /dev/null
+++ b/plugins/testplugin/src/com/android/example/testplugin/StartClientSessionActivity.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.example.testplugin;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.android.omadm.plugin.IDMClientService;
+
+public class StartClientSessionActivity extends Activity {
+ static final String TAG = "StartClientSessionActivity";
+
+ // Binder interface to client service
+ IDMClientService mDMClientService;
+
+ // Service connector object to attach/detach binder interface
+ private final DMClientServiceConnector mDMServiceConnector = new DMClientServiceConnector();
+
+ // test alert 1226 string for Sprint HFA FUMO update (no-op for Android)
+ static final String ALERT_TYPE_HFA_CIFUMO_UPDATE
+ = "org.openmobilealliance.dm.firmwareupdate.devicerequest";
+
+
+ private class DMClientServiceConnector implements ServiceConnection {
+ // package local constructor (called by outer class)
+ DMClientServiceConnector() {}
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ Log.d(TAG, "onServiceConnected for " + name + " service " + service);
+ mDMClientService = IDMClientService.Stub.asInterface(service);
+
+ try {
+ Log.d(TAG, "starting client session with hardcoded values");
+ mDMClientService.startClientSession("sprint", null, null,
+ ALERT_TYPE_HFA_CIFUMO_UPDATE, null, null, null);
+ } catch (RemoteException e) {
+ Log.e(TAG, "remote exception thrown", e);
+ }
+
+ Log.d(TAG, "waiting for callback");
+ // TODO
+ Log.d(TAG, "dumping OMA DM tree");
+ // TODO
+ Log.d(TAG, "finishing activity");
+ finish();
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ Log.d(TAG, "onServiceDisconnected for " + name);
+ mDMClientService = null;
+ }
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.start_client_session_activity);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ // bind to the OMA DM client service
+ Intent intent = new Intent();
+ intent.setClassName("com.android.omadm.service", "com.android.omadm.service.DMClientService");
+ bindService(intent, mDMServiceConnector,
+ Context.BIND_AUTO_CREATE | Context.BIND_IMPORTANT);
+ }
+
+ @Override
+ protected void onPause() {
+ // unbind the OMA DM client service
+ unbindService(mDMServiceConnector);
+ super.onPause();
+ }
+}
diff --git a/samples/dmAccounts.xml b/samples/dmAccounts.xml
new file mode 100644
index 0000000..5c933f5
--- /dev/null
+++ b/samples/dmAccounts.xml
@@ -0,0 +1,20 @@
+<!-- This is a sample dmAccounts.xml. For OMA-DM testing purposes, test server
+info can be pushed in this format to /system/etc/ -->
+<DMAcc version="1">
+ <Account AccName="TestAccName"
+ ServerID="TestServerID"
+ Addr="https://test.server.addr/"
+ AddrType="1"
+ PortNbr="440"
+ ConRef=""
+ ServerName="ServerName"
+ AuthPref="DIGEST"
+ ServerPW="ServerPassword"
+ ServerNonce="abc123"
+ UserName="username"
+ ClientPW="ClientPassword"
+ ClientNonce="123abc"
+ ProxyAddr=""
+ ProxyPortNbr=""
+ />
+</DMAcc>
diff --git a/setting/Dmt.zip b/setting/Dmt.zip
new file mode 100644
index 0000000..da68f42
--- /dev/null
+++ b/setting/Dmt.zip
Binary files differ
diff --git a/setting/Makefile b/setting/Makefile
new file mode 100755
index 0000000..1f64472
--- /dev/null
+++ b/setting/Makefile
@@ -0,0 +1,29 @@
+DM_ROOT := $(CURDIR)/..
+DM_ENGINE := $(DM_ROOT)/engine
+DM_SERVICE := $(DM_ROOT)/DMService
+DM_SETTING := $(DM_ROOT)/setting
+DM_TOOLS := $(DM_ENGINE)/dmlib/dmt-tools
+DM_ASSETS := $(DM_SERVICE)/assets
+DM_PLUGIN := $(DM_ASSETS)/dm/plugin/
+DM_GENERATE := $(DM_TOOLS)/generateDMT
+DM_FSTAB := $(DM_ROOT)/setting/fstab
+DM_TREE_ZIP := $(DM_ROOT)/setting/Dmt.zip
+
+MY_TMP := $(DM_SETTING)/tmp2
+MY_TREE := $(MY_TMP)/Dmt
+MY_OUT := $(MY_TMP)/output
+
+all:
+ @echo building all
+ -rm -rf $(MY_TMP)
+ -mkdir $(MY_TMP)
+ cd $(MY_TMP); unzip $(DM_TREE_ZIP)
+ cd $(DM_TOOLS); bash $(DM_GENERATE) -fstab $(DM_FSTAB) -output $(MY_OUT) -dmt $(MY_TREE)
+ -rm -rf $(DM_SETTING)/dmt_data/*
+ cp -r $(MY_OUT)/treedata/* $(DM_SETTING)/dmt_data/
+ cp $(MY_OUT)/treedata/fstab $(DM_ASSETS)/dm/dmt_data/fstab
+ cp $(MY_OUT)/treedata/*.wbxml $(DM_ASSETS)/dm/dmt_data/
+ cp $(MY_OUT)/treedata/*.dat $(DM_ASSETS)/dm/dmt_data/
+ cp $(MY_OUT)/treedata/*.bmdf $(DM_ASSETS)/dm/dmt_data/
+ -rm -rf $(MY_TMP)
+
diff --git a/setting/README b/setting/README
new file mode 100755
index 0000000..ff1cbfe
--- /dev/null
+++ b/setting/README
@@ -0,0 +1,14 @@
+This directory contains files needed to generate DM Tree files. To add or
+modify tree:
+1. Unzip Dmt.zip
+2. Make necessary changes to metadata files under Dmt/ directory
+3. Zip them to a new Dmt.zip
+4. Run "make" to generate tree files, which also copy them to "assets" directory of DMService
+
+File list
+---------
+Makefile - invokes generateDMT tool to generate tree files and copy them to DMService "assets" directory.
+fstab - DM tree file list; used by generateDMT tool
+event.dat - should be empty but file is needed by native DM engine
+dmt_data - duplicate directory containing same tree files as "assets".
+Dmt.zip - DM tree metadata files
diff --git a/setting/dmt_data/acl.dat b/setting/dmt_data/acl.dat
new file mode 100644
index 0000000..8f73e7a
--- /dev/null
+++ b/setting/dmt_data/acl.dat
@@ -0,0 +1,5 @@
+1:*
+
+[.]
+R=1&G=1&A=1&D=1&E=1
+
diff --git a/setting/dmt_data/acl.txt b/setting/dmt_data/acl.txt
new file mode 100644
index 0000000..4559206
--- /dev/null
+++ b/setting/dmt_data/acl.txt
@@ -0,0 +1,2 @@
+[.]
+Replace=*&Get=*&Add=*&Delete=*&Exec=*
diff --git a/setting/dmt_data/customization.wbxml b/setting/dmt_data/customization.wbxml
new file mode 100644
index 0000000..e96cd4d
--- /dev/null
+++ b/setting/dmt_data/customization.wbxml
Binary files differ
diff --git a/setting/dmt_data/customization.xml b/setting/dmt_data/customization.xml
new file mode 100644
index 0000000..5e0e61b
--- /dev/null
+++ b/setting/dmt_data/customization.xml
@@ -0,0 +1,1191 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>Customization</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>BrandAlpha</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>CarrierLegal</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>CustID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>0</Data>
+ </Node>
+
+ <Node>
+ <NodeName>DiagMSLReq</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>LaunchID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>LaunchZone</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>TetheredData</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>ADC</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Eighteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Eigth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Elevnth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fifteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>First</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fourteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Ninth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Second</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Seventeenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Seventh</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Sixteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Tenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Third</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Thirteenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Twelfth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Android</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>ClientID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>AndroidMarket</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>MobileSearch</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Youtube</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>OperatorID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>NetworkCode</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Browser</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Homepage</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>SearchEngine</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>UAProfURL</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>CallIntercept</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Eight</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Eleventh</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>First</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Ninth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Second</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Seventh</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Tenth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Third</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Twelfth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Contacts</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>First</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Second</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Third</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>EnabledApps</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Skyfire</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>Touch</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>VoWifi</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>VVM</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>MMS</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Proxy</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>ServerUrl</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>RoamPreference</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>HomeOnly</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>MenuDisplay</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Wifi</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>DomRoamMaxUsers</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>GSMMaxUsers</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>IntRoamMaxUsers</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>MaxUsers</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>SSID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/setting/dmt_data/devdetail_ext.wbxml b/setting/dmt_data/devdetail_ext.wbxml
new file mode 100644
index 0000000..cb90e18
--- /dev/null
+++ b/setting/dmt_data/devdetail_ext.wbxml
Binary files differ
diff --git a/setting/dmt_data/devdetail_ext.xml b/setting/dmt_data/devdetail_ext.xml
new file mode 100644
index 0000000..eb4c20b
--- /dev/null
+++ b/setting/dmt_data/devdetail_ext.xml
@@ -0,0 +1,45 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>Ext</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>DateTime</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>SystemSettings</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/setting/dmt_data/devdetail_uri.wbxml b/setting/dmt_data/devdetail_uri.wbxml
new file mode 100644
index 0000000..9212cb6
--- /dev/null
+++ b/setting/dmt_data/devdetail_uri.wbxml
Binary files differ
diff --git a/setting/dmt_data/devdetail_uri.xml b/setting/dmt_data/devdetail_uri.xml
new file mode 100644
index 0000000..555c5c7
--- /dev/null
+++ b/setting/dmt_data/devdetail_uri.xml
@@ -0,0 +1,60 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>URI</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>MaxDepth</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>20</Data>
+ </Node>
+
+ <Node>
+ <NodeName>MaxSegLen</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>256</Data>
+ </Node>
+
+ <Node>
+ <NodeName>MaxTotLen</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>512</Data>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/setting/dmt_data/docs/desc.html b/setting/dmt_data/docs/desc.html
new file mode 100644
index 0000000..4b2a55a
--- /dev/null
+++ b/setting/dmt_data/docs/desc.html
@@ -0,0 +1,2757 @@
+<HTML>
+<HEAD>
+<TITLE>
+Description
+</TITLE>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
+</HEAD>
+<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"><TR ALIGN="center" VALIGN="top"><TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Node List</B></FONT>&nbsp;</TD><TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD></TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR></TABLE>
+<HR>
+<A NAME="." </A>
+<p><b>.</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>ACL : Replace=*&Get=*&Add=*&Delete=*&Exec=*</li>
+<li>Access Types : Get, Replace, Add, Delete, Exec</li>
+</ul>
+<A NAME="/CDMA" </A>
+<p><b>/CDMA</b></p>
+<p></p>
+<p>CDMA node for Sprint HFA.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CDMA/BC10" </A>
+<p><b>/CDMA/BC10</b></p>
+<p></p>
+<p>CDMA BC10.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/BC14" </A>
+<p><b>/CDMA/BC14</b></p>
+<p></p>
+<p>CDMA BC14.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/RoamPreference" </A>
+<p><b>/CDMA/RoamPreference</b></p>
+<p></p>
+<p>CDMA roaming preference.</p>
+<p></p>
+<ul type=disc>
+<li>Format : bin</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/SO68" </A>
+<p><b>/CDMA/SO68</b></p>
+<p></p>
+<p>CDMA SO68.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/1xA" </A>
+<p><b>/CDMA/1xA</b></p>
+<p></p>
+<p>CDMA 1x interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CDMA/1xA/Enabled" </A>
+<p><b>/CDMA/1xA/Enabled</b></p>
+<p></p>
+<p>CDMA 1x enabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Replace, Get</li>
+</ul>
+<A NAME="/CDMA/3GPD" </A>
+<p><b>/CDMA/3GPD</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CDMA/3GPD/*" </A>
+<p><b>/CDMA/3GPD/*</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/AuthAlgoAAA" </A>
+<p><b>/CDMA/3GPD/*/AuthAlgoAAA</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Add, Get, Replace, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/AuthAlgoHA" </A>
+<p><b>/CDMA/3GPD/*/AuthAlgoHA</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/MobileIpAddress" </A>
+<p><b>/CDMA/3GPD/*/MobileIpAddress</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/NAI" </A>
+<p><b>/CDMA/3GPD/*/NAI</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/PasswordAAA" </A>
+<p><b>/CDMA/3GPD/*/PasswordAAA</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/PasswordHA" </A>
+<p><b>/CDMA/3GPD/*/PasswordHA</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/PriHAIp" </A>
+<p><b>/CDMA/3GPD/*/PriHAIp</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/ReverseTunneling" </A>
+<p><b>/CDMA/3GPD/*/ReverseTunneling</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/SecHAIp" </A>
+<p><b>/CDMA/3GPD/*/SecHAIp</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/SpiAAA" </A>
+<p><b>/CDMA/3GPD/*/SpiAAA</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/3GPD/*/SpiHA" </A>
+<p><b>/CDMA/3GPD/*/SpiHA</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/B25" </A>
+<p><b>/CDMA/B25</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CDMA/B25/enablement" </A>
+<p><b>/CDMA/B25/enablement</b></p>
+<p></p>
+<p>CDMA B25 enablement.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/B25/scanpriority" </A>
+<p><b>/CDMA/B25/scanpriority</b></p>
+<p></p>
+<p>CDMA B25 scan priority.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/B26" </A>
+<p><b>/CDMA/B26</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CDMA/B26/enablement" </A>
+<p><b>/CDMA/B26/enablement</b></p>
+<p></p>
+<p>CDMA B26 enablement.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/B26/scanpriority" </A>
+<p><b>/CDMA/B26/scanpriority</b></p>
+<p></p>
+<p>CDMA B26 scan priority.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/B41" </A>
+<p><b>/CDMA/B41</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CDMA/B41/enablement" </A>
+<p><b>/CDMA/B41/enablement</b></p>
+<p></p>
+<p>CDMA B41 enablement.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/B41/scanpriority" </A>
+<p><b>/CDMA/B41/scanpriority</b></p>
+<p></p>
+<p>CDMA B41 scan priority.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/EHRPD" </A>
+<p><b>/CDMA/EHRPD</b></p>
+<p></p>
+<p>CDMA EHRPD interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CDMA/EHRPD/Enabled" </A>
+<p><b>/CDMA/EHRPD/Enabled</b></p>
+<p></p>
+<p>eHRPD enabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace, Add, Delete</li>
+</ul>
+<A NAME="/CDMA/NAM" </A>
+<p><b>/CDMA/NAM</b></p>
+<p></p>
+<p>CDMA NAM interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CDMA/NAM/CdmaNam" </A>
+<p><b>/CDMA/NAM/CdmaNam</b></p>
+<p></p>
+<p>CDMA NAM.</p>
+<p></p>
+<ul type=disc>
+<li>Format : bin</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/NAM/MobDirNum" </A>
+<p><b>/CDMA/NAM/MobDirNum</b></p>
+<p></p>
+<p>CDMA MDN.</p>
+<p></p>
+<ul type=disc>
+<li>Format : bin</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/CDMA/PRL" </A>
+<p><b>/CDMA/PRL</b></p>
+<p></p>
+<p>CDMA PRL node for Sprint HFA.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/PRL/PrefRoamList" </A>
+<p><b>/CDMA/PRL/PrefRoamList</b></p>
+<p></p>
+<p>CDMA PRL node.</p>
+<p></p>
+<ul type=disc>
+<li>Format : bin</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CDMA/SO73" </A>
+<p><b>/CDMA/SO73</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CDMA/SO73/COP0" </A>
+<p><b>/CDMA/SO73/COP0</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Replace, Get</li>
+</ul>
+<A NAME="/CDMA/SO73/COP1to7" </A>
+<p><b>/CDMA/SO73/COP1to7</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Replace, Get</li>
+</ul>
+<A NAME="/Con" </A>
+<p><b>/Con</b></p>
+<p></p>
+<p>Con node for Sprint HFA.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Con/HPPTT" </A>
+<p><b>/Con/HPPTT</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Con/HPPTT/Enabled" </A>
+<p><b>/Con/HPPTT/Enabled</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Replace, Get, Delete</li>
+</ul>
+<A NAME="/Con/HPPTT/UserAddress" </A>
+<p><b>/Con/HPPTT/UserAddress</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Replace, Get, Delete</li>
+</ul>
+<A NAME="/CSIM" </A>
+<p><b>/CSIM</b></p>
+<p></p>
+<p>CSIM node for Sprint HFA.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/CSIM/CoverageObj" </A>
+<p><b>/CSIM/CoverageObj</b></p>
+<p></p>
+<p>CDMA CoverageObj.</p>
+<p></p>
+<ul type=disc>
+<li>Format : bin</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/CSIM/ProvObj" </A>
+<p><b>/CSIM/ProvObj</b></p>
+<p></p>
+<p>CDMA ProvObj.</p>
+<p></p>
+<ul type=disc>
+<li>Format : bin</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Customization" </A>
+<p><b>/Customization</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/BrandAlpha" </A>
+<p><b>/Customization/BrandAlpha</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CarrierLegal" </A>
+<p><b>/Customization/CarrierLegal</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : bin</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CustID" </A>
+<p><b>/Customization/CustID</b></p>
+<p></p>
+<p>Customization ID.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 0</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/Customization/DiagMSLReq" </A>
+<p><b>/Customization/DiagMSLReq</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/LaunchID" </A>
+<p><b>/Customization/LaunchID</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/LaunchZone" </A>
+<p><b>/Customization/LaunchZone</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/TetheredData" </A>
+<p><b>/Customization/TetheredData</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC" </A>
+<p><b>/Customization/ADC</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/ADC/Eighteenth" </A>
+<p><b>/Customization/ADC/Eighteenth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Eigth" </A>
+<p><b>/Customization/ADC/Eigth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Elevnth" </A>
+<p><b>/Customization/ADC/Elevnth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Fifteenth" </A>
+<p><b>/Customization/ADC/Fifteenth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Fifth" </A>
+<p><b>/Customization/ADC/Fifth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/First" </A>
+<p><b>/Customization/ADC/First</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Fourteenth" </A>
+<p><b>/Customization/ADC/Fourteenth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Fourth" </A>
+<p><b>/Customization/ADC/Fourth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Ninth" </A>
+<p><b>/Customization/ADC/Ninth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Second" </A>
+<p><b>/Customization/ADC/Second</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Seventeenth" </A>
+<p><b>/Customization/ADC/Seventeenth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Seventh" </A>
+<p><b>/Customization/ADC/Seventh</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Sixteenth" </A>
+<p><b>/Customization/ADC/Sixteenth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Sixth" </A>
+<p><b>/Customization/ADC/Sixth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Tenth" </A>
+<p><b>/Customization/ADC/Tenth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Third" </A>
+<p><b>/Customization/ADC/Third</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Thirteenth" </A>
+<p><b>/Customization/ADC/Thirteenth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/ADC/Twelfth" </A>
+<p><b>/Customization/ADC/Twelfth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Android" </A>
+<p><b>/Customization/Android</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/Android/ClientID" </A>
+<p><b>/Customization/Android/ClientID</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/Android/ClientID/AndroidMarket" </A>
+<p><b>/Customization/Android/ClientID/AndroidMarket</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Android/ClientID/MobileSearch" </A>
+<p><b>/Customization/Android/ClientID/MobileSearch</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Android/ClientID/Youtube" </A>
+<p><b>/Customization/Android/ClientID/Youtube</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Android/OperatorID" </A>
+<p><b>/Customization/Android/OperatorID</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/Android/OperatorID/NetworkCode" </A>
+<p><b>/Customization/Android/OperatorID/NetworkCode</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Browser" </A>
+<p><b>/Customization/Browser</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/Browser/Homepage" </A>
+<p><b>/Customization/Browser/Homepage</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Browser/SearchEngine" </A>
+<p><b>/Customization/Browser/SearchEngine</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Browser/UAProfURL" </A>
+<p><b>/Customization/Browser/UAProfURL</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept" </A>
+<p><b>/Customization/CallIntercept</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Eight" </A>
+<p><b>/Customization/CallIntercept/Eight</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Eleventh" </A>
+<p><b>/Customization/CallIntercept/Eleventh</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Fifth" </A>
+<p><b>/Customization/CallIntercept/Fifth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/First" </A>
+<p><b>/Customization/CallIntercept/First</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Fourth" </A>
+<p><b>/Customization/CallIntercept/Fourth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Ninth" </A>
+<p><b>/Customization/CallIntercept/Ninth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Second" </A>
+<p><b>/Customization/CallIntercept/Second</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Seventh" </A>
+<p><b>/Customization/CallIntercept/Seventh</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Sixth" </A>
+<p><b>/Customization/CallIntercept/Sixth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Tenth" </A>
+<p><b>/Customization/CallIntercept/Tenth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Third" </A>
+<p><b>/Customization/CallIntercept/Third</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/CallIntercept/Twelfth" </A>
+<p><b>/Customization/CallIntercept/Twelfth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Contacts" </A>
+<p><b>/Customization/Contacts</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/Contacts/Fifth" </A>
+<p><b>/Customization/Contacts/Fifth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Contacts/First" </A>
+<p><b>/Customization/Contacts/First</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Contacts/Fourth" </A>
+<p><b>/Customization/Contacts/Fourth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Contacts/Second" </A>
+<p><b>/Customization/Contacts/Second</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Contacts/Sixth" </A>
+<p><b>/Customization/Contacts/Sixth</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Contacts/Third" </A>
+<p><b>/Customization/Contacts/Third</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/EnabledApps" </A>
+<p><b>/Customization/EnabledApps</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/EnabledApps/Skyfire" </A>
+<p><b>/Customization/EnabledApps/Skyfire</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/EnabledApps/Touch" </A>
+<p><b>/Customization/EnabledApps/Touch</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/EnabledApps/VoWifi" </A>
+<p><b>/Customization/EnabledApps/VoWifi</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/EnabledApps/VVM" </A>
+<p><b>/Customization/EnabledApps/VVM</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/MMS" </A>
+<p><b>/Customization/MMS</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/MMS/Proxy" </A>
+<p><b>/Customization/MMS/Proxy</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/MMS/ServerUrl" </A>
+<p><b>/Customization/MMS/ServerUrl</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/RoamPreference" </A>
+<p><b>/Customization/RoamPreference</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/RoamPreference/HomeOnly" </A>
+<p><b>/Customization/RoamPreference/HomeOnly</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/RoamPreference/MenuDisplay" </A>
+<p><b>/Customization/RoamPreference/MenuDisplay</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Wifi" </A>
+<p><b>/Customization/Wifi</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+</ul>
+<A NAME="/Customization/Wifi/DomRoamMaxUsers" </A>
+<p><b>/Customization/Wifi/DomRoamMaxUsers</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Wifi/GSMMaxUsers" </A>
+<p><b>/Customization/Wifi/GSMMaxUsers</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Wifi/IntRoamMaxUsers" </A>
+<p><b>/Customization/Wifi/IntRoamMaxUsers</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Wifi/MaxUsers" </A>
+<p><b>/Customization/Wifi/MaxUsers</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/Customization/Wifi/SSID" </A>
+<p><b>/Customization/Wifi/SSID</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DevDetail" </A>
+<p><b>/DevDetail</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/DevTyp" </A>
+<p><b>/DevDetail/DevTyp</b></p>
+<p></p>
+<p>Device type, e.g. phone or tablet.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 1.0</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevDetail/ESNV" </A>
+<p><b>/DevDetail/ESNV</b></p>
+<p></p>
+<p>ESN version.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Initial Value : 1.0</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevDetail/FlexV" </A>
+<p><b>/DevDetail/FlexV</b></p>
+<p></p>
+<p>Flex version.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Initial Value : 1.0</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevDetail/FwV" </A>
+<p><b>/DevDetail/FwV</b></p>
+<p></p>
+<p>Firmware version.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Default : 1.0</li>
+<li>Initial Value : 1.0</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevDetail/HwV" </A>
+<p><b>/DevDetail/HwV</b></p>
+<p></p>
+<p>Hardware version.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 1.0</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevDetail/LrgObj" </A>
+<p><b>/DevDetail/LrgObj</b></p>
+<p></p>
+<p>Indicates whether the device supports the SyncML Large Object Handling specification</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Default : true</li>
+<li>Initial Value : true</li>
+</ul>
+<A NAME="/DevDetail/OEM" </A>
+<p><b>/DevDetail/OEM</b></p>
+<p></p>
+<p>Original Equipment Manufacturer.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : Google</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevDetail/PRIChecksum" </A>
+<p><b>/DevDetail/PRIChecksum</b></p>
+<p></p>
+<p>PRI checksum.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Initial Value : 111111</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevDetail/PRLV" </A>
+<p><b>/DevDetail/PRLV</b></p>
+<p></p>
+<p>PRL version.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Initial Value : 1.0</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevDetail/SwV" </A>
+<p><b>/DevDetail/SwV</b></p>
+<p></p>
+<p>Software version.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 1.0</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevDetail/Bearer" </A>
+<p><b>/DevDetail/Bearer</b></p>
+<p></p>
+<p>An optional, internal node, designating a branch of the DevDetail sub tree into which items related to the bearer (CDMA, etc.) are stored. Use of this sub tree can be mandated by other standards.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/DevDetail/Bearer/CDMA" </A>
+<p><b>/DevDetail/Bearer/CDMA</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Max Length : 16</li>
+</ul>
+<A NAME="/DevDetail/Bearer/GSM" </A>
+<p><b>/DevDetail/Bearer/GSM</b></p>
+<p></p>
+<p>the node is used to store the information related to Technology</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Initial Value : 1900-GSM</li>
+<li>Max Length : 16</li>
+</ul>
+<A NAME="/DevDetail/Ext" </A>
+<p><b>/DevDetail/Ext</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add</li>
+</ul>
+<A NAME="/DevDetail/Ext/LastUpdateTime" </A>
+<p><b>/DevDetail/Ext/LastUpdateTime</b></p>
+<p></p>
+<p> Last Update Date Stamp.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/Ext/PreFwV" </A>
+<p><b>/DevDetail/Ext/PreFwV</b></p>
+<p></p>
+<p> Previous firmware version prior to an update.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/Ext/SystemV" </A>
+<p><b>/DevDetail/Ext/SystemV</b></p>
+<p></p>
+<p>The concatenated version information of all FOTA updatable partitions in following order: System + DSP (Modem) + Normal Boot + Logo + LBL + CDT&ATAGS + BPL + MBM.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/Ext/WLANMacAddr" </A>
+<p><b>/DevDetail/Ext/WLANMacAddr</b></p>
+<p></p>
+<p> Wi-Fi MAC address.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/Ext/DateTime" </A>
+<p><b>/DevDetail/Ext/DateTime</b></p>
+<p></p>
+<p>Last Update date and time</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/Ext/DateTime/Date" </A>
+<p><b>/DevDetail/Ext/DateTime/Date</b></p>
+<p></p>
+<p> Last Update Date.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/Ext/DateTime/TimeUTC" </A>
+<p><b>/DevDetail/Ext/DateTime/TimeUTC</b></p>
+<p></p>
+<p> Last Update UTC Time Stamp.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/Ext/SystemSettings" </A>
+<p><b>/DevDetail/Ext/SystemSettings</b></p>
+<p></p>
+<p>System Settings node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/Ext/SystemSettings/AllowUnknownSources" </A>
+<p><b>/DevDetail/Ext/SystemSettings/AllowUnknownSources</b></p>
+<p></p>
+<p> UnknownSources (True) or (False)</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/DevDetail/URI" </A>
+<p><b>/DevDetail/URI</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevDetail/URI/MaxDepth" </A>
+<p><b>/DevDetail/URI/MaxDepth</b></p>
+<p></p>
+<p>Specifies the maximum depth of the management tree supported by the device. The maximum depth of the tree is defined as the maximum number of URI segments that the device supports. The value is a 16 bit, unsigned integer encoded as a numerical string. The value '0' means that the device supports a tree of 'unlimited' depth.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 20</li>
+</ul>
+<A NAME="/DevDetail/URI/MaxSegLen" </A>
+<p><b>/DevDetail/URI/MaxSegLen</b></p>
+<p></p>
+<p>Specifies the maximum total length of any URI segment in a URI used to address a node or node property. The maximum total length of a URI segment is defined as the largest number of characters which the device can support in a single URI segment. Note that depending on the used character set this might not be the same as the number of bytes. The value is a 16 bit, unsigned integer encoded as a numerical string. The value '0' means that the device supports URI segments of 'unlimited' length.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 256</li>
+</ul>
+<A NAME="/DevDetail/URI/MaxTotLen" </A>
+<p><b>/DevDetail/URI/MaxTotLen</b></p>
+<p></p>
+<p>Specifies the maximum total length of any URI used to address a node or node property. The maximum total length of a URI is defined as the largest total number of characters making up the URI which the device can support. Note that depending on the character set this might not be the same as the number of bytes. The value is a 16 bit, unsigned integer encoded as a numerical string. The value '0' means that the device supports URI of 'unlimited' length.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 512</li>
+</ul>
+<A NAME="/DevInfo" </A>
+<p><b>/DevInfo</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/DevInfo/DevId" </A>
+<p><b>/DevInfo/DevId</b></p>
+<p></p>
+<p>A unique identifier for the device.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+<li>Default : 1.0</li>
+<li>Initial Value : 000000012345678</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevInfo/DmV" </A>
+<p><b>/DevInfo/DmV</b></p>
+<p></p>
+<p>A SyncML device management client version identifier (manufacturer specified string).</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace</li>
+<li>Default : 1.0</li>
+<li>Initial Value : 1.2</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevInfo/Lang" </A>
+<p><b>/DevInfo/Lang</b></p>
+<p></p>
+<p>The current language setting of the device. The syntax of the language tags and their use are defined in [RFC1766]. Language codes are defined by ISO in the standard ISO639.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Initial Value : en</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevInfo/LangAuto" </A>
+<p><b>/DevInfo/LangAuto</b></p>
+<p></p>
+<p>This node determines whether the language setting should be 'auto' or not.</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Initial Value : false</li>
+</ul>
+<A NAME="/DevInfo/Loc" </A>
+<p><b>/DevInfo/Loc</b></p>
+<p></p>
+<p>The current location (country) setting of the device. Country codes are defined by ISO in the standard ISO 3166.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Initial Value : US</li>
+<li>Max Length : 2</li>
+</ul>
+<A NAME="/DevInfo/Man" </A>
+<p><b>/DevInfo/Man</b></p>
+<p></p>
+<p>The manufacturer identifier.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevInfo/Mod" </A>
+<p><b>/DevInfo/Mod</b></p>
+<p></p>
+<p>A model identifier</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Default : 1.0</li>
+<li>Initial Value : Nexus</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevInfo/Sort" </A>
+<p><b>/DevInfo/Sort</b></p>
+<p></p>
+<p>The current language sorting comparator for this device.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Initial Value : Latin</li>
+</ul>
+<A NAME="/DevInfo/Bearer" </A>
+<p><b>/DevInfo/Bearer</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DevInfo/Bearer/GSM" </A>
+<p><b>/DevInfo/Bearer/GSM</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+<li>Default : 1.0</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/DevInfo/Ext" </A>
+<p><b>/DevInfo/Ext</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc" </A>
+<p><b>/DMAcc</b></p>
+<p></p>
+<p>A collection of all SyncML DM accounts. It is the root for account settings for OMA DM 1.2.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*" </A>
+<p><b>/DMAcc/*</b></p>
+<p></p>
+<p>The "name" node for a management account sub tree</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AAuthPref" </A>
+<p><b>/DMAcc/*/AAuthPref</b></p>
+<p></p>
+<p>The client authentication type that this server prefers</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppID" </A>
+<p><b>/DMAcc/*/AppID</b></p>
+<p></p>
+<p>Application Id (w7)</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/Name" </A>
+<p><b>/DMAcc/*/Name</b></p>
+<p></p>
+<p>Displayable name for the SyncML DM settings</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/PrefConRef" </A>
+<p><b>/DMAcc/*/PrefConRef</b></p>
+<p></p>
+<p>Preferred connectivity profile</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/ServerID" </A>
+<p><b>/DMAcc/*/ServerID</b></p>
+<p></p>
+<p>The "ServerId" value for this server</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAddr" </A>
+<p><b>/DMAcc/*/AppAddr</b></p>
+<p></p>
+<p>The "name" node for application server address subtree</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAddr/*" </A>
+<p><b>/DMAcc/*/AppAddr/*</b></p>
+<p></p>
+<p>Connectivity profile </p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAddr/*/Addr" </A>
+<p><b>/DMAcc/*/AppAddr/*/Addr</b></p>
+<p></p>
+<p>Server address</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAddr/*/AddrType" </A>
+<p><b>/DMAcc/*/AppAddr/*/AddrType</b></p>
+<p></p>
+<p>Server address type, "URI", "IPv4", or "IPv6"</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAddr/*/Port" </A>
+<p><b>/DMAcc/*/AppAddr/*/Port</b></p>
+<p></p>
+<p>port information </p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAddr/*/Port/*" </A>
+<p><b>/DMAcc/*/AppAddr/*/Port/*</b></p>
+<p></p>
+<p>Server port information</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAddr/*/Port/*/PortNbr" </A>
+<p><b>/DMAcc/*/AppAddr/*/Port/*/PortNbr</b></p>
+<p></p>
+<p>Server port number</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAuth" </A>
+<p><b>/DMAcc/*/AppAuth</b></p>
+<p></p>
+<p>The "name" node for application authentication sub tree</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAuth/*" </A>
+<p><b>/DMAcc/*/AppAuth/*</b></p>
+<p></p>
+<p>Application authentication node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAuth/*/AAuthData" </A>
+<p><b>/DMAcc/*/AppAuth/*/AAuthData</b></p>
+<p></p>
+<p>authentication nonce</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAuth/*/AAuthLevel" </A>
+<p><b>/DMAcc/*/AppAuth/*/AAuthLevel</b></p>
+<p></p>
+<p>authentication level</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+<li>Possible Values : CLCRED,SRVCRED,OBEX,HTTP</li>
+</ul>
+<A NAME="/DMAcc/*/AppAuth/*/AAuthName" </A>
+<p><b>/DMAcc/*/AppAuth/*/AAuthName</b></p>
+<p></p>
+<p>authentication name</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAuth/*/AAuthSecret" </A>
+<p><b>/DMAcc/*/AppAuth/*/AAuthSecret</b></p>
+<p></p>
+<p>authentication secret (password)</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/AppAuth/*/AAuthType" </A>
+<p><b>/DMAcc/*/AppAuth/*/AAuthType</b></p>
+<p></p>
+<p>authentication type</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+<li>Possible Values : HTTP-BASIC,HTTP-DIGEST,BASIC,DIGEST,HMAC,X509,SECUREID,SAFEWORD,DIGIPASS,TRANSPORT</li>
+</ul>
+<A NAME="/DMAcc/*/Ext" </A>
+<p><b>/DMAcc/*/Ext</b></p>
+<p></p>
+<p>An optional, internal node, designating the only branch of the DMAcc sub tree into which extensions can be added, permanently or dynamically.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/Ext/LastClientAuthType" </A>
+<p><b>/DMAcc/*/Ext/LastClientAuthType</b></p>
+<p></p>
+<p>The client authentication type requested by the server in the last session</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/ToConRef" </A>
+<p><b>/DMAcc/*/ToConRef</b></p>
+<p></p>
+<p>The "name" node for connectivity reference subtree</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/ToConRef/*" </A>
+<p><b>/DMAcc/*/ToConRef/*</b></p>
+<p></p>
+<p>Connectivity profile </p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/DMAcc/*/ToConRef/*/ConRef" </A>
+<p><b>/DMAcc/*/ToConRef/*/ConRef</b></p>
+<p></p>
+<p>Linkage to connectivity profile name</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/LTE" </A>
+<p><b>/LTE</b></p>
+<p></p>
+<p>LTE node for Sprint HFA.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/LTE/BSRMaxTime" </A>
+<p><b>/LTE/BSRMaxTime</b></p>
+<p></p>
+<p>LTE extended BSR scan max time.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/BSRTimer" </A>
+<p><b>/LTE/BSRTimer</b></p>
+<p></p>
+<p>LTE extended BSR scan interval.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/nextLTEscan" </A>
+<p><b>/LTE/nextLTEscan</b></p>
+<p></p>
+<p>LTE extended next scan interval.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/APN" </A>
+<p><b>/LTE/APN</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/LTE/APN/0" </A>
+<p><b>/LTE/APN/0</b></p>
+<p></p>
+<p>LTE APN</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/APN/1" </A>
+<p><b>/LTE/APN/1</b></p>
+<p></p>
+<p>LTE APN</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/APN/2" </A>
+<p><b>/LTE/APN/2</b></p>
+<p></p>
+<p>LTE APN</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/APN/3" </A>
+<p><b>/LTE/APN/3</b></p>
+<p></p>
+<p>LTE APN</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/APN/4" </A>
+<p><b>/LTE/APN/4</b></p>
+<p></p>
+<p>LTE APN</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/APN/5" </A>
+<p><b>/LTE/APN/5</b></p>
+<p></p>
+<p>LTE APN</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/APN/6" </A>
+<p><b>/LTE/APN/6</b></p>
+<p></p>
+<p>LTE APN</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/APN/7" </A>
+<p><b>/LTE/APN/7</b></p>
+<p></p>
+<p>LTE APN</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/Service" </A>
+<p><b>/LTE/Service</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/LTE/Service/Enabled" </A>
+<p><b>/LTE/Service/Enabled</b></p>
+<p></p>
+<p>LTE service enabled.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/LTE/Service/Forced" </A>
+<p><b>/LTE/Service/Forced</b></p>
+<p></p>
+<p>LTE service forced.</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects" </A>
+<p><b>/ManagedObjects</b></p>
+<p></p>
+<p>A collection of all Subscriber Device Management MOs.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Add, Replace, Delete</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO" </A>
+<p><b>/ManagedObjects/ConnMO</b></p>
+<p></p>
+<p>ConnMO Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/ext" </A>
+<p><b>/ManagedObjects/ConnMO/ext</b></p>
+<p></p>
+<p>ext Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/ext/Settings" </A>
+<p><b>/ManagedObjects/ConnMO/ext/Settings</b></p>
+<p></p>
+<p>Settings Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/ext/Settings/t_1xRTT" </A>
+<p><b>/ManagedObjects/ConnMO/ext/Settings/t_1xRTT</b></p>
+<p></p>
+<p> Timer for periodic 1xRTT system scan</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/ext/Settings/t_mpsr" </A>
+<p><b>/ManagedObjects/ConnMO/ext/Settings/t_mpsr</b></p>
+<p></p>
+<p> Timer for periodic multimode system scan</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/ext/Settings/tbsr_cdma" </A>
+<p><b>/ManagedObjects/ConnMO/ext/Settings/tbsr_cdma</b></p>
+<p></p>
+<p> Timer for periodic cdma system scan</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IMS" </A>
+<p><b>/ManagedObjects/ConnMO/IMS</b></p>
+<p></p>
+<p>IMS Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IMS/Setting" </A>
+<p><b>/ManagedObjects/ConnMO/IMS/Setting</b></p>
+<p></p>
+<p>Setting Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IMS/Setting/Domain" </A>
+<p><b>/ManagedObjects/ConnMO/IMS/Setting/Domain</b></p>
+<p></p>
+<p> Home domain Name for the device to populate the request URI for REGISTRATION</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IMS/Setting/SIPT1" </A>
+<p><b>/ManagedObjects/ConnMO/IMS/Setting/SIPT1</b></p>
+<p></p>
+<p> SIP T1 Timer</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IMS/Setting/SIPT2" </A>
+<p><b>/ManagedObjects/ConnMO/IMS/Setting/SIPT2</b></p>
+<p></p>
+<p> SIP T2 Timer</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IMS/Setting/SIPTf" </A>
+<p><b>/ManagedObjects/ConnMO/IMS/Setting/SIPTf</b></p>
+<p></p>
+<p> SIP TF Timer</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IMS/Setting/sms_over_IP_network_indication" </A>
+<p><b>/ManagedObjects/ConnMO/IMS/Setting/sms_over_IP_network_indication</b></p>
+<p></p>
+<p> Turns IMS ON/OFF on the device</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IMS/Setting/smsformat" </A>
+<p><b>/ManagedObjects/ConnMO/IMS/Setting/smsformat</b></p>
+<p></p>
+<p> Device Outgoing SMS based on either 3GP or 3GPP2 Standards</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IPV6Enable" </A>
+<p><b>/ManagedObjects/ConnMO/IPV6Enable</b></p>
+<p></p>
+<p>IPV6Enable Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IPV6Enable/Setting" </A>
+<p><b>/ManagedObjects/ConnMO/IPV6Enable/Setting</b></p>
+<p></p>
+<p>Setting Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IPV6Enable/Setting/Enabled" </A>
+<p><b>/ManagedObjects/ConnMO/IPV6Enable/Setting/Enabled</b></p>
+<p></p>
+<p> IPV6Enable node Enabled/Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations" </A>
+<p><b>/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations</b></p>
+<p></p>
+<p>Interior node holding APN status</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Disable" </A>
+<p><b>/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Disable</b></p>
+<p></p>
+<p> IPV6Enable node Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Enable" </A>
+<p><b>/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Enable</b></p>
+<p></p>
+<p> IPV6Enable node Enabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE" </A>
+<p><b>/ManagedObjects/ConnMO/LTE</b></p>
+<p></p>
+<p>LTE Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN</b></p>
+<p></p>
+<p>APN Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/1" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/1</b></p>
+<p></p>
+<p>VZWIMS Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/1/Setting" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/1/Setting</b></p>
+<p></p>
+<p>Setting Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/1/Setting/Enabled" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/1/Setting/Enabled</b></p>
+<p></p>
+<p> APN Enabled/Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/1/Setting/Id" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/1/Setting/Id</b></p>
+<p></p>
+<p> APN Id</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/1/Setting/IP" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/1/Setting/IP</b></p>
+<p></p>
+<p> IP Version.Defined by Standards but not used by Verizon Wireless</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/1/Setting/Name" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/1/Setting/Name</b></p>
+<p></p>
+<p> APN Name</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations</b></p>
+<p></p>
+<p>Interior node holding APN status</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations/Disable" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations/Disable</b></p>
+<p></p>
+<p> APN Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/2" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/2</b></p>
+<p></p>
+<p>VZWIMS Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/2/Setting" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/2/Setting</b></p>
+<p></p>
+<p>Setting Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/2/Setting/Enabled" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/2/Setting/Enabled</b></p>
+<p></p>
+<p> APN Enabled/Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/2/Setting/Id" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/2/Setting/Id</b></p>
+<p></p>
+<p> APN Id</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/2/Setting/IP" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/2/Setting/IP</b></p>
+<p></p>
+<p> IP Version.Defined by Standards but not used by Verizon Wireless</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/2/Setting/Name" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/2/Setting/Name</b></p>
+<p></p>
+<p> APN Name</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations</b></p>
+<p></p>
+<p>Interior node holding APN status</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations/Disable" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations/Disable</b></p>
+<p></p>
+<p> APN Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/3" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/3</b></p>
+<p></p>
+<p>VZWIMS Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/3/Setting" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/3/Setting</b></p>
+<p></p>
+<p>Setting Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/3/Setting/Enabled" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/3/Setting/Enabled</b></p>
+<p></p>
+<p> APN Enabled/Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/3/Setting/Id" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/3/Setting/Id</b></p>
+<p></p>
+<p> APN Id</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/3/Setting/IP" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/3/Setting/IP</b></p>
+<p></p>
+<p> IP Version.Defined by Standards but not used by Verizon Wireless</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/3/Setting/Name" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/3/Setting/Name</b></p>
+<p></p>
+<p> APN Name</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations</b></p>
+<p></p>
+<p>Interior node holding APN status</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Disable" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Disable</b></p>
+<p></p>
+<p> APN Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Enable" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Enable</b></p>
+<p></p>
+<p> APN Enabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/4" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/4</b></p>
+<p></p>
+<p>VZWIMS Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/4/Setting" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/4/Setting</b></p>
+<p></p>
+<p>Setting Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/4/Setting/Enabled" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/4/Setting/Enabled</b></p>
+<p></p>
+<p> APN Enabled/Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/4/Setting/Id" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/4/Setting/Id</b></p>
+<p></p>
+<p> APN Id</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/4/Setting/IP" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/4/Setting/IP</b></p>
+<p></p>
+<p> IP Version.Defined by Standards but not used by Verizon Wireless</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/4/Setting/Name" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/4/Setting/Name</b></p>
+<p></p>
+<p> APN Name</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations</b></p>
+<p></p>
+<p>Interior node holding APN status</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Disable" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Disable</b></p>
+<p></p>
+<p> APN Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Enable" </A>
+<p><b>/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Enable</b></p>
+<p></p>
+<p> APN Enabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800</b></p>
+<p></p>
+<p>VZW800 Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN</b></p>
+<p></p>
+<p>APN Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN/5" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN/5</b></p>
+<p></p>
+<p>VZW800 Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN/5/Setting" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN/5/Setting</b></p>
+<p></p>
+<p>Setting Interior node</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Enabled" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Enabled</b></p>
+<p></p>
+<p> APN Enabled/Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Id" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Id</b></p>
+<p></p>
+<p> APN Id</p>
+<p></p>
+<ul type=disc>
+<li>Format : int</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN/5/Setting/IP" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN/5/Setting/IP</b></p>
+<p></p>
+<p> IP Version.Defined by Standards but not used by Verizon Wireless</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Name" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Name</b></p>
+<p></p>
+<p> APN Name</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations</b></p>
+<p></p>
+<p>Interior node holding APN status</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Disable" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Disable</b></p>
+<p></p>
+<p> APN Disabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Enable" </A>
+<p><b>/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Enable</b></p>
+<p></p>
+<p> APN Enabled</p>
+<p></p>
+<ul type=disc>
+<li>Format : bool</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/ManagedObjects/DiagMon" </A>
+<p><b>/ManagedObjects/DiagMon</b></p>
+<p></p>
+<p>The DiagMon Managed Object.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/DiagMon/RF" </A>
+<p><b>/ManagedObjects/DiagMon/RF</b></p>
+<p></p>
+<p>Device RF Details like System Type, Roam, RSSI etc.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/DiagMon/RF/HomeRoam" </A>
+<p><b>/ManagedObjects/DiagMon/RF/HomeRoam</b></p>
+<p></p>
+<p>Home or Roaming Flag (Home, Roam).</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 1</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/ManagedObjects/DiagMon/RF/CurrentSystem" </A>
+<p><b>/ManagedObjects/DiagMon/RF/CurrentSystem</b></p>
+<p></p>
+<p>Interior node holding Data and Voice status</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/ManagedObjects/DiagMon/RF/CurrentSystem/Data" </A>
+<p><b>/ManagedObjects/DiagMon/RF/CurrentSystem/Data</b></p>
+<p></p>
+<p>Current System (1xRTT or 1xEVDO).</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 1</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/ManagedObjects/DiagMon/RF/CurrentSystem/Voice" </A>
+<p><b>/ManagedObjects/DiagMon/RF/CurrentSystem/Voice</b></p>
+<p></p>
+<p> Current voice system</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+<li>Initial Value : 1</li>
+<li>Max Length : 31</li>
+</ul>
+<A NAME="/RemoteCommands" </A>
+<p><b>/RemoteCommands</b></p>
+<p></p>
+<p>Remote command interior node for Sprint.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/RemoteCommands/Command" </A>
+<p><b>/RemoteCommands/Command</b></p>
+<p></p>
+<p>Remote command exec node for Sprint.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Exec</li>
+</ul>
+<A NAME="/SIM" </A>
+<p><b>/SIM</b></p>
+<p></p>
+<p>SIM node for Sprint HFA.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get</li>
+</ul>
+<A NAME="/SIM/UICCID" </A>
+<p><b>/SIM/UICCID</b></p>
+<p></p>
+<p>SIM UICCID.</p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber" </A>
+<p><b>/Subscriber</b></p>
+<p></p>
+<p>Subscriber node for Sprint HFA.</p>
+<p></p>
+<ul type=disc>
+<li>Format : node</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber/AcctSubType" </A>
+<p><b>/Subscriber/AcctSubType</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber/AcctType" </A>
+<p><b>/Subscriber/AcctType</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber/BAN" </A>
+<p><b>/Subscriber/BAN</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber/BillCycleDate" </A>
+<p><b>/Subscriber/BillCycleDate</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber/CarrierID" </A>
+<p><b>/Subscriber/CarrierID</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber/CSA" </A>
+<p><b>/Subscriber/CSA</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber/State" </A>
+<p><b>/Subscriber/State</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber/UsageMode" </A>
+<p><b>/Subscriber/UsageMode</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<A NAME="/Subscriber/ZIPCode" </A>
+<p><b>/Subscriber/ZIPCode</b></p>
+<p></p>
+<ul type=disc>
+<li>Format : chr</li>
+<li>Mime Type : text/plain</li>
+<li>Access Types : Get, Replace</li>
+</ul>
+<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"><TR ALIGN="center" VALIGN="top"><TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Node List</B></FONT>&nbsp;</TD><TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD></TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR></TABLE>
+</HTML>
diff --git a/setting/dmt_data/docs/index-all.html b/setting/dmt_data/docs/index-all.html
new file mode 100644
index 0000000..7bf6c23
--- /dev/null
+++ b/setting/dmt_data/docs/index-all.html
@@ -0,0 +1,305 @@
+<HTML>
+<HEAD>
+<TITLE>
+Index
+</TITLE>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
+</HEAD>
+<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"><TR ALIGN="center" VALIGN="top"><TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1"> &nbsp;<A HREF="desc.html"><FONT CLASS="NavBarFont1"><B>Node List</B></FONT></A>&nbsp;</TD><TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1Rev"><FONT CLASS="NavBarFont1Rev"><B>Index</B></FONT>&nbsp;</TD></TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR></TABLE><A HREF="#_A_">A</A>&nbsp;&nbsp;<A HREF="#_B_">B</A>&nbsp;&nbsp;<A HREF="#_C_">C</A>&nbsp;&nbsp;<A HREF="#_D_">D</A>&nbsp;&nbsp;<A HREF="#_E_">E</A>&nbsp;&nbsp;<A HREF="#_F_">F</A>&nbsp;&nbsp;<A HREF="#_G_">G</A>&nbsp;&nbsp;<A HREF="#_H_">H</A>&nbsp;&nbsp;<A HREF="#_I_">I</A>&nbsp;&nbsp;<A HREF="#_L_">L</A>&nbsp;&nbsp;<A HREF="#_M_">M</A>&nbsp;&nbsp;<A HREF="#_N_">N</A>&nbsp;&nbsp;<A HREF="#_O_">O</A>&nbsp;&nbsp;<A HREF="#_P_">P</A>&nbsp;&nbsp;<A HREF="#_R_">R</A>&nbsp;&nbsp;<A HREF="#_S_">S</A>&nbsp;&nbsp;<A HREF="#_T_">T</A>&nbsp;&nbsp;<A HREF="#_U_">U</A>&nbsp;&nbsp;<A HREF="#_V_">V</A>&nbsp;&nbsp;<A HREF="#_W_">W</A>&nbsp;&nbsp;<A HREF="#_Y_">Y</A>&nbsp;&nbsp;<A HREF="#_Z_">Z</A>&nbsp;&nbsp;
+<DL>
+<HR><BR><A NAME="_A_"><!-- --></A>
+<DT><A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthData"><B>AAuthData</B></A> - Leaf Node: authentication nonce<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthLevel"><B>AAuthLevel</B></A> - Leaf Node: authentication level<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthName"><B>AAuthName</B></A> - Leaf Node: authentication name<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AAuthPref"><B>AAuthPref</B></A> - Leaf Node: The client authentication type that this server prefers<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthSecret"><B>AAuthSecret</B></A> - Leaf Node: authentication secret (password)<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthType"><B>AAuthType</B></A> - Leaf Node: authentication type<BR><BR>
+<DT><A HREF="desc.html#/Subscriber/AcctSubType"><B>AcctSubType</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Subscriber/AcctType"><B>AcctType</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC"><B>ADC</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAddr/*/Addr"><B>Addr</B></A> - Leaf Node: Server address<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAddr/*/AddrType"><B>AddrType</B></A> - Leaf Node: Server address type, "URI", "IPv4", or "IPv6"<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext/SystemSettings/AllowUnknownSources"><B>AllowUnknownSources</B></A> - Leaf Node: UnknownSources (True) or (False)<BR><BR>
+<DT><A HREF="desc.html#/Customization/Android"><B>Android</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Android/ClientID/AndroidMarket"><B>AndroidMarket</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/LTE/APN"><B>APN</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN"><B>APN</B></A> - Interior Node: APN Interior node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN"><B>APN</B></A> - Interior Node: APN Interior node<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAddr"><B>AppAddr</B></A> - Interior Node: The "name" node for application server address subtree<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAuth"><B>AppAuth</B></A> - Interior Node: The "name" node for application authentication sub tree<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppID"><B>AppID</B></A> - Leaf Node: Application Id (w7)<BR><BR>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/AuthAlgoAAA"><B>AuthAlgoAAA</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/AuthAlgoHA"><B>AuthAlgoHA</B></A> - Leaf Node<BR><BR>
+<HR><BR><A NAME="_B_"><!-- --></A>
+<DT><A HREF="desc.html#/CDMA/B25"><B>B25</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/B26"><B>B26</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/B41"><B>B41</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/Subscriber/BAN"><B>BAN</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/BC10"><B>BC10</B></A> - Leaf Node: CDMA BC10.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/BC14"><B>BC14</B></A> - Leaf Node: CDMA BC14.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Bearer"><B>Bearer</B></A> - Interior Node: An optional, internal node, designating a branch of the DevDetail sub tree into which items related to the bearer (CDMA, etc.) are stored. Use of this sub tree can be mandated by other standards.<BR><BR>
+<DT><A HREF="desc.html#/DevInfo/Bearer"><B>Bearer</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/Subscriber/BillCycleDate"><B>BillCycleDate</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/BrandAlpha"><B>BrandAlpha</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Browser"><B>Browser</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/LTE/BSRMaxTime"><B>BSRMaxTime</B></A> - Leaf Node: LTE extended BSR scan max time.<BR><BR>
+<DT><A HREF="desc.html#/LTE/BSRTimer"><B>BSRTimer</B></A> - Leaf Node: LTE extended BSR scan interval.<BR><BR>
+<HR><BR><A NAME="_C_"><!-- --></A>
+<DT><A HREF="desc.html#/Customization/CallIntercept"><B>CallIntercept</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/Subscriber/CarrierID"><B>CarrierID</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CarrierLegal"><B>CarrierLegal</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA"><B>CDMA</B></A> - Interior Node: CDMA node for Sprint HFA.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Bearer/CDMA"><B>CDMA</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/NAM/CdmaNam"><B>CdmaNam</B></A> - Leaf Node: CDMA NAM.<BR><BR>
+<DT><A HREF="desc.html#/Customization/Android/ClientID"><B>ClientID</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/RemoteCommands/Command"><B>Command</B></A> - Leaf Node: Remote command exec node for Sprint.<BR><BR>
+<DT><A HREF="desc.html#/Con"><B>Con</B></A> - Interior Node: Con node for Sprint HFA.<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO"><B>ConnMO</B></A> - Interior Node: ConnMO Interior node<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/ToConRef/*/ConRef"><B>ConRef</B></A> - Leaf Node: Linkage to connectivity profile name<BR><BR>
+<DT><A HREF="desc.html#/Customization/Contacts"><B>Contacts</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/SO73/COP0"><B>COP0</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/SO73/COP1to7"><B>COP1to7</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CSIM/CoverageObj"><B>CoverageObj</B></A> - Leaf Node: CDMA CoverageObj.<BR><BR>
+<DT><A HREF="desc.html#/Subscriber/CSA"><B>CSA</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CSIM"><B>CSIM</B></A> - Interior Node: CSIM node for Sprint HFA.<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/DiagMon/RF/CurrentSystem"><B>CurrentSystem</B></A> - Interior Node: Interior node holding Data and Voice status<BR><BR>
+<DT><A HREF="desc.html#/Customization/CustID"><B>CustID</B></A> - Leaf Node: Customization ID.<BR><BR>
+<DT><A HREF="desc.html#/Customization"><B>Customization</B></A> - Interior Node<BR><BR>
+<HR><BR><A NAME="_D_"><!-- --></A>
+<DT><A HREF="desc.html#/ManagedObjects/DiagMon/RF/CurrentSystem/Data"><B>Data</B></A> - Leaf Node: Current System (1xRTT or 1xEVDO).<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext/DateTime/Date"><B>Date</B></A> - Leaf Node: Last Update Date.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext/DateTime"><B>DateTime</B></A> - Interior Node: Last Update date and time<BR><BR>
+<DT><A HREF="desc.html#/DevDetail"><B>DevDetail</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/DevInfo/DevId"><B>DevId</B></A> - Leaf Node: A unique identifier for the device.<BR><BR>
+<DT><A HREF="desc.html#/DevInfo"><B>DevInfo</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/DevTyp"><B>DevTyp</B></A> - Leaf Node: Device type, e.g. phone or tablet.<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/DiagMon"><B>DiagMon</B></A> - Interior Node: The DiagMon Managed Object.<BR><BR>
+<DT><A HREF="desc.html#/Customization/DiagMSLReq"><B>DiagMSLReq</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Disable"><B>Disable</B></A> - Leaf Node: IPV6Enable node Disabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations/Disable"><B>Disable</B></A> - Leaf Node: APN Disabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations/Disable"><B>Disable</B></A> - Leaf Node: APN Disabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Disable"><B>Disable</B></A> - Leaf Node: APN Disabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Disable"><B>Disable</B></A> - Leaf Node: APN Disabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Disable"><B>Disable</B></A> - Leaf Node: APN Disabled<BR><BR>
+<DT><A HREF="desc.html#/DMAcc"><B>DMAcc</B></A> - Interior Node: A collection of all SyncML DM accounts. It is the root for account settings for OMA DM 1.2.<BR><BR>
+<DT><A HREF="desc.html#/DevInfo/DmV"><B>DmV</B></A> - Leaf Node: A SyncML device management client version identifier (manufacturer specified string).<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/Domain"><B>Domain</B></A> - Leaf Node: Home domain Name for the device to populate the request URI for REGISTRATION<BR><BR>
+<DT><A HREF="desc.html#/Customization/Wifi/DomRoamMaxUsers"><B>DomRoamMaxUsers</B></A> - Leaf Node<BR><BR>
+<HR><BR><A NAME="_E_"><!-- --></A>
+<DT><A HREF="desc.html#/CDMA/EHRPD"><B>EHRPD</B></A> - Interior Node: CDMA EHRPD interior node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Eight"><B>Eight</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Eighteenth"><B>Eighteenth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Eigth"><B>Eigth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Eleventh"><B>Eleventh</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Elevnth"><B>Elevnth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Enable"><B>Enable</B></A> - Leaf Node: IPV6Enable node Enabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Enable"><B>Enable</B></A> - Leaf Node: APN Enabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Enable"><B>Enable</B></A> - Leaf Node: APN Enabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Enable"><B>Enable</B></A> - Leaf Node: APN Enabled<BR><BR>
+<DT><A HREF="desc.html#/CDMA/1xA/Enabled"><B>Enabled</B></A> - Leaf Node: CDMA 1x enabled<BR><BR>
+<DT><A HREF="desc.html#/LTE/Service/Enabled"><B>Enabled</B></A> - Leaf Node: LTE service enabled.<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting/Enabled"><B>Enabled</B></A> - Leaf Node: IPV6Enable node Enabled/Disabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Enabled"><B>Enabled</B></A> - Leaf Node: APN Enabled/Disabled<BR><BR>
+<DT><A HREF="desc.html#/CDMA/EHRPD/Enabled"><B>Enabled</B></A> - Leaf Node: eHRPD enabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Enabled"><B>Enabled</B></A> - Leaf Node: APN Enabled/Disabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Enabled"><B>Enabled</B></A> - Leaf Node: APN Enabled/Disabled<BR><BR>
+<DT><A HREF="desc.html#/Con/HPPTT/Enabled"><B>Enabled</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Enabled"><B>Enabled</B></A> - Leaf Node: APN Enabled/Disabled<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Enabled"><B>Enabled</B></A> - Leaf Node: APN Enabled/Disabled<BR><BR>
+<DT><A HREF="desc.html#/Customization/EnabledApps"><B>EnabledApps</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/B25/enablement"><B>enablement</B></A> - Leaf Node: CDMA B25 enablement.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/B26/enablement"><B>enablement</B></A> - Leaf Node: CDMA B26 enablement.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/B41/enablement"><B>enablement</B></A> - Leaf Node: CDMA B41 enablement.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/ESNV"><B>ESNV</B></A> - Leaf Node: ESN version.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext"><B>Ext</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/DevInfo/Ext"><B>Ext</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/Ext"><B>Ext</B></A> - Interior Node: An optional, internal node, designating the only branch of the DMAcc sub tree into which extensions can be added, permanently or dynamically.<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/ext"><B>ext</B></A> - Interior Node: ext Interior node<BR><BR>
+<HR><BR><A NAME="_F_"><!-- --></A>
+<DT><A HREF="desc.html#/Customization/ADC/Fifteenth"><B>Fifteenth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Fifth"><B>Fifth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Contacts/Fifth"><B>Fifth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Fifth"><B>Fifth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/First"><B>First</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Contacts/First"><B>First</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/First"><B>First</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/FlexV"><B>FlexV</B></A> - Leaf Node: Flex version.<BR><BR>
+<DT><A HREF="desc.html#/LTE/Service/Forced"><B>Forced</B></A> - Leaf Node: LTE service forced.<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Fourteenth"><B>Fourteenth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Fourth"><B>Fourth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Contacts/Fourth"><B>Fourth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Fourth"><B>Fourth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/FwV"><B>FwV</B></A> - Leaf Node: Firmware version.<BR><BR>
+<HR><BR><A NAME="_G_"><!-- --></A>
+<DT><A HREF="desc.html#/DevDetail/Bearer/GSM"><B>GSM</B></A> - Leaf Node: the node is used to store the information related to Technology<BR><BR>
+<DT><A HREF="desc.html#/DevInfo/Bearer/GSM"><B>GSM</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Wifi/GSMMaxUsers"><B>GSMMaxUsers</B></A> - Leaf Node<BR><BR>
+<HR><BR><A NAME="_H_"><!-- --></A>
+<DT><A HREF="desc.html#/Customization/RoamPreference/HomeOnly"><B>HomeOnly</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Browser/Homepage"><B>Homepage</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/DiagMon/RF/HomeRoam"><B>HomeRoam</B></A> - Leaf Node: Home or Roaming Flag (Home, Roam).<BR><BR>
+<DT><A HREF="desc.html#/Con/HPPTT"><B>HPPTT</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/HwV"><B>HwV</B></A> - Leaf Node: Hardware version.<BR><BR>
+<HR><BR><A NAME="_I_"><!-- --></A>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Id"><B>Id</B></A> - Leaf Node: APN Id<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Id"><B>Id</B></A> - Leaf Node: APN Id<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Id"><B>Id</B></A> - Leaf Node: APN Id<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Id"><B>Id</B></A> - Leaf Node: APN Id<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Id"><B>Id</B></A> - Leaf Node: APN Id<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IMS"><B>IMS</B></A> - Interior Node: IMS Interior node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Wifi/IntRoamMaxUsers"><B>IntRoamMaxUsers</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/IP"><B>IP</B></A> - Leaf Node: IP Version.Defined by Standards but not used by Verizon Wireless<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/IP"><B>IP</B></A> - Leaf Node: IP Version.Defined by Standards but not used by Verizon Wireless<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/IP"><B>IP</B></A> - Leaf Node: IP Version.Defined by Standards but not used by Verizon Wireless<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/IP"><B>IP</B></A> - Leaf Node: IP Version.Defined by Standards but not used by Verizon Wireless<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/IP"><B>IP</B></A> - Leaf Node: IP Version.Defined by Standards but not used by Verizon Wireless<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable"><B>IPV6Enable</B></A> - Interior Node: IPV6Enable Interior node<BR><BR>
+<HR><BR><A NAME="_L_"><!-- --></A>
+<DT><A HREF="desc.html#/DevInfo/Lang"><B>Lang</B></A> - Leaf Node: The current language setting of the device. The syntax of the language tags and their use are defined in [RFC1766]. Language codes are defined by ISO in the standard ISO639.<BR><BR>
+<DT><A HREF="desc.html#/DevInfo/LangAuto"><B>LangAuto</B></A> - Leaf Node: This node determines whether the language setting should be 'auto' or not.<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/Ext/LastClientAuthType"><B>LastClientAuthType</B></A> - Leaf Node: The client authentication type requested by the server in the last session<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext/LastUpdateTime"><B>LastUpdateTime</B></A> - Leaf Node: Last Update Date Stamp.<BR><BR>
+<DT><A HREF="desc.html#/Customization/LaunchID"><B>LaunchID</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/LaunchZone"><B>LaunchZone</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/DevInfo/Loc"><B>Loc</B></A> - Leaf Node: The current location (country) setting of the device. Country codes are defined by ISO in the standard ISO 3166.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/LrgObj"><B>LrgObj</B></A> - Leaf Node: Indicates whether the device supports the SyncML Large Object Handling specification<BR><BR>
+<DT><A HREF="desc.html#/LTE"><B>LTE</B></A> - Interior Node: LTE node for Sprint HFA.<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE"><B>LTE</B></A> - Interior Node: LTE Interior node<BR><BR>
+<HR><BR><A NAME="_M_"><!-- --></A>
+<DT><A HREF="desc.html#/DevInfo/Man"><B>Man</B></A> - Leaf Node: The manufacturer identifier.<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects"><B>ManagedObjects</B></A> - Interior Node: A collection of all Subscriber Device Management MOs.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/URI/MaxDepth"><B>MaxDepth</B></A> - Leaf Node: Specifies the maximum depth of the management tree supported by the device. The maximum depth of the tree is defined as the maximum number of URI segments that the device supports. The value is a 16 bit, unsigned integer encoded as a numerical string. The value '0' means that the device supports a tree of 'unlimited' depth.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/URI/MaxSegLen"><B>MaxSegLen</B></A> - Leaf Node: Specifies the maximum total length of any URI segment in a URI used to address a node or node property. The maximum total length of a URI segment is defined as the largest number of characters which the device can support in a single URI segment. Note that depending on the used character set this might not be the same as the number of bytes. The value is a 16 bit, unsigned integer encoded as a numerical string. The value '0' means that the device supports URI segments of 'unlimited' length.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/URI/MaxTotLen"><B>MaxTotLen</B></A> - Leaf Node: Specifies the maximum total length of any URI used to address a node or node property. The maximum total length of a URI is defined as the largest total number of characters making up the URI which the device can support. Note that depending on the character set this might not be the same as the number of bytes. The value is a 16 bit, unsigned integer encoded as a numerical string. The value '0' means that the device supports URI of 'unlimited' length.<BR><BR>
+<DT><A HREF="desc.html#/Customization/Wifi/MaxUsers"><B>MaxUsers</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/RoamPreference/MenuDisplay"><B>MenuDisplay</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/MMS"><B>MMS</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/NAM/MobDirNum"><B>MobDirNum</B></A> - Leaf Node: CDMA MDN.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/MobileIpAddress"><B>MobileIpAddress</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Android/ClientID/MobileSearch"><B>MobileSearch</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/DevInfo/Mod"><B>Mod</B></A> - Leaf Node: A model identifier<BR><BR>
+<HR><BR><A NAME="_N_"><!-- --></A>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/NAI"><B>NAI</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/NAM"><B>NAM</B></A> - Interior Node: CDMA NAM interior node<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/Name"><B>Name</B></A> - Leaf Node: Displayable name for the SyncML DM settings<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Name"><B>Name</B></A> - Leaf Node: APN Name<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Name"><B>Name</B></A> - Leaf Node: APN Name<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Name"><B>Name</B></A> - Leaf Node: APN Name<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Name"><B>Name</B></A> - Leaf Node: APN Name<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Name"><B>Name</B></A> - Leaf Node: APN Name<BR><BR>
+<DT><A HREF="desc.html#/Customization/Android/OperatorID/NetworkCode"><B>NetworkCode</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/LTE/nextLTEscan"><B>nextLTEscan</B></A> - Leaf Node: LTE extended next scan interval.<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Ninth"><B>Ninth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Ninth"><B>Ninth</B></A> - Leaf Node<BR><BR>
+<HR><BR><A NAME="_O_"><!-- --></A>
+<DT><A HREF="desc.html#/DevDetail/OEM"><B>OEM</B></A> - Leaf Node: Original Equipment Manufacturer.<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations"><B>Operations</B></A> - Interior Node: Interior node holding APN status<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations"><B>Operations</B></A> - Interior Node: Interior node holding APN status<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations"><B>Operations</B></A> - Interior Node: Interior node holding APN status<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations"><B>Operations</B></A> - Interior Node: Interior node holding APN status<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations"><B>Operations</B></A> - Interior Node: Interior node holding APN status<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations"><B>Operations</B></A> - Interior Node: Interior node holding APN status<BR><BR>
+<DT><A HREF="desc.html#/Customization/Android/OperatorID"><B>OperatorID</B></A> - Interior Node<BR><BR>
+<HR><BR><A NAME="_P_"><!-- --></A>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/PasswordAAA"><B>PasswordAAA</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/PasswordHA"><B>PasswordHA</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAddr/*/Port"><B>Port</B></A> - Interior Node: port information <BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/AppAddr/*/Port/*/PortNbr"><B>PortNbr</B></A> - Leaf Node: Server port number<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/PrefConRef"><B>PrefConRef</B></A> - Leaf Node: Preferred connectivity profile<BR><BR>
+<DT><A HREF="desc.html#/CDMA/PRL/PrefRoamList"><B>PrefRoamList</B></A> - Leaf Node: CDMA PRL node.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext/PreFwV"><B>PreFwV</B></A> - Leaf Node: Previous firmware version prior to an update.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/PRIChecksum"><B>PRIChecksum</B></A> - Leaf Node: PRI checksum.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/PriHAIp"><B>PriHAIp</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/PRL"><B>PRL</B></A> - Interior Node: CDMA PRL node for Sprint HFA.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/PRLV"><B>PRLV</B></A> - Leaf Node: PRL version.<BR><BR>
+<DT><A HREF="desc.html#/CSIM/ProvObj"><B>ProvObj</B></A> - Leaf Node: CDMA ProvObj.<BR><BR>
+<DT><A HREF="desc.html#/Customization/MMS/Proxy"><B>Proxy</B></A> - Leaf Node<BR><BR>
+<HR><BR><A NAME="_R_"><!-- --></A>
+<DT><A HREF="desc.html#/RemoteCommands"><B>RemoteCommands</B></A> - Interior Node: Remote command interior node for Sprint.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/ReverseTunneling"><B>ReverseTunneling</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/DiagMon/RF"><B>RF</B></A> - Interior Node: Device RF Details like System Type, Roam, RSSI etc.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/RoamPreference"><B>RoamPreference</B></A> - Leaf Node: CDMA roaming preference.<BR><BR>
+<DT><A HREF="desc.html#/Customization/RoamPreference"><B>RoamPreference</B></A> - Interior Node<BR><BR>
+<HR><BR><A NAME="_S_"><!-- --></A>
+<DT><A HREF="desc.html#/CDMA/B25/scanpriority"><B>scanpriority</B></A> - Leaf Node: CDMA B25 scan priority.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/B26/scanpriority"><B>scanpriority</B></A> - Leaf Node: CDMA B26 scan priority.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/B41/scanpriority"><B>scanpriority</B></A> - Leaf Node: CDMA B41 scan priority.<BR><BR>
+<DT><A HREF="desc.html#/Customization/Browser/SearchEngine"><B>SearchEngine</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/SecHAIp"><B>SecHAIp</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Second"><B>Second</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Second"><B>Second</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Contacts/Second"><B>Second</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/ServerID"><B>ServerID</B></A> - Leaf Node: The "ServerId" value for this server<BR><BR>
+<DT><A HREF="desc.html#/Customization/MMS/ServerUrl"><B>ServerUrl</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/LTE/Service"><B>Service</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting"><B>Setting</B></A> - Interior Node: Setting Interior node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting"><B>Setting</B></A> - Interior Node: Setting Interior node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting"><B>Setting</B></A> - Interior Node: Setting Interior node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting"><B>Setting</B></A> - Interior Node: Setting Interior node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting"><B>Setting</B></A> - Interior Node: Setting Interior node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting"><B>Setting</B></A> - Interior Node: Setting Interior node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting"><B>Setting</B></A> - Interior Node: Setting Interior node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/ext/Settings"><B>Settings</B></A> - Interior Node: Settings Interior node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Seventeenth"><B>Seventeenth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Seventh"><B>Seventh</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Seventh"><B>Seventh</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/SIM"><B>SIM</B></A> - Interior Node: SIM node for Sprint HFA.<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/SIPT1"><B>SIPT1</B></A> - Leaf Node: SIP T1 Timer<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/SIPT2"><B>SIPT2</B></A> - Leaf Node: SIP T2 Timer<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/SIPTf"><B>SIPTf</B></A> - Leaf Node: SIP TF Timer<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Sixteenth"><B>Sixteenth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Sixth"><B>Sixth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Sixth"><B>Sixth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Contacts/Sixth"><B>Sixth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/EnabledApps/Skyfire"><B>Skyfire</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/sms_over_IP_network_indication"><B>sms_over_IP_network_indication</B></A> - Leaf Node: Turns IMS ON/OFF on the device<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/smsformat"><B>smsformat</B></A> - Leaf Node: Device Outgoing SMS based on either 3GP or 3GPP2 Standards<BR><BR>
+<DT><A HREF="desc.html#/CDMA/SO68"><B>SO68</B></A> - Leaf Node: CDMA SO68.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/SO73"><B>SO73</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/DevInfo/Sort"><B>Sort</B></A> - Leaf Node: The current language sorting comparator for this device.<BR><BR>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/SpiAAA"><B>SpiAAA</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/CDMA/3GPD/*/SpiHA"><B>SpiHA</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Wifi/SSID"><B>SSID</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Subscriber/State"><B>State</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Subscriber"><B>Subscriber</B></A> - Interior Node: Subscriber node for Sprint HFA.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/SwV"><B>SwV</B></A> - Leaf Node: Software version.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext/SystemSettings"><B>SystemSettings</B></A> - Interior Node: System Settings node<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext/SystemV"><B>SystemV</B></A> - Leaf Node: The concatenated version information of all FOTA updatable partitions in following order: System + DSP (Modem) + Normal Boot + Logo + LBL + CDT&ATAGS + BPL + MBM.<BR><BR>
+<HR><BR><A NAME="_T_"><!-- --></A>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/ext/Settings/t_1xRTT"><B>t_1xRTT</B></A> - Leaf Node: Timer for periodic 1xRTT system scan<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/ext/Settings/t_mpsr"><B>t_mpsr</B></A> - Leaf Node: Timer for periodic multimode system scan<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/ext/Settings/tbsr_cdma"><B>tbsr_cdma</B></A> - Leaf Node: Timer for periodic cdma system scan<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Tenth"><B>Tenth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Tenth"><B>Tenth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/TetheredData"><B>TetheredData</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Third"><B>Third</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Third"><B>Third</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/Contacts/Third"><B>Third</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Thirteenth"><B>Thirteenth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext/DateTime/TimeUTC"><B>TimeUTC</B></A> - Leaf Node: Last Update UTC Time Stamp.<BR><BR>
+<DT><A HREF="desc.html#/DMAcc/*/ToConRef"><B>ToConRef</B></A> - Interior Node: The "name" node for connectivity reference subtree<BR><BR>
+<DT><A HREF="desc.html#/Customization/EnabledApps/Touch"><B>Touch</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/ADC/Twelfth"><B>Twelfth</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/CallIntercept/Twelfth"><B>Twelfth</B></A> - Leaf Node<BR><BR>
+<HR><BR><A NAME="_U_"><!-- --></A>
+<DT><A HREF="desc.html#/Customization/Browser/UAProfURL"><B>UAProfURL</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/SIM/UICCID"><B>UICCID</B></A> - Leaf Node: SIM UICCID.<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/URI"><B>URI</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/Subscriber/UsageMode"><B>UsageMode</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Con/HPPTT/UserAddress"><B>UserAddress</B></A> - Leaf Node<BR><BR>
+<HR><BR><A NAME="_V_"><!-- --></A>
+<DT><A HREF="desc.html#/ManagedObjects/DiagMon/RF/CurrentSystem/Voice"><B>Voice</B></A> - Leaf Node: Current voice system<BR><BR>
+<DT><A HREF="desc.html#/Customization/EnabledApps/VoWifi"><B>VoWifi</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/Customization/EnabledApps/VVM"><B>VVM</B></A> - Leaf Node<BR><BR>
+<DT><A HREF="desc.html#/ManagedObjects/ConnMO/VZW800"><B>VZW800</B></A> - Interior Node: VZW800 Interior node<BR><BR>
+<HR><BR><A NAME="_W_"><!-- --></A>
+<DT><A HREF="desc.html#/Customization/Wifi"><B>Wifi</B></A> - Interior Node<BR><BR>
+<DT><A HREF="desc.html#/DevDetail/Ext/WLANMacAddr"><B>WLANMacAddr</B></A> - Leaf Node: Wi-Fi MAC address.<BR><BR>
+<HR><BR><A NAME="_Y_"><!-- --></A>
+<DT><A HREF="desc.html#/Customization/Android/ClientID/Youtube"><B>Youtube</B></A> - Leaf Node<BR><BR>
+<HR><BR><A NAME="_Z_"><!-- --></A>
+<DT><A HREF="desc.html#/Subscriber/ZIPCode"><B>ZIPCode</B></A> - Leaf Node<BR><BR>
+</DL>
+<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"><TR ALIGN="center" VALIGN="top"><TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1"> &nbsp;<A HREF="desc.html"><FONT CLASS="NavBarFont1"><B>Node List</B></FONT></A>&nbsp;</TD><TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1Rev"><FONT CLASS="NavBarFont1Rev"><B>Index</B></FONT>&nbsp;</TD></TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR></TABLE><A HREF="#_A_">A</A>&nbsp;&nbsp;<A HREF="#_B_">B</A>&nbsp;&nbsp;<A HREF="#_C_">C</A>&nbsp;&nbsp;<A HREF="#_D_">D</A>&nbsp;&nbsp;<A HREF="#_E_">E</A>&nbsp;&nbsp;<A HREF="#_F_">F</A>&nbsp;&nbsp;<A HREF="#_G_">G</A>&nbsp;&nbsp;<A HREF="#_H_">H</A>&nbsp;&nbsp;<A HREF="#_I_">I</A>&nbsp;&nbsp;<A HREF="#_L_">L</A>&nbsp;&nbsp;<A HREF="#_M_">M</A>&nbsp;&nbsp;<A HREF="#_N_">N</A>&nbsp;&nbsp;<A HREF="#_O_">O</A>&nbsp;&nbsp;<A HREF="#_P_">P</A>&nbsp;&nbsp;<A HREF="#_R_">R</A>&nbsp;&nbsp;<A HREF="#_S_">S</A>&nbsp;&nbsp;<A HREF="#_T_">T</A>&nbsp;&nbsp;<A HREF="#_U_">U</A>&nbsp;&nbsp;<A HREF="#_V_">V</A>&nbsp;&nbsp;<A HREF="#_W_">W</A>&nbsp;&nbsp;<A HREF="#_Y_">Y</A>&nbsp;&nbsp;<A HREF="#_Z_">Z</A>&nbsp;&nbsp;
+</HTML>
diff --git a/setting/dmt_data/docs/index.html b/setting/dmt_data/docs/index.html
new file mode 100644
index 0000000..7efa401
--- /dev/null
+++ b/setting/dmt_data/docs/index.html
@@ -0,0 +1,12 @@
+<HTML>
+<HEAD>
+<TITLE>
+Device Management Tree Documentation
+</TITLE>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+</HEAD>
+<FRAMESET cols="40%,60%">
+<FRAME src="toc.html" name="tocFrame">
+<FRAME src="desc.html" name="descFrame">
+</FRAMESET>
+</HTML>
diff --git a/setting/dmt_data/docs/toc.html b/setting/dmt_data/docs/toc.html
new file mode 100644
index 0000000..33c062c
--- /dev/null
+++ b/setting/dmt_data/docs/toc.html
@@ -0,0 +1,600 @@
+<HTML>
+<HEAD>
+<TITLE>
+TOC
+</TITLE>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+</HEAD>
+<BODY BGCOLOR="white">
+<TABLE BORDER="0" WIDTH="100%">
+<TR>
+<TD NOWRAP>
+<A HREF="desc.html#." TARGET="descFrame">.</A>
+<BR>
+<A HREF="desc.html#/CDMA" TARGET="descFrame">/CDMA</A>
+<BR>
+<A HREF="desc.html#/CDMA/BC10" TARGET="descFrame">/CDMA/BC10</A>
+<BR>
+<A HREF="desc.html#/CDMA/BC14" TARGET="descFrame">/CDMA/BC14</A>
+<BR>
+<A HREF="desc.html#/CDMA/RoamPreference" TARGET="descFrame">/CDMA/RoamPreference</A>
+<BR>
+<A HREF="desc.html#/CDMA/SO68" TARGET="descFrame">/CDMA/SO68</A>
+<BR>
+<A HREF="desc.html#/CDMA/1xA" TARGET="descFrame">/CDMA/1xA</A>
+<BR>
+<A HREF="desc.html#/CDMA/1xA/Enabled" TARGET="descFrame">/CDMA/1xA/Enabled</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD" TARGET="descFrame">/CDMA/3GPD</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*" TARGET="descFrame">/CDMA/3GPD/*</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/AuthAlgoAAA" TARGET="descFrame">/CDMA/3GPD/*/AuthAlgoAAA</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/AuthAlgoHA" TARGET="descFrame">/CDMA/3GPD/*/AuthAlgoHA</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/MobileIpAddress" TARGET="descFrame">/CDMA/3GPD/*/MobileIpAddress</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/NAI" TARGET="descFrame">/CDMA/3GPD/*/NAI</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/PasswordAAA" TARGET="descFrame">/CDMA/3GPD/*/PasswordAAA</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/PasswordHA" TARGET="descFrame">/CDMA/3GPD/*/PasswordHA</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/PriHAIp" TARGET="descFrame">/CDMA/3GPD/*/PriHAIp</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/ReverseTunneling" TARGET="descFrame">/CDMA/3GPD/*/ReverseTunneling</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/SecHAIp" TARGET="descFrame">/CDMA/3GPD/*/SecHAIp</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/SpiAAA" TARGET="descFrame">/CDMA/3GPD/*/SpiAAA</A>
+<BR>
+<A HREF="desc.html#/CDMA/3GPD/*/SpiHA" TARGET="descFrame">/CDMA/3GPD/*/SpiHA</A>
+<BR>
+<A HREF="desc.html#/CDMA/B25" TARGET="descFrame">/CDMA/B25</A>
+<BR>
+<A HREF="desc.html#/CDMA/B25/enablement" TARGET="descFrame">/CDMA/B25/enablement</A>
+<BR>
+<A HREF="desc.html#/CDMA/B25/scanpriority" TARGET="descFrame">/CDMA/B25/scanpriority</A>
+<BR>
+<A HREF="desc.html#/CDMA/B26" TARGET="descFrame">/CDMA/B26</A>
+<BR>
+<A HREF="desc.html#/CDMA/B26/enablement" TARGET="descFrame">/CDMA/B26/enablement</A>
+<BR>
+<A HREF="desc.html#/CDMA/B26/scanpriority" TARGET="descFrame">/CDMA/B26/scanpriority</A>
+<BR>
+<A HREF="desc.html#/CDMA/B41" TARGET="descFrame">/CDMA/B41</A>
+<BR>
+<A HREF="desc.html#/CDMA/B41/enablement" TARGET="descFrame">/CDMA/B41/enablement</A>
+<BR>
+<A HREF="desc.html#/CDMA/B41/scanpriority" TARGET="descFrame">/CDMA/B41/scanpriority</A>
+<BR>
+<A HREF="desc.html#/CDMA/EHRPD" TARGET="descFrame">/CDMA/EHRPD</A>
+<BR>
+<A HREF="desc.html#/CDMA/EHRPD/Enabled" TARGET="descFrame">/CDMA/EHRPD/Enabled</A>
+<BR>
+<A HREF="desc.html#/CDMA/NAM" TARGET="descFrame">/CDMA/NAM</A>
+<BR>
+<A HREF="desc.html#/CDMA/NAM/CdmaNam" TARGET="descFrame">/CDMA/NAM/CdmaNam</A>
+<BR>
+<A HREF="desc.html#/CDMA/NAM/MobDirNum" TARGET="descFrame">/CDMA/NAM/MobDirNum</A>
+<BR>
+<A HREF="desc.html#/CDMA/PRL" TARGET="descFrame">/CDMA/PRL</A>
+<BR>
+<A HREF="desc.html#/CDMA/PRL/PrefRoamList" TARGET="descFrame">/CDMA/PRL/PrefRoamList</A>
+<BR>
+<A HREF="desc.html#/CDMA/SO73" TARGET="descFrame">/CDMA/SO73</A>
+<BR>
+<A HREF="desc.html#/CDMA/SO73/COP0" TARGET="descFrame">/CDMA/SO73/COP0</A>
+<BR>
+<A HREF="desc.html#/CDMA/SO73/COP1to7" TARGET="descFrame">/CDMA/SO73/COP1to7</A>
+<BR>
+<A HREF="desc.html#/Con" TARGET="descFrame">/Con</A>
+<BR>
+<A HREF="desc.html#/Con/HPPTT" TARGET="descFrame">/Con/HPPTT</A>
+<BR>
+<A HREF="desc.html#/Con/HPPTT/Enabled" TARGET="descFrame">/Con/HPPTT/Enabled</A>
+<BR>
+<A HREF="desc.html#/Con/HPPTT/UserAddress" TARGET="descFrame">/Con/HPPTT/UserAddress</A>
+<BR>
+<A HREF="desc.html#/CSIM" TARGET="descFrame">/CSIM</A>
+<BR>
+<A HREF="desc.html#/CSIM/CoverageObj" TARGET="descFrame">/CSIM/CoverageObj</A>
+<BR>
+<A HREF="desc.html#/CSIM/ProvObj" TARGET="descFrame">/CSIM/ProvObj</A>
+<BR>
+<A HREF="desc.html#/Customization" TARGET="descFrame">/Customization</A>
+<BR>
+<A HREF="desc.html#/Customization/BrandAlpha" TARGET="descFrame">/Customization/BrandAlpha</A>
+<BR>
+<A HREF="desc.html#/Customization/CarrierLegal" TARGET="descFrame">/Customization/CarrierLegal</A>
+<BR>
+<A HREF="desc.html#/Customization/CustID" TARGET="descFrame">/Customization/CustID</A>
+<BR>
+<A HREF="desc.html#/Customization/DiagMSLReq" TARGET="descFrame">/Customization/DiagMSLReq</A>
+<BR>
+<A HREF="desc.html#/Customization/LaunchID" TARGET="descFrame">/Customization/LaunchID</A>
+<BR>
+<A HREF="desc.html#/Customization/LaunchZone" TARGET="descFrame">/Customization/LaunchZone</A>
+<BR>
+<A HREF="desc.html#/Customization/TetheredData" TARGET="descFrame">/Customization/TetheredData</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC" TARGET="descFrame">/Customization/ADC</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Eighteenth" TARGET="descFrame">/Customization/ADC/Eighteenth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Eigth" TARGET="descFrame">/Customization/ADC/Eigth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Elevnth" TARGET="descFrame">/Customization/ADC/Elevnth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Fifteenth" TARGET="descFrame">/Customization/ADC/Fifteenth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Fifth" TARGET="descFrame">/Customization/ADC/Fifth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/First" TARGET="descFrame">/Customization/ADC/First</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Fourteenth" TARGET="descFrame">/Customization/ADC/Fourteenth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Fourth" TARGET="descFrame">/Customization/ADC/Fourth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Ninth" TARGET="descFrame">/Customization/ADC/Ninth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Second" TARGET="descFrame">/Customization/ADC/Second</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Seventeenth" TARGET="descFrame">/Customization/ADC/Seventeenth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Seventh" TARGET="descFrame">/Customization/ADC/Seventh</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Sixteenth" TARGET="descFrame">/Customization/ADC/Sixteenth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Sixth" TARGET="descFrame">/Customization/ADC/Sixth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Tenth" TARGET="descFrame">/Customization/ADC/Tenth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Third" TARGET="descFrame">/Customization/ADC/Third</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Thirteenth" TARGET="descFrame">/Customization/ADC/Thirteenth</A>
+<BR>
+<A HREF="desc.html#/Customization/ADC/Twelfth" TARGET="descFrame">/Customization/ADC/Twelfth</A>
+<BR>
+<A HREF="desc.html#/Customization/Android" TARGET="descFrame">/Customization/Android</A>
+<BR>
+<A HREF="desc.html#/Customization/Android/ClientID" TARGET="descFrame">/Customization/Android/ClientID</A>
+<BR>
+<A HREF="desc.html#/Customization/Android/ClientID/AndroidMarket" TARGET="descFrame">/Customization/Android/ClientID/AndroidMarket</A>
+<BR>
+<A HREF="desc.html#/Customization/Android/ClientID/MobileSearch" TARGET="descFrame">/Customization/Android/ClientID/MobileSearch</A>
+<BR>
+<A HREF="desc.html#/Customization/Android/ClientID/Youtube" TARGET="descFrame">/Customization/Android/ClientID/Youtube</A>
+<BR>
+<A HREF="desc.html#/Customization/Android/OperatorID" TARGET="descFrame">/Customization/Android/OperatorID</A>
+<BR>
+<A HREF="desc.html#/Customization/Android/OperatorID/NetworkCode" TARGET="descFrame">/Customization/Android/OperatorID/NetworkCode</A>
+<BR>
+<A HREF="desc.html#/Customization/Browser" TARGET="descFrame">/Customization/Browser</A>
+<BR>
+<A HREF="desc.html#/Customization/Browser/Homepage" TARGET="descFrame">/Customization/Browser/Homepage</A>
+<BR>
+<A HREF="desc.html#/Customization/Browser/SearchEngine" TARGET="descFrame">/Customization/Browser/SearchEngine</A>
+<BR>
+<A HREF="desc.html#/Customization/Browser/UAProfURL" TARGET="descFrame">/Customization/Browser/UAProfURL</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept" TARGET="descFrame">/Customization/CallIntercept</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Eight" TARGET="descFrame">/Customization/CallIntercept/Eight</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Eleventh" TARGET="descFrame">/Customization/CallIntercept/Eleventh</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Fifth" TARGET="descFrame">/Customization/CallIntercept/Fifth</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/First" TARGET="descFrame">/Customization/CallIntercept/First</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Fourth" TARGET="descFrame">/Customization/CallIntercept/Fourth</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Ninth" TARGET="descFrame">/Customization/CallIntercept/Ninth</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Second" TARGET="descFrame">/Customization/CallIntercept/Second</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Seventh" TARGET="descFrame">/Customization/CallIntercept/Seventh</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Sixth" TARGET="descFrame">/Customization/CallIntercept/Sixth</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Tenth" TARGET="descFrame">/Customization/CallIntercept/Tenth</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Third" TARGET="descFrame">/Customization/CallIntercept/Third</A>
+<BR>
+<A HREF="desc.html#/Customization/CallIntercept/Twelfth" TARGET="descFrame">/Customization/CallIntercept/Twelfth</A>
+<BR>
+<A HREF="desc.html#/Customization/Contacts" TARGET="descFrame">/Customization/Contacts</A>
+<BR>
+<A HREF="desc.html#/Customization/Contacts/Fifth" TARGET="descFrame">/Customization/Contacts/Fifth</A>
+<BR>
+<A HREF="desc.html#/Customization/Contacts/First" TARGET="descFrame">/Customization/Contacts/First</A>
+<BR>
+<A HREF="desc.html#/Customization/Contacts/Fourth" TARGET="descFrame">/Customization/Contacts/Fourth</A>
+<BR>
+<A HREF="desc.html#/Customization/Contacts/Second" TARGET="descFrame">/Customization/Contacts/Second</A>
+<BR>
+<A HREF="desc.html#/Customization/Contacts/Sixth" TARGET="descFrame">/Customization/Contacts/Sixth</A>
+<BR>
+<A HREF="desc.html#/Customization/Contacts/Third" TARGET="descFrame">/Customization/Contacts/Third</A>
+<BR>
+<A HREF="desc.html#/Customization/EnabledApps" TARGET="descFrame">/Customization/EnabledApps</A>
+<BR>
+<A HREF="desc.html#/Customization/EnabledApps/Skyfire" TARGET="descFrame">/Customization/EnabledApps/Skyfire</A>
+<BR>
+<A HREF="desc.html#/Customization/EnabledApps/Touch" TARGET="descFrame">/Customization/EnabledApps/Touch</A>
+<BR>
+<A HREF="desc.html#/Customization/EnabledApps/VoWifi" TARGET="descFrame">/Customization/EnabledApps/VoWifi</A>
+<BR>
+<A HREF="desc.html#/Customization/EnabledApps/VVM" TARGET="descFrame">/Customization/EnabledApps/VVM</A>
+<BR>
+<A HREF="desc.html#/Customization/MMS" TARGET="descFrame">/Customization/MMS</A>
+<BR>
+<A HREF="desc.html#/Customization/MMS/Proxy" TARGET="descFrame">/Customization/MMS/Proxy</A>
+<BR>
+<A HREF="desc.html#/Customization/MMS/ServerUrl" TARGET="descFrame">/Customization/MMS/ServerUrl</A>
+<BR>
+<A HREF="desc.html#/Customization/RoamPreference" TARGET="descFrame">/Customization/RoamPreference</A>
+<BR>
+<A HREF="desc.html#/Customization/RoamPreference/HomeOnly" TARGET="descFrame">/Customization/RoamPreference/HomeOnly</A>
+<BR>
+<A HREF="desc.html#/Customization/RoamPreference/MenuDisplay" TARGET="descFrame">/Customization/RoamPreference/MenuDisplay</A>
+<BR>
+<A HREF="desc.html#/Customization/Wifi" TARGET="descFrame">/Customization/Wifi</A>
+<BR>
+<A HREF="desc.html#/Customization/Wifi/DomRoamMaxUsers" TARGET="descFrame">/Customization/Wifi/DomRoamMaxUsers</A>
+<BR>
+<A HREF="desc.html#/Customization/Wifi/GSMMaxUsers" TARGET="descFrame">/Customization/Wifi/GSMMaxUsers</A>
+<BR>
+<A HREF="desc.html#/Customization/Wifi/IntRoamMaxUsers" TARGET="descFrame">/Customization/Wifi/IntRoamMaxUsers</A>
+<BR>
+<A HREF="desc.html#/Customization/Wifi/MaxUsers" TARGET="descFrame">/Customization/Wifi/MaxUsers</A>
+<BR>
+<A HREF="desc.html#/Customization/Wifi/SSID" TARGET="descFrame">/Customization/Wifi/SSID</A>
+<BR>
+<A HREF="desc.html#/DevDetail" TARGET="descFrame">/DevDetail</A>
+<BR>
+<A HREF="desc.html#/DevDetail/DevTyp" TARGET="descFrame">/DevDetail/DevTyp</A>
+<BR>
+<A HREF="desc.html#/DevDetail/ESNV" TARGET="descFrame">/DevDetail/ESNV</A>
+<BR>
+<A HREF="desc.html#/DevDetail/FlexV" TARGET="descFrame">/DevDetail/FlexV</A>
+<BR>
+<A HREF="desc.html#/DevDetail/FwV" TARGET="descFrame">/DevDetail/FwV</A>
+<BR>
+<A HREF="desc.html#/DevDetail/HwV" TARGET="descFrame">/DevDetail/HwV</A>
+<BR>
+<A HREF="desc.html#/DevDetail/LrgObj" TARGET="descFrame">/DevDetail/LrgObj</A>
+<BR>
+<A HREF="desc.html#/DevDetail/OEM" TARGET="descFrame">/DevDetail/OEM</A>
+<BR>
+<A HREF="desc.html#/DevDetail/PRIChecksum" TARGET="descFrame">/DevDetail/PRIChecksum</A>
+<BR>
+<A HREF="desc.html#/DevDetail/PRLV" TARGET="descFrame">/DevDetail/PRLV</A>
+<BR>
+<A HREF="desc.html#/DevDetail/SwV" TARGET="descFrame">/DevDetail/SwV</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Bearer" TARGET="descFrame">/DevDetail/Bearer</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Bearer/CDMA" TARGET="descFrame">/DevDetail/Bearer/CDMA</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Bearer/GSM" TARGET="descFrame">/DevDetail/Bearer/GSM</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext" TARGET="descFrame">/DevDetail/Ext</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext/LastUpdateTime" TARGET="descFrame">/DevDetail/Ext/LastUpdateTime</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext/PreFwV" TARGET="descFrame">/DevDetail/Ext/PreFwV</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext/SystemV" TARGET="descFrame">/DevDetail/Ext/SystemV</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext/WLANMacAddr" TARGET="descFrame">/DevDetail/Ext/WLANMacAddr</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext/DateTime" TARGET="descFrame">/DevDetail/Ext/DateTime</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext/DateTime/Date" TARGET="descFrame">/DevDetail/Ext/DateTime/Date</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext/DateTime/TimeUTC" TARGET="descFrame">/DevDetail/Ext/DateTime/TimeUTC</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext/SystemSettings" TARGET="descFrame">/DevDetail/Ext/SystemSettings</A>
+<BR>
+<A HREF="desc.html#/DevDetail/Ext/SystemSettings/AllowUnknownSources" TARGET="descFrame">/DevDetail/Ext/SystemSettings/AllowUnknownSources</A>
+<BR>
+<A HREF="desc.html#/DevDetail/URI" TARGET="descFrame">/DevDetail/URI</A>
+<BR>
+<A HREF="desc.html#/DevDetail/URI/MaxDepth" TARGET="descFrame">/DevDetail/URI/MaxDepth</A>
+<BR>
+<A HREF="desc.html#/DevDetail/URI/MaxSegLen" TARGET="descFrame">/DevDetail/URI/MaxSegLen</A>
+<BR>
+<A HREF="desc.html#/DevDetail/URI/MaxTotLen" TARGET="descFrame">/DevDetail/URI/MaxTotLen</A>
+<BR>
+<A HREF="desc.html#/DevInfo" TARGET="descFrame">/DevInfo</A>
+<BR>
+<A HREF="desc.html#/DevInfo/DevId" TARGET="descFrame">/DevInfo/DevId</A>
+<BR>
+<A HREF="desc.html#/DevInfo/DmV" TARGET="descFrame">/DevInfo/DmV</A>
+<BR>
+<A HREF="desc.html#/DevInfo/Lang" TARGET="descFrame">/DevInfo/Lang</A>
+<BR>
+<A HREF="desc.html#/DevInfo/LangAuto" TARGET="descFrame">/DevInfo/LangAuto</A>
+<BR>
+<A HREF="desc.html#/DevInfo/Loc" TARGET="descFrame">/DevInfo/Loc</A>
+<BR>
+<A HREF="desc.html#/DevInfo/Man" TARGET="descFrame">/DevInfo/Man</A>
+<BR>
+<A HREF="desc.html#/DevInfo/Mod" TARGET="descFrame">/DevInfo/Mod</A>
+<BR>
+<A HREF="desc.html#/DevInfo/Sort" TARGET="descFrame">/DevInfo/Sort</A>
+<BR>
+<A HREF="desc.html#/DevInfo/Bearer" TARGET="descFrame">/DevInfo/Bearer</A>
+<BR>
+<A HREF="desc.html#/DevInfo/Bearer/GSM" TARGET="descFrame">/DevInfo/Bearer/GSM</A>
+<BR>
+<A HREF="desc.html#/DevInfo/Ext" TARGET="descFrame">/DevInfo/Ext</A>
+<BR>
+<A HREF="desc.html#/DMAcc" TARGET="descFrame">/DMAcc</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*" TARGET="descFrame">/DMAcc/*</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AAuthPref" TARGET="descFrame">/DMAcc/*/AAuthPref</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppID" TARGET="descFrame">/DMAcc/*/AppID</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/Name" TARGET="descFrame">/DMAcc/*/Name</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/PrefConRef" TARGET="descFrame">/DMAcc/*/PrefConRef</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/ServerID" TARGET="descFrame">/DMAcc/*/ServerID</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAddr" TARGET="descFrame">/DMAcc/*/AppAddr</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAddr/*" TARGET="descFrame">/DMAcc/*/AppAddr/*</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAddr/*/Addr" TARGET="descFrame">/DMAcc/*/AppAddr/*/Addr</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAddr/*/AddrType" TARGET="descFrame">/DMAcc/*/AppAddr/*/AddrType</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAddr/*/Port" TARGET="descFrame">/DMAcc/*/AppAddr/*/Port</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAddr/*/Port/*" TARGET="descFrame">/DMAcc/*/AppAddr/*/Port/*</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAddr/*/Port/*/PortNbr" TARGET="descFrame">/DMAcc/*/AppAddr/*/Port/*/PortNbr</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAuth" TARGET="descFrame">/DMAcc/*/AppAuth</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAuth/*" TARGET="descFrame">/DMAcc/*/AppAuth/*</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthData" TARGET="descFrame">/DMAcc/*/AppAuth/*/AAuthData</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthLevel" TARGET="descFrame">/DMAcc/*/AppAuth/*/AAuthLevel</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthName" TARGET="descFrame">/DMAcc/*/AppAuth/*/AAuthName</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthSecret" TARGET="descFrame">/DMAcc/*/AppAuth/*/AAuthSecret</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/AppAuth/*/AAuthType" TARGET="descFrame">/DMAcc/*/AppAuth/*/AAuthType</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/Ext" TARGET="descFrame">/DMAcc/*/Ext</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/Ext/LastClientAuthType" TARGET="descFrame">/DMAcc/*/Ext/LastClientAuthType</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/ToConRef" TARGET="descFrame">/DMAcc/*/ToConRef</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/ToConRef/*" TARGET="descFrame">/DMAcc/*/ToConRef/*</A>
+<BR>
+<A HREF="desc.html#/DMAcc/*/ToConRef/*/ConRef" TARGET="descFrame">/DMAcc/*/ToConRef/*/ConRef</A>
+<BR>
+<A HREF="desc.html#/LTE" TARGET="descFrame">/LTE</A>
+<BR>
+<A HREF="desc.html#/LTE/BSRMaxTime" TARGET="descFrame">/LTE/BSRMaxTime</A>
+<BR>
+<A HREF="desc.html#/LTE/BSRTimer" TARGET="descFrame">/LTE/BSRTimer</A>
+<BR>
+<A HREF="desc.html#/LTE/nextLTEscan" TARGET="descFrame">/LTE/nextLTEscan</A>
+<BR>
+<A HREF="desc.html#/LTE/APN" TARGET="descFrame">/LTE/APN</A>
+<BR>
+<A HREF="desc.html#/LTE/APN/0" TARGET="descFrame">/LTE/APN/0</A>
+<BR>
+<A HREF="desc.html#/LTE/APN/1" TARGET="descFrame">/LTE/APN/1</A>
+<BR>
+<A HREF="desc.html#/LTE/APN/2" TARGET="descFrame">/LTE/APN/2</A>
+<BR>
+<A HREF="desc.html#/LTE/APN/3" TARGET="descFrame">/LTE/APN/3</A>
+<BR>
+<A HREF="desc.html#/LTE/APN/4" TARGET="descFrame">/LTE/APN/4</A>
+<BR>
+<A HREF="desc.html#/LTE/APN/5" TARGET="descFrame">/LTE/APN/5</A>
+<BR>
+<A HREF="desc.html#/LTE/APN/6" TARGET="descFrame">/LTE/APN/6</A>
+<BR>
+<A HREF="desc.html#/LTE/APN/7" TARGET="descFrame">/LTE/APN/7</A>
+<BR>
+<A HREF="desc.html#/LTE/Service" TARGET="descFrame">/LTE/Service</A>
+<BR>
+<A HREF="desc.html#/LTE/Service/Enabled" TARGET="descFrame">/LTE/Service/Enabled</A>
+<BR>
+<A HREF="desc.html#/LTE/Service/Forced" TARGET="descFrame">/LTE/Service/Forced</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects" TARGET="descFrame">/ManagedObjects</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO" TARGET="descFrame">/ManagedObjects/ConnMO</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/ext" TARGET="descFrame">/ManagedObjects/ConnMO/ext</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/ext/Settings" TARGET="descFrame">/ManagedObjects/ConnMO/ext/Settings</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/ext/Settings/t_1xRTT" TARGET="descFrame">/ManagedObjects/ConnMO/ext/Settings/t_1xRTT</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/ext/Settings/t_mpsr" TARGET="descFrame">/ManagedObjects/ConnMO/ext/Settings/t_mpsr</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/ext/Settings/tbsr_cdma" TARGET="descFrame">/ManagedObjects/ConnMO/ext/Settings/tbsr_cdma</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IMS" TARGET="descFrame">/ManagedObjects/ConnMO/IMS</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting" TARGET="descFrame">/ManagedObjects/ConnMO/IMS/Setting</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/Domain" TARGET="descFrame">/ManagedObjects/ConnMO/IMS/Setting/Domain</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/SIPT1" TARGET="descFrame">/ManagedObjects/ConnMO/IMS/Setting/SIPT1</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/SIPT2" TARGET="descFrame">/ManagedObjects/ConnMO/IMS/Setting/SIPT2</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/SIPTf" TARGET="descFrame">/ManagedObjects/ConnMO/IMS/Setting/SIPTf</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/sms_over_IP_network_indication" TARGET="descFrame">/ManagedObjects/ConnMO/IMS/Setting/sms_over_IP_network_indication</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IMS/Setting/smsformat" TARGET="descFrame">/ManagedObjects/ConnMO/IMS/Setting/smsformat</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable" TARGET="descFrame">/ManagedObjects/ConnMO/IPV6Enable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting" TARGET="descFrame">/ManagedObjects/ConnMO/IPV6Enable/Setting</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting/Enabled" TARGET="descFrame">/ManagedObjects/ConnMO/IPV6Enable/Setting/Enabled</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations" TARGET="descFrame">/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Disable" TARGET="descFrame">/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Disable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Enable" TARGET="descFrame">/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Enable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE" TARGET="descFrame">/ManagedObjects/ConnMO/LTE</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/1</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/1/Setting</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Enabled" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/1/Setting/Enabled</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Id" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/1/Setting/Id</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/IP" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/1/Setting/IP</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Name" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/1/Setting/Name</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations/Disable" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations/Disable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/2</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/2/Setting</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Enabled" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/2/Setting/Enabled</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Id" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/2/Setting/Id</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/IP" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/2/Setting/IP</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Name" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/2/Setting/Name</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations/Disable" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations/Disable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/3</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/3/Setting</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Enabled" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/3/Setting/Enabled</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Id" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/3/Setting/Id</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/IP" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/3/Setting/IP</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Name" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/3/Setting/Name</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Disable" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Disable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Enable" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Enable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/4</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/4/Setting</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Enabled" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/4/Setting/Enabled</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Id" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/4/Setting/Id</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/IP" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/4/Setting/IP</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Name" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/4/Setting/Name</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Disable" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Disable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Enable" TARGET="descFrame">/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Enable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN/5</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN/5/Setting</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Enabled" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Enabled</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Id" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Id</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/IP" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN/5/Setting/IP</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Name" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Name</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Disable" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Disable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Enable" TARGET="descFrame">/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Enable</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/DiagMon" TARGET="descFrame">/ManagedObjects/DiagMon</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/DiagMon/RF" TARGET="descFrame">/ManagedObjects/DiagMon/RF</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/DiagMon/RF/HomeRoam" TARGET="descFrame">/ManagedObjects/DiagMon/RF/HomeRoam</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/DiagMon/RF/CurrentSystem" TARGET="descFrame">/ManagedObjects/DiagMon/RF/CurrentSystem</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/DiagMon/RF/CurrentSystem/Data" TARGET="descFrame">/ManagedObjects/DiagMon/RF/CurrentSystem/Data</A>
+<BR>
+<A HREF="desc.html#/ManagedObjects/DiagMon/RF/CurrentSystem/Voice" TARGET="descFrame">/ManagedObjects/DiagMon/RF/CurrentSystem/Voice</A>
+<BR>
+<A HREF="desc.html#/RemoteCommands" TARGET="descFrame">/RemoteCommands</A>
+<BR>
+<A HREF="desc.html#/RemoteCommands/Command" TARGET="descFrame">/RemoteCommands/Command</A>
+<BR>
+<A HREF="desc.html#/SIM" TARGET="descFrame">/SIM</A>
+<BR>
+<A HREF="desc.html#/SIM/UICCID" TARGET="descFrame">/SIM/UICCID</A>
+<BR>
+<A HREF="desc.html#/Subscriber" TARGET="descFrame">/Subscriber</A>
+<BR>
+<A HREF="desc.html#/Subscriber/AcctSubType" TARGET="descFrame">/Subscriber/AcctSubType</A>
+<BR>
+<A HREF="desc.html#/Subscriber/AcctType" TARGET="descFrame">/Subscriber/AcctType</A>
+<BR>
+<A HREF="desc.html#/Subscriber/BAN" TARGET="descFrame">/Subscriber/BAN</A>
+<BR>
+<A HREF="desc.html#/Subscriber/BillCycleDate" TARGET="descFrame">/Subscriber/BillCycleDate</A>
+<BR>
+<A HREF="desc.html#/Subscriber/CarrierID" TARGET="descFrame">/Subscriber/CarrierID</A>
+<BR>
+<A HREF="desc.html#/Subscriber/CSA" TARGET="descFrame">/Subscriber/CSA</A>
+<BR>
+<A HREF="desc.html#/Subscriber/State" TARGET="descFrame">/Subscriber/State</A>
+<BR>
+<A HREF="desc.html#/Subscriber/UsageMode" TARGET="descFrame">/Subscriber/UsageMode</A>
+<BR>
+<A HREF="desc.html#/Subscriber/ZIPCode" TARGET="descFrame">/Subscriber/ZIPCode</A>
+<BR>
+</TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>
diff --git a/setting/dmt_data/fstab b/setting/dmt_data/fstab
new file mode 100644
index 0000000..125936a
--- /dev/null
+++ b/setting/dmt_data/fstab
@@ -0,0 +1,13 @@
+#PATH FILENAME (MUST END WITH .WBXML) fOR NOW, ALL subfile do not overlap
+# first file always is .
+#
+# Also parent URI must be BEFORE child URI
+#
+# This is a sample fstab - PLEASE EDIT this file to match your own tree!!!
+#
+. root.wbxml
+./DevDetail/Ext devdetail_ext.wbxml
+./DevDetail/URI devdetail_uri.wbxml
+./ManagedObjects managedobjects.wbxml
+./Customization customization.wbxml
+./Subscriber subscriber.wbxml
diff --git a/setting/dmt_data/managedobjects.wbxml b/setting/dmt_data/managedobjects.wbxml
new file mode 100644
index 0000000..85de5b6
--- /dev/null
+++ b/setting/dmt_data/managedobjects.wbxml
Binary files differ
diff --git a/setting/dmt_data/managedobjects.xml b/setting/dmt_data/managedobjects.xml
new file mode 100644
index 0000000..c5b6602
--- /dev/null
+++ b/setting/dmt_data/managedobjects.xml
@@ -0,0 +1,21 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>ManagedObjects</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+</MgmtTree>
diff --git a/setting/dmt_data/root.bmdf b/setting/dmt_data/root.bmdf
new file mode 100644
index 0000000..5ee9221
--- /dev/null
+++ b/setting/dmt_data/root.bmdf
Binary files differ
diff --git a/setting/dmt_data/root.mdf b/setting/dmt_data/root.mdf
new file mode 100644
index 0000000..637c65f
--- /dev/null
+++ b/setting/dmt_data/root.mdf
@@ -0,0 +1,1099 @@
+[.]
+type:node
+access:Get,Replace,Add,Delete,Exec
+mime:text/plain
+[/CDMA]
+type:node
+access:Get
+[/CDMA/BC10]
+type:int
+access:Get,Replace
+[/CDMA/BC14]
+type:int
+access:Get,Replace
+[/CDMA/RoamPreference]
+type:bin
+access:Get,Replace
+[/CDMA/SO68]
+type:int
+access:Get,Replace
+[/CDMA/1xA]
+type:node
+access:Get
+[/CDMA/1xA/Enabled]
+type:int
+access:Replace,Get
+[/CDMA/3GPD]
+type:node
+access:Get
+[/CDMA/3GPD/*]
+type:node
+access:Get,Add,Replace,Delete
+[/CDMA/3GPD/*/AuthAlgoAAA]
+type:chr
+access:Add,Get,Replace,Delete
+mime:text/plain
+[/CDMA/3GPD/*/AuthAlgoHA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/MobileIpAddress]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/NAI]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/PasswordAAA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/PasswordHA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/PriHAIp]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/ReverseTunneling]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/SecHAIp]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/SpiAAA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/3GPD/*/SpiHA]
+type:chr
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/B25]
+type:node
+access:Get
+[/CDMA/B25/enablement]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B25/scanpriority]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B26]
+type:node
+access:Get
+[/CDMA/B26/enablement]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B26/scanpriority]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B41]
+type:node
+access:Get
+[/CDMA/B41/enablement]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/B41/scanpriority]
+type:int
+access:Get,Replace
+mime:text/plain
+[/CDMA/EHRPD]
+type:node
+access:Get
+[/CDMA/EHRPD/Enabled]
+type:int
+access:Get,Replace,Add,Delete
+mime:text/plain
+[/CDMA/NAM]
+type:node
+access:Get
+[/CDMA/NAM/CdmaNam]
+type:bin
+access:Get,Replace
+mime:text/plain
+[/CDMA/NAM/MobDirNum]
+type:bin
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/CDMA/PRL]
+type:node
+access:Get,Replace
+[/CDMA/PRL/PrefRoamList]
+type:bin
+access:Get,Replace
+[/CDMA/SO73]
+type:node
+access:Get
+[/CDMA/SO73/COP0]
+type:int
+access:Replace,Get
+[/CDMA/SO73/COP1to7]
+type:int
+access:Replace,Get
+[/Con]
+type:node
+access:Get,Replace
+[/Con/HPPTT]
+type:node
+access:Get,Replace
+[/Con/HPPTT/Enabled]
+type:bool
+access:Replace,Get,Delete
+[/Con/HPPTT/UserAddress]
+type:chr
+access:Replace,Get,Delete
+[/CSIM]
+type:node
+access:Get
+[/CSIM/CoverageObj]
+type:bin
+access:Get,Replace
+mime:text/plain
+[/CSIM/ProvObj]
+type:bin
+access:Get,Replace
+mime:text/plain
+[/Customization]
+type:node
+access:Get,Add,Replace
+[/Customization/BrandAlpha]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CarrierLegal]
+type:bin
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CustID]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/Customization/DiagMSLReq]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/LaunchID]
+type:int
+access:Get,Add,Replace,Delete
+[/Customization/LaunchZone]
+type:int
+access:Get,Add,Replace,Delete
+[/Customization/TetheredData]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC]
+type:node
+access:Get,Add,Replace
+[/Customization/ADC/Eighteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Eigth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Elevnth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Fifteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Fifth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/First]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Fourteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Fourth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Ninth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Second]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Seventeenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Seventh]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Sixteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Sixth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Tenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Third]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Thirteenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/ADC/Twelfth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Android]
+type:node
+access:Get,Add,Replace
+[/Customization/Android/ClientID]
+type:node
+access:Get,Add,Replace
+[/Customization/Android/ClientID/AndroidMarket]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Android/ClientID/MobileSearch]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Android/ClientID/Youtube]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Android/OperatorID]
+type:node
+access:Get,Add,Replace
+[/Customization/Android/OperatorID/NetworkCode]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Browser]
+type:node
+access:Get,Add,Replace
+[/Customization/Browser/Homepage]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Browser/SearchEngine]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Browser/UAProfURL]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept]
+type:node
+access:Get,Add,Replace
+[/Customization/CallIntercept/Eight]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Eleventh]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Fifth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/First]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Fourth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Ninth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Second]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Seventh]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Sixth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Tenth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Third]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/CallIntercept/Twelfth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts]
+type:node
+access:Get,Add,Replace
+[/Customization/Contacts/Fifth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/First]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/Fourth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/Second]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/Sixth]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Contacts/Third]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/EnabledApps]
+type:node
+access:Get,Add,Replace
+[/Customization/EnabledApps/Skyfire]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/EnabledApps/Touch]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/EnabledApps/VoWifi]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/EnabledApps/VVM]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/MMS]
+type:node
+access:Get,Add,Replace
+[/Customization/MMS/Proxy]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/MMS/ServerUrl]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/RoamPreference]
+type:node
+access:Get,Add,Replace
+[/Customization/RoamPreference/HomeOnly]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/RoamPreference/MenuDisplay]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi]
+type:node
+access:Get,Add,Replace
+[/Customization/Wifi/DomRoamMaxUsers]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi/GSMMaxUsers]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi/IntRoamMaxUsers]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi/MaxUsers]
+type:int
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/Customization/Wifi/SSID]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DevDetail]
+type:node
+access:Get
+[/DevDetail/DevTyp]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/DevDetail/ESNV]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevDetail/FlexV]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevDetail/FwV]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+default:1.0
+[/DevDetail/HwV]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/DevDetail/LrgObj]
+type:bool
+access:Get
+mime:text/plain
+default:true
+[/DevDetail/OEM]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/DevDetail/PRIChecksum]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevDetail/PRLV]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevDetail/SwV]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/DevDetail/Bearer]
+type:node
+access:Get,Replace
+[/DevDetail/Bearer/CDMA]
+type:chr
+maxLen:16
+access:Get,Replace
+mime:text/plain
+[/DevDetail/Bearer/GSM]
+type:chr
+maxLen:16
+access:Get,Replace
+mime:text/plain
+[/DevDetail/Ext]
+type:node
+access:Get,Add
+[/DevDetail/Ext/LastUpdateTime]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/PreFwV]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/SystemV]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/WLANMacAddr]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/DateTime]
+type:node
+access:Get
+[/DevDetail/Ext/DateTime/Date]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/DateTime/TimeUTC]
+type:chr
+access:Get
+mime:text/plain
+[/DevDetail/Ext/SystemSettings]
+type:node
+access:Get
+[/DevDetail/Ext/SystemSettings/AllowUnknownSources]
+type:bool
+mime:text/plain
+access:Get,Replace
+[/DevDetail/URI]
+type:node
+access:Get
+[/DevDetail/URI/MaxDepth]
+type:int
+access:Get
+mime:text/plain
+[/DevDetail/URI/MaxSegLen]
+type:int
+access:Get
+mime:text/plain
+[/DevDetail/URI/MaxTotLen]
+type:int
+access:Get
+mime:text/plain
+[/DevInfo]
+type:node
+access:Get
+[/DevInfo/DevId]
+type:chr
+maxLen:31
+access:Get,Add,Replace
+mime:text/plain
+default:1.0
+[/DevInfo/DmV]
+type:chr
+maxLen:31
+access:Get,Add,Replace
+mime:text/plain
+default:1.0
+[/DevInfo/Lang]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevInfo/LangAuto]
+type:bool
+mime:text/plain
+access:Get,Replace
+[/DevInfo/Loc]
+type:chr
+maxLen:2
+access:Get,Replace
+mime:text/plain
+[/DevInfo/Man]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+[/DevInfo/Mod]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+default:1.0
+[/DevInfo/Sort]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/DevInfo/Bearer]
+type:node
+access:Get,Add,Replace,Delete
+[/DevInfo/Bearer/GSM]
+type:chr
+maxLen:31
+access:Get,Replace
+mime:text/plain
+default:1.0
+[/DevInfo/Ext]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AAuthPref]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppID]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/Name]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/PrefConRef]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/ServerID]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAddr]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAddr/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAddr/*/Addr]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAddr/*/AddrType]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAddr/*/Port]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAddr/*/Port/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAddr/*/Port/*/PortNbr]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAuth]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAuth/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/AppAuth/*/AAuthData]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAuth/*/AAuthLevel]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+values:CLCRED,SRVCRED,OBEX,HTTP
+[/DMAcc/*/AppAuth/*/AAuthName]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAuth/*/AAuthSecret]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/AppAuth/*/AAuthType]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+values:HTTP-BASIC,HTTP-DIGEST,BASIC,DIGEST,HMAC,X509,SECUREID,SAFEWORD,DIGIPASS,TRANSPORT
+[/DMAcc/*/Ext]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/Ext/LastClientAuthType]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/DMAcc/*/ToConRef]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/ToConRef/*]
+type:node
+access:Get,Add,Replace,Delete
+[/DMAcc/*/ToConRef/*/ConRef]
+type:chr
+access:Get,Add,Replace,Delete
+mime:text/plain
+[/LTE]
+type:node
+access:Get
+[/LTE/BSRMaxTime]
+type:int
+access:Get,Replace
+[/LTE/BSRTimer]
+type:int
+access:Get,Replace
+[/LTE/nextLTEscan]
+type:int
+access:Get,Replace
+[/LTE/APN]
+type:node
+access:Get
+[/LTE/APN/0]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/1]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/2]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/3]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/4]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/5]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/6]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/APN/7]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/LTE/Service]
+type:node
+access:Get
+[/LTE/Service/Enabled]
+type:int
+access:Get,Replace
+[/LTE/Service/Forced]
+type:int
+access:Get,Replace
+[/ManagedObjects]
+type:node
+access:Get,Add,Replace,Delete
+[/ManagedObjects/ConnMO]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/ext]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/ext/Settings]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/ext/Settings/t_1xRTT]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/ext/Settings/t_mpsr]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/ext/Settings/tbsr_cdma]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IMS/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IMS/Setting/Domain]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/SIPT1]
+type:int
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/SIPT2]
+type:int
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/SIPTf]
+type:int
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/sms_over_IP_network_indication]
+type:bool
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IMS/Setting/smsformat]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/IPV6Enable]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IPV6Enable/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IPV6Enable/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/IPV6Enable/Setting/Operations/Enable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/2]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/3]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations/Enable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/4]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations/Enable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/VZW800]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Enabled]
+type:bool
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Id]
+type:int
+mime:text/plain
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/IP]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Name]
+type:chr
+mime:text/plain
+access:Get,Replace
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations]
+type:node
+access:Get
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Disable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations/Enable]
+type:bool
+mime:text/plain
+access:Get,Exec
+[/ManagedObjects/DiagMon]
+type:node
+access:Get
+[/ManagedObjects/DiagMon/RF]
+type:node
+access:Get
+[/ManagedObjects/DiagMon/RF/HomeRoam]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/ManagedObjects/DiagMon/RF/CurrentSystem]
+type:node
+access:Get
+[/ManagedObjects/DiagMon/RF/CurrentSystem/Data]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/ManagedObjects/DiagMon/RF/CurrentSystem/Voice]
+type:chr
+maxLen:31
+access:Get
+mime:text/plain
+[/RemoteCommands]
+type:node
+access:Get
+[/RemoteCommands/Command]
+type:chr
+access:Get,Exec
+mime:text/plain
+[/SIM]
+type:node
+access:Get
+[/SIM/UICCID]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber]
+type:node
+access:Get,Replace
+[/Subscriber/AcctSubType]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/AcctType]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/BAN]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/BillCycleDate]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/CarrierID]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/CSA]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/State]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/UsageMode]
+type:chr
+access:Get,Replace
+mime:text/plain
+[/Subscriber/ZIPCode]
+type:chr
+access:Get,Replace
+mime:text/plain
diff --git a/setting/dmt_data/root.wbxml b/setting/dmt_data/root.wbxml
new file mode 100644
index 0000000..9c8f64e
--- /dev/null
+++ b/setting/dmt_data/root.wbxml
Binary files differ
diff --git a/setting/dmt_data/root.xml b/setting/dmt_data/root.xml
new file mode 100644
index 0000000..1bb9b84
--- /dev/null
+++ b/setting/dmt_data/root.xml
@@ -0,0 +1,313 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>.</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ <Add/>
+ <Delete/>
+ <Exec/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>DevDetail</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>ESNV</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>1.0</Data>
+ </Node>
+
+ <Node>
+ <NodeName>FlexV</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>1.0</Data>
+ </Node>
+
+ <Node>
+ <NodeName>LrgObj</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>true</Data>
+ </Node>
+
+ <Node>
+ <NodeName>OEM</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>Google</Data>
+ </Node>
+
+ <Node>
+ <NodeName>PRIChecksum</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>111111</Data>
+ </Node>
+
+ <Node>
+ <NodeName>PRLV</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>1.0</Data>
+ </Node>
+
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>CDMA</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>GSM</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>1900-GSM</Data>
+ </Node>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>DevInfo</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>LangAuto</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>false</Data>
+ </Node>
+
+ <Node>
+ <NodeName>Loc</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>US</Data>
+ </Node>
+
+ <Node>
+ <NodeName>Sort</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ <Data>Latin</Data>
+ </Node>
+
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>GSM</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>Ext</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+
+ <Node>
+ <NodeName>DMAcc</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Add/>
+ <Replace/>
+ <Delete/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>RemoteCommands</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>Command</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Exec/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/setting/dmt_data/subscriber.wbxml b/setting/dmt_data/subscriber.wbxml
new file mode 100644
index 0000000..18969c8
--- /dev/null
+++ b/setting/dmt_data/subscriber.wbxml
Binary files differ
diff --git a/setting/dmt_data/subscriber.xml b/setting/dmt_data/subscriber.xml
new file mode 100644
index 0000000..db2502c
--- /dev/null
+++ b/setting/dmt_data/subscriber.xml
@@ -0,0 +1,145 @@
+<MgmtTree>
+ <VerDTD>1.1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+
+ <Node>
+ <NodeName>Subscriber</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+
+ <Node>
+ <NodeName>AcctSubType</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>AcctType</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>BAN</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>BillCycleDate</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>CarrierID</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>CSA</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>State</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>UsageMode</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+
+ <Node>
+ <NodeName>ZIPCode</NodeName>
+ <DFProperties>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ </DFProperties>
+ <Type>text/plain</Type>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/setting/dmt_data/syncmldm.ddf b/setting/dmt_data/syncmldm.ddf
new file mode 100644
index 0000000..ec723ce
--- /dev/null
+++ b/setting/dmt_data/syncmldm.ddf
@@ -0,0 +1,5720 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE MgmtTree SYSTEM "http://www.openmobilealliance.com/tech/DTD/dm_ddf-v1_2.dtd">
+<MgmtTree>
+ <VerDTD>1.2</VerDTD>
+ <Man>Motorola</Man>
+ <Mod>Nexus</Mod>
+ <Node>
+ <NodeName>.</NodeName>
+ <Path></Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Exec/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>CDMA</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>BC10</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>BC14</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>RoamPreference</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SO68</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>1xA</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./CDMA/1xA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>3GPD</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./CDMA/3GPD</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AuthAlgoAAA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AuthAlgoHA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MobileIpAddress</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>NAI</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PasswordAAA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PasswordHA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PriHAIp</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ReverseTunneling</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SecHAIp</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SpiAAA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SpiHA</NodeName>
+ <Path>./CDMA/3GPD/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>B25</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>enablement</NodeName>
+ <Path>./CDMA/B25</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>scanpriority</NodeName>
+ <Path>./CDMA/B25</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>B26</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>enablement</NodeName>
+ <Path>./CDMA/B26</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>scanpriority</NodeName>
+ <Path>./CDMA/B26</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>B41</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>enablement</NodeName>
+ <Path>./CDMA/B41</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>scanpriority</NodeName>
+ <Path>./CDMA/B41</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>EHRPD</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./CDMA/EHRPD</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>NAM</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>CdmaNam</NodeName>
+ <Path>./CDMA/NAM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MobDirNum</NodeName>
+ <Path>./CDMA/NAM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>PRL</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>PrefRoamList</NodeName>
+ <Path>./CDMA/PRL</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>SO73</NodeName>
+ <Path>./CDMA</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>COP0</NodeName>
+ <Path>./CDMA/SO73</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>COP1to7</NodeName>
+ <Path>./CDMA/SO73</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Con</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>HPPTT</NodeName>
+ <Path>./Con</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./Con/HPPTT</Path>
+ <DFProperties>
+ <AccessType>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>UserAddress</NodeName>
+ <Path>./Con/HPPTT</Path>
+ <DFProperties>
+ <AccessType>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>CSIM</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>CoverageObj</NodeName>
+ <Path>./CSIM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ProvObj</NodeName>
+ <Path>./CSIM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Customization</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>BrandAlpha</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CarrierLegal</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CustID</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>DiagMSLReq</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LaunchID</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LaunchZone</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>TetheredData</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ADC</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Eighteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Eigth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Elevnth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fifteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>First</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fourteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Ninth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Second</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Seventeenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Seventh</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sixteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Tenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Third</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Thirteenth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Twelfth</NodeName>
+ <Path>./Customization/ADC</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Android</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>ClientID</NodeName>
+ <Path>./Customization/Android</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AndroidMarket</NodeName>
+ <Path>./Customization/Android/ClientID</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MobileSearch</NodeName>
+ <Path>./Customization/Android/ClientID</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Youtube</NodeName>
+ <Path>./Customization/Android/ClientID</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>OperatorID</NodeName>
+ <Path>./Customization/Android</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>NetworkCode</NodeName>
+ <Path>./Customization/Android/OperatorID</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Browser</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Homepage</NodeName>
+ <Path>./Customization/Browser</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SearchEngine</NodeName>
+ <Path>./Customization/Browser</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>UAProfURL</NodeName>
+ <Path>./Customization/Browser</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>CallIntercept</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Eight</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Eleventh</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>First</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Ninth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Second</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Seventh</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Tenth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Third</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Twelfth</NodeName>
+ <Path>./Customization/CallIntercept</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Contacts</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Fifth</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>First</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Fourth</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Second</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sixth</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Third</NodeName>
+ <Path>./Customization/Contacts</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>EnabledApps</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Skyfire</NodeName>
+ <Path>./Customization/EnabledApps</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Touch</NodeName>
+ <Path>./Customization/EnabledApps</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>VoWifi</NodeName>
+ <Path>./Customization/EnabledApps</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>VVM</NodeName>
+ <Path>./Customization/EnabledApps</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>MMS</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Proxy</NodeName>
+ <Path>./Customization/MMS</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ServerUrl</NodeName>
+ <Path>./Customization/MMS</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>RoamPreference</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>HomeOnly</NodeName>
+ <Path>./Customization/RoamPreference</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MenuDisplay</NodeName>
+ <Path>./Customization/RoamPreference</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Wifi</NodeName>
+ <Path>./Customization</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>DomRoamMaxUsers</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>GSMMaxUsers</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IntRoamMaxUsers</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MaxUsers</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SSID</NodeName>
+ <Path>./Customization/Wifi</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DevDetail</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>DevTyp</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ESNV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>FlexV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>FwV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>HwV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LrgObj</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>OEM</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PRIChecksum</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PRLV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SwV</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>CDMA</NodeName>
+ <Path>./DevDetail/Bearer</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>GSM</NodeName>
+ <Path>./DevDetail/Bearer</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>LastUpdateTime</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PreFwV</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SystemV</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>WLANMacAddr</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>DateTime</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Date</NodeName>
+ <Path>./DevDetail/Ext/DateTime</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>TimeUTC</NodeName>
+ <Path>./DevDetail/Ext/DateTime</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>SystemSettings</NodeName>
+ <Path>./DevDetail/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AllowUnknownSources</NodeName>
+ <Path>./DevDetail/Ext/SystemSettings</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>URI</NodeName>
+ <Path>./DevDetail</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>MaxDepth</NodeName>
+ <Path>./DevDetail/URI</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MaxSegLen</NodeName>
+ <Path>./DevDetail/URI</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MaxTotLen</NodeName>
+ <Path>./DevDetail/URI</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DevInfo</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>DevId</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>DmV</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Lang</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LangAuto</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Loc</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Man</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Mod</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Sort</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>GSM</NodeName>
+ <Path>./DevInfo/Bearer</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <Path>./DevInfo</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DMAcc</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AAuthPref</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AppID</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PrefConRef</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ServerID</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AppAddr</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc/*/AppAddr</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Addr</NodeName>
+ <Path>./DMAcc/*/AppAddr/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AddrType</NodeName>
+ <Path>./DMAcc/*/AppAddr/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Port</NodeName>
+ <Path>./DMAcc/*/AppAddr/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc/*/AppAddr/*/Port</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>PortNbr</NodeName>
+ <Path>./DMAcc/*/AppAddr/*/Port/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>AppAuth</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc/*/AppAuth</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AAuthData</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthLevel</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthName</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthSecret</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthType</NodeName>
+ <Path>./DMAcc/*/AppAuth/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>LastClientAuthType</NodeName>
+ <Path>./DMAcc/*/Ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>ToConRef</NodeName>
+ <Path>./DMAcc/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName/>
+ <Path>./DMAcc/*/ToConRef</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>ConRef</NodeName>
+ <Path>./DMAcc/*/ToConRef/*</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>LTE</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>BSRMaxTime</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>BSRTimer</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>nextLTEscan</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>APN</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>0</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>1</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>2</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>3</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>4</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>5</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>6</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>7</NodeName>
+ <Path>./LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Service</NodeName>
+ <Path>./LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./LTE/Service</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Forced</NodeName>
+ <Path>./LTE/Service</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>ManagedObjects</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>ConnMO</NodeName>
+ <Path>./ManagedObjects</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>ext</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Settings</NodeName>
+ <Path>./ManagedObjects/ConnMO/ext</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>t_1xRTT</NodeName>
+ <Path>./ManagedObjects/ConnMO/ext/Settings</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>t_mpsr</NodeName>
+ <Path>./ManagedObjects/ConnMO/ext/Settings</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>tbsr_cdma</NodeName>
+ <Path>./ManagedObjects/ConnMO/ext/Settings</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>IMS</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Domain</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SIPT1</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SIPT2</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SIPTf</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>sms_over_IP_network_indication</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>smsformat</NodeName>
+ <Path>./ManagedObjects/ConnMO/IMS/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>IPV6Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO/IPV6Enable/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>LTE</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>APN</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>1</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/1/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>2</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/2/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>3</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/3/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>4</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO/LTE/APN/4/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>VZW800</NodeName>
+ <Path>./ManagedObjects/ConnMO</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>APN</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>5</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Setting</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Enabled</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Id</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>IP</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Disable</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Enable</NodeName>
+ <Path>./ManagedObjects/ConnMO/VZW800/APN/5/Setting/Operations</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DiagMon</NodeName>
+ <Path>./ManagedObjects</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>RF</NodeName>
+ <Path>./ManagedObjects/DiagMon</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>HomeRoam</NodeName>
+ <Path>./ManagedObjects/DiagMon/RF</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CurrentSystem</NodeName>
+ <Path>./ManagedObjects/DiagMon/RF</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Data</NodeName>
+ <Path>./ManagedObjects/DiagMon/RF/CurrentSystem</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Voice</NodeName>
+ <Path>./ManagedObjects/DiagMon/RF/CurrentSystem</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>RemoteCommands</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>Command</NodeName>
+ <Path>./RemoteCommands</Path>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>SIM</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>UICCID</NodeName>
+ <Path>./SIM</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Subscriber</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ <Node>
+ <NodeName>AcctSubType</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AcctType</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>BAN</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>BillCycleDate</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CarrierID</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CSA</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>State</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>UsageMode</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ZIPCode</NodeName>
+ <Path>./Subscriber</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ <CaseSense>
+ <CS/>
+ </CaseSense>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/setting/event.dat b/setting/event.dat
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/setting/event.dat
diff --git a/setting/fstab b/setting/fstab
new file mode 100644
index 0000000..125936a
--- /dev/null
+++ b/setting/fstab
@@ -0,0 +1,13 @@
+#PATH FILENAME (MUST END WITH .WBXML) fOR NOW, ALL subfile do not overlap
+# first file always is .
+#
+# Also parent URI must be BEFORE child URI
+#
+# This is a sample fstab - PLEASE EDIT this file to match your own tree!!!
+#
+. root.wbxml
+./DevDetail/Ext devdetail_ext.wbxml
+./DevDetail/URI devdetail_uri.wbxml
+./ManagedObjects managedobjects.wbxml
+./Customization customization.wbxml
+./Subscriber subscriber.wbxml