|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include "senattributes.h" |
|
26 |
|
27 #include "sendebug.h" |
|
28 #include "senlogger.h" |
|
29 |
|
30 |
|
31 EXPORT_C CSenAttributes* CSenAttributes::NewL() |
|
32 { |
|
33 CSenAttributes* self = NewLC(); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 EXPORT_C CSenAttributes* CSenAttributes::NewLC() |
|
39 { |
|
40 CSenAttributes* self = new (ELeave) CSenAttributes(); |
|
41 CleanupStack::PushL(self); |
|
42 self->BaseConstructL(); |
|
43 return self; |
|
44 } |
|
45 |
|
46 EXPORT_C CSenAttributes* CSenAttributes::NewL(const CSenAttributes& aAttributes) |
|
47 { |
|
48 CSenAttributes* self = NewLC(aAttributes); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 EXPORT_C CSenAttributes* CSenAttributes::NewLC(const CSenAttributes& aAttributes) |
|
54 { |
|
55 CSenAttributes* self = new (ELeave) CSenAttributes(); |
|
56 CleanupStack::PushL(self); |
|
57 self->BaseConstructL(aAttributes); |
|
58 return self; |
|
59 } |
|
60 |
|
61 void CSenAttributes::BaseConstructL() |
|
62 { |
|
63 TLSLOG_OPEN(KSenUtilsLogChannel,KSenUtilsLogLevel,KSenUtils,KSenUtilsLog); |
|
64 TLSLOG_L(KSenUtilsLogChannel,KMinLogLevel ,"CSenAttributes::BaseConstructL(): Log opened"); |
|
65 TLSLOG_L(KSenUtilsLogChannel,KMinLogLevel ,"CSenAttributes::BaseConstructL(): End"); |
|
66 } |
|
67 |
|
68 void CSenAttributes::BaseConstructL(const CSenAttributes& aAttributes) |
|
69 { |
|
70 TLSLOG_OPEN(KSenUtilsLogChannel,KSenUtilsLogLevel,KSenUtils,KSenUtilsLog); |
|
71 TLSLOG_L(KSenUtilsLogChannel,KMinLogLevel ,"CSenAttributes::BaseConstructL(): Log opened"); |
|
72 TLSLOG_L(KSenUtilsLogChannel,KMinLogLevel ,"CSenAttributes::BaseConstructL(): End"); |
|
73 |
|
74 TInt error(KErrNone); |
|
75 for (TInt i = 0; i<aAttributes.Count(); i++) |
|
76 { |
|
77 error = iAttrList.Append( ((CSenAttributes&)aAttributes).iAttrList.KeyAt(i), |
|
78 ((CSenAttributes&)aAttributes).iAttrList.ValueAt(i)); |
|
79 if(error!=KErrNone) |
|
80 { |
|
81 iAttrList.Reset(); |
|
82 User::Leave(error); |
|
83 } |
|
84 } |
|
85 } |
|
86 |
|
87 |
|
88 CSenAttributes::CSenAttributes() : |
|
89 iAttrList(ETrue, EFalse) |
|
90 { |
|
91 } |
|
92 |
|
93 |
|
94 EXPORT_C CSenAttributes::~CSenAttributes() |
|
95 { |
|
96 iAttrList.Reset(); |
|
97 |
|
98 // Close the log file and the connection to the server. |
|
99 TLSLOG(KSenUtilsLogChannel,KMinLogLevel,(_L("Log file closed."))); |
|
100 TLSLOG_CLOSE(KSenUtilsLogChannel); |
|
101 } |
|
102 |
|
103 |
|
104 EXPORT_C void CSenAttributes::AddAttributeL(const CSenAttribute& aValue) //codescannerwarnings |
|
105 { |
|
106 TPtrC8 name = aValue.Name(); |
|
107 if ( KErrNotFound != iAttrList.Find(name) ) |
|
108 { |
|
109 // Replace, if attribute exists |
|
110 iAttrList.RemoveByKey(name); |
|
111 } |
|
112 iAttrList.Append(name.AllocL(),&aValue); |
|
113 } |
|
114 |
|
115 |
|
116 EXPORT_C const CSenAttribute& CSenAttributes::GetAttribute(const TDesC8& aName) const |
|
117 { |
|
118 TInt index = iAttrList.Find(aName); |
|
119 return *(iAttrList.ValueAt(index)); |
|
120 } |
|
121 |
|
122 |
|
123 EXPORT_C TInt CSenAttributes::Count() const |
|
124 { |
|
125 return iAttrList.Count(); |
|
126 } |
|
127 |
|
128 |
|
129 EXPORT_C TBool CSenAttributes::Equals(const CSenAttribute& aValue) const |
|
130 { |
|
131 return GetAttribute(aValue.Name()).Equals(aValue); |
|
132 } |
|
133 |
|
134 |
|
135 EXPORT_C TBool CSenAttributes::MatchAny(const CSenAttributes& aAttrs) |
|
136 { |
|
137 for ( TInt i = 0; i < aAttrs.Count(); i++ ) |
|
138 { |
|
139 for ( TInt ii = 0; ii < iAttrList.Count(); ii++ ) |
|
140 { |
|
141 if ( 0 == aAttrs.AttributeAt(i).Equals(*(iAttrList.ValueAt(ii))) ) |
|
142 { |
|
143 return(ETrue); |
|
144 } |
|
145 } |
|
146 } |
|
147 return EFalse; |
|
148 } |
|
149 |
|
150 |
|
151 const CSenAttribute& CSenAttributes::AttributeAt(TInt aIndex) const |
|
152 { |
|
153 return *(iAttrList.ValueAt(aIndex)); |
|
154 } |
|
155 |
|
156 /* |
|
157 RFileLogger* CSenAttributes::Log() const |
|
158 { |
|
159 return(RFileLogger*) &iLog; |
|
160 } |
|
161 |
|
162 */ |