epoc32/include/app/cpbkdatasaveappui.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002 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 *    Phonebook Data Save service helper. Implements "Save to phonebook" 
    16 *    menu functionality for external applications.
    17 *
    18 */
    19 
    20 
    21 #ifndef __CPbkDataSaveAppUi_H__
    22 #define __CPbkDataSaveAppUi_H__
    23 
    24 //  INCLUDES
    25 #include <e32base.h>
    26 
    27 // FORWARD DECLARATIONS
    28 class CEikMenuPane;
    29 class CPbkContactEngine;
    30 class CPbkContactItem;
    31 class CPbkFieldInfo;
    32 class MPbkDataSaveCallback;
    33 class CPbkFFSCheck;
    34 class CPbkExtGlobals;
    35 
    36 
    37 // CLASS DECLARATION
    38 
    39 /**
    40  * Phonebook Data Save service helper. Implements "Save to phonebook" 
    41  * menu functionality for external applications.
    42  *
    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.
    46  */
    47 class CPbkDataSaveAppUi : public CBase
    48     {
    49     public:  // Interface
    50         /**
    51          * Creates an instance of this class.
    52          *
    53          * @param aEngine   Phonebook engine instance.
    54          */
    55         IMPORT_C static CPbkDataSaveAppUi* NewL(CPbkContactEngine& aEngine);
    56 
    57         /**
    58          * Destructor. Destroys this object and cancels any open dialogs.
    59          */
    60         ~CPbkDataSaveAppUi();
    61 
    62         /**
    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.
    67          *
    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
    75          * @see HandleCommandL
    76          */
    77         IMPORT_C void AddMenuItemsL(CEikMenuPane* aMenuPane, TInt aCommandId);
    78 
    79         /**
    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.
    84          *
    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.
    91          * @see AddMenuItemsL
    92          */
    93         IMPORT_C void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
    94 
    95         /**
    96          * Handles a menu command inserted by AddMenuItemsL.
    97          *
    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.
   112          * @see AddMenuItemsL
   113          * @see MPbkDataSaveCallback
   114          * @see TPbkDataSaveCommandId in PbkDataSaveAppUi.hrh
   115          */
   116         IMPORT_C TBool HandleCommandL
   117             (TInt aCommandId, 
   118             CArrayPtr<CPbkFieldInfo>& aFieldTypes,
   119             const TDesC& aText,
   120             MPbkDataSaveCallback* aCallback=NULL);
   121 
   122         /**
   123          * Handles a menu command inserted by AddMenuItemsL.
   124          *
   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.
   139          * @see AddMenuItemsL
   140          * @see MPbkDataSaveCallback
   141          * @see TPbkDataSaveCommandId in PbkDataSaveAppUi.hrh
   142          */
   143         IMPORT_C TBool HandleCommandL
   144             (TInt aCommandId, 
   145             CArrayPtr<CPbkFieldInfo>& aFieldTypes,
   146             const TTime& aDate,
   147             MPbkDataSaveCallback* aCallback=NULL);
   148 
   149         /**
   150          * Hides the "Exit" command from contact editor's options menu.
   151          * Call this function after creating this object.
   152          */
   153         IMPORT_C void HideEditorExitCommand();
   154         
   155     private:  // Implementation
   156         class MFieldData;
   157         class CTextFieldData;
   158         class CDateFieldData;
   159         class CCommandBase;
   160         class CCreateNewCommand;
   161         class CAddToExistingCommand;
   162         CPbkDataSaveAppUi(CPbkContactEngine& aEngine);
   163         void ConstructL();
   164         TBool DoHandleCommandL
   165             (TInt aCommandId, 
   166             CArrayPtr<CPbkFieldInfo>& aFieldTypes,
   167             MFieldData& aFieldData,
   168             MPbkDataSaveCallback* aCallback);
   169 
   170     private:  // Data
   171         /// Ref: Phonebook engine instance
   172         CPbkContactEngine* iEngine;
   173         /// Own: FFS space checker
   174         CPbkFFSCheck* iFFSCheck;
   175         /// Own: base command id
   176         TInt iBaseCommandId;
   177         /// Own: the currently executing command
   178         CCommandBase* iExecutingCommand;
   179         /// Own: flags
   180         TUint iFlags;
   181         /// Own: handle to UI extension factory
   182         CPbkExtGlobals* iExtGlobals;
   183     };
   184 
   185 
   186 /**
   187  * Callback interface for CPbkDataSaveAppUi::HandleCommandL.
   188  */
   189 class MPbkDataSaveCallback
   190     {
   191     public:  // Interface
   192         /**
   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.
   196          *
   197          * @param aContact  Contact where the field cannot be added.
   198          */
   199         IMPORT_C virtual void PbkDataSaveNoFieldL(CPbkContactItem& aContact);
   200 
   201         /**
   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.
   206          *
   207          * @param aText         The original text.
   208          * @param aFieldInfo    The type of field where the text should be 
   209          *                      inserted.
   210          * @return  A substring of aText so that the substring's length is 
   211          *          <=aFieldInfo.MaxLength().
   212          */
   213         IMPORT_C virtual TPtrC PbkDataSaveClipTextL
   214             (const TDesC& aText, CPbkFieldInfo& aFieldInfo);
   215     };
   216 
   217 #endif // __CPbkDataSaveAppUi_H__
   218 
   219 // End of File