static int voip_call_event(void* pArg) { if( appControlInfo.voipInfo.status == voipStatus_idle) { interfaceInfo.showIncomingCall = 0; interface_displayMenu(1); return 0; } interface_addEvent(voip_call_event, NULL, interfaceInfo.showIncomingCall ? 100 : 300, 1); interfaceInfo.showIncomingCall = 1 - interfaceInfo.showIncomingCall; interface_displayMenu(1); return 0; }
static int voip_fillAnsweredCallsMenu(interfaceMenu_t *pMenu, void *pArg) { FILE *file; char *str; int i = 0; interface_clearMenuEntries((interfaceMenu_t*)&AnsweredCallsMenu); str = _T("CLEARLIST"); interface_addMenuEntry((interfaceMenu_t*)&AnsweredCallsMenu, str, voip_clearList, (void*)ENTRY_INFO_SET(LIST_ANSWERED,LAST_DIALED), thumbnail_dial); file = m3u_initFile(ANSWERED_FILENAME, "r"); if(file != NULL) { while ( m3u_readEntry(file) == 0 ) { interface_addMenuEntry((interfaceMenu_t*)&AnsweredCallsMenu, m3u_description, voip_dialNumber, (void*)ENTRY_INFO_SET(LIST_ANSWERED,i), thumbnail_voip ); i++; } } if( i == 0) { str = _T("NO_ANSWERED_CALLS"); interface_addMenuEntryDisabled((interfaceMenu_t*)&AnsweredCallsMenu, str, -1 ); } interface_menuActionShowMenu(pMenu, (void*)&AnsweredCallsMenu); interface_displayMenu(1); return 0; }
static int voip_fillAddressBookMenu(interfaceMenu_t *pMenu, void *pArg) { int i = 0; char *str; FILE *file; interface_clearMenuEntries((interfaceMenu_t*)&AddressBookMenu); str = _T("ADD"); interface_addMenuEntry((interfaceMenu_t*)&AddressBookMenu, str, voip_newAddressBookURI, (void*)ENTRY_INFO_SET(LIST_ADDRESS, LAST_DIALED), thumbnail_dial); file = m3u_initFile(ADDRESSBOOK_FILENAME, "r"); if(file != NULL) { while ( m3u_readEntry(file) == 0 ) { interface_addMenuEntry((interfaceMenu_t*)&AddressBookMenu, m3u_description, voip_dialNumber, (void*)ENTRY_INFO_SET(LIST_ADDRESS, i), thumbnail_account_buddy ); i++; } } if(i == 0) { str = _T("ADDRESS_BOOK_EMPTY"); interface_addMenuEntryDisabled((interfaceMenu_t*)&AddressBookMenu, str, -1 ); } if( interface_getSelectedItem( (interfaceMenu_t*)&AddressBookMenu ) >= i ) { interface_setSelectedItem( (interfaceMenu_t*)&AddressBookMenu, i ); } interface_menuActionShowMenu(pMenu, (void*)&AddressBookMenu); interface_displayMenu(1); return 0; }
static int voip_changeParam(interfaceMenu_t *pMenu, char *value, void* pArg) { char *dest; if( value == NULL ) return 1; switch((int)pArg) { case PARAM_SERVER: dest = appControlInfo.voipInfo.server; break; case PARAM_LOGIN: dest = appControlInfo.voipInfo.login; break; case PARAM_PASSWD: dest = appControlInfo.voipInfo.passwd; break; case PARAM_REALM: dest = appControlInfo.voipInfo.realm; break; default: dest = NULL; } if( dest == NULL ) { return -2; } strcpy(dest,value); if( saveAppSettings() != 0) { interface_showMessageBox(_T("SETTINGS_SAVE_ERROR"), thumbnail_warning, 0); } voip_fillAccountMenu(pMenu, (void*)-1); interface_displayMenu(1); return 0; }
static int voip_addressBookKeyCallback(interfaceMenu_t *pMenu, pinterfaceCommandEvent_t cmd, void* pArg) { int selectedIndex = ENTRY_INFO_GET_INDEX((int)pArg); if (selectedIndex >= 0) { switch(cmd->command) { case interfaceCommandRed: // delete if( voip_deleteEntryFromList(pMenu,pArg) == 0) { interface_displayMenu(1); } return 0; case interfaceCommandGreen: // info voip_showEntryInfo( pMenu, pArg ); return 0; case interfaceCommandYellow: // edit interface_getText(pMenu, _T("ENTER_SIP_URI"), "\\w+", voip_changeURI, voip_getBuddyURI, inputModeABC, pArg); return 0; case interfaceCommandBlue: // rename interface_getText(pMenu, _T("ENTER_TITLE"), "\\w+", voip_renameBuddy, voip_getBuddyName, inputModeABC, pArg); return 0; default: ; } } return 1; }
static int voip_fillAccountMenu(interfaceMenu_t *pMenu, void *pArg) { char buf[MENU_ENTRY_INFO_LENGTH], *str; interface_clearMenuEntries((interfaceMenu_t*)&AccountMenu); snprintf(buf,MENU_ENTRY_INFO_LENGTH, "%s: %s", _T("VOIP_ENABLE"), appControlInfo.voipInfo.enabled ? _T("ON") : _T("OFF")); interface_addMenuEntry((interfaceMenu_t*)&AccountMenu, buf, voip_toggleEnabled, NULL, appControlInfo.voipInfo.enabled ? thumbnail_yes : thumbnail_no); if (appControlInfo.voipInfo.enabled) { //snprintf(buf,MENU_ENTRY_INFO_LENGTH, "SIP: %s", appControlInfo.voipInfo.sip); //interface_addMenuEntry((interfaceMenu_t*)&AccountMenu, interfaceMenuEntryText, buf, strlen(buf), 0, voip_toggleParam, NULL, NULL, (void*)PARAM_SIP, thumbnail_account); str = _T( voip_loggingIn ? "SERVER_QUERY" : (appControlInfo.voipInfo.connected || appControlInfo.voipInfo.server[0] == 0 ? "DISCONNECT" : "LOGIN_TO_SERVER") ); interface_addMenuEntryCustom((interfaceMenu_t*)&AccountMenu, interfaceMenuEntryText, str, strlen(str), appControlInfo.voipInfo.connected || appControlInfo.voipInfo.server[0] != 0, appControlInfo.voipInfo.connected || appControlInfo.voipInfo.server[0] == 0 ? voip_logoutFromServer : voip_reloginToServer, NULL, NULL, NULL, NULL, appControlInfo.voipInfo.connected ? thumbnail_account_active : thumbnail_account_inactive); snprintf(buf,MENU_ENTRY_INFO_LENGTH, "%s: %s", _T("SERVER"), appControlInfo.voipInfo.server[0] != 0 ? appControlInfo.voipInfo.server : _T("NONE") ); interface_addMenuEntry((interfaceMenu_t*)&AccountMenu, buf, voip_toggleParam, (void*)PARAM_SERVER, thumbnail_account); if( appControlInfo.voipInfo.server[0] != 0 ) { snprintf(buf,MENU_ENTRY_INFO_LENGTH, "%s: %s", _T("LOGIN"), appControlInfo.voipInfo.login); interface_addMenuEntry((interfaceMenu_t*)&AccountMenu, buf, voip_toggleParam, (void*)PARAM_LOGIN, thumbnail_account); snprintf(buf,MENU_ENTRY_INFO_LENGTH, "%s: ***", _T("PASSWORD")/*, appControlInfo.voipInfo.passwd*/); interface_addMenuEntry((interfaceMenu_t*)&AccountMenu, buf, voip_toggleParam, (void*)PARAM_PASSWD, thumbnail_account); /*snprintf(buf,MENU_ENTRY_INFO_LENGTH, "%s: %s", _T("REALM"), appControlInfo.voipInfo.realm); interface_addMenuEntry((interfaceMenu_t*)&AccountMenu, buf, voip_toggleParam, (void*)PARAM_REALM, thumbnail_account);*/ } } if( appControlInfo.voipInfo.connected == 0 && appControlInfo.voipInfo.server[0] == 0 && interface_getSelectedItem((interfaceMenu_t*)&AccountMenu) == 0 ) { interface_setSelectedItem((interfaceMenu_t*)&AccountMenu, MENU_ITEM_BACK); } interface_setMenuLogo((interfaceMenu_t*)&AccountMenu, appControlInfo.voipInfo.connected ? thumbnail_account_active : thumbnail_account_inactive, -1, 0, 0, 0); if( pArg != NULL || (interfaceInfo.currentMenu == (interfaceMenu_t*)&AccountMenu) ) { interface_menuActionShowMenu(pMenu, (void*)&AccountMenu); interface_displayMenu(1); } return 0; }
static int voip_callsKeyCallback(interfaceMenu_t *pMenu, pinterfaceCommandEvent_t cmd, void* pArg) { int res, selectedIndex = ENTRY_INFO_GET_INDEX((int)pArg), listIndex = ENTRY_INFO_GET_LIST((int)pArg); char *str = NULL; if (selectedIndex >= 0) { switch(cmd->command) { case interfaceCommandRed: // delete if( voip_deleteEntryFromList(pMenu,pArg) == 0) { interface_displayMenu(1); } return 0; case interfaceCommandGreen: // info voip_showEntryInfo( pMenu, pArg ); return 0; case interfaceCommandYellow: // address book //ENTRY_INFO_SET(LIST_MISSED,selectedIndex) switch(listIndex) { case LIST_MISSED: str = MISSED_FILENAME; break; case LIST_ANSWERED: str = ANSWERED_FILENAME; break; case LIST_DIALED: str = DIALED_FILENAME; break; default :; } if( str == NULL ) { return 0; } if( (res = m3u_getEntry( str, selectedIndex)) == 0) { strcpy(appControlInfo.voipInfo.lastSip, m3u_url); voip_addNewAddressBookEntry(pMenu, appControlInfo.voipInfo.lastSip, NULL); } return 0; default:; } } return 1; }
int open_browser_mw(interfaceMenu_t* pMenu, void* pArg) { #ifdef STBPNX char buf[MENU_ENTRY_INFO_LENGTH]; char open_link[MENU_ENTRY_INFO_LENGTH]; interface_showMessageBox(_T("LOADING_BROWSER"), thumbnail_internet, 0); interface_displayMenu(1); // fill second buffer with same frame getParam(BROWSER_CONFIG_FILE, "HomeURL", "", buf); if(buf[0]!=0) sprintf(open_link,"/usr/local/webkit/_start.sh %s",buf); else sprintf(open_link,"/usr/local/webkit/_start.sh"); helperStartApp(open_link); #endif return 0; }
static void *youtube_MenuVideoSearchThread(void* pArg) { int page; char *str; interfaceMenu_t *pMenu = (interfaceMenu_t *) pArg; int old_count = -1; if(youtubeInfo.search[0] == 0) page = 2; else page = 1; for(; (( page < YOUTUBE_MAX_LINKS/YOUTUBE_LINKS_PER_PAGE + 1 ) && ( old_count != youtubeInfo.count )); page++) { pthread_testcancel(); old_count = youtubeInfo.count; youtube_fillMenu( pMenu, (void *)page ); interface_displayMenu(1); } }
static int rtsp_displayStreamMenu(void* pArg) { char channelEntry[MENU_ENTRY_INFO_LENGTH]; streams_struct* stream_ptr=NULL; int which = GET_NUMBER(pArg); interfaceMenu_t *rtspMenu = (interfaceMenu_t*)&rtspStreamMenu; interface_clearMenuEntries(rtspMenu); interface_showLoadingAnimation(); int streamNumber = 0; for (stream_ptr = pstream_head; stream_ptr != NULL; stream_ptr = stream_ptr->next) { sprintf(channelEntry, "%d: %s", streamNumber+1, stream_ptr->name ? stream_ptr->name : stream_ptr->stream); int entryIndex = interface_addMenuEntry(rtspMenu, channelEntry, rtsp_stream_change, CHANNEL_INFO_SET(which, streamNumber), thumbnail_vod) - 1; interface_setMenuEntryImage(rtspMenu, entryIndex, stream_ptr->thumb); //dprintf("%s: Compare current %s\n", __FUNCTION__, channelEntry); if ( strcmp(stream_info.ip, appControlInfo.rtspInfo.streamIP) == 0 && strcmp(stream_info.streamname, stream_ptr->stream) == 0 ) { interface_setSelectedItem(rtspMenu, streamNumber); } streamNumber++; } if (streamNumber == 0) { char *str; str = _T("NO_MOVIES"); interface_addMenuEntryDisabled(rtspMenu, str, thumbnail_info); } interface_hideLoadingAnimation(); interface_displayMenu(1); return 0; }
static int voip_toggleEnabled(interfaceMenu_t *pMenu, void* pArg) { int showinfo = 1; appControlInfo.voipInfo.enabled = !appControlInfo.voipInfo.enabled; if( saveAppSettings() != 0) { interface_showMessageBox(_T("SETTINGS_SAVE_ERROR"), thumbnail_warning, 0); showinfo = 0; } voip_fillAccountMenu(pMenu, (void*)-1); interface_displayMenu(1); if (showinfo) { interface_showMessageBox(_T("PLEASE_WAIT"), thumbnail_info, 0); } if (appControlInfo.voipInfo.enabled) { system("/usr/local/etc/init.d/S95voip reload"); sleep(5); } else { system("/usr/local/etc/init.d/S95voip stop"); sleep(1); } if (showinfo) { interface_hideMessageBox(); } return 0; }
static int rtsp_play_callback(interfacePlayControlButton_t button, void *pArg) { int which = CHANNEL_INFO_GET_SCREEN(pArg); //int streamNumber = CHANNEL_INFO_GET_CHANNEL(pArg); char url[MAX_URL]; dprintf("%s: in %d\n", __FUNCTION__, button); if ( button == interfacePlayControlPrevious ) { rtsp_startNextChannel(1, pArg); } else if ( button == interfacePlayControlNext ) { rtsp_startNextChannel(0, pArg); } else if ( button == interfacePlayControlSetPosition ) { double position = 0.0; if ( !appControlInfo.rtspInfo.active ) { position = interface_playControlSliderGetPosition(); appControlInfo.playbackInfo.scale = 1.0; rtsp_startVideo(which); gfx_setVideoProviderPosition(screenMain,position); } else { position = interface_playControlSliderGetPosition(); if (gfx_videoProviderIsPaused(screenMain)) { gfx_resumeVideoProvider(screenMain); } gfx_setVideoProviderPosition(screenMain,position); //appControlInfo.playbackInfo.scale = 1.0 gfx_setSpeed(screenMain, appControlInfo.playbackInfo.scale); if( appControlInfo.playbackInfo.scale == 1.0 ) { interface_notifyText(NULL, 0); interface_playControlSelect(interfacePlayControlPlay); } else { sprintf(url, "%1.0fx", appControlInfo.playbackInfo.scale); interface_notifyText(url, 0); interface_playControlSelect(appControlInfo.playbackInfo.scale > 0.0 ? interfacePlayControlFastForward : interfacePlayControlRewind); } } return 0; } else if ( button == interfacePlayControlPlay ) { if ( !appControlInfo.rtspInfo.active ) { appControlInfo.playbackInfo.scale = 1.0; rtsp_startVideo(which); } else { appControlInfo.playbackInfo.scale = 1.0; if (gfx_videoProviderIsPaused(screenMain)) { gfx_resumeVideoProvider(screenMain); } gfx_setSpeed(screenMain, appControlInfo.playbackInfo.scale); interface_notifyText(NULL, 0); interface_playControlSelect(interfacePlayControlPlay); } } else if ( button == interfacePlayControlStop ) { if ( appControlInfo.rtspInfo.active ) { void *show_menu = NULL; switch (appControlInfo.playbackInfo.playlistMode) { case playlistModeIPTV: show_menu = (void*)&rtpStreamMenu; break; case playlistModeFavorites: show_menu = (void*)&playlistMenu; break; #ifdef ENABLE_DLNA case playlistModeDLNA: show_menu = (void*)&BrowseServersMenu; break; #endif default: show_menu = (void*)&rtspStreamMenu; } rtsp_stopVideo(which); /* #ifdef ENABLE_VIDIMAX dprintf("%s(stop): currentMenu %s\n", __FUNCTION__, interfaceInfo.currentMenu->name); if (interfaceInfo.currentMenu == (interfaceMenu_t*)&VidimaxMenu){ show_menu = (void*)&VidimaxMenu; } #endif */ interface_menuActionShowMenu(interfaceInfo.currentMenu, show_menu); interface_showMenu(1, 1); } } else if ( button == interfacePlayControlPause ) { if ( appControlInfo.rtspInfo.active ) { if (gfx_videoProviderIsPaused(screenMain)) { //appControlInfo.playbackInfo.scale = 1.0; gfx_resumeVideoProvider(screenMain); gfx_setSpeed(screenMain, appControlInfo.playbackInfo.scale); interface_playControlSelect(interfacePlayControlPlay); } else { eprintf("%s: gfx_stopVideoProvider...\n", __FUNCTION__); gfx_stopVideoProvider(screenMain, 0, 0); interface_playControlSelect(interfacePlayControlPause); } } } else if ( button == interfacePlayControlFastForward ) { if ( !appControlInfo.rtspInfo.active ) { rtsp_startVideo(which); gfx_setSpeed(screenMain, appControlInfo.playbackInfo.scale); } else { float newScale; if (gfx_videoProviderIsPaused(screenMain)) gfx_resumeVideoProvider(screenMain); if( appControlInfo.playbackInfo.scale >= MAX_SCALE ) newScale = 0.0; else if( appControlInfo.playbackInfo.scale > 0.0 ) newScale = appControlInfo.playbackInfo.scale * 2; else if( appControlInfo.playbackInfo.scale < -2.0 ) newScale = appControlInfo.playbackInfo.scale / 2; else newScale = 1.0; if( newScale != 0.0 && gfx_setSpeed(screenMain, newScale) == 0 ) appControlInfo.playbackInfo.scale = newScale; } if( appControlInfo.playbackInfo.scale == 1.0 ) { interface_notifyText(NULL, 0); interface_playControlSelect(interfacePlayControlPlay); } else { sprintf(url, "%1.0fx", appControlInfo.playbackInfo.scale); interface_notifyText(url, 0); interface_playControlSelect(appControlInfo.playbackInfo.scale > 0.0 ? interfacePlayControlFastForward : interfacePlayControlRewind); } } else if ( button == interfacePlayControlRewind ) { if ( !appControlInfo.rtspInfo.active ) { rtsp_startVideo(which); gfx_setSpeed(screenMain, appControlInfo.playbackInfo.scale); } else { float newScale; if (gfx_videoProviderIsPaused(screenMain)) gfx_resumeVideoProvider(screenMain); if( appControlInfo.playbackInfo.scale >= 2.0 ) newScale = appControlInfo.playbackInfo.scale / 2; else if( appControlInfo.playbackInfo.scale > 0.0 ) newScale = -2.0; else if( appControlInfo.playbackInfo.scale > -MAX_SCALE ) newScale = appControlInfo.playbackInfo.scale * 2; else newScale = 0.0; if( newScale != 0.0 && gfx_setSpeed(screenMain, newScale) == 0 ) appControlInfo.playbackInfo.scale = newScale; } if( appControlInfo.playbackInfo.scale == 1.0 ) { interface_notifyText(NULL, 0); interface_playControlSelect(interfacePlayControlPlay); } else { sprintf(url, "%1.0fx", appControlInfo.playbackInfo.scale); interface_notifyText(url, 0); interface_playControlSelect(appControlInfo.playbackInfo.scale > 0.0 ? interfacePlayControlFastForward : interfacePlayControlRewind); } } else if (button == interfacePlayControlInfo) { interface_playControlSliderEnable(!interface_playControlSliderIsEnabled()); interface_displayMenu(1); return 0; } else if (button == interfacePlayControlAddToPlaylist) { sprintf(url,"rtsp://%s:%d/%s", stream_info.ip, stream_info.port, stream_info.streamname); playlist_addUrl(url, stream_info.streamname); } else if(button == interfacePlayControlMode && appControlInfo.playbackInfo.playlistMode == playlistModeIPTV && appControlInfo.rtpMenuInfo.epg[0] != 0 ) { rtp_showEPG(which, rtsp_setupPlayControl); } else { // default action return 1; } interface_displayMenu(1); dprintf("%s: done\n", __FUNCTION__); return 0; }
int rtsp_startVideo(int which) { char rtsp_url[256+32]; char *str; interface_showLoadingAnimation(); mysem_get(rtsp_semaphore); dprintf("%s: got sem\n", __FUNCTION__); media_slideshowStop(1); gfx_stopVideoProviders(which); sprintf(rtsp_url,"rtsp://%s:%d/%s", stream_info.ip, stream_info.port, stream_info.streamname); // xWorks links workaround if( (str = strstr(rtsp_url, "?manualDetectVideoInfo")) != NULL ) *str = 0; dprintf("%s: starting video %s\n", __FUNCTION__, rtsp_url); if (gfx_startVideoProvider(rtsp_url, which, 1, "") != 0) { mysem_release(rtsp_semaphore); interface_showMessageBox(_T("ERR_STREAM_UNAVAILABLE"), thumbnail_error, 0); eprintf("RTSP: Failed to start video provider '%s'\n", rtsp_url); return -1; } #ifdef ENABLE_VERIMATRIX if (appControlInfo.useVerimatrix != 0) { eprintf("RTSP: Enable verimatrix...\n"); if (gfx_enableVideoProviderVerimatrix(screenMain, VERIMATRIX_INI_FILE) != 0) { interface_showMessageBox(_T("ERR_VERIMATRIX_INIT"), thumbnail_error, 0); } } #endif #ifdef ENABLE_SECUREMEDIA if (appControlInfo.useSecureMedia != 0) { eprintf("RTSP: Enable securemedia...\n"); if (gfx_enableVideoProviderSecureMedia(screenMain) != 0) { interface_showMessageBox(_T("ERR_SECUREMEDIA_INIT"), thumbnail_error, 0); } } #endif if(!gfx_getVideoProviderHasVideo(screenMain)) { if(appControlInfo.slideshowInfo.state == slideshowDisabled) { interface_setBackground(0,0,0,0xFF, INTERFACE_WALLPAPER_IMAGE); } } else { media_slideshowStop(1); } if (gfx_isTrickModeSupported(screenMain)) { interface_playControlSetButtons( interface_playControlGetButtons()|interfacePlayControlFastForward|interfacePlayControlRewind ); } appControlInfo.rtspInfo.active = 1; interface_playControlSelect(interfacePlayControlStop); interface_playControlSelect(interfacePlayControlPlay); #ifdef STBPNX double length_stream = 0.0; double position_stream = 0.0; /// FIXME: should be done by gfx_startVideoProvider if(gfx_getPosition(&length_stream,&position_stream) == 0) { //dprintf("%s: start from pos %f\n", __FUNCTION__, position_stream); interface_playControlSlider(0, (unsigned int)length_stream, (unsigned int)position_stream); }else { interface_playControlSlider(0, 0, 0); } #endif rtsp_enableStateCheck(); dprintf("%s: release sem\n", __FUNCTION__); mysem_release(rtsp_semaphore); interface_hideLoadingAnimation(); interface_displayMenu(1); return 0; }
int youtube_getVideoList(const char *url, youtubeEntryHandler pCallback, int page) { CURLcode ret; CURL *hnd; char proxy[32]; char login[512]; char *str; xmlConfigHandle_t list; xmlConfigHandle_t item; TiXmlNode *entry; TiXmlNode *child; TiXmlElement *elem; const char *video_name, *video_type, *video_url, *thumbnail; static char curl_data[YOUTUBE_LIST_BUFFER_SIZE]; static char err_buff[CURL_ERROR_SIZE]; static curlBufferInfo_t buffer; buffer.data = curl_data; buffer.size = sizeof(curl_data); buffer.pos = 0; if( url == 0 || pCallback == 0 ) return -2; curl_data[0] = 0; hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(hnd, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(hnd, CURLOPT_URL, url); curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, err_buff); curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 2); curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 1); curl_easy_setopt(hnd, CURLOPT_CONNECTTIMEOUT, 15); curl_easy_setopt(hnd, CURLOPT_TIMEOUT, 15); getParam(BROWSER_CONFIG_FILE, "HTTPProxyServer", "", proxy); if( proxy[0] != 0 ) { curl_easy_setopt(hnd, CURLOPT_PROXY, proxy); getParam(BROWSER_CONFIG_FILE, "HTTPProxyLogin", "", login); if( login[0] != 0 ) { str = &login[strlen(login)+1]; getParam(BROWSER_CONFIG_FILE, "HTTPProxyPasswd", "", str); if( *str != 0 ) { str[-1] = ':'; } curl_easy_setopt(hnd, CURLOPT_PROXYUSERPWD, login); } } if (page == 1) { interface_showLoading(); interface_displayMenu(1); } ret = curl_easy_perform(hnd); dprintf("%s: page %d of '%s' acquired (length %d)\n", __FUNCTION__, page, youtubeInfo.search[0] ? youtubeInfo.search : "standard feeds", buffer.pos); curl_easy_cleanup(hnd); if (ret != 0) { eprintf("Youtube: Failed to get video list from '%s': %s\n", url, err_buff); if (page == 1) interface_hideLoading(); return -1; } list = xmlConfigParse( curl_data ); if (list == NULL || (item = xmlConfigGetElement(list, "feed", 0)) == NULL) { if (list) { eprintf("Youtube: parse error %s\n", ((TiXmlDocument*)list)->ErrorDesc()); xmlConfigClose(list); } if (page == 1)interface_hideLoading(); eprintf("Youtube: Failed to parse video list %d\n", page); return -1; } for ( entry = ((TiXmlNode *)item)->FirstChild(); entry != 0; entry = entry->NextSibling() ) { if (entry->Type() == TiXmlNode::TINYXML_ELEMENT && strcasecmp(entry->Value(), "entry") == 0) { item = xmlConfigGetElement(entry, "media:group", 0); if( item != NULL ) { video_name = (char *)xmlConfigGetText(item, "media:title"); video_url = NULL; thumbnail = NULL; for ( child = ((TiXmlNode *)item)->FirstChild(); child != 0 && (video_url == NULL || thumbnail == NULL); child = child->NextSibling() ) { if (child->Type() == TiXmlNode::TINYXML_ELEMENT ) { if(strcasecmp(child->Value(), "media:content") == 0) { elem = (TiXmlElement *)child; video_type = elem->Attribute("type"); if( strcmp( video_type, "application/x-shockwave-flash" ) == 0) { video_url = elem->Attribute("url"); } } else if(thumbnail== 0 && strcasecmp(child->Value(), "media:thumbnail") == 0) { elem = (TiXmlElement *)child; thumbnail = elem->Attribute("url"); } } } if( video_url != NULL ) { //dprintf("%s: Adding Youtube video '%s' url='%s' thumb='%s'\n", __FUNCTION__,video_name,video_url,thumbnail); pCallback(video_url,video_name,thumbnail); } } } } xmlConfigClose(list); if (page == 1) interface_hideLoading(); return ret; }
static void *voip_readPipeThread(void *pArg) { char buffer[BUFFER_SIZE], *buf, *str, *pos; int bytes_left, bytes_total; dprintf("%s: in\n", __FUNCTION__); while( appControlInfo.voipInfo.active ) { //dprintf("%s: read loop\n", __FUNCTION__); if( (bytes_total = voip_pipe_read(buffer, sizeof(buffer))) > 0) { bytes_left = bytes_total; while (bytes_left > 0) { buf = &buffer[bytes_total-bytes_left]; dprintf("%s: recieved '%s' %d/%d\n", __FUNCTION__,buf, bytes_left, bytes_total); bytes_left -= strlen(buf)+1; switch( buf[0] ) { case 'A': if( strncasecmp( buf, "Account deleted", 15 ) == 0) { appControlInfo.voipInfo.connected = 0; voip_loggingIn = 0; voip_fillMenu(interfaceInfo.currentMenu, (void*)0); voip_fillAccountMenu(interfaceInfo.currentMenu, NULL); } break; case 'I': str = &buf[2]; pos = index(str,'\n'); if(pos!=NULL) { time(&voip_lastCallTime); *pos = 0; strcpy(appControlInfo.voipInfo.lastSip,str); //from saveAppSettings(); str = &pos[1]; appControlInfo.voipInfo.status = voipStatus_incoming; voip_call_event(NULL); voip_fillMenu(interfaceInfo.currentMenu, (void*)0); // to (ignored) } break; case 'D': // Disconnect voip_hangup(interfaceInfo.currentMenu,NULL); break; case 'C': if(strncasecmp(buf,"Calling",7) == 0) { appControlInfo.voipInfo.status = voipStatus_dialing; voip_call_event(NULL); voip_fillMenu(interfaceInfo.currentMenu, (void*)0); } else if(strncasecmp(buf,"Connecting",10) == 0) { appControlInfo.voipInfo.status = voipStatus_talking; voip_call_event(NULL); voip_fillMenu(interfaceInfo.currentMenu, (void*)0); } break; case 'L'://Logged In/Logged out if( strncasecmp(buf,"Logged ",7) == 0) { appControlInfo.voipInfo.connected = buf[7] == 'I';// In/Out voip_loggingIn = 0; voip_fillMenu(interfaceInfo.currentMenu, (void*)0); voip_fillAccountMenu(interfaceInfo.currentMenu, NULL); } else if( strncasecmp(buf,"Logging ",8) == 0) { appControlInfo.voipInfo.connected = 0; voip_loggingIn = 1; voip_fillMenu(interfaceInfo.currentMenu, (void*)0); voip_fillAccountMenu(interfaceInfo.currentMenu, NULL); } break; case 'O': strcpy(appControlInfo.voipInfo.lastSip, &buf[1]); voip_addEntryToList(interfaceInfo.currentMenu, (void*)LIST_DIALED); break; case 'R': //Registration Failed if( strncasecmp( buf, "Registration Failed", 19) == 0 ) { appControlInfo.voipInfo.connected = 0; voip_loggingIn = 0; voip_fillMenu(interfaceInfo.currentMenu, (void*)0); voip_fillAccountMenu(interfaceInfo.currentMenu, NULL); interface_showMessageBox(_T("ERR_VOIP_REGISTER"), thumbnail_error, 3000); } break; case 'E': break; default: ; // ignore } interface_displayMenu(1); } } else { //eprintf("VoIP: Error reading NOTIFY pipe\n"); /*voip_cleanup(); break;*/ usleep(1000000); } } dprintf("%s: done\n", __FUNCTION__); //close(voip_socket); return NULL; }