syncmlfw/ds/dsutils/dbcaps/src/NSmldbcapsSerializer.cpp
branchRCL_3
changeset 61 b183ec05bd8c
parent 23 007508d6e57b
child 62 19bba8228ff0
equal deleted inserted replaced
59:13d7c31c74e0 61:b183ec05bd8c
   342 	CNSmlDataStoreFormatFromDbCaps* self = new ( ELeave ) CNSmlDataStoreFormatFromDbCaps();
   342 	CNSmlDataStoreFormatFromDbCaps* self = new ( ELeave ) CNSmlDataStoreFormatFromDbCaps();
   343 	CleanupStack::PushL( self );
   343 	CleanupStack::PushL( self );
   344 	const sml_devinf_datastore_s* dds = aDbCaps.Datastore();
   344 	const sml_devinf_datastore_s* dds = aDbCaps.Datastore();
   345 	
   345 	
   346 	//display name
   346 	//display name
   347 	if(dds)
   347 	NSmlUnicodeConverter::HBufC16InUnicodeLC( 
   348 	    {
   348 		TNSmlDbCapsSerializer::SafePtr( dds->displayname ), self->iDisplayName );
   349         NSmlUnicodeConverter::HBufC16InUnicodeLC( 
   349 	CleanupStack::Pop( self->iDisplayName ); // self->iDisplayName
   350                 TNSmlDbCapsSerializer::SafePtr( dds->displayname ), self->iDisplayName );
       
   351         CleanupStack::Pop( self->iDisplayName ); // self->iDisplayName
       
   352 	    }
       
   353 	
   350 	
   354 	//sync types
   351 	//sync types
   355 	TSmlSyncTypeMask& synctype( self->iSyncTypeMask );
   352 	TSmlSyncTypeMask& synctype( self->iSyncTypeMask );
   356 			
   353 			
   357 	if ( aDbCaps.SupportsSyncType( CNSmlDbCaps::ETwoWaySync ) )
   354 	if ( aDbCaps.SupportsSyncType( CNSmlDbCaps::ETwoWaySync ) )
   405 		}
   402 		}
   406 	else
   403 	else
   407 		{
   404 		{
   408 		synctype.SetNotSupported( ESmlRefreshFromClient );
   405 		synctype.SetNotSupported( ESmlRefreshFromClient );
   409 		}
   406 		}
   410 	if (dds)
   407 	
   411         {
   408 	if ( dds->dsmem )
   412         if ( dds->dsmem )
   409 		{
   413             {
   410 		//max size
   414             //max size
   411 		if ( dds->dsmem->maxmem )
   415             if ( dds->dsmem->maxmem )
   412 			{
   416                 {
   413 			TLex8 lex( dds->dsmem->maxmem->Data() );
   417                 TLex8 lex( dds->dsmem->maxmem->Data() );
   414 			User::LeaveIfError( lex.Val( self->iMaxSize, EDecimal ) );
   418                 User::LeaveIfError( lex.Val( self->iMaxSize, EDecimal ) );
   415 			self->iFlags |= KSmlDataStore_HasMaxSize;
   419                 self->iFlags |= KSmlDataStore_HasMaxSize;
   416 			}
   420                 }
   417 		
   421             
   418 		//max items
   422             //max items
   419 		if ( dds->dsmem->maxid )
   423             if ( dds->dsmem->maxid )
   420 			{
   424                 {
   421 			TLex8 lex( dds->dsmem->maxid->Data() );
   425                 TLex8 lex( dds->dsmem->maxid->Data() );
   422 			User::LeaveIfError( lex.Val( self->iMaxItems, EDecimal ) );
   426                 User::LeaveIfError( lex.Val( self->iMaxItems, EDecimal ) );
   423 			self->iFlags |= KSmlDataStore_HasMaxItems;
   427                 self->iFlags |= KSmlDataStore_HasMaxItems;
   424 			}
   428                 }
   425 		}
   429             }
   426 	
   430         
   427 	//options
   431         
   428 	if ( dds->supportHierarchicalSync )
   432         //options
   429 		{
   433         if ( dds->supportHierarchicalSync )
   430 		self->iFlags |= KSmlDataStore_Hierarchical;
   434             {
   431 		}
   435             self->iFlags |= KSmlDataStore_Hierarchical;
       
   436             }
       
   437         }
       
   438 	
   432 	
   439 	//filter caps
   433 	//filter caps
   440 	const sml_devinf_filtercaplist_s* filterList = aDbCaps.FilterCapsList();
   434 	const sml_devinf_filtercaplist_s* filterList = aDbCaps.FilterCapsList();
   441 	
   435 	
   442 	for ( ; filterList; filterList = filterList->next )
   436 	for ( ; filterList; filterList = filterList->next )
   454 	RPointerArray<CSmlMimeFormat> mimeFormatArray;
   448 	RPointerArray<CSmlMimeFormat> mimeFormatArray;
   455 	CleanupClosePushL( mimeFormatArray );
   449 	CleanupClosePushL( mimeFormatArray );
   456 	// First search all mime types that server supports at receiving
   450 	// First search all mime types that server supports at receiving
   457 	// RX-pref
   451 	// RX-pref
   458 	CSmlMimeFormat* tempFormatRX = CSmlMimeFormat::NewLC();
   452 	CSmlMimeFormat* tempFormatRX = CSmlMimeFormat::NewLC();
   459     if( dds )
   453 	const TPtrC8& ctTypeRX = TNSmlDbCapsSerializer::SafePtr( dds->rxpref->cttype );
   460         {
   454 	const TPtrC8& verCtRX = TNSmlDbCapsSerializer::SafePtr( dds->rxpref->verct );
   461         const TPtrC8& ctTypeRX = TNSmlDbCapsSerializer::SafePtr( dds->rxpref->cttype );
   455 	if ( ctTypeRX.Compare( KNullDesC8 ) != 0 && verCtRX.Compare( KNullDesC8 ) != 0 )
   462         const TPtrC8& verCtRX = TNSmlDbCapsSerializer::SafePtr( dds->rxpref->verct );
   456 		{
   463                     
   457 		RStringF mimeFormatRX = aStringPool.OpenFStringL( ctTypeRX );
   464         if ( ctTypeRX.Compare( KNullDesC8 ) != 0 && verCtRX.Compare( KNullDesC8 ) != 0 )
   458 		RStringF mimeVersionRX = aStringPool.OpenFStringL( verCtRX );
   465             {
   459 		tempFormatRX->SetMimeTypeL( mimeFormatRX );
   466             RStringF mimeFormatRX = aStringPool.OpenFStringL( ctTypeRX );
   460 		tempFormatRX->SetMimeVersionL( mimeVersionRX );
   467             RStringF mimeVersionRX = aStringPool.OpenFStringL( verCtRX );
   461 		mimeFormatArray.AppendL( tempFormatRX );
   468             tempFormatRX->SetMimeTypeL( mimeFormatRX );
   462 		CleanupStack::Pop(); // tempFormatRX
   469             tempFormatRX->SetMimeVersionL( mimeVersionRX );
   463 		}
   470             mimeFormatArray.AppendL( tempFormatRX );
   464 	else
   471             CleanupStack::Pop(); // tempFormatRX
   465 		{
   472             }
   466 		CleanupStack::PopAndDestroy(); // tempFormatRX
   473         else
   467 		}
   474             {
   468 	// RXs
   475             CleanupStack::PopAndDestroy(); // tempFormatRX
   469 	if ( dds )
   476             }
   470 		{
   477         // RXs
   471 		SmlDevInfXmitListPtr_t rx = dds->rx;
   478         
   472 		for ( ; rx ; rx = rx->next )
   479             SmlDevInfXmitListPtr_t rx = dds->rx;
   473 			{
   480             for ( ; rx ; rx = rx->next )
   474 			CSmlMimeFormat* tempFormat = CSmlMimeFormat::NewLC();
   481                 {
   475 			const TPtrC8& ctType = TNSmlDbCapsSerializer::SafePtr( rx->data->cttype );
   482                 CSmlMimeFormat* tempFormat = CSmlMimeFormat::NewLC();
   476 			const TPtrC8& verCt = TNSmlDbCapsSerializer::SafePtr( rx->data->verct );
   483                 const TPtrC8& ctType = TNSmlDbCapsSerializer::SafePtr( rx->data->cttype );
   477 			if ( ctType.Compare( KNullDesC8 ) != 0 && verCt.Compare( KNullDesC8 ) != 0 )
   484                 const TPtrC8& verCt = TNSmlDbCapsSerializer::SafePtr( rx->data->verct );
   478 				{
   485                 if ( ctType.Compare( KNullDesC8 ) != 0 && verCt.Compare( KNullDesC8 ) != 0 )
   479 				RStringF mimeFormat = aStringPool.OpenFStringL( ctType );
   486                     {
   480 				RStringF mimeVersion = aStringPool.OpenFStringL( verCt );
   487                     RStringF mimeFormat = aStringPool.OpenFStringL( ctType );
   481 				tempFormat->SetMimeTypeL( mimeFormat );
   488                     RStringF mimeVersion = aStringPool.OpenFStringL( verCt );
   482 				tempFormat->SetMimeVersionL( mimeVersion );
   489                     tempFormat->SetMimeTypeL( mimeFormat );
   483 				mimeFormatArray.AppendL( tempFormat );
   490                     tempFormat->SetMimeVersionL( mimeVersion );
   484 				CleanupStack::Pop(); // tempFormat
   491                     mimeFormatArray.AppendL( tempFormat );
   485 				}
   492                     CleanupStack::Pop(); // tempFormat
   486 			else
   493                     }
   487 				{
   494                 else
   488 				CleanupStack::PopAndDestroy(); // tempFormat
   495                     {
   489 				}
   496                     CleanupStack::PopAndDestroy(); // tempFormat
   490 			}
   497                     }
   491 		}
   498                 }
   492 	
   499             
   493 	const sml_devinf_ctcaplist_s*  ctCapList = dds->ctcap;
   500         
   494 	if ( ctCapList == 0 )
   501         const sml_devinf_ctcaplist_s*  ctCapList = dds->ctcap;
   495 		{
   502         if ( ctCapList == 0 )
   496 		ctCapList = aDbCaps.CtCaps();
   503             {
   497 		}
   504             ctCapList = aDbCaps.CtCaps();
   498 	// Then add CTCaps to correct mime types
   505             }
   499 	if ( ctCapList != 0 )
   506         // Then add CTCaps to correct mime types
   500 	    {    
   507         if ( ctCapList != 0 )
   501         for (; ctCapList; ctCapList = ctCapList->next )
   508             {    
   502     		{
   509             for (; ctCapList; ctCapList = ctCapList->next )
   503     		const SmlDevInfCtCapPtr_t ctCap = ctCapList->data;
   510                 {
   504     		if ( ctCap->cttype->Data() == KNSmlFolderType )
   511                 const SmlDevInfCtCapPtr_t ctCap = ctCapList->data;
   505     			{
   512                 if ( ctCap->cttype->Data() == KNSmlFolderType )
   506     			SmlDevInfPropertyListPtr_t dipl = ctCap->property;
   513                     {
   507     			for ( ; dipl; dipl = dipl->next )
   514                     SmlDevInfPropertyListPtr_t dipl = ctCap->property;
   508     				{
   515                     for ( ; dipl; dipl = dipl->next )
   509     				const SmlDevInfPropertyPtr_t dip = dipl->data;
   516                         {
   510     				if ( dip )
   517                         const SmlDevInfPropertyPtr_t dip = dipl->data;
   511     					{
   518                         if ( dip )
   512     					CSmlDataProperty *temppoint = CNSmlDataPropertyFromDbCaps::NewLC( aStringPool, dip );
   519                             {
   513     					self->iFolderProperties.AppendL( temppoint );
   520                             CSmlDataProperty *temppoint = CNSmlDataPropertyFromDbCaps::NewLC( aStringPool, dip );
   514     					CleanupStack::Pop(); //  temppoint
   521                             self->iFolderProperties.AppendL( temppoint );
   515     					}
   522                             CleanupStack::Pop(); //  temppoint
   516     				}
   523                             }
   517     			}
   524                         }
   518     		else
   525                     }
   519     			{
   526                 else
   520     			for ( TInt j(0); j < mimeFormatArray.Count(); j++ )
   527                     {
   521     			    {
   528                     for ( TInt j(0); j < mimeFormatArray.Count(); j++ )
   522     			    if ( mimeFormatArray[j]->MimeType().DesC().Compare( ctCap->cttype->Data() ) == 0 )
   529                         {
   523     			        {
   530                         if ( mimeFormatArray[j]->MimeType().DesC().Compare( ctCap->cttype->Data() ) == 0 )
   524     			        // Mime version is only in rx-pref or in rx so it must be copied to new mime format
   531                             {
   525     			        CSmlMimeFormat* temppoint = CNSmlMimeFormatFromDbCaps::NewLC( aStringPool, *ctCap );
   532                             // Mime version is only in rx-pref or in rx so it must be copied to new mime format
   526     			        RStringF newMimeVersion = aStringPool.OpenFStringL( mimeFormatArray[j]->MimeVersion().DesC() );
   533                             CSmlMimeFormat* temppoint = CNSmlMimeFormatFromDbCaps::NewLC( aStringPool, *ctCap );
   527     			        temppoint->SetMimeVersionL( newMimeVersion );
   534                             RStringF newMimeVersion = aStringPool.OpenFStringL( mimeFormatArray[j]->MimeVersion().DesC() );
   528     			        delete mimeFormatArray[j];
   535                             temppoint->SetMimeVersionL( newMimeVersion );
   529     			        mimeFormatArray[j] = NULL;
   536                             delete mimeFormatArray[j];
   530     			        mimeFormatArray[j] = temppoint;
   537                             mimeFormatArray[j] = NULL;
   531     			        CleanupStack::Pop(); //  temppoint
   538                             mimeFormatArray[j] = temppoint;
   532     			        }
   539                             CleanupStack::Pop(); //  temppoint
   533     			    }
   540                             }
   534     			}
   541                         }
   535     		}
   542                     }
   536 	    }
   543                 }
       
   544             }
       
   545         }
       
   546 	self->SetMimeFormatsL( mimeFormatArray );
   537 	self->SetMimeFormatsL( mimeFormatArray );
   547 	mimeFormatArray.ResetAndDestroy();
   538 	mimeFormatArray.ResetAndDestroy();
   548 	CleanupStack::PopAndDestroy(); // mimeFormatArray
   539 	CleanupStack::PopAndDestroy(); // mimeFormatArray
   549 	return self;
   540 	return self;
   550 	}
   541 	}