63
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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:
|
|
15 |
* Provides implementation of interface to start Logs application
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#ifndef LOGSUICMDSTARTER_INL
|
|
20 |
#define LOGSUICMDSTARTER_INL
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <apgtask.h>
|
|
24 |
#include <apgcli.h>
|
|
25 |
|
|
26 |
// --------------------------------------------------------------------------
|
|
27 |
// LogsUiCmdStarter::CmdStart
|
|
28 |
// --------------------------------------------------------------------------
|
|
29 |
//
|
|
30 |
inline TInt LogsUiCmdStarter::CmdStart( const TPtrC8 aView )
|
|
31 |
{
|
|
32 |
TInt err( KErrNone );
|
|
33 |
TRAP(err, LogsUiCmdStarter::CmdStartL( aView ));
|
|
34 |
return err;
|
|
35 |
}
|
|
36 |
|
|
37 |
|
|
38 |
// --------------------------------------------------------------------------
|
|
39 |
// LogsUiCmdStarter::CmdStartL
|
|
40 |
// --------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
|
|
43 |
inline void LogsUiCmdStarter::CmdStartL( const TPtrC8 aView )
|
|
44 |
{
|
|
45 |
/***********************************************
|
|
46 |
FIXME: Replaced by code below. Remove this code when sure that new code
|
|
47 |
works better than this with the new ui effects implementation.
|
|
48 |
TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
|
|
49 |
TApaTask task = taskList.FindApp( LogsUiCmdStarterConsts::KLogsUID3 );
|
|
50 |
TPtrC8 msg;
|
|
51 |
msg.Set( aView );
|
|
52 |
|
|
53 |
if( task.Exists() ) //Logs already open. Request it to
|
|
54 |
{ //activate the correct view
|
|
55 |
const TUid dummyUID = { 0x0 };
|
|
56 |
task.SendMessage( dummyUID, msg );
|
|
57 |
task.BringToForeground();
|
|
58 |
}
|
|
59 |
else //Start Logs and request it to activate
|
|
60 |
{ //the correct view
|
|
61 |
TApaAppInfo appInfo;
|
|
62 |
RApaLsSession lsSession;
|
|
63 |
User::LeaveIfError( lsSession.Connect() );
|
|
64 |
CleanupClosePushL( lsSession );
|
|
65 |
|
|
66 |
if( lsSession.GetAppInfo( appInfo, LogsUiCmdStarterConsts::KLogsUID3 ) == KErrNone )
|
|
67 |
{
|
|
68 |
CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
|
|
69 |
cmdLine->SetExecutableNameL( appInfo.iFullName );
|
|
70 |
cmdLine->SetCommandL( EApaCommandRun );
|
|
71 |
cmdLine->SetTailEndL( msg );
|
|
72 |
|
|
73 |
lsSession.StartApp( *cmdLine );
|
|
74 |
CleanupStack::PopAndDestroy( cmdLine );
|
|
75 |
}
|
|
76 |
|
|
77 |
CleanupStack::PopAndDestroy(); // lsSession
|
|
78 |
}
|
|
79 |
***********************************************/
|
|
80 |
|
|
81 |
TPtrC8 msg;
|
|
82 |
msg.Set( aView );
|
|
83 |
|
|
84 |
// Check that Logs application exists
|
|
85 |
TApaAppInfo appInfo;
|
|
86 |
RApaLsSession lsSession;
|
|
87 |
User::LeaveIfError( lsSession.Connect() );
|
|
88 |
CleanupClosePushL( lsSession );
|
|
89 |
User::LeaveIfError( lsSession.GetAppInfo( appInfo, LogsUiCmdStarterConsts::KLogsUID3 ) );
|
|
90 |
|
|
91 |
// Create command line for starting Logs
|
|
92 |
CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
|
|
93 |
cmdLine->SetExecutableNameL( appInfo.iFullName );
|
|
94 |
cmdLine->SetCommandL( EApaCommandRun );
|
|
95 |
|
|
96 |
// Check if Logs is already running
|
|
97 |
TApaTaskList taskList( CCoeEnv::Static()->WsSession() );
|
|
98 |
TApaTask task = taskList.FindApp( LogsUiCmdStarterConsts::KLogsUID3 );
|
|
99 |
|
|
100 |
if( task.Exists() )
|
|
101 |
{
|
|
102 |
// Logs already running. Request it to activate the correct view
|
|
103 |
const TUid dummyUID = { 0x0 };
|
|
104 |
task.SendMessage( dummyUID, msg );
|
|
105 |
|
|
106 |
// The below is just to secure an unlikely case that StartApp() would in future anyhow
|
|
107 |
// send command line parameter to application that is already running (currently
|
|
108 |
// it doesn't). The "dontactivate" just prevents double attempt of activation of
|
|
109 |
// view requested in msg SendMessage'd to Logs.
|
|
110 |
_LIT8(dontActivate, "dontactivate");
|
|
111 |
TPtrC8 dontActivateMsg = dontActivate();
|
|
112 |
cmdLine->SetTailEndL( dontActivateMsg );
|
|
113 |
}
|
|
114 |
else
|
|
115 |
{
|
|
116 |
// Logs not yet running. Request it to activate the correct view
|
|
117 |
cmdLine->SetTailEndL( msg );
|
|
118 |
// Start Logs
|
|
119 |
lsSession.StartApp( *cmdLine );
|
|
120 |
}
|
|
121 |
|
|
122 |
CleanupStack::PopAndDestroy( cmdLine );
|
|
123 |
CleanupStack::PopAndDestroy(); //lsSession
|
|
124 |
}
|
|
125 |
|
|
126 |
#endif //LOGSUICMDSTARTER_INL
|