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/basedriver/src/main/java/org/apache/felix/upnp/basedriver/controller/impl/DriverControllerImpl.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/controller/impl/DriverControllerImpl.java
index f54b4dc..efeaca0 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/controller/impl/DriverControllerImpl.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/controller/impl/DriverControllerImpl.java
@@ -1,147 +1,147 @@
-/*
- * 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.basedriver.controller.impl;
-
-import org.cybergarage.upnp.Device;
-import org.cybergarage.upnp.Service;
-
-import org.apache.felix.upnp.basedriver.Activator;
-import org.apache.felix.upnp.basedriver.importer.core.MyCtrlPoint;
-import org.apache.felix.upnp.basedriver.tool.Logger;
-import org.apache.felix.upnp.basedriver.controller.DevicesInfo;
-import org.apache.felix.upnp.basedriver.controller.DriverController;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class DriverControllerImpl implements DriverController, DevicesInfo{
- private MyCtrlPoint myCtrl;
- private Logger logger = Activator.logger;
-
- public DriverControllerImpl(MyCtrlPoint myCtrl){
- this.myCtrl = myCtrl;
-
- }
-
- public void setLogLevel(int n) {
- logger.setLogLevel(n);
- }
-
- public int getLogLevel() {
- return logger.getLogLevel();
- }
-
- public void setCyberDebug(boolean b) {
- logger.setCyberDebug(b);
- }
-
- public boolean getCyberDebug() {
- return logger.getCyberDebug();
- }
-
- public String getLocationURL(String udn) {
- if (myCtrl == null){
- logger.WARNING("UPnP Importer is disabled. getLocationURL is not available");
- return null;
- }
- if (udn == null || udn.equals("")) throw new IllegalArgumentException("Invalid udn paramenter");
- Device device = myCtrl.getDevice(udn);
- if (device == null) {
- logger.WARNING("getLocationURL():: No device data available for UDN:"+udn);
- return null;
- }
- return device.getLocation();
- }
-
- public String getSCPDURL(String udn, String serviceId) {
- if (myCtrl == null){
- logger.WARNING("UPnP Importer is disabled. getSCPDURL() is not available");
- return null;
- }
- if (udn == null || udn.equals("") ) throw new IllegalArgumentException("Invalid udn paramenter");
- if (serviceId == null || serviceId.equals("") ) throw new IllegalArgumentException("Invalid serviceId paramenter");
- Device device= myCtrl.getDevice(udn);
- if (device == null) {
- logger.WARNING("getSCPDURL():: No device data available for UDN: "+udn);
- return null;
- }
- Service service = device.getService(serviceId);
- if (service == null) {
- logger.WARNING("getSCPDURL():: No service data available for serviceId:"+serviceId + " of UDN " + udn);
- return null;
- }
- String scpd = service.getSCPDURL().trim();
- return resolveRelativeLink(device,scpd);
- }
-
- public String resolveRelativeUrl(String udn, String link) {
- if (myCtrl == null){
- logger.WARNING("UPnP Importer is disabled. resolveRelativeUrl() is not available");
- return null;
- }
- if (udn == null || udn.equals("")) throw new IllegalArgumentException("Invalid udn paramenter");
- Device device = myCtrl.getDevice(udn);
- if (device == null) {
- logger.WARNING("resolveRelativeUrl():: No device data available for UDN: "+udn);
- return null;
- }
- return resolveRelativeLink(device,link);
- }
-
- private String resolveRelativeLink(Device device, String link) {
- if ( device == null || link == null) return null;
- if (link.startsWith("http:"))
- return link;
- else {
- String hostname = "";
- String location = "";
- String urlBase = device.getURLBase().trim();
- //TODO Check if is more important URLBase or location
- if (urlBase.equals("")){
- location = device.getLocation().trim();
- int endHostnameIdx = location.indexOf("/",7);
- if (endHostnameIdx!=-1)
- hostname=location.substring(0,endHostnameIdx);
- else
- hostname = location;
- if (link.startsWith("/")){
- return hostname+link;
- }else{
- //TODO Check for link start with .. or /
- return location +link;
- }
- }
- else {
- return urlBase+link;
- }
- }
- }
-
- public void search(String target) {
- if (myCtrl == null){
- logger.WARNING("UPnP Importer is disabled. resolveRelativeUrl() is not available");
- return ;
- }
- myCtrl.search(target);
- }
-
-
-
-}
+/*
+ * 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.basedriver.controller.impl;
+
+import org.cybergarage.upnp.Device;
+import org.cybergarage.upnp.Service;
+
+import org.apache.felix.upnp.basedriver.Activator;
+import org.apache.felix.upnp.basedriver.importer.core.MyCtrlPoint;
+import org.apache.felix.upnp.basedriver.tool.Logger;
+import org.apache.felix.upnp.basedriver.controller.DevicesInfo;
+import org.apache.felix.upnp.basedriver.controller.DriverController;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class DriverControllerImpl implements DriverController, DevicesInfo{
+ private MyCtrlPoint myCtrl;
+ private Logger logger = Activator.logger;
+
+ public DriverControllerImpl(MyCtrlPoint myCtrl){
+ this.myCtrl = myCtrl;
+
+ }
+
+ public void setLogLevel(int n) {
+ logger.setLogLevel(n);
+ }
+
+ public int getLogLevel() {
+ return logger.getLogLevel();
+ }
+
+ public void setCyberDebug(boolean b) {
+ logger.setCyberDebug(b);
+ }
+
+ public boolean getCyberDebug() {
+ return logger.getCyberDebug();
+ }
+
+ public String getLocationURL(String udn) {
+ if (myCtrl == null){
+ logger.WARNING("UPnP Importer is disabled. getLocationURL is not available");
+ return null;
+ }
+ if (udn == null || udn.equals("")) throw new IllegalArgumentException("Invalid udn paramenter");
+ Device device = myCtrl.getDevice(udn);
+ if (device == null) {
+ logger.WARNING("getLocationURL():: No device data available for UDN:"+udn);
+ return null;
+ }
+ return device.getLocation();
+ }
+
+ public String getSCPDURL(String udn, String serviceId) {
+ if (myCtrl == null){
+ logger.WARNING("UPnP Importer is disabled. getSCPDURL() is not available");
+ return null;
+ }
+ if (udn == null || udn.equals("") ) throw new IllegalArgumentException("Invalid udn paramenter");
+ if (serviceId == null || serviceId.equals("") ) throw new IllegalArgumentException("Invalid serviceId paramenter");
+ Device device= myCtrl.getDevice(udn);
+ if (device == null) {
+ logger.WARNING("getSCPDURL():: No device data available for UDN: "+udn);
+ return null;
+ }
+ Service service = device.getService(serviceId);
+ if (service == null) {
+ logger.WARNING("getSCPDURL():: No service data available for serviceId:"+serviceId + " of UDN " + udn);
+ return null;
+ }
+ String scpd = service.getSCPDURL().trim();
+ return resolveRelativeLink(device,scpd);
+ }
+
+ public String resolveRelativeUrl(String udn, String link) {
+ if (myCtrl == null){
+ logger.WARNING("UPnP Importer is disabled. resolveRelativeUrl() is not available");
+ return null;
+ }
+ if (udn == null || udn.equals("")) throw new IllegalArgumentException("Invalid udn paramenter");
+ Device device = myCtrl.getDevice(udn);
+ if (device == null) {
+ logger.WARNING("resolveRelativeUrl():: No device data available for UDN: "+udn);
+ return null;
+ }
+ return resolveRelativeLink(device,link);
+ }
+
+ private String resolveRelativeLink(Device device, String link) {
+ if ( device == null || link == null) return null;
+ if (link.startsWith("http:"))
+ return link;
+ else {
+ String hostname = "";
+ String location = "";
+ String urlBase = device.getURLBase().trim();
+ //TODO Check if is more important URLBase or location
+ if (urlBase.equals("")){
+ location = device.getLocation().trim();
+ int endHostnameIdx = location.indexOf("/",7);
+ if (endHostnameIdx!=-1)
+ hostname=location.substring(0,endHostnameIdx);
+ else
+ hostname = location;
+ if (link.startsWith("/")){
+ return hostname+link;
+ }else{
+ //TODO Check for link start with .. or /
+ return location +link;
+ }
+ }
+ else {
+ return urlBase+link;
+ }
+ }
+ }
+
+ public void search(String target) {
+ if (myCtrl == null){
+ logger.WARNING("UPnP Importer is disabled. resolveRelativeUrl() is not available");
+ return ;
+ }
+ myCtrl.search(target);
+ }
+
+
+
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/ActionDispatcher.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/ActionDispatcher.java
index f887aef..89c0bbf 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/ActionDispatcher.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/ActionDispatcher.java
@@ -1,47 +1,47 @@
-/*
- * 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.basedriver.export;
-
-import org.cybergarage.upnp.Action;
-import org.cybergarage.upnp.control.ActionListener;
-
-import org.osgi.framework.ServiceReference;
-
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class ActionDispatcher implements ActionListener{
- /**
- *
- */
- public ActionDispatcher(ServiceReference sr) {
- super();
- }
-
- /**
- * @see org.cybergarage.upnp.control.ActionListener#actionControlReceived(org.cybergarage.upnp.Action)
- */
- public boolean actionControlReceived(Action action) {
- // TODO Auto-generated method stub
- 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.basedriver.export;
+
+import org.cybergarage.upnp.Action;
+import org.cybergarage.upnp.control.ActionListener;
+
+import org.osgi.framework.ServiceReference;
+
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class ActionDispatcher implements ActionListener{
+ /**
+ *
+ */
+ public ActionDispatcher(ServiceReference sr) {
+ super();
+ }
+
+ /**
+ * @see org.cybergarage.upnp.control.ActionListener#actionControlReceived(org.cybergarage.upnp.Action)
+ */
+ public boolean actionControlReceived(Action action) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/BuildDevice.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/BuildDevice.java
index 65e431a..a0334e6 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/BuildDevice.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/BuildDevice.java
@@ -1,291 +1,291 @@
-/*
- * 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.basedriver.export;
-
-
-import org.cybergarage.upnp.Action;
-import org.cybergarage.upnp.AllowedValueList;
-import org.cybergarage.upnp.AllowedValueRange;
-import org.cybergarage.upnp.Argument;
-import org.cybergarage.upnp.ArgumentList;
-import org.cybergarage.upnp.Device;
-import org.cybergarage.upnp.RootDescription;
-import org.cybergarage.upnp.Service;
-import org.cybergarage.upnp.StateVariable;
-import org.cybergarage.upnp.xml.DeviceData;
-import org.cybergarage.xml.Node;
-
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.basedriver.Activator;
-import org.apache.felix.upnp.basedriver.util.Converter;
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class BuildDevice {
-
- private static Node buildRootNode(){
- Node root = new Node(RootDescription.ROOT_ELEMENT);
- root.setAttribute("xmlns",RootDescription.ROOT_ELEMENT_NAMESPACE);
- Node spec = new Node(RootDescription.SPECVERSION_ELEMENT);
- Node maj =new Node(RootDescription.MAJOR_ELEMENT);
- maj.setValue("1");
- Node min =new Node(RootDescription.MINOR_ELEMENT);
- min.setValue("0");
- spec.addNode(maj);
- spec.addNode(min);
- root.addNode(spec);
- return root;
- }
-
- private static Device buildRootDeviceNode(Node root,ServiceReference sr){
- Node dev = new Node(Device.ELEM_NAME);
- root.addNode(dev);
- DeviceData dd = new DeviceData();
- dd.setDescriptionURI("/gen-desc.xml");
- dev.setUserData(dd);
- Device devUPnP = new Device(root,dev);
-
-
- Object aux = sr.getProperty(UPnPDevice.TYPE);
- if(aux==null){
- devUPnP.setDeviceType(null);
- }else if(aux instanceof String){
- devUPnP.setDeviceType((String) aux);
- }else if(aux instanceof String[]){
- //The property key UPnP.device.type should be a String
- String[] v = (String[]) aux;
- int maxindex=0;
- int max=Integer.parseInt(v[0].substring(v[0].lastIndexOf(":")+1));
- int tmp;
- for (int i = 1; i < v.length; i++) {
- tmp=Integer.parseInt(v[i].substring(v[i].lastIndexOf(":")+1));
- if(max<tmp){
- max=tmp;
- maxindex=i;
- }
- }
- devUPnP.setDeviceType(v[maxindex]);
- }
-
- devUPnP.setFriendlyName((String) sr.getProperty(UPnPDevice.FRIENDLY_NAME));
- devUPnP.setManufacture((String) sr.getProperty(UPnPDevice.MANUFACTURER));
- devUPnP.setManufactureURL((String) sr.getProperty(UPnPDevice.MANUFACTURER_URL));
- devUPnP.setModelDescription((String) sr.getProperty(UPnPDevice.MODEL_DESCRIPTION));
- devUPnP.setModelName((String) sr.getProperty(UPnPDevice.MODEL_NAME));
- devUPnP.setModelNumber((String) sr.getProperty(UPnPDevice.MODEL_NUMBER));
- devUPnP.setModelURL((String) sr.getProperty(UPnPDevice.MODEL_URL));
- devUPnP.setSerialNumber((String) sr.getProperty(UPnPDevice.SERIAL_NUMBER));
- devUPnP.setUDN((String) sr.getProperty(UPnPDevice.UDN));
- devUPnP.setUPC((String) sr.getProperty(UPnPDevice.UPC));
-
- devUPnP.setLocation("/gen-desc.xml");
-
- addServices("",devUPnP,sr);
- addDevices("",devUPnP,sr);
- devUPnP.setPresentationURL((String) sr.getProperty(UPnPDevice.PRESENTATION_URL));
-
- return devUPnP;
- }
-
- private static void addDevices(String id,Device devUPnP, ServiceReference sr) {
-
- String[] udns=(String[]) sr.getProperty(UPnPDevice.CHILDREN_UDN);
- if(udns==null) {
- return;
- }
- for (int i = 0; i < udns.length; i++) {
- try {
- ServiceReference[] aux = Activator.bc.getServiceReferences(
- UPnPDevice.class.getName(),"("+UPnPDevice.UDN+"="+udns[i]+")"
- );
- if(aux==null || aux.length == 0)
- continue;
- //id=+"/device/"+i; // twa: wrong in recursion
- //buildDevice(id,devUPnP,aux[0]); // twa: wrong in recursion
- String localId = new StringBuffer(id).append("/device/").append(i).toString();
- buildDevice(localId,devUPnP,aux[0]); // twa: better
- } catch (InvalidSyntaxException ignored) {}
- }
- }
-
- private static void buildDevice(String id,Device parent, ServiceReference sr) {
- Node dev = new Node(Device.ELEM_NAME);
- DeviceData dd = new DeviceData();
- dd.setDescriptionURI(id+"/gen-desc.xml");
- dev.setUserData(dd);
-
- Device devUPnP = new Device(dev);
-
- devUPnP.setFriendlyName((String) sr.getProperty(UPnPDevice.FRIENDLY_NAME));
- devUPnP.setManufacture((String) sr.getProperty(UPnPDevice.MANUFACTURER));
- devUPnP.setManufactureURL((String) sr.getProperty(UPnPDevice.MANUFACTURER_URL));
- devUPnP.setModelDescription((String) sr.getProperty(UPnPDevice.MODEL_DESCRIPTION));
- devUPnP.setModelName((String) sr.getProperty(UPnPDevice.MODEL_NAME));
- devUPnP.setModelNumber((String) sr.getProperty(UPnPDevice.MODEL_NUMBER));
- devUPnP.setModelURL((String) sr.getProperty(UPnPDevice.MODEL_URL));
- devUPnP.setSerialNumber((String) sr.getProperty(UPnPDevice.SERIAL_NUMBER));
- devUPnP.setUDN((String) sr.getProperty(UPnPDevice.UDN));
- devUPnP.setUPC((String) sr.getProperty(UPnPDevice.UPC));
- devUPnP.setLocation(id+"/gen-desc.xml");
-
- addServices(id,devUPnP,sr);
- addDevices(id,devUPnP,sr);
-
- parent.addDevice(devUPnP); // twa: essential!!!!!!!
- devUPnP.setPresentationURL((String) sr.getProperty(UPnPDevice.PRESENTATION_URL));
-
- }
-
- /**
- * Method used to create a new Service in CyberLink world without creating the XML
- *
- * @param id ServiceId
- * @param devUPnP the CyberLink device that where the new Service will be created
- * @param sr ServiceReference to OSGi Device that used as source of the information
- * for the creation of the device
- */
- private static void addServices(String id,Device devUPnP, ServiceReference sr) {
- UPnPDevice devOSGi = (UPnPDevice) Activator.bc.getService(sr);
-
- if( devOSGi == null) { //added by twa to prevent a null pointer exception
- Activator.logger.WARNING("UPnP Device that cotains serviceId="
- +id+" is deregistered from the framework while is exported");
- return;
- }
-
- UPnPService[] services = devOSGi.getServices();
- if(services==null || services.length==0)
- return;
-
-
-
- for (int i = 0; i < services.length; i++) {
- Service ser = new Service();
- devUPnP.addService(ser);
- ser.setServiceType(services[i].getType() );
- ser.setServiceID(services[i].getId());
- ser.setSCPDURL(id+"/service/"+i+"/gen-desc.xml");
- ser.setDescriptionURL(id+"/service/"+i+"/gen-desc.xml");
- ser.setControlURL(id+"/service/"+i+"/ctrl");
- ser.setEventSubURL(id+"/service/"+i+"/event");
-
- UPnPAction[] actions = services[i].getActions();
- for (int j = 0; j < actions.length; j++) {
- boolean valid=true;
- Action act = new Action(ser.getServiceNode());
- act.setName(actions[j].getName());
- ArgumentList al = new ArgumentList();
-
- String[] names=actions[j].getInputArgumentNames();
- if(names!=null){
- for (int k = 0; k < names.length; k++) {
- UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
- if(variable==null){
- /*
- * //TODO Create a stict and relaxed behavior of the base driver which
- * export as much it can or export only 100% complaint UPnPDevice service
- */
- Activator.logger.WARNING(
- "UPnP Device that cotains serviceId="+id+" contains the action "
- +actions[j].getName()+" with the Input argument "+names[k]
- +" not related to any UPnPStateVariable. Thus this action won't be exported");
- valid=false;
- break;
- }
- Argument a = new Argument();
- a.setDirection(Argument.IN);
- a.setName(names[k]);
- a.setRelatedStateVariableName(variable.getName());
- al.add(a);
- }
- }
- names=actions[j].getOutputArgumentNames();
- if(names!=null && valid){
- for (int k = 0; k < names.length; k++) {
- UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
- if(variable==null){
- /*
- * //TODO Create a stict and relaxed behavior of the base driver which
- * export as much it can or export only 100% complaint UPnPDevice service
- */
- Activator.logger.WARNING(
- "UPnP Device that cotains serviceId="+id+" contains the action "
- +actions[j].getName()+" with the Output argument "+names[k]
- +" not related to any UPnPStateVariable. Thus this action won't be exported");
- }
- Argument a = new Argument();
- a.setDirection(Argument.OUT);
- a.setName(names[k]);
- a.setRelatedStateVariableName(variable.getName());
- al.add(a);
- }
- }
- if(valid) {
- act.setArgumentList(al);
- ser.addAction(act);
- }
- }
-
- UPnPStateVariable[] vars = services[i].getStateVariables();
- for (int j = 0; j < vars.length; j++) {
- StateVariable var = new StateVariable();
- var.setDataType(vars[j].getUPnPDataType());
- var.setName(vars[j].getName());
- var.setSendEvents(vars[j].sendsEvents());
- String[] values = vars[j].getAllowedValues();
- if(values!=null){
- AllowedValueList avl = new AllowedValueList(values);
- var.setAllowedValueList(avl);
- }else if(vars[j].getMaximum()!= null){
- AllowedValueRange avr = new AllowedValueRange(
- vars[j].getMaximum(),
- vars[j].getMinimum(),
- vars[j].getStep()
- );
- var.setAllowedValueRange(avr);
- }
- if(vars[j].getDefaultValue()!=null)
- try {
- var.setDefaultValue(Converter.toString(
- vars[j].getDefaultValue(),vars[j].getUPnPDataType()
- ));
- } catch (Exception ignored) {
- }
- ser.addStateVariable(var);
- }
-
- Activator.bc.ungetService(sr);
- }
-
-
- }
-
- public static Device createCyberLinkDevice(ServiceReference sr){
- Node root = buildRootNode();
- Device devUPnP = buildRootDeviceNode(root,sr);
- return devUPnP;
- }
-}
+/*
+ * 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.basedriver.export;
+
+
+import org.cybergarage.upnp.Action;
+import org.cybergarage.upnp.AllowedValueList;
+import org.cybergarage.upnp.AllowedValueRange;
+import org.cybergarage.upnp.Argument;
+import org.cybergarage.upnp.ArgumentList;
+import org.cybergarage.upnp.Device;
+import org.cybergarage.upnp.RootDescription;
+import org.cybergarage.upnp.Service;
+import org.cybergarage.upnp.StateVariable;
+import org.cybergarage.upnp.xml.DeviceData;
+import org.cybergarage.xml.Node;
+
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.basedriver.Activator;
+import org.apache.felix.upnp.basedriver.util.Converter;
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class BuildDevice {
+
+ private static Node buildRootNode(){
+ Node root = new Node(RootDescription.ROOT_ELEMENT);
+ root.setAttribute("xmlns",RootDescription.ROOT_ELEMENT_NAMESPACE);
+ Node spec = new Node(RootDescription.SPECVERSION_ELEMENT);
+ Node maj =new Node(RootDescription.MAJOR_ELEMENT);
+ maj.setValue("1");
+ Node min =new Node(RootDescription.MINOR_ELEMENT);
+ min.setValue("0");
+ spec.addNode(maj);
+ spec.addNode(min);
+ root.addNode(spec);
+ return root;
+ }
+
+ private static Device buildRootDeviceNode(Node root,ServiceReference sr){
+ Node dev = new Node(Device.ELEM_NAME);
+ root.addNode(dev);
+ DeviceData dd = new DeviceData();
+ dd.setDescriptionURI("/gen-desc.xml");
+ dev.setUserData(dd);
+ Device devUPnP = new Device(root,dev);
+
+
+ Object aux = sr.getProperty(UPnPDevice.TYPE);
+ if(aux==null){
+ devUPnP.setDeviceType(null);
+ }else if(aux instanceof String){
+ devUPnP.setDeviceType((String) aux);
+ }else if(aux instanceof String[]){
+ //The property key UPnP.device.type should be a String
+ String[] v = (String[]) aux;
+ int maxindex=0;
+ int max=Integer.parseInt(v[0].substring(v[0].lastIndexOf(":")+1));
+ int tmp;
+ for (int i = 1; i < v.length; i++) {
+ tmp=Integer.parseInt(v[i].substring(v[i].lastIndexOf(":")+1));
+ if(max<tmp){
+ max=tmp;
+ maxindex=i;
+ }
+ }
+ devUPnP.setDeviceType(v[maxindex]);
+ }
+
+ devUPnP.setFriendlyName((String) sr.getProperty(UPnPDevice.FRIENDLY_NAME));
+ devUPnP.setManufacture((String) sr.getProperty(UPnPDevice.MANUFACTURER));
+ devUPnP.setManufactureURL((String) sr.getProperty(UPnPDevice.MANUFACTURER_URL));
+ devUPnP.setModelDescription((String) sr.getProperty(UPnPDevice.MODEL_DESCRIPTION));
+ devUPnP.setModelName((String) sr.getProperty(UPnPDevice.MODEL_NAME));
+ devUPnP.setModelNumber((String) sr.getProperty(UPnPDevice.MODEL_NUMBER));
+ devUPnP.setModelURL((String) sr.getProperty(UPnPDevice.MODEL_URL));
+ devUPnP.setSerialNumber((String) sr.getProperty(UPnPDevice.SERIAL_NUMBER));
+ devUPnP.setUDN((String) sr.getProperty(UPnPDevice.UDN));
+ devUPnP.setUPC((String) sr.getProperty(UPnPDevice.UPC));
+
+ devUPnP.setLocation("/gen-desc.xml");
+
+ addServices("",devUPnP,sr);
+ addDevices("",devUPnP,sr);
+ devUPnP.setPresentationURL((String) sr.getProperty(UPnPDevice.PRESENTATION_URL));
+
+ return devUPnP;
+ }
+
+ private static void addDevices(String id,Device devUPnP, ServiceReference sr) {
+
+ String[] udns=(String[]) sr.getProperty(UPnPDevice.CHILDREN_UDN);
+ if(udns==null) {
+ return;
+ }
+ for (int i = 0; i < udns.length; i++) {
+ try {
+ ServiceReference[] aux = Activator.bc.getServiceReferences(
+ UPnPDevice.class.getName(),"("+UPnPDevice.UDN+"="+udns[i]+")"
+ );
+ if(aux==null || aux.length == 0)
+ continue;
+ //id=+"/device/"+i; // twa: wrong in recursion
+ //buildDevice(id,devUPnP,aux[0]); // twa: wrong in recursion
+ String localId = new StringBuffer(id).append("/device/").append(i).toString();
+ buildDevice(localId,devUPnP,aux[0]); // twa: better
+ } catch (InvalidSyntaxException ignored) {}
+ }
+ }
+
+ private static void buildDevice(String id,Device parent, ServiceReference sr) {
+ Node dev = new Node(Device.ELEM_NAME);
+ DeviceData dd = new DeviceData();
+ dd.setDescriptionURI(id+"/gen-desc.xml");
+ dev.setUserData(dd);
+
+ Device devUPnP = new Device(dev);
+
+ devUPnP.setFriendlyName((String) sr.getProperty(UPnPDevice.FRIENDLY_NAME));
+ devUPnP.setManufacture((String) sr.getProperty(UPnPDevice.MANUFACTURER));
+ devUPnP.setManufactureURL((String) sr.getProperty(UPnPDevice.MANUFACTURER_URL));
+ devUPnP.setModelDescription((String) sr.getProperty(UPnPDevice.MODEL_DESCRIPTION));
+ devUPnP.setModelName((String) sr.getProperty(UPnPDevice.MODEL_NAME));
+ devUPnP.setModelNumber((String) sr.getProperty(UPnPDevice.MODEL_NUMBER));
+ devUPnP.setModelURL((String) sr.getProperty(UPnPDevice.MODEL_URL));
+ devUPnP.setSerialNumber((String) sr.getProperty(UPnPDevice.SERIAL_NUMBER));
+ devUPnP.setUDN((String) sr.getProperty(UPnPDevice.UDN));
+ devUPnP.setUPC((String) sr.getProperty(UPnPDevice.UPC));
+ devUPnP.setLocation(id+"/gen-desc.xml");
+
+ addServices(id,devUPnP,sr);
+ addDevices(id,devUPnP,sr);
+
+ parent.addDevice(devUPnP); // twa: essential!!!!!!!
+ devUPnP.setPresentationURL((String) sr.getProperty(UPnPDevice.PRESENTATION_URL));
+
+ }
+
+ /**
+ * Method used to create a new Service in CyberLink world without creating the XML
+ *
+ * @param id ServiceId
+ * @param devUPnP the CyberLink device that where the new Service will be created
+ * @param sr ServiceReference to OSGi Device that used as source of the information
+ * for the creation of the device
+ */
+ private static void addServices(String id,Device devUPnP, ServiceReference sr) {
+ UPnPDevice devOSGi = (UPnPDevice) Activator.bc.getService(sr);
+
+ if( devOSGi == null) { //added by twa to prevent a null pointer exception
+ Activator.logger.WARNING("UPnP Device that cotains serviceId="
+ +id+" is deregistered from the framework while is exported");
+ return;
+ }
+
+ UPnPService[] services = devOSGi.getServices();
+ if(services==null || services.length==0)
+ return;
+
+
+
+ for (int i = 0; i < services.length; i++) {
+ Service ser = new Service();
+ devUPnP.addService(ser);
+ ser.setServiceType(services[i].getType() );
+ ser.setServiceID(services[i].getId());
+ ser.setSCPDURL(id+"/service/"+i+"/gen-desc.xml");
+ ser.setDescriptionURL(id+"/service/"+i+"/gen-desc.xml");
+ ser.setControlURL(id+"/service/"+i+"/ctrl");
+ ser.setEventSubURL(id+"/service/"+i+"/event");
+
+ UPnPAction[] actions = services[i].getActions();
+ for (int j = 0; j < actions.length; j++) {
+ boolean valid=true;
+ Action act = new Action(ser.getServiceNode());
+ act.setName(actions[j].getName());
+ ArgumentList al = new ArgumentList();
+
+ String[] names=actions[j].getInputArgumentNames();
+ if(names!=null){
+ for (int k = 0; k < names.length; k++) {
+ UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
+ if(variable==null){
+ /*
+ * //TODO Create a stict and relaxed behavior of the base driver which
+ * export as much it can or export only 100% complaint UPnPDevice service
+ */
+ Activator.logger.WARNING(
+ "UPnP Device that cotains serviceId="+id+" contains the action "
+ +actions[j].getName()+" with the Input argument "+names[k]
+ +" not related to any UPnPStateVariable. Thus this action won't be exported");
+ valid=false;
+ break;
+ }
+ Argument a = new Argument();
+ a.setDirection(Argument.IN);
+ a.setName(names[k]);
+ a.setRelatedStateVariableName(variable.getName());
+ al.add(a);
+ }
+ }
+ names=actions[j].getOutputArgumentNames();
+ if(names!=null && valid){
+ for (int k = 0; k < names.length; k++) {
+ UPnPStateVariable variable = actions[j].getStateVariable(names[k]);
+ if(variable==null){
+ /*
+ * //TODO Create a stict and relaxed behavior of the base driver which
+ * export as much it can or export only 100% complaint UPnPDevice service
+ */
+ Activator.logger.WARNING(
+ "UPnP Device that cotains serviceId="+id+" contains the action "
+ +actions[j].getName()+" with the Output argument "+names[k]
+ +" not related to any UPnPStateVariable. Thus this action won't be exported");
+ }
+ Argument a = new Argument();
+ a.setDirection(Argument.OUT);
+ a.setName(names[k]);
+ a.setRelatedStateVariableName(variable.getName());
+ al.add(a);
+ }
+ }
+ if(valid) {
+ act.setArgumentList(al);
+ ser.addAction(act);
+ }
+ }
+
+ UPnPStateVariable[] vars = services[i].getStateVariables();
+ for (int j = 0; j < vars.length; j++) {
+ StateVariable var = new StateVariable();
+ var.setDataType(vars[j].getUPnPDataType());
+ var.setName(vars[j].getName());
+ var.setSendEvents(vars[j].sendsEvents());
+ String[] values = vars[j].getAllowedValues();
+ if(values!=null){
+ AllowedValueList avl = new AllowedValueList(values);
+ var.setAllowedValueList(avl);
+ }else if(vars[j].getMaximum()!= null){
+ AllowedValueRange avr = new AllowedValueRange(
+ vars[j].getMaximum(),
+ vars[j].getMinimum(),
+ vars[j].getStep()
+ );
+ var.setAllowedValueRange(avr);
+ }
+ if(vars[j].getDefaultValue()!=null)
+ try {
+ var.setDefaultValue(Converter.toString(
+ vars[j].getDefaultValue(),vars[j].getUPnPDataType()
+ ));
+ } catch (Exception ignored) {
+ }
+ ser.addStateVariable(var);
+ }
+
+ Activator.bc.ungetService(sr);
+ }
+
+
+ }
+
+ public static Device createCyberLinkDevice(ServiceReference sr){
+ Node root = buildRootNode();
+ Device devUPnP = buildRootDeviceNode(root,sr);
+ return devUPnP;
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/DeviceNode.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/DeviceNode.java
index 95429ae..71e8d81 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/DeviceNode.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/export/DeviceNode.java
@@ -1,183 +1,183 @@
-/*
- * 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.basedriver.export;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.upnp.UPnPDevice;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class DeviceNode {
-
- private ServiceReference sr;
- private boolean isRootNode;
- private String udn ;
- private boolean hasChild;
- private int numberOfSons;
- private ArrayList children;
- private DeviceNode parent;
-
- public DeviceNode(ServiceReference sr){
- //PRE: argument is always UPnPDevice service reference
- if (sr == null)
- throw new IllegalArgumentException("null is not a valid arg in DeviceNode constructor");
- this.sr = sr;
- udn = (String) sr.getProperty(UPnPDevice.UDN);
- parent=null;
- isRootNode = (sr.getProperty(UPnPDevice.PARENT_UDN) == null);
- String[] sons = ((String[]) sr.getProperty(UPnPDevice.CHILDREN_UDN));
- hasChild = (sons != null);
- if (hasChild) {
- children = new ArrayList();
- numberOfSons = sons.length;
- }
- }
-
- public ServiceReference getReference(){
- return sr;
- }
- public UPnPDevice getDevice(BundleContext ctx){
- return (UPnPDevice)ctx.getService(sr);
- }
-
- public void attach(DeviceNode node){
- if (node == null)
- throw new IllegalArgumentException("null is not a valid arg in DeviceNode.attach() method");
- node.parent = this;
- children.add(node);
- }
-
- public DeviceNode dethatch(String name){
- DeviceNode dn = this.search(name);
- if(dn==null)
- return null;
-
- if(dn.parent!=null){
- Iterator list = dn.parent.children.iterator();
- while (list.hasNext()) {
- DeviceNode x = (DeviceNode) list.next();
- if(x.udn.equals(name)){
- list.remove();
- break;
- }
- }
- }
- dn.parent=null;
- return dn;
- }
-
- public Collection getAllChildren(){
- if((this.children==null)||(this.children.size()==0))
- return null;
-
- Vector v = new Vector(this.children);
- Iterator list = this.children.iterator();
- while (list.hasNext()) {
- DeviceNode x = (DeviceNode) list.next();
- Collection c = x.getAllChildren();
- if(c==null) continue;
- v.addAll(c);
- }
- return v;
- }
-
- public Collection getChildren(){
- if((this.children==null)||(this.children.size()==0))
- return null;
- return this.children;
- }
-
- /**
- * @param name <code>String</code> that contain the UDN to look for
- * @return return a <code>DeviceNode</code> that have the UDN equals to name and <br>
- * if there is any <code>DeviceNode</code> with the proper UDN value return <code>null</code>
- */
- public DeviceNode search(String name){
- if (name == null)
- throw new IllegalArgumentException("null is not a valid arg in DeviceNode.search() method");
- if (name.equals(udn))
- return this;
- else if (hasChild){
- Iterator list = children.iterator();
- while (list.hasNext()){
- DeviceNode child = (DeviceNode)list.next();
- DeviceNode node = child.search(name);
- if (node != null) return node;
- }
- }
- return null;
- }
-
- /**
- *
- * @param udn
- * @return <code>true</code> if and only if this <code>DeviceNode</code>
- * contains a DeviceNode with UDN equals to passed argument or if
- * its USN is equal to passed argument
- */
- public boolean contains(String udn){
- return this.search(udn)!=null;
- }
-
- public boolean isComplete(){
- if (! hasChild) return true;
- if (numberOfSons != children.size())return false;
- Iterator list = children.iterator();
- while (list.hasNext()){
- DeviceNode child = (DeviceNode)list.next();
- if (! child.isComplete()) return false;
- }
- return true;
- }
-
- public DeviceNode isAttachable(DeviceNode node){
- if (node == null)
- throw new IllegalArgumentException("null is not a valid arg in DeviceNode.isAttachable() method");
- String parentUDN=(String) node.getReference().getProperty(UPnPDevice.PARENT_UDN);
- if(parentUDN==null) return null;
- return search(parentUDN);
- }
-
- public boolean isRoot(){
- return isRootNode;
- }
-
- public boolean equals(String udn){
- return this.udn.equals(udn);
- }
-
- public String toString(){
- return udn;
- }
-
- /**
- * @return true if and only
- * if the Device doesn't have embedded Device
- */
- public boolean isLeaf() {
- return !hasChild;
- }
-}
+/*
+ * 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.basedriver.export;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.upnp.UPnPDevice;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class DeviceNode {
+
+ private ServiceReference sr;
+ private boolean isRootNode;
+ private String udn ;
+ private boolean hasChild;
+ private int numberOfSons;
+ private ArrayList children;
+ private DeviceNode parent;
+
+ public DeviceNode(ServiceReference sr){
+ //PRE: argument is always UPnPDevice service reference
+ if (sr == null)
+ throw new IllegalArgumentException("null is not a valid arg in DeviceNode constructor");
+ this.sr = sr;
+ udn = (String) sr.getProperty(UPnPDevice.UDN);
+ parent=null;
+ isRootNode = (sr.getProperty(UPnPDevice.PARENT_UDN) == null);
+ String[] sons = ((String[]) sr.getProperty(UPnPDevice.CHILDREN_UDN));
+ hasChild = (sons != null);
+ if (hasChild) {
+ children = new ArrayList();
+ numberOfSons = sons.length;
+ }
+ }
+
+ public ServiceReference getReference(){
+ return sr;
+ }
+ public UPnPDevice getDevice(BundleContext ctx){
+ return (UPnPDevice)ctx.getService(sr);
+ }
+
+ public void attach(DeviceNode node){
+ if (node == null)
+ throw new IllegalArgumentException("null is not a valid arg in DeviceNode.attach() method");
+ node.parent = this;
+ children.add(node);
+ }
+
+ public DeviceNode dethatch(String name){
+ DeviceNode dn = this.search(name);
+ if(dn==null)
+ return null;
+
+ if(dn.parent!=null){
+ Iterator list = dn.parent.children.iterator();
+ while (list.hasNext()) {
+ DeviceNode x = (DeviceNode) list.next();
+ if(x.udn.equals(name)){
+ list.remove();
+ break;
+ }
+ }
+ }
+ dn.parent=null;
+ return dn;
+ }
+
+ public Collection getAllChildren(){
+ if((this.children==null)||(this.children.size()==0))
+ return null;
+
+ Vector v = new Vector(this.children);
+ Iterator list = this.children.iterator();
+ while (list.hasNext()) {
+ DeviceNode x = (DeviceNode) list.next();
+ Collection c = x.getAllChildren();
+ if(c==null) continue;
+ v.addAll(c);
+ }
+ return v;
+ }
+
+ public Collection getChildren(){
+ if((this.children==null)||(this.children.size()==0))
+ return null;
+ return this.children;
+ }
+
+ /**
+ * @param name <code>String</code> that contain the UDN to look for
+ * @return return a <code>DeviceNode</code> that have the UDN equals to name and <br>
+ * if there is any <code>DeviceNode</code> with the proper UDN value return <code>null</code>
+ */
+ public DeviceNode search(String name){
+ if (name == null)
+ throw new IllegalArgumentException("null is not a valid arg in DeviceNode.search() method");
+ if (name.equals(udn))
+ return this;
+ else if (hasChild){
+ Iterator list = children.iterator();
+ while (list.hasNext()){
+ DeviceNode child = (DeviceNode)list.next();
+ DeviceNode node = child.search(name);
+ if (node != null) return node;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param udn
+ * @return <code>true</code> if and only if this <code>DeviceNode</code>
+ * contains a DeviceNode with UDN equals to passed argument or if
+ * its USN is equal to passed argument
+ */
+ public boolean contains(String udn){
+ return this.search(udn)!=null;
+ }
+
+ public boolean isComplete(){
+ if (! hasChild) return true;
+ if (numberOfSons != children.size())return false;
+ Iterator list = children.iterator();
+ while (list.hasNext()){
+ DeviceNode child = (DeviceNode)list.next();
+ if (! child.isComplete()) return false;
+ }
+ return true;
+ }
+
+ public DeviceNode isAttachable(DeviceNode node){
+ if (node == null)
+ throw new IllegalArgumentException("null is not a valid arg in DeviceNode.isAttachable() method");
+ String parentUDN=(String) node.getReference().getProperty(UPnPDevice.PARENT_UDN);
+ if(parentUDN==null) return null;
+ return search(parentUDN);
+ }
+
+ public boolean isRoot(){
+ return isRootNode;
+ }
+
+ public boolean equals(String udn){
+ return this.udn.equals(udn);
+ }
+
+ public String toString(){
+ return udn;
+ }
+
+ /**
+ * @return true if and only
+ * if the Device doesn't have embedded Device
+ */
+ public boolean isLeaf() {
+ return !hasChild;
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/MyCtrlPoint.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/MyCtrlPoint.java
index a1dffb2..aab6986 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/MyCtrlPoint.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/MyCtrlPoint.java
@@ -1,917 +1,917 @@
-/*
- * 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.basedriver.importer.core;
-
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.cybergarage.http.HTTPRequest;
-import org.cybergarage.upnp.ControlPoint;
-import org.cybergarage.upnp.Device;
-import org.cybergarage.upnp.DeviceList;
-import org.cybergarage.upnp.Service;
-import org.cybergarage.upnp.ServiceList;
-import org.cybergarage.upnp.ServiceStateTable;
-import org.cybergarage.upnp.StateVariable;
-import org.cybergarage.upnp.device.NotifyListener;
-import org.cybergarage.upnp.device.SearchResponseListener;
-import org.cybergarage.upnp.event.NotifyRequest;
-import org.cybergarage.upnp.event.Property;
-import org.cybergarage.upnp.event.PropertyList;
-import org.cybergarage.upnp.ssdp.SSDPPacket;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPEventListener;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.basedriver.Activator;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.FirstMessage;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerModified;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerUnRegistration;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.StateChanged;
-import org.apache.felix.upnp.basedriver.importer.core.event.structs.NotifierQueue;
-import org.apache.felix.upnp.basedriver.importer.core.event.structs.SubscriptionQueue;
-import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPDeviceImpl;
-import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPServiceImpl;
-import org.apache.felix.upnp.basedriver.importer.util.ParseUSN;
-import org.apache.felix.upnp.basedriver.util.Converter;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class MyCtrlPoint extends ControlPoint
- implements
- NotifyListener,
- SearchResponseListener,
- ServiceListener
-{
- private BundleContext context;
- private Hashtable devices;//key UDN value OsgideviceInfo(Osgi)
- private SubscriptionQueue subQueue;
- private NotifierQueue notifierQueue;
-
- private final String UPNP_EVENT_LISTENER_FLTR =
- "(" + Constants.OBJECTCLASS + "=" + UPnPEventListener.class.getName() + ")";
- private final String UPNP_DEVICE_FLTR =
- "(" + Constants.OBJECTCLASS + "=" + UPnPDevice.class.getName() + ")";
- private final String EXPORT_FLTR =
- "(" + UPnPDevice.UPNP_EXPORT + "=*" + ")";
- private final String IMPORT_FLTR =
- "(" + org.apache.felix.upnp.basedriver.util.Constants.UPNP_IMPORT + "=*" + ")";
-
-
- public MyCtrlPoint(BundleContext context, SubscriptionQueue subQueue,
- NotifierQueue notifierQueue) {
- super();
- this.context = context;
- devices = new Hashtable();
- addNotifyListener(this);
- addSearchResponseListener(this);
- try {
- context.addServiceListener(this, UPNP_EVENT_LISTENER_FLTR);
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- this.subQueue = subQueue;
- this.notifierQueue = notifierQueue;
- }
-
- public void httpRequestRecieved(HTTPRequest httpReq) {
- Activator.logger.DEBUG("[Importer] httpRequestRecieved event");
- Activator.logger.PACKET(httpReq.toString());
-
- if (httpReq.isNotifyRequest() == true) {
- Activator.logger.DEBUG("[Importer] Notify Request");
- NotifyRequest notifyReq = new NotifyRequest(httpReq);
- String uuid = notifyReq.getSID();
- long seq = notifyReq.getSEQ();
- PropertyList props = notifyReq.getPropertyList();
-// int propCnt = props.size();
-// Hashtable hash = new Hashtable();
-// for (int n = 0; n < propCnt; n++) {
-// Property prop = props.getProperty(n);
-// String varName = prop.getName();
-// String varValue = prop.getValue();
-// hash.put(varName, varValue);
-// }
- newEventArrived(uuid, seq, props);
- httpReq.returnOK();
- return;
- }
-
- Activator.logger.DEBUG("BAD Request");
- httpReq.returnBadRequest();
-
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.cybergarage.upnp.ControlPoint#removeExpiredDevices()
- *
- */
- public void removeExpiredDevices() {
- DeviceList devList = getDeviceList();
- int devCnt = devList.size();
- for (int n = 0; n < devCnt; n++) {
- Device dev = devList.getDevice(n);
- if (dev.isExpired() == true) {
- Activator.logger.DEBUG("[Importer] Expired device:"+ dev.getFriendlyName());
- removeDevice(dev);
- removeOSGiExpireDevice(dev);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.cybergarage.upnp.device.NotifyListener#deviceNotifyReceived(org.cybergarage.upnp.ssdp.SSDPPacket)
- */
- public void deviceNotifyReceived(SSDPPacket ssdpPacket) {
- Activator.logger.DEBUG("[Importer] deviceNotifyReceived");
- Activator.logger.PACKET(ssdpPacket.toString());
- /*
- * if the packet is
- * NOTIFY or ISALIVE or *new* ROOT then create and register the UPnPDevice and
- * all the embeeded device too
- * DEVICE or SERVICE then if they already exist in OSGi do nothing otherwise I'll create and
- * register all the UPnPDevice need starting from the root device
- * *root* BYEBYE then I'll unregister it and all its children from OSGi Framework
- * *service* BYEBYE then I'll re-register the UPnPDevice that contain the service with the updated
- * properties
- * *device* BYEBYE then I'll re-register the UPnPDevice that contain the device with the updated
- * properties and also unregister the UPnPDevice that has left
- */
- String usn = ssdpPacket.getUSN();
- ParseUSN parseUSN = new ParseUSN(usn);
- String udn = parseUSN.getUDN();
-
- ServiceReference[] refs = null;
- String filter = "(&" + UPNP_DEVICE_FLTR + EXPORT_FLTR+ ")";
- try {
- refs = context.getServiceReferences(UPnPDevice.class.getName(), filter);
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- if (refs != null) {
- for (int i = 0; i < refs.length; i++) {
- UPnPDevice dev = (UPnPDevice) context.getService(refs[i]);
- Dictionary dic = dev.getDescriptions(null);
- if (((String) dic.get(UPnPDevice.UDN)).equals(udn)) {
- return;
- }
- }
- }
-
- if (ssdpPacket.isAlive()) {
-
- Activator.logger.DEBUG("[Importer] ssdpPacket.isAlive");
- if (devices.containsKey(udn)) {
- Activator.logger.DEBUG("[Importer] Device already discovered");
- if (parseUSN.isService()) {
- doServiceUpdating(udn,parseUSN.getServiceType());
- }
- } else {
- doDeviceRegistration(udn);
- }
-
- } else if (ssdpPacket.isByeBye()) {
- Activator.logger.DEBUG("[Importer] ssdpPacket.isByeBye");
-
- synchronized (devices) {
-
- if (devices.containsKey(udn)) {
- if (parseUSN.isDevice()) {
- Activator.logger.DEBUG("[Importer] parseUSN.isDevice ...unregistering all the children devices ");
-
- //unregistering all the children devices
- UPnPDeviceImpl dev = ((OSGiDeviceInfo) devices.get(udn)).getOSGiDevice();
- removeOSGiandUPnPDeviceHierarchy(dev);
-
- } else if (parseUSN.isService()) {
- Activator.logger.DEBUG("[Importer] parseUSN.isService ...registering modified device again ");
- /*
- * I have to unregister the UPnPDevice and register it again
- * with the updated properties
- */
- UPnPDeviceImpl device =
- ((OSGiDeviceInfo) devices.get(udn)).getOSGiDevice();
- ServiceRegistration registar =
- ((OSGiDeviceInfo) devices.get(udn)).getRegistration();
- String[] oldServicesID =
- (String[]) (device.getDescriptions(null).get(UPnPService.ID));
- String[] oldServiceType =
- (String[]) (device.getDescriptions(null).get(UPnPService.TYPE));
-
- Device cyberDevice = findDeviceCtrl(this, udn);
- Vector vec = new Vector();
- for (int i = 0; i < oldServiceType.length; i++) {
- Service ser = cyberDevice.getService(oldServicesID[i]);
- if (!(ser.getServiceType().equals(parseUSN.getServiceType())))
- {
- vec.add(oldServicesID[i]);
- }
- }
-
- //new serviceID
- String[] actualServicesID = new String[vec.size()];
- actualServicesID = (String[]) vec.toArray(new String[]{});
-
- //new serviceType
- String[] actualServiceType = new String[oldServiceType.length - 1];
- vec.clear();
- for (int i = 0; i < oldServiceType.length; i++) {
- if (!(oldServiceType[i].equals(parseUSN.getServiceType())))
- {
- vec.add(oldServiceType[i]);
- }
- }
- actualServiceType = (String[]) vec.toArray(new String[]{});
-
- //unrigistering and registering again with the new properties
- unregisterUPnPDevice(registar);
- device.setProperty(UPnPService.ID, actualServicesID);
- device.setProperty(UPnPService.TYPE, actualServiceType);
- registerUPnPDevice(null, device, device.getDescriptions(null));
- searchForListener(cyberDevice);
- }
- }
-
- }//synchronized(devices)
- } else {
- /*
- * if it is a service means that it has deleted when the
- * owner was unregister so I can skip this bye-bye
- *
- * //TODO Understand the comment
- *
- */
- }
- }
-
- public synchronized void removeOSGiandUPnPDeviceHierarchy(final UPnPDeviceImpl dev)
- {
- /*
- * remove all the UPnPDevice from the struct of local device recursively
- */
- final String udn = (String) dev.getDescriptions(null).get(UPnPDevice.UDN);
-
- if(devices.containsKey(udn) == false){
- Activator.logger.INFO("Device "+dev.getDescriptions(null).get(UPnPDevice.FRIENDLY_NAME)+"("+udn+") already removed");
- return;
- }
-
- String[] childrenUDN = (String[]) dev.getDescriptions(null).get(
- UPnPDevice.CHILDREN_UDN);
-
- if (childrenUDN == null) {
- //no children
- unregisterUPnPDevice(((OSGiDeviceInfo) devices.get(udn)).getRegistration());
- Activator.logger.INFO("Device "+dev.getDescriptions(null).get(UPnPDevice.FRIENDLY_NAME)+"("+udn+") deleted");
- devices.remove(udn);
- return;
- } else {
- for (int i = 0; i < childrenUDN.length; i++) {
- if (devices.get(childrenUDN[i]) != null) {
- removeOSGiandUPnPDeviceHierarchy(((OSGiDeviceInfo) devices.get(childrenUDN[i])).getOSGiDevice());
- }
- }
- unregisterUPnPDevice(((OSGiDeviceInfo) devices.get(udn)).getRegistration());
- Activator.logger.INFO("Device "+dev.getDescriptions(null).get(UPnPDevice.FRIENDLY_NAME)+"("+udn+") deleted");
- devices.remove(udn);
- }
- }
-
- public synchronized void removeOSGiExpireDevice(Device dev) {
- /*
- * unregistering root device with all its children device from OSGi
- * deleting root device and all its children from struct that conatin
- * a list of local device
- */
- removeOSGiandUPnPDeviceHierarchy(((OSGiDeviceInfo) devices.get(dev
- .getUDN())).getOSGiDevice());
- }
-
- public void registerUPnPDevice(Device dev, UPnPDeviceImpl upnpDev,
- Dictionary prop) {
- /*
- * registering the new Device as OSGi UPnPDevice and then add
- * ServiceRegistration and UPnPDevice reference to the hashtable
- * that contains local devices
- */
- if (prop == null && upnpDev == null) {
- UPnPDeviceImpl newDevice = new UPnPDeviceImpl(dev, context);
- ServiceRegistration registration =
- context.registerService(UPnPDevice.class.getName(),
- newDevice,
- newDevice.getDescriptions(null));
- OSGiDeviceInfo deviceInfo =
- new OSGiDeviceInfo(newDevice,registration);
-
- String udn = (String) ((newDevice.getDescriptions(null)).get(UPnPDevice.UDN));
- devices.put(udn, deviceInfo);
- } else {
- ServiceRegistration registration =
- context.registerService(UPnPDevice.class.getName(), upnpDev, prop);
- OSGiDeviceInfo deviceInfo =
- new OSGiDeviceInfo(upnpDev, registration);
- devices.put(upnpDev.getDescriptions(null).get(UPnPDevice.UDN),deviceInfo);
- }
- }
-
-
- public void unregisterUPnPDevice(ServiceRegistration registration) {
- registration.unregister();
-
- }
-
- public Device findDeviceCtrl(ControlPoint ctrl, String udn) {
- /*
- * this return the device looking in all the struct
- */
-
- DeviceList devList = getDeviceList();
- Device dev = null;
- int i = 0;
- while (i < devList.size() && (dev == null)) {
- if (devList.getDevice(i).getUDN().equals(udn)) {
- dev = devList.getDevice(i);
- return dev;
- }
- dev = findDevice(udn, devList.getDevice(i));
- i++;
- }
- return dev;
- }
-
- public Device findDevice(String udn, Device dev) {
- /*
- * look for the device if it exist, starting from the root on
- * cyberlink struct
- */
- DeviceList devList = dev.getDeviceList();
- Device aux = null;
- for (int i = 0; i < devList.size(); i++) {
- if (devList.getDevice(i).getUDN().equals(udn)) {
- return devList.getDevice(i);
- } else {
- if((aux = findDevice(udn, devList.getDevice(i))) != null)
- return aux;
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.cybergarage.upnp.device.SearchResponseListener#deviceSearchResponseReceived(org.cybergarage.upnp.ssdp.SSDPPacket)
- */
- public void deviceSearchResponseReceived(SSDPPacket ssdpPacket) {
- Activator.logger.DEBUG("[Importer] deviceSearchResponseReceived");
- Activator.logger.PACKET(ssdpPacket.toString());
-
- String usn = ssdpPacket.getUSN();
- ParseUSN parseUSN = new ParseUSN(usn);
- String udn = parseUSN.getUDN();
-
- ServiceReference[] refs = null;
-
- String filter = "(&" + UPNP_DEVICE_FLTR + EXPORT_FLTR + ")";
-
- try {
- refs = context.getServiceReferences(UPnPDevice.class.getName(),
- filter);
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
-
- if (refs != null) {
- for (int i = 0; i < refs.length; i++) {
- UPnPDevice dev = (UPnPDevice) context.getService(refs[i]);
- Dictionary dic = dev.getDescriptions(null);
- if (((String) dic.get(UPnPDevice.UDN)).equals(udn)) {
- return;
- }
- }
- }
-
- if (devices.containsKey(udn)) {
- Activator.logger.DEBUG("[Importer] Device already discovered");
- /*
- * Exist the registered device either in OSGi and
- * hashtable of local device
- */
- if (parseUSN.isService()) {
- doServiceUpdating(udn,parseUSN.getServiceType());
- }
- } else {
- doDeviceRegistration(udn);
- }
-
- }
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
- */
- public void serviceChanged(ServiceEvent event) {
- Activator.logger.DEBUG("[Importer] serviceChanged");
- Activator.logger.DEBUG("Event::"+event.toString());
-
- if (event.getType() == ServiceEvent.REGISTERED) {
- /* check new listener registration */
- ServiceReference serRef = event.getServiceReference();
- Object obj = serRef.getProperty(UPnPEventListener.UPNP_FILTER);
- /* obtain interested devices for the listener */
- ServiceReference[] devicesRefs = null;
- if (obj != null) {
- Filter filter = (Filter) obj;
- String filtra = filter.toString();
- /*
- * Avoid to implement the notification for device
- * that are not been created by BaseDriver
- */
- String newfilter = "(&" + filtra + IMPORT_FLTR + ")";
- //String newfilter = "(&" + filtra + "(!" + EXPORT_FLTR + ")" + ")";
- //System.out.println(newfilter);
- try {
- devicesRefs = context.getServiceReferences(UPnPDevice.class
- .getName(), newfilter);
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
-
- if (devicesRefs != null) {/*
- *
- * only if there is a compatibile device
- */
- Dictionary dic = new Hashtable();
- for (int i = 0; i < devicesRefs.length; i++) {
- UPnPDevice device = (UPnPDevice) context.getService(devicesRefs[i]);
- dic.put(UPnPDevice.ID, device.getDescriptions(null).get(UPnPDevice.UDN));
- dic.put(UPnPDevice.TYPE, device.getDescriptions(null).get(UPnPDevice.TYPE));
- UPnPService[] services = device.getServices();
- if (services != null) {
- for (int j = 0; j < services.length; j++) {
- dic.put(UPnPService.ID, services[j].getId());
- dic.put(UPnPService.TYPE, services[j].getType());
- //TODO add method boolean serviceEvented() so we can remove the below cycle
- UPnPStateVariable[] stateVars = services[j].getStateVariables();
- boolean hasEventedVars = false;
- for (int k = 0; k < stateVars.length && ! hasEventedVars; k++) {
- hasEventedVars = stateVars[k].sendsEvents();
- if (hasEventedVars) {
- if(filter.match(dic)){
- UPnPEventListener listener =
- (UPnPEventListener) context.getService(serRef);
- FirstMessage msg = new FirstMessage(
- ((UPnPServiceImpl) services[j]).getCyberService(),
- listener);
- subQueue.enqueue(msg);
- }
- }
- }
- }
- }
- context.ungetService(devicesRefs[i]);
- }
- }
- } else {/* obj==null (interested in all devices) */
- try {
- String newfilter = "(!" + EXPORT_FLTR+ ")";
- devicesRefs = context.getServiceReferences(UPnPDevice.class.getName(), newfilter);
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- if (devicesRefs != null) {/*
- *
- * only if there is a device
- */
-
- for (int i = 0; i < devicesRefs.length; i++) {
- UPnPDevice device = (UPnPDevice) context
- .getService(devicesRefs[i]);
- UPnPService[] services = device.getServices();
- if (services != null) {
- for (int j = 0; j < services.length; j++) {
- UPnPStateVariable[] stateVars = services[j]
- .getStateVariables();
- boolean bool = false;
- for (int k = 0; k < stateVars.length; k++) {
- bool = stateVars[k].sendsEvents();
- if (bool) {
- break;
- }
- }
- if (bool) {
- UPnPEventListener listener =
- (UPnPEventListener) context.getService(serRef);
- FirstMessage msg = new FirstMessage(
- ((UPnPServiceImpl) services[j]).getCyberService(),
- listener);
- subQueue.enqueue(msg);
- }
- }
- }
- context.ungetService(devicesRefs[i]);
- }
- }
- }
-
- } else if (event.getType() == ServiceEvent.MODIFIED) {
- Vector newServices = new Vector();
- ServiceReference serRef = event.getServiceReference();
- Filter filter = (Filter) serRef.getProperty(UPnPEventListener.UPNP_FILTER);
- UPnPEventListener listener = (UPnPEventListener) context.getService(serRef);
- ServiceReference[] devicesRefs = null;
-
- if (filter != null) {
- try {
- String filtra = filter.toString();
- String newfilter = "(&" + filtra + "(!" + EXPORT_FLTR + ")" + ")";
- devicesRefs = context.getServiceReferences(UPnPDevice.class.getName(), newfilter);
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- if (devicesRefs != null) {/*
- *
- * only if there is a compatibile device
- */
- Dictionary dic = new Hashtable();
- /*
- * look for the service that match
- */
- for (int i = 0; i < devicesRefs.length; i++) {
- UPnPDevice device = (UPnPDevice) context
- .getService(devicesRefs[i]);
- dic.put(UPnPDevice.ID, device.getDescriptions(null)
- .get(UPnPDevice.UDN));
- dic.put(UPnPDevice.TYPE, device.getDescriptions(null)
- .get(UPnPDevice.TYPE));
- UPnPService[] services = device.getServices();
-
- if (services != null) {
- for (int j = 0; j < services.length; j++) {
- dic.put(UPnPService.ID, services[j].getId());
- dic.put(UPnPService.TYPE, services[j].getType());
-
- UPnPStateVariable[] stateVars = services[j]
- .getStateVariables();
- boolean hasEventedVars = false;
- for (int k = 0; k < stateVars.length; k++) {
- hasEventedVars = stateVars[k].sendsEvents();
- if (hasEventedVars) {
- break;
- }
- }
- if (!hasEventedVars) {
- continue;
- }
-
- boolean bool = filter.match(dic);
- if (bool) {
- newServices
- .add(((UPnPServiceImpl) services[j])
- .getCyberService());
- }
- }//for services
- }//services ==null
- context.ungetService(devicesRefs[i]);
- }//for devicesRefs
- ListenerModified msg = new ListenerModified(newServices,
- listener);
- subQueue.enqueue(msg);
- }//devicesrefs !=null
- } else {//interrested in all devices
- try {
-
- String newfilter = "(!(" + UPnPDevice.UPNP_EXPORT + "=*"
- + ")" + ")";
- devicesRefs = context.getServiceReferences(UPnPDevice.class
- .getName(), newfilter);
- } catch (InvalidSyntaxException e) {
- e.printStackTrace();
- }
- if (devicesRefs != null) {/*
- * only if there is a device
- */
-
- for (int i = 0; i < devicesRefs.length; i++) {
- UPnPDevice device = (UPnPDevice) context
- .getService(devicesRefs[i]);
- UPnPService[] services = device.getServices();
- if (services != null) {
- for (int j = 0; j < services.length; j++) {
- UPnPStateVariable[] stateVars = services[j]
- .getStateVariables();
- boolean hasEventedVars = false;
- for (int k = 0; k < stateVars.length; k++) {
- hasEventedVars = stateVars[k].sendsEvents();
- if (hasEventedVars) {
- break;
- }
- }
- if (hasEventedVars) {
- newServices
- .add(((UPnPServiceImpl) services[j])
- .getCyberService());
- }//hasEventedvars
- }//for services
- }//services !=null
- context.ungetService(devicesRefs[i]);
- }//for devicesRefs
- subQueue
- .enqueue(new ListenerModified(newServices, listener));
- }//devicesRefs !=null
-
- }
-
- } else if (event.getType() == ServiceEvent.UNREGISTERING) {
- UPnPEventListener listener = (UPnPEventListener) context
- .getService(event.getServiceReference());
- if (listener != null) {
- ListenerUnRegistration msg = new ListenerUnRegistration(
- listener);
- subQueue.enqueue(msg);
- }
- context.ungetService(event.getServiceReference());
- }
- } /*
- * (non-Javadoc)
- *
- * @see org.cybergarage.upnp.event.EventListener#eventNotifyReceived(java.lang.String,
- * long, java.lang.String, java.lang.String)
- */
- /*
- * public void eventNotifyReceived(String uuid, long seq, String varName,
- * String value) { // TODO Auto-generated method stub StateChanged msg = new
- * StateChanged(uuid, varName, value,seq);,serviceFromSid(uuid)
- * notifierQueue.enqueue(msg); }
- */
-
- public Service serviceFromSid(String sid) {
- Enumeration e = devices.elements();
- Service cyberService = null;
- while (e.hasMoreElements()) {
- OSGiDeviceInfo deviceinfo = (OSGiDeviceInfo) e.nextElement();
- UPnPDevice device = deviceinfo.getOSGiDevice();
- UPnPService[] services = (UPnPService[]) device.getServices();
- UPnPServiceImpl[] servicesImpl = new UPnPServiceImpl[services.length];
- for (int i = 0; i < servicesImpl.length; i++) {
- servicesImpl[i] = (UPnPServiceImpl) services[i];
- }
- for (int i = 0; i < servicesImpl.length; i++) {
- cyberService = servicesImpl[i].getCyberService();
- boolean bool = cyberService.isSubscribed();
- if (bool) {
- if (cyberService.getSID().equals(sid)) {
- return cyberService;
- }
- }
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.felix.upnpbase.importer.MyEventListener#newEventArrived(java.lang.String,
- * long, java.util.Dictionary)
- */
- public void newEventArrived(String uuid, long seq, PropertyList props) {
- Activator.logger.DEBUG("[Importer] newEventArrived");
- Service service = serviceFromSid(uuid);
- if (service != null) {
- int size = props.size();
- Hashtable hash = new Hashtable();
- for (int i = 0; i < size; i++) {
- Property prop = props.getProperty(i);
- String varName = prop.getName();
- String varValue = prop.getValue();
- String upnpType = service.getStateVariable(varName).getDataType();
- Object valueObj;
- try {
- valueObj = Converter.parseString(varValue,upnpType);
- } catch (Exception e) {
- Activator.logger.ERROR("[Importer] Bad data value in Notify event: "
- +"var name="+varName +" value="+varValue +" type="+upnpType + "\n"+e);
- return;
- }
- hash.put(varName, valueObj);
- }
-
- Device device = service.getDevice();
- StateChanged msg = new StateChanged(uuid, seq, hash, device, service);
- notifierQueue.enqueue(msg);
- }
- }
-
- public void doServiceUpdating(String udn,String serviceType){
- Activator.logger.DEBUG("[Importer] check for service updating");
- OSGiDeviceInfo deviceinfo = (OSGiDeviceInfo) devices.get(udn);
- UPnPDeviceImpl device = deviceinfo.getOSGiDevice();
- boolean isSerPresent = device.existServiceType(serviceType);
- if (!isSerPresent) {
- /*
- * The serivice doesn't exist so it's new.
- * Find the udn of owner device and re-register the owner
- */
- ServiceRegistration registar =
- ((OSGiDeviceInfo) devices.remove(udn)).getRegistration();
- String[] oldServicesID =
- (String[]) device.getDescriptions(null).get(UPnPServiceImpl.ID);
- String[] oldServicesType =
- (String[]) device.getDescriptions(null).get(UPnPServiceImpl.TYPE);
-
- //to handle multiple instance of a serivice of the same type
- Device cyberDevice = findDeviceCtrl(this, udn);
- ServiceList serviceList = cyberDevice.getServiceList();
- ArrayList newServicesID = new ArrayList();
-
- for (int i = 0; i < serviceList.size(); i++) {
- if (serviceList.getService(i).getServiceType()
- .equals(serviceType))
- {
- newServicesID.add(serviceList.getService(i).getServiceID());
- }
- }
-
- //adding the new servicesID
- String[] currentServicesID =
- new String[(oldServicesID.length + newServicesID.size())];
- int endOld = 1;
- for (int i = 0; i < oldServicesID.length; i++) {
- currentServicesID[i] = oldServicesID[i];
- endOld++;
- }
- int j = 0;
- for (; endOld < currentServicesID.length; endOld++) {
- currentServicesID[endOld] = (String) newServicesID.get(j);
- j++;
- }
-
- //adding the new ServiceType
- String[] currentServicesType = new String[oldServicesType.length + 1];
- for (int i = 0; i < oldServicesType.length; i++) {
- currentServicesType[i] = oldServicesType[i];
- }
- currentServicesType[currentServicesType.length - 1] = serviceType;
-
-
- // unregistring the OSGi Device
- // and setting new properties
- unregisterUPnPDevice(registar);
- device.setProperty(UPnPService.ID, currentServicesID);
- device.setProperty(UPnPServiceImpl.TYPE,currentServicesType);
-
- //registering the service with the updated properties
- //TODO Check if null to the first paramaters is correct or it requires the reference to the cyberdomo upnp device
- registerUPnPDevice(null, device, device.getDescriptions(null));
- searchForListener(cyberDevice);
- }
- }
-
- public void doDeviceRegistration(String udn,boolean checkDouble){
- if(checkDouble){
- try {
- ServiceReference[] refs =
- Activator.bc.getServiceReferences(
- UPnPDevice.class.getName(),
- "(" + UPnPDevice.UDN + "=" + udn + ")"
- );
- if(refs!=null)
- return;
- } catch (InvalidSyntaxException ignored) {
- }
- }
- doDeviceRegistration(udn);
- }
-
- public synchronized void doDeviceRegistration(String udn){
- /*
- * registering the new device either if it is new root device or
- * a new embedded device
- */
- Device dev = findDeviceCtrl(this, udn);
- if (dev == null) {
- /*
- * In this case the UPnP SDK notifies us that a ssdp:alive has arrived,
- * but, because the no root device ssdp:alive packet has recieved by the UPnP SDK
- * no Device is present in the UPnP SDK device list.
- */
- Activator.logger.INFO("Cyberlink notified packet from UDN:" +udn+ ", but Device instance doesn't exist in Cyberlink structs! It will be Ignored");
- }else if(devices.containsKey(udn) == false) {
- Activator.logger.INFO("[Importer] registering UPnPDevice:"+dev.getFriendlyName()+"("+dev.getUDN()+")" );
- registerUPnPDevice(dev, null, null);
- searchForListener(dev);
- /*
- * now we can register all the device embedded device and service without
- * recieving the NOTIFY
- */
- //XXX Think about this choice
- for (Iterator i = dev.getDeviceList().iterator(); i.hasNext();) {
- Device d = (Device) i.next();
- doDeviceRegistration(d.getUDN(),true);
- }
- }else if(devices.containsKey(udn) == true) {
- Activator.logger.INFO("[Importer] UPnPDevice UDN::"+dev.getFriendlyName()+"("+dev.getUDN()+") already registered Skipping");
- }
- }
-
- public void searchForListener(Device device) {
- Activator.logger.DEBUG("[Importer] searching for UPnPEventListener");
- ServiceReference[] listeners = null;
- try {
- listeners = context.getServiceReferences(UPnPEventListener.class.getName(), null);
- } catch (InvalidSyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- if (listeners != null) {
- String deviceID = device.getUDN();
- String serviceID;
- String deviceType = device.getDeviceType();
- String serviceType;
- Hashtable hash = new Hashtable();
- hash.put(UPnPDevice.ID, deviceID);
- hash.put(UPnPDevice.TYPE, deviceType);
- ServiceList services = device.getServiceList();
- Vector eventedSers = new Vector();
-
- for (int i = 0; i < services.size(); i++) {
- Service service = (Service) services.elementAt(i);
- ServiceStateTable vars = service.getServiceStateTable();
- for (int j = 0; j < vars.size(); j++) {
- StateVariable var = (StateVariable) vars.elementAt(j);
- if (var.isSendEvents()) {
- eventedSers.add(service);
- break;
- }
- }
- }
-
- for (int i = 0; i < listeners.length; i++) {
- UPnPEventListener listener = (UPnPEventListener) context
- .getService(listeners[i]);
- Filter filter = (Filter) listeners[i]
- .getProperty(UPnPEventListener.UPNP_FILTER);
- if (filter == null) {
- for (int j = 0; j < eventedSers.size(); j++) {
- Service ser = (Service) eventedSers.elementAt(j);
- subQueue.enqueue(new FirstMessage(ser, listener));
- }
- } else {
- for (int j = 0; j < eventedSers.size(); j++) {
- Service ser = (Service) eventedSers.elementAt(j);
- serviceID = ser.getServiceID();
- serviceType = ser.getServiceType();
- hash.put(UPnPService.ID, serviceID);
- hash.put(UPnPService.TYPE, serviceType);
- boolean bool = filter.match(hash);
- if (bool) {
- subQueue.enqueue(new FirstMessage(ser, listener));
- }
-
- }
- }
-
- }
-
- }
- }
+/*
+ * 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.basedriver.importer.core;
+
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.cybergarage.http.HTTPRequest;
+import org.cybergarage.upnp.ControlPoint;
+import org.cybergarage.upnp.Device;
+import org.cybergarage.upnp.DeviceList;
+import org.cybergarage.upnp.Service;
+import org.cybergarage.upnp.ServiceList;
+import org.cybergarage.upnp.ServiceStateTable;
+import org.cybergarage.upnp.StateVariable;
+import org.cybergarage.upnp.device.NotifyListener;
+import org.cybergarage.upnp.device.SearchResponseListener;
+import org.cybergarage.upnp.event.NotifyRequest;
+import org.cybergarage.upnp.event.Property;
+import org.cybergarage.upnp.event.PropertyList;
+import org.cybergarage.upnp.ssdp.SSDPPacket;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPEventListener;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.basedriver.Activator;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.FirstMessage;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerModified;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerUnRegistration;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.StateChanged;
+import org.apache.felix.upnp.basedriver.importer.core.event.structs.NotifierQueue;
+import org.apache.felix.upnp.basedriver.importer.core.event.structs.SubscriptionQueue;
+import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPDeviceImpl;
+import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPServiceImpl;
+import org.apache.felix.upnp.basedriver.importer.util.ParseUSN;
+import org.apache.felix.upnp.basedriver.util.Converter;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class MyCtrlPoint extends ControlPoint
+ implements
+ NotifyListener,
+ SearchResponseListener,
+ ServiceListener
+{
+ private BundleContext context;
+ private Hashtable devices;//key UDN value OsgideviceInfo(Osgi)
+ private SubscriptionQueue subQueue;
+ private NotifierQueue notifierQueue;
+
+ private final String UPNP_EVENT_LISTENER_FLTR =
+ "(" + Constants.OBJECTCLASS + "=" + UPnPEventListener.class.getName() + ")";
+ private final String UPNP_DEVICE_FLTR =
+ "(" + Constants.OBJECTCLASS + "=" + UPnPDevice.class.getName() + ")";
+ private final String EXPORT_FLTR =
+ "(" + UPnPDevice.UPNP_EXPORT + "=*" + ")";
+ private final String IMPORT_FLTR =
+ "(" + org.apache.felix.upnp.basedriver.util.Constants.UPNP_IMPORT + "=*" + ")";
+
+
+ public MyCtrlPoint(BundleContext context, SubscriptionQueue subQueue,
+ NotifierQueue notifierQueue) {
+ super();
+ this.context = context;
+ devices = new Hashtable();
+ addNotifyListener(this);
+ addSearchResponseListener(this);
+ try {
+ context.addServiceListener(this, UPNP_EVENT_LISTENER_FLTR);
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+ this.subQueue = subQueue;
+ this.notifierQueue = notifierQueue;
+ }
+
+ public void httpRequestRecieved(HTTPRequest httpReq) {
+ Activator.logger.DEBUG("[Importer] httpRequestRecieved event");
+ Activator.logger.PACKET(httpReq.toString());
+
+ if (httpReq.isNotifyRequest() == true) {
+ Activator.logger.DEBUG("[Importer] Notify Request");
+ NotifyRequest notifyReq = new NotifyRequest(httpReq);
+ String uuid = notifyReq.getSID();
+ long seq = notifyReq.getSEQ();
+ PropertyList props = notifyReq.getPropertyList();
+// int propCnt = props.size();
+// Hashtable hash = new Hashtable();
+// for (int n = 0; n < propCnt; n++) {
+// Property prop = props.getProperty(n);
+// String varName = prop.getName();
+// String varValue = prop.getValue();
+// hash.put(varName, varValue);
+// }
+ newEventArrived(uuid, seq, props);
+ httpReq.returnOK();
+ return;
+ }
+
+ Activator.logger.DEBUG("BAD Request");
+ httpReq.returnBadRequest();
+
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cybergarage.upnp.ControlPoint#removeExpiredDevices()
+ *
+ */
+ public void removeExpiredDevices() {
+ DeviceList devList = getDeviceList();
+ int devCnt = devList.size();
+ for (int n = 0; n < devCnt; n++) {
+ Device dev = devList.getDevice(n);
+ if (dev.isExpired() == true) {
+ Activator.logger.DEBUG("[Importer] Expired device:"+ dev.getFriendlyName());
+ removeDevice(dev);
+ removeOSGiExpireDevice(dev);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cybergarage.upnp.device.NotifyListener#deviceNotifyReceived(org.cybergarage.upnp.ssdp.SSDPPacket)
+ */
+ public void deviceNotifyReceived(SSDPPacket ssdpPacket) {
+ Activator.logger.DEBUG("[Importer] deviceNotifyReceived");
+ Activator.logger.PACKET(ssdpPacket.toString());
+ /*
+ * if the packet is
+ * NOTIFY or ISALIVE or *new* ROOT then create and register the UPnPDevice and
+ * all the embeeded device too
+ * DEVICE or SERVICE then if they already exist in OSGi do nothing otherwise I'll create and
+ * register all the UPnPDevice need starting from the root device
+ * *root* BYEBYE then I'll unregister it and all its children from OSGi Framework
+ * *service* BYEBYE then I'll re-register the UPnPDevice that contain the service with the updated
+ * properties
+ * *device* BYEBYE then I'll re-register the UPnPDevice that contain the device with the updated
+ * properties and also unregister the UPnPDevice that has left
+ */
+ String usn = ssdpPacket.getUSN();
+ ParseUSN parseUSN = new ParseUSN(usn);
+ String udn = parseUSN.getUDN();
+
+ ServiceReference[] refs = null;
+ String filter = "(&" + UPNP_DEVICE_FLTR + EXPORT_FLTR+ ")";
+ try {
+ refs = context.getServiceReferences(UPnPDevice.class.getName(), filter);
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+ if (refs != null) {
+ for (int i = 0; i < refs.length; i++) {
+ UPnPDevice dev = (UPnPDevice) context.getService(refs[i]);
+ Dictionary dic = dev.getDescriptions(null);
+ if (((String) dic.get(UPnPDevice.UDN)).equals(udn)) {
+ return;
+ }
+ }
+ }
+
+ if (ssdpPacket.isAlive()) {
+
+ Activator.logger.DEBUG("[Importer] ssdpPacket.isAlive");
+ if (devices.containsKey(udn)) {
+ Activator.logger.DEBUG("[Importer] Device already discovered");
+ if (parseUSN.isService()) {
+ doServiceUpdating(udn,parseUSN.getServiceType());
+ }
+ } else {
+ doDeviceRegistration(udn);
+ }
+
+ } else if (ssdpPacket.isByeBye()) {
+ Activator.logger.DEBUG("[Importer] ssdpPacket.isByeBye");
+
+ synchronized (devices) {
+
+ if (devices.containsKey(udn)) {
+ if (parseUSN.isDevice()) {
+ Activator.logger.DEBUG("[Importer] parseUSN.isDevice ...unregistering all the children devices ");
+
+ //unregistering all the children devices
+ UPnPDeviceImpl dev = ((OSGiDeviceInfo) devices.get(udn)).getOSGiDevice();
+ removeOSGiandUPnPDeviceHierarchy(dev);
+
+ } else if (parseUSN.isService()) {
+ Activator.logger.DEBUG("[Importer] parseUSN.isService ...registering modified device again ");
+ /*
+ * I have to unregister the UPnPDevice and register it again
+ * with the updated properties
+ */
+ UPnPDeviceImpl device =
+ ((OSGiDeviceInfo) devices.get(udn)).getOSGiDevice();
+ ServiceRegistration registar =
+ ((OSGiDeviceInfo) devices.get(udn)).getRegistration();
+ String[] oldServicesID =
+ (String[]) (device.getDescriptions(null).get(UPnPService.ID));
+ String[] oldServiceType =
+ (String[]) (device.getDescriptions(null).get(UPnPService.TYPE));
+
+ Device cyberDevice = findDeviceCtrl(this, udn);
+ Vector vec = new Vector();
+ for (int i = 0; i < oldServiceType.length; i++) {
+ Service ser = cyberDevice.getService(oldServicesID[i]);
+ if (!(ser.getServiceType().equals(parseUSN.getServiceType())))
+ {
+ vec.add(oldServicesID[i]);
+ }
+ }
+
+ //new serviceID
+ String[] actualServicesID = new String[vec.size()];
+ actualServicesID = (String[]) vec.toArray(new String[]{});
+
+ //new serviceType
+ String[] actualServiceType = new String[oldServiceType.length - 1];
+ vec.clear();
+ for (int i = 0; i < oldServiceType.length; i++) {
+ if (!(oldServiceType[i].equals(parseUSN.getServiceType())))
+ {
+ vec.add(oldServiceType[i]);
+ }
+ }
+ actualServiceType = (String[]) vec.toArray(new String[]{});
+
+ //unrigistering and registering again with the new properties
+ unregisterUPnPDevice(registar);
+ device.setProperty(UPnPService.ID, actualServicesID);
+ device.setProperty(UPnPService.TYPE, actualServiceType);
+ registerUPnPDevice(null, device, device.getDescriptions(null));
+ searchForListener(cyberDevice);
+ }
+ }
+
+ }//synchronized(devices)
+ } else {
+ /*
+ * if it is a service means that it has deleted when the
+ * owner was unregister so I can skip this bye-bye
+ *
+ * //TODO Understand the comment
+ *
+ */
+ }
+ }
+
+ public synchronized void removeOSGiandUPnPDeviceHierarchy(final UPnPDeviceImpl dev)
+ {
+ /*
+ * remove all the UPnPDevice from the struct of local device recursively
+ */
+ final String udn = (String) dev.getDescriptions(null).get(UPnPDevice.UDN);
+
+ if(devices.containsKey(udn) == false){
+ Activator.logger.INFO("Device "+dev.getDescriptions(null).get(UPnPDevice.FRIENDLY_NAME)+"("+udn+") already removed");
+ return;
+ }
+
+ String[] childrenUDN = (String[]) dev.getDescriptions(null).get(
+ UPnPDevice.CHILDREN_UDN);
+
+ if (childrenUDN == null) {
+ //no children
+ unregisterUPnPDevice(((OSGiDeviceInfo) devices.get(udn)).getRegistration());
+ Activator.logger.INFO("Device "+dev.getDescriptions(null).get(UPnPDevice.FRIENDLY_NAME)+"("+udn+") deleted");
+ devices.remove(udn);
+ return;
+ } else {
+ for (int i = 0; i < childrenUDN.length; i++) {
+ if (devices.get(childrenUDN[i]) != null) {
+ removeOSGiandUPnPDeviceHierarchy(((OSGiDeviceInfo) devices.get(childrenUDN[i])).getOSGiDevice());
+ }
+ }
+ unregisterUPnPDevice(((OSGiDeviceInfo) devices.get(udn)).getRegistration());
+ Activator.logger.INFO("Device "+dev.getDescriptions(null).get(UPnPDevice.FRIENDLY_NAME)+"("+udn+") deleted");
+ devices.remove(udn);
+ }
+ }
+
+ public synchronized void removeOSGiExpireDevice(Device dev) {
+ /*
+ * unregistering root device with all its children device from OSGi
+ * deleting root device and all its children from struct that conatin
+ * a list of local device
+ */
+ removeOSGiandUPnPDeviceHierarchy(((OSGiDeviceInfo) devices.get(dev
+ .getUDN())).getOSGiDevice());
+ }
+
+ public void registerUPnPDevice(Device dev, UPnPDeviceImpl upnpDev,
+ Dictionary prop) {
+ /*
+ * registering the new Device as OSGi UPnPDevice and then add
+ * ServiceRegistration and UPnPDevice reference to the hashtable
+ * that contains local devices
+ */
+ if (prop == null && upnpDev == null) {
+ UPnPDeviceImpl newDevice = new UPnPDeviceImpl(dev, context);
+ ServiceRegistration registration =
+ context.registerService(UPnPDevice.class.getName(),
+ newDevice,
+ newDevice.getDescriptions(null));
+ OSGiDeviceInfo deviceInfo =
+ new OSGiDeviceInfo(newDevice,registration);
+
+ String udn = (String) ((newDevice.getDescriptions(null)).get(UPnPDevice.UDN));
+ devices.put(udn, deviceInfo);
+ } else {
+ ServiceRegistration registration =
+ context.registerService(UPnPDevice.class.getName(), upnpDev, prop);
+ OSGiDeviceInfo deviceInfo =
+ new OSGiDeviceInfo(upnpDev, registration);
+ devices.put(upnpDev.getDescriptions(null).get(UPnPDevice.UDN),deviceInfo);
+ }
+ }
+
+
+ public void unregisterUPnPDevice(ServiceRegistration registration) {
+ registration.unregister();
+
+ }
+
+ public Device findDeviceCtrl(ControlPoint ctrl, String udn) {
+ /*
+ * this return the device looking in all the struct
+ */
+
+ DeviceList devList = getDeviceList();
+ Device dev = null;
+ int i = 0;
+ while (i < devList.size() && (dev == null)) {
+ if (devList.getDevice(i).getUDN().equals(udn)) {
+ dev = devList.getDevice(i);
+ return dev;
+ }
+ dev = findDevice(udn, devList.getDevice(i));
+ i++;
+ }
+ return dev;
+ }
+
+ public Device findDevice(String udn, Device dev) {
+ /*
+ * look for the device if it exist, starting from the root on
+ * cyberlink struct
+ */
+ DeviceList devList = dev.getDeviceList();
+ Device aux = null;
+ for (int i = 0; i < devList.size(); i++) {
+ if (devList.getDevice(i).getUDN().equals(udn)) {
+ return devList.getDevice(i);
+ } else {
+ if((aux = findDevice(udn, devList.getDevice(i))) != null)
+ return aux;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.cybergarage.upnp.device.SearchResponseListener#deviceSearchResponseReceived(org.cybergarage.upnp.ssdp.SSDPPacket)
+ */
+ public void deviceSearchResponseReceived(SSDPPacket ssdpPacket) {
+ Activator.logger.DEBUG("[Importer] deviceSearchResponseReceived");
+ Activator.logger.PACKET(ssdpPacket.toString());
+
+ String usn = ssdpPacket.getUSN();
+ ParseUSN parseUSN = new ParseUSN(usn);
+ String udn = parseUSN.getUDN();
+
+ ServiceReference[] refs = null;
+
+ String filter = "(&" + UPNP_DEVICE_FLTR + EXPORT_FLTR + ")";
+
+ try {
+ refs = context.getServiceReferences(UPnPDevice.class.getName(),
+ filter);
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+
+ if (refs != null) {
+ for (int i = 0; i < refs.length; i++) {
+ UPnPDevice dev = (UPnPDevice) context.getService(refs[i]);
+ Dictionary dic = dev.getDescriptions(null);
+ if (((String) dic.get(UPnPDevice.UDN)).equals(udn)) {
+ return;
+ }
+ }
+ }
+
+ if (devices.containsKey(udn)) {
+ Activator.logger.DEBUG("[Importer] Device already discovered");
+ /*
+ * Exist the registered device either in OSGi and
+ * hashtable of local device
+ */
+ if (parseUSN.isService()) {
+ doServiceUpdating(udn,parseUSN.getServiceType());
+ }
+ } else {
+ doDeviceRegistration(udn);
+ }
+
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
+ */
+ public void serviceChanged(ServiceEvent event) {
+ Activator.logger.DEBUG("[Importer] serviceChanged");
+ Activator.logger.DEBUG("Event::"+event.toString());
+
+ if (event.getType() == ServiceEvent.REGISTERED) {
+ /* check new listener registration */
+ ServiceReference serRef = event.getServiceReference();
+ Object obj = serRef.getProperty(UPnPEventListener.UPNP_FILTER);
+ /* obtain interested devices for the listener */
+ ServiceReference[] devicesRefs = null;
+ if (obj != null) {
+ Filter filter = (Filter) obj;
+ String filtra = filter.toString();
+ /*
+ * Avoid to implement the notification for device
+ * that are not been created by BaseDriver
+ */
+ String newfilter = "(&" + filtra + IMPORT_FLTR + ")";
+ //String newfilter = "(&" + filtra + "(!" + EXPORT_FLTR + ")" + ")";
+ //System.out.println(newfilter);
+ try {
+ devicesRefs = context.getServiceReferences(UPnPDevice.class
+ .getName(), newfilter);
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+
+ if (devicesRefs != null) {/*
+ *
+ * only if there is a compatibile device
+ */
+ Dictionary dic = new Hashtable();
+ for (int i = 0; i < devicesRefs.length; i++) {
+ UPnPDevice device = (UPnPDevice) context.getService(devicesRefs[i]);
+ dic.put(UPnPDevice.ID, device.getDescriptions(null).get(UPnPDevice.UDN));
+ dic.put(UPnPDevice.TYPE, device.getDescriptions(null).get(UPnPDevice.TYPE));
+ UPnPService[] services = device.getServices();
+ if (services != null) {
+ for (int j = 0; j < services.length; j++) {
+ dic.put(UPnPService.ID, services[j].getId());
+ dic.put(UPnPService.TYPE, services[j].getType());
+ //TODO add method boolean serviceEvented() so we can remove the below cycle
+ UPnPStateVariable[] stateVars = services[j].getStateVariables();
+ boolean hasEventedVars = false;
+ for (int k = 0; k < stateVars.length && ! hasEventedVars; k++) {
+ hasEventedVars = stateVars[k].sendsEvents();
+ if (hasEventedVars) {
+ if(filter.match(dic)){
+ UPnPEventListener listener =
+ (UPnPEventListener) context.getService(serRef);
+ FirstMessage msg = new FirstMessage(
+ ((UPnPServiceImpl) services[j]).getCyberService(),
+ listener);
+ subQueue.enqueue(msg);
+ }
+ }
+ }
+ }
+ }
+ context.ungetService(devicesRefs[i]);
+ }
+ }
+ } else {/* obj==null (interested in all devices) */
+ try {
+ String newfilter = "(!" + EXPORT_FLTR+ ")";
+ devicesRefs = context.getServiceReferences(UPnPDevice.class.getName(), newfilter);
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+ if (devicesRefs != null) {/*
+ *
+ * only if there is a device
+ */
+
+ for (int i = 0; i < devicesRefs.length; i++) {
+ UPnPDevice device = (UPnPDevice) context
+ .getService(devicesRefs[i]);
+ UPnPService[] services = device.getServices();
+ if (services != null) {
+ for (int j = 0; j < services.length; j++) {
+ UPnPStateVariable[] stateVars = services[j]
+ .getStateVariables();
+ boolean bool = false;
+ for (int k = 0; k < stateVars.length; k++) {
+ bool = stateVars[k].sendsEvents();
+ if (bool) {
+ break;
+ }
+ }
+ if (bool) {
+ UPnPEventListener listener =
+ (UPnPEventListener) context.getService(serRef);
+ FirstMessage msg = new FirstMessage(
+ ((UPnPServiceImpl) services[j]).getCyberService(),
+ listener);
+ subQueue.enqueue(msg);
+ }
+ }
+ }
+ context.ungetService(devicesRefs[i]);
+ }
+ }
+ }
+
+ } else if (event.getType() == ServiceEvent.MODIFIED) {
+ Vector newServices = new Vector();
+ ServiceReference serRef = event.getServiceReference();
+ Filter filter = (Filter) serRef.getProperty(UPnPEventListener.UPNP_FILTER);
+ UPnPEventListener listener = (UPnPEventListener) context.getService(serRef);
+ ServiceReference[] devicesRefs = null;
+
+ if (filter != null) {
+ try {
+ String filtra = filter.toString();
+ String newfilter = "(&" + filtra + "(!" + EXPORT_FLTR + ")" + ")";
+ devicesRefs = context.getServiceReferences(UPnPDevice.class.getName(), newfilter);
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+ if (devicesRefs != null) {/*
+ *
+ * only if there is a compatibile device
+ */
+ Dictionary dic = new Hashtable();
+ /*
+ * look for the service that match
+ */
+ for (int i = 0; i < devicesRefs.length; i++) {
+ UPnPDevice device = (UPnPDevice) context
+ .getService(devicesRefs[i]);
+ dic.put(UPnPDevice.ID, device.getDescriptions(null)
+ .get(UPnPDevice.UDN));
+ dic.put(UPnPDevice.TYPE, device.getDescriptions(null)
+ .get(UPnPDevice.TYPE));
+ UPnPService[] services = device.getServices();
+
+ if (services != null) {
+ for (int j = 0; j < services.length; j++) {
+ dic.put(UPnPService.ID, services[j].getId());
+ dic.put(UPnPService.TYPE, services[j].getType());
+
+ UPnPStateVariable[] stateVars = services[j]
+ .getStateVariables();
+ boolean hasEventedVars = false;
+ for (int k = 0; k < stateVars.length; k++) {
+ hasEventedVars = stateVars[k].sendsEvents();
+ if (hasEventedVars) {
+ break;
+ }
+ }
+ if (!hasEventedVars) {
+ continue;
+ }
+
+ boolean bool = filter.match(dic);
+ if (bool) {
+ newServices
+ .add(((UPnPServiceImpl) services[j])
+ .getCyberService());
+ }
+ }//for services
+ }//services ==null
+ context.ungetService(devicesRefs[i]);
+ }//for devicesRefs
+ ListenerModified msg = new ListenerModified(newServices,
+ listener);
+ subQueue.enqueue(msg);
+ }//devicesrefs !=null
+ } else {//interrested in all devices
+ try {
+
+ String newfilter = "(!(" + UPnPDevice.UPNP_EXPORT + "=*"
+ + ")" + ")";
+ devicesRefs = context.getServiceReferences(UPnPDevice.class
+ .getName(), newfilter);
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+ if (devicesRefs != null) {/*
+ * only if there is a device
+ */
+
+ for (int i = 0; i < devicesRefs.length; i++) {
+ UPnPDevice device = (UPnPDevice) context
+ .getService(devicesRefs[i]);
+ UPnPService[] services = device.getServices();
+ if (services != null) {
+ for (int j = 0; j < services.length; j++) {
+ UPnPStateVariable[] stateVars = services[j]
+ .getStateVariables();
+ boolean hasEventedVars = false;
+ for (int k = 0; k < stateVars.length; k++) {
+ hasEventedVars = stateVars[k].sendsEvents();
+ if (hasEventedVars) {
+ break;
+ }
+ }
+ if (hasEventedVars) {
+ newServices
+ .add(((UPnPServiceImpl) services[j])
+ .getCyberService());
+ }//hasEventedvars
+ }//for services
+ }//services !=null
+ context.ungetService(devicesRefs[i]);
+ }//for devicesRefs
+ subQueue
+ .enqueue(new ListenerModified(newServices, listener));
+ }//devicesRefs !=null
+
+ }
+
+ } else if (event.getType() == ServiceEvent.UNREGISTERING) {
+ UPnPEventListener listener = (UPnPEventListener) context
+ .getService(event.getServiceReference());
+ if (listener != null) {
+ ListenerUnRegistration msg = new ListenerUnRegistration(
+ listener);
+ subQueue.enqueue(msg);
+ }
+ context.ungetService(event.getServiceReference());
+ }
+ } /*
+ * (non-Javadoc)
+ *
+ * @see org.cybergarage.upnp.event.EventListener#eventNotifyReceived(java.lang.String,
+ * long, java.lang.String, java.lang.String)
+ */
+ /*
+ * public void eventNotifyReceived(String uuid, long seq, String varName,
+ * String value) { // TODO Auto-generated method stub StateChanged msg = new
+ * StateChanged(uuid, varName, value,seq);,serviceFromSid(uuid)
+ * notifierQueue.enqueue(msg); }
+ */
+
+ public Service serviceFromSid(String sid) {
+ Enumeration e = devices.elements();
+ Service cyberService = null;
+ while (e.hasMoreElements()) {
+ OSGiDeviceInfo deviceinfo = (OSGiDeviceInfo) e.nextElement();
+ UPnPDevice device = deviceinfo.getOSGiDevice();
+ UPnPService[] services = (UPnPService[]) device.getServices();
+ UPnPServiceImpl[] servicesImpl = new UPnPServiceImpl[services.length];
+ for (int i = 0; i < servicesImpl.length; i++) {
+ servicesImpl[i] = (UPnPServiceImpl) services[i];
+ }
+ for (int i = 0; i < servicesImpl.length; i++) {
+ cyberService = servicesImpl[i].getCyberService();
+ boolean bool = cyberService.isSubscribed();
+ if (bool) {
+ if (cyberService.getSID().equals(sid)) {
+ return cyberService;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.felix.upnpbase.importer.MyEventListener#newEventArrived(java.lang.String,
+ * long, java.util.Dictionary)
+ */
+ public void newEventArrived(String uuid, long seq, PropertyList props) {
+ Activator.logger.DEBUG("[Importer] newEventArrived");
+ Service service = serviceFromSid(uuid);
+ if (service != null) {
+ int size = props.size();
+ Hashtable hash = new Hashtable();
+ for (int i = 0; i < size; i++) {
+ Property prop = props.getProperty(i);
+ String varName = prop.getName();
+ String varValue = prop.getValue();
+ String upnpType = service.getStateVariable(varName).getDataType();
+ Object valueObj;
+ try {
+ valueObj = Converter.parseString(varValue,upnpType);
+ } catch (Exception e) {
+ Activator.logger.ERROR("[Importer] Bad data value in Notify event: "
+ +"var name="+varName +" value="+varValue +" type="+upnpType + "\n"+e);
+ return;
+ }
+ hash.put(varName, valueObj);
+ }
+
+ Device device = service.getDevice();
+ StateChanged msg = new StateChanged(uuid, seq, hash, device, service);
+ notifierQueue.enqueue(msg);
+ }
+ }
+
+ public void doServiceUpdating(String udn,String serviceType){
+ Activator.logger.DEBUG("[Importer] check for service updating");
+ OSGiDeviceInfo deviceinfo = (OSGiDeviceInfo) devices.get(udn);
+ UPnPDeviceImpl device = deviceinfo.getOSGiDevice();
+ boolean isSerPresent = device.existServiceType(serviceType);
+ if (!isSerPresent) {
+ /*
+ * The serivice doesn't exist so it's new.
+ * Find the udn of owner device and re-register the owner
+ */
+ ServiceRegistration registar =
+ ((OSGiDeviceInfo) devices.remove(udn)).getRegistration();
+ String[] oldServicesID =
+ (String[]) device.getDescriptions(null).get(UPnPServiceImpl.ID);
+ String[] oldServicesType =
+ (String[]) device.getDescriptions(null).get(UPnPServiceImpl.TYPE);
+
+ //to handle multiple instance of a serivice of the same type
+ Device cyberDevice = findDeviceCtrl(this, udn);
+ ServiceList serviceList = cyberDevice.getServiceList();
+ ArrayList newServicesID = new ArrayList();
+
+ for (int i = 0; i < serviceList.size(); i++) {
+ if (serviceList.getService(i).getServiceType()
+ .equals(serviceType))
+ {
+ newServicesID.add(serviceList.getService(i).getServiceID());
+ }
+ }
+
+ //adding the new servicesID
+ String[] currentServicesID =
+ new String[(oldServicesID.length + newServicesID.size())];
+ int endOld = 1;
+ for (int i = 0; i < oldServicesID.length; i++) {
+ currentServicesID[i] = oldServicesID[i];
+ endOld++;
+ }
+ int j = 0;
+ for (; endOld < currentServicesID.length; endOld++) {
+ currentServicesID[endOld] = (String) newServicesID.get(j);
+ j++;
+ }
+
+ //adding the new ServiceType
+ String[] currentServicesType = new String[oldServicesType.length + 1];
+ for (int i = 0; i < oldServicesType.length; i++) {
+ currentServicesType[i] = oldServicesType[i];
+ }
+ currentServicesType[currentServicesType.length - 1] = serviceType;
+
+
+ // unregistring the OSGi Device
+ // and setting new properties
+ unregisterUPnPDevice(registar);
+ device.setProperty(UPnPService.ID, currentServicesID);
+ device.setProperty(UPnPServiceImpl.TYPE,currentServicesType);
+
+ //registering the service with the updated properties
+ //TODO Check if null to the first paramaters is correct or it requires the reference to the cyberdomo upnp device
+ registerUPnPDevice(null, device, device.getDescriptions(null));
+ searchForListener(cyberDevice);
+ }
+ }
+
+ public void doDeviceRegistration(String udn,boolean checkDouble){
+ if(checkDouble){
+ try {
+ ServiceReference[] refs =
+ Activator.bc.getServiceReferences(
+ UPnPDevice.class.getName(),
+ "(" + UPnPDevice.UDN + "=" + udn + ")"
+ );
+ if(refs!=null)
+ return;
+ } catch (InvalidSyntaxException ignored) {
+ }
+ }
+ doDeviceRegistration(udn);
+ }
+
+ public synchronized void doDeviceRegistration(String udn){
+ /*
+ * registering the new device either if it is new root device or
+ * a new embedded device
+ */
+ Device dev = findDeviceCtrl(this, udn);
+ if (dev == null) {
+ /*
+ * In this case the UPnP SDK notifies us that a ssdp:alive has arrived,
+ * but, because the no root device ssdp:alive packet has recieved by the UPnP SDK
+ * no Device is present in the UPnP SDK device list.
+ */
+ Activator.logger.INFO("Cyberlink notified packet from UDN:" +udn+ ", but Device instance doesn't exist in Cyberlink structs! It will be Ignored");
+ }else if(devices.containsKey(udn) == false) {
+ Activator.logger.INFO("[Importer] registering UPnPDevice:"+dev.getFriendlyName()+"("+dev.getUDN()+")" );
+ registerUPnPDevice(dev, null, null);
+ searchForListener(dev);
+ /*
+ * now we can register all the device embedded device and service without
+ * recieving the NOTIFY
+ */
+ //XXX Think about this choice
+ for (Iterator i = dev.getDeviceList().iterator(); i.hasNext();) {
+ Device d = (Device) i.next();
+ doDeviceRegistration(d.getUDN(),true);
+ }
+ }else if(devices.containsKey(udn) == true) {
+ Activator.logger.INFO("[Importer] UPnPDevice UDN::"+dev.getFriendlyName()+"("+dev.getUDN()+") already registered Skipping");
+ }
+ }
+
+ public void searchForListener(Device device) {
+ Activator.logger.DEBUG("[Importer] searching for UPnPEventListener");
+ ServiceReference[] listeners = null;
+ try {
+ listeners = context.getServiceReferences(UPnPEventListener.class.getName(), null);
+ } catch (InvalidSyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (listeners != null) {
+ String deviceID = device.getUDN();
+ String serviceID;
+ String deviceType = device.getDeviceType();
+ String serviceType;
+ Hashtable hash = new Hashtable();
+ hash.put(UPnPDevice.ID, deviceID);
+ hash.put(UPnPDevice.TYPE, deviceType);
+ ServiceList services = device.getServiceList();
+ Vector eventedSers = new Vector();
+
+ for (int i = 0; i < services.size(); i++) {
+ Service service = (Service) services.elementAt(i);
+ ServiceStateTable vars = service.getServiceStateTable();
+ for (int j = 0; j < vars.size(); j++) {
+ StateVariable var = (StateVariable) vars.elementAt(j);
+ if (var.isSendEvents()) {
+ eventedSers.add(service);
+ break;
+ }
+ }
+ }
+
+ for (int i = 0; i < listeners.length; i++) {
+ UPnPEventListener listener = (UPnPEventListener) context
+ .getService(listeners[i]);
+ Filter filter = (Filter) listeners[i]
+ .getProperty(UPnPEventListener.UPNP_FILTER);
+ if (filter == null) {
+ for (int j = 0; j < eventedSers.size(); j++) {
+ Service ser = (Service) eventedSers.elementAt(j);
+ subQueue.enqueue(new FirstMessage(ser, listener));
+ }
+ } else {
+ for (int j = 0; j < eventedSers.size(); j++) {
+ Service ser = (Service) eventedSers.elementAt(j);
+ serviceID = ser.getServiceID();
+ serviceType = ser.getServiceType();
+ hash.put(UPnPService.ID, serviceID);
+ hash.put(UPnPService.TYPE, serviceType);
+ boolean bool = filter.match(hash);
+ if (bool) {
+ subQueue.enqueue(new FirstMessage(ser, listener));
+ }
+
+ }
+ }
+
+ }
+
+ }
+ }
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/OSGiDeviceInfo.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/OSGiDeviceInfo.java
index 3003ea3..0bd8886 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/OSGiDeviceInfo.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/OSGiDeviceInfo.java
@@ -1,49 +1,49 @@
-/*
- * 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.basedriver.importer.core;
-
-
-import org.osgi.framework.ServiceRegistration;
-
-import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPDeviceImpl;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class OSGiDeviceInfo {
- private UPnPDeviceImpl osgidevice;
- private ServiceRegistration registration;
-
- /**
- * @param osgidevice UPnPDeviceImpl a Service
- * @param registration Serviceregistration of the UPnPDevice service
- */
- public OSGiDeviceInfo(UPnPDeviceImpl osgidevice,
- ServiceRegistration registration) {
- this.osgidevice = osgidevice;
- this.registration = registration;
- }
- public UPnPDeviceImpl getOSGiDevice(){
- return osgidevice;
- }
- public ServiceRegistration getRegistration(){
- return registration;
- }
-}
+/*
+ * 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.basedriver.importer.core;
+
+
+import org.osgi.framework.ServiceRegistration;
+
+import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPDeviceImpl;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class OSGiDeviceInfo {
+ private UPnPDeviceImpl osgidevice;
+ private ServiceRegistration registration;
+
+ /**
+ * @param osgidevice UPnPDeviceImpl a Service
+ * @param registration Serviceregistration of the UPnPDevice service
+ */
+ public OSGiDeviceInfo(UPnPDeviceImpl osgidevice,
+ ServiceRegistration registration) {
+ this.osgidevice = osgidevice;
+ this.registration = registration;
+ }
+ public UPnPDeviceImpl getOSGiDevice(){
+ return osgidevice;
+ }
+ public ServiceRegistration getRegistration(){
+ return registration;
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/FirstMessage.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/FirstMessage.java
index 140b15e..5f679c4 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/FirstMessage.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/FirstMessage.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.basedriver.importer.core.event.message;
-
-import org.cybergarage.upnp.Device;
-import org.cybergarage.upnp.Service;
-
-import org.osgi.service.upnp.UPnPEventListener;
-
-/**
- * This class rappresent a message that is equeued for the Suscriber.<br>
- * This is message is related to a registration of listener for a
- * CyberLink Service during the registering of the UPnP Event Listener
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-
-public class FirstMessage {
- private Service service;
- private UPnPEventListener listener;
- private String sid;
- private Device device;
-
- public FirstMessage(Service service, UPnPEventListener listener) {
- this.service = service;
- this.listener = listener;
- this.sid = "";
- this.device = service.getDevice();
- }
- public Service getService() {
- return service;
- }
- public UPnPEventListener getListener() {
- return listener;
- }
- public void setSid(String sid) {
- this.sid = sid;
- }
- public String getSid() {
- return sid;
- }
- public Device getDevice() {
- return device;
- }
- public String getDeviceID(){
- return device.getUDN();
- }
- public String getServiceID(){
- return service.getServiceID();
- }
+/*
+ * 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.basedriver.importer.core.event.message;
+
+import org.cybergarage.upnp.Device;
+import org.cybergarage.upnp.Service;
+
+import org.osgi.service.upnp.UPnPEventListener;
+
+/**
+ * This class rappresent a message that is equeued for the Suscriber.<br>
+ * This is message is related to a registration of listener for a
+ * CyberLink Service during the registering of the UPnP Event Listener
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+
+public class FirstMessage {
+ private Service service;
+ private UPnPEventListener listener;
+ private String sid;
+ private Device device;
+
+ public FirstMessage(Service service, UPnPEventListener listener) {
+ this.service = service;
+ this.listener = listener;
+ this.sid = "";
+ this.device = service.getDevice();
+ }
+ public Service getService() {
+ return service;
+ }
+ public UPnPEventListener getListener() {
+ return listener;
+ }
+ public void setSid(String sid) {
+ this.sid = sid;
+ }
+ public String getSid() {
+ return sid;
+ }
+ public Device getDevice() {
+ return device;
+ }
+ public String getDeviceID(){
+ return device.getUDN();
+ }
+ public String getServiceID(){
+ return service.getServiceID();
+ }
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/ListenerModified.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/ListenerModified.java
index cf197bb..be5a1ff 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/ListenerModified.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/ListenerModified.java
@@ -1,45 +1,45 @@
-/*
- * 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.basedriver.importer.core.event.message;
-
-import java.util.Vector;
-
-import org.osgi.service.upnp.UPnPEventListener;
-
-/**
- * Message that is euqueued for Suscriber, only when a UPnPEventListener changes
- * his properties
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class ListenerModified {
- private Vector newServices;
- private UPnPEventListener listener;
- public ListenerModified(Vector newServices,UPnPEventListener listener){
- this.newServices=newServices;
- this.listener=listener;
- }
- public UPnPEventListener getListener(){
- return listener;
- }
- public Vector getNewServices(){
- return newServices;
- }
-}
+/*
+ * 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.basedriver.importer.core.event.message;
+
+import java.util.Vector;
+
+import org.osgi.service.upnp.UPnPEventListener;
+
+/**
+ * Message that is euqueued for Suscriber, only when a UPnPEventListener changes
+ * his properties
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class ListenerModified {
+ private Vector newServices;
+ private UPnPEventListener listener;
+ public ListenerModified(Vector newServices,UPnPEventListener listener){
+ this.newServices=newServices;
+ this.listener=listener;
+ }
+ public UPnPEventListener getListener(){
+ return listener;
+ }
+ public Vector getNewServices(){
+ return newServices;
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/ListenerUnRegistration.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/ListenerUnRegistration.java
index ad34f69..ea36439 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/ListenerUnRegistration.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/ListenerUnRegistration.java
@@ -1,39 +1,39 @@
-/*
- * 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.basedriver.importer.core.event.message;
-
-import org.osgi.service.upnp.UPnPEventListener;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class ListenerUnRegistration {
- private UPnPEventListener listener;
- /**
- * @param listener
- */
- public ListenerUnRegistration(UPnPEventListener listener) {
- super();
- this.listener = listener;
- }
- public UPnPEventListener getListener() {
- return listener;
- }
-}
+/*
+ * 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.basedriver.importer.core.event.message;
+
+import org.osgi.service.upnp.UPnPEventListener;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class ListenerUnRegistration {
+ private UPnPEventListener listener;
+ /**
+ * @param listener
+ */
+ public ListenerUnRegistration(UPnPEventListener listener) {
+ super();
+ this.listener = listener;
+ }
+ public UPnPEventListener getListener() {
+ return listener;
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/SidExipired.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/SidExipired.java
index a8b5ff7..ab0cfa5 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/SidExipired.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/SidExipired.java
@@ -1,44 +1,44 @@
-/*
- * 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.basedriver.importer.core.event.message;
-
-import org.cybergarage.upnp.Service;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class SidExipired {
-private String sid;
-private Service service;
-/**
- * @param sid
- */
- public SidExipired(String sid,Service service) {
- super();
- this.sid = sid;
- this.service=service;
- }
- public String getSid(){
- return sid;
- }
- public Service getService(){
- return service;
- }
-}
+/*
+ * 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.basedriver.importer.core.event.message;
+
+import org.cybergarage.upnp.Service;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class SidExipired {
+private String sid;
+private Service service;
+/**
+ * @param sid
+ */
+ public SidExipired(String sid,Service service) {
+ super();
+ this.sid = sid;
+ this.service=service;
+ }
+ public String getSid(){
+ return sid;
+ }
+ public Service getService(){
+ return service;
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/StateChanged.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/StateChanged.java
index 9e0bfff..e29a76c 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/StateChanged.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/message/StateChanged.java
@@ -1,80 +1,80 @@
-/*
- * 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.basedriver.importer.core.event.message;
-
-import java.util.Dictionary;
-
-import org.cybergarage.upnp.Device;
-import org.cybergarage.upnp.Service;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class StateChanged {
- private String sid;
- private Dictionary dic;
- private long seq;
- private Service service;
- private Device device;
- /**
- * @param sid
- * @param dic
- * @param varName
- * @param varValue
- */
- public StateChanged(String sid, long seq, Dictionary dic, Device device,
- Service service) {
- super();
- this.sid = sid;
- /*
- * this.varName = varName; this.varValue = varValue;
- */
- this.dic = dic;
- /* dic.put(this.varName, this.varValue); */
- //this.service=service;
- this.seq = seq;
- this.device = device;
- this.service = service;
- }
-
- public Dictionary getDictionary() {
- return dic;
- }
- public String getSid() {
- return sid;
- }
- /*
- * public String getVarName() { return varName; } public String
- * getVarValue() { return varValue; }
- */
- public long getSeq() {
- return seq;
- }
- /*
- * public Service getService(){ return service; }
- *
- */
- public String getDeviceID() {
- return device.getUDN();
- }
- public String getServiceID() {
- return service.getServiceID();
- }
+/*
+ * 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.basedriver.importer.core.event.message;
+
+import java.util.Dictionary;
+
+import org.cybergarage.upnp.Device;
+import org.cybergarage.upnp.Service;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class StateChanged {
+ private String sid;
+ private Dictionary dic;
+ private long seq;
+ private Service service;
+ private Device device;
+ /**
+ * @param sid
+ * @param dic
+ * @param varName
+ * @param varValue
+ */
+ public StateChanged(String sid, long seq, Dictionary dic, Device device,
+ Service service) {
+ super();
+ this.sid = sid;
+ /*
+ * this.varName = varName; this.varValue = varValue;
+ */
+ this.dic = dic;
+ /* dic.put(this.varName, this.varValue); */
+ //this.service=service;
+ this.seq = seq;
+ this.device = device;
+ this.service = service;
+ }
+
+ public Dictionary getDictionary() {
+ return dic;
+ }
+ public String getSid() {
+ return sid;
+ }
+ /*
+ * public String getVarName() { return varName; } public String
+ * getVarValue() { return varValue; }
+ */
+ public long getSeq() {
+ return seq;
+ }
+ /*
+ * public Service getService(){ return service; }
+ *
+ */
+ public String getDeviceID() {
+ return device.getUDN();
+ }
+ public String getServiceID() {
+ return service.getServiceID();
+ }
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Listener2Sids.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Listener2Sids.java
index f721797..f5cddfa 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Listener2Sids.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Listener2Sids.java
@@ -1,58 +1,58 @@
-/*
- * 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.basedriver.importer.core.event.structs;
-
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.osgi.service.upnp.UPnPEventListener;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class Listener2Sids {
- private Hashtable listenerSid;
-
- public Listener2Sids() {
- this.listenerSid = new Hashtable();
- }
-
- public void put(UPnPEventListener listener, String sid) {
- if (!listenerSid.containsKey(listener)) {
- Vector vec = new Vector();
- vec.add(sid);
- listenerSid.put(listener, vec);
- } else {
- Vector vec = (Vector) listenerSid.get(listener);
- if (!vec.contains(sid)) {
- vec.add(sid);
- }
- }
- }
-
- public final void remove(UPnPEventListener listener) {
- listenerSid.remove(listener);
- }
-
- public final Vector get(UPnPEventListener listener) {
- return ((Vector) listenerSid.get(listener));
- }
-}
-
+/*
+ * 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.basedriver.importer.core.event.structs;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.osgi.service.upnp.UPnPEventListener;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class Listener2Sids {
+ private Hashtable listenerSid;
+
+ public Listener2Sids() {
+ this.listenerSid = new Hashtable();
+ }
+
+ public void put(UPnPEventListener listener, String sid) {
+ if (!listenerSid.containsKey(listener)) {
+ Vector vec = new Vector();
+ vec.add(sid);
+ listenerSid.put(listener, vec);
+ } else {
+ Vector vec = (Vector) listenerSid.get(listener);
+ if (!vec.contains(sid)) {
+ vec.add(sid);
+ }
+ }
+ }
+
+ public final void remove(UPnPEventListener listener) {
+ listenerSid.remove(listener);
+ }
+
+ public final Vector get(UPnPEventListener listener) {
+ return ((Vector) listenerSid.get(listener));
+ }
+}
+
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Monitor.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Monitor.java
index ae08a49..095a473 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Monitor.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Monitor.java
@@ -1,234 +1,234 @@
-/*
- * 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.basedriver.importer.core.event.structs;
-
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.cybergarage.upnp.Service;
-
-import org.osgi.service.upnp.UPnPEventListener;
-
-import org.apache.felix.upnp.basedriver.importer.core.MyCtrlPoint;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.FirstMessage;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerModified;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class Monitor {
- private Hashtable sidStateVars;
- private SidsListenersMaps sidListSid;
-
- public Monitor() {
- this.sidListSid = new SidsListenersMaps();
- this.sidStateVars = new Hashtable();
- }
-
- public synchronized void putStateVars(String sid, StateVarsToNotify vars) {
- sidStateVars.put(sid, vars);
- Vector listeners = (Vector) sidListSid.getListenersFromSid(sid);
- if (listeners != null) {
- sidListSid.updateListeners(sid, vars.getDeviceID(), vars.getServiceID(), vars.getDictionary());
- sidListSid.setAlreadyFirst(sid,true);
- } else {
- sidListSid.setAlreadyFirst(sid, false);
- }
- }
- public synchronized void updateStateVars(String sid, Dictionary dic) {
- StateVarsToNotify vars = (StateVarsToNotify) sidStateVars.get(sid);
- if (vars != null) {
- vars.updateDic(dic);
- if (sidListSid.getAlreadyFirst(sid)) {
- /*
- * Sends only the changed StateVariable
- */
- sidListSid.updateListeners(sid,
- vars.getDeviceID(), vars.getServiceID(),
- dic);
- } else {
- /*
- * Sends the sholw StateVariable for the service
- */
- boolean bool = sidListSid.updateListeners(sid,
- vars.getDeviceID(), vars.getServiceID(),
- vars.getDictionary());
- if (bool) {
- sidListSid.setAlreadyFirst(sid,true);
- }
- }
- }
- }
-
-/*
- public synchronized StateVarsToNotify getStateVars(String sid) {
- return (StateVarsToNotify) sidStateVars.get(sid);
- }
- public synchronized void removeStateVars(String sid) {
- sidStateVars.remove(sid);
- }
-*/
- public synchronized void addListener(String sid, UPnPEventListener listener) {
- StateVarsToNotify vars = (StateVarsToNotify) sidStateVars.get(sid);
- if (vars != null) {
- /*
- * Notify the listener whit the whole StateVariables and then
- * the next time you send only the changed StateVariables
- */
- listener.notifyUPnPEvent(vars.getDeviceID(),
- vars.getServiceID(),vars.getDictionary());
- }
- sidListSid.putSid2Listeners(sid, listener);
- sidListSid.putListener2Sids(listener, sid);
- }
-
- /**
- * Delete the reference to the listener from the stuctures sid2Listeners and listener2Sids.
- * Also if no more listner are listening for a UPnP Service that UPnP Service is unscribed.
- *
- * @param listener The listener to delete
- * @param ctrl Needed for reference
- */
- public synchronized void delListener(UPnPEventListener listener,
- MyCtrlPoint ctrl/*##renew, SidRenewer sidRenewer*/) {
-
- //francesco-renew
- // State variable clean up -- todo?
-
- Vector sids = sidListSid.getSidsFromListener(listener);
- if (sids != null) {
- Iterator i = sids.iterator();
- while(i.hasNext()){
- String sid = (String) i.next();
- Vector listeners =
- sidListSid.getListenersFromSid(sid);
- listeners.remove(listener);
- if (listeners.size() == 0) {
- Service service =
- ctrl.serviceFromSid(sid);
- //##renew Renewer renewer = sidRenewer.get((String) sids.elementAt(i));
- //##renew renewer.stop();
- if (service != null) {
- boolean ok = ctrl.unsubscribe(service);
- if (!ok) {
- //TODO Log?s
- service.clearSID();
- }
- }
- sidListSid.setAlreadyFirst(sid,false);
- sidStateVars.remove(sid);
- i.remove();
- }
- }
- sidListSid.removeListenerKey(listener);
- }
- }
-
- public synchronized void updateListener(ListenerModified msg,
- SubscriptionQueue subqueue, MyCtrlPoint ctrl/*##renew, SidRenewer sidRenewer*/) {
- UPnPEventListener listener = msg.getListener();
- Vector newServices = msg.getNewServices();
- Vector subscribed = new Vector();
- Vector notSubscribed = new Vector();
-
- for (int i = 0; i < newServices.size(); i++) {
- Service ser = (Service) newServices.elementAt(i);
- if (ser.isSubscribed()) {
- subscribed.add(ser);
- } else {
- notSubscribed.add(ser);
- }
- }
-
-
- Vector oldSids = sidListSid.getSidsFromListener(listener);
- // francesco-renew
- // check subscribed services
- if(oldSids==null) return;
-
- for (int i = 0; i < notSubscribed.size(); i++) {
- Service ser = (Service) notSubscribed.elementAt(i);
- subqueue.enqueue(new FirstMessage(ser, listener));
- }
-
- for (int i = 0; i < oldSids.size(); i++) {
- String oldSid = (String) oldSids.elementAt(i);
- if (!subscribed.contains(oldSid)) {
- // francesco-renew
- // to check -- Listner removal from sid2Listener
-
- unsubscribeListenerForSid(oldSid,listener,ctrl);
- }
- }
-
- }
-
- /**
- * Unregister the listener as UPnPListener for the UPnPService with
- * the spicfied SID
- *
- * @param sid
- * @param listener
- * @param ctrl
- */
- private void unsubscribeListenerForSid(String sid, UPnPEventListener listener, MyCtrlPoint ctrl) {
- Vector listeners = sidListSid.getListenersFromSid(sid);
- listeners.remove(listener);
- if(listeners.size()==0){
- Service service = ctrl.serviceFromSid(sid);
- if (service != null) {
- boolean ok = ctrl.unsubscribe(service);
- if (!ok) {
- //TODO Log?
- service.clearSID();
- }
- }
- sidListSid.setAlreadyFirst(sid,false);
- sidStateVars.remove(sid);
- }
- Vector sids = sidListSid.getSidsFromListener(listener);
- sids.remove(sid);
- if(sids.size()==0){
- sidListSid.removeListenerKey(listener);
- }
- }
-
- public synchronized void delSid(String sid) {
- Vector listeners = sidListSid.getListenersFromSid(sid);
- if(listeners==null)return;
- for (int i = 0; i < listeners.size(); i++) {
- Vector sids = sidListSid.getSidsFromListener((UPnPEventListener) listeners
- .elementAt(i));
- sids.remove(sid);
- }
- sidListSid.removeSidKey(sid);
- }
-
- public synchronized void clearAll(String sid, Service service) {
- service.clearSID();
- delSid(sid);
- sidStateVars.remove(sid);
- }
-
+/*
+ * 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.basedriver.importer.core.event.structs;
+
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.cybergarage.upnp.Service;
+
+import org.osgi.service.upnp.UPnPEventListener;
+
+import org.apache.felix.upnp.basedriver.importer.core.MyCtrlPoint;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.FirstMessage;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerModified;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class Monitor {
+ private Hashtable sidStateVars;
+ private SidsListenersMaps sidListSid;
+
+ public Monitor() {
+ this.sidListSid = new SidsListenersMaps();
+ this.sidStateVars = new Hashtable();
+ }
+
+ public synchronized void putStateVars(String sid, StateVarsToNotify vars) {
+ sidStateVars.put(sid, vars);
+ Vector listeners = (Vector) sidListSid.getListenersFromSid(sid);
+ if (listeners != null) {
+ sidListSid.updateListeners(sid, vars.getDeviceID(), vars.getServiceID(), vars.getDictionary());
+ sidListSid.setAlreadyFirst(sid,true);
+ } else {
+ sidListSid.setAlreadyFirst(sid, false);
+ }
+ }
+ public synchronized void updateStateVars(String sid, Dictionary dic) {
+ StateVarsToNotify vars = (StateVarsToNotify) sidStateVars.get(sid);
+ if (vars != null) {
+ vars.updateDic(dic);
+ if (sidListSid.getAlreadyFirst(sid)) {
+ /*
+ * Sends only the changed StateVariable
+ */
+ sidListSid.updateListeners(sid,
+ vars.getDeviceID(), vars.getServiceID(),
+ dic);
+ } else {
+ /*
+ * Sends the sholw StateVariable for the service
+ */
+ boolean bool = sidListSid.updateListeners(sid,
+ vars.getDeviceID(), vars.getServiceID(),
+ vars.getDictionary());
+ if (bool) {
+ sidListSid.setAlreadyFirst(sid,true);
+ }
+ }
+ }
+ }
+
+/*
+ public synchronized StateVarsToNotify getStateVars(String sid) {
+ return (StateVarsToNotify) sidStateVars.get(sid);
+ }
+ public synchronized void removeStateVars(String sid) {
+ sidStateVars.remove(sid);
+ }
+*/
+ public synchronized void addListener(String sid, UPnPEventListener listener) {
+ StateVarsToNotify vars = (StateVarsToNotify) sidStateVars.get(sid);
+ if (vars != null) {
+ /*
+ * Notify the listener whit the whole StateVariables and then
+ * the next time you send only the changed StateVariables
+ */
+ listener.notifyUPnPEvent(vars.getDeviceID(),
+ vars.getServiceID(),vars.getDictionary());
+ }
+ sidListSid.putSid2Listeners(sid, listener);
+ sidListSid.putListener2Sids(listener, sid);
+ }
+
+ /**
+ * Delete the reference to the listener from the stuctures sid2Listeners and listener2Sids.
+ * Also if no more listner are listening for a UPnP Service that UPnP Service is unscribed.
+ *
+ * @param listener The listener to delete
+ * @param ctrl Needed for reference
+ */
+ public synchronized void delListener(UPnPEventListener listener,
+ MyCtrlPoint ctrl/*##renew, SidRenewer sidRenewer*/) {
+
+ //francesco-renew
+ // State variable clean up -- todo?
+
+ Vector sids = sidListSid.getSidsFromListener(listener);
+ if (sids != null) {
+ Iterator i = sids.iterator();
+ while(i.hasNext()){
+ String sid = (String) i.next();
+ Vector listeners =
+ sidListSid.getListenersFromSid(sid);
+ listeners.remove(listener);
+ if (listeners.size() == 0) {
+ Service service =
+ ctrl.serviceFromSid(sid);
+ //##renew Renewer renewer = sidRenewer.get((String) sids.elementAt(i));
+ //##renew renewer.stop();
+ if (service != null) {
+ boolean ok = ctrl.unsubscribe(service);
+ if (!ok) {
+ //TODO Log?s
+ service.clearSID();
+ }
+ }
+ sidListSid.setAlreadyFirst(sid,false);
+ sidStateVars.remove(sid);
+ i.remove();
+ }
+ }
+ sidListSid.removeListenerKey(listener);
+ }
+ }
+
+ public synchronized void updateListener(ListenerModified msg,
+ SubscriptionQueue subqueue, MyCtrlPoint ctrl/*##renew, SidRenewer sidRenewer*/) {
+ UPnPEventListener listener = msg.getListener();
+ Vector newServices = msg.getNewServices();
+ Vector subscribed = new Vector();
+ Vector notSubscribed = new Vector();
+
+ for (int i = 0; i < newServices.size(); i++) {
+ Service ser = (Service) newServices.elementAt(i);
+ if (ser.isSubscribed()) {
+ subscribed.add(ser);
+ } else {
+ notSubscribed.add(ser);
+ }
+ }
+
+
+ Vector oldSids = sidListSid.getSidsFromListener(listener);
+ // francesco-renew
+ // check subscribed services
+ if(oldSids==null) return;
+
+ for (int i = 0; i < notSubscribed.size(); i++) {
+ Service ser = (Service) notSubscribed.elementAt(i);
+ subqueue.enqueue(new FirstMessage(ser, listener));
+ }
+
+ for (int i = 0; i < oldSids.size(); i++) {
+ String oldSid = (String) oldSids.elementAt(i);
+ if (!subscribed.contains(oldSid)) {
+ // francesco-renew
+ // to check -- Listner removal from sid2Listener
+
+ unsubscribeListenerForSid(oldSid,listener,ctrl);
+ }
+ }
+
+ }
+
+ /**
+ * Unregister the listener as UPnPListener for the UPnPService with
+ * the spicfied SID
+ *
+ * @param sid
+ * @param listener
+ * @param ctrl
+ */
+ private void unsubscribeListenerForSid(String sid, UPnPEventListener listener, MyCtrlPoint ctrl) {
+ Vector listeners = sidListSid.getListenersFromSid(sid);
+ listeners.remove(listener);
+ if(listeners.size()==0){
+ Service service = ctrl.serviceFromSid(sid);
+ if (service != null) {
+ boolean ok = ctrl.unsubscribe(service);
+ if (!ok) {
+ //TODO Log?
+ service.clearSID();
+ }
+ }
+ sidListSid.setAlreadyFirst(sid,false);
+ sidStateVars.remove(sid);
+ }
+ Vector sids = sidListSid.getSidsFromListener(listener);
+ sids.remove(sid);
+ if(sids.size()==0){
+ sidListSid.removeListenerKey(listener);
+ }
+ }
+
+ public synchronized void delSid(String sid) {
+ Vector listeners = sidListSid.getListenersFromSid(sid);
+ if(listeners==null)return;
+ for (int i = 0; i < listeners.size(); i++) {
+ Vector sids = sidListSid.getSidsFromListener((UPnPEventListener) listeners
+ .elementAt(i));
+ sids.remove(sid);
+ }
+ sidListSid.removeSidKey(sid);
+ }
+
+ public synchronized void clearAll(String sid, Service service) {
+ service.clearSID();
+ delSid(sid);
+ sidStateVars.remove(sid);
+ }
+
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/NotifierQueue.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/NotifierQueue.java
index c881509..dcf17cd 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/NotifierQueue.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/NotifierQueue.java
@@ -1,62 +1,62 @@
-/*
- * 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.basedriver.importer.core.event.structs;
-
-import java.util.Vector;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class NotifierQueue {
- private Vector queue;
- private boolean running = true;
-
- public NotifierQueue(){
- queue=new Vector();
- }
-
- public synchronized void enqueue(Object obj){
- queue.add(obj);
- if(queue.size() == 1){
- notify();
- }
-
- }
-
- public synchronized Object dequeue(){
- while(queue.size()==0 && running){
- try {
- wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- if (running)
- return queue.remove(0);
- else
- return null;
- }
-
- public synchronized void close() {
- running = false;
- notify();
- }
-
-}
+/*
+ * 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.basedriver.importer.core.event.structs;
+
+import java.util.Vector;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class NotifierQueue {
+ private Vector queue;
+ private boolean running = true;
+
+ public NotifierQueue(){
+ queue=new Vector();
+ }
+
+ public synchronized void enqueue(Object obj){
+ queue.add(obj);
+ if(queue.size() == 1){
+ notify();
+ }
+
+ }
+
+ public synchronized Object dequeue(){
+ while(queue.size()==0 && running){
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ if (running)
+ return queue.remove(0);
+ else
+ return null;
+ }
+
+ public synchronized void close() {
+ running = false;
+ notify();
+ }
+
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Sid2Listeners.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Sid2Listeners.java
index f6dfd85..5badc82 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Sid2Listeners.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/Sid2Listeners.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.basedriver.importer.core.event.structs;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.osgi.service.upnp.UPnPEventListener;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class Sid2Listeners {
- private Hashtable sidListener;
- private Hashtable alreadyfirst;
-
- public Sid2Listeners() {
- this.sidListener = new Hashtable();
- this.alreadyfirst = new Hashtable();
- }
-
- public void put(String sid, UPnPEventListener listener) {
- if (!sidListener.containsKey(sid)) {
- Vector vec = new Vector();
- vec.add(listener);
- sidListener.put(sid, vec);
- } else {
- Vector vec = (Vector) sidListener.get(sid);
- if (!vec.contains(listener)) {
- vec.add(listener);
- }
- }
- }
-
- public final void remove(String sid) {
- sidListener.remove(sid);
- }
-
- public final Vector get(String sid) {
- return ((Vector) sidListener.get(sid));
- }
-
- /**
- * @param sid
- * @param dictionary
- */
- public boolean updateListeners(String sid, String deviceID,String serviceID, Dictionary dictionary) {
-
- Vector listeners = (Vector) sidListener.get(sid);
- if (listeners != null) {
- for (int i = 0; i < listeners.size(); i++) {
- UPnPEventListener listener = (UPnPEventListener) listeners.elementAt(i);
- listener.notifyUPnPEvent(deviceID, serviceID, dictionary);
- }
- return true;
- }
- return false;
- }
-
- public boolean getAlreadyFirst(String sid) {
- return ((Boolean) alreadyfirst.get(sid)).booleanValue();
- }
-
- public void setAlreadyFirst(String sid, boolean bool) {
- alreadyfirst.put(sid, new Boolean(bool));
- }
+/*
+ * 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.basedriver.importer.core.event.structs;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.osgi.service.upnp.UPnPEventListener;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class Sid2Listeners {
+ private Hashtable sidListener;
+ private Hashtable alreadyfirst;
+
+ public Sid2Listeners() {
+ this.sidListener = new Hashtable();
+ this.alreadyfirst = new Hashtable();
+ }
+
+ public void put(String sid, UPnPEventListener listener) {
+ if (!sidListener.containsKey(sid)) {
+ Vector vec = new Vector();
+ vec.add(listener);
+ sidListener.put(sid, vec);
+ } else {
+ Vector vec = (Vector) sidListener.get(sid);
+ if (!vec.contains(listener)) {
+ vec.add(listener);
+ }
+ }
+ }
+
+ public final void remove(String sid) {
+ sidListener.remove(sid);
+ }
+
+ public final Vector get(String sid) {
+ return ((Vector) sidListener.get(sid));
+ }
+
+ /**
+ * @param sid
+ * @param dictionary
+ */
+ public boolean updateListeners(String sid, String deviceID,String serviceID, Dictionary dictionary) {
+
+ Vector listeners = (Vector) sidListener.get(sid);
+ if (listeners != null) {
+ for (int i = 0; i < listeners.size(); i++) {
+ UPnPEventListener listener = (UPnPEventListener) listeners.elementAt(i);
+ listener.notifyUPnPEvent(deviceID, serviceID, dictionary);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public boolean getAlreadyFirst(String sid) {
+ return ((Boolean) alreadyfirst.get(sid)).booleanValue();
+ }
+
+ public void setAlreadyFirst(String sid, boolean bool) {
+ alreadyfirst.put(sid, new Boolean(bool));
+ }
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SidRenewer.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SidRenewer.java
index 7644656..afcc0c9 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SidRenewer.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SidRenewer.java
@@ -1,50 +1,50 @@
-/*
- * 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.basedriver.importer.core.event.structs;
-
-
-import java.util.Hashtable;
-
-import org.apache.felix.upnp.basedriver.importer.core.event.thread.Renewer;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class SidRenewer {
-private Hashtable hash;
-
- /**
- * @param hash
- */
- public SidRenewer() {
- super();
- this.hash = new Hashtable();
- }
-
- public synchronized void put(String sid, Renewer renewer){
- hash.put(sid,renewer);
- }
- public synchronized Renewer get(String sid){
- return (Renewer)hash.get(sid);
- }
- public synchronized void remove(String sid){
- hash.remove(sid);
- }
-}
+/*
+ * 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.basedriver.importer.core.event.structs;
+
+
+import java.util.Hashtable;
+
+import org.apache.felix.upnp.basedriver.importer.core.event.thread.Renewer;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class SidRenewer {
+private Hashtable hash;
+
+ /**
+ * @param hash
+ */
+ public SidRenewer() {
+ super();
+ this.hash = new Hashtable();
+ }
+
+ public synchronized void put(String sid, Renewer renewer){
+ hash.put(sid,renewer);
+ }
+ public synchronized Renewer get(String sid){
+ return (Renewer)hash.get(sid);
+ }
+ public synchronized void remove(String sid){
+ hash.remove(sid);
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SidsListenersMaps.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SidsListenersMaps.java
index fb81d1f..1320287 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SidsListenersMaps.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SidsListenersMaps.java
@@ -1,76 +1,76 @@
-/*
- * 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.basedriver.importer.core.event.structs;
-
-import java.util.Dictionary;
-import java.util.Vector;
-
-import org.osgi.service.upnp.UPnPEventListener;
-
-/**
- * This class contain two table:
- * - sid2listener: have SID of Suscribed Service as key and a Vector of UPnPEventListener as value
- * - listener2sids: have an UPnPEventListener as kay and a Vector of SID of Scriscrobed Service
- *
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class SidsListenersMaps {
- private Sid2Listeners sid2Listeners;
- private Listener2Sids listeners2Sids;
-
- public SidsListenersMaps(){
- sid2Listeners=new Sid2Listeners();
- listeners2Sids=new Listener2Sids();
- }
-
-
- /////////////////// Sid to Listeners //////////////////////////////////
- public final void putSid2Listeners(String sid, UPnPEventListener listener) {
- sid2Listeners.put(sid,listener);
- }
- public final Vector getListenersFromSid(String sid) {
- return sid2Listeners.get(sid);
- }
- public final void removeSidKey(String sid) {
- sid2Listeners.remove(sid);
- }
- public final boolean updateListeners(String sid, String deviceID, String serviceID,Dictionary dictionary){
- return sid2Listeners.updateListeners(sid,deviceID,serviceID,dictionary);
- }
- public final boolean getAlreadyFirst(String sid) {
- return sid2Listeners.getAlreadyFirst(sid);
- }
- public final void setAlreadyFirst(String sid, boolean bool) {
- sid2Listeners.setAlreadyFirst(sid,bool);
- }
-
-
-
- /////////////////// Listener to Sids //////////////////////////////////
- public final void putListener2Sids(UPnPEventListener listener,String sid) {
- listeners2Sids.put(listener,sid);
- }
- public final Vector getSidsFromListener(UPnPEventListener listener){
- return listeners2Sids.get(listener);
- }
- public final void removeListenerKey(UPnPEventListener listener){
- listeners2Sids.remove(listener);
- }
+/*
+ * 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.basedriver.importer.core.event.structs;
+
+import java.util.Dictionary;
+import java.util.Vector;
+
+import org.osgi.service.upnp.UPnPEventListener;
+
+/**
+ * This class contain two table:
+ * - sid2listener: have SID of Suscribed Service as key and a Vector of UPnPEventListener as value
+ * - listener2sids: have an UPnPEventListener as kay and a Vector of SID of Scriscrobed Service
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class SidsListenersMaps {
+ private Sid2Listeners sid2Listeners;
+ private Listener2Sids listeners2Sids;
+
+ public SidsListenersMaps(){
+ sid2Listeners=new Sid2Listeners();
+ listeners2Sids=new Listener2Sids();
+ }
+
+
+ /////////////////// Sid to Listeners //////////////////////////////////
+ public final void putSid2Listeners(String sid, UPnPEventListener listener) {
+ sid2Listeners.put(sid,listener);
+ }
+ public final Vector getListenersFromSid(String sid) {
+ return sid2Listeners.get(sid);
+ }
+ public final void removeSidKey(String sid) {
+ sid2Listeners.remove(sid);
+ }
+ public final boolean updateListeners(String sid, String deviceID, String serviceID,Dictionary dictionary){
+ return sid2Listeners.updateListeners(sid,deviceID,serviceID,dictionary);
+ }
+ public final boolean getAlreadyFirst(String sid) {
+ return sid2Listeners.getAlreadyFirst(sid);
+ }
+ public final void setAlreadyFirst(String sid, boolean bool) {
+ sid2Listeners.setAlreadyFirst(sid,bool);
+ }
+
+
+
+ /////////////////// Listener to Sids //////////////////////////////////
+ public final void putListener2Sids(UPnPEventListener listener,String sid) {
+ listeners2Sids.put(listener,sid);
+ }
+ public final Vector getSidsFromListener(UPnPEventListener listener){
+ return listeners2Sids.get(listener);
+ }
+ public final void removeListenerKey(UPnPEventListener listener){
+ listeners2Sids.remove(listener);
+ }
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/StateVarsToNotify.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/StateVarsToNotify.java
index 48af2f3..de40a2b 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/StateVarsToNotify.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/StateVarsToNotify.java
@@ -1,68 +1,68 @@
-/*
- * 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.basedriver.importer.core.event.structs;
-
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-
-import org.apache.felix.upnp.basedriver.importer.core.event.message.StateChanged;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class StateVarsToNotify {
- private Dictionary stateVars;
- private String sid;
- private String deviceID;
- private String serviceID;
-
- //public StateVarsToNotify(String sid, String deviceID, String serviceID,Dictionary dic) {
- public StateVarsToNotify(StateChanged msg) {
- this.stateVars= msg.getDictionary();
- this.sid = msg.getSid();
- this.deviceID = msg.getDeviceID();
- this.serviceID = msg.getServiceID();
- }
-
-
- public synchronized Dictionary getDictionary() {
- return stateVars;
- }
- public synchronized String getSid() {
- return sid;
- }
- public synchronized String getDeviceID() {
- return deviceID;
- }
- public synchronized String getServiceID() {
- return serviceID;
- }
-
-
- public void updateDic(Dictionary dic){
- Enumeration e=dic.keys();
- while(e.hasMoreElements()){
- String varName=(String)e.nextElement();
- Object varValue=dic.get(varName);
- stateVars.put(varName,varValue);
- }
- }
+/*
+ * 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.basedriver.importer.core.event.structs;
+
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import org.apache.felix.upnp.basedriver.importer.core.event.message.StateChanged;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class StateVarsToNotify {
+ private Dictionary stateVars;
+ private String sid;
+ private String deviceID;
+ private String serviceID;
+
+ //public StateVarsToNotify(String sid, String deviceID, String serviceID,Dictionary dic) {
+ public StateVarsToNotify(StateChanged msg) {
+ this.stateVars= msg.getDictionary();
+ this.sid = msg.getSid();
+ this.deviceID = msg.getDeviceID();
+ this.serviceID = msg.getServiceID();
+ }
+
+
+ public synchronized Dictionary getDictionary() {
+ return stateVars;
+ }
+ public synchronized String getSid() {
+ return sid;
+ }
+ public synchronized String getDeviceID() {
+ return deviceID;
+ }
+ public synchronized String getServiceID() {
+ return serviceID;
+ }
+
+
+ public void updateDic(Dictionary dic){
+ Enumeration e=dic.keys();
+ while(e.hasMoreElements()){
+ String varName=(String)e.nextElement();
+ Object varValue=dic.get(varName);
+ stateVars.put(varName,varValue);
+ }
+ }
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SubscriptionQueue.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SubscriptionQueue.java
index 6a043d0..49e272f 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SubscriptionQueue.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/structs/SubscriptionQueue.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.basedriver.importer.core.event.structs;
-
-import java.util.Vector;
-
-
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class SubscriptionQueue {
- private Vector queue;
- private boolean running = true;
-
- public SubscriptionQueue(){
- queue=new Vector();
- }
- public synchronized void enqueue(Object obj){
- queue.add(obj);
- if(queue.size()==1){
- notify();
- }
- }
- public synchronized Object dequeue(){
- while(queue.size()==0 && running){
- try {
- wait();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- if (running)
- return queue.remove(0);
- else
- return null;
- }
-
- public synchronized void close() {
- running = false;
- notify();
- }
-
-
-}
+/*
+ * 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.basedriver.importer.core.event.structs;
+
+import java.util.Vector;
+
+
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class SubscriptionQueue {
+ private Vector queue;
+ private boolean running = true;
+
+ public SubscriptionQueue(){
+ queue=new Vector();
+ }
+ public synchronized void enqueue(Object obj){
+ queue.add(obj);
+ if(queue.size()==1){
+ notify();
+ }
+ }
+ public synchronized Object dequeue(){
+ while(queue.size()==0 && running){
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ if (running)
+ return queue.remove(0);
+ else
+ return null;
+ }
+
+ public synchronized void close() {
+ running = false;
+ notify();
+ }
+
+
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/Notifier.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/Notifier.java
index f976d50..295f1d8 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/Notifier.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/Notifier.java
@@ -1,64 +1,64 @@
-/*
- * 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.basedriver.importer.core.event.thread;
-
-import org.apache.felix.upnp.basedriver.importer.core.event.message.StateChanged;
-import org.apache.felix.upnp.basedriver.importer.core.event.structs.Monitor;
-import org.apache.felix.upnp.basedriver.importer.core.event.structs.NotifierQueue;
-import org.apache.felix.upnp.basedriver.importer.core.event.structs.StateVarsToNotify;
-
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class Notifier extends Thread {
-
- private NotifierQueue notifierQueue;
- private Monitor monitor;
- private boolean running = true;
-
- public Notifier(NotifierQueue notifierQueue,Monitor monitor) {
- super("upnp.basedriver.Notifier");
- this.notifierQueue = notifierQueue;
- this.monitor = monitor;
-
- }
-
- public void run() {
- while (running) {
- StateChanged msg = (StateChanged) notifierQueue.dequeue();
- if (running) {
- StateVarsToNotify vars = null;
- if (msg.getSeq() == 0) {
- vars = new StateVarsToNotify(msg);
- monitor.putStateVars(msg.getSid(),vars);
- } else {
- monitor.updateStateVars(msg.getSid(),msg.getDictionary());
- }
- }
- }
- }
-
- public void close() {
- running = false;
- notifierQueue.close();
- }
+/*
+ * 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.basedriver.importer.core.event.thread;
+
+import org.apache.felix.upnp.basedriver.importer.core.event.message.StateChanged;
+import org.apache.felix.upnp.basedriver.importer.core.event.structs.Monitor;
+import org.apache.felix.upnp.basedriver.importer.core.event.structs.NotifierQueue;
+import org.apache.felix.upnp.basedriver.importer.core.event.structs.StateVarsToNotify;
+
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class Notifier extends Thread {
+
+ private NotifierQueue notifierQueue;
+ private Monitor monitor;
+ private boolean running = true;
+
+ public Notifier(NotifierQueue notifierQueue,Monitor monitor) {
+ super("upnp.basedriver.Notifier");
+ this.notifierQueue = notifierQueue;
+ this.monitor = monitor;
+
+ }
+
+ public void run() {
+ while (running) {
+ StateChanged msg = (StateChanged) notifierQueue.dequeue();
+ if (running) {
+ StateVarsToNotify vars = null;
+ if (msg.getSeq() == 0) {
+ vars = new StateVarsToNotify(msg);
+ monitor.putStateVars(msg.getSid(),vars);
+ } else {
+ monitor.updateStateVars(msg.getSid(),msg.getDictionary());
+ }
+ }
+ }
+ }
+
+ public void close() {
+ running = false;
+ notifierQueue.close();
+ }
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/Renewer.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/Renewer.java
index 563bb98..b605943 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/Renewer.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/Renewer.java
@@ -1,83 +1,83 @@
-/*
- * 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.basedriver.importer.core.event.thread;
-
-
-import org.cybergarage.upnp.Service;
-
-import org.apache.felix.upnp.basedriver.importer.core.MyCtrlPoint;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.SidExipired;
-import org.apache.felix.upnp.basedriver.importer.core.event.structs.SubscriptionQueue;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class Renewer extends Thread {
- private long timeout;
- private String sid;
- private Service service;
- private MyCtrlPoint ctrl;
- private boolean bool;
- private SubscriptionQueue subqueue;
- private final long time_before_renew=60000;
- /**
- * *
- *
- * @param timeout
- * @param sid
- * @param service
- */
- public Renewer(long timeout, String sid, Service service,
- MyCtrlPoint ctrl,SubscriptionQueue subqueue) {
- super("ReNewal" + sid);
- if (timeout - time_before_renew > 0) {
- this.timeout = timeout - time_before_renew;
- } else {
- this.timeout = timeout;
- }
- this.sid = sid;
- this.service = service;
- this.ctrl = ctrl;
- bool = true;
- this.subqueue=subqueue;
- }
- public void run() {
- while (bool) {
- try {
- sleep(timeout);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- boolean ok = ctrl.subscribe(service, sid, 180000);
- if (ok) {//renew ok
- if (service.getTimeout() - time_before_renew > 0) {
- timeout = service.getTimeout() - time_before_renew;
- } else {
- timeout = service.getTimeout();
- }
- } else {//renew not ok
- bool=false;
- subqueue.enqueue(new SidExipired(sid,service));
- }
- }
- }
-
+/*
+ * 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.basedriver.importer.core.event.thread;
+
+
+import org.cybergarage.upnp.Service;
+
+import org.apache.felix.upnp.basedriver.importer.core.MyCtrlPoint;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.SidExipired;
+import org.apache.felix.upnp.basedriver.importer.core.event.structs.SubscriptionQueue;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class Renewer extends Thread {
+ private long timeout;
+ private String sid;
+ private Service service;
+ private MyCtrlPoint ctrl;
+ private boolean bool;
+ private SubscriptionQueue subqueue;
+ private final long time_before_renew=60000;
+ /**
+ * *
+ *
+ * @param timeout
+ * @param sid
+ * @param service
+ */
+ public Renewer(long timeout, String sid, Service service,
+ MyCtrlPoint ctrl,SubscriptionQueue subqueue) {
+ super("ReNewal" + sid);
+ if (timeout - time_before_renew > 0) {
+ this.timeout = timeout - time_before_renew;
+ } else {
+ this.timeout = timeout;
+ }
+ this.sid = sid;
+ this.service = service;
+ this.ctrl = ctrl;
+ bool = true;
+ this.subqueue=subqueue;
+ }
+ public void run() {
+ while (bool) {
+ try {
+ sleep(timeout);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ boolean ok = ctrl.subscribe(service, sid, 180000);
+ if (ok) {//renew ok
+ if (service.getTimeout() - time_before_renew > 0) {
+ timeout = service.getTimeout() - time_before_renew;
+ } else {
+ timeout = service.getTimeout();
+ }
+ } else {//renew not ok
+ bool=false;
+ subqueue.enqueue(new SidExipired(sid,service));
+ }
+ }
+ }
+
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/SubScriber.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/SubScriber.java
index 82d0bff..0829867 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/SubScriber.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/event/thread/SubScriber.java
@@ -1,92 +1,92 @@
-/*
- * 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.basedriver.importer.core.event.thread;
-
-
-import org.cybergarage.upnp.Service;
-
-import org.osgi.service.log.LogService;
-
-import org.apache.felix.upnp.basedriver.Activator;
-import org.apache.felix.upnp.basedriver.importer.core.MyCtrlPoint;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.FirstMessage;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerModified;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerUnRegistration;
-import org.apache.felix.upnp.basedriver.importer.core.event.message.SidExipired;
-import org.apache.felix.upnp.basedriver.importer.core.event.structs.Monitor;
-import org.apache.felix.upnp.basedriver.importer.core.event.structs.SubscriptionQueue;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class SubScriber extends Thread {
-
- private MyCtrlPoint ctrl;
- private SubscriptionQueue subQueue;
- private boolean running = true;
- private Monitor monitor;
-
-
- public SubScriber(MyCtrlPoint ctrl, SubscriptionQueue subQueue, Monitor monitor) {
- super("upnp.basedriver.Subscriber");
- this.ctrl = ctrl;
- this.subQueue = subQueue;
- this.monitor=monitor;
-
- }
-
- public void run() {
- while (running) {
- Object msg = subQueue.dequeue();
- if (running) {
- if (msg instanceof FirstMessage) {
- FirstMessage firstmsg = (FirstMessage) msg;
- Service service = firstmsg.getService();
- if (!service.isSubscribed()) {//is not subscribe
- boolean ok = ctrl.subscribe(service,120000);
- String sid = "";
- if (ok) {//subcribe ok
- sid = service.getSID();
- firstmsg.setSid(sid);
- monitor.addListener(sid,firstmsg.getListener());
- } else {//subscribe not ok
- Activator.logger.log(LogService.LOG_ERROR,"Sucribe failed");
- }
- } else {// already subscribe
- monitor.addListener(service.getSID(),firstmsg.getListener());
- }
- } else if (msg instanceof ListenerModified) {
- monitor.updateListener((ListenerModified)msg,subQueue,ctrl);
- } else if (msg instanceof ListenerUnRegistration) {
- ListenerUnRegistration unreg=(ListenerUnRegistration)msg;
- monitor.delListener(unreg.getListener(),ctrl);
- } else if(msg instanceof SidExipired){
- Activator.logger.WARNING("[Importer] Please report the bug. Used code - should be checked and removed");
- }
- }
- }
- }
-
- public void close() {
- running = false;
- subQueue.close();
- }
-
+/*
+ * 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.basedriver.importer.core.event.thread;
+
+
+import org.cybergarage.upnp.Service;
+
+import org.osgi.service.log.LogService;
+
+import org.apache.felix.upnp.basedriver.Activator;
+import org.apache.felix.upnp.basedriver.importer.core.MyCtrlPoint;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.FirstMessage;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerModified;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.ListenerUnRegistration;
+import org.apache.felix.upnp.basedriver.importer.core.event.message.SidExipired;
+import org.apache.felix.upnp.basedriver.importer.core.event.structs.Monitor;
+import org.apache.felix.upnp.basedriver.importer.core.event.structs.SubscriptionQueue;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class SubScriber extends Thread {
+
+ private MyCtrlPoint ctrl;
+ private SubscriptionQueue subQueue;
+ private boolean running = true;
+ private Monitor monitor;
+
+
+ public SubScriber(MyCtrlPoint ctrl, SubscriptionQueue subQueue, Monitor monitor) {
+ super("upnp.basedriver.Subscriber");
+ this.ctrl = ctrl;
+ this.subQueue = subQueue;
+ this.monitor=monitor;
+
+ }
+
+ public void run() {
+ while (running) {
+ Object msg = subQueue.dequeue();
+ if (running) {
+ if (msg instanceof FirstMessage) {
+ FirstMessage firstmsg = (FirstMessage) msg;
+ Service service = firstmsg.getService();
+ if (!service.isSubscribed()) {//is not subscribe
+ boolean ok = ctrl.subscribe(service,120000);
+ String sid = "";
+ if (ok) {//subcribe ok
+ sid = service.getSID();
+ firstmsg.setSid(sid);
+ monitor.addListener(sid,firstmsg.getListener());
+ } else {//subscribe not ok
+ Activator.logger.log(LogService.LOG_ERROR,"Sucribe failed");
+ }
+ } else {// already subscribe
+ monitor.addListener(service.getSID(),firstmsg.getListener());
+ }
+ } else if (msg instanceof ListenerModified) {
+ monitor.updateListener((ListenerModified)msg,subQueue,ctrl);
+ } else if (msg instanceof ListenerUnRegistration) {
+ ListenerUnRegistration unreg=(ListenerUnRegistration)msg;
+ monitor.delListener(unreg.getListener(),ctrl);
+ } else if(msg instanceof SidExipired){
+ Activator.logger.WARNING("[Importer] Please report the bug. Used code - should be checked and removed");
+ }
+ }
+ }
+ }
+
+ public void close() {
+ running = false;
+ subQueue.close();
+ }
+
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPActionImpl.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPActionImpl.java
index 33b2837..4d63eb6 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPActionImpl.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPActionImpl.java
@@ -1,174 +1,174 @@
-/*
- * 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.basedriver.importer.core.upnp;
-
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.cybergarage.upnp.Action;
-import org.cybergarage.upnp.Argument;
-import org.cybergarage.upnp.ArgumentList;
-import org.cybergarage.upnp.UPnPStatus;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPException;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.basedriver.util.Converter;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class UPnPActionImpl implements UPnPAction {
-
- private Action act;
- private UPnPServiceImpl actsFather;
- /**
- * @param act
- */
- public UPnPActionImpl(Action act,UPnPServiceImpl ser) {
- // TODO to check
- this.act=act;
- actsFather=ser;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getName()
- */
- public String getName() {
- // TODO to check
- return act.getName();
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
- */
- public String getReturnArgumentName() {
- /* TODO should I to parse again the xml?
- */
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
- */
- public String[] getInputArgumentNames() {
- // TODO to check
- ArgumentList argsList=act.getInputArgumentList();
- if(argsList.size()==0){
- return null;
- }
- String [] inputArgs=new String[argsList.size()];
- for(int i=0;i<argsList.size();i++){
- inputArgs[i]=argsList.getArgument(i).getName();
- }
- return inputArgs;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
- */
- public String[] getOutputArgumentNames() {
- // TODO to check
- ArgumentList argsList=act.getOutputArgumentList();
- if(argsList.size()==0){
- return null;
- }
- String [] outArgs=new String[argsList.size()];
- for(int i=0;i<argsList.size();i++){
- outArgs[i]=argsList.getArgument(i).getName();
- }
- return outArgs;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String argumentName) {
- /*
-
- check if the way to obtain the UPnPStateVariabile is not too bad
-
- */
- Argument arg=act.getArgument(argumentName);
- if(arg==null){
- return null;
- }
- String varName=arg.getRelatedStateVariableName();
- return actsFather.getStateVariable(varName);
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
- */
- public Dictionary invoke(Dictionary args) throws Exception {
- /*TODO
- check if I have understood wath this method should do
- */
- /*
- * I look for argument and value and then I add them to ArgumentList
- */
- ArgumentList argsList=new ArgumentList();
- argsList= act.getInputArgumentList();
-
- for(int i=0;i<argsList.size();i++){
- /*
- * I assert that .getArgument(i) will return to me an Argument with only the name of the
- * Argument and not it's value. I'll set the associated value by myself and
- * Also I assert that the Argument are ordered
- */
- Argument argument=argsList.getArgument(i);
- String argumentName=argument.getName();
- //String relateVar=argument.getRelatedStateVariableName();
- UPnPStateVariable stateVar=this.getStateVariable(argumentName);
- String upnpType=stateVar.getUPnPDataType();
- /*Class javaClass=stateVar.getJavaDataType();*/
- //setting the value related to the input argument
- argument.setValue(Converter.toString(args.get(argumentName),upnpType));
- }
- act.setInArgumentValues(argsList);
- if(act.postControlAction()==true){
- //TODO check what happen if I don't have any output argument
- Properties outDic=new Properties();
- ArgumentList outArgs=act.getOutputArgumentList();
- if(outArgs.size()==0){
- return null;
- }
- for(int i=0;i<outArgs.size();i++){
- Argument argument=outArgs.getArgument(i);
- String argumentName=outArgs.getArgument(i).getName();
- //String relateVar=argument.getRelatedStateVariableName();
- UPnPStateVariable stateVar=getStateVariable(argumentName);
- //String javaType=stateVar.getJavaDataType().getName();
- //TODO rember to catch number exception
- String upnpType=stateVar.getUPnPDataType();
- outDic.put(argumentName,Converter.parseString(argument.getValue(),upnpType));
- }
- return outDic;
- }else{
- UPnPStatus controlStatus = act.getControlStatus();
- throw new UPnPException(controlStatus.getCode(),controlStatus.getDescription());
- }
-
- }
-
-}
+/*
+ * 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.basedriver.importer.core.upnp;
+
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import org.cybergarage.upnp.Action;
+import org.cybergarage.upnp.Argument;
+import org.cybergarage.upnp.ArgumentList;
+import org.cybergarage.upnp.UPnPStatus;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPException;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.basedriver.util.Converter;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class UPnPActionImpl implements UPnPAction {
+
+ private Action act;
+ private UPnPServiceImpl actsFather;
+ /**
+ * @param act
+ */
+ public UPnPActionImpl(Action act,UPnPServiceImpl ser) {
+ // TODO to check
+ this.act=act;
+ actsFather=ser;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getName()
+ */
+ public String getName() {
+ // TODO to check
+ return act.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getReturnArgumentName()
+ */
+ public String getReturnArgumentName() {
+ /* TODO should I to parse again the xml?
+ */
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getInputArgumentNames()
+ */
+ public String[] getInputArgumentNames() {
+ // TODO to check
+ ArgumentList argsList=act.getInputArgumentList();
+ if(argsList.size()==0){
+ return null;
+ }
+ String [] inputArgs=new String[argsList.size()];
+ for(int i=0;i<argsList.size();i++){
+ inputArgs[i]=argsList.getArgument(i).getName();
+ }
+ return inputArgs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getOutputArgumentNames()
+ */
+ public String[] getOutputArgumentNames() {
+ // TODO to check
+ ArgumentList argsList=act.getOutputArgumentList();
+ if(argsList.size()==0){
+ return null;
+ }
+ String [] outArgs=new String[argsList.size()];
+ for(int i=0;i<argsList.size();i++){
+ outArgs[i]=argsList.getArgument(i).getName();
+ }
+ return outArgs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String argumentName) {
+ /*
+
+ check if the way to obtain the UPnPStateVariabile is not too bad
+
+ */
+ Argument arg=act.getArgument(argumentName);
+ if(arg==null){
+ return null;
+ }
+ String varName=arg.getRelatedStateVariableName();
+ return actsFather.getStateVariable(varName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPAction#invoke(java.util.Dictionary)
+ */
+ public Dictionary invoke(Dictionary args) throws Exception {
+ /*TODO
+ check if I have understood wath this method should do
+ */
+ /*
+ * I look for argument and value and then I add them to ArgumentList
+ */
+ ArgumentList argsList=new ArgumentList();
+ argsList= act.getInputArgumentList();
+
+ for(int i=0;i<argsList.size();i++){
+ /*
+ * I assert that .getArgument(i) will return to me an Argument with only the name of the
+ * Argument and not it's value. I'll set the associated value by myself and
+ * Also I assert that the Argument are ordered
+ */
+ Argument argument=argsList.getArgument(i);
+ String argumentName=argument.getName();
+ //String relateVar=argument.getRelatedStateVariableName();
+ UPnPStateVariable stateVar=this.getStateVariable(argumentName);
+ String upnpType=stateVar.getUPnPDataType();
+ /*Class javaClass=stateVar.getJavaDataType();*/
+ //setting the value related to the input argument
+ argument.setValue(Converter.toString(args.get(argumentName),upnpType));
+ }
+ act.setInArgumentValues(argsList);
+ if(act.postControlAction()==true){
+ //TODO check what happen if I don't have any output argument
+ Properties outDic=new Properties();
+ ArgumentList outArgs=act.getOutputArgumentList();
+ if(outArgs.size()==0){
+ return null;
+ }
+ for(int i=0;i<outArgs.size();i++){
+ Argument argument=outArgs.getArgument(i);
+ String argumentName=outArgs.getArgument(i).getName();
+ //String relateVar=argument.getRelatedStateVariableName();
+ UPnPStateVariable stateVar=getStateVariable(argumentName);
+ //String javaType=stateVar.getJavaDataType().getName();
+ //TODO rember to catch number exception
+ String upnpType=stateVar.getUPnPDataType();
+ outDic.put(argumentName,Converter.parseString(argument.getValue(),upnpType));
+ }
+ return outDic;
+ }else{
+ UPnPStatus controlStatus = act.getControlStatus();
+ throw new UPnPException(controlStatus.getCode(),controlStatus.getDescription());
+ }
+
+ }
+
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPDeviceImpl.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPDeviceImpl.java
index 7fd1fe0..c4e1dc7 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPDeviceImpl.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPDeviceImpl.java
@@ -1,144 +1,144 @@
-/*
- * 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.basedriver.importer.core.upnp;
-
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.cybergarage.upnp.Device;
-
-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.basedriver.importer.util.DeviceSetup;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class UPnPDeviceImpl implements UPnPDevice {
-
- /**
- * <code>properties</code> Dictionary that contains Device properties
- */
- private Dictionary properties;
- private Vector icons;
- private Hashtable services;
- /**
- * @param dev
- * Device the cyberLink Device used to rappresent the real UPnP
- * Device
- */
- public UPnPDeviceImpl(Device dev, BundleContext context) {
- properties = new Hashtable();
- this.services=new Hashtable();
- this.icons=new Vector();
- DeviceSetup.deviceSetup(properties,dev,icons,services);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPDevice#getService(java.lang.String)
- */
- public UPnPService getService(String serviceId) {
- return (UPnPServiceImpl) services.get(serviceId);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPDevice#getServices()
- */
- public UPnPService[] getServices() {
- Enumeration e = services.elements();
- if (e == null) {
- //TODO should I return null or an empty array? The specification seems to said to return null
- return null;
- }
- UPnPService[] uPnPser = new UPnPService[services.size()];
- int i = 0;
- while (e.hasMoreElements()) {
- uPnPser[i] = (UPnPServiceImpl) e.nextElement();
- i++;
- }
- return uPnPser;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPDevice#getIcons(java.lang.String)
- */
- public UPnPIcon[] getIcons(String locale) {
- if (locale != null) {
- return null;
- }
- if(icons.size()==0){
- return null;
- }
- return (UPnPIcon[]) icons.toArray(new UPnPIcon[]{});
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPDevice#getDescriptions(java.lang.String)
- */
-
- public Dictionary getDescriptions(String locale) {
- //TODO Sent the right localized version of Description if are available
- if (locale != null) {
- return null;
- }
- return properties;
- }
-
- /**
- * @param serviceType
- * @return true if device contains the serviceType
- */
- public boolean existServiceType(String serviceType) {
- String[] services = (String[]) properties.get(UPnPService.TYPE);
- if (services != null) {
- for (int i = 0; i < services.length; i++) {
- if (services[i].equals(serviceType)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * @param property
- * @param obj
- */
- public void setProperty(String property, Object obj) {
- properties.remove(property);
- properties.put(property, obj);
-
- }
-
+/*
+ * 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.basedriver.importer.core.upnp;
+
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.cybergarage.upnp.Device;
+
+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.basedriver.importer.util.DeviceSetup;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class UPnPDeviceImpl implements UPnPDevice {
+
+ /**
+ * <code>properties</code> Dictionary that contains Device properties
+ */
+ private Dictionary properties;
+ private Vector icons;
+ private Hashtable services;
+ /**
+ * @param dev
+ * Device the cyberLink Device used to rappresent the real UPnP
+ * Device
+ */
+ public UPnPDeviceImpl(Device dev, BundleContext context) {
+ properties = new Hashtable();
+ this.services=new Hashtable();
+ this.icons=new Vector();
+ DeviceSetup.deviceSetup(properties,dev,icons,services);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPDevice#getService(java.lang.String)
+ */
+ public UPnPService getService(String serviceId) {
+ return (UPnPServiceImpl) services.get(serviceId);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPDevice#getServices()
+ */
+ public UPnPService[] getServices() {
+ Enumeration e = services.elements();
+ if (e == null) {
+ //TODO should I return null or an empty array? The specification seems to said to return null
+ return null;
+ }
+ UPnPService[] uPnPser = new UPnPService[services.size()];
+ int i = 0;
+ while (e.hasMoreElements()) {
+ uPnPser[i] = (UPnPServiceImpl) e.nextElement();
+ i++;
+ }
+ return uPnPser;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPDevice#getIcons(java.lang.String)
+ */
+ public UPnPIcon[] getIcons(String locale) {
+ if (locale != null) {
+ return null;
+ }
+ if(icons.size()==0){
+ return null;
+ }
+ return (UPnPIcon[]) icons.toArray(new UPnPIcon[]{});
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPDevice#getDescriptions(java.lang.String)
+ */
+
+ public Dictionary getDescriptions(String locale) {
+ //TODO Sent the right localized version of Description if are available
+ if (locale != null) {
+ return null;
+ }
+ return properties;
+ }
+
+ /**
+ * @param serviceType
+ * @return true if device contains the serviceType
+ */
+ public boolean existServiceType(String serviceType) {
+ String[] services = (String[]) properties.get(UPnPService.TYPE);
+ if (services != null) {
+ for (int i = 0; i < services.length; i++) {
+ if (services[i].equals(serviceType)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param property
+ * @param obj
+ */
+ public void setProperty(String property, Object obj) {
+ properties.remove(property);
+ properties.put(property, obj);
+
+ }
+
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPIconImpl.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPIconImpl.java
index dba0d8a..fcce8a0 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPIconImpl.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPIconImpl.java
@@ -1,105 +1,105 @@
-/*
- * 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.basedriver.importer.core.upnp;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.cybergarage.upnp.Icon;
-
-import org.osgi.service.upnp.UPnPIcon;
-
-import org.apache.felix.upnp.basedriver.importer.util.HTTPRequestForIcon;
-import org.apache.felix.upnp.basedriver.importer.util.ParseLocation;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class UPnPIconImpl implements UPnPIcon {
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getMimeType()
- */
- private Icon icon;
- private org.cybergarage.upnp.Device cyberdev;
- public UPnPIconImpl(Icon cybericon,org.cybergarage.upnp.Device cyberdev){
- this.icon=cybericon;
- this.cyberdev=cyberdev;
- }
- public String getMimeType() {
- // TODO to check
- return icon.getMimeType();
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getWidth()
- */
- public int getWidth() {
- String width=icon.getWidth();
- if(width.length()==0){
- return -1;
- }
- return Integer.parseInt(width);
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getHeight()
- */
- public int getHeight() {
- String higth=icon.getHeight();
- if(higth.length()==0){
- return -1;
- }
- return Integer.parseInt(higth);
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getSize()
- */
- public int getSize() {
- // TODO Auto-generated method stub
- return -1;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getDepth()
- */
- public int getDepth() {
- String depth=icon.getDepth();
- if(depth.length()==0){
- return -1;
- }
- return Integer.parseInt(depth);
- }
-
- /* (non-Javadoc)
- * @see org.osgi.service.upnp.UPnPIcon#getInputStream()
- */
- public InputStream getInputStream() throws IOException {
- String urlString=ParseLocation.getUrlBase(cyberdev.getLocation())+icon.getURL();
- URL url=new URL(urlString);
- HTTPRequestForIcon requestor=new HTTPRequestForIcon(url);
-
- return requestor.getInputStream();
- }
-
-}
+/*
+ * 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.basedriver.importer.core.upnp;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.cybergarage.upnp.Icon;
+
+import org.osgi.service.upnp.UPnPIcon;
+
+import org.apache.felix.upnp.basedriver.importer.util.HTTPRequestForIcon;
+import org.apache.felix.upnp.basedriver.importer.util.ParseLocation;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class UPnPIconImpl implements UPnPIcon {
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getMimeType()
+ */
+ private Icon icon;
+ private org.cybergarage.upnp.Device cyberdev;
+ public UPnPIconImpl(Icon cybericon,org.cybergarage.upnp.Device cyberdev){
+ this.icon=cybericon;
+ this.cyberdev=cyberdev;
+ }
+ public String getMimeType() {
+ // TODO to check
+ return icon.getMimeType();
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getWidth()
+ */
+ public int getWidth() {
+ String width=icon.getWidth();
+ if(width.length()==0){
+ return -1;
+ }
+ return Integer.parseInt(width);
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getHeight()
+ */
+ public int getHeight() {
+ String higth=icon.getHeight();
+ if(higth.length()==0){
+ return -1;
+ }
+ return Integer.parseInt(higth);
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getSize()
+ */
+ public int getSize() {
+ // TODO Auto-generated method stub
+ return -1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getDepth()
+ */
+ public int getDepth() {
+ String depth=icon.getDepth();
+ if(depth.length()==0){
+ return -1;
+ }
+ return Integer.parseInt(depth);
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.upnp.UPnPIcon#getInputStream()
+ */
+ public InputStream getInputStream() throws IOException {
+ String urlString=ParseLocation.getUrlBase(cyberdev.getLocation())+icon.getURL();
+ URL url=new URL(urlString);
+ HTTPRequestForIcon requestor=new HTTPRequestForIcon(url);
+
+ return requestor.getInputStream();
+ }
+
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPServiceImpl.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPServiceImpl.java
index 40c7c26..877fe03 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPServiceImpl.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPServiceImpl.java
@@ -1,159 +1,159 @@
-/*
- * 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.basedriver.importer.core.upnp;
-
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import org.cybergarage.upnp.Action;
-import org.cybergarage.upnp.ActionList;
-import org.cybergarage.upnp.Service;
-import org.cybergarage.upnp.ServiceStateTable;
-import org.cybergarage.upnp.StateVariable;
-
-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 UPnPServiceImpl implements UPnPService {
- private Service service;
- private Hashtable actions;
- private Hashtable stateVariables;
-
- public UPnPServiceImpl(Service service) {
- this.service = service;
- actions = new Hashtable();
- stateVariables=new Hashtable();
- /*
- * action
- */
- ActionList actionlist = service.getActionList();
- for (int i = 0; i < actionlist.size(); i++) {
- Action act = actionlist.getAction(i);
- actions.put(act.getName(), new UPnPActionImpl(act,this));
- }
- /*StateVariable*/
- ServiceStateTable stateTable=service.getServiceStateTable();
- for(int i=0;i<stateTable.size();i++){
- StateVariable var= stateTable.getStateVariable(i);
- stateVariables.put(var.getName(),new UPnPStateVariableImpl(var));
- }
-
-
- } /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPService#getId()
- */
- public String getId() {
- // TODO Auto-generated method stub
- return service.getServiceID();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPService#getType()
- */
- public String getType() {
- // TODO Auto-generated method stub
- return service.getServiceType();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPService#getVersion()
- */
- public String getVersion() {
- String serviceType = service.getServiceType();
- int start = serviceType.lastIndexOf(':');
- String version = serviceType.substring(start+1);
- return version;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPService#getAction(java.lang.String)
- */
- public UPnPAction getAction(String name) {
- //TODO to check
- return (UPnPAction) actions.get(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPService#getActions()
- */
- public UPnPAction[] getActions() {
- //TODO check again
- Enumeration e=actions.elements();
- if(e==null){
- return null;
- }
- UPnPAction [] uPnPacts=new UPnPAction[actions.size()];
- int i=0;
- while(e.hasMoreElements()){
- uPnPacts[i]=(UPnPActionImpl)e.nextElement();
- i++;
- }
- return uPnPacts;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPService#getStateVariables()
- */
- public UPnPStateVariable[] getStateVariables() {
- //TODO check again
- UPnPStateVariableImpl [] vars =new UPnPStateVariableImpl[stateVariables.size()];
- Enumeration e=stateVariables.elements();
- if(e==null){
- return null;
- }
- int i=0;
- while(e.hasMoreElements()){
- vars[i]=(UPnPStateVariableImpl)e.nextElement();
- i++;
- }
- return vars;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.upnp.UPnPService#getStateVariable(java.lang.String)
- */
- public UPnPStateVariable getStateVariable(String name) {
- //TODO chack again
- return (UPnPStateVariableImpl) stateVariables.get(name);
- }
-
- public Service getCyberService(){
- return service;
- }
-
+/*
+ * 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.basedriver.importer.core.upnp;
+
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.cybergarage.upnp.Action;
+import org.cybergarage.upnp.ActionList;
+import org.cybergarage.upnp.Service;
+import org.cybergarage.upnp.ServiceStateTable;
+import org.cybergarage.upnp.StateVariable;
+
+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 UPnPServiceImpl implements UPnPService {
+ private Service service;
+ private Hashtable actions;
+ private Hashtable stateVariables;
+
+ public UPnPServiceImpl(Service service) {
+ this.service = service;
+ actions = new Hashtable();
+ stateVariables=new Hashtable();
+ /*
+ * action
+ */
+ ActionList actionlist = service.getActionList();
+ for (int i = 0; i < actionlist.size(); i++) {
+ Action act = actionlist.getAction(i);
+ actions.put(act.getName(), new UPnPActionImpl(act,this));
+ }
+ /*StateVariable*/
+ ServiceStateTable stateTable=service.getServiceStateTable();
+ for(int i=0;i<stateTable.size();i++){
+ StateVariable var= stateTable.getStateVariable(i);
+ stateVariables.put(var.getName(),new UPnPStateVariableImpl(var));
+ }
+
+
+ } /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPService#getId()
+ */
+ public String getId() {
+ // TODO Auto-generated method stub
+ return service.getServiceID();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPService#getType()
+ */
+ public String getType() {
+ // TODO Auto-generated method stub
+ return service.getServiceType();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPService#getVersion()
+ */
+ public String getVersion() {
+ String serviceType = service.getServiceType();
+ int start = serviceType.lastIndexOf(':');
+ String version = serviceType.substring(start+1);
+ return version;
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPService#getAction(java.lang.String)
+ */
+ public UPnPAction getAction(String name) {
+ //TODO to check
+ return (UPnPAction) actions.get(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPService#getActions()
+ */
+ public UPnPAction[] getActions() {
+ //TODO check again
+ Enumeration e=actions.elements();
+ if(e==null){
+ return null;
+ }
+ UPnPAction [] uPnPacts=new UPnPAction[actions.size()];
+ int i=0;
+ while(e.hasMoreElements()){
+ uPnPacts[i]=(UPnPActionImpl)e.nextElement();
+ i++;
+ }
+ return uPnPacts;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPService#getStateVariables()
+ */
+ public UPnPStateVariable[] getStateVariables() {
+ //TODO check again
+ UPnPStateVariableImpl [] vars =new UPnPStateVariableImpl[stateVariables.size()];
+ Enumeration e=stateVariables.elements();
+ if(e==null){
+ return null;
+ }
+ int i=0;
+ while(e.hasMoreElements()){
+ vars[i]=(UPnPStateVariableImpl)e.nextElement();
+ i++;
+ }
+ return vars;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.upnp.UPnPService#getStateVariable(java.lang.String)
+ */
+ public UPnPStateVariable getStateVariable(String name) {
+ //TODO chack again
+ return (UPnPStateVariableImpl) stateVariables.get(name);
+ }
+
+ public Service getCyberService(){
+ return service;
+ }
+
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPStateVariableImpl.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPStateVariableImpl.java
index f64b995..dd86bb9 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPStateVariableImpl.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/core/upnp/UPnPStateVariableImpl.java
@@ -1,274 +1,274 @@
-/*
- * 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.basedriver.importer.core.upnp;
-
-
-import java.util.Date;
-import java.util.Hashtable;
-
-import org.cybergarage.upnp.AllowedValueList;
-import org.cybergarage.upnp.AllowedValueRange;
-import org.cybergarage.upnp.StateVariable;
-
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.basedriver.Activator;
-import org.apache.felix.upnp.basedriver.util.Converter;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class UPnPStateVariableImpl implements UPnPStateVariable {
-
- private StateVariable variable;
-
- private Number max = null;
- private Number min = null;
- private Number step = null;
-
- private String[] values = null;
-
- private Boolean hasMaxMinStep = null;
- private Boolean hasRangeValues = null;
-
- private static Hashtable upnp2javaTable = null;
-
- static{
- upnp2javaTable = new Hashtable(30);
- String[] upnpType = null;
- upnpType = new String[]{"ui1","ui2","i1","i2","i4","int"};
- for (int i = 0; i < upnpType.length; i++) {
- upnp2javaTable.put(upnpType[i],Integer.class);
- }
-
- upnpType = new String[]{"ui4","time","time.tz"};
- for (int i = 0; i < upnpType.length; i++) {
- upnp2javaTable.put(upnpType[i],Long.class);
- }
-
- upnpType = new String[]{"r4","float"};
- for (int i = 0; i < upnpType.length; i++) {
- upnp2javaTable.put(upnpType[i],Float.class);
- }
-
- upnpType = new String[]{"r8","number","fixed.14.4"};
- for (int i = 0; i < upnpType.length; i++) {
- upnp2javaTable.put(upnpType[i],Double.class);
- }
-
- upnpType = new String[]{"char"};
- for (int i = 0; i < upnpType.length; i++) {
- upnp2javaTable.put(upnpType[i],Character.class);
- }
-
- upnpType = new String[]{"string","uri","uuid"};
- for (int i = 0; i < upnpType.length; i++) {
- upnp2javaTable.put(upnpType[i],String.class);
- }
-
- upnpType = new String[]{"date","dateTime","dateTime.tz"};
- for (int i = 0; i < upnpType.length; i++) {
- upnp2javaTable.put(upnpType[i],Date.class);
- }
-
- upnpType = new String[]{"boolean"};
- for (int i = 0; i < upnpType.length; i++) {
- upnp2javaTable.put(upnpType[i],Boolean.class);
- }
-
- upnpType = new String[]{"bin.base64","bin.hex"};
- for (int i = 0; i < upnpType.length; i++) {
- upnp2javaTable.put(upnpType[i],byte[].class);
- }
-
-
- }
-
- /**
- * @param variable
- */
- public UPnPStateVariableImpl(StateVariable variable) {
-
- this.variable = variable;
- }
-
- /**
- * @see org.osgi.service.upnp.UPnPStateVariable#getName()
- */
- public String getName() {
- return variable.getName();
- }
-
- /**
- * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
- */
- public Class getJavaDataType() {
- return (Class) upnp2javaTable.get(variable.getDataType());
- }
-
- /**
- * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
- */
- public String getUPnPDataType() {
- return variable.getDataType();
- }
-
- /**
- * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
- */
- public Object getDefaultValue() {
- //TODO must be implemented from scretch, it's just raccommend
- return null;
- }
-
- /**
- * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
- */
- public String[] getAllowedValues() {
- if(hasRangeValues == null)
- initValueConstraint();
-
- return values;
- }
-
- /**
- * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
- */
- public Number getMinimum() {
- if(hasMaxMinStep == null)
- initValueConstraint();
-
- return min;
- }
-
- /**
- * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
- */
- public Number getMaximum() {
- if(hasMaxMinStep == null)
- initValueConstraint();
-
- return max;
- }
-
- /**
- * <b>NOTE:</b> This type of control caches the value recieved by the Device so if XML changes it doesn't affect the OSGi service
- *
- * @since 0.3
- */
- private void initValueConstraint(){
- if(hasRangeValues != null || hasMaxMinStep != null)
- return;
-
- hasRangeValues = Boolean.FALSE;
- hasMaxMinStep = Boolean.FALSE;
-
- final AllowedValueRange allowedValueRange = variable.getAllowedValueRange();
- final AllowedValueList allowedValueList = variable.getAllowedValueList();
-
- if(allowedValueRange != null && allowedValueList != null){
- Activator.logger.WARNING("Imported device with StateVariable "
- +variable.getName()+" contains either AllowedValueRange and AllowedValueList UPnP doesn't allow it because it. Neither of the restriction will be applied");
-
- }else if( allowedValueRange != null ){
-
- initMaxMinStep(allowedValueRange);
-
- }else if( allowedValueList != null ){
-
- initAllowedValues(allowedValueList);
-
- }
- }
-
- /**
- * @param allowedValueList
- * @since 0.3
- */
- private void initAllowedValues(AllowedValueList allowedValueList){
- //PRE:invoked only by initValueConstraint() thus allowedValueList must not null
- if (String.class != getJavaDataType()) {
- Activator.logger.WARNING("Imported device with StateVariable "
- +variable.getName()+" contains AllowedValueList but its UPnP type doesn't allow it because it is +"+getUPnPDataType());
- return;
- }
-
- if(allowedValueList.size() == 0){
- return ;
- }
-
- values = new String[allowedValueList.size()];
- for (int i = 0; i < allowedValueList.size(); i++) {
- values[i] = allowedValueList.getAllowedValue(i).getValue();
- }
- }
-
- /**
- * @param allowedValueRange
- * @since 0.3
- */
- private void initMaxMinStep(AllowedValueRange allowedValueRange){
- //PRE:invoked only by initValueConstraint() thus allowedValueRange must not be null
- if(allowedValueRange==null){
- return;
- }
-
- if(!Number.class.isAssignableFrom(getJavaDataType())){
- Activator.logger.WARNING("Imported device with StateVariable "
- +variable.getName()+" contains AllowedValueRange but its UPnP type doesn't allow it because it is +"+getUPnPDataType());
- return;
- }
-
- final String maxStr = allowedValueRange.getMaximum();
- final String minStr = allowedValueRange.getMinimum();
- final String stepStr = allowedValueRange.getStep();
-
- try{
- final String type = getUPnPDataType();
- max = (Number)Converter.parseString(maxStr,type);
- min = (Number)Converter.parseString(minStr,type);
- step = (Number)Converter.parseString(stepStr,type);
- }catch(Exception ex){
- Activator.logger.WARNING("Imported device with StateVariable "
- +variable.getName()+" contains an invalid definition for AllowedValueRange");
- }
- hasMaxMinStep = Boolean.TRUE;
- }
-
- /**
- * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
- */
- public Number getStep() {
- if(hasMaxMinStep == null)
- initValueConstraint();
-
- return step;
-
- }
-
- /**
- * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
- */
- public boolean sendsEvents() {
- return variable.isSendEvents();
- }
-
-
-}
+/*
+ * 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.basedriver.importer.core.upnp;
+
+
+import java.util.Date;
+import java.util.Hashtable;
+
+import org.cybergarage.upnp.AllowedValueList;
+import org.cybergarage.upnp.AllowedValueRange;
+import org.cybergarage.upnp.StateVariable;
+
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.basedriver.Activator;
+import org.apache.felix.upnp.basedriver.util.Converter;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class UPnPStateVariableImpl implements UPnPStateVariable {
+
+ private StateVariable variable;
+
+ private Number max = null;
+ private Number min = null;
+ private Number step = null;
+
+ private String[] values = null;
+
+ private Boolean hasMaxMinStep = null;
+ private Boolean hasRangeValues = null;
+
+ private static Hashtable upnp2javaTable = null;
+
+ static{
+ upnp2javaTable = new Hashtable(30);
+ String[] upnpType = null;
+ upnpType = new String[]{"ui1","ui2","i1","i2","i4","int"};
+ for (int i = 0; i < upnpType.length; i++) {
+ upnp2javaTable.put(upnpType[i],Integer.class);
+ }
+
+ upnpType = new String[]{"ui4","time","time.tz"};
+ for (int i = 0; i < upnpType.length; i++) {
+ upnp2javaTable.put(upnpType[i],Long.class);
+ }
+
+ upnpType = new String[]{"r4","float"};
+ for (int i = 0; i < upnpType.length; i++) {
+ upnp2javaTable.put(upnpType[i],Float.class);
+ }
+
+ upnpType = new String[]{"r8","number","fixed.14.4"};
+ for (int i = 0; i < upnpType.length; i++) {
+ upnp2javaTable.put(upnpType[i],Double.class);
+ }
+
+ upnpType = new String[]{"char"};
+ for (int i = 0; i < upnpType.length; i++) {
+ upnp2javaTable.put(upnpType[i],Character.class);
+ }
+
+ upnpType = new String[]{"string","uri","uuid"};
+ for (int i = 0; i < upnpType.length; i++) {
+ upnp2javaTable.put(upnpType[i],String.class);
+ }
+
+ upnpType = new String[]{"date","dateTime","dateTime.tz"};
+ for (int i = 0; i < upnpType.length; i++) {
+ upnp2javaTable.put(upnpType[i],Date.class);
+ }
+
+ upnpType = new String[]{"boolean"};
+ for (int i = 0; i < upnpType.length; i++) {
+ upnp2javaTable.put(upnpType[i],Boolean.class);
+ }
+
+ upnpType = new String[]{"bin.base64","bin.hex"};
+ for (int i = 0; i < upnpType.length; i++) {
+ upnp2javaTable.put(upnpType[i],byte[].class);
+ }
+
+
+ }
+
+ /**
+ * @param variable
+ */
+ public UPnPStateVariableImpl(StateVariable variable) {
+
+ this.variable = variable;
+ }
+
+ /**
+ * @see org.osgi.service.upnp.UPnPStateVariable#getName()
+ */
+ public String getName() {
+ return variable.getName();
+ }
+
+ /**
+ * @see org.osgi.service.upnp.UPnPStateVariable#getJavaDataType()
+ */
+ public Class getJavaDataType() {
+ return (Class) upnp2javaTable.get(variable.getDataType());
+ }
+
+ /**
+ * @see org.osgi.service.upnp.UPnPStateVariable#getUPnPDataType()
+ */
+ public String getUPnPDataType() {
+ return variable.getDataType();
+ }
+
+ /**
+ * @see org.osgi.service.upnp.UPnPStateVariable#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ //TODO must be implemented from scretch, it's just raccommend
+ return null;
+ }
+
+ /**
+ * @see org.osgi.service.upnp.UPnPStateVariable#getAllowedValues()
+ */
+ public String[] getAllowedValues() {
+ if(hasRangeValues == null)
+ initValueConstraint();
+
+ return values;
+ }
+
+ /**
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMinimum()
+ */
+ public Number getMinimum() {
+ if(hasMaxMinStep == null)
+ initValueConstraint();
+
+ return min;
+ }
+
+ /**
+ * @see org.osgi.service.upnp.UPnPStateVariable#getMaximum()
+ */
+ public Number getMaximum() {
+ if(hasMaxMinStep == null)
+ initValueConstraint();
+
+ return max;
+ }
+
+ /**
+ * <b>NOTE:</b> This type of control caches the value recieved by the Device so if XML changes it doesn't affect the OSGi service
+ *
+ * @since 0.3
+ */
+ private void initValueConstraint(){
+ if(hasRangeValues != null || hasMaxMinStep != null)
+ return;
+
+ hasRangeValues = Boolean.FALSE;
+ hasMaxMinStep = Boolean.FALSE;
+
+ final AllowedValueRange allowedValueRange = variable.getAllowedValueRange();
+ final AllowedValueList allowedValueList = variable.getAllowedValueList();
+
+ if(allowedValueRange != null && allowedValueList != null){
+ Activator.logger.WARNING("Imported device with StateVariable "
+ +variable.getName()+" contains either AllowedValueRange and AllowedValueList UPnP doesn't allow it because it. Neither of the restriction will be applied");
+
+ }else if( allowedValueRange != null ){
+
+ initMaxMinStep(allowedValueRange);
+
+ }else if( allowedValueList != null ){
+
+ initAllowedValues(allowedValueList);
+
+ }
+ }
+
+ /**
+ * @param allowedValueList
+ * @since 0.3
+ */
+ private void initAllowedValues(AllowedValueList allowedValueList){
+ //PRE:invoked only by initValueConstraint() thus allowedValueList must not null
+ if (String.class != getJavaDataType()) {
+ Activator.logger.WARNING("Imported device with StateVariable "
+ +variable.getName()+" contains AllowedValueList but its UPnP type doesn't allow it because it is +"+getUPnPDataType());
+ return;
+ }
+
+ if(allowedValueList.size() == 0){
+ return ;
+ }
+
+ values = new String[allowedValueList.size()];
+ for (int i = 0; i < allowedValueList.size(); i++) {
+ values[i] = allowedValueList.getAllowedValue(i).getValue();
+ }
+ }
+
+ /**
+ * @param allowedValueRange
+ * @since 0.3
+ */
+ private void initMaxMinStep(AllowedValueRange allowedValueRange){
+ //PRE:invoked only by initValueConstraint() thus allowedValueRange must not be null
+ if(allowedValueRange==null){
+ return;
+ }
+
+ if(!Number.class.isAssignableFrom(getJavaDataType())){
+ Activator.logger.WARNING("Imported device with StateVariable "
+ +variable.getName()+" contains AllowedValueRange but its UPnP type doesn't allow it because it is +"+getUPnPDataType());
+ return;
+ }
+
+ final String maxStr = allowedValueRange.getMaximum();
+ final String minStr = allowedValueRange.getMinimum();
+ final String stepStr = allowedValueRange.getStep();
+
+ try{
+ final String type = getUPnPDataType();
+ max = (Number)Converter.parseString(maxStr,type);
+ min = (Number)Converter.parseString(minStr,type);
+ step = (Number)Converter.parseString(stepStr,type);
+ }catch(Exception ex){
+ Activator.logger.WARNING("Imported device with StateVariable "
+ +variable.getName()+" contains an invalid definition for AllowedValueRange");
+ }
+ hasMaxMinStep = Boolean.TRUE;
+ }
+
+ /**
+ * @see org.osgi.service.upnp.UPnPStateVariable#getStep()
+ */
+ public Number getStep() {
+ if(hasMaxMinStep == null)
+ initValueConstraint();
+
+ return step;
+
+ }
+
+ /**
+ * @see org.osgi.service.upnp.UPnPStateVariable#sendsEvents()
+ */
+ public boolean sendsEvents() {
+ return variable.isSendEvents();
+ }
+
+
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/DeviceSetup.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/DeviceSetup.java
index e24e043..332bf60 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/DeviceSetup.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/DeviceSetup.java
@@ -1,143 +1,143 @@
-/*
- * 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.basedriver.importer.util;
-
-
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.cybergarage.upnp.Device;
-import org.cybergarage.upnp.DeviceList;
-import org.cybergarage.upnp.IconList;
-import org.cybergarage.upnp.Service;
-import org.cybergarage.upnp.ServiceList;
-
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPIcon;
-import org.osgi.service.upnp.UPnPService;
-
-import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPIconImpl;
-import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPServiceImpl;
-import org.apache.felix.upnp.basedriver.util.Constants;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class DeviceSetup {
-
- public static void deviceSetup(Dictionary properties, Device dev,Vector icons,Hashtable services) {
- //TODO if I don't have any device, the size of devlist is 0
- DeviceList devList = dev.getDeviceList();
- /* childrenUDN property */
- if (devList.size() > 0) {
- String[] childrenUDN = new String[devList.size()];
- for (int i = 0; i < devList.size(); i++) {
- childrenUDN[i] = devList.getDevice(i).getUDN();
- }
- properties.put(UPnPDevice.CHILDREN_UDN, childrenUDN);
- }
- /* DEVICE CATEGORY */
- properties.put(
- org.osgi.service
- .device.Constants.DEVICE_CATEGORY,
- new String[]{UPnPDevice.DEVICE_CATEGORY}
- );
-
- /*UPNP_IMPORT*/
- properties.put(Constants.UPNP_IMPORT, "http://felix.apache.org");
-
- /* FRIENDLY_NAME */
- //check the implementation fo getFriendlyName made by CyberLink
- properties.put(UPnPDevice.FRIENDLY_NAME, dev.getFriendlyName());
- /* MANUFACTURER */
- properties.put(UPnPDevice.MANUFACTURER, dev.getManufacture());
- /* MANUFACTURER_URL */
- properties.put(UPnPDevice.MANUFACTURER_URL, dev.getManufactureURL());
- /* MODEL_DESCRIPTION */
- properties.put(UPnPDevice.MODEL_DESCRIPTION, dev.getModelDescription());
- /* MODEL_NAME */
- properties.put(UPnPDevice.MODEL_NAME, dev.getModelName());
- /* MODEL_NUMBER */
- properties.put(UPnPDevice.MODEL_NUMBER, dev.getModelNumber());
- /* MODEL_URL */
- properties.put(UPnPDevice.MODEL_URL, dev.getModelURL());
- /* PARENT_UDN */
- if (!dev.isRootDevice()) {
- Device parent = dev.getParentDevice();
- /*Device root = dev.getRootDevice();
- if (root == null) {
- System.out.println("il device " + dev.getFriendlyName()
- + "non ha root !!!");
- }*/
- properties.put(UPnPDevice.PARENT_UDN, parent.getUDN());
- }
- /* PRESENTATION_URL */
- properties.put(UPnPDevice.PRESENTATION_URL, dev.getPresentationURL());
- /* SERIAL_NUMBER */
- properties.put(UPnPDevice.SERIAL_NUMBER, dev.getSerialNumber());
- /* TYPE */
- properties.put(UPnPDevice.TYPE, dev.getDeviceType());
- /* UDN */
- properties.put(UPnPDevice.UDN, dev.getUDN());
- /* UPC */
- properties.put(UPnPDevice.UPC, dev.getUPC());
-
- IconList iconsList = dev.getIconList();
- if (iconsList.size() != 0) {
- for (int i = 0; i < iconsList.size(); i++) {
- UPnPIcon icon = new UPnPIconImpl(iconsList.getIcon(i),dev);
- icons.add(icon);
- }
- }
- /*
- * service of this device
- */
- ServiceList serviceList = dev.getServiceList();
- /*
- * if dev contain no service I'll get an empty SserviceList object
- */
- String[] servicesIDProperty = new String[serviceList.size()];
- String[] servicesTypeProperty;
- HashSet serTypeSet = new HashSet();
- for (int i = 0; i < serviceList.size(); i++) {
- Service service = serviceList.getService(i);
- UPnPServiceImpl serviceImpl = new UPnPServiceImpl(service);
- services.put(service.getServiceID(), serviceImpl);
- servicesIDProperty[i] = serviceImpl.getId();
- serTypeSet.add(serviceImpl.getType());
- }
- servicesTypeProperty = new String[serTypeSet.size()];
- Iterator iter = serTypeSet.iterator();
- int i = 0;
- while (iter.hasNext()) {
- servicesTypeProperty[i] = (String) iter.next();
- i++;
- }
- properties.put(UPnPService.ID, servicesIDProperty);
- properties.put(UPnPService.TYPE, servicesTypeProperty);
-
-
- }
-
+/*
+ * 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.basedriver.importer.util;
+
+
+import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.cybergarage.upnp.Device;
+import org.cybergarage.upnp.DeviceList;
+import org.cybergarage.upnp.IconList;
+import org.cybergarage.upnp.Service;
+import org.cybergarage.upnp.ServiceList;
+
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPIcon;
+import org.osgi.service.upnp.UPnPService;
+
+import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPIconImpl;
+import org.apache.felix.upnp.basedriver.importer.core.upnp.UPnPServiceImpl;
+import org.apache.felix.upnp.basedriver.util.Constants;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class DeviceSetup {
+
+ public static void deviceSetup(Dictionary properties, Device dev,Vector icons,Hashtable services) {
+ //TODO if I don't have any device, the size of devlist is 0
+ DeviceList devList = dev.getDeviceList();
+ /* childrenUDN property */
+ if (devList.size() > 0) {
+ String[] childrenUDN = new String[devList.size()];
+ for (int i = 0; i < devList.size(); i++) {
+ childrenUDN[i] = devList.getDevice(i).getUDN();
+ }
+ properties.put(UPnPDevice.CHILDREN_UDN, childrenUDN);
+ }
+ /* DEVICE CATEGORY */
+ properties.put(
+ org.osgi.service
+ .device.Constants.DEVICE_CATEGORY,
+ new String[]{UPnPDevice.DEVICE_CATEGORY}
+ );
+
+ /*UPNP_IMPORT*/
+ properties.put(Constants.UPNP_IMPORT, "http://felix.apache.org");
+
+ /* FRIENDLY_NAME */
+ //check the implementation fo getFriendlyName made by CyberLink
+ properties.put(UPnPDevice.FRIENDLY_NAME, dev.getFriendlyName());
+ /* MANUFACTURER */
+ properties.put(UPnPDevice.MANUFACTURER, dev.getManufacture());
+ /* MANUFACTURER_URL */
+ properties.put(UPnPDevice.MANUFACTURER_URL, dev.getManufactureURL());
+ /* MODEL_DESCRIPTION */
+ properties.put(UPnPDevice.MODEL_DESCRIPTION, dev.getModelDescription());
+ /* MODEL_NAME */
+ properties.put(UPnPDevice.MODEL_NAME, dev.getModelName());
+ /* MODEL_NUMBER */
+ properties.put(UPnPDevice.MODEL_NUMBER, dev.getModelNumber());
+ /* MODEL_URL */
+ properties.put(UPnPDevice.MODEL_URL, dev.getModelURL());
+ /* PARENT_UDN */
+ if (!dev.isRootDevice()) {
+ Device parent = dev.getParentDevice();
+ /*Device root = dev.getRootDevice();
+ if (root == null) {
+ System.out.println("il device " + dev.getFriendlyName()
+ + "non ha root !!!");
+ }*/
+ properties.put(UPnPDevice.PARENT_UDN, parent.getUDN());
+ }
+ /* PRESENTATION_URL */
+ properties.put(UPnPDevice.PRESENTATION_URL, dev.getPresentationURL());
+ /* SERIAL_NUMBER */
+ properties.put(UPnPDevice.SERIAL_NUMBER, dev.getSerialNumber());
+ /* TYPE */
+ properties.put(UPnPDevice.TYPE, dev.getDeviceType());
+ /* UDN */
+ properties.put(UPnPDevice.UDN, dev.getUDN());
+ /* UPC */
+ properties.put(UPnPDevice.UPC, dev.getUPC());
+
+ IconList iconsList = dev.getIconList();
+ if (iconsList.size() != 0) {
+ for (int i = 0; i < iconsList.size(); i++) {
+ UPnPIcon icon = new UPnPIconImpl(iconsList.getIcon(i),dev);
+ icons.add(icon);
+ }
+ }
+ /*
+ * service of this device
+ */
+ ServiceList serviceList = dev.getServiceList();
+ /*
+ * if dev contain no service I'll get an empty SserviceList object
+ */
+ String[] servicesIDProperty = new String[serviceList.size()];
+ String[] servicesTypeProperty;
+ HashSet serTypeSet = new HashSet();
+ for (int i = 0; i < serviceList.size(); i++) {
+ Service service = serviceList.getService(i);
+ UPnPServiceImpl serviceImpl = new UPnPServiceImpl(service);
+ services.put(service.getServiceID(), serviceImpl);
+ servicesIDProperty[i] = serviceImpl.getId();
+ serTypeSet.add(serviceImpl.getType());
+ }
+ servicesTypeProperty = new String[serTypeSet.size()];
+ Iterator iter = serTypeSet.iterator();
+ int i = 0;
+ while (iter.hasNext()) {
+ servicesTypeProperty[i] = (String) iter.next();
+ i++;
+ }
+ properties.put(UPnPService.ID, servicesIDProperty);
+ properties.put(UPnPService.TYPE, servicesTypeProperty);
+
+
+ }
+
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/HTTPRequestForIcon.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/HTTPRequestForIcon.java
index 6987bfb..3ebfa84 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/HTTPRequestForIcon.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/HTTPRequestForIcon.java
@@ -1,98 +1,98 @@
-/*
- * 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.basedriver.importer.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.URL;
-
-/**
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class HTTPRequestForIcon {
- private URL url;
-
- public HTTPRequestForIcon(URL url) {
- this.url = url;
- }
- public InputStream getInputStream() throws IOException {
- //TODO we should speak about that
- InetAddress inet = InetAddress.getByName(url.getHost());
- int port = url.getPort();
- Socket socket = null;
- socket = new Socket(inet, port);
- OutputStream out = null;
- out = socket.getOutputStream();
- String CRLF = "\r\n";
- url.getFile();
- String request = "GET " + url.getPath() + " " + "HTTP/1.1" + CRLF
- + "Host: " + url.getHost() + CRLF + "Connection: " + "close"
- + CRLF + CRLF;
- //System.out.println(request);
- byte[] get = request.getBytes();
- out.write(get, 0, get.length);
- InputStream in = socket.getInputStream();
- boolean exit = true;
- while (exit) {
- byte[] b = new byte[1];
- in.read(b, 0, b.length);
-
- if (b[0] == '\r') {
- in.read(b, 0, b.length);
- while (b[0] == '\r') {
- in.read(b, 0, b.length);
- }
- if (b[0] != '\n') {
- continue;
- }
- in.read(b, 0, b.length);
- if (b[0] != '\r') {
- continue;
- }
- in.read(b, 0, b.length);
- if (b[0] != '\n') {
- continue;
- }
- exit = false;
- }
- }
-
- return in;
-
- /*
- * HTTPResponse response=new HTTPResponse(in);
- * InputStream iconInStream=response.getContentInputStream();
- * return iconInStream;
- *
- */
- /*
- *
- * byte[] buff = new byte[maxLength]; int initial = 0; while (initial <
- * maxLength - 1) { int read = 0; read = in.read(buff, initial, 1024);
- * if (read == -1) break; initial += read; } System.out.println(new
- * String(buff));
- */
-
- }
-
+/*
+ * 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.basedriver.importer.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.URL;
+
+/**
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class HTTPRequestForIcon {
+ private URL url;
+
+ public HTTPRequestForIcon(URL url) {
+ this.url = url;
+ }
+ public InputStream getInputStream() throws IOException {
+ //TODO we should speak about that
+ InetAddress inet = InetAddress.getByName(url.getHost());
+ int port = url.getPort();
+ Socket socket = null;
+ socket = new Socket(inet, port);
+ OutputStream out = null;
+ out = socket.getOutputStream();
+ String CRLF = "\r\n";
+ url.getFile();
+ String request = "GET " + url.getPath() + " " + "HTTP/1.1" + CRLF
+ + "Host: " + url.getHost() + CRLF + "Connection: " + "close"
+ + CRLF + CRLF;
+ //System.out.println(request);
+ byte[] get = request.getBytes();
+ out.write(get, 0, get.length);
+ InputStream in = socket.getInputStream();
+ boolean exit = true;
+ while (exit) {
+ byte[] b = new byte[1];
+ in.read(b, 0, b.length);
+
+ if (b[0] == '\r') {
+ in.read(b, 0, b.length);
+ while (b[0] == '\r') {
+ in.read(b, 0, b.length);
+ }
+ if (b[0] != '\n') {
+ continue;
+ }
+ in.read(b, 0, b.length);
+ if (b[0] != '\r') {
+ continue;
+ }
+ in.read(b, 0, b.length);
+ if (b[0] != '\n') {
+ continue;
+ }
+ exit = false;
+ }
+ }
+
+ return in;
+
+ /*
+ * HTTPResponse response=new HTTPResponse(in);
+ * InputStream iconInStream=response.getContentInputStream();
+ * return iconInStream;
+ *
+ */
+ /*
+ *
+ * byte[] buff = new byte[maxLength]; int initial = 0; while (initial <
+ * maxLength - 1) { int read = 0; read = in.read(buff, initial, 1024);
+ * if (read == -1) break; initial += read; } System.out.println(new
+ * String(buff));
+ */
+
+ }
+
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/ParseLocation.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/ParseLocation.java
index 21c0c4f..089259d 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/ParseLocation.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/ParseLocation.java
@@ -1,31 +1,31 @@
-/*
- * 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.basedriver.importer.util;
-
-/**
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class ParseLocation {
- public static String getUrlBase(String location){
- String [] splited=StringSplitter.split(location, '/');
- String value=splited[0]+"/"+"/"+splited[2];
- return value;
- }
-}
+/*
+ * 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.basedriver.importer.util;
+
+/**
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class ParseLocation {
+ public static String getUrlBase(String location){
+ String [] splited=StringSplitter.split(location, '/');
+ String value=splited[0]+"/"+"/"+splited[2];
+ return value;
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/ParseUSN.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/ParseUSN.java
index c0194ac..47f426f 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/ParseUSN.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/importer/util/ParseUSN.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.basedriver.importer.util;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class ParseUSN {
- boolean service;
- boolean device;
- String udn;
- String serviceType;
-
- public ParseUSN(String usn) {
- String [] splited=StringSplitter.split(usn, ':');
- if(splited.length==5||splited.length==2){
- udn="uuid:"+splited[1];
- device=true;
- service=false;
- }else if(splited.length==8){
- udn="uuid:"+splited[1];
- if(splited[5].equals("device")){
- device=true;
- service=false;
- }else{
- serviceType=splited[3]+":"+splited[4]+":"+splited[5]+":"+splited[6]+":"+splited[7];
- device=false;
- service=true;
- }
- }
- }
-
- public boolean isService() {
- return service;
- }
- public boolean isDevice() {
- return device;
- }
- public String getUDN() {
- return udn;
- }
- public String getServiceType() {
- return serviceType;
- }
-
+/*
+ * 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.basedriver.importer.util;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class ParseUSN {
+ boolean service;
+ boolean device;
+ String udn;
+ String serviceType;
+
+ public ParseUSN(String usn) {
+ String [] splited=StringSplitter.split(usn, ':');
+ if(splited.length==5||splited.length==2){
+ udn="uuid:"+splited[1];
+ device=true;
+ service=false;
+ }else if(splited.length==8){
+ udn="uuid:"+splited[1];
+ if(splited[5].equals("device")){
+ device=true;
+ service=false;
+ }else{
+ serviceType=splited[3]+":"+splited[4]+":"+splited[5]+":"+splited[6]+":"+splited[7];
+ device=false;
+ service=true;
+ }
+ }
+ }
+
+ public boolean isService() {
+ return service;
+ }
+ public boolean isDevice() {
+ return device;
+ }
+ public String getUDN() {
+ return udn;
+ }
+ public String getServiceType() {
+ return serviceType;
+ }
+
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/tool/Logger.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/tool/Logger.java
index e1c4ed1..2d28aa2 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/tool/Logger.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/tool/Logger.java
@@ -1,253 +1,253 @@
-/*
- * 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.basedriver.tool;
-
-import java.io.PrintStream;
-
-import org.apache.felix.upnp.basedriver.Activator;
-import org.cybergarage.util.Debug;
-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.log.LogService;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class Logger implements ServiceListener {
-
- private ServiceReference rls;
- private LogService osgiLogService;
- private int level;
- private PrintStream out;
- public final static String NEWLINE = System.getProperty("line.separator");
- public static final String ROW ="\n================REQUEST=====================\n";
- public static final String END_ROW ="--------------------------------------------";
-
- private final static String LEVEL_TO_STRING[] = new String[]{
- "",
- "ERROR [ " + Activator.bc.getBundle().getBundleId() + " ] ",
- "WARNING [ " + Activator.bc.getBundle().getBundleId() + " ] ",
- "INFO [ " + Activator.bc.getBundle().getBundleId() + " ] ",
- "DEBUG [ " + Activator.bc.getBundle().getBundleId() + " ] ",
- };
-
-
- /**
- * Create a Logger with <code>System.out</code> as <tt>PrintStream</tt> and without
- * reporting message on both <tt>PrintStream</tt> and <tt>LogService</tt>
- *
- * @param log <tt>ServiceReference</tt> to the <tt>LogService</tt> to use,
- * or null to avoid the use of this service
- *
- * @see #Logger(LogService, PrintStream, boolean)
- */
- public Logger(String levelStr){
- this.out = System.out;
- try {
- this.level = Integer.parseInt(levelStr);
- } catch (Exception ex){
- out.println("WARNING [UPnPBaseDriver Log]: " + levelStr+" is not a valid value!");
- this.level=2;
- }
- findService();
- }
-
- public void setCyberDebug(String value){
- try {
- if (Boolean.valueOf(value).booleanValue()){
- Debug.on();
- out.println("INFO [UPnPBaseDriver] Started CyberLink Debug");
- }
- } catch (Exception ex){
- out.println("WARNING [UPnPBaseDriver CyberLog]: " + value +" is not a valid value!");
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////// programmatic interface ////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
-
- public void setLogLevel(int level){
- if (level < 0 || level >4 ) throw new IllegalArgumentException("Log Level must be [0-4]");
- this.level = level;
- }
-
- public int getLogLevel(){
- return this.level;
- }
-
-
- public void setCyberDebug(boolean value){
- if (value) Debug.on();
- else Debug.off();
- }
-
- public boolean getCyberDebug(){
- return Debug.isOn();
- }
- //////////////////////////// end programmatic interface ////////////////////////////
-
-
- public final void ERROR(String message) {
- log(1,message);
- }
-
- public final void WARNING(String message) {
- log(2,message);
- }
-
- public final void INFO(String message) {
- log(3,message);
- }
-
- public final void DEBUG(String message) {
- log(4,message);
- }
-
- public final void PACKET(String message) {
- log(4, new StringBuffer(ROW).append(message).append(END_ROW).toString());
- }
-
- /**
- * Logs a message.
- *
- * <p>The <tt>ServiceReference</tt> field and the <tt>Throwable</tt>
- * field of the <tt>LogEntry</tt> object will be set to <tt>null</tt>.
- * @param msglevel The severity of the message.
- * This should be one of the defined log levels
- * but may be any integer that is interpreted in a user defined way.
- * @param message Human readable string describing the condition or <tt>null</tt>.
- * @see #LOG_ERROR
- * @see #LOG_WARNING
- * @see #LOG_INFO
- * @see #LOG_DEBUG
- */
- public void log(int msglevel, String message) {
- synchronized (this) {
- if (msglevel <= this.level){
- if (this.osgiLogService != null ){
- osgiLogService.log(msglevel, message);
- }
- else {
- StringBuffer sb = new StringBuffer(Logger.LEVEL_TO_STRING[msglevel]);
- this.out.println(sb.append(message));
- }
- }
- }
-
- }
-
- /**
- * Logs a message with an exception.
- *
- * <p>The <tt>ServiceReference</tt> field of the <tt>LogEntry</tt> object will be set to <tt>null</tt>.
- * @param msglevel The severity of the message.
- * This should be one of the defined log levels
- * but may be any integer that is interpreted in a user defined way.
- * @param message The human readable string describing the condition or <tt>null</tt>.
- * @param exception The exception that reflects the condition or <tt>null</tt>.
- * @see #LOG_ERROR
- * @see #LOG_WARNING
- * @see #LOG_INFO
- * @see #LOG_DEBUG
- */
- public void log(int msglevel, String message, Throwable exception) {
- synchronized (this) {
- if (msglevel <= this.level){
- if(this.osgiLogService != null){
- osgiLogService.log(msglevel, message, exception);
- }
- else {
- StringBuffer sb = new StringBuffer(Logger.LEVEL_TO_STRING[msglevel]);
- this.out.println(sb.append(message).append(NEWLINE).append(exception));
- exception.printStackTrace(this.out);
- }
- }
- }
- }
-
- private synchronized void setLogService(ServiceReference reference){
- this.rls = reference;
- this.osgiLogService = (LogService) Activator.bc.getService(rls);
- }
- /**
- * This look for a <tt>LogService</tt> if it founds no <tt>LogService</tt> will register a new
- * Listener of LogService
- *
- */
- private synchronized void findService() {
- //PRE:Actually no LogService are setted and we are registered as ServiceListener
- // for LogService (unregisterin event)
- this.rls = Activator.bc.getServiceReference(LogService.class.getName());
- if (this.rls != null){
- this.osgiLogService = (LogService) Activator.bc.getService(rls);
- }
- try {
- Activator.bc.addServiceListener(this,
- "(" + Constants.OBJECTCLASS + "=" + LogService.class.getName() + ")"
- );
- } catch (InvalidSyntaxException ignore) {}
- //POST: We are connected to a LogService or we are registered as ServiceListener
- // for LogService(registering event)
- }
-
- private synchronized void releaseLogService() {
- if( osgiLogService != null)
- Activator.bc.ungetService(this.rls);
- this.rls = null;
- this.osgiLogService = null;
- }
-
- /**
- * Used to keep track the existence of a <tt>LogService</tt>
- *
- * @see ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
- */
- public void serviceChanged(ServiceEvent e) {
- switch (e.getType()) {
- case ServiceEvent.REGISTERED: {
- // put here code check for serviceid
- setLogService(e.getServiceReference());
- }break;
-
- case ServiceEvent.MODIFIED:
- break;
-
- case ServiceEvent.UNREGISTERING: {
- // put here code check for serviceid
- releaseLogService();
- }break;
- }
- }
-
- /**
- * Stop using the <tt>LogService</tt> and listening for those service event
- *
- * NOTE: All the message will be reported to <tt>PrintStream</tt>
- *
- */
- public void close(){
- Activator.bc.removeServiceListener(this);
- releaseLogService();
- }
-}
+/*
+ * 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.basedriver.tool;
+
+import java.io.PrintStream;
+
+import org.apache.felix.upnp.basedriver.Activator;
+import org.cybergarage.util.Debug;
+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.log.LogService;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class Logger implements ServiceListener {
+
+ private ServiceReference rls;
+ private LogService osgiLogService;
+ private int level;
+ private PrintStream out;
+ public final static String NEWLINE = System.getProperty("line.separator");
+ public static final String ROW ="\n================REQUEST=====================\n";
+ public static final String END_ROW ="--------------------------------------------";
+
+ private final static String LEVEL_TO_STRING[] = new String[]{
+ "",
+ "ERROR [ " + Activator.bc.getBundle().getBundleId() + " ] ",
+ "WARNING [ " + Activator.bc.getBundle().getBundleId() + " ] ",
+ "INFO [ " + Activator.bc.getBundle().getBundleId() + " ] ",
+ "DEBUG [ " + Activator.bc.getBundle().getBundleId() + " ] ",
+ };
+
+
+ /**
+ * Create a Logger with <code>System.out</code> as <tt>PrintStream</tt> and without
+ * reporting message on both <tt>PrintStream</tt> and <tt>LogService</tt>
+ *
+ * @param log <tt>ServiceReference</tt> to the <tt>LogService</tt> to use,
+ * or null to avoid the use of this service
+ *
+ * @see #Logger(LogService, PrintStream, boolean)
+ */
+ public Logger(String levelStr){
+ this.out = System.out;
+ try {
+ this.level = Integer.parseInt(levelStr);
+ } catch (Exception ex){
+ out.println("WARNING [UPnPBaseDriver Log]: " + levelStr+" is not a valid value!");
+ this.level=2;
+ }
+ findService();
+ }
+
+ public void setCyberDebug(String value){
+ try {
+ if (Boolean.valueOf(value).booleanValue()){
+ Debug.on();
+ out.println("INFO [UPnPBaseDriver] Started CyberLink Debug");
+ }
+ } catch (Exception ex){
+ out.println("WARNING [UPnPBaseDriver CyberLog]: " + value +" is not a valid value!");
+ }
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////// programmatic interface ////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////
+
+ public void setLogLevel(int level){
+ if (level < 0 || level >4 ) throw new IllegalArgumentException("Log Level must be [0-4]");
+ this.level = level;
+ }
+
+ public int getLogLevel(){
+ return this.level;
+ }
+
+
+ public void setCyberDebug(boolean value){
+ if (value) Debug.on();
+ else Debug.off();
+ }
+
+ public boolean getCyberDebug(){
+ return Debug.isOn();
+ }
+ //////////////////////////// end programmatic interface ////////////////////////////
+
+
+ public final void ERROR(String message) {
+ log(1,message);
+ }
+
+ public final void WARNING(String message) {
+ log(2,message);
+ }
+
+ public final void INFO(String message) {
+ log(3,message);
+ }
+
+ public final void DEBUG(String message) {
+ log(4,message);
+ }
+
+ public final void PACKET(String message) {
+ log(4, new StringBuffer(ROW).append(message).append(END_ROW).toString());
+ }
+
+ /**
+ * Logs a message.
+ *
+ * <p>The <tt>ServiceReference</tt> field and the <tt>Throwable</tt>
+ * field of the <tt>LogEntry</tt> object will be set to <tt>null</tt>.
+ * @param msglevel The severity of the message.
+ * This should be one of the defined log levels
+ * but may be any integer that is interpreted in a user defined way.
+ * @param message Human readable string describing the condition or <tt>null</tt>.
+ * @see #LOG_ERROR
+ * @see #LOG_WARNING
+ * @see #LOG_INFO
+ * @see #LOG_DEBUG
+ */
+ public void log(int msglevel, String message) {
+ synchronized (this) {
+ if (msglevel <= this.level){
+ if (this.osgiLogService != null ){
+ osgiLogService.log(msglevel, message);
+ }
+ else {
+ StringBuffer sb = new StringBuffer(Logger.LEVEL_TO_STRING[msglevel]);
+ this.out.println(sb.append(message));
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Logs a message with an exception.
+ *
+ * <p>The <tt>ServiceReference</tt> field of the <tt>LogEntry</tt> object will be set to <tt>null</tt>.
+ * @param msglevel The severity of the message.
+ * This should be one of the defined log levels
+ * but may be any integer that is interpreted in a user defined way.
+ * @param message The human readable string describing the condition or <tt>null</tt>.
+ * @param exception The exception that reflects the condition or <tt>null</tt>.
+ * @see #LOG_ERROR
+ * @see #LOG_WARNING
+ * @see #LOG_INFO
+ * @see #LOG_DEBUG
+ */
+ public void log(int msglevel, String message, Throwable exception) {
+ synchronized (this) {
+ if (msglevel <= this.level){
+ if(this.osgiLogService != null){
+ osgiLogService.log(msglevel, message, exception);
+ }
+ else {
+ StringBuffer sb = new StringBuffer(Logger.LEVEL_TO_STRING[msglevel]);
+ this.out.println(sb.append(message).append(NEWLINE).append(exception));
+ exception.printStackTrace(this.out);
+ }
+ }
+ }
+ }
+
+ private synchronized void setLogService(ServiceReference reference){
+ this.rls = reference;
+ this.osgiLogService = (LogService) Activator.bc.getService(rls);
+ }
+ /**
+ * This look for a <tt>LogService</tt> if it founds no <tt>LogService</tt> will register a new
+ * Listener of LogService
+ *
+ */
+ private synchronized void findService() {
+ //PRE:Actually no LogService are setted and we are registered as ServiceListener
+ // for LogService (unregisterin event)
+ this.rls = Activator.bc.getServiceReference(LogService.class.getName());
+ if (this.rls != null){
+ this.osgiLogService = (LogService) Activator.bc.getService(rls);
+ }
+ try {
+ Activator.bc.addServiceListener(this,
+ "(" + Constants.OBJECTCLASS + "=" + LogService.class.getName() + ")"
+ );
+ } catch (InvalidSyntaxException ignore) {}
+ //POST: We are connected to a LogService or we are registered as ServiceListener
+ // for LogService(registering event)
+ }
+
+ private synchronized void releaseLogService() {
+ if( osgiLogService != null)
+ Activator.bc.ungetService(this.rls);
+ this.rls = null;
+ this.osgiLogService = null;
+ }
+
+ /**
+ * Used to keep track the existence of a <tt>LogService</tt>
+ *
+ * @see ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
+ */
+ public void serviceChanged(ServiceEvent e) {
+ switch (e.getType()) {
+ case ServiceEvent.REGISTERED: {
+ // put here code check for serviceid
+ setLogService(e.getServiceReference());
+ }break;
+
+ case ServiceEvent.MODIFIED:
+ break;
+
+ case ServiceEvent.UNREGISTERING: {
+ // put here code check for serviceid
+ releaseLogService();
+ }break;
+ }
+ }
+
+ /**
+ * Stop using the <tt>LogService</tt> and listening for those service event
+ *
+ * NOTE: All the message will be reported to <tt>PrintStream</tt>
+ *
+ */
+ public void close(){
+ Activator.bc.removeServiceListener(this);
+ releaseLogService();
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Converter.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Converter.java
index 68a602c..8ee1bcb 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Converter.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Converter.java
@@ -1,254 +1,254 @@
-/*
- * 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.basedriver.util;
-
-import java.text.ParseException;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.apache.xerces.impl.dv.util.Base64;
-import org.apache.xerces.impl.dv.util.HexBin;
-
-import org.osgi.service.upnp.UPnPStateVariable;
-
-/**
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class Converter {
-
- /**
- *
- * @param value Object that contain the value
- * @param upnpType String conating the UPnP Type of the Object
- * @return a String that contain the UPnP rappresentation of the value contained in Object
- * of type specified by typeUPnP
- */
- public static String toString(Object value,String upnpType) throws Exception{
- if((value==null)||(upnpType==null))
- throw new NullPointerException("Must be specified a valid value and upnpType");
-
- if(value instanceof Number){
- if(value instanceof Integer){
- return value.toString();
- }else if(value instanceof Float){
- return value.toString();
- }else if(value instanceof Long){
- if(upnpType.equals(UPnPStateVariable.TYPE_TIME)){
- long l = ((Long)value).longValue();
- if(l<0) throw new IllegalArgumentException(l+ "Must be greater than 0");
- Calendar c = Calendar.getInstance();
- c.set(Calendar.HOUR_OF_DAY,(int) (l/3600000));
- int x=(int) (l % 3600000);
- c.set(Calendar.MINUTE,(int) (x / 60000));
- c.set(Calendar.SECOND,(x % 60000)/1000);
- SimpleDateFormat sdt = new SimpleDateFormat("HH:mm:ss");
- return sdt.format(c.getTime());
- }else if(upnpType.equals(UPnPStateVariable.TYPE_TIME_TZ)){
- long l = ((Long)value).longValue();
- if(l<0) throw new IllegalArgumentException(l+ "Must be greater than 0");
- Calendar c = Calendar.getInstance();
- c.set(Calendar.HOUR_OF_DAY,(int) (l/3600000));
- int x=(int) (l % 3600000);
- c.set(Calendar.MINUTE,(int) (x / 60000));
- c.set(Calendar.SECOND,(x % 60000)/1000);
- SimpleDateFormat sdt = new SimpleDateFormat("HH:mm:ssZ");
- return sdt.format(c.getTime());
- }else{
- //Must be UPnPStateVariable.TYPE_UI4)
- return value.toString();
- }
- }else if(value instanceof Double){
- if(upnpType.equals(UPnPStateVariable.TYPE_FIXED_14_4)){
- return Long.toString(((Double)value).longValue())+"."+
- Integer.toString((int) (((((Double)value).doubleValue()*10000D) % 10000)));
- }else{
- //Must be UPnPStateVariable.TYPE_R8 or UPnPStateVariable.TYPE_NUMBER
- return value.toString();
- }
- }
- }else if(value instanceof Date){
- if(upnpType.equals("dateTime")){
- SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
- return sdt.format(value);
- }else if(upnpType.equals("dateTime.tz")){
- SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
- return sdt.format(value);
- }else if(upnpType.equals("date")){
- SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd");
- return sdt.format(value);
- }
- }else if(value instanceof Boolean){
- //Must be UPnPStateVariable.TYPE_BOOLEAN
- if(((Boolean)value).booleanValue()){
- return "1";
- }else{
- return "0";
- }
- }else if(value instanceof Character){
- //Must be UPnPStateVariable.TYPE_CHAR
- return value.toString();
- }else if(value instanceof String){
- return value.toString();
- //Must be one of
- // UPnPStateVariable.TYPE_STRING or
- // UPnPStateVariable.TYPE_URI or
- // UPnPStateVariable.TYPE_UUID
- }else if(value instanceof byte[]){
- if(upnpType.equals("bin.hex")){
- return HexBin.encode((byte[]) value);
- }else if(upnpType.equals("bin.base64")){
- return Base64.encode((byte[]) value);
- }
- }
- throw new IllegalArgumentException("Invalid Binding");
- }
-
- /**
- *
- * @param value
- * @param upnpType
- * @return
- */
- public static Object parseString(String value,String upnpType) throws Exception{
- if (value ==null && upnpType.equals("string"))
- value = "";
- if((value==null)||(upnpType==null))
- throw new NullPointerException("Must be specified a valid value and upnpType");
-
- if (upnpType.equals("ui1") || upnpType.equals("ui2")
- || upnpType.equals("i1") || upnpType.equals("i2")
- || upnpType.equals("i4") || upnpType.equals("int")) {
-
- return new Integer(value);
- } else if (upnpType.equals("ui4")){
- return new Long(value);
- } else if(upnpType.equals("time")){
- String[] timeFormats=new String[]{"HH:mm:ss"};
- Date d=getDateValue(value,timeFormats,timeFormats);
-
- Calendar c = Calendar.getInstance();
- c.setTime(d);
- return new Long(
- c.get(Calendar.HOUR_OF_DAY)*3600000
- +c.get(Calendar.MINUTE)*60000
- +c.get(Calendar.SECOND)*1000
- );
- } else if(upnpType.equals("time.tz")) {
- String[] timeFormats=new String[]{"HH:mm:ssZ","HH:mm:ss"};
- Date d=getDateValue(value,timeFormats,timeFormats);
- TimeZone tz = TimeZone.getDefault();
- Calendar c = Calendar.getInstance(tz);
- c.setTime(d);
-
- if(timeFormats[0].equals("HH:mm:ssZ")&&(tz.inDaylightTime(d)))
- c.add(Calendar.MILLISECOND,3600000);
- return new Long(
- c.get(Calendar.HOUR_OF_DAY)*3600000
- +c.get(Calendar.MINUTE)*60000
- +c.get(Calendar.SECOND)*1000
- );
- } else if (upnpType.equals("r4") || upnpType.equals("float")) {
- return new Float(value);
- } else if (upnpType.equals("r8") || upnpType.equals("number")
- || upnpType.equals("fixed.14.4")){
- return new Double(value);
- } else if (upnpType.equals("char")) {
- return new Character(value.charAt(0));
- } else if (upnpType.equals("string") || upnpType.equals("uri")
- || upnpType.equals("uuid")) {
- return value;
- } else if (upnpType.equals("date")) {
- String[] timeFormats=new String[]{"yyyy-MM-dd"};
-
- Date d=getDateValue(value,timeFormats,timeFormats);
- return d;
- } else if (upnpType.equals("dateTime")) {
-
- String[] timeFormats=new String[]{
- "yyyy-MM-dd",
- "yyyy-MM-dd'T'HH:mm:ss"
- };
-
- Date d=getDateValue(value,timeFormats,timeFormats);
- return d;
- } else if (upnpType.equals("dateTime.tz")) {
-
- String[] timeFormats=new String[]{
- "yyyy-MM-dd",
- "yyyy-MM-dd'T'HH:mm:ss",
- "yyyy-MM-dd'T'HH:mm:ssZ"
- };
-
- Date d=getDateValue(value,timeFormats,timeFormats);
- return d;
- } else if (upnpType.equals("boolean")) {
- if(value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true")
- || value.equalsIgnoreCase("1"))
- return Boolean.TRUE;
- else
- return Boolean.FALSE;
- } else if (upnpType.equals("bin.base64")) {
- return Base64.decode(value);
- } else if (upnpType.equals("bin.hex")) {
- return HexBin.decode(value);
- }
- throw new IllegalArgumentException("Invalid Binding");
- }
-
- private static String normalizeTimeZone(String value){
- if(value.endsWith("Z")){
- value=value.substring(0,value.length()-1)+"+0000";
- }else if((value.length()>7)
- &&(value.charAt(value.length()-3)==':')
- &&((value.charAt(value.length()-6)=='-')||(value.charAt(value.length()-6)=='+'))){
-
- value=value.substring(0,value.length()-3)+value.substring(value.length()-2);
- }
- return value;
- }
-
- /**
- * @param value
- * @param timeFormats
- * @param choosedIndex
- * @return
- * @throws ParseException
- */
- private static Date getDateValue(String value, String[] timeFormats, String[] choosedIndex) throws ParseException {
- ParsePosition position = null;
- Date d;
- value=normalizeTimeZone(value);
- for (int i=0; i<timeFormats.length; i++) {
- position = new ParsePosition(0);
- SimpleDateFormat sdt = new SimpleDateFormat(timeFormats[i]);
- d=sdt.parse(value,position);
- if(d!=null){
- if(position.getIndex()>=value.length()){
- choosedIndex[0]=timeFormats[i];
- return d;
- }
- }
- }
- throw new ParseException("Error parsing "+value,position.getIndex());
- }
-}
+/*
+ * 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.basedriver.util;
+
+import java.text.ParseException;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.apache.xerces.impl.dv.util.Base64;
+import org.apache.xerces.impl.dv.util.HexBin;
+
+import org.osgi.service.upnp.UPnPStateVariable;
+
+/**
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class Converter {
+
+ /**
+ *
+ * @param value Object that contain the value
+ * @param upnpType String conating the UPnP Type of the Object
+ * @return a String that contain the UPnP rappresentation of the value contained in Object
+ * of type specified by typeUPnP
+ */
+ public static String toString(Object value,String upnpType) throws Exception{
+ if((value==null)||(upnpType==null))
+ throw new NullPointerException("Must be specified a valid value and upnpType");
+
+ if(value instanceof Number){
+ if(value instanceof Integer){
+ return value.toString();
+ }else if(value instanceof Float){
+ return value.toString();
+ }else if(value instanceof Long){
+ if(upnpType.equals(UPnPStateVariable.TYPE_TIME)){
+ long l = ((Long)value).longValue();
+ if(l<0) throw new IllegalArgumentException(l+ "Must be greater than 0");
+ Calendar c = Calendar.getInstance();
+ c.set(Calendar.HOUR_OF_DAY,(int) (l/3600000));
+ int x=(int) (l % 3600000);
+ c.set(Calendar.MINUTE,(int) (x / 60000));
+ c.set(Calendar.SECOND,(x % 60000)/1000);
+ SimpleDateFormat sdt = new SimpleDateFormat("HH:mm:ss");
+ return sdt.format(c.getTime());
+ }else if(upnpType.equals(UPnPStateVariable.TYPE_TIME_TZ)){
+ long l = ((Long)value).longValue();
+ if(l<0) throw new IllegalArgumentException(l+ "Must be greater than 0");
+ Calendar c = Calendar.getInstance();
+ c.set(Calendar.HOUR_OF_DAY,(int) (l/3600000));
+ int x=(int) (l % 3600000);
+ c.set(Calendar.MINUTE,(int) (x / 60000));
+ c.set(Calendar.SECOND,(x % 60000)/1000);
+ SimpleDateFormat sdt = new SimpleDateFormat("HH:mm:ssZ");
+ return sdt.format(c.getTime());
+ }else{
+ //Must be UPnPStateVariable.TYPE_UI4)
+ return value.toString();
+ }
+ }else if(value instanceof Double){
+ if(upnpType.equals(UPnPStateVariable.TYPE_FIXED_14_4)){
+ return Long.toString(((Double)value).longValue())+"."+
+ Integer.toString((int) (((((Double)value).doubleValue()*10000D) % 10000)));
+ }else{
+ //Must be UPnPStateVariable.TYPE_R8 or UPnPStateVariable.TYPE_NUMBER
+ return value.toString();
+ }
+ }
+ }else if(value instanceof Date){
+ if(upnpType.equals("dateTime")){
+ SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ return sdt.format(value);
+ }else if(upnpType.equals("dateTime.tz")){
+ SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
+ return sdt.format(value);
+ }else if(upnpType.equals("date")){
+ SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd");
+ return sdt.format(value);
+ }
+ }else if(value instanceof Boolean){
+ //Must be UPnPStateVariable.TYPE_BOOLEAN
+ if(((Boolean)value).booleanValue()){
+ return "1";
+ }else{
+ return "0";
+ }
+ }else if(value instanceof Character){
+ //Must be UPnPStateVariable.TYPE_CHAR
+ return value.toString();
+ }else if(value instanceof String){
+ return value.toString();
+ //Must be one of
+ // UPnPStateVariable.TYPE_STRING or
+ // UPnPStateVariable.TYPE_URI or
+ // UPnPStateVariable.TYPE_UUID
+ }else if(value instanceof byte[]){
+ if(upnpType.equals("bin.hex")){
+ return HexBin.encode((byte[]) value);
+ }else if(upnpType.equals("bin.base64")){
+ return Base64.encode((byte[]) value);
+ }
+ }
+ throw new IllegalArgumentException("Invalid Binding");
+ }
+
+ /**
+ *
+ * @param value
+ * @param upnpType
+ * @return
+ */
+ public static Object parseString(String value,String upnpType) throws Exception{
+ if (value ==null && upnpType.equals("string"))
+ value = "";
+ if((value==null)||(upnpType==null))
+ throw new NullPointerException("Must be specified a valid value and upnpType");
+
+ if (upnpType.equals("ui1") || upnpType.equals("ui2")
+ || upnpType.equals("i1") || upnpType.equals("i2")
+ || upnpType.equals("i4") || upnpType.equals("int")) {
+
+ return new Integer(value);
+ } else if (upnpType.equals("ui4")){
+ return new Long(value);
+ } else if(upnpType.equals("time")){
+ String[] timeFormats=new String[]{"HH:mm:ss"};
+ Date d=getDateValue(value,timeFormats,timeFormats);
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(d);
+ return new Long(
+ c.get(Calendar.HOUR_OF_DAY)*3600000
+ +c.get(Calendar.MINUTE)*60000
+ +c.get(Calendar.SECOND)*1000
+ );
+ } else if(upnpType.equals("time.tz")) {
+ String[] timeFormats=new String[]{"HH:mm:ssZ","HH:mm:ss"};
+ Date d=getDateValue(value,timeFormats,timeFormats);
+ TimeZone tz = TimeZone.getDefault();
+ Calendar c = Calendar.getInstance(tz);
+ c.setTime(d);
+
+ if(timeFormats[0].equals("HH:mm:ssZ")&&(tz.inDaylightTime(d)))
+ c.add(Calendar.MILLISECOND,3600000);
+ return new Long(
+ c.get(Calendar.HOUR_OF_DAY)*3600000
+ +c.get(Calendar.MINUTE)*60000
+ +c.get(Calendar.SECOND)*1000
+ );
+ } else if (upnpType.equals("r4") || upnpType.equals("float")) {
+ return new Float(value);
+ } else if (upnpType.equals("r8") || upnpType.equals("number")
+ || upnpType.equals("fixed.14.4")){
+ return new Double(value);
+ } else if (upnpType.equals("char")) {
+ return new Character(value.charAt(0));
+ } else if (upnpType.equals("string") || upnpType.equals("uri")
+ || upnpType.equals("uuid")) {
+ return value;
+ } else if (upnpType.equals("date")) {
+ String[] timeFormats=new String[]{"yyyy-MM-dd"};
+
+ Date d=getDateValue(value,timeFormats,timeFormats);
+ return d;
+ } else if (upnpType.equals("dateTime")) {
+
+ String[] timeFormats=new String[]{
+ "yyyy-MM-dd",
+ "yyyy-MM-dd'T'HH:mm:ss"
+ };
+
+ Date d=getDateValue(value,timeFormats,timeFormats);
+ return d;
+ } else if (upnpType.equals("dateTime.tz")) {
+
+ String[] timeFormats=new String[]{
+ "yyyy-MM-dd",
+ "yyyy-MM-dd'T'HH:mm:ss",
+ "yyyy-MM-dd'T'HH:mm:ssZ"
+ };
+
+ Date d=getDateValue(value,timeFormats,timeFormats);
+ return d;
+ } else if (upnpType.equals("boolean")) {
+ if(value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true")
+ || value.equalsIgnoreCase("1"))
+ return Boolean.TRUE;
+ else
+ return Boolean.FALSE;
+ } else if (upnpType.equals("bin.base64")) {
+ return Base64.decode(value);
+ } else if (upnpType.equals("bin.hex")) {
+ return HexBin.decode(value);
+ }
+ throw new IllegalArgumentException("Invalid Binding");
+ }
+
+ private static String normalizeTimeZone(String value){
+ if(value.endsWith("Z")){
+ value=value.substring(0,value.length()-1)+"+0000";
+ }else if((value.length()>7)
+ &&(value.charAt(value.length()-3)==':')
+ &&((value.charAt(value.length()-6)=='-')||(value.charAt(value.length()-6)=='+'))){
+
+ value=value.substring(0,value.length()-3)+value.substring(value.length()-2);
+ }
+ return value;
+ }
+
+ /**
+ * @param value
+ * @param timeFormats
+ * @param choosedIndex
+ * @return
+ * @throws ParseException
+ */
+ private static Date getDateValue(String value, String[] timeFormats, String[] choosedIndex) throws ParseException {
+ ParsePosition position = null;
+ Date d;
+ value=normalizeTimeZone(value);
+ for (int i=0; i<timeFormats.length; i++) {
+ position = new ParsePosition(0);
+ SimpleDateFormat sdt = new SimpleDateFormat(timeFormats[i]);
+ d=sdt.parse(value,position);
+ if(d!=null){
+ if(position.getIndex()>=value.length()){
+ choosedIndex[0]=timeFormats[i];
+ return d;
+ }
+ }
+ }
+ throw new ParseException("Error parsing "+value,position.getIndex());
+ }
+}
diff --git a/upnp/basedriver/src/main/java/org/apache/xerces/impl/dv/util/Base64.java b/upnp/basedriver/src/main/java/org/apache/xerces/impl/dv/util/Base64.java
index 8a15e63..947dc8b 100644
--- a/upnp/basedriver/src/main/java/org/apache/xerces/impl/dv/util/Base64.java
+++ b/upnp/basedriver/src/main/java/org/apache/xerces/impl/dv/util/Base64.java
@@ -35,7 +35,7 @@
*
* @author Jeffrey Rodriguez
* @author Sandy Gao
- * @version $Id: Base64.java,v 1.15 2004/10/14 15:20:18 mrglavas Exp $
+ * @version $Id$
*/
public final class Base64 {
diff --git a/upnp/basedriver/src/main/java/org/apache/xerces/impl/dv/util/HexBin.java b/upnp/basedriver/src/main/java/org/apache/xerces/impl/dv/util/HexBin.java
index 8a9249d..6590f73 100644
--- a/upnp/basedriver/src/main/java/org/apache/xerces/impl/dv/util/HexBin.java
+++ b/upnp/basedriver/src/main/java/org/apache/xerces/impl/dv/util/HexBin.java
@@ -27,7 +27,7 @@
* @xerces.internal
*
* @author Jeffrey Rodriguez
- * @version $Id: HexBin.java,v 1.13 2004/10/14 15:20:18 mrglavas Exp $
+ * @version $Id$
*/
public final class HexBin {
static private final int BASELENGTH = 128;
diff --git a/upnp/doc/config.properties.upnp b/upnp/doc/config.properties.upnp
index 6da7806..9f44b0e 100644
--- a/upnp/doc/config.properties.upnp
+++ b/upnp/doc/config.properties.upnp
@@ -1,510 +1,510 @@
-# 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.
-
-#
-# Framework config properties.
-#
-org.osgi.framework.system.packages=org.osgi.framework; version=1.3.0, \
- org.osgi.service.packageadmin; version=1.2.0, \
- org.osgi.service.startlevel; version=1.0.0, \
- org.osgi.service.url; version=1.0.0, \
- org.osgi.util.tracker; version=1.3.2 \
- ${jre-${java.specification.version}}
-
-#org.osgi.framework.bootdelegation=sun.*,com.sun.*
-
-felix.cache.profile=upnp
-
-felix.auto.start.1= \
- file:bundle/org.apache.felix.shell-1.1.0-SNAPSHOT.jar \
- file:bundle/org.apache.felix.shell.tui-1.1.0-SNAPSHOT.jar \
- file:bundle/org.apache.felix.bundlerepository-1.1.0-SNAPSHOT.jar \
- file:../org.osgi.core/target/org.osgi.core-1.1.0-SNAPSHOT.jar \
- file:../javax.servlet/target/javax.servlet-1.0.1-SNAPSHOT.jar \
- file:../org.osgi.compendium/target/org.osgi.compendium-1.1.0-SNAPSHOT.jar \
- file:../http.jetty/target/org.apache.felix.http.jetty-0.9.0-SNAPSHOT.jar \
- file:../upnp/basedriver/target/org.apache.felix.upnp.basedriver-0.3.0-SNAPSHOT.jar \
- file:../upnp/extra/target/org.apache.felix.upnp.extra-0.3.0-SNAPSHOT.jar \
- file:../upnp/tester/target/org.apache.felix.upnp.tester-0.2.0-SNAPSHOT.jar \
- file:../upnp/samples/tv/target/org.apache.felix.upnp.sample.tv-0.2.0-SNAPSHOT.jar \
- file:../upnp/samples/clock/target/org.apache.felix.upnp.sample.clock-0.2.0-SNAPSHOT.jar \
- file:../upnp/samples/binarylight/target/org.apache.felix.upnp.sample.binaryLight-0.2.0-SNAPSHOT.jar
-
-felix.log.level=4
-felix.startlevel.framework=1
-felix.startlevel.bundle=1
-#framework.service.urlhandlers=false
-
-#
-# Bundle config properties.
-#
-org.osgi.service.http.port=8080
-osgi.shell.telnet=on
-#obr.repository.url=http://bundles.osgi.org/obr/browse?_xml=1&cmd=repository
-
-
-#
-# UPnP Basedriver properties
-#
-
-#felix.upnpbase.log=2
-#felix.upnpbase.exporter.enabled=true
-#felix.upnpbase.importer.enabled=true
-#felix.upnpbase.cyberdomo.log=false
-#felix.upnpbase.cyberdomo.net.loopback=false
-#felix.upnpbase.cyberdomo.net.onlyIPV4=true
-#felix.upnpbase.cyberdomo.net.onlyIPV6=false
-
-#
-# Other useful properties you might configure are
-# the System Properties used by Cyberdomo (e.g. -Dcyberdomo.ssdp.mx=10)
-#
-# cyberdomo.ssdp.mx (default 5)
-# cyberdomo.ssdp.buffersize (default 2048)
-# cyberdomo.ssdp.port (default 1900 )
-#
-
-#
-# Java platform package export properties.
-#
-jre-1.3=, \
- javax.accessibility; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.transaction; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- version="1.3.0"
-
-jre-1.4=, \
- javax.accessibility; \
- javax.crypto; \
- javax.crypto.interfaces; \
- javax.crypto.spec; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.transaction; \
- javax.transaction.xa; \
- javax.xml.parsers; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stream; \
- org.ietf.jgss; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.w3c.dom; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- version="1.4.0"
-
-jre-1.5=, \
- javax.accessibility; \
- javax.activity; \
- javax.crypto; \
- javax.crypto.interfaces; \
- javax.crypto.spec; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.bmp; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.management; \
- javax.management.loading; \
- javax.management.modelmbean; \
- javax.management.monitor; \
- javax.management.openmbean; \
- javax.management.relation; \
- javax.management.remote; \
- javax.management.remote.rmi; \
- javax.management.timer; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.rmi.ssl; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.security.sasl; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.sql.rowset; \
- javax.sql.rowset.serial; \
- javax.sql.rowset.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.plaf.synth; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.transaction; \
- javax.transaction.xa; \
- javax.xml; \
- javax.xml.datatype; \
- javax.xml.namespace; \
- javax.xml.parsers; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stream; \
- javax.xml.validation; \
- javax.xml.xpath; \
- org.ietf.jgss; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.omg.stub.javax.management.remote.rmi; \
- org.w3c.dom; \
- org.w3c.dom.bootstrap; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.ls; \
- org.w3c.dom.ranges; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- version="1.5.0"
-
-jre-1.6=, \
- javax.accessibility; \
- javax.activation; \
- javax.activity; \
- javax.annotation; \
- javax.annotation.processing; \
- javax.crypto; \
- javax.crypto.interfaces; \
- javax.crypto.spec; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.bmp; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.jws; \
- javax.jws.soap; \
- javax.lang.model; \
- javax.lang.model.element; \
- javax.lang.model.type; \
- javax.lang.model.util; \
- javax.management; \
- javax.management.loading; \
- javax.management.modelmbean; \
- javax.management.monitor; \
- javax.management.openmbean; \
- javax.management.relation; \
- javax.management.remote; \
- javax.management.remote.rmi; \
- javax.management.timer; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.rmi.ssl; \
- javax.script; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.security.cert; \
- javax.security.sasl; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.sql.rowset; \
- javax.sql.rowset.serial; \
- javax.sql.rowset.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.plaf.synth; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.tools; \
- javax.transaction; \
- javax.transaction.xa; \
- javax.xml; \
- javax.xml.bind; \
- javax.xml.bind.annotation; \
- javax.xml.bind.annotation.adapters; \
- javax.xml.bind.attachment; \
- javax.xml.bind.helpers; \
- javax.xml.bind.util; \
- javax.xml.crypto; \
- javax.xml.crypto.dom; \
- javax.xml.crypto.dsig; \
- javax.xml.crypto.dsig.dom; \
- javax.xml.crypto.dsig.keyinfo; \
- javax.xml.crypto.dsig.spec; \
- javax.xml.datatype; \
- javax.xml.namespace; \
- javax.xml.parsers; \
- javax.xml.soap; \
- javax.xml.stream; \
- javax.xml.stream.events; \
- javax.xml.stream.util; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stax; \
- javax.xml.transform.stream; \
- javax.xml.validation; \
- javax.xml.ws; \
- javax.xml.ws.handler; \
- javax.xml.ws.handler.soap; \
- javax.xml.ws.http; \
- javax.xml.ws.soap; \
- javax.xml.ws.spi; \
- javax.xml.xpath; \
- org.ietf.jgss; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.omg.stub.javax.management.remote.rmi; \
- org.w3c.dom; \
- org.w3c.dom.bootstrap; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.ls; \
- org.w3c.dom.ranges; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.w3c.dom.xpath; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- version=\"1.6.0\"
+# 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.
+
+#
+# Framework config properties.
+#
+org.osgi.framework.system.packages=org.osgi.framework; version=1.3.0, \
+ org.osgi.service.packageadmin; version=1.2.0, \
+ org.osgi.service.startlevel; version=1.0.0, \
+ org.osgi.service.url; version=1.0.0, \
+ org.osgi.util.tracker; version=1.3.2 \
+ ${jre-${java.specification.version}}
+
+#org.osgi.framework.bootdelegation=sun.*,com.sun.*
+
+felix.cache.profile=upnp
+
+felix.auto.start.1= \
+ file:bundle/org.apache.felix.shell-1.1.0-SNAPSHOT.jar \
+ file:bundle/org.apache.felix.shell.tui-1.1.0-SNAPSHOT.jar \
+ file:bundle/org.apache.felix.bundlerepository-1.1.0-SNAPSHOT.jar \
+ file:../org.osgi.core/target/org.osgi.core-1.1.0-SNAPSHOT.jar \
+ file:../javax.servlet/target/javax.servlet-1.0.1-SNAPSHOT.jar \
+ file:../org.osgi.compendium/target/org.osgi.compendium-1.1.0-SNAPSHOT.jar \
+ file:../http.jetty/target/org.apache.felix.http.jetty-0.9.0-SNAPSHOT.jar \
+ file:../upnp/basedriver/target/org.apache.felix.upnp.basedriver-0.9.0-SNAPSHOT.jar \
+ file:../upnp/extra/target/org.apache.felix.upnp.extra-0.3.0-SNAPSHOT.jar \
+ file:../upnp/tester/target/org.apache.felix.upnp.tester-0.2.0-SNAPSHOT.jar \
+ file:../upnp/samples/tv/target/org.apache.felix.upnp.sample.tv-0.2.0-SNAPSHOT.jar \
+ file:../upnp/samples/clock/target/org.apache.felix.upnp.sample.clock-0.2.0-SNAPSHOT.jar \
+ file:../upnp/samples/binarylight/target/org.apache.felix.upnp.sample.binaryLight-0.2.0-SNAPSHOT.jar
+
+felix.log.level=4
+felix.startlevel.framework=1
+felix.startlevel.bundle=1
+#framework.service.urlhandlers=false
+
+#
+# Bundle config properties.
+#
+org.osgi.service.http.port=8080
+osgi.shell.telnet=on
+#obr.repository.url=http://bundles.osgi.org/obr/browse?_xml=1&cmd=repository
+
+
+#
+# UPnP Basedriver properties
+#
+
+#felix.upnpbase.log=2
+#felix.upnpbase.exporter.enabled=true
+#felix.upnpbase.importer.enabled=true
+#felix.upnpbase.cyberdomo.log=false
+#felix.upnpbase.cyberdomo.net.loopback=false
+#felix.upnpbase.cyberdomo.net.onlyIPV4=true
+#felix.upnpbase.cyberdomo.net.onlyIPV6=false
+
+#
+# Other useful properties you might configure are
+# the System Properties used by Cyberdomo (e.g. -Dcyberdomo.ssdp.mx=10)
+#
+# cyberdomo.ssdp.mx (default 5)
+# cyberdomo.ssdp.buffersize (default 2048)
+# cyberdomo.ssdp.port (default 1900 )
+#
+
+#
+# Java platform package export properties.
+#
+jre-1.3=, \
+ javax.accessibility; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ version="1.3.0"
+
+jre-1.4=, \
+ javax.accessibility; \
+ javax.crypto; \
+ javax.crypto.interfaces; \
+ javax.crypto.spec; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.net; \
+ javax.net.ssl; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml.parsers; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stream; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version="1.4.0"
+
+jre-1.5=, \
+ javax.accessibility; \
+ javax.activity; \
+ javax.crypto; \
+ javax.crypto.interfaces; \
+ javax.crypto.spec; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.bmp; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.management; \
+ javax.management.loading; \
+ javax.management.modelmbean; \
+ javax.management.monitor; \
+ javax.management.openmbean; \
+ javax.management.relation; \
+ javax.management.remote; \
+ javax.management.remote.rmi; \
+ javax.management.timer; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.net; \
+ javax.net.ssl; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.rmi.ssl; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.security.sasl; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.sql.rowset; \
+ javax.sql.rowset.serial; \
+ javax.sql.rowset.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.plaf.synth; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml; \
+ javax.xml.datatype; \
+ javax.xml.namespace; \
+ javax.xml.parsers; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stream; \
+ javax.xml.validation; \
+ javax.xml.xpath; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.omg.stub.javax.management.remote.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.bootstrap; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.ls; \
+ org.w3c.dom.ranges; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version="1.5.0"
+
+jre-1.6=, \
+ javax.accessibility; \
+ javax.activation; \
+ javax.activity; \
+ javax.annotation; \
+ javax.annotation.processing; \
+ javax.crypto; \
+ javax.crypto.interfaces; \
+ javax.crypto.spec; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.bmp; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.jws; \
+ javax.jws.soap; \
+ javax.lang.model; \
+ javax.lang.model.element; \
+ javax.lang.model.type; \
+ javax.lang.model.util; \
+ javax.management; \
+ javax.management.loading; \
+ javax.management.modelmbean; \
+ javax.management.monitor; \
+ javax.management.openmbean; \
+ javax.management.relation; \
+ javax.management.remote; \
+ javax.management.remote.rmi; \
+ javax.management.timer; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.net; \
+ javax.net.ssl; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.rmi.ssl; \
+ javax.script; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.security.cert; \
+ javax.security.sasl; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.sql.rowset; \
+ javax.sql.rowset.serial; \
+ javax.sql.rowset.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.plaf.synth; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.tools; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml; \
+ javax.xml.bind; \
+ javax.xml.bind.annotation; \
+ javax.xml.bind.annotation.adapters; \
+ javax.xml.bind.attachment; \
+ javax.xml.bind.helpers; \
+ javax.xml.bind.util; \
+ javax.xml.crypto; \
+ javax.xml.crypto.dom; \
+ javax.xml.crypto.dsig; \
+ javax.xml.crypto.dsig.dom; \
+ javax.xml.crypto.dsig.keyinfo; \
+ javax.xml.crypto.dsig.spec; \
+ javax.xml.datatype; \
+ javax.xml.namespace; \
+ javax.xml.parsers; \
+ javax.xml.soap; \
+ javax.xml.stream; \
+ javax.xml.stream.events; \
+ javax.xml.stream.util; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stax; \
+ javax.xml.transform.stream; \
+ javax.xml.validation; \
+ javax.xml.ws; \
+ javax.xml.ws.handler; \
+ javax.xml.ws.handler.soap; \
+ javax.xml.ws.http; \
+ javax.xml.ws.soap; \
+ javax.xml.ws.spi; \
+ javax.xml.xpath; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.omg.stub.javax.management.remote.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.bootstrap; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.ls; \
+ org.w3c.dom.ranges; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.w3c.dom.xpath; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version=\"1.6.0\"
diff --git a/upnp/doc/upnp.sh.bat b/upnp/doc/upnp.sh.bat
old mode 100644
new mode 100755
index 3c1aa34..3557d59
--- a/upnp/doc/upnp.sh.bat
+++ b/upnp/doc/upnp.sh.bat
@@ -1,8 +1,8 @@
-#!/bin/sh
-
-
-cd ../../main
-
-echo "lauching Felix with UPnP bundles"
-java -Dfelix.config.properties=file:../upnp/doc/config.properties.upnp -jar bin/felix.jar
-
+#!/bin/sh
+
+
+cd ../../main
+
+echo "lauching Felix with UPnP bundles"
+java -Dfelix.config.properties=file:../upnp/doc/config.properties.upnp -jar bin/felix.jar
+
diff --git a/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/EventSource.java b/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/EventSource.java
index fca147e..eedb72a 100644
--- a/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/EventSource.java
+++ b/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/EventSource.java
@@ -1,33 +1,33 @@
-/*
- * 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.extra.util;
-
-import java.beans.PropertyChangeListener;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public interface EventSource {
- void addPropertyChangeListener(PropertyChangeListener listener);
- void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
- void removePropertyChangeListener(PropertyChangeListener listener);
- void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
-}
-
+/*
+ * 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.extra.util;
+
+import java.beans.PropertyChangeListener;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public interface EventSource {
+ void addPropertyChangeListener(PropertyChangeListener listener);
+ void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
+ void removePropertyChangeListener(PropertyChangeListener listener);
+ void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
+}
+
diff --git a/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/UPnPEventNotifier.java b/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/UPnPEventNotifier.java
index 6f40474..0dd7f8b 100644
--- a/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/UPnPEventNotifier.java
+++ b/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/UPnPEventNotifier.java
@@ -1,259 +1,259 @@
-/*
- * 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.extra.util;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Dictionary;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Vector;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-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.UPnPLocalStateVariable;
-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 UPnPEventNotifier implements PropertyChangeListener, ServiceListener {
- private BundleContext context;
- private UPnPDevice device;
- private UPnPService service;
- private String deviceId;
- private String serviceId;
-
- private Properties UPnPTargetListener;
- private Vector upnpListeners = new Vector();
- final private Object LOCK = new Object();
-
-
- private class NotifierThread extends Thread {
- private ServiceReference sr;
- private Properties events;
-
- public NotifierThread(ServiceReference sr, Properties events){
- super("UPnPEventNotifier");
- this.sr = sr;
- this.events = events;
- }
-
- public void run(){
- try {
- UPnPEventListener listener = (UPnPEventListener) context.getService(sr);
- listener.notifyUPnPEvent(deviceId,serviceId,events);
- context.ungetService(sr);
- } catch (Exception ignored){
- }
- }
- }
-
- public UPnPEventNotifier(BundleContext context, UPnPDevice device, UPnPService service, EventSource source){
- this(context,device,service);
-
- if (source != null){
- UPnPStateVariable[] vars = service.getStateVariables();
- if (vars != null){
- for (int i=0;i<vars.length;i++){
- if(vars[i].sendsEvents()){
- source.addPropertyChangeListener(vars[i].getName(),this);
- }
- }
- }
- }
-
- }
-
- public UPnPEventNotifier(BundleContext context, UPnPDevice device, UPnPService service){
- this.context=context;
- this.device=device;
- this.service=service;
- setupUPnPListenerWatcher();
- }
-
- /**
- * @param deviceId
- */
- private void setupUPnPListenerWatcher() {
- Dictionary dict = device.getDescriptions(null);
- this.deviceId = (String) dict.get(UPnPDevice.ID);
- this.serviceId=service.getId();
- UPnPTargetListener = new Properties();
- UPnPTargetListener.put(UPnPDevice.ID,deviceId);
- UPnPTargetListener.put(UPnPService.ID,serviceId);
- UPnPTargetListener.put(UPnPDevice.TYPE,dict.get(UPnPDevice.TYPE));
- UPnPTargetListener.put(UPnPService.TYPE,service.getType());
- String ANY_UPnPEventListener = "("+Constants.OBJECTCLASS+"="+UPnPEventListener.class.getName()+")";
-
- synchronized (LOCK) {
- try {
- String filter = ANY_UPnPEventListener;
- context.addServiceListener(this,filter);
- } catch (Exception ex) {
- System.out.println(ex);
- }
-
- ServiceReference[] listeners = null;
- try {
- listeners = context.getServiceReferences(UPnPEventListener.class.getName(),null);
- if (listeners != null){
- for (int i = 0;i<listeners.length;i++){
- ServiceReference sr = listeners[i];
- Filter filter = (Filter) sr.getProperty(UPnPEventListener.UPNP_FILTER);
- if (filter == null) upnpListeners.add(sr);
- else {
- if (filter.match(UPnPTargetListener))
- addNewListener(sr);
- }
- }
- }
- } catch (Exception ex) {
- System.out.println(ex);
- }
-
- Properties status = getCurrentStatus();
- if (! status.isEmpty())
- doNotify(status);
-
- } // end LOCK
-
- }
-
- private Properties getCurrentStatus() {
- Properties status = new Properties();
- UPnPStateVariable[] vars = service.getStateVariables();
- if (vars != null){
- for (int i=0;i<vars.length;i++){
- if(vars[i].sendsEvents()){
- if (vars[i] instanceof UPnPLocalStateVariable){
- UPnPLocalStateVariable localVar = (UPnPLocalStateVariable) vars[i];
- String property = localVar.getName();
- Object value = localVar.getCurrentValue();
- status.put(property,value);
- }
- else {
- System.out.println("[Warning] The StateVariable (" +vars[i].getName() +")"
- + " of device (ID:" + deviceId + ") "
- + "should implement the interface UPnPLocalStateVariable");
- }
- }
- } // end for
- }
- return status;
- }
-
- /* (non-Javadoc)
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent evt) {
- String property = evt.getPropertyName();
- Object value = evt.getNewValue();
- Properties events = new Properties();
- events.put(property,value);
- doNotify(events);
- }
-
- private void doNotify(Properties events){
-
- synchronized (LOCK) {
- Iterator list = upnpListeners.iterator();
- while (list.hasNext()){
- final ServiceReference sr = (ServiceReference)list.next();
- new NotifierThread(sr,events).start();
- }
- }
- }
-
- private void doNotify(ServiceReference sr) {
- Properties status = getCurrentStatus();
- if (! status.isEmpty())
- new NotifierThread(sr,status).start();
- }
-
-
- /* (non-Javadoc)
- * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
- */
- public void serviceChanged(ServiceEvent e) {
- ServiceReference sr = e.getServiceReference();
- synchronized (LOCK) {
- switch(e.getType()){
- case ServiceEvent.REGISTERED:{
- Filter filter = (Filter) sr.getProperty(UPnPEventListener.UPNP_FILTER);
- if (filter == null) {
- addNewListener(sr);
- doNotify(sr);
- }
- else {
- if (filter.match(UPnPTargetListener)){
- addNewListener(sr);
- doNotify(sr);
- }
- }
- };break;
-
- case ServiceEvent.MODIFIED:{
- Filter filter = (Filter) sr.getProperty(UPnPEventListener.UPNP_FILTER);
- removeListener(sr);
- if (filter == null)
- addNewListener(sr);
- else {
- if (filter.match(UPnPTargetListener))
- addNewListener(sr);
- }
- };break;
-
- case ServiceEvent.UNREGISTERING:{
- removeListener(sr);
- };break;
- }
- }//end LOCK
-
- }
-
-
- /**
- * @param reference
- */
- private void removeListener(ServiceReference reference) {
- upnpListeners.remove(reference);
- }
-
- /**
- * @param reference
- */
- private void addNewListener(ServiceReference reference) {
- upnpListeners.add(reference);
- }
-
- public void destroy(){
- context.removeServiceListener(this);
- upnpListeners.removeAllElements();
- }
-}
+/*
+ * 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.extra.util;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Vector;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+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.UPnPLocalStateVariable;
+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 UPnPEventNotifier implements PropertyChangeListener, ServiceListener {
+ private BundleContext context;
+ private UPnPDevice device;
+ private UPnPService service;
+ private String deviceId;
+ private String serviceId;
+
+ private Properties UPnPTargetListener;
+ private Vector upnpListeners = new Vector();
+ final private Object LOCK = new Object();
+
+
+ private class NotifierThread extends Thread {
+ private ServiceReference sr;
+ private Properties events;
+
+ public NotifierThread(ServiceReference sr, Properties events){
+ super("UPnPEventNotifier");
+ this.sr = sr;
+ this.events = events;
+ }
+
+ public void run(){
+ try {
+ UPnPEventListener listener = (UPnPEventListener) context.getService(sr);
+ listener.notifyUPnPEvent(deviceId,serviceId,events);
+ context.ungetService(sr);
+ } catch (Exception ignored){
+ }
+ }
+ }
+
+ public UPnPEventNotifier(BundleContext context, UPnPDevice device, UPnPService service, EventSource source){
+ this(context,device,service);
+
+ if (source != null){
+ UPnPStateVariable[] vars = service.getStateVariables();
+ if (vars != null){
+ for (int i=0;i<vars.length;i++){
+ if(vars[i].sendsEvents()){
+ source.addPropertyChangeListener(vars[i].getName(),this);
+ }
+ }
+ }
+ }
+
+ }
+
+ public UPnPEventNotifier(BundleContext context, UPnPDevice device, UPnPService service){
+ this.context=context;
+ this.device=device;
+ this.service=service;
+ setupUPnPListenerWatcher();
+ }
+
+ /**
+ * @param deviceId
+ */
+ private void setupUPnPListenerWatcher() {
+ Dictionary dict = device.getDescriptions(null);
+ this.deviceId = (String) dict.get(UPnPDevice.ID);
+ this.serviceId=service.getId();
+ UPnPTargetListener = new Properties();
+ UPnPTargetListener.put(UPnPDevice.ID,deviceId);
+ UPnPTargetListener.put(UPnPService.ID,serviceId);
+ UPnPTargetListener.put(UPnPDevice.TYPE,dict.get(UPnPDevice.TYPE));
+ UPnPTargetListener.put(UPnPService.TYPE,service.getType());
+ String ANY_UPnPEventListener = "("+Constants.OBJECTCLASS+"="+UPnPEventListener.class.getName()+")";
+
+ synchronized (LOCK) {
+ try {
+ String filter = ANY_UPnPEventListener;
+ context.addServiceListener(this,filter);
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+
+ ServiceReference[] listeners = null;
+ try {
+ listeners = context.getServiceReferences(UPnPEventListener.class.getName(),null);
+ if (listeners != null){
+ for (int i = 0;i<listeners.length;i++){
+ ServiceReference sr = listeners[i];
+ Filter filter = (Filter) sr.getProperty(UPnPEventListener.UPNP_FILTER);
+ if (filter == null) upnpListeners.add(sr);
+ else {
+ if (filter.match(UPnPTargetListener))
+ addNewListener(sr);
+ }
+ }
+ }
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+
+ Properties status = getCurrentStatus();
+ if (! status.isEmpty())
+ doNotify(status);
+
+ } // end LOCK
+
+ }
+
+ private Properties getCurrentStatus() {
+ Properties status = new Properties();
+ UPnPStateVariable[] vars = service.getStateVariables();
+ if (vars != null){
+ for (int i=0;i<vars.length;i++){
+ if(vars[i].sendsEvents()){
+ if (vars[i] instanceof UPnPLocalStateVariable){
+ UPnPLocalStateVariable localVar = (UPnPLocalStateVariable) vars[i];
+ String property = localVar.getName();
+ Object value = localVar.getCurrentValue();
+ status.put(property,value);
+ }
+ else {
+ System.out.println("[Warning] The StateVariable (" +vars[i].getName() +")"
+ + " of device (ID:" + deviceId + ") "
+ + "should implement the interface UPnPLocalStateVariable");
+ }
+ }
+ } // end for
+ }
+ return status;
+ }
+
+ /* (non-Javadoc)
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ String property = evt.getPropertyName();
+ Object value = evt.getNewValue();
+ Properties events = new Properties();
+ events.put(property,value);
+ doNotify(events);
+ }
+
+ private void doNotify(Properties events){
+
+ synchronized (LOCK) {
+ Iterator list = upnpListeners.iterator();
+ while (list.hasNext()){
+ final ServiceReference sr = (ServiceReference)list.next();
+ new NotifierThread(sr,events).start();
+ }
+ }
+ }
+
+ private void doNotify(ServiceReference sr) {
+ Properties status = getCurrentStatus();
+ if (! status.isEmpty())
+ new NotifierThread(sr,status).start();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
+ */
+ public void serviceChanged(ServiceEvent e) {
+ ServiceReference sr = e.getServiceReference();
+ synchronized (LOCK) {
+ switch(e.getType()){
+ case ServiceEvent.REGISTERED:{
+ Filter filter = (Filter) sr.getProperty(UPnPEventListener.UPNP_FILTER);
+ if (filter == null) {
+ addNewListener(sr);
+ doNotify(sr);
+ }
+ else {
+ if (filter.match(UPnPTargetListener)){
+ addNewListener(sr);
+ doNotify(sr);
+ }
+ }
+ };break;
+
+ case ServiceEvent.MODIFIED:{
+ Filter filter = (Filter) sr.getProperty(UPnPEventListener.UPNP_FILTER);
+ removeListener(sr);
+ if (filter == null)
+ addNewListener(sr);
+ else {
+ if (filter.match(UPnPTargetListener))
+ addNewListener(sr);
+ }
+ };break;
+
+ case ServiceEvent.UNREGISTERING:{
+ removeListener(sr);
+ };break;
+ }
+ }//end LOCK
+
+ }
+
+
+ /**
+ * @param reference
+ */
+ private void removeListener(ServiceReference reference) {
+ upnpListeners.remove(reference);
+ }
+
+ /**
+ * @param reference
+ */
+ private void addNewListener(ServiceReference reference) {
+ upnpListeners.add(reference);
+ }
+
+ public void destroy(){
+ context.removeServiceListener(this);
+ upnpListeners.removeAllElements();
+ }
+}
diff --git a/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/UPnPSubscriber.java b/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/UPnPSubscriber.java
index 3d80a93..9f0bc4b 100644
--- a/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/UPnPSubscriber.java
+++ b/upnp/extra/src/main/java/org/apache/felix/upnp/extra/util/UPnPSubscriber.java
@@ -1,139 +1,139 @@
-/*
- * 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.extra.util;
-
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-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 {
- private BundleContext context;
- private UPnPEventListener listener;
- private HashMap hash;
-
- private class Subscription implements UPnPEventListener{
- ServiceRegistration registration;
-
- Subscription(String keys){
- try {
- Filter filter = context.createFilter(keys);
- Properties props = new Properties();
- props.put(UPnPEventListener.UPNP_FILTER, filter);
- registration = context.registerService(UPnPEventListener.class.getName(), this, props);
- }catch (Exception ex){
- System.out.println(ex);
- }
- }
-
- public void unsubscribe(){
- registration.unregister();
- }
-
- public void notifyUPnPEvent(String arg0, String arg1, Dictionary arg2) {
- listener.notifyUPnPEvent( arg0, arg1, arg2);
- }
- }
-
-
- public UPnPSubscriber(BundleContext context,UPnPEventListener listener){
- if ((context == null)|| (listener == null))
- throw new IllegalArgumentException("Illegal arguments in UPnPSubscriber constructor.");
- this.context = context;
- this.listener = listener;
- hash = new HashMap();
- }
-
- public void subscribe(String filter){
- if (hash.get(filter) == null){
- hash.put(filter, new Subscription(filter));
- }
- }
-
- public void unsubscribe(String filter){
- if (hash.containsKey(filter)) {
- Subscription subscription = (Subscription) hash.get(filter);
- subscription.unsubscribe();
- hash.remove(filter);
- }
- }
-
- public void unsubscribeAll(){
- Iterator list = hash.entrySet().iterator();
- while (list.hasNext()){
- Map.Entry entry = (Map.Entry) list.next();
- Subscription subcription = (Subscription) entry.getValue();
- subcription.unsubscribe();
- list.remove();
- }
- }
-
- public String subscribeServiceIdOf(String deviceId, String serviceId){
- String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" + serviceId + "))";
- subscribe(keys);
- return keys;
- }
-
- public String subscribeServiceTypeOf(String deviceId, String serviceType){
- String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.TYPE + "=" + serviceType + "))";
- subscribe(keys);
- return keys;
- }
-
- public String subscribeEveryServiceType(String deviceType, String serviceType){
- String keys = "(&(" + UPnPDevice.TYPE + "="+ deviceType + ")(" + UPnPService.TYPE + "=" + serviceType + "))";
- subscribe(keys);
- return keys;
- }
-
- public String subscribeAllServicesOf(String deviceId){
- String keys = "(" + UPnPDevice.ID + "="+ deviceId + ")";
- subscribe(keys);
- return keys;
- }
-
- public String subscribeEveryDeviceTypeServices(String deviceType){
- String keys = "(" + UPnPDevice.TYPE + "="+ deviceType + ")";
- subscribe(keys);
- return keys;
- }
-
-
- public void unsubscribeServiceIdOf(String deviceId, String serviceId){
- String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" + serviceId + "))";
- unsubscribe(keys);
- }
-
- public void unsubscribeAllServicesOf(String deviceId){
- String keys = "(" + UPnPDevice.ID + "="+ deviceId + ")";
- unsubscribe(keys);
- }
+/*
+ * 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.extra.util;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+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 {
+ private BundleContext context;
+ private UPnPEventListener listener;
+ private HashMap hash;
+
+ private class Subscription implements UPnPEventListener{
+ ServiceRegistration registration;
+
+ Subscription(String keys){
+ try {
+ Filter filter = context.createFilter(keys);
+ Properties props = new Properties();
+ props.put(UPnPEventListener.UPNP_FILTER, filter);
+ registration = context.registerService(UPnPEventListener.class.getName(), this, props);
+ }catch (Exception ex){
+ System.out.println(ex);
+ }
+ }
+
+ public void unsubscribe(){
+ registration.unregister();
+ }
+
+ public void notifyUPnPEvent(String arg0, String arg1, Dictionary arg2) {
+ listener.notifyUPnPEvent( arg0, arg1, arg2);
+ }
+ }
+
+
+ public UPnPSubscriber(BundleContext context,UPnPEventListener listener){
+ if ((context == null)|| (listener == null))
+ throw new IllegalArgumentException("Illegal arguments in UPnPSubscriber constructor.");
+ this.context = context;
+ this.listener = listener;
+ hash = new HashMap();
+ }
+
+ public void subscribe(String filter){
+ if (hash.get(filter) == null){
+ hash.put(filter, new Subscription(filter));
+ }
+ }
+
+ public void unsubscribe(String filter){
+ if (hash.containsKey(filter)) {
+ Subscription subscription = (Subscription) hash.get(filter);
+ subscription.unsubscribe();
+ hash.remove(filter);
+ }
+ }
+
+ public void unsubscribeAll(){
+ Iterator list = hash.entrySet().iterator();
+ while (list.hasNext()){
+ Map.Entry entry = (Map.Entry) list.next();
+ Subscription subcription = (Subscription) entry.getValue();
+ subcription.unsubscribe();
+ list.remove();
+ }
+ }
+
+ public String subscribeServiceIdOf(String deviceId, String serviceId){
+ String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" + serviceId + "))";
+ subscribe(keys);
+ return keys;
+ }
+
+ public String subscribeServiceTypeOf(String deviceId, String serviceType){
+ String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.TYPE + "=" + serviceType + "))";
+ subscribe(keys);
+ return keys;
+ }
+
+ public String subscribeEveryServiceType(String deviceType, String serviceType){
+ String keys = "(&(" + UPnPDevice.TYPE + "="+ deviceType + ")(" + UPnPService.TYPE + "=" + serviceType + "))";
+ subscribe(keys);
+ return keys;
+ }
+
+ public String subscribeAllServicesOf(String deviceId){
+ String keys = "(" + UPnPDevice.ID + "="+ deviceId + ")";
+ subscribe(keys);
+ return keys;
+ }
+
+ public String subscribeEveryDeviceTypeServices(String deviceType){
+ String keys = "(" + UPnPDevice.TYPE + "="+ deviceType + ")";
+ subscribe(keys);
+ return keys;
+ }
+
+
+ public void unsubscribeServiceIdOf(String deviceId, String serviceId){
+ String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" + serviceId + "))";
+ unsubscribe(keys);
+ }
+
+ public void unsubscribeAllServicesOf(String deviceId){
+ String keys = "(" + UPnPDevice.ID + "="+ deviceId + ")";
+ unsubscribe(keys);
+ }
}
\ No newline at end of file
diff --git a/upnp/pom.xml b/upnp/pom.xml
index 97f830d..fec9fb6 100644
--- a/upnp/pom.xml
+++ b/upnp/pom.xml
@@ -16,48 +16,48 @@
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: Root POM</name>
- <artifactId>upnp</artifactId>
- <version>1.0.0</version>
-
- <profiles>
- <profile>
- <id>packaging-bundle</id>
- <activation>
- <property>
- <name>packaging</name>
- <value>bundle</value>
- </property>
- </activation>
- <modules>
- <module>extra</module>
- <module>basedriver</module>
- <module>tester</module>
- <module>samples</module>
- </modules>
- </profile>
- <profile>
- <id>default</id>
- <activation>
- <property>
- <name>!packaging</name>
- </property>
- </activation>
- <modules>
- <module>extra</module>
- <module>basedriver</module>
- <module>tester</module>
- <module>samples</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: Root POM</name>
+ <artifactId>upnp</artifactId>
+ <version>1.0.0</version>
+
+ <profiles>
+ <profile>
+ <id>packaging-bundle</id>
+ <activation>
+ <property>
+ <name>packaging</name>
+ <value>bundle</value>
+ </property>
+ </activation>
+ <modules>
+ <module>extra</module>
+ <module>basedriver</module>
+ <module>tester</module>
+ <module>samples</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>default</id>
+ <activation>
+ <property>
+ <name>!packaging</name>
+ </property>
+ </activation>
+ <modules>
+ <module>extra</module>
+ <module>basedriver</module>
+ <module>tester</module>
+ <module>samples</module>
+ </modules>
+ </profile>
+ </profiles>
+</project>
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;
+ }
+
+
+}
diff --git a/upnp/tester/pom.xml b/upnp/tester/pom.xml
index 8452770..69edf6e 100644
--- a/upnp/tester/pom.xml
+++ b/upnp/tester/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,69 +17,70 @@
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.tester</artifactId>
- <packaging>bundle</packaging>
- <name>Apache Felix UPnP Tester</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.tester</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Felix UPnP Tester</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><![CDATA[Matteo Demuru <demuru@apache.org>,Francesco Furfari <furfari@apache.org>,Stefano "Kismet" Lenzi <lenzi@apache.org>]]></Bundle-Author>
- <Bundle-Description>
- OSGi Generic Control Point to control UPnPDevice services
- </Bundle-Description>
- <Bundle-SymbolicName>org.apache.felix.upnp.tester</Bundle-SymbolicName>
- <Bundle-Activator>org.apache.felix.upnp.tester.Activator</Bundle-Activator>
- <Private-Package>org.apache.felix.upnp.tester.*</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><![CDATA[Matteo Demuru <demuru@apache.org>,Francesco Furfari <furfari@apache.org>,Stefano "Kismet" Lenzi <lenzi@apache.org>]]></Bundle-Author>
+ <Bundle-Description>
+ OSGi Generic Control Point to control UPnPDevice services
+ </Bundle-Description>
+ <Bundle-SymbolicName>org.apache.felix.upnp.tester</Bundle-SymbolicName>
+ <Bundle-Activator>org.apache.felix.upnp.tester.Activator</Bundle-Activator>
+ <Private-Package>org.apache.felix.upnp.tester.*</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.basedriver</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- </dependency>
- <!-- dependency>
- Note: this dependency might be restored when (if) a converter utility will be exposed by extra bundle.
- So far Tester uses the Converter class of the basedriver (it should be fixed)
- <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.basedriver</artifactId>
+ <version>0.8.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <!-- dependency>
+ Note: this dependency might be restored when (if) a converter utility will be exposed by extra bundle.
+ So far Tester uses the Converter class of the basedriver (it should be fixed)
+ <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/tester/src/main/java/org/apache/felix/upnp/tester/ControlPoint.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/ControlPoint.java
index ac39d5d..b459386 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/ControlPoint.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/ControlPoint.java
@@ -1,375 +1,375 @@
-/*
- * 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.tester;
-
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.net.URL;
-
-import javax.swing.AbstractAction;
-import javax.swing.ButtonGroup;
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.JSplitPane;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
-
-import org.osgi.framework.BundleException;
-
-import org.apache.felix.upnp.tester.discovery.DriverProxy;
-import org.apache.felix.upnp.tester.discovery.RootDeviceListener;
-import org.apache.felix.upnp.tester.gui.LogPanel;
-import org.apache.felix.upnp.tester.gui.PropertiesViewer;
-import org.apache.felix.upnp.tester.gui.TreeViewer;
-import org.apache.felix.upnp.tester.gui.Util;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class ControlPoint implements PopupMenuListener {
- RootDeviceListener listener;
- TreeViewer viewer;
- PropertiesViewer properties;
- JFrame frame;
-
-
- public ControlPoint() {
- frame = new JFrame("Felix UPnPDevice Tester");
- try {
- URL eventIconUrl = Util.class.getResource("IMAGES/logo.gif");
- ImageIcon icon= new ImageIcon(eventIconUrl,"logo");
- frame.setIconImage(icon.getImage());
- }
- catch (Exception ex){
- System.out.println("Resource: IMAGES/logo.gif not found : " + ex.toString());
- }
- //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
- frame.addWindowListener(new WindowAdapter(){
- public void windowClosing(WindowEvent e){
- try {
- Activator.context.getBundle().stop();
- } catch (BundleException ex) {
- ex.printStackTrace();
- }
- }
-
- });
- frame.setBounds(0,0,300,200);
-
-
- doMenuBar(frame);
- doControlPanel();
- Mediator.setControlPoint(this);
- Mediator.setMainFrame(frame);
- listener = new RootDeviceListener();
- Mediator.setRootDeviceListener(listener);
- listener.setDeviceNodeListener(viewer);
-
- frame.pack();
- frame.setVisible(true);
-
- DriverProxy driverProxy = new DriverProxy();
- Mediator.setDriverProxy(driverProxy);
-
- listener.activate();
- }
-
- public void close(){
- listener.deactive();
- frame.dispose();
- Mediator.getDriverProxy().close();
- }
-
- private void doControlPanel(){
- JPanel panel = new JPanel(new BorderLayout());
- viewer = new TreeViewer();
- viewer.setPreferredSize(new Dimension(180,450));
- properties = new PropertiesViewer();
- Mediator.setPropertiesViewer(properties);
-
- JSplitPane treeSplitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,viewer,properties);
- JPanel logPanel = new LogPanel();
- logPanel.setPreferredSize(new Dimension(180,100));
- JSplitPane logSplitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT,treeSplitter,logPanel);
- panel.add(logSplitter);
- frame.getContentPane().add(panel);
-
-
- }
-
- /////////////////////////// MENU /////////////////////////////
- JMenu searchMenu,loggerMenu,cyberMenu;
- public void doMenuBar(JFrame frame) {
-
- JMenuBar menuBar = new JMenuBar();
-
- //////////////// FILE
- JMenu file_menu = new JMenu("File");
- file_menu.setMnemonic(KeyEvent.VK_F);
-
- searchMenu = new JMenu("Search");
- final String ALL_DEVICE = "ssdp:all";
- final String ROOT_DEVICE = "upnp:rootdevice";
- searchMenu.setMnemonic(KeyEvent.VK_L);
- searchMenu.setEnabled(false);
- AbstractAction searchAction = new AbstractAction(){
- public void actionPerformed(ActionEvent e) {
- DriverProxy controller = Mediator.getDriverProxy();
- if (e.getActionCommand().equals(ALL_DEVICE))
- controller.doSearch(ALL_DEVICE);
- else if (e.getActionCommand().equals(ROOT_DEVICE))
- controller.doSearch(ROOT_DEVICE);
- }
- };
-
- JMenuItem rootDeviceItem = new JMenuItem("Root Devices");
- rootDeviceItem.setMnemonic(KeyEvent.VK_R);
- rootDeviceItem.addActionListener(searchAction);
- rootDeviceItem.setActionCommand(ROOT_DEVICE);
- searchMenu.add(rootDeviceItem);
-
- JMenuItem allDeviceItem = new JMenuItem("All Devices");
- allDeviceItem .setMnemonic(KeyEvent.VK_A);
- allDeviceItem .addActionListener(searchAction);
- allDeviceItem .setActionCommand(ALL_DEVICE);
- searchMenu.add(allDeviceItem);
-
-
- JMenuItem checkIncompleteItem = new JMenuItem("Print Pending Devices");
- checkIncompleteItem.setMnemonic(KeyEvent.VK_I);
- checkIncompleteItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Mediator.getRootDeviceListener().checkIncompleteDevice();
- }
- });
-
- JMenuItem checkErrataItem = new JMenuItem("Check Errata UPnPDevices");
- checkErrataItem.setMnemonic(KeyEvent.VK_E);
- checkErrataItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- RootDeviceListener.checkErrataDevice();}
- });
-
-
- loggerMenu = new JMenu("Felix Logger");
- final String NO_LOGGING ="No Logging";
- final String ERROR ="Error";
- final String WARNING ="Warning";
- final String INFO ="Info";
- final String DEBUG ="Debug";
-
- loggerMenu.getPopupMenu().addPopupMenuListener(this);
- loggerMenu.setMnemonic(KeyEvent.VK_L);
- loggerMenu.setEnabled(false);
- AbstractAction loggerAction = new AbstractAction(){
- public void actionPerformed(ActionEvent e) {
- DriverProxy controller = Mediator.getDriverProxy();
- if (e.getActionCommand().equals(NO_LOGGING))
- controller.setLogLevel(0);
- else if (e.getActionCommand().equals(ERROR))
- controller.setLogLevel(1);
- else if (e.getActionCommand().equals(WARNING))
- controller.setLogLevel(2);
- else if (e.getActionCommand().equals(INFO))
- controller.setLogLevel(3);
- else if (e.getActionCommand().equals(DEBUG))
- controller.setLogLevel(4);
- }
- };
-
- ButtonGroup group = new ButtonGroup();
-
- JRadioButtonMenuItem rbMenuItem = new JRadioButtonMenuItem(NO_LOGGING);
- rbMenuItem.setSelected(true);
- rbMenuItem.setMnemonic(KeyEvent.VK_N);
- rbMenuItem.setActionCommand(NO_LOGGING);
- rbMenuItem.addActionListener(loggerAction);
- group.add(rbMenuItem);
- loggerMenu.add(rbMenuItem);
- loggerMenu.addSeparator();
-
- rbMenuItem = new JRadioButtonMenuItem(ERROR);
- rbMenuItem.setMnemonic(KeyEvent.VK_E);
- rbMenuItem.setActionCommand(ERROR);
- rbMenuItem.addActionListener(loggerAction);
- group.add(rbMenuItem);
- loggerMenu.add(rbMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem(WARNING);
- rbMenuItem.setMnemonic(KeyEvent.VK_W);
- rbMenuItem.setActionCommand(WARNING);
- rbMenuItem.addActionListener(loggerAction);
- group.add(rbMenuItem);
- loggerMenu.add(rbMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem(INFO);
- rbMenuItem.setMnemonic(KeyEvent.VK_I);
- rbMenuItem.setActionCommand(INFO);
- rbMenuItem.addActionListener(loggerAction);
- group.add(rbMenuItem);
- loggerMenu.add(rbMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem(DEBUG);
- rbMenuItem.setMnemonic(KeyEvent.VK_D);
- rbMenuItem.setActionCommand(DEBUG);
- rbMenuItem.addActionListener(loggerAction);
- group.add(rbMenuItem);
- loggerMenu.add(rbMenuItem);
-
- final String ON ="On";
- final String OFF ="Off";
- cyberMenu = new JMenu("Cyber Debugger");
- cyberMenu.getPopupMenu().addPopupMenuListener(this);
- cyberMenu.setMnemonic(KeyEvent.VK_C);
- cyberMenu.setEnabled(false);
- AbstractAction cyberAction = new AbstractAction(){
- public void actionPerformed(ActionEvent e) {
- DriverProxy controller = Mediator.getDriverProxy();
- if (e.getActionCommand().equals(ON))
- controller.setCyberDebug(true);
- else if (e.getActionCommand().equals(OFF))
- controller.setCyberDebug(false);
- }
- };
-
-
- ButtonGroup cyberGroup = new ButtonGroup();
- rbMenuItem = new JRadioButtonMenuItem(ON);
- rbMenuItem.setSelected(true);
- rbMenuItem.setMnemonic(KeyEvent.VK_O);
- rbMenuItem.setActionCommand(ON);
- rbMenuItem.addActionListener(cyberAction);
- cyberGroup.add(rbMenuItem);
- cyberMenu.add(rbMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem(OFF);
- rbMenuItem.setMnemonic(KeyEvent.VK_F);
- rbMenuItem.setActionCommand(OFF);
- rbMenuItem.addActionListener(cyberAction);
- cyberGroup.add(rbMenuItem);
- cyberMenu.add(rbMenuItem);
-
- /*
- JMenuItem clearSubscriptionItem = new JMenuItem("Clear Subscriptions");
- clearSubscriptionItem.setMnemonic(KeyEvent.VK_S);
- clearSubscriptionItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
-// to do
- }
- });
- */
-
- JMenuItem exitItem = new JMenuItem("Exit");
- exitItem.setMnemonic(KeyEvent.VK_X);
- exitItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- try {
- Activator.context.getBundle().stop();
- }catch (Exception ex){
- ex.printStackTrace();
- }
- }
- });
-
-
- file_menu.add(searchMenu);
- file_menu.addSeparator();
- file_menu.add(loggerMenu);
- file_menu.add(cyberMenu);
- file_menu.addSeparator();
- file_menu.add(checkIncompleteItem);
- file_menu.add(checkErrataItem);
- //file_menu.addSeparator();
- //file_menu.add(clearSubscriptionItem);
- file_menu.addSeparator();
- file_menu.add(exitItem);
-
- menuBar.add(file_menu);
- frame.setJMenuBar(menuBar);
-
- }
-
-
- public void enableMenus(boolean driverAvailable,int logLevel,boolean cyberDebug) {
- searchMenu.setEnabled(driverAvailable);
- Component[] items = searchMenu.getPopupMenu().getComponents();
- for (int i=0;i < items.length;i++)
- items[i].setEnabled(driverAvailable);
-
- loggerMenu.setEnabled(driverAvailable);
- items = loggerMenu.getPopupMenu().getComponents();
- for (int i=0;i < items.length;i++)
- items[i].setEnabled(driverAvailable);
- if (driverAvailable){
- ((JRadioButtonMenuItem)items[logLevel>0?logLevel+1:0]).setSelected(true);
- }
- cyberMenu.setEnabled(driverAvailable);
- items = cyberMenu.getPopupMenu().getComponents();
- for (int i=0;i < items.length;i++)
- items[i].setEnabled(driverAvailable);
- if (driverAvailable){
- if (cyberDebug)
- ((JRadioButtonMenuItem)items[0]).setSelected(true);
- else
- ((JRadioButtonMenuItem)items[1]).setSelected(true);
- }
- }
-
- public void popupMenuCanceled(PopupMenuEvent e) { }
- public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { }
-
- public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
- JPopupMenu loggerPopup = loggerMenu.getPopupMenu();
- JPopupMenu cyberPopup = cyberMenu.getPopupMenu();
- if (e.getSource()==loggerPopup){
- int logLevel = Mediator.getDriverProxy().getLogLevel();
- Component[] items = loggerPopup.getComponents();
- ((JRadioButtonMenuItem)items[logLevel>0?logLevel+1:0]).setSelected(true);
- }
- else if (e.getSource()==cyberPopup){
- boolean cyberDebug = Mediator.getDriverProxy().getCyberDebug();
- Component[] items = cyberPopup.getComponents();
- if (cyberDebug)
- ((JRadioButtonMenuItem)items[0]).setSelected(true);
- else
- ((JRadioButtonMenuItem)items[1]).setSelected(true);
- }
-
-
- }
-
-
-
-
-}
+/*
+ * 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.tester;
+
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.net.URL;
+
+import javax.swing.AbstractAction;
+import javax.swing.ButtonGroup;
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JSplitPane;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+
+import org.osgi.framework.BundleException;
+
+import org.apache.felix.upnp.tester.discovery.DriverProxy;
+import org.apache.felix.upnp.tester.discovery.RootDeviceListener;
+import org.apache.felix.upnp.tester.gui.LogPanel;
+import org.apache.felix.upnp.tester.gui.PropertiesViewer;
+import org.apache.felix.upnp.tester.gui.TreeViewer;
+import org.apache.felix.upnp.tester.gui.Util;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class ControlPoint implements PopupMenuListener {
+ RootDeviceListener listener;
+ TreeViewer viewer;
+ PropertiesViewer properties;
+ JFrame frame;
+
+
+ public ControlPoint() {
+ frame = new JFrame("Felix UPnPDevice Tester");
+ try {
+ URL eventIconUrl = Util.class.getResource("IMAGES/logo.gif");
+ ImageIcon icon= new ImageIcon(eventIconUrl,"logo");
+ frame.setIconImage(icon.getImage());
+ }
+ catch (Exception ex){
+ System.out.println("Resource: IMAGES/logo.gif not found : " + ex.toString());
+ }
+ //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ frame.addWindowListener(new WindowAdapter(){
+ public void windowClosing(WindowEvent e){
+ try {
+ Activator.context.getBundle().stop();
+ } catch (BundleException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ });
+ frame.setBounds(0,0,300,200);
+
+
+ doMenuBar(frame);
+ doControlPanel();
+ Mediator.setControlPoint(this);
+ Mediator.setMainFrame(frame);
+ listener = new RootDeviceListener();
+ Mediator.setRootDeviceListener(listener);
+ listener.setDeviceNodeListener(viewer);
+
+ frame.pack();
+ frame.setVisible(true);
+
+ DriverProxy driverProxy = new DriverProxy();
+ Mediator.setDriverProxy(driverProxy);
+
+ listener.activate();
+ }
+
+ public void close(){
+ listener.deactive();
+ frame.dispose();
+ Mediator.getDriverProxy().close();
+ }
+
+ private void doControlPanel(){
+ JPanel panel = new JPanel(new BorderLayout());
+ viewer = new TreeViewer();
+ viewer.setPreferredSize(new Dimension(180,450));
+ properties = new PropertiesViewer();
+ Mediator.setPropertiesViewer(properties);
+
+ JSplitPane treeSplitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,viewer,properties);
+ JPanel logPanel = new LogPanel();
+ logPanel.setPreferredSize(new Dimension(180,100));
+ JSplitPane logSplitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT,treeSplitter,logPanel);
+ panel.add(logSplitter);
+ frame.getContentPane().add(panel);
+
+
+ }
+
+ /////////////////////////// MENU /////////////////////////////
+ JMenu searchMenu,loggerMenu,cyberMenu;
+ public void doMenuBar(JFrame frame) {
+
+ JMenuBar menuBar = new JMenuBar();
+
+ //////////////// FILE
+ JMenu file_menu = new JMenu("File");
+ file_menu.setMnemonic(KeyEvent.VK_F);
+
+ searchMenu = new JMenu("Search");
+ final String ALL_DEVICE = "ssdp:all";
+ final String ROOT_DEVICE = "upnp:rootdevice";
+ searchMenu.setMnemonic(KeyEvent.VK_L);
+ searchMenu.setEnabled(false);
+ AbstractAction searchAction = new AbstractAction(){
+ public void actionPerformed(ActionEvent e) {
+ DriverProxy controller = Mediator.getDriverProxy();
+ if (e.getActionCommand().equals(ALL_DEVICE))
+ controller.doSearch(ALL_DEVICE);
+ else if (e.getActionCommand().equals(ROOT_DEVICE))
+ controller.doSearch(ROOT_DEVICE);
+ }
+ };
+
+ JMenuItem rootDeviceItem = new JMenuItem("Root Devices");
+ rootDeviceItem.setMnemonic(KeyEvent.VK_R);
+ rootDeviceItem.addActionListener(searchAction);
+ rootDeviceItem.setActionCommand(ROOT_DEVICE);
+ searchMenu.add(rootDeviceItem);
+
+ JMenuItem allDeviceItem = new JMenuItem("All Devices");
+ allDeviceItem .setMnemonic(KeyEvent.VK_A);
+ allDeviceItem .addActionListener(searchAction);
+ allDeviceItem .setActionCommand(ALL_DEVICE);
+ searchMenu.add(allDeviceItem);
+
+
+ JMenuItem checkIncompleteItem = new JMenuItem("Print Pending Devices");
+ checkIncompleteItem.setMnemonic(KeyEvent.VK_I);
+ checkIncompleteItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ Mediator.getRootDeviceListener().checkIncompleteDevice();
+ }
+ });
+
+ JMenuItem checkErrataItem = new JMenuItem("Check Errata UPnPDevices");
+ checkErrataItem.setMnemonic(KeyEvent.VK_E);
+ checkErrataItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ RootDeviceListener.checkErrataDevice();}
+ });
+
+
+ loggerMenu = new JMenu("Felix Logger");
+ final String NO_LOGGING ="No Logging";
+ final String ERROR ="Error";
+ final String WARNING ="Warning";
+ final String INFO ="Info";
+ final String DEBUG ="Debug";
+
+ loggerMenu.getPopupMenu().addPopupMenuListener(this);
+ loggerMenu.setMnemonic(KeyEvent.VK_L);
+ loggerMenu.setEnabled(false);
+ AbstractAction loggerAction = new AbstractAction(){
+ public void actionPerformed(ActionEvent e) {
+ DriverProxy controller = Mediator.getDriverProxy();
+ if (e.getActionCommand().equals(NO_LOGGING))
+ controller.setLogLevel(0);
+ else if (e.getActionCommand().equals(ERROR))
+ controller.setLogLevel(1);
+ else if (e.getActionCommand().equals(WARNING))
+ controller.setLogLevel(2);
+ else if (e.getActionCommand().equals(INFO))
+ controller.setLogLevel(3);
+ else if (e.getActionCommand().equals(DEBUG))
+ controller.setLogLevel(4);
+ }
+ };
+
+ ButtonGroup group = new ButtonGroup();
+
+ JRadioButtonMenuItem rbMenuItem = new JRadioButtonMenuItem(NO_LOGGING);
+ rbMenuItem.setSelected(true);
+ rbMenuItem.setMnemonic(KeyEvent.VK_N);
+ rbMenuItem.setActionCommand(NO_LOGGING);
+ rbMenuItem.addActionListener(loggerAction);
+ group.add(rbMenuItem);
+ loggerMenu.add(rbMenuItem);
+ loggerMenu.addSeparator();
+
+ rbMenuItem = new JRadioButtonMenuItem(ERROR);
+ rbMenuItem.setMnemonic(KeyEvent.VK_E);
+ rbMenuItem.setActionCommand(ERROR);
+ rbMenuItem.addActionListener(loggerAction);
+ group.add(rbMenuItem);
+ loggerMenu.add(rbMenuItem);
+
+ rbMenuItem = new JRadioButtonMenuItem(WARNING);
+ rbMenuItem.setMnemonic(KeyEvent.VK_W);
+ rbMenuItem.setActionCommand(WARNING);
+ rbMenuItem.addActionListener(loggerAction);
+ group.add(rbMenuItem);
+ loggerMenu.add(rbMenuItem);
+
+ rbMenuItem = new JRadioButtonMenuItem(INFO);
+ rbMenuItem.setMnemonic(KeyEvent.VK_I);
+ rbMenuItem.setActionCommand(INFO);
+ rbMenuItem.addActionListener(loggerAction);
+ group.add(rbMenuItem);
+ loggerMenu.add(rbMenuItem);
+
+ rbMenuItem = new JRadioButtonMenuItem(DEBUG);
+ rbMenuItem.setMnemonic(KeyEvent.VK_D);
+ rbMenuItem.setActionCommand(DEBUG);
+ rbMenuItem.addActionListener(loggerAction);
+ group.add(rbMenuItem);
+ loggerMenu.add(rbMenuItem);
+
+ final String ON ="On";
+ final String OFF ="Off";
+ cyberMenu = new JMenu("Cyber Debugger");
+ cyberMenu.getPopupMenu().addPopupMenuListener(this);
+ cyberMenu.setMnemonic(KeyEvent.VK_C);
+ cyberMenu.setEnabled(false);
+ AbstractAction cyberAction = new AbstractAction(){
+ public void actionPerformed(ActionEvent e) {
+ DriverProxy controller = Mediator.getDriverProxy();
+ if (e.getActionCommand().equals(ON))
+ controller.setCyberDebug(true);
+ else if (e.getActionCommand().equals(OFF))
+ controller.setCyberDebug(false);
+ }
+ };
+
+
+ ButtonGroup cyberGroup = new ButtonGroup();
+ rbMenuItem = new JRadioButtonMenuItem(ON);
+ rbMenuItem.setSelected(true);
+ rbMenuItem.setMnemonic(KeyEvent.VK_O);
+ rbMenuItem.setActionCommand(ON);
+ rbMenuItem.addActionListener(cyberAction);
+ cyberGroup.add(rbMenuItem);
+ cyberMenu.add(rbMenuItem);
+
+ rbMenuItem = new JRadioButtonMenuItem(OFF);
+ rbMenuItem.setMnemonic(KeyEvent.VK_F);
+ rbMenuItem.setActionCommand(OFF);
+ rbMenuItem.addActionListener(cyberAction);
+ cyberGroup.add(rbMenuItem);
+ cyberMenu.add(rbMenuItem);
+
+ /*
+ JMenuItem clearSubscriptionItem = new JMenuItem("Clear Subscriptions");
+ clearSubscriptionItem.setMnemonic(KeyEvent.VK_S);
+ clearSubscriptionItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+// to do
+ }
+ });
+ */
+
+ JMenuItem exitItem = new JMenuItem("Exit");
+ exitItem.setMnemonic(KeyEvent.VK_X);
+ exitItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ try {
+ Activator.context.getBundle().stop();
+ }catch (Exception ex){
+ ex.printStackTrace();
+ }
+ }
+ });
+
+
+ file_menu.add(searchMenu);
+ file_menu.addSeparator();
+ file_menu.add(loggerMenu);
+ file_menu.add(cyberMenu);
+ file_menu.addSeparator();
+ file_menu.add(checkIncompleteItem);
+ file_menu.add(checkErrataItem);
+ //file_menu.addSeparator();
+ //file_menu.add(clearSubscriptionItem);
+ file_menu.addSeparator();
+ file_menu.add(exitItem);
+
+ menuBar.add(file_menu);
+ frame.setJMenuBar(menuBar);
+
+ }
+
+
+ public void enableMenus(boolean driverAvailable,int logLevel,boolean cyberDebug) {
+ searchMenu.setEnabled(driverAvailable);
+ Component[] items = searchMenu.getPopupMenu().getComponents();
+ for (int i=0;i < items.length;i++)
+ items[i].setEnabled(driverAvailable);
+
+ loggerMenu.setEnabled(driverAvailable);
+ items = loggerMenu.getPopupMenu().getComponents();
+ for (int i=0;i < items.length;i++)
+ items[i].setEnabled(driverAvailable);
+ if (driverAvailable){
+ ((JRadioButtonMenuItem)items[logLevel>0?logLevel+1:0]).setSelected(true);
+ }
+ cyberMenu.setEnabled(driverAvailable);
+ items = cyberMenu.getPopupMenu().getComponents();
+ for (int i=0;i < items.length;i++)
+ items[i].setEnabled(driverAvailable);
+ if (driverAvailable){
+ if (cyberDebug)
+ ((JRadioButtonMenuItem)items[0]).setSelected(true);
+ else
+ ((JRadioButtonMenuItem)items[1]).setSelected(true);
+ }
+ }
+
+ public void popupMenuCanceled(PopupMenuEvent e) { }
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { }
+
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
+ JPopupMenu loggerPopup = loggerMenu.getPopupMenu();
+ JPopupMenu cyberPopup = cyberMenu.getPopupMenu();
+ if (e.getSource()==loggerPopup){
+ int logLevel = Mediator.getDriverProxy().getLogLevel();
+ Component[] items = loggerPopup.getComponents();
+ ((JRadioButtonMenuItem)items[logLevel>0?logLevel+1:0]).setSelected(true);
+ }
+ else if (e.getSource()==cyberPopup){
+ boolean cyberDebug = Mediator.getDriverProxy().getCyberDebug();
+ Component[] items = cyberPopup.getComponents();
+ if (cyberDebug)
+ ((JRadioButtonMenuItem)items[0]).setSelected(true);
+ else
+ ((JRadioButtonMenuItem)items[1]).setSelected(true);
+ }
+
+
+ }
+
+
+
+
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/Mediator.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/Mediator.java
index 128f8c0..8361eab 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/Mediator.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/Mediator.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.tester;
-
-
-import javax.swing.JFrame;
-import javax.swing.JTree;
-
-import org.apache.felix.upnp.tester.discovery.DriverProxy;
-import org.apache.felix.upnp.tester.discovery.RootDeviceListener;
-import org.apache.felix.upnp.tester.gui.PropertiesViewer;
-import org.apache.felix.upnp.tester.gui.TreeViewer;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class Mediator {
- static PropertiesViewer props;
- static JTree tree;
- static JFrame frame;
- static DriverProxy driverProxy;
- static RootDeviceListener rootDeviceListener;
- static ControlPoint controlPoint;
- static TreeViewer treeViewer;
-
-
- public static void setPropertiesViewer(PropertiesViewer props){
- Mediator.props=props;
- }
- public static PropertiesViewer getPropertiesViewer(){
- return props;
- }
-
- public static void setUPnPDeviceTree(JTree tree){
- Mediator.tree=tree;
- }
- public static JTree getUPnPDeviceTree(){
- return tree;
- }
-
- public static void setTreeViewer(TreeViewer treeViewer){
- Mediator.treeViewer=treeViewer;
- }
- public static TreeViewer getTreeViewer(){
- return treeViewer;
- }
-
- public static void setMainFrame(JFrame frame){
- Mediator.frame=frame;
- }
- public static JFrame getMainFrame(){
- return frame;
- }
- public static void setControlPoint(ControlPoint controlPoint){
- Mediator.controlPoint=controlPoint;
- }
- public static ControlPoint getControlPoint(){
- return controlPoint;
- }
-
- public static void setDriverProxy(DriverProxy driverProxy) {
- Mediator.driverProxy = driverProxy;
- }
-
- public static DriverProxy getDriverProxy(){
- return driverProxy;
- }
-
- public static void setRootDeviceListener(RootDeviceListener listener) {
- Mediator.rootDeviceListener = listener;
- }
-
- public static RootDeviceListener getRootDeviceListener(){
- return rootDeviceListener;
- }
-}
+/*
+ * 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.tester;
+
+
+import javax.swing.JFrame;
+import javax.swing.JTree;
+
+import org.apache.felix.upnp.tester.discovery.DriverProxy;
+import org.apache.felix.upnp.tester.discovery.RootDeviceListener;
+import org.apache.felix.upnp.tester.gui.PropertiesViewer;
+import org.apache.felix.upnp.tester.gui.TreeViewer;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class Mediator {
+ static PropertiesViewer props;
+ static JTree tree;
+ static JFrame frame;
+ static DriverProxy driverProxy;
+ static RootDeviceListener rootDeviceListener;
+ static ControlPoint controlPoint;
+ static TreeViewer treeViewer;
+
+
+ public static void setPropertiesViewer(PropertiesViewer props){
+ Mediator.props=props;
+ }
+ public static PropertiesViewer getPropertiesViewer(){
+ return props;
+ }
+
+ public static void setUPnPDeviceTree(JTree tree){
+ Mediator.tree=tree;
+ }
+ public static JTree getUPnPDeviceTree(){
+ return tree;
+ }
+
+ public static void setTreeViewer(TreeViewer treeViewer){
+ Mediator.treeViewer=treeViewer;
+ }
+ public static TreeViewer getTreeViewer(){
+ return treeViewer;
+ }
+
+ public static void setMainFrame(JFrame frame){
+ Mediator.frame=frame;
+ }
+ public static JFrame getMainFrame(){
+ return frame;
+ }
+ public static void setControlPoint(ControlPoint controlPoint){
+ Mediator.controlPoint=controlPoint;
+ }
+ public static ControlPoint getControlPoint(){
+ return controlPoint;
+ }
+
+ public static void setDriverProxy(DriverProxy driverProxy) {
+ Mediator.driverProxy = driverProxy;
+ }
+
+ public static DriverProxy getDriverProxy(){
+ return driverProxy;
+ }
+
+ public static void setRootDeviceListener(RootDeviceListener listener) {
+ Mediator.rootDeviceListener = listener;
+ }
+
+ public static RootDeviceListener getRootDeviceListener(){
+ return rootDeviceListener;
+ }
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/UPnPSubscriber.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/UPnPSubscriber.java
index 0c4d983..baaff4d 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/UPnPSubscriber.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/UPnPSubscriber.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.tester;
-
-import java.util.Dictionary;
-import java.util.HashMap;
-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 {
- private BundleContext context;
- private UPnPEventListener listener;
- private HashMap hash;
-
- private class Subscription implements UPnPEventListener{
- ServiceRegistration registration;
-
- Subscription(String keys){
- try {
- Filter filter = context.createFilter(keys);
- Properties props = new Properties();
- props.put(UPnPEventListener.UPNP_FILTER, filter);
- registration = context.registerService(UPnPEventListener.class.getName(), this, props);
- }catch (Exception ex){
- System.out.println(ex);
- }
- }
-
- public void unsubscribe(){
- registration.unregister();
- }
-
- public void notifyUPnPEvent(String arg0, String arg1, Dictionary arg2) {
- listener.notifyUPnPEvent( arg0, arg1, arg2);
- }
- }
-
-
- public UPnPSubscriber(BundleContext context,UPnPEventListener listener){
- this.context = context;
- this.listener = listener;
- hash = new HashMap();
- }
-
- public void subscribe(String deviceId, String serviceId){
- String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" + serviceId + "))";
- if (hash.get(keys) == null){
- hash.put(keys, new Subscription(keys));
- }
- }
-
- public void unsubscribe(String deviceId, String serviceId){
- String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" + serviceId + "))";
- if (hash.containsKey(keys)) {
- Subscription subscription = (Subscription) hash.get(keys);
- subscription.unsubscribe();
- hash.remove(keys);
- }
- }
-
-
-
-
-}
+/*
+ * 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.tester;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+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 {
+ private BundleContext context;
+ private UPnPEventListener listener;
+ private HashMap hash;
+
+ private class Subscription implements UPnPEventListener{
+ ServiceRegistration registration;
+
+ Subscription(String keys){
+ try {
+ Filter filter = context.createFilter(keys);
+ Properties props = new Properties();
+ props.put(UPnPEventListener.UPNP_FILTER, filter);
+ registration = context.registerService(UPnPEventListener.class.getName(), this, props);
+ }catch (Exception ex){
+ System.out.println(ex);
+ }
+ }
+
+ public void unsubscribe(){
+ registration.unregister();
+ }
+
+ public void notifyUPnPEvent(String arg0, String arg1, Dictionary arg2) {
+ listener.notifyUPnPEvent( arg0, arg1, arg2);
+ }
+ }
+
+
+ public UPnPSubscriber(BundleContext context,UPnPEventListener listener){
+ this.context = context;
+ this.listener = listener;
+ hash = new HashMap();
+ }
+
+ public void subscribe(String deviceId, String serviceId){
+ String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" + serviceId + "))";
+ if (hash.get(keys) == null){
+ hash.put(keys, new Subscription(keys));
+ }
+ }
+
+ public void unsubscribe(String deviceId, String serviceId){
+ String keys = "(&(" + UPnPDevice.ID + "="+ deviceId + ")(" + UPnPService.ID + "=" + serviceId + "))";
+ if (hash.containsKey(keys)) {
+ Subscription subscription = (Subscription) hash.get(keys);
+ subscription.unsubscribe();
+ hash.remove(keys);
+ }
+ }
+
+
+
+
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DeviceNode.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DeviceNode.java
index 550194b..3c7eff8 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DeviceNode.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DeviceNode.java
@@ -1,215 +1,215 @@
-/*
- * 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.tester.discovery;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.upnp.UPnPDevice;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class DeviceNode {
-
- private ServiceReference sr;
- private boolean isRootNode;
- private String udn ;
- private boolean hasChild;
- private int numberOfSons;
- private ArrayList children;
- private DeviceNode parent;
-
- public DeviceNode(ServiceReference sr){
- //PRE: argument is always UPnPDevice service reference
- if (sr == null)
- throw new IllegalArgumentException("null is not a valid arg in DeviceNode constructor");
- this.sr = sr;
- udn = (String) sr.getProperty(UPnPDevice.UDN);
- parent=null;
- isRootNode = (sr.getProperty(UPnPDevice.PARENT_UDN) == null);
- String[] sons = ((String[]) sr.getProperty(UPnPDevice.CHILDREN_UDN));
- hasChild = (sons != null);
- if (hasChild) {
- children = new ArrayList();
- numberOfSons = sons.length;
- }
- /*
- //Operation to let DeviceNode::isComplete() O(1)
- isComplete = !hasChild;
- */
- }
-
- public ServiceReference getReference(){
- return sr;
- }
- public UPnPDevice getDevice(BundleContext ctx){
- return (UPnPDevice)ctx.getService(sr);
- }
-
- public void attach(DeviceNode node){
- if (node == null)
- throw new IllegalArgumentException("null is not a valid arg in DeviceNode.attach() method");
- node.parent = this;
- /*
- //Operation to let DeviceNode::isComplete() O(1)
- if((numberOfSons==children.size()-1)
- &&(node.isComplete())){
- this.isComplete = true;
- }
- */
- children.add(node);
- }
-
- public DeviceNode dethatch(String name){
- DeviceNode dn = this.search(name);
- if(dn==null)
- return null;
-
- if(dn.parent!=null){
- Iterator list = dn.parent.children.iterator();
- while (list.hasNext()) {
- DeviceNode x = (DeviceNode) list.next();
- if(x.udn.equals(name)){
- list.remove();
- /*
- //Operation to let DeviceNode::isComplete() O(1)
- dn.parent.isComplete=false;
- */
- break;
- }
- }
- }
- dn.parent=null;
- return dn;
- }
-
- public Collection getAllChildren(){
- if((this.children==null)||(this.children.size()==0))
- return new ArrayList();
-
- Vector v = new Vector(this.children);
- Iterator list = this.children.iterator();
- while (list.hasNext()) {
- DeviceNode x = (DeviceNode) list.next();
- Collection c = x.getAllChildren();
- if(c==null) continue;
- v.addAll(c);
- }
- return v;
- }
-
- public Collection getChildren(){
- if((this.children==null)||(this.children.size()==0))
- return new ArrayList();
- return this.children;
- }
-
- /**
- * @param name <code>String</code> that contain the UDN to look for
- * @return return a <code>DeviceNode</code> that have the UDN equals to name and <br>
- * if there is any <code>DeviceNode</code> with the proper UDN value return <code>null</code>
- */
- public DeviceNode search(String name){
- if (name == null)
- throw new IllegalArgumentException("null is not a valid arg in DeviceNode.search() method");
- if (name.equals(udn))
- return this;
- else if (hasChild){
- Iterator list = children.iterator();
- while (list.hasNext()){
- DeviceNode child = (DeviceNode)list.next();
- DeviceNode node = child.search(name);
- if (node != null) return node;
- }
- }
- return null;
- }
-
- /**
- *
- * @param udn
- * @return <code>true</code> if and only if this <code>DeviceNode</code>
- * contains a DeviceNode with UDN equals to passed argument or if
- * its USN is equal to passed argument
- */
- public boolean contains(String udn){
- return this.search(udn)!=null;
- }
-
- public boolean isComplete(){
- /*
- //Operation to let DeviceNode::isComplete() O(1)
- return isComplete;
- */
- if (! hasChild) return true;
- if (numberOfSons != children.size())return false;
- Iterator list = children.iterator();
- while (list.hasNext()){
- DeviceNode child = (DeviceNode)list.next();
- if (! child.isComplete()) return false;
- }
- return true;
- }
-
- public DeviceNode isAttachable(DeviceNode node){
- if (node == null)
- throw new IllegalArgumentException("null is not a valid arg in DeviceNode.isAttachable() method");
- String parentUDN=(String) node.getReference().getProperty(UPnPDevice.PARENT_UDN);
- if(parentUDN==null) return null;
- return search(parentUDN);
- }
-
- public boolean isRoot(){
- return isRootNode;
- }
-
- public boolean equals(String udn){
- return this.udn.equals(udn);
- }
-
- public String toString(){
- return udn;
- }
- public boolean isLeaf() {
- return !hasChild;
- }
-
- public void print(){
- System.out.println("####Device Node");
- String[] props = sr.getPropertyKeys();
- for (int i=0;i< props.length;i++){
- Object prop= sr.getProperty(props[i]);
- if (prop instanceof String[]){
- System.out.println(props[i]+ "=");
- String[] multiple = (String[])prop;
- for (int j=0;j< multiple.length;j++){
- System.out.println(multiple[j]+ ";");
- }
-
- }
- else System.out.println(props[i]+ "="+ prop);
- }
- System.out.println("####Device Node");
- }
-}
+/*
+ * 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.tester.discovery;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.upnp.UPnPDevice;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class DeviceNode {
+
+ private ServiceReference sr;
+ private boolean isRootNode;
+ private String udn ;
+ private boolean hasChild;
+ private int numberOfSons;
+ private ArrayList children;
+ private DeviceNode parent;
+
+ public DeviceNode(ServiceReference sr){
+ //PRE: argument is always UPnPDevice service reference
+ if (sr == null)
+ throw new IllegalArgumentException("null is not a valid arg in DeviceNode constructor");
+ this.sr = sr;
+ udn = (String) sr.getProperty(UPnPDevice.UDN);
+ parent=null;
+ isRootNode = (sr.getProperty(UPnPDevice.PARENT_UDN) == null);
+ String[] sons = ((String[]) sr.getProperty(UPnPDevice.CHILDREN_UDN));
+ hasChild = (sons != null);
+ if (hasChild) {
+ children = new ArrayList();
+ numberOfSons = sons.length;
+ }
+ /*
+ //Operation to let DeviceNode::isComplete() O(1)
+ isComplete = !hasChild;
+ */
+ }
+
+ public ServiceReference getReference(){
+ return sr;
+ }
+ public UPnPDevice getDevice(BundleContext ctx){
+ return (UPnPDevice)ctx.getService(sr);
+ }
+
+ public void attach(DeviceNode node){
+ if (node == null)
+ throw new IllegalArgumentException("null is not a valid arg in DeviceNode.attach() method");
+ node.parent = this;
+ /*
+ //Operation to let DeviceNode::isComplete() O(1)
+ if((numberOfSons==children.size()-1)
+ &&(node.isComplete())){
+ this.isComplete = true;
+ }
+ */
+ children.add(node);
+ }
+
+ public DeviceNode dethatch(String name){
+ DeviceNode dn = this.search(name);
+ if(dn==null)
+ return null;
+
+ if(dn.parent!=null){
+ Iterator list = dn.parent.children.iterator();
+ while (list.hasNext()) {
+ DeviceNode x = (DeviceNode) list.next();
+ if(x.udn.equals(name)){
+ list.remove();
+ /*
+ //Operation to let DeviceNode::isComplete() O(1)
+ dn.parent.isComplete=false;
+ */
+ break;
+ }
+ }
+ }
+ dn.parent=null;
+ return dn;
+ }
+
+ public Collection getAllChildren(){
+ if((this.children==null)||(this.children.size()==0))
+ return new ArrayList();
+
+ Vector v = new Vector(this.children);
+ Iterator list = this.children.iterator();
+ while (list.hasNext()) {
+ DeviceNode x = (DeviceNode) list.next();
+ Collection c = x.getAllChildren();
+ if(c==null) continue;
+ v.addAll(c);
+ }
+ return v;
+ }
+
+ public Collection getChildren(){
+ if((this.children==null)||(this.children.size()==0))
+ return new ArrayList();
+ return this.children;
+ }
+
+ /**
+ * @param name <code>String</code> that contain the UDN to look for
+ * @return return a <code>DeviceNode</code> that have the UDN equals to name and <br>
+ * if there is any <code>DeviceNode</code> with the proper UDN value return <code>null</code>
+ */
+ public DeviceNode search(String name){
+ if (name == null)
+ throw new IllegalArgumentException("null is not a valid arg in DeviceNode.search() method");
+ if (name.equals(udn))
+ return this;
+ else if (hasChild){
+ Iterator list = children.iterator();
+ while (list.hasNext()){
+ DeviceNode child = (DeviceNode)list.next();
+ DeviceNode node = child.search(name);
+ if (node != null) return node;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param udn
+ * @return <code>true</code> if and only if this <code>DeviceNode</code>
+ * contains a DeviceNode with UDN equals to passed argument or if
+ * its USN is equal to passed argument
+ */
+ public boolean contains(String udn){
+ return this.search(udn)!=null;
+ }
+
+ public boolean isComplete(){
+ /*
+ //Operation to let DeviceNode::isComplete() O(1)
+ return isComplete;
+ */
+ if (! hasChild) return true;
+ if (numberOfSons != children.size())return false;
+ Iterator list = children.iterator();
+ while (list.hasNext()){
+ DeviceNode child = (DeviceNode)list.next();
+ if (! child.isComplete()) return false;
+ }
+ return true;
+ }
+
+ public DeviceNode isAttachable(DeviceNode node){
+ if (node == null)
+ throw new IllegalArgumentException("null is not a valid arg in DeviceNode.isAttachable() method");
+ String parentUDN=(String) node.getReference().getProperty(UPnPDevice.PARENT_UDN);
+ if(parentUDN==null) return null;
+ return search(parentUDN);
+ }
+
+ public boolean isRoot(){
+ return isRootNode;
+ }
+
+ public boolean equals(String udn){
+ return this.udn.equals(udn);
+ }
+
+ public String toString(){
+ return udn;
+ }
+ public boolean isLeaf() {
+ return !hasChild;
+ }
+
+ public void print(){
+ System.out.println("####Device Node");
+ String[] props = sr.getPropertyKeys();
+ for (int i=0;i< props.length;i++){
+ Object prop= sr.getProperty(props[i]);
+ if (prop instanceof String[]){
+ System.out.println(props[i]+ "=");
+ String[] multiple = (String[])prop;
+ for (int j=0;j< multiple.length;j++){
+ System.out.println(multiple[j]+ ";");
+ }
+
+ }
+ else System.out.println(props[i]+ "="+ prop);
+ }
+ System.out.println("####Device Node");
+ }
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DeviceNodeListener.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DeviceNodeListener.java
index 0fa8702..a37a602 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DeviceNodeListener.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DeviceNodeListener.java
@@ -1,28 +1,28 @@
-/*
- * 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.tester.discovery;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public interface DeviceNodeListener {
- public void deviceDetected(DeviceNode d);
- public void rootDeviceUnplugged(String udn);
-}
+/*
+ * 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.tester.discovery;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public interface DeviceNodeListener {
+ public void deviceDetected(DeviceNode d);
+ public void rootDeviceUnplugged(String udn);
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DriverProxy.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DriverProxy.java
index 179cb5d..851ad8f 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DriverProxy.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/discovery/DriverProxy.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.tester.discovery;
-
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-
-import org.apache.felix.upnp.basedriver.controller.DevicesInfo;
-import org.apache.felix.upnp.basedriver.controller.DriverController;
-import org.apache.felix.upnp.tester.Activator;
-import org.apache.felix.upnp.tester.Mediator;
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class DriverProxy implements ServiceListener {
- private DevicesInfo devicesInfo;
- private DriverController drvController;
- public DriverProxy(){
- ServiceReference sr = Activator.context.getServiceReference(DevicesInfo.class.getName());
- if (sr != null){
- devicesInfo = (DevicesInfo)Activator.context.getService(sr);
- drvController = (DriverController) devicesInfo;
- Mediator.getControlPoint().enableMenus(true,getLogLevel(),getCyberDebug());
- Mediator.getTreeViewer().setPopupMenuEnabled(true);
- }
- String filter = "(" + Constants.OBJECTCLASS + "=" + DevicesInfo.class.getName() + ")" ;
- try {
- Activator.context.addServiceListener(this,filter);
- } catch (Exception ignored){};
- }
-
- public boolean isDriverAvailable(){
- return (drvController != null);
- }
-
- public String getDeviceDescriptionURI(String udn){
- if (devicesInfo != null)
- return devicesInfo.getLocationURL(udn);
- return "";
- }
-
- public String getServiceDescriptionURI(String udn,String serviceId){
- if (devicesInfo != null)
- return devicesInfo.getSCPDURL(udn,serviceId);
- return null;
- }
-
- public String resolveRelativeUrl(String udn,String link){
- if (devicesInfo != null)
- return devicesInfo.resolveRelativeUrl(udn,link);
- return null;
- }
-
- public boolean getCyberDebug(){
- if (drvController != null)
- return drvController.getCyberDebug();
- return false;
- }
- public void setCyberDebug(boolean b){
- if (drvController != null)
- drvController.setCyberDebug(b);
- }
- public int getLogLevel(){
- if (drvController != null)
- return drvController.getLogLevel();
- return 0;
- }
-
- public void setLogLevel(int value){
- if (drvController != null)
- drvController.setLogLevel(value);
- }
- public void doSearch(String target){
- if (drvController != null)
- drvController.search(target);
- }
-
-
- public void serviceChanged(ServiceEvent e) {
- switch(e.getType()){
- case ServiceEvent.REGISTERED:{
- Object service = Activator.context.getService(e.getServiceReference());
- if (service != null){
- devicesInfo = (DevicesInfo) service;
- drvController = (DriverController) devicesInfo;
- Mediator.getControlPoint().enableMenus(true,getLogLevel(),getCyberDebug());
- Mediator.getTreeViewer().setPopupMenuEnabled(true);
- }
- };break;
- case ServiceEvent.UNREGISTERING:{
- devicesInfo = null;
- drvController =null;
- Mediator.getControlPoint().enableMenus(false,0,false);
- Mediator.getTreeViewer().setPopupMenuEnabled(false);
- };break;
- }
- }
-
- public void close(){
- Activator.context.removeServiceListener(this);
- }
-
-
-}
+/*
+ * 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.tester.discovery;
+
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+
+import org.apache.felix.upnp.basedriver.controller.DevicesInfo;
+import org.apache.felix.upnp.basedriver.controller.DriverController;
+import org.apache.felix.upnp.tester.Activator;
+import org.apache.felix.upnp.tester.Mediator;
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class DriverProxy implements ServiceListener {
+ private DevicesInfo devicesInfo;
+ private DriverController drvController;
+ public DriverProxy(){
+ ServiceReference sr = Activator.context.getServiceReference(DevicesInfo.class.getName());
+ if (sr != null){
+ devicesInfo = (DevicesInfo)Activator.context.getService(sr);
+ drvController = (DriverController) devicesInfo;
+ Mediator.getControlPoint().enableMenus(true,getLogLevel(),getCyberDebug());
+ Mediator.getTreeViewer().setPopupMenuEnabled(true);
+ }
+ String filter = "(" + Constants.OBJECTCLASS + "=" + DevicesInfo.class.getName() + ")" ;
+ try {
+ Activator.context.addServiceListener(this,filter);
+ } catch (Exception ignored){};
+ }
+
+ public boolean isDriverAvailable(){
+ return (drvController != null);
+ }
+
+ public String getDeviceDescriptionURI(String udn){
+ if (devicesInfo != null)
+ return devicesInfo.getLocationURL(udn);
+ return "";
+ }
+
+ public String getServiceDescriptionURI(String udn,String serviceId){
+ if (devicesInfo != null)
+ return devicesInfo.getSCPDURL(udn,serviceId);
+ return null;
+ }
+
+ public String resolveRelativeUrl(String udn,String link){
+ if (devicesInfo != null)
+ return devicesInfo.resolveRelativeUrl(udn,link);
+ return null;
+ }
+
+ public boolean getCyberDebug(){
+ if (drvController != null)
+ return drvController.getCyberDebug();
+ return false;
+ }
+ public void setCyberDebug(boolean b){
+ if (drvController != null)
+ drvController.setCyberDebug(b);
+ }
+ public int getLogLevel(){
+ if (drvController != null)
+ return drvController.getLogLevel();
+ return 0;
+ }
+
+ public void setLogLevel(int value){
+ if (drvController != null)
+ drvController.setLogLevel(value);
+ }
+ public void doSearch(String target){
+ if (drvController != null)
+ drvController.search(target);
+ }
+
+
+ public void serviceChanged(ServiceEvent e) {
+ switch(e.getType()){
+ case ServiceEvent.REGISTERED:{
+ Object service = Activator.context.getService(e.getServiceReference());
+ if (service != null){
+ devicesInfo = (DevicesInfo) service;
+ drvController = (DriverController) devicesInfo;
+ Mediator.getControlPoint().enableMenus(true,getLogLevel(),getCyberDebug());
+ Mediator.getTreeViewer().setPopupMenuEnabled(true);
+ }
+ };break;
+ case ServiceEvent.UNREGISTERING:{
+ devicesInfo = null;
+ drvController =null;
+ Mediator.getControlPoint().enableMenus(false,0,false);
+ Mediator.getTreeViewer().setPopupMenuEnabled(false);
+ };break;
+ }
+ }
+
+ public void close(){
+ Activator.context.removeServiceListener(this);
+ }
+
+
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java
index d8654b4..3e5a744 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/ActionPanel.java
@@ -1,366 +1,366 @@
-/*
- * 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.tester.gui;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import javax.swing.AbstractAction;
-import javax.swing.AbstractCellEditor;
-import javax.swing.DefaultCellEditor;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSlider;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.SwingConstants;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.TableModelEvent;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableModel;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPException;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.basedriver.util.Converter;
-import org.apache.felix.upnp.tester.Mediator;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class ActionPanel extends JPanel {
-
- UPnPAction action;
- ArgumentsModel argsModel;
- MyTable table;
- JPanel buttonPanel;
-
- OutputArgumentsModel outArgsModel;
- JTable outTable;
-
- /**
- *
- */
- public ActionPanel() {
- super(new GridBagLayout());
- buildButtonPanel();
- buildTable();
- add(new JScrollPane(table),Util.setConstrains(0,0,1,1,100,100));
- add(new JScrollPane(outTable),Util.setConstrains(0,1,1,1,100,100));
- add(buttonPanel,Util.setConstrains(1,0,1,1,1,1));
- }
-
- private void buildButtonPanel(){
- buttonPanel = new JPanel();
- JButton doAction = new JButton("Do Action");
- doAction.addActionListener(new AbstractAction(){
- public void actionPerformed(ActionEvent e) {
- outArgsModel.clearData();
-
- Dictionary params = null;
- Dictionary result = null;
- if (argsModel.getRowCount()!= 0){
- if (table.isEditing()) table.getCellEditor().stopCellEditing();
- params = new Hashtable();
- for (int i =0;i<argsModel.getRowCount();i++){
- String name = (String) argsModel.getValueAt(i,0);
- String value = (String)argsModel.getValueAt(i,3);
- try {
- params.put(
- name,
- Converter.parseString(
- value,
- action.getStateVariable(name).getUPnPDataType()));
- } catch (Exception ex) {
- LogPanel.log("Error invoking action (bad parameter)");
- return ;
- }
- }
- }
- try {result = action.invoke(params);}
- catch (UPnPException ex){
- String error =
- "===== Action Failed =====" +
- "\nUPnP Error Code::\n " +ex.getUPnPError_Code() +
- "\nUPnP Error Description::\n " +ex.getMessage();
- printReport(params,error);
- JOptionPane.showMessageDialog(
- Mediator.getPropertiesViewer(),error);
- }
- catch (Exception ex){
- printReport(params,ex.getMessage());
- JOptionPane.showMessageDialog(
- Mediator.getPropertiesViewer(),
- ex.getMessage()
- );
- }
- if (result != null) {
- printReport(params,result);
- outArgsModel.setData(action,result);
- JOptionPane.showMessageDialog(
- Mediator.getPropertiesViewer(),
- "Action invoked!"
- );
-
- }
- }
- private void printReport(Dictionary params,Object result) {
- String input = "";
- String output = "";
- if (params != null) input = params.toString();
- if (output != null) output = result.toString();
- String method = action.getName();
- String report = "\n==== Action:: " + method + " ====\n"
- + input
- + "\n----------- result ----------\n"
- + output
- + "\n-----------------------------";
- LogPanel.log(report);
- }
- });
- buttonPanel.add(doAction);
- }
-
- private void buildTable(){
- argsModel = new ArgumentsModel();
- table = new MyTable(argsModel);
- argsModel.setTable(table);
-
- outArgsModel = new OutputArgumentsModel();
- outTable = new JTable(outArgsModel);
- }
-
- public void setArguments(UPnPAction action){
- this.action = action;
- argsModel.setData(action);
- outArgsModel.clearData();
- }
-
-}
-
-//thanks to Thomas Wagner 18/10/2005
-class OutputArgumentsModel extends ArgumentsModel {
-
- public OutputArgumentsModel() {
- super();
- header = new String[]{"output arg name","related Var","Java \\ UpnP type","value"};
- }
-
- public void clearData() {
- names = new String[]{""};
- related = new String[]{""};
- types = new String[]{""};
- values = new String[]{""};
- size=0;
- this.fireTableChanged(new TableModelEvent(this));
- }
-
- public void setData(UPnPAction action, Object result){
-
- Hashtable res = (Hashtable) result;
-
- String[] names = action.getOutputArgumentNames();
- size = 0;
- this.names = names;
- if (names!=null){
- values = new String[names.length];
- types = new String[names.length];
- related = new String[names.length];
- for (int i=0;i<names.length;i++) {
- UPnPStateVariable currentStateVar = action.getStateVariable(names[i]);
-
- Object value = res.get(names[i]);
- values[i]=value.toString();
- related[i] = currentStateVar.getName();
-
- String javaType =currentStateVar.getJavaDataType().toString();
- javaType = javaType.substring(javaType.lastIndexOf('.')+1);
- String upnpType = currentStateVar.getUPnPDataType();
- types[i] = javaType + " \\ " + upnpType;
- }
- size = names.length;
- }
- this.fireTableChanged(new TableModelEvent(this));
- }
-}
-
-//thanks to Thomas Wagner 12/10/2005
-class ArgumentsModel extends AbstractTableModel {
- int size = 0;
- private MyTable table;
- String[] names = new String[]{""};
- String[] related = new String[]{""};
- String[] types = new String[]{""};
- String[] values = new String[]{""};
- String[] header = new String[]{"arg name","related Var","Java \\ UpnP type","value"};
-
- public void setTable(MyTable table) {
- this.table = table;
- }
-
- public int getColumnCount() { return 4; }
- public int getRowCount() { return size;}
- public String getColumnName(int col) { return header[col]; }
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return (columnIndex ==3);
- }
- public Object getValueAt(int row, int col) {
- if (col == 0) return names[row];
- else if (col == 1) return related[row];
- else if (col == 2) return types[row];
- else if (col == 3) return values[row];
- return null;
- }
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- values[rowIndex]= (String) aValue;
- }
-
- public void setData(UPnPAction action){
-
- table.deleteMyCellEditors();
-
-
- String[] names = action.getInputArgumentNames();
- size = 0;
- this.names = names;
- if (names!=null){
- values = new String[names.length];
- related = new String[names.length];
- types = new String[names.length];
- for (int i=0;i<names.length;i++) {
- values[i]="";
- UPnPStateVariable currentStateVar = action.getStateVariable(names[i]);
- related[i] = currentStateVar.getName();
- String javaType = currentStateVar.getJavaDataType().toString();
- javaType = javaType.substring(javaType.lastIndexOf('.')+1);
- String upnpType = currentStateVar.getUPnPDataType();
- types[i] = javaType + " \\ " + upnpType;
-
- //handle allowed value list
- if ( currentStateVar.getAllowedValues() != null) {
- String av[] = currentStateVar.getAllowedValues();
- JComboBox comboBox = new JComboBox();
- for (int j = 0; j < av.length; j++) {
- comboBox.addItem(av[j]);
- }
- values[i] = av[0]; //preset the first value from list
- table.setMyCellEditor(new DefaultCellEditor(comboBox),i);
- }
-
- //handle default value
- if (currentStateVar.getDefaultValue() != null) {
- String val = currentStateVar.getDefaultValue().toString();
- if(val.length() > 0)
- values[i] = val;
- }
-
- //handle range values
- if ((currentStateVar.getMaximum()!= null)
- &&(currentStateVar.getMinimum()!= null)){
- int max = currentStateVar.getMaximum().intValue();
- int min = currentStateVar.getMinimum().intValue();
- int value = min;
- try { value = Integer.parseInt(values[i]);}
- catch (NumberFormatException ignored){}
- table.setMyCellEditor(new SliderEditor(min,max,value),i);
- }
-
- }
- size = names.length;
- }
- this.fireTableChanged(new TableModelEvent(this));
- this.fireTableStructureChanged();
- }
-}
-
-// thanks to Thomas Wagner 12/10/2005
-class MyTable extends JTable {
-
- private Hashtable cellEditors;
-
- public MyTable(TableModel dm) {
- super(dm);
- cellEditors = new Hashtable();
- }
-
- public void setMyCellEditor(TableCellEditor editor,int col){
- cellEditors.put(new Integer(col),editor);
- }
-
- public void deleteMyCellEditors(){
- cellEditors.clear();
- }
-
- //overwritten JTable method
- public TableCellEditor getCellEditor(int row,int col) {
- TableCellEditor tce = (TableCellEditor) cellEditors.get(new Integer(row));
- if( tce != null) {
- return tce;
- } else {
- return super.getCellEditor(row,col);
- }
- }
-}
-
-class SliderEditor extends AbstractCellEditor implements TableCellEditor
-{
- JPanel editor;
- JTextField text;
- JSlider slider;
- public SliderEditor(int min, int max, int value){
- editor = new JPanel(new BorderLayout());
- //editor.setBorder(new EmptyBorder(1,0,1,0));
- text = new JTextField(Integer.toString(max).length());
- slider = new JSlider(SwingConstants.HORIZONTAL,min,max,value);
- editor.add(text,BorderLayout.WEST);
- editor.add(slider);
- slider.addChangeListener(new ChangeListener(){
- public void stateChanged(ChangeEvent e) {
- //if (! replSlider.getValueIsAdjusting()){
- text.setText(new Integer(slider.getValue()).toString());
- //}
- }
- });
-
- }
-
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- text.setText((String) value);
- try {
- slider.setValue(Integer.parseInt((String)value));
- } catch (NumberFormatException ignored) {}
- return editor;
- }
-
- public Object getCellEditorValue() {
- return text.getText();
- }
-}
-
+/*
+ * 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.tester.gui;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import javax.swing.AbstractAction;
+import javax.swing.AbstractCellEditor;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSlider;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableModel;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPException;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.basedriver.util.Converter;
+import org.apache.felix.upnp.tester.Mediator;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class ActionPanel extends JPanel {
+
+ UPnPAction action;
+ ArgumentsModel argsModel;
+ MyTable table;
+ JPanel buttonPanel;
+
+ OutputArgumentsModel outArgsModel;
+ JTable outTable;
+
+ /**
+ *
+ */
+ public ActionPanel() {
+ super(new GridBagLayout());
+ buildButtonPanel();
+ buildTable();
+ add(new JScrollPane(table),Util.setConstrains(0,0,1,1,100,100));
+ add(new JScrollPane(outTable),Util.setConstrains(0,1,1,1,100,100));
+ add(buttonPanel,Util.setConstrains(1,0,1,1,1,1));
+ }
+
+ private void buildButtonPanel(){
+ buttonPanel = new JPanel();
+ JButton doAction = new JButton("Do Action");
+ doAction.addActionListener(new AbstractAction(){
+ public void actionPerformed(ActionEvent e) {
+ outArgsModel.clearData();
+
+ Dictionary params = null;
+ Dictionary result = null;
+ if (argsModel.getRowCount()!= 0){
+ if (table.isEditing()) table.getCellEditor().stopCellEditing();
+ params = new Hashtable();
+ for (int i =0;i<argsModel.getRowCount();i++){
+ String name = (String) argsModel.getValueAt(i,0);
+ String value = (String)argsModel.getValueAt(i,3);
+ try {
+ params.put(
+ name,
+ Converter.parseString(
+ value,
+ action.getStateVariable(name).getUPnPDataType()));
+ } catch (Exception ex) {
+ LogPanel.log("Error invoking action (bad parameter)");
+ return ;
+ }
+ }
+ }
+ try {result = action.invoke(params);}
+ catch (UPnPException ex){
+ String error =
+ "===== Action Failed =====" +
+ "\nUPnP Error Code::\n " +ex.getUPnPError_Code() +
+ "\nUPnP Error Description::\n " +ex.getMessage();
+ printReport(params,error);
+ JOptionPane.showMessageDialog(
+ Mediator.getPropertiesViewer(),error);
+ }
+ catch (Exception ex){
+ printReport(params,ex.getMessage());
+ JOptionPane.showMessageDialog(
+ Mediator.getPropertiesViewer(),
+ ex.getMessage()
+ );
+ }
+ if (result != null) {
+ printReport(params,result);
+ outArgsModel.setData(action,result);
+ JOptionPane.showMessageDialog(
+ Mediator.getPropertiesViewer(),
+ "Action invoked!"
+ );
+
+ }
+ }
+ private void printReport(Dictionary params,Object result) {
+ String input = "";
+ String output = "";
+ if (params != null) input = params.toString();
+ if (output != null) output = result.toString();
+ String method = action.getName();
+ String report = "\n==== Action:: " + method + " ====\n"
+ + input
+ + "\n----------- result ----------\n"
+ + output
+ + "\n-----------------------------";
+ LogPanel.log(report);
+ }
+ });
+ buttonPanel.add(doAction);
+ }
+
+ private void buildTable(){
+ argsModel = new ArgumentsModel();
+ table = new MyTable(argsModel);
+ argsModel.setTable(table);
+
+ outArgsModel = new OutputArgumentsModel();
+ outTable = new JTable(outArgsModel);
+ }
+
+ public void setArguments(UPnPAction action){
+ this.action = action;
+ argsModel.setData(action);
+ outArgsModel.clearData();
+ }
+
+}
+
+//thanks to Thomas Wagner 18/10/2005
+class OutputArgumentsModel extends ArgumentsModel {
+
+ public OutputArgumentsModel() {
+ super();
+ header = new String[]{"output arg name","related Var","Java \\ UpnP type","value"};
+ }
+
+ public void clearData() {
+ names = new String[]{""};
+ related = new String[]{""};
+ types = new String[]{""};
+ values = new String[]{""};
+ size=0;
+ this.fireTableChanged(new TableModelEvent(this));
+ }
+
+ public void setData(UPnPAction action, Object result){
+
+ Hashtable res = (Hashtable) result;
+
+ String[] names = action.getOutputArgumentNames();
+ size = 0;
+ this.names = names;
+ if (names!=null){
+ values = new String[names.length];
+ types = new String[names.length];
+ related = new String[names.length];
+ for (int i=0;i<names.length;i++) {
+ UPnPStateVariable currentStateVar = action.getStateVariable(names[i]);
+
+ Object value = res.get(names[i]);
+ values[i]=value.toString();
+ related[i] = currentStateVar.getName();
+
+ String javaType =currentStateVar.getJavaDataType().toString();
+ javaType = javaType.substring(javaType.lastIndexOf('.')+1);
+ String upnpType = currentStateVar.getUPnPDataType();
+ types[i] = javaType + " \\ " + upnpType;
+ }
+ size = names.length;
+ }
+ this.fireTableChanged(new TableModelEvent(this));
+ }
+}
+
+//thanks to Thomas Wagner 12/10/2005
+class ArgumentsModel extends AbstractTableModel {
+ int size = 0;
+ private MyTable table;
+ String[] names = new String[]{""};
+ String[] related = new String[]{""};
+ String[] types = new String[]{""};
+ String[] values = new String[]{""};
+ String[] header = new String[]{"arg name","related Var","Java \\ UpnP type","value"};
+
+ public void setTable(MyTable table) {
+ this.table = table;
+ }
+
+ public int getColumnCount() { return 4; }
+ public int getRowCount() { return size;}
+ public String getColumnName(int col) { return header[col]; }
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return (columnIndex ==3);
+ }
+ public Object getValueAt(int row, int col) {
+ if (col == 0) return names[row];
+ else if (col == 1) return related[row];
+ else if (col == 2) return types[row];
+ else if (col == 3) return values[row];
+ return null;
+ }
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ values[rowIndex]= (String) aValue;
+ }
+
+ public void setData(UPnPAction action){
+
+ table.deleteMyCellEditors();
+
+
+ String[] names = action.getInputArgumentNames();
+ size = 0;
+ this.names = names;
+ if (names!=null){
+ values = new String[names.length];
+ related = new String[names.length];
+ types = new String[names.length];
+ for (int i=0;i<names.length;i++) {
+ values[i]="";
+ UPnPStateVariable currentStateVar = action.getStateVariable(names[i]);
+ related[i] = currentStateVar.getName();
+ String javaType = currentStateVar.getJavaDataType().toString();
+ javaType = javaType.substring(javaType.lastIndexOf('.')+1);
+ String upnpType = currentStateVar.getUPnPDataType();
+ types[i] = javaType + " \\ " + upnpType;
+
+ //handle allowed value list
+ if ( currentStateVar.getAllowedValues() != null) {
+ String av[] = currentStateVar.getAllowedValues();
+ JComboBox comboBox = new JComboBox();
+ for (int j = 0; j < av.length; j++) {
+ comboBox.addItem(av[j]);
+ }
+ values[i] = av[0]; //preset the first value from list
+ table.setMyCellEditor(new DefaultCellEditor(comboBox),i);
+ }
+
+ //handle default value
+ if (currentStateVar.getDefaultValue() != null) {
+ String val = currentStateVar.getDefaultValue().toString();
+ if(val.length() > 0)
+ values[i] = val;
+ }
+
+ //handle range values
+ if ((currentStateVar.getMaximum()!= null)
+ &&(currentStateVar.getMinimum()!= null)){
+ int max = currentStateVar.getMaximum().intValue();
+ int min = currentStateVar.getMinimum().intValue();
+ int value = min;
+ try { value = Integer.parseInt(values[i]);}
+ catch (NumberFormatException ignored){}
+ table.setMyCellEditor(new SliderEditor(min,max,value),i);
+ }
+
+ }
+ size = names.length;
+ }
+ this.fireTableChanged(new TableModelEvent(this));
+ this.fireTableStructureChanged();
+ }
+}
+
+// thanks to Thomas Wagner 12/10/2005
+class MyTable extends JTable {
+
+ private Hashtable cellEditors;
+
+ public MyTable(TableModel dm) {
+ super(dm);
+ cellEditors = new Hashtable();
+ }
+
+ public void setMyCellEditor(TableCellEditor editor,int col){
+ cellEditors.put(new Integer(col),editor);
+ }
+
+ public void deleteMyCellEditors(){
+ cellEditors.clear();
+ }
+
+ //overwritten JTable method
+ public TableCellEditor getCellEditor(int row,int col) {
+ TableCellEditor tce = (TableCellEditor) cellEditors.get(new Integer(row));
+ if( tce != null) {
+ return tce;
+ } else {
+ return super.getCellEditor(row,col);
+ }
+ }
+}
+
+class SliderEditor extends AbstractCellEditor implements TableCellEditor
+{
+ JPanel editor;
+ JTextField text;
+ JSlider slider;
+ public SliderEditor(int min, int max, int value){
+ editor = new JPanel(new BorderLayout());
+ //editor.setBorder(new EmptyBorder(1,0,1,0));
+ text = new JTextField(Integer.toString(max).length());
+ slider = new JSlider(SwingConstants.HORIZONTAL,min,max,value);
+ editor.add(text,BorderLayout.WEST);
+ editor.add(slider);
+ slider.addChangeListener(new ChangeListener(){
+ public void stateChanged(ChangeEvent e) {
+ //if (! replSlider.getValueIsAdjusting()){
+ text.setText(new Integer(slider.getValue()).toString());
+ //}
+ }
+ });
+
+ }
+
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ text.setText((String) value);
+ try {
+ slider.setValue(Integer.parseInt((String)value));
+ } catch (NumberFormatException ignored) {}
+ return editor;
+ }
+
+ public Object getCellEditorValue() {
+ return text.getText();
+ }
+}
+
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java
index 5fe322d..c9def89 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/LogPanel.java
@@ -1,74 +1,74 @@
-/*
- * 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.tester.gui;
-
-import java.awt.BorderLayout;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollBar;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class LogPanel extends JPanel {
- private static JTextArea logArea = new JTextArea(4,50);
- private static JPanel statusBar = new JPanel(new BorderLayout());
- private static JLabel statusText = new JLabel();
-
- private static JScrollPane scroll = new JScrollPane(logArea);
-
- public LogPanel() {
- super(new BorderLayout());
- logArea.setText("");
- //add(new JScrollPane(new JTextArea(4,80)));
- add(scroll);
- statusBar.add(statusText,BorderLayout.EAST);
- add(statusBar,BorderLayout.SOUTH);
- }
-
- /* public static void log(String msg) {
- logArea.append(msg + "\n\r");
- JScrollBar scrBar = scroll.getVerticalScrollBar();
- int maxPos = scrBar.getMaximum();
- scrBar.setValue(maxPos);
- }*/
-
- public static void log(final String msg){
- synchronized (logArea) {
- logArea.append(msg );
- logArea.append("\n\r");
- }
- JScrollBar scrBar = scroll.getVerticalScrollBar();
- int maxPos = scrBar.getMaximum();
- scrBar.setValue(maxPos);
- }
-
- public static void status(final String msg){
- statusText.setText(msg);
- }
-
- public static void clear(String msg) {
- logArea.setText("");
- }
-
-}
+/*
+ * 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.tester.gui;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollBar;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class LogPanel extends JPanel {
+ private static JTextArea logArea = new JTextArea(4,50);
+ private static JPanel statusBar = new JPanel(new BorderLayout());
+ private static JLabel statusText = new JLabel();
+
+ private static JScrollPane scroll = new JScrollPane(logArea);
+
+ public LogPanel() {
+ super(new BorderLayout());
+ logArea.setText("");
+ //add(new JScrollPane(new JTextArea(4,80)));
+ add(scroll);
+ statusBar.add(statusText,BorderLayout.EAST);
+ add(statusBar,BorderLayout.SOUTH);
+ }
+
+ /* public static void log(String msg) {
+ logArea.append(msg + "\n\r");
+ JScrollBar scrBar = scroll.getVerticalScrollBar();
+ int maxPos = scrBar.getMaximum();
+ scrBar.setValue(maxPos);
+ }*/
+
+ public static void log(final String msg){
+ synchronized (logArea) {
+ logArea.append(msg );
+ logArea.append("\n\r");
+ }
+ JScrollBar scrBar = scroll.getVerticalScrollBar();
+ int maxPos = scrBar.getMaximum();
+ scrBar.setValue(maxPos);
+ }
+
+ public static void status(final String msg){
+ statusText.setText(msg);
+ }
+
+ public static void clear(String msg) {
+ logArea.setText("");
+ }
+
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java
index fa9ea4f..ae08dff 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/PropertiesViewer.java
@@ -1,223 +1,223 @@
-/*
- * 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.tester.gui;
-
-
-
-import java.awt.Component;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.GridBagLayout;
-import java.awt.Point;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseMotionListener;
-
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTree;
-import javax.swing.event.TableModelEvent;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.DefaultTableCellRenderer;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPDevice;
-
-import org.apache.felix.upnp.tester.Mediator;
-import org.apache.felix.upnp.tester.discovery.DeviceNode;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class PropertiesViewer extends JPanel {
-
- ActionPanel actionsPanel;
- SubscriptionPanel subscriptionPanel;
- DataModel dataModel;
- JTable table;
-
- public PropertiesViewer(){
- super(new GridBagLayout());
- buildTable();
- actionsPanel = new ActionPanel();
- subscriptionPanel = new SubscriptionPanel();
-
- JScrollPane scroll = new JScrollPane(table);
- scroll.setPreferredSize(new Dimension(500,200));
- //actionsPanel.setPreferredSize(new Dimension(500,100)); twa
- actionsPanel.setPreferredSize(new Dimension(500,200));
- add(scroll,Util.setConstrains(0,0,6,2,100,50));
- add(actionsPanel,Util.setConstrains(0,2,6,1,100,20));
- add(subscriptionPanel,Util.setConstrains(0,3,6,1,100,5));
- showActionPanel(false);
- showSubscriptionPanel(false);
-
- table.addMouseMotionListener(new MouseMotionListener(){
- private final Cursor handCursor = new Cursor(Cursor.HAND_CURSOR);
-
- public void mouseDragged(MouseEvent e) {}
- public void mouseMoved(MouseEvent e) {
- String link = getDataLink(e.getPoint());
- if (link != null)
- table.setCursor(handCursor);
- else
- table.setCursor(Cursor.getDefaultCursor());
- }
-
- });
-
- table.addMouseListener(new MouseAdapter(){
- public void mouseClicked(MouseEvent e){
- String link = getDataLink(e.getPoint());
- if (link != null)
- Util.openUrl(link);
- }
- });
-
- }
-
- public String getDataLink(Point p) {
- int col = table.columnAtPoint(p);
- if (col != 1)
- return null;
- else {
- int row = table.rowAtPoint(p);
- String data = (String) dataModel.getValueAt(row,col);
- if (data == null) return null;
- if (data.length()<4) return null;
- String begin = data.substring(0,4);
- if (begin.equalsIgnoreCase("http"))
- return data;
- else {
- String propertyName= (String) dataModel.getValueAt(row,0);
- if (propertyName.equalsIgnoreCase(UPnPDevice.PRESENTATION_URL)
- ||propertyName.equalsIgnoreCase(UPnPDevice.MANUFACTURER_URL)
- ||propertyName.equalsIgnoreCase(UPnPDevice.MODEL_URL) )
- {
- JTree tree = Mediator.getUPnPDeviceTree();
- UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
- String url = "";
- if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)){
- UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
- while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
- parent = (UPnPDeviceTreeNode)parent.getParent();
- DeviceNode device = (DeviceNode) parent.getUserObject();
- String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
- url = Mediator.getDriverProxy().resolveRelativeUrl(udn,data);
- return url;
- }
- else if (selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE))
- {
- DeviceNode node = (DeviceNode) selectedNode.getUserObject();
- String udn = (String)node.getReference().getProperty(UPnPDevice.UDN);
- url = Mediator.getDriverProxy().resolveRelativeUrl(udn,data);
- return url;
- }
- }
- return null;
- }
- }
- }
-
- public void setProperties(String[]name,String[]values){
- dataModel.setData(name,values);
- }
-
- public void setAction(UPnPAction action){
- actionsPanel.setArguments(action);
-
- }
-
- public void showActionPanel(boolean show){
- actionsPanel.setVisible(show);
- }
-
- public void showSubscriptionPanel(boolean show){
- subscriptionPanel.setVisible(show);
- }
-
- private void buildTable(){
- dataModel = new DataModel();
- table = new JTable(dataModel);
- table.setDefaultRenderer(table.getColumnClass(1), new LinkCellRenderer());
- }
-
-
-}
-
-class DataModel extends AbstractTableModel {
- int size = 0;
- String[] names = new String[]{""};
- String[] values = new String[]{""};
- String[] header = new String[]{"property key","value"};
-
- public String getColumnName(int col) { return header[col]; }
- public int getColumnCount() { return 2; }
- public int getRowCount() { return size;}
- public Object getValueAt(int row, int col) {
- if (col==0) return names[row];
- else return values[row];
- }
-
- /*
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return false;
- }
- */
-
- public void setData(String[]names,String[]values){
- this.names=names;
- this.values=values;
- size = names.length;
- this.fireTableChanged(new TableModelEvent(this));
- }
-
-}
-
-class LinkCellRenderer extends DefaultTableCellRenderer
-{
- public LinkCellRenderer(){
- super();
- }
-
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
- super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
- if (column==1){
- String propertyName = (String)table.getModel().getValueAt(row,0);
- if (propertyName.equalsIgnoreCase(UPnPDevice.PRESENTATION_URL)
- ||propertyName.equalsIgnoreCase(UPnPDevice.MODEL_URL)
- ||propertyName.equalsIgnoreCase(UPnPDevice.MANUFACTURER_URL))
- {
- if (!value.equals(""))
- setValue("<html><a href=''>"+value+"</a></html>");
- return this;
- }
- if (((String) value).length()<4) return this;
- String begin = ((String) value).substring(0,4);
- if (begin.equalsIgnoreCase("http"))
- setValue("<html><a href=''>"+value+"</a></html>");
- }
- return this;
- }
-
-}
-
+/*
+ * 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.tester.gui;
+
+
+
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.GridBagLayout;
+import java.awt.Point;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionListener;
+
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTree;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.DefaultTableCellRenderer;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPDevice;
+
+import org.apache.felix.upnp.tester.Mediator;
+import org.apache.felix.upnp.tester.discovery.DeviceNode;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class PropertiesViewer extends JPanel {
+
+ ActionPanel actionsPanel;
+ SubscriptionPanel subscriptionPanel;
+ DataModel dataModel;
+ JTable table;
+
+ public PropertiesViewer(){
+ super(new GridBagLayout());
+ buildTable();
+ actionsPanel = new ActionPanel();
+ subscriptionPanel = new SubscriptionPanel();
+
+ JScrollPane scroll = new JScrollPane(table);
+ scroll.setPreferredSize(new Dimension(500,200));
+ //actionsPanel.setPreferredSize(new Dimension(500,100)); twa
+ actionsPanel.setPreferredSize(new Dimension(500,200));
+ add(scroll,Util.setConstrains(0,0,6,2,100,50));
+ add(actionsPanel,Util.setConstrains(0,2,6,1,100,20));
+ add(subscriptionPanel,Util.setConstrains(0,3,6,1,100,5));
+ showActionPanel(false);
+ showSubscriptionPanel(false);
+
+ table.addMouseMotionListener(new MouseMotionListener(){
+ private final Cursor handCursor = new Cursor(Cursor.HAND_CURSOR);
+
+ public void mouseDragged(MouseEvent e) {}
+ public void mouseMoved(MouseEvent e) {
+ String link = getDataLink(e.getPoint());
+ if (link != null)
+ table.setCursor(handCursor);
+ else
+ table.setCursor(Cursor.getDefaultCursor());
+ }
+
+ });
+
+ table.addMouseListener(new MouseAdapter(){
+ public void mouseClicked(MouseEvent e){
+ String link = getDataLink(e.getPoint());
+ if (link != null)
+ Util.openUrl(link);
+ }
+ });
+
+ }
+
+ public String getDataLink(Point p) {
+ int col = table.columnAtPoint(p);
+ if (col != 1)
+ return null;
+ else {
+ int row = table.rowAtPoint(p);
+ String data = (String) dataModel.getValueAt(row,col);
+ if (data == null) return null;
+ if (data.length()<4) return null;
+ String begin = data.substring(0,4);
+ if (begin.equalsIgnoreCase("http"))
+ return data;
+ else {
+ String propertyName= (String) dataModel.getValueAt(row,0);
+ if (propertyName.equalsIgnoreCase(UPnPDevice.PRESENTATION_URL)
+ ||propertyName.equalsIgnoreCase(UPnPDevice.MANUFACTURER_URL)
+ ||propertyName.equalsIgnoreCase(UPnPDevice.MODEL_URL) )
+ {
+ JTree tree = Mediator.getUPnPDeviceTree();
+ UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
+ String url = "";
+ if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)){
+ UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
+ while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
+ parent = (UPnPDeviceTreeNode)parent.getParent();
+ DeviceNode device = (DeviceNode) parent.getUserObject();
+ String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
+ url = Mediator.getDriverProxy().resolveRelativeUrl(udn,data);
+ return url;
+ }
+ else if (selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE))
+ {
+ DeviceNode node = (DeviceNode) selectedNode.getUserObject();
+ String udn = (String)node.getReference().getProperty(UPnPDevice.UDN);
+ url = Mediator.getDriverProxy().resolveRelativeUrl(udn,data);
+ return url;
+ }
+ }
+ return null;
+ }
+ }
+ }
+
+ public void setProperties(String[]name,String[]values){
+ dataModel.setData(name,values);
+ }
+
+ public void setAction(UPnPAction action){
+ actionsPanel.setArguments(action);
+
+ }
+
+ public void showActionPanel(boolean show){
+ actionsPanel.setVisible(show);
+ }
+
+ public void showSubscriptionPanel(boolean show){
+ subscriptionPanel.setVisible(show);
+ }
+
+ private void buildTable(){
+ dataModel = new DataModel();
+ table = new JTable(dataModel);
+ table.setDefaultRenderer(table.getColumnClass(1), new LinkCellRenderer());
+ }
+
+
+}
+
+class DataModel extends AbstractTableModel {
+ int size = 0;
+ String[] names = new String[]{""};
+ String[] values = new String[]{""};
+ String[] header = new String[]{"property key","value"};
+
+ public String getColumnName(int col) { return header[col]; }
+ public int getColumnCount() { return 2; }
+ public int getRowCount() { return size;}
+ public Object getValueAt(int row, int col) {
+ if (col==0) return names[row];
+ else return values[row];
+ }
+
+ /*
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return false;
+ }
+ */
+
+ public void setData(String[]names,String[]values){
+ this.names=names;
+ this.values=values;
+ size = names.length;
+ this.fireTableChanged(new TableModelEvent(this));
+ }
+
+}
+
+class LinkCellRenderer extends DefaultTableCellRenderer
+{
+ public LinkCellRenderer(){
+ super();
+ }
+
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected, boolean hasFocus, int row, int column) {
+ super.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
+ if (column==1){
+ String propertyName = (String)table.getModel().getValueAt(row,0);
+ if (propertyName.equalsIgnoreCase(UPnPDevice.PRESENTATION_URL)
+ ||propertyName.equalsIgnoreCase(UPnPDevice.MODEL_URL)
+ ||propertyName.equalsIgnoreCase(UPnPDevice.MANUFACTURER_URL))
+ {
+ if (!value.equals(""))
+ setValue("<html><a href=''>"+value+"</a></html>");
+ return this;
+ }
+ if (((String) value).length()<4) return this;
+ String begin = ((String) value).substring(0,4);
+ if (begin.equalsIgnoreCase("http"))
+ setValue("<html><a href=''>"+value+"</a></html>");
+ }
+ return this;
+ }
+
+}
+
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java
index 410b7c4..847a400 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/SubscriptionPanel.java
@@ -1,155 +1,155 @@
-/*
- * 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.tester.gui;
-
-
-
-import java.awt.event.ActionEvent;
-import java.util.Dictionary;
-import java.util.Enumeration;
-
-import javax.swing.AbstractAction;
-import javax.swing.JButton;
-import javax.swing.JPanel;
-import javax.swing.JTree;
-import javax.swing.SwingUtilities;
-
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPEventListener;
-import org.osgi.service.upnp.UPnPService;
-
-import org.apache.felix.upnp.tester.Activator;
-import org.apache.felix.upnp.tester.Mediator;
-import org.apache.felix.upnp.tester.UPnPSubscriber;
-import org.apache.felix.upnp.tester.discovery.DeviceNode;
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class SubscriptionPanel extends JPanel implements UPnPEventListener{
- public SubscriptionPanel() {
- super();
- buildButtonPanel();
- }
-
- private void buildButtonPanel(){
- JButton subscribeBtn = new JButton("Subscribe");
- subscribeBtn.addActionListener(new AbstractAction(){
- public void actionPerformed(ActionEvent e) {
- //System.out.println("subscribing ...");
- doSubscribe();
- }
- });
- JButton unsubscribeBtn = new JButton("Unsubscribe");
- unsubscribeBtn.addActionListener(new AbstractAction(){
- public void actionPerformed(ActionEvent e) {
- //System.out.println("unsubscribing ...");
- doUnsubscribe();
- }
- });
- add(subscribeBtn);
- add(unsubscribeBtn);
- }
-
- UPnPSubscriber subscriber;
- public void doSubscribe()
- {
- if (subscriber == null)
- subscriber = new UPnPSubscriber(Activator.context,this);
-
- UPnPDeviceTreeNode selectedNode = getSelectedNode();
- String serviceId = getServiceId(selectedNode);
- String parentId = getDeviceId(selectedNode);
- LogPanel.log("subscribing ... "+ "ServiceId ["+serviceId+"] of DeviceId ["+parentId +"]");
- subscriber.subscribe(parentId,serviceId);
- setSubscribedVariableOf(selectedNode);
- }
-
- public void doUnsubscribe(){
- UPnPDeviceTreeNode selectedNode = getSelectedNode();
- String serviceId = getServiceId(selectedNode);
- String parentId = getDeviceId(selectedNode);
- LogPanel.log("unsubscribing ... "+ "ServiceId ["+serviceId+"] of DeviceId ["+parentId +"]");
- subscriber.unsubscribe(parentId,serviceId);
- setUnubscribedVariableOf(selectedNode);
- }
-
- public void notifyUPnPEvent(final String deviceId, final String serviceId, final Dictionary events) {
- // UPnP base driver notify are synchronous !!
- Runnable doShowMsg = new Runnable() {
- public void run() {
- LogPanel.log("notifyUPnPEvent::[DeviceID "+deviceId+"][ServiceId "+serviceId+"]");
- Enumeration elements = events.keys();
- while (elements.hasMoreElements()){
- Object key = elements.nextElement();
- Object value = events.get(key);
- LogPanel.log("["+key+"][value "+value+"]");
- }
- }
- };
- SwingUtilities.invokeLater(doShowMsg);
-
- }
-
- private void setSubscribedVariableOf(UPnPDeviceTreeNode selectedNode){
- Enumeration list = selectedNode.children();
- while (list.hasMoreElements()){
- UPnPDeviceTreeNode node = (UPnPDeviceTreeNode) list.nextElement();
- if (node.category == UPnPDeviceTreeNode.EVENTED_STATE)
- node.category = UPnPDeviceTreeNode.SUBSCRIBED_STATE;
- }
- JTree tree = Mediator.getUPnPDeviceTree();
- tree.validate();
- tree.repaint();
- }
-
- private void setUnubscribedVariableOf(UPnPDeviceTreeNode selectedNode){
- Enumeration list = selectedNode.children();
- while (list.hasMoreElements()){
- UPnPDeviceTreeNode node = (UPnPDeviceTreeNode) list.nextElement();
- if (node.category == UPnPDeviceTreeNode.SUBSCRIBED_STATE)
- node.category = UPnPDeviceTreeNode.EVENTED_STATE;
- }
- JTree tree = Mediator.getUPnPDeviceTree();
- tree.validate();
- tree.repaint();
- }
-
- private UPnPDeviceTreeNode getSelectedNode(){
- JTree tree = Mediator.getUPnPDeviceTree();
- UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
- return selectedNode;
- }
- private String getServiceId (UPnPDeviceTreeNode selectedNode){
- Object userObj = selectedNode.getUserObject();
- String serviceId = ((UPnPService) userObj).getId();
- return serviceId;
- }
- private String getDeviceId (UPnPDeviceTreeNode selectedNode){
- UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
- DeviceNode node =(DeviceNode)parent.getUserObject();
- String parentId = (String) node.getReference().getProperty(UPnPDevice.ID);
- return parentId;
- }
-
-
-
-}
-
-
+/*
+ * 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.tester.gui;
+
+
+
+import java.awt.event.ActionEvent;
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPEventListener;
+import org.osgi.service.upnp.UPnPService;
+
+import org.apache.felix.upnp.tester.Activator;
+import org.apache.felix.upnp.tester.Mediator;
+import org.apache.felix.upnp.tester.UPnPSubscriber;
+import org.apache.felix.upnp.tester.discovery.DeviceNode;
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class SubscriptionPanel extends JPanel implements UPnPEventListener{
+ public SubscriptionPanel() {
+ super();
+ buildButtonPanel();
+ }
+
+ private void buildButtonPanel(){
+ JButton subscribeBtn = new JButton("Subscribe");
+ subscribeBtn.addActionListener(new AbstractAction(){
+ public void actionPerformed(ActionEvent e) {
+ //System.out.println("subscribing ...");
+ doSubscribe();
+ }
+ });
+ JButton unsubscribeBtn = new JButton("Unsubscribe");
+ unsubscribeBtn.addActionListener(new AbstractAction(){
+ public void actionPerformed(ActionEvent e) {
+ //System.out.println("unsubscribing ...");
+ doUnsubscribe();
+ }
+ });
+ add(subscribeBtn);
+ add(unsubscribeBtn);
+ }
+
+ UPnPSubscriber subscriber;
+ public void doSubscribe()
+ {
+ if (subscriber == null)
+ subscriber = new UPnPSubscriber(Activator.context,this);
+
+ UPnPDeviceTreeNode selectedNode = getSelectedNode();
+ String serviceId = getServiceId(selectedNode);
+ String parentId = getDeviceId(selectedNode);
+ LogPanel.log("subscribing ... "+ "ServiceId ["+serviceId+"] of DeviceId ["+parentId +"]");
+ subscriber.subscribe(parentId,serviceId);
+ setSubscribedVariableOf(selectedNode);
+ }
+
+ public void doUnsubscribe(){
+ UPnPDeviceTreeNode selectedNode = getSelectedNode();
+ String serviceId = getServiceId(selectedNode);
+ String parentId = getDeviceId(selectedNode);
+ LogPanel.log("unsubscribing ... "+ "ServiceId ["+serviceId+"] of DeviceId ["+parentId +"]");
+ subscriber.unsubscribe(parentId,serviceId);
+ setUnubscribedVariableOf(selectedNode);
+ }
+
+ public void notifyUPnPEvent(final String deviceId, final String serviceId, final Dictionary events) {
+ // UPnP base driver notify are synchronous !!
+ Runnable doShowMsg = new Runnable() {
+ public void run() {
+ LogPanel.log("notifyUPnPEvent::[DeviceID "+deviceId+"][ServiceId "+serviceId+"]");
+ Enumeration elements = events.keys();
+ while (elements.hasMoreElements()){
+ Object key = elements.nextElement();
+ Object value = events.get(key);
+ LogPanel.log("["+key+"][value "+value+"]");
+ }
+ }
+ };
+ SwingUtilities.invokeLater(doShowMsg);
+
+ }
+
+ private void setSubscribedVariableOf(UPnPDeviceTreeNode selectedNode){
+ Enumeration list = selectedNode.children();
+ while (list.hasMoreElements()){
+ UPnPDeviceTreeNode node = (UPnPDeviceTreeNode) list.nextElement();
+ if (node.category == UPnPDeviceTreeNode.EVENTED_STATE)
+ node.category = UPnPDeviceTreeNode.SUBSCRIBED_STATE;
+ }
+ JTree tree = Mediator.getUPnPDeviceTree();
+ tree.validate();
+ tree.repaint();
+ }
+
+ private void setUnubscribedVariableOf(UPnPDeviceTreeNode selectedNode){
+ Enumeration list = selectedNode.children();
+ while (list.hasMoreElements()){
+ UPnPDeviceTreeNode node = (UPnPDeviceTreeNode) list.nextElement();
+ if (node.category == UPnPDeviceTreeNode.SUBSCRIBED_STATE)
+ node.category = UPnPDeviceTreeNode.EVENTED_STATE;
+ }
+ JTree tree = Mediator.getUPnPDeviceTree();
+ tree.validate();
+ tree.repaint();
+ }
+
+ private UPnPDeviceTreeNode getSelectedNode(){
+ JTree tree = Mediator.getUPnPDeviceTree();
+ UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
+ return selectedNode;
+ }
+ private String getServiceId (UPnPDeviceTreeNode selectedNode){
+ Object userObj = selectedNode.getUserObject();
+ String serviceId = ((UPnPService) userObj).getId();
+ return serviceId;
+ }
+ private String getDeviceId (UPnPDeviceTreeNode selectedNode){
+ UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
+ DeviceNode node =(DeviceNode)parent.getUserObject();
+ String parentId = (String) node.getReference().getProperty(UPnPDevice.ID);
+ return parentId;
+ }
+
+
+
+}
+
+
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java
index ced75d4..ed81b6b 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/TreeViewer.java
@@ -1,322 +1,322 @@
-/*
- * 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.tester.gui;
-
-
-import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
-
-import javax.swing.AbstractAction;
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JScrollPane;
-import javax.swing.JTree;
-import javax.swing.SwingUtilities;
-import javax.swing.ToolTipManager;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreePath;
-
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.tester.Activator;
-import org.apache.felix.upnp.tester.Mediator;
-import org.apache.felix.upnp.tester.discovery.DeviceNode;
-import org.apache.felix.upnp.tester.discovery.DeviceNodeListener;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class TreeViewer extends JPanel implements DeviceNodeListener
-{
-
- private UPnPDeviceTreeNode root;
- private DefaultTreeModel treeModel;
- private JTree tree;
- final TreePopup popup ;
- public TreeViewer(){
- super(new BorderLayout());
- Mediator.setTreeViewer(this);
- root = new UPnPDeviceTreeNode("UPnP Devices");
- treeModel= new DefaultTreeModel(root);
- tree = new JTree(treeModel);
- Mediator.setUPnPDeviceTree(tree);
- tree.setCellRenderer(new TreeNodeCellRenderer() );
- tree.putClientProperty("JTree.lineStyle", "Angled");
- add(new JScrollPane(tree));
- addTreeSelectionListener();
-
-
- popup = new TreePopup(tree);
- popup.setEnabled(false);
- tree.addMouseListener(new MouseAdapter(){
- public void mouseClicked(MouseEvent e){
- if (SwingUtilities.isRightMouseButton(e)){
- TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
- tree.setSelectionPath(path);
- tree.scrollPathToVisible(path);
- popup.show(tree, e.getX(), e.getY());
- }
- }
- });
- ToolTipManager.sharedInstance().registerComponent(tree);
-
-
- }
-
- public void setPopupMenuEnabled(boolean driverControllerAvailable){
- popup.getComponent(0).setEnabled(driverControllerAvailable);
- }
- public void deviceDetected(DeviceNode node) {
- root.add(new UPnPDeviceTreeNode(node,Activator.context));
- treeModel.nodeStructureChanged(root);
- }
-
- public void rootDeviceUnplugged(String udn){
- Enumeration list = root.children();
- while (list.hasMoreElements()){
- UPnPDeviceTreeNode node= (UPnPDeviceTreeNode)list.nextElement();
- DeviceNode device = (DeviceNode)node.getUserObject();
- if (udn.equals(device.toString())) {
- node.removeFromParent();
- treeModel.nodeStructureChanged(root);
- }
- }
- }
-
- private void addTreeSelectionListener(){
- tree.addTreeSelectionListener(new TreeSelectionListener(){
- public void valueChanged(TreeSelectionEvent e){
- UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
- doNodeAction(selectedNode);
- }
- });
- }
-
- private void doNodeAction(UPnPDeviceTreeNode node){
- if (node == null) {
- clearPropertiesViewer();
- return;
- }
- if (node.category.equals(UPnPDeviceTreeNode.ACTION))
- Mediator.getPropertiesViewer().showActionPanel(true);
- else
- Mediator.getPropertiesViewer().showActionPanel(false);
-
- if (node.category.equals(UPnPDeviceTreeNode.SERVICE))
- Mediator.getPropertiesViewer().showSubscriptionPanel(true);
- else
- Mediator.getPropertiesViewer().showSubscriptionPanel(false);
-
- if ( node.category.equals(UPnPDeviceTreeNode.DEVICE)
- ||node.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE)){
- DeviceNode device = (DeviceNode) node.getUserObject();
- UPnPDevice upnpDevice = device.getDevice(Activator.context);
- makeProperties(upnpDevice);
- }
- else if (node.category.equals(UPnPDeviceTreeNode.SERVICE)){
- UPnPService service = (UPnPService) node.getUserObject();
- makeProperties(service);
- }
- else if (node.category.equals(UPnPDeviceTreeNode.ACTION)){
- UPnPAction action = (UPnPAction) node.getUserObject();
- makeProperties(action);
- Mediator.getPropertiesViewer().setAction(action);
- }
- else if (node.category.equals(UPnPDeviceTreeNode.STATE)
- ||node.category.equals(UPnPDeviceTreeNode.EVENTED_STATE)
- ||node.category.equals(UPnPDeviceTreeNode.SUBSCRIBED_STATE)){
- UPnPStateVariable state = (UPnPStateVariable) node.getUserObject();
- makeProperties(state);
- }
-
- }
-
- private void clearPropertiesViewer(){
- String[] names = new String[]{};
- String[] values = new String[]{};
- PropertiesViewer viewer = Mediator.getPropertiesViewer();
- viewer.setProperties(names,values);
- viewer.showActionPanel(false);
- viewer.showSubscriptionPanel(false);
- }
-
- private void makeProperties(UPnPDevice upnpDevice){
- Dictionary dict = upnpDevice.getDescriptions(null);
- int size = dict.size();
- String[] names = new String[size];
- String[] values = new String[size];
- Enumeration keys = dict.keys();
- for (int i=0;i<size;i++){
- names[i]= (String) keys.nextElement();
- values[i]= Util.justString(dict.get(names[i]));
- }
- Mediator.getPropertiesViewer().setProperties(names,values);
- }
-
- private void makeProperties(UPnPService service){
- String[] names = new String[]{"Id","Type","Version"};
- String[] values = new String[]{service.getId(),service.getType(),service.getType()};
- Mediator.getPropertiesViewer().setProperties(names,values);
- }
-
- private void makeProperties(UPnPAction action){
- ArrayList names = new ArrayList();
- ArrayList values = new ArrayList();
- names.add("Name");
- values.add(action.getName());
-
- String returnName = action.getReturnArgumentName();
- if (returnName != null){
- names.add("Return value name");
- values.add(returnName);
- }
- String[] inArg = action.getInputArgumentNames();
- if (inArg != null){
- for (int i = 0; i<inArg.length;i++){
- names.add("Input arg["+ (i+1)+"]");
- values.add(inArg[i]);
- }
- }
- String[] outArg = action.getOutputArgumentNames();
- if (outArg != null){
- for (int i = 0; i<outArg.length;i++){
- names.add("Output arg["+ (i+1)+"]");
- values.add(outArg[i]);
- }
- }
-
- Mediator.getPropertiesViewer().setProperties(
- (String[])names.toArray(new String[]{}),
- (String[])values.toArray(new String[]{})
- );
-
- }
-
- private void makeProperties(UPnPStateVariable state){
- ArrayList names = new ArrayList();
- ArrayList values = new ArrayList();
- names.add("Name");
- values.add(state.getName());
- names.add("Evented");
- values.add(state.sendsEvents()? "yes":"no");
- names.add("Default Value");
- values.add(Util.justString(state.getDefaultValue()));
- names.add("Java Data Type");
- values.add(state.getJavaDataType().getName());
- names.add("Java UPnP Type");
- values.add(state.getUPnPDataType());
- names.add("Minimum");
- values.add(Util.justString(state.getMinimum()));
- names.add("Maximum");
- values.add(Util.justString(state.getMaximum()));
- names.add("Step");
- values.add(Util.justString(state.getStep()));
- String[] allowed = state.getAllowedValues();
- if (allowed!=null){
- for (int i=0;i<allowed.length;i++){
- names.add("Allowed value["+i+1+"]");
- values.add(allowed[i]);
- }
- }
- Mediator.getPropertiesViewer().setProperties(
- (String[])names.toArray(new String[]{}),
- (String[])values.toArray(new String[]{})
- );
- }
-
-
-}
-
-class TreePopup extends JPopupMenu implements PopupMenuListener {
- JTree tree;
- JMenuItem item;
-
- public TreePopup(final JTree tree){
- super();
- this.tree = tree;
- (item = add(new AbstractAction(){
- public void actionPerformed(ActionEvent e){
- UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
- String url = "";
- if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)){
- UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
- while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
- parent = (UPnPDeviceTreeNode)parent.getParent();
- DeviceNode device = (DeviceNode) parent.getUserObject();
- String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
- url = Mediator.getDriverProxy().getDeviceDescriptionURI(udn);
- }
-
- else if (selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE))
- {
- DeviceNode node = (DeviceNode) selectedNode.getUserObject();
- String udn = (String)node.getReference().getProperty(UPnPDevice.UDN);
- url = Mediator.getDriverProxy().getDeviceDescriptionURI(udn);
- }
- else if (selectedNode.category.equals(UPnPDeviceTreeNode.SERVICE))
- {
- UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
- while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
- parent = (UPnPDeviceTreeNode)parent.getParent();
- DeviceNode device = (DeviceNode) parent.getUserObject();
- String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
- UPnPService service = (UPnPService) selectedNode.getUserObject();
- url = Mediator.getDriverProxy().getServiceDescriptionURI(udn,service.getId());
- }
- Util.openUrl(url);
- }
- })).setText("Show Description");
- addPopupMenuListener(this);
-
- }
-
- public void popupMenuCanceled(PopupMenuEvent e){}
- public void popupMenuWillBecomeInvisible(PopupMenuEvent e){}
- public void popupMenuWillBecomeVisible(PopupMenuEvent e){
- if (Mediator.getDriverProxy().isDriverAvailable()){
- UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
- if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)
- ||selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE)
- ||selectedNode.category.equals(UPnPDeviceTreeNode.SERVICE))
- {
- item.setEnabled(true);
- }
- else
- item.setEnabled(false);
- }
- else
- item.setEnabled(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.tester.gui;
+
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import javax.swing.AbstractAction;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.ToolTipManager;
+import javax.swing.event.PopupMenuEvent;
+import javax.swing.event.PopupMenuListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.tester.Activator;
+import org.apache.felix.upnp.tester.Mediator;
+import org.apache.felix.upnp.tester.discovery.DeviceNode;
+import org.apache.felix.upnp.tester.discovery.DeviceNodeListener;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class TreeViewer extends JPanel implements DeviceNodeListener
+{
+
+ private UPnPDeviceTreeNode root;
+ private DefaultTreeModel treeModel;
+ private JTree tree;
+ final TreePopup popup ;
+ public TreeViewer(){
+ super(new BorderLayout());
+ Mediator.setTreeViewer(this);
+ root = new UPnPDeviceTreeNode("UPnP Devices");
+ treeModel= new DefaultTreeModel(root);
+ tree = new JTree(treeModel);
+ Mediator.setUPnPDeviceTree(tree);
+ tree.setCellRenderer(new TreeNodeCellRenderer() );
+ tree.putClientProperty("JTree.lineStyle", "Angled");
+ add(new JScrollPane(tree));
+ addTreeSelectionListener();
+
+
+ popup = new TreePopup(tree);
+ popup.setEnabled(false);
+ tree.addMouseListener(new MouseAdapter(){
+ public void mouseClicked(MouseEvent e){
+ if (SwingUtilities.isRightMouseButton(e)){
+ TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
+ tree.setSelectionPath(path);
+ tree.scrollPathToVisible(path);
+ popup.show(tree, e.getX(), e.getY());
+ }
+ }
+ });
+ ToolTipManager.sharedInstance().registerComponent(tree);
+
+
+ }
+
+ public void setPopupMenuEnabled(boolean driverControllerAvailable){
+ popup.getComponent(0).setEnabled(driverControllerAvailable);
+ }
+ public void deviceDetected(DeviceNode node) {
+ root.add(new UPnPDeviceTreeNode(node,Activator.context));
+ treeModel.nodeStructureChanged(root);
+ }
+
+ public void rootDeviceUnplugged(String udn){
+ Enumeration list = root.children();
+ while (list.hasMoreElements()){
+ UPnPDeviceTreeNode node= (UPnPDeviceTreeNode)list.nextElement();
+ DeviceNode device = (DeviceNode)node.getUserObject();
+ if (udn.equals(device.toString())) {
+ node.removeFromParent();
+ treeModel.nodeStructureChanged(root);
+ }
+ }
+ }
+
+ private void addTreeSelectionListener(){
+ tree.addTreeSelectionListener(new TreeSelectionListener(){
+ public void valueChanged(TreeSelectionEvent e){
+ UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
+ doNodeAction(selectedNode);
+ }
+ });
+ }
+
+ private void doNodeAction(UPnPDeviceTreeNode node){
+ if (node == null) {
+ clearPropertiesViewer();
+ return;
+ }
+ if (node.category.equals(UPnPDeviceTreeNode.ACTION))
+ Mediator.getPropertiesViewer().showActionPanel(true);
+ else
+ Mediator.getPropertiesViewer().showActionPanel(false);
+
+ if (node.category.equals(UPnPDeviceTreeNode.SERVICE))
+ Mediator.getPropertiesViewer().showSubscriptionPanel(true);
+ else
+ Mediator.getPropertiesViewer().showSubscriptionPanel(false);
+
+ if ( node.category.equals(UPnPDeviceTreeNode.DEVICE)
+ ||node.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE)){
+ DeviceNode device = (DeviceNode) node.getUserObject();
+ UPnPDevice upnpDevice = device.getDevice(Activator.context);
+ makeProperties(upnpDevice);
+ }
+ else if (node.category.equals(UPnPDeviceTreeNode.SERVICE)){
+ UPnPService service = (UPnPService) node.getUserObject();
+ makeProperties(service);
+ }
+ else if (node.category.equals(UPnPDeviceTreeNode.ACTION)){
+ UPnPAction action = (UPnPAction) node.getUserObject();
+ makeProperties(action);
+ Mediator.getPropertiesViewer().setAction(action);
+ }
+ else if (node.category.equals(UPnPDeviceTreeNode.STATE)
+ ||node.category.equals(UPnPDeviceTreeNode.EVENTED_STATE)
+ ||node.category.equals(UPnPDeviceTreeNode.SUBSCRIBED_STATE)){
+ UPnPStateVariable state = (UPnPStateVariable) node.getUserObject();
+ makeProperties(state);
+ }
+
+ }
+
+ private void clearPropertiesViewer(){
+ String[] names = new String[]{};
+ String[] values = new String[]{};
+ PropertiesViewer viewer = Mediator.getPropertiesViewer();
+ viewer.setProperties(names,values);
+ viewer.showActionPanel(false);
+ viewer.showSubscriptionPanel(false);
+ }
+
+ private void makeProperties(UPnPDevice upnpDevice){
+ Dictionary dict = upnpDevice.getDescriptions(null);
+ int size = dict.size();
+ String[] names = new String[size];
+ String[] values = new String[size];
+ Enumeration keys = dict.keys();
+ for (int i=0;i<size;i++){
+ names[i]= (String) keys.nextElement();
+ values[i]= Util.justString(dict.get(names[i]));
+ }
+ Mediator.getPropertiesViewer().setProperties(names,values);
+ }
+
+ private void makeProperties(UPnPService service){
+ String[] names = new String[]{"Id","Type","Version"};
+ String[] values = new String[]{service.getId(),service.getType(),service.getType()};
+ Mediator.getPropertiesViewer().setProperties(names,values);
+ }
+
+ private void makeProperties(UPnPAction action){
+ ArrayList names = new ArrayList();
+ ArrayList values = new ArrayList();
+ names.add("Name");
+ values.add(action.getName());
+
+ String returnName = action.getReturnArgumentName();
+ if (returnName != null){
+ names.add("Return value name");
+ values.add(returnName);
+ }
+ String[] inArg = action.getInputArgumentNames();
+ if (inArg != null){
+ for (int i = 0; i<inArg.length;i++){
+ names.add("Input arg["+ (i+1)+"]");
+ values.add(inArg[i]);
+ }
+ }
+ String[] outArg = action.getOutputArgumentNames();
+ if (outArg != null){
+ for (int i = 0; i<outArg.length;i++){
+ names.add("Output arg["+ (i+1)+"]");
+ values.add(outArg[i]);
+ }
+ }
+
+ Mediator.getPropertiesViewer().setProperties(
+ (String[])names.toArray(new String[]{}),
+ (String[])values.toArray(new String[]{})
+ );
+
+ }
+
+ private void makeProperties(UPnPStateVariable state){
+ ArrayList names = new ArrayList();
+ ArrayList values = new ArrayList();
+ names.add("Name");
+ values.add(state.getName());
+ names.add("Evented");
+ values.add(state.sendsEvents()? "yes":"no");
+ names.add("Default Value");
+ values.add(Util.justString(state.getDefaultValue()));
+ names.add("Java Data Type");
+ values.add(state.getJavaDataType().getName());
+ names.add("Java UPnP Type");
+ values.add(state.getUPnPDataType());
+ names.add("Minimum");
+ values.add(Util.justString(state.getMinimum()));
+ names.add("Maximum");
+ values.add(Util.justString(state.getMaximum()));
+ names.add("Step");
+ values.add(Util.justString(state.getStep()));
+ String[] allowed = state.getAllowedValues();
+ if (allowed!=null){
+ for (int i=0;i<allowed.length;i++){
+ names.add("Allowed value["+i+1+"]");
+ values.add(allowed[i]);
+ }
+ }
+ Mediator.getPropertiesViewer().setProperties(
+ (String[])names.toArray(new String[]{}),
+ (String[])values.toArray(new String[]{})
+ );
+ }
+
+
+}
+
+class TreePopup extends JPopupMenu implements PopupMenuListener {
+ JTree tree;
+ JMenuItem item;
+
+ public TreePopup(final JTree tree){
+ super();
+ this.tree = tree;
+ (item = add(new AbstractAction(){
+ public void actionPerformed(ActionEvent e){
+ UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
+ String url = "";
+ if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)){
+ UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
+ while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
+ parent = (UPnPDeviceTreeNode)parent.getParent();
+ DeviceNode device = (DeviceNode) parent.getUserObject();
+ String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
+ url = Mediator.getDriverProxy().getDeviceDescriptionURI(udn);
+ }
+
+ else if (selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE))
+ {
+ DeviceNode node = (DeviceNode) selectedNode.getUserObject();
+ String udn = (String)node.getReference().getProperty(UPnPDevice.UDN);
+ url = Mediator.getDriverProxy().getDeviceDescriptionURI(udn);
+ }
+ else if (selectedNode.category.equals(UPnPDeviceTreeNode.SERVICE))
+ {
+ UPnPDeviceTreeNode parent = (UPnPDeviceTreeNode)selectedNode.getParent();
+ while (parent.category!=UPnPDeviceTreeNode.ROOT_DEVICE)
+ parent = (UPnPDeviceTreeNode)parent.getParent();
+ DeviceNode device = (DeviceNode) parent.getUserObject();
+ String udn = (String)device.getReference().getProperty(UPnPDevice.UDN);
+ UPnPService service = (UPnPService) selectedNode.getUserObject();
+ url = Mediator.getDriverProxy().getServiceDescriptionURI(udn,service.getId());
+ }
+ Util.openUrl(url);
+ }
+ })).setText("Show Description");
+ addPopupMenuListener(this);
+
+ }
+
+ public void popupMenuCanceled(PopupMenuEvent e){}
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e){}
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e){
+ if (Mediator.getDriverProxy().isDriverAvailable()){
+ UPnPDeviceTreeNode selectedNode = (UPnPDeviceTreeNode)tree.getLastSelectedPathComponent();
+ if (selectedNode.category.equals(UPnPDeviceTreeNode.DEVICE)
+ ||selectedNode.category.equals(UPnPDeviceTreeNode.ROOT_DEVICE)
+ ||selectedNode.category.equals(UPnPDeviceTreeNode.SERVICE))
+ {
+ item.setEnabled(true);
+ }
+ else
+ item.setEnabled(false);
+ }
+ else
+ item.setEnabled(false);
+
+ }
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java
index c5bb6bc..88fa626 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/UPnPDeviceTreeNode.java
@@ -1,236 +1,236 @@
-/*
- * 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.tester.gui;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.image.ImageObserver;
-import java.net.URL;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JToolTip;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.service.upnp.UPnPAction;
-import org.osgi.service.upnp.UPnPDevice;
-import org.osgi.service.upnp.UPnPService;
-import org.osgi.service.upnp.UPnPStateVariable;
-
-import org.apache.felix.upnp.tester.discovery.DeviceNode;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class UPnPDeviceTreeNode extends DefaultMutableTreeNode {
- public final static String ROOT_DEVICE = "RootDeviceNode";
- public final static String DEVICE = "DeviceNode";
- public final static String SERVICE = "UPnPService";
- public final static String ACTION = "UPnPAction";
- public final static String STATE = "UPnPStateVariable";
- public final static String EVENTED_STATE = "EventedStateVariable";
- public final static String SUBSCRIBED_STATE = "SubscribedStateVariable";
-
- protected String category;
- public UPnPDeviceTreeNode(String obj) {
- super(obj);
- category = obj.getClass().getName();
- }
-
- public UPnPDeviceTreeNode(DeviceNode obj, BundleContext ctx) {
- super(obj);
-
- if (obj.isRoot()) category = ROOT_DEVICE;
- else category = DEVICE;
-
- UPnPDevice device = (UPnPDevice)ctx.getService(obj.getReference());
- UPnPService[] services = device.getServices();
-
- Collection nodeChildren = obj.getChildren();
- if (nodeChildren != null){
- Iterator list = nodeChildren.iterator();
- while (list.hasNext()){
- DeviceNode node = (DeviceNode)list.next();
- this.add(new UPnPDeviceTreeNode(node,ctx));
- }
- }
- if (services != null){
- for (int i=0;i<services.length;i++)
- this.add(new UPnPDeviceTreeNode(services[i]));
- }
-
- }
-
- public UPnPDeviceTreeNode(UPnPService obj) {
- super(obj);
- category = SERVICE;
- UPnPStateVariable[] variables = obj.getStateVariables();
- if (variables != null){
- for (int i=0;i<variables.length;i++)
- this.add(new UPnPDeviceTreeNode(variables[i]));
- }
- UPnPAction[] actions = obj.getActions();
- if (actions != null){
- for (int i=0;i<actions.length;i++)
- this.add(new UPnPDeviceTreeNode(actions[i]));
- }
- }
- public UPnPDeviceTreeNode(UPnPAction obj) {
- super(obj);
- category = ACTION;
- }
-
- public UPnPDeviceTreeNode(UPnPStateVariable obj) {
- super(obj);
- if (obj.sendsEvents()) category = EVENTED_STATE;
- else category = STATE;
- }
-
- public String toString() {
- if (category.equals(DEVICE)||category.equals(ROOT_DEVICE)){
- DeviceNode node = (DeviceNode) getUserObject();
- return node.toString();
- }
- else if (category.equals(SERVICE)){
- UPnPService node = (UPnPService) getUserObject();
- return node.getType();
- }
- else if (category.equals(ACTION)){
- UPnPAction node = (UPnPAction) getUserObject();
- return node.getName();
- }
- else if (category.equals(STATE) ||category.equals(EVENTED_STATE)||category.equals(SUBSCRIBED_STATE)){
- UPnPStateVariable node = (UPnPStateVariable) getUserObject();
- return node.getName();
- }
- else
- return getUserObject().toString();
- }
-}
-
-// local class for JTree icon renderer
-class TreeNodeCellRenderer extends DefaultTreeCellRenderer implements ImageObserver{
-
- private HashMap icons ;
- ImageIcon image;
- public TreeNodeCellRenderer() {
- super();
- icons = new HashMap();
- try {
- icons.put(UPnPDeviceTreeNode.EVENTED_STATE, loadIcon(UPnPDeviceTreeNode.EVENTED_STATE));
- image = loadIcon(UPnPDeviceTreeNode.SUBSCRIBED_STATE);
- // to use animate gif
- //image.setImageObserver(this);
- icons.put(UPnPDeviceTreeNode.SUBSCRIBED_STATE, image);
-
- icons.put(UPnPDeviceTreeNode.ROOT_DEVICE, loadIcon(UPnPDeviceTreeNode.ROOT_DEVICE));
- icons.put(UPnPDeviceTreeNode.DEVICE, loadIcon(UPnPDeviceTreeNode.DEVICE));
- icons.put(UPnPDeviceTreeNode.SERVICE, loadIcon(UPnPDeviceTreeNode.SERVICE));
- icons.put(UPnPDeviceTreeNode.ACTION, loadIcon(UPnPDeviceTreeNode.ACTION));
- icons.put(UPnPDeviceTreeNode.STATE, loadIcon(UPnPDeviceTreeNode.STATE));
- } catch (Exception ex) {
- System.out.println(ex);
- }
-
- }
-
- public JToolTip createToolTip() {
- JToolTip tip = super.createToolTip();
- tip.setBackground(Color.yellow);
- return tip;
- }
-
- //test to display animated gif
- /*
- public boolean imageUpdate(Image img, int infoflags,
- int x, int y, int width, int height){
- //System.out.println("image update");
- Mediator.getUPnPDeviceTree().validate();
- Mediator.getUPnPDeviceTree().repaint();
- return true;
- }
- */
-
- public Component getTreeCellRendererComponent(JTree tree, Object value,
- boolean sel, boolean expanded, boolean leaf, int row,
- boolean hasFocus) {
- Icon icon = selectIcon((UPnPDeviceTreeNode) value);
- setToolTip((UPnPDeviceTreeNode) value);
- if (icon != null) {
- setOpenIcon(icon);
- setClosedIcon(icon);
- setLeafIcon(icon);
- } else {
- setOpenIcon(getDefaultOpenIcon());
- setClosedIcon(getDefaultClosedIcon());
- setLeafIcon(getDefaultLeafIcon());
- }
- return super.getTreeCellRendererComponent(tree, value, sel, expanded,
- leaf, row, hasFocus);
- }
-
- public Icon selectIcon(UPnPDeviceTreeNode node) {
- Icon icon = null;
- try {
- String tag = node.category;
- icon = (Icon) icons.get(tag);
- } catch (Exception ex) {
- System.out.println("getTreeCellRendererComponent Exception:" + ex);
- }
- return icon;
- }
-
- public void setToolTip(UPnPDeviceTreeNode node) {
- String tag = node.category;
- if (tag.equals(UPnPDeviceTreeNode.ROOT_DEVICE)
- ||tag.equals(UPnPDeviceTreeNode.DEVICE))
- {
- DeviceNode device = (DeviceNode) node.getUserObject();
- setToolTipText("<html><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' ><TR BGCOLOR='#F9FF79' ><TD>"
- + device.getReference().getProperty(UPnPDevice.FRIENDLY_NAME).toString()
- +"</TD></TR></TABLE ></html>");
- }
- else
- setToolTipText(null);
- }
-
- public static ImageIcon loadIcon(String name)
- {
- try {
- /*
- System.out.println("loading image ..."+name);
- System.out.println("from "+"IMAGES/" + name + ".gif");
- */
- URL eventIconUrl = UPnPDeviceTreeNode.class.getResource("IMAGES/" + name + ".gif");
- return new ImageIcon(eventIconUrl,name);
- }
- catch (Exception ex){
- System.out.println("Resource:" + name + " not found : " + ex.toString());
- 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.tester.gui;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.image.ImageObserver;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JToolTip;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPDevice;
+import org.osgi.service.upnp.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+import org.apache.felix.upnp.tester.discovery.DeviceNode;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class UPnPDeviceTreeNode extends DefaultMutableTreeNode {
+ public final static String ROOT_DEVICE = "RootDeviceNode";
+ public final static String DEVICE = "DeviceNode";
+ public final static String SERVICE = "UPnPService";
+ public final static String ACTION = "UPnPAction";
+ public final static String STATE = "UPnPStateVariable";
+ public final static String EVENTED_STATE = "EventedStateVariable";
+ public final static String SUBSCRIBED_STATE = "SubscribedStateVariable";
+
+ protected String category;
+ public UPnPDeviceTreeNode(String obj) {
+ super(obj);
+ category = obj.getClass().getName();
+ }
+
+ public UPnPDeviceTreeNode(DeviceNode obj, BundleContext ctx) {
+ super(obj);
+
+ if (obj.isRoot()) category = ROOT_DEVICE;
+ else category = DEVICE;
+
+ UPnPDevice device = (UPnPDevice)ctx.getService(obj.getReference());
+ UPnPService[] services = device.getServices();
+
+ Collection nodeChildren = obj.getChildren();
+ if (nodeChildren != null){
+ Iterator list = nodeChildren.iterator();
+ while (list.hasNext()){
+ DeviceNode node = (DeviceNode)list.next();
+ this.add(new UPnPDeviceTreeNode(node,ctx));
+ }
+ }
+ if (services != null){
+ for (int i=0;i<services.length;i++)
+ this.add(new UPnPDeviceTreeNode(services[i]));
+ }
+
+ }
+
+ public UPnPDeviceTreeNode(UPnPService obj) {
+ super(obj);
+ category = SERVICE;
+ UPnPStateVariable[] variables = obj.getStateVariables();
+ if (variables != null){
+ for (int i=0;i<variables.length;i++)
+ this.add(new UPnPDeviceTreeNode(variables[i]));
+ }
+ UPnPAction[] actions = obj.getActions();
+ if (actions != null){
+ for (int i=0;i<actions.length;i++)
+ this.add(new UPnPDeviceTreeNode(actions[i]));
+ }
+ }
+ public UPnPDeviceTreeNode(UPnPAction obj) {
+ super(obj);
+ category = ACTION;
+ }
+
+ public UPnPDeviceTreeNode(UPnPStateVariable obj) {
+ super(obj);
+ if (obj.sendsEvents()) category = EVENTED_STATE;
+ else category = STATE;
+ }
+
+ public String toString() {
+ if (category.equals(DEVICE)||category.equals(ROOT_DEVICE)){
+ DeviceNode node = (DeviceNode) getUserObject();
+ return node.toString();
+ }
+ else if (category.equals(SERVICE)){
+ UPnPService node = (UPnPService) getUserObject();
+ return node.getType();
+ }
+ else if (category.equals(ACTION)){
+ UPnPAction node = (UPnPAction) getUserObject();
+ return node.getName();
+ }
+ else if (category.equals(STATE) ||category.equals(EVENTED_STATE)||category.equals(SUBSCRIBED_STATE)){
+ UPnPStateVariable node = (UPnPStateVariable) getUserObject();
+ return node.getName();
+ }
+ else
+ return getUserObject().toString();
+ }
+}
+
+// local class for JTree icon renderer
+class TreeNodeCellRenderer extends DefaultTreeCellRenderer implements ImageObserver{
+
+ private HashMap icons ;
+ ImageIcon image;
+ public TreeNodeCellRenderer() {
+ super();
+ icons = new HashMap();
+ try {
+ icons.put(UPnPDeviceTreeNode.EVENTED_STATE, loadIcon(UPnPDeviceTreeNode.EVENTED_STATE));
+ image = loadIcon(UPnPDeviceTreeNode.SUBSCRIBED_STATE);
+ // to use animate gif
+ //image.setImageObserver(this);
+ icons.put(UPnPDeviceTreeNode.SUBSCRIBED_STATE, image);
+
+ icons.put(UPnPDeviceTreeNode.ROOT_DEVICE, loadIcon(UPnPDeviceTreeNode.ROOT_DEVICE));
+ icons.put(UPnPDeviceTreeNode.DEVICE, loadIcon(UPnPDeviceTreeNode.DEVICE));
+ icons.put(UPnPDeviceTreeNode.SERVICE, loadIcon(UPnPDeviceTreeNode.SERVICE));
+ icons.put(UPnPDeviceTreeNode.ACTION, loadIcon(UPnPDeviceTreeNode.ACTION));
+ icons.put(UPnPDeviceTreeNode.STATE, loadIcon(UPnPDeviceTreeNode.STATE));
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+
+ }
+
+ public JToolTip createToolTip() {
+ JToolTip tip = super.createToolTip();
+ tip.setBackground(Color.yellow);
+ return tip;
+ }
+
+ //test to display animated gif
+ /*
+ public boolean imageUpdate(Image img, int infoflags,
+ int x, int y, int width, int height){
+ //System.out.println("image update");
+ Mediator.getUPnPDeviceTree().validate();
+ Mediator.getUPnPDeviceTree().repaint();
+ return true;
+ }
+ */
+
+ public Component getTreeCellRendererComponent(JTree tree, Object value,
+ boolean sel, boolean expanded, boolean leaf, int row,
+ boolean hasFocus) {
+ Icon icon = selectIcon((UPnPDeviceTreeNode) value);
+ setToolTip((UPnPDeviceTreeNode) value);
+ if (icon != null) {
+ setOpenIcon(icon);
+ setClosedIcon(icon);
+ setLeafIcon(icon);
+ } else {
+ setOpenIcon(getDefaultOpenIcon());
+ setClosedIcon(getDefaultClosedIcon());
+ setLeafIcon(getDefaultLeafIcon());
+ }
+ return super.getTreeCellRendererComponent(tree, value, sel, expanded,
+ leaf, row, hasFocus);
+ }
+
+ public Icon selectIcon(UPnPDeviceTreeNode node) {
+ Icon icon = null;
+ try {
+ String tag = node.category;
+ icon = (Icon) icons.get(tag);
+ } catch (Exception ex) {
+ System.out.println("getTreeCellRendererComponent Exception:" + ex);
+ }
+ return icon;
+ }
+
+ public void setToolTip(UPnPDeviceTreeNode node) {
+ String tag = node.category;
+ if (tag.equals(UPnPDeviceTreeNode.ROOT_DEVICE)
+ ||tag.equals(UPnPDeviceTreeNode.DEVICE))
+ {
+ DeviceNode device = (DeviceNode) node.getUserObject();
+ setToolTipText("<html><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' ><TR BGCOLOR='#F9FF79' ><TD>"
+ + device.getReference().getProperty(UPnPDevice.FRIENDLY_NAME).toString()
+ +"</TD></TR></TABLE ></html>");
+ }
+ else
+ setToolTipText(null);
+ }
+
+ public static ImageIcon loadIcon(String name)
+ {
+ try {
+ /*
+ System.out.println("loading image ..."+name);
+ System.out.println("from "+"IMAGES/" + name + ".gif");
+ */
+ URL eventIconUrl = UPnPDeviceTreeNode.class.getResource("IMAGES/" + name + ".gif");
+ return new ImageIcon(eventIconUrl,name);
+ }
+ catch (Exception ex){
+ System.out.println("Resource:" + name + " not found : " + ex.toString());
+ return null;
+ }
+ }
+
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java
index 67a6506..965e771 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/gui/Util.java
@@ -1,104 +1,104 @@
-/*
- * 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.tester.gui;
-
-import java.awt.GridBagConstraints;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-
-public class Util {
- final static GridBagConstraints constrains = new GridBagConstraints();
-
- public static GridBagConstraints setConstrains(int x,int y,int w,int h,int wx, int wy)
- {
- constrains.insets.left=5;
- constrains.insets.right=5;
- constrains.insets.bottom=3;
- constrains.fill=GridBagConstraints.BOTH;
- constrains.anchor=GridBagConstraints.WEST;
- constrains.gridx=x;
- constrains.gridy=y;
- constrains.gridwidth=w;
- constrains.gridheight=h;
- constrains.weightx=wx;
- constrains.weighty=wy;
- return constrains;
- }
-
- public static String justString(Object obj){
- if (obj == null) return "";
- else if (obj instanceof String[]){
- String[] items = (String[])obj;
- String tmp = "";
- for (int i = 0; i < items.length; i++) {
- tmp+=items[i]+"; ";
- }
- return tmp;
- }
- return obj.toString();
- }
-
- public static void openUrl(String url) {
- try {
- if (url == null) return;
- String os=System.getProperty("os.name","").toLowerCase();
- Process p = null;
- if(os.indexOf("windows")!=-1){
- String cmd = null;
- cmd = "cmd.exe /C start "+url;
- LogPanel.log("[Executing cmd] " +cmd);
- p = Runtime.getRuntime().exec(cmd);
-
- }else if(os.indexOf("linux")!=-1){
- String[] cmd = new String[]{
- "/bin/sh",
- "-c",
- "( $BROWSER " + url + " || mozilla-firefox '" + url + "' || firefox '" + url
- + "' || mozilla '" + url + "' || konqueror '" + url + "' || opera '" + url + "' )"
- };
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < cmd.length; i++) {
- sb.append(" ").append(cmd[i]);
-
- }
- LogPanel.log("[Executing cmd] " +sb.toString());
- p = Runtime.getRuntime().exec(cmd);
- }
- BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
- BufferedReader out = new BufferedReader(new InputStreamReader(p.getInputStream()));
- while (true) {
- while(err.ready()) System.err.println(err.readLine());
- while(out.ready()) System.out.println(out.readLine());
- try{
- p.exitValue();
- break;
- }catch (IllegalThreadStateException e) {
- }
- }
- } catch (Exception ex){
- System.out.println(ex);
- }
- }
-
-}
+/*
+ * 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.tester.gui;
+
+import java.awt.GridBagConstraints;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/*
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+
+public class Util {
+ final static GridBagConstraints constrains = new GridBagConstraints();
+
+ public static GridBagConstraints setConstrains(int x,int y,int w,int h,int wx, int wy)
+ {
+ constrains.insets.left=5;
+ constrains.insets.right=5;
+ constrains.insets.bottom=3;
+ constrains.fill=GridBagConstraints.BOTH;
+ constrains.anchor=GridBagConstraints.WEST;
+ constrains.gridx=x;
+ constrains.gridy=y;
+ constrains.gridwidth=w;
+ constrains.gridheight=h;
+ constrains.weightx=wx;
+ constrains.weighty=wy;
+ return constrains;
+ }
+
+ public static String justString(Object obj){
+ if (obj == null) return "";
+ else if (obj instanceof String[]){
+ String[] items = (String[])obj;
+ String tmp = "";
+ for (int i = 0; i < items.length; i++) {
+ tmp+=items[i]+"; ";
+ }
+ return tmp;
+ }
+ return obj.toString();
+ }
+
+ public static void openUrl(String url) {
+ try {
+ if (url == null) return;
+ String os=System.getProperty("os.name","").toLowerCase();
+ Process p = null;
+ if(os.indexOf("windows")!=-1){
+ String cmd = null;
+ cmd = "cmd.exe /C start "+url;
+ LogPanel.log("[Executing cmd] " +cmd);
+ p = Runtime.getRuntime().exec(cmd);
+
+ }else if(os.indexOf("linux")!=-1){
+ String[] cmd = new String[]{
+ "/bin/sh",
+ "-c",
+ "( $BROWSER " + url + " || mozilla-firefox '" + url + "' || firefox '" + url
+ + "' || mozilla '" + url + "' || konqueror '" + url + "' || opera '" + url + "' )"
+ };
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < cmd.length; i++) {
+ sb.append(" ").append(cmd[i]);
+
+ }
+ LogPanel.log("[Executing cmd] " +sb.toString());
+ p = Runtime.getRuntime().exec(cmd);
+ }
+ BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ BufferedReader out = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ while (true) {
+ while(err.ready()) System.err.println(err.readLine());
+ while(out.ready()) System.out.println(out.readLine());
+ try{
+ p.exitValue();
+ break;
+ }catch (IllegalThreadStateException e) {
+ }
+ }
+ } catch (Exception ex){
+ System.out.println(ex);
+ }
+ }
+
+}
diff --git a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java
index 7eb1bb8..c73d5af 100644
--- a/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java
+++ b/upnp/tester/src/main/java/org/apache/felix/upnp/tester/test.java
@@ -1,79 +1,79 @@
-/*
- * 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.tester;
-
-import java.awt.Image;
-import java.net.URL;
-
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-public class test extends JFrame {
-
- Image image;
-
- public test(String filename) {
- super(filename);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- //image = getToolkit().getImage(filename);
- ImageIcon image =loadIcon("EventedStateVariable");
- //image.setImageObserver(this);
- JPanel panel = new JPanel();
-
- panel.add(new JLabel(image));
- JLabel lab = new JLabel();
- lab.setIcon(image);
- panel.add(lab);
- this.getContentPane().add(panel);
- }
-
- /*public void paint(Graphics g) {
- super.paint(g);
- g.drawImage(image, 25, 25, this);
- }*/
-
- public static void main(String args[]) {
- if (args.length > 0) {
- JFrame f = new test(args[0]);
- f.setSize(300, 300);
- f.show();
- } else {
- System.err.println(
- "You must specify an image filename to display");
- }
- }
-
-
- public static ImageIcon loadIcon(String name)
- {
- try {
- //System.out.println("loading image ..."+path);
- URL eventIconUrl = test.class.getResource("images/" + name + ".gif");
- return new ImageIcon(eventIconUrl,name);
- }
- catch (Exception ex){
- System.out.println("Resource:" + name + " not found : " + ex.toString());
- 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.tester;
+
+import java.awt.Image;
+import java.net.URL;
+
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+public class test extends JFrame {
+
+ Image image;
+
+ public test(String filename) {
+ super(filename);
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ //image = getToolkit().getImage(filename);
+ ImageIcon image =loadIcon("EventedStateVariable");
+ //image.setImageObserver(this);
+ JPanel panel = new JPanel();
+
+ panel.add(new JLabel(image));
+ JLabel lab = new JLabel();
+ lab.setIcon(image);
+ panel.add(lab);
+ this.getContentPane().add(panel);
+ }
+
+ /*public void paint(Graphics g) {
+ super.paint(g);
+ g.drawImage(image, 25, 25, this);
+ }*/
+
+ public static void main(String args[]) {
+ if (args.length > 0) {
+ JFrame f = new test(args[0]);
+ f.setSize(300, 300);
+ f.show();
+ } else {
+ System.err.println(
+ "You must specify an image filename to display");
+ }
+ }
+
+
+ public static ImageIcon loadIcon(String name)
+ {
+ try {
+ //System.out.println("loading image ..."+path);
+ URL eventIconUrl = test.class.getResource("images/" + name + ".gif");
+ return new ImageIcon(eventIconUrl,name);
+ }
+ catch (Exception ex){
+ System.out.println("Resource:" + name + " not found : " + ex.toString());
+ return null;
+ }
+ }
+
}