QString QDesktopServices::storageLocation(StandardLocation type) { TFileName path; switch (type) { case DesktopLocation: qWarning("No desktop concept in Symbian OS"); // But lets still use some feasible default path.Append(writableDataRoot()); break; case DocumentsLocation: path.Append(writableDataRoot()); break; case FontsLocation: path.Append(KFontsDir); break; case ApplicationsLocation: path.Append(exeDrive().Name()); path.Append(KSysBin); break; case MusicLocation: path.Append(writableDataRoot()); path.Append(PathInfo::SoundsPath()); break; case MoviesLocation: path.Append(writableDataRoot()); path.Append(PathInfo::VideosPath()); break; case PicturesLocation: path.Append(writableDataRoot()); path.Append(PathInfo::ImagesPath()); break; case TempLocation: return QDir::tempPath(); break; case HomeLocation: path.Append(writableDataRoot()); //return QDir::homePath(); break; break; case DataLocation: qt_s60GetRFs().PrivatePath(path); path.Insert(0, writableExeDrive().Name()); break; case CacheLocation: qt_s60GetRFs().PrivatePath(path); path.Insert(0, writableExeDrive().Name()); path.Append(KCacheSubDir); break; default: // Lets use feasible default path.Append(writableDataRoot()); break; } // Convert to cross-platform format and clean the path QString nativePath = QString::fromUtf16(path.Ptr(), path.Length()); QString qtPath = QDir::fromNativeSeparators(nativePath); qtPath = QDir::cleanPath(qtPath); // Note: The storage location returned can be a directory that does not exist; // i.e., it may need to be created by the system or the user. return qtPath; }
void ScrShotsGenUtils::DumpJsFileL(CScrShotsSettings* scrShotsSettings) { CGetImei* getImei = CGetImei::NewL(); CleanupStack::PushL(getImei); RBuf8 formatBuf; formatBuf.Create(256); formatBuf.CleanupClosePushL(); TFileName infoFile; User::LeaveIfError(CEikonEnv::Static()->FsSession().PrivatePath(infoFile)); infoFile.Append( KDeviceJSFile ); TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName()); infoFile.Insert(0, KCDriveWithColon); RFs fsConn; User::LeaveIfError(fsConn.Connect()); CleanupClosePushL(fsConn); RFile jsFile; if(BaflUtils::FileExists(fsConn, infoFile)){ BaflUtils::DeleteFile(fsConn, infoFile); } //now create the file User::LeaveIfError(jsFile.Create(fsConn, infoFile, EFileWrite)); CleanupClosePushL(jsFile); // User::LeaveIfError(jsFile.Write(KFunctionBlockStart)); RBuf8 values; values.Create(256); for(int i = 0; i < KDeviceParamsCount ; i++){ formatBuf.Zero(); TInt sizeOfItem = User::StringLength((TText8 *)DeviceParams [i]); TPtr8 item((unsigned char*)DeviceParams [i],sizeOfItem ,sizeOfItem ); switch(i){ //device_model case 0:{ CDeviceTypeInformation* devInfo = SysUtil::GetDeviceTypeInfoL(); CleanupStack::PushL(devInfo); TPtrC manufName, modelCode, modelName; devInfo->GetManufacturerName(manufName); devInfo->GetModelCode(modelCode); devInfo->GetModelName(modelName); RBuf8 manufName8, modelName8, modelCode8; manufName8.Create(128); modelName8.Create(128); modelCode8.Create(128); manufName8.CleanupClosePushL(); modelName8.CleanupClosePushL(); modelCode8.CleanupClosePushL(); manufName8.Copy(manufName); modelName8.Copy(modelName); modelCode8.Copy(modelCode); values.Format(KModelNameFormatString, &manufName8, &modelName8, &modelCode8); CleanupStack::PopAndDestroy(4); break; } //firmware_version case 1:{ RBuf swVersion; swVersion.Create(128); SysUtil::GetSWVersion(swVersion); values.Copy(swVersion); TInt pos = 0; while((pos = values.Find(_L8("\n"))) != KErrNotFound){ //values.Delete(pos,1); values.Replace(pos,1,_L8("_")); } swVersion.Close(); break; } //ram_info case 2:{ TInt totalram= 0; HAL::Get(HALData::EMemoryRAM, totalram); totalram /= 1024; values.Num(totalram); break; } //uptime case 3:{ TTimeIntervalMicroSeconds32 iTickPeriod; UserHal::TickPeriod(iTickPeriod); TUint tickCount = User::TickCount(); TUint noOfTicksPerSecond = (1000 * 1000) / iTickPeriod.Int(); TInt noOfSecsSinceStartUp = tickCount / noOfTicksPerSecond;//noOfMicroSecsSinceStartup / (1000 * 1000); values.Num(noOfSecsSinceStartUp); break; } //scrshot count case 4:{ values.Num(scrShotsSettings->TotalScrShotCount()); break; } //symbian version case 5:{ TVersion epocver = User::Version(); values.Copy(epocver.Name()); break; } //series 60 version case 6:{ VersionInfo::TPlatformVersion platformVersion; VersionInfo::GetVersion(platformVersion); TInt aMajor = platformVersion.iMajorVersion; TInt aMinor = platformVersion.iMinorVersion; values.Format(_L8("%d.%d"),aMajor, aMinor); break; } //country code case 7:{ TLocale loc; int code = loc.CountryCode(); values.Num(code); break; } //imei hash case 8:{ TBuf8<256> inputimei; TBuf8<256> outimeihash; if(getImei->IsImeiFetched()){ getImei->GetImei(inputimei); GetWhirlPoolHash(outimeihash,inputimei); values.Copy(outimeihash); } } break; } formatBuf.Format(KStringVariableDeclaration, &item, &values); TRACE_ON(RDebug::Printf((const char*)formatBuf.PtrZ())); jsFile.Write(formatBuf); } values.Close(); CleanupStack::PopAndDestroy(4); //TODO: This code should be commented in final release build #if BRAHMA_DEBUG //code to copy the js file just created to the c:\ so that it can be analyzed _LIT(KTargetFileName, "c:\\device_info.js"); BaflUtils::CopyFile(CEikonEnv::Static()->FsSession(),infoFile, KTargetFileName); #endif }
EXPORT_C void AknsUtils::CreateAppIconLC( MAknsSkinInstance* aInstance, TUid aAppUid, TAknsAppIconType aType, CFbsBitmap*& aBitmap, CFbsBitmap*& aMask ) { aBitmap = NULL; aMask = NULL; if (!aInstance) { User::Leave(KErrArgument); } TSize legacySize( 42, 29 ); TInt bitmapIndex( 0 ); TInt maskIndex( 1 ); if( aType == EAknsAppIconTypeContext ) { legacySize = TSize( 44, 44 ); bitmapIndex = 2; maskIndex = 3; } else if( aType != EAknsAppIconTypeList ) { User::Leave( KErrArgument ); } // Make the forthcoming pushes safe (up to level 2) CleanupStack::PushL( static_cast<TAny*>(NULL) ); CleanupStack::PushL( static_cast<TAny*>(NULL) ); CleanupStack::Pop( 2 ); // 1. Check if the icon has been configured. TInt ret = KErrNone; TBool configuredIcon = EFalse; // CAknsAppSkinInstance* apskin = static_cast<CAknsAppSkinInstance*>(aInstance); if ( apskin ) { TInt config = apskin->IsIconConfiguredL( aAppUid ); if ( config > 0 ) configuredIcon = ETrue; } if ( !configuredIcon ) { // 2. Skin-originating icon ret = GetAppIconFromSkin( aInstance, aAppUid, legacySize, aBitmap, aMask ); if( ret == KErrNone ) { // These pushes are safe CleanupStack::PushL( aBitmap ); // (1) CleanupStack::PushL( aMask ); // (2) return; } } // Cache connected apparc session for future reuse, if not already cached // This is done per appskininstance when necessary... if (!apskin->iCachedApaSession) { apskin->iCachedApaSession = new (ELeave) RApaLsSession; User::LeaveIfError(apskin->iCachedApaSession->Connect()); } RApaLsSession* lsSession = apskin->iCachedApaSession; TBool forceDefaultIcon = EFalse; TApaAppInfo appInfo; TFileName filename; // 3. New appicon framework HBufC* filenameBuf = NULL; TBool javaIcon = EFalse; ret = lsSession->GetAppIcon( aAppUid, filenameBuf ); if( filenameBuf ) { filename.Copy( *filenameBuf ); delete filenameBuf; } if( ret == KErrNone ) { ret = lsSession->GetAppInfo( appInfo, aAppUid ); } if( (ret==KErrNone) && (filename.Length()>2) && (appInfo.iFullName.Length()>2) ) { // Correct drive letter, if necessary if( appInfo.iFullName[1]==':' ) { if( filename[1]==':' ) { filename[0] = appInfo.iFullName[0]; } else if( filename[0]=='\\' ) { filename.Insert( 0, appInfo.iFullName.Left(2) ); } } // check if the icon is java icon javaIcon = AknsJavaUtils::IsJavaIcon(filename); if( AknIconUtils::IsMifFile( filename ) ) { // SVG icon // SVG always has only one icon bitmapIndex = 0; maskIndex = 1; AknIconUtils::ValidateLogicalAppIconId( filename, bitmapIndex, maskIndex ); if (javaIcon) { AknsJavaUtils::CreateIconLC(*lsSession, aAppUid, aBitmap, aMask, bitmapIndex, maskIndex ); // aBitmap, aMask (2) } else { AknIconUtils::CreateIconLC( aBitmap, aMask, filename, bitmapIndex, maskIndex ); // aBitmap, aMask (2) } AknInternalIconUtils::SetAppIcon(aBitmap); //icon case return; } else { // MBM icon AknIconUtils::ValidateLogicalAppIconId( filename, bitmapIndex, maskIndex ); TRAP( ret, AknIconUtils::CreateIconL( aBitmap, aMask, filename, bitmapIndex, maskIndex ) ); if( ret == KErrNone ) { // These pushes are safe CleanupStack::PushL( aBitmap ); // (1) CleanupStack::PushL( aMask ); // (2) } else { bitmapIndex = 0; maskIndex = 1; AknIconUtils::ValidateLogicalAppIconId( filename, bitmapIndex, maskIndex ); AknIconUtils::CreateIconLC( aBitmap, aMask, filename, bitmapIndex, maskIndex ); // aBitmap, aMask (2) } AknInternalIconUtils::SetAppIcon(aBitmap); //icon case return; } } else if( ret!=KErrNotSupported ) { // New framework, but no icon defined forceDefaultIcon = ETrue; } CApaMaskedBitmap* apaBmp = CApaMaskedBitmap::NewLC(); // apaBmp (1) // 3. Old (AIF-based) framework if( !forceDefaultIcon ) { TInt apaErr = lsSession->GetAppIcon( aAppUid, legacySize, *apaBmp ); // Use default icon if APPARC did not initialize icon bitmaps if( apaErr || (!apaBmp) || (!apaBmp->Mask()) || (!apaBmp->Handle()) || (!apaBmp->Mask()->Handle()) ) { forceDefaultIcon = ETrue; } } if( forceDefaultIcon ) { // Default icon CleanupStack::PopAndDestroy( 1 ); // apaBmp (0) TAknsItemID iid = KAknsIIDQgnMenuUnknownLst; bitmapIndex = EMbmAvkonQgn_menu_unknown_lst; maskIndex = EMbmAvkonQgn_menu_unknown_lst_mask; if( aType == EAknsAppIconTypeContext ) { iid = KAknsIIDQgnMenuUnknownCxt; bitmapIndex = EMbmAvkonQgn_menu_unknown_cxt; maskIndex = EMbmAvkonQgn_menu_unknown_cxt_mask; } AknsUtils::CreateIconLC( aInstance, iid, aBitmap, aMask, AknIconUtils::AvkonIconFileName(), bitmapIndex, maskIndex ); // aBitmap, aMask (2) } else { // AIF-based icon CFbsBitmap* iconOwnedBitmap = new (ELeave) CFbsBitmap(); CleanupStack::PushL( iconOwnedBitmap ); // iob (3) CFbsBitmap* iconOwnedMask = new (ELeave) CFbsBitmap(); CleanupStack::PushL( iconOwnedMask ); // iom (4) User::LeaveIfError( iconOwnedBitmap->Duplicate( apaBmp->Handle() ) ); User::LeaveIfError( iconOwnedMask->Duplicate( apaBmp->Mask()->Handle() ) ); CAknIcon* tmpIcon = CAknIcon::NewL(); CleanupStack::Pop( 2 ); // iom, iob (2) CleanupStack::PopAndDestroy( 1 ); // apaBmp (0) // Ownership is transferred tmpIcon->SetBitmap( iconOwnedBitmap ); tmpIcon->SetMask( iconOwnedMask ); // Ownership of tmpIcon is transferred CAknIcon* appIcon = AknIconUtils::CreateIconL( tmpIcon ); aBitmap = appIcon->Bitmap(); aMask = appIcon->Mask(); // Detach and delete appIcon->SetBitmap( NULL ); appIcon->SetMask( NULL ); delete appIcon; // These are both safe CleanupStack::PushL( aBitmap ); // (1) CleanupStack::PushL( aMask ); // (2) } }
TUid CDeploymentComponentData::ResolveUidL(RFs& aFs) { RDEBUG("CDeploymentComponentData::ResolveUidL()"); TUid ret(TUid::Null() ); HBufC* buf = HBufC::NewLC(KMaxFileName); TPtr16 ptr = buf->Des(); ptr.Copy(iDataFileName); // if PIP/DRM package, we need to use license manager to extract the sis file if (iMimeType == KPipMimeType || iMimeType == KDrmMessageMimeType || iMimeType == KDrmContentMimeType) { RDEBUG8_2(" -> mime: %S", &iMimeType ); RFile originalFile; RFile decryptedFile; TFileName decryptedTempFileName; RDEBUG_2(" -> opening original file: %S", &ptr ); // leave if can not open the original file User::LeaveIfError(originalFile.Open(aFs, ptr, EFileWrite) ); RDEBUG(" -> done"); // First construct the temp path User::LeaveIfError(aFs.PrivatePath(decryptedTempFileName) ); // set drive letter into the path decryptedTempFileName.Insert( 0, TParsePtrC( PathInfo::PhoneMemoryRootPath() ).Drive() ); // append "piptemp\\" decryptedTempFileName.Append(KTempDir); // create the folder aFs.MkDir(decryptedTempFileName); // Use license manager to extract files from the pip package CDRMLicenseManager* licenseMgr = CDRMLicenseManager::NewL(); CleanupStack::PushL(licenseMgr); // decryp from the original file into the temp file RDEBUG_2(" -> extracting SIS file into: %S", &decryptedTempFileName); User::LeaveIfError(licenseMgr->ExtractSISFileL(originalFile, decryptedTempFileName) ); RDEBUG(" -> done"); // Get the sis file name decryptedTempFileName.Append( *(licenseMgr->GetSISMemberL()->Name() )); // open temporary handle to it. RDEBUG_2(" -> opening decrypted file: %S", &decryptedTempFileName ); User::LeaveIfError(decryptedFile.Open(aFs, decryptedTempFileName, EFileShareAny) ); RDEBUG(" -> done"); // parse the uid from the file ret = ParseUidFromSisFileL(decryptedFile); // no use anymore for the decrypted file decryptedFile.Close(); // delete the temp file TInt err = aFs.Delete(decryptedTempFileName); if (err != KErrNone) { RDEBUG_2("**** ERROR, unable to delete temporary file: %S", &decryptedTempFileName ); } CleanupStack::PopAndDestroy(licenseMgr); decryptedFile.Close(); originalFile.Close(); } else if (iMimeType == KSisxMimeType || iMimeType == KSisMimeType ) { RDEBUG(" -> mime: x-epoc/x-sisx-app"); RFile originalFile; RDEBUG_2(" -> opening file: %S", &ptr ); User::LeaveIfError(originalFile.Open(aFs, ptr, EFileRead) ); RDEBUG(" -> opened ok"); ret = ParseUidFromSisFileL(originalFile); originalFile.Close(); } else { RDEBUG8_2( "**** ERROR - CDeploymentComponentData::ResolveUidL( ) - cannot get uid from mime type: %S", &iMimeType ); } CleanupStack::PopAndDestroy(buf); return ret; }