-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathMessageListItem.vala
More file actions
670 lines (571 loc) · 25 KB
/
MessageListItem.vala
File metadata and controls
670 lines (571 loc) · 25 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
/*-
* Copyright (c) 2017 elementary LLC. (https://elementary.io)
*
* 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/>.
*
* Authored by: Corentin Noël <corentin@elementary.io>
*/
public class Mail.MessageListItem : Gtk.ListBoxRow {
public bool loaded { get; private set; }
public Camel.MessageInfo message_info { get; construct; }
public Camel.MimeMessage? mime_message { get; private set; default = null; }
private Mail.WebView web_view;
private GLib.Cancellable loading_cancellable;
private Gtk.InfoBar blocked_images_infobar;
private Gtk.Revealer fields_revealer;
private Gtk.Revealer secondary_revealer;
private Gtk.StyleContext style_context;
private Hdy.Avatar avatar;
private Gtk.FlowBox attachment_bar = null;
private string message_content;
private bool message_is_html = false;
private bool message_loaded = false;
private static Gee.HashMap<string, Gdk.Pixbuf> avatars;
private static GLib.Settings desktop_settings;
public bool expanded {
get {
return secondary_revealer.reveal_child;
}
set {
secondary_revealer.reveal_child = value;
fields_revealer.reveal_child = value;
if (value) {
if (!message_loaded) {
get_message.begin ();
message_loaded = true;
}
style_context.remove_class ("collapsed");
} else {
style_context.add_class ("collapsed");
}
}
}
private GLib.Settings settings;
public MessageListItem (Camel.MessageInfo message_info) {
Object (
message_info: message_info
);
}
static construct {
avatars = new Gee.HashMap<string, Gdk.Pixbuf> (null, null);
desktop_settings = new GLib.Settings ("org.gnome.desktop.interface");
}
construct {
loading_cancellable = new GLib.Cancellable ();
style_context = get_style_context ();
style_context.add_class (Granite.STYLE_CLASS_CARD);
style_context.add_class ("message-list-item");
unowned string? parsed_address;
unowned string? parsed_name;
var camel_address = new Camel.InternetAddress ();
camel_address.unformat (message_info.from);
camel_address.get (0, out parsed_name, out parsed_address);
if (parsed_name == null) {
parsed_name = parsed_address;
}
avatar = new Hdy.Avatar (40, parsed_name, true) {
valign = START
};
var from_label = new Gtk.Label (message_info.from) {
wrap = true,
xalign = 0
};
var to_label = new Gtk.Label (_("To:")) {
halign = END
};
to_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
var to_val_label = new Gtk.Label (message_info.to) {
hexpand = true,
wrap = true,
xalign = 0
};
var relevant_timestamp = message_info.date_received;
if (relevant_timestamp == 0) {
// Sent messages do not have a date_received timestamp.
relevant_timestamp = message_info.date_sent;
}
var date_format = Granite.DateTime.get_default_date_format (false, true, true);
var time_format = Granite.DateTime.get_default_time_format (desktop_settings.get_enum ("clock-format") == 1, false);
var datetime_label = new Gtk.Label (
///TRANSLATORS: The first %s represents the date and the second %s the time of the message (either when it was received or sent)
new DateTime.from_unix_utc (relevant_timestamp).to_local ().format (_("%s at %s").printf (date_format, time_format))
) {
halign = END,
valign = START
};
datetime_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
var action_box = new Gtk.Box (HORIZONTAL, 6) {
halign = END,
hexpand = true
};
var fields_grid = new Gtk.Grid () {
column_spacing = 3,
margin_top = 3
};
fields_grid.attach (to_label, 0, 0);
fields_grid.attach (to_val_label, 1, 0);
fields_grid.attach (action_box, 2, 0);
fields_revealer = new Gtk.Revealer ();
fields_revealer.add (fields_grid);
var cc_info = message_info.cc;
if (cc_info != null) {
var cc_label = new Gtk.Label (_("Cc:")) {
halign = END,
valign = START
};
cc_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
var cc_val_label = new Gtk.Label (cc_info) {
wrap = true,
xalign = 0
};
fields_grid.attach (cc_label, 0, 1);
fields_grid.attach (cc_val_label, 1, 1);
}
var starred_icon = new Gtk.Image ();
var starred_button = new Gtk.Button () {
child = starred_icon
};
starred_button.get_style_context ().add_class ("image-button");
if (Camel.MessageFlags.FLAGGED in (int) message_info.flags) {
starred_icon.icon_name = "starred-symbolic";
starred_button.tooltip_text = _("Unstar message");
} else {
starred_icon.icon_name = "non-starred-symbolic";
starred_button.tooltip_text = _("Star message");
}
var upper_section = new Menu ();
upper_section.append (_("Reply"), Action.print_detailed_name (
MainWindow.ACTION_PREFIX + MainWindow.ACTION_REPLY, message_info.uid
));
upper_section.append (_("Reply All"), Action.print_detailed_name (
MainWindow.ACTION_PREFIX + MainWindow.ACTION_REPLY_ALL, message_info.uid
));
upper_section.append (_("Forward"), Action.print_detailed_name (
MainWindow.ACTION_PREFIX + MainWindow.ACTION_FORWARD, message_info.uid
));
var lower_section = new Menu ();
lower_section.append (_("Print…"), Action.print_detailed_name (
MainWindow.ACTION_PREFIX + MainWindow.ACTION_PRINT, message_info.uid
));
var actions_menu = new Menu ();
actions_menu.append_section (null, upper_section);
actions_menu.append_section (null, lower_section);
var actions_menu_button = new Gtk.MenuButton () {
image = new Gtk.Image.from_icon_name ("view-more-symbolic", Gtk.IconSize.MENU),
tooltip_text = _("More"),
menu_model = actions_menu,
use_popover = false
};
actions_menu_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
var header_vgrid = new Gtk.Grid () {
valign = START
};
header_vgrid.attach (from_label, 0, 0);
header_vgrid.attach (datetime_label, 1, 0);
header_vgrid.attach (fields_revealer, 0, 1, 2);
var header = new Gtk.Box (HORIZONTAL, 12) {
margin_top = 12,
margin_bottom = 12,
margin_start = 12,
margin_end = 12
};
header.add (avatar);
header.add (header_vgrid);
var header_event_box = new Gtk.EventBox ();
header_event_box.events |= Gdk.EventMask.ENTER_NOTIFY_MASK;
header_event_box.events |= Gdk.EventMask.LEAVE_NOTIFY_MASK;
header_event_box.events |= Gdk.EventMask.BUTTON_RELEASE_MASK;
header_event_box.add (header);
var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) {
hexpand = true
};
settings = new GLib.Settings ("io.elementary.mail");
blocked_images_infobar = new Gtk.InfoBar () {
margin_top = 12,
margin_bottom = 12,
margin_start = 12,
margin_end = 12,
message_type = WARNING
};
blocked_images_infobar.add_button (_("Show Images"), 1);
blocked_images_infobar.add_button (_("Always Show from Sender"), 2);
blocked_images_infobar.get_style_context ().add_class (Gtk.STYLE_CLASS_FRAME);
blocked_images_infobar.no_show_all = true;
var infobar_content = blocked_images_infobar.get_content_area ();
infobar_content.add (new Gtk.Label (_("This message contains remote images.")));
infobar_content.show_all ();
((Gtk.Box) blocked_images_infobar.get_action_area ()).orientation = Gtk.Orientation.VERTICAL;
web_view = new Mail.WebView () {
margin_top = 12,
margin_bottom = 12,
margin_start = 12,
margin_end = 12
};
web_view.mouse_target_changed.connect (on_mouse_target_changed);
web_view.context_menu.connect (on_webview_context_menu);
web_view.load_finished.connect (() => {
loaded = true;
});
var secondary_box = new Gtk.Box (VERTICAL, 0);
secondary_box.add (separator);
secondary_box.add (blocked_images_infobar);
secondary_box.add (web_view);
secondary_revealer = new Gtk.Revealer () {
transition_type = SLIDE_UP
};
secondary_revealer.add (secondary_box);
var base_box = new Gtk.Box (VERTICAL, 0) {
hexpand = true,
vexpand = true
};
base_box.add (header_event_box);
base_box.add (secondary_revealer);
if (Camel.MessageFlags.ATTACHMENTS in (int) message_info.flags) {
var attachment_icon = new Gtk.Image.from_icon_name ("mail-attachment-symbolic", Gtk.IconSize.MENU) {
tooltip_text = _("This message contains one or more attachments")
};
action_box.add (attachment_icon);
attachment_bar = new Gtk.FlowBox () {
hexpand = true,
homogeneous = true
};
attachment_bar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
attachment_bar.get_style_context ().add_class ("bottom-toolbar");
secondary_box.add (attachment_bar);
}
action_box.add (starred_button);
action_box.add (actions_menu_button);
add (base_box);
expanded = false;
show_all ();
get_gravatar.begin (parsed_address, (obj, res) => {
FileIcon? file_icon = get_gravatar.end (res);
avatar.set_loadable_icon (file_icon);
});
/* Override default handler to stop event propagation. Otherwise clicking the menu will
expand or collapse the MessageListItem. */
actions_menu_button.button_release_event.connect ((event) => {
actions_menu_button.set_active (true);
return Gdk.EVENT_STOP;
});
header_event_box.enter_notify_event.connect ((event) => {
if (event.detail != Gdk.NotifyType.INFERIOR) {
var window = header_event_box.get_window ();
var cursor = new Gdk.Cursor.from_name (window.get_display (), "pointer");
window.set_cursor (cursor);
}
});
header_event_box.leave_notify_event.connect ((event) => {
if (event.detail != Gdk.NotifyType.INFERIOR) {
header_event_box.get_window ().set_cursor (null);
}
});
header_event_box.button_release_event.connect ((event) => {
expanded = !expanded;
return Gdk.EVENT_STOP;
});
destroy.connect (() => {
loading_cancellable.cancel ();
});
/* Connecting to clicked () doesn't allow us to prevent the event from propagating to header_event_box */
starred_button.button_release_event.connect (() => {
if (Camel.MessageFlags.FLAGGED in (int) message_info.flags) {
message_info.set_flags (Camel.MessageFlags.FLAGGED, 0);
starred_icon.icon_name = "non-starred-symbolic";
starred_icon.tooltip_text = _("Star message");
} else {
message_info.set_flags (Camel.MessageFlags.FLAGGED, ~0);
starred_icon.icon_name = "starred-symbolic";
starred_icon.tooltip_text = _("Unstar message");
}
return Gdk.EVENT_STOP;
});
web_view.image_load_blocked.connect (() => {
blocked_images_infobar.show ();
});
web_view.link_activated.connect ((uri) => {
try {
AppInfo.launch_default_for_uri (uri, null);
} catch (Error e) {
warning ("Failed to open link: %s", e.message);
}
});
}
public void print () {
try {
var settings = new Gtk.PrintSettings ();
/// Translators: This is the default file name of a printed email
string filename = _("Email Message");
unowned string subject = message_info.subject;
if (subject != null && subject != "") {
/* Replace any runs of whitespace, non-printing characters or slashes with a
single space and remove and leading or trailing spaces. */
var sanitized_subject = new Regex ("[[:space:][:cntrl:]/]+").replace (subject, -1, 0, " ").strip ();
if (sanitized_subject.length <= 64) {
filename = sanitized_subject;
} else {
filename = "%s…".printf (sanitized_subject.substring (0, sanitized_subject.char_count (64 - 1)));
}
}
settings.set (Gtk.PRINT_SETTINGS_OUTPUT_BASENAME, filename);
/* @TODO: include header fields in printed output */
var print_operation = new WebKit.PrintOperation (web_view);
print_operation.set_print_settings (settings);
print_operation.run_dialog ((Gtk.ApplicationWindow) get_toplevel ());
} catch (Error e) {
var print_error_dialog = new Granite.MessageDialog.with_image_from_icon_name (
_("Unable to print email"),
_(""),
"printer"
) {
badge_icon = new ThemedIcon ("dialog-error"),
transient_for = (Gtk.Window) get_toplevel ()
};
print_error_dialog.show_error_details (e.message);
print_error_dialog.present ();
print_error_dialog.response.connect (() => print_error_dialog.destroy ());
}
}
private void on_mouse_target_changed (WebKit.WebView web_view, WebKit.HitTestResult hit_test, uint mods) {
var message_list = (MessageList) get_ancestor (typeof (MessageList));
if (hit_test.context_is_link ()) {
message_list.hovering_over_link (hit_test.get_link_label (), hit_test.get_link_uri ());
} else {
message_list.hovering_over_link (null, null);
}
}
private bool on_webview_context_menu (WebKit.ContextMenu menu, Gdk.Event event, WebKit.HitTestResult hit_test) {
WebKit.ContextMenu new_context_menu = new WebKit.ContextMenu ();
for (int i = 0; i < menu.get_n_items (); i++) {
var item = menu.get_item_at_position (i);
switch (item.get_stock_action ()) {
case WebKit.ContextMenuAction.COPY_LINK_TO_CLIPBOARD:
case WebKit.ContextMenuAction.COPY_IMAGE_URL_TO_CLIPBOARD:
case WebKit.ContextMenuAction.COPY:
new_context_menu.append (item);
break;
default:
break;
}
}
menu.remove_all ();
foreach (var item in new_context_menu.get_items ()) {
menu.append (item);
}
menu.append (new WebKit.ContextMenuItem.from_stock_action (WebKit.ContextMenuAction.SELECT_ALL));
return false;
}
private async FileIcon? get_gravatar (string address) {
/* GLib.File.new_for_uri seemingly doesn't support https */
var uri = "http://www.gravatar.com/avatar/%s?d=404&s=%d".printf (
Checksum.compute_for_string (ChecksumType.MD5, address.strip ().down ()),
avatar.size * get_style_context ().get_scale ()
);
var server_file = File.new_for_uri (uri);
var path = Path.build_filename (Environment.get_tmp_dir (), server_file.get_basename ());
var local_file = File.new_for_path (path);
if (!local_file.query_exists (loading_cancellable)) {
try {
yield server_file.copy_async (local_file, FileCopyFlags.OVERWRITE, GLib.Priority.DEFAULT, loading_cancellable, null);
} catch (Error e) {
if (!(e is IOError.CANCELLED)) {
warning (e.message);
}
return null;
}
}
return new FileIcon (local_file);
}
private async void get_message () {
var folder = message_info.summary.folder;
Camel.MimeMessage? message = null;
try {
message = yield folder.get_message (message_info.uid, GLib.Priority.DEFAULT, loading_cancellable);
} catch (Error e) {
warning ("Could not get message. %s", e.message);
}
var flags = (Camel.FolderFlags)folder.get_flags ();
if (!(Camel.FolderFlags.IS_JUNK in flags) && settings.get_boolean ("always-load-remote-images")) {
web_view.load_images ();
} else if (message != null) {
var whitelist = settings.get_strv ("remote-images-whitelist");
unowned string? sender;
weak Camel.InternetAddress from = message.get_from ();
if (from == null) {
return;
}
from.@get (0, null, out sender);
if (sender in whitelist) {
web_view.load_images ();
}
blocked_images_infobar.response.connect ((id) => {
if (id == 2) {
if (!(sender in whitelist)) {
whitelist += sender;
settings.set_strv ("remote-images-whitelist", whitelist);
}
}
web_view.load_images ();
blocked_images_infobar.destroy ();
});
}
if (message != null) {
mime_message = message;
yield open_message (message);
}
}
private async void open_message (Camel.MimeMessage message) {
yield parse_mime_content (message.content);
if (message_content == null) {
return;
}
if (message_is_html) {
web_view.load_html (message_content);
} else {
/*
* Instead of calling web_view.load_plain_text, use Camel's ToHTML
* filter to convert text to HTML. This gives us some niceties like
* clickable URLs and email addresses for free.
*
* Explanation of MimeFilterToHTMLFlags:
* https://wiki.gnome.org/Apps/Evolution/Camel.MimeFilter#Camel.MimeFilterToHtml
*/
var flags = Camel.MimeFilterToHTMLFlags.CONVERT_NL |
Camel.MimeFilterToHTMLFlags.CONVERT_SPACES |
Camel.MimeFilterToHTMLFlags.CONVERT_URLS |
Camel.MimeFilterToHTMLFlags.CONVERT_ADDRESSES;
var html = Camel.text_to_html (message_content, flags, 0);
web_view.load_html (html);
}
}
private async void parse_mime_content (Camel.DataWrapper mime_content) {
if (mime_content is Camel.Multipart) {
var content = mime_content as Camel.Multipart;
for (uint i = 0; i < content.get_number (); i++) {
var part = content.get_part (i);
var field = part.get_mime_type_field ();
if (part.disposition == "inline") {
yield handle_inline_mime (part);
} else if (part.disposition == "attachment") {
var button = new AttachmentButton (part, loading_cancellable);
button.activate.connect (() => show_attachment (button.mime_part));
attachment_bar.add (button);
}
if (field.type == "text") {
yield handle_text_mime (part.content);
} else if (field.type == "multipart") {
yield parse_mime_content (part.content);
}
}
} else {
yield handle_text_mime (mime_content);
}
}
private async void handle_text_mime (Camel.DataWrapper part) {
var field = part.get_mime_type_field ();
if (message_content == null || (!message_is_html && field.subtype == "html")) {
var os = new GLib.MemoryOutputStream.resizable ();
try {
yield part.decode_to_output_stream (os, GLib.Priority.DEFAULT, loading_cancellable);
os.close ();
} catch (Error e) {
warning ("Possible error decoding email message: %s", e.message);
return;
}
// Convert the message to UTF-8 to ensure we have a valid GLib string.
message_content = convert_to_utf8 (os, field.param ("charset"));
if (field.subtype == "html") {
message_is_html = true;
}
}
}
private static string convert_to_utf8 (GLib.MemoryOutputStream os, string? encoding) {
var num_bytes = (int) os.get_data_size ();
var bytes = (string) os.steal_data ();
string? utf8 = null;
if (encoding != null) {
string? iconv_encoding = Camel.iconv_charset_name (encoding);
if (iconv_encoding != null) {
try {
utf8 = GLib.convert (bytes, num_bytes, "UTF-8", iconv_encoding);
} catch (ConvertError e) {
// Nothing to do - result will be assigned below.
}
}
}
if (utf8 == null || !utf8.validate ()) {
/*
* If message_content is not valid UTF-8 at this point, assume that
* it is ISO-8859-1 encoded by default, and convert it to UTF-8.
*/
try {
utf8 = GLib.convert (bytes, num_bytes, "UTF-8", "ISO-8859-1");
} catch (ConvertError e) {
critical ("Every string should be valid ISO-8859-1. ConvertError: %s", e.message);
utf8 = "";
}
}
return utf8;
}
private async void handle_inline_mime (Camel.MimePart part) {
if (part.get_content_id () == null) {
return;
}
var byte_array = new ByteArray ();
var os = new Camel.StreamMem ();
os.set_byte_array (byte_array);
try {
yield part.content.decode_to_stream (os, GLib.Priority.DEFAULT, loading_cancellable);
} catch (Error e) {
warning ("Error decoding inline attachment: %s", e.message);
return;
}
Bytes bytes = ByteArray.free_to_bytes (byte_array);
var inline_stream = new MemoryInputStream.from_bytes (bytes);
web_view.add_internal_resource (part.get_content_id (), inline_stream);
}
public async string get_message_body_html () {
return yield web_view.get_body_html ();
}
private void show_attachment (Camel.MimePart mime_part) {
var dialog = new Granite.MessageDialog (
_("Trust and open “%s”?").printf (mime_part.get_filename ()),
_("Attachments may cause damage to your system if opened. Only open files from trusted sources."),
new ThemedIcon ("dialog-warning"),
Gtk.ButtonsType.CANCEL
) {
transient_for = (Gtk.Window) get_toplevel ()
};
var open_button = dialog.add_button (_("Open Anyway"), Gtk.ResponseType.OK);
open_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
dialog.present ();
dialog.response.connect ((response_id) => {
if (response_id == Gtk.ResponseType.OK) {
show_file_anyway.begin (mime_part);
}
dialog.destroy ();
});
}
private async void show_file_anyway (Camel.MimePart mime_part) {
try {
GLib.FileIOStream iostream;
var file = File.new_tmp ("XXXXXX-%s".printf (mime_part.get_filename ()), out iostream);
yield mime_part.content.decode_to_output_stream (iostream.output_stream, GLib.Priority.DEFAULT, null);
yield GLib.AppInfo.launch_default_for_uri_async (file.get_uri (), (AppLaunchContext) null, null);
} catch (Error e) {
critical (e.message);
}
}
}