/** * Creates a new presence update. Status, priority, and mode are left un-set. * * @param type the type. */ public Presence(Type type) { // Ensure that the stanza ID is set by calling super(). super(); setType(type); }
/** * Creates a new presence update with a specified status, priority, and mode. * * @param type the type. * @param status a text message describing the presence update. * @param priority the priority of this presence update. * @param mode the mode type for this presence update. */ public Presence(Type type, String status, int priority, Mode mode) { // Ensure that the stanza ID is set by calling super(). super(); setType(type); setStatus(status); setPriority(priority); setMode(mode); }
@Test(expected = NullPointerException.class) public void setNullPresenceTypeTest() { getNewPresence().setType(null); }
@Test public void setPresenceTypeTest() throws IOException, SAXException { Presence.Type type = Presence.Type.unavailable; Presence.Type type2 = Presence.Type.subscribe; StringBuilder controlBuilder = new StringBuilder(); controlBuilder.append("<presence") .append(" type=\"") .append(type) .append("\">") .append("</presence>"); String control = controlBuilder.toString(); Presence presenceTypeInConstructor = new Presence(type); presenceTypeInConstructor.setStanzaId(null); assertEquals(type, presenceTypeInConstructor.getType()); assertXMLEqual(control, presenceTypeInConstructor.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); controlBuilder = new StringBuilder(); controlBuilder.append("<presence") .append(" type=\"") .append(type2) .append("\">") .append("</presence>"); control = controlBuilder.toString(); Presence presenceTypeSet = getNewPresence(); presenceTypeSet.setType(type2); assertEquals(type2, presenceTypeSet.getType()); assertXMLEqual(control, presenceTypeSet.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
/** * Creates a new presence update. Status, priority, and mode are left un-set. * * @param type the type. */ public Presence(Type type) { // Ensure that the stanza ID is set by calling super(). super(); setType(type); }
/** * Creates a new presence update. Status, priority, and mode are left un-set. * * @param type the type. */ public Presence(Type type) { setType(type); }
/** * Creates a new presence update. Status, priority, and mode are left un-set. * * @param type the type. */ public Presence(Type type) { setType(type); }
/** * Creates a new presence update. Status, priority, and mode are left un-set. * * @param type the type. */ public Presence(Type type) { setType(type); }
public JsonObject deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (jp.getCurrentToken() != JsonToken.START_OBJECT) { throw new IOException("invalid start marker"); } Presence p = new Presence(); while (jp.nextToken() != JsonToken.END_OBJECT) { String fieldname = jp.getCurrentName(); jp.nextToken(); //move to next token in string if ("userEmail".equals(fieldname)) { p.setUserEmail(jp.getText()); } else if ("domain".equals(fieldname)) { p.setDomain(jp.getText()); } else if ("type".equals(fieldname)) { p.setType(jp.getText()); } } jp.close(); return p; }
Presence np, packet = new Presence(); packet.setID(sessionManager.nextStreamID().toString()); packet.setFrom(server.createJID(operator, null)); if(!available) packet.setType(Presence.Type.unavailable); else packet.setType(null); // add the custom XML Element xml = DocumentHelper.createElement(QName.get("custom", "http://www.custom.com/xmpp")); xml.addAttribute("type", "presenceupdate"); packet.addExtension(new PacketExtension(xml));
Presence presence = (Presence) packet; Presence presence_request = new Presence(Presence.Type.subscribed); presence_request.setTo(presence.getFrom()); presence_request.setType(Presence.Type.subscribed); presence_request.setFrom("current_logged_in_user"); connection.sendPacket(presence_request); roster.createEntry(presence.getFrom(), null, null);
/** * Creates a new presence update with a specified status, priority, and mode. * * @param type the type. * @param status a text message describing the presence update. * @param priority the priority of this presence update. * @param mode the mode type for this presence update. */ public Presence(Type type, String status, int priority, Mode mode) { setType(type); setStatus(status); setPriority(priority); setMode(mode); }
/** * Creates a new presence update with a specified status, priority, and mode. * * @param type the type. * @param status a text message describing the presence update. * @param priority the priority of this presence update. * @param mode the mode type for this presence update. */ public Presence(Type type, String status, int priority, Mode mode) { setType(type); setStatus(status); setPriority(priority); setMode(mode); }
/** * Creates a new presence update with a specified status, priority, and mode. * * @param type the type. * @param status a text message describing the presence update. * @param priority the priority of this presence update. * @param mode the mode type for this presence update. */ public Presence(Type type, String status, int priority, Mode mode) { setType(type); setStatus(status); setPriority(priority); setMode(mode); }
/** * Creates a new presence update with a specified status, priority, and mode. * * @param type the type. * @param status a text message describing the presence update. * @param priority the priority of this presence update. * @param mode the mode type for this presence update. */ public Presence(Type type, String status, int priority, Mode mode) { // Ensure that the stanza ID is set by calling super(). super(); setType(type); setStatus(status); setPriority(priority); setMode(mode); }
/** * This method lets you send the presence direct to the gateway. Type, To and From * are modified. * @param presence the presence used to login to gateway */ public void login(Presence presence){ presence.setType(Presence.Type.available); presence.setTo(entityJID); presence.setFrom(connection.getUser()); connection.sendPacket(presence); }
Presence reply = new Presence(Presence.Type.available); if (!isAvailable) { reply.setType(Presence.Type.unavailable);