Commit d119e728 authored by Lamarque Souza's avatar Lamarque Souza
Browse files

Make hidden wifi networks work.

BUG: 209464
FIXED-IN: nm09
parent 231fe321
......@@ -30,7 +30,7 @@ set(networkmanager_SRCS
kde4_add_plugin(plasma_applet_networkmanagement ${networkmanager_SRCS})
target_link_libraries(plasma_applet_networkmanagement ${KDE4_PLASMA_LIBS} knmclient knminternals knm_nm ${KDE4_KIO_LIBS} ${KDE4_SOLID_LIBS} solidcontrol solidcontrolnm09)
target_link_libraries(plasma_applet_networkmanagement ${KDE4_PLASMA_LIBS} knmclient knminternals knm_nm ${KDE4_KIO_LIBS} ${KDE4_SOLID_LIBS} solidcontrol solidcontrolnm09 solidcontrolfuture)
install(TARGETS plasma_applet_networkmanagement DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES plasma-applet-networkmanagement.desktop DESTINATION ${SERVICES_INSTALL_DIR})
......
......@@ -49,6 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "wirelessnetworkitem.h"
#include "hiddenwirelessnetworkitem.h"
#include "gsminterfaceconnectionitem.h"
#include "../solidcontrolfuture/wirelessnetworkinterfaceenvironment.h"
ActivatableListWidget::ActivatableListWidget(RemoteActivatableList* activatables, QGraphicsWidget* parent) : Plasma::ScrollWidget(parent),
m_hiddenItem(0),
......@@ -217,8 +218,6 @@ void ActivatableListWidget::createItem(RemoteActivatable * activatable, const bo
void ActivatableListWidget::createHiddenItem()
{
return; // TODO: make hidden essid work first before enabling this again.
if (m_hiddenItem) {
return;
}
......@@ -308,6 +307,7 @@ void ActivatableListWidget::filter()
}
if (m_interfaces.count() && m_hasWireless) {
kDebug() << "Lamarque 1";
bool found = false;
foreach (QString uni, m_interfaces.keys())
{
......@@ -321,7 +321,7 @@ void ActivatableListWidget::filter()
m_hiddenItem->disappear();
m_hiddenItem = 0;
}
} else if (m_showAllTypes && m_hasWireless && !m_vpn) {
} else if (m_hasWireless && !m_vpn) {
createHiddenItem();
} else if (m_hiddenItem) {
m_hiddenItem->disappear();
......@@ -378,10 +378,40 @@ void ActivatableListWidget::hoverLeave(const QString& uni)
void ActivatableListWidget::connectToHiddenNetwork(const QString &ssid)
{
Solid::Control::WirelessNetworkInterfaceNm09 * wiface = 0;
foreach (Solid::Control::NetworkInterfaceNm09 * iface, Solid::Control::NetworkManagerNm09::networkInterfaces()) {
if (iface->type() == Solid::Control::NetworkInterfaceNm09::Wifi && iface->connectionState() > Solid::Control::NetworkInterfaceNm09::Unavailable) {
wiface = qobject_cast<Solid::Control::WirelessNetworkInterfaceNm09 *>(iface);
break;
}
}
if (!wiface) {
return;
}
m_hiddenConnectionInProgress << ssid;
QStringList args = QStringList(ssid) << "create";
QStringList args;
QString moduleArgs;
Solid::Control::WirelessNetworkInterfaceEnvironment envt(wiface);
Solid::Control::WirelessNetwork * network = envt.findNetwork(ssid);
if (network) {
moduleArgs = QString::fromLatin1("%1 %2")
.arg(wiface->uni())
.arg(network->referenceAccessPoint());
} else {
moduleArgs = QString::fromLatin1("%1 %2")
.arg(wiface->uni())
.arg(ssid);
}
args << QLatin1String("create") << QLatin1String("--type") << QLatin1String("802-11-wireless") << QLatin1String("--specific-args") << moduleArgs << QLatin1String("wifi_pass");
kDebug() << "invoking networkmanagement_configshell" << args;
// TODO: make this really work.
KToolInvocation::kdeinitExec(KGlobal::dirs()->findResource("exe", "networkmanagement_configshell"), args);
int ret = KToolInvocation::kdeinitExec(KGlobal::dirs()->findResource("exe", "networkmanagement_configshell"), args);
kDebug() << ret << args;
m_hiddenItem->setupItem();
}
// vim: sw=4 sts=4 et tw=100
......@@ -75,16 +75,17 @@ void HiddenWirelessNetworkItem::setupItem()
m_connect = new Plasma::IconWidget(this);
m_connect->setDrawBackground(false);
m_connect->setOrientation(Qt::Horizontal);
m_connect->setIcon("network-wireless");
m_connect->setText(i18nc("label for creating a connection to a hidden wireless network", "<hidden network>"));
m_layout->addItem(m_connect);
connect(m_connect, SIGNAL(activated()), SLOT(connectClicked()));
m_ssidEdit = new Plasma::LineEdit(this);
m_ssidEdit->nativeWidget()->setClickMessage(s_defaultText);
m_ssidEdit->hide();
connect(m_ssidEdit->nativeWidget(), SIGNAL(returnPressed()), SLOT(ssidEntered()));
}
m_connect->show();
m_connect->setIcon("network-wireless");
m_connect->setText(i18nc("label for creating a connection to a hidden wireless network", "<hidden network>"));
m_ssidEdit->hide();
m_ssidEdit->nativeWidget()->setClickMessage(s_defaultText);
}
void HiddenWirelessNetworkItem::connectClicked()
......
......@@ -85,6 +85,8 @@ WirelessPreferences::WirelessPreferences(bool setDefaults, const QVariantList &a
ap = iface->findAccessPoint(apUni);
if (ap) {
ssid = ap->ssid();
} else {
ssid = apUni;
}
}
}
......
#ifndef PLASMA_NM_VERSION_H
#define PLASMA_NM_VERSION_H
static const char * plasmaNmVersion = "nm09-20110906";
static const char * plasmaNmVersion = "nm09-20110907";
#endif
......@@ -97,23 +97,18 @@ int main(int argc, char **argv)
qout << i18n("Expected two specific args, found %1: %2", specificArgs.count(), specifics) << "\n";
return -1;
}
}
else {
} else {
con = editor.createConnection(true, Knm::Connection::typeFromString(type), specificArgs);
}
if(!con)
{
if (!con) {
kDebug(KDE_DEFAULT_DEBUG_AREA) << Knm::Connection::typeFromString(type) << "type connection cannot be created.";
return -1;
}
/* TODO: test if connection already exists and in case affirmative do not add it. */
ManageConnection::saveConnection(con);
return app.exec();
} else if (args->isSet("hiddennetwork")) {
QString ssidOfHiddenNetwork = args->getOption("hiddennetwork");
kDebug(KDE_DEFAULT_DEBUG_AREA) << "I have been told to setup a connection to a hidden network..." << ssidOfHiddenNetwork;
return 0;
} else {
args->usage();
return -1;
......
......@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QTimer>
#include <QDBusReply>
#include <KDebug>
#include <KLocale>
......@@ -27,7 +28,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "manageconnection.h"
#include "settings/bluetooth.h"
ManageConnection::ManageConnection(Knm::Connection *con)
ManageConnection::ManageConnection(Knm::Connection *con): m_manager("org.kde.networkmanagement",
"/org/kde/networkmanagement",
"org.kde.networkmanagement",
QDBusConnection::sessionBus())
{
bool addConnection = true;
mSystemSettings = new NMDBusSettingsConnectionProvider(0, 0);
......@@ -53,6 +57,7 @@ ManageConnection::ManageConnection(Knm::Connection *con)
if (addConnection) {
connect(mSystemSettings, SIGNAL(addConnectionCompleted(bool, const QString &)), SLOT(addConnectionCompleted(bool, const QString &)));
connect(&m_manager, SIGNAL(ActivatableAdded(QString, uint)), this, SLOT(activatableAdded(QString, uint)));
mSystemSettings->addConnection(con);
}
}
......@@ -77,8 +82,27 @@ void ManageConnection::addConnectionCompleted(bool valid, const QString &errorMe
KMessageBox::error(0, i18n("Connection create operation failed."));
else
KMessageBox::error(0, errorMessage);
deleteLater();
kapp->quit();
}
}
void ManageConnection::activatableAdded(QString path, uint type)
{
QDBusInterface activatable("org.kde.networkmanagement",
path,
"org.kde.networkmanagement.Activatable",
QDBusConnection::sessionBus());
if (!activatable.isValid()) {
goto OUT;
}
// Activate the connection. This step is required to make hidden wifi networks work.
activatable.call("activate");
OUT:
deleteLater();
kapp->quit();
}
......
......@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QDBusInterface>
#include <KApplication>
#include "nmdbussettingsconnectionprovider.h"
......@@ -34,6 +36,8 @@ public:
private Q_SLOTS:
void addConnectionCompleted(bool valid, const QString &errorMessage);
void updateConnectionCompleted();
void activatableAdded(QString, uint);
private:
NMDBusSettingsConnectionProvider * mSystemSettings;
QDBusInterface m_manager;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment