ximpfw/presence/srcpresencedatamodel/presencepublishing/ownpresenceeventimp.cpp
changeset 51 61fad867f68e
equal deleted inserted replaced
-1:000000000000 51:61fad867f68e
       
     1 /*
       
     2 * Copyright (c) 2006 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:  MOwnPresenceEvent API object implementation.
       
    15  *
       
    16 */
       
    17 
       
    18 #include "ownpresenceeventimp.h"
       
    19 #include "presenceinfoimp.h"
       
    20 #include "ximpobjecthelpers.h"
       
    21 #include "ximpdatasubscriptionstateimp.h"
       
    22 #include <s32strm.h>
       
    23 
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // COwnPresenceEventImp::NewLC()
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 EXPORT_C COwnPresenceEventImp* COwnPresenceEventImp::NewLC(
       
    30     CXIMPDataSubscriptionStateImp* aState )
       
    31     {
       
    32     COwnPresenceEventImp* self = new( ELeave ) COwnPresenceEventImp();
       
    33     CleanupStack::PushL( self );
       
    34     self->ConstructL( aState );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // COwnPresenceEventImp::NewL()
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C COwnPresenceEventImp* COwnPresenceEventImp::NewL(
       
    43     CXIMPDataSubscriptionStateImp* aState )
       
    44     {
       
    45     COwnPresenceEventImp* self = NewLC( aState );
       
    46     CleanupStack::Pop( self );
       
    47     return self;
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // COwnPresenceEventImp::NewFromStreamLC()
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 CXIMPApiEventBase* COwnPresenceEventImp::NewFromStreamLC( RReadStream& aStream )
       
    56     {
       
    57     COwnPresenceEventImp* self = new( ELeave ) COwnPresenceEventImp;
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL( aStream );
       
    60     return self;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // COwnPresenceEventImp::~COwnPresenceEventImp()
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 COwnPresenceEventImp::~COwnPresenceEventImp()
       
    68     {
       
    69     delete iPresenceInfo;
       
    70     delete iSubscriptionState;
       
    71     }
       
    72 
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // COwnPresenceEventImp::COwnPresenceEventImp()
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 COwnPresenceEventImp::COwnPresenceEventImp()
       
    79     {
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // COwnPresenceEventImp::ConstructL()
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void COwnPresenceEventImp::ConstructL( CXIMPDataSubscriptionStateImp* aState )
       
    87     {
       
    88     iSubscriptionState = aState;
       
    89     iPresenceInfo = CPresenceInfoImp::NewL();
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // COwnPresenceEventImp::ConstructL()
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 void COwnPresenceEventImp::ConstructL( RReadStream& aStream )
       
    97     {
       
    98     iSubscriptionState = CXIMPDataSubscriptionStateImp::NewL();
       
    99     iPresenceInfo = CPresenceInfoImp::NewL();
       
   100     InternalizeL( aStream );
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // Implement supported interface access.
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( COwnPresenceEventImp,
       
   108                                      MOwnPresenceEvent )
       
   109     XIMPIMP_IF_BASE_GET_CLASS( CXIMPApiEventBase, this )
       
   110 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
   111 
       
   112 
       
   113 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( COwnPresenceEventImp,
       
   114                                            MOwnPresenceEvent )
       
   115     XIMPIMP_IF_BASE_GET_CONST_CLASS( CXIMPApiEventBase, this )                                            
       
   116 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
   117 
       
   118 
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // Implement methods from base event interface and base event class
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 XIMPIMP_IMPLEMENT_EVENT_BASE_METHODS( COwnPresenceEventImp,
       
   125                                       MOwnPresenceEvent )
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // COwnPresenceEventImp::EqualsContent()
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 TBool COwnPresenceEventImp::EqualsContent( 
       
   132     const CXIMPApiEventBase& aOtherInstance ) const
       
   133     {
       
   134     const COwnPresenceEventImp* tmp =
       
   135     TXIMPGetImpClassOrPanic< const COwnPresenceEventImp>::From( aOtherInstance.Base() );
       
   136 
       
   137 
       
   138     TBool same = ETrue;
       
   139 
       
   140     TBool x = iPresenceInfo->EqualsContent( *tmp->iPresenceInfo );
       
   141     same &= x;
       
   142     
       
   143     x = iSubscriptionState->EqualsContent( *tmp->iSubscriptionState );
       
   144     same &= x;
       
   145 
       
   146     return same;
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // From class CXIMPApiEventBase.
       
   151 // COwnPresenceEventImp::ExternalizeL()
       
   152 // ---------------------------------------------------------------------------
       
   153 //
       
   154 void COwnPresenceEventImp::ExternalizeL( RWriteStream& aStream ) const
       
   155     {
       
   156     iPresenceInfo->ExternalizeL( aStream );
       
   157     iSubscriptionState->ExternalizeL( aStream );
       
   158     }
       
   159 
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // COwnPresenceEventImp::InternalizeL()
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void COwnPresenceEventImp::InternalizeL( RReadStream& aStream )
       
   166     {
       
   167     iPresenceInfo->InternalizeL( aStream );
       
   168     iSubscriptionState->InternalizeL( aStream );
       
   169     }
       
   170 
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // From class MOwnPresenceEvent.
       
   174 // COwnPresenceEventImp::Status()
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 const MXIMPDataSubscriptionState&
       
   178     COwnPresenceEventImp::DataSubscriptionState() const
       
   179     {
       
   180     return *iSubscriptionState;
       
   181     }
       
   182 
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // From class MOwnPresenceEvent.
       
   186 // COwnPresenceEventImp::SubscribedPresence()
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 const MPresenceInfo& 
       
   190     COwnPresenceEventImp::SubscribedPresence() const
       
   191     {
       
   192     return *iPresenceInfo;
       
   193     }
       
   194 
       
   195 // ---------------------------------------------------------------------------
       
   196 // COwnPresenceEventImp::SetPresenceInfo
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 void COwnPresenceEventImp::SetPresenceInfo( CPresenceInfoImp* aInfoImp )
       
   200     {
       
   201     delete iPresenceInfo;
       
   202     iPresenceInfo = aInfoImp;
       
   203     }
       
   204 
       
   205 // End of file
       
   206