diff --git a/discovery/org.eclipse.tm.discovery.model.edit/.classpath b/discovery/org.eclipse.tm.discovery.model.edit/.classpath
new file mode 100644
index 00000000000..751c8f2e504
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/.project b/discovery/org.eclipse.tm.discovery.model.edit/.project
new file mode 100644
index 00000000000..f165aed12fe
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/.project
@@ -0,0 +1,28 @@
+
+
+ org.eclipse.tm.discovery.model.edit
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.pde.PluginNature
+
+
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/META-INF/MANIFEST.MF b/discovery/org.eclipse.tm.discovery.model.edit/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..f818819b8c7
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/META-INF/MANIFEST.MF
@@ -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
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/about.html b/discovery/org.eclipse.tm.discovery.model.edit/about.html
new file mode 100644
index 00000000000..928af38d499
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/about.html
@@ -0,0 +1,29 @@
+
+
About
+
+
+
+
+About This Content
+
+July 27, 2006
+License
+
+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 http://www.eclipse.org/legal/epl-v10.html.
+For purposes of the EPL, "Program" will mean the Content.
+
+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.
+
+
+
\ No newline at end of file
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/build.properties b/discovery/org.eclipse.tm.discovery.model.edit/build.properties
new file mode 100644
index 00000000000..3c9f12b2fd8
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/build.properties
@@ -0,0 +1,15 @@
+#
+#
+#
+# $Id$
+
+bin.includes = .,\
+ icons/,\
+ META-INF/,\
+ plugin.xml,\
+ plugin.properties,\
+ about.html
+jars.compile.order = .
+source.. = src/
+output.. = bin/
+src.includes = about.html
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/Pair.gif b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/Pair.gif
new file mode 100644
index 00000000000..94c953e013b
Binary files /dev/null and b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/Pair.gif differ
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/device.gif b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/device.gif
new file mode 100644
index 00000000000..a871b0d7ab4
Binary files /dev/null and b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/device.gif differ
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/network.gif b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/network.gif
new file mode 100644
index 00000000000..ec3bb95a6dc
Binary files /dev/null and b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/network.gif differ
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/service.gif b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/service.gif
new file mode 100644
index 00000000000..e07b81aa6c9
Binary files /dev/null and b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/service.gif differ
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/serviceType.gif b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/serviceType.gif
new file mode 100644
index 00000000000..5ae555a346c
Binary files /dev/null and b/discovery/org.eclipse.tm.discovery.model.edit/icons/full/obj16/serviceType.gif differ
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/plugin.properties b/discovery/org.eclipse.tm.discovery.model.edit/plugin.properties
new file mode 100644
index 00000000000..e9d74051f0e
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/plugin.properties
@@ -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
+
\ No newline at end of file
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/plugin.xml b/discovery/org.eclipse.tm.discovery.model.edit/plugin.xml
new file mode 100644
index 00000000000..d1bab02dd09
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/plugin.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/DeviceItemProvider.java b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/DeviceItemProvider.java
new file mode 100644
index 00000000000..c7f2c7dab32
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/DeviceItemProvider.java
@@ -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;
+
+ }
+
+}
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/DiscoveryModelEditPlugin.java b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/DiscoveryModelEditPlugin.java
new file mode 100644
index 00000000000..e32473c663e
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/DiscoveryModelEditPlugin.java
@@ -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 Plugin.
+ *
+ * @generated
+ */
+ public static class Implementation extends EclipsePlugin {
+ /**
+ * Creates an instance.
+ *
+ * @generated
+ */
+ public Implementation() {
+ super();
+
+ // Remember the static instance.
+ //
+ plugin = this;
+ }
+ }
+
+}
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/ModelItemProviderAdapterFactory.java b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/ModelItemProviderAdapterFactory.java
new file mode 100644
index 00000000000..156e209d750
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/ModelItemProviderAdapterFactory.java
@@ -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();
+ }
+
+}
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/NetworkItemProvider.java b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/NetworkItemProvider.java
new file mode 100644
index 00000000000..54c6d2e477d
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/NetworkItemProvider.java
@@ -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;
+ }
+
+}
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/PairItemProvider.java b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/PairItemProvider.java
new file mode 100644
index 00000000000..c0c7e33a04e
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/PairItemProvider.java
@@ -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;
+ }
+
+}
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/ServiceItemProvider.java b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/ServiceItemProvider.java
new file mode 100644
index 00000000000..75a2c8a54f7
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/ServiceItemProvider.java
@@ -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;
+ }
+
+}
diff --git a/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/ServiceTypeItemProvider.java b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/ServiceTypeItemProvider.java
new file mode 100644
index 00000000000..e492adcba83
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.model.edit/src/org/eclipse/tm/discovery/model/provider/ServiceTypeItemProvider.java
@@ -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;
+ }
+
+}
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/.classpath b/discovery/org.eclipse.tm.discovery.protocol.dnssd/.classpath
new file mode 100644
index 00000000000..751c8f2e504
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/.project b/discovery/org.eclipse.tm.discovery.protocol.dnssd/.project
new file mode 100644
index 00000000000..fea92ff8016
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/.project
@@ -0,0 +1,28 @@
+
+
+ org.eclipse.tm.discovery.protocol.dnssd
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/META-INF/MANIFEST.MF b/discovery/org.eclipse.tm.discovery.protocol.dnssd/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..d89e5991b8a
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/META-INF/MANIFEST.MF
@@ -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
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/about.html b/discovery/org.eclipse.tm.discovery.protocol.dnssd/about.html
new file mode 100644
index 00000000000..928af38d499
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/about.html
@@ -0,0 +1,29 @@
+
+About
+
+
+
+
+About This Content
+
+July 27, 2006
+License
+
+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 http://www.eclipse.org/legal/epl-v10.html.
+For purposes of the EPL, "Program" will mean the Content.
+
+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.
+
+
+
\ No newline at end of file
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/build.properties b/discovery/org.eclipse.tm.discovery.protocol.dnssd/build.properties
new file mode 100644
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/plugin.xml b/discovery/org.eclipse.tm.discovery.protocol.dnssd/plugin.xml
new file mode 100644
index 00000000000..c612ca67a60
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/plugin.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/Activator.java b/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/Activator.java
new file mode 100644
index 00000000000..85d502f91c3
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/Activator.java
@@ -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;
+ }
+
+}
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/DNSSDProtocol.java b/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/DNSSDProtocol.java
new file mode 100644
index 00000000000..00cd7d3f6ae
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/DNSSDProtocol.java
@@ -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 DNS-Based
+ * Service Discovery
The DNS packets supported by the implementation are:
+ *
+ *
+ * - DNS Pointer resource record (PTR)
+ *
+ * Name |
+ * Type |
+ * Class |
+ * TTL |
+ * Data Size |
+ * Domain Name |
+ *
+ *
+ * - DNS Service resource record (SRV)
+ *
+ * Name |
+ * Type |
+ * Class |
+ * TTL |
+ * Data Size |
+ * Priority |
+ * Weight |
+ * Port |
+ * Target |
+ *
+ *
+ * - DNS Text resource record (TXT)
+ *
+ * Name |
+ * Type |
+ * Class |
+ * TTL |
+ * Data Size |
+ * Data Pairs |
+ *
+ *
+ * - DNS Address resource record (A)
+ *
+ * Name |
+ * Type |
+ * Class |
+ * TTL |
+ * Data Size |
+ * Address |
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+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();
+ }
+
+
+
+}
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/Messages.java b/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/Messages.java
new file mode 100644
index 00000000000..236439045ea
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/Messages.java
@@ -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 + '!';
+ }
+ }
+}
diff --git a/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/messages.properties b/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/messages.properties
new file mode 100644
index 00000000000..78138f7704b
--- /dev/null
+++ b/discovery/org.eclipse.tm.discovery.protocol.dnssd/src/org/eclipse/tm/discovery/protocol/dnssd/messages.properties
@@ -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