S60 5th Edition SDK
Example Applications Guide

csasyncrequesthandler.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : csasyncrequesthandler.h
00004 *  Part of     : CSAsync
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2004-2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 
00017 #ifndef __CCSASYNCREQUESTHANDLER_H__
00018 #define __CCSASYNCREQUESTHANDLER_H__
00019 
00020 // INCLUDE FILES
00021 #include <e32base.h>
00022 #include "TimeServerSession.h"
00023 
00024 // FORWARD DECLARATIONS
00025 class MAsyncTimeObserver;
00026 
00027 // CLASS DECLARATION
00028 /**
00029 * CCSAsyncRequestHandler
00030 *  An instance of the request handler object for the ClientServerAsync
00031 *  example application
00032 */
00033 class CCSAsyncRequestHandler : public CActive
00034     {
00035     public: // Constructors and destructors
00036         /**
00037         * NewL.
00038         * Two-phased constructor.
00039         * Creates a CCSAsyncRequestHandler object using two phase construction,
00040         * and return a pointer to the created object.
00041         * @param aObserver The object to be used to
00042         *                  handle updates from the server.
00043         * @return A pointer to the created instance of CCSAsyncRequestHandler.
00044         */
00045         static CCSAsyncRequestHandler* NewL( MAsyncTimeObserver& aObserver );
00046 
00047         /**
00048         * NewLC.
00049         * Two-phased constructor.
00050         * Creates a CCSAsyncRequestHandler object using two phase construction,
00051         * and return a pointer to the created object.
00052         * @param aObserver The object to be used to
00053         *                  handle updates from the server.
00054         * @return A pointer to the created instance of CCSAsyncRequestHandler.
00055         */
00056         static CCSAsyncRequestHandler* NewLC( MAsyncTimeObserver& aObserver );
00057 
00058         /**
00059         * ~CCSAsyncRequestHandler.
00060         * Destructor.
00061         * Destroys the object and release all memory objects.
00062         */
00063         virtual ~CCSAsyncRequestHandler();
00064 
00065     public: // New functions
00066 
00067         /**
00068         * RequestTime.
00069         * Sends a request to the server for an update to the time.
00070         */
00071         void RequestTime();
00072 
00073         /**
00074         * CancelRequest.
00075         * Cancels an outstanding request.
00076         */
00077         void CancelRequest() ;
00078 
00079         /**
00080         * Time.
00081         * Gets a copy of the last time received from the server.
00082         * @return The time.
00083         */
00084         TTime Time() const;
00085 
00086     protected: // Functions from base classes
00087 
00088         /**
00089         * From CActive, RunL.
00090         * Callback function.
00091         * Invoked to handle responses from the server.
00092         */
00093         void RunL();
00094 
00095         /**
00096         * From CActive, DoCancel.
00097         * Cancels any outstanding operation.
00098         */
00099         void DoCancel();
00100 
00101     private: // Constructors and destructors
00102 
00103         /**
00104         * CCSAsyncRequestHandler.
00105         * Performs the first phase of two phase construction.
00106         * @param aObserver The object to be used to
00107         *                  handle updates from the server.
00108         */
00109         CCSAsyncRequestHandler( MAsyncTimeObserver& aObserver );
00110 
00111         /**
00112         * ConstructL.
00113         * Performs the second phase construction of a
00114         * CCSAsyncRequestHandler object.
00115         */
00116         void ConstructL();
00117 
00118     private: // Data
00119 
00120         /**
00121         * iSession, the time server session.
00122         */
00123         RTimeServerSession iSession;
00124 
00125         /**
00126         * iTime, passed to the session to store the time.
00127         */
00128         TTime iTime;
00129 
00130         /**
00131         * iObserver, observer which handles updates from the server.
00132         */
00133         MAsyncTimeObserver& iObserver;
00134     };
00135 
00136 
00137 #endif //__CCSASYNCREQUESTHANDLER_H__
00138 
00139 // End of File

© Nokia 2009

Back to top