You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.7 KiB
124 lines
3.7 KiB
13 years ago
|
/***************************************************************************
|
||
|
*
|
||
12 years ago
|
* tdenetman-menuitem.cpp - A NetworkManager frontend for KDE
|
||
13 years ago
|
*
|
||
|
* Copyright (C) 2005, 2006, 2008 Novell, Inc.
|
||
|
*
|
||
|
* Author: Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||
|
* Will Stephenson <wstephenson@suse.de>, <wstephenson@kde.org>
|
||
|
* Valentine Sinitsyn <e_val@inbox.ru>
|
||
|
* Helmut Schaa <hschaa@suse.de>, <helmut.schaa@gmx.de>
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation; either version 2 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
|
*
|
||
|
**************************************************************************/
|
||
|
|
||
12 years ago
|
#include "tdenetman-menuitem.h"
|
||
13 years ago
|
|
||
|
#include <tqevent.h>
|
||
|
#include <tqguardedptr.h>
|
||
|
#include <tqvbox.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
13 years ago
|
#include <tqpushbutton.h>
|
||
|
#include <tqpixmap.h>
|
||
|
#include <tqpixmapcache.h>
|
||
|
#include <tqpainter.h>
|
||
|
#include <tqstyle.h>
|
||
|
#include <dcopclient.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kdialogbase.h>
|
||
|
#include <knotifyclient.h>
|
||
|
#include <knotifydialog.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kstdguiitem.h>
|
||
|
#include <khelpmenu.h>
|
||
|
#include <kprocess.h>
|
||
|
#include <kiconloader.h>
|
||
|
#include <kconfig.h>
|
||
|
#include <kmessagebox.h>
|
||
|
|
||
|
using namespace ConnectionSettings;
|
||
|
|
||
|
class NetworkMenuItemPrivate
|
||
|
{
|
||
|
public:
|
||
12 years ago
|
NetworkMenuItemPrivate(TDENetworkDevice* device, TDENetworkConnection* connection)
|
||
13 years ago
|
: dev(device), conn(connection)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
~NetworkMenuItemPrivate() {}
|
||
|
|
||
12 years ago
|
TQGuardedPtr<TDENetworkDevice> dev;
|
||
|
TQGuardedPtr<TDENetworkConnection> conn;
|
||
13 years ago
|
};
|
||
|
|
||
|
void NetworkMenuItem::slotActivate()
|
||
|
{
|
||
|
kdDebug() << "NetworkMenuItem::slotActivate()" << endl;
|
||
12 years ago
|
|
||
|
TDEGlobalNetworkManager* nm = KGlobal::networkManager();
|
||
13 years ago
|
|
||
|
if (d->dev && d->conn)
|
||
|
{
|
||
12 years ago
|
TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
|
||
|
if (deviceConnMan)
|
||
13 years ago
|
{
|
||
12 years ago
|
kdDebug() << "Activate Connection " << d->conn->UUID.ascii() << " on Device " << d->dev->deviceNode().ascii() << endl;
|
||
|
printf("Activate Connection %s on Device %s\n\r", d->conn->UUID.ascii(), d->dev->deviceNode().ascii());
|
||
13 years ago
|
|
||
12 years ago
|
TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(d->conn->UUID);
|
||
|
if ((result == TDENetworkConnectionStatus::Disconnected)
|
||
|
|| (result == TDENetworkConnectionStatus::Invalid)) {
|
||
|
//
|
||
13 years ago
|
}
|
||
12 years ago
|
else {
|
||
13 years ago
|
kdDebug() << "ActivateDevice failed" << endl;
|
||
12 years ago
|
}
|
||
13 years ago
|
}
|
||
|
}
|
||
|
else if (d->conn)
|
||
|
{
|
||
|
// no device given, just take the default device
|
||
12 years ago
|
printf("Activate Connection %s on default device\n\r", d->conn->UUID.ascii());
|
||
|
|
||
|
TDENetworkConnectionStatus::TDENetworkConnectionStatus result = nm->initiateConnection(d->conn->UUID);
|
||
|
if ((result == TDENetworkConnectionStatus::Disconnected)
|
||
|
|| (result == TDENetworkConnectionStatus::Invalid)) {
|
||
|
//
|
||
|
}
|
||
|
else {
|
||
|
kdDebug() << "ActivateConnection failed" << endl;
|
||
|
}
|
||
13 years ago
|
}
|
||
|
else
|
||
|
kdDebug() << "Device or Connection invalid" << endl;
|
||
|
}
|
||
|
|
||
12 years ago
|
NetworkMenuItem::NetworkMenuItem (TDENetworkDevice* dev, TDENetworkConnection* conn, TQObject* parent, const char* name)
|
||
13 years ago
|
: TQObject(parent, name)
|
||
|
{
|
||
|
d = new NetworkMenuItemPrivate(dev, conn);
|
||
|
}
|
||
|
|
||
|
NetworkMenuItem::~NetworkMenuItem ()
|
||
|
{
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
12 years ago
|
#include "tdenetman-menuitem.moc"
|