20
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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: Phonebook 2 server app assign create empty
|
|
15 |
* : property phase.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
#include "CPbk2SelectCreateEmptyPropertyPhase.h"
|
|
21 |
|
|
22 |
// Phonebook 2
|
|
23 |
#include "MPbk2ServicePhaseObserver.h"
|
|
24 |
#include <MPbk2ApplicationServices.h>
|
|
25 |
#include "CPbk2ServerAppAppUi.h"
|
|
26 |
#include "Pbk2ServerApp.hrh"
|
|
27 |
|
|
28 |
// Virtual Phonebook
|
|
29 |
#include <MVPbkStoreContact.h>
|
|
30 |
#include <CVPbkContactManager.h>
|
|
31 |
#include <MVPbkContactStore.h>
|
|
32 |
#include <MVPbkContactStoreList.h>
|
|
33 |
|
|
34 |
// System includes
|
|
35 |
#include <eikon.hrh>
|
|
36 |
|
|
37 |
|
|
38 |
// --------------------------------------------------------------------------
|
|
39 |
// CPbk2SelectCreateEmptyPropertyPhase::CPbk2SelectCreateEmptyPropertyPhase
|
|
40 |
// --------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CPbk2SelectCreateEmptyPropertyPhase::CPbk2SelectCreateEmptyPropertyPhase(
|
|
43 |
MPbk2ServicePhaseObserver& aObserver,
|
|
44 |
TVPbkContactStoreUriPtr aSavingStoreUri,
|
|
45 |
MPbk2SelectFieldProperty*& aSelectFieldProperty, TInt& aResult,
|
|
46 |
TUint& aNoteFlags ) :
|
|
47 |
CActive( EPriorityIdle ),
|
|
48 |
iObserver( aObserver ),
|
|
49 |
iSavingStoreUri( aSavingStoreUri ),
|
|
50 |
iSelectFieldProperty( aSelectFieldProperty ),
|
|
51 |
iResult( aResult ),
|
|
52 |
iNoteFlags( aNoteFlags )
|
|
53 |
{
|
|
54 |
CActiveScheduler::Add( this );
|
|
55 |
}
|
|
56 |
|
|
57 |
// --------------------------------------------------------------------------
|
|
58 |
// CPbk2SelectCreateEmptyPropertyPhase::~CPbk2SelectCreateEmptyPropertyPhase
|
|
59 |
// --------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CPbk2SelectCreateEmptyPropertyPhase::~CPbk2SelectCreateEmptyPropertyPhase()
|
|
62 |
{
|
|
63 |
Cancel();
|
|
64 |
|
|
65 |
delete iStoreContact;
|
|
66 |
}
|
|
67 |
|
|
68 |
// --------------------------------------------------------------------------
|
|
69 |
// CPbk2SelectCreateEmptyPropertyPhase::NewL
|
|
70 |
// --------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CPbk2SelectCreateEmptyPropertyPhase* CPbk2SelectCreateEmptyPropertyPhase::NewL
|
|
73 |
( MPbk2ServicePhaseObserver& aObserver,
|
|
74 |
TVPbkContactStoreUriPtr aSavingStoreUri,
|
|
75 |
MPbk2SelectFieldProperty*& aSelectFieldProperty,
|
|
76 |
TInt& aResult, TUint& aNoteFlags )
|
|
77 |
{
|
|
78 |
CPbk2SelectCreateEmptyPropertyPhase* self =
|
|
79 |
new ( ELeave ) CPbk2SelectCreateEmptyPropertyPhase
|
|
80 |
( aObserver, aSavingStoreUri, aSelectFieldProperty,
|
|
81 |
aResult, aNoteFlags );
|
|
82 |
return self;
|
|
83 |
}
|
|
84 |
|
|
85 |
// --------------------------------------------------------------------------
|
|
86 |
// CPbk2SelectCreateEmptyPropertyPhase::LaunchServicePhaseL
|
|
87 |
// --------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
void CPbk2SelectCreateEmptyPropertyPhase::LaunchServicePhaseL()
|
|
90 |
{
|
|
91 |
IssueRequest();
|
|
92 |
}
|
|
93 |
|
|
94 |
// --------------------------------------------------------------------------
|
|
95 |
// CPbk2SelectCreateEmptyPropertyPhase::CancelServicePhase
|
|
96 |
// --------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
void CPbk2SelectCreateEmptyPropertyPhase::CancelServicePhase()
|
|
99 |
{
|
|
100 |
iObserver.PhaseCanceled( *this );
|
|
101 |
}
|
|
102 |
|
|
103 |
// --------------------------------------------------------------------------
|
|
104 |
// CPbk2SelectCreateEmptyPropertyPhase::RequestCancelL
|
|
105 |
// --------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
void CPbk2SelectCreateEmptyPropertyPhase::RequestCancelL( TInt aExitCommandId )
|
|
108 |
{
|
|
109 |
if ( aExitCommandId == EEikBidCancel )
|
|
110 |
{
|
|
111 |
iObserver.PhaseAborted( *this );
|
|
112 |
}
|
|
113 |
else
|
|
114 |
{
|
|
115 |
iObserver.PhaseCanceled( *this );
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
// --------------------------------------------------------------------------
|
|
120 |
// CPbk2SelectCreateEmptyPropertyPhase::AcceptDelayed
|
|
121 |
// --------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void CPbk2SelectCreateEmptyPropertyPhase::AcceptDelayedL
|
|
124 |
( const TDesC8& /*aContactLinkBuffer*/ )
|
|
125 |
{
|
|
126 |
// Nothing to do
|
|
127 |
}
|
|
128 |
|
|
129 |
// --------------------------------------------------------------------------
|
|
130 |
// CPbk2SelectCreateEmptyPropertyPhase::DenyDelayed
|
|
131 |
// --------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
void CPbk2SelectCreateEmptyPropertyPhase::DenyDelayedL
|
|
134 |
( const TDesC8& /*aContactLinkBuffer*/ )
|
|
135 |
{
|
|
136 |
// Nothing to do
|
|
137 |
}
|
|
138 |
|
|
139 |
// --------------------------------------------------------------------------
|
|
140 |
// CPbk2SelectCreateEmptyPropertyPhase::Results
|
|
141 |
// --------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
MVPbkContactLinkArray* CPbk2SelectCreateEmptyPropertyPhase::Results() const
|
|
144 |
{
|
|
145 |
// No contact link results
|
|
146 |
return NULL;
|
|
147 |
}
|
|
148 |
|
|
149 |
// --------------------------------------------------------------------------
|
|
150 |
// CPbk2SelectCreateEmptyPropertyPhase::ExtraResultData
|
|
151 |
// --------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
TInt CPbk2SelectCreateEmptyPropertyPhase::ExtraResultData() const
|
|
154 |
{
|
|
155 |
return KErrNotSupported;
|
|
156 |
}
|
|
157 |
|
|
158 |
// --------------------------------------------------------------------------
|
|
159 |
// CPbk2SelectCreateEmptyPropertyPhase::TakeStoreContact
|
|
160 |
// --------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
MVPbkStoreContact* CPbk2SelectCreateEmptyPropertyPhase::TakeStoreContact()
|
|
163 |
{
|
|
164 |
MVPbkStoreContact* contact = iStoreContact;
|
|
165 |
iStoreContact = NULL;
|
|
166 |
return contact;
|
|
167 |
}
|
|
168 |
|
|
169 |
// --------------------------------------------------------------------------
|
|
170 |
// CPbk2SelectCreateEmptyPropertyPhase::FieldContent
|
|
171 |
// --------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
HBufC* CPbk2SelectCreateEmptyPropertyPhase::FieldContent() const
|
|
174 |
{
|
|
175 |
return NULL;
|
|
176 |
}
|
|
177 |
|
|
178 |
// --------------------------------------------------------------------------
|
|
179 |
// CPbk2SelectCreateEmptyPropertyPhase::RunL
|
|
180 |
// --------------------------------------------------------------------------
|
|
181 |
//
|
|
182 |
void CPbk2SelectCreateEmptyPropertyPhase::RunL()
|
|
183 |
{
|
|
184 |
CreateNewContactL();
|
|
185 |
|
|
186 |
iResult = KErrNotFound;
|
|
187 |
iSelectFieldProperty = NULL;
|
|
188 |
iObserver.NextPhase( *this );
|
|
189 |
}
|
|
190 |
|
|
191 |
// --------------------------------------------------------------------------
|
|
192 |
// CPbk2SelectCreateEmptyPropertyPhase::RunError
|
|
193 |
// --------------------------------------------------------------------------
|
|
194 |
//
|
|
195 |
TInt CPbk2SelectCreateEmptyPropertyPhase::RunError( TInt aError )
|
|
196 |
{
|
|
197 |
iObserver.PhaseError( *this, aError );
|
|
198 |
return KErrNone;
|
|
199 |
}
|
|
200 |
|
|
201 |
// --------------------------------------------------------------------------
|
|
202 |
// CPbk2SelectCreateEmptyPropertyPhase::DoCancel
|
|
203 |
// --------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
void CPbk2SelectCreateEmptyPropertyPhase::DoCancel()
|
|
206 |
{
|
|
207 |
// Nothing to do
|
|
208 |
}
|
|
209 |
|
|
210 |
// --------------------------------------------------------------------------
|
|
211 |
// CPbk2SelectCreateEmptyPropertyPhase::IssueRequest
|
|
212 |
// --------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CPbk2SelectCreateEmptyPropertyPhase::IssueRequest()
|
|
215 |
{
|
|
216 |
TRequestStatus* status = &iStatus;
|
|
217 |
User::RequestComplete( status, KErrNone );
|
|
218 |
SetActive();
|
|
219 |
}
|
|
220 |
|
|
221 |
// --------------------------------------------------------------------------
|
|
222 |
// CPbk2SelectCreateEmptyPropertyPhase::CreateNewContactL
|
|
223 |
// --------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
void CPbk2SelectCreateEmptyPropertyPhase::CreateNewContactL()
|
|
226 |
{
|
|
227 |
CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&>
|
|
228 |
( *CEikonEnv::Static()->EikAppUi() );
|
|
229 |
|
|
230 |
MVPbkContactStore* targetStore = appUi.ApplicationServices().
|
|
231 |
ContactManager().ContactStoresL().Find( iSavingStoreUri );
|
|
232 |
|
|
233 |
iNoteFlags |= KPbk2NoteFlagOneContactCreated;
|
|
234 |
iStoreContact = targetStore->CreateNewContactLC();
|
|
235 |
CleanupStack::Pop(); // targetStore->CreateNewContactLC()
|
|
236 |
}
|
|
237 |
|
|
238 |
// End of File
|