Skip to content

Commit

Permalink
Implemented stubs for languages module
Browse files Browse the repository at this point in the history
  • Loading branch information
Eism authored and igorkorsukov committed Jan 21, 2021
1 parent 4c705d9 commit 436cdf8
Show file tree
Hide file tree
Showing 36 changed files with 525 additions and 90 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ set(TELEMETRY_TRACK_ID "" CACHE STRING "Telemetry track id")
set(CRASH_REPORT_URL "" CACHE STRING "URL where to send crash reports")

option(BUILD_NETWORK_MODULE "Build network module" ON)
option(BUILD_LANGUAGES_MODULE "Build languages module" ON)

option(SOUNDFONT3 "Ogg Vorbis compressed fonts" ON) # Enable Ogg Vorbis compressed fonts, requires Ogg & Vorbis
option(DOWNLOAD_SOUNDFONT "Download the latest soundfont version as part of the build process" ON)
Expand Down
1 change: 1 addition & 0 deletions build/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define TELEMETRY_TRACK_ID "${TELEMETRY_TRACK_ID}"

#cmakedefine BUILD_NETWORK_MODULE
#cmakedefine BUILD_LANGUAGES_MODULE

#cmakedefine WIN_SPARKLE_ENABLED
#cmakedefine MAC_SPARKLE_ENABLED
Expand Down
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ if (NOT OS_IS_WASM)

add_subdirectory(cloud)
add_subdirectory(extensions)
add_subdirectory(languages)

if (BUILD_LANGUAGES_MODULE)
add_subdirectory(languages)
endif (BUILD_LANGUAGES_MODULE)

add_subdirectory(plugins)
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/appshell/qml/HomePage/AddonsContent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ FocusScope {
search: searchField.searchText
backgroundColor: root.color
}

LanguagesPage {
id: languagesComp

Expand Down
6 changes: 3 additions & 3 deletions src/languages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/languagestypes.h
${CMAKE_CURRENT_LIST_DIR}/languageserrors.h
${CMAKE_CURRENT_LIST_DIR}/ilanguagesconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/ilanguagescontroller.h
${CMAKE_CURRENT_LIST_DIR}/ilanguagesservice.h
${CMAKE_CURRENT_LIST_DIR}/ilanguageunpacker.h
${CMAKE_CURRENT_LIST_DIR}/internal/languagesconfiguration.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/languagesconfiguration.h
${CMAKE_CURRENT_LIST_DIR}/internal/languagescontroller.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/languagescontroller.h
${CMAKE_CURRENT_LIST_DIR}/internal/languagesservice.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/languagesservice.h
${CMAKE_CURRENT_LIST_DIR}/internal/languageunpacker.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/languageunpacker.h
${CMAKE_CURRENT_LIST_DIR}/view/languagelistmodel.cpp
Expand Down
4 changes: 1 addition & 3 deletions src/languages/ilanguagesconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include "io/path.h"
#include "languagestypes.h"

namespace mu {
namespace languages {
namespace mu::languages {
class ILanguagesConfiguration : MODULE_EXPORT_INTERFACE
{
INTERFACE_ID(ILanguagesConfiguration)
Expand All @@ -49,6 +48,5 @@ class ILanguagesConfiguration : MODULE_EXPORT_INTERFACE
virtual io::path languageArchivePath(const QString& languageCode) const = 0;
};
}
}

#endif // MU_LANGUAGES_ILANGUAGESCONFIGURATION_H
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_LANGUAGES_ILANGUAGESCONTROLLER_H
#define MU_LANGUAGES_ILANGUAGESCONTROLLER_H
#ifndef MU_LANGUAGES_ILANGUAGESSERVICE_H
#define MU_LANGUAGES_ILANGUAGESSERVICE_H

#include "modularity/imoduleexport.h"
#include "retval.h"

#include "languagestypes.h"

namespace mu {
namespace languages {
class ILanguagesController : MODULE_EXPORT_INTERFACE
namespace mu::languages {
class ILanguagesService : MODULE_EXPORT_INTERFACE
{
INTERFACE_ID(ILanguagesController)
INTERFACE_ID(ILanguagesService)

public:
virtual ~ILanguagesController() = default;
virtual ~ILanguagesService() = default;

virtual ValCh<LanguagesHash> languages() const = 0;
virtual RetCh<LanguageProgress> install(const QString& languageCode) = 0;
Expand All @@ -44,6 +43,5 @@ class ILanguagesController : MODULE_EXPORT_INTERFACE
virtual RetCh<Language> languageChanged() = 0;
};
}
}

#endif // MU_LANGUAGES_ILANGUAGESCONTROLLER_H
#endif // MU_LANGUAGES_ILANGUAGESSERVICE_H
4 changes: 1 addition & 3 deletions src/languages/ilanguageunpacker.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include "modularity/imoduleexport.h"
#include "ret.h"

namespace mu {
namespace languages {
namespace mu::languages {
class ILanguageUnpacker : MODULE_EXPORT_INTERFACE
{
INTERFACE_ID(ILanguageUnpacker)
Expand All @@ -36,6 +35,5 @@ class ILanguageUnpacker : MODULE_EXPORT_INTERFACE
virtual Ret unpack(const QString& languageCode, const QString& source, const QString& destination) const = 0;
};
}
}

#endif // MU_LANGUAGES_ILANGUAGEUNPACKER_H
4 changes: 1 addition & 3 deletions src/languages/internal/languagesconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include "iglobalconfiguration.h"
#include "framework/system/ifilesystem.h"

namespace mu {
namespace languages {
namespace mu::languages {
class LanguagesConfiguration : public ILanguagesConfiguration
{
INJECT(languages, framework::IGlobalConfiguration, globalConfiguration)
Expand Down Expand Up @@ -56,6 +55,5 @@ class LanguagesConfiguration : public ILanguagesConfiguration
async::Channel<LanguagesHash> m_languagesHashChanged;
};
}
}

#endif // MU_LANGUAGES_LANGUAGESCONFIGURATION_H
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "languagescontroller.h"
#include "languagesservice.h"

#include <QDir>
#include <QTranslator>
Expand Down Expand Up @@ -44,26 +44,26 @@ static const QStringList languageFileTypes = {
"tours"
};

void LanguagesController::init()
void LanguagesService::init()
{
fileSystem()->makePath(configuration()->languagesSharePath());
fileSystem()->makePath(configuration()->languagesDataPath());

QString code = configuration()->currentLanguageCode();
loadLanguage(code);

QtConcurrent::run(this, &LanguagesController::th_refreshLanguages);
QtConcurrent::run(this, &LanguagesService::th_refreshLanguages);
}

ValCh<LanguagesHash> LanguagesController::languages() const
ValCh<LanguagesHash> LanguagesService::languages() const
{
ValCh<LanguagesHash> languagesHash = configuration()->languages();
languagesHash.val = correctLanguagesStates(languagesHash.val).val;

return languagesHash;
}

RetCh<LanguageProgress> LanguagesController::install(const QString& languageCode)
RetCh<LanguageProgress> LanguagesService::install(const QString& languageCode)
{
RetCh<LanguageProgress> result;

Expand Down Expand Up @@ -104,12 +104,12 @@ RetCh<LanguageProgress> LanguagesController::install(const QString& languageCode
m_languageChanged.send(languageHash[languageCode]);
closeOperation(languageCode, languageProgressStatus);
}, Asyncable::AsyncMode::AsyncSetRepeat);
QtConcurrent::run(this, &LanguagesController::th_install, languageCode, languageProgressStatus, languageFinishChannel);
QtConcurrent::run(this, &LanguagesService::th_install, languageCode, languageProgressStatus, languageFinishChannel);

return result;
}

RetCh<LanguageProgress> LanguagesController::update(const QString& languageCode)
RetCh<LanguageProgress> LanguagesService::update(const QString& languageCode)
{
RetCh<LanguageProgress> result;

Expand Down Expand Up @@ -151,12 +151,12 @@ RetCh<LanguageProgress> LanguagesController::update(const QString& languageCode)
closeOperation(languageCode, languageProgressStatus);
}, Asyncable::AsyncMode::AsyncSetRepeat);

QtConcurrent::run(this, &LanguagesController::th_update, languageCode, languageProgressStatus, languageFinishChannel);
QtConcurrent::run(this, &LanguagesService::th_update, languageCode, languageProgressStatus, languageFinishChannel);

return result;
}

Ret LanguagesController::uninstall(const QString& languageCode)
Ret LanguagesService::uninstall(const QString& languageCode)
{
LanguagesHash languagesHash = languages().val;

Expand Down Expand Up @@ -184,7 +184,7 @@ Ret LanguagesController::uninstall(const QString& languageCode)
return make_ret(Err::NoError);
}

RetVal<Language> LanguagesController::currentLanguage() const
RetVal<Language> LanguagesService::currentLanguage() const
{
RetVal<Language> result;

Expand All @@ -207,7 +207,7 @@ RetVal<Language> LanguagesController::currentLanguage() const
return result;
}

Ret LanguagesController::setCurrentLanguage(const QString& languageCode)
Ret LanguagesService::setCurrentLanguage(const QString& languageCode)
{
if (languageCode == DEFAULT_LANGUAGE) {
resetLanguageByDefault();
Expand Down Expand Up @@ -246,15 +246,15 @@ Ret LanguagesController::setCurrentLanguage(const QString& languageCode)
return save;
}

RetCh<Language> LanguagesController::languageChanged()
RetCh<Language> LanguagesService::languageChanged()
{
RetCh<Language> result;
result.ret = make_ret(Err::NoError);
result.ch = m_languageChanged;
return result;
}

RetVal<LanguagesHash> LanguagesController::parseLanguagesConfig(const QByteArray& json) const
RetVal<LanguagesHash> LanguagesService::parseLanguagesConfig(const QByteArray& json) const
{
RetVal<LanguagesHash> result;

Expand Down Expand Up @@ -287,7 +287,7 @@ RetVal<LanguagesHash> LanguagesController::parseLanguagesConfig(const QByteArray
return result;
}

LanguageFiles LanguagesController::parseLanguageFiles(const QJsonObject& languageObject) const
LanguageFiles LanguagesService::parseLanguageFiles(const QJsonObject& languageObject) const
{
LanguageFiles files;

Expand All @@ -302,13 +302,13 @@ LanguageFiles LanguagesController::parseLanguageFiles(const QJsonObject& languag
return files;
}

bool LanguagesController::isLanguageExists(const QString& languageCode) const
bool LanguagesService::isLanguageExists(const QString& languageCode) const
{
io::paths files = configuration()->languageFilePaths(languageCode);
return !files.empty();
}

bool LanguagesController::checkLanguageFilesHash(const QString& languageCode, const LanguageFiles& languageFiles) const
bool LanguagesService::checkLanguageFilesHash(const QString& languageCode, const LanguageFiles& languageFiles) const
{
io::paths filePaths = configuration()->languageFilePaths(languageCode);
int filesSize = static_cast<int>(filePaths.size());
Expand Down Expand Up @@ -346,7 +346,7 @@ bool LanguagesController::checkLanguageFilesHash(const QString& languageCode, co
return true;
}

RetVal<LanguagesHash> LanguagesController::correctLanguagesStates(LanguagesHash& languages) const
RetVal<LanguagesHash> LanguagesService::correctLanguagesStates(LanguagesHash& languages) const
{
RetVal<LanguagesHash> result;
bool isNeedUpdate = false;
Expand Down Expand Up @@ -376,7 +376,7 @@ RetVal<LanguagesHash> LanguagesController::correctLanguagesStates(LanguagesHash&
return result;
}

LanguageStatus::Status LanguagesController::languageStatus(const Language& language) const
LanguageStatus::Status LanguagesService::languageStatus(const Language& language) const
{
if (!isLanguageExists(language.code)) {
return LanguageStatus::Status::NoInstalled;
Expand All @@ -389,7 +389,7 @@ LanguageStatus::Status LanguagesController::languageStatus(const Language& langu
return LanguageStatus::Status::Installed;
}

RetVal<QString> LanguagesController::downloadLanguage(const QString& languageCode, async::Channel<LanguageProgress>* progressChannel) const
RetVal<QString> LanguagesService::downloadLanguage(const QString& languageCode, async::Channel<LanguageProgress>* progressChannel) const
{
RetVal<QString> result;

Expand Down Expand Up @@ -420,7 +420,7 @@ RetVal<QString> LanguagesController::downloadLanguage(const QString& languageCod
return result;
}

Ret LanguagesController::removeLanguage(const QString& languageCode) const
Ret LanguagesService::removeLanguage(const QString& languageCode) const
{
io::paths files = configuration()->languageFilePaths(languageCode);

Expand All @@ -435,7 +435,7 @@ Ret LanguagesController::removeLanguage(const QString& languageCode) const
return make_ret(Err::NoError);
}

Ret LanguagesController::loadLanguage(const QString& languageCode)
Ret LanguagesService::loadLanguage(const QString& languageCode)
{
io::paths files = configuration()->languageFilePaths(languageCode);

Expand All @@ -458,7 +458,7 @@ Ret LanguagesController::loadLanguage(const QString& languageCode)
return make_ret(Err::NoError);
}

void LanguagesController::resetLanguageByDefault()
void LanguagesService::resetLanguageByDefault()
{
Ret load = loadLanguage(DEFAULT_LANGUAGE);
if (!load) {
Expand All @@ -468,7 +468,7 @@ void LanguagesController::resetLanguageByDefault()
configuration()->setCurrentLanguageCode(DEFAULT_LANGUAGE);
}

void LanguagesController::th_refreshLanguages()
void LanguagesService::th_refreshLanguages()
{
QBuffer buff;
INetworkManagerPtr networkManagerPtr = networkManagerCreator()->makeNetworkManager();
Expand Down Expand Up @@ -507,8 +507,8 @@ void LanguagesController::th_refreshLanguages()
configuration()->setLanguages(resultLanguages);
}

void LanguagesController::th_install(const QString& languageCode, async::Channel<LanguageProgress>* progressChannel,
async::Channel<Ret>* finishChannel)
void LanguagesService::th_install(const QString& languageCode, async::Channel<LanguageProgress>* progressChannel,
async::Channel<Ret>* finishChannel)
{
progressChannel->send(LanguageProgress(ANALYSING_STATUS, true));

Expand Down Expand Up @@ -536,8 +536,8 @@ void LanguagesController::th_install(const QString& languageCode, async::Channel
finishChannel->send(make_ret(Err::NoError));
}

void LanguagesController::th_update(const QString& languageCode, async::Channel<LanguageProgress>* progressChannel,
async::Channel<Ret>* finishChannel)
void LanguagesService::th_update(const QString& languageCode, async::Channel<LanguageProgress>* progressChannel,
async::Channel<Ret>* finishChannel)
{
progressChannel->send(LanguageProgress(ANALYSING_STATUS, true));

Expand Down Expand Up @@ -566,7 +566,7 @@ void LanguagesController::th_update(const QString& languageCode, async::Channel<
finishChannel->send(make_ret(Err::NoError));
}

void LanguagesController::closeOperation(const QString& languageCode, async::Channel<LanguageProgress>* progressChannel)
void LanguagesService::closeOperation(const QString& languageCode, async::Channel<LanguageProgress>* progressChannel)
{
progressChannel->close();
m_operationsHash.remove(languageCode);
Expand Down
Loading

0 comments on commit 436cdf8

Please sign in to comment.