Nokia N97 SDK
Example Applications Guide

CIMOpenAPIExampleAppUi Class Reference

#include <IMOpenAPIExampleAppUi.h>

Inheritance diagram for CIMOpenAPIExampleAppUi:

List of all members.

Detailed Description

Application UI class. Provides support for the following features:

Definition at line 44 of file IMOpenAPIExampleAppUi.h.


Public Member Functions

void  ConstructL ()
  ~CIMOpenAPIExampleAppUi ()
void  SetGameState (TGameState const aState)
TGameState  GetGameState () const
void  HandleMessageErrorFromModel (const TInt aIntegerInfo, const TDesC &aStringInfo)
void  HandleMessageFromModel (const TInternalMsgID aMsgID, const TInt aIntegerInfo, const TDesC &aStringInfo)
void  HandleChallengeRec (const TDesC &aUserID)
void  HandleMessageIMConnectionFromModel (const TInternalMsgID aMsgID, const TInt aIntegerInfo)
void  DisplayInfoMessage (TInt aResourceID)
void  PlayedIndex (const TInt aIntegerInfo)

Private Member Functions

void  DynInitMenuPaneL (TInt aResourceId, CEikMenuPane *aMenuPane)
void  HandleCommandL (TInt aCommand)
virtual TKeyResponse  HandleKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType)
TBool  Challenge ()
void  LoginSettings ()
CIMOpenAPIExampleDocument &  Document () const
void  SelectAccessPoint ()

Private Attributes

CIMOpenAPIExampleContainer *  iAppContainer
CAknWaitDialog *  iWaitDialog
TBuf< KMaxInfoMsgLength >  iDisplayMessage
TBuf< KMaxChallengeIDLength >  iUserID
TBuf< KMaxServerAddressLength >  iServerAddress
TBuf< KMaxPasswordLength >  iPassword
TUint32  iAPNumber
TBool  iLoginSettingsDone
RGenConAgentDialogServer  iDlgSrv
TRequestStatus  iStatus


Constructor & Destructor Documentation

CIMOpenAPIExampleAppUi::~CIMOpenAPIExampleAppUi (   ) 
 

Destructor.

Definition at line 70 of file IMOpenAPIExampleAppUi.cpp.

References iAppContainer, iDlgSrv, and iWaitDialog.

00071     {
00072     if (iAppContainer)
00073         {
00074         RemoveFromStack( iAppContainer );
00075         delete iAppContainer;
00076         }
00077     if (iWaitDialog)
00078         {
00079         delete iWaitDialog;
00080         iWaitDialog = NULL;
00081         }
00082         
00083     iDlgSrv.Close();
00084         
00085    }


Member Function Documentation

void CIMOpenAPIExampleAppUi::ConstructL (   ) 
 

EPOC default constructor.

Definition at line 43 of file IMOpenAPIExampleAppUi.cpp.

References CIMOpenAPIExampleContainer::ConstructL(), Document(), GetGameState(), iAPNumber, iAppContainer, iDisplayMessage, iLoginSettingsDone, CIMOpenAPIExampleContainer::SetGameView(), CIMOpenAPIExampleContainer::SetModel(), and CIMOpenAPIExampleDocument::SetPointerToUI().

00044     {
00045     BaseConstructL(CAknAppUi::EAknEnableSkin);
00046     SetLayoutAwareApp(EFalse);
00047     
00048         Document().SetPointerToUI(this);
00049     iAppContainer = new (ELeave) CIMOpenAPIExampleContainer;
00050     iAppContainer->SetMopParent( this );
00051     iAppContainer->ConstructL( ClientRect() );
00052     AddToStackL( iAppContainer );
00053     
00054         
00055     iAppContainer->SetGameView( Document().Model().GetGameState() );
00056     iAppContainer->SetModel( &(Document().Model()) );
00057     
00058     iAPNumber = 0;
00059     iLoginSettingsDone = EFalse;
00060     
00061     iDisplayMessage.Copy(KNullDesC);
00062     }

void CIMOpenAPIExampleAppUi::SetGameState (  TGameState const   aState  ) 
 

SetGameState. Set the UI according to current game state

Parameters:
aState  current game state

Definition at line 512 of file IMOpenAPIExampleAppUi.cpp.

References iAppContainer, and CIMOpenAPIExampleContainer::SetGameView().

Referenced by CIMOpenAPIExamplemodel::SetGameState().

00513         {
00514         iAppContainer->SetGameView(aState);
00515         }

TGameState CIMOpenAPIExampleAppUi::GetGameState (   )  const
 

GetGameState. Get the current game state

Returns:
Current game state

Definition at line 522 of file IMOpenAPIExampleAppUi.cpp.

References Document(), CIMOpenAPIExamplemodel::GetGameState(), and CIMOpenAPIExampleDocument::Model().

Referenced by ConstructL(), and DynInitMenuPaneL().

00523         {
00524         return Document().Model().GetGameState();
00525         }

void CIMOpenAPIExampleAppUi::HandleMessageErrorFromModel (  const TInt  aIntegerInfo,
const TDesC &  aStringInfo
) 
 

HandleMessageErrorFromModel. handle error messages from Model. Model calls this function

Parameters:
aIntegerInfo  Error information as string aStringInfo Error information in string

Definition at line 309 of file IMOpenAPIExampleAppUi.cpp.

References iDisplayMessage.

Referenced by CIMOpenAPIExamplemodel::HandleSendErrorL().

00312         {
00313         CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse );
00314         note->SetTimeout( CAknNoteDialog::ELongTimeout  );
00315         _LIT(errString, "in, %S with Error code: %d");
00316 
00317         switch (aErrorCode)
00318         {
00319         case KImApiErrNotLogged:
00320             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_NOT_LOGGEDIN );
00321             break;
00322 
00323                 default:
00324             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_ERROR );
00325             iDisplayMessage.AppendFormat(errString, &aStringInfo, aErrorCode);
00326                     break;
00327                 }
00328     note->ExecuteLD( iDisplayMessage );
00329     iDisplayMessage.Copy(KNullDesC); 
00330         }

void CIMOpenAPIExampleAppUi::HandleMessageFromModel (  const TInternalMsgID  aMsgID,
const TInt  aIntegerInfo,
const TDesC &  aStringInfo
) 
 

HandleMessageFromModel. handle messages from Model. Model calls this function

Parameters:
aMsgID  internal message id, used inside application aIntegerInfo information as string aStringInfo Error information in string

Definition at line 370 of file IMOpenAPIExampleAppUi.cpp.

References Document(), iAppContainer, iDisplayMessage, and CIMOpenAPIExampleContainer::SetCellSign().

Referenced by CIMOpenAPIExamplemodel::HandleMessageSentL(), CIMOpenAPIExamplemodel::HandleNewPToPMessageL(), and CIMOpenAPIExamplemodel::SendPlayedIndex().

00374         {
00375         CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse );
00376         note->SetTimeout( CAknNoteDialog::ELongTimeout  );
00377 
00378         switch (aMsgID)
00379                 {
00380         case ChallengeSent:
00381             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_SENT );
00382             break;
00383 
00384                 // handled by a seperate function
00385         case ChallengeRec:
00386                         break;
00387 
00388         case PlayedIndexRec:
00389             iAppContainer->SetCellSign(Document().Model().GetOppSign(), aIntegerInfo);
00390             break;
00391 
00392                 case StartGameRec:
00393             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_GAME_STARTED );                
00394                         break;
00395 
00396 
00397                 case EndGameRec:
00398             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_GAME_ENDED );
00399             break;
00400 
00401 
00402                 case ChallengeAcceptedRec:
00403             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_ACCEPTED );
00404                 break;
00405 
00406 
00407                 case ChallengeRejectedRec:
00408             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_REJECTED );
00409                         break;
00410 
00411                 case AlreadyInGameRec:
00412             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_ALREADY_IN_GAME );
00413                 break;
00414 
00415         case YouWon:
00416             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_YOU_WON );
00417             break;
00418 
00419         case YouLost:
00420             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_YOU_LOST );
00421             break;
00422 
00423         case GameDraw:
00424             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_GAME_DRAW );
00425             break;
00426 
00427         case StartGameWarning:
00428             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_START_GAME_WARNING );
00429             break;
00430 
00431         case EndChallengeRec:
00432             StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_ENDED );
00433             break;
00434 
00435                 default:
00436             break;
00437                 }
00438     if ( iDisplayMessage.Compare(KNullDesC) != 0)
00439         note->ExecuteLD( iDisplayMessage );
00440     else
00441         delete note;
00442 
00443     iDisplayMessage.Copy(KNullDesC);
00444         }

void CIMOpenAPIExampleAppUi::HandleChallengeRec (  const TDesC &  aUserID  ) 
 

HandleChallengeRec. handle challenge from Model. Model calls this function when some challenge comes

Parameters:
aUserID  reference to the challenger User Id

Definition at line 338 of file IMOpenAPIExampleAppUi.cpp.

References Document(), iAppContainer, iDisplayMessage, and CIMOpenAPIExampleContainer::SetMySign().

Referenced by CIMOpenAPIExamplemodel::HandleNewPToPMessageL().

00339     {
00340     TInt err = KErrNone;
00341     _LIT(errorString,"Error:( %i )");
00342     CAknQueryDialog* query = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone);
00343     StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_RECEIVED );
00344     iDisplayMessage.Append(aUserID);
00345     if ( query->ExecuteLD( R_CHALLENGE_QUERY, iDisplayMessage ) )
00346         {
00347         TRAP( err , Document().Model().SendChallengeAccepted() );
00348         iAppContainer->SetMySign(EZeroSign);
00349         }
00350     else
00351         TRAP( err , Document().Model().SendChallengeRejected() );
00352         
00353     if (err != KErrNone )
00354                 {
00355                 CAknErrorNote* note = new(ELeave) CAknErrorNote();
00356                 TBuf<0x100> buf;
00357                 buf.Format(errorString, err );
00358                 note->ExecuteLD( buf );
00359                 }
00360     iDisplayMessage.Copy(KNullDesC);
00361     }

void CIMOpenAPIExampleAppUi::HandleMessageIMConnectionFromModel (  const TInternalMsgID  aMsgID,
const TInt  aIntegerInfo
) 
 

HandleMessageIMConnectionFromModel. handle connection related messages from Model. Model calls this function

Parameters:
aMsgID  Internal message id, used inside application aIntegerInfo Information as string

Definition at line 453 of file IMOpenAPIExampleAppUi.cpp.

References iDisplayMessage, and iWaitDialog.

Referenced by CIMOpenAPIExamplemodel::HandleLoginL(), and CIMOpenAPIExamplemodel::HandleLogoutL().

00457         {
00458         CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse );
00459         note->SetTimeout( CAknNoteDialog::ELongTimeout  );
00460 
00461         switch (aMsgID)
00462                 {
00463                 case Connected:
00464                         iWaitDialog->ProcessFinishedL();
00465                         if (aErrorCode != KErrNone)
00466                                 {
00467                                 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_LOGIN_FAILED );
00468                                 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_ERROR );
00469                                 iDisplayMessage.AppendNum(aErrorCode);
00470                                 }
00471                         else 
00472                                 {
00473                                 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_LOGIN_SUCCESS );
00474                                 }
00475                         note->ExecuteLD( iDisplayMessage );
00476                         break;
00477 
00478                 case DisConnected:
00479                         if (iWaitDialog)
00480                                 iWaitDialog->ProcessFinishedL();
00481                         StringLoader::Load ( iDisplayMessage, R_INFO_MSG_DISCONNECTED );
00482                         note->ExecuteLD( iDisplayMessage );
00483                         break;
00484 
00485         default:
00486             break;
00487                 }
00488         if(note)
00489                 {
00490                 delete note;
00491                 note = NULL;
00492                 }
00493     iDisplayMessage.Copy(KNullDesC);
00494         }

void CIMOpenAPIExampleAppUi::DisplayInfoMessage (  TInt  aResourceID  ) 
 

DisplayInfoMessage. Displays the information message to user with given resource id

Parameters:
aResourceID  resource id of the message

Definition at line 532 of file IMOpenAPIExampleAppUi.cpp.

References iDisplayMessage.

00533     {
00534     CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse );
00535         note->SetTimeout( CAknNoteDialog::ELongTimeout  );
00536         StringLoader::Load ( iDisplayMessage, aResourceID );
00537         note->ExecuteLD( iDisplayMessage );
00538     iDisplayMessage.Copy(KNullDesC);
00539     }

void CIMOpenAPIExampleAppUi::PlayedIndex (  const TInt  aIntegerInfo  ) 
 

PlayedIndex. This functions gets the index position in the matrix where opponent has marked cross or circle.

Parameters:
aIntegerInfo  position in the 3*3 matrix, 0 to 8

void CIMOpenAPIExampleAppUi::DynInitMenuPaneL (  TInt  aResourceId,
CEikMenuPane *  aMenuPane
)  [private]
 

PlayedIndex. From MEikMenuObserver

Definition at line 95 of file IMOpenAPIExampleAppUi.cpp.

References Document(), GetGameState(), and iLoginSettingsDone.

00097     {
00098         // Here we select the game options menu according to game state
00099                 switch (aResourceId)
00100                         {
00101                         case R_IMOPENAPIEXAMPLE_MENU:
00102                                 switch ( Document().Model().GetGameState() )
00103                                 {
00104                                 case EStateNotLogin:
00105                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue);
00106                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue);
00107                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue);
00108                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, (!iLoginSettingsDone));
00109                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue);
00110                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue);
00111                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue);
00112                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, EFalse);
00113                     break;
00114 
00115                                 case EStateSending:
00116                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue);
00117                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue);
00118                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue);
00119                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue);
00120                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue);
00121                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue);
00122                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue);
00123                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue);
00124                                         break;
00125 
00126                                 case EStateLoginIdle:
00127                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue);
00128                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue);
00129                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue);
00130                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, EFalse);
00131                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue);
00132                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue);
00133                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, EFalse);
00134                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue);
00135                                         break;
00136 
00137                                 case EStateChallenged:
00138                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue);
00139                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue);
00140                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue);
00141                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue);
00142                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue);
00143                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, EFalse);
00144                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue);
00145                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue);
00146                                         break;
00147                                 
00148                                 case EStateReadytoStart:
00149                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue);
00150                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue);
00151                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue);
00152                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue);
00153                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue);
00154                     if (Document().Model().GetOppSign() == ECrossSign )
00155                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue);
00156                     else
00157                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, EFalse);
00158                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, EFalse);
00159                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue);
00160                                         break;
00161 
00162                                 case EStateWaitingForOppMove:
00163                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue);
00164                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue);
00165                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue);
00166                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, EFalse);
00167                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue);
00168                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue);
00169                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue);
00170                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue);
00171                                         break;
00172 
00173                                 case EStateWaitingForOwnMove:
00174                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue);
00175                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue);
00176                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, EFalse);
00177                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, EFalse);
00178                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue);
00179                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue);
00180                     aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue);
00181                                         aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue);
00182                                         break;
00183 
00184                                 default:
00185                                         break;
00186                                 } // iState switch ends
00187                         default:
00188                                 break;
00189                         } // aResourceId switch ends  
00190     }

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

From CEikAppUi, takes care of command handling.

Parameters:
aCommand  command to be handled

Definition at line 209 of file IMOpenAPIExampleAppUi.cpp.

References Challenge(), Document(), iAPNumber, iAppContainer, iDisplayMessage, iPassword, iServerAddress, iUserID, iWaitDialog, LoginSettings(), CIMOpenAPIExampleContainer::PlayMove(), and CIMOpenAPIExampleContainer::SetMySign().

00210     {
00211         TInt err = KErrNone;
00212         _LIT(errString, "Error:( %i )");
00213         TBuf<KMaxChallengeIDLength> OppnentID;
00214         TBuf<KMaxChallengeIDLength> OppnentI;
00215 
00216         switch ( aCommand )
00217                 {
00218                 case EAknSoftkeyBack:
00219             TRAP( err , Document().Model().PrepareToExit() );
00220             Exit();
00221                         break;
00222                 case EEikCmdExit:
00223             TRAP( err , Document().Model().PrepareToExit() );
00224             Exit();
00225                         break;
00226 
00227                 case EIMOpenAPIExampleCmdLogin:
00228                         TRAP(err ,Document().Model().LoginL(iServerAddress, iUserID, iPassword, iAPNumber));
00229                         if (err!=KErrNone)
00230                                 {
00231                     break;                          
00232                         }
00233                         iWaitDialog = new(ELeave)CAknWaitDialog((REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), EFalse );
00234                         StringLoader::Load ( iDisplayMessage, R_INFO_MSG_LOGGING );
00235                         iWaitDialog->SetTextL  ( iDisplayMessage );  
00236                         iWaitDialog->ExecuteDlgLD(CAknNoteDialog::ENoTone,R_SINGULAR_WAIT_NOTE);
00237                         break;
00238                         
00239                 case EIMOpenAPIExampleCmdLogout:
00240                         TRAP(err ,Document().Model().LogoutL());
00241                         iWaitDialog = new(ELeave)CAknWaitDialog((REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), EFalse );
00242                         StringLoader::Load ( iDisplayMessage, R_INFO_MSG_LOGGING_OUT );
00243                         iWaitDialog->SetTextL  ( iDisplayMessage );  
00244                         iWaitDialog->ExecuteDlgLD(CAknNoteDialog::ENoTone,R_SINGULAR_WAIT_NOTE);
00245                         break;
00246                         
00247                 case EIMOpenAPIExampleCmdIMSettings:
00248                         LoginSettings();
00249                         break;
00250                         
00251                 case EIMOpenAPIExampleCmdExitGame:
00252             TRAP(err ,Document().Model().SendExitGame());
00253                         break;
00254 
00255         case EIMOpenAPIExampleCmdStartGame:
00256             TRAP(err ,Document().Model().SendStartGame());
00257                         break;
00258 
00259                 case EIMOpenAPIExampleCmdChallenge:
00260             if (Challenge())
00261                 {
00262                 TRAP( err , Document().Model().SendChallenge() );
00263                 if(err!=KErrNone)
00264                     break;
00265                 iAppContainer->SetMySign(ECrossSign);
00266                 }
00267                         break;
00268 
00269         case EIMOpenAPIExampleCmdEndChallenge:
00270             TRAP( err , Document().Model().SendEndChallenge() );
00271             break;
00272 
00273         case EIMOpenAPIExampleCmdSelect:
00274             iAppContainer->PlayMove();
00275             break;
00276                 
00277                 default:
00278                         break;      
00279                 }
00280         
00281         if (err != KErrNone )
00282                         {
00283                         if(err==-5)
00284                                         {
00285                                         CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse );
00286                                         note->SetTimeout( CAknNoteDialog::ELongTimeout  );
00287                                         StringLoader::Load ( iDisplayMessage, R_INFO_MSG_NOT_SUPPORTED );
00288                                         note->ExecuteLD( iDisplayMessage );
00289                                 iDisplayMessage.Copy(KNullDesC); 
00290                                         }       
00291                         else 
00292                                         {
00293                                         CAknErrorNote* note = new(ELeave) CAknErrorNote();
00294                                         TBuf<0x100> buf;
00295                                         buf.Format(errString, err );
00296                                         note->ExecuteLD( buf );                      
00297                                         }
00298                         }
00299                         iDisplayMessage.Copy(KNullDesC);
00300         }

TKeyResponse CIMOpenAPIExampleAppUi::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 198 of file IMOpenAPIExampleAppUi.cpp.

00200     {
00201     return EKeyWasNotConsumed;
00202     }

TBool CIMOpenAPIExampleAppUi::Challenge (   )  [private]
 

Challenge. Display a query dialog for User ID of the opponent to be challenged

Returns:
ETrue if user accepts to send challenge

Definition at line 546 of file IMOpenAPIExampleAppUi.cpp.

References Document(), CIMOpenAPIExampleDocument::Model(), and CIMOpenAPIExamplemodel::SetOppID().

Referenced by HandleCommandL().

00547     {
00548     TBuf<KMaxChallengeIDLength> oppnentID;
00549         CAknTextQueryDialog* OppIDQuery = CAknTextQueryDialog::NewL(oppnentID);
00550         CleanupStack::PushL(OppIDQuery);
00551         HBufC* prompt;
00552         prompt = StringLoader::LoadLC(R_INFO_MSG_OPP_ID_PROMPT);// Pushes prompt onto the Cleanup Stack.
00553         OppIDQuery->SetPromptL(*prompt);
00554         CleanupStack::PopAndDestroy(prompt);
00555         CleanupStack::Pop(OppIDQuery);
00556         if (OppIDQuery->ExecuteLD(R_DATA_QUERY))
00557             {
00558                 Document().Model().SetOppID(oppnentID);
00559                 return ETrue;
00560                 }
00561     return EFalse;
00562     }

void CIMOpenAPIExampleAppUi::LoginSettings (   )  [private]
 

LoginSettings. Do the login settings. Displays query dialogs for user id, password server address and access points and saves to internal variables

Definition at line 569 of file IMOpenAPIExampleAppUi.cpp.

References iLoginSettingsDone, iPassword, iServerAddress, iUserID, and SelectAccessPoint().

Referenced by HandleCommandL().

00570         {
00571         HBufC* prompt;
00572         
00573         // For User ID
00574         CAknTextQueryDialog* userIDQuery = CAknTextQueryDialog::NewL(iUserID);
00575         CleanupStack::PushL(userIDQuery);
00576         prompt = StringLoader::LoadLC(R_INFO_MSG_USER_ID);// Pushes prompt to Cleanup Stack.
00577         userIDQuery->SetPromptL(*prompt);
00578         CleanupStack::PopAndDestroy(prompt);
00579         CleanupStack::Pop(userIDQuery);
00580         if (!(userIDQuery->ExecuteLD(R_USER_ID_QUERY))) 
00581             return; // return if user cancels
00582         
00583         //For Password
00584         CAknTextQueryDialog* passwordQuery = CAknTextQueryDialog::NewL(iPassword);
00585         CleanupStack::PushL(passwordQuery);
00586         prompt = StringLoader::LoadLC(R_INFO_MSG_PASSWORD);// Pushes prompt to Cleanup Stack.
00587         passwordQuery->SetPromptL(*prompt);
00588         CleanupStack::PopAndDestroy(prompt);
00589         CleanupStack::Pop(passwordQuery);
00590         if(!(passwordQuery->ExecuteLD(R_PASSWORD_QUERY))) 
00591             return; // return if user cancels
00592         
00593         //For Server Address
00594         CAknTextQueryDialog* serverAddressQuery = CAknTextQueryDialog::NewL(iServerAddress);
00595         CleanupStack::PushL(serverAddressQuery);
00596         prompt = StringLoader::LoadLC(R_INFO_MSG_SERVER_ADDRESS);// Pushes prompt to Cleanup Stack.
00597         serverAddressQuery->SetPromptL(*prompt);
00598         CleanupStack::PopAndDestroy(prompt);
00599         CleanupStack::Pop(serverAddressQuery);
00600         if(!(serverAddressQuery->ExecuteLD(R_SERVER_ADDRESS_QUERY)))
00601             return; // return if user cancels
00602         
00603         SelectAccessPoint();
00604     iLoginSettingsDone = ETrue;
00605         }

CIMOpenAPIExampleDocument & CIMOpenAPIExampleAppUi::Document (   )  const [private]
 

Document. Returns a reference to the application document

Returns:
reference to CIMOpenAPIExampleDocument

Definition at line 501 of file IMOpenAPIExampleAppUi.cpp.

Referenced by Challenge(), ConstructL(), DynInitMenuPaneL(), GetGameState(), HandleChallengeRec(), HandleCommandL(), and HandleMessageFromModel().

00502     {
00503     return *static_cast<CIMOpenAPIExampleDocument*>(CEikAppUi::Document());
00504     }

void CIMOpenAPIExampleAppUi::SelectAccessPoint (   )  [private]
 

SelectAccessPoint Display a selection list of access points to user and stores selected access point to iAPNumber

Returns:
none

Definition at line 612 of file IMOpenAPIExampleAppUi.cpp.

References iAPNumber, iDlgSrv, and iStatus.

Referenced by LoginSettings().

00613     {
00614         TConnectionPrefs prefs;
00615 
00616     iDlgSrv.Connect();
00617 
00618     prefs.iRank = 1;
00619     prefs.iDirection = ECommDbConnectionDirectionOutgoing;
00620     prefs.iBearerSet = ECommDbBearerCSD | ECommDbBearerWcdma | ECommDbBearerVirtual;
00621 
00622         TRAPD( err, iDlgSrv.IapConnection( iAPNumber, prefs, iStatus ) );
00623     User::LeaveIfError( err );
00624         
00625     User::WaitForRequest( iStatus );
00626     iDlgSrv.Close();
00627     }


Member Data Documentation

CIMOpenAPIExampleContainer* CIMOpenAPIExampleAppUi::iAppContainer [private]
 

iAppContainer. Pointer to application container

Definition at line 188 of file IMOpenAPIExampleAppUi.h.

Referenced by ConstructL(), HandleChallengeRec(), HandleCommandL(), HandleMessageFromModel(), SetGameState(), and ~CIMOpenAPIExampleAppUi().

CAknWaitDialog* CIMOpenAPIExampleAppUi::iWaitDialog [private]
 

iWaitDialog. Pointer to wait dialog

Definition at line 194 of file IMOpenAPIExampleAppUi.h.

Referenced by HandleCommandL(), HandleMessageIMConnectionFromModel(), and ~CIMOpenAPIExampleAppUi().

TBuf<KMaxInfoMsgLength> CIMOpenAPIExampleAppUi::iDisplayMessage [private]
 

iDisplayMessage. Buffer for holding message to be displayed to the user

Definition at line 200 of file IMOpenAPIExampleAppUi.h.

Referenced by ConstructL(), DisplayInfoMessage(), HandleChallengeRec(), HandleCommandL(), HandleMessageErrorFromModel(), HandleMessageFromModel(), and HandleMessageIMConnectionFromModel().

TBuf<KMaxChallengeIDLength> CIMOpenAPIExampleAppUi::iUserID [private]
 

iUserID. Buffer for holding user id for login

Definition at line 206 of file IMOpenAPIExampleAppUi.h.

Referenced by HandleCommandL(), and LoginSettings().

TBuf<KMaxServerAddressLength> CIMOpenAPIExampleAppUi::iServerAddress [private]
 

iUserID. Buffer for holding server address for login

Definition at line 212 of file IMOpenAPIExampleAppUi.h.

Referenced by HandleCommandL(), and LoginSettings().

TBuf<KMaxPasswordLength> CIMOpenAPIExampleAppUi::iPassword [private]
 

iPassword. Buffer for holding password for login

Definition at line 218 of file IMOpenAPIExampleAppUi.h.

Referenced by HandleCommandL(), and LoginSettings().

TUint32 CIMOpenAPIExampleAppUi::iAPNumber [private]
 

iAPNumber. Integer for holding access point for login

Definition at line 224 of file IMOpenAPIExampleAppUi.h.

Referenced by ConstructL(), HandleCommandL(), and SelectAccessPoint().

TBool CIMOpenAPIExampleAppUi::iLoginSettingsDone [private]
 

flag indicating, whether login settings are specified.

Definition at line 229 of file IMOpenAPIExampleAppUi.h.

Referenced by ConstructL(), DynInitMenuPaneL(), and LoginSettings().

RGenConAgentDialogServer CIMOpenAPIExampleAppUi::iDlgSrv [private]
 

iDlgSrv Dialog server for access point selection

Definition at line 235 of file IMOpenAPIExampleAppUi.h.

Referenced by SelectAccessPoint(), and ~CIMOpenAPIExampleAppUi().

TRequestStatus CIMOpenAPIExampleAppUi::iStatus [private]
 

iStatus Request status for requests made to RGenConAgentDialogServer

Definition at line 241 of file IMOpenAPIExampleAppUi.h.

Referenced by SelectAccessPoint().


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

© Nokia 2009

Back to top