×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    Question How to Close built in Email Client Application

    Hi All,
    I am new to symbian.I am opening the built in Email Client Application in S60 3rd Edition Simulator when an email comes in the inbox.But while it's opened and again new email comes, then it try to open it again and the program crashes. But when i manually close the Email Client before receiving any other mail, then it works great but when i try to close "Email Client" then the program crash.

    I am opening the Email Client to view an email using following code:
    Code:
    void CInternetEmailEngine::DisplayMessageL( const TMsvId &aId )
    {
    // 1. construct the client MTM
    	TMsvEntry indexEntry;
    	TMsvId serviceId;
    	TInt error;
    	TInt error1;
    	CMsvOperation* op;
    	
    	User::LeaveIfError( iMsvSession->GetEntry(aId, serviceId, indexEntry));
    	CBaseMtm* mtm = iClientReg->NewMtmL(indexEntry.iMtm);
    	
    	//const TPtrC ptr = mtm->SubjectL();
    	
    	CleanupStack::PushL(mtm);
    
    	// 2. construct the user interface MTM
    	CBaseMtmUi* uiMtm = iUiReg->NewMtmUiL(*mtm);
    	CleanupStack::PushL(uiMtm);
    
    	// 3. display the message
    	TRAP(error, uiMtm->BaseMtm().SwitchCurrentEntryL(indexEntry.Id()));
    	
    	if(error == KErrNoMemory || error == KErrNotFound){
    		User::InfoPrint(_L("Error occured  : " + error));
    	}
    	CMsvOperationWait* waiter=CMsvOperationWait::NewLC();
    	waiter->Start(); //we use synchronous waiter
    	
    	 //the main "async-sync" call
    TRAP(error1, op = uiMtm->ViewL(waiter->iStatus)); (Program Crashes Here)
    		
    	
    	if (error1 == KErrNotSupported)
    	{
    		User::Leave(KErrNotSupported);
    	}
    	
    	CleanupStack::PushL(op);
    CleanupStack::PopAndDestroy(4); // op,waiter, mtm, uimtm
    	
    	}
    I want to close the email client after capturing the screen and open again when a new email received.

    Please Help, This is very urgent.
    Thanks in advance

  2. #2
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: How to Close built in Email Client Application

    Hello Prakash,

    What I would suggest is DO NOT open the client again in case a new mail comes. The point I am trying to make is that the user might have not finished reading the mail and your program will open another. Secondly, you can always have a global boolean variable which tells you if the email window is open, so that you don't open a new one when one is already open. As soon as the user closes the window ( you can capture the right soft key to know that) you may go ahead and open up the new window for the second email that has arrived.
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    Re: How to Close built in Email Client Application

    Quote Originally Posted by ssn.kishore View Post
    Hello Prakash,

    What I would suggest is DO NOT open the client again in case a new mail comes. The point I am trying to make is that the user might have not finished reading the mail and your program will open another. Secondly, you can always have a global boolean variable which tells you if the email window is open, so that you don't open a new one when one is already open. As soon as the user closes the window ( you can capture the right soft key to know that) you may go ahead and open up the new window for the second email that has arrived.
    Hi Kishor,

    Thanks for your invaluable time.But in my case all the processing should be automated.Let me repeate the flow of my application. This app will be running in background and continuesly listen for the incoming emails, When a new email received then this mail will be opened in built-in email client and then a screenshot will be captured and sent via a webservice to the server.The same process should continue with each mail.

    In case of single mail, my code runds well.But in case of multiple mails, After opening the first mail and after capturing the screen, when it tries to open the another mail then it crashes.Becasue the email client is already opened.So i want to close the email client, if it's already opened. In this application user interaction is nil. So i have to close the email client using the code.Please help me it's urgent.And if another alternate is possible then plz suggest.
    Thanks in advance.

  4. #4
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: How to Close built in Email Client Application

    Well, I got your problem 100% now. Here is what I would do with my meagre Symbian knowledge.

    - Wait for incoming email event
    - Open the mail received in the native client
    - Capture the screenshot
    - Simulate the "Right soft key" so that the client exits
    - Wait for a couple of seconds (asynchronously) so that all the processing required to close the client is done by the system
    - Open up another email in case there is one

    You can see this link for simulation of key events (use procedure 3) and for the scan codes see this.
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    3

    Re: How to Close built in Email Client Application

    Quote Originally Posted by ssn.kishore View Post
    Well, I got your problem 100% now. Here is what I would do with my meagre Symbian knowledge.

    - Wait for incoming email event
    - Open the mail received in the native client
    - Capture the screenshot
    - Simulate the "Right soft key" so that the client exits
    - Wait for a couple of seconds (asynchronously) so that all the processing required to close the client is done by the system
    - Open up another email in case there is one

    You can see this link for simulation of key events (use procedure 3) and for the scan codes see this.

    Kishore,
    Thanks a lot for your great job, it worked and now i can close the email client by using the following code.
    Code:
    TInt CInternetEmailEngine::PeriodicCloseAppTimerCallBack(TAny* aAny)
    	{
    		CInternetEmailEngine* self = static_cast<CInternetEmailEngine*>( aAny );
    		TRawEvent lEventDown;
    		lEventDown.Set(TRawEvent::EKeyDown, EStdKeyDevice1);
    		UserSvr::AddEvent(lEventDown);
    		User::After(2*1000*1000);
    		
    		// Cancel the timer when the callback should not be called again.
    	    Call: self->iPeriodicCloseAppTimer->Cancel();
    		    
    		return KErrNone; // App closes after returning from here.
    }
    I used the CPeriodic timer to execute the closing process after some delay.It works well for first two times but when there are more than two mail received then at third chance it fails.

    After debugin the code i reliazed that the app crashes after returning from highlighted code.

    Actually i am calling this close event like this :
    Code:
    void CInternetEmailEngine::TakeScreenShot()
    	{
    	CInternetEmailAppUi::TakeScreenShot();
    	iPeriodicCloseAppTimer = CPeriodic::NewL(CActive::EPriorityIdle);
    	iPeriodicCloseAppTimer->Start((2*1000*1000),(2*1000*1000),TCallBack(PeriodicCloseAppTimerCallBack, this));
    	}
    And the method TakeScreenShot is also called using the Cperiodic Timer.
    I fail to understand why the application is crashing.

    Please help me.
    Thanks in advance.

  6. #6
    Regular Contributor
    Join Date
    Feb 2008
    Location
    Pune, India
    Posts
    340

    Re: How to Close built in Email Client Application

    Dear friend, I somehow hesitate to use the CPeriodic Class, instead I would suggest to use the Simple Timer Implementation from wiki. It has worked for me several times and will work for you too.

    Another way to get a simple timer implementation class directly in your project is to do the following,

    - Right click your project folder in Carbide and select "Add New Class"
    - Select the type as "Active Class"
    - Give a name

    Carbide will create a class for you which will be a simple timer implementation.

    I hope this helps!
    Regards,
    Sainagakishore Srikantham (Kishore)

    Don't Hope, KNOW!!! ---------- Visit me at http://ssnkishore.blogspot.com ----------

Similar Threads

  1. Replies: 10
    Last Post: 2008-02-01, 20:20
  2. J2ME Application in Flip Close Mode
    By Amit21 in forum Mobile Java General
    Replies: 1
    Last Post: 2008-01-18, 20:05
  3. J2me Application for Flip close mode.
    By Amit21 in forum Mobile Java General
    Replies: 0
    Last Post: 2008-01-17, 07:42
  4. Replies: 0
    Last Post: 2007-09-11, 13:36
  5. Nokia N91, how to close the music application in the background?
    By goodluck_975 in forum General Development Questions
    Replies: 3
    Last Post: 2007-03-08, 14:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×