Changeset 2348

Show
Ignore:
Timestamp:
07/22/07 14:48:22 (1 year ago)
Author:
dgollub
Message:

New implementation of configurable object formats.

Request "file" objformat from the engine. This makes storing of
configured objformats easier - since the engine takes care about
marshalling... and we can make use of the OSyncFile helpers.

For making 1:1 backups configure the <objformat> to "file" and disable
the converters in the engine...

e.g.: msynctool --sync BLUBB --disable-converters

Syncing with <objformat> set formatB and sourceformat formatA with
--disable-converters is non-sense ... because the converter gets involded.

Recommendation for UI Backup Wizard:

Create a spearate Backup group with the plugin for the device which
should get backuped and file-sync. file-sync with
<objformat>filer</objformat> (<objtype>data</objtype> (?)) and disable
the converters for each sync.

TODO: implement syncgroup config property to disable converters for the
group.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/file-sync/src/file_sync.c

    r2347 r2348  
    6666                        } else if (!xmlStrcmp(cur->name, (const xmlChar *)"objtype")) { 
    6767                                dir->objtype = g_strdup(str); 
     68                        } else if (!xmlStrcmp(cur->name, (const xmlChar *)"objformat")) { 
     69                                dir->objformat = g_strdup(str); 
    6870                        } else if (!xmlStrcmp(cur->name, (const xmlChar *)"recursive")) { 
    6971                                dir->recursive = (g_ascii_strcasecmp(str, "TRUE") == 0); 
     
    267269        osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, data, info, ctx, change); 
    268270        OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); 
     271        OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 
    269272        OSyncFileDir *dir = osync_objtype_sink_get_userdata(sink); 
    270273        OSyncError *error = NULL; 
     
    289292                        /* No break. Continue below */ 
    290293                case OSYNC_CHANGE_TYPE_MODIFIED: 
     294 
    291295                        //FIXME add ownership for file-sync 
     296 
    292297                        odata = osync_change_get_data(change); 
    293298                        g_assert(odata); 
     299 
     300                        /* Convert to the configured store object format */ 
     301                        if (dir->objformat && strcmp("file", dir->objformat)) { 
     302 
     303                                OSyncFormatConverterPath *path = NULL; 
     304 
     305                                OSyncObjFormat *fileformat = osync_format_env_find_objformat(formatenv, "file"); 
     306                                OSyncObjFormat *targetformat = osync_format_env_find_objformat(formatenv, dir->objformat); 
     307                                OSyncObjFormat *detectedFormat = osync_format_env_detect_objformat_full(formatenv, odata, &error); 
     308 
     309                                /* Sanity check - if the converters are disable the engine sends not the requested "file" object format */ 
     310                                if (fileformat == osync_data_get_objformat(odata)) { 
     311                                        /* Find converter path from file to detected format */ 
     312                                        path = osync_format_env_find_path(formatenv, fileformat, detectedFormat, &error); 
     313 
     314                                        if (!osync_format_env_convert(formatenv, path, odata, &error)) { 
     315                                                osync_error_set(&error, OSYNC_ERROR_EXISTS, "Can't convert to customized objformat."); 
     316                                                goto error; 
     317                                        } 
     318                                } 
     319 
     320                                /* Find converter path from detectedFormat to targetFromat. 
     321                                   This is needed to avoid shortcuts path: 
     322                                     "another object format with plain converter (or detector)" -> plain -> file 
     323                                 
     324                                   To be safe we convert $detectedFormat -> $targetformat in advance. 
     325                                   And later convert $targetformat to fileFormat. 
     326                                */ 
     327                                path = osync_format_env_find_path(formatenv, detectedFormat, targetformat, &error); 
     328 
     329                                if (!osync_format_env_convert(formatenv, path, odata, &error)) { 
     330                                        osync_error_set(&error, OSYNC_ERROR_EXISTS, "Can't convert to customized objformat."); 
     331                                        goto error; 
     332                                } 
     333 
     334 
     335                                /* Find converter path fromat $targetformat to fileFormat. */ 
     336                                path = osync_format_env_find_path(formatenv, targetformat, fileformat, &error); 
     337 
     338                                if (!osync_format_env_convert(formatenv, path, odata, &error)) { 
     339                                        osync_error_set(&error, OSYNC_ERROR_EXISTS, "Can't convert to customized objformat."); 
     340                                        goto error; 
     341                                } 
     342 
     343                        } 
     344 
    294345                        osync_data_get_data(odata, &buffer, &size); 
    295346                        g_assert(buffer); 
     
    571622        if (!osync_filesync_parse_settings(env, osync_plugin_info_get_config(info), error)) 
    572623                goto error_free_env; 
    573          
     624 
    574625        /* Now we register the objtypes that we can sync. This plugin is special. It can 
    575626         * synchronize any objtype we configure it to sync and where a conversion 
     
    583634                        goto error_free_env; 
    584635                 
     636 
     637                if (!osync_format_env_find_objformat(formatenv, dir->objformat)) { 
     638                        osync_error_set(error, OSYNC_ERROR_GENERIC, "Configured storage format \"%s\" for object type \"%s\" is unknown. Is the format plugin missing?"); 
     639                        goto error_free_env; 
     640                } 
     641         
     642 
    585643                dir->sink = sink; 
    586644                 
    587                 /* The file format is the only one we understand */ 
    588                 osync_objtype_sink_add_objformat(sink, "file"); 
     645                //osync_objtype_sink_add_objformat(sink, "file"); 
     646                osync_objtype_sink_add_objformat(sink, dir->objformat); 
    589647                 
    590648                /* All sinks have the same functions of course */ 
  • plugins/file-sync/src/file_sync.h

    r2347 r2348  
    4545typedef struct OSyncFileDir { 
    4646        char *objtype; 
     47        char *objformat; 
    4748        char *path; 
    4849        GDir *dir;