0
|
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 |
#include <stringloader.h>
|
|
20 |
#include <aknsettingitemlist.h>
|
|
21 |
#include <aknradiobuttonsettingpage.h>
|
|
22 |
#include <ApSettingsHandlerUI.h>
|
|
23 |
#include <ApUtils.h>
|
|
24 |
|
|
25 |
#include "JavaDebugAgentRes.h"
|
|
26 |
#include "JavaDebugAgentSettings.h"
|
|
27 |
#include "JavaDebugAgentSettingsApItem.h"
|
|
28 |
|
|
29 |
#define SUPER CAknSettingItem
|
|
30 |
CJavaDebugAgentSettingsApItem::
|
|
31 |
CJavaDebugAgentSettingsApItem(TInt aId, TInt* aApId) : SUPER(aId), iApId(aApId)
|
|
32 |
{
|
|
33 |
}
|
|
34 |
|
|
35 |
CJavaDebugAgentSettingsApItem::~CJavaDebugAgentSettingsApItem()
|
|
36 |
{
|
|
37 |
delete iCommsDb;
|
|
38 |
delete iAlwaysAskText;
|
|
39 |
delete iUserDefinedText;
|
|
40 |
}
|
|
41 |
|
|
42 |
const TDesC& CJavaDebugAgentSettingsApItem::SettingTextL()
|
|
43 |
{
|
|
44 |
if (*iApId != KNoAccessPoint && !iApNameValid)
|
|
45 |
{
|
|
46 |
if (UpdateApName() == KErrNone)
|
|
47 |
{
|
|
48 |
iApNameValid = ETrue;
|
|
49 |
}
|
|
50 |
else
|
|
51 |
{
|
|
52 |
*iApId = KNoAccessPoint;
|
|
53 |
}
|
|
54 |
}
|
|
55 |
if (*iApId == KNoAccessPoint)
|
|
56 |
{
|
|
57 |
return *AlwaysAskTextL();
|
|
58 |
}
|
|
59 |
else
|
|
60 |
{
|
|
61 |
return iApName;
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
void CJavaDebugAgentSettingsApItem::EditItemL(TBool /*aCalledFromMenu*/)
|
|
66 |
{
|
|
67 |
UpdateApName();
|
|
68 |
TBool aUserDefinedAp = ((*iApId) != KNoAccessPoint);
|
|
69 |
while (AlwaysAskOrSelectApL(&aUserDefinedAp))
|
|
70 |
{
|
|
71 |
if (aUserDefinedAp)
|
|
72 |
{
|
|
73 |
// The primary purpose of this tool is to support
|
|
74 |
// on-device-debugging over WLAN. We could filter out WLAN
|
|
75 |
// access points here. The way it's done now, this tool can
|
|
76 |
// be used for remote on-device debugging over GPRS. Why not?
|
|
77 |
CApSettingsHandler *apUi = CApSettingsHandler::NewLC(
|
|
78 |
ETrue,
|
|
79 |
EApSettingsSelListIsPopUp,
|
|
80 |
EApSettingsSelMenuSelectNormal,
|
|
81 |
KEApIspTypeAll,
|
|
82 |
EApBearerTypeAllBearers,
|
|
83 |
KEApSortNameAscending,
|
|
84 |
EIPv4 | EIPv6);
|
|
85 |
|
|
86 |
// Override prompt
|
|
87 |
apUi->SetTextOverrideL(EPopupPromptText, SettingName());
|
|
88 |
|
|
89 |
// Let the user select the access point
|
|
90 |
TUint32 id = *iApId;
|
|
91 |
TInt ret = apUi->RunSettingsL(id, id);
|
|
92 |
CleanupStack::PopAndDestroy(apUi);
|
|
93 |
|
|
94 |
// Access point selection menu has "Exit" menu item
|
|
95 |
if (ret & KApUiEventExitRequested)
|
|
96 |
{
|
|
97 |
CEikonEnv::Static()->EikAppUi()->HandleCommandL(EEikCmdExit);
|
|
98 |
break;
|
|
99 |
}
|
|
100 |
|
|
101 |
// Store the settings
|
|
102 |
if (ret & KApUiEventSelected)
|
|
103 |
{
|
|
104 |
*iApId = id;
|
|
105 |
iApNameValid = EFalse;
|
|
106 |
UpdateListBoxTextL();
|
|
107 |
break;
|
|
108 |
}
|
|
109 |
}
|
|
110 |
else
|
|
111 |
{
|
|
112 |
if (*iApId != KNoAccessPoint)
|
|
113 |
{
|
|
114 |
*iApId = KNoAccessPoint;
|
|
115 |
UpdateListBoxTextL();
|
|
116 |
}
|
|
117 |
break;
|
|
118 |
}
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
TBool CJavaDebugAgentSettingsApItem::AlwaysAskOrSelectApL(TInt* aUserDefinedAp)
|
|
123 |
{
|
|
124 |
// options array
|
|
125 |
CDesCArrayFlat* values = new(ELeave)CDesCArrayFlat(1);
|
|
126 |
CleanupStack::PushL(values);
|
|
127 |
values->AppendL(*AlwaysAskTextL());
|
|
128 |
values->AppendL(*UserDefinedTextL());
|
|
129 |
|
|
130 |
// Create dialog
|
|
131 |
CAknRadioButtonSettingPage* dlg = new(ELeave)CAknRadioButtonSettingPage(
|
|
132 |
R_JAVA_DEBUG_AGENT_RADIO_BUTTON_SETTING_PAGE, *aUserDefinedAp, values);
|
|
133 |
|
|
134 |
// Show the dialog
|
|
135 |
CleanupStack::PushL(dlg);
|
|
136 |
dlg->SetSettingTextL(SettingName());
|
|
137 |
CleanupStack::Pop(dlg);
|
|
138 |
TBool ok = dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged);
|
|
139 |
CleanupStack::PopAndDestroy(values);
|
|
140 |
return ok;
|
|
141 |
}
|
|
142 |
|
|
143 |
TInt CJavaDebugAgentSettingsApItem::UpdateApName()
|
|
144 |
{
|
|
145 |
TRAPD(err, UpdateApNameL());
|
|
146 |
return err;
|
|
147 |
}
|
|
148 |
|
|
149 |
void CJavaDebugAgentSettingsApItem::UpdateApNameL()
|
|
150 |
{
|
|
151 |
CApUtils* apUtils = CApUtils::NewLC(*CommsDbL());
|
|
152 |
apUtils->NameL(*iApId, iApName);
|
|
153 |
CleanupStack::PopAndDestroy(apUtils);
|
|
154 |
}
|
|
155 |
|
|
156 |
CCommsDatabase* CJavaDebugAgentSettingsApItem::CommsDbL()
|
|
157 |
{
|
|
158 |
if (!iCommsDb)
|
|
159 |
{
|
|
160 |
iCommsDb = CCommsDatabase::NewL();
|
|
161 |
}
|
|
162 |
return iCommsDb;
|
|
163 |
}
|
|
164 |
|
|
165 |
const TDesC* CJavaDebugAgentSettingsApItem::AlwaysAskTextL()
|
|
166 |
{
|
|
167 |
if (!iAlwaysAskText)
|
|
168 |
{
|
|
169 |
iAlwaysAskText = StringLoader::LoadL(
|
|
170 |
R_JAVA_DEBUG_AGENT_ACCESS_POINT_ALWAYS_ASK);
|
|
171 |
}
|
|
172 |
return iAlwaysAskText;
|
|
173 |
}
|
|
174 |
|
|
175 |
const TDesC* CJavaDebugAgentSettingsApItem::UserDefinedTextL()
|
|
176 |
{
|
|
177 |
if (!iUserDefinedText)
|
|
178 |
{
|
|
179 |
iUserDefinedText = StringLoader::LoadL(
|
|
180 |
R_JAVA_DEBUG_AGENT_ACCESS_POINT_USER_DEFINED);
|
|
181 |
}
|
|
182 |
return iUserDefinedText;
|
|
183 |
}
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Local Variables:
|
|
187 |
* c-basic-offset: 4
|
|
188 |
* indent-tabs-mode: nil
|
|
189 |
* End:
|
|
190 |
*/
|