コード例 #1
0
void Cdmatest::SaveMappingsL()
    {
	TInt c( iMappingTable.Count() );
	if ( c > 0 )
	{
    	RFs fs;
    	User::LeaveIfError( fs.Connect() );
    	CleanupClosePushL( fs );
    	RFileWriteStream buf;
    	User::LeaveIfError( buf.Replace( fs, KMappingTableFile, EFileWrite ) );
    	CleanupClosePushL( buf );
		
		TInt i( 0 ) ;
		do 
			{
			buf.WriteUint32L( iMappingTable[i].iURI.Length() );
			buf.WriteL( iMappingTable[i].iURI );
			buf.WriteUint32L( iMappingTable[i].iLuid.Length() );
			buf.WriteL( iMappingTable[i].iLuid );
			}
		while ( ++i < c )	;
		buf.CommitL();
		buf.Close();
	
		CleanupStack::PopAndDestroy(); // buf
		CleanupStack::PopAndDestroy(); // fs
		}
    }
コード例 #2
0
TInt CSenBaseIdentityManager::WriteConfigurationToL( const TDesC& aFile )
    {
    // First, collect everything into MEMORY
    CBufFlat *pBuf = CBufFlat::NewL(KFLATBUF_SIZE);
    CleanupStack::PushL(pBuf);

    RBufWriteStream bufWs(*pBuf);
    CleanupClosePushL(bufWs);

    bufWs.WriteL(KUsersStart);

    if(iIdentity)
        {
        iIdentity->WriteAsXMLToL(bufWs);
        }

    bufWs.WriteL(KUsersEnd);

    TPtrC8 p8 = pBuf->Ptr(0);

    CleanupStack::PopAndDestroy(1); // bufWs

    // Everything in MEMORY ok, prepare to write into file
    RFs fss;
    User::LeaveIfError(fss.Connect());
    CleanupClosePushL(fss);

    RFileWriteStream fileOutStream;
    CleanupClosePushL(fileOutStream);


    if(!SysUtil::FFSSpaceBelowCriticalLevelL(&fss, p8.Length()) )
        {
        // note, this will zero-length the file(!)
        // it is better to require that 2xfilesize is available and not to
        // dangerously zero the old file and find out
        // that there is no space left..

        //Data caging 2 implementation
#if defined( EKA2 ) || defined( RD_SECURE_PRIV_DATA )
        TBuf<KMaxPath> file;
        fss.CreatePrivatePath(EDriveC);
        fss.PrivatePath(file);
        file.Append(aFile);
        fileOutStream.Replace(fss, file, EFileWrite);
#else
        fileOutStream.Replace(fss, aFile, EFileWrite);
#endif
        // finally write the UTF-8 into the file. 
        fileOutStream.WriteL(p8);
        }

    CleanupStack::PopAndDestroy(3); // fileOutStream, fss, pBuf

    return KErrNone;
    }
コード例 #3
0
void CEmTubePlaylistEntry::ExportL( RFileWriteStream& aStream )
	{
	TInt l = iLocation->Length();
	aStream.WriteInt32L( l );
	if( l )
		{
		aStream.WriteL( *iLocation );
		}

	l = iName->Length();
	aStream.WriteInt32L( l );
	if( l )
		{
		aStream.WriteL( *iName );
		}

	aStream.WriteInt32L( iPlayCount );
	aStream.WriteInt32L( (TInt)iType );
	aStream.WriteReal64L( TReal(iTime.Int64()) );
	}
コード例 #4
0
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
//
void CPolicyClientRequestHandler::DumpClientsL(RFileWriteStream& aFile)
	{
	// Lint seems to have some trouble identifying the TThreadId class.
	// Due to this, Lint will report several errors here that are incorrect.
	// These errors are disabled.
	/*lint -e10 -e1013 -e1055 -e746 -e747 */
	for(TInt i = iControlPolicyClients.Count() - 1; i >= 0; i--)
		{
		TPckgC<TThreadId> clientid(iControlPolicyClients[i]->iClientId.Id());
		aFile.WriteL(clientid);
		}
	/*lint +e10 +e1013 +e1055 +e746 +e747 */
	}
コード例 #5
0
// ----------------------------------------------------------------------------
// CAudioStreamEngine::SaveAudioFileL()
//
// saves the audio data in the buffer into a file
// ----------------------------------------------------------------------------
void CAudioStreamEngine::SaveAudioFileL()
    {
    if (!iBufferOK)
    {
        // In case the encoding was changed between recording and trying to save the file
        ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Recorded buffer does not match current encoding."), ETrue);   
        ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Please re-record and try again."), EFalse); 
        return;
    }
    RFileWriteStream audiofile;

    // Check for free space for saving the sample
    TVolumeInfo volinfo;
    TInt err=iFs.Volume(volinfo,EDriveC);
    if ( volinfo.iFree<(iFrameCount*iFrameSize))
        {
        // Not enough free space on drive for saving, report and exit
        ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Cannot save file:\nnot enough space!"), ETrue); 
        return;
        }

    TFileName fileName;
    fileName.Copy(iAudioFilePath);
    fileName.Append(iAudioFile);
    err = audiofile.Replace(iFs, fileName, EFileWrite|EFileStream);
    if (err==KErrNone) 
        {
        if (iUseAMR)
            {
                // Write the six-byte AMR header, so that the file can be used by other
                // applications as well.
                for (int i = 0; i < KAMRHeaderLength; i++)
                    audiofile.WriteUint8L(KAMRNBHeader[i]);
            }
            
        // File opened ok, proceed writing.
        // Write audio data directly from iStreamBuffer
        for (TUint idx=iStreamStart; idx<=iStreamEnd; idx++)//iFrameCount; idx++)
            {
            audiofile.WriteL(GetFrame(idx));
            }
        ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Saving complete!"), ETrue); 
        }   
    else 
        {
        // failed to open file
        ShowMessage(_L("CAudioStreamEngine::SaveAudioFileL() Error saving audio sample!"), ETrue); 
        }
    audiofile.Close();
    }
コード例 #6
0
void CVideoEntry::ExportL( RFileWriteStream &aStream )
	{
	aStream.WriteInt16L( iMediaTitle->Length() );
	aStream.WriteL( *iMediaTitle, iMediaTitle->Length() );

	aStream.WriteInt16L( iUrl->Length() );
	aStream.WriteL( *iUrl, iUrl->Length() );

	aStream.WriteInt16L( iThumbnailUrl->Length() );
	aStream.WriteL( *iThumbnailUrl, iThumbnailUrl->Length() );

	aStream.WriteInt16L( iThumbnailFile->Length() );
	aStream.WriteL( *iThumbnailFile, iThumbnailFile->Length() );

	aStream.WriteInt16L( iVideoId->Length() );
	aStream.WriteL( *iVideoId, iVideoId->Length() );

	aStream.WriteInt16L( iAuthorName->Length() );
	aStream.WriteL( *iAuthorName, iAuthorName->Length() );

	aStream.WriteInt16L( iAuthorUrl->Length() );
	aStream.WriteL( *iAuthorUrl, iAuthorUrl->Length() );

	aStream.WriteInt16L( iRelatedUrl->Length() );
	aStream.WriteL( *iRelatedUrl, iRelatedUrl->Length() );

	aStream.WriteInt16L( iAuthorVideosUrl->Length() );
	aStream.WriteL( *iAuthorVideosUrl, iAuthorVideosUrl->Length() );

	aStream.WriteInt32L( iThumbnailHeight );
	aStream.WriteInt32L( iThumbnailWidth );
	aStream.WriteInt32L( iDuration );
	aStream.WriteReal32L( iAverageRating );

	aStream.WriteInt32L( iViewCount );

	aStream.CommitL();
	}
コード例 #7
0
void CEmTubePlaylist::ExportL( RFileWriteStream& aStream )
	{
	if( Name().Length() )
		{
		aStream.WriteInt32L( Name().Length() );
		aStream.WriteL( Name() );
		}
	else
		{
		aStream.WriteInt32L( 0 );
		}

	aStream.WriteInt32L( (TInt)iType );
	aStream.WriteInt32L( iFlags );

	aStream.WriteInt32L( iEntries.Count() );
	for(TInt i=0;i<iEntries.Count();i++)
		{
		iEntries[i]->ExportL( aStream );
		}
	}
コード例 #8
0
// ---------------------------------------------------------------------------
// Write the file to correct directory.
// ---------------------------------------------------------------------------
//
EXPORT_C void CXIMPTestFileTool::PluginStoreL( const TDesC8& aExternalizedObject )
    {
    HBufC* fileName = GetFileNameLC( 
            KFileToolPluginDirBase,
            iObjIndex );

    RFileWriteStream out;
    CleanupClosePushL( out );
    out.Create( iFs, *fileName, EFileWrite|EFileStream|EFileShareAny );

    // write the file
    TUint32 len = aExternalizedObject.Length();
    out.WriteUint32L( len );
    out.WriteL( aExternalizedObject );
    CleanupStack::PopAndDestroy(); // out

    CleanupStack::PopAndDestroy( fileName ); // fileName

    // next file will have a new index
    iObjIndex++;
    }
コード例 #9
0
TBool CDiscussion::WriteDiscussionToFileL() {
	TPtr pId(iDiscussionId->Des());
	
	if(iDiscussionInMemory && pId.Length() > 0) {
		RFs aSession = CCoeEnv::Static()->FsSession();	
		TFileName aFilePath = GetFileName(aSession);

		RFileWriteStream aFile;
		TBuf8<128> aBuf;
		
#ifdef _DEBUG
		if(iDiscussionReadObserver) {
			aBuf.Format(_L8("DISC  Start: Save discussion %d to file"), iItemId);
			iDiscussionReadObserver->DiscussionDebug(aBuf);
		}
#endif
	
		if(aFile.Replace(aSession, aFilePath, EFileStreamText|EFileWrite) == KErrNone) {
			CleanupClosePushL(aFile);

			CXmppAtomEntryParser* aAtomEntryParser = CXmppAtomEntryParser::NewLC();
			
			aFile.WriteL(_L8("<?xml version='1.0' encoding='UTF-8'?>\r\n"));		
			aBuf.Format(_L8("\t<discussion notify='%d'>\r\n"), iNotify);
			aFile.WriteL(aBuf);

			for(TInt i = 0; i < iEntries.Count(); i++) {
				CThreadedEntry* aThread = iEntries[i];			
				CAtomEntryData* aEntry = aThread->GetEntry();	
				
				aFile.WriteL(_L8("\t\t"));						
				aFile.WriteL(aAtomEntryParser->AtomEntryToXmlL(aEntry, KNullDesC8, true));
				aFile.WriteL(_L8("\r\n"));						
				
				if(aThread->CommentCount() > 0) {
					aFile.WriteL(_L8("\t\t<comments>\r\n"));	
					
					for(TInt x = 0; x < aThread->CommentCount(); x++) {
						CAtomEntryData* aComment = aThread->GetCommentByIndex(x);
						
						aFile.WriteL(_L8("\t\t\t"));						
						aFile.WriteL(aAtomEntryParser->AtomEntryToXmlL(aComment, aEntry->GetId(), true));
						aFile.WriteL(_L8("\r\n"));						
					}
					
					aFile.WriteL(_L8("\t\t</comments>\r\n"));	
				}
			}

			aFile.WriteL(_L8("\t</discussion>\r\n</?xml?>"));

			CleanupStack::PopAndDestroy(); // CXmppAtomEntryParser
			CleanupStack::PopAndDestroy(&aFile);
			
#ifdef _DEBUG
			if(iDiscussionReadObserver) {
				aBuf.Format(_L8("DISC  End: Save discussion %d to file"), iItemId);
				iDiscussionReadObserver->DiscussionDebug(aBuf);
			}
#endif
		
			return true;
		}
#ifdef _DEBUG
		else {
			if(iDiscussionReadObserver) {
				aBuf.Format(_L8("DISC  Fail: Save discussion %d to file"), iItemId);
				iDiscussionReadObserver->DiscussionDebug(aBuf);
			}
		}
#endif		
	}
	
	return false;
}
コード例 #10
0
EXPORT_C void CSenXmlReader::ParseL(const TDesC8& aBuff)
    {
    // In S60 2nd edition FP3 (2.8) platform a temp file has to be used, since the
    // underlying expat parser would crash when parsing a document which consists 
    // of more that 2048 bytes of XML.

    if (aBuff.Length() > 2048) // there is 2048 bytes limitation in expat parser!
        {
        SENDEBUG_L("CSenXmlReader::ParseL(): parsing over 2048 bytes of XML (EKA1)");
        SENDEBUG((_L("- document size: %d bytes."), aBuff.Length() ));

        // Parse large XML documents using file server
        RFs fss;
        User::LeaveIfError(fss.Connect());
        CleanupClosePushL(fss);

        // Now create a new temp file in the specified path using unique 
        // file name which is generated by the file server. Since file 
        // server is not responsible to delete this file, it must be done 
        // after parsing is finished.

        // Path for temp file
        _LIT(KFilePath, "c:\\");

        // Stores the temp file name when fileOutStream.Temp() returns:
        TFileName tempFilename; 
    
        // Try to generate new temporary file, leave if it failes:
        RFileWriteStream fileOutStream;
        User::LeaveIfError(fileOutStream.Temp(fss, KFilePath, tempFilename, EFileWrite));
        CleanupClosePushL(fileOutStream);
        SENDEBUG((_L("CSenXmlReader::ParseL(): used temp file name: '%S'"), &tempFilename));

        // Write XML document into the file:
        fileOutStream.WriteL(aBuff);

        // fileOutStream.Close(). Must be done prior ParseL()!
        CleanupStack::PopAndDestroy(); 

        // Parse the file:
        ParseL(fss, tempFilename);

        // Now delete the temporary file (when it is not in locked in parser's use)
        fss.Delete(tempFilename);

        // Finally close the file server session
        CleanupStack::PopAndDestroy(); // fss.Close()
        SENDEBUG_L("CSenXmlReader::ParseL() successfully parsed > 2048 bytes of XML.");
        }
    else
        {
        // Smaller documents may be parsed normally, even with older versions
        // of Symbian XML framework's expat parser.
        
        CleanUp();
        
#if defined(__SERIES60_30__)
    RecreateParserL();
#endif // __SERIES_30__ defined

        TInt feature(iEnabledFeature);

        TReaderData* pData = new (ELeave) TReaderData;
        pData->ipReader         = this;
        pData->iEnabledFeature  = iEnabledFeature;
        CleanupStack::PushL( TCleanupItem( CSenXmlReader::CleanupParser, pData ) );
        // Parse the XML document:
        iParser->ParseL(aBuff);
        CleanupStack::Pop();
        delete pData;
        
        iParser->ParseEndL(); // Enables Symbian XML framework errors to propagete OnErrorL() callback

        CleanUp();

        if (iEnabledFeature < 0) 
            {
            TInt error(iEnabledFeature);
            iEnabledFeature = feature;
            SENDEBUG((_L("CSenXmlReader::ParserL: leaving (%d)"), iEnabledFeature));
            User::Leave(error);
            }
            
        iContentHandler->EndDocument();
        }
    }