|
1 /* |
|
2 * Copyright (c) 2002-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 "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: A virtual phonebook operation class that reads a contact |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CContactRetriever.h" |
|
22 |
|
23 #include <MVPbkSingleContactOperationObserver.h> |
|
24 #include "CContact.h" |
|
25 #include "CContactStore.h" |
|
26 |
|
27 namespace VPbkSimStore { |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CContactRetriever::CContactRetriever |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CContactRetriever::CContactRetriever( TInt aSimIndex, |
|
38 CContactStore& aStore, MVPbkSingleContactOperationObserver& aObserver ) |
|
39 : CActive( EPriorityStandard ), |
|
40 iSimIndex ( aSimIndex ), |
|
41 iStore( aStore ), |
|
42 iObserver( aObserver ) |
|
43 { |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CContactRetriever::ConstructL |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CContactRetriever::ConstructL() |
|
52 { |
|
53 CActiveScheduler::Add( this ); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CContactRetriever::NewL |
|
58 // Two-phased constructor. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CContactRetriever* CContactRetriever::NewL( CContactStore& aStore, |
|
62 TInt aSimIndex, MVPbkSingleContactOperationObserver& aObserver ) |
|
63 { |
|
64 CContactRetriever* self = |
|
65 new( ELeave ) CContactRetriever( aSimIndex, aStore, aObserver ); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop( self ); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CContactRetriever::~CContactRetriever |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CContactRetriever::~CContactRetriever() |
|
77 { |
|
78 Cancel(); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CContactRetriever::RunL |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CContactRetriever::RunL() |
|
86 { |
|
87 CContact* contact = iStore.ReadContactL( iSimIndex ); |
|
88 iObserver.VPbkSingleContactOperationComplete( *this, contact ); |
|
89 // Observer took ownership of the contact |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CContactRetriever::DoCancel |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CContactRetriever::DoCancel() |
|
97 { |
|
98 // Nothing to cancel |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CContactRetriever::RunError |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 TInt CContactRetriever::RunError( TInt aError ) |
|
106 { |
|
107 iObserver.VPbkSingleContactOperationFailed( *this, aError ); |
|
108 return KErrNone; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CContactRetriever::StartL |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CContactRetriever::StartL() |
|
116 { |
|
117 TRequestStatus* st = &iStatus; |
|
118 User::RequestComplete( st, KErrNone ); |
|
119 SetActive(); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CContactRetriever::Cancel |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CContactRetriever::Cancel() |
|
127 { |
|
128 CActive::Cancel(); |
|
129 } |
|
130 |
|
131 } // namespace VPbkSimStore |
|
132 |
|
133 // End of File |