~danielholm/+junk/lastfm-online-account

« back to all changes in this revision

Viewing changes to account-creation.py

  • Committer: DanielHolm
  • Date: 2014-01-31 20:09:39 UTC
  • Revision ID: d.holmen@gmail.com-20140131200939-5bpr8vw3btzw8akw
Initial code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from gi.repository import Accounts
 
2
 
 
3
manager = Accounts.Manager.new_for_service_type("scrobbling")
 
4
 
 
5
# Monitor the creation/deletion/enabling of accounts
 
6
def on_enabled_event(manager, account_id):
 
7
    account = manager.load_account(account_id)
 
8
    for service in account.list_services():
 
9
        account_service = Accounts.AccountService.new(account, service)
 
10
        if account_service.get_enabled():
 
11
            # handle the account
 
12
            pass
 
13
manager.connect("enabled-event", on_enabled_event)
 
14
 
 
15
# Get the list of all the enabled accounts which support the
 
16
# "scrobbling" service type
 
17
for account_service in manager.get_enabled_account_services():
 
18
    display_name = account_service.get_account().get_display_name()
 
19
    provider_name = account_service.get_account().get_provider_name()
 
20
    service_name = account_service.get_service().get_name()
 
21
    print("Account %s - provider %s, service %s" %
 
22
        (display_name, provider_name, service_name))
 
 
b'\\ No newline at end of file'