1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-30 04:42:18 -05:00

CommandParser and CommandHandlers: Use Broadcast helper methods

This commit is contained in:
Sebastian Kaspari 2010-03-24 19:31:59 +01:00
parent 976ef4f598
commit c66eeecb0b
7 changed files with 42 additions and 24 deletions

View File

@ -143,9 +143,12 @@ public class CommandParser
Message usageMessage = new Message("Syntax: " + command.getUsage());
conversation.addMessage(usageMessage);
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
Intent intent = Broadcast.createConversationIntent(
Broadcast.CONVERSATION_MESSAGE,
server.getId(),
conversation.getName()
);
service.sendBroadcast(intent);
}
}
@ -162,9 +165,12 @@ public class CommandParser
message.setColor(Message.COLOR_RED);
conversation.addMessage(message);
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
Intent intent = Broadcast.createConversationIntent(
Broadcast.CONVERSATION_MESSAGE,
server.getId(),
conversation.getName()
);
service.sendBroadcast(intent);
}
}

View File

@ -55,9 +55,11 @@ public class CloseHandler extends BaseHandler
if (conversation.getType() == Conversation.TYPE_QUERY) {
server.removeConversation(conversation.getName());
Intent intent = new Intent(Broadcast.CONVERSATION_REMOVE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
Intent intent = Broadcast.createConversationIntent(
Broadcast.CONVERSATION_REMOVE,
server.getId(),
conversation.getName()
);
service.sendBroadcast(intent);
}
}

View File

@ -47,9 +47,11 @@ public class EchoHandler extends BaseHandler
Message message = new Message(BaseHandler.mergeParams(params));
conversation.addMessage(message);
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
Intent intent = Broadcast.createConversationIntent(
Broadcast.CONVERSATION_REMOVE,
server.getId(),
conversation.getName()
);
service.sendBroadcast(intent);
} else {
throw new CommandException("Text is missing");

View File

@ -56,9 +56,11 @@ public class MeHandler extends BaseHandler
message.setIcon(R.drawable.action);
server.getConversation(conversation.getName()).addMessage(message);
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
Intent intent = Broadcast.createConversationIntent(
Broadcast.CONVERSATION_REMOVE,
server.getId(),
conversation.getName()
);
service.sendBroadcast(intent);
service.getConnection(server.getId()).sendAction(conversation.getName(), action);

View File

@ -60,9 +60,11 @@ public class NamesHandler extends BaseHandler
message.setColor(Message.COLOR_YELLOW);
conversation.addMessage(message);
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
Intent intent = Broadcast.createConversationIntent(
Broadcast.CONVERSATION_REMOVE,
server.getId(),
conversation.getName()
);
service.sendBroadcast(intent);
}

View File

@ -53,9 +53,11 @@ public class NoticeHandler extends BaseHandler
message.setIcon(R.drawable.info);
conversation.addMessage(message);
Intent intent = new Intent(Broadcast.CONVERSATION_MESSAGE);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CONVERSATION, conversation.getName());
Intent intent = Broadcast.createConversationIntent(
Broadcast.CONVERSATION_REMOVE,
server.getId(),
conversation.getName()
);
service.sendBroadcast(intent);
service.getConnection(server.getId()).sendNotice(params[1], text);

View File

@ -59,9 +59,11 @@ public class QueryHandler extends BaseHandler
server.addConversationl(new Query(params[1]));
Intent intent = new Intent(Broadcast.CONVERSATION_NEW);
intent.putExtra(Broadcast.EXTRA_SERVER, server.getId());
intent.putExtra(Broadcast.EXTRA_CONVERSATION, params[1]);
Intent intent = Broadcast.createConversationIntent(
Broadcast.CONVERSATION_REMOVE,
server.getId(),
conversation.getName()
);
service.sendBroadcast(intent);
} else {
throw new CommandException("Invalid number of params");