2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Generic Phonebook address selection dialog. Used for selecting recipient
16 * address from a contact for Call, Send SMS, email and MMS.
21 #ifndef __CPbkAddressSelect_H__
22 #define __CPbkAddressSelect_H__
26 #include <coedef.h> // TKeyResponse
27 #include <w32std.h> // TKeyEvent, TEventCode
30 // FORWARD DECLARATIONS
31 class CPbkContactItem;
32 class TPbkContactItemField;
33 class CPbkSelectFieldDlg;
40 * This class is the abstrack base class for Phonebook address selection
41 * dialogs. Address selection dialogs are used for selecting recipient
42 * address from a contact for Call, Send SMS, email and MMS. Select one
43 * of the derived classes for a particular concrete dialog implementation.
45 class CPbkAddressSelect : public CBase
49 * Parameters for ExecuteLD(TBaseParams&).
50 * @see ExecuteLD(TBaseParams&)
56 * Returns the contact supplied to constructor.
57 * @return Contact item.
59 IMPORT_C const CPbkContactItem& ContactItem();
62 * Sets the focused field of the contact item. If focused field
63 * is a non-empty address field it is returned directly by
64 * ExecuteLD. The default value is NULL.
65 * @param aFocusedField The focused field to set
67 IMPORT_C void SetFocusedField(const TPbkContactItemField* aFocusedField);
70 * Set to ETrue to use default address of the contact directly.
71 * Focused field overrides default address if both are
72 * available. The default value is EFalse.
73 * @param aUseDefaultDirectly Defines whether the default address
74 * should be used directly
76 IMPORT_C void SetUseDefaultDirectly(TBool aUseDefaultDirectly);
79 * Returns the selected field or NULL if no selection was made.
80 * @return Selected contact item field.
82 IMPORT_C const TPbkContactItemField* SelectedField() const;
85 * Returns the focused field or NULL if there was no field
87 * @return Focused contact item field.
89 IMPORT_C const TPbkContactItemField* FocusedField() const;
91 protected: // Derived class interface
95 * @param aContact Contact from which to select an address.
96 * @param aDefaultField The field to use as the default. NULL if
97 * no default is set for aContact.
100 (const CPbkContactItem& aContact,
101 const TPbkContactItemField* aDefaultField);
104 /// Ref: the contact where to select an address
105 const CPbkContactItem& iContact;
106 /// Ref: the default field of the contact
107 const TPbkContactItemField* iDefaultField;
108 /// Ref: the focused field of the contact
109 const TPbkContactItemField* iFocusedField;
110 /// Own: is the default address to be used directly
111 TBool iUseDefaultDirectly;
112 /// Own: the selected field of the contact
113 const TPbkContactItemField* iSelectedField;
120 friend class CPbkAddressSelect;
124 * Destructor. Cancels address selection query if active.
126 IMPORT_C ~CPbkAddressSelect();
128 protected: // Base class interface
132 IMPORT_C CPbkAddressSelect();
135 * Runs an address selection query (if necessary).
137 * @param aParams see TBaseParams.
138 * @return ETrue if query was accepted, EFalse if canceled.
140 IMPORT_C TBool ExecuteLD(TBaseParams& aParams);
143 * Returns aItem passed to ExecuteLD.
144 * @return Contact item.
146 IMPORT_C const CPbkContactItem& ContactItem() const;
149 * Exit any address selection query. Makes ExecuteLD return which means
150 * this object is destroyed after this function returns!
151 * @param aAccept ETrue means the query selection is accepted and
152 * EFalse that query is canceled.
154 IMPORT_C void AttemptExitL(TBool aAccept);
156 private: // Base class interface. Private because these functions are
157 // only to be called from this classes implementation.
159 * Returns ETrue if aField is an applicable address field.
160 * @param aField Contact item field.
161 * @return ETrue if the contact item field is an applicable address field.
163 virtual TBool AddressField(const TPbkContactItemField& aField) const = 0;
166 * Called if there are no applicable address fields in aItem passed
169 virtual void NoAddressesL() = 0;
172 * Returns title to use for the address selection list query.
173 * @return Title used for the address selection list query.
175 virtual const TDesC& QueryTitleL() = 0;
178 * Returns a softkey resource id to use for the address
179 * selection list query.
180 * @return Softkey resource if that is used for the address
181 * selection list query.
183 virtual TInt QuerySoftkeysResource() const = 0;
186 * Override to handle key events in the list query.
187 * The default implementation is empty.
188 * @param aKeyEvent The key event.
189 * @param aType The key event type.
191 IMPORT_C virtual TKeyResponse PbkControlKeyEventL
192 (const TKeyEvent& aKeyEvent,TEventCode aType);
194 // Spare virtual functions
195 IMPORT_C virtual void Reserved_1();
196 IMPORT_C virtual void Reserved_2();
198 private: // data members
199 /// Ref: aItem passed to ExecuteLD
200 const CPbkContactItem* iContactItem;
201 /// Field selection dialog for this class
202 class CSelectFieldDlg;
203 friend class CSelectFieldDlg;
204 /// Own: field selection dialog
205 CPbkSelectFieldDlg* iFieldDlg;
206 /// Own: field array for iFieldDlg
207 CPbkFieldArray* iFields;
208 /// Ref: set to ETrue when exeuction enters destructor
209 TBool* iDestroyedPtr;
215 #endif // __CPbkAddressSelect_H__