Index: include/misc.h =================================================================== RCS file: /sources/gnokii/gnokii/include/misc.h,v retrieving revision 1.53 diff -u -p -r1.53 misc.h --- include/misc.h 24 Apr 2005 19:45:43 -0000 1.53 +++ include/misc.h 29 Mar 2006 13:20:22 -0000 @@ -125,5 +125,6 @@ char **gnokii_strsplit(const char *string, const char *delimiter, int tokens); void gnokii_strfreev(char **str_array); +int gnokii_str_has_caseprefix(const char *str, const char *prefix); #endif /* _gnokii_misc_h */ Index: common/misc.c =================================================================== RCS file: /sources/gnokii/gnokii/common/misc.c,v retrieving revision 1.105 diff -u -p -r1.105 misc.c --- common/misc.c 24 Nov 2005 00:27:16 -0000 1.105 +++ common/misc.c 29 Mar 2006 13:20:23 -0000 @@ -570,6 +570,17 @@ void gnokii_strfreev(char **str_array) } /* + * whether string has the prefix + */ + +#define MIN(x, y) (x < y ? x : y) + +int gnokii_str_has_caseprefix(const char *str, const char *prefix) +{ + return (strncasecmp(str, prefix, MIN(strlen(str), strlen(prefix))) == 0); +} + +/* * check if the timestamp in dt has valid date and time */ API int gn_timestamp_isvalid(gn_timestamp dt) Index: common/phones/Makefile =================================================================== RCS file: /sources/gnokii/gnokii/common/phones/Makefile,v retrieving revision 1.22 diff -u -p -r1.22 Makefile --- common/phones/Makefile 1 Jul 2004 22:17:03 -0000 1.22 +++ common/phones/Makefile 29 Mar 2006 13:20:23 -0000 @@ -30,6 +30,7 @@ OBJS = generic.lo \ atnok.lo \ atsie.lo \ atsoer.lo \ + atmot.lo \ gnapplet.lo \ fake.lo Index: common/phones/atgen.c =================================================================== RCS file: /sources/gnokii/gnokii/common/phones/atgen.c,v retrieving revision 1.118 diff -u -p -r1.118 atgen.c --- common/phones/atgen.c 13 Feb 2006 20:39:11 -0000 1.118 +++ common/phones/atgen.c 29 Mar 2006 13:20:23 -0000 @@ -45,6 +45,7 @@ #include "phones/atgen.h" #include "phones/atbosch.h" #include "phones/ateric.h" +#include "phones/atmot.h" #include "phones/atnok.h" #include "phones/atsie.h" #include "phones/atsoer.h" @@ -1864,17 +1865,19 @@ static gn_error Initialise(gn_data *setu if (ret) goto out; - if (!strncasecmp(manufacturer, "bosch", 5)) + if (gnokii_str_has_caseprefix(manufacturer, "bosch")) at_bosch_init(model, setupdata->model, state); - else if (!strncasecmp(manufacturer, "ericsson", 8)) + else if (gnokii_str_has_caseprefix(manufacturer, "ericsson")) at_ericsson_init(model, setupdata->model, state); - else if (!strncasecmp(manufacturer, "nokia", 5)) + else if (gnokii_str_has_caseprefix(manufacturer, "nokia")) at_nokia_init(model, setupdata->model, state); - else if (!strncasecmp(manufacturer, "siemens", 7)) + else if (gnokii_str_has_caseprefix(manufacturer, "siemens")) at_siemens_init(model, setupdata->model, state); - else if (!strncasecmp(manufacturer, "sony ericsson", 14)) + else if (gnokii_str_has_caseprefix(manufacturer, "sony ericsson")) at_sonyericsson_init(model, setupdata->model, state); - + else if (gnokii_str_has_caseprefix(manufacturer, "Motorola")) + at_motorola_init(model, setupdata->model, state); + StoreDefaultCharset(state); dprintf("Initialisation completed\n"); --- /dev/null 2006-02-09 09:03:48.738500360 +0000 +++ common/phones/atmot.c 2006-03-29 14:15:17.000000000 +0100 @@ -0,0 +1,81 @@ +/* + + $Id$ + + G N O K I I + + A Linux/Unix toolset and driver for the mobile phones. + + This file is part of gnokii. + + Gnokii is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Gnokii 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 gnokii; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Copyright (C) 2006 Bastien Nocera + + This file provides functions specific to at commands on motorola + phones. See README for more details on supported mobile phones. + +*/ + +#include +#include +#include + +#include "config.h" +#include "compat.h" +#include "misc.h" +#include "gnokii.h" +#include "phones/generic.h" +#include "phones/atgen.h" +#include "phones/atmot.h" + +static at_recv_function_type identify; + +static gn_error ReplyIdentify(int messagetype, unsigned char *buffer, int length, gn_data *data, struct gn_statemachine *state) +{ + at_line_buffer buf; + gn_error error; + char *model; + + if (strlen (buffer) < 2 || strncmp(buffer + 1, "AT+CGMM", 7) != 0) { + return (*identify) (messagetype, buffer, length, data, state); + } + + if ((error = at_error_get(buffer, state)) != GN_ERR_NONE) return error; + + buf.line1 = buffer + 1; + buf.length = length; + splitlines(&buf); + + /* The line usually looks like: + * +CGMM: "GSM900","GSM1800","GSM1900","GSM850","MODEL=V547" + */ + model = strstr (buf.line2, "MODEL="); + if (!model) { + strcpy (data->model, strip_quotes(buf.line2 + 1 + strlen ("+CGMM: "))); + } else { + strcpy (data->model, strip_quotes(model + strlen ("MODEL="))); + model = strchr (data->model, '"'); + if (model) + *model = '\0'; + } + + return GN_ERR_NONE; +} + +void at_motorola_init(char* foundmodel, char* setupmodel, struct gn_statemachine *state) +{ + identify = at_insert_recv_function(GN_OP_Identify, ReplyIdentify, state); +} --- /dev/null 2006-02-09 09:03:48.738500360 +0000 +++ include/phones/atmot.h 2006-03-03 16:32:32.000000000 +0000 @@ -0,0 +1,39 @@ +/* + + $Id$ + + G N O K I I + + A Linux/Unix toolset and driver for the mobile phones. + + This file is part of gnokii. + + Gnokii is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Gnokii 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 gnokii; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Copyright (C) 2006 Bastien Nocera + + This file provides functions specific to AT commands on Siemens phones. + See README for more details on supported mobile phones. + +*/ + +#ifndef _gnokii_atmot_h_ +#define _gnokii_atmot_h_ + +#include "gnokii.h" + +void at_motorola_init(char* foundmodel, char* setupmodel, struct gn_statemachine *state); + +#endif