WebDAV: added templates for Yahoo and Google
This patch introduces the new "peerType" property which marks templates and configs as something that can be used for the 'source-config@<target>' configs necessary for local sync. Only "WebDAV" is used. If peerType is not set, the template or config is traditional SyncML. This patch also adds two templates, one for Google Calendar and one for Yahoo CardDAV and CalDAV. Because Yahoo CardDAV is unreliable, it is not enabled.
This commit is contained in:
parent
bfb7a85f84
commit
33f0c9c3f6
4 changed files with 116 additions and 2 deletions
|
@ -1988,6 +1988,25 @@ static string filterConfig(const string &buffer)
|
|||
return res.str();
|
||||
}
|
||||
|
||||
static string removeComments(const string &buffer)
|
||||
{
|
||||
ostringstream res;
|
||||
|
||||
typedef boost::split_iterator<string::const_iterator> string_split_iterator;
|
||||
for (string_split_iterator it =
|
||||
boost::make_split_iterator(buffer, boost::first_finder("\n", boost::is_iequal()));
|
||||
it != string_split_iterator();
|
||||
++it) {
|
||||
string line = boost::copy_range<string>(*it);
|
||||
if (!line.empty() &&
|
||||
!boost::starts_with(line, "#")) {
|
||||
res << line << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return res.str();
|
||||
}
|
||||
|
||||
// remove comment lines from scanFiles() output
|
||||
static string filterFiles(const string &buffer)
|
||||
{
|
||||
|
@ -2237,6 +2256,12 @@ protected:
|
|||
buffer.replace(uuid, end - uuid, "deviceId = fixed-devid");
|
||||
}
|
||||
|
||||
string filterRandomUUID(const string &buffer) {
|
||||
string copy = buffer;
|
||||
removeRandomUUID(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/** create new configurations */
|
||||
void testSetupScheduleWorld() { doSetupScheduleWorld(false); }
|
||||
void doSetupScheduleWorld(bool shared) {
|
||||
|
@ -2617,6 +2642,7 @@ protected:
|
|||
" template name = template description\n"
|
||||
" eGroupware = http://www.egroupware.org\n"
|
||||
" Funambol = http://my.funambol.com\n"
|
||||
" Google_Calendar = event sync via CalDAV, use for the 'source-config@google-calendar' config\n"
|
||||
" Google_Contacts = contact sync via SyncML, see http://www.google.com/support/mobile/bin/topic.py?topic=22181\n"
|
||||
" Goosync = http://www.goosync.com/\n"
|
||||
" Memotoo = http://www.memotoo.com\n"
|
||||
|
@ -2625,7 +2651,8 @@ protected:
|
|||
" Ovi = http://www.ovi.com\n"
|
||||
" ScheduleWorld = server no longer in operation\n"
|
||||
" SyncEvolution = http://www.syncevolution.org\n"
|
||||
" Synthesis = http://www.synthesis.ch\n",
|
||||
" Synthesis = http://www.synthesis.ch\n"
|
||||
" Yahoo = contact and event sync using WebDAV, use for the 'source-config@yahoo' config\n",
|
||||
help.m_out.str());
|
||||
CPPUNIT_ASSERT_EQUAL_DIFF("", help.m_err.str());
|
||||
}
|
||||
|
@ -2896,8 +2923,9 @@ protected:
|
|||
}
|
||||
|
||||
void testPrintFileTemplatesConfig() {
|
||||
// simulate reading templates from user's XDG HOME
|
||||
symlink("../templates", (m_testDir + "/syncevolution-templates").c_str());
|
||||
ScopedEnvChange templates("SYNCEVOLUTION_TEMPLATE_DIR", "templates");
|
||||
ScopedEnvChange templates("SYNCEVOLUTION_TEMPLATE_DIR", "/dev/null");
|
||||
ScopedEnvChange xdg("XDG_CONFIG_HOME", m_testDir);
|
||||
ScopedEnvChange home("HOME", m_testDir);
|
||||
|
||||
|
@ -2905,6 +2933,42 @@ protected:
|
|||
}
|
||||
|
||||
void doPrintFileTemplates() {
|
||||
// Compare only the properties which are really set.
|
||||
//
|
||||
// note that "backend" will be take from the @default context if one
|
||||
// exists, so run this before setting up Funambol below
|
||||
std::string googlecaldav =
|
||||
"syncURL = https://www.google.com/calendar/dav/%u/user/?SyncEvolution=Google\n"
|
||||
"deviceId = fixed-devid\n"
|
||||
"ConsumerReady = 1\n"
|
||||
"peerType = WebDAV\n"
|
||||
"[calendar]\n"
|
||||
"sync = two-way\n"
|
||||
"backend = CalDAV\n";
|
||||
{
|
||||
TestCmdline cmdline("--print-config", "--template", "google calendar", NULL);
|
||||
cmdline.doit();
|
||||
CPPUNIT_ASSERT_EQUAL_DIFF(googlecaldav,
|
||||
removeComments(filterRandomUUID(filterConfig(cmdline.m_out.str()))));
|
||||
}
|
||||
|
||||
std::string yahoo =
|
||||
"deviceId = fixed-devid\n"
|
||||
"ConsumerReady = 1\n"
|
||||
"peerType = WebDAV\n"
|
||||
"[addressbook]\n"
|
||||
"sync = disabled\n"
|
||||
"backend = CardDAV\n"
|
||||
"[calendar]\n"
|
||||
"sync = two-way\n"
|
||||
"backend = CalDAV\n";
|
||||
{
|
||||
TestCmdline cmdline("--print-config", "--template", "yahoo", NULL);
|
||||
cmdline.doit();
|
||||
CPPUNIT_ASSERT_EQUAL_DIFF(yahoo,
|
||||
removeComments(filterRandomUUID(filterConfig(cmdline.m_out.str()))));
|
||||
}
|
||||
|
||||
testSetupFunambol();
|
||||
|
||||
{
|
||||
|
@ -3140,6 +3204,8 @@ protected:
|
|||
"\n"
|
||||
"ConsumerReady:\n"
|
||||
"\n"
|
||||
"peerType:\n"
|
||||
"\n"
|
||||
"defaultPeer:\n");
|
||||
string sourceProperties("sync:\n"
|
||||
"\n"
|
||||
|
@ -4092,6 +4158,7 @@ private:
|
|||
"peers/scheduleworld/config.ini:WebURL = http://www.scheduleworld.com\n"
|
||||
"peers/scheduleworld/config.ini:# IconURI = \n"
|
||||
"peers/scheduleworld/config.ini:# ConsumerReady = 0\n"
|
||||
"peers/scheduleworld/config.ini:# peerType = \n"
|
||||
|
||||
"peers/scheduleworld/sources/addressbook/.internal.ini:# adminData = \n"
|
||||
"peers/scheduleworld/sources/addressbook/.internal.ini:# synthesisID = 0\n"
|
||||
|
|
|
@ -1327,6 +1327,25 @@ static BoolConfigProperty syncPropConsumerReady("ConsumerReady",
|
|||
"Has no effect in a user's server configuration.\n",
|
||||
"0");
|
||||
|
||||
/**
|
||||
* Some guidelines for peerType = WebDAV:
|
||||
* - Such templates may only be used to create the 'source-config@<target>.
|
||||
* configurations. Typically <target> can be the same as the template's
|
||||
* name.
|
||||
* - Because determining the default database in WebDAV can be difficult,
|
||||
* the GUI should allow the user to choose and set the "uri"
|
||||
* properties accordingly.
|
||||
* - A GUI should also create a <target> configuration for synchronizing
|
||||
* against the WebDAV backends.
|
||||
*/
|
||||
static ConfigProperty syncPropPeerType("peerType",
|
||||
"Defines what a configuration is meant to be used for.\n"
|
||||
"Used in templates and the resulting configs to tell a GUI\n"
|
||||
"that special handling may be necessary. GUIs should ignore\n"
|
||||
"unknown types.\n"
|
||||
"The traditional SyncML configs use an empty value.\n"
|
||||
"\"WebDAV\" is used for the WebDAV side in a local synchronization.\n");
|
||||
|
||||
static ULongConfigProperty syncPropHashCode("HashCode", "used by the SyncML library internally; do not modify");
|
||||
|
||||
static ConfigProperty syncPropConfigDate("ConfigDate", "used by the SyncML library internally; do not modify");
|
||||
|
@ -1486,6 +1505,7 @@ ConfigPropertyRegistry &SyncConfig::getRegistry()
|
|||
registry.push_back(&syncPropWebURL);
|
||||
registry.push_back(&syncPropIconURI);
|
||||
registry.push_back(&syncPropConsumerReady);
|
||||
registry.push_back(&syncPropPeerType);
|
||||
registry.push_back(&syncPropHashCode);
|
||||
registry.push_back(&syncPropConfigDate);
|
||||
registry.push_back(&syncPropNonce);
|
||||
|
|
12
src/templates/contexts/Google-Calendar.ini
Normal file
12
src/templates/contexts/Google-Calendar.ini
Normal file
|
@ -0,0 +1,12 @@
|
|||
=== template.ini ===
|
||||
fingerprint = Google Calendar
|
||||
description = event sync via CalDAV, use for the 'source-config@google-calendar' config
|
||||
|
||||
=== config.ini ===
|
||||
consumerReady = 1
|
||||
peerType = WebDAV
|
||||
syncURL = https://www.google.com/calendar/dav/%u/user/?SyncEvolution=Google
|
||||
|
||||
=== sources/calendar/config.ini ===
|
||||
sync = two-way
|
||||
backend = CalDAV
|
15
src/templates/contexts/Yahoo.ini
Normal file
15
src/templates/contexts/Yahoo.ini
Normal file
|
@ -0,0 +1,15 @@
|
|||
=== template.ini ===
|
||||
fingerprint = Yahoo
|
||||
description = contact and event sync using WebDAV, use for the 'source-config@yahoo' config
|
||||
|
||||
=== config.ini ===
|
||||
consumerReady = 1
|
||||
peerType = WebDAV
|
||||
|
||||
=== sources/addressbook/config.ini ===
|
||||
sync = none
|
||||
backend = CardDAV
|
||||
|
||||
=== sources/calendar/config.ini ===
|
||||
sync = two-way
|
||||
backend = CalDAV
|
Loading…
Reference in a new issue