Esempio n. 1
0
// ---------------------------------------------------------
// TCodParser::ParseL()
// ---------------------------------------------------------
//
void TCodParser::ParseL( const TDesC& aBuf, CCodData& aData )
    {
    CLOG(( EParse, 2, _L("-> TCodParser::ParseL") ));
    CDUMP(( EParse, 2, _S("Buf:"), _S("    "), \
        (const TUint8*)aBuf.Ptr(), aBuf.Size() ));
    iError = KErrNone;
    iData = &aData;
    iBuf = &aBuf;
    iCurP = iBuf->Ptr();
    iEndP = iCurP + iBuf->Length();
    CMediaObjectData *mediaObject = CMediaObjectData::NewL();
    // Processing lines (attribute and value) until there is more lines to read.
    while ( AttrLineL(mediaObject) )
        {
        // Some compilers require empty controlled statement block instead of
        // just a semicolon.
        }
    iData->AppendMediaObjectL( mediaObject );   
#ifdef __TEST_COD_LOG
    TPtrC ptr16;
    TPtrC8 ptr8;
    CLOG(( EParse, 3, _L("TCodParser::ParseL data:") ));
    ptr16.Set( aData.Name() );
    CLOG(( EParse, 3, _L("  Name<%S>"), &ptr16 ));
    ptr16.Set( aData.Vendor() );
    CLOG(( EParse, 3, _L("  Vendor<%S>"), &ptr16 ));
    ptr16.Set( aData.Description() );
    CLOG(( EParse, 3, _L("  Desc<%S>"), &ptr16 ));
    CLOG(( EParse, 3, _L("  Size(%d)"), aData.Size() ));
    ptr8.Set( aData.InstallNotify() );
    CLOG(( EParse, 3, _L8("  InstNotif<%S>"), &ptr8 ));
    ptr8.Set( aData.NextUrl() );
    CLOG(( EParse, 3, _L8("  NextUrl<%S>"), &ptr8 ));
    ptr8.Set( aData.NextUrlAtError() );
    CLOG(( EParse, 3, _L8("  NextUrlAtErr<%S>"), &ptr8 ));
    ptr8.Set( aData.InfoUrl() );
    CLOG(( EParse, 3, _L8("  InfoUrl<%S>"), &ptr8 ));
    ptr16.Set( aData.Price() );
    CLOG(( EParse, 3, _L("  Price<%S>"), &ptr16 ));
    ptr8.Set( aData.Icon() );
    CLOG(( EParse, 3, _L8("  Icon<%S>"), &ptr8 ));
#endif /* def __TEST_COD_LOG */

    // NULL data for clarity. These are never used later, but don't keep
    // pointers to objects which are out of reach.
    iBuf = NULL;
    iData = NULL;
    iCurP = NULL;
    iEndP = NULL;
    User::LeaveIfError( iError );
    CLOG(( EParse, 2, _L("<- TCodParser::ParseL") ));
    }
Esempio n. 2
0
int main(void)
{
	struct diag_vcdiff *vcdiff;
	struct diag_vcdiff_context *context;
	struct diag_vcdiff_vm *vm;
	uint8_t *target;

#define HELLO_VCDIFF DIAGONAL_TEST_DIR "/vcdiff/hello.vcdiff"
	context = diag_vcdiff_context_new_path(HELLO_VCDIFF);
	if (!context) {
		return 1;
	}
	context->compatibility = 1;
	vcdiff = diag_vcdiff_read(context);
	if (!vcdiff) {
		return 2;
	}
	assert(vcdiff->num_windows == 1);
#define CDUMP(x) printf("context->" #x ": %d\n", context->x)
	CDUMP(compatibility);
#undef CDUMP
#define VDUMP(x) printf("vcdiff->" #x ": %d\n", vcdiff->x)
	VDUMP(version);
	VDUMP(indicator);
	VDUMP(compressor_id);
	VDUMP(length_code_table_data);
#undef VDUMP
#define WDUMP(x) printf("vcdiff->windows[0]->" #x ": %d\n", vcdiff->windows[0]->x)
	WDUMP(indicator);
	WDUMP(length_source_segment);
	WDUMP(position_source_segment);
#undef WDUMP
#define DDUMP(x) printf("vcdiff->windows[0]->delta->" #x ": %d\n", vcdiff->windows[0]->delta->x)
	DDUMP(length);
	DDUMP(s_window);
	DDUMP(indicator);
	DDUMP(length_data);
	DDUMP(length_inst);
	DDUMP(length_addr);
#undef DDUMP
	vm = diag_vcdiff_vm_new_path(HELLO_VCDIFF);
	target = diag_vcdiff_decode(vm, vcdiff);
	assert(target && vm->s_target == 14);
	assert(strncmp("hello, world.\n", (const char *)target, 14) == 0);
	diag_vcdiff_vm_destroy(vm);
	diag_vcdiff_context_destroy(context);
	return EXIT_SUCCESS;
}
Esempio n. 3
0
// ---------------------------------------------------------
// TDdParser::ParseL()
// ---------------------------------------------------------
//
void TDdParser::ParseL( const TDesC& aBuf, CCodData& aData, const TBool aIsDd2, TBool& aIsLicenseTag )
    {
    CLOG(( EParse, 2, _L("-> TDdParser::ParseL") ));
    CDUMP(( EParse, 2, _S("Buf:"), _S("    "), \
        (const TUint8*)aBuf.Ptr(), aBuf.Size() ));
    iError = KErrNone;
    iData = &aData;
    // XML Parser expects the buffer contain a BOM and be in
    // network byte order (this is hard-coded into cXmlParser).
    // We already have the buffer converted to UCS-2, native byte order, BOM
    // removed, and this cannot be changed without changing API.
    // So we have to re-add BOM and convert the buffer back to network byte
    // order. This is an annoying a waste, luckily a DD file is small
    // enough not to be significant.
    HBufC* buf = HBufC::NewLC( aBuf.Length() + 1 );
    buf->Des().Append( 0xFFFE );    // Add BOM, little endian as aBuf.
    buf->Des().Append( aBuf );      // Append buffer.
    // Now turn the whole buffer big-endian.
    TUint8* ptr = (TUint8*)buf->Ptr();
    for ( TInt i = 0; i < buf->Size(); i += 2 )
        {
        TUint8 tmp = ptr[i];
        ptr[i] = ptr[i + 1];
        ptr[i + 1] = tmp;
        }
    NW_WBXML_Dictionary_t* dictArray[ 1 ] = 
        { (NW_WBXML_Dictionary_t*)&NW_DdDummy_WBXMLDictionary };
    RNwWbxmlDictionary wbxmlDict;
    User::LeaveIfError( wbxmlDict.Initialize( 1, dictArray ) );
    CleanupClosePushL<RNwWbxmlDictionary>( wbxmlDict );

    NW_TinyDom_Handle_t domHandle;
    NW_Status_t stat;
    CNwDomDocumentNode* docNode = new (ELeave) CNwDomDocumentNode();
    CleanupStack::PushL( docNode );
    docNode->iDocNode = CXML_DOM_DocumentNode_BuildTree
        ( 
        &domHandle, 
        (NW_Byte*)buf->Ptr(), 
        (NW_Int32)buf->Size(), 
        /*encoded=*/NW_FALSE, 
        /*publicID=*/NW_DdDummy_PublicId, 
        /*extTNotStringTable=*/NW_FALSE,
        &stat
        );
    LeaveIfNwErrorL( stat );
    User::LeaveIfNull( docNode->iDocNode ); // Safety code.
    if (!aIsDd2)
	{
	  DocNodeL( docNode->iDocNode );
	}
    else
	{
	  iIsLicenseTag = EFalse;
	  ParseDd2DocNodeL( docNode->iDocNode );
	}
    CleanupStack::PopAndDestroy( 3, buf );  // docNode, close wbxmlDict, buf

#ifdef __TEST_COD_LOG
    TPtrC ptr16;
    TPtrC8 ptr8;
    CLOG(( EParse, 3, _L("TCodParser::ParseL data:") ));
    ptr16.Set( aData.Name() );
    CLOG(( EParse, 3, _L("  Name<%S>"), &ptr16 ));
    ptr16.Set( aData.Vendor() );
    CLOG(( EParse, 3, _L("  Vendor<%S>"), &ptr16 ));
    ptr16.Set( aData.Description() );
    CLOG(( EParse, 3, _L("  Desc<%S>"), &ptr16 ));
    CLOG(( EParse, 3, _L("  Size(%d)"), aData.Size() ));
    ptr8.Set( aData.InstallNotify() );
    CLOG(( EParse, 3, _L8("  InstNotif<%S>"), &ptr8 ));
    ptr8.Set( aData.NextUrl() );
    CLOG(( EParse, 3, _L8("  NextUrl<%S>"), &ptr8 ));
    ptr8.Set( aData.NextUrlAtError() );
    CLOG(( EParse, 3, _L8("  NextUrlAtErr<%S>"), &ptr8 ));
    ptr8.Set( aData.InfoUrl() );
    CLOG(( EParse, 3, _L8("  InfoUrl<%S>"), &ptr8 ));
    ptr16.Set( aData.Price() );
    CLOG(( EParse, 3, _L("  Price<%S>"), &ptr16 ));
    ptr8.Set( aData.Icon() );
    CLOG(( EParse, 3, _L8("  Icon<%S>"), &ptr8 ));

//TODO add logs for OMA 2
#endif /* def __TEST_COD_LOG */
	
	//If there are no media objects present to download, 
    if( !iData->Count() )
    	{
    	User::Leave( KErrCodInvalidDescriptor );	
    	}
    	
    // NULL data for clarity. These are never used later, but don't keep
    // pointers to objects which are out of reach.
    iData = NULL;
    User::LeaveIfError( iError );
    aIsLicenseTag = iIsLicenseTag;
    CLOG(( EParse, 2, _L("<- TDdParser::ParseL") ));
    }