diff --git a/AUTHORS b/AUTHORS index cea55c0766848..59e147d99095b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,5 +10,11 @@ kaikreuzer Karel Goderis kgoderis manroh +Marc Mettke +Marc Mettke +marcel Marcel Verpaalen +Markus Rathgeb Oliver Libutzki +Sebastian Janzen +Thomas Eichstädt-Engelen diff --git a/addons/archetype-catalog.xml b/addons/archetype-catalog.xml index cef9431a5c679..46a2acbd7bb00 100644 --- a/addons/archetype-catalog.xml +++ b/addons/archetype-catalog.xml @@ -5,7 +5,7 @@ org.eclipse.smarthome.archetype org.eclipse.smarthome.archetype.binding - 0.7.0-SNAPSHOT + 0.8.0-SNAPSHOT https://repo.eclipse.org/content/repositories/smarthome-snapshots Archetype for creating new bindings for openHAB 2. diff --git a/addons/binding/org.openhab.binding.max.test/.classpath b/addons/binding/org.openhab.binding.max.test/.classpath new file mode 100644 index 0000000000000..95df5aebb3a5b --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/addons/binding/org.openhab.binding.max.test/.groovy/suggestions.xdsl b/addons/binding/org.openhab.binding.max.test/.groovy/suggestions.xdsl new file mode 100644 index 0000000000000..1ce9852b140c0 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/.groovy/suggestions.xdsl @@ -0,0 +1,2 @@ + + diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.project b/addons/binding/org.openhab.binding.max.test/.project similarity index 77% rename from bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.project rename to addons/binding/org.openhab.binding.max.test/.project index 0e79cb6780cbe..fb672a390b611 100644 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.project +++ b/addons/binding/org.openhab.binding.max.test/.project @@ -1,6 +1,6 @@ - org.eclipse.smarthome.io.multimedia.tts.marytts + org.openhab.binding.max.test @@ -20,13 +20,9 @@ - - org.eclipse.pde.ds.core.builder - - - + org.eclipse.jdt.groovy.core.groovyNature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.jdt.core.prefs b/addons/binding/org.openhab.binding.max.test/.settings/org.eclipse.jdt.core.prefs similarity index 84% rename from bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.jdt.core.prefs rename to addons/binding/org.openhab.binding.max.test/.settings/org.eclipse.jdt.core.prefs index f42de363afaae..443e08599a2e6 100644 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.jdt.core.prefs +++ b/addons/binding/org.openhab.binding.max.test/.settings/org.eclipse.jdt.core.prefs @@ -4,4 +4,5 @@ org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.7 diff --git a/addons/binding/org.openhab.binding.max.test/.settings/org.eclipse.jdt.groovy.core.prefs b/addons/binding/org.openhab.binding.max.test/.settings/org.eclipse.jdt.groovy.core.prefs new file mode 100644 index 0000000000000..a68b5bf397081 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/.settings/org.eclipse.jdt.groovy.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +groovy.compiler.level=-1 diff --git a/addons/binding/org.openhab.binding.max.test/.settings/org.eclipse.pde.core.prefs b/addons/binding/org.openhab.binding.max.test/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000000000..e313d3c3b6b38 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +resolve.requirebundle=false diff --git a/addons/binding/org.openhab.binding.max.test/.settings/org.maven.ide.eclipse.prefs b/addons/binding/org.openhab.binding.max.test/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 0000000000000..56e59e829b59a --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Fri Feb 18 22:39:16 CET 2011 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/addons/binding/org.openhab.binding.max.test/META-INF/MANIFEST.MF b/addons/binding/org.openhab.binding.max.test/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000..d87610f4a8980 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/META-INF/MANIFEST.MF @@ -0,0 +1,27 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Openhab Max! Binding Tests +Bundle-SymbolicName: org.openhab.binding.max.test;singleton:=true +Bundle-Version: 2.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-Vendor: Openhab +Fragment-Host: org.openhab.binding.max +Import-Package: org.openhab.binding.max, + org.slf4j, + groovy.json, + groovy.lang, + org.codehaus.groovy.reflection, + org.codehaus.groovy.runtime, + org.codehaus.groovy.runtime.callsite, + org.codehaus.groovy.runtime.typehandling, + org.eclipse.smarthome.core.events, + org.eclipse.smarthome.core.thing.setup, + org.eclipse.smarthome.core.thing.util, + org.eclipse.smarthome.test, + org.eclipse.smarthome.test.storage, + org.hamcrest;core=split, + org.osgi.service.device +Require-Bundle: org.junit;bundle-version="4.11.0" +Export-Package: org.openhab.binding.max.internal.message;x-internal:=true, + org.openhab.binding.max.test;uses:="org.eclipse.smarthome.test" + diff --git a/addons/binding/org.openhab.binding.max.test/MaxBindingTests.launch b/addons/binding/org.openhab.binding.max.test/MaxBindingTests.launch new file mode 100644 index 0000000000000..542fab481d331 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/MaxBindingTests.launch @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/addons/binding/org.openhab.binding.max.test/build.properties b/addons/binding/org.openhab.binding.max.test/build.properties new file mode 100644 index 0000000000000..2fa4ab96b4e65 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/build.properties @@ -0,0 +1,6 @@ +source.. = src/test/groovy,\ + src/test/java/ +output.. = target/classes/ +bin.includes = META-INF/,\ + .,\ + src/ diff --git a/addons/binding/org.openhab.binding.max.test/pom.xml b/addons/binding/org.openhab.binding.max.test/pom.xml new file mode 100644 index 0000000000000..f402905a3c987 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/pom.xml @@ -0,0 +1,115 @@ + + + 4.0.0 + org.openhab.binding + org.openhab.binding.max.test + eclipse-test-plugin + MAX! Binding Tests + + + org.openhab.binding + pom + 2.0.0-SNAPSHOT + + + + + org.openhab.binding.max.test + org.openhab.binding.max.test + + + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho-version} + + + + eclipse-plugin + org.eclipse.equinox.event + 0.0.0 + + + eclipse-plugin + org.eclipse.equinox.ds + 0.0.0 + + + eclipse-plugin + org.eclipse.smarthome.config.xml + 0.0.0 + + + eclipse-plugin + org.eclipse.smarthome.core.thing.xml + 0.0.0 + + + eclipse-plugin + org.eclipse.smarthome.core.binding.xml + 0.0.0 + + + org.slf4j + slf4j-api + 0.0.0 + + + + org.slf4j + slf4j-simple + 0.0.0 + + + + org.slf4j + slf4j-log4j12 + 0.0.0 + + + + + org.eclipse.equinox.ds + 1 + true + + + org.eclipse.equinox.event + 2 + true + + + org.eclipse.smarthome.core + 4 + true + + + org.eclipse.smarthome.core.thing + 4 + true + + + org.eclipse.smarthome.config.xml + 4 + true + + + org.eclipse.smarthome.core.thing.xml + 4 + true + + + org.eclipse.smarthome.core.binding.xml + 4 + true + + + + + + + + diff --git a/addons/binding/org.openhab.binding.max.test/sample/sampleMessage.txt b/addons/binding/org.openhab.binding.max.test/sample/sampleMessage.txt new file mode 100644 index 0000000000000..dfe346ac57615 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/sample/sampleMessage.txt @@ -0,0 +1,12 @@ +H:KEQ0565026,0b5951,0113,00000000,4eed6795,01,32,0f0113,0f34,03,0000 +M:00,01,VgIFAQhiYWRrYW1lcgsNowIMU3R1ZGVlcmthbWVyB7bnAwlXb29ua2FtZXIL6aIEDFN6b25qYSBLYW1lcgjDSQUGWm9sZGVyCMHWCAILDaNLRVEwNTQ0MjQyEUJhZGthbWVyIFJhZGlhdG9yAQEHtudLRVEwMTQ1MTcyFVJhZGlhdG9yIFN0dWRlZXJrYW1lcgIDDhXMTEVRMDAxNTM0MBlXYWxsIFRoZXJtb3N0YXQgV29vbmthbWVyAwEL6aJLRVE5MDE1NDMyG1BsdWcgQWRhcHRlciBNdXVydmVyd2FybWluZwMFBDNvSkVRMDM4MDg3OBdFY28gU3dpdGNoIFN0dWRlZXJrYW1lcgAEDnX2S0VRMTEwNDM4MBpXaW5kb3cgU2Vuc29yIFN0dWRlZXJrYW1lcgIBCMNJS0VRMDY0ODk0ORJUaGVybW9zdGFhdCBTem9uamEEAQjB1ktFUTA2NDkzMTIRU3R1ZGVlcmthbWVyIElybWEFAQ== +C:0b5951,7QtZUQATAf9LRVEwNTY1MDI2AQsABEAAAAAAAAAAQQAAAAAAAAAAAAAAAAAAAAAAAAAAAAsABEAAAAAAAAAAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAGh0dHA6Ly9tYXguZXEtMy5kZTo4MC9jdWJlADAvbG9va3VwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAENFVAAACgADAAAOEENFU1QAAwACAAAcIA== +C:0b0da3,0gsNowIBEABLRVEwNTQ0MjQyLCQ9CQcYAzAM/wBIYViRSP1ZFE0gTSBNIEUgRSBFIEUgRSBFIEhhWJFQ/VkVUSBRIFEgRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIEhQWFpI/lkUTSBNIE0gRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIA== +C:08c1d6,0gjB1gEFGP9LRVEwNjQ5MzEyKyE9CQcYAzAM/wBEeFUgVSBVIFUgVSBVIEUgRSBFIEUgRSBFIER4VRZFIEUgRSBFIEUgRSBFIEUgRSBFIEUgRFFEYkTkTQ9FIEUgRSBFIEUgRSBFIEUgRSBEUURiRORND0UgRSBFIEUgRSBFIEUgRSBFIERRRGJE5E0PRSBFIEUgRSBFIEUgRSBFIEUgRFFEYkTkTQ9FIEUgRSBFIEUgRSBFIEUgRSBEUURiRORRGEUgRSBFIEUgRSBFIEUgRSBFIA== +C:0e75f6,EQ519gQCEABLRVExMTA0Mzgw +C:04336f,EQQzbwUAEg9KRVEwMzgwODc4 +C:0be9a2,0gvpogEDEapLRVE5MDE1NDMyKyE9CQcYAzAM/wBEbFkgWSBZIFkgWSBZIEUgRSBFIEUgRSBFIERgWSBZIFkgWSBZIFkgRSBFIEUgRSBFIEUgRFFUYUTYWSBZIFkgWSBFIEUgRSBFIEUgRSBEUVRhRNhZIFkgWSBZIEUgRSBFIEUgRSBFIERRVGFE2FkgWSBZIFkgRSBFIEUgRSBFIEUgRFFUYUTYWSBZIFkgWSBFIEUgRSBFIEUgRSBEUVRhRNhZIFkgWSBZIEUgRSBFIEUgRSBFIA== +C:0e15cc,zg4VzAMDEP9MRVEwMDE1MzQwKyE9CURsWSBZIFkgWSBZIFkgRSBFIEUgRSBFIEUgRGBZIFkgWSBZIFkgWSBFIEUgRSBFIEUgRSBEUVRhRNhZIFkgWSBZIEUgRSBFIEUgRSBFIERRVGFE2FkgWSBZIFkgRSBFIEUgRSBFIEUgRFFUYUTYWSBZIFkgWSBFIEUgRSBFIEUgRSBEUVRhRNhZIFkgWSBZIEUgRSBFIEUgRSBFIERRVGFE2FkgWSBZIFkgRSBFIEUgRSBFIEUgBxgw +C:08c349,0gjDSQEEGP9LRVEwNjQ4OTQ5KiA9CQcYAzAM/wBEbFUKRSBFIEUgRSBFIEUgRSBFIEUgRSBFIERgVQlFIEUgRSBFIEUgRSBFIEUgRSBFIEUgRFFUYUS0VQNFIEUgRSBFIEUgRSBFIEUgRSBEUVRhRLRVA0UgRSBFIEUgRSBFIEUgRSBFIERRVGFEtFUDRSBFIEUgRSBFIEUgRSBFIEUgRFFUYUS0VQNFIEUgRSBFIEUgRSBFIEUgRSBEUVRhRLRVCkUgRSBFIEUgRSBFIEUgRSBFIA== +C:07b6e7,0ge25wECGP9LRVEwMTQ1MTcyKyE9CQcYAzAM/wBEflUaRSBFIEUgRSBFIEUgRSBFIEUgRSBFIER+VRpFIEUgRSBFIEUgRSBFIEUgRSBFIEUgRFRUcEjSVRJJIEkgSSBFIEUgRSBFIEUgRSBEVFRwSNJVEkkgSSBJIEUgRSBFIEUgRSBFIERUVG9U01URSSBJIEkgRSBFIEUgRSBFIEUgRFRUcEjSVRJJIEkgSSBFIEUgRSBFIEUgRSBEVFRwSNJVEkkgSSBJIEUgRSBFIEUgRSBFIA== +L:CwsNowkSGE0kALAACwjB1gkSGGAiAAAABg519gkSEAYEM28JAAALC+miCRIYACIAAAAMDhXMCRIYBCIAAACtCwjDSQkSGGQqAGMACwe25wkSGGQkAAAA diff --git a/addons/binding/org.openhab.binding.max.test/src/test/groovy/org/openhab/binding/max/test/MaxBridgeHandlerOSGiTest.groovy b/addons/binding/org.openhab.binding.max.test/src/test/groovy/org/openhab/binding/max/test/MaxBridgeHandlerOSGiTest.groovy new file mode 100644 index 0000000000000..1974f2e4a550b --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/src/test/groovy/org/openhab/binding/max/test/MaxBridgeHandlerOSGiTest.groovy @@ -0,0 +1,90 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * 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 + */ +package org.openhab.binding.max.test + +import static org.hamcrest.CoreMatchers.* +import static org.junit.Assert.* +import static org.junit.matchers.JUnitMatchers.* + +import org.eclipse.smarthome.config.core.Configuration +import org.eclipse.smarthome.core.thing.Bridge +import org.eclipse.smarthome.core.thing.ManagedThingProvider +import org.eclipse.smarthome.core.thing.ThingProvider +import org.eclipse.smarthome.core.thing.ThingTypeUID +import org.eclipse.smarthome.core.thing.ThingUID +import org.eclipse.smarthome.core.thing.binding.ThingHandler +import org.eclipse.smarthome.test.OSGiTest +import org.eclipse.smarthome.test.storage.VolatileStorageService +import org.junit.Before +import org.junit.Test +import org.openhab.binding.max.MaxBinding +import org.openhab.binding.max.internal.factory.MaxCubeHandlerFactory +import org.openhab.binding.max.internal.handler.MaxCubeBridgeHandler + + + +/** + * Tests for {@link MaxCubeBridgeHandler}. + * + * @author Marcel Verpaalen - Initial version + * @since 2.0 + */ +class MaxBridgeHandlerOSGiTest extends OSGiTest { + + final ThingTypeUID BRIDGE_THING_TYPE_UID = new ThingTypeUID("max", "bridge") + + ManagedThingProvider managedThingProvider + VolatileStorageService volatileStorageService = new VolatileStorageService() + + + @Before + void setUp() { + registerService(volatileStorageService) + managedThingProvider = getService(ThingProvider, ManagedThingProvider) + assertThat managedThingProvider, is(notNullValue()) + } + + @Test + void maxCubeBridgeHandlerRegisteredAndUnregister() { + + MaxCubeBridgeHandler maxBridgeHandler = getService(ThingHandler, MaxCubeBridgeHandler) + assertThat maxBridgeHandler, is(nullValue()) + + Configuration configuration = new Configuration().with { + put(MaxBinding.SERIAL_NUMBER, "KEQ0565026") + put(MaxBinding.IP_ADDRESS, "192.168.3.100") + it + } + + + ThingUID cubeUid = new ThingUID(BRIDGE_THING_TYPE_UID, "testCube"); + + + Bridge maxBridge = managedThingProvider.createThing( + BRIDGE_THING_TYPE_UID, + cubeUid, + null, configuration) + + assertThat maxBridge, is(notNullValue()) + + // wait for MaxCubeBridgeHandler to be registered + waitForAssert({ + maxBridgeHandler = getService(ThingHandler, MaxCubeBridgeHandler) + assertThat maxBridgeHandler, is(notNullValue()) + }, 10000) + + managedThingProvider.remove(maxBridge.getUID()) + + // wait for MaxCubeBridgeHandler to be unregistered + waitForAssert({ + maxBridgeHandler = getService(ThingHandler, MaxCubeBridgeHandler) + assertThat maxBridgeHandler, is(nullValue()) + }, 10000) + } + +} diff --git a/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/C_MessageTest.java b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/C_MessageTest.java new file mode 100644 index 0000000000000..528ba257e81a7 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/C_MessageTest.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * 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 + */ +package org.openhab.binding.max.internal.message; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +/** + * Tests cases for {@link C_Message}. + * + * @author Andreas Heil (info@aheil.de) + * @author Marcel Verpaalen - OH2 Version and updates + * @since 1.4.0 + */ +public class C_MessageTest { + + public final String rawData = "C:0b0da3,0gsNowIBEABLRVEwNTQ0MjQyLCQ9CQcYAzAM/wBIYViRSP1ZFE0gTSBNIEUgRSBFIEUgRSBFIEhhWJFQ/VkVUSBRIFEgRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIEhQWFpI/lkUTSBNIE0gRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIA=="; + + private C_Message message = null; + + @Before + public void Before() { + message = new C_Message(rawData); + } + + @Test + public void getMessageTypeTest() { + + MessageType messageType = ((Message) message).getType(); + + assertEquals(MessageType.C, messageType); + } + + @Test + public void getRFAddressTest() { + + String rfAddress = message.getRFAddress(); + + assertEquals("0b0da3", rfAddress); + } + + @Test + public void getDeviceTypeTest() { + + DeviceType deviceType = message.getDeviceType(); + + assertEquals(DeviceType.HeatingThermostatPlus, deviceType); + } + + @Test + public void getSerialNumberTes() { + String serialNumber = message.getSerialNumber(); + + assertEquals("KEQ0544242", serialNumber); + } +} \ No newline at end of file diff --git a/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/ConfigurationTest.java b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/ConfigurationTest.java new file mode 100644 index 0000000000000..b012606fb1ba6 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/ConfigurationTest.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * 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 + */ +package org.openhab.binding.max.internal.message; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +/** + * Tests cases for {@link DeviceConfiguration}. + * + * @author Andreas Heil (info@aheil.de) + * @author Marcel Verpaalen - OH2 Version and updates + * @since 1.4.0 + */ + +public class ConfigurationTest { + + public final String rawData = "C:0b0da3,0gsNowIBEABLRVEwNTQ0MjQyLCQ9CQcYAzAM/wBIYViRSP1ZFE0gTSBNIEUgRSBFIEUgRSBFIEhhWJFQ/VkVUSBRIFEgRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIEhQWFpI/lkUTSBNIE0gRSBFIEUgRSBFIEUgSFBYWkj+WRRNIE0gTSBFIEUgRSBFIEUgRSBIUFhaSP5ZFE0gTSBNIEUgRSBFIEUgRSBFIA=="; + + private C_Message c_message = null; + private DeviceConfiguration configuration = null; + + @Before + public void Before() { + c_message = new C_Message(rawData); + configuration = DeviceConfiguration.create(c_message); + } + + @Test + public void createTest() { + assertNotNull(configuration); + } + + @Test + public void getRfAddressTest() { + String rfAddress = configuration.getRFAddress(); + + assertEquals("0b0da3", rfAddress); + } + + @Test + public void getDeviceTypeTest() { + + DeviceType deviceType = configuration.getDeviceType(); + + assertEquals(DeviceType.HeatingThermostatPlus, deviceType); + } + + @Test + public void getSerialNumberTest() { + String serialNumber = configuration.getSerialNumber(); + + assertEquals("KEQ0544242", serialNumber); + } + +} diff --git a/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/M_MessageTest.java b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/M_MessageTest.java new file mode 100644 index 0000000000000..f92e6ea9b3e6c --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/M_MessageTest.java @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * 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 + */ +package org.openhab.binding.max.internal.message; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; + +import org.junit.Before; +import org.junit.Test; + +/** + * Tests cases for {@link M_Message}. + * + * @author Marcel Verpaalen - Initial version + * @since 2.0 + */ +public class M_MessageTest { + + public final String rawData = "M:00,01,VgIFAQhiYWRrYW1lcgsNowIMU3R1ZGVlcmthbWVyB7bnAwlXb29ua2FtZXIL6aIEDFN6b25qYSBLYW1lcgjDSQUGWm9sZGVyCMHWCAILDaNLRVEwNTQ0MjQyEUJhZGthbWVyIFJhZGlhdG9yAQEHtudLRVEwMTQ1MTcyFVJhZGlhdG9yIFN0dWRlZXJrYW1lcgIDDhXMTEVRMDAxNTM0MBlXYWxsIFRoZXJtb3N0YXQgV29vbmthbWVyAwEL6aJLRVE5MDE1NDMyG1BsdWcgQWRhcHRlciBNdXVydmVyd2FybWluZwMFBDNvSkVRMDM4MDg3OBdFY28gU3dpdGNoIFN0dWRlZXJrYW1lcgAEDnX2S0VRMTEwNDM4MBpXaW5kb3cgU2Vuc29yIFN0dWRlZXJrYW1lcgIBCMNJS0VRMDY0ODk0ORJUaGVybW9zdGFhdCBTem9uamEEAQjB1ktFUTA2NDkzMTIRU3R1ZGVlcmthbWVyIElybWEFAQ=="; + + private M_Message message = null; + + @Before + public void Before() { + message = new M_Message(rawData); + } + + @Test + public void getMessageTypeTest() { + + MessageType messageType = ((Message) message).getType(); + + assertEquals(MessageType.M, messageType); + } + + @Test + public void deviceInformationTest() { + + ArrayList allDevicesInformation = message.devices; + + assertEquals(8, allDevicesInformation.size()); + + DeviceInformation deviceInformation = allDevicesInformation.get(0); + assertEquals("Badkamer Radiator", deviceInformation.getName()); + assertEquals("0B0DA3", deviceInformation.getRFAddress()); + assertEquals(1, deviceInformation.getRoomId()); + assertEquals("KEQ0544242", deviceInformation.getSerialNumber()); + assertEquals(DeviceType.HeatingThermostatPlus, deviceInformation.getDeviceType()); + + } + + @Test + public void deviceInformationTypeTest1() { + + ArrayList allDevicesInformation = message.devices; + DeviceInformation deviceInformation = allDevicesInformation.get(1); + assertEquals(DeviceType.HeatingThermostat, deviceInformation.getDeviceType()); + } + + @Test + public void deviceInformationTypeTest2() { + + ArrayList allDevicesInformation = message.devices; + DeviceInformation deviceInformation = allDevicesInformation.get(2); + assertEquals(DeviceType.WallMountedThermostat, deviceInformation.getDeviceType()); + } + + @Test + public void deviceInformationTypeTest3() { + + ArrayList allDevicesInformation = message.devices; + DeviceInformation deviceInformation = allDevicesInformation.get(4); + assertEquals(DeviceType.EcoSwitch, deviceInformation.getDeviceType()); + } + + @Test + public void deviceInformationTypeTest4() { + + ArrayList allDevicesInformation = message.devices; + DeviceInformation deviceInformation = allDevicesInformation.get(5); + assertEquals(DeviceType.ShutterContact, deviceInformation.getDeviceType()); + } + + @Test + public void roomInformationTest() { + + ArrayList roomInformation = message.rooms; + + assertEquals(5, roomInformation.size()); + assertEquals("badkamer", roomInformation.get(0).getName()); + + } + +} diff --git a/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/S_CommandTest.java b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/S_CommandTest.java new file mode 100644 index 0000000000000..c0e7032ffef46 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/S_CommandTest.java @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * 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 + */ +package org.openhab.binding.max.internal.message; + +import static org.junit.Assert.*; + +import org.apache.commons.net.util.Base64; +import org.junit.Test; +import org.openhab.binding.max.internal.Utils; + +/** +* Tests cases for {@link S_Command}. +* +* @author Andreas Heil (info@aheil.de) +* @author Marcel Verpaalen - OH2 Version and updates +* @since 1.4.0 +*/ +public class S_CommandTest { + + public final String foo = "s:AARAAAAAAP4wAaiLix8=\r\n"; + + @Test + public void PrefixTest() { + S_Command scmd = new S_Command("0b0da3", 1, ThermostatModeType.MANUAL, 20.0); + + String commandStr = scmd.getCommandString(); + + String prefix = commandStr.substring(0, 2); + + assertEquals("s:", prefix); + + } + + @Test + public void BaseCommandTest() { + S_Command scmd = new S_Command("0b0da3", 1, ThermostatModeType.MANUAL, 20.0); + + String commandStr = scmd.getCommandString(); + + String base64Data = commandStr.substring(3); + byte[] bytes = Base64.decodeBase64(base64Data.getBytes()); + + int[] data = new int[bytes.length]; + + for (int i = 0; i < bytes.length; i++) { + data[i] = bytes[i] & 0xFF; + } + + String decodedString = Utils.toHex(data); + assertEquals("s:AARAAAAACw2jAWg=\r\n", commandStr); + assertEquals("011000000002C368C05A", decodedString); + + } + + @Test + public void boostModeTest() { + S_Command scmd = new S_Command("0b0da3", 1, ThermostatModeType.BOOST, 21.0); + + String commandStr = scmd.getCommandString(); + + assertEquals("s:AARAAAAACw2jAeo=\r\n", commandStr); + + } + + @Test + public void autotModeTest() { + S_Command scmd = new S_Command("0b0da3", 1, ThermostatModeType.AUTOMATIC, 0); + + String commandStr = scmd.getCommandString(); + + assertEquals("s:AARAAAAACw2jAQA=\r\n", commandStr); + + } +} diff --git a/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/UtilsTest.java b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/UtilsTest.java new file mode 100644 index 0000000000000..6e77ee93b1e67 --- /dev/null +++ b/addons/binding/org.openhab.binding.max.test/src/test/java/org/openhab/binding/max/internal/message/UtilsTest.java @@ -0,0 +1,144 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * 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 + */ +package org.openhab.binding.max.internal.message; + +import static org.junit.Assert.*; + +import java.util.Date; + +//import junit.framework.Assert; + + + + +import org.junit.Test; +import org.openhab.binding.max.internal.Utils; + +/** +* Tests cases for {@link Utils}. +* +* @author Andreas Heil (info@aheil.de) +* @author Marcel Verpaalen - OH2 Version and updates +* @since 1.4.0 +*/ +public class UtilsTest { + + @Test + public void fromHexTest() { + + int ar0 = Utils.fromHex("00"); + int ar1 = Utils.fromHex("01"); + int ar31 = Utils.fromHex("1F"); + int ar255 = Utils.fromHex("FF"); + + assertEquals(0, ar0); + assertEquals(1, ar1); + assertEquals(31, ar31); + assertEquals(255, ar255); + } + + @Test + public void fromByteTest() { + + byte b0 = 0; + byte b127 = 127; + byte b128 = (byte) 128; // overflow due to + byte bn128 = -128; // signed bytes + byte bn1 = -1; + + int ar0 = Utils.fromByte(b0); + int ar127 = Utils.fromByte(b127); + int ar128 = Utils.fromByte(b128); + int arn128 = Utils.fromByte(bn128); + int arn1 = Utils.fromByte(bn1); + + assertEquals(0, ar0); + assertEquals(127, ar127); + assertEquals(128, ar128); + assertEquals(128, arn128); + assertEquals(255, arn1); + } + + @Test + public void toHexNoArgTest() { + + String actualResult = Utils.toHex(); + + assertEquals("", actualResult ); + } + + @Test + public void toHexOneArgTest() { + + String actualResult = Utils.toHex(15); + + assertEquals("0F", actualResult ); + } + + @Test + public void toHexMultipleArgTest() { + + String actualResult = Utils.toHex(4863); + + assertEquals("12FF", actualResult ); + } + + @SuppressWarnings("deprecation") + @Test + public void resolveDateTimeTest() { + + int date = Utils.fromHex("858B"); // 05-09-2011 + int time = Utils.fromHex("2E"); // 23:00 + + Date result = Utils.resolveDateTime(date, time); + + assertEquals(5, result.getDate()); + assertEquals(9, result.getMonth()); + assertEquals(2011, result.getYear()); + assertEquals(23, result.getHours()); + assertEquals(00, result.getMinutes()); + } + + @Test + public void getBitsTest() { + boolean b1[] = Utils.getBits(0xFF); + + assertEquals(b1.length, 8); + for (int i = 0; i < 8; i++) + { + assertEquals(true, b1[i]); + } + + boolean b2[] = Utils.getBits(0x5A); + + assertEquals(b2.length, 8); + assertEquals(false, b2[0]); + assertEquals(true, b2[1]); + assertEquals(false, b2[2]); + assertEquals(true, b2[3]); + assertEquals(true, b2[4]); + assertEquals(false, b2[5]); + assertEquals(true, b2[6]); + assertEquals(false, b2[7]); + } + + @Test + public void hexStringToByteArrayTest() { + String s = "000102030AFF"; + + byte[] result = Utils.hexStringToByteArray(s); + + assertEquals(0, result[0] & 0xFF); + assertEquals(1, result[1] & 0xFF); + assertEquals(2, result[2] & 0xFF); + assertEquals(3, result[3] & 0xFF); + assertEquals(10, result[4] & 0xFF); + assertEquals(255, result[5] & 0xFF); + } +} \ No newline at end of file diff --git a/addons/binding/org.openhab.binding.sonos/ESH-INF/thing/thing-types.xml b/addons/binding/org.openhab.binding.sonos/ESH-INF/thing/thing-types.xml index a0842fc1d80d6..f7dc175dc2eee 100644 --- a/addons/binding/org.openhab.binding.sonos/ESH-INF/thing/thing-types.xml +++ b/addons/binding/org.openhab.binding.sonos/ESH-INF/thing/thing-types.xml @@ -25,6 +25,8 @@ + + @@ -59,25 +61,25 @@ - + String Add a Zone Player to the group of the given Zone Player - + Switch Set the first occurring alarm either ON or OFF. Alarms have first have to be defined through the Sonos Controller app - + String Properties of the alarm currently running - + Switch Set to ON if the alarm was triggered @@ -85,8 +87,9 @@ Player - + Control the Zone Player, e.g. start/stop/next/previous/ffward/rewind + Player @@ -107,116 +110,128 @@ Title of the song currently playing - + String Name of the current track or radio station currently playing - + Switch Set or get the status of the white led on the front of the Zone Player - + Switch Indicator set to ON when the line-in of the Zone Player is connected - + Switch Indicator set to ON if the this Zone Player is the Zone Group Coordinator - + Switch Set or get the mute state of the master volume of the Zone Player - + String Play the Line-in of the the Zone Player corresponding to the given UIN - + String Play the given playlist. The playlist has to predefined in the Sonos Controller app - + + Switch + + Play the songs from the current queue + + + + Number + + Play the given track number from the current queue + + + String Play the given URI - + Switch Put all Zone Players in one group, and stream audio from the line-in from the Zone Player that triggered the command - + String Play the given radio station. The radio station has to be predefined in the Sonos Controller app - + String Remove the given Zone Player to the group of this Zone Player - + Switch Restore the state of the Zone Player - + Switch Restore the state of all the Zone Players - + Switch Save the state of the Zone Player - + Switch Save the state of all the Zone Players - + Number Snooze the running alarm, if any, with the given number of minutes - + Switch Make the Zone Player leave its Group and become a standalone Zone Player - + String The State channel contains state of the Zone Player, e.g. PLAYING, STOPPED,... - + Switch Stop the Zone Player @@ -226,21 +241,22 @@ Dimmer Set or get the master volume + SoundVolume - + String XML formatted string with the current zonegroup configuration - + String Id of the Zone Group the Zone Player belongs to - + String Name of the Zone Group the Zone Player belongs to diff --git a/addons/binding/org.openhab.binding.sonos/META-INF/MANIFEST.MF b/addons/binding/org.openhab.binding.sonos/META-INF/MANIFEST.MF index 0dea8f91b98fb..9d196e844b9e0 100644 --- a/addons/binding/org.openhab.binding.sonos/META-INF/MANIFEST.MF +++ b/addons/binding/org.openhab.binding.sonos/META-INF/MANIFEST.MF @@ -22,7 +22,9 @@ Import-Package: com.google.common.collect, org.jupnp.model.meta, org.jupnp.model.types, org.osgi.service.component, - org.slf4j + org.slf4j, + org.xml.sax, + org.xml.sax.helpers Service-Component: OSGI-INF/* Export-Package: org.openhab.binding.sonos, org.openhab.binding.sonos.handler diff --git a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/SonosBindingConstants.java b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/SonosBindingConstants.java index ad1338d8c4b70..5234f51528775 100644 --- a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/SonosBindingConstants.java +++ b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/SonosBindingConstants.java @@ -39,6 +39,8 @@ public class SonosBindingConstants { public final static String MUTE = "mute"; public final static String PLAYLINEIN = "playlinein"; public final static String PLAYLIST = "playlist"; + public final static String PLAYQUEUE = "playqueue"; + public final static String PLAYTRACK = "playtrack"; public final static String PLAYURI = "playuri"; public final static String PUBLICADDRESS = "publicaddress"; public final static String RADIO = "radio"; diff --git a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java index 2c5b43e5991ae..66664b234a9e5 100644 --- a/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java +++ b/addons/binding/org.openhab.binding.sonos/src/main/java/org/openhab/binding/sonos/handler/ZonePlayerHandler.java @@ -9,6 +9,8 @@ package org.openhab.binding.sonos.handler; import static org.openhab.binding.sonos.SonosBindingConstants.*; + +import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -23,6 +25,7 @@ import java.util.TimeZone; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; + import org.apache.commons.lang.StringUtils; import org.eclipse.smarthome.config.core.Configuration; import org.eclipse.smarthome.config.discovery.DiscoveryListener; @@ -59,7 +62,9 @@ import org.openhab.binding.sonos.internal.SonosZonePlayerState; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import com.google.common.collect.Lists; + import static org.openhab.binding.sonos.config.ZonePlayerConfiguration.UDN; /** @@ -99,7 +104,6 @@ public class ZonePlayerHandler extends BaseThingHandler implements @Override public void run() { try { - updateCurrentURIFormatted(); updateZoneInfo(); updateRunningAlarmProperties(); updateLed(); @@ -137,7 +141,7 @@ public void dispose() { pollingJob.cancel(true); pollingJob = null; } - + if (getThing().getStatus() == ThingStatus.ONLINE) { logger.debug("Setting status for thing '{}' to OFFLINE", getThing() .getUID()); @@ -148,9 +152,9 @@ public void dispose() { @Override public void initialize() { - ZonePlayerConfiguration configuration = getConfigAs(ZonePlayerConfiguration.class); + Configuration configuration = getConfig(); - if (configuration.udn != null) { + if (configuration.get("udn") != null) { onSubscription(); onUpdate(); super.initialize(); @@ -161,21 +165,25 @@ public void initialize() { @Override public void thingDiscovered(DiscoveryService source, DiscoveryResult result) { - if (getThing().getConfiguration().get(UDN) - .equals(result.getProperties().get(UDN))) { - logger.debug("Discovered UDN '{}' for thing '{}'", result - .getProperties().get(UDN), getThing().getUID()); - getThing().setStatus(ThingStatus.ONLINE); - onSubscription(); - onUpdate(); + if(result.getThingUID().equals(this.getThing().getUID())) { + if (getThing().getConfiguration().get(UDN) + .equals(result.getProperties().get(UDN))) { + logger.debug("Discovered UDN '{}' for thing '{}'", result + .getProperties().get(UDN), getThing().getUID()); + getThing().setStatus(ThingStatus.ONLINE); + onSubscription(); + onUpdate(); + } } } @Override public void thingRemoved(DiscoveryService source, ThingUID thingUID) { - logger.debug("Setting status for thing '{}' to OFFLINE", getThing() - .getUID()); - getThing().setStatus(ThingStatus.OFFLINE); + if(thingUID.equals(this.getThing().getUID())) { + logger.debug("Setting status for thing '{}' to OFFLINE", getThing() + .getUID()); + getThing().setStatus(ThingStatus.OFFLINE); + } } @Override @@ -229,6 +237,12 @@ public void handleCommand(ChannelUID channelUID, Command command) { case PLAYLIST: playPlayList(command); break; + case PLAYQUEUE: + playQueue(command); + break; + case PLAYTRACK: + playTrack(command); + break; case PLAYURI: playURI(command); break; @@ -447,6 +461,14 @@ public void onValueReceived(String variable, String value, String service) { stateMap.get("CurrentAlbum")) : UnDefType.UNDEF); break; } + case "CurrentTrackMetaData": { + updateTrackMetaData(); + break; + } + case "CurrentURI": { + updateCurrentURIFormatted(value); + break; + } } } @@ -469,7 +491,7 @@ private synchronized void onUpdate() { int refreshInterval = DEFAULT_REFRESH_INTERVAL; Object refreshConfig = config.get("refresh"); if (refreshConfig != null) { - refreshInterval = Integer.parseInt((String) refreshConfig); + refreshInterval = ((BigDecimal) refreshConfig).intValue(); } pollingJob = scheduler.scheduleAtFixedRate(pollingRunnable, 0, refreshInterval, TimeUnit.SECONDS); @@ -582,30 +604,72 @@ public boolean isCoordinator() { return getUDN().equals(getCoordinator()); } - protected void updateCurrentURIFormatted() { + protected void updateTrackMetaData() { + + String coordinator = getCoordinator(); + ZonePlayerHandler coordinatorHandler = getHandlerByName(coordinator); + SonosMetaData currentTrack = getTrackMetadata(); + + if (coordinatorHandler != null && coordinatorHandler != this) { + coordinatorHandler.updateMediaInfo(); + currentTrack = coordinatorHandler.getTrackMetadata(); + } + + if (currentTrack != null) { - String currentURI = null; + String artist = null; + if (currentTrack.getAlbumArtist().equals("")) { + artist = currentTrack.getCreator(); + } else { + artist = currentTrack.getAlbumArtist(); + } + + String album = currentTrack.getAlbum(); + String title = null; + if(!currentTrack.getTitle().contains("x-sonosapi-stream")) { + title = currentTrack.getTitle(); + } + + // update individual variables + this.onValueReceived("CurrentArtist", (artist != null) ? artist + : "", "AVTransport"); + if(title!=null) { + this.onValueReceived("CurrentTitle", (title != null) ? title : "", + "AVTransport"); + } + this.onValueReceived("CurrentAlbum", (album != null) ? album : "", + "AVTransport"); + + updateMediaInfo(); + + } + + } + + protected void updateCurrentURIFormatted(String URI) { + + String currentURI = URI; SonosMetaData currentTrack = null; String coordinator = getCoordinator(); ZonePlayerHandler coordinatorHandler = getHandlerByName(coordinator); - if (!isGroupCoordinator() && coordinatorHandler != null) { + if (coordinatorHandler != null && coordinatorHandler != this) { + if(currentURI.contains("x-rincon-stream")) { + coordinatorHandler.updateMediaInfo(); + } currentURI = coordinatorHandler.getCurrentURI(); currentTrack = coordinatorHandler.getTrackMetadata(); } else { - currentURI = getCurrentURI(); + // currentURI = getCurrentURI(); currentTrack = getTrackMetadata(); } if (currentURI != null) { - - String resultString = null; - String artist = null; - String album = null; - String title = null; + String title = stateMap.get("CurrentTitle"); + String resultString = stateMap.get("CurrentURIFormatted"); + boolean needsUpdating = false; if (opmlPartnerID != null && currentURI.contains("x-sonosapi-stream")) { - String stationID = StringUtils.substringBetween(currentURI, ":s", "?sid"); String previousStationID = stateMap.get("StationID"); @@ -638,7 +702,7 @@ protected void updateCurrentURIFormatted() { List fields = SonosXMLParser .getRadioTimeFromXML(response); - if (fields != null) { + if (fields != null && fields.size() > 0) { resultString = new String(); // radio name should be first field @@ -652,47 +716,44 @@ protected void updateCurrentURIFormatted() { resultString = resultString + " - "; } } + + needsUpdating = true; } } - } else { - resultString = stateMap.get("CurrentURIFormatted"); - title = stateMap.get("CurrentTitle"); } + } + + if(currentURI.contains("x-rincon-stream")) { + if(currentTrack != null) { + resultString = stateMap.get("CurrentTitle"); + needsUpdating = true; + } + } - } else { - if (currentTrack != null) { - if (!currentTrack.getTitle().contains("x-sonosapi-stream")) { - if (currentTrack.getAlbumArtist().equals("")) { - resultString = currentTrack.getCreator() + " - " - + currentTrack.getAlbum() + " - " - + currentTrack.getTitle(); - artist = currentTrack.getCreator(); - } else { - resultString = currentTrack.getAlbumArtist() - + " - " + currentTrack.getAlbum() + " - " - + currentTrack.getTitle(); - artist = currentTrack.getAlbumArtist(); - } - album = currentTrack.getAlbum(); - title = currentTrack.getTitle(); + if (!currentURI.contains("x-rincon-mp3") && !currentURI.contains("x-rincon-stream") && !currentURI.contains("x-sonosapi")) { + if(currentTrack != null) { + if (currentTrack.getAlbumArtist().equals("")) { + resultString = currentTrack.getCreator() + " - " + + currentTrack.getAlbum() + " - " + + currentTrack.getTitle(); + } else { + resultString = currentTrack.getAlbumArtist() + + " - " + currentTrack.getAlbum() + " - " + + currentTrack.getTitle(); } - } else { - resultString = ""; + needsUpdating = true; } } - this.onValueReceived("CurrentURIFormatted", resultString, - "AVTransport"); - // update individual variables - this.onValueReceived("CurrentArtist", (artist != null) ? artist - : " ", "AVTransport"); - this.onValueReceived("CurrentTitle", (title != null) ? title : " ", - "AVTransport"); - this.onValueReceived("CurrentAlbum", (album != null) ? album : " ", - "AVTransport"); + if(needsUpdating) { + this.onValueReceived("CurrentURIFormatted", (resultString != null) ? resultString : "", + "AVTransport"); + this.onValueReceived("CurrentTitle", (title != null) ? title : "", + "AVTransport"); + } } } @@ -711,7 +772,6 @@ public String getUDN() { } public String getCurrentURI() { - updateMediaInfo(); return stateMap.get("CurrentURI"); } @@ -877,6 +937,9 @@ protected void saveState() { savedState = new SonosZonePlayerState(); String currentURI = getCurrentURI(); + savedState.transportState = getTransportState(); + savedState.volume = getVolume(); + if (currentURI != null) { if (currentURI.contains("x-sonosapi-stream:")) { @@ -966,8 +1029,6 @@ protected void saveState() { } } - savedState.transportState = getTransportState(); - savedState.volume = getVolume(); savedState.relTime = getPosition(); } else { savedState.entry = null; @@ -985,7 +1046,9 @@ protected void restoreState() { synchronized (this) { if (savedState != null) { // put settings back - setVolume(DecimalType.valueOf(savedState.volume)); + if(savedState.volume != null) { + setVolume(DecimalType.valueOf(savedState.volume)); + } if (isCoordinator()) { if (savedState.entry != null) { @@ -1008,7 +1071,9 @@ protected void restoreState() { setCurrentURI(savedState.entry); setPosition(savedState.relTime); } + } + if(savedState.transportState != null) { if (savedState.transportState.equals("PLAYING")) { play(); } else if (savedState.transportState.equals("STOPPED")) { @@ -1150,6 +1215,10 @@ public void setPositionTrack(long tracknr) { seek("TRACK_NR", Long.toString(tracknr)); } + public void setPositionTrack(String tracknr) { + seek("TRACK_NR", tracknr); + } + protected void seek(String unit, String target) { if (unit != null && target != null) { @@ -1231,25 +1300,25 @@ public void playLineIn(Command command) { if (command != null && command instanceof StringType) { String remotePlayerName = command.toString(); - - Thing coordinatorThing = thingRegistry.get(new ThingUID( - ZONEPLAYER_THING_TYPE_UID, getCoordinator())); - ZonePlayerHandler coordinatorHandler = (ZonePlayerHandler) coordinatorThing - .getHandler(); + String coordinatorUDN = getCoordinator(); + ZonePlayerHandler coordinatorHandler = getHandlerByName(coordinatorUDN); ZonePlayerHandler remoteHandler = getHandlerByName(remotePlayerName); - // stop whatever is currently playing - coordinatorHandler.stop(); + if(coordinatorHandler!=null && remoteHandler!=null) { - // set the URI - coordinatorHandler.setCurrentURI("x-rincon-stream:" - + remoteHandler.getConfig().get(UDN), ""); + // stop whatever is currently playing + coordinatorHandler.stop(); - // take the system off mute - coordinatorHandler.setMute(OnOffType.OFF); + // set the URI + coordinatorHandler.setCurrentURI("x-rincon-stream:" + + remoteHandler.getConfig().get(UDN), ""); - // start jammin' - coordinatorHandler.play(); + // take the system off mute + coordinatorHandler.setMute(OnOffType.OFF); + + // start jammin' + coordinatorHandler.play(); + } } } @@ -1258,7 +1327,7 @@ protected ZonePlayerHandler getHandlerByName(String remotePlayerName) { if(thingRegistry!=null) { Thing thing = thingRegistry.get(new ThingUID( ZONEPLAYER_THING_TYPE_UID, remotePlayerName)); - + if (thing == null) { Collection allThings = thingRegistry.getAll(); for (Thing aThing : allThings) { @@ -1584,6 +1653,19 @@ public void playURI(Command command) { } + public void playQueue(Command command) { + ZonePlayerHandler coordinator = getHandlerByName(getCoordinator()); + + // set the current playlist to our new queue + coordinator.setCurrentURI("x-rincon-queue:" + getUDN() + "#0", ""); + + // take the system off mute + coordinator.setMute(OnOffType.OFF); + + // start jammin' + coordinator.play(); + } + public void setLed(Command command) { if (command != null) { if (command instanceof OnOffType @@ -1668,6 +1750,25 @@ public void playRadio(Command command) { } + public void playTrack(Command command) { + + if(command != null && command instanceof DecimalType) { + ZonePlayerHandler coordinator = getHandlerByName(getCoordinator()); + + String trackNumber = command.toString(); + + // seek the track - warning, we do not check if the tracknumber falls in the boundary of the queue + setPositionTrack(trackNumber); + + // take the system off mute + coordinator.setMute(OnOffType.OFF); + + // start jammin' + coordinator.play(); + } + + } + public void playPlayList(Command command) { List playlists = getPlayLists(); SonosEntry theEntry = null; @@ -1736,8 +1837,14 @@ public String getCurrentZoneName() { } public String getCurrentURIFormatted() { - updateCurrentURIFormatted(); + updateCurrentURIFormatted(getCurrentURI()); return stateMap.get("CurrentURIFormatted"); } + @Override + public void onStatusChanged(boolean status) { + // TODO Auto-generated method stub + + } + } diff --git a/addons/binding/pom.xml b/addons/binding/pom.xml index 05137cfe00006..0af0f2c14243f 100644 --- a/addons/binding/pom.xml +++ b/addons/binding/pom.xml @@ -18,6 +18,7 @@ org.openhab.binding.sonos org.openhab.binding.max + org.openhab.binding.max.test org.openhab.binding.networkhealth diff --git a/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF b/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF index 4bd2a33b4de43..5e98dcc29b1d1 100644 --- a/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF +++ b/bundles/core/org.openhab.core.compat1x/META-INF/MANIFEST.MF @@ -9,6 +9,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Import-Package: com.google.common.base, javax.servlet, javax.servlet.http, + javax.sound.sampled, org.apache.commons.collections, org.apache.commons.exec;version="1.1.0", org.apache.commons.httpclient;version="3.1.0", @@ -18,8 +19,11 @@ Import-Package: com.google.common.base, org.apache.commons.io;version="2.0.1", org.apache.commons.lang, org.apache.commons.net.util, + org.eclipse.emf.common.util, + org.eclipse.emf.ecore, org.eclipse.emf.ecore.resource, org.eclipse.smarthome.core.autoupdate, + org.eclipse.smarthome.core.common.registry, org.eclipse.smarthome.core.events, org.eclipse.smarthome.core.items, org.eclipse.smarthome.core.library.items, @@ -31,6 +35,9 @@ Import-Package: com.google.common.base, org.eclipse.smarthome.core.types, org.eclipse.smarthome.io.multimedia.tts, org.eclipse.smarthome.model.item, + org.eclipse.smarthome.model.sitemap, + org.eclipse.smarthome.ui.chart, + org.eclipse.smarthome.ui.items, org.openhab.io.multimedia.actions, org.openhab.library.tel.types, org.osgi.framework, @@ -53,12 +60,15 @@ Export-Package: org.openhab.core.autoupdate, org.openhab.core.types, org.openhab.io.console, org.openhab.io.multimedia.actions, + org.openhab.io.multimedia.tts, org.openhab.io.net.actions, org.openhab.io.net.exec, org.openhab.io.net.http, org.openhab.library.tel.items, org.openhab.library.tel.types, - org.openhab.model.item.binding + org.openhab.model.item.binding, + org.openhab.ui.chart, + org.openhab.ui.items Bundle-ClassPath: lib/jl1.0.1.jar, . -Service-Component: OSGI-INF/* +Service-Component: OSGI-INF/*.xml diff --git a/bundles/core/org.openhab.core.compat1x/OSGI-INF/chartproviderfactory.xml b/bundles/core/org.openhab.core.compat1x/OSGI-INF/chartproviderfactory.xml new file mode 100644 index 0000000000000..005406d4d87c9 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/OSGI-INF/chartproviderfactory.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bundles/core/org.openhab.core.compat1x/OSGI-INF/itemuiregistry.xml b/bundles/core/org.openhab.core.compat1x/OSGI-INF/itemuiregistry.xml new file mode 100644 index 0000000000000..0e23fdfb13724 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/OSGI-INF/itemuiregistry.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/OSGI-INF/tts_mary.xml b/bundles/core/org.openhab.core.compat1x/OSGI-INF/ttsservicefactory.xml similarity index 55% rename from bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/OSGI-INF/tts_mary.xml rename to bundles/core/org.openhab.core.compat1x/OSGI-INF/ttsservicefactory.xml index c439d8800e807..19d3b580796d0 100644 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/OSGI-INF/tts_mary.xml +++ b/bundles/core/org.openhab.core.compat1x/OSGI-INF/ttsservicefactory.xml @@ -2,16 +2,14 @@ - - - - - - + + + diff --git a/bundles/core/org.openhab.core.compat1x/build.properties b/bundles/core/org.openhab.core.compat1x/build.properties index 52fd2a4448dc6..a0811032723ae 100644 --- a/bundles/core/org.openhab.core.compat1x/build.properties +++ b/bundles/core/org.openhab.core.compat1x/build.properties @@ -7,5 +7,8 @@ bin.includes = META-INF/,\ OSGI-INF/eventbridge.xml,\ OSGI-INF/eventpublisherdelegate.xml,\ OSGI-INF/bindingconfigreaderfactory.xml,\ - OSGI-INF/actionservicefactory.xml + OSGI-INF/actionservicefactory.xml,\ + OSGI-INF/itemuiregistry.xml,\ + OSGI-INF/chartproviderfactory.xml,\ + OSGI-INF/ttsservicefactory.xml source.. = src/main/java/ diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/binding/internal/BindingConfigReaderDelegate.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/binding/internal/BindingConfigReaderDelegate.java index b93c58bfd9bed..16ded5ce357b4 100644 --- a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/binding/internal/BindingConfigReaderDelegate.java +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/binding/internal/BindingConfigReaderDelegate.java @@ -54,12 +54,6 @@ public void processBindingConfiguration(String context, String itemType, String } - @Override - public void removeConfigurations(String context) { - reader.removeConfigurations(context); - - } - private org.openhab.core.items.Item getOpenHABItem(String itemType) throws BindingConfigParseException { return getOpenHABItem(itemType, "itemName"); } @@ -81,4 +75,13 @@ private org.openhab.core.items.Item getOpenHABItem(String itemType, throw new BindingConfigParseException("cannot process unknown item type " + itemType); } + @Override + public void startConfigurationUpdate(String context) { + reader.removeConfigurations(context); + } + + @Override + public void stopConfigurationUpdate(String context) { + } + } diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/ItemMapper.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/ItemMapper.java index d9e93198c1aa0..7de31288823b2 100644 --- a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/ItemMapper.java +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/compat1x/internal/ItemMapper.java @@ -8,6 +8,7 @@ */ package org.openhab.core.compat1x.internal; +import org.eclipse.smarthome.core.items.GroupItem; import org.eclipse.smarthome.core.items.Item; import org.eclipse.smarthome.core.library.items.ColorItem; import org.eclipse.smarthome.core.library.items.ContactItem; @@ -34,7 +35,25 @@ public static org.openhab.core.items.Item mapToOpenHABItem(Item item) { if(item instanceof ColorItem) result = new org.openhab.core.library.items.ColorItem(item.getName()); if(item instanceof DateTimeItem) result = new org.openhab.core.library.items.DateTimeItem(item.getName()); if(item instanceof ESHCallItem) result = new org.openhab.library.tel.items.CallItem(item.getName()); - + + if(item instanceof GroupItem) { + GroupItem gItem = (GroupItem) item; + org.openhab.core.items.Item baseItem = ItemMapper.mapToOpenHABItem(gItem.getBaseItem()); + org.openhab.core.items.GroupItem ohgItem; + if(baseItem instanceof GenericItem) { + ohgItem = new org.openhab.core.items.GroupItem(item.getName(), (GenericItem) baseItem); + } else { + ohgItem = new org.openhab.core.items.GroupItem(item.getName()); + } + for(Item member : gItem.getMembers()) { + org.openhab.core.items.Item ohMember = ItemMapper.mapToOpenHABItem(member); + if(ohMember != null) { + ohgItem.addMember(ohMember); + } + } + result = ohgItem; + } + if(result instanceof org.openhab.core.items.GenericItem) { org.openhab.core.items.GenericItem genericItem = (GenericItem) result; if(item.getState()!=null) { diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/internal/ItemUIRegistryDelegate.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/internal/ItemUIRegistryDelegate.java new file mode 100644 index 0000000000000..8390d259700f4 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/internal/ItemUIRegistryDelegate.java @@ -0,0 +1,194 @@ +package org.openhab.core.items.internal; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.smarthome.core.common.registry.RegistryChangeListener; +import org.openhab.core.compat1x.internal.ItemMapper; +import org.openhab.core.items.Item; +import org.openhab.core.items.ItemNotFoundException; +import org.openhab.core.items.ItemNotUniqueException; +import org.openhab.core.items.ItemRegistryChangeListener; +import org.openhab.core.types.State; +import org.openhab.model.sitemap.LinkableWidget; +import org.openhab.model.sitemap.Sitemap; +import org.openhab.model.sitemap.Widget; +import org.openhab.ui.items.ItemUIRegistry; + +public class ItemUIRegistryDelegate implements ItemUIRegistry, RegistryChangeListener { + + private org.eclipse.smarthome.ui.items.ItemUIRegistry itemUIRegistry; + private Set listeners = new HashSet<>(); + + protected void setItemUIRegistry(org.eclipse.smarthome.ui.items.ItemUIRegistry itemUIRegistry) { + this.itemUIRegistry = itemUIRegistry; + itemUIRegistry.addRegistryChangeListener(this); + } + + protected void unsetItemUIRegistry(org.eclipse.smarthome.core.items.ItemRegistry itemUIRegistry) { + this.itemUIRegistry = null; + } + + @Override + public Item getItem(String name) throws ItemNotFoundException { + org.eclipse.smarthome.core.items.Item eshItem = itemUIRegistry.get(name); + return ItemMapper.mapToOpenHABItem(eshItem); + } + + @Override + public Item getItemByPattern(String name) throws ItemNotFoundException, ItemNotUniqueException { + org.eclipse.smarthome.core.items.Item eshItem; + try { + eshItem = itemUIRegistry.getItemByPattern(name); + } catch (org.eclipse.smarthome.core.items.ItemNotFoundException e) { + throw new ItemNotFoundException(name); + } catch (org.eclipse.smarthome.core.items.ItemNotUniqueException e) { + throw new ItemNotUniqueException(name, null); + } + return ItemMapper.mapToOpenHABItem(eshItem); + } + + @Override + public Collection getItems() { + Collection eshItems = itemUIRegistry.getItems(); + Collection ohItems = new HashSet(eshItems.size()); + + for(org.eclipse.smarthome.core.items.Item eshItem : eshItems) { + ohItems.add(ItemMapper.mapToOpenHABItem(eshItem)); + } + return ohItems; + } + + @Override + public Collection getItems(String pattern) { + Collection eshItems = itemUIRegistry.getItems(pattern); + Collection ohItems = new HashSet(eshItems.size()); + + for(org.eclipse.smarthome.core.items.Item eshItem : eshItems) { + ohItems.add(ItemMapper.mapToOpenHABItem(eshItem)); + } + return ohItems; + } + + @Override + public boolean isValidItemName(String itemName) { + return itemUIRegistry.isValidItemName(itemName); + } + + @Override + public void addItemRegistryChangeListener(ItemRegistryChangeListener listener) { + this.listeners.add(listener); + } + + @Override + public void removeItemRegistryChangeListener(ItemRegistryChangeListener listener) { + this.listeners.remove(listener); + } + + @Override + public void added(org.eclipse.smarthome.core.items.Item element) { + Item ohItem = ItemMapper.mapToOpenHABItem(element); + for(ItemRegistryChangeListener listener : listeners) { + listener.itemAdded(ohItem); + } + } + + @Override + public void removed(org.eclipse.smarthome.core.items.Item element) { + Item ohItem = ItemMapper.mapToOpenHABItem(element); + for(ItemRegistryChangeListener listener : listeners) { + listener.itemRemoved(ohItem); + } + } + + @Override + public void updated(org.eclipse.smarthome.core.items.Item oldElement, org.eclipse.smarthome.core.items.Item element) { + Item ohItem = ItemMapper.mapToOpenHABItem(element); + for(ItemRegistryChangeListener listener : listeners) { + listener.itemRemoved(ohItem); + listener.itemAdded(ohItem); + } + } + + @Override + public String getIcon(String itemName) { + return itemUIRegistry.getIcon(itemName); + } + + @Override + public String getLabel(String itemName) { + return itemUIRegistry.getLabel(itemName); + } + + @Override + public Widget getDefaultWidget(Class itemType, String itemName) { + return null; + } + + @Override + public Widget getWidget(String itemName) { + return null; + } + + @Override + public String getLabel(Widget w) { + return itemUIRegistry.getLabel(w.getItem()); + } + + @Override + public String getIcon(Widget w) { + return itemUIRegistry.getIcon(w.getItem()); + } + + @Override + public State getState(Widget w) { + return null; + } + + @Override + public Widget getWidget(Sitemap sitemap, String id) { + return null; + } + + @Override + public String getWidgetId(Widget w) { + return null; + } + + @Override + public EList getChildren(LinkableWidget w) { + return null; + } + + @Override + public boolean iconExists(String icon) { + return itemUIRegistry.iconExists(icon); + } + + @Override + public String getLabelColor(Widget w) { + return null; + } + + @Override + public String getValueColor(Widget w) { + return null; + } + + @Override + public boolean getVisiblity(Widget w) { + return true; + } + + @Override + public State getItemState(String itemName) { + try { + return getItem(itemName).getState(); + } catch (ItemNotFoundException e) { + return null; + } + } + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/actions/Audio.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/actions/Audio.java index b5059a5b0782a..a55cc38ef3c1f 100644 --- a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/actions/Audio.java +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/actions/Audio.java @@ -50,6 +50,7 @@ public class Audio { + private static final String RUNTIME_DIR ="runtime"; private static final String SOUND_DIR = "sounds"; private static final Logger logger = LoggerFactory.getLogger(Audio.class); @@ -65,7 +66,7 @@ public class Audio { static public void playSound( @ParamDoc(name="filename", text="the filename with extension") String filename) { try { - InputStream is = new FileInputStream(SOUND_DIR + File.separator + filename); + InputStream is = new FileInputStream(RUNTIME_DIR + File.separator + SOUND_DIR + File.separator + filename); if (filename.toLowerCase().endsWith(".mp3")) { Player player = new Player(is); playInThread(player); diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/TTSService.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/TTSService.java new file mode 100644 index 0000000000000..04c518ce9414f --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/TTSService.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * 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 + */ +package org.openhab.io.multimedia.tts; + +/** + * This is the interface that a text-to-speech service has to implement. + * + * @author Kai Kreuzer - Initial contribution and API + * + */ +public interface TTSService { + + /** + * Speaks the text with a given voice + * + * @param text + * the text to speak + * @param voice + * the name of the voice to use or null, if the default voice + * should be used + * @param device + * the name of audio device to be used to play the audio or null, + * if the default output device should be used + */ + void say(String text, String voice, String outputDevice); + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceDelegate.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceDelegate.java new file mode 100644 index 0000000000000..c94ef4cee2ae2 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceDelegate.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * 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 + */ +package org.openhab.io.multimedia.tts.internal; + +import org.eclipse.smarthome.io.multimedia.tts.TTSService; + +/** + * This class serves as a mapping from the "old" org.openhab namespace to the + * new org.eclipse.smarthome namespace for the action service. It wraps an + * instance with the old interface into a class with the new interface. + * + * @author Tobias Bräutigam - Initial contribution and API + */ +public class TTSServiceDelegate implements TTSService { + + private org.openhab.io.multimedia.tts.TTSService service; + + public TTSServiceDelegate(org.openhab.io.multimedia.tts.TTSService service) { + this.service = service; + } + + @Override + public void say(String text, String voice, String outputDevice) { + service.say(text, voice, outputDevice); + } + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceFactory.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceFactory.java new file mode 100644 index 0000000000000..62c5220239d5d --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/multimedia/tts/internal/TTSServiceFactory.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * 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 + */ +package org.openhab.io.multimedia.tts.internal; + +import java.net.URL; +import java.util.Collection; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Map; +import java.util.Set; + +import org.openhab.core.compat1x.internal.CompatibilityActivator; +import org.openhab.io.multimedia.tts.TTSService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class listens for services that implement the old tts service interface + * and registers an according service for each under the new interface. + * + * @author Tobias Bräutigam - Initial contribution and API (copied from + * ActionServiceFactory) + */ +public class TTSServiceFactory { + private static final Logger logger = LoggerFactory + .getLogger(TTSServiceFactory.class); + + private Map> delegates = new HashMap<>(); + private BundleContext context; + + private Map ttsServices = new HashMap<>(); + + public void activate(BundleContext context) { + this.context = context; + for (TTSService service : ttsServices.keySet()) { + registerDelegateService(service,ttsServices.get(service)); + } + } + + public void deactivate() { + for (ServiceRegistration serviceReg : delegates + .values()) { + serviceReg.unregister(); + } + delegates.clear(); + this.context = null; + } + + public void addTTSService(TTSService service, Map prop) { + if (context != null) { + registerDelegateService(service,prop); + } else { + ttsServices.put(service,prop); + } + } + + public void removeTTSService(TTSService service) { + if (context != null) { + unregisterDelegateService(service); + } + } + + private void registerDelegateService(TTSService ttsService, Map properties) { + if (!delegates.containsKey(ttsService.getClass().getName())) { + TTSServiceDelegate service = new TTSServiceDelegate(ttsService); + Dictionary props = new Hashtable(); + if (properties != null && properties.containsKey("os")) + props.put("os", properties.get("os")); + ServiceRegistration serviceReg = context + .registerService( + org.eclipse.smarthome.io.multimedia.tts.TTSService.class, + service, props); + delegates.put(ttsService.getClass().getName(), serviceReg); + } + } + + private void unregisterDelegateService(TTSService service) { + if (delegates.containsKey(service.getClass().getName())) { + ServiceRegistration serviceReg = delegates + .get(service.getClass().getName()); + delegates.remove(service.getClass().getName()); + serviceReg.unregister(); + } + } +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/actions/Ping.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/actions/Ping.java index 5d939feea7f0e..bbc5294bbb118 100644 --- a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/actions/Ping.java +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/actions/Ping.java @@ -50,9 +50,11 @@ public static boolean checkVitality(String host, int port, int timeout) throws I } else { SocketAddress socketAddress = new InetSocketAddress(host, port); - - Socket socket = new Socket(); - socket.connect(socketAddress, timeout); + + try (Socket socket = new Socket()) { + socket.connect(socketAddress, timeout); + } + success = true; } } diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/http/SecureHttpContext.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/http/SecureHttpContext.java new file mode 100644 index 0000000000000..8132a2179a4c8 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/http/SecureHttpContext.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2010-2014, openHAB.org and others. + * + * 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 + */ +package org.openhab.io.net.http; + +import java.io.IOException; +import java.net.URL; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.osgi.service.http.HttpContext; + + +/** + * Implementation of {@link HttpContext} which adds Basic-Authentication + * functionality to openHAB. + * + * @author Thomas.Eichstaedt-Engelen + * @since 0.9.0 + */ +public class SecureHttpContext implements HttpContext { + + private HttpContext defaultContext = null; + + public SecureHttpContext() { + } + + public SecureHttpContext(HttpContext defaultContext, final String realm) { + this.defaultContext = defaultContext; + } + + + /** + *

@{inheritDoc}

+ *

Delegates to defaultContext.getMimeType() + */ + public String getMimeType(String name) { + return this.defaultContext.getMimeType(name); + } + + /** + *

@{inheritDoc}

+ *

Delegates to defaultContext.getResource() + */ + public URL getResource(String name) { + return this.defaultContext.getResource(name); + } + + @Override + public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException { + return true; + } + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Chart.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Chart.java new file mode 100644 index 0000000000000..b0f21c3e29b77 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Chart.java @@ -0,0 +1,104 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Chart'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Chart#getService Service}
  • + *
  • {@link org.openhab.model.sitemap.Chart#getRefresh Refresh}
  • + *
  • {@link org.openhab.model.sitemap.Chart#getPeriod Period}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getChart() + * @model + * @generated + */ +public interface Chart extends NonLinkableWidget +{ + /** + * Returns the value of the 'Service' attribute. + * + *

+ * If the meaning of the 'Service' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Service' attribute. + * @see #setService(String) + * @see org.openhab.model.sitemap.SitemapPackage#getChart_Service() + * @model + * @generated + */ + String getService(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Chart#getService Service}' attribute. + * + * + * @param value the new value of the 'Service' attribute. + * @see #getService() + * @generated + */ + void setService(String value); + + /** + * Returns the value of the 'Refresh' attribute. + * + *

+ * If the meaning of the 'Refresh' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Refresh' attribute. + * @see #setRefresh(int) + * @see org.openhab.model.sitemap.SitemapPackage#getChart_Refresh() + * @model + * @generated + */ + int getRefresh(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Chart#getRefresh Refresh}' attribute. + * + * + * @param value the new value of the 'Refresh' attribute. + * @see #getRefresh() + * @generated + */ + void setRefresh(int value); + + /** + * Returns the value of the 'Period' attribute. + * + *

+ * If the meaning of the 'Period' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Period' attribute. + * @see #setPeriod(String) + * @see org.openhab.model.sitemap.SitemapPackage#getChart_Period() + * @model + * @generated + */ + String getPeriod(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Chart#getPeriod Period}' attribute. + * + * + * @param value the new value of the 'Period' attribute. + * @see #getPeriod() + * @generated + */ + void setPeriod(String value); + +} // Chart diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/ColorArray.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/ColorArray.java new file mode 100644 index 0000000000000..8d4b59727f375 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/ColorArray.java @@ -0,0 +1,159 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Color Array'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.ColorArray#getItem Item}
  • + *
  • {@link org.openhab.model.sitemap.ColorArray#getCondition Condition}
  • + *
  • {@link org.openhab.model.sitemap.ColorArray#getSign Sign}
  • + *
  • {@link org.openhab.model.sitemap.ColorArray#getState State}
  • + *
  • {@link org.openhab.model.sitemap.ColorArray#getArg Arg}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray() + * @model + * @generated + */ +public interface ColorArray extends EObject +{ + /** + * Returns the value of the 'Item' attribute. + * + *

+ * If the meaning of the 'Item' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Item' attribute. + * @see #setItem(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Item() + * @model + * @generated + */ + String getItem(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getItem Item}' attribute. + * + * + * @param value the new value of the 'Item' attribute. + * @see #getItem() + * @generated + */ + void setItem(String value); + + /** + * Returns the value of the 'Condition' attribute. + * + *

+ * If the meaning of the 'Condition' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Condition' attribute. + * @see #setCondition(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Condition() + * @model + * @generated + */ + String getCondition(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getCondition Condition}' attribute. + * + * + * @param value the new value of the 'Condition' attribute. + * @see #getCondition() + * @generated + */ + void setCondition(String value); + + /** + * Returns the value of the 'Sign' attribute. + * + *

+ * If the meaning of the 'Sign' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Sign' attribute. + * @see #setSign(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Sign() + * @model + * @generated + */ + String getSign(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getSign Sign}' attribute. + * + * + * @param value the new value of the 'Sign' attribute. + * @see #getSign() + * @generated + */ + void setSign(String value); + + /** + * Returns the value of the 'State' attribute. + * + *

+ * If the meaning of the 'State' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'State' attribute. + * @see #setState(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_State() + * @model + * @generated + */ + String getState(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getState State}' attribute. + * + * + * @param value the new value of the 'State' attribute. + * @see #getState() + * @generated + */ + void setState(String value); + + /** + * Returns the value of the 'Arg' attribute. + * + *

+ * If the meaning of the 'Arg' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Arg' attribute. + * @see #setArg(String) + * @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Arg() + * @model + * @generated + */ + String getArg(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getArg Arg}' attribute. + * + * + * @param value the new value of the 'Arg' attribute. + * @see #getArg() + * @generated + */ + void setArg(String value); + +} // ColorArray diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Colorpicker.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Colorpicker.java new file mode 100644 index 0000000000000..a3ec46013c6d1 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Colorpicker.java @@ -0,0 +1,50 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Colorpicker'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Colorpicker#getFrequency Frequency}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getColorpicker() + * @model + * @generated + */ +public interface Colorpicker extends NonLinkableWidget +{ + /** + * Returns the value of the 'Frequency' attribute. + * + *

+ * If the meaning of the 'Frequency' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Frequency' attribute. + * @see #setFrequency(int) + * @see org.openhab.model.sitemap.SitemapPackage#getColorpicker_Frequency() + * @model + * @generated + */ + int getFrequency(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Colorpicker#getFrequency Frequency}' attribute. + * + * + * @param value the new value of the 'Frequency' attribute. + * @see #getFrequency() + * @generated + */ + void setFrequency(int value); + +} // Colorpicker diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Frame.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Frame.java new file mode 100644 index 0000000000000..0d7ab945a6242 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Frame.java @@ -0,0 +1,18 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Frame'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getFrame() + * @model + * @generated + */ +public interface Frame extends LinkableWidget +{ +} // Frame diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Group.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Group.java new file mode 100644 index 0000000000000..5de36047d1db8 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Group.java @@ -0,0 +1,18 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Group'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getGroup() + * @model + * @generated + */ +public interface Group extends LinkableWidget +{ +} // Group diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Image.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Image.java new file mode 100644 index 0000000000000..50c3f3e5ce634 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Image.java @@ -0,0 +1,95 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Image'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Image#getUrl Url}
  • + *
  • {@link org.openhab.model.sitemap.Image#getRefresh Refresh}
  • + *
  • {@link org.openhab.model.sitemap.Image#getIconColor Icon Color}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getImage() + * @model + * @generated + */ +public interface Image extends LinkableWidget +{ + /** + * Returns the value of the 'Url' attribute. + * + *

+ * If the meaning of the 'Url' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Url' attribute. + * @see #setUrl(String) + * @see org.openhab.model.sitemap.SitemapPackage#getImage_Url() + * @model + * @generated + */ + String getUrl(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Image#getUrl Url}' attribute. + * + * + * @param value the new value of the 'Url' attribute. + * @see #getUrl() + * @generated + */ + void setUrl(String value); + + /** + * Returns the value of the 'Refresh' attribute. + * + *

+ * If the meaning of the 'Refresh' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Refresh' attribute. + * @see #setRefresh(int) + * @see org.openhab.model.sitemap.SitemapPackage#getImage_Refresh() + * @model + * @generated + */ + int getRefresh(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Image#getRefresh Refresh}' attribute. + * + * + * @param value the new value of the 'Refresh' attribute. + * @see #getRefresh() + * @generated + */ + void setRefresh(int value); + + /** + * Returns the value of the 'Icon Color' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.ColorArray}. + * + *

+ * If the meaning of the 'Icon Color' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Icon Color' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getImage_IconColor() + * @model containment="true" + * @generated + */ + EList getIconColor(); + +} // Image diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/LinkableWidget.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/LinkableWidget.java new file mode 100644 index 0000000000000..43236894c2646 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/LinkableWidget.java @@ -0,0 +1,41 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Linkable Widget'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.LinkableWidget#getChildren Children}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getLinkableWidget() + * @model + * @generated + */ +public interface LinkableWidget extends Widget +{ + /** + * Returns the value of the 'Children' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.Widget}. + * + *

+ * If the meaning of the 'Children' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Children' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getLinkableWidget_Children() + * @model containment="true" + * @generated + */ + EList getChildren(); + +} // LinkableWidget diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/List.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/List.java new file mode 100644 index 0000000000000..6b9ab068650b6 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/List.java @@ -0,0 +1,50 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'List'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.List#getSeparator Separator}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getList() + * @model + * @generated + */ +public interface List extends NonLinkableWidget +{ + /** + * Returns the value of the 'Separator' attribute. + * + *

+ * If the meaning of the 'Separator' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Separator' attribute. + * @see #setSeparator(String) + * @see org.openhab.model.sitemap.SitemapPackage#getList_Separator() + * @model + * @generated + */ + String getSeparator(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.List#getSeparator Separator}' attribute. + * + * + * @param value the new value of the 'Separator' attribute. + * @see #getSeparator() + * @generated + */ + void setSeparator(String value); + +} // List diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Mapping.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Mapping.java new file mode 100644 index 0000000000000..3b66359020802 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Mapping.java @@ -0,0 +1,78 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Mapping'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Mapping#getCmd Cmd}
  • + *
  • {@link org.openhab.model.sitemap.Mapping#getLabel Label}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getMapping() + * @model + * @generated + */ +public interface Mapping extends EObject +{ + /** + * Returns the value of the 'Cmd' attribute. + * + *

+ * If the meaning of the 'Cmd' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Cmd' attribute. + * @see #setCmd(String) + * @see org.openhab.model.sitemap.SitemapPackage#getMapping_Cmd() + * @model + * @generated + */ + String getCmd(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getCmd Cmd}' attribute. + * + * + * @param value the new value of the 'Cmd' attribute. + * @see #getCmd() + * @generated + */ + void setCmd(String value); + + /** + * Returns the value of the 'Label' attribute. + * + *

+ * If the meaning of the 'Label' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Label' attribute. + * @see #setLabel(String) + * @see org.openhab.model.sitemap.SitemapPackage#getMapping_Label() + * @model + * @generated + */ + String getLabel(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getLabel Label}' attribute. + * + * + * @param value the new value of the 'Label' attribute. + * @see #getLabel() + * @generated + */ + void setLabel(String value); + +} // Mapping diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/NonLinkableWidget.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/NonLinkableWidget.java new file mode 100644 index 0000000000000..a44084587a4e3 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/NonLinkableWidget.java @@ -0,0 +1,18 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Non Linkable Widget'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getNonLinkableWidget() + * @model + * @generated + */ +public interface NonLinkableWidget extends Widget +{ +} // NonLinkableWidget diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Selection.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Selection.java new file mode 100644 index 0000000000000..36784aafcc822 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Selection.java @@ -0,0 +1,41 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Selection'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Selection#getMappings Mappings}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSelection() + * @model + * @generated + */ +public interface Selection extends NonLinkableWidget +{ + /** + * Returns the value of the 'Mappings' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.Mapping}. + * + *

+ * If the meaning of the 'Mappings' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Mappings' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getSelection_Mappings() + * @model containment="true" + * @generated + */ + EList getMappings(); + +} // Selection diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Setpoint.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Setpoint.java new file mode 100644 index 0000000000000..bca7016396af5 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Setpoint.java @@ -0,0 +1,105 @@ +/** + */ +package org.openhab.model.sitemap; + +import java.math.BigDecimal; + +/** + * + * A representation of the model object 'Setpoint'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Setpoint#getMinValue Min Value}
  • + *
  • {@link org.openhab.model.sitemap.Setpoint#getMaxValue Max Value}
  • + *
  • {@link org.openhab.model.sitemap.Setpoint#getStep Step}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSetpoint() + * @model + * @generated + */ +public interface Setpoint extends NonLinkableWidget +{ + /** + * Returns the value of the 'Min Value' attribute. + * + *

+ * If the meaning of the 'Min Value' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Min Value' attribute. + * @see #setMinValue(BigDecimal) + * @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MinValue() + * @model + * @generated + */ + BigDecimal getMinValue(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMinValue Min Value}' attribute. + * + * + * @param value the new value of the 'Min Value' attribute. + * @see #getMinValue() + * @generated + */ + void setMinValue(BigDecimal value); + + /** + * Returns the value of the 'Max Value' attribute. + * + *

+ * If the meaning of the 'Max Value' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Max Value' attribute. + * @see #setMaxValue(BigDecimal) + * @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MaxValue() + * @model + * @generated + */ + BigDecimal getMaxValue(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMaxValue Max Value}' attribute. + * + * + * @param value the new value of the 'Max Value' attribute. + * @see #getMaxValue() + * @generated + */ + void setMaxValue(BigDecimal value); + + /** + * Returns the value of the 'Step' attribute. + * + *

+ * If the meaning of the 'Step' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Step' attribute. + * @see #setStep(BigDecimal) + * @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_Step() + * @model + * @generated + */ + BigDecimal getStep(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getStep Step}' attribute. + * + * + * @param value the new value of the 'Step' attribute. + * @see #getStep() + * @generated + */ + void setStep(BigDecimal value); + +} // Setpoint diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Sitemap.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Sitemap.java new file mode 100644 index 0000000000000..c01b333876df2 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Sitemap.java @@ -0,0 +1,122 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Sitemap'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Sitemap#getName Name}
  • + *
  • {@link org.openhab.model.sitemap.Sitemap#getLabel Label}
  • + *
  • {@link org.openhab.model.sitemap.Sitemap#getIcon Icon}
  • + *
  • {@link org.openhab.model.sitemap.Sitemap#getChildren Children}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap() + * @model + * @generated + */ +public interface Sitemap extends SitemapModel +{ + /** + * Returns the value of the 'Name' attribute. + * + *

+ * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Name() + * @model + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the 'Label' attribute. + * + *

+ * If the meaning of the 'Label' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Label' attribute. + * @see #setLabel(String) + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Label() + * @model + * @generated + */ + String getLabel(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getLabel Label}' attribute. + * + * + * @param value the new value of the 'Label' attribute. + * @see #getLabel() + * @generated + */ + void setLabel(String value); + + /** + * Returns the value of the 'Icon' attribute. + * + *

+ * If the meaning of the 'Icon' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Icon' attribute. + * @see #setIcon(String) + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Icon() + * @model + * @generated + */ + String getIcon(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getIcon Icon}' attribute. + * + * + * @param value the new value of the 'Icon' attribute. + * @see #getIcon() + * @generated + */ + void setIcon(String value); + + /** + * Returns the value of the 'Children' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.Widget}. + * + *

+ * If the meaning of the 'Children' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Children' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Children() + * @model containment="true" + * @generated + */ + EList getChildren(); + +} // Sitemap diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/SitemapModel.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/SitemapModel.java new file mode 100644 index 0000000000000..19ff030deecf9 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/SitemapModel.java @@ -0,0 +1,19 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Model'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getSitemapModel() + * @model + * @generated + */ +public interface SitemapModel extends EObject +{ +} // SitemapModel diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Slider.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Slider.java new file mode 100644 index 0000000000000..135b055b7f3c4 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Slider.java @@ -0,0 +1,77 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Slider'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Slider#getFrequency Frequency}
  • + *
  • {@link org.openhab.model.sitemap.Slider#isSwitchEnabled Switch Enabled}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSlider() + * @model + * @generated + */ +public interface Slider extends NonLinkableWidget +{ + /** + * Returns the value of the 'Frequency' attribute. + * + *

+ * If the meaning of the 'Frequency' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Frequency' attribute. + * @see #setFrequency(int) + * @see org.openhab.model.sitemap.SitemapPackage#getSlider_Frequency() + * @model + * @generated + */ + int getFrequency(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Slider#getFrequency Frequency}' attribute. + * + * + * @param value the new value of the 'Frequency' attribute. + * @see #getFrequency() + * @generated + */ + void setFrequency(int value); + + /** + * Returns the value of the 'Switch Enabled' attribute. + * + *

+ * If the meaning of the 'Switch Enabled' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Switch Enabled' attribute. + * @see #setSwitchEnabled(boolean) + * @see org.openhab.model.sitemap.SitemapPackage#getSlider_SwitchEnabled() + * @model + * @generated + */ + boolean isSwitchEnabled(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Slider#isSwitchEnabled Switch Enabled}' attribute. + * + * + * @param value the new value of the 'Switch Enabled' attribute. + * @see #isSwitchEnabled() + * @generated + */ + void setSwitchEnabled(boolean value); + +} // Slider diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Switch.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Switch.java new file mode 100644 index 0000000000000..9e25290d7d256 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Switch.java @@ -0,0 +1,41 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'Switch'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Switch#getMappings Mappings}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getSwitch() + * @model + * @generated + */ +public interface Switch extends NonLinkableWidget +{ + /** + * Returns the value of the 'Mappings' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.Mapping}. + * + *

+ * If the meaning of the 'Mappings' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Mappings' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getSwitch_Mappings() + * @model containment="true" + * @generated + */ + EList getMappings(); + +} // Switch diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Text.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Text.java new file mode 100644 index 0000000000000..07c57d5676db1 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Text.java @@ -0,0 +1,18 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Text'. + * + * + * + * @see org.openhab.model.sitemap.SitemapPackage#getText() + * @model + * @generated + */ +public interface Text extends LinkableWidget +{ +} // Text diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Video.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Video.java new file mode 100644 index 0000000000000..379a1bee0df93 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Video.java @@ -0,0 +1,50 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Video'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Video#getUrl Url}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getVideo() + * @model + * @generated + */ +public interface Video extends NonLinkableWidget +{ + /** + * Returns the value of the 'Url' attribute. + * + *

+ * If the meaning of the 'Url' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Url' attribute. + * @see #setUrl(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVideo_Url() + * @model + * @generated + */ + String getUrl(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Video#getUrl Url}' attribute. + * + * + * @param value the new value of the 'Url' attribute. + * @see #getUrl() + * @generated + */ + void setUrl(String value); + +} // Video diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/VisibilityRule.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/VisibilityRule.java new file mode 100644 index 0000000000000..3eac63a984020 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/VisibilityRule.java @@ -0,0 +1,132 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Visibility Rule'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.VisibilityRule#getItem Item}
  • + *
  • {@link org.openhab.model.sitemap.VisibilityRule#getCondition Condition}
  • + *
  • {@link org.openhab.model.sitemap.VisibilityRule#getSign Sign}
  • + *
  • {@link org.openhab.model.sitemap.VisibilityRule#getState State}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule() + * @model + * @generated + */ +public interface VisibilityRule extends EObject +{ + /** + * Returns the value of the 'Item' attribute. + * + *

+ * If the meaning of the 'Item' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Item' attribute. + * @see #setItem(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Item() + * @model + * @generated + */ + String getItem(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getItem Item}' attribute. + * + * + * @param value the new value of the 'Item' attribute. + * @see #getItem() + * @generated + */ + void setItem(String value); + + /** + * Returns the value of the 'Condition' attribute. + * + *

+ * If the meaning of the 'Condition' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Condition' attribute. + * @see #setCondition(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Condition() + * @model + * @generated + */ + String getCondition(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getCondition Condition}' attribute. + * + * + * @param value the new value of the 'Condition' attribute. + * @see #getCondition() + * @generated + */ + void setCondition(String value); + + /** + * Returns the value of the 'Sign' attribute. + * + *

+ * If the meaning of the 'Sign' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Sign' attribute. + * @see #setSign(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Sign() + * @model + * @generated + */ + String getSign(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getSign Sign}' attribute. + * + * + * @param value the new value of the 'Sign' attribute. + * @see #getSign() + * @generated + */ + void setSign(String value); + + /** + * Returns the value of the 'State' attribute. + * + *

+ * If the meaning of the 'State' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'State' attribute. + * @see #setState(String) + * @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_State() + * @model + * @generated + */ + String getState(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getState State}' attribute. + * + * + * @param value the new value of the 'State' attribute. + * @see #getState() + * @generated + */ + void setState(String value); + +} // VisibilityRule diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Webview.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Webview.java new file mode 100644 index 0000000000000..4ec866416fa22 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Webview.java @@ -0,0 +1,77 @@ +/** + */ +package org.openhab.model.sitemap; + + +/** + * + * A representation of the model object 'Webview'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Webview#getHeight Height}
  • + *
  • {@link org.openhab.model.sitemap.Webview#getUrl Url}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getWebview() + * @model + * @generated + */ +public interface Webview extends NonLinkableWidget +{ + /** + * Returns the value of the 'Height' attribute. + * + *

+ * If the meaning of the 'Height' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Height' attribute. + * @see #setHeight(int) + * @see org.openhab.model.sitemap.SitemapPackage#getWebview_Height() + * @model + * @generated + */ + int getHeight(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Webview#getHeight Height}' attribute. + * + * + * @param value the new value of the 'Height' attribute. + * @see #getHeight() + * @generated + */ + void setHeight(int value); + + /** + * Returns the value of the 'Url' attribute. + * + *

+ * If the meaning of the 'Url' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Url' attribute. + * @see #setUrl(String) + * @see org.openhab.model.sitemap.SitemapPackage#getWebview_Url() + * @model + * @generated + */ + String getUrl(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Webview#getUrl Url}' attribute. + * + * + * @param value the new value of the 'Url' attribute. + * @see #getUrl() + * @generated + */ + void setUrl(String value); + +} // Webview diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Widget.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Widget.java new file mode 100644 index 0000000000000..9cbd6342370b2 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/model/sitemap/Widget.java @@ -0,0 +1,158 @@ +/** + */ +package org.openhab.model.sitemap; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Widget'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.openhab.model.sitemap.Widget#getItem Item}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getLabel Label}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getIcon Icon}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getLabelColor Label Color}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getValueColor Value Color}
  • + *
  • {@link org.openhab.model.sitemap.Widget#getVisibility Visibility}
  • + *
+ *

+ * + * @see org.openhab.model.sitemap.SitemapPackage#getWidget() + * @model + * @generated + */ +public interface Widget extends EObject +{ + /** + * Returns the value of the 'Item' attribute. + * + *

+ * If the meaning of the 'Item' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Item' attribute. + * @see #setItem(String) + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Item() + * @model + * @generated + */ + String getItem(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Widget#getItem Item}' attribute. + * + * + * @param value the new value of the 'Item' attribute. + * @see #getItem() + * @generated + */ + void setItem(String value); + + /** + * Returns the value of the 'Label' attribute. + * + *

+ * If the meaning of the 'Label' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Label' attribute. + * @see #setLabel(String) + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Label() + * @model + * @generated + */ + String getLabel(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Widget#getLabel Label}' attribute. + * + * + * @param value the new value of the 'Label' attribute. + * @see #getLabel() + * @generated + */ + void setLabel(String value); + + /** + * Returns the value of the 'Icon' attribute. + * + *

+ * If the meaning of the 'Icon' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Icon' attribute. + * @see #setIcon(String) + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Icon() + * @model + * @generated + */ + String getIcon(); + + /** + * Sets the value of the '{@link org.openhab.model.sitemap.Widget#getIcon Icon}' attribute. + * + * + * @param value the new value of the 'Icon' attribute. + * @see #getIcon() + * @generated + */ + void setIcon(String value); + + /** + * Returns the value of the 'Label Color' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.ColorArray}. + * + *

+ * If the meaning of the 'Label Color' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Label Color' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_LabelColor() + * @model containment="true" + * @generated + */ + EList getLabelColor(); + + /** + * Returns the value of the 'Value Color' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.ColorArray}. + * + *

+ * If the meaning of the 'Value Color' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Value Color' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_ValueColor() + * @model containment="true" + * @generated + */ + EList getValueColor(); + + /** + * Returns the value of the 'Visibility' containment reference list. + * The list contents are of type {@link org.openhab.model.sitemap.VisibilityRule}. + * + *

+ * If the meaning of the 'Visibility' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Visibility' containment reference list. + * @see org.openhab.model.sitemap.SitemapPackage#getWidget_Visibility() + * @model containment="true" + * @generated + */ + EList getVisibility(); + +} // Widget diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/ChartProvider.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/ChartProvider.java new file mode 100644 index 0000000000000..17dfeb5f8ae2f --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/ChartProvider.java @@ -0,0 +1,82 @@ +package org.openhab.ui.chart; + +import java.awt.image.BufferedImage; +import java.util.Date; + +import org.openhab.core.items.ItemNotFoundException; + +/** + * Defines the interface for chart providers. A chart provider interfaces with + * the persistence store to get the data and receives parameters from the UI + * chart servlet and returns a chart image object (PNG). + * + * @author Chris Jackson + * @since 1.4.0 + * + * + */ +public interface ChartProvider { + /** + * Gets the name of this chart provider. + * + * @return String containing the provider name + */ + String getName(); + + /** + * Creates a chart object. This sets the initial parameters for the chart + * before the items are added + * + * @param service + * A string containing the name of the persistence service. May + * be null in which case the chart provider can decide itself + * which store to use. + * @param widget + * The widget ID. This allows the chart provider to look up the + * widget and get the items directly from the sitemap definition. + * May be null. + * @param theme + * A string containing a theme name for the chart. The provider + * should store its own themes. May be null to use a default + * theme. + * @param height + * The height of the chart. + * @param width + * The width of the chart. + * @param startTime + * The start time of the chart + * @param endTime + * The end time of the chart + * @param height + * The height of the chart + * @param width + * The width of the chart + * @param items + * The items to display on the chart + * @param groups + * The groups to display on the chart + * + * @return BufferedImage object if the chart is rendered correctly, + * otherwise null. + * + * @throws ItemNotFoundException if an item or group is not found + * @throws IllegalArgumentException if an invalid argument is passed + */ + BufferedImage createChart(String service, String theme, Date startTime, Date endTime, int height, + int width, String items, String groups) throws ItemNotFoundException; + + /** + * Gets the type of data that will be written by the chart. + * + * @return ImageType + */ + ImageType getChartType(); + + /** + * Provides a list of image types + * + */ + public enum ImageType { + png, jpg, gif; + } +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderDelegate.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderDelegate.java new file mode 100644 index 0000000000000..e6c0338db2c17 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderDelegate.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * 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 + */ +package org.openhab.ui.chart.internal; + +import java.awt.image.BufferedImage; +import java.util.Date; + +import org.apache.commons.lang.StringUtils; +import org.eclipse.smarthome.core.items.ItemNotFoundException; +import org.openhab.ui.chart.ChartProvider; + + +/** + * This class serves as a mapping from the "old" org.openhab namespace to the new org.eclipse.smarthome + * namespace for the action service. It wraps an instance with the old interface + * into a class with the new interface. + * + * @author Kai Kreuzer - Initial contribution and API + */ +public class ChartProviderDelegate implements org.eclipse.smarthome.ui.chart.ChartProvider { + + private ChartProvider provider; + + public ChartProviderDelegate(ChartProvider chartProvider) { + this.provider = chartProvider; + } + + @Override + public String getName() { + return provider.getName(); + } + + @Override + public BufferedImage createChart(String service, String theme, Date startTime, Date endTime, int height, int width, + String items, String groups) throws ItemNotFoundException { + try { + return provider.createChart(service, theme, startTime, endTime, height, width, items, groups); + } catch (org.openhab.core.items.ItemNotFoundException e) { + throw new ItemNotFoundException(StringUtils.substringBetween(e.getMessage(), "'")); + } + } + + @Override + public ImageType getChartType() { + return ImageType.valueOf(provider.getChartType().name()); + } + +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderFactory.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderFactory.java new file mode 100644 index 0000000000000..393e9664c0c1d --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/chart/internal/ChartProviderFactory.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. + * + * 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 + */ +package org.openhab.ui.chart.internal; + +import java.util.Dictionary; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Map; +import java.util.Set; + +import org.openhab.ui.chart.ChartProvider; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +/** + * This class listens for services that implement the old chart provider service interface and registers + * an according service for each under the new interface. + * + * @author Kai Kreuzer - Initial contribution and API + */ +public class ChartProviderFactory { + + private Map> delegates = new HashMap<>(); + private BundleContext context; + + private Set chartProviders = new HashSet<>(); + + public void activate(BundleContext context) { + this.context = context; + for(ChartProvider provider : chartProviders) { + registerDelegateProvider(provider); + } + } + + public void deactivate() { + for(ServiceRegistration serviceReg : delegates.values()) { + serviceReg.unregister(); + } + delegates.clear(); + this.context = null; + } + + public void addChartProvider(ChartProvider provider) { + if(context!=null) { + registerDelegateProvider(provider); + } else { + chartProviders.add(provider); + } + } + + public void removeChartProvider(ChartProvider provider) { + if(context!=null) { + unregisterDelegateProvider(provider); + } + } + + private void registerDelegateProvider(ChartProvider chartProvider) { + if(!delegates.containsKey(chartProvider.getName())) { + ChartProviderDelegate service = new ChartProviderDelegate(chartProvider); + Dictionary props = new Hashtable(); + ServiceRegistration serviceReg = + context.registerService(org.eclipse.smarthome.ui.chart.ChartProvider.class, service, props); + delegates.put(chartProvider.getName(), serviceReg); + } + } + + private void unregisterDelegateProvider(ChartProvider chartProvider) { + if(delegates.containsKey(chartProvider.getName())) { + ServiceRegistration serviceReg = + delegates.get(chartProvider.getName()); + delegates.remove(chartProvider.getName()); + serviceReg.unregister(); + } + } +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIProvider.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIProvider.java new file mode 100644 index 0000000000000..6ea8ec247b8a7 --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIProvider.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2010-2014, openHAB.org and others. + * + * 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 + */ +package org.openhab.ui.items; + +import org.openhab.core.items.Item; +import org.openhab.model.sitemap.Widget; + + +/** + * This interface describes the methods that need to be implemented by a provider that + * wants to define the appearance of an item in the UI. + * + * @author Kai Kreuzer + * + */ +public interface ItemUIProvider { + + /** + * Returns the name of a bitmap to use as an icon. This name does not need to include + * state information or a file extension; if these are missing, they will be automatically added. + * + * TODO: Note that the consumer of this provider needs to be aware of these icons, so we + * have some implicit dependency between them. Maybe worth refactoring? + * + * @param itemName the name of the item to return the icon for + * @return the name of the icon to use or null if undefined. + */ + public String getIcon(String itemName); + + /** + * Returns the label text to be used for an item in the UI. + * + * @param item the name of the item to return the label text for + * @return the label text to be used in the UI or null if undefined. + */ + public String getLabel(String itemName); + + /** + * Provides a default widget for a given item (class). This is used whenever + * the UI needs to be created dynamically and there is no other source + * of information about the widgets. + * + * @param itemType the class of the item + * @param itemName the item name to get the default widget for + * + * @return a widget implementation that can be used for the given item + */ + public Widget getDefaultWidget(Class itemType, String itemName); + + /** + *

Provides a widget for a given item. This can be used to overwrite the widget + * listed in the sitemap. A use case for this is that the sitemap defines merely + * the parent-child-relation of widgets, but the concrete widget to be used for + * rendering might be selected dynamically at runtime.

+ *

If the sitemap widget should not be overridden, this method must return + * null.

+ * + * @param itemName the item name to get the widget for + * @return a widget to use for the given item or null if sitemap should not be overridden. + */ + public Widget getWidget(String itemName); +} diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIRegistry.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIRegistry.java new file mode 100644 index 0000000000000..f78376b53c90c --- /dev/null +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/ui/items/ItemUIRegistry.java @@ -0,0 +1,158 @@ +/** + * Copyright (c) 2010-2014, openHAB.org and others. + * + * 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 + */ +package org.openhab.ui.items; + +import org.eclipse.emf.common.util.EList; +import org.openhab.core.items.ItemRegistry; +import org.openhab.core.types.State; +import org.openhab.model.sitemap.LinkableWidget; +import org.openhab.model.sitemap.Sitemap; +import org.openhab.model.sitemap.Widget; + +/** + * This interface is used by a service which combines the core item registry + * with an aggregation of item ui providers; it can be therefore widely used for + * all UI related information requests regarding items. + * + * @author Kai Kreuzer + * @author Chris Jackson + * @since 0.8.0 + * + */ +public interface ItemUIRegistry extends ItemRegistry, ItemUIProvider { + + /** + * Retrieves the label for a widget. + * + * This first checks, if there is a label defined in the sitemap. If not, it + * checks all item UI providers for a label. If no label can be found, it is + * set to an empty string. + * + * If the label contains a "[%format]" section, i.e. + * “[%s]" for a string or "[%.3f]" for a decimal, this is replaced by the + * current value of the item and padded by a "" element. + * + * @param w + * the widget to retrieve the label for + * @return the label to use for the widget + */ + public String getLabel(Widget w); + + /** + * Retrieves the icon name for a widget. + * + * This first checks, if there is an icon defined in the sitemap. If not, if + * checks all item UI providers for an icon. If no icon can be found, the + * default icon name is the widget type name, e.g. "switch". + * + * If the icon name does not contain a "-" and has a state other than + * "undefined", its current state is appended to the icon name, e.g. + * "switch-on". If no such icon exists, the base icon ("switch") will be + * returned nonetheless. + * + * @param w + * the widget to retrieve the icon name for + * @return the icon name to use for the widget + */ + public String getIcon(Widget w); + + /** + * Retrieves the current state of the item of a widget or + * UnDefType.UNDEF. + * + * @param w + * the widget to retrieve the item state for + * @return the item state of the widget + */ + public State getState(Widget w); + + /** + * Retrieves the widget for a given id on a given sitemap. + * + * @param sitemap + * the sitemap to look for the widget + * @param id + * the id of the widget to look for + * @return the widget for the given id + */ + public Widget getWidget(Sitemap sitemap, String id); + + /** + * Provides an id for a widget. + * + * This constructs a string out of the position of the sitemap, so if this + * widget is the third child of a page linked from the fifth widget on the + * home screen, its id would be "0503". If the widget is dynamically created + * and not available in the sitemap, the name of its associated item is used + * instead. + * + * @param w + * the widget to get the id for + * @return an id for this widget + */ + public String getWidgetId(Widget w); + + /** + * this should be used instead of LinkableWidget.getChildren() as there + * might be no children defined on the widget, but they should be + * dynamically determined by looking at the members of the underlying item. + * + * @param w + * the widget to retrieve the children for + * @return the (dynamically or statically defined) children of the widget + */ + public EList getChildren(LinkableWidget w); + + /** + * Checks whether an icon with a given name exists + * + * @param icon + * the icon name to check + * @return true, if the icon exists + */ + public boolean iconExists(String icon); + + /** + * Gets the label color for the widget. Checks conditional statements to + * find the color based on the item value + * + * @param w + * Widget + * @return String with the color + */ + public String getLabelColor(Widget w); + + /** + * Gets the value color for the widget. Checks conditional statements to + * find the color based on the item value + * + * @param w + * Widget + * @return String with the color + */ + public String getValueColor(Widget w); + + /** + * Gets the widget visibility based on the item state + * + * @param w + * Widget + * @return true if the item is visible + */ + public boolean getVisiblity(Widget w); + + /** + * Gets the item state + * + * @param itemName + * item name + * @return State of the item + */ + public State getItemState(String itemName); +} diff --git a/bundles/core/org.openhab.core.init/.classpath b/bundles/core/org.openhab.core.init/.classpath index 913a170d25eb1..1e446acfc621c 100644 --- a/bundles/core/org.openhab.core.init/.classpath +++ b/bundles/core/org.openhab.core.init/.classpath @@ -1,8 +1,8 @@ + + - - diff --git a/bundles/core/org.openhab.core.init/.settings/org.eclipse.jdt.core.prefs b/bundles/core/org.openhab.core.init/.settings/org.eclipse.jdt.core.prefs index 4ede96d8a736c..443e08599a2e6 100644 --- a/bundles/core/org.openhab.core.init/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/core/org.openhab.core.init/.settings/org.eclipse.jdt.core.prefs @@ -1,2 +1,8 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/bundles/core/org.openhab.core/.classpath b/bundles/core/org.openhab.core/.classpath index 913a170d25eb1..1e446acfc621c 100644 --- a/bundles/core/org.openhab.core/.classpath +++ b/bundles/core/org.openhab.core/.classpath @@ -1,8 +1,8 @@ + + - - diff --git a/bundles/core/org.openhab.core/.settings/org.eclipse.jdt.core.prefs b/bundles/core/org.openhab.core/.settings/org.eclipse.jdt.core.prefs index 4ede96d8a736c..443e08599a2e6 100644 --- a/bundles/core/org.openhab.core/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/core/org.openhab.core/.settings/org.eclipse.jdt.core.prefs @@ -1,2 +1,8 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/bundles/core/org.openhab.core/META-INF/MANIFEST.MF b/bundles/core/org.openhab.core/META-INF/MANIFEST.MF index b3a95abf78514..68b54c33551df 100644 --- a/bundles/core/org.openhab.core/META-INF/MANIFEST.MF +++ b/bundles/core/org.openhab.core/META-INF/MANIFEST.MF @@ -1,6 +1,5 @@ Manifest-Version: 1.0 -Service-Component: OSGI-INF/autoapprove.xml,OSGI-INF/thingitemprovider.xml, - OSGI-INF/thinglinkprovider.xml,OSGI-INF/defaultsitemapprovider.xml +Service-Component: OSGI-INF/*.xml Private-Package: org.openhab.core.internal,org.openhab.core.internal.e vents,org.openhab.core.internal.items Ignore-Package: org.openhab.core.internal.items,org.openhab.core.inter @@ -30,6 +29,7 @@ Import-Package: com.google.common.cache;version="10.0.1", org.eclipse.smarthome.core.items, org.eclipse.smarthome.core.thing, org.eclipse.smarthome.core.thing.link, + org.eclipse.smarthome.core.thing.setup, org.eclipse.smarthome.core.thing.type, org.eclipse.smarthome.core.types, org.eclipse.smarthome.model.rule.runtime;resolution:=optional, diff --git a/bundles/core/org.openhab.core/OSGI-INF/autoapprove.xml b/bundles/core/org.openhab.core/OSGI-INF/autoapprove.xml index 9cd2117d884ae..8c8cbf74e5316 100644 --- a/bundles/core/org.openhab.core/OSGI-INF/autoapprove.xml +++ b/bundles/core/org.openhab.core/OSGI-INF/autoapprove.xml @@ -11,7 +11,7 @@ --> - + diff --git a/bundles/core/org.openhab.core/OSGI-INF/thingitemprovider.xml b/bundles/core/org.openhab.core/OSGI-INF/thingitemprovider.xml deleted file mode 100644 index 51166816353b1..0000000000000 --- a/bundles/core/org.openhab.core/OSGI-INF/thingitemprovider.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - diff --git a/bundles/core/org.openhab.core/OSGI-INF/thinglinkprovider.xml b/bundles/core/org.openhab.core/OSGI-INF/thinglinkprovider.xml deleted file mode 100644 index 760e47d89173c..0000000000000 --- a/bundles/core/org.openhab.core/OSGI-INF/thinglinkprovider.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - diff --git a/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/inbox/AutoApproveService.java b/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/inbox/AutoApproveService.java index 695a7bda835fd..d58869ecbcda5 100644 --- a/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/inbox/AutoApproveService.java +++ b/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/inbox/AutoApproveService.java @@ -16,7 +16,7 @@ import org.eclipse.smarthome.config.discovery.DiscoveryResultFlag; import org.eclipse.smarthome.config.discovery.inbox.Inbox; import org.eclipse.smarthome.config.discovery.inbox.InboxListener; -import org.eclipse.smarthome.core.thing.ManagedThingProvider; +import org.eclipse.smarthome.core.thing.setup.ThingSetupManager; import org.osgi.service.cm.ConfigurationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,35 +33,41 @@ public class AutoApproveService implements InboxListener { final static private Logger logger = LoggerFactory.getLogger(AutoApproveService.class); - private ManagedThingProvider managedThingProvider; + private ThingSetupManager thingSetupManager; private Inbox inbox; protected void activate(Map configProps) throws ConfigurationException { String enabled = (String) configProps.get("enabled"); - if("true".equalsIgnoreCase(enabled)) { - inbox.addInboxListener(this); - for(DiscoveryResult result : inbox.getAll()) { - if(result.getFlag().equals(DiscoveryResultFlag.NEW)) { - thingAdded(inbox, result); - } - } - } else { - this.inbox.removeInboxListener(this); - } + enable(enabled); + } + + protected void modified(Map configProps) throws ConfigurationException { + String enabled = (String) configProps.get("enabled"); + enable(enabled); } - @Override + private void enable(String enabled) { + if("true".equalsIgnoreCase(enabled)) { + inbox.addInboxListener(this); + for(DiscoveryResult result : inbox.getAll()) { + if(result.getFlag().equals(DiscoveryResultFlag.NEW)) { + thingAdded(inbox, result); + } + } + } else { + this.inbox.removeInboxListener(this); + } + } + + @Override public void thingAdded(Inbox source, DiscoveryResult result) { logger.debug("Approving inbox entry '{}'", result.toString()); Map props = new HashMap<>(result.getProperties()); - // TODO: this is a hack as long as we do not have a possibility to store localized labels for things - props.put("label", result.getLabel()); - Configuration conf = new Configuration(props); - managedThingProvider.createThing(result.getThingTypeUID(), result.getThingUID(), result.getBridgeUID(), conf); + thingSetupManager.addThing(result.getThingUID(), conf, result.getBridgeUID(), result.getLabel()); } @Override @@ -82,12 +88,12 @@ protected void unsetInbox(Inbox inbox) { } - protected void setManagedThingProvider(ManagedThingProvider managedThingProvider) { - this.managedThingProvider = managedThingProvider; + protected void setThingSetupManager(ThingSetupManager thingSetupManager) { + this.thingSetupManager = thingSetupManager; } - protected void unsetManagedThingProvider(ManagedThingProvider managedThingProvider) { - this.managedThingProvider = null; + protected void unsetThingSetupManager(ThingSetupManager thingSetupManager) { + this.thingSetupManager = null; } } diff --git a/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/DefaultSitemapProvider.java b/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/DefaultSitemapProvider.java index 1b73e98f5a7fc..530d72d6c1ac8 100644 --- a/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/DefaultSitemapProvider.java +++ b/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/DefaultSitemapProvider.java @@ -11,6 +11,7 @@ import org.eclipse.smarthome.core.items.GroupItem; import org.eclipse.smarthome.core.items.Item; import org.eclipse.smarthome.core.items.ItemRegistry; +import org.eclipse.smarthome.core.thing.setup.ThingSetupManager; import org.eclipse.smarthome.model.sitemap.Sitemap; import org.eclipse.smarthome.model.sitemap.SitemapFactory; import org.eclipse.smarthome.model.sitemap.SitemapProvider; @@ -41,21 +42,38 @@ protected void unsetItemRegistry(ItemRegistry itemRegistry) { public Sitemap getSitemap(String sitemapName) { if(sitemapName.equals("default")) { SitemapImpl sitemap = (SitemapImpl) SitemapFactory.eINSTANCE.createSitemap(); - FrameImpl frame = (FrameImpl) SitemapFactory.eINSTANCE.createFrame(); + FrameImpl mainFrame = (FrameImpl) SitemapFactory.eINSTANCE.createFrame(); + + FrameImpl thingFrame = (FrameImpl) SitemapFactory.eINSTANCE.createFrame(); + thingFrame.setLabel("Things"); sitemap.setLabel("Home"); sitemap.setName("default"); - sitemap.getChildren().add(frame); for(Item item : itemRegistry.getAll()) { - if(item instanceof GroupItem && !item.getName().equals("Things") - && (item.getGroupNames().isEmpty() || item.getGroupNames().contains("Things"))) { + if(item instanceof GroupItem && (item.getTags().contains(ThingSetupManager.TAG_HOME_GROUP) || item.getTags().contains(ThingSetupManager.TAG_THING))) { GroupImpl group = (GroupImpl) SitemapFactory.eINSTANCE.createGroup(); group.setItem(item.getName()); - frame.getChildren().add(group); + group.setLabel(item.getLabel()); + String category = item.getCategory(); + if(category != null) { + group.setIcon(item.getCategory()); + } + if(item.getTags().contains(ThingSetupManager.TAG_HOME_GROUP)) { + mainFrame.getChildren().add(group); + } else { + thingFrame.getChildren().add(group); + } } } - + + if(!mainFrame.getChildren().isEmpty()) { + sitemap.getChildren().add(mainFrame); + } + if(!thingFrame.getChildren().isEmpty()) { + sitemap.getChildren().add(thingFrame); + } + return sitemap; } return null; diff --git a/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/ThingItemChannelLinkProvider.java b/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/ThingItemChannelLinkProvider.java deleted file mode 100644 index 92cde341cbeee..0000000000000 --- a/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/ThingItemChannelLinkProvider.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. - * - * 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 - */ -package org.openhab.core.internal.item; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.smarthome.core.common.registry.Provider; -import org.eclipse.smarthome.core.common.registry.ProviderChangeListener; -import org.eclipse.smarthome.core.common.registry.RegistryChangeListener; -import org.eclipse.smarthome.core.thing.Channel; -import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.thing.ThingRegistry; -import org.eclipse.smarthome.core.thing.link.ItemChannelLink; -import org.eclipse.smarthome.core.thing.link.ItemChannelLinkProvider; - -/** - * This class provides item channel links for all items that were created through - * the {@link ThingItemUIProvider}. - * - * @author Kai Kreuzer - * - */ -public class ThingItemChannelLinkProvider implements ItemChannelLinkProvider, RegistryChangeListener { - - private Set> listeners = new HashSet<>(); - private ThingRegistry thingRegistry; - private ThingItemUIProvider thingItemUIProvider; - - @Override - public void addProviderChangeListener( - ProviderChangeListener listener) { - listeners.add(listener); - } - - @Override - public void removeProviderChangeListener( - ProviderChangeListener listener) { - listeners.remove(listener); - } - - @Override - public Set getAll() { - Set links = new HashSet<>(); - if(thingItemUIProvider.isEnabled()) { - for(Thing thing : thingRegistry.getAll()) { - links.addAll(getLinks(thing)); - } - } - return links; - } - - private Set getLinks(Thing element) { - Set links = new HashSet<>(); - if(thingItemUIProvider.isEnabled()) { - for(Channel channel : element.getChannels()) { - links.add(new ItemChannelLink(channel.getUID().toString().replace(":", "_").replaceAll("#", "_"), channel.getUID())); - } - } - return links; - } - - protected void setThingItemUIProvider(ThingItemUIProvider thingItemUIProvider) { - this.thingItemUIProvider = thingItemUIProvider; - } - - protected void unsetThingItemUIProvider(ThingItemUIProvider thingItemUIProvider) { - this.thingItemUIProvider = null; - } - - protected void setThingRegistry(ThingRegistry thingRegistry) { - this.thingRegistry = thingRegistry; - this.thingRegistry.addRegistryChangeListener(this); - } - - protected void unsetThingRegistry(ThingRegistry thingRegistry) { - this.thingRegistry.addRegistryChangeListener(this); - this.thingRegistry = null; - } - - public void updated(Provider provider, Thing oldelement, - Thing element) { - for(ProviderChangeListener listener : listeners) { - for(ItemChannelLink link : getLinks(oldelement)) { - listener.removed(this, link); - } - for(ItemChannelLink link : getLinks(element)) { - listener.added(this, link); - } - } - } - - @Override - public void added(Thing element) { - for(ProviderChangeListener listener : listeners) { - for(ItemChannelLink link : getLinks(element)) { - listener.added(this, link); - } - } - } - - @Override - public void removed(Thing element) { - for(ProviderChangeListener listener : listeners) { - for(ItemChannelLink link : getLinks(element)) { - listener.removed(this, link); - } - } - } - - @Override - public void updated(Thing oldElement, Thing element) { - for(ProviderChangeListener listener : listeners) { - for(ItemChannelLink link : getLinks(oldElement)) { - listener.removed(this, link); - } - for(ItemChannelLink link : getLinks(element)) { - listener.added(this, link); - } - } - } - -} diff --git a/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/ThingItemUIProvider.java b/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/ThingItemUIProvider.java deleted file mode 100644 index 421ce9bc25079..0000000000000 --- a/bundles/core/org.openhab.core/src/main/java/org/openhab/core/internal/item/ThingItemUIProvider.java +++ /dev/null @@ -1,319 +0,0 @@ -/** - * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. - * - * 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 - */ -package org.openhab.core.internal.item; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.WordUtils; -import org.eclipse.smarthome.core.common.registry.ProviderChangeListener; -import org.eclipse.smarthome.core.common.registry.RegistryChangeListener; -import org.eclipse.smarthome.core.events.EventPublisher; -import org.eclipse.smarthome.core.items.GroupItem; -import org.eclipse.smarthome.core.items.Item; -import org.eclipse.smarthome.core.items.ItemFactory; -import org.eclipse.smarthome.core.items.ItemProvider; -import org.eclipse.smarthome.core.thing.Bridge; -import org.eclipse.smarthome.core.thing.Channel; -import org.eclipse.smarthome.core.thing.ManagedThingProvider; -import org.eclipse.smarthome.core.thing.Thing; -import org.eclipse.smarthome.core.thing.ThingRegistry; -import org.eclipse.smarthome.core.thing.ThingStatus; -import org.eclipse.smarthome.core.thing.type.ChannelDefinition; -import org.eclipse.smarthome.core.thing.type.ThingType; -import org.eclipse.smarthome.core.thing.type.ThingTypeRegistry; -import org.eclipse.smarthome.core.types.UnDefType; -import org.eclipse.smarthome.model.sitemap.Widget; -import org.eclipse.smarthome.ui.items.ItemUIProvider; -import org.osgi.service.cm.ConfigurationException; - -/** - * This class dynamically provides items incl. labels from all things of the {@link ManagedThingProvider}. - * All items are hierarchically sorted with a root group item called "Things". - * - * @author Kai Kreuzer - * - */ -public class ThingItemUIProvider implements ItemUIProvider, ItemProvider, RegistryChangeListener { - - private Set> listeners = new HashSet<>(); - - private ThingRegistry thingRegistry; - private ItemFactory itemFactory; - private ThingTypeRegistry thingTypeRegistry; - private EventPublisher eventPublisher; - private GroupItem rootItem; - - private boolean enabled = false; - - - @Override - public String getIcon(String itemName) { - if(!enabled) return null; - - if("Things".equals(itemName)) { - return "network"; - } - - for(Thing thing : thingRegistry.getAll()) { - if(thing.getUID().toString().replaceAll(":", "_").replaceAll("#", "_").equals(itemName)) { - String icon = null; - if(thing instanceof Bridge) { - icon = "network"; - } else { - icon = "switch"; - } - if(thing.getStatus().equals(ThingStatus.ONLINE)) { - return icon + "-on"; - } else { - return icon + "-off"; - } - } - for(Channel ch : thing.getChannels()) { - if(ch.getUID().toString().replaceAll(":", "_").replaceAll("#", "_").equals(itemName)) { - if(ch.getAcceptedItemType().equals("Color")) { - return "switch"; - } - if(ch.getAcceptedItemType().equals("Dimmer")) { - return "switch"; - } - } - } - } - return null; - } - - @Override - public String getLabel(String itemName) { - if(!enabled) return null; - - for(Thing thing : thingRegistry.getAll()) { - if(thing.getUID().toString().replaceAll(":", "_").replaceAll("#", "_").equals(itemName)) { - String label = (String) thing.getConfiguration().get("label"); - if(label!=null && !label.isEmpty()) { - return label; - } else { - return WordUtils.capitalize(itemName.replace("_", " ")); - } - } - for(Channel channel : thing.getChannels()) { - if(channel.getUID().toString().replaceAll(":", "_").replaceAll("#", "_").equals(itemName)) { - String label = (String) StringUtils.capitalize(channel.getUID().getId()); - ThingType thingType = thingTypeRegistry.getThingType(thing.getThingTypeUID()); - if(thingType!=null) { - for(ChannelDefinition chDef : thingType.getChannelDefinitions()) { - if (chDef.getId().equals(channel.getUID().getId())) { - label = chDef.getType().getLabel(); - } - } - } - if(channel.getAcceptedItemType().equals("String")) label += " [%s]"; - if(channel.getAcceptedItemType().equals("Number")) label += " [%.1f]"; - return label; - } - } - } - return null; - } - - @Override - public Widget getDefaultWidget(Class itemType, - String itemName) { - return null; - } - - @Override - public Widget getWidget(String itemName) { - return null; - } - - @Override - public Collection getAll() { - if(!enabled) return Collections.emptySet(); - - Set items = new HashSet<>(); - GroupItem all = getRootItem(); - for(Thing thing : thingRegistry.getAll()) { - GroupItem group = createItemsForThing(thing); - if((thing instanceof Bridge) || thing.getBridgeUID() == null) { - if(group!=null) { - if(all.getMembers().contains(group)) { - all.removeMember(group); - } - all.addMember(group); - } - } - for(Item item : group.getAllMembers()) { - items.add(item); - } - items.add(group); - } - items.add(all); - return items; - } - - /*default*/ GroupItem createItemsForThing(Thing thing) { - GroupItem group = new GroupItem(thing.getUID().toString().replaceAll(":", "_").replaceAll("#", "_")); - for(Channel channel : thing.getChannels()) { - Item item = itemFactory.createItem(channel.getAcceptedItemType(), channel.getUID().toString().replaceAll(":", "_").replaceAll("#", "_")); - if(item!=null) { - if(group.getMembers().contains(item)) { - group.removeMember(item); - } - group.addMember(item); - } - } - if(thing instanceof Bridge) { - Bridge bridge = (Bridge) thing; - for(Thing child : bridge.getThings()) { - group.addMember(createItemsForThing(child)); - } - } - if(thing.getBridgeUID()!=null) { - group.addGroupName(thing.getBridgeUID().toString().replaceAll(":", "_").replaceAll("#", "_")); - } else { - group.addGroupName("Things"); - } - return group; - } - - @Override - public void addProviderChangeListener(ProviderChangeListener listener) { - listeners.add(listener); - for(Item item : getAll()) { - listener.added(this, item); - } - } - - @Override - public void removeProviderChangeListener( - ProviderChangeListener listener) { - listeners.remove(listener); - - } - - protected void setItemFactory(ItemFactory itemFactory) { - this.itemFactory = itemFactory; - } - - protected void unsetItemFactory(ItemFactory itemFactory) { - this.itemFactory = null; - } - - protected void setThingRegistry(ThingRegistry thingRegistry) { - this.thingRegistry = thingRegistry; - this.thingRegistry.addRegistryChangeListener(this); - } - - protected void unsetThingRegistry(ThingRegistry thingRegistry) { - this.thingRegistry.addRegistryChangeListener(this); - this.thingRegistry = null; - } - - protected void setEventPublisher(EventPublisher eventPublisher) { - this.eventPublisher = eventPublisher; - } - - protected void unsetEventPublisher(EventPublisher eventPublisher) { - this.eventPublisher = null; - } - - protected void setThingTypeRegistry(ThingTypeRegistry thingTypeRegistry) { - this.thingTypeRegistry = thingTypeRegistry; - } - - protected void unsetThingTypeRegistry(ThingTypeRegistry thingProvider) { - this.thingTypeRegistry = null; - } - - private synchronized GroupItem getRootItem() { - if(rootItem==null) { - rootItem = new GroupItem("Things"); - getAll(); - } - return rootItem; - } - - protected void activate(Map properties) throws ConfigurationException { - if(properties!=null) { - String enabled = (String) properties.get("enabled"); - if("true".equalsIgnoreCase(enabled)) { - this.enabled = true; - for(ProviderChangeListener listener : listeners) { - for(Item item : getAll()) { - listener.added(this, item); - } - } - } else { - this.enabled = false; - for(ProviderChangeListener listener : listeners) { - for(Item item : getAll()) { - listener.removed(this, item); - } - } - } - } - } - - @Override - public void added(Thing element) { - if(!enabled) return; - for(ProviderChangeListener listener : listeners) { - listener.removed(this, getRootItem()); - } - rootItem = null; - GroupItem group = createItemsForThing(element); - rootItem = getRootItem(); - for(ProviderChangeListener listener : listeners) { - for(Item item : group.getMembers()) { - listener.added(this, item); - } - listener.added(this, group); - listener.added(this, getRootItem()); - - } - if(group.getAcceptedDataTypes().contains(UnDefType.UNDEF)) { - eventPublisher.postUpdate(group.getName(), UnDefType.UNDEF); - } - if(rootItem.getAcceptedDataTypes().contains(UnDefType.UNDEF)) { - eventPublisher.postUpdate(rootItem.getName(), UnDefType.UNDEF); - } - } - - @Override - public void removed(Thing element) { - if(!enabled) return; - for(ProviderChangeListener listener : listeners) { - listener.removed(this, getRootItem()); - rootItem = null; - GroupItem group = createItemsForThing(element); - listener.removed(this, group); - for(Item item : group.getMembers()) { - listener.removed(this, item); - } - listener.added(this, getRootItem()); - } - } - - @Override - public void updated(Thing oldElement, Thing element) { - if(!enabled) return; - removed(oldElement); - added(element); - } - - public boolean isEnabled() { - return enabled; - } - -} diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.classpath b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.classpath deleted file mode 100644 index 8fded99aab140..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.pde.core.prefs b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index e67024ad35216..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Mon Oct 11 21:08:09 CEST 2010 -eclipse.preferences.version=1 -pluginProject.extensions=false -resolve.requirebundle=false diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/META-INF/MANIFEST.MF b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/META-INF/MANIFEST.MF deleted file mode 100644 index c85662642de93..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/META-INF/MANIFEST.MF +++ /dev/null @@ -1,36 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Eclipse SmartHome Multimedia I/O MaryTTS Bundle -Bundle-SymbolicName: org.eclipse.smarthome.io.multimedia.tts.marytts -Bundle-Version: 0.8.0.qualifier -Bundle-Vendor: Eclipse.org/SmartHome -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 -Bundle-ClassPath: ., - lib/voice-cmu-slt-hsmm-5.0.jar, - lib/voice-bits1-hsmm-5.0-SNAPSHOT.jar, - lib/voice-bits3-hsmm-5.0-SNAPSHOT.jar, - lib/emotionml-checker-java-1.0-SNAPSHOT.jar, - lib/freetts-1.0.jar, - lib/freetts-de-1.0.jar, - lib/freetts-en_us-1.0.jar, - lib/jtok-core-1.9.1.jar, - lib/marytts-server-5.1-SNAPSHOT.jar, - lib/mwdumper-1.16.jar, - lib/sgt-3.0.jar, - lib/marytts-runtime-5.1-SNAPSHOT.jar, - lib/marytts-common-5.1-SNAPSHOT.jar, - lib/marytts-signalproc-5.1-SNAPSHOT.jar, - lib/marytts-lang-de-5.1-SNAPSHOT.jar, - lib/marytts-lang-en-5.1-SNAPSHOT.jar, - lib/opennlp-maxent-3.0.1-incubating.jar, - lib/opennlp-tools-1.5.1-incubating.jar -Import-Package: org.apache.commons.collections.map, - org.apache.commons.io, - org.apache.commons.lang, - org.eclipse.smarthome.core.library.types, - org.eclipse.smarthome.io.multimedia.tts, - org.osgi.framework, - org.slf4j -Service-Component: OSGI-INF/tts_mary.xml -Bundle-ActivationPolicy: lazy -Bundle-Activator: org.eclipse.smarthome.io.multimedia.tts.marytts.internal.MultimediaActivator diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/about.html b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/about.html deleted file mode 100644 index c258ef55d834c..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/about.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - -About - - -

About This Content

- -

June 5, 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/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/build.properties b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/build.properties deleted file mode 100644 index 41d7510ccb735..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/build.properties +++ /dev/null @@ -1,24 +0,0 @@ -output.. = target/classes/ -bin.includes = META-INF/,\ - .,\ - OSGI-INF/,\ - about.html,\ - lib/voice-bits1-hsmm-5.0-SNAPSHOT.jar,\ - lib/voice-bits3-hsmm-5.0-SNAPSHOT.jar,\ - lib/voice-cmu-slt-hsmm-5.0.jar,\ - lib/emotionml-checker-java-1.0-SNAPSHOT.jar,\ - lib/freetts-1.0.jar,\ - lib/freetts-de-1.0.jar,\ - lib/freetts-en_us-1.0.jar,\ - lib/jtok-core-1.9.1.jar,\ - lib/marytts-server-5.1-SNAPSHOT.jar,\ - lib/mwdumper-1.16.jar,\ - lib/sgt-3.0.jar,\ - lib/marytts-runtime-5.1-SNAPSHOT.jar,\ - lib/marytts-common-5.1-SNAPSHOT.jar,\ - lib/marytts-signalproc-5.1-SNAPSHOT.jar,\ - lib/marytts-lang-de-5.1-SNAPSHOT.jar,\ - lib/marytts-lang-en-5.1-SNAPSHOT.jar,\ - lib/opennlp-maxent-3.0.1-incubating.jar,\ - lib/opennlp-tools-1.5.1-incubating.jar -source.. = src/main/java/ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-common-5.1-SNAPSHOT.jar b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-common-5.1-SNAPSHOT.jar deleted file mode 100644 index ec28b9956562d..0000000000000 Binary files a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-common-5.1-SNAPSHOT.jar and /dev/null differ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-runtime-5.1-SNAPSHOT.jar b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-runtime-5.1-SNAPSHOT.jar deleted file mode 100644 index de055708a2ece..0000000000000 Binary files a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-runtime-5.1-SNAPSHOT.jar and /dev/null differ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-server-5.1-SNAPSHOT.jar b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-server-5.1-SNAPSHOT.jar deleted file mode 100644 index 5a5797e907dbf..0000000000000 Binary files a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-server-5.1-SNAPSHOT.jar and /dev/null differ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-signalproc-5.1-SNAPSHOT.jar b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-signalproc-5.1-SNAPSHOT.jar deleted file mode 100644 index 2d58c4378a25d..0000000000000 Binary files a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/lib/marytts-signalproc-5.1-SNAPSHOT.jar and /dev/null differ diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/pom.xml b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/pom.xml deleted file mode 100644 index 23ad6f18cb6f5..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/pom.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - org.eclipse.smarthome.bundles - io - 0.8.0-SNAPSHOT - - - - org.eclipse.smarthome.io.multimedia.tts.marytts - org.eclipse.smarthome.io.multimedia.tts.marytts - ${basedir}/resources - - - 4.0.0 - org.eclipse.smarthome.io - org.eclipse.smarthome.io.multimedia.tts.marytts - - Eclipse SmartHome Multimedia I/O MaryTTS - - eclipse-plugin - - - - - com.savage7.maven.plugins - maven-external-dependency-plugin - - - ${basedir}/lib - - - - - com.sun.speech.freetts - freetts - 1.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/freetts-1.0.jar - - true - - - - com.sun.speech.freetts - freetts-de - 1.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/freetts-de-1.0.jar - - true - - - - com.sun.speech.freetts - freetts-en_us - 1.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/freetts-en_us-1.0.jar - - true - - - - gov.noaa.pmel.sgt - sgt - 3.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/sgt-3.0.jar - - true - - - - de.dfki.lt.jtok - jtok-core - 1.9.1 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/jtok-core-1.9.1.jar - - true - - - - org.wikimedia - mwdumper - 1.16 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/mwdumper-1.16.jar - - true - - - - emotionml-checker-java - emotionml-checker-java - 1.0-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/emotionml-checker-java-1.0-SNAPSHOT.jar - - true - - - - opennlp-maxent - opennlp-maxent - 3.0.1-incubating - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/opennlp-maxent-3.0.1-incubating.jar - - true - - - - opennlp-tools - opennlp-tools - 1.5.1-incubating - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/opennlp-tools-1.5.1-incubating.jar - - true - - - - marytts-lang-de - marytts-lang-de - 5.1-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/marytts-lang-de-5.1-SNAPSHOT.jar - - true - - - - marytts-lang-en - marytts-lang-en - 5.1-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/marytts-lang-en-5.1-SNAPSHOT.jar - - true - - - - voice-bits1-hsmm - voice-bits1-hsmm - 5.0-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/voice-bits1-hsmm-5.0-SNAPSHOT.jar - - true - - - - voice-bits3-hsmm - voice-bits3-hsmm - 5.0-SNAPSHOT - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/voice-bits3-hsmm-5.0-SNAPSHOT.jar - - true - - - - voice-cmu-slt-hsmm - voice-cmu-slt-hsmm - 5.0 - jar - - http://repository-openhab.forge.cloudbees.com/3rd/marytts/voice-cmu-slt-hsmm-5.0.jar - - true - - - - - - - resolve-install-external-dependencies - process-resources - - - resolve-external - - - - - - org.vafer - jdeb - - - - - - - com.savage7.maven.plugins - maven-external-dependency-plugin - 0.4 - - - - - - diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/MultimediaActivator.java b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/MultimediaActivator.java deleted file mode 100644 index 467ab4404815a..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/MultimediaActivator.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others. - * 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 - */ -package org.eclipse.smarthome.io.multimedia.tts.marytts.internal; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Extension of the default OSGi bundle activator - * - * @author Kai Kreuzer - Initial contribution and API - */ -public class MultimediaActivator implements BundleActivator { - - private final Logger logger = LoggerFactory.getLogger(MultimediaActivator.class); - - private static BundleContext context; - - /** - * Called whenever the OSGi framework starts our bundle - */ - public void start(BundleContext bc) throws Exception { - context = bc; - logger.debug("Multimedia I/O MaryTTS bundle has been started."); - } - - /** - * Called whenever the OSGi framework stops our bundle - */ - public void stop(BundleContext bc) throws Exception { - context = null; - logger.debug("Multimedia I/O MaryTTS bundle has been stopped."); - } - - /** - * Returns the bundle context of this bundle - * @return the bundle context - */ - public static BundleContext getContext() { - return context; - } -} diff --git a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/tts/TTSServiceMaryTTS.java b/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/tts/TTSServiceMaryTTS.java deleted file mode 100644 index 035c051b75ad5..0000000000000 --- a/bundles/io/org.eclipse.smarthome.io.multimedia.tts.marytts/src/main/java/org/eclipse/smarthome/io/multimedia/tts/marytts/internal/tts/TTSServiceMaryTTS.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2010-2015, openHAB.org and others. - * - * 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 - */ -package org.eclipse.smarthome.io.multimedia.tts.marytts.internal.tts; - -import java.util.Locale; - -import javax.sound.sampled.AudioInputStream; - -import marytts.LocalMaryInterface; -import marytts.MaryInterface; -import marytts.exceptions.MaryConfigurationException; -import marytts.exceptions.SynthesisException; -import marytts.modules.synthesis.Voice; -import marytts.util.data.audio.AudioPlayer; - -import org.apache.commons.lang.StringUtils; -import org.eclipse.smarthome.io.multimedia.tts.TTSService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This is a pure Java TTS service implementation, based on MaryTTS. - * - * @author Tobias Bräutigam - * @since 0.8.0 - * - */ -public class TTSServiceMaryTTS implements TTSService { - private static final Logger logger = LoggerFactory - .getLogger(TTSServiceMaryTTS.class); - - private static MaryInterface marytts; - private Voice defaultVoice; - - public void activate() { - try { - marytts = new LocalMaryInterface(); - Locale systemLocale = Locale.getDefault(); - if (marytts.getAvailableLocales().contains(systemLocale)) { - defaultVoice = Voice.getDefaultVoice(systemLocale); - } - if (defaultVoice == null) { - // Fallback - defaultVoice = Voice.getVoice(marytts.getAvailableVoices() - .iterator().next()); - } - } catch (MaryConfigurationException e) { - logger.error( - "Error connecting to Mary TTS: " + e.getLocalizedMessage(), - e); - } - } - - public void deactivate() { - marytts = null; - } - - /** - * {@inheritDoc} - */ - public synchronized void say(String text, String voiceName, String outputDevice) { - if (marytts == null) { - logger.error("Mary TTS is not available"); - return; - } - if (text == null) { - return; - } - Voice voice = null; - if (StringUtils.isBlank(voiceName)) { - logger.debug( - "Mary TTS: {} (Voice not set. Using default voice {}).", - new String[] { text, defaultVoice.toString() }); - voice = defaultVoice; - } else { - voice = Voice.getVoice(voiceName); - logger.debug("Mary TTS: {} (Voice: {})", new String[] { text, - voiceName }); - } - - if (voice != null) { - // Workaround: we have to set the Locale first, because only in the - // LocalMaryInterface.setLocale() method the required private method - // LocalMaryInterface.setAudioFileFormatForVoice() method is called. - // After that we can set the voice, otherwise an NPE occurs - marytts.setLocale(voice.getLocale()); - marytts.setVoice(voice.getName()); - try { - AudioInputStream audio = marytts.generateAudio(text); - AudioPlayer player = new AudioPlayer(audio); - player.start(); - player.join(); - - } catch (SynthesisException e) { - logger.error("Error during tts generation: {}", - e.getLocalizedMessage(), e); - } catch (InterruptedException e) { - logger.error("Error during tts playback: {}", - e.getLocalizedMessage(), e); - } - } else { - logger.error("Could not find voice: {}", voiceName); - logger.info("Available Voices are {} ", - StringUtils.join(marytts.getAvailableVoices(), ", ")); - } - } - -} diff --git a/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-https.xml b/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-https.xml index 024cebc1d48d7..5a723699920f2 100644 --- a/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-https.xml +++ b/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-https.xml @@ -38,10 +38,10 @@
- - - - + + + + diff --git a/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-selector.xml b/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-selector.xml index 6068cbab7d6fb..2cbd9fe14d74a 100644 --- a/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-selector.xml +++ b/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-selector.xml @@ -21,8 +21,8 @@
- - + + 300000 diff --git a/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-ssl.xml b/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-ssl.xml index 0ffde304179f4..b0dfd0ad379c4 100644 --- a/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-ssl.xml +++ b/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty-ssl.xml @@ -7,14 +7,14 @@ - / - - - / - + / + + + / + - - + + SSL_RSA_WITH_DES_CBC_SHA diff --git a/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty.xml b/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty.xml index 1f5efaa9c8303..81d241bd2835d 100644 --- a/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty.xml +++ b/bundles/io/org.openhab.io.jetty/jettyhome/etc/jetty.xml @@ -81,7 +81,7 @@ https - + 32768 8192 diff --git a/bundles/io/org.openhab.io.transport.serial/.classpath b/bundles/io/org.openhab.io.transport.serial/.classpath index e5b1c31ae6985..37b651fd08612 100644 --- a/bundles/io/org.openhab.io.transport.serial/.classpath +++ b/bundles/io/org.openhab.io.transport.serial/.classpath @@ -1,7 +1,7 @@ + - diff --git a/bundles/io/org.openhab.io.transport.serial/META-INF/MANIFEST.MF b/bundles/io/org.openhab.io.transport.serial/META-INF/MANIFEST.MF index 29ca72fbdc567..0ab79a14d5997 100644 --- a/bundles/io/org.openhab.io.transport.serial/META-INF/MANIFEST.MF +++ b/bundles/io/org.openhab.io.transport.serial/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: openHAB Serial Transport Bundle Bundle-SymbolicName: org.openhab.io.transport.serial Bundle-Version: 2.0.0.qualifier Bundle-Vendor: openHAB.org -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ClassPath: lib/nrjavaserial-3.8.8.jar Export-Package: gnu.io Import-Package: gnu.io diff --git a/bundles/io/pom.xml b/bundles/io/pom.xml index f69f55d18783e..94fca29250b26 100644 --- a/bundles/io/pom.xml +++ b/bundles/io/pom.xml @@ -19,7 +19,6 @@ org.openhab.io.transport.serial org.openhab.io.jetty org.openhab.io.rest.docs - org.openhab.io.multimedia.tts.marytts diff --git a/bundles/ui/org.openhab.ui.dashboard/META-INF/MANIFEST.MF b/bundles/ui/org.openhab.ui.dashboard/META-INF/MANIFEST.MF index 9c57e1f107ec4..21f3f3799b35e 100644 --- a/bundles/ui/org.openhab.ui.dashboard/META-INF/MANIFEST.MF +++ b/bundles/ui/org.openhab.ui.dashboard/META-INF/MANIFEST.MF @@ -6,6 +6,6 @@ Bundle-Version: 2.0.0.qualifier Bundle-Vendor: openHAB.org Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Service-Component: OSGI-INF/dashboardservice.xml -Import-Package: org.osgi.service.component;version="1.2.2", +Import-Package: org.osgi.service.component;version="[1.2,2.0)", org.osgi.service.http;version="1.2.1", org.slf4j diff --git a/bundles/ui/org.openhab.ui.dashboard/web/index.html b/bundles/ui/org.openhab.ui.dashboard/web/index.html index 997e7023c69d5..e5458c72db496 100644 --- a/bundles/ui/org.openhab.ui.dashboard/web/index.html +++ b/bundles/ui/org.openhab.ui.dashboard/web/index.html @@ -79,7 +79,7 @@

Welcome to openHAB 2.0

-

openHAB 2.0 - Copyright © 2014 openHAB UG (haftungsbeschränkt) / All rights reserved

+

openHAB 2.0 - Copyright © 2015 openHAB UG (haftungsbeschränkt) / All rights reserved

\ No newline at end of file diff --git a/distribution/openhabhome/conf/items/demo.items b/distribution/openhabhome/conf/items/demo.items index eababe82eb544..7fe8035db1778 100644 --- a/distribution/openhabhome/conf/items/demo.items +++ b/distribution/openhabhome/conf/items/demo.items @@ -1,11 +1,11 @@ -Group All -Group gGF (All) -Group gFF (All) -Group gC (All) -Group Outdoor (All) -Group Shutters (All) -Group Weather (All) -Group Status (All) +Group gFF "First Floor" [ "home-group" ] +Group gGF "Ground Floor" [ "home-group" ] +Group gC "Cellar" [ "home-group" ] +Group Garden [ "home-group" ] +Group Weather [ "home-group" ] + +Group Status +Group Shutters Group GF_Living "Living Room"