コード例 #1
0
  void login() {
    try {
      logoutBtn.setEnabled(true);
      contactList.setEditable(false);
      loginBtn.setEnabled(false);
      loginId.setEnabled(false);
      password.setEnabled(false);

      //
      plugin.login(
          getMyLoginId(), password.getText(), getContactList(), MessagingNetwork.STATUS_ONLINE);
      logoutBtn.setEnabled(true);
    } catch (Throwable tr) {
      printException(tr);
      boolean loggedIn = false;
      try {
        loggedIn = plugin.getClientStatus(getMyLoginId()) != MessagingNetwork.STATUS_OFFLINE;
      } catch (Throwable tr2) {
        printException(tr2);
      }
      if (!loggedIn) {
        enableLoginUI();
      }
    }
  }
コード例 #2
0
  public void init() {
    try {
      // data init
      loginId.setText("" + cfg.REQPARAM_SRC_LOGIN_ID);
      password.setText("" + cfg.REQPARAM_SRC_PASSWORD);

      // ui init
      setLayout(new GridLayout(2, 1));
      Panel inputArea = new Panel(new BorderLayout(2, 2));
      inputArea.add(contactList, "Center");
      Panel bottomR = new Panel(new FlowLayout(FlowLayout.RIGHT));
      bottomR.add(loginBtn);
      bottomR.add(logoutBtn);
      bottomR.add(closeBtn);
      Panel bottomL = new Panel(new FlowLayout());
      bottomL.add(new Label("status:"));
      bottomL.add(clientStatus);
      bottomL.add(new Label("  contact:"));
      bottomL.add(contactListEntry);
      bottomL.add(addToContactList);
      bottomL.add(removeFromContactList);
      bottomL.add(getUserDetailsButton());
      bottomL.add(getSendContactsButton());
      Panel bottom = new Panel(new BorderLayout());
      bottom.add("Center", bottomR);
      bottom.add("West", bottomL);
      inputArea.add(bottom, "South");
      Panel leftTop = new Panel(new GridLayout(10, 1));
      leftTop.add(new Label("login id:")); // 1
      leftTop.add(loginId); // 2
      leftTop.add(new Label("password:"******""));
      leftTop.add(new Label("")); // 6

      leftTop.add(new Label("send msg"));
      leftTop.add(sendMsg); // 8
      leftTop.add(new Label("to"));
      leftTop.add(dstLoginId); // 10

      Panel left = new Panel(new FlowLayout());
      left.add(leftTop);
      inputArea.add(left, "West");
      Panel eventLogPanel = new Panel(new BorderLayout());
      eventLogPanel.add("Center", eventLog);
      Panel eventLogPanelButtons = new Panel(new FlowLayout(FlowLayout.RIGHT));
      eventLogPanelButtons.add(clearEventLogBtn);
      eventLogPanel.add("South", eventLogPanelButtons);
      add(inputArea);
      add(eventLogPanel);
      setBackground(SystemColor.control);
      doLayout();
      sendMsg.requestFocus();
    } catch (Throwable tr) {
      CAT.error("exception", tr);
      System.exit(1);
    }
  }
コード例 #3
0
 void enableLoginUI() {
   try {
     logoutBtn.setEnabled(false);
     contactList.setEditable(true);
     loginBtn.setEnabled(true);
     loginId.setEnabled(true);
     password.setEnabled(true);
   } catch (Throwable tr) {
     CAT.error("exception", tr);
   }
 }
コード例 #4
0
 {
   ActionListener al =
       new ActionListener() {
         public void actionPerformed(ActionEvent ev) {
           if (!(StringUtil.isNullOrTrimmedEmpty(dstLoginId.getText()))
               && !(StringUtil.isNullOrTrimmedEmpty(sendMsg.getText()))) {
             try {
               plugin.sendMessage(getMyLoginId(), dstLoginId.getText(), sendMsg.getText());
               sendMsg.setText("msg " + Math.random());
             } catch (Throwable tr) {
               printException(tr);
             }
           }
         }
       };
   sendMsg.selectAll();
   sendMsg.addActionListener(al);
   dstLoginId.addActionListener(al);
 }
コード例 #5
0
 void fetchUserDetails() {
   try {
     UserDetails d = plugin.getUserDetails(getMyLoginId(), contactListEntry.getText());
     String s =
         getMyLoginId()
             + " reports: user details for "
             + contactListEntry.getText()
             + " are:\r\n  nick="
             + StringUtil.toPrintableString(d.getNick())
             + ",\r\n  real name="
             + StringUtil.toPrintableString(d.getRealName())
             + ",\r\n  email="
             + StringUtil.toPrintableString(d.getEmail())
             + ".";
     CAT.info(s);
     log(s);
   } catch (Exception ex) {
     printException(ex);
   }
 }
コード例 #6
0
  void sendContacts() {
    try {
      int n = (int) (7 * Math.random());
      if (n < 1) n = 2;

      String[] nicks = new String[n];
      String[] loginIds = new String[n];

      int i = 0;
      while (i < n) {
        nicks[i] = "random uin #" + i;
        loginIds[i] = "" + (22222 + (int) (10000000 * Math.random()));
        i++;
      }
      plugin.sendContacts(getMyLoginId(), contactListEntry.getText(), nicks, loginIds);
    } catch (Exception ex) {
      printException(ex);
    }
  }
コード例 #7
0
 String getMyLoginId() {
   return loginId.getText();
 }
コード例 #8
0
 {
   password.setEchoChar('*');
 }