예제 #1
0
bool ScriptInterface::SetProperty_(jsval obj, const wchar_t* name, jsval value, bool constant, bool enumerate)
{
	uintN attrs = 0;
	if (constant)
		attrs |= JSPROP_READONLY | JSPROP_PERMANENT;
	if (enumerate)
		attrs |= JSPROP_ENUMERATE;

	if (! JSVAL_IS_OBJECT(obj))
		return false;
	JSObject* object = JSVAL_TO_OBJECT(obj);

	utf16string name16(name, name + wcslen(name));
	if (! JS_DefineUCProperty(m->m_cx, object, reinterpret_cast<const jschar*>(name16.c_str()), name16.length(), value, NULL, NULL, attrs))
		return false;
	return true;
}
예제 #2
0
bool ScriptInterface::SetProperty_(JS::HandleValue obj, const wchar_t* name, JS::HandleValue value, bool constant, bool enumerate)
{
	JSAutoRequest rq(m->m_cx);
	uint attrs = 0;
	if (constant)
		attrs |= JSPROP_READONLY | JSPROP_PERMANENT;
	if (enumerate)
		attrs |= JSPROP_ENUMERATE;

	if (!obj.isObject())
		return false;
	JS::RootedObject object(m->m_cx, &obj.toObject());

	utf16string name16(name, name + wcslen(name));
	if (! JS_DefineUCProperty(m->m_cx, object, reinterpret_cast<const jschar*>(name16.c_str()), name16.length(), value, NULL, NULL, attrs))
		return false;
	return true;
}
예제 #3
0
// -----------------------------------------------------------------------------
// CAsf::ParseExtendedContentDescriptionObjectL
// -----------------------------------------------------------------------------
//
void CAsf::ParseExtendedContentDescriptionObjectL()
    {
    TInt i;
    
    LOGFN( "CAsf::ParseExtendedContentDescriptionObjectL" );
    TInt offset( iExtendedContentDescriptionOffset + KObjectID );
    TUint32 objSize( ReadUint64FromBlockL( *iHeaderData, offset ) );

    if ( iHeaderData->Length() < iExtendedContentDescriptionOffset + objSize )
        {
        User::Leave( KErrOverflow );
        }

    offset += KObjectSize;
    iExtendedContentDescriptionCount = ReadUint16FromBlockL( *iHeaderData, offset );
    offset += 2;

    for ( i = 0 ; i < iExtendedContentDescriptionCount; i++ )
        {
        TInt nameLength( ReadUint16FromBlockL( *iHeaderData, offset ) );
        offset += 2;
        HBufC16* name16( HBuf16FromBlockL( *iHeaderData, offset, nameLength ) );
        offset += nameLength;
        CleanupStack::PushL( name16 );
        if( !name16->CompareF( KWMAlbumTitle ) )
            {
            iAlbumTitle = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMPicture ) )
            {
            iPicture = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMText) )
            {
            iText = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMComposer ) )
            {
            iComposer = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMGenre ) )
            {
            iGenre = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMYear ) || !name16->CompareF( KWMYear1 ) )
            {
            if ( !iYear )
                {
                iYear = ReadExtendedContentObjectL( offset );
                }
            }
        else if( !name16->CompareF( KWMOriginalArtist) )
            {
            iOriginalArtist = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMTrackNumber ) )
            {
            iTrackNumber = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMUniqueFileIdentifier ) )
            {
            iUniqueFileID = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMAudioFileURL ) )
            {
            iAudioFileUrl = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMSharedUserRating ) )
            {
            iSharedUserRating = ReadExtendedContentObjectL( offset );
            }
        else if( !name16->CompareF( KWMDate ) )
            {
            iDate = ReadExtendedContentObjectL( offset );
            }
        CleanupStack::PopAndDestroy( name16 );

        offset += 2; // data type
        TInt valueLength( ReadUint16FromBlockL( *iHeaderData, offset ) );
        offset += 2;
        offset += valueLength;
        }
    }
예제 #4
0
static bool getAppInfo(const String8& path, AppInfo& outInfo) {
    memset(&outInfo, 0, sizeof(outInfo));

    AssetManager assetManager;
    int32_t cookie = 0;
    if (!assetManager.addAssetPath(path, &cookie)) {
        return false;
    }

    Asset* asset = assetManager.openNonAsset(cookie, "AndroidManifest.xml", Asset::ACCESS_BUFFER);
    if (asset == NULL) {
        return false;
    }

    ResXMLTree xml;
    if (xml.setTo(asset->getBuffer(true), asset->getLength(), false) != NO_ERROR) {
        delete asset;
        return false;
    }

    const String16 kAndroidNamespace("http://schemas.android.com/apk/res/android");
    const String16 kManifestTag("manifest");
    const String16 kApplicationTag("application");
    const String16 kUsesSdkTag("uses-sdk");
    const String16 kVersionCodeAttr("versionCode");
    const String16 kMultiArchAttr("multiArch");
    const String16 kMinSdkVersionAttr("minSdkVersion");

    ResXMLParser::event_code_t event;
    while ((event = xml.next()) != ResXMLParser::BAD_DOCUMENT &&
            event != ResXMLParser::END_DOCUMENT) {
        if (event != ResXMLParser::START_TAG) {
            continue;
        }

        size_t len;
        const char16_t* name = xml.getElementName(&len);
        String16 name16(name, len);
        if (name16 == kManifestTag) {
            ssize_t idx = xml.indexOfAttribute(
                    kAndroidNamespace.string(), kAndroidNamespace.size(),
                    kVersionCodeAttr.string(), kVersionCodeAttr.size());
            if (idx >= 0) {
                outInfo.versionCode = xml.getAttributeData(idx);
            }

        } else if (name16 == kApplicationTag) {
            ssize_t idx = xml.indexOfAttribute(
                    kAndroidNamespace.string(), kAndroidNamespace.size(),
                    kMultiArchAttr.string(), kMultiArchAttr.size());
            if (idx >= 0) {
                outInfo.multiArch = xml.getAttributeData(idx) != 0;
            }

        } else if (name16 == kUsesSdkTag) {
            ssize_t idx = xml.indexOfAttribute(
                    kAndroidNamespace.string(), kAndroidNamespace.size(),
                    kMinSdkVersionAttr.string(), kMinSdkVersionAttr.size());
            if (idx >= 0) {
                uint16_t type = xml.getAttributeDataType(idx);
                if (type >= Res_value::TYPE_FIRST_INT && type <= Res_value::TYPE_LAST_INT) {
                    outInfo.minSdkVersion = xml.getAttributeData(idx);
                } else if (type == Res_value::TYPE_STRING) {
                    String8 minSdk8(xml.getStrings().string8ObjectAt(idx));
                    char* endPtr;
                    int minSdk = strtol(minSdk8.string(), &endPtr, 10);
                    if (endPtr != minSdk8.string() + minSdk8.size()) {
                        fprintf(stderr, "warning: failed to parse android:minSdkVersion '%s'\n",
                                minSdk8.string());
                    } else {
                        outInfo.minSdkVersion = minSdk;
                    }
                } else {
                    fprintf(stderr, "warning: unrecognized value for android:minSdkVersion.\n");
                }
            }
        }
    }

    delete asset;
    return true;
}