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.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: 
williamr@2
    15
*    Phonebook Data Save service helper. Implements "Save to phonebook" 
williamr@2
    16
*    menu functionality for external applications.
williamr@2
    17
*
williamr@2
    18
*/
williamr@2
    19
williamr@2
    20
williamr@2
    21
#ifndef __CPbkDataSaveAppUi_H__
williamr@2
    22
#define __CPbkDataSaveAppUi_H__
williamr@2
    23
williamr@2
    24
//  INCLUDES
williamr@2
    25
#include <e32base.h>
williamr@2
    26
williamr@2
    27
// FORWARD DECLARATIONS
williamr@2
    28
class CEikMenuPane;
williamr@2
    29
class CPbkContactEngine;
williamr@2
    30
class CPbkContactItem;
williamr@2
    31
class CPbkFieldInfo;
williamr@2
    32
class MPbkDataSaveCallback;
williamr@2
    33
class CPbkFFSCheck;
williamr@2
    34
class CPbkExtGlobals;
williamr@2
    35
williamr@2
    36
williamr@2
    37
// CLASS DECLARATION
williamr@2
    38
williamr@2
    39
/**
williamr@2
    40
 * Phonebook Data Save service helper. Implements "Save to phonebook" 
williamr@2
    41
 * menu functionality for external applications.
williamr@2
    42
 *
williamr@2
    43
 * Note that in most cases current status pane layout is replaced with the
williamr@2
    44
 * Phonebook one. Restoring the original pane is left to be
williamr@2
    45
 * the responsibility of the client.
williamr@2
    46
 */
williamr@2
    47
class CPbkDataSaveAppUi : public CBase
williamr@2
    48
    {
williamr@2
    49
    public:  // Interface
williamr@2
    50
        /**
williamr@2
    51
         * Creates an instance of this class.
williamr@2
    52
         *
williamr@2
    53
         * @param aEngine   Phonebook engine instance.
williamr@2
    54
         */
williamr@2
    55
        IMPORT_C static CPbkDataSaveAppUi* NewL(CPbkContactEngine& aEngine);
williamr@2
    56
williamr@2
    57
        /**
williamr@2
    58
         * Destructor. Destroys this object and cancels any open dialogs.
williamr@2
    59
         */
williamr@2
    60
        ~CPbkDataSaveAppUi();
williamr@2
    61
williamr@2
    62
        /**
williamr@2
    63
         * Adds Phonebook data save menu items to a menu pane. Called from 
williamr@2
    64
         * applications DynInitMenuPaneL. This call is not mandatory: 
williamr@2
    65
         * if the application provides its own menus it may call
williamr@2
    66
         * HandleCommandL directly from menu's command handler.
williamr@2
    67
         *
williamr@2
    68
         * @param aMenuPane     Menu pane where to add the menu items.
williamr@2
    69
         * @param aCommandId    Id of command which to replace with Phonebook
williamr@2
    70
         *                      data save menu items. This command id is stored
williamr@2
    71
         *                      into this object as the base id after which are
williamr@2
    72
         *                      app-specific command Ids reserved for Phonebook
williamr@2
    73
         *                      data save API usage.
williamr@2
    74
         * @see DynInitMenuPaneL
williamr@2
    75
         * @see HandleCommandL
williamr@2
    76
         */
williamr@2
    77
        IMPORT_C void AddMenuItemsL(CEikMenuPane* aMenuPane, TInt aCommandId);
williamr@2
    78
williamr@2
    79
        /**
williamr@2
    80
         * Updates Phonebook data save menu items. Called from applications 
williamr@2
    81
         * DynInitMenuPaneL. This call is not mandatory: if the application 
williamr@2
    82
         * provides its own menus it may call HandleCommandL directly 
williamr@2
    83
         * from menu's command handler.
williamr@2
    84
         *
williamr@2
    85
         * @param aResourceId   Resource id of the menu pane as passed to 
williamr@2
    86
         *                      MEikMenuObserver::DynInitMenuPaneL. If this 
williamr@2
    87
         *                      resource id does not match with Phonebook data
williamr@2
    88
         *                      save submenu this function does nothing.
williamr@2
    89
         * @param aMenuPane     Menu pane as passed to 
williamr@2
    90
         *                      MEikMenuObserver::DynInitMenuPaneL.
williamr@2
    91
         * @see AddMenuItemsL
williamr@2
    92
         */
williamr@2
    93
        IMPORT_C void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
williamr@2
    94
williamr@2
    95
        /**
williamr@2
    96
         * Handles a menu command inserted by AddMenuItemsL.
williamr@2
    97
         *
williamr@2
    98
         * @param aCommandId        Command to execute. iBaseCommandId+1 is
williamr@2
    99
         *                          Create New Entry and iBaseCommandId+2 is
williamr@2
   100
         *                          Add to Existing Entry. Use directly 
williamr@2
   101
         *                          EPbkCmdDataSaveCreateNew or EPbkCmdDataSaveAddToExisting
williamr@2
   102
         *                          if AddMenuItemsL is not called.
williamr@2
   103
         * @param aFieldTypes       Field types where the user can select from.
williamr@2
   104
         *                          If there is only one field type selection
williamr@2
   105
         *                          list is not displayed.
williamr@2
   106
         * @param aText             Text to put to the selected field.
williamr@2
   107
         * @param aCallback         Calls back to this object if there are 
williamr@2
   108
         *                          problems in adding the field. See 
williamr@2
   109
         *                          MPbkDataSaveCallback class for details.
williamr@2
   110
         * @return  ETrue if the command was executed and the data added, 
williamr@2
   111
         *          EFalse if the operation was canceled in any stage.
williamr@2
   112
         * @see AddMenuItemsL
williamr@2
   113
         * @see MPbkDataSaveCallback
williamr@2
   114
         * @see TPbkDataSaveCommandId in PbkDataSaveAppUi.hrh
williamr@2
   115
         */
williamr@2
   116
        IMPORT_C TBool HandleCommandL
williamr@2
   117
            (TInt aCommandId, 
williamr@2
   118
            CArrayPtr<CPbkFieldInfo>& aFieldTypes,
williamr@2
   119
            const TDesC& aText,
williamr@2
   120
            MPbkDataSaveCallback* aCallback=NULL);
williamr@2
   121
williamr@2
   122
        /**
williamr@2
   123
         * Handles a menu command inserted by AddMenuItemsL.
williamr@2
   124
         *
williamr@2
   125
         * @param aCommandId        Command to execute. iBaseCommandId+1 is
williamr@2
   126
         *                          Create New Entry and iBaseCommandId+2 is
williamr@2
   127
         *                          Add to Existing Entry. Use directly 
williamr@2
   128
         *                          EPbkCmdDataSaveCreateNew or EPbkCmdDataSaveAddToExisting
williamr@2
   129
         *                          if AddMenuItemsL is not called.
williamr@2
   130
         * @param aFieldTypes       Field types where the user can select from.
williamr@2
   131
         *                          If there is only one field type selection
williamr@2
   132
         *                          list is not displayed.
williamr@2
   133
         * @param aDate             Date to put to the selected field.
williamr@2
   134
         * @param aCallback         Calls back to this object if there are 
williamr@2
   135
         *                          problems in adding the field. See 
williamr@2
   136
         *                          MPbkDataSaveCallback class for details.
williamr@2
   137
         * @return  ETrue if the command was executed and the data added, 
williamr@2
   138
         *          EFalse if the operation was canceled in any stage.
williamr@2
   139
         * @see AddMenuItemsL
williamr@2
   140
         * @see MPbkDataSaveCallback
williamr@2
   141
         * @see TPbkDataSaveCommandId in PbkDataSaveAppUi.hrh
williamr@2
   142
         */
williamr@2
   143
        IMPORT_C TBool HandleCommandL
williamr@2
   144
            (TInt aCommandId, 
williamr@2
   145
            CArrayPtr<CPbkFieldInfo>& aFieldTypes,
williamr@2
   146
            const TTime& aDate,
williamr@2
   147
            MPbkDataSaveCallback* aCallback=NULL);
williamr@2
   148
williamr@2
   149
        /**
williamr@2
   150
         * Hides the "Exit" command from contact editor's options menu.
williamr@2
   151
         * Call this function after creating this object.
williamr@2
   152
         */
williamr@2
   153
        IMPORT_C void HideEditorExitCommand();
williamr@2
   154
        
williamr@2
   155
    private:  // Implementation
williamr@2
   156
        class MFieldData;
williamr@2
   157
        class CTextFieldData;
williamr@2
   158
        class CDateFieldData;
williamr@2
   159
        class CCommandBase;
williamr@2
   160
        class CCreateNewCommand;
williamr@2
   161
        class CAddToExistingCommand;
williamr@2
   162
        CPbkDataSaveAppUi(CPbkContactEngine& aEngine);
williamr@2
   163
        void ConstructL();
williamr@2
   164
        TBool DoHandleCommandL
williamr@2
   165
            (TInt aCommandId, 
williamr@2
   166
            CArrayPtr<CPbkFieldInfo>& aFieldTypes,
williamr@2
   167
            MFieldData& aFieldData,
williamr@2
   168
            MPbkDataSaveCallback* aCallback);
williamr@2
   169
williamr@2
   170
    private:  // Data
williamr@2
   171
        /// Ref: Phonebook engine instance
williamr@2
   172
        CPbkContactEngine* iEngine;
williamr@2
   173
        /// Own: FFS space checker
williamr@2
   174
        CPbkFFSCheck* iFFSCheck;
williamr@2
   175
        /// Own: base command id
williamr@2
   176
        TInt iBaseCommandId;
williamr@2
   177
        /// Own: the currently executing command
williamr@2
   178
        CCommandBase* iExecutingCommand;
williamr@2
   179
        /// Own: flags
williamr@2
   180
        TUint iFlags;
williamr@2
   181
        /// Own: handle to UI extension factory
williamr@2
   182
        CPbkExtGlobals* iExtGlobals;
williamr@2
   183
    };
williamr@2
   184
williamr@2
   185
williamr@2
   186
/**
williamr@2
   187
 * Callback interface for CPbkDataSaveAppUi::HandleCommandL.
williamr@2
   188
 */
williamr@2
   189
class MPbkDataSaveCallback
williamr@2
   190
    {
williamr@2
   191
    public:  // Interface
williamr@2
   192
        /**
williamr@2
   193
         * Called by CPbkDataSaveAppUi::HandleCommandL if there is no field
williamr@2
   194
         * available where to save the data and no new field could be added.
williamr@2
   195
         * Default implementation does nothing.
williamr@2
   196
         *
williamr@2
   197
         * @param aContact  Contact where the field cannot be added.
williamr@2
   198
         */
williamr@2
   199
        IMPORT_C virtual void PbkDataSaveNoFieldL(CPbkContactItem& aContact);
williamr@2
   200
williamr@2
   201
        /**
williamr@2
   202
         * Called from CPbkDataSaveAppUi::HandleCommandL if the aText is too 
williamr@2
   203
         * long to fit into field.
williamr@2
   204
         * Default implementation clips aText from the end. If an empty 
williamr@2
   205
         * string is returned the field addition is canceled.
williamr@2
   206
         *
williamr@2
   207
         * @param aText         The original text.
williamr@2
   208
         * @param aFieldInfo    The type of field where the text should be 
williamr@2
   209
         *                      inserted.
williamr@2
   210
         * @return  A substring of aText so that the substring's length is 
williamr@2
   211
         *          <=aFieldInfo.MaxLength().
williamr@2
   212
         */
williamr@2
   213
        IMPORT_C virtual TPtrC PbkDataSaveClipTextL
williamr@2
   214
            (const TDesC& aText, CPbkFieldInfo& aFieldInfo);
williamr@2
   215
    };
williamr@2
   216
williamr@2
   217
#endif // __CPbkDataSaveAppUi_H__
williamr@2
   218
williamr@2
   219
// End of File