View Single Post
Posts: 7 | Thanked: 2 times | Joined on Apr 2010
#8
Originally Posted by Schturman View Post
.....
What I do is wrong ?
Thanks
Working versions of both scripts:
online
Code:
#!/usr/bin/env python

import dbus
import gobject

#NAMES
TP_ACCT_MGR = 'org.freedesktop.Telepathy.AccountManager'
TP_ACCT = 'org.freedesktop.Telepathy.Account'
DBUS_PROPS = 'org.freedesktop.DBus.Properties'

sessbus = dbus.SessionBus()
am_obj = sessbus.get_object(TP_ACCT_MGR,
                            '/org/freedesktop/Telepathy/AccountManager')
am_props = dbus.Interface(am_obj, DBUS_PROPS)

accounts = am_props.Get(TP_ACCT_MGR,
                            "ValidAccounts")
for path in accounts:
        if ("/org/freedesktop/Telepathy/Account/ring/tel/ring" == path):
            continue
        acct_obj = sessbus.get_object(TP_ACCT_MGR, path)
        acct_props = dbus.Interface(acct_obj, DBUS_PROPS)

        acct_props.Set(TP_ACCT,
                           "RequestedPresence",
                           dbus.Struct((dbus.UInt32(2),
                                        dbus.String(u"available"),
                                        dbus.String(u"") )) )
        acct_props.Set(TP_ACCT,
                           "ConnectAutomatically",
                           dbus.Boolean(True))
offline
Code:
#!/usr/bin/env python

import dbus
import gobject

#NAMES
TP_ACCT_MGR = 'org.freedesktop.Telepathy.AccountManager'
TP_ACCT = 'org.freedesktop.Telepathy.Account'
DBUS_PROPS = 'org.freedesktop.DBus.Properties'

sessbus = dbus.SessionBus()
am_obj = sessbus.get_object(TP_ACCT_MGR,
                            '/org/freedesktop/Telepathy/AccountManager')
am_props = dbus.Interface(am_obj, DBUS_PROPS)

accounts = am_props.Get(TP_ACCT_MGR,
                            "ValidAccounts")
for path in accounts:
        if ("/org/freedesktop/Telepathy/Account/ring/tel/ring" == path):
            continue
        acct_obj = sessbus.get_object(TP_ACCT_MGR, path)
        acct_props = dbus.Interface(acct_obj, DBUS_PROPS)

        acct_props.Set(TP_ACCT,
                           "RequestedPresence",
                           dbus.Struct((dbus.UInt32(2),
                                        dbus.String(u"available"),
                                        dbus.String(u"") )) )
        acct_props.Set(TP_ACCT,
                           "ConnectAutomatically",
                           dbus.Boolean(True))
Unexpected indent. This line of code has more spaces at the start than the one before, but the one before is not the start of a subblock (e.g. if/while/for statement). All lines of code in a block must start with exactly the same string of whitespace

But I'd still like to know how to set the presence, or status of the IM accounts. Any ideas?

Last edited by hillbicks; 2011-05-01 at 15:43.