apparmor picture_files_read
-
I'm working on an app that needs permissions to access the user's Pictures directory. I'm programming with C++ and SDL. I set this in my apparmor file:
{
"policy_groups": [
"audio",
"picture_files_read"
],
"policy_version": 16.04
}I am able to access the app's directory here:
/home/phablet/.local/share/appname.craig/
I can read and write to that directory.However, I am not able to read files from this directory:
/home/phablet/PicturesIs there something I have over looked?
Thank you for your help.
-
@Craig Hi Craig,
Short answer, please read this page :
http://docs.ubports.com/en/latest/appdev/platform/apparmor.html#picture-files-readDevelopers should typically use the content_exchange policy group and API to access picture files instead
You might want to use :
http://docs.ubports.com/en/latest/appdev/guides/contenthub.htmlI don't know about how to use the reserved rights but I'll advise to follow the common rules and use the content hub.
-
@AppLee Thank you. I read those pages before and I read them again. I added hooks in my manifest.json and a contenthub.json file. I see my app listed when I open Gallery, select a photo and click the share icon.
I'm programming my app in C++ and SDL2. So my question is: How can I get my app to open the content hub so a user can select a photo from their Gallery?
-
@Craig have you tried Telegram AppDev group ?, or maybe create a new topic for this issue
-
@AppLee I'm getting my C++/SDL app to receive pictures from the content hub as you suggested. I hope this can serve as a half-way tutorial for others out there. But it's not complete. Here is what I have so far:
In my manifest.json, I have "content-hub" in the hooks section:
"hooks": { "SDLTest": { "apparmor": "SDLTest.apparmor", "desktop": "SDLTest.desktop", "content-hub": "SDLTest-contenthub.json" }In SDLTest-contenthub.json I have "pictures":
{
"destination": [
"pictures"
]
}In SDLTest.apparmor I have "content_exchange":
{
"policy_groups": [
"audio",
"content_exchange"
],
"policy_version": 16.04
}After I run "clickable", I open the Gallery app, select a photo and click on the link icon, I see my app listed. After I selected my app, I used "adb shell" and found the photo I selected on my phone at this system path:
/home/phablet/.cache/sdltest.craig/HubIncoming/18And I had read/write access to the photos with C++. This part works great so far!
But all I need to understand now is how to I get my app to LAUNCH Gallery when a user clicks a button inside my app. I'm using purely C++ and SDL. I imagine it would work something like this:
if ( event.type == SDL_FINGERDOWN ) {
SomeFunctionHere(LaunchGallery);
}Detailed instructions would be appreciated. You wont bore me.
-
@Craig I dont think that its supported for an App to launch another app. You could export a picture and then the suer canchoose Gallery as a target. But so far just launching a specific app is not possible. Its also hard to make this stable since what if Gallery app is not installed, has been renamed etc ?
-
@Craig
Hi, and good job on this.
Now you want to use the content hub the other way around and export a picture from your app.You'll have to add
ContentHandler.Sourceto your SDLTest-contenthub.json
You should read this : http://docs.ubports.com/en/latest/appdev/guides/contenthub.html#exportingAs Flo wrote, you cannot force an app, the user has to select the destination app.
-
@Flohack What about when the Messaging app launches the content hub so I can attach an image to a text message?
-
@Craig
What Florian meant is that an app cannot directly opens another one (even less a specific one).
You have to go through the Content Hub to do so, but it's not the messaging app opening the gallery... -
@AppLee Why would I want to export a picture from my app when that's not what it needs to do? It needs to acquire a picture from the content hub, namely Gallery or File Manager. Sorry, maybe I didn't make it clear what I'm trying to do.
-
@AppLee Sorry, I must not be using the right vocabulary. Basically, like how the Messaging app opens the content hub and you can choose from Gallery or File Manager, then a photo is sent to a directory where the Messaging app can access it. How can I get my C++ app to open/launch/etc the content hub? I have already added the required code for my app to be listed as a "destination" in the content hub. I just need to understand how to create an event/link/etc in C++ that will open the content hub for my app's users. Thank you!
-
@Craig
Oh sorry, I ddin't fully understand your question.So you can refer there : http://docs.ubports.com/en/latest/appdev/guides/contenthub.html#importing
You can call theContentPeerPickerin your code to display the app choice to import a Picture from. -
@AppLee I read that Importing section, thanks. What language is that written in? Qml? My app is written in C++. Is there a way to open the content hub with C++? Or is there some headers I can put in my C++ program that will enable a new function to do that? I can't seem to find documentation for C++.
-
@Craig
Yes it's QML, I don't know about C++ only.
Can you consider some QML for the front part of your app ?
It's not difficult to learn and use. -
@AppLee Okay, I tried it. I did "clickable create" and selected the C++ binary option.
When I run "clickable" the main.cpp file calls qml/Main.qml and it says "Hello World!" on my touch device.
Now, I tried to swap the code in Main.qml for this code here:
https://api-docs.ubports.com/sdk/apps/qml/Ubuntu.Content/ContentHub.html
The code just below "Example usage for importing content:"When I run "clickable", clickable reports: /bin/sh: 1: Syntax error: "(" unexpected
Is there a mistake in the documented code? What do I need to put in the Main.qml file so it brings up the content hub?
Thanks!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register Login