Break common at utilities to atutils.c/.h

This commit is contained in:
Denis Kenzior 2009-09-04 14:01:32 -05:00 committed by Denis Kenzior
parent 2693c604a9
commit 5749b6e75d
5 changed files with 113 additions and 56 deletions

View File

@ -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

View File

@ -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();

View File

@ -23,40 +23,15 @@
#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 <ofono/types.h>
#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();

57
drivers/atmodem/atutil.c Normal file
View File

@ -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;
}
}

50
drivers/atmodem/atutil.h Normal file
View File

@ -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 \