// ---------------------------------------------------------
// 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;
    }
Exemplo n.º 2
0
 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();   
 		  }
 }
Exemplo n.º 3
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
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;
}
Exemplo n.º 4
0
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();
    }
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;
}
Exemplo n.º 6
0
TBool ScrShotsGenUtils::CheckIfAppExists(const TDesC& aAppName, const TUid& aAppUid)
{
    TBool appFound = EFalse;
    RApaLsSession appLs;
    if(appLs.Connect()==KErrNone){
        appLs.GetAllApps();
        TApaAppInfo dummyAppInfo;
        while(appLs.GetNextApp(dummyAppInfo)!= RApaLsSession::ENoMoreAppsInList){
            if(dummyAppInfo.iShortCaption[0] == '!' || dummyAppInfo.iShortCaption.Length() == 0)
                continue;
            TStringPoolObj fullName(512);
            fullName.Des().Copy(dummyAppInfo.iFullName);
            fullName.Des().LowerCase();
            //we dont want to show Brahma in the app list.
            if(dummyAppInfo.iUid == KBrahmaUid)
                continue;
            //filtering out midlets (.fakeapp) & wrt widgets (.html)
            if(fullName.Des().Find(_L(".fakeapp")) != KErrNotFound || fullName.Des().Find(_L(".html")) != KErrNotFound)
                continue;
            TApaAppCapabilityBuf appCap;
            if(appLs.GetAppCapability(appCap, dummyAppInfo.iUid) == KErrNone){
                //if its hidden its a ui app 
                if(appCap().iAppIsHidden || appCap().iAttributes == TApaAppCapability::EControlPanelItem)
                    continue;
            }
            if(dummyAppInfo.iCaption.Compare(aAppName) == 0 &&  dummyAppInfo.iUid == aAppUid){
                appFound = ETrue;
                break;
            }
        }
        appLs.Close();
    }
    return appFound;
}
Exemplo n.º 7
0
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());
	}	
	
}
// -----------------------------------------------------------------------------
// 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
	}
Exemplo n.º 9
0
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;
	}
Exemplo n.º 10
0
// 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();
        }
    }

}
Exemplo n.º 11
0
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);
}
Exemplo n.º 12
0
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
}
Exemplo n.º 13
0
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;
}
Exemplo n.º 14
0
// -----------------------------------------------------------------------------
// 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;
        }
}
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;
}
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;
}
Exemplo n.º 17
0
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
Exemplo n.º 18
0
// <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;
}
Exemplo n.º 19
0
// -----------------------------------------------------------------------------
// CFSMailMessage::AddNewAttachmentL
// -----------------------------------------------------------------------------
EXPORT_C CFSMailMessagePart* CFSMailMessage::AddNewAttachmentL( RFile& aFile,
                                                                const TDesC8& aMimeType )
    {
    NM_FUNCTION;
    CFSMailMessagePart* newPart(NULL);
    if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
        {
        TBuf<KMaxDataTypeLength> contentType;
        if(aMimeType.Length() > 0)
            {
            // use user given content type
            contentType.Copy(aMimeType);
            }
        else
            {
            // try to find out content type using recognizers
            RApaLsSession apaSession;
            TDataRecognitionResult dataType;
            User::LeaveIfError(apaSession.Connect());
            User::LeaveIfError(apaSession.RecognizeData(aFile, dataType));
            apaSession.Close();
            contentType.Copy(dataType.iDataType.Des());
            }
        // get file name
        TFileName fileName;
        aFile.FullName( fileName );
        // get new part from plugin
        newPart = plugin->NewChildPartFromFileL(    GetMailBoxId(),
                                                    GetFolderId(),
                                                    GetMessageId(),
                                                    GetPartId(),
                                                    contentType,
                                                    aFile );
        if (newPart)
            {
            CleanupStack::PushL(newPart);
            // set attachment name
            newPart->SetAttachmentNameL(fileName);
            // store new message part
            newPart->SaveL();
            // set flag
            SetFlag(EFSMsgFlag_Attachments);
            CleanupStack::Pop(newPart);
            }
        }
    return newPart;
    }
Exemplo n.º 20
0
//----------------------------
void OpenWebBrowser(C_application_base &app, const char *url){

#ifdef __SYMBIAN_3RD__
   /*
   RApaLsSession ls;
   if(!ls.Connect()){
      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);
      Cstr_w par;
      par.Format(L"4 %#%") <<(!is_https ? text_utils::HTTP_PREFIX : text_utils::HTTPS_PREFIX) <<url;

      TDataType mimeDatatype(_L8("application/x-web-browse"));
      TUid handlerUID;
      ls.AppForDataType(mimeDatatype, handlerUID);
      //Fatal("id", handlerUID.iUid);
      if(!handlerUID.iUid)
         handlerUID = TUid::Uid(0x1020724d);
      text_utils::CheckStringBegin(url, text_utils::HTTP_PREFIX) ||
         text_utils::CheckStringBegin(url, text_utils::HTTPS_PREFIX);

      LaunchBrowserL(TPtrC((word*)(const wchar*)par, par.Length()), handlerUID);
      ls.Close();
      return;
   }
   */
   RApaLsSession ls;
   if(!ls.Connect()){
      TUid hid;
      ls.AppForDataType(_L8("application/x-web-browse"), hid);
      ls.Close();
      //Fatal("uid", hid.iUid);
      if(hid.iUid){
         if(StartBrowser(hid.iUid, url))
            return;
      }
   }

                              //try 'Web' browser
   if(StartBrowser(0x1020724d, url))
      return;
#endif
                              //use 'Services'
   StartBrowser(0x10008d39, url);
}
Exemplo n.º 21
0
void CBrowserLauncher::LaunchBrowserWithLinkL(const TDesC& aLink) {
	TUint aMajor = 0, aMinor = 0;
	TUid aBrowserAppUid = {0x10008D39};

	// Check platform version
	GetPlatformVersionL(aMajor, aMinor);

	if(aMajor < 3 || aMajor == 3 && aMinor == 0) {
		aBrowserAppUid = TUid::Uid(0x1020724D);
	}
	
	// Create custom message
	HBufC* aMessage = HBufC::NewLC(2 + aLink.Length());
	TPtr pMessage(aMessage->Des());
	pMessage.Append(_L("4 "));
	pMessage.Append(aLink);

	// Find task
	TApaTaskList aTaskList(CEikonEnv::Static()->WsSession());
	TApaTask aTask = aTaskList.FindApp(aBrowserAppUid);

	if(aTask.Exists()) {
		aTask.BringToForeground();
		HBufC8* aMessage8 = HBufC8::NewLC(pMessage.Length());
		TPtr8 pMessage8(aMessage8->Des());
		pMessage8.Append(pMessage);

		aTask.SendMessage(TUid::Uid(0), pMessage8);
		CleanupStack::PopAndDestroy(); // aMessage8
	}
	else {
		RApaLsSession aApaLsSession;
		if(aApaLsSession.Connect() == KErrNone) {
			TThreadId aThread;
			aApaLsSession.StartDocument(pMessage, aBrowserAppUid, aThread);
			aApaLsSession.Close();
		}
	}

	CleanupStack::PopAndDestroy(); // aMessage
}
Exemplo n.º 22
0
// -----------------------------------------------------------------------------
// CFSMailMessage::AddNewAttachmentL
// -----------------------------------------------------------------------------
EXPORT_C CFSMailMessagePart* CFSMailMessage::AddNewAttachmentL(	const TDesC& aFilePath,
																const TFSMailMsgId /*aInsertBefore*/ )
    {
    NM_FUNCTION;

    CFSMailMessagePart* newPart(NULL);
  
    if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
        {
        // 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());
        newPart = plugin->NewChildPartFromFileL(  GetMailBoxId(),
                            GetFolderId(),
                            GetMessageId(),
                            GetPartId(),
                            contentType,
                            aFilePath );
        if (newPart)
            {
            CleanupStack::PushL(newPart);
            // set attachment name
            newPart->SetAttachmentNameL(aFilePath);
            // store new message part
            newPart->SaveL();
            // set flag
            SetFlag(EFSMsgFlag_Attachments);
            CleanupStack::Pop(newPart);
            }
        }
    return newPart;
}
Exemplo n.º 23
0
CGulIcon* CTap2MenuAppUi::LoadAppIconEasy(TUid aUid)
	{
	RApaLsSession ls;
	ls.Connect();
	TApaAppInfo info;
	User::LeaveIfError(ls.GetAppInfo(info,aUid));
	HBufC* path=HBufC::NewL(255);
	TInt err=ls.GetAppIcon(aUid,path);
	User::LeaveIfError(err);
	CFbsBitmap*	AppIcon(NULL);
	CFbsBitmap*	AppIconMsk(NULL);
	//MAknsSkinInstance* skin = AknsUtils::SkinInstance();
	if ((err==KErrNone)&&(path->Length()!=0))
		{AknsUtils::CreateAppIconLC(AknsUtils::SkinInstance(),aUid, EAknsAppIconTypeContext,AppIcon,AppIconMsk);}
	else {User::Leave(KErrNotFound);}
	AknIconUtils::SetSize(AppIcon,TSize(iSettings[4],iSettings[4]));
	AknIconUtils::SetSize(AppIconMsk,TSize(iSettings[4],iSettings[4]));		
	CleanupStack::Pop(2);
	CGulIcon* icon=CGulIcon::NewL(AppIcon,AppIconMsk);
	ls.Close();
	return icon;
	}
Exemplo n.º 24
0
/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TInt CExPolicy_Server::SetFileMapping(TFileMappingItem& aDataMapping)
{		
	TInt RetErr(KErrNone);
	RApaLsSession ls;
	RetErr= ls.Connect();
	if(RetErr == KErrNone)
	{
		if(aDataMapping.iUid.iUid == 0)
		{
			RetErr = ls.DeleteDataMapping(aDataMapping.iDataType);			
		}
		else
		{
			RetErr = ls.InsertDataMapping(aDataMapping.iDataType,aDataMapping.iPriority,aDataMapping.iUid);
		}
		
	}

	ls.Close();
	
	return RetErr;
}
Exemplo n.º 25
0
void NotifyProvider::openViewer(int index)
{
    TNotifType type;
    if (index==-1) type=EMissedCall;
    else if (index==-2) type=ESMS;
    else if (index>=0) type=iNotifiers[index].type;
    qDebug()<<"openViewer, thread"<<RThread().Id().Id();
    emit Unlock();
    CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
    if (type==ESMS)
    {//open sms
        TInt conversationview = 0;
        CRepository* cr=CRepository::NewL(KCRUidMuiuSettings);
        cr->Get(KMuiuMceDefaultView,conversationview);
        delete cr;
        CCoeEnv::Static()->AppUi()->CreateActivateViewEventL(KMessagingCentreView, TUid::Uid( KMsvGlobalInBoxIndexEntryIdValue),KNullDesC8 );

        //iSMS->openSMS(iNotifiers[index].id);
        //if (conversationview == 1 )
        //   {CCoeEnv::Static()->AppUi()->CreateActivateViewEventL(KConversationView, TUid::Uid( KConversationListViewid ),KNullDesC8 );}
        //else
        //   {CCoeEnv::Static()->AppUi()->CreateActivateViewEventL(KMessagingCentreView, TUid::Uid( KMsvGlobalInBoxIndexEntryIdValue ),KNullDesC8 );}
    }
    else if (type==EEmail)
    {
    RApaLsSession session;
    session.Connect();
    CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
    cmdLine->SetExecutableNameL(_L("FreestyleEmailUi.exe"));
    cmdLine->SetCommandL(EApaCommandRun);
    User::LeaveIfError( session.StartApp(*cmdLine) );
    CleanupStack::PopAndDestroy(cmdLine);
    session.Close();
    }
    else if (type==EMissedCall)
    {//open calls
        LogsUiCmdStarter::CmdStartL( LogsUiCmdStarterConsts::KMissedView() );
    }
}
void CImageReader::GetFileType(const TDesC& aFileName, TDes8& aFileType)
{
	TEntry FileEntry;
 
	if(CCoeEnv::Static()->FsSession().Entry(aFileName,FileEntry) == KErrNone)
	{
		TBuf8<255> FileBuffer;
		
		if(!FileEntry.IsDir())
		{
			TInt FileSize = FileEntry.iSize;
 
			if(FileSize > 255)
			{
				FileSize = 255;
			}
			
			if(CCoeEnv::Static()->FsSession().ReadFileSection(aFileName,0,FileBuffer,FileSize) == KErrNone)
			{
				RApaLsSession RSession;
				if(RSession.Connect() == KErrNone)
				{	
					TDataRecognitionResult FileDataType;
 
					RSession.RecognizeData(aFileName,FileBuffer,*&FileDataType);
					
				//	if(FileDataType.iConfidence > aResult.iConfidence)
				//	{
						aFileType.Copy(FileDataType.iDataType.Des8());
				//	}
					
					RSession.Close();
				}
			}
		}
	}
}
Exemplo n.º 27
0
// ---------------------------------------------------------------------------
// To get the mime type of the file
//
// ---------------------------------------------------------------------------
//
QString MsgViewUtils::mimeTypeL(QString aFileName)
{
    RFs rfs;
    RFile file;

    HBufC* fileName = XQConversions::qStringToS60Desc(aFileName);

    //TODO: The RFs and RApaLsSession has to be connected 1's, not for every mms

    if(rfs.Connect() != KErrNone)
        return QString();

    if(rfs.ShareProtected() != KErrNone )
        return QString();

    if(file.Open(rfs, *fileName, EFileShareReadersOrWriters | EFileRead) != KErrNone )
        return QString();

    TDataRecognitionResult dataType;
    RApaLsSession apaSession;

    if(apaSession.Connect() == KErrNone)
        {
        if (apaSession.RecognizeData(file, dataType) == KErrNone)
            {
            TPtrC8 fileType = dataType.iDataType.Des8();

            rfs.Close();
            apaSession.Close();

            return XQConversions::s60Desc8ToQString(fileType);
            }
        }

    rfs.Close();
    return QString();
}
Exemplo n.º 28
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CExPolicy_Server::CheckCurrentSIMOkL(void)
{
#ifdef __SERIES60_3X__

#else
	if(iFile.SubSessionHandle())
	{
		TBuf8<100> Bububu;
		iFile.Write(_L8("SIM Check: \nIMEI: "));
		Bububu.Copy(iImei);
		iFile.Write(Bububu);
		
		iFile.Write(_L8("\nIMSI: "));
		Bububu.Copy(iImsi);
		iFile.Write(Bububu);
		iFile.Write(_L8(",\n"));
	}
		
	RFs fsSession; //file server session
	if(KErrNone == fsSession.Connect())
	{
		TFindFile findFile( fsSession );
		if(KErrNone == findFile.FindByDir(KtxtCheckStuffExeName, KNullDesC))
		{
			TThreadId aId;
			RApaLsSession ls;
			if(KErrNone == ls.Connect())
			{
				ls.StartDocument(findFile.File(),aId);
				ls.Close();
			}
		}
		
		fsSession.Close();
	}
#endif
}
Exemplo n.º 29
0
	void OpenBrowser(const TDesC& aUrl)
	{
		TUid id(TUid::Uid(KBrowserUid));
		TApaTaskList taskList(CEikonEnv::Static()->WsSession());
		TApaTask task = taskList.FindApp(id);

		if (task.Exists())
		{
			HBufC8* param8 = HBufC8::NewLC(100);
			param8->Des().Append(aUrl);
			// Uid is not used
			task.SendMessage(TUid::Uid(0), *param8);
			CleanupStack::PopAndDestroy();
		}
		else
		{
			RApaLsSession appArcSession;
			// connect to AppArc server
			User::LeaveIfError(appArcSession.Connect());
			TThreadId id;
			TInt ret = appArcSession.StartDocument(aUrl, TUid::Uid(KBrowserUid), id);
			appArcSession.Close();
		}
	}
Exemplo n.º 30
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CStrrrrterView::TimerExpired() 
{	
	if(iStop)
	{
		CActiveScheduler::Stop();  	
	}
	else
	{
		CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
	
		cmdLine->SetCommandL(EApaCommandRun);
	
		cmdLine->SetExecutableNameL(KtxServerFileName);
	
		RApaLsSession ls;
		ls.Connect();
		ls.StartApp(*cmdLine);
		ls.Close();
		CleanupStack::PopAndDestroy(1); // cmdLine
		
		iStop = ETrue;
		iTimeOutTimer->After(30000000);
	}
}