33
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-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: Methods for ServerSettingsView
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <hblineedit.h>
|
36
|
19 |
#include <hbmessagebox.h>
|
38
|
20 |
#include <hbnamespace.h>
|
36
|
21 |
#include "serversettingsview.h"
|
33
|
22 |
#include "dmadvancedview.h"
|
36
|
23 |
#include "settingsdataformcustomitem.h"
|
33
|
24 |
|
|
25 |
ServerSettingsView::ServerSettingsView(HbMainWindow* mainWindow, DmAdvancedView* serversview, QString& header, QGraphicsItem* parent): HbView(parent), iMainWindow(mainWindow),
|
|
26 |
form(NULL),dataformmodel(NULL),serversView(serversview),backbehaviorset(false)
|
|
27 |
{
|
|
28 |
constructview(header);
|
|
29 |
viewspecificmenu = new HbMenu();
|
|
30 |
help = viewspecificmenu->addAction(hbTrId("txt_common_menu_help"));
|
|
31 |
exit = viewspecificmenu->addAction(hbTrId("txt_common_menu_exit"));
|
|
32 |
connect(exit, SIGNAL(triggered()), QCoreApplication::instance(), SLOT(quit()));
|
|
33 |
setMenu(viewspecificmenu);
|
|
34 |
}
|
|
35 |
ServerSettingsView::~ServerSettingsView()
|
|
36 |
{
|
|
37 |
|
|
38 |
}
|
|
39 |
|
|
40 |
void ServerSettingsView::constructview(QString& header)
|
|
41 |
{
|
|
42 |
if(!form)
|
|
43 |
{
|
|
44 |
//custom prototype
|
|
45 |
form = new HbDataForm();
|
37
|
46 |
QList <HbAbstractViewItem*> protos = form->itemPrototypes();
|
33
|
47 |
customPrototype = new SettingsDataFormCustomItem(form);
|
37
|
48 |
protos.append(customPrototype);
|
|
49 |
form->setItemPrototypes(protos);
|
33
|
50 |
dataformmodel = new HbDataFormModel();
|
|
51 |
makeviewItemsVisible(header);
|
|
52 |
form->setModel(dataformmodel);
|
|
53 |
setWidget(form);
|
|
54 |
iMainWindow->addView(this);
|
|
55 |
}
|
|
56 |
else //form already created
|
|
57 |
{
|
|
58 |
}
|
|
59 |
}
|
|
60 |
|
|
61 |
int ServerSettingsView::setProfileValues(QStringList& settingdatalist,
|
|
62 |
bool& sessiontype, QStringList& apdata, int& currentap
|
|
63 |
, int& portnum, bool& networkauthval)
|
|
64 |
{
|
|
65 |
Q_UNUSED(sessiontype);
|
|
66 |
Q_UNUSED(networkauthval);
|
|
67 |
int count = settingdatalist.count();
|
|
68 |
apnameslist = apdata;
|
|
69 |
if(count > 0)
|
|
70 |
{
|
|
71 |
servername->setContentWidgetData(QString("text"), settingdatalist.first());
|
|
72 |
serverid->setContentWidgetData(QString("text"), settingdatalist[1]);
|
|
73 |
serverpwd->setContentWidgetData(QString("echoMode"),HbLineEdit::Password );
|
|
74 |
serverpwd->setContentWidgetData(QString("text"), settingdatalist[2]);
|
|
75 |
QStringList sList;
|
|
76 |
sList <<hbTrId("txt_device_update_button_internet");
|
|
77 |
sList<<hbTrId("txt_device_update_button_bluetooth");
|
|
78 |
sessionmode->setContentWidgetData(QString("text"), sList[0]);//Internet selected
|
|
79 |
sessionmode->setContentWidgetData(QString("additionalText"), sList[1]);
|
|
80 |
|
|
81 |
apdata.append(hbTrId("txt_device_update_setlabel_access_point_val_defaul"));
|
|
82 |
accesspoint->setContentWidgetData(QString("items"), apdata);
|
|
83 |
currentiapindex = currentap;
|
|
84 |
if(currentap >= 0)
|
|
85 |
accesspoint->setContentWidgetData(QString("currentIndex"), currentap);
|
|
86 |
else
|
|
87 |
accesspoint->setContentWidgetData(QString("currentIndex"), apdata.count()-1);
|
|
88 |
form->addConnection(accesspoint, SIGNAL(currentIndexChanged (int ) ),this, SLOT(accessPointItemChanged(int)));
|
|
89 |
hostaddress->setContentWidgetData(QString("text"),settingdatalist[3]);
|
|
90 |
port->setContentWidgetData(QString("text"),portnum);//Integer only setting needs to be done
|
|
91 |
username->setContentWidgetData(QString("text"),settingdatalist[4]);
|
|
92 |
userpwd->setContentWidgetData(QString("echoMode"),HbLineEdit::Password );
|
|
93 |
userpwd->setContentWidgetData(QString("text"),settingdatalist[5]);
|
|
94 |
QStringList yesnoList;
|
|
95 |
yesnoList <<hbTrId("txt_device_update_button_yes");
|
|
96 |
yesnoList<<hbTrId("txt_device_update_button_no");
|
|
97 |
networkauth->setContentWidgetData(QString("text"), yesnoList[0]);
|
|
98 |
networkauth->setContentWidgetData(QString("additionalText"), yesnoList[1]);
|
|
99 |
networkusername->setContentWidgetData(QString("text"),settingdatalist[6]);
|
|
100 |
networkpwd->setContentWidgetData(QString("echoMode"),HbLineEdit::Password );
|
|
101 |
networkpwd->setContentWidgetData(QString("text"),settingdatalist[7]);
|
|
102 |
return 0;
|
|
103 |
}
|
|
104 |
else
|
|
105 |
return -1;
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
void ServerSettingsView::backButtonClicked()
|
|
110 |
{
|
|
111 |
qDebug("OMADM server settings back button clicked");
|
|
112 |
//Trigger main view
|
|
113 |
//Send data back to servers view and save the profile
|
|
114 |
QStringList itemlist;
|
|
115 |
itemlist << servername->contentWidgetData(QString("text")).toString();
|
|
116 |
itemlist << serverid->contentWidgetData(QString("text")).toString();
|
|
117 |
itemlist << serverpwd->contentWidgetData(QString("text")).toString();
|
|
118 |
|
|
119 |
itemlist << hostaddress->contentWidgetData(QString("text")).toString();
|
|
120 |
|
|
121 |
itemlist << username->contentWidgetData(QString("text")).toString();
|
|
122 |
|
|
123 |
itemlist << userpwd->contentWidgetData(QString("text")).toString();
|
|
124 |
|
|
125 |
itemlist
|
|
126 |
<< networkusername->contentWidgetData(QString("text")).toString();
|
|
127 |
|
|
128 |
itemlist << networkpwd->contentWidgetData(QString("text")).toString();
|
|
129 |
QString sesstype =
|
|
130 |
sessionmode->contentWidgetData(QString("text")).toString();
|
|
131 |
bool sessmode = false;
|
|
132 |
if (sesstype.compare("Internet"))
|
|
133 |
sessmode = true;
|
|
134 |
//Map this current iap with iap array
|
|
135 |
QString curriap;
|
|
136 |
if (currentiapindex >= 0 && currentiapindex < apnameslist.count())
|
|
137 |
curriap = apnameslist[currentiapindex];//accesspoint->contentWidgetData(QString("currentText")).toString();
|
|
138 |
else
|
|
139 |
curriap.clear();
|
|
140 |
unsigned int portval = port->contentWidgetData(QString("text")).toInt();
|
|
141 |
QString netauthdata =
|
|
142 |
sessionmode->contentWidgetData(QString("text")).toString();
|
|
143 |
bool netauthval = false;
|
|
144 |
if (netauthdata.compare("yes"))
|
|
145 |
netauthval = true;
|
|
146 |
//check server name , server id, host addr & usrname
|
|
147 |
if ((itemlist[0].length() > 0) && (itemlist[1].length() > 0)
|
|
148 |
&& (itemlist[3].length() > 0) && (itemlist[4].length() > 0))
|
|
149 |
{
|
|
150 |
serversView->saveProfile(itemlist, sessmode, curriap, portval,
|
|
151 |
netauthval);
|
|
152 |
qDebug("omadm before crash");
|
|
153 |
form->removeConnection(accesspoint,
|
|
154 |
SIGNAL(currentIndexChanged (int ) ), this,
|
|
155 |
SLOT(accessPointItemChanged(int)));
|
|
156 |
qDebug("omadm after crash");
|
|
157 |
iMainWindow->setCurrentView(serversView);
|
|
158 |
//Form wk08 soft key owned by view
|
|
159 |
//iMainWindow->removeSoftKeyAction(Hb::SecondarySoftKey,backaction);
|
|
160 |
dataformmodel->clear();
|
|
161 |
}
|
|
162 |
else
|
|
163 |
{
|
38
|
164 |
HbMessageBox *note = new HbMessageBox(HbMessageBox::MessageTypeInformation);
|
|
165 |
note->setText(hbTrId(
|
33
|
166 |
"txt_device_update_dialog_enter_mandatory_field_values"));
|
38
|
167 |
note->setAttribute( Qt::WA_DeleteOnClose);
|
|
168 |
note->setTimeout(HbPopup::NoTimeout);
|
|
169 |
note->open();
|
33
|
170 |
}
|
|
171 |
}
|
|
172 |
|
|
173 |
void ServerSettingsView::checkServerIdvalue()
|
|
174 |
{
|
|
175 |
QString srvid = serverid->contentWidgetData(QString("text")).toString();
|
|
176 |
if(serversView->checkServerId(srvid))
|
|
177 |
{
|
|
178 |
serverid->setContentWidgetData(QString("text"), QString(""));
|
38
|
179 |
HbMessageBox *note= new HbMessageBox(HbMessageBox::MessageTypeInformation);
|
|
180 |
note->setText(hbTrId("txt_device_update_dialog_invalid_server_id"));
|
|
181 |
note->setAttribute( Qt::WA_DeleteOnClose);
|
|
182 |
note->setTimeout(HbPopup::NoTimeout);
|
|
183 |
note->open();
|
33
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
void ServerSettingsView::setBackButtonBehavior()
|
|
188 |
{
|
|
189 |
if (!backbehaviorset)
|
|
190 |
{
|
|
191 |
qDebug("OMADM server settings view back behavior setting");
|
|
192 |
backaction = new HbAction(Hb::BackNaviAction, this);
|
|
193 |
connect(backaction, SIGNAL(triggered()), this,
|
|
194 |
SLOT(backButtonClicked()));
|
|
195 |
setNavigationAction(backaction);
|
|
196 |
backbehaviorset = true;
|
|
197 |
}
|
|
198 |
qDebug("OMADM server settings view back behavior setting done");
|
|
199 |
}
|
|
200 |
|
|
201 |
void ServerSettingsView::makeviewItemsVisible(QString& formtitle)
|
|
202 |
{
|
|
203 |
setBackButtonBehavior();
|
|
204 |
form->setHeading(hbTrId("txt_device_update_subhead_advanced_device_updates"));
|
|
205 |
form->setDescription(formtitle);
|
|
206 |
if(dataformmodel->rowCount() <= 0)
|
|
207 |
{
|
|
208 |
QString itemname(hbTrId("txt_device_update_formlabel_server_name"));
|
|
209 |
servername = dataformmodel->appendDataFormItem(HbDataFormModelItem::TextItem , itemname);
|
|
210 |
|
|
211 |
itemname = hbTrId("txt_device_update_formlabel_server_id");
|
|
212 |
serverid = dataformmodel->appendDataFormItem(HbDataFormModelItem::TextItem , itemname);
|
|
213 |
|
|
214 |
form->addConnection(serverid, SIGNAL(editingFinished ()),
|
|
215 |
this, SLOT(checkServerIdvalue()));
|
|
216 |
itemname = hbTrId("txt_device_update_formlabel_server_password");
|
|
217 |
serverpwd = dataformmodel->appendDataFormItem(HbDataFormModelItem::TextItem, itemname);
|
|
218 |
|
|
219 |
itemname = hbTrId("txt_device_update_setlabel_session_mode");
|
|
220 |
sessionmode = dataformmodel->appendDataFormItem(HbDataFormModelItem::ToggleValueItem, itemname);
|
|
221 |
|
|
222 |
itemname = hbTrId("txt_device_update_setlabel_access_point");
|
|
223 |
accesspoint = dataformmodel->appendDataFormItem(HbDataFormModelItem::ComboBoxItem , itemname);
|
|
224 |
|
|
225 |
itemname = hbTrId("txt_device_update_formlabel_host_address");
|
|
226 |
hostaddress = dataformmodel->appendDataFormItem(HbDataFormModelItem::TextItem, itemname);
|
|
227 |
|
|
228 |
itemname = hbTrId("txt_device_update_formlabel_port");
|
|
229 |
port = dataformmodel->appendDataFormItem(HbDataFormModelItem::CustomItemBase, itemname);
|
|
230 |
|
|
231 |
itemname = hbTrId("txt_device_update_formlabel_user_name");
|
|
232 |
username = dataformmodel->appendDataFormItem(HbDataFormModelItem::TextItem, itemname);
|
|
233 |
|
|
234 |
itemname = hbTrId("txt_device_update_formlabel_password");
|
|
235 |
userpwd = dataformmodel->appendDataFormItem(HbDataFormModelItem::TextItem, itemname);
|
|
236 |
|
|
237 |
itemname = hbTrId("txt_device_update_setlabel_network_authentication");
|
|
238 |
networkauth = dataformmodel->appendDataFormItem(HbDataFormModelItem::ToggleValueItem, itemname);
|
|
239 |
|
|
240 |
itemname = hbTrId("txt_device_update_formlabel_network_user_name");
|
|
241 |
networkusername = dataformmodel->appendDataFormItem(HbDataFormModelItem::TextItem, itemname);
|
|
242 |
|
|
243 |
itemname = hbTrId("txt_device_update_formlabel_network_password");
|
|
244 |
networkpwd = dataformmodel->appendDataFormItem(HbDataFormModelItem::TextItem, itemname);
|
|
245 |
}
|
|
246 |
}
|
|
247 |
|
|
248 |
void ServerSettingsView::accessPointItemChanged(int apindex)
|
|
249 |
{
|
|
250 |
currentiapindex = apindex;
|
|
251 |
qDebug("omadm iap changed");
|
|
252 |
}
|
|
253 |
|