Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.


I'm writing an app and I'm trying to incorporate content hub into it.
My app downloads various file formats so I want to be able to export images, videos and other types of content to other apps.
I followed this content hub guide but found it lacking in examples for exporting content.
Anyway, when I'm trying to export any content, the transfer's state always changes to "aborted" immediately and I have no idea why.
Here is my OpenContentPopup component:

PopupBase {
    id: root

    property var activeTransfer
    property var items: []
    property alias contentType: peerPicker.contentType

    Connections {
        target: activeTransfer
        onStateChanged: {
            console.log("Transfer state changed to " + activeTransfer.state)
        }
    }

    ContentPeerPicker {
        id: peerPicker
        handler: ContentHandler.Destination

        onPeerSelected: {
            for (var i = 0; i < items.length; i++) {
                console.log("Sharing item with name: " + items[i].name + ", url: " + items[i].url)
            }

            activeTransfer = peer.request()
            activeTransfer.items = root.items
            activeTransfer.state = ContentTransfer.Charged
            PopupUtils.close(root)
        }

        onCancelPressed: {
            PopupUtils.close(root)
        }
    }
}

When I'm trying to export an image the ContentPeerPicker gives me the option to open the Gallery app, but when I select the gallery app the gallery app isn't opened and it appears that the transfer's state is aborted (or 5..).
My logs in the code example give me:

<debug> Sharing item with name: name, url: file:///home/phablet/.local/share/com.nogzatalz.downow/download/Cover.jpg
<debug> Transfer state changed to 5

manifest.json:

{
    "name": "com.nogzatalz.downow",
    "description": "Torrent downloading app",
    "framework": "ubuntu-sdk-14.10-qml-dev3",
    "architecture": "armhf",
    "title": "DowNow",
    "hooks": {
        "downow": {
            "desktop": "downow.desktop",
            "apparmor": "apparmor.json",
            "urls": "urldispatcher.json",
            "content-hub": "content-hub.json"
        }
    },
    "version": "0.1.28",
    "maintainer": "DowNow Support <downow-support@nogzatalz.com>"
}

content-hub.json:

{
    "source": [
        "pictures",
        "videos"
    ]
}

apparmor.json:

{
    "policy_groups": [
        "networking",
        "content_exchange",
        "content_exchange_source",
        "audio"
    ],
    "policy_version": 1.2
}

I really think we need better error messages..
Any help is appreciated!
Thanks, Tal

share|improve this question
    
Shouldn't it be activeTransfer.start() ? –  user2563892 Aug 15 at 11:26
    
I see you've taken it out of webbrowser-app –  user2563892 Aug 15 at 11:36
    
Here are the files for the Sharing in webbrowser-app: bazaar.launchpad.net/~phablet-team/webbrowser-app/trunk/files/… –  user2563892 Aug 15 at 11:41
    
Yeah, I did use the ContentShareDialog.qml file from webbrowser-app as a base. Although I can't see what I'm doing wrong here.. –  meta221 Aug 15 at 12:56
    
I tried also adding activeTransfer.start() but that did not help. –  meta221 Aug 15 at 12:57

2 Answers 2

I think the problem is you are trying to charge it before the transfer is ready. Look at this as an example:

http://bazaar.launchpad.net/~ken-vandine/+junk/hub-exporter/view/head:/hub-exporter.qml#L426

share|improve this answer

Apparently the code I shared was correct.
In my main function I had:

setenv("APP_ID", "com.nogzatalz.downow", /*overwrite*/ true);

I guess that messed up app armor..
I only put it there because I used to get errors about APP_ID not being set or something..
Anyway, Thanks for all your help everyone! =)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.