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

[addons][vfs] cleanup, "C" interface fix, documentation rework #17527

Merged
merged 8 commits into from
Mar 28, 2020

Conversation

AlwinEsch
Copy link
Member

@AlwinEsch AlwinEsch commented Mar 20, 2020

Description

This request revises the VFS addon interface. The changes in the addon itself are rather minor, since only the CVFSEntry::IoControl has been revised on the addon to avoid the Kodi-side header "IFileTypes.h" (this only corresponded to C++).

This API change now translates the Kodi site to its own for addon, which makes this "C" ABI compatible and more importantly, safer in the event of changes to IFileTypes.h, which could inadvertently cause problems with addons.

Another API change is that the individual structures are now in their own arrays, so it is safer if a callback function or property is added. However, this does not require any code changes to addon and is fixed with a new creation.

The commit "[settings] allow TranslatableIntegerSettingOption to get string from" allows the addon itself a string ID to its network drive connection that can be created in Kodi's settings. This is independent and will still be moved in a own request.

There are also some clang code cleanups in it.

In addition, everything between Kodi and addon is now in pure "C".

Here is the new documention view available: http://alwinesch.github.io/group__cpp__kodi__addon__vfs.html

Motivation and Context

Related to #17514 and to become the documentation in future available for everything 😁

How Has This Been Tested?

Tested now on few addons, need to test more and comes next days, also is the API not so big that it becomes critical.

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@AlwinEsch AlwinEsch added Type: Cleanup non-breaking change which removes non-working or unmaintained functionality Type: Improvement non-breaking change which improves existing functionality Component: Binary add-ons Documentation API change: Binary add-ons v19 Matrix labels Mar 20, 2020
@AlwinEsch AlwinEsch added this to the Matrix 19.0-alpha 1 milestone Mar 20, 2020
KodiToAddonFuncTable_VFSEntry toAddon;
AddonProps_VFSEntry* props;
AddonToKodiFuncTable_VFSEntry* toKodi;
KodiToAddonFuncTable_VFSEntry* toAddon;
Copy link
Member

Choose a reason for hiding this comment

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

what about std::unique ptrs?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can not use a C++ std::unique in a "C" ABI, thats one of the main reason of this request.

Copy link
Member

Choose a reason for hiding this comment

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

oh yea, didn't look at the location of this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

NP, thanks a lot for review!

@@ -24,6 +24,7 @@ class CGUIDialogNetworkSetup : public CGUIDialogSettingsManualBase
int defaultPort; //!< Default port to use for protocol
std::string type; //!< URL type for protocol
int label; //!< String ID to use as label in dialog
std::string addonId; //!< Addon identifier, leaved empty if inside Kodi
Copy link
Member

Choose a reason for hiding this comment

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

It's not evident to me, where is this used?

Copy link
Member Author

@AlwinEsch AlwinEsch Mar 21, 2020

Choose a reason for hiding this comment

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

Currently vfs addons are forced to take Kodi's own string id's (e.g. at vfs.sftp https://github.com/xbmc/vfs.sftp/blob/Leia/vfs.sftp/addon.xml.in#L21) and the std::pair<int, int> in settings this could not be identified.

This is then taken here https://github.com/xbmc/xbmc/pull/17527/files#diff-8211fa801621c92df9bf6515d2d45b8aR200 to give to replaced pair with TranslatableIntegerSettingOption his addon id.

EDIT: Without is the "My special secure VFS addon" not possible to give on GUI

Copy link
Member

Choose a reason for hiding this comment

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

thanks for the explanation

@garbear
Copy link
Member

garbear commented Mar 21, 2020

Two comments, otherwise looks good

This was before given to Kodi to have on his calls to addon.
That basically not match a "C" ABI where the use of "C++" parts within
"C" not allowed!

With this it becomes given via "void*" to Kodi and with a "static_cast"
changed back to required class on addon.
Added to separate "C" and "C++" part and further to allow a "C" only
in future.
On this commit becomes them replaced to use independent enum and
structures, to pass related data between Kodi and Addon.

This prevents conflicts when using "C" and ensures a secure ABI interface.

In addition, it is much safer in the event that the Kodi changes what in its
headers. This can easily occur because previously it was not directly visible
that IFileTypes.h was also used on addons.

Only currently still used on libXBMC_addon.h and removed on PVR rework.
This done to prevent API backward problems if something becomes replaced
e.g. on props or to kodi calls.
This changes the interface to pure "C" and no "C++" dependencies in it.
With this change the whole VFS documentation becomes reworked and to have
usable on doxygen.

There are much parts added to understand his usage.
@AlwinEsch
Copy link
Member Author

If nothing against then I bring it in tommorow and then update of the addons.
Working test of all vfs addons was OK.

jenkins build this please

@AlwinEsch AlwinEsch merged commit 1e627d2 into xbmc:master Mar 28, 2020
@AlwinEsch AlwinEsch deleted the change-vfs branch March 28, 2020 19:36
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Mar 30, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Mar 30, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request May 5, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 3, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 4, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 4, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 5, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 6, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 6, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 6, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Aug 7, 2020
[addons][vfs] cleanup, "C" interface fix, documentation rework
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change: Binary add-ons Component: Binary add-ons Documentation Type: Cleanup non-breaking change which removes non-working or unmaintained functionality Type: Improvement non-breaking change which improves existing functionality v19 Matrix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants