use of org.jivesoftware.sparkimpl.plugin.gateways.GatewayPlugin in project Spark by igniterealtime.
the class Workspace method loadPlugins.
/**
* Starts the Loading of all Spark Plugins.
*/
public void loadPlugins() {
// Send Available status
SparkManager.getSessionManager().changePresence(statusBox.getPresence());
// Add presence and message listeners
// we listen for these to force open a 1-1 peer chat window from other operators if
// one isn't already open
StanzaFilter workspaceMessageFilter = new StanzaTypeFilter(Message.class);
// Add the packetListener to this instance
SparkManager.getSessionManager().getConnection().addAsyncStanzaListener(this, workspaceMessageFilter);
// Make presence available to anonymous requests, if from anonymous user in the system.
StanzaListener workspacePresenceListener = stanza -> {
Presence presence = (Presence) stanza;
JivePropertiesExtension extension = (JivePropertiesExtension) presence.getExtension(JivePropertiesExtension.NAMESPACE);
if (extension != null && extension.getProperty("anonymous") != null) {
boolean isAvailable = statusBox.getPresence().getMode() == Presence.Mode.available;
Presence reply = new Presence(Presence.Type.available);
if (!isAvailable) {
reply.setType(Presence.Type.unavailable);
}
reply.setTo(presence.getFrom());
try {
SparkManager.getSessionManager().getConnection().sendStanza(reply);
} catch (SmackException.NotConnectedException e) {
Log.warning("Unable to send presence reply to " + reply.getTo(), e);
}
}
};
SparkManager.getSessionManager().getConnection().addAsyncStanzaListener(workspacePresenceListener, new StanzaTypeFilter(Presence.class));
// Until we have better plugin management, will init after presence updates.
gatewayPlugin = new GatewayPlugin();
gatewayPlugin.initialize();
// Load all non-presence related items.
conferences.loadConferenceBookmarks();
SearchManager.getInstance();
transcriptPlugin = new ChatTranscriptPlugin();
// Load Broadcast Plugin
broadcastPlugin = new BroadcastPlugin();
broadcastPlugin.initialize();
// Load BookmarkPlugin
bookmarkPlugin = new BookmarkPlugin();
bookmarkPlugin.initialize();
// Schedule loading of the plugins after two seconds.
TaskEngine.getInstance().schedule(new TimerTask() {
public void run() {
final PluginManager pluginManager = PluginManager.getInstance();
SparkManager.getMainWindow().addMainWindowListener(pluginManager);
pluginManager.initializePlugins();
// Subscriptions are always manual
Roster roster = Roster.getInstanceFor(SparkManager.getConnection());
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
}
}, 2000);
// Check URI Mappings
SparkManager.getChatManager().handleURIMapping(Spark.ARGUMENTS);
}
Aggregations