Ejemplo n.º 1
0
 @Override
 public void dispose() {
   synchronized (isQuittingLock) {
     if (isQuitting) {
       disposeRequested = true;
     } else {
       super.dispose();
     }
   }
 }
Ejemplo n.º 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();
      }
    }
  }
Ejemplo n.º 3
0
  /** On register */
  @Override
  public void onRegister() {
    // Call parent method to ensure "register" status is tracked
    super.onRegister();

    // execute commands
    CommandParser parser = CommandParser.getInstance();

    this.updateNickMatchPattern();
    for (String command : server.getConnectCommands()) {
      parser.parse(command, server, server.getConversation(ServerInfo.DEFAULT_NAME), service);
    }

    // TODO: Detect "You are now identified for <nick>" notices from NickServ and handle
    //       auto joins in onNotice instead if the user has chosen to wait for NickServ
    //       identification before auto joining channels.

    // delay 1 sec before auto joining channels
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      // do nothing
    }

    // join channels
    if (autojoinChannels != null) {
      for (String channel : autojoinChannels) {
        // Add support for channel keys
        joinChannel(channel);
      }
    } else {
      for (String channel : server.getAutoJoinChannels()) {
        joinChannel(channel);
      }
    }

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

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

    service.sendBroadcast(intent);
  }
Ejemplo n.º 4
0
  protected void onDisconnect() {
    // TODO Auto-generated method stub
    super.onDisconnect();
    while (true) {

      try {
        Thread.sleep(60000);
        reconnect();
      } catch (NickAlreadyInUseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IrcException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
Ejemplo n.º 5
0
 private final void superClassQuitServer(String message) {
   super.quitServer(message);
 }
Ejemplo n.º 6
0
 protected void onJoin(String channel, String sender, String login, String hostname) {
   super.onJoin(channel, sender, login, hostname);
   if (sender.equals(this.getName()) && !quiet)
     this.sendMessage(channel, "Hello, I am a bot. Say \"!tweet\" and I will tweet what you say.");
 }