diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2012-08-30 11:14:30 +0200 |
---|---|---|
committer | Sjoerd Simons <sjoerd@luon.net> | 2012-08-30 11:14:30 +0200 |
commit | 0521cf411207ff672552aad038199f11d5351b39 (patch) | |
tree | 16af5f0c9b18983f2252ef8d9632cbe6300be01e | |
parent | 5be35463770005db0b40c51f4b6bb4903792e29b (diff) |
Add utilities to add an account
-rw-r--r-- | src/util.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util.py b/src/util.py index 6b9a7e9..ebd7c79 100644 --- a/src/util.py +++ b/src/util.py @@ -65,3 +65,25 @@ def setup_run_dir (path): override_env ("XDG_DATA_HOME", os.path.join (path, ".local")) override_env ("MC_ACCOUNT_DIR", os.path.join (path, ".config", "mission-control", "accounts")) + +def got_account_cb (o, r, password, func): + account = o.create_account_finish (r) + # Put the password in our credentials store + try: + os.makedirs (os.path.join (GLib.get_user_config_dir (), "phoenix")) + except: + pass + authfile = os.path.join (GLib.get_user_config_dir (), "phoenix", "auth") + f = open (authfile, "a+") + f.write (account.get_path_suffix() + " " + password + "\n") + + func(account) + +def create_account (am, cm, protocol, name, parameters, password, func): + request = Tp.AccountRequest.new (am, cm, protocol, name) + for k,v in parameters.items(): + request.set_parameter (k, v) + + request.create_account_async ( + lambda o, r, u: got_account_cb (o, r, password, func), + None) |