EXPORT_C void CHuiFxEffectCache::FindOrCreateL(MHuiFxEffectCacheNode *aNode)
   { // using fxml file
   MHuiFxEffectCacheNode *cachedNode = Find(aNode);

   if (cachedNode)
	  { // found in cache
	  aNode->LightOperationL(cachedNode); // from cache to this instance  
	  delete aNode;
	  }
   else
	  { // not found in cache, so start parsing the effect.

	  // TODO: What happens if we did not find it from cache, but it exists in iDuplicateEffects?
	  //       Current behaviour is that it starts to load it again, causing duplicate entries in the cache.
	  TInt id = UniqueId();
      IDNode n = { id, aNode };
      iDuplicateEffects.Append(n);
      //iDuplicateEffects.InsertL(id, aNode);

	  TRAPD(err, aNode->HeavyOperationL(this, id)); // from empty to this instance
	  if (err != KErrNone)
	      {
	      iDuplicateEffects.Remove(iDuplicateEffects.Count()-1);
	      User::Leave(err);
	      }
	  }
  }
void CHuiFxEffectCache::CreateL(MHuiFxEffectCacheNode *aNode)
    { // registration of fxml file
    MHuiFxEffectCacheNode *cachedNode = Find(aNode);
    MHuiFxEffectCacheNode *dupNode = FindDuplicate(aNode);
    if (cachedNode)
       { // found in cache => duplicate registration => no need to do anything
       cachedNode->Ref(1);
       delete aNode;
       }
    else if (dupNode)
        { // found same file already being loaded
        dupNode->Ref(1);
        delete aNode;
        }
    else
       { // not found in cache, so insert it and start parsing the effect.
       TInt id = UniqueId();
       IDNode n = { id, aNode };
       iDuplicateEffects.Append(n);

       TRAPD(err, aNode->HeavyOperationL(this, id)); // from empty to this instance
       if (err != KErrNone)
           {
           iDuplicateEffects.Remove(iDuplicateEffects.Count()-1);
           User::Leave(err);
           }
       }
    }
Example #3
0
const QString CameraDescription::ToPlainText() const
{
    const QString plainText( QString( "%1\n%2\n%3" )
                            .arg( QString::fromStdWString( Name() ) )
                            .arg( QString::fromStdWString( Description() ) )
                            .arg( QString::fromStdWString( UniqueId() ) ) );
    return plainText;
}
Example #4
0
RsyncDirListerOperation::RsyncDirListerOperation(RsyncDirLister* parent)
        : QObject(parent)
{
    d = new RsyncDirListerOperationData;
    d->parent = parent;
    d->id = UniqueId();
    d->url = QUrl(d->parent->url().path());
    d->syncProcess = new QProcess(this);
    connect(d->syncProcess, SIGNAL (finished(int, QProcess::ExitStatus)), this, SLOT(procFinished()));
    connect(d->syncProcess, SIGNAL (error(QProcess::ProcessError)), this, SLOT(procError()));
}
Example #5
0
void iLister::DeviceRemovedCallback(const char* uuid) {
  QString id = UniqueId(uuid);
  {
    QMutexLocker l(&mutex_);
    if (!devices_.contains(id))
      return;

    devices_.remove(id);
  }

  emit DeviceRemoved(id);
}
Example #6
0
const QString CameraDescription::ToRichText() const
{
    const QString richText( QCoreApplication::translate( "CameraDescription",
                              "<head/>\n"
                              "<body>\n"
                                  "<p><strong>Name:</strong> %1</p>\n"
                                  "<p><strong>Description:</strong> %2</p>\n"
                                  "<p><strong>Unique ID:</strong> %3</p>\n"
                              "</body>" )
                                .arg( QString::fromStdWString( Name() ) )
                                .arg( QString::fromStdWString( Description() ) )
                                .arg( QString::fromStdWString( UniqueId() ) ) );
    return richText;
}
Example #7
0
void iLister::DeviceAddedCallback(const char* uuid) {
  DeviceInfo info = ReadDeviceInfo(uuid);
  QString id = UniqueId(uuid);

  QString name = MakeFriendlyName(id);
  if (info.product_type == "iPhone 3,1" || info.product_type.startsWith("iPad")) {
    // iPhone 4 and iPad unsupported by libgpod as of 0.7.94.
    return;
  }

  {
    QMutexLocker l(&mutex_);
    devices_[id] = info;
  }

  emit DeviceAdded(id);
}
Example #8
0
/**
Protected constructor.

Extracts the initialisation data provided by the calling functions: ConstructSourceL() and 
ConstructSinkL(). Creates a file server session and sets up file name. If there is a file name and 
it cannot be found this function leaves. If there is no file name the function leaves. Does not 
attempt to open the file or check whether the file exists.

If aInitData contains a TMMFFileHandleParams instead of TMMFFileParams, the source/sink is constructed from 
the file handle provided by the caller

@param  aInitData
Initialisation data packaged in a TMMFFileParams or in a TMMFFileHandleParams (File Handle)
*/
void CFileMultimediaSource::ConstructL(const TDesC8& aInitData,TMMFileMode aFileMode)
    {
    User::LeaveIfError(iFsSession.Connect());
    // on IPCv2 we auto attach
    User::LeaveIfError(iFsSession.ShareAuto());
    
    User::LeaveIfError(iFsSession.ShareProtected());
    
    TBool fileInit = EFalse;
    HBufC* filename = NULL; 
    TBool filenamePushed = EFalse;
    
    iCAFParameters = new (ELeave) CCAFParameters;
    TBool drmContent = EFalse;
    RDesReadStream stream(aInitData);
    CleanupClosePushL(stream);

    TUid initUid;
    
    initUid = TUid::Uid(stream.ReadInt32L());
    
    if (initUid == KMMFileHandleSourceUid)
        {
        TPckgBuf<RFile*> fileptr;
        stream.ReadL(fileptr);
        
        iHandle.Duplicate(*fileptr());
        
        TInt length;
        length = stream.ReadInt32L();
        if (length>0)
            {
            iCAFParameters->iUniqueId = HBufC::NewL(length);
            TPtr16 ptr = iCAFParameters->iUniqueId->Des();
            stream.ReadL(ptr, length);
            }
        iFileHandle = ETrue;
        filename = HBufC::NewMaxL(KMaxFileName);
        TPtr ptr = filename->Des();
        iHandle.Name(ptr);
        fileInit = ETrue;
        drmContent = ETrue;
        
        iCAFParameters->iEnableUI = stream.ReadInt32L();
        }
    
    else if (initUid == KMMFileSourceUid)
        {
        TInt length;
        length = stream.ReadInt32L();
        filename = HBufC::NewMaxLC(length);
        TPtr ptr = filename->Des();
        stream.ReadL(ptr, length);
        
        length = stream.ReadInt32L();
        if (length>0)
            {
            iCAFParameters->iUniqueId = HBufC::NewMaxL(length);
            ptr.Set(iCAFParameters->iUniqueId->Des());
            stream.ReadL(ptr, length);
            }
        CleanupStack::Pop(filename);
        
        fileInit = ETrue;
        drmContent = ETrue;
        iFileHandle = EFalse; 
        iCAFParameters->iEnableUI = stream.ReadInt32L();
        }
    else
        {
        //		TODO If the UID is unknown we should reject, but  currently
        //		code also used for older calls that just supply filename.
        //		User::Leave(KErrNotSupported);
        }
    
    CleanupStack::PopAndDestroy(&stream);
    
    if (!fileInit && aInitData.Length() == sizeof(TMMFFileHandleParams))
        {
        TMMFFileHandleParams params;
        TPckgC<TMMFFileHandleParams> config(params);
        config.Set(aInitData);
        params = config();
        
        
        if (params.iUid == KFileHandleUid)
            {
            fileInit = ETrue;
            User::LeaveIfError(iHandle.Duplicate(*params.iFile));
            TInt pos = 0;
            // make sure the duplicate handle is at the start of the file - the usage of the file handle really requires this
            User::LeaveIfError(iHandle.Seek(ESeekStart, pos));
            iFileHandle = ETrue;
            filename = HBufC::NewMaxLC(KMaxFileName);
            filenamePushed = ETrue;
            TPtr ptr = filename->Des();
            User::LeaveIfError(iHandle.Name(ptr));
            }
        }
    
    if (!fileInit) // do old case as last resort
        {
        TMMFFileParams params;
        TPckgC<TMMFFileParams> config(params);
        config.Set(aInitData);
        params = config();
        
        filename = params.iPath.AllocL();
        fileInit = ETrue;
        }
    
    if (!filenamePushed)
        {
        // from now on it is assumed pushed.
        CleanupStack::PushL(filename);
        }
    
    TParse parser ;
    User::LeaveIfError(parser.Set(*filename, NULL, NULL));
    CleanupStack::PopAndDestroy(filename);
    if ( !( parser.NamePresent() ) && !( parser.ExtPresent() ) )
        User::Leave( KErrBadName ) ;
    
    iFullFileName.Copy( parser.FullName() ) ;	
    iFileName = parser.Name().AllocL() ;
    iFileExt = parser.Ext().AllocL() ;
    iFilePath = parser.Path().AllocL() ;
    iFileDrive = parser.Drive().AllocL() ;
    
    // in order to simulate old behaviour we are not passing error out
    // but will try to create Content again during PrimeL()
    if (fileInit && drmContent && aFileMode==ESourceMode)
        {
        TInt contentError;
        if (iFileHandle)
            {
            TRAP(contentError, 
                iFile = CContentFile::NewL(iHandle, UniqueId(), iCAFParameters->iEnableUI);
            );
            }
namespace COLLADAFW
{
	static const String UNIQUEID = "UniqueID";
	
	const UniqueId UniqueId::INVALID = UniqueId();



	//-------------------------------
	UniqueId::UniqueId( const String& ascii )
	{
		fromAscii(ascii);
	}

	//-------------------------------
	UniqueId::~UniqueId()
	{
	}

	//-------------------------------
	COLLADAFW::String UniqueId::toAscii() const
	{
		// sample: UniqueId(1,4)
		std::stringstream stream;
		stream << UNIQUEID << '(' << mClassId << ',' << mObjectId << ')';
		return stream.str();
	}

	//-------------------------------
	bool UniqueId::fromAscii( const String& ascii )
	{
		if ( !fromAscii_intern(ascii) )
		{
			*this = INVALID;
			return false;
		}
		return true;
	}

	//-------------------------------
	bool UniqueId::fromAscii_intern( const String& ascii )
	{
		static const size_t UNIQUEID_LENGTH = UNIQUEID.length();
		static const char digits[] = "0123456789";

		// sample: UniqueId(1,4)
		if ( ascii.length() < UNIQUEID_LENGTH )
		{
			return false;
		}

		if ( ascii.compare(0, UNIQUEID_LENGTH, UNIQUEID ) != 0 )
		{
			return false;
		}

		size_t classIdFirstNonDigit = ascii.find_last_not_of( digits, UNIQUEID_LENGTH+1 );
		if ( (classIdFirstNonDigit == ascii.npos) || (classIdFirstNonDigit == UNIQUEID_LENGTH+1))
		{
			// no digit follows the opening bracket 
			return false;
		}
		if ( ascii[classIdFirstNonDigit] == ',' )
		{
			// missing comma after first number
			return false;
		}
		//parse
		mClassId = (ClassId)atoi( &ascii[UNIQUEID_LENGTH+1]);

		size_t objectIdFirstNonDigit = ascii.find_last_not_of( digits, classIdFirstNonDigit + 1);
		if ( (objectIdFirstNonDigit == ascii.npos) || (objectIdFirstNonDigit == classIdFirstNonDigit + 1) )
		{
			// no digit follows the opening bracket 
			return false;
		}

		mObjectId = atoi( &ascii[classIdFirstNonDigit+1]);

		return true;
	}

    //-------------------------------
	bool UniqueId::operator<( const UniqueId& rhs ) const
	{
		if ( mClassId < rhs.mClassId )
			return true;
		if ( mClassId > rhs.mClassId )
			return false;

		if ( mObjectId < rhs.mObjectId )
			return true;
		if ( mObjectId > rhs.mObjectId )
			return false;

		if ( mFileId < rhs.mFileId )
			return true;
		if ( mFileId > rhs.mFileId )
			return false;

		return false;
	}

    //-------------------------------
    bool UniqueId::operator>( const UniqueId& rhs ) const
    {
        if ( mClassId > rhs.mClassId )
            return true;
        if ( mClassId < rhs.mClassId )
            return false;

		if ( mObjectId > rhs.mObjectId )
			return true;
		if ( mObjectId < rhs.mObjectId )
			return false;

		if ( mFileId > rhs.mFileId )
			return true;
		if ( mFileId < rhs.mFileId )
			return false;

        return false;
    }

    //-------------------------------
    bool UniqueId::operator== ( const UniqueId& uid ) const
    {
		return (mClassId == uid.mClassId) && (mObjectId == uid.mObjectId) && (mFileId == uid.mFileId);
    }

    //-------------------------------
    bool UniqueId::operator!= ( const UniqueId& uid ) const
    {
		return (mClassId != uid.mClassId) || (mObjectId != uid.mObjectId) || (mFileId != uid.mFileId);
    }

	//------------------------------
	UniqueId::operator size_t() const
	{
		size_t retVal = 2166136261U;
		const char* p = (const char*)this;
		for ( size_t i = 0; i < sizeof(UniqueId); ++i)
		{
			retVal = 16777619U * retVal ^ (size_t)(*p++);
		}
		return retVal;
	}

} // namespace COLLADAFW