|
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 * Provides methods for CPbkThumbnailManager implementation classes. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkThumbnailManagerImpl.h" |
|
22 #include "CPbkEmbeddedThumbnail.h" |
|
23 |
|
24 #include <CPbkContactItem.h> |
|
25 #include <TPbkContactItemField.h> |
|
26 #include <CPbkFieldsInfo.h> |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 MPbkThumbnailReader* PbkThumbnailOperationFactory::CreateReaderLC |
|
31 (const CPbkContactItem& aContact, |
|
32 MPbkThumbnailGetObserver& aObserver, |
|
33 TInt aFieldId /*= EPbkFieldIdThumbnailImage*/) |
|
34 { |
|
35 const TPbkContactItemField* field = aContact.FindField(aFieldId); |
|
36 MPbkThumbnailReader* reader = NULL; |
|
37 if (field) |
|
38 { |
|
39 switch (field->StorageType()) |
|
40 { |
|
41 case KStorageTypeStore: |
|
42 { |
|
43 reader = CPbkEmbeddedThumbnailReader::NewLC(*field,aObserver); |
|
44 break; |
|
45 } |
|
46 default: |
|
47 { |
|
48 // Unsupported storage type -> return NULL |
|
49 break; |
|
50 } |
|
51 } |
|
52 } |
|
53 return reader; |
|
54 } |
|
55 |
|
56 MPbkThumbnailReader* PbkThumbnailOperationFactory::CreateImageReaderLC |
|
57 (const CPbkContactItem& aContact, |
|
58 MPbkThumbnailGetImageObserver& aObserver, |
|
59 TInt aFieldId /*= EPbkFieldIdThumbnailImage*/) |
|
60 { |
|
61 const TPbkContactItemField* field = aContact.FindField(aFieldId); |
|
62 MPbkThumbnailReader* reader = NULL; |
|
63 if (field) |
|
64 { |
|
65 switch (field->StorageType()) |
|
66 { |
|
67 case KStorageTypeStore: |
|
68 { |
|
69 reader = CPbkEmbeddedThumbnailImageReader::NewLC(*field,aObserver); |
|
70 break; |
|
71 } |
|
72 default: |
|
73 { |
|
74 // Unsupported storage type -> return NULL |
|
75 break; |
|
76 } |
|
77 } |
|
78 } |
|
79 return reader; |
|
80 } |
|
81 |
|
82 MPbkThumbnailWriter* PbkThumbnailOperationFactory::CreateWriterLC |
|
83 (CPbkContactItem& aContact, |
|
84 const CPbkFieldsInfo& aFieldsInfo, |
|
85 MPbkThumbnailSetObserver& aObserver, |
|
86 TInt aFieldId /*= EPbkFieldIdThumbnailImage*/) |
|
87 { |
|
88 MPbkThumbnailWriter* writer = NULL; |
|
89 |
|
90 TPbkContactItemField* field = aContact.FindField(aFieldId); |
|
91 if (field && !SupportedStorageType(field->StorageType())) |
|
92 { |
|
93 // Existing field's storage type is not supported -> remove field |
|
94 aContact.RemoveField(aContact.FindFieldIndex(*field)); |
|
95 field = NULL; |
|
96 } |
|
97 |
|
98 if (!field) |
|
99 { |
|
100 // No thumbnail field -> create one |
|
101 CPbkFieldInfo* fieldInfo = aFieldsInfo.Find(aFieldId); |
|
102 if (!SupportedStorageType(fieldInfo->FieldStorageType())) |
|
103 { |
|
104 // Global field type's storage type is not supported -> abort |
|
105 User::Leave(KErrNotSupported); |
|
106 } |
|
107 field = &aContact.AddFieldL(*fieldInfo); |
|
108 } |
|
109 |
|
110 switch (field->StorageType()) |
|
111 { |
|
112 case KStorageTypeStore: |
|
113 { |
|
114 writer = CPbkEmbeddedThumbnailWriter::NewLC(*field, aObserver); |
|
115 break; |
|
116 } |
|
117 default: |
|
118 { |
|
119 // Field's storage type is not supported |
|
120 User::Leave(KErrNotSupported); |
|
121 break; |
|
122 } |
|
123 } |
|
124 return writer; |
|
125 } |
|
126 |
|
127 TBool PbkThumbnailOperationFactory::SupportedStorageType |
|
128 (TStorageType aStorageType) |
|
129 { |
|
130 return KStorageTypeStore==aStorageType ? ETrue: EFalse; |
|
131 } |
|
132 |
|
133 // End of File |