web_plat/feeds_engine_api/inc/FeedsServerClient.h
changeset 0 dd21522fd290
child 37 cb62a4f66ebe
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2005 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 the License "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:  The client side connection to the FeedsSever.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef FEEDS_SERVER_CLIENT_H
       
    20 #define FEEDS_SERVER_CLIENT_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 
       
    25 #include <FeedsServerFeed.h>
       
    26 #include <FeedsServerFolderItem.h>
       
    27 #include <FeedsServerRequestHandler.h>
       
    28 #include <FeedsServerSettings.h>
       
    29 
       
    30 //API changes
       
    31 #include "FeedsInterface.h"
       
    32 #include "FeedsMap.h"
       
    33 #include "Transaction.h"
       
    34 
       
    35 // CONSTANTS
       
    36 
       
    37 // MACROS
       
    38 
       
    39 // DATA TYPES
       
    40 
       
    41 // FUNCTION PROTOTYPES
       
    42 
       
    43 // FORWARD DECLARATIONS
       
    44 
       
    45 
       
    46 // CLASS DECLARATION
       
    47    class CClientRequestHandler;
       
    48 /**
       
    49 *  The RFeedsServer observer interface.
       
    50 *
       
    51 *  \b Library: FeedsEngine.lib
       
    52 *
       
    53 *  @since 3.1
       
    54 */
       
    55 class MFeedsServerObserver
       
    56     {
       
    57     public:  // New Methods
       
    58         /**
       
    59         * Reports the progress of the UpdateAllFeedsL request.  
       
    60         *
       
    61         * @since 3.1
       
    62         * @param aTotalCount The total count of feeds to be updated.
       
    63         * @param aRemaining The current number of feeds remaining to be updated.
       
    64         * @return void.
       
    65         */
       
    66         // TODO: remove this.
       
    67         virtual void UpdateAllProgress(TInt aTotalCount, TInt aRemaining) = 0;
       
    68 
       
    69         /**
       
    70         * Notifies the observer that the feeds server settings have changed.  
       
    71         * ToDo: This is only called when the value was changed by a differnt client.
       
    72         * Call FetchSettingsL() to set up this notification
       
    73         *
       
    74         * @since 3.1
       
    75         * @param aStatus The result code of the request.  KErrNotFound is ok.
       
    76         * @return void.
       
    77         */
       
    78         virtual void SettingsChanged( TInt aStatus ) = 0;
       
    79     };
       
    80 
       
    81 
       
    82 /**
       
    83 *  The client side interface to the FeedsServer.
       
    84 *
       
    85 *  \b Library: FeedsEngine.lib
       
    86 *
       
    87 *  @since 3.1
       
    88 */
       
    89 class RFeedsServer:  public RSessionBase, public MFeedsApiObserver
       
    90     {
       
    91     public:
       
    92         /**
       
    93         * C++ default constructor.
       
    94         */
       
    95         IMPORT_C RFeedsServer(MFeedsServerObserver& aObserver, TInt aFolderListId = 0);
       
    96 
       
    97 
       
    98     public: // From RSessionBase
       
    99         /**
       
   100         * Connects to the server
       
   101         *
       
   102         * @since 3.1
       
   103         * @return Error/success code
       
   104         */
       
   105         IMPORT_C TInt Connect();
       
   106 
       
   107         /**
       
   108         * Closes the connection to the server
       
   109         *
       
   110         * @since 3.1
       
   111         * @return Error/success code
       
   112         */
       
   113         IMPORT_C void Close();
       
   114 
       
   115         /**
       
   116         * Returns the implementation's version.
       
   117         *
       
   118         * @since 3.1
       
   119         * @return The version.
       
   120         */
       
   121         IMPORT_C TVersion Version() const;
       
   122 
       
   123 
       
   124     public: // From MFeedsApiObserver
       
   125 
       
   126         /**
       
   127         * Requests the observer to send a command to the server.
       
   128         *
       
   129         * @since 3.1
       
   130         * @param aFunction The function number identifying the request. 
       
   131         * @param aArgs A set of up to 4 arguments and their types to be passed to the server.
       
   132         * @param aStatus The request status object used to contain the completion status of the request.
       
   133         * @return void.
       
   134         */
       
   135     	virtual void SendAsyncCommand(TInt /*aFunction*/, const TIpcArgs& /*aArgs*/, 
       
   136                TRequestStatus& /*aStatus*/) const {} ; 
       
   137 
       
   138         /**
       
   139         * This function is called by Ctransaction class whenever
       
   140         * request is completed
       
   141         * 
       
   142         * @param aTrans Pointer to current transaction class
       
   143         * @param aEvent event related to this call.
       
   144         */
       
   145         virtual void RequestCompleted(CTransaction* aTrans, TInt aStatus);
       
   146 
       
   147        	/**
       
   148         * Request to create a network connection.
       
   149         *
       
   150         * @param aConnectionPtr A pointer to the new connection. If NULL, the 
       
   151         *  proxy filter will automatically create a network connection.
       
   152         * @param aSockSvrHandle A handle to the socket server.
       
   153         * @param aNewConn A flag if a new connection was created. If the 
       
   154         *                 connection is not new, proxy filter optimization will not 
       
   155         *                 read the proxy again from CommsBd.
       
   156         * @param aBearerType The bearer type of the new connection
       
   157         * @return void
       
   158         */
       
   159         virtual void NetworkConnectionNeededL(TInt* aConnectionPtr, TInt& aSockSvrHandle,
       
   160     	    TBool& aNewConn, TApBearerType& aBearerType);
       
   161 
       
   162         /**
       
   163         * Request the FeedsServer to cancel all activities that can be cancelled.
       
   164         */            
       
   165         virtual void CancelAllCommandsL() {} ;
       
   166 
       
   167     public:
       
   168         /**
       
   169         * Notifies the observer that the request is completed.
       
   170         *
       
   171         * @since 3.1
       
   172         * @param aRequestHandler The request handler.
       
   173         * @param aStatus The result code of the request.
       
   174         * @return void.
       
   175         */
       
   176         void RequestHandlerCompletedL(CTransaction& aTrans,
       
   177                 TInt aStatus);
       
   178 
       
   179         void SetServerFeed(RFeed& aFeedsServerFeed);
       
   180 
       
   181         void SetServerFolderItem(RFolderItem& aFeedsServerFolderItem);
       
   182 
       
   183     public:  // New methods
       
   184         /**
       
   185         * Once fetched, it returns the settings.  This method panics the
       
   186         * client if it is called before the settings is available.
       
   187         *
       
   188         * @since 3.1
       
   189         * @return The settings.
       
   190         */
       
   191         IMPORT_C const TFeedsServerSettings Settings() const;
       
   192 
       
   193         /**
       
   194         * Requests the server to change its settings to match the provided values. 
       
   195         * Some care is needed by the client to prevent settings loss if SettingsChanged
       
   196         * was called after it called SettingsL.
       
   197         *
       
   198         * @since 3.1
       
   199         * @return void.
       
   200         */
       
   201         IMPORT_C void UpdateSettingsL( const TFeedsServerSettings& aNewSettings );
       
   202 
       
   203         /**
       
   204         * Fetch the feeds server settings synchronously.
       
   205         *
       
   206         * @since 3.1
       
   207         * @return The settings.
       
   208         */
       
   209         IMPORT_C const TFeedsServerSettings FetchServerSettingsSyncL() const;
       
   210 
       
   211         /**
       
   212         * Fetch the feeds server settings asynchronously.
       
   213         *
       
   214         * @since 3.1
       
   215         * @return void.
       
   216         */
       
   217         IMPORT_C void FetchServerSettingsL();
       
   218 
       
   219         /**
       
   220         * Sets up a notifier to execute when the settings of given folder list changes.
       
   221         *
       
   222         * @since 3.2
       
   223         * @return void
       
   224         */
       
   225         IMPORT_C void WatchSettingsL();
       
   226 
       
   227         /**
       
   228         * Request the FeedsServer to cancel all activities that can be cancelled.
       
   229         *
       
   230         * @since 3.1
       
   231         * @return void.
       
   232         */
       
   233         IMPORT_C void CancelAllL();
       
   234 
       
   235         /**
       
   236         * Disconnect connection provided by client for manual update. 
       
   237         *
       
   238         * @since 3.1
       
   239         * @return void.
       
   240         */
       
   241         IMPORT_C void DisconnectManualUpdateConnectionL();
       
   242 
       
   243         /**
       
   244         * Print tables of database.
       
   245         *
       
   246         * @since 3.2
       
   247         * @if _DEBUG is turned off, server do thign for this request 
       
   248         * @return void
       
   249         */
       
   250         IMPORT_C void DebugPrintTablesL();
       
   251 
       
   252     public:  // Friends
       
   253         friend class RFeed;
       
   254         friend class RFolderItem;
       
   255 
       
   256 
       
   257     private:  // Data
       
   258         MFeedsServerObserver&           iObserver;
       
   259         TFeedsServerSettings            iSettings;
       
   260         TFeedsServerSettings            iPendingSettings;
       
   261         TInt                            iFolderListId;
       
   262         RPointerArray<CClientRequestHandler>   iActiveRequests;
       
   263     };
       
   264 
       
   265 
       
   266 #endif  // FEEDS_SERVER_CLIENT_H
       
   267 // End of File