|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : IMOpenAPIExampleAppUi.cpp 00004 * Part of : IMOpenAPIExample 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 <eikmenub.h> 00018 #include <aknwaitdialog.h> 00019 #include <aknnotewrappers.h> 00020 #include <stringloader.h> 00021 #include <badesca.h> 00022 #include <imerrors.h> 00023 #include <aknquerydialog.h> 00024 #include <aknlistquerydialog.h> 00025 #include <akndialog.h> 00026 #include <avkon.hrh> 00027 #include <IMOpenAPIExample.rsg> 00028 00029 #include "IMOpenAPIExampleAppUi.h" 00030 #include "IMOpenAPIExampleContainer.h" 00031 #include "IMOpenAPIExampleDocument.h" 00032 #include "IMOpenAPIExamplemodel.h" 00033 #include "IMOpenAPIExample.hrh" 00034 #include "IMOpenAPIExampleGrid.h" 00035 00036 // ================= MEMBER FUNCTIONS ======================= 00037 // 00038 // ---------------------------------------------------------- 00039 // CIMOpenAPIExampleAppUi::ConstructL() 00040 // 00041 // ---------------------------------------------------------- 00042 // 00043 void CIMOpenAPIExampleAppUi::ConstructL() 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 00060 iDisplayMessage.Copy(KNullDesC); 00061 } 00062 00063 // ---------------------------------------------------- 00064 // CIMOpenAPIExampleAppUi::~CIMOpenAPIExampleAppUi() 00065 // Destructor 00066 // Frees reserved resources 00067 // ---------------------------------------------------- 00068 // 00069 CIMOpenAPIExampleAppUi::~CIMOpenAPIExampleAppUi() 00070 { 00071 if (iAppContainer) 00072 { 00073 RemoveFromStack( iAppContainer ); 00074 delete iAppContainer; 00075 } 00076 if (iWaitDialog) 00077 { 00078 delete iWaitDialog; 00079 iWaitDialog = NULL; 00080 } 00081 00082 iDlgSrv.Close(); 00083 00084 } 00085 00086 // ------------------------------------------------------------------------------ 00087 // CIMOpenAPIExampleAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) 00088 // This function is called by the EIKON framework just before it displays 00089 // a menu pane. Its default implementation is empty, and by overriding it, 00090 // the application can set the state of menu items dynamically according 00091 // to the state of application data. 00092 // ------------------------------------------------------------------------------ 00093 // 00094 void CIMOpenAPIExampleAppUi::DynInitMenuPaneL( 00095 TInt aResourceId,CEikMenuPane* aMenuPane) 00096 { 00097 // Here we select the game options menu according to game state 00098 switch (aResourceId) 00099 { 00100 case R_IMOPENAPIEXAMPLE_MENU: 00101 switch ( Document().Model().GetGameState() ) 00102 { 00103 case EStateNotLogin: 00104 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue); 00105 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue); 00106 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue); 00107 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, EFalse); 00108 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue); 00109 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue); 00110 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue); 00111 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, EFalse); 00112 break; 00113 00114 case EStateSending: 00115 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue); 00116 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue); 00117 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue); 00118 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue); 00119 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue); 00120 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue); 00121 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue); 00122 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue); 00123 break; 00124 00125 case EStateLoginIdle: 00126 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue); 00127 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue); 00128 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue); 00129 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, EFalse); 00130 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue); 00131 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue); 00132 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, EFalse); 00133 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue); 00134 break; 00135 00136 case EStateChallenged: 00137 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue); 00138 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue); 00139 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue); 00140 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue); 00141 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue); 00142 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, EFalse); 00143 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue); 00144 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue); 00145 break; 00146 00147 case EStateReadytoStart: 00148 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue); 00149 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue); 00150 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue); 00151 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, ETrue); 00152 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue); 00153 if (Document().Model().GetOppSign() == ECrossSign ) 00154 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue); 00155 else 00156 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, EFalse); 00157 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, EFalse); 00158 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue); 00159 break; 00160 00161 case EStateWaitingForOppMove: 00162 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue); 00163 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, ETrue); 00164 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue); 00165 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, EFalse); 00166 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue); 00167 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue); 00168 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue); 00169 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue); 00170 break; 00171 00172 case EStateWaitingForOwnMove: 00173 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogin, ETrue); 00174 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdChallenge, ETrue); 00175 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdSelect, EFalse); 00176 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdExitGame, EFalse); 00177 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdStartGame, ETrue); 00178 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdEndChallenge, ETrue); 00179 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdLogout, ETrue); 00180 aMenuPane->SetItemDimmed(EIMOpenAPIExampleCmdIMSettings, ETrue); 00181 break; 00182 00183 default: 00184 break; 00185 } // iState switch ends 00186 default: 00187 break; 00188 } // aResourceId switch ends 00189 } 00190 00191 // ---------------------------------------------------- 00192 // CIMOpenAPIExampleAppUi::HandleKeyEventL( 00193 // const TKeyEvent& aKeyEvent,TEventCode /*aType*/) 00194 // takes care of key event handling 00195 // ---------------------------------------------------- 00196 // 00197 TKeyResponse CIMOpenAPIExampleAppUi::HandleKeyEventL( 00198 const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/) 00199 { 00200 return EKeyWasNotConsumed; 00201 } 00202 00203 // ---------------------------------------------------- 00204 // CIMOpenAPIExampleAppUi::HandleCommandL(TInt aCommand) 00205 // takes care of command handling 00206 // ---------------------------------------------------- 00207 // 00208 void CIMOpenAPIExampleAppUi::HandleCommandL(TInt aCommand) 00209 { 00210 TInt err = KErrNone; 00211 _LIT(errString, "Error:( %i )"); 00212 TBuf<KMaxChallengeIDLength> OppnentID; 00213 TBuf<KMaxChallengeIDLength> OppnentI; 00214 00215 switch ( aCommand ) 00216 { 00217 case EAknSoftkeyBack: 00218 TRAP( err , Document().Model().PrepareToExit() ); 00219 Exit(); 00220 break; 00221 case EEikCmdExit: 00222 TRAP( err , Document().Model().PrepareToExit() ); 00223 Exit(); 00224 break; 00225 00226 case EIMOpenAPIExampleCmdLogin: 00227 TRAP(err ,Document().Model().LoginL(iServerAddress, iUserID, iPassword, iAPNumber)); 00228 if (err!=KErrNone) 00229 { 00230 break; 00231 } 00232 iWaitDialog = new(ELeave)CAknWaitDialog((REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), EFalse ); 00233 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_LOGGING ); 00234 iWaitDialog->SetTextL ( iDisplayMessage ); 00235 iWaitDialog->ExecuteDlgLD(CAknNoteDialog::ENoTone,R_SINGULAR_WAIT_NOTE); 00236 break; 00237 00238 case EIMOpenAPIExampleCmdLogout: 00239 TRAP(err ,Document().Model().LogoutL()); 00240 iWaitDialog = new(ELeave)CAknWaitDialog((REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), EFalse ); 00241 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_LOGGING_OUT ); 00242 iWaitDialog->SetTextL ( iDisplayMessage ); 00243 iWaitDialog->ExecuteDlgLD(CAknNoteDialog::ENoTone,R_SINGULAR_WAIT_NOTE); 00244 break; 00245 00246 case EIMOpenAPIExampleCmdIMSettings: 00247 LoginSettings(); 00248 break; 00249 00250 case EIMOpenAPIExampleCmdExitGame: 00251 TRAP(err ,Document().Model().SendExitGame()); 00252 break; 00253 00254 case EIMOpenAPIExampleCmdStartGame: 00255 TRAP(err ,Document().Model().SendStartGame()); 00256 break; 00257 00258 case EIMOpenAPIExampleCmdChallenge: 00259 if (Challenge()) 00260 { 00261 TRAP( err , Document().Model().SendChallenge() ); 00262 if(err!=KErrNone) 00263 break; 00264 iAppContainer->SetMySign(ECrossSign); 00265 } 00266 break; 00267 00268 case EIMOpenAPIExampleCmdEndChallenge: 00269 TRAP( err , Document().Model().SendEndChallenge() ); 00270 break; 00271 00272 case EIMOpenAPIExampleCmdSelect: 00273 iAppContainer->PlayMove(); 00274 break; 00275 00276 default: 00277 break; 00278 } 00279 00280 if (err != KErrNone ) 00281 { 00282 if(err==-5) 00283 { 00284 CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse ); 00285 note->SetTimeout( CAknNoteDialog::ELongTimeout ); 00286 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_NOT_SUPPORTED ); 00287 note->ExecuteLD( iDisplayMessage ); 00288 iDisplayMessage.Copy(KNullDesC); 00289 } 00290 else 00291 { 00292 CAknErrorNote* note = new(ELeave) CAknErrorNote(); 00293 TBuf<0x100> buf; 00294 buf.Format(errString, err ); 00295 note->ExecuteLD( buf ); 00296 } 00297 } 00298 iDisplayMessage.Copy(KNullDesC); 00299 } 00300 00301 00302 // ---------------------------------------------------- 00303 // CIMOpenAPIExampleAppUi::HandleMessageErrorFromModel( const TInt aErrorCode, 00304 // const TDesC& aStringInfo) 00305 // Model calls this function for error messages 00306 // ---------------------------------------------------- 00307 // 00308 void CIMOpenAPIExampleAppUi::HandleMessageErrorFromModel( 00309 const TInt aErrorCode, 00310 const TDesC& aStringInfo ) 00311 { 00312 CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse ); 00313 note->SetTimeout( CAknNoteDialog::ELongTimeout ); 00314 _LIT(errString, "in, %S with Error code: %d"); 00315 00316 switch (aErrorCode) 00317 { 00318 case KImApiErrNotLogged: 00319 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_NOT_LOGGEDIN ); 00320 break; 00321 00322 default: 00323 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_ERROR ); 00324 iDisplayMessage.AppendFormat(errString, &aStringInfo, aErrorCode); 00325 break; 00326 } 00327 note->ExecuteLD( iDisplayMessage ); 00328 iDisplayMessage.Copy(KNullDesC); 00329 } 00330 00331 // ---------------------------------------------------- 00332 // CIMOpenAPIExampleAppUi::HandleChallengeRec(const TDesC& aUserID ) 00333 // Model calls this function when it receives a challenge 00334 // ---------------------------------------------------- 00335 // 00336 00337 void CIMOpenAPIExampleAppUi::HandleChallengeRec(const TDesC& aUserID ) 00338 { 00339 TInt err = KErrNone; 00340 _LIT(errorString,"Error:( %i )"); 00341 CAknQueryDialog* query = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone); 00342 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_RECEIVED ); 00343 iDisplayMessage.Append(aUserID); 00344 if ( query->ExecuteLD( R_CHALLENGE_QUERY, iDisplayMessage ) ) 00345 { 00346 TRAP( err , Document().Model().SendChallengeAccepted() ); 00347 iAppContainer->SetMySign(EZeroSign); 00348 } 00349 else 00350 TRAP( err , Document().Model().SendChallengeRejected() ); 00351 00352 if (err != KErrNone ) 00353 { 00354 CAknErrorNote* note = new(ELeave) CAknErrorNote(); 00355 TBuf<0x100> buf; 00356 buf.Format(errorString, err ); 00357 note->ExecuteLD( buf ); 00358 } 00359 iDisplayMessage.Copy(KNullDesC); 00360 } 00361 00362 // ---------------------------------------------------- 00363 // CIMOpenAPIExampleAppUi::HandleMessageNewMsgFromModel(const TInternalMsgID aMsgID, 00364 // const TInt aIntegerInfo, 00365 // const TDesC& /*aStringInfo*/ ) 00366 // Handles messages from model, except challenge, connection and error messages 00367 // ---------------------------------------------------- 00368 // 00369 void CIMOpenAPIExampleAppUi::HandleMessageFromModel( 00370 const TInternalMsgID aMsgID, 00371 const TInt aIntegerInfo, 00372 const TDesC& /*aStringInfo*/ ) 00373 { 00374 CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse ); 00375 note->SetTimeout( CAknNoteDialog::ELongTimeout ); 00376 00377 switch (aMsgID) 00378 { 00379 case ChallengeSent: 00380 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_SENT ); 00381 break; 00382 00383 // handled by a seperate function 00384 case ChallengeRec: 00385 break; 00386 00387 case PlayedIndexRec: 00388 iAppContainer->SetCellSign(Document().Model().GetOppSign(), aIntegerInfo); 00389 break; 00390 00391 case StartGameRec: 00392 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_GAME_STARTED ); 00393 break; 00394 00395 00396 case EndGameRec: 00397 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_GAME_ENDED ); 00398 break; 00399 00400 00401 case ChallengeAcceptedRec: 00402 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_ACCEPTED ); 00403 break; 00404 00405 00406 case ChallengeRejectedRec: 00407 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_REJECTED ); 00408 break; 00409 00410 case AlreadyInGameRec: 00411 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_ALREADY_IN_GAME ); 00412 break; 00413 00414 case YouWon: 00415 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_YOU_WON ); 00416 break; 00417 00418 case YouLost: 00419 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_YOU_LOST ); 00420 break; 00421 00422 case GameDraw: 00423 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_GAME_DRAW ); 00424 break; 00425 00426 case StartGameWarning: 00427 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_START_GAME_WARNING ); 00428 break; 00429 00430 case EndChallengeRec: 00431 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_CHALLENGE_ENDED ); 00432 break; 00433 00434 default: 00435 break; 00436 } 00437 if ( iDisplayMessage.Compare(KNullDesC) != 0) 00438 note->ExecuteLD( iDisplayMessage ); 00439 else 00440 delete note; 00441 00442 iDisplayMessage.Copy(KNullDesC); 00443 } 00444 00445 // ---------------------------------------------------- 00446 // CIMOpenAPIExampleAppUi::HandleMessageIMConnectionFromModel( 00447 // const TInternalMsgID aMsgID, 00448 // const TInt aErrorCode) 00449 // Model calls this function for connection and disconnection 00450 // ---------------------------------------------------- 00451 // 00452 void CIMOpenAPIExampleAppUi::HandleMessageIMConnectionFromModel( 00453 const TInternalMsgID aMsgID, 00454 const TInt aErrorCode ) 00455 00456 { 00457 CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse ); 00458 note->SetTimeout( CAknNoteDialog::ELongTimeout ); 00459 00460 switch (aMsgID) 00461 { 00462 case Connected: 00463 iWaitDialog->ProcessFinishedL(); 00464 if (aErrorCode != KErrNone) 00465 { 00466 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_LOGIN_FAILED ); 00467 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_ERROR ); 00468 iDisplayMessage.AppendNum(aErrorCode); 00469 } 00470 else 00471 { 00472 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_LOGIN_SUCCESS ); 00473 } 00474 note->ExecuteLD( iDisplayMessage ); 00475 break; 00476 00477 case DisConnected: 00478 if (iWaitDialog) 00479 iWaitDialog->ProcessFinishedL(); 00480 StringLoader::Load ( iDisplayMessage, R_INFO_MSG_DISCONNECTED ); 00481 note->ExecuteLD( iDisplayMessage ); 00482 break; 00483 00484 default: 00485 break; 00486 } 00487 if(note) 00488 { 00489 delete note; 00490 note = NULL; 00491 } 00492 iDisplayMessage.Copy(KNullDesC); 00493 } 00494 00495 // ---------------------------------------------------- 00496 // CIMOpenAPIExampleDocument& CIMOpenAPIExampleAppUi::Document() const 00497 // Provides a pointer to document to be used by other functions 00498 // ---------------------------------------------------- 00499 // 00500 CIMOpenAPIExampleDocument& CIMOpenAPIExampleAppUi::Document() const 00501 { 00502 return *static_cast<CIMOpenAPIExampleDocument*>(CEikAppUi::Document()); 00503 } 00504 00505 00506 // ---------------------------------------------------- 00507 // CIMOpenAPIExampleAppUi::SetGameState(TGameState const aState) 00508 // Sets game status, actually to the container 00509 // ---------------------------------------------------- 00510 // 00511 void CIMOpenAPIExampleAppUi::SetGameState(TGameState const aState) 00512 { 00513 iAppContainer->SetGameView(aState); 00514 } 00515 00516 // ---------------------------------------------------- 00517 // CIMOpenAPIExampleAppUi::GetGameState() const 00518 // returns current Game state, it calls model for this 00519 // ---------------------------------------------------- 00520 // 00521 TGameState CIMOpenAPIExampleAppUi::GetGameState() const 00522 { 00523 return Document().Model().GetGameState(); 00524 } 00525 00526 // ---------------------------------------------------- 00527 // CIMOpenAPIExampleAppUi::DisplayInfoMessage(TInt aResourceID) 00528 // can display any info message to the user, by resource id 00529 // ---------------------------------------------------- 00530 // 00531 void CIMOpenAPIExampleAppUi::DisplayInfoMessage(TInt aResourceID) 00532 { 00533 CAknInformationNote* note = new (ELeave) CAknInformationNote( EFalse ); 00534 note->SetTimeout( CAknNoteDialog::ELongTimeout ); 00535 StringLoader::Load ( iDisplayMessage, aResourceID ); 00536 note->ExecuteLD( iDisplayMessage ); 00537 iDisplayMessage.Copy(KNullDesC); 00538 } 00539 00540 // ---------------------------------------------------- 00541 // CIMOpenAPIExampleAppUi::Challenge() 00542 // Handles Challenge, generates a text input for writing opponent id 00543 // ---------------------------------------------------- 00544 // 00545 TBool CIMOpenAPIExampleAppUi::Challenge() 00546 { 00547 TBuf<KMaxChallengeIDLength> oppnentID; 00548 CAknTextQueryDialog* OppIDQuery = CAknTextQueryDialog::NewL(oppnentID); 00549 CleanupStack::PushL(OppIDQuery); 00550 HBufC* prompt; 00551 prompt = StringLoader::LoadLC(R_INFO_MSG_OPP_ID_PROMPT);// Pushes prompt onto the Cleanup Stack. 00552 OppIDQuery->SetPromptL(*prompt); 00553 CleanupStack::PopAndDestroy(prompt); 00554 CleanupStack::Pop(OppIDQuery); 00555 if (OppIDQuery->ExecuteLD(R_DATA_QUERY)) 00556 { 00557 Document().Model().SetOppID(oppnentID); 00558 return ETrue; 00559 } 00560 return EFalse; 00561 } 00562 00563 // ---------------------------------------------------- 00564 // CIMOpenAPIExampleAppUi::LoginSettings() 00565 // Display and accepts data from settings query dialogs 00566 // ---------------------------------------------------- 00567 // 00568 void CIMOpenAPIExampleAppUi::LoginSettings() 00569 { 00570 HBufC* prompt; 00571 00572 // For User ID 00573 CAknTextQueryDialog* userIDQuery = CAknTextQueryDialog::NewL(iUserID); 00574 CleanupStack::PushL(userIDQuery); 00575 prompt = StringLoader::LoadLC(R_INFO_MSG_USER_ID);// Pushes prompt to Cleanup Stack. 00576 userIDQuery->SetPromptL(*prompt); 00577 CleanupStack::PopAndDestroy(prompt); 00578 CleanupStack::Pop(userIDQuery); 00579 if (!(userIDQuery->ExecuteLD(R_USER_ID_QUERY))) 00580 return; // return if user cancels 00581 00582 //For Password 00583 CAknTextQueryDialog* passwordQuery = CAknTextQueryDialog::NewL(iPassword); 00584 CleanupStack::PushL(passwordQuery); 00585 prompt = StringLoader::LoadLC(R_INFO_MSG_PASSWORD);// Pushes prompt to Cleanup Stack. 00586 passwordQuery->SetPromptL(*prompt); 00587 CleanupStack::PopAndDestroy(prompt); 00588 CleanupStack::Pop(passwordQuery); 00589 if(!(passwordQuery->ExecuteLD(R_PASSWORD_QUERY))) 00590 return; // return if user cancels 00591 00592 //For Server Address 00593 CAknTextQueryDialog* serverAddressQuery = CAknTextQueryDialog::NewL(iServerAddress); 00594 CleanupStack::PushL(serverAddressQuery); 00595 prompt = StringLoader::LoadLC(R_INFO_MSG_SERVER_ADDRESS);// Pushes prompt to Cleanup Stack. 00596 serverAddressQuery->SetPromptL(*prompt); 00597 CleanupStack::PopAndDestroy(prompt); 00598 CleanupStack::Pop(serverAddressQuery); 00599 if(!(serverAddressQuery->ExecuteLD(R_SERVER_ADDRESS_QUERY))) 00600 return; // return if user cancels 00601 00602 SelectAccessPoint(); 00603 } 00604 00605 // ---------------------------------------------------- 00606 // CIMOpenAPIExampleAppUi::SelectAccessPoint() 00607 // Display an available access points selection list box 00608 // ---------------------------------------------------- 00609 // 00610 void CIMOpenAPIExampleAppUi::SelectAccessPoint() 00611 { 00612 TConnectionPrefs prefs; 00613 00614 iDlgSrv.Connect(); 00615 00616 prefs.iRank = 1; 00617 prefs.iDirection = ECommDbConnectionDirectionOutgoing; 00618 prefs.iBearerSet = ECommDbBearerCSD | ECommDbBearerWcdma | ECommDbBearerVirtual; 00619 00620 TRAPD( err, iDlgSrv.IapConnection( iAPNumber, prefs, iStatus ) ); 00621 User::LeaveIfError( err ); 00622 00623 User::WaitForRequest( iStatus ); 00624 iDlgSrv.Close(); 00625 } 00626 00627 // End of File 00628
|
© Nokia 2006 |