Bug 25035 - Add API to AccountManager to get a list of Account objects, all ready.
Summary: Add API to AccountManager to get a list of Account objects, all ready.
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-qt (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: Andre Moreira Magalhaes
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-11 07:22 UTC by Will Thompson
Modified: 2010-07-01 17:17 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Will Thompson 2009-11-11 07:22:38 UTC
I keep assuming when giving examples of how to use TpQt4 that, given a ready Tp::AccountManager, you can get a list of Tp::Accounts corresponding to ValidAccounts, all of which are ready. But currently, you have to iterate am->validAccounts, constructing a Tp::Account for each one, wait for them all to become ready, and only then do whatever you wanted to do in the first place.

You need to make sure you cope correctly with an account being deleted while you wait. While it's not rocket science, it's something people will get wrong, and this is something the binding should do for us.

Potential API for this would need a way to say what features you want to be ready on the list of Tp::Accounts. I guess this is why it's non-trivial. I can think of two ways the API could work off-hand:

• Add a Feature to Tp::AM saying that you want it to keep the Tp::Accounts ready for you, and an extra argument to becomeReady to say which features you want ready on those Tp::Accounts. Then, make am->validAccounts() and friends on a Tp::AM with FeatureReadyAccounts enabled always give you ready accounts back.

• Add am->prepareValidAccounts(AccountFeatures f), an asynchronous operation.

I think the former would make life easier for the programmer. Compare:

    mAM = Tp::AccountManager::create();
    connect(mAM->becomeReady(Tp::AccountManager::FeatureReadyAccounts,
                Tp::Account::FeatureProtocolInfo),
            SIGNAL(finished(Tp::PendingOperation *)),
            SLOT(onAMReady(Tp::PendingOperation *)));

  void onAMReady(...) {
      QList<AccountPtr> accounts = mAM->validAccounts();
      // do whatever you wanted to do
  }

to:

    mAM = Tp::AccountManager::create();
    connect(mAM->becomeReady(),
            SIGNAL(finished(Tp::PendingOperation *)),
            SLOT(onAMReady(Tp::PendingOperation *)));

  void onAMReady(...) {
      connect(mAM->prepareValidAccounts(),
            SIGNAL(finished(Tp::PendingOperation *)),
            SLOT(onAccountsReady(Tp::PendingOperation *)));
  }

  void onAccountsReady(...) {
      // do whatever you wanted to do
  }
Comment 1 Will Thompson 2010-06-25 02:32:29 UTC
Hey, let's re-purpose this bug for André's account-improvements branch, which makes the AM only ever return ready accounts.
Comment 2 Will Thompson 2010-07-01 08:25:14 UTC
This was merged, and will be in 0.3.6!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.