コード例 #1
0
ファイル: LoginForm.java プロジェクト: sondangphi/cti-project
 public LoginForm() {
   initComponents();
   Image image = Toolkit.getDefaultToolkit().getImage("images/stock_lock.png");
   try {
     agentObject = new AgentObject();
     uti = new Utility();
     File f = new File(filename);
     if (!f.exists()) f.createNewFile();
     FileInputStream fis = new FileInputStream(f);
     if (fis.available() == 0) {
       System.out.println("file is empty");
       uti.writeInfor(filename, "host", host);
       uti.writeInfor(filename, "aport", Integer.toString(aport));
       uti.writeInfor(filename, "qport", Integer.toString(qport));
       System.out.println("write file");
     }
     System.out.println("read file");
     host = uti.readInfor(filename, "host");
     aport = Integer.parseInt(uti.readInfor(filename, "aport"));
     qport = Integer.parseInt(uti.readInfor(filename, "qport"));
     listQueue = new ArrayList<QueueObject>();
     getListQueue();
     queueId = listQueue.get(cb_queue.getSelectedIndex()).getQueueId();
     if (queueId == null) lb_notify_queue.setText("(*)");
     else lb_notify_queue.setText("");
   } catch (Exception e) {
   }
   this.setIconImage(image);
 }
コード例 #2
0
ファイル: LoginForm.java プロジェクト: sondangphi/cti-project
  private void btn_loginActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btn_loginActionPerformed
    // TODO add your handling code here:
    char[] p = pwd.getPassword();
    Agent agentClient = null;
    pass = new String(p);
    agentId = tx_agent.getText();
    iface = tx_iface.getText();
    queueId = listQueue.get(cb_queue.getSelectedIndex()).getQueueId();
    queueName = listQueue.get(cb_queue.getSelectedIndex()).getQueueName();
    agentObject.setAgentId(agentId);
    agentObject.setPass(pass);
    agentObject.setInterface(iface);
    agentObject.setRole(role);
    agentObject.setQueueId(queueId);
    agentObject.setQueueName(queueName);
    lb_notify_queue.setText("");
    lb_notify_iface.setText("");
    lb_notify_pwd.setText("");
    lb_notify_agent.setText("");
    try {
      // kiem tra thong tin nguoi dung nhap vao
      if (!agentId.equalsIgnoreCase("") && uti.checkAgent(agentId)) {
        if (!pass.equalsIgnoreCase("") && uti.checkPwd(pass)) {
          if (!iface.equalsIgnoreCase("") && uti.checkIface(iface)) {
            if (!queueId.equalsIgnoreCase("")) {
              cmd = "100@" + agentId + "@" + pass + "@SIP/" + iface + "@" + queueId + "@" + role;
              lb_status.setText(cmd);
              Socket clientSocket = new Socket(host, aport);
              if (clientSocket != null) {
                System.out.println("connect to server " + clientSocket.getInetAddress().toString());
                agentClient = new Agent(clientSocket, this);
              }
            } else lb_notify_queue.setText("(*)");
          } else lb_notify_iface.setText("(*)");
        } else lb_notify_pwd.setText("(*)");
      } else lb_notify_agent.setText("(*)");

    } catch (Exception e) {
      System.out.println("btn_loginActionPerformed\t" + e);
    }
  } // GEN-LAST:event_btn_loginActionPerformed