commsfwsupport/commselements/serverden/src/sd_minterceptmsgs.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2008-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 // messageintercept.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include "sd_minterceptmsgs.h"
       
    23 #include <elements/sd_mintercept.h>
       
    24 #include <elements/metatype.h>
       
    25 #include <elements/metatypevariablelen.h>
       
    26 
       
    27 
       
    28 #ifdef _DEBUG
       
    29 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
       
    30 // (if it could happen through user error then you should give it an explicit, documented, category + code)
       
    31 _LIT(KSpecAssert_ElemSvrDenMIntMC, "ElemSvrDenMIntMC");
       
    32 #endif
       
    33 
       
    34 using namespace Den;
       
    35 using namespace Messages;
       
    36 using namespace Elements;
       
    37 
       
    38 // Implementation UID for MessageIntercept messages
       
    39 static const TInt KMessageInterceptRequestMsgImplementationUid = 0x10283063;
       
    40 
       
    41 enum
       
    42 	{
       
    43 	EResetMsg = 0,
       
    44 	EEnableMsg,
       
    45 	EEnableFallibleMsgModeMsg,
       
    46 	EDisableMsg,
       
    47 	EAppendExpressionMsg,
       
    48 	EAppendActionMsg,
       
    49 	EQueryCompleteMsg,
       
    50 	EInitFallibleMsgModeMsg,
       
    51 	ECheckFallibleMsgModeMsg
       
    52 	};
       
    53 
       
    54 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TSoftResetMsg, KMessageInterceptRequestMsgImplementationUid, EResetMsg)
       
    55 END_ATTRIBUTE_TABLE_BASE(TApiExtSessionReqMsg, EApiExtSessionReqMsg)
       
    56 
       
    57 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TEnableMsg, KMessageInterceptRequestMsgImplementationUid, EEnableMsg)
       
    58 END_ATTRIBUTE_TABLE_BASE(TApiExtSessionReqMsg, EApiExtSessionReqMsg)
       
    59 
       
    60 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TEnableFallibleMsgModeMsg, KMessageInterceptRequestMsgImplementationUid, EEnableFallibleMsgModeMsg)
       
    61 	REGISTER_ATTRIBUTE(TEnableFallibleMsgModeMsg, iCount, TMeta<TInt>)
       
    62 END_ATTRIBUTE_TABLE_BASE(TApiExtSessionReqMsg, EApiExtSessionReqMsg)
       
    63 
       
    64 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TDisableMsg, KMessageInterceptRequestMsgImplementationUid, EDisableMsg)
       
    65 END_ATTRIBUTE_TABLE_BASE(TApiExtSessionReqMsg, EApiExtSessionReqMsg)
       
    66 
       
    67 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TAppendExpressionMsg, KMessageInterceptRequestMsgImplementationUid, EAppendExpressionMsg)
       
    68 	REGISTER_ATTRIBUTE(TAppendExpressionMsg, iExpression, TMeta<TEventExpression>)
       
    69 END_ATTRIBUTE_TABLE_BASE(TApiExtSessionReqMsg, EApiExtSessionReqMsg)
       
    70 
       
    71 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TAppendActionMsg, KMessageInterceptRequestMsgImplementationUid, EAppendActionMsg)
       
    72 	REGISTER_ATTRIBUTE(TAppendActionMsg, iAction, TMeta<TAction>)
       
    73 END_ATTRIBUTE_TABLE_BASE(TApiExtSessionReqMsg, EApiExtSessionReqMsg)
       
    74 
       
    75 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TQueryCompleteMsg, KMessageInterceptRequestMsgImplementationUid, EQueryCompleteMsg)
       
    76 END_ATTRIBUTE_TABLE_BASE(TApiExtSessionReqMsg, EApiExtSessionReqMsg)
       
    77 
       
    78 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TInitFallibleMsgModeMsg, KMessageInterceptRequestMsgImplementationUid, EInitFallibleMsgModeMsg)
       
    79 	REGISTER_ATTRIBUTE(TInitFallibleMsgModeMsg, iArray, TMetaVarLen8<TBuf8<1024> >)
       
    80 END_ATTRIBUTE_TABLE_BASE(TApiExtSessionReqMsg, EApiExtSessionReqMsg)
       
    81 
       
    82 EXPORT_START_ATTRIBUTE_TABLE_AND_FN(TCheckFallibleMsgModeMsg, KMessageInterceptRequestMsgImplementationUid, ECheckFallibleMsgModeMsg)
       
    83 END_ATTRIBUTE_TABLE_BASE(TApiExtSessionReqMsg, EApiExtSessionReqMsg)
       
    84 
       
    85 // Message implementations
       
    86 //---------------------------------
       
    87 EXPORT_C TEnableFallibleMsgModeMsg::TEnableFallibleMsgModeMsg()
       
    88 :	iCount(0)
       
    89 	{
       
    90 	}
       
    91 
       
    92 EXPORT_C TEnableFallibleMsgModeMsg::TEnableFallibleMsgModeMsg(TInt aCount)
       
    93 :	iCount(aCount)
       
    94 	{
       
    95 	}
       
    96 
       
    97 EXPORT_C TAppendExpressionMsg::TAppendExpressionMsg()
       
    98 	{
       
    99 	}
       
   100 
       
   101 EXPORT_C TAppendExpressionMsg::TAppendExpressionMsg(const TEventExpression& aExpression)
       
   102 :	iExpression(aExpression)
       
   103 	{
       
   104 	}
       
   105 
       
   106 EXPORT_C TAppendActionMsg::TAppendActionMsg(const TAction& aAction)
       
   107 :	iAction(aAction)
       
   108 	{
       
   109 	}
       
   110 
       
   111 EXPORT_C void TSoftResetMsg::DispatchL(NetInterfaces::TInterfaceControl& /*aIntfCtl*/,
       
   112 			                           TSessionUniqueId /*aClientUniqueId*/,
       
   113 	                                   RResponseMsg& /*aResponseMsg*/)
       
   114 	{
       
   115 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   116 	// Simply reset the register
       
   117 	User::Leave(KErrNotSupported);
       
   118 	//return FetchMsgInterceptControl().SoftReset();
       
   119 #else
       
   120 	User::Leave(KErrNotSupported);
       
   121 #endif //#ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   122 	}
       
   123 
       
   124 EXPORT_C void TEnableMsg::DispatchL(NetInterfaces::TInterfaceControl& /*aIntfCtl*/,
       
   125 			                        TSessionUniqueId /*aClientUniqueId*/,
       
   126 	                                RResponseMsg& /*aResponseMsg*/)
       
   127 	{
       
   128 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   129 	// Enable the intercept register
       
   130 	//return FetchMsgInterceptControl().Enable();
       
   131 	User::Leave(KErrNotSupported);
       
   132 #else
       
   133 	User::Leave(KErrNotSupported);
       
   134 #endif // #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   135 	}
       
   136 
       
   137 EXPORT_C void TEnableFallibleMsgModeMsg::DispatchL(NetInterfaces::TInterfaceControl& aIntfCtl,
       
   138 			                                       TSessionUniqueId /*aClientUniqueId*/,
       
   139 	                                               RResponseMsg& aResponseMsg)
       
   140 	{
       
   141 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   142 	AFallibleTestControl* tc = static_cast<AFallibleTestControl*>(aIntfCtl.FetchInterfaceL(aResponseMsg.InterfaceId()));
       
   143 	aResponseMsg.Complete(tc->Enable(iCount));
       
   144 #else
       
   145 	// Fixing unused local variable warnings.
       
   146 	(void)aIntfCtl;
       
   147 	(void)aResponseMsg;
       
   148 
       
   149 	User::Leave(KErrNotSupported);
       
   150 #endif // __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   151 	}
       
   152 
       
   153 EXPORT_C TSoftResetMsg::TSoftResetMsg()
       
   154 	{
       
   155 	}
       
   156 
       
   157 EXPORT_C TEnableMsg::TEnableMsg()
       
   158 	{
       
   159 	}
       
   160 
       
   161 EXPORT_C void TInitFallibleMsgModeMsg::DispatchL(NetInterfaces::TInterfaceControl& aIntfCtl,
       
   162 			                                     TSessionUniqueId /*aClientUniqueId*/,
       
   163 	                                             RResponseMsg& aResponseMsg)
       
   164 	{
       
   165 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   166 	AFallibleTestControl* tc = static_cast<AFallibleTestControl*>(aIntfCtl.FetchInterfaceL(aResponseMsg.InterfaceId()));
       
   167 	const RArray<TNodeSignal::TMessageId> array(sizeof(TNodeSignal::TMessageId), reinterpret_cast<TNodeSignal::TMessageId*>(const_cast<TUint8*>(iArray.Ptr())), iArray.Size()/sizeof(TNodeSignal::TMessageId));
       
   168 	tc->InitL(array);
       
   169 	aResponseMsg.Complete(KErrNone);
       
   170 #else
       
   171 	// Fixing unused local variable warnings.
       
   172 	(void)aIntfCtl;
       
   173 	(void)aResponseMsg;
       
   174 
       
   175 	User::Leave(KErrNotSupported);
       
   176 #endif // __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   177 	}
       
   178 
       
   179 EXPORT_C void TInitFallibleMsgModeMsg::InitL(RArray<TNodeSignal::TMessageId>& aArray)
       
   180 	{
       
   181 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   182 	__ASSERT_DEBUG(aArray.Count(), User::Panic(KSpecAssert_ElemSvrDenMIntMC, 1));
       
   183 	for(TInt i=0 ; i<aArray.Count() ; i++)
       
   184 		{
       
   185 		iArray.Append((TUint8*)&aArray[i], sizeof(TNodeSignal::TMessageId));
       
   186 		}
       
   187 #else
       
   188 	// Fixing unused local variable warnings.
       
   189 	(void)aArray;
       
   190 
       
   191 	User::Leave(KErrNotSupported);
       
   192 #endif //#ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   193 	}
       
   194 
       
   195 EXPORT_C TInitFallibleMsgModeMsg::TInitFallibleMsgModeMsg()
       
   196 	{
       
   197 	}
       
   198 
       
   199 EXPORT_C TCheckFallibleMsgModeMsg::TCheckFallibleMsgModeMsg()
       
   200 	{
       
   201 	}
       
   202 
       
   203 EXPORT_C void TCheckFallibleMsgModeMsg::DispatchL(NetInterfaces::TInterfaceControl& aIntfCtl,
       
   204 			                                       TSessionUniqueId /*aClientUniqueId*/,
       
   205 	                                               RResponseMsg& aResponseMsg)
       
   206 	{
       
   207 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   208 	AFallibleTestControl* tc = static_cast<AFallibleTestControl*>(aIntfCtl.FetchInterfaceL(aResponseMsg.InterfaceId()));
       
   209 	TCheckFallibleMsgModeResponseMsg msg;
       
   210 	msg.iCheckResult = tc->CheckFinished();
       
   211 	TBuf8<TMIMessages::KMaxExternalisedReqAndRespMsgSize> msgDst;
       
   212 	aResponseMsg.Complete(msg, msgDst);
       
   213 	msg.~TCheckFallibleMsgModeResponseMsg();
       
   214 #else
       
   215 	// Fixing unused local variable warnings.
       
   216 	(void)aIntfCtl;
       
   217 	(void)aResponseMsg;
       
   218 
       
   219 	User::Leave(KErrNotSupported);
       
   220 #endif // __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   221 	}
       
   222 
       
   223 EXPORT_C void TDisableMsg::DispatchL(NetInterfaces::TInterfaceControl& /*aIntfCtl*/,
       
   224 			                         TSessionUniqueId /*aClientUniqueId*/,
       
   225 	                                 RResponseMsg& /*aResponseMsg*/)
       
   226 	{
       
   227 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   228 	// Disable the intercept register
       
   229 	User::Leave(KErrNotSupported);
       
   230 #else
       
   231 	User::Leave(KErrNotSupported);
       
   232 #endif//#ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   233 	}
       
   234 
       
   235 EXPORT_C TDisableMsg::TDisableMsg()
       
   236 	{
       
   237 	}
       
   238 
       
   239 EXPORT_C void TAppendExpressionMsg::DispatchL(NetInterfaces::TInterfaceControl& /*aIntfCtl*/,
       
   240 			                                  TSessionUniqueId /*aClientUniqueId*/,
       
   241 	                                          RResponseMsg& /*aResponseMsg*/)
       
   242 	{
       
   243 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   244 	// Append expression to the intercept register (it should go on the current pattern)
       
   245 	//return FetchMsgInterceptControl().AppendExpression(iExpression);
       
   246 	User::Leave(KErrNotSupported);
       
   247 #else
       
   248 	User::Leave(KErrNotSupported);
       
   249 #endif
       
   250 	}
       
   251 
       
   252 EXPORT_C TAppendActionMsg::TAppendActionMsg()
       
   253 	{
       
   254 	}
       
   255 
       
   256 EXPORT_C void TAppendActionMsg::DispatchL(NetInterfaces::TInterfaceControl& /*aIntfCtl*/,
       
   257 			                              TSessionUniqueId /*aClientUniqueId*/,
       
   258 	                                      RResponseMsg& /*aResponseMsg*/)
       
   259 	{
       
   260 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   261 	// Append action to the intercept register (it should terminate the current pattern)
       
   262 	//return FetchMsgInterceptControl().AppendAction(iAction);
       
   263 	User::Leave(KErrNotSupported);
       
   264 #else
       
   265 	User::Leave(KErrNotSupported);
       
   266 #endif //#ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   267 	}
       
   268 
       
   269 EXPORT_C TQueryCompleteMsg::TQueryCompleteMsg()
       
   270 	{
       
   271 	}
       
   272 
       
   273 EXPORT_C void TQueryCompleteMsg::DispatchL(NetInterfaces::TInterfaceControl& /*aIntfCtl*/,
       
   274 			                               TSessionUniqueId /*aClientUniqueId*/,
       
   275 	                                       RResponseMsg& /*aResponseMsg*/)
       
   276 	{
       
   277 #ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   278 	// Query completion of the register
       
   279 	//return FetchMsgInterceptControl().QueryComplete();
       
   280 	User::Leave(KErrNotSupported);
       
   281 #else
       
   282 	User::Leave(KErrNotSupported);
       
   283 #endif //#ifdef __ELEMENTS_MESSAGE_INTERCEPT_ACTIVE
       
   284 	}
       
   285 
       
   286 DEFINE_MVIP_CTR(TSoftResetMsg);
       
   287 DEFINE_MVIP_CTR(TEnableMsg);
       
   288 DEFINE_MVIP_CTR(TEnableFallibleMsgModeMsg);
       
   289 DEFINE_MVIP_CTR(TDisableMsg);
       
   290 DEFINE_MVIP_CTR(TAppendExpressionMsg);
       
   291 DEFINE_MVIP_CTR(TAppendActionMsg);
       
   292 DEFINE_MVIP_CTR(TQueryCompleteMsg);
       
   293 DEFINE_MVIP_CTR(TInitFallibleMsgModeMsg);
       
   294 DEFINE_MVIP_CTR(TCheckFallibleMsgModeMsg);
       
   295 
       
   296 /** Message interface registration table */
       
   297 const TImplementationProxy ImplementationTable[] =
       
   298 	{
       
   299 	MVIP_CTR_ENTRY(EResetMsg, TSoftResetMsg),
       
   300 	MVIP_CTR_ENTRY(EEnableMsg, TEnableMsg),
       
   301 	MVIP_CTR_ENTRY(EEnableFallibleMsgModeMsg, TEnableFallibleMsgModeMsg),
       
   302 	MVIP_CTR_ENTRY(EDisableMsg, TDisableMsg),
       
   303 	MVIP_CTR_ENTRY(EAppendExpressionMsg, TAppendExpressionMsg),
       
   304 	MVIP_CTR_ENTRY(EAppendActionMsg, TAppendActionMsg),
       
   305 	MVIP_CTR_ENTRY(EQueryCompleteMsg, TQueryCompleteMsg),
       
   306 	MVIP_CTR_ENTRY(EInitFallibleMsgModeMsg, TInitFallibleMsgModeMsg),
       
   307 	MVIP_CTR_ENTRY(ECheckFallibleMsgModeMsg, TCheckFallibleMsgModeMsg)
       
   308 	};
       
   309 
       
   310 
       
   311 TUid TMIMessages::ImplementationUid()
       
   312 	{
       
   313 	return TUid::Uid(KMessageInterceptRequestMsgImplementationUid);
       
   314 	}
       
   315 
       
   316 TInt TMIMessages::ImplementationProxyTableSize()
       
   317 	{
       
   318 	return (sizeof(ImplementationTable) / sizeof(ImplementationTable[0]));
       
   319 	};
       
   320 
       
   321 const TImplementationProxy* TMIMessages::ImplementationProxyTable()
       
   322 	{
       
   323 	return ImplementationTable;
       
   324 	};
       
   325 
       
   326 
       
   327 //*************************************************************************
       
   328 //
       
   329 //Response messages
       
   330 //
       
   331 //*************************************************************************
       
   332 
       
   333 EXPORT_C TCheckFallibleMsgModeResponseMsg* TCheckFallibleMsgModeResponseMsg::NewL() //For the ecom factory
       
   334 	{
       
   335 	return new (ELeave) TCheckFallibleMsgModeResponseMsg;
       
   336 	}
       
   337 
       
   338 EXPORT_C TCheckFallibleMsgModeResponseMsg::TCheckFallibleMsgModeResponseMsg()
       
   339 :	iCheckResult(EFalse)
       
   340 	{
       
   341 	}
       
   342 
       
   343 EXPORT_START_ATTRIBUTE_TABLE_AND_FN( TCheckFallibleMsgModeResponseMsg, KMessageInterceptResponseMsgImplementationUid, ECheckFallibleMsgModeResponseMsg )
       
   344 	REGISTER_ATTRIBUTE( TCheckFallibleMsgModeResponseMsg, iCheckResult, TMeta<TBool>)
       
   345 END_ATTRIBUTE_TABLE_BASE( TApiExtRespMsg, 0 )
       
   346 
       
   347