You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
(56) |
Apr
(109) |
May
(15) |
Jun
(3) |
Jul
(37) |
Aug
(96) |
Sep
(40) |
Oct
(4) |
Nov
(54) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(47) |
Feb
(30) |
Mar
(102) |
Apr
(120) |
May
(68) |
Jun
(54) |
Jul
(53) |
Aug
(122) |
Sep
(190) |
Oct
(71) |
Nov
(85) |
Dec
(108) |
2007 |
Jan
(72) |
Feb
(190) |
Mar
(53) |
Apr
(101) |
May
(145) |
Jun
(148) |
Jul
(167) |
Aug
(143) |
Sep
(23) |
Oct
(198) |
Nov
(223) |
Dec
(195) |
2008 |
Jan
(100) |
Feb
(129) |
Mar
(79) |
Apr
(77) |
May
(34) |
Jun
(95) |
Jul
(112) |
Aug
(160) |
Sep
(82) |
Oct
(124) |
Nov
(199) |
Dec
(355) |
2009 |
Jan
(436) |
Feb
(89) |
Mar
(298) |
Apr
(189) |
May
(33) |
Jun
(88) |
Jul
(105) |
Aug
(44) |
Sep
(181) |
Oct
(87) |
Nov
(75) |
Dec
(1) |
2010 |
Jan
(63) |
Feb
(21) |
Mar
(3) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(26) |
Aug
(37) |
Sep
(26) |
Oct
(15) |
Nov
(13) |
Dec
|
From: <svn...@op...> - 2005-04-06 21:30:12
|
Author: drzeus Date: 2005-04-06 23:31:32 +0200 (Wed, 06 Apr 2005) New Revision: 448 Modified: trunk/misc/opensync.spec.in Log: RPM lacked an explicit make Modified: trunk/misc/opensync.spec.in =================================================================== --- trunk/misc/opensync.spec.in 2005-04-06 21:24:21 UTC (rev 447) +++ trunk/misc/opensync.spec.in 2005-04-06 21:31:32 UTC (rev 448) @@ -37,6 +37,7 @@ %build %configure --enable-engine --disable-debug --disable-tracing --disable-profiling --enable-tools --disable-unit-tests --disable-python +make %install rm -rf %{buildroot} |
From: <svn...@op...> - 2005-04-06 21:28:17
|
Author: drzeus Date: 2005-04-06 23:29:37 +0200 (Wed, 06 Apr 2005) New Revision: 118 Added: trunk/misc/ trunk/misc/multisync.spec.in Modified: trunk/Makefile.am trunk/configure.in Log: RPM support Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2005-04-06 21:02:58 UTC (rev 117) +++ trunk/Makefile.am 2005-04-06 21:29:37 UTC (rev 118) @@ -5,7 +5,9 @@ EXTRA_DIST = \ autogen.sh \ buildtest.sh \ - gui + gui \ + misc/multisync.spec \ + misc/multisync.spec.in dist-hook: find $(distdir) -name .svn -print0 | xargs -0 rm -rf Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2005-04-06 21:02:58 UTC (rev 117) +++ trunk/configure.in 2005-04-06 21:29:37 UTC (rev 118) @@ -25,4 +25,5 @@ AC_OUTPUT([ Makefile tools/Makefile +misc/multisync.spec ]) Added: trunk/misc/multisync.spec.in =================================================================== --- trunk/misc/multisync.spec.in 2005-04-06 21:02:58 UTC (rev 117) +++ trunk/misc/multisync.spec.in 2005-04-06 21:29:37 UTC (rev 118) @@ -0,0 +1,63 @@ +Summary: A synchronisation program. +Name: @PACKAGE@ +Version: @VERSION@ +Release: 1 +License: GPL +Group: Applications/Communications +Source: %{name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version} +Requires: libxml2 glib2 libopensync libgnomeui +BuildRequires: libxml2-devel glib2-devel libopensync-devel +BuildRequires: libopensync-plugin-evolution2-devel libgnomeui-devel + +%description +MultiSync is a program to synchronize calendars, addressbooks and other PIM data +between programs on your computer and other computers, mobile devices, PDAs or +cell phones. It relies on the OpenSync framework to do the actual +synchronisation. + +%package cli +Summary: Command line version of %{name} +Group: Applications/Communications +Requires: libxml2 glib2 libopensync + +%description cli +Command line version of MultiSync. To allow synchronisation on machines which +lack a X server. + +%prep +%setup -q + +%build +%configure +cd gui +%configure +cd .. + +make +cd gui +make +cd .. + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} +rm -f %{buildroot}%{_bindir}/convcard +cd gui +make install DESTDIR=%{buildroot} +cd .. + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +%{_bindir}/multisync0.90 + +%files cli +%defattr(-,root,root) +%{_bindir}/msynctool + +%changelog +* Fri Mar 18 2005 Pierre Ossman <dr...@dr...> 0.90.15-1 +- Initial package |
From: <svn...@op...> - 2005-04-06 21:23:00
|
Author: abauer Date: 2005-04-06 23:24:21 +0200 (Wed, 06 Apr 2005) New Revision: 447 Modified: branches/experimental-kdepim/src/knotes.cpp Log: Strip html from the notes (if "rich" notes are enabled) Modified: branches/experimental-kdepim/src/knotes.cpp =================================================================== --- branches/experimental-kdepim/src/knotes.cpp 2005-04-06 13:20:14 UTC (rev 446) +++ branches/experimental-kdepim/src/knotes.cpp 2005-04-06 21:24:21 UTC (rev 447) @@ -99,8 +99,21 @@ static QString strip_html(QString input) { - QString output; - + printf("input is %s\n", (const char*)input.local8Bit()); + QString output = NULL; + unsigned int i = 0; + int inbraces = 0; + for (i = 0; i < input.length(); i++) { + QCharRef cur = input[i]; + if (cur == '<') + inbraces = 1; + if (cur == '>') + inbraces = 0; + if (!inbraces) + output += input[i]; + } + printf("output is %s\n", (const char*)output.local8Bit()); + return output; } bool KNotesDataSource::get_changeinfo(OSyncContext *ctx) |
From: <svn...@op...> - 2005-04-06 21:01:36
|
Author: abauer Date: 2005-04-06 23:02:58 +0200 (Wed, 06 Apr 2005) New Revision: 117 Removed: trunk/cli/ trunk/python/ Log: Removed obsolete python and cli directories |
From: <svn...@op...> - 2005-04-06 20:42:24
|
Author: drzeus Date: 2005-04-06 22:43:44 +0200 (Wed, 06 Apr 2005) New Revision: 116 Modified: trunk/gui/evolution2_sync/evolution2_sync.c trunk/gui/file-sync/file_sync.c Log: gcc4 fixes Modified: trunk/gui/evolution2_sync/evolution2_sync.c =================================================================== --- trunk/gui/evolution2_sync/evolution2_sync.c 2005-03-31 15:51:35 UTC (rev 115) +++ trunk/gui/evolution2_sync/evolution2_sync.c 2005-04-06 20:43:44 UTC (rev 116) @@ -135,12 +135,12 @@ { xmlDocPtr doc; - doc = xmlNewDoc("1.0"); - doc->children = xmlNewDocNode(doc, NULL, "config", NULL); + doc = xmlNewDoc((xmlChar*)"1.0"); + doc->children = xmlNewDocNode(doc, NULL, (xmlChar*)"config", NULL); - xmlNewChild(doc->children, NULL, "adress_path", options->addressbook_path); - xmlNewChild(doc->children, NULL, "calendar_path", options->calendar_path); - xmlNewChild(doc->children, NULL, "tasks_path", options->tasks_path); + xmlNewChild(doc->children, NULL, (xmlChar*)"adress_path", (xmlChar*)options->addressbook_path); + xmlNewChild(doc->children, NULL, (xmlChar*)"calendar_path", (xmlChar*)options->calendar_path); + xmlNewChild(doc->children, NULL, (xmlChar*)"tasks_path", (xmlChar*)options->tasks_path); xmlDocDumpMemory(doc, (xmlChar **)data, size); *size++; @@ -176,7 +176,7 @@ return FALSE; } - if (xmlStrcmp(cur->name, "config")) { + if (xmlStrcmp(cur->name, (xmlChar*)"config")) { printf("EVO2-SYNC data seems not to be a valid configdata.\n"); xmlFreeDoc(doc); return FALSE; @@ -185,7 +185,7 @@ cur = cur->xmlChildrenNode; while (cur != NULL) { - char *str = xmlNodeGetContent(cur); + char *str = (char*)xmlNodeGetContent(cur); if (str) { if (!xmlStrcmp(cur->name, (const xmlChar *)"adress_path")) { options->addressbook_path = g_strdup(str); Modified: trunk/gui/file-sync/file_sync.c =================================================================== --- trunk/gui/file-sync/file_sync.c 2005-03-31 15:51:35 UTC (rev 115) +++ trunk/gui/file-sync/file_sync.c 2005-04-06 20:43:44 UTC (rev 116) @@ -42,7 +42,7 @@ return FALSE; } - if (xmlStrcmp(cur->name, "config")) { + if (xmlStrcmp(cur->name, (xmlChar*)"config")) { xmlFreeDoc(doc); osync_error_set(error, OSYNC_ERROR_GENERIC, "Config valid is not valid"); osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); @@ -52,7 +52,7 @@ cur = cur->xmlChildrenNode; while (cur != NULL) { - char *str = xmlNodeGetContent(cur); + char *str = (char*)xmlNodeGetContent(cur); if (str) { if (!xmlStrcmp(cur->name, (const xmlChar *)"path")) { env->path = g_strdup(str); @@ -119,11 +119,11 @@ { xmlDocPtr doc; - doc = xmlNewDoc("1.0"); - doc->children = xmlNewDocNode(doc, NULL, "config", NULL); + doc = xmlNewDoc((xmlChar*)"1.0"); + doc->children = xmlNewDocNode(doc, NULL, (xmlChar*)"config", NULL); - xmlNewChild(doc->children, NULL, "path", options->path); - xmlNewChild(doc->children, NULL, "recursive", options->recursive ? "TRUE" : "FALSE"); + xmlNewChild(doc->children, NULL, (xmlChar*)"path", (xmlChar*)options->path); + xmlNewChild(doc->children, NULL, (xmlChar*)"recursive", (xmlChar*)(options->recursive ? "TRUE" : "FALSE")); xmlDocDumpMemory(doc, (xmlChar **)data, size); *size++; |
From: <svn...@op...> - 2005-04-06 13:18:55
|
Author: drzeus Date: 2005-04-06 15:20:14 +0200 (Wed, 06 Apr 2005) New Revision: 446 Added: plugins/evolution2/misc/ plugins/evolution2/misc/evolution2.spec.in Modified: plugins/evolution2/Makefile.am plugins/evolution2/configure.in Log: RPM support Modified: plugins/evolution2/Makefile.am =================================================================== --- plugins/evolution2/Makefile.am 2005-04-06 13:06:06 UTC (rev 445) +++ plugins/evolution2/Makefile.am 2005-04-06 13:20:14 UTC (rev 446) @@ -3,4 +3,6 @@ SUBDIRS = src EXTRA_DIST = \ - autogen.sh + autogen.sh \ + misc/evolution2.spec \ + misc/evolution2.spec.in Modified: plugins/evolution2/configure.in =================================================================== --- plugins/evolution2/configure.in 2005-04-06 13:06:06 UTC (rev 445) +++ plugins/evolution2/configure.in 2005-04-06 13:20:14 UTC (rev 446) @@ -49,4 +49,5 @@ AC_OUTPUT([ Makefile src/Makefile +misc/evolution2.spec ]) Added: plugins/evolution2/misc/evolution2.spec.in =================================================================== --- plugins/evolution2/misc/evolution2.spec.in 2005-04-06 13:06:06 UTC (rev 445) +++ plugins/evolution2/misc/evolution2.spec.in 2005-04-06 13:20:14 UTC (rev 446) @@ -0,0 +1,51 @@ +Summary: Evolution 2 sync. plugin for OpenSync +Name: @PACKAGE@ +Version: @VERSION@ +Release: 1 +License: GPL +Group: Development/Libraries +Source: %{name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version} +Requires: glib2 libopensync evolution-data-server +BuildRequires: glib2-devel libopensync-devel evolution-data-server-devel + +%description +This plugin allows applications using OpenSync to synchronise to and from +Evolution 2. + +%package devel +Summary: Header files, libraries and development documentation for %{name} +Group: Development/Libraries +Requires: %{name} = %{version} + +%description devel +This package contains the header files, static libraries and development +documentation for %{name}. If you like to develop programs using %{name}, +you will need to install %{name}-devel. + +%prep +%setup -q + +%build +%configure + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} +rm -f %{buildroot}%{_libdir}/opensync/plugins/*.la + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +%{_libdir}/opensync/plugins/evo2_sync.so +%{_datadir}/opensync/defaults/evo2-sync + +%files devel +%defattr(-,root,root) +%{_includedir}/opensync-1.0/opensync/evo2_sync.h + +%changelog +* Wed Apr 6 2005 Pierre Ossman <dr...@dr...> 0.15-1 +- Initial package |
From: <svn...@op...> - 2005-04-06 13:04:45
|
Author: drzeus Date: 2005-04-06 15:06:06 +0200 (Wed, 06 Apr 2005) New Revision: 445 Modified: plugins/evolution2/src/evolution2_xml.c Log: gcc4 fixes Modified: plugins/evolution2/src/evolution2_xml.c =================================================================== --- plugins/evolution2/src/evolution2_xml.c 2005-04-06 13:05:41 UTC (rev 444) +++ plugins/evolution2/src/evolution2_xml.c 2005-04-06 13:06:06 UTC (rev 445) @@ -47,7 +47,7 @@ return FALSE; } - if (xmlStrcmp(cur->name, "config")) { + if (xmlStrcmp(cur->name, (xmlChar*)"config")) { osync_debug("EVO2-SYNC", 0, "data seems not to be a valid configdata.\n"); xmlFreeDoc(doc); return FALSE; @@ -56,7 +56,7 @@ cur = cur->xmlChildrenNode; while (cur != NULL) { - char *str = xmlNodeGetContent(cur); + char *str = (char*)xmlNodeGetContent(cur); if (str) { if (!xmlStrcmp(cur->name, (const xmlChar *)"adress_path")) { env->addressbook_path = g_strdup(str); |
From: <svn...@op...> - 2005-04-06 13:04:21
|
Author: drzeus Date: 2005-04-06 15:05:41 +0200 (Wed, 06 Apr 2005) New Revision: 444 Modified: plugins/evolution2/src/Makefile.am Log: Evolution has a bogus 'const' for a return value in its API causing compiler warnings. Together with -Werror this causes the build to fail. Until evo fixes this we have to tell gcc not to check return types. Modified: plugins/evolution2/src/Makefile.am =================================================================== --- plugins/evolution2/src/Makefile.am 2005-04-06 13:01:59 UTC (rev 443) +++ plugins/evolution2/src/Makefile.am 2005-04-06 13:05:41 UTC (rev 444) @@ -4,7 +4,8 @@ INCLUDES = @PACKAGE_CFLAGS@ @EPACKAGE_CFLAGS@ -AM_CFLAGS = -Wall -Werror +# Please remove '-Wno-return-type' when Evo fixes the warning in their headers. +AM_CFLAGS = -Wall -Werror -Wno-return-type config_DATA = evo2-sync |
From: <svn...@op...> - 2005-04-06 13:00:40
|
Author: drzeus Date: 2005-04-06 15:01:59 +0200 (Wed, 06 Apr 2005) New Revision: 443 Modified: plugins/evolution2/configure.in plugins/evolution2/src/Makefile.am Log: Cleaned up the detection for evolution data server and added the latest version of it. Modified: plugins/evolution2/configure.in =================================================================== --- plugins/evolution2/configure.in 2005-04-06 10:22:12 UTC (rev 442) +++ plugins/evolution2/configure.in 2005-04-06 13:01:59 UTC (rev 443) @@ -6,18 +6,29 @@ AC_CONFIG_SRCDIR(src/evolution2_sync.c) AC_CONFIG_HEADER(config.h) -pkg_modules="glib-2.0 evolution-data-server-1.0 libebook-1.0 libecal-1.0 libedata-book-1.0 libedata-cal-1.0 libedataserver-1.0 opensync-1.0" -pkg_modules2="glib-2.0 evolution-data-server-1.1 libebook-1.1 libecal-1.1 libedata-book-1.1 libedata-cal-1.1 libedataserver-1.1 opensync-1.0" +pkg_modules="glib-2.0 opensync-1.0" +pkg_emodules_10="evolution-data-server-1.0 libebook-1.0 libecal-1.0 libedata-book-1.0 libedata-cal-1.0 libedataserver-1.0" +pkg_emodules_11="evolution-data-server-1.1 libebook-1.1 libecal-1.1 libedata-book-1.1 libedata-cal-1.1 libedataserver-1.1" +pkg_emodules_12="evolution-data-server-1.2 libebook-1.2 libecal-1.2 libedata-book-1.2 libedata-cal-1.2 libedataserver-1.2" export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/lib/pkgconfig:$prefix/lib/pkgconfig:/usr/local/lib/pkgconfig -PKG_CHECK_MODULES(PACKAGE, [$pkg_modules], EDS10FOUND=1, [EDS10FOUND=0]) -if test "x${EDS10FOUND}" = "x0"; then - PKG_CHECK_MODULES(PACKAGE, [$pkg_modules2],,AC_MSG_ERROR(Neither evolution-data-server-1.0-dev nor evolution-data-server-1.1-dev was found)) -fi +PKG_CHECK_MODULES(PACKAGE, [$pkg_modules], , AC_MSG_ERROR(GLib >= 2.0 and opensync >= 1.0 required)) + AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) +PKG_CHECK_MODULES(EPACKAGE, [$pkg_emodules_10], EDSFOUND=1, [EDSFOUND=0]) +if test "x${EDSFOUND}" = "x0"; then + PKG_CHECK_MODULES(EPACKAGE, [$pkg_emodules_11], EDSFOUND=1, [EDSFOUND=0]) + if test "x${EDSFOUND}" = "x0"; then + PKG_CHECK_MODULES(EPACKAGE, [$pkg_emodules_12],,AC_MSG_ERROR(No compatible evolution-data-server was found)) + fi +fi + +AC_SUBST(EPACKAGE_CFLAGS) +AC_SUBST(EPACKAGE_LIBS) + AC_ISC_POSIX AC_PROG_CC AM_PROG_CC_STDC Modified: plugins/evolution2/src/Makefile.am =================================================================== --- plugins/evolution2/src/Makefile.am 2005-04-06 10:22:12 UTC (rev 442) +++ plugins/evolution2/src/Makefile.am 2005-04-06 13:01:59 UTC (rev 443) @@ -2,7 +2,7 @@ configdir=@OPENSYNC_CONFIGDIR@ opensyncheaderdir=@OPENSYNC_HEADERDIR@ -INCLUDES = @PACKAGE_CFLAGS@ +INCLUDES = @PACKAGE_CFLAGS@ @EPACKAGE_CFLAGS@ AM_CFLAGS = -Wall -Werror @@ -28,4 +28,4 @@ evolution2_xml.c evo2_sync_la_LDFLAGS = -avoid-version -export-dynamic -module -evo2_sync_la_LIBADD = @PACKAGE_LIBS@ @LIBS@ +evo2_sync_la_LIBADD = @PACKAGE_LIBS@ @EPACKAGE_LIBS@ @LIBS@ |
From: <svn...@op...> - 2005-04-06 10:20:53
|
Author: drzeus Date: 2005-04-06 12:22:12 +0200 (Wed, 06 Apr 2005) New Revision: 442 Modified: trunk/tests/Makefile.am trunk/tests/mock-plugin/Makefile.am Log: Cleaner system for building the mockup plugin. Libtool doesn't build a shared library without -rpath. Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2005-04-05 15:56:56 UTC (rev 441) +++ trunk/tests/Makefile.am 2005-04-06 10:22:12 UTC (rev 442) @@ -1,16 +1,14 @@ ## Process this file with automake to produce Makefile.in +SUBDIRS = mock-plugin + AM_CFLAGS = @XML_CFLAGS@ -Wall -Werror @GCOV_CFLAGS@ INCLUDES = -I$(top_srcdir) @PACKAGE_CFLAGS@ -I$(top_srcdir)/osengine EXTRA_DIST = \ data \ - support.h \ - mock-plugin/mock_sync.h \ - mock-plugin/mock_format.c \ - mock-plugin/mock_sync.c \ - mock-plugin/Makefile.am + support.h if ENABLE_PROF PROFTEST = coverage.sh @@ -97,7 +95,3 @@ clean: rm -rf coverage/* - $(MAKE) clean -C mock-plugin - -all-local: - $(MAKE) -C mock-plugin Modified: trunk/tests/mock-plugin/Makefile.am =================================================================== --- trunk/tests/mock-plugin/Makefile.am 2005-04-05 15:56:56 UTC (rev 441) +++ trunk/tests/mock-plugin/Makefile.am 2005-04-06 10:22:12 UTC (rev 442) @@ -1,10 +1,13 @@ INCLUDES = @PACKAGE_CFLAGS@ AM_CFLAGS = -Wall -Werror @XML_CFLAGS@ +AM_LDFLAGS = -rpath @libdir@ EXTRA_DIST = mock_sync.h -lib_LTLIBRARIES = mock_sync.la mockformat.la +if ENABLE_TESTS +noinst_LTLIBRARIES = mock_sync.la mockformat.la +endif mock_sync_la_SOURCES = mock_sync.c mock_sync_la_LDFLAGS = -avoid-version -export-dynamic -module |
From: <svn...@op...> - 2005-04-05 15:55:39
|
Author: abauer Date: 2005-04-05 17:56:56 +0200 (Tue, 05 Apr 2005) New Revision: 441 Modified: branches/experimental-kdepim/src/knotes.cpp Log: Fixed a bug when getting the summary and body Modified: branches/experimental-kdepim/src/knotes.cpp =================================================================== --- branches/experimental-kdepim/src/knotes.cpp 2005-04-05 14:41:00 UTC (rev 440) +++ branches/experimental-kdepim/src/knotes.cpp 2005-04-05 15:56:56 UTC (rev 441) @@ -97,6 +97,12 @@ return true; } +static QString strip_html(QString input) +{ + QString output; + +} + bool KNotesDataSource::get_changeinfo(OSyncContext *ctx) { osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); @@ -112,7 +118,7 @@ QMap<KNoteID_t,QString>::ConstIterator i; for (i = fNotes.begin(); i != fNotes.end(); i++) { osync_debug("knotes", 4, "Note key: %s", (const char*)i.key().local8Bit()); - osync_debug("knotes", 4, "Note contents:\n%s\n====", (const char*)i.data().local8Bit()); + osync_debug("knotes", 4, "Note summary: %s", (const char*)i.data().local8Bit()); QString uid = i.key(); QString hash = NULL; @@ -131,10 +137,10 @@ osxml_node_set(sum, "Summary", utf8str, enc); xmlNode *body = xmlNewChild(root, NULL, (const xmlChar*)"", NULL); - utf8str = kn_iface->text(i.key()).utf8(); + utf8str = strip_html(kn_iface->text(i.key())).utf8(); hash += utf8str; osxml_node_set(body, "Body", utf8str, enc); - + // initialize the change object OSyncChange *chg = osync_change_new(); osync_change_set_uid(chg, uid.local8Bit()); @@ -145,6 +151,8 @@ osync_change_set_objformat_string(chg, "xml-note"); osync_change_set_data(chg, (char*)doc, sizeof(doc), 1); + osync_debug("knotes", 4, "Reporting note:\%s", osync_change_get_printable(chg)); + // Use the hash table to check if the object // needs to be reported osync_change_set_hash(chg, hash.data()); @@ -169,19 +177,29 @@ // Get osxml data xmlDoc *doc = (xmlDoc*)osync_change_get_data(chg); - xmlNode *root = osxml_node_get_root(doc, "note", NULL); - if (!root) { - osync_context_report_error(ctx, OSYNC_ERROR_CONVERT, "Invalid data"); + + xmlNode *root = xmlDocGetRootElement(doc); + if (!root) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Unable to get xml root element"); osync_trace(TRACE_EXIT_ERROR, "%s: Invalid data", __func__); return false; } - QString summary = osxml_find_node(root, "Summary"); + + if (xmlStrcmp((root)->name, (const xmlChar *) "Note")) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Wrong root element"); + osync_trace(TRACE_EXIT_ERROR, "%s: Invalid data2", __func__); + return false; + } + + printf("Getting note %s and %s\n", osync_change_get_printable(chg), osxml_find_node(root, "Summary")); + QString summary = QString(osxml_find_node(root, "Summary")); QString body = osxml_find_node(root, "Body"); QString hash, uid; // end of the ugly-format parsing switch (type) { case CHANGE_ADDED: + printf("addding new \"%s\" and \"%s\"\n", (const char*)summary.local8Bit(), (const char*)body.local8Bit()); uid = kn_iface->newNote(summary, body); if (kn_iface->status() != DCOPStub::CallSucceeded) { osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Unable to add new note"); |
From: <svn...@op...> - 2005-04-05 14:39:44
|
Author: abauer Date: 2005-04-05 16:41:00 +0200 (Tue, 05 Apr 2005) New Revision: 440 Added: branches/experimental-kdepim/src/kaddrbook.cpp Removed: branches/experimental-kdepim/src/kaddrbook.c branches/experimental-kdepim/src/knotes-test.cpp Modified: branches/experimental-kdepim/ branches/experimental-kdepim/Makefile.am branches/experimental-kdepim/src/ branches/experimental-kdepim/src/kaddrbook.h branches/experimental-kdepim/src/kdepim_impl.cpp branches/experimental-kdepim/src/kdepim_sync.cpp branches/experimental-kdepim/src/knotes.cpp branches/experimental-kdepim/src/knotes.h branches/experimental-kdepim/src/osyncbase.h Log: Finished implementing the vnotes access through dcop Moved the addressbook implementation into its own file Property changes on: branches/experimental-kdepim ___________________________________________________________________ Name: svn:ignore - .libs .deps configure Makefile.in config.log config.status stamp-h1 config.h autom4te.cache libtool aclocal.m4 Makefile kdepim_sync.loT mkinstalldirs depcomp config.guess config.sub ltmain.sh missing install-sh configure.files subdirs stamp-h.in config.cache kdepim_impl_la-kcal.loT config.h.in libopensync-plugin-kdepim* + .libs .deps configure Makefile.in config.log config.status stamp-h1 config.h autom4te.cache libtool aclocal.m4 Makefile kdepim_sync.loT mkinstalldirs depcomp config.guess config.sub ltmain.sh missing install-sh configure.files subdirs stamp-h.in config.cache kdepim_impl_la-kcal.loT config.h.in libopensync-plugin-kdepim* .project .cdtproject Modified: branches/experimental-kdepim/Makefile.am =================================================================== --- branches/experimental-kdepim/Makefile.am 2005-04-05 14:37:54 UTC (rev 439) +++ branches/experimental-kdepim/Makefile.am 2005-04-05 14:41:00 UTC (rev 440) @@ -14,6 +14,12 @@ src/osyncbase.h \ src/knotes.h \ src/KNotesIface.h + +CLEANFILES = \ + src/KNotesIface_stub.h \ + src/KNotesIface_skel.cpp \ + src/KNotesIface_stub.cpp \ + src/KNotesIface.kidl kdepim_sync_la_SOURCES = src/kdepim_sync.cpp kdepim_sync_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror @@ -22,15 +28,16 @@ # ugly hack to make the c++ library work kdepim_sync_la_LIBADD = -lstdc++ -L@OPENSYNC_LIBDIR@ -kdepim_lib_la_SOURCES = src/kdepim_impl.cpp \ - src/kcal.cpp \ - src/knotes.cpp \ - src/kaddrbook.cpp \ - src/KNotesIface_stub.cpp +kdepim_lib_la_SOURCES = \ + src/KNotesIface_stub.cpp \ + src/kdepim_impl.cpp \ + src/kcal.cpp \ + src/knotes.cpp \ + src/kaddrbook.cpp kdepim_lib_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror kdepim_lib_la_LDFLAGS = $(KDE_LDFLAGS) -avoid-version -export-dynamic -module kdepim_lib_la_LIBADD = $(KDE_RPATH) $(LIB_KABC) $(LIB_KCAL) -L$(libdir) -L@OPENSYNC_LIBDIR@ -lopensync-xml -KNotesIface_stub.cpp: +src/KNotesIface_stub.cpp: dcopidl src/KNotesIface.h > src/KNotesIface.kidl dcopidl2cpp src/KNotesIface.kidl \ No newline at end of file Property changes on: branches/experimental-kdepim/src ___________________________________________________________________ Name: svn:ignore - .libs Makefile.in *.loT .deps Makefile + .libs Makefile.in *.loT .deps Makefile KNotesIface_stub.cpp KNotesIface_skel.cpp KNotesIface.kidl KNotesIface_stub.h Deleted: branches/experimental-kdepim/src/kaddrbook.c Added: branches/experimental-kdepim/src/kaddrbook.cpp =================================================================== --- branches/experimental-kdepim/src/kaddrbook.cpp 2005-04-05 14:37:54 UTC (rev 439) +++ branches/experimental-kdepim/src/kaddrbook.cpp 2005-04-05 14:41:00 UTC (rev 440) @@ -0,0 +1,235 @@ +/*********************************************************************** +KAddressbook support for OpenSync kdepim-sync plugin +Copyright (C) 2004 Conectiva S. A. +Copyright (C) 2005 Armin Bauer + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation; + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY +CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, +COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS +SOFTWARE IS DISCLAIMED. +*************************************************************************/ +/** + * @autor Eduardo Pereira Habkost <eha...@co...> + * @autor Armin Bauer <arm...@op...> + */ + +#include "kaddrbook.h" + +KContactDataSource::KContactDataSource(OSyncMember *member, OSyncHashTable *hashtable) + : hashtable(hashtable), member(member) +{ +} + +/** Calculate the hash value for an Addressee. + * Should be called before returning/writing the + * data, because the revision of the Addressee + * can be changed. + */ +QString KContactDataSource::calc_hash(KABC::Addressee &e) +{ + //Get the revision date of the KDE addressbook entry. + //Regard entries with invalid revision dates as having just been changed. + QDateTime revdate = e.revision(); + osync_debug("kde", 3, "Getting hash: %s", revdate.toString().data()); + if (!revdate.isValid()) + { + revdate = QDateTime::currentDateTime(); + e.setRevision(revdate); + } + + return revdate.toString(); +} + +bool KContactDataSource::connect(OSyncContext *ctx) +{ + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); + + //get a handle to the standard KDE addressbook + addressbookptr = KABC::StdAddressBook::self(); + + OSyncError *error = NULL; + + if (!osync_hashtable_load(hashtable, member, &error)) { + osync_context_report_osyncerror(ctx, &error); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error)); + return FALSE; + } + + //Detection mechanismn if this is the first sync + if (!osync_anchor_compare(member, "synced", "true")) { + osync_trace(TRACE_INTERNAL, "Setting slow-sync"); + osync_member_set_slow_sync(member, "contact", TRUE); + osync_anchor_update(member, "synced", "true"); + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; +} + +bool KContactDataSource::disconnect(OSyncContext *ctx) +{ + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); + + KABC::Ticket *ticket = addressbookptr->requestSaveTicket(); + if ( !ticket ) { + osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Unable to get save ticket"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to get save ticket", __func__); + return FALSE; + } + + if ( !addressbookptr->save( ticket ) ) { + osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Unable to use ticket"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to save", __func__); + return FALSE; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; +} + + +bool KContactDataSource::contact_get_changeinfo(OSyncContext *ctx) +{ + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); + + if (osync_member_get_slow_sync(member, "contact")) { + osync_trace(TRACE_INTERNAL, "Got slow-sync"); + osync_hashtable_set_slow_sync(hashtable, "contact"); + } + + // We must reload the KDE addressbook in order to retrieve the latest changes. + if (!addressbookptr->load()) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't reload KDE addressbook"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to reload addrbook", __func__); + return false; + } + + KABC::VCardConverter converter; + + for (KABC::AddressBook::Iterator it=addressbookptr->begin(); it!=addressbookptr->end(); it++ ) { + QString uid = it->uid(); + + OSyncChange *chg = osync_change_new(); + + osync_change_set_member(chg, member); + osync_change_set_uid(chg, uid.local8Bit()); + + QString hash = calc_hash(*it); + + // Convert the VCARD data into a string + const char *data = converter.createVCard(*it).utf8(); + osync_change_set_data(chg, strdup(data), strlen(data) + 1, TRUE); + + // object type and format + osync_change_set_objtype_string(chg, "contact"); + osync_change_set_objformat_string(chg, "vcard21"); + + // Use the hash table to check if the object + // needs to be reported + osync_change_set_hash(chg, hash.data()); + if (osync_hashtable_detect_change(hashtable, chg)) { + osync_context_report_change(ctx, chg); + osync_hashtable_update_hash(hashtable, chg); + } + } + + // Use the hashtable to report deletions + osync_hashtable_report_deleted(hashtable, ctx, "contact"); + + osync_trace(TRACE_EXIT, "%s", __func__); + return true; +} + +/*void kabc_get_data(OSyncContext *ctx, OSyncChange *chg) +{ + QString uid = osync_change_get_uid(chg); + KABC::Addressee a = addressbookptr->findByUid(uid); + KABC::VCardConverter converter; + QCString card = converter.createVCard(a).utf8(); + const char *data = card; + //FIXME: deallocate data somewhere + osync_change_set_data(chg, strdup(data), strlen(data), 1); + osync_context_report_success(ctx); +}*/ + +bool KContactDataSource::vcard_access(OSyncContext *ctx, OSyncChange *chg) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, ctx, chg); + KABC::VCardConverter converter; + + // convert VCARD string from obj->comp into an Addresse object. + char *data = osync_change_get_data(chg); + size_t data_size = osync_change_get_datasize(chg); + QString uid = osync_change_get_uid(chg); + + OSyncChangeType chtype = osync_change_get_changetype(chg); + switch(chtype) { + case CHANGE_MODIFIED: { + KABC::Addressee addressee = converter.parseVCard(QString::fromUtf8(data, data_size)); + + // ensure it has the correct UID and revision + addressee.setUid(uid); + addressee.setRevision(QDateTime::currentDateTime()); + + // replace the current addressbook entry (if any) with the new one + + addressbookptr->insertAddressee(addressee); + + QString hash = calc_hash(addressee); + osync_change_set_hash(chg, hash); + osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY UPDATED (UID=%s)", (const char *)uid.local8Bit()); + break; + } + case CHANGE_ADDED: { + KABC::Addressee addressee = converter.parseVCard(QString::fromUtf8(data, data_size)); + + // ensure it has the correct revision + addressee.setRevision(QDateTime::currentDateTime()); + + // add the new address to the addressbook + addressbookptr->insertAddressee(addressee); + + osync_change_set_uid(chg, addressee.uid().local8Bit()); + + QString hash = calc_hash(addressee); + osync_change_set_hash(chg, hash); + osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY ADDED (UID=%s)", (const char *)addressee.uid().local8Bit()); + break; + } + case CHANGE_DELETED: { + if (uid.isEmpty()) { + osync_context_report_error(ctx, OSYNC_ERROR_FILE_NOT_FOUND, "Trying to delete entry with empty UID"); + osync_trace(TRACE_EXIT_ERROR, "%s: Trying to delete but uid is empty", __func__); + return FALSE; + } + + //find addressbook entry with matching UID and delete it + KABC::Addressee addressee = addressbookptr->findByUid(uid); + if(!addressee.isEmpty()) + addressbookptr->removeAddressee(addressee); + + osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY DELETED (UID=%s)", (const char*)uid.local8Bit()); + + break; + } + default: + osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Operation not supported"); + osync_trace(TRACE_EXIT_ERROR, "%s: Operation not supported", __func__); + return FALSE; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; +} Modified: branches/experimental-kdepim/src/kaddrbook.h =================================================================== --- branches/experimental-kdepim/src/kaddrbook.h 2005-04-05 14:37:54 UTC (rev 439) +++ branches/experimental-kdepim/src/kaddrbook.h 2005-04-05 14:41:00 UTC (rev 440) @@ -23,7 +23,28 @@ #ifndef KADDRBOOK_H #define KADDRBOOK_H +#include <kabc/stdaddressbook.h> +#include <kabc/vcardconverter.h> +#include <kabc/resource.h> + #include "osyncbase.h" +class KContactDataSource { + private: + KABC::AddressBook* addressbookptr; + + OSyncHashTable *hashtable; + OSyncMember *member; + + public: + KContactDataSource(OSyncMember *member, OSyncHashTable *hashtable); + + QString calc_hash(KABC::Addressee &e); + bool connect(OSyncContext *ctx); + bool disconnect(OSyncContext *ctx); + bool contact_get_changeinfo(OSyncContext *ctx); + bool vcard_access(OSyncContext *ctx, OSyncChange *chg); +}; + #endif Modified: branches/experimental-kdepim/src/kdepim_impl.cpp =================================================================== --- branches/experimental-kdepim/src/kdepim_impl.cpp 2005-04-05 14:37:54 UTC (rev 439) +++ branches/experimental-kdepim/src/kdepim_impl.cpp 2005-04-05 14:41:00 UTC (rev 440) @@ -24,14 +24,9 @@ * @autor Eduardo Pereira Habkost <eha...@co...> */ -extern "C" -{ -#include <opensync/opensync.h> -} -#include <kabc/stdaddressbook.h> -#include <kabc/vcardconverter.h> -#include <kabc/resource.h> + + #include <libkcal/resourcecalendar.h> #include <kinstance.h> #include <klocale.h> @@ -50,41 +45,15 @@ #include "kcal.h" #include "knotes.h" - -/*TODO: check why/if the function below is necessary */ -static -void unfold_vcard(char *vcard, size_t *size) -{ - char* in = vcard; - char* out = vcard; - char *end = vcard + *size; - while ( in < end) - { - /* remove any occurrences of "=[CR][LF]" */ - /* these denote folded line markers in VCARD format. */ - /* Dont know why, but Evolution uses the leading "=" */ - /* character to (presumably) denote a control sequence. */ - /* This is not quite how I interpret the VCARD RFC2426 */ - /* spec (section 2.6 line delimiting and folding). */ - /* This seems to work though, so thats the main thing! */ - if (in[0]=='=' && in[1]==13 && in[2]==10) - in+=3; - else - *out++ = *in++; - } - *size = out - vcard; -} - class KdePluginImplementation: public KdePluginImplementationBase { private: - KABC::AddressBook* addressbookptr; - KCalDataSource *kcal; KNotesDataSource *knotes; - + KContactDataSource *kaddrbook; + + OSyncHashTable *hashtable; OSyncMember *member; - OSyncHashTable *hashtable; KApplication *application; @@ -99,10 +68,10 @@ //osync_debug("kde", 3, "%s(%s)", __FUNCTION__); KAboutData aboutData( - "opensync-kdepim-plugin", // internal program name - I18N_NOOP( "OpenSync-KDE-plugin"), // displayable program name. + "libopensync-kdepim-plugin", // internal program name + "OpenSync-KDE-plugin", // displayable program name. "0.1", // version string - I18N_NOOP( "OpenSync KDEPIM plugin" ), // short porgram description + "OpenSync KDEPIM plugin", // short porgram description KAboutData::License_GPL, // license type "(c) 2005, Eduardo Pereira Habkost", // copyright statement 0, // any free form text @@ -113,13 +82,11 @@ KCmdLineArgs::init(&aboutData); application = new KApplication(); - //get a handle to the standard KDE addressbook - addressbookptr = KABC::StdAddressBook::self(); + hashtable = osync_hashtable_new(); - hashtable = osync_hashtable_new(); - kcal = new KCalDataSource(member, hashtable); knotes = new KNotesDataSource(member, hashtable); + kaddrbook = new KContactDataSource(member, hashtable); return true; } @@ -130,35 +97,89 @@ delete kcal; kcal = NULL; } + if (knotes) { delete knotes; knotes = NULL; } + if (application) { delete application; application = NULL; } + if (hashtable) osync_hashtable_free(hashtable); } + virtual void connect(OSyncContext *ctx) + { + if (kcal && !kcal->connect(ctx)) + return; + + if (knotes && !knotes->connect(ctx)) + return; + + if (kaddrbook && !kaddrbook->connect(ctx)) + return; + + osync_context_report_success(ctx); + } + + virtual void disconnect(OSyncContext *ctx) + { + osync_hashtable_close(hashtable); + + if (kcal && !kcal->disconnect(ctx)) + return; + if (knotes && !knotes->disconnect(ctx)) + return; + if (kaddrbook && !kaddrbook->disconnect(ctx)) + return; + + osync_context_report_success(ctx); + } + + virtual void get_changeinfo(OSyncContext *ctx) + { + if (!kaddrbook && !kaddrbook->contact_get_changeinfo(ctx)) + return; + + if (kcal && !kcal->get_changeinfo_events(ctx)) + return; + + if (kcal && !kcal->get_changeinfo_todos(ctx)) + return; + + if (knotes && !knotes->get_changeinfo(ctx)) + return; + + osync_context_report_success(ctx); + } + virtual bool vcard_access(OSyncContext *ctx, OSyncChange *chg) { - if (__vcard_access(ctx, chg) < 0) - return false; - osync_context_report_success(ctx); - /*FIXME: What should be returned? */ - return true; + if (kaddrbook) + return kaddrbook->vcard_access(ctx, chg); + else { + osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No addressbook loaded"); + return false; + } + return true; } virtual bool vcard_commit_change(OSyncContext *ctx, OSyncChange *chg) { - if ( __vcard_access(ctx, chg) < 0) - return false; - osync_hashtable_update_hash(hashtable, chg); - osync_context_report_success(ctx); - /*FIXME: What should be returned? */ - return true; + if (kaddrbook) + if (kaddrbook->vcard_access(ctx, chg)) + osync_hashtable_update_hash(hashtable, chg); + else + return FALSE; + else { + osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "No addressbook loaded"); + return false; + } + return true; } virtual bool event_access(OSyncContext *ctx, OSyncChange *chg) Modified: branches/experimental-kdepim/src/kdepim_sync.cpp =================================================================== --- branches/experimental-kdepim/src/kdepim_sync.cpp 2005-04-05 14:37:54 UTC (rev 439) +++ branches/experimental-kdepim/src/kdepim_sync.cpp 2005-04-05 14:41:00 UTC (rev 440) @@ -102,14 +102,6 @@ impl_object->get_changeinfo(ctx); } -static void kde_get_data(OSyncContext *ctx, OSyncChange *chg) -{ - KdePluginImplementationBase *impl_object = impl_object_for_context(ctx); - osync_debug("kde", 3, "%s",__FUNCTION__); - - impl_object->get_data(ctx, chg); -} - static osync_bool kde_vcard_commit_change(OSyncContext *ctx, OSyncChange *change) { KdePluginImplementationBase *impl_object = impl_object_for_context(ctx); @@ -196,7 +188,6 @@ info->functions.disconnect = kde_disconnect; info->functions.finalize = kde_finalize; info->functions.get_changeinfo = kde_get_changeinfo; - info->functions.get_data = kde_get_data; osync_plugin_accept_objtype(info, "contact"); osync_plugin_accept_objformat(info, "contact", "vcard30", "kde"); Deleted: branches/experimental-kdepim/src/knotes-test.cpp Modified: branches/experimental-kdepim/src/knotes.cpp =================================================================== --- branches/experimental-kdepim/src/knotes.cpp 2005-04-05 14:37:54 UTC (rev 439) +++ branches/experimental-kdepim/src/knotes.cpp 2005-04-05 14:41:00 UTC (rev 440) @@ -43,31 +43,30 @@ bool KNotesDataSource::connect(OSyncContext *ctx) { osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); - //check knotes running - //connect to dcop - DCOPClient *kn_dcop = KApplication::kApplication()->dcopClient(); - if (!kndcop) { + kn_dcop = KApplication::kApplication()->dcopClient(); + if (!kn_dcop) { osync_context_report_error(ctx, OSYNC_ERROR_INITIALIZATION, "Unable to make new dcop for knotes"); osync_trace(TRACE_EXIT_ERROR, "%s: Unable to make new dcop for knotes", __func__); return FALSE; } - if (!dcop->attach()) { + if (!kn_dcop->attach()) { osync_context_report_error(ctx, OSYNC_ERROR_INITIALIZATION, "Unable to attach dcop for knotes"); osync_trace(TRACE_EXIT_ERROR, "%s: Unable to attach dcop for knotes", __func__); return FALSE; } - QCStringList apps = dcop->registeredApplications(); + //check knotes running + QCStringList apps = kn_dcop->registeredApplications(); if (!apps.contains("knotes")) { //start knotes if not running knotesWasRunning = false; } else knotesWasRunning = true; - kn_iface = new KNotesIface_stub(knotesAppname,"KNotesIface"); + kn_iface = new KNotesIface_stub("knotes", "KNotesIface"); osync_trace(TRACE_EXIT, "%s", __func__); return true; @@ -76,7 +75,6 @@ bool KNotesDataSource::disconnect(OSyncContext *ctx) { osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); - //call sync on knotes dcop // FIXME: ugly, but necessary if (!knotesWasRunning) { @@ -84,7 +82,16 @@ } //detach dcop + if (!kn_dcop->detach()) { + osync_context_report_error(ctx, OSYNC_ERROR_INITIALIZATION, "Unable to detach dcop for knotes"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to detach dcop for knotes", __func__); + return FALSE; + } //destroy dcop + delete kn_iface; + kn_iface = NULL; + //delete kn_dcop; + //kn_dcop = NULL; osync_trace(TRACE_EXIT, "%s", __func__); return true; @@ -95,20 +102,20 @@ osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); QMap <KNoteID_t,QString> fNotes; - fNotes = fKNotes->notes(); - if (fKNotes->status() != DCOPStub::CallSucceeded) { + fNotes = kn_iface->notes(); + if (kn_iface->status() != DCOPStub::CallSucceeded) { osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Unable to get changed notes"); osync_trace(TRACE_EXIT_ERROR, "%s: Unable to get changed notes", __func__); return FALSE; } - QMap<KNoteID_t,QString>::ConstIterator i = fNotes.begin(); - while (i != fNotes.end()) { + QMap<KNoteID_t,QString>::ConstIterator i; + for (i = fNotes.begin(); i != fNotes.end(); i++) { osync_debug("knotes", 4, "Note key: %s", (const char*)i.key().local8Bit()); osync_debug("knotes", 4, "Note contents:\n%s\n====", (const char*)i.data().local8Bit()); - QString uid = (*i)->uid(); - + QString uid = i.key(); + QString hash = NULL; // Create osxml doc containing the note xmlDoc *doc = xmlNewDoc((const xmlChar*)"1.0"); xmlNode *root = osxml_node_add_root(doc, "note"); @@ -119,11 +126,13 @@ // Set the right attributes xmlNode *sum = xmlNewChild(root, NULL, (const xmlChar*)"", NULL); - QCString utf8str = (*i)->summary().utf8(); + QCString utf8str = i.data().utf8(); + hash = utf8str; osxml_node_set(sum, "Summary", utf8str, enc); xmlNode *body = xmlNewChild(root, NULL, (const xmlChar*)"", NULL); - utf8str = (*i)->description().utf8(); + utf8str = kn_iface->text(i.key()).utf8(); + hash += utf8str; osxml_node_set(body, "Body", utf8str, enc); // initialize the change object @@ -145,11 +154,13 @@ } } + osync_trace(TRACE_EXIT, "%s", __func__); return true; } bool KNotesDataSource::access(OSyncContext *ctx, OSyncChange *chg) { + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, ctx, chg); OSyncChangeType type = osync_change_get_changetype(chg); QString uid = osync_change_get_uid(chg); @@ -161,7 +172,8 @@ xmlNode *root = osxml_node_get_root(doc, "note", NULL); if (!root) { osync_context_report_error(ctx, OSYNC_ERROR_CONVERT, "Invalid data"); - return false; + osync_trace(TRACE_EXIT_ERROR, "%s: Invalid data", __func__); + return false; } QString summary = osxml_find_node(root, "Summary"); QString body = osxml_find_node(root, "Body"); @@ -170,32 +182,64 @@ // end of the ugly-format parsing switch (type) { case CHANGE_ADDED: - uid = newNote(); + uid = kn_iface->newNote(summary, body); + if (kn_iface->status() != DCOPStub::CallSucceeded) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Unable to add new note"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to add new note", __func__); + return false; + } + + kn_iface->hideNote(uid); + if (kn_iface->status() != DCOPStub::CallSucceeded) + osync_trace(TRACE_INTERNAL, "ERROR: Unable to hide note"); + osync_change_set_uid(chg, uid); osync_change_set_hash(chg, hash); - break; + break; case CHANGE_MODIFIED: - setText - setBody - hash = calc_hash(); + kn_iface->setName(uid, summary); + if (kn_iface->status() != DCOPStub::CallSucceeded) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Unable to set name"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to set name", __func__); + return false; + } + + kn_iface->setText(uid, body); + if (kn_iface->status() != DCOPStub::CallSucceeded) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Unable to set text"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to set text", __func__); + return false; + } + hash = summary + body; osync_change_set_hash(chg, hash); - break; + break; default: osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Invalid change type"); - return false; + osync_trace(TRACE_EXIT_ERROR, "%s: Invalid change type", __func__); + return false; } } else { - //dcop killNote + kn_iface->killNote(uid, true); + if (kn_iface->status() != DCOPStub::CallSucceeded) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Unable to delete note"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to delete note", __func__); + return false; + } } osync_context_report_success(ctx); + osync_trace(TRACE_EXIT, "%s", __func__); return true; } bool KNotesDataSource::commit_change(OSyncContext *ctx, OSyncChange *chg) { - if (!access(ctx, chg)) - return false; + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, ctx, chg); + if (!access(ctx, chg)) { + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to delete note", __func__); + return false; + } osync_hashtable_update_hash(hashtable, chg); + osync_trace(TRACE_EXIT, "%s", __func__); return true; } Modified: branches/experimental-kdepim/src/knotes.h =================================================================== --- branches/experimental-kdepim/src/knotes.h 2005-04-05 14:37:54 UTC (rev 439) +++ branches/experimental-kdepim/src/knotes.h 2005-04-05 14:41:00 UTC (rev 440) @@ -29,32 +29,39 @@ #include <kstandarddirs.h> #include <kio/netaccess.h> #include <klocale.h> +#include <kapplication.h> +#include <qmap.h> +#include "KNotesIface.h" +#include "KNotesIface_stub.h" +#include <stdio.h> +#include <qtimer.h> +#include <dcopclient.h> +#include <qstring.h> +#include <qstringlist.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +typedef QString KNoteID_t; + extern "C" { #include <opensync/opensync.h> #include <opensync/opensync-xml.h> } -// Forward declaration -namespace KCal { - class CalendarLocal; -} - /** KNotes access implementation interface */ class KNotesDataSource { private: OSyncMember *member; - KNotesIface_stub *fKNotes; - DCOPClient *kn_dcop - KNotesIface_stub kn_iface; + OSyncHashTable *hashtable; + + DCOPClient *kn_dcop; + KNotesIface_stub *kn_iface; /** Ugly hack to restart KNotes if it * was running Modified: branches/experimental-kdepim/src/osyncbase.h =================================================================== --- branches/experimental-kdepim/src/osyncbase.h 2005-04-05 14:37:54 UTC (rev 439) +++ branches/experimental-kdepim/src/osyncbase.h 2005-04-05 14:41:00 UTC (rev 440) @@ -16,7 +16,6 @@ virtual void disconnect(OSyncContext *ctx) = 0; virtual void get_changeinfo(OSyncContext *ctx) = 0; - virtual void get_data(OSyncContext *ctx, OSyncChange *chg) = 0; virtual bool vcard_access(OSyncContext *ctx, OSyncChange *chg) = 0; virtual bool vcard_commit_change(OSyncContext *ctx, OSyncChange *chg) = 0; @@ -38,25 +37,4 @@ typedef KdePluginImplementationBase *(*KdeImplInitFunc)(OSyncMember *m, OSyncError **e); -/*TODO: provide base classes like below, - * for hiding the implementation details of a plugin - */ -#if 0 -/** Base class to a OpenSync plugin */ -class OSyncPluginBase { - public: - virtual void connect(OSyncContext *ctx) = 0; - void disconnect(OSyncContext *ctx) = 0; - - virtual void get_changes(OSyncContext *ctx) = 0; -}; - -/** Base class to OpenSync objtype data sink */ -class OSyncDataSinkBase { - public: - virtual void access(OSyncContext *ctx, OSyncChange *chg) = 0; - virtual void commit_change(OSyncContext *ctx, OSyncChange *chg) = 0; -}; -#endif - #endif // KDEPIM_OSYNC_BASE_H |
From: <svn...@op...> - 2005-04-05 14:36:39
|
Author: abauer Date: 2005-04-05 16:37:54 +0200 (Tue, 05 Apr 2005) New Revision: 439 Added: branches/experimental-branch/formats/vformats-xml/xml-vnote.h Modified: branches/experimental-branch/formats/note.c branches/experimental-branch/formats/vformats-xml/Makefile.am branches/experimental-branch/formats/vformats-xml/xml-vnote.c branches/experimental-branch/osengine/osengine_mapcmds.c branches/experimental-branch/tools/osyncplugin.c Log: Implemented the vnote conversion and comparison correctly Modified: branches/experimental-branch/formats/note.c =================================================================== --- branches/experimental-branch/formats/note.c 2005-04-05 14:36:18 UTC (rev 438) +++ branches/experimental-branch/formats/note.c 2005-04-05 14:37:54 UTC (rev 439) @@ -1,6 +1,7 @@ #include <opensync/opensync.h> #include <glib.h> #include <stdio.h> +#include <string.h> static osync_bool detect_plain_as_vnote(OSyncFormatEnv *env, const char *data, int size) { @@ -17,10 +18,20 @@ return CONV_DATA_MISMATCH; } +static void create_vnote11(OSyncChange *change) +{ + char *vnote = g_strdup_printf("BEGIN:VNOTE\r\nVERSION:1.1\r\nBODY:%s\r\nSUMMARY:%s\r\nEND:VNOTE", osync_rand_str(20), osync_rand_str(6)); + + osync_change_set_data(change, vnote, strlen(vnote) + 1, TRUE); + if (!osync_change_get_uid(change)) + osync_change_set_uid(change, osync_rand_str(8)); +} + void get_info(OSyncEnv *env) { osync_env_register_objtype(env, "note"); osync_env_register_objformat(env, "note", "vnote11"); osync_env_register_detector(env, "plain", "vnote11", detect_plain_as_vnote); + osync_env_format_set_create_func(env, "vnote11", create_vnote11); osync_env_format_set_compare_func(env, "vnote11", compare_vnote); } Modified: branches/experimental-branch/formats/vformats-xml/Makefile.am =================================================================== --- branches/experimental-branch/formats/vformats-xml/Makefile.am 2005-04-05 14:36:18 UTC (rev 438) +++ branches/experimental-branch/formats/vformats-xml/Makefile.am 2005-04-05 14:37:54 UTC (rev 439) @@ -9,7 +9,8 @@ vformat.h \ opensync-xml.h \ xml-vcard.h \ - xml-vcal.h + xml-vcal.h \ + xml-vnote.h opensyncheader_HEADERS = opensync-xml.h Modified: branches/experimental-branch/formats/vformats-xml/xml-vnote.c =================================================================== --- branches/experimental-branch/formats/vformats-xml/xml-vnote.c 2005-04-05 14:36:18 UTC (rev 438) +++ branches/experimental-branch/formats/vformats-xml/xml-vnote.c 2005-04-05 14:37:54 UTC (rev 439) @@ -1,5 +1,5 @@ /* - * xml-vcard - A plugin for parsing vcard objects for the opensync framework + * xml-vnote - A plugin for parsing vnote objects for the opensync framework * Copyright (C) 2004-2005 Armin Bauer <arm...@op...> * * This library is free software; you can redistribute it and/or @@ -20,93 +20,190 @@ #include "opensync-xml.h" #include "vformat.h" +#include "xml-vnote.h" #include <glib.h> -static osync_bool conv_vnote_to_xml(void *user_data, char *input, int inpsize, char **output, int *outpsize, osync_bool *free_input, OSyncError **error) +static void handle_unknown_parameter(xmlNode *current, VFormatParam *param) { - osync_debug("VNOTE", 4, "start: %s", __func__); - printf("input is %i\n%s\n", inpsize, input); + osync_trace(TRACE_INTERNAL, "Handling unknown parameter %s", vformat_attribute_param_get_name(param)); + xmlNode *property = xmlNewChild(current, NULL, (xmlChar*)"UnknownParam", + (xmlChar*)vformat_attribute_param_get_nth_value(param, 0)); + osxml_node_add(property, "ParamName", vformat_attribute_param_get_name(param)); +} + +static xmlNode *handle_created_attribute(xmlNode *root, VFormatAttribute *attr) +{ + osync_trace(TRACE_INTERNAL, "Handling created attribute"); + xmlNode *current = xmlNewChild(root, NULL, (xmlChar*)"DateCreated", NULL); + osxml_node_add(current, "Content", vformat_attribute_get_nth_value(attr, 0)); + return current; +} + +static xmlNode *handle_last_modified_attribute(xmlNode *root, VFormatAttribute *attr) +{ + osync_trace(TRACE_INTERNAL, "Handling last_modified attribute"); + xmlNode *current = xmlNewChild(root, NULL, (xmlChar*)"LastModified", NULL); + osxml_node_add(current, "Content", vformat_attribute_get_nth_value(attr, 0)); + return current; +} + +static xmlNode *handle_summary_attribute(xmlNode *root, VFormatAttribute *attr) +{ + osync_trace(TRACE_INTERNAL, "Handling summary attribute"); + xmlNode *current = xmlNewChild(root, NULL, (xmlChar*)"Summary", NULL); + osxml_node_add(current, "Content", vformat_attribute_get_nth_value(attr, 0)); + return current; +} + +static xmlNode *handle_categories_attribute(xmlNode *root, VFormatAttribute *attr) +{ + osync_trace(TRACE_INTERNAL, "Handling Categories attribute"); + xmlNode *current = xmlNewChild(root, NULL, (xmlChar*)"Categories", NULL); - /*GList *p = NULL; - GList *a = NULL; + GList *values = vformat_attribute_get_values_decoded(attr); + for (; values; values = values->next) { + GString *retstr = (GString *)values->data; + g_assert(retstr); + osxml_node_add(current, "Category", retstr->str); + } - VFormat *vcard = vformat_new_from_string(input); - vformat_dump_structure (vcard); - GList *attributes = vformat_get_attributes(vcard); - xmlDoc *doc = xmlNewDoc("1.0"); - xmlNode *root = osxml_node_add_root(doc, "note"); + return current; +} + +static xmlNode *handle_body_attribute(xmlNode *root, VFormatAttribute *attr) +{ + osync_trace(TRACE_INTERNAL, "Handling body attribute"); + xmlNode *current = xmlNewChild(root, NULL, (xmlChar*)"Body", NULL); + osxml_node_add(current, "Content", vformat_attribute_get_nth_value(attr, 0)); + return current; +} + +static xmlNode *handle_class_attribute(xmlNode *root, VFormatAttribute *attr) +{ + osync_trace(TRACE_INTERNAL, "Handling Class attribute"); + xmlNode *current = xmlNewChild(root, NULL, (xmlChar*)"Class", NULL); + osxml_node_add(current, "Content", vformat_attribute_get_nth_value(attr, 0)); + return current; +} + +static void handle_type_parameter(xmlNode *current, VFormatParam *param) +{ + osync_trace(TRACE_INTERNAL, "Handling type parameter %s", vformat_attribute_param_get_name(param)); + xmlNewChild(current, NULL, (xmlChar*)"Type", + (xmlChar*)vformat_attribute_param_get_nth_value(param, 0)); +} + +static xmlNode *handle_unknown_attribute(xmlNode *root, VFormatAttribute *attr) +{ + osync_trace(TRACE_INTERNAL, "Handling unknown attribute %s", vformat_attribute_get_name(attr)); + xmlNode *current = xmlNewChild(root, NULL, (xmlChar*)"UnknownNode", NULL); + osxml_node_add(current, "NodeName", vformat_attribute_get_name(attr)); + GList *values = vformat_attribute_get_values_decoded(attr); + for (; values; values = values->next) { + GString *retstr = (GString *)values->data; + g_assert(retstr); + osxml_node_add(current, "Content", retstr->str); + } + return current; +} + +static void vnote_handle_parameter(GHashTable *hooks, xmlNode *current, VFormatParam *param) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, hooks, current, param); - for (a = attributes; a; a = a->next) { - VFormatAttribute *attr = a->data; - const char *name = vformat_attribute_get_name(attr); + //Find the handler for this parameter + void (* param_handler)(xmlNode *, VFormatParam *); + char *paramname = g_strdup_printf("%s=%s", vformat_attribute_param_get_name(param), vformat_attribute_param_get_nth_value(param, 0)); + param_handler = g_hash_table_lookup(hooks, paramname); + g_free(paramname); + if (!param_handler) + param_handler = g_hash_table_lookup(hooks, vformat_attribute_param_get_name(param)); + + if (param_handler == HANDLE_IGNORE) { + osync_trace(TRACE_EXIT, "%s: Ignored", __func__); + return; + } + + if (param_handler) + param_handler(current, param); + else + handle_unknown_parameter(current, param); + + osync_trace(TRACE_EXIT, "%s", __func__); +} - if (!strcmp(name, "VERSION")) - continue; - - if (!strcmp(name, "BEGIN")) { - root = osxml_node_add_root(doc, "note"); - continue; - } - - xmlNode *current = xmlNewChild(root, NULL, "", NULL); - - //Created - if (!strcmp(name, "DCREATED")) { - osxml_node_set(current, "Created", vformat_attribute_get_nth_value(attr, 0), encoding); - continue; - } +static void vnote_handle_attribute(GHashTable *hooks, xmlNode *root, VFormatAttribute *attr) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p:%s)", __func__, hooks, root, attr, attr ? vformat_attribute_get_name(attr) : "None"); + xmlNode *current = NULL; + + //Dont add empty stuff + GList *v; + for (v = vformat_attribute_get_values(attr); v; v = v->next) { + char *value = v->data; + if (strlen(value) != 0) + goto has_value; + } + osync_trace(TRACE_EXIT, "%s: No values", __func__); + return; + +has_value:; + + //We need to find the handler for this attribute + xmlNode *(* attr_handler)(xmlNode *, VFormatAttribute *) = g_hash_table_lookup(hooks, vformat_attribute_get_name(attr)); + osync_trace(TRACE_INTERNAL, "Hook is: %p", attr_handler); + if (attr_handler == HANDLE_IGNORE) { + osync_trace(TRACE_EXIT, "%s: Ignored", __func__); + return; + } + if (attr_handler) + current = attr_handler(root, attr); + else + current = handle_unknown_attribute(root, attr); - //LastModified - if (!strcmp(name, "LAST_MODIFIED")) { - osxml_node_set(current, "LastModified", vformat_attribute_get_nth_value(attr, 0), encoding); - continue; - } - - //Summary - if (!strcmp(name, "SUMMARY")) { - osxml_node_set(current, "Summary", vformat_attribute_get_nth_value(attr, 0), encoding); - continue; - } - - //Body - if (!strcmp(name, "BODY")) { - osxml_node_set(current, "Body", vformat_attribute_get_nth_value(attr, 0), encoding); - continue; - } - - //Categories - if (!strcmp(name, "CATEGORIES")) { - osxml_node_set(current, "Categories", vformat_attribute_get_nth_value(attr, 0), encoding); - continue; - } - - //Class - if (!strcmp(name, "CLASS")) { - osxml_node_set(current, "Class", vformat_attribute_get_nth_value(attr, 0), encoding); - continue; - } - - //Unknown tag. - osxml_node_mark_unknown(current); - GList *values = vformat_attribute_get_values(attr); - GString *string = g_string_new(vformat_attribute_get_nth_value(attr, 0)); - for (p = values->next; p; p = p->next) { - g_string_sprintfa(string, ";%s", (char *)p->data); - } - osxml_node_add(current, "NodeName", name); - osxml_node_set(current, "UnknownNode", string->str, encoding); - g_string_free(string, 1); - }*/ + //Handle all parameters of this attribute + GList *params = vformat_attribute_get_params(attr); + GList *p = NULL; + for (p = params; p; p = p->next) { + VFormatParam *param = p->data; + vnote_handle_parameter(hooks, current, param); + } + osync_trace(TRACE_EXIT, "%s", __func__); +} + +static osync_bool conv_vnote_to_xml(void *conv_data, char *input, int inpsize, char **output, int *outpsize, osync_bool *free_input, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", __func__, conv_data, input, inpsize, output, outpsize, free_input, error); + GHashTable *hooks = (GHashTable *)conv_data; + + osync_trace(TRACE_INTERNAL, "Input vnote is:\n%s", input); + + //Parse the vnote + VFormat *vnote = vformat_new_from_string(input); + + osync_trace(TRACE_INTERNAL, "Creating xml doc"); + + //Create a new xml document + xmlDoc *doc = xmlNewDoc((xmlChar*)"1.0"); + xmlNode *root = osxml_node_add_root(doc, "Note"); + + osync_trace(TRACE_INTERNAL, "parsing attributes"); + + //For every attribute we have call the handling hook + GList *attributes = vformat_get_attributes(vnote); + GList *a = NULL; + for (a = attributes; a; a = a->next) { + VFormatAttribute *attr = a->data; + vnote_handle_attribute(hooks, root, attr); + } + + osync_trace(TRACE_INTERNAL, "Output XML is:\n%s", osxml_write_to_string(doc)); + *free_input = TRUE; - //*output = (char *)doc; - /*FIXME: this is not really the size of the data pointed by doc. - * But this shouldn't cause problems, anyway, because this - * size field should never be used for xml docs. Actually, - * what needs fixing is the code that uses the size - * field for changes with xml data. - */ - //*outpsize = sizeof(doc); + *output = (char *)doc; + *outpsize = sizeof(doc); + osync_trace(TRACE_EXIT, "%s: TRUE", __func__); return TRUE; } @@ -155,89 +252,200 @@ g_free(tmp); } +static void handle_xml_type_parameter(VFormatAttribute *attr, xmlNode *current) +{ + osync_trace(TRACE_INTERNAL, "Handling type xml parameter"); + char *content = (char*)xmlNodeGetContent(current); + vformat_attribute_add_param_with_value(attr, "TYPE", content); + g_free(content); +} + +static void handle_xml_category_parameter(VFormatAttribute *attr, xmlNode *current) +{ + osync_trace(TRACE_INTERNAL, "Handling category xml parameter"); + char *content = (char*)xmlNodeGetContent(current); + vformat_attribute_add_value(attr, content); + g_free(content); +} + +static void xml_handle_unknown_parameter(VFormatAttribute *attr, xmlNode *current) +{ + osync_trace(TRACE_INTERNAL, "Handling unknown xml parameter %s", current->name); + char *content = (char*)xmlNodeGetContent(current); + vformat_attribute_add_param_with_value(attr, (char*)current->name, content); + g_free(content); +} + +static VFormatAttribute *handle_xml_categories_attribute(VFormat *vnote, xmlNode *root, const char *encoding) +{ + osync_trace(TRACE_INTERNAL, "Handling categories xml attribute"); + VFormatAttribute *attr = vformat_attribute_new(NULL, "CATEGORIES"); + vformat_add_attribute(vnote, attr); + return attr; +} + +static VFormatAttribute *handle_xml_class_attribute(VFormat *vnote, xmlNode *root, const char *encoding) +{ + osync_trace(TRACE_INTERNAL, "Handling class xml attribute"); + VFormatAttribute *attr = vformat_attribute_new(NULL, "CLASS"); + add_value(attr, root, "Content", encoding); + vformat_add_attribute(vnote, attr); + return attr; +} + +static VFormatAttribute *handle_xml_summary_attribute(VFormat *vnote, xmlNode *root, const char *encoding) +{ + VFormatAttribute *attr = vformat_attribute_new(NULL, "SUMMARY"); + add_value(attr, root, "Content", encoding); + vformat_add_attribute(vnote, attr); + return attr; +} + +static VFormatAttribute *handle_xml_body_attribute(VFormat *vnote, xmlNode *root, const char *encoding) +{ + VFormatAttribute *attr = vformat_attribute_new(NULL, "BODY"); + add_value(attr, root, "Content", encoding); + vformat_add_attribute(vnote, attr); + return attr; +} + +static VFormatAttribute *handle_xml_created_attribute(VFormat *vnote, xmlNode *root, const char *encoding) +{ + VFormatAttribute *attr = vformat_attribute_new(NULL, "DCREATED"); + add_value(attr, root, "Content", encoding); + vformat_add_attribute(vnote, attr); + return attr; +} + +static VFormatAttribute *handle_xml_last_modified_attribute(VFormat *vcard, xmlNode *root, const char *encoding) +{ + VFormatAttribute *attr = vformat_attribute_new(NULL, "LAST-MODIFIED"); + add_value(attr, root, "Content", encoding); + vformat_add_attribute(vcard, attr); + return attr; +} + +static void xml_vnote_handle_parameter(OSyncHookTables *hooks, VFormatAttribute *attr, xmlNode *current) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p:%s)", __func__, hooks, attr, current, current ? (char *)current->name : "None"); + + //Find the handler for this parameter + void (* xml_param_handler)(VFormatAttribute *attr, xmlNode *); + char *content = (char*)xmlNodeGetContent(current); + char *paramname = g_strdup_printf("%s=%s", current->name, content); + g_free(content); + xml_param_handler = g_hash_table_lookup(hooks->parameters, paramname); + g_free(paramname); + if (!xml_param_handler) + xml_param_handler = g_hash_table_lookup(hooks->parameters, current->name); + + if (xml_param_handler == HANDLE_IGNORE) { + osync_trace(TRACE_EXIT, "%s: Ignored", __func__); + return; + } + + if (xml_param_handler) + xml_param_handler(attr, current); + + osync_trace(TRACE_EXIT, "%s", __func__); +} + +static VFormatAttribute *xml_handle_unknown_attribute(VFormat *vnote, xmlNode *root, const char *encoding) +{ + osync_trace(TRACE_INTERNAL, "Handling unknown xml attribute %s", root->name); + char *name = osxml_find_node(root, "Name"); + VFormatAttribute *attr = vformat_attribute_new(NULL, name); + add_value(attr, root, "Content", encoding); + vformat_add_attribute(vnote, attr); + return attr; +} + +static void xml_vnote_handle_attribute(OSyncHookTables *hooks, VFormat *vnote, xmlNode *root, const char *encoding) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p:%s)", __func__, hooks, vnote, root, root ? (char *)root->name : "None"); + VFormatAttribute *attr = NULL; + + //We need to find the handler for this attribute + VFormatAttribute *(* xml_attr_handler)(VFormat *vnote, xmlNode *root, const char *) = g_hash_table_lookup(hooks->attributes, root->name); + osync_trace(TRACE_INTERNAL, "xml hook is: %p", xml_attr_handler); + if (xml_attr_handler == HANDLE_IGNORE) { + osync_trace(TRACE_EXIT, "%s: Ignored", __func__); + return; + } + if (xml_attr_handler) + attr = xml_attr_handler(vnote, root, encoding); + else { + osync_trace(TRACE_EXIT, "%s: Ignored2", __func__); + return; + } + + //Handle all parameters of this attribute + xmlNode *child = root->xmlChildrenNode; + while (child) { + xml_vnote_handle_parameter(hooks, attr, child); + child = child->next; + } + osync_trace(TRACE_EXIT, "%s", __func__); +} + static osync_bool conv_xml_to_vnote(void *user_data, char *input, int inpsize, char **output, int *outpsize, osync_bool *free_input, OSyncError **error) { - osync_debug("VNOTE", 4, "start: %s", __func__); - xmlDocDump(stdout, (xmlDoc *)input); - VFormatAttribute *attr = NULL; - xmlNode *root = osxml_node_get_root((xmlDoc *)input, "note", error); - if (!root) + osync_trace(TRACE_ENTRY, "%s(%p, %p, %i, %p, %p, %p, %p)", __func__, user_data, input, inpsize, output, outpsize, free_input, error); + + osync_trace(TRACE_INTERNAL, "Input XML is:\n%s", osxml_write_to_string((xmlDoc *)input)); + + //Get the root node of the input document + xmlNode *root = osxml_node_get_root((xmlDoc *)input, "Note", error); + if (!root) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to get root element of xml-note"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; + } - VFormat *vcard = vformat_new(); + //Make the new vnote + VFormat *vnote = vformat_new(); - const char *std_encoding = "QUOTED-PRINTABLE"; - + osync_trace(TRACE_INTERNAL, "parsing xml attributes"); while (root) { - if (!strcmp((char*)root->name, "Created")) { - //Created - attr = vformat_attribute_new(NULL, "DCREATED"); - add_value(attr, root, "Content", std_encoding); - vformat_add_attribute(vcard, attr); - } else if (!strcmp((char*)root->name, "LastModifed")) { - //LastModifed - attr = vformat_attribute_new(NULL, "LAST-MODIFIED"); - add_value(attr, root, "Content", std_encoding); - vformat_add_attribute(vcard, attr); - } else if (!strcmp((char*)root->name, "Summary")) { - //Summary - attr = vformat_attribute_new(NULL, "SUMMARY"); - add_value(attr, root, "Content", std_encoding); - vformat_add_attribute(vcard, attr); - } else if (!strcmp((char*)root->name, "Body")) { - //Body - attr = vformat_attribute_new(NULL, "BODY"); - add_value(attr, root, "Content", std_encoding); - vformat_add_attribute(vcard, attr); - } else if (!strcmp((char*)root->name, "Categories")) { - //Categories - attr = vformat_attribute_new(NULL, "CATEGORIES"); - add_value(attr, root, "Content", std_encoding); - vformat_add_attribute(vcard, attr); - } else if (!strcmp((char*)root->name, "Class")) { - //Class - attr = vformat_attribute_new(NULL, "CLASS"); - add_value(attr, root, "Content", std_encoding); - vformat_add_attribute(vcard, attr); - } else if (!strcmp((char*)root->name, "UnknownNode")) { - //Unknown Node - attr = vformat_attribute_new(NULL, osxml_find_node(root, "NodeName")); - add_value(attr, root, "Content", std_encoding); - vformat_add_attribute(vcard, attr); - } - + xml_vnote_handle_attribute((OSyncHookTables *)user_data, vnote, root, "QUOTED-PRINTABLE"); root = root->next; } *free_input = TRUE; - *output = vformat_to_string(vcard, VFORMAT_NOTE); - *outpsize = strlen(*output); + *output = vformat_to_string(vnote, VFORMAT_NOTE); + osync_trace(TRACE_INTERNAL, "vnote output is: \n%s", *output); + *outpsize = strlen(*output) + 1; + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; } static OSyncConvCmpResult compare_notes(OSyncChange *leftchange, OSyncChange *rightchange) { + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, leftchange, rightchange); + OSyncXMLScore score[] = { - {50, "/note/Summary"}, - {50, "/note/Class"}, - {50, "/note/Body"}, + {100, "/Note/Summary"}, + {100, "/Note/Body"}, + {0, "/Note/*/Type"}, + {0, "/Note/Uid"}, + {0, "/Note/LastModified"}, + {0, "/Note/DateCreated"}, {0, NULL} }; - return osxml_compare((xmlDoc*)osync_change_get_data(leftchange), (xmlDoc*)osync_change_get_data(rightchange), score, 10, 50); + OSyncConvCmpResult ret = osxml_compare((xmlDoc*)osync_change_get_data(leftchange), (xmlDoc*)osync_change_get_data(rightchange), score, 0, 199); + + osync_trace(TRACE_EXIT, "%s: %i", __func__, ret); + return ret; } static char *print_note(OSyncChange *change) { - osync_debug("VNOTE", 4, "start: %s", __func__); xmlDoc *doc = (xmlDoc *)osync_change_get_data(change); - char *result; - int size; - osync_bool free; - if (!conv_xml_to_vnote(NULL, (char*)doc, 0, &result, &size, &free, NULL)) - return NULL; - return result; + + return osxml_write_to_string(doc); } static void destroy_xml(char *data, size_t size) @@ -245,15 +453,110 @@ xmlFreeDoc((xmlDoc *)data); } +static void *init_vnote_to_xml(void) +{ + osync_trace(TRACE_ENTRY, "%s", __func__); + GHashTable *table = g_hash_table_new(g_str_hash, g_str_equal); + + g_hash_table_insert(table, "X-IRMC-LUID", HANDLE_IGNORE); + g_hash_table_insert(table, "DCREATED", handle_created_attribute); + g_hash_table_insert(table, "LAST-MODIFIED", handle_last_modified_attribute); + g_hash_table_insert(table, "SUMMARY", handle_summary_attribute); + g_hash_table_insert(table, "BODY", handle_body_attribute); + g_hash_table_insert(table, "CLASS", handle_class_attribute); + g_hash_table_insert(table, "CATEGORIES", handle_categories_attribute); + + g_hash_table_insert(table, "VERSION", HANDLE_IGNORE); + g_hash_table_insert(table, "BEGIN", HANDLE_IGNORE); + g_hash_table_insert(table, "END", HANDLE_IGNORE); + + g_hash_table_insert(table, "ENCODING", HANDLE_IGNORE); + g_hash_table_insert(table, "CHARSET", HANDLE_IGNORE); + + g_hash_table_insert(table, "TYPE", handle_type_parameter); + + osync_trace(TRACE_EXIT, "%s: %p", __func__, table); + return (void *)table; +} + +static void fin_vnote_to_xml(void *data) +{ + g_hash_table_destroy((GHashTable *)data); +} + +static void *init_xml_to_vnote(void) +{ + osync_trace(TRACE_ENTRY, "%s", __func__); + + OSyncHookTables *hooks = g_malloc0(sizeof(OSyncHookTables)); + + hooks->attributes = g_hash_table_new(g_str_hash, g_str_equal); + hooks->parameters = g_hash_table_new(g_str_hash, g_str_equal); + + g_hash_table_insert(hooks->attributes, "Summary", handle_xml_summary_attribute); + g_hash_table_insert(hooks->attributes, "Body", handle_xml_body_attribute); + g_hash_table_insert(hooks->attributes, "Class", handle_xml_class_attribute); + g_hash_table_insert(hooks->attributes, "Categories", handle_xml_categories_attribute); + g_hash_table_insert(hooks->attributes, "UnknownNode", xml_handle_unknown_attribute); + g_hash_table_insert(hooks->attributes, "DateCreated", handle_xml_created_attribute); + g_hash_table_insert(hooks->attributes, "LastModified", handle_xml_last_modified_attribute); + + g_hash_table_insert(hooks->parameters, "Type", handle_xml_type_parameter); + g_hash_table_insert(hooks->parameters, "Category", handle_xml_category_parameter); + + g_hash_table_insert(hooks->parameters, "UnknownParameter", xml_handle_unknown_parameter); + + osync_trace(TRACE_EXIT, "%s: %p", __func__, hooks); + return (void *)hooks; +} + +static void fin_xml_to_vnote(void *data) +{ + OSyncHookTables *hooks = (OSyncHookTables *)hooks; + g_hash_table_destroy(hooks->attributes); + g_hash_table_destroy(hooks->parameters); + g_free(hooks); +} + +static time_t get_revision(OSyncChange *change, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, change, error); + + xmlDoc *doc = (xmlDoc *)osync_change_get_data(change); + + xmlXPathObject *xobj = osxml_get_nodeset(doc, "/Note/LastModified"); + + xmlNodeSet *nodes = xobj->nodesetval; + + int size = (nodes) ? nodes->nodeNr : 0; + if (size != 1) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find the revision"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return -1; + } + + char *revision = (char*)osxml_find_node(nodes->nodeTab[0], "Content"); + + osync_trace(TRACE_INTERNAL, "About to convert string %s", revision); + time_t time = vformat_time_to_unix(revision); + g_free(revision); + xmlXPathFreeObject(xobj); + osync_trace(TRACE_EXIT, "%s: %i", __func__, time); + return time; +} + void get_info(OSyncEnv *env) { osync_env_register_objtype(env, "note"); osync_env_register_objformat(env, "note", "xml-note"); - osync_env_format_set_compare_func(env, "xml-note", compare_notes); osync_env_format_set_destroy_func(env, "xml-note", destroy_xml); osync_env_format_set_print_func(env, "xml-note", print_note); + osync_env_format_set_copy_func(env, "xml-note", osxml_copy); + osync_env_format_set_revision_func(env, "xml-note", get_revision); osync_env_register_converter(env, CONVERTER_CONV, "vnote11", "xml-note", conv_vnote_to_xml); + osync_env_converter_set_init(env, "vnote11", "xml-note", init_vnote_to_xml, fin_vnote_to_xml); osync_env_register_converter(env, CONVERTER_CONV, "xml-note", "vnote11", conv_xml_to_vnote); + osync_env_converter_set_init(env, "xml-note", "vnote11", init_xml_to_vnote, fin_xml_to_vnote); } Added: branches/experimental-branch/formats/vformats-xml/xml-vnote.h =================================================================== --- branches/experimental-branch/formats/vformats-xml/xml-vnote.h 2005-04-05 14:36:18 UTC (rev 438) +++ branches/experimental-branch/formats/vformats-xml/xml-vnote.h 2005-04-05 14:37:54 UTC (rev 439) @@ -0,0 +1,11 @@ +#ifndef _XMLVNOTE_H_ +#define _XMLVNOTE_H_ + +typedef struct OSyncHookTables { + GHashTable *attributes; + GHashTable *parameters; +} OSyncHookTables; + +#define HANDLE_IGNORE (void *)1 + +#endif //_XMLVNOTE_H_ Modified: branches/experimental-branch/osengine/osengine_mapcmds.c =================================================================== --- branches/experimental-branch/osengine/osengine_mapcmds.c 2005-04-05 14:36:18 UTC (rev 438) +++ branches/experimental-branch/osengine/osengine_mapcmds.c 2005-04-05 14:37:54 UTC (rev 439) @@ -447,7 +447,7 @@ */ osync_bool osengine_mapping_solve_latest(OSyncEngine *engine, OSyncMapping *mapping, OSyncError **error) { - osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, mapping, error); + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, engine, mapping, error); time_t time = 0; time_t latesttime = 0; @@ -488,6 +488,55 @@ return TRUE; } +/** @brief Checks if the mapping could be solved with solve_latest + * + * This functions checks all changes to see if they contain valid + * timestamp information and if they could be used to solve but does + * not actually solve the mapping + * + * @param engine The engine + * @param mapping The conflicting mapping + * @param error A pointer to an error + * @returns TRUE if the mapping could be solved, FALSE otherwise + * + */ +osync_bool osengine_mapping_check_timestamps(OSyncEngine *engine, OSyncMapping *mapping, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, engine, mapping, error); + + time_t time = 0; + time_t latesttime = 0; + osync_bool preveq = FALSE; + + GList *e = NULL; + for (e = mapping->entries; e; e = e->next) { + OSyncMappingEntry *entry = e->data; + + if (osync_change_get_changetype(entry->change) != CHANGE_UNKNOWN) { + time = osync_change_get_revision(entry->change, error); + if (time == -1) { + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; + } + + if (time > latesttime) { + latesttime = time; + preveq = FALSE; + } else if (time == latesttime) + preveq = TRUE; + } + } + + if (preveq == TRUE) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "Could not decide for one entry. Timestamps where equal"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; + } + + osync_trace(TRACE_EXIT, "%s", __func__); + return TRUE; +} + /** @brief Solves a mapping by setting an updated change * * Solves the mapping by setting an updated change. The change should have been edited by the user. Modified: branches/experimental-branch/tools/osyncplugin.c =================================================================== --- branches/experimental-branch/tools/osyncplugin.c 2005-04-05 14:36:18 UTC (rev 438) +++ branches/experimental-branch/tools/osyncplugin.c 2005-04-05 14:37:54 UTC (rev 439) @@ -312,16 +312,19 @@ char *config; int size; - if (!osync_file_read(configfile, &config, &size, &error)) { - fprintf(stderr, "Unable to read config: %s\n", osync_error_print(&error)); - osync_error_free(&error); - return 1; + if (configfile) { + if (!osync_file_read(configfile, &config, &size, &error)) { + fprintf(stderr, "Unable to read config: %s\n", osync_error_print(&error)); + osync_error_free(&error); + return 1; + } } char *testdir = g_strdup_printf("%s/plgtest.XXXXXX", g_get_tmp_dir()); mkdtemp(testdir); - osync_member_set_config(member, config, size); + if (configfile) + osync_member_set_config(member, config, size); osync_member_set_pluginname(member, pluginname); osync_member_set_configdir(member, testdir); OSyncMemberFunctions *functions = osync_member_get_memberfunctions(member); |
From: <svn...@op...> - 2005-04-05 14:35:03
|
Author: abauer Date: 2005-04-05 16:36:18 +0200 (Tue, 05 Apr 2005) New Revision: 438 Added: branches/experimental-branch/tests/data/vnotes/vnote-minimal.vnt branches/experimental-branch/tests/data/vnotes/vnote1-same.vnt branches/experimental-branch/tests/data/vnotes/vnote1-similar.vnt branches/experimental-branch/tests/data/vnotes/vnote1.vnt branches/experimental-branch/tests/data/vnotes/vnote2.vnt branches/experimental-branch/tests/data/vnotes/vnote3.vnt Modified: branches/experimental-branch/tests/ branches/experimental-branch/tests/Makefile.am branches/experimental-branch/tests/check_vnote.c branches/experimental-branch/tests/mock-plugin/Makefile.am Log: Added unit tests for vnote conversion and comparison Property changes on: branches/experimental-branch/tests ___________________________________________________________________ Name: svn:ignore - Makefile.in env member Makefile user .deps .libs conv sync error filter multisync errorcodes locks vcard vcal *.da *.bb *.bbg + Makefile.in env member Makefile user .deps .libs conv sync error filter multisync errorcodes locks vcard vcal *.da *.bb *.bbg vnote plugin Modified: branches/experimental-branch/tests/Makefile.am =================================================================== --- branches/experimental-branch/tests/Makefile.am 2005-04-05 08:48:16 UTC (rev 437) +++ branches/experimental-branch/tests/Makefile.am 2005-04-05 14:36:18 UTC (rev 438) @@ -17,8 +17,8 @@ endif if ENABLE_TESTS -TESTS = error user member plugin locks env conv sync filter multisync vcard vcal errorcodes $(PROFTEST) -noinst_PROGRAMS = error user member plugin locks env conv sync filter multisync vcard vcal errorcodes +TESTS = error user member plugin locks env conv sync filter multisync vcard vcal vnote errorcodes $(PROFTEST) +noinst_PROGRAMS = error user member plugin locks env conv sync filter multisync vcard vcal vnote errorcodes else TESTS = noinst_PROGRAMS = @@ -85,6 +85,11 @@ vcal_LIBS = @CHECK_LIBS@ vcal_LDFLAGS = @PACKAGE_LIBS@ $(top_builddir)/opensync/libopensync.la $(top_builddir)/osengine/libosengine.la -lcheck -R $(libdir) @GCOV_LDFLAGS@ +vnote_INCLUDES = @CHECK_CFLAGS@ +vnote_SOURCES = check_vnote.c support.c +vnote_LIBS = @CHECK_LIBS@ +vnote_LDFLAGS = @PACKAGE_LIBS@ $(top_builddir)/opensync/libopensync.la $(top_builddir)/osengine/libosengine.la -lcheck -R $(libdir) @GCOV_LDFLAGS@ + errorcodes_INCLUDES = @CHECK_CFLAGS@ errorcodes_SOURCES = check_codes.c support.c errorcodes_LIBS = @CHECK_LIBS@ Modified: branches/experimental-branch/tests/check_vnote.c =================================================================== --- branches/experimental-branch/tests/check_vnote.c 2005-04-05 08:48:16 UTC (rev 437) +++ branches/experimental-branch/tests/check_vnote.c 2005-04-05 14:36:18 UTC (rev 438) @@ -1,6 +1,6 @@ #include "support.h" -static void conv_vcal(const char *filename) +static void conv_vnote(const char *filename) { char *command = g_strdup_printf("cp %s/%s .", g_get_current_dir(), filename); char *testbed = setup_testbed(NULL); @@ -32,13 +32,7 @@ osync_change_set_objformat(change, sourceformat); osync_change_set_objtype(change, osync_objformat_get_objtype(sourceformat)); - OSyncObjFormat *targetformat = NULL; - if (!strcmp(osync_objformat_get_name(sourceformat), "vtodo10")) - targetformat = osync_conv_find_objformat(conv_env, "vtodo20"); - - if (!strcmp(osync_objformat_get_name(sourceformat), "vtodo20")) - targetformat = osync_conv_find_objformat(conv_env, "vtodo10"); - + OSyncObjFormat *targetformat = osync_conv_find_objformat(conv_env, "xml-note"); fail_unless(targetformat != NULL, NULL); OSyncChange *newchange = osync_change_copy(change, &error); @@ -63,8 +57,60 @@ destroy_testbed(testbed); } +static void compare_vnote(const char *lfilename, const char *rfilename, OSyncConvCmpResult result) +{ + char *command1 = g_strdup_printf("cp %s/%s lfile", g_get_current_dir(), lfilename); + char *command2 = g_strdup_printf("cp %s/%s rfile", g_get_current_dir(), rfilename); + char *testbed = setup_testbed(NULL); + system(command1); + g_free(command1); + system(command2); + g_free(command2); + + OSyncError *error = NULL; + OSyncEnv *env = init_env(); + + OSyncFormatEnv *conv_env = osync_conv_env_new(env); + fail_unless(conv_env != NULL, NULL); -static time_t vcal_get_revision(const char *filename) + char *buffer; + int size; + + fail_unless(osync_file_read("lfile", &buffer, &size, &error), NULL); + + OSyncChange *lchange = osync_change_new(); + osync_change_set_uid(lchange, "lfile"); + osync_change_set_data(lchange, buffer, size + 1, TRUE); + osync_change_set_conv_env(lchange, conv_env); + osync_change_set_objformat_string(lchange, "plain"); + + OSyncObjFormat *sourceformat = osync_change_detect_objformat(conv_env, lchange, &error); + fail_unless(sourceformat != NULL, NULL); + osync_change_set_objformat(lchange, sourceformat); + osync_change_set_objtype(lchange, osync_objformat_get_objtype(sourceformat)); + + fail_unless(osync_file_read("rfile", &buffer, &size, &error), NULL); + + OSyncChange *rchange = osync_change_new(); + osync_change_set_uid(rchange, "rfile"); + osync_change_set_data(rchange, buffer, size + 1, TRUE); + osync_change_set_conv_env(rchange, conv_env); + osync_change_set_objformat_string(rchange, "plain"); + + sourceformat = osync_change_detect_objformat(conv_env, rchange, &error); + fail_unless(sourceformat != NULL, NULL); + osync_change_set_objformat(rchange, sourceformat); + osync_change_set_objtype(rchange, osync_objformat_get_objtype(sourceformat)); + + fail_unless(osync_change_compare(lchange, rchange) == result, NULL); + + osync_conv_env_free(conv_env); + osync_env_finalize(env, NULL); + osync_env_free(env); + destroy_testbed(testbed); +} + +static time_t vnote_get_revision(const char *filename) { char *command = g_strdup_printf("cp %s/%s .", g_get_current_dir(), filename); char *testbed = setup_testbed(NULL); @@ -96,10 +142,10 @@ fail_unless(sourceformat != NULL, NULL); osync_change_set_objformat(change, sourceformat); - OSyncObjFormat *targetformat = osync_conv_find_objformat(conv_env, "xml-todo"); + OSyncObjFormat *targetformat = osync_conv_find_objformat(conv_env, "xml-note"); fail_unless(targetformat != NULL, NULL); - fail_unless(osync_change_convert_extension(conv_env, change, targetformat, "evolution", &error), NULL); + fail_unless(osync_change_convert(conv_env, change, targetformat, &error), NULL); time_t time = osync_change_get_revision(change, &error); @@ -111,48 +157,105 @@ return time; } -START_TEST (conv_vcal_evolution2_full1) +START_TEST (conv_vnote1) { - conv_vcal("data/vtodos/evolution2/todo-full1.vcf"); + conv_vnote("data/vnotes/vnote1.vnt"); } END_TEST -START_TEST (todo_get_revision1) +START_TEST (conv_vnote2) { - fail_unless(vcal_get_revision("data/vtodos/evolution2/todo-full1.vcf") == 1110067010, NULL); + conv_vnote("data/vnotes/vnote2.vnt"); } END_TEST -START_TEST (todo_get_revision2) +START_TEST (conv_vnote3) { - fail_unless(vcal_get_revision("data/vtodos/evolution2/todo-full2.vcf") == 1110067010, NULL); + conv_vnote("data/vnotes/vnote3.vnt"); } END_TEST -START_TEST (todo_get_revision3) +START_TEST (conv_vnote_minimal) { - fail_unless(vcal_get_revision("data/vtodos/evolution2/todo-full3.vcf") == 1110063600, NULL); + conv_vnote("data/vnotes/vnote-minimal.vnt"); } END_TEST -START_TEST (todo_no_revision) +START_TEST (get_revision1) { - fail_unless(vcal_get_revision("data/vtodos/kdepim/todo-full1.vcs") == -1, NULL); + fail_unless(vnote_get_revision("data/vnotes/vnote1.vnt") == 1112742000, NULL); } END_TEST -Suite *vcal_suite(void) +START_TEST (get_revision2) { - Suite *s = suite_create("VCal"); - //Suite *s2 = suite_create("VCal"); + fail_unless(vnote_get_revision("data/vnotes/vnote2.vnt") == 1112745661, NULL); +} +END_TEST + +START_TEST (get_revision3) +{ + fail_unless(vnote_get_revision("data/vnotes/vnote3.vnt") == 1112742000, NULL); +} +END_TEST + +START_TEST (get_revision4) +{ + fail_unless(vnote_get_revision("data/vnotes/vnote-minimal.vnt") == -1, NULL); +} +END_TEST + +START_TEST (compare_vnote_same1) +{ + compare_vnote("data/vnotes/vnote1.vnt", "data/vnotes/vnote1.vnt", CONV_DATA_SAME); +} +END_TEST + +START_TEST (compare_vnote_same2) +{ + compare_vnote("data/vnotes/vnote1.vnt", "data/vnotes/vnote1-same.vnt", CONV_DATA_SAME); +} +END_TEST + +START_TEST (compare_vnote_similar1) +{ + compare_vnote("data/vnotes/vnote1.vnt", "data/vnotes/vnote1-similar.vnt", CONV_DATA_SIMILAR); +} +END_TEST + +START_TEST (compare_vnote_mismatch1) +{ + compare_vnote("data/vnotes/vnote1.vnt", "data/vnotes/vnote2.vnt", CONV_DATA_MISMATCH); +} +END_TEST + +START_TEST (compare_vnote_mismatch2) +{ + compare_vnote("data/vnotes/vnote1.vnt", "data/vnotes/vnote-minimal.vnt", CONV_DATA_MISMATCH); +} +END_TEST + +Suite *vnote_suite(void) +{ + Suite *s = suite_create("VNote"); + //Suite *s2 = suite_create("VNote"); - create_case(s, "conv_vcal_evolution2_full1", conv_vcal_evolution2_full1); + create_case(s, "conv_vnote1", conv_vnote1); + create_case(s, "conv_vnote2", conv_vnote2); + create_case(s, "conv_vnote3", conv_vnote3); + create_case(s, "conv_vnote_minimal", conv_vnote_minimal); - create_case(s, "todo_get_revision1", todo_get_revision1); - create_case(s, "todo_get_revision2", todo_get_revision2); - create_case(s, "todo_get_revision3", todo_get_revision3); - create_case(s, "todo_no_revision", todo_no_revision); + create_case(s, "get_revision1", get_revision1); + create_case(s, "get_revision2", get_revision2); + create_case(s, "get_revision3", get_revision3); + create_case(s, "get_revision4", get_revision4); + create_case(s, "compare_vnote_same1", compare_vnote_same1); + create_case(s, "compare_vnote_same2", compare_vnote_same2); + create_case(s, "compare_vnote_similar1", compare_vnote_similar1); + create_case(s, "compare_vnote_mismatch1", compare_vnote_mismatch1); + create_case(s, "compare_vnote_mismatch2", compare_vnote_mismatch2); + return s; } @@ -160,7 +263,7 @@ { int nf; - Suite *s = vcal_suite(); + Suite *s = vnote_suite(); SRunner *sr; sr = srunner_create(s); Added: branches/experimental-branch/tests/data/vnotes/vnote-minimal.vnt =================================================================== --- branches/experimental-branch/tests/data/vnotes/vnote-minimal.vnt 2005-04-05 08:48:16 UTC (rev 437) +++ branches/experimental-branch/tests/data/vnotes/vnote-minimal.vnt 2005-04-05 14:36:18 UTC (rev 438) @@ -0,0 +1,5 @@ +BEGIN:VNOTE +VERSION:1.1 +BODY:This is just a test +END:VNOTE + Added: branches/experimental-branch/tests/data/vnotes/vnote1-same.vnt =================================================================== --- branches/experimental-branch/tests/data/vnotes/vnote1-same.vnt 2005-04-05 08:48:16 UTC (rev 437) +++ branches/experimental-branch/tests/data/vnotes/vnote1-same.vnt 2005-04-05 14:36:18 UTC (rev 438) @@ -0,0 +1,10 @@ +BEGIN:VNOTE +VERSION:1.1 +X-IRMC-LUID:someuid5 +DCREATED:2005-04-07 +LAST-MODIFIED:2005-04-08 +SUMMARY:This is a summary +BODY:This is just a test +CATEGORIES:Birthday,Friends +CLASS:PUBLIC +END:VNOTE Added: branches/experimental-branch/tests/data/vnotes/vnote1-similar.vnt =================================================================== --- branches/experimental-branch/tests/data/vnotes/vnote1-similar.vnt 2005-04-05 08:48:16 UTC (rev 437) +++ branches/experimental-branch/tests/data/vnotes/vnote1-similar.vnt 2005-04-05 14:36:18 UTC (rev 438) @@ -0,0 +1,10 @@ +BEGIN:VNOTE +VERSION:1.1 +X-IRMC-LUID:someuid3 +DCREATED:2005-04-06 +LAST-MODIFIED:2005-04-07 +SUMMARY:This is a summary +BODY:This is just a test +CATEGORIES:Birthday,Friends,Test +CLASS:PRIVATE +END:VNOTE Added: branches/experimental-branch/tests/data/vnotes/vnote1.vnt =================================================================== --- branches/experimental-branch/tests/data/vnotes/vnote1.vnt 2005-04-05 08:48:16 UTC (rev 437) +++ branches/experimental-branch/tests/data/vnotes/vnote1.vnt 2005-04-05 14:36:18 UTC (rev 438) @@ -0,0 +1,10 @@ +BEGIN:VNOTE +VERSION:1.1 +X-IRMC-LUID:someuid +DCREATED:2005-04-05 +LAST-MODIFIED:2005-04-06 +SUMMARY:This is a summary +BODY:This is just a test +CATEGORIES:Birthday,Friends +CLASS:PUBLIC +END:VNOTE Added: branches/experimental-branch/tests/data/vnotes/vnote2.vnt =================================================================== --- branches/experimental-branch/tests/data/vnotes/vnote2.vnt 2005-04-05 08:48:16 UTC (rev 437) +++ branches/experimental-branch/tests/data/vnotes/vnote2.vnt 2005-04-05 14:36:18 UTC (rev 438) @@ -0,0 +1,10 @@ +BEGIN:VNOTE +VERSION:1.1 +X-IRMC-LUID:someuid2 +DCREATED:2005-04-05T01:01:01Z +LAST-MODIFIED:2005-04-06T01:01:01Z +SUMMARY:This is a summary +BODY:This is just a test lines +CATEGORIES:Birthday,Friends +CLASS:PRIVATE +END:VNOTE Added: branches/experimental-branch/tests/data/vnotes/vnote3.vnt =================================================================== --- branches/experimental-branch/tests/data/vnotes/vnote3.vnt 2005-04-05 08:48:16 UTC (rev 437) +++ branches/experimental-branch/tests/data/vnotes/vnote3.vnt 2005-04-05 14:36:18 UTC (rev 438) @@ -0,0 +1,8 @@ +BEGIN:VNOTE +VERSION:1.1 +DCREATED:20050405 +LAST-MODIFIED:20050406 +SUMMARY:This is a summary +BODY:This is a multi\nline\nbody with special chars +CLASS:CONFIDENTIAL +END:VNOTE Modified: branches/experimental-branch/tests/mock-plugin/Makefile.am =================================================================== --- branches/experimental-branch/tests/mock-plugin/Makefile.am 2005-04-05 08:48:16 UTC (rev 437) +++ branches/experimental-branch/tests/mock-plugin/Makefile.am 2005-04-05 14:36:18 UTC (rev 438) @@ -2,7 +2,7 @@ AM_CFLAGS = -Wall -Werror @XML_CFLAGS@ -EXTRA_DIST = mock_sync.h +EXTRA_DIST = mock_sync.h Makefile.in lib_LTLIBRARIES = mock_sync.la mockformat.la |
From: <svn...@op...> - 2005-04-05 08:47:00
|
Author: abauer Date: 2005-04-05 10:48:16 +0200 (Tue, 05 Apr 2005) New Revision: 437 Modified: branches/experimental-branch/misc/buildtest.sh Log: Added a test to the buildtest script to check if configure is working without running autogen.sh before Modified: branches/experimental-branch/misc/buildtest.sh =================================================================== --- branches/experimental-branch/misc/buildtest.sh 2005-04-04 16:13:16 UTC (rev 436) +++ branches/experimental-branch/misc/buildtest.sh 2005-04-05 08:48:16 UTC (rev 437) @@ -29,6 +29,9 @@ cd libopensync-0.?? +echo -n "Checking if configure is working" +./configure --enable-tests=no > /dev/null || exit 1 +./configure --enable-tests=yes > /dev/null || exit 1 echo -n "Making OpenSync" ./autogen.sh --prefix=$TOP_SRCDIR/_inst > /dev/null || exit 1 echo -n "." |
From: <svn...@op...> - 2005-04-04 16:12:00
|
Author: abauer Date: 2005-04-04 18:13:16 +0200 (Mon, 04 Apr 2005) New Revision: 436 Modified: branches/experimental-kdepim/Makefile.am branches/experimental-kdepim/src/knotes-test.cpp branches/experimental-kdepim/src/knotes.cpp branches/experimental-kdepim/src/knotes.h Log: More updates to make the notes part use dcop Modified: branches/experimental-kdepim/Makefile.am =================================================================== --- branches/experimental-kdepim/Makefile.am 2005-04-04 15:28:27 UTC (rev 435) +++ branches/experimental-kdepim/Makefile.am 2005-04-04 16:13:16 UTC (rev 436) @@ -1,31 +1,20 @@ -#FIXME kdepimlibdir=@OPENSYNC_LIBDIR@/kdepim plugindir=@OPENSYNC_PLUGINDIR@ -#configdir=@OPENSYNC_CONFIGDIR@ -#FIXME: set EXTRA_DIST - INCLUDES = $(OSYNC_CFLAGS) $(XML_CFLAGS) $(GLIB_CFLAGS) $(KDE_INCLUDES) $(QT_INCLUDES) AM_CXXFLAGS = -Wall -Werror -# Temporary hack to fix difference between <opensync/opensync.h> and <opensync.h> -INCLUDES += -I@OPENSYNC_INCLUDEDIR@/opensync-1.0/opensync - #FIXME: Is there a KDE macro to set this? LIB_KCAL = -lkcal plugin_LTLIBRARIES = kdepim_sync.la kdepim_lib.la -# format_LTLIBRARIES = kcal_format.la EXTRA_DIST = \ src/kaddrbook.h \ src/kcal.h \ src/osyncbase.h \ - src/knotes.h + src/knotes.h \ + src/KNotesIface.h -# kcal_format_la_SOURCES = src/kcal_format.cpp -# kcal_format_la_LDFLAGS = -avoid-version -export-dynamic -module -# kcal_format_la_LIBADD = $(KDE_RPATH) $(LIB_KABC) - kdepim_sync_la_SOURCES = src/kdepim_sync.cpp kdepim_sync_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror kdepim_sync_la_LDFLAGS = -avoid-version -export-dynamic -module @@ -35,14 +24,13 @@ kdepim_lib_la_SOURCES = src/kdepim_impl.cpp \ src/kcal.cpp \ - src/knotes.cpp + src/knotes.cpp \ + src/kaddrbook.cpp \ + src/KNotesIface_stub.cpp kdepim_lib_la_CXXFLAGS = -DPLUGINDIR=\"$(plugindir)\" -DKDEPIM_LIBDIR=\"$(plugindir)\" -Wall -Werror kdepim_lib_la_LDFLAGS = $(KDE_LDFLAGS) -avoid-version -export-dynamic -module kdepim_lib_la_LIBADD = $(KDE_RPATH) $(LIB_KABC) $(LIB_KCAL) -L$(libdir) -L@OPENSYNC_LIBDIR@ -lopensync-xml -bin_PROGRAMS = notestest - - -notestest_SOURCES = src/knotes-test.cpp src/KNotesIface_stub.cpp -notestest_LDFLAGS = $(KDE_LDFLAGS) -notestest_LDADD = $(KDE_RPATH) $(LIB_KABC) $(LIB_KCAL) -L$(libdir) -L@OPENSYNC_LIBDIR@ +KNotesIface_stub.cpp: + dcopidl src/KNotesIface.h > src/KNotesIface.kidl + dcopidl2cpp src/KNotesIface.kidl \ No newline at end of file Modified: branches/experimental-kdepim/src/knotes-test.cpp =================================================================== --- branches/experimental-kdepim/src/knotes-test.cpp 2005-04-04 15:28:27 UTC (rev 435) +++ branches/experimental-kdepim/src/knotes-test.cpp 2005-04-04 16:13:16 UTC (rev 436) @@ -50,9 +50,8 @@ } } - KNotesIface_stub *fKNotes = new KNotesIface_stub(knotesAppname,"KNotesIface"); - + fNotes = fKNotes->notes(); if (fKNotes->status() != DCOPStub::CallSucceeded) { Modified: branches/experimental-kdepim/src/knotes.cpp =================================================================== --- branches/experimental-kdepim/src/knotes.cpp 2005-04-04 15:28:27 UTC (rev 435) +++ branches/experimental-kdepim/src/knotes.cpp 2005-04-04 16:13:16 UTC (rev 436) @@ -42,60 +42,72 @@ bool KNotesDataSource::connect(OSyncContext *ctx) { - //connect to dcop + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); //check knotes running - //start knotes if not running + + //connect to dcop + DCOPClient *kn_dcop = KApplication::kApplication()->dcopClient(); + if (!kndcop) { + osync_context_report_error(ctx, OSYNC_ERROR_INITIALIZATION, "Unable to make new dcop for knotes"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to make new dcop for knotes", __func__); + return FALSE; + } - // Terminate knotes because we will change its data - // Yes, it is _very_ ugly - //FIXME: use dcop programming interface, not the commandline utility - if (!system("dcop knotes MainApplication-Interface quit")) - /* Restart knotes later */ - knotesWasRunning = true; - else + if (!dcop->attach()) { + osync_context_report_error(ctx, OSYNC_ERROR_INITIALIZATION, "Unable to attach dcop for knotes"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to attach dcop for knotes", __func__); + return FALSE; + } + + QCStringList apps = dcop->registeredApplications(); + if (!apps.contains("knotes")) { + //start knotes if not running knotesWasRunning = false; + } else + knotesWasRunning = true; - calendar = new KCal::CalendarLocal; - if (!calendar) { - osync_context_report_error(ctx, OSYNC_ERROR_INITIALIZATION, "Couldn't allocate calendar object"); - return false; - } - - QString notes_loc = KGlobal::dirs()->saveLocation( "data" , "knotes/" ) + "notes.ics"; + kn_iface = new KNotesIface_stub(knotesAppname,"KNotesIface"); - if (!calendar->load(notes_loc)) { - osync_context_report_error(ctx, OSYNC_ERROR_FILE_NOT_FOUND, "Couldn't load notes"); - return false; - } - - return true; + osync_trace(TRACE_EXIT, "%s", __func__); + return true; } bool KNotesDataSource::disconnect(OSyncContext *ctx) { - if (!saveNotes(ctx)) - return false; - - delete calendar; - calendar = NULL; - - // FIXME: ugly, but necessary - if (knotesWasRunning) - system("knotes"); - return true; + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); + //call sync on knotes dcop + + // FIXME: ugly, but necessary + if (!knotesWasRunning) { + //Terminate knotes + } + + //detach dcop + //destroy dcop + + osync_trace(TRACE_EXIT, "%s", __func__); + return true; } bool KNotesDataSource::get_changeinfo(OSyncContext *ctx) { - KCal::Journal::List notes = calendar->journals(); - - for (KCal::Journal::List::ConstIterator i = notes.begin(); i != notes.end(); i++) { - osync_debug("knotes", 4, "Note summary: %s", (const char*)(*i)->summary().local8Bit()); - osync_debug("knotes", 4, "Note contents:\n%s\n====", (const char*)(*i)->description().local8Bit()); - + osync_trace(TRACE_ENTRY, "%s(%p)", __func__, ctx); + QMap <KNoteID_t,QString> fNotes; + + fNotes = fKNotes->notes(); + if (fKNotes->status() != DCOPStub::CallSucceeded) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Unable to get changed notes"); + osync_trace(TRACE_EXIT_ERROR, "%s: Unable to get changed notes", __func__); + return FALSE; + } + + QMap<KNoteID_t,QString>::ConstIterator i = fNotes.begin(); + while (i != fNotes.end()) { + osync_debug("knotes", 4, "Note key: %s", (const char*)i.key().local8Bit()); + osync_debug("knotes", 4, "Note contents:\n%s\n====", (const char*)i.data().local8Bit()); + QString uid = (*i)->uid(); - QString hash = calc_hash(*i); // Create osxml doc containing the note xmlDoc *doc = xmlNewDoc((const xmlChar*)"1.0"); @@ -124,16 +136,6 @@ osync_change_set_objformat_string(chg, "xml-note"); osync_change_set_data(chg, (char*)doc, sizeof(doc), 1); - - //XXX: workaround to a bug on osync_change_multiply_master: - // convert it to vnote - OSyncFormatEnv *env = osync_member_get_format_env(member); - OSyncError *e = NULL; - if (!osync_change_convert_fmtname(env, chg, "vnote11", &e)) { - osync_context_report_error(ctx, OSYNC_ERROR_CONVERT, "Error converting data to vnote: %s", osync_error_print(&e)); - return false; - } - // Use the hash table to check if the object // needs to be reported osync_change_set_hash(chg, hash.data()); @@ -164,31 +166,18 @@ QString summary = osxml_find_node(root, "Summary"); QString body = osxml_find_node(root, "Body"); - - KCal::Journal *j = calendar->journal(uid); - - if (type == CHANGE_MODIFIED && !j) - type = CHANGE_ADDED; - QString hash, uid; // end of the ugly-format parsing switch (type) { case CHANGE_ADDED: - j = new KCal::Journal; - j->setUid(uid); - j->setSummary(summary); - j->setDescription(body); - hash = calc_hash(j); - calendar->addJournal(j); - uid = j->uid(); + uid = newNote(); osync_change_set_uid(chg, uid); osync_change_set_hash(chg, hash); - break; case CHANGE_MODIFIED: - j->setSummary(summary); - j->setDescription(body); - hash = calc_hash(j); + setText + setBody + hash = calc_hash(); osync_change_set_hash(chg, hash); break; default: @@ -196,10 +185,7 @@ return false; } } else { - KCal::Journal *j = calendar->journal(uid); - if (j) { - calendar->deleteJournal(j); - } + //dcop killNote } osync_context_report_success(ctx); Modified: branches/experimental-kdepim/src/knotes.h =================================================================== --- branches/experimental-kdepim/src/knotes.h 2005-04-04 15:28:27 UTC (rev 435) +++ branches/experimental-kdepim/src/knotes.h 2005-04-04 16:13:16 UTC (rev 436) @@ -52,9 +52,10 @@ { private: OSyncMember *member; - OSyncHashTable *hashtable; - KCal::CalendarLocal *calendar; - + KNotesIface_stub *fKNotes; + DCOPClient *kn_dcop + KNotesIface_stub kn_iface; + /** Ugly hack to restart KNotes if it * was running */ |
From: <svn...@op...> - 2005-04-04 15:27:19
|
Author: abauer Date: 2005-04-04 17:28:27 +0200 (Mon, 04 Apr 2005) New Revision: 435 Added: branches/experimental-kdepim/src/KNotesIface.h branches/experimental-kdepim/src/kaddrbook.c branches/experimental-kdepim/src/knotes-test.cpp Modified: branches/experimental-kdepim/Makefile.am branches/experimental-kdepim/src/kcal.cpp branches/experimental-kdepim/src/kcal.h branches/experimental-kdepim/src/kdepim_impl.cpp branches/experimental-kdepim/src/knotes.cpp branches/experimental-kdepim/src/knotes.h Log: Started the changes to the notes access in the kdepim plugin Modified: branches/experimental-kdepim/Makefile.am =================================================================== --- branches/experimental-kdepim/Makefile.am 2005-04-04 15:26:13 UTC (rev 434) +++ branches/experimental-kdepim/Makefile.am 2005-04-04 15:28:27 UTC (rev 435) @@ -40,4 +40,9 @@ kdepim_lib_la_LDFLAGS = $(KDE_LDFLAGS) -avoid-version -export-dynamic -module kdepim_lib_la_LIBADD = $(KDE_RPATH) $(LIB_KABC) $(LIB_KCAL) -L$(libdir) -L@OPENSYNC_LIBDIR@ -lopensync-xml +bin_PROGRAMS = notestest + +notestest_SOURCES = src/knotes-test.cpp src/KNotesIface_stub.cpp +notestest_LDFLAGS = $(KDE_LDFLAGS) +notestest_LDADD = $(KDE_RPATH) $(LIB_KABC) $(LIB_KCAL) -L$(libdir) -L@OPENSYNC_LIBDIR@ Added: branches/experimental-kdepim/src/KNotesIface.h =================================================================== --- branches/experimental-kdepim/src/KNotesIface.h 2005-04-04 15:26:13 UTC (rev 434) +++ branches/experimental-kdepim/src/KNotesIface.h 2005-04-04 15:28:27 UTC (rev 435) @@ -0,0 +1,139 @@ +/******************************************************************* + KNotesIface.h -- This file defines the DCOP interface for KNotes. + + Copyright (C) 2000 by Adriaan de Groot + 2001-2003 by Michael Brade <br...@kd...> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*******************************************************************/ + +#ifndef __KNotesIface_h__ +#define __KNotesIface_h__ + +#include <qstring.h> +#include <qmap.h> + +#include <dcopobject.h> + + +class KNotesIface : virtual public DCOPObject +{ + K_DCOP +k_dcop: + /** + * Create a new note. + * @param name the name (title) of the new note, if it is empty, + * KNotes will choose an appropriate name + * @param text the body of the new note + * @return the new notes' id + */ + virtual QString newNote( const QString& name = QString::null, + const QString& text = QString::null ) = 0; + + /** + * Create a new note and inserts the current text in the clipboard + * as text. + * + * @param name the name (title) of the new note, if it is empty, + * KNotes will choose an appropriate name + * @return the new notes' id + */ + virtual QString newNoteFromClipboard( const QString& name = QString::null ) = 0; + + /** + * Show a note as if it had been selected from the "notes" menu. + * @param noteId the id of the note to show + */ + virtual ASYNC showNote( const QString& noteId ) const = 0; + + /** + * Hide a note. + * @param noteId the id of the note to hide + */ + virtual ASYNC hideNote( const QString& noteId ) const = 0; + + /** + * Deletes a note forever. + * @param noteId the id of the note to kill + */ + virtual ASYNC killNote( const QString& noteId ) = 0; + + /** + * Deletes a note forever. + * @param noteId the id of the note to kill + * @param force do not request confirmation + */ + virtual ASYNC killNote( const QString& noteId, bool force ) = 0; + + /** + * Get all the notes including their ids. + * @return a QMap that maps the id of a note to its name + */ + virtual QMap<QString,QString> notes() const = 0; + + /** + * Changes the title/name of a note. + * @param noteId the id of the note to be modified + * @param newName the new title + */ + virtual ASYNC setName( const QString& noteId, const QString& newName ) = 0; + + /** + * Sets the text of a note. This will delete the old text! + * @param noteId the id of the note + * @param newText the new text for the note + */ + virtual ASYNC setText( const QString& noteId, const QString& newText ) = 0; + + /** + * Returns the title/name of a note. + * @param noteId the id of the note in question + * @return the name as a QString + */ + virtual QString name( const QString& noteId ) const = 0; + + /** + * Returns the text of a note. + * @param noteId the id of the note in question + * @return the body as a QString + */ + virtual QString text( const QString& noteId ) const = 0; + + /** + * This tells KNotes that a specific app has synchronized with all the notes. + * @param app the app that has synced with KNotes + */ + virtual ASYNC sync( const QString& app ) = 0; + + /** + * Test if a note was created new after the last sync. + * @param app the app that wants to get the status since the last sync + * @param noteId the id of the note + * @return true if the note is new, false if not or if the note does + * not exist + */ + virtual bool isNew( const QString& app, const QString& noteId ) const = 0; + + /** + * Test if a note was modified since the last sync. + * @param app the app that wants to get the status since the last sync + * @param noteId the id of the note + * @return true if modified (note that this will return true if the note is + * new as well!) and false if the note is not modified or doesn't exist + */ + virtual bool isModified( const QString& app, const QString& noteId ) const = 0; +}; + +#endif Added: branches/experimental-kdepim/src/kaddrbook.c =================================================================== --- branches/experimental-kdepim/src/kaddrbook.c 2005-04-04 15:26:13 UTC (rev 434) +++ branches/experimental-kdepim/src/kaddrbook.c 2005-04-04 15:28:27 UTC (rev 435) @@ -0,0 +1,260 @@ +/** Calculate the hash value for an Addressee. + * Should be called before returning/writing the + * data, because the revision of the Addressee + * can be changed. + */ + QString calc_hash(KABC::Addressee &e) + { + //Get the revision date of the KDE addressbook entry. + //Regard entries with invalid revision dates as having just been changed. + QDateTime revdate = e.revision(); + osync_debug("kde", 3, "Getting hash: %s", revdate.toString().data()); + if (!revdate.isValid()) + { + revdate = QDateTime::currentDateTime(); + e.setRevision(revdate); + } + + return revdate.toString(); + } + + virtual void connect(OSyncContext *ctx) + { + //Lock the addressbook + //addressbookticket = addressbookptr->requestSaveTicket(); + + OSyncError *error = NULL; + if (!osync_hashtable_load(hashtable, member, &error)) + { + osync_context_report_osyncerror(ctx, &error); + return; + } + + //Detection mechanismn if this is the first sync + if (!osync_anchor_compare(member, "synced", "true")) { + osync_member_set_slow_sync(member, "contact", TRUE); + osync_anchor_update(member, "synced", "true"); + } + + /*if (!addressbookticket) + { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't lock KDE addressbook"); + return; + }*/ + osync_debug("kde", 3, "KDE addressbook locked OK."); + + if (kcal && !kcal->connect(ctx)) + return; + if (knotes && !knotes->connect(ctx)) + return; + osync_context_report_success(ctx); + } + + virtual void disconnect(OSyncContext *ctx) + { + //Unlock the addressbook + //addressbookptr->save(addressbookticket); + //addressbookticket = NULL; + + KABC::Ticket *ticket = addressbookptr->requestSaveTicket(); + if ( !ticket ) { + osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Unable to get save ticket"); + return; + } + + if ( !addressbookptr->save( ticket ) ) { + osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Unable to get save using ticket"); + return; + } + + osync_hashtable_close(hashtable); + + if (kcal && !kcal->disconnect(ctx)) + return; + if (knotes && !knotes->disconnect(ctx)) + return; + osync_context_report_success(ctx); + } + + + /*FIXME: move kaddrbook implementation to kaddrbook.cpp */ + bool addrbook_get_changeinfo(OSyncContext *ctx) + { + //osync_debug("kde", 3, "kaddrbook::%s(newdbs=%d)", __FUNCTION__, newdbs); + + if (osync_member_get_slow_sync(member, "contact")) + osync_hashtable_set_slow_sync(hashtable, "contact"); + + // We must reload the KDE addressbook in order to retrieve the latest changes. + if (!addressbookptr->load()) { + osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't reload KDE addressbook"); + return false; + } + osync_debug("kde", 3, "KDE addressbook reloaded OK."); + + KABC::VCardConverter converter; + + for (KABC::AddressBook::Iterator it=addressbookptr->begin(); it!=addressbookptr->end(); it++ ) { + QString uid = it->uid(); + + OSyncChange *chg = osync_change_new(); + + osync_change_set_member(chg, member); + osync_change_set_uid(chg, uid.local8Bit()); + + QString hash = calc_hash(*it); + + // Convert the VCARD data into a string + const char *data = converter.createVCard(*it).utf8(); + osync_change_set_data(chg, strdup(data), strlen(data) + 1, TRUE); + + // object type and format + osync_change_set_objtype_string(chg, "contact"); + osync_change_set_objformat_string(chg, "vcard21"); + + // Use the hash table to check if the object + // needs to be reported + osync_change_set_hash(chg, hash.data()); + if (osync_hashtable_detect_change(hashtable, chg)) { + osync_context_report_change(ctx, chg); + osync_hashtable_update_hash(hashtable, chg); + } + } + + // Use the hashtable to report deletions + osync_hashtable_report_deleted(hashtable, ctx, "contact"); + + return true; + } + + virtual void get_changeinfo(OSyncContext *ctx) + { + if (!addrbook_get_changeinfo(ctx)) + return; + if (kcal && !kcal->get_changeinfo_events(ctx)) + return; + + if (kcal && !kcal->get_changeinfo_todos(ctx)) + return; + + if (knotes && !knotes->get_changeinfo(ctx)) + return; + + osync_context_report_success(ctx); + } + + void kabc_get_data(OSyncContext *ctx, OSyncChange *chg) + { + QString uid = osync_change_get_uid(chg); + KABC::Addressee a = addressbookptr->findByUid(uid); + KABC::VCardConverter converter; + QCString card = converter.createVCard(a).utf8(); + const char *data = card; + //FIXME: deallocate data somewhere + osync_change_set_data(chg, strdup(data), strlen(data), 1); + osync_context_report_success(ctx); + } + + + virtual void get_data(OSyncContext *ctx, OSyncChange *) + { + /* + switch (osync_change_get_objtype(chg)) { + case contact: + kabc_get_data(ctx, chg); + break; + case calendar: + kcal->get_data(ctx, chg); + break; + default: + osync_context_report_error(ctx, OSYNC_ERROR_FILE_NOT_FOUND, "Invalid UID"); + return; + } + osync_context_report_success(ctx); + */ + osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Not implemented yet"); + } + + + + /** Access an object, without returning success + * + * returns 0 on success, < 0 on error. + * If an error occurss, the error will be already reported + * using osync_context_report_error() + */ + int __vcard_access(OSyncContext *ctx, OSyncChange *chg) + { + KABC::VCardConverter converter; + + // convert VCARD string from obj->comp into an Addresse object. + char *data = osync_change_get_data(chg); + size_t data_size = osync_change_get_datasize(chg); + QString uid = osync_change_get_uid(chg); + + OSyncChangeType chtype = osync_change_get_changetype(chg); + switch(chtype) + { + case CHANGE_MODIFIED: + { + unfold_vcard(data, &data_size); + KABC::Addressee addressee = converter.parseVCard(QString::fromUtf8(data, data_size)); + + // ensure it has the correct UID and revision + addressee.setUid(uid); + addressee.setRevision(QDateTime::currentDateTime()); + + // replace the current addressbook entry (if any) with the new one + + addressbookptr->insertAddressee(addressee); + + QString hash = calc_hash(addressee); + osync_change_set_hash(chg, hash); + osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY UPDATED (UID=%s)", (const char *)uid.local8Bit()); + break; + } + + case CHANGE_ADDED: + { + unfold_vcard(data, &data_size); + KABC::Addressee addressee = converter.parseVCard(QString::fromUtf8(data, data_size)); + + // ensure it has the correct revision + addressee.setRevision(QDateTime::currentDateTime()); + + // add the new address to the addressbook + addressbookptr->insertAddressee(addressee); + + osync_change_set_uid(chg, addressee.uid().local8Bit()); + + QString hash = calc_hash(addressee); + osync_change_set_hash(chg, hash); + osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY ADDED (UID=%s)", (const char *)addressee.uid().local8Bit()); + + break; + } + + case CHANGE_DELETED: + { + if (uid.isEmpty()) + { + osync_context_report_error(ctx, OSYNC_ERROR_FILE_NOT_FOUND, "Trying to delete entry with empty UID"); + return -1; + } + + //find addressbook entry with matching UID and delete it + KABC::Addressee addressee = addressbookptr->findByUid(uid); + if(!addressee.isEmpty()) + addressbookptr->removeAddressee(addressee); + + osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY DELETED (UID=%s)", (const char*)uid.local8Bit()); + + break; + } + default: + osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Operation not supported"); + return -1; + } + + return 0; + } \ No newline at end of file Modified: branches/experimental-kdepim/src/kcal.cpp =================================================================== --- branches/experimental-kdepim/src/kcal.cpp 2005-04-04 15:26:13 UTC (rev 434) +++ branches/experimental-kdepim/src/kcal.cpp 2005-04-04 15:28:27 UTC (rev 435) @@ -23,12 +23,6 @@ * @autor Eduardo Pereira Habkost <eha...@co...> */ -#include <libkcal/calendarresources.h> -#include <libkcal/icalformat.h> -#include <libkcal/calendarlocal.h> -#include <kdeversion.h> - -#include "osyncbase.h" #include "kcal.h" KCalDataSource::KCalDataSource(OSyncMember *member, OSyncHashTable *hashtable) Modified: branches/experimental-kdepim/src/kcal.h =================================================================== --- branches/experimental-kdepim/src/kcal.h 2005-04-04 15:26:13 UTC (rev 434) +++ branches/experimental-kdepim/src/kcal.h 2005-04-04 15:28:27 UTC (rev 435) @@ -25,6 +25,9 @@ #include <libkcal/calendarresources.h> #include <libkcal/incidence.h> +#include <libkcal/icalformat.h> +#include <libkcal/calendarlocal.h> +#include <kdeversion.h> #include "osyncbase.h" Modified: branches/experimental-kdepim/src/kdepim_impl.cpp =================================================================== --- branches/experimental-kdepim/src/kdepim_impl.cpp 2005-04-04 15:26:13 UTC (rev 434) +++ branches/experimental-kdepim/src/kdepim_impl.cpp 2005-04-04 15:28:27 UTC (rev 435) @@ -142,267 +142,6 @@ osync_hashtable_free(hashtable); } - /** Calculate the hash value for an Addressee. - * Should be called before returning/writing the - * data, because the revision of the Addressee - * can be changed. - */ - QString calc_hash(KABC::Addressee &e) - { - //Get the revision date of the KDE addressbook entry. - //Regard entries with invalid revision dates as having just been changed. - QDateTime revdate = e.revision(); - osync_debug("kde", 3, "Getting hash: %s", revdate.toString().data()); - if (!revdate.isValid()) - { - revdate = QDateTime::currentDateTime(); - e.setRevision(revdate); - } - - return revdate.toString(); - } - - virtual void connect(OSyncContext *ctx) - { - //Lock the addressbook - //addressbookticket = addressbookptr->requestSaveTicket(); - - OSyncError *error = NULL; - if (!osync_hashtable_load(hashtable, member, &error)) - { - osync_context_report_osyncerror(ctx, &error); - return; - } - - //Detection mechanismn if this is the first sync - if (!osync_anchor_compare(member, "synced", "true")) { - osync_member_set_slow_sync(member, "contact", TRUE); - osync_anchor_update(member, "synced", "true"); - } - - /*if (!addressbookticket) - { - osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't lock KDE addressbook"); - return; - }*/ - osync_debug("kde", 3, "KDE addressbook locked OK."); - - if (kcal && !kcal->connect(ctx)) - return; - if (knotes && !knotes->connect(ctx)) - return; - osync_context_report_success(ctx); - } - - virtual void disconnect(OSyncContext *ctx) - { - //Unlock the addressbook - //addressbookptr->save(addressbookticket); - //addressbookticket = NULL; - - KABC::Ticket *ticket = addressbookptr->requestSaveTicket(); - if ( !ticket ) { - osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Unable to get save ticket"); - return; - } - - if ( !addressbookptr->save( ticket ) ) { - osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Unable to get save using ticket"); - return; - } - - osync_hashtable_close(hashtable); - - if (kcal && !kcal->disconnect(ctx)) - return; - if (knotes && !knotes->disconnect(ctx)) - return; - osync_context_report_success(ctx); - } - - - /*FIXME: move kaddrbook implementation to kaddrbook.cpp */ - bool addrbook_get_changeinfo(OSyncContext *ctx) - { - //osync_debug("kde", 3, "kaddrbook::%s(newdbs=%d)", __FUNCTION__, newdbs); - - if (osync_member_get_slow_sync(member, "contact")) - osync_hashtable_set_slow_sync(hashtable, "contact"); - - // We must reload the KDE addressbook in order to retrieve the latest changes. - if (!addressbookptr->load()) { - osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't reload KDE addressbook"); - return false; - } - osync_debug("kde", 3, "KDE addressbook reloaded OK."); - - KABC::VCardConverter converter; - - for (KABC::AddressBook::Iterator it=addressbookptr->begin(); it!=addressbookptr->end(); it++ ) { - QString uid = it->uid(); - - OSyncChange *chg = osync_change_new(); - - osync_change_set_member(chg, member); - osync_change_set_uid(chg, uid.local8Bit()); - - QString hash = calc_hash(*it); - - // Convert the VCARD data into a string - const char *data = converter.createVCard(*it).utf8(); - osync_change_set_data(chg, strdup(data), strlen(data) + 1, TRUE); - - // object type and format - osync_change_set_objtype_string(chg, "contact"); - osync_change_set_objformat_string(chg, "vcard21"); - - // Use the hash table to check if the object - // needs to be reported - osync_change_set_hash(chg, hash.data()); - if (osync_hashtable_detect_change(hashtable, chg)) { - osync_context_report_change(ctx, chg); - osync_hashtable_update_hash(hashtable, chg); - } - } - - // Use the hashtable to report deletions - osync_hashtable_report_deleted(hashtable, ctx, "contact"); - - return true; - } - - virtual void get_changeinfo(OSyncContext *ctx) - { - if (!addrbook_get_changeinfo(ctx)) - return; - if (kcal && !kcal->get_changeinfo_events(ctx)) - return; - - if (kcal && !kcal->get_changeinfo_todos(ctx)) - return; - - if (knotes && !knotes->get_changeinfo(ctx)) - return; - - osync_context_report_success(ctx); - } - - void kabc_get_data(OSyncContext *ctx, OSyncChange *chg) - { - QString uid = osync_change_get_uid(chg); - KABC::Addressee a = addressbookptr->findByUid(uid); - KABC::VCardConverter converter; - QCString card = converter.createVCard(a).utf8(); - const char *data = card; - //FIXME: deallocate data somewhere - osync_change_set_data(chg, strdup(data), strlen(data), 1); - osync_context_report_success(ctx); - } - - - virtual void get_data(OSyncContext *ctx, OSyncChange *) - { - /* - switch (osync_change_get_objtype(chg)) { - case contact: - kabc_get_data(ctx, chg); - break; - case calendar: - kcal->get_data(ctx, chg); - break; - default: - osync_context_report_error(ctx, OSYNC_ERROR_FILE_NOT_FOUND, "Invalid UID"); - return; - } - osync_context_report_success(ctx); - */ - osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Not implemented yet"); - } - - - - /** Access an object, without returning success - * - * returns 0 on success, < 0 on error. - * If an error occurss, the error will be already reported - * using osync_context_report_error() - */ - int __vcard_access(OSyncContext *ctx, OSyncChange *chg) - { - KABC::VCardConverter converter; - - // convert VCARD string from obj->comp into an Addresse object. - char *data = osync_change_get_data(chg); - size_t data_size = osync_change_get_datasize(chg); - QString uid = osync_change_get_uid(chg); - - OSyncChangeType chtype = osync_change_get_changetype(chg); - switch(chtype) - { - case CHANGE_MODIFIED: - { - unfold_vcard(data, &data_size); - KABC::Addressee addressee = converter.parseVCard(QString::fromUtf8(data, data_size)); - - // ensure it has the correct UID and revision - addressee.setUid(uid); - addressee.setRevision(QDateTime::currentDateTime()); - - // replace the current addressbook entry (if any) with the new one - - addressbookptr->insertAddressee(addressee); - - QString hash = calc_hash(addressee); - osync_change_set_hash(chg, hash); - osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY UPDATED (UID=%s)", (const char *)uid.local8Bit()); - break; - } - - case CHANGE_ADDED: - { - unfold_vcard(data, &data_size); - KABC::Addressee addressee = converter.parseVCard(QString::fromUtf8(data, data_size)); - - // ensure it has the correct revision - addressee.setRevision(QDateTime::currentDateTime()); - - // add the new address to the addressbook - addressbookptr->insertAddressee(addressee); - - osync_change_set_uid(chg, addressee.uid().local8Bit()); - - QString hash = calc_hash(addressee); - osync_change_set_hash(chg, hash); - osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY ADDED (UID=%s)", (const char *)addressee.uid().local8Bit()); - - break; - } - - case CHANGE_DELETED: - { - if (uid.isEmpty()) - { - osync_context_report_error(ctx, OSYNC_ERROR_FILE_NOT_FOUND, "Trying to delete entry with empty UID"); - return -1; - } - - //find addressbook entry with matching UID and delete it - KABC::Addressee addressee = addressbookptr->findByUid(uid); - if(!addressee.isEmpty()) - addressbookptr->removeAddressee(addressee); - - osync_debug("kde", 3, "KDE ADDRESSBOOK ENTRY DELETED (UID=%s)", (const char*)uid.local8Bit()); - - break; - } - default: - osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Operation not supported"); - return -1; - } - - return 0; - } - virtual bool vcard_access(OSyncContext *ctx, OSyncChange *chg) { if (__vcard_access(ctx, chg) < 0) Added: branches/experimental-kdepim/src/knotes-test.cpp =================================================================== --- branches/experimental-kdepim/src/knotes-test.cpp 2005-04-04 15:26:13 UTC (rev 434) +++ branches/experimental-kdepim/src/knotes-test.cpp 2005-04-04 15:28:27 UTC (rev 435) @@ -0,0 +1,84 @@ +#include "KNotesIface.h" +#include "KNotesIface_stub.h" +#include <stdio.h> +#include <qmap.h> +#include <qtimer.h> + +#include <kapplication.h> + +#include <dcopclient.h> +#include <qstring.h> +#include <qstringlist.h> + +typedef QString KNoteID_t; + +bool isRunning(const QCString &n) +{ + DCOPClient *dcop = KApplication::kApplication()->dcopClient(); + + if (!dcop->attach()) + printf("nix is\n"); + QCStringList apps = dcop->registeredApplications(); + + QStringList lst; + printf("asd %i, %s", lst.count(), (const char*)lst.join("\n").local8Bit()); + return apps.contains(n); +} + + +int main(void) +{ + printf("test \n"); + + QMap <KNoteID_t,QString> fNotes; + + + /*DCOPClient *fdp = new DCOPClient; + fdp = KApplication::kApplication()->dcopClient(); + + if (!fdp) { + printf("No DCOP connection could be made. The conduit cannot function without DCOP.\n"); + return 1; + }*/ + + QCString knotesAppname = "knotes" ; + if (!isRunning(knotesAppname)) { + knotesAppname = "kontact" ; + if (!isRunning(knotesAppname)) { + printf("KNotes is not running.\n"); + return 1; + } + } + + KNotesIface_stub *fKNotes = new KNotesIface_stub(knotesAppname,"KNotesIface"); + + + fNotes = fKNotes->notes(); + if (fKNotes->status() != DCOPStub::CallSucceeded) + { + printf("Could not retrieve list of notes from KNotes.\n"); + return 1; + +} + + QMap<KNoteID_t,QString>::ConstIterator i = fNotes.begin(); + while (i != fNotes.end()) + { + printf("%s -> %s %s\n", (const char*)i.key().local8Bit(), (const char*)i.data().local8Bit(), (fKNotes->isNew("opensync",i.key())) ? " (new)" : ""); + i++; + } + + QString id = fKNotes->newNote("test1", "test2"); + if (fKNotes->status() != DCOPStub::CallSucceeded) { + printf("Could not add note to KNotes.\n"); + return 1; + } + + fKNotes->hideNote(id); + if (fKNotes->status() != DCOPStub::CallSucceeded) { + printf("Could not hide note to KNotes.\n"); + return 1; + } + + return 0; +} Modified: branches/experimental-kdepim/src/knotes.cpp =================================================================== --- branches/experimental-kdepim/src/knotes.cpp 2005-04-04 15:26:13 UTC (rev 434) +++ branches/experimental-kdepim/src/knotes.cpp 2005-04-04 15:28:27 UTC (rev 435) @@ -30,25 +30,10 @@ * (http://www.opensync.org/ticket/34) */ -#include <libkcal/calendarlocal.h> -#include <libkcal/icalformat.h> -#include <kglobal.h> -#include <kstandarddirs.h> -#include <kio/netaccess.h> -#include <klocale.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - #include "knotes.h" -extern "C" -{ -#include <opensync/opensync-xml.h> -} KNotesDataSource::KNotesDataSource(OSyncMember *m, OSyncHashTable *h) :member(m), hashtable(h) @@ -57,6 +42,11 @@ bool KNotesDataSource::connect(OSyncContext *ctx) { + //connect to dcop + //check knotes running + //start knotes if not running + + // Terminate knotes because we will change its data // Yes, it is _very_ ugly //FIXME: use dcop programming interface, not the commandline utility @@ -71,7 +61,10 @@ osync_context_report_error(ctx, OSYNC_ERROR_INITIALIZATION, "Couldn't allocate calendar object"); return false; } - if (!calendar->load(KGlobal::dirs()->saveLocation( "data" , "knotes/" ) + "notes.ics")) { + + QString notes_loc = KGlobal::dirs()->saveLocation( "data" , "knotes/" ) + "notes.ics"; + + if (!calendar->load(notes_loc)) { osync_context_report_error(ctx, OSYNC_ERROR_FILE_NOT_FOUND, "Couldn't load notes"); return false; } @@ -79,71 +72,6 @@ return true; } -/** Quick hack to avoid using KIO::NetAccess (that needs a KApplication instance */ -static bool copy_file(const char *from, const char *to) -{ - int f1 = open(from, O_RDONLY); - if (f1 < 0) - return false; - int f2 = open(to, O_WRONLY); - if (f2 < 0) { - close(f1); - return false; - } - - char buf[1024]; - int ret; - bool result = true; - for (;;) { - ret = read(f1, buf, 1024); - if (ret == 0) - break; - if (ret < 0) { - if (errno == EINTR) - continue; - result = false; - break; - } - int wret = write(f2, buf, ret); - if (wret < ret) { - result = false; - break; - } - } - close(f1); - close(f2); - return result; -} - -bool KNotesDataSource::saveNotes(OSyncContext *ctx) -{ - // shamelessly copied from KNotes source code - QString file = KGlobal::dirs()->saveLocation( "data" , "knotes/" ) + "notes.ics"; - QString backup = file + "~"; - - // if the backup fails don't even try to save the current notes - // (might just destroy the file that's already there) - - if ( !copy_file(file, backup) ) - { - osync_context_report_error(ctx, OSYNC_ERROR_IO_ERROR, - i18n("Unable to save the notes backup to " - "%1! Check that there is sufficient " - "disk space!").arg( backup ) ); - return false; - } - else if ( !calendar->save( file, new KCal::ICalFormat() ) ) - { - osync_context_report_error(ctx, OSYNC_ERROR_IO_ERROR, - i18n("Unable to save the notes to %1! " - "Check that there is sufficient disk space." - "There should be a backup in %2 " - "though.").arg( file ).arg( backup ) ); - return false; - } - return true; -} - bool KNotesDataSource::disconnect(OSyncContext *ctx) { if (!saveNotes(ctx)) @@ -158,15 +86,6 @@ return true; } -static QString calc_hash(const KCal::Journal *note) -{ - QDateTime d = note->lastModified(); - if (!d.isValid()) - d = QDateTime::currentDateTime(); - /*FIXME: not i18ned string */ - return d.toString(); -} - bool KNotesDataSource::get_changeinfo(OSyncContext *ctx) { KCal::Journal::List notes = calendar->journals(); @@ -227,13 +146,8 @@ return true; } -void KNotesDataSource::get_data(OSyncContext *ctx, OSyncChange *) +bool KNotesDataSource::access(OSyncContext *ctx, OSyncChange *chg) { - osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Not implemented yet"); -} - -bool KNotesDataSource::__access(OSyncContext *ctx, OSyncChange *chg) -{ OSyncChangeType type = osync_change_get_changetype(chg); QString uid = osync_change_get_uid(chg); @@ -288,23 +202,14 @@ } } - return true; -} - -bool KNotesDataSource::access(OSyncContext *ctx, OSyncChange *chg) -{ - if (!__access(ctx, chg)) - return false; - osync_context_report_success(ctx); return true; } bool KNotesDataSource::commit_change(OSyncContext *ctx, OSyncChange *chg) { - if (!__access(ctx, chg)) + if (!access(ctx, chg)) return false; osync_hashtable_update_hash(hashtable, chg); - osync_context_report_success(ctx); return true; } Modified: branches/experimental-kdepim/src/knotes.h =================================================================== --- branches/experimental-kdepim/src/knotes.h 2005-04-04 15:26:13 UTC (rev 434) +++ branches/experimental-kdepim/src/knotes.h 2005-04-04 15:28:27 UTC (rev 435) @@ -1,6 +1,7 @@ /*********************************************************************** KNotes OSyncDataSource class Copyright (C) 2004 Conectiva S. A. +Copyright (C) 2005 Armin Bauer This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as @@ -21,10 +22,23 @@ *************************************************************************/ /** * @autor Eduardo Pereira Habkost <eha...@co...> + * @autor Armin Bauer <arm...@op...> */ -extern "C" { +#include <kglobal.h> +#include <kstandarddirs.h> +#include <kio/netaccess.h> +#include <klocale.h> + +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +extern "C" +{ #include <opensync/opensync.h> +#include <opensync/opensync-xml.h> } // Forward declaration |
From: <svn...@op...> - 2005-04-04 15:24:56
|
Author: abauer Date: 2005-04-04 17:26:13 +0200 (Mon, 04 Apr 2005) New Revision: 434 Added: branches/experimental-kdepim/ Log: Created a branch of the kdepim plugin Copied: branches/experimental-kdepim (from rev 429, plugins/kdepim) |
From: <svn...@op...> - 2005-04-04 15:21:33
|
Author: abauer Date: 2005-04-04 17:22:50 +0200 (Mon, 04 Apr 2005) New Revision: 433 Added: branches/experimental-branch/ Log: Recreated the experimental branch correctly this time Copied: branches/experimental-branch (from rev 429, trunk) |
From: <svn...@op...> - 2005-04-04 15:19:04
|
Author: abauer Date: 2005-04-04 17:20:20 +0200 (Mon, 04 Apr 2005) New Revision: 432 Removed: branches/experimental-branch/ Log: Removed experiemtal branch (created it from the wrong trunk) |
From: <svn...@op...> - 2005-04-04 15:15:53
|
Author: abauer Date: 2005-04-04 17:17:03 +0200 (Mon, 04 Apr 2005) New Revision: 431 Added: branches/experimental-branch/ branches/experimental-branch/opensync/opensync_changecmds.c branches/experimental-branch/opensync/opensync_changecmds.h branches/experimental-branch/opensync/opensync_convert.c branches/experimental-branch/opensync/opensync_error.c branches/experimental-branch/opensync/opensync_error.h branches/experimental-branch/opensync/opensync_format_internals.h branches/experimental-branch/opensync/opensync_member.c branches/experimental-branch/opensync/opensync_member.h branches/experimental-branch/opensync/opensync_plugin.c branches/experimental-branch/opensync/opensync_plugin.h branches/experimental-branch/tests/Makefile.am branches/experimental-branch/tests/check_plugins.c branches/experimental-branch/tests/data/plugin_no_config/ branches/experimental-branch/tests/mock-plugin/mock_sync.c Removed: branches/experimental-branch/opensync/opensync_changecmds.c branches/experimental-branch/opensync/opensync_changecmds.h branches/experimental-branch/opensync/opensync_convert.c branches/experimental-branch/opensync/opensync_error.c branches/experimental-branch/opensync/opensync_error.h branches/experimental-branch/opensync/opensync_format_internals.h branches/experimental-branch/opensync/opensync_member.c branches/experimental-branch/opensync/opensync_member.h branches/experimental-branch/opensync/opensync_plugin.c branches/experimental-branch/opensync/opensync_plugin.h branches/experimental-branch/tests/Makefile.am branches/experimental-branch/tests/check_plugins.c branches/experimental-branch/tests/mock-plugin/mock_sync.c Log: Recreated the experimental branch Copied: branches/experimental-branch (from rev 423, trunk) Deleted: branches/experimental-branch/opensync/opensync_changecmds.c Copied: branches/experimental-branch/opensync/opensync_changecmds.c (from rev 425, trunk/opensync/opensync_changecmds.c) Deleted: branches/experimental-branch/opensync/opensync_changecmds.h Copied: branches/experimental-branch/opensync/opensync_changecmds.h (from rev 425, trunk/opensync/opensync_changecmds.h) Deleted: branches/experimental-branch/opensync/opensync_convert.c Copied: branches/experimental-branch/opensync/opensync_convert.c (from rev 425, trunk/opensync/opensync_convert.c) Deleted: branches/experimental-branch/opensync/opensync_error.c Copied: branches/experimental-branch/opensync/opensync_error.c (from rev 429, trunk/opensync/opensync_error.c) Deleted: branches/experimental-branch/opensync/opensync_error.h Copied: branches/experimental-branch/opensync/opensync_error.h (from rev 429, trunk/opensync/opensync_error.h) Deleted: branches/experimental-branch/opensync/opensync_format_internals.h Copied: branches/experimental-branch/opensync/opensync_format_internals.h (from rev 425, trunk/opensync/opensync_format_internals.h) Deleted: branches/experimental-branch/opensync/opensync_member.c Copied: branches/experimental-branch/opensync/opensync_member.c (from rev 429, trunk/opensync/opensync_member.c) Deleted: branches/experimental-branch/opensync/opensync_member.h Copied: branches/experimental-branch/opensync/opensync_member.h (from rev 429, trunk/opensync/opensync_member.h) Deleted: branches/experimental-branch/opensync/opensync_plugin.c Copied: branches/experimental-branch/opensync/opensync_plugin.c (from rev 429, trunk/opensync/opensync_plugin.c) Deleted: branches/experimental-branch/opensync/opensync_plugin.h Copied: branches/experimental-branch/opensync/opensync_plugin.h (from rev 429, trunk/opensync/opensync_plugin.h) Deleted: branches/experimental-branch/tests/Makefile.am Copied: branches/experimental-branch/tests/Makefile.am (from rev 429, trunk/tests/Makefile.am) Deleted: branches/experimental-branch/tests/check_plugins.c Copied: branches/experimental-branch/tests/check_plugins.c (from rev 429, trunk/tests/check_plugins.c) Copied: branches/experimental-branch/tests/data/plugin_no_config (from rev 429, trunk/tests/data/plugin_no_config) Deleted: branches/experimental-branch/tests/mock-plugin/mock_sync.c Copied: branches/experimental-branch/tests/mock-plugin/mock_sync.c (from rev 429, trunk/tests/mock-plugin/mock_sync.c) |
From: <svn...@op...> - 2005-04-04 15:13:53
|
Author: abauer Date: 2005-04-04 17:15:11 +0200 (Mon, 04 Apr 2005) New Revision: 430 Removed: branches/experimental-branch/ Log: Removed the experimental branch |
From: <svn...@op...> - 2005-03-31 15:50:31
|
Author: abauer Date: 2005-03-31 17:51:35 +0200 (Thu, 31 Mar 2005) New Revision: 115 Modified: trunk/tools/msynctool.c Log: Made the msynctool use the new get_config_or_default function as well Modified: trunk/tools/msynctool.c =================================================================== --- trunk/tools/msynctool.c 2005-03-31 15:03:31 UTC (rev 114) +++ trunk/tools/msynctool.c 2005-03-31 15:51:35 UTC (rev 115) @@ -350,7 +350,7 @@ } OSyncMember *member = osync_member_from_id(group, id); - if (!osync_member_get_config(member, &data, &size, &error)) { + if (!osync_member_get_config_or_default(member, &data, &size, &error)) { printf("Unable to get configdata for member %s: %s\n", memberid, osync_error_print(&error)); osync_error_free(&error); return; |
From: <svn...@op...> - 2005-03-31 15:19:44
|
Author: abauer Date: 2005-03-31 17:20:47 +0200 (Thu, 31 Mar 2005) New Revision: 429 Added: trunk/tests/data/plugin_no_config/ trunk/tests/data/plugin_no_config/configs/ trunk/tests/data/plugin_no_config/configs/group/ trunk/tests/data/plugin_no_config/configs/group/1/ trunk/tests/data/plugin_no_config/configs/group/1/syncmember.conf trunk/tests/data/plugin_no_config/configs/group/2/ trunk/tests/data/plugin_no_config/configs/group/2/file-sync.conf trunk/tests/data/plugin_no_config/configs/group/2/syncmember.conf trunk/tests/data/plugin_no_config/configs/group/syncgroup.conf Modified: trunk/opensync/opensync_error.c trunk/opensync/opensync_error.h trunk/opensync/opensync_member.c trunk/opensync/opensync_member.h trunk/opensync/opensync_plugin.c trunk/opensync/opensync_plugin.h trunk/tests/Makefile.am trunk/tests/check_plugins.c trunk/tests/mock-plugin/mock_sync.c Log: The plugins can now specify 3 types of configurations: No configuration Optional configuration Needs configuration (default) Added a unit tests to see what happens if a client that need configuration has not been configured Modified: trunk/opensync/opensync_error.c =================================================================== --- trunk/opensync/opensync_error.c 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/opensync/opensync_error.c 2005-03-31 15:20:47 UTC (rev 429) @@ -240,4 +240,19 @@ va_end (args); } +/*! @brief Sets the type of an error + * + * @param error A pointer to a error struct to set + * @param type The Error type to set + * + */ +void osync_error_set_type(OSyncError **error, OSyncErrorType type) +{ + if (!error) + return; + + (*error)->type = type; + return; +} + /*@}*/ Modified: trunk/opensync/opensync_error.h =================================================================== --- trunk/opensync/opensync_error.h 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/opensync/opensync_error.h 2005-03-31 15:20:47 UTC (rev 429) @@ -30,3 +30,4 @@ void osync_error_duplicate(OSyncError **target, OSyncError **source); const char *osync_error_print(OSyncError **error); OSyncErrorType osync_error_get_type(OSyncError **error); +void osync_error_set_type(OSyncError **error, OSyncErrorType type); Modified: trunk/opensync/opensync_member.c =================================================================== --- trunk/opensync/opensync_member.c 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/opensync/opensync_member.c 2005-03-31 15:20:47 UTC (rev 429) @@ -47,6 +47,36 @@ return osync_group_get_format_env(member->group); } +OSyncObjTypeSink *osync_member_find_objtype_sink(OSyncMember *member, const char *objtypestr) +{ + GList *o; + for (o = member->objtype_sinks; o; o = o->next) { + OSyncObjTypeSink *sink = o->data; + if (osync_conv_objtype_is_any(sink->objtype->name) || !strcmp(sink->objtype->name, objtypestr)) + return sink; + } + return NULL; +} + +/** @brief Reads the configuration data of this member + * + * The config file is read in this order: + * - If there is a configuration in memory that is not yet saved + * this is returned + * - If there is a config file in the member directory this is read + * and returned + * + * The difference to get_config is that this function will never try to read + * the default config file and return an error instead. So this function is supposed + * to be used by the plugins. + * + * @param member The member + * @param data Return location for the data + * @param size Return location for the size of the data + * @param error Pointer to a error + * @returns TRUE if the config was loaded successfully, FALSE otherwise + * + */ osync_bool osync_member_read_config(OSyncMember *member, char **data, int *size, OSyncError **error) { osync_trace(TRACE_ENTRY, "osync_member_read_config(%p, %p, %p, %p)", member, data, size, error); @@ -78,17 +108,6 @@ return ret; } -OSyncObjTypeSink *osync_member_find_objtype_sink(OSyncMember *member, const char *objtypestr) -{ - GList *o; - for (o = member->objtype_sinks; o; o = o->next) { - OSyncObjTypeSink *sink = o->data; - if (osync_conv_objtype_is_any(sink->objtype->name) || !strcmp(sink->objtype->name, objtypestr)) - return sink; - } - return NULL; -} - #endif /*@}*/ @@ -322,6 +341,14 @@ /** @brief Gets the configuration data of this member * + * The config file is read in this order: + * - If there is a configuration in memory that is not yet saved + * this is returned + * - If there is a config file in the member directory this is read + * and returned + * - Otherwise the default config file is loaded from one the opensync + * directories + * * @param member The member * @param data Return location for the data * @param size Return location for the size of the data @@ -329,12 +356,64 @@ * @returns TRUE if the config was loaded successfully, FALSE otherwise * */ +osync_bool osync_member_get_config_or_default(OSyncMember *member, char **data, int *size, OSyncError **error) +{ + osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, member, data, size, error); + g_assert(member); + osync_bool ret = TRUE; + + if (member->configdata) { + *data = member->configdata; + *size = member->configsize; + osync_trace(TRACE_EXIT, "%s: Configdata already in memory", __func__); + return TRUE; + } + + if (!osync_member_read_config(member, data, size, error)) { + if (osync_error_is_set(error)) { + osync_trace(TRACE_INTERNAL, "Read config not successfull: %s", osync_error_print(error)); + osync_error_free(error); + } + + char *filename = g_strdup_printf(OPENSYNC_CONFIGDIR"/%s", member->pluginname); + osync_debug("OSMEM", 3, "Reading default2 config file for member %lli from %s", member->id, filename); + ret = osync_file_read(filename, data, size, error); + g_free(filename); + } + osync_trace(TRACE_EXIT, "%s: %i", __func__, ret); + return ret; +} + +/** @brief Gets the configuration data of this member + * + * The config file is read in this order: + * - If there is a configuration in memory that is not yet saved + * this is returned + * - If there is a config file in the member directory this is read + * and returned + * - Otherwise the default config file is loaded from one the opensync + * directories (but only if the plugin specified that it can use the default + * configuration) + * + * @param member The member + * @param data Return location for the data + * @param size Return location for the size of the data + * @param error Pointer to a error + * @returns TRUE if the config was loaded successfully, FALSE otherwise + * + */ osync_bool osync_member_get_config(OSyncMember *member, char **data, int *size, OSyncError **error) { osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, member, data, size, error); g_assert(member); osync_bool ret = TRUE; + if (member->plugin->info.config_type == NO_CONFIGURATION) { + osync_error_set(error, OSYNC_ERROR_GENERIC, "This member has no configuration options"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; + } + if (member->configdata) { *data = member->configdata; *size = member->configsize; @@ -348,6 +427,13 @@ osync_error_free(error); } + if (member->plugin->info.config_type == NEEDS_CONFIGURATION) { + //We dont load the default config for these + osync_error_set(error, OSYNC_ERROR_MISCONFIGURATION, "Member has not been configured"); + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); + return FALSE; + } + char *filename = g_strdup_printf(OPENSYNC_CONFIGDIR"/%s", member->pluginname); osync_debug("OSMEM", 3, "Reading default2 config file for member %lli from %s", member->id, filename); ret = osync_file_read(filename, data, size, error); @@ -385,9 +471,12 @@ osync_bool osync_member_has_configuration(OSyncMember *member) { osync_trace(TRACE_ENTRY, "%s(%p)", __func__, member); - g_assert(member); - osync_trace(TRACE_EXIT, "%s: %i", __func__, member->plugin->info.has_configuration); - return member->plugin->info.has_configuration; + g_assert(member); + + osync_bool ret = (member->plugin->info.config_type == NEEDS_CONFIGURATION || member->plugin->info.config_type == OPTIONAL_CONFIGURATION); + + osync_trace(TRACE_EXIT, "%s: %i", __func__, ret); + return ret; } /** @brief Loads a member from a directory where it has been saved Modified: trunk/opensync/opensync_member.h =================================================================== --- trunk/opensync/opensync_member.h 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/opensync/opensync_member.h 2005-03-31 15:20:47 UTC (rev 429) @@ -21,6 +21,8 @@ const char *osync_member_get_configdir(OSyncMember *member); osync_bool osync_member_get_config(OSyncMember *member, char **data, int *size, OSyncError **error); +osync_bool osync_member_get_config_or_default(OSyncMember *member, char **data, int *size, OSyncError **error); + void osync_member_set_config(OSyncMember *member, const char *data, int size); osync_bool osync_member_has_configuration(OSyncMember *member); const char *osync_member_get_pluginname(OSyncMember *member); Modified: trunk/opensync/opensync_plugin.c =================================================================== --- trunk/opensync/opensync_plugin.c 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/opensync/opensync_plugin.c 2005-03-31 15:20:47 UTC (rev 429) @@ -134,7 +134,7 @@ plugin->info.timeouts.read_change_timeout = 60; plugin->info.plugin = plugin; - plugin->info.has_configuration = TRUE; + plugin->info.config_type = NEEDS_CONFIGURATION; if (env) { env->plugins = g_list_append(env->plugins, plugin); Modified: trunk/opensync/opensync_plugin.h =================================================================== --- trunk/opensync/opensync_plugin.h 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/opensync/opensync_plugin.h 2005-03-31 15:20:47 UTC (rev 429) @@ -66,6 +66,20 @@ void (* read) (OSyncContext *, OSyncChange *); } OSyncFormatFunctions; +/*! @brief Gives information about wether the plugin + * has to be configured or not + * + * @ingroup OSyncPluginAPI + **/ +typedef enum { + /** Plugin has no configuration options */ + NO_CONFIGURATION = 0, + /** Plugin can be configured, but will accept the default config in the initialize function */ + OPTIONAL_CONFIGURATION = 1, + /** Plugin must be configured to run correctly */ + NEEDS_CONFIGURATION = 2 +} OSyncConfigurationTypes; + /*! @brief Gives information about a plugin * @ingroup OSyncPluginAPI **/ @@ -85,7 +99,7 @@ /** The timeouts of your plugin */ OSyncPluginTimeouts timeouts; /** Does the plugin have configuration options? */ - osync_bool has_configuration; + OSyncConfigurationTypes config_type; /** The pointer to the plugin (for internal use) */ OSyncPlugin *plugin; } OSyncPluginInfo; Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/tests/Makefile.am 2005-03-31 15:20:47 UTC (rev 429) @@ -17,8 +17,8 @@ endif if ENABLE_TESTS -TESTS = error user member locks env conv sync filter multisync vcard vcal errorcodes $(PROFTEST) -noinst_PROGRAMS = error user member locks env conv sync filter multisync vcard vcal errorcodes +TESTS = error user member plugin locks env conv sync filter multisync vcard vcal errorcodes $(PROFTEST) +noinst_PROGRAMS = error user member plugin locks env conv sync filter multisync vcard vcal errorcodes else TESTS = noinst_PROGRAMS = @@ -34,6 +34,12 @@ member_LIBS = @CHECK_LIBS@ member_LDFLAGS = @PACKAGE_LIBS@ $(top_builddir)/opensync/libopensync.la -lcheck -R $(libdir) @GCOV_LDFLAGS@ +plugin_INCLUDES = @CHECK_CFLAGS@ +plugin_SOURCES = check_plugins.c support.c +plugin_LIBS = @CHECK_LIBS@ +plugin_LDFLAGS = @PACKAGE_LIBS@ $(top_builddir)/opensync/libopensync.la $(top_builddir)/osengine/libosengine.la -lcheck -R $(libdir) @GCOV_LDFLAGS@ + + locks_INCLUDES = @CHECK_CFLAGS@ locks_SOURCES = check_lock.c support.c locks_LIBS = @CHECK_LIBS@ Modified: trunk/tests/check_plugins.c =================================================================== --- trunk/tests/check_plugins.c 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/tests/check_plugins.c 2005-03-31 15:20:47 UTC (rev 429) @@ -1,11 +1,57 @@ -#include <check.h> -#include <opensync/opensync.h> -#include <opensync/opensync_internals.h> -#include <stdlib.h> +#include "support.h" START_TEST (plugin_create) { - OSyncPluginInfo *plugin = osync_plugin_new(); + OSyncPlugin *plugin = osync_plugin_new(NULL); fail_unless(plugin != NULL, "plugin == NULL on creation"); } -END_TEST \ No newline at end of file +END_TEST + +START_TEST (plugin_no_config) +{ + char *testbed = setup_testbed("plugin_no_config"); + OSyncEnv *osync = init_env(); + fail_unless(osync != NULL, NULL); + + OSyncGroup *group = osync_group_load(osync, "configs/group", NULL); + fail_unless(group != NULL, NULL); + fail_unless(osync_env_num_groups(osync) == 1, NULL); + + OSyncError *error = NULL; + OSyncEngine *engine = osengine_new(group, &error); + fail_unless(engine != NULL, NULL); + fail_unless(!osengine_init(engine, &error), NULL); + + osengine_finalize(engine); + osengine_free(engine); + + fail_unless(osync_env_finalize(osync, NULL), NULL); + osync_env_free(osync); + destroy_testbed(testbed); +} +END_TEST + +Suite *plugin_suite(void) +{ + Suite *s = suite_create("Plugins"); + //Suite *s2 = suite_create("Plugins"); + + create_case(s, "plugin_create", plugin_create); + create_case(s, "plugin_no_config", plugin_no_config); + + return s; +} + +int main(void) +{ + int nf; + + Suite *s = plugin_suite(); + + SRunner *sr; + sr = srunner_create(s); + srunner_run_all(sr, CK_NORMAL); + nf = srunner_ntests_failed(sr); + srunner_free(sr); + return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} Added: trunk/tests/data/plugin_no_config/configs/group/1/syncmember.conf =================================================================== --- trunk/tests/data/plugin_no_config/configs/group/1/syncmember.conf 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/tests/data/plugin_no_config/configs/group/1/syncmember.conf 2005-03-31 15:20:47 UTC (rev 429) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<syncmember><pluginname>file-sync</pluginname></syncmember> Property changes on: trunk/tests/data/plugin_no_config/configs/group/1/syncmember.conf ___________________________________________________________________ Name: svn:executable + * Added: trunk/tests/data/plugin_no_config/configs/group/2/file-sync.conf =================================================================== --- trunk/tests/data/plugin_no_config/configs/group/2/file-sync.conf 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/tests/data/plugin_no_config/configs/group/2/file-sync.conf 2005-03-31 15:20:47 UTC (rev 429) @@ -0,0 +1 @@ +<config><path>data2</path><recursive>FALSE</recursive></config> Property changes on: trunk/tests/data/plugin_no_config/configs/group/2/file-sync.conf ___________________________________________________________________ Name: svn:executable + * Added: trunk/tests/data/plugin_no_config/configs/group/2/syncmember.conf =================================================================== --- trunk/tests/data/plugin_no_config/configs/group/2/syncmember.conf 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/tests/data/plugin_no_config/configs/group/2/syncmember.conf 2005-03-31 15:20:47 UTC (rev 429) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<syncmember><pluginname>file-sync</pluginname></syncmember> Property changes on: trunk/tests/data/plugin_no_config/configs/group/2/syncmember.conf ___________________________________________________________________ Name: svn:executable + * Added: trunk/tests/data/plugin_no_config/configs/group/syncgroup.conf =================================================================== --- trunk/tests/data/plugin_no_config/configs/group/syncgroup.conf 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/tests/data/plugin_no_config/configs/group/syncgroup.conf 2005-03-31 15:20:47 UTC (rev 429) @@ -0,0 +1,2 @@ +<?xml version="1.0"?> +<syncgroup><groupname>test</groupname></syncgroup> Property changes on: trunk/tests/data/plugin_no_config/configs/group/syncgroup.conf ___________________________________________________________________ Name: svn:executable + * Modified: trunk/tests/mock-plugin/mock_sync.c =================================================================== --- trunk/tests/mock-plugin/mock_sync.c 2005-03-31 15:04:24 UTC (rev 428) +++ trunk/tests/mock-plugin/mock_sync.c 2005-03-31 15:20:47 UTC (rev 429) @@ -448,7 +448,7 @@ info->longname = "Mock Plugin"; info->description = "Mock Plugin"; info->version = 1; - + info->functions.initialize = mock_initialize; info->functions.connect = mock_connect; info->functions.sync_done = mock_sync_done; |
From: <svn...@op...> - 2005-03-31 15:03:21
|
Author: abauer Date: 2005-03-31 17:04:24 +0200 (Thu, 31 Mar 2005) New Revision: 428 Modified: plugins/kdepim/src/kdepim_sync.cpp Log: Changed the default configuration type of the kdepim plugin to NO_CONFIGURATION Modified: plugins/kdepim/src/kdepim_sync.cpp =================================================================== --- plugins/kdepim/src/kdepim_sync.cpp 2005-03-31 14:04:12 UTC (rev 427) +++ plugins/kdepim/src/kdepim_sync.cpp 2005-03-31 15:04:24 UTC (rev 428) @@ -189,7 +189,7 @@ info->name = "kdepim"; /*FIXME: i18n */ info->description = "Plugin for the KDEPIM on KDE 3.x"; - info->has_configuration = FALSE; + info->config_type = NO_CONFIGURATION; info->functions.initialize = kde_initialize; info->functions.connect = kde_connect; |