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

[Nexus] API related update #136

Merged
merged 3 commits into from
Jan 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace
{

inline const char* kodiTranslateLogLevel(const AddonLog logLevel)
inline const char* kodiTranslateLogLevel(const ADDON_LOG logLevel)
{
switch (logLevel)
{
Expand All @@ -38,7 +38,7 @@ inline const char* kodiTranslateLogLevel(const AddonLog logLevel)
return "LOG_UNKNOWN: ";
}

inline void kodiLog(const AddonLog logLevel, const char* format, ...)
inline void kodiLog(const ADDON_LOG logLevel, const char* format, ...)
{
char buffer[16384];
va_list args;
Expand Down
23 changes: 14 additions & 9 deletions src/RarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#define CONTINUE_PROCESSING 1
#define SUCCESS 0

// Prevent conflicts with Windows macros where have this names.
#ifdef GetTempPath
#undef GetTempPath
#endif // GetTempPath

CRARControl::CRARControl(const std::string& rarPath)
: m_path(rarPath)
{
Expand Down Expand Up @@ -134,11 +139,11 @@ int CRARControl::ArchiveExtract(const std::string& targetPath, const std::string
int retValue = 0;
char name[MAX_PATH_LENGTH];

if (!kodi::vfs::FileExists(m_path))
/* if (!kodi::vfs::FileExists(m_path))
{
kodiLog(ADDON_LOG_DEBUG, "CRARControl::%s: Request file %s not present", __func__, m_path.c_str());
return retValue;
}
}*/

bool all = (fileToExtract.empty() || fileToExtract == "*");

Expand Down Expand Up @@ -177,7 +182,7 @@ int CRARControl::ArchiveExtract(const std::string& targetPath, const std::string
// is to see that something works
m_progress = std::make_shared<kodi::gui::dialogs::CExtendedProgress>();
m_progress->SetPercentage(0.0f);
m_progress->SetTitle(kodi::GetLocalizedString(solid ? 30002 : 30001));
m_progress->SetTitle(kodi::addon::GetLocalizedString(solid ? 30002 : 30001));
m_progress->SetText(m_path);
}

Expand Down Expand Up @@ -243,18 +248,18 @@ int CRARControl::ArchiveExtract(const std::string& targetPath, const std::string
int64 diskSpace = GetFreeDisk(path);

// Check filesize + 10 MByte is available on disk
if (m_extractFileSize + (10 * 1024 * 1024) >= diskSpace)
/* if (m_extractFileSize + (10 * 1024 * 1024) >= diskSpace)
{
kodiLog(ADDON_LOG_ERROR, "CRARControl::%s: Not enough diskSpace with %li MB for file %s with size %li MB",
__func__, diskSpace / 1024 / 1024, m_path.c_str(), m_extractFileSize / 1024 / 1024);
kodi::QueueNotification(QUEUE_ERROR, kodi::GetLocalizedString(30000), kodi::GetLocalizedString(30004));
kodi::QueueNotification(QUEUE_ERROR, kodi::addon::GetLocalizedString(30000), kodi::addon::GetLocalizedString(30004));
return 0;
}
}*/

if (m_progress)
{
// After wanted file is found to progress with his real extract
m_progress->SetTitle(kodi::GetLocalizedString(30000));
m_progress->SetTitle(kodi::addon::GetLocalizedString(30000));
m_progress->SetText(filename);
m_progress->SetProgress(int(float(m_extractedFileSize) / float(m_extractFileSize) * 100), 100);
}
Expand Down Expand Up @@ -426,7 +431,7 @@ int CRARControl::NeedPassword(char* password, size_t size)
if (!passwordAskAllowed && pw.empty())
return STOP_PROCESSING;

std::string header = StringFormat(kodi::GetLocalizedString(30003).c_str(), m_path.length() > 45 ? kodi::vfs::GetFileName(m_path).c_str() : m_path.c_str());
std::string header = StringFormat(kodi::addon::GetLocalizedString(30003).c_str(), m_path.length() > 45 ? kodi::vfs::GetFileName(m_path).c_str() : m_path.c_str());
if (!pw.empty() || kodi::gui::dialogs::Keyboard::ShowAndGetInput(pw, header, false, true))
{
strncpy(password, pw.c_str(), size);
Expand Down Expand Up @@ -485,7 +490,7 @@ RARContext::RARContext(const kodi::addon::VFSUrl& url)
, m_arc(&m_cmd)
, m_extract(&m_cmd)
{
m_cachedir = kodi::GetTempAddonPath("/");
m_cachedir = kodi::addon::GetTempPath("/");
m_password = url.GetPassword();
m_pathinrar = url.GetFilename();
std::replace(m_pathinrar.begin(), m_pathinrar.end(), '\\', '/');
Expand Down
7 changes: 4 additions & 3 deletions src/RarFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,14 @@ class CMyAddon : public kodi::addon::CAddonBase
CRARPasswordControl::CleanupPasswordList();
}

ADDON_STATUS CreateInstance(int instanceType, const std::string& instanceID, KODI_HANDLE instance, const std::string& version, KODI_HANDLE& addonInstance) override
ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo& instance,
KODI_ADDON_INSTANCE_HDL& hdl) override
{
addonInstance = new CRARFile(instance, version);
hdl = new CRARFile(instance);
return ADDON_STATUS_OK;
}

ADDON_STATUS SetSetting(const std::string& settingName, const kodi::CSettingValue& settingValue) override
ADDON_STATUS SetSetting(const std::string& settingName, const kodi::addon::CSettingValue& settingValue) override
{
CRarManager::Get().SettingsUpdate(settingName, settingValue);
return ADDON_STATUS_OK;
Expand Down
2 changes: 1 addition & 1 deletion src/RarFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class CRARFile : public kodi::addon::CInstanceVFS
{
public:
CRARFile(KODI_HANDLE instance, const std::string& version) : CInstanceVFS(instance, version) { }
CRARFile(const kodi::addon::IInstanceInfo& instance) : CInstanceVFS(instance) { }

kodi::addon::VFSFileHandle Open(const kodi::addon::VFSUrl& url) override;
bool Close(kodi::addon::VFSFileHandle context) override;
Expand Down
21 changes: 11 additions & 10 deletions src/RarManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ CRarManager& CRarManager::Get()
CRarManager::CRarManager()
{
// Load the current settings and store to reduce call amount of them
m_asksToUnpack = kodi::GetSettingBoolean("asks_to_unpack");
m_passwordAskAllowed = kodi::GetSettingBoolean("usercheck_for_password");
m_asksToUnpack = kodi::addon::GetSettingBoolean("asks_to_unpack");
m_passwordAskAllowed = kodi::addon::GetSettingBoolean("usercheck_for_password");
for (unsigned int i = 0; i < MAX_STANDARD_PASSWORDS; ++i)
m_standardPasswords[i] = kodi::GetSettingString("standard_password_" + std::to_string(i+1));
m_standardPasswords[i] = kodi::addon::GetSettingString("standard_password_" + std::to_string(i+1));
}

CRarManager::~CRarManager()
{
ClearCache(true);
}

void CRarManager::SettingsUpdate(const std::string& settingName, const kodi::CSettingValue& settingValue)
void CRarManager::SettingsUpdate(const std::string& settingName, const kodi::addon::CSettingValue& settingValue)
{
// Update the by CMyAddon called settings values, done after change inside
// addon settings by e.g. user.
Expand All @@ -89,6 +89,7 @@ bool CRarManager::CacheRarredFile(std::string& strPathInCache, const std::string
const std::string& strPathInRar, uint8_t bOptions,
const std::string& strDir, const int64_t iSize)
{
fprintf(stderr, "---------------------------------------------------------------------------- '%s' '%s'\n", strRarPath.c_str(), strPathInRar.c_str());
bool bShowProgress=false;
if ((iSize > 1024*1024 || iSize == -2) && !(bOptions & EXFILE_NOCACHE)) // 1MB
bShowProgress=true;
Expand Down Expand Up @@ -138,20 +139,20 @@ bool CRarManager::CacheRarredFile(std::string& strPathInCache, const std::string

if (m_asksToUnpack && iSize > EXTRACTION_WARN_SIZE)
{
if (!kodi::gui::dialogs::YesNo::ShowAndGetInput(kodi::GetLocalizedString(30019),
kodi::GetLocalizedString(30020),
if (!kodi::gui::dialogs::YesNo::ShowAndGetInput(kodi::addon::GetLocalizedString(30019),
kodi::addon::GetLocalizedString(30020),
kodi::vfs::GetFileName(strRarPath),
""))
return false;
}

if (CheckFreeSpace(strDir) < iSize)
/* if (CheckFreeSpace(strDir) < iSize)
{
ClearCache();
if (CheckFreeSpace(strDir) < iSize)
{
std::vector<kodi::vfs::CDirEntry> items;
kodi::vfs::GetDirectory(kodi::GetTempAddonPath("/"), "", items);
kodi::vfs::GetDirectory(kodi::addon::GetTempPath("/"), "", items);
while (!items.empty() && CheckFreeSpace(strDir) < iSize)
{
std::string path = items.back().Path();
Expand All @@ -166,11 +167,11 @@ bool CRarManager::CacheRarredFile(std::string& strPathInCache, const std::string

if (items.empty())
{
kodi::QueueNotification(QUEUE_ERROR, "", kodi::GetLocalizedString(30021));
kodi::QueueNotification(QUEUE_ERROR, "", kodi::addon::GetLocalizedString(30021));
return false;
}
}
}
}*/

std::string cf = strDir+"rarfolderXXXXXX";
#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion src/RarManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CRarManager
void ClearCachedFile(const std::string& strRarPath, const std::string& strPathInRar);
void ExtractArchive(const std::string& strArchive, const std::string& strPath);

void SettingsUpdate(const std::string& settingName, const kodi::CSettingValue& settingValue);
void SettingsUpdate(const std::string& settingName, const kodi::addon::CSettingValue& settingValue);
bool PasswordAskAllowed() const { return m_passwordAskAllowed; }
const std::string& StandardPassword(int no) { return m_standardPasswords[no]; }

Expand Down
8 changes: 4 additions & 4 deletions src/RarPassword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
void CRARPasswordControl::CleanupPasswordList()
{
TiXmlDocument xmlDoc;
std::string strSettingsFile = kodi::GetBaseUserPath("rar-control.xml");
std::string strSettingsFile = kodi::addon::GetUserPath("rar-control.xml");

// Check file present and available, if not do nothing
if (!kodi::vfs::FileExists(strSettingsFile))
Expand Down Expand Up @@ -65,7 +65,7 @@ void CRARPasswordControl::CleanupPasswordList()
bool CRARPasswordControl::GetPassword(const std::string& path, std::string& password, bool& passwordSeemsBad)
{
TiXmlDocument xmlDoc;
std::string strSettingsFile = kodi::GetBaseUserPath("rar-control.xml");
std::string strSettingsFile = kodi::addon::GetUserPath("rar-control.xml");

if (!kodi::vfs::FileExists(strSettingsFile))
return false;
Expand Down Expand Up @@ -113,7 +113,7 @@ bool CRARPasswordControl::GetPassword(const std::string& path, std::string& pass
bool CRARPasswordControl::SavePassword(const std::string& path, const std::string& password, const bool& passwordSeemsBad)
{
TiXmlDocument xmlDoc;
std::string strSettingsFile = kodi::GetBaseUserPath("rar-control.xml");
std::string strSettingsFile = kodi::addon::GetUserPath("rar-control.xml");

if (kodi::vfs::FileExists(strSettingsFile))
{
Expand All @@ -124,7 +124,7 @@ bool CRARPasswordControl::SavePassword(const std::string& path, const std::strin
}
}
else
kodi::vfs::CreateDirectory(kodi::GetBaseUserPath());
kodi::vfs::CreateDirectory(kodi::addon::GetUserPath());

bool isUpdated = false;
TiXmlElement* pElement = xmlDoc.FirstChildElement("data");
Expand Down
6 changes: 5 additions & 1 deletion vfs.rar/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="vfs.rar"
version="20.0.0"
version="20.1.0"
name="RAR archive support"
provider-name="spiff">
<requires>@ADDON_DEPENDS@</requires>
Expand All @@ -25,16 +25,20 @@
<summary lang="ca_ES">Desarxivador per fitxers .rar</summary>
<summary lang="de_DE">Entpacker für Rar-Dateien</summary>
<summary lang="en_GB">Unarchiver for .rar files</summary>
<summary lang="es_MX">Descompresor de archivos .rar</summary>
<summary lang="ko_KR">.rar 파일용 아카이브 추출</summary>
<summary lang="pl_PL">Ekstraktor plików .rar</summary>
<summary lang="pt_BR">Descompactador para arquivos .rar</summary>
<summary lang="ru_RU">Распаковщик для архивов .rar</summary>
<summary lang="sv_SE">Uppackare för .rar-filer</summary>
<summary lang="zh_CN">解压 .rar 文件</summary>
<description lang="ca_ES">Aquest complement és una utilitat d'extracció per a arxius RAR.[CR][CR]Permet la lectura directa de fitxers RAR sense comprimir, de manera que no és necessari desempaquetar prèviament. Per a la resta de tipus, es desempaqueta temporalment i es passa a Kodi.[CR][CR]Atenció: el tipus d'arxiu &quot;RAR sòlid&quot; requereix descomprimir completament per utilitzar els fitxers. Per tant, els temps d'accés poden ser llargs pels paquets més grans.</description>
<description lang="de_DE">Dieses Addon dient zum Entpacken von RAR-Archiven.[CR][CR]Es ermöglicht das direkte Lesen nicht komprimierter RAR-Dateien, sodass ein vorheriges Entpacken nicht erforderlich ist. Bei allen anderen Typen wird der Inhalt temporär entpackt und an Kodi übertragen.[CR][CR]Achtung: Der Archivtyp &quot;Solid RAR&quot; erfordert ein vollständiges Entpacken, um die darin enthaltenen Dateien zu verwenden. Daher können die Zugriffszeiten für größere Pakete länger sein.</description>
<description lang="en_GB">This addon is an extraction utility for RAR archives.[CR][CR]It allows direct reading of uncompressed RAR files, so prior unpacking is not necessary. For all other types, it is temporarily unpacked and passed to Kodi.[CR][CR]Attention: A &quot;Solid RAR&quot; archive type requires complete unpacking to use files within it. Hence access times may be long for larger packages.</description>
<description lang="es_MX">Este complemento es una utilidad de extracción para archivos RAR.[CR][CR]Permite lectura directa de archivos RAR sin compresión, así que no es necesario descomprimir previamente. Para todos los demás tipos, se descomprime temporalmente y se pasa esto a Kodi.[CR][CR]Atención: Un archivo del tipo &quot;RAR sólido&quot; requiere descompresión completa para utilizar los archivos dentro de. Debido a esto los tiempos de acceso pueden ser extensos para archivos grandes.</description>
<description lang="ko_KR">이 애드온은 RAR 아카이브용 추출 유틸리티입니다.[CR][CR]압축되지 않은 RAR 파일을 직접 읽을 수 있으므로 사전 압축 풀기가 필요하지 않습니다. 다른 모든 유형의 경우 일시적으로 압축을 풀고 Kodi로 전달됩니다.[CR][CR]주의: &quot;Solid RAR&quot; 아카이브 유형은 그 안에 있는 파일을 사용하기 위해 완전히 압축을 풀어야 합니다. 따라서 더 큰 패키지의 경우 액세스 시간이 길어질 수 있습니다.</description>
<description lang="pl_PL">Ten dodatek jest narzędziem do ekstrakcji archiwów RAR.[CR][CR]Pozwala na bezpośredni odczyt nieskompresowanych plików RAR, więc wcześniejsze rozpakowanie nie jest konieczne. W przypadku wszystkich innych typów są one tymczasowo rozpakowywane i przekazywane do Kodi.[CR][CR]Uwaga: typ archiwum „Ciągły RAR” wymaga całkowitego rozpakowania, aby móc korzystać z zawartych w nim plików. Z tego powodu czasy dostępu mogą być długie w przypadku większych pakietów.</description>
<description lang="pt_BR">Este add-on é um utilitário de extração para arquivos RAR.[CR][CR]Ele permite a leitura direta de arquivos RAR sem compressão, nos quais a descompactação prévia não é necessária. Para todos os outros tipos, os arquivos são descompactados temporariamente e repassados para o Kodi.[CR][CR]Atenção: Um arquivo do tipo &quot;RAR Sólido&quot; requer uma descompactação completa para acesso aos arquivos contidos. Consequentemente, os tempos de acesso podem ser mais longos em pacotes maiores.</description>
<description lang="ru_RU">Это дополнение представляет собой утилиту для работы с архивами RAR.[CR][CR]Оно позволяет напрямую читать несжатые файлы RAR, поэтому предварительная распаковка не требуется. Для всех остальных типов архив временно распаковывается и данные передаются в Kodi.[CR][CR]Внимание: Тип архива &quot;Непрерывный&quot; требует полной распаковки для использования файлов из него. Поэтому для больших пакетов время доступа увеличится.</description>
<description lang="sv_SE">Detta tillägg är ett uppackningsverktyg för RAR-arkiv.[CR][CR]Detta gör det möjligt att spela upp okomprimerade RAR-filer utan att de först packas upp. För alla andra typer, packas den upp tillfälligt och skickas sedan till Kodi.[CR][CR]Observera: Ett &quot;Fast&quot; arkiv kräver en komplett uppackning av arkivet. Därför kan uppstartstiden ta lång tid om det är ett stort arkiv.</description>
<description lang="zh_CN">此插件是 RAR 压缩文件的解压实用程序。[CR][CR]它允许直接读取 RAR 文件,因此无需事先解压缩。对于所有其他类型,它会临时解包并传递给 Kodi。[CR][CR]注意:“Solid RAR”压缩类型需要完全解包才能使用其中的文件。对于较大的压缩包,访问时间可能较长。</description>
Expand Down
18 changes: 9 additions & 9 deletions vfs.rar/resources/language/resource.language.da_dk/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ msgstr ""
"Project-Id-Version: KODI Main\n"
"Report-Msgid-Bugs-To: translations@kodi.tv\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2021-07-27 10:49+0000\n"
"PO-Revision-Date: 2021-10-25 10:02+0000\n"
"Last-Translator: Christian Gade <gade@kodi.tv>\n"
"Language-Team: Danish <https://kodi.weblate.cloud/projects/kodi-add-ons-virtual-filesystems/vfs-rar/da_dk/>\n"
"Language: da_dk\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.7.2\n"
"X-Generator: Weblate 4.8\n"

msgctxt "Addon Summary"
msgid "Unarchiver for .rar files"
Expand Down Expand Up @@ -63,7 +63,7 @@ msgstr "Generel"

msgctxt "#30011"
msgid "Ask for password"
msgstr "Spørg efter kodeord"
msgstr "Spørg efter adgangskode"

msgctxt "#30012"
msgid "If archives are password protected, prompt for the password to be entered"
Expand All @@ -75,23 +75,23 @@ msgstr "Foruddefineret adgangskode til at forsøge dekompression med"

msgctxt "#30014"
msgid "Stored password 1"
msgstr "Gemt kodeord 1"
msgstr "Gemt adgangskode 1"

msgctxt "#30015"
msgid "Stored password 2"
msgstr "Gemt kodeord 2"
msgstr "Gemt adgangskode 2"

msgctxt "#30016"
msgid "Stored password 3"
msgstr "Gemt kodeord 3"
msgstr "Gemt adgangskode 3"

msgctxt "#30017"
msgid "Stored password 4"
msgstr "Gemt kodeord 4"
msgstr "Gemt adgangskode 4"

msgctxt "#30018"
msgid "Stored password 5"
msgstr "Gemt kodeord 5"
msgstr "Gemt adgangskode 5"

msgctxt "#30019"
msgid "Confirm copy"
Expand All @@ -107,7 +107,7 @@ msgstr "Ikke nok tilgængelig hukommelse til at dekomprimere filen"

msgctxt "#30022"
msgid "Passwords"
msgstr "Kodeord"
msgstr "Adgangskoder"

msgctxt "#30023"
msgid "Asks to unpack"
Expand Down