27.1.6
by Sergio Schvezov
Adding license headers |
1 |
/*
|
2 |
Copyright 2014 Canonical Ltd.
|
|
3 |
Authors: Sergio Schvezov <sergio.schvezov@canonical.com>
|
|
4 |
||
5 |
This program is free software: you can redistribute it and/or modify it
|
|
6 |
under the terms of the GNU General Public License version 3, as published
|
|
7 |
by the Free Software Foundation.
|
|
8 |
||
9 |
This program is distributed in the hope that it will be useful, but
|
|
10 |
WITHOUT ANY WARRANTY; without even the implied warranties of
|
|
11 |
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
|
12 |
PURPOSE. See the GNU General Public License for more details.
|
|
13 |
||
14 |
You should have received a copy of the GNU General Public License along
|
|
15 |
with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
*/
|
|
17 |
||
27.10.1
by Sergio Schvezov
test qtcontact |
18 |
#include <QContactManager> |
19 |
#include <QContactFilter> |
|
20 |
#include <QContactEmailAddress> |
|
21 |
#include <QContactDetailFilter> |
|
22 |
#include <QContactManager> |
|
23 |
#include <QContactAvatar> |
|
24 |
#include <QCoreApplication> |
|
27.10.2
by Manuel de la Peña
Do get the method to execute using a signal mapper. |
25 |
#include <QScopedPointer> |
27.10.1
by Sergio Schvezov
test qtcontact |
26 |
#include <QTimer> |
27 |
#include <thread> |
|
28 |
||
29 |
#include "qtcontacts.h" |
|
30 |
#include "qtcontacts.hpp" |
|
31 |
#include "qtcontacts.moc" |
|
32 |
||
33 |
#ifdef __cplusplus
|
|
34 |
extern "C" { |
|
35 |
#include "_cgo_export.h" |
|
36 |
}
|
|
37 |
#endif
|
|
38 |
||
39 |
QTCONTACTS_USE_NAMESPACE
|
|
40 |
||
27.1.7
by Sergio Schvezov
initial qt loop migration |
41 |
int mainloopStart() { |
27.10.1
by Sergio Schvezov
test qtcontact |
42 |
static char empty[1] = {0}; |
43 |
static char *argv[] = {empty, empty, empty}; |
|
44 |
static int argc = 1; |
|
27.1.7
by Sergio Schvezov
initial qt loop migration |
45 |
|
27.10.1
by Sergio Schvezov
test qtcontact |
46 |
QCoreApplication mApp(argc, argv); |
27.1.7
by Sergio Schvezov
initial qt loop migration |
47 |
return mApp.exec(); |
48 |
}
|
|
27.10.1
by Sergio Schvezov
test qtcontact |
49 |
|
27.1.7
by Sergio Schvezov
initial qt loop migration |
50 |
void getAvatar(char *email) { |
27.1.5
by Sergio Schvezov
working version of avatars for gmail |
51 |
QScopedPointer<Avatar> avatar(new Avatar()); |
27.1.9
by Sergio Schvezov
initial working implementation |
52 |
avatar->retrieveThumbnail(QString(email)); |
27.1.5
by Sergio Schvezov
working version of avatars for gmail |
53 |
}
|
54 |
||
27.10.2
by Manuel de la Peña
Do get the method to execute using a signal mapper. |
55 |
void Avatar::retrieveThumbnail(const QString& email) { |
27.10.1
by Sergio Schvezov
test qtcontact |
56 |
QString avatar; |
57 |
||
58 |
QContactManager manager ("galera"); |
|
59 |
QContactDetailFilter filter(QContactEmailAddress::match(email)); |
|
60 |
QList<QContact> contacts = manager.contacts(filter); |
|
61 |
if(contacts.size() > 0) { |
|
62 |
avatar = contacts[0].detail<QContactAvatar>().imageUrl().path(); |
|
63 |
}
|
|
64 |
||
65 |
QByteArray byteArray = avatar.toUtf8(); |
|
66 |
char* cString = byteArray.data(); |
|
67 |
||
27.1.5
by Sergio Schvezov
working version of avatars for gmail |
68 |
callback(cString); |
27.10.1
by Sergio Schvezov
test qtcontact |
69 |
}
|