UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    apparmor picture_files_read

    Scheduled Pinned Locked Moved App Development
    15 Posts 4 Posters 1.1k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • CraigC Offline
        Craig @AppLee
        last edited by

        @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?

        lduboeufL 1 Reply Last reply Reply Quote 1
        • lduboeufL Offline
          lduboeuf @Craig
          last edited by

          @Craig have you tried Telegram AppDev group ?, or maybe create a new topic for this issue

          1 Reply Last reply Reply Quote 0
          • CraigC Offline
            Craig @AppLee
            last edited by

            @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/18

            And 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.

            flohackF AppLeeA 2 Replies Last reply Reply Quote 0
            • flohackF Offline
              flohack @Craig
              last edited by

              @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 ?

              My languages: πŸ‡¦πŸ‡Ή πŸ‡©πŸ‡ͺ πŸ‡¬πŸ‡§ πŸ‡ΊπŸ‡Έ

              CraigC 1 Reply Last reply Reply Quote 0
              • AppLeeA Offline
                AppLee @Craig
                last edited by

                @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.Source to your SDLTest-contenthub.json
                You should read this : http://docs.ubports.com/en/latest/appdev/guides/contenthub.html#exporting

                As Flo wrote, you cannot force an app, the user has to select the destination app.

                CraigC 1 Reply Last reply Reply Quote 0
                • CraigC Offline
                  Craig @flohack
                  last edited by

                  @Flohack What about when the Messaging app launches the content hub so I can attach an image to a text message?

                  AppLeeA 1 Reply Last reply Reply Quote 0
                  • AppLeeA Offline
                    AppLee @Craig
                    last edited by

                    @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...

                    CraigC 1 Reply Last reply Reply Quote 0
                    • CraigC Offline
                      Craig @AppLee
                      last edited by

                      @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.

                      1 Reply Last reply Reply Quote 0
                      • CraigC Offline
                        Craig @AppLee
                        last edited by

                        @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!

                        AppLeeA 1 Reply Last reply Reply Quote 0
                        • AppLeeA Offline
                          AppLee @Craig
                          last edited by

                          @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 the ContentPeerPicker in your code to display the app choice to import a Picture from.

                          CraigC 1 Reply Last reply Reply Quote 0
                          • CraigC Offline
                            Craig @AppLee
                            last edited by

                            @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++.

                            AppLeeA 1 Reply Last reply Reply Quote 0
                            • AppLeeA Offline
                              AppLee @Craig
                              last edited by

                              @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.

                              CraigC 1 Reply Last reply Reply Quote 0
                              • CraigC Offline
                                Craig @AppLee
                                last edited by

                                @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!

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post