|
1 /* |
|
2 * Copyright (c) 2006-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: |
|
15 * Defines implementation of CUniObjectsModel class methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // ========== INCLUDE FILES ================================ |
|
22 #include "UniObjectsModel.h" |
|
23 |
|
24 #include <eikenv.h> |
|
25 #include <gulicon.h> |
|
26 #include <apgicnfl.h> // apamasked bitmaps |
|
27 #include <AknsUtils.h> |
|
28 #include <AknsConstants.h> |
|
29 #include <data_caging_path_literals.hrh> |
|
30 |
|
31 #include <uniutils.mbg> |
|
32 |
|
33 #include "UniUtils.h" |
|
34 #include "UniObjectsInfo.h" |
|
35 #include "UniObjectsModelObserver.h" |
|
36 |
|
37 // ========== EXTERNAL DATA STRUCTURES ===================== |
|
38 |
|
39 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
|
40 |
|
41 // ========== CONSTANTS ==================================== |
|
42 |
|
43 // ========== MACROS ======================================= |
|
44 |
|
45 // ========== LOCAL CONSTANTS AND MACROS =================== |
|
46 |
|
47 // ========== MODULE DATA STRUCTURES ======================= |
|
48 |
|
49 // ========== LOCAL FUNCTION PROTOTYPES ==================== |
|
50 |
|
51 // ========== LOCAL FUNCTIONS ============================== |
|
52 |
|
53 // ========== MEMBER FUNCTIONS ============================= |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CUniObjectsModel::NewL |
|
57 // |
|
58 // Factory method. |
|
59 // --------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CMsgAttachmentModel* CUniObjectsModel::NewL( TBool aReadOnly ) |
|
62 { |
|
63 CUniObjectsModel* self = new( ELeave ) CUniObjectsModel( aReadOnly ); |
|
64 |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // Destructor |
|
74 // --------------------------------------------------------- |
|
75 // |
|
76 CUniObjectsModel::~CUniObjectsModel() |
|
77 { |
|
78 delete iMmsSlideIcon; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CUniObjectsModel::AddObjectL |
|
83 // |
|
84 // Adds an object into the internal array. |
|
85 // --------------------------------------------------------- |
|
86 // |
|
87 CUniObjectsInfo* CUniObjectsModel::AddObjectL( |
|
88 CUniObject& aObject, |
|
89 TInt aDRMType, |
|
90 TBool aAttachmentObject, |
|
91 TInt aSlideNumber, |
|
92 TInt aIndex /*= KErrNotFound*/ ) |
|
93 { |
|
94 CUniObjectsInfo* info = CUniObjectsInfo::NewLC( *this, |
|
95 aObject, |
|
96 aDRMType, |
|
97 aAttachmentObject, |
|
98 aSlideNumber ); |
|
99 |
|
100 if ( aIndex == KErrNotFound ) |
|
101 { |
|
102 iAttachInfoArray->AppendL( info ); |
|
103 } |
|
104 else |
|
105 { |
|
106 iAttachInfoArray->InsertL( aIndex, info ); |
|
107 } |
|
108 |
|
109 iModified = ETrue; |
|
110 |
|
111 CleanupStack::Pop( info ); |
|
112 return info; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------- |
|
116 // CUniObjectsModel::AddEmptySlideL |
|
117 // |
|
118 // Adds an empty slide object into the internal array. |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 CUniObjectsInfo* CUniObjectsModel::AddEmptySlideL( |
|
122 const TDesC& aEmptySlideName, |
|
123 TInt aIndex /*= KErrNotFound*/ ) |
|
124 { |
|
125 CUniObjectsInfo* info = CUniObjectsInfo::NewEmptySlideLC( |
|
126 *this, |
|
127 aEmptySlideName ); |
|
128 |
|
129 if ( aIndex == KErrNotFound ) |
|
130 { |
|
131 iAttachInfoArray->AppendL( info ); |
|
132 } |
|
133 else |
|
134 { |
|
135 iAttachInfoArray->InsertL( aIndex, info ); |
|
136 } |
|
137 |
|
138 iModified = ETrue; |
|
139 |
|
140 CleanupStack::Pop( info ); |
|
141 return info; |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------- |
|
145 // CUniObjectsModel::DeleteObjectL |
|
146 // |
|
147 // Deletes attachment from internal array. Notifies attachment model |
|
148 // observer with EMsgAttachmentRemoved parameter. |
|
149 // --------------------------------------------------------- |
|
150 // |
|
151 void CUniObjectsModel::DeleteObjectL( TInt aIndex, |
|
152 TBool aNotifyObserver ) |
|
153 { |
|
154 if ( aIndex >= 0 && aIndex < iAttachInfoArray->Count() ) |
|
155 { |
|
156 CMsgAttachmentInfo* info = iAttachInfoArray->At( aIndex ); |
|
157 |
|
158 if ( iAttachmentModelObserver != NULL && aNotifyObserver ) |
|
159 { |
|
160 MUniObjectsModelObserver* obs = |
|
161 static_cast<MUniObjectsModelObserver*>( iAttachmentModelObserver ); |
|
162 |
|
163 obs->NotifyChangesL( MMsgAttachmentModelObserver::EMsgAttachmentRemoved, |
|
164 info ); |
|
165 } |
|
166 |
|
167 // delete the information block. |
|
168 delete info; |
|
169 |
|
170 // delete the array entry. |
|
171 iAttachInfoArray->Delete( aIndex ); |
|
172 |
|
173 iModified = ETrue; |
|
174 } |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CUniObjectsModel::CUniObjectsModel |
|
179 // |
|
180 // Constructor. |
|
181 // --------------------------------------------------------- |
|
182 // |
|
183 CUniObjectsModel::CUniObjectsModel( TBool aReadOnly ) : |
|
184 CMsgAttachmentModel( aReadOnly ) |
|
185 { |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------- |
|
189 // CUniObjectsModel::CreateNewInfoL |
|
190 // --------------------------------------------------------- |
|
191 // |
|
192 CMsgAttachmentInfo* CUniObjectsModel::CreateNewInfoL( |
|
193 const TDesC& /*aFileName*/, |
|
194 TInt /*aSize*/, |
|
195 TBool /*aFetched*/, |
|
196 TBool /*aAttachedThisSession*/, |
|
197 TMsvAttachmentId /*aAttachmentId*/, |
|
198 const TDataType& /*aDataType*/, |
|
199 CMsgAttachmentInfo::TDRMDataType /*aDRMDataType*/ ) |
|
200 { |
|
201 User::Leave( KErrNotSupported ); |
|
202 return NULL; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------- |
|
206 // CUniObjectsModel::ChangeOrderL |
|
207 // --------------------------------------------------------- |
|
208 // |
|
209 void CUniObjectsModel::ChangeOrderL( TInt aIndex, TInt aNewPosition ) |
|
210 { |
|
211 if ( aIndex >= 0 && aIndex < iAttachInfoArray->Count() ) |
|
212 { |
|
213 CMsgAttachmentInfo* info = iAttachInfoArray->At( aIndex ); |
|
214 |
|
215 // delete object from array and insert it to new position. |
|
216 iAttachInfoArray->Delete( aIndex ); |
|
217 iAttachInfoArray->InsertL( aNewPosition, info ); |
|
218 |
|
219 iModified = ETrue; |
|
220 } |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------- |
|
224 // CUniObjectsModel::NotifyChangeOrderL |
|
225 // --------------------------------------------------------- |
|
226 // |
|
227 void CUniObjectsModel::NotifyChangeOrderL ( TUniLayout aLayout ) |
|
228 { |
|
229 if ( iAttachmentModelObserver != NULL ) |
|
230 { |
|
231 MUniObjectsModelObserver* obs = |
|
232 static_cast<MUniObjectsModelObserver*>( iAttachmentModelObserver ); |
|
233 obs->NotifyOrderChangeL( aLayout ); |
|
234 } |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------- |
|
238 // CUniObjectsModel::BitmapForMmsSlideL |
|
239 // |
|
240 // Loads system default bitmap. |
|
241 // --------------------------------------------------------- |
|
242 // |
|
243 CGulIcon* CUniObjectsModel::BitmapForMmsSlideL() |
|
244 { |
|
245 if ( !iMmsSlideIcon ) |
|
246 { |
|
247 TParse fileParse; |
|
248 fileParse.Set( KUniUtilsMBMFileName, &KDC_APP_BITMAP_DIR, NULL ); |
|
249 iMmsSlideIcon = AknsUtils::CreateGulIconL( |
|
250 AknsUtils::SkinInstance(), |
|
251 KAknsIIDQgnPropMmsEmptyPageSub, |
|
252 fileParse.FullName(), |
|
253 EMbmUniutilsQgn_prop_mms_empty_page_sub, |
|
254 EMbmUniutilsQgn_prop_mms_empty_page_sub_mask ); |
|
255 } |
|
256 return iMmsSlideIcon; |
|
257 } |
|
258 |
|
259 // ========== OTHER EXPORTED FUNCTIONS ===================== |
|
260 |
|
261 // End of File |