Re: dbus-send examples

2010-02-15 Thread Dan Williams
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


___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: dbus-send examples

2010-02-13 Thread Jaša Bartelj
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.

Can anyone post an example or clarify what this is exactly? Thanks!

Here are a few script snippets I'm writing:


NM="org.freedesktop.NetworkManager"
NM_DEVICES=$(dbus-send --print-reply --system --dest=$NM \
/org/freedesktop/NetworkManager $NM.GetDevices|grep Device|cut -c19-)
NM_CONNECTIONS=$(dbus-send --system --print-reply --type=method_call \
--dest=$NM'UserSettings' '/org/freedesktop/NetworkManagerSettings' \
$NM'Settings.ListConnections'|grep object|cut -c19-)
GSM_MODEM_NAME=0
GSM_CONN_NAME=0

# get reference to GSM modem
for DEV in $NM_DEVICES
do
DEV=$(echo $DEV |sed s:\"::g)
NM_DEVICE_TYPE=$(dbus-send --print-reply --system \
--dest=$NM $DEV org.freedesktop.DBus.Properties.Get \
string:"$NM.Device" string:"DeviceType"|tail -n1|cut -c25- )
if [ $NM_DEVICE_TYPE -eq 3 ]
then
GSM_MODEM_NAME=$DEV
break
fi
done
if [ $GSM_MODEM_NAME == 0 ]
then
echo "Too bad, mobile broadband modem not found!"
exit 2
fi
# get reference to GSM Connection Settings
for CONN in $NM_CONNECTIONS
do
CONN=$(echo $CONN |sed s:\"::g)
dbus-send --system --print-reply \
--dest=$NM'UserSettings' $CONN  $NM'Settings.Connection.GetSettings' \
|grep -q internet.simobil.si
if [ $? -eq 0 ]
then
GSM_CONN_NAME=$CONN
break
fi
done
if [ $GSM_CONN_NAME == 0 ]
then
echo "Too bad, no settings for mobile broadband found!"
exit 3
fi
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: dbus-send examples

2010-01-24 Thread 代尔欣
Hi,
I paste some I ever used. Hope can help you.
It's base on the NM0.7.0

echo "GetDevices"
dbus-send --system --print-reply --reply-timeout=12 --type=method_call
--dest='org.freedesktop.NetworkManager' '/org/freedesktop/NetworkManager'
org.freedesktop.NetworkManager.GetDevices

echo "ActivateConnection"
echo "service name:$1"
echo "connection path:$2"
echo "device object path:$3"
dbus-send --system --print-reply --reply-timeout=12 --type=method_call
--dest='org.freedesktop.NetworkManager' '/org/freedesktop/NetworkManager'
org.freedesktop.NetworkManager.ActivateConnection string:"$1" objpath:"$2"
objpath:"$3"

echo "DeactivateConnection"
echo "active connection:$1"
dbus-send --system --print-reply --reply-timeout=12 --type=method_call
--dest='org.freedesktop.NetworkManager' '/org/freedesktop/NetworkManager'
org.freedesktop.NetworkManager.DeactivateConnection objpath:$1


echo "Sleep"
dbus-send --system --print-reply --reply-timeout=12 --type=method_call
--dest='org.freedesktop.NetworkManager' '/org/freedesktop/NetworkManager'
org.freedesktop.NetworkManager.Sleep boolean:$2

echo "Get org.freedesktop.NetworkManager Property"
echo "Interface:$2 property:$3"
dbus-send --system --print-reply --reply-timeout=12 --type=method_call
--dest='org.freedesktop.NetworkManager' /org/freedesktop/NetworkManager
org.freedesktop.DBus.Properties.Get string:"$2" string:"$3"

echo "List user connections"
dbus-send --system --print-reply --reply-timeout=12 --type=method_call
--dest='org.freedesktop.NetworkManagerUserSettings'
'/org/freedesktop/NetworkManagerSettings'
org.freedesktop.NetworkManagerSettings.ListConnections

echo "List system connections"
dbus-send --system --print-reply --reply-timeout=12 --type=method_call
--dest='org.freedesktop.NetworkManagerSystemSettings'
'/org/freedesktop/NetworkManagerSettings'
org.freedesktop.NetworkManagerSettings.ListConnections

2010/1/22 Kiran Bhat 

> Hi
>   is there any dbus-send Api  examples for Network manager.
>
> regards
> kiran
>
> --
> The INTERNET now has a personality. YOURS! See your Yahoo! 
> Homepage
> .
>
> ___
> NetworkManager-list mailing list
> NetworkManager-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list
>
>
___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


dbus-send examples

2010-01-22 Thread Kiran Bhat
Hi 
  is there any dbus-send Api  examples for Network manager.

regards
kiran



  Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! 
http://downloads.yahoo.com/in/internetexplorer/___
NetworkManager-list mailing list
NetworkManager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list