Merge lp:~ken-vandine/content-hub/pasteboard into lp:content-hub

Proposed by Ken VanDine
Status: Merged
Approved by: Ken VanDine
Approved revision: 317
Merged at revision: 292
Proposed branch: lp:~ken-vandine/content-hub/pasteboard
Merge into: lp:content-hub
Prerequisite: lp:~ken-vandine/content-hub/qmlplugindump_noinstantiate
Diff against target: 1711 lines (+1245/-18) (has conflicts)
23 files modified
CMakeLists.txt (+4/-4)
debian/changelog (+9/-0)
examples/CMakeLists.txt (+1/-0)
examples/pasteboard/CMakeLists.txt (+55/-0)
examples/pasteboard/copy.cpp (+56/-0)
examples/pasteboard/paste.cpp (+59/-0)
import/Ubuntu/Content/CMakeLists.txt (+2/-0)
include/com/ubuntu/content/hub.h (+31/-4)
include/com/ubuntu/content/paste.h (+70/-0)
src/com/ubuntu/content/CMakeLists.txt (+12/-0)
src/com/ubuntu/content/detail/com.ubuntu.content.Paste.xml (+22/-0)
src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml (+24/-0)
src/com/ubuntu/content/detail/paste.cpp (+132/-0)
src/com/ubuntu/content/detail/paste.h (+72/-0)
src/com/ubuntu/content/detail/service.cpp (+115/-6)
src/com/ubuntu/content/detail/service.h (+10/-0)
src/com/ubuntu/content/hub.cpp (+98/-2)
src/com/ubuntu/content/paste.cpp (+50/-0)
src/com/ubuntu/content/paste_p.h (+100/-0)
src/com/ubuntu/content/utils.cpp (+120/-2)
tests/acceptance-tests/CMakeLists.txt (+21/-0)
tests/acceptance-tests/app_hub_communication_paste.cpp (+138/-0)
tests/acceptance-tests/mimedata_test.cpp (+44/-0)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~ken-vandine/content-hub/pasteboard
Reviewer Review Type Date Requested Status
Tyler Hicks Approve
system-apps-ci-bot continuous-integration Needs Fixing
Daniel d'Andrada (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+296352@code.launchpad.net

Commit message

Pasteboard implementation

Description of the change

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:287
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/20/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/917/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/917
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/827
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/827
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/827
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/828/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/828/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/828/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/828/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/828/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/828/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/828/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/828/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/828/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/20/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:288
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/22/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/920/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/920
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/830
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/830
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/830
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/830/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/830/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/830/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/830/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/830/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/830/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/830/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/830/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/830/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/22/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:289
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/24/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/995/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/995
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/896
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/896
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/896
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/890/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/890/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/890/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/890/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/890/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/890/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/890/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/890/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/890/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/24/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:290
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/25/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/996/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/996
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/897
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/897
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/897
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/891/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/891/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/891/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/891/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/891/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/891/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/891/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/891/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/891/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/25/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

In include/com/ubuntu/content/hub.h:

"""
    Q_INVOKABLE virtual Paste* create_paste(const QMimeData& data);
"""

Who owns the created Paste object? Is the caller free to delete it? Will that Paste object live forever, as long as Hub does? Please document it (I know other methods are undocumented and that sucks).

--------------------------------------------------

In include/com/ubuntu/content/paste.h:

Since Paste is public API, I would like to see it documented. Again, I know existing the API isn't, but we can do better than that.

"""
#include <com/ubuntu/content/item.h>
"""

What do you use from this header?

"""
namespace com
{
namespace ubuntu
{
namespace content
{
namespace detail
{
}
}
}
}
"""

You can remove this as you don't forward-declare anything in there.

"""
    Q_PROPERTY(int id READ id)
[...]
    Q_PROPERTY(QString source READ source)
"""

If those properties never change you should declare them as CONSTANT, like this:
Q_PROPERTY(QString source READ source CONSTANT)

"""
    enum State
    {
        created,
        charged,
        saved,
        collected
    };
"""

What do those states mean and why should user the care about them all?

"""
    Q_INVOKABLE virtual int id() const;
    Q_INVOKABLE virtual State state() const;
    Q_INVOKABLE virtual bool charge(const QMimeData& mimeData);
    Q_INVOKABLE virtual QMimeData* mimeData();
    Q_INVOKABLE virtual QString source() const;
"""

They don't have to (nor should) be Q_INVOKABLE if they're already getters or setters of Q_PROPERTIES. You added the Q_INVOKABLE so they could be called from QML, right?

"""
    //Q_PROPERTY(QMimeData mimeData READ mimeData WRITE charge)
"""

Why commented out?

"""
    Q_INVOKABLE virtual bool charge(const QMimeData& mimeData);
"""

Is the user supposed to call this? What's the use case? He can call Hub::create_paste(mimeData) and later change the paste contents passing a different QMimeData?

What's the use of Paste::source property?

review: Needs Information
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

"""
    Q_INVOKABLE virtual const QMimeData* latest_paste_buf();
"""

That usually involves a round-trip through the D-Bus session + deserialization of the QMimeData, right?

So if I (the client) wanna get it asynchronously to avoid blocking my current thread (essentially because of the IPC involved), should I call this method from a separate worker thread? Or would it be simple for you to expose an async version of this on the client API?

review: Needs Information
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Hub is missing a signal to inform clients that the clibboard content has changed.

review: Needs Fixing
Revision history for this message
Ken VanDine (ken-vandine) wrote :
Download full text (3.2 KiB)

> In include/com/ubuntu/content/hub.h:
>
> """
> Q_INVOKABLE virtual Paste* create_paste(const QMimeData& data);
> """
>
> Who owns the created Paste object? Is the caller free to delete it? Will that
> Paste object live forever, as long as Hub does? Please document it (I know
> other methods are undocumented and that sucks).

Caller is free to delete it. The object will be available as long as the hub is running. Eventually we'll cache them to disk as well, so the stack will be restored.

>
> --------------------------------------------------
>
> In include/com/ubuntu/content/paste.h:
>
> Since Paste is public API, I would like to see it documented. Again, I know
> existing the API isn't, but we can do better than that.

Paste is technically a public API, but applications won't have direct access to the Paste object under confinement. Which reminds me why create_paste shouldn't return the Paste object. That should really just return a boolean. The Paste object will be used for the clipboard app.

>
> """
> #include <com/ubuntu/content/item.h>
> """
>
> What do you use from this header?

That can be removed

>
> """
> namespace com
> {
> namespace ubuntu
> {
> namespace content
> {
> namespace detail
> {
> }
> }
> }
> }
> """
>
> You can remove this as you don't forward-declare anything in there.
>
> """
> Q_PROPERTY(int id READ id)
> [...]
> Q_PROPERTY(QString source READ source)
> """
>
> If those properties never change you should declare them as CONSTANT, like
> this:
> Q_PROPERTY(QString source READ source CONSTANT)

Agreed, that would be better

>
> """
> enum State
> {
> created,
> charged,
> saved,
> collected
> };
> """
>
> What do those states mean and why should user the care about them all?

The user probably doesn't care, and we might just blow away the state property.

>
>
> """
> Q_INVOKABLE virtual int id() const;
> Q_INVOKABLE virtual State state() const;
> Q_INVOKABLE virtual bool charge(const QMimeData& mimeData);
> Q_INVOKABLE virtual QMimeData* mimeData();
> Q_INVOKABLE virtual QString source() const;
> """
>
> They don't have to (nor should) be Q_INVOKABLE if they're already getters or
> setters of Q_PROPERTIES. You added the Q_INVOKABLE so they could be called
> from QML, right?

Yes, although we probably only need the charge method to be callable from QML.

>
>
> """
> //Q_PROPERTY(QMimeData mimeData READ mimeData WRITE charge)
> """
>
> Why commented out?

I don't see this commented out, maybe you reviewed this before my last push.

>
> """
> Q_INVOKABLE virtual bool charge(const QMimeData& mimeData);
> """
>
> Is the user supposed to call this? What's the use case? He can call
> Hub::create_paste(mimeData) and later change the paste contents passing a
> different QMimeData?

Not directly, this is for use by the hub. Once the Paste object is charged, it can no longer be charged again. So the data won't change. For qtubuntu, you should only use the API exposed by hub.h.

>
> What's the use of Paste::source property?

This is the appId of the application that created the paste. We'll use this in the...

Read more...

Revision history for this message
Ken VanDine (ken-vandine) wrote :

> Hub is missing a signal to inform clients that the clibboard content has
> changed.

I'm adding property that returns a list of mimetypes on the stack which includes a changed signal.

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:291
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/26/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1014/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1014
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/912
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/912
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/912
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/906/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/906/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/906/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/906/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/906/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/906/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/906/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/906/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/906/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/26/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:293
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/27/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1015/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1015
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/913
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/913
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/913
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/907/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/907/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/907/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/907/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/907/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/907/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/907/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/907/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/907/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/27/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:294
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/28/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1018/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1018
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/916
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/916
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/916
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/910/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/910/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/910/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/910/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/910/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/910/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/910/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/910/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/910/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/28/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:296
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/29/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1024/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1024
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/922
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/922
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/922
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/916/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/916/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/916/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/916/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/916/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/916/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/916/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/916/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/916/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/29/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:297
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/30/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1025/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1025
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/923
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/923
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/923
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/917/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/917/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/917/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/917/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/917/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/917/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/917/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/917/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/917/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/30/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:299
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/31/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1035/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1035
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/932
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/932
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/932
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/926/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/926/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/926/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/926/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/926/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/926/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/926/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/926/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/926/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/31/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Made some modifications here:
http://bazaar.launchpad.net/~dandrader/content-hub/pasteboard/revision/285

- Fix unnecessary round trip and memory leak when fetching a Paste from the service
- Simplify D-Bus interface and traffic using ay instead of av
- Create separate sync and async versions of createPaste

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Code making use of it is here:
lp:~dandrader/qtubuntu/content-hub-clipboard

In src/ubuntumirclient/clipboard.cpp

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> Made some modifications here:
> http://bazaar.launchpad.net/~dandrader/content-hub/pasteboard/revision/285
>
> - Fix unnecessary round trip and memory leak when fetching a Paste from the
> service
> - Simplify D-Bus interface and traffic using ay instead of av
> - Create separate sync and async versions of createPaste

Oh, and added async versions for latestPaste() and pasteById() as well.

Revision history for this message
Ken VanDine (ken-vandine) wrote :

> > Made some modifications here:
> > http://bazaar.launchpad.net/~dandrader/content-hub/pasteboard/revision/285
> >
> > - Fix unnecessary round trip and memory leak when fetching a Paste from the
> > service
> > - Simplify D-Bus interface and traffic using ay instead of av
> > - Create separate sync and async versions of createPaste
>
> Oh, and added async versions for latestPaste() and pasteById() as well.

These changes are great! Only comment I have is I prefer making createPaste async and making the sync version something like createPasteSync. Makes it feel like the preferred function is the async one. But that's not a must for me, it's just more like I'm used to doing with gobject style code. What do you think is more common for Qt?

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 26/07/2016 18:05, Ken VanDine wrote:
>>> Made some modifications here:
>>> http://bazaar.launchpad.net/~dandrader/content-hub/pasteboard/revision/285
>>>
>>> - Fix unnecessary round trip and memory leak when fetching a Paste from the
>>> service
>>> - Simplify D-Bus interface and traffic using ay instead of av
>>> - Create separate sync and async versions of createPaste
>> Oh, and added async versions for latestPaste() and pasteById() as well.
> These changes are great! Only comment I have is I prefer making createPaste async and making the sync version something like createPasteSync. Makes it feel like the preferred function is the async one. But that's not a must for me, it's just more like I'm used to doing with gobject style code. What do you think is more common for Qt?

I followed the convention used here:
http://doc.qt.io/qt-5/qdbusabstractinterface.html#public-functions

But I also prefer prefer the way you suggest. Made the change (same
revision number).

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:300
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/32/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1049/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1049
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/946
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/946
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/946
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/937/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/937/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/937/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/937/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/937/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/937/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/937/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/937/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/937/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/32/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:301
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/33/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1050/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1050
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/947
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/947
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/947
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/938/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/33/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:302
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/36/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1064/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1063
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/959
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/959
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/959
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/950/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/950/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/950/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/950/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/950/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/950/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/950/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/950/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/950/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/36/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:303
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/37/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1068/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1068
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/965
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/965
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/965
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/956/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/956/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/956/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/956/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/956/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/956/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/956/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/956/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/956/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/37/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:305
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/38/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1073/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1073
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/970
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/970
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/970
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/959/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/959/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/959/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/959/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/959/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/959/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/959/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/959/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/959/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/38/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:306
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/39/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1074/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1074
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/971
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/971
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/971
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/960/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/960/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/960/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/960/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/960/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/960/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/960/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/960/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/960/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/39/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:308
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/40/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1099/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1099
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/996
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/996
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/996
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/985/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/985/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/985/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/985/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/985/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/985/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/985/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/985/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/985/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/40/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:309
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/41/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1102/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1102
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/999
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/999
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/999
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/988/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/988/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/988/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/988/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/988/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/988/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/988/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/988/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/988/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/41/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:311
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/42/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1104/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1104
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1001
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1001
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1001
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/990/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/990/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/990/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/990/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/990/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/990/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/990/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/990/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/990/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/42/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Looks good to me.

review: Approve
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

CMakeLists.txt:79:set(CONTENT_HUB_VERSION_MAJOR 0)
CMakeLists.txt:80:set(CONTENT_HUB_VERSION_MINOR 0)
CMakeLists.txt:81:set(CONTENT_HUB_VERSION_PATCH 1)

Please update those to match the version in debian/changelog.

Otherwise things like that will fail:
pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

CMakeLists.txt:79:set(CONTENT_HUB_VERSION_MAJOR 0)
CMakeLists.txt:80:set(CONTENT_HUB_VERSION_MINOR 0)
CMakeLists.txt:81:set(CONTENT_HUB_VERSION_PATCH 1)

Please update those to match the version in debian/changelog.

Otherwise things like that will fail:
pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Would be good also to move over the test for the serialization and deserialization code from lp:qtmir in tests/mirserver/Clipboard/clipboard_test.cpp.

Namely TEST(ClipboardTest, MimeDataSerialization)

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Made some changes in lp:~dandrader/content-hub/pasteboard revision 285. Let me know what you think.

It was really annoying me while testing on a laptop that content-hub was refusing to accept a copy from an app that unity8 was displaying (because ubuntu-app-launch wasn't tracking the running app for some reason). That cannot happen and would be a regression since it works with the current clipboard implementation.

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:312
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/43/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1124/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1124
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1019
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1019
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1019
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1008/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1008/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1008/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1008/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1008/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1008/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1008/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1008/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1008/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/43/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

> CMakeLists.txt:79:set(CONTENT_HUB_VERSION_MAJOR 0)
> CMakeLists.txt:80:set(CONTENT_HUB_VERSION_MINOR 0)
> CMakeLists.txt:81:set(CONTENT_HUB_VERSION_PATCH 1)
>
> Please update those to match the version in debian/changelog.
>
> Otherwise things like that will fail:
> pkg_check_modules(CONTENT_HUB libcontent-hub>=0.2 REQUIRED)

Done

Revision history for this message
Ken VanDine (ken-vandine) wrote :

> Would be good also to move over the test for the serialization and
> deserialization code from lp:qtmir in
> tests/mirserver/Clipboard/clipboard_test.cpp.
>
> Namely TEST(ClipboardTest, MimeDataSerialization)

Done

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:313
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/44/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1127/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1127
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1020
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1020
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1020
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1009/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1009/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1009/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1009/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1009/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1009/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1009/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1009/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1009/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/44/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

> Made some changes in lp:~dandrader/content-hub/pasteboard revision 285. Let me
> know what you think.
>
> It was really annoying me while testing on a laptop that content-hub was
> refusing to accept a copy from an app that unity8 was displaying (because
> ubuntu-app-launch wasn't tracking the running app for some reason). That
> cannot happen and would be a regression since it works with the current
> clipboard implementation.

This is fine, ultimately I hope it'll be a real corner case. But it's really not that big of a deal if it fails.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Thanks!

review: Approve
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:314
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/45/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1128/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1128
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1021
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1021
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1021
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1010/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1010/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1010/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1010/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1010/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1010/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1010/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1010/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1010/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/45/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Tyler Hicks (tyhicks) wrote :

Ubuntu Security would like to review this change. We were involved in the early design stages and were awaiting an update to the design doc for this feature. The design doc that we have access to is still based on an old design that doesn't match this implementation. We're blocked until the doc can be updated.

review: Needs Information
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Wrote focused surface verification based on persistent surface ids here:
http://bazaar.launchpad.net/~dandrader/content-hub/pasteboard/revision/315

315. By Ken VanDine

merged trunk

316. By Ken VanDine

Daniel d'Andrada 2016-08-23 Authenticate using surface ids instead of process ids

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:316
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/46/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1286/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1286
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1152
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1152
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1152
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1135
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1135/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1135
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1135/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1135/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1135
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1135/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1135
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1135/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1135
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1135/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1135
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1135/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1135
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1135/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1135
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1135/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/46/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

The client is blocking on startup waiting for PasteFormats value.

Wrote a fix for it here:
http://bazaar.launchpad.net/~dandrader/content-hub/pasteboard/revision/317

There I've also reduced D-Bus round trips by already sending the paste formats on its changed signal.

317. By Ken VanDine

Daniel d'Andrada 2016-08-24 Improve PasteFormatsChanged

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:317
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/48/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1314/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1314
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1178
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1178
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1178
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1158
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1158/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1158
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1158/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1158/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1158
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1158/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1158
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1158/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1158
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1158/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1158
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1158/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1158
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1158/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1158/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-content-hub-ci/48/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Tyler Hicks (tyhicks) wrote :

I gave this a quick review. It was more of a design review than a detailed code review.

The security of this design is rooted in the random surface ID created by Mir. That surface ID must be randomly generated and of significant size so that bruteforces of the ID is not feasible. I'm told that the ID is randomly generated and evenly distributed throughout a full 128 bits. That should be sufficient.

A future improvement that I'd like to see is a penalty after a number of incorrect surface ID guesses so that a malicious app cannot simply brute force the 128 bit space without any negative side effects. The penalty could be time based, where the pasteboard doesn't return back for several seconds. There are other options, as well.

I had some trouble understanding the intent behind the usage of the APP_ID in the merge proposal. Ken tells me that it is for a future design when there is a pasteboard UI so that the user will be prompted with the APP_ID of the application requesting access to the paste buffer. Since the APP_ID isn't used right now, I'm not concerned, but I'd like to understand more about how the APP_ID is being retrieved before we start prompting users. I'd prefer that we use the APP_ID directly from the D-Bus daemon via the GetConnectionCredentials bus method:

  https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-get-connection-credentials

Thanks for working towards a secure copy and paste solution. I look forward to this design being improved on in the future with the introduction of a pasteboard UI.

review: Approve
Revision history for this message
Tyler Hicks (tyhicks) wrote :

Upon thinking about my suggestion, for a future enhancement, of a penalty to be handed out upon a number of wrong surface ID guesses, I realized that content-hub is not the correct place to implement the penalty. Mir clients will be able to call isSurfaceFocused() themselves to brute force the surface ID. Once they find a valid surface ID, then they can simply pass that to the content-hub. Therefore, the penalty mechanism would need to be implemented in Mir itself.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-09-23 14:45:09 +0000
+++ CMakeLists.txt 2016-08-25 13:22:47 +0000
@@ -24,8 +24,8 @@
24include (EnableCoverageReport)24include (EnableCoverageReport)
25include (GSettings)25include (GSettings)
2626
27set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -pedantic -Wextra -fPIC -pthread")27set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -pthread")
28set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -fno-strict-aliasing -pedantic -Wextra -fPIC -pthread -Wno-unused-function")28set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing -fPIC -pthread -Wno-unused-function")
29set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")29set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
3030
31# Workaround for libexecdir on debian31# Workaround for libexecdir on debian
@@ -77,8 +77,8 @@
77add_definitions(-DI18N_DOMAIN="${GETTEXT_PACKAGE}")77add_definitions(-DI18N_DOMAIN="${GETTEXT_PACKAGE}")
7878
79set(CONTENT_HUB_VERSION_MAJOR 0)79set(CONTENT_HUB_VERSION_MAJOR 0)
80set(CONTENT_HUB_VERSION_MINOR 0)80set(CONTENT_HUB_VERSION_MINOR 2)
81set(CONTENT_HUB_VERSION_PATCH 1)81set(CONTENT_HUB_VERSION_PATCH 0)
82set(CONTENT_HUB_VERSION "${CONTENT_HUB_VERSION_MAJOR}.${CONTENT_HUB_VERSION_MINOR}.${CONTENT_HUB_VERSION_PATCH}")82set(CONTENT_HUB_VERSION "${CONTENT_HUB_VERSION_MAJOR}.${CONTENT_HUB_VERSION_MINOR}.${CONTENT_HUB_VERSION_PATCH}")
8383
84set(QML_API_VERSION_MAJOR 1)84set(QML_API_VERSION_MAJOR 1)
8585
=== modified file 'debian/changelog'
--- debian/changelog 2016-08-22 17:01:38 +0000
+++ debian/changelog 2016-08-25 13:22:47 +0000
@@ -1,9 +1,18 @@
1<<<<<<< TREE
1content-hub (0.1+16.10.20160822-0ubuntu1) yakkety; urgency=medium2content-hub (0.1+16.10.20160822-0ubuntu1) yakkety; urgency=medium
23
3 * No change rebuild for UAL ABI change4 * No change rebuild for UAL ABI change
45
5 -- Ted Gould <ted@gould.cx> Mon, 22 Aug 2016 17:01:38 +00006 -- Ted Gould <ted@gould.cx> Mon, 22 Aug 2016 17:01:38 +0000
67
8=======
9content-hub (0.2-0ubuntu1) UNRELEASED; urgency=medium
10
11 * Pasteboard implementation
12
13 -- Ken VanDine <ken.vandine@canonical.com> Wed, 27 Jul 2016 10:49:05 -0400
14
15>>>>>>> MERGE-SOURCE
7content-hub (0.1+16.10.20160809-0ubuntu1) yakkety; urgency=medium16content-hub (0.1+16.10.20160809-0ubuntu1) yakkety; urgency=medium
817
9 * build dep on qttools5-dev-tools for qdoc18 * build dep on qttools5-dev-tools for qdoc
1019
=== modified file 'examples/CMakeLists.txt'
--- examples/CMakeLists.txt 2013-08-27 22:15:29 +0000
+++ examples/CMakeLists.txt 2016-08-25 13:22:47 +0000
@@ -16,3 +16,4 @@
1616
17add_subdirectory(importer)17add_subdirectory(importer)
18add_subdirectory(exporter)18add_subdirectory(exporter)
19add_subdirectory(pasteboard)
1920
=== added directory 'examples/pasteboard'
=== added file 'examples/pasteboard/CMakeLists.txt'
--- examples/pasteboard/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ examples/pasteboard/CMakeLists.txt 2016-08-25 13:22:47 +0000
@@ -0,0 +1,55 @@
1# Copyright © 2016 Canonical Ltd.
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License version 3 as
5# published by the Free Software Foundation.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License
13# along with this program. If not, see <http://www.gnu.org/licenses/>.
14#
15# Authored by: Ken VanDine <ken.vandine@canonical.com>
16
17include_directories(${CMAKE_CURRENT_BINARY_DIR})
18
19add_executable(
20 copy-to-pasteboard
21
22 copy.cpp
23)
24
25qt5_use_modules(copy-to-pasteboard Core Gui DBus)
26
27set_target_properties(
28 copy-to-pasteboard
29 PROPERTIES
30 AUTOMOC TRUE
31)
32
33target_link_libraries(
34 copy-to-pasteboard
35 content-hub
36)
37
38add_executable(
39 paste-from-pasteboard
40
41 paste.cpp
42)
43
44qt5_use_modules(paste-from-pasteboard Core Gui DBus)
45
46set_target_properties(
47 paste-from-pasteboard
48 PROPERTIES
49 AUTOMOC TRUE
50)
51
52target_link_libraries(
53 paste-from-pasteboard
54 content-hub
55)
056
=== added file 'examples/pasteboard/copy.cpp'
--- examples/pasteboard/copy.cpp 1970-01-01 00:00:00 +0000
+++ examples/pasteboard/copy.cpp 2016-08-25 13:22:47 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */
18
19#include <QCoreApplication>
20#include <QDebug>
21#include <QStringList>
22#include <com/ubuntu/content/hub.h>
23#include <com/ubuntu/content/paste.h>
24
25namespace cuc = com::ubuntu::content;
26
27int main(int argc, char *argv[])
28{
29 QCoreApplication a(argc, argv);
30 if (qgetenv("APP_ID").isEmpty()) {
31 qputenv("APP_ID", "copy-to-pasteboard");
32 }
33
34 QString text("Some text");
35
36 if (a.arguments().size() > 1)
37 text = a.arguments().at(1);
38
39 QMimeData data;
40 data.setText(text);
41
42 auto hub = cuc::Hub::Client::instance();
43
44 /* Won't work unless you disable the surface Id verification with CONTENT_HUB_TESTING=1 env var
45 To get the surface Id of a MirSurface in a real GUI app you should to it like the following:
46 MirPersistentId* mirPermaId = mir_surface_request_persistent_id_sync(mirSurface);
47 QString surfaceId = mir_persistent_id_as_string(mirPermaId);
48 mir_persistent_id_release(mirPermaId);
49 */
50 QString surfaceId("some-bogus-fake-surface-id");
51
52 hub->createPasteSync(surfaceId, const_cast<const QMimeData&>(data));
53
54 qDebug() << text;
55 qDebug() << hub->pasteFormats();
56}
057
=== added file 'examples/pasteboard/paste.cpp'
--- examples/pasteboard/paste.cpp 1970-01-01 00:00:00 +0000
+++ examples/pasteboard/paste.cpp 2016-08-25 13:22:47 +0000
@@ -0,0 +1,59 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */
18
19#include <QCoreApplication>
20#include <QStringList>
21#include <com/ubuntu/content/hub.h>
22
23namespace cuc = com::ubuntu::content;
24
25int main(int argc, char *argv[])
26{
27 QCoreApplication a(argc, argv);
28 if (qgetenv("APP_ID").isEmpty()) {
29 qputenv("APP_ID", "paste-from-pasteboard");
30 }
31
32 QString id("latest");
33
34 if (a.arguments().size() > 1)
35 id = a.arguments().at(1);
36
37 auto hub = cuc::Hub::Client::instance();
38
39 /* Won't work unless you disable the surface Id verification with CONTENT_HUB_TESTING=1 env var
40 To get the surface Id of a MirSurface in a real GUI app you should to it like the following:
41 MirPersistentId* mirPermaId = mir_surface_request_persistent_id_sync(mirSurface);
42 QString surfaceId = mir_persistent_id_as_string(mirPermaId);
43 mir_persistent_id_release(mirPermaId);
44 */
45 QString surfaceId("some-bogus-fake-surface-id");
46
47 QMimeData *mimeData = nullptr;
48 if (id == "latest") {
49 mimeData = hub->latestPaste(surfaceId);
50 } else {
51 mimeData = hub->pasteById(surfaceId, id.toInt());
52 }
53 if (mimeData) {
54 qDebug() << id << ":" << mimeData->text();
55 } else {
56 qDebug() << "content-hub returned no mimedata.";
57 }
58 return 0;
59}
060
=== modified file 'import/Ubuntu/Content/CMakeLists.txt'
--- import/Ubuntu/Content/CMakeLists.txt 2016-05-18 17:18:55 +0000
+++ import/Ubuntu/Content/CMakeLists.txt 2016-08-25 13:22:47 +0000
@@ -39,6 +39,7 @@
39 ${NIH_DBUS_INCLUDE_DIRS}39 ${NIH_DBUS_INCLUDE_DIRS}
40 ${DBUS_INCLUDE_DIRS}40 ${DBUS_INCLUDE_DIRS}
41 ${GLIB_INCLUDE_DIRS}41 ${GLIB_INCLUDE_DIRS}
42 ${UBUNTU_LAUNCH_INCLUDE_DIRS}
42)43)
4344
44set(PLUGIN_HDRS45set(PLUGIN_HDRS
@@ -81,6 +82,7 @@
81 ${NIH_LIBRARIES}82 ${NIH_LIBRARIES}
82 ${NIH_DBUS_LIBRARIES}83 ${NIH_DBUS_LIBRARIES}
83 ${GLIB_LIBRARIES}84 ${GLIB_LIBRARIES}
85 ${UBUNTU_LAUNCH_LDFLAGS}
84)86)
8587
86install(TARGETS ${PLUGIN} DESTINATION ${CONTENT_HUB_IMPORTS_DIR})88install(TARGETS ${PLUGIN} DESTINATION ${CONTENT_HUB_IMPORTS_DIR})
8789
=== modified file 'include/com/ubuntu/content/hub.h'
--- include/com/ubuntu/content/hub.h 2015-09-29 13:15:58 +0000
+++ include/com/ubuntu/content/hub.h 2016-08-25 13:22:47 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013,2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as5 * it under the terms of the GNU Lesser General Public License version 3 as
@@ -23,7 +23,10 @@
23#include <com/ubuntu/content/type.h>23#include <com/ubuntu/content/type.h>
2424
25#include <QObject>25#include <QObject>
26#include <QVector>26#include <QMimeData>
27
28class QStringList;
29class QDBusPendingCall;
2730
28namespace com31namespace com
29{32{
@@ -38,6 +41,7 @@
38class Hub : public QObject41class Hub : public QObject
39{42{
40 Q_OBJECT43 Q_OBJECT
44 Q_PROPERTY(QStringList pasteFormats READ pasteFormats NOTIFY pasteFormatsChanged)
4145
42 public:46 public:
43 struct Client47 struct Client
@@ -66,11 +70,34 @@
66 Q_INVOKABLE virtual Transfer* create_share_to_peer_for_type(Peer peer, Type type);70 Q_INVOKABLE virtual Transfer* create_share_to_peer_for_type(Peer peer, Type type);
67 Q_INVOKABLE virtual bool has_pending(QString peer_id);71 Q_INVOKABLE virtual bool has_pending(QString peer_id);
68 Q_INVOKABLE virtual Peer peer_for_app_id(QString app_id);72 Q_INVOKABLE virtual Peer peer_for_app_id(QString app_id);
69 73
74 ///
75 // Copy & Paste
76
77 QDBusPendingCall createPaste(const QString &surfaceId, const QMimeData& data);
78
79 QDBusPendingCall requestLatestPaste(const QString &surfaceId);
80 QDBusPendingCall requestPasteById(const QString &surfaceId, int pasteId);
81 QMimeData* paste(QDBusPendingCall requestPeply);
82
83 // synchronous versions
84 bool createPasteSync(const QString &surfaceId, const QMimeData& data);
85 QMimeData* latestPaste(const QString &surfaceId);
86 QMimeData* pasteById(const QString &surfaceId, int id);
87
88 QStringList pasteFormats();
89
90 Q_SIGNALS:
91 void pasteFormatsChanged();
92 void pasteboardChanged();
93
94 private Q_SLOTS:
95 void onPasteFormatsChanged(const QStringList &);
70 protected:96 protected:
71 Hub(QObject* = nullptr);97 Hub(QObject* = nullptr);
72 98
73 private:99 private:
100 void requestPasteFormats();
74 struct Private;101 struct Private;
75 QScopedPointer<Private> d;102 QScopedPointer<Private> d;
76 bool eventFilter(QObject *obj, QEvent *event);103 bool eventFilter(QObject *obj, QEvent *event);
77104
=== added file 'include/com/ubuntu/content/paste.h'
--- include/com/ubuntu/content/paste.h 1970-01-01 00:00:00 +0000
+++ include/com/ubuntu/content/paste.h 2016-08-25 13:22:47 +0000
@@ -0,0 +1,70 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */
18#ifndef COM_UBUNTU_CONTENT_PASTE_H_
19#define COM_UBUNTU_CONTENT_PASTE_H_
20
21#include <QObject>
22#include <QSharedPointer>
23#include <QMimeData>
24#include <QString>
25
26namespace com
27{
28namespace ubuntu
29{
30namespace content
31{
32
33class Paste : public QObject
34{
35 Q_OBJECT
36 Q_ENUMS(State)
37 Q_PROPERTY(int id READ id)
38 Q_PROPERTY(QString source READ source)
39
40 public:
41 enum State
42 {
43 created,
44 charged,
45 saved,
46 collected
47 };
48
49 Paste(const Paste&) = delete;
50 virtual ~Paste();
51
52 Paste& operator=(const Paste&) = delete;
53
54 Q_INVOKABLE virtual int id() const;
55 Q_INVOKABLE virtual QMimeData* mimeData();
56 Q_INVOKABLE virtual QString source() const;
57
58 private:
59 struct Private;
60 friend struct Private;
61 friend class Hub;
62 QSharedPointer<Private> d;
63
64 Paste(const QSharedPointer<Private>&, QObject* parent = nullptr);
65};
66}
67}
68}
69
70#endif // COM_UBUNTU_CONTENT_PASTE_H_
071
=== modified file 'src/com/ubuntu/content/CMakeLists.txt'
--- src/com/ubuntu/content/CMakeLists.txt 2015-09-23 14:45:09 +0000
+++ src/com/ubuntu/content/CMakeLists.txt 2016-08-25 13:22:47 +0000
@@ -47,6 +47,13 @@
47 detail/transfer.h com::ubuntu::content::detail::Transfer)47 detail/transfer.h com::ubuntu::content::detail::Transfer)
4848
49qt5_add_dbus_interface(49qt5_add_dbus_interface(
50 CONTENT_PASTE_STUB ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Paste.xml
51 ContentPasteInterface)
52qt5_add_dbus_adaptor(
53 CONTENT_PASTE_SKELETON ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Paste.xml
54 detail/paste.h com::ubuntu::content::detail::Paste)
55
56qt5_add_dbus_interface(
50 CONTENT_HANDLER_STUB ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Handler.xml 57 CONTENT_HANDLER_STUB ${CMAKE_CURRENT_SOURCE_DIR}/detail/com.ubuntu.content.Handler.xml
51 ContentHandlerInterface)58 ContentHandlerInterface)
52qt5_add_dbus_adaptor(59qt5_add_dbus_adaptor(
@@ -56,6 +63,7 @@
56qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/hub.h)63qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/hub.h)
57qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/import_export_handler.h)64qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/import_export_handler.h)
58qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/item.h)65qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/item.h)
66qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/paste.h)
59qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/peer.h)67qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/peer.h)
60qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/store.h)68qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/store.h)
61qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/transfer.h)69qt5_wrap_cpp(CONTENT_HUB_MOCS ${CMAKE_SOURCE_DIR}/include/com/ubuntu/content/transfer.h)
@@ -67,6 +75,7 @@
67 hub.cpp75 hub.cpp
68 import_export_handler.cpp76 import_export_handler.cpp
69 item.cpp77 item.cpp
78 paste.cpp
70 peer.cpp79 peer.cpp
71 store.cpp80 store.cpp
72 transfer.cpp81 transfer.cpp
@@ -75,6 +84,7 @@
75 debug.cpp84 debug.cpp
7685
77 detail/app_manager.cpp86 detail/app_manager.cpp
87 detail/paste.cpp
78 detail/service.cpp88 detail/service.cpp
79 detail/transfer.cpp89 detail/transfer.cpp
80 detail/handler.cpp90 detail/handler.cpp
@@ -83,6 +93,8 @@
83 ${CONTENT_HUB_MOCS}93 ${CONTENT_HUB_MOCS}
84 ${CONTENT_SERVICE_STUB}94 ${CONTENT_SERVICE_STUB}
85 ${CONTENT_SERVICE_SKELETON}95 ${CONTENT_SERVICE_SKELETON}
96 ${CONTENT_PASTE_STUB}
97 ${CONTENT_PASTE_SKELETON}
86 ${CONTENT_TRANSFER_STUB}98 ${CONTENT_TRANSFER_STUB}
87 ${CONTENT_TRANSFER_SKELETON}99 ${CONTENT_TRANSFER_SKELETON}
88 ${CONTENT_HANDLER_STUB}100 ${CONTENT_HANDLER_STUB}
89101
=== added file 'src/com/ubuntu/content/detail/com.ubuntu.content.Paste.xml'
--- src/com/ubuntu/content/detail/com.ubuntu.content.Paste.xml 1970-01-01 00:00:00 +0000
+++ src/com/ubuntu/content/detail/com.ubuntu.content.Paste.xml 2016-08-25 13:22:47 +0000
@@ -0,0 +1,22 @@
1<node>
2 <interface name="com.ubuntu.content.dbus.Paste">
3 <signal name="StateChanged">
4 <arg name="state" type="i"/>
5 </signal>
6 <method name="Id">
7 <arg name="id" type="i" direction="out" />
8 </method>
9 <method name="State">
10 <arg name="state" type="i" direction="out" />
11 </method>
12 <method name="Charge">
13 <arg name="mimeData" type="ay" direction="in" />
14 </method>
15 <method name="MimeData">
16 <arg name="mimeData" type="ay" direction="out" />
17 </method>
18 <method name="source">
19 <arg name="source" type="s" direction="out" />
20 </method>
21 </interface>
22</node>
023
=== modified file 'src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml'
--- src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2015-09-29 13:15:58 +0000
+++ src/com/ubuntu/content/detail/com.ubuntu.content.Service.xml 2016-08-25 13:22:47 +0000
@@ -36,6 +36,22 @@
36 <arg name="type_id" type="s" direction="in" />36 <arg name="type_id" type="s" direction="in" />
37 <arg name="transfer_object" type="o" direction="out" />37 <arg name="transfer_object" type="o" direction="out" />
38 </method>38 </method>
39 <method name="CreatePaste">
40 <arg name="app_id" type="s" direction="in" />
41 <arg name="surfaceId" type="s" direction="in" />
42 <arg name="mimeData" type="ay" direction="in" />
43 <arg name="types" type="as" direction="in" />
44 <arg name="success" type="b" direction="out" />
45 </method>
46 <method name="GetLatestPasteData">
47 <arg name="surfaceId" type="s" direction="in" />
48 <arg name="mimeData" type="ay" direction="out" />
49 </method>
50 <method name="GetPasteData">
51 <arg name="surfaceId" type="s" direction="in" />
52 <arg name="pasteid" type="s" direction="in" />
53 <arg name="mimeData" type="ay" direction="out" />
54 </method>
39 <method name="RegisterImportExportHandler">55 <method name="RegisterImportExportHandler">
40 <arg name="peer_id" type="s" direction="in" />56 <arg name="peer_id" type="s" direction="in" />
41 <arg name="handler_object" type="o" direction="in" />57 <arg name="handler_object" type="o" direction="in" />
@@ -51,5 +67,13 @@
51 <arg name="app_id" type="s" direction="in" />67 <arg name="app_id" type="s" direction="in" />
52 <arg name="peer" type="v" direction="out" />68 <arg name="peer" type="v" direction="out" />
53 </method>69 </method>
70 <method name="PasteFormats">
71 <arg name="formats" type="as" direction="out" />
72 </method>
73 <signal name="PasteFormatsChanged">
74 <arg name="formats" type="as" />
75 </signal>
76 <signal name="PasteboardChanged">
77 </signal>
54 </interface>78 </interface>
55</node>79</node>
5680
=== added file 'src/com/ubuntu/content/detail/paste.cpp'
--- src/com/ubuntu/content/detail/paste.cpp 1970-01-01 00:00:00 +0000
+++ src/com/ubuntu/content/detail/paste.cpp 2016-08-25 13:22:47 +0000
@@ -0,0 +1,132 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */
18
19#include "debug.h"
20#include "paste.h"
21#include "utils.cpp"
22
23#include <QFileInfo>
24#include <com/ubuntu/content/hub.h>
25#include <com/ubuntu/content/store.h>
26#include <com/ubuntu/content/paste.h>
27#include <ubuntu/download_manager/download.h>
28#include <ubuntu/download_manager/manager.h>
29
30namespace cuc = com::ubuntu::content;
31namespace cucd = com::ubuntu::content::detail;
32
33struct cucd::Paste::Private
34{
35 Private(const int id,
36 const QString& source):
37 state(cuc::Paste::created),
38 id(id),
39 source(source)
40 {
41 }
42
43 cuc::Paste::State state;
44 const int id;
45 const QString source;
46 QString destination;
47 QByteArray mimeData;
48};
49
50cucd::Paste::Paste(const int id,
51 const QString& source,
52 QObject* parent) :
53 QObject(parent), d(new Private(id, source))
54{
55 TRACE() << __PRETTY_FUNCTION__;
56}
57
58cucd::Paste::~Paste()
59{
60 TRACE() << __PRETTY_FUNCTION__;
61}
62
63/* unique id of the paste */
64int cucd::Paste::Id()
65{
66 TRACE() << __PRETTY_FUNCTION__;
67 return d->id;
68}
69
70/* returns the add_id of the source app */
71QString cucd::Paste::source()
72{
73 TRACE() << __PRETTY_FUNCTION__;
74 return d->source;
75}
76
77/* returns the add_id of the destination app */
78QString cucd::Paste::destination()
79{
80 TRACE() << __PRETTY_FUNCTION__;
81 if (d->destination.isEmpty())
82 return d->source;
83 return d->destination;
84}
85
86void cucd::Paste::setDestination(QString& dest)
87{
88 TRACE() << __PRETTY_FUNCTION__;
89 d->destination = dest;
90}
91
92/* returns the object path for the paste */
93QString cucd::Paste::path()
94{
95 TRACE() << Q_FUNC_INFO << "destination:" << destination();
96 static const QString path_pattern{"/pastes/%1/%2"};
97 QString path = path_pattern
98 .arg(sanitize_id(destination()))
99 .arg(d->id);
100 return path;
101}
102
103int cucd::Paste::State()
104{
105 TRACE() << __PRETTY_FUNCTION__;
106 return d->state;
107}
108
109void cucd::Paste::Charge(const QByteArray& mimeData)
110{
111 TRACE() << __PRETTY_FUNCTION__ << "STATE:" << d->state;
112
113 if (d->state == cuc::Paste::charged)
114 return;
115
116 d->mimeData = mimeData;
117 d->state = cuc::Paste::charged;
118 Q_EMIT(StateChanged(d->state));
119}
120
121QByteArray cucd::Paste::MimeData()
122{
123 TRACE() << __PRETTY_FUNCTION__;
124
125 if (d->state != cuc::Paste::collected)
126 {
127 d->state = cuc::Paste::collected;
128 Q_EMIT(StateChanged(d->state));
129 }
130
131 return d->mimeData;
132}
0133
=== added file 'src/com/ubuntu/content/detail/paste.h'
--- src/com/ubuntu/content/detail/paste.h 1970-01-01 00:00:00 +0000
+++ src/com/ubuntu/content/detail/paste.h 2016-08-25 13:22:47 +0000
@@ -0,0 +1,72 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */
18#ifndef PASTE_H_
19#define PASTE_H_
20
21#include <QByteArray>
22#include <QDir>
23#include <QObject>
24#include <QtDBus/QDBusMessage>
25#include <QtDBus/QDBusContext>
26
27namespace com
28{
29namespace ubuntu
30{
31namespace content
32{
33namespace detail
34{
35class Paste : public QObject, protected QDBusContext
36{
37 Q_OBJECT
38 Q_PROPERTY(int State READ State NOTIFY StateChanged)
39 Q_PROPERTY(int id READ Id)
40 Q_PROPERTY(QString source READ source)
41
42 public:
43 Paste(const int, const QString&, QObject* parent = nullptr);
44 Paste(const Paste&) = delete;
45 virtual ~Paste();
46
47 Paste& operator=(const Paste&) = delete;
48
49Q_SIGNALS:
50 void StateChanged(int State);
51
52 public Q_SLOTS:
53 int State();
54 void Charge(const QByteArray& mimeData);
55 QByteArray MimeData();
56 int Id();
57 QString source();
58 QString destination();
59 void setDestination(QString&);
60 QString path();
61
62 private:
63 struct Private;
64 QScopedPointer<Private> d;
65
66};
67}
68}
69}
70}
71
72#endif // PASTE_H_
073
=== modified file 'src/com/ubuntu/content/detail/service.cpp'
--- src/com/ubuntu/content/detail/service.cpp 2016-01-29 17:20:58 +0000
+++ src/com/ubuntu/content/detail/service.cpp 2016-08-25 13:22:47 +0000
@@ -23,6 +23,8 @@
23#include "service.h"23#include "service.h"
24#include "peer_registry.h"24#include "peer_registry.h"
25#include "i18n.h"25#include "i18n.h"
26#include "paste.h"
27#include "pasteadaptor.h"
26#include "transfer.h"28#include "transfer.h"
27#include "transferadaptor.h"29#include "transferadaptor.h"
28#include "utils.cpp"30#include "utils.cpp"
@@ -33,10 +35,12 @@
33#include <libnotify/notify.h>35#include <libnotify/notify.h>
3436
35#include <com/ubuntu/content/item.h>37#include <com/ubuntu/content/item.h>
38#include <com/ubuntu/content/paste.h>
36#include <com/ubuntu/content/peer.h>39#include <com/ubuntu/content/peer.h>
37#include <com/ubuntu/content/type.h>40#include <com/ubuntu/content/type.h>
38#include <com/ubuntu/content/transfer.h>41#include <com/ubuntu/content/transfer.h>
3942
43#include <QDBusInterface>
40#include <QDBusMetaType>44#include <QDBusMetaType>
41#include <QCache>45#include <QCache>
42#include <QCoreApplication>46#include <QCoreApplication>
@@ -74,14 +78,22 @@
74 registry(registry),78 registry(registry),
75 app_manager(application_manager)79 app_manager(application_manager)
76 {80 {
81 unityFocus = new QDBusInterface("com.canonical.Unity.FocusInfo" /* service */,
82 "/com/canonical/Unity/FocusInfo" /* object path */,
83 "com.canonical.Unity.FocusInfo" /* interface */,
84 QDBusConnection::sessionBus(),
85 this);
77 }86 }
7887
79 QDBusConnection connection;88 QDBusConnection connection;
80 QSharedPointer<cucd::PeerRegistry> registry;89 QSharedPointer<cucd::PeerRegistry> registry;
81 QSet<cucd::Transfer*> active_transfers;90 QSet<cucd::Transfer*> active_transfers;
91 QList<cucd::Paste*> active_pastes;
92 QStringList pasteFormats;
82 QSet<RegHandler*> handlers;93 QSet<RegHandler*> handlers;
83 QSharedPointer<cua::ApplicationManager> app_manager;94 QSharedPointer<cua::ApplicationManager> app_manager;
8495 QDBusInterface *unityFocus;
96 const int maxActivePastes = 5;
85};97};
8698
87cucd::Service::Service(QDBusConnection connection, const QSharedPointer<cucd::PeerRegistry>& peer_registry,99cucd::Service::Service(QDBusConnection connection, const QSharedPointer<cucd::PeerRegistry>& peer_registry,
@@ -302,14 +314,96 @@
302 return CreateTransfer(peer_id, src_id, cuc::Transfer::Share, type_id);314 return CreateTransfer(peer_id, src_id, cuc::Transfer::Share, type_id);
303}315}
304316
317bool cucd::Service::CreatePaste(const QString& app_id, const QString& surfaceId, const QByteArray& mimeData,
318 const QStringList& types)
319{
320 TRACE() << Q_FUNC_INFO << app_id << types;
321
322 if (!verifiedSurfaceIsFocused(surfaceId)) {
323 return false;
324 }
325
326 static size_t import_counter{0}; import_counter++;
327
328 pid_t pid = d->connection.interface()->servicePid(this->message().service());
329 qWarning() << Q_FUNC_INFO << "PID: " << pid;
330 QString effective_app_id;
331 if (app_id_matches(app_id, pid)) {
332 effective_app_id = app_id;
333 } else {
334 qWarning() << "APP_ID" << app_id << "doesn't match requesting APP";
335 effective_app_id = "?";
336 }
337
338 auto paste = new cucd::Paste(import_counter, effective_app_id, this);
339 new PasteAdaptor(paste);
340 d->active_pastes.append(paste);
341
342 paste->Charge(mimeData);
343
344 if (d->active_pastes.count() > d->maxActivePastes) {
345 // get rid of the oldest one
346 delete d->active_pastes.takeFirst();
347 }
348
349 Q_EMIT(PasteboardChanged());
350
351 bool pendingPasteFormatsChangedSignal = false;
352 Q_FOREACH (QString t, types) {
353 TRACE() << Q_FUNC_INFO << "Type: " << t;
354 if (!d->pasteFormats.contains(t)) {
355 d->pasteFormats.append(t);
356 pendingPasteFormatsChangedSignal = true;
357 }
358 }
359 if (pendingPasteFormatsChangedSignal) {
360 Q_EMIT(PasteFormatsChanged(d->pasteFormats));
361 }
362
363 return true;
364}
365
366QByteArray cucd::Service::GetLatestPasteData(const QString& surfaceId)
367{
368 TRACE() << Q_FUNC_INFO;
369
370 if (d->active_pastes.isEmpty())
371 return QByteArray();
372
373 return getPasteData(surfaceId, d->active_pastes.last()->Id());
374}
375
376QByteArray cucd::Service::GetPasteData(const QString& surfaceId, const QString& pasteId)
377{
378 TRACE() << Q_FUNC_INFO << pasteId;
379
380 if (d->active_pastes.isEmpty())
381 return QByteArray();
382
383 return getPasteData(surfaceId, pasteId.toInt());
384}
385
386QByteArray cucd::Service::getPasteData(const QString &surfaceId, int pasteId)
387{
388 if (!verifiedSurfaceIsFocused(surfaceId)) {
389 qWarning().nospace() << "Surface isn't focused. Denying paste.";
390 return QByteArray();
391 }
392
393 Q_FOREACH (cucd::Paste *p, d->active_pastes)
394 {
395 if (p->Id() == pasteId)
396 return p->MimeData();
397 }
398 return QByteArray();
399}
400
305QDBusObjectPath cucd::Service::CreateTransfer(const QString& dest_id, const QString& src_id, int dir, const QString& type_id)401QDBusObjectPath cucd::Service::CreateTransfer(const QString& dest_id, const QString& src_id, int dir, const QString& type_id)
306{402{
307 TRACE() << Q_FUNC_INFO << "DEST:" << dest_id << "SRC:" << src_id << "DIRECTION:" << dir;403 TRACE() << Q_FUNC_INFO << "DEST:" << dest_id << "SRC:" << src_id << "DIRECTION:" << dir;
308404
309 static size_t import_counter{0}; import_counter++;405 static size_t import_counter{0}; import_counter++;
310406
311 QUuid uuid{QUuid::createUuid()};
312
313 Q_FOREACH (cucd::Transfer *t, d->active_transfers)407 Q_FOREACH (cucd::Transfer *t, d->active_transfers)
314 {408 {
315 if (t->destination() == dest_id || t->source() == src_id)409 if (t->destination() == dest_id || t->source() == src_id)
@@ -384,7 +478,7 @@
384 TRACE() << Q_FUNC_INFO << "Charged";478 TRACE() << Q_FUNC_INFO << "Charged";
385 if (transfer->WasSourceStartedByContentHub())479 if (transfer->WasSourceStartedByContentHub())
386 d->app_manager->stop_application(transfer->source().toStdString());480 d->app_manager->stop_application(transfer->source().toStdString());
387 481
388 gchar ** uris = NULL;482 gchar ** uris = NULL;
389 if (d->registry->peer_is_legacy(transfer->destination())) {483 if (d->registry->peer_is_legacy(transfer->destination())) {
390 TRACE() << Q_FUNC_INFO << "Destination is a legacy app, collecting";484 TRACE() << Q_FUNC_INFO << "Destination is a legacy app, collecting";
@@ -439,7 +533,7 @@
439 }533 }
440 }534 }
441 if (shouldStop)535 if (shouldStop)
442 d->app_manager->stop_application(transfer->source().toStdString()); 536 d->app_manager->stop_application(transfer->source().toStdString());
443 }537 }
444 gchar ** uris = NULL;538 gchar ** uris = NULL;
445 d->app_manager->invoke_application(transfer->destination().toStdString(), uris);539 d->app_manager->invoke_application(transfer->destination().toStdString(), uris);
@@ -478,7 +572,7 @@
478 if (d->registry->peer_is_legacy(transfer->destination())) {572 if (d->registry->peer_is_legacy(transfer->destination())) {
479 TRACE() << Q_FUNC_INFO << "Destination is a legacy app, collecting";573 TRACE() << Q_FUNC_INFO << "Destination is a legacy app, collecting";
480 transfer->SetStore(shared_dir_for_peer(transfer->destination()));574 transfer->SetStore(shared_dir_for_peer(transfer->destination()));
481 575
482 auto items = transfer->Collect();576 auto items = transfer->Collect();
483 gchar* urls[2] = {0};577 gchar* urls[2] = {0};
484 gint i = 0;578 gint i = 0;
@@ -661,3 +755,18 @@
661 }755 }
662 return false;756 return false;
663}757}
758
759QStringList cucd::Service::PasteFormats()
760{
761 TRACE() << Q_FUNC_INFO;
762 return d->pasteFormats;
763}
764
765bool cucd::Service::verifiedSurfaceIsFocused(const QString &surfaceId)
766{
767 /* Only verify focus when not running under testing */
768 if (!qgetenv("CONTENT_HUB_TESTING").isNull())
769 return true;
770
771 return d->unityFocus->call("isSurfaceFocused", surfaceId).arguments().at(0).toBool();
772}
664773
=== modified file 'src/com/ubuntu/content/detail/service.h'
--- src/com/ubuntu/content/detail/service.h 2015-09-29 13:15:58 +0000
+++ src/com/ubuntu/content/detail/service.h 2016-08-25 13:22:47 +0000
@@ -61,6 +61,10 @@
61 QDBusObjectPath CreateImportFromPeer(const QString&, const QString&, const QString&);61 QDBusObjectPath CreateImportFromPeer(const QString&, const QString&, const QString&);
62 QDBusObjectPath CreateExportToPeer(const QString&, const QString&, const QString&);62 QDBusObjectPath CreateExportToPeer(const QString&, const QString&, const QString&);
63 QDBusObjectPath CreateShareToPeer(const QString&, const QString&, const QString&);63 QDBusObjectPath CreateShareToPeer(const QString&, const QString&, const QString&);
64 bool CreatePaste(const QString&, const QString&, const QByteArray&, const QStringList&);
65 QByteArray GetLatestPasteData(const QString& surfaceId);
66 QByteArray GetPasteData(const QString& surfaceId, const QString& pasteId);
67 QStringList PasteFormats();
6468
65 void RegisterImportExportHandler(const QString&, const QDBusObjectPath& handler);69 void RegisterImportExportHandler(const QString&, const QDBusObjectPath& handler);
66 void HandlerActive(const QString&);70 void HandlerActive(const QString&);
@@ -70,12 +74,18 @@
70 QDBusVariant PeerForId(const QString&);74 QDBusVariant PeerForId(const QString&);
7175
72 private:76 private:
77 QByteArray getPasteData(const QString &surfaceId, int pasteId);
73 bool should_cancel(int);78 bool should_cancel(int);
79 bool verifiedSurfaceIsFocused(const QString &surfaceId);
74 struct Private;80 struct Private;
75 struct RegHandler;81 struct RegHandler;
76 QDBusServiceWatcher* m_watcher;82 QDBusServiceWatcher* m_watcher;
77 QScopedPointer<Private> d;83 QScopedPointer<Private> d;
7884
85 Q_SIGNALS:
86 void PasteFormatsChanged(const QStringList &formats);
87 void PasteboardChanged();
88
79 private Q_SLOTS:89 private Q_SLOTS:
80 void handle_imports(int);90 void handle_imports(int);
81 void handle_exports(int);91 void handle_exports(int);
8292
=== modified file 'src/com/ubuntu/content/hub.cpp'
--- src/com/ubuntu/content/hub.cpp 2016-07-15 18:54:41 +0000
+++ src/com/ubuntu/content/hub.cpp 2016-08-25 13:22:47 +0000
@@ -21,6 +21,7 @@
21#include "ContentServiceInterface.h"21#include "ContentServiceInterface.h"
22#include "ContentHandlerInterface.h"22#include "ContentHandlerInterface.h"
23#include "handleradaptor.h"23#include "handleradaptor.h"
24#include "paste_p.h"
24#include "transfer_p.h"25#include "transfer_p.h"
25#include "utils.cpp"26#include "utils.cpp"
2627
@@ -32,6 +33,7 @@
32#include <com/ubuntu/content/type.h>33#include <com/ubuntu/content/type.h>
33#include <libertine.h>34#include <libertine.h>
3435
36#include <QDBusPendingCallWatcher>
35#include <QIcon>37#include <QIcon>
36#include <QStandardPaths>38#include <QStandardPaths>
37#include <QStringList>39#include <QStringList>
@@ -52,6 +54,7 @@
52 }54 }
5355
54 com::ubuntu::content::dbus::Service* service;56 com::ubuntu::content::dbus::Service* service;
57 QStringList pasteFormats;
55};58};
5659
57cuc::Hub::Hub(QObject* parent) : QObject(parent), d{new cuc::Hub::Private{this}}60cuc::Hub::Hub(QObject* parent) : QObject(parent), d{new cuc::Hub::Private{this}}
@@ -79,6 +82,13 @@
79 iconPaths << QString(path + "/usr/share/icons/");82 iconPaths << QString(path + "/usr/share/icons/");
80 }83 }
81 QIcon::setThemeSearchPaths(iconPaths);84 QIcon::setThemeSearchPaths(iconPaths);
85
86 QObject::connect(d->service, &com::ubuntu::content::dbus::Service::PasteFormatsChanged,
87 this, &cuc::Hub::Hub::onPasteFormatsChanged);
88 requestPasteFormats();
89 QObject::connect(d->service, SIGNAL(PasteboardChanged()),
90 this,
91 SIGNAL(pasteboardChanged()));
82}92}
8393
84cuc::Hub::~Hub()94cuc::Hub::~Hub()
@@ -91,6 +101,31 @@
91 return hub;101 return hub;
92}102}
93103
104void cuc::Hub::requestPasteFormats()
105{
106 auto reply = d->service->PasteFormats();
107
108 auto replyWatcher = new QDBusPendingCallWatcher(reply, this);
109 connect(replyWatcher, &QDBusPendingCallWatcher::finished,
110 this, [this, replyWatcher]() {
111 QDBusPendingReply<QStringList> reply = *replyWatcher;
112 replyWatcher->deleteLater();
113 if (!reply.isError()) {
114 d->pasteFormats = reply.value();
115 Q_EMIT(pasteFormatsChanged());
116 }
117 });
118}
119
120void cuc::Hub::onPasteFormatsChanged(const QStringList &formats)
121{
122 TRACE() << Q_FUNC_INFO;
123
124 d->pasteFormats = formats;
125 TRACE() << Q_FUNC_INFO << d->pasteFormats;
126 Q_EMIT(pasteFormatsChanged());
127}
128
94bool cuc::Hub::eventFilter(QObject *obj, QEvent *event)129bool cuc::Hub::eventFilter(QObject *obj, QEvent *event)
95{130{
96 if (event->type() == QEvent::ApplicationActivate)131 if (event->type() == QEvent::ApplicationActivate)
@@ -100,7 +135,7 @@
100 {135 {
101 TRACE() << Q_FUNC_INFO << id << "Activated";136 TRACE() << Q_FUNC_INFO << id << "Activated";
102 d->service->HandlerActive(id);137 d->service->HandlerActive(id);
103 } else 138 } else
104 {139 {
105 qWarning() << "APP_ID isn't set, the handler ignored";140 qWarning() << "APP_ID isn't set, the handler ignored";
106 }141 }
@@ -181,7 +216,7 @@
181216
182 if (reply.isError())217 if (reply.isError())
183 return result;218 return result;
184 219
185 auto peers = reply.value();220 auto peers = reply.value();
186 QString id = app_id();221 QString id = app_id();
187222
@@ -340,3 +375,64 @@
340 auto peer = reply.value();375 auto peer = reply.value();
341 return qdbus_cast<cuc::Peer>(peer.variant());376 return qdbus_cast<cuc::Peer>(peer.variant());
342}377}
378
379QDBusPendingCall cuc::Hub::createPaste(const QString &surfaceId, const QMimeData& mimeData)
380{
381 /* This needs to be replaced with a better way to get the APP_ID */
382 QString appId = app_id();
383 TRACE() << Q_FUNC_INFO << appId;
384
385 auto serializedMimeData = serializeMimeData(mimeData);
386 if (serializedMimeData.isEmpty()) {
387 return QDBusPendingCall::fromCompletedCall(
388 QDBusMessage::createError("Data serialization failed","Could not serialize mimeData"));
389 }
390
391 return d->service->CreatePaste(appId, surfaceId, serializedMimeData, mimeData.formats());
392}
393
394bool cuc::Hub::createPasteSync(const QString &surfaceId, const QMimeData& data)
395{
396 QDBusPendingCall reply = createPaste(surfaceId, data);
397 reply.waitForFinished();
398 return !reply.isError();
399}
400
401QDBusPendingCall cuc::Hub::requestLatestPaste(const QString &surfaceId)
402{
403 TRACE() << Q_FUNC_INFO;
404 return d->service->GetLatestPasteData(surfaceId);
405}
406
407QDBusPendingCall cuc::Hub::requestPasteById(const QString &surfaceId, int pasteId)
408{
409 TRACE() << Q_FUNC_INFO;
410 return d->service->GetPasteData(surfaceId, QString::number(pasteId));
411}
412
413QMimeData* cuc::Hub::paste(QDBusPendingCall pendingCall)
414{
415 auto reply = QDBusPendingReply<QByteArray>(pendingCall);
416 reply.waitForFinished();
417
418 if (reply.isError())
419 return nullptr;
420
421 QByteArray serializedMimeData = qdbus_cast<QByteArray>(reply.value());
422 return deserializeMimeData(serializedMimeData);
423}
424
425QMimeData* cuc::Hub::latestPaste(const QString &surfaceId)
426{
427 return paste(requestLatestPaste(surfaceId));
428}
429
430QMimeData* cuc::Hub::pasteById(const QString &surfaceId, int pasteId)
431{
432 return paste(requestPasteById(surfaceId, pasteId));
433}
434
435QStringList cuc::Hub::pasteFormats() {
436 TRACE() << Q_FUNC_INFO;
437 return d->pasteFormats;
438}
343439
=== added file 'src/com/ubuntu/content/paste.cpp'
--- src/com/ubuntu/content/paste.cpp 1970-01-01 00:00:00 +0000
+++ src/com/ubuntu/content/paste.cpp 2016-08-25 13:22:47 +0000
@@ -0,0 +1,50 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */
18
19#include <com/ubuntu/content/paste.h>
20
21#include "paste_p.h"
22#include "utils.cpp"
23
24namespace cuc = com::ubuntu::content;
25
26cuc::Paste::Paste(const QSharedPointer<cuc::Paste::Private>& d, QObject* parent)
27 : QObject(parent),
28 d(d)
29{
30}
31
32cuc::Paste::~Paste()
33{
34 TRACE() << Q_FUNC_INFO;
35}
36
37int cuc::Paste::id() const
38{
39 return d->id();
40}
41
42QMimeData* cuc::Paste::mimeData()
43{
44 return deserializeMimeData(d->mimeData());
45}
46
47QString cuc::Paste::source() const
48{
49 return d->source();
50}
051
=== added file 'src/com/ubuntu/content/paste_p.h'
--- src/com/ubuntu/content/paste_p.h 1970-01-01 00:00:00 +0000
+++ src/com/ubuntu/content/paste_p.h 2016-08-25 13:22:47 +0000
@@ -0,0 +1,100 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */
18#ifndef COM_UBUNTU_CONTENT_PASTE_P_H_
19#define COM_UBUNTU_CONTENT_PASTE_P_H_
20
21#include "common.h"
22#include "ContentPasteInterface.h"
23
24#include <com/ubuntu/content/item.h>
25#include <com/ubuntu/content/paste.h>
26
27#include <QByteArray>
28#include <QMimeData>
29#include <QObject>
30
31namespace com
32{
33namespace ubuntu
34{
35namespace content
36{
37class Paste::Private : public QObject
38{
39 Q_OBJECT
40 public:
41 static Paste* make_paste(const QDBusObjectPath& paste, QObject* parent)
42 {
43 QSharedPointer<Private> d{new Private{paste, parent}};
44 return new Paste{d, parent};
45 }
46
47 Private(const QDBusObjectPath& paste, QObject* parent)
48 : QObject(parent),
49 remote_paste(
50 new com::ubuntu::content::dbus::Paste(
51 HUB_SERVICE_NAME,
52 paste.path(),
53 QDBusConnection::sessionBus(), this))
54 {
55 }
56
57 int id()
58 {
59 auto reply = remote_paste->Id();
60 reply.waitForFinished();
61
62 return reply.value();
63 }
64
65 State state()
66 {
67 auto reply = remote_paste->State();
68 reply.waitForFinished();
69
70 return static_cast<Paste::State>(reply.value());
71 }
72
73 QByteArray mimeData()
74 {
75 auto reply = remote_paste->MimeData();
76 reply.waitForFinished();
77
78 if (reply.isError())
79 return nullptr;
80
81 QByteArray serializedMimeData = qdbus_cast<QByteArray>(reply.value());
82
83 return serializedMimeData;
84 }
85
86 QString source()
87 {
88 auto reply = remote_paste->source();
89 reply.waitForFinished();
90
91 return static_cast<QString>(reply.value());
92 }
93
94 com::ubuntu::content::dbus::Paste* remote_paste;
95};
96}
97}
98}
99
100#endif // COM_UBUNTU_CONTENT_PASTE_P_H_
0101
=== modified file 'src/com/ubuntu/content/utils.cpp'
--- src/com/ubuntu/content/utils.cpp 2015-10-23 15:12:48 +0000
+++ src/com/ubuntu/content/utils.cpp 2016-08-25 13:22:47 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as5 * it under the terms of the GNU Lesser General Public License version 3 as
@@ -20,6 +20,7 @@
20#include <QDir>20#include <QDir>
21#include <QFile>21#include <QFile>
22#include <QFileInfo>22#include <QFileInfo>
23#include <QMimeData>
23#include <QProcess>24#include <QProcess>
24#include <QtCore>25#include <QtCore>
25#include <QtDBus/QDBusMessage>26#include <QtDBus/QDBusMessage>
@@ -33,6 +34,9 @@
33#include "com/ubuntu/content/type.h"34#include "com/ubuntu/content/type.h"
34#include <unistd.h>35#include <unistd.h>
35#include <liblibertine/libertine.h>36#include <liblibertine/libertine.h>
37#include <ubuntu-app-launch/appid.h>
38#include <ubuntu-app-launch/application.h>
39#include <ubuntu-app-launch/registry.h>
3640
37#include <sys/apparmor.h>41#include <sys/apparmor.h>
38/* need to be exposed in libapparmor but for now ... */42/* need to be exposed in libapparmor but for now ... */
@@ -40,9 +44,100 @@
40#define AA_MAY_READ (1 << 2)44#define AA_MAY_READ (1 << 2)
4145
42namespace cuc = com::ubuntu::content;46namespace cuc = com::ubuntu::content;
47namespace ual = ubuntu::app_launch;
4348
44namespace {49namespace {
4550
51/* Used for pasteboard */
52const int maxFormatsCount = 16;
53const int maxBufferSize = 4 * 1024 * 1024; // 4 Mb
54
55/*
56 Data format:
57 number of mime types (sizeof(int))
58 data layout ((4 * sizeof(int)) * number of mime types)
59 mime type string offset (sizeof(int))
60 mime type string size (sizeof(int))
61 data offset (sizeof(int))
62 data size (sizeof(int))
63 data (n bytes)
64*/
65QByteArray serializeMimeData(const QMimeData &mimeData)
66{
67 const QStringList formats = mimeData.formats();
68 const int formatCount = qMin(formats.size(), maxFormatsCount);
69 const int headerSize = sizeof(int) + (formatCount * 4 * sizeof(int));
70 int bufferSize = headerSize;
71
72 for (int i = 0; i < formatCount; i++)
73 bufferSize += formats[i].size() + mimeData.data(formats[i]).size();
74
75 QByteArray serializedMimeData;
76 if (bufferSize <= maxBufferSize) {
77 // Serialize data.
78 serializedMimeData.resize(bufferSize);
79 {
80 char *buffer = serializedMimeData.data();
81 int* header = reinterpret_cast<int*>(serializedMimeData.data());
82 int offset = headerSize;
83 header[0] = formatCount;
84 for (int i = 0; i < formatCount; i++) {
85 const QByteArray data = mimeData.data(formats[i]);
86 const int formatOffset = offset;
87 const int formatSize = formats[i].size();
88 const int dataOffset = offset + formatSize;
89 const int dataSize = data.size();
90 memcpy(&buffer[formatOffset], formats[i].toLatin1().data(), formatSize);
91 memcpy(&buffer[dataOffset], data.data(), dataSize);
92 header[i*4+1] = formatOffset;
93 header[i*4+2] = formatSize;
94 header[i*4+3] = dataOffset;
95 header[i*4+4] = dataSize;
96 offset += formatSize + dataSize;
97 }
98 }
99 } else {
100 qWarning("Not sending contents (%d bytes) to the global clipboard as it's"
101 " bigger than the maximum allowed size of %d bytes", bufferSize, maxBufferSize);
102 }
103
104 return serializedMimeData;
105}
106
107QMimeData *deserializeMimeData(const QByteArray &serializedMimeData)
108{
109 if (static_cast<std::size_t>(serializedMimeData.size()) < sizeof(int)) {
110 // Data is invalid
111 return nullptr;
112 }
113
114 QMimeData *mimeData = new QMimeData;
115
116 const char* const buffer = serializedMimeData.constData();
117 const int* const header = reinterpret_cast<const int*>(serializedMimeData.constData());
118
119 const int count = qMin(header[0], maxFormatsCount);
120
121 for (int i = 0; i < count; i++) {
122 const int formatOffset = header[i*4+1];
123 const int formatSize = header[i*4+2];
124 const int dataOffset = header[i*4+3];
125 const int dataSize = header[i*4+4];
126
127 if (formatOffset + formatSize <= serializedMimeData.size()
128 && dataOffset + dataSize <= serializedMimeData.size()) {
129
130 QString mimeType = QString::fromLatin1(&buffer[formatOffset], formatSize);
131 QByteArray mimeDataBytes(&buffer[dataOffset], dataSize);
132
133 mimeData->setData(mimeType, mimeDataBytes);
134 }
135 }
136
137 return mimeData;
138}
139
140
46QList<cuc::Type> known_types()141QList<cuc::Type> known_types()
47{142{
48 QList<cuc::Type> types;143 QList<cuc::Type> types;
@@ -104,6 +199,29 @@
104}199}
105200
106201
202bool app_id_matches(QString id, pid_t pid)
203{
204 TRACE() << Q_FUNC_INFO << id << pid;
205
206 /* Don't verify app_id while testing */
207 if (!qgetenv("CONTENT_HUB_TESTING").isNull())
208 return true;
209
210 std::shared_ptr<ual::Registry> reg = ual::Registry::getDefault();
211 auto app_id = ual::AppID::find(id.toStdString());
212 if (app_id.empty())
213 return false;
214 auto app = ual::Application::create(app_id, reg);
215 if (!app.get()->hasInstances())
216 return false;
217 Q_FOREACH (std::shared_ptr<ual::Application::Instance> instance, app.get()->instances()) {
218 if (instance.get()->hasPid(pid))
219 return true;
220 }
221 return false;
222}
223
224
107QString aa_profile(QString uniqueConnectionId)225QString aa_profile(QString uniqueConnectionId)
108{226{
109 TRACE() << Q_FUNC_INFO << uniqueConnectionId;227 TRACE() << Q_FUNC_INFO << uniqueConnectionId;
@@ -235,7 +353,7 @@
235 qWarning() << "error:" << strerror(errno) << path;353 qWarning() << "error:" << strerror(errno) << path;
236 return false;354 return false;
237 }355 }
238 356
239 if (allowed) {357 if (allowed) {
240 TRACE() << "ALLOWED:" << QString::number(allowed);358 TRACE() << "ALLOWED:" << QString::number(allowed);
241 return true;359 return true;
242360
=== modified file 'tests/acceptance-tests/CMakeLists.txt'
--- tests/acceptance-tests/CMakeLists.txt 2015-06-29 13:46:54 +0000
+++ tests/acceptance-tests/CMakeLists.txt 2016-08-25 13:22:47 +0000
@@ -41,6 +41,12 @@
41)41)
4242
43add_executable(43add_executable(
44 app_hub_communication_paste
45 app_hub_communication_paste.cpp
46 ${MOCS}
47)
48
49add_executable(
44 app_hub_communication_handler50 app_hub_communication_handler
45 app_hub_communication_handler.cpp51 app_hub_communication_handler.cpp
46 ${MOCS}52 ${MOCS}
@@ -68,32 +74,47 @@
68 source_all.json74 source_all.json
69)75)
7076
77add_executable(
78 mimedata_test
79 mimedata_test.cpp
80 ${MOCS}
81)
82
71qt5_use_modules(app_hub_communication_default_source Core Gui DBus Test)83qt5_use_modules(app_hub_communication_default_source Core Gui DBus Test)
72qt5_use_modules(app_hub_communication_known_sources Core Gui DBus Test)84qt5_use_modules(app_hub_communication_known_sources Core Gui DBus Test)
73qt5_use_modules(app_hub_communication_stores Core Gui DBus Test)85qt5_use_modules(app_hub_communication_stores Core Gui DBus Test)
74qt5_use_modules(app_hub_communication_transfer Core Gui DBus Test)86qt5_use_modules(app_hub_communication_transfer Core Gui DBus Test)
87qt5_use_modules(app_hub_communication_paste Core Gui DBus Test)
75qt5_use_modules(app_hub_communication_handler Core Gui DBus Test)88qt5_use_modules(app_hub_communication_handler Core Gui DBus Test)
76qt5_use_modules(test_utils Core Test)89qt5_use_modules(test_utils Core Test)
77qt5_use_modules(test_hook Core Gui DBus Test)90qt5_use_modules(test_hook Core Gui DBus Test)
91qt5_use_modules(mimedata_test Core Test)
7892
79target_link_libraries(app_hub_communication_stores content-hub gmock gtest gtest_main)93target_link_libraries(app_hub_communication_stores content-hub gmock gtest gtest_main)
80target_link_libraries(app_hub_communication_default_source content-hub gmock gtest gtest_main)94target_link_libraries(app_hub_communication_default_source content-hub gmock gtest gtest_main)
81target_link_libraries(app_hub_communication_known_sources content-hub gmock gtest gtest_main)95target_link_libraries(app_hub_communication_known_sources content-hub gmock gtest gtest_main)
82target_link_libraries(app_hub_communication_stores content-hub gmock gtest gtest_main)96target_link_libraries(app_hub_communication_stores content-hub gmock gtest gtest_main)
83target_link_libraries(app_hub_communication_transfer content-hub gmock gtest gtest_main)97target_link_libraries(app_hub_communication_transfer content-hub gmock gtest gtest_main)
98target_link_libraries(app_hub_communication_paste content-hub gmock gtest gtest_main)
84target_link_libraries(app_hub_communication_handler content-hub gmock gtest gtest_main)99target_link_libraries(app_hub_communication_handler content-hub gmock gtest gtest_main)
85target_link_libraries(test_utils content-hub gmock gtest gtest_main)100target_link_libraries(test_utils content-hub gmock gtest gtest_main)
86target_link_libraries(test_types content-hub gmock gtest gtest_main)101target_link_libraries(test_types content-hub gmock gtest gtest_main)
87target_link_libraries(test_hook content-hub gmock gtest gtest_main ${GSETTINGS_LDFLAGS})102target_link_libraries(test_hook content-hub gmock gtest gtest_main ${GSETTINGS_LDFLAGS})
103target_link_libraries(mimedata_test content-hub gmock gtest gtest_main)
88104
89add_test(app_hub_communication_default_source app_hub_communication_default_source)105add_test(app_hub_communication_default_source app_hub_communication_default_source)
90add_test(app_hub_communication_known_sources app_hub_communication_known_sources)106add_test(app_hub_communication_known_sources app_hub_communication_known_sources)
91add_test(app_hub_communication_stores app_hub_communication_stores)107add_test(app_hub_communication_stores app_hub_communication_stores)
92add_test(app_hub_communication_transfer app_hub_communication_transfer)108add_test(app_hub_communication_transfer app_hub_communication_transfer)
109add_test(app_hub_communication_paste app_hub_communication_transfer)
93add_test(app_hub_communication_handler app_hub_communication_handler)110add_test(app_hub_communication_handler app_hub_communication_handler)
94add_test(test_utils test_utils)111add_test(test_utils test_utils)
95add_test(test_types test_types)112add_test(test_types test_types)
96add_test(test_hook test_hook)113add_test(test_hook test_hook)
114add_test(mimedata_test mimedata_test)
115
116SET_TESTS_PROPERTIES(app_hub_communication_paste
117 PROPERTIES ENVIRONMENT "CONTENT_HUB_TESTING=1")
97118
98set_target_properties(119set_target_properties(
99 test_hook120 test_hook
100121
=== added file 'tests/acceptance-tests/app_hub_communication_paste.cpp'
--- tests/acceptance-tests/app_hub_communication_paste.cpp 1970-01-01 00:00:00 +0000
+++ tests/acceptance-tests/app_hub_communication_paste.cpp 2016-08-25 13:22:47 +0000
@@ -0,0 +1,138 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ken VanDine <ken.vandine@canonical.com>
17 */
18
19#include "app_manager_mock.h"
20#include "test_harness.h"
21#include "../cross_process_sync.h"
22#include "../fork_and_run.h"
23
24#include <com/ubuntu/content/hub.h>
25#include <com/ubuntu/content/item.h>
26#include <com/ubuntu/content/paste.h>
27
28#include "com/ubuntu/content/detail/peer_registry.h"
29#include "com/ubuntu/content/detail/service.h"
30#include "com/ubuntu/content/serviceadaptor.h"
31
32#include <gmock/gmock.h>
33#include <gtest/gtest.h>
34
35#include <QCoreApplication>
36#include <QtDBus/QDBusConnection>
37#include <QStandardPaths>
38#include <QTemporaryDir>
39#include <QtTest/QTest>
40
41#include <thread>
42
43namespace cua = com::ubuntu::ApplicationManager;
44namespace cuc = com::ubuntu::content;
45namespace cucd = com::ubuntu::content::detail;
46
47void PrintTo(const QString& s, ::std::ostream* os) {
48 *os << std::string(qPrintable(s));
49}
50
51namespace
52{
53QString service_name{"com.ubuntu.content.dbus.Service"};
54
55struct MockedPeerRegistry : public cucd::PeerRegistry
56{
57 MockedPeerRegistry() : cucd::PeerRegistry()
58 {
59 using namespace ::testing;
60
61 ON_CALL(*this, default_source_for_type(_)).WillByDefault(Return(cuc::Peer::unknown()));
62 ON_CALL(*this, install_default_source_for_type(_,_)).WillByDefault(Return(false));
63 ON_CALL(*this, install_source_for_type(_,_)).WillByDefault(Return(false));
64 }
65
66 MOCK_METHOD1(default_source_for_type, cuc::Peer(cuc::Type t));
67 MOCK_METHOD1(enumerate_known_peers, void(const std::function<void(const cuc::Peer&)>&));
68 MOCK_METHOD2(enumerate_known_sources_for_type, void(cuc::Type, const std::function<void(const cuc::Peer&)>&));
69 MOCK_METHOD2(enumerate_known_destinations_for_type, void(cuc::Type, const std::function<void(const cuc::Peer&)>&));
70 MOCK_METHOD2(enumerate_known_shares_for_type, void(cuc::Type, const std::function<void(const cuc::Peer&)>&));
71 MOCK_METHOD2(install_default_source_for_type, bool(cuc::Type, cuc::Peer));
72 MOCK_METHOD2(install_source_for_type, bool(cuc::Type, cuc::Peer));
73 MOCK_METHOD2(install_destination_for_type, bool(cuc::Type, cuc::Peer));
74 MOCK_METHOD2(install_share_for_type, bool(cuc::Type, cuc::Peer));
75 MOCK_METHOD1(remove_peer, bool(cuc::Peer));
76 MOCK_METHOD1(peer_is_legacy, bool(QString));
77};
78}
79
80TEST(Hub, transfer_creation_and_states_work)
81{
82 using namespace ::testing;
83
84 test::CrossProcessSync sync;
85
86 auto parent = [&sync]()
87 {
88 int argc = 0;
89 QCoreApplication app{argc, nullptr};
90
91 QDBusConnection connection = QDBusConnection::sessionBus();
92
93 auto mock = new ::testing::NiceMock<MockedPeerRegistry>{};
94
95 QSharedPointer<cucd::PeerRegistry> registry{mock};
96 auto app_manager = QSharedPointer<cua::ApplicationManager>(new MockedAppManager());
97 cucd::Service implementation(connection, registry, app_manager, &app);
98 new ServiceAdaptor(std::addressof(implementation));
99
100 ASSERT_TRUE(connection.registerService(service_name));
101 ASSERT_TRUE(connection.registerObject("/", std::addressof(implementation)));
102
103 sync.signal_ready();
104
105 app.exec();
106
107 connection.unregisterObject("/");
108 connection.unregisterService(service_name);
109 };
110
111 auto child = [&sync]()
112 {
113 int argc = 0;
114 QCoreApplication app(argc, nullptr);
115
116 sync.wait_for_signal_ready();
117
118 test::TestHarness harness;
119 harness.add_test_case([]()
120 {
121 qputenv("APP_ID", "some-app");
122
123 QMimeData data;
124 data.setText("some text");
125 auto hub = cuc::Hub::Client::instance();
126 QString surfaceId("some-bogus-fake-surface-id");
127 bool ok = hub->createPasteSync(surfaceId, const_cast<const QMimeData&>(data));
128 ASSERT_TRUE(ok);
129 EXPECT_EQ(QString(data.text()), QString(hub->latestPaste(surfaceId)->text()));
130 EXPECT_EQ(QString(data.text()), QString(hub->pasteById(surfaceId, 1)->text()));
131
132 hub->quit();
133 });
134 EXPECT_EQ(0, QTest::qExec(std::addressof(harness)));
135 };
136
137 EXPECT_EQ(EXIT_SUCCESS, test::fork_and_run(child, parent));
138}
0139
=== added file 'tests/acceptance-tests/mimedata_test.cpp'
--- tests/acceptance-tests/mimedata_test.cpp 1970-01-01 00:00:00 +0000
+++ tests/acceptance-tests/mimedata_test.cpp 2016-08-25 13:22:47 +0000
@@ -0,0 +1,44 @@
1/*
2 * Copyright (C) 2014-2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <gtest/gtest.h>
18
19#include "../../src/com/ubuntu/content/utils.cpp"
20
21#include <QMimeData>
22
23TEST(PasteBoardTest, MimeDataSerialization)
24{
25 QMimeData mimeData;
26 mimeData.setData("text/plain", "Hello World!");
27 mimeData.setData("text/html", "<html lang=\"en\"><body>Hello World!</body></html>");
28
29 QByteArray serializedMimeData = serializeMimeData(const_cast<const QMimeData&>(mimeData));
30
31 ASSERT_TRUE(serializedMimeData.size() > 0);
32
33 QMimeData *deserializedMimeData = deserializeMimeData(serializedMimeData);
34
35 ASSERT_TRUE(deserializedMimeData != nullptr);
36
37 ASSERT_TRUE(deserializedMimeData->hasFormat("text/plain"));
38 ASSERT_EQ(mimeData.data("text/plain"), deserializedMimeData->data("text/plain"));
39
40 ASSERT_TRUE(deserializedMimeData->hasFormat("text/html"));
41 ASSERT_EQ(mimeData.data("text/html"), deserializedMimeData->data("text/html"));
42
43 delete deserializedMimeData;
44}

Subscribers

People subscribed via source and target branches