ximpfw/core/srcdatamodel/ximpserviceinfoimp.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:  MXIMPServiceInfo API object implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "ximpserviceinfoimp.h"
       
    19 #include "ximprbufhelpers.h"
       
    20 
       
    21 
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS =============================
       
    24 
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CXIMPServiceInfoImp::NewLC()
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 EXPORT_C CXIMPServiceInfoImp* CXIMPServiceInfoImp::NewLC()
       
    31     {
       
    32     CXIMPServiceInfoImp* self = new( ELeave ) CXIMPServiceInfoImp;
       
    33     CleanupStack::PushL( self );
       
    34     self->ConstructL();
       
    35     return self;
       
    36     }
       
    37     
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CXIMPServiceInfoImp::NewL()
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C CXIMPServiceInfoImp* CXIMPServiceInfoImp::NewL()
       
    44     {
       
    45     CXIMPServiceInfoImp* self = NewLC();
       
    46     CleanupStack::Pop( self );
       
    47     return self;
       
    48     }
       
    49     
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CXIMPServiceInfoImp::NewLC()
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CXIMPServiceInfoImp* CXIMPServiceInfoImp::NewLC(
       
    57                                              TUid aProtocolImplUid,
       
    58                                              const TDesC16& aServiceAddress,
       
    59                                              const TDesC16& aUsername,
       
    60                                              const TDesC16& aPassword,
       
    61                                              TInt32 aIapId )
       
    62     {
       
    63     CXIMPServiceInfoImp* self = new( ELeave ) CXIMPServiceInfoImp();
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL( aProtocolImplUid, aServiceAddress, aUsername, aPassword, aIapId );
       
    66     return self;
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CXIMPServiceInfoImp::~CXIMPServiceInfoImp()
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CXIMPServiceInfoImp::~CXIMPServiceInfoImp()
       
    74     {
       
    75     iAddress.Close();
       
    76     iUserId.Close();
       
    77     iPassword.Close();
       
    78     }
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CXIMPServiceInfoImp::CXIMPServiceInfoImp()
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 CXIMPServiceInfoImp::CXIMPServiceInfoImp()
       
    86     {
       
    87     }
       
    88 
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CXIMPServiceInfoImp::ConstructL()
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void CXIMPServiceInfoImp::ConstructL( TUid aProtocolImplUid,
       
    95                                       const TDesC16& aServiceAddress,
       
    96                                       const TDesC16& aUsername,
       
    97                                       const TDesC16& aPassword,
       
    98                                       TInt32 aIapId )
       
    99     {
       
   100     iProtocolUid = aProtocolImplUid;
       
   101     iIapId = aIapId;
       
   102     iAddress.CreateL( aServiceAddress );
       
   103     iUserId.CreateL( aUsername );
       
   104     iPassword.CreateL( aPassword );
       
   105     }
       
   106 
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // CXIMPServiceInfoImp::ConstructL()
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CXIMPServiceInfoImp::ConstructL()
       
   113     {
       
   114     // Initialize RBufs to zero length, realloc later when needed
       
   115     iAddress.CreateL( 0 );
       
   116     iUserId.CreateL( 0 );
       
   117     iPassword.CreateL( 0 );
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CXIMPServiceInfoImp::NewFromStreamLC()
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 XIMPIMP_IMPLEMENT_DATAOBJ_NEWFROMSTREAM( CXIMPServiceInfoImp )
       
   125 
       
   126 
       
   127 // ---------------------------------------------------------------------------
       
   128 // Implement supported interface access.
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( CXIMPServiceInfoImp, 
       
   132                                      MXIMPServiceInfo )
       
   133 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
   134 
       
   135 
       
   136 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( CXIMPServiceInfoImp, 
       
   137                                            MXIMPServiceInfo )
       
   138 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
   139 
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // From class MXIMPServiceInfo.
       
   143 // CXIMPServiceInfoImp::Address()
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 const TDesC16& CXIMPServiceInfoImp::ServiceAddress() const
       
   147     {
       
   148     return iAddress;
       
   149     }
       
   150 
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // From class MXIMPServiceInfo.
       
   154 // CXIMPServiceInfoImp::UserId()
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 const TDesC16& CXIMPServiceInfoImp::UserId() const
       
   158     {
       
   159     return iUserId;
       
   160     }
       
   161 
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // From class MXIMPServiceInfo.
       
   165 // CXIMPServiceInfoImp::Password()
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 const TDesC16& CXIMPServiceInfoImp::Password() const
       
   169     {
       
   170     return iPassword;
       
   171     }
       
   172 
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // From class MXIMPServiceInfo.
       
   176 // CXIMPServiceInfoImp::IapId()
       
   177 // ---------------------------------------------------------------------------
       
   178 //
       
   179 TInt32 CXIMPServiceInfoImp::IapId() const
       
   180     {
       
   181     return iIapId;
       
   182     }
       
   183 
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // From class MXIMPServiceInfo.
       
   187 // CXIMPServiceInfoImp::ProtocolImplUid()
       
   188 // ---------------------------------------------------------------------------
       
   189 //
       
   190 TUid CXIMPServiceInfoImp::ProtocolImplUid() const
       
   191     {
       
   192     return iProtocolUid;
       
   193     }
       
   194 
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // CXIMPServiceInfoImp::ExternalizeL()
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 void CXIMPServiceInfoImp::ExternalizeL( RWriteStream& aStream ) const
       
   201     {
       
   202     XIMPRBuf16Helper::ExternalizeL( iAddress, aStream );
       
   203     XIMPRBuf16Helper::ExternalizeL( iUserId, aStream );
       
   204     XIMPRBuf16Helper::ExternalizeL( iPassword, aStream );
       
   205 
       
   206     aStream.WriteInt32L( iProtocolUid.iUid );
       
   207     aStream.WriteInt32L( iIapId );
       
   208     }
       
   209 
       
   210 
       
   211 // ---------------------------------------------------------------------------
       
   212 // CXIMPServiceInfoImp::InternalizeL()
       
   213 // ---------------------------------------------------------------------------
       
   214 //
       
   215 EXPORT_C void CXIMPServiceInfoImp::InternalizeL( RReadStream& aStream )
       
   216     {
       
   217     XIMPRBuf16Helper::InternalizeL( iAddress, aStream );
       
   218     XIMPRBuf16Helper::InternalizeL( iUserId, aStream );
       
   219     XIMPRBuf16Helper::InternalizeL( iPassword, aStream );
       
   220 
       
   221     iProtocolUid.iUid = aStream.ReadInt32L();
       
   222     iIapId = aStream.ReadInt32L();
       
   223     }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 // CXIMPServiceInfoImp::EqualsContent()
       
   227 // ---------------------------------------------------------------------------
       
   228 //
       
   229 TBool CXIMPServiceInfoImp::EqualsContent( 
       
   230     const CXIMPApiDataObjBase& aOtherInstance ) const
       
   231     {
       
   232     const CXIMPServiceInfoImp* tmp =
       
   233     TXIMPGetImpClassOrPanic< const CXIMPServiceInfoImp >::From( aOtherInstance.Base() );
       
   234     
       
   235 
       
   236     TBool same = ETrue;
       
   237     TBool x = EFalse;
       
   238 
       
   239     if( ServiceAddress().Compare( tmp->ServiceAddress() ) == 0 &&
       
   240         UserId().Compare( tmp->UserId() ) == 0 &&
       
   241         Password().Compare( tmp->Password() ) == 0 &&
       
   242         ProtocolImplUid() == tmp->ProtocolImplUid() )
       
   243         {
       
   244         x = ETrue;
       
   245         }
       
   246     
       
   247     same &= x;
       
   248 
       
   249     return same;
       
   250     }
       
   251 
       
   252 
       
   253 // End of file