ximpfw/presence/srcpresencedatamodel/presentitygroups/presentitygroupinfoimp.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:  MPresencetityGrpouInfo API object implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "presentitygroupinfoimp.h"
       
    20 #include "ximpidentityimp.h"
       
    21 #include "ximprbufhelpers.h"
       
    22 #include "ximpobjecthelpers.h"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS =============================
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CPresentityGroupInfoImp::NewLC()
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 EXPORT_C CPresentityGroupInfoImp* CPresentityGroupInfoImp::NewLC( 
       
    31                                                 const MXIMPIdentity& aIdentity, 
       
    32                                                 const TDesC16& aDisplayName )
       
    33     {
       
    34     CPresentityGroupInfoImp* self = new( ELeave ) CPresentityGroupInfoImp;
       
    35     CleanupStack::PushL( self );
       
    36     self->ConstructL( aIdentity, aDisplayName );
       
    37     return self;
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CPresentityGroupInfoImp::NewLC()
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 EXPORT_C CPresentityGroupInfoImp* CPresentityGroupInfoImp::NewLC()
       
    45     {
       
    46     CPresentityGroupInfoImp* self = new( ELeave ) CPresentityGroupInfoImp;
       
    47     CleanupStack::PushL( self );
       
    48     self->ConstructL();
       
    49     return self;
       
    50     }
       
    51 
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CPresentityGroupInfoImp::NewL()
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 EXPORT_C CPresentityGroupInfoImp* CPresentityGroupInfoImp::NewL()
       
    58     {
       
    59     CPresentityGroupInfoImp* self = NewLC();
       
    60     CleanupStack::Pop( self );
       
    61     return self;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CPresentityGroupInfoImp::NewFromStreamLC()
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 XIMPIMP_IMPLEMENT_DATAOBJ_NEWFROMSTREAM( CPresentityGroupInfoImp )
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // Implement supported interface access.
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( CPresentityGroupInfoImp, MPresentityGroupInfo )
       
    75 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
    76 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( CPresentityGroupInfoImp, MPresentityGroupInfo )
       
    77 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CPresentityGroupInfoImp::~CPresentityGroupInfoImp()
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 CPresentityGroupInfoImp::~CPresentityGroupInfoImp()
       
    84     {
       
    85     iDisplayName.Close();
       
    86     delete iIdentity;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CPresentityGroupInfoImp::CPresentityGroupInfoImp()
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 CPresentityGroupInfoImp::CPresentityGroupInfoImp()
       
    94     {
       
    95     }
       
    96 
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CPresentityGroupInfoImp::ConstructL()
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CPresentityGroupInfoImp::ConstructL()
       
   103     {
       
   104     iDisplayName.CreateL( 0 );
       
   105     iIdentity = CXIMPIdentityImp::NewLC();
       
   106     CleanupStack::Pop( iIdentity );
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CPresentityGroupInfoImp::ConstructL()
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CPresentityGroupInfoImp::ConstructL( const MXIMPIdentity& aIdentity, 
       
   114                                               const TDesC16& aDisplayName )
       
   115     {
       
   116     const CXIMPIdentityImp* sourceIdentity =
       
   117     TXIMPGetImpClassOrPanic< const CXIMPIdentityImp >::From( aIdentity );
       
   118     iIdentity = TXIMPObjectCloner< CXIMPIdentityImp >::CloneL( *sourceIdentity );
       
   119 
       
   120     iDisplayName.CreateL( aDisplayName );
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // CPresentityGroupInfoImp::ExternalizeL()
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 void CPresentityGroupInfoImp::ExternalizeL( RWriteStream& aStream ) const
       
   128     {
       
   129     iIdentity->ExternalizeL( aStream );
       
   130     XIMPRBuf16Helper::ExternalizeL( iDisplayName, aStream );
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // CPresentityGroupInfoImp::InternalizeL()
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C void CPresentityGroupInfoImp::InternalizeL( RReadStream& aStream )
       
   138     {
       
   139     iIdentity->InternalizeL( aStream );
       
   140     XIMPRBuf16Helper::InternalizeL( iDisplayName, aStream );
       
   141     }
       
   142     
       
   143 // ---------------------------------------------------------------------------
       
   144 // From MPresentityGroupInfo class.
       
   145 // CPresentityGroupInfoImp::GroupId()
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 const MXIMPIdentity& CPresentityGroupInfoImp::GroupId() const
       
   149     {
       
   150     return *iIdentity;
       
   151     }
       
   152 
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // From MPresentityGroupInfo class.
       
   156 // CPresentityGroupInfoImp::GroupDisplayName()
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 const TDesC16& CPresentityGroupInfoImp::GroupDisplayName() const
       
   160     {
       
   161     return iDisplayName;
       
   162     }
       
   163 
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // From MPresentityGroupInfo class.
       
   167 // CPresentityGroupInfoImp::SetGroupIdL()
       
   168 // ---------------------------------------------------------------------------
       
   169 //
       
   170 void CPresentityGroupInfoImp::SetGroupIdL( MXIMPIdentity* aIdentity )
       
   171     {
       
   172     CXIMPIdentityImp* identityImp =
       
   173     TXIMPGetImpClassOrPanic< CXIMPIdentityImp>::From( *aIdentity );
       
   174 
       
   175     delete iIdentity;
       
   176     iIdentity = identityImp; 
       
   177     }
       
   178   
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // From MPresentityGroupInfo class.
       
   182 // CPresentityGroupInfoImp::SetGroupDisplayNameL()
       
   183 // ---------------------------------------------------------------------------
       
   184 //
       
   185 void CPresentityGroupInfoImp::SetGroupDisplayNameL( 
       
   186     const TDesC16& aDisplayName )
       
   187     {
       
   188     HBufC16* displayNameBuf = aDisplayName.AllocL();
       
   189     iDisplayName.Close();
       
   190     iDisplayName.Assign( displayNameBuf );
       
   191     }
       
   192     
       
   193     
       
   194 // ---------------------------------------------------------------------------
       
   195 // CPresentityGroupInfoImp::GroupIdLinearOrder
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 EXPORT_C TInt CPresentityGroupInfoImp::GroupIdLinearOrder( 
       
   199         const CPresentityGroupInfoImp& aA,
       
   200         const CPresentityGroupInfoImp& aB )
       
   201     {
       
   202     return aA.Identity().Compare( aB.Identity() );
       
   203     }
       
   204 
       
   205 // ---------------------------------------------------------------------------
       
   206 // CPresentityGroupInfoImp::Identity
       
   207 // ---------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C const CXIMPIdentityImp& CPresentityGroupInfoImp::Identity() const
       
   210     {
       
   211     return *iIdentity;
       
   212     }
       
   213 
       
   214 // ---------------------------------------------------------------------------
       
   215 // CPresentityGroupInfoImp::EqualsContent()
       
   216 // ---------------------------------------------------------------------------
       
   217 //
       
   218 TBool CPresentityGroupInfoImp::EqualsContent( 
       
   219     const CXIMPApiDataObjBase& aOtherInstance ) const
       
   220     {
       
   221     const CPresentityGroupInfoImp* tmp =
       
   222     TXIMPGetImpClassOrPanic< const CPresentityGroupInfoImp >::From( 
       
   223                                                         aOtherInstance.Base() );
       
   224     
       
   225     TBool same = ETrue;
       
   226     TBool x;
       
   227     x = iIdentity->EqualsContent( *( tmp->iIdentity ) );
       
   228     same &= x;
       
   229 
       
   230     x = 0 == iDisplayName.Compare( tmp->iDisplayName );
       
   231     same &= x;
       
   232 
       
   233     return same;
       
   234     }
       
   235 
       
   236 // End of file