summaryrefslogtreecommitdiff
path: root/tests/libtracker-miner/tracker-miner-mock.vala
blob: 302a3387b5160eb19196a9e0d085b0cbe91d4858 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// Copyright (C) 2010, Nokia
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301, USA.
//

using GLib;

public class TrackerMinerMock : GLib.Object {

    public bool is_paused ;
    public string pause_reason { get; set; default = ""; }
    public string name { get; set; default = ""; } 
    public string[] apps { get { return _apps; } }
    public string[] reasons { get { return _apps; } }

    public signal void progress (string miner, string status, double progress);
    public signal void paused ();
    public signal void resumed ();

    string[] _apps;
    string[] _reasons;

    public TrackerMinerMock (string name) {
        this.name = name;
        this._apps = {};
        this._reasons = {};
    }

    public void set_paused (bool paused) { this.is_paused = paused; }
    public bool get_paused () { return this.is_paused ; }

    public void pause (string app, string reason) {

        if (this._apps.length == 0) {
            this._apps = { app };
        } else {
            this._apps += app;
        }

        if (this._reasons.length == 0) {
            this._reasons = { reason };
        } else {
            this._reasons += reason;
        }
        this.is_paused = true;
        this.paused ();
    }

    public void resume () {
        this._apps = null;
        this._reasons = null;
        this.is_paused = false;
        this.resumed ();
    }

}