Debian Codegraph @

src/models/unsupported.js

raw
1 /* exported FlatpakUnsupportedModel */
2 /* eslint class-methods-use-this: */
3
4 /* unsupported.js
5 *
6 * Copyright 2020 Martin Abente Lahaye
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 const {GObject} = imports.gi;
23
24
25 var FlatpakUnsupportedModel = GObject.registerClass({
26 GTypeName: 'FlatpakUnsupportedModel',
27 }, class FlatpakUnsupportedModel extends GObject.Object {
28 _init() {
29 super._init();
30 this.reset();
31 }
32
33 getPermissions() {
34 return {};
35 }
36
37 static getGroup() {
38 return 'unsupported';
39 }
40
41 static getKey() {
42 return null;
43 }
44
45 getOptions() { // eslint-disable-line class-methods-use-this
46 return null;
47 }
48
49 updateFromProxyProperty() { // eslint-disable-line class-methods-use-this
50 return false;
51 }
52
53 updateStatusProperty() {
54
55 /* does not apply to this backend */
56 }
57
58 updateProxyProperty() { // eslint-disable-line class-methods-use-this
59 return false;
60 }
61
62 loadFromKeyFile(group, key, value) {
63 this._permissions.add([group, key, value]);
64 return true;
65 }
66
67 saveToKeyFile(keyFile) {
68 this._permissions.forEach(([group, key, value]) => {
69 let _value;
70
71 try {
72 const existing = keyFile.get_value(group, key);
73 _value = `${value};${existing}`;
74 } catch (err) {
75 _value = `${value}`;
76 }
77
78 keyFile.set_value(group, key, _value);
79 });
80 }
81
82 reset() {
83 this._permissions = new Set();
84 }
85
86 isEmpty() {
87 return this._permissions.size === 0;
88 }
89 });