Package org.jivesoftware.smackx.pubsub.packet

Examples of org.jivesoftware.smackx.pubsub.packet.PubSub


    return createPubsubPacket(to, type, ext, null);
  }
 
  static PubSub createPubsubPacket(String to, Type type, PacketExtension ext, PubSubNamespace ns)
  {
    PubSub request = new PubSub();
    request.setTo(to);
    request.setType(type);
   
    if (ns != null)
    {
      request.setPubSubNamespace(ns);
    }
    request.addExtension(ext);
   
    return request;
  }
View Full Code Here


*/
public class PubSubProvider implements IQProvider
{
  public IQ parseIQ(XmlPullParser parser) throws Exception
  {
        PubSub pubsub = new PubSub();
        String namespace = parser.getNamespace();
        pubsub.setPubSubNamespace(PubSubNamespace.valueOfFromXmlns(namespace));
        boolean done = false;

        while (!done)
        {
            int eventType = parser.next();
           
            if (eventType == XmlPullParser.START_TAG)
            {
              PacketExtension ext = PacketParserUtils.parsePacketExtension(parser.getName(), namespace, parser);
             
              if (ext != null)
              {
                pubsub.addExtension(ext);
              }
            }
            else if (eventType == XmlPullParser.END_TAG)
            {
                if (parser.getName().equals("pubsub"))
View Full Code Here

   * @param submitForm
   */
  public void sendConfigurationForm(Form submitForm)
    throws XMPPException
  {
    PubSub packet = createPubsubPacket(Type.SET, new FormNode(FormNodeType.CONFIGURE_OWNER, getId(), submitForm), PubSubNamespace.OWNER);
    SyncPacketSend.getReply(con, packet);
  }
View Full Code Here

   * @throws XMPPException
   */
  public List<Subscription> getSubscriptions()
    throws XMPPException
  {
    PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId()));
    SubscriptionsExtension subElem = (SubscriptionsExtension)reply.getExtension(PubSubElementType.SUBSCRIPTIONS);
    return subElem.getSubscriptions();
  }
View Full Code Here

   * @exception XMPPException
   */
  public Subscription subscribe(String jid)
    throws XMPPException
  {
    PubSub reply = (PubSub)sendPubsubPacket(Type.SET, new SubscribeExtension(jid, getId()));
    return (Subscription)reply.getExtension(PubSubElementType.SUBSCRIPTION);
  }
View Full Code Here

   * @exception XMPPException
   */
  public Subscription subscribe(String jid, SubscribeForm subForm)
    throws XMPPException
  {
    PubSub request = createPubsubPacket(Type.SET, new SubscribeExtension(jid, getId()));
    request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm));
    PubSub reply = (PubSub)PubSubManager.sendPubsubPacket(con, jid, Type.SET, request);
    return (Subscription)reply.getExtension(PubSubElementType.SUBSCRIPTION);
  }
View Full Code Here

   * @throws XMPPException
   */
  public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId)
    throws XMPPException
  {
    PubSub packet = (PubSub)sendPubsubPacket(Type.GET, new OptionsExtension(jid, getId(), subscriptionId));
    FormNode ext = (FormNode)packet.getExtension(PubSubElementType.OPTIONS);
    return new SubscribeForm(ext.getForm());
  }
View Full Code Here

   * @exception XMPPException
   */
  public LeafNode createNode()
    throws XMPPException
  {
    PubSub reply = (PubSub)sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.CREATE));
    NodeExtension elem = (NodeExtension)reply.getExtension("create", PubSubNamespace.BASIC.getXmlns());
   
    LeafNode newNode = new LeafNode(con, elem.getNode());
    newNode.setTo(to);
    nodeMap.put(newNode.getId(), newNode);
   
View Full Code Here

   * @exception XMPPException
   */
  public Node createNode(String name, Form config)
    throws XMPPException
  {
    PubSub request = createPubsubPacket(to, Type.SET, new NodeExtension(PubSubElementType.CREATE, name));
    boolean isLeafNode = true;
   
    if (config != null)
    {
      request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
      FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
     
      if (nodeTypeField != null)
        isLeafNode = nodeTypeField.getValues().next().equals(NodeType.leaf.toString());
    }
View Full Code Here

   * @throws XMPPException
   */
  public List<Affiliation> getAffiliations()
    throws XMPPException
  {
    PubSub reply = (PubSub)sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.AFFILIATIONS));
    AffiliationsExtension listElem = (AffiliationsExtension)reply.getExtension(PubSubElementType.AFFILIATIONS);
    return listElem.getAffiliations();
  }
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.pubsub.packet.PubSub

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.