|
1 /* |
|
2 * Copyright (c) 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 the License "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 file details plugin* |
|
15 */ |
|
16 #include <MPFileDetailsDialog.h> |
|
17 #include <MPFileDetails.h> |
|
18 #include "filedetailsplugin.h" |
|
19 #include <mpxmediageneraldefs.h> |
|
20 #include <mpxmediageneralextdefs.h> |
|
21 #include <mpxmedia.h> |
|
22 #include <mpxmediavideodefs.h> |
|
23 #include <vcxmyvideosdefs.h> |
|
24 |
|
25 const TInt KThousandNotKilobyte = 1000; |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CFileDetailsPlugin::NewL |
|
29 // |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CFileDetailsPlugin* CFileDetailsPlugin::NewL() |
|
33 { |
|
34 CFileDetailsPlugin* self = |
|
35 new (ELeave) CFileDetailsPlugin(); |
|
36 |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CFileDetailsPlugin::CFileDetailsPlugin |
|
42 // |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CFileDetailsPlugin::CFileDetailsPlugin() |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CFileDetailsPlugin::~CFileDetailsPlugin |
|
51 // |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CFileDetailsPlugin::~CFileDetailsPlugin() |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CFileDetailsPlugin::~CFileDetailsPlugin |
|
60 // |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CFileDetailsPlugin::ShowFileDetails( const CMPXMedia& aMedia ) |
|
64 { |
|
65 CMPFileDetailsDialog* detailsDialog = CMPFileDetailsDialog::NewL(); |
|
66 CMPFileDetails* details = new (ELeave) CMPFileDetails(); |
|
67 |
|
68 //File path |
|
69 if ( aMedia.IsSupported( KMPXMediaGeneralUri ) ) |
|
70 { |
|
71 details->iFilePath = aMedia.ValueText( KMPXMediaGeneralUri ).AllocLC(); |
|
72 } |
|
73 |
|
74 //Name |
|
75 if ( aMedia.IsSupported( KMPXMediaGeneralTitle ) ) |
|
76 { |
|
77 details->iTitle = aMedia.ValueText( KMPXMediaGeneralTitle ).AllocLC(); |
|
78 } |
|
79 else if ( details->iFilePath ) |
|
80 { |
|
81 details->iTitle = details->iFilePath->AllocLC(); |
|
82 } |
|
83 |
|
84 //Duration |
|
85 if ( aMedia.IsSupported( KVcxMediaMyVideosDuration ) ) |
|
86 { |
|
87 TReal32 length = *(aMedia.Value<TReal32>( KVcxMediaMyVideosDuration )); |
|
88 if ( length > 0 ) |
|
89 { |
|
90 details->iDurationInSeconds = static_cast<TUint>( length ); |
|
91 } |
|
92 } |
|
93 |
|
94 //File size |
|
95 if ( aMedia.IsSupported( KMPXMediaGeneralExtSizeInt64 ) ) |
|
96 { |
|
97 details->iSize = *(aMedia.Value<TInt64>( KMPXMediaGeneralExtSizeInt64 )); |
|
98 } |
|
99 |
|
100 //Copyright |
|
101 if ( aMedia.IsSupported( KMPXMediaGeneralCopyright ) ) |
|
102 { |
|
103 details->iCopyright = aMedia.ValueText( KMPXMediaGeneralCopyright ).AllocLC(); |
|
104 } |
|
105 |
|
106 //MIME |
|
107 if ( aMedia.IsSupported( KMPXMediaGeneralMimeType ) ) |
|
108 { |
|
109 details->iFormat = aMedia.ValueText( KMPXMediaGeneralMimeType ).AllocLC(); |
|
110 } |
|
111 |
|
112 // File creation date |
|
113 if ( aMedia.IsSupported( KMPXMediaGeneralDate ) ) |
|
114 { |
|
115 details->iTime = *aMedia.Value<TTime>( KMPXMediaGeneralDate ) ; |
|
116 } |
|
117 |
|
118 // Bit rate |
|
119 if ( aMedia.IsSupported( KMPXMediaVideoBitRate ) ) |
|
120 { |
|
121 // Multiplied by 1k as the value provided by MDS is kbps and file |
|
122 // details dialog assumes it get bps |
|
123 details->iBitrate = *aMedia.Value<TUint16>( KMPXMediaVideoBitRate ) * KThousandNotKilobyte ; |
|
124 } |
|
125 |
|
126 // Height |
|
127 if ( aMedia.IsSupported( KMPXMediaVideoHeight ) ) |
|
128 { |
|
129 details->iResolutionHeight = *aMedia.Value<TUint16>( KMPXMediaVideoHeight ); |
|
130 } |
|
131 |
|
132 // Width |
|
133 if ( aMedia.IsSupported( KMPXMediaVideoWidth ) ) |
|
134 { |
|
135 details->iResolutionWidth = *aMedia.Value<TUint16>( KMPXMediaVideoWidth ); |
|
136 } |
|
137 |
|
138 //Artist |
|
139 if ( aMedia.IsSupported( KMPXMediaVideoArtist ) ) |
|
140 { |
|
141 details->iArtist = aMedia.ValueText( KMPXMediaVideoArtist ).AllocLC(); |
|
142 } |
|
143 |
|
144 detailsDialog->ExecuteLD( details ); |
|
145 |
|
146 // cleanup |
|
147 if( details->iFormat ) |
|
148 { |
|
149 CleanupStack::PopAndDestroy( details->iFormat ); |
|
150 details->iFormat = NULL; |
|
151 } |
|
152 if( details->iCopyright ) |
|
153 { |
|
154 CleanupStack::PopAndDestroy( details->iCopyright ); |
|
155 details->iCopyright = NULL; |
|
156 } |
|
157 if( details->iTitle ) |
|
158 { |
|
159 CleanupStack::PopAndDestroy( details->iTitle ); |
|
160 details->iTitle = NULL; |
|
161 } |
|
162 if( details->iFilePath ) |
|
163 { |
|
164 CleanupStack::PopAndDestroy( details->iFilePath ); |
|
165 details->iFilePath = NULL; |
|
166 } |
|
167 |
|
168 delete details; |
|
169 } |