messagingfw/msgurlhandler/urlhandler/src/MsgUrlHandlerAppUi.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This file contains the implementation for the class defined in 
       
    15 // MsgUrlHandlerApp.h
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @see	MsgUrlHandlerApp.h
       
    22 */
       
    23   
       
    24 #include <inetprottextutils.h>
       
    25 #include <uriutils.h>
       
    26 #include <uri8.h>
       
    27 
       
    28 #include "MsgUrlHandlerApp.H"
       
    29 #include "MTSCHEME.H"
       
    30 #include "SMSSCH.H"
       
    31 
       
    32 
       
    33 _LIT8(KMailtoScheme, "mailto");
       
    34 _LIT8(KSmsScheme, "sms");
       
    35 
       
    36 
       
    37 CMsgUrlHandlerAppUi::CMsgUrlHandlerAppUi()
       
    38 	{
       
    39 	}
       
    40 
       
    41 //             The second phase constructor of the application UI class.
       
    42 // 
       
    43 void CMsgUrlHandlerAppUi::ConstructL()
       
    44     {
       
    45 	           // BaseConstructL() completes the UI framework's
       
    46 	           // construction of the App UI.
       
    47     BaseConstructL();
       
    48 
       
    49 	// Create the idle active object
       
    50 	iIdleConstructor = CIdle::NewL(CActive::EPriorityHigh);
       
    51 	iIdleConstructor->Start(TCallBack(IdleConstructCallbackL, this));
       
    52 	}			
       
    53 
       
    54 CMsgUrlHandlerAppUi::~CMsgUrlHandlerAppUi()
       
    55 	{
       
    56 	delete iCommandLineFileName;
       
    57 	delete iIdleConstructor;
       
    58 	}
       
    59 
       
    60 TInt CMsgUrlHandlerAppUi::IdleConstructCallbackL(TAny* aThis)
       
    61 	{
       
    62 	CMsgUrlHandlerAppUi *uiThis = STATIC_CAST(CMsgUrlHandlerAppUi*, aThis);
       
    63  
       
    64 	uiThis->IdleConstructL();
       
    65 
       
    66 	delete uiThis->iIdleConstructor;
       
    67 	uiThis->iIdleConstructor = NULL;
       
    68 
       
    69 	return EFalse;	// Never recall this
       
    70 	}
       
    71 
       
    72 void CMsgUrlHandlerAppUi::IdleConstructL()
       
    73 	{
       
    74 	LoadStartPageL();
       
    75 	}
       
    76 
       
    77 TBool CMsgUrlHandlerAppUi::ProcessCommandParametersL(TApaCommand aCommand,TFileName& aDocumentName,const TDesC8& aTail)
       
    78 //
       
    79 // get the document opened from the command line
       
    80 //
       
    81 	{
       
    82 	if (aCommand==EApaCommandOpen && aDocumentName.Length())
       
    83 		{
       
    84 		if (iCommandLineFileName == NULL)
       
    85 			iCommandLineFileName = aDocumentName.AllocL();
       
    86 		}
       
    87 	return CEikAppUi::ProcessCommandParametersL(aCommand,aDocumentName,aTail);
       
    88 	}
       
    89 
       
    90 void CMsgUrlHandlerAppUi::LoadStartPageL()
       
    91 	{
       
    92 	if (iCommandLineFileName)
       
    93 		{
       
    94 		LaunchMailEditorL(*iCommandLineFileName);
       
    95 		delete iCommandLineFileName;
       
    96 		iCommandLineFileName = NULL;
       
    97 		}
       
    98 	}
       
    99 
       
   100 void CMsgUrlHandlerAppUi::LaunchMailEditorL(const TDesC& aUrl)
       
   101 	{
       
   102 	// Get the scheme from the url.
       
   103 	
       
   104 	CUri8* uri = UriUtils::CreateUriL(aUrl);
       
   105 	CleanupStack::PushL(uri);
       
   106 	TPtrC8 scheme = uri->Uri().Extract(EUriScheme);		
       
   107 		
       
   108 	InetProtTextUtils::RemoveWhiteSpace(scheme, InetProtTextUtils::ERemoveBoth);
       
   109 
       
   110 	// Check if scheme is valid and launch the correct mail editor.
       
   111 	CMsgSchemeHandlerBase* handler = NULL;
       
   112 	if (scheme.CompareF(KMailtoScheme) == 0)
       
   113 		handler = CMailtoSchemeHandler::NewL();
       
   114 	else if (scheme.CompareF(KSmsScheme) == 0)
       
   115 		handler = CSmsSchemeHandler::NewL();
       
   116 	else
       
   117 		User::Leave(KErrNotSupported);
       
   118 
       
   119 	CleanupStack::PopAndDestroy(uri);
       
   120 	CleanupStack::PushL(handler);
       
   121 	TRAPD(ignore, handler->ParseUrlAndSendL(aUrl));
       
   122 	CleanupStack::PopAndDestroy(handler);
       
   123 
       
   124 	PrepareToExit();
       
   125 	Exit();
       
   126 	}
       
   127 
       
   128 void CMsgUrlHandlerAppUi::HandleCommandL(TInt aCommand)
       
   129 	{
       
   130 	switch (aCommand)
       
   131 		{
       
   132 	case EEikCmdExit:
       
   133 		Exit();
       
   134 		break;
       
   135 	default:
       
   136 		break;
       
   137 		}
       
   138 	}