You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fu...@apache.org on 2006/05/03 09:45:05 UTC

svn commit: r399191 [2/2] - in /incubator/felix/trunk: org.apache.felix.upnp.sample.binaryLight/ org.apache.felix.upnp.sample.binaryLight/src/ org.apache.felix.upnp.sample.binaryLight/src/main/ org.apache.felix.upnp.sample.binaryLight/src/main/java/ or...

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockPane.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockPane.java?rev=399191&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockPane.java (added)
+++ incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/ClockPane.java Wed May  3 00:44:48 2006
@@ -0,0 +1,209 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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:felix-dev@incubator.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);
+	}
+}
+

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/EventSource.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/EventSource.java?rev=399191&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/EventSource.java (added)
+++ incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/EventSource.java Wed May  3 00:44:48 2006
@@ -0,0 +1,30 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.PropertyChangeListener;
+/* 
+* @author <a href="mailto:felix-dev@incubator.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);
+}
+

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/GetTimeAction.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/GetTimeAction.java?rev=399191&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/GetTimeAction.java (added)
+++ incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/GetTimeAction.java Wed May  3 00:44:48 2006
@@ -0,0 +1,86 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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:felix-dev@incubator.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;
+	}
+}

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/ResultStateVariable.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/ResultStateVariable.java?rev=399191&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/ResultStateVariable.java (added)
+++ incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/ResultStateVariable.java Wed May  3 00:44:48 2006
@@ -0,0 +1,96 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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;
+/* 
+* @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+*/
+
+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;
+	}
+	
+}

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/SetTimeAction.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/SetTimeAction.java?rev=399191&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/SetTimeAction.java (added)
+++ incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/SetTimeAction.java Wed May  3 00:44:48 2006
@@ -0,0 +1,92 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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 org.osgi.service.upnp.UPnPAction;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+/* 
+* @author <a href="mailto:felix-dev@incubator.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 {
+		//Date value = (Date) args.get(NEW_TIME_VALUE);
+		long l = ((Long) args.get(NEW_TIME_VALUE)).longValue();
+		((TimeStateVariable) time).setCurrentTime(l);
+		args.remove(NEW_TIME_VALUE);
+		args.put(NEW_RESULT_VALUE,((TimeStateVariable) time).getCurrentTime());
+		return args;
+	}
+}

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java?rev=399191&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java (added)
+++ incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/TimeStateVariable.java Wed May  3 00:44:48 2006
@@ -0,0 +1,104 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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;
+/* 
+* @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+*/
+
+public class TimeStateVariable implements UPnPStateVariable{
+	
+	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().setTimeInMillis(milliseconds);
+	}
+}

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/TimerService.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/TimerService.java?rev=399191&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/TimerService.java (added)
+++ incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/TimerService.java Wed May  3 00:44:48 2006
@@ -0,0 +1,103 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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:felix-dev@incubator.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;
+	}
+}

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/UPnPEventNotifier.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/UPnPEventNotifier.java?rev=399191&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/UPnPEventNotifier.java (added)
+++ incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/java/org/apache/felix/upnp/sample/clock/UPnPEventNotifier.java Wed May  3 00:44:48 2006
@@ -0,0 +1,187 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.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.UPnPService;
+import org.osgi.service.upnp.UPnPStateVariable;
+
+/* 
+* @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+*/
+
+public class UPnPEventNotifier implements PropertyChangeListener,ServiceListener {
+	BundleContext context;
+	UPnPDevice device;
+	UPnPService service;
+	EventSource source;
+	
+	Properties UPnPTargetListener;
+	String deviceId;
+	String serviceId;
+	Vector upnpListeners = new Vector();
+	
+	public UPnPEventNotifier(BundleContext context,UPnPDevice device,UPnPService service,EventSource source){
+		this.context=context;
+		this.device=device;
+		this.service=service;
+		this.source=source;
+		this.serviceId=service.getId();
+		setupUPnPListenerHouseKeeping(device);
+	}
+	
+	/**
+	 * @param deviceId
+	 */
+	private void setupUPnPListenerHouseKeeping(UPnPDevice device) {
+		UPnPTargetListener = new Properties();
+		Dictionary dict = device.getDescriptions(null);
+		deviceId = (String) dict.get(UPnPDevice.ID);
+		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()+")";
+		
+		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);
+		}
+		
+	    try {
+	    	//String filter = "(&" + ANY_UPnPEventListener + deviceId_Filter + ")";
+	    	String filter = ANY_UPnPEventListener;
+			context.addServiceListener(this,filter);
+		} catch (Exception ex) {
+			System.out.println(ex);
+		}
+		
+		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);
+			}
+		}
+		
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+	 */
+	public void propertyChange(PropertyChangeEvent evt) {
+		Iterator list = upnpListeners.iterator();
+		String property = evt.getPropertyName();
+		Object value = evt.getNewValue();
+		String valueString = value.toString();
+		final Properties events = new Properties();
+		events.put(property,valueString);
+		while (list.hasNext()){
+			final ServiceReference sr = (ServiceReference)list.next();
+			String[] props =sr.getPropertyKeys();
+			new Thread(){
+				public void run(){
+					try {
+						UPnPEventListener listener = (UPnPEventListener) context.getService(sr);
+						listener.notifyUPnPEvent(deviceId,serviceId,events);
+						context.ungetService(sr);
+					} catch (Exception ex){
+						System.out.println("Clock UPnPEventNotifier Err: " +ex);
+						System.out.println("context: " +context);
+						System.out.println("listener: " +context.getService(sr));
+						System.out.println("sr: " +sr);
+						System.out.println();
+					}
+				}
+			}.start();						
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
+	 */
+	public void serviceChanged(ServiceEvent e) {
+		switch(e.getType()){
+			case ServiceEvent.REGISTERED:{
+				ServiceReference sr = e.getServiceReference();
+				Filter filter = (Filter) sr.getProperty(UPnPEventListener.UPNP_FILTER);
+				if (filter == null) addNewListener(sr);
+				else {				
+					if (filter.match(UPnPTargetListener))
+						addNewListener(sr);
+				}
+			};break;
+			
+			case ServiceEvent.MODIFIED:{				
+			};break;
+			
+			case ServiceEvent.UNREGISTERING:{	
+				removeListener(e.getServiceReference());
+			};break;
+				
+		}
+		
+	}
+
+	/**
+	 * @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();
+	}
+}

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/META-INF/Manifest.mf
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/META-INF/Manifest.mf?rev=399191&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/META-INF/Manifest.mf (added)
+++ incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/META-INF/Manifest.mf Wed May  3 00:44:48 2006
@@ -0,0 +1,4 @@
+Bundle-Author: Matteo Demuru <de...@apache.org>,Francesco Furfari <fu...@apache.org>,Satoshi Konno <konno@users.sourceforge.
+ net>,Stefano "Kismet" Lenzi <le...@apache.org>
+Bundle-ClassPath: .
+

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/org/apache/felix/upnp/sample/clock/images/clock.gif
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/org/apache/felix/upnp/sample/clock/images/clock.gif?rev=399191&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/org/apache/felix/upnp/sample/clock/images/clock.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/org/apache/felix/upnp/sample/clock/images/clock.jpg
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/org/apache/felix/upnp/sample/clock/images/clock.jpg?rev=399191&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/org/apache/felix/upnp/sample/clock/images/clock.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/org/apache/felix/upnp/sample/clock/images/logo.gif
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/org/apache/felix/upnp/sample/clock/images/logo.gif?rev=399191&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/felix/trunk/org.apache.felix.upnp.sample.clock/src/main/resources/org/apache/felix/upnp/sample/clock/images/logo.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream