Index: common/libfunctions.c =================================================================== RCS file: /sources/gnokii/gnokii/common/libfunctions.c,v retrieving revision 1.32 diff -u -p -r1.32 libfunctions.c --- common/libfunctions.c 29 May 2007 19:26:40 -0000 1.32 +++ common/libfunctions.c 7 Jul 2007 16:15:05 -0000 @@ -46,6 +46,8 @@ #include "misc.h" #include "gnokii.h" #include "device.h" +#include "cfgreader.h" +#include "gnokii-internal.h" /* this macro sets the "lasterror" code */ #define LASTERROR(state,nr) ((state->lasterror = nr)) /* do not delete the double brackets! */ @@ -502,3 +504,27 @@ GNOKII_API gn_error gn_lib_search_one_co return LASTERROR((*state), GN_ERR_UNKNOWNMODEL); } +GNOKII_API gn_error gn_lib_reconnect_with_driver(struct gn_statemachine *state, const char *driver) +{ + gn_error error; + + if ((error = gn_lib_phone_close (state)) != GN_ERR_NONE) { + fprintf(stderr, _("gn_lib_phone_close failed: %s\nQuitting.\n"), + gn_error_print(error)); + return error; + } + + if (cfg_set (gn_cfg_info, "global", "model", driver) == NULL) { + fprintf(stderr, _("cfg_set failed: \nQuitting.\n")); + return GN_ERR_NOCONFIG; + } + + sleep (2); + if ((error = gn_lib_phone_open (state)) != GN_ERR_NONE) { + fprintf(stderr, _("gn_lib_phone_open failed: %s\nQuitting.\n"), + gn_error_print(error)); + return error; + } + + return GN_ERR_NONE; +} Index: include/gnokii.h =================================================================== RCS file: /sources/gnokii/gnokii/include/gnokii.h,v retrieving revision 1.111 diff -u -p -r1.111 gnokii.h --- include/gnokii.h 11 Jun 2007 20:36:23 -0000 1.111 +++ include/gnokii.h 7 Jul 2007 16:15:07 -0000 @@ -120,6 +120,9 @@ GNOKII_API gn_error gn_lib_phone_open( s /* closes the connection to the phone */ GNOKII_API gn_error gn_lib_phone_close( struct gn_statemachine *state ); +/* reconnect to the phone using a different driver */ +GNOKII_API gn_error gn_lib_reconnect_with_driver( struct gn_statemachine *state, const char *driver ); + /* ask phone for static information (model, manufacturer, revision and imei) */ GNOKII_API const char *gn_lib_get_phone_model ( struct gn_statemachine *state ); /* e.g. 6310 */ GNOKII_API const char *gn_lib_get_phone_product_name( struct gn_statemachine *state ); /* e.g. NPE-4 */