skins/AknSkins/srvsrc/AknsSrvClient.cpp
changeset 0 05e9090e2422
child 1 ba33815114d6
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  Skin server client.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <AknsSrvClient.h>
       
    21 #include "AknsSrv.h"
       
    22 #include "AknsSkinChangeHandler.h"
       
    23 #include "AknsSrvClientMemberData.h"
       
    24 #include <AknsImageAttributeData.h>
       
    25 #include "AknsSrvUtils.h"
       
    26 
       
    27 #include <aknutils.h> 
       
    28 #include <akniconconfig.h>
       
    29 
       
    30 #include "AknsDebug.h"
       
    31 #include <hal.h>
       
    32 #include <badesca.h>
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 // Number of re-tries for skin server connection.
       
    37 const TInt KAknSkinSrvConnectionTries = 2;
       
    38 // Number of message slots.
       
    39 const TUint KAknSkinSrvDefaultMessageSlots = 2;
       
    40 
       
    41 // ============================= LOCAL FUNCTIONS ===============================
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // AknsSrvCArrayPtrCleanup
       
    45 // Cleanup operation for CArrayPtr<CAknsSrvSkinInformationPkg>
       
    46 // -----------------------------------------------------------------------------
       
    47 static void AknsSrvCArrayPtrCAknsSrvSkinInformationPkgCleanup( TAny* aItem )
       
    48     {
       
    49     CArrayPtr<CAknsSrvSkinInformationPkg>* array = static_cast<
       
    50         CArrayPtr<CAknsSrvSkinInformationPkg>*>( aItem );
       
    51     array->ResetAndDestroy();
       
    52     delete array;
       
    53     }
       
    54 
       
    55 // ============================ MEMBER FUNCTIONS ===============================
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // RAknsSrvSession::RAknsSrvSession
       
    59 // C++ constructor can NOT contain any code, that might leave.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C RAknsSrvSession::RAknsSrvSession()
       
    63     : RSessionBase(), iMemberData(NULL)
       
    64     {
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // RAknsSrvSession::Connect
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C TInt RAknsSrvSession::Connect(
       
    72     MAknsSkinChangeObserver* aObserver,
       
    73     TInt aPriority )
       
    74     {
       
    75     AKNS_TRACE_INFO("RAknsSrvSession::Connect ENTERED");
       
    76 
       
    77     if( iHandle )
       
    78         {
       
    79         AKNS_TRACE_INFO("RAknsSrvSession::Connect Handle exists, RETURN KErrNone");
       
    80         return KErrNone;
       
    81         }
       
    82 
       
    83     // Connect to server and make sure this can't cause 2 servers launch
       
    84     // if 2 clients are trying to connect simultaneously.
       
    85 
       
    86     AKNS_TRACE_INFO("RAknsSrvSession::Connect Creating member data");
       
    87 
       
    88     iMemberData = new TAknsSrvClientMemberData;
       
    89     if (!iMemberData)
       
    90         {
       
    91         AKNS_TRACE_ERROR("RAknsSrvSession::Connect NO MEMORY");
       
    92         return KErrNoMemory;
       
    93         }
       
    94 
       
    95     iMemberData->iHandler = NULL;
       
    96     iMemberData->iObserver = aObserver;
       
    97 
       
    98     TInt err( KErrNone );
       
    99 
       
   100     for ( TInt tries = 0; tries < KAknSkinSrvConnectionTries ; tries++ )
       
   101         {
       
   102         AKNS_TRACE_INFO("RAknsSrvSession::Connect Creating session");
       
   103         
       
   104         err = CreateSession( KAknSkinSrvName, Version(),
       
   105             KAknSkinSrvDefaultMessageSlots );
       
   106         
       
   107         AKNS_TRACE_INFO1("RAknsSrvSession::Connect Session create ret %d", err);
       
   108 
       
   109         // Break if connected to existing server or if the problem is
       
   110         // other than missing server.
       
   111 
       
   112         if ( err == KErrNone ||
       
   113             ( err != KErrNotFound && err != KErrServerTerminated ) )
       
   114             {
       
   115             break;
       
   116             }
       
   117 
       
   118         AKNS_TRACE_INFO("RAknsSrvSession::Connect Trying to start the server");
       
   119 
       
   120         err = StartServer();    // try start a new server
       
   121 
       
   122         AKNS_TRACE_INFO1("RAknsSrvSession::Connect StartServer ret %d", err);
       
   123 
       
   124         // If server launched ok or someone else got to launch it first,
       
   125         // try connect again.
       
   126 
       
   127         if( (err!=KErrNone) && (err!=KErrAlreadyExists) )
       
   128             {
       
   129             break; // server not launched: don't cycle round again
       
   130             }
       
   131         }
       
   132 
       
   133     if (err != KErrNone)
       
   134         {
       
   135         AKNS_TRACE_ERROR1("RAknsSrvSession::Connect CREATE SESSION FAILED, err=%d", err);
       
   136         delete iMemberData;
       
   137         iMemberData = NULL;
       
   138         return err;
       
   139         }
       
   140 
       
   141     // Check if the user wanted us to notify skin changes and create
       
   142     // the Active object to handle the notification events. Otherwise
       
   143     // just return.
       
   144     if( iMemberData->iObserver)
       
   145         {
       
   146         AKNS_TRACE_INFO("RAknsSrvSession::Connect Observer required");
       
   147 
       
   148         __ASSERT_DEBUG( CActiveScheduler::Current(), User::Panic(
       
   149             KAknSkinSrvPanicCategory, EAknsSrvNoActiveScheduler ) );
       
   150 
       
   151         iMemberData->iHandler = new CAknsSkinChangeHandler( *this, aPriority );
       
   152 
       
   153         if( !iMemberData->iHandler )
       
   154             {
       
   155             AKNS_TRACE_ERROR("RAknsSrvSession::Connect NO MEMORY FOR HANDLER");
       
   156             delete iMemberData;
       
   157             iMemberData = NULL;
       
   158             return KErrNoMemory;
       
   159             }
       
   160 
       
   161         CActiveScheduler::Add( iMemberData->iHandler );
       
   162         iMemberData->iHandler->SetActive();
       
   163 
       
   164         // Set the notify handler also on the server side;
       
   165         SendReceive( EAknSkinSrvSetNotifyHandler, TIpcArgs( iMemberData->iHandler) );
       
   166         EventHandled();
       
   167         }
       
   168 
       
   169     AKNS_TRACE_INFO("RAknsSrvSession::Connect COMPLETED");
       
   170 
       
   171     // Everything went ok if we managed to get here.
       
   172     return KErrNone;
       
   173     }
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // RAknsSrvSession::Close
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 EXPORT_C void RAknsSrvSession::Close()
       
   180     {
       
   181     if ( iMemberData && iMemberData->iHandler )
       
   182         {
       
   183         iMemberData->iHandler->Cancel();
       
   184         delete iMemberData->iHandler;
       
   185         iMemberData->iHandler = NULL;
       
   186         }
       
   187 
       
   188     RSessionBase::Close();
       
   189     if (iMemberData)
       
   190         {
       
   191         delete iMemberData;
       
   192         iMemberData = NULL;
       
   193         }
       
   194     }
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // RAknsSrvSession::EnableSkinChangeNotify
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 EXPORT_C void RAknsSrvSession::EnableSkinChangeNotify()
       
   201     {
       
   202     SendReceive( EAknSkinSrvEnableNotifySkinChange , TIpcArgs( TIpcArgs::ENothing) );
       
   203     }
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // RAknsSrvSession::DisableSkinChangeNotify
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C void RAknsSrvSession::DisableSkinChangeNotify()
       
   210     {
       
   211     SendReceive( EAknSkinSrvDisableNotifySkinChange, TIpcArgs( TIpcArgs::ENothing) );
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // RAknsSrvSession::ClientError
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 EXPORT_C void RAknsSrvSession::ClientError(TInt aErrorCode)
       
   219     {
       
   220     AKNS_TRACE_ERROR("RAknsSrvSession::ClientError");
       
   221 
       
   222     SendReceive(EAknSkinSrvClientError, TIpcArgs( aErrorCode ) );
       
   223 
       
   224     AKNS_TRACE_INFO("RAknsSrvSession::ClientError COMPLETED");
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // RAknsSrvSession::SetAllDefinitionSets
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 EXPORT_C TInt RAknsSrvSession::SetAllDefinitionSets( const TAknsPkgID aPID )
       
   232     {
       
   233     AKNS_TRACE_INFO2("RAknsSrvSession::SetAllDefinitionSets %i %i", aPID.iNumber, aPID.iTimestamp);
       
   234     TInt freeRAM = 0;
       
   235     HAL::Get(HALData::EMemoryRAMFree, freeRAM);
       
   236     if ( freeRAM < KAknSkinSrvFreeRAMNeeded )
       
   237         {
       
   238         return KErrNoMemory;
       
   239         }
       
   240 
       
   241     return SendReceive( EAknSkinSrvSetAllItemDefSets,
       
   242         TIpcArgs( aPID.iNumber, aPID.iTimestamp) );
       
   243     } //lint !e1746 TUid is a single word
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 // RAknsSrvSession::EnumerateSkinPackages
       
   247 // -----------------------------------------------------------------------------
       
   248 //
       
   249 EXPORT_C CArrayPtr<CAknsSrvSkinInformationPkg>*
       
   250     RAknsSrvSession::EnumerateSkinPackagesL(
       
   251         TAknSkinSrvSkinPackageLocation aLocation )
       
   252     {
       
   253     CArrayPtrFlat<CAknsSrvSkinInformationPkg>* array =
       
   254         new (ELeave) CArrayPtrFlat<CAknsSrvSkinInformationPkg>(5);
       
   255     CleanupStack::PushL( TCleanupItem(
       
   256         AknsSrvCArrayPtrCAknsSrvSkinInformationPkgCleanup, array ) );
       
   257 
       
   258     TPckgBuf<TInt> pkgCountPack;
       
   259     SendReceive( EAknSkinSrvEnumeratePackages, TIpcArgs(&pkgCountPack, aLocation));
       
   260     TInt pkgCount = pkgCountPack();
       
   261     if (pkgCount <= 0)
       
   262         {
       
   263         CleanupStack::Pop( array );
       
   264         return array;
       
   265         }
       
   266     if ( ( pkgCount*sizeof(TAknsSrvSkinInfoPkg) ) > KMaxTInt )
       
   267         {
       
   268         CleanupStack::Pop( array );
       
   269         return array;
       
   270         }
       
   271     HBufC8* packages = HBufC8::NewLC(pkgCount*sizeof(TAknsSrvSkinInfoPkg));
       
   272     TPtr8 ptr8 = packages->Des();
       
   273     User::LeaveIfError(SendReceive( EAknSkinSrvReceivePackages, TIpcArgs(pkgCount, &ptr8)));
       
   274 
       
   275     for (TInt count = 0; count < pkgCount; count++)
       
   276         {
       
   277         TAknsSrvSkinInfoPkg* pkg = (TAknsSrvSkinInfoPkg*)&(ptr8[count*sizeof(TAknsSrvSkinInfoPkg)]);
       
   278         CAknsSrvSkinInformationPkg* pack = CAknsSrvSkinInformationPkg::NewL(
       
   279             pkg->iPID,
       
   280             pkg->iColorSchemePID,
       
   281             pkg->iSkinDirectoryBuf,
       
   282             pkg->iSkinIniFileDirectoryBuf,
       
   283             pkg->iSkinNameBuf,
       
   284             pkg->iIdleStateWallPaperImageName,
       
   285             KNullDesC,
       
   286             pkg->iFullName,
       
   287             pkg->iIdleBgImageIndex,
       
   288             0,
       
   289             pkg->iIsDeletable,
       
   290             pkg->iIsCopyable,
       
   291             EFalse,
       
   292             pkg->iProtectionType,
       
   293             pkg->iCorrupted,
       
   294             pkg->iSupportAnimBg
       
   295             );
       
   296         CleanupStack::PushL(pack);
       
   297         array->AppendL(pack);
       
   298         CleanupStack::Pop(pack);
       
   299         }
       
   300 
       
   301     CleanupStack::PopAndDestroy( packages );
       
   302     CleanupStack::Pop( array );
       
   303 
       
   304     AKNS_TRACE_INFO1("RAknsSrvSession::EnumerateSkinPackagesL COMPLETED %i",
       
   305         array->Count() );
       
   306 
       
   307     return array;
       
   308     }
       
   309 
       
   310 // -----------------------------------------------------------------------------
       
   311 // RAknsSrvSession::CreateChunkLookupL
       
   312 // -----------------------------------------------------------------------------
       
   313 //
       
   314 EXPORT_C CAknsSrvChunkLookup* RAknsSrvSession::CreateChunkLookupL()
       
   315     {
       
   316     CAknsSrvChunkLookup* chunklookup = CAknsSrvChunkLookup::NewL();
       
   317     return chunklookup;
       
   318     }
       
   319 
       
   320 // -----------------------------------------------------------------------------
       
   321 // RAknsSrvSession::Version
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 TVersion RAknsSrvSession::Version() const
       
   325     {
       
   326     // client side version is set same as the server side version here, since
       
   327     // both are implemented in the same DLL
       
   328     return TVersion( KAknSkinSrvMajorVersionNumber,
       
   329         KAknSkinSrvMinorVersionNumber, KAknSkinSrvBuildVersionNumber );
       
   330     }
       
   331 
       
   332 // -----------------------------------------------------------------------------
       
   333 // RAknsSrvSession::SetIdleWallPaper
       
   334 // -----------------------------------------------------------------------------
       
   335 //
       
   336 EXPORT_C TInt RAknsSrvSession::SetIdleWallpaper( const TDesC& aFilename )
       
   337     {
       
   338     TInt freeRAM = 0;
       
   339     HAL::Get(HALData::EMemoryRAMFree, freeRAM);
       
   340     if ( freeRAM < KAknSkinSrvFreeRAMNeeded )
       
   341         {
       
   342         return KErrNoMemory;
       
   343         }
       
   344 
       
   345     return SendReceive( EAknSkinSrvSetIdleWallPaper,
       
   346         TIpcArgs( &aFilename, aFilename.Length() ) );
       
   347     }
       
   348 
       
   349 // -----------------------------------------------------------------------------
       
   350 // RAknsSrvSession::
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353 EXPORT_C TInt RAknsSrvSession::StoreScalableGraphics(const TAknsItemID& aIID,
       
   354     const TInt aType, const TSize& aLayoutSize, const CFbsBitmap* aBmp,
       
   355     const CFbsBitmap* aMask, TBool aMorphing)
       
   356     {
       
   357     TAknsSrvLayoutInfo layoutInfo;
       
   358     layoutInfo.iLayoutType = aType;
       
   359     layoutInfo.iLayoutSize = aLayoutSize;
       
   360     TPckgC<TAknsSrvLayoutInfo> layoutInfoPack( layoutInfo );
       
   361 
       
   362     TInt bmphandle = 0;
       
   363     TInt mskhandle = 0;
       
   364 
       
   365     if (aBmp)
       
   366         {
       
   367         bmphandle = aBmp->Handle();
       
   368         }
       
   369     else
       
   370         {
       
   371         return KErrArgument;
       
   372         }
       
   373     if (aMask)
       
   374         {
       
   375         mskhandle = aMask->Handle();
       
   376         }
       
   377 
       
   378     TPckgC<TAknsItemID> iidPack( aIID );
       
   379     if (aMorphing)
       
   380         {
       
   381         return SendReceive( EAknSkinSrvStoreMorphingScalableGfx, TIpcArgs(
       
   382         &iidPack, &layoutInfoPack, bmphandle, mskhandle));
       
   383         }
       
   384     else
       
   385         {
       
   386         return SendReceive( EAknSkinSrvStoreScalableGfx, TIpcArgs(
       
   387         &iidPack, &layoutInfoPack, bmphandle, mskhandle));
       
   388         }
       
   389     }
       
   390 
       
   391 // -----------------------------------------------------------------------------
       
   392 // RAknsSrvSession::ClearScalableGraphics
       
   393 // -----------------------------------------------------------------------------
       
   394 //
       
   395 EXPORT_C TInt RAknsSrvSession::ClearScalableGraphics()
       
   396     {
       
   397     return SendReceive( EAknSkinSrvClearScalableGfx, TIpcArgs() );
       
   398     }
       
   399 
       
   400 // -----------------------------------------------------------------------------
       
   401 // RAknsSrvSession::DeleteSkin
       
   402 // -----------------------------------------------------------------------------
       
   403 //
       
   404 EXPORT_C TInt RAknsSrvSession::DeleteSkin(
       
   405     const TAknsPkgID /*aPID*/, TAknSkinSrvSkinPackageLocation /*aLocation*/ )
       
   406     {
       
   407     return KErrNotSupported;
       
   408     }
       
   409 
       
   410 // -----------------------------------------------------------------------------
       
   411 // RAknsSrvSession::CopySkin
       
   412 // -----------------------------------------------------------------------------
       
   413 //
       
   414 EXPORT_C TInt RAknsSrvSession::CopySkin(
       
   415     const TAknsPkgID /*aPID*/, TAknSkinSrvSkinPackageLocation /*aSourceLocation*/,
       
   416     TAknSkinSrvSkinPackageLocation /*aDestLocation*/)
       
   417     {
       
   418     return KErrNotSupported;
       
   419     }
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // RAknsSrvSession::OpenBitmapFile
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 EXPORT_C TInt RAknsSrvSession::OpenBitmapFile( const TDesC& aFilename, TInt &aFileHandle)
       
   426     {
       
   427     TPckgBuf<TInt> filehandlePack;
       
   428     TInt fileserverHandle = SendReceive(
       
   429         EAknSkinSrvOpenBitmapFile, TIpcArgs(&aFilename, &filehandlePack));
       
   430     aFileHandle = filehandlePack();
       
   431     return fileserverHandle;
       
   432     }
       
   433 
       
   434 // -----------------------------------------------------------------------------
       
   435 // RAknsSrvSession::OpenInifile
       
   436 // -----------------------------------------------------------------------------
       
   437 //
       
   438 EXPORT_C TInt RAknsSrvSession::OpenInifile(
       
   439     const TAknsPkgID aPID, TAknSkinSrvSkinPackageLocation aLocation,
       
   440     TInt& aFilehandle, TBool aWriteToFile)
       
   441     {
       
   442     TPckgC<TAknsPkgID> iidPack( aPID );
       
   443     TPckgBuf<TInt> filehandlePack;
       
   444     TInt fileserverHandle = SendReceive(
       
   445         EAknSkinSrvOpenIniFile, TIpcArgs(&iidPack, aLocation, &filehandlePack, aWriteToFile));
       
   446     aFilehandle = filehandlePack();
       
   447     return fileserverHandle;
       
   448     }
       
   449 
       
   450 // -----------------------------------------------------------------------------
       
   451 // RAknsSrvSession::CopySoundFile
       
   452 // -----------------------------------------------------------------------------
       
   453 //
       
   454 EXPORT_C TInt RAknsSrvSession::CopySoundFile(const TDesC& aSourceFilename, const TDesC& aTargetFilename)
       
   455   {
       
   456   return SendReceive(
       
   457     EAknSkinSrvCopySoundFile, TIpcArgs(&aSourceFilename, &aTargetFilename) );
       
   458   }
       
   459 
       
   460 // -----------------------------------------------------------------------------
       
   461 // RAknsSrvSession::DecodeWallpaperImageL
       
   462 // -----------------------------------------------------------------------------
       
   463 //
       
   464 EXPORT_C void RAknsSrvSession::DecodeWallpaperImageL(
       
   465     const TDesC& aFilename, const TSize& aTargetSize, CFbsBitmap*& aBitmap, CFbsBitmap*& aMask)
       
   466     {
       
   467     TPckgBuf<TInt> bmphandlePack;
       
   468     TPckgBuf<TInt> mskhandlePack;
       
   469     TPckgC<TSize> sizePack(aTargetSize);
       
   470     User::LeaveIfError(
       
   471         SendReceive(
       
   472             EAknSkinSrvDecodeWallpaperImage,
       
   473             TIpcArgs(&aFilename, &sizePack, &bmphandlePack, &mskhandlePack)));
       
   474     if (aTargetSize == TSize(-1,-1))
       
   475         {
       
   476         // 0,0 is used to check if the image is corrupted
       
   477         return;
       
   478         }
       
   479 
       
   480     delete aBitmap;
       
   481     aBitmap = NULL;
       
   482     delete aMask;
       
   483     aMask = NULL;
       
   484 
       
   485     CFbsBitmap* bitmap = NULL;
       
   486     CFbsBitmap* mask = NULL;
       
   487     bitmap = new (ELeave) CFbsBitmap;
       
   488     CleanupStack::PushL(bitmap);
       
   489     User::LeaveIfError(bitmap->Duplicate(bmphandlePack()));
       
   490     if (mskhandlePack())
       
   491         {
       
   492         mask = new (ELeave) CFbsBitmap;
       
   493         CleanupStack::PushL(mask);
       
   494         User::LeaveIfError(mask->Duplicate(mskhandlePack()));
       
   495         CleanupStack::Pop(2);
       
   496         }
       
   497     else
       
   498         {
       
   499         CleanupStack::Pop( bitmap );
       
   500         }
       
   501 
       
   502     AknIconConfig::CompressIfPreferred( bitmap, mask );
       
   503 
       
   504     aBitmap = bitmap;
       
   505     aMask = mask;
       
   506     }
       
   507 
       
   508 
       
   509 EXPORT_C void RAknsSrvSession::AddWallpaperL(const TDesC& aFilename, const TSize& aTargetSize )
       
   510     {
       
   511     TPckgC<TSize> sizePack(aTargetSize);
       
   512     User::LeaveIfError( SendReceive( EAknSkinSrvCacheWallpaperImage,
       
   513                 TIpcArgs(&aFilename, &sizePack)));
       
   514     
       
   515     return;
       
   516     }
       
   517 
       
   518 EXPORT_C CFbsBitmap* RAknsSrvSession::WallpaperImageL( const TDesC& aFilename )
       
   519     {
       
   520     TPckgBuf<TInt> bmphandlePack;
       
   521     TPckgBuf<TInt> mskhandlePack;
       
   522     CFbsBitmap* bitmap = NULL;
       
   523     
       
   524 //    CWsScreenDevice* screenDevice = 
       
   525 //            STATIC_CAST(CWsScreenDevice*, CCoeEnv::Static()->SystemGc().Device());   
       
   526 //    CleanupStack::PushL( screenDevice );
       
   527 //    User::LeaveIfError( screenDevice->Construct() );
       
   528 //    TSize currentScreenSize = screenDevice->SizeInPixels();
       
   529 //    TPckgC<TSize> sizePack( currentScreenSize );
       
   530 //    
       
   531 //    CleanupStack::PopAndDestroy( screenDevice );
       
   532     
       
   533     TRect screen;
       
   534     AknLayoutUtils::LayoutMetricsRect(
       
   535                             AknLayoutUtils::EScreen, screen );
       
   536     TPckgC<TSize> sizePack( screen.Size() );    
       
   537     
       
   538     User::LeaveIfError( SendReceive(EAknSkinSrvDecodeWallpaperImage,
       
   539             TIpcArgs(&aFilename, &sizePack, &bmphandlePack, &mskhandlePack))); 
       
   540     
       
   541     if ( bmphandlePack() )
       
   542         {
       
   543         bitmap = new (ELeave) CFbsBitmap;
       
   544         CleanupStack::PushL(bitmap);
       
   545         User::LeaveIfError(bitmap->Duplicate(bmphandlePack()));
       
   546         CleanupStack::Pop( bitmap );
       
   547         }
       
   548     return bitmap;
       
   549     }
       
   550 // -----------------------------------------------------------------------------
       
   551 // RAknsSrvSession::OpenImageInifile
       
   552 // -----------------------------------------------------------------------------
       
   553 //
       
   554 EXPORT_C TInt RAknsSrvSession::OpenImageInifile( TAknsSrvInifileType aType, TInt& aFilehandle )
       
   555     {
       
   556     TPckgBuf<TInt> filehandlePack;
       
   557     TInt fileserverHandle = SendReceive( EAknSkinSrvOpenImageInifile, TIpcArgs(&filehandlePack, aType));
       
   558     aFilehandle = filehandlePack();
       
   559     return fileserverHandle;
       
   560     }
       
   561 
       
   562 // -----------------------------------------------------------------------------
       
   563 // RAknsSrvSession::DoWriteInifileL
       
   564 // -----------------------------------------------------------------------------
       
   565 //
       
   566 void RAknsSrvSession::DoWriteInifileL(const CDesCArray& aFilenameArray)
       
   567     {
       
   568     TInt fileserverhandle;
       
   569     TInt filehandle;
       
   570     fileserverhandle = OpenImageInifile(EAknsSrvInifileSSWP, filehandle);
       
   571     RFile file;
       
   572     User::LeaveIfError(file.AdoptFromServer(fileserverhandle, filehandle));
       
   573     CleanupClosePushL(file);
       
   574     User::LeaveIfError(file.SetSize(0));
       
   575     TFileText textFile;
       
   576     textFile.Set(file);
       
   577     textFile.Seek(ESeekStart);
       
   578 
       
   579     for (TInt count = 0; count < aFilenameArray.Count() ; count++)
       
   580         {
       
   581         User::LeaveIfError(textFile.Write(aFilenameArray.MdcaPoint(count)));
       
   582         }
       
   583 
       
   584     file.Flush();
       
   585     CleanupStack::PopAndDestroy(); // file
       
   586     }
       
   587 
       
   588 // -----------------------------------------------------------------------------
       
   589 // RAknsSrvSession::SetSlideSetWallpaper
       
   590 // -----------------------------------------------------------------------------
       
   591 //
       
   592 EXPORT_C TInt RAknsSrvSession::SetSlideSetWallpaper(const CDesCArray& /*aFilenameArray*/)
       
   593     {
       
   594     //deprecated for 9.2 page specific wallpaper
       
   595     return KErrNotSupported;  
       
   596     }
       
   597 
       
   598 // -----------------------------------------------------------------------------
       
   599 // RAknsSrvSession::FreeUnnecessaryLayoutBitmaps
       
   600 // -----------------------------------------------------------------------------
       
   601 //
       
   602 EXPORT_C void RAknsSrvSession::FreeUnnecessaryLayoutBitmaps(TAknsSrcScreenMode aMode)
       
   603     {
       
   604     TInt type( aMode );
       
   605     SendReceive( EAknSkinSrvFreeLayoutBitmaps, TIpcArgs( type ) );
       
   606     }
       
   607 
       
   608 
       
   609 EXPORT_C void RAknsSrvSession::RemoveWallpaper( const TDesC& aFilename )
       
   610     {
       
   611     SendReceive( EAknSkinSrvFreeDecodedWallpaper, TIpcArgs(&aFilename) );
       
   612     }
       
   613 
       
   614 EXPORT_C void RAknsSrvSession::RemoveAllWallpapers(  )
       
   615     {
       
   616     SendReceive( EAknSkinSrvFreeDecodedWallpaper, TIpcArgs(&KNullDesC) );
       
   617     }
       
   618 
       
   619 // -----------------------------------------------------------------------------
       
   620 // Checks if the appUid has non-skinnable configuration icons.
       
   621 // -----------------------------------------------------------------------------
       
   622 //
       
   623 EXPORT_C TInt RAknsSrvSession::CheckIconConfiguration( TUid aAppUid )
       
   624     {
       
   625     TPckgC<TUid> uidPack(aAppUid);
       
   626     return SendReceive( EAknSkinSrvCheckIconConfiguration, TIpcArgs( &uidPack ) );
       
   627     }
       
   628 
       
   629 // -----------------------------------------------------------------------------
       
   630 // RAknsSrvSession::AcknowledgeSkinChangeNotification
       
   631 // -----------------------------------------------------------------------------
       
   632 //
       
   633 TInt RAknsSrvSession::AcknowledgeSkinChangeNotification()
       
   634     {
       
   635     TInt type( EAknsSCHNContentChanged );
       
   636     return SendReceive( EAknSkinSrvAckNotification, TIpcArgs( type ) );
       
   637     }
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 // RAknsSrvSession::Reserved1
       
   641 // -----------------------------------------------------------------------------
       
   642 //
       
   643 EXPORT_C TInt RAknsSrvSession::Reserved1()
       
   644     {
       
   645     return 0;
       
   646     }
       
   647 
       
   648 // -----------------------------------------------------------------------------
       
   649 // RAknsSrvSession::Reserved2
       
   650 // -----------------------------------------------------------------------------
       
   651 //
       
   652 EXPORT_C TInt RAknsSrvSession::Reserved2()
       
   653     {
       
   654     return 0;
       
   655     }
       
   656 
       
   657 // -----------------------------------------------------------------------------
       
   658 // RAknsSrvSession::Reserved3
       
   659 // -----------------------------------------------------------------------------
       
   660 //
       
   661 EXPORT_C TInt RAknsSrvSession::Reserved3()
       
   662     {
       
   663     return 0;
       
   664     }
       
   665 
       
   666 // -----------------------------------------------------------------------------
       
   667 // RAknsSrvSession::Reserved4
       
   668 // -----------------------------------------------------------------------------
       
   669 //
       
   670 EXPORT_C void RAknsSrvSession::Reserved4()
       
   671     {
       
   672     }
       
   673 
       
   674 // -----------------------------------------------------------------------------
       
   675 // RAknsSrvSession::SendCancel
       
   676 // -----------------------------------------------------------------------------
       
   677 //
       
   678 void RAknsSrvSession::SendCancel()
       
   679     {
       
   680     SendReceive(EAknSkinSrvCancel, TIpcArgs( TIpcArgs::ENothing ) );
       
   681     }
       
   682 
       
   683 // -----------------------------------------------------------------------------
       
   684 // RAknsSrvSession::EventHandled
       
   685 // -----------------------------------------------------------------------------
       
   686 //
       
   687 void RAknsSrvSession::EventHandled()
       
   688     {
       
   689     SendReceive(EAknSkinSrvNextEvent, TIpcArgs( TIpcArgs::ENothing),
       
   690         iMemberData->iHandler->iStatus);
       
   691     }
       
   692 
       
   693 // End of File