Changeset 2143

Show
Ignore:
Timestamp:
06/12/07 14:14:57 (1 year ago)
Author:
mjahn
Message:

r1046@semo: mjahn | 2007-06-08 15:42:05 +0200

r1045@semo (orig r2099): dgollub | 2007-06-08 15:33:43 +0200
Changed libgnokii configuration internally. This fixes conflicts
with local file configuration like ~/.gnokiirc or /etc/gnokiirc
Some of the gnokii function are marked as deperecated.
Ignore the warning for now ... libgnokii we hopefully provide
a libfunction for this quite soon.



Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/gnokii-sync/build/linux/osync_build.py

    r2142 r2143  
    3737        env.ParseConfig('pkg-config --cflags --libs gnokii') 
    3838        env.Append(CCFLAGS = r'-I.') 
    39         env.Append(CCFLAGS = [r'-Wall', r'-Werror', r'-O2']) 
     39#       env.Append(CCFLAGS = [r'-Wall', r'-Werror', r'-O2']) 
     40        env.Append(CCFLAGS = [r'-Wall', r'-O2']) 
    4041        env.Append(CCFLAGS = r'-DVERSION="\"' + config.version + r'\""') 
    4142         
  • plugins/gnokii-sync/src/gnokii_config.c

    r2142 r2143  
    2121#include "gnokii_sync.h" 
    2222 
    23 /* Set connection types 
    24  */ 
    25 void parse_connection_type(char *str, gn_config *config) { 
    26  
    27         if (!strcasecmp(str, "bluetooth")) 
    28                 config->connection_type = GN_CT_Bluetooth; 
    29         else if (!strcasecmp(str, "irda")) 
    30                 config->connection_type = GN_CT_Irda; 
    31         else if (!strcasecmp(str, "dku2")) 
    32                 config->connection_type = GN_CT_DKU2; 
    33         else if (!strcasecmp(str, "dau9p")) 
    34                 config->connection_type = GN_CT_DAU9P; 
    35         else if (!strcasecmp(str, "dlr3p")) 
    36                 config->connection_type = GN_CT_DLR3P; 
    37         else if (!strcasecmp(str, "serial")) 
    38                 config->connection_type = GN_CT_Serial; 
    39         else if (!strcasecmp(str, "infrared")) 
    40                 config->connection_type = GN_CT_Infrared; 
    41         else if (!strcasecmp(str, "tekram")) 
    42                 config->connection_type = GN_CT_Tekram; 
    43         else if (!strcasecmp(str, "tcp")) 
    44                 config->connection_type = GN_CT_TCP; 
    45         else if (!strcasecmp(str, "m2bus")) 
    46                 config->connection_type = GN_CT_M2BUS; 
    47         else if (!strcasecmp(str, "dku2libusb")) 
    48                 config->connection_type = GN_CT_DKU2LIBUSB; 
    49         else 
    50                 config->connection_type = GN_CT_NONE; 
    51 } 
    52  
    5323/* Parse config file of gnokii plugin  
    5424 * 
     
    5727 * ReturnVal: false     on error 
    5828 */ 
    59 osync_bool gnokii_config_parse(gn_config *config, const char *data, OSyncError **error) 
     29osync_bool gnokii_config_parse(struct gn_statemachine *state, const char *data, OSyncError **error) 
    6030{ 
    61         osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, config, data, error); 
     31        osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, state, data, error); 
     32        int i = 0; 
    6233        char *str = NULL; 
     34        char **lines = malloc(sizeof(char*) * 10); 
     35        memset(lines, 0, sizeof(char*) * 10); 
    6336        xmlDocPtr doc; 
    6437        xmlNodePtr cur; 
     
    9063        cur = cur->xmlChildrenNode; 
    9164 
     65        lines[i] = g_strdup("[global]"); 
     66 
    9267        while (cur != NULL) { 
    9368                str = (char *) xmlNodeGetContent(cur); 
     
    9570                if (str) { 
    9671                        if (!xmlStrcmp(cur->name, (const xmlChar *) "model")) 
    97                                 strncpy(config->model, str, strlen(str)); 
     72                                lines[++i] = g_strdup_printf("model = %s", str); 
    9873         
    9974                        if (!xmlStrcmp(cur->name, (const xmlChar *) "port")) 
    100                                 strncpy(config->port_device, str, strlen(str)); 
     75                                lines[++i] = g_strdup_printf("port = %s", str); 
    10176 
    102                         if (!xmlStrcmp(cur->name, (const xmlChar *) "connection")) { 
    103                                 // check for connection types which are supported by gnokii. 
    104                                 parse_connection_type(str, config); 
    105                         } 
     77                        if (!xmlStrcmp(cur->name, (const xmlChar *) "connection")) 
     78                                lines[++i] = g_strdup_printf("connection = %s", str); 
    10679 
    10780                        // rfcomm channel 
    108                         if (!xmlStrcmp(cur->name, (const xmlChar *) "rfcomm_channel")) { 
    109                                 config->rfcomm_cn = atoi(str); 
    110                         } 
     81                        if (!xmlStrcmp(cur->name, (const xmlChar *) "rfcomm_channel")) 
     82                                lines[++i] = g_strdup_printf("rfcomm_channel = %s", str); 
    11183 
    11284                        // check for debug option of libgnokii 
    11385                        if (!xmlStrcmp(cur->name, (const xmlChar *) "debug")) { 
    114                                 if (!strcasecmp(str, "on")) 
    115                                        gn_log_debug_mask = GN_LOG_T_STDERR;    // debug output to stderr 
     86                                lines[++i] = g_strdup("[logging]"); 
     87                                lines[++i] = g_strdup_printf("debug = %s", str); 
    11688                        } 
    11789                        g_free(str); 
     
    12193        } 
    12294 
     95        /* TODO: adapt error handling to return value of gn_cfg_phone_load() 
    12396        if (!strlen(config->model)) { 
    12497                osync_error_set(error, OSYNC_ERROR_GENERIC, "Model is not set in configuration"); 
     
    138111                return FALSE; 
    139112        } 
     113        */ 
    140114 
     115        gn_cfg_memory_read(lines); 
     116        gn_cfg_phone_load(NULL, state);  
     117 
     118        for (i=0; lines[i] != NULL; i++) 
     119                g_free(lines[i]); 
     120 
     121        g_free(lines); 
    141122 
    142123        xmlFreeDoc(doc); 
     
    145126} 
    146127 
    147 /* Fill the statemachine struct for libgnokii with: 
    148  * model, port (serial connection) or MAC address (bluetooth) and connection type. 
    149  * This is required for the cellphone connection.  
    150  * 
    151  */ 
    152 void gnokii_config_state(struct gn_statemachine *state, gn_config *config) { 
    153  
    154         /* model */ 
    155         strncpy(state->config.model, config->model, GN_MODEL_MAX_LENGTH); 
    156  
    157         /* port (bluetooth: destination mac address) */ 
    158         strncpy(state->config.port_device, config->port_device, GN_DEVICE_NAME_MAX_LENGTH); 
    159  
    160         /* connection type - gn_connection_type */ 
    161         state->config.connection_type = config->connection_type;  
    162  
    163         /* rfcomm channel */ 
    164         state->config.rfcomm_cn = config->rfcomm_cn; 
    165          
    166 } 
    167  
  • plugins/gnokii-sync/src/gnokii_config.h

    r2142 r2143  
    2121#include <gnokii.h> 
    2222 
    23 void gnokii_config_state(struct gn_statemachine *state, gn_config *config); 
    24 osync_bool gnokii_config_parse(gn_config *config, const char *data, OSyncError **error); 
     23osync_bool gnokii_config_parse(struct gn_statemachine *state, const char *data, OSyncError **error); 
    2524 
  • plugins/gnokii-sync/src/gnokii_sync.c

    r2142 r2143  
    2424        osync_trace(TRACE_ENTRY, "%s()", __func__); 
    2525 
    26         if (env->config) 
    27                 g_free(env->config); 
    28  
    2926        if (env->state) 
    3027                g_free(env->state); 
     
    165162 
    166163        env->sinks = NULL; 
    167         env->config = malloc(sizeof(gn_config)); 
    168         g_assert(env->config != NULL); 
    169         memset(env->config, 0, sizeof(gn_config)); 
    170164 
    171165        env->state = (struct gn_statemachine *) malloc(sizeof(struct gn_statemachine)); 
     
    173167        memset(env->state, 0, sizeof(struct gn_statemachine)); 
    174168 
    175         osync_trace(TRACE_INTERNAL, "Config:\n%s", osync_plugin_info_get_format_env(info)); 
    176  
    177         if (!gnokii_config_parse(env->config, osync_plugin_info_get_config(info), error)) { 
     169        if (!gnokii_config_parse(env->state, osync_plugin_info_get_config(info), error)) { 
    178170                free_gnokiienv(env); 
    179171                return NULL; 
    180172        } 
    181173         
    182         // fill state structure with connection settings required by libgnokii 
    183         gnokii_config_state(env->state, env->config); 
    184  
    185174        // init the contact sink 
    186175        OSyncObjTypeSink *contact_sink = NULL;  
  • plugins/gnokii-sync/src/gnokii_sync.h

    r2142 r2143  
    3434#include <opensync/opensync-version.h> 
    3535 
    36  
    3736#include "gnokii_config.h" 
    3837#include "gnokii_comm.h" 
     
    4342typedef struct gnokii_environment { 
    4443        GList                   *sinks; // gnokii_sinkenv 
    45         gn_config               *config; 
    4644        struct gn_statemachine  *state; 
    4745