Content Hub from webapp
-
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?
-
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-descriptionYou can also try the telegram group if you cannot find more help here on the forum: https://t.me/UbuntuAppDevEN
Good luck.
-
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...
-
@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.
-
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-descriptionYou can also try the telegram group if you cannot find more help here on the forum: https://t.me/UbuntuAppDevEN
Good luck.
-
@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.
-
-
-
@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. -