After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 724308 - Make it possible to pass "flags" to "remove()
Make it possible to pass "flags" to "remove()
Status: RESOLVED OBSOLETE
Product: grilo
Classification: Other
Component: core
git master
Other All
: Normal normal
: ---
Assigned To: grilo-maint
grilo-maint
Depends on:
Blocks: 724309 727469
 
 
Reported: 2014-02-13 16:43 UTC by Bastien Nocera
Modified: 2018-07-22 12:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
WIP: core: Add remove operation flags (5.95 KB, patch)
2014-02-21 15:26 UTC, Bastien Nocera
none Details | Review
core: Rename GrlOperationOptions "flags" to "resolution-flags" (20.73 KB, patch)
2014-05-12 22:52 UTC, Bastien Nocera
none Details | Review
core: Add remove operation flags (15.99 KB, patch)
2014-05-12 22:52 UTC, Bastien Nocera
none Details | Review
test-ui: Don't remove items from the view when remove fails (813 bytes, patch)
2014-05-12 22:53 UTC, Bastien Nocera
committed Details | Review
all: Port from ..._flags() to ..._resolution_flags() (6.71 KB, patch)
2014-05-12 22:57 UTC, Bastien Nocera
committed Details | Review
core: Add remove operation flags (16.82 KB, patch)
2014-05-13 06:45 UTC, Bastien Nocera
none Details | Review
core: Rename GrlOperationOptions "flags" to "resolution-flags" (20.15 KB, patch)
2014-05-13 06:45 UTC, Bastien Nocera
none Details | Review
core: Add remove operation flags (17.10 KB, patch)
2014-05-13 06:58 UTC, Bastien Nocera
none Details | Review
core: Rename GrlOperationOptions "flags" to "resolution-flags" (21.72 KB, patch)
2014-05-13 06:58 UTC, Bastien Nocera
none Details | Review
core: Add remove operation flags (17.02 KB, patch)
2014-05-30 14:46 UTC, Bastien Nocera
none Details | Review
core: Rename GrlOperationOptions "flags" to "resolution-flags" (21.72 KB, patch)
2014-05-30 14:46 UTC, Bastien Nocera
committed Details | Review
core: Fix possible crash when passing NULL options (1.21 KB, patch)
2014-05-30 14:47 UTC, Bastien Nocera
committed Details | Review
core: Add remove operation flags (17.11 KB, patch)
2017-06-29 14:12 UTC, Bastien Nocera
none Details | Review

Description Bastien Nocera 2014-02-13 16:43:25 UTC
grl_source_remove() is currently limited, as there's no way to tell the backend which type of "remove" we'd like.

For example, for objects on the local filesystem, we might want to either delete them straight away, or move them to trash. For the pocket plugin, we'd like to have a difference between "remove" (I'm really not interested in reading/watching this after all) and "archive" (I'm done watching this, save it in the archive so that I can find it again later).

I think that we could either pass strings, which would be plugin/source specific (and documented in the grilo docs) or try to add a comprehensive list of removal types in grilo with a way to discover them.
Comment 1 Juan A. Suarez Romero 2014-02-20 22:20:09 UTC
The way we were considering this was the source defining what it means removing in their context. So, a source could define that remove() means moving to a thrash, while in other case it could mean physically remove it. Also, in those cases that we both options are valid, we were considering using a configuration option, so basically you would were deciding what kind of removing do you want.

But reading again your description, it is clear that this is not enough, because in lot of cases you want different removals in the same source. As example, in the podcasts plugin, in the same session you could use remove() for "mark as readed" or "remove this feed".

So yeah, I can't think on a better approach than the flags. I wonder if it makes sense to have a  predefined set of flags that can be used any source, besides allowing them to add new flags (mostly like we do with metadata keys). So applications that relies on this predefined flags could basically interact with any source without needing to deal with them separately. As saying, not very if it's worth to. I have a mixed feelings.
Comment 2 Bastien Nocera 2014-02-21 15:26:03 UTC
Created attachment 269926 [details] [review]
WIP: core: Add remove operation flags

Allow passing remove flags to backends to implement various
kinds of removals (deletion, moving to trash, marking as
read/watched, etc.)
Comment 3 Juan A. Suarez Romero 2014-05-12 12:50:43 UTC
I'm feeling we are trying to overload too much the remove() operation.

For instance, the "watched" option. IMHO, "watched" is a mark you want to put in an element when you already have watched that element. Similarly, there's the "favourite" mark. But marking something as "watched" doesn't mean by itself that should be deleted. I think that depends on specific source that could try to give that meaning to elements marked as "watched".

What I'm trying to say? That I think for the case of watched elements, we should use the same approach as marking elements as favourite. That is, the source supports a "watched" key, and when we want to mark something as watched we just set that value to TRUE and call store_metadata() to update the value.

I'm using a Pocket app in my mobile, and that is exactly what it does: when you mark an element as read/watched, it is moved to the archive.

And what it happens with "watched" elements when we do a search/browse? It is clear for me that if we would be deleting them, they should never appear again. But with podcasts or Pocket plugin, while usually we don't want to show the "watched" elements when browsing, sometimes we could want to do it (for instance, to unmark it again). In fact this is what most podcasts apps do: they allow to show all elements or only those not watched.

In our case, I think what to do depends entirely on the source: if it only wants to show unwatched elements, that's fine. Even the source in this case could purge the watched elements from time to time to clear space.

But it could also supports the case of showing all elements, or only the watched ones. If we follow the approach of marking the element as "watched" (the same approach we have used to mark an element as "favourite"), the source could support a filter by "watched" key. So application could get all the elements just by a normal browsing, or only those unwatched using a filter where "watched" == FALSE.

Still, we have the case of "delete" vs. "moving to trash". I'm not sure if repeating the same approach as above is worth or not. That is, we have a "in-trash" key that we set to TRUE when we want to move the element to the thrash. When setting this value, the source internally moves the element to the trash, so it won't be available again in the browse. So all the elements we browse/search have always the "in-trash" value to FALSE. And that somewhat we could access the Trash to "undelete" the elements.

If we still prefer to go with the flags approach, I'm wondering if it would be better to implement as it is proposed, or rather use the GrlCaps/GrlOperationOptions. This latter would allow to introspect what sort of "remove" the source implements, and invoke it with the correct one. Also, it would allow us to extend in the future with other options for the remove() case without breaking the API.
Comment 4 Bastien Nocera 2014-05-12 13:00:03 UTC
(In reply to comment #3)
> I'm feeling we are trying to overload too much the remove() operation.
> 
> For instance, the "watched" option. IMHO, "watched" is a mark you want to put
> in an element when you already have watched that element. Similarly, there's
> the "favourite" mark. But marking something as "watched" doesn't mean by itself
> that should be deleted. I think that depends on specific source that could try
> to give that meaning to elements marked as "watched".
> 
> What I'm trying to say? That I think for the case of watched elements, we
> should use the same approach as marking elements as favourite. That is, the
> source supports a "watched" key, and when we want to mark something as watched
> we just set that value to TRUE and call store_metadata() to update the value.
> 
> I'm using a Pocket app in my mobile, and that is exactly what it does: when you
> mark an element as read/watched, it is moved to the archive.

The archive isn't accessible through the Pocket plugin in Grilo, so it's as good as removed. The split between watched (read, really) and deleted in Pocket is the same as trashed and deleted (unrecoverably) for local files.

> And what it happens with "watched" elements when we do a search/browse? It is
> clear for me that if we would be deleting them, they should never appear again.

They won't appear again, hence why this is a flag to "remove" rather than simply a property of the media.

> But with podcasts or Pocket plugin, while usually we don't want to show the
> "watched" elements when browsing, sometimes we could want to do it (for
> instance, to unmark it again). In fact this is what most podcasts apps do: they
> allow to show all elements or only those not watched.

We don't show items that are in the trash. For a similar reason, we don't offer a UI to Pocket's archives articles/videos.

> In our case, I think what to do depends entirely on the source: if it only
> wants to show unwatched elements, that's fine. Even the source in this case
> could purge the watched elements from time to time to clear space.
> 
> But it could also supports the case of showing all elements, or only the
> watched ones. If we follow the approach of marking the element as "watched"
> (the same approach we have used to mark an element as "favourite"), the source
> could support a filter by "watched" key. So application could get all the
> elements just by a normal browsing, or only those unwatched using a filter
> where "watched" == FALSE.
> 
> Still, we have the case of "delete" vs. "moving to trash". I'm not sure if
> repeating the same approach as above is worth or not. That is, we have a
> "in-trash" key that we set to TRUE when we want to move the element to the
> thrash. When setting this value, the source internally moves the element to the
> trash, so it won't be available again in the browse. So all the elements we
> browse/search have always the "in-trash" value to FALSE. And that somewhat we
> could access the Trash to "undelete" the elements.

This is really weird. I don't think that changing a property on a media should make it unavailable.

> If we still prefer to go with the flags approach, I'm wondering if it would be
> better to implement as it is proposed, or rather use the
> GrlCaps/GrlOperationOptions. This latter would allow to introspect what sort of
> "remove" the source implements, and invoke it with the correct one. Also, it
> would allow us to extend in the future with other options for the remove() case
> without breaking the API.

I think this is the way I'll go then.
Comment 5 Juan A. Suarez Romero 2014-05-12 13:20:06 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > I'm using a Pocket app in my mobile, and that is exactly what it does: when you
> > mark an element as read/watched, it is moved to the archive.
> 
> The archive isn't accessible through the Pocket plugin in Grilo, so it's as
> good as removed. The split between watched (read, really) and deleted in Pocket
> is the same as trashed and deleted (unrecoverably) for local files.
> 

But this is due the way you have implemented the Pocket plugin in Grilo: you just don't want to show watched elements, and don't have the option to allow application to get them. But if you think in a more general approach, I don't think that a "watched" element should always be removed. As I explained in the case of the Podcasts, a plugin that allow to list all content or only unwatched content is a very common case.

And even when it seems that marking as watched and delete could seem the same (from the Pocket plugin point of view) it is not, because if you access the Pocket service from your browser, the result would be very different if you have deleted or archive.

> > And what it happens with "watched" elements when we do a search/browse? It is
> > clear for me that if we would be deleting them, they should never appear again.
> 
> They won't appear again, hence why this is a flag to "remove" rather than
> simply a property of the media.
> 

Maybe the point here is about the interpretation of what it means "archive" in the case of Pocket. For me, archive means "this is read/watched, keep it for the future". From what I see, for you it means "delete this element by putting it in the archive (like a Thrash)".


> > But with podcasts or Pocket plugin, while usually we don't want to show the
> > "watched" elements when browsing, sometimes we could want to do it (for
> > instance, to unmark it again). In fact this is what most podcasts apps do: they
> > allow to show all elements or only those not watched.
> 
> We don't show items that are in the trash. For a similar reason, we don't offer
> a UI to Pocket's archives articles/videos.
> 

Would it make sense to show them? I really think that the archive is the place to store things already watched, and that you want to keep them for the future, because they are interesting.

> > In our case, I think what to do depends entirely on the source: if it only
> > wants to show unwatched elements, that's fine. Even the source in this case
> > could purge the watched elements from time to time to clear space.
> > 
> > But it could also supports the case of showing all elements, or only the
> > watched ones. If we follow the approach of marking the element as "watched"
> > (the same approach we have used to mark an element as "favourite"), the source
> > could support a filter by "watched" key. So application could get all the
> > elements just by a normal browsing, or only those unwatched using a filter
> > where "watched" == FALSE.
> > 
> > Still, we have the case of "delete" vs. "moving to trash". I'm not sure if
> > repeating the same approach as above is worth or not. That is, we have a
> > "in-trash" key that we set to TRUE when we want to move the element to the
> > thrash. When setting this value, the source internally moves the element to the
> > trash, so it won't be available again in the browse. So all the elements we
> > browse/search have always the "in-trash" value to FALSE. And that somewhat we
> > could access the Trash to "undelete" the elements.
> 
> This is really weird. I don't think that changing a property on a media should
> make it unavailable.
> 

I agree that implementing this with a key could be weird. But I don't think that it is weird to hide elements are depending on the value of a key. This is what I'm proposing with the case of "watched" elements.


> > If we still prefer to go with the flags approach, I'm wondering if it would be
> > better to implement as it is proposed, or rather use the
> > GrlCaps/GrlOperationOptions. This latter would allow to introspect what sort of
> > "remove" the source implements, and invoke it with the correct one. Also, it
> > would allow us to extend in the future with other options for the remove() case
> > without breaking the API.
> 
> I think this is the way I'll go then.

Nice.
Comment 6 Bastien Nocera 2014-05-12 13:36:24 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > I'm using a Pocket app in my mobile, and that is exactly what it does: when you
> > > mark an element as read/watched, it is moved to the archive.
> > 
> > The archive isn't accessible through the Pocket plugin in Grilo, so it's as
> > good as removed. The split between watched (read, really) and deleted in Pocket
> > is the same as trashed and deleted (unrecoverably) for local files.
> > 
> 
> But this is due the way you have implemented the Pocket plugin in Grilo: you
> just don't want to show watched elements, and don't have the option to allow
> application to get them. But if you think in a more general approach, I don't
> think that a "watched" element should always be removed. As I explained in the
> case of the Podcasts, a plugin that allow to list all content or only unwatched
> content is a very common case.
> 
> And even when it seems that marking as watched and delete could seem the same
> (from the Pocket plugin point of view) it is not, because if you access the
> Pocket service from your browser, the result would be very different if you
> have deleted or archive.

For the podcast plugin, you'd use metadata on those files. You wouldn't remove things you mark as watched.

> > > And what it happens with "watched" elements when we do a search/browse? It is
> > > clear for me that if we would be deleting them, they should never appear again.
> > 
> > They won't appear again, hence why this is a flag to "remove" rather than
> > simply a property of the media.
> > 
> 
> Maybe the point here is about the interpretation of what it means "archive" in
> the case of Pocket. For me, archive means "this is read/watched, keep it for
> the future". From what I see, for you it means "delete this element by putting
> it in the archive (like a Thrash)".

I can rename it "archive" if that's clearer. It makes no difference to me.

> > > But with podcasts or Pocket plugin, while usually we don't want to show the
> > > "watched" elements when browsing, sometimes we could want to do it (for
> > > instance, to unmark it again). In fact this is what most podcasts apps do: they
> > > allow to show all elements or only those not watched.
> > 
> > We don't show items that are in the trash. For a similar reason, we don't offer
> > a UI to Pocket's archives articles/videos.
> > 
> 
> Would it make sense to show them? I really think that the archive is the place
> to store things already watched, and that you want to keep them for the future,
> because they are interesting.

No, not in grilo anyway. I'd make it accessible if there was a separate application for all things Pocket though.

> > > In our case, I think what to do depends entirely on the source: if it only
> > > wants to show unwatched elements, that's fine. Even the source in this case
> > > could purge the watched elements from time to time to clear space.
> > > 
> > > But it could also supports the case of showing all elements, or only the
> > > watched ones. If we follow the approach of marking the element as "watched"
> > > (the same approach we have used to mark an element as "favourite"), the source
> > > could support a filter by "watched" key. So application could get all the
> > > elements just by a normal browsing, or only those unwatched using a filter
> > > where "watched" == FALSE.
> > > 
> > > Still, we have the case of "delete" vs. "moving to trash". I'm not sure if
> > > repeating the same approach as above is worth or not. That is, we have a
> > > "in-trash" key that we set to TRUE when we want to move the element to the
> > > thrash. When setting this value, the source internally moves the element to the
> > > trash, so it won't be available again in the browse. So all the elements we
> > > browse/search have always the "in-trash" value to FALSE. And that somewhat we
> > > could access the Trash to "undelete" the elements.
> > 
> > This is really weird. I don't think that changing a property on a media should
> > make it unavailable.
> > 
> 
> I agree that implementing this with a key could be weird. But I don't think
> that it is weird to hide elements are depending on the value of a key. This is
> what I'm proposing with the case of "watched" elements.

In the case of Pocket, it would disappear from the "unread" view completely, our only view. I would use a function to enact an action, I wouldn't set a property.
Comment 7 Juan A. Suarez Romero 2014-05-12 18:28:00 UTC
(In reply to comment #6)
> > And even when it seems that marking as watched and delete could seem the same
> > (from the Pocket plugin point of view) it is not, because if you access the
> > Pocket service from your browser, the result would be very different if you
> > have deleted or archive.
> 
> For the podcast plugin, you'd use metadata on those files. You wouldn't remove
> things you mark as watched.
> 

I don't know what you mean by "use metadata on those files". 

I think the difference between your pov and mine is about what it means in Pocket to move to archive: in your pov, it means like moving to Trash, in mine it means like marking something as watched (correct me if I'm wrong).

> > > > And what it happens with "watched" elements when we do a search/browse? It is
> > > > clear for me that if we would be deleting them, they should never appear again.
> > > 
> > > They won't appear again, hence why this is a flag to "remove" rather than
> > > simply a property of the media.
> > > 
> > 
> > Maybe the point here is about the interpretation of what it means "archive" in
> > the case of Pocket. For me, archive means "this is read/watched, keep it for
> > the future". From what I see, for you it means "delete this element by putting
> > it in the archive (like a Thrash)".
> 
> I can rename it "archive" if that's clearer. It makes no difference to me.

Neither for me. It is not about the name, but about what's the meaning.

> > Would it make sense to show them? I really think that the archive is the place
> > to store things already watched, and that you want to keep them for the future,
> > because they are interesting.
> 
> No, not in grilo anyway. I'd make it accessible if there was a separate
> application for all things Pocket though.
> 

Fair enough.

> > I agree that implementing this with a key could be weird. But I don't think
> > that it is weird to hide elements are depending on the value of a key. This is
> > what I'm proposing with the case of "watched" elements.
> 
> In the case of Pocket, it would disappear from the "unread" view completely,
> our only view. I would use a function to enact an action, I wouldn't set a
> property.

Yes. I guess that the unread view is the one we want to show in our app. But "all" view is something that could be interesting for other apps. I don't mean we need to do it, though. The point is when we are going to add a new feature, try to generalize as much as possible so most apps/sources can take advantage of that feature.
Comment 8 Bastien Nocera 2014-05-12 22:52:52 UTC
Created attachment 276409 [details] [review]
core: Rename GrlOperationOptions "flags" to "resolution-flags"

And rename the associated functions as well. This will allow us
to add new Flags without trampling on those ones.
Comment 9 Bastien Nocera 2014-05-12 22:52:59 UTC
Created attachment 276410 [details] [review]
core: Add remove operation flags

Allow passing remove flags to backends to implement various
kinds of removals (deletion, moving to trash, marking as
read/watched, etc.)
Comment 10 Bastien Nocera 2014-05-12 22:53:04 UTC
Created attachment 276411 [details] [review]
test-ui: Don't remove items from the view when remove fails
Comment 11 Bastien Nocera 2014-05-12 22:57:55 UTC
Created attachment 276412 [details] [review]
all: Port from ..._flags() to ..._resolution_flags()
Comment 12 Bastien Nocera 2014-05-12 23:01:19 UTC
It should be possible to skip the "Rename flags to resolution-flags" patch, and move the additional struct member of GrlSourceRemoveSpec at the end. This might be enough to avoid breaking ABI/API.
Comment 13 Bastien Nocera 2014-05-12 23:02:05 UTC
(In reply to comment #12)
> It should be possible to skip the "Rename flags to resolution-flags" patch, and
> move the additional struct member of GrlSourceRemoveSpec at the end. This might
> be enough to avoid breaking ABI/API.

And obviously create new "with_options" versions of grl_source_remove*
Comment 14 Bastien Nocera 2014-05-13 06:45:11 UTC
Created attachment 276441 [details] [review]
core: Add remove operation flags

Allow passing remove flags to backends to implement various
kinds of removals (deletion, moving to trash, marking as
read/watched, etc.)
Comment 15 Bastien Nocera 2014-05-13 06:45:17 UTC
Created attachment 276442 [details] [review]
core: Rename GrlOperationOptions "flags" to "resolution-flags"

And add the associated functions as well. Deprecate the old
functions.
Comment 16 Bastien Nocera 2014-05-13 06:58:52 UTC
Created attachment 276443 [details] [review]
core: Add remove operation flags

Allow passing remove flags to backends to implement various
kinds of removals (deletion, moving to trash, marking as
read/watched, etc.)
Comment 17 Bastien Nocera 2014-05-13 06:58:59 UTC
Created attachment 276444 [details] [review]
core: Rename GrlOperationOptions "flags" to "resolution-flags"

And add the associated functions as well. Deprecate the old
functions.
Comment 18 Bastien Nocera 2014-05-30 14:46:50 UTC
Created attachment 277556 [details] [review]
core: Add remove operation flags

Allow passing remove flags to backends to implement various
kinds of removals (deletion, moving to trash, marking as
read/watched, etc.)
Comment 19 Bastien Nocera 2014-05-30 14:46:56 UTC
Created attachment 277557 [details] [review]
core: Rename GrlOperationOptions "flags" to "resolution-flags"

And add the associated functions as well. Deprecate the old
functions.
Comment 20 Bastien Nocera 2014-05-30 14:47:03 UTC
Created attachment 277558 [details] [review]
core: Fix possible crash when passing NULL options

grl_operation_options_get_resolution_flags() shouldn't
crash when the options passed are NULL.
Comment 21 Bastien Nocera 2015-02-17 12:38:34 UTC
Attachment 277557 [details] pushed as c65c68b - core: Rename GrlOperationOptions "flags" to "resolution-flags"
Attachment 277558 [details] pushed as 3ba699d - core: Fix possible crash when passing NULL options
Comment 22 Bastien Nocera 2015-04-24 12:29:27 UTC
Comment on attachment 276412 [details] [review]
all: Port from ..._flags() to ..._resolution_flags()

Was committed as 878a0bf600eab88fde31453b8933d705b65e2ad0
Comment 23 Bastien Nocera 2017-06-29 14:11:24 UTC
Comment on attachment 276411 [details] [review]
test-ui: Don't remove items from the view when remove fails

Committed in 37e40deab108bffc58c80627ff9f76ef2b73b7cb
Comment 24 Bastien Nocera 2017-06-29 14:12:40 UTC
Created attachment 354689 [details] [review]
core: Add remove operation flags

Allow passing remove flags to backends to implement various
kinds of removals (deletion, moving to trash, marking as
read/watched, etc.)
Comment 25 Bastien Nocera 2018-07-22 12:17:07 UTC
Moved to https://gitlab.gnome.org/GNOME/grilo/merge_requests/11