예제 #1
0
  /** On connect */
  @Override
  public void onConnect() {
    server.setStatus(Status.CONNECTED);

    server.setMayReconnect(true);

    ignoreMOTD = service.getSettings().isIgnoreMOTDEnabled();

    service.sendBroadcast(Broadcast.createServerIntent(Broadcast.SERVER_UPDATE, server.getId()));

    service.notifyConnected(server.getTitle());

    Message message = new Message(service.getString(R.string.message_connected, server.getTitle()));
    message.setColor(Message.COLOR_GREEN);
    server.getConversation(ServerInfo.DEFAULT_NAME).addMessage(message);

    Message infoMessage = new Message(service.getString(R.string.message_now_login));
    infoMessage.setColor(Message.COLOR_GREY);
    server.getConversation(ServerInfo.DEFAULT_NAME).addMessage(infoMessage);

    Intent intent =
        Broadcast.createConversationIntent(
            Broadcast.CONVERSATION_MESSAGE, server.getId(), ServerInfo.DEFAULT_NAME);

    if (server.getAuthentication().hasNickservCredentials()) {
      identify(server.getAuthentication().getNickservPassword());
    }

    service.sendBroadcast(intent);
  }
예제 #2
0
  /** On disconnect */
  @Override
  public void onDisconnect() {
    // Call parent method to ensure "register" status is tracked
    super.onDisconnect();

    if (service.getSettings().isReconnectEnabled() && server.getStatus() != Status.DISCONNECTED) {
      setAutojoinChannels(server.getCurrentChannelNames());

      server.setStatus(Status.CONNECTING);
      service.connect(server);
    } else {
      server.setStatus(Status.DISCONNECTED);
    }

    service.notifyDisconnected(server.getTitle());

    Intent sIntent = Broadcast.createServerIntent(Broadcast.SERVER_UPDATE, server.getId());
    service.sendBroadcast(sIntent);

    Collection<Conversation> conversations = server.getConversations();

    for (Conversation conversation : conversations) {
      Message message = new Message(service.getString(R.string.message_disconnected));
      message.setIcon(R.drawable.error);
      message.setColor(Message.COLOR_RED);
      server.getConversation(conversation.getName()).addMessage(message);

      Intent cIntent =
          Broadcast.createConversationIntent(
              Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName());
      service.sendBroadcast(cIntent);
    }

    synchronized (isQuittingLock) {
      isQuitting = false;
      if (disposeRequested) {
        super.dispose();
      }
    }
  }