mobilemessaging/postcard/postcardinc/PostcardContact.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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:  
       
    15 *     Postcard application's interface to contacts (Phonebook2 and
       
    16 *     virtual phonebook)
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __POSTCARDCONTACT_H__
       
    23 #define __POSTCARDCONTACT_H__
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <AiwCommon.h>
       
    27 #include <MVPbkFieldType.h>
       
    28 
       
    29 #include "Postcard.hrh"
       
    30 #include "PostcardPanic.h"
       
    31 
       
    32 class CAiwServiceHandler;
       
    33 class CAiwGenericParamList;
       
    34 class CVPbkContactStoreUriArray;
       
    35 class CContactMatcher;
       
    36 class MVPbkStoreContact;
       
    37 
       
    38 /**
       
    39  * Postcard contact
       
    40  */
       
    41 class CPostcardContact : public CBase, 
       
    42                          public MAiwNotifyCallback, 
       
    43                          public MAknInputBlockCancelHandler
       
    44     {
       
    45     public:  // constants
       
    46 
       
    47     enum TLocation // address location
       
    48         {
       
    49         ELocationPreferred,
       
    50         ELocationHome,
       
    51         ELocationWork
       
    52         };
       
    53     static const TInt KNumLocations = ELocationWork + 1;
       
    54 
       
    55     enum TAddressField // address field
       
    56         {
       
    57         EAddressFieldStreet,
       
    58         EAddressFieldExtendedAddress,
       
    59         EAddressFieldPostalCode,
       
    60         EAddressFieldLocality,
       
    61         EAddressFieldRegion,
       
    62         EAddressFieldCountry
       
    63         };
       
    64     static const TInt KNumAddressFields = EAddressFieldCountry + 1;
       
    65 
       
    66     public:  // Constructors and destructor
       
    67 
       
    68         /**
       
    69         * Two-phased constructor.
       
    70         * @return pointer to created CPostcardContact
       
    71         */
       
    72         static CPostcardContact* NewL( RFs& aFs );
       
    73 
       
    74         /**
       
    75          * Destructor.
       
    76          */
       
    77         ~CPostcardContact();
       
    78 
       
    79     public:
       
    80 
       
    81         /**
       
    82         * Checks if the contact refers to a valid contact (contact was found)
       
    83         */
       
    84         inline TBool IsValid() const;
       
    85 
       
    86         /**
       
    87         * Checks if the contact includes any of Extended Info, Street, City,
       
    88         * Zip, Region or Country fields with location aLocation.
       
    89         * @param aLocation Location Preferred/Home/Work to check
       
    90         * @return ETrue if the contact has address information for the location
       
    91         */
       
    92 	    TBool HasLocationL(TLocation aLocation) const;
       
    93 
       
    94         /**
       
    95         * Creates a contact string of aContactItem's address field with
       
    96         * location aAddressLocation 
       
    97         * (in practise "<street><extended><zip><city><region><country>")
       
    98         * @param aBuffer Contains the contact string on return
       
    99         * @param aAddressLocation Location Preferred/Home/Work to get
       
   100         */
       
   101         void GetContactStringL(TDes& aBuffer, TLocation aAddressLocation) const;
       
   102 
       
   103         /**
       
   104         * Get address field from a contact
       
   105         * @param aLocation Location Preferred/Home/Work to get
       
   106         * @param aAddressField Address field to get
       
   107         * @return Address field text or "empty" descriptor
       
   108         */
       
   109         HBufC* GetAddressFieldLC(TLocation aLocation,
       
   110             TAddressField aAddressField) const;
       
   111 
       
   112         /**
       
   113         * Get name from a contact. Uses Phonebook2 name formatter.
       
   114         * @return Contact name text or "empty" descriptor
       
   115         */
       
   116         HBufC* GetNameLC() const;
       
   117 
       
   118         /**
       
   119         * Fetch contact from using Phonebook2 UI services
       
   120         */
       
   121         void FetchContactL();
       
   122 
       
   123         /**
       
   124         * Fetch contact from a contact link in a file
       
   125         * @param aFile File containing a contact link packed into a descriptor
       
   126         */
       
   127         void FetchContactL(RFile& aFile);
       
   128 
       
   129         /**
       
   130         * Convert from TPostcardControls to TAddressField
       
   131         * @param aControlId Control ID to convert
       
   132         * @return Address field
       
   133         */
       
   134         static inline TAddressField ControlIdToAddrField(TInt aControlId);
       
   135 
       
   136     public: // Functions from base classes
       
   137 
       
   138         /**
       
   139          * from MAiwNotifyCallback
       
   140          * Handles notifications caused by an asynchronous AIW commands
       
   141          */
       
   142         TInt HandleNotifyL(TInt aCmdId, TInt aEventId,
       
   143             CAiwGenericParamList& aEventParamList,
       
   144             const CAiwGenericParamList& aInParamList);
       
   145 
       
   146         /**
       
   147         * from MAknInputBlockCancelHandler
       
   148         * Handles cancellation of AIW call to phonebook.
       
   149         */
       
   150         void AknInputBlockCancel();
       
   151 
       
   152     private:	// new functions
       
   153 
       
   154         /**
       
   155          * Handles asynchronous AIW command completed event notification
       
   156          * @param aEventParamList Event parameters
       
   157          */
       
   158         void HandleAiwEventCompletedL(CAiwGenericParamList& aEventParamList);
       
   159 
       
   160         /**
       
   161         * Convert location to Virtual Phonebook field type parameter
       
   162         * @param aLocation Location to convert
       
   163         * @return Field type parameter
       
   164         */
       
   165         static inline TVPbkFieldTypeParameter LocToFieldTypeParam(
       
   166             TLocation aLocation);
       
   167 
       
   168         /**
       
   169         * Convert address field to Virtual Phonebook subfield type
       
   170         * @param aAddressField Address field to convert
       
   171         * @return Subfield type
       
   172         */
       
   173         static inline TVPbkSubFieldType AddrFieldToSubFieldType(
       
   174             TAddressField aAddressField);
       
   175 
       
   176         /**
       
   177         * Initializes AIW single item contact fetch parameter list
       
   178         * @param aParamList Parameter list to initialize with parameters
       
   179         */
       
   180         void InitAiwContactFetchParamL(
       
   181             CAiwGenericParamList& aParamList) const;
       
   182 
       
   183         /**
       
   184         * Read a field from a contact
       
   185         * @param aFieldType Virtual Phonebook field type
       
   186         * @param aSubFieldType Virtual Phonebook subfield type
       
   187         * @param aFieldTypeParameter Virtual Phonebook field type parameter
       
   188         * @return Contact field text or "empty" descriptor
       
   189         */
       
   190         HBufC* GetContactFieldLC( TVPbkFieldTypeName aFieldType,
       
   191             TVPbkSubFieldType aSubFieldType,
       
   192             TVPbkFieldTypeParameter aFieldTypeParameter) const;
       
   193 
       
   194     private:  // constructors
       
   195 	    CPostcardContact( RFs& aFs );
       
   196 
       
   197         /**
       
   198         * EPOC constructor
       
   199         */
       
   200         void ConstructL();
       
   201 
       
   202     private:    // data
       
   203         // Table to convert from TLocation to virtual phonebook field
       
   204         // type parameter
       
   205         static const TVPbkFieldTypeParameter
       
   206             iLocToFieldTypeParam[KNumLocations];
       
   207 
       
   208         // Table to convert from TAddressField to virtual phonebook subfield
       
   209         // type
       
   210         static const TVPbkSubFieldType
       
   211             iAddrFieldToSubFieldType[KNumAddressFields];
       
   212 
       
   213         // Table to convert from TPostcardControls to TAddressField
       
   214         static const TAddressField
       
   215             iControlIdToAddrField[KNumAddressFields];
       
   216 
       
   217         CAiwServiceHandler*         iAiwServiceHandler; // for contact fetch
       
   218         CVPbkContactStoreUriArray*  iUriArray;          // opened contact stores
       
   219         CContactMatcher*            iContactMatcher;    // contact matcher
       
   220         MVPbkStoreContact*          iStoreContact;      // contact selected by user
       
   221         CActiveSchedulerWait        iActSchedWait;      // to hide the asynchronity
       
   222         TBool                       iShutdown;
       
   223         
       
   224         RFs&                        iFs;
       
   225      };
       
   226 
       
   227 #include "PostcardContact.inl"
       
   228 
       
   229 #endif // __POSTCARDCONTACT_H__
       
   230 
       
   231 // End of File