web_plat/feeds_engine_api/inc/FeedsInterface.h
changeset 0 dd21522fd290
child 26 cb62a4f66ebe
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2008 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 FEED_INTERFACE_H
       
    20 #define FEED_INTERFACE_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <ApEngineconsts.h>
       
    26 //#include "Transaction.h"
       
    27 #include "FeedsEntity.h"
       
    28 #include "FeedAttributes.h"
       
    29 #include "FolderAttributes.h"
       
    30 // CONSTANTS
       
    31 
       
    32 // MACROS
       
    33 
       
    34 // DATA TYPES
       
    35 
       
    36 // FUNCTION PROTOTYPES
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CTransaction;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 class MFeedsApiObserver
       
    44     {
       
    45 public:
       
    46     /**
       
    47      * This function is called by Ctransaction class whenever
       
    48      * request is completed
       
    49      * 
       
    50      * @param aTrans Pointer to current transaction class
       
    51      * @param aEver event related to this call.
       
    52      */
       
    53      virtual void RequestCompleted(CTransaction* aTrans, TInt aEvent) = 0;
       
    54 
       
    55     /**
       
    56      * Request to create a network connection.
       
    57      *
       
    58      * @param aConnectionPtr A pointer to the new connection. If NULL, the 
       
    59      *                       proxy filter will automatically create a network connection.
       
    60      * @param aSockSvrHandle A handle to the socket server.
       
    61      * @param aNewConn A flag if a new connection was created. If the 
       
    62      *                 connection is not new, proxy filter optimization will not 
       
    63      *                 read the proxy again from CommsBd.
       
    64      * @param aBearerType The bearer type of the new connection
       
    65      * @return void
       
    66      */
       
    67      virtual void
       
    68     		NetworkConnectionNeededL(TInt* aConnectionPtr,
       
    69     				TInt& aSockSvrHandle, TBool& aNewConn,
       
    70     				TApBearerType& aBearerType) = 0 ;
       
    71 
       
    72     };
       
    73 
       
    74 /**
       
    75  *  The CTransaction observer interface.
       
    76  *
       
    77  */
       
    78 class MTransactionObserver
       
    79     {
       
    80 public:
       
    81     // New Methods
       
    82     /**
       
    83      * Requests the observer to send a command to the server.
       
    84      *
       
    85      * @param aFunction The function number identifying the request. 
       
    86      * @param aArgs A set of up to 4 arguments and their types to be passed to the server.
       
    87      * @param aStatus The request status object used to contain the completion status of the request.
       
    88      * @return void.
       
    89      */
       
    90     virtual void SendAsyncCommand(TInt aFunction, const TIpcArgs& aArgs,
       
    91     		TRequestStatus& aStatus) const = 0;
       
    92 
       
    93     /**
       
    94      * Notifies the observer that the request is completed.
       
    95      *
       
    96      * @param aRequestHandler The request handler.
       
    97      * @param aStatus The result code of the request.
       
    98      * @return void.
       
    99      */
       
   100     virtual void RequestHandlerCompleted(CTransaction& aRequestHandler,
       
   101     		TInt aStatus) = 0;
       
   102 
       
   103     /**
       
   104      * Cancels all the commands
       
   105      */
       
   106     virtual void CancelAllCommandsL() = 0;
       
   107 
       
   108     /**
       
   109      * Request to create a network connection.
       
   110      *
       
   111      * @since 3.1
       
   112      * @param aConnectionPtr A pointer to the new connection. If NULL, the 
       
   113      *                       proxy filter will automatically create a network connection.
       
   114      * @param aSockSvrHandle A handle to the socket server.
       
   115      * @param aNewConn A flag if a new connection was created. If the 
       
   116      *                 connection is not new, proxy filter optimization will not 
       
   117      *                 read the proxy again from CommsBd.
       
   118      * @param aBearerType The bearer type of the new connection
       
   119      * @return void
       
   120      */
       
   121     virtual void
       
   122             NetworkConnectionNeededL(TInt* aConnectionPtr,
       
   123                 TInt& aSockSvrHandle, TBool& aNewConn,
       
   124                 TApBearerType& aBearerType) = 0;
       
   125     };
       
   126 
       
   127 struct TFeedsServerSetting
       
   128     {
       
   129     TBool iAutoUpdate;
       
   130     TInt  iAutoUpdateFreq;
       
   131     TUint iAutoUpdateAP;
       
   132     TBool iAutoUpdateWhileRoaming;
       
   133     };
       
   134 /**
       
   135  *  The client side interface to the FeedsServer.
       
   136  *
       
   137  *  \b Library: FeedsEngine.lib
       
   138  *
       
   139  */
       
   140 
       
   141 class RFeedsInterface : public RSessionBase, public MTransactionObserver
       
   142     {
       
   143 public:
       
   144     /**
       
   145      * C++ default constructor.
       
   146      */
       
   147     IMPORT_C RFeedsInterface(MFeedsApiObserver& aObserver,
       
   148             TInt aFolderListId = 0);
       
   149 
       
   150 public:
       
   151     // From RSessionBase
       
   152     /**
       
   153      * Connects to the server
       
   154      *
       
   155      * @return Error/success code
       
   156      */
       
   157     IMPORT_C TInt Connect();
       
   158 
       
   159     /**
       
   160      * Closes the connection to the server
       
   161      *
       
   162      * @return Error/success code
       
   163      */
       
   164     IMPORT_C void Close();
       
   165 
       
   166     /**
       
   167      * Returns the implementation's version.
       
   168      *
       
   169      * @return The version.
       
   170      */
       
   171     IMPORT_C TVersion Version() const;
       
   172 
       
   173 public: // From MRequestHandlerObserver
       
   174     /**
       
   175      * Requests the observer to send a command to the server.
       
   176      *
       
   177      * @param aFunction The function number identifying the request. 
       
   178      * @param aArgs A set of up to 4 arguments and their types to be passed to the server.
       
   179      * @param aStatus The request status object used to contain the completion status of the request.
       
   180      * @return void.
       
   181      */
       
   182     virtual void SendAsyncCommand(TInt aFunction, const TIpcArgs& aArgs,
       
   183     		TRequestStatus& aStatus) const;
       
   184 
       
   185     /**
       
   186      * Notifies the observer that the request is completed.
       
   187      *
       
   188      * @param aRequestHandler The request handler.
       
   189      * @param aStatus The result code of the request.
       
   190      * @return void.
       
   191      */
       
   192     virtual void RequestHandlerCompleted(CTransaction& aTransaction,
       
   193     		TInt aStatus);
       
   194 
       
   195     /**
       
   196      * Request the FeedsServer to cancel all activities that can be cancelled.
       
   197      */
       
   198     virtual void CancelAllCommandsL();
       
   199 
       
   200 public:
       
   201     /**
       
   202      * Fetches Root folder (Asynchronous) Observer will be called when request completes
       
   203      *
       
   204      * @return TInt (KErrNone if successful).
       
   205      */
       
   206 
       
   207     IMPORT_C TInt GetRootFolderL();
       
   208     /**
       
   209      * Add new Feed/Folder into feedserver (Sync)
       
   210      *
       
   211      * @param aType (EFolder/EFeed)
       
   212      * @param aArgs Map cotaining various values
       
   213      * @param aParent Under which folder this object should be added
       
   214      * 
       
   215      * @return void.
       
   216      */
       
   217 
       
   218     IMPORT_C void AddL(TFeedsEntityType aType, const CFeedsMap& aArgs,const CFeedsEntity& aParent);
       
   219     /**
       
   220      * Deletes passed feeds/folders from list
       
   221      *
       
   222      * @param aFeedsEntities array of feedsentities to be deleted
       
   223      * @return void.
       
   224      */
       
   225 
       
   226     IMPORT_C void DeleteL(const RPointerArray<const CFeedsEntity> aFeedsEntities);
       
   227 
       
   228     /**
       
   229     * Print tables of database.
       
   230     *
       
   231     * @return void
       
   232     */
       
   233     IMPORT_C void RFeedsInterface::DebugPrintTablesL();
       
   234 
       
   235     /**
       
   236     * Disconnect connection provided by client for manual update.
       
   237     *
       
   238     * @return void
       
   239     */
       
   240     IMPORT_C void RFeedsInterface::DisconnectManualUpdateConnectionL();
       
   241 
       
   242      /**
       
   243      * Fetches feed (async)
       
   244      *
       
   245      * @param aEntity Feed to be fetched.
       
   246      * @param aForceUpdate If ETrue the feed is always updated before returning it.
       
   247      * @param aNoCache If ETrue the feed isn't placed in database after updating.
       
   248      * @return void.
       
   249      */
       
   250 
       
   251     IMPORT_C TInt FetchL(const CFeedsEntity& aEntity, TBool aForceUpdate, TBool aNoCache);
       
   252     /**
       
   253      * Fetches feed (async)
       
   254      *
       
   255      * @param aEntity Feed to be fetched.
       
   256      * @param aForceUpdate If ETrue the feed is always updated before returning it.
       
   257      * @param aNoCache If ETrue the feed isn't placed in database after updating.
       
   258      * @return TInt.
       
   259      */
       
   260 
       
   261     IMPORT_C TInt FetchL(const TDesC& aUrl, TBool aForceUpdate, TBool aNoCache);
       
   262      
       
   263     /**
       
   264      * Update Given list of folders(or All if only RootFolder is provided)
       
   265      *
       
   266      * @param aFeedsArray array of feeds to be updated
       
   267      * @return void
       
   268      */
       
   269 
       
   270     IMPORT_C TInt UpdateL(const RPointerArray<const CFeedsEntity>& aFeedsArray);
       
   271 
       
   272     //	TInt Find(TFeedsEntityType aType
       
   273 
       
   274     /**
       
   275      * Fetches settings from server.
       
   276      *
       
   277      * @param aFeedsSettings This Struct will contain settings if request is successful
       
   278      * @return void 
       
   279      */
       
   280 
       
   281     IMPORT_C TInt GetSettingsL(TFeedsServerSetting& aFeedsSetting, TBool aAsync = ETrue); 
       
   282 
       
   283      /**
       
   284      * Sets new setting.
       
   285      *
       
   286      * @param aFeedsSettings new settings.
       
   287      * @return void
       
   288      */
       
   289 
       
   290     IMPORT_C void SetSettingsL(const TFeedsServerSetting& aFeedsSetting);
       
   291 
       
   292      /**
       
   293      * Sets up a notifier to execute when the settings change.
       
   294      *
       
   295      * @return void.
       
   296      */
       
   297 
       
   298      IMPORT_C void RFeedsInterface::WatchSettingsL();
       
   299 
       
   300      /**
       
   301      * Export passed folder in OPML file
       
   302      *
       
   303      * @param aFeedsArray array of folder/feed to be exported
       
   304      * @param aFileName name of opml file.
       
   305      * @return void.
       
   306      */
       
   307 
       
   308     IMPORT_C void ExportFoldersL(const RPointerArray<const CFeedsEntity>& aFeedsArray,const TDesC& aFileName);
       
   309     /**
       
   310      * Imports OPML file
       
   311      *
       
   312      * @param aFileName name of OPML file to be imported
       
   313      * @return void.
       
   314      */
       
   315 
       
   316     IMPORT_C void ImportOPMLL(const TDesC& aFileName);
       
   317     /**
       
   318      * Cancels all pending requests
       
   319      *
       
   320      * @return void.
       
   321      */
       
   322 
       
   323     IMPORT_C void CancelAllL();
       
   324     /**
       
   325      * Moves list of folders/feeds to diff folder.
       
   326      *
       
   327      * @param aSourceFolders array of folder/feeds to be moved
       
   328      * @param aDestinationFolder 
       
   329      * @return void.
       
   330      */
       
   331 
       
   332     IMPORT_C void MoveToFolderL(const RPointerArray<const CFeedsEntity>& aSourceFolders,const CFeedsEntity& aDestinationFolder);
       
   333     /**
       
   334      * Changes index of folders.
       
   335      *
       
   336      * @param aFolderItems array of folderitem whose index are to be changed
       
   337      * @param aIndex new index
       
   338      * @return void
       
   339      */
       
   340 
       
   341     IMPORT_C void MoveL(const RPointerArray<const CFeedsEntity>& aFolderItems,TInt aIndex);
       
   342 
       
   343     /**
       
   344      * Sets attribute (Changes will be sent to feedserver)
       
   345      *
       
   346      * @param aFeedEntity Feed/Folder/Item whose attributes are to be changed
       
   347      * @param aNewValues map containing new attribute values.
       
   348      * @return void.
       
   349      */
       
   350 
       
   351     IMPORT_C TInt SetAttributeL(const CFeedsEntity& aFeedEntity, const CFeedsMap& aNewValues);
       
   352     /**
       
   353      * Returns Root folder
       
   354      *
       
   355      * @return pointer to CFeedsEntity (rootfolder)
       
   356      */
       
   357 
       
   358     IMPORT_C CFeedsEntity* RootFolder();
       
   359     /**
       
   360      * Fetches currently fetched feed
       
   361      *
       
   362      * @return pointer to CFeedsEntity (current feed)
       
   363      */
       
   364 
       
   365     IMPORT_C CFeedsEntity* Feed();
       
   366     /**
       
   367      * Sets notifier for folder list changes
       
   368      *
       
   369      * @return void
       
   370      */
       
   371 
       
   372     IMPORT_C void WatchFolderListL();
       
   373     /**
       
   374      * Uses aFeed attribute to change correponding feed attributes in aRootFolder tree
       
   375      *
       
   376      * @return TInt (KErrNone if successful).
       
   377      */
       
   378     TBool UpdateFeed(CFeedsEntity* aRootFolder,CFeedsEntity* aFeed);
       
   379 
       
   380     /**
       
   381      * Searches CFeedsEntity pertaining to aFeedId
       
   382      *
       
   383      * @param aFeedId (feed id to be searched)
       
   384      * @param aSearch folder/feed under which search will be performed.
       
   385      * @return TInt (KErrNone if successful).
       
   386      */
       
   387 
       
   388     IMPORT_C CFeedsEntity* SearchFeed(TInt aFeedId,CFeedsEntity* aSearch);
       
   389 
       
   390     /**
       
   391      * Request the feeds server to update the feed's item status. 
       
   392      *
       
   393      * @since 7.1
       
   394      * @param aItemIds The id's of the items to update.
       
   395      * @param aItemStatus The new item status.
       
   396      * @return void
       
   397      */
       
   398      IMPORT_C void UpdateFeedItemStatusL(const RArray<TInt>& aItemIds,
       
   399                 const RArray<TFeedItemStatus>& aItemStatus, TInt aUnreadCount);
       
   400 
       
   401     /**
       
   402      * return currently fetched settings. 
       
   403      *
       
   404      * @since 7.1
       
   405      * @return TFeedsServerSetting.
       
   406      */   
       
   407      IMPORT_C TFeedsServerSetting Settings();
       
   408 
       
   409 public:
       
   410     /**
       
   411      * Request to create a network connection.
       
   412      *
       
   413      * @param aConnectionPtr A pointer to the new connection. If NULL, the 
       
   414      *                       proxy filter will automatically create a network connection.
       
   415      * @param aSockSvrHandle A handle to the socket server.
       
   416      * @param aNewConn A flag if a new connection was created. If the 
       
   417      *                 connection is not new, proxy filter optimization will not 
       
   418      *                 read the proxy again from CommsBd.
       
   419      * @param aBearerType The bearer type of the new connection
       
   420      * @return void
       
   421      */
       
   422     void NetworkConnectionNeededL( TInt* aConnectionPtr, TInt& aSockSvrHandle,
       
   423     		TBool& aNewConn, TApBearerType& aBearerType );
       
   424 
       
   425     /**
       
   426      * Calls synchronous SendReceive on current session
       
   427      *
       
   428      * @param aFunction The function number identifying the request. 
       
   429      * @param aArgs A set of up to 4 arguments and their types to be passed to the server.
       
   430      * @return void.
       
   431      */
       
   432     TInt SendReceiveSync(TInt aFunction, const TIpcArgs& aArgs) const;
       
   433 
       
   434 private:
       
   435     /**
       
   436      * Gets unique transaction (Factory function)
       
   437      *
       
   438      * @return new CTransaction
       
   439      */
       
   440 
       
   441     CTransaction* GetTransactionL();
       
   442     /**
       
   443      * Create the server thread/process
       
   444      *
       
   445      * @since 3.1
       
   446      * @return An error code.
       
   447      */
       
   448     TInt StartServer();
       
   449 
       
   450 private:
       
   451     MFeedsApiObserver& iObserver;
       
   452 
       
   453     CFeedsEntity* iRootFolder;
       
   454     CFeedsEntity* iCurrentFeed;
       
   455 
       
   456     RPointerArray<CTransaction> iActiveTransaction;
       
   457     TInt iFolderListId;
       
   458     TInt iIsConnected;
       
   459     TFeedsServerSetting iSetting;
       
   460 
       
   461 private:
       
   462     //Used for creating connection
       
   463     TBool iConnectionReady;
       
   464     TInt iConnectionPtr;
       
   465     TInt iSockSvrHandle;
       
   466     TBool iNewConn;
       
   467     TApBearerType iBearerType;
       
   468 
       
   469     };
       
   470     
       
   471 #endif  // FEED_INTERFACE_H
       
   472 // End of File