1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Initial population

This commit is contained in:
Javier Montalvo Orus 2006-09-07 12:01:07 +00:00
parent c7460a86e4
commit 782cb9ad70
29 changed files with 2345 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.tm.discovery.model.edit</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tm.discovery.model.edit;singleton:=true
Bundle-Version: 1.0.0
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.tm.discovery.model.provider.DiscoveryModelEditPlugin$Implementation
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.tm.discovery.model.provider
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.edit;visibility:=reexport,
org.eclipse.tm.discovery.model
Eclipse-LazyStart: true

View file

@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head><title>About</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body lang="EN-US">
<h2>About This Content</h2>
<p>July 27, 2006</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in
("Content"). Unless otherwise indicated below, the Content is provided
to you under the terms and conditions of the
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is
available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, "Program" will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse
Foundation, the Content is being redistributed by another party
("Redistributor") and different terms and conditions may
apply to your use of any object code in the Content. Check the
Redistributor's license that was provided with the Content. If no such
license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any
source code in the Content and such source code may be obtained at http://www.eclipse.org.</p>
</body></html>

View file

@ -0,0 +1,15 @@
# <copyright>
# </copyright>
#
# $Id$
bin.includes = .,\
icons/,\
META-INF/,\
plugin.xml,\
plugin.properties,\
about.html
jars.compile.order = .
source.. = src/
output.. = bin/
src.includes = about.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

View file

@ -0,0 +1,60 @@
##################################################################################
# Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License v1.0 which accompanies this distribution, and is
# available at http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Javier Montalvo Orús (Symbian) - initial API and implementation
##################################################################################
# ====================================================================
# To code developer:
# Do NOT change the properties between this line and the
# "%%% END OF TRANSLATED PROPERTIES %%%" line.
# Make a new property name, append to the end of the file and change
# the code to use the new property.
# ====================================================================
# ====================================================================
# %%% END OF TRANSLATED PROPERTIES %%%
# ====================================================================
pluginName = Service Discovery Edit Support
providerName = Symbian
_UI_CreateChild_text = {0}
_UI_CreateChild_text2 = {1} {0}
_UI_CreateChild_text3 = {1}
_UI_CreateChild_tooltip = Create New {0} Under {1} Feature
_UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}.
_UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent.
_UI_PropertyDescriptor_description = The {0} of the {1}
_UI_Unknown_type = Object
_UI_Unknown_datatype= Value
_UI_SDDevice_sDServiceType_feature = SD Service Type
_UI_SDNetwork_sDDevice_feature = SD Device
_UI_SDService_sDPair_feature = SD Pair
_UI_SDServiceType_sDService_feature = SD Service
_UI_Device_type = Device
_UI_Network_type = Network
_UI_Pair_type = Pair
_UI_Service_type = Service
_UI_ServiceType_type = Service Type
_UI_Device_serviceType_feature = Service Type
_UI_Device_address_feature = Address
_UI_Device_name_feature = Name
_UI_Network_device_feature = Device
_UI_Pair_key_feature = Key
_UI_Pair_value_feature = Value
_UI_Service_pair_feature = Pair
_UI_Service_name_feature = Name
_UI_ServiceType_service_feature = Service
_UI_ServiceType_name_feature = Name
_UI_Unknown_feature = Unspecified

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
This program and the accompanying materials are made available under the terms
of the Eclipse Public License v1.0 which accompanies this distribution, and is
available at http://www.eclipse.org/legal/epl-v10.html
Contributors:
Javier Montalvo Orús (Symbian) - initial API and implementation
-->
<plugin>
<extension point="org.eclipse.emf.edit.itemProviderAdapterFactories">
<factory
uri = "http://www.eclipse.org/tm/discovery"
class = "org.eclipse.tm.discovery.provider.ModelItemProviderAdapterFactory"
supportedTypes =
"org.eclipse.emf.edit.provider.IEditingDomainItemProvider
org.eclipse.emf.edit.provider.IStructuredItemContentProvider
org.eclipse.emf.edit.provider.ITreeItemContentProvider
org.eclipse.emf.edit.provider.IItemLabelProvider
org.eclipse.emf.edit.provider.IItemPropertySource" />
</extension>
</plugin>

View file

@ -0,0 +1,217 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.model.provider;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.eclipse.tm.discovery.model.ModelFactory;
import org.eclipse.tm.discovery.model.ModelPackage;
import org.eclipse.tm.discovery.model.Device;
/**
* This is the item provider adapter for a {@link org.eclipse.tm.discovery.model.Device} object.
*
* @generated
*/
public class DeviceItemProvider
extends ItemProviderAdapter
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
*
* @generated
*/
public DeviceItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
*
* @generated
*/
public List getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addAddressPropertyDescriptor(object);
addNamePropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Address feature.
*
* @generated
*/
protected void addAddressPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Device_address_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Device_address_feature", "_UI_Device_type"),
ModelPackage.Literals.DEVICE__ADDRESS,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Name feature.
*
* @generated
*/
protected void addNamePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Device_name_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Device_name_feature", "_UI_Device_type"),
ModelPackage.Literals.DEVICE__NAME,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
*
* @generated
*/
public Collection getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(ModelPackage.Literals.DEVICE__SERVICE_TYPE);
}
return childrenFeatures;
}
/**
* This returns Device.gif.
*
* @generated NOT
*/
public Object getImage(Object object) {
return getResourceLocator().getImage("full/obj16/device");
//return null;
}
/**
* This returns the label text for the adapted class.
*
* @generated NOT
*/
public String getText(Object object) {
String name = ((Device)object).getName();
String address = ((Device)object).getAddress();
StringBuffer result = new StringBuffer();
if(address != null)
result.append(address);
if(name != null)
result.append(" ("+name+")");
return result.toString();
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
*
* @generated
*/
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Device.class)) {
case ModelPackage.DEVICE__ADDRESS:
case ModelPackage.DEVICE__NAME:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
case ModelPackage.DEVICE__SERVICE_TYPE:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
/**
* This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
* describing all of the children that can be created under this object.
*
* @generated
*/
protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
newChildDescriptors.add
(createChildParameter
(ModelPackage.Literals.DEVICE__SERVICE_TYPE,
ModelFactory.eINSTANCE.createServiceType()));
}
/**
* Return the resource locator for this item provider's resources.
*
* @generated
*/
public ResourceLocator getResourceLocator() {
return DiscoveryModelEditPlugin.INSTANCE;
}
/**
* @generated not
*
*/
public Collection getChildren(Object object) {
Collection collect = super.getChildren(object);
return collect;
}
}

View file

@ -0,0 +1,88 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.model.provider;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
/**
* This is the central singleton for the DiscoveryModel edit plugin.
*
* @generated
*/
public final class DiscoveryModelEditPlugin extends EMFPlugin {
/**
* Keep track of the singleton.
*
* @generated
*/
public static final DiscoveryModelEditPlugin INSTANCE = new DiscoveryModelEditPlugin();
/**
* Keep track of the singleton.
*
* @generated
*/
private static Implementation plugin;
/**
* Create the instance.
*
* @generated
*/
public DiscoveryModelEditPlugin() {
super
(new ResourceLocator [] {
});
}
/**
* Returns the singleton instance of the Eclipse plugin.
*
* @return the singleton instance.
* @generated
*/
public ResourceLocator getPluginResourceLocator() {
return plugin;
}
/**
* Returns the singleton instance of the Eclipse plugin.
*
* @return the singleton instance.
* @generated
*/
public static Implementation getPlugin() {
return plugin;
}
/**
* The actual implementation of the Eclipse <b>Plugin</b>.
*
* @generated
*/
public static class Implementation extends EclipsePlugin {
/**
* Creates an instance.
*
* @generated
*/
public Implementation() {
super();
// Remember the static instance.
//
plugin = this;
}
}
}

View file

@ -0,0 +1,271 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.model.provider;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.tm.discovery.model.util.ModelAdapterFactory;
/**
* This is the factory that is used to provide the interfaces needed to support Viewers.
* The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
* The adapters also support Eclipse property sheets.
* Note that most of the adapters are shared among multiple instances.
*
* @generated
*/
public class ModelItemProviderAdapterFactory extends ModelAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
/**
* This keeps track of the root adapter factory that delegates to this adapter factory.
*
* @generated
*/
protected ComposedAdapterFactory parentAdapterFactory;
/**
* This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
*
* @generated
*/
protected IChangeNotifier changeNotifier = new ChangeNotifier();
/**
* This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
*
* @generated
*/
protected Collection supportedTypes = new ArrayList();
/**
* This constructs an instance.
*
* @generated not
*/
public ModelItemProviderAdapterFactory() {
supportedTypes.add(IEditingDomainItemProvider.class);
supportedTypes.add(IStructuredItemContentProvider.class);
supportedTypes.add(ITreeItemContentProvider.class);
supportedTypes.add(IItemLabelProvider.class);
supportedTypes.add(IItemPropertySource.class);
supportedTypes.add(ITableItemLabelProvider.class);
}
/**
* This keeps track of the one adapter used for all {@link org.eclipse.tm.discovery.model.Device} instances.
*
* @generated
*/
protected DeviceItemProvider deviceItemProvider;
/**
* This creates an adapter for a {@link org.eclipse.tm.discovery.model.Device}.
*
* @generated
*/
public Adapter createDeviceAdapter() {
if (deviceItemProvider == null) {
deviceItemProvider = new DeviceItemProvider(this);
}
return deviceItemProvider;
}
/**
* This keeps track of the one adapter used for all {@link org.eclipse.tm.discovery.model.Network} instances.
*
* @generated
*/
protected NetworkItemProvider networkItemProvider;
/**
* This creates an adapter for a {@link org.eclipse.tm.discovery.model.Network}.
*
* @generated
*/
public Adapter createNetworkAdapter() {
if (networkItemProvider == null) {
networkItemProvider = new NetworkItemProvider(this);
}
return networkItemProvider;
}
/**
* This keeps track of the one adapter used for all {@link org.eclipse.tm.discovery.model.Pair} instances.
*
* @generated
*/
protected PairItemProvider pairItemProvider;
/**
* This creates an adapter for a {@link org.eclipse.tm.discovery.model.Pair}.
*
* @generated
*/
public Adapter createPairAdapter() {
if (pairItemProvider == null) {
pairItemProvider = new PairItemProvider(this);
}
return pairItemProvider;
}
/**
* This keeps track of the one adapter used for all {@link org.eclipse.tm.discovery.model.Service} instances.
*
* @generated
*/
protected ServiceItemProvider serviceItemProvider;
/**
* This creates an adapter for a {@link org.eclipse.tm.discovery.model.Service}.
*
* @generated
*/
public Adapter createServiceAdapter() {
if (serviceItemProvider == null) {
serviceItemProvider = new ServiceItemProvider(this);
}
return serviceItemProvider;
}
/**
* This keeps track of the one adapter used for all {@link org.eclipse.tm.discovery.model.ServiceType} instances.
*
* @generated
*/
protected ServiceTypeItemProvider serviceTypeItemProvider;
/**
* This creates an adapter for a {@link org.eclipse.tm.discovery.model.ServiceType}.
*
* @generated
*/
public Adapter createServiceTypeAdapter() {
if (serviceTypeItemProvider == null) {
serviceTypeItemProvider = new ServiceTypeItemProvider(this);
}
return serviceTypeItemProvider;
}
/**
* This returns the root adapter factory that contains this factory.
*
* @generated
*/
public ComposeableAdapterFactory getRootAdapterFactory() {
return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
}
/**
* This sets the composed adapter factory that contains this factory.
*
* @generated
*/
public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
this.parentAdapterFactory = parentAdapterFactory;
}
/**
*
* @generated
*/
public boolean isFactoryForType(Object type) {
return supportedTypes.contains(type) || super.isFactoryForType(type);
}
/**
* This implementation substitutes the factory itself as the key for the adapter.
*
* @generated
*/
public Adapter adapt(Notifier notifier, Object type) {
return super.adapt(notifier, this);
}
/**
*
* @generated
*/
public Object adapt(Object object, Object type) {
if (isFactoryForType(type)) {
Object adapter = super.adapt(object, type);
if (!(type instanceof Class) || (((Class)type).isInstance(adapter))) {
return adapter;
}
}
return null;
}
/**
* This adds a listener.
*
* @generated
*/
public void addListener(INotifyChangedListener notifyChangedListener) {
changeNotifier.addListener(notifyChangedListener);
}
/**
* This removes a listener.
*
* @generated
*/
public void removeListener(INotifyChangedListener notifyChangedListener) {
changeNotifier.removeListener(notifyChangedListener);
}
/**
* This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
*
* @generated
*/
public void fireNotifyChanged(Notification notification) {
changeNotifier.fireNotifyChanged(notification);
if (parentAdapterFactory != null) {
parentAdapterFactory.fireNotifyChanged(notification);
}
}
/**
* This disposes all of the item providers created by this factory.
*
* @generated
*/
public void dispose() {
if (deviceItemProvider != null) deviceItemProvider.dispose();
if (networkItemProvider != null) networkItemProvider.dispose();
if (pairItemProvider != null) pairItemProvider.dispose();
if (serviceItemProvider != null) serviceItemProvider.dispose();
if (serviceTypeItemProvider != null) serviceTypeItemProvider.dispose();
}
}

View file

@ -0,0 +1,143 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.model.provider;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.eclipse.tm.discovery.model.ModelFactory;
import org.eclipse.tm.discovery.model.ModelPackage;
import org.eclipse.tm.discovery.model.Network;
/**
* This is the item provider adapter for a {@link org.eclipse.tm.discovery.model.Network} object.
*
* @generated
*/
public class NetworkItemProvider
extends ItemProviderAdapter
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource {
/**
* This constructs an instance from a factory and a notifier.
*
* @generated
*/
public NetworkItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
*
* @generated
*/
public List getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
}
return itemPropertyDescriptors;
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
*
* @generated
*/
public Collection getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(ModelPackage.Literals.NETWORK__DEVICE);
}
return childrenFeatures;
}
/**
* This returns Network.gif.
*
* @generated NOT
*/
public Object getImage(Object object) {
return getResourceLocator().getImage("full/obj16/network");
}
/**
* This returns the label text for the adapted class.
*
* @generated NOT
*/
public String getText(Object object) {
return "Network";
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
*
* @generated
*/
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Network.class)) {
case ModelPackage.NETWORK__DEVICE:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
/**
* This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
* describing all of the children that can be created under this object.
*
* @generated
*/
protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
newChildDescriptors.add
(createChildParameter
(ModelPackage.Literals.NETWORK__DEVICE,
ModelFactory.eINSTANCE.createDevice()));
}
/**
* Return the resource locator for this item provider's resources.
*
* @generated
*/
public ResourceLocator getResourceLocator() {
return DiscoveryModelEditPlugin.INSTANCE;
}
}

View file

@ -0,0 +1,197 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.model.provider;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.eclipse.tm.discovery.model.ModelPackage;
import org.eclipse.tm.discovery.model.Pair;
/**
* This is the item provider adapter for a {@link org.eclipse.tm.discovery.model.Pair} object.
*
* @generated not
*/
public class PairItemProvider
extends ItemProviderAdapter
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource,
ITableItemLabelProvider
{
/**
* This constructs an instance from a factory and a notifier.
*
* @generated
*/
public PairItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
*
* @generated
*/
public List getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addKeyPropertyDescriptor(object);
addValuePropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Key feature.
*
* @generated
*/
protected void addKeyPropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Pair_key_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Pair_key_feature", "_UI_Pair_type"),
ModelPackage.Literals.PAIR__KEY,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This adds a property descriptor for the Value feature.
*
* @generated
*/
protected void addValuePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Pair_value_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Pair_value_feature", "_UI_Pair_type"),
ModelPackage.Literals.PAIR__VALUE,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This returns Pair.gif.
*
* @generated NOT
*/
public Object getImage(Object object) {
return null;
}
/**
* This returns the label text for the adapted class.
*
* @generated NOT
*/
public String getText(Object object) {
return null;
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
*
* @generated
*/
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Pair.class)) {
case ModelPackage.PAIR__KEY:
case ModelPackage.PAIR__VALUE:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
}
super.notifyChanged(notification);
}
/**
* This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
* describing all of the children that can be created under this object.
*
* @generated
*/
protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
}
/**
* Return the resource locator for this item provider's resources.
*
* @generated
*/
public ResourceLocator getResourceLocator() {
return DiscoveryModelEditPlugin.INSTANCE;
}
/**
* @generated NOT
*/
public Object getColumnImage(Object object, int columnIndex) {
return null;
}
/**
* @generated NOT
*/
public String getColumnText(Object object, int columnIndex) {
String returnString = null;
if(columnIndex == 0)
{
returnString = ((Pair)object).getKey();
}
else if(columnIndex == 1)
{
returnString = ((Pair)object).getValue();
}
return returnString;
}
}

View file

@ -0,0 +1,174 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.model.provider;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.eclipse.tm.discovery.model.ModelFactory;
import org.eclipse.tm.discovery.model.ModelPackage;
import org.eclipse.tm.discovery.model.Service;
/**
* This is the item provider adapter for a {@link org.eclipse.tm.discovery.model.Service} object.
*
* @generated
*/
public class ServiceItemProvider
extends ItemProviderAdapter
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource{
/**
* This constructs an instance from a factory and a notifier.
*
* @generated
*/
public ServiceItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
*
* @generated
*/
public List getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addNamePropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Name feature.
*
* @generated
*/
protected void addNamePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_Service_name_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_Service_name_feature", "_UI_Service_type"),
ModelPackage.Literals.SERVICE__NAME,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
*
* @generated
*/
public Collection getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(ModelPackage.Literals.SERVICE__PAIR);
}
return childrenFeatures;
}
/**
* This returns Service.gif.
*
* @generated not
*/
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage("full/obj16/Service"));
}
/**
* This returns the label text for the adapted class.
*
* @generated NOT
*/
public String getText(Object object) {
return ((Service)object).getName();
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
*
* @generated
*/
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(Service.class)) {
case ModelPackage.SERVICE__NAME:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
case ModelPackage.SERVICE__PAIR:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
/**
* This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
* describing all of the children that can be created under this object.
*
* @generated
*/
protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
newChildDescriptors.add
(createChildParameter
(ModelPackage.Literals.SERVICE__PAIR,
ModelFactory.eINSTANCE.createPair()));
}
/**
* Return the resource locator for this item provider's resources.
*
* @generated
*/
public ResourceLocator getResourceLocator() {
return DiscoveryModelEditPlugin.INSTANCE;
}
/* NO CHILDREN IN TREE */
public boolean hasChildren(Object object) {
return false;
}
}

View file

@ -0,0 +1,169 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.model.provider;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemProviderAdapter;
import org.eclipse.emf.edit.provider.ViewerNotification;
import org.eclipse.tm.discovery.model.ModelFactory;
import org.eclipse.tm.discovery.model.ModelPackage;
import org.eclipse.tm.discovery.model.ServiceType;
/**
* This is the item provider adapter for a {@link org.eclipse.tm.discovery.model.ServiceType} object.
*
* @generated
*/
public class ServiceTypeItemProvider
extends ItemProviderAdapter
implements
IEditingDomainItemProvider,
IStructuredItemContentProvider,
ITreeItemContentProvider,
IItemLabelProvider,
IItemPropertySource
{
/**
* This constructs an instance from a factory and a notifier.
*
* @generated
*/
public ServiceTypeItemProvider(AdapterFactory adapterFactory) {
super(adapterFactory);
}
/**
* This returns the property descriptors for the adapted class.
*
* @generated
*/
public List getPropertyDescriptors(Object object) {
if (itemPropertyDescriptors == null) {
super.getPropertyDescriptors(object);
addNamePropertyDescriptor(object);
}
return itemPropertyDescriptors;
}
/**
* This adds a property descriptor for the Name feature.
*
* @generated
*/
protected void addNamePropertyDescriptor(Object object) {
itemPropertyDescriptors.add
(createItemPropertyDescriptor
(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
getResourceLocator(),
getString("_UI_ServiceType_name_feature"),
getString("_UI_PropertyDescriptor_description", "_UI_ServiceType_name_feature", "_UI_ServiceType_type"),
ModelPackage.Literals.SERVICE_TYPE__NAME,
true,
false,
false,
ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,
null,
null));
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
*
* @generated
*/
public Collection getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(ModelPackage.Literals.SERVICE_TYPE__SERVICE);
}
return childrenFeatures;
}
/**
* This returns ServiceType.gif.
*
* @generated
*/
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage("full/obj16/ServiceType"));
}
/**
* This returns the label text for the adapted class.
*
* @generated NOT
*/
public String getText(Object object) {
String label = ((ServiceType)object).getName();
return label == null || label.length() == 0 ? "": label;
}
/**
* This handles model notifications by calling {@link #updateChildren} to update any cached
* children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
*
* @generated
*/
public void notifyChanged(Notification notification) {
updateChildren(notification);
switch (notification.getFeatureID(ServiceType.class)) {
case ModelPackage.SERVICE_TYPE__NAME:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
return;
case ModelPackage.SERVICE_TYPE__SERVICE:
fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
return;
}
super.notifyChanged(notification);
}
/**
* This adds to the collection of {@link org.eclipse.emf.edit.command.CommandParameter}s
* describing all of the children that can be created under this object.
*
* @generated
*/
protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, object);
newChildDescriptors.add
(createChildParameter
(ModelPackage.Literals.SERVICE_TYPE__SERVICE,
ModelFactory.eINSTANCE.createService()));
}
/**
* Return the resource locator for this item provider's resources.
*
* @generated
*/
public ResourceLocator getResourceLocator() {
return DiscoveryModelEditPlugin.INSTANCE;
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.tm.discovery.protocol.dnssd</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: DNS Service Discovery Plug-in
Bundle-SymbolicName: org.eclipse.tm.discovery.protocol.dnssd;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.tm.discovery.protocol.dnssd.Activator
Bundle-Vendor: Symbian
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.tm.discovery.engine,
org.eclipse.tm.discovery.model,
org.eclipse.emf.ecore;bundle-version="2.2.0"
Eclipse-LazyStart: true

View file

@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head><title>About</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body lang="EN-US">
<h2>About This Content</h2>
<p>July 27, 2006</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in
("Content"). Unless otherwise indicated below, the Content is provided
to you under the terms and conditions of the
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is
available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, "Program" will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse
Foundation, the Content is being redistributed by another party
("Redistributor") and different terms and conditions may
apply to your use of any object code in the Content. Check the
Redistributor's license that was provided with the Content. If no such
license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any
source code in the Content and such source code may be obtained at http://www.eclipse.org.</p>
</body></html>

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension point="org.eclipse.tm.discovery.engine.discoveryProtocol">
<protocol
class="org.eclipse.tm.discovery.protocol.dnssd.DNSSDProtocol"
name="DNS-SD"/>
</extension>
</plugin>

View file

@ -0,0 +1,50 @@
package org.eclipse.tm.discovery.protocol.dnssd;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.tm.discovery.protocol.dnssd";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,717 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.protocol.dnssd;
import java.io.ByteArrayInputStream;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.tm.discovery.model.Device;
import org.eclipse.tm.discovery.model.ModelFactory;
import org.eclipse.tm.discovery.model.Network;
import org.eclipse.tm.discovery.model.Pair;
import org.eclipse.tm.discovery.model.Service;
import org.eclipse.tm.discovery.model.ServiceType;
import org.eclipse.tm.discovery.protocol.IProtocol;
import org.eclipse.tm.discovery.transport.ITransport;
/**
* DNS-based Service Discovery implementation based on <a
* href="http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt">DNS-Based
* Service Discovery</a> <br/><br/> The DNS packets supported by the implementation are:
*
* <ul>
* <li> DNS Pointer resource record (PTR) <br/> <table border="1">
* <tr>
* <td>Name</td>
* <td>Type</td>
* <td>Class</td>
* <td>TTL</td>
* <td>Data Size</td>
* <td>Domain Name</td>
* </tr>
* </table> <br/>
* <li> DNS Service resource record (SRV)<br/> <table border="1">
* <tr>
* <td>Name</td>
* <td>Type</td>
* <td>Class</td>
* <td>TTL</td>
* <td>Data Size</td>
* <td>Priority</td>
* <td>Weight</td>
* <td>Port</td>
* <td>Target</td>
* </tr>
* </table> <br/>
* <li> DNS Text resource record (TXT) <br/> <table border="1">
* <tr>
* <td>Name</td>
* <td>Type</td>
* <td>Class</td>
* <td>TTL</td>
* <td>Data Size</td>
* <td>Data Pairs</td>
* </tr>
* </table> <br/>
* <li> DNS Address resource record (A) <br/> <table border="1">
* <tr>
* <td>Name</td>
* <td>Type</td>
* <td>Class</td>
* <td>TTL</td>
* <td>Data Size</td>
* <td>Address</td>
* </tr>
* </table>
* </ul>
* <br/>
*
*
*/
public class DNSSDProtocol implements IProtocol {
// DNS Pointer resource record identifier
private final static int PTR = 0x0C;
// DNS Service resource record identifier
private final static int SRV = 0x21;
// DNS Text resource record identifier
private final static int TXT = 0x10;
// DNS Address resource record identifier
private final static int A = 0x01;
// DNS packet reference.
private byte[] packet;
// provide 64k for the received packet
private final int MAX_PACKET_SIZE = 65535;
private byte[] buffer = new byte[MAX_PACKET_SIZE];
//IP address identifying the target
private String address;
// Queries for services and legacy services
private final String SERVICE_DISCOVERY_COMMAND = Messages.getString("DNSSDProtocol.ServiceDiscoveryCommand"); //$NON-NLS-1$
private final String LEGACY_SERVICE_DISCOVERY_COMMAND = Messages.getString("DNSSDProtocol.legacyServiceDiscoveryCommand"); //$NON-NLS-1$
// Patterns to parse service name and service type
private final Pattern serviceNamePattern = Pattern.compile("^_?(\\w+)\\..+"); //$NON-NLS-1$
private final Pattern serviceTypeNamePattern = Pattern.compile("^[^\\.]+\\._?(\\w+)\\..+"); //$NON-NLS-1$
private Resource resource = null;
private ITransport transport = null;
private String query = null;
/* (non-Javadoc)
* @see org.eclipse.tm.discovery.protocol.IProtocol#getQueries()
*/
public String[] getQueries()
{
return new String[]{
SERVICE_DISCOVERY_COMMAND,
LEGACY_SERVICE_DISCOVERY_COMMAND
};
}
/* (non-Javadoc)
* @see org.eclipse.tm.discovery.protocol.IProtocol#getDiscoveryJob(java.lang.String, org.eclipse.emf.ecore.resource.Resource, org.eclipse.tm.discovery.transport.ITransport)
*/
public Job getDiscoveryJob(String aQuery, Resource aResource, ITransport aTransport){
resource = aResource;
transport = aTransport;
query = aQuery;
return new Job(Messages.getString("DNSSDProtocol.JobName")) { //$NON-NLS-1$
protected IStatus run(IProgressMonitor monitor) {
if (transport != null) {
sendQuery(transport, query, PTR);
Vector discoveredServices = new Vector();
if (!resource.getContents().isEmpty()) {
Iterator deviceIterator = ((Network) resource.getContents().get(0)).getDevice().iterator();
while (deviceIterator.hasNext()) {
Device device = (Device) deviceIterator.next();
Iterator serviceTypeIterator = device.getServiceType().iterator();
while (serviceTypeIterator.hasNext()) {
ServiceType serviceType = (ServiceType) serviceTypeIterator.next();
if (serviceType.getName().equals(SERVICE_DISCOVERY_COMMAND) ||
serviceType.getName().equals(LEGACY_SERVICE_DISCOVERY_COMMAND)) {
Iterator serviceIterator = serviceType.getService().iterator();
while (serviceIterator.hasNext()) {
Service service = (Service) serviceIterator.next();
if (!discoveredServices.contains(service.getName())) {
discoveredServices.add(service.getName());
}
}
serviceTypeIterator.remove();
}
}
}
for (int i = 0; i < discoveredServices.size(); i++) {
sendQuery(transport,(String) discoveredServices.elementAt(i), PTR);
}
}
}
return new Status(IStatus.OK,
"org.eclipse.rse.discovery.engine", IStatus.OK, //$NON-NLS-1$
Messages.getString("DNSSDProtocol.FinishedJobName"), null); //$NON-NLS-1$
}
};
}
/*
* Creates and sends the specified query in a DNS-SD packet and call the function to populate the model with the received data
*/
private void sendQuery(ITransport transport, String query, int type) {
try {
//clean buffer
for (int i = 0; i < buffer.length; i++) {
buffer[i]=0;
}
// number of queries (1)
buffer[4] = (byte) 0x00;
buffer[5] = (byte) 0x01;
//jump to the data section of the packet letting the other fields as 0s
int index = 12;
StringTokenizer tokenizer = new StringTokenizer(query, "."); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
buffer[index] = (byte) token.length();
index++;
for (int subIndex = 0; subIndex < token.getBytes().length; subIndex++) {
buffer[index + subIndex] = token.getBytes()[subIndex];
}
index += token.getBytes().length;
}
//end of data section
buffer[index++] = 0x00;
// type TXT-SRV-PTR
buffer[index++] = 0x00;
buffer[index++] = (byte) (type & 0xFF);
//inet
buffer[index++] = 0x00;
buffer[index++] = 0x01;
packet = new byte[index];
for (int position = 0; position < index; position++)
packet[position] = buffer[position];
//send the packet using the provided ITransport implementation
transport.send(packet);
// wait to receive data until timeout
while (true) {
address = transport.receive(buffer);
packet = buffer;
populateModel(resource);
}
} catch (Exception e) {
// timeout, no more services to discover
}
}
/*
* Populates the provided model with the contents of the received packet
*/
private void populateModel(Resource resource) {
Network network = null;
Device device = null;
boolean found = false;
Iterator deviceIterator = null;
if (resource.getContents().isEmpty()) {
network = ModelFactory.eINSTANCE.createNetwork();
resource.getContents().add(network);
} else {
network = (Network) resource.getContents().get(0);
}
deviceIterator = network.getDevice().iterator();
while (deviceIterator.hasNext()) {
Device aDevice = (Device) deviceIterator.next();
if (aDevice.getAddress().equals(address)) {
device = aDevice;
found = true;
break;
}
}
if (!found) {
device = ModelFactory.eINSTANCE.createDevice();
device.setAddress(address);
network.getDevice().add(device);
}
ByteArrayInputStream packetInputStream = new ByteArrayInputStream(packet);
//skip transactionID+flags
packetInputStream.skip(4);
int queriesNumber = packetInputStream.read() << 8 | packetInputStream.read();
int answersNumber = packetInputStream.read() << 8 | packetInputStream.read();
//skip authority RRs
packetInputStream.skip(2);
int additionalRecordsNumber = packetInputStream.read() << 8 | packetInputStream.read();
// read queries
for (int i = 0; i < queriesNumber; i++) {
getName(packetInputStream, packet);
//skip type
packetInputStream.skip(2);
//skip class
packetInputStream.skip(2);
}
//read answers
for (int i = 0; i < answersNumber + additionalRecordsNumber; i++) {
found = false;
String name = getName(packetInputStream, packet);
//packet type
int type = packetInputStream.read() << 8 | packetInputStream.read();
//skip class
packetInputStream.skip(2);
//skip TTL
packetInputStream.skip(4);
switch (type) {
/*
* A PACKET (DNS Address resource record identifier)
*/
case DNSSDProtocol.A:
handleARecord(packetInputStream, device, name);
break;
/*
* PTR PACKET (DNS Pointer resource record identifier)
*/
case DNSSDProtocol.PTR:
handlePTRRecord(packetInputStream, device, name);
break;
/*
* SRV PACKET (DNS Service resource record identifier)
*/
case DNSSDProtocol.SRV:
handleSRVRecord(packetInputStream, device, name);
break;
/*
* TXT PACKET (DNS Text resource record identifier)
*/
case DNSSDProtocol.TXT:
handleTXTRecord(packetInputStream, device, name);
break;
}
}
}
private void handleARecord(ByteArrayInputStream packetInputStream, Device device, String name) {
int dataLength = packetInputStream.read() << 8 | packetInputStream.read();
//skip address
packetInputStream.skip(dataLength);
if (device != null) {
device.setName(name.substring(0, name.indexOf('.') ));
}
}
private void handlePTRRecord(ByteArrayInputStream packetInputStream, Device device, String name) {
Service service = null;
ServiceType serviceType = null;
//skip dataLength
packetInputStream.skip(2);
String ptrDataName = getName(packetInputStream, packet);
String serviceTypeName = name;
//parse the service type name
if(!(serviceTypeName.equals(SERVICE_DISCOVERY_COMMAND) || serviceTypeName.equals(LEGACY_SERVICE_DISCOVERY_COMMAND)))
{
Matcher matcher = serviceNamePattern.matcher(name);
if (matcher.matches())
serviceTypeName = matcher.group(1);
}
//find if we have a serviceType with this name...
Iterator serviceTypeIterator = device.getServiceType().iterator();
boolean found = false;
while (serviceTypeIterator.hasNext()) {
ServiceType aServiceType = (ServiceType) serviceTypeIterator.next();
if (aServiceType.getName().equals(serviceTypeName)) {
serviceType = aServiceType;
found = true;
break;
}
}
if (!found) {
serviceType = ModelFactory.eINSTANCE.createServiceType();
serviceType.setName(serviceTypeName);
device.getServiceType().add(serviceType);
}
if (!ptrDataName.equals("")) { //$NON-NLS-1$
//find if we have a service with this name...
String serviceName = null;
if(serviceTypeName.equals(SERVICE_DISCOVERY_COMMAND) || serviceTypeName.equals(LEGACY_SERVICE_DISCOVERY_COMMAND))
{
serviceName = ptrDataName;
}
else
{
//parse the service type name
Matcher matcher = serviceNamePattern.matcher(ptrDataName);
if (matcher.matches())
serviceName = matcher.group(1);
}
Iterator serviceIterator = serviceType.getService().iterator();
found = false;
while (serviceIterator.hasNext()) {
Service aService = (Service) serviceIterator.next();
if (aService.getName().equals(serviceName)) {
service = aService;
found = true;
break;
}
}
if (!found) {
service = ModelFactory.eINSTANCE.createService();
service.setName(serviceName);
serviceType.getService().add(service);
}
}
}
private void handleSRVRecord(ByteArrayInputStream packetInputStream, Device device, String name) {
Service service = null;
ServiceType serviceType = null;
//data of the packet, without bytes for priority-weight-port
int dataLength = (packetInputStream.read() << 8 | packetInputStream.read()) - 6;
int priority = packetInputStream.read() << 8 | packetInputStream.read();
int weight = packetInputStream.read() << 8 | packetInputStream.read();
int port = packetInputStream.read() << 8 | packetInputStream.read();
byte[] data = new byte[dataLength];
try {
packetInputStream.read(data);
} catch (Exception e) {
e.printStackTrace();
}
//find if we have a serviceType with this name...
String serviceTypeName = null; //name.substring(name.indexOf('.') + 1);
//parse the service type name
Matcher matcher = serviceTypeNamePattern.matcher(name);
if (matcher.matches())
serviceTypeName = matcher.group(1);
Iterator serviceTypeIterator = device.getServiceType().iterator();
boolean found = false;
while (serviceTypeIterator.hasNext()) {
ServiceType aServiceType = (ServiceType) serviceTypeIterator.next();
if (aServiceType.getName().equals(serviceTypeName)) {
serviceType = aServiceType;
found = true;
break;
}
}
if (!found) {
serviceType = ModelFactory.eINSTANCE.createServiceType();
serviceType.setName(serviceTypeName);
device.getServiceType().add(serviceType);
}
//find if we have a service with this name...
String serviceName = null;
Matcher matcher2 = serviceNamePattern.matcher(name);
if (matcher2.matches())
serviceName = matcher2.group(1);
Iterator serviceIterator = serviceType.getService().iterator();
found = false;
while (serviceIterator.hasNext()) {
Service temp = (Service) serviceIterator.next();
if (temp.getName().equals(serviceName)) {
service = temp;
found = true;
break;
}
}
if (!found) {
service = ModelFactory.eINSTANCE.createService();
service.setName(serviceName);
serviceType.getService().add(service);
}
service.setName(serviceName);
String[] keys = new String[]{"port","priority","weight"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String[] values = new String[]{port+"",priority+"",weight+""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
for (int i = 0; i < keys.length; i++) {
Pair text = null;
Iterator pairIterator = service.getPair().iterator();
found = false;
while (pairIterator.hasNext()) {
Pair aPair = (Pair) pairIterator.next();
if (aPair != null)
{
if (aPair.getKey().equals(keys[i])) {
String current = aPair.getValue();
if (!current.equals(values[i]))
aPair.setValue(values[i]);
found = true;
break;
}
}
}
if (!found) {
text = ModelFactory.eINSTANCE.createPair();
text.setKey(keys[i]);
text.setValue(values[i]);
service.getPair().add(text);
}
}
}
private void handleTXTRecord(ByteArrayInputStream packetInputStream, Device device, String recordName) {
ServiceType serviceType = null;
Service service = null;;
int dataLength = packetInputStream.read() << 8 | packetInputStream.read();
byte [] data = new byte[dataLength];
try {
packetInputStream.read(data);
} catch (Exception e) {
e.printStackTrace();
}
// Find if we have a serviceType with this name...
String serviceTypeName = null;
Matcher matcher1 = serviceTypeNamePattern.matcher(recordName);
if (matcher1.matches())
serviceTypeName = matcher1.group(1);
Iterator serviceTypeIterator = device.getServiceType().iterator();
boolean found = false;
while (serviceTypeIterator.hasNext()) {
ServiceType aServiceType = (ServiceType) serviceTypeIterator.next();
if (aServiceType != null) {
if (aServiceType.getName().equals(serviceTypeName)) {
serviceType = aServiceType;
found = true;
break;
}
}
}
if (!found) {
serviceType = ModelFactory.eINSTANCE.createServiceType();
serviceType.setName(serviceTypeName);
device.getServiceType().add(serviceType);
}
// Find if we have a service with this name...
String serviceName = null;
Matcher matcher2 = serviceNamePattern.matcher(recordName);
if (matcher2.matches())
serviceName = matcher2.group(1);
Iterator serviceIterator = serviceType.getService().iterator();
found = false;
while (serviceIterator.hasNext()) {
Service aService = (Service) serviceIterator.next();
if (aService != null) {
if (aService.getName().equals(serviceName)) {
service = aService;
found = true;
break;
}
}
}
if (!found) {
service = ModelFactory.eINSTANCE.createService();
service.setName(recordName);
serviceType.getService().add(service);
}
//process "key=value" pairs
//only alfanumeric key/value allowed
StringBuffer dataBuffer = new StringBuffer();
for (int j = 0; j < dataLength; j++) {
if (data[j] >= '0') {
dataBuffer.append((char) data[j]);
}
if (!(j == 0) && (data[j] < '0' || j == dataLength - 1)) {
StringTokenizer stk = new StringTokenizer(dataBuffer.toString(), "="); //$NON-NLS-1$
String key = stk.nextToken();
//DNS-Based Service Discovery
//6.4 Rules for Names in DNS-SD Name/Value Pairs
//If a key has no value, assume "true"
String value = "true"; //$NON-NLS-1$
try {
value = stk.nextToken();
} catch (Exception e) {
//no value, assume "true"
}
//find if we are updating the value of a key...
Pair text = null;
Iterator pairIterator = service.getPair().iterator();
found = false;
while (pairIterator.hasNext()) {
Pair aPair = (Pair) pairIterator.next();
if (aPair != null)
{
if (aPair.getKey().equals(key)) {
String current = aPair.getValue();
if (!current.equals(value))
aPair.setValue(value);
found = true;
break;
}
}
}
if (!found) {
text = ModelFactory.eINSTANCE.createPair();
text.setKey(key);
text.setValue(value);
service.getPair().add(text);
}
dataBuffer = new StringBuffer();
}
}
}
// returns the name, that can be compressed using DNS compression
// For more information about DNS compression: RFC 1035 (4.1.4. Message compression)
private String getName(ByteArrayInputStream packetInputStream, byte[] packet) {
StringBuffer buffer = new StringBuffer();
int nextByte = 0;
while (true) {
nextByte = packetInputStream.read();
//check if it's a pointer
//pointer: |11xxxxxx|-|xxxxxxxx| where xxx...x is the pointer in the packet
if ((nextByte & 0xC0) == 0xC0) {
int upperByte = (nextByte & (byte) 0x3F) << 8;
int offset = packetInputStream.read() | upperByte;
buffer.append(getReference(packet, offset));
break;
} else if (nextByte == 0x00) {
break;
} else {
for (int i = 0; i < nextByte; i++) {
buffer.append((char)packetInputStream.read());
}
buffer.append('.');
}
}
return buffer.toString();
}
private String getReference(byte[] packet, int offset) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; packet[offset + i] != 0x00;) {
int numReads = packet[offset + i];
//check if it's a pointer
//pointer: |11xxxxxx|-|xxxxxxxx| where xxx...x is the pointer in the packet
if ((numReads & 0xC0) == 0xC0) {
int upperByte = (numReads & (byte) 0x3F) << 8;
int nextOffset = packet[offset + i + 1] | upperByte;
buffer.append(getReference(packet, nextOffset));
break;
} else {
for (int j = 0; j < numReads; j++) {
buffer.append((char) packet[offset + i + j + 1]);
}
buffer.append('.');
}
i += (numReads + 1);
}
return buffer.toString();
}
}

View file

@ -0,0 +1,32 @@
/********************************************************************************
* Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Javier Montalvo Orús (Symbian) - initial API and implementation
********************************************************************************/
package org.eclipse.tm.discovery.protocol.dnssd;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "org.eclipse.tm.discovery.protocol.dnssd.messages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View file

@ -0,0 +1,14 @@
##################################################################################
# Copyright (c) 2006 Symbian Software Ltd. All rights reserved.
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License v1.0 which accompanies this distribution, and is
# available at http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Javier Montalvo Orús (Symbian) - initial API and implementation
##################################################################################
DNSSDProtocol.ServiceDiscoveryCommand=_services._dns-sd._udp.local.
DNSSDProtocol.legacyServiceDiscoveryCommand=_services._mdns._udp.local.
DNSSDProtocol.JobName=DNS-SD Service Discovery
DNSSDProtocol.FinishedJobName=DNS-SD Service Discovery finished