コード例 #1
0
void 
XPFUpdateWindow::setUpdateItemList (XPFUpdateItemList *list)
{
	CStr255_AC theWordDelete ((ResNumber) kXPFStringsResource, kDeleteWord);
	CStr255_AC theWordInstall ((ResNumber) kXPFStringsResource, kInstallWord);

	TView *listView = FindSubView ('list');
	listView->SetDrawingEnvironment (new TThemeWhiteEnvironment, false);

	CViewPoint offset (0, 0);
	
	for (XPFUpdateListIterator iter (list); iter.Current (); iter.Next ()) {
		if (iter->getAction () == kActionNone) continue;
	
		TView *itemView = TViewServer::fgViewServer->DoCreateViews (GetDocument (), listView, kUpdateItem, offset);
		
		TStaticText *name = (TStaticText *) itemView->FindSubView ('item');
		TStaticText *installed = (TStaticText *) itemView->FindSubView ('inst');
		TStaticText *available = (TStaticText *) itemView->FindSubView ('avai');
		TStaticText *action = (TStaticText *) itemView->FindSubView ('acti');
		
		name->SetText (iter->getResourceName (), false);
		
		char buffer [64];
		
		parseVersion (buffer, iter->getInstalledVersion ());
		installed->SetText (buffer, false);
		
		parseVersion (buffer, iter->getAvailableVersion ());
		available->SetText (buffer, false);
		
		if (!iter->getIsQualified ()) available->SetText ("n/a", false);
		
		switch (iter->getAction ()) {
	
			case kActionDelete:
				theWordDelete.CopyTo (buffer);
				break;
			
			case kActionInstall:
				theWordInstall.CopyTo (buffer);
				break;
				
			default:
				buffer[0] = 0;
				break;
				
		}
		
		action->SetText (buffer, false);	
		
		offset.v += itemView->GetSize().v;
	}	
}
コード例 #2
0
static int updateVersionHelper(const QString &command)
{
    Utils::SynchronousProcess process;
    Utils::SynchronousProcessResponse response
            = process.runBlocking(command, QStringList() << QLatin1String("--version"));
    if (response.result != Utils::SynchronousProcessResponse::Finished)
        return 0;

    // Astyle prints the version on stdout or stderr, depending on platform
    const int version = parseVersion(response.stdOut().trimmed());
    if (version != 0)
        return version;
    return parseVersion(response.stdErr().trimmed());
}
void AssetsManager::update()
{
    if (!_localManifest->isLoaded())
    {
        CCLOG("AssetsManager : No local manifest file found error.\n");
        dispatchUpdateEvent(EventAssetsManager::EventCode::ERROR_NO_LOCAL_MANIFEST);
        return;
    }

    _waitToUpdate = true;

    switch (_updateState) {
        case State::UNCHECKED:
        {
            _updateState = State::PREDOWNLOAD_VERSION;
        }
        case State::PREDOWNLOAD_VERSION:
        {
            downloadVersion();
        }
            break;
        case State::VERSION_LOADED:
        {
            parseVersion();
        }
            break;
        case State::PREDOWNLOAD_MANIFEST:
        {
            downloadManifest();
        }
            break;
        case State::MANIFEST_LOADED:
        {
            parseManifest();
        }
            break;
        case State::FAIL_TO_UPDATE:
        case State::NEED_UPDATE:
        {
            // Manifest not loaded yet
            if (!_remoteManifest->isLoaded())
            {
                _waitToUpdate = true;
                _updateState = State::PREDOWNLOAD_MANIFEST;
                downloadManifest();
            }
            else
            {
                startUpdate();
            }
        }
            break;
        case State::UP_TO_DATE:
        case State::UPDATING:
            _waitToUpdate = false;
            break;
        default:
            break;
    }
}
コード例 #4
0
ファイル: read300.cpp プロジェクト: AntonioBL/MuseScore
Score::FileError MasterScore::read300(XmlReader& e)
      {
      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "programVersion") {
                  setMscoreVersion(e.readElementText());
                  parseVersion(mscoreVersion());
                  }
            else if (tag == "programRevision")
                  setMscoreRevision(e.readInt());
            else if (tag == "Score") {
                  if (!read(e))
                        return FileError::FILE_BAD_FORMAT;
                  }
            else if (tag == "Revision") {
                  Revision* revision = new Revision;
                  revision->read(e);
                  revisions()->add(revision);
                  }
            }

      int id = 1;
      for (LinkedElements* le : e.linkIds())
            le->setLid(this, id++);

      for (Staff* s : staves())
            s->updateOttava();

      setCreated(false);
      return FileError::FILE_NO_ERROR;
      }
コード例 #5
0
ファイル: read301.cpp プロジェクト: Jojo-Schmitz/MuseScore
Score::FileError MasterScore::read301(XmlReader& e)
      {
      bool top = true;
      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "programVersion") {
                  setMscoreVersion(e.readElementText());
                  parseVersion(mscoreVersion());
                  }
            else if (tag == "programRevision")
                  setMscoreRevision(e.readIntHex());
            else if (tag == "Score") {
                  MasterScore* score;
                  if (top) {
                        score = this;
                        top   = false;
                        }
                  else {
                        score = new MasterScore();
                        score->setMscVersion(mscVersion());
                        addMovement(score);
                        }
                  if (!score->read(e))
                        return FileError::FILE_BAD_FORMAT;
                  }
            else if (tag == "Revision") {
                  Revision* revision = new Revision;
                  revision->read(e);
                  revisions()->add(revision);
                  }
            }
      return FileError::FILE_NO_ERROR;
      }
コード例 #6
0
ファイル: updater.cpp プロジェクト: 0312birdzhang/taot
void Updater::setCurrentVersion(const QString &currentVersion)
{
    if (m_currentVersion == currentVersion)
        return;

    m_currentVersion = currentVersion;
    m_numericCurrentVersion = parseVersion(m_currentVersion);
    emit currentVersionChanged();
}
コード例 #7
0
DWORD WINAPI LoadUpdate (LPVOID param)
{
  CUpdateDlg* dlg = (CUpdateDlg*) param;

  if (dlg->autoCheck)
    UpdateVersion (NULL);

  char buf[2048];
  sprintf (buf, "Current version: %s\r\n"
                "Last version: %s\r\n",
                formatVersion (curVersion),
                formatVersion (lastVersion));
  dlg->SetDlgItemText (IDC_BUFFER, buf);

  if (curVersion < lastVersion)
  {
    CString log = buf;
    log += "\r\nLoading changelog...";
    dlg->SetDlgItemText (IDC_BUFFER, log);
    try
    {
      CInternetSession inet;
      CInternetFile* file = dynamic_cast<CInternetFile*> (inet.OpenURL (logURL));
      log = buf;
      log += "\r\nChangelog:\r\n";
      if (file != NULL)
      {
        while (file->ReadString (buf, sizeof buf - 5))
        {
          if (buf[0] == '*' && buf[1] == '*')
          {
            unsigned int ver = parseVersion (buf + 2);
            if (ver != 0 && ver <= curVersion)
              break;
          }
          log += buf;
        }
        log.Replace ("\n", "\r\n");
        dlg->SetDlgItemText (IDC_BUFFER, log);
        delete file;
      }
      else
        lastVersion = 0;
    }
    catch (CInternetException*)
    {
    }
  }

  return 0;
}
コード例 #8
0
ファイル: opackagemanager.cpp プロジェクト: opieproject/opie
int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 )
{
    // TODO - should this be in OIpkg???

    int epoch1, epoch2;
    QString version1, revision1;
    QString version2, revision2;

    parseVersion( ver1, &epoch1, &version1, &revision1 );
    parseVersion( ver2, &epoch2, &version2, &revision2 );

    if ( epoch1 > epoch2 )
        return 1;
    else if ( epoch1 < epoch2 )
        return -1;

    int r = verrevcmp( version1.latin1(), version2.latin1() );
    if (r)
        return r;

    r = verrevcmp( revision1.latin1(), revision2.latin1() );
    return r;
}
コード例 #9
0
extern int iniReader()
{

	FILE *handle = NULL;
	if (fopen_s(&handle, __INIFILE__, "r"))
	{
		return 1;
	}
	if (handle == NULL)
	{
		crashViewer("0x10000002", "接收数据时侦测到空指针错误");
		return -2;
	}
	while (!feof(handle))
	{

		char temp[__BUFFSIZE__];
		fgets(temp, __BUFFSIZE__, handle);

		if (strchr(temp, '#') != NULL)
		{
			continue;
		}
		if (strcmp(temp, "[VERSION]\n") == 0)
		{
			parseVersion(handle);
		}
		else if (strcmp(temp, "[ADMINISTRATOR]\n") == 0)
		{
			parseAdmin(handle);
		}
		else if (strcmp(temp, "[LOG]\n") == 0)
		{
			parseLOG(handle);
		}
		else if (strcmp(temp, "[DB]\n") == 0)
		{
			parseDB(handle);
		}
		else {
			continue;
		}

	}

	return 0;
}
コード例 #10
0
ファイル: UpdateChecker.cpp プロジェクト: Samangan/mpc-hc
Update_Status UpdateChecker::isUpdateAvailable(const Version& currentVersion)
{
	Update_Status updateAvailable = UPDATER_LATEST_STABLE;

	try {
		CInternetSession internet;
		CHttpFile* versionFile = (CHttpFile*) internet.OpenURL(versionFileURL,
															   1,
															   INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD,
															   NULL,
															   0);

		if (versionFile) {
			CString latestVersionStr;
			char buffer[101];
			UINT br = 0;

			while ((br = versionFile->Read(buffer, 50)) > 0) {
				buffer[br] = '\0';
				latestVersionStr += buffer;
			}

			if (!parseVersion(latestVersionStr)) {
				updateAvailable = UPDATER_ERROR;
			} else {
				int comp = compareVersion(currentVersion, latestVersion);

				if (comp < 0) {
					updateAvailable = UPDATER_UPDATE_AVAILABLE;
				} else if (comp > 0) {
					updateAvailable = UPDATER_NEWER_VERSION;
				}
			}

			delete versionFile;
		} else {
			updateAvailable = UPDATER_ERROR;
		}
	} catch (CInternetException* pEx) {
		updateAvailable = UPDATER_ERROR;
		pEx->Delete();
	}

	return updateAvailable;
}
コード例 #11
0
  Error parseOne() {
    read();
    switch (Tok.K) {
    case Eof:
      return Error::success();
    case KwExports:
      for (;;) {
        read();
        if (Tok.K != Identifier) {
          unget();
          return Error::success();
        }
        if (Error Err = parseExport())
          return Err;
      }
    case KwHeapsize:
      return parseNumbers(&Info.HeapReserve, &Info.HeapCommit);
    case KwStacksize:
      return parseNumbers(&Info.StackReserve, &Info.StackCommit);
    case KwLibrary:
    case KwName: {
      bool IsDll = Tok.K == KwLibrary; // Check before parseName.
      std::string Name;
      if (Error Err = parseName(&Name, &Info.ImageBase))
        return Err;

      Info.ImportName = Name;

      // Set the output file, but don't override /out if it was already passed.
      if (Info.OutputFile.empty()) {
        Info.OutputFile = Name;
        // Append the appropriate file extension if not already present.
        if (!sys::path::has_extension(Name))
          Info.OutputFile += IsDll ? ".dll" : ".exe";
      }

      return Error::success();
    }
    case KwVersion:
      return parseVersion(&Info.MajorImageVersion, &Info.MinorImageVersion);
    default:
      return createError("unknown directive: " + Tok.Value);
    }
  }
コード例 #12
0
void AssetsManagerEx::onSuccess(const std::string &/*srcUrl*/, const std::string &storagePath, const std::string &customId)
{
    if (customId == VERSION_ID)
    {
        _updateState = State::VERSION_LOADED;
        parseVersion();
    }
    else if (customId == MANIFEST_ID)
    {
        _updateState = State::MANIFEST_LOADED;
        parseManifest();
    }
    else
    {
        bool ok = true;
        auto &assets = _remoteManifest->getAssets();
        auto assetIt = assets.find(customId);
        if (assetIt != assets.end())
        {
            Manifest::Asset asset = assetIt->second;
            if (_verifyCallback != nullptr)
            {
                ok = _verifyCallback(storagePath, asset);
            }
        }
        
        if (ok)
        {
            bool compressed = assetIt != assets.end() ? assetIt->second.compressed : false;
            if (compressed)
            {
                decompressDownloadedZip(customId, storagePath);
            }
            else
            {
                fileSuccess(customId, storagePath);
            }
        }
        else
        {
            fileError(customId, "Asset file verification failed after downloaded");
        }
    }
}
コード例 #13
0
void DefinitionUpdater::checkVersion() {
  // parse reply data for version information
  const QByteArray data(reply->readAll());
  reply->deleteLater();
  QString remoteversion = parseVersion(data);

  // check for newer version
  if (versionCompare(remoteversion,version)>0) {
    version = remoteversion;
    save = new QFile(filename);
    save->open(QIODevice::WriteOnly | QIODevice::Truncate);
    if (save) {
      save->write(data);
      save->flush();
      save->close();
      delete save;
      save = NULL;
    }
  }
}
コード例 #14
0
DWORD WINAPI UpdateVersion (LPVOID param)
{
  try
  {
    CInternetSession inet;
    CInternetFile* file = dynamic_cast<CInternetFile*> (inet.OpenURL (versionURL));
    char buf[256];
    if (file != NULL)
    {
      lastVersion = parseVersion (file->ReadString (buf, 255));
      delete file;
    }
    else
      lastVersion = 0;
  }
  catch (CInternetException*)
  {
  }
  return 0;
}
コード例 #15
0
ファイル: parser.cpp プロジェクト: michael-popov/clockworkdb
//static
Command* Command::parseTokens( Tokens& tokens, bool helpMode )
{
    if (tokens.empty()) THROW( CWDB_ERR_PARSER, "Bad syntax: no tokens to parse");
    Command* result = 0;
    try {
        switch(tokens.front().m_angen) {
            case ANGEN_CREATE:   parseCreate( tokens, helpMode, result ); break;
            case ANGEN_DESCR:    parseDescr( tokens, helpMode, result ); break;
            case ANGEN_DROP:     parseDrop( tokens, helpMode, result ); break;
            case ANGEN_DUMP:     parseDump( tokens, helpMode, result ); break;
            case ANGEN_GET:
            case ANGEN_SET:
            case ANGEN_PUT:      parseInput( tokens, helpMode, result ); break;
            case ANGEN_QUERY:    parseQuery( tokens, helpMode, result ); break;
            case ANGEN_USE:      parseUse( tokens, helpMode, result ); break;
            case ANGEN_GENERATE: parseGenerate( tokens, helpMode, result ); break;
            case ANGEN_VERSION:  parseVersion( tokens, helpMode, result ); break;
            case ANGEN_FORMAT:   parseFormat( tokens, helpMode, result ); break;
            case ANGEN_COMPACT:  parseCompact( tokens, helpMode, result ); break;
            case ANGEN_UPDATE:   parseUpdate( tokens, helpMode, result ); break;
            case ANGEN_START:
            case ANGEN_STOP:     parseStart( tokens, helpMode, result ); break;
            case ANGEN_EXPORT:   parseExport( tokens, helpMode, result ); break;
            case ANGEN_IMPORT:   parseImport( tokens, helpMode, result ); break;
            default: THROW( CWDB_ERR_PARSER, "Bad syntax: unknown command" );
        }
    }
    catch (CWDBException& e) {
        if (result != 0) {
            delete result;
            result = 0;
        }
        throw e;
    }

    return result;
}
コード例 #16
0
void DefinitionUpdater::checkReadyRead() {
  // get all data received at the moment (more may follow)
  const QByteArray data(reply->readAll());

  if (save) {
    // consecutive data received
    // -> append it to current file
    save->write(data);
  } else {
    // no file open -> first data for our request
    // -> parse reply data for version information
    QString remoteversion = parseVersion(data);

    // check for newer version
    if (versionCompare(remoteversion,version)>0) {
      version = remoteversion;
      save = new QFile(filename);
      save->open(QIODevice::WriteOnly | QIODevice::Truncate);
      if (save) {
        save->write(data);
      }
    }
  }
}
コード例 #17
0
bool parse(const String8& str, ConfigDescription* out) {
    Vector<String8> parts = AaptUtil::splitAndLowerCase(str, '-');

    ConfigDescription config;
    AaptLocaleValue locale;
    ssize_t index = 0;
    ssize_t localeIndex = 0;
    const ssize_t N = parts.size();
    const char* part = parts[index].string();

    if (str.length() == 0) {
        goto success;
    }

    if (parseMcc(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseMnc(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    // Locale spans a few '-' separators, so we let it
    // control the index.
    localeIndex = locale.initFromDirName(parts, index);
    if (localeIndex < 0) {
        return false;
    } else if (localeIndex > index) {
        locale.writeTo(&config);
        index = localeIndex;
        if (index >= N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseLayoutDirection(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseSmallestScreenWidthDp(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseScreenWidthDp(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseScreenHeightDp(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseScreenLayoutSize(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseScreenLayoutLong(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseScreenRound(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseOrientation(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseUiModeType(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseUiModeNight(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseDensity(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseTouchscreen(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseKeysHidden(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseKeyboard(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseNavHidden(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseNavigation(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseScreenSize(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    if (parseVersion(part, &config)) {
        index++;
        if (index == N) {
            goto success;
        }
        part = parts[index].string();
    }

    // Unrecognized.
    return false;

success:
    if (out != NULL) {
        applyVersionForCompatibility(&config);
        *out = config;
    }
    return true;
}
コード例 #18
0
ファイル: OpenGL.cpp プロジェクト: MajorBreakfast/cvt
	void GL::init()
	{
		static bool init = false;
		const GLubyte* str;
		if( init )
			return;
		init = true;

		/* version check */
		str = glGetString( GL_VERSION );
		parseVersion( ( const char* ) str, &_glmajor, &_glminor );
		str = glGetString( GL_SHADING_LANGUAGE_VERSION );
		parseVersion( ( const char* ) str, &_glslmajor, &_glslminor );

		if( _glmajor < 2  || ( _glmajor == 2 && _glminor == 0 ) ) {
			std::cerr << "GL Version too old, at least GL 2.1 is needed" << std::endl;
			std::exit( EXIT_FAILURE );
		}

		if( _glslmajor == 1 && _glslminor < 20 ) {
			std::cerr << "GLSL Version too old, at least GLSL 1.20 is needed" << std::endl;
			std::exit( EXIT_FAILURE );
		}

		/* extensions check */
		if( _glmajor > 2 ) {
			int numext;
			glGetIntegerv( GL_NUM_EXTENSIONS, &numext );
			for( int i = 0; i < numext; i++ ) {
				_extensions.push_back( ( const char* ) glGetStringi( GL_EXTENSIONS, i ) );
			}
		} else {
			String cvtstr( ( const char* ) glGetString( GL_EXTENSIONS ) );
			cvtstr.tokenize( _extensions, ' ' );
		}

		if( existsExtension( "GL_ARB_vertex_array_object" ) || ( _glmajor > 2 || ( _glmajor == 2 && _glminor >= 1 ) ) ) {
			glGenVertexArrays = ( void (*)( GLsizei, GLuint* ) ) getProcAddress( "glGenVertexArrays" );
			glDeleteVertexArrays = ( void (*)( GLsizei, const GLuint* ) ) getProcAddress( "glDeleteVertexArrays" );
			glBindVertexArray = ( void (*)( GLuint ) ) getProcAddress( "glBindVertexArray" );
			glIsVertexArray = ( GLboolean (*)( GLuint ) ) getProcAddress( "glIsVertexArray" );
		} else if( existsExtension( "GL_APPLE_vertex_array_object" ) ) {
			glGenVertexArrays = ( void (*)( GLsizei, GLuint* ) ) getProcAddress( "glGenVertexArraysAPPLE" );
			glDeleteVertexArrays = ( void (*)( GLsizei, const GLuint* ) ) getProcAddress( "glDeleteVertexArraysAPPLE" );
			glBindVertexArray = ( void (*)( GLuint ) ) getProcAddress( "glBindVertexArrayAPPLE" );
			glIsVertexArray = ( GLboolean (*)( GLuint ) ) getProcAddress( "glIsVertexArrayAPPLE" );
		} else {
			std::cerr << "GL vertex array object extension missing" << std::endl;
			std::exit( EXIT_FAILURE );
		}

		if( !existsExtension( "GL_ARB_texture_non_power_of_two" ) && _glmajor <= 2 ) {
			std::cerr << "GL texture non power of two extension missing" << std::endl;
			std::exit( EXIT_FAILURE );
		}

		if( existsExtension( "GL_EXT_framebuffer_object" ) || existsExtension( "GL_ARB_framebuffer_object" ) || _glmajor > 2 ) {
			glBindRenderbuffer = ( void (*)( GLenum target, GLuint renderbuffer) ) getProcAddress( "glBindRenderbuffer" );
			glDeleteRenderbuffers = ( void (*)( GLsizei n, const GLuint *renderbuffers) ) getProcAddress( "glDeleteRenderbuffers" );
			glGenRenderbuffers = ( void (*)( GLsizei n, GLuint *renderbuffers) ) getProcAddress( "glGenRenderbuffers" );
			glRenderbufferStorage = ( void (*)( GLenum target, GLenum internalformat, GLsizei width, GLsizei height) ) getProcAddress( "glRenderbufferStorage" );

			glBindFramebuffer = ( void (*)( GLenum target, GLuint framebuffer ) ) getProcAddress( "glBindFramebuffer" );
			glDeleteFramebuffers = ( void (*)( GLsizei n, const GLuint *framebuffers ) ) getProcAddress( "glDeleteFramebuffers" );
			glGenFramebuffers = ( void (*)( GLsizei n, GLuint *framebuffers ) ) getProcAddress( "glGenFramebuffers" );

			glFramebufferTexture1D = ( void (*)( GLenum target,  GLenum attachment,  GLenum textarget, GLuint texture, GLint level ) ) getProcAddress( "glFramebufferTexture1D" );
			glFramebufferTexture2D = ( void (*)( GLenum target,  GLenum attachment,  GLenum textarget, GLuint texture, GLint level ) ) getProcAddress( "glFramebufferTexture2D" );
			glFramebufferTexture3D = ( void (*)( GLenum target,  GLenum attachment,  GLenum textarget, GLuint texture, GLint level, GLint zoffset ) ) getProcAddress( "glFramebufferTexture3D" );

			glFramebufferRenderbuffer = ( void (*)( GLenum target,  GLenum attachment,  GLenum renderbuffertarget, GLuint renderbuffer) ) getProcAddress( "glFramebufferRenderbuffer" );
		} else {
			std::cerr << "GL framebuffer extension missing" << std::endl;
			std::exit( EXIT_FAILURE );
		}

	}
コード例 #19
0
ファイル: Version.cpp プロジェクト: Pigaco/Console
Version::Version(const std::string &stringRepresentation)
{
    parseVersion(stringRepresentation, m_major, m_minor, m_mini, m_build);
}
コード例 #20
0
ファイル: updater.cpp プロジェクト: 0312birdzhang/taot
void Updater::onNetworkReply(QNetworkReply *reply)
{
    if (reply != m_reply) {
        // Reply not for the latest request. Ignore it.
        reply->deleteLater();
        setBusy(false);
        return;
    }
    m_reply = NULL;

    if (reply->error() == QNetworkReply::OperationCanceledError) {
        // Operation was canceled by us, ignore this error.
        reply->deleteLater();
        setBusy(false);
        return;
    }

    if (reply->error() != QNetworkReply::NoError) {
        qWarning() << reply->errorString();
        emit error(reply->errorString());
        reply->deleteLater();
        setBusy(false);
        return;
    }

    const QVariantList releases = parseJson(reply->readAll());
    reply->deleteLater();
    if (releases.isEmpty()) {
        setBusy(false);
        return;
    }

    int k = 0;
    QVariantMap release = releases.at(0).toMap();
    while (release.value("prerelease").toBool()
           || release.value("draft").toBool()
           || (release.value("tag_name").toString().contains("-")
               && !release.value("tag_name").toString().endsWith("-" + m_variant))) {
        release = releases.at(++k).toMap();
    }

    const QString name = release.value("tag_name").toString();
    const QString title = release.value("name").toString();
    const QString changeLog = release.value("body").toString();

    const int version = parseVersion(name);
    if (version < 0) {
        emit error(tr("Couldn't parse release version"));
        setBusy(false);
        return;
    }

    m_numericLatestVersion = parseVersion(name);
    if (m_latestRelease)
        delete m_latestRelease;
    m_latestRelease = new Release(name, title, changeLog, this);
    emit latestReleaseChanged();

    if (!m_latestReleaseValid) {
        m_latestReleaseValid = true;
        emit latestReleaseValidChanged();
    }

    setUpdateAvailable(m_numericCurrentVersion < m_numericLatestVersion);
    setBusy(false);
}
コード例 #21
0
Application::Application(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MPQInit();
    instance = this;
    resources = NULL;
    imageLibrary = NULL;
    dotaLibrary = NULL;
    mainWindow = NULL;
    cache = NULL;
    hInstance = _hInstance;
    _loaded = false;

    root = String::getPath(getAppPath());
    cfg.read();

    warLoader = new MPQLoader("Custom_V1");
    warLoader->loadArchive(String::buildFullName(cfg.warPath, "war3.mpq"));
    warLoader->loadArchive(String::buildFullName(cfg.warPath, "war3x.mpq"));
    warLoader->loadArchive(String::buildFullName(cfg.warPath, "war3xlocal.mpq"));
    warLoader->loadArchive(String::buildFullName(cfg.warPath, "war3patch.mpq"));

    if (logCommand(lpCmdLine))
        return;

    ScriptType::initTypes();
    UpdateDialog::init(hInstance);

    INITCOMMONCONTROLSEX iccex;
    iccex.dwSize = sizeof iccex;
    iccex.dwICC = ICC_STANDARD_CLASSES | ICC_PROGRESS_CLASS |
                  ICC_BAR_CLASSES | ICC_TREEVIEW_CLASSES | ICC_LISTVIEW_CLASSES |
                  ICC_TAB_CLASSES | ICC_UPDOWN_CLASS | ICC_DATE_CLASSES;
    InitCommonControlsEx(&iccex);
    LoadLibrary("Riched20.dll");
    OleInitialize(NULL);

    String path = String::getPath(getAppPath());
    String resPath = String::buildFullName(path, "resources.mpq");
    String patchPath = String::buildFullName(path, "install.mpq");
    File* tOpen = File::open(resPath, File::READ);
    if (tOpen == NULL)
    {
        tOpen = File::open(patchPath, File::READ);
        if (tOpen)
        {
            delete tOpen;
            MoveFile(patchPath, resPath);
        }
    }
    else
        delete tOpen;
    resources = MPQArchive::open(resPath);
    MPQArchive* patch = MPQArchive::open(patchPath, File::READ);
    if (patch)
    {
        for (uint32 i = 0; i < patch->getHashSize(); i++)
        {
            char const* name = patch->getFileName(i);
            if (name)
            {
                MPQFile* source = patch->openFile(i, File::READ);
                if (source)
                {
                    MPQFile* dest = resources->openFile(name, File::REWRITE);
                    if (dest)
                    {
                        static uint8 buf[1024];
                        while (int length = source->read(buf, sizeof buf))
                            dest->write(buf, length);
                        delete dest;
                    }
                    delete source;
                }
            }
        }
        delete patch;
        DeleteFile(patchPath);
    }

    imageLibrary = new ImageLibrary(resources);

    cache = new CacheManager();
    dotaLibrary = new DotaLibrary();

#if 0
    File* dlog = File::open("diff.txt", File::REWRITE);
    for (int pt = 0; pt < 120; pt++)
    {
        String prev = "";
        bool different = false;
        for (int ver = 1; ver <= 80 && !different; ver++)
        {
            Dota* dota = dotaLibrary->getDota(makeVersion(6, ver));
            if (dota)
            {
                Dota::Hero* hero = dota->getHero(pt);
                if (hero)
                {
                    if (prev == "")
                        prev = hero->name;
                    else if (prev.icompare(hero->name))
                        different = true;
                }
            }
        }
        if (different)
        {
            dlog->printf("  Pt=%d\r\n", pt);
            prev = "";
            for (int ver = 1; ver <= 80; ver++)
            {
                Dota* dota = dotaLibrary->getDota(makeVersion(6, ver));
                if (dota)
                {
                    Dota::Hero* hero = dota->getHero(pt);
                    if (hero)
                    {
                        if (prev.icompare(hero->name))
                        {
                            dlog->printf("6.%02d = %s\r\n", ver, hero->name);
                            prev = hero->name;
                        }
                    }
                }
            }
        }
    }
    delete dlog;
#endif
#if 0
    dotaLibrary->getDota(parseVersion("6.79e"),
                         "K:\\Progs\\DotAReplay\\maps\\DotA v6.79e.w3x");
    WIN32_FIND_DATA data;
    String enumPath = "K:\\Progs\\DotAReplay\\maps";
    HANDLE hFind = FindFirstFile(String::buildFullName(enumPath, "*"), &data);
    BOOL success = (hFind != INVALID_HANDLE_VALUE);
    while (success)
    {
        String file(data.cFileName);
        if (String::getExtension(file).icompare(".w3x") == 0)
        {
            file.toLower();
            Array<String> sub;
            if (file.rfind("dota{{_| }allstars}?{_| }v(\\d)\\.(\\d\\d)([b-z]?)[^b-z]", 0, &sub) >= 0)
            {
                int major = sub[1].toInt();
                int minor = sub[2].toInt();
                int build = 0;
                if (!sub[3].isEmpty())
                    build = int(sub[3][0] - 'a');
                uint32 version = makeVersion(major, minor, build);

                dotaLibrary->getDota(version, String::buildFullName(enumPath, file));
            }
        }
        success = FindNextFile(hFind, &data);
    }
    FindClose(hFind);
#endif

    mainWindow = new MainWnd();

    mainWindow->postLoad();
    _loaded = true;

    if (lpCmdLine[0])
    {
        COPYDATASTRUCT cd;
        cd.dwData = MAINWND_OPEN_REPLAY;
        cd.cbData = strlen(lpCmdLine) + 1;
        cd.lpData = lpCmdLine;
        PostMessage(getMainWindow(), WM_COPYDATA_FAKE, NULL, (LPARAM) &cd);
    }
}
コード例 #22
0
ファイル: qqmldirparser.cpp プロジェクト: 2gis/2gisqt5android
/*!
\a url is used for generating errors.
*/
bool QQmlDirParser::parse(const QString &source)
{
    _errors.clear();
    _plugins.clear();
    _components.clear();
    _scripts.clear();
    _designerSupported = false;

    quint16 lineNumber = 0;
    bool firstLine = true;

    const QChar *ch = source.constData();
    while (!ch->isNull()) {
        ++lineNumber;

        bool invalidLine = false;
        const QChar *lineStart = ch;

        scanSpace(ch);
        if (*ch == QLatin1Char('\n')) {
            ++ch;
            continue;
        }
        if (ch->isNull())
            break;

        QString sections[4];
        int sectionCount = 0;

        do {
            if (*ch == QLatin1Char('#')) {
                scanToEnd(ch);
                break;
            }
            const QChar *start = ch;
            scanWord(ch);
            if (sectionCount < 4) {
                sections[sectionCount++] = source.mid(start-source.constData(), ch-start);
            } else {
                reportError(lineNumber, start-lineStart, QLatin1String("unexpected token"));
                scanToEnd(ch);
                invalidLine = true;
                break;
            }
            scanSpace(ch);
        } while (*ch != QLatin1Char('\n') && !ch->isNull());

        if (!ch->isNull())
            ++ch;

        if (invalidLine) {
            reportError(lineNumber, 0,
                        QStringLiteral("invalid qmldir directive contains too many tokens"));
            continue;
        } else if (sectionCount == 0) {
            continue; // no sections, no party.

        } else if (sections[0] == QLatin1String("module")) {
            if (sectionCount != 2) {
                reportError(lineNumber, 0,
                            QStringLiteral("module identifier directive requires one argument, but %1 were provided").arg(sectionCount - 1));
                continue;
            }
            if (!_typeNamespace.isEmpty()) {
                reportError(lineNumber, 0,
                            QStringLiteral("only one module identifier directive may be defined in a qmldir file"));
                continue;
            }
            if (!firstLine) {
                reportError(lineNumber, 0,
                            QStringLiteral("module identifier directive must be the first directive in a qmldir file"));
                continue;
            }

            _typeNamespace = sections[1];

        } else if (sections[0] == QLatin1String("plugin")) {
            if (sectionCount < 2 || sectionCount > 3) {
                reportError(lineNumber, 0,
                            QStringLiteral("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1));

                continue;
            }

            const Plugin entry(sections[1], sections[2]);

            _plugins.append(entry);

        } else if (sections[0] == QLatin1String("internal")) {
            if (sectionCount != 3) {
                reportError(lineNumber, 0,
                            QStringLiteral("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1));
                continue;
            }
            Component entry(sections[1], sections[2], -1, -1);
            entry.internal = true;
            _components.insertMulti(entry.typeName, entry);
        } else if (sections[0] == QLatin1String("singleton")) {
            if (sectionCount < 3 || sectionCount > 4) {
                reportError(lineNumber, 0,
                            QStringLiteral("singleton types require 2 or 3 arguments, but %1 were provided").arg(sectionCount - 1));
                continue;
            } else if (sectionCount == 3) {
                // handle qmldir directory listing case where singleton is defined in the following pattern:
                // singleton TestSingletonType TestSingletonType.qml
                Component entry(sections[1], sections[2], -1, -1);
                entry.singleton = true;
                _components.insertMulti(entry.typeName, entry);
            } else {
                // handle qmldir module listing case where singleton is defined in the following pattern:
                // singleton TestSingletonType 2.0 TestSingletonType20.qml
                int major, minor;
                if (parseVersion(sections[2], &major, &minor)) {
                    const QString &fileName = sections[3];
                    Component entry(sections[1], fileName, major, minor);
                    entry.singleton = true;
                    _components.insertMulti(entry.typeName, entry);
                } else {
                    reportError(lineNumber, 0, QStringLiteral("invalid version %1, expected <major>.<minor>").arg(sections[2]));
                }
            }
        } else if (sections[0] == QLatin1String("typeinfo")) {
            if (sectionCount != 2) {
                reportError(lineNumber, 0,
                            QStringLiteral("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1));
                continue;
            }
#ifdef QT_CREATOR
            TypeInfo typeInfo(sections[1]);
            _typeInfos.append(typeInfo);
#endif

        } else if (sections[0] == QLatin1String("designersupported")) {
            if (sectionCount != 1)
                reportError(lineNumber, 0, QStringLiteral("designersupported does not expect any argument"));
            else
                _designerSupported = true;
        } else if (sections[0] == QLatin1String("depends")) {
            if (sectionCount != 3) {
                reportError(lineNumber, 0,
                            QStringLiteral("depends requires 2 arguments, but %1 were provided").arg(sectionCount - 1));
                continue;
            }

            int major, minor;
            if (parseVersion(sections[2], &major, &minor)) {
                Component entry(sections[1], QString(), major, minor);
                entry.internal = true;
                _dependencies.insert(entry.typeName, entry);
            } else {
                reportError(lineNumber, 0, QStringLiteral("invalid version %1, expected <major>.<minor>").arg(sections[2]));
            }
        } else if (sectionCount == 2) {
            // No version specified (should only be used for relative qmldir files)
            const Component entry(sections[0], sections[1], -1, -1);
            _components.insertMulti(entry.typeName, entry);
        } else if (sectionCount == 3) {
            int major, minor;
            if (parseVersion(sections[1], &major, &minor)) {
                const QString &fileName = sections[2];

                if (fileName.endsWith(QLatin1String(".js"))) {
                    // A 'js' extension indicates a namespaced script import
                    const Script entry(sections[0], fileName, major, minor);
                    _scripts.append(entry);
                } else {
                    const Component entry(sections[0], fileName, major, minor);
                    _components.insertMulti(entry.typeName, entry);
                }
            } else {
                reportError(lineNumber, 0, QStringLiteral("invalid version %1, expected <major>.<minor>").arg(sections[1]));
            }
        } else {
            reportError(lineNumber, 0,
                        QStringLiteral("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount));
        }

        firstLine = false;
    }

    return hasError();
}
コード例 #23
0
void DirectiveParser::parseDirective(Token *token)
{
    assert(token->type == Token::PP_HASH);

    mTokenizer->lex(token);
    if (isEOD(token))
    {
        // Empty Directive.
        return;
    }

    DirectiveType directive = getDirective(token);

    // While in an excluded conditional block/group,
    // we only parse conditional directives.
    if (skipping() && !isConditionalDirective(directive))
    {
        skipUntilEOD(mTokenizer, token);
        return;
    }

    switch(directive)
    {
      case DIRECTIVE_NONE:
        mDiagnostics->report(Diagnostics::PP_DIRECTIVE_INVALID_NAME,
                             token->location, token->text);
        skipUntilEOD(mTokenizer, token);
        break;
      case DIRECTIVE_DEFINE:
        parseDefine(token);
        break;
      case DIRECTIVE_UNDEF:
        parseUndef(token);
        break;
      case DIRECTIVE_IF:
        parseIf(token);
        break;
      case DIRECTIVE_IFDEF:
        parseIfdef(token);
        break;
      case DIRECTIVE_IFNDEF:
        parseIfndef(token);
        break;
      case DIRECTIVE_ELSE:
        parseElse(token);
        break;
      case DIRECTIVE_ELIF:
        parseElif(token);
        break;
      case DIRECTIVE_ENDIF:
        parseEndif(token);
        break;
      case DIRECTIVE_ERROR:
        parseError(token);
        break;
      case DIRECTIVE_PRAGMA:
        parsePragma(token);
        break;
      case DIRECTIVE_EXTENSION:
        parseExtension(token);
        break;
      case DIRECTIVE_VERSION:
        parseVersion(token);
        break;
      case DIRECTIVE_LINE:
        parseLine(token);
        break;
      default:
        assert(false);
        break;
    }

    skipUntilEOD(mTokenizer, token);
    if (token->type == Token::LAST)
    {
        mDiagnostics->report(Diagnostics::PP_EOF_IN_DIRECTIVE,
                             token->location, token->text);
    }
}
コード例 #24
0
void AssetsManagerEx::update()
{
    if (_updateEntry != UpdateEntry::NONE)
    {
        CCLOGERROR("AssetsManagerEx::update, updateEntry isn't NONE");
        return;
    }

    if (!_inited){
        CCLOG("AssetsManagerEx : Manifests uninited.\n");
        dispatchUpdateEvent(EventAssetsManagerEx::EventCode::ERROR_NO_LOCAL_MANIFEST);
        return;
    }
    if (!_localManifest->isLoaded())
    {
        CCLOG("AssetsManagerEx : No local manifest file found error.\n");
        dispatchUpdateEvent(EventAssetsManagerEx::EventCode::ERROR_NO_LOCAL_MANIFEST);
        return;
    }

    _updateEntry = UpdateEntry::DO_UPDATE;

    switch (_updateState) {
        case State::UNCHECKED:
        {
            _updateState = State::PREDOWNLOAD_VERSION;
        }
        case State::PREDOWNLOAD_VERSION:
        {
            downloadVersion();
        }
            break;
        case State::VERSION_LOADED:
        {
            parseVersion();
        }
            break;
        case State::PREDOWNLOAD_MANIFEST:
        {
            downloadManifest();
        }
            break;
        case State::MANIFEST_LOADED:
        {
            parseManifest();
        }
            break;
        case State::FAIL_TO_UPDATE:
        case State::NEED_UPDATE:
        {
            // Manifest not loaded yet
            if (!_remoteManifest->isLoaded())
            {
                _updateState = State::PREDOWNLOAD_MANIFEST;
                downloadManifest();
            }
            else
            {
                startUpdate();
            }
        }
            break;
        case State::UP_TO_DATE:
        case State::UPDATING:
        case State::UNZIPPING:
            _updateEntry = UpdateEntry::NONE;
            break;
        default:
            break;
    }
}
コード例 #25
0
ファイル: ifofile.cpp プロジェクト: jbowtie/xoreos
void IFOFile::load() {
	unload();

	_gff = new GFF3File("module", kFileTypeIFO, MKTAG('I', 'F', 'O', ' '));

	const GFF3Struct &ifoTop = _gff->getTopLevel();

	// IFO version
	_version   = ifoTop.getUint("Mod_Version");
	_creatorID = ifoTop.getUint("Mod_Creator_ID");

	// Game version
	Common::UString version = ifoTop.getString("Mod_MinGameVer");
	parseVersion(version);

	// Expansions
	_expansions = ifoTop.getUint("Expansion_Pack");

	// Is Save?
	_isSave = ifoTop.getUint("Mod_IsSaveGame") == 1;

	// Tag
	_tag = ifoTop.getString("Mod_Tag");

	// Name and description
	ifoTop.getLocString("Mod_Name"       , _name);
	ifoTop.getLocString("Mod_Description", _description);

	// ID
	size_t idSize = _isSave ? 32 : 16;
	Common::SeekableReadStream *id = ifoTop.getData("Mod_ID");
	if (id && (id->read(_id, idSize) != idSize))
		throw Common::Exception("Can't read MOD ID");
	delete id;

	// TLK
	_customTLK = ifoTop.getString("Mod_CustomTlk");

	// Starting movie
	_startMovie = ifoTop.getString("Mod_StartMovie");

	// HAK List
	if (ifoTop.hasField("Mod_HakList")) {
		const GFF3List &haks = ifoTop.getList("Mod_HakList");

		for (GFF3List::const_iterator h = haks.begin(); h != haks.end(); ++h)
			_haks.insert(_haks.begin(), (*h)->getString("Mod_Hak"));
	}

	// Singular HAK
	Common::UString hak = ifoTop.getString("Mod_Hak");
	if (!hak.empty())
		_haks.insert(_haks.begin(), hak);

	// Areas
	if (ifoTop.hasField("Mod_Area_list")) {
		const GFF3List &areas = ifoTop.getList("Mod_Area_list");

		for (GFF3List::const_iterator a = areas.begin(); a != areas.end(); ++a)
			_areas.push_back((*a)->getString("Area_Name"));
	}

	std::sort(_areas.begin(), _areas.end(), Common::UString::iless());

	// NSS files that should be cached
	if (ifoTop.hasField("Mod_CacheNSSList")) {
		const GFF3List &nss = ifoTop.getList("Mod_CacheNSSList");

		for (GFF3List::const_iterator n = nss.begin(); n != nss.end(); ++n)
			_nssCache.push_back((*n)->getString("ResRef"));
	}

	// Quests
	if (ifoTop.hasField("Quest_list")) {
		const GFF3List &quests = ifoTop.getList("Quest_list");

		for (GFF3List::const_iterator q = quests.begin(); q != quests.end(); ++q)
			_quests.push_back((*q)->getString("Quest"));
	}
	if (ifoTop.hasField("QuestBase_list")) {
		const GFF3List &quests = ifoTop.getList("QuestBase_list");

		for (GFF3List::const_iterator q = quests.begin(); q != quests.end(); ++q)
			_questDBs.push_back((*q)->getString("QuestBase"));
	}

	// NPCs
	if (ifoTop.hasField("StoryNPC_list")) {
		const GFF3List &npcs = ifoTop.getList("StoryNPC_list");

		for (GFF3List::const_iterator n = npcs.begin(); n != npcs.end(); ++n)
			_storyNPCs.push_back((*n)->getString("StoryNPC"));
	}
	if (ifoTop.hasField("MonsterNPC_list")) {
		const GFF3List &npcs = ifoTop.getList("MonsterNPC_list");

		for (GFF3List::const_iterator n = npcs.begin(); n != npcs.end(); ++n)
			_monsterNPCs.push_back((*n)->getString("MonsterNPC"));
	}

	// Entry
	_entryArea = ifoTop.getString("Mod_Entry_Area");
	_entryX    = ifoTop.getDouble("Mod_Entry_X");
	_entryY    = ifoTop.getDouble("Mod_Entry_Y");
	_entryZ    = ifoTop.getDouble("Mod_Entry_Z");
	_entryDirX = ifoTop.getDouble("Mod_Entry_Dir_X");
	_entryDirY = ifoTop.getDouble("Mod_Entry_Dir_Y");

	// Time settings
	_hourDawn       = ifoTop.getUint("Mod_DawnHour"  , 0);
	_hourDusk       = ifoTop.getUint("Mod_DuskHour"  , 0);
	_minutesPerHour = ifoTop.getUint("Mod_MinPerHour", 1);
	_startHour      = ifoTop.getUint("Mod_StartHour" , 0);
	_startDay       = ifoTop.getUint("Mod_StartDay"  , 1);
	_startMonth     = ifoTop.getUint("Mod_StartMonth", 1);
	_startYear      = ifoTop.getUint("Mod_StartYear" , 0);

	// Weather
	_minWeatherIntensity = ifoTop.getSint("Mod_MinWeatInt",   0);
	_maxWeatherIntensity = ifoTop.getSint("Mod_MaxWeatInt", 100);
	_rainChance          = ifoTop.getSint("Mod_RainChance",   0);
	_snowChance          = ifoTop.getSint("Mod_SnowChance",   0);

	// XP Scale
	_xpScale = ifoTop.getUint("Mod_XPScale", 100) / 100.0f;
}
void AssetsManager::onSuccess(const std::string &srcUrl, const std::string &storagePath, const std::string &customId)
{
    if (customId == VERSION_ID)
    {
        _updateState = State::VERSION_LOADED;
        parseVersion();
    }
    else if (customId == MANIFEST_ID)
    {
        _updateState = State::MANIFEST_LOADED;
        parseManifest();
    }
    else if (customId == BATCH_UPDATE_ID)
    {
        // Finished with error check
        if (_failedUnits.size() > 0 || _totalWaitToDownload > 0)
        {
            // Save current download manifest information for resuming
            _tempManifest->saveToFile(_tempManifestPath);
            
            decompressDownloadedZip();
            
            _updateState = State::FAIL_TO_UPDATE;
            dispatchUpdateEvent(EventAssetsManager::EventCode::UPDATE_FAILED);
        }
        else
        {
            updateSucceed();
        }
    }
    else
    {
        auto assets = _remoteManifest->getAssets();
        auto assetIt = assets.find(customId);
        if (assetIt != assets.end())
        {
            // Set download state to SUCCESSED
            _tempManifest->setAssetDownloadState(customId, Manifest::DownloadState::SUCCESSED);
            
            // Add file to need decompress list
            if (assetIt->second.compressed) {
                _compressedFiles.push_back(storagePath);
            }
        }
        
        auto unitIt = _downloadUnits.find(customId);
        if (unitIt != _downloadUnits.end())
        {
            // Reduce count only when unit found in _downloadUnits
            _totalWaitToDownload--;
            
            _percentByFile = 100 * (float)(_totalToDownload - _totalWaitToDownload) / _totalToDownload;
            // Notify progression event
            dispatchUpdateEvent(EventAssetsManager::EventCode::UPDATE_PROGRESSION, "");
        }
        // Notify asset updated event
        dispatchUpdateEvent(EventAssetsManager::EventCode::ASSET_UPDATED, customId);
        
        unitIt = _failedUnits.find(customId);
        // Found unit and delete it
        if (unitIt != _failedUnits.end())
        {
            // Remove from failed units list
            _failedUnits.erase(unitIt);
        }
    }
}
コード例 #27
0
ファイル: read114.cpp プロジェクト: DannyBehar/MuseScore
Score::FileError Score::read114(XmlReader& e)
      {
      if (parentScore())
            setMscVersion(parentScore()->mscVersion());

      for (unsigned int i = 0; i < sizeof(style114)/sizeof(*style114); ++i)
            style()->set(style114[i].idx, style114[i].val);

      // old text style defaults
      TextStyle ts = style()->textStyle("Chord Symbol");
      ts.setYoff(-4.0);
      style()->setTextStyle(ts);
      TempoMap tm;
      while (e.readNextStartElement()) {
            e.setTrack(-1);
            const QStringRef& tag(e.name());
            if (tag == "Staff")
                  readStaff(e);
            else if (tag == "KeySig") {               // not supported
                  KeySig* ks = new KeySig(this);
                  ks->read(e);
                  // customKeysigs.append(ks);
                  delete ks;
                  }
            else if (tag == "siglist")
                  _sigmap->read(e, _fileDivision);
            else if (tag == "programVersion") {
                  _mscoreVersion = e.readElementText();
                  parseVersion(_mscoreVersion);
                  }
            else if (tag == "programRevision")
                  _mscoreRevision = e.readInt();
            else if (tag == "Mag"
               || tag == "MagIdx"
               || tag == "xoff"
               || tag == "Symbols"
               || tag == "cursorTrack"
               || tag == "yoff")
                  e.skipCurrentElement();       // obsolete
            else if (tag == "tempolist") {
                  // store the tempo list to create invisible tempo text later
                  qreal tempo = e.attribute("fix","2.0").toDouble();
                  tm.setRelTempo(tempo);
                  while (e.readNextStartElement()) {
                        if (e.name() == "tempo") {
                              int tick = e.attribute("tick").toInt();
                              double tmp = e.readElementText().toDouble();
                              tick = (tick * MScore::division + _fileDivision/2) / _fileDivision;
                              auto pos = tm.find(tick);
                              if (pos != tm.end())
                                    tm.erase(pos);
                              tm.setTempo(tick, tmp);
                        }
                        else if (e.name() == "relTempo")
                              e.readElementText();
                        else
                              e.unknown();
                  }
            }
            else if (tag == "playMode")
                  _playMode = PlayMode(e.readInt());
            else if (tag == "SyntiSettings")
                  _synthesizerState.read(e);
            else if (tag == "Spatium")
                  _style.setSpatium (e.readDouble() * MScore::DPMM);
            else if (tag == "Division")
                  _fileDivision = e.readInt();
            else if (tag == "showInvisible")
                  _showInvisible = e.readInt();
            else if (tag == "showFrames")
                  _showFrames = e.readInt();
            else if (tag == "showMargins")
                  _showPageborders = e.readInt();
            else if (tag == "Style") {
                  qreal sp = _style.spatium();
                  _style.load(e);
                  // adjust this now so chords render properly on read
                  // other style adjustments can wait until reading is finished
                  if (style(StyleIdx::useGermanNoteNames).toBool())
                        style()->set(StyleIdx::useStandardNoteNames, false);
                  if (_layoutMode == LayoutMode::FLOAT) {
                        // style should not change spatium in
                        // float mode
                        _style.setSpatium(sp);
                        }
                  }
            else if (tag == "TextStyle") {
                  TextStyle s;
                  s.read(e);

                  qreal spMM = _style.spatium() / MScore::DPMM;
                  if (s.frameWidthMM() != 0.0)
                        s.setFrameWidth(Spatium(s.frameWidthMM() / spMM));
                  if (s.paddingWidthMM() != 0.0)
                        s.setPaddingWidth(Spatium(s.paddingWidthMM() / spMM));
\
                  // convert 1.2 text styles
                  s.setName(convertOldTextStyleNames(s.name()));

                  if (s.name() == "Lyrics Odd Lines" || s.name() == "Lyrics Even Lines")
                        s.setAlign((s.align() & ~ Align(AlignmentFlags::VMASK)) | AlignmentFlags::BASELINE);

                  _style.setTextStyle(s);
                  }
            else if (tag == "page-layout") {
                  if (_layoutMode != LayoutMode::FLOAT && _layoutMode != LayoutMode::SYSTEM) {
                        PageFormat pf;
                        pf.copy(*pageFormat());
                        pf.read(e, this);
                        setPageFormat(pf);
                        }
                  else
                        e.skipCurrentElement();
                  }
            else if (tag == "copyright" || tag == "rights") {
                  Text* text = new Text(this);
                  text->read(e);
                  text->layout();
                  setMetaTag("copyright", text->plainText());
                  delete text;
                  }
            else if (tag == "movement-number")
                  setMetaTag("movementNumber", e.readElementText());
            else if (tag == "movement-title")
                  setMetaTag("movementTitle", e.readElementText());
            else if (tag == "work-number")
                  setMetaTag("workNumber", e.readElementText());
            else if (tag == "work-title")
                  setMetaTag("workTitle", e.readElementText());
            else if (tag == "source")
                  setMetaTag("source", e.readElementText());
            else if (tag == "metaTag") {
                  QString name = e.attribute("name");
                  setMetaTag(name, e.readElementText());
                  }
            else if (tag == "Part") {
                  Part* part = new Part(this);
                  part->read114(e);
                  _parts.push_back(part);
                  }
            else if (tag == "Slur") {
                  Slur* slur = new Slur(this);
                  slur->read(e);
                  addSpanner(slur);
                  }
            else if ((tag == "HairPin")
                || (tag == "Ottava")
                || (tag == "TextLine")
                || (tag == "Volta")
                || (tag == "Trill")
                || (tag == "Pedal")) {
                  Spanner* s = static_cast<Spanner*>(Element::name2Element(tag, this));
                  s->read(e);
                  if (s->track() == -1)
                        s->setTrack(e.track());
                  else
                        e.setTrack(s->track());       // update current track
                  if (s->tick() == -1)
                        s->setTick(e.tick());
                  else
                        e.initTick(s->tick());      // update current tick
                  if (s->track2() == -1)
                        s->setTrack2(s->track());
                  if (s->ticks() == 0) {
                        delete s;
                        qDebug("zero spanner %s ticks: %d", s->name(), s->ticks());
                        }
                  else {
                        addSpanner(s);
                        }
                  }
            else if (tag == "Excerpt") {
                  if (MScore::noExcerpts)
                        e.skipCurrentElement();
                  else {
                        Excerpt* ex = new Excerpt(this);
                        ex->read(e);
                        _excerpts.append(ex);
                        }
                  }
            else if (tag == "Beam") {
                  Beam* beam = new Beam(this);
                  beam->read(e);
                  beam->setParent(0);
                  // _beams.append(beam);
                  }
            else if (tag == "name")
                  setName(e.readElementText());
            else
                  e.unknown();
            }

      if (e.error() != XmlStreamReader::NoError)
            return FileError::FILE_BAD_FORMAT;

      int n = nstaves();
      for (int idx = 0; idx < n; ++idx) {
            Staff* s = _staves[idx];
            int track = idx * VOICES;

            // check barLineSpan
            if (s->barLineSpan() > (n - idx)) {
                  qDebug("read114: invalid bar line span %d (max %d)",
                     s->barLineSpan(), n - idx);
                  s->setBarLineSpan(n - idx);
                  }
            for (auto i : e.clefs(idx)) {
                  int tick = i.first;
                  ClefType clefId = i.second;
                  Measure* m = tick2measure(tick);
                  if (!m)
                        continue;
                  if ((tick == m->tick()) && m->prevMeasure())
                        m = m->prevMeasure();
                  Segment* seg = m->getSegment(Segment::Type::Clef, tick);
                  if (seg->element(track))
                        static_cast<Clef*>(seg->element(track))->setGenerated(false);
                  else {
                        Clef* clef = new Clef(this);
                        clef->setClefType(clefId);
                        clef->setTrack(track);
                        clef->setParent(seg);
                        clef->setGenerated(false);
                        seg->add(clef);
                        }
                  }

            // create missing KeySig
            KeyList* km = s->keyList();
            for (auto i = km->begin(); i != km->end(); ++i) {
                  int tick = i->first;
                  if (tick < 0) {
                        qDebug("read114: Key tick %d", tick);
                        continue;
                        }
                  if (tick == 0 && i->second.key() == Key::C)
                        continue;
                  Measure* m = tick2measure(tick);
                  if (!m)           //empty score
                        break;
                  Segment* seg = m->getSegment(Segment::Type::KeySig, tick);
                  if (seg->element(track))
                        static_cast<KeySig*>(seg->element(track))->setGenerated(false);
                  else {
                        KeySigEvent ke = i->second;
                        KeySig* ks = new KeySig(this);
                        ks->setKeySigEvent(ke);
                        ks->setParent(seg);
                        ks->setTrack(track);
                        ks->setGenerated(false);
                        seg->add(ks);
                        }
                  }
            }

      for (std::pair<int,Spanner*> p : spanner()) {
            Spanner* s = p.second;
            if (s->type() != Element::Type::SLUR) {
                  if (s->type() == Element::Type::VOLTA) {
                        Volta* volta = static_cast<Volta*>(s);
                        volta->setAnchor(Spanner::Anchor::MEASURE);
                        }
                  }

            if (s->type() == Element::Type::OTTAVA
                || s->type() == Element::Type::PEDAL
                || s->type() == Element::Type::TRILL
                || s->type() == Element::Type::TEXTLINE) {
                  qreal yo = 0;
                  if (s->type() == Element::Type::OTTAVA) {
                      // fix ottava position
                      yo = styleS(StyleIdx::ottavaY).val() * spatium();
                      if (s->placement() == Element::Placement::BELOW)
                            yo = -yo + s->staff()->height();
                      }
                  else if (s->type() == Element::Type::PEDAL) {
                        yo = styleS(StyleIdx::pedalY).val() * spatium();
                        }
                  else if (s->type() == Element::Type::TRILL) {
                        yo = styleS(StyleIdx::trillY).val() * spatium();
                        }
                  else if (s->type() == Element::Type::TEXTLINE) {
                        yo = -5.0 * spatium();
                  }
                  if (!s->spannerSegments().isEmpty()) {
                        for (SpannerSegment* seg : s->spannerSegments()) {
                              if (!seg->userOff().isNull())
                                    seg->setUserYoffset(seg->userOff().y() - yo);
                              }
                        }
                  else {
                        s->setUserYoffset(-yo);
                        }
                  }
            }

      connectTies();

      //
      // remove "middle beam" flags from first ChordRest in
      // measure
      //
      for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) {
            int tracks = nstaves() * VOICES;
            bool first = true;
            for (int track = 0; track < tracks; ++track) {
                  for (Segment* s = m->first(); s; s = s->next()) {
                        if (s->segmentType() != Segment::Type::ChordRest)
                              continue;
                        ChordRest* cr = static_cast<ChordRest*>(s->element(track));
                        if (cr) {
                              if(cr->type() == Element::Type::REST) {
                                    Rest* r = static_cast<Rest*>(cr);
                                    if (!r->userOff().isNull()) {
                                          int lineOffset = r->computeLineOffset();
                                          qreal lineDist = r->staff() ? r->staff()->staffType()->lineDistance().val() : 1.0;
                                          r->rUserYoffset() -= (lineOffset * .5 * lineDist * r->spatium());
                                          }
                                    }
                              if(!first) {
                                    switch(cr->beamMode()) {
                                          case Beam::Mode::AUTO:
                                          case Beam::Mode::BEGIN:
                                          case Beam::Mode::END:
                                          case Beam::Mode::NONE:
                                                break;
                                          case Beam::Mode::MID:
                                          case Beam::Mode::BEGIN32:
                                          case Beam::Mode::BEGIN64:
                                                cr->setBeamMode(Beam::Mode::BEGIN);
                                                break;
                                          case Beam::Mode::INVALID:
                                                if (cr->type() == Element::Type::CHORD)
                                                      cr->setBeamMode(Beam::Mode::AUTO);
                                                else
                                                      cr->setBeamMode(Beam::Mode::NONE);
                                                break;
                                          }
                                    first = false;
                                    }
                              }
                        }
                  }
            }
      for (MeasureBase* mb = _measures.first(); mb; mb = mb->next()) {
            if (mb->type() == Element::Type::VBOX) {
                  Box* b  = static_cast<Box*>(mb);
                  qreal y = point(styleS(StyleIdx::staffUpperBorder));
                  b->setBottomGap(y);
                  }
            }

      _fileDivision = MScore::division;

      //
      //    sanity check for barLineSpan and update ottavas
      //
      foreach(Staff* staff, _staves) {
            int barLineSpan = staff->barLineSpan();
            int idx = staffIdx(staff);
            int n = nstaves();
            if (idx + barLineSpan > n) {
                  qDebug("bad span: idx %d  span %d staves %d", idx, barLineSpan, n);
                  staff->setBarLineSpan(n - idx);
                  }
            staff->updateOttava();
            }
コード例 #28
0
bool Parser::parseOne(Directive *&ret) {
  consumeToken();
  switch (_tok._kind) {
  case Kind::eof:
    return true;
  case Kind::kw_exports: {
    // EXPORTS
    std::vector<PECOFFLinkingContext::ExportDesc> exports;
    for (;;) {
      PECOFFLinkingContext::ExportDesc desc;
      if (!parseExport(desc))
        break;
      exports.push_back(desc);
    }
    ret = new (_alloc) Exports(exports);
    return true;
  }
  case Kind::kw_heapsize: {
    // HEAPSIZE
    uint64_t reserve, commit;
    if (!parseMemorySize(reserve, commit))
      return false;
    ret = new (_alloc) Heapsize(reserve, commit);
    return true;
  }
  case Kind::kw_library: {
    // LIBRARY
    std::string name;
    uint64_t baseaddr;
    if (!parseName(name, baseaddr))
      return false;
    if (!StringRef(name).endswith_lower(".dll"))
      name.append(".dll");
    ret = new (_alloc) Library(name, baseaddr);
    return true;
  }
  case Kind::kw_stacksize: {
    // STACKSIZE
    uint64_t reserve, commit;
    if (!parseMemorySize(reserve, commit))
      return false;
    ret = new (_alloc) Stacksize(reserve, commit);
    return true;
  }
  case Kind::kw_name: {
    // NAME
    std::string outputPath;
    uint64_t baseaddr;
    if (!parseName(outputPath, baseaddr))
      return false;
    ret = new (_alloc) Name(outputPath, baseaddr);
    return true;
  }
  case Kind::kw_version: {
    // VERSION
    int major, minor;
    if (!parseVersion(major, minor))
      return false;
    ret = new (_alloc) Version(major, minor);
    return true;
  }
  default:
    error(_tok, Twine("Unknown directive: ") + _tok._range);
    return false;
  }
}
コード例 #29
0
ファイル: java_exe.c プロジェクト: edwinm/Jarx
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nShowCmd ) {
	HINSTANCE hVM;
	int result;
	char line[LINEMAXLEN];
	char jarfile[LINEMAXLEN];
	char classpath[LINEMAXLEN];
	char classname[LINEMAXLEN];
	char errorStr[LINEMAXLEN];
	char downloadStr[LINEMAXLEN];
	char cmd[2*LINEMAXLEN];
	char versionmin[30];
	int versmin = 0;
	int version;
	char *p;
	char *pExt;
	int error = 0;
	char *arg = NULL;

	*jarfile = '\0';
	*classpath = '\0';
	*classname = '\0';
	*versionmin = '\0';

	hInst = hInstance;

	// Possible situations:
	// 1) Jarx is opened because a .jar is double clicked:
	//		Read manifest and execute
	// 2) Jarx is opened because a .jarx is double clicked:
	//		Read jarx and execute
	// 2) Jarx is opened because some other file is double clicked
	//		Try to read a default.jarx in the app map
	// Else: show Jarx dialog box

	// Remove dblquotes from cmdline
	getCmdParam( lpCmdLine, line, sizeof( line ) - 1 );
	GetLongPathName( line, cmd, sizeof( cmd ) - 1 );

	// Find extension
	pExt = strrchr( cmd, '.' );
	if ( pExt != NULL && stricmp( pExt, ".jarx" ) == 0 ) {
		// it's .jarx - read and parse .jarx file
		readConfig( cmd, jarfile, classpath, classname, versionmin );
	} else if ( pExt != NULL && stricmp( pExt, ".jar" ) == 0 ) {
		// it's .jar
		// Only use filename (without path)
		// p = strrchr( cmd, '\\' );
		//if ( p != NULL )
		//	strcpy( classpath, p+1 );
		//else
		strcpy( jarfile, cmd );
	} else {
		// It's not a .jar or .jarx - try to get the default.jarx from the application map
		getCmdParam( GetCommandLine(), cmd, sizeof(cmd) );
		p = strrchr( cmd, '\\' );
		if ( p != NULL ) {
			*p = '\0';
			_chdir( cmd );
		}
		readConfig( DEFAULTJARX, jarfile, classpath, classname, versionmin );
		getCmdParam( lpCmdLine, cmd, sizeof(cmd) );
		if ( strlen( cmd ) > 0 )
			arg = cmd;
	}

	// Still no jarfile found? Show JARX dialog
	if ( *jarfile == '\0' ) {
		DialogBox( hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, aboutCallback );
		return 0;
	}

	// No classpath? -> use jarfile as classpath
	if ( *classpath == '\0' )
		strcpy( classpath, jarfile );

	// Versionmin set?
	if ( *versionmin != '\0' )
		versmin = parseVersion( versionmin );
	else
		versmin = 0;

	// try to load a JVM
	hVM = getJVM( &version );

	if ( hVM == NULL ) {
		error = IDS_NOTINSTALLED;
	} else {
		// execute class in JVM
		result = execJVM( hVM, hInstance, jarfile, classpath, classname, arg, version, versmin );
		switch( result ) {
			case JVM_PROBLEM:
				error = IDS_CANTCREATEJVM;
				break;
			case JVM_VERSIONTOOSMALL:
				error = IDS_JAVATOOOLD;
				break;
			case JVM_CLASSERR:
				// Probably MS JVM
				// Just execute jview
				if ( *classname != '\0' ) {
					strReplace( classname, '/', '.' );
					sprintf( cmd, "jview /cp \"%s\" %s", classpath, classname );
					result = execute( cmd );
					if ( !result )
						error = IDS_NOJVIEW;
					break;

				} else
					error = IDS_NOJVIEW;
		}
	}

	// Error occured
	if ( error != 0 ) {
		LoadString( hInst, error, errorStr, sizeof( errorStr ) - 1 );
		LoadString( hInst, IDS_DOWNLOAD, downloadStr, sizeof( downloadStr ) - 1 );
		sprintf( line, downloadStr, errorStr );
		result = MessageBox( NULL, line, "JARX", MB_OKCANCEL | MB_ICONEXCLAMATION );
		if ( result == IDOK )
			ShellExecute(NULL, "open", JAVADOWNLOAD, NULL, NULL, SW_SHOWNORMAL);
		return 1;
	}
	return 0;
}
コード例 #30
0
APMFirmwareVersion::APMFirmwareVersion(const QString &versionText):
    _major(0),_minor(0),_patch(0)
{
    parseVersion(versionText);
}