From cd2ed0270aa8333ee167fb0fe752637b18b1cc79 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sat, 1 Sep 2007 19:14:19 -0400 Subject: [PATCH] Temporary fix for the flashing dialog box bug. Fixed searching after a previous search. Fixed searching for terms containing a space character. --- src/ncast.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++----------- src/ncast.h | 3 ++- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/src/ncast.c b/src/ncast.c index d17a785..9c2367d 100644 --- a/src/ncast.c +++ b/src/ncast.c @@ -68,6 +68,9 @@ #include #endif +static int msg_box; +static void remove_handle(CURLM * cmh, struct genre_s *g, int clean); + /* The indent variable in the message structure is for indenting wrapped lines * (pick info for example). See ncast.h for more information. */ @@ -174,6 +177,7 @@ static void *do_message(void *data) wbkgd(w, CP_HELP_WINDOW); keypad(w, TRUE); pan = new_panel(w); + msg_box++; while (1) { chtype c; @@ -206,7 +210,7 @@ static void *do_message(void *data) update_panels(); doupdate(); - wtimeout(w, 700); + wtimeout(w, TIMEOUT); while ((c = wgetch(w)) == ERR) { top_panel(pan); @@ -245,6 +249,7 @@ static void *do_message(void *data) del_panel(pan); delwin(w); curs_set(curs); + msg_box--; return NULL; } @@ -785,6 +790,10 @@ static void add_genre(unsigned int flags, char *title, char *url, memset(&genres[ginfo.total], 0, sizeof(struct genre_s)); genres[ginfo.total].url = url; genres[ginfo.total].title = title; + + if (!strcmp(title, "Search")) + flags |= GENRE_SEARCH; + genres[ginfo.total].flags = flags; genres[ginfo.total].nodups = nodups; genres[ginfo.total].max_pages = max_pages; @@ -1547,13 +1556,21 @@ static char *search_prompt(int which) static void do_server_search(const char *str) { char tmp[255]; - struct genre_s *g = &genres[ginfo.y]; + struct genre_s *g = &genres[ginfo.total-1]; CURLMcode error; + char *p; + + remove_handle(cmh, g, 1); snprintf(tmp, sizeof(tmp), "%s/directory/?s=%s", shoutcast_url, str); g->buf = realloc(g->buf, strlen(tmp)*sizeof(char)+1); sprintf(g->buf, "%s", tmp); + for (p = g->buf; *p; p++) { + if (*p == ' ') + *p = '+'; + } + if (set_curl_easy_opts(g)) return; @@ -1839,8 +1856,10 @@ static void search_picks(int which, struct genre_s *gp) return; } - search->which = !which ? SEARCH_SERVER : SEARCH_PLAYING; // FIXME config default + search->which = !which ? SEARCH_SERVER : SEARCH_PLAYING; } + else + search->which = !which ? SEARCH_SERVER : SEARCH_PLAYING; search->key = which; search->gp = gp; @@ -2629,14 +2648,18 @@ static void remove_handle(CURLM * cmh, struct genre_s *g, int clean) { int error; - if (g->flags & GENRE_CONNECT || !(g->flags & GENRE_DONE) || - g->flags & GENRE_REFRESH) { + if (!g->ch) + return; + + if (g->flags & GENRE_SEARCH || g->flags & GENRE_CONNECT || + !(g->flags & GENRE_DONE) || g->flags & GENRE_REFRESH) { if ((error = curl_multi_remove_handle(cmh, g->ch)) != CURLE_OK && error != CURLM_BAD_EASY_HANDLE) se_message(0, 0, "%s: %i: %s", __FILE__, __LINE__, curl_multi_strerror(error)); else { + g->ch = NULL; g->flags &= ~(GENRE_FETCH) | ~(GENRE_CONNECT); g->flags |= GENRE_DONE; @@ -2914,6 +2937,7 @@ static void *progloop(void *data) { ncast_plugin *ncp = NULL; struct genre_s *genre_init = NULL; + int volume = 50; initscr(); @@ -3007,7 +3031,7 @@ static void *progloop(void *data) } } else - wtimeout(wp, 700); + wtimeout(wp, TIMEOUT); while ((cmsg = curl_multi_info_read(cmh, &c)) != NULL) { if (cmsg->msg == CURLMSG_DONE) { @@ -3071,6 +3095,10 @@ static void *progloop(void *data) //update_picks_win(gp->picks, gp->pick, gp->y); } } + else { + parse_picks(&genres[i]); + genres[i].urldata->size = 0; + } break; } @@ -3117,10 +3145,17 @@ static void *progloop(void *data) bottom_panel(genre_p); } - draw_window_decor(gp); - update_status(gp); - update_panels(); - doupdate(); + /* + * Temporary fix for "flashing" dialog boxes. The panel is "ontop" + * before update_panels(), but not after. When threading is removed + * and a window stack is used instead, this will be fixed. + */ + if (!msg_box) { + draw_window_decor(gp); + update_status(gp); + update_panels(); + doupdate(); + } if (pth_ctrl(PTH_CTRL_GETTHREADS_READY) > 0) { pth_yield(NULL); @@ -3519,10 +3554,19 @@ again: case 'Q': goto done; case '1': - send_to_player("volume %c\n", 'a'); + volume -= 10; + + if (volume < 0) + volume = 0; + + send_to_player("volume %i\n", volume); break; case '2': - send_to_player("volume %i\n", 1); + volume += 10; + + if (volume > 100) + volume = 100; + send_to_player("volume %i\n", volume); break; default: for (i = 0; i < plugin; i++) { diff --git a/src/ncast.h b/src/ncast.h index aca2730..007d72d 100644 --- a/src/ncast.h +++ b/src/ncast.h @@ -152,7 +152,8 @@ enum { GENRE_SECTION = 0x0040, GENRE_COLLAPSED = 0x0080, GENRE_HIDDEN = 0x0100, - GENRE_AUTOFETCH = 0x0200 + GENRE_AUTOFETCH = 0x0200, + GENRE_SEARCH = 0x0400, }; struct genre_rw_s { -- 2.11.4.GIT