Re: Switch Network Connections
- From: Jirka Klimes <jklimes redhat com>
- To: networkmanager-list gnome org
- Subject: Re: Switch Network Connections
- Date: Mon, 8 Nov 2010 09:33:54 +0100
On Monday 08 of November 2010 08:13:35 Jos Collin-ERS,HCLTech wrote:
> Hello,
>
> I have a wired and a wireless connections available in my computer. Both of
> them are configured in the NetworkManager. How can I programatically
> choose (or switch) to wired or wireless connection, using java?. After
> choosing a connection my computer should use that particular connection to
> access the Internet.
>
> I have searched in the NetworkManager spec, but didn't find anything useful
> for doing this.
> http://projects.gnome.org/NetworkManager/developers/spec.html
>
> By the way, what is ActivateConnection under
> org.freedesktop.NetworkManager? Will it do the job for me?
>
> Please suggest.
>
> Thanks,
> Jos Collin
NetworkManager provides a D-Bus interface to communicate with it. The API is
described by the link you provide, which is for version 0.7. For NM 0.8 use
http://projects.gnome.org/NetworkManager/developers/spec-08.html.
The ActivateConnection() is the right method to call for activating a
connection (connect to the Internet) by NM.
You can talk to D-Bus with a number of utilities and languages.
command-line tools: dbus-send, qdbus, ...
D-Dus GUI (debuggers): d-feet, qdbusviewer, ...
languages: python, C, Java, ...
Using dbus-send, the call would look like this:
dbus-send --system --print-reply --dest="org.freedesktop.NetworkManager"
/org/freedesktop/NetworkManager
"org.freedesktop.NetworkManager.ActivateConnection"
string:"org.freedesktop.NetworkManagerUserS
ettings" objpath:"/org/freedesktop/NetworkManagerSettings/34"
objpath:"/org/freedesktop/NetworkManager/Devices/1"
objpath:"/org/freedesktop/NetworkManager/AccessPoint/4"
You can find examples in C and python in NM source tree:
http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples
See also this thread:
http://old.nabble.com/Documentation-td28023791.html
For Java, you need to use java d-bus binding:
http://dbus.freedesktop.org/doc/dbus-java/
Jirka
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]