S60 3rd Edition SDK for Symbian OS
Example Applications Guide

ChatBase.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : ChatBase.h
00004 *  Part of     : Chat
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2005-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 #ifndef CHATBASE_H
00017 #define CHATBASE_H
00018 
00019 #include "ChatProtocolConstants.h"
00020 
00021 // FORWARD DECLARATIONS
00022 class MLog;
00023 
00024        /**
00025         * TChatState
00026         * The state of the active object, determines behaviour within
00027         * the RunL method.
00028         * EWaitingToGetDevice waiting for the user to select a device
00029         * EGettingDevice searching for a device
00030         * EGettingService searching for a service
00031         * EGettingConnection connecting to a service on a remote machine
00032         * EConnected connected to a service on a remote machine
00033         * ESendingMessage sending a message to the remote machine
00034         * EWaitingForMessage wainting for message from remote machine
00035         * EConnecting connecting to remote machine
00036         * EDisconnecting disconnecting from remote machine
00037         */
00038  
00039         enum TChatState 
00040             {
00041             EWaitingToGetDevice,
00042             EGettingDevice,
00043             EGettingService,
00044             EGettingConnection,
00045             EConnected,
00046             EDisconnected,
00047             ESendingMessage,
00048             EWaitingForMessage,
00049             EConnecting,
00050             EDisconnecting
00051             };
00052             
00053             
00054 /**
00055 * CChatBase
00056 * Connects and sends messages to a remote machine using bluetooth
00057 */
00058 class CChatBase : public CActive 
00059     {
00060     public: // Constructors and destructor
00061 
00062         /**
00063         * NewL()
00064         * Construct a CChatClient
00065         * @param aLog the log to send output to
00066         * @return a pointer to the created instance of CChatClient
00067         */
00068         static CChatBase* NewL( MLog& aLog );
00069 
00070         /**
00071         * NewLC()
00072         * Construct a CChatClient
00073         * @param aLog the log to send output to
00074         * @return a pointer to the created instance of CChatClient
00075         */
00076         static CChatBase* NewLC( MLog& aLog );
00077 
00078         /**
00079         * CChatBase()
00080         * Constructs this object
00081         * @param aLog the log to send output to
00082         */
00083         CChatBase( MLog& aLog );
00084         
00085         /**
00086         * ~CChatBase()
00087         * Destroy the object and release all memory objects. 
00088         * Close any open sockets.
00089         */
00090         virtual ~CChatBase();
00091 
00092     public:     // New functions
00093 
00094         /**
00095         * SetServer()
00096         * Set servermode
00097         * @param aServerMode ETrue if servermode is used
00098         */
00099         void SetServer( TBool aServerMode );
00100     
00101         /**
00102         * Server()
00103         * Get Servermode
00104         * @return servermode
00105         */
00106         TBool Server();
00107     
00108         /**
00109         * SetState()
00110         * Set state
00111         * @param aState the state of the engine
00112         */
00113         void SetState( TChatState aState );
00114     
00115         /**
00116         * State()
00117         * Get State
00118         * @return state
00119         */
00120         TInt State();
00121     
00122         /**
00123         * IsConnected()
00124         * @return ETrue if the client is fully connected to the server.
00125         */
00126         TBool IsConnected();
00127 
00128         /**
00129         * IsConnecting()
00130         * @return ETrue if the client is establishing a 
00131         * connection to the server.
00132         */
00133         TBool IsConnecting();
00134 
00135         /**
00136         * IsConnected()
00137         * @return ETrue if the client is connected.
00138         */
00139         TBool IsSendingMessage();
00140         
00141     
00142         /**
00143         * IsReadyToSendMessage()
00144         * @return ETrue if the client can send a message.
00145         */
00146         TBool IsReadyToSendMessage();
00147 
00148 
00149     protected:    // from CActive
00150 
00151         /**
00152         * DoCancel()
00153         * Cancel any outstanding requests
00154         */
00155         void DoCancel();
00156 
00157         /**
00158         * RunL()
00159         * Respond to an event
00160         */
00161         void RunL();
00162 
00163     private:    // Functions from base classes
00164 
00165         /**
00166         * ConstructL()
00167         * Performs second phase construction of this object
00168         */
00169         void ConstructL();
00170 
00171     private:    // New functions
00172      
00173     private:    // data
00174 
00175         /** 
00176         * iState the current state of the client 
00177         */
00178         TChatState iState;
00179 
00180         /** 
00181         * iLog the log to send output to 
00182         */
00183         MLog& iLog;
00184         
00185         /** 
00186         * iServerMode indicates server mode 
00187         */
00188         TBool iServerMode;  
00189     };
00190 
00191 #endif // CHATBASE_H
00192 
00193 // End of File

© Nokia 2006

Back to top