Re: dbus-send examples



On Sat, 2010-02-13 at 15:13 +0100, Jaša Bartelj wrote:
> Thank you very much, 代尔欣! Being new to D-Bus this helps a lot.
> 
> Unfortunately figuring out the correct parameters for the calls is
> quite difficult because there are no examples.
> 
> In interface "org.freedesktop.NetworkManager" the method
> "ActivateConnection" has 3 parameters (string, object,object or soo,
> see spec http://projects.gnome.org/NetworkManager/developers/spec-08.html#org.freedesktop.NetworkManager).
> I figured out how to query NetworkManager for the latter two arguments
> but I'm at a loss what the service-name parameter should be.

Connections (profiles, configurations, etc) are a collection of all the
settings needed to connect to a specific network, like a 3G network, a
specific wifi network, etc.  Connections are provided by Settings
Services, of which there are two: user & system.

http://live.gnome.org/NetworkManagerConfiguration

(see "Settings Services")

The system settings service runs in system context (ie, as root) and
because of that, the connections it provides are available to all users.
User settings services (nm-applet, knetworkmanager, etc) run in a user's
login session, and because of that, the connections they provide are
only usable by that user, not by other users.

So the answer to your question depends on what settings service provides
the connection you want to make NetworkManager apply to the device
you're about to activate.  When you know that, you pass that
connection's D-Bus object path (as provided by the settings service that
exports it) and that settings service name to NetworkManager.

So if you know the UUID of the connection you want to connect, you do
something like this (pseudo-code):

my_uuid = "8c47de32-cc4a-437d-b340-ccdd1ccb3073"

my_connection_path = NULL
my_service = NULL

# maybe the connection we're looking for is
# provided by the system settings service
for each connection exported by org.freedesktop.NetworkManagerSystemSettings:
    if this connection's UUID == my_uuid:
        my_connection_path = this connection D-Bus object path
        my_service = "org.freedesktop.NetworkManagerSystemSettings"

# or maybe it's provided by the user settings service
if not my_connection:
    for each connection exported by org.freedesktop.NetworkManagerUserSettings:
        if this connection's UUID == my_uuid:
            my_connection_path = this connection D-Bus object path
            my_service = "org.freedesktop.NetworkManagerUserSettings"

org.freedesktop.NetworkManager.ActivateConnection (my_service, my_connection_path, ...)

> Can anyone post an example or clarify what this is exactly? Thanks!
> 
> Here are a few script snippets I'm writing:

Python is actually a *lot* easier for this :)

Dan




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]