photosgallery/photossuitelauncher/src/photossuitelauncher.cpp
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2009 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:   Main application class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 // Command Line and APA
       
    22 #include <apgtask.h>
       
    23 #include <apgcli.h>
       
    24 #include <apaid.h>
       
    25 #include <apacmdln.h>
       
    26 
       
    27 #include <glxlog.h>
       
    28 
       
    29 const TInt KPhotosSuiteUid ( 0x101f4cd2 );
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // LaunchMenuViewL
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 void LaunchMenuViewL( const TDesC8& aMessage )
       
    36 	{
       
    37 	GLX_LOG_INFO("PhotosSuiteLauncher LaunchMenuViewL");
       
    38 	RWsSession wssession;
       
    39 	User::LeaveIfError(wssession.Connect());
       
    40 	CleanupClosePushL(wssession);
       
    41 	
       
    42   TApaTaskList taskList( wssession );    
       
    43   TApaTask task = taskList.FindApp( TUid::Uid( KPhotosSuiteUid ) );
       
    44   
       
    45   if ( task.Exists() )
       
    46       {
       
    47       TInt err = task.SendMessage( TUid::Uid( KUidApaMessageSwitchOpenFileValue ), 
       
    48         					aMessage );
       
    49 	    }
       
    50 	else
       
    51 	    { // app not yet running
       
    52 	    RApaLsSession appArcSession;
       
    53 	    CleanupClosePushL( appArcSession );
       
    54 	    User::LeaveIfError( appArcSession.Connect() ); 	    
       
    55       TApaAppInfo appInfo;
       
    56       TInt err = appArcSession.GetAppInfo( appInfo, 
       
    57       								TUid::Uid( KPhotosSuiteUid ) );
       
    58       if( err == KErrNone )
       
    59           {
       
    60           CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
       
    61           cmdLine->SetExecutableNameL( appInfo.iFullName );
       
    62           cmdLine->SetCommandL( EApaCommandRun );
       
    63           cmdLine->SetTailEndL( aMessage );
       
    64 
       
    65           appArcSession.StartApp( *cmdLine );
       
    66           CleanupStack::PopAndDestroy( cmdLine );
       
    67           }
       
    68 	    CleanupStack::PopAndDestroy( &appArcSession ); 
       
    69 	    }
       
    70   CleanupStack::PopAndDestroy( &wssession ); 
       
    71 	}
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // DoItL
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 void DoItL()
       
    78     {
       
    79     GLX_LOG_INFO("PhotosSuiteLauncher DoItL");	
       
    80     LaunchMenuViewL(_L8("mm://photossuite?exit=hide"));
       
    81     }
       
    82 
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // E32Main
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 GLDEF_C TInt E32Main()
       
    89     {
       
    90     __UHEAP_MARK;
       
    91     CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
       
    92     TRAPD(error,DoItL()); // more initialization, then do example 
       
    93     if(error != KErrNone)   
       
    94 	    {
       
    95 	    GLX_LOG_INFO1("PhotosSuiteLauncher DoItL Error %d",error);	
       
    96 	    }
       
    97     delete cleanup; // destroy clean-up stack
       
    98     __UHEAP_MARKEND;
       
    99     return 0; // and return
       
   100     }
       
   101 
       
   102