gssettingsuis/Gs/gslauncher/src/GSLauncher.cpp
branchRCL_3
changeset 54 7e0eff37aedb
parent 0 8c5d936e5675
child 18 e3554c9069b6
equal deleted inserted replaced
53:8ee96d21d9bf 54:7e0eff37aedb
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Launches GS views.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "GSLauncher.h"
       
    19 
       
    20 #include <e32property.h>
       
    21 #include <w32std.h>
       
    22 #include <apgcli.h>
       
    23 #include <viewcli.h>
       
    24 #ifdef  SYMBIAN_ENABLE_SPLIT_HEADERS
       
    25 #include <viewclipartner.h>
       
    26 #endif
       
    27 
       
    28 #include <gsfwviewuids.h>
       
    29 #include <s32mem.h>
       
    30 
       
    31 
       
    32 const TUid KGSMessageViewLaunch = { 0x1 };
       
    33 const TInt KGSApaMsgLength = 1024;
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 // ---------------------------------------------------------------------------
       
    37 // description_if_needed
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 CGSLauncher::CGSLauncher()
       
    41 	{
       
    42 	}
       
    43 
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // description_if_needed
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 void CGSLauncher::ConstructL()
       
    50 	{
       
    51 	//code
       
    52 	}
       
    53 	
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // description_if_needed
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C CGSLauncher* CGSLauncher::NewL()
       
    60   {
       
    61   CGSLauncher* self = CGSLauncher::NewLC();
       
    62   CleanupStack::Pop( self );
       
    63   return self;
       
    64   }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // description_if_needed
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 EXPORT_C CGSLauncher* CGSLauncher::NewLC()
       
    71   {
       
    72   CGSLauncher* self = new( ELeave ) CGSLauncher;
       
    73   CleanupStack::PushL( self );
       
    74   self->ConstructL();
       
    75   return self;
       
    76   }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // description_if_needed
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 CGSLauncher::~CGSLauncher()
       
    84     {
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // implementation_description
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void CGSLauncher::LaunchGSViewL( const TUid aTarget, 
       
    92                                           const TUid aCustomMessageId,
       
    93                                           const TDesC8& aCustomMessage )
       
    94     {
       
    95 	RProperty		prop;
       
    96 	RWsSession 		ws;
       
    97 	User::LeaveIfError(ws.Connect());
       
    98 	CleanupClosePushL( ws );
       
    99 	
       
   100 	TApaTaskList 	l(ws);
       
   101 	TApaTask 		gs = l.FindApp(KUidGS);
       
   102 	
       
   103 	// GS not running, launch via avkon
       
   104 	if ( !gs.Exists() )
       
   105 		{
       
   106 		CVwsSessionWrapper* wsw = CVwsSessionWrapper::NewLC();
       
   107 		const TVwsViewId viewId( KUidGS, aTarget );
       
   108 		wsw->CreateActivateViewEvent( viewId,aCustomMessageId, aCustomMessage );
       
   109 		CleanupStack::PopAndDestroy( wsw );
       
   110 		}
       
   111 	else
       
   112 		{
       
   113 		// GS running, send parameters in string
       
   114         // Pachage custom message
       
   115 		CBufFlat* buffer = CBufFlat::NewL( KGSApaMsgLength ); // etc
       
   116 		CleanupStack::PushL( buffer );
       
   117 		RBufWriteStream stream( *buffer );
       
   118 		stream << aTarget;
       
   119 		// In case none plugin needs custom message currently, set it to NULL.
       
   120 		stream << aCustomMessageId;
       
   121 		stream << aCustomMessage;
       
   122 //		stream << TUid::Uid(0);
       
   123 //		stream << KNullDesC8;
       
   124 		stream.CommitL();
       
   125 		stream.Close();
       
   126 		TPtr8 pBuffer( buffer->Ptr( 0 ) );
       
   127 
       
   128         gs.SendMessage( KGSMessageViewLaunch, pBuffer );
       
   129 		CleanupStack::PopAndDestroy( buffer );
       
   130 		gs.BringToForeground();
       
   131 		}		
       
   132 	CleanupStack::PopAndDestroy( &ws );
       
   133     }
       
   134 
       
   135