Nokia N97 SDK
Example Applications Guide

CChatAppUi Class Reference

#include <ChatAppui.h>

Inheritance diagram for CChatAppUi:

List of all members.

Detailed Description

Application UI class. Provides support for the following features:

Definition at line 35 of file ChatAppui.h.


Public Member Functions

void  ConstructL ()
  ~CChatAppUi ()

Private Member Functions

void  DynInitMenuPaneL (TInt aResourceId, CEikMenuPane *aMenuPane)
void  HandleCommandL (TInt aCommand)
virtual TKeyResponse  HandleKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType)
virtual void  HandleResourceChangeL (TInt aType)
void  ShowBTNotAvailableNoteL ()

Private Attributes

CChatContainer *  iAppContainer
CChatBt *  iChatBt
CChatInet *  iChatInet
TBool  iBtAvailable


Constructor & Destructor Documentation

CChatAppUi::~CChatAppUi (   ) 
 

Destructor.

Definition at line 79 of file ChatAppui.cpp.

References iAppContainer, iChatBt, and iChatInet.

00080     {
00081     delete iChatBt;
00082     iChatBt = NULL;
00083     
00084     delete iChatInet;
00085     iChatInet= NULL;
00086     
00087     if ( iAppContainer )
00088         {
00089         RemoveFromStack( iAppContainer );
00090         delete iAppContainer;
00091         iAppContainer = NULL;
00092         }
00093    }


Member Function Documentation

void CChatAppUi::ConstructL (   ) 
 

default constructor.

Definition at line 43 of file ChatAppui.cpp.

References iAppContainer, iBtAvailable, iChatBt, iChatInet, CChatInet::NewL(), CChatBt::NewL(), and CChatContainer::NewL().

00044     {
00045     BaseConstructL( CAknAppUi::EAknEnableSkin );
00046 
00047     iAppContainer = CChatContainer::NewL( ClientRect() );    
00048     
00049     // so view can update scroll bars
00050     iAppContainer->SetMopParent( this ); 
00051 
00052     AddToStackL( iAppContainer );
00053 
00054     iChatBt = CChatBt::NewL( *iAppContainer );
00055     iChatInet = CChatInet::NewL( *iAppContainer );
00056 
00057     // check whether BT is available or not
00058 
00059     RSdp sdpSession;
00060 
00061     if ( sdpSession.Connect() == KErrNone )
00062         {
00063         sdpSession.Close();
00064     
00065         iBtAvailable = ETrue;
00066         }
00067     else
00068         {
00069         iBtAvailable = EFalse;
00070         }
00071     }

void CChatAppUi::HandleCommandL (  TInt  aCommand  )  [private]
 

From CEikAppUi, takes care of command handling.

Parameters:
aCommand  command to be handled

Definition at line 201 of file ChatAppui.cpp.

References CChatInet::DisconnectL(), iChatBt, iChatInet, CChatBase::IsConnected(), CChatBase::IsConnecting(), CChatBase::Server(), CChatInet::Stop(), and CChatBt::StopL().

00202     {
00203     TBuf<KChatTextBufLength> text;
00204 
00205       switch ( aCommand )
00206           {
00207           
00208           case EAknSoftkeyExit:
00209           case EEikCmdExit:          
00210               {
00211               if ( iChatInet->IsConnected() || iChatInet->IsConnecting() )
00212                   {
00213                   if ( iChatInet->Server() )
00214                       {
00215                           iChatInet->Stop();
00216                       }
00217                   else
00218                       {
00219                       iChatInet->DisconnectL();
00220                       }           
00221                   }
00222               if ( iChatBt->IsConnected() || iChatBt->IsConnecting()  )
00223                   {
00224                   if ( iChatBt->Server() )
00225                       {
00226                           iChatBt->StopL();
00227                       }
00228                   else
00229                       {
00230                       iChatBt->DisconnectL();
00231                       }
00232                   }
00233  
00234               Exit();
00235               break;
00236               }
00237               
00238           case EChatBtChat:
00239               {
00240               break;
00241               }
00242               
00243           case EChatIpChat:
00244               {
00245               break;
00246               }
00247               
00248           case EChatStartChat:
00249               {
00250               if ( !iBtAvailable  )
00251                   {
00252                   ShowBTNotAvailableNoteL();
00253                   }
00254               else 
00255                   {
00256                   iChatBt->StartL();
00257                   }
00258               break;
00259               }
00260               
00261           case EChatConnect:
00262               {
00263               if ( !iBtAvailable  )
00264                   {
00265                   ShowBTNotAvailableNoteL();
00266                   }
00267               else 
00268                   {
00269                   iChatBt->ConnectL();  
00270                   }
00271               break;
00272               }
00273               
00274           case EChatStartIpChat:
00275               {
00276               iChatInet->StartL();
00277               break;
00278               }
00279               
00280           case EChatIpConnect:
00281               {
00282               iAppContainer->ShowDataQueryL( 
00283                   R_CHAT_SERVERDATA_QUERY, 
00284                   0, 
00285                   0, 
00286                   KChatTextBufLength, 
00287                   EFalse, 
00288                   text );
00289 
00290               if ( text.Length() != 0 )
00291                   {
00292                   iChatInet->ConnectL( text );
00293                   }
00294               break;
00295               }
00296               
00297           case EChatDisconnect:
00298               {
00299               if ( iChatInet->IsConnected() )
00300                   {
00301                   iChatInet->DisconnectL(); 
00302                   }
00303               if ( iChatBt->IsConnected() )
00304                   {
00305                   iChatBt->DisconnectL(); 
00306                   }
00307                 break;
00308               }
00309               
00310           case EChatStopBtChat:
00311               {
00312               if ( !iBtAvailable  )
00313                   {
00314                   ShowBTNotAvailableNoteL();
00315                   }
00316               else 
00317                   {
00318                   iChatBt->StopL(); 
00319                   }
00320               break;
00321               }
00322               
00323           case EChatStopIpChat:
00324               {
00325               iChatInet->Stop();
00326               break;
00327               } 
00328                  
00329           case EChatSendMessage:
00330               {
00331               iAppContainer->ShowDataQueryL( 
00332                   R_CHAT_DATA_QUERY, 
00333                   0, 
00334                   0, 
00335                   KChatTextBufLength, 
00336                   ETrue, 
00337                   text );
00338               
00339               if ( iChatInet->IsConnected() )
00340                   {
00341                   iChatInet->SendMessageL( text );
00342                   }
00343               if( iChatBt->IsConnected() )
00344                   {
00345                   iChatBt->SendMessageL( text );
00346                   }
00347               break;
00348               }
00349               
00350            case EChatClearList:
00351                {
00352                iAppContainer->ClearMessageListL();
00353                break;
00354                } 
00355               
00356           default:
00357               break;      
00358           }
00359     }

TKeyResponse CChatAppUi::HandleKeyEventL (  const TKeyEvent &  aKeyEvent,
TEventCode  aType
)  [private, virtual]
 

From CEikAppUi, handles key events.

Parameters:
aKeyEvent  Event to handled.
aType  Type of the key event.
Returns:
Response code (EKeyWasConsumed, EKeyWasNotConsumed).

Definition at line 190 of file ChatAppui.cpp.

00192     {
00193     return EKeyWasNotConsumed;
00194     }

void CChatAppUi::HandleResourceChangeL (  TInt  aType  )  [private, virtual]
 

From CEikAppUi, handles key events.

Parameters:
aType  The type of resources that have changed

Definition at line 388 of file ChatAppui.cpp.

References iAppContainer.

00389     {
00390     CAknAppUi::HandleResourceChangeL( aType );
00391 
00392     // ADDED FOR SCALABLE UI SUPPORT
00393     // *****************************
00394     if ( aType==KEikDynamicLayoutVariantSwitch )
00395         {
00396         iAppContainer->SetRect( ClientRect() );
00397         }
00398     //Controls derived from CCoeControl, handled in container class
00399     iAppContainer->HandleResourceChange( aType );
00400     }

void CChatAppUi::ShowBTNotAvailableNoteL (   )  [private]
 

ShowBTNotAvailableNoteL. Show note if BT is not available

Definition at line 366 of file ChatAppui.cpp.

00367     {
00368     // Load a string from the resource file and display it
00369     HBufC* textResource = StringLoader::LoadLC( R_CHAT_NO_BT );
00370     CAknErrorNote* errorNote;
00371 
00372     errorNote = new ( ELeave ) CAknErrorNote;
00373 
00374     // Show the information Note with
00375     // textResource loaded with StringLoader.
00376     errorNote->ExecuteLD( *textResource);
00377 
00378     // Pop HBuf from CleanUpStack and Destroy it.
00379     CleanupStack::PopAndDestroy( textResource );
00380     }


Member Data Documentation

CChatBt* CChatAppUi::iChatBt [private]
 

iClient the BT chat engine Owned by CChatAppUi

Definition at line 96 of file ChatAppui.h.

Referenced by ConstructL(), DynInitMenuPaneL(), HandleCommandL(), and ~CChatAppUi().

CChatInet* CChatAppUi::iChatInet [private]
 

iClientInet the TCPIP chat engine Owned by CChatAppUi

Definition at line 103 of file ChatAppui.h.

Referenced by ConstructL(), DynInitMenuPaneL(), HandleCommandL(), and ~CChatAppUi().

TBool CChatAppUi::iBtAvailable [private]
 

iBtAvailable, ETrue if an SDP session can be opened, EFalse otherwise.

Definition at line 108 of file ChatAppui.h.

Referenced by ConstructL().


The documentation for this class was generated from the following files:

© Nokia 2009

Back to top