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

v1.0.2 #141

Merged
merged 43 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
95733e9
update juce version (5.2.1)
eliottparis Jun 6, 2018
8dba54b
server app - relative path support for config file
eliottparis Jun 9, 2018
899b22f
add kiwi-node-server as submodule
eliottparis Jun 9, 2018
8e231e3
GUI improvements:
eliottparis Jun 10, 2018
41fa573
fix linux build
eliottparis Jun 10, 2018
1da4140
Add Juce dependency to the engine
eliottparis Jun 10, 2018
29f90a0
Add new [sfplay~] object
eliottparis Jun 10, 2018
b0b63c3
Add new [sfrecord~] object
eliottparis Jun 10, 2018
1a1651f
update doc
eliottparis Jun 10, 2018
d961f6f
small fix
eliottparis Jun 11, 2018
b9318e0
Open kiwi file by dragging it to the console
eliottparis Jun 11, 2018
c1dd581
incompatible version handling quick-fix
eliottparis Jun 11, 2018
234332c
fix DocumentBrowser tooltip
eliottparis Jun 11, 2018
2e9076b
update trashed document view
eliottparis Jun 11, 2018
f917427
initialize colors in LookAndFeel
eliottparis Jun 12, 2018
aafa391
update patcherview link
eliottparis Jun 13, 2018
d9b6b16
patcherview boxes polish
eliottparis Jun 13, 2018
9571200
correct some text displayed
eliottparis Jun 13, 2018
f6550c3
correct a text and clean some code
eliottparis Jun 13, 2018
d838682
update [sf.play~] and [sf.record~] objects
eliottparis Jun 13, 2018
44d93f0
code clean
eliottparis Jun 14, 2018
1c58ece
GUI and UX enhancements:
eliottparis Jun 14, 2018
be10d9f
DocumentBrowserView:
eliottparis Jun 14, 2018
5388531
fixup! DocumentBrowserView:
eliottparis Jun 14, 2018
92b2f63
fix last commit
eliottparis Jun 14, 2018
72bdb51
fix object resizing behavior
eliottparis Jun 15, 2018
cdf14de
update model::Converter
eliottparis Jun 16, 2018
34353a7
Add conversion error messages to console
eliottparis Jun 16, 2018
1269099
removes "ratio", "min_width", "min_height" members from the model::Ob…
eliottparis Jun 16, 2018
164239f
bump model to v4.0.1
eliottparis Jun 16, 2018
3ae393f
Add v4 to v4.0.1 model converter
eliottparis Jun 16, 2018
38b375a
handle 404 errors in download and duplicate api requests
eliottparis Jun 16, 2018
64e8804
add a more descriptive commit message when an object is created and (…
eliottparis Jun 16, 2018
b1867cc
fix transaction stack crashs by implementing gestures as Sessions in …
eliottparis Jun 16, 2018
8c7d351
update PatcherComponent toolbar
eliottparis Jun 16, 2018
3f71828
fix hexadecimal user id conversion (fixes user list display in patche…
eliottparis Jun 16, 2018
6d2c9c2
better connection error handling (still need a big refactoring)
eliottparis Jun 17, 2018
cda4fc0
Add [sf.play~] and [sf.record~] helps
eliottparis Jun 17, 2018
7e0e2a6
update ressources
eliottparis Jun 17, 2018
92461bb
bump Kiwi version to v1.0.2
eliottparis Jun 17, 2018
5085271
add v1.0.2 changelog
eliottparis Jun 17, 2018
955cd59
update kiwi-node-server
eliottparis Jun 17, 2018
f127131
Merge pull request #140 from Musicoll/dev/v1.0.2
eliottparis Jun 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "ThirdParty/Juce"]
path = ThirdParty/Juce
url = https://github.com/julianstorer/JUCE.git
url=https://github.com/WeAreROLI/JUCE.git
[submodule "ThirdParty/concurrentqueue"]
path = ThirdParty/concurrentqueue
url = https://github.com/cameron314/concurrentqueue.git
[submodule "ThirdParty/Beast"]
path = ThirdParty/Beast
url = https://github.com/boostorg/beast.git
[submodule "ThirdParty/kiwi-node-server"]
path = ThirdParty/kiwi-node-server
url = https://github.com/Musicoll/kiwi-node-server.git
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ add_library(KiwiEngine STATIC ${KIWI_ENGINE_SRC})
target_include_directories(KiwiEngine PUBLIC ${ROOT_DIR}/Modules)
target_add_dependency(KiwiEngine KiwiModel)
target_add_dependency(KiwiEngine KiwiDsp)
target_add_dependency(KiwiEngine Juce)
set_target_properties(KiwiEngine PROPERTIES FOLDER Modules)
source_group_rec("${KIWI_ENGINE_SRC}" ${ROOT_DIR}/Modules/KiwiEngine)

Expand Down
142 changes: 111 additions & 31 deletions Client/Source/KiwiApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ namespace kiwi
m_api.reset(new Api(*m_api_controller));

m_instance = std::make_unique<Instance>();
m_command_manager->registerAllCommandsForTarget(this);

checkLatestRelease();

startTimer(10);
m_command_manager->registerAllCommandsForTarget(this);

#if JUCE_WINDOWS
openCommandFile(commandLine);
Expand All @@ -136,7 +132,11 @@ namespace kiwi
macMainMenuPopup.addSeparator();
macMainMenuPopup.addCommandItem(&getCommandManager(), CommandIDs::showAppSettingsWindow);
juce::MenuBarModel::setMacMainMenu(m_menu_model.get(), &macMainMenuPopup, TRANS("Open Recent"));
#endif
#endif

pingServer();
startTimer(TimerIds::MainScheduler, 10); // main scheduler update
startTimer(TimerIds::ServerPing, 3000); // Server ping
}

void KiwiApp::anotherInstanceStarted(juce::String const& command_line)
Expand Down Expand Up @@ -209,7 +209,9 @@ namespace kiwi
engine::SwitchTilde::declare();
engine::Float::declare();
engine::ClipTilde::declare();
engine::Clip::declare();
engine::Clip::declare();
engine::SfPlayTilde::declare();
engine::SfRecordTilde::declare();
}

void KiwiApp::declareObjectViews()
Expand All @@ -230,7 +232,8 @@ namespace kiwi
juce::MenuBarModel::setMacMainMenu(nullptr);
#endif

stopTimer();
stopTimer(TimerIds::MainScheduler);
stopTimer(TimerIds::ServerPing);

m_instance.reset();
m_api->cancelAll();
Expand Down Expand Up @@ -270,9 +273,18 @@ namespace kiwi
return true;
}

void KiwiApp::timerCallback()
void KiwiApp::timerCallback(int timer_id)
{
m_scheduler->process();
if(timer_id == TimerIds::MainScheduler)
{
m_instance->tick();
m_scheduler->process();
}
else if(timer_id == TimerIds::ServerPing)
{
// ping server
pingServer();
}
}

bool KiwiApp::isMacOSX()
Expand Down Expand Up @@ -331,7 +343,6 @@ namespace kiwi
void KiwiApp::setAuthUser(Api::AuthUser const& auth_user)
{
(*KiwiApp::use().m_api_controller).setAuthUser(auth_user);

KiwiApp::useInstance().login();
}

Expand All @@ -342,45 +353,114 @@ namespace kiwi

void KiwiApp::logout()
{
useInstance().logout();
useInstance().handleConnectionLost();
KiwiApp::use().m_api_controller->logout();
KiwiApp::commandStatusChanged();
}

void KiwiApp::checkLatestRelease()
bool KiwiApp::canConnectToServer()
{
std::string current_version = getApplicationVersion().toStdString();
const auto server_version = KiwiApp::use().m_last_server_version_check;

Api::CallbackFn<std::string const&> on_success = [current_version](std::string const& latest_version)
return (!server_version.empty()
&& server_version != "null"
&& KiwiApp::use().canConnectToServerVersion(server_version));
}

bool KiwiApp::canConnectToServerVersion(std::string const& server_version)
{
const auto& version = KiwiApp::use().getApplicationVersion();
return (version.compare(server_version) == 0);
}

void KiwiApp::pingSucceed(std::string const& new_server_version)
{
bool was_connected = canConnectToServer();

if((new_server_version == m_last_server_version_check) && was_connected)
return;

if (was_connected)
{
KiwiApp::useScheduler().schedule([current_version, latest_version]()
{
if (current_version.compare(latest_version) != 0)
{
juce::AlertWindow::showMessageBoxAsync(juce::AlertWindow::QuestionIcon,
"New release available" ,
"Upgrading required to access remote documents.\n\n Please visit:\n https://github.com/Musicoll/Kiwi/releases");
}
});
};
logout();
}

Api::ErrorCallback on_fail =[](Api::Error error)
if (canConnectToServerVersion(new_server_version))
{
useInstance().login();
}
else if(m_last_server_version_check != new_server_version)
{
const auto current_version = KiwiApp::use().getApplicationVersion().toStdString();
warning("Can't connect to server! Requires Kiwi " + new_server_version
+ ", please visit:");
warning("https://github.com/Musicoll/Kiwi/releases");
}

m_last_server_version_check = new_server_version;

if(!was_connected && canConnectToServer())
{
const auto api_host = m_api_controller->getHost();
post("Connection established to " + api_host);
}
}

void KiwiApp::pingFailed(Api::Error error)
{
static const std::string ping_failed = "null";

const bool was_connected = canConnectToServer();
if(was_connected)
{
KiwiApp::error("Connection lost");
m_instance->handleConnectionLost();
}
else if(m_last_server_version_check != ping_failed)
{
KiwiApp::error("Connection to server failed: " + error.getMessage());
}

m_last_server_version_check = ping_failed;
}

void KiwiApp::pingServer()
{
Api::CallbackFn<std::string const&> success = [this](std::string const& server_version) {

KiwiApp::useScheduler().schedule([this, server_version]() {
pingSucceed(server_version);
});

};

useApi().getRelease(on_success, on_fail);
useApi().getRelease(success, [this](Api::Error err) {

KiwiApp::useScheduler().schedule([this, err = std::move(err)]() {
pingFailed(err);
});

});
}

void KiwiApp::networkSettingsChanged(NetworkSettings const& settings, juce::Identifier const& id)
{
if (id == Ids::server_address)
{
logout();
auto& api = *m_api_controller;

m_api_controller->setHost(settings.getHost());
m_api_controller->setPort(settings.getApiPort());
const auto host = settings.getHost();
const auto api_port = settings.getApiPort();
//const auto session_port = settings.getSessionPort();

checkLatestRelease();
if((api.getHost() != host) || (api_port != api.getPort()))
{
// settings changed
m_api_controller->setHost(settings.getHost());
m_api_controller->setPort(settings.getApiPort());

pingServer();
}
}
}

Expand Down
67 changes: 45 additions & 22 deletions Client/Source/KiwiApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
namespace ProjectInfo
{
const char* const projectName = "Kiwi";
const char* const versionString = "v1.0.1";
const int versionNumber = 0x101;
const char* const versionString = "v1.0.2";
const int versionNumber = 0x102;
}

namespace kiwi
Expand All @@ -44,9 +44,10 @@ namespace kiwi
// KiWi APPLICATION //
// ================================================================================ //

class KiwiApp : public juce::JUCEApplication,
public NetworkSettings::Listener,
public juce::Timer
class KiwiApp
: public juce::JUCEApplication
, public NetworkSettings::Listener
, public juce::MultiTimer
{
public: // methods

Expand Down Expand Up @@ -76,7 +77,7 @@ namespace kiwi
bool moreThanOneInstanceAllowed() override;

//! @brief Timer call back, processes the scheduler events list.
void timerCallback() override final;
void timerCallback(int timer_id) override;

//! @brief Returns true if the app is running in a Mac OSX operating system.
static bool isMacOSX();
Expand Down Expand Up @@ -111,7 +112,10 @@ namespace kiwi
static Api::AuthUser const& getCurrentUser();

//! @brief Log-out the user
static void logout();
static void logout();

//! @brief Return true if the application can connect to the server.
static bool canConnectToServer();

//! @brief Get the current running engine instance.
static engine::Instance& useEngineInstance();
Expand Down Expand Up @@ -220,7 +224,20 @@ namespace kiwi
KiwiApp() = default;
~KiwiApp() = default;

private: // methods
private: // methods

//! @internal Returns true if the App is compatible with a given server version.
bool canConnectToServerVersion(std::string const& server_version);

//! @internal Ping the server to test current connection
//! @brief Called regularly by the App
void pingServer();

//! @internal handle ping succeed
void pingSucceed(std::string const& server_version);

//! @internal handle ping failed
void pingFailed(Api::Error error);

//! @internal Utility to quit the app asynchronously.
class AsyncQuitRetrier;
Expand All @@ -231,27 +248,33 @@ namespace kiwi
//! @internal Initializes gui specific objects.
void declareObjectViews();

//! @internal Checks if current Kiwi version is the latest. Show popup if version not up to date.
void checkLatestRelease();

// @brief Handles changes of server address.
void networkSettingsChanged(NetworkSettings const& settings, juce::Identifier const& ids) override final;

//! @brief Parse startup command line and open file if exists.
void openCommandFile(juce::String const& command_line);

private: // members

std::unique_ptr<ApiController> m_api_controller;
std::unique_ptr<Api> m_api;
private: // members

enum TimerIds : int
{
MainScheduler = 0,
ServerPing,
};

LookAndFeel m_looknfeel;
TooltipWindow m_tooltip_window;

std::unique_ptr<Instance> m_instance;
std::unique_ptr<juce::ApplicationCommandManager> m_command_manager;
std::unique_ptr<MainMenuModel> m_menu_model;
std::unique_ptr<ApiController> m_api_controller = nullptr;
std::unique_ptr<Api> m_api = nullptr;

LookAndFeel m_looknfeel;
TooltipWindow m_tooltip_window;
std::unique_ptr<StoredSettings> m_settings;
std::unique_ptr<tool::Scheduler<>> m_scheduler;
std::unique_ptr<Instance> m_instance = nullptr;
std::unique_ptr<juce::ApplicationCommandManager> m_command_manager = nullptr;
std::unique_ptr<MainMenuModel> m_menu_model = nullptr;
std::unique_ptr<StoredSettings> m_settings = nullptr;

std::unique_ptr<tool::Scheduler<>> m_scheduler = nullptr;

std::string m_last_server_version_check {};
};
}
Loading