contacts_plat/phonebook_2_xsp_view_activation_api/inc/xSPViewServices.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2006 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 *       xSP View client-side API.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __XSPVIEWSERVICES_H__
       
    21 #define __XSPVIEWSERVICES_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32cmn.h>
       
    25 #include <e32svr.h>
       
    26 
       
    27 #include <MVPbkContactLink.h>
       
    28 
       
    29 
       
    30 // CLASS DECLARATION
       
    31 /**
       
    32  * The xSP View API, which is used to bring a certain
       
    33  * view in front and get tab-view information.
       
    34  *
       
    35  * There is an issue with KErrServerTerminated error code
       
    36  * sometimes returned by this API functions. This situation
       
    37  * may arise when server object is terminated with the
       
    38  * Phonebook process but clients outside the Phonebook
       
    39  * are not informed and their handles remain open. A way to
       
    40  * deal with this KErrServerTerminated error is to close
       
    41  * the handle first by calling Close() and then reopen it
       
    42  * by calling Open() or Activate() methods which do not
       
    43  * require explicit Open() calls.
       
    44  * 
       
    45  * The following panic codes are possible in case the API is abused:
       
    46  * 
       
    47  * Panic category xSPViewActivator. These panics represent programming errors
       
    48  * which are detected by the view activator service that activates a tab view.
       
    49  * Possible panic codes for this category are: EBadDescriptorLength = 0
       
    50  * (descriptor length was illegal), EBadDescriptor = 1 (descriptor type was
       
    51  * not correct; could not write to client side descriptor buffer).
       
    52  */
       
    53 class RxSPViewServices : public RSessionBase
       
    54     {
       
    55 
       
    56     public: // Implementation
       
    57 
       
    58         /**
       
    59          * Opens a session to the server. Launches Phonebook in the background.
       
    60          * @return Error code
       
    61          */
       
    62         IMPORT_C TInt Open();
       
    63 
       
    64         /**
       
    65          * Closes the session.
       
    66          */
       
    67         IMPORT_C void Close();
       
    68 
       
    69         /**
       
    70          *  Triggers xSP extension view activation. Starts the Phonebook
       
    71          *      if it was not running already. Designed to be used by
       
    72          *      the xSP extension view activator. If the session was not
       
    73          *		open, this method will open one and close it afterwards.
       
    74          *		If the session was open, this method will not close it
       
    75          *		afterwards. 
       
    76          *  @param aEComID xSP extension ECom implementation ID
       
    77          *  @param aOriginalViewID view original / old ID
       
    78          *  @return KErrNone if successful, error code otherwise
       
    79          */
       
    80         IMPORT_C TInt Activate( TUint32 aEComID, 
       
    81                                 TInt aOriginalViewID);
       
    82 
       
    83         /**
       
    84          *  Triggers xSP extension view activation. Starts the Phonebook
       
    85          *      if it was not running already. Designed to be used by
       
    86          *      the xSP extension view activator. If the session was not
       
    87          *		open, this method will open one and close it afterwards.
       
    88          *		If the session was open, this method will not close it
       
    89          *		afterwards.
       
    90          *  @param aEComID xSP extension ECom implementation ID
       
    91          *  @param aOriginalViewID view original / old ID
       
    92          *  @param aContactLink which contact item to show
       
    93          *  @param aFocusedField which field gets the focus
       
    94          */
       
    95         IMPORT_C void ActivateL( TUint32 aEComID, 
       
    96                                  TInt aOriginalViewID, 
       
    97                                  MVPbkContactLink* aContactLink, 
       
    98                                  TInt aFocusedField );
       
    99 
       
   100         /**
       
   101          *  Triggers xSP extension view activation. Starts the Phonebook
       
   102          *      if it was not running already. Designed to be used by
       
   103          *      the xSP extension view activator. If the session was not
       
   104          *		open, this method will open one and close it afterwards.
       
   105          *		If the session was open, this method will not close it
       
   106          *		afterwards.
       
   107          *  @param aEComID xSP extension ECom implementation ID
       
   108          *  @param aOriginalViewID view original / old ID
       
   109          *  @param aParamBuf specifies which contact to show (see CPbk2ViewState.h or
       
   110          *                   CPbkViewState.h for details)
       
   111          *  @return KErrNone if successful, error code otherwise
       
   112          */
       
   113         IMPORT_C TInt Activate( TUint32 aEComID, 
       
   114                                 TInt aOriginalViewID, 
       
   115                                 TPtr8& aParamBuf);
       
   116 
       
   117         /**
       
   118          *  Triggers view activation asynchronously.
       
   119          *
       
   120          *  @param aEComID xSP extension ECom implementation ID
       
   121          *  @param aOriginalViewID view original / old ID
       
   122          *  @param aParamBuf specifies which contact to show (see CPbk2ViewState.h or
       
   123          *                   CPbkViewState.h for details)
       
   124          *  @param aStatus contains the status of the request on completion
       
   125          */
       
   126         IMPORT_C void Activate( TUint32 aEComID, 
       
   127                                 TInt aOriginalViewID, 
       
   128                                 TPtr8& aParamBuf, 
       
   129                                 TRequestStatus& aStatus );
       
   130          
       
   131         /**
       
   132          *  Cancel activate
       
   133          *  @return KErrNone if successful, error code otherwise
       
   134          */                       
       
   135       	IMPORT_C TInt CancelActivate() const;
       
   136       	
       
   137         /**
       
   138          *  Constructor
       
   139          */                       
       
   140       	IMPORT_C RxSPViewServices();
       
   141       	
       
   142       	/**
       
   143          *	Opens a session to the server. Async version.
       
   144          *	Launches Phonebook in the background.
       
   145          *	@param aAsyncMessageSlots The number of message slots available to session.
       
   146          *	@param aType type of session to create.
       
   147          *	@param aStatus request status 
       
   148          *	@return Error code
       
   149          */
       
   150         IMPORT_C TInt Open( TInt aAsyncMessageSlots,
       
   151         					TIpcSessionType aType,
       
   152         					TRequestStatus& aStatus );
       
   153                  
       
   154         /**
       
   155          *  Get view count
       
   156          *	@param aCount placeholder for view count
       
   157          *  @return KErrNone if successful, error code otherwise
       
   158          */                       
       
   159 		IMPORT_C TInt GetViewCount( TInt& aCount ) const;
       
   160 		
       
   161 		/**
       
   162          *  Get view count. Async version.
       
   163          *	@param aCount placeholder for view count
       
   164          *	@param aStatus request status 
       
   165          *  @return KErrNone if successful, error code otherwise
       
   166          */                       
       
   167 		IMPORT_C TInt GetViewCount( TInt& aCount,
       
   168 									TRequestStatus& aStatus );
       
   169 		
       
   170 		/**
       
   171          *  Cancel async get view count
       
   172          *  @return KErrNone if successful, error code otherwise
       
   173          */ 									
       
   174 		IMPORT_C TInt CancelGetViewCount() const;
       
   175 		
       
   176 		/**
       
   177          *  Get packed view data buffer length
       
   178          *	@param aIndex view index
       
   179          *	@param aLength placeholder for buffer length
       
   180          *  @return KErrNone if successful, error code otherwise
       
   181          */
       
   182 		IMPORT_C TInt GetPackedViewDataBufferLength( TInt aIndex, 
       
   183 														TInt& aLength ) const;
       
   184 		
       
   185 		/**
       
   186          *  Get packed view data buffer length. Async version.
       
   187          *	@param aIndex view index
       
   188          *	@param aLength placeholder for buffer length
       
   189          *	@param aStatus request status 
       
   190          *  @return KErrNone if successful, error code otherwise
       
   191          */
       
   192 		IMPORT_C TInt GetPackedViewDataBufferLength( TInt aIndex,
       
   193 														TInt& aLength,
       
   194 														TRequestStatus& aStatus );
       
   195 		
       
   196 		
       
   197 		/**
       
   198          *  Cancel async get packed view data buffer length
       
   199          *  @return KErrNone if successful, error code otherwise
       
   200          */ 									
       
   201 		IMPORT_C TInt CancelGetPackedViewDataBufferLength() const;
       
   202 														
       
   203 		/**
       
   204          *  Get packed view data
       
   205          *	@param aIndex view index
       
   206          *	@param aPackedViewData reference to allocated buffer.
       
   207          *		The buffer will contain packed data on successful return      
       
   208          *  @return KErrNone if successful, error code otherwise
       
   209          */
       
   210 		IMPORT_C TInt GetPackedViewData( TInt aIndex, TDes8& aPackedViewData ) const;
       
   211 		
       
   212 		/**
       
   213          *  Get packed view data. Async version.
       
   214          *	@param aIndex view index
       
   215          *	@param aPackedViewData reference to allocated buffer.
       
   216          *		The buffer will contain packed data on successful completion
       
   217          *	@param aStatus request status     
       
   218          *  @return KErrNone if successful, error code otherwise
       
   219          */
       
   220 		IMPORT_C TInt GetPackedViewData( TInt aIndex,
       
   221 											TDes8& aPackedViewData,
       
   222 											TRequestStatus& aStatus );
       
   223 		
       
   224 		/**
       
   225          *  Cancel get packet view data
       
   226          *  @return KErrNone if successful, error code otherwise
       
   227          */ 									
       
   228 		IMPORT_C TInt CancelGetPackedViewData() const;
       
   229 
       
   230     private:    // Private methods
       
   231 
       
   232         /**
       
   233          * Returns the client side API version.
       
   234          */
       
   235         TVersion Version() const;
       
   236 
       
   237         /**
       
   238          * Starts the Phonebook if it is not already running.
       
   239          */
       
   240         void StartPhonebookL();
       
   241         
       
   242     private: // data
       
   243     
       
   244     	/// Own: pointer to view count
       
   245     	TPtr8 iViewCount;
       
   246     	/// Own: pointer to packed view data buffer length
       
   247     	TPtr8 iPackedViewDataBufferLength;
       
   248     };
       
   249 
       
   250 
       
   251 #endif // __XSPVIEWSERVICES_H__
       
   252 
       
   253 // End of file.