telephonyprotocols/pdplayer/umts/test/mbufgobblerlayer/src/mbufgobblerhelper.cpp
branchRCL_3
changeset 82 042fd2753b8f
equal deleted inserted replaced
74:9200f38b1324 82:042fd2753b8f
       
     1 // Copyright (c) 2010 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 // Helper class supplying useful logging functions to the providers in the layer
       
    15 //
       
    16 
       
    17 /**
       
    18  @file
       
    19  @internalComponent
       
    20 */
       
    21 
       
    22 #include "mbufgobblerhelper.h"
       
    23 #include "mbufgobblerlog.h"
       
    24 #include <elements/mm_node.h>
       
    25 #include <comms-infras/ss_nodeinterfaces.h>
       
    26 
       
    27 
       
    28 void MbufGobblerHelper::LogCreateDestroy(const TDesC8& aSubTag, const TDesC8& aNodeName, TAny* aNodePtr, TBool aIsCreate)
       
    29 	{
       
    30 	// to eradicate warnings on builds for which the LOG macro does nothing (e.g. urel)
       
    31 	(void)(aSubTag); (void)(aNodeName); (void)(aNodePtr); (void)(aIsCreate);
       
    32 	
       
    33 	if(aIsCreate)
       
    34 		{
       
    35 		LOG(aSubTag,_L8("%S (0x%x) Created"), &aNodeName, aNodePtr);
       
    36 		}		
       
    37 	else
       
    38 		{
       
    39 		LOG(aSubTag,_L8("%S (0x%x) Destroyed"), &aNodeName, aNodePtr);
       
    40 		}		
       
    41 	}
       
    42 
       
    43 void MbufGobblerHelper::LogMessage(const TDesC8& aSubTag, const TDesC8& aNodeName, TAny* aNodePtr, const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage)
       
    44 	{
       
    45 	// to eradicate warnings on builds for which the LOG macro does nothing (e.g. urel)
       
    46 	(void)(aSubTag); (void)(aNodeName); (void)(aNodePtr);
       
    47 
       
    48 	TInt msgId = aMessage.MessageId().MessageId();
       
    49 	TInt realm = aMessage.MessageId().Realm();
       
    50 	
       
    51 	TUint32 threadid_of_sender = aSender.Thread();
       
    52 	Messages::TNodeId nid = Messages::address_cast<Messages::TNodeId>(aSender);
       
    53 	TAny* ptr = nid.Ptr(); //this seems to be the only hting that can be used to print out something to address the node
       
    54 	TAny* rptr = aRecipient.Ptr();
       
    55 	__CFLOG_VAR((KMbufGobblerComponentTag, aSubTag,_L8("Node %S(0x%x) message received (msgid=%d, realm=0x%x), sender(0x%x threadID=%d)"), &aNodeName, rptr, msgId, realm, ptr, threadid_of_sender));
       
    56 	}
       
    57 
       
    58 void MbufGobblerHelper::PrintClientNodes(const TDesC8& aSubTag, const TDesC8& aNodeName, MeshMachine::AMMNodeBase& aNode, TInt& aClientCount)
       
    59 	{
       
    60 	// to eradicate warnings on builds for which the LOG macro does nothing (e.g. urel)
       
    61 	(void)(aSubTag); (void)(aNodeName);
       
    62 
       
    63 	TUint type = ESock::TCFClientType::EData | ESock::TCFClientType::ECtrl | ESock::TCFClientType::EServProvider | ESock::TCFClientType::ECtrlProvider;
       
    64 	TInt totclients =  	aNode.CountClients<Messages::TDefaultClientMatchPolicy>(type);
       
    65 	//only print if count different than previous
       
    66 	if(aClientCount != totclients)
       
    67 		{
       
    68 		aClientCount = 	totclients;
       
    69 		LOG(aSubTag,_L8("Printing Node %S(0x%x) info..."), &aNodeName, aNode.Id().Ptr());
       
    70 		LOG(aSubTag, _L8("\tTotal Num clients = %d"), totclients);
       
    71 		
       
    72 		//enumerate through clients	
       
    73 		Messages::TClientIter<Messages::TDefaultClientMatchPolicy> clientIter(aNode.GetClientIter<Messages::TDefaultClientMatchPolicy>(type));
       
    74 		Messages::RNodeInterface* client = clientIter++;
       
    75 		while (client)
       
    76 			{
       
    77 			
       
    78 			Messages::TNodeId id = client->RecipientId();
       
    79 			//look up node type
       
    80 			TBuf8<20> typlu;
       
    81 			switch(client->Type())
       
    82 				{
       
    83 				case ESock::TCFClientType::EUnknown:
       
    84 					typlu = _L8("EUnknown");
       
    85 					break;
       
    86 				case ESock::TCFClientType::EData:
       
    87 					typlu = _L8("EData");
       
    88 					break;
       
    89 				case ESock::TCFClientType::ECtrl:
       
    90 					typlu = _L8("ECtrl");
       
    91 					break;
       
    92 				case ESock::TCFClientType::EServProvider:
       
    93 					typlu = _L8("EServProvider");
       
    94 					break;
       
    95 				case ESock::TCFClientType::ECtrlProvider:
       
    96 					typlu = _L8("ECtrlProvider");
       
    97 					break;
       
    98 				default:
       
    99 					typlu = _L8("Unknown");
       
   100 					break;
       
   101 				}
       
   102 			LOG(aSubTag, _L8("\t\tClientNode(0x%x) type=%d(%S), flags=%d"), id.Ptr(), client->Type(), &typlu, client->Flags());
       
   103 			client = clientIter++;
       
   104 			}
       
   105 		}
       
   106 		
       
   107 	}
       
   108