~ci-train-bot/history-service/history-service-ubuntu-zesty-2629

« back to all changes in this revision

Viewing changes to src/contactmatcher.cpp

  • Committer: Bileto Bot
  • Author(s): Gustavo Pichorim Boiko
  • Date: 2016-11-30 15:13:58 UTC
  • mfrom: (230.2.23 staging)
  • Revision ID: ci-train-bot@canonical.com-20161130151358-jy3mqj0ir0b6ncxe
Improve group chat support.

Approved by: Roberto Mier Escandón , Tiago Salem Herrmann

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2014-2015 Canonical, Ltd.
 
2
 * Copyright (C) 2014-2016 Canonical, Ltd.
3
3
 *
4
4
 * Authors:
5
5
 *  Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
95
95
 *
96
96
 * Note that synchronous requests should only be placed after \ref TelepathyHelper is ready.
97
97
 */
98
 
QVariantMap ContactMatcher::contactInfo(const QString &accountId, const QString &identifier, bool synchronous)
 
98
QVariantMap ContactMatcher::contactInfo(const QString &accountId, const QString &identifier, bool synchronous, const QVariantMap &properties)
99
99
{
100
100
    InternalContactMap &internalMap = mContactMap[accountId];
101
101
 
103
103
    if (internalMap.contains(identifier)) {
104
104
        return internalMap[identifier];
105
105
    }
106
 
 
 
106
    
107
107
    QVariantMap map;
 
108
 
108
109
    // and if there was no match, asynchronously request the info, and return an empty map for now
109
110
    if (History::TelepathyHelper::instance()->ready()) {
110
111
        map = requestContactInfo(accountId, identifier, synchronous);
114
115
    }
115
116
    map[History::FieldIdentifier] = identifier;
116
117
    map[History::FieldAccountId] = accountId;
 
118
 
 
119
    QMapIterator<QString, QVariant> i(properties);
 
120
    while (i.hasNext()) {
 
121
        i.next();
 
122
        if (!map.contains(i.key())) {
 
123
            map[i.key()] = i.value();
 
124
        }
 
125
    }
 
126
 
117
127
    mContactMap[accountId][identifier] = map;
118
128
    return map;
119
129
}