From: <svn...@op...> - 2009-04-12 20:43:39
|
Author: scriptor Date: Sun Apr 12 22:43:27 2009 New Revision: 5591 URL: http://www.opensync.org/changeset/5591 Log: Added support for testing the "note" format "memo". Modified: plugins/ldap-sync/misc/ldap_format_convert.c plugins/ldap-sync/tests/check_do_convert_from_to.c Modified: plugins/ldap-sync/misc/ldap_format_convert.c ============================================================================== --- plugins/ldap-sync/misc/ldap_format_convert.c Sun Apr 12 20:58:16 2009 (r5590) +++ plugins/ldap-sync/misc/ldap_format_convert.c Sun Apr 12 22:43:27 2009 (r5591) @@ -56,6 +56,7 @@ TARGET_VTODO_10, TARGET_VTODO_20, TARGET_LDAP_TODO, + TARGET_MEMO, TARGET_VNOTE_11, TARGET_VJOURNAL, TARGET_LDAP_NOTE, @@ -254,6 +255,31 @@ + } else if (!strcmp(sfname, "memo")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VJOURNAL: + targetformat = osync_format_env_find_objformat(env, "vjournal"); + break; + + case TARGET_VNOTE_11: + targetformat = osync_format_env_find_objformat(env, "vnote11"); + break; + + case TARGET_LDAP_NOTE: + targetformat = osync_format_env_find_objformat(env, "ldap-note"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert memo into this format. Supported formats: xmlformat, ldap-note, vnote11, vjournal.", __FILE__, __LINE__); + goto error; + } + + } else if (!strcmp(sfname, "vnote11")) { switch (type) { case TARGET_AUTO: @@ -265,12 +291,16 @@ targetformat = osync_format_env_find_objformat(env, "ldap-note"); break; + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; + case TARGET_XMLFORMAT: targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); break; default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vnote11 into this format. Supported formats: xmlformat, ldap-note, vjournal.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vnote11 into this format. Supported formats: xmlformat, ldap-note, memo, vjournal.", __FILE__, __LINE__); goto error; } @@ -283,6 +313,10 @@ targetformat = osync_format_env_find_objformat(env, "vnote11"); break; + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; + case TARGET_LDAP_NOTE: targetformat = osync_format_env_find_objformat(env, "ldap-event"); break; @@ -292,7 +326,7 @@ break; default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vjournal into this format. Supported formats: xmlformat, ldap-note, vnote11.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vjournal into this format. Supported formats: xmlformat, memo, ldap-note, vnote11.", __FILE__, __LINE__); goto error; } @@ -393,9 +427,13 @@ case TARGET_XMLFORMAT: targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); break; + + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-note-doc into this format. Supported formats: vnote11, ldap-note, xmlformat-note.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-note-doc into this format. Supported formats: vnote11, ldap-note, memo, xmlformat-note.", __FILE__, __LINE__); goto error; } @@ -417,8 +455,12 @@ targetformat = osync_format_env_find_objformat(env, "xmlformat-journal"); break; + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; + default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-journal-doc into this format. Supported formats: vjournal, ldap-note, xmlformat-journal.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-journal-doc into this format. Supported formats: vjournal, ldap-note, memo, xmlformat-journal.", __FILE__, __LINE__); goto error; } @@ -533,13 +575,17 @@ case TARGET_VNOTE_11: targetformat = osync_format_env_find_objformat(env, "vnote11"); break; + + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; case TARGET_XMLFORMAT: targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); break; default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert ldap-note into this format. Supported formats: xmlformat, vjournal, vnote11.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert ldap-note into this format. Supported formats: xmlformat, memo, vjournal, vnote11.", __FILE__, __LINE__); goto error; } @@ -599,6 +645,7 @@ fprintf(stderr, "--to-ldap-todo\tConvert to LDAP todo\n"); fprintf(stderr, "--to-vnote11\tConvert to vnote 1.1\n"); fprintf(stderr, "--to-vjournal\tConvert to vjournal\n"); + fprintf(stderr, "--to-memo\tConvert to memo\n"); fprintf(stderr, "--to-ldap-note\tConvert to LDAP note\n"); fprintf(stderr, "--to-xmlformat\tConvert to xmlformat\n"); @@ -929,6 +976,9 @@ } else if (!strcmp (arg, "--to-vjournal")) { detection_type = TARGET_VJOURNAL; + } else if (!strcmp (arg, "--to-memo")) { + detection_type = TARGET_MEMO; + } else if (!strcmp (arg, "--to-xmlformat")) { detection_type = TARGET_XMLFORMAT; @@ -949,15 +999,15 @@ } else if (!strcmp (arg, "--out")) { if (!strncmp(argv[i + 1], "--", 2)) { osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Output filename MUST NOT begin with \'--\'. Use --help, if necessary.", __FILE__, __LINE__); - continue; + goto error; } else if (!strncmp(argv[i + 1], "-", 1)) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR. Output filename MUST NOT begin with \'-\'. Use --help, if necessary.", __FILE__, __LINE__); - continue; + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR. Output filename MUST NOT begin with \'-\'. Use --help, if necessary.", __FILE__, __LINE__); + goto error; } else if (argv[i + 1] == 0) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: --out must be followed by a name of a file where the output can be written to. Use --help, if necessary.", __FILE__, __LINE__); - continue; + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: --out must be followed by a name of a file where the output can be written to. Use --help, if necessary.", __FILE__, __LINE__); + goto error; } else { output_filename = argv[i + 1]; @@ -1182,7 +1232,9 @@ osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unknown reason.\n", __FILE__, __LINE__); } - + fprintf(stderr, "%s: %s", __func__, osync_error_print(&error)); + fflush(stderr); + osync_trace(TRACE_ERROR, "%s: %s", __func__, osync_error_print(&error)); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); return 1; } Modified: plugins/ldap-sync/tests/check_do_convert_from_to.c ============================================================================== --- plugins/ldap-sync/tests/check_do_convert_from_to.c Sun Apr 12 20:58:16 2009 (r5590) +++ plugins/ldap-sync/tests/check_do_convert_from_to.c Sun Apr 12 22:43:27 2009 (r5591) @@ -56,6 +56,7 @@ TARGET_VTODO_10, TARGET_VTODO_20, TARGET_LDAP_TODO, + TARGET_MEMO, TARGET_VNOTE_11, TARGET_VJOURNAL, TARGET_LDAP_NOTE, @@ -254,6 +255,31 @@ + } else if (!strcmp(sfname, "memo")) { + switch (type) { + case TARGET_AUTO: + case TARGET_VJOURNAL: + targetformat = osync_format_env_find_objformat(env, "vjournal"); + break; + + case TARGET_VNOTE_11: + targetformat = osync_format_env_find_objformat(env, "vnote11"); + break; + + case TARGET_LDAP_NOTE: + targetformat = osync_format_env_find_objformat(env, "ldap-note"); + break; + + case TARGET_XMLFORMAT: + targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); + break; + + default: + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert memo into this format. Supported formats: xmlformat, ldap-note, vnote11, vjournal.", __FILE__, __LINE__); + goto error; + } + + } else if (!strcmp(sfname, "vnote11")) { switch (type) { case TARGET_AUTO: @@ -265,12 +291,16 @@ targetformat = osync_format_env_find_objformat(env, "ldap-note"); break; + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; + case TARGET_XMLFORMAT: targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); break; default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vnote11 into this format. Supported formats: xmlformat, ldap-note, vjournal.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vnote11 into this format. Supported formats: xmlformat, ldap-note, memo, vjournal.", __FILE__, __LINE__); goto error; } @@ -283,6 +313,10 @@ targetformat = osync_format_env_find_objformat(env, "vnote11"); break; + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; + case TARGET_LDAP_NOTE: targetformat = osync_format_env_find_objformat(env, "ldap-event"); break; @@ -292,7 +326,7 @@ break; default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vjournal into this format. Supported formats: xmlformat, ldap-note, vnote11.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert vjournal into this format. Supported formats: xmlformat, memo, ldap-note, vnote11.", __FILE__, __LINE__); goto error; } @@ -393,9 +427,13 @@ case TARGET_XMLFORMAT: targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); break; + + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-note-doc into this format. Supported formats: vnote11, ldap-note, xmlformat-note.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-note-doc into this format. Supported formats: vnote11, ldap-note, memo, xmlformat-note.", __FILE__, __LINE__); goto error; } @@ -417,8 +455,12 @@ targetformat = osync_format_env_find_objformat(env, "xmlformat-journal"); break; + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; + default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-journal-doc into this format. Supported formats: vjournal, ldap-note, xmlformat-journal.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert xmlformat-journal-doc into this format. Supported formats: vjournal, ldap-note, memo, xmlformat-journal.", __FILE__, __LINE__); goto error; } @@ -533,13 +575,17 @@ case TARGET_VNOTE_11: targetformat = osync_format_env_find_objformat(env, "vnote11"); break; + + case TARGET_MEMO: + targetformat = osync_format_env_find_objformat(env, "memo"); + break; case TARGET_XMLFORMAT: targetformat = osync_format_env_find_objformat(env, "xmlformat-note"); break; default: - osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert ldap-note into this format. Supported formats: xmlformat, vjournal, vnote11.", __FILE__, __LINE__); + osync_error_set(error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unable to convert ldap-note into this format. Supported formats: xmlformat, memo, vjournal, vnote11.", __FILE__, __LINE__); goto error; } @@ -599,6 +645,7 @@ fprintf(stderr, "--to-ldap-todo\tConvert to LDAP todo\n"); fprintf(stderr, "--to-vnote11\tConvert to vnote 1.1\n"); fprintf(stderr, "--to-vjournal\tConvert to vjournal\n"); + fprintf(stderr, "--to-memo\tConvert to memo\n"); fprintf(stderr, "--to-ldap-note\tConvert to LDAP note\n"); fprintf(stderr, "--to-xmlformat\tConvert to xmlformat\n"); @@ -929,6 +976,9 @@ } else if (!strcmp (arg, "--to-vjournal")) { detection_type = TARGET_VJOURNAL; + } else if (!strcmp (arg, "--to-memo")) { + detection_type = TARGET_MEMO; + } else if (!strcmp (arg, "--to-xmlformat")) { detection_type = TARGET_XMLFORMAT; @@ -949,15 +999,15 @@ } else if (!strcmp (arg, "--out")) { if (!strncmp(argv[i + 1], "--", 2)) { osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Output filename MUST NOT begin with \'--\'. Use --help, if necessary.", __FILE__, __LINE__); - continue; + goto error; } else if (!strncmp(argv[i + 1], "-", 1)) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR. Output filename MUST NOT begin with \'-\'. Use --help, if necessary.", __FILE__, __LINE__); - continue; + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR. Output filename MUST NOT begin with \'-\'. Use --help, if necessary.", __FILE__, __LINE__); + goto error; } else if (argv[i + 1] == 0) { - osync_trace(TRACE_ERROR, "%s:%i: ERROR: --out must be followed by a name of a file where the output can be written to. Use --help, if necessary.", __FILE__, __LINE__); - continue; + osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: --out must be followed by a name of a file where the output can be written to. Use --help, if necessary.", __FILE__, __LINE__); + goto error; } else { output_filename = argv[i + 1]; @@ -1182,7 +1232,9 @@ osync_error_set(&error, OSYNC_ERROR_GENERIC, "%s:%i: ERROR: Unknown reason.\n", __FILE__, __LINE__); } - + fprintf(stderr, "%s: %s", __func__, osync_error_print(&error)); + fflush(stderr); + osync_trace(TRACE_ERROR, "%s: %s", __func__, osync_error_print(&error)); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); return 1; } |