Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #76 from matthewvogt/normalization
Browse files Browse the repository at this point in the history
[libcontacts] Skip validation when normalizing numbers
  • Loading branch information
matthewvogt committed Feb 10, 2014
2 parents 285aff6 + f73cd4c commit fefaf47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/seasidecache.cpp
Expand Up @@ -1241,22 +1241,23 @@ QUrl SeasideCache::filteredAvatarUrl(const QContact &contact, const QStringList
return QUrl();
}

QString SeasideCache::normalizePhoneNumber(const QString &input)
QString SeasideCache::normalizePhoneNumber(const QString &input, bool validate)
{
const QtContactsSqliteExtensions::NormalizePhoneNumberFlags normalizeFlags(QtContactsSqliteExtensions::KeepPhoneNumberDialString |
QtContactsSqliteExtensions::ValidatePhoneNumber);
QtContactsSqliteExtensions::NormalizePhoneNumberFlags normalizeFlags(QtContactsSqliteExtensions::KeepPhoneNumberDialString);
if (validate) {
// If the number if not valid, return empty
normalizeFlags |= QtContactsSqliteExtensions::ValidatePhoneNumber;
}

// If the number if not valid, return null
return QtContactsSqliteExtensions::normalizePhoneNumber(input, normalizeFlags);
}

QString SeasideCache::minimizePhoneNumber(const QString &input)
QString SeasideCache::minimizePhoneNumber(const QString &input, bool validate)
{
// TODO: use a configuration variable to make this configurable
const int maxCharacters = QtContactsSqliteExtensions::DefaultMaximumPhoneNumberCharacters;

// If the number if not valid, return null
QString validated(normalizePhoneNumber(input));
QString validated(normalizePhoneNumber(input, validate));
if (validated.isNull())
return validated;

Expand Down
4 changes: 2 additions & 2 deletions src/seasidecache.h
Expand Up @@ -326,8 +326,8 @@ class CONTACTCACHE_EXPORT SeasideCache : public QObject
static QString generateDisplayLabelFromNonNameDetails(const QContact &contact);
static QUrl filteredAvatarUrl(const QContact &contact, const QStringList &metadataFragments = QStringList());

static QString normalizePhoneNumber(const QString &input);
static QString minimizePhoneNumber(const QString &input);
static QString normalizePhoneNumber(const QString &input, bool validate = false);
static QString minimizePhoneNumber(const QString &input, bool validate = false);

bool event(QEvent *event);

Expand Down

0 comments on commit fefaf47

Please sign in to comment.