201023
authorhgs
Tue, 13 Jul 2010 03:51:25 +0530
changeset 46 b9b00b134b0d
parent 45 0f9fc722d255
child 47 d316aecb87fd
201023
clientprovisioning/cpqtsp/cpqtsp.pro
clientprovisioning/cpqtsp/rom/cpqtsp.iby
devicemgmtdialogsplugin/devicemanagementnotifierdevman.qrc
devicemgmtdialogsplugin/devicemgmtdialogsplugin.pro
devicemgmtdialogsplugin/rom/devicemgmtdialogsplugin.iby
devicemgmtdialogsplugin/src/omacppinquerydialog.cpp
deviceupdatesui/deviceupdatesplugin/deviceupdatesplugin.pro
omadmadapters/bld/bld.inf
omadmadapters/email/bld/bld.inf
omadmadapters/email/bld/nsmldmemailadapter.mmp
omadmadapters/email/inc/nsmldmemailadapter.h
omadmadapters/email/sis/emailadapter.pkg
omadmadapters/email/sis/gensis.bat
omadmadapters/email/src/nsmldmemailadapter.cpp
omadmadapters/email/src/nsmldmemailadapter.rss
omadmadapters/email/tsrc/bwins/emailtestu.def
omadmadapters/email/tsrc/conf/emailtest.cfg
omadmadapters/email/tsrc/eabi/emailtestu.def
omadmadapters/email/tsrc/group/bld.inf
omadmadapters/email/tsrc/group/emailtest.mmp
omadmadapters/email/tsrc/group/emailtest.pkg
omadmadapters/email/tsrc/inc/TestDmDDFObject.h
omadmadapters/email/tsrc/inc/dmatest.h
omadmadapters/email/tsrc/inc/emailtest.h
omadmadapters/email/tsrc/init/emailtest.ini
omadmadapters/email/tsrc/src/TestDmDDFObject.cpp
omadmadapters/email/tsrc/src/dmatest.cpp
omadmadapters/email/tsrc/src/emailtest.cpp
omadmadapters/email/tsrc/src/emailtestBlocks.cpp
omadmadapters/nsmldmbmadapter/group/bld.inf
omadmadapters/nsmldmbmadapter/group/nsmldmbmadapter.mmp
omadmadapters/nsmldmbmadapter/inc/bmadapterlogger.h
omadmadapters/nsmldmbmadapter/inc/nsmldmbmadapter.h
omadmadapters/nsmldmbmadapter/inc/nsmldmbmadapter.inl
omadmadapters/nsmldmbmadapter/inc/nsmldmbmsettingstore.h
omadmadapters/nsmldmbmadapter/rom/nsmldmbmadapter.iby
omadmadapters/nsmldmbmadapter/src/nsmldmbmadapter.cpp
omadmadapters/nsmldmbmadapter/src/nsmldmbmadapter.rss
omadmadapters/nsmldmbmadapter/src/nsmldmbmsettingstore.cpp
omadmadapters/rom/omadmadapters.iby
omadmadapters/streamingadapter/bld/bld.inf
omadmadapters/streamingadapter/bld/nsmlstreamingadapter.mmp
omadmadapters/streamingadapter/conf/streamingadapter.confml
omadmadapters/streamingadapter/conf/streamingadapter_20024310.crml
omadmadapters/streamingadapter/inc/nsmlstreamingadapter.h
omadmadapters/streamingadapter/inc/streamingadapterCRKeys.h
omadmadapters/streamingadapter/src/nsmldmstreamingadapter.rss
omadmadapters/streamingadapter/src/nsmlstreamingadapter.cpp
--- a/clientprovisioning/cpqtsp/cpqtsp.pro	Tue Jul 13 03:48:30 2010 +0530
+++ b/clientprovisioning/cpqtsp/cpqtsp.pro	Tue Jul 13 03:51:25 2010 +0530
@@ -31,6 +31,7 @@
 }
 
 CONFIG += hb service
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
 include(Cpqtsp.pri)
 LIBS+=-lxqservice -lxqserviceutil -lflogger
 MMP_RULES += "LIBRARY msgs.lib centralrepository.lib provisioningengine.lib featmgr.lib apengine.lib favouritesengine.lib smcm.lib gsmu.lib"
--- a/clientprovisioning/cpqtsp/rom/cpqtsp.iby	Tue Jul 13 03:48:30 2010 +0530
+++ b/clientprovisioning/cpqtsp/rom/cpqtsp.iby	Tue Jul 13 03:51:25 2010 +0530
@@ -24,7 +24,4 @@
 file = ABI_DIR/BUILD_DIR/Cpqtsp.exe PROGRAMS_DIR/Cpqtsp.exe
 data = DATAZ_/private/10003a3f/import/apps/Cpqtsp_reg.rsc private/10003a3f/import/apps/Cpqtsp_reg.rsc
 
-data=/epoc32/data/z/resource/plugins/devicedialogs/devicemanagementnotifiersplugin.qtplugin		resource/plugins/devicedialogs/devicemanagementnotifiersplugin.qtplugin
-file=ABI_DIR/BUILD_DIR/devicemanagementnotifiersplugin.dll		SHARED_LIB_DIR/devicemanagementnotifiersplugin.dll
-
 #endif
\ No newline at end of file
--- a/devicemgmtdialogsplugin/devicemanagementnotifierdevman.qrc	Tue Jul 13 03:48:30 2010 +0530
+++ b/devicemgmtdialogsplugin/devicemanagementnotifierdevman.qrc	Tue Jul 13 03:51:25 2010 +0530
@@ -3,7 +3,7 @@
         <file>resources/dialog.docml</file>
         <file>resources/dialoginformative.docml</file>
         <file>resources/dialogserverpushconfirm.docml</file>
-        <file>resources/PIN.docml</file>
+        <file>resources/pin.docml</file>
     </qresource>
     <qresource prefix="/devman_icon" >
     	<file>resources/iconnotifier.svg</file>
--- a/devicemgmtdialogsplugin/devicemgmtdialogsplugin.pro	Tue Jul 13 03:48:30 2010 +0530
+++ b/devicemgmtdialogsplugin/devicemgmtdialogsplugin.pro	Tue Jul 13 03:51:25 2010 +0530
@@ -13,7 +13,7 @@
 # Contributors:
 #
 # Description: 
-#     Pro file of devicemanagementnotifiersplugin
+#     Pro file of devicemgmtdialogsplugin
 #
 #
 
@@ -23,6 +23,7 @@
           plugin        
 INCLUDEPATH += .
 DEPENDPATH += .
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
 
 DESTDIR = $${HB_BUILD_DIR}/plugins/devicedialogs
 
@@ -54,6 +55,10 @@
     pluginstub.path = /resource/plugins/devicedialogs
     DEPLOYMENT += pluginstub
     MMP_RULES += "LIBRARY syncmlclientapi.lib centralrepository.lib flogger.lib"
+    
+    BLD_INF_RULES.prj_exports += \
+  	"$${LITERAL_HASH}include <platform_paths.hrh>" \
+  	"rom/devicemgmtdialogsplugin.iby             CORE_APP_LAYER_IBY_EXPORT_PATH(devicemgmtdialogsplugin.iby)"
 }
 !local {
     target.path = $${HB_PLUGINS_DIR}/devicedialogs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtdialogsplugin/rom/devicemgmtdialogsplugin.iby	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,23 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef __DEVICEMGMTDIALOGSPLUGIN_IBY__
+#define __DEVICEMGMTDIALOGSPLUGIN_IBY__
+
+data=/epoc32/data/z/resource/plugins/devicedialogs/devicemanagementnotifiersplugin.qtplugin		resource/plugins/devicedialogs/devicemanagementnotifiersplugin.qtplugin
+file=ABI_DIR/BUILD_DIR/devicemanagementnotifiersplugin.dll		SHARED_LIB_DIR/devicemanagementnotifiersplugin.dll
+
+#endif
\ No newline at end of file
--- a/devicemgmtdialogsplugin/src/omacppinquerydialog.cpp	Tue Jul 13 03:48:30 2010 +0530
+++ b/devicemgmtdialogsplugin/src/omacppinquerydialog.cpp	Tue Jul 13 03:51:25 2010 +0530
@@ -57,7 +57,8 @@
     loader.load(":/xml/resources/pin.docml", &ok);
     if (!ok)
         {
-        return;
+        qFatal("omacppinquerydialog createcppinquery() Unable to read pin.docml");
+        
         }
 
     HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
--- a/deviceupdatesui/deviceupdatesplugin/deviceupdatesplugin.pro	Tue Jul 13 03:48:30 2010 +0530
+++ b/deviceupdatesui/deviceupdatesplugin/deviceupdatesplugin.pro	Tue Jul 13 03:51:25 2010 +0530
@@ -30,7 +30,7 @@
 LIBS += -lcpframework \
 					-lcentralrepository \
 					-lws32 \
-					-lapparc
+					-lapgrfx
 
 # Input
 HEADERS += deviceupdatesplugin.h \
--- a/omadmadapters/bld/bld.inf	Tue Jul 13 03:48:30 2010 +0530
+++ b/omadmadapters/bld/bld.inf	Tue Jul 13 03:51:25 2010 +0530
@@ -25,12 +25,12 @@
 #include "../syncmldm/bld/bld.inf"
 #include "../syncmldm12/bld/bld.inf"
 //#include "../browseradapter/bld/bld.inf"
-//#include "../streamingadapter/bld/bld.inf"
+#include "../streamingadapter/bld/bld.inf"
 
 #include "../globalwlansettings/group/bld.inf"
 //#include "../nsmldminternet/group/bld.inf"
 #include "../nsmldmalwaysonadapter/group/bld.inf"
-//#include "../nsmldmbmadapter/group/bld.inf"
+#include "../nsmldmbmadapter/group/bld.inf"
 #include "../connmoadapter/group/bld.inf"
 
 #ifdef __SYNCML_DM_DS
@@ -38,7 +38,7 @@
 #endif
 
 #ifdef __SYNCML_DM_EMAIL
-//#include "../email/bld/bld.inf"
+#include "../email/bld/bld.inf"
 #endif
 
 #ifdef __SYNCML_DM_MMS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/bld/bld.inf	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    build info file for email settings adapter
+*
+*/
+
+
+
+
+PRJ_MMPFILES
+./nsmldmemailadapter.mmp
+
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/bld/nsmldmemailadapter.mmp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Project file for SyncML DM Email adapter
+*
+*/
+
+
+
+  
+#include "defaultcaps.hrh"
+#include  <platform_paths.hrh>
+
+CAPABILITY      CAP_ECOM_PLUGIN
+TARGET          nsmldmemailadapter.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x101F6E34
+VENDORID        VID_DEFAULT
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+SOURCEPATH      ../src
+USERINCLUDE     ../inc ../../inc
+SOURCE          nsmldmemailadapter.cpp
+
+START RESOURCE  nsmldmemailadapter.rss
+TARGET nsmldmemailadapter.rsc
+LANGUAGE_IDS
+END
+
+
+
+LIBRARY         euser.lib ecom.lib msgs.lib charconv.lib imcm.lib nsmldebug.lib commdb.lib
+LIBRARY					efsrv.lib sysutil.lib nsmldmiapmatcher.lib
+LIBRARY         etel.lib                        // RTelServer
+LIBRARY         etelmm.lib                      // RMobilePhone
+
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/inc/nsmldmemailadapter.h	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,744 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    DM Email Settings Adapter
+ *
+*/
+
+
+
+
+
+#ifndef __NSMLDMEMAILADAPTER_H__
+#define __NSMLDMEMAILADAPTER_H__
+
+// -----------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------
+#include <e32base.h>
+#include <smldmadapter.h>
+#include <msvapi.h>
+
+// -----------------------------------------------------------------------------
+// Class forwards
+// -----------------------------------------------------------------------------
+class CImSmtpSettings;
+class CImPop3Settings;
+class CImImap4Settings;
+class CImIAPPreferences;
+class CMsvSession;
+class CEmailAccounts;
+
+
+// -----------------------------------------------------------------------------
+// Definitions
+// -----------------------------------------------------------------------------
+
+// the DDF version must be changed if any changes in DDF structure 
+// ( built in DDFStructureL() function )
+//
+_LIT8( KNSmlDMEmailDDFVersion, "1.1" ); 
+
+_LIT8( KNSmlDMEmailTextPlain, "text/plain" );
+_LIT8( KNSmlDMEmailNodeName, "Email" );
+_LIT8( KNSmlDMEmailDescription, "The interior object holds all email objects" );
+_LIT8( KNSmlDMDynamicNodeDescription, "Placeholder for one or more Email objects" );
+_LIT8( KNSmlDMNameDescription, "Displayable Account Name for the Email Settings" );
+_LIT8( KNSmlDMUIDDescription, "User ID for email account" );
+_LIT8( KNSmlDMPWDescription, "Password for email account " );
+_LIT8( KNSmlDMUAddrDescription, "User's email address" );
+_LIT8( KNSmlDMUNameDescription, "Displayable name for the user" );
+_LIT8( KNSmlDMMrcvDescription, "Host name of the receiving  (IMAP/POP3) server" );
+_LIT8( KNSmlDMMsndDescription, "Host name of the SMTP server" );
+_LIT8( KNSmlDMMproDescription, "Remote mailbox protocol" );
+_LIT8( KNSmlDMUseSecConDescription, "Secure connection is used or not" );
+_LIT8( KNSmlDMUseSauthDescription, "SMTP authentication is used or not" );
+_LIT8( KNSmlDMSauthUIDDescription, "SMTP authenticatio user Id" );
+_LIT8( KNSmlDMSauthPWDescription, "SMTP authentication password" );
+_LIT8( KNSmlDMPtxtSAuthDescription, "Plain text SMTP authentication is allowed or not" );
+_LIT8( KNSmlDMDelFetDescription, "Defines whether to delete fetched mail from remote server" );
+_LIT8( KNSmlDMUseAPOPDescription, "Defines whether  the APOP is used or not" );
+_LIT8( KNSmlDMRcvPortDescription, "Port for IMAP4 or POP3" );
+_LIT8( KNSmlDMSndPortDescription, "Port for SMTP" );
+_LIT8( KNSmlDMToNapIDDescription, "Link to connectivity information" );
+
+_LIT8( KNSmlDMSToNapIDDescription, "Link to connectivity information for sending SMTP" );
+_LIT8( KNSmlDMSUseSecConDescription, "Defines whether SSL/TLS security is used in SMTP" );
+_LIT8( KNSmlDMUseStartTLSDescription, "Defines whether StartTLS is used in IMAP/POP" );
+_LIT8( KNSmlDMSUseStartTLSDescription, "Defines whether StartTLS is in SMTP" );
+_LIT8( KNSmlDMMrcvPortDescription, "Defines the port number of the IMAP/POP server" );
+_LIT8( KNSmlDMMsndPortDescription, "Defines the port number of the SMTP server" );
+_LIT8( KNSmlDMFolderPathDescription, "Defines the mailbox folder path" );
+
+_LIT8( KNSmlDMEmailDynamicNode, "" );
+_LIT8( KNSmlDMEmailName, "Name" );
+_LIT8( KNSmlDMEmailUID, "UID" );
+_LIT8( KNSmlDMEmailPW, "PW" );
+_LIT8( KNSmlDMEmailUAddr, "UAddr" );
+_LIT8( KNSmlDMEmailUName, "UName" );
+_LIT8( KNSmlDMEmailMrcv, "Mrcv" );
+_LIT8( KNSmlDMEmailMsnd, "Msnd" );
+_LIT8( KNSmlDMEmailMpro, "Mpro" );
+_LIT8( KNSmlDMEmailUseAPOP, "UseAPOP" );
+_LIT8( KNSmlDMEmailUseSecCon, "UseSecCon" );
+_LIT8( KNSmlDMEmailUseSauth, "UseSauth" );
+_LIT8( KNSmlDMEmailSauthUID, "SauthUID" );
+_LIT8( KNSmlDMEmailSauthPW, "SauthPW" );
+_LIT8( KNSmlDMEmailPtxtSAuth, "PtxtSAuth" );
+//_LIT8( KNSmlDMEmailRcvPort, "RcvPort" );
+//_LIT8( KNSmlDMEmailSndPort, "SndPort" );
+_LIT8( KNSmlDMEmailToNapID, "ToNapID" );
+_LIT8( KNSmlDMEmailIAPUri, "AP" );
+
+_LIT8( KNSmlDMEmailSToNapID, "SToNapID" );
+_LIT8( KNSmlDMEmailSUseSecCon, "SUseSecCon" );
+_LIT8( KNSmlDMEmailUseStartTLS, "UseStartTLS" );
+_LIT8( KNSmlDMEmailSUseStartTLS, "SUseStartTLS" );
+_LIT8( KNSmlDMEmailMrcvPort, "MrcvPort" );
+_LIT8( KNSmlDMEmailMsndPort, "MsndPort" );
+_LIT8( KNSmlDMEmailFolderPath, "FolderPath" );
+
+_LIT8( KNSmlDMEmailMproPOP, "POP" );
+_LIT8( KNSmlDMEmailMproIMAP, "IMAP" );
+_LIT8( KNSmlDMEmailTrue, "True" );
+_LIT8( KNSmlDMEmailFalse, "False" );
+
+_LIT8( KNSmlDMEmailListOfLeafs, "Name/UID/PW/UAddr/UName/Mrcv/Msnd/Mpro/UseSecCon/UseSauth/SauthUID/SauthPW/PtxtSAuth/ToNapID/SToNapID/SUseSecCon/UseStartTLS/SUseStartTLS/MrcvPort/MsndPort/UseAPOP/FolderPath" );
+_LIT8( KNSmlDMEmailSeparator8, "/" );
+_LIT8( KNSmlEmailUriDotSlash, "./");
+
+const TInt KNSmlDmFatMinimumFileSize = 512;
+const TInt KNSmlSmtpMessageTypeValue = 0x10001028;
+const TInt KNSmlDefaultMaxLimit = 1024*10; //maximum message size (default)
+const TInt KNSmlDmEmailGranularity = 4;
+const TUint32 KNSmlDmEmailAlwaysAskIap = 0;
+
+const TInt KNSmlDMEmailNormalSmtpPort = 25;
+const TInt KNSmlDMEmailSslSmtpPort = 465;
+const TInt KNSmlDMEmailNormalImap4Port = 143;
+const TInt KNSmlDMEmailNormalPop3Port = 110;
+const TInt KNSmlDMEmailSslWrappedImap4Port = 993;
+const TInt KNSmlDMEmailSslWrappedPop3Port = 995;
+const TInt KNSmlDMEmailDefaultHeaderCount = 30;
+
+const TInt KNSmlDmEmailImapLuidLow = 50000;
+const TInt KNSmlDmEmailImapLuidHigh = 100000;
+const TInt KNSmlDmEmailPopLuidHigh = 150000;
+const TUint32 KNSmlDMEmailMaxPortNbr = 0xffff;
+
+/**
+* The main class of the SyncML DM Email adapter.
+*
+*  @since 
+*/
+class CNSmlDmEmailAdapter : public CSmlDmAdapter, public MMsvSessionObserver
+    {
+public:
+    /**
+     * The one phase constructor
+     *
+     */
+    static CNSmlDmEmailAdapter* NewL(MSmlDmCallback* aDmCallback );
+
+    /** 
+     * The destructor
+     *
+     */
+    virtual ~CNSmlDmEmailAdapter();
+
+    // Adapter interface from CSmlDmAdapter
+    /**
+     * The function returns current version of the DDF.  By asking
+     * current DDF versions from adapters DM Module can control *
+     * possible changes in the data structure and send the changed DDF
+     * description to a management server.  This function is always
+     * called after DDFStructureL.  
+     * @param aVersion DDF version of the
+     * adapter. (filled by the adapter) 
+     * @publishedPartner 
+     * @prototype
+     */
+
+    void DDFVersionL( CBufBase& aDDFVersion );
+    /**
+     * The function for filling the DDF structure of the adapter
+     * This function is only called once, immediately after the adapter is created.
+     * @param aDDFObject   Reference to root object. A DM adapter starts filling
+     * the data structure by calling AddChildObjectL to the root object and
+     * so describes the DDF of the adapter. 
+     * @publishedPartner
+     * @prototype
+    */
+    void DDFStructureL( MSmlDmDDFObject& aDDF );
+    /**
+     * The function creates new leaf objects, or replaces data in existing leaf
+     * objects. The information about the success of the command should be
+     * returned by calling SetStatusL function of MSmlDmCallback callback
+     * interface. This makes it possible to buffer the commands.  However, all
+     * the status codes for buffered commands must be returned at the latest when
+     * the adapter's CompleteOutstandingCmdsL() is called.
+     * @param aURI         URI of the object
+     * @param aLUID        LUID of the object (if the adapter has earlier returned a
+     *                    LUID to the DM Module). For new objects, this is the LUID
+     *                    inherited through the parent node.
+     * @param aObject      Data of the object.
+     * @param aType        MIME type of the object
+     * @param aStatusRef   Reference to correct command, i.e. this reference
+     *                    must be used when calling the SetStatusL of this command
+     * @publishedPartner
+     * @prototype
+    */
+    void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
+                            const TDesC8& aObject, const TDesC8& aType, 
+                            TInt aStatusRef );
+    /**
+     * The function deletes an object and its child objects. The SetStatusL
+     * should be used as described in UpdateLeafObjectL()
+     * @param aURI     URI of the object
+     * @param aLUID        LUID of the object (if the adapter have earlier returned
+     *                     LUID to the DM Module).
+     * @param aStatusRef   Reference to correct command, i.e. this reference must
+     *                     be used when calling the SetStatusL of this command.
+     * @publishedPartner
+     * @prototype
+    */
+    void DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
+                        const TInt aStatusRef );
+    /**
+     * The function fetches data of a leaf object. The SetStatusL should be used
+     * as described in UpdateLeafObjectL(). The data is returned by using the
+     * SetResultsL function of MSmlCallback callback interface, and may be streamed.
+     * @param aURI         URI of the object
+     * @param aLUID            LUID of the object (if the adapter have earlier
+     *                       returned LUID to the DM Module).   
+     * @param aType            MIME type of the object
+     * @param aResultsRef  Reference to correct results, i.e. this reference
+     *                         must be used when returning the result by calling
+     *                         the SetResultsL.
+     * @param aStatusRef       Reference to correct command, i.e. this reference
+     *                         must be used when calling the SetStatusL of this
+     *                         command.
+     * @publishedPartner
+     * @prototype
+    */
+    void FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
+                           const TDesC8& aType, const TInt aResultsRef, 
+                           const TInt aStatusRef );
+    /**
+     * The function fetches URI list. An adapter returns the list of URI segments
+     * under the given URI be separated by slash ("/"). The URI segment names for
+     * new objects must be given by the adapter.
+     * The list is returned by calling the SetResultsL function of MSmlCallback
+     * callback interface. Results from this call MUST NOT be streamed.
+     * @param aParentURI                   URI of the parent object
+     * @param aParentLUID              LUID of the parent object (if the
+     *                                     adapter have earlier returned LUID to
+     *                                     the DM Module).   
+     * @param aPreviousURISegmentList  URI list with mapping LUID information,
+     *                                     which is known by DM engine. An adapter
+     *                                     can use this information when verifying
+     *                                     if old objects still exists. An adapter
+     *                                     also knows what objects are new to DM
+     *                                     engine and can provide LUID mapping for
+     *                                     them. aPreviousURISegmentList parameter
+     *                                     (see above) helps to recognise new
+     *                                     objects.
+     * @param aResultsRef              Reference to correct results, i.e. this
+     *                                     reference must be used when returning
+     *                                     the result by calling the SetResultsL.
+     * @param aStatusRef                   Reference to correct command, i.e. this
+     *                                     reference must be used when calling the
+     *                                     SetStatusL of this command.
+     * @publishedPartner
+     * @prototype
+    */
+    void ChildURIListL( const TDesC8& aURI, 
+                        const TDesC8& aLUID, 
+                     const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
+        const TInt aResultsRef, const TInt aStatusRef );
+    /**
+     * The function adds node object. In some cases an implementation of the
+     * function may be empty function, if the node object does not need concrete
+     * database update. Still this function may be helpful to an adapter, i.e. in
+     * passing mapping LUID of the node to DM Module. The SetStatusL should be
+     * used as described in UpdateLeafObjectL()
+     * @param aURI         URI of the object
+     * @param aParentLUID  LUID of the parent object (if the adapter have
+     *                         earlier returned LUID to the DM Module).   
+     * @param aStatusRef       Reference to correct command, i.e. this reference
+     *                         must be used when calling the SetStatusL of this
+     *                         command.
+     * @publishedPartner
+     * @prototype
+    */
+    void AddNodeObjectL( const TDesC8& aURI, const TDesC8& aParentLUID, 
+                         const TInt aStatusRef );
+    /**
+     * The function creates new leaf objects, or replaces data in existing leaf
+     * objects, in the case where data is large enough to be streamed. The
+     * information about the success of the command should be returned by calling
+     * SetStatusL function of MSmlDmCallback callback interface. This makes it
+     * possible to buffer the commands.  However, all the status codes for buffered
+     * commands must be returned at the latest when the CompleteOutstandingCmdsL()
+     * of adapter is called.
+     * @param aURI     URI of the object
+     * @param aLUID        LUID of the object (if the adapter has earlier returned a
+     *                     LUID to the DM Module). For new objects, this is the LUID
+     *                     inherited through the parent node.
+     * @param aStream  Data of the object. Adapter should create write stream
+     *                     and return, when data is written to stream by DM agent,
+     *                     StreamCommittedL() is called by DM engine
+     * @param aType        MIME type of the object
+     * @param aStatusRef   Reference to correct command, i.e. this reference
+     *                     must be used when calling the SetStatusL of this
+     *                     command.
+     * @publishedPartner
+     * @prototype
+    */
+    void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
+                            RWriteStream*& aStream, const TDesC8& aType, 
+                            const TInt aStatusRef );
+    /**
+     * The function fetches the size of the data of a leaf object. The size is
+     * in bytes, and must reflect the number of bytes that will be transferred
+     * when the framework calls FetchLeafObjectL. The SetStatusL should be used
+     * as described in FetchLeafObjectL(). The size value is returned by using
+     * the SetResultsL function of MSmlCallback callback interface, and must be
+     * a decimal integer expressed as a string, eg. "1234".
+     * Results from this call MUST NOT be streamed.
+     * @param aURI         URI of the object
+     * @param aLUID            LUID of the object (if the adapter have earlier
+     *                         returned LUID to the DM Module).   
+     * @param aType            MIME type of the object
+     * @param aResultsRef  Reference to correct results, i.e. this reference
+     *                         must be used when returning the result by calling
+     *                         the SetResultsL.
+     * @param aStatusRef       Reference to correct command, i.e. this reference
+     *                         must be used when calling the SetStatusL of this
+     *                         command.
+     * @publishedPartner
+     * @prototype
+    */
+    void FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, 
+                               const TDesC8& aType, const TInt aResultsRef, 
+                               const TInt aStatusRef );
+    /**
+     * The function implements execute command. The information about the success
+     * of the command should be returned by calling SetStatusL function of
+     * MSmlDmCallback callback interface. This makes it possible to buffer the
+     * commands.
+     * However, all the status codes for buffered commands must be returned at
+     * the latest when the CompleteOutstandingCmdsL() of adapter is called.
+     * @param aURI         URI of the command
+     * @param aLUID            LUID of the object (if the adapter have earlier
+     *                         returned LUID to the DM Module).   
+     * @param aArgument        Argument for the command
+     * @param aType            MIME type of the object 
+     * @param aStatusRef       Reference to correct command, i.e. this reference
+     *                         must be used when calling the SetStatusL of this
+     *                         command.
+     * @publishedPartner
+     * @prototype
+    */
+    void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, 
+                          const TDesC8& aArgument, const TDesC8& aType, 
+                          const TInt aStatusRef );
+    /**
+     * The function implements execute command. The information about the
+     * success of the command should be returned by calling SetStatusL function
+     * of MSmlDmCallback callback interface. This makes it possible to buffer the
+     * commands.
+     * However, all the status codes for buffered commands must be returned at
+     * the latest when the CompleteOutstandingCmdsL() of adapter is called.
+     * @param aURI         URI of the command
+     * @param aLUID            LUID of the object (if the adapter have earlier
+     *                         returned LUID to the DM Module).   
+     * @param aStream      Argument for the command. Adapter should create
+     *                         write stream and return, when data is written to
+     *                         stream by DM agent, StreamCommittedL() is called by
+     *                         DM engine
+     * @param aType            MIME type of the object 
+     * @param aStatusRef       Reference to correct command, i.e. this reference
+     *                         must be used when calling the SetStatusL of this
+     *                         command.
+     * @publishedPartner
+     * @prototype
+    */
+    void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, 
+                          RWriteStream*& aStream, const TDesC8& aType, 
+                          const TInt aStatusRef );
+    /**
+     * The function implements copy command. The information about the success of
+     * the command should be returned by calling SetStatusL function of
+     * MSmlDmCallback callback interface. This makes it possible to buffer the
+     * commands.
+     * However, all the status codes for buffered commands must be returned at
+     * the latest when the CompleteOutstandingCmdsL() of adapter is called.
+     * @param aTargetURI       Target URI for the command
+     * @param aSourceLUID  LUID of the target object (if one exists, and if the adapter
+     *                         has earlier returned a LUID to the DM Module).   
+     * @param aSourceURI       Source URI for the command
+     * @param aSourceLUID  LUID of the source object (if the adapter has
+     *                         earlier returned a LUID to the DM Module).   
+     * @param aType            MIME type of the objects
+     * @param aStatusRef       Reference to correct command, i.e. this reference
+     *                         must be used when calling the SetStatusL of this
+     *                         command.
+     * @publishedPartner
+     * @prototype
+    */
+    void CopyCommandL( const TDesC8& aTargetURI, const TDesC8& aTargetLUID, 
+                       const TDesC8& aSourceURI, const TDesC8& aSourceLUID, 
+                       const TDesC8& aType, TInt aStatusRef );
+    /**
+     * The function indicates start of Atomic command.
+     * @publishedPartner
+     * @prototype
+    */
+    void StartAtomicL();
+    /**
+     * The function indicates successful end of Atomic command. The adapter
+     * should commit all changes issued between StartAtomicL() and
+     * CommitAtomicL()
+     * @publishedPartner
+     * @prototype
+    */
+    void CommitAtomicL();
+    /**
+     * The function indicates unsuccessful end of Atomic command. The adapter
+     * should rollback all changes issued between StartAtomicL() and
+     * RollbackAtomicL(). If rollback fails for a command, adapter should use
+     * SetStatusL() to indicate it.
+     * @publishedPartner
+     * @prototype
+    */
+    void RollbackAtomicL();
+    /**
+     * Returns ETrue if adapter supports streaming otherwise EFalse.
+     * @param aItemSize size limit for stream usage
+     * @return TBool ETrue for streaming support
+     * @publishedPartner
+     * @prototype
+    */
+    TBool StreamingSupport( TInt& aItemSize );
+    /**
+     * Called when stream returned from UpdateLeafObjectL or ExecuteCommandL has
+     * been written to and committed. Not called when fetching item.
+     * @publishedPartner
+     * @prototype
+    */  
+    void StreamCommittedL();
+    /**
+     * The function tells the adapter that all the commands of the message that
+     * can be passed to the adapter have now been passed.  This indciates that
+     * the adapter must supply status codes and results to any buffered commands.
+     * This must be done at latest by the time this function returns.
+     * This function is used at the end of SyncML messages, and during processing
+     * of Atomic.   In the case of Atomic processing, the function will be
+     * followed by a call to CommitAtomicL or RollbackAtomicL.
+     * @publishedPartner
+     * @prototype
+    */
+    void CompleteOutstandingCmdsL();
+
+protected:  
+    /**
+     * Inherited from MMsvSessionObserver
+     * Indicates an event has occurred.
+     * @param aEvent Indicates the event type. 
+     * @param aArg1 Event type-specific argument value 
+     * @param aArg2 Event type-specific argument value 
+     * @param aArg3 Event type-specific argument value 
+     */
+    void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2,
+                              TAny* aArg3 );
+
+private:
+
+struct TNSmlEmailCommandElement
+    {
+    HBufC8* iLastUriSeg;
+    HBufC8* iData;
+    TInt iStatusRef;
+    TBool iLeaf;
+    CSmlDmAdapter::TError iStatus;
+    };
+
+enum TNSmlEmailAccountType
+    {
+    EImap,
+    EPop,
+    EUnknown
+    };
+
+enum TNSmlEmailSecuritySetting
+    {
+    EUseSecCon = 1,
+    EUseStartTls,
+    ESuseSecCon,
+    ESuseStartTls,
+    };
+
+struct TNSmlEmailSettingsElement
+    {
+    CArrayFixFlat<TNSmlEmailCommandElement> *iNodeBuf;
+    /* iMappingName = Email/xxxx */
+    HBufC8* iMappingName;
+    HBufC* iName;
+    CImSmtpSettings* iSmtpSettings;
+    CImPop3Settings* iPop3Settings;
+    CImImap4Settings* iImap4Settings;
+    CImIAPPreferences* iIapPref;
+    CImIAPPreferences* iSmtpIapPref;
+    
+    TBool iExecuted;
+    TInt iLuid;
+    TBool iJustFetch;
+    CNSmlDmEmailAdapter::TNSmlEmailAccountType iAccType;
+    TInt iAccId;
+    TMsvId iServiceId;
+    };
+
+    /**
+    * C++ default constructor.
+    */
+    void ConstructL();
+    CNSmlDmEmailAdapter();
+    CNSmlDmEmailAdapter( MSmlDmCallback* aDmCallback );
+
+    /**
+     * Initializes the buffer for leaf nodes.
+     * @param    aURI URI of the object
+     * @param    aObject The data to be updated
+     * @param    aStatusRef The status reference
+     * @param    aIndex The index to command buffer
+     * @return   status of the operation
+     */
+    TInt FirstAddLeafL(const TDesC8& aURI, 
+        const TDesC8& aObject, 
+        TInt aStatusRef,
+        TInt aIndex);
+
+    /**
+     * Updates the value of leaf object
+     * @param    aLastUriSeg URI of the object
+     * @param    aObject The data to be updated
+     * @param    aIndex The index to node buffer
+     * @param    aCommand The index to command buffer
+     * @return   status of the operation
+     */
+    TInt DoAddLeafObjectL(const TDesC8& aLastUriSeg, 
+        const TDesC8& aObject,
+        TInt aIndex, 
+        TInt aCommand);
+
+    /**
+     * Set the default values to email account
+     * @param    aIndex The index to node buffer
+     * @return   none
+     */
+    void SetDefaultSettingsL(TInt aIndex);
+
+    /**
+     * Converts 16bit descriptor to integer
+     * @param    aLuid The descriptor to be converted
+     * @return    Integer value of the descriptor
+     */
+    TInt DesToInt(const TDesC& aLuid) const;
+
+    /**
+     * Converts 8bit descriptor to integer
+     * @param    aLuid The descriptor to be converted
+     * @return    Integer value of the descriptor
+     */
+    TInt DesToInt(const TDesC8& aLuid) const;
+
+    /**
+     * Converts integer to 16bit descriptor
+     * @param    aLuid The integer to be converted
+     * @return    The Integer as a descriptor
+     */
+    HBufC* IntToDesLC(const TInt aLuid) const;
+
+    /**
+     * Converts integer to 8bit descriptor
+     * @param    aLuid The integer to be converted
+     * @return    The Integer as a descriptor
+     */
+    HBufC8* IntToDes8LC(const TInt aLuid) const;
+
+    /**
+     * Converts 16bit descriptor to 8bit descriptor
+     * @param    aSource The descriptor to be converted
+     * @return    The 8bit descriptor
+     */
+    HBufC8* ConvertTo8LC( const TDesC& aSource ) const;
+
+    /**
+     * Transfers the email settings from memory to phones permanent data store
+     * @param    aIndex The index to command buffer
+     * @return    Luid of the email account
+     */
+    TInt ValidateAndStoreSettingsL(TInt aIndex);
+
+    /**
+     * Restores the settings to the adapter from phones permanent data store
+     * @param    aIndex The index to command buffer
+     * @return    Status of the operation
+     */
+    TInt DoRestoreSettingsL(TInt aIndex);
+
+    /**
+     * Opens the CMsvSession if it is not open already
+     * @param    none
+     * @return    Status of the operation
+     */
+    TInt OpenSessionL();
+
+    /**
+     * Parses the last URI segment from URI
+     * @param    aURI The whole URI
+     * @return    The last URI segment
+     */
+    TPtrC8 LastURISeg(const TDesC8& aURI) const; 
+
+    /**
+     * Removes the last URI segment from URI
+     * @param    aURI The whole URI
+     * @return    The aURI without the last URI segment
+     */
+    TPtrC8 RemoveLastURISeg(const TDesC8& aURI) const;
+
+    /**
+     * Calculates the number of URI segments
+     * @param    aURI The whole URI
+     * @return    The number of URI segments
+     */
+    TInt NumOfURISegs(const TDesC8& aURI) const;
+
+    /**
+     * Fills the DDF node with desired properties
+     * @param    aNode           Reference to node or leaf which info to be filled.
+     * @param    aAccTypes       Access rights for a leaf / node.
+     * @param    aOccurrence     Occurance of the node / leaf.
+     * @param    aScope          Scope (dynamic / permanent) of the leaf / node.
+     * @param    aFormat         Data format of the leaf / node.
+     * @param    aDescription    Description of the node / leaf.
+     * @param    aDefaultValue   Default value for a leaf or node.
+     * @return    none
+     */
+    void FillNodeInfoL( MSmlDmDDFObject& aNode,
+        const TSmlDmAccessTypes& aAccTypes, 
+                        MSmlDmDDFObject::TOccurence aOccurrence, 
+                        MSmlDmDDFObject::TScope aScope, 
+                        MSmlDmDDFObject::TDFFormat aFormat,
+                        const TDesC8& aDescription) const;
+
+    /**
+     * Parses the dot and slash in start of URI away
+     * @param    aURI The whole URI
+     * @return    The URI without dot and slash in start
+     */
+    TPtrC8 RemoveDotSlash(const TDesC8& aURI) const;
+
+    /**
+     * Fetches the value of leaf node
+     * @param    aURI The whole URI
+     * @param    aLUID The LUID
+     * @param    aObject The storage for the result
+     * @return    Status of the operation
+     */
+    CSmlDmAdapter::TError FetchObjectL(const TDesC8& aURI, 
+        const TDesC8& aLUID,
+        CBufBase& aObject);
+
+    /**
+     * Calculates correct account id from the LUID
+     * @param    aAccType Account Type
+     * @param    aAccId Account ID
+     * @param    aLuid The LUID
+     * @return    none
+     */
+    void GetIdByLuid( TNSmlEmailAccountType& aAccType, 
+                      TInt& aAccId, const TInt aLuid ) const;
+
+    /**
+     * Calculates LUID from the account id
+     * @param    aAccType Account Type
+     * @param    aAccId Account ID
+     * @param    aLuid The LUID
+     * @return    none
+     */
+    void SetLuidById( const TNSmlEmailAccountType& aAccType, 
+                      const TInt& aAccId, TInt& aLuid ) const;
+
+    /**
+     * Checks if the account with given id exists
+     * @param    aAccs Pointer to CEmailAccount object
+     * @param    aAccType Account Type
+     * @param    aId Account ID
+     * @param    aIndex The LUIDIndex to the command buffer
+     * @return    True if the account exists
+     */
+    TBool AccountExistsL( CEmailAccounts* aAccs, 
+                         const TNSmlEmailAccountType aAccType, 
+                         const TInt aId,
+                         TInt aIndex );
+
+    /**
+     * Sets the parameters related to STARTTLS and SSL/TLS
+     * @param    aObject The value(True/False) to be set
+     * @param    aThisElem The element of which value is to be set.
+     * @param    aSetting The setting which value is to be set
+     * @return    none
+     */
+    void SetDefaultSecurityL(const TDesC8& aObject,
+                          const TNSmlEmailSettingsElement* aThisElem,
+                          const TNSmlEmailSecuritySetting aSetting
+        ) const;
+
+    /**
+     * Fetches the parameters related to STARTTLS and SSL/TLS
+     * @param    aObject The storage for the value
+     * @param    aElem The element of which value is fetched.
+     * @param    aSetting The setting which value is fetched.
+     * @return    Status of the operation
+     */
+    CSmlDmAdapter::TError FetchSecurityValueL(CBufBase& aObject, 
+        const TNSmlEmailSettingsElement* aElem,
+        const TNSmlEmailSecuritySetting aSetting ) const;
+		
+		/**
+     * Creates the mapping for the email account preset
+     * @param    aURI The whole URI
+     * @return   the luid of the email account specified im aURI, else -1
+     */
+		TInt ConstructTreeL(const TDesC8& aURI);
+		
+ /**
+        * The function extracts Email/x node from aURI		        
+        * @param    aURI     Email aURI.
+        * @return   Email/x node.
+    */ 
+    TPtrC8 GetDynamicEmailNodeUri( const TDesC8& aURI );
+		
+private:
+    // Pointer to CMsvSession
+    CMsvSession* iMsvSession;
+    // The buffer for received commands
+    CArrayFixFlat<TNSmlEmailSettingsElement>* iBuffer;
+    };
+
+#endif // __NSMLDMEMAILADAPTER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/sis/emailadapter.pkg	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,35 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: Implementation of dm adapters
+; 	This is part of omadmextensions.
+;
+&EN
+
+; standard SIS file header
+#{"nsmlemailadapter"},(0x101F6E34),2,0,0,TYPE=SA
+
+;Localised Vendor name
+%{"Nokia-EN"}
+
+;Unique Vendor name
+:"Nokia"
+
+;Supports Series 60 v 3.0
+;[0x101F6E34], 0, 0, 0, {"Series60ProductID"}
+
+;Files to install
+;Exes  to be installed 
+"\EPOC32\RELEASE\ARMV5\UREL\nsmldmemailadapter.dll"                            -"!:\sys\bin\nsmldmemailadapter.dll"
+; Application resource files to be installed 
+"\EPOC32\data\z\resource\plugins\nsmldmemailadapter.Rsc"             -"!:\resource\plugins\nsmldmemailadapter.Rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/sis/gensis.bat	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,19 @@
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description: Implementation of dm adapters
+rem 	This is part of omadmextensions.
+rem
+
+makesis emailadapter.pkg
+signsis emailadapter.SIS emailadapter.SISX \S60\mw\contentmanagement\swinstalleruis\Appinstui\internal\RD_rootCA\rd.cer \s60\mw\contentmanagement\swinstalleruis\appinstui\internal\RD_rootca\rd-key.pem
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/src/nsmldmemailadapter.cpp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,3364 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    DM Email Settings Adapter
+ *
+*/
+
+
+
+
+#include <implementationproxy.h> // For TImplementationProxy definition
+#include <utf.h>
+#include <iapprefs.h>
+#include <smtpset.h>
+#include <pop3set.h>
+#include <imapset.h>
+#include <sysutil.h>
+#include <etelmm.h>
+
+#include <cemailaccounts.h>
+
+#include "nsmldmimpluids.h"
+#include "nsmldmemailadapter.h"
+#include "nsmldebug.h"
+#include "nsmlconstants.h"
+#include "nsmldmconst.h"
+#include "nsmldmiapmatcher.h"
+
+#ifndef __WINS__
+// This lowers the unnecessary compiler warning (armv5) to remark.
+// "Warning:  #174-D: expression has no effect..." is caused by 
+// DBG_ARGS8 macro in no-debug builds.
+#pragma diag_remark 174
+#endif
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter* CNSmlDmEmailAdapter::NewL( )
+// -----------------------------------------------------------------------------
+CNSmlDmEmailAdapter* CNSmlDmEmailAdapter::NewL(MSmlDmCallback* aDmCallback )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::NewL(): begin");
+    CNSmlDmEmailAdapter* self = new (ELeave) CNSmlDmEmailAdapter(aDmCallback);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    _DBG_FILE("CNSmlDmEmailAdapter::NewL(): end");
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::CNSmlDmEmailAdapter()
+// -----------------------------------------------------------------------------
+
+CNSmlDmEmailAdapter::CNSmlDmEmailAdapter( MSmlDmCallback* aDmCallback )
+    : CSmlDmAdapter(aDmCallback)
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::CNSmlDmEmailAdapter(): begin");
+    iMsvSession = NULL;
+    _DBG_FILE("CNSmlDmEmailAdapter::CNSmlDmEmailAdapter(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::ConstructL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::ConstructL()
+    {
+    iBuffer = new (ELeave) CArrayFixFlat <TNSmlEmailSettingsElement> 
+        (KNSmlDmEmailGranularity);
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::~CNSmlDmEmailAdapter()
+// -----------------------------------------------------------------------------
+CNSmlDmEmailAdapter::~CNSmlDmEmailAdapter()
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::~CNSmlDmEmailAdapter(): begin");
+    delete iMsvSession;
+    if(iBuffer)
+        {
+        for(TInt i=0;i<iBuffer->Count();i++)
+            {
+            delete iBuffer->At(i).iMappingName;
+            delete iBuffer->At(i).iName;
+            delete iBuffer->At(i).iSmtpSettings;
+            delete iBuffer->At(i).iPop3Settings;
+            delete iBuffer->At(i).iImap4Settings;
+            delete iBuffer->At(i).iIapPref;
+            delete iBuffer->At(i).iSmtpIapPref;
+
+            if(iBuffer->At(i).iNodeBuf)
+                {
+                for(TInt j=0;j<iBuffer->At(i).iNodeBuf->Count();j++)
+                    {
+                    delete iBuffer->At(i).iNodeBuf->At(j).iLastUriSeg;
+                    delete iBuffer->At(i).iNodeBuf->At(j).iData;
+                    }
+                iBuffer->At(i).iNodeBuf->Reset();
+                delete iBuffer->At(i).iNodeBuf;
+                }
+            }
+        iBuffer->Reset();
+        delete iBuffer;
+        }
+
+    _DBG_FILE("CNSmlDmEmailAdapter::~CNSmlDmEmailAdapter(): end");
+    }
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmEmailAdapter::DDFVersionL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::DDFVersionL(CBufBase& aDDFVersion)
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::DDFVersionL(TDes& aDDFVersion): begin");
+    aDDFVersion.InsertL(0,KNSmlDMEmailDDFVersion);
+    _DBG_FILE("CNSmlDmEmailAdapter::DDFVersionL(TDes& aDDFVersion): end");
+    }
+
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmEmailAdapter::DDFStructureL()
+//
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::DDFStructureL(MSmlDmDDFObject& aDDF)
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::DDFStructureL(): begin");
+
+    TSmlDmAccessTypes accessTypesNode;
+
+    accessTypesNode.SetGet();
+
+    // Email
+    MSmlDmDDFObject& email = aDDF.AddChildObjectL(KNSmlDMEmailNodeName);
+    FillNodeInfoL(email,accessTypesNode,MSmlDmDDFObject::EOne,
+                  MSmlDmDDFObject::EPermanent,
+                  MSmlDmDDFObject::ENode,KNSmlDMEmailDescription);
+
+    accessTypesNode.SetAdd();
+    accessTypesNode.SetDelete();
+    accessTypesNode.SetReplace();
+    MSmlDmDDFObject& rtNode = email.AddChildObjectGroupL();
+
+
+    FillNodeInfoL(rtNode,accessTypesNode,MSmlDmDDFObject::EZeroOrMore,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::ENode,
+                  KNSmlDMDynamicNodeDescription);
+
+    TSmlDmAccessTypes accessTypes;
+    accessTypes.SetGet();
+    accessTypes.SetAdd();
+    accessTypes.SetReplace();
+    //displayable account name
+    MSmlDmDDFObject& name = rtNode.AddChildObjectL(KNSmlDMEmailName);
+    FillNodeInfoL(name,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMNameDescription);
+
+    //user id for email account
+    MSmlDmDDFObject& uid = rtNode.AddChildObjectL(KNSmlDMEmailUID);
+    FillNodeInfoL(uid,accessTypes,MSmlDmDDFObject::EOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMUIDDescription);
+
+    //password for email account
+    TSmlDmAccessTypes accessTypesPw;
+    accessTypesPw.SetAdd();
+    accessTypesPw.SetReplace();
+    MSmlDmDDFObject& pw = rtNode.AddChildObjectL(KNSmlDMEmailPW);
+    FillNodeInfoL(pw,accessTypesPw,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMPWDescription);
+
+    //user's email address
+    MSmlDmDDFObject& uaddr = rtNode.AddChildObjectL(KNSmlDMEmailUAddr);
+    FillNodeInfoL(uaddr,accessTypes,MSmlDmDDFObject::EOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMUAddrDescription);
+
+    //Displayable name for the user
+    MSmlDmDDFObject& uname = rtNode.AddChildObjectL(KNSmlDMEmailUName);
+    FillNodeInfoL(uname,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMUNameDescription);
+
+    //Host name for the receiving server
+    MSmlDmDDFObject& mrcv = rtNode.AddChildObjectL(KNSmlDMEmailMrcv);
+    FillNodeInfoL(mrcv,accessTypes,MSmlDmDDFObject::EOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMMrcvDescription);
+
+    //Host name for the sending server
+    MSmlDmDDFObject& msnd = rtNode.AddChildObjectL(KNSmlDMEmailMsnd);
+    FillNodeInfoL(msnd,accessTypes,MSmlDmDDFObject::EOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMMsndDescription);
+
+    //Remote mailbox protocol
+    MSmlDmDDFObject& mpro = rtNode.AddChildObjectL(KNSmlDMEmailMpro);
+    FillNodeInfoL(mpro,accessTypes,MSmlDmDDFObject::EOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMMproDescription);
+
+    //Use secure connection
+    MSmlDmDDFObject& useSecCon = rtNode.AddChildObjectL(KNSmlDMEmailUseSecCon);
+    FillNodeInfoL(useSecCon,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool,
+                  KNSmlDMUseSecConDescription);
+
+    //Use APop
+    MSmlDmDDFObject& useAPOP = rtNode.AddChildObjectL(KNSmlDMEmailUseAPOP);
+    FillNodeInfoL(useAPOP, accessTypes, MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EBool,
+                  KNSmlDMUseAPOPDescription );
+
+    //Use smtp authentication
+    MSmlDmDDFObject& useSauth = rtNode.AddChildObjectL(KNSmlDMEmailUseSauth);
+    FillNodeInfoL(useSauth,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool,
+                  KNSmlDMUseSauthDescription);
+
+    //smtp authentication user id
+    MSmlDmDDFObject& sauthUid = rtNode.AddChildObjectL(KNSmlDMEmailSauthUID);
+    FillNodeInfoL(sauthUid,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMSauthUIDDescription);
+
+    //Use smtp authentication
+    MSmlDmDDFObject& sauthPw = rtNode.AddChildObjectL(KNSmlDMEmailSauthPW);
+    FillNodeInfoL(sauthPw,accessTypesPw,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMSauthPWDescription);
+
+    //Use smtp authentication
+    MSmlDmDDFObject& ptxtSAuth = rtNode.AddChildObjectL(KNSmlDMEmailPtxtSAuth);
+    FillNodeInfoL(ptxtSAuth,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool,
+                  KNSmlDMPtxtSAuthDescription);
+
+    //Link to IAP
+    MSmlDmDDFObject& toNapId = rtNode.AddChildObjectL(KNSmlDMEmailToNapID);
+    FillNodeInfoL(toNapId,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMToNapIDDescription);
+
+    //Link to IAP for SMTP
+    MSmlDmDDFObject& sToNapId = rtNode.AddChildObjectL(KNSmlDMEmailSToNapID);
+    FillNodeInfoL(sToNapId,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMSToNapIDDescription);
+
+    //SSL/TLS used in SMTP
+    MSmlDmDDFObject& sUseSecCon = rtNode.
+        AddChildObjectL(KNSmlDMEmailSUseSecCon);
+    FillNodeInfoL(sUseSecCon,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool,
+                  KNSmlDMSUseSecConDescription);
+
+    //StartTLS used in IMAP/POP
+    MSmlDmDDFObject& useStartTls = rtNode.
+        AddChildObjectL(KNSmlDMEmailUseStartTLS);
+    FillNodeInfoL(useStartTls,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool,
+                  KNSmlDMUseStartTLSDescription);
+
+    //StartTLS used in SMTP
+    MSmlDmDDFObject& sUseStartTls = rtNode.
+        AddChildObjectL(KNSmlDMEmailSUseStartTLS);
+    FillNodeInfoL(sUseStartTls,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EBool,
+                  KNSmlDMSUseStartTLSDescription);
+
+    //port of IMAP/POP server
+    MSmlDmDDFObject& mrcvPort = rtNode.AddChildObjectL(KNSmlDMEmailMrcvPort);
+    FillNodeInfoL(mrcvPort,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EInt,
+                  KNSmlDMMrcvPortDescription);
+
+    //port of SMTP server
+    MSmlDmDDFObject& msndPort = rtNode.AddChildObjectL(KNSmlDMEmailMsndPort);
+    FillNodeInfoL(msndPort,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EInt,
+                  KNSmlDMMsndPortDescription);
+
+    //IMAP folder path
+    MSmlDmDDFObject& folderPath = rtNode.
+        AddChildObjectL(KNSmlDMEmailFolderPath);
+    FillNodeInfoL(folderPath,accessTypes,MSmlDmDDFObject::EZeroOrOne,
+                  MSmlDmDDFObject::EDynamic,MSmlDmDDFObject::EChr,
+                  KNSmlDMFolderPathDescription);
+
+    _DBG_FILE("CNSmlDmEmailAdapter::DDFStructureL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmEmailAdapter::UpdateLeafObjectL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
+                                             const TDesC8& aLUID,
+                                             const TDesC8& aObject,
+                                             const TDesC8& /*aType*/,
+                                             const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): begin");
+
+    TInt index = -1;
+    TBool firstAdd = EFalse;
+
+    for(TInt i = 0; i<iBuffer->Count(); i++)
+        {
+        TPtrC8 parentUri = RemoveLastURISeg(aURI);
+        //Check Node from buffer if match
+        if(iBuffer->At(i).iMappingName->Compare(parentUri) == 0 )
+            {
+            firstAdd = ETrue;
+            index = i;
+            break;
+            }
+        }
+ 	
+ 	TInt luid = DesToInt(aLUID);
+			
+    if(aLUID.Length()==0 && index<0)
+        {
+        	luid = ConstructTreeL(aURI);
+        	if(luid == -1)        	
+        	{
+        		Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+        		_DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end");
+        		return;
+        	}
+        }
+
+    if( OpenSessionL() != KErrNone )
+        {
+        Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+        _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end");
+        return;
+        }
+
+    if(!firstAdd)
+        {
+
+        if(LastURISeg(aURI).Compare(KNSmlDMEmailMpro)==0)
+            {
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end");
+            return;
+            }
+        index = -1;
+        for(TInt i=0;i<iBuffer->Count();i++)
+            {
+            if(iBuffer->At(i).iLuid == luid)
+                {
+                index = i;
+                break;
+                }
+            }
+
+        if(index<0)
+            {
+            TNSmlEmailSettingsElement newNode;
+            newNode.iImap4Settings = NULL;
+            newNode.iPop3Settings = NULL;
+            newNode.iSmtpSettings = NULL;
+            newNode.iIapPref = NULL;
+            newNode.iSmtpIapPref = NULL;
+            newNode.iLuid = luid;
+            newNode.iMappingName = aURI.AllocLC();
+            newNode.iName = HBufC::NewLC(0);
+            newNode.iNodeBuf = new (ELeave) CArrayFixFlat 
+                <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity);
+            newNode.iExecuted = ETrue;
+            GetIdByLuid(newNode.iAccType, newNode.iAccId, luid); 
+            iBuffer->AppendL(newNode);
+            index = iBuffer->Count() - 1;
+            TInt err = DoRestoreSettingsL(index);
+            if(err!=KErrNone)
+                {
+                CleanupStack::PopAndDestroy(2); //newNode.iMappingName,newNode.iName
+                newNode.iMappingName = NULL;
+                newNode.iName = NULL;
+                iBuffer->At(index).iNodeBuf->Reset();
+                delete iBuffer->At(index).iNodeBuf;
+                iBuffer->Delete(index);
+                }
+            if(err==KErrNotFound)
+                {
+                Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end");
+                return;
+                }
+            else if(err!=KErrNone)
+                {
+                Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end");
+                return;
+                }
+            CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName
+            }
+        TNSmlEmailCommandElement newCommand;
+        newCommand.iLastUriSeg = LastURISeg(aURI).AllocLC();
+        newCommand.iData = NULL;
+        newCommand.iStatusRef = aStatusRef;
+        newCommand.iLeaf = ETrue;
+        newCommand.iStatus = CSmlDmAdapter::EOk;
+        iBuffer->At(index).iNodeBuf->AppendL(newCommand);
+        CleanupStack::Pop(); //newCommand.iLastUriSeg
+        iBuffer->At(index).iJustFetch=EFalse;
+        DoAddLeafObjectL(newCommand.iLastUriSeg->Des(),aObject,index,
+                         iBuffer->At(index).iNodeBuf->Count()-1);
+        }
+    else
+        {
+        FirstAddLeafL(aURI,aObject,aStatusRef,index);
+        }
+
+    _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::DeleteObjectL( const TDesC8& aURI,
+//                                         const TDesC8& aLUID,
+//                                         const TInt aStatusRef )
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::DeleteObjectL( const TDesC8& aURI,
+                                         const TDesC8& aLUID,
+                                         const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): begin");
+    if(NumOfURISegs(aURI)==2)
+        {
+        if(aLUID.Length()==0)
+            {
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): ENotFound end");
+            return;
+            }
+
+        TInt luid = DesToInt(aLUID);
+        TInt err = OpenSessionL();
+        if(err!=KErrNone)
+            {
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): EError end");
+            return;
+            }
+        CEmailAccounts* emailAccs = CEmailAccounts::NewLC();
+        TNSmlEmailAccountType accType;
+        TInt id;
+        GetIdByLuid(accType, id, luid );
+        if( AccountExistsL( emailAccs, accType, id, -1 ) )
+            {
+            switch ( accType )
+                {
+            case EImap:
+                {
+                RArray<TImapAccount> imap4Accs;
+                CleanupClosePushL( imap4Accs );
+                emailAccs->GetImapAccountsL( imap4Accs );
+                
+                for (TInt i(0); i < imap4Accs.Count(); i++)
+                    {
+                    if ( imap4Accs[i].iImapAccountId == id  ) 
+                        {
+                        // Delete also related Smtp account
+                        TSmtpAccount relatedSmtp;
+                        emailAccs->GetSmtpAccountL( imap4Accs[i].iSmtpService, relatedSmtp );
+                        emailAccs->DeleteImapAccountL( imap4Accs[i] );
+                        emailAccs->DeleteSmtpAccountL( relatedSmtp );                       
+                        //The only email a/c in phone gettiong deleted , so delete the default sntp a/c                     
+                        if( imap4Accs.Count() == 1 )
+	                        {
+	                        TInt deferr = KErrNone;
+                        	TRAP(deferr, emailAccs->DeleteDefaultSmtpAccountL());
+                        	DBG_ARGS(_S16("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): Delete default smtp account Error code %d"),deferr);
+    	                    }
+                        break;   
+                        }
+                    }
+                
+                CleanupStack::PopAndDestroy(&imap4Accs); //imap4Accs
+                
+                // If the default account was just deleted,
+                // new one needs to be set.
+                // 
+	            TSmtpAccount defaultSmtp;
+	            TInt retVal = emailAccs->DefaultSmtpAccountL( defaultSmtp );
+	            if (  retVal != KErrNone )
+	                {
+                    RArray<TImapAccount> imapAccs;
+                    CleanupClosePushL( imapAccs );
+                    emailAccs->GetImapAccountsL( imapAccs );
+                    if ( imapAccs.Count() > 0 )
+                        {
+                        TSmtpAccount relatedSmtp;
+                        emailAccs->GetSmtpAccountL( imapAccs[0].iSmtpService, relatedSmtp );
+	                    emailAccs->SetDefaultSmtpAccountL( relatedSmtp );
+                        }
+                    CleanupStack::PopAndDestroy( &imapAccs );
+                    RArray<TPopAccount> popAccounts;
+                    CleanupClosePushL( popAccounts );
+                    emailAccs->GetPopAccountsL( popAccounts );
+                    if ( popAccounts.Count() > 0 )
+                        {
+                        TSmtpAccount relatedSmtp;
+                        emailAccs->GetSmtpAccountL( popAccounts[0].iSmtpService, relatedSmtp );
+	                    emailAccs->SetDefaultSmtpAccountL( relatedSmtp );
+                        }
+                    CleanupStack::PopAndDestroy( &popAccounts );
+	                }	                
+                break;    
+                }
+                
+            case EPop:
+                {
+                RArray<TPopAccount> popAccs;
+                CleanupClosePushL( popAccs );
+                emailAccs->GetPopAccountsL( popAccs );
+                
+                for (TInt i(0); i < popAccs.Count(); i++)
+                    {
+                    if ( popAccs[i].iPopAccountId == id  ) 
+                        {
+                        // Delete also related Smtp account
+                        TSmtpAccount relatedSmtp;
+                        emailAccs->GetSmtpAccountL( popAccs[i].iSmtpService, relatedSmtp );
+                        emailAccs->DeletePopAccountL( popAccs[i] );    
+                        emailAccs->DeleteSmtpAccountL( relatedSmtp );
+                        if( popAccs.Count() == 1 )
+                        	{
+                        	TInt deferr = KErrNone;
+                        	TRAP(deferr, emailAccs->DeleteDefaultSmtpAccountL());
+                        	DBG_ARGS(_S16("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): Delete default smtp account Error code %d "),deferr);
+                        	}
+                        break;                                             
+                        }
+                    }
+                
+                CleanupStack::PopAndDestroy(); //popAccs
+
+                // If the default account was just deleted,
+                // new one needs to be set.
+                // 
+	            TSmtpAccount defSmtp;
+	            TInt retVal = emailAccs->DefaultSmtpAccountL( defSmtp );
+	            if (  retVal != KErrNone )
+	                {
+                    RArray<TPopAccount> popAccounts;
+                    CleanupClosePushL( popAccounts );
+                    emailAccs->GetPopAccountsL( popAccounts );
+                    if ( popAccounts.Count() > 0 )
+                        {
+                        TSmtpAccount relatedSmtp;
+                        emailAccs->GetSmtpAccountL( popAccounts[0].iSmtpService, relatedSmtp );
+	                    emailAccs->SetDefaultSmtpAccountL( relatedSmtp );
+                        }
+                    CleanupStack::PopAndDestroy( &popAccounts );
+                    RArray<TImapAccount> imapAccs;
+                    CleanupClosePushL( imapAccs );
+                    emailAccs->GetImapAccountsL( imapAccs );
+                    if ( imapAccs.Count() > 0 )
+                        {
+                        TSmtpAccount relatedSmtp;
+                        emailAccs->GetSmtpAccountL( imapAccs[0].iSmtpService, relatedSmtp );
+	                    emailAccs->SetDefaultSmtpAccountL( relatedSmtp );
+                        }
+                    CleanupStack::PopAndDestroy( &imapAccs );                    
+	                }	                
+                break;
+                }                
+                
+            default:
+                Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                break;
+                }
+
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            }
+        else
+            {
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            }
+        CleanupStack::PopAndDestroy(); //emailAccs
+        }
+    else
+        {
+        Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+        }
+
+    _DBG_FILE("CNSmlDmEmailAdapter::DeleteLeafObjectL( ): end");
+    }
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmEmailAdapter::FetchLeafObjectL( const TDesC8& aURI,
+//                                            const TDesC8& aLUID,
+//                                            const TDesC8& aType,
+//                                            const TInt aResultsRef,
+//                                            const TInt aStatusRef )
+//  
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::FetchLeafObjectL( const TDesC8& aURI,
+                                            const TDesC8& aLUID,
+                                            const TDesC8& aType,
+                                            const TInt aResultsRef,
+                                            const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): begin");
+		
+	TInt luid = DesToInt(aLUID);	
+			
+    if(aLUID.Length()==0)
+        {
+        	luid = ConstructTreeL(aURI);
+        	if(luid == -1)        	
+        	{
+        		Callback().SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+        		_DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): ENotFound end");
+        		return;
+        	}
+        }
+    if( OpenSessionL() != KErrNone )
+        {
+        Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+        _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): EError end");
+        return;
+        }
+
+    TInt index  = -1;
+    for(TInt i=0;i<iBuffer->Count();i++)
+        {
+        if(iBuffer->At(i).iLuid == luid)
+            {
+            index = i;
+            break;
+            }
+        }
+
+    if(index<0)
+        {
+        TNSmlEmailSettingsElement newNode;
+        newNode.iImap4Settings = NULL;
+        newNode.iPop3Settings = NULL;
+        newNode.iSmtpSettings = NULL;
+        newNode.iIapPref = NULL;
+        newNode.iSmtpIapPref = NULL;
+        newNode.iLuid = luid;
+        newNode.iMappingName = aURI.AllocLC();
+        newNode.iName = HBufC::NewLC(0);
+        newNode.iNodeBuf = new (ELeave)
+            CArrayFixFlat <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity);
+        newNode.iExecuted = ETrue;
+        newNode.iJustFetch = ETrue;
+        GetIdByLuid(newNode.iAccType, newNode.iAccId, luid);
+        iBuffer->AppendL(newNode);
+        index = iBuffer->Count() - 1;
+        if( DoRestoreSettingsL(index) != KErrNone )
+            {
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName
+            _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): EError end");
+            return;
+            }
+        CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName
+        }
+
+    TPtrC8 lastUriSeg = LastURISeg(aURI);
+    CBufBase* object = CBufFlat::NewL(32);
+    CleanupStack::PushL(object);
+    CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
+
+    if(lastUriSeg.Compare(KNSmlDMEmailName)==0)
+        {
+        HBufC8 *data = HBufC8::NewLC(iBuffer->At(index).iName->Length());
+        TPtr8 dataPtr = data->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( 
+            dataPtr,iBuffer->At(index).iName->Des() );
+        object->InsertL(0,dataPtr);
+        CleanupStack::PopAndDestroy(); //data
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailUID)==0)
+        {
+        HBufC *data = NULL;
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->LoginName().Length());
+            data->Des().Copy(iBuffer->At(index).iPop3Settings->LoginName());
+            }
+        else if(iBuffer->At(index).iImap4Settings!= NULL)
+            {
+            data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->LoginName().Length());
+            data->Des().Copy(iBuffer->At(index).iImap4Settings->LoginName());
+            }
+        if(data)
+            {
+            HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data);
+            CleanupStack::PushL(data8);
+            object->InsertL(0,*data8);
+            CleanupStack::PopAndDestroy(2);//data, data8
+            }
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailPW)==0)
+        {
+        HBufC *data = NULL;
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->Password().Length());
+            data->Des().Copy(iBuffer->At(index).iPop3Settings->Password());
+            }
+        else if(iBuffer->At(index).iImap4Settings!= NULL)
+            {
+            data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->Password().Length());
+            data->Des().Copy(iBuffer->At(index).iImap4Settings->Password());
+            }
+        if(data)
+            {
+            HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data);
+            CleanupStack::PushL(data8);
+            object->InsertL(0,*data8);
+            CleanupStack::PopAndDestroy(2);//data, data8
+            }
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailUAddr)==0)
+        {
+        HBufC *data = NULL;
+        data = iBuffer->At(index).iSmtpSettings->EmailAddress().AllocLC();
+        HBufC8 *data8 = HBufC8::NewLC(data->Size());
+        TPtr8 dataPtr8 = data8->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
+
+        object->InsertL(0,dataPtr8);
+        CleanupStack::PopAndDestroy(2); //data, data8
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailUName)==0)
+        {
+
+        HBufC *data = NULL;
+        data = iBuffer->At(index).iSmtpSettings->EmailAlias().AllocLC();
+        HBufC8 *data8 = HBufC8::NewLC(data->Size());
+        TPtr8 dataPtr8 = data8->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
+
+        object->InsertL(0,dataPtr8);
+        CleanupStack::PopAndDestroy(2); //data, data8
+        }
+
+    else if(lastUriSeg.Compare( KNSmlDMEmailMrcv)==0)
+        {
+        HBufC *data = NULL;
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            data = iBuffer->At(index).iPop3Settings->ServerAddress().AllocLC();
+            }
+        else if(iBuffer->At(index).iImap4Settings!= NULL)
+            {
+            data = iBuffer->At(index).iImap4Settings->ServerAddress().AllocLC();
+            }
+        else
+        	{
+          	status = CSmlDmAdapter::ENotFound;
+        	}
+        if(data)
+        	{	    
+        		HBufC8 *data8 = HBufC8::NewLC(data->Size());
+        		TPtr8 dataPtr8 = data8->Des();
+        		CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
+
+        		object->InsertL(0,dataPtr8);
+        		CleanupStack::PopAndDestroy(2); //data, data8
+        	}
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailMsnd)==0)
+        {
+        HBufC *data = NULL;
+        data = iBuffer->At(index).iSmtpSettings->ServerAddress().AllocLC();
+        HBufC8 *data8 = HBufC8::NewLC(data->Size());
+        TPtr8 dataPtr8 = data8->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
+
+        object->InsertL(0,dataPtr8);
+        CleanupStack::PopAndDestroy(2); //data, data8
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailMpro)==0)
+        {
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            object->InsertL(0,KNSmlDMEmailMproPOP);
+            }
+        else if(iBuffer->At(index).iImap4Settings!= NULL)
+            {
+            object->InsertL(0,KNSmlDMEmailMproIMAP);
+            }
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailUseSecCon)==0)
+        {
+        FetchSecurityValueL(*object, &iBuffer->At(index), EUseSecCon );
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailUseSauth)==0)
+        {
+        if(iBuffer->At(index).iSmtpSettings->SMTPAuth())
+            {
+            object->InsertL(0,KNSmlDMEmailTrue);
+            }
+        else
+            {
+            object->InsertL(0,KNSmlDMEmailFalse);
+            }
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailSauthUID)==0)
+        {
+        HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->LoginName().Length());
+        data->Des().Copy(iBuffer->At(index).iSmtpSettings->LoginName());
+        HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data);
+        CleanupStack::PushL(data8);
+        object->InsertL(0,*data8);
+        CleanupStack::PopAndDestroy(2);//data, data8
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailSauthPW)==0)
+        {
+        HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->Password().Length());
+        data->Des().Copy(iBuffer->At(index).iSmtpSettings->Password());
+        HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data);
+        CleanupStack::PushL(data8);
+        object->InsertL(0,*data8);
+        CleanupStack::PopAndDestroy(2);//data, data8
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailPtxtSAuth)==0)
+        {
+        if(iBuffer->At(index).iSmtpSettings->InboxLoginDetails())
+            {
+            object->InsertL(0,KNSmlDMEmailTrue);
+            }
+        else
+            {
+            object->InsertL(0,KNSmlDMEmailFalse);
+            }
+        }
+
+    else if (lastUriSeg.Compare(KNSmlDMEmailSUseSecCon)==0)
+        {
+        FetchSecurityValueL(*object, &iBuffer->At(index), ESuseSecCon );
+        }
+
+    else if (lastUriSeg.Compare(KNSmlDMEmailUseStartTLS)==0)
+        {
+        FetchSecurityValueL(*object, &iBuffer->At(index), EUseStartTls );
+        }
+
+    else if (lastUriSeg.Compare(KNSmlDMEmailSUseStartTLS)==0)
+        {
+        FetchSecurityValueL(*object, &iBuffer->At(index), ESuseStartTls );
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailMrcvPort)==0)
+        {
+        TUint port;
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            port = iBuffer->At(index).iPop3Settings->Port();
+            }
+        else 
+            {
+            port = iBuffer->At(index).iImap4Settings->Port();
+            }
+        HBufC8 *data = IntToDes8LC(port);
+        object->InsertL(0,data->Des());
+        CleanupStack::PopAndDestroy(); //data
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailMsndPort)==0)
+        {
+        TUint port = iBuffer->At(index).iSmtpSettings->Port();
+        HBufC8 *data = IntToDes8LC(port);
+        object->InsertL(0,data->Des());
+        CleanupStack::PopAndDestroy(); //data
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailUseAPOP)==0)
+        {
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            if(iBuffer->At(index).iPop3Settings->Apop())
+                {
+                object->InsertL(0,KNSmlDMEmailTrue);
+                }
+            else
+                {
+                object->InsertL(0,KNSmlDMEmailFalse);
+                }
+            }
+        else
+            {
+            status = CSmlDmAdapter::ENotFound;
+            }
+        }
+
+    else if (lastUriSeg.Compare(KNSmlDMEmailFolderPath)==0)
+        {
+        if(iBuffer->At(index).iImap4Settings)
+            {
+            object->InsertL(0, iBuffer->At(index).iImap4Settings->FolderPath() );
+            }
+        else
+            {
+            status = CSmlDmAdapter::ENotFound;
+            }
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailToNapID)==0)
+        {
+
+        CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() );
+        CleanupStack::PushL(iapmatch);
+        HBufC8* uri8 = NULL;
+        TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs();
+        if ( iapCount )
+            {
+            TImIAPChoice localIAP = iBuffer->At(index).iIapPref->IAPPreference(0);
+            uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP );
+            }
+
+        if( uri8 )
+            {
+            CleanupStack::PushL(uri8);
+            object->InsertL(0,uri8->Des());
+            status = CSmlDmAdapter::EOk;
+            CleanupStack::PopAndDestroy(); // uri8
+            }        
+
+        CleanupStack::PopAndDestroy(); // iapMatch
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailSToNapID)==0)
+        {
+
+        // SToNapID exists only for SMTP
+        if (iBuffer->At(index).iSmtpSettings!= NULL)
+            {
+            CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() );
+            CleanupStack::PushL(iapmatch);
+            HBufC8* uri8 = NULL;
+            TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs();
+            if ( iapCount )
+                {
+                TImIAPChoice localIAP = iBuffer->At(index).iSmtpIapPref->IAPPreference(0);
+                uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP );
+                }
+
+            if( uri8 )
+                {
+                CleanupStack::PushL(uri8);
+                object->InsertL(0,uri8->Des());
+                status = CSmlDmAdapter::EOk;
+                CleanupStack::PopAndDestroy(); // uri8
+                }           
+
+            CleanupStack::PopAndDestroy(); // iapMatch
+            }
+        else
+            {
+            status = CSmlDmAdapter::ENotFound;
+            }
+        }
+
+    if(status == CSmlDmAdapter::EOk)
+        {
+        Callback().SetResultsL(aResultsRef,*object,aType);
+        }
+    Callback().SetStatusL(aStatusRef, status);
+    CleanupStack::PopAndDestroy(object); //object
+
+    _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmEmailAdapter::ChildURIListL( const TDesC8& aURI,
+//                                          const TDesC8& aParentLUID,
+//                                          const CArrayFix<TSmlDmMappingInfo>& 
+//                                          aPreviousURISegmentList,
+//                                          const TInt aResultsRef,
+//                                          const TInt aStatusRef  )
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::ChildURIListL( const TDesC8& aURI,
+                                         const TDesC8& aParentLUID,
+                                         const CArrayFix<TSmlDmMappingInfo>& 
+                                         aPreviousURISegmentList,
+                                         const TInt aResultsRef,
+                                         const TInt aStatusRef  )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::ChildURIListL(): begin");
+
+    CSmlDmAdapter::TError ret = CSmlDmAdapter::EError;
+
+    if( OpenSessionL() != KErrNone )
+        {
+        Callback().SetStatusL(aStatusRef, ret);
+        _DBG_FILE("CNSmlDmEmailAdapter::ChildURIListL(): end");
+        return;
+        }
+    CBufBase *currentList = CBufFlat::NewL(128);
+    CleanupStack::PushL(currentList);
+
+    CEmailAccounts* emailAccs = CEmailAccounts::NewLC();
+
+    if(aURI.Compare(KNSmlDMEmailNodeName)==0)
+        {
+        RArray<TImapAccount> imap4Accounts;
+        CleanupClosePushL( imap4Accounts );
+        emailAccs->GetImapAccountsL(imap4Accounts);
+
+        // First, IMAP accounts
+        //
+        TInt luid;
+        TPtrC8 name;
+        // cycle through every found account
+        for(TInt count = 0; count < imap4Accounts.Count(); count++)
+            {
+            SetLuidById( EImap, imap4Accounts[count].iImapAccountId, luid );
+
+            TBool found = EFalse;
+            // cycle through every known account
+            for(TInt i = 0; i<aPreviousURISegmentList.Count();i++)
+                {
+                // compare if found is known
+                if( luid == DesToInt(aPreviousURISegmentList.At(i).iURISegLUID))
+                    {
+                    found = ETrue;
+                    name.Set(aPreviousURISegmentList.At(i).iURISeg);
+                    break;
+                    }
+                }
+            // if found != known add mapping to it
+            if(!found)
+                {
+                HBufC8 *uri = HBufC8::NewLC(aURI.Length() + 
+                                            KNSmlDMEmailMproIMAP().Length() + 6);
+                                            
+                TPtr8 uriPtr = uri->Des();
+                uriPtr.Format(aURI);
+                uriPtr.Append(KNSmlDMEmailSeparator8);
+                uriPtr.Append(KNSmlDMEmailMproIMAP);
+                TUint16 crc;
+               	Mem::Crc ( crc, &imap4Accounts[count],sizeof(TImapAccount) );
+                HBufC8 *crcBuf = IntToDes8LC(crc);
+                uriPtr.Append(*crcBuf);
+                HBufC8 *luidBuf = IntToDes8LC(luid);
+                Callback().SetMappingL(uriPtr,luidBuf->Des());
+                currentList->InsertL( currentList->Size(),LastURISeg(uriPtr));
+                CleanupStack::PopAndDestroy(3); //uri,luidBuf, crcBuf
+                }
+            else
+                {
+                currentList->InsertL( currentList->Size(),name );
+                }
+            // in all cases: add it to results.
+            if(count < imap4Accounts.Count()-1 )
+                {
+                currentList->InsertL(currentList->Size(),KNSmlDMEmailSeparator8);
+                }
+            }
+        CleanupStack::PopAndDestroy(); //imap4Accounts
+
+        // Then, POP accounts
+        //
+        RArray<TPopAccount> pop3Accounts;
+        CleanupClosePushL( pop3Accounts );
+        emailAccs->GetPopAccountsL( pop3Accounts );
+        if (pop3Accounts.Count()&&currentList->Size()>0)
+            {
+            // there is at least one account; insert separator
+            currentList->InsertL(currentList->Size(),KNSmlDMEmailSeparator8);
+            }
+        // cycle through every found account
+        for(TInt count = 0; count < pop3Accounts.Count(); count++)
+            {
+            SetLuidById( EPop, pop3Accounts[count].iPopAccountId, luid );
+
+            TBool found = EFalse;
+            // cycle through every known account
+            for(TInt i = 0; i<aPreviousURISegmentList.Count();i++)
+                {
+                // compare if found is known
+                if( luid == DesToInt(aPreviousURISegmentList.At(i).iURISegLUID))
+
+                    {
+                    found = ETrue;
+                    name.Set(aPreviousURISegmentList.At(i).iURISeg);
+                    break;
+                    }
+                }
+            // if found != known add mapping to it
+            if(!found)
+                {
+                                         
+                HBufC8 *uri = HBufC8::NewLC(aURI.Length() + 
+                                            KNSmlDMEmailMproPOP().Length() + 5);
+                TPtr8 uriPtr = uri->Des();
+                uriPtr.Format(aURI);
+                uriPtr.Append(KNSmlDMEmailSeparator8);
+                uriPtr.Append(KNSmlDMEmailMproPOP);
+                TUint16 crc;
+               	Mem::Crc ( crc, &pop3Accounts[count],sizeof(TPopAccount) );
+                HBufC8 *crcBuf = IntToDes8LC(crc);
+                uriPtr.Append(*crcBuf);
+                HBufC8 *luidBuf = IntToDes8LC(luid);
+                Callback().SetMappingL(uriPtr,luidBuf->Des());
+                currentList->InsertL( currentList->Size(),LastURISeg(uriPtr));
+                CleanupStack::PopAndDestroy(3); //uri,luidBuf,crcBuf
+                }
+            else
+                {
+                currentList->InsertL( currentList->Size(),name );
+                }
+            // in all cases: add it to results.
+            if(count < pop3Accounts.Count()-1)
+                {
+                currentList->InsertL(currentList->Size(),KNSmlDMEmailSeparator8);
+                }
+            }
+        CleanupStack::PopAndDestroy(); //pop3Accounts
+        ret = CSmlDmAdapter::EOk;
+        }
+    else
+        {
+        if(aParentLUID.Length() > 0)
+            {
+            TInt err = KErrNotFound;
+            TInt luid = DesToInt(aParentLUID);
+            TNSmlEmailAccountType accType;
+            TInt id;
+            GetIdByLuid( accType, id, luid );
+            switch ( accType )
+                {
+            case EImap:
+                {
+                RArray<TImapAccount> imap4Accounts;
+                CleanupClosePushL( imap4Accounts );
+                emailAccs->GetImapAccountsL( imap4Accounts ); 
+                for ( TInt i=0; i<imap4Accounts.Count(); i++ )
+                    {
+                    if ( imap4Accounts[i].iImapAccountId == id )
+                        {
+                        err = KErrNone;
+                        break;
+                        }
+                    }
+                CleanupStack::PopAndDestroy(); //imap4Accounts    
+                break;                
+                }
+            case EPop:
+                {
+                RArray<TPopAccount> pop3Accounts;
+                CleanupClosePushL( pop3Accounts );
+                emailAccs->GetPopAccountsL(pop3Accounts); 
+                for ( TInt i=0; i<pop3Accounts.Count(); i++ )
+                    {
+                    if ( pop3Accounts[i].iPopAccountId == id )
+                        {
+                        err = KErrNone;
+                        break;
+                        }
+                    }
+                CleanupStack::PopAndDestroy(); //pop3Accounts       
+                break;                
+                }
+            default:
+                ret = CSmlDmAdapter::EError;
+                break;
+                }
+            if( err == KErrNotFound )
+                {
+                ret = CSmlDmAdapter::ENotFound;
+                }
+            
+            if ( err == KErrNone )
+                {
+                ret = CSmlDmAdapter::EOk;
+                currentList->InsertL(0,KNSmlDMEmailListOfLeafs);
+                }
+            }
+        else
+            {
+            ret = CSmlDmAdapter::ENotFound;
+            }
+        }
+    // Common part
+    Callback().SetStatusL(aStatusRef, ret);
+    if( ret == CSmlDmAdapter::EOk )
+        {
+        Callback().SetResultsL(aResultsRef,*currentList,KNullDesC8);
+        }
+
+    CleanupStack::PopAndDestroy(emailAccs); //emailAccs
+    CleanupStack::PopAndDestroy(currentList); //currentList
+    _DBG_FILE("CNSmlDmEmailAdapter::ChildURIListL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::AddNodeObjectL( const TDesC8& aURI, 
+// const TDesC8& aParentLUID, const TInt aStatusRef )
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::AddNodeObjectL( const TDesC8& aURI,
+                                          const TDesC8& aParentLUID,
+                                          const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): begin");
+
+    if(aParentLUID.Length()>0)
+        {
+        TInt luid = DesToInt(aParentLUID);
+        TInt accId;
+        TNSmlEmailAccountType accType;
+        GetIdByLuid( accType, accId, luid );
+        TInt err = OpenSessionL();
+        if(err!=KErrNone)
+            {
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EError end");
+            return;
+            }
+        CEmailAccounts* emailAccs = CEmailAccounts::NewLC();
+        TBool accEx = AccountExistsL( emailAccs, accType, accId, -1 );
+        CleanupStack::PopAndDestroy( emailAccs );
+        if( accEx )
+            {
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EAlreadyExists);
+            _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EAlreadyExists end");
+            return;
+            }
+        else
+            {
+            TInt ret = Callback().RemoveMappingL( KNSmlDMEmailAdapterImplUid, 
+						GetDynamicEmailNodeUri(aURI), ETrue );
+			if(ret != KErrNone)
+				{
+            	Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+	            _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EError end");
+            	return;
+				}
+            }
+        Callback().SetMappingL(aURI,KNullDesC8);
+        }
+
+    if( aURI.Find(KNSmlDMEmailNodeName)>=0 && NumOfURISegs(aURI)==2 )
+        {
+        if( OpenSessionL() != KErrNone )
+            {
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EError end");
+            return;
+            }
+
+        RFs fs;
+        User::LeaveIfError( fs.Connect() );
+        CleanupClosePushL(fs);
+        //2files and 2 folders are needed for settings
+        if (SysUtil::FFSSpaceBelowCriticalLevelL(&fs,
+                                                 KNSmlDmFatMinimumFileSize*4))
+            {
+            CleanupStack::PopAndDestroy(); //fs
+            Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EDiskFull);
+            _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): EDiskFull end");
+            return;
+            // do not write
+            }
+        CleanupStack::PopAndDestroy(); //fs
+
+
+        TNSmlEmailSettingsElement newNode;
+        newNode.iMappingName = aURI.AllocLC();
+        newNode.iName = HBufC::NewLC(0);
+        newNode.iNodeBuf = new (ELeave)
+            CArrayFixFlat <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity);
+        newNode.iExecuted = EFalse;
+        newNode.iImap4Settings = NULL;
+        newNode.iPop3Settings = NULL;
+        newNode.iSmtpSettings = NULL;
+        newNode.iIapPref = NULL;
+        newNode.iSmtpIapPref = NULL;
+        newNode.iLuid = 0;
+        newNode.iJustFetch=EFalse;
+        iBuffer->AppendL(newNode);
+        CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName
+        TNSmlEmailCommandElement newCommand;
+        newCommand.iLastUriSeg = LastURISeg(aURI).AllocLC(); //aURI.AllocLC();
+        newCommand.iData = NULL;
+        newCommand.iStatusRef = aStatusRef;
+        newCommand.iLeaf = EFalse;
+        newCommand.iStatus = CSmlDmAdapter::EOk;
+        TInt index = iBuffer->Count() - 1;
+        iBuffer->At(index).iNodeBuf->AppendL(newCommand);
+        CleanupStack::Pop(); //newCommand.iLastUriSeg
+
+
+        }
+    _DBG_FILE("CNSmlDmEmailAdapter::AddNodeObjectL(): end");
+    }
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::UpdateLeafObjectL( const TDesC8& aURI,
+// const TDesC8& aLUID, RWriteStream*& aStream, const TDesC8& aType,
+// const TInt aStatusRef )
+// This should update a stream object, but in case of Email settings streaming 
+// is not supported.
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::UpdateLeafObjectL( const TDesC8& /*aURI*/,
+                                             const TDesC8& /*aLUID*/,
+                                             RWriteStream*& /*aStream*/,
+                                             const TDesC8& /*aType*/,
+                                             const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(stream): begin");
+    Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlDmEmailAdapter::UpdateLeafObjectL(stream): end");
+    }
+// -----------------------------------------------------------------------------
+// void CNSmlDmEmailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI,
+// const TDesC8& aLUID, const TDesC8& aType, const TInt aResultsRef,
+// const TInt aStatusRef )
+// Fetches data object and returns its size.
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI,
+                                                const TDesC8& aLUID,
+                                                const TDesC8& aType,
+                                                const TInt aResultsRef,
+                                                const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectSizeL(): begin");
+
+    CBufBase *result = CBufFlat::NewL(32);
+    CleanupStack::PushL(result);
+    CSmlDmAdapter::TError status = FetchObjectL(aURI, aLUID, *result);
+    if( status == CSmlDmAdapter::EOk )
+        {
+        TInt objSizeInBytes = result->Size();
+        TBuf8<4> stringObjSizeInBytes;
+        stringObjSizeInBytes.Num( objSizeInBytes );
+        result->Reset();
+        result->InsertL( 0, stringObjSizeInBytes );
+        Callback().SetResultsL(aResultsRef, *result, aType);
+        }
+    Callback().SetStatusL(aStatusRef, status);
+    CleanupStack::PopAndDestroy(); //result
+    _DBG_FILE("CNSmlDmEmailAdapter::FetchLeafObjectSizeL(): end");
+    }
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::ExecuteCommandL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::ExecuteCommandL( const TDesC8& /*aURI*/,
+                                           const TDesC8& /*aLUID*/,
+                                           const TDesC8& /*aArgument*/,
+                                           const TDesC8& /*aType*/,
+                                           const TInt aStatusRef )
+    {
+    //Not supported
+    _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): begin");
+    Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::ExecuteCommandL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::ExecuteCommandL( const TDesC8& /*aURI*/,
+                                           const TDesC8& /*aLUID*/,
+                                           RWriteStream*& /*aStream*/,
+                                           const TDesC8& /*aType*/,
+                                           const TInt aStatusRef )
+    {
+    //Not supported
+    _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): begin");
+    Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlDmEmailAdapter::ExecuteCommandL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::CopyCommandL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/,
+                                        const TDesC8& /*aTargetLUID*/,
+                                        const TDesC8& /*aSourceURI*/,
+                                        const TDesC8& /*aSourceLUID*/,
+                                        const TDesC8& /*aType*/,
+                                        TInt aStatusRef )
+    {
+    //Not supported
+    _DBG_FILE("CNSmlDmEmailAdapter::CopyCommandL(): begin");
+    Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlDmEmailAdapter::CopyCommandL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::StartAtomicL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::StartAtomicL()
+    {
+    //Not supported
+    _DBG_FILE("CNSmlDmEmailAdapter::StartAtomicL(): begin");
+    _DBG_FILE("CNSmlDmEmailAdapter::StartAtomicL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::CommitAtomicL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::CommitAtomicL()
+    {
+    //Not supported
+    _DBG_FILE("CNSmlDmEmailAdapter::CommitAtomicL(): begin");
+    _DBG_FILE("CNSmlDmEmailAdapter::CommitAtomicL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::RollbackAtomicL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::RollbackAtomicL()
+    {
+    //Not supported
+    _DBG_FILE("CNSmlDmEmailAdapter::RollbackAtomicL(): begin");
+    _DBG_FILE("CNSmlDmEmailAdapter::RollbackAtomicL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::StreamingSupport()
+// -----------------------------------------------------------------------------
+TBool CNSmlDmEmailAdapter::StreamingSupport( TInt& /*aItemSize*/ )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::StreamingSupport(): begin");
+    _DBG_FILE("CNSmlDmEmailAdapter::StreamingSupport(): end");
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::StreamCommittedL()
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::StreamCommittedL()
+    {
+    //Not supported
+    _DBG_FILE("CNSmlDmEmailAdapter::StreamCommittedL(): begin");
+    _DBG_FILE("CNSmlDmEmailAdapter::StreamCommittedL(): end");
+    }
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::CompleteOutstandingCmdsL()
+// Indication of message ending. The buffered commands must be executed
+// before return of this function.
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::CompleteOutstandingCmdsL()
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::CompleteOutstandingCmdsL(): begin");
+
+    for(TInt i=0;i<iBuffer->Count();i++)
+        {
+
+        //Set buffered port values
+        for(TInt cmd=0;cmd<iBuffer->At(i).iNodeBuf->Count();cmd++)
+            {
+            
+            TNSmlEmailSettingsElement& bufElem = iBuffer->At(i);
+            TNSmlEmailCommandElement& elem = bufElem.iNodeBuf->At(cmd);
+
+            if(elem.iLastUriSeg->Compare(KNSmlDMEmailMrcvPort)==0)
+                {
+                TUint port = DesToInt(*elem.iData);
+                
+                if(port>0 && port <= KNSmlDMEmailMaxPortNbr)
+                    {
+                    if(bufElem.iPop3Settings!= NULL)
+                        {
+                        bufElem.iPop3Settings->SetPort(port);
+                        }
+                    else if(bufElem.iImap4Settings!= NULL)
+                        {
+                        bufElem.iImap4Settings->SetPort(port);
+                        }
+                    }
+                else
+                    {
+                    elem.iStatus = CSmlDmAdapter::EInvalidObject;
+                    }
+                }
+            else if(elem.iLastUriSeg->Compare(KNSmlDMEmailMsndPort)==0)
+                {
+                TUint port = DesToInt(*elem.iData);
+                
+                if(port>0 && port <= KNSmlDMEmailMaxPortNbr)
+                    {
+                    bufElem.iSmtpSettings->SetPort(port);
+                    }
+                else
+                    {
+                    elem.iStatus = CSmlDmAdapter::EInvalidObject;
+                    }
+                }
+                if((iBuffer->At(i).iSmtpSettings->LoginName()==KNullDesC8) && elem.iLastUriSeg->Compare(KNSmlDMEmailUID)==0)
+              	{
+                	elem.iStatus = CSmlDmAdapter::EError;
+        	      }
+           }
+        
+
+        CSmlDmAdapter::TError stat = CSmlDmAdapter::EOk;
+        TInt luid=-1;
+        
+        if(iBuffer->At(i).iExecuted)
+            {
+            TRAPD( leaveCode,luid = ValidateAndStoreSettingsL(i) );
+            if(leaveCode!=KErrNone)
+                {
+                stat = CSmlDmAdapter::EError;
+                }
+            }
+        else
+            {
+            stat = CSmlDmAdapter::EError;
+            }
+
+        for(TInt cmd=0;cmd<iBuffer->At(i).iNodeBuf->Count();cmd++)
+            {
+
+            if(iBuffer->At(i).iNodeBuf->At(cmd).iStatus==CSmlDmAdapter::EOk)
+                {
+                Callback().SetStatusL(iBuffer->At(i).iNodeBuf->At(cmd).iStatusRef,
+                                      stat);
+                if(!iBuffer->At(i).iNodeBuf->At(cmd).iLeaf)
+                    {
+                    if(stat==CSmlDmAdapter::EOk)
+                        {
+                        HBufC8* luidDes = IntToDes8LC(luid);
+                        Callback().SetMappingL( iBuffer->At(i).iMappingName->Des(),
+                                                luidDes->Des() );
+                        CleanupStack::PopAndDestroy(); //luidDes
+                        }
+                    }
+                }
+            else
+                {
+                Callback().SetStatusL(iBuffer->At(i).iNodeBuf->At(cmd).iStatusRef,
+                                      iBuffer->At(i).iNodeBuf->At(cmd).iStatus);
+                }
+
+            delete iBuffer->At(i).iNodeBuf->At(cmd).iLastUriSeg;
+            iBuffer->At(i).iNodeBuf->At(cmd).iLastUriSeg= NULL;
+            delete iBuffer->At(i).iNodeBuf->At(cmd).iData;
+            iBuffer->At(i).iNodeBuf->At(cmd).iData= NULL;
+
+            }
+        iBuffer->At(i).iNodeBuf->Reset();
+        delete iBuffer->At(i).iNodeBuf;
+        iBuffer->At(i).iNodeBuf = NULL;
+        delete iBuffer->At(i).iMappingName;
+        iBuffer->At(i).iMappingName= NULL;
+        delete iBuffer->At(i).iName;
+        iBuffer->At(i).iName= NULL;
+        delete iBuffer->At(i).iSmtpSettings;
+        iBuffer->At(i).iSmtpSettings= NULL;
+        delete iBuffer->At(i).iPop3Settings;
+        iBuffer->At(i).iPop3Settings= NULL;
+        delete iBuffer->At(i).iImap4Settings;
+        iBuffer->At(i).iImap4Settings= NULL;
+        delete iBuffer->At(i).iIapPref;
+        iBuffer->At(i).iIapPref= NULL;
+        delete iBuffer->At(i).iSmtpIapPref;
+        iBuffer->At(i).iSmtpIapPref= NULL;
+
+        } // end for
+    iBuffer->Reset();
+
+    _DBG_FILE("CNSmlDmEmailAdapter::CompleteOutstandingCmdsL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+
+#ifndef IMPLEMENTATION_PROXY_ENTRY
+#define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr)  {{aUid},(aFuncPtr)}
+#endif
+
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(KNSmlDMEmailAdapterImplUid, 
+                               CNSmlDmEmailAdapter::NewL)
+    };
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    _DBG_FILE("ImplementationGroupProxy() for CNSmlDmEmailAdapter: begin");
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    _DBG_FILE("ImplementationGroupProxy() for CNSmlDmEmailAdapter: end");
+    return ImplementationTable;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// TPtrC8 CNSmlDmEmailAdapter::LastURISeg(const TDesC8& aURI)
+// Returns only the last uri segemnt
+// -----------------------------------------------------------------------------
+TPtrC8 CNSmlDmEmailAdapter::LastURISeg(const TDesC8& aURI) const
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::LastURISeg() : begin");
+    TInt i;
+    for(i=aURI.Length()-1;i>=0;i--)
+        {
+        if(aURI[i]=='/')
+            {
+            break;
+            }
+        }
+    _DBG_FILE("CNSmlDmEmailAdapter::LastURISeg() : end");
+    if(i==0)
+        {
+        return aURI;
+        }
+    else
+        {
+        return aURI.Mid(i+1);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TPtrC8 CNSmlDmEmailAdapter::RemoveLastURISeg(const TDesC8& aURI)
+// returns parent uri, i.e. removes last uri segment
+// -----------------------------------------------------------------------------
+TPtrC8 CNSmlDmEmailAdapter::RemoveLastURISeg(const TDesC8& aURI) const
+    {
+    TInt i;
+    for(i=aURI.Length()-1;i>=0;i--)
+        {
+        if(aURI[i]=='/')
+            {
+            break;
+            }
+        }
+    return aURI.Left(i);
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// TInt CNSmlDmEmailAdapter::NumOfURISegs(const TDesC8& aURI)
+// Returns the num of uri segs
+// -----------------------------------------------------------------------------
+TInt CNSmlDmEmailAdapter::NumOfURISegs(const TDesC8& aURI) const
+    {
+    TInt numOfURISegs = 1;
+    for(TInt i=0;i<aURI.Length();i++)
+        {
+        if(aURI[i]=='/')
+            {
+            numOfURISegs++;
+            }
+        }
+    return numOfURISegs;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// void CNSmlDmEmailAdapter::HandleSessionEventL( TMsvSessionEvent /*aEvent*/,
+//                                               TAny* /*aArg1*/,
+//                                               TAny* /*aArg2*/,
+//                                               TAny* /*aArg3*/ )
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::HandleSessionEventL( TMsvSessionEvent /*aEvent*/,
+                                               TAny* /*aArg1*/,
+                                               TAny* /*aArg2*/,
+                                               TAny* /*aArg3*/ )
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::HandleSessionEventL(): begin");
+    _DBG_FILE("CNSmlDmEmailAdapter::HandleSessionEventL(): end");
+    }
+
+
+// -----------------------------------------------------------------------------
+// TInt CNSmlDmEmailAdapter::DesToInt(const TDesC& aLuid) const
+// Converts 16bit descriptor to int
+// -----------------------------------------------------------------------------
+TInt CNSmlDmEmailAdapter::DesToInt(const TDesC& aLuid) const
+    {
+    TLex16 lex(aLuid);
+    TInt value = 0;
+    lex.Val(value);
+    return value;
+    }
+
+// -----------------------------------------------------------------------------
+// TInt CNSmlDmEmailAdapter::DesToInt(const TDesC8& aLuid) const
+// Converts 8bit descriptor to int
+// -----------------------------------------------------------------------------
+TInt CNSmlDmEmailAdapter::DesToInt(const TDesC8& aLuid) const
+    {
+    TLex8 lex(aLuid);
+    TInt value = 0;
+    lex.Val(value);
+    return value;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::FirstAddLeafL()
+// -----------------------------------------------------------------------------
+TInt CNSmlDmEmailAdapter::FirstAddLeafL(const TDesC8& aURI, 
+                                        const TDesC8& aObject,
+                                        TInt aStatusRef,
+                                        TInt aIndex)
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::FirstAddLeafL() :: begin");
+
+    TPtrC8 lastSeg = LastURISeg(aURI);
+
+    TNSmlEmailCommandElement newCommand;
+    newCommand.iLastUriSeg = lastSeg.AllocLC();
+    newCommand.iData = aObject.AllocLC();
+    newCommand.iStatusRef = aStatusRef;
+    newCommand.iLeaf = ETrue;
+    newCommand.iStatus = CSmlDmAdapter::EOk;
+    iBuffer->At(aIndex).iNodeBuf->AppendL(newCommand);
+    CleanupStack::Pop(2); //newCommand.iLastUriSeg, newCommand.iData
+    if(!iBuffer->At(aIndex).iExecuted)
+        {
+        if(lastSeg.Compare(KNSmlDMEmailMpro)==0)
+            {
+            TBool ok = EFalse;
+            HBufC8* object = aObject.AllocLC();
+            TPtr8 objectPtr = object->Des();
+            objectPtr.UpperCase();
+
+            if(objectPtr.Find(KNSmlDMEmailMproPOP) >= 0)
+                {
+                iBuffer->At(aIndex).iPop3Settings = new(ELeave) CImPop3Settings;
+                ok=ETrue;
+                }
+
+            else if(objectPtr.Find(KNSmlDMEmailMproIMAP) >= 0)
+                {
+                iBuffer->At(aIndex).iImap4Settings = new(ELeave) CImImap4Settings;
+                ok=ETrue;
+                }
+            if(ok)
+                {
+                iBuffer->At(aIndex).iSmtpSettings = new(ELeave) CImSmtpSettings;
+                iBuffer->At(aIndex).iIapPref = CImIAPPreferences::NewLC();
+                iBuffer->At(aIndex).iSmtpIapPref = CImIAPPreferences::NewLC();
+                CleanupStack::Pop(); //iBuffer->At(index).iIapPref
+                CleanupStack::Pop(); //iBuffer->At(index).iSmtpIapPref
+                SetDefaultSettingsL(aIndex);
+
+                for(TInt i = 0; i<iBuffer->At(aIndex).iNodeBuf->Count();i++)
+                    {
+                    if(iBuffer->At(aIndex).iNodeBuf->At(i).iLeaf)
+                        {
+                        DoAddLeafObjectL(iBuffer->At(aIndex).iNodeBuf->At(i).iLastUriSeg->Des(),
+                                         iBuffer->At(aIndex).iNodeBuf->At(i).iData->Des(),
+                                         aIndex, i);
+                        }
+                    }
+
+                iBuffer->At(aIndex).iExecuted = ETrue;
+                }
+            CleanupStack::PopAndDestroy(); //object
+            }
+        }
+    else
+        {
+        DoAddLeafObjectL(lastSeg,aObject,aIndex,
+                         iBuffer->At(aIndex).iNodeBuf->Count()-1);
+        }
+
+    _DBG_FILE("CNSmlDmEmailAdapter::FirstAddLeafL() :: end");
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::DoAddLeafObjectL
+// -----------------------------------------------------------------------------
+TInt CNSmlDmEmailAdapter::DoAddLeafObjectL(const TDesC8& aLastUriSeg,
+                                           const TDesC8& aObject,
+                                           TInt aIndex,
+                                           TInt aCommand)
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::DoAddLeafObjectL() :: begin");
+    if(aLastUriSeg.Compare(KNSmlDMEmailName)==0)
+        {
+        if ( aObject.Size() < KEmailAccountNameSize )
+            {
+            delete iBuffer->At(aIndex).iName;
+            iBuffer->At(aIndex).iName = NULL;
+            iBuffer->At(aIndex).iName = HBufC::NewL(aObject.Size());
+            TPtr namePtr = iBuffer->At(aIndex).iName->Des();
+            CnvUtfConverter::ConvertToUnicodeFromUtf8( namePtr, aObject );
+            }
+        else 
+            {
+            iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = 
+                CSmlDmAdapter::ETooLargeObject;
+            }
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailUID)==0)
+        {
+        if(iBuffer->At(aIndex).iPop3Settings!= NULL)
+            {
+            iBuffer->At(aIndex).iPop3Settings->SetLoginNameL(aObject);
+            }
+        else if(iBuffer->At(aIndex).iImap4Settings!= NULL)
+            {
+            iBuffer->At(aIndex).iImap4Settings->SetLoginNameL(aObject);
+            }
+        if(iBuffer->At(aIndex).iSmtpSettings->LoginName()==KNullDesC8)
+            {
+            iBuffer->At(aIndex).iSmtpSettings->SetLoginNameL(aObject);
+            }
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailPW)==0)
+        {
+        if(iBuffer->At(aIndex).iPop3Settings!= NULL)
+            {
+            iBuffer->At(aIndex).iPop3Settings->SetPasswordL(aObject);
+            }
+        else if(iBuffer->At(aIndex).iImap4Settings!= NULL)
+            {
+            iBuffer->At(aIndex).iImap4Settings->SetPasswordL(aObject);
+            }
+        if(iBuffer->At(aIndex).iSmtpSettings->Password()==KNullDesC8)
+            {
+            iBuffer->At(aIndex).iSmtpSettings->SetPasswordL(aObject);
+            }
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailUAddr)==0)
+        {
+        HBufC *object = HBufC::NewLC(aObject.Size());
+        TPtr objectPtr = object->Des();
+        CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject );
+        if(iBuffer->At(aIndex).iSmtpSettings!= NULL)
+            {
+            iBuffer->At(aIndex).iSmtpSettings->SetEmailAddressL(objectPtr);
+            iBuffer->At(aIndex).iSmtpSettings->SetReplyToAddressL(objectPtr);
+            iBuffer->At(aIndex).iSmtpSettings->SetReceiptAddressL(objectPtr);
+            }
+
+        CleanupStack::PopAndDestroy(); //object
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailUName)==0)
+        {
+        HBufC *object = HBufC::NewLC(aObject.Size());
+        TPtr objectPtr = object->Des();
+        CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject );
+        if(iBuffer->At(aIndex).iSmtpSettings!= NULL)
+            {
+            iBuffer->At(aIndex).iSmtpSettings->SetEmailAliasL(objectPtr);
+            }
+        CleanupStack::PopAndDestroy(); //object
+        }
+
+    else if(aLastUriSeg.Compare( KNSmlDMEmailMrcv)==0)
+        {
+        HBufC *object = HBufC::NewLC(aObject.Size());
+        TPtr objectPtr = object->Des();
+        CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject );
+        if(iBuffer->At(aIndex).iPop3Settings!= NULL)
+            {
+            iBuffer->At(aIndex).iPop3Settings->SetServerAddressL(objectPtr);
+            }
+        else if(iBuffer->At(aIndex).iImap4Settings!= NULL)
+            {
+            iBuffer->At(aIndex).iImap4Settings->SetServerAddressL(objectPtr);
+            }
+        CleanupStack::PopAndDestroy(); //object
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailMsnd)==0)
+        {
+        HBufC *object = HBufC::NewLC(aObject.Size());
+        TPtr objectPtr = object->Des();
+        CnvUtfConverter::ConvertToUnicodeFromUtf8( objectPtr, aObject );
+        if(iBuffer->At(aIndex).iSmtpSettings!= NULL)
+            {
+            iBuffer->At(aIndex).iSmtpSettings->SetServerAddressL(objectPtr);
+            }
+        CleanupStack::PopAndDestroy(); //object
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailMpro)==0)
+        {
+        iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = CSmlDmAdapter::EOk;
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailUseSecCon)==0)
+        {
+        SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), EUseSecCon );
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailUseSauth)==0)
+        {
+        HBufC8 *data = aObject.AllocLC();
+        TPtr8 dataPtr = data->Des();
+        dataPtr.Capitalize();
+        TBool object=EFalse;
+        if(dataPtr.Find(KNSmlDMEmailTrue)>=0)
+            {
+            object = ETrue;
+            }
+        if(iBuffer->At(aIndex).iSmtpSettings!= NULL)
+            {
+            iBuffer->At(aIndex).iSmtpSettings->SetSMTPAuth(object);
+            }
+        CleanupStack::PopAndDestroy(); //data
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailSauthUID)==0)
+        {
+        if( iBuffer->At(aIndex).iSmtpSettings )
+            {
+            iBuffer->At(aIndex).iSmtpSettings->SetLoginNameL(aObject);
+            }
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailSauthPW)==0)
+        {
+        if( iBuffer->At(aIndex).iSmtpSettings )
+            {
+            iBuffer->At(aIndex).iSmtpSettings->SetPasswordL( aObject );
+            }
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailPtxtSAuth)==0)
+        {
+        HBufC8 *data = aObject.AllocLC();
+        TPtr8 dataPtr = data->Des();
+        dataPtr.Capitalize();
+        TBool object=EFalse;
+        if(dataPtr.Find(KNSmlDMEmailTrue)>=0)
+            {
+            object = ETrue;
+            }
+        if(iBuffer->At(aIndex).iSmtpSettings!= NULL)
+            {
+            iBuffer->At(aIndex).iSmtpSettings->SetInboxLoginDetails(object);
+            }
+        CleanupStack::PopAndDestroy(); //data
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailSUseSecCon)==0)
+        {
+        SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), ESuseSecCon );
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailUseStartTLS)==0)
+        {
+        SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), EUseStartTls );
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailSUseStartTLS)==0)
+        {
+        SetDefaultSecurityL(aObject, &iBuffer->At(aIndex), ESuseStartTls );
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailMrcvPort)==0)
+        {
+        TNSmlEmailSettingsElement& bufElem = iBuffer->At(aIndex);
+        TNSmlEmailCommandElement& elem = bufElem.iNodeBuf->At(aCommand);
+        elem.iData = aObject.AllocL();
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailMsndPort)==0)
+        {
+        TNSmlEmailSettingsElement& bufElem = iBuffer->At(aIndex);
+        TNSmlEmailCommandElement& elem = bufElem.iNodeBuf->At(aCommand);
+        elem.iData = aObject.AllocL();
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailUseAPOP)==0)
+        {
+        TBool object=EFalse;
+        if(aObject.Find(_L8("True"))>=0 || aObject.Find(_L8("true"))>=0)
+            {
+            object = ETrue;
+            }
+        if(iBuffer->At(aIndex).iPop3Settings!= NULL)
+            {
+            iBuffer->At(aIndex).iPop3Settings->SetApop(object);
+            }
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailFolderPath)==0)
+        {
+        if(iBuffer->At(aIndex).iImap4Settings!= NULL)
+            {
+            iBuffer->At(aIndex).iImap4Settings->SetFolderPathL(aObject);
+            }
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailToNapID)==0)
+        {
+        CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() );
+        CleanupStack::PushL(iapmatch);
+
+        TInt iap = iapmatch->IAPIdFromURIL( aObject );
+
+        if ( iap != KErrNotFound )
+            {
+            TImIAPChoice localIAP;
+            localIAP.iIAP = iap;
+            DBG_ARGS(_S("IAP = %d"), localIAP.iIAP);
+            localIAP.iDialogPref = ECommDbDialogPrefDoNotPrompt;
+
+            if ( iBuffer->At(aIndex).iSmtpIapPref->NumberOfIAPs() )
+                {
+                iBuffer->At(aIndex).iIapPref->RemoveIAPL(0);
+                }
+            iBuffer->At(aIndex).iIapPref->AddIAPL(localIAP,0);
+            if (iBuffer->At(aIndex).iSmtpSettings!= NULL)
+                {
+                if ( iBuffer->At(aIndex).iSmtpIapPref->NumberOfIAPs() )
+                    {
+                    iBuffer->At(aIndex).iSmtpIapPref->RemoveIAPL(0);
+                    }
+                iBuffer->At(aIndex).iSmtpIapPref->AddIAPL(localIAP,0);
+                }
+            }
+        else
+            {
+            iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus = CSmlDmAdapter::ENotFound;
+            }
+
+        CleanupStack::PopAndDestroy(); // iapmatch
+        }
+
+    else if(aLastUriSeg.Compare(KNSmlDMEmailSToNapID)==0)
+        {
+        CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() );
+        CleanupStack::PushL(iapmatch);
+
+        TInt iap = iapmatch->IAPIdFromURIL( aObject );
+
+        if ( iap != KErrNotFound )
+            {
+            TImIAPChoice localIAP;
+            localIAP.iIAP = iap;
+            DBG_ARGS(_S("SMTP IAP = %d"), localIAP.iIAP);
+            localIAP.iDialogPref = ECommDbDialogPrefDoNotPrompt;
+            if ( iBuffer->At(aIndex).iSmtpSettings!= NULL )
+                {
+                if ( iBuffer->At(aIndex).iSmtpIapPref->NumberOfIAPs() )
+                    {
+                    iBuffer->At(aIndex).iSmtpIapPref->RemoveIAPL(0);
+                    }
+                iBuffer->At(aIndex).iSmtpIapPref->AddIAPL(localIAP,0);
+                }
+            else
+                {
+                iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus =
+                    CSmlDmAdapter::ENotFound;
+                }
+            }
+        else
+            {
+            iBuffer->At(aIndex).iNodeBuf->At(aCommand).iStatus =
+                CSmlDmAdapter::ENotFound;
+            }
+
+        CleanupStack::PopAndDestroy(); // iapmatch
+        }
+    _DBG_FILE("CNSmlDmEmailAdapter::DoAddLeafObjectL() :: end");
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// void CNSmlDmEmailAdapter::SetDefaultSettingsL(TInt aIndex)
+// Set defaults for used protocol
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::SetDefaultSettingsL(TInt aIndex)
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSettingsL() :: begin");
+    TNSmlEmailSettingsElement& thisElem = iBuffer->At(aIndex);
+    CEmailAccounts* emailAccs = CEmailAccounts::NewLC();
+    if( thisElem.iPop3Settings )
+        {
+          
+        emailAccs->PopulateDefaultPopSettingsL(*thisElem.iPop3Settings,
+                                               *thisElem.iIapPref
+                                               );
+        emailAccs->PopulateDefaultSmtpSettingsL(*thisElem.iSmtpSettings,
+                                                *thisElem.iSmtpIapPref 
+                                               );
+                                               
+        thisElem.iPop3Settings->SetDeleteEmailsWhenDisconnecting( EFalse ); 
+        thisElem.iPop3Settings->SetInboxSynchronisationLimit( KNSmlDMEmailDefaultHeaderCount );
+        thisElem.iPop3Settings->SetSecureSockets( EFalse );
+        thisElem.iPop3Settings->SetAutoSendOnConnect( ETrue );
+        thisElem.iPop3Settings->SetDisconnectedUserMode( ETrue );
+        thisElem.iPop3Settings->SetAcknowledgeReceipts( EFalse );                                
+        }
+    else if( thisElem.iImap4Settings )
+        {
+        
+        emailAccs->PopulateDefaultImapSettingsL(*thisElem.iImap4Settings,
+                                                *thisElem.iIapPref 
+                                                );
+
+        emailAccs->PopulateDefaultSmtpSettingsL(*thisElem.iSmtpSettings,
+                                                *thisElem.iSmtpIapPref 
+                                               );
+                                                
+        thisElem.iImap4Settings->SetDeleteEmailsWhenDisconnecting( EFalse );
+        thisElem.iImap4Settings->SetInboxSynchronisationLimit( KNSmlDMEmailDefaultHeaderCount );
+        thisElem.iImap4Settings->SetMailboxSynchronisationLimit( KNSmlDMEmailDefaultHeaderCount );
+        thisElem.iImap4Settings->SetSecureSockets( EFalse );
+        thisElem.iImap4Settings->SetAutoSendOnConnect( ETrue );
+        thisElem.iImap4Settings->SetDisconnectedUserMode( ETrue );
+        thisElem.iImap4Settings->SetImapIdle( ETrue );
+        thisElem.iImap4Settings->SetUpdatingSeenFlags( ETrue );
+        }
+    thisElem.iSmtpSettings->SetLoginNameL(KNullDesC8);
+    thisElem.iSmtpSettings->SetPasswordL(KNullDesC8);
+    // Set IAP id to 0 and ask from user if ToNapID/SToNapID not sent
+    TImIAPChoice tmpIap;
+    tmpIap.iIAP = KNSmlDmEmailAlwaysAskIap;
+    tmpIap.iDialogPref = ECommDbDialogPrefPrompt;
+    thisElem.iIapPref->AddIAPL( tmpIap, 0 );
+    thisElem.iSmtpIapPref->AddIAPL( tmpIap, 0 );
+    CleanupStack::PopAndDestroy(); //emailAccs
+    _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSettingsL() :: end");
+    }
+
+// -----------------------------------------------------------------------------
+// HBufC* CNSmlDmEmailAdapter::IntToDesLC(const TInt aLuid) const
+// Converts integer to 16bit descriptor
+// -----------------------------------------------------------------------------
+HBufC* CNSmlDmEmailAdapter::IntToDesLC(const TInt aLuid) const
+    {
+    HBufC* buf = HBufC::NewLC(10); //10 = max length of 32bit integer
+    TPtr ptrBuf = buf->Des();
+    ptrBuf.Num(aLuid);
+    return buf;
+    }
+
+// -----------------------------------------------------------------------------
+// HBufC8* CNSmlDmEmailAdapter::IntToDes8LC(const TInt aLuid) const
+// Converts integer to 8bit descriptor
+// -----------------------------------------------------------------------------
+HBufC8* CNSmlDmEmailAdapter::IntToDes8LC(const TInt aLuid) const
+    {
+    HBufC8* buf = HBufC8::NewLC(10); //10 = max length of 32bit integer
+    TPtr8 ptrBuf = buf->Des();
+    ptrBuf.Num(aLuid);
+    return buf;
+    }
+   
+// -----------------------------------------------------------------------------
+//      CNSmlDmEmailAdapter::ConvertTo8LC()
+//      Converts string value to 8-bit
+//      
+// -----------------------------------------------------------------------------
+HBufC8* CNSmlDmEmailAdapter::ConvertTo8LC( const TDesC& aSource ) const
+    {
+    HBufC8* buf = HBufC8::NewLC( aSource.Length()*2);
+    TPtr8 bufPtr = buf->Des();
+    CnvUtfConverter::ConvertFromUnicodeToUtf8( bufPtr, aSource );
+
+    return buf;
+    }
+
+// -----------------------------------------------------------------------------
+// TInt CNSmlDmEmailAdapter::ValidateAndStoreSettingsL(TInt aIndex
+// Transfers the email settings from memory to phones permanent data store
+// -----------------------------------------------------------------------------
+TInt CNSmlDmEmailAdapter::ValidateAndStoreSettingsL(TInt aIndex)
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::ValidateAndStoreSettingsL() : begin");
+    TInt luid = 0;
+
+    TNSmlEmailSettingsElement& thisElem = iBuffer->At(aIndex);
+
+    if( iBuffer->At( aIndex ).iJustFetch )
+        {
+        _DBG_FILE("CNSmlDmEmailAdapter::ValidateAndStoreSettingsL() : end");
+        return luid;
+        }
+    CEmailAccounts* emailAccs = CEmailAccounts::NewLC();
+    if( iBuffer->At( aIndex ).iLuid != 0 )
+        {
+        switch ( thisElem.iAccType )
+            {
+        case EPop:
+            {
+            TPopAccount accId;
+            emailAccs->GetPopAccountL( thisElem.iServiceId, accId ); 
+            //Copy name field
+            accId.iPopAccountName.Copy(thisElem.iName->Des());
+            emailAccs->SavePopSettingsL( accId, *thisElem.iPop3Settings );
+	        emailAccs->SavePopIapSettingsL( accId, *thisElem.iIapPref );            
+            TSmtpAccount smtpAcc;
+	        emailAccs->GetSmtpAccountL( accId.iSmtpService, smtpAcc ); 
+	        //Copy name field
+	        smtpAcc.iSmtpAccountName.Copy(thisElem.iName->Des());
+	        emailAccs->SaveSmtpSettingsL( smtpAcc, *thisElem.iSmtpSettings );
+	        emailAccs->SaveSmtpIapSettingsL( smtpAcc, *thisElem.iSmtpIapPref );
+            break;            
+            }
+        case EImap:
+            {
+            TImapAccount accId2;
+    	    emailAccs->GetImapAccountL( thisElem.iServiceId, accId2 );
+    	    //Copy name field
+    	    accId2.iImapAccountName.Copy(thisElem.iName->Des());
+            emailAccs->SaveImapSettingsL( accId2, *thisElem.iImap4Settings );
+	        emailAccs->SaveImapIapSettingsL( accId2, *thisElem.iIapPref );
+            TSmtpAccount smtpAccForImap;
+	        emailAccs->GetSmtpAccountL( accId2.iSmtpService, smtpAccForImap );
+	        //Copy name field
+	        smtpAccForImap.iSmtpAccountName.Copy(thisElem.iName->Des()); 
+	        emailAccs->SaveSmtpSettingsL( smtpAccForImap, *thisElem.iSmtpSettings );
+	        emailAccs->SaveSmtpIapSettingsL( smtpAccForImap, *thisElem.iSmtpIapPref );
+            break;            
+            }
+        default:
+
+            break;
+            }
+        }
+    else // if(iBuffer->At(aIndex).iLuid != 0)
+        {
+        RTelServer telServer;
+        User::LeaveIfError( telServer.Connect() );
+        CleanupClosePushL(telServer);
+
+        TInt numPhones = 0;
+        User::LeaveIfError( telServer.EnumeratePhones( numPhones ) );
+        if ( numPhones < 1 )
+            {
+            User::Leave( KErrNotFound );
+            }
+
+        RTelServer::TPhoneInfo info;
+        User::LeaveIfError( telServer.GetPhoneInfo( 0, info ) );
+        RMobilePhone mobilePhone;
+        User::LeaveIfError( mobilePhone.Open( telServer, info.iName ) );
+        CleanupClosePushL( mobilePhone );
+        TRequestStatus status;
+        RMobilePhone::TMobilePhoneIdentityV1 mobilePhoneIdentity;
+        mobilePhone.GetPhoneId( status, mobilePhoneIdentity );
+        User::WaitForRequest( status );
+        User::LeaveIfError( status.Int() );
+        TBuf<50> imei;            
+        imei.Copy( mobilePhoneIdentity.iSerialNumber );
+        
+        CleanupStack::PopAndDestroy(&mobilePhone);
+        CleanupStack::PopAndDestroy(&telServer);
+        if ( thisElem.iPop3Settings )
+            {
+            TPopAccount accId;
+            accId = emailAccs->CreatePopAccountL( *thisElem.iName, 
+                                                  *thisElem.iPop3Settings, 
+                                                  *thisElem.iIapPref, 
+                                                  EFalse );
+
+    	    TSmtpAccount smtpAcc = emailAccs->CreateSmtpAccountL( accId, 
+    	                                                          *thisElem.iSmtpSettings, 
+                                                                  *thisElem.iSmtpIapPref, 
+                                                                  EFalse );
+            TMsvEntry smtpEntry;
+            TMsvEntry popEntry;
+            CMsvEntry* entry = iMsvSession->GetEntryL(smtpAcc.iSmtpService);
+            CleanupStack::PushL(entry);
+            smtpEntry = entry->Entry();
+            smtpEntry.iMtmData2 =  smtpAcc.iSmtpAccountId;
+            smtpEntry.iDescription.Set( imei );
+	        entry->ChangeL(smtpEntry);
+            CleanupStack::PopAndDestroy(entry);
+
+            entry = iMsvSession->GetEntryL(smtpAcc.iRelatedService);
+            CleanupStack::PushL(entry);
+            popEntry = entry->Entry();
+            popEntry.iMtmData2 =  accId.iPopAccountId;          
+            popEntry.iDescription.Set( imei );
+	        entry->ChangeL(popEntry);
+            CleanupStack::PopAndDestroy(entry);
+
+            if ( accId.iSmtpService != smtpAcc.iSmtpService || smtpAcc.iRelatedService != accId.iPopService )
+                {
+                DBG_ARGS8(_S8("ERROR!!! PopAccount creation: iSmtpService=%d, smtpAcc.iSmtpService=%d, iRelatedService=%d, iPopService=%d"),
+                                accId.iSmtpService, smtpAcc.iSmtpService, smtpAcc.iRelatedService, accId.iPopService );
+                }                                                               
+            
+            thisElem.iAccType = EPop;
+            thisElem.iAccId = accId.iPopAccountId;
+            SetLuidById( thisElem.iAccType, thisElem.iAccId, thisElem.iLuid );
+
+			  RArray<TPopAccount> popAccs;
+              CleanupClosePushL( popAccs );
+              emailAccs->GetPopAccountsL( popAccs );
+              
+			  RArray<TImapAccount> imapAccs;
+              CleanupClosePushL( imapAccs );
+              emailAccs->GetImapAccountsL( imapAccs );
+              
+              if ( popAccs.Count() == 1 && !imapAccs.Count())
+                 {
+                  emailAccs->SetDefaultSmtpAccountL( smtpAcc );
+                 }
+              
+              CleanupStack::PopAndDestroy( &imapAccs );          
+			  CleanupStack::PopAndDestroy( &popAccs );          
+            // Check and set the default account
+	        TSmtpAccount defSmtp;
+	        TInt retVal = emailAccs->DefaultSmtpAccountL( defSmtp );
+	        if (  retVal != KErrNone )
+	            {
+                RArray<TPopAccount> popAccounts;
+                CleanupClosePushL( popAccounts );
+                emailAccs->GetPopAccountsL( popAccounts );
+                if ( popAccounts.Count() > 0 )
+                    {
+                    TSmtpAccount relatedSmtp;
+                    emailAccs->GetSmtpAccountL( popAccounts[0].iSmtpService, relatedSmtp );
+	                emailAccs->SetDefaultSmtpAccountL( relatedSmtp );
+                    }
+                CleanupStack::PopAndDestroy( &popAccounts );
+	            }	                
+            }
+        else if ( thisElem.iImap4Settings )
+            {
+            TImapAccount accId2;
+            accId2 = emailAccs->CreateImapAccountL(*thisElem.iName, 
+                                                   *thisElem.iImap4Settings, 
+                                                   *thisElem.iIapPref,
+                                                   EFalse);
+
+    	    TSmtpAccount smtpAcc = emailAccs->CreateSmtpAccountL( accId2, 
+    	                                                          *thisElem.iSmtpSettings, 
+                                                                  *thisElem.iSmtpIapPref, 
+                                                                  EFalse );
+            
+            TMsvEntry smtpEntry;
+            TMsvEntry imapEntry;
+            CMsvEntry* entry = iMsvSession->GetEntryL(smtpAcc.iSmtpService);
+            CleanupStack::PushL(entry);
+            smtpEntry = entry->Entry();
+            smtpEntry.iMtmData2 =  smtpAcc.iSmtpAccountId;          
+            smtpEntry.iDescription.Set( imei );
+	        entry->ChangeL(smtpEntry);
+            CleanupStack::PopAndDestroy(entry);
+
+            entry = iMsvSession->GetEntryL(smtpAcc.iRelatedService);
+            CleanupStack::PushL(entry);
+            imapEntry = entry->Entry();
+            imapEntry.iMtmData2 =  accId2.iImapAccountId;          
+            imapEntry.iDescription.Set( imei );
+	        entry->ChangeL(imapEntry);
+            CleanupStack::PopAndDestroy(entry);
+
+            if ( accId2.iSmtpService != smtpAcc.iSmtpService || smtpAcc.iRelatedService != accId2.iImapService )
+                {
+                DBG_ARGS8(_S8("ERROR!!! ImapAccount creation: iSmtpService=%d, smtpAcc.iSmtpService=%d, iRelatedService=%d, iImapService=%d"),
+                                accId2.iSmtpService, smtpAcc.iSmtpService, smtpAcc.iRelatedService, accId2.iImapService );
+                }
+                                                                  
+                                                   
+            thisElem.iAccType = EImap;
+            thisElem.iAccId = accId2.iImapAccountId;
+            SetLuidById( thisElem.iAccType, thisElem.iAccId, thisElem.iLuid );
+
+            // Check and set the default account
+            RArray<TPopAccount> popAccs;
+            CleanupClosePushL( popAccs );
+            emailAccs->GetPopAccountsL( popAccs );
+              
+			RArray<TImapAccount> imapAccs;
+            CleanupClosePushL( imapAccs );
+            emailAccs->GetImapAccountsL( imapAccs );
+              
+            if ( imapAccs.Count() == 1 && !popAccs.Count())
+            	{
+                emailAccs->SetDefaultSmtpAccountL( smtpAcc );
+                }
+              
+            CleanupStack::PopAndDestroy( &imapAccs );          
+			CleanupStack::PopAndDestroy( &popAccs );
+	        TSmtpAccount defaultSmtp;
+	        TInt retVal = emailAccs->DefaultSmtpAccountL( defaultSmtp );
+	        if (  retVal != KErrNone )
+	            {
+                RArray<TImapAccount> imapAccs;
+                CleanupClosePushL( imapAccs );
+                emailAccs->GetImapAccountsL( imapAccs );
+                if ( imapAccs.Count() > 0 )
+                    {
+                    TSmtpAccount relatedSmtp;
+                    emailAccs->GetSmtpAccountL( imapAccs[0].iSmtpService, relatedSmtp );
+	                emailAccs->SetDefaultSmtpAccountL( relatedSmtp );
+                    }
+                CleanupStack::PopAndDestroy( &imapAccs );
+	            }	                
+            }
+
+        }
+    luid = thisElem.iLuid;
+    CleanupStack::PopAndDestroy(); //emailAccs
+    _DBG_FILE("CNSmlDmEmailAdapter::ValidateAndStoreSettingsL() : end");
+    return luid;
+    }
+// -----------------------------------------------------------------------------
+// void CNSmlDmEmailAdapter::GetIdByLuid( TNSmlEmailAccountType& aAccType,
+//                                           TInt& aAccId, 
+//                                       const TInt aLuid ) const
+// Calculates the account type and id on basis of luid
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::GetIdByLuid( TNSmlEmailAccountType& aAccType,
+                                       TInt& aAccId, 
+                                       const TInt aLuid ) const
+    {
+    if ( ( aLuid > KNSmlDmEmailImapLuidLow ) && 
+         ( aLuid < KNSmlDmEmailImapLuidHigh ) )
+        {
+        aAccType = EImap;
+        aAccId = aLuid - KNSmlDmEmailImapLuidLow;
+        }
+    else if (( aLuid > KNSmlDmEmailImapLuidHigh ) && 
+             ( aLuid < KNSmlDmEmailPopLuidHigh ))
+        {
+        aAccType = EPop;
+        aAccId = aLuid - KNSmlDmEmailImapLuidHigh;
+        }
+    else
+        {
+        aAccType = EUnknown;
+        }
+
+    }
+
+
+// -----------------------------------------------------------------------------
+// void CNSmlDmEmailAdapter::SetLuidById( const TNSmlEmailAccountType& aAccType,
+// const TInt& aAccId, TInt& aLuid ) const
+// Sets the luid on basis of account type and id
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::SetLuidById( const TNSmlEmailAccountType& aAccType,
+                                       const TInt& aAccId, TInt& aLuid ) const
+    {
+    switch (aAccType)
+        {
+    case EImap :
+        aLuid = KNSmlDmEmailImapLuidLow + aAccId;
+        break;
+
+    case EPop :
+        aLuid = KNSmlDmEmailImapLuidHigh + aAccId;
+        break;
+
+    default :
+        aLuid = -1;
+        break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TBool CNSmlDmEmailAdapter::AccountExistsL( const CEmailAccounts* aAccs, 
+//                                          const TNSmlEmailAccountType aAccType, 
+//                                          const TInt aId,
+//                                          TInt aIndex )
+// Checks if the accout matching the given parameters is found. 
+// returns True if found.
+// -----------------------------------------------------------------------------
+TBool CNSmlDmEmailAdapter::AccountExistsL( CEmailAccounts* aAccs, 
+                                           const TNSmlEmailAccountType aAccType, 
+                                           const TInt aId,
+                                           TInt aIndex )
+    {
+    RArray<TImapAccount> imap4Accs;
+    CleanupClosePushL( imap4Accs );
+    RArray<TPopAccount> pop3Accs;
+    CleanupClosePushL( pop3Accs );
+    switch ( aAccType )
+        {
+    case EImap:
+        aAccs->GetImapAccountsL(imap4Accs);
+        for(TInt i=0;i<imap4Accs.Count();i++)
+            {
+            if ( imap4Accs[i].iImapAccountId == aId )
+                {
+                
+                if ( aIndex >= 0 )
+                    {
+                    iBuffer->At(aIndex).iServiceId = imap4Accs[i].iImapService;
+                    delete iBuffer->At(aIndex).iName;
+                    iBuffer->At(aIndex).iName = NULL;
+                    iBuffer->At(aIndex).iName = HBufC::NewL(imap4Accs[i].iImapAccountName.Size());
+                    *iBuffer->At(aIndex).iName = imap4Accs[i].iImapAccountName;
+                    }
+                CleanupStack::PopAndDestroy(2); //imap4Accs, pop3Accs
+                return ETrue;
+                }
+            }
+        break;
+        
+    case EPop:
+        aAccs->GetPopAccountsL(pop3Accs);
+        for(TInt i=0;i<pop3Accs.Count();i++)
+            {
+            if ( pop3Accs[i].iPopAccountId == aId )
+                {
+                if ( aIndex >= 0 )
+                    {
+                    iBuffer->At(aIndex).iServiceId = pop3Accs[i].iPopService;                    
+                    delete iBuffer->At(aIndex).iName;
+                    iBuffer->At(aIndex).iName = NULL;
+                    iBuffer->At(aIndex).iName = HBufC::NewL(pop3Accs[i].iPopAccountName.Size());
+                    *iBuffer->At(aIndex).iName = pop3Accs[i].iPopAccountName;
+                    }
+                CleanupStack::PopAndDestroy(2); //imap4Accs, pop3Accs
+                return ETrue;
+                }
+            }
+        break;
+    default:
+        // Returns EFalse in this case.
+        break;
+        }
+    CleanupStack::PopAndDestroy(2); //imap4Accs, pop3Accs
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TInt CNSmlDmEmailAdapter::DoRestoreSettingsL(TInt aIndex)
+// Restores the settings to the adapter from settings store
+// -----------------------------------------------------------------------------
+TInt CNSmlDmEmailAdapter::DoRestoreSettingsL(TInt aIndex)
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::DoRestoreSettingsL() : begin");
+    TNSmlEmailSettingsElement& thisElem = iBuffer->At(aIndex);
+
+    CEmailAccounts* emailAccs = CEmailAccounts::NewLC();
+    TInt err = KErrNone;
+
+    // These are destroyed latest at destructor
+    thisElem.iSmtpSettings = new (ELeave) CImSmtpSettings;
+    thisElem.iIapPref = CImIAPPreferences::NewLC();
+    thisElem.iSmtpIapPref = CImIAPPreferences::NewLC();
+
+    switch( thisElem.iAccType )
+        {
+    case EImap:
+        if (AccountExistsL(emailAccs, thisElem.iAccType, thisElem.iAccId, aIndex ))
+            {
+            TImapAccount imapAccId;
+            
+            thisElem.iImap4Settings = new(ELeave) CImImap4Settings;
+            
+            //Get IMAP account by iAccId id
+            emailAccs->GetImapAccountL(thisElem.iServiceId, imapAccId);
+            //Get IMAP settings by account id
+            emailAccs->LoadImapSettingsL( imapAccId, *thisElem.iImap4Settings );
+            //Get IMAP settings IAP prefs
+            emailAccs->LoadImapIapSettingsL( imapAccId, *thisElem.iIapPref );
+            
+            TSmtpAccount smtpAccount;
+            //Get smtp account by related IMAP id
+            emailAccs->GetSmtpAccountL( imapAccId.iSmtpService, smtpAccount );  
+            //Get smtp settings by IMAP id                                        
+            emailAccs->LoadSmtpSettingsL( smtpAccount, *thisElem.iSmtpSettings );
+            //Get Smtp settings IAP prefs
+            emailAccs->LoadSmtpIapSettingsL( smtpAccount, *thisElem.iSmtpIapPref );
+            }
+        else
+            {
+            err = KErrNotFound;
+            }
+        break;
+
+    case EPop:
+        if (AccountExistsL(emailAccs, thisElem.iAccType, thisElem.iAccId, aIndex ))
+            {
+            TPopAccount popAccId;
+            
+            thisElem.iPop3Settings = new(ELeave) CImPop3Settings;
+            
+            //Get POP3 account by iAccId id
+            emailAccs->GetPopAccountL( thisElem.iServiceId, popAccId );
+            //Get POP3 settings by account id
+            emailAccs->LoadPopSettingsL( popAccId, *thisElem.iPop3Settings );
+            //Get POP3 setting IAP prefs
+            emailAccs->LoadPopIapSettingsL( popAccId, *thisElem.iIapPref );
+                        
+            TSmtpAccount smtpAccount;
+            //Get smtp account by related POP id
+            emailAccs->GetSmtpAccountL( popAccId.iSmtpService, smtpAccount );  
+            //Get smtp settings                                        
+            emailAccs->LoadSmtpSettingsL( smtpAccount, *thisElem.iSmtpSettings );
+            //Get Smtp setting IAP prefs
+            emailAccs->LoadSmtpIapSettingsL( smtpAccount, *thisElem.iSmtpIapPref );
+            }
+        else
+            {
+            err = KErrNotFound;
+            }
+        break;
+
+    default:
+        err = KErrNotFound;
+        break;
+        }
+
+    if ( err )
+        {
+        _DBG_FILE("CNSmlDmEmailAdapter::DoRestoreSettingsL() : \
+         KErrNotFound end");
+        CleanupStack::PopAndDestroy(2); // iIapPref, iSmtpIapPref
+        CleanupStack::PopAndDestroy(emailAccs); //emailAccs
+        return KErrNotFound;
+        }
+
+    CleanupStack::Pop(2); // iIapPref, iSmtpIapPref
+    CleanupStack::PopAndDestroy(emailAccs); //emailAccs
+    _DBG_FILE("CNSmlDmEmailAdapter::DoRestoreSettingsL() : end");
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::OpenSessionL()
+// Opens the CMsvSession if it is not open already
+// -----------------------------------------------------------------------------
+TInt CNSmlDmEmailAdapter::OpenSessionL()
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::OpenSessionL() : begin");
+    if(!iMsvSession)
+        {
+        TRAPD(err, iMsvSession = CMsvSession::OpenSyncL(*this));
+        _DBG_FILE("CNSmlDmEmailAdapter::OpenSessionL() : end");
+        return err;
+        }
+
+    _DBG_FILE("CNSmlDmEmailAdapter::OpenSessionL() : end");
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmEmailAdapter::FillNodeInfoL()
+// Fills the node info in ddf structure
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode,
+                                         const TSmlDmAccessTypes& aAccTypes,
+                                         MSmlDmDDFObject::TOccurence aOccurrence,
+                                         MSmlDmDDFObject::TScope aScope,
+                                         MSmlDmDDFObject::TDFFormat aFormat,
+                                         const TDesC8& aDescription) const
+    {
+    aNode.SetAccessTypesL(aAccTypes);
+    aNode.SetOccurenceL(aOccurrence);
+    aNode.SetScopeL(aScope);
+    aNode.SetDFFormatL(aFormat);
+    if(aFormat!=MSmlDmDDFObject::ENode)
+        {
+        aNode.AddDFTypeMimeTypeL(KNSmlDMEmailTextPlain);
+        }
+    aNode.SetDescriptionL(aDescription);
+
+    }
+
+// -----------------------------------------------------------------------------
+// TPtrC8 CNSmlDmEmailAdapter::RemoveDotSlash(const TDesC8& aURI)
+// return uri without dot and slash in start
+// -----------------------------------------------------------------------------
+TPtrC8 CNSmlDmEmailAdapter::RemoveDotSlash(const TDesC8& aURI) const
+    {
+    if(aURI.Find(KNSmlEmailUriDotSlash)==0)
+        {
+        return aURI.Right(aURI.Length()-KNSmlEmailUriDotSlash().Length());
+        }
+    else
+        {
+        return aURI;
+        }
+    }
+// -----------------------------------------------------------------------------
+// CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchObjectL(const TDesC8& aURI,
+// const TDesC8& aLUID, CBufBase& aObject)
+// Fetches object acording to URI & LUID. Retur codes acording to 
+// CSmlDmAdapter::TError.
+// -----------------------------------------------------------------------------
+CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchObjectL(const TDesC8& aURI,
+                                                        const TDesC8& aLUID,
+                                                        CBufBase& aObject)
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : begin");
+    CSmlDmAdapter::TError status = EOk;
+    if(aLUID.Length()==0)
+        {
+        _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : ENotFound end");
+        return CSmlDmAdapter::ENotFound;
+        }
+    if( OpenSessionL() != KErrNone )
+        {
+        _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : EError end");
+        return CSmlDmAdapter::EError;
+        }
+    TInt luid = DesToInt(aLUID);
+    TInt index  = -1;
+    for(TInt i=0;i<iBuffer->Count();i++)
+        {
+        if(iBuffer->At(i).iLuid == luid)
+            {
+            index = i;
+            break;
+            }
+        }
+
+    if(index<0)
+        {
+        TNSmlEmailSettingsElement newNode;
+        newNode.iImap4Settings = NULL;
+        newNode.iPop3Settings = NULL;
+        newNode.iSmtpSettings = NULL;
+        newNode.iIapPref = NULL;
+        newNode.iLuid = luid;
+        newNode.iMappingName = aURI.AllocLC();
+        newNode.iName = HBufC::NewLC(0);
+        newNode.iNodeBuf = new (ELeave)
+            CArrayFixFlat <TNSmlEmailCommandElement> (KNSmlDmEmailGranularity);
+        newNode.iExecuted = ETrue;
+        newNode.iJustFetch = ETrue;
+        GetIdByLuid(newNode.iAccType, newNode.iAccId, luid);
+        iBuffer->AppendL(newNode);
+        index = iBuffer->Count() - 1;
+        if(DoRestoreSettingsL(index)!=KErrNone)
+            {
+            CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName
+            _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : EError end");
+            return CSmlDmAdapter::EError;
+            }
+        CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName
+        }
+
+    TPtrC8 lastUriSeg = LastURISeg(aURI);
+
+    if(lastUriSeg.Compare(KNSmlDMEmailName)==0)
+        {
+        HBufC8 *data = HBufC8::NewLC(iBuffer->At(index).iName->Length());
+        TPtr8 dataPtr = data->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr, iBuffer->At(index).iName->Des() );
+        aObject.InsertL(0,dataPtr);
+        CleanupStack::PopAndDestroy(); //data
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailUID)==0)
+        {
+        HBufC *data = NULL;
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->LoginName().Length());
+            data->Des().Copy(iBuffer->At(index).iPop3Settings->LoginName());
+            }
+        else if(iBuffer->At(index).iImap4Settings!= NULL)
+            {
+            data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->LoginName().Length());
+            data->Des().Copy(iBuffer->At(index).iImap4Settings->LoginName());
+            }
+        if(data)
+            {
+            HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data);
+            CleanupStack::PushL(data8);
+            aObject.InsertL(0,*data8);
+            CleanupStack::PopAndDestroy(2);//data, data8
+            }
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailPW)==0)
+        {
+        HBufC *data = NULL;
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            data = HBufC::NewLC(iBuffer->At(index).iPop3Settings->Password().Length());
+            data->Des().Copy(iBuffer->At(index).iPop3Settings->Password());
+            }
+        else if(iBuffer->At(index).iImap4Settings!= NULL)
+            {
+            data = HBufC::NewLC(iBuffer->At(index).iImap4Settings->Password().Length());
+            data->Des().Copy(iBuffer->At(index).iImap4Settings->Password());
+            }
+        if(data)
+            {
+            HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data);
+            CleanupStack::PushL(data8);
+            aObject.InsertL(0,*data8);
+            CleanupStack::PopAndDestroy(2);//data, data8
+            }
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailUAddr)==0)
+        {
+        HBufC *data = NULL;
+        data = iBuffer->At(index).iSmtpSettings->EmailAddress().AllocLC();
+        HBufC8 *data8 = HBufC8::NewLC(data->Size());
+        TPtr8 dataPtr8 = data8->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
+
+        aObject.InsertL(0,dataPtr8);
+        CleanupStack::PopAndDestroy(2); //data, data8
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailUName)==0)
+        {
+
+        HBufC *data = NULL;
+        data = iBuffer->At(index).iSmtpSettings->EmailAlias().AllocLC();
+        HBufC8 *data8 = HBufC8::NewLC(data->Size());
+        TPtr8 dataPtr8 = data8->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
+
+        aObject.InsertL(0,dataPtr8);
+        CleanupStack::PopAndDestroy(2); //data, data8
+        }
+
+    else if(lastUriSeg.Compare( KNSmlDMEmailMrcv)==0)
+        {
+        HBufC *data = NULL;
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            data = iBuffer->At(index).iPop3Settings->ServerAddress().AllocLC();
+            }
+        else if(iBuffer->At(index).iImap4Settings!= NULL)
+            {
+            data = iBuffer->At(index).iImap4Settings->ServerAddress().AllocLC();
+            }
+        else
+        	{
+          	status = CSmlDmAdapter::ENotFound;
+          	return status;            
+        	}
+        HBufC8 *data8 = HBufC8::NewLC(data->Size());
+        TPtr8 dataPtr8 = data8->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
+
+        aObject.InsertL(0,dataPtr8);
+        CleanupStack::PopAndDestroy(2); //data, data8
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailMsnd)==0)
+        {
+        HBufC *data = NULL;
+        data = iBuffer->At(index).iSmtpSettings->ServerAddress().AllocLC();
+        HBufC8 *data8 = HBufC8::NewLC(data->Size());
+        TPtr8 dataPtr8 = data8->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( dataPtr8, data->Des() );
+
+        aObject.InsertL(0,dataPtr8);
+        CleanupStack::PopAndDestroy(2); //data, data8
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailMpro)==0)
+        {
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            aObject.InsertL(0,KNSmlDMEmailMproPOP);
+            }
+        else if(iBuffer->At(index).iImap4Settings!= NULL)
+            {
+            aObject.InsertL(0,KNSmlDMEmailMproIMAP);
+            }
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailUseSecCon)==0)
+        {
+        FetchSecurityValueL(aObject, &iBuffer->At(index), EUseSecCon );
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailUseSauth)==0)
+        {
+        if(iBuffer->At(index).iSmtpSettings->SMTPAuth())
+            {
+            aObject.InsertL(0,KNSmlDMEmailTrue);
+            }
+        else
+            {
+            aObject.InsertL(0,KNSmlDMEmailFalse);
+            }
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailSauthUID)==0)
+        {
+        HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->LoginName().Length());
+        data->Des().Copy(iBuffer->At(index).iSmtpSettings->LoginName());
+        HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data);
+        CleanupStack::PushL(data8);
+        aObject.InsertL(0,*data8);
+        CleanupStack::PopAndDestroy(2);//data, data8
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailSauthPW)==0)
+        {
+        HBufC *data = HBufC::NewLC(iBuffer->At(index).iSmtpSettings->Password().Length());
+        data->Des().Copy(iBuffer->At(index).iSmtpSettings->Password());
+        HBufC8 *data8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*data);
+        CleanupStack::PushL(data8);
+        aObject.InsertL(0,*data8);
+        CleanupStack::PopAndDestroy(2);//data, data8
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailPtxtSAuth)==0)
+        {
+        if(iBuffer->At(index).iSmtpSettings->InboxLoginDetails())
+            {
+            aObject.InsertL(0,KNSmlDMEmailTrue);
+            }
+        else
+            {
+            aObject.InsertL(0,KNSmlDMEmailFalse);
+            }
+        }
+
+    else if (lastUriSeg.Compare(KNSmlDMEmailSUseSecCon)==0)
+        {
+        FetchSecurityValueL(aObject, &iBuffer->At(index), ESuseSecCon );
+        }
+
+    else if (lastUriSeg.Compare(KNSmlDMEmailUseStartTLS)==0)
+        {
+        FetchSecurityValueL(aObject, &iBuffer->At(index), EUseStartTls );
+        }
+
+    else if (lastUriSeg.Compare(KNSmlDMEmailSUseStartTLS)==0)
+        {
+        FetchSecurityValueL(aObject, &iBuffer->At(index), ESuseStartTls );
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailMrcvPort)==0)
+        {
+        TUint port;
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            port = iBuffer->At(index).iPop3Settings->Port();
+            }
+        else 
+            {
+            port = iBuffer->At(index).iImap4Settings->Port();
+            }
+        HBufC8 *data = IntToDes8LC(port);
+        aObject.InsertL(0,data->Des());
+        CleanupStack::PopAndDestroy(); //data
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailMsndPort)==0)
+        {
+        TUint port = iBuffer->At(index).iSmtpSettings->Port();
+        HBufC8 *data = IntToDes8LC(port);
+        aObject.InsertL(0,data->Des());
+        CleanupStack::PopAndDestroy(); //data
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailUseAPOP)==0)
+        {
+        if(iBuffer->At(index).iPop3Settings!= NULL)
+            {
+            if(iBuffer->At(index).iPop3Settings->Apop())
+                {
+                aObject.InsertL(0,KNSmlDMEmailTrue);
+                }
+            else
+                {
+                aObject.InsertL(0,KNSmlDMEmailFalse);
+                }
+            }
+        else if(iBuffer->At(index).iImap4Settings!= NULL)
+            {
+            status = CSmlDmAdapter::ENotFound;
+            }
+        }
+
+    else if (lastUriSeg.Compare(KNSmlDMEmailFolderPath)==0)
+        {
+        if( iBuffer->At(index).iImap4Settings )
+            {
+            aObject.InsertL(0, iBuffer->At(index).iImap4Settings->FolderPath() );
+            }
+        else
+            {
+            status = CSmlDmAdapter::ENotFound;
+            }
+        }
+
+    else if(lastUriSeg.Compare(KNSmlDMEmailToNapID)==0)
+        {
+        CNSmlDMIAPMatcher* iapmatch=CNSmlDMIAPMatcher::NewL( &Callback() );
+        CleanupStack::PushL(iapmatch);
+        HBufC8* uri8 = NULL;
+        TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs();
+        if ( iapCount )
+            {
+            TImIAPChoice localIAP = iBuffer->At(index).iIapPref->IAPPreference(0);
+            uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP );
+            }
+
+        if( uri8 )
+            {
+            CleanupStack::PushL(uri8);
+            aObject.InsertL(0,uri8->Des());
+            status = CSmlDmAdapter::EOk;
+            CleanupStack::PopAndDestroy(); // uri8
+            }       
+
+        CleanupStack::PopAndDestroy(); // iapMatch
+        }
+    else if(lastUriSeg.Compare(KNSmlDMEmailSToNapID)==0)
+        {
+        // SToNapID exists only for SMTP
+        if (iBuffer->At(index).iSmtpSettings!= NULL)
+            {
+            CNSmlDMIAPMatcher* iapmatch=CNSmlDMIAPMatcher::NewL( &Callback() );
+            CleanupStack::PushL(iapmatch);
+            HBufC8* uri8 = NULL;
+            TInt iapCount = iBuffer->At(index).iIapPref->NumberOfIAPs();
+            if ( iapCount )
+                {
+                TImIAPChoice localIAP = iBuffer->At(index).iSmtpIapPref->IAPPreference(0);
+                uri8 = iapmatch->URIFromIAPIdL( localIAP.iIAP );
+                }
+
+            if( uri8 )
+                {
+                CleanupStack::PushL(uri8);
+                aObject.InsertL(0,uri8->Des());
+                status = CSmlDmAdapter::EOk;
+                CleanupStack::PopAndDestroy(); // uri8
+                }          
+
+            CleanupStack::PopAndDestroy(); // iapMatch
+            }
+        else
+            {
+            status = CSmlDmAdapter::ENotFound;
+            }
+        }
+    _DBG_FILE("CNSmlDmEmailAdapter::FetchObjectL() : end");
+    return status;
+    }
+
+// -----------------------------------------------------------------------------
+// void CNSmlDmEmailAdapter::SetDefaultSecurityL(const TDesC8& aObject,
+// const TNSmlEmailSettingsElement* thisElem,
+// const TNSmlEmailSecuritySetting aSetting )
+// Sets (on/off) the security modes: SSL/TLS, StartTLS
+// -----------------------------------------------------------------------------
+void CNSmlDmEmailAdapter::SetDefaultSecurityL(const TDesC8& aObject,
+                                              const TNSmlEmailSettingsElement* aThisElem,
+                                              const TNSmlEmailSecuritySetting aSetting
+    ) const
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSecurityL(): begin");
+    HBufC8 *data = aObject.AllocLC();
+    TPtr8 dataPtr = data->Des();
+    dataPtr.Capitalize();
+    TBool object=EFalse;
+    if(dataPtr.Find(KNSmlDMEmailTrue)>=0)
+        {
+        object = ETrue;
+        }
+    switch ( aSetting )
+        {
+    case EUseSecCon :
+        if ( object )
+            {
+            if ( aThisElem->iImap4Settings )
+                {
+                aThisElem->iImap4Settings->SetSecureSockets(EFalse);
+                aThisElem->iImap4Settings->SetSSLWrapper(ETrue);
+                aThisElem->iImap4Settings->SetPort( KNSmlDMEmailSslWrappedImap4Port );
+                }
+            else if ( aThisElem->iPop3Settings )
+                {
+                aThisElem->iPop3Settings->SetSecureSockets(EFalse);
+                aThisElem->iPop3Settings->SetSSLWrapper(ETrue);
+                aThisElem->iPop3Settings->SetPort( KNSmlDMEmailSslWrappedPop3Port );
+                }
+            }
+        else
+            {
+            if ( aThisElem->iImap4Settings )
+                {
+                aThisElem->iImap4Settings->SetPort( KNSmlDMEmailNormalImap4Port );
+                aThisElem->iImap4Settings->SetSSLWrapper(EFalse);
+                }
+            else if ( aThisElem->iPop3Settings )
+                {
+                aThisElem->iPop3Settings->SetPort( KNSmlDMEmailNormalPop3Port );
+                aThisElem->iPop3Settings->SetSSLWrapper(EFalse);
+                }
+            }
+        break;
+    case EUseStartTls :
+         if ( object )
+            {
+           if ( aThisElem->iImap4Settings )
+                {
+                aThisElem->iImap4Settings->SetSecureSockets(ETrue);
+                aThisElem->iImap4Settings->SetSSLWrapper(EFalse);
+                aThisElem->iImap4Settings->SetPort( KNSmlDMEmailNormalImap4Port );
+                }
+            else if ( aThisElem->iPop3Settings )
+                {
+                aThisElem->iPop3Settings->SetSecureSockets(ETrue);
+                aThisElem->iPop3Settings->SetSSLWrapper(EFalse);
+                aThisElem->iPop3Settings->SetPort( KNSmlDMEmailNormalPop3Port );
+                }
+            }
+        else
+            {
+            if ( aThisElem->iImap4Settings )
+                {
+                aThisElem->iImap4Settings->SetSecureSockets(EFalse);
+                }
+            else if ( aThisElem->iPop3Settings )
+                {
+                aThisElem->iPop3Settings->SetSecureSockets(EFalse);
+                }
+            }
+        break;
+    case ESuseSecCon :
+        if ( object )
+            {
+            // The port is same in all cases
+            aThisElem->iSmtpSettings->SetSecureSockets(EFalse);
+            aThisElem->iSmtpSettings->SetSSLWrapper(ETrue);
+            aThisElem->iSmtpSettings->SetPort( KNSmlDMEmailSslSmtpPort );
+            }
+        else
+            {
+            aThisElem->iSmtpSettings->SetPort( KNSmlDMEmailNormalSmtpPort );
+            aThisElem->iSmtpSettings->SetSSLWrapper( EFalse );
+            }
+        break;
+    case ESuseStartTls :
+        if ( object )
+            {
+            // The port is same in all cases
+            aThisElem->iSmtpSettings->SetSecureSockets(ETrue);
+            aThisElem->iSmtpSettings->SetSSLWrapper(EFalse);
+            aThisElem->iSmtpSettings->SetPort( KNSmlDMEmailNormalSmtpPort );
+            }
+        else
+            {
+            aThisElem->iSmtpSettings->SetSecureSockets( EFalse );
+            }
+
+        break;
+    default :
+        break;
+        }
+    CleanupStack::PopAndDestroy(); // object
+    _DBG_FILE("CNSmlDmEmailAdapter::SetDefaultSecurityL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchSecurityValueL(
+//                               CBufBase& aObject,
+//                               const TNSmlEmailSettingsElement* aElem,
+//                               const TNSmlEmailSecuritySetting aSetting )
+// Gets the status(on/off) of security modes  SSL/TLS or StartTLS
+// -----------------------------------------------------------------------------
+
+CSmlDmAdapter::TError CNSmlDmEmailAdapter::FetchSecurityValueL(
+    CBufBase& aObject,
+    const TNSmlEmailSettingsElement* aElem,
+    const TNSmlEmailSecuritySetting aSetting ) const
+    {
+    _DBG_FILE("CNSmlDmEmailAdapter::FetchSecurityValueL(): start");
+    TBool result=EFalse;
+    CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
+    switch ( aSetting )
+        {
+
+        case EUseStartTls :
+                if ( aElem->iImap4Settings)
+                    {
+                    result = aElem->iImap4Settings->SecureSockets();
+                    }
+                else if(aElem->iPop3Settings)
+                    {
+                    result = aElem->iPop3Settings->SecureSockets();
+                    }
+                else
+                    {
+                    status = CSmlDmAdapter::EError;
+                    }
+                break;
+        case EUseSecCon :
+                if ( aElem->iImap4Settings)
+                    {
+                    result = aElem->iImap4Settings->SSLWrapper();
+                    }
+                else if(aElem->iPop3Settings)
+                    {
+                    result = aElem->iPop3Settings->SSLWrapper();
+                    }
+                else
+                    {
+                    status = CSmlDmAdapter::EError;
+                    }
+                break;
+        case ESuseStartTls :
+                if(aElem->iSmtpSettings)
+                    {
+                    result = aElem->iSmtpSettings->SecureSockets();
+                    }
+                else
+                    {
+                    status = CSmlDmAdapter::EError;
+                    }
+                break;
+        case ESuseSecCon :
+                if(aElem->iSmtpSettings)
+                    {
+                    result = aElem->iSmtpSettings->SSLWrapper();
+                    }
+                else
+                    {
+                    status = CSmlDmAdapter::EError;
+                    }
+                break;
+        default:
+            status = CSmlDmAdapter::EError;
+            break;
+        }
+        
+    if ( result )
+        {
+        aObject.InsertL(0,KNSmlDMEmailTrue);
+        }
+    else 
+        {
+        aObject.InsertL(0,KNSmlDMEmailFalse);
+        }
+    _DBG_FILE("CNSmlDmEmailAdapter::FetchSecurityValueL(): end");
+    return status;
+    }
+
+//--------------------------------------------------------------------
+//TInt CNSmlDmEmailAdapter::ConstructTreeL(const TDesC8& aURI)
+//
+//-------------------------------------------------------------------
+
+TInt CNSmlDmEmailAdapter::ConstructTreeL(const TDesC8& aURI)
+{
+	TInt ret = KErrNotFound;
+	CEmailAccounts* emailAccs = CEmailAccounts::NewLC();
+	
+    if(aURI.Find(KNSmlDMEmailNodeName)!= KErrNotFound)
+        {
+        RArray<TImapAccount> imap4Accounts;
+        CleanupClosePushL( imap4Accounts );
+        emailAccs->GetImapAccountsL(imap4Accounts);
+
+        // First, IMAP accounts
+        //
+        TInt luid;
+        TPtrC8 name;
+        // cycle through every found account
+        for(TInt count = 0; count < imap4Accounts.Count(); count++)
+            {
+            
+            	SetLuidById( EImap, imap4Accounts[count].iImapAccountId, luid );
+            	HBufC8 *uri = HBufC8::NewLC(KNSmlDMEmailNodeName().Length() + 
+                                            KNSmlDMEmailMproIMAP().Length() + 6);
+                                            
+                TPtr8 uriPtr = uri->Des();
+                uriPtr.Append(KNSmlDMEmailNodeName);
+                uriPtr.Append(KNSmlDMEmailSeparator8);
+                uriPtr.Append(KNSmlDMEmailMproIMAP);
+                uriPtr.AppendNumFixedWidth(count,EDecimal,3); 
+                HBufC8 *luidBuf = IntToDes8LC(luid); 
+                HBufC8* mapInfo = Callback().GetLuidAllocL(uriPtr);					
+				if (mapInfo->Length() == 0)
+				{                             
+                	Callback().SetMappingL(uriPtr, luidBuf->Des());
+                	if( aURI.Find(uriPtr) >= 0 )
+        			{ 
+         				ret = luid;
+        			}  
+				}
+				else
+				{
+					delete mapInfo;
+				}
+
+                CleanupStack::PopAndDestroy(2); //uri,luidBuf   
+            }
+        CleanupStack::PopAndDestroy(); //imap4Accounts
+
+        // Then, POP accounts
+        //
+        RArray<TPopAccount> pop3Accounts;
+        CleanupClosePushL( pop3Accounts );
+        emailAccs->GetPopAccountsL( pop3Accounts );        
+        // cycle through every found account
+        for(TInt count = 0; count < pop3Accounts.Count(); count++)
+            {
+            	SetLuidById( EPop, pop3Accounts[count].iPopAccountId, luid );
+                                     
+                HBufC8 *uri = HBufC8::NewLC(KNSmlDMEmailNodeName().Length() + 
+                                            KNSmlDMEmailMproPOP().Length() + 5);
+                TPtr8 uriPtr = uri->Des();
+                uriPtr.Append(KNSmlDMEmailNodeName);
+                uriPtr.Append(KNSmlDMEmailSeparator8);
+                uriPtr.Append(KNSmlDMEmailMproPOP);
+				uriPtr.AppendNumFixedWidth(count,EDecimal,3); 
+                HBufC8 *luidBuf = IntToDes8LC(luid);
+                HBufC8* mapInfo = Callback().GetLuidAllocL(uriPtr);					
+				if (mapInfo->Length() == 0)
+				{ 
+                	Callback().SetMappingL(uriPtr,luidBuf->Des());
+                	if( aURI.Find(uriPtr) >= 0 )
+        			{ 
+         				ret = luid;
+        			}  
+				}
+				else
+				{
+					delete mapInfo;
+				}
+
+                CleanupStack::PopAndDestroy(2); //uri,luidBuf
+            }
+        CleanupStack::PopAndDestroy(); //pop3Accounts
+        }
+        CleanupStack::PopAndDestroy(); //emailAccs
+		return ret;
+}
+
+//------------------------------------------------------------------------------
+// TPtrC8 CNSmlDmEmailAdapter::GetDynamicEmailNodeUri( const TDesC8& aURI )
+// returns Email/xxx URI
+//------------------------------------------------------------------------------
+TPtrC8 CNSmlDmEmailAdapter::GetDynamicEmailNodeUri( const TDesC8& aURI )
+    {
+    DBG_ARGS8(_S8("CNSmlDmEmailAdapter::GetDynamicEmailNodeUri() - <%S> "), &aURI);
+    TInt i= 0;
+	TBuf8<50> EmailAccRoot(KNSmlDMEmailNodeName);
+    for ( i = aURI.Find( KNSmlDMEmailNodeName ) + EmailAccRoot.Length() + 1; 
+						i < aURI.Length(); i++ )
+        {
+        if( aURI[i] == '/' )
+            {
+            break;
+            }
+        }        
+    _DBG_FILE("CNSmlDmEmailAdapter::GetDynamicEmailNodeUri(): end");
+    return aURI.Left( i );
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/src/nsmldmemailadapter.rss	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,49 @@
+CHARACTER_SET UTF8/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Resource data for SyncML DM Email adapter
+*
+*/
+
+
+
+
+
+
+#include <registryinfo.rh>
+#include "nsmldmconstants.h"
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x101F6E34; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = KNSmlDMInterfaceUid; // DM interface UID
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x101F6E35; // DM Email implementation UID
+                version_no = 1; 
+                display_name = "";
+                default_data = "";
+                opaque_data = "";
+                }
+            };
+          }
+      };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/bwins/emailtestu.def	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,3 @@
+EXPORTS
+	?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/conf/emailtest.cfg	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,96 @@
+[Test]
+title DDF
+create emailtest foobar jee
+foobar DDFStructure
+delete foobar
+[Endtest] 
+
+[Test]
+title StartAtomic
+create emailtest foobar
+foobar StartAtomic
+delete foobar
+[Endtest]
+
+[Test]
+title CommitAtomic
+create emailtest foobar
+foobar CommitAtomic
+delete foobar
+[Endtest]
+
+[Test]
+title RollbackAtomic
+create emailtest foobar
+foobar RollbackAtomic
+delete foobar
+[Endtest]
+
+[Test]
+title AddEmail
+create emailtest foobar
+foobar AddNode Email/IMAP33245
+foobar UpdateLeaf Email/IMAP33245/Name email99
+foobar UpdateLeaf Email/IMAP33245/UName Test
+foobar UpdateLeaf Email/IMAP33245/Mpro IMAP
+foobar UpdateLeaf Email/IMAP33245/Mrcv mai..yaho.com
+foobar UpdateLeaf Email/IMAP33245/Msnd smtp.yahoo.com
+foobar CompleteCommands
+delete foobar
+[Endtest]
+
+[Test]
+title UpdateLeafEmailName
+create emailtest foobar
+foobar UpdateLeaf Email/IMAP33245/Name newname99
+delete foobar
+[Endtest]
+
+[Test]
+title FetchNodeEmail
+create emailtest foobar
+foobar FetchNode Email/IMAP33245
+delete foobar
+[Endtest]
+
+[Test]
+title FetchLeafEmailName
+create emailtest foobar
+foobar FetchLeaf Email/IMAP33245/Name
+delete foobar
+[Endtest]
+
+[Test]
+title FetchLeafEmailUName
+create emailtest foobar
+foobar FetchLeaf Email/IMAP33245/UName
+delete foobar
+[Endtest]
+
+[Test]
+title FetchLeafEmailMpro
+create emailtest foobar
+foobar FetchLeaf Email/IMAP33245/Mpro
+delete foobar
+[Endtest]
+
+[Test]
+title FetchLeafEmailMrcv
+create emailtest foobar
+foobar FetchLeaf Email/IMAP33245/Mrcv
+delete foobar
+[Endtest]
+
+[Test]
+title FetchLeafEmailMsnd
+create emailtest foobar
+foobar FetchLeaf Email/IMAP33245/Msnd
+delete foobar
+[Endtest]
+
+[Test]
+title DeleteEmail
+create emailtest foobar
+foobar DeleteNode Email/IMAP33245
+delete foobar
+[Endtest]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/eabi/emailtestu.def	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,9 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+	_ZTI10CemailTest @ 2 NONAME ; #<TI>#
+	_ZTI16CTestDmDDFObject @ 3 NONAME ; #<TI>#
+	_ZTI8Cdmatest @ 4 NONAME ; #<TI>#
+	_ZTV10CemailTest @ 5 NONAME ; #<VT>#
+	_ZTV16CTestDmDDFObject @ 6 NONAME ; #<VT>#
+	_ZTV8Cdmatest @ 7 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/group/bld.inf	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DM adapter test component
+* 	This is part of omadmextensions/adapter test application.
+*
+*/
+
+
+
+
+
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+DEFAULT
+
+PRJ_TESTEXPORTS
+// NOTE: If using ARS requirements all export operations should be done under this.
+// 'abld test export'
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+// Example: 
+
+
+PRJ_TESTMMPFILES
+// NOTE: If using ARS requirements .mmp file operation should be done under this.
+// 'abld test build'
+emailtest.mmp
+
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/group/emailtest.mmp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DM adapter test component
+* 	This is part of omadmextensions/adapter test application.
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+TARGET          emailtest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+
+CAPABILITY	ALL -TCB
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID 	0x00000000
+
+//TARGETPATH      ?target_path
+DEFFILE         emailtest.def
+
+SOURCEPATH      ../src
+SOURCE          dmatest.cpp
+SOURCE          TestDmDDFObject.cpp
+SOURCE          emailtest.cpp
+SOURCE          emailtestBlocks.cpp
+
+
+USERINCLUDE     ../inc 
+USERINCLUDE		  ../../inc
+
+SYSTEMINCLUDE   /epoc32/include/ecom
+APP_LAYER_SYSTEMINCLUDE
+
+ 
+
+LIBRARY         apgrfx.lib apmime.lib
+LIBRARY         euser.lib ecom.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib 
+LIBRARY         SWInstCli.lib
+
+LANG			SC
+
+
+
+SMPSAFE
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/group/emailtest.pkg	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,38 @@
+;
+; Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:  Implementation of DM adapter test component
+; 	This is part of omadmextensions/adapter test application.
+;
+
+;*Languages
+&EN
+;
+;*Standard SIS file header. This section specifies the package name,
+;application UID, and version/build numbers. Add the package TYPE here if needed.
+#{"emailtest"},(0x101FB3E8),1,0,1;
+;
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia Test EN"}
+
+;*Files To Copy...<src> <destination>
+"\epoc32\release\armv5\urel\emailtest.dll" -"C:\sys\bin\emailtest.dll"
+"..\conf\emailtest.cfg"-"C:\TestFramework\emailtest.cfg"
+"..\init\emailtest.ini"-"C:\TestFramework\emailtest.ini"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/inc/TestDmDDFObject.h	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,203 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DM adapter test component
+* 	This is part of omadmextensions/adapter test application.
+*
+*/
+
+
+
+
+
+
+#ifndef __TESTDMDDFOBJECT_H
+#define __TESTDMDDFOBJECT_H
+
+//  INCLUDES
+//#include <?include_file>
+#include <smldmadapter.h>
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+class CStifLogger;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CTestDmDDFObject : public CBase, public MSmlDmDDFObject
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CTestDmDDFObject* NewL( CStifLogger *aLog );
+        static CTestDmDDFObject* NewLC( CStifLogger *aLog );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CTestDmDDFObject();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+		virtual void SetNameL( const TDesC8& aName );
+		
+		void DumpL( const TDesC8& aParentName, TBool aFullDump = ETrue );
+		void ExternalizeL(RWriteStream& aStream) const;
+		
+		
+
+    public: // Functions from base classes
+    
+//sf-    *********************************
+    
+		void SetAccessTypesL( TSmlDmAccessTypes aAccessTypes );
+		void SetDefaultValueL( const TDesC8& aDefaultValue );
+		void SetDescriptionL( const TDesC8& aDescription );
+		void SetDFFormatL( TDFFormat aFormat );
+		void SetOccurenceL( TOccurence aOccurence );
+		void SetScopeL( TScope aScope );
+		void SetDFTitleL( const TDesC8& aTitle );
+		void AddDFTypeMimeTypeL( const TDesC8& aMimeType );
+		void SetAsObjectGroup();
+		MSmlDmDDFObject& AddChildObjectL(const TDesC8& aNodeName);
+		MSmlDmDDFObject& AddChildObjectGroupL();
+
+//sf-    #############################
+
+		const TDesC8& Name();
+		TSmlDmAccessTypes  AccessTypes();
+		const TDesC8& DefaultValue();
+		const TDesC8& Description();
+		TDFFormat DFFormat();
+		TOccurence Occurence();
+		TScope Scope();
+		const TDesC8& DFTitle();
+		const TDesC8& DFTypeMimeType();
+		TBool ObjectGroup();
+		
+		TInt ChildObjectCount();
+		CTestDmDDFObject& ChildObject( TInt aIndex );
+
+		CTestDmDDFObject* FindChildObject( const TDesC8& aName );
+		TInt SubObjectsCount();
+
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CTestDmDDFObject( CStifLogger *aLog );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CTestDmDDFObject( const CTestDmDDFObject& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CTestDmDDFObject& operator=( const CTestDmDDFObject& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+		HBufC8* iName;
+
+		TSmlDmAccessTypes iAccessTypes;
+		HBufC8* iDefaultValue;
+		HBufC8* iDescription;
+		TDFFormat iFormat;
+		TOccurence iOccurence;
+		TScope iScope;
+		HBufC8* iTitle;
+		HBufC8* iMimeType;
+		TBool iObjectGroup;
+		
+		RPointerArray<CTestDmDDFObject> iChildren;
+
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+        /**
+        * Logger.
+        */
+        CStifLogger*    iLog;
+
+    };
+
+#endif      // __TESTDMDDFOBJECT_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/inc/dmatest.h	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,277 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DM adapter test component
+* 	This is part of omadmextensions/adapter test application.
+*
+*/
+
+
+
+
+
+
+#ifndef __DMA_TEST_H__
+#define __DMA_TEST_H__
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <apmstd.h>
+#include <smldmadapter.h>
+#include "nsmldmemailadapter.h"
+
+class Cdmatest;
+
+
+struct TMapping
+	{
+	TBuf8<256> iURI;
+	TBuf8<64> iLuid;
+	TMapping( const TDesC8 &aURI, const TDesC8 &aLuid )  : iURI( aURI ), iLuid( aLuid )
+	{
+		
+		}
+	};
+	
+typedef RArray<TMapping> RMappingArray;
+
+typedef void (Cdmatest::* ResultsFunction)( TInt , CBufBase& , const TDesC8&  ) ; 
+
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class Cdmatest : public CScriptBase, public MSmlDmCallback
+    {
+    
+    public:  // Constructors and destructor
+        
+        /**
+        * Destructor.
+        */
+        virtual ~Cdmatest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @since ?Series60_version
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem ) = 0;
+    
+
+	public:
+		/**
+		The function is used to return the data in case of FetchLeafObjectL(),
+		FetchLeafObjectSizeL() and ChildURIListL() functions. It should not be
+		called where the DM command has failed, i.e. the error code returned in
+		SetStatusL is something other than EOk.
+		@param aResultsRef	Reference to correct command
+		@param aObject		The data which should be returned
+		@param aType			MIME type of the object
+		@publishedPartner
+		@prototype
+		*/
+		void SetResultsL( TInt aResultsRef, CBufBase& aObject,
+								  const TDesC8& aType );
+		
+		/**
+		The function is used to return the data in case of FetchLeafObjectL() and
+		ChildURIListL() functions, where the size of the data being returned is
+		large enough for the Adapter to stream it. This function should not be
+		called when command was failed, i.e. the error code returned in SetStatusL
+		is something other than EOk.
+		@param aResultsRef	Reference to correct command
+		@param aStream		Large data which should be returned, DM engine
+								closes stream when it has read all the data
+		@param aType			MIME type of the object
+		@publishedPartner
+		@prototype
+		*/
+		void SetResultsL( TInt /*aResultsRef*/, RReadStream*& /*aStream*/,
+								  const TDesC8& /*aType*/ ) 
+		{
+			
+		}
+
+		/**
+		The function returns information about the Add,Update,Delete and Fetch
+		commands success to DM engine. The reference to correct command must be
+		used when calling the SetStatusL function, the reference is got from the
+		argument of the command functions. The SetStatusL function must be called
+		separately for every single command.
+		@param aStatusRef	Reference to correct command
+		@param aErrorCode	Information about the command success
+		@publishedPartner
+		@prototype
+		*/
+		void SetStatusL( TInt aStatusRef,
+								 MSmlDmAdapter::TError aErrorCode ) ;
+
+		/**
+		The function passes map information to DM Module. This function is called
+		for a new management object, both for node objects and for leaf objects.
+		In addition if ChildURIListL() function has returned new objects a mapping
+		information of the new objects must be passed. A mapping is treated as
+		inheritable. If the mapping is not set with this function, the mapping
+		LUID of the parent object is passed in following commands to the object.
+		@param aURI	URI of the object. 
+		@param aLUID	LUID of the object. LUID must contain the all information,
+						which is needed for retrieve the invidual object from the
+						database. Typically it is ID for the database table. In
+						more complicated structures it can be combination of IDs,
+						which represent path to the object.
+		@publishedPartner
+		@prototype
+		*/
+		void SetMappingL( const TDesC8& aURI, const TDesC8& aLUID );
+
+		/**
+		The function is used to make a fetch to other adapters. The most common
+		use is to make a fetch to the AP adapter, because when managing the access
+		points, the data comes as URI. For example, there are ToNAPId field in
+		some adapters, and data to it can be something like AP/IAPidx, and then
+		the link to AP adapter is needed.
+		Using FetchLinkL causes the DM Framework to make a Get request to the
+		appropriate DM adapter.  The receiving adapter MUST complete the Get
+		request synchronously.
+		@param aURI		URI of the object. 
+		@param aData		Reference to data, i.e. data is returned here
+		@param aStatus	The status of fetch command is returned here
+		@publishedPartner
+		@prototype
+		*/
+		void FetchLinkL( const TDesC8& /*aURI*/, CBufBase& /*aData*/,
+								 MSmlDmAdapter::TError& /*aStatus*/ ) 
+			{
+				
+			}
+
+		/**
+		The function returns the LUID which is mapped to aURI. If LUID is not
+		found, the function allocates a null length string, i.e. the function
+		allocates memory in every case.
+		@param aURI	URI of the object. 
+		@publishedPartner
+		@prototype
+		*/
+		HBufC8* GetLuidAllocL( const TDesC8& aURI ) ;
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    
+    void GetMappingInfoListL( const TDesC8& aURI,
+								CArrayFix<TSmlDmMappingInfo>& aSegmentList );
+
+#else
+// nothing
+#endif
+		        
+    protected:  // New functions
+
+        
+		void FetchNodeResultsL( TInt aResultsRef, CBufBase& aObject,
+							  const TDesC8& aType );
+		void SaveDataL( TInt aResultsRef, CBufBase& aObject,
+							  const TDesC8& aType ) ;
+							  
+		TPtrC8 LastURISeg( const TDesC8& aURI );
+		TPtrC8 RemoveLastURISeg( const TDesC8& aURI );
+		TPtrC RemoveLastURISeg( const TDesC& aURI );
+		void SetURIL( const TDesC& aURI );
+		void SetURIL( const TDesC8& aURI );
+		void SetURIL( HBufC8* aURI );		
+		HBufC8 *LoadFileLC( const TDesC &aFileName, TDataType &aType );
+		HBufC8 *LoadFileLC( const TDesC8 &aFileName, TDataType &aType );
+		HBufC8 *GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName );
+		HBufC8* GetLuidAllocLC( const TDesC8& aURI ) ;
+		TPtrC8 RemoveLastSeg(const TDesC8& aURI);
+		
+		TInt FetchNodeL( CStifItemParser& aItem ) ;
+		TInt FetchLeafL( CStifItemParser& aItem ) ;
+		TInt AddNodeL( CStifItemParser& aItem );
+		TInt DeleteObjectL( CStifItemParser& aItem );	
+		TInt UpdateLeafL( CStifItemParser& aItem )	;
+		TInt UpdateLeafDataL( CStifItemParser& aItem ) ;
+		TInt UpdateLeafDataURLL( CStifItemParser& aItem ) ;
+		
+		TInt ExecuteLeafL ( CStifItemParser& aItem ) ;
+		TInt ExecuteLeafDataL ( CStifItemParser& aItem ) ;
+		TInt StartAtomicL( CStifItemParser& aItem )	;
+		TInt CommitAtomicL( CStifItemParser& aItem )	;
+		TInt RollbackAtomicL( CStifItemParser& aItem )	;
+		TInt CompleteCommandsL( CStifItemParser& aItem );
+		TInt DDFStructureL( CStifItemParser& aItem )	;
+//        TInt DeliverL( CStifItemParser& aItem ) ;
+//        TInt DetailsL( CStifItemParser& aItem ) ;
+//		TInt InstallL( CStifItemParser& aItem ) ;
+//		TInt BareInstallL( CStifItemParser& aItem ) ;		
+
+    protected:
+
+        /**
+        * C++ default constructor.
+        */
+        Cdmatest( CTestModuleIf& aTestModuleIf, TUid aUid );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // Cdmatest( const Cdmatest& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // Cdmatest& operator=( const Cdmatest& );
+
+		/**
+        * Frees all resources allocated from test methods.
+        * @since ?Series60_version
+        */
+        virtual void Delete();
+        void LoadMappingsL();
+        void SaveMappingsL();
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+		MSmlDmAdapter::TError iStatus ;
+        ResultsFunction iResultsFunction;
+        //CSmlDmAdapter *iAdapter ;
+        CNSmlDmEmailAdapter *iAdapter ;
+        HBufC8 *iURI; 
+        CArrayFix<TSmlDmMappingInfo> *iEmptyMappingInfoArray;
+		TFileName iSaveFileName;
+		RMappingArray iMappingTable;
+		TUid iUid;
+		TInt iCounter;
+		//class CNSmlDmMgmtTree* iMgmtTree;
+		class CNSmlDmMgmtTree* iMgmtTree;
+		CNSmlDmEmailAdapter *Adapter() ;
+    };
+
+#endif      // __DMA_TEST_H__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/inc/emailtest.h	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DM adapter test component
+* 	This is part of omadmextensions/adapter test application.
+*
+*/
+
+
+
+
+
+
+#ifndef TCTEST_H
+#define TCTEST_H
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <smldmadapter.h>
+#include "dmatest.h"
+
+const TUint KNSmlemailAdapterImplUid = 0x101F6E35;
+	
+
+const TUid KAdapterUid = 
+		{
+		KNSmlemailAdapterImplUid
+		};
+// Logging path
+_LIT( KamtestLogPath, "\\logs\\testframework\\tctest\\" ); 
+// Log file
+_LIT( KamtestLogFile, "tctest.txt" ); 
+
+
+// FORWARD DECLARATIONS
+class CemailTest;
+
+
+// CLASS DECLARATION
+
+/**
+*  CemailTest test class for STIF Test Framework TestScripter.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class CemailTest : public Cdmatest
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CemailTest* NewL( CTestModuleIf& aTestModuleIf );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CemailTest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @since ?Series60_version
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem );
+                
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CemailTest( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // ?classname( const ?classname& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // ?classname& operator=( const ?classname& );
+    
+        /**
+        * Frees all resources allocated from test methods.
+        * @since ?Series60_version
+        */
+        virtual void Delete();
+        
+        /**
+        * Test methods are listed below. 
+        */
+        
+        /**
+        * Example test method.
+        * @since ?Series60_version
+        * @param aItem Script line containing parameters.
+        * @return Symbian OS error code.
+        */
+/*        virtual TInt ExampleL( CStifItemParser& aItem ) ;
+        virtual TInt DeliverL( CStifItemParser& aItem ) ;
+        virtual TInt DetailsL( CStifItemParser& aItem ) ;
+		    virtual TInt InstallL( CStifItemParser& aItem ) ;
+		    virtual TInt BareInstallL( CStifItemParser& aItem ) ;*/
+		
+
+    private:    // Data
+        HBufC8 *GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName );
+
+
+    };
+
+#endif      // TCTEST_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/init/emailtest.ini	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,204 @@
+#
+# This is STIF initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module.
+# 	- Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation
+#		DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02
+#
+
+[Engine_Defaults]
+
+TestReportMode= FullReport    # Possible values are: 'Empty', 'Summary', 'Environment',
+                                                     'TestCases' or 'FullReport'
+
+CreateTestReport= YES         # Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT         # Possible values: TXT or HTML
+TestReportOutput= FILE        # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+DisableMeasurement= stifmeasurementdisablenone  # Possible values are:
+              # 'stifmeasurementdisablenone', 'stifmeasurementdisableall'
+              # 'stifmeasurementplugin01', 'stifmeasurementplugin02',
+              # 'stifmeasurementplugin03', 'stifmeasurementplugin04',
+              # 'stifmeasurementplugin05' or 'stifbappeaprofiler'
+
+Timeout= 0                    # Default timeout value for each test case. In milliseconds
+#UITestingSupport= YES        # Possible values: YES or NO
+#SeparateProcesses= YES       # Possible values: YES or NO (default: NO)
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= XXXXXXXXX
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+#[New_Module]
+#ModuleName= demomodule
+#[End_Module]
+
+
+[New_Module]
+ModuleName= testscripter
+#DM
+TestCaseFile= c:\testframework\emailtest.cfg
+[End_Module]
+
+
+# Load testmoduleXXX, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleXXX used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleXXX used configuration file(s)
+#TestCaseFile= c:\testframework\testcases1.cfg
+#TestCaseFile= c:\testframework\testcases2.cfg
+#TestCaseFile= c:\testframework\manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIF logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+#	- Will write log file in unicode format.
+#		+ YES, Log file will be written in unicode format
+#		+ NO, Log will be written as normal, not unicode, file.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#'
+#NOTE: TestEngine and TestServer logging settings cannot change here
+
+#CreateLogDirectories= YES    # Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+#EmulatorFormat= HTML         # Possible values: TXT or HTML
+#EmulatorOutput= FILE         # Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML         # Possible values: TXT or HTML
+#HardwareOutput= FILE         # Possible values: FILE or RDEBUG
+
+#FileCreationMode= OVERWRITE  # Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES       # Possible values: YES or NO
+#WithTimeStamp= YES           # Possible values: YES or NO
+#WithLineBreak= YES           # Possible values: YES or NO
+#WithEventRanking= YES        # Possible values: YES or NO
+
+#FileUnicode= YES             # Possible values: YES or NO
+#AddTestCaseTitle= YES        # Possible values: YES or NO
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/src/TestDmDDFObject.cpp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,516 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DM adapter test component
+* 	This is part of omadmextensions/adapter test application.
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+
+#include "TestDmDDFObject.h"
+#include "StifLogger.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTestDmDDFObject::CTestDmDDFObject
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTestDmDDFObject::CTestDmDDFObject( CStifLogger *aLog )
+	: iName( 0 )
+	, iAccessTypes()
+	, iDefaultValue( 0 )
+	, iDescription( 0 )
+	, iFormat( (TDFFormat)0 )
+	, iOccurence( (TOccurence)0 )
+	, iScope( (TScope)0 )
+	, iTitle ( 0 )
+	, iMimeType( 0 )
+	, iObjectGroup( EFalse )
+	, iLog( aLog )
+//	RPointerArray<CTestDmDDFObject> iChildren;
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDmDDFObject::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTestDmDDFObject::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDmDDFObject::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTestDmDDFObject* CTestDmDDFObject::NewL( CStifLogger *aLog )
+    {
+    CTestDmDDFObject* self = CTestDmDDFObject::NewLC( aLog );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CTestDmDDFObject* CTestDmDDFObject::NewLC( CStifLogger *aLog )
+    {
+    CTestDmDDFObject* self = new( ELeave ) CTestDmDDFObject( aLog );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+
+    return self;
+    }
+
+    
+// Destructor
+CTestDmDDFObject::~CTestDmDDFObject()
+    {
+	delete iName;
+	delete iDefaultValue;
+	delete iDescription;
+	delete iTitle;
+	delete iMimeType;
+	iChildren.ResetAndDestroy();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTestDmDDFObject::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+/*?type CTestDmDDFObject::?member_function(
+    ?arg_type arg,
+    ?arg_type arg )
+    {
+    
+    ?code
+    
+    }
+*/
+
+void CTestDmDDFObject::SetAccessTypesL( TSmlDmAccessTypes aAccessTypes )
+	{
+	iLog->Log( _L8( "SetAccessTypesL, aAccessTypes=%d" ), aAccessTypes.GetACL() );
+	iAccessTypes = aAccessTypes;
+	}
+
+void CTestDmDDFObject::SetDefaultValueL( const TDesC8& aDefaultValue )
+	{
+	iLog->Log( _L8( "SetDefaultValueL, aDefaultValue='%S'" ), &aDefaultValue );
+	delete iDefaultValue;
+	iDefaultValue = 0;
+	iDefaultValue = aDefaultValue.AllocL();
+	}
+
+void CTestDmDDFObject::SetDescriptionL( const TDesC8& aDescription )
+	{
+	iLog->Log( _L8( "SetDescriptionL, aDescription='%S'" ), &aDescription );
+	delete iDescription;
+	iDescription = 0;
+	iDescription = aDescription.AllocL();
+	}
+	
+void CTestDmDDFObject::SetDFFormatL( TDFFormat aFormat )
+	{
+	iLog->Log( _L8( "SetDFFormatL, aFormat=%d" ), aFormat );
+	iFormat = aFormat;
+	}
+	
+void CTestDmDDFObject::SetOccurenceL( TOccurence aOccurence )
+	{
+	iLog->Log( _L8( "SetOccurenceL, aOccurence=%d" ), aOccurence );
+	iOccurence = aOccurence;
+	}
+	
+void CTestDmDDFObject::SetScopeL( TScope aScope )
+	{
+	iLog->Log( _L8( "SetScopeL, aScope=%d" ), aScope );
+	iScope = aScope;
+	}
+	
+void CTestDmDDFObject::SetDFTitleL( const TDesC8& aTitle )
+	{
+	iLog->Log( _L8( "SetDFTitleL, aTitle='%S'" ), &aTitle );
+	delete iTitle;
+	iTitle = 0;
+	iTitle = aTitle.AllocL();
+	}
+	
+void CTestDmDDFObject::AddDFTypeMimeTypeL( const TDesC8& aMimeType )
+	{
+	iLog->Log( _L8( "AddDFTypeMimeTypeL, aMimeType='%S'" ), &aMimeType );
+	delete iMimeType;
+	iMimeType = 0;
+	iMimeType = aMimeType.AllocL();
+	}
+	
+void CTestDmDDFObject::SetAsObjectGroup()
+	{
+	iLog->Log( _L8( "SetAsObjectGroup, true" ) );
+	iObjectGroup = ETrue;
+	}
+	
+MSmlDmDDFObject& CTestDmDDFObject::AddChildObjectL(const TDesC8& aNodeName)
+	{
+	iLog->Log( _L8( "AddChildObjectL, aNodeName='%S'" ), &aNodeName );
+	CTestDmDDFObject* child = CTestDmDDFObject::NewLC( iLog ); //, aNodeName );
+	child->SetNameL( aNodeName );
+	iChildren.AppendL( child );
+	CleanupStack::Pop( child ); // Don't destroy
+	return *child;
+	}
+
+MSmlDmDDFObject& CTestDmDDFObject::AddChildObjectGroupL()
+	{
+	iLog->Log( _L8( "AddChildObjectGroupL, ''" ) );
+	CTestDmDDFObject* child = CTestDmDDFObject::NewLC( iLog ); //, KNullDesC );
+	child->SetAsObjectGroup();
+	iChildren.AppendL( child );
+	CleanupStack::Pop( child ); // Don't destroy
+	return *child;
+	}
+
+// Own functions
+
+void CTestDmDDFObject::SetNameL( const TDesC8& aName )
+	{
+	delete iName;
+	iName = 0;
+	iName = aName.AllocL();
+	}
+
+void CTestDmDDFObject::DumpL( const TDesC8& aParentName, TBool aFullDump )
+	{
+	TPtrC8 name( _L8("<X>") );
+	if (iName && iName->Length() > 0)
+		{
+		name.Set( *iName );
+		}
+
+	HBufC8* fullName = HBufC8::NewLC( aParentName.Length() + name.Length() + 1 );
+	*fullName = aParentName;
+	if (aParentName.Length() > 0 && aParentName[ aParentName.Length() - 1 ] != '/')
+		{
+		fullName->Des().Append( _L8("/"));
+		}
+	fullName->Des().Append( name );
+
+	/* Translate some members to text for dumping */
+	TBuf8<20> strAccessTypes;
+	TUint8 accessTypes = iAccessTypes.GetACL();
+	if ((accessTypes & iAccessTypes.EAccessType_Add) != 0)
+		{
+		strAccessTypes.Append( _L8("A") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Copy) != 0)
+		{
+		strAccessTypes.Append( _L8("C") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Delete) != 0)
+		{
+		strAccessTypes.Append( _L8("D") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Exec) != 0)
+		{
+		strAccessTypes.Append( _L8("E") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Get) != 0)
+		{
+		strAccessTypes.Append( _L8("G") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Replace) != 0)
+		{
+		strAccessTypes.Append( _L8("R") );
+		}
+	
+	TBuf8<20> strFormat;
+	switch( iFormat )
+		{
+	case EB64:
+		strFormat = _L8("Base64");
+		break;
+	case EBool:
+		strFormat = _L8("Bool");
+		break;
+	case EChr:
+		strFormat = _L8("Chr");
+		break;
+	case EInt:
+		strFormat = _L8("Int");
+		break;
+	case ENode:
+		strFormat = _L8("Node");
+		break;
+	case ENull:
+		strFormat = _L8("Null");
+		break;
+	case EXml:
+		strFormat = _L8("Xml");
+		break;
+	case EBin:
+		strFormat = _L8("Bin");
+		break;
+	default:
+		break;
+		}
+
+
+	TBuf8<20> strOccurence;
+	switch( iOccurence )
+		{
+	case EOne:
+		/** The node appears exactly once */
+		strOccurence = _L8("M:1");
+		break;
+	case EZeroOrOne:
+		/** The node is optional and may appear zero or once */
+		strOccurence = _L8("O:0-1");
+		break;
+	case EZeroOrMore:
+		/** The node is optional and may appear zero or more times */
+		strOccurence = _L8("O:0-*");
+		break;
+	case EOneOrMore:
+		/** The node is mandatory and may appear once or more times */
+		strOccurence = _L8("M:1-*");
+		break;
+	case EZeroOrN:
+		/** The node is optional and may appear between once and 'N' times */
+		strOccurence = _L8("O:1-N");
+		break;
+	case EOneOrN:
+		/** The node is mandatory and may appear between once and 'N' times */
+		strOccurence = _L8("M:1-N");
+		break;
+	default:
+		break;
+		}
+	
+	
+	TBuf8<20> strScope;
+	switch( iScope)
+		{
+	case EPermanent:
+		/** The node appears exactly once */
+		strScope = _L8("Permanent");
+		break;
+	case EDynamic:
+		/** The node is optional and may appear zero or once */
+		strScope = _L8("O:Dynamic");
+		break;
+	default:
+		break;
+		}
+
+	
+	/* Dump main data */
+	if (aFullDump)
+		{
+		iLog->Log( _L8( "DDFObject: '%S'" ), fullName );
+		}
+		else
+		{
+		iLog->Log( _L8( "DDFObject: '%S'   (%S), %S, %S, %S" ),
+					fullName, &strAccessTypes, &strFormat, &strOccurence, &strScope );
+		}
+	
+	/* Dump members */
+	if (aFullDump)
+		{
+		TPtrC8 empty( _L8( "<null>" ) );
+		#define CHK_NULL(a) ((a)==0?(TDesC8*)(&empty):(TDesC8*)(a))
+
+		iLog->Log( _L8( "    iName=='%S'" ), iName );
+		iLog->Log( _L8( "    iAccessTypes=%d (%S)" ), iAccessTypes.GetACL(), &strAccessTypes );
+		iLog->Log( _L8( "    iDefaultValue='%S'" ), CHK_NULL(iDefaultValue));
+		iLog->Log( _L8( "    iDescription='%S'" ), CHK_NULL(iDescription ));
+		iLog->Log( _L8( "    iFormat=%d (%S)" ), iFormat, &strFormat );
+		iLog->Log( _L8( "    iOccurence=%d (%S)" ), iOccurence, &strOccurence );
+		iLog->Log( _L8( "    iScope=%d (%S)" ), iScope, &strScope );
+		iLog->Log( _L8( "    iTitle='%S'" ), CHK_NULL(iTitle ));
+		iLog->Log( _L8( "    iMimeType='%S'" ), CHK_NULL(iMimeType ));
+		iLog->Log( _L8( "----------------------------------" ) );
+		}
+	
+	/* Dump children */
+	for (TInt i = 0 ; i < iChildren.Count() ; i++)
+		{
+		iChildren[i]->DumpL( *fullName, aFullDump );
+		}
+
+	CleanupStack::PopAndDestroy( fullName );
+	}
+
+/*
+void CTestDmDDFObject::ExternalizeL(RWriteStream& aStream) const
+	{
+	X;
+	aStream << *iName << eol;
+	}
+*/
+
+const TDesC8& CTestDmDDFObject::Name()
+	{
+	return (iName != 0) ? *iName : KNullDesC8();
+	}
+
+TSmlDmAccessTypes  CTestDmDDFObject::AccessTypes()
+	{
+	return iAccessTypes;
+	}
+
+const TDesC8& CTestDmDDFObject::DefaultValue()
+	{
+	return (iDefaultValue != 0) ? *iDefaultValue : KNullDesC8();
+	}
+
+const TDesC8& CTestDmDDFObject::Description()
+	{
+	return (iDescription != 0) ? *iDescription : KNullDesC8();
+	}
+
+CTestDmDDFObject::TDFFormat CTestDmDDFObject::DFFormat()
+	{
+	return iFormat;
+	}
+
+CTestDmDDFObject::TOccurence CTestDmDDFObject::Occurence()
+	{
+	return iOccurence;
+	}
+
+CTestDmDDFObject::TScope CTestDmDDFObject::Scope()
+	{
+	return iScope;
+	}
+
+const TDesC8& CTestDmDDFObject::DFTitle()
+	{
+	return (iTitle != 0) ? *iTitle : KNullDesC8();
+	}
+
+const TDesC8& CTestDmDDFObject::DFTypeMimeType()
+	{
+	return (iMimeType != 0) ? *iMimeType : KNullDesC8();
+	}
+
+TBool CTestDmDDFObject::ObjectGroup()
+	{
+	return iObjectGroup;
+	}
+
+TInt CTestDmDDFObject::ChildObjectCount()
+	{
+	return iChildren.Count();
+	}
+
+CTestDmDDFObject& CTestDmDDFObject::ChildObject( TInt aIndex )
+	{
+	return *iChildren[aIndex];
+	}
+
+CTestDmDDFObject* CTestDmDDFObject::FindChildObject( const TDesC8& aName )
+	{
+	CTestDmDDFObject* foundObject = 0;
+
+	for (TInt i = 0 ; i < iChildren.Count() ; i++)
+		{
+		if ( aName.CompareC( iChildren[i]->Name() ) == 0 )
+			{
+			foundObject = iChildren[i];
+			break;
+			}
+		}
+
+	return foundObject;
+	}
+
+TInt CTestDmDDFObject::SubObjectsCount()
+	{
+	TInt count = 0;
+
+	TInt i;
+	for (i = 0 ; i < iChildren.Count() ; i++)
+		{
+		count += iChildren[i]->SubObjectsCount();
+		}
+	count += i;
+
+	return count;
+	}
+
+/*
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+?type  ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg )  // ?description
+    {
+
+    ?code
+
+    }
+*/
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/src/dmatest.cpp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,953 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DM adapter test component
+* 	This is part of omadmextensions/adapter test application.
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+#include "dmatest.h"
+
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include <S32FILE.H>
+#include <s32mem.h>
+#include <apgcli.h>
+#include <e32svr.h>
+#include <e32math.h>
+#include <f32file.h>
+#include <swinstapi.h>
+
+#include "TestDmDDFObject.h"
+
+_LIT8( KEmptyType, "" );
+_LIT8( KDefaultType, "text/plain" );
+_LIT( KMappingTableFile, "\\dmtestmappings.txt" );
+//_LIT8( KNSmlDMSeparator8, "/" );
+const TUint8 KNSmlDMUriSeparator = 0x2f; //forward slash
+
+#define LEAVE_IF_ERROR(x,msg) \
+	{ TInt __xres = (x); if ( __xres < 0 ) { if ( iLog ) iLog->Log( (msg), __xres ); User::Leave( __xres );	} }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cdmatest::Cdmatest
+// C++ default constructor can NOT contain any code, that
+// leave.
+// -----------------------------------------------------------------------------
+//
+Cdmatest::Cdmatest(CTestModuleIf& aTestModuleIf, TUid aUid ):
+        CScriptBase( aTestModuleIf ), iMappingTable(2), iUid( aUid )
+    {
+    
+    }
+
+// -----------------------------------------------------------------------------
+// Cdmatest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Cdmatest::ConstructL()
+    {    
+    Adapter();
+	iEmptyMappingInfoArray = new ( ELeave ) CArrayFixFlat<TSmlDmMappingInfo>(1);
+	
+	TRAPD( err, LoadMappingsL() );
+	if (err != KErrEof && err != KErrNone && err != KErrNotFound)
+		{
+		User::Leave( err );
+		}
+    }
+    
+CNSmlDmEmailAdapter *Cdmatest::Adapter()  
+	{
+	if ( iAdapter == NULL )
+		{
+		if ( iLog )
+			{
+			iLog->Log( _L( "Loading Adapter" ) );
+			}
+  		
+  		TRAPD( err, iAdapter = (CNSmlDmEmailAdapter*) CSmlDmAdapter::NewL( iUid,*this ) );
+	if ( err == KErrNone )
+		{
+		if (iLog )
+			{
+			iLog->Log( _L( "Loaded" ) );	
+			}
+		}
+	else
+		{
+		if (iLog)
+			{
+			iLog->Log( _L( "Failed to load adapter: %d" ), err );
+			}
+		}
+		}
+	return iAdapter;
+	}
+    
+    
+void Cdmatest::LoadMappingsL()
+	{
+	TDataType type; 
+	HBufC8 *data = LoadFileLC( KMappingTableFile,  type );
+	RDesReadStream buf( *data );
+	CleanupClosePushL( buf );
+
+	TInt len( data->Length() );
+	while (buf.Source()->TellL( MStreamBuf::ERead ).Offset() < len)
+		{
+		TUint32 val = buf.ReadUint32L();
+		TBuf8<256> uri;
+		TBuf8<64> luid;
+		buf.ReadL(uri, val);
+		val = buf.ReadUint32L();
+		buf.ReadL(luid, val);
+		TMapping m( uri, luid ) ;
+		TInt err( iMappingTable.Append( m )	);
+		if ( err == KErrNone )
+			{
+			iLog->Log( _L8( "Loaded mapping: '%S' : '%S'"), &m.iURI, &m.iLuid );
+			}
+		else
+			{
+			iLog->Log( _L8( "FAILED TO Load mapping: '%d' "), err );
+			}
+		}
+	CleanupStack::PopAndDestroy( &buf); // buf
+	CleanupStack::PopAndDestroy( data ); // data
+	}
+    	
+	
+
+void Cdmatest::SaveMappingsL()
+    {
+	TInt c( iMappingTable.Count() );
+	if ( c > 0 )
+	{
+    	RFs fs;
+    	User::LeaveIfError( fs.Connect() );
+    	CleanupClosePushL( fs );
+    	RFileWriteStream buf;
+    	User::LeaveIfError( buf.Replace( fs, KMappingTableFile, EFileWrite ) );
+    	CleanupClosePushL( buf );
+		
+		TInt i( 0 ) ;
+		do 
+			{
+			buf.WriteUint32L( iMappingTable[i].iURI.Length() );
+			buf.WriteL( iMappingTable[i].iURI );
+			buf.WriteUint32L( iMappingTable[i].iLuid.Length() );
+			buf.WriteL( iMappingTable[i].iLuid );
+			}
+		while ( ++i < c )	;
+		buf.CommitL();
+		buf.Close();
+	
+		CleanupStack::PopAndDestroy(); // buf
+		CleanupStack::PopAndDestroy(); // fs
+		}
+    }
+    	
+    
+// Destructor
+Cdmatest::~Cdmatest()
+    {
+    // Delete resources allocated from test methods
+    TRAPD(err, SaveMappingsL() );
+    if ( err != KErrNone )
+    	{
+    	iLog->Log( _L8( "Failed to save mappings!: %d"), err );
+    	}
+    Delete();
+    
+    // Delete logger
+    delete iLog;  
+    delete iEmptyMappingInfoArray;
+    delete iAdapter;
+    delete iURI;
+    iMappingTable.Reset();
+    REComSession::FinalClose();    
+    }
+
+
+// -----------------------------------------------------------------------------
+// Camatest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void Cdmatest::Delete() 
+    {
+    
+    }
+
+// -----------------------------------------------------------------------------
+// Cdmatest::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+
+
+        
+HBufC8 *Cdmatest::GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName )
+	{
+	TPtrC nodename( KNullDesC );
+
+    TInt i( aItem.GetNextString ( nodename ) );
+    if ( i != KErrNone ) 
+	    {
+	    iLog->Log( _L( "ERROR Reading '%S' argument: 0x%X" ), &aName, i );
+	    }
+	else
+		{
+		iLog->Log( _L("%S: %S"), &aName, &nodename);
+		}
+	
+	HBufC8 *buf = HBufC8::NewLC( nodename.Length() ) ;
+	buf->Des().Copy( nodename );
+	return buf;
+	}
+	
+TInt Cdmatest::FetchNodeL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("FetchNodeL") );
+
+	iResultsFunction = FetchNodeResultsL;
+	
+    TPtrC8 nodename( GetNextStringLC( aItem, _L(" nodename" ) )->Des() ) ;
+		
+	SetURIL(nodename) ;//
+	HBufC8 *luid = GetLuidAllocLC( *iURI );
+
+	Adapter()->ChildURIListL( *iURI, *luid, *iEmptyMappingInfoArray, 4, 5) ;
+
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		}
+	else
+		{
+		iLog->Log( _L("FetchNodeL: ChildUriList Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid ) ; 
+	CleanupStack::PopAndDestroy() ; // nodename
+	iLog->Log( _L("FetchNodeL: Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+	
+TInt Cdmatest::StartAtomicL( CStifItemParser& /*aItem*/ )	
+	{
+	TRAPD( err, Adapter()->StartAtomicL() ) ;
+	iLog->Log( _L("StartAtomicL: Atomic started resulting error %d" ), err );	
+    return err;
+	}
+
+TInt Cdmatest::RollbackAtomicL( CStifItemParser& /*aItem*/ )	
+	{
+	TRAPD( err, Adapter()->RollbackAtomicL() ) ;
+	iLog->Log( _L("RollbackAtomicL: Atomic rolled back resulting error %d" ), err );	
+    return err;
+	}
+	
+TInt Cdmatest::CommitAtomicL( CStifItemParser& /*aItem*/ )	
+	{
+	TRAPD( err, Adapter()->CommitAtomicL() ) ;
+	iLog->Log( _L("RollbackAtomicL: Atomic commited resulting error %d" ), err );	
+    return err;
+	}
+	
+
+TInt Cdmatest::DDFStructureL( CStifItemParser& /*aItem*/ )	
+	{
+	CTestDmDDFObject* ddfRoot = CTestDmDDFObject::NewLC( iLog ); //, aNodeName );
+
+	TRAPD( err, iAdapter->DDFStructureL( *ddfRoot ) ) ;
+	CleanupStack::PopAndDestroy( ddfRoot );
+	iLog->Log( _L("DDFStructureL: method called resulting error %d" ), err );	
+    return err;
+	}
+		
+		
+TInt Cdmatest::AddNodeL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("AddNodeL") );
+
+    
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("nodename" ) )->Des() ) ;
+    SetURIL( nodename );
+
+	Adapter()->AddNodeObjectL( *iURI, KEmptyType, 8 ) ;
+	
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("AddNodeL: AddNodeObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("AddNodeL: AddNodeObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+		
+	CleanupStack::PopAndDestroy() ; // nodename
+	iLog->Log( _L("AddNodeL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}	
+		
+TInt Cdmatest::UpdateLeafL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("UpdateLeafL") );
+
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
+    TPtrC8 data (GetNextStringLC( aItem, _L("datafile"))->Des() );
+    
+	HBufC8 *mime = GetNextStringLC( aItem, _L("mime") ) ;
+    SetURIL( nodename );
+    
+    TPtrC8 parentURI(RemoveLastSeg(nodename));
+    HBufC8 *luid = GetLuidAllocLC( parentURI );
+    
+    TDataType type; 
+
+	TPtrC8 mimePtr( *mime == KNullDesC8 ? type.Des8() : mime->Des() );
+
+    /**
+    virtual void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+									const TDesC8& aObject, const TDesC8& aType,
+									TInt aStatusRef ) = 0;
+    */
+    
+	Adapter()->UpdateLeafObjectL( *iURI , *luid, data, mimePtr, 3);
+
+	if ( iStatus == MSmlDmAdapter::EOk )
+	{
+		iLog->Log( _L("UpdateLeafL: UpdateLeafObjectL Successful! %d" ), iStatus );	
+	}
+	else
+	{
+		iLog->Log( _L("UpdateLeafL UpdateLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+	}
+
+	CleanupStack::PopAndDestroy(); // loadfile
+	CleanupStack::PopAndDestroy(); // luid
+	CleanupStack::PopAndDestroy(); // mime
+	CleanupStack::PopAndDestroy(); // nodename
+
+	iLog->Log( _L("UpdateLeafL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}	
+	
+
+TInt Cdmatest::UpdateLeafDataURLL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("UpdateLeafDataL") );
+
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
+    TPtrC8 http (GetNextStringLC( aItem, _L("http"))->Des() );
+    TPtrC8 url (GetNextStringLC( aItem, _L("rest of url"))->Des() );
+	HBufC8 *mime = GetNextStringLC( aItem, _L("mime") ) ;
+    SetURIL( nodename );
+    
+    _LIT8( KTag, "://" );
+    
+    HBufC8 *fullurl = HBufC8::NewLC( http.Length() + KTag().Length() + url.Length() );
+    TPtr8 pfullurl( fullurl->Des() );
+    pfullurl.Copy( http ) ;
+    pfullurl.Append( KTag );
+    pfullurl.Append( url );
+    TPtrC8 mimePtr( *mime == KNullDesC8 ? KDefaultType() : mime->Des() );
+    
+    HBufC8 *luid = GetLuidAllocLC( *iURI );
+    /**
+    virtual void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+									const TDesC8& aObject, const TDesC8& aType,
+									TInt aStatusRef ) = 0;
+    */
+	Adapter()->UpdateLeafObjectL( *iURI , *luid, pfullurl, mimePtr, 3);
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("UpdateLeafDataL: UpdateLeafObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("UpdateLeafDataL UpdateLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid ); // 
+	CleanupStack::PopAndDestroy( mime ); // mime
+	CleanupStack::PopAndDestroy(); // url
+	CleanupStack::PopAndDestroy(); // http
+	CleanupStack::PopAndDestroy(); // nodename
+	iLog->Log( _L("UpdateLeafDataL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+    
+TInt Cdmatest::UpdateLeafDataL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+   TestModuleIf().Printf( 0, _L("Camtest"), _L("UpdateLeafDataL") );
+
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
+    TPtrC8 data (GetNextStringLC( aItem, _L("data"))->Des() );
+	HBufC8 *mime = GetNextStringLC( aItem, _L("mime") ) ;
+	
+    SetURIL( nodename );
+    
+        
+    TPtrC8 mimePtr( *mime == KNullDesC8 ? KDefaultType() : mime->Des() );
+    
+    TPtrC8 parentURI(RemoveLastSeg(nodename));
+    HBufC8 *luid = GetLuidAllocLC( parentURI );
+     
+//    
+//    virtual void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+//									const TDesC8& aObject, const TDesC8& aType,
+//									TInt aStatusRef ) = 0;
+//   
+	Adapter()->UpdateLeafObjectL( *iURI , *luid, data, mimePtr, 3);
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("UpdateLeafDataL: UpdateLeafObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("UpdateLeafDataL UpdateLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	
+	CleanupStack::PopAndDestroy(); // mime
+	CleanupStack::PopAndDestroy(); // luid
+	CleanupStack::PopAndDestroy(); // data
+	CleanupStack::PopAndDestroy(); // nodename
+	iLog->Log( _L("UpdateLeafDataL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}	
+			
+TInt Cdmatest::FetchLeafL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Camtest"), _L("FetchLeafL") );
+
+	iResultsFunction = NULL;
+	
+    TInt i( 0 );
+    TPtrC8 nodename ( GetNextStringLC( aItem, _L( "nodename" ) )->Des() ) ;
+    
+    //TPtrC datafile;
+    TPtrC datafile( KNullDesC );
+    i = aItem.GetNextString ( datafile ) ;
+    if ( i != KErrNone ) 
+	    {
+	    iLog->Log(_L("FetchLeafL: ERROR Reading outfile argument: 0x%X"), i );
+	    //return i;
+	    }
+	else
+		{
+		iSaveFileName = datafile;
+		iLog->Log( _L( " Save file nameis '%S'" ), &iSaveFileName );
+		iResultsFunction = SaveDataL;
+		}
+    
+	SetURIL(nodename) ;
+		
+		/*
+			void FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+								   const TDesC8& aType, TInt aResultsRef,
+								   TInt aStatusRef );
+		*/
+    TPtrC8 parentURI(RemoveLastSeg(nodename));
+    HBufC8 *luid = GetLuidAllocLC( parentURI );
+
+	Adapter()->FetchLeafObjectL( *iURI, *luid, KEmptyType, 7, 8 ) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("FetchLeafL: FetchLeafObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("FetchLeafL: FetchLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid );
+	CleanupStack::PopAndDestroy(  ); // nodename
+	iLog->Log( _L("FetchLeafL Test Complete with status %d" ), ret );	
+    return ret;
+	}	
+
+
+TInt Cdmatest::ExecuteLeafL( CStifItemParser& aItem )		
+	{
+	TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Camtest"), _L("ExecuteLeafL") );
+
+	iResultsFunction = NULL;
+	
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Nodename") )->Des() ) ;
+    TPtrC8 data( GetNextStringLC ( aItem, _L("Input file") )->Des() ) ;
+	
+	SetURIL(nodename) ;
+
+		/*
+			virtual void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID,
+							      const TDesC8& aArgument, const TDesC8& aType,
+								  TInt aStatusRef ) = 0;
+		*/
+	TDataType type;
+	
+    TPtrC8 parentURI(RemoveLastSeg(nodename));
+    HBufC8 *luid = GetLuidAllocLC( parentURI );
+
+	Adapter()->ExecuteCommandL( *iURI, *luid, data, KEmptyType, 11 ) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("ExecuteLeafL: ExecuteCommandL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("ExecuteLeafL: ExecuteCommandL FetchLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid ); // luid
+	CleanupStack::PopAndDestroy(); // data
+	CleanupStack::PopAndDestroy(); // nodename
+	
+	iLog->Log( _L("ExecuteLeafL: Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+	
+TInt Cdmatest::CompleteCommandsL( CStifItemParser& /*aItem*/ )
+	{
+	TRAPD( err, Adapter()->CompleteOutstandingCmdsL() );
+	delete iAdapter;
+	iAdapter = NULL;
+	return err;
+	}
+TInt Cdmatest::DeleteObjectL( CStifItemParser& aItem )
+{
+	TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Camtest"), _L("DeleteObjectL") );
+
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Nodename") )->Des() ) ;
+
+	SetURIL(nodename) ;
+
+	HBufC8 *luid = GetLuidAllocLC( *iURI );
+	Adapter()->DeleteObjectL( *iURI, *luid, 11 ) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("DeleteNode: DeleteObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("DeleteNode: DeleteObjectL FetchLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid ); // luid
+	CleanupStack::PopAndDestroy(); // nodename	
+	iLog->Log( _L("ExecuteLeafDataL Test Complete with status %d" ), ret );	
+
+    return ret;	
+}
+	
+TInt Cdmatest::ExecuteLeafDataL( CStifItemParser& aItem )		
+	{
+	TInt ret( KErrNone );
+
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Camtest"), _L("ExecuteLeafL") );
+
+	iResultsFunction = NULL;
+	
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Nodename") )->Des() ) ;
+    TPtrC8 data( GetNextStringLC ( aItem, _L("Input data") )->Des() ) ;
+    
+	SetURIL(nodename) ;
+
+		/*
+			virtual void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID,
+							      const TDesC8& aArgument, const TDesC8& aType,
+								  TInt aStatusRef ) = 0;
+		*/
+	HBufC8 *luid = GetLuidAllocLC( *iURI );
+	Adapter()->ExecuteCommandL( *iURI, *luid, data, KEmptyType, 11 ) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("ExecuteLeafDataL: ExecuteCommandL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("ExecuteLeafDataL: ExecuteCommandL FetchLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy(); // luid
+	CleanupStack::PopAndDestroy(); // data		
+	CleanupStack::PopAndDestroy(); // nodename	
+	iLog->Log( _L("ExecuteLeafDataL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+
+
+HBufC8 *Cdmatest::LoadFileLC( const TDesC &aFileName, TDataType &aType )	
+	{
+	RFs fs ;
+	LEAVE_IF_ERROR( fs.Connect(), _L( "Could not connect fileserver: %d"  ) );
+	
+	CleanupClosePushL( fs );
+	RFile file ;
+	LEAVE_IF_ERROR( file.Open(fs,aFileName,EFileRead), _L( "Could not open file: %d" ) );
+	
+	
+	
+	CleanupClosePushL( file );
+	TInt dataSize ;
+	LEAVE_IF_ERROR( file.Size( dataSize ), _L( "Could not get file size: %d" ) );
+	HBufC8 *nodedata = HBufC8::NewL ( dataSize );
+	CleanupStack::PushL( nodedata );
+	TPtr8 nodedataptr( nodedata->Des() );
+	LEAVE_IF_ERROR( file.Read( nodedataptr ), _L( "Could not read file: %d" ) );
+	TDataRecognitionResult aDataType;
+	RApaLsSession ls ;
+	TInt err( ls.Connect() );
+	if ( err == KErrNone )
+		{
+		CleanupClosePushL( ls );
+		err = ls.RecognizeData(aFileName, nodedataptr, aDataType)  ;
+		if ( err == KErrNone )
+			{
+			aType = aDataType.iDataType;
+			}
+		else
+			{
+			iLog->Log( _L("LoadFileLC: WARNING Failed to get type: %d" ), err );
+			aType = TDataType( KDefaultType );
+			}	
+		CleanupStack::PopAndDestroy( &ls ); 
+		}
+	else
+		{
+		iLog->Log( _L("LoadFileLC: WARNING Failed to connect rapalssession: %d" ), err );
+		}	
+	CleanupStack::Pop( nodedata );
+	CleanupStack::PopAndDestroy( &file ); 
+	CleanupStack::PopAndDestroy( &fs ); 
+	CleanupStack::PushL( nodedata );
+	return nodedata ;
+	}
+
+HBufC8 *Cdmatest::LoadFileLC( const TDesC8 &aFileName, TDataType &aType )	
+	{
+	TFileName fn ;
+	fn.Copy( aFileName );
+	return LoadFileLC( fn, aType );
+	}
+	
+
+void Cdmatest::SaveDataL( TInt /*aResultsRef*/, CBufBase& aObject,
+							  const TDesC8& aType ) 
+	{
+	iLog->Log( _L8( "Saving data of type: '%S'" ), &aType );
+	RFs fs;
+	User::LeaveIfError( fs.Connect() );
+	CleanupClosePushL( fs );
+	RFile file;
+	User::LeaveIfError( file.Replace ( fs, iSaveFileName, EFileWrite ) );
+	CleanupClosePushL( file );
+	TPtrC8 p( aObject.Ptr( 0 ) );
+	User::LeaveIfError( file.Write( p ) );
+	CleanupStack::PopAndDestroy( 2 ); // file, fs
+	}
+							  
+		
+	
+void Cdmatest::FetchNodeResultsL( TInt /*aResultsRef*/, CBufBase& aObject,
+							  const TDesC8& /*aType*/ )
+	{
+	TPtrC8 ptr( aObject.Ptr( 0 ) );	
+	iLog->Log( _L8("FetchNodeResultsL for '%S': '%S'" ), iURI, &ptr );
+	
+	if ( ptr.Length() > 0 )
+		{
+		TPtrC8 last( LastURISeg( ptr ) );
+		HBufC8 *oldUri = HBufC8::NewL( iURI->Length() );
+		(*oldUri) = *iURI; 
+		do 
+			{
+			iLog->Log ( _L8( " Node: '%S' "), &last );
+			HBufC8 *nUri = HBufC8::NewLC( oldUri->Length() + 1 + last.Length() );
+			nUri->Des().Copy( *oldUri ) ;
+			nUri->Des().Append( '/' );
+			nUri->Des().Append( last );
+			
+			SetURIL( nUri );
+			//iResultsFunction = FetchNodeResultsL;
+			
+		    //TPtrC8 parentURI(RemoveLastSeg(*nUri));
+		    //HBufC8 *luid = GetLuidAllocLC( parentURI );
+		    CleanupStack::Pop( nUri );
+			
+			HBufC8 *luid = GetLuidAllocLC( *iURI );
+			
+			Adapter()->ChildURIListL( *nUri, KNullDesC8, *iEmptyMappingInfoArray, 4, 5 );//Dipak
+			
+			CleanupStack::PopAndDestroy( luid ); 			
+			
+			ptr.Set( RemoveLastURISeg( ptr ) );
+			last.Set( LastURISeg( ptr ) );
+			
+			}
+		while (last != KNullDesC8);	
+		}
+	
+	}
+	
+
+	
+TPtrC8 Cdmatest::LastURISeg( const TDesC8& aURI )
+	{
+	TInt i;
+	for( i = aURI.Length() - 1; i >= 0; i-- ) 
+		{
+		if( aURI[i] == '/' )
+			{
+			break;
+			}
+		}
+
+	if( i == 0 )
+		{
+		return aURI;
+		}
+	else
+		{
+		return aURI.Mid( i+1 );
+		}
+	}
+TPtrC8 Cdmatest::RemoveLastSeg(const TDesC8& aURI)
+	{
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			break;
+			}
+		}
+
+	if(i>0)
+		{
+		return aURI.Left(i);
+		}
+	else
+		{
+		return KNullDesC8();
+		}
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 Cdmatest::RemoveLastURISeg(const TDesC8& aURI)
+// returns parent uri, i.e. removes last uri segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 Cdmatest::RemoveLastURISeg( const TDesC8& aURI )
+	{
+	TInt i;
+	for ( i = aURI.Length() - 1; i >= 0 ; i-- )
+		{
+		if( aURI[i] == '/' )
+			{
+			break;
+			}
+		}
+	if ( i > -1 )
+		{
+		return aURI.Left( i );	
+		}
+	else
+		{
+		return KNullDesC8();
+		}
+	}	
+	
+TPtrC Cdmatest::RemoveLastURISeg( const TDesC& aURI )
+	{
+	TInt i;
+	for ( i = aURI.Length() - 1; i >= 0 ; i-- )
+		{
+		if( aURI[i] == '/' )
+			{
+			break;
+			}
+		}
+	if ( i > -1 )
+		{
+		return aURI.Left( i );	
+		}
+	else
+
+		{
+		return KNullDesC();
+		}
+	}		
+	
+void Cdmatest::SetURIL( const TDesC& aURI )
+	{
+	if ( iURI != NULL )
+		{
+		delete iURI ;
+		iURI = NULL;
+		}
+	iURI = HBufC8::NewL( aURI.Length() ) ;
+	iURI->Des().Copy( aURI );
+	}
+	
+void Cdmatest::SetURIL( const TDesC8& aURI )
+	{
+	if ( iURI != NULL )
+		{
+		delete iURI ;
+		iURI = NULL;
+		}
+	iURI = HBufC8::NewL( aURI.Length() ) ;
+	iURI->Des().Copy( aURI );
+	}	
+
+void Cdmatest::SetURIL( HBufC8* aURI )
+	{
+	if ( iURI != NULL )
+		{
+		delete iURI ;
+		iURI = NULL;
+		}
+	iURI = aURI ;
+	}
+		
+		
+		
+void Cdmatest::SetResultsL( 
+	TInt aResultsRef, 
+	CBufBase& aObject,
+	const TDesC8& aType )
+	{
+	TPtrC8 ptr( aObject.Ptr(0) );
+	iLog->Log( _L8( "SetResults, ref=%d, object='%S', type='%S'" ), aResultsRef, &ptr, &aType );
+	if ( iResultsFunction )
+		{
+		(this->*iResultsFunction)( aResultsRef, aObject, aType );
+		iResultsFunction = NULL ;
+		}
+	
+	}
+
+
+void Cdmatest::SetStatusL( TInt aStatusRef,
+							 MSmlDmAdapter::TError aErrorCode ) 
+	{
+	iStatus = aErrorCode ;
+	iLog->Log( _L( "SetStatusL, ref=%d, code=%d" ), aStatusRef, aErrorCode );
+	
+	
+	}
+	
+void Cdmatest::SetMappingL( const TDesC8& aURI, const TDesC8& aLUID ) 
+	{
+	iLog->Log( _L8( "SetMappingL, aURI='%s', aLUID='%s'" ), aURI.Ptr(), aLUID.Ptr() );	
+	
+	iMappingTable.Append(TMapping( aURI, aLUID ) )	;
+	}
+	
+HBufC8* Cdmatest::GetLuidAllocL( const TDesC8& aURI ) 
+	{
+	iLog->Log( _L8( "GetLuidAllocL, aURI='%S'" ), &aURI );		
+	HBufC8 *res = NULL;		
+	for( TInt i(0); i < iMappingTable.Count(); i++ )	
+		{
+		if ( aURI == iMappingTable[i].iURI )
+			{
+			res = iMappingTable[i].iLuid.AllocL();
+			}
+		}
+	if ( res == NULL )
+		{
+		res = HBufC8::NewL( 0 );
+		}
+	iLog->Log( _L8( "GetLuidAllocL, response='%S'" ), res );
+	return res;
+	}	    
+    
+HBufC8* Cdmatest::GetLuidAllocLC( const TDesC8& aURI ) 
+	{
+	iLog->Log( _L8( "GetLuidAllocL, aURI='%S'" ), &aURI );
+	HBufC8 *res = NULL;		
+	for( TInt i(0); i < iMappingTable.Count(); i++ )	
+		{
+		if ( aURI == iMappingTable[i].iURI )
+			{
+			res = iMappingTable[i].iLuid.AllocLC();
+			break;
+			}
+		}
+	if ( res == NULL )
+		{
+		res = HBufC8::NewLC( 0 );
+		}
+	iLog->Log( _L8( "GetLuidAllocLC, response='%S'" ), res );
+	return res ;
+	}	
+    	
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    
+void Cdmatest::GetMappingInfoListL( const TDesC8& /*aURI*/,
+								CArrayFix<TSmlDmMappingInfo>& /*aSegmentList*/ )
+	{
+	// do nothing
+	}								
+
+#else
+// nothing
+#endif
+//***************************************************************************
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/src/emailtest.cpp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DM adapter test component
+* 	This is part of omadmextensions/adapter test application.
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "emailTest.h"
+#include <stiflogger.h>
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CemailTest::CemailTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+/*CemailTest::CemailTest( 
+    CTestModuleIf& aTestModuleIf ):
+        CScriptBase( aTestModuleIf )
+    {
+    }*/
+CemailTest::CemailTest( CTestModuleIf& aTestModuleIf )
+		: Cdmatest( aTestModuleIf, KAdapterUid )
+    {
+    }
+// -----------------------------------------------------------------------------
+// CemailTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CemailTest::ConstructL()
+    {
+/*    iLog = CStifLogger::NewL( KamtestLogPath, 
+                          KamtestLogFile,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );*///Commented the Part for emailTest Dipak
+    iLog = CStifLogger::NewL( KamtestLogPath, 
+                          KamtestLogFile,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile );
+                          
+    iLog->Log( _L( "Loading Adapter" ) );
+    
+	Cdmatest::ConstructL();                         	
+
+    }
+
+// -----------------------------------------------------------------------------
+// CemailTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CemailTest* CemailTest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    CemailTest* self = new (ELeave) CemailTest( aTestModuleIf );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    
+    }
+    
+// Destructor
+CemailTest::~CemailTest()
+    { 
+    
+    // Delete resources allocated from test methods
+//    Delete();
+    
+    // Delete logger
+//    delete iLog;  
+    
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL( 
+    CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+    {
+    
+    return ( CScriptBase* ) CemailTest::NewL( aTestModuleIf );
+        
+    }
+
+
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/email/tsrc/src/emailtestBlocks.cpp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,108 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of DM adapter test component
+* 	This is part of omadmextensions/adapter test application.
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include "emailTest.h"
+#include <e32math.h>
+#include <f32file.h>
+#include <swinstapi.h>
+
+
+//using namespace NApplicationManagement;//Dipak
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CemailTest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void CemailTest::Delete() 
+    {
+    
+    }
+    
+// -----------------------------------------------------------------------------
+// CemailTest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CemailTest::RunMethodL( 
+    CStifItemParser& aItem ) 
+    {
+   
+    TStifFunctionInfo const KFunctions[] =
+        {  
+        // Copy this line for every implemented function.
+        // First string is the function name used in TestScripter script file.
+        // Second is the actual implementation member function. 
+        ENTRY( "DDFStructure", CemailTest::DDFStructureL),
+        ENTRY( "FetchNode", CemailTest::FetchNodeL ),
+        ENTRY( "FetchLeaf", CemailTest::FetchLeafL ),
+        ENTRY( "AddNode", CemailTest::AddNodeL ),
+        ENTRY( "UpdateLeaf", CemailTest::UpdateLeafL ),
+        ENTRY( "UpdateLeafData", CemailTest::UpdateLeafDataL ),
+        ENTRY( "Execute", CemailTest::ExecuteLeafL ),
+        ENTRY( "ExecuteData", CemailTest::ExecuteLeafDataL ),
+        ENTRY( "DeleteNode", CemailTest::DeleteObjectL ),
+        ENTRY( "StartAtomic", CemailTest::StartAtomicL),
+	    ENTRY( "CommitAtomic", CemailTest::CommitAtomicL),
+	    ENTRY( "RollbackAtomic", CemailTest::RollbackAtomicL),
+	    ENTRY( "CompleteCommands", CemailTest::CompleteCommandsL),
+        };
+
+    const TInt count = sizeof( KFunctions ) / 
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+
+    }    
+
+        
+        
+HBufC8 *CemailTest::GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName )
+	{
+	TPtrC nodename;
+	nodename.Set( KNullDesC );
+
+    TInt i( aItem.GetNextString ( nodename ) );
+    if ( i != KErrNone ) 
+	    {
+	    iLog->Log( _L( "ERROR Reading '%S' argument: 0x%X" ), &aName, i );
+	    }
+	else
+		{
+		iLog->Log( _L("%S: %S"), &aName, &nodename);
+		}
+	
+	HBufC8 *buf = HBufC8::NewLC( nodename.Length() ) ;
+	buf->Des().Copy( nodename );
+	
+	return buf;
+	}
+	
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/group/bld.inf	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Build information file for project nsmldmbmadapter
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+nsmldmbmadapter.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_TESTEXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/group/nsmldmbmadapter.mmp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Project definition file for project nsmldmbmadapter
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <defaultcaps.hrh>
+
+TARGET                  nsmldmbmadapter.dll
+TARGETTYPE              PLUGIN
+UID                     0x10009d8d 0x101f6d2f
+
+CAPABILITY              CAP_ECOM_PLUGIN
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  nsmldmbmadapter.cpp
+SOURCE                  nsmldmbmsettingstore.cpp
+
+START RESOURCE          nsmldmbmadapter.rss
+END
+
+//LANG sc
+
+USERINCLUDE             ../inc
+
+//Default system include paths for middleware layer modules
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+LIBRARY        euser.lib ecom.lib cmmanagerdatabase.lib cmmanager.lib charconv.lib flogger.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/inc/bmadapterlogger.h	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Logging functions for the component.
+*
+*/
+
+
+
+#ifndef BMADAPTERLOGGER_H
+#define BMADAPTERLOGGER_H
+
+#ifndef _DEBUG
+
+// UREL BUILD:
+#define BMADAPTER_LOGGING_METHOD  0   // No logging in UREL builds
+
+#else
+
+// UDEB BUILD:
+#define BMADAPTER_LOGGING_METHOD  1     // 0 = No logging,
+                                        // 1 = Flogger,
+                                        // 2 = RDebug
+#endif // _DEBUG
+
+
+#if BMADAPTER_LOGGING_METHOD == 1 // Flogger
+
+#include <flogger.h>
+_LIT(KBMADAPTERLOGFolder,"NSMLDMBMADAPTER");
+_LIT(KBMADAPTERLOGFile,"NSMLDMBMADAPTER.txt");
+
+#define BMADAPTERLOGTEXT(x)\
+    {\
+    RFileLogger::Write(KBMADAPTERLOGFolder(),KBMADAPTERLOGFile(),EFileLoggingModeAppend,\
+    x);\
+    }
+
+#define BMADAPTERLOGSTRING(x)\
+    {\
+    _LIT8(tempLogDes,x);\
+    RFileLogger::Write(KBMADAPTERLOGFolder(),KBMADAPTERLOGFile(),EFileLoggingModeAppend,\
+    tempLogDes());\
+    }
+
+#define BMADAPTERLOGSTRING2(x,y)\
+    { _LIT8(tempLogDes,x);\
+    RFileLogger::WriteFormat(KBMADAPTERLOGFolder(),\
+                             KBMADAPTERLOGFile(),\
+                             EFileLoggingModeAppend,\
+                             TRefByValue<const TDesC8>(tempLogDes()),y);\
+    }
+
+#define BMADAPTERLOGSTRING3(x,y,z)\
+    { _LIT8(tempLogDes,x);\
+    RFileLogger::WriteFormat(KBMADAPTERLOGFolder(),\
+                             KBMADAPTERLOGFile(),\
+                             EFileLoggingModeAppend,\
+    TRefByValue<const TDesC8>(tempLogDes()),y,z);\
+    }
+
+#define BMADAPTERLOGSTRING4(w,x,y,z)\
+    { _LIT8(tempLogDes,w);\
+    RFileLogger::WriteFormat(KBMADAPTERLOGFolder(),\
+                             KBMADAPTERLOGFile(),\
+                             EFileLoggingModeAppend,\
+    TRefByValue<const TDesC8>(tempLogDes()),x,y,z);\
+    }
+
+
+#elif BMADAPTER_LOGGING_METHOD == 2    // RDebug
+
+#include <e32svr.h>
+
+#define BMADAPTERLOGSTRING(x) RDebug::Print(x);
+#define BMADAPTERLOGSTRING(x) RDebug::Print(_L(x));
+#define BMADAPTERLOGSTRING2(x,y) RDebug::Print(_L(x),y);
+#define BMADAPTERLOGSTRING3(x,y,z) RDebug::Print(_L(x),y,z);
+#define BMADAPTERLOGSTRING4(w,x,y,z) RDebug::Print(_L(w),x,y,z);
+
+#else // BMADAPTER_LOGGING_METHOD == 0 or invalid
+
+#define BMADAPTERLOGSTRING(x)
+#define BMADAPTERLOGSTRING(x)
+#define BMADAPTERLOGSTRING2(x,y)
+#define BMADAPTERLOGSTRING3(x,y,z)
+#define BMADAPTERLOGSTRING4(w,x,y,z)
+
+#endif // BMADAPTER_LOGGING_METHOD
+
+#endif  // BMADAPTERLOGGER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/inc/nsmldmbmadapter.h	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,887 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Device management adapter handling bearer management related settings
+*
+*/
+
+
+
+
+#ifndef NSMLDMBMADAPTER_H
+#define NSMLDMBMADAPTER_H
+
+#include <smldmadapter.h>
+
+#include "nsmldmbmsettingstore.h"
+
+class CSmlDmBmCommandElement;
+class CSmlDmBmSettingsElement;
+class CNSmlDmBmSettingStore;
+
+/**  The DDF version must be changed if any changes in DDF structure 
+( built in DDFStructureL() function ) */
+_LIT8( KNSmlDmBMAdapterDDFVersion, "1.1" ); 
+_LIT8( KNSmlDmBMAdapterTextPlain, "text/plain" );
+
+/** Names of the nodes */
+/** When updating KNSmlDmBMAdapterBMURI also update 
+KNSmlDmBmAdapterURIMaxLength! */
+_LIT8(KNSmlDmBMAdapterBMURI, "./BearerManagementSNAP");
+_LIT8(KNSmlDmBMAdapterBM, "BearerManagementSNAP");
+_LIT8(KNSmlDmBMAdapterName, "Name");
+_LIT8(KNSmlDmBMAdapterIAPPriorityList, "IAPPriorityList");
+_LIT8(KNSmlDmBMAdapterEmbeddedSNAP, "EmbeddedSNAP");
+_LIT8(KNSmlDmBMAdapterMetadata, "Metadata");
+_LIT8(KNSmlDmBMAdapterProtected, "Protected");
+_LIT8(KNSmlDmBMAdapterHidden, "Hidden");
+
+/** Descriptions of the nodes */
+_LIT8( KNSmlDmBMAdapterBMDescription, 
+       "BearerManagement provides management of Access Point groups (SNAPs)");
+_LIT8( KNSmlDmBMAdapterDynamicDescription, 
+       "Node presents a group of Access Points (SNAP)");
+_LIT8( KNSmlDmBMAdapterNameDescription, 
+       "Name of the Access Point group");
+_LIT8( KNSmlDmBMAdapterIAPPriorityListDescription, 
+       "Comma separated list of Access Point URIs in priority order.");
+_LIT8( KNSmlDmBMAdapterEmbeddedSNAPDescription, 
+       "URI of embedded Access Point group. All Access points of the Embedded \
+       SNAP are seen as also belonging to this SNAP");
+_LIT8( KNSmlDmBMAdapterMetadataDescription, 
+       "32 bit integer representing SNAP metadata. Following bitmasks indicate \
+       meaning of the individual bits: \n 0x00000001 \t Internet: The SNAP is \
+       the Internet SNAP. This may only be set to one SNAP object.\n \
+       0x00000002\tHighlight: SNAP is highlighted in certain UI dialog.\n \
+       0x00000004\tHidden: SNAP is hidden in certain UI dialog.");
+_LIT8( KNSmlDmBMAdapterProtectedDescription, 
+       "SNAP is protected with one of the following protection levels. \
+       Protected object can not be modified without NetworkControl capability \n \
+       0 \t No protection \n 1 \t SNAP and related objects \n \
+       2 \t SNAP name is protected.");
+_LIT8( KNSmlDmBMAdapterHiddenDescription, 
+       "SNAP is set as hidden in the setting store");
+
+/** Leaf nodes of snap node */
+_LIT8( KNSmlDmBMAllLeafNodes, 
+       "Name/IAPPriorityList/Metadata/Protected/Hidden/EmbeddedSNAP");
+_LIT8( KNSmlDmBMAllLeafNodesNoEmbedded, 
+       "Name/IAPPriorityList/Metadata/Protected/Hidden");
+
+/** URI of for fetching IAP nodes */
+/** When updating KNSmlDmBMAdapterIAPURI also update 
+KNSmlDmBmAdapterAPURIMaxLength! */
+_LIT8( KNSmlDmBMAdapterIAPURI, "./AP" );
+/** Node name of AP adapter root */
+_LIT8( KNSmlDmBMAdapterIAPNode, "AP" );
+/** URI segment separator */
+/** When updating this literal also update 
+KNSmlDmBmAdapterAPURIMaxLength and KNSmlDmBmAdapterURIMaxLength! */
+_LIT8( KNSmlDmBmSeparator, "/" );
+/** URI segment separator */
+/** When updating KNSmlDmBMAdapterBMURI also update 
+KNSmlDmBmAdapterAPURIMaxLength and KNSmlDmBmAdapterURIMaxLength! */
+_LIT8( KNSmlDmBmUriListSeparator, "," );
+/** Prefix in URIs (removed for LUID mapping) */
+_LIT8( KNSmlDmBmAdapterURIPrefix, "./" );
+
+/** Name prefix for unnamed snap nodes */
+_LIT8( KNSmlDmBMSNAPNamePrefix, "SNAP" );
+_LIT8( KNSmlDmBMBooleanTrue, "True" );
+_LIT8( KNSmlDmBMBooleanFalse, "False" );
+
+
+const TInt KNSmlDmBMGranularity = 4;
+const TInt KNsmlDmBmSNAPNodeDepth = 2;
+const TInt KNSmlDmBmInvalidRef = -1;
+
+/** Maximum length of snap URI including a separator character in URI List.
+Node is not calculated here. KNSmlDmBMAdapterBMURI + KNSmlDmBmSeparator + 
+KNSmlDmBmUriListSeparator
+*/
+const TInt KNSmlDmBmAdapterURIMaxLength =  24;
+
+/** Maximum length of AP URI including a separator character in URI List.
+Node is not calculated here. KNSmlDmBMAdapterIAPURI + KNSmlDmBmSeparator + 
+KNSmlDmBmUriListSeparator
+*/
+const TInt KNSmlDmBmAdapterAPURIMaxLength = 6;
+
+/** Maximum length of 32bit integer */
+const TInt KMaxLengthOf32bitInteger = 10;
+
+/**
+ *  Bearer Management device management adapter
+ *
+ *  Bearer Management device management adapter manages settings
+ *  related to Service Network Access Points (SNAPs) which are
+ *  used for groupin IAPs
+ *
+ *  @lib nsmldmbmadapter
+ *  @since S60 v3.2
+ */
+class CNSmlDmBmAdapter : public CSmlDmAdapter
+    {
+    
+public:
+
+/** Possible command types */
+enum TCommandType
+    {
+    EAddCmd,
+    EGetCmd,
+    EGetSizeCmd,
+    EDeleteCmd
+    };
+
+    /**
+     * Two-phased constructor.
+     */
+    static CNSmlDmBmAdapter* NewL( MSmlDmCallback* aDmCallback );
+
+    /**
+     * Destructor.
+     */
+    virtual ~CNSmlDmBmAdapter();
+
+
+// from base class CSmlDmAdapter
+
+    /**
+     *  The function returns current version of the DDF. 
+     *
+     *  @since S60 v3.2
+     *  @param aDDFVersion DDF version of the
+     *  adapter. (filled by the adapter) 
+     */
+    void DDFVersionL( CBufBase& aDDFVersion );
+
+    /**
+     *  The function for filling the DDF structure of the adapter
+     *
+     *  @since S60 v3.2
+     *  @param aDDF Reference to root object.
+    */
+    void DDFStructureL( MSmlDmDDFObject& aDDF );
+
+    /**
+     * The function creates new leaf objects, or replaces data in existing 
+     * leaf objects. The information about the success of the command is
+     * returned by calling SetStatusL function of MSmlDmCallback callback
+     * interface. 
+     *     
+     * @since S60 v3.2
+     * @param aURI         URI of the object
+     * @param aLUID        LUID of the object 
+     * @param aObject      Data of the object.
+     * @param aType        MIME type of the object
+     * @param aStatusRef   Reference to correct command, i.e. this reference
+     *                     must be used when calling the SetStatusL of this 
+     *                     command
+    */
+    void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+                            const TDesC8& aObject, const TDesC8& aType,
+                            TInt aStatusRef );
+    /**
+     * The function deletes an object and its child objects. 
+     *
+     * @since S60 v3.2
+     * @param aURI         URI of the object
+     * @param aLUID        LUID of the object (if the adapter have earlier 
+     *                     returned LUID to the DM Module).
+     * @param aStatusRef   Reference to correct command, i.e. this reference 
+     *                     must be used when calling the SetStatusL of this 
+     *                     command.
+    */
+    void DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+                        TInt aStatusRef );
+
+    /**
+     * The function fetches data of a leaf object. The SetStatusL is used
+     * as described in UpdateLeafObjectL(). The data is returned by using the
+     * SetResultsL function of MSmlCallback callback interface.
+     *
+     * @since S60 v3.2
+     * @param aURI             URI of the object
+     * @param aLUID            LUID of the object (if the adapter have 
+     *                         earlier returned LUID to the DM Module). 
+     * @param aType            MIME type of the object
+     * @param aResultsRef      Reference to correct results, i.e. this 
+     *                         reference must be used when returning the 
+     *                         result by calling the SetResultsL.
+     * @param aStatusRef       Reference to correct command, i.e. this 
+     *                         reference must be used when calling the 
+     *                         SetStatusL of this command.
+    */
+    void FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+                           const TDesC8& aType, TInt aResultsRef,
+                           TInt aStatusRef );
+
+    /**
+     * The function fetches the size of the data of a leaf object. The size 
+     * is in bytes, and must reflect the number of bytes that will be 
+     * transferred when the framework calls FetchLeafObjectL. 
+     *
+     * @since S60 v3.2
+     * @param aURI             URI of the object
+     * @param aLUID            LUID of the object (if the adapter have 
+     *                         earlier returned LUID to the DM Module).   
+     * @param aType            MIME type of the object
+     * @param aResultsRef      Reference to correct results, i.e. this 
+     *                         reference must be used when returning the 
+     *                         result by calling the SetResultsL.
+     * @param aStatusRef       Reference to correct command, i.e. this 
+     *                         reference must be used when calling the 
+     *                         SetStatusL of this command.
+    */
+    void FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID,
+                               const TDesC8& aType, TInt aResultsRef,
+                               TInt aStatusRef );
+
+    /**
+     * The function fetches URI list. An adapter returns the list of URI 
+     * segments under the given URI be separated by slash ("/"). The URI 
+     * segment names for new objects must be given by the adapter.
+     * The list is returned by calling the SetResultsL function of 
+     * MSmlCallback callback interface. 
+     *
+     * @since S60 v3.2
+     * @param aURI                     URI of the parent object
+     * @param aLUID                    LUID of the parent object (if the
+     *                                 adapter have earlier returned LUID to
+     *                                 the DM Module).   
+     * @param aPreviousURISegmentList  URI list with mapping LUID 
+     *                                 information, which is known by DM
+     *                                 engine.  
+     * @param aResultsRef              Reference to correct results, i.e. 
+     *                                 this reference must be used when 
+     *                                 returning the result by calling the 
+     *                                 SetResultsL.
+     * @param aStatusRef               Reference to correct command, i.e. 
+     *                                 this reference must be used when 
+     *                                 calling the SetStatusL of this 
+     *                                 command.
+    */
+    void ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID,
+                        const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
+                        TInt aResultsRef, TInt aStatusRef );
+
+    /**
+     * The function adds node object. 
+     *
+     * @since S60 v3.2
+     * @param aURI             URI of the object
+     * @param aParentLUID      LUID of the parent object (if the adapter have
+     *                         earlier returned LUID to the DM Module).   
+     * @param aStatusRef       Reference to correct command, i.e. this 
+     *                         reference must be used when calling the 
+     *                         SetStatusL of this command.
+    */
+    void AddNodeObjectL( const TDesC8& aURI, const TDesC8& aParentLUID,
+                         TInt aStatusRef );
+    /**
+     * The adapter does not support streaming and no implementation is 
+     * provided for this function.
+     *
+     * @since S60 v3.2
+     * @param aURI         URI of the object
+     * @param aLUID        LUID of the object
+     * @param aStream      Data of the object. 
+     * @param aType        MIME type of the object
+     * @param aStatusRef   Reference to correct command, i.e. this reference
+     *                     must be used when calling the SetStatusL of this
+     *                     command.
+    */
+    void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+                            RWriteStream*& aStream, const TDesC8& aType,
+                            TInt aStatusRef );
+    /**
+     * The adapter does not support execute command and does not 
+     * provide implementation for this function. 
+     *
+     *  @since S60 v3.2
+     * @param aURI             URI of the command
+     * @param aLUID            LUID of the object
+     * @param aArgument        Argument for the command
+     * @param aType            MIME type of the object 
+     * @param aStatusRef       Reference to correct command, i.e. this 
+     *                         reference must be used when calling the 
+     *                         SetStatusL of this command.
+    */
+    void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, 
+                          const TDesC8& aArgument, const TDesC8& aType, 
+                          TInt aStatusRef );
+    /**
+     * The adapter does not support execute command and does not 
+     * provide implementation for this function. 
+     *
+     * @since S60 v3.2
+     * @param aURI         URI of the command
+     * @param aLUID            LUID of the object 
+     * @param aStream      Argument for the command. 
+     * @param aType            MIME type of the object 
+     * @param aStatusRef       Reference to correct command, i.e. this 
+     *                         reference must be used when calling the 
+     *                         SetStatusL of this command.
+    */
+    void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID,
+                          RWriteStream*& aStream, const TDesC8& aType,
+                          TInt aStatusRef );
+    /**
+     * The adapter does not support copy command and does not 
+     * provide implementation for this function. 
+     *
+     * @since S60 v3.2
+     * @param aTargetURI       Target URI for the command
+     * @param aTargetLUID      LUID of the target object 
+     * @param aSourceURI       Source URI for the command
+     * @param aSourceLUID      LUID of the source object 
+     * @param aType            MIME type of the objects
+     * @param aStatusRef       Reference to correct command, i.e. this 
+     *                         reference must be used when calling the 
+     *                         SetStatusL of this command.
+    */
+    void CopyCommandL( const TDesC8& aTargetURI, const TDesC8& aTargetLUID, 
+                       const TDesC8& aSourceURI, const TDesC8& aSourceLUID, 
+                       const TDesC8& aType, TInt aStatusRef );
+    /**
+     * Not supported
+     *  @since S60 v3.2
+    */
+    void StartAtomicL();
+    /**
+     * Not Supported     
+     *  @since S60 v3.2
+     *
+    */
+    void CommitAtomicL();
+    /**
+     * Not supported.
+     *  @since S60 v3.2
+     */
+    void RollbackAtomicL();
+    /**
+     * Returns EFalse as the adapter does not support streaming
+     *
+     * @since S60 v3.2
+     * @param aItemSize size limit for stream usage
+     * @return TBool EFalse as streaming is not supported
+    */
+    TBool StreamingSupport( TInt& aItemSize );
+    /**
+     * Not supported
+     *
+     *  @since S60 v3.2
+    */  
+    void StreamCommittedL();
+    /**
+     * The function tells the adapter that all the commands of the message 
+     * that can be passed to the adapter have now been passed.  This 
+     * indciates that the adapter must supply status codes and results to 
+     * any buffered commands. This must be done at latest by the time this 
+     * function returns. This function is used at the end of SyncML messages, 
+     * and during processing of Atomic.  
+     *
+     *  @since S60 v3.2
+    */
+    void CompleteOutstandingCmdsL();
+    
+    /**
+     * Function checks if a SNAP with the argument URI is buffered for 
+     * later handling. If so, the function calls iSettingStore object 
+     * to store the SNAP. This function is called by the iSettingStore 
+     * object to check whether EmbeddedSNAP node referenced by a command is 
+     * still in the buffer and needs to be stored first.
+     *
+     * @since S60 v3.2
+     * @param aURI Descriptor containing the SNAP URI
+     */    
+    void StoreSnapIfBufferedL( const TDesC8& aURI );
+
+
+    /**
+     * Function returns a pointer to a HBufC object containing  a SNAP URI 
+     * which correcponds to the argument LUID.
+     *
+     * @since S60 v3.2
+     * @param aSnapId LUID of SNAP object
+     * @return Descriptor containing the SNAP URI. 
+     */    
+    HBufC8* GetSnapUriFromLuidL( const TUint aSnapId );
+
+
+    /**
+     * Function returns a pointer to HBufC object containing a 
+     * comma separated list of IAP URIs according to the IAP LUIDs
+     * contained in the argument array.
+     *
+     * @since S60 v3.2
+     * @param aIdArray Array of IAP LUIDs for which the URI list is formed.
+     * @return HBufC object containing a comma separated list of IAP URIs
+     */
+    HBufC8* GetIapListL( const RArray<TUint>& aIdArray );
+
+
+    /**
+     * Function returns an array containing the LUIDs of IAP URIs listed in 
+     * argument descriptor. 
+     *
+     *  @since S60 v3.2
+     * @param aIAPList TDesC object containing a comma separated list of IAP
+     *  URIs
+     * @return Array of IAP LUIDs that correspond to the argument URI list. 
+     */    
+    RArray<TUint> GetIdArrayL( const TDesC8& aIAPList);
+
+    
+    /**
+     * Converts integer to 8bit descriptor
+     *
+     *  @since S60 v3.2
+     * @param    aLuid The integer to be converted
+     * @return    The Integer as a descriptor
+     */
+    HBufC8* IntToDes8L( TInt aLuid) const;
+
+    /**
+     * Converts 8bit descriptor to integer
+     *
+     *  @since S60 v3.2
+     * @param    aLuid The descriptor to be converted
+     * @return    Integer value of the descriptor
+     */
+    TUint DesToIntL(const TDesC8& aLuid) const;
+
+    /**
+     * Converts 8bit descriptor to a boolean value
+     * @since S60 v3.2
+     * @param aBoolDes The descriptor to be converted
+     * @param aBool A pointer to a boolean where result is stored
+     * @return ETrue if conversion was succesful, otherwise EFalse
+     */
+    TBool DesToBool(const TDesC8& aBoolDes, TBool& aBool ) const;
+
+    /**
+     * Converts boolean value to 8bit descriptor
+     * @since S60 v3.2
+     * @param    aBool The boolean value to be converted
+     * @return    The boolean value as a descriptor
+     */
+    HBufC8* BoolToDes8LC( TBool aBool) const;
+
+
+    /**
+     * The function calls the GetLuidAllocL function of the MSmlDmCallback to 
+     * get the LUID which is mapped to aURI. This function LUID is not found,  
+     * the function allocates a null length string, i.e. the function
+     * allocates memory in every case.
+     * @since S60 v3.2
+     * @param aURI  URI of the object. 
+     */
+    HBufC8* GetLuidAllocL( const TDesC8& aURI );
+
+private:
+
+     /**
+     * Constructor
+     */
+    CNSmlDmBmAdapter();
+
+    /**
+     * Constructor
+     * @param aDmCallback Callback object to the framework
+     */
+    CNSmlDmBmAdapter( MSmlDmCallback* aDmCallback );
+
+    /**
+     * Second phase constructor
+     */
+    void ConstructL();
+    
+    
+    /**
+     * Searches the buffer for a SNAP with the parameter mapping name 
+     * @param aMappingName Mapping Name of this SNAP
+     * @return Pointer to the CSmlDmBmSettingsElement object in buffer. 
+     * The object is owned by the CNSmlDmBmAdapter.  
+     */
+     CSmlDmBmSettingsElement* GetSnapIfBuffered( const TDesC8& aMappingName);
+     
+    /**
+     * Returns the first URI from a list of URIs
+     * @param  aURIList Comma separated list of URIs
+     * @return    The first URI
+     */
+     TPtrC8 FirstURI(const TDesC8& aURIList) const;
+    
+    /**
+     * Returns the number of URIs in a list of URIs
+     * @param aURIList Comma-separated list of URIs
+     * @return Number of URIs in the list.  
+     */
+    TInt NumOfURIs(const TDesC8& aURIList) const;
+
+
+    /**
+     * Removes the first URI from a list of URIs
+     * @param  aURIList Comma separated list of URIs
+     * @return    The first URI
+     */
+     TPtrC8 RemoveFirstURI(const TDesC8& aURI) const;
+
+    /**
+     * Parses the last URI segment from URI
+     * @param    aURI The whole URI
+     * @return    The last URI segment
+     */
+    TPtrC8 LastURISeg(const TDesC8& aURI) const; 
+
+    /**
+     * Removes the last URI segment from URI
+     * @param    aURI The whole URI
+     * @return    The aURI without the last URI segment
+     */
+    TPtrC8 RemoveLastURISeg(const TDesC8& aURI) const;
+
+    /**
+     * Calculates the number of URI segments
+     * @param    aURI The whole URI
+     * @return    The number of URI segments
+     */
+    TInt NumOfURISegs(const TDesC8& aURI) const;
+
+    /**
+     * Checks if the URI refers to predefined SNAP (of format SNAPx) in which
+     * case operations should be successful even if passed LUID is empty.
+     * Maps the URI to found id.
+     * @param    aURI The whole URI
+     * @param    aLUID LUID
+     * @return    The SNAP ID if found
+     */
+    TInt MapPredefinedSnapsL( const TDesC8& aURI, const TDesC8& aLUID );
+    
+    /**
+     * Tries to find predefined URI string (SNAPx) fronm input
+     * returns the ID.
+     * @param    aURI The whole URI    
+     * @return    The SNAP ID if found
+     */
+    TInt GetPredefinedSnapIdFromUri( const TDesC8& aURI ) const;
+
+private: //data
+
+    /**
+     * Buffered commands. Contains a CSmlDmBmSettingsElement object 
+     * for each SNAP. THese in turn contain commands for the SNAP.
+     */
+    RPointerArray<CSmlDmBmSettingsElement> iBuffer;
+    
+    /**
+     * Setting store object, which is called for managing settings 
+     * in CommsDat. Own.
+     */
+     CNSmlDmBmSettingStore * iSettingStore;
+     
+     /**
+      * CmManager object for SNAP existence checking for
+      * direct accesses to pre-defined SNAPs    
+      */
+     RCmManagerExt iCmManagerExt;
+        
+    };
+
+
+/**
+ *  CSmlDmBmCommandElement 
+ *
+ * Helper class, which stores a single buffered command for a SNAP. 
+ *  @lib nsmldmbmadapter
+ *  @since S60 v3.2
+ */
+
+class CSmlDmBmCommandElement : public CBase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     */
+    static CSmlDmBmCommandElement* NewLC( TBool aLeaf, 
+                                          TInt aStatusRef, 
+                                          TInt aResultRef, 
+                                          CNSmlDmBmAdapter::TCommandType  aCmdType, 
+                                          const TDesC8& aLastUriSeg, 
+                                          const TDesC8& aData );
+
+    /**
+     * Destructor.
+     */
+     ~CSmlDmBmCommandElement();
+
+    /**
+     * Returns the iExecuted member value of the object
+     *
+     * @since S60 v3.2
+     * @return The iExecuted member value of the object
+     */
+    inline TBool Executed();
+
+    /**
+     * Sets the iExecuted member value of the object
+     *
+     * @since S60 v3.2
+     * @param aExecuted Executed value for the object. 
+     */    
+    inline void SetExecuted( TBool aExecuted );
+    
+    /**
+     * Returns the iStatus member value of the object
+     *
+     * @since S60 v3.2
+     * @return The iStatus value of the object
+     */
+    inline CSmlDmAdapter::TError Status();
+    
+    /**
+     * Sets the iStatus member value of the object
+     *
+     * @since S60 v3.2
+     * @param aStatus Status value for the object. 
+     */    
+    inline void SetStatus( CSmlDmAdapter::TError aStatus ); 
+    
+    /**
+     * Returns the iLeaf member value of the object
+     *
+     * @since S60 v3.2
+     * @return The iLeaf member value of the object
+     */
+    inline TBool Leaf();
+    
+    /**
+     * Returns the iStatusRef member value of the object
+     *
+     * @since S60 v3.2
+     * @return The iStatusRef member value of the object
+     */
+    inline TInt StatusRef();
+    
+    /**
+     * Returns the iResultRef member value of the object
+     *
+     * @since S60 v3.2
+     * @return The iResultRef member value of the object
+     */
+    inline TInt ResultRef();
+    
+    /**
+     * Returns the iCmdType member value of the object
+     *
+     * @since S60 v3.2
+     * @return The iCmdType member value of the object
+     */
+    inline CNSmlDmBmAdapter::TCommandType  CmdType();
+    
+    /**
+     * Returns the iData member value of the object
+     *
+     * @since S60 v3.2
+     * @return The iData member value of the object
+     */
+    inline const HBufC8* Data();
+    
+    /**
+     * Returns the iLastUriSeg member value of the object
+     *
+     * @since S60 v3.2
+     * @return The iLastUriSeg member value of the object
+     */
+    inline const HBufC8* LastUriSeg();
+    
+    /**
+     * Sets the iData member value of the object
+     *
+     * @since S60 v3.2
+     * @param aData Data set to the object. The data will be owned by 
+     * the command object. 
+     */   
+    inline void SetDataL( const TDesC8& aData );
+
+private:
+
+    CSmlDmBmCommandElement( TBool aLeaf, 
+                            TInt aStatusRef, 
+                            TInt aResultRef, 
+                            CNSmlDmBmAdapter::TCommandType aCmdType );
+
+    void ConstructL( const TDesC8& aLastUriSeg, const TDesC8& aData );
+
+    
+private: //data
+
+    /**
+     * Has command been executed. 
+     * Set to ETrue when command is executed.
+     */
+    TBool iExecuted;
+    
+    /**
+     * The execution status of an exeuted command. 
+     * Filled in when command is executed.
+     */    
+    CSmlDmAdapter::TError iStatus;
+    
+    
+    /**
+     * True if commend is for a leaf node, False if it is for a Snap node.
+     */    
+    const TBool iLeaf;
+    
+    /**
+     * Reference for returning the status to DM framework.
+     */    
+    const TInt iStatusRef;
+    
+    /**
+     * Reference for returning result of Get command to the DM framework.
+     */    
+    const TInt iResultRef;
+    
+    /**
+     * Type of command.
+     */    
+    const CNSmlDmBmAdapter::TCommandType  iCmdType;
+    
+
+    /**
+     * Data which is either ment to be stored to setting store 
+     * or which has been fetched from there. 
+     */
+    HBufC8* iData;
+
+    /**
+     * Last segment in the command URI, which indicates the leaf node 
+     * in question. For non leaf command empty string. 
+     */    
+    HBufC8* iLastUriSeg;
+
+    };
+
+
+/**
+ *  CSmlDmBmSettingsElement
+ *
+ * Helper class which stores information of a single SNAP object 
+ * into buffer. Contains the buffered commands for the 
+ * SNAP as a list of CSmlBmCommandElement objects.
+ *
+ *  @lib nsmldmbmadapter
+ *  @since S60 v3.2
+ */
+
+class CSmlDmBmSettingsElement : public CBase
+    {
+ 
+public:
+
+    /**
+     * Two-phased constructor.
+     */
+     static CSmlDmBmSettingsElement* NewLC( const TDesC8& aMappingName );
+    
+    /**
+     * Destructor.
+     */
+    ~CSmlDmBmSettingsElement();
+     
+    /**
+     * Returns a reference to iNodeBuf member.  
+     * @since S60 v3.2
+     * @return Reference to iNodeBuf member of the object
+     */
+    inline RPointerArray<CSmlDmBmCommandElement>& NodeBuf(); 
+
+    /**
+     * Returns the iMappingName member value.  
+     * @since S60 v3.2
+     * @return The iMappingName member value of the object
+     */
+    inline const HBufC8* MappingName();
+
+    /**
+     * Returns the iExecuted member value.  
+     * @since S60 v3.2
+     * @return The iExecuted member value of the object
+     */
+    inline TBool Executed();
+    
+    /**
+     * Sets the iExecuted member value.  
+     * @since S60 v3.2
+     * @param aExecuted Value for the iExecuted member of the object
+     */
+    inline void SetExecuted( TBool aExecuted );
+
+    /**
+     * Returns the iLuid member value.  
+     * @since S60 v3.2
+     * @return The iLuid member value of the object
+     */
+    inline TInt Luid();
+    
+    /**
+     * Sets the iLuid member value.  
+     * @since S60 v3.2
+     * @param aLuid Value for the iLuid member of the object
+     */
+    inline void SetLuid( TInt aLuid );
+    
+        
+private:
+
+    CSmlDmBmSettingsElement();
+
+    void ConstructL( const TDesC8& aMappingName );
+
+private: //data
+
+    /**
+     * Buffer of commands for this SNAP object. Commands 
+     * are added as they come in from the framework and 
+     * executed by the setting store.
+     */
+    RPointerArray<CSmlDmBmCommandElement> iNodeBuf;
+
+    /**
+     * Indicates whether commands for this SNAP have been executed. 
+     * Set to Erue by CNsmlDmBmSettingStore when object is handled.
+     */    
+    TBool iExecuted;
+    
+    /**
+     * LUID (Local UID) is the CommsDat id of the SNAP node. This is 
+     * filled in when SNAP object is created in CommsDat. 
+     */
+    TInt iLuid;
+
+    /**
+     * Mapping name of this SNAP node. This is mapped to the 
+     * iLuid when the Snap is created and has id. 
+     */
+    HBufC8* iMappingName;
+    };
+
+#include "nsmldmbmadapter.inl"
+
+#endif // NSMLDMBMADAPTER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/inc/nsmldmbmadapter.inl	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Contains implementations of inline functions
+*
+*/
+
+
+
+// -----------------------------------------------------------------------------
+// Returns the iExecuted member of the object
+// -----------------------------------------------------------------------------
+//
+TBool CSmlDmBmCommandElement::Executed()
+    {
+    return iExecuted;
+    }
+
+// -----------------------------------------------------------------------------
+// Returns the iStatus member of the object
+// -----------------------------------------------------------------------------
+//
+CSmlDmAdapter::TError CSmlDmBmCommandElement::Status()
+    {
+    return iStatus;
+    }
+    
+// -----------------------------------------------------------------------------
+// Returns the iLeaf member of the object
+// -----------------------------------------------------------------------------
+//
+TBool CSmlDmBmCommandElement::Leaf()
+    {
+    return iLeaf;
+    }
+    
+// -----------------------------------------------------------------------------
+// Returns the iStatusRef member of the object
+// -----------------------------------------------------------------------------
+//
+TInt CSmlDmBmCommandElement::StatusRef()
+    {
+    return iStatusRef;    
+    }
+    
+// -----------------------------------------------------------------------------
+// Returns the iResultRef member of the object
+// -----------------------------------------------------------------------------
+//
+TInt CSmlDmBmCommandElement::ResultRef()
+    {
+    return iResultRef;
+    }
+    
+// -----------------------------------------------------------------------------
+// Returns the iCmdType member of the object
+// -----------------------------------------------------------------------------
+//
+CNSmlDmBmAdapter::TCommandType  CSmlDmBmCommandElement::CmdType()
+    {
+    return iCmdType;
+    }
+    
+// -----------------------------------------------------------------------------
+// Returns the iData member of the object
+// -----------------------------------------------------------------------------
+//
+const HBufC8* CSmlDmBmCommandElement::Data()
+    {
+    return iData;
+    }
+    
+// -----------------------------------------------------------------------------
+// Returns the iLastUriSeg member of the object
+// -----------------------------------------------------------------------------
+//
+const HBufC8* CSmlDmBmCommandElement::LastUriSeg()
+    {
+    return iLastUriSeg;
+    }
+    
+// -----------------------------------------------------------------------------
+// Sets the iExecuted member of the object
+// -----------------------------------------------------------------------------
+//
+void CSmlDmBmCommandElement::SetExecuted( TBool aExecuted )
+    {
+    iExecuted = aExecuted;
+    }
+
+// -----------------------------------------------------------------------------
+// Sets the iStatus member of the object
+// -----------------------------------------------------------------------------
+//
+void CSmlDmBmCommandElement::SetStatus( CSmlDmAdapter::TError aStatus )
+    {
+    iStatus = aStatus;
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// Sets the iData member of the object. Ownership of aData argument will be 
+// transfered to the CSmlDmBmCommandElement
+// -----------------------------------------------------------------------------
+//
+void CSmlDmBmCommandElement::SetDataL( const TDesC8& aData )
+    {  
+    if ( aData.Length() > iData->Length() )
+        {
+        iData = iData->ReAllocL( aData.Length() );
+        }
+    *iData = aData;
+    }
+
+//Function definitions for CSmlDmBmSettingsElement
+// -----------------------------------------------------------------------------
+// Returns reference to iNodeBuf
+// -----------------------------------------------------------------------------
+RPointerArray<CSmlDmBmCommandElement>& CSmlDmBmSettingsElement::NodeBuf()
+    {
+    return iNodeBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// Returns iMappingName
+// -----------------------------------------------------------------------------
+const HBufC8* CSmlDmBmSettingsElement::MappingName()
+    {
+    return iMappingName;
+    }
+
+// -----------------------------------------------------------------------------
+// Returns iExecuted
+// -----------------------------------------------------------------------------
+TBool CSmlDmBmSettingsElement::Executed()
+    {
+    return iExecuted;
+    }
+    
+// -----------------------------------------------------------------------------
+// Sets the iExecuted member value
+// -----------------------------------------------------------------------------
+void CSmlDmBmSettingsElement::SetExecuted( TBool aExecuted )
+    {
+    iExecuted = aExecuted;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Returns iLuid
+// -----------------------------------------------------------------------------
+TBool CSmlDmBmSettingsElement::Luid()
+    {
+    return iLuid;
+    }
+    
+// -----------------------------------------------------------------------------
+// Sets the iExecuted member value
+// -----------------------------------------------------------------------------
+void CSmlDmBmSettingsElement::SetLuid( TInt aLuid )
+    {
+    iLuid = aLuid;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/inc/nsmldmbmsettingstore.h	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,218 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   The class manages snap data in Commsdat using CMManager
+*
+*/
+
+
+
+
+#ifndef NSMLDMBMSETTINGSTORE_H
+#define NSMLDMBMSETTINGSTORE_H
+
+#include <cmmanagerext.h>
+
+#include "nsmldmbmadapter.h"
+
+const TInt KShift8 = 8;
+
+class CNSmlDmBmAdapter;
+class CSmlDmBmCommandElement;
+class CSmlDmBmSettingsElement;
+
+/**
+ *  Setting Store is used for managing settings in CommsDat
+ *
+ *  The class provides functions for executing commands 
+ *  and sets of commands that involve manipulation of 
+ *  data in CommsDat. 
+ *
+ *  @lib nsmldmbmadapter
+ *  @since S60 v3.2
+ */
+class CNSmlDmBmSettingStore : public CBase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     */
+    static CNSmlDmBmSettingStore * NewL( CNSmlDmBmAdapter* aAdapter );
+
+    /**
+     * Destructor.
+     */
+    virtual ~CNSmlDmBmSettingStore();
+
+
+    /**
+     * Executes all commands for the argument snap object.
+     * Executed commands are set as executed and status is filled 
+     * in. For Get commands also fetched data is filled in the command.
+     *
+     * @since S60 v3.2
+     * @param aSettings Settings object for the SNAP, contains all 
+     * commands to be executed for the SNAP
+     */
+    void StoreSnapL( CSmlDmBmSettingsElement& aSettings );
+
+    
+    /**
+     * Executes the argument command. Checks the node from 
+     * for which the command is intended and calls node specific functions.
+     *
+     * @since S60 v3.2
+     * @param aCmd Command to be executed
+     * @param aLuid LUID of the SNAP which command is referring.
+     */
+     void ExecuteCmdL( CSmlDmBmCommandElement& aCmd, TUint aLuid);
+
+    /**
+     * Fetches all SNAPs and inserts id of each SNAp into the argument array
+     *
+     * @since S60 v3.2
+     * @param aLUIDArray Array for SNAP ids
+     */
+    void GetSnapsL( RArray<TUint32>& aLUIDArray );
+ 
+private:
+
+    CNSmlDmBmSettingStore( CNSmlDmBmAdapter * aAdapter );
+
+    void ConstructL();
+
+//----------- Commands for managing leaf nodes -------------------//
+
+    /**
+     * Executes snap commands. The valid commands include 
+     * get and delete. With get commands the iData 
+     * memeber is used to pass fetched data back to caller. 
+     * After execution of command the function fills in the status 
+     * in aCmd.iStatus memeber and sets aCmd.iExecuted as True. The function
+     * leaves if command can not be executed for some reason. 
+     *
+     * @param aCmd The command to be executed
+     * @param aLuid The id of the snap
+     */
+    void ExecuteSnapCmdL( CSmlDmBmCommandElement& aCmd, TUint aLuid );
+
+    /**
+     * Executes iap list commands. The valid commands include 
+     * update and get. With update commands data is read from the 
+     * iData memeber of the argument command. With get commands the iData 
+     * memeber is used to pass fetched data back to caller. 
+     * After execution of command the function fills in the status 
+     * in aCmd.iStatus memeber and sets aCmd.iExecuted as True. The function
+     * leaves if command can not be executed for some reason. 
+     *
+     * @param aCmd The command to be executed
+     * @param aSnap The snap object
+     */
+    void ExecuteIapsCmdL( CSmlDmBmCommandElement& aCmd, 
+                          RCmDestinationExt& aSnap );
+
+    /**
+     * Executes protection commands. The valid commands include 
+     * update and get. With update commands data is read from the 
+     * iData memeber of the argument command. With get commands the iData 
+     * memeber is used to pass fetched data back to caller. 
+     * After execution of command the function fills in the status 
+     * in aCmd.iStatus memeber and sets aCmd.iExecuted as True. The function
+     * leaves if command can not be executed for some reason. 
+     *
+     * @param aCmd The command to be executed
+     * @param aSnap The snap object
+     */
+    void ExecuteProtectionCmdL( CSmlDmBmCommandElement& aCmd, 
+                                RCmDestinationExt& aSnap );
+
+    /**
+     * Executes hidden commands. The valid commands include 
+     * update and get. With update commands data is read from the 
+     * iData memeber of the argument command. With get commands the iData 
+     * memeber is used to pass fetched data back to caller. 
+     * After execution of command the function fills in the status 
+     * in aCmd.iStatus memeber and sets aCmd.iExecuted as True. The function
+     * leaves if command can not be executed for some reason. 
+     *
+     * @param aCmd The command to be executed
+     * @param aSnap The snap object
+     */
+    void ExecuteHiddenCmdL( CSmlDmBmCommandElement& aCmd, 
+                            RCmDestinationExt& aSnap );
+
+    /**
+     * Executes metadata commands. The valid commands include 
+     * update and get. With update commands data is read from the 
+     * iData memeber of the argument command. With get commands the iData 
+     * memeber is used to pass fetched data back to caller. 
+     * After execution of command the function fills in the status 
+     * in aCmd.iStatus memeber and sets aCmd.iExecuted as True. The function
+     * leaves if command can not be executed for some reason. 
+     *
+     * @param aCmd The command to be executed
+     * @param aSnap The snap object
+     */
+    void ExecuteMetadataCmdL( CSmlDmBmCommandElement& aCmd, 
+                              RCmDestinationExt& aSnap );
+
+    /**
+     * Executes embedded snap commands. The valid commands include 
+     * update, get and delete. With update commands data is read from the 
+     * iData memeber of the argument command. With get commands the iData 
+     * memeber is used to pass fetched data back to caller. 
+     * After execution of command the function fills in the status 
+     * in aCmd.iStatus memeber and sets aCmd.iExecuted as True. The function
+     * leaves if command can not be executed for some reason. 
+     *
+     * @param aCmd The command to be executed
+     * @param aLuid The id of the snap
+     */
+    void ExecuteEmbeddedSnapCmdL( CSmlDmBmCommandElement& aCmd, 
+                                  RCmDestinationExt& aSnap );
+    /**
+     * Executes name commands. The valid commands include 
+     * update and get. With update commands data is read from the 
+     * iData memeber of the argument command. With get commands the iData 
+     * memeber is used to pass fetched data back to caller. 
+     * After execution of command the function fills in the status 
+     * in aCmd.iStatus memeber and sets aCmd.iExecuted as True. The function
+     * leaves if command can not be executed for some reason. 
+     *
+     * @param aCmd The command to be executed
+     * @param aSnap The snap object
+     */
+    void ExecuteNameCmdL( CSmlDmBmCommandElement& aCmd, 
+                          RCmDestinationExt& aSnap );
+
+
+private: //data
+
+    /**
+     * CmManager is used for accessing CommsDat.
+     */
+     RCmManagerExt iCmManagerExt;
+     
+    /**
+     * Pointer to the adapter. This is used for 
+     * querying data from DM framework when necessary
+     * and using helper functions. Not own.
+     */ 
+    CNSmlDmBmAdapter* iAdapter;
+
+  };
+
+
+#endif // NSmlDmBmSettingStore_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/rom/nsmldmbmadapter.iby	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Image description file for project nsmldmbmadapter
+*
+*/
+
+
+
+#ifndef NSMLDMBMADAPTER_IBY
+#define NSMLDMBMADAPTER_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+
+#ifdef __SYNCML_DM
+
+ECOM_PLUGIN( nsmldmbmadapter.dll, nsmldmbmadapter.rsc )
+
+#endif // __SYNCML_DM
+
+#endif // NSMLDMBMADAPTER_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/src/nsmldmbmadapter.cpp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,1675 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Bearer management DM adapter. Provides handling of 
+                Bearer management related settings in Device management
+*
+*/
+
+
+
+#include <ecom/implementationproxy.h>
+#include <cmdestinationext.h>
+
+#include "nsmldmbmadapter.h"
+#include "bmadapterlogger.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// --------------------------------------------------------------------------
+// Maps plugin UID to its factory function (constructor)
+// --------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(0x101f6d2f, 
+                               CNSmlDmBmAdapter::NewL)
+    };
+
+// --------------------------------------------------------------------------
+// For ecom plugin implementation
+// -------------------------------------------------------------------------
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::NewL
+// --------------------------------------------------------------------------
+CNSmlDmBmAdapter* CNSmlDmBmAdapter::NewL( MSmlDmCallback* aDmCallback )
+    {
+    BMADAPTERLOGSTRING("CNSmlDmBmAdapter::NewL: Start")
+    CNSmlDmBmAdapter* self = new (ELeave) CNSmlDmBmAdapter( aDmCallback );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    BMADAPTERLOGSTRING("CNSmlDmBmAdapter::NewL: End")
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::CNSmlDmBmAdapter
+// --------------------------------------------------------------------------
+
+CNSmlDmBmAdapter::CNSmlDmBmAdapter( MSmlDmCallback* aDmCallback ) 
+    : CSmlDmAdapter( aDmCallback )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::ConstructL
+// --------------------------------------------------------------------------
+void CNSmlDmBmAdapter::ConstructL()
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::CNSmlDmBmAdapter: Start" )
+    iSettingStore = CNSmlDmBmSettingStore::NewL( this );
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::CNSmlDmBmAdapter: End" )
+    }
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::~CNSmlDmBmAdapter
+// --------------------------------------------------------------------------
+CNSmlDmBmAdapter::~CNSmlDmBmAdapter()
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::~CNSmlDmBmAdapter: Start" )
+    iBuffer.ResetAndDestroy();
+    iBuffer.Close();
+    delete iSettingStore;
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::~CNSmlDmBmAdapter: End" )
+    }
+    
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::DDFVersionL
+// Returns ddf version nr
+// --------------------------------------------------------------------------
+void CNSmlDmBmAdapter::DDFVersionL( CBufBase& aDDFVersion )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::DDFVersionL: Start" )
+    aDDFVersion.InsertL( 0, KNSmlDmBMAdapterDDFVersion );
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::DDFVersionL:End" )
+    }
+   
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::DDFStructureL
+//  Constructs the DDF structure
+// --------------------------------------------------------------------------
+void CNSmlDmBmAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::DDFStructureL: Start" )
+    TSmlDmAccessTypes accessTypes;
+
+    // BearerManagementSNAP
+    MSmlDmDDFObject& bm = aDDF.AddChildObjectL( KNSmlDmBMAdapterBM );
+    accessTypes.SetGet();
+    accessTypes.SetAdd();
+    bm.SetAccessTypesL( accessTypes );
+    bm.SetOccurenceL( MSmlDmDDFObject::EOne );
+    bm.SetScopeL( MSmlDmDDFObject::EPermanent );
+    bm.SetDFFormatL( MSmlDmDDFObject::ENode );
+    bm.AddDFTypeMimeTypeL( KNSmlDmBMAdapterTextPlain );
+    bm.SetDescriptionL( KNSmlDmBMAdapterBMDescription );
+    accessTypes.Reset();
+
+    
+    // BearerManagementSNAP/<X>
+    MSmlDmDDFObject& dynamic1 = bm.AddChildObjectGroupL();
+    accessTypes.SetAdd();
+    accessTypes.SetDelete();
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    dynamic1.SetAccessTypesL( accessTypes );
+    dynamic1.SetOccurenceL( MSmlDmDDFObject::EZeroOrMore );
+    dynamic1.SetScopeL( MSmlDmDDFObject::EDynamic );
+    dynamic1.SetDFFormatL( MSmlDmDDFObject::ENode );
+    dynamic1.AddDFTypeMimeTypeL( KNSmlDmBMAdapterTextPlain );
+    dynamic1.SetDescriptionL( KNSmlDmBMAdapterDynamicDescription );
+    accessTypes.Reset();
+
+
+    // BearerManagementSNAP/<X>/Name
+    MSmlDmDDFObject& name = dynamic1.AddChildObjectL( KNSmlDmBMAdapterName );
+    accessTypes.SetAdd();
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    name.SetAccessTypesL( accessTypes );
+    name.SetOccurenceL( MSmlDmDDFObject::EOne );
+    name.SetScopeL( MSmlDmDDFObject::EDynamic );
+    name.SetDFFormatL( MSmlDmDDFObject::EChr );
+    name.SetDescriptionL( KNSmlDmBMAdapterNameDescription );
+    accessTypes.Reset();
+
+    // BearerManagementSNAP/<X>/IAPPrioityList
+    MSmlDmDDFObject& iapList = 
+    dynamic1.AddChildObjectL( KNSmlDmBMAdapterIAPPriorityList );
+    accessTypes.SetAdd();
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    iapList.SetAccessTypesL( accessTypes );
+    iapList.SetOccurenceL( MSmlDmDDFObject::EOne );
+    iapList.SetScopeL( MSmlDmDDFObject::EDynamic );
+    iapList.SetDFFormatL( MSmlDmDDFObject::EChr );
+    iapList.SetDescriptionL( KNSmlDmBMAdapterIAPPriorityListDescription );
+    accessTypes.Reset();
+        
+    // BearerManagementSNAP/<X>/EmbeddedSNAP
+    MSmlDmDDFObject& embedded = 
+    dynamic1.AddChildObjectL( KNSmlDmBMAdapterEmbeddedSNAP );
+    accessTypes.SetAdd();
+    accessTypes.SetDelete();
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    embedded.SetAccessTypesL( accessTypes );
+    embedded.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
+    embedded.SetScopeL( MSmlDmDDFObject::EDynamic );
+    embedded.SetDFFormatL( MSmlDmDDFObject::EChr );
+    embedded.SetDescriptionL( KNSmlDmBMAdapterEmbeddedSNAPDescription );
+    accessTypes.Reset();
+
+    // BearerManagementSNAP/<X>/Metadata
+    MSmlDmDDFObject& metadata = 
+    dynamic1.AddChildObjectL( KNSmlDmBMAdapterMetadata );
+    accessTypes.SetAdd();
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    metadata.SetAccessTypesL( accessTypes );
+    metadata.SetOccurenceL( MSmlDmDDFObject::EOne );
+    metadata.SetScopeL( MSmlDmDDFObject::EDynamic );
+    metadata.SetDFFormatL( MSmlDmDDFObject::EInt );
+    metadata.SetDescriptionL( KNSmlDmBMAdapterMetadataDescription );
+    accessTypes.Reset();
+ 
+ 
+    // BearerManagementSNAP/<X>/Protected
+    MSmlDmDDFObject& protection = 
+    dynamic1.AddChildObjectL( KNSmlDmBMAdapterProtected );
+    accessTypes.SetAdd();
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    protection.SetAccessTypesL( accessTypes );
+    protection.SetOccurenceL( MSmlDmDDFObject::EOne );
+    protection.SetScopeL( MSmlDmDDFObject::EDynamic );
+    protection.SetDFFormatL( MSmlDmDDFObject::EInt );
+    protection.SetDescriptionL( KNSmlDmBMAdapterProtectedDescription );
+    accessTypes.Reset(); 
+    
+    // BearerManagementSNAP/<X>/Hidden
+    MSmlDmDDFObject& hidden = dynamic1.AddChildObjectL( KNSmlDmBMAdapterHidden );
+    accessTypes.SetAdd();
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    hidden.SetAccessTypesL( accessTypes );
+    hidden.SetOccurenceL( MSmlDmDDFObject::EOne );
+    hidden.SetScopeL( MSmlDmDDFObject::EDynamic );
+    hidden.SetDFFormatL( MSmlDmDDFObject::EBool );
+    hidden.SetDescriptionL( KNSmlDmBMAdapterHiddenDescription );
+    accessTypes.Reset(); 
+    
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::DDFStructureL: End" )
+    }
+
+// -------------------------------------------------------------------------
+// CNSmlDmBmAdapter::UpdateLeafObjectL
+//  Adds or updates leaf node value. If snap object is 
+//  in buffer this command is also buffered. Also if leaf node 
+//  is embedded snap and that snap is buffered, the argument command
+//  is buffered.
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
+                                          const TDesC8& aLUID, 
+                                          const TDesC8& aObject, 
+                                          const TDesC8& /*aType*/, 
+                                          TInt aStatusRef )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::UpdateLeafObjectL: Start" )
+    BMADAPTERLOGSTRING4( "\tUpdateLeafObjectL  \tURI: %S, \n\tLUID: %S,\
+                         \tobject: %S ", 
+                        &aURI, &aLUID, &aObject )
+
+    TInt snapId = MapPredefinedSnapsL( aURI, aLUID );
+                        
+    // Check if parent snap node is found in the buffered settings
+    CSmlDmBmSettingsElement* snap = 
+    GetSnapIfBuffered( RemoveLastURISeg( aURI ) );
+
+    // data for buffered SNAP -> Store command into buffer    
+    if ( snap )
+        {
+        CSmlDmBmCommandElement* cmd = 
+        CSmlDmBmCommandElement::NewLC( ETrue, 
+                                       aStatusRef,
+                                       KNSmlDmBmInvalidRef, 
+                                       CNSmlDmBmAdapter::EAddCmd,
+                                       LastURISeg( aURI ), 
+                                       aObject);
+        snap->NodeBuf().AppendL(cmd);
+        CleanupStack::Pop( cmd );
+        BMADAPTERLOGSTRING2( "\tSnap %S found, buffering cmd", 
+                            snap->MappingName() )
+
+        }
+    // updates for an existing SNAP
+    else
+        {
+
+        // If setting embedded SNAP node and the embedded SNAP node is still 
+        // buffered -> Buffer also this command
+        if( !LastURISeg( aURI ).Compare( KNSmlDmBMAdapterEmbeddedSNAP ) )
+            {
+            snap = GetSnapIfBuffered( aObject );
+
+                // embedded SNAP is buffered
+                if ( snap )
+                    {
+                    CSmlDmBmCommandElement* cmd = 
+                    CSmlDmBmCommandElement::NewLC( ETrue, 
+                                                   aStatusRef,
+                                                   KNSmlDmBmInvalidRef, 
+                                                   CNSmlDmBmAdapter::EAddCmd,
+                                                   LastURISeg( aURI ), 
+                                                   aObject);
+
+                    // buffer this command
+                    CSmlDmBmSettingsElement* setting = 
+                    CSmlDmBmSettingsElement::NewLC( RemoveLastURISeg( aURI ) );
+                    
+                    // Check if SNAP was predefined or not
+                    if( snapId == KErrNotFound )
+                        {
+                        snapId = DesToIntL( aLUID );
+                        }
+                    setting->SetLuid( snapId );
+                    iBuffer.AppendL( setting );
+                    CleanupStack::Pop( setting );
+                    setting->NodeBuf().AppendL(cmd);
+                    CleanupStack::Pop( cmd );
+                    BMADAPTERLOGSTRING2( "\tEmbedded Snap %S buffered, buffering cmd", 
+                                         snap->MappingName() )
+                    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::UpdateLeafObjectL: End" )
+                    return;
+                    }
+            }
+        // execute command and return status  
+        CSmlDmBmCommandElement* cmd = 
+        CSmlDmBmCommandElement::NewLC( ETrue, 
+                                       aStatusRef,
+                                       KNSmlDmBmInvalidRef, 
+                                       CNSmlDmBmAdapter::EAddCmd,
+                                       LastURISeg( aURI ), 
+                                       aObject);
+        if( snapId == KErrNotFound )
+            {
+            snapId = DesToIntL( aLUID );
+            }
+        iSettingStore->ExecuteCmdL( *cmd, snapId );
+        BMADAPTERLOGSTRING2( "\tCmd executed with status: %d", 
+                              cmd->Status() )
+        Callback().SetStatusL( aStatusRef, cmd->Status() );
+        CleanupStack::PopAndDestroy( cmd );
+
+        }
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::UpdateLeafObjectL: End" )
+    }
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::DeleteObjectL
+//  Deletes node or leaf object. If the snap this command relates to is
+//  buffered, also the delete command is buffered.
+// --------------------------------------------------------------------------
+
+void CNSmlDmBmAdapter::DeleteObjectL( const TDesC8& aURI, 
+                                      const TDesC8& aLUID,
+                                      TInt aStatusRef )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::DeleteObjectL: Start" )
+    BMADAPTERLOGSTRING3( "\tDeleteObjectL  \tURI: %S, \tLUID: %S", 
+                         &aURI, &aLUID )
+    
+    CSmlDmBmCommandElement* cmd;
+    
+    TInt snapId = MapPredefinedSnapsL( aURI, aLUID );
+    // check if node or leaf object and create command accordingly
+    // when updating, make sure that cmd is constructed
+    if ( NumOfURISegs( aURI  ) == KNsmlDmBmSNAPNodeDepth )
+        {
+        cmd = CSmlDmBmCommandElement::NewLC( EFalse, 
+                                             aStatusRef,
+                                             KNSmlDmBmInvalidRef, 
+                                             CNSmlDmBmAdapter::EDeleteCmd,
+                                             KNullDesC8, KNullDesC8 );
+        }
+    else if ( ! LastURISeg( aURI ).Compare( KNSmlDmBMAdapterEmbeddedSNAP() ) )
+        {
+        cmd = CSmlDmBmCommandElement::NewLC( ETrue, 
+                                             aStatusRef,
+                                             KNSmlDmBmInvalidRef, 
+                                             CNSmlDmBmAdapter::EDeleteCmd,
+                                             LastURISeg( aURI ), 
+                                             KNullDesC8 );
+        }
+    else
+        {
+        // unsupported node, framework should check this
+        Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+        BMADAPTERLOGSTRING( "\tCNSmlDmBmAdapter::DeleteObjectL: \
+        Error, unsupported node" )
+        return;
+        }
+
+    // If this SNAP still in buffer -> buffer command for later execution
+    // Check if SNAP is found in the buffered settings
+    CSmlDmBmSettingsElement* snap = NULL;
+    if( cmd->Leaf() )
+        {
+        snap = GetSnapIfBuffered( RemoveLastURISeg( aURI ) );
+        }
+    else
+        {
+        snap = GetSnapIfBuffered( aURI );
+        }
+    // when updating make sure that cmd is removed from cleanup 
+    // stack and deleted if necessary
+    
+    // if cmd for buffered snap append cmd to buffer
+    if ( snap )
+        {
+        snap->NodeBuf().AppendL( cmd );
+        CleanupStack::Pop( cmd );
+        BMADAPTERLOGSTRING2( "\tSnap %S found, buffering cmd", 
+                            snap->MappingName() )
+        }
+    // if existing node, execute command
+    else if( aLUID.Length() > 0 || snapId != KErrNotFound )
+        {
+        if( snapId == KErrNotFound )
+            {
+            snapId = DesToIntL( aLUID );
+            }
+        iSettingStore->ExecuteCmdL( *cmd, snapId );
+        BMADAPTERLOGSTRING2( "\tCmd executed with status: %d ", 
+                              cmd->Status() )
+        Callback().SetStatusL( aStatusRef, cmd->Status() );
+        CleanupStack::PopAndDestroy( cmd );
+        }
+        // unknown node    
+    else
+        {
+        BMADAPTERLOGSTRING( "\tUnknown node\n" )
+        Callback().SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
+        CleanupStack::PopAndDestroy( cmd );
+        }
+    
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::DeleteObjectL: End" )
+    }
+// -------------------------------------------------------------------------
+// CNSmlDmBmAdapter::FetchLeafObjectL
+//  Fetches leaf object value. If the snap is buffered also this command 
+//  will
+//  be buffered.
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::FetchLeafObjectL( const TDesC8& aURI, 
+                                         const TDesC8& aLUID, 
+                                         const TDesC8& /*aType*/, 
+                                         const TInt aResultsRef, 
+                                         const TInt aStatusRef )
+    {
+    BMADAPTERLOGSTRING( "NSmlDmBMAdapter::FetchLeafObjectL: Start" )
+    BMADAPTERLOGSTRING3( "\tFetchLeafObjectL  \tURI: %S, \tLUID: %S,", 
+                        &aURI, &aLUID )
+
+    TInt snapId = MapPredefinedSnapsL( aURI, aLUID );                         
+                        
+    // check if parent snap node is buffered 
+    CSmlDmBmSettingsElement* snap = 
+    GetSnapIfBuffered( RemoveLastURISeg( aURI ) );
+
+    // data for buffered SNAP -> Store command into buffer    
+    if ( snap )
+        {
+        CSmlDmBmCommandElement* cmd = 
+        CSmlDmBmCommandElement::NewLC( ETrue, 
+                                       aStatusRef, 
+                                       aResultsRef, 
+                                       CNSmlDmBmAdapter::EGetCmd,
+                                       LastURISeg( aURI ), 
+                                       KNullDesC8);
+        snap->NodeBuf().AppendL( cmd );
+        CleanupStack::Pop( cmd );
+        BMADAPTERLOGSTRING2( "\tSnap %S found, buffering cmd", 
+                            snap->MappingName() )
+        }
+    // otherwise execute cmd right away
+    else
+        {
+                
+        CSmlDmBmCommandElement* cmd = 
+        CSmlDmBmCommandElement::NewLC( ETrue, 
+                                       aStatusRef, 
+                                       aResultsRef, 
+                                       CNSmlDmBmAdapter::EGetCmd,
+                                       LastURISeg( aURI ), 
+                                       KNullDesC8);
+        if( snapId == KErrNotFound )
+            {
+            snapId = DesToIntL( aLUID );
+            }
+
+        iSettingStore->ExecuteCmdL( *cmd, snapId );
+        BMADAPTERLOGSTRING2( "\tCmd executed with status: %d ", 
+                              cmd->Status() )
+        // if executed return status
+        if ( cmd->Executed() ) 
+            {
+            Callback().SetStatusL( aStatusRef, cmd->Status() );
+            // if successful set results
+            if ( cmd->Status() == CSmlDmAdapter::EOk )
+                {
+                BMADAPTERLOGSTRING2( "\tCmd executed with result: %S ", 
+                                      cmd->Data() )
+                CBufBase* result = CBufFlat::NewL( cmd->Data()->Size() );
+                CleanupStack::PushL( result );
+                result->InsertL( 0, *cmd->Data() );
+                Callback().SetResultsL( aResultsRef, *result, KNullDesC8 );
+                CleanupStack::PopAndDestroy( result );
+                }
+            }
+        else
+            {
+            // failed to execute command
+            Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+            }
+        CleanupStack::PopAndDestroy( cmd );
+        }
+    
+    BMADAPTERLOGSTRING( "NSmlDmBMAdapter::FetchLeafObjectL: End" )
+    }
+
+// --------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::FetchLeafObjectSizeL
+//  Fetches leaf object size. If the snap is buffered also this command will
+//  be buffered.
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, 
+                                             const TDesC8& aLUID,
+                                             const TDesC8& /* aType */, 
+                                             TInt aResultsRef,
+                                             TInt aStatusRef )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::FetchLeafObjectSizeL: Start" )
+    BMADAPTERLOGSTRING3( "\tFetchLeafObjectSizeL  \tURI: %S, \tLUID: %S,", 
+                         &aURI, &aLUID )
+   
+    TInt snapId = MapPredefinedSnapsL( aURI, aLUID );
+    
+    // check if parent snap node is buffered 
+    CSmlDmBmSettingsElement* snap = 
+    GetSnapIfBuffered( RemoveLastURISeg( aURI ) );
+
+    // data for buffered SNAP -> Store command into buffer    
+    if ( snap )
+        {
+        CSmlDmBmCommandElement* cmd = 
+        CSmlDmBmCommandElement::NewLC( ETrue, 
+                                       aStatusRef, 
+                                       aResultsRef, 
+                                       CNSmlDmBmAdapter::EGetSizeCmd,
+                                       LastURISeg( aURI ), 
+                                       KNullDesC8);
+        snap->NodeBuf().AppendL( cmd );
+        CleanupStack::Pop( cmd ); 
+        BMADAPTERLOGSTRING2( "\tSnap %S found, buffering cmd", 
+                             snap->MappingName() )
+        }
+    // otherwise execute get size cmd right away
+    else
+        {
+        CSmlDmBmCommandElement* cmd = 
+        CSmlDmBmCommandElement::NewLC( ETrue, 
+                                       aStatusRef, 
+                                       aResultsRef, 
+                                       CNSmlDmBmAdapter::EGetSizeCmd,
+                                       LastURISeg( aURI ), 
+                                       KNullDesC8);
+        if( snapId == KErrNotFound )
+            {
+            snapId = DesToIntL( aLUID );
+            }
+        iSettingStore->ExecuteCmdL( *cmd, snapId );
+        BMADAPTERLOGSTRING2( "\tCmd executed with status: %d ", 
+                              cmd->Status() )
+        // if executed get status
+        if ( cmd->Executed() ) 
+            {
+            Callback().SetStatusL( aStatusRef, cmd->Status() );
+            // if successful get results
+            if ( cmd->Status() == CSmlDmAdapter::EOk )
+                {
+                BMADAPTERLOGSTRING2( "\tCmd executed with result: %S ", 
+                                      cmd->Data() )
+                CBufBase* result = CBufFlat::NewL( cmd->Data()->Size() );
+                CleanupStack::PushL( result );
+                result->InsertL( 0, *cmd->Data() );
+                Callback().SetResultsL( aResultsRef, *result, KNullDesC8 );
+                CleanupStack::PopAndDestroy( result );
+                }
+            }
+        else
+            {
+            // failed to execute command
+            Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+            }
+        
+        CleanupStack::PopAndDestroy( cmd );
+        }
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::FetchLeafObjectSizeL: End" )
+    }
+
+// ------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::ChildURIListL
+//  Fetches child nodes of a node. these may be either all snap nodes
+//  or leaf nodes under a snap node. 
+// ------------------------------------------------------------------------
+void CNSmlDmBmAdapter::ChildURIListL( const TDesC8& aURI, 
+                                      const TDesC8& aLUID,
+                                      const CArrayFix<TSmlDmMappingInfo>& 
+                                      aPreviousURISegmentList,
+                                      TInt aResultsRef, 
+                                      TInt aStatusRef )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::ChildURIListL: Start" )
+    BMADAPTERLOGSTRING3( "\tChildURIListL  URI: %S, LUID: %S ", 
+                        &aURI, &aLUID )
+                        
+    TInt snapId = MapPredefinedSnapsL( aURI, aLUID );
+    
+    CBufBase* resultList = CBufFlat::NewL( KSmlMaxURISegLen );
+    CleanupStack::PushL( resultList );
+    // get all snap nodes
+    if ( !aURI.Compare(KNSmlDmBMAdapterBM) )
+        {
+        RArray<TUint32> snaps = RArray<TUint32>( KNSmlDmBMGranularity );
+        CleanupClosePushL( snaps );
+        iSettingStore->GetSnapsL( snaps );
+        TInt currentSNAP( -1 );
+        for ( TInt i( 0 ); i < snaps.Count(); i++)
+            {
+            currentSNAP = snaps[i];
+            BMADAPTERLOGSTRING2( "\tSnap id: %d, ", currentSNAP )
+
+            // check that not previously mapped
+            TBool found = EFalse;
+            
+            for ( TInt j( 0 ); j < aPreviousURISegmentList.Count(); j++ )
+                {
+                TSmlDmMappingInfo mapping = aPreviousURISegmentList.At( j );
+                // snap already has mapping
+                if ( currentSNAP == DesToIntL( mapping.iURISegLUID ) )
+                    {
+                    BMADAPTERLOGSTRING2( " URI: %S exists ", &mapping.iURISeg )
+                    found = ETrue;
+                    // add to result list
+                    resultList->InsertL( resultList->Size(), 
+                                         mapping.iURISeg);
+                    break;
+                    }
+                }
+            if ( !found )
+                {
+                // This is new snap -> create URI and mapping and add 
+                // node name to result
+                HBufC8* uri = HBufC8::NewLC( aURI.Length() + 
+                                             KNSmlDmBmSeparator().Length() +
+                                             KSmlMaxURISegLen );
+                    
+                TPtr8 uriPtr = uri->Des(); 
+                uriPtr.Format( aURI );
+                uriPtr.Append( KNSmlDmBmSeparator );
+                uriPtr.Append( KNSmlDmBMSNAPNamePrefix ); 
+                HBufC8* luidBuf = IntToDes8L( currentSNAP );
+                CleanupStack::PushL( luidBuf );
+                uriPtr.Append( *luidBuf );
+
+                Callback().SetMappingL( uriPtr, *luidBuf );
+                resultList->InsertL( resultList->Size(), 
+                                     LastURISeg( uriPtr ) );
+                BMADAPTERLOGSTRING2( "Creating mapping for URI %S ", &uriPtr ) 
+                CleanupStack::PopAndDestroy( luidBuf );
+                CleanupStack::PopAndDestroy( uri );
+                }
+            // insert separator if not last    
+            if ( i < snaps.Count() - 1 )
+                {
+                resultList->InsertL( resultList->Size(), 
+                                     KNSmlDmBmSeparator );
+                }
+            }
+        CleanupStack::PopAndDestroy( &snaps );
+        Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
+        Callback().SetResultsL( aResultsRef, *resultList, KNullDesC8 );
+        }
+    // get child nodes of a snap node
+    else if ( NumOfURISegs( aURI ) == KNsmlDmBmSNAPNodeDepth )
+        {        
+        CSmlDmBmSettingsElement* snap = GetSnapIfBuffered( aURI );
+        // if buffered, add this command to buffer
+        if( snap )
+            {
+            CSmlDmBmCommandElement* cmd = 
+            CSmlDmBmCommandElement::NewLC( EFalse, 
+                                           aStatusRef,
+                                           aResultsRef, 
+                                           CNSmlDmBmAdapter::EGetCmd, 
+                                           KNullDesC8, 
+                                           KNullDesC8 );
+            snap->NodeBuf().AppendL( cmd );
+            CleanupStack::Pop( cmd );
+            BMADAPTERLOGSTRING2( "\tSnap %S found, buffering cmd", 
+                                 snap->MappingName() )
+            }
+        // existing snap must have luid mapped
+        else if( aLUID.Length() > 0 || snapId != KErrNotFound )
+            {
+            CSmlDmBmCommandElement* cmd = 
+            CSmlDmBmCommandElement::NewLC( EFalse, 
+                                           aStatusRef,
+                                           aResultsRef, 
+                                           CNSmlDmBmAdapter::EGetCmd, 
+                                           KNullDesC8, 
+                                           KNullDesC8 );
+            if( snapId == KErrNotFound )
+                {
+                snapId = DesToIntL( aLUID );
+                }
+            
+            iSettingStore->ExecuteCmdL( *cmd, snapId );
+            BMADAPTERLOGSTRING2( "\tCmd executed with status: %d ", 
+                                  cmd->Status() )
+            Callback().SetStatusL( aStatusRef, cmd->Status() );
+            if( cmd->Status() == CSmlDmAdapter::EOk )
+                {
+                resultList->InsertL( 0, *cmd->Data() );
+                Callback().SetResultsL( aResultsRef, 
+                                        *resultList, 
+                                        KNullDesC8 );
+                } 
+            CleanupStack::PopAndDestroy( cmd );
+            }
+        // invalid snap object
+        else
+            {
+            BMADAPTERLOGSTRING( "\tCNSmlDmBmAdapter::ChildURIListL: Error, \
+            invalid snap node" )
+            Callback().SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound );
+            }           
+        }
+    else
+        {
+        BMADAPTERLOGSTRING( "\tChildURIListL: Invalid URI" )
+        }
+    CleanupStack::PopAndDestroy( resultList );
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::ChildURIListL: End" )
+    }
+ 
+// --------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::AddNodeObjectL
+//  Adds a snap node. The node is buffered until all data is received.
+// --------------------------------------------------------------------------
+void CNSmlDmBmAdapter::AddNodeObjectL( const TDesC8& aURI, 
+                                       const TDesC8& aParentLUID,
+                                       TInt aStatusRef )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::AddNodeObjectL: Start" )
+    BMADAPTERLOGSTRING3( "\tAddNodeObjectL  \tURI: %S, \tparent LUID: %S,", 
+                        &aURI, &aParentLUID )
+    if ( NumOfURISegs( aURI ) == KNsmlDmBmSNAPNodeDepth )
+        {
+        // if same node already exists command fails
+        CSmlDmBmSettingsElement* setting = GetSnapIfBuffered( aURI );
+        if( setting || aParentLUID.Compare( KNullDesC8) )
+            {
+            BMADAPTERLOGSTRING( "\t Snap exists" )
+            Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EAlreadyExists );
+            }
+        else if ( LastURISeg( aURI ).Length() > KSmlMaxURISegLen )
+            {
+            BMADAPTERLOGSTRING( "\t Node name too long" )
+            Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+            }
+        else
+            {
+            // Store command in buffer for later processing
+            setting = CSmlDmBmSettingsElement::NewLC( aURI );
+            iBuffer.AppendL( setting );
+            CleanupStack::Pop( setting );
+        
+            // store the add node command
+            CSmlDmBmCommandElement* command = 
+            CSmlDmBmCommandElement::NewLC( EFalse, 
+                                           aStatusRef,
+                                           KNSmlDmBmInvalidRef, 
+                                           CNSmlDmBmAdapter::EAddCmd, 
+                                           KNullDesC8, 
+                                           KNullDesC8 );
+            TInt index( iBuffer.Count() - 1 );
+            iBuffer[index]->NodeBuf().AppendL( command ); 
+            CleanupStack::Pop( command );
+            BMADAPTERLOGSTRING( "\t Cmd buffered" )
+            }
+        }
+      
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::AddNodeObjectL: End" )
+    }
+
+// -------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::UpdateLeafObjectL
+//  Not supported
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::UpdateLeafObjectL( const TDesC8& /* aURI */, 
+                                          const TDesC8& /* aLUID */, 
+                                          RWriteStream*& /* aStream */, 
+                                          const TDesC8& /* aType */, 
+                                          TInt /* aStatusRef */ )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::UpdateLeafObjectL: Start" )
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::UpdateLeafObjectL: End" )
+    }
+
+
+
+// -------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::ExecuteCommandL
+//  Not supported
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::ExecuteCommandL( const TDesC8& /* aURI */, 
+                                        const TDesC8& /* aLUID */, 
+                                        const TDesC8& /* aArgument */, 
+                                        const TDesC8& /* aType */, 
+                                        TInt aStatusRef )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::ExecuteCommandL: Start" )
+    Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::ExecuteCommandL: End" )
+    }
+// -------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::ExecuteCommandL
+//  Not supported
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::ExecuteCommandL( const TDesC8& /* aURI */, 
+                                        const TDesC8& /* aLUID */, 
+                                        RWriteStream*& /* aStream */, 
+                                        const TDesC8& /* aType */, 
+                                        TInt aStatusRef )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::ExecuteCommandL: Start" )
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::ExecuteCommandL: End" )
+    }
+ 
+// -------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::CopyCommandL
+//  Not supported
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::CopyCommandL( const TDesC8& /* aTargetURI */ , 
+                                     const TDesC8& /* aTargetLUID */ , 
+                                     const TDesC8& /* aSourceURI */ , 
+                                     const TDesC8& /* aSourceLUID */, 
+                                     const TDesC8& /* aType */ , 
+                                     TInt aStatusRef )
+    {
+    //not supported
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::CopyCommandL: Sart" )
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::CopyCommandL: End" )
+    }
+// -------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::StartAtomicL
+//  Not supported
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::StartAtomicL()
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::StartAtomicL: Start" )
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::StartAtomicL: End" )
+    }
+// -------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::CommitAtomicL
+//  Not supported
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::CommitAtomicL()
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::CommitAtomicL: Start" )
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::CommitAtomicL: End" )
+    }
+
+// -------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::RollbackAtomicL
+//  Not supported
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::RollbackAtomicL()
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::RollbackAtomicL: Start" )
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::RollbackAtomicL: End" )
+    }
+
+TBool CNSmlDmBmAdapter::StreamingSupport( TInt& /* aItemSize */ )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::StreamingSupport: Start" )
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::StreamingSupport: End" )
+    return EFalse;
+    }
+// -------------------------------------------------------------------------
+//  CNSmlDmBmAdapter::StreamCommittedL
+//  Not supported
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::StreamCommittedL()
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::StreamCommittedL: Start" )
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::StreamCommittedL: End" )
+    }
+
+// -------------------------------------------------------------------------
+// CNSmlDmBmAdapter::CompleteOutstandingCmdsL
+//  CNSmlDmBmAdapter::CompleteOutstandingCmdsL
+// -------------------------------------------------------------------------
+void CNSmlDmBmAdapter::CompleteOutstandingCmdsL()
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::CompleteOutstandingCmdsL: Start" )
+    CSmlDmBmSettingsElement* settings( NULL );
+    CSmlDmBmCommandElement* cmd( NULL );
+    TInt err(0);
+    // Read through the buffer and execute commands
+    for ( TInt i(0); i < iBuffer.Count(); )
+        {
+        settings = iBuffer[i];
+        if( settings->NodeBuf().Count() )
+            {
+            // the setting may be executed already if it has been an embedded
+            // snap for another snap
+            if ( !settings->Executed() ) 
+                {
+                //execute commands for snap
+                TRAP( err, iSettingStore->StoreSnapL( *settings )); 
+                } 
+            // if can't recover from error, don't continue processing 
+            // commands
+            if( err == KErrNoMemory || 
+                err == KErrDiskFull )
+                {
+                BMADAPTERLOGSTRING2( "\tCNSmlDmBmAdapter::\
+                CompleteOutstandingCmdsL: Error %d", err )
+                User::Leave( err );
+                }
+            // if this is a new snap and created successfully, map luid
+            if ( !settings->NodeBuf()[0]->Leaf() &&
+                 settings->NodeBuf()[0]->CmdType() == CNSmlDmBmAdapter::EAddCmd && 
+                 settings->NodeBuf()[0]->Executed() &&
+                 settings->NodeBuf()[0]->Status() == CSmlDmAdapter::EOk )
+                {
+                HBufC8* luid = IntToDes8L( settings->Luid() );
+                CleanupStack::PushL( luid );
+                Callback().SetMappingL( *settings->MappingName(), *luid );
+                BMADAPTERLOGSTRING3( "\t Setting mapping %S - %S ",
+                settings->MappingName(), luid )
+                CleanupStack::PopAndDestroy( luid );
+                }
+            // set status for all commands executed and remove the command
+            for ( TInt j( 0 ); j < settings->NodeBuf().Count(); )
+                {
+                
+                cmd = settings->NodeBuf()[j];
+                 
+                // return status values if executed
+                if ( cmd->Executed() )
+                    {
+                    
+                    Callback().SetStatusL( cmd->StatusRef(),
+                                  cmd->Status() );
+                    // for certain errors, don't continue command execution
+                    if( cmd->Status() == CSmlDmAdapter::ENoMemory )
+                        {
+                        // commands are deleted     
+                        iBuffer.ResetAndDestroy();
+                        BMADAPTERLOGSTRING( "\tCmd failed with CSmlDmAdapter::ENoMemory" )
+                        User::Leave( KErrNoMemory );
+                        }
+                   else if( cmd->Status() == CSmlDmAdapter::EDiskFull )
+                        {
+                        // commands are deleted   
+                        iBuffer.ResetAndDestroy();
+                        BMADAPTERLOGSTRING( "\tCmd failed with CSmlDmAdapter::EDiskFull" )
+                        User::Leave( KErrDiskFull );
+                        }
+                   else
+                        {
+                        BMADAPTERLOGSTRING2( 
+                            "\tCmd failed with CSmlDmAdapter::%d", 
+                            cmd->Status() )
+                        }
+                    // for get commands, also return the results
+                   if ( cmd->CmdType() == CNSmlDmBmAdapter::EGetCmd || 
+                        cmd->CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+                       {
+                       CBufBase* result = CBufFlat::NewL( cmd->Data()->Size() );
+                       CleanupStack::PushL( result );
+                       result->InsertL( 0, *cmd->Data() ); 
+                       Callback().SetResultsL( cmd->ResultRef(), 
+                                               *result, 
+                                               KNullDesC8 );
+                       CleanupStack::PopAndDestroy( result );
+                       }
+                   }
+               else
+                   {
+                   Callback().SetStatusL( cmd->StatusRef(),
+                                 CSmlDmAdapter::EError );
+                   }
+               settings->NodeBuf().Remove( j );
+               delete cmd;
+               }
+            }
+            
+        // delete settings element and remove it from buffer 
+        delete settings;
+        iBuffer.Remove( i );
+        }
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::CompleteOutstandingCmdsL: End" )
+    }
+
+
+
+// -------------------------------------------------------------------------
+// CNSmlDmBmAdapter::StoreSnapIfBufferedL
+// If argument snap is found in the buffer iSettingStore->StoreSNAPL is 
+// called 
+// for it and LUID is mapped. SNAP is set as executed.
+// This is called when checking if snap has embedded snap reference to 
+// another 
+// snap which is stored further in the command buffer. 
+// All embedded snap commands of this type are buffered and execution only 
+// happens with CompleteOutstandingCmdsL call. 
+// -------------------------------------------------------------------------
+    
+void CNSmlDmBmAdapter::StoreSnapIfBufferedL( const TDesC8& aURI )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::StoreSnapIfBufferedL: Start" )
+    CSmlDmBmSettingsElement* snap = GetSnapIfBuffered( aURI );
+    // if snap is in buffer and is a new snap
+    if( snap && !snap->Luid() )
+        {
+        iSettingStore->StoreSnapL( *snap );
+        // set mapping if succesfully executed
+        if ( snap->NodeBuf()[0]->Executed() &&
+             snap->NodeBuf()[0]->Status() == CSmlDmAdapter::EOk )
+            {
+            HBufC8* luid = IntToDes8L( snap->Luid() );
+            CleanupStack::PushL( luid );
+            Callback().SetMappingL( *snap->MappingName(), *luid);
+            CleanupStack::PopAndDestroy( luid );
+            }
+        }
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::StoreSnapIfBufferedL: End" )
+    }
+// -------------------------------------------------------------------------
+// CNSmlDmBmAdapter::GetSnapUriFromLuidL
+// Returns heap desciptor holding snap node URI matching the argument LUID
+// -------------------------------------------------------------------------
+HBufC8* CNSmlDmBmAdapter::GetSnapUriFromLuidL( const TUint aSnapId )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::GetSnapURIFromLUIDL: Start" )
+    HBufC8* uri( NULL );
+    MSmlDmAdapter::TError err( MSmlDmAdapter::EOk );
+    CBufBase* fetchRes = CBufFlat::NewL( KSmlMaxURISegLen );
+    CleanupStack::PushL( fetchRes );
+    // fetch all snap nodes
+    Callback().FetchLinkL( KNSmlDmBMAdapterBMURI, *fetchRes, err );
+
+    TPtr8 snapNodes = fetchRes->Ptr( 0 );
+
+    TInt numSnaps = NumOfURISegs( snapNodes );
+        
+    // get uri-luid mappings for snap nodes
+    for ( TInt i( 0 ); i < numSnaps; i++ )
+        {
+        TPtrC8 node = LastURISeg( snapNodes );
+
+        HBufC8* uriSeg = HBufC8::NewLC( KNSmlDmBmAdapterURIMaxLength + 
+                                        node.Length());
+        uriSeg->Des().Append( KNSmlDmBMAdapterBM() );
+        uriSeg->Des().Append( KNSmlDmBmSeparator() );
+        uriSeg->Des().Append( node ); 
+
+        HBufC8* luid = Callback().GetLuidAllocL( *uriSeg );
+        CleanupStack::PopAndDestroy( uriSeg );
+        CleanupStack::PushL( luid );
+        // node may not have luid mapped if it's just created
+        if( luid->Size() )
+            {
+            TInt id = DesToIntL( *luid );
+            CleanupStack::PopAndDestroy( luid ); 
+            if ( aSnapId ==  id ) 
+                {
+                uri = HBufC8::NewLC( KNSmlDmBMAdapterBMURI().Size() + 
+                               KNSmlDmBmSeparator().Size() + 
+                               node.Size() );
+
+                uri->Des().Append( KNSmlDmBMAdapterBMURI() );
+                uri->Des().Append( KNSmlDmBmSeparator() );
+                uri->Des().Append( node );
+                break;
+                }
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy( luid );
+            }
+        snapNodes = RemoveLastURISeg( snapNodes );
+        }
+          
+    if( uri )
+        {
+         CleanupStack::Pop( uri );
+        }
+
+    CleanupStack::PopAndDestroy( fetchRes );
+
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::IdArrayToIAPList: End" )
+    return uri;
+    }
+
+// -------------------------------------------------------------------------
+// CNSmlDmBmAdapter::GetIapListL
+// Returns heap desciptor holding a comma separated list of AP node URIs
+// matching the luids in the argument array.
+// -------------------------------------------------------------------------
+HBufC8* CNSmlDmBmAdapter::GetIapListL( const RArray<TUint>& aIdArray )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::GetIapListL: Start" )
+    HBufC8* iapList = HBufC8::NewLC( aIdArray.Count() * 
+                                    ( KNSmlDmBmAdapterAPURIMaxLength + 
+                                      KSmlMaxURISegLen ) );
+    MSmlDmAdapter::TError err;
+    CBufBase* fetchRes = CBufFlat::NewL( KSmlMaxURISegLen );
+    CleanupStack::PushL( fetchRes );
+    // fetch dynamic AP nodes, so that LUID mapping is created
+    Callback().FetchLinkL( KNSmlDmBMAdapterIAPURI, *fetchRes, err );
+
+    // list of all nodes has a trailing '/' unlike regular uris, remove that
+    // for further handling 
+    TPtr8 iapNodes = fetchRes->Ptr( 0 );
+    if ( iapNodes.Length() > 0 && iapNodes[iapNodes.Length() - 1] == '/')
+        {
+        iapNodes = iapNodes.Left( iapNodes.Length() - 1 );
+        }
+
+    TInt numAPs = NumOfURISegs( iapNodes );
+    
+    CArrayFixFlat<TSmlDmMappingInfo>* mappings = 
+        new (ELeave) CArrayFixFlat<TSmlDmMappingInfo>( numAPs * 
+                                                       sizeof( TSmlDmMappingInfo ) );
+    CleanupStack::PushL( mappings );
+    
+   // get uri-luid mappings for all ap nodes
+    HBufC8* luid = NULL;
+    for ( TInt i( 0 ); i < numAPs; i++ )
+        {
+        TSmlDmMappingInfo m;
+        m.iURISeg = LastURISeg( iapNodes );
+        
+        HBufC8* uriSeg = HBufC8::NewLC( KNSmlDmBmAdapterAPURIMaxLength + 
+                                        m.iURISeg.Length() );
+        uriSeg->Des().Replace( 0, 
+                               uriSeg->Length(), 
+                               KNSmlDmBMAdapterIAPNode() );
+        uriSeg->Des().Append( KNSmlDmBmSeparator() );
+        uriSeg->Des().Append( m.iURISeg ); 
+
+        luid = Callback().GetLuidAllocL( *uriSeg );
+        CleanupStack::PopAndDestroy( uriSeg );
+        CleanupStack::PushL( luid );
+        m.iURISegLUID.Set( *luid );
+        mappings->AppendL( m ); 
+        iapNodes = RemoveLastURISeg( iapNodes );
+        }
+        
+    // find out URIs matching argument IAP ids
+    for (TInt i(0); i < aIdArray.Count(); i++)
+        {
+        TBool found = EFalse;
+
+        for ( TInt j( 0 ); j < mappings->Count(); j++ )
+            {
+            if ( aIdArray[i] == DesToIntL( mappings->At( j ).iURISegLUID ) )
+                {
+                // add to result
+                iapList->Des().Append( KNSmlDmBMAdapterIAPURI() );
+                iapList->Des().Append( KNSmlDmBmSeparator() );
+                iapList->Des().Append( mappings->At(j).iURISeg );
+                // not last -> add separator
+                if ( i < aIdArray.Count() - 1 )
+                    {
+                    iapList->Des().Append( KNSmlDmBmUriListSeparator );
+                    }
+                found = ETrue;
+                break;
+                }
+            }
+        if ( ! found )
+            {
+            BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::GetIapListL: \
+            Error IAP matching id not found" )
+            User::Leave( KErrNotFound );
+            }
+        }
+  
+    // cleanup each allocated luid
+    CleanupStack::PopAndDestroy( numAPs ); 
+    CleanupStack::PopAndDestroy( mappings );
+    CleanupStack::PopAndDestroy( fetchRes );
+    CleanupStack::Pop( iapList );
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::GetIapListL: End" )
+    return iapList;
+    }
+    
+// -------------------------------------------------------------------------
+// CNSmlDmBmAdapter::GetIdArrayL
+// Returns array holding LUIDs matching the AP node in the argument list.
+// -------------------------------------------------------------------------
+RArray<TUint> CNSmlDmBmAdapter::GetIdArrayL( const TDesC8& aIAPList )
+    {
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::GetIdArrayL: Start" )
+    TPtrC8 uri;
+    RArray<TUint> iaps;
+    CleanupClosePushL( iaps );
+    uri.Set( aIAPList );
+    // fetch AP nodes so that mappings are created
+    MSmlDmAdapter::TError err;
+    CBufBase* fetchRes = CBufFlat::NewL( KSmlMaxURISegLen );
+    CleanupStack::PushL( fetchRes );
+    // fetch dynamic AP nodes, so that LUID mappings are created
+    Callback().FetchLinkL( KNSmlDmBMAdapterIAPURI, *fetchRes, err );
+    
+    for ( TInt i(0), n = NumOfURIs( aIAPList ); i < n; i++ )
+        {
+        TPtrC8 thisURI = FirstURI( uri );
+        // remove ./ from beginning
+        TPtrC8 apUri = thisURI.Mid( KNSmlDmBmAdapterURIPrefix().Length() );
+        HBufC8* luid = Callback().GetLuidAllocL( apUri );
+        CleanupStack::PushL( luid );
+        TInt id = DesToIntL( *luid );
+        CleanupStack::PopAndDestroy( luid );
+        iaps.Append( id );
+        uri.Set( RemoveFirstURI( uri ) );
+        }
+    
+    CleanupStack::PopAndDestroy( fetchRes );
+    CleanupStack::Pop( &iaps );
+    BMADAPTERLOGSTRING( "CNSmlDmBmAdapter::GetIdArrayL: End" )
+    return iaps;
+    }
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::IntToDes8L
+// Converts integer to 8bit descriptor
+// --------------------------------------------------------------------------
+HBufC8* CNSmlDmBmAdapter::IntToDes8L( TInt aLuid ) const
+    {
+    HBufC8* buf = HBufC8::NewL( KMaxLengthOf32bitInteger ); 
+    TPtr8 ptrBuf = buf->Des();
+
+    // Unless aLuid is casted as TInt64, PC-Lint reports: 
+    // Significant prototype coercion
+    // 
+    ptrBuf.Num( TInt64( aLuid ) );
+    return buf;
+    }
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::DesToIntL
+// Converts 8bit descriptor to int
+// --------------------------------------------------------------------------
+TUint CNSmlDmBmAdapter::DesToIntL( const TDesC8& aLuid ) const
+    {
+    __UHEAP_MARK;
+    TLex8 lex( aLuid );
+    TUint value( 0 );
+    User::LeaveIfError( lex.Val( value ) );
+    __UHEAP_MARKEND;
+    return value;
+    }
+    
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::DesToBool
+// Converts 8bit descriptor to a boolean value
+// --------------------------------------------------------------------------
+TBool CNSmlDmBmAdapter::DesToBool(const TDesC8& aBoolDes, TBool& aBool ) const
+    {
+    __UHEAP_MARK;
+    if ( !aBoolDes.Compare( KNSmlDmBMBooleanTrue ) )
+        {
+        aBool = ETrue;
+        }
+    else if ( !aBoolDes.Compare( KNSmlDmBMBooleanFalse ) )
+        {
+        aBool = EFalse;
+        }
+    else
+        {
+        __UHEAP_MARKEND;
+        return EFalse;
+        }
+    __UHEAP_MARKEND;
+    return ETrue;
+    }
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::BoolToDes8LC
+// Converts boolean value to 8bit descriptor
+// --------------------------------------------------------------------------
+
+HBufC8* CNSmlDmBmAdapter::BoolToDes8LC( TBool aBool) const
+    {
+    HBufC8* ret;
+    if( aBool )
+        {
+        ret = HBufC8::NewLC( KNSmlDmBMBooleanTrue().Size() );
+        ret->Des().Append( KNSmlDmBMBooleanTrue() ); 
+        }
+    else
+        {
+        ret = HBufC8::NewLC( KNSmlDmBMBooleanFalse().Size() );
+        ret->Des().Append( KNSmlDmBMBooleanFalse() ); 
+        }
+    return ret;
+    }
+
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::GetLuidAllocL
+// The function calls the GetLuidAllocL function of the MSmlDmCallback to get
+// the LUID which is mapped to aURI.
+// --------------------------------------------------------------------------
+HBufC8* CNSmlDmBmAdapter::GetLuidAllocL( const TDesC8& aURI )
+    {
+    return Callback().GetLuidAllocL( aURI );
+    }
+
+   
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::GetSnapIfBuffered
+// Returns a pointer to the snap CSmlDmBmSettingsElement object if found in 
+// the buffer 
+// --------------------------------------------------------------------------
+CSmlDmBmSettingsElement* CNSmlDmBmAdapter::GetSnapIfBuffered( const TDesC8& 
+                                                              aMappingName )
+    {
+    CSmlDmBmSettingsElement* settings = NULL;
+    for ( TInt i( 0 ); i<iBuffer.Count(); i++ )
+        {
+        if ( !iBuffer[i]->MappingName()->Compare( aMappingName ) )
+            {
+            settings = iBuffer[i];
+            break;
+            }
+        }
+    return settings;
+    }
+// -------------------------------------------------------------------------
+// CNSmlDmBmAdapter::FirstURI
+// Returns the first URI from a list of URIs
+// -------------------------------------------------------------------------
+TPtrC8 CNSmlDmBmAdapter::FirstURI( const TDesC8& aURIList ) const
+    {
+    __UHEAP_MARK;
+    TInt i;
+    for ( i = 0; i < aURIList.Length(); i++ )
+        {
+        if ( aURIList[i] == ',' )
+            {
+            break;
+            }
+        }
+    if ( i == aURIList.Length() - 1 )
+        {
+        __UHEAP_MARKEND;
+        return aURIList;
+        }
+    else
+        {
+        __UHEAP_MARKEND;
+        return aURIList.Mid( 0, i );
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::NumOfURIs
+// Returns the num of uris
+// --------------------------------------------------------------------------
+TInt CNSmlDmBmAdapter::NumOfURIs( const TDesC8& aURIList ) const
+    {
+    __UHEAP_MARK;
+    if ( !aURIList.Length() )
+        {
+        return 0;
+        }
+    TInt numOfURIs( 1 );
+    for ( TInt i(0); i < aURIList.Length(); i++ )
+        {
+        if ( aURIList[i] == ',' )
+            {
+            numOfURIs++;
+            }
+        }
+    __UHEAP_MARKEND;
+    return numOfURIs;
+    }
+    
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::RemoveFirstURI
+// extracts first uri an returns the remaining part of the uri list 
+// --------------------------------------------------------------------------
+TPtrC8 CNSmlDmBmAdapter::RemoveFirstURI( const TDesC8& aURIList ) const
+    {
+    __UHEAP_MARK;
+    TInt i;
+    for ( i = 0; i < aURIList.Length(); i++ )
+        {
+        if ( aURIList[i] == ',' )
+            {
+            break;
+            }
+        }
+    if ( i <  aURIList.Length() ) 
+        {
+        __UHEAP_MARKEND;
+        return aURIList.Mid( i + 1 );
+        }
+    else
+        {
+        __UHEAP_MARKEND;
+        return aURIList.Mid( i ); 
+        }
+        
+    }
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::LastURISeg
+// Returns the last uri segemnt of a uri. 
+// --------------------------------------------------------------------------
+TPtrC8 CNSmlDmBmAdapter::LastURISeg( const TDesC8& aURI ) const
+    {
+    __UHEAP_MARK;
+    TInt i;
+    for ( i=aURI.Length()-1; i >= 0; i-- )
+        {
+        if ( aURI[i]=='/' )
+            {
+            break;
+            }
+        }
+    if ( i==0 )
+        {
+        __UHEAP_MARKEND;
+        return aURI;
+        }
+    else
+        {
+        __UHEAP_MARKEND;
+        return aURI.Mid( i + 1 );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::RemoveLastURISeg
+// returns parent uri, i.e. removes last uri segment
+// --------------------------------------------------------------------------
+TPtrC8 CNSmlDmBmAdapter::RemoveLastURISeg( const TDesC8& aURI ) const
+    {
+    __UHEAP_MARK;
+    TInt i;
+    for ( i = aURI.Length()-1; i >= 0; i-- )
+        {
+        if ( aURI[i]=='/' )
+            {
+            break;
+            }
+        }
+    if ( i > -1 )
+        {
+        __UHEAP_MARKEND;
+        return aURI.Left( i );
+        }
+    else
+        {
+        __UHEAP_MARKEND;
+        return aURI;
+        }
+    
+    }
+
+
+
+// --------------------------------------------------------------------------
+// CNSmlDmBmAdapter::NumOfURISegs
+// Returns the num of uri segs
+// --------------------------------------------------------------------------
+TInt CNSmlDmBmAdapter::NumOfURISegs( const TDesC8& aURI ) const
+    {
+    __UHEAP_MARK;
+    TInt numOfURISegs( 1 );
+    for ( TInt i(0); i < aURI.Length(); i++ )
+        {
+        if ( aURI[i]=='/' )
+            {
+            numOfURISegs++;
+            }
+        }
+    __UHEAP_MARKEND;
+    return numOfURISegs;
+    }
+
+TInt CNSmlDmBmAdapter::MapPredefinedSnapsL( const TDesC8& aURI, const TDesC8& aLUID )
+{
+    TInt snapId( KErrNotFound ); 
+    // If this is an add to pre-defined SNAPs then LUID we get is empty, but we still need
+    // to handle it.
+    if( aLUID.Length() == 0 && ( ( snapId = GetPredefinedSnapIdFromUri( aURI ) ) != KErrNotFound ) )
+        {               
+        // Check if SNAP with given ID exists (from CmManager)
+        iCmManagerExt.OpenL();
+        TRAPD( err, RCmDestinationExt dest = iCmManagerExt.DestinationL( snapId ) );
+        iCmManagerExt.Close();
+        
+        // If exists -> Call SetMapping to set LUID.
+        if( err == KErrNone )
+            {
+            HBufC8* uri = HBufC8::NewLC( KNSmlDmBMAdapterBM().Length() + 
+                                         KNSmlDmBmSeparator().Length() +
+                                         KSmlMaxURISegLen );
+                
+            TPtr8 uriPtr = uri->Des(); 
+            uriPtr.Format( KNSmlDmBMAdapterBM );
+            uriPtr.Append( KNSmlDmBmSeparator );
+            uriPtr.Append( KNSmlDmBMSNAPNamePrefix ); 
+            HBufC8* luidBuf = IntToDes8L( snapId );
+            CleanupStack::PushL( luidBuf );
+            uriPtr.Append( *luidBuf );
+    
+            Callback().SetMappingL( uriPtr, *luidBuf );
+            
+            BMADAPTERLOGSTRING2( "Creating mapping for URI %S ", &uriPtr ) 
+            CleanupStack::PopAndDestroy( luidBuf );
+            CleanupStack::PopAndDestroy( uri );
+            }                                          
+        }                       
+    return snapId;
+}
+
+TInt CNSmlDmBmAdapter::GetPredefinedSnapIdFromUri( const TDesC8& aURI ) const
+    {    
+    TInt ret = KErrNotFound;
+    
+    // First check that URI starts with BearerManagementSNAP
+    TInt startIndex = aURI.Find( KNSmlDmBMAdapterBM );
+    
+    if( startIndex == KErrNotFound )
+        {
+        return KErrNotFound;
+        }
+    
+    // Then assume there is separator
+    startIndex += KNSmlDmBMAdapterBM().Length() + KNSmlDmBmSeparator().Length();
+    
+    if( startIndex >= aURI.Length() )
+        {
+        // No separator. This was an access to ./BearerManagementSNAP
+        return KErrNotFound;
+        }
+    
+    TPtrC8 predefinedUriStart = aURI.Mid( startIndex  );
+    
+    startIndex = predefinedUriStart.Find( KNSmlDmBMSNAPNamePrefix );
+    
+    // Result should be zero ( = start of string)
+    if( startIndex != 0 )
+        {
+        return KErrNotFound;
+        }
+    
+    startIndex += KNSmlDmBMSNAPNamePrefix().Length();     
+    
+    TInt endIndex = 0;
+    
+    endIndex = predefinedUriStart.Find( KNSmlDmBmSeparator );
+    
+    
+    
+    if ( endIndex == KErrNotFound )
+        {
+        TPtrC8 snapId = predefinedUriStart.Mid( startIndex );
+        TRAPD( err, ret = DesToIntL( snapId ) );
+        if( err != KErrNone )
+            {
+            ret = KErrNotFound;
+            }       
+        }
+    else
+        {
+        TPtrC8 snapId = predefinedUriStart.Mid( startIndex, endIndex - startIndex );
+        TRAPD( err, ret = DesToIntL( snapId ) );
+        if( err != KErrNone )
+            {
+            ret = KErrNotFound;
+            }       
+        }    
+    return ret;    
+    }
+
+
+
+//---------------------- CSmlDmBmCommandElement -------------------------//
+
+// --------------------------------------------------------------------------
+// CSmlDmBmCommandElement* CSmlDmBmCommandElement::NewLC
+// --------------------------------------------------------------------------
+
+CSmlDmBmCommandElement* CSmlDmBmCommandElement::NewLC( TBool aLeaf,
+                                                       TInt aStatusRef, 
+                                                       TInt aResultRef, 
+                                                       CNSmlDmBmAdapter::TCommandType aCmdType,
+                                                       const TDesC8& aLastUriSeg, 
+                                                       const TDesC8& aData )
+    {
+    CSmlDmBmCommandElement* self = new (ELeave) CSmlDmBmCommandElement( aLeaf, 
+                                                                        aStatusRef, 
+                                                                        aResultRef, 
+                                                                        aCmdType );
+    CleanupStack::PushL(self);
+    self->ConstructL( aLastUriSeg, aData );
+    return self;
+    }
+    
+// --------------------------------------------------------------------------
+// CSmlDmBmCommandElement::~CSmlDmBmCommandElement
+// --------------------------------------------------------------------------
+CSmlDmBmCommandElement::~CSmlDmBmCommandElement()
+    {
+    delete iLastUriSeg;
+    delete iData;
+    }
+    
+// --------------------------------------------------------------------------
+// CSmlDmBmCommandElement::CSmlDmBmCommandElement
+// --------------------------------------------------------------------------
+CSmlDmBmCommandElement::CSmlDmBmCommandElement( TBool aLeaf,
+                                                TInt aStatusRef, 
+                                                TInt aResultRef, 
+                                                CNSmlDmBmAdapter::TCommandType  aCmdType )
+                                                : iStatus( CSmlDmAdapter::EError ),
+                                                iLeaf( aLeaf ),
+                                                iStatusRef( aStatusRef ),
+                                                iResultRef( aResultRef ),
+                                                iCmdType( aCmdType ),
+                                                iData( NULL )
+                                                
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CSmlDmBmCommandElement::ConstructL
+// --------------------------------------------------------------------------
+void CSmlDmBmCommandElement::ConstructL( const TDesC8& aLastUriSeg, 
+                                         const TDesC8& aData )
+    {
+    iLastUriSeg = aLastUriSeg.AllocL();
+    iData = aData.AllocL();
+    }
+
+//---------------------- CSmlDmBmSettingsElement -------------------------//
+
+// --------------------------------------------------------------------------
+// CSmlDmBmSettingsElement* CSmlDmBmSettingsElement::NewLC
+// --------------------------------------------------------------------------
+CSmlDmBmSettingsElement* CSmlDmBmSettingsElement::NewLC( const TDesC8& aMappingName )
+    {
+    CSmlDmBmSettingsElement* self = new (ELeave) CSmlDmBmSettingsElement();
+    CleanupStack::PushL(self);
+    self->ConstructL( aMappingName );
+    return self;
+    }
+// --------------------------------------------------------------------------
+// CSmlDmBmSettingsElement::~CSmlDmBmSettingsElement
+// --------------------------------------------------------------------------
+CSmlDmBmSettingsElement::~CSmlDmBmSettingsElement()
+    {
+    // deallocate all elements
+    iNodeBuf.ResetAndDestroy();
+    iNodeBuf.Close();
+    delete iMappingName;
+    }
+
+// --------------------------------------------------------------------------
+// CSmlDmBmSettingsElement::CSmlDmBmSettingsElement
+// --------------------------------------------------------------------------
+CSmlDmBmSettingsElement::CSmlDmBmSettingsElement()
+                                                : iExecuted( EFalse ),
+                                                  iLuid( 0 ),
+                                                  iMappingName( NULL ) 
+    {
+    
+    }
+// --------------------------------------------------------------------------
+// CSmlDmBmSettingsElement::ConstructL
+// --------------------------------------------------------------------------
+void CSmlDmBmSettingsElement::ConstructL( const TDesC8& aMappingName )
+    {
+    iMappingName = aMappingName.AllocL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/src/nsmldmbmadapter.rss	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,45 @@
+CHARACTER_SET UTF8/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Resource definitions for project nsmldmbmadapter
+*
+*/
+
+
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x101f6d2f; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = 0x102018B4; //DM interface UID
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x101f6d2f; // BM adapter implementation UID
+                version_no = 1; 
+                display_name = "";
+                default_data = "";
+                opaque_data = "";
+                }
+            };
+          }
+      };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldmbmadapter/src/nsmldmbmsettingstore.cpp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,851 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Provides settings management in CommsDat.
+*
+*/
+
+
+
+
+#include <utf.h>
+#include <cmdestinationext.h>
+#include <cmconnectionmethoddef.h>
+#include <cmmanagerdef.h>
+#include <commsdat.h>
+
+#include "nsmldmbmsettingstore.h"
+#include "nsmldmbmadapter.h"
+#include "bmadapterlogger.h"
+
+// -----------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::NewL
+// -----------------------------------------------------------------------------
+CNSmlDmBmSettingStore* CNSmlDmBmSettingStore::NewL( CNSmlDmBmAdapter * aAdapter )
+    {
+    CNSmlDmBmSettingStore* self = new (ELeave) CNSmlDmBmSettingStore( aAdapter );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::CNSmlDmBmSettingStore
+// -----------------------------------------------------------------------------
+CNSmlDmBmSettingStore::CNSmlDmBmSettingStore( CNSmlDmBmAdapter * aAdapter ) 
+    : iAdapter( aAdapter )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::ConstructL
+// -----------------------------------------------------------------------------
+void CNSmlDmBmSettingStore::ConstructL()
+    {
+    iCmManagerExt.OpenL();
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::~CNSmlDmBmSettingStore
+// -----------------------------------------------------------------------------
+CNSmlDmBmSettingStore::~CNSmlDmBmSettingStore()
+    {
+    iCmManagerExt.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::StoreSnapL
+// Stores data related to a snap object. Executes commands for the snap and fills 
+// in status and for get commands result values.
+// -----------------------------------------------------------------------------
+void CNSmlDmBmSettingStore::StoreSnapL( CSmlDmBmSettingsElement& aSettings )
+    {
+    // this snap has been handled
+    aSettings.SetExecuted( ETrue );
+
+    // error empty settings object
+    if ( !aSettings.NodeBuf().Count() )
+      {
+      BMADAPTERLOGSTRING( "StoreSnapL: Error, No commands found" )
+        return;
+        }
+       
+    TInt nameCmdInd( -1 );
+    TInt startInd( 0 );
+    RCmDestinationExt snap;
+    TInt snapId( 0 );
+    
+    // New SNAP to be stored, first command is add node
+    if( !aSettings.NodeBuf()[0]->Leaf() && 
+      aSettings.NodeBuf()[0]->CmdType() == CNSmlDmBmAdapter::EAddCmd)
+        {
+        CSmlDmBmCommandElement* snapCmd( NULL );
+        CSmlDmBmCommandElement* nameCmd( NULL );
+      
+        snapCmd = aSettings.NodeBuf()[0];
+        startInd = 1;
+
+        // find name command
+        for ( TInt i( 0 ); i < aSettings.NodeBuf().Count(); i++)
+            {
+            if ( aSettings.NodeBuf()[i]->Leaf() && 
+                 !aSettings.NodeBuf()[i]->LastUriSeg()->Compare( KNSmlDmBMAdapterName ) )
+                {
+                nameCmd = aSettings.NodeBuf()[i];
+                nameCmdInd = i;
+                break;
+                }
+            }
+        // Snap can be created when name cmd exists
+        if ( snapCmd && nameCmd )
+            {
+            HBufC* name = HBufC::NewLC( nameCmd->Data()->Size() );
+            TPtr namePtr = name->Des();
+            CnvUtfConverter::ConvertToUnicodeFromUtf8( namePtr, *nameCmd->Data() );
+            snap = iCmManagerExt.CreateDestinationL( namePtr );
+            CleanupStack::PopAndDestroy( name );
+            CleanupClosePushL( snap );
+                              
+            snap.UpdateL();
+            snapCmd->SetStatus( CSmlDmAdapter::EOk );
+            nameCmd->SetStatus( CSmlDmAdapter::EOk );
+            snapCmd->SetExecuted( ETrue );
+            nameCmd->SetExecuted( ETrue );
+            aSettings.SetLuid( snap.Id() );
+            }
+        else
+            {
+            BMADAPTERLOGSTRING( "StoreSnapL: Error, SNAP doesn't have necessary data and can't be stored" )
+            return;
+            }
+        }
+    // existing SNAP
+    else
+        {
+        snap = iCmManagerExt.DestinationL( aSettings.Luid() );
+        CleanupClosePushL( snap );
+        }
+    snapId = snap.Id();
+    TInt err( KErrNone );
+    // execute all remaining commands for the snap 
+    // starting after add node cmd
+    for ( TInt i( startInd ); i < aSettings.NodeBuf().Count(); i++ )
+        {
+        // name command is already executed -> skipped
+        if ( i != nameCmdInd )
+            {
+            CSmlDmBmCommandElement* currentCmd = aSettings.NodeBuf()[i];
+            // handle leaf commands
+            // leaves are trapped and if possible 
+            // execution continues with remaining commands
+            if ( currentCmd->Leaf() )
+                {
+                // name
+                if ( !currentCmd->LastUriSeg()->Compare( KNSmlDmBMAdapterName() ) )
+                    {
+                    // name is set more than once within same message
+                    TRAP( err, ExecuteNameCmdL( *currentCmd, snap ) );
+                    }
+                // metadata 
+                else if ( !currentCmd->LastUriSeg()->Compare( KNSmlDmBMAdapterMetadata ) )
+                    {
+                    TRAP( err, ExecuteMetadataCmdL( *currentCmd, snap ) );
+                    }
+                // protected
+                else if ( !currentCmd->LastUriSeg()->Compare( KNSmlDmBMAdapterProtected ) )
+                    {
+                    TRAP( err, ExecuteProtectionCmdL( *currentCmd, snap ) );
+                    }
+                // hidden
+                else if ( !currentCmd->LastUriSeg()->Compare( KNSmlDmBMAdapterHidden ) )
+                    {
+                    TRAP( err, ExecuteHiddenCmdL( *currentCmd, snap ) );
+                    }
+                // iap list 
+                else if ( !currentCmd->LastUriSeg()->Compare( KNSmlDmBMAdapterIAPPriorityList ) )
+                    {
+                    TRAP( err, ExecuteIapsCmdL( *currentCmd, snap ) );
+                    }
+                // embedded snap  
+                else if ( !currentCmd->LastUriSeg()->Compare( KNSmlDmBMAdapterEmbeddedSNAP ) )
+                    {
+                    TRAP( err, ExecuteEmbeddedSnapCmdL( *currentCmd, snap ) );
+                    }
+                else
+                    {
+                    // invalid node
+                    BMADAPTERLOGSTRING( "StoreSnapL: Error, Invalid node name" )
+                    currentCmd->SetStatus( CSmlDmAdapter::ENotFound );
+                    err = KErrNone;
+                    }
+                }
+            // snap node    
+            else
+                {
+                TRAP( err, ExecuteSnapCmdL( *currentCmd, snap.Id() ) );
+                // no more commands will be executed
+                // after snap is deleted
+                if( currentCmd->CmdType() == CNSmlDmBmAdapter::EDeleteCmd )
+                    {
+                    break;
+                    }
+                }
+  
+            // handle errors, check if execution may continue
+            if( err != KErrNone )
+                {
+                // cases where not worth continuing
+                // attempt to return status codes however
+                if( err == KErrNoMemory )
+                    {
+                    currentCmd->SetStatus( CSmlDmAdapter::ENoMemory );
+                    currentCmd->SetExecuted( ETrue );
+                    break;
+                    }
+                else if( err == KErrDiskFull )
+                    {
+                    currentCmd->SetStatus( CSmlDmAdapter::EDiskFull );
+                    currentCmd->SetExecuted( ETrue );
+                    break;
+                    }
+                // cases where command execution continues
+                else if( err == KErrNotFound )
+                    {
+                    currentCmd->SetStatus( CSmlDmAdapter::ENotFound );
+                    }
+                else if( err == KErrArgument )
+                    {
+                    currentCmd->SetStatus( CSmlDmAdapter::EInvalidObject );
+                    }
+                else
+                    {
+                    currentCmd->SetStatus( CSmlDmAdapter::EError );
+                    }
+                // if error occurred, reopen snap to dismis any changes
+                // continue with rest of buffered commands    
+                CleanupStack::PopAndDestroy( &snap );
+                snap = iCmManagerExt.DestinationL( snapId );
+                CleanupClosePushL( snap );
+                }
+            // if leaf cmd execution was successful and data written -> update the snap
+            else if( currentCmd->Leaf() &&
+                currentCmd->Status() == CSmlDmAdapter::EOk && 
+                currentCmd->CmdType() != CNSmlDmBmAdapter::EGetCmd && 
+                currentCmd->CmdType() != CNSmlDmBmAdapter::EGetSizeCmd )
+                {
+                snap.UpdateL();
+                }
+            else
+                {
+                BMADAPTERLOGSTRING( 
+                    "StoreSnapL: Leaf cmd execution unsuccessful" )
+                }
+            currentCmd->SetExecuted( ETrue );
+
+            }
+        }
+    CleanupStack::PopAndDestroy( &snap );
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::ExecuteCmdL
+// Executes a single command
+// -----------------------------------------------------------------------------
+void CNSmlDmBmSettingStore::ExecuteCmdL( CSmlDmBmCommandElement& aCmd, TUint aLuid)
+    {
+    if( !aCmd.Leaf() )
+        {
+        ExecuteSnapCmdL( aCmd, aLuid );
+        }
+    else 
+        {
+        // snap can be opened
+        RCmDestinationExt snap = iCmManagerExt.DestinationL( aLuid );
+        CleanupClosePushL( snap );
+        // name
+        if ( !aCmd.LastUriSeg()->Compare( KNSmlDmBMAdapterName ) )
+            {
+            ExecuteNameCmdL( aCmd, snap );
+            }
+        // iap list
+        else if ( !aCmd.LastUriSeg()->Compare( KNSmlDmBMAdapterIAPPriorityList ) )
+            {
+            ExecuteIapsCmdL( aCmd, snap );
+            } 
+        // metadata
+        else if ( !aCmd.LastUriSeg()->Compare( KNSmlDmBMAdapterMetadata ) )
+            {
+            ExecuteMetadataCmdL( aCmd, snap ); 
+            } 
+        // protected
+        else if ( !aCmd.LastUriSeg()->Compare( KNSmlDmBMAdapterProtected ) )
+            {
+            ExecuteProtectionCmdL( aCmd, snap ); 
+            }
+        // hidden 
+        else if ( !aCmd.LastUriSeg()->Compare( KNSmlDmBMAdapterHidden ) )
+            {
+            ExecuteHiddenCmdL( aCmd, snap ); 
+            }
+        // embedded snap
+        else if ( !aCmd.LastUriSeg()->Compare( KNSmlDmBMAdapterEmbeddedSNAP ) )
+            {
+            ExecuteEmbeddedSnapCmdL( aCmd, snap );
+            }
+        else
+            {
+            // invalid node
+            BMADAPTERLOGSTRING( "ExecuteCmdL: Error, Invalid node name" )
+            aCmd.SetStatus( CSmlDmAdapter::ENotFound );
+            }
+        // update snap if necessary              
+        if( aCmd.Status() == CSmlDmAdapter::EOk &&
+            aCmd.CmdType() != CNSmlDmBmAdapter::EGetCmd && 
+            aCmd.CmdType() != CNSmlDmBmAdapter::EGetSizeCmd)
+            {
+            snap.UpdateL();
+            }
+        aCmd.SetExecuted( ETrue );
+        CleanupStack::PopAndDestroy( &snap );
+        }
+    }
+
+   
+// -----------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::GetSnapsL
+// Fetches all snap ids
+// -----------------------------------------------------------------------------
+void CNSmlDmBmSettingStore::GetSnapsL( RArray<TUint32>& aLUIDArray )
+        {
+        iCmManagerExt.AllDestinationsL( aLUIDArray);
+        }
+ 
+// -----------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::ExecuteSnapCmdL
+// Executes a command for snap node. Either delete or get, adds are handled 
+// in StoreSNAPL
+// -----------------------------------------------------------------------------
+void CNSmlDmBmSettingStore::ExecuteSnapCmdL( CSmlDmBmCommandElement& aCmd, TUint aLuid )
+    {
+    RCmDestinationExt snap = iCmManagerExt.DestinationL( aLuid );
+    CleanupClosePushL( snap );
+    if ( aCmd.CmdType() == CNSmlDmBmAdapter::EGetCmd )
+        {
+        TBool found( EFalse );
+        // get child node list
+
+        // check if snap has embedded snap        
+        for ( TInt i(0), c = snap.ConnectionMethodCount(); i < c; i++ )
+            {
+            RCmConnectionMethodExt cm = snap.ConnectionMethodL( i );
+            if ( cm.GetBoolAttributeL( CMManager::ECmDestination ) )
+                {
+                found = ETrue;
+                break;
+                }
+            }
+        if( found )
+            {
+            aCmd.SetDataL( KNSmlDmBMAllLeafNodes );
+            }
+        else
+            {
+            aCmd.SetDataL( KNSmlDmBMAllLeafNodesNoEmbedded );
+            }
+
+        aCmd.SetStatus( CSmlDmAdapter::EOk );
+        aCmd.SetExecuted( ETrue );
+        CleanupStack::PopAndDestroy( &snap );
+        }
+    else if ( aCmd.CmdType() == CNSmlDmBmAdapter::EDeleteCmd )
+        {
+        snap.DeleteLD();
+        aCmd.SetStatus( CSmlDmAdapter::EOk );
+        aCmd.SetExecuted( ETrue );
+        CleanupStack::Pop( &snap );
+        }
+    else
+        {
+        BMADAPTERLOGSTRING( "ExecuteSnapCmdL: Error, Invalid cmd type" )
+        aCmd.SetStatus( CSmlDmAdapter::EError );
+        CleanupStack::PopAndDestroy( &snap );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::ExecuteIapsCmdL
+// Executes an iap list command (add or get).
+// ---------------------------------------------------------------------------
+//    
+void CNSmlDmBmSettingStore::ExecuteIapsCmdL( CSmlDmBmCommandElement& aCmd, 
+                                             RCmDestinationExt& aSnap )
+    {
+    // for add command replace the list of iaps with the new one
+    if ( aCmd.CmdType() == CNSmlDmBmAdapter::EAddCmd )
+        {
+        // remove old iaps
+        for( TInt i(0); i < aSnap.ConnectionMethodCount(); )
+            {
+            RCmConnectionMethodExt cm = aSnap.ConnectionMethodL( i );
+            // if iap, remove
+            if ( !cm.GetBoolAttributeL( CMManager::ECmDestination ) )
+                {
+                aSnap.RemoveConnectionMethodL( cm );
+                }
+            // otherwise skip the ebedded snap entry  
+            else
+                {
+                i++;
+                }
+            }
+        // add new list of iaps 
+        RArray<TUint> iaps = iAdapter->GetIdArrayL( *aCmd.Data() );
+        CleanupClosePushL( iaps );
+        TInt wildcard(0);
+        for ( TInt i( 0 ); i < iaps.Count(); i++ )
+            {
+            RCmConnectionMethodExt cm = iCmManagerExt.ConnectionMethodL( iaps[i] );
+            aSnap.AddConnectionMethodL( cm );
+            if ( aSnap.PriorityL( cm ) != CMManager::KDataMobilitySelectionPolicyPriorityWildCard )
+                {
+                // set the priority of iap as it's index in the list
+                // but preceding any iaps with wildcard priority.
+                aSnap.ModifyPriorityL( cm, i - wildcard );
+                }
+            else
+                {
+                wildcard++;
+                }
+            }
+        aCmd.SetStatus( CSmlDmAdapter::EOk );
+        CleanupStack::PopAndDestroy( &iaps );
+        }
+    // for get command fetch the list of iaps
+    else if ( aCmd.CmdType() == CNSmlDmBmAdapter::EGetCmd || 
+              aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+        {
+        RArray<TUint> ids;
+        CleanupClosePushL( ids );
+        for ( TInt i(0), c = aSnap.ConnectionMethodCount(); i < c; i++ )
+            {
+            // if not embedded snap or hidden, insert into iap list 
+            // (hidden iaps not handled by internet adapter, so link won't be found)
+            if( !aSnap.ConnectionMethodL(i).GetBoolAttributeL( CMManager::ECmDestination ) &&
+                !aSnap.ConnectionMethodL(i).GetBoolAttributeL( CMManager::ECmHidden ) )
+                {
+                ids.Insert( aSnap.ConnectionMethodL(i).GetIntAttributeL( 
+                                                       CMManager::ECmIapId ), i );
+                }
+            }
+        if ( ids.Count() > 0)
+            {
+            HBufC8* iapList = iAdapter->GetIapListL( ids );
+            CleanupStack::PushL( iapList );
+            aCmd.SetDataL( *iapList );
+            CleanupStack::PopAndDestroy( iapList );
+            }
+        else
+            {
+            aCmd.SetDataL( KNullDesC8 );
+            }
+        CleanupStack::PopAndDestroy( &ids );
+        // for size command, set the command data to be the 
+        // size of the fetched data
+        if( aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+            {
+            HBufC8* size = iAdapter->IntToDes8L( aCmd.Data()->Size() );
+            CleanupStack::PushL( size );
+            aCmd.SetDataL( *size );
+            CleanupStack::PopAndDestroy( size );
+            }
+        aCmd.SetStatus( CSmlDmAdapter::EOk );
+        aCmd.SetExecuted( ETrue );
+        }
+    else
+        {
+        // unsupported command
+        // this is checked by framework
+        aCmd.SetStatus( CSmlDmAdapter::EError );
+        BMADAPTERLOGSTRING( "ExecuteIapsCmdL: Error, Only Add, Get and Get size commands supported" )
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::ExecuteProtectionCmdL
+// Executes an protected command (add or get).
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmBmSettingStore::ExecuteProtectionCmdL( CSmlDmBmCommandElement& aCmd, 
+                                                   RCmDestinationExt& aSnap )
+    {
+    if ( aCmd.CmdType() == CNSmlDmBmAdapter::EAddCmd )
+        {
+        __UHEAP_MARK;
+        TInt data( iAdapter->DesToIntL( *aCmd.Data() ) );
+        // is proper protection level
+        if ( data == CMManager::EProtLevel0 )
+            {
+            aSnap.SetProtectionL( CMManager::EProtLevel0 );
+            aCmd.SetStatus( CSmlDmAdapter::EOk );
+            }
+        else if ( data == CMManager::EProtLevel1 )
+            {
+            aSnap.SetProtectionL( CMManager::EProtLevel1 );
+            aCmd.SetStatus( CSmlDmAdapter::EOk );
+            }
+        else if ( data == CMManager::EProtLevel2 )
+            {
+            aSnap.SetProtectionL( CMManager::EProtLevel2 );
+            aCmd.SetStatus( CSmlDmAdapter::EOk );
+            }
+        else
+            {
+            aCmd.SetStatus( CSmlDmAdapter::EInvalidObject );
+            }
+        __UHEAP_MARKEND;
+        }
+    else if ( aCmd.CmdType() == CNSmlDmBmAdapter::EGetCmd ||
+              aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+        {
+        HBufC8* data = iAdapter->IntToDes8L( aSnap.ProtectionLevel() );
+        CleanupStack::PushL( data );
+        aCmd.SetDataL( *data );
+        CleanupStack::PopAndDestroy( data );
+        
+        // for size command, set the command data to be the 
+        // size of the fetched data
+        if( aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+            {
+            HBufC8* size = iAdapter->IntToDes8L( aCmd.Data()->Size() );
+            CleanupStack::PushL( size );
+            aCmd.SetDataL( *size );
+            CleanupStack::PopAndDestroy( size );
+            }
+
+        aCmd.SetStatus( CSmlDmAdapter::EOk );
+        aCmd.SetExecuted( ETrue );
+        }
+    else
+        {
+        // unsupported command
+        // this is checked by framework
+        aCmd.SetStatus( CSmlDmAdapter::EError );
+        BMADAPTERLOGSTRING( "ExecuteProtectionCmdL: Error, Only Add, Get and Get size commands supported" )
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::ExecuteHiddenCmdL
+// Executes hidden command (add or get)
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmBmSettingStore::ExecuteHiddenCmdL( CSmlDmBmCommandElement& aCmd, 
+                                               RCmDestinationExt& aSnap )
+    {
+    if ( aCmd.CmdType() == CNSmlDmBmAdapter::EAddCmd )
+        {
+        __UHEAP_MARK;
+        TBool data; 
+        if( iAdapter->DesToBool( *aCmd.Data(), data ) )
+            {
+            aSnap.SetHiddenL( data );
+            aCmd.SetStatus( CSmlDmAdapter::EOk );
+            }
+        else
+            {
+            aCmd.SetStatus( CSmlDmAdapter::EInvalidObject );
+            }
+        __UHEAP_MARKEND;
+        }
+    else if ( aCmd.CmdType() == CNSmlDmBmAdapter::EGetCmd ||
+              aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+        {
+        HBufC8* data = iAdapter->BoolToDes8LC( aSnap.IsHidden() );
+        aCmd.SetDataL( *data );
+        CleanupStack::PopAndDestroy( data ); 
+        // for size command, set the command data to be the 
+        // size of the fetched data
+        if( aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+            {
+            HBufC8* size = iAdapter->IntToDes8L( aCmd.Data()->Size() );
+            CleanupStack::PushL( size );
+            aCmd.SetDataL( *size );
+            CleanupStack::PopAndDestroy( size );
+            }
+        aCmd.SetStatus( CSmlDmAdapter::EOk );
+        aCmd.SetExecuted( ETrue );
+        }
+    else
+        {
+        // unsupported command
+        // this is checked by framework
+        aCmd.SetStatus( CSmlDmAdapter::EError );
+        BMADAPTERLOGSTRING( "ExecuteHiddenCmdL: Error, Only Add, Get and Get size commands supported" )
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::ExecuteMetadataCmdL
+// Executes metadata command (add or get)
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmBmSettingStore::ExecuteMetadataCmdL( CSmlDmBmCommandElement& aCmd, 
+                                                 RCmDestinationExt& aSnap )
+    {
+    if ( aCmd.CmdType() == CNSmlDmBmAdapter::EAddCmd )
+        {
+        __UHEAP_MARK;
+        
+        TInt data( iAdapter->DesToIntL( *aCmd.Data() ) );
+        // AND with inversed bit masks to check if data 
+        // has bits set that are not defined for metadata
+        if( ( data & 
+              ~CMManager::ESnapMetadataHighlight &
+              ~CMManager::ESnapMetadataHiddenAgent & 
+              ~CMManager::ESnapMetadataPurpose ) )
+            {
+            aCmd.SetStatus( CSmlDmAdapter::EError );
+            }
+        // set value for each metadata bit
+        else
+            {
+            aSnap.SetMetadataL( CMManager::ESnapMetadataHighlight, 
+                                CMManager::ESnapMetadataHighlight & data );
+            aSnap.SetMetadataL( CMManager::ESnapMetadataHiddenAgent, 
+                                CMManager::ESnapMetadataHiddenAgent & data );
+            aSnap.SetMetadataL( CMManager::ESnapMetadataPurpose, 
+                              ( CMManager::ESnapMetadataPurpose & data ) >> KShift8 );
+            aCmd.SetStatus( CSmlDmAdapter::EOk );
+            }
+        __UHEAP_MARKEND;
+        }
+    else if ( aCmd.CmdType() == CNSmlDmBmAdapter::EGetCmd ||
+              aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+        {
+        // get all metadata values
+        TInt metadata(0);
+        metadata = aSnap.MetadataL( CMManager::ESnapMetadataHighlight ) +
+                   aSnap.MetadataL( CMManager::ESnapMetadataHiddenAgent ) + 
+                 ( aSnap.MetadataL( CMManager::ESnapMetadataPurpose ) << KShift8 );
+        HBufC8* data = iAdapter->IntToDes8L( metadata );
+        CleanupStack::PushL( data );
+        aCmd.SetDataL( *data ); 
+        CleanupStack::PopAndDestroy( data );
+        
+        // for size command, set the command data to be the 
+        // size of the fetched data
+        if( aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+            {
+            HBufC8* size = iAdapter->IntToDes8L( aCmd.Data()->Size() );
+            CleanupStack::PushL( size );
+            aCmd.SetDataL( *size );
+            CleanupStack::PopAndDestroy( size );
+            }
+        aCmd.SetStatus( CSmlDmAdapter::EOk );
+        aCmd.SetExecuted( ETrue );
+        }
+    else
+        {
+        // unsupported command
+        // this is checked by framework
+        aCmd.SetStatus( CSmlDmAdapter::EError );
+        BMADAPTERLOGSTRING( "ExecuteMetadataCmdL: Error, Only Add, Get and Get size commands supported" )
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::ExecuteEmbeddedSnapCmdL
+// Executes embedded snap command (add, get or delete)
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmBmSettingStore::ExecuteEmbeddedSnapCmdL( CSmlDmBmCommandElement& aCmd, 
+                                                     RCmDestinationExt& aSnap )
+    {
+    if ( aCmd.CmdType() == CNSmlDmBmAdapter::EAddCmd )
+        {
+        // Remove ./ from beginning of the URI
+        TPtrC8 embeddedUri = aCmd.Data()->Mid( KNSmlDmBmAdapterURIPrefix().Length() );
+
+        // if the embedded snap is still in buffer it's stored here
+        iAdapter->StoreSnapIfBufferedL( embeddedUri );
+        // LUID mapping is assumed done by this time
+
+        // get SNAP id for the URI 
+        HBufC8* luid = iAdapter->GetLuidAllocL( embeddedUri );
+        CleanupStack::PushL( luid );
+        if ( luid->Size() > 0 )
+            {
+            TInt id = iAdapter->DesToIntL( *luid );
+
+            // open snap with the id
+            RCmDestinationExt embedded = iCmManagerExt.DestinationL( id );
+            CleanupClosePushL( embedded );
+
+            // check if snap has an existing embedded snap                       
+            for ( TInt i(0), c = aSnap.ConnectionMethodCount(); i < c; i++ )
+                {
+                RCmConnectionMethodExt cm = aSnap.ConnectionMethodL( i );
+                // remove existing embedded snap before adding new one
+                if ( cm.GetBoolAttributeL( CMManager::ECmDestination ) )
+                    {
+                    aSnap.DeleteConnectionMethodL( cm );
+                    break;
+                }
+            }
+            aSnap.AddEmbeddedDestinationL( embedded ); 
+            CleanupStack::PopAndDestroy( &embedded );
+            aCmd.SetStatus( CSmlDmAdapter::EOk );
+            }
+        else
+            {
+            // no luid for the uri
+            BMADAPTERLOGSTRING( "ExecuteEmbeddedSnapCmdL: No LUID found for embedded snap" )
+            aCmd.SetStatus( CSmlDmAdapter::EInvalidObject );
+            }
+        aCmd.SetExecuted( ETrue );
+        CleanupStack::PopAndDestroy( luid );
+        }
+    else if ( aCmd.CmdType() == CNSmlDmBmAdapter::EGetCmd ||
+              aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+        {
+        // get destination
+        TInt embeddedId( -1 );
+        for ( TInt i( 0 ), c = aSnap.ConnectionMethodCount(); i < c; i++ )
+            {
+            RCmConnectionMethodExt cm = aSnap.ConnectionMethodL( i );
+            // check if embedded
+            if ( cm.GetBoolAttributeL( CMManager::ECmDestination ) )
+                {
+                // get snap id
+                embeddedId = cm.GetIntAttributeL( CMManager::ECmId );
+
+                // CMManager::ECmId returns element id, 
+                // GetSnapUriFromLuidL needs record id
+                embeddedId = ( embeddedId & KCDMaskShowRecordId ) >> KShift8;
+
+                HBufC8* embeddedUri = iAdapter->GetSnapUriFromLuidL( embeddedId );
+                CleanupStack::PushL( embeddedUri );
+                
+                if( !embeddedUri )
+                    {
+                    embeddedId = -1;
+                    break;
+                    }
+                aCmd.SetDataL( *embeddedUri );
+                CleanupStack::PopAndDestroy( embeddedUri );
+                
+                // for size command, set the command data to be the 
+                // size of the fetched data
+                if( aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+                    {
+                    HBufC8* size = iAdapter->IntToDes8L( aCmd.Data()->Size() );
+                    CleanupStack::PushL( size );
+                    aCmd.SetDataL( *size );
+                    CleanupStack::PopAndDestroy( size );
+                    }
+                aCmd.SetStatus( CSmlDmAdapter::EOk );
+                aCmd.SetExecuted( ETrue );
+                break;
+                }
+            }
+        // if no embedded snap exists return not found
+        if ( embeddedId < 0 )
+            {
+            BMADAPTERLOGSTRING( "ExecuteEmbeddedSnapCmdL: Get, No embedded snap found" )
+            aCmd.SetStatus( CSmlDmAdapter::ENotFound );
+            aCmd.SetExecuted( ETrue );
+            }
+        }
+    else if ( aCmd.CmdType() == CNSmlDmBmAdapter::EDeleteCmd )
+        {
+        TBool found( EFalse);
+        for ( TInt i( 0 ), c = aSnap.ConnectionMethodCount(); i < c; i++ )
+            {
+            RCmConnectionMethodExt cm = aSnap.ConnectionMethodL( i );
+            // find embedded snap and delete it
+            if ( cm.GetBoolAttributeL( CMManager::ECmDestination ) )
+                {
+                found = ETrue;
+                aSnap.DeleteConnectionMethodL( cm );
+                aCmd.SetStatus( CSmlDmAdapter::EOk );
+                break;
+                }
+            }
+        if ( !found )
+            {
+            BMADAPTERLOGSTRING( "ExecuteEmbeddedSnapCmdL: Delete, No embedded snap found" )
+            aCmd.SetStatus( CSmlDmAdapter::ENotFound );
+            aCmd.SetExecuted( ETrue );
+            }
+        }
+    else    
+        {
+        // unsupported command
+        // this is checked by framework
+        aCmd.SetStatus( CSmlDmAdapter::EError );
+        aCmd.SetExecuted( ETrue );
+        BMADAPTERLOGSTRING( "ExecuteEmbeddedSnapCmdL: Error, command not supported" )
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmBmSettingStore::ExecuteNameCmdL
+// Executes name command (add or get )
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmBmSettingStore::ExecuteNameCmdL( CSmlDmBmCommandElement& aCmd, 
+                                             RCmDestinationExt& aSnap )
+    {
+    if ( aCmd.CmdType() == CNSmlDmBmAdapter::EAddCmd )
+        {
+        HBufC* name = HBufC::NewLC( aCmd.Data()->Size() );
+        TPtr namePtr = name->Des();
+        CnvUtfConverter::ConvertToUnicodeFromUtf8( namePtr, *aCmd.Data() );
+        aSnap.SetNameL( namePtr );
+        CleanupStack::PopAndDestroy( name );
+        aCmd.SetStatus( CSmlDmAdapter::EOk );
+        }
+    else if ( aCmd.CmdType() == CNSmlDmBmAdapter::EGetCmd ||
+              aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+        {
+        HBufC* data = aSnap.NameLC();
+        HBufC8* data8 = HBufC8::NewLC( data->Size() );
+        TPtr8 toPtr = data8->Des();
+        CnvUtfConverter::ConvertFromUnicodeToUtf8( toPtr, *data );
+        aCmd.SetDataL( *data8 );
+        CleanupStack::PopAndDestroy( data8 );
+        CleanupStack::PopAndDestroy( data );
+       
+        // for size command, set the command data to be the 
+        // size of the fetched data
+        if( aCmd.CmdType() == CNSmlDmBmAdapter::EGetSizeCmd )
+            {
+            HBufC8* size = iAdapter->IntToDes8L( aCmd.Data()->Size() );
+            CleanupStack::PushL( size );
+            aCmd.SetDataL( *size );
+            CleanupStack::PopAndDestroy( size );
+            }
+        aCmd.SetStatus( CSmlDmAdapter::EOk );
+        aCmd.SetExecuted( ETrue );
+        }
+    else    
+        {
+        // unsupported command
+        // this is checked by framework
+        aCmd.SetStatus( CSmlDmAdapter::EError );
+        BMADAPTERLOGSTRING( "ExecuteEmbeddedSnapCmdL: Error, Only Add, Get and Get size commands supported" )
+        }
+    }
+
--- a/omadmadapters/rom/omadmadapters.iby	Tue Jul 13 03:48:30 2010 +0530
+++ b/omadmadapters/rom/omadmadapters.iby	Tue Jul 13 03:51:25 2010 +0530
@@ -34,7 +34,7 @@
 #endif
 
 #ifdef FF_DM_STREAMING_ADAPTER
-REM ECOM_PLUGIN(nsmldmstreamingadapter.dll,nsmldmstreamingadapter.rsc)
+ECOM_PLUGIN(nsmldmstreamingadapter.dll,nsmldmstreamingadapter.rsc)
 #endif
 
 #ifdef FF_DM_BROWSER_ADAPTER
@@ -48,7 +48,7 @@
 #endif // __SYNCML_DS
 
 #ifdef __SYNCML_DM_EMAIL //  SyncML device management email settings plug-in
-REM ECOM_PLUGIN(nsmldmemailadapter.dll,nsmldmemailadapter.rsc)
+ECOM_PLUGIN(nsmldmemailadapter.dll,nsmldmemailadapter.rsc)
 #endif // __SYNCML_DM_EMAIL
 
 #ifdef __SYNCML_DM_MMS //  SyncML device management MMS settings plug-in
@@ -76,7 +76,7 @@
 ECOM_PLUGIN( nsmldmalwaysonadapter.dll, nsmldmalwaysonadapter.rsc )
 #endif // __ALWAYS_ONLINE_PDPCONTEXT2
 
-REM ECOM_PLUGIN( nsmldmbmadapter.dll, nsmldmbmadapter.rsc )
+ECOM_PLUGIN( nsmldmbmadapter.dll, nsmldmbmadapter.rsc )
 
 #ifdef FF_RUNTIME_DEVICE_CAPABILITY_CONFIGURATION
 REM ECOM_PLUGIN(dcmodmadapter.dll,dcmodmadapter.rsc)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/streamingadapter/bld/bld.inf	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,34 @@
+/*
+* ==============================================================================
+*  Name        : bld.inf
+*  Part of     : OMA DM Adapter
+*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   build info file for streaming adapter
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+
+../conf/streamingadapter.confml                    APP_LAYER_CONFML(streamingadapter.confml)
+../conf/streamingadapter_20024310.crml 	        APP_LAYER_CRML(streamingadapter_20024310.crml)
+
+PRJ_MMPFILES
+nsmlstreamingadapter.mmp
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/streamingadapter/bld/nsmlstreamingadapter.mmp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* ==============================================================================
+*  Name        : nsmldmstreamingadapter.mmp
+*  Part of     : nsmldmstreamingadapter
+*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of dm adapters
+* 	This is part of omadmextensions.
+*
+*/
+
+
+#include "defaultcaps.hrh"
+#include  <platform_paths.hrh>
+
+CAPABILITY      CAP_ECOM_PLUGIN
+TARGET          nsmldmstreamingadapter.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x20024310
+VENDORID        VID_DEFAULT
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+SOURCEPATH      ../src
+
+USERINCLUDE     ../inc 
+
+
+SOURCE          nsmlstreamingadapter.cpp
+
+START RESOURCE nsmldmstreamingadapter.rss
+TARGET nsmldmstreamingadapter.rsc
+LANGUAGE_IDS
+END
+
+LIBRARY         euser.lib 
+LIBRARY         ecom.lib 
+LIBRARY         nsmldebug.lib
+LIBRARY         nsmlagentcommon.lib
+LIBRARY         centralrepository.lib
+LIBRARY 	commdb.lib 
+LIBRARY     nsmldmiapmatcher.lib
+LIBRARY         mpsettengine.lib
+
+
+
+SMPSAFE
Binary file omadmadapters/streamingadapter/conf/streamingadapter.confml has changed
Binary file omadmadapters/streamingadapter/conf/streamingadapter_20024310.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/streamingadapter/inc/nsmlstreamingadapter.h	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,238 @@
+/*
+*  Name        : nsmldmstreamingadapter.h
+*  Part of     : nsmldmstreamingadapter
+*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of dm adapters
+* 	This is part of omadmextensions.
+*
+*/
+
+
+#ifndef __NSMLDMSTREAMINGADAPTER_H__
+#define __NSMLDMSTREAMINGADAPTER_H__
+
+// INCLUDES
+#include <e32base.h>
+#include <smldmadapter.h>
+#include "nsmldmconstants.h"
+
+const TInt KMaxLengthStreamingName = 255;
+const TInt KMaxLengthToProxy = 255;
+const TInt KMaxLengthNetInfo = 255;
+const TInt KMaxLengthTempInfo = 10;
+
+const TInt KMinPort = 1024;
+const TInt KMaxPort = 65535;
+const TInt KPortDiff = 5;
+const TUint KNSmlDMStreamingAdapterImplUid = 0x20024311;
+
+const TInt KMnMaxBwGPRS = 9050;
+const TInt KMxMaxBwGPRS = 40200;
+const TInt KMnSusBwGPRS = 6335;
+const TInt KMxSusBwGPRS = 28140;
+
+const TInt KMnMaxBwEGPRS = 44800;
+const TInt KMxMaxBwEGPRS = 108800;
+const TInt KMnSusBwEGPRS = 26880;
+const TInt KMxSusBwEGPRS = 65280;
+
+const TInt KMnMaxBwWCDMA = 64000;
+const TInt KMxMaxBwWCDMA = 384000;
+const TInt KMnSusBwWCDMA = 44800;
+const TInt KMxSusBwWCDMA = 268800;
+
+const TInt KMnMaxBwHSDPA = 600000;
+const TInt KMxMaxBwHSDPA = 3600000;
+const TInt KMnSusBwHSDPA = 420000;
+const TInt KMxSusBwHSDPA = 2520000;
+
+const TInt KMnMaxBwWLAN = 64000;
+const TInt KMxMaxBwWLAN = 3000000;
+const TInt KMnSusBwWLAN = 44800;
+const TInt KMxSusBwWLAN = 2100000;
+
+const TInt KMnMaxBwCDMA = 9050;
+const TInt KMxMaxBwCDMA = 40200;
+const TInt KMnSusBwCDMA = 6335;
+const TInt KMxSusBwCDMA = 28140;
+
+const TInt KMnMaxBwCDMA2000 = 9050;
+const TInt KMxMaxBwCDMA2000 = 40200;
+const TInt KMnSusBwCDMA2000 = 6335;
+const TInt KMxSusBwCDMA2000 = 28140;
+
+
+/*
+const TInt KMnMaxBw = 5000;
+
+const TInt KMnMaxBwGPRS = 99995; // <
+const TInt KMnMaxBw3G = 1920001; // < 
+const TInt KMnMaxBwEGPRS = 199995; // < 
+const TInt KMnMaxBwWLAN = 4300001; // <
+const TInt KMnMaxBwHSDPA = 3999995; // < 
+const TInt KMnMaxBwCDMA = 99995; // <
+const TInt KMnMaxBwCDMA2000 = 153601; // < */
+
+
+
+
+// MACROS
+
+class CMPSettingsModel;
+
+// the DDF version must be changed if any changes in DDF structure 
+// ( built in DDFStructureL() function )
+_LIT8( KNSmlDMStreamingAdapterDDFVersion, "1.0" ); 
+
+_LIT8 (KNSmlURISeparator ,"/");
+
+_LIT8( KNSmlDMStreamingAdapterTextPlain, "text/plain" );
+_LIT8( KNSmlDMStreamingAdapterNodeName, "Streaming" );
+_LIT8( KNSmlDMStreamingAdapterDescription, "The parent object holding all Streaming Settings" );
+
+_LIT8( KNSmlDMStreamingAdapterVal, "Name/To-Proxy/To-NapID/NetInfo/MIN-UDP-PORT/MAX-UDP-PORT" );
+_LIT8( KNSmlDMStreamingAdapterName, "Name" );
+_LIT8( KNSmlDMStreamingAdapterNameDescription, "Streaming configuration name" );
+_LIT8( KNSmlDMStreamingAdapterToProxy, "To-Proxy" );
+_LIT8( KNSmlDMStreamingAdapterToProxyDescription, "Streaming proxy server ID" );
+_LIT8( KNSmlDMStreamingAdapterToNapID, "To-NapID" );
+_LIT8( KNSmlDMStreamingAdapterToNapIDDescription, "The APN that is used for Streaming" );
+_LIT8( KNSmlDMStreamingAdapterNetInfo, "NetInfo" );
+_LIT8( KNSmlDMStreamingAdapterNetInfoVal, "GPRS/EGPRS/WCDMA/CDMA/CDMA2000/WLAN/HSDPA" );
+
+_LIT8( KNSmlDMStreamingAdapterNetInfoGPRS, "GPRS" );
+_LIT8( KNSmlDMStreamingAdapterNetInfoEGPRS, "EGPRS" );
+_LIT8( KNSmlDMStreamingAdapterNetInfoWCDMA, "WCDMA" );
+_LIT8( KNSmlDMStreamingAdapterNetInfoCDMA2000, "CDMA2000" );
+_LIT8( KNSmlDMStreamingAdapterNetInfoWLAN, "WLAN" );
+_LIT8( KNSmlDMStreamingAdapterNetInfoCDMA, "CDMA" );
+_LIT8( KNSmlDMStreamingAdapterNetInfoHSDPA, "HSDPA" );
+
+_LIT8( KNSmlDMStreamingAdapterNetInfoDescription, "The parameter which contains networks information" );
+_LIT8( KNSmlDMStreamingAdapterMinUdpPort, "MIN-UDP-PORT" );
+_LIT8( KNSmlDMStreamingAdapterMinUdpPortDescription, "The min port number used for streaming" );
+_LIT8( KNSmlDMStreamingAdapterMaxUdpPort, "MAX-UDP-PORT" );
+_LIT8( KNSmlDMStreamingAdapterMaxUdpPortDescription, "The max port number used for streaming" );
+
+_LIT8( KCommaSep,",");
+
+
+
+// CLASS DECLARATION
+class CNSmlDmStreamingAdapter : public CSmlDmAdapter
+    {
+public: // constructors and destructor
+    static CNSmlDmStreamingAdapter* NewL(MSmlDmCallback* aDmCallback );
+    static CNSmlDmStreamingAdapter* NewLC(MSmlDmCallback* aDmCallback );
+
+    virtual ~CNSmlDmStreamingAdapter();
+
+//private: ///new functions
+public: ///new functions
+    
+    void SetNetInfoL(const TDesC8& aObject,const TDesC8 &aDes,TDataBearer aBearer,const TInt aStatusRef,const TInt aMnMaxBw, const TInt aMxMaxBw,const TInt aMnSusBw, const TInt aMxSusBw);
+		
+    CSmlDmAdapter::TError GetNetInfoL(CBufBase& aObject,TDataBearer aBearer,const TDesC8 &aDes);
+
+    void SetLeafPropertiesL( MSmlDmDDFObject& aObject, 
+                 const TSmlDmAccessTypes& aAccessTypes, 
+                 const TDesC8& aDescription ) const;
+    CNSmlDmStreamingAdapter(TAny* aEcomArguments);
+    /**
+     * Two-phased constructor.
+     */
+    void ConstructL();
+    CSmlDmAdapter::TError FetchLeafObjectL( const TDesC8& aURI, CBufBase& aObject );
+    
+    void SetMinUDPPortL(const TDesC8& aObject,const TInt aStatusRef);
+    
+    void SetMaxUDPPortL(const TDesC8& aObject,const TInt aStatusRef);
+    
+    void SetDefaultApL(const TDesC8& aObject,const TInt aStatusRef);
+    
+    CSmlDmAdapter::TError GetDefaultApL(CBufBase& aObject);
+    
+//private: // from base classes
+public: // from base classes
+    // Adapter interface from CSmlDmAdapter
+    void DDFVersionL( CBufBase& aDDFVersion );
+    void DDFStructureL( MSmlDmDDFObject& aDDF );
+    void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
+                const TDesC8& aObject, const TDesC8& aType, 
+                const TInt aStatusRef );
+    void DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID, TInt aStatusRef ); 
+    void FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
+                   const TDesC8& aType, const TInt aResultsRef, 
+                   const TInt aStatusRef ); 
+    void ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID, 
+                const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, 
+                const TInt aResultsRef, const TInt aStatusRef );  
+    void AddNodeObjectL( const TDesC8& aURI, const TDesC8& aParentLUID, 
+                 const TInt aStatusRef );
+    
+    void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
+                RWriteStream*& aStream, const TDesC8& aType, 
+                const TInt aStatusRef );
+    void FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, 
+                   const TDesC8& aType, const TInt aResultsRef, 
+                   const TInt aStatusRef );
+     
+    void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID,
+                          const TDesC8& aArgument, 
+                          const TDesC8& aType,
+                          const TInt aStatusRef );
+                                  
+    void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID,
+                          RWriteStream*& aStream, 
+                          const TDesC8& aType,
+                          const TInt aStatusRef );
+    
+    void CopyCommandL( const TDesC8& aTargetURI, const TDesC8& aTargetLUID,
+                       const TDesC8& aSourceURI, 
+                       const TDesC8& aSourceLUID,
+                       const TDesC8& aType, TInt aStatusRef );
+    void StartAtomicL();
+    void CommitAtomicL();
+    void RollbackAtomicL();
+    TBool StreamingSupport( TInt& aItemSize );
+    void StreamCommittedL();
+    void CompleteOutstandingCmdsL();
+    
+    static void Cleanup( TAny* aAny );
+    
+    /**
+    * Fills the given information to a DDF Object node.
+    * @param aNode The node whose data is filled.
+    * @param aAccTypes The access types of the node.
+    * @param aOccurance Occurance of the node.
+    * @param aScope The scope of the node.
+    * @param aFormat The format of the node's data, i.e. node/chr/bin/...
+    * @param aDescription Informal description of the node.
+    */
+    void FillNodeInfoL( MSmlDmDDFObject& aNode, 
+                        const TSmlDmAccessTypes& aAccTypes, 
+                        MSmlDmDDFObject::TOccurence aOccurrence, 
+                        MSmlDmDDFObject::TScope aScope, 
+                        MSmlDmDDFObject::TDFFormat aFormat,
+                        const TDesC8& aDescription ) const;
+    
+private:
+    MSmlDmCallback* iDmCallback;
+    
+    CMPSettingsModel* iModel;
+    
+    };
+
+#endif // __NSMLDMSTREAMINGADAPTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/streamingadapter/inc/streamingadapterCRKeys.h	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,36 @@
+/*
+*  Name        : streamingadapterCRKeys.h
+*  Part of     : streamingadapter
+*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of dm adapters
+* 	This is part of omadmextensions.
+*
+*/
+
+#ifndef STREAMINGADAPTERCRKEYS_H
+#define STREAMINGADAPTERCRKEYS_H
+
+// CONSTANTS
+
+// key uid
+const TUid KCRUidStreamingAdapter = {0x20024310};
+
+// Configuration Name for Streaming Adapter
+const TUint32 KStreamingConfigurationName = 0x00000001;
+
+
+#endif // STREAMINGADAPTERCRKEYS_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/streamingadapter/src/nsmldmstreamingadapter.rss	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,49 @@
+/*
+* ============================================================================
+*  Name     : nsmlstreaming.rss
+*  Part of  : streaming adapter
+*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of dm adapters
+* 	This is part of omadmextensions.
+*
+*/
+
+CHARACTER_SET UTF8
+
+#include <registryinfo.rh>
+#include "nsmldmconstants.h"
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x20024310;//The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = KNSmlDMInterfaceUid; // DM interface UID
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x20024311; // DM browser implementation UID
+                version_no = 1; 
+                display_name = "";
+                default_data = "";
+                opaque_data = "";
+                }
+            };
+          }
+      };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/streamingadapter/src/nsmlstreamingadapter.cpp	Tue Jul 13 03:51:25 2010 +0530
@@ -0,0 +1,1380 @@
+/*
+*  Name        : nsmldmstreamingadapter.cpp
+*  Part of     : nsmldmstreamingadapter
+*  Interface   : ecom / SmlDmAdapter
+*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of dm adapters
+* 	This is part of omadmextensions.
+*
+*/
+
+
+//INCLUDE FILES
+#include <implementationproxy.h> // For TImplementationProxy definition
+#include <centralrepository.h>
+#include <commdb.h>
+#include <cdbcols.h>             // CommsDB columname defs
+#include <e32base.h>
+#include <e32std.h>
+#include <e32const.h>
+#include <mpsettingsmodel.h>
+#include <e32msgqueue.h>
+
+
+#include "nsmldebug.h"
+#include "nsmlconstants.h"
+#include "nsmldmconst.h"
+#include "nsmlstreamingadapter.h"
+#include "nsmldmiapmatcher.h"
+#include "streamingadapterCRKeys.h"
+
+#ifndef __WINS__
+// This lowers the unnecessary compiler warning (armv5) to remark.
+// "Warning:  #174-D: expression has no effect..." is caused by 
+// DBG_ARGS8 macro in no-debug builds.
+#pragma diag_remark 174
+#endif
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDmStreamingAdapter* CNSmlDmStreamingAdapter::NewL( )
+// -----------------------------------------------------------------------------
+CNSmlDmStreamingAdapter* CNSmlDmStreamingAdapter::NewL(MSmlDmCallback* aDmCallback )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::NewL(): begin");
+    CNSmlDmStreamingAdapter* self = NewLC( aDmCallback );
+    CleanupStack::Pop();
+    _DBG_FILE("CNSmlDmStreamingAdapter::NewL(): end");
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmStreamingAdapter* CNSmlDmStreamingAdapter::NewLC( )
+// -----------------------------------------------------------------------------
+CNSmlDmStreamingAdapter* CNSmlDmStreamingAdapter::NewLC(MSmlDmCallback* aDmCallback )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::NewLC(): begin");
+    CNSmlDmStreamingAdapter* self = new (ELeave) CNSmlDmStreamingAdapter(aDmCallback);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    self->iDmCallback = aDmCallback;
+    _DBG_FILE("CNSmlDmStreamingAdapter::NewLC(): end");
+    return self;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDmStreamingAdapter::~CNSmlDmStreamingAdapter()
+// -----------------------------------------------------------------------------
+CNSmlDmStreamingAdapter::~CNSmlDmStreamingAdapter()
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::~CNSmlDmStreamingAdapter(): begin");
+    if(iModel)
+        delete iModel;
+    _DBG_FILE("CNSmlDmStreamingAdapter::~CNSmlDmStreamingAdapter(): end");
+    }
+    
+// -----------------------------------------------------------------------------
+// CNSmlDmStreamingAdapter::CNSmlDmStreamingAdapter()
+// -----------------------------------------------------------------------------
+
+CNSmlDmStreamingAdapter::CNSmlDmStreamingAdapter(TAny* aEcomArguments):CSmlDmAdapter(aEcomArguments)
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::CNSmlDmStreamingAdapter(aEcomArguments): begin");
+    _DBG_FILE("CNSmlDmStreamingAdapter::CNSmlDmStreamingAdapter(aEcomArguments): end"); 
+    }
+
+
+void CNSmlDmStreamingAdapter::ConstructL()
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::ConstructL: begin");
+        if ( !iModel )
+                {
+                RImplInfoPtrArray impl; 
+                CleanupStack::PushL( TCleanupItem( Cleanup, &impl ) );
+                CMPSettingsModel::ListImplementationsL( impl );
+                if( impl.Count() > 0 )
+                    {
+                    _DBG_FILE("CStreamingAdapter::ConstructL: Creating CMPSettingsModel");
+                    // using the first available implementation
+                    iModel= CMPSettingsModel::NewL( impl[0]->ImplementationUid() );
+                    _DBG_FILE("CStreamingAdapter::ConstructL: Creating CMPSettingsModel Done" );
+                    }
+                CleanupStack::PopAndDestroy(); // implArray
+                // Load default values
+                //iModel->LoadSettingsL(EConfigDefault);
+                if(iModel)
+                	iModel->LoadSettingsL(EConfigUser);
+                }
+        _DBG_FILE("CNSmlDmStreamingAdapter::ConstructL: end");
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDmStreamingAdapter::SetLeafPropertiesL()
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::SetLeafPropertiesL( MSmlDmDDFObject& aObject, 
+                                                const TSmlDmAccessTypes& aAccessTypes, 
+                                                const TDesC8& aDescription ) const
+    {
+    aObject.SetAccessTypesL( aAccessTypes );
+    aObject.SetScopeL( MSmlDmDDFObject::EPermanent );
+    aObject.SetDFFormatL( MSmlDmDDFObject::EChr );
+    aObject.AddDFTypeMimeTypeL( KNSmlDMStreamingAdapterTextPlain );
+    aObject.SetDescriptionL( aDescription );
+    }
+
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::DDFVersionL()
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::DDFVersionL(CBufBase& aDDFVersion)
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFVersionL(TDes& aDDFVersion): begin");
+    aDDFVersion.InsertL(0,KNSmlDMStreamingAdapterDDFVersion);
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFVersionL(TDes& aDDFVersion): end");
+    }
+
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::DDFStructureL()
+//
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): begin");
+    
+    TSmlDmAccessTypes accessTypes;
+    accessTypes.SetGet();
+    
+    TSmlDmAccessTypes accessNoDeleteTypes;
+    accessNoDeleteTypes.SetGet();
+    accessNoDeleteTypes.SetReplace();
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterNodeName");
+    MSmlDmDDFObject& dmStreamingAdap = aDDF.AddChildObjectL( KNSmlDMStreamingAdapterNodeName );
+    dmStreamingAdap.SetAccessTypesL( accessTypes ); 
+    dmStreamingAdap.SetScopeL( MSmlDmDDFObject::EPermanent );
+    dmStreamingAdap.SetDescriptionL( KNSmlDMStreamingAdapterDescription );
+  
+  
+  	_DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterName");
+    MSmlDmDDFObject& confName = dmStreamingAdap.AddChildObjectL(KNSmlDMStreamingAdapterName);
+    FillNodeInfoL(  confName, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterNameDescription );
+    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterToProxy");
+    MSmlDmDDFObject& toProxyID = dmStreamingAdap.AddChildObjectL(KNSmlDMStreamingAdapterToProxy);
+    FillNodeInfoL(  toProxyID, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterToProxyDescription );
+    
+     
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterToNapID");
+    MSmlDmDDFObject& toNapID = dmStreamingAdap.AddChildObjectL(KNSmlDMStreamingAdapterToNapID);
+    FillNodeInfoL(  toNapID, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterToNapIDDescription );
+    
+    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterNetInfo");
+    MSmlDmDDFObject& netInfo = dmStreamingAdap.AddChildObjectL(KNSmlDMStreamingAdapterNetInfo);
+    FillNodeInfoL(  netInfo, 
+                    accessTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::ENode,
+                    KNSmlDMStreamingAdapterNetInfo );
+    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterNetInfoGPRS");
+    MSmlDmDDFObject& netInfoGPRS = netInfo.AddChildObjectL(KNSmlDMStreamingAdapterNetInfoGPRS);
+    FillNodeInfoL(  netInfoGPRS, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterNetInfo );
+                    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterNetInfoEGPRS");
+    MSmlDmDDFObject& netInfoEGPRS = netInfo.AddChildObjectL(KNSmlDMStreamingAdapterNetInfoEGPRS);
+    FillNodeInfoL(  netInfoEGPRS, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterNetInfo );
+                    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterNetInfoWCDMA");
+    MSmlDmDDFObject& netInfoWCDMA = netInfo.AddChildObjectL(KNSmlDMStreamingAdapterNetInfoWCDMA);
+    FillNodeInfoL(  netInfoWCDMA, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterNetInfo );
+                    
+                    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterNetInfoCDMA2000");
+    MSmlDmDDFObject& netInfoCDMA2000 = netInfo.AddChildObjectL(KNSmlDMStreamingAdapterNetInfoCDMA2000);
+    FillNodeInfoL(  netInfoCDMA2000, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterNetInfo );
+                    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterNetInfoWLAN");
+    MSmlDmDDFObject& netInfoWLAN = netInfo.AddChildObjectL(KNSmlDMStreamingAdapterNetInfoWLAN);
+    FillNodeInfoL(  netInfoWLAN, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterNetInfo );
+                    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterNetInfoCDMA");
+    MSmlDmDDFObject& netInfoCDMA = netInfo.AddChildObjectL(KNSmlDMStreamingAdapterNetInfoCDMA);
+    FillNodeInfoL(  netInfoCDMA, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterNetInfo );
+    
+    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterNetInfoHSDPA");
+    MSmlDmDDFObject& netInfoHSDPA = netInfo.AddChildObjectL(KNSmlDMStreamingAdapterNetInfoHSDPA);
+    FillNodeInfoL(  netInfoHSDPA, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMStreamingAdapterNetInfo );
+    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterMinUdpPort");
+    MSmlDmDDFObject& minUdpPort = dmStreamingAdap.AddChildObjectL(KNSmlDMStreamingAdapterMinUdpPort);
+    FillNodeInfoL(  minUdpPort, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EInt,
+                    KNSmlDMStreamingAdapterMinUdpPortDescription );
+    
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): Creating Node KNSmlDMStreamingAdapterMaxUdpPort");
+    MSmlDmDDFObject& maxUdpPort = dmStreamingAdap.AddChildObjectL(KNSmlDMStreamingAdapterMaxUdpPort);
+    FillNodeInfoL(  maxUdpPort, 
+                    accessNoDeleteTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::EInt,
+                    KNSmlDMStreamingAdapterMaxUdpPortDescription );
+    
+    _DBG_FILE("CNSmlDmStreamingAdapter::DDFStructureL(): end");
+    }
+    
+void CNSmlDmStreamingAdapter::SetNetInfoL(const TDesC8& aObject,const TDesC8 &aDes,TDataBearer aBearer,const TInt aStatusRef,const TInt aMnMaxBw, const TInt aMxMaxBw,const TInt aMnSusBw,const TInt aMxSusBw)
+	{
+	TInt aSusBw;
+  TInt aMaxBw;
+  TLex8 aConv;      
+  TInt err;
+  //aConv = aObject;
+  TInt ret = aObject.Locate(KCommaSep()[0]);
+  TInt ret1 = aObject.LocateReverse(KCommaSep()[0]);
+  
+  TInt len = aObject.Length() - (ret1 + 1);
+  TPtrC8 segment1 = aObject.Right( len );
+  aConv = segment1;
+ 
+  TPtrC8 firstSeg = aObject.Left( ret );
+  if(firstSeg.Compare(aDes))
+      {
+            DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::SetNetInfoL() - %d:  Error in SetMaxBandwidth"), aBearer);
+      iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject);
+      return;
+      }
+  
+  
+  err = aConv.Val(aMaxBw);
+  if(err != KErrNone)
+      {
+            DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::SetNetInfoL() - %d: Error in Conversion"), aBearer);
+      iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+      return;
+      }
+
+  if(aMaxBw > 0)
+  	{
+  	err = iModel->SetMaxBandwidth(aMaxBw,aBearer);
+  	}
+  else
+  	{
+  	_DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in SetMaxBandwidth");
+    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+    return;
+    }
+    
+  if(err != KErrNone)
+      {
+      DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::SetNetInfoL() - %d: Error in SetMaxBandwidth"), aBearer);
+      iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+      return;
+      //return retValue;
+      }
+  
+
+  TBuf8<KMaxLengthTempInfo> aSusBf;
+  for(TInt i = (ret+1); i < (ret1); i++)
+      {
+      aSusBf.Append(aObject[i]);
+      }
+  aConv = aSusBf;
+  err = aConv.Val(aSusBw);
+  if(err != KErrNone)
+      {
+            DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::SetNetInfoL() - %d: Error in Conversion"), aBearer);
+      iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+      return;
+      }
+  
+  if(aSusBw > 0)
+  	{
+  	err = iModel->SetSustainBandwidth(aSusBw,aBearer);
+  	}
+  else
+  	{
+  	_DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in SetSustainBandwidth");
+    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+    return;
+    }
+  
+    if(err != KErrNone)
+		    {
+		    DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::SetNetInfoL() - %d: Error in SetSustainBandwidth"), aBearer);
+		    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+		    return;
+		    }
+    if(aMaxBw > aMxMaxBw || aMaxBw < aMnMaxBw)
+  	    {
+        DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::SetNetInfoL() - %d: Error Invalid aMaxBw"), aBearer);
+        iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+        return;
+        }
+    if(aSusBw > aMxSusBw || aSusBw < aMnSusBw)
+        {
+        DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::SetNetInfoL() - %d: Error Invalid aSusBw"), aBearer);
+        iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+        return;
+        }
+
+  iModel->StoreSettingsL();
+  
+  iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk);
+	}
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::UpdateLeafObjectL()
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
+                                               const TDesC8& aLUID, 
+                                               const TDesC8& aObject, 
+                                               const TDesC8& aType, 
+                                               const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): begin");
+    
+		//CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
+    TInt ret = aURI.LocateReverse(KNSmlURISeparator()[0]);
+    if ( ret == KErrNotFound ) 
+        {
+        //retValue = CSmlDmAdapter::EError;
+        iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+        }
+    else
+        {
+        //iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
+        TInt len = aURI.Length() - (ret + 1);
+        TPtrC8 segment = aURI.Right( len );
+        
+        if(segment == KNSmlDMStreamingAdapterName)
+            {
+            	// Set for Streaming Configuration Name
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterName");
+            TBuf<KMaxLengthStreamingName> aBuf;
+            TInt aErr;
+            CRepository* centrep( NULL);
+            aBuf.Zero();
+            if(aObject.Length() <= KMaxLengthStreamingName)
+               {
+            aBuf.Copy(aObject);
+               }
+            else
+                {
+                _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in KMaxLengthStreamingName");
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ETooLargeObject);
+                return;
+                }
+   					
+            centrep = CRepository::NewLC( KCRUidStreamingAdapter );
+            if ( centrep )
+                {
+                _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Inside Cenrep Get");
+                aErr = centrep->Set( KStreamingConfigurationName, aBuf );
+                if(aErr != KErrNone)
+                    {
+                    _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in CenRep Get");
+                    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+                    CleanupStack::PopAndDestroy(centrep);	
+                    return;
+                    }
+                CleanupStack::PopAndDestroy(centrep);
+                iModel->StoreSettingsL();
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
+                }
+            else
+                {
+                _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in Creating the cenrep");
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+                }
+            }
+        else if(segment == KNSmlDMStreamingAdapterToProxy)
+            {
+            	// Set for Streaming settings proxy address
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterToProxy");
+            TBuf<KMaxLengthToProxy> aBuf;
+            if(aObject.Length() <= KMaxLengthToProxy)
+               {
+            aBuf.Copy(aObject);
+               }
+           else
+               {
+               _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in KMaxLengthToProxy");
+               iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ETooLargeObject);
+               return;
+               }
+            ret = iModel->SetProxyHostNameL(aBuf);
+            if(ret != KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in SetProxyHostNameL %d"), ret);
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+                return;
+                }
+            iModel->StoreSettingsL();    
+            iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );    
+            }
+        else if(segment == KNSmlDMStreamingAdapterToNapID)
+            {
+           	SetDefaultApL(aObject,aStatusRef);
+           	/*
+            TInt aNap;
+            TUint32 aNapId;
+            TLex8 aConv;
+            aConv = aObject;
+            CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() );
+            CleanupStack::PushL(iapmatch);
+            
+            aNap = iapmatch->IAPIdFromURIL(aObject);
+            
+            if(aNap == KErrNotFound)
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in IAPIdFromURIL %d"), aNap);
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject );
+                return;
+                }
+                
+            aNapId = aNap;
+            CleanupStack::PopAndDestroy(); // iapMatch
+            
+            TInt ret;// = aConv.Val(aNapId,EDecimal);
+            ret = iModel->SetDefaultAp(aNapId);
+            if(ret == KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): SetDefaultAp success %d"), ret);
+                iModel->StoreSettingsL();
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );    
+                }
+            else
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in SetDefaultAp %d"), ret);
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject );
+                }*/
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoGPRS)
+            {
+                // Set for the netwrok information when Databearer is GPRS
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterNetInfoGPRS");
+            SetNetInfoL(aObject,KNSmlDMStreamingAdapterNetInfoGPRS,EBearerGPRS,aStatusRef,KMnMaxBwGPRS,KMxMaxBwGPRS,KMnSusBwGPRS,KMxSusBwGPRS);
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoEGPRS)
+            {
+                // Set for the netwrok information when Databearer is EGPRS
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterNetInfoEGPRS");
+            SetNetInfoL(aObject,KNSmlDMStreamingAdapterNetInfoEGPRS,EBearerEGPRS,aStatusRef,KMnMaxBwEGPRS,KMxMaxBwEGPRS,KMnSusBwEGPRS,KMxSusBwEGPRS);
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoWCDMA)
+            {
+                // Set for the netwrok information when Databearer is  WCDMA
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterNetInfoWCDMA");
+            SetNetInfoL(aObject,KNSmlDMStreamingAdapterNetInfoWCDMA,EBearerWCDMA,aStatusRef,KMnMaxBwWCDMA,KMxMaxBwWCDMA,KMnSusBwWCDMA,KMxSusBwWCDMA);
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoCDMA2000)
+            {
+                // Set for the netwrok information when Databearer is CDMA2000
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterNetInfoCDMA2000");
+            SetNetInfoL(aObject,KNSmlDMStreamingAdapterNetInfoCDMA2000,EBearerCDMA2000,aStatusRef,KMnMaxBwCDMA2000,KMxMaxBwCDMA2000,KMnSusBwCDMA2000,KMxSusBwCDMA2000);
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoWLAN)
+            {
+                // Set for the netwrok information when Databearer is WLAN
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterNetInfoWLAN");
+            SetNetInfoL(aObject,KNSmlDMStreamingAdapterNetInfoWLAN,EBearerWLAN,aStatusRef,KMnMaxBwWLAN,KMxMaxBwWLAN,KMnSusBwWLAN,KMxSusBwWLAN);
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoCDMA)
+            {
+                // Set for the netwrok information when Databearer is CDMA
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterNetInfoCDMA");
+            SetNetInfoL(aObject,KNSmlDMStreamingAdapterNetInfoCDMA,EBearerCDMA,aStatusRef,KMnMaxBwCDMA,KMxMaxBwCDMA,KMnSusBwCDMA,KMxSusBwCDMA);
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoHSDPA)
+            {
+                // Set for the netwrok information when Databearer is HSDPA
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterNetInfoHSDPA");
+            SetNetInfoL(aObject,KNSmlDMStreamingAdapterNetInfoHSDPA,EBearerHSDPA,aStatusRef,KMnMaxBwHSDPA,KMxMaxBwHSDPA,KMnSusBwHSDPA,KMxSusBwHSDPA);
+            }                
+        else if(segment == KNSmlDMStreamingAdapterMinUdpPort)
+            {
+            	// Set for the min udp port for streaming settings
+            	SetMinUDPPortL(aObject,aStatusRef);
+            	/*
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterMinUdpPort");
+            TInt aMinPort;
+            TInt aMaxPort;
+            TLex8 aConv;
+            TInt ret = KErrNone;
+            aConv = aObject;
+            ret = iModel->GetMaxUDPPort(aMaxPort);
+            if(ret != KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in GetMaxUDPPort: %d"), ret);
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+                return;
+                }
+            ret = aConv.Val(aMinPort);
+            if(ret != KErrNone)
+            	{
+      	      _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in conversion");
+              iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+              return;
+            	}
+            
+            
+            if(aMinPort < (aMaxPort - KPortDiff) && aMinPort >= KMinPort && aMinPort < KMaxPort)
+                {
+                ret = iModel->SetMinUDPPort(aMinPort);
+                if(ret != KErrNone)
+                    {
+                    DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in SetMinUDPPort: %d"), ret);
+                    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+                    return;
+                    }
+                iModel->StoreSettingsL();
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk);
+                }
+            else
+                {
+                _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Invalid Port value");
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject);
+                }
+                */
+            }
+        else if(segment == KNSmlDMStreamingAdapterMaxUdpPort)
+            {
+            	SetMaxUDPPortL(aObject,aStatusRef);
+            	// Set for the max udp port for streaming settings
+            	/*
+            _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): begin");
+            TInt aMaxPort;
+            TInt aMinPort;
+            TLex8 aConv;
+            TInt ret = KErrNone;
+            aConv = aObject;
+            ret = iModel->GetMinUDPPort(aMinPort);
+            if(ret != KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in GetMinUDPPort: %d"), ret);
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+                return;
+                }
+            ret = aConv.Val(aMaxPort);
+            if(ret != KErrNone)
+            	{
+      	      _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in conversion");
+              iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+              return;
+            	}
+            
+            if(aMaxPort > (aMinPort + KPortDiff) && aMaxPort >= KMinPort && aMaxPort <= KMaxPort )
+                {
+                ret = iModel->SetMaxUDPPort(aMaxPort);
+                if(ret != KErrNone)
+                    {
+                    DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in SetMaxUDPPort: %d"), ret);
+                    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+                    return;
+                    }
+                iModel->StoreSettingsL();
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk);
+                }
+            else
+                {
+                _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Invalid Port value");
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject);
+                } */    
+            }
+        }
+    _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): end");
+    }
+    
+    void CNSmlDmStreamingAdapter::SetDefaultApL(const TDesC8& aObject,const TInt aStatusRef)
+    {
+    TInt aNap;
+    TUint32 aNapId;
+    TLex8 aConv;
+    aConv = aObject;
+    CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() );
+    CleanupStack::PushL(iapmatch);
+    
+    aNap = iapmatch->IAPIdFromURIL(aObject);
+    
+    if(aNap == KErrNotFound)
+        {
+        DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in IAPIdFromURIL %d"), aNap);
+        iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject );
+        return;
+        }
+        
+    aNapId = aNap;
+    CleanupStack::PopAndDestroy(); // iapMatch
+    
+    TInt ret;// = aConv.Val(aNapId,EDecimal);
+    ret = iModel->SetDefaultAp(aNapId);
+    if(ret == KErrNone)
+        {
+        DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): SetDefaultAp success %d"), ret);
+        iModel->StoreSettingsL();
+        iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk );    
+        }
+    else
+        {
+        DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in SetDefaultAp %d"), ret);
+        iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject );
+        }
+    }
+    
+    void CNSmlDmStreamingAdapter::SetMinUDPPortL(const TDesC8& aObject,const TInt aStatusRef)
+    {
+    			_DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): KNSmlDMStreamingAdapterMinUdpPort");
+            TInt aMinPort;
+            TInt aMaxPort;
+            TLex8 aConv;
+            TInt ret = KErrNone;
+            aConv = aObject;
+            ret = iModel->GetMaxUDPPort(aMaxPort);
+            if(ret != KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in GetMaxUDPPort: %d"), ret);
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+                return;
+                }
+            ret = aConv.Val(aMinPort);
+            if(ret != KErrNone)
+            	{
+      	      _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in conversion");
+              iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+              return;
+            	}
+            
+            
+            if(aMinPort < (aMaxPort - KPortDiff) && aMinPort >= KMinPort && aMinPort < KMaxPort)
+                {
+                ret = iModel->SetMinUDPPort(aMinPort);
+                if(ret != KErrNone)
+                    {
+                    DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in SetMinUDPPort: %d"), ret);
+                    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+                    return;
+                    }
+                iModel->StoreSettingsL();
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk);
+                }
+            else
+                {
+                _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Invalid Port value");
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject);
+                }
+    }
+    
+    void CNSmlDmStreamingAdapter::SetMaxUDPPortL(const TDesC8& aObject,const TInt aStatusRef)
+    {
+    			_DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): begin");
+            TInt aMaxPort;
+            TInt aMinPort;
+            TLex8 aConv;
+            TInt ret = KErrNone;
+            aConv = aObject;
+            ret = iModel->GetMinUDPPort(aMinPort);
+            if(ret != KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in GetMinUDPPort: %d"), ret);
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+                return;
+                }
+            ret = aConv.Val(aMaxPort);
+            if(ret != KErrNone)
+            	{
+      	      _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in conversion");
+              iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+              return;
+            	}
+            
+            if(aMaxPort > (aMinPort + KPortDiff) && aMaxPort >= KMinPort && aMaxPort <= KMaxPort )
+                {
+                ret = iModel->SetMaxUDPPort(aMaxPort);
+                if(ret != KErrNone)
+                    {
+                    DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Error in SetMaxUDPPort: %d"), ret);
+                    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError);
+                    return;
+                    }
+                iModel->StoreSettingsL();
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk);
+                }
+            else
+                {
+                _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): Invalid Port value");
+                iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject);
+                }
+      }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDmStreamingAdapter::DeleteObjectL()
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::DeleteObjectL( const TDesC8& /*aURI*/, 
+                                           const TDesC8& /*aLUID*/, 
+                                           const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::DeleteLeafObjectL( ): begin");
+    _DBG_FILE("CNSmlDmStreamingAdapter::DeleteLeafObjectL( ): end");
+    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotAllowed );
+    }
+
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
+// const TDesC8& aType, const TInt aResultsRef, const TInt aStatusRef )
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::FetchLeafObjectL( const TDesC8& aURI, 
+                                              const TDesC8& /*aLUID*/, 
+                                              const TDesC8& aType, 
+                                              const TInt aResultsRef, 
+                                              const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): begin");
+    
+    CBufBase *object = CBufFlat::NewL( 1 );
+    CleanupStack::PushL( object );
+    
+    CSmlDmAdapter::TError retValue = FetchLeafObjectL( aURI, *object );
+    
+    iDmCallback->SetStatusL( aStatusRef, retValue );
+    iDmCallback->SetResultsL( aResultsRef, *object, aType );
+    CleanupStack::PopAndDestroy(); //object
+    _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): end");
+    }
+
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::ChildURIListL( const TDesC& aURI, 
+// const TDesC& aParentLUID, const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, 
+// const TInt aResultsRef, const TInt aStatusRef )
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::ChildURIListL( const TDesC8& aURI, 
+                                           const TDesC8& /*aParentLUID*/, 
+                                           const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, 
+                                           const TInt aResultsRef, 
+                                           const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::ChildURIListL(): begin");
+    CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
+    CBufBase* currentURISegmentList = CBufFlat::NewL( 1 );
+    CleanupStack::PushL( currentURISegmentList );
+    TInt ret = aURI.LocateReverse(KNSmlURISeparator()[0]);
+    if ( ret == KErrNotFound ) 
+        {
+        ret = -1;
+        }
+    TInt len = aURI.Length() - ( ret + 1 );
+    TPtrC8 segment = aURI.Right( len );
+
+    if ( segment == KNSmlDMStreamingAdapterNodeName )
+        {
+        _DBG_FILE("CNSmlDmStreamingAdapter::ChildURIListL(): begin");
+      	currentURISegmentList->InsertL( currentURISegmentList->Size(), KNSmlDMStreamingAdapterVal() );
+        }
+    else if ( segment == KNSmlDMStreamingAdapterNetInfo )
+        {
+        _DBG_FILE("CNSmlDmStreamingAdapter::ChildURIListL(): begin");
+      	currentURISegmentList->InsertL( currentURISegmentList->Size(), KNSmlDMStreamingAdapterNetInfoVal() );
+        }
+    
+    else
+        {
+        retValue = CSmlDmAdapter::EError;
+        }
+    iDmCallback->SetStatusL( aStatusRef, retValue );
+    iDmCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 );
+    CleanupStack::PopAndDestroy(); //currentURISegmentList
+    _DBG_FILE("CNSmlDmStreamingAdapter::ChildURIListL(): end");
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDmStreamingAdapter::AddNodeObjectL( const TDesC8& aURI, 
+// const TDesC8& aParentLUID, const TInt aStatusRef )
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::AddNodeObjectL( const TDesC8& /*aURI*/, 
+                                            const TDesC8& /*aParentLUID*/, 
+                                            const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::AddNodeObjectL(): begin");
+    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotAllowed );
+    _DBG_FILE("CNSmlDmStreamingAdapter::AddNodeObjectL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::UpdateLeafObjectL()
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::UpdateLeafObjectL( const TDesC8& /*aURI*/, 
+                                               const TDesC8& /*aLUID*/, 
+                                               RWriteStream*& /*aStream*/, 
+                                               const TDesC8& /*aType*/, 
+                                               const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): stream: begin");
+    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    _DBG_FILE("CNSmlDmStreamingAdapter::UpdateLeafObjectL(): stream: end");
+    }
+
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, 
+//  const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef, TInt aStatusRef )
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, 
+                                                  const TDesC8& /*aLUID*/, 
+                                                  const TDesC8& aType, 
+                                                  const TInt aResultsRef, 
+                                                  const TInt aStatusRef )
+    {
+
+    _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectSizeL(): begin");
+    
+    CBufBase *object = CBufFlat::NewL( 1 );
+    CleanupStack::PushL( object );
+    CSmlDmAdapter::TError retValue = FetchLeafObjectL( aURI, *object );
+        
+    TInt objSizeInBytes = object->Size();
+    TBuf8<2> stringObjSizeInBytes;
+    stringObjSizeInBytes.Num( objSizeInBytes );
+    object->Reset();
+    object->InsertL( 0, stringObjSizeInBytes );
+    
+    iDmCallback->SetStatusL( aStatusRef, retValue );
+    iDmCallback->SetResultsL( aResultsRef, *object, aType );
+    CleanupStack::PopAndDestroy(); //object
+    _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectSizeL(): end");
+    }
+    
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::ExecuteCommandL( const TDesC8& aURI, 
+//  const TDesC8& aParentLUID, TDesC8& aArgument, const TDesC8& aType, TInt aStatusRef )
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aArgument, const TDesC8& aType, const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::ExecuteCommandL(): begin");
+    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    _DBG_FILE("CNSmlDmStreamingAdapter::ExecuteCommandL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::ExecuteCommandL( const TDesC8& aURI, 
+//  const TDesC8& aParentLUID, RWriteStream*& aStream, const TDesC8& aType, 
+//  TInt aStatusRef )
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, 
+                                             const TDesC8& /*aParentLUID*/, 
+                                             RWriteStream*& /*aStream*/, 
+                                             const TDesC8& /*aType*/, 
+                                             const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::ExecuteCommandL(): stream: begin");
+    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    _DBG_FILE("CNSmlDmStreamingAdapter::ExecuteCommandL(): stream: end");
+    }
+
+// -----------------------------------------------------------------------------
+//  CNSmlDmStreamingAdapter::CopyCommandL( const TDesC8& aTargetURI, const TDesC8& 
+//  aSourceURI, const TDesC8& aSourceLUID, const TDesC8& /*aType*/, TInt aStatusRef )
+// -----------------------------------------------------------------------------
+void CNSmlDmStreamingAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, const TDesC8& 
+                                          /*aTargetLUID*/, const TDesC8& /*aSourceURI*/, 
+                                          const TDesC8& /*aSourceLUID*/, 
+                                          const TDesC8& /*aType*/, TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::CopyCommandL(): begin");
+    iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    _DBG_FILE("CNSmlDmStreamingAdapter::CopyCommandL(): end");
+    }
+
+// --------------------------------------
+//  CNSmlDmStreamingAdapter::StartAtomicL()
+// --------------------------------------
+void CNSmlDmStreamingAdapter::StartAtomicL()
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::StartAtomicL(): begin");
+    _DBG_FILE("CNSmlDmStreamingAdapter::StartAtomicL(): end");
+    }
+    
+// ---------------------------------------
+//  CNSmlDmStreamingAdapter::CommitAtomicL()
+// ---------------------------------------
+void CNSmlDmStreamingAdapter::CommitAtomicL()
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::CommitAtomicL(): begin");
+    _DBG_FILE("CNSmlDmStreamingAdapter::CommitAtomicL(): end");
+    }
+
+// -----------------------------------------
+//  CNSmlDmStreamingAdapter::RollbackAtomicL()
+// -----------------------------------------
+void CNSmlDmStreamingAdapter::RollbackAtomicL()
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::RollbackAtomicL(): begin");
+    _DBG_FILE("CNSmlDmStreamingAdapter::RollbackAtomicL(): end");
+    }
+
+// -----------------------------------------------------------
+//  CNSmlDmStreamingAdapter::StreamingSupport( TInt& aItemSize )
+// -----------------------------------------------------------  
+TBool CNSmlDmStreamingAdapter::StreamingSupport( TInt& /*aItemSize*/ )
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::StreamingSupport(): begin");
+    _DBG_FILE("CNSmlDmStreamingAdapter::StreamingSupport(): end");
+    return EFalse;
+    }
+
+// ------------------------------------------
+//  CNSmlDmStreamingAdapter::StreamCommittedL()
+// ------------------------------------------
+void CNSmlDmStreamingAdapter::StreamCommittedL()
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::StreamCommittedL(): begin");
+    _DBG_FILE("CNSmlDmStreamingAdapter::StreamCommittedL(): end");
+    }
+
+// --------------------------------------------------
+//  CNSmlDmStreamingAdapter::CompleteOutstandingCmdsL()
+// --------------------------------------------------   
+void CNSmlDmStreamingAdapter::CompleteOutstandingCmdsL()
+    {
+    _DBG_FILE("CNSmlDmStreamingAdapter::CompleteOutstandingCmdsL(): begin");
+    _DBG_FILE("CNSmlDmStreamingAdapter::CompleteOutstandingCmdsL(): end");    
+    }
+
+
+CSmlDmAdapter::TError CNSmlDmStreamingAdapter::GetNetInfoL(CBufBase& aObject,TDataBearer aBearer,const TDesC8 &aDes)
+    {
+      TBuf8<KMaxLengthNetInfo> aNetInfoBuf;   
+      CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
+      TInt err;
+      aNetInfoBuf.Append(aDes);
+      aNetInfoBuf.Append(KCommaSep);
+              
+      TInt aSusBw = 0;
+      err = iModel->GetSustainBandwidth(aSusBw,aBearer);
+      if(err != KErrNone)
+          {
+          DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::GetNetInfoL() - %d: Error in GetSustainBandwidth: %d"),aBearer,err);
+          retValue = CSmlDmAdapter::EError;
+          return retValue;
+          }
+      TBuf8<KMaxLengthTempInfo> aSusBwBuf;
+      aSusBwBuf.Num(aSusBw);
+      aNetInfoBuf.Append(aSusBwBuf);
+      aNetInfoBuf.Append(KCommaSep);
+      //aObject.InsertL(0,aSusBwBuf);
+      
+      
+      TInt aMaxBw;
+      err = iModel->GetMaxBandwidth(aMaxBw,aBearer);
+      if(err != KErrNone)
+          {
+          DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::GetNetInfoL() - %d: Error in GetMaxBandwidth: %d"),aBearer,err);
+          retValue = CSmlDmAdapter::EError;
+          return retValue;
+          }
+      TBuf8<KMaxLengthTempInfo> aMaxBwBuf;
+      aMaxBwBuf.Num(aMaxBw);
+      aNetInfoBuf.Append(aMaxBwBuf);
+      
+      aObject.InsertL(0,aNetInfoBuf);
+      retValue= CSmlDmAdapter::EOk;
+      return retValue;
+    }
+// -----------------------------------------------------------------------------
+// CNSmlDmDevDetailAdapter::FetchLeafObjectL()
+// -----------------------------------------------------------------------------
+CSmlDmAdapter::TError CNSmlDmStreamingAdapter::FetchLeafObjectL( const TDesC8& aURI, 
+                                                               CBufBase& aObject )
+    {
+    _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): begin");
+    CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
+    TInt ret = aURI.LocateReverse(KNSmlURISeparator()[0]);
+    TInt err = KErrNone;
+    if ( ret == KErrNotFound ) 
+        {
+        retValue = CSmlDmAdapter::EError;
+        }
+    else
+        {
+        TInt len = aURI.Length() - (ret + 1);
+        TPtrC8 segment = aURI.Right( len );
+        
+        if(segment == KNSmlDMStreamingAdapterName)
+            {
+            	// Get for Streaming Configuration Setting name(It is not displayed for the user).
+            _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterName");
+            TBuf8<KMaxLengthStreamingName> aName;
+            CRepository* centrep( NULL);
+            aName.Zero();
+            centrep = CRepository::NewLC( KCRUidStreamingAdapter );
+
+            if ( centrep )
+                {
+                _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): Error in CenRep");
+                TFullName temp;
+                
+                if (centrep->Get( KStreamingConfigurationName, temp )==KErrNone && temp.Length() )
+                    {
+                    _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): Cenrep Get");
+                    temp.Trim();
+                    aName.Copy(temp);
+                    }
+                else
+                		{
+                		_DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): Error in Cenrep Get");
+                		retValue = CSmlDmAdapter::EError;
+                		CleanupStack::PopAndDestroy(centrep);	
+                		return retValue;
+                		}
+                CleanupStack::PopAndDestroy(centrep);
+                }
+            aObject.InsertL(0,aName);
+            retValue= CSmlDmAdapter::EOk;    
+            }
+        else if(segment == KNSmlDMStreamingAdapterToProxy)
+            {
+            	// Get for Proxy Address of the streaming settings.
+            _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterToProxy");
+            TBuf<KMaxLengthToProxy> uri;
+            err = iModel->GetProxyHostName(uri);
+            if(err != KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::FetchLeafObjectL(): Error in GetProxyHostName: %d"), err);
+                retValue = CSmlDmAdapter::EError;
+                return retValue;
+                }
+            TPtr8 ptr = uri.Collapse(); 
+            aObject.InsertL(0,ptr); 
+            retValue= CSmlDmAdapter::EOk;
+            }
+        else if(segment == KNSmlDMStreamingAdapterToNapID)
+            {
+            	// Get for Access Point that is set in the streaming settings
+            	retValue = GetDefaultApL(aObject);
+            	retValue = CSmlDmAdapter::EOk;  // even if no AP set return with null value
+            	return retValue;
+            	/*
+            _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterToNapID");
+            TUint32 aNapId;
+            err = iModel->GetDefaultAp(aNapId);
+            if(err != KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::FetchLeafObjectL(): Error in GetDefaultAp: %d"), err);
+                retValue = CSmlDmAdapter::EError;
+                return retValue;
+                }
+            CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() );
+            CleanupStack::PushL(iapmatch);
+
+            HBufC8* uri8 = iapmatch->URIFromIAPIdL( aNapId );
+            
+            if( uri8 )
+                {
+                CleanupStack::PushL(uri8);
+                aObject.InsertL(0,uri8->Des());
+                retValue= CSmlDmAdapter::EOk;
+                CleanupStack::PopAndDestroy(); // uri8
+                }
+            else
+                {
+                _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): Error in URIFromIAPIdL:ENotFound");
+                retValue= CSmlDmAdapter::ENotFound;
+                }    
+            CleanupStack::PopAndDestroy(); // iapMatch */
+            
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoHSDPA)
+            {
+            	// Get for network information when data bearer is HSDPA
+            _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterNetInfoHSDPA");
+            retValue = GetNetInfoL(aObject,EBearerHSDPA,KNSmlDMStreamingAdapterNetInfoHSDPA);
+             return retValue;
+            
+           
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoGPRS)
+            {
+            	// Get for network information when data bearer is GPRS
+            _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterNetInfoGPRS");
+            retValue = GetNetInfoL(aObject,EBearerGPRS,KNSmlDMStreamingAdapterNetInfoGPRS);
+            return retValue;
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoEGPRS)
+            {
+            	// Get for network information when data bearer is EGPRS
+            _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterNetInfoEGPRS");
+            retValue = GetNetInfoL(aObject,EBearerEGPRS,KNSmlDMStreamingAdapterNetInfoEGPRS);
+            return retValue;
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoWCDMA)
+            {
+            	// Get for network information when data bearer is WCDMA
+            _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterNetInfoWCDMA");
+            retValue = GetNetInfoL(aObject,EBearerWCDMA,KNSmlDMStreamingAdapterNetInfoWCDMA);
+            return retValue;
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoCDMA)
+            {
+            	// Get for network information when data bearer is CDMA
+            _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterNetInfoCDMA");
+            retValue = GetNetInfoL(aObject,EBearerCDMA,KNSmlDMStreamingAdapterNetInfoCDMA);
+            return retValue;
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoCDMA2000)
+            {
+            	// Get for network information when data bearer is CDMA2000
+            _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterNetInfoCDMA2000");
+            retValue = GetNetInfoL(aObject,EBearerCDMA2000,KNSmlDMStreamingAdapterNetInfoCDMA2000);
+            return retValue;
+            }
+        else if(segment == KNSmlDMStreamingAdapterNetInfoWLAN)
+            {
+            	// Get for network information when data bearer is WLAN
+            _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterNetInfoWLAN");
+            retValue = GetNetInfoL(aObject,EBearerWLAN,KNSmlDMStreamingAdapterNetInfoWLAN);
+            return retValue;
+            }
+        else if(segment == KNSmlDMStreamingAdapterMinUdpPort)
+            {
+            	// Get for Min UDP port of streaming settings
+            _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterMinUdpPort");
+            TInt aMinPort;
+            err = iModel->GetMinUDPPort(aMinPort);
+            if(err != KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmInfoAdapter::FetchLeafObjectL(): Error in GetMinUDPPort: %d"), err);
+                retValue = CSmlDmAdapter::EError;
+                return retValue;
+                }
+            TBuf8<10> aMinPortBuf;
+            aMinPortBuf.Num(aMinPort);
+            aObject.InsertL(0,aMinPortBuf);
+            retValue= CSmlDmAdapter::EOk;
+            }
+        else if(segment == KNSmlDMStreamingAdapterMaxUdpPort)
+            {
+            	// Get for Max UDP port of streaming settings
+            _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterMaxUdpPort");
+            TInt aMaxPort;
+            err = iModel->GetMaxUDPPort(aMaxPort);
+            if(err != KErrNone)
+                {
+                DBG_ARGS8(_S8("CNSmlDmInfoAdapter::FetchLeafObjectL(): Error in GetMaxUDPPort: %d"), err);
+                retValue= CSmlDmAdapter::EError;
+                return retValue;
+                }
+            TBuf8<10> aMaxPortBuf;
+            aMaxPortBuf.Num(aMaxPort);
+            aObject.InsertL(0,aMaxPortBuf);
+            retValue= CSmlDmAdapter::EOk;    
+            }
+        }
+    _DBG_FILE("CNSmlDmInfoAdapter::FetchLeafObjectL(): end");
+    return retValue;
+    }
+    
+    
+    CSmlDmAdapter::TError CNSmlDmStreamingAdapter::GetDefaultApL(CBufBase& aObject)
+    {
+    CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
+    _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): KNSmlDMStreamingAdapterToNapID");
+      TUint32 aNapId;
+      TInt err;
+      err = iModel->GetDefaultAp(aNapId);
+      if(err != KErrNone)
+          {
+          DBG_ARGS8(_S8("CNSmlDmStreamingAdapter::FetchLeafObjectL(): Error in GetDefaultAp: %d"), err);
+          retValue = CSmlDmAdapter::EError;
+          return retValue;
+          }
+      CNSmlDMIAPMatcher* iapmatch = CNSmlDMIAPMatcher::NewL( &Callback() );
+      CleanupStack::PushL(iapmatch);
+
+      HBufC8* uri8 = iapmatch->URIFromIAPIdL( aNapId );
+      
+      if( uri8 )
+          {
+          CleanupStack::PushL(uri8);
+          aObject.InsertL(0,uri8->Des());
+          retValue= CSmlDmAdapter::EOk;
+          CleanupStack::PopAndDestroy(); // uri8
+          }
+      else
+          {
+          _DBG_FILE("CNSmlDmStreamingAdapter::FetchLeafObjectL(): Error in URIFromIAPIdL:ENotFound");
+          retValue= CSmlDmAdapter::ENotFound;
+          }    
+      CleanupStack::PopAndDestroy(); // iapMatch
+      return retValue;
+      }
+
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::FillNodeInfoL()
+// Fills the DDF node info.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmStreamingAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode, 
+                                        const TSmlDmAccessTypes& aAccTypes, 
+                                        MSmlDmDDFObject::TOccurence aOccurrence, 
+                                        MSmlDmDDFObject::TScope aScope, 
+                                        MSmlDmDDFObject::TDFFormat aFormat, 
+                                        const TDesC8& aDescription ) const
+    {
+    _DBG_FILE("CNSmlDmInfoAdapter::FillNodeInfoL(): end");
+    aNode.SetAccessTypesL( aAccTypes );
+    aNode.SetOccurenceL( aOccurrence );
+    aNode.SetScopeL( aScope );
+    aNode.SetDFFormatL( aFormat );
+    
+    if( aFormat != MSmlDmDDFObject::ENode )
+        {
+        aNode.AddDFTypeMimeTypeL( KNSmlDMStreamingAdapterTextPlain );
+        }
+    
+    aNode.SetDescriptionL( aDescription );
+   	_DBG_FILE("CNSmlDmInfoAdapter::FillNodeInfoL(): end");
+    }
+
+/*
+
+TInt CNSmlDmStreamingAdapter::ThreadFunction(TAny* aStarted)
+    {
+    _DBG_FILE("CNSmlDmInfoAdapter::ThreadFunction(): Start");
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    _DBG_FILE("CNSmlDmInfoAdapter::CTrapCleanup New");
+    RMsgQueueBase& aMsgQ= *(RMsgQueueBase*) aStarted;
+    CNetworkInfo * aNetInfo;
+    TRAPD(err,aNetInfo = CNetworkInfo::NewL());
+    _DBG_FILE("CNSmlDmInfoAdapter::CNetworkInfo New");
+    TRAP(err,aNetInfo->GetNetworkInfoL(aMsgQ));
+    _DBG_FILE("CNSmlDmInfoAdapter::ThreadFunction(): End");
+    delete aNetInfo;
+    delete cleanup;
+    }
+*/
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::Cleanup
+// -----------------------------------------------------------------------------
+//
+void CNSmlDmStreamingAdapter::Cleanup( TAny* aAny )
+    {
+    RImplInfoPtrArray* implArray = 
+        reinterpret_cast< RImplInfoPtrArray*> ( aAny );
+    implArray->ResetAndDestroy();
+    implArray->Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+#ifndef IMPLEMENTATION_PROXY_ENTRY
+#define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr)  {{aUid},(aFuncPtr)}
+#endif
+
+const TImplementationProxy ImplementationTable[] = 
+    {
+        IMPLEMENTATION_PROXY_ENTRY(KNSmlDMStreamingAdapterImplUid, CNSmlDmStreamingAdapter::NewL)
+    };
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    _DBG_FILE("ImplementationGroupProxy() for CNSmlDmStreamingAdapter: begin");
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    _DBG_FILE("ImplementationGroupProxy() for CNSmlDmStreamingAdapter: end");
+    return ImplementationTable;
+    }
+
+// End of file
+