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: Implementation of CBIPXMLWriter class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "BIPXMLWriter.h" |
|
21 #include <obexutilsmessagehandler.h> |
|
22 |
|
23 |
|
24 // CONSTANTS |
|
25 _LIT8( KBIPXmlDocBegin," <imaging-capabilities version=\"1.0\">" ); |
|
26 _LIT8( KBIPXmlDocEnd, "</imaging-capabilities>" ); |
|
27 _LIT8( KBIPXmlImageFormatsBegin, "<image-formats encoding=\"" ); |
|
28 _LIT8( KBIPXmlImageFormatsEnd, "/>"); |
|
29 _LIT8( KBIPImageTypes, "JPEGBMPGIFWBMPPNGJPEG2000" ); |
|
30 _LIT8( KBIPUserSeries60, "USR-SERIES60-" ); |
|
31 |
|
32 const TInt KBIPImageTypesLength = 30; |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // NewL |
|
37 // Two-phased constructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CBIPXmlWriter* CBIPXmlWriter::NewL() |
|
41 { |
|
42 TRACE_FUNC |
|
43 CBIPXmlWriter* self = new ( ELeave ) CBIPXmlWriter(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop(self); |
|
47 return( self ); |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------- |
|
51 // CBIPXmlWriter() |
|
52 // --------------------------------------------------------- |
|
53 // |
|
54 CBIPXmlWriter::CBIPXmlWriter() |
|
55 { |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // OpenXmlDocumentL() |
|
60 // --------------------------------------------------------- |
|
61 // |
|
62 void CBIPXmlWriter::OpenXmlDocumentL( TFileName& aFileName ) |
|
63 { |
|
64 TRACE_FUNC |
|
65 User::LeaveIfError( iFileSession.Connect() ); |
|
66 TPath tempPath; |
|
67 TInt drive = TObexUtilsMessageHandler::GetMessageCentreDriveL(); |
|
68 TDriveUnit driveString (drive); |
|
69 User::LeaveIfError(iFileSession.CreatePrivatePath( drive )); |
|
70 User::LeaveIfError(iFileSession.PrivatePath(tempPath)); |
|
71 User::LeaveIfError(ifile.Temp( iFileSession, tempPath, aFileName, EFileWrite )); |
|
72 User::LeaveIfError( ifile.Write( KBIPXmlDocBegin ) ); |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CloseXmlDocumentL() |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 void CBIPXmlWriter::CloseXmlDocumentL() |
|
80 { |
|
81 TRACE_FUNC |
|
82 User::LeaveIfError( ifile.Write( KBIPXmlDocEnd ) ); |
|
83 User::LeaveIfError( ifile.Flush() ); |
|
84 ifile.Close(); |
|
85 iFileSession.Close(); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // OpenXmlElementL() |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 void CBIPXmlWriter::OpenXmlElementL( TElementType aElement ) |
|
93 { |
|
94 switch( aElement ) |
|
95 { |
|
96 case EImageFormats: |
|
97 { |
|
98 User::LeaveIfError( ifile.Write( KBIPXmlImageFormatsBegin ) ); |
|
99 break; |
|
100 } |
|
101 case EPreferredFormat: |
|
102 { |
|
103 break; |
|
104 } |
|
105 case EAttachmentFormats: |
|
106 { |
|
107 break; |
|
108 } |
|
109 case EFilteringParameters: |
|
110 { |
|
111 break; |
|
112 } |
|
113 case EDPOFOptions: |
|
114 { |
|
115 break; |
|
116 } |
|
117 default: |
|
118 { |
|
119 } |
|
120 } |
|
121 TRACE_FUNC |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------- |
|
125 // AddXmlAttributeL() |
|
126 // --------------------------------------------------------- |
|
127 // |
|
128 void CBIPXmlWriter::AddXmlAttributeL( TAttributeType aAttributeType, TDesC8& aAttr ) |
|
129 { |
|
130 TRACE_FUNC_ENTRY |
|
131 TBuf8<KBIPImageTypesLength> attribute = KBIPImageTypes(); |
|
132 switch( aAttributeType ) |
|
133 { |
|
134 case EEncoding: |
|
135 { |
|
136 if( attribute.Find( aAttr ) == KErrNotFound ) |
|
137 { |
|
138 User::LeaveIfError( ifile.Write( KBIPUserSeries60 ) ); |
|
139 User::LeaveIfError( ifile.Write( aAttr ) ); |
|
140 |
|
141 } |
|
142 else |
|
143 { |
|
144 User::LeaveIfError( ifile.Write( aAttr ) ); |
|
145 } |
|
146 break; |
|
147 } |
|
148 case EPixel: |
|
149 { |
|
150 User::LeaveIfError( ifile.Write( aAttr ) ); |
|
151 break; |
|
152 } |
|
153 case EMaxSize: |
|
154 { |
|
155 User::LeaveIfError( ifile.Write( aAttr ) ); |
|
156 break; |
|
157 } |
|
158 case ETransformation: |
|
159 { |
|
160 break; |
|
161 } |
|
162 default: |
|
163 { |
|
164 } |
|
165 } |
|
166 TRACE_FUNC_EXIT |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------- |
|
170 // CloseXmlElementL() |
|
171 // --------------------------------------------------------- |
|
172 // |
|
173 void CBIPXmlWriter::CloseXmlElementL() |
|
174 { |
|
175 TRACE_FUNC |
|
176 User::LeaveIfError( ifile.Write( KBIPXmlImageFormatsEnd ) ); |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------- |
|
180 // ConstructL() |
|
181 // --------------------------------------------------------- |
|
182 // |
|
183 void CBIPXmlWriter::ConstructL() |
|
184 { |
|
185 TRACE_FUNC |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------- |
|
189 // ~CBIPXmlWriter() |
|
190 // --------------------------------------------------------- |
|
191 // |
|
192 CBIPXmlWriter::~CBIPXmlWriter() |
|
193 { |
|
194 TRACE_FUNC |
|
195 ifile.Close(); |
|
196 iFileSession.Close(); |
|
197 } |
|
198 |
|
199 // End of File |
|