Search in sources :

Example 1 with IRCConnection

use of f00f.net.irc.martyr.IRCConnection in project Openfire by igniterealtime.

the class IRCSession method logIn.

@Override
public void logIn(PresenceType presenceType, String verboseStatus) {
    connection = new IRCConnection();
    autoResponder = new AutoResponder(connection);
    //        autoReconnect = new AutoReconnect(connection);
    autoRegister = new AutoRegister(connection, getRegistration().getNickname(), getRegistration().getNickname(), "IM Gateway User", getRegistration().getPassword());
    listener = new IRCListener(this);
    listener.enable();
    new Thread() {

        @Override
        public void run() {
            try {
                connection.connect(JiveGlobals.getProperty("plugin.gateway.irc.connecthost", "irc.freenode.net"), JiveGlobals.getIntProperty("plugin.gateway.irc.connectport", 7000));
                setPresence(PresenceType.available);
                setLoginStatus(TransportLoginStatus.LOGGED_IN);
                try {
                    getTransport().syncLegacyRoster(getJID(), getBuddyManager().getBuddies());
                } catch (UserNotFoundException e) {
                    Log.debug("IRC: Error finding user while syncing legacy roster.");
                }
                List<String> buddyList = new ArrayList<String>();
                for (TransportBuddy buddy : getBuddyManager().getBuddies()) {
                    buddyList.add(buddy.getName());
                }
                if (!buddyList.isEmpty()) {
                    connection.sendCommand(new IsonCommand(StringUtils.join(buddyList, " ")));
                }
                statusCheck = new StatusCheck();
                timer.schedule(statusCheck, timerInterval, timerInterval);
                getBuddyManager().activate();
            } catch (UnknownHostException e) {
                Log.debug("IRC: Unable to connect to host:", e);
                setFailureStatus(ConnectionFailureReason.CAN_NOT_CONNECT);
                sessionDisconnected("IRC server does not appear to exist.");
            } catch (IOException e) {
                Log.debug("IRC: Connection error while trying to connect ot IRC server:", e);
                setFailureStatus(ConnectionFailureReason.CAN_NOT_CONNECT);
                sessionDisconnected("Connection failed while trying to contact IRC server..");
            }
        }
    }.start();
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) IsonCommand(f00f.net.irc.martyr.commands.IsonCommand) UnknownHostException(java.net.UnknownHostException) TransportBuddy(net.sf.kraken.roster.TransportBuddy) IOException(java.io.IOException) IRCConnection(f00f.net.irc.martyr.IRCConnection) AutoResponder(f00f.net.irc.martyr.services.AutoResponder) AutoRegister(f00f.net.irc.martyr.services.AutoRegister) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

IRCConnection (f00f.net.irc.martyr.IRCConnection)1 IsonCommand (f00f.net.irc.martyr.commands.IsonCommand)1 AutoRegister (f00f.net.irc.martyr.services.AutoRegister)1 AutoResponder (f00f.net.irc.martyr.services.AutoResponder)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TransportBuddy (net.sf.kraken.roster.TransportBuddy)1 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)1