webengine/widgetregistry/Client/src/WidgetRegistryClient.cpp
changeset 0 dd21522fd290
child 25 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2003, 2004, 2005 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 the License "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: 
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <f32file.h>
       
    21 #include <s32mem.h>
       
    22 #include "WidgetRegistryClient.h"
       
    23 
       
    24 
       
    25 // ============================================================================
       
    26 // Starts the widget registry server
       
    27 //
       
    28 // @since 3.1
       
    29 // ============================================================================
       
    30 //
       
    31 TInt StartServer()
       
    32     {
       
    33     const TUidType KServerUidType(
       
    34         KNullUid, KNullUid, KWidgetRegistryServerUid );
       
    35 
       
    36     RProcess server;
       
    37     TInt ret = server.Create(
       
    38         KWidgetRegistryImage, KNullDesC, KServerUidType );
       
    39 
       
    40     // Did we manage to create the thread/process?
       
    41     if (ret == KErrNone)
       
    42         {
       
    43         // Wait to see if the thread/process died during construction
       
    44         TRequestStatus serverDiedRequestStatus;
       
    45         server.Rendezvous( serverDiedRequestStatus );
       
    46 
       
    47         // do we have to abort?
       
    48         if  ( serverDiedRequestStatus != KRequestPending )
       
    49             {
       
    50             // abort the startup here
       
    51             server.Kill(0);
       
    52             }
       
    53         else
       
    54             {
       
    55             // start server
       
    56             server.Resume();
       
    57             }
       
    58 
       
    59         User::WaitForRequest( serverDiedRequestStatus );
       
    60 
       
    61         // Determine the reason for the server exit.
       
    62         const TInt exitReason = ( server.ExitType() == EExitPanic ) ?
       
    63             KErrGeneral : serverDiedRequestStatus.Int();
       
    64         ret = exitReason;
       
    65 
       
    66         // Finished with process handle
       
    67         server.Close();
       
    68         }
       
    69 
       
    70     return ret;
       
    71     }
       
    72 
       
    73 // ============================================================================
       
    74 // RWidgetRegistryClientSession::RWidgetRegistryClientSession()
       
    75 // C++ constructor
       
    76 //
       
    77 // @since 3.1
       
    78 // ============================================================================
       
    79 //
       
    80 EXPORT_C RWidgetRegistryClientSession::RWidgetRegistryClientSession()
       
    81     {
       
    82     }
       
    83 
       
    84 // ============================================================================
       
    85 // RWidgetRegistryClientSession::Connect()
       
    86 // Connect to widgetregistry server
       
    87 //
       
    88 // @since 3.1
       
    89 // ============================================================================
       
    90 //
       
    91 EXPORT_C TInt RWidgetRegistryClientSession::Connect()
       
    92     {
       
    93     TInt startupAttempts = KWidgetRegistryServerStartupAttempts;
       
    94 
       
    95     for ( ;; )
       
    96         {
       
    97         TInt ret = CreateSession( KWidgetRegistryName, Version(),
       
    98             KWidgetRegistryServerAsynchronousSlotCount );
       
    99 
       
   100         if ( ret != KErrNotFound && ret != KErrServerTerminated )
       
   101             {
       
   102             return ret;
       
   103             }
       
   104 
       
   105         if ( startupAttempts-- == 0 )
       
   106             {
       
   107             return ret;
       
   108             }
       
   109 
       
   110         ret = StartServer();
       
   111         if ( ret != KErrNone && ret != KErrAlreadyExists )
       
   112             {
       
   113             return ret;
       
   114             }
       
   115         }
       
   116     }
       
   117 
       
   118 // ============================================================================
       
   119 // RWidgetRegistryClientSession::Version()
       
   120 // Returns the version
       
   121 //
       
   122 // @since 3.1
       
   123 // ============================================================================
       
   124 //
       
   125 EXPORT_C TVersion RWidgetRegistryClientSession::Version() const
       
   126     {
       
   127     const TVersion version(
       
   128         KWidgetRegistryClientVersionMajor,
       
   129         KWidgetRegistryClientVersionMinor,
       
   130         KWidgetRegistryClientVersionBuild );
       
   131 
       
   132     return version;
       
   133     }
       
   134 
       
   135 
       
   136 // ============================================================================
       
   137 // RWidgetRegistryClientSession::Disconnect()
       
   138 // Disconnect from widgetregistry server
       
   139 //
       
   140 // @since 3.1
       
   141 // ============================================================================
       
   142 //
       
   143 EXPORT_C TInt RWidgetRegistryClientSession::Disconnect()
       
   144     {
       
   145     SendReceive( EOpCodeWidgetRegistryDisconnect, TIpcArgs() );
       
   146     RSessionBase::Close();
       
   147     return KErrNone;
       
   148     }
       
   149 
       
   150 // ============================================================================
       
   151 // RWidgetRegistryClientSession::IsWidget()
       
   152 // Returns true if the Uid falls within the range specified for widgets.
       
   153 //
       
   154 // @since 3.1
       
   155 // ============================================================================
       
   156 //
       
   157 EXPORT_C TBool RWidgetRegistryClientSession::IsWidget( const TUid& aUid )
       
   158     {
       
   159     TBool retVal = EFalse;
       
   160     iMesgArgs = TIpcArgs( aUid.iUid );
       
   161     retVal = SendReceive( EOpCodeIsWidget, iMesgArgs );
       
   162 
       
   163     return retVal;
       
   164     }
       
   165 
       
   166 // ============================================================================
       
   167 // RWidgetRegistryClientSession::WidgetExists()
       
   168 // Returns true if the widget is installed
       
   169 //
       
   170 // @since 3.1
       
   171 // ============================================================================
       
   172 //
       
   173 EXPORT_C TBool RWidgetRegistryClientSession::WidgetExistsL(
       
   174     const TDesC& aBundleId )
       
   175     {
       
   176     TBool retVal = EFalse;
       
   177     TInt len = aBundleId.Length();
       
   178     iMesgArgs = TIpcArgs( &aBundleId, len );
       
   179 
       
   180     retVal = SendReceive( EOpCodeWidgetExists, iMesgArgs );
       
   181     return retVal;
       
   182     }
       
   183 
       
   184 
       
   185 // ============================================================================
       
   186 // RWidgetRegistryClientSession::IsWidgetRunning()
       
   187 // Returns true if the widget is running.
       
   188 //
       
   189 // @since 3.1
       
   190 // ============================================================================
       
   191 //
       
   192 EXPORT_C TBool RWidgetRegistryClientSession::IsWidgetRunning( const TUid& aUid )
       
   193     {
       
   194     TBool retVal = EFalse;
       
   195     iMesgArgs = TIpcArgs( aUid.iUid );
       
   196     retVal = SendReceive( EOpCodeIsWidgetRunning, iMesgArgs );
       
   197 
       
   198     return retVal;
       
   199     }
       
   200 
       
   201 // ============================================================================
       
   202 // RWidgetRegistryClientSession::WidgetSapiAccessState()
       
   203 // Returns whether sapi access is prompted, promptless or denied.
       
   204 //
       
   205 // @since 5.0
       
   206 // ============================================================================
       
   207 //
       
   208 EXPORT_C TInt RWidgetRegistryClientSession::WidgetSapiAccessState( const TUid& aUid )
       
   209     {
       
   210     TInt retVal = -1;
       
   211     iMesgArgs = TIpcArgs( aUid.iUid );
       
   212     retVal = SendReceive( EOpWidgetSapiAccessState, iMesgArgs );
       
   213 
       
   214     return retVal;
       
   215     }
       
   216 
       
   217 // ============================================================================
       
   218 // RWidgetRegistryClientSession::IsWidgetInMiniView()
       
   219 // Returns true if the widget is in MiniView.
       
   220 //
       
   221 // @since 
       
   222 // ============================================================================
       
   223 //
       
   224 EXPORT_C TBool RWidgetRegistryClientSession::IsWidgetInMiniView( const TUid& aUid )
       
   225     {
       
   226     TBool retVal = EFalse;
       
   227     iMesgArgs = TIpcArgs( aUid.iUid );
       
   228     retVal = SendReceive( EOpCodeIsWidgetInMiniView, iMesgArgs );
       
   229 
       
   230     return retVal;
       
   231     }
       
   232 
       
   233 // ============================================================================
       
   234 // RWidgetRegistryClientSession::IsWidgetInFullView()
       
   235 // Returns true if the widget is in FullView.
       
   236 //
       
   237 // @since 
       
   238 // ============================================================================
       
   239 //
       
   240 EXPORT_C TBool RWidgetRegistryClientSession::IsWidgetInFullView( const TUid& aUid )
       
   241     {
       
   242     TBool retVal = EFalse;
       
   243     iMesgArgs = TIpcArgs( aUid.iUid );
       
   244     retVal = SendReceive( EOpCodeIsWidgetInFullView, iMesgArgs );
       
   245 
       
   246     return retVal;
       
   247     }
       
   248 
       
   249 // ============================================================================
       
   250 // RWidgetRegistryClientSession::IsBlanketPermGranted()
       
   251 // Returns true if the widget is granted blanket permission.
       
   252 //
       
   253 // @since 
       
   254 // ============================================================================
       
   255 EXPORT_C TBool RWidgetRegistryClientSession::IsBlanketPermGranted( const TUid& aUid )
       
   256     {
       
   257     TBool retVal = EFalse;
       
   258     iMesgArgs = TIpcArgs( aUid.iUid );
       
   259     retVal = SendReceive( EOpCodeIsWidgetPromptNeeded, iMesgArgs );
       
   260 
       
   261     return retVal;
       
   262     }
       
   263 
       
   264 // ============================================================================
       
   265 // RWidgetRegistryClientSession::WidgetCount()
       
   266 // Returns count of widgets installed.
       
   267 //
       
   268 // @since 3.1
       
   269 // ============================================================================
       
   270 //
       
   271 EXPORT_C TInt RWidgetRegistryClientSession::WidgetCount( TInt& aCount )
       
   272     {
       
   273     TInt ret = 0;
       
   274     iMesgArgs = TIpcArgs();
       
   275     ret = SendReceive( EOpCodeWidgetCount, iMesgArgs );
       
   276     aCount = ret;
       
   277 
       
   278     return ret;
       
   279     }
       
   280 
       
   281 // ============================================================================
       
   282 // RWidgetRegistryClientSession::GetWidgetPath()
       
   283 // Returns path of the widget with a particular UId
       
   284 //
       
   285 // @since 3.1
       
   286 // ============================================================================
       
   287 //
       
   288 EXPORT_C void RWidgetRegistryClientSession::GetWidgetPath(
       
   289     const TUid& aUid,
       
   290     TDes& aWidgetPath )
       
   291     {
       
   292     iMesgArgs = TIpcArgs( &aWidgetPath, aWidgetPath.Length(), aUid.iUid );
       
   293     TInt len = SendReceive( EOpCodeGetWidgetPath, iMesgArgs );
       
   294 
       
   295     if ( len >= 0 )
       
   296         {
       
   297         aWidgetPath.SetLength( len );
       
   298         }
       
   299     }
       
   300 
       
   301 // ============================================================================
       
   302 // RWidgetRegistryClientSession::GetWidgetUid()
       
   303 // Returns uid of the widget with a particular bundle identifier
       
   304 //
       
   305 // @since 3.1
       
   306 // ============================================================================
       
   307 //
       
   308 EXPORT_C TInt RWidgetRegistryClientSession::GetWidgetUidL(
       
   309     const TDesC& aBundleId )
       
   310     {
       
   311     TInt uid = 0;
       
   312     iMesgArgs = TIpcArgs( &aBundleId,  aBundleId.Length() );
       
   313 
       
   314     uid = SendReceive( EOpCodeGetWidgetUid, iMesgArgs );
       
   315     return uid;
       
   316     }
       
   317 
       
   318 // ============================================================================
       
   319 // RWidgetRegistryClientSession::GetWidgetUidForUrl()
       
   320 // Returns UId of the widget with a patricular html path
       
   321 //
       
   322 // @since 3.1
       
   323 // ============================================================================
       
   324 //
       
   325 EXPORT_C TInt RWidgetRegistryClientSession::GetWidgetUidForUrl(
       
   326     const TDesC& aUrl )
       
   327     {
       
   328     TInt uid = 0;
       
   329     iMesgArgs = TIpcArgs( &aUrl, aUrl.Length() );
       
   330 
       
   331     uid = SendReceive( EOpCodeGetWidgetUidForUrl, iMesgArgs );
       
   332     return uid;
       
   333     }
       
   334 
       
   335 // ============================================================================
       
   336 // RWidgetRegistryClientSession::GetAvailableUidL()
       
   337 // Return the next available UId
       
   338 //
       
   339 // @since 3.1
       
   340 // ============================================================================
       
   341 //
       
   342 EXPORT_C TUid RWidgetRegistryClientSession::GetAvailableUidL( TUint aDriveLetter )
       
   343     {
       
   344     TInt uid = 0;
       
   345     iMesgArgs = TIpcArgs( aDriveLetter );
       
   346 
       
   347     uid = SendReceive( EOpCodeGetAvailableUid, iMesgArgs );
       
   348     if ( KNullUid.iUid == uid )
       
   349       {
       
   350       User::Leave( KErrNotFound );
       
   351       }
       
   352     return TUid::Uid( uid );
       
   353     }
       
   354 
       
   355 // ============================================================================
       
   356 // RWidgetRegistryClientSession::GetWidgetBundleId()
       
   357 // Returns bundle Id of the widget with a particular UId
       
   358 //
       
   359 // @since 3.1
       
   360 // ============================================================================
       
   361 //
       
   362 EXPORT_C void RWidgetRegistryClientSession::GetWidgetBundleId(
       
   363     const TUid& aUid,
       
   364     TDes& aWidgetBundleId )
       
   365     {
       
   366     iMesgArgs = TIpcArgs(
       
   367         &aWidgetBundleId, aWidgetBundleId.Length(), aUid.iUid );
       
   368     TInt len = SendReceive( EOpCodeGetWidgetBundleId, iMesgArgs );
       
   369 
       
   370     if ( len >= 0 )
       
   371         {
       
   372         aWidgetBundleId.SetLength( len );
       
   373         }
       
   374     }
       
   375 
       
   376 // ============================================================================
       
   377 // RWidgetRegistryClientSession::GetWidgetBundleName()
       
   378 // Returns bundle display name of the widget with a particular UId
       
   379 //
       
   380 // @since 3.1
       
   381 // ============================================================================
       
   382 //
       
   383 EXPORT_C void RWidgetRegistryClientSession::GetWidgetBundleName(
       
   384     const TUid& aUid,
       
   385     TDes& aWidgetBundleName )
       
   386     {
       
   387     iMesgArgs = TIpcArgs(
       
   388         &aWidgetBundleName, aWidgetBundleName.Length(), aUid.iUid );
       
   389     TInt len = SendReceive( EOpCodeGetWidgetBundleName, iMesgArgs );
       
   390 
       
   391     if ( len >= 0 )
       
   392         {
       
   393         aWidgetBundleName.SetLength( len );
       
   394         }
       
   395     }
       
   396 
       
   397 // ============================================================================
       
   398 // RWidgetRegistryClientSession::GetWidgetPropertyValue()
       
   399 // Returns info.plist key value string for the widget with a particular UId
       
   400 //
       
   401 // @since 3.1
       
   402 // ============================================================================
       
   403 //
       
   404 EXPORT_C
       
   405 CWidgetPropertyValue* RWidgetRegistryClientSession::GetWidgetPropertyValueL(
       
   406     const TUid& aUid,
       
   407     TWidgetPropertyId aPropertyId)
       
   408     {
       
   409     const TInt maxSize = 2*KWidgetPropertyValSerializeMaxLength; // need 16 bit chars
       
   410     CBufFlat* buf = CBufFlat::NewL( maxSize );
       
   411     CleanupStack::PushL( buf );
       
   412     buf->ExpandL( 0, maxSize );
       
   413     TPtr8 p( buf->Ptr(0) );
       
   414     User::LeaveIfError(
       
   415 
       
   416         SendReceive( EOpCodeGetWidgetPropertyValue,
       
   417                      TIpcArgs( aUid.iUid, aPropertyId, &p ) )
       
   418         );
       
   419 
       
   420     // deserialize
       
   421     RDesReadStream stream( p );
       
   422     CleanupClosePushL( stream );
       
   423 
       
   424     CWidgetPropertyValue* value = CWidgetPropertyValue::NewL();
       
   425     CleanupStack::PushL( value );
       
   426 
       
   427     value->DeserializeL( stream );
       
   428 
       
   429     CleanupStack::Pop(); // value
       
   430     CleanupStack::PopAndDestroy( 2, buf ); // stream, buf
       
   431     return value;
       
   432     }
       
   433 
       
   434 // ============================================================================
       
   435 // RWidgetRegistryClientSession::InstalledWidgets()
       
   436 // Returns widget info for all the installed widgets.
       
   437 //
       
   438 // @since 3.1
       
   439 // ============================================================================
       
   440 //
       
   441 EXPORT_C TInt RWidgetRegistryClientSession::InstalledWidgetsL(
       
   442     RWidgetInfoArray& aWidgetInfoArr )
       
   443     {
       
   444     TInt status = KErrNone;
       
   445     // gets total size of all elements in the widgetinfo array in terms of
       
   446     // buffer length; negative value means one of the system-wide error
       
   447     TInt ret = SendReceive( EOpCodeInstalledWidgetsPhase1, TIpcArgs() );
       
   448     if ( ret > 0 )
       
   449         {
       
   450         CBufFlat* responseBuff = NULL;
       
   451         TPtr8 responsePtr( NULL, 0 );
       
   452         responseBuff = CBufFlat::NewL( ret );
       
   453         CleanupStack::PushL( responseBuff );
       
   454         responseBuff->ExpandL( 0, ret );
       
   455         responsePtr.Set( ( TUint8* ) responseBuff->Ptr( 0 ).Ptr(), ret, ret );
       
   456 
       
   457         iMesgArgs = TIpcArgs( &responsePtr );
       
   458         TInt count = SendReceive( EOpCodeInstalledWidgetsPhase2, iMesgArgs );
       
   459 
       
   460         if ( count > 0 )
       
   461             {
       
   462             RBufReadStream stream;
       
   463             // Unpack the response.
       
   464             stream.Open( *responseBuff, 0 );
       
   465             CleanupClosePushL( stream );
       
   466             // Read the widget info.
       
   467             DeserializeWidgetInfoL( stream, aWidgetInfoArr, count );
       
   468             CleanupStack::PopAndDestroy( &stream );
       
   469             }
       
   470 
       
   471         CleanupStack::PopAndDestroy( responseBuff );
       
   472         }
       
   473 
       
   474    return status;
       
   475    }
       
   476 
       
   477 // ============================================================================
       
   478 // RWidgetRegistryClientSession::RunningWidgets()
       
   479 // Returns widget info for all the running widgets.
       
   480 //
       
   481 // @since 3.1
       
   482 // ============================================================================
       
   483 //
       
   484 EXPORT_C TInt RWidgetRegistryClientSession::RunningWidgetsL(
       
   485     RWidgetInfoArray& widgetInfoArr )
       
   486     {
       
   487     TInt status = KErrNone;
       
   488     // gets total size of all elements in the widgetinfo array in terms of
       
   489     // buffer length; negative value means one of the system-wide error
       
   490     TInt ret = SendReceive( EOpCodeRunningWidgetsPhase1, TIpcArgs() );
       
   491 
       
   492     if ( ret > 0 )
       
   493         {
       
   494         CBufFlat* responseBuff = NULL;
       
   495         TPtr8 responsePtr( NULL, 0 );
       
   496         responseBuff = CBufFlat::NewL( ret );
       
   497         CleanupStack::PushL( responseBuff );
       
   498         responseBuff->ExpandL( 0, ret );
       
   499         responsePtr.Set( ( TUint8* ) responseBuff->Ptr( 0 ).Ptr(), ret, ret );
       
   500 
       
   501         iMesgArgs = TIpcArgs( &responsePtr );
       
   502         TInt count = SendReceive( EOpCodeRunningWidgetsPhase2, iMesgArgs );
       
   503 
       
   504         if ( count > 0 )
       
   505             {
       
   506             RBufReadStream stream;
       
   507             // Unpack the response.
       
   508             stream.Open( *responseBuff, 0 );
       
   509             CleanupClosePushL( stream );
       
   510             // Read the widget info.
       
   511             DeserializeWidgetInfoL( stream, widgetInfoArr, count );
       
   512             CleanupStack::PopAndDestroy( &stream );
       
   513             }
       
   514 
       
   515         CleanupStack::PopAndDestroy( responseBuff );
       
   516         }
       
   517 
       
   518     return status;
       
   519     }
       
   520 
       
   521 // ============================================================================
       
   522 // RWidgetRegistryClientSession::RegisterWidget()
       
   523 // Registers the widget
       
   524 //
       
   525 // @since 3.1
       
   526 // ============================================================================
       
   527 //
       
   528 EXPORT_C void RWidgetRegistryClientSession::RegisterWidgetL(
       
   529     const RPointerArray<CWidgetPropertyValue>&  aPropertyValues )
       
   530     {
       
   531     CBufFlat* buf = MarshalPropertyValuesL( aPropertyValues );
       
   532 
       
   533     CleanupStack::PushL( buf );
       
   534     TPtr8 p( buf->Ptr(0) );
       
   535     User::LeaveIfError(
       
   536 
       
   537         SendReceive( EOpCodeRegisterWidget, TIpcArgs( &p ) )
       
   538 
       
   539         );
       
   540     CleanupStack::PopAndDestroy( buf ); 
       
   541     }
       
   542 
       
   543 // ============================================================================
       
   544 // RWidgetRegistryClientSession::DeRegisterWidget()
       
   545 // Deregister the widget
       
   546 //
       
   547 // @since 3.1
       
   548 // ============================================================================
       
   549 //
       
   550 EXPORT_C void RWidgetRegistryClientSession::DeRegisterWidgetL(
       
   551     const TUid& aUid )
       
   552     {
       
   553     iMesgArgs = TIpcArgs( aUid.iUid );
       
   554 
       
   555     TInt error = SendReceive( EOpCodeDeRegisterWidget, iMesgArgs );
       
   556     User::LeaveIfError( error );
       
   557     }
       
   558 
       
   559 // ============================================================================
       
   560 // RWidgetRegistryClientSession::SetActive()
       
   561 // Set/Reset active status of the widget
       
   562 //
       
   563 // @since 3.1
       
   564 // ============================================================================
       
   565 //
       
   566 EXPORT_C void RWidgetRegistryClientSession::SetActive(
       
   567     const TUid& aUid, TInt aStatus )
       
   568     {
       
   569     iMesgArgs = TIpcArgs( aUid.iUid, aStatus );
       
   570 
       
   571     TInt error = SendReceive( EOpCodeSetActive, iMesgArgs );
       
   572     User::LeaveIfError( error );
       
   573     }
       
   574 // ============================================================================
       
   575 // RWidgetRegistryClientSession::SetMiniViewL()
       
   576 // Sets when widget is launched in miniview
       
   577 //
       
   578 // @since 5.0
       
   579 // ============================================================================
       
   580 //
       
   581 EXPORT_C void RWidgetRegistryClientSession::SetMiniViewL(
       
   582     const TUid& aUid, TInt aStatus )
       
   583     {
       
   584     iMesgArgs = TIpcArgs( aUid.iUid, aStatus );
       
   585     TInt error = SendReceive( EOpCodeSetWidgetInMiniView, iMesgArgs );
       
   586     User::LeaveIfError( error );
       
   587     }
       
   588 
       
   589 // ============================================================================
       
   590 // RWidgetRegistryClientSession::SetFullViewL()
       
   591 // Sets when widget is launched in fullview
       
   592 //
       
   593 // @since 5.0
       
   594 // ============================================================================
       
   595 //
       
   596 EXPORT_C void RWidgetRegistryClientSession::SetFullViewL(
       
   597     const TUid& aUid, TInt aStatus )
       
   598     {
       
   599     iMesgArgs = TIpcArgs( aUid.iUid, aStatus );
       
   600     TInt error = SendReceive( EOpCodeSetWidgetInFullView, iMesgArgs );
       
   601     User::LeaveIfError( error );
       
   602     }
       
   603 
       
   604 // ============================================================================
       
   605 // RWidgetRegistryClientSession::SetBlanketPermissionL()
       
   606 // Set/Reset blanket permission for widget
       
   607 //
       
   608 // @since 5.0
       
   609 // ============================================================================
       
   610 //
       
   611 EXPORT_C void RWidgetRegistryClientSession::SetBlanketPermissionL(
       
   612     const TUid& aUid, TInt aStatus )
       
   613     {
       
   614     iMesgArgs = TIpcArgs( aUid.iUid, aStatus );
       
   615     TInt error = SendReceive( EOpCodeSetWidgetPromptNeeded, iMesgArgs );
       
   616     User::LeaveIfError( error );
       
   617     }
       
   618 
       
   619 // ============================================================================
       
   620 // RWidgetRegistryClientSession::MarshalPropertyValuesL()
       
   621 // Creates and returns heap descriptor which holds contents of property values
       
   622 //
       
   623 // @since 3.1
       
   624 // ============================================================================
       
   625 //
       
   626 CBufFlat* RWidgetRegistryClientSession::MarshalPropertyValuesL(
       
   627     const RPointerArray<CWidgetPropertyValue>&  aPropertyValues ) const
       
   628     {
       
   629     CBufFlat* buf = CBufFlat::NewL( 512 );
       
   630     CleanupStack::PushL( buf );
       
   631 
       
   632     RBufWriteStream stream( *buf );
       
   633     CleanupClosePushL( stream );
       
   634 
       
   635     TInt i = 0;
       
   636     for ( ; i < EWidgetPropertyIdCount; ++i )
       
   637         {
       
   638         aPropertyValues[i]->SerializeL( stream );
       
   639         }
       
   640 
       
   641     CleanupStack::PopAndDestroy( &stream );
       
   642     CleanupStack::Pop( buf ); 
       
   643 
       
   644     return buf;
       
   645     }
       
   646 
       
   647 // ============================================================================
       
   648 // RWidgetRegistryClientSession::DeserializeWidgetInfoL()
       
   649 // Initializes widgetinfo array with the contents of aStream
       
   650 //
       
   651 // @since 3.1
       
   652 // ============================================================================
       
   653 //
       
   654 void RWidgetRegistryClientSession::DeserializeWidgetInfoL(
       
   655     RReadStream& aStream,
       
   656     RWidgetInfoArray& aWidgetInfoArr,
       
   657     TInt aCount )
       
   658     {
       
   659 
       
   660     for ( TInt i = 0; i < aCount; i++ )
       
   661         {
       
   662         CWidgetInfo* tempInfo = new ( ELeave ) CWidgetInfo();
       
   663         CleanupStack::PushL( tempInfo );
       
   664         tempInfo->iUid.iUid = aStream.ReadInt32L();
       
   665         tempInfo->iFileSize = aStream.ReadInt32L();
       
   666 
       
   667         TInt len = 0;
       
   668         TBuf<KWidgetRegistryVal> tempNameBuf;
       
   669         TBuf<KMaxDriveName+1> tempDriveBuf;
       
   670 
       
   671         len = aStream.ReadInt32L();
       
   672         aStream.ReadL( tempNameBuf, len );
       
   673         *(tempInfo->iBundleName) = tempNameBuf;
       
   674 
       
   675         len = aStream.ReadInt32L();
       
   676         aStream.ReadL( tempDriveBuf, len );
       
   677         *(tempInfo->iDriveName) = tempDriveBuf;
       
   678 
       
   679         aWidgetInfoArr.AppendL( tempInfo );
       
   680         CleanupStack::Pop( tempInfo );
       
   681         }
       
   682     }
       
   683 
       
   684 // ============================================================================
       
   685 // RWidgetRegistryClientSession::GetLprojName()
       
   686 // Get the language project name which is the directory to hold localized
       
   687 // resources
       
   688 //
       
   689 // @since 3.1
       
   690 // ============================================================================
       
   691 //
       
   692 EXPORT_C void RWidgetRegistryClientSession::GetLprojName( TDes& aLprojName )
       
   693     {
       
   694     iMesgArgs = TIpcArgs( &aLprojName, aLprojName.Length() );
       
   695     TInt len = SendReceive( EOpCodeGetLprojName, iMesgArgs );
       
   696 
       
   697     if ( len >= 0 )
       
   698         {
       
   699         aLprojName.SetLength( len );
       
   700         }
       
   701     }
       
   702 
       
   703 // ============================================================================
       
   704 // RWidgetRegistryClientSession::SecurityPolicyId()
       
   705 // Returns security policyId.
       
   706 //
       
   707 // @since 5.0
       
   708 // ============================================================================
       
   709 //
       
   710 EXPORT_C TInt RWidgetRegistryClientSession::SecurityPolicyId()
       
   711     {
       
   712     TInt ret = 0;
       
   713     iMesgArgs = TIpcArgs();
       
   714     ret = SendReceive( EOpCodeSecurityPolicyId, iMesgArgs );
       
   715     return ret;
       
   716     }
       
   717 
       
   718 // End of File