Ensure privmsg with mention of user's nick opens new query when appropriate

If a private message that should open a new query window contains a
mention of the user's nick, the expected new window fails to open
because the isMentioned() path tries to use
server.getConversation().setStatus(), and server.getConversation() is
null in this case.  Fix this by moving the attempt to highlight the
window to a point where a conversation is guaranteed to exist.
This commit is contained in:
Steven Luo 2011-05-29 17:48:47 -07:00 committed by Sebastian Kaspari
parent f1b57c9e25
commit caf3272f71
1 changed files with 28 additions and 25 deletions

View File

@ -203,24 +203,14 @@ public class IRCConnection extends PircBot
@Override
protected void onAction(String sender, String login, String hostname, String target, String action)
{
Conversation conversation;
Message message = new Message(sender + " " + action);
message.setIcon(R.drawable.action);
if (isMentioned(action)) {
// highlight
message.setColor(Message.COLOR_RED);
service.updateNotification(
target + ": " + sender + " " + action,
service.getSettings().isVibrateHighlightEnabled(),
service.getSettings().isSoundHighlightEnabled()
);
server.getConversation(target).setStatus(Conversation.STATUS_HIGHLIGHT);
}
if (target.equals(this.getNick())) {
// We are the target - this is an action in a query
Conversation conversation = server.getConversation(sender);
conversation = server.getConversation(sender);
if (conversation == null) {
// Open a query if there's none yet
conversation = new Query(sender);
@ -243,7 +233,8 @@ public class IRCConnection extends PircBot
}
} else {
// A action in a channel
server.getConversation(target).addMessage(message);
conversation = server.getConversation(target);
conversation.addMessage(message);
Intent intent = Broadcast.createConversationIntent(
Broadcast.CONVERSATION_MESSAGE,
@ -252,6 +243,18 @@ public class IRCConnection extends PircBot
);
service.sendBroadcast(intent);
}
if (isMentioned(action)) {
// highlight
message.setColor(Message.COLOR_RED);
service.updateNotification(
target + ": " + sender + " " + action,
service.getSettings().isVibrateHighlightEnabled(),
service.getSettings().isSoundHighlightEnabled()
);
conversation.setStatus(Conversation.STATUS_HIGHLIGHT);
}
}
/**
@ -580,17 +583,6 @@ public class IRCConnection extends PircBot
{
Message message = new Message("<" + sender + "> " + text);
if (isMentioned(text)) {
message.setColor(Message.COLOR_RED);
service.updateNotification(
"<" + sender + "> " + text,
service.getSettings().isVibrateHighlightEnabled(),
service.getSettings().isSoundHighlightEnabled()
);
server.getConversation(sender).setStatus(Conversation.STATUS_HIGHLIGHT);
}
Conversation conversation = server.getConversation(sender);
if (conversation == null) {
@ -615,6 +607,17 @@ public class IRCConnection extends PircBot
);
service.sendBroadcast(intent);
}
if (isMentioned(text)) {
message.setColor(Message.COLOR_RED);
service.updateNotification(
"<" + sender + "> " + text,
service.getSettings().isVibrateHighlightEnabled(),
service.getSettings().isSoundHighlightEnabled()
);
conversation.setStatus(Conversation.STATUS_HIGHLIGHT);
}
}
/**