omads/omadsextensions/adapters/agenda/src/nsmlagendadatastore.cpp
branchRCL_3
changeset 67 2abf74df9cdc
parent 61 57a9de0b82e8
--- a/omads/omadsextensions/adapters/agenda/src/nsmlagendadatastore.cpp	Wed Sep 15 11:57:08 2010 +0300
+++ b/omads/omadsextensions/adapters/agenda/src/nsmlagendadatastore.cpp	Wed Oct 13 14:15:45 2010 +0300
@@ -34,7 +34,7 @@
 #include <SmlDataFormat.h>
 #include <SmlDataSyncDefs.h>
 #include <data_caging_path_literals.hrh>
-#include <nsmlagendadatastore_1_1_2.rsg>
+#include <NSmlAgendaDataStore_1_1_2.rsg>
 #include <e32property.h>
 #include <DataSyncInternalPSKeys.h>
 #include <CalenImporter.h>
@@ -217,8 +217,6 @@
        iCommittedUidArr->Reset();
        delete iCommittedUidArr;
        }
-    
-     delete iAgendaAdapterLog;
 	FLOG(_L("CNSmlAgendaDataStore::~CNSmlAgendaDataStore(): END"));
 	}
 
@@ -257,7 +255,38 @@
 		{
 		FLOG(_L("CNSmlAgendaDataStore::DoOpenL: Calling the OpenStoreL: '%S'"), &aStoreName);
 		TRAP( err, OpenStoreL() );
-		}    
+		}
+    else 
+    	{
+    	// Provided profile is created from the DS Application
+    	FLOG(_L("CNSmlAgendaDataStore::DoOpenL: storename: '%S'"), &aStoreName);    	
+    	if ( iOpenedStoreName )
+            {
+            delete iOpenedStoreName;
+            iOpenedStoreName = NULL;
+            }
+        iOpenedStoreName = aStoreName.AllocL();  
+        
+        CCalSession* calsession = CCalSession::NewL();
+        CleanupStack::PushL(calsession);
+        TRAP( err, calsession->OpenL( aStoreName ) );
+        if ( err )
+            {
+            FLOG(_L("CNSmlAgendaDataStore::DoOpenL: Cannot open the session: '%d'"), err); 
+            CleanupStack::PopAndDestroy( calsession ); 
+            User::RequestComplete( iCallerStatus, err );
+            return;
+            }
+            
+        // Disable notifications
+        TRAP_IGNORE( calsession->DisablePubSubNotificationsL() );
+        TRAP_IGNORE( calsession->DisableChangeBroadcast() );    
+        // Get ID of database
+        calsession->FileIdL( iOpenedStoreId );
+        
+        // Close the session
+        CleanupStack::PopAndDestroy( calsession ); 
+    	}
 		
 	if ( err )
 	    {
@@ -274,11 +303,6 @@
 	
 	iChangeFinder = CNSmlChangeFinder::NewL( aContext, iKey, iHasHistory,
 	                                         KNSmlAgendaAdapterImplUid );
-	if (iAgendaAdapterLog)
-	    {
-	    delete iAgendaAdapterLog;
-	    iAgendaAdapterLog = NULL;
-	    }
 	iAgendaAdapterLog = CNSmlAgendaAdapterLog::NewL( aContext );
 	iState = ENSmlOpenAndWaiting;
     User::RequestComplete( iCallerStatus, err );