gdbus: Introduce g_dbus_proxy_path_lookup()

g_dbus_proxy_path_lookup() returns the path of the proxy that matches the
passed path. It also returns the index of the proxy coming next to the
matched proxy in the passed list.
diff --git a/gdbus/client.c b/gdbus/client.c
index f909557..9364be7 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -26,6 +26,7 @@
 #endif
 
 #include <stdio.h>
+#include <string.h>
 #include <glib.h>
 #include <dbus/dbus.h>
 
@@ -376,6 +377,26 @@
 	return NULL;
 }
 
+char *g_dbus_proxy_path_lookup(GList *list, int *index, const char *path)
+{
+	int len = strlen(path);
+	GList *l;
+
+	for (l = g_list_nth(list, index ? *index : 0); l; l = g_list_next(l)) {
+		GDBusProxy *proxy = l->data;
+
+		const char *proxy_path = g_dbus_proxy_get_path(proxy);
+
+		if (index)
+			(*index)++;
+
+		if (!strncasecmp(proxy_path, path, len))
+			return strdup(proxy_path);
+	}
+
+	return NULL;
+}
+
 static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
 							void *user_data)
 {
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 85cb968..4880c84 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -341,6 +341,7 @@
 
 GDBusProxy *g_dbus_proxy_lookup(GList *list, int *index, const char *path,
 						const char *interface);
+char *g_dbus_proxy_path_lookup(GList *list, int *index, const char *path);
 
 gboolean g_dbus_proxy_refresh_property(GDBusProxy *proxy, const char *name);