diff --git a/plugins/windows-notification/src/toast_notification_builder.vala b/plugins/windows-notification/src/toast_notification_builder.vala index 29ce6d2f..d38aca79 100644 --- a/plugins/windows-notification/src/toast_notification_builder.vala +++ b/plugins/windows-notification/src/toast_notification_builder.vala @@ -45,7 +45,7 @@ namespace Dino.Plugins.WindowsNotification { // https://docs.microsoft.com/en-us/previous-versions/windows/apps/hh761494(v=win.10) // Eventually modern adaptive templates might be desired: // https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=builder-syntax - public ToastNotification Build() { + public async ToastNotification Build() { ToastTemplateType templateType = _header != null ? ToastTemplateType.ToastText02 : ToastTemplateType.ToastText01; if (_imagePath != null) { if (templateType == ToastTemplateType.ToastText02) { @@ -55,7 +55,7 @@ namespace Dino.Plugins.WindowsNotification { } } - var template = BuildStanzaFromXml(ToastNotificationManager.GetTemplateContent(templateType)); + var template = yield BuildStanzaFromXml(ToastNotificationManager.GetTemplateContent(templateType)); { // add header and body var attributes = new Gee.ArrayList(); attributes.add(new StanzaAttribute.build("", "id", "1")); @@ -105,17 +105,10 @@ namespace Dino.Plugins.WindowsNotification { return new ToastNotification(xml); } - private StanzaNode BuildStanzaFromXml(string xml) { + private async StanzaNode BuildStanzaFromXml(string xml) { var reader = new Xmpp.StanzaReader.for_string(xml); - StanzaNode root_node = null; - var loop = new MainLoop(); - reader.read_node - .begin((obj, res) => { - root_node = reader.read_node.end(res); - loop.quit(); - }); - loop.run(); + StanzaNode root_node = yield reader.read_node(); ExecuteOnAllSubNodes(root_node, (node) => { node.ns_uri = ""; diff --git a/plugins/windows-notification/src/win_notification_provider.vala b/plugins/windows-notification/src/win_notification_provider.vala index 549518a5..b118b0ea 100644 --- a/plugins/windows-notification/src/win_notification_provider.vala +++ b/plugins/windows-notification/src/win_notification_provider.vala @@ -55,7 +55,7 @@ namespace Dino.Plugins.WindowsNotification { string body = Markup.escape_text(conversation.counterpart.to_string()); var image_path = get_avatar(conversation); - var notification = new ToastNotificationBuilder() + var notification = yield new ToastNotificationBuilder() .SetHeader(summary) .SetBody(body) .SetImage(image_path) @@ -108,7 +108,7 @@ namespace Dino.Plugins.WindowsNotification { break; } - var notification = new ToastNotificationBuilder() + var notification = yield new ToastNotificationBuilder() .SetHeader(summary) .SetBody(body) .Build(); @@ -130,7 +130,7 @@ namespace Dino.Plugins.WindowsNotification { string body = _("%s invited you to %s").printf(inviter_display_name, display_room); var image_path = get_avatar(direct_conversation); - var notification = new ToastNotificationBuilder() + var notification = yield new ToastNotificationBuilder() .SetHeader(summary) .SetBody(body) .SetImage(image_path) @@ -167,7 +167,7 @@ namespace Dino.Plugins.WindowsNotification { string body = _("%s requests the permission to write in %s").printf(display_name, display_room); var image_path = get_avatar(conversation); - var notification = new ToastNotificationBuilder() + var notification = yield new ToastNotificationBuilder() .SetHeader(summary) .SetBody(body) .SetImage(image_path) @@ -201,7 +201,7 @@ namespace Dino.Plugins.WindowsNotification { } var image_path = get_avatar(conversation); - var notification = new ToastNotificationBuilder() + var notification = yield new ToastNotificationBuilder() .SetHeader(conversation_display_name) .SetBody(body) .SetImage(image_path)