|
Nokia N97 SDK Example Applications Guide |
#include <IMOpenAPIExampleModel.h>
Inheritance diagram for CIMOpenAPIExamplemodel:

Definition at line 44 of file IMOpenAPIExampleModel.h.
Public Member Functions |
|
| void | HandleLoginL (const TInt aErrorCode) |
| void | HandleCancelLoginL (const TInt aErrorCode) |
| void | HandleLogoutL (const TInt aErrorCode) |
| void | HandleMessageSentL (const TInt aOpCode, const TInt aErrorCode) |
| void | HandleSendErrorL (const TInt aOpCode, const TInt aErrorCode, MImClientDetailedError *aDetailedError) |
| void | HandleNewPToPMessageL (const TInt aErrorCode, const TContactItemId aContactId, const TDesC &aUserId, const TDesC &aMessageType, const TDesC8 &aContent) |
| void | HandleNewPToPMessageL (const TInt aErrorCode, const TContactItemId aContactId, const TDesC &aUserId, const TDesC &aMessageType, const TDesC16 &aContent) |
| void | LoginL (const TDesC &aServerAddress, const TDesC &aUserId, const TDesC &aPassword, const TInt aAccessPoint) |
| void | LogoutL () |
| void | SendChallenge () |
| void | SendChallengeAccepted () |
| void | SendChallengeRejected () |
| void | SendAlreadyInGame () |
| void | SendStartGame () |
| void | SendExitGame () |
| void | SendPlayedIndex (TInt aIndex) |
| void | SendEndChallenge () |
| void | SetOppID (const TDesC16 &aOppID) |
| ~CIMOpenAPIExamplemodel () | |
| TGameState | GetGameState () const |
| void | SetGameState (TGameState const aState) |
| TGameSign | GetOppSign () const |
| TBool | IsIndexPositionEmpty (TInt aIndex) |
| void | PrepareToExit () |
Static Public Member Functions |
|
| static CIMOpenAPIExamplemodel * | NewLC (CIMOpenAPIExampleDocument *aDocument) |
| static CIMOpenAPIExamplemodel * | NewL (CIMOpenAPIExampleDocument *aDocument) |
Private Member Functions |
|
| CIMOpenAPIExamplemodel () | |
| void | ConstructL (CIMOpenAPIExampleDocument *aDocument) |
| TBool | CheckForSeries (TGameSign aValue, TInt aStartIndex, TInt aIndexIncrement) |
| TBool | MatchOppID (TDesC16 &aOppID) |
| TInt | SendMsg (TDesC16 &aContent) |
| void | ResetGameData () |
| TBool | IsGameFinnished (TBool &aIsDraw) |
| TBool | IsGameDraw () |
Private Attributes |
|
| CImConnection * | iIMConnection |
| MImClient * | iIMClient |
| CIMOpenAPIExampleDocument * | iDocument |
| TFixedArray< TGameSign, 9 > | iGameData |
| TGameState | iState |
| TInt | iMsgID |
| CDesC16Array * | iArrayOfIDs |
| HBufC * | iOppID |
| TBool | iSending |
| TMsg | iLastMsg |
| TGameSign | iMySign |
| TGameSign | iOppSign |
| TBuf< KMaxProtocolStrLength > | iMessageToSend |
| TInt64 | iSeed |
| TBool | iNotSupported |
|
|
~CIMOpenAPIExamplemodel. Destructor Definition at line 100 of file IMOpenAPIExampleModel.cpp. References iIMClient. 00101 { 00102 if( iIMClient ) 00103 { 00104 iIMClient->UnregisterObserver(); 00105 delete iIMClient; 00106 iIMClient = NULL; 00107 } 00108 00109 if (iIMConnection) 00110 { 00111 iIMConnection->UnregisterObserver(); 00112 delete iIMConnection; 00113 iIMConnection = NULL; 00114 } 00115 00116 if(iOppID) 00117 delete iOppID; 00118 iOppID = NULL; 00119 00120 if (iArrayOfIDs) 00121 { 00122 iArrayOfIDs->Reset(); 00123 delete iArrayOfIDs; 00124 } 00125 }
|
|
|
CIMOpenAPIExamplemodel. C++ constructor Definition at line 133 of file IMOpenAPIExampleModel.cpp.
|
|
|
HandleLoginL. From MImConnectionObserver Definition at line 143 of file IMOpenAPIExampleModel.cpp. References CIMOpenAPIExampleAppUi::HandleMessageIMConnectionFromModel(), iDocument, SetGameState(), and CIMOpenAPIExampleDocument::UI(). 00144 { 00145 iDocument->UI()->HandleMessageIMConnectionFromModel(Connected, aErrorCode); 00146 if (aErrorCode == KErrNone) 00147 { 00148 SetGameState(EStateLoginIdle); 00149 } 00150 }
|
|
|
HandleCancelLoginL. From MImConnectionObserver Definition at line 168 of file IMOpenAPIExampleModel.cpp.
|
|
|
HandleLogoutL. From MImConnectionObserver Definition at line 157 of file IMOpenAPIExampleModel.cpp. References CIMOpenAPIExampleAppUi::HandleMessageIMConnectionFromModel(), iDocument, SetGameState(), and CIMOpenAPIExampleDocument::UI(). 00158 { 00159 iDocument->UI()->HandleMessageIMConnectionFromModel(DisConnected, aErrorCode); 00160 SetGameState(EStateNotLogin); 00161 }
|
|
||||||||||||
|
HandleMessageSentL. From MImObserver Definition at line 179 of file IMOpenAPIExampleModel.cpp. References GetGameState(), CIMOpenAPIExampleAppUi::HandleMessageFromModel(), iDocument, iLastMsg, iSending, SetGameState(), and CIMOpenAPIExampleDocument::UI(). 00180 { 00181 iSending = EFalse; 00182 switch (iLastMsg) 00183 { 00184 case MsgChallenge: 00185 SetGameState(EStateChallenged); 00186 iDocument->UI()->HandleMessageFromModel(ChallengeSent, aErrorCode, KNullDesC); 00187 break; 00188 00189 case MsgChallengeAccepted: 00190 SetGameState(EStateReadytoStart); 00191 break; 00192 00193 case MsgChallengeRejected: 00194 SetGameState(EStateLoginIdle); 00195 break; 00196 00197 case MsgStartGameYourTurn: 00198 if (GetGameState() == EStateReadytoStart) 00199 SetGameState(EStateWaitingForOppMove); 00200 break; 00201 00202 case MsgStartGameOppTurn: 00203 if (GetGameState() == EStateReadytoStart) 00204 SetGameState(EStateWaitingForOwnMove); 00205 break; 00206 00207 case MsgExitGame: 00208 iDocument->UI()->HandleMessageFromModel(EndGameRec, aErrorCode, KNullDesC); 00209 SetGameState(EStateReadytoStart); 00210 break; 00211 00212 case MsgPlayedIndex: 00213 break; 00214 00215 case MsgEndChallenge: 00216 iDocument->UI()->HandleMessageFromModel(EndChallengeRec, aErrorCode, KNullDesC); 00217 SetGameState(EStateLoginIdle); 00218 break; 00219 00220 case MsgAlreadyInGame: 00221 break; 00222 00223 default: 00224 break; 00225 } 00226 }
|
|
||||||||||||||||
|
HandleSendErrorL. From MImObserver Definition at line 233 of file IMOpenAPIExampleModel.cpp. References CIMOpenAPIExampleAppUi::HandleMessageErrorFromModel(), iDocument, iSending, SetGameState(), and CIMOpenAPIExampleDocument::UI(). 00236 { 00237 iSending = EFalse; 00238 00239 00240 switch (aErrorCode) 00241 { 00242 case KImApiErrNotLogged: 00243 SetGameState(EStateNotLogin); 00244 iDocument->UI()->HandleMessageErrorFromModel(aErrorCode,KNullDesC ); 00245 break; 00246 00247 default: 00248 iDocument->UI()->HandleMessageErrorFromModel(aErrorCode,KNullDesC ); 00249 break; 00250 } 00251 }
|
|
||||||||||||||||||||||||
|
HandleNewPToPMessageL. From MImObserver Definition at line 404 of file IMOpenAPIExampleModel.cpp.
|
|
||||||||||||||||||||||||
|
HandleNewPToPMessageL. From MImObserver Definition at line 259 of file IMOpenAPIExampleModel.cpp. References CIMOpenAPIExampleAppUi::HandleChallengeRec(), CIMOpenAPIExampleAppUi::HandleMessageFromModel(), iDocument, iOppID, iState, SetGameState(), SetOppID(), and CIMOpenAPIExampleDocument::UI(). 00265 { 00266 TInt integerInfo = 0; 00267 TLex16 receivedMsgLex; 00268 TPtrC16 receivedMsg; 00269 TBool isDraw = EFalse; 00270 00271 00272 // checking for played index, which is different from other messages 00273 if (aContent.Find(KPlayedIndex) != KErrNotFound) 00274 { 00275 receivedMsgLex.Assign(aContent.Right(1)); 00276 receivedMsgLex.Val(integerInfo); 00277 receivedMsg.Set( aContent.Left(11) ); 00278 } 00279 else 00280 receivedMsg.Set(aContent); 00281 00282 switch (iState) 00283 { 00284 // In login idle state we only expect a Challenge from any other user 00285 case EStateLoginIdle: 00286 if ( receivedMsg.Compare(KChallenge) == 0) 00287 { 00288 SetOppID(aUserId); 00289 iDocument->UI()->HandleChallengeRec(aUserId); 00290 } 00291 break; 00292 00293 // In Challenged state we only expects challenge accepted or rejected from our opp 00294 case EStateChallenged: 00295 if( aUserId.Find(*iOppID) == KErrNotFound ) 00296 break; 00297 else if ( receivedMsg.Compare(KChallengeAccepted) == 0) 00298 { 00299 SetGameState(EStateReadytoStart); 00300 iDocument->UI()->HandleMessageFromModel(ChallengeAcceptedRec, aErrorCode, aContent); 00301 } 00302 else if ( receivedMsg.Compare(KChallengeRejected) == 0) 00303 { 00304 SetGameState(EStateLoginIdle); 00305 iDocument->UI()->HandleMessageFromModel(ChallengeRejectedRec, aErrorCode, aContent); 00306 } 00307 else if ( receivedMsg.Compare(KAlreadyInGame) == 0) 00308 { 00309 SetGameState(EStateLoginIdle); 00310 iDocument->UI()->HandleMessageFromModel(AlreadyInGameRec, aErrorCode, aContent); 00311 } 00312 // if opp also sent the challenge at the same time, we will reply already in game 00313 else if ( receivedMsg.Compare(KChallenge) == 0) 00314 { 00315 SetGameState(EStateLoginIdle); 00316 iDocument->UI()->HandleMessageFromModel(AlreadyInGameRec, aErrorCode, aContent); 00317 } 00318 // in all othe requests we will not take any action 00319 break; 00320 00321 00322 case EStateReadytoStart: 00323 if( aUserId.Find(*iOppID) == KErrNotFound ) 00324 break; 00325 else if ( receivedMsg.Compare(KStartGameYourTurn) == 0) 00326 { 00327 SetGameState(EStateWaitingForOwnMove); 00328 iDocument->UI()->HandleMessageFromModel(StartGameRec, aErrorCode, aContent); 00329 } 00330 else if ( receivedMsg.Compare(KStartGameOppTurn) == 0) 00331 { 00332 SetGameState(EStateWaitingForOppMove); 00333 iDocument->UI()->HandleMessageFromModel(StartGameRec, aErrorCode, aContent); 00334 } 00335 else if ( receivedMsg.Compare(KExitGame) == 0) 00336 { 00337 iDocument->UI()->HandleMessageFromModel(EndGameRec, aErrorCode, aContent); 00338 SetGameState(EStateReadytoStart); 00339 } 00340 else if ( receivedMsg.Compare(KEndChallenge) == 0) 00341 { 00342 iDocument->UI()->HandleMessageFromModel(EndChallengeRec, aErrorCode, KNullDesC); 00343 SetGameState(EStateLoginIdle); 00344 } 00345 else 00346 SendEndChallenge(); 00347 break; 00348 00349 00350 case EStateWaitingForOppMove: 00351 if( aUserId.Find(*iOppID) == KErrNotFound ) 00352 break; 00353 else if ( receivedMsg.Compare(KPlayedIndex) == 0) 00354 { 00355 iDocument->UI()->HandleMessageFromModel(PlayedIndexRec, integerInfo, aContent); 00356 iGameData.At(integerInfo) = iOppSign; 00357 if ( IsGameFinnished(isDraw) ) 00358 { 00359 if (isDraw) 00360 iDocument->UI()->HandleMessageFromModel(GameDraw, aErrorCode, aContent); 00361 else 00362 iDocument->UI()->HandleMessageFromModel(YouLost, aErrorCode, aContent); 00363 ResetGameData(); 00364 SetGameState(EStateReadytoStart); 00365 break; 00366 } 00367 SetGameState(EStateWaitingForOwnMove); 00368 } 00369 else if ( receivedMsg.Compare(KExitGame) == 0) 00370 { 00371 iDocument->UI()->HandleMessageFromModel(EndGameRec, aErrorCode, aContent); 00372 SetGameState(EStateReadytoStart); 00373 } 00374 else 00375 SendEndChallenge(); 00376 break; 00377 00378 00379 case EStateWaitingForOwnMove: 00380 if( aUserId.Find(*iOppID) == KErrNotFound ) 00381 break; 00382 if ( receivedMsg.Compare(KExitGame) == 0) 00383 { 00384 iDocument->UI()->HandleMessageFromModel(EndGameRec, aErrorCode, aContent); 00385 SetGameState(EStateReadytoStart); 00386 } 00387 else 00388 SendEndChallenge(); 00389 break; 00390 00391 00392 default: 00393 break; 00394 00395 } 00396 00397 }
|
|
||||||||||||||||||||
|
LoginL. Login request to IM server. This method is Asynchronous. called from UI
Definition at line 418 of file IMOpenAPIExampleModel.cpp. References iIMConnection, and iNotSupported. 00420 { 00421 // We are using TRAPD at the UI level, because it has GUI to display 00422 if (iNotSupported) 00423 User::Leave(KErrNotSupported); 00424 iIMConnection->LoginL(aServerAddress, aUserId, aPassword, aAccessPoint); 00425 }
|
|
|
LogoutL. Logout request from IM server. Called from UI Definition at line 432 of file IMOpenAPIExampleModel.cpp. References iIMConnection. 00433 { 00434 // We are using TRAPD at the UI level, because it has GUI to display 00435 iIMConnection->LogoutL(); 00436 }
|
|
|
SendChallenge. Send the challenge to the oponent. Called from UI Definition at line 454 of file IMOpenAPIExampleModel.cpp. References iLastMsg, iMessageToSend, iMsgID, iMySign, iOppSign, and SendMsg(). 00455 { 00456 iMessageToSend.Copy(KChallenge); 00457 iMsgID = SendMsg(iMessageToSend); 00458 iLastMsg = MsgChallenge; 00459 iMySign = ECrossSign; 00460 iOppSign = EZeroSign; 00461 }
|
|
|
SendChallengeAccepted. Send that the challenge has been accepted by the UI. Called from UI Definition at line 467 of file IMOpenAPIExampleModel.cpp. References iLastMsg, iMessageToSend, iMsgID, iMySign, iOppSign, and SendMsg(). 00468 { 00469 iMessageToSend.Copy(KChallengeAccepted); 00470 iMsgID = SendMsg(iMessageToSend); 00471 iLastMsg = MsgChallengeAccepted; 00472 iMySign = EZeroSign; 00473 iOppSign = ECrossSign; 00474 }
|
|
|
SendChallengeRejected. Send that the challenge has been rejected by the UI. Called from UI Definition at line 480 of file IMOpenAPIExampleModel.cpp. References iLastMsg, iMessageToSend, iMsgID, SendMsg(), and SetOppID(). 00481 { 00482 iMessageToSend.Copy(KChallengeRejected); 00483 iMsgID = SendMsg(iMessageToSend); 00484 iLastMsg = MsgChallengeRejected; 00485 SetOppID(KNullDesC); 00486 }
|
|
|
SendAlreadyInGame. Send that user is already in a game so he/she cant accept messages from users other than opponent. Definition at line 492 of file IMOpenAPIExampleModel.cpp. References iLastMsg, iMessageToSend, iMsgID, and SendMsg(). 00493 { 00494 iMessageToSend.Copy(KAlreadyInGame); 00495 iMsgID = SendMsg(iMessageToSend); 00496 iLastMsg = MsgAlreadyInGame; 00497 }
|
|
|
SendStartGame. Send to the opponent that user has started the game. Definition at line 503 of file IMOpenAPIExampleModel.cpp. References iLastMsg, iMessageToSend, iMsgID, iSeed, and SendMsg(). 00504 { 00505 TBool turn; 00506 00507 // Find a randomize turn 00508 turn = ( Math::Rand(iSeed) ) % 2; 00509 00510 if (turn) 00511 { 00512 iMessageToSend.Copy(KStartGameOppTurn); 00513 iMsgID = SendMsg(iMessageToSend); 00514 iLastMsg = MsgStartGameOppTurn; 00515 } 00516 else 00517 { 00518 iMessageToSend.Copy(KStartGameYourTurn); 00519 iMsgID = SendMsg(iMessageToSend); 00520 iLastMsg = MsgStartGameYourTurn; 00521 } 00522 }
|
|
|
SendExitGame. Send to the opponent that user has exited the game. Definition at line 528 of file IMOpenAPIExampleModel.cpp. References iLastMsg, iMessageToSend, iMsgID, and SendMsg(). 00529 { 00530 iMessageToSend.Copy(KExitGame); 00531 iMsgID = SendMsg(iMessageToSend); 00532 iLastMsg = MsgExitGame; 00533 }
|
|
|
SendPlayedIndex. Send to the opponent that user has played on this index in the game matrix, so that opponent mark that position
Definition at line 539 of file IMOpenAPIExampleModel.cpp. References CIMOpenAPIExampleAppUi::HandleMessageFromModel(), iDocument, iGameData, iLastMsg, iMessageToSend, iMsgID, iMySign, IsGameFinnished(), ResetGameData(), SendMsg(), SetGameState(), and CIMOpenAPIExampleDocument::UI(). Referenced by CIMOpenAPIExampleContainer::PlayMove(). 00540 { 00541 TBool isDraw = EFalse; 00542 00543 iMessageToSend.Copy(KPlayedIndex); 00544 iMessageToSend.AppendNumUC(aIndex,EDecimal); 00545 iMsgID = SendMsg(iMessageToSend); 00546 iLastMsg = MsgPlayedIndex; 00547 00548 iGameData.At(aIndex) = iMySign; 00549 if ( IsGameFinnished(isDraw) ) 00550 { 00551 if (isDraw) 00552 iDocument->UI()->HandleMessageFromModel(GameDraw, KErrNone, KNullDesC); 00553 else 00554 iDocument->UI()->HandleMessageFromModel(YouWon, KErrNone, KNullDesC); 00555 ResetGameData(); 00556 SetGameState(EStateReadytoStart); 00557 return; 00558 } 00559 SetGameState(EStateWaitingForOppMove); 00560 }
|
|
|
SendEndChallenge. Send to the opponent that user has ended the challenge. This means that user is now free to play with any other users Definition at line 566 of file IMOpenAPIExampleModel.cpp. References iLastMsg, iMessageToSend, iMsgID, and SendMsg(). Referenced by PrepareToExit(). 00567 { 00568 iMessageToSend.Copy(KEndChallenge); 00569 iMsgID = SendMsg(iMessageToSend); 00570 iLastMsg = MsgEndChallenge; 00571 }
|
|
|
SetOppID. Set the opponent's user's id locally
Definition at line 666 of file IMOpenAPIExampleModel.cpp. References iOppID. Referenced by CIMOpenAPIExampleAppUi::Challenge(), ConstructL(), HandleNewPToPMessageL(), SendChallengeRejected(), and SetGameState(). 00667 { 00668 TBuf<KMaxUserIDLength> oppID(aOppID); 00669 oppID.LowerCase(); 00670 delete iOppID; 00671 iOppID = NULL; 00672 iOppID = oppID.AllocL(); 00673 iArrayOfIDs->Reset(); 00674 iArrayOfIDs->AppendL(*iOppID); 00675 }
|
|
|
NewLC. Factory method for creating the class instance
Definition at line 74 of file IMOpenAPIExampleModel.cpp. References ConstructL(). Referenced by NewL(). 00075 { 00076 CIMOpenAPIExamplemodel* self = new (ELeave) CIMOpenAPIExamplemodel; 00077 CleanupStack::PushL(self); 00078 self->ConstructL(aDocument); 00079 return self; 00080 }
|
|
|
NewL. Factory method for creating the class instance
Definition at line 87 of file IMOpenAPIExampleModel.cpp. References NewLC(). Referenced by CIMOpenAPIExampleDocument::ConstructL(). 00088 { 00089 CIMOpenAPIExamplemodel* self = NewLC(aDocument); 00090 CleanupStack::Pop(self); 00091 return self; 00092 }
|
|
|
GetGameState. Get current game state from model.
Definition at line 639 of file IMOpenAPIExampleModel.cpp. References iSending, and iState. Referenced by CIMOpenAPIExampleAppUi::GetGameState(), and HandleMessageSentL().
|
|
|
SetGameState. Set current game state
Definition at line 651 of file IMOpenAPIExampleModel.cpp. References iDocument, iState, ResetGameData(), CIMOpenAPIExampleAppUi::SetGameState(), SetOppID(), and CIMOpenAPIExampleDocument::UI(). Referenced by HandleLoginL(), HandleLogoutL(), HandleMessageSentL(), HandleNewPToPMessageL(), HandleSendErrorL(), and SendPlayedIndex(). 00652 { 00653 iState = aState; 00654 iDocument->UI()->SetGameState(aState); 00655 if (iState == EStateReadytoStart) 00656 ResetGameData(); 00657 else if (iState == EStateLoginIdle) 00658 SetOppID(KNullDesC); 00659 }
|
|
|
GetOppSign. Get opponent's sign
Definition at line 694 of file IMOpenAPIExampleModel.cpp. References iOppSign. 00695 { 00696 return iOppSign; 00697 }
|
|
|
IsIndexPositionEmpty. Find whether a position on game's grid is empty
Definition at line 713 of file IMOpenAPIExampleModel.cpp. References iGameData. Referenced by CIMOpenAPIExampleContainer::PlayMove(). 00714 { 00715 if ( iGameData.At(aIndex) == EEmptySign ) 00716 return ETrue; 00717 return EFalse; 00718 }
|
|
|
PrepareToExit. Close connections and prepare to exit application Definition at line 724 of file IMOpenAPIExampleModel.cpp. References iState, and SendEndChallenge(). 00725 { 00726 if ( (iState != EStateNotLogin) && (iState != EStateLoginIdle) ) 00727 SendEndChallenge(); 00728 }
|
|
|
ConstructL. 2nd phase constructor
Definition at line 34 of file IMOpenAPIExampleModel.cpp. References iArrayOfIDs, iDocument, iIMClient, iIMConnection, iLastMsg, iMsgID, iNotSupported, iSending, iState, ResetGameData(), and SetOppID(). Referenced by NewLC(). 00035 { 00036 TRAPD(err,iIMConnection = CImConnection::NewL(KNullDesC)); 00037 if (err!=KErrNone) 00038 { 00039 iNotSupported = ETrue; 00040 iState = EStateNotLogin; 00041 } 00042 else 00043 { 00044 iIMConnection->RegisterObserverL(this); // registering the connection 00045 iIMClient = iIMConnection->CreateImClientL();// creating the client 00046 iIMClient->RegisterObserverL(this); // registering the client 00047 00048 // Check the IM status and set the application accordingly 00049 if (iIMConnection->ImConnectionStatus() == ELoggedIn) 00050 iState = EStateLoginIdle; 00051 else 00052 00053 iNotSupported=EFalse; 00054 } 00055 00056 iDocument = aDocument; 00057 ResetGameData(); // reset game data grid 00058 00059 00060 iArrayOfIDs = new (ELeave) CDesCArrayFlat(1); 00061 00062 // msg sent ids are zero in the begining 00063 iMsgID = 0; 00064 iSending = EFalse; 00065 iLastMsg = MsgEndChallenge; 00066 SetOppID(KNullDesC); 00067 }
|
|
||||||||||||||||
|
CheckForSeries. Check for a series of 3 consective values on the grid. The functions checks whether the three positions starting from an starting index and increased by given increament has the same values.
Definition at line 626 of file IMOpenAPIExampleModel.cpp. References iGameData. Referenced by IsGameFinnished(). 00627 { 00628 return ( (iGameData.At(aStartIndex) == aValue) && 00629 (iGameData.At(aStartIndex+aIndexIncrement) == aValue) && 00630 (iGameData.At(aStartIndex+aIndexIncrement+aIndexIncrement) == aValue) ); 00631 00632 }
|
|
|
MatchOppID. Match whether the given id is same as opponent's id, Each message goes through this check in a game.
Definition at line 682 of file IMOpenAPIExampleModel.cpp. References iOppID. 00683 { 00684 if ( iOppID->Compare(aOppID) == 0 ) 00685 return ETrue; 00686 return EFalse; 00687 }
|
|
|
SendMsg. Send given message
Definition at line 443 of file IMOpenAPIExampleModel.cpp. References iIMClient, and iSending. Referenced by SendAlreadyInGame(), SendChallenge(), SendChallengeAccepted(), SendChallengeRejected(), SendEndChallenge(), SendExitGame(), SendPlayedIndex(), and SendStartGame(). 00444 { 00445 iSending = ETrue; 00446 //SetGameState (EStateSending); 00447 return iIMClient->SendPToPMessageL(*iArrayOfIDs, aContent); 00448 }
|
|
|
ResetGameData. Resets all game data, usually done before starting a game Definition at line 703 of file IMOpenAPIExampleModel.cpp. References iGameData. Referenced by ConstructL(), SendPlayedIndex(), and SetGameState(). 00704 { 00705 for (TInt8 i=0; i<9; i++) // set all game matrix data to 'empty' 00706 iGameData.At(i) = EEmptySign; 00707 }
|
|
|
IsGameFinnished. Find whether the game is finnished.
Definition at line 576 of file IMOpenAPIExampleModel.cpp. References CheckForSeries(), and IsGameDraw(). Referenced by SendPlayedIndex(). 00577 { 00578 // checking for sign ECrossSign (*) win in the matrix 00579 if ( CheckForSeries(ECrossSign,ECrossSign,EZeroSign) || CheckForSeries(ECrossSign,3,EZeroSign) || 00580 CheckForSeries(ECrossSign,6,EZeroSign) || CheckForSeries(ECrossSign,ECrossSign,3) || 00581 CheckForSeries(ECrossSign,EZeroSign,3) || CheckForSeries(ECrossSign,EEmptySign,3) || 00582 CheckForSeries(ECrossSign,ECrossSign,4) || CheckForSeries(ECrossSign,EEmptySign,EEmptySign) ) 00583 { 00584 aIsDraw = EFalse; 00585 return ETrue; 00586 } 00587 00588 // checking for sign EZeroSign (o) win in the matrix 00589 else if ( CheckForSeries(EZeroSign,ECrossSign,EZeroSign) || CheckForSeries(EZeroSign,3,EZeroSign) || CheckForSeries(EZeroSign,6,EZeroSign) || 00590 CheckForSeries(EZeroSign,ECrossSign,3) || CheckForSeries(EZeroSign,EZeroSign,3) || CheckForSeries(EZeroSign,EEmptySign,3) || 00591 CheckForSeries(EZeroSign,ECrossSign,4) || CheckForSeries(EZeroSign,EEmptySign,EEmptySign) ) 00592 { 00593 aIsDraw = EFalse; 00594 return ETrue; 00595 } 00596 00597 else if (IsGameDraw()) 00598 { 00599 aIsDraw = ETrue; 00600 return ETrue; 00601 } 00602 00603 return EFalse; 00604 }
|
|
|
IsGameDraw. Find whether the game has draw.
Definition at line 611 of file IMOpenAPIExampleModel.cpp. References iGameData. Referenced by IsGameFinnished(). 00612 { 00613 for (TInt i=0;i<9;i++) 00614 { 00615 if (iGameData.At(i) == EEmptySign) 00616 return false; 00617 } 00618 return true; 00619 }
|
|
|
iIMConnection. Pointer to CImConnection. Used for IM connection handling Definition at line 311 of file IMOpenAPIExampleModel.h. Referenced by ConstructL(), LoginL(), and LogoutL(). |
|
|
iIMClient. Pointer to MImClient. Used for IM communication Definition at line 317 of file IMOpenAPIExampleModel.h. Referenced by ConstructL(), SendMsg(), and ~CIMOpenAPIExamplemodel(). |
|
|
iDocument. A local copy to the document pointer Definition at line 323 of file IMOpenAPIExampleModel.h. Referenced by ConstructL(), HandleLoginL(), HandleLogoutL(), HandleMessageSentL(), HandleNewPToPMessageL(), HandleSendErrorL(), SendPlayedIndex(), and SetGameState(). |
|
|
iGameData. This is a 9 member array, represents game data during a game. It can have three posible values. 0, 1 and -1. 0 is equivalent to circle sign, 1 is to cross and -1 represents an empty location in game grid Definition at line 331 of file IMOpenAPIExampleModel.h. Referenced by CheckForSeries(), IsGameDraw(), IsIndexPositionEmpty(), ResetGameData(), and SendPlayedIndex(). |
|
|
iState. This is Game state, all othe classes will get the game state from here. The TGameState is defined in IMOpenAPIExamplemsg.h Definition at line 338 of file IMOpenAPIExampleModel.h. Referenced by ConstructL(), GetGameState(), HandleNewPToPMessageL(), PrepareToExit(), and SetGameState(). |
|
|
iMsgID. This is last sent message id Definition at line 344 of file IMOpenAPIExampleModel.h. Referenced by ConstructL(), SendAlreadyInGame(), SendChallenge(), SendChallengeAccepted(), SendChallengeRejected(), SendEndChallenge(), SendExitGame(), SendPlayedIndex(), and SendStartGame(). |
|
|
iArrayOfIDs. Array of oponent ids, to match with returning messages Definition at line 350 of file IMOpenAPIExampleModel.h. Referenced by ConstructL(). |
|
|
iOppID. Opponent ID Definition at line 356 of file IMOpenAPIExampleModel.h. Referenced by HandleNewPToPMessageL(), MatchOppID(), and SetOppID(). |
|
|
iOppID. ETrue while some message is being send and response didnt yet come Definition at line 362 of file IMOpenAPIExampleModel.h. Referenced by ConstructL(), GetGameState(), HandleMessageSentL(), HandleSendErrorL(), and SendMsg(). |
|
|
iOppID. Stores last message sent. TMsg is defined in IMOpenAPIExamplemsg.h Definition at line 368 of file IMOpenAPIExampleModel.h. Referenced by ConstructL(), HandleMessageSentL(), SendAlreadyInGame(), SendChallenge(), SendChallengeAccepted(), SendChallengeRejected(), SendEndChallenge(), SendExitGame(), SendPlayedIndex(), and SendStartGame(). |
|
|
iMySign, iOppSign. User's own and opponent's signs. TGameSign is defined in IMOpenAPIExamplemsg.h Definition at line 374 of file IMOpenAPIExampleModel.h. Referenced by SendChallenge(), SendChallengeAccepted(), and SendPlayedIndex(). |
|
|
iMessageToSend Buffer containing message to be sent Definition at line 380 of file IMOpenAPIExampleModel.h. Referenced by SendAlreadyInGame(), SendChallenge(), SendChallengeAccepted(), SendChallengeRejected(), SendEndChallenge(), SendExitGame(), SendPlayedIndex(), and SendStartGame(). |
|
|
iSeed This seed is used to randomize who's turn is first. Definition at line 386 of file IMOpenAPIExampleModel.h. Referenced by SendStartGame(). |
|
|
iNotSupported Whether the IM functionality is supported or not Definition at line 392 of file IMOpenAPIExampleModel.h. Referenced by ConstructL(), and LoginL(). |
|
© Nokia 2009 |