From: <svn...@op...> - 2010-04-18 08:49:51
|
Author: dgollub Date: Sun Apr 18 10:49:40 2010 New Revision: 6045 URL: http://www.opensync.org/changeset/6045 Log: Make serialization of username optional, depending on support flags. Fixes issues with Barry plugin. Patch by Nicolas Modified: trunk/opensync/ipc/opensync_serializer.c Modified: trunk/opensync/ipc/opensync_serializer.c ============================================================================== --- trunk/opensync/ipc/opensync_serializer.c Sun Feb 28 18:40:50 2010 (r6044) +++ trunk/opensync/ipc/opensync_serializer.c Sun Apr 18 10:49:40 2010 (r6045) @@ -1358,6 +1358,7 @@ return FALSE; } +#define MARSHAL_PLUGINAUTEHNTICATION_USERNAME (1 << 0) #define MARSHAL_PLUGINAUTEHNTICATION_PASSWORD (1 << 1) #define MARSHAL_PLUGINAUTEHNTICATION_REFERENCE (1 << 2) @@ -1382,12 +1383,20 @@ * */ - username = osync_plugin_authentication_get_username(auth); - password = osync_plugin_authentication_get_password(auth); - reference = osync_plugin_authentication_get_reference(auth); + if (osync_plugin_authentication_option_is_supported(auth, OSYNC_PLUGIN_AUTHENTICATION_USERNAME)) + username = osync_plugin_authentication_get_username(auth); + + if (osync_plugin_authentication_option_is_supported(auth, OSYNC_PLUGIN_AUTHENTICATION_PASSWORD)) + password = osync_plugin_authentication_get_password(auth); + + if (osync_plugin_authentication_option_is_supported(auth, OSYNC_PLUGIN_AUTHENTICATION_REFERENCE)) + reference = osync_plugin_authentication_get_reference(auth); osync_assert(username); + if (username) + available_fields |= MARSHAL_PLUGINAUTEHNTICATION_USERNAME; + if (password) available_fields |= MARSHAL_PLUGINAUTEHNTICATION_PASSWORD; @@ -1396,7 +1405,8 @@ osync_message_write_uint(message, available_fields, error); - osync_message_write_string(message, username, error); + if (username) + osync_message_write_string(message, username, error); if (password) osync_message_write_string(message, password, error); @@ -1420,6 +1430,9 @@ char *password = NULL; char *reference = NULL; + // Supported options by default : none + OSyncPluginAuthenticationOptionSupportedFlags supported_options = 0; + osync_assert(message); /* @@ -1440,16 +1453,20 @@ if (!osync_message_read_uint(message, &available_fields, error)) goto error; - if (!osync_message_read_string(message, &username, error)) - goto error; + if (available_fields & MARSHAL_PLUGINAUTEHNTICATION_USERNAME) { + if (!osync_message_read_string(message, &username, error)) + goto error; - osync_plugin_authentication_set_username(*auth, username); - osync_free(username); + supported_options |= OSYNC_PLUGIN_AUTHENTICATION_USERNAME; + osync_plugin_authentication_set_username(*auth, username); + osync_free(username); + } if (available_fields & MARSHAL_PLUGINAUTEHNTICATION_PASSWORD) { if (!osync_message_read_string(message, &password, error)) goto error; + supported_options |= OSYNC_PLUGIN_AUTHENTICATION_PASSWORD; osync_plugin_authentication_set_password(*auth, password); osync_free(password); } @@ -1458,10 +1475,13 @@ if (!osync_message_read_string(message, &reference, error)) goto error; + supported_options |= OSYNC_PLUGIN_AUTHENTICATION_REFERENCE; osync_plugin_authentication_set_reference(*auth, reference); osync_free(reference); } + osync_plugin_authentication_option_set_supported(*auth, supported_options); + return TRUE; error: return FALSE; |