Skip to content

Commit

Permalink
Addons: Separate code and fix IDE error
Browse files Browse the repository at this point in the history
This fixes an IDE error in Eclipse CDT by switching from `typedef`
to `using`.

Error was:

  Type 'ADDON::AddonInfoPtr' could not be resolved
  • Loading branch information
garbear committed Oct 10, 2021
1 parent d16dd92 commit 9c7ba3e
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 90 deletions.
1 change: 1 addition & 0 deletions xbmc/addons/Addon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "addons/IAddon.h"
#include "addons/addoninfo/AddonInfo.h"
#include "utils/XBMCTinyXML.h"

class TiXmlElement;
Expand Down
4 changes: 3 additions & 1 deletion xbmc/addons/IAddon.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

#pragma once

#include "addons/addoninfo/AddonInfo.h"
#include "XBDateTime.h"
#include "addons/addoninfo/AddonInfoTypes.h"
#include "addons/addoninfo/AddonType.h"

#include <memory>
#include <set>
Expand Down
86 changes: 1 addition & 85 deletions xbmc/addons/addoninfo/AddonInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,101 +10,17 @@

#include "XBDateTime.h"
#include "addons/AddonVersion.h"
#include "addons/addoninfo/AddonInfoTypes.h"
#include "addons/addoninfo/AddonType.h"

#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

namespace ADDON
{

class CAddonBuilder;
class CAddonInfo;
typedef std::shared_ptr<CAddonInfo> AddonInfoPtr;
typedef std::vector<AddonInfoPtr> AddonInfos;

enum class AddonDisabledReason
{
/// @brief Special reason for returning all disabled addons.
///
/// Only used as an actual value when an addon is enabled.
NONE = 0,
USER = 1,
INCOMPATIBLE = 2,
PERMANENT_FAILURE = 3
};

enum class AddonOriginType
{
/// @brief The type of the origin of an addon.
///
/// Represents where an addon was installed from.
SYSTEM = 0, /// The addon is a system addon
REPOSITORY = 1, /// The addon origin is a repository
MANUAL = 2 /// The addon origin is a zip file, package or development build
};

//! @brief Reasons why an addon is not updateable
enum class AddonUpdateRule
{
ANY = 0, //!< used internally, not to be explicitly set
USER_DISABLED_AUTO_UPDATE = 1, //!< automatic updates disabled via AddonInfo dialog
PIN_OLD_VERSION = 2 //!< user downgraded to an older version
};

/*!
* @brief Add-on state defined within addon.xml to report about the current addon
* lifecycle state.
*
* E.g. the add-on is broken and can no longer be used.
*
* XML examples:
* ~~~~~~~~~~~~~{.xml}
* <lifecyclestate type="broken" lang="en_GB">SOME TEXT</lifecyclestate>
* ~~~~~~~~~~~~~
*/
enum class AddonLifecycleState
{
NORMAL = 0, //!< Used if an add-on has no special lifecycle state which is the default state
DEPRECATED = 1, //!< the add-on should be marked as deprecated but is still usable
BROKEN = 2, //!< the add-on should marked as broken in the repository
};

struct DependencyInfo
{
std::string id;
AddonVersion versionMin, version;
bool optional;
DependencyInfo(std::string id,
const AddonVersion& versionMin,
const AddonVersion& version,
bool optional)
: id(std::move(id)),
versionMin(versionMin.empty() ? version : versionMin),
version(version),
optional(optional)
{
}

bool operator==(const DependencyInfo& rhs) const
{
return id == rhs.id && versionMin == rhs.versionMin && version == rhs.version &&
optional == rhs.optional;
}

bool operator!=(const DependencyInfo& rhs) const
{
return !(rhs == *this);
}
};

typedef std::map<std::string, std::string> InfoMap;
typedef std::map<std::string, std::string> ArtMap;

class CAddonInfoBuilder;

class CAddonInfo
Expand Down
1 change: 1 addition & 0 deletions xbmc/addons/addoninfo/AddonInfoBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "CompileInfo.h"
#include "LangInfo.h"
#include "addons/addoninfo/AddonInfo.h"
#include "addons/addoninfo/AddonType.h"
#include "filesystem/File.h"
#include "filesystem/SpecialProtocol.h"
Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/addoninfo/AddonInfoBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#include "addons/Repository.h"
#include "addons/addoninfo/AddonInfo.h"
#include "addons/addoninfo/AddonInfoTypes.h"

#include <utility>

Expand Down
104 changes: 104 additions & 0 deletions xbmc/addons/addoninfo/AddonInfoTypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright (C) 2021 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/

#pragma once

#include "addons/AddonVersion.h"

#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>

namespace ADDON
{

class CAddonInfo;
using AddonInfoPtr = std::shared_ptr<CAddonInfo>;
using AddonInfos = std::vector<AddonInfoPtr>;

enum class AddonDisabledReason
{
/// @brief Special reason for returning all disabled addons.
///
/// Only used as an actual value when an addon is enabled.
NONE = 0,
USER = 1,
INCOMPATIBLE = 2,
PERMANENT_FAILURE = 3
};

enum class AddonOriginType
{
/// @brief The type of the origin of an addon.
///
/// Represents where an addon was installed from.
SYSTEM = 0, /// The addon is a system addon
REPOSITORY = 1, /// The addon origin is a repository
MANUAL = 2 /// The addon origin is a zip file, package or development build
};

//! @brief Reasons why an addon is not updateable
enum class AddonUpdateRule
{
ANY = 0, //!< used internally, not to be explicitly set
USER_DISABLED_AUTO_UPDATE = 1, //!< automatic updates disabled via AddonInfo dialog
PIN_OLD_VERSION = 2 //!< user downgraded to an older version
};

/*!
* @brief Add-on state defined within addon.xml to report about the current addon
* lifecycle state.
*
* E.g. the add-on is broken and can no longer be used.
*
* XML examples:
* ~~~~~~~~~~~~~{.xml}
* <lifecyclestate type="broken" lang="en_GB">SOME TEXT</lifecyclestate>
* ~~~~~~~~~~~~~
*/
enum class AddonLifecycleState
{
NORMAL = 0, //!< Used if an add-on has no special lifecycle state which is the default state
DEPRECATED = 1, //!< the add-on should be marked as deprecated but is still usable
BROKEN = 2, //!< the add-on should marked as broken in the repository
};

struct DependencyInfo
{
std::string id;
AddonVersion versionMin, version;
bool optional;
DependencyInfo(std::string id,
const AddonVersion& versionMin,
const AddonVersion& version,
bool optional)
: id(std::move(id)),
versionMin(versionMin.empty() ? version : versionMin),
version(version),
optional(optional)
{
}

bool operator==(const DependencyInfo& rhs) const
{
return id == rhs.id && versionMin == rhs.versionMin && version == rhs.version &&
optional == rhs.optional;
}

bool operator!=(const DependencyInfo& rhs) const
{
return !(rhs == *this);
}
};

using InfoMap = std::map<std::string, std::string>;
using ArtMap = std::map<std::string, std::string>;

} /* namespace ADDON */
1 change: 1 addition & 0 deletions xbmc/addons/addoninfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(SOURCES AddonInfoBuilder.cpp
set(HEADERS AddonInfoBuilder.h
AddonExtensions.h
AddonInfo.h
AddonInfoTypes.h
AddonType.h)

core_add_library(addons_addoninfo)
2 changes: 2 additions & 0 deletions xbmc/addons/binary-addons/BinaryAddonBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "BinaryAddonBase.h"

#include "addons/addoninfo/AddonInfo.h"

#include "threads/SingleLock.h"
#include "utils/log.h"

Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/binary-addons/BinaryAddonBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#include "AddonInstanceHandler.h"
#include "addons/addoninfo/AddonInfo.h"
#include "addons/addoninfo/AddonInfoTypes.h"
#include "threads/CriticalSection.h"

#include <memory>
Expand Down
1 change: 1 addition & 0 deletions xbmc/addons/settings/AddonSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "GUIInfoManager.h"
#include "LangInfo.h"
#include "ServiceBroker.h"
#include "addons/addoninfo/AddonInfo.h"
#include "addons/gui/GUIDialogAddonSettings.h"
#include "addons/settings/SettingUrlEncodedString.h"
#include "filesystem/Directory.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/games/addons/GameClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "GameClientSubsystem.h"
#include "addons/addoninfo/AddonInfoTypes.h"
#include "addons/binary-addons/AddonDll.h"
#include "addons/kodi-dev-kit/include/kodi/addon-instance/Game.h"
#include "threads/CriticalSection.h"
Expand Down
2 changes: 1 addition & 1 deletion xbmc/platform/win32/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ WINRT_WARNING_PUSH
/* empty */

#include "FileItem.h" //63 seconds
#include "addons/addoninfo/AddonInfo.h" // 62 seconds
#include "addons/addoninfo/AddonInfoTypes.h" // 62 seconds
1 change: 1 addition & 0 deletions xbmc/utils/FileExtensionProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "ServiceBroker.h"
#include "addons/AddonManager.h"
#include "addons/addoninfo/AddonInfo.h"
#include "settings/AdvancedSettings.h"
#include "settings/SettingsComponent.h"

Expand Down
2 changes: 1 addition & 1 deletion xbmc/utils/FileExtensionProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#pragma once

#include "addons/AddonEvents.h"
#include "addons/addoninfo/AddonInfo.h"
#include "addons/addoninfo/AddonType.h"
#include "settings/AdvancedSettings.h"

namespace ADDON
Expand Down

0 comments on commit 9c7ba3e

Please sign in to comment.