ximpfw/core/srcdatamodel/ximpcontextstateeventimp.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     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:  MXIMPContextStateEvent API object implementation.
       
    15  *
       
    16 */
       
    17 
       
    18 #include <s32strm.h>
       
    19 
       
    20 #include "ximpcontextstateimp.h"
       
    21 #include "ximpstatusimp.h"
       
    22 #include "ximpcontextstateeventimp.h"
       
    23 
       
    24 
       
    25 namespace
       
    26     {
       
    27     enum TStatusObjectExistency
       
    28         {
       
    29         ENoStatusObject = 0,
       
    30         EHasStatusObject = 1
       
    31         };
       
    32     }
       
    33 
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // CXIMPContextStateEventImp::NewLC()
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C CXIMPContextStateEventImp* CXIMPContextStateEventImp::NewLC()
       
    40     {
       
    41     CXIMPContextStateEventImp* self = new( ELeave ) CXIMPContextStateEventImp();
       
    42     CleanupStack::PushL( self );
       
    43     self->ConstructL();
       
    44     return self;
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CXIMPContextStateEventImp::NewL()
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C CXIMPContextStateEventImp* CXIMPContextStateEventImp::NewL()
       
    53     {
       
    54     CXIMPContextStateEventImp* self = CXIMPContextStateEventImp::NewLC();
       
    55     CleanupStack::Pop( self );
       
    56     return self;
       
    57     }
       
    58 
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CXIMPContextStateEventImp::NewFromStreamLC()
       
    62 // Instantiation method for event automation.
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CXIMPApiEventBase* CXIMPContextStateEventImp::NewFromStreamLC(
       
    66         RReadStream& aStream )
       
    67     {
       
    68     CXIMPContextStateEventImp* self = new( ELeave ) CXIMPContextStateEventImp;
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL( aStream );
       
    71     return self;
       
    72     }
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CXIMPContextStateEventImp::~CXIMPContextStateEventImp()
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CXIMPContextStateEventImp::~CXIMPContextStateEventImp()
       
    80     {
       
    81     delete iState;
       
    82     delete iStateChangeReason;
       
    83     }
       
    84 
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // CXIMPContextStateEventImp::CXIMPContextStateEventImp()
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 CXIMPContextStateEventImp::CXIMPContextStateEventImp()
       
    91     {
       
    92     }
       
    93 
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CXIMPContextStateEventImp::ConstructL()
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CXIMPContextStateEventImp::ConstructL()
       
   100     {
       
   101     iState = CXIMPContextStateImp::NewL();
       
   102     }
       
   103 
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CXIMPContextStateEventImp::ConstructL()
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void CXIMPContextStateEventImp::ConstructL( RReadStream& aStream )
       
   110     {
       
   111     iState = CXIMPContextStateImp::NewL();
       
   112     iState->InternalizeL( aStream );
       
   113 
       
   114 
       
   115     TStatusObjectExistency exists =
       
   116              ( TStatusObjectExistency ) aStream.ReadInt8L();
       
   117 
       
   118     if( exists  == EHasStatusObject )
       
   119         {
       
   120         iStateChangeReason = CXIMPStatusImp::NewL();
       
   121         iStateChangeReason->InternalizeL( aStream );
       
   122         }
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // Implement supported interface access.
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( CXIMPContextStateEventImp,
       
   130                                      MXIMPContextStateEvent )
       
   131     XIMPIMP_IF_BASE_GET_CLASS( CXIMPApiEventBase, this )
       
   132 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
   133 
       
   134 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( CXIMPContextStateEventImp,
       
   135                                            MXIMPContextStateEvent )
       
   136     XIMPIMP_IF_BASE_GET_CONST_CLASS( CXIMPApiEventBase, this ) 
       
   137 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
   138 
       
   139 
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // Implement methods from base event interface and base event class
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 XIMPIMP_IMPLEMENT_EVENT_BASE_METHODS( CXIMPContextStateEventImp,
       
   146                                       MXIMPContextStateEvent )
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CXIMPContextStateEventImp::EqualsContent()
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 TBool CXIMPContextStateEventImp::EqualsContent( 
       
   153     const CXIMPApiEventBase& aOtherInstance ) const 
       
   154     {
       
   155     const CXIMPContextStateEventImp* tmp =
       
   156     TXIMPGetImpClassOrPanic< const CXIMPContextStateEventImp>::From( 
       
   157                                                        aOtherInstance.Base() );
       
   158     
       
   159     TBool same = ETrue;
       
   160 
       
   161     TBool x = iState->EqualsContent(*(tmp->iState));
       
   162     same &= x;
       
   163 
       
   164 	
       
   165 	if( (!iStateChangeReason) && (!tmp->iStateChangeReason) )
       
   166 		{
       
   167 		//both are NULL
       
   168 		same &= ETrue;
       
   169 		}
       
   170 	else if ((iStateChangeReason) && (tmp->iStateChangeReason))
       
   171 		{
       
   172 		//both not NULL, contents need to be checked
       
   173     x = iStateChangeReason->ResultCode() == tmp->iStateChangeReason->ResultCode();
       
   174     same &= x;
       
   175 
       
   176     x = 0 == iStateChangeReason->ProtocolResultDescription().Compare(
       
   177                 tmp->iStateChangeReason->ProtocolResultDescription() );
       
   178     same &= x;
       
   179 		}
       
   180 	else
       
   181 		{
       
   182 		// One of them is NULL
       
   183 		same &= EFalse;		
       
   184 		}
       
   185 
       
   186     return same;
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CXIMPContextStateEventImp::ExternalizeL()
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 void CXIMPContextStateEventImp::ExternalizeL( RWriteStream& aStream ) const
       
   194     {
       
   195     iState->ExternalizeL( aStream );
       
   196 
       
   197     if( iStateChangeReason )
       
   198         {
       
   199         aStream.WriteInt8L( EHasStatusObject );
       
   200         iStateChangeReason->ExternalizeL( aStream );
       
   201         }
       
   202     else
       
   203         {
       
   204         aStream.WriteInt8L( ENoStatusObject );
       
   205         }
       
   206     }
       
   207 
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // CXIMPContextStateEventImp::StateChangeReason()
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 const MXIMPStatus* CXIMPContextStateEventImp::StateChangeReason() const
       
   214     {
       
   215     return iStateChangeReason;
       
   216     }
       
   217 
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // CXIMPContextStateEventImp::ContextState()
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 const MXIMPContextState&
       
   224     CXIMPContextStateEventImp::ContextState() const
       
   225     {
       
   226     return *iState;
       
   227     }
       
   228 
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // CXIMPContextStateEventImp::ContextStateImp()
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C CXIMPContextStateImp&
       
   235     CXIMPContextStateEventImp::ContextStateImp()
       
   236     {
       
   237     return *iState;
       
   238     }
       
   239 
       
   240 
       
   241 // ---------------------------------------------------------------------------
       
   242 // CXIMPContextStateEventImp::SetStateChangeReasonImp()
       
   243 // ---------------------------------------------------------------------------
       
   244 //
       
   245 EXPORT_C void CXIMPContextStateEventImp::SetStateChangeReasonImp(
       
   246     CXIMPStatusImp* aStateChangeReason )
       
   247     {
       
   248     delete iStateChangeReason;
       
   249     iStateChangeReason = aStateChangeReason; 
       
   250     }
       
   251     
       
   252 
       
   253 // ---------------------------------------------------------------------------
       
   254 // CXIMPContextStateEventImp::StateChangeReasonImp()
       
   255 // ---------------------------------------------------------------------------
       
   256 //
       
   257 EXPORT_C CXIMPStatusImp*
       
   258     CXIMPContextStateEventImp::StateChangeReasonImp()
       
   259     {
       
   260     return iStateChangeReason;
       
   261     }
       
   262 
       
   263 
       
   264 // End of file
       
   265