70 /** |
76 /** |
71 GetObjectInfo request handler |
77 GetObjectInfo request handler |
72 */ |
78 */ |
73 void CMTPPictBridgeDpGetObjectInfo::ServiceL() |
79 void CMTPPictBridgeDpGetObjectInfo::ServiceL() |
74 { |
80 { |
75 __FLOG(_L8(">> CMTPPictBridgeDpGetObjectInfo::ServiceL")); |
81 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPGETOBJECTINFO_SERVICEL_ENTRY ); |
76 BuildObjectInfoL(); |
82 BuildObjectInfoL(); |
77 SendDataL(*iObjectInfoToBuildP); |
83 SendDataL(*iObjectInfoToBuildP); |
78 __FLOG(_L8("<< CMTPPictBridgeDpGetObjectInfo::ServiceL")); |
84 OstTraceFunctionExit0( CMTPPICTBRIDGEDPGETOBJECTINFO_SERVICEL_EXIT ); |
79 } |
85 } |
80 |
86 |
81 /** |
87 /** |
82 Second-phase construction |
88 Second-phase construction |
83 */ |
89 */ |
84 void CMTPPictBridgeDpGetObjectInfo::ConstructL() |
90 void CMTPPictBridgeDpGetObjectInfo::ConstructL() |
85 { |
91 { |
86 __FLOG_OPEN(KMTPSubsystem, KComponent); |
92 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPGETOBJECTINFO_CONSTRUCTL_ENTRY ); |
87 iObjectInfoToBuildP = CMTPTypeObjectInfo::NewL(); |
93 iObjectInfoToBuildP = CMTPTypeObjectInfo::NewL(); |
|
94 OstTraceFunctionExit0( CMTPPICTBRIDGEDPGETOBJECTINFO_CONSTRUCTL_EXIT ); |
88 } |
95 } |
89 |
96 |
90 /** |
97 /** |
91 Populate the object info dataset |
98 Populate the object info dataset |
92 */ |
99 */ |
93 void CMTPPictBridgeDpGetObjectInfo::BuildObjectInfoL() |
100 void CMTPPictBridgeDpGetObjectInfo::BuildObjectInfoL() |
94 { |
101 { |
95 __FLOG(_L8(">> CMTPPictBridgeDpGetObjectInfo::BuildObjectInfoL")); |
102 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPGETOBJECTINFO_BUILDOBJECTINFOL_ENTRY ); |
96 __ASSERT_DEBUG(iRequestChecker, Panic(EMTPPictBridgeDpRequestCheckNull)); |
103 __ASSERT_DEBUG(iRequestChecker, Panic(EMTPPictBridgeDpRequestCheckNull)); |
97 |
104 |
98 TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
105 TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
99 |
106 |
100 __FLOG_VA((_L8(" object handle 0x%x"), objectHandle)); |
107 OstTrace1( TRACE_NORMAL, CMTPPICTBRIDGEDPGETOBJECTINFO_BUILDOBJECTINFOL, "object handle 0x%x", objectHandle ); |
101 |
108 |
102 //1. storage id |
109 //1. storage id |
103 TUint32 storageId(iFramework.StorageMgr().DefaultStorageId()); // we always use default storage for DPS |
110 TUint32 storageId(iFramework.StorageMgr().DefaultStorageId()); // we always use default storage for DPS |
104 |
111 |
105 iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EStorageID, storageId); |
112 iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EStorageID, storageId); |
106 |
113 |
107 //2. object format |
114 //2. object format |
108 TUint16 format(EMTPFormatCodeScript); // we only handle DPS script |
115 TUint16 format(EMTPFormatCodeScript); // we only handle DPS script |
109 iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, format); |
116 iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, format); |
110 __FLOG_VA((_L8(" format ok 0x%x"), format)); |
117 OstTrace1( TRACE_NORMAL, DUP1_CMTPPICTBRIDGEDPGETOBJECTINFO_BUILDOBJECTINFOL, "format ok 0x%x", format ); |
111 |
118 |
112 //3. protection status, |
119 //3. protection status, |
113 TUint16 protection(EMTPProtectionNoProtection); // we do not care about protection |
120 TUint16 protection(EMTPProtectionNoProtection); // we do not care about protection |
114 |
121 |
115 iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EProtectionStatus, protection); |
122 iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EProtectionStatus, protection); |
116 __FLOG_VA((_L8(" protection(%d) ok"), protection)); |
123 OstTrace1( TRACE_NORMAL, DUP2_CMTPPICTBRIDGEDPGETOBJECTINFO_BUILDOBJECTINFOL, " protection(%d) ok", protection ); |
117 |
124 |
118 //4. object compressed size |
125 //4. object compressed size |
119 // see SetFileSizeDateL |
126 // see SetFileSizeDateL |
120 |
127 |
121 //5. thumb format |
128 //5. thumb format |
137 CleanupStack::PushL(objectP); |
144 CleanupStack::PushL(objectP); |
138 |
145 |
139 iFramework.ObjectMgr().ObjectL(objectHandle, *objectP); |
146 iFramework.ObjectMgr().ObjectL(objectHandle, *objectP); |
140 |
147 |
141 //12. Parent object |
148 //12. Parent object |
142 TUint32 parent(objectP->Uint(CMTPObjectMetaData::EParentHandle)); |
149 TUint32 parent(objectP->Uint(CMTPObjectMetaData::EParentHandle)); |
|
150 // refer to 5.3.1.9 of MTP Spec 1.0 |
|
151 if (parent == KMTPHandleNoParent) |
|
152 { |
|
153 parent = 0; |
|
154 } |
143 iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EParentObject, parent); |
155 iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EParentObject, parent); |
144 |
156 |
145 //13 and 14. Association type and description |
157 //13 and 14. Association type and description |
146 TUint16 associationType(EMTPAssociationTypeUndefined); |
158 TUint16 associationType(EMTPAssociationTypeUndefined); |
147 iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EAssociationType, associationType); |
159 iObjectInfoToBuildP->SetUint16L(CMTPTypeObjectInfo::EAssociationType, associationType); |
151 iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::ESequenceNumber, 0); |
163 iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::ESequenceNumber, 0); |
152 |
164 |
153 //16. file name |
165 //16. file name |
154 //use the name without full path specification |
166 //use the name without full path specification |
155 TParse parse; |
167 TParse parse; |
156 User::LeaveIfError( parse.Set(objectP->DesC(CMTPObjectMetaData::ESuid), NULL, NULL) ); |
168 LEAVEIFERROR( parse.Set(objectP->DesC(CMTPObjectMetaData::ESuid), NULL, NULL), |
|
169 OstTraceExt2( TRACE_ERROR, DUP3_CMTPPICTBRIDGEDPGETOBJECTINFO_BUILDOBJECTINFOL, |
|
170 "Sets up TParse object for %S failed! error code %d", objectP->DesC(CMTPObjectMetaData::ESuid), munged_err)); |
157 iObjectInfoToBuildP->SetStringL(CMTPTypeObjectInfo::EFilename, parse.NameAndExt()); |
171 iObjectInfoToBuildP->SetStringL(CMTPTypeObjectInfo::EFilename, parse.NameAndExt()); |
158 |
172 |
159 //4, compressed size, 17 Date created, and 18 Date modified |
173 //4, compressed size, 17 Date created, and 18 Date modified |
160 SetFileSizeDateL(objectP->DesC(CMTPObjectMetaData::ESuid), (objectHandle==iPictBridgeDP.PtpServer()->DeviceDiscoveryHandle())); |
174 SetFileSizeDateL(objectP->DesC(CMTPObjectMetaData::ESuid), (objectHandle==iPictBridgeDP.PtpServer()->DeviceDiscoveryHandle())); |
161 |
175 |
162 //18. keyword |
176 //18. keyword |
163 //empty keyword |
177 //empty keyword |
164 iObjectInfoToBuildP->SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC); |
178 iObjectInfoToBuildP->SetStringL(CMTPTypeObjectInfo::EKeywords, KNullDesC); |
165 CleanupStack::PopAndDestroy(objectP); |
179 CleanupStack::PopAndDestroy(objectP); |
166 __FLOG(_L8("<< CMTPPictBridgeDpGetObjectInfo::BuildObjectInfoL")); |
180 OstTraceFunctionExit0( CMTPPICTBRIDGEDPGETOBJECTINFO_BUILDOBJECTINFOL_EXIT ); |
167 } |
181 } |
168 |
182 |
169 |
183 |
170 /** |
184 /** |
171 Set file properties |
185 Set file properties |
172 */ |
186 */ |
173 void CMTPPictBridgeDpGetObjectInfo::SetFileSizeDateL(const TDesC& aFileName, TBool aDiscoveryFile) |
187 void CMTPPictBridgeDpGetObjectInfo::SetFileSizeDateL(const TDesC& aFileName, TBool aDiscoveryFile) |
174 { |
188 { |
175 __FLOG_VA((_L16(">> CMTPPictBridgeDpGetObjectInfo::SetFileSizeDateL aDiscoveryFile %d %S"), aDiscoveryFile, &aFileName)); |
189 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPGETOBJECTINFO_SETFILESIZEDATEL_ENTRY ); |
|
190 OstTraceExt2( TRACE_NORMAL, CMTPPICTBRIDGEDPGETOBJECTINFO_SETFILESIZEDATEL, |
|
191 "aDiscoveryFile %d %S", aDiscoveryFile, aFileName ); |
176 |
192 |
177 // open the file for retrieving information |
193 // open the file for retrieving information |
178 RFile file; |
194 RFile file; |
179 TInt size(0); |
195 TInt size(0); |
180 TTime modifiedTime=0; |
196 TTime modifiedTime=0; |
181 |
197 |
182 if (!aDiscoveryFile) |
198 if (!aDiscoveryFile) |
183 { |
199 { |
184 User::LeaveIfError(file.Open(iFramework.Fs(), aFileName, EFileShareReadersOnly)); |
200 LEAVEIFERROR(file.Open(iFramework.Fs(), aFileName, EFileShareReadersOnly), |
|
201 OstTraceExt2( TRACE_ERROR, DUP3_CMTPPICTBRIDGEDPGETOBJECTINFO_SETFILESIZEDATEL, |
|
202 "Open %S failed! error code %d", aFileName, munged_err )); |
185 CleanupClosePushL(file); |
203 CleanupClosePushL(file); |
186 |
204 |
187 //file size |
205 //file size |
188 User::LeaveIfError(file.Size(size)); |
206 LEAVEIFERROR(file.Size(size), |
189 |
207 OstTrace1( TRACE_ERROR, DUP4_CMTPPICTBRIDGEDPGETOBJECTINFO_SETFILESIZEDATEL, |
|
208 "Get current file size failed! error code %d", munged_err)); |
|
209 |
190 //file modified time |
210 //file modified time |
191 User::LeaveIfError(file.Modified(modifiedTime)); |
211 LEAVEIFERROR(file.Modified(modifiedTime), |
|
212 OstTrace1( TRACE_ERROR, DUP5_CMTPPICTBRIDGEDPGETOBJECTINFO_SETFILESIZEDATEL, |
|
213 "Gets local date and time the file was last modified failed! error code %d", munged_err)); |
192 } |
214 } |
193 else |
215 else |
194 { |
216 { |
195 //file modified time |
217 //file modified time |
196 modifiedTime.HomeTime(); |
218 modifiedTime.HomeTime(); |
197 } |
219 } |
198 |
220 |
199 //file size |
221 //file size |
200 TUint32 fileSize=size; |
222 TUint32 fileSize=size; |
201 iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EObjectCompressedSize, fileSize); |
223 iObjectInfoToBuildP->SetUint32L(CMTPTypeObjectInfo::EObjectCompressedSize, fileSize); |
202 __FLOG_VA((_L8(" file size %d"), fileSize)); |
224 OstTrace1( TRACE_NORMAL, DUP2_CMTPPICTBRIDGEDPGETOBJECTINFO_SETFILESIZEDATEL, "file size %d", fileSize ); |
203 |
225 |
204 //file modified time |
226 //file modified time |
205 const TInt KTimeStringLen=0x0f;// YYYYMMDDThhmmss(.s), we exclude tenths of seconds and use length 15, (MTP 1.0 spec, section 3.2.5) |
227 const TInt KTimeStringLen=0x0f;// YYYYMMDDThhmmss(.s), we exclude tenths of seconds and use length 15, (MTP 1.0 spec, section 3.2.5) |
206 TBuf<KTimeStringLen> modifiedTimeBuffer; |
228 TBuf<KTimeStringLen> modifiedTimeBuffer; |
207 _LIT(KTimeFormat,"%Y%M%DT%H%M%T%S"); |
229 _LIT(KTimeFormat,"%Y%M%DT%H%M%T%S"); |