|
Before Width: | Height: | Size: 543 B After Width: | Height: | Size: 1020 B |
|
After Width: | Height: | Size: 554 B |
|
After Width: | Height: | Size: 553 B |
|
Before Width: | Height: | Size: 736 B After Width: | Height: | Size: 587 B |
|
Before Width: | Height: | Size: 781 B After Width: | Height: | Size: 687 B |
|
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 584 B |
|
Before Width: | Height: | Size: 585 B After Width: | Height: | Size: 655 B |
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.call;
|
||||
|
||||
import net.java.sip.communicator.impl.gui.*;
|
||||
import net.java.sip.communicator.service.neomedia.*;
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.Timer;
|
||||
|
||||
/**
|
||||
* @author Damian Minkov
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class ParanoiaTimerSecurityPanel
|
||||
extends SecurityPanel<SrtpControl>
|
||||
{
|
||||
/**
|
||||
* The security timer.
|
||||
*/
|
||||
private Timer timer = new Timer(true);
|
||||
|
||||
/**
|
||||
* Creates an instance of this <tt>ParanoiaTimerSecurityPanel</tt>.
|
||||
*/
|
||||
ParanoiaTimerSecurityPanel()
|
||||
{
|
||||
super(null);
|
||||
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes contained components.
|
||||
*/
|
||||
private void initComponents()
|
||||
{
|
||||
final SimpleDateFormat format = new SimpleDateFormat("mm:ss");
|
||||
final Calendar c = Calendar.getInstance();
|
||||
final JLabel counter = new JLabel();
|
||||
|
||||
counter.setForeground(Color.red);
|
||||
counter.setFont(counter.getFont().deriveFont(
|
||||
(float)(counter.getFont().getSize() + 5)));
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
setBorder(
|
||||
BorderFactory.createEmptyBorder(20, 20, 20, 20));
|
||||
|
||||
GridBagConstraints constraints = new GridBagConstraints();
|
||||
|
||||
JLabel messageLabel = new JLabel(GuiActivator.getResources()
|
||||
.getI18NString("service.gui.security.SECURITY_ALERT"));
|
||||
|
||||
messageLabel.setForeground(Color.WHITE);
|
||||
|
||||
constraints.anchor = GridBagConstraints.CENTER;
|
||||
constraints.fill = GridBagConstraints.NONE;
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy = 0;
|
||||
add(messageLabel, constraints);
|
||||
|
||||
constraints.anchor = GridBagConstraints.CENTER;
|
||||
constraints.fill = GridBagConstraints.NONE;
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy = 1;
|
||||
add(counter, constraints);
|
||||
|
||||
ZrtpControl zrtpControl = null;
|
||||
if (securityControl instanceof ZrtpControl)
|
||||
zrtpControl = (ZrtpControl) securityControl;
|
||||
|
||||
int initialSeconds = 0;
|
||||
|
||||
if (zrtpControl != null)
|
||||
initialSeconds = (int) zrtpControl.getTimeoutValue()/1000;
|
||||
|
||||
c.set(Calendar.HOUR, 0);
|
||||
c.set(Calendar.MINUTE, 0);
|
||||
c.set(Calendar.SECOND, initialSeconds);
|
||||
|
||||
counter.setText(format.format(c.getTime()));
|
||||
|
||||
if (initialSeconds > 0)
|
||||
timer.schedule(new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
c.add(Calendar.SECOND, -1);
|
||||
counter.setText(format.format(c.getTime()));
|
||||
}
|
||||
}, 0, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the security timer.
|
||||
*
|
||||
* @param evt the security event of which we're notified
|
||||
*/
|
||||
public void securityOn(CallPeerSecurityOnEvent evt)
|
||||
{
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Nothing to do here.
|
||||
*
|
||||
* @param evt the security event of which we're notified
|
||||
*/
|
||||
public void securityOff(CallPeerSecurityOffEvent evt) {}
|
||||
|
||||
/**
|
||||
* Indicates that the security is time-outed, is not supported by the
|
||||
* other end.
|
||||
* @param evt Details about the event that caused this message.
|
||||
*/
|
||||
public void securityTimeout(CallPeerSecurityTimeoutEvent evt)
|
||||
{
|
||||
timer.cancel();
|
||||
|
||||
// fail peer, call
|
||||
if(evt.getSource() instanceof AbstractCallPeer)
|
||||
{
|
||||
AbstractCallPeer peer = (AbstractCallPeer)evt.getSource();
|
||||
peer.setState(CallPeerState.FAILED, "Encryption Required!");
|
||||
}
|
||||
}
|
||||
|
||||
public void loadSkin()
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.util.swing;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.jvnet.lafwidget.animation.*;
|
||||
|
||||
/**
|
||||
* The <tt>FadeInBaloonPanel</tt> is a semi-transparent "balloon" panel, which
|
||||
* could be shown in a glass pane for example. You can define a begin point,
|
||||
* where the balloon triangle would show.
|
||||
*
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class FadeInBalloonPanel
|
||||
extends TransparentPanel
|
||||
{
|
||||
/**
|
||||
* The begin point, where the balloon triangle will be shown.
|
||||
*/
|
||||
private Point beginPoint;
|
||||
|
||||
/**
|
||||
* The begin point shift, which defines the rectangle point shift.
|
||||
*/
|
||||
private final static int beginPointShift = 6;
|
||||
|
||||
/**
|
||||
* Sets the begin point.
|
||||
*
|
||||
* @param beginPoint the begin point
|
||||
*/
|
||||
public void setBeginPoint(Point beginPoint)
|
||||
{
|
||||
this.beginPoint = beginPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the <code>paintComponent</code> method of <tt>JButton</tt> to
|
||||
* paint the button background and icon, and all additional effects of this
|
||||
* configurable button.
|
||||
*
|
||||
* @param g The Graphics object.
|
||||
*/
|
||||
protected void paintComponent(Graphics g)
|
||||
{
|
||||
g = g.create();
|
||||
try
|
||||
{
|
||||
internalPaintComponent((Graphics2D) g);
|
||||
}
|
||||
finally
|
||||
{
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints this button.
|
||||
* @param g the <tt>Graphics</tt> object used for painting
|
||||
*/
|
||||
private void internalPaintComponent(Graphics2D g)
|
||||
{
|
||||
AntialiasingManager.activateAntialiasing(g);
|
||||
/*
|
||||
* As JComponent#paintComponent says, if you do not invoke super's
|
||||
* implementation you must honor the opaque property, that is if this
|
||||
* component is opaque, you must completely fill in the background in a
|
||||
* non-opaque color. If you do not honor the opaque property you will
|
||||
* likely see visual artifacts.
|
||||
*/
|
||||
if (isOpaque())
|
||||
{
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
// Paint a roll over fade out.
|
||||
FadeTracker fadeTracker = FadeTracker.getInstance();
|
||||
|
||||
float visibility = isVisible() ? 0.8f : 0.0f;
|
||||
if (fadeTracker.isTracked(this, FadeKind.ROLLOVER))
|
||||
{
|
||||
visibility = fadeTracker.getFade(this, FadeKind.ROLLOVER);
|
||||
}
|
||||
|
||||
g.setColor(new Color(0f, 0f, 0f, visibility));
|
||||
|
||||
int y = 0;
|
||||
|
||||
// draw triangle (polygon)
|
||||
if (beginPoint != null)
|
||||
{
|
||||
y = beginPointShift;
|
||||
|
||||
int x1Points[] = { beginPoint.x,
|
||||
beginPoint.x + beginPointShift,
|
||||
beginPoint.x - beginPointShift};
|
||||
|
||||
int y1Points[] = { beginPoint.y,
|
||||
beginPoint.y + beginPointShift,
|
||||
beginPoint.y + beginPointShift};
|
||||
|
||||
GeneralPath polygon =
|
||||
new GeneralPath(GeneralPath.WIND_EVEN_ODD,
|
||||
x1Points.length);
|
||||
|
||||
polygon.moveTo(x1Points[0], y1Points[0]);
|
||||
|
||||
for (int index = 1; index < x1Points.length; index++) {
|
||||
polygon.lineTo(x1Points[index], y1Points[index]);
|
||||
};
|
||||
|
||||
polygon.closePath();
|
||||
g.fill(polygon);
|
||||
}
|
||||
|
||||
if (visibility != 0.0f)
|
||||
{
|
||||
g.fillRoundRect(
|
||||
0, y, this.getWidth(), this.getHeight(), 10, 10);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The <tt>ButtonRepaintCallback</tt> is charged to repaint this button
|
||||
* when the fade animation is performed.
|
||||
*/
|
||||
private class PanelRepaintCallback implements FadeTrackerCallback
|
||||
{
|
||||
public void fadeEnded(FadeKind arg0)
|
||||
{
|
||||
repaintLater();
|
||||
}
|
||||
|
||||
public void fadePerformed(FadeKind arg0, float arg1)
|
||||
{
|
||||
repaintLater();
|
||||
}
|
||||
|
||||
private void repaintLater()
|
||||
{
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
FadeInBalloonPanel.this.repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fadeReversed(FadeKind arg0, boolean arg1, float arg2)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows/hides this panel.
|
||||
*
|
||||
* @param isVisible <tt>true</tt> to show this panel, <tt>false</tt> to
|
||||
* hide it
|
||||
*/
|
||||
public void setVisible(boolean isVisible)
|
||||
{
|
||||
FadeTracker fadeTracker = FadeTracker.getInstance();
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
fadeTracker.trackFadeIn(FadeKind.ROLLOVER,
|
||||
FadeInBalloonPanel.this,
|
||||
true,
|
||||
new PanelRepaintCallback());
|
||||
}
|
||||
else
|
||||
{
|
||||
fadeTracker.trackFadeOut(FadeKind.ROLLOVER,
|
||||
FadeInBalloonPanel.this,
|
||||
true,
|
||||
new PanelRepaintCallback());
|
||||
}
|
||||
}
|
||||
}
|
||||