phoneengine/phonecntfinder2/src/cphcntcontactidimpl2.cpp
changeset 21 92ab7f8d0eab
child 22 6bb1b21d2484
equal deleted inserted replaced
4:c84cf270c54f 21:92ab7f8d0eab
       
     1 /*!
       
     2 * Copyright (c) 2009 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:  Wraps the QContact for the legacy handling in the phone engine
       
    15 */
       
    16 
       
    17 #include <QDebug>
       
    18 #include <e32base.h>
       
    19 #include <utf.h>
       
    20 #include <qcontact.h>
       
    21 #include "cphcntcontactidimpl2.h"
       
    22 // ---------------------------------------------------------------------------
       
    23 // c'tor
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 
       
    27 CPhCntContactIdImpl2::~CPhCntContactIdImpl2() 
       
    28     {
       
    29     
       
    30     }
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // copy c'tor
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CPhCntContactIdImpl2::CPhCntContactIdImpl2(const QContact aContact)
       
    37 :iContact(aContact), iValid(true)
       
    38     {
       
    39     
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // Static constructor
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CPhCntContactIdImpl2* CPhCntContactIdImpl2::NewL(const QContact aContact)
       
    47     {
       
    48     CPhCntContactIdImpl2* self = new( ELeave ) CPhCntContactIdImpl2(aContact);
       
    49     return self;
       
    50     }
       
    51  
       
    52 // ---------------------------------------------------------------------------
       
    53 // CloneL
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CPhCntContactId* CPhCntContactIdImpl2::CloneL() const
       
    57     {
       
    58     return CPhCntContactIdImpl2::NewL(Contact());
       
    59     }
       
    60      
       
    61 // ---------------------------------------------------------------------------
       
    62 // Invalidate
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 
       
    66 void CPhCntContactIdImpl2::Invalidate()
       
    67     {
       
    68     iValid = false;
       
    69     }
       
    70      
       
    71 // ---------------------------------------------------------------------------
       
    72 // IsValid
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 TBool CPhCntContactIdImpl2::IsValid() const
       
    76     {
       
    77     return iValid;
       
    78     }
       
    79      
       
    80 // ---------------------------------------------------------------------------
       
    81 // ContactId
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 TContactItemId CPhCntContactIdImpl2::ContactId() const
       
    85     {
       
    86     if (IsValid())
       
    87         {
       
    88         return iContact.localId();
       
    89         }
       
    90     else
       
    91         {
       
    92         return KErrNotFound;
       
    93         }
       
    94     }
       
    95      
       
    96 // ---------------------------------------------------------------------------
       
    97 // PackLC
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 HBufC8* CPhCntContactIdImpl2::PackLC() const
       
   101 
       
   102 
       
   103     {
       
   104     HBufC8* valueToReturn = NULL;
       
   105     
       
   106     if (IsValid())
       
   107         {
       
   108         QString str; 
       
   109         str.setNum(iContact.localId());
       
   110         TPtrC16 value(str.utf16());
       
   111         valueToReturn =  CnvUtfConverter::ConvertFromUnicodeToUtf8L(value);
       
   112         CleanupStack::PushL(valueToReturn);
       
   113         }
       
   114         
       
   115     return valueToReturn;
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // Contact
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 const QContact CPhCntContactIdImpl2::Contact() const
       
   123     {
       
   124     return iContact;
       
   125     }
       
   126 
       
   127 
       
   128     
       
   129