/** * Adds the given <tt>FileTransferListener</tt> that would listen for file transfer requests and * created file transfers. * * @param listener the <tt>FileTransferListener</tt> to add */ public void addFileTransferListener(FileTransferListener listener) { synchronized (fileTransferListeners) { if (!fileTransferListeners.contains(listener)) { this.fileTransferListeners.add(listener); } } }
/** * Construct (with WhiteboardSession) and send a WhiteboardObject to a contact. * * @param wbSession the white-board session, to which the object would be send * @param ws WhiteboardShape to convert and send * @param c contact * @return WhiteboardObject sent */ public WhiteboardObject sendWhiteboardObject(WhiteboardSession wbSession, WhiteboardShape ws) throws OperationFailedException { Vector supportedWBO = new Vector(Arrays.asList(wbSession.getSupportedWhiteboardObjects())); if (ws instanceof WhiteboardObjectPath) { if (!supportedWBO.contains(WhiteboardObjectPath.NAME)) return null; WhiteboardObjectPath obj = (WhiteboardObjectPath) wbSession.createWhiteboardObject(WhiteboardObjectPath.NAME); ws.setID(obj.getID()); obj.setPoints(((WhiteboardObjectPath) ws).getPoints()); obj.setColor(ws.getColor()); obj.setThickness(ws.getThickness()); wbSession.sendWhiteboardObject(obj); return obj; } else if (ws instanceof WhiteboardObjectPolyLine) { if (!supportedWBO.contains(WhiteboardObjectPolyLine.NAME)) return null; WhiteboardObjectPolyLine obj = (WhiteboardObjectPolyLine) wbSession.createWhiteboardObject(WhiteboardObjectPolyLine.NAME); ws.setID(obj.getID()); obj.setPoints(((WhiteboardObjectPolyLine) ws).getPoints()); obj.setColor(ws.getColor()); obj.setThickness(ws.getThickness()); wbSession.sendWhiteboardObject(obj); return obj; } else if (ws instanceof WhiteboardObjectPolygon) { if (!supportedWBO.contains(WhiteboardObjectPolygon.NAME)) return null; WhiteboardObjectPolygon obj = (WhiteboardObjectPolygon) wbSession.createWhiteboardObject(WhiteboardObjectPolygon.NAME); ws.setID(obj.getID()); obj.setPoints(((WhiteboardObjectPolygon) ws).getPoints()); obj.setBackgroundColor(((WhiteboardObjectPolygon) ws).getBackgroundColor()); obj.setFill(((WhiteboardObjectPolygon) ws).isFill()); obj.setColor(ws.getColor()); obj.setThickness(ws.getThickness()); wbSession.sendWhiteboardObject(obj); return obj; } else if (ws instanceof WhiteboardObjectLine) { if (!supportedWBO.contains(WhiteboardObjectLine.NAME)) return null; WhiteboardObjectLine obj = (WhiteboardObjectLine) wbSession.createWhiteboardObject(WhiteboardObjectLine.NAME); ws.setID(obj.getID()); obj.setWhiteboardPointStart(((WhiteboardObjectLine) ws).getWhiteboardPointStart()); obj.setWhiteboardPointEnd(((WhiteboardObjectLine) ws).getWhiteboardPointEnd()); obj.setColor(ws.getColor()); obj.setThickness(ws.getThickness()); wbSession.sendWhiteboardObject(obj); return obj; } else if (ws instanceof WhiteboardObjectRect) { if (!supportedWBO.contains(WhiteboardObjectRect.NAME)) return null; WhiteboardObjectRect obj = (WhiteboardObjectRect) wbSession.createWhiteboardObject(WhiteboardObjectRect.NAME); ws.setID(obj.getID()); obj.setFill(((WhiteboardObjectRect) ws).isFill()); obj.setHeight(((WhiteboardObjectRect) ws).getHeight()); obj.setWhiteboardPoint(((WhiteboardObjectRect) ws).getWhiteboardPoint()); obj.setWidth((((WhiteboardObjectRect) ws)).getWidth()); obj.setColor(ws.getColor()); obj.setThickness(ws.getThickness()); wbSession.sendWhiteboardObject(obj); return obj; } else if (ws instanceof WhiteboardObjectCircle) { if (!supportedWBO.contains(WhiteboardObjectCircle.NAME)) return null; WhiteboardObjectCircle obj = (WhiteboardObjectCircle) wbSession.createWhiteboardObject(WhiteboardObjectCircle.NAME); ws.setID(obj.getID()); obj.setFill(((WhiteboardObjectCircle) ws).isFill()); obj.setRadius(((WhiteboardObjectCircle) ws).getRadius()); obj.setWhiteboardPoint(((WhiteboardObjectCircle) ws).getWhiteboardPoint()); obj.setBackgroundColor((((WhiteboardObjectCircle) ws)).getBackgroundColor()); obj.setColor(ws.getColor()); obj.setThickness(ws.getThickness()); wbSession.sendWhiteboardObject(obj); return obj; } else if (ws instanceof WhiteboardObjectText) { if (!supportedWBO.contains(WhiteboardObjectText.NAME)) return null; WhiteboardObjectText obj = (WhiteboardObjectText) wbSession.createWhiteboardObject(WhiteboardObjectText.NAME); ws.setID(obj.getID()); obj.setFontName(((WhiteboardObjectText) ws).getFontName()); obj.setFontSize(((WhiteboardObjectText) ws).getFontSize()); obj.setText(((WhiteboardObjectText) ws).getText()); obj.setWhiteboardPoint(((WhiteboardObjectText) ws).getWhiteboardPoint()); obj.setColor(ws.getColor()); obj.setThickness(ws.getThickness()); wbSession.sendWhiteboardObject(obj); return obj; } else if (ws instanceof WhiteboardObjectImage) { if (!supportedWBO.contains(WhiteboardObjectImage.NAME)) return null; WhiteboardObjectImage obj = (WhiteboardObjectImage) wbSession.createWhiteboardObject(WhiteboardObjectImage.NAME); ws.setID(obj.getID()); obj.setBackgroundImage(((WhiteboardObjectImage) ws).getBackgroundImage()); obj.setHeight(((WhiteboardObjectImage) ws).getHeight()); obj.setWhiteboardPoint(((WhiteboardObjectImage) ws).getWhiteboardPoint()); obj.setWidth(((WhiteboardObjectImage) ws).getWidth()); obj.setColor(ws.getColor()); obj.setThickness(ws.getThickness()); wbSession.sendWhiteboardObject(obj); return obj; } return null; }