mmsengine/mmsmessage/src/mmssendingchain.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2003 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:   Structure to hold MMS encapsulation 1.1 version
       
    15 *                previoulsy-sent-by and previously-sent-date information  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include    "mmssendingchain.h"
       
    24 
       
    25 // EXTERNAL DATA STRUCTURES
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // LOCAL CONSTANTS AND MACROS
       
    34 
       
    35 // MODULE DATA STRUCTURES
       
    36 
       
    37 // LOCAL FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 // ============================= LOCAL FUNCTIONS ===============================
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CMmsSendingChain::CMmsSendingChain
       
    47 // C++ default constructor can NOT contain any code, that
       
    48 // might leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CMmsSendingChain::CMmsSendingChain()
       
    52     {
       
    53     // everything is initailized to 0 by CBase
       
    54     }
       
    55 
       
    56     
       
    57 // Destructor
       
    58 CMmsSendingChain::~CMmsSendingChain()
       
    59     {
       
    60     delete iSender;
       
    61     }
       
    62 
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CMmsSendingChain::Compare
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 TInt CMmsSendingChain::Compare(
       
    69     const CMmsSendingChain& aFirst,
       
    70     const CMmsSendingChain& aSecond )
       
    71     {
       
    72     if ( aFirst.iOrder == aSecond.iOrder )
       
    73         {
       
    74         return 0;
       
    75         }
       
    76     if ( aFirst.iOrder > aSecond.iOrder )
       
    77         {
       
    78         return 1;
       
    79         }
       
    80     else
       
    81         {
       
    82         return -1;
       
    83         }
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CMmsSendingChain::InternalizeL
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CMmsSendingChain::InternalizeL( RMsvReadStream& aStream )
       
    91     {
       
    92     aStream >> iOrder;
       
    93     aStream >> iDate;
       
    94     TInt32 length;
       
    95     aStream >> length;
       
    96     delete iSender;
       
    97     iSender = NULL;
       
    98     if ( length > 0 )
       
    99         {
       
   100         iSender = HBufC::NewL( aStream, length );
       
   101         }
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CMmsSendingChain::ExternalizeL
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CMmsSendingChain::ExternalizeL( RMsvWriteStream& aStream ) const
       
   109     {
       
   110     aStream << iOrder;
       
   111     aStream << iDate;
       
   112     TInt32 length = Sender().Length();
       
   113     aStream << length;
       
   114     if ( length > 0 )
       
   115         {
       
   116         aStream << Sender();
       
   117         }
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CMmsSendingChain::Sender
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 EXPORT_C TPtrC CMmsSendingChain::Sender() const
       
   125     {
       
   126     return iSender ? TPtrC( *iSender ) : TPtrC(); 
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CMmsSendingChain::SetSenderL
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 
       
   134 EXPORT_C void CMmsSendingChain::SetSenderL( const TDesC& aSender )
       
   135     {
       
   136     HBufC* newAttrib = aSender.AllocL();
       
   137     delete iSender;
       
   138     iSender = newAttrib;
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CMmsSendingChain::Size
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 TInt CMmsSendingChain::Size() const
       
   146     {
       
   147     TInt size = 0;
       
   148     size += sizeof( iOrder );
       
   149     size += sizeof( iDate );
       
   150     size += sizeof( TInt32 );
       
   151     size += Sender().Size();
       
   152     return size;
       
   153     }
       
   154 
       
   155 
       
   156 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   157 
       
   158 //  End of File