Skip to content

Commit

Permalink
Implemented stubs for system module
Browse files Browse the repository at this point in the history
  • Loading branch information
Eism authored and igorkorsukov committed Jan 25, 2021
1 parent edcc817 commit 6dc23eb
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ option(BUILD_TELEMETRY_MODULE "Build with telemetry module" ON)
set(TELEMETRY_TRACK_ID "" CACHE STRING "Telemetry track id")
set(CRASH_REPORT_URL "" CACHE STRING "URL where to send crash reports")

option(BUILD_SYSTEM_MODULE "Build system module" ON)
option(BUILD_NETWORK_MODULE "Build network module" ON)
option(BUILD_USERSCORES_MODULE "Build userscores module" ON)
option(BUILD_WORKSPACE_MODULE "Build workspace module" 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 @@ -43,6 +43,7 @@
#cmakedefine BUILD_TELEMETRY_MODULE
#define TELEMETRY_TRACK_ID "${TELEMETRY_TRACK_ID}"

#cmakedefine BUILD_SYSTEM_MODULE
#cmakedefine BUILD_NETWORK_MODULE
#cmakedefine BUILD_USERSCORES_MODULE
#cmakedefine BUILD_WORKSPACE_MODULE
Expand Down
5 changes: 4 additions & 1 deletion src/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ if (BUILD_NETWORK_MODULE)
add_subdirectory(network)
endif (BUILD_NETWORK_MODULE)

add_subdirectory(system)
if (BUILD_SYSTEM_MODULE)
add_subdirectory(system)
endif (BUILD_SYSTEM_MODULE)

add_subdirectory(audio)
add_subdirectory(midi)
add_subdirectory(midi_old)
Expand Down
10 changes: 9 additions & 1 deletion src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@
#include "framework/fonts/fontsmodule.h"
#include "framework/actions/actionsmodule.h"
#include "framework/shortcuts/shortcutsmodule.h"
#include "framework/system/systemmodule.h"

#ifdef BUILD_SYSTEM_MODULE
#include "framework/system/systemmodule.h"
#else
#include "stubs/framework/system/systemstubmodule.h"
#endif
#ifdef BUILD_NETWORK_MODULE
#include "framework/network/networkmodule.h"
#else
Expand Down Expand Up @@ -141,7 +145,11 @@ int main(int argc, char** argv)
app.addModule(new mu::fonts::FontsModule());
app.addModule(new mu::ui::UiModule());
app.addModule(new mu::uicomponents::UiComponentsModule());
#ifdef BUILD_SYSTEM_MODULE
app.addModule(new mu::system::SystemModule());
#else
app.addModule(new mu::system::SystemStubModule());
#endif

#ifdef BUILD_NETWORK_MODULE
app.addModule(new mu::network::NetworkModule());
Expand Down
2 changes: 1 addition & 1 deletion src/palette/internal/paletteworkspacesetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void PaletteWorkspaceSetup::setup()
};

RetValCh<workspace::IWorkspacePtr> workspace = workspaceManager()->currentWorkspace();
if (workspace.val) {
if (workspace.ret) {
bool ok = applyWorkspaceData(workspace.val);
if (!ok) {
Ms::PaletteTreePtr tree(Ms::PaletteCreator::newDefaultPaletteTree());
Expand Down
4 changes: 4 additions & 0 deletions src/stubs/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
if (NOT BUILD_NETWORK_MODULE)
add_subdirectory(network)
endif (NOT BUILD_NETWORK_MODULE)

if (NOT BUILD_SYSTEM_MODULE)
add_subdirectory(system)
endif (NOT BUILD_SYSTEM_MODULE)
29 changes: 29 additions & 0 deletions src/stubs/framework/system/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#=============================================================================
# MuseScore
# Music Composition & Notation
#
# Copyright (C) 2020 MuseScore BVBA and others
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=============================================================================

set(MODULE system)

set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/systemstubmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/systemstubmodule.h
${CMAKE_CURRENT_LIST_DIR}/filesystemstub.cpp
${CMAKE_CURRENT_LIST_DIR}/filesystemstub.h
)

include(${PROJECT_SOURCE_DIR}/build/module.cmake)
51 changes: 51 additions & 0 deletions src/stubs/framework/system/filesystemstub.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "filesystemstub.h"

using namespace mu::system;
using namespace mu;

Ret FileSystemStub::exists(const io::path&) const
{
return make_ret(Ret::Code::NotSupported);
}

Ret FileSystemStub::remove(const io::path&) const
{
return make_ret(Ret::Code::NotSupported);
}

Ret FileSystemStub::makePath(const io::path&) const
{
return make_ret(Ret::Code::NotSupported);
}

RetVal<io::paths> FileSystemStub::scanFiles(const io::path&, const QStringList&, IFileSystem::ScanMode) const
{
RetVal<io::paths> result;
result.ret = make_ret(Ret::Code::NotSupported);
return result;
}

RetVal<QByteArray> FileSystemStub::readFile(const io::path&) const
{
RetVal<QByteArray> result;
result.ret = make_ret(Ret::Code::NotSupported);
return result;
}
40 changes: 40 additions & 0 deletions src/stubs/framework/system/filesystemstub.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_SYSTEM_FILESYSTEMSTUB_H
#define MU_SYSTEM_FILESYSTEMSTUB_H

#include "system/ifilesystem.h"

namespace mu::system {
class FileSystemStub : public IFileSystem
{
public:
Ret exists(const io::path& path) const override;
Ret remove(const io::path& path) const override;

Ret makePath(const io::path& path) const override;

RetVal<io::paths> scanFiles(const io::path& rootDir, const QStringList& filters,
ScanMode mode = ScanMode::IncludeSubdirs) const override;

RetVal<QByteArray> readFile(const io::path& filePath) const override;
};
}

#endif // MU_SYSTEM_FILESYSTEMSTUB_H
35 changes: 35 additions & 0 deletions src/stubs/framework/system/systemstubmodule.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "systemstubmodule.h"

#include "modularity/ioc.h"
#include "filesystemstub.h"

using namespace mu::system;
using namespace mu::framework;

std::string SystemStubModule::moduleName() const
{
return "system_stub";
}

void SystemStubModule::registerExports()
{
ioc()->registerExport<IFileSystem>(moduleName(), new FileSystemStub());
}
34 changes: 34 additions & 0 deletions src/stubs/framework/system/systemstubmodule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_SYSTEM_SYSTEMSTUBMODULE_H
#define MU_SYSTEM_SYSTEMSTUBMODULE_H

#include "modularity/imodulesetup.h"

namespace mu::system {
class SystemStubModule : public framework::IModuleSetup
{
public:
std::string moduleName() const override;

void registerExports() override;
};
}

#endif // MU_SYSTEM_SYSTEMSTUBMODULE_H
6 changes: 4 additions & 2 deletions src/workspace/internal/workspacemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ void WorkspaceManager::setupCurrentWorkspace()
workspace = findAndInit(defaultWorkspaceName);
}

m_currentWorkspace = workspace;
m_currentWorkspaceChanged.send(workspace);
if (workspace) {
m_currentWorkspace = workspace;
m_currentWorkspaceChanged.send(workspace);
}
}

WorkspacePtr WorkspaceManager::findByName(const std::string& name) const
Expand Down

0 comments on commit 6dc23eb

Please sign in to comment.