|
1 /* |
|
2 * Copyright (c) 2002 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 * Handling thumbnail save/retrieve operations and making these |
|
16 * operations synchronous |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef __CBCARDTHUMBNAILHANDLER_H__ |
|
22 #define __CBCARDTHUMBNAILHANDLER_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <MPbkThumbnailOperationObservers.h> |
|
27 |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class MPbkThumbnailOperation; |
|
31 class CPbkThumbnailManager; |
|
32 class CPbkContactEngine; |
|
33 class CPbkContactItem; |
|
34 class CFbsBitmap; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Class for handling thumbnail save/retrieve operations and making these |
|
40 * operations synchronous |
|
41 */ |
|
42 NONSHARABLE_CLASS(CBCardThumbnailHandler) : |
|
43 public CBase, |
|
44 private MPbkThumbnailGetObserver, |
|
45 private MPbkThumbnailSetObserver, |
|
46 private MPbkThumbnailGetImageObserver |
|
47 { |
|
48 public: // Constructors and destructor |
|
49 /** |
|
50 * Creates a new BCard thumbnail handler. |
|
51 * @param aEngine Contact engine |
|
52 */ |
|
53 static CBCardThumbnailHandler* NewL(CPbkContactEngine& aEngine); |
|
54 |
|
55 /** |
|
56 * Destructor. |
|
57 */ |
|
58 ~CBCardThumbnailHandler(); |
|
59 |
|
60 private: // Constructors |
|
61 CBCardThumbnailHandler(); |
|
62 void ConstructL(CPbkContactEngine& aEngine); |
|
63 |
|
64 public: // Interface |
|
65 /** |
|
66 * Saves the given 8bit descriptor to the given contact item |
|
67 * as thumbnail. |
|
68 * |
|
69 * @param aContactItem Contact item where the thubmbnail is stored |
|
70 * @param aSource Source thumbnail to store; a 8bit descriptor |
|
71 * containing the image. |
|
72 */ |
|
73 void SaveThumbnailL(CPbkContactItem& aContactItem, const TDesC8& aSource); |
|
74 |
|
75 /** |
|
76 * Gets the thumbnail from the contact. |
|
77 * |
|
78 * @param aContactItem Contact item where the thumbnail is fetched. |
|
79 * @return The thumbnail image of the contact as a |
|
80 * 8bit descriptor. |
|
81 */ |
|
82 const TDesC8& GetThumbnailL(CPbkContactItem& aContactItem); |
|
83 |
|
84 /** |
|
85 * Check if the given contact has an inserted thumbnail. |
|
86 * |
|
87 * @param aContactItem Contact item to check for thumbnail existence. |
|
88 */ |
|
89 TBool HasThumbnail(const CPbkContactItem& aContactItem) const; |
|
90 |
|
91 private: // From MPbkThumbnailGetImageObserver |
|
92 void PbkThumbnailGetImageComplete |
|
93 (MPbkThumbnailOperation& aOperation, CPbkImageDataWithInfo* aImageData); |
|
94 void PbkThumbnailGetImageFailed |
|
95 (MPbkThumbnailOperation& aOperation, TInt aError); |
|
96 |
|
97 private: // From MPbkThumbnailGetObserver |
|
98 void PbkThumbnailGetComplete( |
|
99 MPbkThumbnailOperation& aOperation, CFbsBitmap* aBitmap); |
|
100 void PbkThumbnailGetFailed |
|
101 (MPbkThumbnailOperation& aOperation, TInt aError); |
|
102 |
|
103 private: // From MPbkThumbnailSetObserver |
|
104 void PbkThumbnailSetComplete |
|
105 (MPbkThumbnailOperation& aOperation); |
|
106 void PbkThumbnailSetFailed |
|
107 (MPbkThumbnailOperation& aOperation, TInt aError); |
|
108 |
|
109 private: // Implementation |
|
110 TBool IsAlreadyExportableL(CPbkContactItem& aContactItem); |
|
111 HBufC8* GetThumbnailBitmapL(CPbkContactItem& aContactItem); |
|
112 void ProcessError(MPbkThumbnailOperation& aOperation, TInt aError); |
|
113 void ProcessComplete(MPbkThumbnailOperation& aOperation); |
|
114 |
|
115 private: // Data |
|
116 /// Own: phonebook thumbnail manager |
|
117 CPbkThumbnailManager* iManager; |
|
118 /// Own: asynchronous thumbnail operation |
|
119 MPbkThumbnailOperation* iThumbOperation; |
|
120 /// Own: image data |
|
121 CPbkImageDataWithInfo* iImageData; |
|
122 /// Own: the bitmap |
|
123 CFbsBitmap* iBitmap; |
|
124 /// Own: thumbnail bitmap jpeg descriptor |
|
125 HBufC8* iImageBlob; |
|
126 /// Own: active scheduler |
|
127 CActiveSchedulerWait iWait; |
|
128 /// Own: error code |
|
129 TInt iError; |
|
130 }; |
|
131 |
|
132 #endif // __CBCARDTHUMBNAILHANDLER_H__ |
|
133 |
|
134 // End of File |