syncmlfw/common/alertqueue/src/NSmlDSAlertParser11.cpp
changeset 0 b497e44ab2fc
child 60 eb6690d0d439
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Parser for SyncML 1.1 formatted alert message
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32mem.h>
       
    20 #include <SyncMLHistory.h>
       
    21 #include <SyncMLAlertInfo.h>
       
    22 #include <ecom.h>
       
    23 #include <barsread.h>
       
    24 #include <barsc.h>
       
    25 #include <s32mem.h>
       
    26 #include <data_caging_path_literals.hrh>
       
    27 #include <NSmlDSTypesRes.rsg>
       
    28 
       
    29 #include <nsmlconstants.h>
       
    30 #include <nsmlunicodeconverter.h>
       
    31 #include <nsmldsconstants.h>
       
    32 #include "nsmldshostclient.h"
       
    33 #include "nsmldsagconstants.h"
       
    34 #include "NSmlAlertQueue.h"
       
    35 #include <nsmldebug.h>
       
    36 
       
    37 // ---------------------------------------------------------
       
    38 // CNSmlDSAlertParser11::CNSmlDSAlertParser11(CSmlAlertInfo& aAlertInfo, CSyncMLHistoryPushMsg& aHistoryInfo )
       
    39 // Constructor
       
    40 // ---------------------------------------------------------
       
    41 CNSmlDSAlertParser11::CNSmlDSAlertParser11( CSmlAlertInfo& aAlertInfo, CSyncMLHistoryPushMsg& aHistoryInfo )
       
    42 : CNSmlMessageParserBase( aAlertInfo, aHistoryInfo )
       
    43 	{
       
    44 	_DBG_FILE("CNSmlDSAlertParser11::CNSmlDSAlertParser11");
       
    45 	}
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CNSmlDSAlertParser11::~CNSmlDSAlertParser11()
       
    49 // Destructor
       
    50 // ---------------------------------------------------------
       
    51 CNSmlDSAlertParser11::~CNSmlDSAlertParser11()
       
    52 	{
       
    53 	_DBG_FILE("CNSmlDSAlertParser11::~CNSmlDSAlertParser11");
       
    54 	}
       
    55 	
       
    56 // ---------------------------------------------------------
       
    57 // CNSmlDSAlertParser11::ParseMessageL()
       
    58 // Parses the message
       
    59 // ---------------------------------------------------------
       
    60 void CNSmlDSAlertParser11::ParseMessageL()
       
    61 	{
       
    62 	_DBG_FILE("CNSmlDSAlertParser11::ParseMessageL : Begin");
       
    63 	CWBXMLSyncMLDocHandler* docHandler = CWBXMLSyncMLDocHandler::NewL( this );
       
    64 	CleanupStack::PushL( docHandler );
       
    65 	CWBXMLParser* parser = CWBXMLParser::NewL();
       
    66 	CleanupStack::PushL( parser );
       
    67 	parser->SetDocumentHandler( docHandler );
       
    68 	parser->SetExtensionHandler( docHandler );
       
    69 	RDesReadStream readStream;
       
    70 	readStream.Open( Message() );
       
    71 	CleanupClosePushL ( readStream );
       
    72 	parser->SetDocumentL( readStream );
       
    73 	TWBXMLParserError ret = KWBXMLParserErrorOk;
       
    74 
       
    75 	while ( ret == KWBXMLParserErrorOk )
       
    76 		{
       
    77 	    ret = parser->ParseL();
       
    78 		}
       
    79 	
       
    80 	if ( iFoundProfiles.Count() == 0 )
       
    81 		{
       
    82 		iAlertInfo.SetProfileId( KNSmlNullId );
       
    83 		User::Leave(KErrNotFound);
       
    84 		}
       
    85 	
       
    86 	ResolveProfileL( iContentCount );
       
    87 	
       
    88 	iAlertInfo.SetJobControl( CSmlAlertInfo::ECreateJob );
       
    89 	
       
    90 	CleanupStack::PopAndDestroy( 3 ); //readStream, parser, docHandler
       
    91 	_DBG_FILE("CNSmlDSAlertParser11::ParseMessageL : End");
       
    92 	}
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // CNSmlDSAlertParser11::ResolveProfileL()
       
    96 // Resolves profile if more than one match is found
       
    97 // ---------------------------------------------------------
       
    98 void CNSmlDSAlertParser11::ResolveProfileL( TInt /*aContentCount*/ )
       
    99 	{
       
   100 	CNSmlAlertInfo* info = NULL;
       
   101 	TInt matchCheck(0);
       
   102 	TInt matchIndex(0);
       
   103 	
       
   104 	TBool match(EFalse);
       
   105 	
       
   106 	for (TInt index = 0; index < iFoundProfiles.Count(); index++)
       
   107 		{
       
   108 		info = iFoundProfiles[index];
       
   109 		
       
   110 		if (info->iMatchCount == iContentCount)
       
   111 			{
       
   112 			match = ETrue;
       
   113 			break; //all contents found and full match
       
   114 			}
       
   115 		
       
   116 		if ( info->iMatchCount > matchCheck )
       
   117 			{
       
   118 			matchIndex = index;
       
   119 			}
       
   120 		
       
   121 		}
       
   122 			
       
   123 	if ( !match )	
       
   124 		{
       
   125 		info = iFoundProfiles[matchIndex];
       
   126 		}
       
   127 	
       
   128 	iAlertInfo.SetProfileId( info->iProfileId );
       
   129 	
       
   130 	for (TInt i=0; i< info->iTaskInfo.Count(); i++ )
       
   131 		{
       
   132 		iAlertInfo.TaskIds().AppendL( info->iTaskInfo[i]->iTaskId );
       
   133 		iAlertInfo.TaskSyncTypes().AppendL( info->iTaskInfo[i]->iSyncType);
       
   134 		}
       
   135 	iAlertInfo.SetVendorSpecificInfoL( KNullDesC8() );
       
   136 	}
       
   137 	
       
   138 // ---------------------------------------------------------
       
   139 // CNSmlDSAlert::PCDATAToUnicodeLC()
       
   140 // Converts data in Pcdata structure (used by xml parser)
       
   141 // to Unicode 
       
   142 // ---------------------------------------------------------
       
   143 void CNSmlDSAlertParser11::PCDATAToUnicodeLC( const SmlPcdata_t& aPcdata, HBufC*& aUnicodeData ) const
       
   144 	{
       
   145 	if ( !aPcdata.content )
       
   146 		{
       
   147 		aUnicodeData = NULL;
       
   148 		aUnicodeData = HBufC::NewLC( 0 );
       
   149 		}
       
   150 	TPtr8 pcdata( (TUint8*) aPcdata.content, aPcdata.length, aPcdata.length );
       
   151 	TrimRightSpaceAndNull( pcdata );
       
   152 	NSmlUnicodeConverter::HBufC16InUnicodeLC( pcdata, aUnicodeData );    
       
   153 	}
       
   154 
       
   155 /// ---------------------------------------------------------
       
   156 // CNSmlDSAlert::TrimRightSpaceAndNull
       
   157 // Trims right spaces and zero terminator (NULL) 
       
   158 // ---------------------------------------------------------
       
   159 void CNSmlDSAlertParser11::TrimRightSpaceAndNull( TDes8& aDes ) const
       
   160 	{
       
   161 	aDes.TrimRight();
       
   162 	if ( aDes.Length() > 0 )
       
   163 		{
       
   164 		if ( aDes[aDes.Length() - 1] == NULL )
       
   165 			{
       
   166 			aDes.SetLength( aDes.Length() - 1 );
       
   167 			}	
       
   168 		}
       
   169 	}	
       
   170 
       
   171 //
       
   172 // Callback functions implementation
       
   173 //
       
   174 // ---------------------------------------------------------
       
   175 // CNSmlDSAlertParser11::smlAlertCmdFuncL
       
   176 // Alert command from server.  
       
   177 // ---------------------------------------------------------
       
   178 Ret_t CNSmlDSAlertParser11::smlAlertCmdFuncL( SmlAlertPtr_t aAlert )
       
   179 	{
       
   180 	TSmlSyncType syncType(ESmlTwoWay);
       
   181 	
       
   182 	if ( aAlert->data )	
       
   183 		{
       
   184 		TPtr8 pcdata( (TUint8*) aAlert->data->content, aAlert->data->length, aAlert->data->length );
       
   185 		TrimRightSpaceAndNull( pcdata );
       
   186 				
       
   187 		if (pcdata == KNSmlDSTwoWayByServer)
       
   188 			{
       
   189 			syncType = ESmlTwoWay;
       
   190 			}
       
   191 		else if (pcdata == KNSmlDSOneWayFromClientByServer)
       
   192 			{
       
   193 			syncType = ESmlOneWayFromClient;
       
   194 			}
       
   195 		else if (pcdata == KNSmlDSRefreshFromClientByServer)
       
   196 			{
       
   197 			syncType = ESmlRefreshFromClient;
       
   198 			}
       
   199 		else if (pcdata == KNSmlDSOneWayFromServerByServer)
       
   200 			{
       
   201 			syncType = ESmlOneWayFromServer;
       
   202 			}
       
   203 		else if (pcdata == KNSmlDSRefreshFromServerByServer)
       
   204 			{
       
   205 			syncType = ESmlRefreshFromServer;
       
   206 			}
       
   207 		else if (pcdata == KNSmlDSSlowSync)
       
   208 			{
       
   209 			syncType = ESmlSlowSync;
       
   210 			}
       
   211 		else 
       
   212 			{
       
   213 			syncType = ESmlTwoWay;
       
   214 			} 
       
   215 			
       
   216 		}
       
   217 
       
   218 	SmlMetInfMetInf_t* metInf = NULL;
       
   219 	TPtr8 mediaType( NULL, 0, 0 );
       
   220 	
       
   221 	if ( aAlert->itemList->item->meta )
       
   222 		{
       
   223 		if ( aAlert->itemList->item->meta->content && 
       
   224 			aAlert->itemList->item->meta->contentType == SML_PCDATA_EXTENSION && 
       
   225 			aAlert->itemList->item->meta->extension == SML_EXT_METINF )
       
   226 			{
       
   227 			metInf = (SmlMetInfMetInf_t*) aAlert->itemList->item->meta->content;
       
   228 			
       
   229 			if ( metInf->type )
       
   230 				{
       
   231 				mediaType.Set( static_cast<TUint8*>( metInf->type->content ), metInf->type->length, metInf->type->length );
       
   232 				TrimRightSpaceAndNull( mediaType );
       
   233 				}
       
   234 			}
       
   235 		}
       
   236 		
       
   237 	if ( aAlert->itemList )
       
   238 		{
       
   239 		if (aAlert->itemList->item)
       
   240 			{
       
   241 			if ( aAlert->itemList->item->source )
       
   242 				{
       
   243 				HBufC8* remotePath = NULL;
       
   244 				
       
   245 				TPtr8 pcdata( (TUint8*) aAlert->itemList->item->source->locURI->content, aAlert->itemList->item->source->locURI->length, aAlert->itemList->item->source->locURI->length );
       
   246 				TrimRightSpaceAndNull( pcdata );
       
   247 				remotePath = pcdata.AllocLC();
       
   248 				TPtr8 p = remotePath->Des();				
       
   249 				iContentCount++;
       
   250 				for (TInt i = 0; i < iFoundProfiles.Count(); i++)
       
   251 					{
       
   252 					MatchContentTypeL( p, mediaType, syncType, i );	
       
   253 					}
       
   254 							
       
   255 				CleanupStack::PopAndDestroy(); // remotePath	
       
   256     			}
       
   257 			}
       
   258 		}
       
   259 	
       
   260 	return 0;
       
   261 	}
       
   262 // ---------------------------------------------------------
       
   263 // CNSmlDSAlertParser11::smlGetCmdFuncL
       
   264 // Get command from server
       
   265 // ---------------------------------------------------------
       
   266 Ret_t CNSmlDSAlertParser11::smlGetCmdFuncL( SmlGetPtr_t /*aContent*/ )
       
   267 	{
       
   268 	return 0;
       
   269 	}
       
   270 // ---------------------------------------------------------
       
   271 // CNSmlDSAlertParser11::smlPutCmdFuncL
       
   272 // Put command from server
       
   273 // ---------------------------------------------------------
       
   274 Ret_t CNSmlDSAlertParser11::smlPutCmdFuncL( SmlPutPtr_t /*aContent*/ )
       
   275 	{
       
   276 	return 0;
       
   277 	}
       
   278 // ---------------------------------------------------------
       
   279 // CNSmlDSAlertParser11::smlResultsCmdFuncL
       
   280 // Results command from server
       
   281 // ---------------------------------------------------------
       
   282 Ret_t CNSmlDSAlertParser11::smlResultsCmdFuncL( SmlResultsPtr_t /*aContent*/ )
       
   283 	{
       
   284 	return 0;
       
   285 	}
       
   286 // ---------------------------------------------------------
       
   287 // CNSmlDSAlertParser11::smlStatusCmdFuncL
       
   288 // Status command from server
       
   289 // ---------------------------------------------------------
       
   290 Ret_t CNSmlDSAlertParser11::smlStatusCmdFuncL( SmlStatusPtr_t /*aContent*/ )
       
   291 	{
       
   292 	return 0;
       
   293 	}
       
   294 // ---------------------------------------------------------
       
   295 // CNSmlDSAlertParser11::smlStartMessageFuncL
       
   296 // SyncHdr from server
       
   297 // ---------------------------------------------------------
       
   298 Ret_t CNSmlDSAlertParser11::smlStartMessageFuncL( SmlSyncHdrPtr_t aSyncHdr )
       
   299 	{
       
   300 	if ( !aSyncHdr || !aSyncHdr->source || !aSyncHdr->source->locURI  ) 
       
   301 		{
       
   302 		User::Leave( KErrGeneral );
       
   303 		}
       
   304 
       
   305     HBufC* syncHdrSource = NULL; 
       
   306     PCDATAToUnicodeLC( *aSyncHdr->source->locURI, syncHdrSource );
       
   307     syncHdrSource->Des().TrimRight();
       
   308     CNSmlURI* syncHdrSourceURI = CNSmlURI::NewLC( *syncHdrSource );
       
   309     SearchProfileURIL( *syncHdrSourceURI ); 
       
   310     CleanupStack::PopAndDestroy( 2 ); //syncHdrSourceURI, syncHdrSource
       
   311     
       
   312     HBufC* sessionId = NULL;
       
   313     PCDATAToUnicodeLC( *aSyncHdr->sessionID, sessionId );
       
   314     sessionId->Des().TrimRight();
       
   315     
       
   316     TInt id = 0;
       
   317 	TLex lex( sessionId->Des() );
       
   318 	lex.Val(id);
       
   319 	
       
   320 	iAlertInfo.SetSessionId( id );
       
   321 	CleanupStack::PopAndDestroy( ); // sessionId
       
   322 	
       
   323 	return 0;
       
   324 	}
       
   325 
       
   326 // ---------------------------------------------------------
       
   327 // CNSmlDSAlertParser11::SearchProfileURIL( CNSmlURI& aUri )
       
   328 // Matches profile
       
   329 // ---------------------------------------------------------
       
   330 TBool CNSmlDSAlertParser11::SearchProfileURIL( CNSmlURI& aUri )
       
   331 	{
       
   332 	TBool found( EFalse );
       
   333 	
       
   334 	CNSmlDSSettings* settings = CNSmlDSSettings::NewLC();
       
   335 	
       
   336 	CNSmlDSProfileList* profileList = new ( ELeave ) CArrayPtrFlat<CNSmlDSProfileListItem>(1);
       
   337 	CleanupStack::PushL( PtrArrCleanupItem( CNSmlDSProfileListItem, profileList) );
       
   338 
       
   339 	settings->GetAllProfileListL( profileList);
       
   340 	
       
   341 	//read profile values
       
   342 	for (TInt index = 0; index < profileList->Count(); index++ )
       
   343 		{
       
   344 		TInt profileId = profileList->At(index)->IntValue(EDSProfileId);
       
   345 		CNSmlDSProfile* profile = settings->ProfileL(profileId);
       
   346 		CleanupStack::PushL( profile );
       
   347 		
       
   348 	    CNSmlURI* syncServer= CNSmlURI::NewL( profile->StrValue( EDSProfileServerURL), (profile->IntValue(EDSProfileTransportId) == KUidNSmlMediumTypeInternet.iUid));
       
   349     	
       
   350 		if ( syncServer->HostNameWithPortL( EFalse ) == aUri.HostName() || syncServer->HostNameWithPortL( ETrue ) == aUri.HostName() )
       
   351 			{
       
   352 			if ( iAlertInfo.Transport() == KUidNSmlMediumTypeInternet.iUid )
       
   353 			    {
       
   354 			    // accept only internet bearers
       
   355 			    if ( ( profile->IntValue(EDSProfileTransportId) == KUidNSmlMediumTypeInternet.iUid ) 
       
   356 			       && ( profile->IntValue(EDSProfileServerAlertedAction) != ESmlDisableSync ) )
       
   357     				{
       
   358     				CNSmlAlertInfo* info = new (ELeave) CNSmlAlertInfo;
       
   359     				info->iProfileId = profile->IntValue( EDSProfileId );
       
   360     				info->iIAPId = profile->IntValue( EDSProfileIAPId );
       
   361     				iFoundProfiles.AppendL( info );
       
   362     				}        
       
   363 			    }
       
   364 			else
       
   365 			    {
       
   366 			    // accept only local bearers
       
   367 			    if ( ( profile->IntValue(EDSProfileTransportId) != KUidNSmlMediumTypeInternet.iUid ) 
       
   368 			        && ( profile->IntValue(EDSProfileServerAlertedAction) != ESmlDisableSync ) )
       
   369     				{
       
   370     				CNSmlAlertInfo* info = new (ELeave) CNSmlAlertInfo;
       
   371     				info->iProfileId = profile->IntValue( EDSProfileId );
       
   372     				info->iIAPId = profile->IntValue( EDSProfileIAPId );
       
   373     				iFoundProfiles.AppendL( info );
       
   374     				}        
       
   375 			    }
       
   376 			}
       
   377 		delete syncServer;
       
   378 		syncServer = NULL;
       
   379 		
       
   380 		CleanupStack::PopAndDestroy(); //profile
       
   381 		}
       
   382 		
       
   383 	CleanupStack::PopAndDestroy(2); //profileList, settings
       
   384 	
       
   385 	if ( iAlertInfo.Transport() == KUidNSmlMediumTypeInternet.iUid )
       
   386 	    {
       
   387     	if ( iFoundProfiles.Count() > 1 )
       
   388     	    {
       
   389     	    RArray<TInt> indexes;
       
   390             CleanupClosePushL( indexes );
       
   391             
       
   392             for (TInt j = 0; j < iFoundProfiles.Count(); j++ )
       
   393                 {
       
   394                 CNSmlAlertInfo* info = iFoundProfiles[j];
       
   395                 if ( info->iIAPId == -1 )    
       
   396                     {
       
   397                     indexes.Append( j );    
       
   398                     }
       
   399                 }
       
   400             
       
   401             if ( indexes.Count() < iFoundProfiles.Count() )
       
   402                 {
       
   403                 for ( TInt count(0); count < indexes.Count(); count++ )
       
   404                     {
       
   405                     CNSmlAlertInfo* temp = iFoundProfiles[indexes[count]];
       
   406                     iFoundProfiles.Remove( indexes[count] );
       
   407                     delete temp;
       
   408                     temp = NULL;       
       
   409                     }	        
       
   410                 }
       
   411                 
       
   412         	CleanupStack::PopAndDestroy( &indexes );    
       
   413     	    }
       
   414 	    }
       
   415 	    
       
   416 	return found;
       
   417 	}
       
   418 
       
   419 // ---------------------------------------------------------
       
   420 // CNSmlDSAlertParser11::SearchProfileL( TDesC8& /*aServerUri*/ )
       
   421 // Derived from base class
       
   422 // ---------------------------------------------------------
       
   423 void CNSmlDSAlertParser11::SearchProfileL( TDesC8& /*aServerUri*/ )
       
   424 	{
       
   425 	
       
   426 	}
       
   427 
       
   428 // ---------------------------------------------------------
       
   429 // CNSmlDSAlertParser11::MatchContentTypeL(TDesC8& aPath, TDesC8& aMimeType, TSmlSyncType aSyncType, TInt aProfileIndex)
       
   430 // Matches content type
       
   431 // ---------------------------------------------------------
       
   432 void CNSmlDSAlertParser11::MatchContentTypeL( TDesC8& aPath, TDesC8& aMimeType, TSmlSyncType aSyncType, TInt aProfileIndex )
       
   433 	{
       
   434 	RImplInfoPtrArray implArray;
       
   435 	CleanupStack::PushL(PtrArrCleanupItemRArr(CImplementationInformation, &implArray));
       
   436 	
       
   437 	TUid dsUid = { KNSmlDSInterfaceUid };
       
   438 	REComSession::ListImplementationsL(dsUid, implArray);
       
   439 
       
   440 	// Look through adapters to get right uid and ParameterList
       
   441 	TInt countImpls = implArray.Count();
       
   442 	CImplementationInformation* implInfo = NULL;
       
   443 	
       
   444 	for (TInt i = 0 ; i < countImpls; i++)
       
   445 		{
       
   446 		implInfo = implArray[ i ];
       
   447 		CNSmlDSSettings* settings = CNSmlDSSettings::NewLC();
       
   448 		CNSmlDSProfile* profile = settings->ProfileL( iFoundProfiles[aProfileIndex]->iProfileId );
       
   449 		CleanupStack::PushL( profile );
       
   450 		
       
   451 		CNSmlDSContentType* type = profile->ContentType( implInfo->ImplementationUid().iUid );
       
   452 		
       
   453 		if ( type )
       
   454 			{
       
   455 			
       
   456 			HBufC *uri = HBufC::NewLC(aPath.Size());
       
   457 			TPtr typePtr = uri->Des();
       
   458 			CnvUtfConverter::ConvertToUnicodeFromUtf8( typePtr, aPath);
       
   459 			
       
   460 			HBufC *mimeType = HBufC::NewLC(aMimeType.Size());
       
   461 			TPtr mimePtr = mimeType->Des();
       
   462 			CnvUtfConverter::ConvertToUnicodeFromUtf8( mimePtr, aMimeType);
       
   463 
       
   464 			if (typePtr.Compare( type->StrValue( EDSAdapterServerDataSource ))  == 0)
       
   465 				{
       
   466 				/* CR: 403-1188 */
       
   467 				if (iAlertInfo.Transport() != KUidNSmlMediumTypeInternet.iUid)
       
   468 					{
       
   469 					_DBG_FILE("CNSmlDSAlertParser11::MatchContentTypeL : Inside Not Internet");
       
   470 					if ( ConvertContentTypeL( mimePtr, implInfo->ImplementationUid().iUid ))
       
   471 						{
       
   472 						iFoundProfiles[aProfileIndex]->iMatchCount++;
       
   473 					
       
   474 						TNSmlContentTypeInfo* info = new (ELeave) TNSmlContentTypeInfo;
       
   475 						info->iTaskId = type->IntValue( EDSAdapterTableId );
       
   476 						info->iSyncType = aSyncType;
       
   477 					
       
   478 						iFoundProfiles[aProfileIndex]->iTaskInfo.AppendL( info );
       
   479 						
       
   480 						type->SetIntValue (EDSAdapterEnabled, ETrue) ; 
       
   481 										
       
   482 						profile->SaveL() ;
       
   483 						}
       
   484 					} // CR: 403-1188
       
   485 				else
       
   486 					{
       
   487 					_DBG_FILE("CNSmlDSAlertParser11::MatchContentTypeL : Inside Internet");
       
   488 					if ( ConvertContentTypeL( mimePtr, implInfo->ImplementationUid().iUid ) && (type->IntValue(EDSAdapterEnabled) != EFalse) )
       
   489 						{
       
   490 					
       
   491 						iFoundProfiles[aProfileIndex]->iMatchCount++;
       
   492 						
       
   493 						TNSmlContentTypeInfo* info = new (ELeave) TNSmlContentTypeInfo;
       
   494 						info->iTaskId = type->IntValue(EDSAdapterTableId);
       
   495 						info->iSyncType = (TSmlSyncType) aSyncType;
       
   496 						
       
   497 						iFoundProfiles[aProfileIndex]->iTaskInfo.AppendL(info);
       
   498 						}
       
   499 					}				
       
   500 				}
       
   501 			CleanupStack::PopAndDestroy(2); // uri, mimeType
       
   502 			}
       
   503 			
       
   504 		CleanupStack::PopAndDestroy(2); // settings, profile
       
   505 		}
       
   506 		
       
   507 	REComSession::FinalClose();
       
   508 	CleanupStack::PopAndDestroy(); //implArray
       
   509 
       
   510 	}
       
   511 
       
   512 // ---------------------------------------------------------
       
   513 // CNSmlDSAlertParser11::ConvertContentTypeL( TDesC& aMimeType, const TInt aDataProviderId )
       
   514 // Targets content type
       
   515 // ---------------------------------------------------------
       
   516 TBool CNSmlDSAlertParser11::ConvertContentTypeL( TDesC& aMimeType, const TInt aDataProviderId )
       
   517 	{
       
   518 	
       
   519 	
       
   520 	HBufC8* contentType;
       
   521 	
       
   522 	TInt pc(0);
       
   523 	RFs	fs;
       
   524 	User::LeaveIfError( fs.Connect() );
       
   525 	CleanupClosePushL(fs);
       
   526 	pc++;
       
   527 	
       
   528 	TFileName fileName;
       
   529 	Dll::FileName( fileName );
       
   530 	
       
   531 	TParse parse;
       
   532 	parse.Set( KNSmlAlertDirAndResource, &KDC_RESOURCE_FILES_DIR, NULL );
       
   533 	fileName = parse.FullName();
       
   534 	
       
   535     RResourceFile resourceFile; 
       
   536 	resourceFile.OpenL( fs,fileName );
       
   537 	CleanupClosePushL( resourceFile );
       
   538 	pc++;
       
   539 	
       
   540 	HBufC8* typesRes = resourceFile.AllocReadLC( NSML_DS_CONTENT_TYPES );
       
   541 	pc++;
       
   542 	TResourceReader reader;
       
   543 	reader.SetBuffer( typesRes );
       
   544 
       
   545 	TUint32 nOfTypes = reader.ReadInt16();
       
   546 	HBufC* textPtr = NULL;
       
   547 	TBool contentFound(EFalse);
       
   548 	
       
   549 	for ( TUint32 i=0; i < nOfTypes; i++)
       
   550 		{
       
   551 		reader.ReadInt16();	//num code
       
   552 		textPtr = reader.ReadHBufCL();
       
   553 		TPtr tmp = textPtr->Des();
       
   554 		tmp.LowerCase();
       
   555 		if ( textPtr->Des() == aMimeType )
       
   556 			{
       
   557 			contentFound = ETrue;
       
   558 			break;
       
   559 			}
       
   560 		delete textPtr;
       
   561 		textPtr = NULL;
       
   562 		}
       
   563 	
       
   564 	if ( contentFound )
       
   565 		{
       
   566 		CleanupStack::PushL( textPtr );
       
   567 		pc++;
       
   568 		
       
   569 		TPtr tmpPtr = textPtr->Des();
       
   570 		tmpPtr.LowerCase();
       
   571 		contentType = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *textPtr );
       
   572 		CleanupStack::PushL( contentType );  // Leave aContentText to the cleanupstack
       
   573 		pc++;
       
   574 		
       
   575 		CNSmlDSHostClient* hostClient = CNSmlDSHostClient::NewLC();
       
   576 		pc++;
       
   577 		
       
   578 		RArray<TSmlDataProviderId> dataProviders;
       
   579 		dataProviders.AppendL( aDataProviderId );
       
   580 		CleanupClosePushL( dataProviders );
       
   581 		pc++;
       
   582 		
       
   583 		RArray<TInt> result;
       
   584 		CleanupClosePushL( result );
       
   585 		pc++;
       
   586 		
       
   587 		TInt status(KErrNone);
       
   588 		hostClient->CreateDataProvidersL( dataProviders, result );
       
   589 		
       
   590 		for (TInt index = 0; index < dataProviders.Count(); index++)
       
   591 			{
       
   592 			if (result[index] != KErrNone)
       
   593 				{
       
   594 				contentFound = EFalse;
       
   595 				}
       
   596 			}
       
   597 		
       
   598 		if ( contentFound )
       
   599 			{
       
   600 			TNSmlDPInformation* adapterInfo = hostClient->DataProviderInformationL( aDataProviderId, status );
       
   601 			
       
   602 			if ( status == KErrNone)
       
   603 				{
       
   604 				
       
   605 				TInt mimeSupported(EFalse);
       
   606 				
       
   607 				TInt mimeCount = adapterInfo->iMimeTypes->Count();
       
   608 				TPtrC8 pType = contentType->Des();
       
   609 				
       
   610 				for (TInt i = 0; i < mimeCount; i++)
       
   611 					{
       
   612 					TPtrC8 pInfo = (* adapterInfo->iMimeTypes )[i];
       
   613 				
       
   614 					if ( pType.Compare( pInfo ) == 0 )
       
   615 						{
       
   616 						mimeSupported = ETrue;
       
   617 						break;
       
   618 						}	
       
   619 					}
       
   620 				
       
   621 				contentFound = mimeSupported;
       
   622 				
       
   623 				}
       
   624 			else
       
   625 				{
       
   626 				contentFound = EFalse;
       
   627 				}
       
   628 			
       
   629 			if ( adapterInfo )
       
   630 			    {
       
   631 			    delete adapterInfo->iDisplayName;
       
   632 		    	delete adapterInfo->iMimeTypes;
       
   633 			    delete adapterInfo->iMimeVersions;
       
   634 			    delete adapterInfo;		        
       
   635 			    }
       
   636 			}
       
   637 		
       
   638 		}
       
   639 	
       
   640 	CleanupStack::PopAndDestroy(pc);
       
   641 		
       
   642 	return contentFound;
       
   643 	}
       
   644 
       
   645 // ---------------------------------------------------------
       
   646 // CNSmlDSAlertParser11::smlEndMessageFuncL
       
   647 // End of SyncML message was reached
       
   648 // ---------------------------------------------------------
       
   649 Ret_t CNSmlDSAlertParser11::smlEndMessageFuncL( Boolean_t /*aFinal*/ )
       
   650 	{
       
   651 	return 0;
       
   652 	}
       
   653 	
       
   654 // ---------------------------------------------------------
       
   655 // CNSmlDSAlertParser11::smlStartSyncFuncL
       
   656 // Sync command from server
       
   657 // ---------------------------------------------------------
       
   658 Ret_t CNSmlDSAlertParser11::smlStartSyncFuncL( SmlSyncPtr_t /*aContent*/ )
       
   659 	{
       
   660 	return 0;
       
   661 	}
       
   662 	
       
   663 // ---------------------------------------------------------
       
   664 // CNSmlDSAlertParser11::smlEndSyncFuncL
       
   665 // End of Sync command was reached
       
   666 // ---------------------------------------------------------
       
   667 Ret_t CNSmlDSAlertParser11::smlEndSyncFuncL()
       
   668 	{
       
   669 	return 0;
       
   670 	}
       
   671 	
       
   672 // ---------------------------------------------------------
       
   673 // CNSmlDSAlertParser11::smlStartAtomicFuncL
       
   674 // Atomic command from server, Atomic is not supported
       
   675 // ---------------------------------------------------------
       
   676 Ret_t CNSmlDSAlertParser11::smlStartAtomicFuncL( SmlAtomicPtr_t /*aContent*/ )
       
   677 	{
       
   678 	return 0;
       
   679 	}
       
   680 	
       
   681 // ---------------------------------------------------------
       
   682 // CNSmlDSAlertParser11::smlEndAtomicFuncL
       
   683 // End of Atomic command was reached, Atomic is not supported
       
   684 // ---------------------------------------------------------
       
   685 Ret_t CNSmlDSAlertParser11::smlEndAtomicFuncL()
       
   686 	{
       
   687 	return 0;
       
   688 	}
       
   689 	
       
   690 // ---------------------------------------------------------
       
   691 // CNSmlDSAlertParser11::smlStartSequenceFuncL
       
   692 // Sequence command from server, Sequence is not supported
       
   693 // ---------------------------------------------------------
       
   694 Ret_t CNSmlDSAlertParser11::smlStartSequenceFuncL( SmlSequencePtr_t /*aContent*/ )
       
   695 	{
       
   696 	return 0;
       
   697 	}
       
   698 	
       
   699 // ---------------------------------------------------------
       
   700 // CNSmlDSAlertParser11::smlEndSequenceFuncL
       
   701 // 
       
   702 // ---------------------------------------------------------
       
   703 Ret_t CNSmlDSAlertParser11::smlEndSequenceFuncL()
       
   704 	{
       
   705 	return 0;
       
   706 	}
       
   707 	
       
   708 // ---------------------------------------------------------
       
   709 // CNSmlDSAlertParser11::smlAddCmdFuncL
       
   710 // 
       
   711 // ---------------------------------------------------------
       
   712 Ret_t CNSmlDSAlertParser11::smlAddCmdFuncL( SmlAddPtr_t /*aContent*/ )
       
   713 	{
       
   714 	return 0;
       
   715 	}
       
   716 	
       
   717 // ---------------------------------------------------------
       
   718 // CNSmlDSAlertParser11::smlCopyCmdFuncL
       
   719 // 
       
   720 // ---------------------------------------------------------
       
   721 Ret_t CNSmlDSAlertParser11::smlCopyCmdFuncL( SmlCopyPtr_t /*aContent*/)
       
   722 	{
       
   723 	return 0;
       
   724 	}
       
   725 	
       
   726 // ---------------------------------------------------------
       
   727 // CNSmlDSAlertParser11::smlDeleteCmdFuncL
       
   728 // 
       
   729 // ---------------------------------------------------------
       
   730 Ret_t CNSmlDSAlertParser11::smlDeleteCmdFuncL( SmlDeletePtr_t /*aContent*/ )
       
   731 	{
       
   732 	return 0;
       
   733 	}
       
   734 	
       
   735 // ---------------------------------------------------------
       
   736 // CNSmlDSAlertParser11::smlExecCmdFuncL
       
   737 // 
       
   738 // ---------------------------------------------------------
       
   739 Ret_t CNSmlDSAlertParser11::smlExecCmdFuncL( SmlExecPtr_t /*aContent*/ )
       
   740 	{
       
   741 	return 0;
       
   742 	}
       
   743 	
       
   744 // ---------------------------------------------------------
       
   745 // CNSmlDSAlertParser11::smlMapCmdFuncL
       
   746 // 
       
   747 // ---------------------------------------------------------
       
   748 Ret_t CNSmlDSAlertParser11::smlMapCmdFuncL( SmlMapPtr_t /*aContent*/ )   
       
   749 	{
       
   750 	return 0;
       
   751 	}
       
   752 	
       
   753 // ---------------------------------------------------------
       
   754 // CNSmlDSAlertParser11::smlReplaceCmdFuncL
       
   755 // 
       
   756 // ---------------------------------------------------------
       
   757 Ret_t CNSmlDSAlertParser11::smlReplaceCmdFuncL( SmlReplacePtr_t /*aContent*/ )
       
   758 	{
       
   759 	return 0;
       
   760 	}
       
   761 	
       
   762 // ---------------------------------------------------------
       
   763 // CNSmlDSAlertParser11::smlSearchCmdFuncL
       
   764 // 
       
   765 // ---------------------------------------------------------
       
   766 Ret_t CNSmlDSAlertParser11::smlSearchCmdFuncL( SmlSearchPtr_t /*aContent*/ )
       
   767 	{
       
   768 	return 0;
       
   769 	}
       
   770 	
       
   771 // ---------------------------------------------------------
       
   772 // CNSmlDSAlertParser11::smlMoveCmdFuncL
       
   773 // 
       
   774 // ---------------------------------------------------------
       
   775 Ret_t CNSmlDSAlertParser11::smlMoveCmdFuncL( SmlMovePtr_t /*aContent*/ )
       
   776 	{
       
   777 	return 0;
       
   778 	}
       
   779 
       
   780 //End of File