diff options
author | Yana Stamcheva <yana@jitsi.org> | 2012-08-11 17:34:33 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2012-08-11 17:34:33 +0000 |
commit | 3301f2a10dd2999f830629bdc73b50fff0e40a59 (patch) | |
tree | 0a88e3b10770cd1a0f2c1fc4762f91fb0dd08272 /src/net | |
parent | a687c482c64c2e4751b371b820b9e6f83c78fec4 (diff) | |
download | jitsi-3301f2a10dd2999f830629bdc73b50fff0e40a59.zip jitsi-3301f2a10dd2999f830629bdc73b50fff0e40a59.tar.gz jitsi-3301f2a10dd2999f830629bdc73b50fff0e40a59.tar.bz2 |
Adds an optional signup link in provisioning authentication window.
Diffstat (limited to 'src/net')
4 files changed, 133 insertions, 12 deletions
diff --git a/src/net/java/sip/communicator/service/httputil/HttpUtils.java b/src/net/java/sip/communicator/service/httputil/HttpUtils.java index eb210c6..dedbd25 100644 --- a/src/net/java/sip/communicator/service/httputil/HttpUtils.java +++ b/src/net/java/sip/communicator/service/httputil/HttpUtils.java @@ -674,10 +674,13 @@ public class HttpUtils // if password is not saved ask user for credentials if(pass == null) { + AuthenticationWindow authWindow = new AuthenticationWindow( authUsername, null, - authscope.getHost(), true, null, errorMessage); + authscope.getHost(), true, null, errorMessage, + HttpUtilActivator.getResources().getSettingsString( + "plugin.provisioning.SIGN_UP_LINK")); authWindow.setVisible(true); if(!authWindow.isCanceled()) diff --git a/src/net/java/sip/communicator/util/UtilActivator.java b/src/net/java/sip/communicator/util/UtilActivator.java index 5f17974..61f1827 100644 --- a/src/net/java/sip/communicator/util/UtilActivator.java +++ b/src/net/java/sip/communicator/util/UtilActivator.java @@ -11,6 +11,7 @@ import java.net.*; import javax.imageio.*; +import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.keybindings.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.resources.*; @@ -44,6 +45,8 @@ public class UtilActivator private static ResourceManagementService resourceService; + private static BrowserLauncherService browserLauncherService; + private static BundleContext bundleContext; /** @@ -173,6 +176,24 @@ public class UtilActivator } /** + * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle + * context. + * @return the <tt>BrowserLauncherService</tt> obtained from the bundle + * context + */ + public static BrowserLauncherService getBrowserLauncher() + { + if (browserLauncherService == null) + { + browserLauncherService + = ServiceUtils.getService( + bundleContext, + BrowserLauncherService.class); + } + return browserLauncherService; + } + + /** * Returns the image corresponding to the given <tt>imageID</tt>. * * @param imageID the identifier of the image diff --git a/src/net/java/sip/communicator/util/swing/AuthenticationWindow.java b/src/net/java/sip/communicator/util/swing/AuthenticationWindow.java index e95cf74..4d2ec46 100644 --- a/src/net/java/sip/communicator/util/swing/AuthenticationWindow.java +++ b/src/net/java/sip/communicator/util/swing/AuthenticationWindow.java @@ -12,6 +12,7 @@ import java.awt.event.*; import javax.swing.*; import net.java.sip.communicator.util.*; +import net.java.sip.communicator.util.Logger; import org.jitsi.util.*; @@ -28,6 +29,11 @@ public class AuthenticationWindow private static final long serialVersionUID = 1L; /** + * Used for logging. + */ + private static Logger logger = Logger.getLogger(AuthenticationWindow.class); + + /** * Info text area. */ private final JTextArea infoTextArea = new JTextArea(); @@ -124,6 +130,11 @@ public class AuthenticationWindow private String passwordLabelText = null; /** + * The sign up link if specified. + */ + private String signupLink = null; + + /** * Creates an instance of the <tt>LoginWindow</tt>. * * @param server the server name @@ -135,7 +146,7 @@ public class AuthenticationWindow ImageIcon icon) { this(null, null, server, isUserNameEditable, false, - icon, null, null, null, null, null); + icon, null, null, null, null, null, null); } /** @@ -148,6 +159,9 @@ public class AuthenticationWindow * @param windowText customized window text * @param usernameLabelText customized username field label text * @param passwordLabelText customized password field label text + * @param errorMessage an error message if this dialog is shown to indicate + * the user that something went wrong + * @param signupLink an URL that allows the user to sign up */ private AuthenticationWindow(String userName, char[] password, @@ -159,7 +173,8 @@ public class AuthenticationWindow String windowText, String usernameLabelText, String passwordLabelText, - String errorMessage) + String errorMessage, + String signupLink) { super(false); @@ -168,6 +183,7 @@ public class AuthenticationWindow this.usernameLabelText = usernameLabelText; this.passwordLabelText = passwordLabelText; this.isRememberPassword = isRememberPassword; + this.signupLink = signupLink; init(userName, password, server, isUserNameEditable, icon, errorMessage); } @@ -263,7 +279,34 @@ public class AuthenticationWindow this(userName, password, server, isUserNameEditable, false, - icon, null, null, null, null, errorMessage); + icon, null, null, null, null, errorMessage, null); + } + + /** + * Creates an instance of the <tt>LoginWindow</tt>. + * + * @param userName the user name to set by default + * @param password the password to set by default + * @param server the server name this authentication window is about + * @param isUserNameEditable indicates if the user name should be editable + * by the user or not + * @param icon the icon displayed on the left of the authentication window + * @param errorMessage an error message explaining a reason for opening + * the authentication dialog (when a wrong password was provided, etc.) + * @param signupLink an URL that allows the user to sign up + */ + public AuthenticationWindow(String userName, + char[] password, + String server, + boolean isUserNameEditable, + ImageIcon icon, + String errorMessage, + String signupLink) + { + this(userName, password, server, + isUserNameEditable, + false, + icon, null, null, null, null, errorMessage, signupLink); } /** @@ -283,7 +326,7 @@ public class AuthenticationWindow boolean isUserNameEditable, ImageIcon icon) { - this(userName, password, server, isUserNameEditable, icon, null); + this(userName, password, server, isUserNameEditable, icon, null, null); } /** @@ -400,17 +443,25 @@ public class AuthenticationWindow labelsPanel.add(uinLabel); labelsPanel.add(passwdLabel); - labelsPanel.add(new JLabel()); - - this.rememberPassCheckBox.setOpaque(false); - this.rememberPassCheckBox.setBorder(null); TransparentPanel textFieldsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8)); textFieldsPanel.add(uinValue); textFieldsPanel.add(passwdField); - textFieldsPanel.add(rememberPassCheckBox); + + JPanel southFieldsPanel = new TransparentPanel(new GridLayout(1, 2)); + + this.rememberPassCheckBox.setOpaque(false); + this.rememberPassCheckBox.setBorder(null); + + southFieldsPanel.add(rememberPassCheckBox); + if (signupLink != null && signupLink.length() > 0) + southFieldsPanel.add(createWebSignupLabel( + UtilActivator.getResources().getI18NString( + "plugin.simpleaccregwizz.SIGNUP"), signupLink)); + else + southFieldsPanel.add(new JLabel()); boolean allowRememberPassword = true; @@ -440,9 +491,13 @@ public class AuthenticationWindow mainPanel.setBorder( BorderFactory.createEmptyBorder(20, 0, 20, 20)); + JPanel mainFieldsPanel = new TransparentPanel(new BorderLayout(0, 10)); + mainFieldsPanel.add(labelsPanel, BorderLayout.WEST); + mainFieldsPanel.add(textFieldsPanel, BorderLayout.CENTER); + mainFieldsPanel.add(southFieldsPanel, BorderLayout.SOUTH); + mainPanel.add(infoTextArea, BorderLayout.NORTH); - mainPanel.add(labelsPanel, BorderLayout.WEST); - mainPanel.add(textFieldsPanel, BorderLayout.CENTER); + mainPanel.add(mainFieldsPanel, BorderLayout.CENTER); mainPanel.add(southEastPanel, BorderLayout.SOUTH); this.getContentPane().add(mainPanel, BorderLayout.EAST); @@ -633,4 +688,45 @@ public class AuthenticationWindow { return isRememberPassword; } + + /** + * Creates the subscribe label. + * @param linkName the link name + * @return the newly created subscribe label + */ + private Component createWebSignupLabel( String linkName, + final String linkURL) + { + JLabel subscribeLabel = + new JLabel("<html><a href=''>" + + linkName + + "</a></html>", + JLabel.RIGHT); + + subscribeLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); + subscribeLabel.setToolTipText( + UtilActivator.getResources().getI18NString( + "plugin.simpleaccregwizz.SPECIAL_SIGNUP")); + subscribeLabel.addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent e) + { + try + { + UtilActivator.getBrowserLauncher() + .openURL(linkURL); + } + catch (UnsupportedOperationException ex) + { + // This should not happen, because we check if the + // operation is supported, before adding the sign + // up. + logger.error("The web sign up is not supported.", + ex); + } + } + }); + return subscribeLabel; + } + } diff --git a/src/net/java/sip/communicator/util/util.manifest.mf b/src/net/java/sip/communicator/util/util.manifest.mf index c04fbe3..21e0e63 100644 --- a/src/net/java/sip/communicator/util/util.manifest.mf +++ b/src/net/java/sip/communicator/util/util.manifest.mf @@ -31,6 +31,7 @@ Import-Package: com.sun.awt, net.java.sip.communicator.service.netaddr, net.java.sip.communicator.service.netaddr.event, net.java.sip.communicator.service.contactlist, + net.java.sip.communicator.service.browserlauncher, org.apache.xml.serialize, org.jitsi.service.configuration, org.jitsi.service.resources, |