summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denis.kenzior@intel.com>2009-09-04 14:01:32 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-09-04 20:37:49 -0500
commit5749b6e75d217b3249d5c81410c13d9fd3db50fd (patch)
tree34301c2a09e2a3d09711ab0d5f3c4f23652daccc
parent2693c604a97dc9cab8252539a8a1959227312fa6 (diff)
downloadofono-5749b6e75d217b3249d5c81410c13d9fd3db50fd.tar.bz2
Break common at utilities to atutils.c/.h
-rw-r--r--Makefile.am4
-rw-r--r--drivers/atmodem/at.h29
-rw-r--r--drivers/atmodem/atmodem.c29
-rw-r--r--drivers/atmodem/atutil.c57
-rw-r--r--drivers/atmodem/atutil.h50
5 files changed, 113 insertions, 56 deletions
diff --git a/Makefile.am b/Makefile.am
index b45bd253..7b74f232 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -96,7 +96,9 @@ builtin_sources += $(gatchat_sources) drivers/atmodem/at.h \
drivers/atmodem/phonebook.c \
drivers/atmodem/ssn.c \
drivers/atmodem/devinfo.c \
- drivers/atmodem/vendor.h
+ drivers/atmodem/vendor.h \
+ drivers/atmodem/atutil.h \
+ drivers/atmodem/atutil.c
builtin_modules += modemconf
builtin_sources += plugins/modemconf.c
diff --git a/drivers/atmodem/at.h b/drivers/atmodem/at.h
index 7d307a1d..c57069bb 100644
--- a/drivers/atmodem/at.h
+++ b/drivers/atmodem/at.h
@@ -19,34 +19,7 @@
*
*/
-void decode_at_error(struct ofono_error *error, const char *final);
-void dump_response(const char *func, gboolean ok, GAtResult *result);
-
-struct cb_data {
- void *cb;
- void *data;
- void *user;
-};
-
-static inline struct cb_data *cb_data_new(void *cb, void *data)
-{
- struct cb_data *ret;
-
- ret = g_try_new0(struct cb_data, 1);
-
- if (!ret)
- return ret;
-
- ret->cb = cb;
- ret->data = data;
-
- return ret;
-}
-
-#define DECLARE_FAILURE(e) \
- struct ofono_error e; \
- e.type = OFONO_ERROR_TYPE_FAILURE; \
- e.error = 0 \
+#include "atutil.h"
extern void at_netreg_init();
extern void at_netreg_exit();
diff --git a/drivers/atmodem/atmodem.c b/drivers/atmodem/atmodem.c
index d6ae3919..64ac9052 100644
--- a/drivers/atmodem/atmodem.c
+++ b/drivers/atmodem/atmodem.c
@@ -23,39 +23,14 @@
#include <config.h>
#endif
-#include <string.h>
#include <glib.h>
-#include <gdbus.h>
#include <gatchat.h>
-#include <stdlib.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
-#include <ofono/log.h>
-#include <ofono/modem.h>
-#include "at.h"
-
-void dump_response(const char *func, gboolean ok, GAtResult *result)
-{
- GSList *l;
+#include <ofono/types.h>
- ofono_debug("%s got result: %d", func, ok);
- ofono_debug("Final response: %s", result->final_or_pdu);
-
- for (l = result->lines; l; l = l->next)
- ofono_debug("Response line: %s", (char *) l->data);
-}
-
-void decode_at_error(struct ofono_error *error, const char *final)
-{
- if (!strcmp(final, "OK")) {
- error->type = OFONO_ERROR_TYPE_NO_ERROR;
- error->error = 0;
- } else {
- error->type = OFONO_ERROR_TYPE_FAILURE;
- error->error = 0;
- }
-}
+#include "at.h"
static int atmodem_init(void)
{
diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c
new file mode 100644
index 00000000..5d9ceb85
--- /dev/null
+++ b/drivers/atmodem/atutil.c
@@ -0,0 +1,57 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2009 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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <gatchat.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/log.h>
+#include <ofono/types.h>
+
+#include "atutil.h"
+
+void dump_response(const char *func, gboolean ok, GAtResult *result)
+{
+ GSList *l;
+
+ ofono_debug("%s got result: %d", func, ok);
+ ofono_debug("Final response: %s", result->final_or_pdu);
+
+ for (l = result->lines; l; l = l->next)
+ ofono_debug("Response line: %s", (char *) l->data);
+}
+
+void decode_at_error(struct ofono_error *error, const char *final)
+{
+ if (!strcmp(final, "OK")) {
+ error->type = OFONO_ERROR_TYPE_NO_ERROR;
+ error->error = 0;
+ } else {
+ error->type = OFONO_ERROR_TYPE_FAILURE;
+ error->error = 0;
+ }
+}
diff --git a/drivers/atmodem/atutil.h b/drivers/atmodem/atutil.h
new file mode 100644
index 00000000..06d7fc31
--- /dev/null
+++ b/drivers/atmodem/atutil.h
@@ -0,0 +1,50 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2009 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
+ *
+ */
+
+void decode_at_error(struct ofono_error *error, const char *final);
+void dump_response(const char *func, gboolean ok, GAtResult *result);
+
+struct cb_data {
+ void *cb;
+ void *data;
+ void *user;
+};
+
+static inline struct cb_data *cb_data_new(void *cb, void *data)
+{
+ struct cb_data *ret;
+
+ ret = g_try_new0(struct cb_data, 1);
+
+ if (!ret)
+ return ret;
+
+ ret->cb = cb;
+ ret->data = data;
+
+ return ret;
+}
+
+#define DECLARE_FAILURE(e) \
+ struct ofono_error e; \
+ e.type = OFONO_ERROR_TYPE_FAILURE; \
+ e.error = 0 \
+