summaryrefslogtreecommitdiffstats
path: root/tdenetworkmanager/src/knetworkmanager-menuitem.cpp
blob: 927f1ae0c17de1ff208f5fd79dbaae10ddad62e2 (plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/***************************************************************************
 *
 * knetworkmanager-menuitem.cpp - A NetworkManager frontend for KDE
 *
 * 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
 *
 **************************************************************************/

#include "knetworkmanager-menuitem.h"

#include <tqevent.h>
#include <tqguardedptr.h>
#include <tqvbox.h>
#include <tqlayout.h>
#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:
		NetworkMenuItemPrivate(TDENetworkDevice* device, TDENetworkConnection* connection)
		: dev(device), conn(connection)
		{

		}
		~NetworkMenuItemPrivate() {}
	
		TQGuardedPtr<TDENetworkDevice> dev;
		TQGuardedPtr<TDENetworkConnection> conn;
};

void NetworkMenuItem::slotActivate()
{
	kdDebug() << "NetworkMenuItem::slotActivate()" << endl;

	TDEGlobalNetworkManager* nm = KGlobal::networkManager();

	if (d->dev && d->conn)
	{
		TDENetworkConnectionManager* deviceConnMan = d->dev->connectionManager();
		if (deviceConnMan)
		{
			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());

			TDENetworkConnectionStatus::TDENetworkConnectionStatus result = deviceConnMan->initiateConnection(d->conn->UUID);
			if ((result == TDENetworkConnectionStatus::Disconnected)
				|| (result == TDENetworkConnectionStatus::Invalid)) {
				//
			}
			else {
				kdDebug() << "ActivateDevice failed" << endl;
			}
		}
	}
	else if (d->conn)
	{
		// no device given, just take the default device
		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;
		}
	}
	else
		kdDebug() << "Device or Connection invalid" << endl;
}

NetworkMenuItem::NetworkMenuItem (TDENetworkDevice* dev, TDENetworkConnection* conn, TQObject* parent, const char* name)
		       : TQObject(parent, name)
{
	d = new NetworkMenuItemPrivate(dev, conn);
}

NetworkMenuItem::~NetworkMenuItem ()
{
	delete d;
}



#include "knetworkmanager-menuitem.moc"