void *DataManager::do_dl_thread( void * parameter)
{
    int i;
    char buf[128];

    pthread_detach(pthread_self());
    
    pthread_mutex_t mutex;
    pthread_mutex_init(&mutex,NULL);
    
    SongInfo *pSongs = SongRndList;
    int size = 0;
    while(1) {
        if(start_dl_flag && pDownList) {
            pSongs = pDownList;
            size = pSongs->size;
                for(i=0; i<size; i++) {
                        if(restart_dl_flag)
                            break;
                        get_last_name(pSongs->location, buf);
                        if(pSongs->album_logo)
                            downloadSong(buf, pSongs->album_logo, FILE_TYPE_LOGO);
                        if(strlen(pSongs->lyric) > 6)
                             downloadSong(buf, pSongs->lyric, FILE_TYPE_LYRIC);
                        pSongs++;
                  }
                pthread_mutex_lock(&mutex);
                if(i == size) {
                    // turn off dl flag, finished
                    start_dl_flag = false;
                }else {
                    printf("*** restart dl list\n");
                    restart_dl_flag = false; // already update the dl list, restart 
                }
                pthread_mutex_unlock(&mutex);             
        }
        sleep(1);
    }
    return NULL;
}
void SearchWidget::finishGetSongUrl(QNetworkReply *reply)
{
    if(reply->error() == QNetworkReply::NoError)
    {
        QString text = reply->readAll();
        QScriptEngine engine;
        QScriptValue sv = engine.evaluate("value=" + text);
        if(sv.property("status").toInt32() == 1)
        {
            QString songurl = sv.property("url").toString();
            qDebug()<<songurl;
            if(state == Play)
                playSong(songurl);
            if(state == Download)
                downloadFile(songurl);
                downloadSong(songurl);
        }
    }
    state = -1;
}