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 * Phonebook Data Save service helper. Implements "Save to phonebook"
16 * menu functionality for external applications.
21 #ifndef __CPbkDataSaveAppUi_H__
22 #define __CPbkDataSaveAppUi_H__
27 // FORWARD DECLARATIONS
29 class CPbkContactEngine;
30 class CPbkContactItem;
32 class MPbkDataSaveCallback;
40 * Phonebook Data Save service helper. Implements "Save to phonebook"
41 * menu functionality for external applications.
43 * Note that in most cases current status pane layout is replaced with the
44 * Phonebook one. Restoring the original pane is left to be
45 * the responsibility of the client.
47 class CPbkDataSaveAppUi : public CBase
51 * Creates an instance of this class.
53 * @param aEngine Phonebook engine instance.
55 IMPORT_C static CPbkDataSaveAppUi* NewL(CPbkContactEngine& aEngine);
58 * Destructor. Destroys this object and cancels any open dialogs.
63 * Adds Phonebook data save menu items to a menu pane. Called from
64 * applications DynInitMenuPaneL. This call is not mandatory:
65 * if the application provides its own menus it may call
66 * HandleCommandL directly from menu's command handler.
68 * @param aMenuPane Menu pane where to add the menu items.
69 * @param aCommandId Id of command which to replace with Phonebook
70 * data save menu items. This command id is stored
71 * into this object as the base id after which are
72 * app-specific command Ids reserved for Phonebook
73 * data save API usage.
74 * @see DynInitMenuPaneL
77 IMPORT_C void AddMenuItemsL(CEikMenuPane* aMenuPane, TInt aCommandId);
80 * Updates Phonebook data save menu items. Called from applications
81 * DynInitMenuPaneL. This call is not mandatory: if the application
82 * provides its own menus it may call HandleCommandL directly
83 * from menu's command handler.
85 * @param aResourceId Resource id of the menu pane as passed to
86 * MEikMenuObserver::DynInitMenuPaneL. If this
87 * resource id does not match with Phonebook data
88 * save submenu this function does nothing.
89 * @param aMenuPane Menu pane as passed to
90 * MEikMenuObserver::DynInitMenuPaneL.
93 IMPORT_C void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
96 * Handles a menu command inserted by AddMenuItemsL.
98 * @param aCommandId Command to execute. iBaseCommandId+1 is
99 * Create New Entry and iBaseCommandId+2 is
100 * Add to Existing Entry. Use directly
101 * EPbkCmdDataSaveCreateNew or EPbkCmdDataSaveAddToExisting
102 * if AddMenuItemsL is not called.
103 * @param aFieldTypes Field types where the user can select from.
104 * If there is only one field type selection
105 * list is not displayed.
106 * @param aText Text to put to the selected field.
107 * @param aCallback Calls back to this object if there are
108 * problems in adding the field. See
109 * MPbkDataSaveCallback class for details.
110 * @return ETrue if the command was executed and the data added,
111 * EFalse if the operation was canceled in any stage.
113 * @see MPbkDataSaveCallback
114 * @see TPbkDataSaveCommandId in PbkDataSaveAppUi.hrh
116 IMPORT_C TBool HandleCommandL
118 CArrayPtr<CPbkFieldInfo>& aFieldTypes,
120 MPbkDataSaveCallback* aCallback=NULL);
123 * Handles a menu command inserted by AddMenuItemsL.
125 * @param aCommandId Command to execute. iBaseCommandId+1 is
126 * Create New Entry and iBaseCommandId+2 is
127 * Add to Existing Entry. Use directly
128 * EPbkCmdDataSaveCreateNew or EPbkCmdDataSaveAddToExisting
129 * if AddMenuItemsL is not called.
130 * @param aFieldTypes Field types where the user can select from.
131 * If there is only one field type selection
132 * list is not displayed.
133 * @param aDate Date to put to the selected field.
134 * @param aCallback Calls back to this object if there are
135 * problems in adding the field. See
136 * MPbkDataSaveCallback class for details.
137 * @return ETrue if the command was executed and the data added,
138 * EFalse if the operation was canceled in any stage.
140 * @see MPbkDataSaveCallback
141 * @see TPbkDataSaveCommandId in PbkDataSaveAppUi.hrh
143 IMPORT_C TBool HandleCommandL
145 CArrayPtr<CPbkFieldInfo>& aFieldTypes,
147 MPbkDataSaveCallback* aCallback=NULL);
150 * Hides the "Exit" command from contact editor's options menu.
151 * Call this function after creating this object.
153 IMPORT_C void HideEditorExitCommand();
155 private: // Implementation
157 class CTextFieldData;
158 class CDateFieldData;
160 class CCreateNewCommand;
161 class CAddToExistingCommand;
162 CPbkDataSaveAppUi(CPbkContactEngine& aEngine);
164 TBool DoHandleCommandL
166 CArrayPtr<CPbkFieldInfo>& aFieldTypes,
167 MFieldData& aFieldData,
168 MPbkDataSaveCallback* aCallback);
171 /// Ref: Phonebook engine instance
172 CPbkContactEngine* iEngine;
173 /// Own: FFS space checker
174 CPbkFFSCheck* iFFSCheck;
175 /// Own: base command id
177 /// Own: the currently executing command
178 CCommandBase* iExecutingCommand;
181 /// Own: handle to UI extension factory
182 CPbkExtGlobals* iExtGlobals;
187 * Callback interface for CPbkDataSaveAppUi::HandleCommandL.
189 class MPbkDataSaveCallback
193 * Called by CPbkDataSaveAppUi::HandleCommandL if there is no field
194 * available where to save the data and no new field could be added.
195 * Default implementation does nothing.
197 * @param aContact Contact where the field cannot be added.
199 IMPORT_C virtual void PbkDataSaveNoFieldL(CPbkContactItem& aContact);
202 * Called from CPbkDataSaveAppUi::HandleCommandL if the aText is too
203 * long to fit into field.
204 * Default implementation clips aText from the end. If an empty
205 * string is returned the field addition is canceled.
207 * @param aText The original text.
208 * @param aFieldInfo The type of field where the text should be
210 * @return A substring of aText so that the substring's length is
211 * <=aFieldInfo.MaxLength().
213 IMPORT_C virtual TPtrC PbkDataSaveClipTextL
214 (const TDesC& aText, CPbkFieldInfo& aFieldInfo);
217 #endif // __CPbkDataSaveAppUi_H__