- auto retry last fm on fail
This commit is contained in:
parent
36be257462
commit
fa29020cea
16
src/main.cpp
16
src/main.cpp
|
@ -7,6 +7,7 @@
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cstddef>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "backend.hpp"
|
#include "backend.hpp"
|
||||||
|
@ -50,17 +51,22 @@ void initLastFM(bool checkMode = false) {
|
||||||
lastfm = new LastFM(settings.lastfm.username, settings.lastfm.password, settings.lastfm.api_key,
|
lastfm = new LastFM(settings.lastfm.username, settings.lastfm.password, settings.lastfm.api_key,
|
||||||
settings.lastfm.api_secret);
|
settings.lastfm.api_secret);
|
||||||
LastFM::LASTFM_STATUS status = lastfm->authenticate();
|
LastFM::LASTFM_STATUS status = lastfm->authenticate();
|
||||||
if (status && checkMode)
|
if (status) {
|
||||||
wxMessageBox(_("Error authenticating at LastFM!"), _("PlayerLink"), wxOK | wxICON_ERROR);
|
delete lastfm;
|
||||||
else if (checkMode)
|
lastfm = nullptr;
|
||||||
|
if (checkMode)
|
||||||
|
wxMessageBox(_("Error authenticating at LastFM!"), _("PlayerLink"), wxOK | wxICON_ERROR);
|
||||||
|
} else if (checkMode)
|
||||||
wxMessageBox(_("The LastFM authentication was successful."), _("PlayerLink"), wxOK | wxICON_INFORMATION);
|
wxMessageBox(_("The LastFM authentication was successful."), _("PlayerLink"), wxOK | wxICON_INFORMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMediaTasks() {
|
void handleMediaTasks() {
|
||||||
initLastFM();
|
|
||||||
int64_t lastMs = 0;
|
int64_t lastMs = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
if (!lastfm)
|
||||||
|
initLastFM();
|
||||||
|
|
||||||
auto mediaInformation = backend::getMediaInformation();
|
auto mediaInformation = backend::getMediaInformation();
|
||||||
auto settings = utils::getSettings();
|
auto settings = utils::getSettings();
|
||||||
if (!mediaInformation) {
|
if (!mediaInformation) {
|
||||||
|
@ -441,7 +447,6 @@ public:
|
||||||
utils::saveSettings(settings);
|
utils::saveSettings(settings);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
wxBitmapButton* addButton = new wxBitmapButton(panel, wxID_ANY, add_button_texture);
|
wxBitmapButton* addButton = new wxBitmapButton(panel, wxID_ANY, add_button_texture);
|
||||||
addButton->SetToolTip(_("Add application"));
|
addButton->SetToolTip(_("Add application"));
|
||||||
addButton->Bind(wxEVT_BUTTON, [this, panel, frameSizer, size, delete_button_texture, edit_button_texture,
|
addButton->Bind(wxEVT_BUTTON, [this, panel, frameSizer, size, delete_button_texture, edit_button_texture,
|
||||||
|
@ -462,7 +467,6 @@ public:
|
||||||
delete app;
|
delete app;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
checkboxRowSizer->Add(anyOtherCheckbox, 1, wxALL | wxALIGN_CENTER_VERTICAL);
|
checkboxRowSizer->Add(anyOtherCheckbox, 1, wxALL | wxALIGN_CENTER_VERTICAL);
|
||||||
checkboxRowSizer->Add(addButton, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 5);
|
checkboxRowSizer->Add(addButton, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 5);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue