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,40 +23,15 @@ #include #endif -#include #include -#include #include -#include #define OFONO_API_SUBJECT_TO_CHANGE #include -#include -#include +#include + #include "at.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; - } -} - static int atmodem_init(void) { at_voicecall_init(); 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 +#endif + +#include +#include +#include +#include + +#define OFONO_API_SUBJECT_TO_CHANGE +#include +#include + +#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 \ +