Пример #1
0
  public void trialLogin() {
    // TODO Auto-generated method stub
    RestClient result = null;
    try {
      result =
          new Rest.renewSession()
              .execute(
                  Rest.RENEW_SESSION,
                  Rest.OTOKE + Rest.accessCode + email + ":" + userPW,
                  Rest.POST)
              .get();
    } catch (InterruptedException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (ExecutionException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    if (result.getResponseCode() == 201) {
      RestClient result3 = null;
      try {
        result3 = new request().execute(Rest.USER, Rest.OSESS + Profile.sk, Rest.GET).get();
      } catch (InterruptedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      } catch (ExecutionException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }

      if (result3 != null) {
        Profile.setProfile(result3.getResponse(), userPW);
        CacheInternalStorage.cacheUserLoginInfo(
            new UserLoginInfo(email, userPW, true), getApplicationContext()); // cache user info

        TaskQueue.start();
        TaskQueueImage.start(getApplicationContext());
        TaskQueueImage2.start();
        Intent i = new Intent(getApplicationContext(), OohlalaMain.class);
        startActivity(i);
      }
    }
  }
Пример #2
0
  public void setUserPW(String fb_uid) {
    // TODO Auto-generated method stub
    RestClient result = null;
    try {
      result =
          new Rest.request()
              .execute(Rest.SCHOOL + "?email=" + email, Rest.OTOKE + Rest.accessCode2, Rest.GET)
              .get();
    } catch (InterruptedException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (ExecutionException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    Log.i("set userPW: ", result.getResponse());

    JSONObject user_info = null;
    int user_id = -1;
    try {
      user_info = (new JSONObject(result.getResponse())).getJSONObject("user_info");
      user_id = (new JSONObject(result.getResponse())).getJSONObject("user_info").getInt("user_id");
    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    if (user_id != -1) {
      String user_fb_token = null;
      try {
        user_fb_token = user_info.getString("fb_token");
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      userPW = RetrieveData.hash(email + user_fb_token + fb_uid).trim();
      Log.i("userPW: ", userPW);
    }
  }