bugfix: vCard 3.0 with mixed case were not converted properly to vCard 2.1

by SyncEvolution (must convert to upper case because vCard 2.1 only allows
that), leading to problems with mapping phone numbers in the Funambol server.
Diagnosed and reported by Paul McDermott, thanks a lot!


git-svn-id: https://zeitsenke.de/svn/SyncEvolution/trunk@462 15ad00c4-1369-45f4-8270-35d70d36bdcd
This commit is contained in:
Patrick Ohly 2007-11-30 22:40:33 +00:00
parent 5ddc85129e
commit b355a5fb95
1 changed files with 26 additions and 0 deletions

View File

@ -312,6 +312,14 @@ void EvolutionContactSource::exportData(ostream &out)
}
}
string toupperstr(string str)
{
for (size_t i = 0; i < str.size(); i++) {
str[i] = toupper(str[i]);
}
return str;
}
SyncItem *EvolutionContactSource::createItem( const string &uid, SyncState state )
{
logItem( uid, "extracting from EV", true );
@ -430,6 +438,24 @@ SyncItem *EvolutionContactSource::createItem( const string &uid, SyncState state
++it) {
vprop->addParameter("TYPE", it->c_str());
}
// Also make all strings uppercase because 3.0 is
// case-insensitive whereas 2.1 requires uppercase.
list< pair<string, string> > parameters;
while (vprop->parameterCount() > 0) {
const char *param = vprop->getParameter(0);
const char *value = vprop->getParameterValue(0);
if (!param || !value) {
break;
}
parameters.push_back(pair<string, string>(toupperstr(param), toupperstr(value)));
vprop->removeParameter(0);
}
while (parameters.size() > 0) {
pair<string, string> param_value = parameters.front();
vprop->addParameter(param_value.first.c_str(), param_value.second.c_str());
parameters.pop_front();
}
}
vobj->setVersion("2.1");