|
1 /* |
|
2 * Copyright (c) 2010 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: MDS to CPIX Image Document fetcher |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cpixmediaimagedoc.h" |
|
20 #include <mdeobject.h> |
|
21 #include <mdccommon.h> |
|
22 #include <mdeitem.h> |
|
23 #include <mdeconstants.h> |
|
24 #include <mdeobjectdef.h> |
|
25 #include "harvesterserverlogger.h" |
|
26 |
|
27 _LIT( KFormatDateTime, "%04d-%02d-%02dT%02d:%02d:%02dZ"); // yyyy-mm-ddThh:mm:ssZ |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CCPIXDocFetcher::NewL() |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CCPIXMediaImageDoc* CCPIXMediaImageDoc::NewL() |
|
34 { |
|
35 CCPIXMediaImageDoc* self = CCPIXMediaImageDoc::NewLC(); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CCPIXDocFetcher::NewLC() |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CCPIXMediaImageDoc* CCPIXMediaImageDoc::NewLC() |
|
45 { |
|
46 CCPIXMediaImageDoc* self = new (ELeave) CCPIXMediaImageDoc(); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CCPIXDocFetcher::~CCPIXMediaImageDoc() |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CCPIXMediaImageDoc::~CCPIXMediaImageDoc() |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CCPIXDocFetcher::CCPIXMediaImageDoc() |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CCPIXMediaImageDoc::CCPIXMediaImageDoc() |
|
66 { |
|
67 |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CCPIXDocFetcher::ConstructL() |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void CCPIXMediaImageDoc::ConstructL() |
|
75 { |
|
76 CCPIXDocFetcher::ConstructL();//Must have |
|
77 |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CCPIXDocFetcher::GetCpixDocumentL() |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 CSearchDocument* CCPIXMediaImageDoc::GetCpixDocumentL(const CMdEObject& aObject, |
|
85 const TDesC& aAppClass, |
|
86 CMdEObjectDef& aObjectDef) |
|
87 { |
|
88 //Get basic document |
|
89 CPIXLOGSTRING("START CCPIXMediaImageDoc::GetCpixDocumentL"); |
|
90 CSearchDocument* index_item = CCPIXDocFetcher::GetCpixDocumentL(aObject,aAppClass,aObjectDef); |
|
91 //URI and Excerpt is done add additional properties here |
|
92 CMdEProperty* property(NULL); |
|
93 //Get user comment field |
|
94 CMdEPropertyDef& commentPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCommentProperty ); |
|
95 if(aObject.Property( commentPropDef, property )!= KErrNotFound) |
|
96 { |
|
97 //Add field to document |
|
98 CMdETextProperty* textProperty = ( CMdETextProperty* ) property; |
|
99 AddFiledtoDocumentL(*index_item, |
|
100 MdeConstants::MediaObject::KCommentProperty, |
|
101 textProperty->Value()); |
|
102 } |
|
103 CMdEPropertyDef& dateTimePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Image::KDateTimeOriginalProperty); |
|
104 if(aObject.Property( dateTimePropDef, property ) != KErrNotFound) |
|
105 { |
|
106 //Add field to document |
|
107 if(EPropertyTime == property->Def().PropertyType()) |
|
108 { |
|
109 CMdETimeProperty& timeProperty = static_cast < CMdETimeProperty& > (*property); |
|
110 TDateTime time = timeProperty.Value().DateTime(); |
|
111 TBuf<32> buf; |
|
112 buf.Format( KFormatDateTime, time.Year(), |
|
113 time.Month() + 1, |
|
114 time.Day() + 1, |
|
115 time.Hour(), |
|
116 time.Minute(), |
|
117 time.Second() ); |
|
118 AddFiledtoDocumentL(*index_item, |
|
119 MdeConstants::Image::KDateTimeOriginalProperty, |
|
120 buf, |
|
121 CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized); |
|
122 } |
|
123 } |
|
124 //Latitude error currently |
|
125 /* TODO- Bhuvi Location is a seperate object for each image object if any such relation |
|
126 * exist it has to be searched from Relation table and from there we have to open |
|
127 * location object and query Longitude and Latitudes |
|
128 */ |
|
129 /* |
|
130 CMdEPropertyDef& latitudePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Location::KLatitudeProperty); |
|
131 if(aObject.Property( latitudePropDef, property ) != KErrNotFound) |
|
132 { |
|
133 TBuf<32> buf; |
|
134 TRealFormat format(32,16); //Real format |
|
135 format.iTriLen = 0; |
|
136 //Add field to document |
|
137 if(EPropertyReal32 == property->Def().PropertyType()) |
|
138 { |
|
139 CMdEReal32Property& real32Property = (CMdEReal32Property&) property; |
|
140 buf.Num( real32Property.Value(), format ); |
|
141 } |
|
142 else |
|
143 if(EPropertyReal64 == property->Def().PropertyType()) |
|
144 { |
|
145 CMdEReal64Property& real64Property = (CMdEReal64Property&) property; |
|
146 buf.Num( real64Property.Value(), format ); |
|
147 } |
|
148 AddFiledtoDocumentL(*index_item, |
|
149 MdeConstants::Location::KLatitudeProperty, |
|
150 buf, |
|
151 CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized); |
|
152 } |
|
153 //Longitude |
|
154 CMdEPropertyDef& longitudePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Location::KLongitudeProperty); |
|
155 if(aObject.Property( longitudePropDef, property ) != KErrNotFound) |
|
156 { |
|
157 TBuf<32> buf; |
|
158 TRealFormat format(32,16); //Real format |
|
159 format.iTriLen = 0; |
|
160 //Add field to document |
|
161 if(EPropertyReal32 == property->Def().PropertyType()) |
|
162 { |
|
163 CMdEReal32Property& real32Property = (CMdEReal32Property&) property; |
|
164 buf.Num( real32Property.Value(), format ); |
|
165 } |
|
166 else |
|
167 if(EPropertyReal64 == property->Def().PropertyType()) |
|
168 { |
|
169 CMdEReal64Property& real64Property = (CMdEReal64Property&) property; |
|
170 buf.Num( real64Property.Value(), format ); |
|
171 } |
|
172 AddFiledtoDocumentL(*index_item, |
|
173 MdeConstants::Location::KLongitudeProperty, |
|
174 buf, |
|
175 CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized); |
|
176 } |
|
177 */ |
|
178 CPIXLOGSTRING("END CCPIXMediaImageDoc::GetCpixDocumentL"); |
|
179 return index_item; |
|
180 } |
|
181 //End of life |