Package hamsam.api

Examples of hamsam.api.Buddy


                String groupName = (String) iter.next();
                List list = (List) map.get(groupName);

                for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                    String buddy = (String) iterator.next();
                    buddyList.add(new Buddy(protocol, buddy, groupName));
                }
            }
        }

        Buddy[] buddies = new Buddy[buddyList.size()];
View Full Code Here


        String passport = cmd.getParam(1);
        String alias = cmd.getParam(2);
       
        if(statusCode != null && passport != null)
        {
          Buddy buddy = new Buddy(protocol, passport);
          buddy.setAlias(alias);
          buddy.setStatus(Util.getVerboseStatus(statusCode));
          processor.buddyStatusChanged(buddy);
        }
        return;
      }
    }
View Full Code Here

      if((memberLists & 1) != 0) // This buddy is in FL
      {
        for(int i = 0; i < memberGroups.length; i++)
        {
          String group = (String) allGroups.get(memberGroups[i]);
          Buddy buddy = new Buddy(protocol, passport, group);
          buddy.setAlias(alias);
          allBuddies.add(buddy);
        }
      }
      if((memberLists & 2) != 0) // This buddy is in AL
      {
        Buddy buddy = new Buddy(protocol, passport);
        buddy.setAlias(alias);
        allowList.add(buddy);
      }
      if((memberLists & 4) != 0) // This buddy is in BL
      {
        Buddy buddy = new Buddy(protocol, passport);
        buddy.setAlias(alias);
        blockList.add(buddy);
      }

      // Check if we received all LST commands
      if(++lstReceivedCount == lstReplyCount)
      {
        // Send the buddy list to the client
        Buddy[] buddies = (Buddy[]) allBuddies.toArray(new Buddy[0]);
        processor.buddyListReceived(buddies);

        Command blp = new Command("BLP");
        blp.addParam("AL");
        sendToServer(blp, "processPrivacySetting");
      }
    }
    else if("CHL".equals(type))
    {
      String challenge = cmd.getParam(1);
      if(challenge != null)
        handleChallenge(challenge);
      return;
    }
    else if("RNG".equals(type))
      handleSBInvitation(cmd);
    else if("NLN".equals(type))
    {
      String passport = cmd.getParam(1);
      String alias = Util.urlDecode(cmd.getParam(2));
      String status = Util.getVerboseStatus(cmd.getParam(0));
      Buddy buddy = new Buddy(this.protocol, passport);
      buddy.setAlias(alias);
      buddy.setStatus(status);
      processor.buddyStatusChanged(buddy);
    }
    else if("FLN".equals(type))
    {
      String passport = cmd.getParam(0);
      Buddy buddy = new Buddy(this.protocol, passport);
      buddy.setStatus(null);
      processor.buddyStatusChanged(buddy);
    }
  }
View Full Code Here

    String alias = Util.urlDecode(cmd.getParam(5));

    try
    {
      // send the invitation
      Buddy host = new Buddy(protocol, passport);
      host.setAlias(alias);
      Buddy[] buddies = new Buddy[] {host};
      Conference conf = new Conference(protocol, host, buddies);
      Response res = processor.conferenceInvitationReceived(conf, "");

      if(res.isAccepted())
View Full Code Here

        continue;
      }

      tok = new StringTokenizer(split[1], ",");
      for(int j = 0; tok.hasMoreTokens(); j++)
        buddyVector.add(new Buddy(this, tok.nextToken(), split[0]));
    }

    return (Buddy[])buddyVector.toArray(new Buddy[0]);
  }
View Full Code Here

          break;

        case 13:
          if(pack.getService() == SERVICE_LOGOFF || Integer.parseInt(value) == 0)
          {
            Buddy buddy = new Buddy(this, name);
            buddy.setStatus(parseYahooStatus(STATUS_OFFLINE, null));

            listener.buddyStatusChanged(buddy);
            break;
          }

          Buddy buddy = new Buddy(this, name);
          buddy.setStatus(parseYahooStatus(state, msg));

          listener.buddyStatusChanged(buddy);
          break;

        case 16: /* Custom error message */
 
View Full Code Here

    if(msg == null || from == null)
      return;

    if(msg.equalsIgnoreCase("TYPING"))
    {
      Buddy buddy = new Buddy(this, from);
      if(stat == 1)
        listener.typingStarted(buddy);
      else if(stat == 0)
        listener.typingStopped(buddy);
    }
View Full Code Here

        if(pack.getService() == SERVICE_SYSMESSAGE)
          listener.protocolMessageReceived(this, Util.parseYahooMessage(msg));
        else if(pack.getStatus() <= 1 || pack.getStatus() == 5)
        {
          Buddy buddy = new Buddy(this, from);

          if(time != -1)
            listener.offlineMessageReceived(buddy, new Date(time),
                    Util.parseYahooMessage(msg));
          else
View Full Code Here

        away = Integer.parseInt(value);
    }

    if(myid != null)
    {
      Response resp = listener.buddyAddRequest(new Buddy(this, who), new Buddy(this, myid), msg);
      if(!resp.isAccepted())
      {
        Packet retPack = new Packet(SERVICE_REJECTCONTACT, STATUS_AVAILABLE, sessionID);
        retPack.putData(1, yahooID);
        retPack.putData(7, who);
        retPack.putData(14, resp.getMessage());

        sendToWriterThread(retPack);
      }
    }
    else if(name != null)
    {
      Buddy buddy = new Buddy(this, name);
      buddy.setStatus(parseYahooStatus(state, msg));
      listener.buddyStatusChanged(buddy);
    }
    else if(pack.getStatus() == 0x07)
    {
      Buddy buddy = new Buddy(this, who);
      listener.buddyAddRejected(buddy, msg);
    }
  }
View Full Code Here

   * @param pack the packet containing the data.
   */
  private void processConference(Packet pack)
  {
    String msg = null;
    Buddy host = null;
    Buddy who = null;
    String room = null;
    String id = null;
    Vector members = new Vector();

    int size = pack.getDataSize();
    for(int i = 0; i < size; i++)
    {
      int key = pack.getKey(i);
      String value = pack.getValue(i);

      if(key == 50)
        host = new Buddy(this, value);
      if(key == 52// invite
        members.add(new Buddy(this, value));
      if(key == 53// logon
        who = new Buddy(this, value);
      if(key == 54// decline
        who = new Buddy(this, value);
      if(key == 55// unavailable (status == 2)
        who = new Buddy(this, value);
      if(key == 56// logoff
        who = new Buddy(this, value);
      if(key == 57)
        room = value;
      if(key == 58// join message
        msg = value;
      if(key == 14// decline/conf message
        msg = value;
      if (key == 16// error
        msg = value;
      if(key == 1// my id
        id = value;
      if(key == 3// message sender
        who = new Buddy(this, value);
    }

    if(room == null)
      return;

View Full Code Here

TOP

Related Classes of hamsam.api.Buddy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.