imservices/searchfeatureplugin/srcsearchdatamodel/search/searchinfoimp.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2007 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:  MsearchInfo API object implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "searchinfoimp.h"
       
    19 #include "ximpidentityimp.h"
       
    20 #include "ximprbufhelpers.h"
       
    21 #include "ximpobjecthelpers.h"
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS =============================
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // CSearchInfoImp::NewLC()
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 EXPORT_C CSearchInfoImp* CSearchInfoImp::NewLC()
       
    30     {
       
    31     CSearchInfoImp* self = new( ELeave ) CSearchInfoImp;
       
    32     CleanupStack::PushL( self );
       
    33     self->ConstructL();
       
    34     return self;
       
    35     }
       
    36 
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CSearchInfoImp::NewL()
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C CSearchInfoImp* CSearchInfoImp::NewL()
       
    43     {
       
    44     CSearchInfoImp* self = NewLC();
       
    45     CleanupStack::Pop( self );
       
    46     return self;
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CSearchInfoImp::NewFromStreamLC()
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 XIMPIMP_IMPLEMENT_DATAOBJ_NEWFROMSTREAM( CSearchInfoImp )
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // Implement supported interface access.
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 XIMPIMP_IF_BASE_GET_INTERFACE_BEGIN( CSearchInfoImp, MSearchInfo )
       
    60 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
    61 XIMPIMP_IF_BASE_GET_CONST_INTERFACE_BEGIN( CSearchInfoImp, MSearchInfo )
       
    62 XIMPIMP_IF_BASE_GET_INTERFACE_END()
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CSearchInfoImp::~CSearchInfoImp()
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CSearchInfoImp::~CSearchInfoImp()
       
    69     {
       
    70     iFirstname.Close();
       
    71     iLastname.Close();
       
    72     iEmailId.Close();
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CSearchInfoImp::CSearchInfoImp()
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CSearchInfoImp::CSearchInfoImp()
       
    80     {
       
    81     }
       
    82 
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CSearchInfoImp::ConstructL()
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void CSearchInfoImp::ConstructL()
       
    89     {
       
    90     iFirstname.CreateL( 0 );
       
    91     iLastname.CreateL( 0 );
       
    92     iEmailId.CreateL( 0 );
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CSearchInfoImp::ExternalizeL()
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CSearchInfoImp::ExternalizeL( RWriteStream& aStream ) const
       
   100     {
       
   101   
       
   102     XIMPRBuf16Helper::ExternalizeL( iFirstname, aStream );
       
   103     XIMPRBuf16Helper::ExternalizeL( iLastname, aStream );
       
   104     XIMPRBuf16Helper::ExternalizeL( iEmailId, aStream ); 
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CSearchInfoImp::InternalizeL()
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 EXPORT_C void CSearchInfoImp::InternalizeL( RReadStream& aStream )
       
   112     {
       
   113     XIMPRBuf16Helper::InternalizeL( iFirstname, aStream );
       
   114     XIMPRBuf16Helper::InternalizeL( iLastname, aStream );
       
   115     XIMPRBuf16Helper::InternalizeL( iEmailId, aStream );
       
   116      
       
   117     }
       
   118   
       
   119 
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // From MSearchInfo class.
       
   123 // CSearchInfoImp::GetFieldInfo()
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 const TDesC16& CSearchInfoImp::GetFieldInfo(TInfoType aType) const
       
   127     {
       
   128      switch(aType)
       
   129 	     {
       
   130 	   	 case EFirstName:
       
   131 		   	 {
       
   132 		   	 return iFirstname;	
       
   133 		   	 }
       
   134 	   	 case ELastName:
       
   135 		   	 {
       
   136 		   	 return iLastname;	
       
   137 		   	 }
       
   138 	   	 case EEmailAddress:
       
   139 		   	 {
       
   140 		   	 return iEmailId;	
       
   141 		   	 }
       
   142 	     default :
       
   143 	         {
       
   144 	         return KNullDesC();
       
   145 	         }
       
   146 	     }
       
   147     }
       
   148     
       
   149 
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // From MsearchInfo class.
       
   153 // CSearchInfoImp::SetFieldInfoL()
       
   154 // ---------------------------------------------------------------------------
       
   155 //
       
   156 void CSearchInfoImp::SetFieldInfoL(const TDesC16& aFieldInfo ,TInfoType aType) 
       
   157     
       
   158     {
       
   159     switch(aType)
       
   160 	     {
       
   161 	   	 case EFirstName:
       
   162 		   	 {
       
   163 		   	 HBufC16* buf = aFieldInfo.AllocL();
       
   164     		 iFirstname.Close();
       
   165     		 iFirstname.Assign( buf );
       
   166 		   	 break;
       
   167 		   	 }
       
   168 	   	 case ELastName:
       
   169 		   	 {
       
   170 		   	 HBufC16* buf= aFieldInfo.AllocL();
       
   171     		 iLastname.Close();
       
   172              iLastname.Assign( buf );
       
   173 		   	 break;	
       
   174 		   	 }
       
   175 	   	 case EEmailAddress:
       
   176 		   	 {
       
   177 		   	 HBufC16* buf = aFieldInfo.AllocL();
       
   178     		 iEmailId.Close();
       
   179     		 iEmailId.Assign( buf );
       
   180 		   	 break;	
       
   181 		   	 }
       
   182 	   
       
   183 	     }
       
   184    
       
   185     }
       
   186  
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // CSearchInfoImp::EqualsContent()
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 TBool CSearchInfoImp::EqualsContent( 
       
   193     const CXIMPApiDataObjBase& /*aOtherInstance*/ ) const
       
   194     {
       
   195     return ETrue; 
       
   196     }
       
   197 // ---------------------------------------------------------------------------
       
   198 // CSearchInfoImp:: InfoLinearOrder
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 EXPORT_C TInt CSearchInfoImp::InfoLinearOrder(
       
   202         const CSearchInfoImp& /*aA*/,
       
   203         const CSearchInfoImp& /*aB*/ )
       
   204     {
       
   205     // Just returns 1 so that the results are appended as they come from server.
       
   206     return 1;
       
   207     }
       
   208     
       
   209 
       
   210 // End of file