|
1 /* |
|
2 * Copyright (c) 2008 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 #ifdef __PRESENCE |
|
20 |
|
21 #include "creator_impselement.h" |
|
22 #include "creator_traces.h" |
|
23 #include "creator_imps.h" |
|
24 |
|
25 using namespace creatorimps; |
|
26 |
|
27 /* |
|
28 * |
|
29 */ |
|
30 CCreatorImpsServerElement* CCreatorImpsServerElement::NewL(CCreatorEngine* aEngine, const TDesC& aName, const TDesC& aContext ) |
|
31 { |
|
32 CCreatorImpsServerElement* self = new (ELeave) CCreatorImpsServerElement(aEngine); |
|
33 CleanupStack::PushL(self); |
|
34 self->ConstructL(aName, aContext); |
|
35 CleanupStack::Pop(self); |
|
36 return self; |
|
37 } |
|
38 /* |
|
39 * |
|
40 */ |
|
41 CCreatorImpsServerElement::CCreatorImpsServerElement(CCreatorEngine* aEngine) |
|
42 : |
|
43 CCreatorScriptElement(aEngine) |
|
44 { |
|
45 iIsCommandElement = ETrue; |
|
46 } |
|
47 |
|
48 void CCreatorImpsServerElement::ExecuteCommandL() |
|
49 { |
|
50 const CCreatorScriptAttribute* amountAttr = FindAttributeByName(KAmount); |
|
51 TInt entryAmount = 1; |
|
52 if( amountAttr ) |
|
53 { |
|
54 entryAmount = ConvertStrToIntL(amountAttr->Value()); |
|
55 } |
|
56 // Get 'fields' element |
|
57 CCreatorScriptElement* fieldsElement = FindSubElement(KFields); |
|
58 if( fieldsElement && fieldsElement->SubElements().Count() > 0 ) |
|
59 { |
|
60 // Get sub-elements |
|
61 const RPointerArray<CCreatorScriptElement>& fields = fieldsElement->SubElements(); |
|
62 // Create note entries, the amount of entries is defined by entryAmount: |
|
63 for( TInt cI = 0; cI < entryAmount; ++cI ) |
|
64 { |
|
65 CIMPSParameters* param = new (ELeave) CIMPSParameters; |
|
66 CleanupStack::PushL(param); |
|
67 |
|
68 for( TInt i = 0; i < fields.Count(); ++i ) |
|
69 { |
|
70 CCreatorScriptElement* field = fields[i]; |
|
71 TPtrC elemName = field->Name(); |
|
72 TPtrC elemContent = field->Content(); |
|
73 const CCreatorScriptAttribute* randomAttr = fields[i]->FindAttributeByName(KRandomLength); |
|
74 TBool useRandom = EFalse; |
|
75 if( randomAttr || elemContent.Length() == 0 ) |
|
76 { |
|
77 useRandom = ETrue; |
|
78 } |
|
79 |
|
80 if( elemName == KName ) |
|
81 { |
|
82 if( useRandom ) |
|
83 { |
|
84 param->SetRandomNameL(*iEngine); |
|
85 } |
|
86 else |
|
87 { |
|
88 SetContentToTextParamL(param->iServerName, elemContent); |
|
89 } |
|
90 } |
|
91 if( elemName == KUrl ) |
|
92 { |
|
93 if( useRandom ) |
|
94 { |
|
95 param->SetRandomUrlL(*iEngine); |
|
96 } |
|
97 else |
|
98 { |
|
99 SetContentToTextParamL(param->iServerURL, elemContent); |
|
100 } |
|
101 } |
|
102 if( elemName == KUsername ) |
|
103 { |
|
104 if( useRandom ) |
|
105 { |
|
106 param->SetRandomUsernameL(*iEngine); |
|
107 } |
|
108 else |
|
109 { |
|
110 SetContentToTextParamL(param->iServerUsername, elemContent); |
|
111 } |
|
112 } |
|
113 if( elemName == KPassword ) |
|
114 { |
|
115 if( useRandom ) |
|
116 { |
|
117 param->SetRandomPasswordL(*iEngine); |
|
118 } |
|
119 else |
|
120 { |
|
121 SetContentToTextParamL(param->iServerPassword, elemContent); |
|
122 } |
|
123 } |
|
124 if( elemName == KConnectionMethodName ) |
|
125 { |
|
126 if( useRandom || CompareIgnoreCase(elemContent, creatorimps::KDefault) == 0 ) |
|
127 { |
|
128 param->SetDefaultAccessPointL(); |
|
129 } |
|
130 else |
|
131 { |
|
132 SetContentToTextParamL(param->iServerAccessPointName, elemContent); |
|
133 } |
|
134 } |
|
135 } |
|
136 iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryIMPSServers, param); |
|
137 CleanupStack::Pop(); // param |
|
138 } |
|
139 } |
|
140 else |
|
141 { |
|
142 iEngine->AppendToCommandArrayL(ECmdCreateMiscEntryIMPSServers, 0, entryAmount); |
|
143 } |
|
144 } |
|
145 |
|
146 #endif // __PRESENCE |