Merge lp:~super-friends/qml-friends/qml-friends-upload-async into lp:qml-friends

Proposed by Ugo Riboni
Status: Merged
Merged at revision: 4
Proposed branch: lp:~super-friends/qml-friends/qml-friends-upload-async
Merge into: lp:qml-friends
Diff against target: 64 lines (+37/-0)
3 files modified
debian/changelog (+6/-0)
modules/Friends/plugin/friendsservice.cpp (+26/-0)
modules/Friends/plugin/friendsservice.h (+5/-0)
To merge this branch: bzr merge lp:~super-friends/qml-friends/qml-friends-upload-async
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Review via email: mp+138429@code.launchpad.net

Commit message

Add bindings for uploadForAccountAsync and the uploadComplete signal

Description of the change

Add bindings for uploadForAccountAsync and the uploadComplete signal

To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2012-11-28 20:11:08 +0000
3+++ debian/changelog 2012-12-06 11:40:30 +0000
4@@ -1,3 +1,9 @@
5+qml-friends (0.0+r4) UNRELEASED; urgency=low
6+
7+ * Added uploadForAccountAsync and uploadComplete signal
8+
9+ -- Ugo Riboni <ugo.riboni@canonical.com> Thu, 06 Dec 2012 11:37:09 +0000
10+
11 qml-friends (0.0+r3) quantal; urgency=low
12
13 * Rev 3
14
15=== modified file 'modules/Friends/plugin/friendsservice.cpp'
16--- modules/Friends/plugin/friendsservice.cpp 2012-11-28 19:59:10 +0000
17+++ modules/Friends/plugin/friendsservice.cpp 2012-12-06 11:40:30 +0000
18@@ -68,3 +68,29 @@
19 return friends_service_upload(m_service, acct.data(), path.data(), desc.data());
20 }
21
22+void FriendsServiceQml::uploadCompleteCallback(GObject *source_object, GAsyncResult *res, gpointer user_data)
23+{
24+ Q_UNUSED(source_object);
25+
26+ FriendsServiceQml* service = (FriendsServiceQml*) user_data;
27+ if (service) {
28+ gchar* result_url;
29+ GError* error = NULL;
30+ bool success = friends_service_upload_finish(service->m_service, res, &result_url, &error);
31+ QString errorMessage;
32+ if (!success) {
33+ errorMessage = QString::fromUtf8(error->message);
34+ }
35+ Q_EMIT service->uploadComplete(QString::fromUtf8(result_url), success, errorMessage);
36+ }
37+}
38+
39+void FriendsServiceQml::uploadForAccountAsync(const QString& account_id, const QString& uri, const QString& description) const
40+{
41+ QByteArray acct = account_id.toUtf8();
42+ QByteArray path = uri.toUtf8();
43+ QByteArray desc = description.toUtf8();
44+ friends_service_upload_async(m_service, acct.data(), path.data(), desc.data(),
45+ &uploadCompleteCallback, (gpointer) this);
46+}
47+
48
49=== modified file 'modules/Friends/plugin/friendsservice.h'
50--- modules/Friends/plugin/friendsservice.h 2012-11-28 19:59:10 +0000
51+++ modules/Friends/plugin/friendsservice.h 2012-12-06 11:40:30 +0000
52@@ -37,8 +37,13 @@
53 QStringList featuresForProtocol(const QString& protocol) const;
54 bool sendForAccount(const QString& account, const QString& message) const;
55 bool uploadForAccount(const QString& account_id, const QString& uri, const QString& description) const;
56+ void uploadForAccountAsync(const QString& account_id, const QString& uri, const QString& description) const;
57+
58+Q_SIGNALS:
59+ void uploadComplete(QString resultUrl, bool success, QString errorMessage);
60
61 private:
62+ static void uploadCompleteCallback(GObject *source_object, GAsyncResult *res, gpointer user_data);
63 FriendsService* m_service;
64 };
65

Subscribers

People subscribed via source and target branches

to all changes: