00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "SQLiteContactSource.h"
00020 #include "SyncEvolutionUtil.h"
00021
00022 static EvolutionSyncSource *createSource(const EvolutionSyncSourceParams ¶ms)
00023 {
00024 pair <string, string> sourceType = EvolutionSyncSource::getSourceType(params.m_nodes);
00025 bool isMe = sourceType.first == "SQLite Address Book";
00026
00027 #ifndef ENABLE_SQLITE
00028 return isMe ? RegisterSyncSource::InactiveSource : NULL;
00029 #else
00030 bool maybeMe = sourceType.first == "addressbook";
00031
00032 if (isMe || maybeMe) {
00033 if (sourceType.second == "" || sourceType.second == "text/x-vcard") {
00034 return new SQLiteContactSource(params);
00035 } else {
00036 return NULL;
00037 }
00038 }
00039 return NULL;
00040 #endif
00041 }
00042
00043 static RegisterSyncSource registerMe("SQLite Address Book",
00044 #ifdef ENABLE_SQLITE
00045 true,
00046 #else
00047 false,
00048 #endif
00049 createSource,
00050 "SQLite Address Book = addressbook = contacts = sqlite-contacts\n"
00051 " vCard 2.1 (default) = text/x-vcard\n",
00052 Values() +
00053 (Aliases("SQLite Address Book") + "sqlite-contacts" + "sqlite"));
00054
00055 #ifdef ENABLE_SQLITE
00056 #ifdef ENABLE_UNIT_TESTS
00057
00058 class EvolutionSQLiteContactsTest : public CppUnit::TestFixture {
00059 CPPUNIT_TEST_SUITE(EvolutionSQLiteContactsTest);
00060 CPPUNIT_TEST(testInstantiate);
00061 CPPUNIT_TEST_SUITE_END();
00062
00063 protected:
00064 void testInstantiate() {
00065 boost::shared_ptr<EvolutionSyncSource> source;
00066 source.reset(EvolutionSyncSource::createTestingSource("contacts", "contacts", true));
00067 source.reset(EvolutionSyncSource::createTestingSource("contacts", "addressbook", true));
00068 source.reset(EvolutionSyncSource::createTestingSource("contacts", "sqlite-contacts", true));
00069 source.reset(EvolutionSyncSource::createTestingSource("contacts", "SQLite Address Book:text/x-vcard", true));
00070 }
00071 };
00072
00073 SYNCEVOLUTION_TEST_SUITE_REGISTRATION(EvolutionSQLiteContactsTest);
00074
00075 #endif // ENABLE_UNIT_TESTS
00076
00077 #ifdef ENABLE_INTEGRATION_TESTS
00078 namespace {
00079 #if 0
00080 }
00081 #endif
00082
00083 static class VCard21Test : public RegisterSyncSourceTest {
00084 public:
00085 VCard21Test() : RegisterSyncSourceTest("sqlite_vcard21", "vcard21") {}
00086
00087 virtual void updateConfig(ClientTestConfig &config) const
00088 {
00089 config.type = "sqlite-contacts:text/x-vcard";
00090 config.testcases = "testcases/sqlite_vcard21.vcf";
00091 }
00092 } VCard21Test;
00093
00094 }
00095 #endif // ENABLE_INTEGRATION_TESTS
00096
00097 #endif // ENABLE_SQLITE