|
1 /* |
|
2 * Copyright (c) 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: MBUtils ECOM implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 //INCLUDE FILES |
|
19 #include "cmrmbutilsextensionimpl.h" |
|
20 #include "cmrmbutilsmailboxlistener.h" |
|
21 #include "cmrmbutilssettings.h" |
|
22 #include "CFSMailClient.h" |
|
23 |
|
24 #include "emailtrace.h" |
|
25 |
|
26 #include <ct/rcpointerarray.h> |
|
27 #include <cmrmailboxutils.h> |
|
28 |
|
29 // ---------------------------------------------------------------------------- |
|
30 // CMRMbUtilsExtensionImpl::CMRMbUtilsExtensionImpl |
|
31 // |
|
32 // Constructor. |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 CMRMbUtilsExtensionImpl::CMRMbUtilsExtensionImpl( |
|
36 MMRMailboxUtilsObserver& aObserver ) |
|
37 : iMRMailboxObserver( aObserver ) |
|
38 { |
|
39 // No implementation |
|
40 } |
|
41 |
|
42 // ---------------------------------------------------------------------------- |
|
43 // CMRMbUtilsExtensionImpl::~CMRMbUtilsExtensionImpl |
|
44 // |
|
45 // Destructor. |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 CMRMbUtilsExtensionImpl::~CMRMbUtilsExtensionImpl() |
|
49 { |
|
50 FUNC_LOG; |
|
51 |
|
52 iMailboxes.ResetAndDestroy(); |
|
53 |
|
54 if ( iMailClient ) |
|
55 { |
|
56 iMailClient->RemoveObserver( *iMailboxListener ); |
|
57 iMailClient->Close(); |
|
58 } |
|
59 |
|
60 delete iSettings; |
|
61 delete iMailboxListener; |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // CMRMbUtilsExtensionImpl::NewL |
|
66 // ---------------------------------------------------------------------------- |
|
67 // |
|
68 CMRMbUtilsExtensionImpl* CMRMbUtilsExtensionImpl::NewL( |
|
69 TAny* aMRMailboxObserver ) |
|
70 { |
|
71 FUNC_LOG; |
|
72 |
|
73 MMRMailboxUtilsObserver* mrMailboxObserver = |
|
74 static_cast<MMRMailboxUtilsObserver*>( aMRMailboxObserver ); |
|
75 |
|
76 CMRMbUtilsExtensionImpl* self = |
|
77 new (ELeave) CMRMbUtilsExtensionImpl( *mrMailboxObserver ); |
|
78 CleanupStack::PushL( self ); |
|
79 self->ConstructL(); |
|
80 CleanupStack::Pop( self ); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // CMRMbUtilsExtensionImpl::ConstructL |
|
86 // ---------------------------------------------------------------------------- |
|
87 // |
|
88 void CMRMbUtilsExtensionImpl::ConstructL() |
|
89 { |
|
90 FUNC_LOG; |
|
91 |
|
92 iMailClient = CFSMailClient::NewL(); |
|
93 |
|
94 iMailboxListener = |
|
95 CMRMBUtilsMailboxListener::NewL( |
|
96 iMailboxes, |
|
97 *iMailClient, |
|
98 iMRMailboxObserver ); |
|
99 |
|
100 iSettings = CMRMBUtilsSettings::NewL( *iMailClient ); |
|
101 |
|
102 iMailClient->AddObserverL( *iMailboxListener ); |
|
103 } |
|
104 |
|
105 // ---------------------------------------------------------------------------- |
|
106 // CMRMbUtilsExtensionImpl::SettingsMgr |
|
107 // ---------------------------------------------------------------------------- |
|
108 // |
|
109 MMRMBUtilsSettings* CMRMbUtilsExtensionImpl::SettingsMgr() |
|
110 { |
|
111 return iSettings; |
|
112 } |
|
113 |
|
114 // ---------------------------------------------------------------------------- |
|
115 // CMRMbUtilsExtensionImpl::MRMailBoxes |
|
116 // ---------------------------------------------------------------------------- |
|
117 // |
|
118 const RPointerArray<CMRMailBoxInfo>& |
|
119 CMRMbUtilsExtensionImpl::MRMailBoxes() const |
|
120 { |
|
121 FUNC_LOG; |
|
122 |
|
123 return iMailboxes; |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // CMRMbUtilsExtensionImpl::NewL |
|
128 // ---------------------------------------------------------------------------- |
|
129 // |
|
130 const CMRMailBoxInfo* CMRMbUtilsExtensionImpl::MRMailBoxInfoL( |
|
131 TInt aEntryId ) const |
|
132 { |
|
133 FUNC_LOG; |
|
134 |
|
135 const CMRMailBoxInfo* KInfo = NULL; |
|
136 |
|
137 TInt mailboxCount( iMailboxes.Count() ); |
|
138 for ( TInt i(0); i < mailboxCount && !KInfo; ++i ) |
|
139 { |
|
140 if ( aEntryId == iMailboxes[i]->EntryId() ) |
|
141 { |
|
142 KInfo = iMailboxes[i]; |
|
143 } |
|
144 } |
|
145 return KInfo; |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CMRMbUtilsExtensionImpl::ListMRMailBoxesL |
|
150 // ---------------------------------------------------------------------------- |
|
151 // |
|
152 void CMRMbUtilsExtensionImpl::ListMRMailBoxesL( |
|
153 RArray<CMRMailboxUtils::TMailboxInfo>& aMailBoxes ) |
|
154 { |
|
155 FUNC_LOG; |
|
156 |
|
157 TInt mailboxCount( iMailboxes.Count() ); |
|
158 for ( TInt i(0); i < mailboxCount; ++i ) |
|
159 { |
|
160 CMRMailboxUtils::TMailboxInfo info; |
|
161 info.iName.Set( iMailboxes[i]->Name() ); |
|
162 info.iEmailAddress.Set( iMailboxes[i]->Address() ); |
|
163 info.iMtmUid = iMailboxes[i]->MtmUid(); |
|
164 info.iEntryId = iMailboxes[i]->EntryId(); |
|
165 |
|
166 aMailBoxes.Append( info ); |
|
167 } |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------------------------- |
|
171 // CMRMbUtilsExtensionImpl::ExtensionL |
|
172 // ---------------------------------------------------------------------------- |
|
173 // |
|
174 TAny* CMRMbUtilsExtensionImpl::ExtensionL( TUid /*aExtensionUid*/ ) |
|
175 { |
|
176 return NULL; |
|
177 } |
|
178 |
|
179 // EOF |