networkprotocols/iphook/inhook6example/src/exaout.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2004-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 // exaout.cpp - Outbound plugin example module
       
    15 //
       
    16 
       
    17 #include "exaout.h"
       
    18 
       
    19 CExaoutFlowInfo::CExaoutFlowInfo( CFlowContext &aFlow) : iFlow(aFlow)
       
    20 	/**
       
    21 	* Constructor.
       
    22 	*
       
    23 	* @param aFlow	The flow context.
       
    24 	*/
       
    25 	{
       
    26 	}
       
    27 
       
    28 CExaoutFlowInfo::~CExaoutFlowInfo()
       
    29 	/**
       
    30 	* Destructor.
       
    31 	*
       
    32 	* The #iMgr value indicates whether object is still linked
       
    33 	* or not (because, depending on how CProtocolExaout::NetworkDetached()
       
    34 	* or destructor has been implemented, this could be a <em>floating flow</em>,
       
    35 	* which is not attached to the protocol any more).
       
    36 	*
       
    37 	* However, if this is still attached, then must detach the the flow
       
    38 	* from the protocol instance.
       
    39 	*/
       
    40 	{
       
    41 /** @code */
       
    42 	if (iMgr)
       
    43 		{
       
    44 		iMgr = NULL;
       
    45 		iDLink.Deque();
       
    46 		}
       
    47 /** @endcode */
       
    48 	}
       
    49 
       
    50 
       
    51 MFlowHook *CProtocolExaout::OpenL(TPacketHead& /*aHead*/, CFlowContext* aFlow)
       
    52 	/**
       
    53 	* A new flow is opening.
       
    54 	*
       
    55 	* This example attaches to every flow.
       
    56 	*
       
    57 	* @param aFlow	The flow context.
       
    58 	*/
       
    59 	{
       
    60 	CExaoutFlowInfo* info = new (ELeave) CExaoutFlowInfo(*aFlow);
       
    61 	iFlowList.AddLast(*info);	// Save the flow info for later use
       
    62 	info->iMgr = this;			// info is now linked!
       
    63 	return info;
       
    64 	}
       
    65 
       
    66 TInt CExaoutFlowInfo::ReadyL(TPacketHead& /*aHead*/)
       
    67 	/**
       
    68 	* A flow has been connect to interface.
       
    69 	*
       
    70 	* This is called when the flow has been connected to the interface,
       
    71 	* source address has been selected.
       
    72 	*
       
    73 	* The example does not have any reason to block the connection
       
    74 	* process, and thus always returns READY.
       
    75 	*
       
    76 	* @return EFlow_READY always.
       
    77 	*/
       
    78 	{
       
    79 /** code */
       
    80 	return EFlow_READY;
       
    81 /** @endcode */
       
    82 	}
       
    83 
       
    84 //
       
    85 // Applies all the remaining modifications needed for every outgoing packet
       
    86 //
       
    87 TInt CExaoutFlowInfo::ApplyL(RMBufSendPacket& /*aPacket*/, RMBufSendInfo& /*aInfo*/)
       
    88 	/**
       
    89 	* A outbound packet is being sent to the flow.
       
    90 	*
       
    91 	* The example is dummy, and does do anything with the packet,
       
    92 	* return always KErrNone (= packet processed). For some example,
       
    93 	* see MFlowHook::ApplyL example.
       
    94 	*
       
    95 	* @return KErrNone
       
    96 	*/
       
    97 	{
       
    98 /** @code */
       
    99 	//
       
   100 	// This would contain any packet processing code.
       
   101 	// 
       
   102 	return KErrNone;
       
   103 /** @endcode */
       
   104 	}
       
   105 
       
   106 void CExaoutFlowInfo::Close()
       
   107 	/**
       
   108 	* The reference counting, one less.
       
   109 	*
       
   110 	* The MFlowHook objects <b>must implement</b> reference counting semantics
       
   111 	* and they must automaticly self-destruct after the last reference
       
   112 	* is removed.
       
   113 	*
       
   114 	* A object returned by OpenL counts as one reference. As each
       
   115 	* flow gets own object, the initial value after CBase construction
       
   116 	* is 0. This is not touched, and thus, the object is deleted when
       
   117 	* the count goes negative.
       
   118 	*/
       
   119 	{
       
   120 /** @code */
       
   121 	if (--iRefs < 0)
       
   122 		{
       
   123 		delete this;
       
   124 		}
       
   125 /** @endcode */
       
   126 	}
       
   127 
       
   128 void CExaoutFlowInfo::Open()
       
   129 	/**
       
   130 	* The reference counting, one more.
       
   131 	*
       
   132 	* The MFlowHook objects <b>must implement</b> reference counting semantics
       
   133 	* and they must automaticly self-destruct after the last reference
       
   134 	* is removed.
       
   135 	*/
       
   136 	{
       
   137 /** @code */
       
   138 	iRefs++;
       
   139 /** @endcode */
       
   140 	}