Changeset 2099
- Timestamp:
- 06/08/07 15:33:43 (1 year ago)
- Files:
-
- plugins/gnokii-sync/build/linux/osync_build.py (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_config.c (modified) (7 diffs)
- plugins/gnokii-sync/src/gnokii_config.h (modified) (1 diff)
- plugins/gnokii-sync/src/gnokii_sync.c (modified) (3 diffs)
- plugins/gnokii-sync/src/gnokii_sync.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/gnokii-sync/build/linux/osync_build.py
r2097 r2099 37 37 env.ParseConfig('pkg-config --cflags --libs gnokii') 38 38 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']) 40 41 env.Append(CCFLAGS = r'-DVERSION="\"' + config.version + r'\""') 41 42 plugins/gnokii-sync/src/gnokii_config.c
r2097 r2099 21 21 #include "gnokii_sync.h" 22 22 23 /* Set connection types24 */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 else50 config->connection_type = GN_CT_NONE;51 }52 53 23 /* Parse config file of gnokii plugin 54 24 * … … 57 27 * ReturnVal: false on error 58 28 */ 59 osync_bool gnokii_config_parse( gn_config *config, const char *data, OSyncError **error)29 osync_bool gnokii_config_parse(struct gn_statemachine *state, const char *data, OSyncError **error) 60 30 { 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; 62 33 char *str = NULL; 34 char **lines = malloc(sizeof(char*) * 10); 35 memset(lines, 0, sizeof(char*) * 10); 63 36 xmlDocPtr doc; 64 37 xmlNodePtr cur; … … 90 63 cur = cur->xmlChildrenNode; 91 64 65 lines[i] = g_strdup("[global]"); 66 92 67 while (cur != NULL) { 93 68 str = (char *) xmlNodeGetContent(cur); … … 95 70 if (str) { 96 71 if (!xmlStrcmp(cur->name, (const xmlChar *) "model")) 97 strncpy(config->model, str, strlen(str));72 lines[++i] = g_strdup_printf("model = %s", str); 98 73 99 74 if (!xmlStrcmp(cur->name, (const xmlChar *) "port")) 100 strncpy(config->port_device, str, strlen(str));75 lines[++i] = g_strdup_printf("port = %s", str); 101 76 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); 106 79 107 80 // 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); 111 83 112 84 // check for debug option of libgnokii 113 85 if (!xmlStrcmp(cur->name, (const xmlChar *) "debug")) { 114 if (!strcasecmp(str, "on"))115 gn_log_debug_mask = GN_LOG_T_STDERR; // debug output to stderr86 lines[++i] = g_strdup("[logging]"); 87 lines[++i] = g_strdup_printf("debug = %s", str); 116 88 } 117 89 g_free(str); … … 121 93 } 122 94 95 /* TODO: adapt error handling to return value of gn_cfg_phone_load() 123 96 if (!strlen(config->model)) { 124 97 osync_error_set(error, OSYNC_ERROR_GENERIC, "Model is not set in configuration"); … … 138 111 return FALSE; 139 112 } 113 */ 140 114 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); 141 122 142 123 xmlFreeDoc(doc); … … 145 126 } 146 127 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
r2097 r2099 21 21 #include <gnokii.h> 22 22 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); 23 osync_bool gnokii_config_parse(struct gn_statemachine *state, const char *data, OSyncError **error); 25 24 plugins/gnokii-sync/src/gnokii_sync.c
r2097 r2099 24 24 osync_trace(TRACE_ENTRY, "%s()", __func__); 25 25 26 if (env->config)27 g_free(env->config);28 29 26 if (env->state) 30 27 g_free(env->state); … … 165 162 166 163 env->sinks = NULL; 167 env->config = malloc(sizeof(gn_config));168 g_assert(env->config != NULL);169 memset(env->config, 0, sizeof(gn_config));170 164 171 165 env->state = (struct gn_statemachine *) malloc(sizeof(struct gn_statemachine)); … … 173 167 memset(env->state, 0, sizeof(struct gn_statemachine)); 174 168 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)) { 178 170 free_gnokiienv(env); 179 171 return NULL; 180 172 } 181 173 182 // fill state structure with connection settings required by libgnokii183 gnokii_config_state(env->state, env->config);184 185 174 // init the contact sink 186 175 OSyncObjTypeSink *contact_sink = NULL; plugins/gnokii-sync/src/gnokii_sync.h
r2097 r2099 34 34 #include <opensync/opensync-version.h> 35 35 36 37 36 #include "gnokii_config.h" 38 37 #include "gnokii_comm.h" … … 43 42 typedef struct gnokii_environment { 44 43 GList *sinks; // gnokii_sinkenv 45 gn_config *config;46 44 struct gn_statemachine *state; 47 45
