Ejemplo n.º 1
1
 public void fireEvent(NCCPConnection.ConnectionEvent e) {
   ConnectionListener l;
   int max = listeners.size();
   for (int i = 0; i < max; ++i) {
     ExpCoordinator.print(
         new String(
             "NCCPConnection.fireEvent ("
                 + toString()
                 + ") event: "
                 + e.getType()
                 + " max:"
                 + max
                 + " i:"
                 + i),
         2);
     l = (ConnectionListener) (listeners.elementAt(i));
     switch (e.getType()) {
       case ConnectionEvent.CONNECTION_FAILED:
         l.connectionFailed(e);
         break;
       case ConnectionEvent.CONNECTION_CLOSED:
         l.connectionClosed(e);
         break;
       case ConnectionEvent.CONNECTION_OPENED:
         ExpCoordinator.printer.print(
             new String("Opened control connection (" + toString() + ")"));
         l.connectionOpened(e);
     }
   }
 }
Ejemplo n.º 2
1
  public Message send(Message query) {
    int q, r;
    Message best = null;
    byte rcode;

    for (q = 0; q < 20; q++) {
      boolean ok = false;
      for (r = 0; r < resolvers.length; r++) ok |= sendTo(query, r, q);
      if (!ok) break;
      Message m = null;
      synchronized (queue) {
        try {
          queue.wait((quantum + 1) * 1000);
        } catch (InterruptedException e) {
          System.out.println("interrupted");
        }
        if (queue.size() == 0) continue;
        m = (Message) queue.firstElement();
        queue.removeElementAt(0);
        Integer I = (Integer) queue.firstElement();
        queue.removeElementAt(0);
        r = I.intValue();
      }
      if (m == null) invalid[r] = true;
      else {
        rcode = m.getHeader().getRcode();
        if (rcode == Rcode.NOERROR) return m;
        else {
          if (best == null) best = m;
          invalid[r] = true;
        }
      }
    }
    return best;
  }
 public boolean checkEvents(BundleEvent[] expevents) {
   boolean res = true;
   for (int i = 0; i < 20; i++) {
     try {
       Thread.sleep(100);
     } catch (InterruptedException ignore) {
     }
     if (events.size() == expevents.length) {
       break;
     }
   }
   if (events.size() == expevents.length) {
     for (int i = 0; i < events.size(); i++) {
       BundleEvent be = (BundleEvent) events.elementAt(i);
       if (!(be.getBundle().equals(expevents[i].getBundle())
           && be.getType() == expevents[i].getType())) {
         res = false;
       }
     }
   } else {
     res = false;
   }
   if (!res) {
     out.println("Real events");
     for (int i = 0; i < events.size(); i++) {
       BundleEvent be = (BundleEvent) events.elementAt(i);
       out.println("Event " + be.getBundle() + ", Type " + be.getType());
     }
     out.println("Expected events");
     for (int i = 0; i < expevents.length; i++) {
       out.println("Event " + expevents[i].getBundle() + ", Type " + expevents[i].getType());
     }
   }
   return res;
 }
 /** Get row count (part of table model interface) */
 public int getRowCount() {
   int count = data.size();
   if (filter_data != null) {
     count = filter_data.size();
   }
   return count;
 }
Ejemplo n.º 5
0
 /**
  * Gets the urlClassLoader that enables to access to the objects jar files.
  *
  * @return an URLClassLoader
  */
 public URLClassLoader getObjectsClassLoader() {
   if (objectsClassLoader == null) {
     try {
       if (isExecutionMode()) {
         URL[] listUrl = new URL[1];
         listUrl[0] = instance.getTangaraPath().toURI().toURL();
         objectsClassLoader = new URLClassLoader(listUrl);
       } else {
         File f = new File(instance.getTangaraPath().getParentFile(), "objects");
         File[] list = f.listFiles();
         Vector<URL> vector = new Vector<URL>();
         for (int i = 0; i < list.length; i++) {
           if (list[i].getName().endsWith(".jar")) vector.add(list[i].toURI().toURL());
         }
         File flib =
             new File(
                 instance.getTangaraPath().getParentFile().getAbsolutePath().replace("\\", "/")
                     + "/objects/lib");
         File[] listflib = flib.listFiles();
         for (int j = 0; j < listflib.length; j++) {
           if (listflib[j].getName().endsWith(".jar")) vector.add(listflib[j].toURI().toURL());
         }
         URL[] listUrl = new URL[vector.size()];
         for (int j = 0; j < vector.size(); j++) listUrl[j] = vector.get(j);
         objectsClassLoader = new URLClassLoader(listUrl);
       }
     } catch (Exception e1) {
       displayError("URL MAL FORMED " + e1);
       return null;
     }
   }
   return objectsClassLoader;
 }
Ejemplo n.º 6
0
  public Vector<String> getUserNames() {
    int i;
    Vector<String> names = new Vector<String>(connections.size());

    for (i = 0; i < connections.size(); i++) {
      names.addElement((String) connections.elementAt(i).nickname);
    }

    return names;
  }
 /** Add data to the table as a new row */
 public void addData(SOAPMonitorData soap) {
   int row = data.size();
   data.addElement(soap);
   if (filter_data != null) {
     if (filterMatch(soap)) {
       row = filter_data.size();
       filter_data.addElement(soap);
       fireTableRowsInserted(row, row);
     }
   } else {
     fireTableRowsInserted(row, row);
   }
 }
Ejemplo n.º 8
0
 private boolean checkSocket(Socket s) {
   int l = deny.size();
   byte address[] = s.getInetAddress().getAddress();
   for (int i = 0; i < l; i++) {
     AddressMatcher match = (AddressMatcher) deny.elementAt(i);
     if (match.matches(address)) return false;
   }
   l = accept.size();
   for (int i = 0; i < l; i++) {
     AddressMatcher match = (AddressMatcher) accept.elementAt(i);
     if (match.matches(address)) return true;
   }
   return false;
 }
 public boolean action(Event e, Object arg) {
   System.out.println(e + " " + arg);
   if (e.target == bf.tf) {
     System.out.println("new page");
     String url = bf.tf.getText();
     pages.addElement(url);
     String page = split(url);
     System.out.println("Server = " + server);
     System.out.println("Port = " + port);
     System.out.println("Page = " + page);
     connect(page);
     position++;
     bf.back.enable();
     return true;
   } else if (e.target == bf.back) {
     System.out.println("pos " + position + " " + pages.size());
     if (position > 0) {
       position--;
       String page = split((String) pages.elementAt(position));
       bf.tf.setText((String) pages.elementAt(position));
       connect(page);
       if (position == 0) {
         bf.back.disable();
       }
       bf.forward.enable();
     }
     return true;
   } else if (e.target == bf.forward) {
     if (position != pages.size() - 1) {
       position++;
       bf.tf.setText((String) pages.elementAt(position));
       String page = split((String) pages.elementAt(position));
       if (position == pages.size() - 1) {
         bf.forward.disable();
       }
       bf.back.enable();
       connect(page);
     }
     return true;
   } else if (e.target == bf.b) {
     System.out.println("Disposing of browser frame");
     bf.hide();
     bf.dispose();
     bf = null;
     return true;
   } else {
     return false;
   }
 }
  private String[] getNoAuthCiperSuites(String ciperSuites[]) {
    // Count the number of ciper suites.
    Vector<Integer> v = new Vector<Integer>();
    for (int i = 0; i < ciperSuites.length; i++) {
      if (ciperSuites[i].indexOf("anon") != -1) v.add(new Integer(i));
    }

    String ret[] = new String[v.size()];
    for (int i = 0; i < v.size(); i++) {
      int tmp = v.get(i).intValue();
      ret[i] = ciperSuites[tmp];
    }

    return ret;
  }
Ejemplo n.º 11
0
  public void nick_name(String msg) {
    try {
      String name = msg.substring(13);
      this.setName(name);
      Vector v = father.onlineList;
      boolean isRepeatedName = false;
      int size = v.size();
      for (int i = 0; i < size; i++) {
        ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
        if (tempSat.getName().equals(name)) {
          isRepeatedName = true;
          break;
        }
      }
      if (isRepeatedName == true) {
        dout.writeUTF("<#NAME_REPEATED#>");
        din.close();
        dout.close();
        sc.close();
        flag = false;
      } else {
        v.add(this);
        father.refreshList();
        String nickListMsg = "";
        StringBuilder nickListMsgSb = new StringBuilder();
        size = v.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
          nickListMsgSb.append("!");
          nickListMsgSb.append(tempSat.getName());
        }
        nickListMsgSb.append("<#NICK_LIST#>");
        nickListMsg = nickListMsgSb.toString();
        Vector tempv = father.onlineList;
        size = tempv.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) tempv.get(i);
          tempSat.dout.writeUTF(nickListMsg);
          if (tempSat != this) {
            tempSat.dout.writeUTF("<#MSG#>" + this.getName() + "is now online....");
          }
        }
      }

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 12
0
  private void updateTabBar(Vector vtThread) {
    pnlThread.removeAll();
    for (int iThreadIndex = 0; iThreadIndex < vtThread.size(); iThreadIndex++) {
      try {
        Vector vtThreadInfo = (Vector) vtThread.elementAt(iThreadIndex);
        PanelThreadMonitor mntTemp = new PanelThreadMonitor(channel);

        String strThreadID = (String) vtThreadInfo.elementAt(0);
        String strThreadName = (String) vtThreadInfo.elementAt(1);
        int iThreadStatus = Integer.parseInt((String) vtThreadInfo.elementAt(2));
        mntTemp.setThreadID(strThreadID);
        mntTemp.setThreadName(strThreadName);
        mntTemp.setThreadStatus(iThreadStatus);
        showResult(mntTemp.txtMonitor, (String) vtThreadInfo.elementAt(3));
        mntTemp.addPropertyChangeListener(this);

        pnlThread.add(strThreadName, mntTemp);
        mntTemp.updateStatus();
      } catch (Exception e) {
        e.printStackTrace();
        MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
      }
    }
    Skin.applySkin(this);
  }
Ejemplo n.º 13
0
 public void setConnected(boolean b, boolean process_pending) {
   if (b && state != ConnectionEvent.CONNECTION_OPENED) {
     if (host.length() > 0)
       ExpCoordinator.print(
           "NCCPConnection open connection to ipaddress " + host + " port " + port);
     state = ConnectionEvent.CONNECTION_OPENED;
     // connected = true;
     fireEvent(new ConnectionEvent(this, state));
     ExpCoordinator.printer.print("NCCPConnection.setConnected " + b + " event fired", 8);
     if (process_pending) {
       int max = pendingMessages.size();
       ExpCoordinator.printer.print(new String("   pendingMessages " + max + " elements"), 8);
       for (int i = 0; i < max; ++i) {
         sendMessage((NCCP.Message) pendingMessages.elementAt(i));
       }
       pendingMessages.removeAllElements();
     }
   } else {
     if (!b
         && (state != ConnectionEvent.CONNECTION_CLOSED
             || state != ConnectionEvent.CONNECTION_FAILED)) {
       if (host.length() > 0)
         ExpCoordinator.print(
             new String(
                 "NCCPConnection.setConnected -- Closed control socket for " + host + "." + port));
       state = ConnectionEvent.CONNECTION_CLOSED;
       fireEvent(new ConnectionEvent(this, state));
     }
   }
 }
Ejemplo n.º 14
0
  public static void main(String[] args) throws SdpParseException, SdpException {
    String sdpFields =
        "v=0\r\n"
            + "o=4855 13760799956958020 13760799956958020 IN IP4 166.35.224.216\r\n"
            + "s=nortelnetworks\r\n"
            + "p=+1 972 684 1000\r\n"
            + "c=IN IP4 166.35.224.216\r\n"
            + "t=0 0\r\n"
            + "m=audio 50006 RTP/AVP 0 8 4 18\r\n"
            + "a=rtpmap:0 PCMU/8000\r\n"
            + "a=rtpmap:8 PCMA/8000\r\n"
            + "a=rtpmap:4 G723/8000\r\n"
            + "a=rtpmap:18 G729A/8000\r\n"
            + "a=ptime:30\r\n";
    SdpFactory sdpFactory = new SdpFactory();
    SessionDescription sessionDescription = sdpFactory.createSessionDescription(sdpFields);

    System.out.println("sessionDescription = " + sessionDescription);
    Vector mediaDescriptions = sessionDescription.getMediaDescriptions(true);
    for (int i = 0; i < mediaDescriptions.size(); i++) {
      MediaDescription m = (MediaDescription) mediaDescriptions.elementAt(i);
      System.out.println("m = " + m.toString());
      Media media = m.getMedia();
      Vector formats = media.getMediaFormats(false);
      System.out.println("formats = " + formats);
    }
  }
Ejemplo n.º 15
0
 public void removeUser(String strChannel) {
   Vector vtData = tblUser.getFilteredData();
   for (int iIndex = 0; iIndex < vtData.size(); iIndex++) {
     Vector vtRow = (Vector) vtData.elementAt(iIndex);
     if (vtRow.elementAt(0).equals(strChannel)) tblUser.deleteRow(iIndex);
   }
 }
Ejemplo n.º 16
0
  public void sendGlobalServerMsg(String msg) {
    int i;
    connection you;

    for (i = 0; i < connections.size(); i++) {
      you = (connection) connections.elementAt(i);
      you.sendServerMsg(msg);
    }
  }
Ejemplo n.º 17
0
 // ------------------------------------------------------------
 // test whether "s1" and "s2" share substring, each substring
 // is deliminated by "delim"
 // ------------------------------------------------------------
 public static boolean shareString(String s1, String s2, String delim) {
   Vector v1 = str2vec(s1, delim);
   Vector v2 = str2vec(s2, delim);
   for (int i = 0; i < v1.size(); i++) {
     String s = (String) v1.elementAt(i);
     if (v2.contains(s)) return true;
   }
   return false;
 }
Ejemplo n.º 18
0
 public PDBChain findChain(String id) {
   for (int i = 0; i < chains.size(); i++) {
     // System.out.println("ID = " + id + " " +((PDBChain)chains.elementAt(i)).id);
     if (((PDBChain) chains.elementAt(i)).id.equals(id)) {
       return (PDBChain) chains.elementAt(i);
     }
   }
   return null;
 }
 /** Update a message */
 public void updateData(SOAPMonitorData soap) {
   int row;
   if (filter_data == null) {
     // No filter, so just fire table updated
     row = data.indexOf(soap);
     if (row != -1) {
       fireTableRowsUpdated(row, row);
     }
   } else {
     // Check if the row was being displayed
     row = filter_data.indexOf(soap);
     if (row == -1) {
       // Row was not displayed, so check for if it
       // now needs to be displayed
       if (filterMatch(soap)) {
         int index = -1;
         row = data.indexOf(soap) + 1;
         while ((row < data.size()) && (index == -1)) {
           index = filter_data.indexOf(data.elementAt(row));
           if (index != -1) {
             // Insert at this location
             filter_data.add(index, soap);
           }
           row++;
         }
         if (index == -1) {
           // Insert at end
           index = filter_data.size();
           filter_data.addElement(soap);
         }
         fireTableRowsInserted(index, index);
       }
     } else {
       // Row was displayed, so check if it needs to
       // be updated or removed
       if (filterMatch(soap)) {
         fireTableRowsUpdated(row, row);
       } else {
         filter_data.remove(soap);
         fireTableRowsDeleted(row, row);
       }
     }
   }
 }
Ejemplo n.º 20
0
 public Session findSessionTo(String to) {
   int n = clients.size();
   Log.fine(Name + ": looking for client to " + to);
   for (int i = 0; i < n; i++) {
     Session ias = clients.elementAt(i);
     Log.fine(Name + ": client " + i + " id is " + ias.sid);
     if (ias.sid.startsWith(to)) return ias;
   }
   return null;
 }
Ejemplo n.º 21
0
 public Session findSession(String id) {
   int n = clients.size();
   Log.fine(Name + ": looking for client with id " + id);
   for (int i = 0; i < n; i++) {
     Session ias = clients.elementAt(i);
     Log.fine(Name + ": client " + i + " id is " + ias.sid);
     if (ias.sid.equals(id)) return ias;
   }
   return null;
 }
 /** Find the data for a given id */
 public SOAPMonitorData findData(Long id) {
   SOAPMonitorData soap = null;
   for (int row = data.size(); (row > 0) && (soap == null); row--) {
     soap = (SOAPMonitorData) data.elementAt(row - 1);
     if (soap.getId().longValue() != id.longValue()) {
       soap = null;
     }
   }
   return soap;
 }
Ejemplo n.º 23
0
 public boolean existLogin(String login) {
   boolean res = false;
   for (int i = 0; i < mClients.size(); i++) {
     ClientInfo clientInfo = (ClientInfo) mClients.get(i);
     if (login.equals(clientInfo.login)) {
       res = true;
     }
   }
   return res;
 }
Ejemplo n.º 24
0
 /*
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 */
 public boolean yaEsta(String nombre) {
   boolean siOno = false;
   for (int a = 0; a < vectorJugadores.size(); a++) {
     if (nombre.equals(vectorJugadores.get(a))) {
       siOno = true;
       break;
     }
   }
   return siOno;
 }
Ejemplo n.º 25
0
  /** @param msg Sende msg an alle Teilnehmer */
  public void broadcast(String msg) {
    int i;
    connection you;

    for (i = 0; i < connections.size(); i++) {
      // System.out.println("Nachricht verschicken!");
      you = (connection) connections.elementAt(i);
      you.out.println(msg);
    }
  }
Ejemplo n.º 26
0
  public void createPopupMenu() {
    menu = new JPopupMenu();
    for (int i = filenames.size() - 2, j = 0; i >= 0; i--, j++) {
      menu.add((String) filenames.elementAt(i));
      JMenuItem mi = (JMenuItem) menu.getComponent(j);
      mi.setFont(new Font("Arial", Font.PLAIN, 11));
      mi.addActionListener(this);
    }

    menu.pack();
    // setPopupLocation(200, 200);
  }
Ejemplo n.º 27
0
  public boolean userExists(String name) {
    int i;
    connection you;

    for (i = 0; i < connections.size(); i++) {
      you = (connection) connections.elementAt(i);
      if (you.getNickname().equals(name)) {
        return true;
      }
    }
    return false;
  }
 /** Remove all messages from the table (but leave "most recent") */
 public void clearAll() {
   int last_row = data.size() - 1;
   if (last_row > 0) {
     data.removeAllElements();
     SOAPMonitorData soap = new SOAPMonitorData(null, null, null);
     data.addElement(soap);
     if (filter_data != null) {
       filter_data.removeAllElements();
       filter_data.addElement(soap);
     }
     fireTableDataChanged();
   }
 }
Ejemplo n.º 29
0
 public static String commonString(String s1, String s2, String delim) {
   Vector v1 = str2vec(s1, delim);
   Vector v2 = str2vec(s2, delim);
   StringBuffer buf = new StringBuffer();
   for (int i = 0; i < v1.size(); i++) {
     String s = (String) v1.elementAt(i);
     if (v2.contains(s)) {
       if (buf.length() > 0) buf.append(delim);
       buf.append(s);
     }
   }
   return buf.toString();
 }
Ejemplo n.º 30
0
  void sendMultipleUdpMessages(Message msg, Vector dests) {
    Address dest;

    for (int i = 0; i < dests.size(); i++) {
      dest = (Address) dests.elementAt(i);
      msg.setDest(dest);

      try {
        sendUdpMessage(msg);
      } catch (Exception e) {
        Trace.debug("UDP.sendMultipleUdpMessages()", "exception=" + e);
      }
    }
  }