Java 类org.jivesoftware.smack.SmackException.FeatureNotSupportedException 实例源码

项目:maxs    文件:XMPPService.java   
public void notifyAboutNewMasterAddress(final EntityBareJid newMasterAddress) {
    final XMPPConnection connection = getConnection();
    if (connection == null || !connection.isAuthenticated()) {
        return;
    }

    final Roster roster = Roster.getInstanceFor(connection);

    Async.go(new ThrowingRunnable() {
        @Override
        public void runOrThrow() throws NotLoggedInException, NotConnectedException,
                FeatureNotSupportedException, InterruptedException {
            if (roster.isSubscriptionPreApprovalSupported()) {
                roster.preApprove(newMasterAddress);
            }
            RosterUtil.askForSubscriptionIfRequired(roster, newMasterAddress);
        }
    });
}
项目:Smack    文件:MultipleRecipientManager.java   
/**
 * Sends the specified stanza(/packet) to the collection of specified recipients using the specified
 * connection. If the server has support for XEP-33 then only one stanza(/packet) is going to be sent to
 * the server with the multiple recipient instructions. However, if XEP-33 is not supported by
 * the server then the client is going to send the stanza(/packet) to each recipient.
 * 
 * @param connection the connection to use to send the packet.
 * @param packet the stanza(/packet) to send to the list of recipients.
 * @param to the collection of JIDs to include in the TO list or <tt>null</tt> if no TO list exists.
 * @param cc the collection of JIDs to include in the CC list or <tt>null</tt> if no CC list exists.
 * @param bcc the collection of JIDs to include in the BCC list or <tt>null</tt> if no BCC list
 *        exists.
 * @param replyTo address to which all replies are requested to be sent or <tt>null</tt>
 *        indicating that they can reply to any address.
 * @param replyRoom JID of a MUC room to which responses should be sent or <tt>null</tt>
 *        indicating that they can reply to any address.
 * @param noReply true means that receivers should not reply to the message.
 * @throws XMPPErrorException if server does not support XEP-33: Extended Stanza Addressing and
 *         some XEP-33 specific features were requested.
 * @throws NoResponseException if there was no response from the server.
 * @throws FeatureNotSupportedException if special XEP-33 features where requested, but the
 *         server does not support them.
 * @throws NotConnectedException 
 */
public static void send(XMPPConnection connection, Stanza packet, Collection<String> to, Collection<String> cc, Collection<String> bcc,
        String replyTo, String replyRoom, boolean noReply) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException {
    // Check if *only* 'to' is set and contains just *one* entry, in this case extended stanzas addressing is not
    // required at all and we can send it just as normal stanza without needing to add the extension element
    if (to != null && to.size() == 1 && (cc == null || cc.isEmpty()) && (bcc == null || bcc.isEmpty()) && !noReply
                    && StringUtils.isNullOrEmpty(replyTo) && StringUtils.isNullOrEmpty(replyRoom)) {
        String toJid = to.iterator().next();
        packet.setTo(toJid);
        connection.sendStanza(packet);
        return;
    }
    String serviceAddress = getMultipleRecipienServiceAddress(connection);
    if (serviceAddress != null) {
        // Send packet to target users using multiple recipient service provided by the server
        sendThroughService(connection, packet, to, cc, bcc, replyTo, replyRoom, noReply,
                serviceAddress);
    }
    else {
        // Server does not support XEP-33 so try to send the packet to each recipient
        if (noReply || (replyTo != null && replyTo.trim().length() > 0) ||
                (replyRoom != null && replyRoom.trim().length() > 0)) {
            // Some specified XEP-33 features were requested so throw an exception alerting
            // the user that this features are not available
            throw new FeatureNotSupportedException("Extended Stanza Addressing");
        }
        // Send the packet to each individual recipient
        sendToIndividualRecipients(connection, packet, to, cc, bcc);
    }
}
项目:Smack    文件:MultipleRecipientManager.java   
/**
  * Sends the specified stanza(/packet) to the collection of specified recipients using the
  * specified connection. If the server has support for XEP-33 then only one
  * stanza(/packet) is going to be sent to the server with the multiple recipient instructions.
  * However, if XEP-33 is not supported by the server then the client is going to send
  * the stanza(/packet) to each recipient.
  *
  * @param connection the connection to use to send the packet.
  * @param packet     the stanza(/packet) to send to the list of recipients.
  * @param to         the collection of JIDs to include in the TO list or <tt>null</tt> if no TO
  *                   list exists.
  * @param cc         the collection of JIDs to include in the CC list or <tt>null</tt> if no CC
  *                   list exists.
  * @param bcc        the collection of JIDs to include in the BCC list or <tt>null</tt> if no BCC
  *                   list exists.
  * @throws FeatureNotSupportedException if special XEP-33 features where requested, but the
  *         server does not support them.
  * @throws XMPPErrorException if server does not support XEP-33: Extended Stanza Addressing and
  *                       some XEP-33 specific features were requested.
  * @throws NoResponseException if there was no response from the server.
  * @throws NotConnectedException 
  */
 public static void send(XMPPConnection connection, Stanza packet, Collection<String> to, Collection<String> cc, Collection<String> bcc) throws NoResponseException, XMPPErrorException, FeatureNotSupportedException, NotConnectedException
{
     send(connection, packet, to, cc, bcc, null, null, false);
 }