|
|
|
@ -103,8 +103,8 @@ public IrcStack(final ProtocolProviderServiceIrcImpl parentProvider,
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public boolean isConnected()
|
|
|
|
public boolean isConnected()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (this.irc != null && this.connectionState != null && this.connectionState
|
|
|
|
return (this.irc != null && this.connectionState != null
|
|
|
|
.isConnected());
|
|
|
|
&& this.connectionState.isConnected());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -192,7 +192,8 @@ public void onFailure(Exception e)
|
|
|
|
while (!result.isDone())
|
|
|
|
while (!result.isDone())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGGER
|
|
|
|
LOGGER
|
|
|
|
.trace("Waiting for the connection to be established ...");
|
|
|
|
.trace("Waiting for the connection to be established "
|
|
|
|
|
|
|
|
+ "...");
|
|
|
|
result.wait();
|
|
|
|
result.wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -203,15 +204,16 @@ public void onFailure(Exception e)
|
|
|
|
&& this.connectionState.isConnected())
|
|
|
|
&& this.connectionState.isConnected())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if connecting succeeded, set state to registered
|
|
|
|
// if connecting succeeded, set state to registered
|
|
|
|
this.provider
|
|
|
|
this.provider.setCurrentRegistrationState(
|
|
|
|
.setCurrentRegistrationState(RegistrationState.REGISTERED);
|
|
|
|
RegistrationState.REGISTERED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if connecting failed, set state to unregistered and throw
|
|
|
|
// if connecting failed, set state to unregistered and throw
|
|
|
|
// the exception if one exists
|
|
|
|
// the exception if one exists
|
|
|
|
this.provider
|
|
|
|
this.provider
|
|
|
|
.setCurrentRegistrationState(RegistrationState.UNREGISTERED);
|
|
|
|
.setCurrentRegistrationState(
|
|
|
|
|
|
|
|
RegistrationState.UNREGISTERED);
|
|
|
|
Exception e = result.getException();
|
|
|
|
Exception e = result.getException();
|
|
|
|
if (e != null)
|
|
|
|
if (e != null)
|
|
|
|
throw e;
|
|
|
|
throw e;
|
|
|
|
@ -220,13 +222,15 @@ public void onFailure(Exception e)
|
|
|
|
catch (IOException e)
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.provider
|
|
|
|
this.provider
|
|
|
|
.setCurrentRegistrationState(RegistrationState.UNREGISTERED);
|
|
|
|
.setCurrentRegistrationState(
|
|
|
|
|
|
|
|
RegistrationState.UNREGISTERED);
|
|
|
|
throw e;
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (InterruptedException e)
|
|
|
|
catch (InterruptedException e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.provider
|
|
|
|
this.provider
|
|
|
|
.setCurrentRegistrationState(RegistrationState.UNREGISTERED);
|
|
|
|
.setCurrentRegistrationState(
|
|
|
|
|
|
|
|
RegistrationState.UNREGISTERED);
|
|
|
|
throw e;
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -336,7 +340,8 @@ public void setSubject(ChatRoomIrcImpl chatroom, String subject)
|
|
|
|
throw new IllegalArgumentException("Cannot have a null chatroom");
|
|
|
|
throw new IllegalArgumentException("Cannot have a null chatroom");
|
|
|
|
LOGGER.trace("Setting chat room topic to '" + subject + "'");
|
|
|
|
LOGGER.trace("Setting chat room topic to '" + subject + "'");
|
|
|
|
this.irc
|
|
|
|
this.irc
|
|
|
|
.changeTopic(chatroom.getIdentifier(), subject == null ? "" : subject);
|
|
|
|
.changeTopic(chatroom.getIdentifier(),
|
|
|
|
|
|
|
|
subject == null ? "" : subject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -442,7 +447,8 @@ public void join(final ChatRoomIrcImpl chatroom, final String password)
|
|
|
|
synchronized (joinSignal)
|
|
|
|
synchronized (joinSignal)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGGER
|
|
|
|
LOGGER
|
|
|
|
.trace("Issue join channel command to IRC library and wait for join operation to complete (un)successfully.");
|
|
|
|
.trace("Issue join channel command to IRC library and wait "
|
|
|
|
|
|
|
|
+ "for join operation to complete (un)successfully.");
|
|
|
|
// TODO Refactor this ridiculous nesting of functions and
|
|
|
|
// TODO Refactor this ridiculous nesting of functions and
|
|
|
|
// classes.
|
|
|
|
// classes.
|
|
|
|
this.irc.joinChannel(chatroom.getIdentifier(), password,
|
|
|
|
this.irc.joinChannel(chatroom.getIdentifier(), password,
|
|
|
|
@ -453,7 +459,8 @@ public void join(final ChatRoomIrcImpl chatroom, final String password)
|
|
|
|
public void onSuccess(IRCChannel channel)
|
|
|
|
public void onSuccess(IRCChannel channel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGGER
|
|
|
|
LOGGER
|
|
|
|
.trace("Started callback for successful join of channel '"
|
|
|
|
.trace("Started callback for successful join of "
|
|
|
|
|
|
|
|
+ "channel '"
|
|
|
|
+ chatroom.getIdentifier() + "'.");
|
|
|
|
+ chatroom.getIdentifier() + "'.");
|
|
|
|
ChatRoomIrcImpl actualChatRoom = chatroom;
|
|
|
|
ChatRoomIrcImpl actualChatRoom = chatroom;
|
|
|
|
synchronized (joinSignal)
|
|
|
|
synchronized (joinSignal)
|
|
|
|
@ -482,7 +489,8 @@ public void onSuccess(IRCChannel channel)
|
|
|
|
message,
|
|
|
|
message,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
new Date(),
|
|
|
|
new Date(),
|
|
|
|
MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
|
|
|
|
MessageReceivedEvent
|
|
|
|
|
|
|
|
.SYSTEM_MESSAGE_RECEIVED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IrcStack.this.joined.put(
|
|
|
|
IrcStack.this.joined.put(
|
|
|
|
@ -536,10 +544,12 @@ public void onSuccess(IRCChannel channel)
|
|
|
|
.getMUC()
|
|
|
|
.getMUC()
|
|
|
|
.fireLocalUserPresenceEvent(
|
|
|
|
.fireLocalUserPresenceEvent(
|
|
|
|
actualChatRoom,
|
|
|
|
actualChatRoom,
|
|
|
|
LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED,
|
|
|
|
LocalUserChatRoomPresenceChangeEvent
|
|
|
|
|
|
|
|
.LOCAL_USER_JOINED,
|
|
|
|
null);
|
|
|
|
null);
|
|
|
|
LOGGER
|
|
|
|
LOGGER
|
|
|
|
.trace("Finished successful join callback for channel '"
|
|
|
|
.trace("Finished successful join callback "
|
|
|
|
|
|
|
|
+ "for channel '"
|
|
|
|
+ chatroom.getIdentifier()
|
|
|
|
+ chatroom.getIdentifier()
|
|
|
|
+ "'. Waking up original thread.");
|
|
|
|
+ "'. Waking up original thread.");
|
|
|
|
// Notify waiting threads of finished
|
|
|
|
// Notify waiting threads of finished
|
|
|
|
@ -554,8 +564,9 @@ public void onSuccess(IRCChannel channel)
|
|
|
|
public void onFailure(Exception e)
|
|
|
|
public void onFailure(Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGGER
|
|
|
|
LOGGER
|
|
|
|
.trace("Started callback for failed attempt to join channel '"
|
|
|
|
.trace("Started callback for failed attempt to "
|
|
|
|
+ chatroom.getIdentifier() + "'.");
|
|
|
|
+ "join channel '" + chatroom.getIdentifier()
|
|
|
|
|
|
|
|
+ "'.");
|
|
|
|
// TODO how should we communicate a failed attempt
|
|
|
|
// TODO how should we communicate a failed attempt
|
|
|
|
// at joining the channel? (System messages don't
|
|
|
|
// at joining the channel? (System messages don't
|
|
|
|
// seem to show if there is no actual chat room
|
|
|
|
// seem to show if there is no actual chat room
|
|
|
|
@ -569,18 +580,21 @@ public void onFailure(Exception e)
|
|
|
|
"Failed to join channel "
|
|
|
|
"Failed to join channel "
|
|
|
|
+ chatroom.getIdentifier() + " ("
|
|
|
|
+ chatroom.getIdentifier() + " ("
|
|
|
|
+ e.getMessage() + ")",
|
|
|
|
+ e.getMessage() + ")",
|
|
|
|
"text/plain", "UTF-8", "Failed to join");
|
|
|
|
"text/plain", "UTF-8",
|
|
|
|
|
|
|
|
"Failed to join");
|
|
|
|
chatroom
|
|
|
|
chatroom
|
|
|
|
.fireMessageReceivedEvent(
|
|
|
|
.fireMessageReceivedEvent(
|
|
|
|
message,
|
|
|
|
message,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
new Date(),
|
|
|
|
new Date(),
|
|
|
|
MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
|
|
|
|
MessageReceivedEvent
|
|
|
|
|
|
|
|
.SYSTEM_MESSAGE_RECEIVED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGGER
|
|
|
|
LOGGER
|
|
|
|
.trace("Finished callback for failed attempt to join channel '"
|
|
|
|
.trace("Finished callback for failed "
|
|
|
|
|
|
|
|
+ "attempt to join channel '"
|
|
|
|
+ chatroom.getIdentifier()
|
|
|
|
+ chatroom.getIdentifier()
|
|
|
|
+ "'. Waking up original thread.");
|
|
|
|
+ "'. Waking up original thread.");
|
|
|
|
// Notify waiting threads of finished
|
|
|
|
// Notify waiting threads of finished
|
|
|
|
@ -957,7 +971,8 @@ public void onChannelPart(ChanPartMessage msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGGER
|
|
|
|
LOGGER
|
|
|
|
.warn(
|
|
|
|
.warn(
|
|
|
|
"This should not have happened. Please report this as it is a bug.",
|
|
|
|
"This should not have happened. Please report this "
|
|
|
|
|
|
|
|
+ "as it is a bug.",
|
|
|
|
e);
|
|
|
|
e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|