001/**
002 *
003 * Copyright © 2014-2015 Florian Schmaus
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smackx.muc;
018
019import org.jivesoftware.smack.SmackException;
020
021import org.jxmpp.jid.DomainBareJid;
022
023public abstract class MultiUserChatException extends SmackException {
024
025    protected MultiUserChatException() {
026    }
027
028    protected MultiUserChatException(String message) {
029        super(message);
030    }
031
032    /**
033     *
034     */
035    private static final long serialVersionUID = 1L;
036
037    // This could eventually become an unchecked exception. But be aware that it's required in the
038    // control flow of MultiUserChat.createOrJoinIfNecessary
039    public static class MucAlreadyJoinedException extends MultiUserChatException {
040
041        /**
042         *
043         */
044        private static final long serialVersionUID = 1L;
045
046    }
047
048    /**
049     * Thrown if the requested operation required the MUC to be joined by the
050     * client, while the client is currently joined.
051     *
052     */
053    public static class MucNotJoinedException extends MultiUserChatException {
054
055        /**
056         *
057         */
058        private static final long serialVersionUID = 1L;
059
060        public MucNotJoinedException(MultiUserChat multiUserChat) {
061            super("Client not currently joined " + multiUserChat.getRoom());
062        }
063    }
064
065    public static class MissingMucCreationAcknowledgeException extends MultiUserChatException {
066
067        /**
068         *
069         */
070        private static final long serialVersionUID = 1L;
071
072    }
073
074    /**
075     * Thrown if the MUC room does not support the requested configuration option.
076     */
077    public static class MucConfigurationNotSupportedException extends MultiUserChatException {
078
079        /**
080         *
081         */
082        private static final long serialVersionUID = 1L;
083
084        public MucConfigurationNotSupportedException(String configString) {
085            super("The MUC configuration '" + configString + "' is not supported by the MUC service");
086        }
087    }
088
089    /**
090     * Thrown when trying to enter a MUC room that is not hosted a domain providing a MUC service.
091     * Try {@link MultiUserChatManager#getXMPPServiceDomains()} for a list of client-local domains
092     * providing a MUC service.
093     */
094    public static class NotAMucServiceException extends MultiUserChatException {
095
096        /**
097         *
098         */
099        private static final long serialVersionUID = 1L;
100
101        NotAMucServiceException(DomainBareJid service) {
102            super("Can't perform operation because " + service
103                            + " does not provide a MUC (XEP-45) service.");
104        }
105
106        NotAMucServiceException(MultiUserChat multiUserChat) {
107            super("Can not join '" + multiUserChat.getRoom() + "', because '"
108                            + multiUserChat.getRoom().asDomainBareJid()
109                            + "' does not provide a MUC (XEP-45) service.");
110        }
111    }
112}