Пример #1
0
  @Override
  public void sendMessage(final FriendMessage message) {

    HashMap<String, Friend> friends = AccountManager.getInstance().getFriends();
    Friend friend = friends.get(message.getTo());
    Screenname buddy = new Screenname(friend.getUserName());
    Conversation c = (Conversation) friend.getUserInfo();
    if (c == null) {
      c = connection.getIcbmService().getImConversation(buddy);
      friend.setUserInfo(c);
    }
    Message oscarMessage =
        new Message() {

          public boolean isAutoResponse() {
            return false;
          }

          public String getMessageBody() {
            return message.getMessage();
          }
        };
    c.sendMessage(oscarMessage);
    Friend recipient = friends.get(message.getTo());
    accountListener.didReceiveMessageForFriend(message, recipient);
  }
Пример #2
0
 public Friend getFriendFromBuddy(Screenname buddy, boolean needFullInfo) {
   Friend friend = new Friend(buddy.getFormatted());
   friend.setAccount(AIMAccount.this);
   //		friend.setName(buddy.getFormatted());
   //		if (needFullInfo)
   //			friendApplyNewStatusFromContact(friend, contact);
   return friend;
 }
Пример #3
0
    public void applyInfoToFriendFromBuddyInfo(final Friend friend, BuddyInfo info) {
      friend.setIsAvailable(true);
      long status = info.getIcqStatus();
      if ((status & FullUserInfo.ICQSTATUS_AWAY) == 1) {
        friend.setStatus(Friend.Status.AWAY);
      } else if (((status & FullUserInfo.ICQSTATUS_DND) == 1)) {
        friend.setStatus(Friend.Status.DND);
      } else if ((status & FullUserInfo.ICQSTATUS_OCCUPIED) == 1) {
        friend.setStatus(Friend.Status.DND);
      } else if ((status & FullUserInfo.ICQSTATUS_NA) == 1) {
        friend.setStatus(Friend.Status.NA);
      } else if ((status & FullUserInfo.ICQSTATUS_DEFAULT) == 1) {
        friend.setStatus(Friend.Status.AVAILABLE);
      } else if ((status & FullUserInfo.ICQSTATUS_FFC) == 1) {
        friend.setStatus(Friend.Status.AVAILABLE);
      }

      friend.setStatusMessage(info.getStatusMessage());
      //			Screenname buddy = new Screenname(friend.getUserName());
      //			connection.getInfoService().requestDirectoryInfo(buddy);
      //			connection.getInfoService().requestUserProfile(buddy);

      //			 int requestId = nextSeqId();
      long buddyUIN = Long.parseLong(friend.getUserName());
      long ownerUIN = Long.parseLong(getUserName());
      MetaShortInfoRequest req = new MetaShortInfoRequest(ownerUIN, 2, buddyUIN);

      //	         ShortInfoResponseRetriever responseRetriever = new ShortInfoResponseRetriever();
      connection
          .getInfoService()
          .getOscarConnection()
          .sendSnacRequest(
              req,
              new SnacRequestAdapter() {
                public void handleResponse(SnacResponseEvent e) {
                  SnacCommand snac = e.getSnacCommand();
                  if (snac instanceof MetaShortInfoCmd) {
                    MetaShortInfoCmd infoSnac = (MetaShortInfoCmd) snac;
                    String nick = infoSnac.getNickname();
                    String firstName = infoSnac.getFirstName();
                    String lastName = infoSnac.getLastName();
                    String fullname = firstName + " " + lastName;
                    if (fullname.length() < 2) fullname = nick;
                    friend.setName(fullname);
                  }
                }
              });

      //	         synchronized(responseRetriever)
      //	         {
      //	             try{
      //	                 responseRetriever.wait(30000);
      //	             }
      //	             catch (InterruptedException ex)
      //	             {
      //	             }
      //	         }

    }