/** * Login from the user preferences, * * @return : Return false if login was unsuccessful */ public static boolean loginFromPref() { String userName = SaveSharedPreference.getData(WebMethods.ctx, SaveSharedPreference.USERNAME_KEY); String password = SaveSharedPreference.getData(WebMethods.ctx, SaveSharedPreference.USER_PASS_KEY); return false; }
/** * Method to do a login, using username and password * * @param userName : The username * @param password : The password * @return : Return false if login was unsuccessful */ public static boolean login(String userName, String password) { // Create the new user, User user = new User(); user.setUser(this); // If the login query was succesful, save the preferences String firstName = "Default"; String id = "0"; boolean success = false; if (success) { SaveSharedPreference.setData(ctx, SaveSharedPreference.USER_ID_KEY, id); SaveSharedPreference.setData(ctx, SaveSharedPreference.USER_NAME_KEY, firstName); SaveSharedPreference.setData(ctx, SaveSharedPreference.USER_PASS_KEY, password); SaveSharedPreference.setData(ctx, SaveSharedPreference.USERNAME_KEY, userName); } return false; }
/** * Make a request request call to restful * * @param uri * @throws JSONException */ private void requestRequests(String uri) throws JSONException { RequestPackaging p = new RequestPackaging(); p.setMethod("POST"); // Set the HTTP REQUEST method p.setUri(uri); // Sets the URI JSONArray jar = new JSONArray(); JSONObject object = new JSONObject(); object.put("query", "select"); // What kind of query object.put("method", "getborrowbookrequest"); // What kind of request object.put( "id", SaveSharedPreference.getID(getActivity())); // Pass the id for the user to the webservice jar.put(object); p.setJarParams(jar); // Add the param objects to the JSONArray MyTask task = new MyTask(); task.execute(p); }
/** * Make a reply request call to restful * * @param position * @throws JSONException */ public void requestReplyRequest(int position) throws JSONException { BorrowedBook borrowedBook = (BorrowedBook) borrowedBooks.get(position); RequestPackaging p = new RequestPackaging(); p.setMethod("POST"); // Set the HTTP REQUEST method p.setUri(BookshelfConstants.CONNECTION_URI); // Sets the URI JSONArray jar = new JSONArray(); JSONObject object = new JSONObject(); object.put("query", "update"); // What kind of query object.put("method", "replyborrowedbook"); // What kind of request object.put( "friendid", SaveSharedPreference.getID(getActivity())); // Pass the id for the user to the webservice object.put("id", borrowedBook.getRenter().getId()); object.put("isbn", borrowedBooks.get(position).getIsbn()); object.put("accepted", "FALSE"); object.put("replied", "TRUE"); jar.put(object); p.setJarParams(jar); // Add the param objects to the JSONArray MyTask task = new MyTask(); task.execute(p); }