37
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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: Implementation of CPhoneStateHandle class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <pevirtualengine.h>
|
|
21 |
|
|
22 |
#include "phoneui.pan"
|
|
23 |
#include "phoneconstants.h"
|
|
24 |
#include "cphonestatehandle.h"
|
|
25 |
#include "mphonestate.h"
|
|
26 |
#include "phonelogger.h"
|
|
27 |
#include "cphoneerrormessageshandler.h"
|
|
28 |
|
|
29 |
// Constant defines state singleton priority which must be lower
|
|
30 |
// than KUidNoteControllerSingleton priority(which is default 100)
|
|
31 |
// this ensures that NoteControl is destructed before iFactoryLibrary
|
|
32 |
// is closed.
|
|
33 |
const TInt SingletonDestructionPriority(99);
|
|
34 |
|
|
35 |
// ================= MEMBER FUNCTIONS =======================
|
|
36 |
|
|
37 |
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
// CPhoneStateHandle::CPhoneStateHandle
|
|
40 |
// C++ default constructor can NOT contain any code, that
|
|
41 |
// might leave.
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
CPhoneStateHandle::CPhoneStateHandle(
|
|
45 |
MPhoneViewCommandHandle* aViewCommandHandle) :
|
|
46 |
CCoeStatic( KUidStateHandleSingleton, SingletonDestructionPriority ),
|
|
47 |
iViewCommandHandle( aViewCommandHandle )
|
|
48 |
{
|
|
49 |
}
|
|
50 |
|
|
51 |
// Destructor
|
|
52 |
CPhoneStateHandle::~CPhoneStateHandle()
|
|
53 |
{
|
|
54 |
if ( iFactoryLibrary.Handle() )
|
|
55 |
{
|
|
56 |
delete iPhoneErrorMessagesHandler;
|
|
57 |
delete iPhoneResourceResolver;
|
|
58 |
delete iPhoneStateMachine;
|
|
59 |
delete iStateMachineFactory;
|
|
60 |
iFactoryLibrary.Close();
|
|
61 |
}
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------
|
|
65 |
// CPhoneStateHandle::CreateL
|
|
66 |
// (other items were commented in a header).
|
|
67 |
// ---------------------------------------------------------
|
|
68 |
//
|
|
69 |
CPhoneStateHandle* CPhoneStateHandle::CreateL(
|
|
70 |
MPhoneViewCommandHandle* aViewCommandHandle,
|
|
71 |
const TDesC& aFileName,
|
|
72 |
const TUid aFactoryUid )
|
|
73 |
{
|
|
74 |
CPhoneStateHandle* instance = static_cast<CPhoneStateHandle*>(
|
|
75 |
CCoeEnv::Static( KUidStateHandleSingleton ) );
|
|
76 |
if ( !instance )
|
|
77 |
{
|
|
78 |
instance = new( ELeave ) CPhoneStateHandle( aViewCommandHandle );
|
|
79 |
CleanupStack::PushL( instance );
|
|
80 |
instance->ConstructL( aFileName, aFactoryUid );
|
|
81 |
CleanupStack::Pop( instance );
|
|
82 |
}
|
|
83 |
return instance;
|
|
84 |
}
|
|
85 |
|
|
86 |
// ---------------------------------------------------------
|
|
87 |
// CPhoneStateHandle::InstanceL
|
|
88 |
// (other items were commented in a header).
|
|
89 |
// ---------------------------------------------------------
|
|
90 |
//
|
|
91 |
EXPORT_C CPhoneStateHandle* CPhoneStateHandle::Instance()
|
|
92 |
{
|
|
93 |
CPhoneStateHandle* instance = static_cast<CPhoneStateHandle*>(
|
|
94 |
CCoeEnv::Static( KUidStateHandleSingleton ) );
|
|
95 |
__ASSERT_DEBUG( instance, Panic( EPhoneCtrlSingletonNotInitialized ) );
|
|
96 |
return instance;
|
|
97 |
}
|
|
98 |
|
|
99 |
// ---------------------------------------------------------
|
|
100 |
// CPhoneStateHandle::StateMachine
|
|
101 |
// ---------------------------------------------------------
|
|
102 |
//
|
|
103 |
EXPORT_C MPhoneStateMachine* CPhoneStateHandle::StateMachine()
|
|
104 |
{
|
|
105 |
__ASSERT_DEBUG( Instance(), Panic( EPhoneCtrlSingletonNotInitialized ) );
|
|
106 |
return iPhoneStateMachine;
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------
|
|
110 |
// CPhoneStateHandle::ViewCommandHandle
|
|
111 |
// ---------------------------------------------------------
|
|
112 |
//
|
|
113 |
EXPORT_C MPhoneViewCommandHandle* CPhoneStateHandle::ViewCommandHandle()
|
|
114 |
{
|
|
115 |
return iViewCommandHandle;
|
|
116 |
}
|
|
117 |
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
// CPhoneStateHandle::ConstructL
|
|
120 |
// Symbian 2nd phase constructor can leave.
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void CPhoneStateHandle::ConstructL(
|
|
124 |
const TDesC& aFileName,
|
|
125 |
const TUid aFactoryUid )
|
|
126 |
{
|
|
127 |
TFileName fileName( KDriveZ );
|
|
128 |
fileName.Append( KDC_SHARED_LIB_DIR );
|
|
129 |
fileName.Append( aFileName );
|
|
130 |
LoadLibraryHandleL( fileName, aFactoryUid );
|
|
131 |
}
|
|
132 |
|
|
133 |
// ---------------------------------------------------------
|
|
134 |
// CPhoneStateHandle::LoadLibraryHandleL
|
|
135 |
// ---------------------------------------------------------
|
|
136 |
void CPhoneStateHandle::LoadLibraryHandleL(
|
|
137 |
const TDesC& aFileName,
|
|
138 |
const TUid aFactoryUid )
|
|
139 |
{
|
|
140 |
|
|
141 |
TBool factoryFound = EFalse;
|
|
142 |
TParse fullentry;
|
|
143 |
fullentry.Set( aFileName, NULL, NULL );
|
|
144 |
|
|
145 |
if ( iFactoryLibrary.Load( fullentry.Name(), fullentry.DriveAndPath() )
|
|
146 |
== KErrNone )
|
|
147 |
{
|
|
148 |
if ( iFactoryLibrary.Type()[1] == aFactoryUid )
|
|
149 |
{
|
|
150 |
factoryFound = ETrue;
|
|
151 |
}
|
|
152 |
else
|
|
153 |
{
|
|
154 |
iFactoryLibrary.Close();
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
// If Factory not found:
|
|
159 |
if ( !factoryFound )
|
|
160 |
{
|
|
161 |
Panic( EPhoneCtrlFactoryLibraryNotFound );
|
|
162 |
}
|
|
163 |
// Look for the 1st exported function
|
|
164 |
iEntry = iFactoryLibrary.Lookup( KPhoneUiStateMachineOrdinal );
|
|
165 |
|
|
166 |
// Create the state machine factory
|
|
167 |
iStateMachineFactory = (CPhoneUIStateMachineFactoryBase*) iEntry();
|
|
168 |
|
|
169 |
// Create the state machine
|
|
170 |
iPhoneStateMachine = iStateMachineFactory->CreatePhoneStateMachineL(
|
|
171 |
iViewCommandHandle );
|
|
172 |
|
|
173 |
// Create the phone resource resolver
|
|
174 |
iPhoneResourceResolver =
|
|
175 |
iStateMachineFactory->CreatePhoneResourceResolverL();
|
|
176 |
|
|
177 |
// Create the phone error messages handler
|
|
178 |
iPhoneErrorMessagesHandler =
|
|
179 |
iStateMachineFactory->CreatePhoneErrorMessagesHandlerL(
|
|
180 |
iViewCommandHandle, iPhoneStateMachine );
|
|
181 |
}
|
|
182 |
|
|
183 |
// End of File
|