http://bugzilla.moblin.org/show_bug.cgi?id=7838
--- Comment #18 from pohly <patrick.ohly(a)intel.com> 2010-01-14 06:12:52 PST ---
(In reply to comment #16)
(In reply to comment #15)
> A useable single-file installation of SyncEvolution. I consider this a valuable
> feature.
Okay, I see.
> > > What if <Manufacturer> or <Model> contain commas and/or
underscores?
> > Not considered so far. If there is really such strange manufacture or model,
we
> > can fix that later.
>
> Once we role out 1.0 final and users start adding template files for their own
> phones, they don't have the option of modifying the source code of the
> syncevo-dbus-server or the sync-ui.
>
> The question of parsing these strings is only relevant if we reliably need to
> decompose the strings into <manufacturer> and <model>. This might not
be
> necessary at all. A fuzzy string match might do just fine. For a hierarchical
> view of templates, we could split at _ (*any* underscore, regardless how many
> there are) and treat the individual words as "most general" to "most
specific".
> That would also work for future extensions, like Nokia_N7120c_v1,
> Nokia_N7120c_v2.
I was thinking something different thus resulting a different approach. I think
users will not add their own templates (do we have any command line/ui option
for this?), thus the templates is maintained by us.Why do normal user need
their own template? They only need their only configurations.
True for users. I was thinking of distributors who might want to add additional
templates.
With this assumption, I compromised a little to make the
finger(print) string
more technical to help a better match, with this approach:
Nokia_N7210 will never match to LG_N7210c;
Not at all? What if Company Foo and Bar both sell the identical device XYZ and
we only have a template for Foo_XYZ?
Nokia_N700 match with Nokia_N7000 will have less score than
Nokia_N700 match
with Nokia_N701
I consider these features useful.
I have no idea how well this matching will work in practice.
Some real examples:
./syncevolution --template ?Nokia_N7210c
Available configuration templates:
Nokia_7210c = Nokia 7210c phone 4
Nokia = Default templates for nokia phone 2
ServerDefault = server side default template 1
SyncEvolutionServer = SyncEvolution server side template 1
./syncevolution --template ?7210c
Available configuration templates:
Nokia = Default templates for nokia phone 1
Nokia_7210c = Nokia 7210c phone 1
ServerDefault = server side default template 1
SyncEvolutionServer = SyncEvolution server side template 1
IMHO the Nokia_7210c template should get a higher score in the
second case.
Overall the whole matching code seems way to complicated to me. A "longest
common subsequence" match and a score defined as "length of
subsequence"/"length of fingerprint in template" might provide more
intuitive
results. I have an implementation of LCS lying around somewhere. Ping me if you
want it.
Congwu, can you add the real templates together with
this patch and add unit tests for the code to the Cmdline tests?
This is a lot of complex code that at least I don't understand
just by reading it. This is useful regardless how we really implement
the matching.
To run with a controlled set of file templates you could copy
those as we do for PIM data and then run the tests with a
ScopedEnvChange templates("SYNCEVOLUTION_TEMPLATE_DIR",
"testcases/templates").
Regarding naming of the top-level src/templates/[client|server]
directories: this is ambiguous. Is a "server template" something to
be used *by* a SyncML client or by a SyncML server *for* a client?
Traditionally, SyncEvolution had "server templates" which were used
by a client. Your patch reverses the meaning by putting the
Funambol/ScheduleWorld templates into a "client" directory.
Perhaps we can avoid the ambiguity by using "clients" and "servers"
(plural)? "servers" makes it more obvious that the templates are
describing servers, to be used by one client. Same the other way
around for one server supporting multiple clients.
(In reply to comment #17)
I have just updated the patch for your comments expect below.
Patrick, what do
you think about this?
For general comments, see above.
Regarding the code, here's a diff for changes that I would find useful:
diff --git a/README b/README
index c80fd34..7de4391 100644
--- a/README
+++ b/README
@@ -320,7 +320,7 @@ a list of valid values.
sources, so if you want to change a source property of just one specific
sync source, then use "--configure --source-property ... <server>
<source>".
---template|-l <server name>|default|?
+--template|-l <server name>|default|?|?<device>
Can be used to select from one of the built-in default configurations
for known SyncML servers. Defaults to the <server> name, so --template
only has to be specified when creating multiple different configurations
@@ -330,6 +330,13 @@ a list of valid values.
Each template contains a pseudo-random device ID. Therefore setting the
"deviceId" sync property is only necessary when manually recreating a
configuration or when a more descriptive name is desired.
+ The available templates for different known SyncML servers are listed
+ when using a single question mark instead of a template name. When using
+ the ?<device> format, a fuzzy search for a template that might be suitable
+ for talking to such a device is done. The matching works best when using
+ <device> = <Manufacturer>_<Model>. The output in this mode gives the
+ template name followed by a short description and a rating how well the
+ template matches the device (higher is better).
--status|-t
The changes made to local data since the last synchronization are
diff --git a/src/syncevo-dbus-server.cpp b/src/syncevo-dbus-server.cpp
index 24ac449..aeddc21 100644
--- a/src/syncevo-dbus-server.cpp
+++ b/src/syncevo-dbus-server.cpp
@@ -2657,8 +2657,8 @@ void Connection::process(const Caller_t &caller,
SyncConfig::ConfigList servers = SyncConfig::getConfigs();
BOOST_FOREACH(const SyncConfig::ConfigList::value_type
&server,
servers) {
- SyncContext context(server.first);
- if (context.getSyncURL() == serverID) {
+ SyncConfig config(server.first);
+ if (config.getSyncURL() == serverID) {
config = server.first;
break;
}
@@ -2672,9 +2672,12 @@ void Connection::process(const Caller_t &caller,
string btAddr = id->second.substr(0,
id->second.find("+"));
BOOST_FOREACH(const
SyncConfig::ConfigList::value_type &server,
servers) {
- SyncContext context(server.first);
- string url = context.getSyncURL();
- SE_LOG_INFO (NULL, NULL, "matching against
%s",url.c_str());
+ SyncConfig config(server.first);
+ string url = config.getSyncURL();
+ SE_LOG_DEBUG(NULL, NULL, "matching against
%s",url.c_str());
+ // this will not match:
+ // syncURL = obex-bt://mac-address,
http://some.ip.address:port
+ // syncURL =
http://mac-address+channel
if (url.find ("obex-bt://") ==0 &&
url.substr(strlen("obex-bt://"), url.npos) == btAddr) {
config = server.first;
break;
diff --git a/src/syncevo/SyncConfig.cpp b/src/syncevo/SyncConfig.cpp
index 9c3a795..342056b 100644
--- a/src/syncevo/SyncConfig.cpp
+++ b/src/syncevo/SyncConfig.cpp
@@ -386,23 +386,33 @@ SyncConfig::TemplateList
SyncConfig::getBuiltInTemplates()
result.addDefaultTemplate("Google", "http://m.google.com/sync");
result.addDefaultTemplate("ZYB", "http://www.zyb.com");
result.addDefaultTemplate("Mobical", "http://www.mobical.net");
+ // Why is this called SyncEvolution*Client*?
+ // It is the config for a SyncEvolution server and thus should be
+ // name "SyncEvolution" to be consistent with the other template names.
result.addDefaultTemplate("SyncEvolutionClient",
"http://www.syncevolution.org");
result.sort (TemplateDescription::compare_op);
return result;
}
-SyncConfig::TemplateList SyncConfig::matchPeerTemplates(const DeviceList
&peers)
+static string SyncEvolutionTemplateDir()
{
- TemplateList result;
- // match against all possible templates without any assumption on
directory
- // layout, the match is entirely based on the metadata .template.ini
string templateDir(TEMPLATE_DIR);
const char *envvar = getenv("SYNCEVOLUTION_TEMPLATE_DIR");
if (envvar) {
templateDir = envvar;
}
+ return templateDir;
+}
+
+SyncConfig::TemplateList SyncConfig::matchPeerTemplates(const DeviceList
&peers)
+{
+ TemplateList result;
+ // match against all possible templates without any assumption on
directory
+ // layout, the match is entirely based on the metadata .template.ini
+ string templateDir(SyncEvolutionTemplateDir());
+
std::queue <std::string, std::list<std::string> > directories;
if (isDir(templateDir)) {
directories.push (templateDir);
@@ -447,11 +457,7 @@ boost::shared_ptr<SyncConfig>
SyncConfig::createPeerTemplate(const string &serve
}
// case insensitive search for read-only file template config
- string templateConfig(TEMPLATE_DIR);
- const char *envvar = getenv("SYNCEVOLUTION_TEMPLATE_DIR");
- if (envvar) {
- templateConfig = envvar;
- }
+ string templateConfig(SyncEvolutionTemplateDir());
// before starting another fuzzy match process, first try to load the
// template directly taking the parameter as the path
@@ -683,7 +689,8 @@ boost::shared_ptr<SyncConfig>
SyncConfig::createPeerTemplate(const string &serve
} else if (boost::iequals(server, "syncevolutionclient")) {
config->setSyncURL("http://yourserver:port");
config->setWebURL("http://www.syncevolution.org");
- config->setConsumerReady(true);
+ // No normal consumer will run a SyncEvolution HTTP server.
+ // config->setConsumerReady(true);
source = config->getSyncSourceConfig("addressbook");
source->setURI("addressbook");
source = config->getSyncSourceConfig("calendar");
@@ -1997,7 +2004,7 @@ int TemplateConfig::serverModeMatch
(SyncConfig::MatchMode mode)
return BEST_MATCH;
}
-/*
+/**
* fingerprint = Manufacture_Mod
* Mod = ModPre([a-z]*)ModMid([0-9]*)ModLast([a-z]*)
* 7210c = "" 7210 c
diff --git a/src/syncevo/SyncConfig.h b/src/syncevo/SyncConfig.h
index 9af8742..fb23b67 100644
--- a/src/syncevo/SyncConfig.h
+++ b/src/syncevo/SyncConfig.h
@@ -1588,9 +1588,11 @@ class PersistentSyncSourceConfig : public
SyncSourceConfig {
virtual const char* getSupportedTypes() const { return ""; }
};
-/*
+/**
* Representing a template configuration node
- * */
+ *
+ * PO: what is a template configuration node?
+ */
class TemplateConfig
{
boost::shared_ptr<FileConfigNode> m_metaNode;
--
Configure bugmail:
http://bugzilla.moblin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching someone on the CC list of the bug.