40
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 |
#include "mpxvideo_debug.h"
|
|
19 |
#include "videosettingsgroup.h"
|
|
20 |
#include "videosettingsaccesspointentry.h"
|
|
21 |
#include <cpsettingformitemdata.h>
|
|
22 |
#include <cpitemdatahelper.h>
|
|
23 |
#include <hbdataformmodel.h>
|
|
24 |
#include <hblineedit.h>
|
|
25 |
#include <hbinputeditorinterface.h>
|
|
26 |
#include <hbdataformviewitem.h>
|
|
27 |
#include <hbinputstandardfilters.h>
|
|
28 |
#include <hbvalidator.h>
|
|
29 |
#include <hbpushbutton.h>
|
|
30 |
#include <mpsettingsmodel.h>
|
|
31 |
#include <MPSettEngPluginImplementationUIDs.hrh>
|
|
32 |
#include <xqconversions.h>
|
|
33 |
#include <qapplication.h>
|
|
34 |
#include <hbapplication.h>
|
|
35 |
|
41
|
36 |
const int PROXY_LOWEST_ACCEPTED_VALUE = 1;
|
|
37 |
const int UDP_LOWEST_ACCEPTED_VALUE = 1024;
|
|
38 |
const int PORT_HIGHEST_ACCEPTED_VALUE = 65535;
|
|
39 |
|
|
40 |
void gValidatePortValues(int& value, int bottom, int top)
|
|
41 |
{
|
|
42 |
if(value < bottom)
|
|
43 |
{
|
|
44 |
value = bottom;
|
|
45 |
}
|
|
46 |
|
|
47 |
if(value > top)
|
|
48 |
{
|
|
49 |
value = top;
|
|
50 |
}
|
|
51 |
}
|
|
52 |
|
40
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
// Constructor
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
VideoSettingsGroup::VideoSettingsGroup(CpItemDataHelper &itemDataHelper) :
|
|
58 |
CpSettingFormItemData(HbDataFormModelItem::GroupItem, QString()),
|
|
59 |
mItemDataHelper(itemDataHelper),
|
|
60 |
mSettingsModel(0),
|
|
61 |
mAccessPointItem(0),
|
|
62 |
mLowestUDPPortItem(0),
|
|
63 |
mHighestUDPPortItem(0),
|
|
64 |
mUseProxyItem(0),
|
|
65 |
mProxyServerItem(0),
|
|
66 |
mProxyPortItem(0)
|
|
67 |
{
|
|
68 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::VideoSettingsGroup()"));
|
41
|
69 |
|
40
|
70 |
// Load the translation file.
|
|
71 |
QString lang = QLocale::system().name();
|
|
72 |
bool loaded(false);
|
|
73 |
|
41
|
74 |
loaded = mTranslator.load( "videos_" + lang, QString("c:/resource/qt/translations") );
|
40
|
75 |
|
|
76 |
if (!loaded)
|
|
77 |
{
|
41
|
78 |
mTranslator.load("videos_" + lang, QString("z:/resource/qt/translations") );
|
40
|
79 |
}
|
|
80 |
|
|
81 |
// Install the translator
|
|
82 |
HbApplication* app = qobject_cast<HbApplication*>(qApp);
|
|
83 |
if(app)
|
|
84 |
{
|
41
|
85 |
app->installTranslator(&mTranslator);
|
40
|
86 |
}
|
41
|
87 |
|
40
|
88 |
this->setLabel(hbTrId("txt_videos_subhead_video_streaming_settings"));
|
41
|
89 |
|
40
|
90 |
TRAPD(err, InitSettingsModelL());
|
|
91 |
if(err != KErrNone)
|
|
92 |
{
|
|
93 |
delete mSettingsModel;
|
|
94 |
mSettingsModel = 0;
|
|
95 |
return;
|
|
96 |
}
|
41
|
97 |
|
40
|
98 |
itemDataHelper.connectToForm(SIGNAL(itemShown(const QModelIndex)), this, SLOT(itemShown(const QModelIndex)));
|
41
|
99 |
|
40
|
100 |
// Access point in use
|
41
|
101 |
mAccessPointItem = new VideoSettingsAccessPointEntry(itemDataHelper,
|
40
|
102 |
hbTrId("txt_videos_dblist_access_point"), this);
|
|
103 |
this->appendChild(mAccessPointItem);
|
41
|
104 |
|
40
|
105 |
// Lowest UDP port
|
|
106 |
mLowestUDPPortItem = new CpSettingFormItemData(HbDataFormModelItem::TextItem,
|
|
107 |
hbTrId("txt_videos_dblist_min_udp_port"));
|
|
108 |
mLowestUDPPortItem->setContentWidgetData(QString("maxRows"), 1);
|
41
|
109 |
mItemDataHelper.addConnection(mLowestUDPPortItem, SIGNAL(editingFinished()),
|
40
|
110 |
this, SLOT(lowestUdpPortEditingFinished()));
|
|
111 |
this->appendChild(mLowestUDPPortItem);
|
41
|
112 |
|
40
|
113 |
// Highest UDP port
|
|
114 |
mHighestUDPPortItem = new CpSettingFormItemData(HbDataFormModelItem::TextItem,
|
|
115 |
hbTrId("txt_videos_dblist_max_udp_port"));
|
|
116 |
mHighestUDPPortItem->setContentWidgetData(QString("maxRows"), 1);
|
41
|
117 |
mItemDataHelper.addConnection(mHighestUDPPortItem, SIGNAL(editingFinished()),
|
40
|
118 |
this, SLOT(highestUdpPortEditingFinished()));
|
|
119 |
this->appendChild(mHighestUDPPortItem);
|
41
|
120 |
|
40
|
121 |
// Use proxy
|
|
122 |
mUseProxyItem = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, QString());
|
|
123 |
mUseProxyItem->setContentWidgetData(QString("text"), hbTrId("txt_videos_formlabel_proxy_in_use"));
|
|
124 |
this->appendChild(mUseProxyItem);
|
41
|
125 |
|
40
|
126 |
// Proxy server address
|
|
127 |
mProxyServerItem = new CpSettingFormItemData(HbDataFormModelItem::TextItem,
|
|
128 |
hbTrId("txt_videos_dblist_proxy_host_name"));
|
|
129 |
mProxyServerItem->setContentWidgetData(QString("maxRows"), 1);
|
|
130 |
mProxyServerItem->setContentWidgetData(QString("placeholderText"), hbTrId("txt_videos_dblist_none"));
|
41
|
131 |
mItemDataHelper.addConnection(mProxyServerItem, SIGNAL(editingFinished()),
|
40
|
132 |
this, SLOT(proxyServerEditingFinished()));
|
|
133 |
this->appendChild(mProxyServerItem);
|
41
|
134 |
|
40
|
135 |
// Proxy port number
|
|
136 |
mProxyPortItem = new CpSettingFormItemData(HbDataFormModelItem::TextItem,
|
|
137 |
hbTrId("txt_videos_dblist_proxy_port"));
|
|
138 |
mProxyPortItem->setContentWidgetData(QString("maxRows"), 1);
|
41
|
139 |
mItemDataHelper.addConnection(mProxyPortItem, SIGNAL(editingFinished()),
|
40
|
140 |
this, SLOT(proxyPortEditingFinished()));
|
|
141 |
this->appendChild(mProxyPortItem);
|
41
|
142 |
|
40
|
143 |
loadSettings();
|
|
144 |
}
|
|
145 |
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
// Destructor
|
|
148 |
// ---------------------------------------------------------------------------
|
|
149 |
//
|
|
150 |
VideoSettingsGroup::~VideoSettingsGroup()
|
|
151 |
{
|
|
152 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::~VideoSettingsGroup()"));
|
41
|
153 |
|
40
|
154 |
TRAP_IGNORE( mSettingsModel->StoreSettingsL() );
|
41
|
155 |
|
40
|
156 |
delete mSettingsModel;
|
|
157 |
}
|
|
158 |
|
|
159 |
// ---------------------------------------------------------------------------
|
|
160 |
// getAccessPointId
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
uint VideoSettingsGroup::getAccessPointId()
|
|
164 |
{
|
|
165 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::getAccessPointId()"));
|
41
|
166 |
|
40
|
167 |
TUint32 defaultAp(0);
|
|
168 |
mSettingsModel->GetDefaultAp(defaultAp);
|
41
|
169 |
|
40
|
170 |
MPX_DEBUG(_L("Returned access point id = %i"), defaultAp);
|
41
|
171 |
|
40
|
172 |
return defaultAp;
|
|
173 |
}
|
|
174 |
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
// setAccessPointId
|
|
177 |
// ---------------------------------------------------------------------------
|
|
178 |
//
|
|
179 |
void VideoSettingsGroup::setAccessPointId(const uint& defaultAp)
|
|
180 |
{
|
41
|
181 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::setAccessPointId()"),
|
40
|
182 |
_L("defaultAp = %i"), defaultAp);
|
41
|
183 |
|
|
184 |
uint oldAp = getAccessPointId();
|
|
185 |
|
|
186 |
if(oldAp != defaultAp)
|
|
187 |
{
|
|
188 |
mSettingsModel->SetDefaultAp(defaultAp);
|
|
189 |
mUseProxyItem->setContentWidgetData(QString("checked"), false);
|
|
190 |
}
|
40
|
191 |
}
|
|
192 |
|
|
193 |
// ---------------------------------------------------------------------------
|
|
194 |
// lowestUdpPortValueChanged
|
|
195 |
// ---------------------------------------------------------------------------
|
|
196 |
//
|
|
197 |
void VideoSettingsGroup::lowestUdpPortEditingFinished()
|
|
198 |
{
|
|
199 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::lowestUdpPortValueChanged()"));
|
41
|
200 |
|
40
|
201 |
int minPort = mLowestUDPPortItem->contentWidgetData(QString("text")).toString().toInt();
|
|
202 |
int maxPort = mHighestUDPPortItem->contentWidgetData(QString("text")).toString().toInt();
|
41
|
203 |
|
40
|
204 |
MPX_DEBUG(_L("minudp = %i, maxudp = %i"), minPort, maxPort);
|
41
|
205 |
|
40
|
206 |
if(minPort > maxPort)
|
|
207 |
{
|
|
208 |
minPort = maxPort;
|
|
209 |
}
|
41
|
210 |
|
|
211 |
gValidatePortValues(minPort, UDP_LOWEST_ACCEPTED_VALUE, PORT_HIGHEST_ACCEPTED_VALUE);
|
|
212 |
|
|
213 |
mLowestUDPPortItem->setContentWidgetData(QString("text"), QString::number(minPort));
|
|
214 |
|
40
|
215 |
mSettingsModel->SetMinUDPPort(minPort);
|
|
216 |
}
|
|
217 |
|
|
218 |
// ---------------------------------------------------------------------------
|
|
219 |
// highestUdpPortValueChanged
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
//
|
|
222 |
void VideoSettingsGroup::highestUdpPortEditingFinished()
|
|
223 |
{
|
|
224 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::highestUdpPortValueChanged()"));
|
41
|
225 |
|
40
|
226 |
int maxPort = mHighestUDPPortItem->contentWidgetData(QString("text")).toString().toInt();
|
|
227 |
int minPort = mLowestUDPPortItem->contentWidgetData(QString("text")).toString().toInt();
|
41
|
228 |
|
40
|
229 |
MPX_DEBUG(_L("minudp = %i, maxudp = %i"), minPort, maxPort);
|
41
|
230 |
|
40
|
231 |
if(maxPort < minPort)
|
|
232 |
{
|
|
233 |
maxPort = minPort;
|
|
234 |
}
|
41
|
235 |
|
|
236 |
gValidatePortValues(maxPort, UDP_LOWEST_ACCEPTED_VALUE, PORT_HIGHEST_ACCEPTED_VALUE);
|
|
237 |
|
|
238 |
mHighestUDPPortItem->setContentWidgetData(QString("text"), QString::number(maxPort));
|
|
239 |
|
40
|
240 |
mSettingsModel->SetMaxUDPPort(maxPort);
|
|
241 |
}
|
|
242 |
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
// useProxyToggled
|
|
245 |
// ---------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
void VideoSettingsGroup::useProxyToggled(int state)
|
|
248 |
{
|
41
|
249 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::useProxyToggled()"),
|
40
|
250 |
_L("state = %i"), state);
|
41
|
251 |
|
40
|
252 |
mProxyServerItem->setEnabled(state == Qt::Checked);
|
|
253 |
mProxyPortItem->setEnabled(state == Qt::Checked);
|
41
|
254 |
|
40
|
255 |
mSettingsModel->SetProxyMode(state == Qt::Checked ? 1 : 0);
|
|
256 |
}
|
|
257 |
|
|
258 |
// ---------------------------------------------------------------------------
|
|
259 |
// proxyServerValueChanged
|
|
260 |
// ---------------------------------------------------------------------------
|
|
261 |
//
|
|
262 |
void VideoSettingsGroup::proxyServerEditingFinished()
|
|
263 |
{
|
|
264 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::proxyServerValueChanged()"));
|
41
|
265 |
|
40
|
266 |
QString text = mProxyServerItem->contentWidgetData(QString("text")).toString();
|
41
|
267 |
|
40
|
268 |
MPX_DEBUG(_L("new proxy server = '%s'"), text.data());
|
41
|
269 |
|
40
|
270 |
HBufC* proxyServer = XQConversions::qStringToS60Desc(text);
|
|
271 |
TRAP_IGNORE( mSettingsModel->SetProxyHostNameL(*proxyServer) );
|
|
272 |
delete proxyServer;
|
|
273 |
}
|
|
274 |
|
|
275 |
// ---------------------------------------------------------------------------
|
|
276 |
// proxyPortValueChanged
|
|
277 |
// ---------------------------------------------------------------------------
|
|
278 |
//
|
|
279 |
void VideoSettingsGroup::proxyPortEditingFinished()
|
|
280 |
{
|
|
281 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::proxyPortValueChanged()"));
|
41
|
282 |
|
40
|
283 |
int proxyPort = mProxyPortItem->contentWidgetData(QString("text")).toString().toInt();
|
41
|
284 |
|
40
|
285 |
MPX_DEBUG(_L("new proxy port = %i"), proxyPort);
|
41
|
286 |
|
|
287 |
gValidatePortValues(proxyPort, PROXY_LOWEST_ACCEPTED_VALUE, PORT_HIGHEST_ACCEPTED_VALUE);
|
|
288 |
|
|
289 |
mProxyPortItem->setContentWidgetData(QString("text"), QString::number(proxyPort));
|
|
290 |
|
|
291 |
mSettingsModel->SetProxyPort(proxyPort);
|
40
|
292 |
}
|
|
293 |
|
|
294 |
// ---------------------------------------------------------------------------
|
|
295 |
// itemShown
|
|
296 |
// ---------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
void VideoSettingsGroup::itemShown(const QModelIndex& index)
|
|
299 |
{
|
41
|
300 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::itemShown()"),
|
40
|
301 |
_L("index row = %i"), index.row());
|
41
|
302 |
|
40
|
303 |
HbDataFormModelItem* modelItem = mItemDataHelper.modelItemFromModelIndex(index);
|
41
|
304 |
|
40
|
305 |
if(modelItem == mLowestUDPPortItem ||
|
|
306 |
modelItem == mHighestUDPPortItem ||
|
|
307 |
modelItem == mProxyPortItem )
|
|
308 |
{
|
|
309 |
HbLineEdit *editor = static_cast<HbLineEdit *>(mItemDataHelper.widgetFromModelIndex(index));
|
|
310 |
|
41
|
311 |
editor->setMaxLength(5);
|
|
312 |
|
40
|
313 |
HbEditorInterface editorIf(editor);
|
|
314 |
editorIf.setFilter(HbDigitsOnlyFilter::instance());
|
|
315 |
}
|
41
|
316 |
|
40
|
317 |
if(modelItem == mProxyServerItem)
|
|
318 |
{
|
|
319 |
mItemDataHelper.addConnection(mUseProxyItem, SIGNAL(stateChanged(int)), this, SLOT(useProxyToggled(int)));
|
|
320 |
HbEditorInterface editor(mItemDataHelper.widgetFromModelIndex(index));
|
|
321 |
editor.setFilter(HbUrlFilter::instance());
|
|
322 |
}
|
|
323 |
}
|
|
324 |
|
|
325 |
// ---------------------------------------------------------------------------
|
|
326 |
// InitSettingsModelL
|
|
327 |
// ---------------------------------------------------------------------------
|
|
328 |
//
|
|
329 |
void VideoSettingsGroup::InitSettingsModelL()
|
|
330 |
{
|
|
331 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::InitSettingsModelL()"));
|
41
|
332 |
|
40
|
333 |
TUid settingsUid = {KMPSettEngImplUidROP};
|
|
334 |
mSettingsModel = CMPSettingsModel::NewL(settingsUid);
|
|
335 |
mSettingsModel->LoadSettingsL(EConfigUser);
|
|
336 |
}
|
|
337 |
|
|
338 |
// ---------------------------------------------------------------------------
|
|
339 |
// loadSettings
|
|
340 |
// ---------------------------------------------------------------------------
|
|
341 |
//
|
|
342 |
void VideoSettingsGroup::loadSettings()
|
|
343 |
{
|
|
344 |
MPX_ENTER_EXIT(_L("VideoSettingsGroup::loadSettings()"));
|
41
|
345 |
|
40
|
346 |
int lowestUdpPort(0);
|
|
347 |
mSettingsModel->GetMinUDPPort(lowestUdpPort);
|
|
348 |
mLowestUDPPortItem->setContentWidgetData(QString("text"), QString::number(lowestUdpPort));
|
41
|
349 |
|
40
|
350 |
int highestUdpPort(0);
|
|
351 |
mSettingsModel->GetMaxUDPPort(highestUdpPort);
|
|
352 |
mHighestUDPPortItem->setContentWidgetData(QString("text"), QString::number(highestUdpPort));
|
41
|
353 |
|
40
|
354 |
int proxyMode(0);
|
|
355 |
mSettingsModel->GetProxyMode(proxyMode);
|
|
356 |
mUseProxyItem->setContentWidgetData(QString("checked"), proxyMode == 1);
|
|
357 |
useProxyToggled(proxyMode == 1 ? Qt::Checked : Qt::Unchecked);
|
41
|
358 |
|
|
359 |
TBuf<496> proxyServerBuf;
|
40
|
360 |
mSettingsModel->GetProxyHostName(proxyServerBuf);
|
|
361 |
QString proxyServer = XQConversions::s60DescToQString(proxyServerBuf);
|
|
362 |
mProxyServerItem->setContentWidgetData(QString("text"), proxyServer);
|
41
|
363 |
|
40
|
364 |
int proxyPort;
|
|
365 |
mSettingsModel->GetProxyPort(proxyPort);
|
|
366 |
mProxyPortItem->setContentWidgetData(QString("text"), QString::number(proxyPort));
|
41
|
367 |
|
40
|
368 |
mAccessPointItem->setIapId(getAccessPointId());
|
|
369 |
}
|