|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : ChatBase.cpp 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 // INCLUDE FILES 00017 #include <ChatEx.rsg> 00018 #include "ChatBase.h" 00019 #include "Chat.pan" 00020 #include "Log.h" 00021 #include <StringLoader.h> 00022 00023 00024 // ============================ MEMBER FUNCTIONS ============================== 00025 00026 // ---------------------------------------------------------------------------- 00027 // CChatBase::NewL() 00028 // Two-phased constructor. 00029 // ---------------------------------------------------------------------------- 00030 // 00031 CChatBase* CChatBase::NewL( MLog& aLog ) 00032 { 00033 CChatBase* self = NewLC( aLog ); 00034 CleanupStack::Pop( self ); 00035 return self; 00036 } 00037 00038 // ---------------------------------------------------------------------------- 00039 // CChatBase::NewLC() 00040 // Two-phased constructor. 00041 // ---------------------------------------------------------------------------- 00042 // 00043 CChatBase* CChatBase::NewLC( MLog& aLog ) 00044 { 00045 CChatBase* self = new ( ELeave ) CChatBase( aLog ); 00046 CleanupStack::PushL( self ); 00047 self->ConstructL (); 00048 return self; 00049 } 00050 00051 // ---------------------------------------------------------------------------- 00052 // CChatBase::ConstructL() 00053 // Perform second phase construction of this object. 00054 // ---------------------------------------------------------------------------- 00055 // 00056 void CChatBase::ConstructL() 00057 { 00058 // no implementation required 00059 } 00060 00061 // ---------------------------------------------------------------------------- 00062 // CChatBt::CChatBt() 00063 // Constructor. 00064 // ---------------------------------------------------------------------------- 00065 // 00066 CChatBase::CChatBase( MLog& aLog ) 00067 : CActive( CActive::EPriorityStandard ), 00068 iState( EWaitingToGetDevice ), 00069 iLog( aLog ), 00070 iServerMode( EFalse ) 00071 { 00072 CActiveScheduler::Add( this ); 00073 } 00074 00075 // ---------------------------------------------------------------------------- 00076 // CChatBase::~CChatBase() 00077 // Destructor. 00078 // ---------------------------------------------------------------------------- 00079 // 00080 CChatBase::~CChatBase() 00081 { 00082 00083 } 00084 00085 // ---------------------------------------------------------------------------- 00086 // CChatBase::DoCancel() 00087 // Cancel any outstanding requests. 00088 // ---------------------------------------------------------------------------- 00089 // 00090 void CChatBase::DoCancel() 00091 { 00092 // no implementation required 00093 } 00094 00095 // ---------------------------------------------------------------------------- 00096 // CChatBase::RunL() 00097 // Respond to an event. 00098 // ---------------------------------------------------------------------------- 00099 // 00100 void CChatBase::RunL() 00101 { 00102 // no implementation required 00103 } 00104 00105 // ---------------------------------------------------------------------------- 00106 // CChatBase::IsServer() 00107 // True if the acting as server. 00108 // ---------------------------------------------------------------------------- 00109 // 00110 TBool CChatBase::Server() 00111 { 00112 return iServerMode; 00113 } 00114 00115 // ---------------------------------------------------------------------------- 00116 // CChatBase::SetServer() 00117 // 00118 // ---------------------------------------------------------------------------- 00119 // 00120 void CChatBase::SetServer( TBool aServerMode ) 00121 { 00122 iServerMode = aServerMode; 00123 } 00124 00125 // ---------------------------------------------------------------------------- 00126 // CChatBase::SetState() 00127 // 00128 // ---------------------------------------------------------------------------- 00129 // 00130 void CChatBase::SetState( TChatState aState ) 00131 { 00132 iState = aState; 00133 } 00134 00135 // ---------------------------------------------------------------------------- 00136 // CChatBase::State() 00137 // 00138 // ---------------------------------------------------------------------------- 00139 // 00140 TInt CChatBase::State() 00141 { 00142 return iState; 00143 } 00144 00145 // ---------------------------------------------------------------------------- 00146 // CChatBase::IsReadyToSendMessage() 00147 // True if the client can send a message. 00148 // ---------------------------------------------------------------------------- 00149 // 00150 TBool CChatBase::IsReadyToSendMessage() 00151 { 00152 return ( State() == EConnected ); 00153 } 00154 00155 // ---------------------------------------------------------------------------- 00156 // CChatBase::IsConnected() 00157 // True if the client can send a message. 00158 // ---------------------------------------------------------------------------- 00159 // 00160 TBool CChatBase::IsConnected() 00161 { 00162 return ( ( State() == EConnected )||( State() == ESendingMessage ) ); 00163 } 00164 00165 00166 // ---------------------------------------------------------------------------- 00167 // CChatBase::IsConnecting() 00168 // True if is establishing a connection. 00169 // ---------------------------------------------------------------------------- 00170 // 00171 TBool CChatBase::IsConnecting() 00172 { 00173 return ( ( State() == EGettingDevice ) 00174 || 00175 ( State() == EGettingService ) 00176 || 00177 ( State() == EGettingConnection ) 00178 || 00179 ( State() == EConnecting ) 00180 ); 00181 } 00182 00183 // ---------------------------------------------------------------------------- 00184 // CChatBase::IsSendingMessage() 00185 // True if the client is connected. 00186 // ---------------------------------------------------------------------------- 00187 // 00188 TBool CChatBase::IsSendingMessage() 00189 { 00190 return ( State() == ESendingMessage ); 00191 } 00192 00193 00194 00195
|
© Nokia 2006 |