blob: 64d6a6da508bf7f1e0e0a11932588b4c0a9113e1 (
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
|
/*
* Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
using Folks;
public class Contacts.UnlinkOperation : Operation {
private weak Store store;
private Individual individual;
private Gee.HashSet<Persona> personas = new Gee.HashSet<Persona> ();
private bool _reversable = false;
public override bool reversable { get { return this._reversable; } }
private string _description;
public override string description { owned get { return this._description; } }
public UnlinkOperation (Store store, Individual main) {
this.store = store;
this.individual = main;
this._description = _("Unlinking contacts");
}
/* Remove a personas from individual */
public override async void execute () throws GLib.Error {
foreach (var persona in this.individual.personas)
this.personas.add (persona);
yield store.aggregator.unlink_individual (this.individual);
this._reversable = true;
notify_property ("reversable");
}
/* Undo the unlinking */
public override async void _undo () throws GLib.Error {
yield this.store.aggregator.link_personas (personas);
this._reversable = false;
notify_property ("reversable");
}
}
|