Changeset 2102

Show
Ignore:
Timestamp:
06/09/07 00:32:45 (1 year ago)
Author:
dgollub
Message:

Added missing osync_context_report() avoids deadlock.
Reporting deleted entries is broken at the moment ...
Fixed an issue with wrong userdata and the gnokii_sinenv.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/gnokii-sync/src/gnokii_calendar.c

    r2097 r2102  
    443443        g_free(caldata); 
    444444 
     445        osync_context_report_success(ctx); 
     446 
    445447        osync_trace(TRACE_EXIT, "%s", __func__); 
    446448} 
  • plugins/gnokii-sync/src/gnokii_contact.c

    r2097 r2102  
    368368        gnokii_environment *env = (gnokii_environment *) plugindata; 
    369369 
     370        osync_trace(TRACE_INTERNAL, "sinkenv: %p", sinkenv); 
     371 
    370372 
    371373        // check for slowsync and prepare the "contact" hashtable if needed 
     
    420422                                continue; 
    421423 
     424                        hash = gnokii_contact_hash(contact); 
     425                        OSyncChangeType type = osync_hashtable_get_changetype(sinkenv->hashtable, uid, hash); 
     426 
     427                        if (type == OSYNC_CHANGE_TYPE_UNMODIFIED) { 
     428                                g_free(hash); 
     429                                continue; 
     430                        } 
     431 
     432                        osync_hashtable_update_hash(sinkenv->hashtable, type, uid, hash); 
     433 
    422434                        OSyncChange *change = osync_change_new(&error); 
    423435 
    424436                        // prepare UID with gnokii-contact-<memory type>-<memory location> 
    425437                        uid = gnokii_contact_uid(contact); 
     438 
    426439                        osync_change_set_uid(change, uid); 
    427                         g_free(uid); 
    428  
    429                         // get hash of contact  
    430                         hash = gnokii_contact_hash(contact); 
    431440                        osync_change_set_hash(change, hash);     
    432                         g_free(hash); 
    433  
     441                        osync_change_set_changetype(change, type); 
    434442 
    435443                        // set data 
    436                         OSyncData *data = osync_data_new((char *) contact, sizeof(gn_calnote), sinkenv->objformat, &error); 
     444                        osync_trace(TRACE_INTERNAL, "objformat: %p", sinkenv->objformat); 
     445                        OSyncData *data = osync_data_new((char *) contact, sizeof(gn_phonebook_entry), sinkenv->objformat, &error); 
    437446                        if (!data) { 
    438447                                osync_change_unref(change); 
     
    447456                        osync_change_set_data(change, data); 
    448457                        osync_data_unref(data); 
    449                  
    450                         OSyncChangeType type = osync_hashtable_get_changetype(sinkenv->hashtable, uid, hash); 
    451                         if (type != OSYNC_CHANGE_TYPE_UNMODIFIED) { 
    452                                osync_trace(TRACE_INTERNAL, "Position: %i Needs to be reported (!= hash)", location - 1); 
    453                                osync_context_report_change(ctx, change); 
    454                                 osync_hashtable_update_hash(sinkenv->hashtable, type, uid, hash); 
    455                         }       
     458 
     459                        osync_context_report_change(ctx, change); 
     460 
     461                        osync_trace(TRACE_INTERNAL, "Position: %i Needs to be reported (!= hash)", location - 1); 
     462                        osync_trace(TRACE_INTERNAL, "Change: %p", change); 
     463 
     464                        osync_change_unref(change); 
    456465 
    457466                        g_free(hash); 
     
    461470        } 
    462471 
    463         osync_trace(TRACE_INTERNAL, "number of contact notes: %i", location - 1); 
    464  
     472 
     473        /* FIXME: this is really really broken :(  
    465474        int i; 
     475 
    466476        char **uids = osync_hashtable_get_deleted(sinkenv->hashtable); 
    467477        for (i = 0; uids[i]; i++) { 
     
    498508        } 
    499509        g_free(uids); 
    500  
    501  
     510        */ 
     511 
     512        osync_context_report_success(ctx); 
    502513 
    503514        osync_trace(TRACE_EXIT, "%s()", __func__); 
  • plugins/gnokii-sync/src/gnokii_sync.c

    r2099 r2102  
    156156        char *configdata = NULL; 
    157157         
     158        OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info);  
     159 
    158160        // create gnokii_environment which stores config and statemachine for libgnokii 
    159         gnokii_environment *env = malloc(sizeof(gnokii_environment)); 
    160         g_assert(env != NULL); 
    161         memset(env, 0, sizeof(gnokii_environment))
     161        gnokii_environment *env = osync_try_malloc0(sizeof(gnokii_environment), error); 
     162        if (!env) 
     163               return NULL
    162164 
    163165        env->sinks = NULL; 
    164166 
    165         env->state = (struct gn_statemachine *) malloc(sizeof(struct gn_statemachine)); 
    166         g_assert(env->state != NULL); 
    167         memset(env->state, 0, sizeof(struct gn_statemachine)); 
    168  
     167        env->state = osync_try_malloc0(sizeof(struct gn_statemachine), error); 
     168        if (!env->state) { 
     169                free_gnokiienv(env); 
     170                return NULL; 
     171        } 
     172 
     173        // parse the member configuration 
    169174        if (!gnokii_config_parse(env->state, osync_plugin_info_get_config(info), error)) { 
    170175                free_gnokiienv(env); 
     
    173178         
    174179        // init the contact sink 
    175         OSyncObjTypeSink *contact_sink = NULL;  
    176         contact_sink = osync_objtype_sink_new("contact", error); 
    177         osync_objtype_sink_add_objformat(contact_sink, "gnokii-contact"); 
     180        gnokii_sinkenv *contact_sinkenv = osync_try_malloc0(sizeof(gnokii_sinkenv), error);  
     181        contact_sinkenv->sink = osync_objtype_sink_new("contact", error); 
     182        osync_objtype_sink_add_objformat(contact_sinkenv->sink, "gnokii-contact"); 
    178183 
    179184        OSyncObjTypeSinkFunctions contact_functions; 
     
    187192        contact_functions.sync_done = sync_done; 
    188193 
    189         osync_objtype_sink_set_functions(contact_sink, contact_functions, env); 
    190         osync_plugin_info_add_objtype(info, contact_sink); 
    191  
    192         env->sinks = g_list_append(env->sinks, contact_sink); 
     194        osync_objtype_sink_set_functions(contact_sinkenv->sink, contact_functions, contact_sinkenv); 
     195        osync_plugin_info_add_objtype(info, contact_sinkenv->sink); 
     196 
     197        contact_sinkenv->objformat = osync_format_env_find_objformat(formatenv, "gnokii-contact"); 
     198        osync_trace(TRACE_INTERNAL, "contact_sinkenv->objformat: %p", contact_sinkenv->objformat); 
     199 
     200        env->sinks = g_list_append(env->sinks, contact_sinkenv); 
    193201 
    194202 
    195203        // init the event sink 
    196         OSyncObjTypeSink *event_sink = osync_objtype_sink_new("event", error); 
    197         osync_objtype_sink_add_objformat(event_sink, "gnokii-event"); 
     204        gnokii_sinkenv *event_sinkenv = osync_try_malloc0(sizeof(gnokii_sinkenv), error);  
     205        event_sinkenv->sink = osync_objtype_sink_new("event", error); 
     206        osync_objtype_sink_add_objformat(event_sinkenv->sink, "gnokii-event"); 
    198207 
    199208        OSyncObjTypeSinkFunctions event_functions; 
     
    207216        event_functions.sync_done = sync_done; 
    208217 
    209         osync_objtype_sink_set_functions(event_sink, event_functions, env); 
    210         osync_plugin_info_add_objtype(info, event_sink); 
    211  
    212         env->sinks = g_list_append(env->sinks, event_sink); 
     218        osync_objtype_sink_set_functions(event_sinkenv->sink, event_functions, event_sinkenv); 
     219        osync_plugin_info_add_objtype(info, event_sinkenv->sink); 
     220 
     221        event_sinkenv->objformat = osync_format_env_find_objformat(formatenv, "gnokii-event"); 
     222 
     223        env->sinks = g_list_append(env->sinks, event_sinkenv); 
    213224 
    214225