[grilo] registry: Use g_strv_contains()



commit abb24872157eac0c8005b167baadf22773b62106
Author: Xavier Claessens <xavier claessens collabora com>
Date:   Wed Aug 26 13:08:59 2015 -0400

    registry: Use g_strv_contains()
    
    GNetworkConnectivity was added in glib 2.44, so was g_strv_contains().
    No need of a custom implementation here.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754093

 src/grl-registry.c |   33 +++++++--------------------------
 1 files changed, 7 insertions(+), 26 deletions(-)
---
diff --git a/src/grl-registry.c b/src/grl-registry.c
index c70caaa..cd24da4 100644
--- a/src/grl-registry.c
+++ b/src/grl-registry.c
@@ -126,10 +126,6 @@ static void shutdown_plugin (GrlPlugin *plugin);
 
 static void configs_free (GList *configs);
 
-#ifdef HAVE_GIO_WITH_NETMON
-static gboolean strv_contains (const char **strv, const char  *str);
-#endif
-
 static GrlPlugin *grl_registry_prepare_plugin (GrlRegistry *registry,
                                                const gchar *library_filename,
                                                GError **error);
@@ -256,8 +252,8 @@ network_changed_cb (GObject     *gobject,
       if (!tags)
         continue;
 
-      if ((strv_contains (tags, LOCAL_NET_TAG) ||
-           strv_contains (tags, INTERNET_NET_TAG)) &&
+      if ((g_strv_contains (tags, LOCAL_NET_TAG) ||
+           g_strv_contains (tags, INTERNET_NET_TAG)) &&
           !SOURCE_IS_INVISIBLE(current_source)) {
         GRL_DEBUG ("Network isn't available for '%s', hiding",
                    grl_source_get_id (current_source));
@@ -273,7 +269,7 @@ network_changed_cb (GObject     *gobject,
       if (!tags)
         continue;
 
-      if (strv_contains (tags, LOCAL_NET_TAG) &&
+      if (g_strv_contains (tags, LOCAL_NET_TAG) &&
           SOURCE_IS_INVISIBLE(current_source)) {
         GRL_DEBUG ("Local network became available for '%s', showing",
                    grl_source_get_id (current_source));
@@ -281,7 +277,7 @@ network_changed_cb (GObject     *gobject,
         g_signal_emit (registry, registry_signals[SIG_SOURCE_ADDED], 0, current_source);
       }
 
-      if (strv_contains (tags, INTERNET_NET_TAG) &&
+      if (g_strv_contains (tags, INTERNET_NET_TAG) &&
           connectivity == G_NETWORK_CONNECTIVITY_FULL &&
           SOURCE_IS_INVISIBLE(current_source)) {
         GRL_DEBUG ("Internet became available for '%s', showing",
@@ -290,7 +286,7 @@ network_changed_cb (GObject     *gobject,
         g_signal_emit (registry, registry_signals[SIG_SOURCE_ADDED], 0, current_source);
       }
 
-      if (strv_contains (tags, INTERNET_NET_TAG) &&
+      if (g_strv_contains (tags, INTERNET_NET_TAG) &&
           connectivity != G_NETWORK_CONNECTIVITY_FULL &&
           !SOURCE_IS_INVISIBLE(current_source)) {
         GRL_DEBUG ("Internet became unavailable for '%s', hiding",
@@ -341,21 +337,6 @@ configs_free (GList *configs)
 }
 
 #ifdef HAVE_GIO_WITH_NETMON
-static gboolean
-strv_contains (const char **strv,
-               const char  *str)
-{
-  const char **s = strv;
-
-  while (*s) {
-    if (g_str_equal (str, *s))
-      return TRUE;
-    s++;
-  }
-
-  return FALSE;
-}
-
 static void
 update_source_visibility (GrlRegistry *registry,
                           GrlSource   *source)
@@ -369,8 +350,8 @@ update_source_visibility (GrlRegistry *registry,
   if (!tags)
     return;
 
-  needs_local = strv_contains (tags, LOCAL_NET_TAG);
-  needs_inet = strv_contains (tags, INTERNET_NET_TAG);
+  needs_local = g_strv_contains (tags, LOCAL_NET_TAG);
+  needs_inet = g_strv_contains (tags, INTERNET_NET_TAG);
 
   if (!needs_local &&
       !needs_inet)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]