|
QString | m_hostname |
|
bool | m_ipv4_dhcp |
|
QString | m_ipv4_addr |
|
QString | m_ipv4_mask |
|
QString | m_ipv4_router |
|
QString | m_ipv4_dns |
|
|
static QString | percentEncode (const QString &s) |
|
void | setStatus (int code, QByteArray description) |
|
void | setHeader (QByteArray name, QByteArray value) |
|
void | setHeader (QByteArray name, int value) |
|
void | write (QByteArray data) |
|
void | write (QString data) |
|
void | write (const char *data) |
|
void | about () |
|
HttpSession | getSession () |
|
virtual void | writeHeader (HttpRequest &request, HttpResponse &response) |
|
virtual void | writeFooter (HttpRequest &request, HttpResponse &response) |
|
Protected Member Functions inherited from MRequestHandler |
bool | needsLogin (HttpRequest &request, HttpResponse &response) |
|
QString | m_javascript |
|
Protected Attributes inherited from MRequestHandler |
bool | m_needs_access_data |
|
bool | m_needs_change_settings |
|
bool | m_cacheable |
|
Definition at line 16 of file networkcontroller.h.
NetworkController::NetworkController |
( |
| ) |
|
void NetworkController::actionApply |
( |
HttpRequest & |
request | ) |
|
|
private |
Read form HTTP post reply and load into the line
Definition at line 119 of file networkcontroller.cpp.
120 m_hostname = request.getParameter(
"hostname");
121 m_ipv4_dhcp = ( request.getParameter(
"ipv4_dhcp") ==
"Y") ?
true :
false;
122 m_ipv4_addr = request.getParameter(
"ipv4_addr");
123 m_ipv4_mask = request.getParameter(
"ipv4_mask");
124 m_ipv4_router = request.getParameter(
"ipv4_router");
125 m_ipv4_dns = request.getParameter(
"ipv4_dns");
127 QFile host(CONFIG_HOSTNAME);
128 if (!host.open(QIODevice::WriteOnly | QIODevice::Text)) {
129 qDebug() <<
"Could not open /etc/conf.d/hostname for writing";
130 write( tr(
"Sorry, it is not possible to write to /etc/conf.d/hostname").toUtf8() );
133 host.write(
"# This file is generated by fotobot application\n");
134 host.write(
"# Your changes will be overwritten\n\n");
135 host.write( QString(
"hostname=\"%1\"\n").arg(m_hostname).toUtf8() );
138 QFile net(CONFIG_NET);
139 if (!net.open(QIODevice::WriteOnly | QIODevice::Text)) {
140 qDebug() <<
"Could not open /etc/conf.d/hostname for writing";
141 write( tr(
"Sorry, it is not possible to write to /etc/conf.d/net").toUtf8() );
144 net.write(
"# This file is generated by fotobot application\n");
145 net.write(
"# Your changes will be overwritten\n\n");
147 net.write(
"dns_servers_eth0=\"8.8.8.8\"\n" );
148 net.write(
"config_eth0=\"dhcp\"\n" );
149 net.write(
"fallback_eth0=\"192.168.1.111 netmask 255.255.255.0\"\n" );
151 net.write( QString(
"config_eth0=\"%1 netmask %2\"\n").arg(m_ipv4_addr).arg(m_ipv4_mask).toUtf8() );
152 net.write( QString(
"routes_eth0=\"%1\"\n").arg(m_ipv4_router).toUtf8() );
153 net.write( QString(
"dns_servers_eth0=\"%1\"\n").arg(m_ipv4_dns).toUtf8() );
157 write( tr(
"<h2>Restarting....</h2>\n<p>Device is restarting now. Please wait few minutes and then refresh this page.</p>").toUtf8() );
159 QProcess *restart =
new QProcess();
160 restart->start(
"/usr/bin/fotobot-reboot");
void NetworkController::servicePrivate |
( |
HttpRequest & |
request | ) |
|
|
virtual |
Generates the response
Implements WebPage.
Definition at line 22 of file networkcontroller.cpp.
23 QByteArray action = request.getParameter(
"action");
24 if (action.startsWith(
"apply")) {
33 "<table class=\"formTable\">\n"
35 "<input type=\"hidden\" name=\"action\" value=\"apply\"/>\n"
36 "<tr><td>%2</td><td><input type=\"text\" name=\"hostname\" value=\"%3\"></td></tr>\n"
37 "<tr><td>%4</td><td><input type=\"checkbox\" name=\"ipv4_dhcp\" value=\"Y\" %5></td></tr>\n"
38 "<tr><td>%6</td><td><input type=\"text\" name=\"ipv4_addr\" value=\"%7\"></td></tr>\n"
39 "<tr><td>%8</td><td><input type=\"text\" name=\"ipv4_mask\" value=\"%9\"></td></tr>\n"
40 "<tr><td>%10</td><td><input type=\"text\" name=\"ipv4_router\" value=\"%11\"></td></tr>\n"
41 "<tr><td>%12</td><td><input type=\"text\" name=\"ipv4_dns\" value=\"%13\"></td></tr>\n"
42 "<tr><td></td><td><input type=\"submit\" value=\"OK\"></td></tr>\n"
44 .arg(tr(
"Network settings"))
45 .arg(tr(
"Hostname:")) .arg( m_hostname )
46 .arg(tr(
"Use DHCP:")) .arg( (m_ipv4_dhcp) ?
"checked" :
"" )
47 .arg(tr(
"IPv4 address:")) .arg( m_ipv4_addr )
48 .arg(tr(
"IPv4 mask:")) .arg( m_ipv4_mask )
49 .arg(tr(
"IPv4 router:")) .arg( m_ipv4_router )
50 .arg(tr(
"IPv4 dns server:")) .arg( m_ipv4_dns )
void actionApply(HttpRequest &request)
The documentation for this class was generated from the following files: