~fenryxo/nuvola-player/master

« back to all changes in this revision

Viewing changes to src/nuvolakit-runner/components/scrobbler/LastfmCompatibleScrobbler.vala

  • Committer: Jiří Janoušek
  • Date: 2019-02-23 17:15:18 UTC
  • Revision ID: git-v1:7175c72e92b7ed304827dd9c161d66abc35010a4
Move generic LastfmCompatibleScrobber API to parent class

Issue: tiliado/nuvolaruntime#17

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2014-2018 Jiří Janoušek <janousek.jiri@gmail.com>
 
2
 * Copyright 2014-2019 Jiří Janoušek <janousek.jiri@gmail.com>
3
3
 *
4
4
 * Redistribution and use in source and binary forms, with or without
5
5
 * modification, are permitted provided that the following conditions are met:
29
29
    public const string HTTP_POST = "POST";
30
30
 
31
31
    public string? session {get; protected set; default = null;}
32
 
    public bool has_session { get { return session != null; }}
33
 
    public string? username { get; protected set; default = null;}
 
32
    public override bool has_session { get { return session != null; }}
34
33
    private Soup.Session connection;
35
34
    private string api_key;
36
35
    private string api_secret;
63
62
     * @return authorization URL
64
63
     * @throws AudioScrobblerError on failure
65
64
     */
66
 
    public async string request_authorization() throws AudioScrobblerError {
 
65
    public override async string request_authorization() throws AudioScrobblerError {
67
66
        // http://www.last.fm/api/show/auth.getToken
68
67
        const string API_METHOD = "auth.getToken";
69
68
        var params = new HashTable<string, string>(str_hash, str_equal);
90
89
     *
91
90
     * @throws AudioScrobblerError on failure
92
91
     */
93
 
    public async void finish_authorization() throws AudioScrobblerError {
 
92
    public override async void finish_authorization() throws AudioScrobblerError {
94
93
        // http://www.last.fm/api/show/auth.getSession
95
94
        const string API_METHOD = "auth.getSession";
96
95
        var params = new HashTable<string, string>(str_hash, str_equal);
124
123
        token = null;
125
124
    }
126
125
 
127
 
    public void drop_session() {
 
126
    public override void drop_session() {
128
127
        session = null;
129
128
        username = null;
130
129
    }
131
130
 
132
 
    public async void retrieve_username() throws AudioScrobblerError {
 
131
    public override async void retrieve_username() throws AudioScrobblerError {
133
132
        const string API_METHOD = "user.getInfo";
134
133
        if (session == null) {
135
134
            throw new AudioScrobblerError.NO_SESSION("%s %s: There is no authorized session.", id, API_METHOD);