|
1 /* |
|
2 * Copyright (c) 2004 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: Sources |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <s32buf.h> |
|
22 #include <s32file.h> |
|
23 |
|
24 #include <nsmlfolderparser.h> |
|
25 #include "nsmlparserconstants.h" |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // TNSmlFolderAttributeData::TNSmlFolderAttributeData |
|
31 // Constructor |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C TNSmlFolderAttributeData::TNSmlFolderAttributeData() |
|
35 : iHidden(EBooleanMissing), iSystem(EBooleanMissing), |
|
36 iArchived(EBooleanMissing), iDelete(EBooleanMissing), |
|
37 iWritable(EBooleanMissing), iReadable(EBooleanMissing), |
|
38 iExecutable(EBooleanMissing) |
|
39 { |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // TNSmlFolderAttributeData::AttributeCount |
|
44 // Returns the amount of fields that are not EBooleanMissing |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C TInt TNSmlFolderAttributeData::AttributeCount() const |
|
48 { |
|
49 TInt count = 0; |
|
50 |
|
51 if ( iHidden ) count++; |
|
52 if ( iSystem ) count++; |
|
53 if ( iArchived ) count++; |
|
54 if ( iDelete ) count++; |
|
55 if ( iWritable ) count++; |
|
56 if ( iReadable ) count++; |
|
57 if ( iExecutable ) count++; |
|
58 |
|
59 return count; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // TNSmlFolderAttributeData::GenerateXml |
|
64 // Generates attribute xml |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 EXPORT_C void TNSmlFolderAttributeData::GenerateXml( TPtr8& aXml, const CNSmlXmlParser* aParser ) const |
|
68 { |
|
69 aParser->AppendElement(aXml, KFolderAttributesElement()); |
|
70 |
|
71 if ( iHidden ) |
|
72 { |
|
73 aParser->AppendElement(aXml, KAttributeHiddenElement(), aParser->BooleanToString( iHidden )); |
|
74 } |
|
75 |
|
76 if ( iSystem ) |
|
77 { |
|
78 aParser->AppendElement(aXml, KAttributeSystemElement(), aParser->BooleanToString( iSystem )); |
|
79 } |
|
80 |
|
81 if ( iArchived ) |
|
82 { |
|
83 aParser->AppendElement(aXml, KAttributeArchivedElement(), aParser->BooleanToString( iArchived )); |
|
84 } |
|
85 |
|
86 if ( iDelete ) |
|
87 { |
|
88 aParser->AppendElement(aXml, KAttributeDeleteElement(), aParser->BooleanToString( iDelete )); |
|
89 } |
|
90 |
|
91 if ( iWritable ) |
|
92 { |
|
93 aParser->AppendElement(aXml, KAttributeWritableElement(), aParser->BooleanToString( iWritable )); |
|
94 } |
|
95 |
|
96 if ( iReadable ) |
|
97 { |
|
98 aParser->AppendElement(aXml, KAttributeReadableElement(), aParser->BooleanToString( iReadable )); |
|
99 } |
|
100 |
|
101 if ( iExecutable ) |
|
102 { |
|
103 aParser->AppendElement(aXml, KAttributeExecutableElement(), aParser->BooleanToString( iExecutable )); |
|
104 } |
|
105 |
|
106 aParser->AppendEndElement(aXml, KFolderAttributesElement()); |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // TNSmlFolderAttributeData::CountXmlSize |
|
111 // Coounts the size of the xml if it was generated using the values currently in |
|
112 // member variables |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C TInt TNSmlFolderAttributeData::CountXmlSize( const CNSmlXmlParser* aParser ) const |
|
116 { |
|
117 TInt size = 0; |
|
118 size += aParser->SizeOfElements( KFolderAttributesElement() ); |
|
119 |
|
120 if ( iHidden ) |
|
121 { |
|
122 size += aParser->SizeOfBoolean( iHidden, KAttributeHiddenElement() ); |
|
123 } |
|
124 |
|
125 if ( iSystem ) |
|
126 { |
|
127 size += aParser->SizeOfBoolean( iSystem, KAttributeSystemElement() ); |
|
128 } |
|
129 |
|
130 if ( iArchived ) |
|
131 { |
|
132 size += aParser->SizeOfBoolean( iArchived, KAttributeArchivedElement() ); |
|
133 } |
|
134 |
|
135 if ( iDelete ) |
|
136 { |
|
137 size += aParser->SizeOfBoolean( iDelete, KAttributeDeleteElement() ); |
|
138 } |
|
139 |
|
140 if ( iWritable ) |
|
141 { |
|
142 size += aParser->SizeOfBoolean( iWritable, KAttributeWritableElement() ); |
|
143 } |
|
144 |
|
145 if ( iReadable ) |
|
146 { |
|
147 size += aParser->SizeOfBoolean( iReadable, KAttributeReadableElement() ); |
|
148 } |
|
149 |
|
150 if ( iExecutable ) |
|
151 { |
|
152 size += aParser->SizeOfBoolean( iExecutable, KAttributeExecutableElement() ); |
|
153 } |
|
154 |
|
155 return size; |
|
156 } |
|
157 |
|
158 // End of File |