~ubuntu-branches/ubuntu/trusty/telephony-service/trusty

« back to all changes in this revision

Viewing changes to Ubuntu/Telephony/contactwatcher.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Gustavo Pichorim Boiko, Tiago Salem Herrmann, Ubuntu daily release
  • Date: 2013-12-05 08:42:04 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20131205084204-3oaeeuwb2k5p887t
Tags: 0.1+14.04.20131205-0ubuntu1
[ Gustavo Pichorim Boiko ]
* Test ContactWatcher's "interactive" property.

[ Tiago Salem Herrmann ]
* Accept non numeric id's.
* Add support for private and unknown phone numbers.

[ Ubuntu daily release ]
* Automatic snapshot from revision 761

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <QContactDetailFilter>
30
30
#include <QContactPhoneNumber>
31
31
 
 
32
namespace C {
 
33
#include <libintl.h>
 
34
}
 
35
 
32
36
ContactWatcher::ContactWatcher(QObject *parent) :
33
 
    QObject(parent)
 
37
    QObject(parent), mInteractive(true)
34
38
{
35
39
    connect(ContactUtils::sharedManager(),
36
40
            SIGNAL(contactsAdded(QList<QContactId>)),
85
89
 
86
90
void ContactWatcher::setPhoneNumber(const QString &phoneNumber)
87
91
{
 
92
    const bool isPrivate = phoneNumber.startsWith("x-ofono-private");
 
93
    const bool isUnknown = phoneNumber.startsWith("x-ofono-unknown");
 
94
 
88
95
    mPhoneNumber = phoneNumber;
 
96
    mInteractive = true;
89
97
    Q_EMIT phoneNumberChanged();
90
 
    if (phoneNumber.isEmpty()) {
 
98
    if (mPhoneNumber.isEmpty() || isPrivate || isUnknown) {
91
99
        mAlias.clear();
92
100
        mContactId.clear();
93
101
        mAvatar.clear();
94
102
        mPhoneNumberSubTypes.clear();
95
103
        mPhoneNumberContexts.clear();
 
104
        mInteractive = false;
 
105
 
 
106
        if (isPrivate) {
 
107
            mAlias = C::gettext("Private Number");
 
108
        } else if (isUnknown) {
 
109
            mAlias = C::gettext("Unknown Number");
 
110
        }
 
111
 
96
112
        Q_EMIT contactIdChanged();
97
113
        Q_EMIT avatarChanged();
98
114
        Q_EMIT aliasChanged();
99
115
        Q_EMIT phoneNumberSubTypesChanged();
100
116
        Q_EMIT phoneNumberContextsChanged();
101
117
        Q_EMIT isUnknownChanged();
 
118
        Q_EMIT interactiveChanged();
102
119
        return;
103
120
    }
104
121
 
 
122
    Q_EMIT interactiveChanged();
105
123
    searchByPhoneNumber(mPhoneNumber);
106
124
}
107
125
 
110
128
    return mContactId.isEmpty();
111
129
}
112
130
 
 
131
bool ContactWatcher::interactive() const
 
132
{
 
133
    return mInteractive;
 
134
}
113
135
 
114
136
void ContactWatcher::onContactsAdded(QList<QContactId> ids)
115
137
{