bool AbstractAspect::readBasicAttributes(XmlStreamReader * reader)
{
	QString prefix(tr("XML read error: ","prefix for XML error messages"));
	QString postfix(tr(" (non-critical)", "postfix for XML error messages"));

	QXmlStreamAttributes attribs = reader->attributes();
	QString str;

	// read name
	str = attribs.value(reader->namespaceUri().toString(), "name").toString();
	if(str.isEmpty())
	{
		reader->raiseWarning(prefix+tr("aspect name missing or empty")+postfix);
	}
	setName(str);
	// read creation time
	str = attribs.value(reader->namespaceUri().toString(), "creation_time").toString();
	QDateTime creation_time = QDateTime::fromString(str, "yyyy-dd-MM hh:mm:ss:zzz");
	if(str.isEmpty() || !creation_time.isValid())
	{
		reader->raiseWarning(tr("Invalid creation time for '%1'. Using current time.").arg(name()));
		setCreationTime(QDateTime::currentDateTime());
	}
	else
		setCreationTime(creation_time);
	// read caption spec
	str = attribs.value(reader->namespaceUri().toString(), "caption_spec").toString();
	setCaptionSpec(str);

	return true;
}
Result ZipFile::uncompressEntry (int index, const File& targetDirectory, bool shouldOverwriteFiles)
{
    auto* zei = entries.getUnchecked (index);

   #if JUCE_WINDOWS
    auto entryPath = zei->entry.filename;
   #else
    auto entryPath = zei->entry.filename.replaceCharacter ('\\', '/');
   #endif

    if (entryPath.isEmpty())
        return Result::ok();

    auto targetFile = targetDirectory.getChildFile (entryPath);

    if (entryPath.endsWithChar ('/') || entryPath.endsWithChar ('\\'))
        return targetFile.createDirectory(); // (entry is a directory, not a file)

    ScopedPointer<InputStream> in (createStreamForEntry (index));

    if (in == nullptr)
        return Result::fail ("Failed to open the zip file for reading");

    if (targetFile.exists())
    {
        if (! shouldOverwriteFiles)
            return Result::ok();

        if (! targetFile.deleteFile())
            return Result::fail ("Failed to write to target file: " + targetFile.getFullPathName());
    }

    if (! targetFile.getParentDirectory().createDirectory())
        return Result::fail ("Failed to create target folder: " + targetFile.getParentDirectory().getFullPathName());

    {
        FileOutputStream out (targetFile);

        if (out.failedToOpen())
            return Result::fail ("Failed to write to target file: " + targetFile.getFullPathName());

        out << *in;
    }

    targetFile.setCreationTime (zei->entry.fileTime);
    targetFile.setLastModificationTime (zei->entry.fileTime);
    targetFile.setLastAccessTime (zei->entry.fileTime);

    return Result::ok();
}
void CollectionConfiguration::copyConfiguration(const QHelpEngineCore &source,
                                                QHelpEngineCore &target)
{
    setCreationTime(target, creationTime(source));
    setWindowTitle(target, windowTitle(source));
    target.setCurrentFilter(source.currentFilter());
    setCacheDir(target, cacheDir(source), cacheDirIsRelativeToCollection(source));
    setFilterFunctionalityEnabled(target, filterFunctionalityEnabled(source));
    setFilterToolbarVisible(target, filterToolbarVisible(source));
    setAddressBarEnabled(target, addressBarEnabled(source));
    setAddressBarVisible(target, addressBarVisible(source));
    setDocumentationManagerEnabled(target, documentationManagerEnabled(source));
    setApplicationIcon(target, applicationIcon(source));
    setAboutMenuTexts(target, aboutMenuTexts(source));
    setAboutIcon(target, aboutIcon(source));
    setAboutTexts(target, aboutTexts(source));
    setAboutImages(target, aboutImages(source));
    setDefaultHomePage(target, defaultHomePage(source));
}
OblivionSaveGame::OblivionSaveGame(QString const &fileName, MOBase::IPluginGame const *game) :
  GamebryoSaveGame(fileName, game)
{
  FileWrapper file(this, "TES4SAVEGAME");
  file.setBZString(true);

  file.skip<unsigned char>(); //Major version
  file.skip<unsigned char>(); //Minor version

  file.skip<SYSTEMTIME>();  // exe last modified (!)

  file.skip<unsigned long>(); //Header version
  file.skip<unsigned long>(); //Header size

  file.read(m_SaveNumber);

  file.read(m_PCName);
  file.read(m_PCLevel);
  file.read(m_PCLocation);

  file.skip<float>(); //game days
  file.skip<unsigned long>(); //game ticks

  //there is a save time stored here. So use it rather than the file time, which
  //could have been copied.
  //Note: This says it uses getlocaltime api to obtain it which is u/s - if so
  //we should ignore this.
  SYSTEMTIME ctime;
  file.read(ctime);
  setCreationTime(ctime);

  //Note that screenshot size, width, height and data are apparently the same
  //structure
  file.skip<unsigned long>(); //Screenshot size.

  file.readImage();

  file.readPlugins();
}
Exemple #5
0
/*
*******************************************************************
* Function:   
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
void xDistributedSession::unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream)
{

	xNetInterface *netInterface  = (xNetInterface*) connection->getInterface();
	if (netInterface)
	{
		//////////////////////////////////////////////////////////////////////////
		//initial update  ? 
		if(stream->readFlag())
		{
			if(stream->readFlag())
			{
				char oName[256];stream->readString(oName);	// retrieve objects name : 
				char cName[256];stream->readString(cName);	// retrieve objects dist class name : 
				int type  = stream->readInt(32);							//read the dist class base type : 
				int userID = stream->readInt(32);	
				int serverID2 = stream->readInt(32);	
				float creationTime = 0.0f;
				stream->read(&creationTime);
				int sessionID = stream->readInt(32);	
				int MaxUsers = stream->readInt(32);	
				char pass[256];stream->readString(pass);





				//////////////////////////////////////////////////////////////////////////
				//now we store all in the dist object :

				//find and store the dist class : 
				xDistributedClassesArrayType *_classes = netInterface->getDistributedClassInterface()->getDistrutedClassesPtr();
				xDistributedClass *classTemplate = netInterface->getDistributedClassInterface()->get(cName,type);
				if (!classTemplate)
				{
					xLogger::xLog(ELOGERROR,E_LI_SESSION,"Warning initial unpack of session %s failed :  no related class found  : %s",oName,cName);
					//xLogger::xLog(ELOGINFO,XL_START,"Warning Initial Unpack Update, no related class found  : %s",cName);
					//xLogger::xLog(ELOGERROR,XL_SESSION,"Warning Initial Unpack Update, no related class found  : %s",cName);
					classTemplate  = netInterface->getDistributedClassInterface()->createClass(cName,type);

				}
				setDistributedClass(classTemplate);
				SetName(oName);
				setServerID(connection->getGhostIndex(this));
				setObjectFlags(E_DO_CREATION_CREATED);
				setUserID(userID);
				setNetInterface(netInterface);
				setCreationTime(creationTime);
				setSessionID(sessionID);
                			
				
				getOwnershipState().set( 1<<E_DO_OS_OWNER,  getUserID() == ((vtConnection*)connection)->getUserID() );

				setInterfaceFlags(E_DO_CREATED);
				getSessionFlags().set( 1 << E_SF_INCOMPLETE );


				xLogger::xLog(ELOGTRACE,E_LI_SESSION,"Retrieved initial state of session %s",oName);
				initProperties();
				setMaxUsers(MaxUsers);
				setPassword(xNString(pass));
				vtConnection *con  = (vtConnection*)connection;
				setOwnerConnection(con);
			}
		}



		int updateBits = stream->readSignedInt(32);
		TNL::BitSet32 updateBitsMask(updateBits);
		setGhostUpdateBits(updateBits);

		xDistributedPropertyArrayType &props = *getDistributedPorperties();
		int propCounter = 0;
		for (unsigned int i = 0  ;  i < props.size() ; i++ )
		{
			xDistributedProperty *prop  = props[i];
			xDistributedPropertyInfo*propInfo  = prop->getPropertyInfo();
			int blockIndex = prop->getBlockIndex();
			if (updateBitsMask.testStrict(1<<blockIndex))
			{
				prop->updateFromServer(stream);
				xLogger::xLog(ELOGTRACE,E_LI_SESSION,"Client : retrieving session property : %s |pred :%d",prop->getPropertyInfo()->mName.getString(),prop->getPropertyInfo()->mPredictionType);
				//xLogger::xLog(ELOGINFO,XL_START,"client : retrieving session property : %s",prop->getPropertyInfo()->mName.getString());
				getSessionFlags().set( 1 << E_SF_COMPLETE );
				propCounter++;
			}
		}

		if (propCounter == props.size())
		{
			getSessionFlags().set( 1 << E_SF_COMPLETE );
		}
	}
}