customization/WallpaperAdapter/src/WallpaperAdapter.cpp
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2002 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:  DM Wallpaper Adapter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /*
       
    20 ./Customization -+--> Wallpaper -+--> Image
       
    21 
       
    22 
       
    23 ./Customization -+--> Wallpaper -+--> Image
       
    24 
       
    25 ./Customization -+--> Themes -+--> CurrentThemes -+--> <X> * -+--> AppRef
       
    26                  |            |                               |
       
    27                  |            |                               |--> ID
       
    28                  |            |                               |
       
    29                  |            |                               |--> Name
       
    30                  |            |                               |
       
    31                  |            |                               |--> Version
       
    32                  |            |
       
    33                  |            |--> ActiveTheme
       
    34                  |            |
       
    35                  |            |--> InstallTheme
       
    36                  |            |
       
    37                  |            |--> InstallOptions
       
    38                  |
       
    39                  |
       
    40                  |
       
    41 ./Customization -+--> OperatorLogo -+--> LogoData
       
    42                  |
       
    43                  |
       
    44                  |
       
    45 ./Customization -+--> EmbeddedLinks -+--> <X> * -+--> Links -+--> <X> * -+--> URL
       
    46                  |                               |                       |
       
    47                  |                               |--> ID                 |--> Name
       
    48                  |                               |                       |
       
    49                  |                               |--> AppName            |--> UserName
       
    50                  |                                                       |
       
    51                  |                                                       |--> Password
       
    52                  |                                                       |
       
    53                  |                                                       |--> ConRef
       
    54                  |                                                       |
       
    55                  |                                                       |
       
    56                  |
       
    57                  |
       
    58 ./Customization -+--> Startup -+--> WelcomeData
       
    59                  |
       
    60                  |
       
    61                  |
       
    62 ./Customization -+--> ScreenSaver --+----> CurrentScreenSavers --> <X> * ---+-----> ID
       
    63 				 |					|										|
       
    64 				 |					|----> ActiveSc							|-----> Name
       
    65 				 |					|										|
       
    66 				 |					|----> InstallScreenSaver				|-----> Description
       
    67 				 |					|										|
       
    68 				 |					|----> InstallOptions					|-----> CustomProperty
       
    69 				 |															|
       
    70 				 |															|-----> Version
       
    71                  |
       
    72                  |
       
    73                  |
       
    74 ./Customization -+--> Wallpaper -+--> Image
       
    75                  |
       
    76                  |
       
    77                  |
       
    78 ./Customization -+--> IdleSoftkeys -+--> SoftKeys -+--> <X> * -+--> ID
       
    79                  |                  |                          |
       
    80                  |                  |                          |--> Caption
       
    81                  |                  |                          |
       
    82                  |                  |                          |--> Image
       
    83                  |                  |                          |
       
    84                  |                  |                          |--> TargetRef
       
    85                  |                  |
       
    86                  |                  |
       
    87                  |                  |--> Targets -+--> <X> * -+--> ID
       
    88                  |                  |                         |
       
    89                  |                  |                         |--> Description
       
    90                  |                  |
       
    91                  |                  |
       
    92                  |                  |--> WebTargets -+--> <X> * -+--> ID
       
    93                  |                                               |
       
    94                  |                                               |--> Description
       
    95                  |                                               |
       
    96                  |                                               |--> URL
       
    97                  |                                               |
       
    98                  |                                               |--> UserName
       
    99                  |                                               |
       
   100                  |                                               |--> Password
       
   101                  |                                               |
       
   102                  |                                               |--> ConRef
       
   103                  |
       
   104                  |
       
   105                  |-->
       
   106                  |
       
   107                  |-->
       
   108                  |
       
   109                  |-->
       
   110                  |
       
   111                  |-->
       
   112                  |
       
   113                  |-->
       
   114                  |
       
   115                  |-->
       
   116                  |
       
   117                  |-->
       
   118                  |
       
   119                  |
       
   120                  |
       
   121 
       
   122 */
       
   123 
       
   124 #include <imcvcodc.h>
       
   125 #include "debug.h"
       
   126 #include "WallpaperAdapter.h"
       
   127 #include "nsmldmuri.h"
       
   128 #include <implementationproxy.h> // For TImplementationProxy definition
       
   129 #include <f32file.h>
       
   130 #include "FileCoderB64.h"
       
   131 #include <AknsWallpaperUtils.h>
       
   132 
       
   133 //#ifdef __SAP_POLICY_MANAGEMENT
       
   134 #include <PolicyEngineXACML.h>
       
   135 //#endif
       
   136 #include <featmgr.h>
       
   137 #ifdef __Sml_DEBUG__
       
   138 #pragma message("Sml Debugging is ON!")
       
   139 #endif
       
   140 
       
   141 
       
   142 _LIT( KIVBackgroundImagePathBin, "c:\\system\\data\\backgroundimage.bin" );
       
   143 
       
   144 _LIT8( KMimeTypeJpeg, "image/jpeg" );
       
   145 _LIT8( KMimeTypeGif, "image/jpeg" );
       
   146 
       
   147 // ------------------------------------------------------------------------------------------------
       
   148 // CWallpaperAdapter* CWallpaperAdapter::NewL( )
       
   149 // ------------------------------------------------------------------------------------------------
       
   150 CWallpaperAdapter* CWallpaperAdapter::NewL( MSmlDmCallback* aDmCallback )
       
   151 	{
       
   152 	RDEBUG("CWallpaperAdapter::NewL(): begin");
       
   153 
       
   154 	CWallpaperAdapter* self = NewLC( aDmCallback );
       
   155 	CleanupStack::Pop();
       
   156 	return self;
       
   157 	}
       
   158 
       
   159 // ------------------------------------------------------------------------------------------------
       
   160 // CWallpaperAdapter* CWallpaperAdapter::NewLC( )
       
   161 // ------------------------------------------------------------------------------------------------
       
   162 CWallpaperAdapter* CWallpaperAdapter::NewLC( MSmlDmCallback* aDmCallback )
       
   163 	{
       
   164 	CWallpaperAdapter* self = new( ELeave ) CWallpaperAdapter( aDmCallback );
       
   165 	CleanupStack::PushL( self );
       
   166 	self->ConstructL();
       
   167 	return self;
       
   168 	}
       
   169 
       
   170 // ------------------------------------------------------------------------------------------------
       
   171 // CWallpaperAdapter::CWallpaperAdapter()
       
   172 // ------------------------------------------------------------------------------------------------
       
   173 
       
   174 CWallpaperAdapter::CWallpaperAdapter( MSmlDmCallback* aDmCallback )
       
   175 	: CTARMDmAdapter( aDmCallback )
       
   176 	, iCallBack( aDmCallback )
       
   177 	{
       
   178 	RDEBUG("CWallpaperAdapter::CWallpaperAdapter()");
       
   179 	}
       
   180 
       
   181 // ------------------------------------------------------------------------------------------------
       
   182 // CWallpaperAdapter::~CWallpaperAdapter()
       
   183 // ------------------------------------------------------------------------------------------------
       
   184 
       
   185 CWallpaperAdapter::~CWallpaperAdapter()
       
   186 	{
       
   187 	RDEBUG("CWallpaperAdapter::~CWallpaperAdapter()");
       
   188 	FeatureManager::UnInitializeLib();
       
   189 	}
       
   190 
       
   191 // ------------------------------------------------------------------------------------------------
       
   192 //  CWallpaperAdapter::DDFVersionL()
       
   193 // ------------------------------------------------------------------------------------------------
       
   194 void CWallpaperAdapter::DDFVersionL( CBufBase& aDDFVersion )
       
   195 	{
       
   196 	aDDFVersion.InsertL( 0, KSmlWPDDFVersion );
       
   197 	}
       
   198 
       
   199 // ------------------------------------------------------------------------------------------------
       
   200 //  CWallpaperAdapter::DDFStructureL()
       
   201 //
       
   202 // ------------------------------------------------------------------------------------------------
       
   203 void CWallpaperAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
       
   204 	{
       
   205 	RDEBUG( "CWallpaperAdapter::DDFStructureL(): begin" );
       
   206 	
       
   207 	TSmlDmAccessTypes accessTypesGet;
       
   208 	accessTypesGet.SetGet();
       
   209 	
       
   210 	/*
       
   211 	Node: ./Customzation
       
   212 	This interior node is the common parent to all customization..
       
   213 	Status: Required
       
   214 	Occurs: One
       
   215 	Format: Node
       
   216 	Access Types: Get
       
   217 	Values: N/A
       
   218 	*/
       
   219 	// Apps
       
   220 	MSmlDmDDFObject& apps = aDDF.AddChildObjectL( KSmlCustomizationN );
       
   221 	FillNodeInfoL(apps, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
       
   222 		MSmlDmDDFObject::ENode, KSmlCustomizationD, EFalse );
       
   223 
       
   224 	/*
       
   225 	Node: ./Customization/Wallpaper
       
   226 	This interior node acts as a placeholder for one or more update packages within a same content provider group.
       
   227 	Status: Required
       
   228 	Occurs: One
       
   229 	Format: Node
       
   230 	Access Types: Get
       
   231 	Values: N/A
       
   232 	*/
       
   233 	// Apps/<x>/
       
   234 	// e.g. /Apps/Games
       
   235 	MSmlDmDDFObject& groupNode = apps.AddChildObjectL( KSmlWPWallpaperN );
       
   236 	FillNodeInfoL( groupNode, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
       
   237 		MSmlDmDDFObject::ENode, KSmlWPWallpaperD, EFalse );
       
   238 
       
   239 	/*
       
   240 	Node: ./Customization/Wallpaper/Data
       
   241 Image node stores the wallpaper image as binary data, and its runtime Type determines the interpretation.
       
   242 ·	Status: Optional
       
   243 ·	Occurs: One
       
   244 ·	Format: bin
       
   245 ·	Access Types: Get, Replace
       
   246 ·	Values: N/A
       
   247 	*/
       
   248 	TSmlDmAccessTypes accessTypesGetReplace;
       
   249 	accessTypesGetReplace.SetGet();
       
   250 	accessTypesGetReplace.SetReplace();
       
   251 
       
   252 	MSmlDmDDFObject& imageNode = groupNode.AddChildObjectL( KSmlWPDataN );
       
   253 	FillNodeInfoL( imageNode, accessTypesGetReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
       
   254 		MSmlDmDDFObject::EBin, KSmlWPImageD, EFalse);
       
   255 	}
       
   256 
       
   257 // ------------------------------------------------------------------------------------------------
       
   258 //  CWallpaperAdapter::UpdateLeafObjectL()
       
   259 //  
       
   260 // ------------------------------------------------------------------------------------------------
       
   261 void CWallpaperAdapter::_UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& /*aLUID*/, const TDesC8& aObject, const TDesC8& aType, const TInt aStatusRef )
       
   262 	{
       
   263 
       
   264 	RDEBUG( "CWallpaperAdapter::UpdateLeafObjectL(): begin" );
       
   265 	TError ret = EOk ;
       
   266 	TInt err = KErrNone;
       
   267 	
       
   268 #ifdef __TARM_SYMBIAN_CONVERGENCY
       
   269 	TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
       
   270 	TInt cnt = NSmlDmURI::NumOfURISegs( uriPtrc ) ;
       
   271 #else
       
   272 	TInt cnt = NSmlDmURI::NumOfURISegs( aURI ) ;
       
   273 #endif
       
   274 
       
   275 	if ( cnt == 3 ) 
       
   276 		{
       
   277 		TPtrC8 app = NSmlDmURI::LastURISeg( aURI ) ;
       
   278 		if ( app == KSmlWPDataN ) 
       
   279 			{
       
   280 			if( IsImageL( aType ) )
       
   281 				{
       
   282 				RFs fs;
       
   283 				User::LeaveIfError( fs.Connect() );
       
   284 				CleanupClosePushL( fs );
       
   285 				
       
   286 				TBool setWallpaper = aObject.Length();
       
   287 				if (setWallpaper)
       
   288 					{
       
   289 					TFileCoderB64 decoder;
       
   290 					TBool isEncoded = TFileCoderB64::CheckB64Encode( aObject );
       
   291 					if (isEncoded )
       
   292 						{
       
   293 						decoder.DecodeToL( aObject, KIVBackgroundImagePathBin() );
       
   294 						}
       
   295 					else
       
   296 						{
       
   297 						// aObject is original data, save it to KIVBackgroundImagePathBin()
       
   298 						RFile file;
       
   299 						User::LeaveIfError( file.Replace( fs, KIVBackgroundImagePathBin(), EFileWrite));
       
   300 						CleanupClosePushL( file );
       
   301 						User::LeaveIfError( file.Write( aObject ) );
       
   302 						
       
   303 						CleanupStack::PopAndDestroy(); // file
       
   304 						}					
       
   305 					err = AknsWallpaperUtils::SetIdleWallpaper( KIVBackgroundImagePathBin(), 0 );
       
   306 					}
       
   307 				else
       
   308 					{
       
   309 					// Clear wallpaper
       
   310 					err = AknsWallpaperUtils::SetIdleWallpaper( KNullDesC(), 0 );
       
   311 					// Delete wallpaper file
       
   312 					fs.Delete( KIVBackgroundImagePathBin() );
       
   313 					}
       
   314 				
       
   315 				if (err != KErrNone)
       
   316 					{
       
   317 					ret = EError;
       
   318 					}
       
   319 				CleanupStack::PopAndDestroy(); // fs
       
   320 				}
       
   321 			else
       
   322 				{
       
   323 				RDEBUG("*** mime type is not supported!");
       
   324 				ret = EInvalidObject;
       
   325 				}
       
   326 			}
       
   327 		}
       
   328 	else
       
   329 		{
       
   330 		ret = EError ;
       
   331 		}
       
   332 
       
   333 	iCallBack->SetStatusL( aStatusRef, ret );
       
   334 	}
       
   335 
       
   336 // ------------------------------------------------------------------------------------------------
       
   337 //
       
   338 // ------------------------------------------------------------------------------------------------
       
   339 void CWallpaperAdapter::_UpdateLeafObjectL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/, RWriteStream*& /*aStream*/, const TDesC8& /*aType*/, TInt aStatusRef )
       
   340 	{
       
   341 	RDEBUG( "CWallpaperAdapter::UpdateLeafObjectL(...RWriteStream...): begin" );
       
   342 	//Not supported
       
   343 	TError ret = EError;
       
   344 	iCallBack->SetStatusL( aStatusRef, ret );
       
   345 	}
       
   346 
       
   347 
       
   348 // ------------------------------------------------------------------------------------------------
       
   349 // CWallpaperAdapter::DeleteObjectL( const TDesC& aURI, const TDesC& aLUID )
       
   350 // ------------------------------------------------------------------------------------------------
       
   351 void CWallpaperAdapter::_DeleteObjectL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/, const TInt aStatusRef )
       
   352 	{
       
   353 	RDEBUG( "CWallpaperAdapter::DeleteObjectL(): begin" );
       
   354 	//Not supported
       
   355 	CSmlDmAdapter::TError ret = CSmlDmAdapter::EError;
       
   356 	iCallBack->SetStatusL( aStatusRef, ret );
       
   357 	}
       
   358 
       
   359 // ------------------------------------------------------------------------------------------------
       
   360 //  CWallpaperAdapter::FetchLeafObjectL( const TDesC& aURI, const TDesC& aLUID, const TDesC& aType, CBufBase& aObject )
       
   361 // ------------------------------------------------------------------------------------------------
       
   362 void CWallpaperAdapter::_FetchLeafObjectL( const TDesC8& aURI, const TDesC8& /*aLUID*/, const TDesC8& /*aType*/, const TInt /*aResultsRef*/, const TInt aStatusRef )
       
   363 	{
       
   364 	RDEBUG("CWallpaperAdapter::FetchLeafObjectL(): begin");
       
   365 	CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
       
   366 
       
   367 #ifdef __TARM_SYMBIAN_CONVERGENCY
       
   368 	TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
       
   369 	TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) );
       
   370 #else
       
   371 	TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) );
       
   372 #endif
       
   373 
       
   374 	if( numSeqs == 3 ) 
       
   375 		{
       
   376 #ifdef __TARM_SYMBIAN_CONVERGENCY
       
   377 	TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) );
       
   378 #else
       
   379 	TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
       
   380 #endif		
       
   381 		if( mapping == KSmlWPDataN ) 
       
   382 			{
       
   383 			status = CSmlDmAdapter::EError;
       
   384 			}
       
   385 		} 
       
   386 	else 
       
   387 		{
       
   388 		status = EInvalidObject ;
       
   389 		}
       
   390 	iCallBack->SetStatusL( aStatusRef, status );
       
   391 	}
       
   392 
       
   393 // ------------------------------------------------------------------------------------------------
       
   394 //
       
   395 // ------------------------------------------------------------------------------------------------
       
   396 void CWallpaperAdapter::_FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& /*aLUID*/, const TDesC8& /*aType*/, TInt /*aResultsRef*/, TInt aStatusRef )
       
   397 	{
       
   398 	RDEBUG("CWallpaperAdapter::FetchLeafObjectSizeL(): begin");
       
   399 
       
   400 #ifdef __TARM_SYMBIAN_CONVERGENCY
       
   401 	TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
       
   402 	TNodeId nodeId = NodeId( uriPtrc );
       
   403 #else
       
   404 	TNodeId nodeId = NodeId( aURI );
       
   405 #endif
       
   406 
       
   407 	TError ret = EOk ;
       
   408 
       
   409 	switch( nodeId )
       
   410 		{
       
   411 		case ENodeCustomization:
       
   412 			ret = EError;
       
   413 			break;
       
   414 
       
   415 		case ENodeWallpaper:
       
   416 			ret = EError;
       
   417 			break;
       
   418 
       
   419 		case ENodeImage:
       
   420 			ret = EError;
       
   421 			break;
       
   422 
       
   423 		default:
       
   424 			ret = EError;
       
   425 			break;
       
   426 		}
       
   427 
       
   428 	iCallBack->SetStatusL( aStatusRef, ret );
       
   429 	}
       
   430 
       
   431 // ------------------------------------------------------------------------------------------------
       
   432 //  CWallpaperAdapter::ChildURIListL( const TDesC& aURI, const TDesC& aParentLUID, const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, CArrayFix<TPtrC>& aCurrentURISegmentList )
       
   433 // ------------------------------------------------------------------------------------------------
       
   434 void CWallpaperAdapter::_ChildURIListL( const TDesC8& aURI, const TDesC8& /*aParentLUID*/, const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, const TInt aResultsRef, const TInt aStatusRef  )
       
   435 	{
       
   436 	RDEBUG("CWallpaperAdapter::ChildURIListL(): begin");
       
   437 	
       
   438 	CSmlDmAdapter::TError ret = CSmlDmAdapter::EOk;
       
   439 		
       
   440 	CBufBase *currentList = CBufFlat::NewL( 128 );
       
   441 	CleanupStack::PushL( currentList );
       
   442 
       
   443 #ifdef __TARM_SYMBIAN_CONVERGENCY
       
   444 	TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
       
   445 	TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) );
       
   446 #else
       
   447 	TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) );
       
   448 #endif
       
   449 
       
   450 #ifdef __TARM_SYMBIAN_CONVERGENCY	
       
   451 	if ( numSeqs == 0 || uriPtrc == _L8("") )
       
   452 #else
       
   453 	if ( numSeqs == 0 || aURI == _L8("") )
       
   454 #endif	
       
   455 		{
       
   456 		currentList->InsertL( 0, KSmlCustomizationN() );
       
   457 		}
       
   458 	else if (numSeqs == 1)
       
   459 		{
       
   460 		currentList->InsertL( 0, KSmlWPWallpaperN() );
       
   461 		}
       
   462 	else if (numSeqs == 2)
       
   463 		{
       
   464 		currentList->InsertL( 0, KSmlWPDataN() );
       
   465 		}
       
   466 	else if (numSeqs == 3)
       
   467 		{
       
   468 		//Empty result, no error code
       
   469 		//currentList->InsertL( 0, KNullDesC8() );
       
   470 		}
       
   471 	else
       
   472 		{
       
   473 		ret = CSmlDmAdapter::EError;
       
   474 		}
       
   475 	
       
   476 	iCallBack->SetStatusL( aStatusRef, ret );
       
   477 	
       
   478 	if( ret==CSmlDmAdapter::EOk )
       
   479 		{
       
   480 		iCallBack->SetResultsL( aResultsRef, *currentList, KNullDesC8 );
       
   481 		}
       
   482 	
       
   483 	CleanupStack::PopAndDestroy(); //currentList
       
   484 	}
       
   485 
       
   486 // ------------------------------------------------------------------------------------------------
       
   487 // CWallpaperAdapter::AddNodeObjectL( const TDesC& aURI, const TDesC& aParentLUID )
       
   488 // ------------------------------------------------------------------------------------------------
       
   489 void CWallpaperAdapter::_AddNodeObjectL( const TDesC8& /*aURI*/, const TDesC8& /*aParentLUID*/, const TInt aStatusRef )
       
   490 	{
       
   491 	RDEBUG("CWallpaperAdapter::AddNodeObjectL(): begin");
       
   492 	//Not supported
       
   493 	CSmlDmAdapter::TError ret = CSmlDmAdapter::EError;
       
   494 	iCallBack->SetStatusL( aStatusRef, ret );
       
   495 	}
       
   496 
       
   497 // ------------------------------------------------------------------------------------------------
       
   498 //
       
   499 // ------------------------------------------------------------------------------------------------
       
   500 void CWallpaperAdapter::_ExecuteCommandL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/, const TDesC8& /*aArgument*/, const TDesC8& /*aType*/, TInt aStatusRef )
       
   501 	{
       
   502 	RDEBUG("CWallpaperAdapter::ExecuteCommandL(): begin");
       
   503 	//Not supported
       
   504 	TError ret = EError;
       
   505 	iCallBack->SetStatusL( aStatusRef, ret );
       
   506 	}
       
   507 
       
   508 // ------------------------------------------------------------------------------------------------
       
   509 //
       
   510 // ------------------------------------------------------------------------------------------------
       
   511 void CWallpaperAdapter::_ExecuteCommandL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/, RWriteStream*& /*aStream*/, const TDesC8& /*aType*/, TInt aStatusRef )
       
   512 	{
       
   513 	RDEBUG("CWallpaperAdapter::ExecuteCommandL(...RWriteStream...): begin");
       
   514 	//Not supported
       
   515 	TError ret = EError;
       
   516 	iCallBack->SetStatusL( aStatusRef, ret );
       
   517 	}
       
   518 	
       
   519 // ------------------------------------------------------------------------------------------------
       
   520 //
       
   521 // ------------------------------------------------------------------------------------------------
       
   522 void CWallpaperAdapter::_CopyCommandL( const TDesC8& /*aTargetURI*/, const TDesC8& /*aTargetLUID*/, const TDesC8& /*aSourceURI*/, const TDesC8& /*aSourceLUID*/, const TDesC8& /*aType*/, TInt aStatusRef )
       
   523 	{
       
   524 	RDEBUG("CWallpaperAdapter::CopyCommandL()");
       
   525 	//Not supported
       
   526 	TError ret = EError;
       
   527 	iCallBack->SetStatusL( aStatusRef, ret );
       
   528 	}
       
   529 
       
   530 // ------------------------------------------------------------------------------------------------
       
   531 //
       
   532 // ------------------------------------------------------------------------------------------------
       
   533 void CWallpaperAdapter::StartAtomicL()
       
   534 	{
       
   535 	RDEBUG("CWallpaperAdapter::StartAtomicL()");
       
   536 	//Not supported
       
   537 	}
       
   538 
       
   539 // ------------------------------------------------------------------------------------------------
       
   540 //
       
   541 // ------------------------------------------------------------------------------------------------
       
   542 void CWallpaperAdapter::CommitAtomicL()
       
   543 	{
       
   544 	RDEBUG("CWallpaperAdapter::CommitAtomicL()");
       
   545 	//Not supported
       
   546 	}
       
   547 
       
   548 // ------------------------------------------------------------------------------------------------
       
   549 //
       
   550 // ------------------------------------------------------------------------------------------------
       
   551 void CWallpaperAdapter::RollbackAtomicL()
       
   552 	{
       
   553 	RDEBUG("CWallpaperAdapter::RollbackAtomicL()");
       
   554 	//Not supported
       
   555 	}
       
   556 
       
   557 // ------------------------------------------------------------------------------------------------
       
   558 //
       
   559 // ------------------------------------------------------------------------------------------------
       
   560 TBool CWallpaperAdapter::StreamingSupport( TInt& /*aItemSize*/ )
       
   561 	{
       
   562 	RDEBUG("CWallpaperAdapter::StreamingSupport()");
       
   563 	return EFalse;
       
   564 	}
       
   565 
       
   566 // ------------------------------------------------------------------------------------------------
       
   567 //
       
   568 // ------------------------------------------------------------------------------------------------
       
   569 #ifdef __TARM_SYMBIAN_CONVERGENCY	
       
   570 void CWallpaperAdapter::StreamCommittedL( RWriteStream& /*aStream*/ )
       
   571 #else
       
   572 void CWallpaperAdapter::StreamCommittedL()
       
   573 #endif	
       
   574 	{	
       
   575 	RDEBUG("CWallpaperAdapter::StreamCommittedL(): begin");
       
   576 	RDEBUG("CWallpaperAdapter::StreamCommittedL(): end");
       
   577 	}
       
   578 
       
   579 // ------------------------------------------------------------------------------------------------
       
   580 //
       
   581 // ------------------------------------------------------------------------------------------------
       
   582 void CWallpaperAdapter::CompleteOutstandingCmdsL()
       
   583 	{
       
   584 	RDEBUG("CWallpaperAdapter::CompleteOutstandingCmdsL()");
       
   585 	}
       
   586 
       
   587 // -----------------------------------------------------------------------------
       
   588 // 
       
   589 // -----------------------------------------------------------------------------
       
   590 //
       
   591 //#ifdef __SAP_POLICY_MANAGEMENT
       
   592 TPtrC8 CWallpaperAdapter::PolicyRequestResourceL( const TDesC8& /*aURI*/ )
       
   593 	{
       
   594 	
       
   595 if(!FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement ))
       
   596 {
       
   597 	User::Leave(KErrNotSupported);
       
   598 	
       
   599 }
       
   600 return PolicyEngineXACML::KCustomizationManagement();
       
   601 
       
   602 	
       
   603 	}
       
   604 //#endif
       
   605 
       
   606 // ------------------------------------------------------------------------------------------------
       
   607 //
       
   608 // ------------------------------------------------------------------------------------------------
       
   609 CWallpaperAdapter::TNodeId CWallpaperAdapter::NodeId( const TDesC8& aURI )
       
   610 	{
       
   611 	TNodeId id = ENodeUnknown;
       
   612 
       
   613 #ifdef __TARM_SYMBIAN_CONVERGENCY
       
   614 	TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash( aURI );
       
   615 	TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
       
   616 	TPtrC8 app = NSmlDmURI::LastURISeg( uriPtrc );
       
   617 #else
       
   618 	TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) );
       
   619 	TPtrC8 app = NSmlDmURI::LastURISeg( aURI );
       
   620 #endif
       
   621 
       
   622 	if ( cnt == 1 )
       
   623 		{
       
   624 		if (app == KSmlCustomizationN)
       
   625 			{
       
   626 			id = ENodeCustomization;
       
   627 			}
       
   628 		}
       
   629 	else if ( cnt == 2 ) 
       
   630 		{
       
   631 		if (app == KSmlWPWallpaperN)
       
   632 			{
       
   633 			id = ENodeWallpaper;
       
   634 			}
       
   635 		}
       
   636 	else if ( cnt == 3 ) 
       
   637 		{
       
   638 		if (app == KSmlWPDataN)
       
   639 			{
       
   640 			id = ENodeImage;
       
   641 			}
       
   642 		}
       
   643 
       
   644 	return id;
       
   645 	}
       
   646 
       
   647 // ------------------------------------------------------------------------------------------------
       
   648 //
       
   649 // ------------------------------------------------------------------------------------------------
       
   650 const TImplementationProxy ImplementationTable[] = 
       
   651 	{
       
   652 	{ {KSmlDMWallpaperAdapterImplUid}, (TProxyNewLPtr)CWallpaperAdapter::NewL }
       
   653 	};
       
   654 
       
   655 // ------------------------------------------------------------------------------------------------
       
   656 //
       
   657 // ------------------------------------------------------------------------------------------------
       
   658 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
   659 	{
       
   660 	aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
   661 	return ImplementationTable;
       
   662 	}
       
   663 
       
   664 // ------------------------------------------------------------------------------------------------
       
   665 //
       
   666 // ------------------------------------------------------------------------------------------------
       
   667 void CWallpaperAdapter::ConstructL( )
       
   668 	{
       
   669 		TRAPD( errf, FeatureManager::InitializeLibL() );
       
   670 		if( errf != KErrNone )
       
   671 		{
       
   672 			User::Leave(errf);
       
   673 		}
       
   674 		if( ! FeatureManager::FeatureSupported(KFeatureIdSapWallpaperAdapter))
       
   675 		{
       
   676 			
       
   677 	   		User::Leave( KErrNotSupported );
       
   678 		}
       
   679 	}
       
   680 
       
   681 // -------------------------------------------------------------------------------------
       
   682 // CWallpaperAdapter::FillNodeInfoL()
       
   683 // Fills the node info in ddf structure
       
   684 // -------------------------------------------------------------------------------------
       
   685 void CWallpaperAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode,TSmlDmAccessTypes aAccTypes,
       
   686 								MSmlDmDDFObject::TOccurence aOccurrence, MSmlDmDDFObject::TScope aScope, 
       
   687 								MSmlDmDDFObject::TDFFormat aFormat,const TDesC8& aDescription,TBool aObjectGroup)
       
   688 	{
       
   689 	aNode.SetAccessTypesL(aAccTypes);
       
   690 	aNode.SetOccurenceL(aOccurrence);
       
   691 	aNode.SetScopeL(aScope);
       
   692 	aNode.SetDFFormatL(aFormat);
       
   693 	if(aFormat!=MSmlDmDDFObject::ENode)
       
   694 		{
       
   695 		aNode.AddDFTypeMimeTypeL(KSmlWPTextPlain);
       
   696 		}
       
   697 	aNode.SetDescriptionL(aDescription);
       
   698 	if(aObjectGroup)
       
   699 		{
       
   700 		aNode.SetAsObjectGroup();
       
   701 		}
       
   702 	}
       
   703 
       
   704 // -------------------------------------------------------------------------------------
       
   705 // CWallpaperAdapter::IsImage()
       
   706 // Checks whether the given mime type is image format (that we support)
       
   707 // -------------------------------------------------------------------------------------
       
   708 TBool CWallpaperAdapter::IsImageL( const TDesC8& aMime ) 
       
   709 	{
       
   710 	RDEBUG_2("CWallpaperAdapter::IsImageL( %S )", &aMime );
       
   711 	TBool ret = EFalse;
       
   712 	HBufC8* buf = aMime.AllocLC();
       
   713 	TPtr8 ptr = buf->Des();
       
   714 	ptr.LowerCase();
       
   715 	ptr.Trim();
       
   716 	
       
   717 	
       
   718 	
       
   719 	if( ptr == KMimeTypeJpeg )
       
   720 		{
       
   721 		ret = ETrue;
       
   722 		}
       
   723 	else if( ptr == KMimeTypeGif )
       
   724 		{
       
   725 		ret = ETrue;
       
   726 		}
       
   727 
       
   728 	CleanupStack::PopAndDestroy( buf );
       
   729 	return ret;
       
   730 	}
       
   731 	
       
   732