Exemple #1
0
 // submitEvent will send the event object to the server and store it.
 private void submitEvent(Event event) {
   ServerRequests serverRequest = new ServerRequests(this);
   serverRequest.storeEventDataInBackground(
       event,
       new GetEventCallback() {
         @Override
         public void done(Event returnedEvent) {
           finish();
         }
       });
 }
Exemple #2
0
 private void updateUserData(User user) {
   ServerRequests serverRequest = new ServerRequests(this);
   serverRequest.updateUserEventCountInBackground(
       user,
       new GetUserCallback() {
         @Override
         public void done(User returnedUser) {
           finish();
         }
       });
 }
 private void registerUser(User user) {
   ServerRequests serverRequests = new ServerRequests(this);
   serverRequests.storeUserDataInBackground(
       user,
       new GetUserCallBack() {
         @Override
         public void done(User returnedUser) {
           startActivity(new Intent(Register.this, Login.class));
         }
       });
 }
 private void registerUser(User user) {
   ServerRequests serverRequests = new ServerRequests(this);
   serverRequests.storeUserDataInBackground(
       user,
       new GetUserCallback() {
         @Override
         public void done(User returnedUser) {
           showMessage("Congraduations! The user has been created successfully.");
           startActivity(new Intent(Register.this, Login.class));
         }
       });
 }
Exemple #5
0
 private void authenticate(User user) {
   ServerRequests serverRequests = new ServerRequests(this);
   serverRequests.fetchUserDataInBackground(
       user,
       new GetUserCallback() {
         @Override
         public void done(User returnedUser) {
           if (returnedUser == null) {
             showErrorMessage();
           } else {
             logUserIn(returnedUser);
           }
         }
       });
 }
Exemple #6
0
 private void addInvitees(ArrayList<Friend> invitees, User host) {
   ServerRequests serverRequest = new ServerRequests(this);
   for (Friend invitee : invitees) {
     // TODO: send push requests here
     serverRequest.storeInviteeDataInBackground(
         host,
         invitee,
         new GetInviteeCallback() {
           @Override
           public void done(Object o) {
             dropdownListAdapter.clearSelectedFriends();
             finish();
           }
         },
         EventResponse.NO_RESPONSE);
   }
 }
 ////////
 //
 // getUser
 //
 // retrieves an instance of the User class containing information on the
 // username specified. If the user does not exist or there is an error
 // it returns null;
 //
 ////////
 public static User getUser(String uname) {
   ArrayList<User> users = ServerRequests.getUserInfo(uname);
   if (users == null) {
     return null;
   }
   if (users.size() != 1) {
     return null;
   }
   return users.get(0);
 }
  private void returnSendlist() {
    User user = userLocalStore.getLoggedInUser();
    ArrayList<Friend> friendlistsend = dataAdapter.friendList;
    for (int i = 0; i < friendlistsend.size(); i++) {
      Friend friend = friendlistsend.get(i);
      if (friend.isSelected()) {
        Friend friendsend = new Friend(friend.username, friend.friendname, null, null, -1);
        sendingFriendlist.add(friendsend);

        if (((AppDelegate) this.getApplication()).isTheFriendInTheWoz(friend.username)) {
          // if you send a rendez and your friends chat is allocated, need to append.
          // else the first instance will be able to retrieve this
          SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
          String time = dateFormatGmt.format(new Date()).toString();
          RendezStatus tem =
              new RendezStatus(
                  user.username,
                  statusTitle,
                  details,
                  location,
                  null,
                  timefor,
                  type,
                  -1,
                  friend.username);
          rendezChatDictionary temp =
              ((AppDelegate) this.getApplication()).getRendezDictionary(friend.username);
          temp.allDeesRendez.add(0, tem);
          // ((AppDelegate) this.getApplication()).putItInTheWoz(friend.username, temp);
        }
      }
    }

    for (int i = 0; i < groups.size(); i++) {
      if (groups.get(i).isSelected()) {
        Friend friendsend =
            new Friend(groups.get(i).groupname, groups.get(i).groupdetail, null, null, -1);
        sendingFriendlist.add(friendsend);
        /*
         * need to figure out the emits for this...
         * */

        if (((AppDelegate) this.getApplication()).isTheFriendInTheWoz(groups.get(i).groupname)) {
          SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
          String time = dateFormatGmt.format(new Date()).toString();
          RendezStatus tem =
              new RendezStatus(
                  user.username,
                  statusTitle,
                  details,
                  location,
                  null,
                  timefor,
                  type,
                  -1,
                  groups.get(i).groupname);
          rendezChatDictionary temp =
              ((AppDelegate) this.getApplication()).getRendezDictionary(groups.get(i).groupname);
          temp.allDeesRendez.add(0, tem);
          // ((AppDelegate) this.getApplication()).putItInTheWoz(groups.get(i).groupname, temp);
        }
      }
    }

    RendezStatus status =
        new RendezStatus(
            user.username, statusTitle, details, location, null, timefor, type, -1, null);
    ServerRequests serverRequests = new ServerRequests(this);
    serverRequests.sendToFriendsInBackground(
        user,
        sendingFriendlist,
        status,
        new SendRendezStatusCallback() {
          @Override
          public void done(ArrayList status) {
            ArrayList<RendezStatus> rs = status;
            for (int i = 0; i < status.size(); i++) {
              ((AppDelegate) getApplication())
                  .putItInTheWozRendezStatus(rs.get(i).username, rs.get(i));
              ((AppDelegate) getApplication())
                  .emitRendez(
                      rs.get(i).id,
                      sendingFriendlist.get(i).username,
                      statusTitle,
                      details,
                      location,
                      timefor,
                      type,
                      0);
            }
          }
        });
    Intent returnIntent = new Intent();
    returnIntent.putExtra("result", 1);
    setResult(RESULT_OK, returnIntent);
    finish();
  }
 ////////
 //
 // createUser
 //
 // method to create a user account on the server. takes a username, password
 // and email address and hashes the password with a MD5 hash. This method
 // assumes that the username, password and email have been validated.
 //
 ////////
 public static boolean createUser(String uname, String password, String email) {
   password = hashPassword(password);
   return ServerRequests.registerUser(uname, password, email);
 }
 ////////
 //
 // logIn
 //
 // method to log in and retrieve a session ID
 //
 ////////
 public static String logIn(String uname, String password) {
   password = hashPassword(password);
   return ServerRequests.createSession(uname, password);
 }