示例#1
0
void playlist::getNError(QNetworkReply::NetworkError error)
{
    qDebug() << "Network Error (if this is 99 then it will retry" << error;
    if(error == QNetworkReply::UnknownNetworkError && this->currentdownloaditem != -1)
        beginDownload(this->currentdownloaditem);

}
示例#2
0
void playlist::downloadDone(int position)
{
    if(this->existAt(position+1) && this->currentSkeyItem == -1 && !pList->at(position+1)->downloaded && this->currentdownloaditem != position+1)
    {
        if(((position+1) - this->currentplaying())<=this->prefetch)
            beginDownload(position+1);
    }
    else
        this->currentdownloaditem = -1;
    pList->at(position)->downloaded = true;
    QModelIndex changed = this->createIndex(position,this->sName,0);
    emit this->dataChanged(changed,changed);
}
void IVLEFetcher::buildDirectoriesAndDownloadList(){
    QVariantMap::Iterator it,itt, ittt;
    QString name;
    QVariantMap folders, course,files,file;
    toDownload.clear();
    for(it = courses.begin(); it != courses.end(); it++){
        course = it.value().toMap();
        name = course.value("name").toString();
        folders = course.value("folders").toMap();
        if(!path.exists(name)){
            if(!path.mkpath(name)){
                qWarning("Failed to create directory!");
            }
        }
        path.cd(name);
        for(itt = folders.begin(); itt != folders.end(); itt++){
            files = itt.value().toMap();
            if(files.count() == 0){
                qDebug()<<itt.key();
            }else{
                if(!path.exists(itt.key())){
                    path.mkdir(itt.key());
                }
                path.cd(itt.key());
                for(ittt = files.begin(); ittt != files.end(); ittt++){
                    file = ittt.value().toMap();
                    //TODO: update files if the file found is older than the one in webbin
                    if(!path.exists(file.value("name").toString())){
                        toDownload.insert(ittt.key(),path.absoluteFilePath(file.value("name").toString()));
                    }
                }
                path.cdUp();
            }
        }
        path.cdUp();
    }
    emit statusUpdate(gottenWebbinInfo);
    beginDownload();
}
示例#4
0
bool StartStage_AutoPatch::processMessage(unsigned int uiMsgID, void* pParam)
{
	WriteConWarning("Entry Proecess Message For C++\n");

	switch (uiMsgID)
	{
	case MSG_DOWNLOAD_URL:
		{
			NDMsg_DownloadUrl* pkUrl = (NDMsg_DownloadUrl*) pParam;
			m_bRequestedDownload = true;

			if (pkUrl->getMsgID() != uiMsgID)
			{
				return false;
			}

			if (!pkUrl->getNeedDownload())
			{
				setDone();
				return true;
			}

			m_pkStageUI->showProgress(true);

			const StringVector& kVec = pkUrl->getUrlVector();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
			char szExeFileName[500] = {0};
			GetModuleFileNameA(0, szExeFileName, sizeof(szExeFileName));
			string strCurrentDir = getPath(szExeFileName);
			SetCurrentDirectoryA(strCurrentDir.c_str());
			strCurrentDir.erase(strCurrentDir.end() - 1);
			strCurrentDir = getUpFolder(strCurrentDir);
#endif

			WriteConWarning("Will Download Patch From Server!\n");

			for (unsigned int uiIndex = 0; uiIndex < kVec.size(); uiIndex++)
			{
				const string& strUrl = kVec[uiIndex];

				if (0 == strUrl.size())
				{
					continue;
				}

				int nPos = strUrl.find_last_of('/');

				if (-1 == nPos)
				{
					continue;
				}

				string strFileName = strUrl.substr(nPos + 1, strUrl.length());

				DownloadPackage* pkPackage = new DownloadPackage;
				pkPackage->FromUrl(strUrl.c_str());

				string strPath = "";
				char szTempPath[2048] = { 0 };
				//SDCARD_GAME_NAME_SLASH
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
				strPath = string(SDCARD_GAME_NAME_SLASH) + strFileName;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
				strPath = strCurrentDir + strFileName;
#endif

				WriteCon(
					"%d:%s will be download...Add to download task list.\n Save to %s...\n",
					uiIndex + 1, strUrl.c_str(), strPath.c_str());

				pkPackage->ToPath(strPath.c_str());
				pkPackage->setDownloadListener(this);

				m_kDownloadList.push_back(pkPackage);

				beginDownload();
			}
		}
		break;
	default:
		return false;
	}

	return true;
}