QProcess and Sailjail

Where you starting out from: transfer-engine/example at master · sailfishos/transfer-engine · GitHub ?

Yes, with the addition of starting the destination application via QProcess::startDetached() and passing the shared content to it (e.g. an URL) as a command line parameter… Those are actually the only changes.

Problem solved. Adding

setStatus(MediaTransferInterface::TransferFinished);

does the job and all sharing operations now appear in Transfers as successful.

4 Likes

Is this something that should be included in the example code? If so, could you make a PR to add it?

Looking at the header, you’d think: void statusChanged(MediaTransferInterface::TransferStatus status); as a signal should be available to emit to QML?

I’m still investigating it. At this point I’m not really sure if it is supposed to be done like I did it. I thought that the transfer engine should know by itself if the transfer has finished and the application / plugin shouldn’t need to tell it. But maybe not.

Another problem is that even though transfers are now shown as successful on the Transfers list, only time and transfer type icon (in this case Upload) are shown, nothing else. I’m not actually sure what should be displayed if I am sharing content like text string or URL, but I guess it shouldn’t be just time and nothing else. I’ve already tried with displayName and several other variables but it doesn’t seem to have any effect. I’m trying to have there shown if not the shared text / URL, then maybe at least the application name the sharing operation was directed to.

1 Like

By analyzing the contents of /usr/lib64/qt5/qml/Sailfish/TransferEngine/TransfersPage.qml I was able to find out that the file name to be shown on the Transfers list is read from MediaItem’s ResourceName.

Now, how to set it? All my attempts have failed, I still only get timestamp of the transfer (and now also serviceIcon that I used to distinguish my app’s transfers).

1 Like

Still no joy, I can’t make it display any further information on the Transfers screen. Trying to manually write to resourceName or applicationIcon has no effect whatsoever… I guess that in case of sharing an image or document those variables are filled automatically by the Transfer Engine, e.g. with an image’s thumbnail or document’s icon resulting from its MIME type and path to the file in resourceName, but is there really no way to add it manually in case of sharing a string or an URL?

1 Like

Oh, man. I was really hoping not to have to build to get further:) But as you suggest, there is no ‘resourceName’ for a string (a url is also a string, or?). Which leads me to think, display the resource itself! Can you get resourceName in debug output?

The Settings / Transfers list is /usr/lib64/qt5/qml/Sailfish/TransferEngine/TransfersPage.qml, and it is ‘hardcoded’ there what is being read and displayed on that list: serviceIcon, status, url, thumbnailIcon, applicationIcon, resourceName, and that’s it. So I can’t just display the resource itself, at least without patching TransfersPage.qml, which is what I don’t want to do…

Actually, if I had a choice, I’d prefer not to show those sharing operations on the Transfers list at all rather than have such crippled incomplete and meaningless entries filling up the list, but it doesn’t seem to be controllable, either.

I’ll check.

What I meant was, set the resourceName in the plugin. You’re actually not sharing a resource but just a String? Then I’d look to see if the resourceName can be set.

Yes, I did set it in the plugin, but still nothing shows up in Transfers. I’ll check the debug output in the evening to verify if it really gets set at all.

The shared content is simply an URL, i.e. a simple string - tapping and holding a link, selecting “Share with” (or whatever it is in English UI), then selecting my application from the list, and the plugin simply passes the URL string as a command line parameter to my application and launches it via QProcess::startDetached.

As as I wrote, I’d even be happy if the transfers were not shown on the Transfers list at all, but it looks that the transfer-engine puts there whatever it handles.

I don’t seem to have that issue on my plugin that does basically the same thing…

I guess it’s because your plugin is used to share files - images, documents, etc. They have their paths, file names, MIME types, etc. It seems that in such case the transfer-engine takes all the info (like document name, icon, etc., and in case of images even thumbnail) by itself and properly shows it. Problems seem to arise when a simple text string (like e.g. a link) is being shared, as in such case there is no application icon (e.g. from MIME type) or resourceName (e.g. file name), or path that the transfer-engine could automatically use and display, and at the same time it doesn’t seem to allow entering it programmatically… So it doesn’t show anything.

Can your plugin be used to share a text string like URL? If so, do you get in such case anything more than just the time stamp?

Don’t know if it matters here, but in some contexts urls are NOT just strings!

Javascript URL objects, and QUrls are more complex.
Not sure about the QML url basic type, and Qt.url().

E.g. in order to test a regular expression against an QML url property in JS, you have to toString() it because it gets converted to an URL object.

1 Like

Just a flyby but is this the difference between ‘share’ and ‘transfer’?

It handles plaintext in its non-file form.
And while it does pollute the transfers list, it does not stick in the transfers screen.

@poetaster
Well, in my case the plugin consists of both those parts.

I had only had, in memory, the ‘url sharing’ from the browser which, of course, does not show up in transfers. I’m going to admit I’m confused, but I’m debugging api foo, so that’s not surprising :slight_smile:

I meant that properties declared as strings could be used as such. When I say string, in this case I mean QString. Which is also not a string :slight_smile:

Now I’m going to have to read your code. Well, at least it’s online :slight_smile: