/** * Get the URL for this service. An URL is created by * combining the protocol, address, port, and path properties. */ public String getURL(String protocol) { String url = protocol + "://" + getAddress() + ":" + getPort(); String path = getPropertyString("path"); if (path != null) { if (path.indexOf("://") >= 0) { url = path; } else { url += path.startsWith("/") ? path : "/" + path; } } return url; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(getActivity()) .inflate(R.layout.grid_item_host, parent, false); } final ServiceInfo item = this.getItem(position); ((TextView)convertView.findViewById(R.id.host_name)).setText(item.getName()); String[] addresses = item.getHostAddresses(); String hostAddress; if (addresses.length > 0) { hostAddress = addresses[0] + ":" + item.getPort(); } else { hostAddress = getString(R.string.wizard_zeroconf_no_host_address); } ((TextView) convertView.findViewById(R.id.host_address)).setText(hostAddress); ImageView statusIndicator = (ImageView)convertView.findViewById(R.id.status_indicator); int statusColor = getActivity().getResources().getColor(R.color.host_status_available); statusIndicator.setColorFilter(statusColor); // Remove context menu ImageView contextMenu = (ImageView)convertView.findViewById(R.id.list_context_menu); contextMenu.setVisibility(View.GONE); return convertView; } }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long itemId) { ServiceInfo selectedServiceInfo = serviceInfos[position]; String[] addresses = selectedServiceInfo.getHostAddresses(); if (addresses.length == 0) { // Couldn't get any address Toast.makeText(getActivity(), R.string.wizard_zeroconf_cant_connect_no_host_address, Toast.LENGTH_LONG) .show(); return; } String hostName = selectedServiceInfo.getName(); String hostAddress = addresses[0]; int hostHttpPort = selectedServiceInfo.getPort(); HostInfo selectedHostInfo = new HostInfo(hostName, hostAddress, HostConnection.PROTOCOL_TCP, hostHttpPort, HostInfo.DEFAULT_TCP_PORT, null, null, true, HostInfo.DEFAULT_EVENT_SERVER_PORT, false); listener.onAddHostZeroconfFoundHost(selectedHostInfo); } });
/** * During recovery we need to duplicate service info to reregister them * * @param info */ ServiceInfoImpl(ServiceInfo info) { this._ipv4Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet4Address>()); this._ipv6Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet6Address>()); if (info != null) { this._domain = info.getDomain(); this._protocol = info.getProtocol(); this._application = info.getApplication(); this._name = info.getName(); this._subtype = info.getSubtype(); this._port = info.getPort(); this._weight = info.getWeight(); this._priority = info.getPriority(); this._text = info.getTextBytes(); this._persistent = info.isPersistent(); Inet6Address[] ipv6Addresses = info.getInet6Addresses(); for (Inet6Address address : ipv6Addresses) { this._ipv6Addresses.add(address); } Inet4Address[] ipv4Addresses = info.getInet4Addresses(); for (Inet4Address address : ipv4Addresses) { this._ipv4Addresses.add(address); } } this._state = new ServiceInfoState(this); }
/** * During recovery we need to duplicate service info to reregister them * * @param info */ ServiceInfoImpl(ServiceInfo info) { this._ipv4Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet4Address>()); this._ipv6Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet6Address>()); if (info != null) { this._domain = info.getDomain(); this._protocol = info.getProtocol(); this._application = info.getApplication(); this._name = info.getName(); this._subtype = info.getSubtype(); this._port = info.getPort(); this._weight = info.getWeight(); this._priority = info.getPriority(); this._text = info.getTextBytes(); this._persistent = info.isPersistent(); Inet6Address[] ipv6Addresses = info.getInet6Addresses(); for (Inet6Address address : ipv6Addresses) { this._ipv6Addresses.add(address); } Inet4Address[] ipv4Addresses = info.getInet4Addresses(); for (Inet4Address address : ipv4Addresses) { this._ipv4Addresses.add(address); } } this._state = new ServiceInfoState(this); }
/** * During recovery we need to duplicate service info to reregister them * * @param info */ ServiceInfoImpl(ServiceInfo info) { this._ipv4Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet4Address>()); this._ipv6Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet6Address>()); if (info != null) { this._domain = info.getDomain(); this._protocol = info.getProtocol(); this._application = info.getApplication(); this._name = info.getName(); this._subtype = info.getSubtype(); this._port = info.getPort(); this._weight = info.getWeight(); this._priority = info.getPriority(); this._text = info.getTextBytes(); this._persistent = info.isPersistent(); Inet6Address[] ipv6Addresses = info.getInet6Addresses(); for (Inet6Address address : ipv6Addresses) { this._ipv6Addresses.add(address); } Inet4Address[] ipv4Addresses = info.getInet4Addresses(); for (Inet4Address address : ipv4Addresses) { this._ipv4Addresses.add(address); } } this._state = new ServiceInfoState(this); }
/** * During recovery we need to duplicate service info to reregister them * * @param info */ ServiceInfoImpl(ServiceInfo info) { this._ipv4Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet4Address>()); this._ipv6Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet6Address>()); if (info != null) { this._domain = info.getDomain(); this._protocol = info.getProtocol(); this._application = info.getApplication(); this._name = info.getName(); this._subtype = info.getSubtype(); this._port = info.getPort(); this._weight = info.getWeight(); this._priority = info.getPriority(); this._text = info.getTextBytes(); this._persistent = info.isPersistent(); Inet6Address[] ipv6Addresses = info.getInet6Addresses(); for (Inet6Address address : ipv6Addresses) { this._ipv6Addresses.add(address); } Inet4Address[] ipv4Addresses = info.getInet4Addresses(); for (Inet4Address address : ipv4Addresses) { this._ipv4Addresses.add(address); } } this._state = new ServiceInfoState(this); }
int port = i.getPort(); String text = i.getTextString(); log.info("DNS TXT: " + text);
ServiceInfo cachedServiceEntryInfo = ((DNSRecord) serviceEntry).getServiceInfo(persistent); if (cachedServiceEntryInfo != null) { cachedInfo = new ServiceInfoImpl(map, cachedServiceEntryInfo.getPort(), cachedServiceEntryInfo.getWeight(), cachedServiceEntryInfo.getPriority(), persistent, (byte[]) null); srvBytes = cachedServiceEntryInfo.getTextBytes(); server = cachedServiceEntryInfo.getServer();
ServiceInfo cachedServiceEntryInfo = ((DNSRecord) serviceEntry).getServiceInfo(persistent); if (cachedServiceEntryInfo != null) { cachedInfo = new ServiceInfoImpl(map, cachedServiceEntryInfo.getPort(), cachedServiceEntryInfo.getWeight(), cachedServiceEntryInfo.getPriority(), persistent, (byte[]) null); srvBytes = cachedServiceEntryInfo.getTextBytes(); server = cachedServiceEntryInfo.getServer();
ServiceInfo cachedServiceEntryInfo = ((DNSRecord) serviceEntry).getServiceInfo(persistent); if (cachedServiceEntryInfo != null) { cachedInfo = new ServiceInfoImpl(map, cachedServiceEntryInfo.getPort(), cachedServiceEntryInfo.getWeight(), cachedServiceEntryInfo.getPriority(), persistent, (byte[]) null); srvBytes = cachedServiceEntryInfo.getTextBytes(); server = cachedServiceEntryInfo.getServer();
ServiceInfo cachedServiceEntryInfo = ((DNSRecord) serviceEntry).getServiceInfo(persistent); if (cachedServiceEntryInfo != null) { cachedInfo = new ServiceInfoImpl(map, cachedServiceEntryInfo.getPort(), cachedServiceEntryInfo.getWeight(), cachedServiceEntryInfo.getPriority(), persistent, (byte[]) null); srvBytes = cachedServiceEntryInfo.getTextBytes(); server = cachedServiceEntryInfo.getServer();