|
1 /* |
|
2 * Copyright (c) 2006 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 #ifndef __JAVA_DEBUG_AGENT_SETTINGS_H_ |
|
20 #define __JAVA_DEBUG_AGENT_SETTINGS_H_ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <s32strm.h> |
|
24 #include <AknSettingItemList.h> |
|
25 #include "JavaDebugAgent.hrh" |
|
26 |
|
27 #define KNoAccessPoint KMaxTUint |
|
28 |
|
29 // Setting item created by CJavaDebugAgentSettings::TBoolParam |
|
30 class CJavaDebugAgentSettingsBooleanItem : |
|
31 public CAknEnumeratedTextPopupSettingItem |
|
32 { |
|
33 public: |
|
34 inline CJavaDebugAgentSettingsBooleanItem(TInt aResId, TInt& aValue) : |
|
35 CAknEnumeratedTextPopupSettingItem(aResId, aValue) {} |
|
36 inline void ChangeValueL() { SetInternalValue(!InternalValue()); } |
|
37 }; |
|
38 |
|
39 class CJavaDebugAgentDriver; |
|
40 class CJavaDebugAgentSettings : public CBase |
|
41 { |
|
42 public: |
|
43 class TParam { |
|
44 private: |
|
45 TInt iId; |
|
46 public: |
|
47 TParam(TInt aId) : iId(aId) {} |
|
48 virtual ~TParam(); |
|
49 TInt Id() const { return iId; } |
|
50 virtual TInt Size() const = 0; |
|
51 virtual void ReadL(RReadStream* aStream, TInt aSize) = 0; |
|
52 virtual void WriteL(RWriteStream* aStream) const = 0; |
|
53 virtual CAknSettingItem* CreateSettingItemL() = 0; |
|
54 }; |
|
55 |
|
56 class TPortParam : public TParam { |
|
57 private: |
|
58 enum { KSize = 2 }; |
|
59 TInt iPort; |
|
60 public: |
|
61 TPortParam(TInt aId, TInt aPort = 0): TParam(aId), iPort(aPort) {} |
|
62 TInt16 Value() const { return iPort; } |
|
63 void SetValue(TInt16 aPort) { iPort = aPort; } |
|
64 void SetValue(const TPortParam& aPort) { iPort = aPort.iPort; } |
|
65 TBool Equals(const TPortParam& aPort) const |
|
66 { return Id() == aPort.Id() && iPort == aPort.iPort; } |
|
67 |
|
68 virtual TInt Size() const; |
|
69 virtual void ReadL(RReadStream* aStream, TInt aSize); |
|
70 virtual void WriteL(RWriteStream* aStream) const; |
|
71 virtual CAknSettingItem* CreateSettingItemL(); |
|
72 private: |
|
73 TPortParam& operator=(const TPortParam&) {/*please dont*/return *this;} |
|
74 }; |
|
75 |
|
76 class TIntParam : public TParam { |
|
77 protected: |
|
78 enum { KSize = 4 }; |
|
79 TInt iInt; |
|
80 public: |
|
81 TIntParam(TInt aId, TInt aInt = 0): TParam(aId), iInt(aInt) {} |
|
82 TInt Value() const { return iInt; } |
|
83 void SetValue(TInt aInt) { iInt = aInt; } |
|
84 void SetValue(const TIntParam& aInt) { iInt = aInt.iInt; } |
|
85 TBool Equals(const TIntParam& aInt) const |
|
86 { return Id() == aInt.Id() && iInt == aInt.iInt; } |
|
87 |
|
88 virtual TInt Size() const; |
|
89 virtual void ReadL(RReadStream* aStream, TInt aSize); |
|
90 virtual void WriteL(RWriteStream* aStream) const; |
|
91 virtual CAknSettingItem* CreateSettingItemL(); |
|
92 private: |
|
93 TIntParam& operator=(const TIntParam&) {/*please dont*/return *this;} |
|
94 }; |
|
95 |
|
96 class TApParam : public TIntParam { |
|
97 public: |
|
98 TApParam(TInt aId, TInt aAp = KNoAccessPoint): TIntParam(aId, aAp) {} |
|
99 virtual CAknSettingItem* CreateSettingItemL(); |
|
100 private: |
|
101 TApParam& operator=(const TApParam&) {/*please dont*/return *this;} |
|
102 }; |
|
103 |
|
104 class TEnumParam : public TIntParam { |
|
105 public: |
|
106 TEnumParam(TInt aId, TInt aValue = 0): TIntParam(aId, aValue) {} |
|
107 virtual CAknSettingItem* CreateSettingItemL(); |
|
108 private: |
|
109 TEnumParam& operator=(const TEnumParam&) {/*please dont*/return *this;} |
|
110 }; |
|
111 |
|
112 class TBoolParam : public TParam { |
|
113 private: |
|
114 enum { KSize = 1 }; |
|
115 TBool iBool; |
|
116 public: |
|
117 TBoolParam(TInt aId, TBool aBool=EFalse): TParam(aId),iBool(aBool) {} |
|
118 TBool Value() const { return iBool; } |
|
119 void SetValue(TBool aBool) { iBool = aBool; } |
|
120 void SetValue(const TBoolParam& aBool) { iBool = aBool.iBool; } |
|
121 TBool Equals(const TBoolParam& aBool) const |
|
122 { return Id() == aBool.Id() && iBool == aBool.iBool; } |
|
123 |
|
124 virtual TInt Size() const; |
|
125 virtual void ReadL(RReadStream* aStream, TInt aSize); |
|
126 virtual void WriteL(RWriteStream* aStream) const; |
|
127 virtual CAknSettingItem* CreateSettingItemL(); |
|
128 private: |
|
129 TBoolParam& operator=(const TBoolParam&) {/*please dont*/return *this;} |
|
130 }; |
|
131 |
|
132 class TStrParam : public TParam { |
|
133 private: |
|
134 TBuf<KDebugAgentMaxStrParamLength> iBuf; |
|
135 public: |
|
136 TStrParam(TInt aId): TParam(aId) {} |
|
137 const TDesC& Value() const { return iBuf; } |
|
138 void SetValueL(const TDesC* aValue); |
|
139 void SetValueL(const TStrParam& aStr) { SetValueL(&aStr.Value()); } |
|
140 TBool Equals(const TStrParam& aStr) const |
|
141 { return Id() == aStr.Id() && !Value().Compare(aStr.Value()); } |
|
142 |
|
143 virtual TInt Size() const; |
|
144 virtual void ReadL(RReadStream* aStream, TInt aSize); |
|
145 virtual void WriteL(RWriteStream* aStream) const; |
|
146 virtual CAknSettingItem* CreateSettingItemL(); |
|
147 private: |
|
148 TStrParam& operator=(const TStrParam&) {/*please dont*/return *this;} |
|
149 }; |
|
150 |
|
151 private: |
|
152 RPointerArray<TParam> iParams; |
|
153 TBoolParam iAutoClean; |
|
154 TBoolParam iFileLog; |
|
155 TStrParam iPCHost; |
|
156 TPortParam iPCPort; |
|
157 TPortParam iAgentPort; |
|
158 TBoolParam iConnectToPC; |
|
159 TApParam iApId; |
|
160 TEnumParam iKeepAlivePeriod; |
|
161 TEnumParam iFontSize; |
|
162 |
|
163 public: |
|
164 static CJavaDebugAgentSettings* NewL(); |
|
165 ~CJavaDebugAgentSettings(); |
|
166 |
|
167 void ApplyTo(CJavaDebugAgentDriver* aDriver) const; |
|
168 void CopyFrom(const CJavaDebugAgentSettings* aSettings); |
|
169 TBool Equals(const CJavaDebugAgentSettings* aSettings) const; |
|
170 void LoadL(); |
|
171 void SaveL() const; |
|
172 |
|
173 TBool AutoClean() const { return iAutoClean.Value(); } |
|
174 TBool FileLog() const { return iFileLog.Value(); } |
|
175 const TDesC& PCHost() const { return iPCHost.Value(); } |
|
176 TInt PCPort() const { return iPCPort.Value(); } |
|
177 TInt AgentPort() const { return iAgentPort.Value(); } |
|
178 TBool ConnectToPC() const { return iConnectToPC.Value(); } |
|
179 TInt ApId() const { return iApId.Value(); } |
|
180 TInt KeepAlivePeriod() const { return iKeepAlivePeriod.Value(); } |
|
181 TInt FontSize() const { return iFontSize.Value(); } |
|
182 |
|
183 const TParam* FindParam(TInt aId) const; |
|
184 TParam* FindParam(TInt aId); |
|
185 |
|
186 private: |
|
187 CJavaDebugAgentSettings(); |
|
188 void ConstructL(); |
|
189 void LoadL(const TDesC& aPrefsFile); |
|
190 void LoadL(RReadStream* aStream); |
|
191 void SaveL(const TDesC& aPrefsFile) const; |
|
192 void SaveL(RWriteStream* aStream) const; |
|
193 }; |
|
194 |
|
195 #endif // __JAVA_DEBUG_AGENT_SETTINGS_H_ |
|
196 |
|
197 /** |
|
198 * Local Variables: |
|
199 * mode: c++ |
|
200 * c-basic-offset: 4 |
|
201 * indent-tabs-mode: nil |
|
202 * End: |
|
203 */ |