Ubuntu logo

Developer

  • QML
  • SDK 1.0
  • Ubuntu.OnlineAccounts
  • › AccountServiceModel
  • Search API:

    AccountServiceModel

    A model of the user's Online Accounts More...

    Properties

    Detailed Description

    The AccountServiceModel is a model representing the user's Online Accounts services. Please note that an Online Account can offer several different services (chat, e-mail, micro-blogging, etc.); these are the items represented by this model, and not the user accounts as a whole. Since most applications are interested on a small subset of the user's accounts, AccountServiceModel offers some filtering functionalities: it is possible to restrict it to only one account provider, to a specific service type (for instance, an e-mail application will probably be interested in only those accounts which offer an e-mail service), or to a specific service (e.g., picasa; this is often equivalent to filtering by provider and by service-type, because it's rare for a provider to offer two different services of the same type). By default, only enabled accounts are returned. Use the includeDisabled property to list also disabled accounts; keep in mind, though, that an application should never use an account which has been disabled by the user.

    The model defines the following roles:

    • displayName is the name of the account (usually the user's login)
    • providerName is the name of the account provider (e.g., "Google")
    • serviceName is the name of the service (e.g., "Picasa")
    • enabled
    • accountServiceHandle is a handle to the underlying Qt object which can be used to instantiate an AccountService from QML
    • accountId is the numeric ID of the account
    • accountHandle is a handle to the underlying Qt object which can be used to instantiate an Account from QML

    Examples of use:

    1. Model of all enabled microblogging accounts:

    Item {
        AccountServiceModel {
            id: accounts
            serviceType: "microblogging"
        }
        ListView {
            model: accounts
            delegate: Text { text: model.displayName + " by " + model.providerName }
        }
    }

    2. List all Facebook account services:

    Item {
        AccountServiceModel {
            id: accounts
            provider: "facebook"
            includeDisabled: true
        }
        ListView {
            model: accounts
            delegate: Text { text: model.serviceName + " on " + model.displayName }
        }
    }

    3. List all Flickr accounts enabled for uploading:

    Item {
        AccountServiceModel {
            id: accounts
            service: "flickr-sharing"
        }
        ListView {
            model: accounts
            delegate: Rectangle {
                id: rect
                Text { text: rect.model.displayName }
                AccountService {
                    id: accountService
                    objectHandle: rect.model.accountServiceHandle
                    onAuthenticated: { console.log("Access token is " + reply.AccessToken) }
                    onAuthenticationError: { console.log("Authentication failed, code " + error.code) }
                }
                MouseArea {
                    anchors.fill: parent
                    onClicked: accountService.authenticate()
                }
            }
        }
    }

    4. List all the online accounts, without their services:

    Item {
        AccountServiceModel {
            id: accounts
            service: "global"
        }
        ListView {
            model: accounts
            delegate: Rectangle {
                id: rect
                Text { text: account.displayName }
                Account {
                    id: account
                    objectHandle: rect.model.accountHandle
                }
            }
        }
    }

    Property Documentation

    account : Account

    If set, the model will list only those accounts services available in the given account.


    accountId : quint32

    If set, the model will list only those accounts services available in the given account.


    includeDisabled : bool

    If true, even disabled account services will be listed. Note that an application should never use a disabled account.

    By default, this property is false.


    provider : string

    If set, the model will list only those accounts services provided by this provider.


    service : string

    If set, the model will list only those accounts services for this specific service.


    serviceType : string

    If set, the model will list only those accounts services supporting this service type. Each provider-specific service is an instance of a generic service type (such as "e-mail", "IM", etc.) which identifies the main functionality provided by the service.