omads/omadsextensions/adapters/notes/src/NSmlNotepadDataStore.cpp
changeset 30 04643625ed38
parent 22 1a3f0bca12c6
child 41 e32446434994
child 54 13ecdfc9a581
equal deleted inserted replaced
26:fdc38da86094 30:04643625ed38
   193 	    {
   193 	    {
   194 		delete iDefaultStoreName;
   194 		delete iDefaultStoreName;
   195 		iDefaultStoreName = NULL;
   195 		iDefaultStoreName = NULL;
   196 	    }
   196 	    }
   197 	iDefaultStoreName = HBufC::NewL( KNSmlDefaultStoreNameMaxSize );
   197 	iDefaultStoreName = HBufC::NewL( KNSmlDefaultStoreNameMaxSize );
   198 	TInt len = iDefaultStoreName->Length();
   198 	*iDefaultStoreName = KNSmlNotepadStoreName; 
   199 	TPtr obptr = iDefaultStoreName->Des();
   199 	
   200 	iNpdDb->GetDefaultDatastoreName(obptr);
       
   201 	if(iOwnStoreFormat)
   200 	if(iOwnStoreFormat)
   202 	    {
   201 	    {
   203 		delete iOwnStoreFormat;
   202 		delete iOwnStoreFormat;
   204 		iOwnStoreFormat = NULL;
   203 		iOwnStoreFormat = NULL;
   205 	    }
   204 	    }
   230 // CDesCArray* CNSmlNotepadDataStore::DoListStoresLC();
   229 // CDesCArray* CNSmlNotepadDataStore::DoListStoresLC();
   231 // ----------------------------------------------------------------------------
   230 // ----------------------------------------------------------------------------
   232 CDesCArray* CNSmlNotepadDataStore::DoListStoresLC()
   231 CDesCArray* CNSmlNotepadDataStore::DoListStoresLC()
   233 	{
   232 	{
   234 	_NOTEPAD_DBG_FILE("CNSmlNotepadDataStore::DoListStoresLC(): begin");
   233 	_NOTEPAD_DBG_FILE("CNSmlNotepadDataStore::DoListStoresLC(): begin");
   235 	CDesCArray* npdStores = iNpdDb->ListDatabasesL();
   234 	CDesCArrayFlat *npdStores = new (ELeave)CDesCArrayFlat(1);
   236 	CleanupStack::PushL( npdStores );
   235     CleanupStack::PushL(npdStores);
   237 	_NOTEPAD_DBG_FILE("CNSmlNotepadDataStore::DoListStoresLC(): end");
   236     npdStores->AppendL(KNSmlNotepadStoreName);
       
   237     _NOTEPAD_DBG_FILE("CNSmlNotepadDataStore::DoListStoresLC(): end");
   238 	return npdStores;
   238 	return npdStores;
   239 	}
   239 	}
   240 	
   240 	
   241 // ----------------------------------------------------------------------------
   241 // ----------------------------------------------------------------------------
   242 // void CNSmlNotepadDataStore::DoOpenL(const TDesC& 		  aStoreName, 
   242 // void CNSmlNotepadDataStore::DoOpenL(const TDesC& 		  aStoreName, 
   245 // ----------------------------------------------------------------------------
   245 // ----------------------------------------------------------------------------
   246 void CNSmlNotepadDataStore::DoOpenL( const TDesC& aStoreName, 
   246 void CNSmlNotepadDataStore::DoOpenL( const TDesC& aStoreName, 
   247 									MSmlSyncRelationship& aContext, 
   247 									MSmlSyncRelationship& aContext, 
   248 									TRequestStatus& aStatus )
   248 									TRequestStatus& aStatus )
   249     {
   249     {
   250 	iCallerStatus = &aStatus;
   250     _NOTEPAD_DBG_FILE("CNSmlNotepadDataStore::DoOpenL(): begin");	
       
   251     iCallerStatus = &aStatus;
   251 	*iCallerStatus = KRequestPending;
   252 	*iCallerStatus = KRequestPending;
   252 	if( iState != ENSmlClosed || iDataBaseOpened )
   253 	if( iState != ENSmlClosed || iDataBaseOpened )
   253 	    {
   254 	    {
       
   255         
   254 		User::RequestComplete( iCallerStatus, KErrInUse );	
   256 		User::RequestComplete( iCallerStatus, KErrInUse );	
   255 		return;	
   257 		return;	
   256 	    }
   258 	    }
   257 	if(aStoreName.Length()>0)
   259 	if(aStoreName.Length()>0)
   258 	    {
   260 	    {
   262             }	
   264             }	
   263 	    }
   265 	    }
   264 		
   266 		
   265 	// Open the Database
   267 	// Open the Database
   266 	TInt err( KErrNone );
   268 	TInt err( KErrNone );
   267 	TRAP(err,iNpdDb->OpenL( aStoreName ));
   269 	TRAP(err,iNpdDb->OpenL( KNSmlNotepadDefaultStoreName ));
   268 	if ( err )
   270 	if ( err )
   269         {
   271         {
   270         User::RequestComplete( iCallerStatus, err );
   272         User::RequestComplete( iCallerStatus, err );
   271         return;
   273         return;
   272         }
   274         }
   274     if ( iOpenedStoreName )
   276     if ( iOpenedStoreName )
   275         {
   277         {
   276         delete iOpenedStoreName;
   278         delete iOpenedStoreName;
   277         iOpenedStoreName = NULL;
   279         iOpenedStoreName = NULL;
   278         }
   280         }
   279     iOpenedStoreName = aStoreName.Alloc();
   281     iOpenedStoreName = HBufC::NewL( KNSmlDefaultStoreNameMaxSize );
       
   282     *iOpenedStoreName = KNSmlNotepadStoreName;
   280     
   283     
   281     iDataBaseOpened = ETrue;
   284     iDataBaseOpened = ETrue;
   282 		
   285 		
   283 	if ( iChangeFinder )
   286 	if ( iChangeFinder )
   284 		{
   287 		{
   287 		iChangeFinder = NULL;
   290 		iChangeFinder = NULL;
   288 		}
   291 		}
   289 	iChangeFinder = CNSmlChangeFinder::NewL( aContext, iKey, iSyncHistory, KNSmlNotepadAdapterImplUid );
   292 	iChangeFinder = CNSmlChangeFinder::NewL( aContext, iKey, iSyncHistory, KNSmlNotepadAdapterImplUid );
   290 	
   293 	
   291 	err = FetchModificationsL();
   294 	err = FetchModificationsL();
       
   295 	
   292 	
   296 	
   293 	iState = ENSmlOpenAndWaiting;	
   297 	iState = ENSmlOpenAndWaiting;	
   294 	User::RequestComplete( iCallerStatus, err );
   298 	User::RequestComplete( iCallerStatus, err );
   295 	
   299 	
   296 	_NOTEPAD_DBG_FILE("CNSmlNotepadDataStore::DoOpenL(): end");
   300 	_NOTEPAD_DBG_FILE("CNSmlNotepadDataStore::DoOpenL(): end");