示例#1
0
  public void onDisconnect() {

    if (ManagerConnectionState.CONNECTED == this.managerConnection.getState()) {
      this.managerConnection.logoff();
      txtEvents = "Disconnected from: " + ip + ":" + port;
      conteudo.setJlConnection(txtEvents);
    }
  }
示例#2
0
  public void kSendUuiMessage() {
    String device = conteudo.getUuiDevice();
    String protocol = conteudo.getUuiProtocol();
    String length = conteudo.getUuiLength();
    String data = conteudo.getUuiData();

    String uuiParam;

    KSendUUIAction action;
    action = new KSendUUIAction();

    if (!device.equals("") && !data.equals("") && !protocol.equals("") && !length.equals("")) {

      action.setData(data);
      action.setDevice(device);
      action.setLength(length);
      action.setProtocol(protocol);

      uuiParam =
          ("Dial(Khomp/"
              + action.getDevice()
              + "/"
              + action.getProtocol()
              + "/"
              + action.getLength()
              + "/"
              + action.getData()
              + ")");

      if (ManagerConnectionState.CONNECTED == this.managerConnection.getState()) {
        try {
          managerConnection.sendAction(action, sendCB);
          System.out.println("Sending UUI message to " + device);
          this.changeInfo(uuiParam);
        } catch (IOException | IllegalArgumentException | IllegalStateException ex) {
          Logger.getLogger(Aplicacao.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    } else {
      System.out.println("Existem valores em branco!");
    }
  }
示例#3
0
  public void kSendPresentation() {
    String channel = conteudo.getChannel();
    String presentation = conteudo.getPresentation();
    String presentationParam;

    KGSMPresentationAction action;
    action = new KGSMPresentationAction();

    if (!channel.equals("") && !presentation.equals("")) {

      action.setChannel(channel);
      action.setPresentation(presentation);

      presentationParam =
          ("Action: "
              + action.getAction()
              + CRLF
              + "channel: "
              + action.getChannel()
              + CRLF
              + "presentation: "
              + action.getPresentation()
              + CRLF
              + CRLF);

      if (ManagerConnectionState.CONNECTED == this.managerConnection.getState()) {
        try {
          managerConnection.sendAction(action, sendCB);
          System.out.println("Sending Presentation: " + presentation + " to channel: " + channel);
          this.changeInfo(presentationParam);
        } catch (IOException | IllegalArgumentException | IllegalStateException ex) {
          Logger.getLogger(Aplicacao.class.getName()).log(Level.SEVERE, null, ex);
        }
      } else {
        JOptionPane.showMessageDialog(telaPrincipal, "Necessário conectar primeiro!");
      }
    } else {
      System.out.println("Existem valores em branco!");
    }
  }
示例#4
0
  public void kSendUssdMessage() {

    String device = conteudo.getUSSDDevice();
    String message = conteudo.getUSSDMessage();
    String ussdParam;

    KSendUSSDAction action;
    action = new KSendUSSDAction();

    if (!device.equals("") && !message.equals("")) {

      action.setDevice(device);
      action.setMessage(message);

      ussdParam =
          ("Action: "
              + action.getAction()
              + CRLF
              + "device: "
              + action.getDevice()
              + CRLF
              + "message: "
              + action.getMessage()
              + CRLF
              + CRLF);

      if (ManagerConnectionState.CONNECTED == this.managerConnection.getState()) {
        try {
          managerConnection.sendAction(action, sendCB);
          System.out.println("Sending USSD message to " + device);
          this.changeInfo(ussdParam);
        } catch (IOException | IllegalArgumentException | IllegalStateException ex) {
          Logger.getLogger(Aplicacao.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    } else {
      System.out.println("Existem valores em branco!");
    }
  }
示例#5
0
  public void kSendSimCardSelection() {

    String channel = conteudo.getSimCardChannel();
    int simCard = conteudo.getSimCardSelected();
    String selectionParam;

    KSelectSIMcardAction action;
    action = new KSelectSIMcardAction();

    if (!channel.equals("") && simCard > -1) {

      action.setChannel(channel);
      action.setSIMCard(simCard);

      selectionParam =
          ("Action: "
              + action.getAction()
              + CRLF
              + "channel: "
              + action.getChannel()
              + CRLF
              + "simcard: "
              + action.getSIMCard()
              + CRLF
              + CRLF);

      if (ManagerConnectionState.CONNECTED == this.managerConnection.getState()) {
        try {
          managerConnection.sendAction(action, sendCB);
          System.out.println("Changind SIM card to: SIMcard: " + simCard);
          this.changeInfo(selectionParam);
        } catch (IOException | IllegalArgumentException | IllegalStateException ex) {
          Logger.getLogger(Aplicacao.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    } else {
      System.out.println("Existem valores em branco!");
    }
  }
示例#6
0
  public boolean kSendSMS() {

    String channel = conteudo.getChannel();
    String text = conteudo.getSmsText();
    String destination = conteudo.getNumber();
    String context = conteudo.getContext();
    String tech = conteudo.getTech();
    boolean back = false;
    String smsParam;
    boolean confirmation = conteudo.getConfirmation();

    KSendSMSAction action;
    action = new KSendSMSAction();

    if (!destination.equals("") && !channel.equals("") && !text.equals("")) {

      action.setDevice(channel);
      action.setDestination(destination);
      action.setMessage(text);
      action.setConfirmation(confirmation);

      smsParam =
          ("Action: "
              + action.getAction()
              + CRLF
              + "device: "
              + action.getDevice()
              + CRLF
              + "destination: "
              + action.getDestination()
              + CRLF
              + "Message: "
              + action.getMessage()
              + CRLF
              + "Confirmation: "
              + action.getConfirmation()
              + CRLF
              + CRLF);

      if (ManagerConnectionState.CONNECTED == this.managerConnection.getState()) {
        try {
          managerConnection.sendAction(action, sendCB);
          back = true;
          System.out.println("Sending SMS to " + destination);
          this.changeInfo(smsParam);
        } catch (IOException | IllegalArgumentException | IllegalStateException ex) {
          Logger.getLogger(Aplicacao.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    } else {
      System.out.println("Existem valores em branco!");
      return back;
    }

    return back;
  }
示例#7
0
  /** @return */
  public boolean sendPing() {
    ip = conteudo.getServerIp();
    port = conteudo.getServerPort();

    boolean retv = false;
    try {
      System.out.println("Sending a Ping.");
      InputStream ins = Runtime.getRuntime().exec("ping -n 1 -w 2000 " + ip).getInputStream();
      Thread.sleep(3000);
      byte[] prsbuf = new byte[ins.available()];
      ins.read(prsbuf);
      String parsstr = new StringTokenizer(new String(prsbuf), "%").nextToken().trim();

      if (!parsstr.endsWith("100")) {
        retv = true;
      }
      // System.out.println(parsstr);
      this.changeInfo(parsstr);
    } catch (IOException | InterruptedException e) {
      System.out.println("IOException" + e.getMessage());
      retv = false;
    }
    return retv;
  }
示例#8
0
  /**
   * @return
   * @throws IOException
   */
  public boolean onConnect() throws IOException {
    /* variaveis locais */
    boolean back = false;
    ip = conteudo.getServerIp();
    port = conteudo.getServerPort();
    user = conteudo.getUser();
    password = conteudo.getPassword();

    ManagerConnectionFactory factory = new ManagerConnectionFactory(ip, user, password);

    this.managerConnection = factory.createManagerConnection();
    // registro para eventos
    this.managerConnection.addEventListener(this);

    txtEvents = "Trying Connection to: " + ip + ":" + port;
    conteudo.setJlConnection(txtEvents);
    telaPrincipal.changeJlConnection();
    this.changeInfo(txtEvents);

    try {
      // efetiva login
      this.managerConnection.login();

    } catch (IllegalStateException | AuthenticationFailedException | TimeoutException ex) {
      Logger.getLogger(Aplicacao.class.getName()).log(Level.SEVERE, null, ex);
    }

    if (this.managerConnection.getState() == ManagerConnectionState.CONNECTED) {
      registrarClasses();
      txtEvents = "Connected on: " + ip + ":" + port;
      conteudo.setJlConnection(txtEvents);
      this.changeInfo(txtEvents);
      back = true;
    }

    return back;
  }
示例#9
0
 public void exportLog() {
   String text = conteudo.getEventText();
   System.out.println("Logs:\n" + text);
   GravarArquivo gravaarquivo = new GravarArquivo();
   gravaarquivo.gravar(text);
 }
示例#10
0
  /** @param text */
  public void changeInfo(String text) {

    System.out.println(text);
    conteudo.setEventText(text);
    // telaPrincipal.setCampos();
  }
示例#11
0
  public int makeCallAplicacao() {

    String number = conteudo.getNumber();
    String channel = conteudo.getChannel();
    String context = conteudo.getContext();
    String tech = conteudo.getTech();
    int priority = 1;
    int timeOut = 30000;
    int back = 0;
    int actID = this.actionID + 1;

    this.actionID = actID;

    OriginateAction originateAction;
    // SendActionCallback sendCB = this;

    originateAction = new OriginateAction();

    if (!number.equals("") && !channel.equals("") && !context.equals("")) {
      originateAction.setActionId(String.valueOf(actID));

      if (tech.equalsIgnoreCase("Khomp")) {
        originateAction.setChannel(tech + "/" + channel + "/" + number);
      } else {
        originateAction.setChannel(tech + "/" + number);
      }

      originateAction.setContext(context);
      originateAction.setExten(number);
      originateAction.setPriority(priority);
      originateAction.setTimeout(timeOut);
      back = 1;
    } else {
      System.out.println("Existem valores em branco!");
      return back;
    }

    if (ManagerConnectionState.CONNECTED == this.managerConnection.getState()) {
      System.out.println("Calling to " + "Channel:" + channel + ", Extension:" + number);

      try {
        managerConnection.sendAction(originateAction, sendCB);
      } catch (IOException | IllegalArgumentException | IllegalStateException ex) {
        Logger.getLogger(Aplicacao.class.getName()).log(Level.SEVERE, null, ex);
      }
    } else {
      back = -1;
    }

    String callParam =
        ("Action: Originate"
            + CRLF
            + "ActionID: "
            + originateAction.getActionId()
            + CRLF
            + "Channel: "
            + originateAction.getChannel()
            + CRLF
            + "Context: "
            + originateAction.getContext()
            + CRLF
            + "Exten: "
            + originateAction.getExten()
            + CRLF
            + "Priority: "
            + originateAction.getPriority()
            + CRLF
            + CRLF);

    this.changeInfo(callParam);

    // cria e popula objeto call
    Call call = new Call();
    call.setActionID(Integer.toString(actID));
    call.setChannel(channel);
    call.setStatus("Connected");

    //        conteudo.setTabela(call);
    //        telaPrincipal.mostraTabelaChannels();
    return back;
  }
示例#12
0
 private void tratarEvento(InterfaceEvento interfaceEvento) {
   for (String str : interfaceEvento.getAll()) {
     conteudo.setEventText(str);
   }
 }