menucontentsrv/inc/menuclientoperation.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Definition of Menu operation subsession
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __MENUCLIENTOPERATION_H__
       
    20 #define __MENUCLIENTOPERATION_H__
       
    21 
       
    22 #include "mcsmenuoperation.h"
       
    23 #include <e32base.h>
       
    24 
       
    25 class RMenu;
       
    26 class RMenuBuf;
       
    27 class CMenuItem;
       
    28 
       
    29 /**
       
    30  *  Menu operation subsession object.
       
    31  *  This is a "disposable" object (used only once):
       
    32  *  CreateXxx() -> Start() -> Close().
       
    33  *  CreateXxx() methods package and send operation data to server side; Start()
       
    34  *  invokes the operation asynchronously.
       
    35  *  @lib mcsmenu.lib
       
    36  *  @since S60 v5.0
       
    37  */
       
    38 NONSHARABLE_CLASS( RMenuOperation ): public RSubSessionBase
       
    39     {
       
    40 
       
    41 public:
       
    42 
       
    43     /**
       
    44     * Close the operation. Safe to call if not open.
       
    45     */
       
    46     void Close();
       
    47 
       
    48     /**
       
    49     * Create a Remove operation.
       
    50     * @param aMenu Menu.
       
    51     * @param aId Remove this item.
       
    52     * @return Error code.
       
    53     */
       
    54     TInt CreateRemove( RMenu& aMenu, TInt aId );
       
    55 
       
    56     /**
       
    57     * Create a MoveToFolder operation.
       
    58     * @param aMenu Menu.
       
    59     * @param aId ID-s of item to be to be moved have been sent in this
       
    60     * buffer.
       
    61     * @param aMoveBefore. Move the items before this item (if found).
       
    62     * If aMoveBefore is not found, the aItem is moved to the end.
       
    63     * @return Error code.
       
    64     */
       
    65     TInt CreateMoveToFolder(
       
    66         RMenu& aMenu,
       
    67         const RMenuBuf& aItems,
       
    68         TInt aFolder,
       
    69         TInt aMoveBefore );
       
    70 
       
    71     /**
       
    72     * Create Reorder operation.
       
    73     * @param aMenu Menu.
       
    74     * @param aId ID of item to be to be reordered.
       
    75     * @param aMoveBefore. Move the item before this item (if found).
       
    76     * If aMoveBefore is not found, the aItem is moved to the end.
       
    77     * @return Error code.
       
    78     */
       
    79     TInt CreateReorder( RMenu& aMenu, TInt aId, TInt aMoveBefore );
       
    80 
       
    81     /**
       
    82     * Create Add operation.
       
    83     * @param aMenu Menu.
       
    84     * @param aType Type. Maximum length is KMenuMaxTypeLen.
       
    85     * @param aChanges Operation data (attributes, etc.) have been sent in this
       
    86     * buffer.
       
    87     * @param aId ID of item to be created is returned here (ID is reserved,
       
    88     * but not yet valid).
       
    89     * @return Error code.
       
    90     */
       
    91     TInt CreateAdd( RMenu& aMenu, const TDesC& aType, const RMenuBuf& aChanges, TInt& aId );
       
    92 
       
    93     /**
       
    94     * Create Update operation.
       
    95     * @param aMenu Menu.
       
    96     * @param aId Id.
       
    97     * @param aChanges Operation data (attributes, etc.) have been sent in this
       
    98     * buffer.
       
    99     * @return Error code.
       
   100     */
       
   101     TInt CreateUpdate( RMenu& aMenu, TInt aId, const RMenuBuf& aChanges );
       
   102 
       
   103     /**
       
   104     * Cancel operation.
       
   105     * NOT safe to call on an unopened operation.
       
   106     */
       
   107     void Cancel();
       
   108 
       
   109     /**
       
   110     * Start operation.
       
   111     * @param aStatus Completes with error code when operation is done.
       
   112     */
       
   113     void Start( TRequestStatus &aStatus );
       
   114 
       
   115     };
       
   116 
       
   117 /**
       
   118  *  RMenuOperation wrapped as CMenuOperation.
       
   119  *  @lib mcsmenu.lib
       
   120  *  @since S60 v5.0
       
   121  */
       
   122 NONSHARABLE_CLASS( CMenuClientOperation ): public CMenuOperation
       
   123     {
       
   124 
       
   125 public:
       
   126 
       
   127     /**
       
   128     * Destructor.
       
   129     */
       
   130     virtual ~CMenuClientOperation();
       
   131 
       
   132     /**
       
   133     * Constructor.
       
   134     * @param aMenu Menu.
       
   135     * @param Priority Active Object priority.
       
   136     * @param aStatus Completes with error code when operation is done.
       
   137     */
       
   138     CMenuClientOperation(
       
   139         RMenu &aMenu,
       
   140         TInt aPriority,
       
   141         TRequestStatus &aObserverStatus );
       
   142 
       
   143     /**
       
   144     * Construct and start Remove operation.
       
   145     * @param aMenu Menu.
       
   146     * @param aId Remove this item.
       
   147     */
       
   148     void RemoveL( TInt aId );
       
   149 
       
   150     /**
       
   151     * Construct and start a MoveToFolder operation.
       
   152     * @param aMenu Menu.
       
   153     * @param aId ID-s of item to be to be moved have been sent in this
       
   154     * buffer.
       
   155     * @param aMoveBefore. Move the items before this item (if found).
       
   156     * If aMoveBefore is not found, the aItem is moved to the end.
       
   157     */
       
   158     void MoveToFolderL( const RMenuBuf& aItems, TInt aFolder, TInt aMoveBefore );
       
   159 
       
   160     /**
       
   161     * Construct and start Reorder operation.
       
   162     * @param aMenu Menu.
       
   163     * @param aId ID of item to be to be reordered.
       
   164     * @param aMoveBefore. Move the item before this item (if found).
       
   165     * If aMoveBefore is not found, the aItem is moved to the end.
       
   166     */
       
   167     void ReorderL( TInt aId, TInt aMoveBefore );
       
   168 
       
   169     /**
       
   170     * Construct and start Add operation.
       
   171     * @param aMenu Menu.
       
   172     * @param aType Type. Maximum length is KMenuMaxTypeLen.
       
   173     * @param aChanges Operation data (attributes, etc.) have been sent in this
       
   174     * buffer.
       
   175     * @return ID of item to be created (ID is reserved, but not yet valid).
       
   176     */
       
   177     TInt AddL( const TDesC& aType, const RMenuBuf& aChanges );
       
   178 
       
   179     /**
       
   180     * Construct and start Update operation.
       
   181     * @param aMenu Menu.
       
   182     * @param aId Id.
       
   183     * @param aChanges Operation data (attributes, etc.) have been sent in this
       
   184     * buffer.
       
   185     */
       
   186     void UpdateL( TInt aId, const RMenuBuf& aChanges );
       
   187 
       
   188 private:
       
   189 
       
   190     /**
       
   191     * Start operation.
       
   192     */
       
   193     void Start();
       
   194 
       
   195 // from base class CActive
       
   196 
       
   197     /**
       
   198     * Operation completed.
       
   199     */
       
   200     void RunL();
       
   201 
       
   202     /**
       
   203     * Cancel operation.
       
   204     */
       
   205     void DoCancel();
       
   206 
       
   207     /**
       
   208     * Never called, RunL() is not leaving.
       
   209     */
       
   210     TInt RunError( TInt /*aError*/ ) { return KErrNone; }
       
   211 
       
   212 private:    // data
       
   213 
       
   214     RMenuOperation iOperation; ///< The operation. Own.
       
   215 
       
   216     };
       
   217 
       
   218 #endif // __MENUCLIENTOPERATION_H__