-
Notifications
You must be signed in to change notification settings - Fork 3
/
qmlaccess.cpp
103 lines (85 loc) · 4.06 KB
/
qmlaccess.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "qmlaccess.h"
#include <QDebug>
#include <QStringList>
#include "dataobject.h"
#include "networkdetails.h"
QMLAccess::QMLAccess(QWidget *parent) :
QDeclarativeView(parent)
{
m_context = rootContext();
m_context->setContextProperty("wMain", this);
QList<QObject*> dataList;
QStringList networkNameList;
QStringList networkSecurityList;
QStringList networkCodeList;
/***SET THE ROUTE TO WHERE NETWORKS ARE STORED***/
routeToNetworking = "/system/osso/connectivity/IAP";
/***CREATE A GCONFITEM TO ACCESS NETWORKS***/
GConfItem networkingDir(routeToNetworking);
/***CREATE A LIST WITH ALL THE SAVED NETWORKS***/
QStringList networkList = networkingDir.listDirs();
/***SEARCH IN THE ***/
for (int var = 0; var < networkList.count(); ++var) {
GConfItem network(networkList.at(var));
QStringList networkProperties = network.listEntries();
GConfItem wlan_security(network.key()+"/wlan_security");
debug("KEY:"+wlan_security.key()+" VALUE:"+wlan_security.value().toString());
if (wlan_security.value().toString()!="NONE"){
if (networkProperties.contains(networkList.at(var)+"/wlan_ssid")){
networkCodeList.append(networkList.at(var));
for (int p = 0; p < networkProperties.count(); ++p) {
GConfItem networkProperty(networkProperties.at(p));
if(networkProperty.key().contains("name")){
networkNameList.append(networkProperty.value().toString());
}
if(networkProperty.key().contains("wlan_security")){
networkSecurityList.append(networkProperty.value().toString());
}
/*else{
debug("Key"+networkProperty.key()+" VALUE: "+networkProperty.value().toString());
}*/
}
}
}
}
if (networkNameList.count()==networkSecurityList.count()){
for (int var = 0; var < networkNameList.count(); ++var) {
dataList.append(new DataObject(networkNameList.at(var),networkSecurityList.at(var),networkCodeList.at(var)));
}
}
m_context->setContextProperty("networkListModel", QVariant::fromValue(dataList));
setAttribute(Qt::WA_OpaquePaintEvent);
setAttribute(Qt::WA_NoSystemBackground);
setSource(QUrl("qrc:/qml/main.qml"));
}
void QMLAccess::debug(QString msg){
qDebug() << msg;
}
void QMLAccess::getNetworkDetails(QString network){
QList<QObject*> detailsList;
GConfItem networkingDetails(network);
QStringList networkProperties = networkingDetails.listEntries();
for (int var = 0; var < networkProperties.count(); ++var) {
GConfItem networkProperty(networkProperties.at(var));
if (networkProperty.key().contains("name")){
m_context->setContextProperty("networkName", networkProperty.value().toString());
}else if (
!networkProperty.key().contains("proxy_rtsp") &&
!networkProperty.key().contains("EAP_wpa2_only_mode") &&
!networkProperty.key().contains("proxy") &&
!networkProperty.key().contains("type") &&
!networkProperty.key().contains("dns") &&
!networkProperty.key().contains("ipv4") &&
!networkProperty.key().contains("wlan_hidden") &&
!networkProperty.key().contains("autoconnect") &&
!networkProperty.key().contains("wlan_ssid") &&
!networkProperty.key().contains("url") &&
!networkProperty.key().contains("wlan_wepdefkey")
){
QString key = networkProperty.key();
key = key.mid(key.lastIndexOf("/")+1);
detailsList.append(new NetworkDetails(key,networkProperty.value().toString()));
}
}
m_context->setContextProperty("networkPropertiesModel", QVariant::fromValue(detailsList));
}