void GPodderSearchPage::SearchClicked() { emit Busy(true); mygpo::PodcastListPtr list(api_->search(ui_->query->text())); NewClosure(list, SIGNAL(finished()), this, SLOT(SearchFinished(mygpo::PodcastListPtr)), list); NewClosure(list, SIGNAL(parseError()), this, SLOT(SearchFailed(mygpo::PodcastListPtr)), list); NewClosure(list, SIGNAL(requestError(QNetworkReply::NetworkError)), this, SLOT(SearchFailed(mygpo::PodcastListPtr)), list); }
gboolean _SearchLyricProc(SearchInfo * pInfo) { AppInfo app = {0}; theApp.m_player.GetSearchApp(pInfo->nAppIndex, &app); OnShowState("正在使用%s搜索歌词(%d)...", app.szName, pInfo->nCount); pInfo->nCount--; int iState; pid_t pr = waitpid(pInfo->child, &iState, WNOHANG); if (pr <= 0) { if (pInfo->nCount == 0) { OnShowState("使用%s搜索歌词超时!", app.szName); if (theApp.m_player.IsCurrSong(pInfo->info)) { SmartShowWnd(FALSE); } SearchFailed(*pInfo); free(pInfo); return FALSE; } return TRUE; } FILE * pFile = fopen(pInfo->szTmpFileName, "r"); if (!pFile) { LyricLog("打开临时文件(%s)失败!iState=%ld", pInfo->szTmpFileName, iState); if (theApp.m_player.IsCurrSong(pInfo->info)) { SmartShowWnd(FALSE); } SearchFailed(*pInfo); free(pInfo); return FALSE; } fseek(pFile, 0, SEEK_END); int nLen = ftell(pFile); gchar* lpszBuf = (gchar*)malloc(nLen); fseek(pFile, 0, SEEK_SET); // 解析列表并显示选择窗口 GList* ListLyrics = NULL; LyricsListItem item = {0}; while (fgets(lpszBuf, nLen, pFile)) { if (memcmp(lpszBuf, "artist=", strlen("artist=")) == 0) { strncpy(item.szArtist, lpszBuf + strlen("artist="), MAX_PATH); } else if (memcmp(lpszBuf, "title=", strlen("title=")) == 0) { strncpy(item.szTitle, lpszBuf + strlen("title="), MAX_PATH); } else if (memcmp(lpszBuf, "id=", strlen("id=")) == 0) { strncpy(item.szID, lpszBuf + strlen("id="), MAX_PATH); LyricsListItem * pNewItem = (LyricsListItem *)malloc(sizeof(LyricsListItem)); *pNewItem = item; ListLyrics = g_list_append(ListLyrics, pNewItem); memset(item.szArtist, 0, sizeof(item.szArtist)); memset(item.szID, 0, sizeof(item.szID)); memset(item.szTitle, 0, sizeof(item.szTitle)); item.index++; } } fclose(pFile); pFile = NULL; free(lpszBuf); lpszBuf = NULL; int nLyricCount = g_list_length(ListLyrics); if (nLyricCount <= 0) { LyricLog("没有搜索到歌词!歌曲信息(%s, %s)", pInfo->info.szArtist, pInfo->info.szTitle); OnShowState("没有搜索到歌词!"); SearchFailed(*pInfo); } else// if (nLyricCount > 0) { if (pInfo->bSmartDownLoad) { GList* first = g_list_first(ListLyrics); LyricsListItem *pItem = first->data; SongInfo info = pInfo->info; strncpy(info.szArtist, pItem->szArtist, MAX_PATH); strncpy(info.szTitle, pItem->szTitle, MAX_PATH); DownLoadLyric(pItem->szID, info, pInfo->nAppIndex); _FreeList(ListLyrics); } else { GladeXML* xml = glade_xml_new(SEL_LYRIC_GLADE_FILE, NULL, NULL); gtk_widget_show(SelLyricDlgInit(xml, ListLyrics, pInfo->info, pInfo->nAppIndex)); } } free(pInfo); return FALSE; }