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

Content Hub from webapp

Scheduled Pinned Locked Moved Solved App Development
webappcontent-hub
6 Posts 2 Posters 301 Views 1 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.
    • P Offline
      Plarde
      last edited by 1 Jun 2024, 15:18

      I'm developing a webapp and I'd like to let users export files from my app. I planned to do this using an <a href="data:image/png;base64,..." download="myfile.png">.

      I added the "content-hub": "appname-contenthub.json" line in the manifest, set destination, share and source to "all" in that file, and I added the "content_exchange" policy group in the apparmor file.

      It seems to be the intended way of working because it unlocks the Content Hub, but whenever I download the file and try to share it elsewhere, whenever I tap an external application, it doesn't react.

      When I check the log, I see these 3 lines whenever I tap an app in the content hub view:

      Jun 01 11:07:37 ubuntu-phablet aa-exec[14559]: Dbus error:  QDBusError("org.freedesktop.DBus.Error.AccessDenied", "An AppArmor policy prevents this sender from sending this message to this recipient; type=\"method_call\", sender=\":1.458\" (uid=32011 pid=14559 comm=\"webapp-container --app-id=appname.yourname www/ind\" label=\"appname.yourname_appname_1.0.0 (enforce)\") interface=\"com.lomiri.content.dbus.Transfer\" member=\"Direction\" error name=\"(unset)\" requested_reply=\"0\" destination=\"com.lomiri.content.dbus.Service\" (uid=32011 pid=14637 comm=\"/usr/bin/content-hub-service \" label=\"unconfined\")")
      Jun 01 11:07:37 ubuntu-phablet aa-exec[14559]: Dbus error:  QDBusError("org.freedesktop.DBus.Error.AccessDenied", "An AppArmor policy prevents this sender from sending this message to this recipient; type=\"method_call\", sender=\":1.458\" (uid=32011 pid=14559 comm=\"webapp-container --app-id=appname.yourname www/ind\" label=\"appname.yourname_appname_1.0.0 (enforce)\") interface=\"com.lomiri.content.dbus.Transfer\" member=\"SelectionType\" error name=\"(unset)\" requested_reply=\"0\" destination=\"com.lomiri.content.dbus.Service\" (uid=32011 pid=14637 comm=\"/usr/bin/content-hub-service \" label=\"unconfined\")")
      Jun 01 11:07:37 ubuntu-phablet aa-exec[14559]: Dbus error:  QDBusError("org.freedesktop.DBus.Error.AccessDenied", "An AppArmor policy prevents this sender from sending this message to this recipient; type=\"method_call\", sender=\":1.458\" (uid=32011 pid=14559 comm=\"webapp-container --app-id=appname.yourname www/ind\" label=\"appname.yourname_appname_1.0.0 (enforce)\") interface=\"com.lomiri.content.dbus.Transfer\" member=\"State\" error name=\"(unset)\" requested_reply=\"0\" destination=\"com.lomiri.content.dbus.Service\" (uid=32011 pid=14637 comm=\"/usr/bin/content-hub-service \" label=\"unconfined\")")
      

      Is this a problem with my app, or an issue with Ubuntu Touch security?

      A 1 Reply Last reply 1 Jun 2024, 21:34 Reply Quote 0
      • A Offline
        AppLee @Plarde
        last edited by 2 Jun 2024, 11:47

        Hi @Plarde

        First of all, you lack permission in the apparmor file.
        content_exchange_source

        Then you're not doing anything, so I suppose this is just a simple inheritance from Morph Browser that do not share the file as intended.
        I never tried webapp so I don't know how to actually do it, but I guess you'll have to somehow to overload the class in order to specify that you are sharing a picture...

        You will have to give something to the Content Hub like the code snippet about onExportRequested here: https://ubports.gitlab.io/docs/api-docs/?p=lomiri-content-qml-api%2Fqml-lomiri-content-contenthub.html#detailed-description

        You can also try the telegram group if you cannot find more help here on the forum: https://t.me/UbuntuAppDevEN

        Good luck.

        P 1 Reply Last reply 2 Jun 2024, 17:34 Reply Quote 1
        • A Offline
          AppLee @Plarde
          last edited by 1 Jun 2024, 21:34

          Hi @Plarde

          Do you have a repository we can access to see your code and try to help?
          What comes to mind is probably an issue with the file path or an issue in the apparmor file...

          I have no direct experience with the Content Hub but I know that filepath can be confusing...

          P 1 Reply Last reply 2 Jun 2024, 04:21 Reply Quote 0
          • P Offline
            Plarde @AppLee
            last edited by 2 Jun 2024, 04:21

            @AppLee Hey, thanks for checking!

            Here's a basic reproducible project: https://gitlab.com/Semphriss/ut-webapp-contenthub

            The first commit is a basic project as generated by Clickable, all the defaults except the project type set to HTML. I did not change any file.

            The second commit is the basic steps I followed to attempt to make it work, which will give the same behavior as I described.

            A 1 Reply Last reply 2 Jun 2024, 11:47 Reply Quote 0
            • A Offline
              AppLee @Plarde
              last edited by 2 Jun 2024, 11:47

              Hi @Plarde

              First of all, you lack permission in the apparmor file.
              content_exchange_source

              Then you're not doing anything, so I suppose this is just a simple inheritance from Morph Browser that do not share the file as intended.
              I never tried webapp so I don't know how to actually do it, but I guess you'll have to somehow to overload the class in order to specify that you are sharing a picture...

              You will have to give something to the Content Hub like the code snippet about onExportRequested here: https://ubports.gitlab.io/docs/api-docs/?p=lomiri-content-qml-api%2Fqml-lomiri-content-contenthub.html#detailed-description

              You can also try the telegram group if you cannot find more help here on the forum: https://t.me/UbuntuAppDevEN

              Good luck.

              P 1 Reply Last reply 2 Jun 2024, 17:34 Reply Quote 1
              • P Offline
                Plarde @AppLee
                last edited by 2 Jun 2024, 17:34

                @AppLee It works! Many, many thanks!

                For exporting, I will let the user tap the document in the download pop-up, and the webview will handle exporting. I tested it, and it seems to export as intended.

                I really should switch my app to use QML with a WebView object, but unfortunately I'm not remotely familiar enough with QML to implement it without help.

                If you (or any passerby) is curious about the app in question, it's here: https://github.com/Semphriss/Annotate. I'll upload it to the Open Store in a few days, after fixing the last few rough edges.

                Thanks again for the help! I'll see if I can switch this thread to a Q&A one so that I can accept your answer.

                A 1 Reply Last reply 2 Jun 2024, 18:04 Reply Quote 1
                • P Plarde marked this topic as a question on 2 Jun 2024, 17:34
                • P Plarde has marked this topic as solved on 2 Jun 2024, 17:35
                • A Offline
                  AppLee @Plarde
                  last edited by 2 Jun 2024, 18:04

                  @Plarde
                  I'm glad it worked.

                  Sure, I understand it's easier to start with a basis you master.
                  I personally forced myself to use pure QML as much as I can to teach me how it works.
                  And we have people that can help as well as good example to borrow some code.

                  Thanks for your contribution, it's always appreciated.
                  People usually agree that we need more native apps for Ubuntu Touch.

                  1 Reply Last reply Reply Quote 1
                  • A arubislander has marked this topic as solved on 3 Jun 2024, 05:44
                  6 out of 6
                  • First post
                    6/6
                    Last post