00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "FileSyncSource.h"
00020
00021 static EvolutionSyncSource *createSource(const EvolutionSyncSourceParams ¶ms)
00022 {
00023 pair <string, string> sourceType = EvolutionSyncSource::getSourceType(params.m_nodes);
00024
00025
00026 bool isMe = sourceType.first == "Files in one directory";
00027
00028 #ifndef ENABLE_FILE
00029
00030
00031 return isMe ? RegisterSyncSource::InactiveSource : NULL;
00032 #else
00033
00034
00035 bool maybeMe = false ;
00036
00037 if (isMe || maybeMe) {
00038
00039
00040 if (
00041 sourceType.second.size()) {
00042 return new FileSyncSource(params, sourceType.second);
00043 } else {
00044 return NULL;
00045 }
00046 }
00047 return NULL;
00048 #endif
00049 }
00050
00051 static RegisterSyncSource registerMe("Files in one directory",
00052 #ifdef ENABLE_FILE
00053 true,
00054 #else
00055 false,
00056 #endif
00057 createSource,
00058 "Files in one directory = file\n"
00059 " Stores items in one directory as one file per item.\n"
00060 " The directory is selected via [file://]<path>; it\n"
00061 " will only be created if the prefix is given, otherwise\n"
00062 " it must exist already. Only items of the same type can\n"
00063 " be synchronized and this type must be specified explicitly\n"
00064 " with both mime type and version.\n"
00065 " Examples:\n"
00066 " file:text/plain:1.0\n"
00067 " file:text/x-vcard:2.1\n"
00068 " file:text/vcard:3.0\n"
00069 " file:text/x-calendar:1.0\n"
00070 " file:text/calendar:2.0\n",
00071 Values() +
00072 (Aliases("Files in one directory") + "file"));
00073
00074 #ifdef ENABLE_FILE
00075 #ifdef ENABLE_UNIT_TESTS
00076
00077 class FileSyncSourceUnitTest : public CppUnit::TestFixture {
00078 CPPUNIT_TEST_SUITE(FileSyncSourceUnitTest);
00079 CPPUNIT_TEST(testInstantiate);
00080 CPPUNIT_TEST_SUITE_END();
00081
00082 protected:
00083 void testInstantiate() {
00084 boost::shared_ptr<EvolutionSyncSource> source;
00085 source.reset(EvolutionSyncSource::createTestingSource("file", "file:text/vcard:3.0", true));
00086 source.reset(EvolutionSyncSource::createTestingSource("file", "file:text/plain:1.0", true));
00087 source.reset(EvolutionSyncSource::createTestingSource("file", "Files in one directory:text/x-vcard:2.1", true));
00088 }
00089 };
00090
00091 SYNCEVOLUTION_TEST_SUITE_REGISTRATION(FileSyncSourceUnitTest);
00092
00093 #endif // ENABLE_UNIT_TESTS
00094
00095 #ifdef ENABLE_INTEGRATION_TESTS
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 namespace {
00109 #if 0
00110 }
00111 #endif
00112
00113 static class VCard21Test : public RegisterSyncSourceTest {
00114 public:
00115 VCard21Test() : RegisterSyncSourceTest("file_vcard21", "vcard21") {}
00116
00117 virtual void updateConfig(ClientTestConfig &config) const
00118 {
00119
00120
00121 config.type = "file:text/x-vcard:2.1";
00122 }
00123 } VCard21Test;
00124
00125 static class VCard30Test : public RegisterSyncSourceTest {
00126 public:
00127 VCard30Test() : RegisterSyncSourceTest("file_vcard30", "vcard30") {}
00128
00129 virtual void updateConfig(ClientTestConfig &config) const
00130 {
00131 config.type = "file:text/vcard:3.0";
00132 }
00133 } VCard30Test;
00134
00135 static class ICal20Test : public RegisterSyncSourceTest {
00136 public:
00137 ICal20Test() : RegisterSyncSourceTest("file_ical20", "ical20") {}
00138
00139 virtual void updateConfig(ClientTestConfig &config) const
00140 {
00141 config.type = "file:text/calendar:2.0";
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 config.sourceKnowsItemSemantic = false;
00154 }
00155 } ICal20Test;
00156
00157 static class ITodo20Test : public RegisterSyncSourceTest {
00158 public:
00159 ITodo20Test() : RegisterSyncSourceTest("file_itodo20", "itodo20") {}
00160
00161 virtual void updateConfig(ClientTestConfig &config) const
00162 {
00163 config.type = "file:text/calendar:2.0";
00164 }
00165 } ITodo20Test;
00166
00167 }
00168 #endif // ENABLE_INTEGRATION_TESTS
00169
00170 #endif // ENABLE_FILE