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 777980 - Add a public wrapper for GDataParsable:get_content_type
Add a public wrapper for GDataParsable:get_content_type
Status: RESOLVED FIXED
Product: libgdata
Classification: Platform
Component: General
git master
Other All
: Normal enhancement
: ---
Assigned To: libgdata-maint
libgdata-maint
Depends on:
Blocks:
 
 
Reported: 2017-01-31 12:39 UTC by Debarshi Ray
Modified: 2017-02-08 16:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
core: Add a public wrapper for GDataParsable:get_content_type (2.85 KB, patch)
2017-01-31 12:58 UTC, Debarshi Ray
none Details | Review
core: Add a public wrapper for GDataParsable:get_content_type (2.86 KB, patch)
2017-01-31 17:31 UTC, Debarshi Ray
committed Details | Review
tests: Assert the content-type of various GDataParsable types (34.86 KB, patch)
2017-01-31 17:36 UTC, Debarshi Ray
none Details | Review
app: Specify the correct content type (1.54 KB, patch)
2017-02-06 14:43 UTC, Debarshi Ray
committed Details | Review
tests: Assert the content-type of various GDataParsable types (34.83 KB, patch)
2017-02-06 14:44 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2017-01-31 12:39:05 UTC
In bug 771825 and bug 771823, we are trying to marshal a GDataEntry (specifically a GDataPicasaWebFile at the moment) across D-Bus. We can hardcode the content-type, or poke at the GDataParsableClass, but it would be nice if we can avoid that. Something like gdata_parsable_get_content_type would help.
Comment 1 Debarshi Ray 2017-01-31 12:58:20 UTC
Created attachment 344648 [details] [review]
core: Add a public wrapper for GDataParsable:get_content_type
Comment 2 Philip Withnall 2017-01-31 15:11:00 UTC
Review of attachment 344648 [details] [review]:

Would be good to add a few calls to this into the tests. How about the test_entry_[get|parse]_[xml|json]() tests in gdata/tests/general.c?

::: gdata/gdata-parsable.c
@@ +552,3 @@
+ * @self: a #GDataParsable
+ *
+ * Returns the content type upon which the #GDataParsable is built. For example, application/atom+xml or application/json.

Nitpick: Put backticks around the two example content types: `application/atom+xml` or `application/json`. This is the gtk-doc/Markdown formatting for monospaced text.
Comment 3 Debarshi Ray 2017-01-31 17:31:12 UTC
Created attachment 344658 [details] [review]
core: Add a public wrapper for GDataParsable:get_content_type
Comment 4 Debarshi Ray 2017-01-31 17:35:58 UTC
(In reply to Philip Withnall from comment #2)
> Review of attachment 344648 [details] [review] [review]:
> 
> Would be good to add a few calls to this into the tests. How about the
> test_entry_[get|parse]_[xml|json]() tests in gdata/tests/general.c?

Base classes like GDataEntry and GDataFeed support both XML and JSON, and their content-type is almost non-consequential. So, I only added assertions for those types that implement either the XML or JSON virtual methods.

I guess the real value would be to assert it for more leaf-level or service-specific classes where the content-type really matters.

By the way, what's up with GDataAPPCategories? It only overrides the JSON parsing vfuncs, but doesn't override the get_content_type. Does it also support both XML and JSON?
Comment 5 Debarshi Ray 2017-01-31 17:36:35 UTC
Created attachment 344661 [details] [review]
tests: Assert the content-type of various GDataParsable types

A quick first pass at asserting the content-type.
Comment 6 Philip Withnall 2017-01-31 17:49:09 UTC
Review of attachment 344658 [details] [review]:

Looks good, thanks.
Comment 7 Philip Withnall 2017-01-31 17:54:32 UTC
(In reply to Debarshi Ray from comment #4)
> (In reply to Philip Withnall from comment #2)
> > Review of attachment 344648 [details] [review] [review] [review]:
> > 
> > Would be good to add a few calls to this into the tests. How about the
> > test_entry_[get|parse]_[xml|json]() tests in gdata/tests/general.c?
> 
> Base classes like GDataEntry and GDataFeed support both XML and JSON, and
> their content-type is almost non-consequential. So, I only added assertions
> for those types that implement either the XML or JSON virtual methods.
> 
> I guess the real value would be to assert it for more leaf-level or
> service-specific classes where the content-type really matters.

Yeah, but that would be a separate set of tests: to ensure that the leaf implementations are setting the *correct* content-types. The tests I wanted here (and which you have added, thanks) are just to check that the get_content_type() method doesn’t explode.

> By the way, what's up with GDataAPPCategories? It only overrides the JSON
> parsing vfuncs, but doesn't override the get_content_type. Does it also
> support both XML and JSON?

Whoops, that’s an omission. Could you whip up a patch to add the missing get_content_type() vfunc implementation? GDataAPPCategories only supports JSON — it was ported from XML to JSON for the latest version of the YouTube API a while ago.
Comment 8 Philip Withnall 2017-01-31 17:54:49 UTC
Review of attachment 344661 [details] [review]:

Looks good apart from the FIXME, which can be removed after GDataAPPCategories is fixed.
Comment 9 Debarshi Ray 2017-01-31 18:23:23 UTC
Comment on attachment 344658 [details] [review]
core: Add a public wrapper for GDataParsable:get_content_type

Pushed to master.
Comment 10 Debarshi Ray 2017-01-31 18:27:03 UTC
> Whoops, that’s an omission. Could you whip up a patch to add the missing
> get_content_type() vfunc implementation? GDataAPPCategories only supports
> JSON — it was ported from XML to JSON for the latest version of the YouTube
> API a while ago.

Ok, I will do that.
Comment 11 Debarshi Ray 2017-02-06 14:43:56 UTC
Created attachment 345035 [details] [review]
app: Specify the correct content type
Comment 12 Debarshi Ray 2017-02-06 14:44:33 UTC
Created attachment 345036 [details] [review]
tests: Assert the content-type of various GDataParsable types
Comment 13 Philip Withnall 2017-02-08 16:43:07 UTC
Review of attachment 345035 [details] [review]:

Yes!
Comment 14 Philip Withnall 2017-02-08 16:44:27 UTC
Review of attachment 345036 [details] [review]:

Looks good, thanks.
Comment 15 Debarshi Ray 2017-02-08 16:47:56 UTC
Thanks for the reviews! Pushed to master.