|
Nokia N97 SDK 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 iLoginSettingsDone = EFalse; 00060 00061 iDisplayMessage.Copy(KNullDesC); 00062 } 00063 00064 // ---------------------------------------------------- 00065 // CIMOpenAPIExampleAppUi::~CIMOpenAPIExampleAppUi() 00066 // Destructor 00067 // Frees reserved resources 00068 // ---------------------------------------------------- 00069 // 00070 CIMOpenAPIExampleAppUi::~CIMOpenAPIExampleAppUi() 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 } 00086 00087 // ------------------------------------------------------------------------------ 00088 // CIMOpenAPIExampleAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) 00089 // This function is called by the EIKON framework just before it displays 00090 // a menu pane. Its default implementation is empty, and by overriding it, 00091 // the application can set the state of menu items dynamically according 00092 // to the state of application data. 00093 // ------------------------------------------------------------------------------ 00094 // 00095 void CIMOpenAPIExampleAppUi::DynInitMenuPaneL( 00096 TInt aResourceId,CEikMenuPane* aMenuPane) 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 } 00191 00192 // ---------------------------------------------------- 00193 // CIMOpenAPIExampleAppUi::HandleKeyEventL( 00194 // const TKeyEvent& aKeyEvent,TEventCode /*aType*/) 00195 // takes care of key event handling 00196 // ---------------------------------------------------- 00197 // 00198 TKeyResponse CIMOpenAPIExampleAppUi::HandleKeyEventL( 00199 const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/) 00200 { 00201 return EKeyWasNotConsumed; 00202 } 00203 00204 // ---------------------------------------------------- 00205 // CIMOpenAPIExampleAppUi::HandleCommandL(TInt aCommand) 00206 // takes care of command handling 00207 // ---------------------------------------------------- 00208 // 00209 void CIMOpenAPIExampleAppUi::HandleCommandL(TInt aCommand) 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 } 00301 00302 00303 // ---------------------------------------------------- 00304 // CIMOpenAPIExampleAppUi::HandleMessageErrorFromModel( const TInt aErrorCode, 00305 // const TDesC& aStringInfo) 00306 // Model calls this function for error messages 00307 // ---------------------------------------------------- 00308 // 00309 void CIMOpenAPIExampleAppUi::HandleMessageErrorFromModel( 00310 const TInt aErrorCode, 00311 const TDesC& aStringInfo ) 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 } 00331 00332 // ---------------------------------------------------- 00333 // CIMOpenAPIExampleAppUi::HandleChallengeRec(const TDesC& aUserID ) 00334 // Model calls this function when it receives a challenge 00335 // ---------------------------------------------------- 00336 // 00337 00338 void CIMOpenAPIExampleAppUi::HandleChallengeRec(const TDesC& aUserID ) 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 } 00362 00363 // ---------------------------------------------------- 00364 // CIMOpenAPIExampleAppUi::HandleMessageNewMsgFromModel(const TInternalMsgID aMsgID, 00365 // const TInt aIntegerInfo, 00366 // const TDesC& /*aStringInfo*/ ) 00367 // Handles messages from model, except challenge, connection and error messages 00368 // ---------------------------------------------------- 00369 // 00370 void CIMOpenAPIExampleAppUi::HandleMessageFromModel( 00371 const TInternalMsgID aMsgID, 00372 const TInt aIntegerInfo, 00373 const TDesC& /*aStringInfo*/ ) 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 } 00445 00446 // ---------------------------------------------------- 00447 // CIMOpenAPIExampleAppUi::HandleMessageIMConnectionFromModel( 00448 // const TInternalMsgID aMsgID, 00449 // const TInt aErrorCode) 00450 // Model calls this function for connection and disconnection 00451 // ---------------------------------------------------- 00452 // 00453 void CIMOpenAPIExampleAppUi::HandleMessageIMConnectionFromModel( 00454 const TInternalMsgID aMsgID, 00455 const TInt aErrorCode ) 00456 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 } 00495 00496 // ---------------------------------------------------- 00497 // CIMOpenAPIExampleDocument& CIMOpenAPIExampleAppUi::Document() const 00498 // Provides a pointer to document to be used by other functions 00499 // ---------------------------------------------------- 00500 // 00501 CIMOpenAPIExampleDocument& CIMOpenAPIExampleAppUi::Document() const 00502 { 00503 return *static_cast<CIMOpenAPIExampleDocument*>(CEikAppUi::Document()); 00504 } 00505 00506 00507 // ---------------------------------------------------- 00508 // CIMOpenAPIExampleAppUi::SetGameState(TGameState const aState) 00509 // Sets game status, actually to the container 00510 // ---------------------------------------------------- 00511 // 00512 void CIMOpenAPIExampleAppUi::SetGameState(TGameState const aState) 00513 { 00514 iAppContainer->SetGameView(aState); 00515 } 00516 00517 // ---------------------------------------------------- 00518 // CIMOpenAPIExampleAppUi::GetGameState() const 00519 // returns current Game state, it calls model for this 00520 // ---------------------------------------------------- 00521 // 00522 TGameState CIMOpenAPIExampleAppUi::GetGameState() const 00523 { 00524 return Document().Model().GetGameState(); 00525 } 00526 00527 // ---------------------------------------------------- 00528 // CIMOpenAPIExampleAppUi::DisplayInfoMessage(TInt aResourceID) 00529 // can display any info message to the user, by resource id 00530 // ---------------------------------------------------- 00531 // 00532 void CIMOpenAPIExampleAppUi::DisplayInfoMessage(TInt aResourceID) 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 } 00540 00541 // ---------------------------------------------------- 00542 // CIMOpenAPIExampleAppUi::Challenge() 00543 // Handles Challenge, generates a text input for writing opponent id 00544 // ---------------------------------------------------- 00545 // 00546 TBool CIMOpenAPIExampleAppUi::Challenge() 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 } 00563 00564 // ---------------------------------------------------- 00565 // CIMOpenAPIExampleAppUi::LoginSettings() 00566 // Display and accepts data from settings query dialogs 00567 // ---------------------------------------------------- 00568 // 00569 void CIMOpenAPIExampleAppUi::LoginSettings() 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 } 00606 00607 // ---------------------------------------------------- 00608 // CIMOpenAPIExampleAppUi::SelectAccessPoint() 00609 // Display an available access points selection list box 00610 // ---------------------------------------------------- 00611 // 00612 void CIMOpenAPIExampleAppUi::SelectAccessPoint() 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 } 00628 00629 // End of File 00630
|
© Nokia 2009 |