tracker-miner-mock.vala 2.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
//
// 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.
//

20 21 22 23 24 25 26
using GLib;

public class TrackerMinerMock : GLib.Object {

    public bool is_paused ;
    public string pause_reason { get; set; default = ""; }
    public string name { get; set; default = ""; } 
27 28
    public string[] apps { get { return _apps; } }
    public string[] reasons { get { return _apps; } }
29 30 31 32 33

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

34 35 36
    string[] _apps;
    string[] _reasons;

37 38
    public TrackerMinerMock (string name) {
        this.name = name;
39 40
        this._apps = {};
        this._reasons = {};
41 42 43 44 45 46 47
    }

    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) {

48 49
        if (this._apps.length == 0) {
            this._apps = { app };
50
        } else {
51
            this._apps += app;
52 53
        }

54 55
        if (this._reasons.length == 0) {
            this._reasons = { reason };
56
        } else {
57
            this._reasons += reason;
58 59 60 61 62 63
        }
        this.is_paused = true;
        this.paused ();
    }

    public void resume () {
64 65
        this._apps = null;
        this._reasons = null;
66 67 68 69
        this.is_paused = false;
        this.resumed ();
    }

70
}