datacommsserver/esockserver/ssock/ss_transporthook.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2005-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 //
       
    15 
       
    16 /**
       
    17  @file ss_transporthook.CPP
       
    18 */
       
    19 
       
    20 #include "ss_transporthook.h"
       
    21 #include <comms-infras/metatype.h>
       
    22 #include <comms-infras/ss_log.h>
       
    23 #include <ss_glob.h>
       
    24 #include <comms-infras/ss_thread.h>
       
    25 #include <comms-infras/ss_nodeinterfaces.h>
       
    26 
       
    27 
       
    28 using namespace ESock;
       
    29 using namespace Meta;
       
    30 using namespace CommsFW;
       
    31 using namespace Messages;
       
    32 
       
    33 
       
    34 //TODO[PROD] - reimplement hooks?
       
    35 #if 0
       
    36 
       
    37 #ifdef _DEBUG
       
    38 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
       
    39 // (if it could happen through user error then you should give it an explicit, documented, category + code)
       
    40 _LIT(KSpecAssert_ESockSSockstrnsp, "ESockSSockstrnsp");
       
    41 #endif
       
    42 
       
    43 //class TCFRegisterMessageHook : public TCFRegisterHookSignal
       
    44 EXPORT_C TCFRegisterMessageHook::TCFRegisterMessageHook(const TNodeId& aSenderId, TUint aActivityId, const TNodeSignal::TMessageId& aMessageId):
       
    45     TCFRegisterHookSignal( Messages::TSignatureBase::TypeId() ),
       
    46     iMessageId(aMessageId),
       
    47     iActivityId(aActivityId)
       
    48     {
       
    49     SetClientId(aSenderId());
       
    50     }
       
    51 
       
    52 EXPORT_C CCFHookEntry* TCFRegisterMessageHook::NewHookEntryL() const
       
    53     {
       
    54     return new(ELeave)CCFMessageHookEntry(iMessageId,iActivityId,TNodeId(iNode),TNodeId(ClientId()));
       
    55     }
       
    56 
       
    57 EXPORT_C void TCFRegisterMessageHook::Error(TAny* aItf, TInt aError)
       
    58     {
       
    59     Messages::ANode* itf = static_cast<Messages::ANode*>(aItf);
       
    60     TNodeId itfid = itf ? itf->NodeId() : TNodeId::NullCommsId();
       
    61     TCFMessage::TRegisterHookError(itfid,iActivityId,iMessageId,aError).PostTo(TNodeId(ClientId()));
       
    62     }
       
    63 
       
    64 //class TCFDeregisterMessageHook : public TCFDeregisterHookSignal
       
    65 EXPORT_C TCFDeregisterMessageHook::TCFDeregisterMessageHook(const TNodeId& aSenderId, const TNodeSignal::TMessageId& aMessageId):
       
    66     TCFDeregisterHookSignal(Messages::TSignatureBase::TypeId()),
       
    67     iMessageId(aMessageId)
       
    68     {
       
    69     SetClientId(aSenderId());
       
    70     }
       
    71 
       
    72 //class TTransportHookError : public Messages::TSignatureBase
       
    73 TInt TTransportHookError::VerifyDestination(const CommsFW::TCookie& aDestination, CommsFW::MTransportReceiver& aTransport)
       
    74     {
       
    75     //deregister local tag if any
       
    76     TCFDeregisterMessageHook dereg(static_cast<const TNodeId&>(TNodeId(aDestination)),iHookedMessageId);
       
    77     dereg.DeregisterLocalTag(aTransport);
       
    78     return Messages::TSignatureBase::VerifyDestination(aDestination, aTransport);
       
    79     }
       
    80 
       
    81 //class CCFMessageHooks : public CCFTransportHooks
       
    82 void CCFMessageHooks::WalkHooks( const TCFSignalBase& aMessage, const TCookie& aRecipient )
       
    83     {//place to optimise wlak before calling the base class
       
    84     CCFTransportHooks::WalkHooks( aMessage, aRecipient );
       
    85     }
       
    86 
       
    87 void CCFMessageHooks::RegisterL( const CommsFW::TCFRegisterHookSignal& aMessage )
       
    88     {//place to do some extra stuff for look-up optimisation
       
    89     CCFTransportHooks::RegisterL( aMessage );
       
    90     }
       
    91 
       
    92 void CCFMessageHooks::Deregister( const CommsFW::TCFDeregisterHookSignal& aMessage )
       
    93     {//place to undo some extra stuff done for look-up optimisation
       
    94     CCFTransportHooks::Deregister( aMessage );
       
    95     }
       
    96 
       
    97 //class CCFMessageHookEntry : public CCFHookEntry
       
    98 EXPORT_C CCFMessageHookEntry::CCFMessageHookEntry( const TNodeSignal::TMessageId& aMessageId, TInt aActivityId, const TNodeId& aNode, const TNodeId& aListener ) :
       
    99     CCFHookEntry(Messages::TSignatureBase::TypeId(),aNode(),aListener()),
       
   100     iMessageId(aMessageId),
       
   101     iActivityId(aActivityId)
       
   102     {
       
   103 	LOG(ESockLog::Printf(KESockMessageHook, _L("CCFMessageHookEntry [this=%08x]:\t Registered [aMessagedId=%d] [aActivityId=%d] [aNode=%08x] [aListener=%08x]"),
       
   104 	    this, aMessageId.MessageId(), aActivityId, aNode.Printable(), aListener.Printable()));
       
   105     }
       
   106 
       
   107 EXPORT_C TBool CCFMessageHookEntry::Match(const CommsFW::TCFSignalBase& aMessage, const TCookie& aRecipient)
       
   108     {
       
   109     return CCFHookEntry::Match( aMessage, aRecipient ) && static_cast<const Messages::TSignatureBase&>(aMessage).MessageId() == iMessageId;
       
   110     }
       
   111 
       
   112 EXPORT_C void CCFMessageHookEntry::Notify(const CommsFW::TCFSignalBase& aMessage) const
       
   113     {
       
   114     __ASSERT_DEBUG(aMessage.IsTypeOf(TNodeSignal::TypeId()), User::Panic(KSpecAssert_ESockSSockstrnsp, 1));
       
   115 	TNodeSignal& sig = static_cast<TNodeSignal&>(const_cast<CommsFW::TCFSignalBase&>(aMessage));
       
   116 	TInt activityId = sig.ActivityId();
       
   117 	sig.SetActivity(iActivityId);
       
   118 	CCFHookEntry::Notify(sig);
       
   119 	sig.SetActivity(activityId);
       
   120     }
       
   121 
       
   122 EXPORT_C TBool CCFMessageHookEntry::Match( const TCFDeregisterHookSignal& aReq ) const
       
   123     {
       
   124     return CCFHookEntry::Match( aReq );
       
   125     }
       
   126 
       
   127 #endif
       
   128 
       
   129