2 <?xml-stylesheet href="chrome://browser/content/places/places.css"?>
3 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
4 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
5 <?xml-stylesheet href="browseList.css"?>
6 <!DOCTYPE page SYSTEM "chrome://bonjour4firefox/locale/bonjour4firefox.dtd">
9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
10 style="background-color: transparent !important; -moz-appearance: none !important;"
11 onload="BonjourBrowser.init()"
12 onunload="BonjourBrowser.cleanup()">
15 <menupopup id="targetmenu">
16 <menuitem label="&bonjour4firefoxSidebarOpenDefault.label;" value="current"/>
17 <menuitem label="&bonjour4firefoxSidebarOpenTab.label;" value="tab"/>
18 <menuitem label="&bonjour4firefoxSidebarOpenWindow.label;" value="window"/>
21 <tree id="treeBrowseList" flex="1" class="sidebar-placesTree" hidecolumnpicker="true">
22 <treecols hide="true">
23 <treecol id="title" flex="1" primary="true" hideheader="true"/>
26 <treechildren class="sidebar-placesTreechildren" context="targetmenu" flex="1" id="treeChildrenBrowseList">
29 <treecell src="chrome://bonjour4firefox/content/_internal_bonjour4firefox.png" label="About Bonjour"/>
43 ResolveListener: null,
47 document.getElementById("treeChildrenBrowseList").addEventListener( "click", this.listListener, false );
51 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
52 const cid = "@apple.com/DNSSDService;1";
53 Service = Components.classes[cid].createInstance();
54 Service = Service.QueryInterface(Components.interfaces.IDNSSDService);
62 BrowseListener = this.browseListener;
63 ResolveListener = this.resolveListener;
67 Browse = Service.browse(0, "_http._tcp", "", BrowseListener );
86 browseListener: function( service, add, interfaceIndex, error, serviceName, regtype, domain )
90 // First see if we can look this guy up
92 var treeView = document.getElementById( 'treeChildrenBrowseList' );
95 for ( i = 1; i < treeView.childNodes.length; i++ )
97 var ti = treeView.childNodes[ i ];
98 var tr = ti.childNodes[ 0 ];
99 var tc = tr.childNodes[ 0 ];
101 if ( tc.getAttribute( 'label' ) == serviceName )
110 // If we've already seen this guy, then bump up his reference count
114 var refcnt = treeItem.getUserData( 'refcnt' );
119 var newTreeItem = document.createElement('treeitem');
120 var newTreeRow = document.createElement('treerow');
121 newTreeRow.setAttribute( 'properties', 'bonjourRow' );
122 var newTreeCell = document.createElement('treecell');
123 newTreeCell.setAttribute( 'label', serviceName );
124 newTreeCell.setAttribute( 'src', 'chrome://bonjour4firefox/content/_internal_bonjour4firefox.png' );
126 newTreeItem.appendChild( newTreeRow );
127 newTreeRow.appendChild( newTreeCell );
128 newTreeItem.setUserData( 'interfaceIndex', interfaceIndex, null );
129 newTreeItem.setUserData( 'serviceName', serviceName, null );
130 newTreeItem.setUserData( 'regtype', regtype, null );
131 newTreeItem.setUserData( 'domain', domain, null );
132 newTreeItem.setUserData( 'refcnt', 1, null );
134 // Insert in alphabetical order
136 var insertBefore = null;
138 for ( i = 1; i < treeView.childNodes.length; i++ )
140 var ti = treeView.childNodes[ i ];
141 var tr = ti.childNodes[ 0 ];
142 var tc = tr.childNodes[ 0 ];
144 if ( serviceName.toLowerCase() < tc.getAttribute( 'label' ).toLowerCase() )
151 if ( insertBefore != null )
153 treeView.insertBefore( newTreeItem, insertBefore );
157 treeView.appendChild( newTreeItem );
163 var refcnt = treeItem.getUserData( 'refcnt' );
167 treeView.removeChild( treeItem );
173 alert( 'There was an error browsing for websites: ' + error );
177 listListener: function( event )
179 var treeBrowseList = document.getElementById( 'treeBrowseList' );
181 if ( treeBrowseList.currentIndex == 0 )
183 window._content.location="http://www.apple.com/macosx/features/bonjour";
187 var item = treeBrowseList.view.getItemAtIndex(treeBrowseList.currentIndex);
189 var interfaceIndex = item.getUserData("interfaceIndex");
190 var serviceName = item.getUserData("serviceName");
191 var regtype = item.getUserData("regtype");
192 var domain = item.getUserData("domain");
196 Resolve = Service.resolve( interfaceIndex, serviceName, regtype, domain, ResolveListener );
206 resolveListener: function( service, interfaceIndex, error, fullname, host, port, path )
210 window._content.location='http://' + host + ':' + port + path;
214 alert( 'There was an error resolving ' + fullname );