コード例 #1
0
ファイル: XmppBuddies.java プロジェクト: sd542927172/gtalksms
  public int retrieveState(String userID) {
    int userState = XmppFriend.OFFLINE; // default return value
    Presence userFromServer = null;

    try {
      userFromServer = sConnection.getRoster().getPresence(userID);
      userState = retrieveState(userFromServer.getMode(), userFromServer.isAvailable());
    } catch (NullPointerException e) {
      Log.e("retrieveState(): Invalid connection or user - NPE", e);
    }

    return userState;
  }
コード例 #2
0
 @Override
 public void onReceiveWithoutSms(Context context, int partNum, int res) {
   answerTo = null;
   Log.w("sms in smsMap missing");
   switch (res) {
     case Activity.RESULT_OK:
       send(context.getString(R.string.chat_sms_delivered));
       break;
     case Activity.RESULT_CANCELED:
       send(context.getString(R.string.chat_sms_not_delivered));
       break;
   }
 }
コード例 #3
0
ファイル: XmppBuddies.java プロジェクト: sd542927172/gtalksms
  /**
   * returns the status message for a given bare or full JID
   *
   * @param userID
   * @return
   */
  public String retrieveStatusMessage(String userID) {
    String userStatus = ""; // default return value

    try {
      userStatus = sConnection.getRoster().getPresence(userID).getStatus();
    } catch (NullPointerException e) {
      Log.e("Invalid connection or user in retrieveStatus() - NPE", e);
      userStatus = "";
    }
    // Server may set their status to null; we want empty string
    if (userStatus == null) {
      userStatus = "";
    }

    return userStatus;
  }
コード例 #4
0
ファイル: XmppBuddies.java プロジェクト: sd542927172/gtalksms
  /**
   * retrieves the current xmpp rooster and sends a broadcast ACTION_XMPP_PRESENCE_CHANGED for every
   * friend does nothing if we are offline
   *
   * @return
   */
  public ArrayList<XmppFriend> retrieveFriendList() {

    ArrayList<XmppFriend> friends = new ArrayList<XmppFriend>();

    if (sConnection != null && sConnection.isAuthenticated()) {
      try {
        String userID = null;
        String status = null;
        Roster roster = sConnection.getRoster();

        for (RosterEntry r : roster.getEntries()) {
          userID = r.getUser();
          status = retrieveStatusMessage(userID);
          friends.add(new XmppFriend(userID, r.getName(), status, retrieveState(userID)));
        }

        sendFriendList(friends);
      } catch (Exception ex) {
        Log.w("Failed to retrieve Xmpp Friend list", ex);
      }
    }

    return friends;
  }