phonebookui/Phonebook2/ServerApplication/inc/CPbk2ContactImppDataAssigner.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Phonebook 2 textual contact data assigner.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2CONTACTIMPPDATAASSIGNER_H
       
    20 #define CPBK2CONTACTIMPPDATAASSIGNER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "MPbk2ContactAssigner.h"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class MPbk2ContactAssignerObserver;
       
    28 class TVPbkFieldVersitProperty;
       
    29 
       
    30 // CLASS DECLARATION
       
    31 
       
    32 /**
       
    33  * Phonebook 2 textual contact data assigner.
       
    34  */
       
    35 class CPbk2ContactImppDataAssigner : public CActive,
       
    36                                      public MPbk2ContactAssigner
       
    37     {
       
    38     public: // Construction and destruction
       
    39 
       
    40         /**
       
    41          * Creates a new instance of this class.
       
    42          *
       
    43          * @param aObserver     Observer.
       
    44          * @return  A new instance of this class.
       
    45          */
       
    46         static CPbk2ContactImppDataAssigner* NewL(
       
    47                 MPbk2ContactAssignerObserver& aObserver );
       
    48 
       
    49         /**
       
    50          * Destructor.
       
    51          */
       
    52         ~CPbk2ContactImppDataAssigner();
       
    53 
       
    54     public: // From MPbk2ContactAssigner
       
    55         void AssignDataL(
       
    56                 MVPbkStoreContact& aStoreContact,
       
    57                 MVPbkStoreContactField* aContactField,
       
    58                 const MVPbkFieldType* aFieldType,
       
    59                 const HBufC* aDataBuffer );
       
    60         void AssignAttributeL(
       
    61                 MVPbkStoreContact& aStoreContact,
       
    62                 MVPbkStoreContactField* aContactField,
       
    63                 TPbk2AttributeAssignData aAttributeAssignData );
       
    64 
       
    65     private: // From CActive
       
    66         void RunL();
       
    67         void DoCancel();
       
    68         TInt RunError(
       
    69                 TInt aError );
       
    70 
       
    71     private: // Implementation
       
    72         CPbk2ContactImppDataAssigner(
       
    73                 MPbk2ContactAssignerObserver& aObserver );
       
    74         void IssueRequest();
       
    75         void ParseDataBuffer(TPtrC* axSP, TPtrC* aFirstName, TPtrC* aLastName,
       
    76                 TPtrC* aNickname, TPtrC aDataBuffer);
       
    77         void UpdateField(const TVPbkFieldVersitProperty& aVersitProp,
       
    78                 const TDesC& aValue, MVPbkStoreContact* aStoreContact);
       
    79         inline TBool GetDataBufferPart(TPtrC* aBuffer, TPtrC* aPart);
       
    80 
       
    81     private: // Data
       
    82         /// Ref: Observer
       
    83         MPbk2ContactAssignerObserver& iObserver;
       
    84         /// Own: Index of the added field
       
    85         TInt iIndex;
       
    86     };
       
    87 
       
    88 TBool CPbk2ContactImppDataAssigner::GetDataBufferPart(
       
    89         TPtrC* aBuffer, TPtrC* aPart)
       
    90     {
       
    91     const TChar KSeparator = '\n';
       
    92 
       
    93     TInt pos = aBuffer->Locate(KSeparator);
       
    94     if (pos == KErrNotFound)
       
    95         {
       
    96         aPart->Set(*aBuffer);
       
    97         return EFalse;
       
    98         }
       
    99     else
       
   100         {
       
   101         aPart->Set(aBuffer->Left(pos));
       
   102         if (pos == aBuffer->Length()-1)
       
   103             {
       
   104             return EFalse;
       
   105             }
       
   106         }
       
   107     aBuffer->Set(aBuffer->Mid(++pos));
       
   108     return ETrue;
       
   109     }
       
   110 
       
   111 #endif // CPBK2CONTACTIMPPDATAASSIGNER_H
       
   112 
       
   113 // End of File