@Override protected ArrayList<String> doInBackground(Void... params) { ArrayList<String> allContacts = new ArrayList<String>(); Iterator<User> iter = UserManager.getContactList().iterator(); while (iter.hasNext()) { User u = iter.next(); allContacts.add(u.getNickname()); } UserSearchManager search = new UserSearchManager(NetworkService.getInstance().getConnection()); try { Object[] ss = search.getSearchServices().toArray(); for (Object s : ss) { Log.d(TAG, s.toString()); } } catch (XMPPException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Form searchForm = search.getSearchForm(); // Form answerForm = searchForm.createAnswerForm(); // answerForm.setAnswer("last", "DeMoro"); // ReportedData data = search.getSearchResults(answerForm); // TODO [backend] add all emails and names from OpenComm users to the arraylist // TODO [backend] add all emails and names from the phonebook with emails return allContacts; }
public ReturnState login(String email, String password) { try { // attempt to connect this.xmppConn.connect(); // extract JID from the email address by removing nonalphanumeric // characters from the email address String jid = email.replaceAll("[^a-zA-Z0-9]", "") + DEFAULT_HOSTNAME; if (D) Log.d( TAG, "Attempt login: email - " + email + ", jid - " + jid + ", password - " + password); try { this.xmppConn.login(jid, password, DEFAULT_RESOURCE); // check that the email is the right one if (!email.equals(this.getConnection().getAccountManager().getAccountAttribute("email"))) { if (D) Log.d(TAG, "Email does not match"); // disconnect this.xmppConn.disconnect(); // reconnect to the server _instance = new NetworkService(DEFAULT_HOST, DEFAULT_PORT); MultiUserChat.addInvitationListener(NetworkService.getInstance().getConnection(), null); return ReturnState.INVALID_PAIR; } return ReturnState.SUCCEEDED; } catch (XMPPException e) { // if login failed e.printStackTrace(); return ReturnState.INVALID_PAIR; } } catch (XMPPException e) { if (D) Log.d(TAG, "Connection to server failed"); return ReturnState.COULDNT_CONNECT; } }
public MultiUserChat accept() { ConferenceRoom muc = new ConferenceRoom(NetworkService.getInstance().getConnection(), room); try { muc.join(); } catch (XMPPException e) { System.out.println("Could not join chatroom:" + e); } return muc; }