summaryrefslogtreecommitdiff
path: root/src/plugins/StandardHostInterface.vala
blob: 857c8ff7d6cee97509d9f791cb34b53a39af5aca (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

namespace Plugins {

public class StandardHostInterface : Object, Spit.HostInterface {
    private string config_domain;
    private string config_id;
    private File module_file;
    private Spit.PluggableInfo info;
    
    public StandardHostInterface(Spit.Pluggable pluggable, string config_domain) {
        this.config_domain = config_domain;
        config_id = parse_key(pluggable.get_id());
        module_file = get_pluggable_module_file(pluggable);
        pluggable.get_info(ref info);
    }
    
    private static string parse_key(string id) {
        // special case: legacy plugins (Web publishers moved into SPIT) have special names
        // new plugins will use their full ID
        switch (id) {
            case "org.yorba.shotwell.publishing.facebook":
                return "facebook";
            
            case "org.yorba.shotwell.publishing.picasa":
                return "picasa";
            
            case "org.yorba.shotwell.publishing.flickr":
                return "flickr";
                
            case "org.yorba.shotwell.publishing.youtube":
                return "youtube";

            default:
                return id;
        }
    }
    
    public File get_module_file() {
        return module_file;
    }
    
    public bool get_config_bool(string key, bool def) {
        return Config.Facade.get_instance().get_plugin_bool(config_domain, config_id, key, def);
    }
    
    public void set_config_bool(string key, bool val) {
        Config.Facade.get_instance().set_plugin_bool(config_domain, config_id, key, val);
    }
    
    public int get_config_int(string key, int def) {
        return Config.Facade.get_instance().get_plugin_int(config_domain, config_id, key, def);
    }
    
    public void set_config_int(string key, int val) {
        Config.Facade.get_instance().set_plugin_int(config_domain, config_id, key, val);
    }
    
    public string? get_config_string(string key, string? def) {
        return Config.Facade.get_instance().get_plugin_string(config_domain, config_id, key, def);
    }
    
    public void set_config_string(string key, string? val) {
        Config.Facade.get_instance().set_plugin_string(config_domain, config_id, key, val);
    }
    
    public double get_config_double(string key, double def) {
        return Config.Facade.get_instance().get_plugin_double(config_domain, config_id, key, def);
    }
    
    public void set_config_double(string key, double val) {
        Config.Facade.get_instance().set_plugin_double(config_domain, config_id, key, val);
    }
    
    public void unset_config_key(string key) {
        Config.Facade.get_instance().unset_plugin_key(config_domain, config_id, key);
    }
}

}