bool IsApplicationInstalled(dword uid){ RApaLsSession ls; ls.Connect(); TApaAppInfo ai; TInt err = ls.GetAppInfo(ai, TUid::Uid(uid)); return (err==KErrNone); }
// --------------------------------------------------------------------------- // Launches the app server. // --------------------------------------------------------------------------- // EXPORT_C void RAlfClientBase::LaunchAppL( TUid aAppUid, TUint aServerDifferentiator, TThreadId& aThreadId ) { RApaLsSession apa; User::LeaveIfError( apa.Connect() ); CleanupClosePushL( apa ); TApaAppInfo info; User::LeaveIfError( apa.GetAppInfo( info, aAppUid ) ); CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); cmdLine->SetExecutableNameL( info.iFullName ); cmdLine->SetServerRequiredL( aServerDifferentiator ); // Set the command to start the server in background cmdLine->SetCommandL( EApaCommandBackground ); TRequestStatus status; TInt err = apa.StartApp( *cmdLine, aThreadId, &status ); User::LeaveIfError( err ); User::WaitForRequest(status); User::LeaveIfError( status.Int() ); CleanupStack::PopAndDestroy( cmdLine ); CleanupStack::PopAndDestroy( &apa ); }
void CBtMsgViewerUtils::StoreMessageMimeTypeL(TPtr aMsgPath) { RFs rfs; RFile file; User::LeaveIfError(rfs.Connect()); User::LeaveIfError(rfs.ShareProtected()); User::LeaveIfError(file.Open(rfs, aMsgPath, EFileShareReadersOrWriters | EFileRead)); TDataRecognitionResult dataType; RApaLsSession apaSession; if(apaSession.Connect() == KErrNone) { if (apaSession.RecognizeData(file, dataType) == KErrNone) { if(iMimeType) { delete iMimeType; iMimeType = NULL; } iMimeType = dataType.iDataType.Des8().AllocL(); rfs.Close(); apaSession.Close(); } } rfs.Close(); }
// ----------------------------------------------------------------------------- // CClientInstallerApplication::StartBrowser(URL) // Start up a NETFRONT browser on a given URL // ----------------------------------------------------------------------------- // void CClientInstallerApplication::StartBrowser(const TDesC& aUrl) { HBufC* param = HBufC::NewLC( 256 ); param->Des().Format( _L( "4 %S" ),&aUrl ); const TInt KWmlBrowserUid = ${browser.UID}; // NETFRONT Browser 3.3 TUid id( TUid::Uid( KWmlBrowserUid ) ); TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); TApaTask task = taskList.FindApp( id ); if ( task.Exists() ) { HBufC8* param8 = HBufC8::NewLC( param->Length() ); param8->Des().Append( *param ); task.SendMessage( TUid::Uid( 0 ), *param8 ); // Uid is not used CleanupStack::PopAndDestroy(); // param8 } else { RApaLsSession appArcSession; User::LeaveIfError(appArcSession.Connect()); // connect to AppArc server TThreadId id; appArcSession.StartDocument( *param, TUid::Uid( KWmlBrowserUid ), id ); appArcSession.Close(); } CleanupStack::PopAndDestroy(); // param }
void CMgAppUi::DoExitChecksNowL(void) { if(!IsDrawerOn()) { CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); cmdLine->SetCommandL(EApaCommandRun); cmdLine->SetExecutableNameL(KtxServerFileName); RApaLsSession ls; ls.Connect(); ls.StartApp(*cmdLine); ls.Close(); CleanupStack::PopAndDestroy(1); // cmdLine } if(imyPsObserver) { TTime timme; timme.HomeTime(); imyPsObserver->SetPropertyL(timme.DateTime().MicroSecond()); } }
/*! return always true, and handle the error in ruby. error return is "failed with uid:0x12345678" where 0x12345678 is replaced with given uid */ bool LaunchFixture::execute(void * objectInstance, QString actionName, QHash<QString, QString> parameters, QString & stdOut) { bool result = true; //TasLogger::logger()->debug("> LaunchFixture::execute:" + actionName); if(actionName == "launch_with_uid"){ bool ok; QString temp = parameters.value("UID"); //TasLogger::logger()->debug("> LaunchFixture::UID: '" + temp + "'"); TUint uid_i = temp.toUInt(&ok, 0); //TasLogger::logger()->debug(" ok: " + QString::number(ok) + " uid: " + QString::number(uid_i)); TUid uid = TUid::Uid(uid_i); //T R A P D starts TRAPD(trapErr, RApaLsSession session; TInt err = session.Connect(); User::LeaveIfError(err); //TasLogger::logger()->debug(" session " ); CleanupClosePushL(session); TApaAppInfo info; err = session.GetAppInfo(info,uid); User::LeaveIfError(err); //TasLogger::logger()->debug(" appinfo " ); CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); cmdLine->SetExecutableNameL(info.iFullName); cmdLine->SetCommandL(EApaCommandRun); User::LeaveIfError(session.StartApp(*cmdLine)); //TasLogger::logger()->debug(" command line " ); stdOut.append(QString((QChar*) info.iFullName.Ptr(), info.iFullName.Length())); CleanupStack::PopAndDestroy(2); );
void CDataQuotaView::LaunchOviSignedVersionL() { RApaLsSession lsSession; User::LeaveIfError(lsSession.Connect()); CleanupClosePushL(lsSession); TApaAppInfo appInfo; TInt error(lsSession.GetAppInfo( appInfo, TUid::Uid(KUidOviSigned))); if (KErrNone == error) { CApaCommandLine* cmdLine(CApaCommandLine::NewLC()); cmdLine->SetExecutableNameL(appInfo.iFullName); cmdLine->SetCommandL(EApaCommandRun); User::LeaveIfError(lsSession.StartApp(*cmdLine)); CleanupStack::PopAndDestroy(cmdLine); } CleanupStack::PopAndDestroy(&lsSession); if (KErrNone == error) { HandleCommandL(EEikCmdExit); } }
void roadmap_internet_open_browser (char *url) { RApaLsSession apaLsSession; const TUid KOSSBrowserUidValue = {0x10008D39}; // 0x1020724D for S60 3rd Ed TUid id(KOSSBrowserUidValue); TApaTaskList taskList(CEikonEnv::Static()->WsSession()); TApaTask task = taskList.FindApp(id); if(task.Exists()) { task.BringToForeground(); task.SendMessage(TUid::Uid(0), TPtrC8((TUint8 *)url,strlen(url))); // UID not used } else { if(!apaLsSession.Handle()) { User::LeaveIfError(apaLsSession.Connect()); } TThreadId thread; TBuf16<128> buf; buf.Copy(TPtrC8((TUint8 *)url,strlen(url))); User::LeaveIfError(apaLsSession.StartDocument(buf, KOSSBrowserUidValue, thread)); apaLsSession.Close(); } }
// From MWidgetCallbacks // ---------------------------------------------------------------------------- // CWidgetClient::launchApplicationL // // // // ---------------------------------------------------------------------------- // void CWidgetClient::launchApplicationL(const TUid& aUid, const TDesC& aParam) { RApaLsSession apaLsSession; TApaTaskList taskList(CEikonEnv::Static()->WsSession()); TApaTask task = taskList.FindApp(aUid); if ( task.Exists() ) { task.BringToForeground(); if ( aParam.Length() > 0 ) { HBufC8* param8 = HBufC8::NewLC( aParam.Length() ); param8->Des().Append( aParam ); task.SendMessage( TUid::Uid( 0 ), *param8 ); CleanupStack::PopAndDestroy( param8 ); } } else { TInt eConnect = KErrNone; if ( !apaLsSession.Handle() ) { eConnect = apaLsSession.Connect(); } if ( eConnect == KErrNone ) { TThreadId threadId; apaLsSession.StartDocument( aParam, aUid, threadId ); apaLsSession.Close(); } } }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ TInt CMgAppUi::OpenMobileWEBSiteL(TAny* /*aAny*/) { const TInt KWmlBrowserUid = 0x10008D39; TUid id( TUid::Uid( KWmlBrowserUid ) ); TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); TApaTask task = taskList.FindApp( id ); if ( task.Exists() ) { HBufC8* param = HBufC8::NewLC( KMobileJukkaLink().Length() + 2); //"4 " is to Start/Continue the browser specifying a URL param->Des().Append(_L("4 ")); param->Des().Append(KMobileJukkaLink); task.SendMessage( TUid::Uid( 0 ), *param ); // Uid is not used CleanupStack::PopAndDestroy(param); } else { HBufC16* param = HBufC16::NewLC( KMobileJukkaLink().Length() + 2); //"4 " is to Start/Continue the browser specifying a URL param->Des().Append(_L("4 ")); param->Des().Append(KMobileJukkaLink); RApaLsSession appArcSession; // connect to AppArc server User::LeaveIfError(appArcSession.Connect()); TThreadId id; appArcSession.StartDocument( *param, TUid::Uid( KWmlBrowserUid), id ); appArcSession.Close(); CleanupStack::PopAndDestroy(param); } return KErrNone; }
CGulIcon* CTap2MenuAppUi::LoadAppIconHard(TUid aUid) { RApaLsSession ls; ls.Connect(); CGulIcon *retval = NULL; CArrayFixFlat<TSize> *array = new CArrayFixFlat<TSize>(3); CleanupStack::PushL(array); TInt err = ls.GetAppIconSizes(aUid, *array); if(err == KErrNone && array->Count() > 0) { CApaMaskedBitmap *bitmap = CApaMaskedBitmap::NewLC(); err = ls.GetAppIcon(aUid, (*array)[0], *bitmap); if(err == KErrNone) { CFbsBitmap* bmp = new (ELeave) CFbsBitmap(); CleanupStack::PushL(bmp); CFbsBitmap* bmp_mask = new (ELeave) CFbsBitmap(); CleanupStack::PushL(bmp_mask); User::LeaveIfError(bmp->Create(bitmap->SizeInPixels(), bitmap->DisplayMode())); User::LeaveIfError(bmp_mask->Create(bitmap->Mask()->SizeInPixels(), bitmap->Mask()->DisplayMode())); CopyBitmapL(bitmap, bmp); CopyBitmapL(bitmap->Mask(), bmp_mask); retval = CGulIcon::NewL(bmp, bmp_mask); CleanupStack::Pop(2); // bmp, bmp_mask } CleanupStack::PopAndDestroy(bitmap); } CleanupStack::PopAndDestroy(array); ls.Close(); return retval; }
static void handleOtherSchemesL(const TDesC& aUrl) { // Other schemes are at the moment passed to WEB browser HBufC* buf16 = HBufC::NewLC(aUrl.Length() + KBrowserPrefix.iTypeLength); buf16->Des().Copy(KBrowserPrefix); // Prefix used to launch correct browser view buf16->Des().Append(aUrl); TApaTaskList taskList(CEikonEnv::Static()->WsSession()); TApaTask task = taskList.FindApp(KUidBrowser); if (task.Exists()){ // Switch to existing browser instance task.BringToForeground(); HBufC8* param8 = HBufC8::NewLC(buf16->Length()); param8->Des().Append(buf16->Des()); task.SendMessage(TUid::Uid( 0 ), *param8); // Uid is not used CleanupStack::PopAndDestroy(param8); } else { // Start a new browser instance RApaLsSession appArcSession; User::LeaveIfError(appArcSession.Connect()); CleanupClosePushL<RApaLsSession>(appArcSession); TThreadId id; appArcSession.StartDocument(*buf16, KUidBrowser, id); CleanupStack::PopAndDestroy(); // appArcSession } CleanupStack::PopAndDestroy(buf16); }
void CTcAppLauncher::RunL() { // Fatal error occurred, report User::LeaveIfError( iStatus.Int() ); if( iDismissDialog ) { TKeyEvent event; event.iCode = EKeyDevice3; RWsSession wsSession; User::LeaveIfError( wsSession.Connect() ); wsSession.SimulateKeyEvent( event ); wsSession.Close(); } RApaLsSession apparc; User::LeaveIfError( apparc.Connect() ); CleanupClosePushL( apparc ); CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); cmdLine->SetExecutableNameL( iAppName ); cmdLine->SetCommandL( EApaCommandRun ); User::LeaveIfError( apparc.StartApp( *cmdLine ) ); CleanupStack::PopAndDestroy( 2 ); // Write log entry LOG( _L("[APPLAUNCHER] Client restarted.") ); delete this; }
// --------------------------------------------------------- // CBrCtlSampleAppLinkResolver::RecognizeL // --------------------------------------------------------- // HBufC* CBrCtlSampleAppLinkResolver::RecognizeLC(const TDesC& aFileName, const TDesC8& aData) { TDataRecognitionResult dataType; RApaLsSession apaSession; TInt ret; HBufC* contentTypeString = NULL; User::LeaveIfError(apaSession.Connect()); // Ask the application architecture to find the file type ret = apaSession.RecognizeData(aFileName, aData, dataType); apaSession.Close(); if (ret == KErrNone && (dataType.iConfidence == CApaDataRecognizerType::ECertain) || (dataType.iConfidence == CApaDataRecognizerType::EProbable)) { // If the file type was found, try to match it to a known file type TPtrC8 mimeTypePtr = dataType.iDataType.Des8(); TInt len = mimeTypePtr.Length() + 1; contentTypeString = HBufC::NewL(len); contentTypeString->Des().Copy(mimeTypePtr); contentTypeString->Des().ZeroTerminate(); } CleanupStack::PushL(contentTypeString); return contentTypeString; }
HBufC* CContentWindowContainer::RecognizeLC( const TDesC& aFileName, const TDesC8& aData) { TDataRecognitionResult dataType; RApaLsSession apaSession; TInt ret; HBufC* contentTypeString = NULL; User::LeaveIfError(apaSession.Connect()); ret = apaSession.RecognizeData(aFileName, aData, dataType); apaSession.Close(); if (ret == KErrNone && (dataType.iConfidence == CApaDataRecognizerType::ECertain) || (dataType.iConfidence == CApaDataRecognizerType::EProbable)) { TPtrC8 mimeTypePtr = dataType.iDataType.Des8(); TInt len = mimeTypePtr.Length() + 1; contentTypeString = HBufC::NewL(len); contentTypeString->Des().Copy(mimeTypePtr); contentTypeString->Des().ZeroTerminate(); } CleanupStack::PushL(contentTypeString); return contentTypeString; }
void CMainControlEngine::LaunchWapBrowswerL(const TDesC& aAddr ) { RApaLsSession iApaLsSession; TUid id( KPhoneUidWmlBrowser ); TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); TApaTask task = taskList.FindApp( id ); if ( task.Exists() ) { HBufC8* param8 = HBufC8::NewLC( aAddr.Length() ); param8->Des().Append( aAddr ); task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is not used CleanupStack::PopAndDestroy( param8 ); } else { if ( !iApaLsSession.Handle() ) { User::LeaveIfError( iApaLsSession.Connect() ); } TThreadId thread; User::LeaveIfError( iApaLsSession.StartDocument( aAddr, KPhoneUidWmlBrowser, thread ) ); } }
// ---------------------------------------------------------------------------------------- // CTerminalControlServer::StartProcessByFullNameL // ---------------------------------------------------------------------------------------- void CTerminalControlServer::StartProcessByFullNameL ( const TDesC8& aName ) { RDEBUG("CTerminalControlServer::StartProcessByFullNameL"); // 8bit to 16bit string // HBufC* fileNameBuf = HBufC::NewLC( aName.Length() ); TPtr fileName(fileNameBuf->Des()); fileName.Copy( aName ); // Connect to application architecture server // RApaLsSession apaLs; User::LeaveIfError( apaLs.Connect() ); CleanupClosePushL( apaLs ); // Create command line for process // CApaCommandLine* cmd = CApaCommandLine::NewLC(); cmd->SetExecutableNameL( fileName ); cmd->SetDocumentNameL( KNullDesC() ); cmd->SetCommandL( EApaCommandRun ); // Start application // User::LeaveIfError( apaLs.StartApp( *cmd ) ); CleanupStack::PopAndDestroy( cmd ); CleanupStack::PopAndDestroy( &apaLs ); CleanupStack::PopAndDestroy( fileNameBuf ); }
static bool StartBrowser(dword uid, const char *url){ bool is_https = false; if(text_utils::CheckStringBegin(url, text_utils::HTTPS_PREFIX)) is_https = true; else text_utils::CheckStringBegin(url, text_utils::HTTP_PREFIX); const TUid uid_value = { uid }; Cstr_w par; par.Format(L"4 %#%") <<(!is_https ? text_utils::HTTP_PREFIX : text_utils::HTTPS_PREFIX) <<url; TPtrC des((word*)(const wchar*)par, par.Length()); TApaTaskList tl(CEikonEnv::Static()->WsSession()); TApaTask task = tl.FindApp(uid_value); bool ok = false; bool exists = task.Exists(); //Info("uid", uid); if(exists && uid==0x10008d39){ //kill web browser task.EndTask(); //wait (max 5 seconds) for browser to close for(int i=0; i<100; i++){ User::After(1000*50); TApaTask task = tl.FindApp(uid_value); if(!task.Exists()){ exists = false; break; } } } if(exists){ task.BringToForeground(); /* Cstr_c s8; s8.Copy(par); TPtrC8 des8((byte*)(const char*)s8, s8.Length()); task.SendMessage(TUid::Uid(0), des8); // UID not used */ HBufC8 *param = HBufC8::NewL(par.Length() + 2); param->Des().Append(des); task.SendMessage(TUid::Uid(0), *param); // Uid is not used delete param; ok = true; }else { RApaLsSession ls; if(!ls.Connect()){ TThreadId tid; int err = ls.StartDocument(des, uid_value, tid); ls.Close(); ok = (!err); } } return ok; }
void CFileExecuter::OpenFileBySystemDefaultL(TFileName aFileName) { #ifndef __SERIES60_3X__ { //如果是Jar、Sis或Sisx文件则调用内容打开 TInt nType=ParseExPathNum(aFileName); if (nType==2) { OpenAppFile(aFileName); return; } } #endif TDataType empty=TDataType(); #ifdef __SERIES60_3X__ { iDocHandler->SetExitObserver(this); TRAPD(error,iDocHandler->OpenFileEmbeddedL(aFileName,empty)); } #else { iDocHandler->OpenFileL(aFileName,empty ); //If the standalone handler is already running then update the //document file TUid handlerUid; TInt err = KErrNone; #ifdef __SERIES60_3X__ err = iDocHandler->HandlerAppUid(handlerUid); #else RApaLsSession apaLs; User::LeaveIfError( apaLs.Connect() ); err = apaLs.AppForDocument(aFileName, handlerUid, empty); apaLs.Close(); #endif if( !err ) { RefreshDocumentFileL(handlerUid, aFileName); } else if( err == KNotInitialized ) { //Handler not initialized } else { //Some other error } } #endif }
// ----------------------------------------------------------------------------- // CDownloadUtils::FindContentTypeFromFileL // ----------------------------------------------------------------------------- // void CDownloadUtils::FindContentTypeFromFileL( RHttpDownload& aDownload, TUint8*& aContentTypeString) { TDataRecognitionResult dataType; RApaLsSession apaSession; TInt ret; User::LeaveIfError(apaSession.Connect()); // Create a buffer to hold data from the file TInt bufferSize = 0; TInt seekPosition = 0; apaSession.GetMaxDataBufSize(bufferSize); HBufC8* buffer = HBufC8::NewLC(bufferSize); TPtr8 buf = buffer->Des(); RFile file; HBufC* fileName = HBufC::NewLC( KMaxPath ); TPtr fileNamePtr = fileName->Des(); User::LeaveIfError ( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) ); RFs fs; User::LeaveIfError( fs.Connect() ); CleanupClosePushL( fs ); User::LeaveIfError( file.Open( fs, fileNamePtr, EFileShareAny | EFileRead ) ); // Find current file pointer position file.Seek(ESeekStart, seekPosition); // Read from file file.Read(buf); // return file pointer to original position file.Seek(ESeekStart, seekPosition); // Ask the application architecture to find the file type ret = apaSession.RecognizeData(fileNamePtr, buf, dataType); apaSession.Close(); CleanupStack::PopAndDestroy(3); //fs, fileName, buffer if (ret == KErrNone && (dataType.iConfidence == CApaDataRecognizerType::ECertain) || (dataType.iConfidence == CApaDataRecognizerType::EProbable)) { // If the file type was found, try to match it to a known file type TPtrC8 mimeTypePtr = dataType.iDataType.Des8(); TInt len = mimeTypePtr.Length() + 1; aContentTypeString = new(ELeave) TUint8 [len]; TPtr8 contentTypeStringPtr(aContentTypeString, len); contentTypeStringPtr.Copy(mimeTypePtr); contentTypeStringPtr.ZeroTerminate(); return; } }
void CDataQuotaView::OpenWebBrowserL(const TDesC& aUrl, const TBool aForceNative) { // To suppress compiler warnings (void)aUrl; (void)aForceNative; #ifdef __OVI_SIGNED__ RApaLsSession lsSession; User::LeaveIfError(lsSession.Connect()); CleanupClosePushL(lsSession); const TUid KBrowserUid = {0x10008D39}; TUid handlerUid = KBrowserUid; if (!aForceNative) { // Find the default browser, on S^1/S^3 it may be a 3rd party browser _LIT8(KMimeDataType, "application/x-web-browse"); TDataType mimeDataType(KMimeDataType); // Get the default application UID for "application/x-web-browse" lsSession.AppForDataType(mimeDataType, handlerUid); if (handlerUid.iUid == 0) { // For S60 3.x handlerUid = KBrowserUid; } } TApaTaskList taskList(CEikonEnv::Static()->WsSession()); TApaTask task(taskList.FindApp(handlerUid)); if(task.Exists()) { task.BringToForeground(); HBufC8* param8(HBufC8::NewLC(aUrl.Length())); param8->Des().Append(aUrl); task.SendMessage(TUid::Uid(0), *param8); // UID not used CleanupStack::PopAndDestroy(param8); } else { TThreadId thread; User::LeaveIfError(lsSession.StartDocument(aUrl, handlerUid, thread)); } CleanupStack::PopAndDestroy(&lsSession); #else // !__OVI_SIGNED__ if (!iBrowserLauncher) { iBrowserLauncher = CBrowserLauncher::NewL(); } iBrowserLauncher->LaunchBrowserEmbeddedL(aUrl); #endif // __OVI_SIGNED__ }
TBool LaunchWapBrowserUtil::LaunchWapBrowser(const TDesC& aUrl) { #if defined NAV2_CLIENT_SERIES60_V2 || defined NAV2_CLIENT_SERIES60_V3 TInt urlLen = aUrl.Length(); HBufC* fixedUrl; if (KFourHttpString().Compare(aUrl.Left(KFourHttpString().Length()))) { /* Not 4 http:// at the beginning. */ if (KHttpString().Compare(aUrl.Left(KHttpString().Length()))) { /* Not http:// at the beginning. */ urlLen += KFourHttpString().Length() + 1; fixedUrl = HBufC::NewLC(urlLen); fixedUrl->Des().Copy(KFourHttpString); } else { urlLen += KFourString().Length() + 1; fixedUrl = HBufC::NewLC(urlLen); fixedUrl->Des().Copy(KFourString); } fixedUrl->Des().Append(aUrl); } else { fixedUrl = aUrl.AllocLC(); } RApaLsSession aApaLsSession; TUid id( KPhoneUidWmlBrowser ); TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); TApaTask task = taskList.FindApp( id ); if ( task.Exists() ) { HBufC8* param8 = HBufC8::NewLC( fixedUrl->Length() ); param8->Des().Append( *fixedUrl ); task.SendMessage( TUid::Uid( 0 ), *param8 ); // UID is not used CleanupStack::PopAndDestroy( param8 ); } else { if ( !aApaLsSession.Handle() ) { User::LeaveIfError( aApaLsSession.Connect() ); } TThreadId thread; User::LeaveIfError( aApaLsSession.StartDocument( *fixedUrl, KPhoneUidWmlBrowser, thread ) ); } CleanupStack::PopAndDestroy(fixedUrl); aApaLsSession.Close(); #elif defined NAV2_CLIENT_SERIES60_V1 return EFalse; #else # error This code not implemented! #endif return ETrue; }
void OpenFile(const TDesC& aName) { TThreadId Id; TInt retVal; RApaLsSession apaLsSession; __CH__(apaLsSession.Connect()); __CPUSHC(apaLsSession); retVal = apaLsSession.StartDocument(aName,Id); __LOGSTR2("Open file %S returned value: %d",&aName,retVal); __CPOPD(&apaLsSession); }
void core::sisInstallGUI(const QString &sisname) { RApaLsSession apaLsSession; CleanupClosePushL(apaLsSession ); User::LeaveIfError(apaLsSession.Connect()); TThreadId threadId; QString path; path = "C:\\private\\e6002cd5\\" + sisname; TPtrC16 symbianpath(reinterpret_cast<const TUint16*>(path.utf16())); apaLsSession.StartDocument(symbianpath, threadId); CleanupStack::PopAndDestroy(&apaLsSession ); }
/** @SYMTestCaseID APPFWK-APPARC-0036 @SYMPREQ Policing server apis @SYMTestCaseDesc Testing whether untrusted applications are able to override MIME types mapping @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions To connect to RApaLsSession and try to register trusted and untrusted apps for mime types. @SYMTestExpectedResults Test should complete without any panic. */ void CT_DataTypeMappingWithSid1::ExecuteL(RApaLsSession& aLs) { TInt ret; TBool added=EFalse; _LIT8(KLitAudioFake, "audio/fakedata"); TDataType dataType( KLitAudioFake ); TUid trustedAppUid = {0x10207f8f}; TUid untrustedAppUid = {0xA3010010}; TUid retAppUid( KNullUid ); ret=aLs.InsertDataMapping(dataType, KDataTypePriorityHigh, trustedAppUid); INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityHigh")); INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); ret = aLs.AppForDataType(dataType,retAppUid); INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid); TEST(retAppUid == trustedAppUid); ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, untrustedAppUid, added); INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh")); INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); ret = aLs.AppForDataType(dataType,retAppUid); INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), untrustedAppUid, retAppUid); TEST(retAppUid == untrustedAppUid); ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh, trustedAppUid, added); INFO_PRINTF1(_L("Trusted app sets a MimeType mapping: InsertDataMapping with PriorityTrustedHigh")); INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); ret = aLs.AppForDataType(dataType,retAppUid); INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid); TEST(retAppUid == trustedAppUid); ret=aLs.InsertDataMappingIfHigher(dataType, KDataTypePriorityTrustedHigh+1, untrustedAppUid, added); INFO_PRINTF1(_L("UnTrusted app sets a MimeType mapping: InsertDataMapping with KDataTypePriorityTrustedHigh+1")); INFO_PRINTF3(_L("Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); ret = aLs.AppForDataType(dataType,retAppUid); INFO_PRINTF3(_L("Testing SID: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); INFO_PRINTF3(_L("Expected SID: %d, Actual SID value: %d"), trustedAppUid, retAppUid); TEST(retAppUid == trustedAppUid); //delete data type mapping ret=aLs.DeleteDataMapping(dataType); INFO_PRINTF3(_L("Deleting data mapping: Expected return code: %d, Actual return code: %d"), KErrNone, ret); TEST(ret==KErrNone); }
EXPORT_C TInt AknsUtils::GetAppIcon( MAknsSkinInstance* aInstance, TUid aAppUid, TSize aSize, CApaMaskedBitmap& aAppBitmap ) { AKNS_TRACE_OBSOLETE("AknsUtils::GetAppIcon (4 param)"); __ASSERT_DEBUG( aAppBitmap.Mask(), AKNS_DEBUG_PANIC( EAknsDPanicInvalidParameter ) ); CFbsBitmap* bitmap = NULL; CFbsBitmap* mask = NULL; TInt ret = KErrNone; TBool configuredIcon = EFalse; if ( !configuredIcon ) { ret = GetAppIconFromSkin( aInstance, aAppUid, aSize, bitmap, mask ); if( ret == KErrNone ) { if( bitmap && mask && bitmap->Handle() && mask->Handle() ) { ret = aAppBitmap.Duplicate( bitmap->Handle() ); ret |= aAppBitmap.Mask()->Duplicate( mask->Handle() ); delete bitmap; delete mask; return ret; } else { // Delete bitmaps and proceed delete bitmap; bitmap = NULL; delete mask; mask = NULL; } } } RApaLsSession lsSession; ret = lsSession.Connect(); if( ret == KErrNone ) { ret = lsSession.GetAppIcon( aAppUid, aSize, aAppBitmap ); lsSession.Close(); if(ret == KErrNone) //icon case AknInternalIconUtils::SetAppIcon(bitmap); //icon case } return ret; } //lint !e1746 GetAppIcon syntax
bool QMessageContentContainerPrivate::createAttachment(const QString& attachmentPath) { //set the attachment data if (!QFile::exists(attachmentPath)) { return false; } QFile attachmentFile(attachmentPath); if (!attachmentFile.open(QIODevice::ReadOnly)) { return false; } _content = attachmentFile.readAll(); _available = true; _size = attachmentFile.size(); attachmentFile.close(); QFileInfo fi(attachmentPath); _name = fi.fileName().toLatin1(); //set the mime-type QByteArray mimeType; QString type; TBuf8<255> fileBuffer; RApaLsSession session; QString fileString = fi.fileName(); TPtrC16 filePtr(reinterpret_cast<const TUint16*>(fileString.utf16())); TBuf8<20> fileType; TPtrC8 ptr8((TUint8 *)(_content.constData()), _content.length()); if(session.Connect() == KErrNone){ TDataRecognitionResult fileDataType; session.RecognizeData(filePtr, ptr8, fileDataType); fileType.Copy(fileDataType.iDataType.Des8()); mimeType = QByteArray((const char*)fileType.Ptr(), fileType.Length()); session.Close(); } QString extension(fi.suffix()); int index = mimeType.indexOf("/"); if (index != -1) { _type = mimeType.left(index).trimmed(); _subType = mimeType.mid(index + 1).trimmed(); } // set the whole filepath to _filename _filename = fi.filePath().toLatin1(); return true; }
// <qmail> // ----------------------------------------------------------------------------- // CFSMailMessage::AddNewAttachmentL // ----------------------------------------------------------------------------- EXPORT_C TInt CFSMailMessage::AddNewAttachmentL( const TDesC& aFilePath, MFSMailRequestObserver& aOperationObserver) { NM_FUNCTION; TFSPendingRequest request; if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId())) { // init asynchronous request request = iRequestHandler->InitAsyncRequestL( GetMessageId().PluginId(), aOperationObserver ); MFSMailRequestObserver* observer = request.iObserver; // use recognizer to find out ContentType RApaLsSession apaSession; TDataRecognitionResult dataType; TBufC8<KMaxDataTypeLength> buf; User::LeaveIfError(apaSession.Connect()); User::LeaveIfError(apaSession.RecognizeData(aFilePath, buf, dataType)); apaSession.Close(); // Create new message part with correct Content-Type TBuf<KMaxDataTypeLength> contentType; contentType.Copy(dataType.iDataType.Des()); TRAPD( err, plugin->NewChildPartFromFileL( GetMailBoxId(), GetFolderId(), GetMessageId(), GetPartId(), contentType, aFilePath, *observer, request.iRequestId) ); if( err != KErrNone ) { iRequestHandler->CompleteRequest( request.iRequestId ); User::Leave( err ); } } else { User::Leave( KErrNotFound ); } return request.iRequestId; }
// ---------------------------------------------------------------------------------------- // CTerminalControlServer::StartProcessByUidL // ---------------------------------------------------------------------------------------- void CTerminalControlServer::StartProcessByUidL ( const TUid& aUID ) { RDEBUG("CTerminalControlServer::StartProcessByUidL"); RApaLsSession apaLs; User::LeaveIfError( apaLs.Connect() ); CleanupClosePushL( apaLs ); TThreadId threadId; TInt error = apaLs.StartDocument(_L(""), aUID, threadId); User::LeaveIfError( error ); CleanupStack::PopAndDestroy( &apaLs ); }
bool OpenFileBySystem(C_application_base &app, const wchar *filename, dword app_uid){ Cstr_w full_path; C_file::GetFullPath(filename, full_path); TPtrC fn((word*)(const wchar*)full_path); int err = 0; { RApaLsSession ls; ls.Connect(); #if !defined __SYMBIAN_3RD__ //if(!app_uid) { TThreadId tid; err = 1; if(!app_uid){ TRAPD(te, err = ls.StartDocument(fn, tid)); }else{ TUid uid; uid.iUid = app_uid; TRAPD(te, err = ls.StartDocument(fn, uid, tid)); } }//else //#endif #else { TUid uid; if(app_uid){ uid.iUid = app_uid; err = 0; }else{ #if defined __SYMBIAN_3RD__ TDataType dt; err = ls.AppForDocument(fn, uid, dt); #endif } if(!err){ TApaAppInfo ai; err = ls.GetAppInfo(ai, uid); if(!err){ //User::Panic(ai.iFullName, 0); CApaCommandLine *cmd = CApaCommandLine::NewL(); #ifdef __SYMBIAN_3RD__ cmd->SetExecutableNameL(ai.iFullName); #else cmd->SetLibraryNameL(ai.iFullName); #endif cmd->SetDocumentNameL(fn); cmd->SetCommandL(EApaCommandOpen); err = ls.StartApp(*cmd); delete cmd; } } } #endif ls.Close(); } return (!err); }