// -----------------------------------------------------------------------------
// CTestSDKButtons::TestMenuBtWriteInternalStateL
// -----------------------------------------------------------------------------
//
TInt CTestSDKButtons::TestMenuBtWriteInternalStateL( CStifItemParser& /*aItem*/ )
    {
    class CTestEikMenuButton : public CEikMenuButton
        {
    public:
        /*Constructor*/
        CTestEikMenuButton(){}
        /*Deconstructor*/
        ~CTestEikMenuButton(){}
        void DoWriteInternalStateL( RWriteStream aStream )
            {
            WriteInternalStateL( aStream );
            }
        };
    CTestEikMenuButton* menubutton = new ( ELeave ) CTestEikMenuButton;
    CleanupStack::PushL( menubutton );
    TResourceReader reader;
    CCoeEnv::Static()->CreateResourceReaderLC( reader, R_TEST_MENU_BUTTON );
    menubutton->ConstructFromResourceL( reader );
    const TInt KHBufSize = 4096;
    HBufC8* buf = HBufC8::NewL( KHBufSize );
    CleanupStack::PushL( buf );
    TPtr8 ptr = buf->Des();
    RDesWriteStream stream;
    CleanupClosePushL( stream );
    stream.Open( ptr );
    menubutton->DoWriteInternalStateL( stream );
    stream.CommitL();
    stream.Close();
    CleanupStack::PopAndDestroy( 4 );// menubutton, reader, buf, stream
    
    return KErrNone;
    }
// -----------------------------------------------------------------------------
// CTestSDKSettingPages::TestSettingpagesRadioButtonWriteInternalStateLL
// -----------------------------------------------------------------------------
//
TInt CTestSDKSettingPages::TestSettingpagesRadioButtonWriteInternalStateLL( CStifItemParser& /*aItem*/ )
    {
    CDesCArrayFlat* mArr = new( ELeave ) CDesCArrayFlat( KSize );
    CleanupStack::PushL( mArr );

    TBuf<KBufSize> tom( KTom );
    TBuf<KBufSize> jack( KJack );
    TBuf<KBufSize> mary( KMary );
    mArr->AppendL( tom );
    mArr->AppendL( jack );
    mArr->AppendL( mary );
    TInt optin( KZero );
    TBuf< KBufSize > buffer( KTestString );
    CTestRadioButtonSettingPage* dialog =
    new (ELeave) CTestRadioButtonSettingPage( &buffer, KOne, EAknCtPopupSettingList,
        R_EXAMPLE_EDITOR_CONTROL, R_EXAMPLE_SETTING_PAGE, optin, mArr );
    CleanupStack::PushL( dialog );
    dialog->ConstructL();
    
    RDesWriteStream stream;
    CleanupClosePushL( stream );
    HBufC8* hbuf = HBufC8::NewL( KHBufSize );
    CleanupStack::PushL( hbuf );
    TPtr8 ptr = hbuf->Des();
    stream.Open( ptr );
    dialog->DoWriteInternalStateL( stream );
    stream.CommitL();
    stream.Close();  
    CleanupStack::PopAndDestroy( KFour );
    return KErrNone;
    }
static void ExternalizeL( RDesWriteStream& aStream, CCallRemotePartyInfo& aInfo )
    {
    aStream.PushL();
    aInfo.ExternalizeL( aStream );
    aStream.CommitL();
    aStream.Pop();
    aStream.Close();
    }
void CBBFetchMediaRequest::ConstructL(const CFbsBitmap* aBitmap)
{
	iMediaThumbnail = CBBString8::NewL(KThumbnail, 1024);
	TInt err=KErrNone;
	if (aBitmap) {
		{
			TPtr8 bufp(iMediaThumbnail->iBuf->Des());
			RDesWriteStream wStream;
			wStream.Open(bufp);
			CC_TRAPD(err, aBitmap->ExternalizeL(wStream));
			if (err==KErrNone) {
				wStream.CommitL();
				wStream.Close();
			}
		}
		while (err==KErrOverflow) {
			TInt size = iMediaThumbnail->iBuf->Des().MaxLength() *2;
			delete iMediaThumbnail; iMediaThumbnail=0;
			iMediaThumbnail = CBBString8::NewL(KThumbnail, size);
			TPtr8 bufp(iMediaThumbnail->iBuf->Des());
			RDesWriteStream wStream;
			wStream.Open(bufp);
			CC_TRAP(err, aBitmap->ExternalizeL(wStream));
			if (err==KErrNone)  {
				wStream.CommitL();
				wStream.Close();
			}
		}
	}

	RDebug::Print(_L("%d"), iMediaThumbnail->iBuf->Des().Length());
	
	/*if (aBitmap) {
		TPckg<CFbsBitmap> xBitmap(*aBitmap);
		iMediaThumbnail = CBBString8::NewL(KThumbnail, xBitmap.Size());
		iMediaThumbnail->Append(xBitmap);
	} else {
		iMediaThumbnail = CBBString8::NewL(KThumbnail, 0);
	}*/
}