5
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-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 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: This Class is observer for the Launching Application
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "launcherobserver.h"
|
|
19 |
#include "asynchrequestmanager.h"
|
|
20 |
#include "appobserver.h"
|
|
21 |
#include "appmanagercommon.h"
|
|
22 |
|
|
23 |
|
|
24 |
// -----------------------------------------------------------------------------
|
|
25 |
// launcherObserver::NewL
|
|
26 |
// Returns the instance of CLauncherObserver.
|
|
27 |
// -----------------------------------------------------------------------------
|
|
28 |
CLauncherObserver* CLauncherObserver::NewL( MAppObserver* aObserver ,TInt32& aTransactionID, CAsynchRequestManager* aAsynchRequestManager )
|
|
29 |
{
|
|
30 |
CLauncherObserver* self = new ( ELeave )CLauncherObserver( aObserver ,aTransactionID, aAsynchRequestManager );
|
|
31 |
return self;
|
|
32 |
}
|
|
33 |
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
// Destructor.
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
//
|
|
38 |
CLauncherObserver::~CLauncherObserver()
|
|
39 |
{
|
|
40 |
|
|
41 |
iAppThread.Close();
|
|
42 |
}
|
|
43 |
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
// Two-phased constructor.
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
CLauncherObserver::CLauncherObserver(MAppObserver* aObserver ,TInt32& aTransactionID, CAsynchRequestManager* aAsynchRequestManager ):
|
|
49 |
CActive( EPriorityStandard ),
|
|
50 |
iAppObserver ( aObserver ),
|
|
51 |
iTransactionID( aTransactionID ),
|
|
52 |
iAsynchRequestManager ( aAsynchRequestManager )
|
|
53 |
|
|
54 |
{
|
|
55 |
CActiveScheduler::Add( this );
|
|
56 |
}
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
// Activates the asynchronous request
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
void CLauncherObserver::ActivateRequestL( TThreadId& aThreadId )
|
|
66 |
{
|
|
67 |
|
|
68 |
User::LeaveIfError( iAppThread.Open( aThreadId ) );
|
|
69 |
iStatus = KRequestPending;
|
|
70 |
SetActive();
|
|
71 |
iAppThread.Logon( iStatus );
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
// sets the observer pointer
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
void CLauncherObserver::SetAppObserver ( MAppObserver* aAppObserver )
|
|
79 |
{
|
|
80 |
|
|
81 |
iAppObserver = aAppObserver;
|
|
82 |
}
|
|
83 |
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
// Notifies callback the result for asynchronous request.
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
void CLauncherObserver::NotifyRequestResultL( TInt aReason , TAppOperationEvent& aOperationEvent )
|
|
89 |
{
|
|
90 |
//Inform core class for completing the reuqest
|
|
91 |
iAsynchRequestManager->RequestComplete( iTransactionID );
|
|
92 |
|
|
93 |
if( iAppObserver )
|
|
94 |
{
|
|
95 |
iAppObserver->AppNotifyCallbackL( aReason , iTransactionID , aOperationEvent );
|
|
96 |
}
|
|
97 |
|
|
98 |
if( aOperationEvent != EAppCancel ) // If this is called because of cancel then skip the deletion
|
|
99 |
delete this;
|
|
100 |
|
|
101 |
}
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
// Inherited from CActive class
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CLauncherObserver::DoCancel()
|
|
107 |
{
|
|
108 |
iAppThread.LogonCancel( iStatus );
|
|
109 |
TAppOperationEvent appEvent = EAppCancel;
|
|
110 |
TRAP_IGNORE( NotifyRequestResultL( KErrCancel , appEvent ) );
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
// Inherited from CActive class
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
void CLauncherObserver::RunL()
|
|
118 |
{
|
|
119 |
TAppOperationEvent appEvent = EAppComplete;
|
|
120 |
NotifyRequestResultL( iStatus.Int(), appEvent );
|
|
121 |
}
|
|
122 |
|