bluetoothengine/bthid/bthidserver/inc/datasegmenter.h
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     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:  Declares main application class.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CMDSEGMENTER_H__
       
    20 #define __CMDSEGMENTER_H__
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 /*!
       
    25  This utility class segments large commands into MTU size packets
       
    26  */
       
    27 class CDataSegmenter : public CBase
       
    28     {
       
    29 public:
       
    30 
       
    31     /*!
       
    32      Create a CDataSegmenter object
       
    33      @result a pointer to the created instance of CDataSegmenter
       
    34      */
       
    35     static CDataSegmenter* NewL();
       
    36 
       
    37     /*!
       
    38      Create a CDataSegmenter object
       
    39      @result a pointer to the created instance of CDataSegmenter
       
    40      */
       
    41     static CDataSegmenter* NewLC();
       
    42 
       
    43     /*!
       
    44      Destroy the object and release all memory objects
       
    45      */
       
    46     ~CDataSegmenter();
       
    47 
       
    48     /*!
       
    49      Prepares buffers for sending a large command, possibly in separate packets.
       
    50      @param aInitialHeader the header to use in the first packet.
       
    51      @param aPayload the payload section of the packet.
       
    52      @param aAdditionalHeader the header byte to use on continuation packets.
       
    53      @param aMTU the current MTU for a packet.
       
    54      */
       
    55     void SegmentDataL(const TDesC8& aInitialHeader, const TDesC8& aPayload,
       
    56             TChar aAdditionalHeaderByte, TInt aMTU);
       
    57 
       
    58     /*!
       
    59      Retrieves the first packet in a sequence.
       
    60      Function will leave if there is no data packet to return.
       
    61      @result a pointer to the data packet
       
    62      */
       
    63     const HBufC8* FirstPacketL() const;
       
    64 
       
    65     /*!
       
    66      Retrieves the next packet in a sequence.
       
    67      @result a pointer to the data packet
       
    68      @result 0 if there are no more packets
       
    69      */
       
    70     const HBufC8* NextPacket();
       
    71 
       
    72     /*!
       
    73      Resets the state of the object
       
    74      */
       
    75     void Reset();
       
    76 
       
    77 private:
       
    78 
       
    79     /*!
       
    80      Constructs this object
       
    81      */
       
    82     CDataSegmenter();
       
    83 
       
    84     /*!
       
    85      Performs second phase construction of this object
       
    86      */
       
    87     void ConstructL();
       
    88 
       
    89 private:
       
    90     /*! Dynamic buffer to hold a command packet */
       
    91     HBufC8* iPacket;
       
    92 
       
    93     /*! Dynamic buffer used to hold payload not sent in first packet */
       
    94     HBufC8* iPayloadBuf;
       
    95 
       
    96     /*! Pointer to the current remaining payload */
       
    97     TPtrC8 iPayloadBufPtr;
       
    98 
       
    99     /*! The current maximum size of a packet */
       
   100     TInt iMTU;
       
   101 
       
   102     /*! The header byte to use on continuation packets */
       
   103     TChar iAdditionalHeaderByte;
       
   104     };
       
   105 
       
   106 #endif // __CMDSEGMENTER_H__