示例#1
0
  /**
   * Send an XMPPBean of type ERROR.
   *
   * <p>TODO: Option for custom ERROR tag and text is missing.
   *
   * @param inBean the XMPPBean to reply with an ERROR. The playload will be copied.
   */
  public void sendXMPPBeanError(XMPPBean inBean) {
    XMPPBean resultBean = inBean.clone();
    resultBean.setTo(inBean.getFrom());
    resultBean.setFrom(mMXAProxy.getXmppJid());
    resultBean.setType(XMPPBean.TYPE_ERROR);

    _proxy.getBindingStub().sendXMPPBean(resultBean);
  }
示例#2
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;
  }
示例#3
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;
  }