Exemplo n.º 1
0
    /*
     * (non-Javadoc)
     *
     * @see
     * org.jivesoftware.smack.PacketListener#processPacket(org.jivesoftware
     * .smack.packet.Packet)
     */
    @Override
    public void processPacket(Packet packet) {
      if (packet instanceof BeanIQAdapter) {
        XMPPBean inBean = ((BeanIQAdapter) packet).getBean();

        if (inBean instanceof PrepareServiceUploadBean) {
          handlePrepareServiceUploadBean((PrepareServiceUploadBean) inBean);
        } else if (inBean instanceof ServiceUploadConclusionBean
            && inBean.getType() == XMPPBean.TYPE_RESULT) {
          // Do nothing, just ack
        } else {
          handleUnknownBean(inBean);
        }
      }
    }
Exemplo n.º 2
0
  /**
   * Formats a Bean to a string.
   *
   * @param bean the bean
   * @return the formatted string of the Bean
   */
  public String beanToString(XMPPBean bean) {
    String str =
        "XMPPBean: [NS="
            + bean.getNamespace()
            + " id="
            + bean.getId()
            + " from="
            + bean.getFrom()
            + " to="
            + bean.getTo()
            + " type="
            + bean.getType()
            + " payload="
            + bean.payloadToXML();

    if (bean.errorCondition != null) str += " errorCondition=" + bean.errorCondition;
    if (bean.errorText != null) str += " errorText=" + bean.errorText;
    if (bean.errorType != null) str += " errorType=" + bean.errorType;

    str += "]";

    return str;
  }
Exemplo n.º 3
0
  /**
   * Convert an XMPPBean to an XMPPIQ to send it via the MXAProxy/MXA.
   *
   * @param bean the bean to convert
   * @param mergePayload true if the playload should be merged
   * @return the XMPPIQ
   */
  public XMPPIQ beanToIQ(XMPPBean bean, boolean mergePayload) {
    // default XMPP IQ type
    int type = XMPPIQ.TYPE_GET;

    switch (bean.getType()) {
      case XMPPBean.TYPE_GET:
        type = XMPPIQ.TYPE_GET;
        break;
      case XMPPBean.TYPE_SET:
        type = XMPPIQ.TYPE_SET;
        break;
      case XMPPBean.TYPE_RESULT:
        type = XMPPIQ.TYPE_RESULT;
        break;
      case XMPPBean.TYPE_ERROR:
        type = XMPPIQ.TYPE_ERROR;
        break;
    }

    XMPPIQ iq;

    if (mergePayload) iq = new XMPPIQ(bean.getFrom(), bean.getTo(), type, null, null, bean.toXML());
    else
      iq =
          new XMPPIQ(
              bean.getFrom(),
              bean.getTo(),
              type,
              bean.getChildElement(),
              bean.getNamespace(),
              bean.payloadToXML());

    iq.packetID = bean.getId();

    return iq;
  }