Package tigase.xml

Examples of tigase.xml.Element


          log.fine("Added buddy do repository for: " + buddy);
        } catch (TigaseDBException e) {
          log.log(Level.WARNING, "Problem updating repository data", e);
        }

        Element pres_el = new Element(PRESENCE_ELNAME,
            new String[] {"to", "from"},
            new String[] {packet.getElemFrom(), packet.getElemTo()});
        if (!pres_type.equals("null")) {
          pres_el.setAttribute("type", pres_type);
        }
        if (!pres_show.equals("null")) {
          Element show = new Element("show", pres_show);
          pres_el.addChild(show);
        }
        Packet presence = new Packet(pres_el);
        log.finest("Sending out presence: " + presence.toString());
        addOutPacket(presence);
View Full Code Here


      addOutPacket(Authorization.BAD_REQUEST.getResponseMessage(packet,
          "IQ request must have either 'set' or 'get' type.", true));
      return;
    }
    if (packet.getType() == StanzaType.get) {
      Element query = new Element("query");
      query.setXMLNS("jabber:iq:gateway");
      query.addChild(new Element("desc", gw_desc));
      query.addChild(new Element("prompt"));
      addOutPacket(packet.okResult(query, 0));
    }
    if (packet.getType() == StanzaType.set) {
      String legacyName = packet.getElemCData("/iq/query/prompt");
      String jid = formatJID(legacyName);
      addOutPacket(packet.okResult(new Element("prompt", jid), 1));
    }
  }
View Full Code Here

  }

  public List<Element> getPresence(String ... from) {
    List<Element> result = new ArrayList<Element>();
    for (String f: from) {
      Element  presence = jid_presence.get(f);
      if (presence != null) {
        result.add(presence);
      }
    }
    return result;
View Full Code Here

    }
    return start_time;
  }

  private Element createMessageHistory(String jid) {
    return new Element("iq", new Element[] {
        new Element("chat",
          new String[] {"xmlns", "with", "start"},
          new String[] {"urn:xmpp:tmp:archive", jid, sdf.format(new Date())})},
      new String[] {"type", "id"},
      new String[] {"result", ""+System.currentTimeMillis()});
  }
View Full Code Here

  }

  private void addMsgBody(String jid, String direction, Element body) {
    long start_time = getMsgStartTime(jid);
    List<Element> msg_history_l = id_cache.get(MESSAGE_ID+jid);
    Element msg_history = null;
    if (msg_history == null) {
      msg_history = createMessageHistory(jid);
      add(MESSAGE_ID+jid, Arrays.asList(msg_history));
    } else {
      msg_history = msg_history_l.get(0);
    }
    long current_secs = (System.currentTimeMillis()/1000) - start_time;
    msg_history.findChild("/iq/chat").addChild(new Element(direction,
        new Element[] {body},
        new String[] {"secs"},
        new String[] {""+current_secs}));
  }
View Full Code Here

    String id = JIDUtils.getNodeID(packet.getElemFrom());
    GatewayConnection conn = gw_connections.get(id);
    if (conn != null || !create) {
      if (conn != null) {
        conn.addJid(packet.getElemFrom());
        addOutPacket(new Packet(new Element(PRESENCE_ELNAME,
              new String[] {"from", "to"},
              new String[] {getComponentId(), packet.getElemFrom()})));
        updateRosterPresence(conn.getRoster(), packet.getElemFrom());
      }
      return conn;
View Full Code Here

        new String[] {"secs"},
        new String[] {""+current_secs}));
  }

  public void addFromMessage(Element message) {
    Element body = message.findChild("/message/body");
    if (body == null) {
      return;
    }
    String jid = message.getAttribute("from");
    addMsgBody(jid, "from", body);
View Full Code Here

  }

  public void logout(GatewayConnection gc) {
    String[] jids = gc.getAllJids();
    for (String username: jids) {
      addOutPacket(new Packet(new Element(PRESENCE_ELNAME,
            new String[] {"from", "to", "type"},
            new String[] {getComponentId(), username, "unavailable"})));
      List<RosterItem> roster = gc.getRoster();
      for (RosterItem item: roster) {
        String from = formatJID(item.getBuddyId());
        Element pres_el = new Element(PRESENCE_ELNAME,
          new String[] {"to", "from", "type"},
          new String[] {username, from, "unavailable"});
        Packet presence = new Packet(pres_el);
        log.finest("Sending out presence: " + presence.toString());
        addOutPacket(presence);
View Full Code Here

    String jid = message.getAttribute("from");
    addMsgBody(jid, "from", body);
  }

  public void addToMessage(Element message) {
    Element body = message.findChild("/message/body");
    if (body == null) {
      return;
    }
    String jid = message.getAttribute("to");
    addMsgBody(jid, "to", body);
View Full Code Here

  }

  public void loginCompleted(GatewayConnection gc) {
    String[] jids = gc.getAllJids();
    for (String username: jids) {
      addOutPacket(new Packet(new Element(PRESENCE_ELNAME,
            new String[] {"from", "to"},
            new String[] {getComponentId(), username})));
    }
  }
View Full Code Here

TOP

Related Classes of tigase.xml.Element

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.