|
1 /* |
|
2 * Copyright (c) 2009-2009 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: Implementation of MyCard image loader |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "ccappmycardimageloader.h" |
|
19 #include "ccappmycardcommon.h" |
|
20 |
|
21 // phonebook |
|
22 #include <CVPbkContactManager.h> |
|
23 #include <MVPbkStoreContact.h> |
|
24 #include <MVPbkFieldType.h> |
|
25 |
|
26 #include <CPbk2ImageManager.h> |
|
27 #include <TPbk2ImageManagerParams.h> |
|
28 #include <VPbkEng.rsg> |
|
29 #include <MVPbkContactFieldBinaryData.h> |
|
30 #include <MVPbkContactFieldTextData.h> |
|
31 |
|
32 // System |
|
33 #include <fbs.h> |
|
34 #include <eikenv.h> |
|
35 |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CCCAppMyCardImageLoader::NewL |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CCCAppMyCardImageLoader* CCCAppMyCardImageLoader::NewL( |
|
42 MMyCardImageLoaderObserver& aObserver ) |
|
43 { |
|
44 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardImageLoader::NewL()")); |
|
45 |
|
46 CCCAppMyCardImageLoader* self = |
|
47 new ( ELeave ) CCCAppMyCardImageLoader( aObserver ); |
|
48 |
|
49 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardImageLoader::NewL()")); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CCCAppMyCardImageLoader::~CCCAppMyCardImageLoader |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CCCAppMyCardImageLoader::~CCCAppMyCardImageLoader() |
|
58 { |
|
59 CCA_DP(KMyCardLogFile, |
|
60 CCA_L("->CCCAppMyCardImageLoader::~CCCAppMyCardImageLoader()")); |
|
61 |
|
62 delete iImageDecoding; |
|
63 delete iImageBuffer; |
|
64 delete iImageFileName; |
|
65 |
|
66 CCA_DP(KMyCardLogFile, |
|
67 CCA_L("<-CCCAppMyCardImageLoader::~CCCAppMyCardImageLoader()")); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CCCAppMyCardImageLoader::CCCAppMyCardImageLoader |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 inline CCCAppMyCardImageLoader::CCCAppMyCardImageLoader( |
|
75 MMyCardImageLoaderObserver& aObserver ) : |
|
76 iObserver( aObserver ) |
|
77 { |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CCCAppMyCardImageLoader::LoadContactImageL |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CCCAppMyCardImageLoader::LoadContactImageL( |
|
85 MVPbkStoreContact& aContact, |
|
86 const TSize& aThumbnailSize ) |
|
87 { |
|
88 CCA_DP(KMyCardLogFile, |
|
89 CCA_L("->CCCAppMyCardImageLoader::LoadContactImageL()")); |
|
90 |
|
91 MVPbkStoreContactFieldCollection& fields = aContact.Fields(); |
|
92 |
|
93 delete iImageBuffer; |
|
94 iImageBuffer = NULL; |
|
95 delete iImageFileName; |
|
96 iImageFileName = NULL; |
|
97 delete iImageDecoding; |
|
98 iImageDecoding = NULL; |
|
99 |
|
100 const TInt fieldCount = fields.FieldCount(); |
|
101 |
|
102 // Check all the fields and store first and last name |
|
103 for ( TInt i = 0; i < fieldCount; ++i ) |
|
104 { |
|
105 MVPbkStoreContactField& field = fields.FieldAt( i ); |
|
106 const MVPbkFieldType* fieldType = field.BestMatchingFieldType(); |
|
107 |
|
108 if ( fieldType ) |
|
109 { |
|
110 if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_THUMBNAILPIC ) |
|
111 { |
|
112 MVPbkContactFieldData& contactField = field.FieldData(); |
|
113 iImageBuffer = |
|
114 MVPbkContactFieldBinaryData::Cast(contactField).BinaryData().AllocL(); |
|
115 } |
|
116 |
|
117 if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_CALLEROBJIMG ) |
|
118 { |
|
119 MVPbkContactFieldData& contactField = field.FieldData(); |
|
120 iImageFileName = MVPbkContactFieldTextData::Cast(contactField).Text().AllocL(); |
|
121 } |
|
122 } |
|
123 } |
|
124 |
|
125 if( iImageBuffer ) |
|
126 { |
|
127 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
128 iImageDecoding = CCCAppImageDecoding::NewL( |
|
129 *this, |
|
130 fs, |
|
131 iImageBuffer, |
|
132 iImageFileName ); |
|
133 iImageFileName = NULL; // ownership is moved to CCCAppImageDecoding |
|
134 iImageBuffer = NULL; // ownership is moved to CCCAppImageDecoding |
|
135 iImageDecoding->StartL( aThumbnailSize ); |
|
136 } |
|
137 else |
|
138 { |
|
139 iObserver.ThumbnailLoadError( KErrNotFound ); |
|
140 } |
|
141 |
|
142 CCA_DP(KMyCardLogFile, |
|
143 CCA_L("<-CCCAppMyCardImageLoader::LoadContactImageL()")); |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // CCCAppMyCardImageLoader::LoadImageL |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CCCAppMyCardImageLoader::LoadImageL( |
|
151 const TDesC8& aImageData, |
|
152 const TDesC& aImageFileName, |
|
153 const TSize& aThumbnailSize ) |
|
154 { |
|
155 CCA_DP(KMyCardLogFile, |
|
156 CCA_L("->CCCAppMyCardImageLoader::LoadImageL()")); |
|
157 |
|
158 delete iImageDecoding; |
|
159 iImageDecoding = NULL; |
|
160 |
|
161 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
162 iImageDecoding = CCCAppImageDecoding::NewL( |
|
163 *this, |
|
164 fs, |
|
165 aImageData.AllocLC(), |
|
166 aImageFileName.AllocLC() ); |
|
167 CleanupStack::Pop( 2 ); // imagedata, imagefilename |
|
168 iImageDecoding->StartL( aThumbnailSize ); |
|
169 |
|
170 CCA_DP(KMyCardLogFile, |
|
171 CCA_L("<-CCCAppMyCardImageLoader::LoadImageL()")); |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CCCAppMyCardImageLoader::ResizeImageL |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CCCAppMyCardImageLoader::ResizeImageL( const TSize& aThumbnailSize ) |
|
179 { |
|
180 if( iImageDecoding ) |
|
181 { |
|
182 iImageDecoding->StartL( aThumbnailSize ); |
|
183 } |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // CCCAppMyCardImageLoader::BitmapReadyL |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void CCCAppMyCardImageLoader::BitmapReadyL( CFbsBitmap* aBitmap ) |
|
191 { |
|
192 iObserver.ThumbnailReady( aBitmap ); |
|
193 } |
|
194 |
|
195 |
|
196 // End of File |