|
1 /* |
|
2 * Copyright (c) 2010 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 helper object to open messagin entries (e.g. emails). |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 #include "MsvUI.h" |
|
21 |
|
22 #include <mtclbase.h> |
|
23 #include <mtclreg.h> |
|
24 #include <mtmuibas.h> |
|
25 #include <mtuireg.h> |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS ============================= |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CMsvUI::CMsvUI |
|
32 // C++ constructor can NOT contain any code, that might leave. |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CMsvUI::CMsvUI() |
|
36 : CActive( EPriorityStandard ) |
|
37 { |
|
38 } |
|
39 |
|
40 // Destructor. |
|
41 CMsvUI::~CMsvUI() |
|
42 { |
|
43 Cancel(); |
|
44 if ( iOperation ) |
|
45 { |
|
46 iOperation->Cancel(); |
|
47 } |
|
48 delete iOperation; |
|
49 iOperation = NULL; |
|
50 delete iUI; |
|
51 iUI = NULL; |
|
52 delete iMtm; |
|
53 iMtm = NULL; |
|
54 delete iUIReg; |
|
55 iUIReg = NULL; |
|
56 delete iMtmReg; |
|
57 iMtmReg = NULL; |
|
58 delete iSession; |
|
59 iSession = NULL; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CMsvUI::OpenEntryL |
|
64 // From MMsvUI. Opens the messaging entry. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CMsvUI::OpenEntryL( const TUid& aMsvId ) |
|
68 { |
|
69 if ( iOperation ) |
|
70 { |
|
71 User::Leave( KErrInUse ); |
|
72 } |
|
73 |
|
74 if ( ! iSession ) |
|
75 { |
|
76 iSession = CMsvSession::OpenSyncL( *this ); |
|
77 } |
|
78 |
|
79 if ( ! iMtmReg ) |
|
80 { |
|
81 iMtmReg = CClientMtmRegistry::NewL( *iSession ); |
|
82 } |
|
83 |
|
84 if ( ! iUIReg ) |
|
85 { |
|
86 iUIReg = CMtmUiRegistry::NewL( *iSession ); |
|
87 } |
|
88 |
|
89 TMsvId entryId( aMsvId.iUid ) ; |
|
90 TMsvEntry entry; |
|
91 User::LeaveIfError( iSession->GetEntry( entryId, entryId, entry ) ); |
|
92 // entryId now contains the service ID of the entry (not used currently) |
|
93 |
|
94 if ( ! iMtm || iMtm->Type() != entry.iMtm ) |
|
95 { |
|
96 // MTM changed. UI will most probably change, too. |
|
97 delete iUI; |
|
98 iUI = NULL; |
|
99 delete iMtm; |
|
100 iMtm = NULL; |
|
101 iMtm = iMtmReg->NewMtmL( entry.iMtm ); |
|
102 } |
|
103 |
|
104 if ( ! iUI ) |
|
105 { |
|
106 iUI = iUIReg->NewMtmUiL( *iMtm ); |
|
107 } |
|
108 |
|
109 iMtm->SwitchCurrentEntryL( entry.Id() ); |
|
110 iOperation = iUI->OpenL( iStatus ); |
|
111 |
|
112 if ( iOperation && iOperation->IsActive() ) |
|
113 { |
|
114 if ( ! IsAdded() ) |
|
115 { |
|
116 CActiveScheduler::Add(this); |
|
117 } |
|
118 SetActive(); |
|
119 } |
|
120 else |
|
121 { |
|
122 Deque(); |
|
123 delete iOperation; |
|
124 iOperation = NULL; |
|
125 } |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CMsvUI::RunL |
|
130 // From CActive. Handles an active object's request completion event. |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CMsvUI::RunL() |
|
134 { |
|
135 Deque(); |
|
136 delete iOperation; |
|
137 iOperation = NULL; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CMsvUI::DoCancel |
|
142 // From CActive. Implements cancellation of an outstanding request. |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 void CMsvUI::DoCancel() |
|
146 { |
|
147 if ( iOperation ) |
|
148 { |
|
149 iOperation->Cancel(); |
|
150 } |
|
151 delete iOperation; |
|
152 iOperation = NULL; |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // CIDSGenericResultItem::HandleSessionEventL |
|
157 // From MMsvSessionObserver. Indicates an event has occurred. |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void CMsvUI::HandleSessionEventL( TMsvSessionEvent aEvent, |
|
161 TAny* /* aArg1 */, |
|
162 TAny* /* aArg2 */, |
|
163 TAny* /* aArg3 */ ) |
|
164 { |
|
165 switch ( aEvent ) |
|
166 { |
|
167 case EMsvCloseSession: |
|
168 case EMsvServerTerminated: |
|
169 { |
|
170 Deque(); |
|
171 delete iOperation; |
|
172 iOperation = NULL; |
|
173 delete iUI; |
|
174 iUI = NULL; |
|
175 delete iMtm; |
|
176 iMtm = NULL; |
|
177 delete iUIReg; |
|
178 iUIReg = NULL; |
|
179 delete iMtmReg; |
|
180 iMtmReg = NULL; |
|
181 delete iSession; |
|
182 iSession = NULL; |
|
183 break; |
|
184 } |
|
185 default: |
|
186 break; |
|
187 } |
|
188 } |
|
189 |
|
190 // End of File |