~elementary-pantheon/poa-eds-bridge/say-were-desktop

« back to all changes in this revision

Viewing changes to src/GSignonSessionOAuth.vala

  • Committer: Corentin Noël
  • Date: 2014-08-30 22:14:37 UTC
  • Revision ID: corentin@elementaryos.org-20140830221437-q6fc566erxfntsis
Remove Source if Account is removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    }
8
8
 
9
9
    public override E.AuthenticationSessionResult execute_sync (GLib.Cancellable? cancellable = null) throws GLib.Error {
10
 
        warning ("");
11
 
        return E.AuthenticationSessionResult.ERROR;
 
10
        var loop = new MainLoop ();
 
11
        E.AuthenticationSessionResult? result = null;
 
12
        execute.begin (GLib.Priority.DEFAULT, cancellable, (obj, res) => {
 
13
            execute.end (res);
 
14
            result = (E.AuthenticationSessionResult)res;
 
15
            loop.quit ();
 
16
        });
 
17
 
 
18
        loop.run ();
 
19
        if (result != null)
 
20
            return result;
 
21
        else
 
22
            return E.AuthenticationSessionResult.ERROR;
12
23
    }
13
24
 
14
25
    public override async E.AuthenticationSessionResult execute (int io_priority, GLib.Cancellable? cancellable = null) throws GLib.Error {
15
26
        var authenticator = get_authenticator ();
16
 
        var source = get_server ().ref_source (get_source_uid ());
 
27
        /*var source = get_server ().ref_source (get_source_uid ());
17
28
        if (source == null) {
18
29
            throw new IOError.NOT_FOUND (_("No such data source for UID '%s'"), get_source_uid ());
19
30
        }
25
36
            /* Hard-code the method and mechanism names.  If they disagree
26
37
             * with AgAuthData then hopefully the signon process will fail
27
38
             * with a suitable error message. */
28
 
            var auth_session = new Signon.AuthSession (auth_data.get_credentials_id (), "oauth");
 
39
            /*var auth_session = new Signon.AuthSession (auth_data.get_credentials_id (), "oauth");
29
40
            auth_session.state_changed.connect ((session, state, msg) => {message (msg);});
30
41
            var session_data = yield auth_session.process_async (auth_data.get_login_parameters (source), "", cancellable);
31
42
            var secret = session_data.lookup_value ("AccessToken", VariantType.STRING);
37
48
            yield authenticator.try_password (string_builder, cancellable);
38
49
        } catch (Error e) {
39
50
            throw e;
40
 
        }
 
51
        }*/
41
52
 
42
53
        return E.AuthenticationSessionResult.ERROR;
43
54
    }