Added svn properties
Fixed test runtime enviroment boostrap
Fixed dependecy in tester artifact
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@674879 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/upnp/samples/binarylight/pom.xml b/upnp/samples/binarylight/pom.xml
index 05279d2..ba8b09f 100644
--- a/upnp/samples/binarylight/pom.xml
+++ b/upnp/samples/binarylight/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -17,66 +17,66 @@
specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>felix</artifactId>
- <groupId>org.apache.felix</groupId>
- <version>1.0.2</version>
- <relativePath>../../../pom/pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.upnp.sample.binaryLight</artifactId>
- <packaging>bundle</packaging>
- <name>Apache Felix UPnP Sample Binary-Light</name>
- <version>0.2.0-SNAPSHOT</version>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>felix</artifactId>
+ <groupId>org.apache.felix</groupId>
+ <version>1.0.2</version>
+ <relativePath>../../../pom/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.upnp.sample.binaryLight</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Felix UPnP Sample Binary-Light</name>
+ <version>0.2.0-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${pom.name}</Bundle-Name>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
- <Bundle-Author>Matteo Demuru <demuru@apache.org>,Francesco Furfari <furfari@apache.org>,Stefano "Kismet" Lenzi <lenzi@apache.org></Bundle-Author>
- <Bundle-Description>Standardized BinaryLight DCPs to test UPnP Base Driver</Bundle-Description>
- <Bundle-SymbolicName>org.apache.felix.upnp.sample.binaryLight</Bundle-SymbolicName>
- <Bundle-Activator>org.apache.felix.upnp.sample.binaryLight.Activator</Bundle-Activator>
- <Private-Package>org.apache.felix.upnp.sample.binaryLight.*</Private-Package>
- <Import-Package>*</Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.compendium</artifactId>
+ <Bundle-Author>Matteo Demuru <demuru@apache.org>,Francesco Furfari <furfari@apache.org>,Stefano "Kismet" Lenzi <lenzi@apache.org></Bundle-Author>
+ <Bundle-Description>Standardized BinaryLight DCPs to test UPnP Base Driver</Bundle-Description>
+ <Bundle-SymbolicName>org.apache.felix.upnp.sample.binaryLight</Bundle-SymbolicName>
+ <Bundle-Activator>org.apache.felix.upnp.sample.binaryLight.Activator</Bundle-Activator>
+ <Private-Package>org.apache.felix.upnp.sample.binaryLight.*</Private-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
<version>1.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>javax.servlet</artifactId>
- <version>1.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.upnp.extra</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-</project>
-
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>javax.servlet</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.upnp.extra</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
+
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/LightModel.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/LightModel.java
index 374cc20..d48d2d3 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/LightModel.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/LightModel.java
@@ -1,113 +1,113 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-
-import org.apache.felix.upnp.extra.util.EventSource;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class LightModel implements EventSource{
-
- private boolean status = false;
- private boolean target = false;
- private boolean failure = false;
- private PropertyChangeSupport propertySupport = new PropertyChangeSupport(this);
-
- public LightModel(){
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener){
- propertySupport.addPropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener){
- propertySupport.removePropertyChangeListener(listener);
- }
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- propertySupport.addPropertyChangeListener(propertyName,listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- propertySupport.removePropertyChangeListener(propertyName,listener);
- }
-
- public void doSwitch(boolean value){
- if (value) switchOn();
- else switchOff();
- }
-
- public void switchOn(){
- target = true;
- if(! failure) {
- boolean oldStatus = status;
- status = true;
- propertySupport.firePropertyChange("Status",oldStatus,status);
- }
- }
-
- public void switchOff(){
- target = false;
- if(! failure) {
- boolean oldStatus = status;
- status = false;
- propertySupport.firePropertyChange("Status",oldStatus,status);
- }
- }
-
- public void setFailure(boolean value){
- failure = value;
- if (failure){
- status = false;
- }
- else {
- if (target) {
- status = true;
- }
- else{
- status = false;
- }
- }
- propertySupport.firePropertyChange("Status",!status,status);
- propertySupport.firePropertyChange("Failure",!failure,failure);
- }
-
-
- /**
- * @return
- */
- public boolean getTarget() {
- return target;
- }
-
- /**
- * @return
- */
- public boolean getStatus() {
- return status;
- }
-
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+import org.apache.felix.upnp.extra.util.EventSource;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class LightModel implements EventSource{
+
+ private boolean status = false;
+ private boolean target = false;
+ private boolean failure = false;
+ private PropertyChangeSupport propertySupport = new PropertyChangeSupport(this);
+
+ public LightModel(){
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener){
+ propertySupport.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener){
+ propertySupport.removePropertyChangeListener(listener);
+ }
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ propertySupport.addPropertyChangeListener(propertyName,listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ propertySupport.removePropertyChangeListener(propertyName,listener);
+ }
+
+ public void doSwitch(boolean value){
+ if (value) switchOn();
+ else switchOff();
+ }
+
+ public void switchOn(){
+ target = true;
+ if(! failure) {
+ boolean oldStatus = status;
+ status = true;
+ propertySupport.firePropertyChange("Status",oldStatus,status);
+ }
+ }
+
+ public void switchOff(){
+ target = false;
+ if(! failure) {
+ boolean oldStatus = status;
+ status = false;
+ propertySupport.firePropertyChange("Status",oldStatus,status);
+ }
+ }
+
+ public void setFailure(boolean value){
+ failure = value;
+ if (failure){
+ status = false;
+ }
+ else {
+ if (target) {
+ status = true;
+ }
+ else{
+ status = false;
+ }
+ }
+ propertySupport.firePropertyChange("Status",!status,status);
+ propertySupport.firePropertyChange("Failure",!failure,failure);
+ }
+
+
+ /**
+ * @return
+ */
+ public boolean getTarget() {
+ return target;
+ }
+
+ /**
+ * @return
+ */
+ public boolean getStatus() {
+ return status;
+ }
+
+
+
+}
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/LightUI.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/LightUI.java
index 2e56106..02238cc 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/LightUI.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/LightUI.java
@@ -1,185 +1,185 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight;
-
-import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.net.URL;
-
-import javax.swing.AbstractAction;
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
-
-import org.osgi.framework.BundleException;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class LightUI extends JFrame implements PropertyChangeListener {
- private final static ImageIcon LIGHT_ON = LightUI.loadIcon("LightOn.gif","ON");
- private final static ImageIcon LIGHT_OFF = LightUI.loadIcon("LightOff.gif","OFF");
- private final static ImageIcon LIGHT_FAIL = LightUI.loadIcon("LightFail.gif","FAILURE");
- private final JLabel label = new JLabel();
- private LightModel model;
- private JButton btnSwitch;
- private JButton btnFailure;
-
- public LightUI(LightModel model) {
- super("Felix UPnP BinaryLight");
- this.model = model;
- setSize(150,150);
- JPanel panel = new JPanel(new BorderLayout());
- panel.add(doMainPanel(),BorderLayout.CENTER);
- panel.add(doControlPanel(),BorderLayout.SOUTH);
- getContentPane().add(panel);
- model.addPropertyChangeListener(this);
-
- addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e)
- {
- try {
- Activator.context.getBundle().stop();
- } catch (BundleException ex) {
- ex.printStackTrace();
- }
- }
- });
- try {
- URL eventIconUrl = LightUI.class.getResource("images/logo.gif");
- ImageIcon icon= new ImageIcon(eventIconUrl,"logo");
- setIconImage(icon.getImage());
- }
- catch (Exception ex){
- System.out.println("Resource: IMAGES/logo.gif not found : " + ex.toString());
- }
-
- pack();
- setVisible(true);
- }
-
- private JPanel doMainPanel(){
- JPanel panel = new JPanel();
- label.setIcon(LIGHT_OFF);
- //label.setSize(new Dimension(32,32));
- label.addMouseListener(new MouseAdapter(){
- public void mouseClicked(MouseEvent e){
- if (SwingUtilities.isLeftMouseButton(e)){
- if (e.getClickCount()==1){
- Icon icon = label.getIcon();
- if (icon == LIGHT_ON)
- model.switchOff();
- else
- model.switchOn();
- }
- }
- }
- });
- panel.add(label);
- return panel;
- }
-
- private JPanel doControlPanel(){
- JPanel panel = new JPanel();
- btnSwitch = new JButton("On");
- btnFailure = new JButton("Break");
- panel.add(btnSwitch);
- panel.add(btnFailure);
-
- btnSwitch.addActionListener(new AbstractAction(){
- public void actionPerformed(ActionEvent e) {
- if (btnSwitch.getText().equals("On")){
- btnSwitch.setText("Off");
- model.switchOn();
- }else {
- btnSwitch.setText("On");
- model.switchOff();
- }
- }
- });
-
- btnFailure.addActionListener(new AbstractAction(){
- public void actionPerformed(ActionEvent e) {
- if (btnFailure.getText().equals("Break")){
- btnFailure.setText("Repair");
- btnSwitch.setEnabled(false);
- model.setFailure(true);
- } else {
- btnFailure.setText("Break");
- btnSwitch.setEnabled(true);
- model.setFailure(false);
- }
- }
- });
-
- return panel;
- }
-
- public static ImageIcon loadIcon(String path,String title)
- {
- try {
- URL eventIconUrl = LightUI.class.getResource("images/" + path);
- return new ImageIcon(eventIconUrl,title);
- }
- catch (Exception ex){
- System.out.println("Resource:" + path + " not found : " + ex.toString());
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent evt) {
- String property = evt.getPropertyName();
- boolean value = ((Boolean) evt.getNewValue()).booleanValue();
- System.out.println("BinaryLight property::"+property + " changed to:" + value);
- if (property.equals("Status")){
- if (value){
- label.setIcon(LIGHT_ON);
- btnSwitch.setText("Off");
- }
- else{
- label.setIcon(LIGHT_OFF);
- btnSwitch.setText("On");
- }
- }
- else if (property.equals("Failure")){
- if (value)
- label.setIcon(LIGHT_FAIL);
- }
- getContentPane().validate();
- repaint();
-
- }
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.net.URL;
+
+import javax.swing.AbstractAction;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import org.osgi.framework.BundleException;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class LightUI extends JFrame implements PropertyChangeListener {
+ private final static ImageIcon LIGHT_ON = LightUI.loadIcon("LightOn.gif","ON");
+ private final static ImageIcon LIGHT_OFF = LightUI.loadIcon("LightOff.gif","OFF");
+ private final static ImageIcon LIGHT_FAIL = LightUI.loadIcon("LightFail.gif","FAILURE");
+ private final JLabel label = new JLabel();
+ private LightModel model;
+ private JButton btnSwitch;
+ private JButton btnFailure;
+
+ public LightUI(LightModel model) {
+ super("Felix UPnP BinaryLight");
+ this.model = model;
+ setSize(150,150);
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.add(doMainPanel(),BorderLayout.CENTER);
+ panel.add(doControlPanel(),BorderLayout.SOUTH);
+ getContentPane().add(panel);
+ model.addPropertyChangeListener(this);
+
+ addWindowListener(new WindowAdapter(){
+ public void windowClosing(WindowEvent e)
+ {
+ try {
+ Activator.context.getBundle().stop();
+ } catch (BundleException ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+ try {
+ URL eventIconUrl = LightUI.class.getResource("images/logo.gif");
+ ImageIcon icon= new ImageIcon(eventIconUrl,"logo");
+ setIconImage(icon.getImage());
+ }
+ catch (Exception ex){
+ System.out.println("Resource: IMAGES/logo.gif not found : " + ex.toString());
+ }
+
+ pack();
+ setVisible(true);
+ }
+
+ private JPanel doMainPanel(){
+ JPanel panel = new JPanel();
+ label.setIcon(LIGHT_OFF);
+ //label.setSize(new Dimension(32,32));
+ label.addMouseListener(new MouseAdapter(){
+ public void mouseClicked(MouseEvent e){
+ if (SwingUtilities.isLeftMouseButton(e)){
+ if (e.getClickCount()==1){
+ Icon icon = label.getIcon();
+ if (icon == LIGHT_ON)
+ model.switchOff();
+ else
+ model.switchOn();
+ }
+ }
+ }
+ });
+ panel.add(label);
+ return panel;
+ }
+
+ private JPanel doControlPanel(){
+ JPanel panel = new JPanel();
+ btnSwitch = new JButton("On");
+ btnFailure = new JButton("Break");
+ panel.add(btnSwitch);
+ panel.add(btnFailure);
+
+ btnSwitch.addActionListener(new AbstractAction(){
+ public void actionPerformed(ActionEvent e) {
+ if (btnSwitch.getText().equals("On")){
+ btnSwitch.setText("Off");
+ model.switchOn();
+ }else {
+ btnSwitch.setText("On");
+ model.switchOff();
+ }
+ }
+ });
+
+ btnFailure.addActionListener(new AbstractAction(){
+ public void actionPerformed(ActionEvent e) {
+ if (btnFailure.getText().equals("Break")){
+ btnFailure.setText("Repair");
+ btnSwitch.setEnabled(false);
+ model.setFailure(true);
+ } else {
+ btnFailure.setText("Break");
+ btnSwitch.setEnabled(true);
+ model.setFailure(false);
+ }
+ }
+ });
+
+ return panel;
+ }
+
+ public static ImageIcon loadIcon(String path,String title)
+ {
+ try {
+ URL eventIconUrl = LightUI.class.getResource("images/" + path);
+ return new ImageIcon(eventIconUrl,title);
+ }
+ catch (Exception ex){
+ System.out.println("Resource:" + path + " not found : " + ex.toString());
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ String property = evt.getPropertyName();
+ boolean value = ((Boolean) evt.getNewValue()).booleanValue();
+ System.out.println("BinaryLight property::"+property + " changed to:" + value);
+ if (property.equals("Status")){
+ if (value){
+ label.setIcon(LIGHT_ON);
+ btnSwitch.setText("Off");
+ }
+ else{
+ label.setIcon(LIGHT_OFF);
+ btnSwitch.setText("On");
+ }
+ }
+ else if (property.equals("Failure")){
+ if (value)
+ label.setIcon(LIGHT_FAIL);
+ }
+ getContentPane().validate();
+ repaint();
+
+ }
+
+
+}
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/GetStatusAction.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/GetStatusAction.java
index 9b19b6a..06744ff 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/GetStatusAction.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/GetStatusAction.java
@@ -1,93 +1,93 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight.actions;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.sample.binaryLight.LightModel;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class GetStatusAction implements UPnPAction {
-
- final private String NAME = "GetStatus";
- final private String RESULT_STATUS = "ResultStatus";
- final private String[] OUT_ARG_NAMES = new String[]{RESULT_STATUS};
- private UPnPStateVariable state;
- private LightModel model;
-
-
- public GetStatusAction(LightModel model,UPnPStateVariable state){
- this.state = state;
- this.model=model;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
- */
- public String getReturnArgumentName() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
- */
- public String[] getInputArgumentNames() {
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
- */
- public String[] getOutputArgumentNames() {
- return OUT_ARG_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String argumentName) {
- return state;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
- */
- public Dictionary invoke(Dictionary args) throws Exception {
- boolean status = model.getStatus();
- Hashtable result = new Hashtable();
- result.put(RESULT_STATUS,new Boolean(status));
- return result;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight.actions;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.sample.binaryLight.LightModel;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class GetStatusAction implements UPnPAction {
+
+ final private String NAME = "GetStatus";
+ final private String RESULT_STATUS = "ResultStatus";
+ final private String[] OUT_ARG_NAMES = new String[]{RESULT_STATUS};
+ private UPnPStateVariable state;
+ private LightModel model;
+
+
+ public GetStatusAction(LightModel model,UPnPStateVariable state){
+ this.state = state;
+ this.model=model;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
+ */
+ public String getReturnArgumentName() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
+ */
+ public String[] getInputArgumentNames() {
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
+ */
+ public String[] getOutputArgumentNames() {
+ return OUT_ARG_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String argumentName) {
+ return state;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
+ */
+ public Dictionary invoke(Dictionary args) throws Exception {
+ boolean status = model.getStatus();
+ Hashtable result = new Hashtable();
+ result.put(RESULT_STATUS,new Boolean(status));
+ return result;
+ }
+}
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/GetTargetAction.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/GetTargetAction.java
index b40d2ef..8529ab3 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/GetTargetAction.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/GetTargetAction.java
@@ -1,93 +1,93 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight.actions;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.sample.binaryLight.LightModel;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class GetTargetAction implements UPnPAction {
-
- final private String NAME = "GetTarget";
- final private String RET_TARGET_VALUE = "RetTargetValue";
- final private String[] OUT_ARG_NAMES = new String[]{RET_TARGET_VALUE};
- private UPnPStateVariable state;
- private LightModel model;
-
-
- public GetTargetAction(LightModel model,UPnPStateVariable state){
- this.state = state;
- this.model=model;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
- */
- public String getReturnArgumentName() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
- */
- public String[] getInputArgumentNames() {
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
- */
- public String[] getOutputArgumentNames() {
- return OUT_ARG_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String argumentName) {
- return state;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
- */
- public Dictionary invoke(Dictionary args) throws Exception {
- boolean target = model.getTarget();
- Hashtable result = new Hashtable();
- result.put(RET_TARGET_VALUE,new Boolean(target));
- return result;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight.actions;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.sample.binaryLight.LightModel;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class GetTargetAction implements UPnPAction {
+
+ final private String NAME = "GetTarget";
+ final private String RET_TARGET_VALUE = "RetTargetValue";
+ final private String[] OUT_ARG_NAMES = new String[]{RET_TARGET_VALUE};
+ private UPnPStateVariable state;
+ private LightModel model;
+
+
+ public GetTargetAction(LightModel model,UPnPStateVariable state){
+ this.state = state;
+ this.model=model;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
+ */
+ public String getReturnArgumentName() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
+ */
+ public String[] getInputArgumentNames() {
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
+ */
+ public String[] getOutputArgumentNames() {
+ return OUT_ARG_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String argumentName) {
+ return state;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
+ */
+ public Dictionary invoke(Dictionary args) throws Exception {
+ boolean target = model.getTarget();
+ Hashtable result = new Hashtable();
+ result.put(RET_TARGET_VALUE,new Boolean(target));
+ return result;
+ }
+}
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/SetTargetAction.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/SetTargetAction.java
index cac1e44..ebf4677 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/SetTargetAction.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/actions/SetTargetAction.java
@@ -1,90 +1,90 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight.actions;
-
-import java.util.Dictionary;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.sample.binaryLight.LightModel;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class SetTargetAction implements UPnPAction {
-
- final private String NAME = "SetTarget";
- final private String NEW_TARGET_VALUE = "NewTargetValue";
- final private String[] IN_ARG_NAMES = new String[]{NEW_TARGET_VALUE};
- private UPnPStateVariable state;
- private LightModel model;
-
-
- public SetTargetAction(LightModel model,UPnPStateVariable state){
- this.state = state;
- this.model=model;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
- */
- public String getReturnArgumentName() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
- */
- public String[] getInputArgumentNames() {
- return IN_ARG_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
- */
- public String[] getOutputArgumentNames() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String argumentName) {
- return state;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
- */
- public Dictionary invoke(Dictionary args) throws Exception {
- Boolean value = (Boolean) args.get(NEW_TARGET_VALUE);
- model.doSwitch(value.booleanValue());
- return null;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight.actions;
+
+import java.util.Dictionary;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.sample.binaryLight.LightModel;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class SetTargetAction implements UPnPAction {
+
+ final private String NAME = "SetTarget";
+ final private String NEW_TARGET_VALUE = "NewTargetValue";
+ final private String[] IN_ARG_NAMES = new String[]{NEW_TARGET_VALUE};
+ private UPnPStateVariable state;
+ private LightModel model;
+
+
+ public SetTargetAction(LightModel model,UPnPStateVariable state){
+ this.state = state;
+ this.model=model;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
+ */
+ public String getReturnArgumentName() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
+ */
+ public String[] getInputArgumentNames() {
+ return IN_ARG_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
+ */
+ public String[] getOutputArgumentNames() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String argumentName) {
+ return state;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
+ */
+ public Dictionary invoke(Dictionary args) throws Exception {
+ Boolean value = (Boolean) args.get(NEW_TARGET_VALUE);
+ model.doSwitch(value.booleanValue());
+ return null;
+ }
+}
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/devices/LightDevice.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/devices/LightDevice.java
index 7065d42..c99bb9b 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/devices/LightDevice.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/devices/LightDevice.java
@@ -1,146 +1,146 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight.devices;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Dictionary;
-import java.util.Properties;
-import java.util.Random;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPIcon;
-import org.osgi.service.upnp.UPnPService;
-
-import org.apache.felix.upnp.extra.util.UPnPEventNotifier;
-import org.apache.felix.upnp.sample.binaryLight.LightModel;
-import org.apache.felix.upnp.sample.binaryLight.LightUI;
-import org.apache.felix.upnp.sample.binaryLight.icons.LightIcon;
-import org.apache.felix.upnp.sample.binaryLight.services.PowerSwitchService;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class LightDevice implements UPnPDevice {
-
- final private String DEVICE_ID = "uuid:Felix-BinaryLight+" +Integer.toHexString(new Random(System.currentTimeMillis()).nextInt());
- private BundleContext context;
- private LightModel model;
- private LightUI ui;
- private PowerSwitchService powerSwitch;
- private UPnPService[] services;
- private Dictionary dictionary;
- private UPnPEventNotifier notifier;
-
- public LightDevice(BundleContext context) {
- this.context=context;
- model = new LightModel();
- ui = new LightUI(model);
- powerSwitch = new PowerSwitchService(model);
- services = new UPnPService[]{powerSwitch};
- setupDeviceProperties();
- buildEventNotifyer();
- }
-
- public LightModel getModel(){
- return model;
- }
- /**
- *
- */
- private void buildEventNotifyer() {
- notifier = new UPnPEventNotifier(context,this,powerSwitch,model);
- }
-
- private void setupDeviceProperties(){
- dictionary = new Properties();
- dictionary.put(UPnPDevice.UPNP_EXPORT,"");
- dictionary.put(
- org.osgi.service
- .device.Constants.DEVICE_CATEGORY,
- new String[]{UPnPDevice.DEVICE_CATEGORY}
- );
- //dictionary.put(UPnPDevice.DEVICE_CATEGORY,new String[]{UPnPDevice.DEVICE_CATEGORY});
- dictionary.put(UPnPDevice.FRIENDLY_NAME,"Felix OSGi-UPnP BinaryLight");
- dictionary.put(UPnPDevice.MANUFACTURER,"Apache Software Foundation");
- dictionary.put(UPnPDevice.MANUFACTURER_URL,"http://felix.apache.org");
- dictionary.put(UPnPDevice.MODEL_DESCRIPTION,"A BinaryLight device to test OSGi to UPnP service export");
- dictionary.put(UPnPDevice.MODEL_NAME,"Lucciola");
- dictionary.put(UPnPDevice.MODEL_NUMBER,"1.0");
- dictionary.put(UPnPDevice.MODEL_URL,"http://felix.apache.org/site/upnp-examples.html");
- String port = context.getProperty("org.osgi.service.http.port");
- InetAddress inet;
- try {
- inet = InetAddress.getLocalHost();
- String hostname = inet.getHostName();
- //String hostname = inet.getHostAddress();
- dictionary.put(UPnPDevice.PRESENTATION_URL,"http://"+hostname + ":"+port+"/upnp/binaryLight/");
- } catch (UnknownHostException e) {
- System.out.println("Warning: enable to cacth localhost name");
- }
- dictionary.put(UPnPDevice.SERIAL_NUMBER,"123456789");
- dictionary.put(UPnPDevice.TYPE,"urn:schemas-upnp-org:device:BinaryLight:1");
- dictionary.put(UPnPDevice.UDN,DEVICE_ID);
- //dictionary.put(UPnPDevice.ID,dictionary.get(UPnPDevice.UDN));
- dictionary.put(UPnPDevice.UPC,"1213456789");
- }
-
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getService(java.lang.String)
- */
- public UPnPService getService(String serviceId) {
- if (serviceId.equals(powerSwitch.getId())) return powerSwitch;
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getServices()
- */
- public UPnPService[] getServices() {
- return services;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getIcons(java.lang.String)
- */
- public UPnPIcon[] getIcons(String locale) {
- UPnPIcon icon = new LightIcon();
- return new UPnPIcon[]{icon} ;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getDescriptions(java.lang.String)
- */
- public Dictionary getDescriptions(String locale) {
- return dictionary;
- }
-
- /**
- *
- */
- public void close() {
- ui.dispose();
- notifier.destroy();
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight.devices;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Dictionary;
+import java.util.Properties;
+import java.util.Random;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPIcon;
+import org.osgi.service.upnp.UPnPService;
+
+import org.apache.felix.upnp.extra.util.UPnPEventNotifier;
+import org.apache.felix.upnp.sample.binaryLight.LightModel;
+import org.apache.felix.upnp.sample.binaryLight.LightUI;
+import org.apache.felix.upnp.sample.binaryLight.icons.LightIcon;
+import org.apache.felix.upnp.sample.binaryLight.services.PowerSwitchService;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class LightDevice implements UPnPDevice {
+
+ final private String DEVICE_ID = "uuid:Felix-BinaryLight+" +Integer.toHexString(new Random(System.currentTimeMillis()).nextInt());
+ private BundleContext context;
+ private LightModel model;
+ private LightUI ui;
+ private PowerSwitchService powerSwitch;
+ private UPnPService[] services;
+ private Dictionary dictionary;
+ private UPnPEventNotifier notifier;
+
+ public LightDevice(BundleContext context) {
+ this.context=context;
+ model = new LightModel();
+ ui = new LightUI(model);
+ powerSwitch = new PowerSwitchService(model);
+ services = new UPnPService[]{powerSwitch};
+ setupDeviceProperties();
+ buildEventNotifyer();
+ }
+
+ public LightModel getModel(){
+ return model;
+ }
+ /**
+ *
+ */
+ private void buildEventNotifyer() {
+ notifier = new UPnPEventNotifier(context,this,powerSwitch,model);
+ }
+
+ private void setupDeviceProperties(){
+ dictionary = new Properties();
+ dictionary.put(UPnPDevice.UPNP_EXPORT,"");
+ dictionary.put(
+ org.osgi.service
+ .device.Constants.DEVICE_CATEGORY,
+ new String[]{UPnPDevice.DEVICE_CATEGORY}
+ );
+ //dictionary.put(UPnPDevice.DEVICE_CATEGORY,new String[]{UPnPDevice.DEVICE_CATEGORY});
+ dictionary.put(UPnPDevice.FRIENDLY_NAME,"Felix OSGi-UPnP BinaryLight");
+ dictionary.put(UPnPDevice.MANUFACTURER,"Apache Software Foundation");
+ dictionary.put(UPnPDevice.MANUFACTURER_URL,"http://felix.apache.org");
+ dictionary.put(UPnPDevice.MODEL_DESCRIPTION,"A BinaryLight device to test OSGi to UPnP service export");
+ dictionary.put(UPnPDevice.MODEL_NAME,"Lucciola");
+ dictionary.put(UPnPDevice.MODEL_NUMBER,"1.0");
+ dictionary.put(UPnPDevice.MODEL_URL,"http://felix.apache.org/site/upnp-examples.html");
+ String port = context.getProperty("org.osgi.service.http.port");
+ InetAddress inet;
+ try {
+ inet = InetAddress.getLocalHost();
+ String hostname = inet.getHostName();
+ //String hostname = inet.getHostAddress();
+ dictionary.put(UPnPDevice.PRESENTATION_URL,"http://"+hostname + ":"+port+"/upnp/binaryLight/");
+ } catch (UnknownHostException e) {
+ System.out.println("Warning: enable to cacth localhost name");
+ }
+ dictionary.put(UPnPDevice.SERIAL_NUMBER,"123456789");
+ dictionary.put(UPnPDevice.TYPE,"urn:schemas-upnp-org:device:BinaryLight:1");
+ dictionary.put(UPnPDevice.UDN,DEVICE_ID);
+ //dictionary.put(UPnPDevice.ID,dictionary.get(UPnPDevice.UDN));
+ dictionary.put(UPnPDevice.UPC,"1213456789");
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getService(java.lang.String)
+ */
+ public UPnPService getService(String serviceId) {
+ if (serviceId.equals(powerSwitch.getId())) return powerSwitch;
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getServices()
+ */
+ public UPnPService[] getServices() {
+ return services;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getIcons(java.lang.String)
+ */
+ public UPnPIcon[] getIcons(String locale) {
+ UPnPIcon icon = new LightIcon();
+ return new UPnPIcon[]{icon} ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getDescriptions(java.lang.String)
+ */
+ public Dictionary getDescriptions(String locale) {
+ return dictionary;
+ }
+
+ /**
+ *
+ */
+ public void close() {
+ ui.dispose();
+ notifier.destroy();
+ }
+
+}
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/icons/LightIcon.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/icons/LightIcon.java
index 6f54e3b..75171b0 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/icons/LightIcon.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/icons/LightIcon.java
@@ -1,73 +1,73 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight.icons;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.osgi.service.upnp.UPnPIcon;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class LightIcon implements UPnPIcon {
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getMimeType()
- */
- public String getMimeType() {
- return "image/gif";
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getWidth()
- */
- public int getWidth() {
- return 32;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getHeight()
- */
- public int getHeight() {
- return 32;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getSize()
- */
- public int getSize() {
- return 1072;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getDepth()
- */
- public int getDepth() {
- return 16;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getInputStream()
- */
- public InputStream getInputStream() throws IOException {
- return LightIcon.class.getResourceAsStream("images/LightOn.gif");
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight.icons;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.osgi.service.upnp.UPnPIcon;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class LightIcon implements UPnPIcon {
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getMimeType()
+ */
+ public String getMimeType() {
+ return "image/gif";
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getWidth()
+ */
+ public int getWidth() {
+ return 32;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getHeight()
+ */
+ public int getHeight() {
+ return 32;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getSize()
+ */
+ public int getSize() {
+ return 1072;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getDepth()
+ */
+ public int getDepth() {
+ return 16;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getInputStream()
+ */
+ public InputStream getInputStream() throws IOException {
+ return LightIcon.class.getResourceAsStream("images/LightOn.gif");
+ }
+}
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/services/PowerSwitchService.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/services/PowerSwitchService.java
index c4fc2ac..7904c05 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/services/PowerSwitchService.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/services/PowerSwitchService.java
@@ -1,118 +1,118 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight.services;
-
-import java.util.HashMap;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.sample.binaryLight.LightModel;
-import org.apache.felix.upnp.sample.binaryLight.actions.GetStatusAction;
-import org.apache.felix.upnp.sample.binaryLight.actions.GetTargetAction;
-import org.apache.felix.upnp.sample.binaryLight.actions.SetTargetAction;
-import org.apache.felix.upnp.sample.binaryLight.statevariables.StatusStateVariable;
-import org.apache.felix.upnp.sample.binaryLight.statevariables.TargetStateVariable;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class PowerSwitchService implements UPnPService{
-
- final private String SERVICE_ID = "urn:upnp-org:serviceId:SwitchPower:1";
- final private String SERVICE_TYPE = "urn:schemas-upnp-org:service:SwitchPower:1";
- final private String VERSION ="1";
-
- private LightModel model;
- private UPnPStateVariable status,target;
- private UPnPStateVariable[] states;
- private HashMap actions = new HashMap();
-
-
- public PowerSwitchService(LightModel model){
- this.model = model;
- status = new StatusStateVariable(model);
- target = new TargetStateVariable();
- this.states = new UPnPStateVariable[]{status,target};
-
- UPnPAction setTarget = new SetTargetAction(model,target);
- UPnPAction getTarget = new GetTargetAction(model,target);
- UPnPAction getStatus = new GetStatusAction(model,status);
- actions.put(setTarget.getName(),setTarget);
- actions.put(getTarget.getName(),getTarget);
- actions.put(getStatus.getName(),getStatus);
-
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getId()
- */
- public String getId() {
- return SERVICE_ID;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getType()
- */
- public String getType() {
- return SERVICE_TYPE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getVersion()
- */
- public String getVersion() {
- return VERSION;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getAction(java.lang.String)
- */
- public UPnPAction getAction(String name) {
- return (UPnPAction)actions.get(name);
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getActions()
- */
- public UPnPAction[] getActions() {
- return (UPnPAction[])(actions.values()).toArray(new UPnPAction[]{});
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getStateVariables()
- */
- public UPnPStateVariable[] getStateVariables() {
- return states;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String name) {
- if (name.equals("Status"))
- return status;
- else if (name.equals("Target"))
- return target;
- else return null;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight.services;
+
+import java.util.HashMap;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.sample.binaryLight.LightModel;
+import org.apache.felix.upnp.sample.binaryLight.actions.GetStatusAction;
+import org.apache.felix.upnp.sample.binaryLight.actions.GetTargetAction;
+import org.apache.felix.upnp.sample.binaryLight.actions.SetTargetAction;
+import org.apache.felix.upnp.sample.binaryLight.statevariables.StatusStateVariable;
+import org.apache.felix.upnp.sample.binaryLight.statevariables.TargetStateVariable;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class PowerSwitchService implements UPnPService{
+
+ final private String SERVICE_ID = "urn:upnp-org:serviceId:SwitchPower:1";
+ final private String SERVICE_TYPE = "urn:schemas-upnp-org:service:SwitchPower:1";
+ final private String VERSION ="1";
+
+ private LightModel model;
+ private UPnPStateVariable status,target;
+ private UPnPStateVariable[] states;
+ private HashMap actions = new HashMap();
+
+
+ public PowerSwitchService(LightModel model){
+ this.model = model;
+ status = new StatusStateVariable(model);
+ target = new TargetStateVariable();
+ this.states = new UPnPStateVariable[]{status,target};
+
+ UPnPAction setTarget = new SetTargetAction(model,target);
+ UPnPAction getTarget = new GetTargetAction(model,target);
+ UPnPAction getStatus = new GetStatusAction(model,status);
+ actions.put(setTarget.getName(),setTarget);
+ actions.put(getTarget.getName(),getTarget);
+ actions.put(getStatus.getName(),getStatus);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getId()
+ */
+ public String getId() {
+ return SERVICE_ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getType()
+ */
+ public String getType() {
+ return SERVICE_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getVersion()
+ */
+ public String getVersion() {
+ return VERSION;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getAction(java.lang.String)
+ */
+ public UPnPAction getAction(String name) {
+ return (UPnPAction)actions.get(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getActions()
+ */
+ public UPnPAction[] getActions() {
+ return (UPnPAction[])(actions.values()).toArray(new UPnPAction[]{});
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getStateVariables()
+ */
+ public UPnPStateVariable[] getStateVariables() {
+ return states;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String name) {
+ if (name.equals("Status"))
+ return status;
+ else if (name.equals("Target"))
+ return target;
+ else return null;
+ }
+}
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/statevariables/StatusStateVariable.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/statevariables/StatusStateVariable.java
index f28ea45..38c5f63 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/statevariables/StatusStateVariable.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/statevariables/StatusStateVariable.java
@@ -1,102 +1,102 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight.statevariables;
-import org.osgi.service.upnp.UPnPLocalStateVariable;
-
-import org.apache.felix.upnp.sample.binaryLight.LightModel;
-
-public class StatusStateVariable implements UPnPLocalStateVariable{
-
- final private String NAME = "Status";
- final private Boolean DEFAULT_VALUE = Boolean.FALSE;
- private LightModel model;
-
-
- public StatusStateVariable(LightModel model){
- this.model= model;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
- */
- public Class getJavaDataType() {
- return Boolean.class;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
- */
- public String getUPnPDataType() {
- return TYPE_BOOLEAN;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
- */
- public Object getDefaultValue() {
- return DEFAULT_VALUE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
- */
- public String[] getAllowedValues() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
- */
- public Number getMinimum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
- */
- public Number getMaximum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
- */
- public Number getStep() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
- */
- public boolean sendsEvents() {
- return true;
- }
-
- public Object getCurrentValue() {
- return new Boolean(model.getStatus());
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight.statevariables;
+import org.osgi.service.upnp.UPnPLocalStateVariable;
+
+import org.apache.felix.upnp.sample.binaryLight.LightModel;
+
+public class StatusStateVariable implements UPnPLocalStateVariable{
+
+ final private String NAME = "Status";
+ final private Boolean DEFAULT_VALUE = Boolean.FALSE;
+ private LightModel model;
+
+
+ public StatusStateVariable(LightModel model){
+ this.model= model;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
+ */
+ public Class getJavaDataType() {
+ return Boolean.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
+ */
+ public String getUPnPDataType() {
+ return TYPE_BOOLEAN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return DEFAULT_VALUE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
+ */
+ public String[] getAllowedValues() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
+ */
+ public Number getMinimum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
+ */
+ public Number getMaximum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
+ */
+ public Number getStep() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
+ */
+ public boolean sendsEvents() {
+ return true;
+ }
+
+ public Object getCurrentValue() {
+ return new Boolean(model.getStatus());
+ }
+}
diff --git a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/statevariables/TargetStateVariable.java b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/statevariables/TargetStateVariable.java
index cfa8918..c99a983 100644
--- a/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/statevariables/TargetStateVariable.java
+++ b/upnp/samples/binarylight/src/main/java/org/apache/felix/upnp/sample/binaryLight/statevariables/TargetStateVariable.java
@@ -1,94 +1,94 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.binaryLight.statevariables;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-public class TargetStateVariable implements UPnPStateVariable{
-
- final private String NAME = "Target";
- final private Boolean DEFAULT_VALUE = Boolean.FALSE;
-
-
- public TargetStateVariable(){
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
- */
- public Class getJavaDataType() {
- return Boolean.class;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
- */
- public String getUPnPDataType() {
- return TYPE_BOOLEAN;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
- */
- public Object getDefaultValue() {
- return DEFAULT_VALUE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
- */
- public String[] getAllowedValues() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
- */
- public Number getMinimum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
- */
- public Number getMaximum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
- */
- public Number getStep() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
- */
- public boolean sendsEvents() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.binaryLight.statevariables;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+public class TargetStateVariable implements UPnPStateVariable{
+
+ final private String NAME = "Target";
+ final private Boolean DEFAULT_VALUE = Boolean.FALSE;
+
+
+ public TargetStateVariable(){
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
+ */
+ public Class getJavaDataType() {
+ return Boolean.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
+ */
+ public String getUPnPDataType() {
+ return TYPE_BOOLEAN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return DEFAULT_VALUE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
+ */
+ public String[] getAllowedValues() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
+ */
+ public Number getMinimum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
+ */
+ public Number getMaximum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
+ */
+ public Number getStep() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
+ */
+ public boolean sendsEvents() {
+ return false;
+ }
+}
diff --git a/upnp/samples/clock/pom.xml b/upnp/samples/clock/pom.xml
index cdbbdb3..bd219df 100644
--- a/upnp/samples/clock/pom.xml
+++ b/upnp/samples/clock/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -17,60 +17,60 @@
specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>felix</artifactId>
- <groupId>org.apache.felix</groupId>
- <version>1.0.2</version>
- <relativePath>../../../pom/pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.upnp.sample.clock</artifactId>
- <packaging>bundle</packaging>
- <name>Apache Felix UPnP Sample Clock</name>
- <version>0.2.0-SNAPSHOT</version>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>felix</artifactId>
+ <groupId>org.apache.felix</groupId>
+ <version>1.0.2</version>
+ <relativePath>../../../pom/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.upnp.sample.clock</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Felix UPnP Sample Clock</name>
+ <version>0.2.0-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${pom.name}</Bundle-Name>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
- <Bundle-Author>Matteo Demuru <demuru@apache.org>,Francesco Furfari <furfari@apache.org>,Stefano "Kismet" Lenzi <lenzi@apache.org></Bundle-Author>
- <Bundle-Description>CyberLink Clock clone to test UPnPBase driver</Bundle-Description>
- <Bundle-SymbolicName>org.apache.felix.upnp.sample.clock</Bundle-SymbolicName>
- <Bundle-Activator>org.apache.felix.upnp.sample.clock.Activator</Bundle-Activator>
- <Private-Package>org.apache.felix.upnp.sample.clock.*</Private-Package>
- <Import-Package>*</Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.compendium</artifactId>
+ <Bundle-Author>Matteo Demuru <demuru@apache.org>,Francesco Furfari <furfari@apache.org>,Stefano "Kismet" Lenzi <lenzi@apache.org></Bundle-Author>
+ <Bundle-Description>CyberLink Clock clone to test UPnPBase driver</Bundle-Description>
+ <Bundle-SymbolicName>org.apache.felix.upnp.sample.clock</Bundle-SymbolicName>
+ <Bundle-Activator>org.apache.felix.upnp.sample.clock.Activator</Bundle-Activator>
+ <Private-Package>org.apache.felix.upnp.sample.clock.*</Private-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
<version>1.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.upnp.extra</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-</project>
-
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.upnp.extra</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
+
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/Clock.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/Clock.java
index fffbc77..ef69110 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/Clock.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/Clock.java
@@ -1,156 +1,156 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-
-import java.util.Calendar;
-
-public class Clock
-{
- private Calendar cal;
-
- public Clock(Calendar cal)
- {
- this.cal = cal;
- }
-
- public Calendar getCalendar()
- {
- return cal;
- }
-
- ////////////////////////////////////////////////
- // Time
- ////////////////////////////////////////////////
-
- public int getHour()
- {
- return getCalendar().get(Calendar.HOUR);
- }
-
- public int getMinute()
- {
- return getCalendar().get(Calendar.MINUTE);
- }
-
- public int getSecond()
- {
- return getCalendar().get(Calendar.SECOND);
- }
-
- ////////////////////////////////////////////////
- // paint
- ////////////////////////////////////////////////
-
- public final static Clock getInstance()
- {
- return new Clock(Calendar.getInstance());
- }
-
- ////////////////////////////////////////////////
- // getDateString
- ////////////////////////////////////////////////
-
- public final static String toClockString(int value)
- {
- if (value < 10)
- return "0" + Integer.toString(value);
- return Integer.toString(value);
- }
-
- private final static String MONTH_STRING[] = {
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec",
- };
-
- public final static String toMonthString(int value)
- {
- value -= Calendar.JANUARY;
- if (0 <= value && value < 12)
- return MONTH_STRING[value];
- return "";
- }
-
- private final static String WEEK_STRING[] = {
- "Sun",
- "Mon",
- "Tue",
- "Wed",
- "Thu",
- "Fri",
- "Sat",
- };
-
- public final static String toWeekString(int value)
- {
- value -= Calendar.SUNDAY;
- if (0 <= value && value < 7)
- return WEEK_STRING[value];
- return "";
- }
-
- public String getDateString()
- {
- Calendar cal = getCalendar();
- return
- toWeekString(cal.get(Calendar.DAY_OF_WEEK)) +", " +
- toMonthString(cal.get(Calendar.MONTH)) + " " +
- Integer.toString(cal.get(Calendar.DATE)) + ", " +
- toClockString(cal.get(Calendar.YEAR) % 100);
- }
-
- ////////////////////////////////////////////////
- // getTimeString
- ////////////////////////////////////////////////
-
- public String getTimeString()
- {
- Calendar cal = getCalendar();
- return
- toClockString(cal.get(Calendar.HOUR)) +
- (((cal.get(Calendar.SECOND) % 2) == 0) ? ":" : " ") +
- toClockString(cal.get(Calendar.MINUTE));
- }
-
- ////////////////////////////////////////////////
- // toString
- ////////////////////////////////////////////////
-
- public String toString()
- {
- Calendar cal = getCalendar();
- return
- getDateString() + ", " +
- toClockString(cal.get(Calendar.HOUR)) + ":" +
- toClockString(cal.get(Calendar.MINUTE)) + ":" +
- toClockString(cal.get(Calendar.SECOND));
- }
-
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+
+import java.util.Calendar;
+
+public class Clock
+{
+ private Calendar cal;
+
+ public Clock(Calendar cal)
+ {
+ this.cal = cal;
+ }
+
+ public Calendar getCalendar()
+ {
+ return cal;
+ }
+
+ ////////////////////////////////////////////////
+ // Time
+ ////////////////////////////////////////////////
+
+ public int getHour()
+ {
+ return getCalendar().get(Calendar.HOUR);
+ }
+
+ public int getMinute()
+ {
+ return getCalendar().get(Calendar.MINUTE);
+ }
+
+ public int getSecond()
+ {
+ return getCalendar().get(Calendar.SECOND);
+ }
+
+ ////////////////////////////////////////////////
+ // paint
+ ////////////////////////////////////////////////
+
+ public final static Clock getInstance()
+ {
+ return new Clock(Calendar.getInstance());
+ }
+
+ ////////////////////////////////////////////////
+ // getDateString
+ ////////////////////////////////////////////////
+
+ public final static String toClockString(int value)
+ {
+ if (value < 10)
+ return "0" + Integer.toString(value);
+ return Integer.toString(value);
+ }
+
+ private final static String MONTH_STRING[] = {
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec",
+ };
+
+ public final static String toMonthString(int value)
+ {
+ value -= Calendar.JANUARY;
+ if (0 <= value && value < 12)
+ return MONTH_STRING[value];
+ return "";
+ }
+
+ private final static String WEEK_STRING[] = {
+ "Sun",
+ "Mon",
+ "Tue",
+ "Wed",
+ "Thu",
+ "Fri",
+ "Sat",
+ };
+
+ public final static String toWeekString(int value)
+ {
+ value -= Calendar.SUNDAY;
+ if (0 <= value && value < 7)
+ return WEEK_STRING[value];
+ return "";
+ }
+
+ public String getDateString()
+ {
+ Calendar cal = getCalendar();
+ return
+ toWeekString(cal.get(Calendar.DAY_OF_WEEK)) +", " +
+ toMonthString(cal.get(Calendar.MONTH)) + " " +
+ Integer.toString(cal.get(Calendar.DATE)) + ", " +
+ toClockString(cal.get(Calendar.YEAR) % 100);
+ }
+
+ ////////////////////////////////////////////////
+ // getTimeString
+ ////////////////////////////////////////////////
+
+ public String getTimeString()
+ {
+ Calendar cal = getCalendar();
+ return
+ toClockString(cal.get(Calendar.HOUR)) +
+ (((cal.get(Calendar.SECOND) % 2) == 0) ? ":" : " ") +
+ toClockString(cal.get(Calendar.MINUTE));
+ }
+
+ ////////////////////////////////////////////////
+ // toString
+ ////////////////////////////////////////////////
+
+ public String toString()
+ {
+ Calendar cal = getCalendar();
+ return
+ getDateString() + ", " +
+ toClockString(cal.get(Calendar.HOUR)) + ":" +
+ toClockString(cal.get(Calendar.MINUTE)) + ":" +
+ toClockString(cal.get(Calendar.SECOND));
+ }
+
+}
+
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockDevice.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockDevice.java
index cbce196..fac9bb0 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockDevice.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockDevice.java
@@ -1,142 +1,142 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-
-
-import java.beans.PropertyChangeEvent;
-import java.util.Calendar;
-import java.util.Dictionary;
-import java.util.Properties;
-import java.util.Random;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPIcon;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.extra.util.UPnPEventNotifier;
-
-public class ClockDevice implements UPnPDevice {
-
- final private String DEVICE_ID = "uuid:Felix-Clock+"+Integer.toHexString(new Random(System.currentTimeMillis()).nextInt());
- private BundleContext context;
- private TimerService timerService;
- private UPnPService[] services;
- private Dictionary dictionary;
- public static UPnPEventNotifier notifier = null;
-
- public ClockDevice(BundleContext context) {
- this.context=context;
- timerService = new TimerService();
- services = new UPnPService[]{timerService};
- setupDeviceProperties();
- buildEventNotifyer();
- }
-
- /**
- *
- */
- private void buildEventNotifyer() {
- notifier = new UPnPEventNotifier(context,this,timerService);
- }
-
- private void setupDeviceProperties(){
- dictionary = new Properties();
- dictionary.put(UPnPDevice.UPNP_EXPORT,"");
- dictionary.put(
- org.osgi.service
- .device.Constants.DEVICE_CATEGORY,
- new String[]{UPnPDevice.DEVICE_CATEGORY}
- );
- //dictionary.put(UPnPDevice.DEVICE_CATEGORY,new String[]{UPnPDevice.DEVICE_CATEGORY});
- dictionary.put(UPnPDevice.FRIENDLY_NAME,"Felix OSGi-UPnP Clock");
- dictionary.put(UPnPDevice.MANUFACTURER,"Apache Software Foundation");
- dictionary.put(UPnPDevice.MANUFACTURER_URL,"http://felix.apache.org");
- dictionary.put(UPnPDevice.MODEL_DESCRIPTION,"A CyberLink Clock device clone to test OSGi to UPnP service export");
- dictionary.put(UPnPDevice.MODEL_NAME,"DolceDormire");
- dictionary.put(UPnPDevice.MODEL_NUMBER,"1.0");
- dictionary.put(UPnPDevice.MODEL_URL,"http://felix.apache.org/site/upnp-examples.html");
- //dictionary.put(UPnPDevice.PRESENTATION_URL,"http://felix.apache.org/dolceDormire/presentation");
- dictionary.put(UPnPDevice.SERIAL_NUMBER,"123456789");
- dictionary.put(UPnPDevice.TYPE,"urn:schemas-upnp-org:device:clock:1");
- dictionary.put(UPnPDevice.UDN,DEVICE_ID);
- //dictionary.put(UPnPDevice.ID,dictionary.get(UPnPDevice.UDN));
- dictionary.put(UPnPDevice.UPC,"1213456789");
- }
-
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getService(java.lang.String)
- */
- public UPnPService getService(String serviceId) {
- if (serviceId.equals(timerService.getId())) return timerService;
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getServices()
- */
- public UPnPService[] getServices() {
- return services;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getIcons(java.lang.String)
- */
- public UPnPIcon[] getIcons(String locale) {
- UPnPIcon icon = new ClockIcon();
- return new UPnPIcon[]{icon} ;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getDescriptions(java.lang.String)
- */
- public Dictionary getDescriptions(String locale) {
- return dictionary;
- }
-
- /**
- *
- */
- public void start() {
- // TODO Auto-generated method stub
-
- }
-
- /**
- *
- */
- public void stop() {
- notifier.destroy();
- }
-
- /**
- *
- */
- public void update() {
- Clock clock = Clock.getInstance();
- Calendar cal = clock.getCalendar();
- long time = cal.getTime().getTime();
- UPnPStateVariable variable = timerService.getStateVariable("Time");
- notifier.propertyChange(new PropertyChangeEvent(variable,"Time",new Long(time-1000),new Long(time)));
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+
+
+import java.beans.PropertyChangeEvent;
+import java.util.Calendar;
+import java.util.Dictionary;
+import java.util.Properties;
+import java.util.Random;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPIcon;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.extra.util.UPnPEventNotifier;
+
+public class ClockDevice implements UPnPDevice {
+
+ final private String DEVICE_ID = "uuid:Felix-Clock+"+Integer.toHexString(new Random(System.currentTimeMillis()).nextInt());
+ private BundleContext context;
+ private TimerService timerService;
+ private UPnPService[] services;
+ private Dictionary dictionary;
+ public static UPnPEventNotifier notifier = null;
+
+ public ClockDevice(BundleContext context) {
+ this.context=context;
+ timerService = new TimerService();
+ services = new UPnPService[]{timerService};
+ setupDeviceProperties();
+ buildEventNotifyer();
+ }
+
+ /**
+ *
+ */
+ private void buildEventNotifyer() {
+ notifier = new UPnPEventNotifier(context,this,timerService);
+ }
+
+ private void setupDeviceProperties(){
+ dictionary = new Properties();
+ dictionary.put(UPnPDevice.UPNP_EXPORT,"");
+ dictionary.put(
+ org.osgi.service
+ .device.Constants.DEVICE_CATEGORY,
+ new String[]{UPnPDevice.DEVICE_CATEGORY}
+ );
+ //dictionary.put(UPnPDevice.DEVICE_CATEGORY,new String[]{UPnPDevice.DEVICE_CATEGORY});
+ dictionary.put(UPnPDevice.FRIENDLY_NAME,"Felix OSGi-UPnP Clock");
+ dictionary.put(UPnPDevice.MANUFACTURER,"Apache Software Foundation");
+ dictionary.put(UPnPDevice.MANUFACTURER_URL,"http://felix.apache.org");
+ dictionary.put(UPnPDevice.MODEL_DESCRIPTION,"A CyberLink Clock device clone to test OSGi to UPnP service export");
+ dictionary.put(UPnPDevice.MODEL_NAME,"DolceDormire");
+ dictionary.put(UPnPDevice.MODEL_NUMBER,"1.0");
+ dictionary.put(UPnPDevice.MODEL_URL,"http://felix.apache.org/site/upnp-examples.html");
+ //dictionary.put(UPnPDevice.PRESENTATION_URL,"http://felix.apache.org/dolceDormire/presentation");
+ dictionary.put(UPnPDevice.SERIAL_NUMBER,"123456789");
+ dictionary.put(UPnPDevice.TYPE,"urn:schemas-upnp-org:device:clock:1");
+ dictionary.put(UPnPDevice.UDN,DEVICE_ID);
+ //dictionary.put(UPnPDevice.ID,dictionary.get(UPnPDevice.UDN));
+ dictionary.put(UPnPDevice.UPC,"1213456789");
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getService(java.lang.String)
+ */
+ public UPnPService getService(String serviceId) {
+ if (serviceId.equals(timerService.getId())) return timerService;
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getServices()
+ */
+ public UPnPService[] getServices() {
+ return services;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getIcons(java.lang.String)
+ */
+ public UPnPIcon[] getIcons(String locale) {
+ UPnPIcon icon = new ClockIcon();
+ return new UPnPIcon[]{icon} ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getDescriptions(java.lang.String)
+ */
+ public Dictionary getDescriptions(String locale) {
+ return dictionary;
+ }
+
+ /**
+ *
+ */
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ *
+ */
+ public void stop() {
+ notifier.destroy();
+ }
+
+ /**
+ *
+ */
+ public void update() {
+ Clock clock = Clock.getInstance();
+ Calendar cal = clock.getCalendar();
+ long time = cal.getTime().getTime();
+ UPnPStateVariable variable = timerService.getStateVariable("Time");
+ notifier.propertyChange(new PropertyChangeEvent(variable,"Time",new Long(time-1000),new Long(time)));
+ }
+
+}
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockFrame.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockFrame.java
index aa19acb..4adeff2 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockFrame.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockFrame.java
@@ -1,123 +1,123 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-
-import java.awt.BorderLayout;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.net.URL;
-
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-public class ClockFrame extends JFrame implements Runnable
-{
- private final static String TITLE = "Felix UPnP Clock";
- private ClockDevice clockDev;
- private ClockPane clockPane;
-
- public ClockFrame(final BundleContext context)
- {
- super(TITLE);
- try {
- clockDev = new ClockDevice( context);
- }
- catch (Exception e) {
- System.out.println(e);
- }
-
- getContentPane().setLayout(new BorderLayout());
-
- clockPane = new ClockPane();
- getContentPane().add(clockPane, BorderLayout.CENTER);
-
- addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e)
- {
- try {
- context.getBundle().stop();
- } catch (BundleException ex) {
- ex.printStackTrace();
- }
- }
- });
- try {
- URL eventIconUrl = ClockFrame.class.getResource("images/logo.gif");
- ImageIcon icon= new ImageIcon(eventIconUrl,"logo");
- setIconImage(icon.getImage());
- }
- catch (Exception ex){
- System.out.println("Resource: IMAGES/logo.gif not found : " + ex.toString());
- }
-
- pack();
- setVisible(true);
- }
-
- public ClockPane getClockPanel()
- {
- return clockPane;
- }
-
- public ClockDevice getClockDevice()
- {
- return clockDev;
- }
-
- ////////////////////////////////////////////////
- // run
- ////////////////////////////////////////////////
-
- private Thread timerThread = null;
-
- public void run()
- {
- Thread thisThread = Thread.currentThread();
-
- while (timerThread == thisThread) {
- getClockDevice().update();
- getClockPanel().repaint();
- try {
- Thread.sleep(1000);
- }
- catch(InterruptedException e) {}
- }
- }
-
- public void start()
- {
- clockDev.start();
-
- timerThread = new Thread(this,"upnp.sample.clock.ClockFrame");
- timerThread.start();
- }
-
- public void stop()
- {
- clockDev.stop();
- timerThread = null;
- dispose();
- }
-
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+
+import java.awt.BorderLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.net.URL;
+
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+public class ClockFrame extends JFrame implements Runnable
+{
+ private final static String TITLE = "Felix UPnP Clock";
+ private ClockDevice clockDev;
+ private ClockPane clockPane;
+
+ public ClockFrame(final BundleContext context)
+ {
+ super(TITLE);
+ try {
+ clockDev = new ClockDevice( context);
+ }
+ catch (Exception e) {
+ System.out.println(e);
+ }
+
+ getContentPane().setLayout(new BorderLayout());
+
+ clockPane = new ClockPane();
+ getContentPane().add(clockPane, BorderLayout.CENTER);
+
+ addWindowListener(new WindowAdapter(){
+ public void windowClosing(WindowEvent e)
+ {
+ try {
+ context.getBundle().stop();
+ } catch (BundleException ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+ try {
+ URL eventIconUrl = ClockFrame.class.getResource("images/logo.gif");
+ ImageIcon icon= new ImageIcon(eventIconUrl,"logo");
+ setIconImage(icon.getImage());
+ }
+ catch (Exception ex){
+ System.out.println("Resource: IMAGES/logo.gif not found : " + ex.toString());
+ }
+
+ pack();
+ setVisible(true);
+ }
+
+ public ClockPane getClockPanel()
+ {
+ return clockPane;
+ }
+
+ public ClockDevice getClockDevice()
+ {
+ return clockDev;
+ }
+
+ ////////////////////////////////////////////////
+ // run
+ ////////////////////////////////////////////////
+
+ private Thread timerThread = null;
+
+ public void run()
+ {
+ Thread thisThread = Thread.currentThread();
+
+ while (timerThread == thisThread) {
+ getClockDevice().update();
+ getClockPanel().repaint();
+ try {
+ Thread.sleep(1000);
+ }
+ catch(InterruptedException e) {}
+ }
+ }
+
+ public void start()
+ {
+ clockDev.start();
+
+ timerThread = new Thread(this,"upnp.sample.clock.ClockFrame");
+ timerThread.start();
+ }
+
+ public void stop()
+ {
+ clockDev.stop();
+ timerThread = null;
+ dispose();
+ }
+
+}
+
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockIcon.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockIcon.java
index f97d539..764ed1e 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockIcon.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockIcon.java
@@ -1,69 +1,69 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.osgi.service.upnp.UPnPIcon;
-
-public class ClockIcon implements UPnPIcon {
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getMimeType()
- */
- public String getMimeType() {
- return "image/gif";
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getWidth()
- */
- public int getWidth() {
- return 32;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getHeight()
- */
- public int getHeight() {
- return 32;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getSize()
- */
- public int getSize() {
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getDepth()
- */
- public int getDepth() {
- return 16;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getInputStream()
- */
- public InputStream getInputStream() throws IOException {
- return ClockIcon.class.getResourceAsStream("images/clock.gif");
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.osgi.service.upnp.UPnPIcon;
+
+public class ClockIcon implements UPnPIcon {
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getMimeType()
+ */
+ public String getMimeType() {
+ return "image/gif";
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getWidth()
+ */
+ public int getWidth() {
+ return 32;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getHeight()
+ */
+ public int getHeight() {
+ return 32;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getSize()
+ */
+ public int getSize() {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getDepth()
+ */
+ public int getDepth() {
+ return 16;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getInputStream()
+ */
+ public InputStream getInputStream() throws IOException {
+ return ClockIcon.class.getResourceAsStream("images/clock.gif");
+ }
+}
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockPane.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockPane.java
index 9cc5c0c..25b931e 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockPane.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockPane.java
@@ -1,212 +1,212 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-
-import javax.imageio.ImageIO;
-import javax.swing.JPanel;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class ClockPane extends JPanel // MouseListener
-{
- public ClockPane()
- {
- loadImage();
- initPanel();
- }
-
- ////////////////////////////////////////////////
- // Background
- ////////////////////////////////////////////////
-
-
- private BufferedImage panelmage;
-
- private void loadImage()
- {
-
- try {
- panelmage = ImageIO.read(ClockPane.class.getResourceAsStream("images/clock.jpg"));
- }
- catch (Exception e) {
- System.out.println(e);
- }
- }
-
- private BufferedImage getPaneImage()
- {
- return panelmage;
- }
-
- ////////////////////////////////////////////////
- // Background
- ////////////////////////////////////////////////
-
- private void initPanel()
- {
- BufferedImage panelmage = getPaneImage();
- setPreferredSize(new Dimension(panelmage.getWidth(), panelmage.getHeight()));
- }
-
- ////////////////////////////////////////////////
- // Font
- ////////////////////////////////////////////////
-
- private final static String DEFAULT_FONT_NAME = "Lucida Console";
- private final static int DEFAULT_TIME_FONT_SIZE = 60;
- private final static int DEFAULT_DATE_FONT_SIZE = 18;
- private final static int DEFAULT_SECOND_BLOCK_HEIGHT = 8;
- private final static int DEFAULT_SECOND_BLOCK_FONT_SIZE = 10;
-
- private Font timeFont = null;
- private Font dateFont = null;
- private Font secondFont = null;
-
- private Font getFont(Graphics g, int size)
- {
- Font font = new Font(DEFAULT_FONT_NAME, Font.PLAIN, size);
- if (font != null)
- return font;
- return g.getFont();
- }
-
- private Font getTimeFont(Graphics g)
- {
- if (timeFont == null)
- timeFont = getFont(g, DEFAULT_TIME_FONT_SIZE);
- return timeFont;
- }
-
- private Font getDateFont(Graphics g)
- {
- if (dateFont == null)
- dateFont = getFont(g, DEFAULT_DATE_FONT_SIZE);
- return dateFont;
- }
-
- private Font getSecondFont(Graphics g)
- {
- if (secondFont == null)
- secondFont = getFont(g, DEFAULT_SECOND_BLOCK_FONT_SIZE);
- return secondFont;
- }
-
- ////////////////////////////////////////////////
- // paint
- ////////////////////////////////////////////////
-
- private void drawClockInfo(Graphics g)
- {
- Clock clock = Clock.getInstance();
-
- int winWidth = getWidth();
- int winHeight = getHeight();
-
- g.setColor(Color.BLACK);
-
- //// Time String ////
-
- String timeStr = clock.getTimeString();
-
- Font timeFont = getTimeFont(g);
- g.setFont(timeFont);
-
- FontMetrics timeFontMetric = g.getFontMetrics();
- Rectangle2D timeStrBounds = timeFontMetric.getStringBounds(timeStr, g);
-
- int timeStrWidth = (int)timeStrBounds.getWidth();
- int timeStrHeight = (int)timeStrBounds.getHeight();
- int timeStrX = (winWidth-timeStrWidth)/2;
- int timeStrY = (winHeight+timeStrHeight)/2;
- int timeStrOffset = timeStrHeight/8/2;
- g.drawString(
- timeStr,
- timeStrX,
- timeStrY);
-
- //// Date String ////
-
- String dateStr = clock.getDateString();
-
- Font dateFont = getDateFont(g);
- g.setFont(dateFont);
-
- FontMetrics dateFontMetric = g.getFontMetrics();
- Rectangle2D dateStrBounds = dateFontMetric.getStringBounds(dateStr, g);
-
- g.drawString(
- dateStr,
- (winWidth-(int)dateStrBounds.getWidth())/2,
- timeStrY-timeStrHeight-timeStrOffset);
-
- //// Second Bar ////
-
- Font secFont = getSecondFont(g);
- g.setFont(secFont);
- int sec = clock.getSecond();
- int secBarBlockSize = timeStrWidth / 60;
- int secBarBlockY = timeStrY + timeStrOffset;
- for (int n=0; n<sec; n++) {
- int x = timeStrX + (secBarBlockSize*n);
- g.fillRect(
- x,
- secBarBlockY,
- secBarBlockSize-1,
- DEFAULT_SECOND_BLOCK_HEIGHT);
- }
- if (sec != 0 && (sec % 10) == 0) {
- int x = timeStrX + (secBarBlockSize*sec);
- g.drawString(
- Integer.toString(sec),
- x + secBarBlockSize,
- secBarBlockY + DEFAULT_SECOND_BLOCK_HEIGHT);
- }
- }
-
- private void clear(Graphics g)
- {
- g.setColor(Color.GRAY);
- g.clearRect(0, 0, getWidth(), getHeight());
- }
-
-
- private void drawPanelImage(Graphics g)
- {
- g.drawImage(getPaneImage(), 0, 0, null);
- }
-
- public void paint(Graphics g)
- {
- clear(g);
- drawPanelImage(g);
- drawClockInfo(g);
- }
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+
+import javax.imageio.ImageIO;
+import javax.swing.JPanel;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class ClockPane extends JPanel // MouseListener
+{
+ public ClockPane()
+ {
+ loadImage();
+ initPanel();
+ }
+
+ ////////////////////////////////////////////////
+ // Background
+ ////////////////////////////////////////////////
+
+
+ private BufferedImage panelmage;
+
+ private void loadImage()
+ {
+
+ try {
+ panelmage = ImageIO.read(ClockPane.class.getResourceAsStream("images/clock.jpg"));
+ }
+ catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+
+ private BufferedImage getPaneImage()
+ {
+ return panelmage;
+ }
+
+ ////////////////////////////////////////////////
+ // Background
+ ////////////////////////////////////////////////
+
+ private void initPanel()
+ {
+ BufferedImage panelmage = getPaneImage();
+ setPreferredSize(new Dimension(panelmage.getWidth(), panelmage.getHeight()));
+ }
+
+ ////////////////////////////////////////////////
+ // Font
+ ////////////////////////////////////////////////
+
+ private final static String DEFAULT_FONT_NAME = "Lucida Console";
+ private final static int DEFAULT_TIME_FONT_SIZE = 60;
+ private final static int DEFAULT_DATE_FONT_SIZE = 18;
+ private final static int DEFAULT_SECOND_BLOCK_HEIGHT = 8;
+ private final static int DEFAULT_SECOND_BLOCK_FONT_SIZE = 10;
+
+ private Font timeFont = null;
+ private Font dateFont = null;
+ private Font secondFont = null;
+
+ private Font getFont(Graphics g, int size)
+ {
+ Font font = new Font(DEFAULT_FONT_NAME, Font.PLAIN, size);
+ if (font != null)
+ return font;
+ return g.getFont();
+ }
+
+ private Font getTimeFont(Graphics g)
+ {
+ if (timeFont == null)
+ timeFont = getFont(g, DEFAULT_TIME_FONT_SIZE);
+ return timeFont;
+ }
+
+ private Font getDateFont(Graphics g)
+ {
+ if (dateFont == null)
+ dateFont = getFont(g, DEFAULT_DATE_FONT_SIZE);
+ return dateFont;
+ }
+
+ private Font getSecondFont(Graphics g)
+ {
+ if (secondFont == null)
+ secondFont = getFont(g, DEFAULT_SECOND_BLOCK_FONT_SIZE);
+ return secondFont;
+ }
+
+ ////////////////////////////////////////////////
+ // paint
+ ////////////////////////////////////////////////
+
+ private void drawClockInfo(Graphics g)
+ {
+ Clock clock = Clock.getInstance();
+
+ int winWidth = getWidth();
+ int winHeight = getHeight();
+
+ g.setColor(Color.BLACK);
+
+ //// Time String ////
+
+ String timeStr = clock.getTimeString();
+
+ Font timeFont = getTimeFont(g);
+ g.setFont(timeFont);
+
+ FontMetrics timeFontMetric = g.getFontMetrics();
+ Rectangle2D timeStrBounds = timeFontMetric.getStringBounds(timeStr, g);
+
+ int timeStrWidth = (int)timeStrBounds.getWidth();
+ int timeStrHeight = (int)timeStrBounds.getHeight();
+ int timeStrX = (winWidth-timeStrWidth)/2;
+ int timeStrY = (winHeight+timeStrHeight)/2;
+ int timeStrOffset = timeStrHeight/8/2;
+ g.drawString(
+ timeStr,
+ timeStrX,
+ timeStrY);
+
+ //// Date String ////
+
+ String dateStr = clock.getDateString();
+
+ Font dateFont = getDateFont(g);
+ g.setFont(dateFont);
+
+ FontMetrics dateFontMetric = g.getFontMetrics();
+ Rectangle2D dateStrBounds = dateFontMetric.getStringBounds(dateStr, g);
+
+ g.drawString(
+ dateStr,
+ (winWidth-(int)dateStrBounds.getWidth())/2,
+ timeStrY-timeStrHeight-timeStrOffset);
+
+ //// Second Bar ////
+
+ Font secFont = getSecondFont(g);
+ g.setFont(secFont);
+ int sec = clock.getSecond();
+ int secBarBlockSize = timeStrWidth / 60;
+ int secBarBlockY = timeStrY + timeStrOffset;
+ for (int n=0; n<sec; n++) {
+ int x = timeStrX + (secBarBlockSize*n);
+ g.fillRect(
+ x,
+ secBarBlockY,
+ secBarBlockSize-1,
+ DEFAULT_SECOND_BLOCK_HEIGHT);
+ }
+ if (sec != 0 && (sec % 10) == 0) {
+ int x = timeStrX + (secBarBlockSize*sec);
+ g.drawString(
+ Integer.toString(sec),
+ x + secBarBlockSize,
+ secBarBlockY + DEFAULT_SECOND_BLOCK_HEIGHT);
+ }
+ }
+
+ private void clear(Graphics g)
+ {
+ g.setColor(Color.GRAY);
+ g.clearRect(0, 0, getWidth(), getHeight());
+ }
+
+
+ private void drawPanelImage(Graphics g)
+ {
+ g.drawImage(getPaneImage(), 0, 0, null);
+ }
+
+ public void paint(Graphics g)
+ {
+ clear(g);
+ drawPanelImage(g);
+ drawClockInfo(g);
+ }
+}
+
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/GetTimeAction.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/GetTimeAction.java
index f2f4abb..db32b79 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/GetTimeAction.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/GetTimeAction.java
@@ -1,89 +1,89 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class GetTimeAction implements UPnPAction {
-
- final private String NAME = "GetTime";
- final private String RESULT_STATUS = "CurrentTime";
- final private String[] OUT_ARG_NAMES = new String[]{RESULT_STATUS};
- private TimeStateVariable time;
-
-
- public GetTimeAction(TimeStateVariable time){
- this.time = time;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
- */
- public String getReturnArgumentName() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
- */
- public String[] getInputArgumentNames() {
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
- */
- public String[] getOutputArgumentNames() {
- return OUT_ARG_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String argumentName) {
- return time;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
- */
- public Dictionary invoke(Dictionary args) throws Exception {
- String value = time.getCurrentTime();
- Hashtable result = new Hashtable();
- result.put(RESULT_STATUS,value);
- return result;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class GetTimeAction implements UPnPAction {
+
+ final private String NAME = "GetTime";
+ final private String RESULT_STATUS = "CurrentTime";
+ final private String[] OUT_ARG_NAMES = new String[]{RESULT_STATUS};
+ private TimeStateVariable time;
+
+
+ public GetTimeAction(TimeStateVariable time){
+ this.time = time;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
+ */
+ public String getReturnArgumentName() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
+ */
+ public String[] getInputArgumentNames() {
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
+ */
+ public String[] getOutputArgumentNames() {
+ return OUT_ARG_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String argumentName) {
+ return time;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
+ */
+ public Dictionary invoke(Dictionary args) throws Exception {
+ String value = time.getCurrentTime();
+ Hashtable result = new Hashtable();
+ result.put(RESULT_STATUS,value);
+ return result;
+ }
+}
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ResultStateVariable.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ResultStateVariable.java
index 2fd6795..3c936db 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ResultStateVariable.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/ResultStateVariable.java
@@ -1,96 +1,96 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-public class ResultStateVariable implements UPnPStateVariable{
-
- final private String NAME = "Result";
- final private String DEFAULT_VALUE = "";
- private Clock clock;
-
-
- public ResultStateVariable(){
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
- */
- public Class getJavaDataType() {
- return String.class;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
- */
- public String getUPnPDataType() {
- return TYPE_STRING;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
- */
- public Object getDefaultValue() {
- return DEFAULT_VALUE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
- */
- public String[] getAllowedValues() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
- */
- public Number getMinimum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
- */
- public Number getMaximum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
- */
- public Number getStep() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
- */
- public boolean sendsEvents() {
- return false;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+public class ResultStateVariable implements UPnPStateVariable{
+
+ final private String NAME = "Result";
+ final private String DEFAULT_VALUE = "";
+ private Clock clock;
+
+
+ public ResultStateVariable(){
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
+ */
+ public Class getJavaDataType() {
+ return String.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
+ */
+ public String getUPnPDataType() {
+ return TYPE_STRING;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return DEFAULT_VALUE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
+ */
+ public String[] getAllowedValues() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
+ */
+ public Number getMinimum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
+ */
+ public Number getMaximum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
+ */
+ public Number getStep() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
+ */
+ public boolean sendsEvents() {
+ return false;
+ }
+
+}
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/SetTimeAction.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/SetTimeAction.java
index 752028e..69183eb 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/SetTimeAction.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/SetTimeAction.java
@@ -1,97 +1,97 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-
-import java.beans.PropertyChangeEvent;
-import java.util.Dictionary;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class SetTimeAction implements UPnPAction {
-
- final private String NAME = "SetTime";
- final private String NEW_TIME_VALUE = "NewTime";
- final private String NEW_RESULT_VALUE = "Result";
- final private String[] IN_ARG_NAMES = new String[]{NEW_TIME_VALUE};
- final private String[] OUT_ARG_NAMES = new String[]{NEW_RESULT_VALUE};
- private UPnPStateVariable time,result;
-
-
- public SetTimeAction(UPnPStateVariable time,UPnPStateVariable result){
- this.time = time;
- this.result=result;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
- */
- public String getReturnArgumentName() {
- return "Result";
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
- */
- public String[] getInputArgumentNames() {
- return IN_ARG_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
- */
- public String[] getOutputArgumentNames() {
- return OUT_ARG_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String argumentName) {
- if (argumentName.equals("NewTime")) return time;
- else if (argumentName.equals("Result")) return result;
- else return null;
- }
-
- /* (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
- */
- public Dictionary invoke(Dictionary args) throws Exception {
- Long newValue = (Long) args.get(NEW_TIME_VALUE);
- Long oldValue = (Long) ((TimeStateVariable) time).getCurrentValue();
- ((TimeStateVariable) time).setCurrentTime(newValue.longValue());
- ClockDevice.notifier.propertyChange(new PropertyChangeEvent(time,"Time",oldValue,newValue));
- args.remove(NEW_TIME_VALUE);
- args.put(NEW_RESULT_VALUE,((TimeStateVariable) time).getCurrentTime());
- return args;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+
+import java.beans.PropertyChangeEvent;
+import java.util.Dictionary;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class SetTimeAction implements UPnPAction {
+
+ final private String NAME = "SetTime";
+ final private String NEW_TIME_VALUE = "NewTime";
+ final private String NEW_RESULT_VALUE = "Result";
+ final private String[] IN_ARG_NAMES = new String[]{NEW_TIME_VALUE};
+ final private String[] OUT_ARG_NAMES = new String[]{NEW_RESULT_VALUE};
+ private UPnPStateVariable time,result;
+
+
+ public SetTimeAction(UPnPStateVariable time,UPnPStateVariable result){
+ this.time = time;
+ this.result=result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
+ */
+ public String getReturnArgumentName() {
+ return "Result";
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
+ */
+ public String[] getInputArgumentNames() {
+ return IN_ARG_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
+ */
+ public String[] getOutputArgumentNames() {
+ return OUT_ARG_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String argumentName) {
+ if (argumentName.equals("NewTime")) return time;
+ else if (argumentName.equals("Result")) return result;
+ else return null;
+ }
+
+ /* (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
+ */
+ public Dictionary invoke(Dictionary args) throws Exception {
+ Long newValue = (Long) args.get(NEW_TIME_VALUE);
+ Long oldValue = (Long) ((TimeStateVariable) time).getCurrentValue();
+ ((TimeStateVariable) time).setCurrentTime(newValue.longValue());
+ ClockDevice.notifier.propertyChange(new PropertyChangeEvent(time,"Time",oldValue,newValue));
+ args.remove(NEW_TIME_VALUE);
+ args.put(NEW_RESULT_VALUE,((TimeStateVariable) time).getCurrentTime());
+ return args;
+ }
+}
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java
index 6985f0f..3a49517 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java
@@ -1,110 +1,110 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-import java.util.Date;
-
-import org.osgi.service.upnp.UPnPLocalStateVariable;
-
-public class TimeStateVariable implements UPnPLocalStateVariable{
-
- final private String NAME = "Time";
- final private String DEFAULT_VALUE = "";
- private Clock clock;
-
-
- public TimeStateVariable(){
- clock = Clock.getInstance();
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
- */
- public Class getJavaDataType() {
- return Long.class;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
- */
- public String getUPnPDataType() {
- return TYPE_TIME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
- */
- public Object getDefaultValue() {
- return DEFAULT_VALUE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
- */
- public String[] getAllowedValues() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
- */
- public Number getMinimum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
- */
- public Number getMaximum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
- */
- public Number getStep() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
- */
- public boolean sendsEvents() {
- return true;
- }
-
- public String getCurrentTime(){
- return clock.getTimeString();
- }
-
- public void setCurrentTime(long milliseconds){
- clock.getCalendar().setTime(new Date(milliseconds));
- }
-
- public Object getCurrentValue() {
- return new Long(clock.getCalendar().getTime().getTime());
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+import java.util.Date;
+
+import org.osgi.service.upnp.UPnPLocalStateVariable;
+
+public class TimeStateVariable implements UPnPLocalStateVariable{
+
+ final private String NAME = "Time";
+ final private String DEFAULT_VALUE = "";
+ private Clock clock;
+
+
+ public TimeStateVariable(){
+ clock = Clock.getInstance();
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
+ */
+ public Class getJavaDataType() {
+ return Long.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
+ */
+ public String getUPnPDataType() {
+ return TYPE_TIME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return DEFAULT_VALUE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
+ */
+ public String[] getAllowedValues() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
+ */
+ public Number getMinimum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
+ */
+ public Number getMaximum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
+ */
+ public Number getStep() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
+ */
+ public boolean sendsEvents() {
+ return true;
+ }
+
+ public String getCurrentTime(){
+ return clock.getTimeString();
+ }
+
+ public void setCurrentTime(long milliseconds){
+ clock.getCalendar().setTime(new Date(milliseconds));
+ }
+
+ public Object getCurrentValue() {
+ return new Long(clock.getCalendar().getTime().getTime());
+ }
+}
diff --git a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimerService.java b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimerService.java
index 76edcaa..ef92ead 100644
--- a/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimerService.java
+++ b/upnp/samples/clock/src/main/java/org/apache/felix/upnp/sample/clock/TimerService.java
@@ -1,106 +1,106 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.clock;
-
-import java.util.HashMap;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class TimerService implements UPnPService {
- final private String SERVICE_ID = "urn:schemas-upnp-org:serviceId:timer:1";
- final private String SERVICE_TYPE = "urn:schemas-upnp-org:service:timer:1";
- final private String VERSION ="1";
-
- private UPnPStateVariable time,result;
- private UPnPStateVariable[] states;
- private HashMap actions = new HashMap();
-
-
- public TimerService(){
- time = new TimeStateVariable();
- result = new ResultStateVariable();
- this.states = new UPnPStateVariable[]{time,result};
-
- UPnPAction setTime= new SetTimeAction(time,result);
- UPnPAction getTime = new GetTimeAction((TimeStateVariable)time);
- actions.put(setTime.getName(),setTime);
- actions.put(getTime.getName(),getTime);
-
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getId()
- */
- public String getId() {
- return SERVICE_ID;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getType()
- */
- public String getType() {
- return SERVICE_TYPE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getVersion()
- */
- public String getVersion() {
- return VERSION;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getAction(java.lang.String)
- */
- public UPnPAction getAction(String name) {
- return (UPnPAction)actions.get(name);
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getActions()
- */
- public UPnPAction[] getActions() {
- return (UPnPAction[])(actions.values()).toArray(new UPnPAction[]{});
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getStateVariables()
- */
- public UPnPStateVariable[] getStateVariables() {
- return states;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String name) {
- if (name.equals("Time"))
- return time;
- else if (name.equals("Result"))
- return result;
- else return null;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.clock;
+
+import java.util.HashMap;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class TimerService implements UPnPService {
+ final private String SERVICE_ID = "urn:schemas-upnp-org:serviceId:timer:1";
+ final private String SERVICE_TYPE = "urn:schemas-upnp-org:service:timer:1";
+ final private String VERSION ="1";
+
+ private UPnPStateVariable time,result;
+ private UPnPStateVariable[] states;
+ private HashMap actions = new HashMap();
+
+
+ public TimerService(){
+ time = new TimeStateVariable();
+ result = new ResultStateVariable();
+ this.states = new UPnPStateVariable[]{time,result};
+
+ UPnPAction setTime= new SetTimeAction(time,result);
+ UPnPAction getTime = new GetTimeAction((TimeStateVariable)time);
+ actions.put(setTime.getName(),setTime);
+ actions.put(getTime.getName(),getTime);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getId()
+ */
+ public String getId() {
+ return SERVICE_ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getType()
+ */
+ public String getType() {
+ return SERVICE_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getVersion()
+ */
+ public String getVersion() {
+ return VERSION;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getAction(java.lang.String)
+ */
+ public UPnPAction getAction(String name) {
+ return (UPnPAction)actions.get(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getActions()
+ */
+ public UPnPAction[] getActions() {
+ return (UPnPAction[])(actions.values()).toArray(new UPnPAction[]{});
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getStateVariables()
+ */
+ public UPnPStateVariable[] getStateVariables() {
+ return states;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String name) {
+ if (name.equals("Time"))
+ return time;
+ else if (name.equals("Result"))
+ return result;
+ else return null;
+ }
+}
diff --git a/upnp/samples/pom.xml b/upnp/samples/pom.xml
index 05aa0f6..c54df7b 100644
--- a/upnp/samples/pom.xml
+++ b/upnp/samples/pom.xml
@@ -16,46 +16,46 @@
specific language governing permissions and limitations
under the License.
-->
-<project>
- <parent>
- <groupId>org.apache.felix</groupId>
- <artifactId>felix</artifactId>
- <version>1.0.2</version>
- <relativePath>../../pom/pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <name>Apache Felix UPnP Examples: Build</name>
- <artifactId>upnp.examples.build</artifactId>
- <version>0.9.0-SNAPSHOT</version>
-
- <profiles>
- <profile>
- <id>packaging-bundle</id>
- <activation>
- <property>
- <name>packaging</name>
- <value>bundle</value>
- </property>
- </activation>
- <modules>
- <module>binarylight</module>
- <module>clock</module>
- <module>tv</module>
- </modules>
- </profile>
- <profile>
- <id>default</id>
- <activation>
- <property>
- <name>!packaging</name>
- </property>
- </activation>
- <modules>
- <module>binarylight</module>
- <module>clock</module>
- <module>tv</module>
- </modules>
- </profile>
- </profiles>
-</project>
+<project>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>felix</artifactId>
+ <version>1.0.2</version>
+ <relativePath>../../pom/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
+ <name>Apache Felix UPnP Examples: Build</name>
+ <artifactId>upnp.examples.build</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+
+ <profiles>
+ <profile>
+ <id>packaging-bundle</id>
+ <activation>
+ <property>
+ <name>packaging</name>
+ <value>bundle</value>
+ </property>
+ </activation>
+ <modules>
+ <module>binarylight</module>
+ <module>clock</module>
+ <module>tv</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>default</id>
+ <activation>
+ <property>
+ <name>!packaging</name>
+ </property>
+ </activation>
+ <modules>
+ <module>binarylight</module>
+ <module>clock</module>
+ <module>tv</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/upnp/samples/tv/pom.xml b/upnp/samples/tv/pom.xml
index 8e546c9..2386e4f 100644
--- a/upnp/samples/tv/pom.xml
+++ b/upnp/samples/tv/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -17,60 +17,60 @@
specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>felix</artifactId>
- <groupId>org.apache.felix</groupId>
- <version>1.0.2</version>
- <relativePath>../../../pom/pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.upnp.sample.tv</artifactId>
- <packaging>bundle</packaging>
- <name>Apache Felix UPnP Sample TV</name>
- <version>0.2.0-SNAPSHOT</version>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>felix</artifactId>
+ <groupId>org.apache.felix</groupId>
+ <version>1.0.2</version>
+ <relativePath>../../../pom/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.upnp.sample.tv</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Felix UPnP Sample TV</name>
+ <version>0.2.0-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>${pom.name}</Bundle-Name>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
- <Bundle-Author>Matteo Demuru <demuru@apache.org>,Francesco Furfari <furfari@apache.org>,Stefano "Kismet" Lenzi <lenzi@apache.org></Bundle-Author>
- <Bundle-Description>CyberLink Tv clone to test UPnPBase driver</Bundle-Description>
- <Bundle-SymbolicName>org.apache.felix.upnp.sample.tv</Bundle-SymbolicName>
- <Bundle-Activator>org.apache.felix.upnp.sample.tv.Activator</Bundle-Activator>
- <Private-Package>org.apache.felix.upnp.sample.tv.*</Private-Package>
- <Import-Package>*</Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.compendium</artifactId>
+ <Bundle-Author>Matteo Demuru <demuru@apache.org>,Francesco Furfari <furfari@apache.org>,Stefano "Kismet" Lenzi <lenzi@apache.org></Bundle-Author>
+ <Bundle-Description>CyberLink Tv clone to test UPnPBase driver</Bundle-Description>
+ <Bundle-SymbolicName>org.apache.felix.upnp.sample.tv</Bundle-SymbolicName>
+ <Bundle-Activator>org.apache.felix.upnp.sample.tv.Activator</Bundle-Activator>
+ <Private-Package>org.apache.felix.upnp.sample.tv.*</Private-Package>
+ <Import-Package>*</Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
<version>1.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.upnp.extra</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-</project>
-
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.upnp.extra</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
+
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/GetPowerAction.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/GetPowerAction.java
index 3c786df..5106e1d 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/GetPowerAction.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/GetPowerAction.java
@@ -1,85 +1,85 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-public class GetPowerAction implements UPnPAction {
-
- final private String NAME = "GetPower";
- final private String RESULT_STATUS = "Power";
- final private String[] OUT_ARG_NAMES = new String[]{RESULT_STATUS};
- private PowerStateVariable power;
-
-
- public GetPowerAction(PowerStateVariable power){
- this.power = power;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
- */
- public String getReturnArgumentName() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
- */
- public String[] getInputArgumentNames() {
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
- */
- public String[] getOutputArgumentNames() {
- return OUT_ARG_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String argumentName) {
- return power;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
- */
- public Dictionary invoke(Dictionary args) throws Exception {
- Boolean value = power.getCurrentPower();
- Hashtable result = new Hashtable();
- result.put(RESULT_STATUS,value);
- return result;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+public class GetPowerAction implements UPnPAction {
+
+ final private String NAME = "GetPower";
+ final private String RESULT_STATUS = "Power";
+ final private String[] OUT_ARG_NAMES = new String[]{RESULT_STATUS};
+ private PowerStateVariable power;
+
+
+ public GetPowerAction(PowerStateVariable power){
+ this.power = power;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
+ */
+ public String getReturnArgumentName() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
+ */
+ public String[] getInputArgumentNames() {
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
+ */
+ public String[] getOutputArgumentNames() {
+ return OUT_ARG_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String argumentName) {
+ return power;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
+ */
+ public Dictionary invoke(Dictionary args) throws Exception {
+ Boolean value = power.getCurrentPower();
+ Hashtable result = new Hashtable();
+ result.put(RESULT_STATUS,value);
+ return result;
+ }
+}
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/PowerService.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/PowerService.java
index 347d9fc..2352dde 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/PowerService.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/PowerService.java
@@ -1,103 +1,103 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-
-import java.util.HashMap;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-public class PowerService implements UPnPService {
- final private String SERVICE_ID = "urn:schemas-upnp-org:serviceId:power:1";
- final private String SERVICE_TYPE = "urn:schemas-upnp-org:service:power:1";
- final private String VERSION ="1";
-
- private PowerStateVariable power;
- private ResultStateVariable result;
- private UPnPStateVariable[] states;
- private HashMap actions = new HashMap();
-
-
- public PowerService(){
- power = new PowerStateVariable();
- result = new ResultStateVariable();
- this.states = new UPnPStateVariable[]{power,result};
-
- UPnPAction setPower= new SetPowerAction(power,result);
- UPnPAction getPower = new GetPowerAction(power);
- actions.put(setPower.getName(),setPower);
- actions.put(getPower.getName(),getPower);
-
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getId()
- */
- public String getId() {
- return SERVICE_ID;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getType()
- */
- public String getType() {
- return SERVICE_TYPE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getVersion()
- */
- public String getVersion() {
- return VERSION;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getAction(java.lang.String)
- */
- public UPnPAction getAction(String name) {
- return (UPnPAction)actions.get(name);
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getActions()
- */
- public UPnPAction[] getActions() {
- return (UPnPAction[])(actions.values()).toArray(new UPnPAction[]{});
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getStateVariables()
- */
- public UPnPStateVariable[] getStateVariables() {
- return states;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPService#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String name) {
- if (name.equals("Power"))
- return power;
- else if (name.equals("Result"))
- return result;
- else return null;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+
+import java.util.HashMap;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+public class PowerService implements UPnPService {
+ final private String SERVICE_ID = "urn:schemas-upnp-org:serviceId:power:1";
+ final private String SERVICE_TYPE = "urn:schemas-upnp-org:service:power:1";
+ final private String VERSION ="1";
+
+ private PowerStateVariable power;
+ private ResultStateVariable result;
+ private UPnPStateVariable[] states;
+ private HashMap actions = new HashMap();
+
+
+ public PowerService(){
+ power = new PowerStateVariable();
+ result = new ResultStateVariable();
+ this.states = new UPnPStateVariable[]{power,result};
+
+ UPnPAction setPower= new SetPowerAction(power,result);
+ UPnPAction getPower = new GetPowerAction(power);
+ actions.put(setPower.getName(),setPower);
+ actions.put(getPower.getName(),getPower);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getId()
+ */
+ public String getId() {
+ return SERVICE_ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getType()
+ */
+ public String getType() {
+ return SERVICE_TYPE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getVersion()
+ */
+ public String getVersion() {
+ return VERSION;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getAction(java.lang.String)
+ */
+ public UPnPAction getAction(String name) {
+ return (UPnPAction)actions.get(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getActions()
+ */
+ public UPnPAction[] getActions() {
+ return (UPnPAction[])(actions.values()).toArray(new UPnPAction[]{});
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getStateVariables()
+ */
+ public UPnPStateVariable[] getStateVariables() {
+ return states;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPService#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String name) {
+ if (name.equals("Power"))
+ return power;
+ else if (name.equals("Result"))
+ return result;
+ else return null;
+ }
+}
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/PowerStateVariable.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/PowerStateVariable.java
index ef66bc0..1507bb8 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/PowerStateVariable.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/PowerStateVariable.java
@@ -1,120 +1,120 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-import java.beans.PropertyChangeEvent;
-
-import org.osgi.service.upnp.UPnPLocalStateVariable;
-
-import org.apache.felix.upnp.extra.util.UPnPEventNotifier;
-
-public class PowerStateVariable implements UPnPLocalStateVariable {
-
- final private String NAME = "Power";
- final private Boolean DEFAULT_VALUE = Boolean.FALSE;
- private UPnPEventNotifier notifier;
- private Boolean power = Boolean.FALSE;
-
- public PowerStateVariable(){
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
- */
- public Class getJavaDataType() {
- return Boolean.class;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
- */
- public String getUPnPDataType() {
- return TYPE_BOOLEAN;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
- */
- public Object getDefaultValue() {
- return DEFAULT_VALUE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
- */
- public String[] getAllowedValues() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
- */
- public Number getMinimum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
- */
- public Number getMaximum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
- */
- public Number getStep() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
- */
- public boolean sendsEvents() {
- return true;
- }
-
- public Boolean getCurrentPower(){
- return power;
- }
-
- public void setPower(Boolean value){
- if (!value.equals(power)) {
- Boolean oldValue = power;
- power = value;
- if (notifier != null)
- notifier.propertyChange(new PropertyChangeEvent(this,"Power",oldValue,value));
- }
- }
-
- public void setNotifier(UPnPEventNotifier notifier){
- this.notifier = notifier;
- }
-
- public Object getCurrentValue() {
- return power;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+import java.beans.PropertyChangeEvent;
+
+import org.osgi.service.upnp.UPnPLocalStateVariable;
+
+import org.apache.felix.upnp.extra.util.UPnPEventNotifier;
+
+public class PowerStateVariable implements UPnPLocalStateVariable {
+
+ final private String NAME = "Power";
+ final private Boolean DEFAULT_VALUE = Boolean.FALSE;
+ private UPnPEventNotifier notifier;
+ private Boolean power = Boolean.FALSE;
+
+ public PowerStateVariable(){
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
+ */
+ public Class getJavaDataType() {
+ return Boolean.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
+ */
+ public String getUPnPDataType() {
+ return TYPE_BOOLEAN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return DEFAULT_VALUE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
+ */
+ public String[] getAllowedValues() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
+ */
+ public Number getMinimum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
+ */
+ public Number getMaximum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
+ */
+ public Number getStep() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
+ */
+ public boolean sendsEvents() {
+ return true;
+ }
+
+ public Boolean getCurrentPower(){
+ return power;
+ }
+
+ public void setPower(Boolean value){
+ if (!value.equals(power)) {
+ Boolean oldValue = power;
+ power = value;
+ if (notifier != null)
+ notifier.propertyChange(new PropertyChangeEvent(this,"Power",oldValue,value));
+ }
+ }
+
+ public void setNotifier(UPnPEventNotifier notifier){
+ this.notifier = notifier;
+ }
+
+ public Object getCurrentValue() {
+ return power;
+ }
+}
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/ResultStateVariable.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/ResultStateVariable.java
index a50ef03..b64ac28 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/ResultStateVariable.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/ResultStateVariable.java
@@ -1,95 +1,95 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-public class ResultStateVariable implements UPnPStateVariable{
-
- final private String NAME = "Result";
- final private Boolean DEFAULT_VALUE = Boolean.FALSE;
-
-
- public ResultStateVariable(){
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
- */
- public Class getJavaDataType() {
- return Boolean.class;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
- */
- public String getUPnPDataType() {
- return TYPE_BOOLEAN;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
- */
- public Object getDefaultValue() {
- return DEFAULT_VALUE;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
- */
- public String[] getAllowedValues() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
- */
- public Number getMinimum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
- */
- public Number getMaximum() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
- */
- public Number getStep() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
- */
- public boolean sendsEvents() {
- return false;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+public class ResultStateVariable implements UPnPStateVariable{
+
+ final private String NAME = "Result";
+ final private Boolean DEFAULT_VALUE = Boolean.FALSE;
+
+
+ public ResultStateVariable(){
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
+ */
+ public Class getJavaDataType() {
+ return Boolean.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
+ */
+ public String getUPnPDataType() {
+ return TYPE_BOOLEAN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return DEFAULT_VALUE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
+ */
+ public String[] getAllowedValues() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
+ */
+ public Number getMinimum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
+ */
+ public Number getMaximum() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
+ */
+ public Number getStep() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
+ */
+ public boolean sendsEvents() {
+ return false;
+ }
+
+}
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/SetPowerAction.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/SetPowerAction.java
index 30d67ff..909bdc8 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/SetPowerAction.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/SetPowerAction.java
@@ -1,91 +1,91 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-public class SetPowerAction implements UPnPAction {
-
- final private String NAME = "SetPower";
- final private String NEW_TIME_VALUE = "Power";
- final private String NEW_RESULT_VALUE = "Result";
- final private String[] IN_ARG_NAMES = new String[]{NEW_TIME_VALUE};
- final private String[] OUT_ARG_NAMES = new String[]{NEW_RESULT_VALUE};
- private PowerStateVariable power;
- private ResultStateVariable result;
-
-
- public SetPowerAction(PowerStateVariable power,ResultStateVariable result){
- this.power = power;
- this.result=result;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getName()
- */
- public String getName() {
- return NAME;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
- */
- public String getReturnArgumentName() {
- return "Result";
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
- */
- public String[] getInputArgumentNames() {
- return IN_ARG_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
- */
- public String[] getOutputArgumentNames() {
- return OUT_ARG_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String argumentName) {
- if (argumentName.equals("Power")) return power;
- else if (argumentName.equals("Result")) return result;
- else return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
- */
- public Dictionary invoke(Dictionary args) throws Exception {
- Boolean value = (Boolean) args.get(NEW_TIME_VALUE);
- power.setPower(value);
- Hashtable result = new Hashtable();
- result.put(NEW_RESULT_VALUE,Boolean.TRUE);
- return result;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+public class SetPowerAction implements UPnPAction {
+
+ final private String NAME = "SetPower";
+ final private String NEW_TIME_VALUE = "Power";
+ final private String NEW_RESULT_VALUE = "Result";
+ final private String[] IN_ARG_NAMES = new String[]{NEW_TIME_VALUE};
+ final private String[] OUT_ARG_NAMES = new String[]{NEW_RESULT_VALUE};
+ private PowerStateVariable power;
+ private ResultStateVariable result;
+
+
+ public SetPowerAction(PowerStateVariable power,ResultStateVariable result){
+ this.power = power;
+ this.result=result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getName()
+ */
+ public String getName() {
+ return NAME;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
+ */
+ public String getReturnArgumentName() {
+ return "Result";
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
+ */
+ public String[] getInputArgumentNames() {
+ return IN_ARG_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
+ */
+ public String[] getOutputArgumentNames() {
+ return OUT_ARG_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String argumentName) {
+ if (argumentName.equals("Power")) return power;
+ else if (argumentName.equals("Result")) return result;
+ else return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
+ */
+ public Dictionary invoke(Dictionary args) throws Exception {
+ Boolean value = (Boolean) args.get(NEW_TIME_VALUE);
+ power.setPower(value);
+ Hashtable result = new Hashtable();
+ result.put(NEW_RESULT_VALUE,Boolean.TRUE);
+ return result;
+ }
+}
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java
index e7b70ae..f5a0d02 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java
@@ -1,319 +1,319 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-
-import java.awt.Component;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Dictionary;
-import java.util.Properties;
-import java.util.Random;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPEventListener;
-import org.osgi.service.upnp.UPnPIcon;
-import org.osgi.service.upnp.UPnPService;
-
-import org.apache.felix.upnp.extra.util.UPnPEventNotifier;
-import org.apache.felix.upnp.extra.util.UPnPSubscriber;
-
-public class TvDevice implements UPnPDevice,UPnPEventListener,ServiceListener {
-
- final private String DEVICE_ID = "uuid:Felix-TV+" +Integer.toHexString(new Random(System.currentTimeMillis()).nextInt());
- private final static String CLOCK_DEVICE_TYPE = "urn:schemas-upnp-org:device:clock:1";
- private final static String TIME_SERVICE_TYPE = "urn:schemas-upnp-org:service:timer:1";
-
- private final static String LIGHT_DEVICE_TYPE = "urn:schemas-upnp-org:device:light:1";
- private final static String POWER_SERVICE_TYPE = "urn:schemas-upnp-org:service:power:1";
-
- private final static String AIRCON_DEVICE_TYPE = "urn:schemas-upnp-org:device:aircon:1";
- private final static String TEMP_SERVICE_TYPE = "urn:schemas-upnp-org:service:temp:1";
-
- private final static String WASHER_DEVICE_TYPE = "urn:schemas-upnp-org:device:washer:1";
- private final static String STATUS_SERVICE_TYPE = "urn:schemas-upnp-org:service:state:1";
-
- private final String devicesFilter =
- "(&"+
- "("+Constants.OBJECTCLASS+"="+UPnPDevice.class.getName()+"))";
- /*"(|("+UPnPDevice.TYPE+"="+ CLOCK_SERVICE_TYPE+")"+
- "("+UPnPDevice.TYPE+"="+ LIGHT_SERVICE_TYPE+")"+
- "("+UPnPDevice.TYPE+"="+ AIRCON_SERVICE_TYPE+")"+
- "("+UPnPDevice.TYPE+"="+ WASHER_SERVICE_TYPE+")))";*/
-
- private BundleContext context;
- private PowerService powerService;
- private UPnPService[] services;
- private Dictionary dictionary;
- private UPnPEventNotifier notifier;
- private PowerStateVariable powerState;
-
- public TvDevice() {
- powerService = new PowerService();
- services = new UPnPService[]{powerService};
- powerState = (PowerStateVariable) powerService.getStateVariable("Power");
- setupDeviceProperties();
- buildEventNotifyer();
- try {
- Activator.context.addServiceListener(this,devicesFilter);
- } catch (InvalidSyntaxException e) {
- System.out.println(e);
- }
- }
-
- /**
- *
- */
- private void buildEventNotifyer() {
- notifier = new UPnPEventNotifier(Activator.context,this,powerService);
- powerState.setNotifier(notifier);
- }
-
- private void setupDeviceProperties(){
- dictionary = new Properties();
- dictionary.put(UPnPDevice.UPNP_EXPORT,"");
- //org.osgi.service.device.Constants.DEVICE_CATEGORY
- //dictionary.put("DEVICE_CATEGORY","UPnP");
- dictionary.put(
- org.osgi.service
- .device.Constants.DEVICE_CATEGORY,
- new String[]{UPnPDevice.DEVICE_CATEGORY}
- );
- dictionary.put(UPnPDevice.FRIENDLY_NAME,"Felix Sample Tv");
- dictionary.put(UPnPDevice.MANUFACTURER,"Apache Software Foundation");
- dictionary.put(UPnPDevice.MANUFACTURER_URL,"http://felix.apache.org");
- dictionary.put(UPnPDevice.MODEL_DESCRIPTION,"A CyberLink Tv device clone to test OSGi to UPnP service import");
- dictionary.put(UPnPDevice.MODEL_NAME,"BimbiTv");
- dictionary.put(UPnPDevice.MODEL_NUMBER,"1.0");
- dictionary.put(UPnPDevice.MODEL_URL,"http://felix.apache.org/site/upnp-examples.html");
- //dictionary.put(UPnPDevice.PRESENTATION_URL,"http://felix.apache.org/BimbiTv/presentation");
- dictionary.put(UPnPDevice.SERIAL_NUMBER,"123456789");
- dictionary.put(UPnPDevice.TYPE,"urn:schemas-upnp-org:device:tv:1");
- dictionary.put(UPnPDevice.UDN,DEVICE_ID);
- //dictionary.put(UPnPDevice.ID,dictionary.get(UPnPDevice.UDN));
- dictionary.put(UPnPDevice.UPC,"1213456789");
- }
-
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getService(java.lang.String)
- */
- public UPnPService getService(String serviceId) {
- if (serviceId.equals(powerService.getId())) return powerService;
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getServices()
- */
- public UPnPService[] getServices() {
- return services;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getIcons(java.lang.String)
- */
- public UPnPIcon[] getIcons(String locale) {
- UPnPIcon icon = new TvIcon();
- return new UPnPIcon[]{icon} ;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPDevice#getDescriptions(java.lang.String)
- */
- public Dictionary getDescriptions(String locale) {
- return dictionary;
- }
-
-
-
- ////////////////////////////////////////////////
- // Component
- ////////////////////////////////////////////////
-
- private Component comp;
-
- public void setComponent(Component comp)
- {
- this.comp = comp;
- }
-
- public Component getComponent()
- {
- return comp;
- }
-
- ////////////////////////////////////////////////
- // on/off
- ////////////////////////////////////////////////
-
- private boolean onFlag = false;
-
- public void on()
- {
- powerState.setPower(Boolean.TRUE);
- doSubscribe();
- }
-
- public boolean isOn()
- {
- return powerState.getCurrentPower().booleanValue();
- }
- public void off()
- {
- powerState.setPower(Boolean.FALSE);
- undoSubscribe();
- }
-
-
- ////////////////////////////////////////////////
- // Clock
- ////////////////////////////////////////////////
-
- private String clockTime = "";
-
- public String getClockTime()
- {
- return clockTime;
- }
-
- ////////////////////////////////////////////////
- // Aircon
- ////////////////////////////////////////////////
-
- private String airconTemp = "";
-
- public String getAirconTempture()
- {
- return airconTemp;
- }
-
- ////////////////////////////////////////////////
- // Message
- ////////////////////////////////////////////////
-
- private String message = "";
-
- public void setMessage(String msg)
- {
- message = msg;
- }
-
- public String getMessage()
- {
- return message;
- }
-
-
- ////////////////////////////////////////////////
- // Subscribe
- ////////////////////////////////////////////////
-
- private UPnPSubscriber subscriber;
-
- public void doSubscribe()
- {
- subscriber = new UPnPSubscriber(Activator.context,this);
- subscriber.subscribeEveryServiceType(CLOCK_DEVICE_TYPE, TIME_SERVICE_TYPE);
- subscriber.subscribeEveryServiceType(AIRCON_DEVICE_TYPE, TEMP_SERVICE_TYPE);
- subscriber.subscribeEveryServiceType(LIGHT_DEVICE_TYPE, POWER_SERVICE_TYPE);
- subscriber.subscribeEveryServiceType(WASHER_DEVICE_TYPE, STATUS_SERVICE_TYPE);
- }
-
- public void undoSubscribe(){
- subscriber.unsubscribeAll();
- }
-
- ArrayList LinkedDevices = new ArrayList();
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPEventListener#notifyUPnPEvent(java.lang.String, java.lang.String, java.util.Dictionary)
- */
- public void notifyUPnPEvent(String deviceId, String serviceId, Dictionary events) {
- if( !LinkedDevices.contains(deviceId))
- LinkedDevices.add(deviceId);
- if (deviceId.indexOf("Clock") != -1){
- Long time = (Long) events.get("Time");
- clockTime = new Date(time.longValue()).toString();
- }
- else if (deviceId.indexOf("AirCon") != -1)
- airconTemp = (String) events.get("Temp");
- else if (deviceId.indexOf("Washer") != -1)
- message = (String) events.get("State");
- else if (deviceId.indexOf("Light") != -1)
- message = (String) events.get("Power");
-
- comp.repaint();
- }
-
-
- ////////////////////////////////////////////////
- // start/stop
- ////////////////////////////////////////////////
-
- public void start()
- {
- on();
- }
-
- public void stop()
- {
- ((PowerStateVariable) powerService.getStateVariable("Power")).setNotifier(null);
- notifier.destroy();
- off();
- }
-
- /* (non-Javadoc)
- * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
- */
- public void serviceChanged(ServiceEvent event) {
- switch(event.getType()){
- case ServiceEvent.REGISTERED:{
- };break;
-
- case ServiceEvent.MODIFIED:{
- };break;
-
- case ServiceEvent.UNREGISTERING:{
- ServiceReference sr = event.getServiceReference();
- String UDN = (String)sr.getProperty(UPnPDevice.ID);
- if (UDN != null){
- if (LinkedDevices.contains(UDN)) {
- if (UDN.indexOf("Clock") != -1)
- clockTime = "";
- else if (UDN.indexOf("AirCon") != -1)
- airconTemp = "";
- else if (UDN.indexOf("Washer") != -1)
- message = "";
- else if (UDN.indexOf("Light") != -1)
- message = "";
- }
- }
- comp.repaint();
- };break;
- }
- }
-
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+
+import java.awt.Component;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Dictionary;
+import java.util.Properties;
+import java.util.Random;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPEventListener;
+import org.osgi.service.upnp.UPnPIcon;
+import org.osgi.service.upnp.UPnPService;
+
+import org.apache.felix.upnp.extra.util.UPnPEventNotifier;
+import org.apache.felix.upnp.extra.util.UPnPSubscriber;
+
+public class TvDevice implements UPnPDevice,UPnPEventListener,ServiceListener {
+
+ final private String DEVICE_ID = "uuid:Felix-TV+" +Integer.toHexString(new Random(System.currentTimeMillis()).nextInt());
+ private final static String CLOCK_DEVICE_TYPE = "urn:schemas-upnp-org:device:clock:1";
+ private final static String TIME_SERVICE_TYPE = "urn:schemas-upnp-org:service:timer:1";
+
+ private final static String LIGHT_DEVICE_TYPE = "urn:schemas-upnp-org:device:light:1";
+ private final static String POWER_SERVICE_TYPE = "urn:schemas-upnp-org:service:power:1";
+
+ private final static String AIRCON_DEVICE_TYPE = "urn:schemas-upnp-org:device:aircon:1";
+ private final static String TEMP_SERVICE_TYPE = "urn:schemas-upnp-org:service:temp:1";
+
+ private final static String WASHER_DEVICE_TYPE = "urn:schemas-upnp-org:device:washer:1";
+ private final static String STATUS_SERVICE_TYPE = "urn:schemas-upnp-org:service:state:1";
+
+ private final String devicesFilter =
+ "(&"+
+ "("+Constants.OBJECTCLASS+"="+UPnPDevice.class.getName()+"))";
+ /*"(|("+UPnPDevice.TYPE+"="+ CLOCK_SERVICE_TYPE+")"+
+ "("+UPnPDevice.TYPE+"="+ LIGHT_SERVICE_TYPE+")"+
+ "("+UPnPDevice.TYPE+"="+ AIRCON_SERVICE_TYPE+")"+
+ "("+UPnPDevice.TYPE+"="+ WASHER_SERVICE_TYPE+")))";*/
+
+ private BundleContext context;
+ private PowerService powerService;
+ private UPnPService[] services;
+ private Dictionary dictionary;
+ private UPnPEventNotifier notifier;
+ private PowerStateVariable powerState;
+
+ public TvDevice() {
+ powerService = new PowerService();
+ services = new UPnPService[]{powerService};
+ powerState = (PowerStateVariable) powerService.getStateVariable("Power");
+ setupDeviceProperties();
+ buildEventNotifyer();
+ try {
+ Activator.context.addServiceListener(this,devicesFilter);
+ } catch (InvalidSyntaxException e) {
+ System.out.println(e);
+ }
+ }
+
+ /**
+ *
+ */
+ private void buildEventNotifyer() {
+ notifier = new UPnPEventNotifier(Activator.context,this,powerService);
+ powerState.setNotifier(notifier);
+ }
+
+ private void setupDeviceProperties(){
+ dictionary = new Properties();
+ dictionary.put(UPnPDevice.UPNP_EXPORT,"");
+ //org.osgi.service.device.Constants.DEVICE_CATEGORY
+ //dictionary.put("DEVICE_CATEGORY","UPnP");
+ dictionary.put(
+ org.osgi.service
+ .device.Constants.DEVICE_CATEGORY,
+ new String[]{UPnPDevice.DEVICE_CATEGORY}
+ );
+ dictionary.put(UPnPDevice.FRIENDLY_NAME,"Felix Sample Tv");
+ dictionary.put(UPnPDevice.MANUFACTURER,"Apache Software Foundation");
+ dictionary.put(UPnPDevice.MANUFACTURER_URL,"http://felix.apache.org");
+ dictionary.put(UPnPDevice.MODEL_DESCRIPTION,"A CyberLink Tv device clone to test OSGi to UPnP service import");
+ dictionary.put(UPnPDevice.MODEL_NAME,"BimbiTv");
+ dictionary.put(UPnPDevice.MODEL_NUMBER,"1.0");
+ dictionary.put(UPnPDevice.MODEL_URL,"http://felix.apache.org/site/upnp-examples.html");
+ //dictionary.put(UPnPDevice.PRESENTATION_URL,"http://felix.apache.org/BimbiTv/presentation");
+ dictionary.put(UPnPDevice.SERIAL_NUMBER,"123456789");
+ dictionary.put(UPnPDevice.TYPE,"urn:schemas-upnp-org:device:tv:1");
+ dictionary.put(UPnPDevice.UDN,DEVICE_ID);
+ //dictionary.put(UPnPDevice.ID,dictionary.get(UPnPDevice.UDN));
+ dictionary.put(UPnPDevice.UPC,"1213456789");
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getService(java.lang.String)
+ */
+ public UPnPService getService(String serviceId) {
+ if (serviceId.equals(powerService.getId())) return powerService;
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getServices()
+ */
+ public UPnPService[] getServices() {
+ return services;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getIcons(java.lang.String)
+ */
+ public UPnPIcon[] getIcons(String locale) {
+ UPnPIcon icon = new TvIcon();
+ return new UPnPIcon[]{icon} ;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPDevice#getDescriptions(java.lang.String)
+ */
+ public Dictionary getDescriptions(String locale) {
+ return dictionary;
+ }
+
+
+
+ ////////////////////////////////////////////////
+ // Component
+ ////////////////////////////////////////////////
+
+ private Component comp;
+
+ public void setComponent(Component comp)
+ {
+ this.comp = comp;
+ }
+
+ public Component getComponent()
+ {
+ return comp;
+ }
+
+ ////////////////////////////////////////////////
+ // on/off
+ ////////////////////////////////////////////////
+
+ private boolean onFlag = false;
+
+ public void on()
+ {
+ powerState.setPower(Boolean.TRUE);
+ doSubscribe();
+ }
+
+ public boolean isOn()
+ {
+ return powerState.getCurrentPower().booleanValue();
+ }
+ public void off()
+ {
+ powerState.setPower(Boolean.FALSE);
+ undoSubscribe();
+ }
+
+
+ ////////////////////////////////////////////////
+ // Clock
+ ////////////////////////////////////////////////
+
+ private String clockTime = "";
+
+ public String getClockTime()
+ {
+ return clockTime;
+ }
+
+ ////////////////////////////////////////////////
+ // Aircon
+ ////////////////////////////////////////////////
+
+ private String airconTemp = "";
+
+ public String getAirconTempture()
+ {
+ return airconTemp;
+ }
+
+ ////////////////////////////////////////////////
+ // Message
+ ////////////////////////////////////////////////
+
+ private String message = "";
+
+ public void setMessage(String msg)
+ {
+ message = msg;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+
+ ////////////////////////////////////////////////
+ // Subscribe
+ ////////////////////////////////////////////////
+
+ private UPnPSubscriber subscriber;
+
+ public void doSubscribe()
+ {
+ subscriber = new UPnPSubscriber(Activator.context,this);
+ subscriber.subscribeEveryServiceType(CLOCK_DEVICE_TYPE, TIME_SERVICE_TYPE);
+ subscriber.subscribeEveryServiceType(AIRCON_DEVICE_TYPE, TEMP_SERVICE_TYPE);
+ subscriber.subscribeEveryServiceType(LIGHT_DEVICE_TYPE, POWER_SERVICE_TYPE);
+ subscriber.subscribeEveryServiceType(WASHER_DEVICE_TYPE, STATUS_SERVICE_TYPE);
+ }
+
+ public void undoSubscribe(){
+ subscriber.unsubscribeAll();
+ }
+
+ ArrayList LinkedDevices = new ArrayList();
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPEventListener#notifyUPnPEvent(java.lang.String, java.lang.String, java.util.Dictionary)
+ */
+ public void notifyUPnPEvent(String deviceId, String serviceId, Dictionary events) {
+ if( !LinkedDevices.contains(deviceId))
+ LinkedDevices.add(deviceId);
+ if (deviceId.indexOf("Clock") != -1){
+ Long time = (Long) events.get("Time");
+ clockTime = new Date(time.longValue()).toString();
+ }
+ else if (deviceId.indexOf("AirCon") != -1)
+ airconTemp = (String) events.get("Temp");
+ else if (deviceId.indexOf("Washer") != -1)
+ message = (String) events.get("State");
+ else if (deviceId.indexOf("Light") != -1)
+ message = (String) events.get("Power");
+
+ comp.repaint();
+ }
+
+
+ ////////////////////////////////////////////////
+ // start/stop
+ ////////////////////////////////////////////////
+
+ public void start()
+ {
+ on();
+ }
+
+ public void stop()
+ {
+ ((PowerStateVariable) powerService.getStateVariable("Power")).setNotifier(null);
+ notifier.destroy();
+ off();
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
+ */
+ public void serviceChanged(ServiceEvent event) {
+ switch(event.getType()){
+ case ServiceEvent.REGISTERED:{
+ };break;
+
+ case ServiceEvent.MODIFIED:{
+ };break;
+
+ case ServiceEvent.UNREGISTERING:{
+ ServiceReference sr = event.getServiceReference();
+ String UDN = (String)sr.getProperty(UPnPDevice.ID);
+ if (UDN != null){
+ if (LinkedDevices.contains(UDN)) {
+ if (UDN.indexOf("Clock") != -1)
+ clockTime = "";
+ else if (UDN.indexOf("AirCon") != -1)
+ airconTemp = "";
+ else if (UDN.indexOf("Washer") != -1)
+ message = "";
+ else if (UDN.indexOf("Light") != -1)
+ message = "";
+ }
+ }
+ comp.repaint();
+ };break;
+ }
+ }
+
+}
+
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvFrame.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvFrame.java
index 1bafddc..0d50cbf 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvFrame.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvFrame.java
@@ -1,123 +1,123 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-
-import java.awt.BorderLayout;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.net.URL;
-
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-
-import org.osgi.framework.BundleException;
-
-public class TvFrame extends JFrame implements Runnable
-{
- private final static String TITLE = "Felix UpnP TV";
-
- private TvDevice tvDev;
- private TvPane tvPane;
-
- public TvFrame()
- {
- super(TITLE);
-
- tvDev = new TvDevice();
-
- getContentPane().setLayout(new BorderLayout());
-
- tvPane = new TvPane();
- tvDev.setComponent(tvPane);
- tvPane.setDevice(tvDev);
- getContentPane().add(tvPane, BorderLayout.CENTER);
-
- addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e)
- {
- try {
- Activator.context.getBundle().stop();
- } catch (BundleException ex) {
- ex.printStackTrace();
- }
- }
- });
-
- try {
- URL eventIconUrl = TvFrame.class.getResource("images/logo.gif");
- ImageIcon icon= new ImageIcon(eventIconUrl,"logo");
- setIconImage(icon.getImage());
- }
- catch (Exception ex){
- System.out.println("Resource: IMAGES/logo.gif not found : " + ex.toString());
- }
-
- pack();
- setVisible(true);
- }
-
- public TvPane getTvPanel()
- {
- return tvPane;
- }
-
- public TvDevice getTvDevice()
- {
- return tvDev;
- }
-
- ////////////////////////////////////////////////
- // run
- ////////////////////////////////////////////////
-
- private Thread timerThread = null;
-
- public void run()
- {
- Thread thisThread = Thread.currentThread();
-
- while (timerThread == thisThread) {
- tvDev.setMessage("");
- tvPane.repaint();
- try {
- Thread.sleep(1000*5);
- }
- catch(InterruptedException e) {}
- }
- }
-
- public void start()
- {
- tvDev.start();
-
- timerThread = new Thread(this,"upnp.sample.tv.TVFrame");
- timerThread.start();
- }
-
- public void stop()
- {
- tvDev.stop();
- timerThread = null;
- dispose();
- }
-
-
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+
+import java.awt.BorderLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.net.URL;
+
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+
+import org.osgi.framework.BundleException;
+
+public class TvFrame extends JFrame implements Runnable
+{
+ private final static String TITLE = "Felix UpnP TV";
+
+ private TvDevice tvDev;
+ private TvPane tvPane;
+
+ public TvFrame()
+ {
+ super(TITLE);
+
+ tvDev = new TvDevice();
+
+ getContentPane().setLayout(new BorderLayout());
+
+ tvPane = new TvPane();
+ tvDev.setComponent(tvPane);
+ tvPane.setDevice(tvDev);
+ getContentPane().add(tvPane, BorderLayout.CENTER);
+
+ addWindowListener(new WindowAdapter(){
+ public void windowClosing(WindowEvent e)
+ {
+ try {
+ Activator.context.getBundle().stop();
+ } catch (BundleException ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ try {
+ URL eventIconUrl = TvFrame.class.getResource("images/logo.gif");
+ ImageIcon icon= new ImageIcon(eventIconUrl,"logo");
+ setIconImage(icon.getImage());
+ }
+ catch (Exception ex){
+ System.out.println("Resource: IMAGES/logo.gif not found : " + ex.toString());
+ }
+
+ pack();
+ setVisible(true);
+ }
+
+ public TvPane getTvPanel()
+ {
+ return tvPane;
+ }
+
+ public TvDevice getTvDevice()
+ {
+ return tvDev;
+ }
+
+ ////////////////////////////////////////////////
+ // run
+ ////////////////////////////////////////////////
+
+ private Thread timerThread = null;
+
+ public void run()
+ {
+ Thread thisThread = Thread.currentThread();
+
+ while (timerThread == thisThread) {
+ tvDev.setMessage("");
+ tvPane.repaint();
+ try {
+ Thread.sleep(1000*5);
+ }
+ catch(InterruptedException e) {}
+ }
+ }
+
+ public void start()
+ {
+ tvDev.start();
+
+ timerThread = new Thread(this,"upnp.sample.tv.TVFrame");
+ timerThread.start();
+ }
+
+ public void stop()
+ {
+ tvDev.stop();
+ timerThread = null;
+ dispose();
+ }
+
+
+}
+
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvIcon.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvIcon.java
index a6df26d..fb1dec3 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvIcon.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvIcon.java
@@ -1,69 +1,69 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.osgi.service.upnp.UPnPIcon;
-
-public class TvIcon implements UPnPIcon {
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getMimeType()
- */
- public String getMimeType() {
- return "image/gif";
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getWidth()
- */
- public int getWidth() {
- return 32;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getHeight()
- */
- public int getHeight() {
- return 32;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getSize()
- */
- public int getSize() {
- return 0;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getDepth()
- */
- public int getDepth() {
- return 16;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getInputStream()
- */
- public InputStream getInputStream() throws IOException {
- return TvIcon.class.getResourceAsStream("images/tv.gif");
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.osgi.service.upnp.UPnPIcon;
+
+public class TvIcon implements UPnPIcon {
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getMimeType()
+ */
+ public String getMimeType() {
+ return "image/gif";
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getWidth()
+ */
+ public int getWidth() {
+ return 32;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getHeight()
+ */
+ public int getHeight() {
+ return 32;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getSize()
+ */
+ public int getSize() {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getDepth()
+ */
+ public int getDepth() {
+ return 16;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getInputStream()
+ */
+ public InputStream getInputStream() throws IOException {
+ return TvIcon.class.getResourceAsStream("images/tv.gif");
+ }
+}
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvPane.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvPane.java
index f8a0549..7dd1da4 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvPane.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvPane.java
@@ -1,214 +1,214 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-
-import javax.imageio.ImageIO;
-import javax.swing.JPanel;
-
-public class TvPane extends JPanel // MouseListener
-{
- private final static int IMAGE_BORDER_SIZE = 20;
- private final static int IMAGE_BOTTOM_BORDER_SIZE = 30;
-
- ////////////////////////////////////////////////
- // Constructor
- ////////////////////////////////////////////////
-
- public TvPane()
- {
- loadImage();
- initPanel();
- }
-
- ////////////////////////////////////////////////
- // TvDevice
- ////////////////////////////////////////////////
-
- private TvDevice tvDev = null;
-
- public void setDevice(TvDevice dev)
- {
- tvDev = dev;
- }
-
- public TvDevice getDevice()
- {
- return tvDev;
- }
-
- ////////////////////////////////////////////////
- // Background
- ////////////////////////////////////////////////
-
- private BufferedImage panelmage;
- private BufferedImage tvOnImage;
-
- private void loadImage()
- {
- try {
- panelmage = ImageIO.read(TvPane.class.getResourceAsStream("images/tv.jpg"));
- tvOnImage = ImageIO.read(TvPane.class.getResourceAsStream("images/tvon.jpg"));
- }
- catch (Exception e) {
- System.out.println(e);
- }
- }
-
- ////////////////////////////////////////////////
- // Background
- ////////////////////////////////////////////////
-
- private void initPanel()
- {
- setPreferredSize(new Dimension(panelmage.getWidth(), panelmage.getHeight()));
- }
-
- ////////////////////////////////////////////////
- // Font
- ////////////////////////////////////////////////
-
- private final static String DEFAULT_FONT_NAME = "Lucida Console";
- private final static int DEFAULT_TIME_FONT_SIZE = 10;
-
- private Font timeFont = null;
-
- private Font getFont(Graphics g, int size)
- {
- Font font = new Font(DEFAULT_FONT_NAME, Font.BOLD, size);
- if (font != null)
- return font;
- return g.getFont();
- }
-
- private Font getFont(Graphics g)
- {
- if (timeFont == null)
- timeFont = getFont(g, DEFAULT_TIME_FONT_SIZE);
- return timeFont;
- }
-
- ////////////////////////////////////////////////
- // paint
- ////////////////////////////////////////////////
-
- private void drawClockInfo(Graphics g)
- {
- TvDevice tvDev = getDevice();
-
- int winWidth = getWidth();
- int winHeight = getHeight();
-
- Font font = getFont(g);
- g.setFont(font);
- FontMetrics fontMetric = g.getFontMetrics();
- g.setColor(Color.RED);
-
- Rectangle2D strBounds;
- int strWidth;
- int strHeight;
- int strX;
- int strY;
-
- //// Time String ////
-
- String timeStr = tvDev.getClockTime();
- if (timeStr != null && 0 < timeStr.length()) {
- strBounds = fontMetric.getStringBounds(timeStr, g);
- strWidth = (int)strBounds.getWidth();
- strHeight = (int)strBounds.getHeight();
- strX = IMAGE_BORDER_SIZE;
- strY = IMAGE_BORDER_SIZE + strHeight;
- g.drawString(
- timeStr,
- strX,
- strY);
- }
-
- //// Tempture String ////
-
- String tempStr = tvDev.getAirconTempture();
- if (tempStr != null && 0 < tempStr.length()) {
- tempStr += "C";
- strBounds = fontMetric.getStringBounds(tempStr, g);
- strWidth = (int)strBounds.getWidth();
- strHeight = (int)strBounds.getHeight();
- strX = winWidth - IMAGE_BORDER_SIZE - strWidth;
- strY = IMAGE_BORDER_SIZE + strHeight;
- g.drawString(
- tempStr,
- strX,
- strY);
- }
-
- //// Message String ////
-
- String msgStr = tvDev.getMessage();
- if (msgStr != null && 0 < msgStr.length()) {
- strBounds = fontMetric.getStringBounds(msgStr, g);
- strWidth = (int)strBounds.getWidth();
- strHeight = (int)strBounds.getHeight();
- strX = IMAGE_BORDER_SIZE;
- strY = getHeight()-IMAGE_BOTTOM_BORDER_SIZE-2;
- g.drawString(
- msgStr,
- strX,
- strY);
- }
- }
-
- private void drawTvImage(Graphics g)
- {
- //g.setColor(Color.WHITE);
- //g.clearRect(IMAGE_BORDER_SIZE, IMAGE_BORDER_SIZE, getWidth()-IMAGE_BORDER_SIZE*2, getHeight()-IMAGE_BORDER_SIZE-IMAGE_BOTTOM_BORDER_SIZE);
- g.drawImage(tvOnImage, IMAGE_BORDER_SIZE, IMAGE_BORDER_SIZE, null);
- }
-
- private void clear(Graphics g)
- {
- g.setColor(Color.GRAY);
- g.clearRect(0, 0, getWidth(), getHeight());
- }
-
-
- private void drawPanelImage(Graphics g)
- {
- g.drawImage(panelmage, 0, 0, null);
- }
-
- public void paint(Graphics g)
- {
- clear(g);
- drawPanelImage(g);
- TvDevice tvDev = getDevice();
- if (tvDev.isOn() == true) {
- drawTvImage(g);
- drawClockInfo(g);
- }
- }
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+
+import javax.imageio.ImageIO;
+import javax.swing.JPanel;
+
+public class TvPane extends JPanel // MouseListener
+{
+ private final static int IMAGE_BORDER_SIZE = 20;
+ private final static int IMAGE_BOTTOM_BORDER_SIZE = 30;
+
+ ////////////////////////////////////////////////
+ // Constructor
+ ////////////////////////////////////////////////
+
+ public TvPane()
+ {
+ loadImage();
+ initPanel();
+ }
+
+ ////////////////////////////////////////////////
+ // TvDevice
+ ////////////////////////////////////////////////
+
+ private TvDevice tvDev = null;
+
+ public void setDevice(TvDevice dev)
+ {
+ tvDev = dev;
+ }
+
+ public TvDevice getDevice()
+ {
+ return tvDev;
+ }
+
+ ////////////////////////////////////////////////
+ // Background
+ ////////////////////////////////////////////////
+
+ private BufferedImage panelmage;
+ private BufferedImage tvOnImage;
+
+ private void loadImage()
+ {
+ try {
+ panelmage = ImageIO.read(TvPane.class.getResourceAsStream("images/tv.jpg"));
+ tvOnImage = ImageIO.read(TvPane.class.getResourceAsStream("images/tvon.jpg"));
+ }
+ catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+
+ ////////////////////////////////////////////////
+ // Background
+ ////////////////////////////////////////////////
+
+ private void initPanel()
+ {
+ setPreferredSize(new Dimension(panelmage.getWidth(), panelmage.getHeight()));
+ }
+
+ ////////////////////////////////////////////////
+ // Font
+ ////////////////////////////////////////////////
+
+ private final static String DEFAULT_FONT_NAME = "Lucida Console";
+ private final static int DEFAULT_TIME_FONT_SIZE = 10;
+
+ private Font timeFont = null;
+
+ private Font getFont(Graphics g, int size)
+ {
+ Font font = new Font(DEFAULT_FONT_NAME, Font.BOLD, size);
+ if (font != null)
+ return font;
+ return g.getFont();
+ }
+
+ private Font getFont(Graphics g)
+ {
+ if (timeFont == null)
+ timeFont = getFont(g, DEFAULT_TIME_FONT_SIZE);
+ return timeFont;
+ }
+
+ ////////////////////////////////////////////////
+ // paint
+ ////////////////////////////////////////////////
+
+ private void drawClockInfo(Graphics g)
+ {
+ TvDevice tvDev = getDevice();
+
+ int winWidth = getWidth();
+ int winHeight = getHeight();
+
+ Font font = getFont(g);
+ g.setFont(font);
+ FontMetrics fontMetric = g.getFontMetrics();
+ g.setColor(Color.RED);
+
+ Rectangle2D strBounds;
+ int strWidth;
+ int strHeight;
+ int strX;
+ int strY;
+
+ //// Time String ////
+
+ String timeStr = tvDev.getClockTime();
+ if (timeStr != null && 0 < timeStr.length()) {
+ strBounds = fontMetric.getStringBounds(timeStr, g);
+ strWidth = (int)strBounds.getWidth();
+ strHeight = (int)strBounds.getHeight();
+ strX = IMAGE_BORDER_SIZE;
+ strY = IMAGE_BORDER_SIZE + strHeight;
+ g.drawString(
+ timeStr,
+ strX,
+ strY);
+ }
+
+ //// Tempture String ////
+
+ String tempStr = tvDev.getAirconTempture();
+ if (tempStr != null && 0 < tempStr.length()) {
+ tempStr += "C";
+ strBounds = fontMetric.getStringBounds(tempStr, g);
+ strWidth = (int)strBounds.getWidth();
+ strHeight = (int)strBounds.getHeight();
+ strX = winWidth - IMAGE_BORDER_SIZE - strWidth;
+ strY = IMAGE_BORDER_SIZE + strHeight;
+ g.drawString(
+ tempStr,
+ strX,
+ strY);
+ }
+
+ //// Message String ////
+
+ String msgStr = tvDev.getMessage();
+ if (msgStr != null && 0 < msgStr.length()) {
+ strBounds = fontMetric.getStringBounds(msgStr, g);
+ strWidth = (int)strBounds.getWidth();
+ strHeight = (int)strBounds.getHeight();
+ strX = IMAGE_BORDER_SIZE;
+ strY = getHeight()-IMAGE_BOTTOM_BORDER_SIZE-2;
+ g.drawString(
+ msgStr,
+ strX,
+ strY);
+ }
+ }
+
+ private void drawTvImage(Graphics g)
+ {
+ //g.setColor(Color.WHITE);
+ //g.clearRect(IMAGE_BORDER_SIZE, IMAGE_BORDER_SIZE, getWidth()-IMAGE_BORDER_SIZE*2, getHeight()-IMAGE_BORDER_SIZE-IMAGE_BOTTOM_BORDER_SIZE);
+ g.drawImage(tvOnImage, IMAGE_BORDER_SIZE, IMAGE_BORDER_SIZE, null);
+ }
+
+ private void clear(Graphics g)
+ {
+ g.setColor(Color.GRAY);
+ g.clearRect(0, 0, getWidth(), getHeight());
+ }
+
+
+ private void drawPanelImage(Graphics g)
+ {
+ g.drawImage(panelmage, 0, 0, null);
+ }
+
+ public void paint(Graphics g)
+ {
+ clear(g);
+ drawPanelImage(g);
+ TvDevice tvDev = getDevice();
+ if (tvDev.isOn() == true) {
+ drawTvImage(g);
+ drawClockInfo(g);
+ }
+ }
+}
+
diff --git a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/UPnPSubscriber.java b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/UPnPSubscriber.java
index 8780f90..8d1341d 100644
--- a/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/UPnPSubscriber.java
+++ b/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/UPnPSubscriber.java
@@ -1,63 +1,63 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.sample.tv;
-
-import java.util.Properties;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPEventListener;
-import org.osgi.service.upnp.UPnPService;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class UPnPSubscriber {
- ServiceRegistration registration = null;
- BundleContext context;
- UPnPEventListener listener;
-
- public UPnPSubscriber(BundleContext context,UPnPEventListener listener){
- this.context = context;
- this.listener = listener;
- }
-
- public void subscribe(String deviceType, String serviceType){
- String keys = "(&(" + UPnPDevice.TYPE + "="+ deviceType + ")(" + UPnPService.TYPE + "=" + serviceType + "))";
- try {
- Filter filter = context.createFilter(keys);
- Properties props = new Properties();
- props.put(UPnPEventListener.UPNP_FILTER, filter);
- registration = context.registerService(UPnPEventListener.class.getName(), listener, props);
- }catch (Exception ex){
- System.out.println(ex);
- }
- }
-
- public void unsubscribe(){
- registration.unregister();
- registration = null;
- }
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.upnp.sample.tv;
+
+import java.util.Properties;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPEventListener;
+import org.osgi.service.upnp.UPnPService;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class UPnPSubscriber {
+ ServiceRegistration registration = null;
+ BundleContext context;
+ UPnPEventListener listener;
+
+ public UPnPSubscriber(BundleContext context,UPnPEventListener listener){
+ this.context = context;
+ this.listener = listener;
+ }
+
+ public void subscribe(String deviceType, String serviceType){
+ String keys = "(&(" + UPnPDevice.TYPE + "="+ deviceType + ")(" + UPnPService.TYPE + "=" + serviceType + "))";
+ try {
+ Filter filter = context.createFilter(keys);
+ Properties props = new Properties();
+ props.put(UPnPEventListener.UPNP_FILTER, filter);
+ registration = context.registerService(UPnPEventListener.class.getName(), listener, props);
+ }catch (Exception ex){
+ System.out.println(ex);
+ }
+ }
+
+ public void unsubscribe(){
+ registration.unregister();
+ registration = null;
+ }
+
+
+}