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