void ut_remotepartyinfo::TestInternalizeExternalizeEmptyInfoL()
    {
    HBufC8* data = HBufC8::NewLC( 1024 );
    TPtr8 ptr = data->Des();
    RDesWriteStream stream( ptr );
    ExternalizeL( stream, *iInfo );
    
    CCallRemotePartyInfo* info = CCallRemotePartyInfo::NewLC();
    
    RDesReadStream readStream( ptr );
    InternalizeL( readStream, *info );
    
    EUNIT_ASSERT( iInfo->MatchedName().Length() == 0 );
    EUNIT_ASSERT( iInfo->NameFromNetwork().Length() == 0 );
    EUNIT_ASSERT( iInfo->CompanyName().Length() == 0 );
    EUNIT_ASSERT( iInfo->Address().Length() == 0 ); 
    EUNIT_ASSERT( iInfo->CallIndex() == -1 );
    EUNIT_ASSERT( iInfo->RemoteIdentity() == MCallRemotePartyInfo::ERemoteIdentityUnknown );
    EUNIT_ASSERT( iInfo->SATCall() == EFalse );
    
    CleanupStack::PopAndDestroy( info );
    
    
    CleanupStack::PopAndDestroy( data );
    }
Пример #2
0
/**
 * Externalize (non-leaving) the contents of the Alarm Server backup
 * to the backup file.
 */
TInt CASSrvAlarmStore::Externalize()
	{
	TInt error = KErrNone;
	
#ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT
	if (!iServerWideData.ServerIsReadOnly())
		{
#endif
		DEBUG_PRINT1(_L("> Alarm Store Externalize"));
	
		// tell Alarm Queue what type of Store operation we want to perform
		error = ServerWideData().Queue().StartAlarmStoreOperation(CASSrvAlarmQueue::EStoreExternalize);
	
		if (!error)
			{
			TRAP(error, ExternalizeL());
	
			// tell alarm queue that Externalize is complete
			ServerWideData().Queue().EndAlarmStoreOperation(error);
			}
	
		DEBUG_PRINT2(_L("< Alarm Store Externalize - error %i"), error);
#ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT
		}
#endif
	
	return error;
	}
void ut_remotepartyinfo::TestInternalizeExternalizeInfoL()
    {
    _LIT( KMatchedName, "Mr Smith" );
    _LIT( KNameFromNetwork, "John Smith" );
    _LIT( KCompanyName, "Nokia" );
    _LIT( KAddress, "555555" );
    
    iInfo->SetMatchedNameL( KMatchedName );
    iInfo->SetNameFromNetworkL(KNameFromNetwork);
    iInfo->SetCompanyNameL(KCompanyName);
    iInfo->SetAddressL( KAddress );    
    iInfo->SetCallIndex( 2 );
    iInfo->SetRemoteIdentity( MCallRemotePartyInfo::ERemoteIdentityAvailable );
    iInfo->SetSATCall( ETrue );
    
    HBufC8* data = HBufC8::NewLC( 1024 );
    TPtr8 ptr = data->Des();
    
    RDesWriteStream stream( ptr );
    ExternalizeL( stream, *iInfo );
    
    CCallRemotePartyInfo* info = CCallRemotePartyInfo::NewLC();
    RDesReadStream readStream( ptr );
    InternalizeL( readStream, *info );
    
    EUNIT_ASSERT( info->MatchedName().Match( KMatchedName ) == KErrNone );
    EUNIT_ASSERT( info->NameFromNetwork().Match( KNameFromNetwork ) == KErrNone );
    EUNIT_ASSERT( info->CompanyName().Match( KCompanyName ) == KErrNone );
    EUNIT_ASSERT( info->Address().Match( KAddress ) == KErrNone );    
    EUNIT_ASSERT( info->CallIndex() == 2 );
    EUNIT_ASSERT( iInfo->RemoteIdentity() == MCallRemotePartyInfo::ERemoteIdentityAvailable );
    EUNIT_ASSERT( iInfo->SATCall() == ETrue );
    
    CleanupStack::PopAndDestroy( 2, data ); // info, data
    }
// ---------------------------------------------------------
// CDownloadDataClient::MarshalDataL()
// ---------------------------------------------------------
//
HBufC8* CDownloadDataClient::MarshalDataL() const
    {
    TInt bufLen = Bytes();      // Size of class including iMediaArray elements.
                                //  Note that this includes actual bytes occupied by
                                //  contents of descriptors and pointers.
                                
    bufLen += sizeof(TInt);  // We include the count of elements in iMediaArray
                                //  while externalizing.
                                
    bufLen += sizeof(TInt) * iMediaArray.Count();
                                // iMediaArray has an array iTypes. We are including
                                //  count of elements in iTypes array while externalizing
                                //  each element of iMediaArray.
    
    // Dynamic data buffer
    CBufFlat* buf = CBufFlat::NewL(bufLen);
    CleanupStack::PushL(buf);
    // Stream over the buffer
    RBufWriteStream stream(*buf);
    CleanupClosePushL(stream);
    
    ExternalizeL(stream);
    CleanupStack::PopAndDestroy(); //stream
    
    // Create a heap descriptor from the buffer
    HBufC8* des = HBufC8::NewL(buf->Size());
    TPtr8 ptr(des->Des());
    buf->Read(0, ptr, buf->Size());
    CleanupStack::PopAndDestroy(); //buf
    
    return des;
    }
Пример #5
0
/** Writes the object to the specified message store.

The function can leave with the standard stream leave codes.

@param aStore Store to which to write
*/
EXPORT_C void TImEmailTransformingInfo::StoreL( CMsvStore& aStore ) const
	{
	RMsvWriteStream out;
	out.AssignLC( aStore, KUidMsgFileTransformingInfo ); // pushes 'out' to the stack
	ExternalizeL(out);
	out.CommitL();
	CleanupStack::PopAndDestroy();
	}
Пример #6
0
EXPORT_C void CImOffLineArrayStore::StoreL(CMsvStore& aMsvStore) const
	{
	RMsvWriteStream out;
	out.AssignLC( aMsvStore, KUidImQueuedOperationList ); 
	ExternalizeL(out);
	out.CommitL();
	CleanupStack::PopAndDestroy();
	}
Пример #7
0
TStreamId THighscoreHolder::StoreL(CStreamStore& aStore) const
{
	RStoreWriteStream stream;
	TStreamId id = stream.CreateLC(aStore);
	ExternalizeL(stream);
	stream.CommitL();
	CleanupStack::PopAndDestroy();
	return id;
}
Пример #8
0
void CRequestManager::SaveConfigInfoL()
	{
	FLOG(_L("[IMAGEPRINTUI]<<< CEventManager;SaveConfigInfoL "));
	RFileWriteStream stream;
  	CleanupClosePushL(stream);
	if((stream.Replace(CCoeEnv::Static()->FsSession(),iCongFileName->Des() ,EFileWrite)) == KErrNone)
		{
		ExternalizeL(stream);
		}
	CleanupStack::PopAndDestroy(&stream);
	}
Пример #9
0
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
EXPORT_C HBufC8* RCaIdsArray::MarshalDataLC() const
    {
    HBufC8* desc = HBufC8::NewLC( ( Count() + 1 ) * sizeof(TInt32) );
    TPtr8 ptr( desc->Des() );
    RDesWriteStream stream( ptr );
    CleanupClosePushL( stream );
    ExternalizeL( stream );
    stream.CommitL();
    CleanupStack::PopAndDestroy( &stream );
    return desc;
    }
Пример #10
0
// -----------------------------------------------------------------------------
// CWPPushMessage::StoreL
// -----------------------------------------------------------------------------
//
EXPORT_C void CWPPushMessage::StoreL( CMsvStore& aStore ) const
    {
    TUid uid;
    uid.iUid = KProvisioningMessageStreamUid;

    aStore.Remove( uid );

    RMsvWriteStream stream;
    stream.AssignLC( aStore, uid );
    ExternalizeL( stream );
    CleanupStack::PopAndDestroy(); // stream
    }
Пример #11
0
EXPORT_C void CImSSmtpSettings::StoreL(CMsvStore& aMsvStore) const
	{
	RMsvWriteStream out;
	out.AssignLC( aMsvStore, KUidMsvServiceEntry ); // pushes 'out' to the stack
	TRAPD(error, ExternalizeL(out));
	if (error==KErrNone)
		out.CommitL();
	out.Close(); // make sure we close the file
	User::LeaveIfError(error);
	aMsvStore.CommitL();
	CleanupStack::PopAndDestroy();
	}
Пример #12
0
// -----------------------------------------------------------------------------
// CDRMHelperServer::StoreL().
// This function store internal list into data file
// -----------------------------------------------------------------------------
//
void CDRMHelperServer::StoreL()
    {

#ifdef _DRM_TESTING
    WriteL(_L8("StoreL"));
#endif

    RFileWriteStream file;
    User::LeaveIfError(file.Replace( iFs , DataFileL(iFs).FullName() , EFileWrite ));
    file.PushL();
    ExternalizeL(file);
    file.CommitL();
    CleanupStack::PopAndDestroy(&file);//file
    }
Пример #13
0
void CNcdNodeDisclaimer::ExternalizeDataForRequestL( RWriteStream& aStream )
    {
    DLTRACEIN((""));
    
    if ( IsObsolete() )
        {
        DLINFO(("Set as obsolete. This means that server has removed the object."));
        User::Leave( KNcdErrorObsolete );
        }
    
    ExternalizeL( aStream );
        
    DLTRACEOUT((""));
    }
// -----------------------------------------------------------------------------
// CIAUpdateBGFirstTimeHandler::WriteDataL
//
// -----------------------------------------------------------------------------
//
void CIAUpdateBGFirstTimeHandler::WriteDataL()
	{
	RFile file;
    User::LeaveIfError( file.Replace( iFsSession, iPath, EFileWrite|EFileShareAny ) );
    CleanupClosePushL( file );
    
    RFileWriteStream stream( file, 0 );
    CleanupClosePushL( stream );

    ExternalizeL( stream );
    stream.CommitL();
        
    CleanupStack::PopAndDestroy( &stream );
    CleanupStack::PopAndDestroy( &file );
	}
Пример #15
0
// ----------------------------------------------------------------------------
// Create a buffer from an array
// aBuf replaced with the contents of the descriptor array and its sizes.
// The size of the buffer is the size of data in the buffer
// ----------------------------------------------------------------------------
//
EXPORT_C void MPXUser::CreateBufferL(const MDesCArray* aArray, CBufBase*& aBuf)
    {
    delete aBuf;
    aBuf = NULL;

    CBufBase* buffer=CreateBufferLC(KMPXBufGranularity);
    RBufWriteStream ws(*buffer);
    CleanupClosePushL(ws);
    ExternalizeL(aArray, ws);
    ws.CommitL();
    CleanupStack::PopAndDestroy(&ws);
    buffer->Compress();
    CleanupStack::Pop(buffer);
    aBuf = buffer;
    }
Пример #16
0
// Creates and returns a heap descriptor which holds contents of ’this’
EXPORT_C HBufC8* CRTSecMgrRegisterScriptMsg::PackMsgL() const
	{
	// Dynamic data buffer
	CBufFlat* buf = CBufFlat::NewL(KMaxMsgLength);
	CleanupStack::PushL(buf);
	RBufWriteStream stream(*buf); // Stream over the buffer
	CleanupClosePushL(stream);
	ExternalizeL(stream);
	CleanupStack::PopAndDestroy(&stream);
	// Create a heap descriptor from the buffer
	HBufC8* des = HBufC8::NewL(buf->Size());
	TPtr8 ptr(des->Des());
	buf->Read(0, ptr, buf->Size());
	CleanupStack::PopAndDestroy(buf); // Finished with the buffer
	return (des);
	}
// -----------------------------------------------------------------------------
// CIAUpdateBGControllerFile::WriteControllerDataL
//
// -----------------------------------------------------------------------------
//
void CIAUpdateBGControllerFile::WriteControllerDataL()
    {
    RFile file;
    User::LeaveIfError( file.Replace( iFsSession, iPath, EFileWrite ) );
    CleanupClosePushL( file );
    
    RFileWriteStream stream( file, 0 );
    CleanupClosePushL( stream );

    ExternalizeL( stream );
    
    stream.CommitL();
    
    CleanupStack::PopAndDestroy( &stream );
    CleanupStack::PopAndDestroy( &file );
    }
// -----------------------------------------------------------------------------
// CIAUpdaterFileListFile::WriteDataL
//
// -----------------------------------------------------------------------------
//
EXPORT_C void CIAUpdaterFileListFile::WriteDataL()
	{
    IAUPDATE_TRACE_1("[IAUpdater] CIAUpdaterFileListFile::WriteDataL path: %S", &iPath);
    
    TInt sizeOfFile = 5 * sizeof( TInt ); //KVersion, iSilent, iPckgStartIndex, iTotalPckgCount, iFileList.Count()
    
    TInt count( iFileList.Count() );
	for( TInt i = 0; i < count; ++i )
	    {
	    CIAUpdaterFileList* file( iFileList[ i ] );
        sizeOfFile += sizeof( TInt ) // version
                   + file->BundleName().Size() //Bundle name
                   + sizeof( TInt ) // Bundle name length
                   + sizeof( TInt ) //hidden flag
                   + sizeof( TInt ); //file infos count
        TInt fileInfosCount =  file->FileInfos().Count();          
        for( TInt j = 0; j < fileInfosCount; ++j )
	        {
	        CIAUpdaterFileInfo* info( file->FileInfos()[ j ] );
	        sizeOfFile += sizeof( TInt ) // version
	                   + info->FilePath().Size()
	                   + sizeof( TInt ); // File path length
	        }           
	    }
     
    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFsSession, 
	                                            sizeOfFile, 
	                                            IAUpdaterFileConsts::KDrive ) )
	    {
		User::Leave( KErrDiskFull );
	    }
	RFile file;
    User::LeaveIfError( file.Replace( iFsSession, iPath, EFileWrite ) );
    CleanupClosePushL( file );
    
    RFileWriteStream stream( file, 0 );
    CleanupClosePushL( stream );

    ExternalizeL( stream );
    stream.CommitL();
    
    CleanupStack::PopAndDestroy( &stream );
    CleanupStack::PopAndDestroy( &file );

    IAUPDATE_TRACE("[IAUpdater] CIAUpdaterFileListFile::WriteDataL end");
	}
// -----------------------------------------------------------------------------
// CIAUpdatePendingNodesFile::WriteDataL
//
// -----------------------------------------------------------------------------
//
EXPORT_C void CIAUpdatePendingNodesFile::WriteDataL()
	{
    IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdatePendingNodesFile::ReadDataL path: %S", &iPath);
    TInt sizeOfFile = 2 * sizeof( TInt ); //version, count of identifiers
    
    TInt count( iPendingNodes.Count() );
	for( TInt i = 0; i < count; ++i )
	    {
	    CIAUpdaterIdentifier* identifier( iPendingNodes[ i ] );
	    sizeOfFile += sizeof( TInt ) // version 
	                + identifier->Id().Size() //Id
	                + sizeof( TInt ) //Id length
	                + identifier->Namespace().Size() //namespace
	                + sizeof( TInt ); //namespace length
	    }
    if ( SysUtil::DiskSpaceBelowCriticalLevelL( 
            &iFsSession, 
	        sizeOfFile, 
	        IAUpdateCtrlFileConsts::KDrive ) )
	    {
		User::Leave( KErrDiskFull );
	    }
    
	RFile file;
    User::LeaveIfError( file.Replace( iFsSession, iPath, EFileWrite ) );
    CleanupClosePushL( file );
    
    RFileWriteStream stream( file, 0 );
    CleanupClosePushL( stream );

    ExternalizeL( stream );
    stream.CommitL();
    
    CleanupStack::PopAndDestroy( &stream );
    CleanupStack::PopAndDestroy( &file );


    IAUPDATE_TRACE("[IAUPDATE] CIAUpdatePendingNodesFile::WriteDataL end");
	}
// -----------------------------------------------------------------------------
// CHttpCacheEntry::Externalize
//
// -----------------------------------------------------------------------------
//
TInt CHttpCacheEntry::Externalize( RWriteStream& aWriteStream, const TDesC& aDirectory )
    {
    TRAPD( err, ExternalizeL( aWriteStream, aDirectory ) );
    return err;
    }
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void CPosLmNameIndex::SaveL( TChar aDrive )
    {
    RDbTable table;
    TInt err = table.Open( iDatabase, KPosLmIndexTable, RDbRowSet::EUpdatable );
    if ( err == KErrNotFound )
        {
        PosLmDatabaseManager::CreateIndexTableL( iDatabase );
        err = table.Open( iDatabase, KPosLmIndexTable, RDbRowSet::EUpdatable );
        }
    User::LeaveIfError( err );
    CleanupClosePushL( table );

    TInt currentSize = 0;
    table.FirstL();
    if ( table.AtEnd() )
        {
        table.InsertL();
        }
    else
        {
        table.GetL();
        currentSize = table.ColSize( EPosLmIncIndexDataCol ); 
        table.UpdateL();
        }
    
    if ( currentSize < DataSize() )
        {
        // check disk size
        CPosLmDiskUtilities* diskUtilities = CPosLmDiskUtilities::NewL();
        CleanupStack::PushL( diskUtilities );
    
        TInt bytesToWrite = DataSize() - currentSize;
        diskUtilities->DiskSpaceBelowCriticalLevelL( bytesToWrite, aDrive );
    
        CleanupStack::PopAndDestroy( diskUtilities );
        }
    
    // current language
    table.SetColL( EPosLmIncLanguageCol, User::Language() );
    
    // index data
    RDbColWriteStream writeStream;
    writeStream.OpenL( table, EPosLmIncIndexDataCol );
    CleanupClosePushL( writeStream );
    ExternalizeL( writeStream );
    CleanupStack::PopAndDestroy( &writeStream );
    
    // index timestamp
    TTime now;
    now.UniversalTime();
    table.SetColL( EPosLmIncTimestampCol, now );

#ifdef _DEBUG  
    TBuf<64> mtime;
    now.FormatL( mtime, KPosLmTimeFormat );
    LOG1( "NameIndex: Saving index timestamp %S", &mtime); 
#endif    

    table.PutL();
    CleanupStack::PopAndDestroy ( &table );
    
    iTimeStamp = now;
    }
Пример #22
0
HBufC8* CNcdRequestBase::CreateRequestL() 
    {
    DLTRACEIN((""));
    // check required attributes
    if (iNamespace.IsNull() || iVersion.IsNull()) 
        {
        DLERROR(("not creating request"));
        DASSERT( 0 );
        // do not create request if required attributes are not set
        DLTRACEOUT(( "NULL" ));
        return NULL;
        }
        
    // namespace, required
    NcdProtocolUtils::NewAttributeL( iRoot, KAttrNamespace, iNamespace);
    
    // id, optional
    if (iId.NotNull()) 
        {
        NcdProtocolUtils::NewAttributeL( iRoot, KAttrId, iId );
        }
    
    // version, required
    NcdProtocolUtils::NewAttributeL( iRoot, KAttrVersion, iVersion);
    
    // session, optional
    if (iSession.NotNull())
        {
        NcdProtocolUtils::NewAttributeL( iRoot, KAttrSession, iSession);
        }

    // configuration, optional    
    if (iConfiguration) 
        {
        TXmlEngElement configuration = 
            iConfiguration->GetConfigurationElementL(iDocument);
        if (configuration.NotNull())
            iRoot.AppendChildL(configuration);
                
        TXmlEngElement cookies = 
            iConfiguration->GetCookiesElementL(iDocument);
        if (cookies.NotNull())
            iRoot.AppendChildL(cookies);
        
        TXmlEngElement queryResponse = 
            iConfiguration->GetQueryResponseElementL(iDocument);
        if (queryResponse.NotNull())
            iRoot.AppendChildL(queryResponse);
        }
    
    // cookies, optional
    TXmlEngElement cookies = GetCookiesElementL(KCdpNamespacePrefix);
    if ( cookies.NotNull() ) 
        {
        iRoot.AppendChildL(cookies);
        }
    
    TXmlEngElement queryResponses = GetQueryResponsesElementL(KCdpNamespacePrefix);
    if ( queryResponses.NotNull() ) 
        {
        iRoot.AppendChildL(queryResponses);
        }        

    // add element generated in the inheriting class, one of the following:
    // browse / search / manageSubscriptions / purchase / 
    //   installationReport / diffQuery
    iRoot.AppendChildL(iRequestElement);
    
        
    HBufC8* result = ExternalizeL();

    DLTRACEOUT((""));
    return result;
    }