void ScoreLoopThread::RequestUserCompletionCallback(void *userData, SC_Error_t completionStatus) { /* Get the application from userData argument */ AppData_t *app = (AppData_t *) userData; /* Check completion status */ if (completionStatus != SC_OK) { SC_UserController_Release(app->userController); /* Cleanup Controller */ HandleError(app, completionStatus); return; } qDebug() << "Done requesting User"; /* Get the session from the client. */ SC_Session_h session = SC_Client_GetSession(app->client); /* Get the session user from the session. */ SC_User_h user = SC_Session_GetUser(session); /* Write out some user data */ SC_String_h login = SC_User_GetLogin(user); qDebug() << " User's login:"******"<unknown>"); SC_String_h email = SC_User_GetEmail(user); qDebug() << " User's email: " << (email ? SC_String_GetData(email) : "<unknown>"); /* We don't need the UserController anymore, so release it */ SC_UserController_Release(app->userController); /* send this to the app so we can save it for future requests */ emit(instance()->ScoreLoopUserReady(app)); /* normal signal for emitting the username */ emit(instance()->RequestUserCompleted(login ? SC_String_GetData(login) : "<unknown>")); }
void OnlineService::userContextLoaded(SC_Error_t status) { //printf("online userContextLoaded\n"); fflush(stdout); assert(state == LOAD_USER_CONTEXT); if (status != SC_OK) { if (has_user_controller) { SC_UserController_Release(scoreloop_user_controller); has_user_controller = false; } state = DISCONNECTED; printf("SC_UserController_LoadUserContext failed with code %i\n", status); fflush(stdout); return; // handle error } SC_Session_h session = SC_Client_GetSession(scoreloop_client); scoreloop_user = SC_Session_GetUser(session); has_user = true; SC_Context_h user_context = SC_User_GetContext(scoreloop_user); for (int i = 0; i < 5; i++) { const size_t keysize = 255; char key[keysize]; snprintf(key, keysize, "save000%i.spe", i + 1); downloadSaveGame(key); } // fetch & decode autosave & resume file state = CONNECTED; }
void CScores::ControlPress(int index) { switch (index) { case 0: { m_needscenetype = stMainMenu; Close(); } break; case 1: { m_needscenetype = stProfile; Close(); } break; case 2: { FillLocalScoresTable(); } break; case 3: { // Loading Scoreloop scores // First loading score and rank // See OnRequestSuccessRanking() SC_RankingController_Cancel(m_rankingController); //Cancel last request SC_User_h user = SC_Session_GetUser(SC_Client_GetSession(g_client)); SC_RankingController_SetSearchList(m_rankingController, SC_SCORE_SEARCH_LIST_GLOBAL); SC_RankingController_SetMode(m_rankingController, 1); SC_RankingController_SetTimeInterval(m_rankingController, SC_TIME_INTERVAL_GLOBAL); SC_RankingController_RequestRankingForUser(m_rankingController, user); StartWait("Loading current user score"); } break; } }
SC_Money_h ScoreLoopThread::GetStake(AppData_t *app) { /* Get all possible stakes */ SC_MoneyList_h moneyList = SC_Session_GetChallengeStakes(SC_Client_GetSession(app->client)); /* Just pick the first stake here - if available */ if (SC_MoneyList_GetCount(moneyList) > 0) { return SC_MoneyList_GetAt(moneyList, 0); } else { return NULL; } }
FREObject loadScoresAroundUser(FREContext ctx, void* functionData, uint32_t argc, FREObject argv[]) { SC_Session_h session= SC_Client_GetSession(client); SC_User_h aUser = SC_Session_GetUser(session); int aRange; FREGetObjectAsInt32(argv[0],&aRange); #if defined(BB10) SC_ScoresController_LoadScoresAroundUser(scores_controller,aUser,aRange); #else SC_ScoresController_LoadRangeForUser(scores_controller,aUser,aRange); #endif return NULL; }
void CScores::OnRequestSuccessSubmit() { g_localhighscoresubmited = true; Save(); //Loading rank and score again //See OnRequestSuccessRanking() SC_User_h user = SC_Session_GetUser(SC_Client_GetSession(g_client)); SC_RankingController_SetSearchList(m_rankingController, SC_SCORE_SEARCH_LIST_GLOBAL); SC_RankingController_SetMode(m_rankingController, 1); SC_RankingController_SetTimeInterval(m_rankingController, SC_TIME_INTERVAL_GLOBAL); SC_RankingController_RequestRankingForUser(m_rankingController, user); StartWait("Loading current user score"); }