As of now there's no support for fd-passing in D-Bus Python bindings,
hence a small C client is needed in order to test location-reporting
atom.
---
Makefile.am |5 +-
tools/get-location.c | 259 ++
2 files changed, 263 insertions(+), 1 deletions(-)
create mode 100644 tools/get-location.c
diff --git a/Makefile.am b/Makefile.am
index ca558ea..81c39b1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -553,13 +553,16 @@ unit_test_caif_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_caif_OBJECTS)
if TOOLS
-noinst_PROGRAMS += tools/huawei-audio tools/auto-enable
+noinst_PROGRAMS += tools/huawei-audio tools/auto-enable tools/get-location
tools_huawei_audio_SOURCES = $(gdbus_sources) tools/huawei-audio.c
tools_huawei_audio_LDADD = @GLIB_LIBS@ @DBUS_LIBS@
tools_auto_enable_SOURCES = $(gdbus_sources) tools/auto-enable.c
tools_auto_enable_LDADD = @GLIB_LIBS@ @DBUS_LIBS@
+
+tools_get_location_SOURCES = tools/get-location.c
+tools_get_location_LDADD = @GLIB_LIBS@ @DBUS_LIBS@
endif
noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
diff --git a/tools/get-location.c b/tools/get-location.c
new file mode 100644
index 000..dafb3c4
--- /dev/null
+++ b/tools/get-location.c
@@ -0,0 +1,259 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2011 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#define OFONO_SERVICE org.ofono
+
+#define MANAGER_PATH /
+#define MANAGER_INTERFACE OFONO_SERVICE .Manager
+#define LOCATION_REPORTING_INTERFACE OFONO_SERVICE .LocationReporting
+
+#include errno.h
+#include fcntl.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include signal.h
+#include sys/signalfd.h
+#include unistd.h
+
+#include dbus/dbus.h
+#include glib.h
+
+static GMainLoop *event_loop;
+
+static char *get_first_modem_path(DBusConnection *conn)
+{
+ DBusMessage *msg, *reply;
+ DBusMessageIter iter, array, entry;
+ DBusError error;
+ int arg_type;
+ const char *path;
+
+ msg = dbus_message_new_method_call(OFONO_SERVICE, MANAGER_PATH,
+ MANAGER_INTERFACE, GetModems);
+
+ dbus_error_init(error);
+
+ reply = dbus_connection_send_with_reply_and_block(conn, msg, -1,
+ error);
+
+ dbus_message_unref(msg);
+
+ if (!reply) {
+ if (dbus_error_is_set(error)) {
+ fprintf(stderr, %s\n, error.message);
+ dbus_error_free(error);
+ } else {
+ fprintf(stderr, GetModems failed);
+ }
+
+
+ return NULL;
+ }
+
+ dbus_message_iter_init(reply, iter);
+
+ dbus_message_iter_recurse(iter, array);
+ dbus_message_iter_recurse(array, entry);
+
+ arg_type = dbus_message_iter_get_arg_type(entry);
+ while (arg_type != DBUS_TYPE_INVALID
+ arg_type != DBUS_TYPE_OBJECT_PATH) {
+ dbus_message_iter_next(entry);
+ arg_type = dbus_message_iter_get_arg_type(entry);
+ }
+
+ if (arg_type != DBUS_TYPE_OBJECT_PATH) {
+ fprintf(stderr, modem not found\n);
+ return NULL;
+ }
+
+ dbus_message_iter_get_basic(entry, path);
+ fprintf(stderr, Using modem: %s\n, path);
+
+ return strdup(path);
+}
+
+static gboolean data_read_cb(GIOChannel *channel, GIOCondition cond,
+ gpointer data)
+{
+ int fd = GPOINTER_TO_INT(data);
+ char buf[128];
+ int ret;
+
+ while ((ret = read(fd, buf, sizeof(buf) - 1)) = 0) {
+ buf[ret] = '\0';
+ printf(%s, buf);
+ }
+
+ if (errno != EAGAIN errno != EWOULDBLOCK)
+ fprintf(stderr, Error reading fd);
+
+ return TRUE;
+}
+
+static int setup_data_channel(DBusConnection *conn, const char *path)
+{
+ DBusMessage *msg, *reply;
+ DBusError error;
+ int fd, fd_source;
+ GIOChannel *channel;
+
+ msg = dbus_message_new_method_call(OFONO_SERVICE, path,
+ LOCATION_REPORTING_INTERFACE, Request);
+
+