homescreensrv_plat/sapi_menucontent/src/mcscallback.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 #include "mcscallback.h"
       
    19 #include "mcsdsinterface.h"
       
    20 #include "mcsconstants.h"
       
    21 
       
    22 // ---------------------------------------------------------------------------
       
    23 // Two-phase Constructor
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 CMCSCallback* CMCSCallback::NewL( MLiwNotifyCallback *aPtrNotifyCallback, 
       
    27 								  const CLiwGenericParamList& aPtrInParamList, 
       
    28 								  TInt32 aTransactionId, CMCSService& aMcsService,TCmds aCmd  )
       
    29 	{
       
    30 	return new (ELeave)	CMCSCallback( aPtrNotifyCallback, aPtrInParamList, aTransactionId,
       
    31 	    aMcsService, aCmd);
       
    32 	}
       
    33 	
       
    34 // ---------------------------------------------------------------------------
       
    35 //  Constructor
       
    36 // ---------------------------------------------------------------------------
       
    37 //	
       
    38 CMCSCallback::CMCSCallback( MLiwNotifyCallback *aPtrNotifyCallback, 
       
    39 							const CLiwGenericParamList& aPtrInParamList, 
       
    40 							TInt32 aTransactionId, CMCSService& aMcsService,
       
    41 							TCmds aCmd )
       
    42 	{
       
    43 	iPtrNotifyCallback = aPtrNotifyCallback; 
       
    44 	iPtrInParamList = &aPtrInParamList;
       
    45 	iTransactionId = aTransactionId;
       
    46 	iMcsService = &aMcsService;
       
    47 	iCmd = aCmd;
       
    48 	}
       
    49 	
       
    50 // ---------------------------------------------------------------------------
       
    51 // Gives the result of asynchronous SAPI calls
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 void CMCSCallback::NotifyResultL( TInt aErrCode, TAny* aResult )
       
    55 	{
       
    56 	CLiwGenericParamList* outParams= NULL;
       
    57 
       
    58     if(iCmd != ERequestNotification || 
       
    59 	        (iCmd == ERequestNotification  && aErrCode == KErrCancel))
       
    60 	    {
       
    61 		CleanupStack::PushL( this);
       
    62 		outParams = CLiwGenericParamList::NewLC();
       
    63 		outParams->AppendL(TLiwGenericParam(KErrorCode,
       
    64 				TLiwVariant(CMCSDSInterface::ErrCodeConversion(aErrCode))));
       
    65 		}
       
    66 	else
       
    67 		{
       
    68 		outParams = CLiwGenericParamList::NewLC();
       
    69 		}
       
    70 
       
    71 	HandleComandL( aErrCode, aResult, *outParams );
       
    72 
       
    73     
       
    74 	TInt event = KLiwEventInProgress;
       
    75 	if (aErrCode == KErrCancel)
       
    76 		{
       
    77 		event = KLiwEventCanceled;
       
    78 		}
       
    79 	else
       
    80 		if (aErrCode != KErrNone)
       
    81 			{
       
    82 			event = KLiwEventStopped;
       
    83 			}
       
    84 
       
    85 	((MLiwNotifyCallback*)iPtrNotifyCallback)->HandleNotifyL(
       
    86 			iTransactionId, event, *outParams,
       
    87 			*((CLiwGenericParamList*)iPtrInParamList));
       
    88 
       
    89 	CleanupStack::PopAndDestroy(outParams);
       
    90 	if (iCmd != ERequestNotification || (iCmd == ERequestNotification
       
    91 			&& aErrCode == KErrCancel))
       
    92 		{
       
    93 		CleanupStack::PopAndDestroy(this);
       
    94 		}
       
    95 	}
       
    96 
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CMCSCallback::HandleComandL
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CMCSCallback::HandleComandL( TInt &aErrCode, TAny* aResult,
       
   103 		CLiwGenericParamList& aParamList)
       
   104 	{
       
   105 
       
   106 	switch (iCmd)
       
   107 		{
       
   108 		case EGetList:
       
   109 			{
       
   110 			if (aResult && aErrCode == KErrNone)
       
   111 				{
       
   112 				aParamList.AppendL(*static_cast<CLiwGenericParamList*>(aResult));
       
   113 				}
       
   114 			}
       
   115 			break;
       
   116 		case EExecuteAction:
       
   117 			{
       
   118 			// Do Nothing.
       
   119 			}
       
   120 			break;
       
   121 		case ERequestNotification:
       
   122 			{
       
   123 			if (aResult)
       
   124 				{
       
   125 				TInt &folderId = *((TInt*)aResult);
       
   126 				TInt event = aErrCode;
       
   127 				if (event)
       
   128 					{
       
   129 					aErrCode = KErrNone;
       
   130 					}
       
   131 				aParamList.AppendL(TLiwGenericParam( KErrorCode,
       
   132 						TLiwVariant(CMCSDSInterface::ErrCodeConversion(aErrCode))));
       
   133 				iMcsService->SetReqNotificationOutputL(folderId, event, aParamList );
       
   134 					
       
   135 				}
       
   136 			}
       
   137 			break;
       
   138 		case EAddORChange:
       
   139 			{
       
   140 			if (aErrCode== KErrNone)
       
   141 				{
       
   142 				TBuf8<KMenuMaxAttrNameLen> attrname;
       
   143 				TInt &itemId = *((TInt*)aResult);
       
   144 				attrname.Copy(KMenuAttrId());
       
   145 				aParamList.AppendL(TLiwGenericParam(attrname, TLiwVariant(  (TInt32) itemId ) ) );
       
   146 				}
       
   147 			// Do Nothing.
       
   148 			}
       
   149 			break;
       
   150 		case EDelete:
       
   151 			{
       
   152 			// Do Nothing	    	
       
   153 			}
       
   154 			break;
       
   155 		case EOrganize:
       
   156 			{
       
   157 			// Do Nothing	    	
       
   158 			}
       
   159 			break;
       
   160 		case EGetRunningApps:
       
   161 			{
       
   162 			if (aResult)
       
   163 				{
       
   164 				RArray<TUid>& outputArray = *((RArray<TUid>*)aResult);
       
   165 				iMcsService->SetRunningAppsOutputL(outputArray, aParamList);
       
   166 				}
       
   167 			}
       
   168 			break;
       
   169 		default:
       
   170 			{
       
   171 			// Do Nothing	    	
       
   172 			}
       
   173 			break;
       
   174 		}
       
   175 	}
       
   176 
       
   177 // End of file