Re: dbus-send examples



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


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