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
=== modified file 'debian/changelog'
--- debian/changelog 2012-11-28 20:11:08 +0000
+++ debian/changelog 2012-12-06 11:40:30 +0000
@@ -1,3 +1,9 @@
1qml-friends (0.0+r4) UNRELEASED; urgency=low
2
3 * Added uploadForAccountAsync and uploadComplete signal
4
5 -- Ugo Riboni <ugo.riboni@canonical.com> Thu, 06 Dec 2012 11:37:09 +0000
6
1qml-friends (0.0+r3) quantal; urgency=low7qml-friends (0.0+r3) quantal; urgency=low
28
3 * Rev 39 * Rev 3
410
=== modified file 'modules/Friends/plugin/friendsservice.cpp'
--- modules/Friends/plugin/friendsservice.cpp 2012-11-28 19:59:10 +0000
+++ modules/Friends/plugin/friendsservice.cpp 2012-12-06 11:40:30 +0000
@@ -68,3 +68,29 @@
68 return friends_service_upload(m_service, acct.data(), path.data(), desc.data());68 return friends_service_upload(m_service, acct.data(), path.data(), desc.data());
69}69}
7070
71void FriendsServiceQml::uploadCompleteCallback(GObject *source_object, GAsyncResult *res, gpointer user_data)
72{
73 Q_UNUSED(source_object);
74
75 FriendsServiceQml* service = (FriendsServiceQml*) user_data;
76 if (service) {
77 gchar* result_url;
78 GError* error = NULL;
79 bool success = friends_service_upload_finish(service->m_service, res, &result_url, &error);
80 QString errorMessage;
81 if (!success) {
82 errorMessage = QString::fromUtf8(error->message);
83 }
84 Q_EMIT service->uploadComplete(QString::fromUtf8(result_url), success, errorMessage);
85 }
86}
87
88void FriendsServiceQml::uploadForAccountAsync(const QString& account_id, const QString& uri, const QString& description) const
89{
90 QByteArray acct = account_id.toUtf8();
91 QByteArray path = uri.toUtf8();
92 QByteArray desc = description.toUtf8();
93 friends_service_upload_async(m_service, acct.data(), path.data(), desc.data(),
94 &uploadCompleteCallback, (gpointer) this);
95}
96
7197
=== modified file 'modules/Friends/plugin/friendsservice.h'
--- modules/Friends/plugin/friendsservice.h 2012-11-28 19:59:10 +0000
+++ modules/Friends/plugin/friendsservice.h 2012-12-06 11:40:30 +0000
@@ -37,8 +37,13 @@
37 QStringList featuresForProtocol(const QString& protocol) const;37 QStringList featuresForProtocol(const QString& protocol) const;
38 bool sendForAccount(const QString& account, const QString& message) const;38 bool sendForAccount(const QString& account, const QString& message) const;
39 bool uploadForAccount(const QString& account_id, const QString& uri, const QString& description) const;39 bool uploadForAccount(const QString& account_id, const QString& uri, const QString& description) const;
40 void uploadForAccountAsync(const QString& account_id, const QString& uri, const QString& description) const;
41
42Q_SIGNALS:
43 void uploadComplete(QString resultUrl, bool success, QString errorMessage);
4044
41private:45private:
46 static void uploadCompleteCallback(GObject *source_object, GAsyncResult *res, gpointer user_data);
42 FriendsService* m_service;47 FriendsService* m_service;
43};48};
4449

Subscribers

People subscribed via source and target branches

to all changes: