summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2015-08-26 13:08:59 -0400
committerJuan A. Suarez Romero <jasuarez@igalia.com>2015-09-06 16:03:58 +0200
commitda04886a674880aeb24239ba712a2dca1cefb403 (patch)
treebd609c2a7cbda6f532a53392e66f90ce70203ec0
parent1f37b00f6a05742074ff2f20bdeb56b69b8ef3dc (diff)
downloadgrilo-da04886a674880aeb24239ba712a2dca1cefb403.tar.gz
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
-rw-r--r--src/grl-registry.c33
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)