Revision: 201031 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 09:41:17 +0300
branchRCL_3
changeset 23 2bb96f4ecad8
parent 22 8d171aa39c3f
child 24 8e7494275d3a
Revision: 201031 Kit: 201033
omads/omadsappui/AspSyncUtil/inc/AspProfile.h
omads/omadsappui/AspSyncUtil/inc/AspResHandler.h
omads/omadsappui/AspSyncUtil/loc/NSmlDSSync.loc
omads/omadsappui/AspSyncUtil/src/AspProfile.cpp
omads/omadsappui/AspSyncUtil/src/AspResHandler.cpp
omads/omadsappui/AspSyncUtil/src/AspSyncHandler.cpp
omads/omadsappui/AspSyncUtil/src/AspSyncUtil.rss
omads/omadsappui/AspSyncUtil/src/AspUtil.cpp
omads/omadsextensions/adapters/agenda/inc/nsmlagendadatastore.h
omads/omadsextensions/adapters/agenda/src/nsmlagendadatastore.cpp
omads/omadsextensions/dsutils/nsmldefaultagendahandler/src/nsmldefaultagendahandlerplugin.cpp
--- a/omads/omadsappui/AspSyncUtil/inc/AspProfile.h	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsappui/AspSyncUtil/inc/AspProfile.h	Thu Aug 19 09:41:17 2010 +0300
@@ -484,6 +484,8 @@
     	void CreateCalLocalDatabaseL(TDes& aCalName);
     	void RetrieveCalLocalDatabaseL(TDes& aCalName);
     	TBool IsCalNameAvailableL(CCalSession& aSession ,TDes& aCalName);
+    	TBool IsValidClientDataSourceL( TDes& aCalName );
+    	
 		
     private:
     
--- a/omads/omadsappui/AspSyncUtil/inc/AspResHandler.h	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsappui/AspSyncUtil/inc/AspResHandler.h	Thu Aug 19 09:41:17 2010 +0300
@@ -149,15 +149,17 @@
         */
 		static CDesCArrayFlat* ReadDesArrayStaticLC(TInt aResourceId);
 
+		/* Implementation of CMCC PIM v3 begins*/ 
 	   /**
         * Reads progress dialog progress text from resource file.
 		* @param aContent Content name.
 		* @param aCurrent Currently processed sync item.
     	* @param aFinal Number of sync items.
-		* @param aSend ETrue is sync phase is "sending".
+		* @param aPhase Phase of synchronization.
 		* @return Progress text.
         */
-		//HBufC* ReadProgressTextLC(const TDesC& aContent, TInt aCurrent, TInt aFinal, TInt aPhase);
+		HBufC* ReadProgressTextLC(const TDesC& aContent, TInt aCurrent, TInt aFinal, TInt aPhase);
+		/* Implementation of CMCC PIM v3 ends*/
 		
 	   /**
         * Reads progress dialog progress text from resource file.
@@ -176,6 +178,19 @@
         */
 		HBufC* ReadProgressTextLC(TInt aResourceId, const TDesC& aContent);
 
+		/* Implementation of CMCC PIM v3 begins*/ 
+	   /**
+	    * Reads progress dialog progress text from resource file.
+	    * Buffers the last aResource to minimize file operations.
+	    * @param aResourceId Resource id.
+	    * @param aCurrent Currently processed sync item.
+        * @param aFinal Number of sync items.
+        * @param aContent Content name.
+	    * @return Progress text.
+	    */
+		HBufC* ReadProgressTextLC(TInt aResourceId, TInt aCurrent, TInt aFinal, const TDesC& aContent);
+		/* Implementation of CMCC PIM v3 ends*/
+		
 	   /**
         * Reads default profile name from resource file.
 		* @param aIndex Number that is added to proile name (eg. "New Profile(1)").
--- a/omads/omadsappui/AspSyncUtil/loc/NSmlDSSync.loc	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsappui/AspSyncUtil/loc/NSmlDSSync.loc	Thu Aug 19 09:41:17 2010 +0300
@@ -1472,6 +1472,26 @@
 //
 #define qtn_sml_sync_sending	"Sending %0U"
 
+/* Implementation of CMCC PIM v3 begins*/
+//d:changing text displayed at synchronising stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:9.2
+//for TD-SCDMA products only
+//
+#define qtn_sml_sync_sending_xofy_tdscdma   "Sending %0N of %1N %0U"
+/* Implementation of CMCC PIM v3 ends*/ 
+
+/* Implementation of CMCC PIM v3 begins*/
+//d:changing text displayed at synchronising stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:9.2
+//for TD-SCDMA products only
+//
+#define qtn_sml_sync_sending_xofy_cal_tdscdma   "Sending %0N of %1N of calendar entries"
+/* Implementation of CMCC PIM v3 ends*/ 
+
 //d:changing text displayed at synchronising stage
 //d:Image replaced by animation
 //l:popup_note_wait_window
@@ -1479,6 +1499,26 @@
 //
 #define qtn_sml_sync_receiving	"Receiving %0U"
 
+/* Implementation of CMCC PIM v3 begins*/ 
+//d:changing text displayed at synchronising stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:9.2
+//for TD-SCDMA products only
+//
+#define qtn_sml_sync_receiving_xofy_tdscdma "Receiving %0U:%0N"
+/* Implementation of CMCC PIM v3 ends*/ 
+
+/* Implementation of CMCC PIM v3 begins*/ 
+//d:changing text displayed at synchronising stage
+//d:Image replaced by animation
+//l:popup_note_wait_window
+//r:9.2
+//for TD-SCDMA products only
+//
+#define qtn_sml_sync_receiving_xofy_cal_tdscdma "Receiving calendar entries:%0N"
+/* Implementation of CMCC PIM v3 ends*/ 
+
 //d:changing text displayed at disconnect stage
 //d:Image replaced by animation
 //l:popup_note_wait_window 
@@ -1500,7 +1540,15 @@
 //
 #define qtn_sml_sync_cancel		"Cancelling\n"
 
-
+/* Implementation of CMCC PIM v3 begins*/ 
+//d:changing text displayed at synchronising stage
+//d:Image replaced by animation
+//l:popup_note_window
+//r:9.2
+//for TD-SCDMA products only
+//
+#define qtn_nsml_log_err_serverfull_tdscdma  "Server memory is full"
+/* Implementation of CMCC PIM v3 ends*/ 
 
 
 
--- a/omads/omadsappui/AspSyncUtil/src/AspProfile.cpp	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsappui/AspSyncUtil/src/AspProfile.cpp	Thu Aug 19 09:41:17 2010 +0300
@@ -40,8 +40,8 @@
 #include <calenmulticalutil.h>
 #include <CalenInterimUtils2.h>
 
-_LIT(KDrive ,"C:");
 _LIT(KCharUnderscore, "_");
+_LIT( KNSmlAgendaFileNameForDefaultDB, "c:calendar" );
 
 /*******************************************************************************
  * class TAspProviderItem
@@ -898,10 +898,9 @@
        	
        	if (task.iDataProviderId == KUidNSmlAdapterCalendar.iUid)
        	    {
-       	    CCalSession* session = CCalSession::NewL();
-       	    CleanupStack::PushL(session);
-       	    TRAPD (err, session->OpenL(task.iClientDataSource));
-       	    if (err == KErrNotFound)
+            TBool status = EFalse;
+            status = IsValidClientDataSourceL( task.iClientDataSource );
+       	    if ( !status )
        	        {
        	        TInt index = FindProviderIndex(task.iDataProviderId);
        	        TAspProviderItem& provider = ProviderItem(index);
@@ -920,7 +919,7 @@
                 InitAllTasksL();
                 InitDataProvidersL();
        	        }
-       	    CleanupStack::PopAndDestroy(session);
+       	    
        	    }
 
 		goodContentCount++;
@@ -1242,7 +1241,7 @@
 	if (aDataProvider.iDataProviderId == KUidNSmlAdapterCalendar.iUid )
         {
         TBuf<128> calLocalDb ;
-        CreateCalLocalDatabaseL(calLocalDb);
+        CreateCalLocalDatabaseL(calLocalDb);        
         task.CreateL(iProfile->Profile(), aDataProvider.iDataProviderId, 
                 KNullDesC, calLocalDb);
         }
@@ -1317,8 +1316,7 @@
 				if (err != KErrNone)
 					{
 					CreateCalLocalDatabaseL(calLocalDb);
-					}				
-                
+					}								
                 task.CreateL(iProfile->Profile(), aDataProviderId, 
                                               aRemoteDatabase, calLocalDb);
                 }
@@ -1338,8 +1336,7 @@
 		    if (err != KErrNone)
 		        {
 		        CreateCalLocalDatabaseL(calLocalDb);
-		        }
-		    
+		        }		    
 		    task.CreateL(iProfile->Profile(), aDataProviderId, 
 		                                  aRemoteDatabase, calLocalDb);
 		    }
@@ -1390,8 +1387,7 @@
 //
 void CAspContentList::CreateCalLocalDatabaseL(TDes& aCalName)
     {
-            
-    aCalName.Copy(KDrive);
+                
     
     TBuf<KBufSize> buffer;
     iProfile->GetName(buffer);
@@ -1510,8 +1506,8 @@
     // Create the CalFile
     HBufC* calfilename = CCalenMultiCalUtil::GetNextAvailableCalFileL();
     calSession->CreateCalFileL( calfilename->Des(), *calinfo );
-	
-	aCalName.Copy( calfilename->Des() );
+		
+    aCalName.Copy(KNSmlAgendaFileNameForDefaultDB);
     
     delete calfilename;
     
@@ -1580,6 +1576,23 @@
         
         CCalCalendarInfo* caleninfo = vCalSubSession->CalendarInfoL(); 
         CleanupStack::PushL(caleninfo);
+		
+		//Get MARKASDELETE MetaData property
+		keyBuff.Zero();
+		TBool markAsdelete = EFalse;
+		keyBuff.AppendNum( EMarkAsDelete );
+		TPckgC<TBool> pckMarkAsDelete(markAsdelete);
+		TRAPD(err,pckMarkAsDelete.Set(caleninfo->PropertyValueL(keyBuff)));
+		if ( err == KErrNone )
+			{
+			markAsdelete = pckMarkAsDelete();
+			if( markAsdelete )
+				{
+				CleanupStack::PopAndDestroy(caleninfo);
+				CleanupStack::PopAndDestroy(vCalSubSession);  	  	 
+				continue;
+				}
+			}
         
         TInt profileId;
         keyBuff.Zero();
@@ -1623,6 +1636,49 @@
     }
 
 // -----------------------------------------------------------------------------
+// CAspContentList::IsValidClientDataSource
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CAspContentList::IsValidClientDataSourceL( TDes& aCalName )
+    {
+    TBool datasourcefound = ETrue;
+    TBuf8<KBufSize> keyBuff;
+    CCalCalendarInfo* caleninfo = NULL;
+    CCalSession* session = CCalSession::NewL();
+    CleanupStack::PushL(session);
+    TRAPD (err, session->OpenL(aCalName));
+    
+    if( err == KErrNotFound )
+        {
+        datasourcefound = EFalse;
+        }
+    else
+        {
+        caleninfo = session->CalendarInfoL(); 
+        CleanupStack::PushL(caleninfo);
+                
+        //Get MARKASDELETE MetaData property
+        keyBuff.Zero();
+        TBool markAsdelete = EFalse;
+        keyBuff.AppendNum( EMarkAsDelete );
+        TPckgC<TBool> pckMarkAsDelete(markAsdelete);
+        TRAP(err,pckMarkAsDelete.Set(caleninfo->PropertyValueL(keyBuff)));
+        if ( err == KErrNone )
+            {
+            markAsdelete = pckMarkAsDelete();
+            if( markAsdelete )
+                {
+                datasourcefound = EFalse;
+                }
+            }
+        CleanupStack::PopAndDestroy(caleninfo);
+        }
+    CleanupStack::PopAndDestroy(session);
+    return datasourcefound;
+    }
+
+// -----------------------------------------------------------------------------
 // CAspContentList::ReadTaskL
 // 
 // -----------------------------------------------------------------------------
--- a/omads/omadsappui/AspSyncUtil/src/AspResHandler.cpp	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsappui/AspSyncUtil/src/AspResHandler.cpp	Thu Aug 19 09:41:17 2010 +0300
@@ -227,6 +227,54 @@
 	TUtil::StrCopy(aText, parse.FullName());
 	}
 
+/* Implementation of CMCC PIM v3 begins*/
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadProgressTextLC
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadProgressTextLC(const TDesC& aContent, TInt aCurrent, TInt aFinal, TInt aPhase)
+    {
+    HBufC* hBuf = NULL;
+    
+    TBool isCalendar = EFalse;
+    HBufC* content = ReadLC(R_ASP_CONTENT_NAME_CALENDAR);
+    if ( !content->Compare(aContent) )
+        {
+        isCalendar = ETrue;
+        }
+    CleanupStack::PopAndDestroy(content); //content
+    
+    if (aPhase == CAspState::EPhaseSending)
+        {
+        if (isCalendar)
+            {
+            hBuf = ReadProgressTextLC(R_QTN_SML_SYNC_SENDING_XOFY_CAL, aCurrent, aFinal, aContent);
+            }
+        else
+            {
+            hBuf = ReadProgressTextLC(R_QTN_SML_SYNC_SENDING_XOFY, aCurrent, aFinal, aContent);
+            }
+        }
+    else if (aPhase == CAspState::EPhaseReceiving)
+        {
+        if (isCalendar)
+            {
+            hBuf = ReadProgressTextLC(R_QTN_SML_SYNC_RECEIVING_XOFY_CAL, aCurrent, aFinal, aContent);
+            }
+        else
+            {
+            hBuf = ReadProgressTextLC(R_QTN_SML_SYNC_RECEIVING_XOFY, aCurrent, aFinal, aContent);
+            }
+        }
+    else
+        {
+        hBuf = HBufC::NewLC(0);  // empty string
+        }
+
+    return hBuf;
+    }
+/* Implementation of CMCC PIM v3 ends*/
 
 // -----------------------------------------------------------------------------
 // CAspResHandler::ReadProgressTextL
@@ -288,6 +336,61 @@
     return hBuf;
 	}
 
+/* Implementation of CMCC PIM v3 begins*/
+// -----------------------------------------------------------------------------
+// CAspResHandler::ReadProgressTextL
+//
+// Function constructs progress dialog text that is shown with progress bar.
+// Text format is one of the following:
+// "Sending %0N of %1N %U"
+// "Receiving %0U: %0N"
+// -----------------------------------------------------------------------------
+//
+HBufC* CAspResHandler::ReadProgressTextLC(TInt aResourceId, TInt aCurrent, TInt aFinal, const TDesC& aContent)
+    {
+    
+    if (aResourceId != iProgressTextFormatId)
+        {
+        delete iProgressTextFormat;
+        iProgressTextFormat = NULL;
+        iProgressTextFormat = StringLoader::LoadL(aResourceId, iEikEnv);
+        iProgressTextFormatId = aResourceId;
+        }
+    
+    TInt len = iProgressTextFormat->Length() + aContent.Length();// + 8;
+    
+    HBufC* hBuf = HBufC::NewLC(len);
+    TPtr ptr = hBuf->Des();
+
+    HBufC* temp = HBufC::NewLC(len);
+    TPtr tempPtr = temp->Des();
+    
+    if (iProgressTextFormatId == R_QTN_SML_SYNC_RECEIVING_XOFY || iProgressTextFormatId == R_QTN_SML_SYNC_RECEIVING_XOFY_CAL)
+        {
+        // replace %0N with current item
+        StringLoader::Format(tempPtr, iProgressTextFormat->Des(), 0, aCurrent);
+        }
+    else
+        {
+        // replace %0N with current item
+        StringLoader::Format(ptr, iProgressTextFormat->Des(), 0, aCurrent);
+        // replace %1N with total items
+        StringLoader::Format(tempPtr, ptr, 1, aFinal);
+        }
+    if (iProgressTextFormatId == R_QTN_SML_SYNC_RECEIVING_XOFY_CAL || iProgressTextFormatId == R_QTN_SML_SYNC_SENDING_XOFY_CAL)
+        {
+        ptr.Copy(tempPtr);
+        }
+    else
+        {
+        // replace  %0U with content name (eg "Contacts")
+        StringLoader::Format(ptr, tempPtr, 0, aContent);
+        }
+    CleanupStack::PopAndDestroy(temp); //temp
+    
+    return hBuf;
+    }
+/* Implementation of CMCC PIM v3 ends*/
 
 // -----------------------------------------------------------------------------
 // CAspResHandler::ReadProfileInfoTextLC
--- a/omads/omadsappui/AspSyncUtil/src/AspSyncHandler.cpp	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsappui/AspSyncUtil/src/AspSyncHandler.cpp	Thu Aug 19 09:41:17 2010 +0300
@@ -35,7 +35,7 @@
 #include "AspPreSyncPluginInterface.h"
 
 #include <DataSyncInternalPSKeys.h>
-
+#include <featmgr.h>
 
 /******************************************************************************
  * class TAspSyncParam
@@ -890,7 +890,18 @@
 			Dialog()->SetProgress(State()->Progress());
 			}
 			
-		HBufC* hBuf = ResHandlerL()->ReadProgressTextLC(State()->Content(), phase);
+		/* Implementation of CMCC PIM v3 begins*/
+		HBufC* hBuf = NULL;
+		if ( FeatureManager::FeatureSupported(KFeatureIdFfTdCmccpimsynchronizationprogressindicatorui) )
+		    {
+            // CMCC sync progress indicator enabled
+            hBuf = ResHandlerL()->ReadProgressTextLC(State()->Content(), State()->Progress(), State()->TotalProgress(), phase);
+            }
+		else
+		    {
+            hBuf = ResHandlerL()->ReadProgressTextLC(State()->Content(), phase);
+		    }
+		/* Implementation of CMCC PIM v3 ends*/
 		
 
 #ifdef _DEBUG
--- a/omads/omadsappui/AspSyncUtil/src/AspSyncUtil.rss	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsappui/AspSyncUtil/src/AspSyncUtil.rss	Thu Aug 19 09:41:17 2010 +0300
@@ -231,7 +231,13 @@
 //RESOURCE TBUF r_qtn_nsml_receving			    { buf = qtn_sml_sync_recv; }
 RESOURCE TBUF r_qtn_sml_sync_receiving		    { buf = qtn_sml_sync_receiving; }
 RESOURCE TBUF r_qtn_sml_sync_sending		    { buf = qtn_sml_sync_sending; }
-
+/* Implementation of CMCC PIM v3 begins*/ 
+RESOURCE TBUF r_qtn_sml_sync_receiving_xofy     { buf = qtn_sml_sync_receiving_xofy_tdscdma; }
+RESOURCE TBUF r_qtn_sml_sync_sending_xofy       { buf = qtn_sml_sync_sending_xofy_tdscdma; }
+RESOURCE TBUF r_qtn_sml_sync_receiving_xofy_cal { buf = qtn_sml_sync_receiving_xofy_cal_tdscdma; } 
+RESOURCE TBUF r_qtn_sml_sync_sending_xofy_cal   { buf = qtn_sml_sync_sending_xofy_cal_tdscdma; }
+RESOURCE TBUF r_qtn_nsml_log_err_serverfull     { buf = qtn_nsml_log_err_serverfull_tdscdma; }
+/* Implementation of CMCC PIM v3 ends*/
 
 // log dialog strings
 RESOURCE TBUF r_sml_log_synclog_title  		{ buf = qtn_sml_log_synclog_title; }
--- a/omads/omadsappui/AspSyncUtil/src/AspUtil.cpp	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsappui/AspSyncUtil/src/AspUtil.cpp	Thu Aug 19 09:41:17 2010 +0300
@@ -2446,6 +2446,15 @@
 	   	    id = R_ASP_LOG_ERR_SERVERERROR;  // "Error in sync server"
 		    break;
 	        
+		/* Implementation of CMCC PIM v3 begins*/
+		case SyncMLError::KErrServerFull:
+		    if ( FeatureManager::FeatureSupported(KFeatureIdFfTdCmccpimpromptserverfullwhenreceive420statuscodefromserver) )
+		        {
+                id = R_QTN_NSML_LOG_ERR_SERVERFULL;
+		        }
+		    break;
+		/* Implementation of CMCC PIM v3 ends*/
+		    
         default:
             id = R_ASP_LOG_ERR_SYSTEMERROR;  // "System Error"
 		    break;
--- a/omads/omadsextensions/adapters/agenda/inc/nsmlagendadatastore.h	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsextensions/adapters/agenda/inc/nsmlagendadatastore.h	Thu Aug 19 09:41:17 2010 +0300
@@ -49,6 +49,9 @@
 const TInt KNSmlCompactAfterChanges        = 30;
 const TInt KNSmlDefaultStoreNameMaxSize    = 256;
 const TInt KNSmlItemDataExpandSize         = 1024;
+const TInt KDbPersonal                     = 100000;
+const TUid KRepositoryId                   = { 0x2000CF7E };   
+const TInt KNsmlDsOrphanEvent              = 0xB ;
 const TUint KNSmlAgendaAdapterUid    	   = 0x101F6DDD;
 const TUint KNSmlAgendaAdapterStreamUid    = 0x101F6DDD+0x10009d8d;
 _LIT( KNSmlDriveC, "C" );
@@ -678,6 +681,8 @@
         CNSmlAgendaAdapterHandler* iAgendaAdapterHandler;
         // SyncRelationship instance
         CNSmlAgendaAdapterLog* iAgendaAdapterLog;
+        // Flag indicating a Orphan Event
+        TBool iOrphanEvent;
 	};
 
 // ----------------------------------------------------------------------------
--- a/omads/omadsextensions/adapters/agenda/src/nsmlagendadatastore.cpp	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsextensions/adapters/agenda/src/nsmlagendadatastore.cpp	Thu Aug 19 09:41:17 2010 +0300
@@ -78,7 +78,8 @@
 	iRXEntryType( ENSmlNotSet ),
 	iTXEntryType( ENSmlNotSet ),
 	iIsHierarchicalSyncSupported( EFalse ),
-	iParentItemId( 0 )
+	iParentItemId( 0 ),
+    iOrphanEvent( EFalse )
 	{
 	FLOG(_L("CNSmlAgendaDataStore::CNSmlAgendaDataStore(): BEGIN"));
 	// RD_MULTICAL
@@ -254,38 +255,7 @@
 		{
 		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 )
 	    {
@@ -779,11 +749,39 @@
         TInt err( KErrNone );
         // Check the Sync Status
         if( iIsHierarchicalSyncSupported )
-            {
-            TBool syncstatus( EFalse );
-            TRAP( err, syncstatus = iAgendaAdapterHandler->FolderSyncStatusL( aParent ) );
+            {   
+            FLOG(_L("CNSmlAgendaDataStore::DoCreateItemL Supports Hierarchichal"));
+            // Check that parent exists
+            iParentItemId = aParent;
+            if ( iParentItemId == KDbItemUidRoot 
+                 && iDataMimeType == ENSmlCalendar )
+                {
+                FLOG(_L("CNSmlAgendaDataStore::DoCreateItemL: ParentId is NULL"));
+                iParentItemId = NULL;
+                iOrphanEvent = ETrue;
+                iParentItemId = KDbPersonal;
+                }
+          
+            TInt index = KErrNotFound;
+            TInt err = KErrNone;
+            TKeyArrayFix key( 0, ECmpTInt ); // Find key for Ids.
+            
+            err = iCalOffsetArr->Find( iParentItemId, key, index );
+         
+            if( err != KErrNone && iDataMimeType == ENSmlCalendar )
+                {
+                FLOG(_L("CNSmlAgendaDataStore::DoCreateItemL: ParentId is NotFound"));
+                iParentItemId = NULL;
+                iOrphanEvent = EFalse;
+                User::RequestComplete( iCallerStatus, KErrNotFound );
+                return;
+                }           
+            // Check the Sync Status    
+			TBool syncstatus( EFalse );   
+            TRAP( err, syncstatus = iAgendaAdapterHandler->FolderSyncStatusL( iParentItemId ) );
             if( err || !syncstatus  )
                 {
+                iOrphanEvent = EFalse;
                 User::RequestComplete( iCallerStatus, err );
                 FLOG(_L("CNSmlAgendaDataStore::DoCreateItemL - Sync Disabled: END"));
                 return;
@@ -837,35 +835,7 @@
         return;
         }
     
-	if( iIsHierarchicalSyncSupported )
-		{	
-	    // Check that parent exists
-	    iParentItemId = aParent;
-	    if ( iParentItemId == KDbItemUidRoot 
-	         && iDataMimeType == ENSmlCalendar )
-	        {
-	        FLOG(_L("CNSmlAgendaDataStore::DoCreateItemL: ParentId is NULL"));
-	        iParentItemId = NULL;
-	        User::RequestComplete( iCallerStatus, KErrGeneral );
-	        return;
-	        }
-	  
-	    TInt index = KErrNotFound;
-	    TInt err = KErrNone;
-	    TKeyArrayFix key( 0, ECmpTInt ); // Find key for Ids.
-	    
-	    err = iCalOffsetArr->Find( iParentItemId, key, index );
-	 
-	    if( err != KErrNone && iDataMimeType == ENSmlCalendar )
-	        {
-	        FLOG(_L("CNSmlAgendaDataStore::DoCreateItemL: ParentId is NotFound"));
-	        iParentItemId = NULL;
-	        User::RequestComplete( iCallerStatus, KErrNotFound );
-	        return;
-	        }
-		}
-    
-    // TODO: Any other validation is required ?
+    // TODO: Any other validation is required ?  
     
     // Register snapshots if needed
     if( !iSnapshotRegistered )
@@ -2217,6 +2187,7 @@
         {
         FLOG(_L("CNSmlAgendaDataStore::DoCommitCreateCalItemL:Invalid CalendarInfo"));
         CleanupStack::PopAndDestroy( 2 ); // rdArray, readStream
+        iOrphanEvent = EFalse;
         User::Leave( KErrNotFound );
         }
         
@@ -2233,6 +2204,7 @@
         FLOG(_L("CNSmlAgendaDataStore::DoCommitCreateCalItemL:Invalid CalendarInfo"));
         CleanupStack::PopAndDestroy( 2 ); // rdArray, readStream
         delete calfilename;
+        iOrphanEvent = EFalse;
         User::Leave( KErrNotFound );
         }
         
@@ -2253,6 +2225,7 @@
         delete calfilename; 
         FLOG(_L("CNSmlAgendaDataStore::DoCommitCreateCalItemL - \
                    KErrNotSupported: END"));
+        iOrphanEvent = EFalse;
         User::Leave( KErrNotSupported );
         }
     
@@ -2265,6 +2238,7 @@
         delete calfilename; 
         FLOG(_L("CNSmlAgendaDataStore::DoCommitCreateCalItemL - \
                    Multiple items are not supported: END"));
+        iOrphanEvent = EFalse;
         User::Leave( KErrNotSupported );
         }           
         
@@ -2279,6 +2253,7 @@
         delete calfilename; 
         FLOG(_L("CNSmlAgendaDataStore::DoCommitCreateCalItemL - \
                    Error at storing item to database: END"));
+        iOrphanEvent = EFalse;
         User::Leave( KErrGeneral );
         }
 
@@ -2322,7 +2297,19 @@
 	CleanupStack::PopAndDestroy( 2 ); //  rdArray, readStream 
     delete agendautil;
 	delete calfilename;     	
-      
+    
+	if( iOrphanEvent )
+	    {
+        FLOG(_L("CNSmlAgendaDataStore::DoCommitCreateCalItemL: Exiting with invalidparent"));
+        // Set the Orphan Event ID to the cenrep
+        CRepository* rep = CRepository::NewLC(KRepositoryId);
+        TInt err = rep->Set( KNsmlDsOrphanEvent, *iAddItemId );
+        DBG_ARGS(_S("set the cenrep %d "), err);
+        User::LeaveIfError(err);
+        CleanupStack::PopAndDestroy(rep);
+        iOrphanEvent = EFalse;
+        User::Leave( KErrPathNotFound );        
+	    }	
     FLOG(_L("CNSmlAgendaDataStore::DoCommitCreateCalItemL: END"));
     }
     
@@ -3159,6 +3146,7 @@
     
     for(TInt i = 0; i < calfilearr->Count(); i++)
         {
+		TInt err = KErrNone;
         vCalSubSession = CCalSession::NewL(*vCalSession);
         CleanupStack::PushL(vCalSubSession);
         vCalSubSession->OpenL(calfilearr->MdcaPoint(i));
@@ -3166,11 +3154,30 @@
         CCalCalendarInfo* caleninfo = vCalSubSession->CalendarInfoL();
         CleanupStack::PushL(caleninfo);
         
+		//Get MARKASDELETE MetaData property
+		keyBuff.Zero();
+		TBool markAsdelete = EFalse;
+		keyBuff.AppendNum( EMarkAsDelete );
+		TPckgC<TBool> pckMarkAsDelete(markAsdelete);
+		TRAP(err,pckMarkAsDelete.Set(caleninfo->PropertyValueL(keyBuff)));
+		if ( err == KErrNone )
+			{
+			markAsdelete = pckMarkAsDelete();
+			if( markAsdelete )
+				{
+				FLOG(_L("CNSmlAgendaDataStore::IsCalFileAvailableL: Dead Calendar"));
+				CleanupStack::PopAndDestroy(caleninfo);
+				CleanupStack::PopAndDestroy(vCalSubSession);  	  	 
+				continue;
+				}
+			}
+		
+		//Get the ProfileId MetaData property 
         TInt ProfileId;
         keyBuff.Zero();
         keyBuff.AppendNum( EDeviceSyncProfileID );
         TPckgC<TInt> intBuf(ProfileId);
-        TRAPD(err,intBuf.Set(caleninfo->PropertyValueL(keyBuff)));
+        TRAP(err,intBuf.Set(caleninfo->PropertyValueL(keyBuff)));
                     
         if( err != KErrNone )
             {
--- a/omads/omadsextensions/dsutils/nsmldefaultagendahandler/src/nsmldefaultagendahandlerplugin.cpp	Thu Jul 15 18:23:06 2010 +0300
+++ b/omads/omadsextensions/dsutils/nsmldefaultagendahandler/src/nsmldefaultagendahandlerplugin.cpp	Thu Aug 19 09:41:17 2010 +0300
@@ -241,6 +241,24 @@
             CleanupStack::PopAndDestroy(vCalSubSession);  	  	 
             continue;
             }
+			
+		//Get MARKASDELETE MetaData property
+		keyBuff.Zero();
+		TBool markAsdelete = EFalse;
+		keyBuff.AppendNum( EMarkAsDelete );
+		TPckgC<TBool> pckMarkAsDelete(markAsdelete);
+		TRAP(err,pckMarkAsDelete.Set(caleninfo->PropertyValueL(keyBuff)));
+		if ( err == KErrNone )
+			{
+			markAsdelete = pckMarkAsDelete();
+			if( markAsdelete )
+				{
+				FLOG(_L("CNSmlDefaultAgendaHandlerPlugin::SynchronizableCalendarIdsL: Dead Calendar, not including in the snapshot"));
+				CleanupStack::PopAndDestroy(caleninfo);
+				CleanupStack::PopAndDestroy(vCalSubSession);  	  	 
+				continue;
+				}
+			}
         
         //Get OWNER value associated with the CalFile
         keyBuff.Zero();