Search in sources :

Example 1 with ChatSettings

use of org.jivesoftware.smackx.workgroup.settings.ChatSettings in project Spark by igniterealtime.

the class WorkgroupManager method getChatSetting.

/**
 * Returns the chat settings for a particular workgroup.
 *
 * @param key           the key in the chat settings.
 * @param workgroupName the name of the workgroup
 * @return the <code>ChatSetting</code> found with the specified key.
 */
public ChatSetting getChatSetting(String key, String workgroupName) {
    ChatSettings settings = null;
    if (chatSettings.containsKey(workgroupName)) {
        settings = (ChatSettings) chatSettings.get(workgroupName);
    } else {
        XMPPConnection connection = SparkManager.getConnection();
        Workgroup workgroup = new Workgroup(workgroupName, connection);
        try {
            settings = workgroup.getChatSettings();
            chatSettings.put(workgroupName, settings);
        } catch (XMPPException | SmackException e) {
            Log.error("Error retrieving chat setting using key=" + key + " and workgroup=" + workgroupName, e);
        }
    }
    if (settings != null) {
        return settings.getChatSetting(key);
    }
    return null;
}
Also used : ChatSettings(org.jivesoftware.smackx.workgroup.settings.ChatSettings) SmackException(org.jivesoftware.smack.SmackException) XMPPConnection(org.jivesoftware.smack.XMPPConnection) Workgroup(org.jivesoftware.smackx.workgroup.user.Workgroup) XMPPException(org.jivesoftware.smack.XMPPException)

Example 2 with ChatSettings

use of org.jivesoftware.smackx.workgroup.settings.ChatSettings in project Smack by igniterealtime.

the class Workgroup method getChatSettings.

/**
 * Asks the workgroup for it's Chat Settings.
 *
 * @return key specify a key to retrieve only that settings. Otherwise for all settings, key should be null.
 * @throws NoResponseException if there was no response from the remote entity.
 * @throws XMPPErrorException if an error occurs while getting information from the server.
 * @throws NotConnectedException if the XMPP connection is not connected.
 * @throws InterruptedException if the calling thread was interrupted.
 */
private ChatSettings getChatSettings(String key, int type) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    ChatSettings request = new ChatSettings();
    if (key != null) {
        request.setKey(key);
    }
    if (type != -1) {
        request.setType(type);
    }
    request.setType(IQ.Type.get);
    request.setTo(workgroupJID);
    ChatSettings response = connection.sendIqRequestAndWaitForResponse(request);
    return response;
}
Also used : ChatSettings(org.jivesoftware.smackx.workgroup.settings.ChatSettings)

Aggregations

ChatSettings (org.jivesoftware.smackx.workgroup.settings.ChatSettings)2 SmackException (org.jivesoftware.smack.SmackException)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1 XMPPException (org.jivesoftware.smack.XMPPException)1 Workgroup (org.jivesoftware.smackx.workgroup.user.Workgroup)1