Re: Pasteboard Source - "bundle id" content may be empty

6 views
Skip to first unread message

Thomas Tempelmann

unread,
Jan 4, 2017, 10:57:09 AM1/4/17
to nspasteboard Google Group
While implementing the new "org.nspasteboard.source" feature in iClip, I noticed that there's a special case that we should probably add to the docs:

If the "org.nspasteboard.source" marker is available but its content is empty (instead of containing a bundle id), it should be interpreted as: "The app that filled the clipboard is unknown".

Plus, of course, apps evaluating this marker must be able to gracefully handle the case that the specified bundle ID can't be determined - in which case a similar state ("app can't be determined") should be assumed.

I'm just pointing out the empty case because I'll use that in cases where iClip is asked to read the clipboard while having a good reason to assume that it can't know the app that filled it (e.g. when iClip was just launched and is now asked by the user to take the current clipboard contents, which may have been filled by another app before iClip was launched.)

--
Thomas Tempelmann
Irradiated Software

Brian Bucknam

unread,
Jan 4, 2017, 5:34:07 PM1/4/17
to nspasteboard Google Group
Hi Thomas,

I’m trying to understand the situation in which an application would need to add the “org.nspasteboard.source” marker, but would not know what the source actually was. That is, the naïve and obvious solution seems to be: “if the source is not known, do not add a ‘org.nspasteboard.source’ marker.”

The only scenario that occurs to me is something along the lines of restoring the pasteboard to its previous contents after performing some kind of pasteboard manipulation. But even then, if the original source of the data being “restored” is not known, just not including “org.nspasteboard.source” seems reasonable. I guess maybe you are worried that some other application, upon “seeing” pasteboard content has been updated, might assume that your application was the “source” of the un-marked content?

That is, it’s difficult to document a use case that I don’t understand.

Thanks,
Brian

Thomas Tempelmann

unread,
Jan 4, 2017, 7:12:00 PM1/4/17
to nspasteboard Google Group
On Wed, Jan 4, 2017 at 11:33 PM, Brian Bucknam <br...@smilesoftware.com> wrote:
I’m trying to understand the situation in which an application would need to add the “org.nspasteboard.source” marker, but would not know what the source actually was. That is, the naïve and obvious solution seems to be: “if the source is not known, do not add a ‘org.nspasteboard.source’ marker.”

I already mentioned the first part: If iClip is asked by the user to record the current clipboard, and if iClip was not running when that clipboard was set, iClip records internally that the "source app" is "unknown".

Now, if iClip is later asked by the user to place the recorded clipboard content back into the Clipboard, it needs to pass on the "source app" that created those clipboard contents. And therefore it needs to add an empty "source marker". Because, if it would NOT add the source marker at all, then the next app reading the clipboard would assume that the current front app is the creator, which is incorrect. Ergo, by finding a marker with an empty bundle id in the clipboard, a conforming app should assume that the app is not the frontmost and neither is a known app.

This behavior of setting an empty source marker applies to clipboard recording tools like iClip, i.e. tools that preserve clipboard contents and later restore them.

It also means that apps reading the clipboard must not assume the front app to be the creator if they find a "source marker" in the clipboard, no matter what its value is.

Understood and agreed?

Brian Bucknam

unread,
Jan 20, 2017, 2:14:38 PM1/20/17
to nspasteboard Google Group
Hi Thomas,

Thank you for clarifying — that makes sense. I started writing the edits then got distracted — the site is now updated to reflect this.

Thanks,
Brian
Reply all
Reply to author
Forward
0 new messages