Exemple #1
0
 // ----------------------------------------------------------------------
 // for "SrvTypeRqst"
 // get the list of service types for specified scope & naming authority
 // ----------------------------------------------------------------------
 public synchronized String getServiceTypeList(String na, String scope) {
   Vector typelist = new Vector(5);
   Iterator values = table.values().iterator();
   while (values.hasNext()) {
     Entry e = (Entry) values.next();
     if (!e.getDeleted()
         && // nor deleted
         scope.equalsIgnoreCase(e.getScope())
         && // match scope
         (na.equals("*")
             || // NA wildcard
             na.equalsIgnoreCase(e.getNA()))
         && // match NA
         !typelist.contains(e.getType())) {
       typelist.addElement(e.getType());
     }
   }
   StringBuffer tl = new StringBuffer();
   for (int i = 0; i < typelist.size(); i++) {
     String s = (String) typelist.elementAt(i);
     if (tl.length() > 0) tl.append(",");
     tl.append(s);
   }
   return tl.toString();
 }
 /**
  * Refresh the edit box with the data at entry. The current entry pointer is set to the selected
  * entry.
  *
  * @param e the entry to load.
  */
 public void loadEntry(final Entry e) {
   current = e;
   fileLabel.setText("Editing " + e.getFile().getName());
   nameField.setText(e.getName());
   commentField.setText(e.getComment());
   iconField.setText(e.getIcon());
   execField.setText(e.getExec());
   typeField.setText(e.getType());
   categoryField.setText(e.getCategories());
   terminalBox.setSelected(e.isTerminal());
   startupNotifyBox.setSelected(e.isStartupNotify());
 }
Exemple #3
0
 private synchronized String typeAttrList(String type, String scope, String tag, String ltag) {
   StringBuffer attrList = new StringBuffer();
   Iterator values = table.values().iterator();
   while (values.hasNext()) {
     Entry e = (Entry) values.next();
     if (!e.getDeleted()
         && type.equalsIgnoreCase(e.getType())
         && scope.equalsIgnoreCase(e.getScope())
         && ltag.equalsIgnoreCase(e.getLtag())) {
       String s = e.getAttr(tag);
       if (attrList.length() > 0) attrList.append(",");
       attrList.append(s);
     }
   }
   return attrList.toString();
 }
Exemple #4
0
 // ------------------------------------------------------------------
 // send newer updates to the peer through "tcp" peering connection
 // compare each entry's updating ID with IDs in (adalist, atslist)
 // ------------------------------------------------------------------
 public synchronized void antiEntropy(slpTcpHandler tcp, String scope, String rda, long rts) {
   TreeMap tmp = new TreeMap();
   Iterator values = table.values().iterator();
   while (values.hasNext()) {
     Entry e = (Entry) values.next();
     String ada = e.getAcceptDA();
     long ats = e.getAcceptTS();
     if (ada.equalsIgnoreCase(rda)
         && ats > rts
         && // for newer updates
         Util.shareString(scope, e.getScope(), ",")) {
       tmp.put(new Long(ats), e.getLtag().concat(e.getURL()));
     }
   }
   long ctime = System.currentTimeMillis() / 1000;
   values = tmp.values().iterator();
   while (values.hasNext()) {
     String k = (String) values.next();
     Entry e = (Entry) table.get(k);
     int ltime = (int) (e.getArrivalTS() / 1000 + e.getLifetime() - ctime);
     byte[] buf =
         composer.SrvReg(
             0,
             Const.fresh_flag,
             e.getLtag(),
             e.getURL(),
             ltime,
             e.getType(),
             e.getScope(),
             e.getAttr(""));
     buf =
         composer.MeshFwdExt(buf, Const.Fwded, e.getVersionTS(), e.getAcceptDA(), e.getAcceptTS());
     tcp.send(buf, buf.length);
     if (e.getDeleted()) {
       buf = composer.SrvDeReg(0, e.getLtag(), e.getScope(), e.getURL(), ltime, "");
       buf =
           composer.MeshFwdExt(
               buf, Const.Fwded, e.getVersionTS(), e.getAcceptDA(), e.getAcceptTS());
       tcp.send(buf, buf.length);
     }
   }
 }