mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 11:10:52 +00:00
This should round off update testing -- also use the XFERINFOFUNCTION to
abort the update check if canceled.
This commit is contained in:
parent
311909db2e
commit
4ca46015ed
@ -3,7 +3,7 @@
|
||||
user-facing:
|
||||
|
||||
* added first-class support for browse playlists:
|
||||
- press `5` in browse view to view playlists
|
||||
- press `5` in library browse view to switch to playlists
|
||||
- press `M-r` to rename the selected playlist
|
||||
- press `M-s` to save the selected playlist
|
||||
- highlight the left pane, and press `DEL` (`BACKSPACE` on macos) to delete
|
||||
@ -12,7 +12,10 @@ user-facing:
|
||||
- press `M-down` (`CTRL-DOWN` on macos) to move the selected track down
|
||||
- highlight the right pane, and press `DEL` (`BACKSPACE` on macos) to delete
|
||||
the selected track from the playlist
|
||||
* added view titles in library browse mode
|
||||
* added view titles in library browse mode, now playing, and search views
|
||||
* added auto-update check functionality to notify users when a new version is
|
||||
available. also added manual update check to settings
|
||||
* rearranged some items on the settings screen
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -84,7 +84,7 @@ static inline std::string getUserAgent() {
|
||||
% PLATFORM);
|
||||
}
|
||||
|
||||
size_t UpdateCheck::curlWriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
||||
size_t UpdateCheck::CurlWriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
||||
if (ptr && userdata) {
|
||||
UpdateCheck* context = static_cast<UpdateCheck*>(userdata);
|
||||
|
||||
@ -97,6 +97,16 @@ size_t UpdateCheck::curlWriteCallback(char *ptr, size_t size, size_t nmemb, void
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
int UpdateCheck::CurlTransferCallback(
|
||||
void *ptr, curl_off_t downTotal, curl_off_t downNow, curl_off_t upTotal, curl_off_t upNow)
|
||||
{
|
||||
UpdateCheck* context = static_cast<UpdateCheck*>(ptr);
|
||||
if (context->cancel) {
|
||||
return -1; /* kill the stream */
|
||||
}
|
||||
return 0; /* ok! */
|
||||
}
|
||||
|
||||
UpdateCheck::UpdateCheck() {
|
||||
this->curl = nullptr;
|
||||
}
|
||||
@ -118,17 +128,18 @@ bool UpdateCheck::Run(Callback callback) {
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, getUserAgent().c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &curlWriteCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 3000);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 7500);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 500);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &CurlWriteCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, this);
|
||||
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, &CurlTransferCallback);
|
||||
|
||||
this->thread.reset(new std::thread([this] {
|
||||
bool needsUpdate = false;
|
||||
|
@ -55,8 +55,8 @@ namespace musik { namespace box {
|
||||
private:
|
||||
void Reset();
|
||||
|
||||
static size_t curlWriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata);
|
||||
|
||||
static size_t CurlWriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata);
|
||||
static int CurlTransferCallback(void *ptr, curl_off_t downTotal, curl_off_t downNow, curl_off_t upTotal, curl_off_t upNow);
|
||||
virtual void ProcessMessage(musik::core::runtime::IMessage &message);
|
||||
|
||||
std::recursive_mutex mutex;
|
||||
|
@ -259,7 +259,6 @@ bool HttpDataStream::Open(const char *uri, unsigned int options) {
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_AUTOREFERER, 1);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_FAILONERROR, 1);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_NOPROGRESS, 1);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_USERAGENT, "musikcube HttpDataStream");
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_NOPROGRESS, 0);
|
||||
curl_easy_setopt(this->curlEasy, CURLOPT_WRITEHEADER, this);
|
||||
|
Loading…
Reference in New Issue
Block a user