messagingfw/wappushfw/pushutils/src/PushDispatcher.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
child 44 7c176670643f
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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 // Local includes
       
    15 // 
       
    16 //
       
    17 
       
    18 // System includes
       
    19 //
       
    20 #include "pushdispatcher.h"
       
    21 #include <push/pluginkiller.h>
       
    22 #include <push/cpushhandlerbase.h>
       
    23 #include <push/ccontenthandlerbase.h>
       
    24 #include <push/pushlog.h>
       
    25 
       
    26 /** Loads the Wap Push Application or Content Handler Plugin.
       
    27  *
       
    28  * The plug-in returned is responsible for its own destruction.
       
    29  * This behaviour is provided using the plug-in killer, which deletes
       
    30  * the plug-in owner on request when the plugin is ready to kill itself.
       
    31  * 
       
    32  * @param aData Data identifying specific handlers
       
    33  * @param aType Uid of Wap Push App Handling Plugin
       
    34  * @return Plugin Owner
       
    35  * @leave EWapErrPluginNotFound (-10018) if the plug-in server was unable to
       
    36  * find the requested plug-in. 
       
    37  */
       
    38 CPushHandlerBase* PushAppDispatcher::CreatePluginFromDataL(const TDesC& aData, const TUid& aType, MWapPushLog& aLog, MConnManObserver& aManager)
       
    39 	{
       
    40 	CPushHandlerBase* pushHandler = CPushHandlerBase::NewL(aData, aType);
       
    41 	CleanupStack::PushL(pushHandler);
       
    42 
       
    43 	CPluginKiller* pluginKiller = new (ELeave) CPluginKiller(pushHandler);
       
    44 	CleanupStack::Pop(pushHandler);
       
    45 	
       
    46 	// Set some data
       
    47 	pushHandler->SetKiller(*pluginKiller);
       
    48 	pushHandler->SetLogger(aLog);
       
    49 	pushHandler->SetManager(aManager);
       
    50 
       
    51 	return pushHandler;
       
    52 	}
       
    53 
       
    54 
       
    55 /** Loads the Application Handler Plugin using App ID.
       
    56  *
       
    57  *  @param aAppId Uid for identifying specific Handlers in the App Plugin
       
    58  *  @param aLog Logging Utility Mixin class
       
    59  *  @param aManager Connection Manger Observer Mixin Class
       
    60  *  @return Reference to Push Handler Plugin Base
       
    61  */
       
    62 EXPORT_C CPushHandlerBase& PushAppDispatcher::GetHandlerL(TInt aAppId, MWapPushLog& aLog, MConnManObserver& aManager) 
       
    63 	{
       
    64 	__LOG_PAR_DEBUG("PushAppDispatcher called");
       
    65 	const TInt KAppIdLength =10;
       
    66 	TBuf<KAppIdLength> appIdBuf;
       
    67 	_LIT(KAppIdBufFormat, "0x%08x");
       
    68 	appIdBuf.Format(KAppIdBufFormat, aAppId);
       
    69 
       
    70 	CPushHandlerBase* pushHandler = CreatePluginFromDataL(appIdBuf, KUidPushHandlerBase, aLog, aManager);
       
    71 
       
    72 	return *pushHandler;
       
    73 	}
       
    74 
       
    75 
       
    76 /** Loads the Application Handler Plugin using App URI.
       
    77  * 
       
    78  *  The AppURI string needs to be widened from 8 bit to 16 bit 
       
    79  *  Unicode text; this is done by the descriptor Copy() method.
       
    80  *
       
    81  *	@param aAppURI URI for identifying specific Handlers in the App Plugin
       
    82  * 	@param aLog	Logging Utility Mixin class
       
    83  *  @param aManager Connection Manger Observer Mixin Class
       
    84  *  @return Reference to the Push Handler Plugin Base
       
    85  */
       
    86 EXPORT_C CPushHandlerBase& PushAppDispatcher::GetHandlerL(const TDesC8& aAppURI, MWapPushLog& aLog, MConnManObserver& aManager) 
       
    87 	{
       
    88 	__LOG_PAR_DEBUG("PushAppDispatcher called");
       
    89 	HBufC16* applicationURI = HBufC16::NewL(aAppURI.Length());
       
    90 	CleanupStack::PushL(applicationURI);
       
    91 	applicationURI->Des().Copy(aAppURI);
       
    92 	
       
    93 	CPushHandlerBase* pushHandler = CreatePluginFromDataL(*applicationURI, KUidPushHandlerBase, aLog, aManager);
       
    94 	CleanupStack::PopAndDestroy(applicationURI);
       
    95 
       
    96 	return *pushHandler;
       
    97 	}
       
    98 
       
    99 
       
   100 /** Loads the Content-type Handler Plugin using content type string.
       
   101  *
       
   102  *	@param aContentType Content Type requested
       
   103  *  @param aLog	Logging Utility Mixin class
       
   104  *  @param aManager Connection Manger Observer Mixin Class
       
   105  *	@return Reference to the Push Handler Plugin Base
       
   106  */
       
   107 EXPORT_C CContentHandlerBase& PushContentTypeDispatcher::GetHandlerL(const TDesC16& aContentType, MWapPushLog& aLog, MConnManObserver& aManager) 
       
   108 	{
       
   109 	__LOG_PAR_DEBUG("Push Content Type Dispatcher called")
       
   110 
       
   111 	CPushHandlerBase* pushHandler = PushAppDispatcher::CreatePluginFromDataL(aContentType, 
       
   112 																			 KUidPushContentHandlerBase,
       
   113 																			 aLog,
       
   114 																			 aManager);
       
   115 	// This line was added instead of returning directly explicitly to remove a warning under armi
       
   116 	CContentHandlerBase* handlerBase = REINTERPRET_CAST(CContentHandlerBase*, pushHandler);
       
   117 
       
   118 	return *handlerBase;
       
   119 	}