From 8dd7a8d7fe79261c087ba1e5c0af02e422948a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 14 Apr 2016 18:24:00 +0200 Subject: [PATCH] LibNotifyLoader: implement generic HasCapability --- .../browser/linux/libnotify_notification.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/brightray/browser/linux/libnotify_notification.cc b/brightray/browser/linux/libnotify_notification.cc index 399416a5721f..6772588f5099 100644 --- a/brightray/browser/linux/libnotify_notification.cc +++ b/brightray/browser/linux/libnotify_notification.cc @@ -17,6 +17,18 @@ namespace brightray { namespace { LibNotifyLoader libnotify_loader_; +bool HasCapability(const std::string& capability) { + bool result = false; + GList* capabilities = libnotify_loader_.notify_get_server_caps(); + + if (g_list_find_custom(capabilities, capability.c_str(), (GCompareFunc) g_strcmp0) != NULL) + result = true; + + g_list_free_full(capabilities, g_free); + + return result; +} + bool NotifierSupportsActions() { if (getenv("ELECTRON_USE_UBUNTU_NOTIFIER")) return false; @@ -28,12 +40,7 @@ bool NotifierSupportsActions() { if (notify_has_result) return notify_result; - capabilities = libnotify_loader_.notify_get_server_caps(); - - if (g_list_find_custom(capabilities, "actions", (GCompareFunc) g_strcmp0) != NULL) - notify_result = true; - - g_list_free_full(capabilities, g_free); + notify_result = HasCapability("actions"); return notify_result; }