Help me make a sharing plug-in

So… here we go.
Resources on making sharing plug-ins are scarce, but i finally found this:

Looks promising, but there are still some hurdles.
Having followed the previous recommendation of starting with this i found myself not being able to have code run in my uploader class. And since that is not needed in that particular project, perhaps starting from the example yields better results.

I have put up a copy of the example here https://github.com/attah/harbour-seaprint-share-plugin and will try to use this to document my journey to a working plug-in, so that others can use it as a reference. But i need help.

First off i spotted a syntax issue in the .pro file and will be fixing that shortly, but after that i still have issues with lrelease error: Cannot open translations/example_share_plugin-fi.ts: No such file or directory

And obviously that file exists… so i’m currently at a loss. Any ideas?
Once that is sorted i definitely count on there being more issues, so i’m hoping for the gracious help of this community. For more active discussions i can be found on #sailfishos on freenode IRC. I’ll summarize as needed here when things get sorted.

3 Likes

That pro file doesn’t work with shadow builds. So, as a first step, disable shadow builds. Second step, fix the pro file so that shadow builds work :wink:

1 Like

Thanks!
Disabling shadow builds indeed works around the issue. And as per your answer on IRC, i made the .pro file point by absolute path to the ts file, i.e. prepending it with $$PWD/.
Committed and pushed. :slight_smile:

1 Like

Next set of issues.
Despite capabilities only including “image/*” and “text/vcard” the plugin becomes available for sharing PDFs (that i accidentally tested by habit). Not a terrible problem, but curious…

Update: this was a leftover from previous installs with the same name. What types it is capable is evaluated at startup apparently. Makes sense.

More pressing, however, was that even if i share an image accepting to share it crashes in dbus marshalling with

[W] unknown:0 - QDBusMarshaller: cannot add a null QDBusVariant
dbus[23200]: Array or variant type requires that type variant be written, but end_dict_entry was written.
The overall signature expected here was 'sssba{sv}' and we are on byte 7 of that signature.
D-Bus not built with -rdynamic so unable to print a backtrace

Looks like the usage of root.scalePercent is not valid, as there is no such property, and object creation fails subsequently. Now let’s see if the uploader gets called :slight_smile:

Nope, now i’m back to what was stopping me before, but with a much cleaner environment. :slight_smile:
I can console.log() in onAccepted in the qml dialog, but it seems to never reach the uploader class (which is where i assume things happen next).

Maybe a qDebug() << “start”; in start() will not be visible in the same way as debugging from qml, but even exit(1) has no effect, not even in the constructor of the uploader class. Hmmm…

Update: Seems these c++ parts are kept running and survive installation (despite closing the app used to test), so a reboot of the phone did the trick. Ideas facilitating a faster turnaround would be much appreciated.

I have now renamed the files and classes to match my intention with the plug-in.
With this i could not get translations working; and realizing it wasn’t really working (at least not the way i expected) to start with… it has been torn out. I think there is a grand total of one non-name string that is affected… good enough. So for dressing this up as a future example, translations is a thing to make more workable, but i couldn’t make it happen now.

Apart from looking at what the qml dialog should actually contain, i really only have one thing left to fix, since the action itself is pretty trivial.
I can’t get the icon to show up in the sharing menu. I have assumed it is ::serviceIcon() that does that, but various attempts of pointing to the icons in SeaPrint does not seem to work, nor did the original example of QUrl(“image://theme/icon-s-message”);

Any ideas?

why don’t you check how existing plugins do work ?
there are 3-4 i know about. there should be some code somehere.
there is a plugin for nextcloud by beidl, one for clipboard by miklos and depecher comes with plugin too.

Well, that’s where I started… and i stumbled over a few examples that had been stripped beyond what i needed. When i found a complete-looking skeleton, i decided to make my journey in the open so that others might benefit. After all a basic skeleton like that is my preferred starting point, and i would like to give others the opportunity to start from there too. (this is an undercover semi-tutorial)

As to why i didn’t check those specific ones… i didn’t find them. Thanks for pointing them out, it will be worth revisiting for seeing if they have working icons.

I’m not sure i follow… what did you get working?
Showing sharing plugins in your app?
That’s not what i want, i’m making a sharing plugin to be shown in any other app wanting to share certain file types.

Okay, so apparently this is how you add a working icon:

Inspired by: https://github.com/fredldotme/harbour-owncloud

Now, If i only could figure out how to not land back at the sharing method selection page after the dialog is accepted, but all the way to the invoking app…

Try ‘share.to depecher’ you will end at sharing.page.when done. Maybe thats the way it works right now ?

Hmm, i don’t have Depecher, nor Telegram, but you are saying it too only goes back one page, i.e. to share method selection? The built-in share-to-email at least goes all the way back… and if possible i’d like to do that too.

yes, i go to galery, do a share to depecher and after selecting the chat, i am back on the selection page (where to share to)

1 Like

2 plugins from my projects

  1. transfer plugin for application
    https://github.com/Maledictus/harbour-getpocketshareplugin
  2. simple standalon transfer plugin
    https://github.com/Maledictus/harbour-clipboardshareplugin
2 Likes

I wanted to create a share plugin QtCreator template when I came across the very similar issue.

1 Like

Settings -> Other tools -> Restart home screen did the trick for me. It is still PITA but I did not know better approach.

1 Like