コード例 #1
0
ファイル: AIMAccount.java プロジェクト: morpeh/Dolca-HD
  @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
ファイル: AIMAccount.java プロジェクト: morpeh/Dolca-HD
 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
ファイル: AIMAccount.java プロジェクト: morpeh/Dolca-HD
    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)
      //	             {
      //	             }
      //	         }

    }