const MainLoop = imports.mainloop;
const Tp = imports.gi.TelepathyGLib;
const GLib = imports.gi.GLib;
const Lang = imports.lang;

function statusChangedCb() {
  print("statusChangedCb called!");
}

function readyCb(manager, result, user_data) {
  if (!manager.prepare_finish(result)) {
    return;
  }

  accountList = _tpAccountManager.get_valid_accounts();
  for each (var account in accountList) {
    account.connect("status-changed", Lang.bind(this, statusChangedCb));
    print (account);
  }
  print ("ready.");
}

loop = new GLib.MainLoop();

_tpAccountManager = Tp.AccountManager.dup();
_tpAccountManager.prepare_async(null, readyCb, null);

MainLoop.run('');

