Style and comment tweaks.

fix-message-formatting
Danny van Heumen 11 years ago
parent c63dc31896
commit 6059ab6164

@ -1,13 +1,14 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license. See terms of license at gnu.org.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.protocol.irc;
/**
* IRC color codes that can be specified in the color control code.
*
*
* @author Danny van Heumen
*/
public enum Color
@ -36,17 +37,17 @@ public enum Color
/**
* Constructor for enum entries.
*
*
* @param html HTML representation for color
*/
private Color(String html)
private Color(final String html)
{
this.html = html;
}
/**
* Get the HTML representation of this color.
*
*
* @return returns html representation or null if none exist
*/
public String getHtml()

@ -31,13 +31,6 @@
*
* TODO Do we need to cancel any join channel operations still in progress?
*
* TODO Is there a chance that any Listeners will remain active after
* disconnecting?
*
* TODO Create a separate session object that stores: IRCApi instance +
* connection state + channel list container, such that it is easy to check for
* connectivity and manage state.
*
* @author Danny van Heumen
*/
public class IrcStack
@ -194,15 +187,7 @@ public void connect(final String host, final int port,
{
// If tracing is enabled, register another listener that logs
// all IRC messages as published by the IRC client library.
irc.addListener(new IMessageListener()
{
@Override
public void onMessage(final IMessage aMessage)
{
LOGGER.trace("(" + aMessage + ") " + aMessage.asRaw());
}
});
irc.addListener(new DebugListener());
}
connectSynchronized();
@ -635,7 +620,8 @@ public void onSuccess(final IRCChannel channel)
.getMUC()
.fireLocalUserPresenceEvent(
chatroom,
LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOIN_FAILED,
LocalUserChatRoomPresenceChangeEvent
.LOCAL_USER_JOIN_FAILED,
"We got forwarded to channel '"
+ channel.getName() + "'.");
// Notify waiting threads of finished execution.
@ -651,7 +637,8 @@ public void onSuccess(final IRCChannel channel)
try
{
IrcStack.this.joined.put(chatRoomId, chatroom);
irc.addListener(new ChatRoomListener(irc, chatroom));
irc.addListener(
new ChatRoomListener(irc, chatroom));
prepareChatRoom(chatroom, channel);
}
finally
@ -666,7 +653,8 @@ public void onSuccess(final IRCChannel channel)
.getMUC()
.fireLocalUserPresenceEvent(
chatroom,
LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED,
LocalUserChatRoomPresenceChangeEvent
.LOCAL_USER_JOINED,
null);
if (LOGGER.isTraceEnabled())
{
@ -696,7 +684,8 @@ public void onFailure(final Exception e)
.getMUC()
.fireLocalUserPresenceEvent(
chatroom,
LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOIN_FAILED,
LocalUserChatRoomPresenceChangeEvent
.LOCAL_USER_JOIN_FAILED,
e.getMessage());
}
finally
@ -2175,6 +2164,26 @@ private String parse(final String text)
}
}
/**
* Listener for debugging purposes. If logging level is set high enough,
* this listener is added to the irc-api client so it can show all IRC
* messages as they are handled.
*
* @author Danny van Heumen
*/
private static final class DebugListener implements IMessageListener
{
/**
* {@inheritDoc}
*/
@Override
public void onMessage(final IMessage aMessage)
{
LOGGER.trace("(" + aMessage + ") " + aMessage.asRaw());
}
}
/**
* Container for storing server parameters.
*/

@ -18,12 +18,13 @@
*
* @author Stephane Remy
* @author Loic Kempf
* @author Danny van Heumen
*/
public class ProtocolProviderFactoryIrcImpl
extends ProtocolProviderFactory
{
/**
* Constructor
* Constructor.
*/
public ProtocolProviderFactoryIrcImpl()
{
@ -42,22 +43,28 @@ public ProtocolProviderFactoryIrcImpl()
* @return the AccountID of the newly created account.
*/
@Override
public AccountID installAccount( String userIDStr,
Map<String, String> accountProperties)
public AccountID installAccount(final String userIDStr,
final Map<String, String> accountProperties)
{
BundleContext context = IrcActivator.getBundleContext();
if (context == null)
{
throw new NullPointerException(
"The specified BundleContext was null");
}
if (userIDStr == null)
{
throw new NullPointerException(
"The specified AccountID was null");
}
if (accountProperties == null)
{
throw new NullPointerException(
"The specified property map was null");
}
accountProperties.put(USER_ID, userIDStr);
final String host =
@ -69,8 +76,10 @@ public AccountID installAccount( String userIDStr,
//make sure we haven't seen this account id before.
if (registeredAccounts.containsKey(accountID))
{
throw new IllegalStateException(
"An account for id " + userIDStr + " was already installed!");
}
//first store the account and only then load it as the load generates
//an OSGI event, the OSGI event triggers (through the UI) a call to the
@ -85,12 +94,12 @@ public AccountID installAccount( String userIDStr,
/**
* Create an IRC Account ID.
*
*
* {@inheritDoc}
*/
@Override
protected AccountID createAccountID(String userID,
Map<String, String> accountProperties)
protected AccountID createAccountID(final String userID,
final Map<String, String> accountProperties)
{
final String host =
accountProperties.get(ProtocolProviderFactory.SERVER_ADDRESS);
@ -101,12 +110,12 @@ protected AccountID createAccountID(String userID,
/**
* Create an IRC provider service.
*
*
* {@inheritDoc}
*/
@Override
protected ProtocolProviderService createService(String userID,
AccountID accountID)
protected ProtocolProviderService createService(final String userID,
final AccountID accountID)
{
ProtocolProviderServiceIrcImpl service =
new ProtocolProviderServiceIrcImpl();
@ -117,12 +126,12 @@ protected ProtocolProviderService createService(String userID,
/**
* Modify an existing IRC account.
*
*
* {@inheritDoc}
*/
@Override
public void modifyAccount(ProtocolProviderService protocolProvider,
Map<String, String> accountProperties)
public void modifyAccount(final ProtocolProviderService protocolProvider,
final Map<String, String> accountProperties)
{
// not implemented, modified accounts currently get reinstalled as
// "newly" created accounts.

@ -15,10 +15,16 @@
*
* @author Loic Kempf
* @author Stephane Remy
* @author Danny van Heumen
*/
public class ProtocolProviderServiceIrcImpl
extends AbstractProtocolProviderService
{
/**
* The default secure IRC server port.
*/
private static final int DEFAULT_SECURE_IRC_PORT = 6697;
/**
* Logger.
*/
@ -77,7 +83,9 @@ public class ProtocolProviderServiceIrcImpl
public ProtocolProviderServiceIrcImpl()
{
if (LOGGER.isTraceEnabled())
{
LOGGER.trace("Creating a irc provider.");
}
}
/**
@ -93,19 +101,19 @@ public ProtocolProviderServiceIrcImpl()
*
* @see net.java.sip.communicator.service.protocol.AccountID
*/
protected void initialize(String userID, AccountID accountID)
protected void initialize(final String userID, final AccountID accountID)
{
synchronized(initializationLock)
synchronized (initializationLock)
{
this.accountID = accountID;
//Initialize the multi user chat support
multiUserChat = new OperationSetMultiUserChatIrcImpl(this);
addSupportedOperationSet(
OperationSetMultiUserChat.class,
multiUserChat);
// Initialize basic instant messaging
this.instantMessaging =
new OperationSetBasicInstantMessagingIrcImpl(this);
@ -123,33 +131,33 @@ protected void initialize(String userID, AccountID accountID)
// TODO Implement OperationSetServerStoredAccountInfo so we can
// suggest a display name to use when adding new chat rooms?
userID = getAccountID().getUserID();
final String user = getAccountID().getUserID();
ircStack
= new IrcStack(
this,
userID,
userID,
user,
user,
"Jitsi",
userID);
user);
isInitialized = true;
}
}
/**
* Get the Multi User Chat implementation.
*
*
* @return returns the Multi User Chat implementation
*/
public OperationSetMultiUserChatIrcImpl getMUC()
{
return this.multiUserChat;
}
/**
* Get the Basic Instant Messaging implementation.
*
*
* @return returns the Basic Instant Messaging implementation
*/
public OperationSetBasicInstantMessagingIrcImpl getBasicInstantMessaging()
@ -159,7 +167,7 @@ public OperationSetBasicInstantMessagingIrcImpl getBasicInstantMessaging()
/**
* Get the Persistent Presence implementation.
*
*
* @return returns the Persistent Presence implementation.
*/
public OperationSetPersistentPresenceIrcImpl getPersistentPresence()
@ -202,7 +210,6 @@ public RegistrationState getRegistrationState()
{
return currentRegistrationState;
}
/**
* Starts the registration process.
@ -214,7 +221,7 @@ public RegistrationState getRegistrationState()
* registration fails for some reason (e.g. a networking error or an
* implementation problem).
*/
public void register(SecurityAuthority authority)
public void register(final SecurityAuthority authority)
throws OperationFailedException
{
AccountID accountID = getAccountID();
@ -226,7 +233,7 @@ public void register(SecurityAuthority authority)
= accountID
.getAccountPropertyInt(
ProtocolProviderFactory.SERVER_PORT,
6697);
DEFAULT_SECURE_IRC_PORT);
//Verify whether a password has already been stored for this account
String serverPassword = IrcActivator.
getProtocolProviderFactory().loadPassword(getAccountID());
@ -299,19 +306,21 @@ public void register(SecurityAuthority authority)
*/
public void shutdown()
{
if(!isInitialized)
if (!isInitialized)
{
return;
}
if (LOGGER.isTraceEnabled())
{
LOGGER.trace("Killing the Irc Protocol Provider.");
}
if(isRegistered())
if (isRegistered())
{
try
{
//do the un-registration
synchronized(this.initializationLock)
synchronized (this.initializationLock)
{
unregister();
this.ircStack.dispose();
@ -344,18 +353,23 @@ public void unregister()
{
for (ChatRoom joinedChatRoom
: multiUserChat.getCurrentlyJoinedChatRooms())
{
joinedChatRoom.leave();
}
if (ircStack.isConnected())
{
ircStack.disconnect();
}
}
/*
* (non-Javadoc)
/**
* {@inheritDoc}
*
* @see net.java.sip.communicator.service.protocol.ProtocolProviderService#
* isSignallingTransportSecure()
* @return returns true in case of secure transport, or false if transport
* is not secure
*/
@Override
public boolean isSignalingTransportSecure()
{
return this.ircStack.isSecureConnection();
@ -408,9 +422,9 @@ protected RegistrationState getCurrentRegistrationState()
* @param regState the new registration state to set
*/
protected void setCurrentRegistrationState(
RegistrationState regState)
final RegistrationState regState)
{
RegistrationState oldState = this.currentRegistrationState;
final RegistrationState oldState = this.currentRegistrationState;
this.currentRegistrationState = regState;

@ -1,7 +1,8 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license. See terms of license at gnu.org.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.protocol.irc;

@ -0,0 +1,10 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
/**
* This package contains an IRC protocol implementation for Jitsi.
*/
package net.java.sip.communicator.impl.protocol.irc;
Loading…
Cancel
Save