Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an <internet/> kind to requires/recommends/supports #421

Closed
wants to merge 2 commits into from

Conversation

pwithnall
Copy link
Contributor

See the commit messages. This adds a new <internet/> kind to requires/recommends/supports, both in the spec and in libappstream. It includes unit tests.

Fixes: #343

This allows apps to specify whether they require the internet to work,
or whether they explicitly work fully without internet.

Signed-off-by: Philip Withnall <[email protected]>

Fixes: ximion#343
…kind

Includes tests for the XML and YAML implementations.

Signed-off-by: Philip Withnall <[email protected]>

Fixes: ximion#343
@pwithnall
Copy link
Contributor Author

I’m going to be away for a few months from basically now, so won’t be able to respond to review feedback on this after tomorrow or so. Please feel free to update/change/drop/close/adapt the MR in whatever way seems most appropriate.

One thing you might want to think about in particular is the bandwidth_mbitps attribute, which was more of a question mark in the discussion on #343 than the rest of the new bits in the spec. It should be fairly straightforward to drop bandwidth_mbitps from this MR if you don’t think it’s ready to add that now. It can always be added to the spec in future if people end up thinking that’s a good idea.

</para>
<itemizedlist>
<listitem><para><code>always</code> - Needs internet connectivity to work. If used in a <literal>recommends</literal> element, then this indicates that the app can work without internet, but the experience will be significantly degraded.</para></listitem>
<listitem><para><code>offline-only</code> - Never uses the internet, even if it’s available.</para></listitem>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the value in case an application can use the internet to enhance the experience, but otherwise does not need to and would also work perfectly fine offline? (e.g. a media player fetching cover art for songs from the web, but which would play them perfectly find just as well w/o internet connection)
Would that be maybe:

<supports>
  <internet>always</internet>
</supports>

@@ -1044,6 +1184,16 @@ as_relation_load_from_xml (AsRelation *relation, AsContext *ctx, xmlNode *node,
g_autofree gchar *side_str = (gchar*) xmlGetProp (node, (xmlChar*) "side");
priv->display_side_kind = as_display_side_kind_from_string (side_str);

g_free (priv->version);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not your code, but what about g_free (g_steal_pointer (&priv->version)) or as_relation_set_version (relation, NULL)?

g_free (priv->version);
priv->version = NULL;
} else if (priv->item_kind == AS_RELATION_ITEM_KIND_INTERNET) {
g_autofree gchar *bandwidth_str = (gchar*) xmlGetProp (node, (xmlChar*) "bandwidth_mbitps");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g_autofree gchar *bandwidth_str = as_xml_get_prop_value (node, "bandwidth_mbitps");
(a bit nicer to read)

@@ -1101,6 +1251,11 @@ as_relation_to_xml_node (AsRelation *relation, AsContext *ctx, xmlNode *root)
(xmlChar*) as_relation_item_kind_to_string (priv->item_kind),
(xmlChar*) as_control_kind_to_string (as_relation_get_value_control_kind (relation)));

} else if (priv->item_kind == AS_RELATION_ITEM_KIND_INTERNET) {
n = xmlNewTextChild (root, NULL,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use as_xml_add_text_node here, but that's optional :-)

@ximion
Copy link
Owner

ximion commented Aug 10, 2022

Looks really good, all the comments I had are very minor. The only thing I think we need to answer is the "app that can use internet but doesn't need to" case.
I initially thought of dropping the bandwidth_mbitps stuff, but tbh I think it looks fine and I would be okay with adding it now if you/your apps/your client would use it. If it has zero users, then I would be a lot more hesitant with including it.

All in all, thank you a lot for the really good patch and sorry for the delayed reply as well as causing a merge conflict by converting the AsRelation code to using the XML helpers ;-) (they don't do much except for making the C code easier to read).

@JakobDev
Copy link
Contributor

You should probably explicit mention that using it multiple times is supported. Something like this:

<requires>
  <internet>first-run</internet>
</requires>
<recommends>
  <internet>always</internet>
</recommends>

This is to avoid confusion in the implementations.

@ximion
Copy link
Owner

ximion commented Aug 20, 2022

Closing in favour of #425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add <internet/> element to <requires>/<recommends>
3 participants