-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathUtils.vala
More file actions
79 lines (66 loc) · 2.8 KB
/
Copy pathUtils.vala
File metadata and controls
79 lines (66 loc) · 2.8 KB
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
// 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 3 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/>.
//
namespace Maya.Util {
public int compare_events (ECal.Component comp1, ECal.Component comp2) {
var res = comp1.get_icalcomponent ().get_dtstart ().compare (comp2.get_icalcomponent ().get_dtstart ());
if (res != 0)
return res;
// If they have the same date, sort them alphabetically
return comp1.get_summary ().get_value ().collate (comp2.get_summary ().get_value ());
}
/*
* E.Source Utils
*/
public string get_source_location (E.Source source) {
var registry = Calendar.EventStore.get_default ().registry;
string parent_uid = source.parent;
E.Source parent_source = source;
while (parent_source != null) {
parent_uid = parent_source.parent;
if (parent_source.has_extension (E.SOURCE_EXTENSION_AUTHENTICATION)) {
var collection = (E.SourceAuthentication)parent_source.get_extension (E.SOURCE_EXTENSION_AUTHENTICATION);
if (collection.user != null) {
return collection.user;
}
}
if (parent_source.has_extension (E.SOURCE_EXTENSION_COLLECTION)) {
var collection = (E.SourceCollection)parent_source.get_extension (E.SOURCE_EXTENSION_COLLECTION);
if (collection.identity != null) {
return collection.identity;
}
}
if (parent_uid == null)
break;
parent_source = registry.ref_source (parent_uid);
}
if (source.parent == "webcal-stub") {
return _("On the web");
}
return _("On this computer");
}
public ECal.Component? copy_ecal_component (ECal.Component? original) {
if (original == null) {
return null;
}
ECal.Component copy = original.clone ();
E.Source source = original.get_data<E.Source> ("source");
copy.set_data<E.Source> ("source", source);
return copy;
}
public string mangle_uid (string original_uid) {
/* For now just reverse the uid */
var result = original_uid.dup ();
return result.reverse ();
}
}