bool CUpnpBrowserGui::selectItem(std::string id) { bool loop = true; bool endall = false; bool changed = true; bool rchanged = true; neutrino_msg_t msg; neutrino_msg_data_t data; std::vector<UPnPEntry> *entries; unsigned int index, selected, dirnum; index = 0; selected = 0; dirnum = 0; entries = NULL; while (loop) { updateTimes(); if (rchanged) { if (entries) delete entries; entries = NULL; std::list<UPnPAttribute>attribs; std::list<UPnPAttribute>results; std::list<UPnPAttribute>::iterator i; std::stringstream sindex; std::stringstream scount; unsigned int returned = 0; bool rfound = false; bool nfound = false; bool tfound = false; sindex << index; scount << m_listmaxshow; attribs.push_back(UPnPAttribute("ObjectID", id)); attribs.push_back(UPnPAttribute("BrowseFlag", "BrowseDirectChildren")); attribs.push_back(UPnPAttribute("Filter", "*")); attribs.push_back(UPnPAttribute("StartingIndex", sindex.str())); attribs.push_back(UPnPAttribute("RequestedCount", scount.str())); attribs.push_back(UPnPAttribute("SortCriteria", "")); results = m_devices[m_selecteddevice].SendSOAP("urn:schemas-upnp-org:service:ContentDirectory:1", "Browse", attribs); for (i = results.begin(); i != results.end(); i++) { if (i->first == "NumberReturned") { returned = atoi(i->second.c_str()); nfound = true; } if (i->first == "TotalMatches") { dirnum = atoi(i->second.c_str()); tfound = true; } if (i->first == "Result") { entries = decodeResult(i->second); rfound = true; } } if (!entries) return endall; if (!nfound || !tfound || !rfound) { delete entries; return endall; } if (returned != entries->size()) { delete entries; return endall; } if (returned == 0) { delete entries; return endall; } rchanged=false; changed=true; } if (changed) { paintItem(entries, selected - index, dirnum - index, index); changed = false; } m_frameBuffer->blit(); g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat; if( msg == CRCInput::RC_timeout) { // nothing } else if(msg == CRCInput::RC_home) { loop = false; endall = true; } else if(msg == CRCInput::RC_left) { loop = false; } else if (msg_repeatok == CRCInput::RC_up && selected > 0) { selected--; if (selected < index) { index -= m_listmaxshow; rchanged = true; } changed = true; } else if( (msg == CRCInput::RC_yellow || (int) msg == g_settings.key_channelList_pageup) && selected > 0) { if (index > 0) { index-=m_listmaxshow; selected-=m_listmaxshow; rchanged=true; } else selected=0; changed = true; } else if (msg_repeatok == CRCInput::RC_down && selected + 1 < dirnum) { selected++; if (selected + 1 > index + m_listmaxshow) { index += m_listmaxshow; rchanged = true; } changed=true; } else if( (msg == CRCInput::RC_green || (int) msg == g_settings.key_channelList_pagedown)&& selected + 1 < dirnum) { if (index < ((dirnum - 1) / m_listmaxshow) * m_listmaxshow) { index += m_listmaxshow; selected += m_listmaxshow; if (selected + 1 >= dirnum) selected = dirnum - 1; rchanged = true; } else selected = dirnum - 1; changed = true; } else if(msg == CRCInput::RC_right) { if ((*entries)[selected - index].isdir) { endall = selectItem((*entries)[selected - index].id); if (endall) loop = false; } changed = true; } else if(msg == CRCInput::RC_ok) { if (!(*entries)[selected - index].isdir) { m_folderplay = false; int preferred = (*entries)[selected - index].preferred; if (preferred != -1) { std::string protocol, prot, network, mime, additional; protocol=(*entries)[selected - index].resources[preferred].protocol; splitProtocol(protocol, prot, network, mime, additional); if (mime == "audio/mpeg") { CAudioPlayerGui tmpAudioPlayerGui; CAudiofileExt audiofile((*entries)[selected - index].resources[preferred].url, CFile::EXTENSION_MP3); tmpAudioPlayerGui.addToPlaylist(audiofile); tmpAudioPlayerGui.exec(NULL, "urlplayback"); } else if ((mime == "image/gif") || (mime == "image/jpeg")) { CPictureViewerGui tmpPictureViewerGui; CPicture pic; struct stat statbuf; pic.Filename = (*entries)[selected - index].resources[preferred].url; std::string tmp = (*entries)[selected - index].resources[preferred].url.substr((*entries)[selected - index].resources[preferred].url.rfind('/') + 1); pic.Name = tmp.substr(0, tmp.rfind('.')); pic.Type = tmp.substr(tmp.rfind('.') + 1); if(stat(pic.Filename.c_str(), &statbuf) != 0) printf("stat error"); pic.Date = statbuf.st_mtime; tmpPictureViewerGui.addToPlaylist(pic); tmpPictureViewerGui.exec(NULL, "urlplayback"); changed = true; } else if (mime.substr(0,6) == "video/") { m_frameBuffer->ClearFrameBuffer(); m_frameBuffer->blit(); CFile file; file.Name = (*entries)[selected - index].resources[preferred].url.c_str(); //FIXME CMoviePlayerGui tmpMoviePlayerGui; tmpMoviePlayerGui.addToPlaylist(file); tmpMoviePlayerGui.exec(NULL, "urlplayback"); changed = true; } m_playing_entry = (*entries)[selected - index]; } } else { m_folderplay = true; m_playfolder = (*entries)[selected - index].id; m_playid = 0; playnext(); } changed = true; } else if( msg == CRCInput::RC_red) { if(CAudioPlayer::getInstance()->getState() != CBaseDec::STOP) CAudioPlayer::getInstance()->stop(); m_folderplay = false; } else if(msg == NeutrinoMessages::RECORD_START || msg == NeutrinoMessages::ZAPTO || msg == NeutrinoMessages::STANDBY_ON || msg == NeutrinoMessages::SHUTDOWN || msg == NeutrinoMessages::SLEEPTIMER) { loop = false; g_RCInput->postMsg(msg, data); } else if(msg == NeutrinoMessages::EVT_TIMER) { CNeutrinoApp::getInstance()->handleMsg( msg, data ); } else { if( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) loop = false; changed = true; } if (m_folderplay && (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP)) playnext(); m_frameBuffer->blit(); } if (entries) delete entries; m_frameBuffer->ClearFrameBuffer(); m_frameBuffer->blit(); return endall; }
void hello() { int scr=14; WINDOW *w1; w1=newwin (scr+2,62,(nrscr-(scr+2))/2+7,(nrcols-62)/2); wrefresh (w1); werase (w1); WINDOW *w; w=newwin (scr,60,(nrscr-(scr+2))/2+8,(nrcols-60)/2); wsetcolor (w,12,0); for (int h=0;h<=scr+2;h++) mvwprintw (w,h,0," "); wsetcolor (w,12,0); le_border (w,60,scr); wsetcolor (w,13,1); mvwprintw (w,0,1," Welcome to LinuxEyes "); wsetcolor (w,12,0); mvwprintw (w,scr-1,46," ESC - quit "); wrefresh(w); char s[11][100]; strcpy (s[0]," Thank you for installing LinuxEyes. I hope you will"); strcpy (s[1],"enjoy using this player as much as I enjoyed makeing it."); strcpy (s[2],""); strcpy (s[3]," If you have any questions or you would like to send"); strcpy (s[4],"me some suggestions or some bugs information please just"); strcpy (s[5],"email me at [email protected]. Thank you!"); strcpy (s[6]," For more information about using LinuxEyes, please"); strcpy (s[7],"press 'h' to view the help page or visit the website."); strcpy (s[8]," Have Fun!"); strcpy (s[9],"http://lug.orizont.net/~linuxeyes"); strcpy (s[10],"LinuxEyes v"); strcat (s[10],version); strcat (s[10]," - "); strcat (s[10],bday); strcat (s[10],", "); strcat (s[10],bdate); noecho(); play ("/usr/lib/linuxeyes/music/linuxeyes.mp3"); timeout (1); int t=0; int q=0; wsetcolor (w,12,0); for (int i=0;i<=10;i++) { mvwprintw (w,2+i,2," "); mvwprintw (w,2+i,2,"%s",s[i]); } wrefresh (w); do { t=getch(); messages(); if (t==27) { t=getch(); if (t==ERR) q=1; } if ((try_again) && (t==ERR)) playnext(); if (quit==1) q=1; while (t!=ERR) t=getch(); } while (q==0); werase (w); reread=1; }
void help(int scr) { int v,k; int more=0; int cont=0; int q=0; make_help(); WINDOW *w1; w1=newwin (scr+2,62,7,(nrcols-62)/2); wrefresh (w1); werase (w1); WINDOW *w; w=newwin (scr,60,8,(nrcols-60)/2); wsetcolor (w,12,0); for (int h=0;h<=scr+2;h++) mvwprintw (w,h,0," "); wsetcolor (w,12,0); le_border (w,60,scr); wsetcolor (w,13,1); mvwprintw (w,0,1," Help "); wsetcolor (w,12,0); mvwprintw (w,scr-1,46," ESC - quit "); wrefresh(w); noecho(); timeout (1); k=0; do { if (more < 0) {k--; more++; cont=1;} if (more > 0) {k++; more--; cont=1;} if (k < 0) k=0; if (k > help_lines-(scr-5)) k=help_lines-(scr-5); wsetcolor (w,12,0); for (int i=0;i<=scr-5;i++) { mvwprintw (w,2+i,2," "); mvwprintw (w,2+i,2,"%s",help_s[i+k]); } wsetcolor (w,12,0); mvwaddch (w,0,28,ACS_HLINE); mvwaddch (w,scr-1,28,ACS_HLINE); wsetcolor (w,12,1); if (k>0) mvwaddch (w,0,28,ACS_UARROW); if (k<help_lines-(scr-5)) mvwaddch (w,scr-1,28,ACS_DARROW); wrefresh(w); do { messages(); v=getch(); if ((try_again) && (v==ERR)) playnext(); } while ((v==ERR) && (cont==0)); cont=0; if (v == 'q') q=1; if (v == 27) { v=getch(); if (v==ERR) q=1; if (v==91) { v=getch(); if (v==65) k--; if (v==66) k++; if (v==53) more=-scr+4; if (v==54) more=scr-4; } } if (quit==1) q=1; while (v!=ERR) v=getch(); } while (q==0); werase (w); reread=1; }
void about(int scr) { /* initscr(); WINDOW *w; w=newwin (16,78,7,1); werase(w); setcolor (1,1); mvprintw (7,34,"LinuxEyes"); setcolor (1,1); mvprintw (9,2,"AUTHOR"); mvprintw (13,2,"COPYRIGHT"); mvprintw (17,2,"LOTS OF THANKS TO"); mvprintw (20,2,"BUGS AND SUGGESTIONS"); setcolor (1,0); mvprintw (10,5,"Alexandru Radovici - [email protected]"); mvprintw (11,5," [email protected]"); mvprintw (14,5,"This program is free. You may use it on your own risk. You may distribute"); mvprintw (15,2,"it only integral."); mvprintw (18,5,"Xaudio - http://www.xaudio.com"); mvprintw (21,5,"If you have found bugs or have some suggestions to make please send me an"); mvprintw (22,2,"e-mail. Thank you."); wrefresh (w); */ int v,k; int q=0; char s[100][100]; strcpy (s[0],"AUTHOR"); strcpy (s[1]," Alexandru Radovici - [email protected]"); strcpy (s[2],""); strcpy (s[3],"VERSION"); sprintf (s[4]," LinuxEyes %s (%s)",version,v_name); sprintf (s[5]," Build: %s",build); sprintf (s[6]," Date: %s",bdate); /* strcpy (s[4]," LinuxEyes "); strcat (s[4],version); strcat (s[4],", build "); strcat (s[4],build); strcat (s[4]," ("); strcat (s[4],bdate); strcat (s[4],")");*/ strcpy (s[7],""); strcpy (s[8],"ROMANIAN SOFTWARE"); strcpy (s[9]," This software was made in Romania!"); strcpy (s[10],""); strcpy (s[11],"WEBSITE"); strcpy (s[12]," http://lug.orizont.net/~linuxeyes"); strcpy (s[13],""); strcpy (s[14],"COPYRIGHT & DISTRIBUTION"); strcpy (s[15]," This software is freeware, you may use it on your"); strcpy (s[16],"own risk. You may distribute it only integral."); strcpy (s[17],""); strcpy (s[18],"MPEG Audio Layer 3"); strcpy (s[19]," Xaudio - http://www.xaudio.com"); strcpy (s[20],""); strcpy (s[21],"BUGS & SUGGESTIONS"); strcpy (s[22]," If you find any bugs or have any suggestion please"); strcpy (s[23],"email me. ([email protected]) Thank you!"); strcpy (s[24],""); strcpy (s[25],"LOTS OF THANKS TO"); strcpy (s[26]," Vera and Iuliu Radovici"); strcpy (s[27]," Cosmin Chertes"); strcpy (s[28]," Ovidiu Stoica - [email protected]"); strcpy (s[29]," Alexandru Armean - [email protected]"); strcpy (s[30]," Valeriu Moldovan - [email protected]"); strcpy (s[31]," Cristian Klein - [email protected]"); strcpy (s[32],""); strcpy (s[33],"CURRENT SESSION STATISTICS"); sprintf (s[34]," Songs Played: %d",(int)n_songs); sprintf (s[35]," Time Played: %d:%.2d:%.2d",(int)n_secs/(60*60),(int)(n_secs/60)%60,(int)n_secs%60); strcpy (s[36],""); strcpy (s[37],"GLOBAL STATISTICS"); sprintf (s[38]," Songs Played: %d",(int)songs); sprintf (s[39]," Time Played: %d:%.2d:%.2d",(int)secs/(60*60),(int)(secs/60)%60,(int)secs%60); WINDOW *w1; w1=newwin (scr+2,62,7,(nrcols-62)/2); wrefresh (w1); werase (w1); WINDOW *w; w=newwin (scr,60,8,(nrcols-60)/2); wsetcolor (w,12,0); for (int h=0;h<=scr+2;h++) mvwprintw (w,h,0," "); wsetcolor (w,12,0); le_border (w,60,scr); wsetcolor (w,13,1); mvwprintw (w,0,1," About LinuxEyes "); wsetcolor (w,12,0); mvwprintw (w,scr-1,46," ESC - quit "); wrefresh(w); noecho(); timeout (1); k=0; do { wsetcolor (w,12,0); for (int i=0;i<=scr-5;i++) { mvwprintw (w,2+i,2," "); mvwprintw (w,2+i,2,"%s",s[i+k]); } wsetcolor (w,12,0); mvwaddch (w,0,28,ACS_HLINE); mvwaddch (w,scr-1,28,ACS_HLINE); wsetcolor (w,12,1); if (k>0) mvwaddch (w,0,28,ACS_UARROW); if (k<37-(scr-5)) mvwaddch (w,scr-1,28,ACS_DARROW); wrefresh(w); do { sprintf (s[34]," Songs Played: %d",(int)n_songs); sprintf (s[35]," Time Played: %d:%.2d:%.2d",(int)n_secs/(60*60),(int)(n_secs/60)%60,(int)n_secs%60); sprintf (s[38]," Songs Played: %d",(int)songs); sprintf (s[39]," Time Played: %d:%.2d:%.2d",(int)secs/(60*60),(int)(secs/60)%60,(int)secs%60); for (int i=0;i<=scr-5;i++) if (((i+k)==34) || ((i+k)==35) || ((i+k)==38) || ((i+k)==39)) { wsetcolor (w,12,0); mvwprintw (w,2+i,2," "); mvwprintw (w,2+i,2,"%s",s[i+k]); wrefresh (w); } messages(); v=getch(); if ((try_again) && (v==ERR)) playnext(); } while (v==ERR); if (v=='q') q=1; if (v == 27) { v=getch(); if (v==ERR) q=1; if (v==91) { v=getch(); if (v==65) if (k > 0) k--; if (v==66) if (k < 39-(scr-5)) k++; } } if (v=='R') { n_songs=0; n_secs=0; } if (quit==1) q=1; while (v!=ERR) v=getch(); } while (q==0); werase (w); reread=1; }
bool CUpnpBrowserGui::selectItem(std::string id) { bool loop = true; bool endall = false; bool refresh = true; neutrino_msg_t msg; neutrino_msg_data_t data; std::vector<UPnPEntry> *entries = NULL; unsigned int liststart = 0; unsigned int selected = 0; unsigned int total = 0; printf("selectItem: [%s]\n", id.c_str()); if (!getItems(id, liststart, entries, total)) return endall; while (loop) { updateTimes(); if (refresh) { printf("selectItem: refresh, timeout = %d\n", (int) timeout); if (!timeout) paintItems(entries, selected - liststart, total - liststart, liststart); refresh=false; } g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout to update play/stop state display neutrino_msg_t msg_repeatok = msg & ~CRCInput::RC_Repeat; if (msg == CRCInput::RC_timeout) { // nothing } else if (msg == CRCInput::RC_home) { loop=false; endall=true; } else if (!timeout && (msg == CRCInput::RC_left)) { loop=false; } else if (!timeout && (msg_repeatok == (neutrino_msg_t) g_settings.key_list_start)) { updateItemSelection(id, entries, 0, selected, liststart); } else if (!timeout && (msg_repeatok == (neutrino_msg_t) g_settings.key_list_end)) { updateItemSelection(id, entries, total-1, selected, liststart); } else if (!timeout && (msg_repeatok == CRCInput::RC_up || (int) msg == g_settings.key_pageup)) { int step = ((int) msg == g_settings.key_pageup) ? m_listmaxshow : 1; // browse or step 1 int new_selected = selected - step; if (new_selected < 0) { if (selected != 0 && step != 1) new_selected = 0; else new_selected = total - 1; } updateItemSelection(id, entries, new_selected, selected, liststart); } else if (!timeout && (msg_repeatok == CRCInput::RC_down || (int) msg == g_settings.key_pagedown)) { int step = ((int) msg == g_settings.key_pagedown) ? m_listmaxshow : 1; // browse or step 1 int new_selected = selected + step; if (new_selected >= (int) total) { if ((total - m_listmaxshow -1 < selected) && (selected != (total - 1)) && (step != 1)) new_selected = total - 1; else if (((total / m_listmaxshow) + 1) * m_listmaxshow == total + m_listmaxshow) // last page has full entries new_selected = 0; else new_selected = ((step == (int) m_listmaxshow) && (new_selected < (int) (((total / m_listmaxshow)+1) * m_listmaxshow))) ? (total - 1) : 0; } updateItemSelection(id, entries, new_selected, selected, liststart); } else if (!timeout && (msg == CRCInput::RC_ok || msg == CRCInput::RC_right)) { if ((selected - liststart) >= (*entries).size()) continue; if ((*entries)[selected - liststart].isdir) { endall=selectItem((*entries)[selected - liststart].id); if (endall) loop=false; refresh=true; } else { m_folderplay = false; int preferred=(*entries)[selected - liststart].preferred; if (preferred != -1) { std::string &mime = (*entries)[selected - liststart].mime; if (mime.substr(0,6) == "audio/") { m_playing_entry = (*entries)[selected - liststart]; m_playing_entry_is_shown = false; playAudio((*entries)[selected - liststart].resources[preferred].url, (*entries)[selected - liststart].type); } else if (mime.substr(0,6) == "video/") { m_frameBuffer->Clear(); playVideo((*entries)[selected - liststart].title, (*entries)[selected - liststart].resources[preferred].url); m_frameBuffer->showFrame("mp3.jpg"); refresh = true; } else if (mime.substr(0,6) == "image/") { videoDecoder->setBlank(true); showPicture((*entries)[selected - liststart].resources[preferred].url); m_playid = selected; while (true) { g_RCInput->getMsg(&msg, &data, 10); // 1 sec timeout if (msg == CRCInput::RC_home || msg == CRCInput::RC_ok) break; else if (msg == CRCInput::RC_right || msg == CRCInput::RC_down) { m_playfolder = id; m_playid = (m_playid + 1)%total; playnext(); } else if (msg == CRCInput::RC_left || msg == CRCInput::RC_up) { m_playfolder = id; m_playid--; if (m_playid < 0) m_playid = total - 1; playnext(); } else CNeutrinoApp::getInstance()->handleMsg(msg, data); } m_frameBuffer->Clear(); videoDecoder->setBlank(false); refresh = true; } } } } else if (msg == CRCInput::RC_play) { if ((selected - liststart) >= (*entries).size()) continue; m_folderplay = true; m_playfolder = (*entries)[selected - liststart].id; m_playid = 0; playnext(); m_playid++; } else if (msg == CRCInput::RC_yellow) { if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP) CAudioPlayer::getInstance()->stop(); m_folderplay = false; } else if (m_folderplay && msg == (neutrino_msg_t) CRCInput::RC_stop) { timeout = 0; m_folderplay = false; m_frameBuffer->Clear(); refresh = true; } else if (m_folderplay && msg == (neutrino_msg_t) CRCInput::RC_prev) { timeout = 0; m_playid -= 2; if (m_playid < 0) m_playid = 0; } else if (m_folderplay && msg == (neutrino_msg_t) CRCInput::RC_next) { timeout = 0; if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP) CAudioPlayer::getInstance()->stop(); } else if (msg == NeutrinoMessages::RECORD_START || msg == NeutrinoMessages::ZAPTO || msg == NeutrinoMessages::STANDBY_ON || msg == NeutrinoMessages::SHUTDOWN || msg == NeutrinoMessages::SLEEPTIMER) { loop = false; g_RCInput->postMsg(msg, data); } #if 0 else if (msg == NeutrinoMessages::EVT_TIMER) { CNeutrinoApp::getInstance()->handleMsg(msg, data); } else if (msg > CRCInput::RC_MaxRC) #endif else { if (CNeutrinoApp::getInstance()->handleMsg(msg, data) & messages_return::cancel_all) loop = false; //refresh=true; } if (m_folderplay && ((!timeout || (timeout <= time(NULL))) && (CAudioPlayer::getInstance()->getState() == CBaseDec::STOP))) { playnext(); m_playid++; } } delete entries; timeout = 0; m_frameBuffer->Clear(); return endall; }