homescreensrv_plat/sapi_actionhandler/actionhandlerplugins/src/ahhelplauncher.cpp
changeset 73 4bc7b118b3df
parent 66 32469d7d46ff
child 80 397d00875918
child 81 5ef31a21fdd5
equal deleted inserted replaced
66:32469d7d46ff 73:4bc7b118b3df
     1 /*
       
     2 * Copyright (c) 2007 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:  App for Action handler
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include <eikenv.h>
       
    20 #include <hlplch.h> // help launcher
       
    21 #include <liwvariant.h>
       
    22 
       
    23 #include "ahproperties.hrh"
       
    24 #include "ahhelplauncher.h"
       
    25 
       
    26 // ----------------------------------------------------------------------------
       
    27 // Symbian 2nd phase constructor can leave.
       
    28 // ----------------------------------------------------------------------------
       
    29 //
       
    30 void CAHHelpLauncher::ConstructL()
       
    31     {
       
    32     }
       
    33 
       
    34 // ----------------------------------------------------------------------------
       
    35 // Two-phased constructor.
       
    36 // ----------------------------------------------------------------------------
       
    37 //
       
    38 CAHHelpLauncher* CAHHelpLauncher::NewL()
       
    39     {
       
    40     CAHHelpLauncher* self = CAHHelpLauncher::NewLC( );
       
    41     CleanupStack::Pop( self );
       
    42     return self;
       
    43     }
       
    44 
       
    45 // ----------------------------------------------------------------------------
       
    46 // Two-phased constructor.
       
    47 // ----------------------------------------------------------------------------
       
    48 //
       
    49 CAHHelpLauncher* CAHHelpLauncher::NewLC()
       
    50     {
       
    51     CAHHelpLauncher* self = new( ELeave ) CAHHelpLauncher;
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL( );
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // destructor
       
    59 // ---------------------------------------------------------------------------
       
    60 CAHHelpLauncher::~CAHHelpLauncher()
       
    61     {
       
    62 
       
    63     }
       
    64 
       
    65 TInt CAHHelpLauncher::ExecuteActionL( const CLiwMap* aMap )
       
    66     {
       
    67     TInt errCode(KErrArgument);
       
    68     TUid appUid= TUid::Null( );
       
    69     
       
    70     RBuf helpString;
       
    71     CleanupClosePushL( helpString );
       
    72     
       
    73     if ( !ExtractUidL( aMap, appUid, KHelpUid ) 
       
    74         && !ExtractDesL( aMap, helpString, KHelpTopic ) )
       
    75         {
       
    76         CArrayFixFlat<TCoeHelpContext>* array = 
       
    77             new (ELeave) CArrayFixFlat<TCoeHelpContext>(1);
       
    78         CleanupStack::PushL( array );
       
    79         array->AppendL( TCoeHelpContext( appUid, helpString ) );
       
    80         CleanupStack::Pop( array );
       
    81         HlpLauncher::LaunchHelpApplicationL( CCoeEnv::Static()->WsSession( ), array );
       
    82         errCode = KErrNone;
       
    83         }
       
    84     CleanupStack::PopAndDestroy( &helpString );    
       
    85         
       
    86     return errCode;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // 
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 TInt CAHHelpLauncher::ExtractDesL( const CLiwMap* aMap,
       
    94     RBuf& aString, const TDesC8& aMapName )
       
    95     {
       
    96     TInt errCode(KErrNotFound);
       
    97     TLiwVariant variant;
       
    98     variant.PushL( );
       
    99     TPtrC tempString( KNullDesC );
       
   100     if ( aMap->FindL( aMapName, variant ) )
       
   101         {
       
   102         variant.Get( tempString );
       
   103         aString.ReAllocL( tempString.Length( ) );
       
   104         aString.Append( tempString );
       
   105         errCode = KErrNone;
       
   106         }
       
   107     CleanupStack::PopAndDestroy( &variant );    
       
   108     return errCode;
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // 
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 TInt CAHHelpLauncher::ExtractUidL( const CLiwMap* aMap, TUid& aUid,
       
   116     const TDesC8& aMapName )
       
   117     {
       
   118     TInt errCode(KErrNotFound);
       
   119     TInt32 temp( 0);
       
   120     TLiwVariant variant;
       
   121     variant.PushL( );
       
   122     if ( aMap->FindL( aMapName, variant ) )
       
   123         {
       
   124         variant.Get( temp );
       
   125         aUid = TUid::Uid( temp );
       
   126         errCode = KErrNone;
       
   127         }
       
   128     CleanupStack::PopAndDestroy( &variant );
       
   129     return errCode;
       
   130     }
       
   131 // End of file