diff options
author | Yana Stamcheva <yana@jitsi.org> | 2010-09-29 09:53:51 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2010-09-29 09:53:51 +0000 |
commit | 24ed71d202a110a4e949aef91ffd47081bb0a1fc (patch) | |
tree | 378eebb58c5eeee5cb6bf85cf227d1faca65dec1 /src/net | |
parent | fcfaa293010f62110e1f9ce959b6faf6f5cefb19 (diff) | |
download | jitsi-24ed71d202a110a4e949aef91ffd47081bb0a1fc.zip jitsi-24ed71d202a110a4e949aef91ffd47081bb0a1fc.tar.gz jitsi-24ed71d202a110a4e949aef91ffd47081bb0a1fc.tar.bz2 |
Moved the CertificateVerificationService to its own bundle.
Moved SIPCommHTMLEditorKit and SIPCommHTMLEditorPane to the util package.
Diffstat (limited to 'src/net')
18 files changed, 325 insertions, 111 deletions
diff --git a/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java b/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java new file mode 100644 index 0000000..2ae037a --- /dev/null +++ b/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java @@ -0,0 +1,128 @@ +/* + * SIP Communicator, 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.certificate; + +import net.java.sip.communicator.service.certificate.*; +import net.java.sip.communicator.service.configuration.*; +import net.java.sip.communicator.service.fileaccess.*; +import net.java.sip.communicator.service.resources.*; +import net.java.sip.communicator.util.*; + +import org.osgi.framework.*; + +/** + * The certificate verification bundle activator. + * + * @author Yana Stamcheva + */ +public class CertificateVerificationActivator + implements BundleActivator +{ + /** + * The bundle context for this bundle. + */ + static BundleContext bundleContext; + + /** + * The configuration service. + */ + private static ConfigurationService configService; + + /** + * The service giving access to files. + */ + private static FileAccessService fileAccessService; + + /** + * The service giving access to all resources. + */ + private static ResourceManagementService resourcesService; + + /** + * Called when this bundle is started. + * + * @param bc The execution context of the bundle being started. + * @throws Exception if the bundle is not correctly started + */ + public void start(BundleContext bc) throws Exception + { + bundleContext = bc; + + bundleContext.registerService( + CertificateVerificationService.class.getName(), + new CertificateVerificationServiceImpl(), + null); + } + + /** + * Called when this bundle is stopped so the Framework can perform the + * bundle-specific activities necessary to stop the bundle. + * + * @param bc The execution context of the bundle being stopped. + * @throws Exception If this method throws an exception, the bundle is + * still marked as stopped, and the Framework will remove the bundle's + * listeners, unregister all services registered by the bundle, and + * release all services used by the bundle. + */ + public void stop(BundleContext bc) throws Exception + { + } + + /** + * Returns the <tt>ConfigurationService</tt> obtained from the bundle + * context. + * @return the <tt>ConfigurationService</tt> obtained from the bundle + * context + */ + public static ConfigurationService getConfigurationService() + { + if(configService == null) + { + configService + = ServiceUtils.getService( + bundleContext, + ConfigurationService.class); + } + return configService; + } + + /** + * Returns the <tt>FileAccessService</tt> obtained from the bundle context. + * + * @return the <tt>FileAccessService</tt> obtained from the bundle context + */ + public static FileAccessService getFileAccessService() + { + if (fileAccessService == null) + { + fileAccessService + = ServiceUtils.getService( + bundleContext, + FileAccessService.class); + } + return fileAccessService; + } + + /** + * Returns the <tt>ResourceManagementService</tt>, through which we will + * access all resources. + * + * @return the <tt>ResourceManagementService</tt>, through which we will + * access all resources. + */ + public static ResourceManagementService getResources() + { + if (resourcesService == null) + { + resourcesService + = ServiceUtils.getService( + bundleContext, + ResourceManagementService.class); + } + return resourcesService; + } +} diff --git a/src/net/java/sip/communicator/impl/gui/main/login/CertificateVerificationServiceImpl.java b/src/net/java/sip/communicator/impl/certificate/CertificateVerificationServiceImpl.java index 1ad6033..2411613 100644 --- a/src/net/java/sip/communicator/impl/gui/main/login/CertificateVerificationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/certificate/CertificateVerificationServiceImpl.java @@ -4,7 +4,7 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package net.java.sip.communicator.impl.gui.main.login; +package net.java.sip.communicator.impl.certificate; import java.awt.*; import java.awt.event.*; @@ -24,19 +24,17 @@ import javax.naming.ldap.*; import javax.net.ssl.*; import javax.security.auth.x500.*; -import net.java.sip.communicator.service.gui.*; -import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.service.certificate.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.swing.*; - /** * Asks the user for permission for the * certificates which are for some reason not valid and not globally trusted. * * @author Damian Minkov + * @author Yana Stamcheva */ public class CertificateVerificationServiceImpl implements CertificateVerificationService @@ -88,11 +86,11 @@ public class CertificateVerificationServiceImpl private File getKeyStoreLocation() throws Exception { - String keyStoreFile = GuiActivator.getConfigurationService() - .getString(KEYSTORE_FILE_PROP); + String keyStoreFile = CertificateVerificationActivator. + getConfigurationService().getString(KEYSTORE_FILE_PROP); if(keyStoreFile == null || keyStoreFile.length() == 0) - return GuiActivator.getFileAccessService() + return CertificateVerificationActivator.getFileAccessService() .getPrivatePersistentFile(KEY_STORE_FILE_NAME); File f = new File(keyStoreFile); @@ -106,10 +104,10 @@ public class CertificateVerificationServiceImpl // An old version used to store the whole path to the file // and if the user changes location of its home dir // it breaks things. - GuiActivator.getConfigurationService().removeProperty( - KEYSTORE_FILE_PROP); + CertificateVerificationActivator.getConfigurationService() + .removeProperty(KEYSTORE_FILE_PROP); - return GuiActivator.getFileAccessService() + return CertificateVerificationActivator.getFileAccessService() .getPrivatePersistentFile(KEY_STORE_FILE_NAME); } } @@ -211,6 +209,8 @@ public class CertificateVerificationServiceImpl * @param toHost the host we are connecting. * @param toPort the port used when connecting. * @return SSL context object + * + * @throws IOException if the SSLContext could not be initialized */ public SSLContext getSSLContext(String toHost, int toPort) throws IOException @@ -351,7 +351,8 @@ public class CertificateVerificationServiceImpl * which will be always trusted. */ SIPCommCheckBox alwaysTrustCheckBox = new SIPCommCheckBox( - GuiActivator.getResources().getI18NString("service.gui.ALWAYS_TRUST"), + CertificateVerificationActivator.getResources() + .getI18NString("service.gui.ALWAYS_TRUST"), false); /** @@ -361,16 +362,19 @@ public class CertificateVerificationServiceImpl /** * Creates the dialog. - * @param certs - * @param host - * @param port + * + * @param certs the certificates list + * @param host the host + * @param port the port */ - public VerifyCertificateDialog(Certificate[] certs, String host, int port) + public VerifyCertificateDialog( Certificate[] certs, + String host, + int port) { - super(GuiActivator.getUIService().getMainFrame(), false); + super(false); - setTitle(GuiActivator.getResources().getI18NString( - "service.gui.CERT_DIALOG_TITLE")); + setTitle(CertificateVerificationActivator.getResources() + .getI18NString("service.gui.CERT_DIALOG_TITLE")); setModal(true); // for now shows only the first certificate from the chain @@ -400,17 +404,17 @@ public class CertificateVerificationServiceImpl northPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5)); JLabel imgLabel = new JLabel( - GuiActivator.getResources().getImage( + CertificateVerificationActivator.getResources().getImage( "impl.media.security.zrtp.CONF_ICON")); imgLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); northPanel.add(imgLabel, BorderLayout.WEST); - String descriptionTxt = GuiActivator.getResources() - .getI18NString( + String descriptionTxt = CertificateVerificationActivator + .getResources().getI18NString( "service.gui.CERT_DIALOG_DESCRIPTION_TXT", new String[]{ - GuiActivator.getResources().getSettingsString( - "service.gui.APPLICATION_NAME"), + CertificateVerificationActivator.getResources() + .getSettingsString("service.gui.APPLICATION_NAME"), host, String.valueOf(port)}); @@ -436,8 +440,8 @@ public class CertificateVerificationServiceImpl contentPane.add(southPanel, BorderLayout.SOUTH); certButton = new JButton(); - certButton.setText(GuiActivator.getResources() - .getI18NString("service.gui.SHOW_CERT")); + certButton.setText(CertificateVerificationActivator + .getResources().getI18NString("service.gui.SHOW_CERT")); certButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -453,7 +457,9 @@ public class CertificateVerificationServiceImpl TransparentPanel secondButonPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); JButton cancelButton = new JButton( - GuiActivator.getResources().getI18NString("service.gui.CANCEL")); + CertificateVerificationActivator.getResources() + .getI18NString("service.gui.CANCEL")); + cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -462,7 +468,9 @@ public class CertificateVerificationServiceImpl } }); JButton continueButton = new JButton( - GuiActivator.getResources().getI18NString("service.gui.CONTINUE")); + CertificateVerificationActivator.getResources() + .getI18NString("service.gui.CONTINUE")); + continueButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) @@ -487,8 +495,9 @@ public class CertificateVerificationServiceImpl if(certOpened) { certPanel.removeAll(); - certButton.setText(GuiActivator.getResources() - .getI18NString("service.gui.SHOW_CERT")); + certButton.setText( + CertificateVerificationActivator.getResources() + .getI18NString("service.gui.SHOW_CERT")); certPanel.revalidate(); certPanel.repaint(); @@ -527,9 +536,10 @@ public class CertificateVerificationServiceImpl } }); - certButton.setText(GuiActivator.getResources() - .getI18NString("service.gui.HIDE_CERT")); - + certButton.setText( + CertificateVerificationActivator.getResources() + .getI18NString("service.gui.HIDE_CERT")); + certPanel.revalidate(); certPanel.repaint(); // restore default values for prefered size, @@ -569,9 +579,10 @@ public class CertificateVerificationServiceImpl } /** + * Returns the display component for X509 certificate. * - * @param certificate - * @return + * @param certificate the certificate to show + * @return the created component */ private static Component getX509DisplayComponent( X509Certificate certificate) @@ -579,10 +590,11 @@ public class CertificateVerificationServiceImpl Insets valueInsets = new Insets(2,10,0,0); Insets titleInsets = new Insets(10,5,0,0); - ResourceManagementService resources = GuiActivator.getResources(); + ResourceManagementService resources + = CertificateVerificationActivator.getResources(); - TransparentPanel certDisplayPanel = - new TransparentPanel(new GridBagLayout()); + TransparentPanel certDisplayPanel + = new TransparentPanel(new GridBagLayout()); int currentRow = 0; @@ -1016,9 +1028,10 @@ public class CertificateVerificationServiceImpl /** * Not used. - * @return + * @return UnsupportedOperationException */ - public X509Certificate[] getAcceptedIssuers() { + public X509Certificate[] getAcceptedIssuers() + { throw new UnsupportedOperationException(); } @@ -1044,16 +1057,20 @@ public class CertificateVerificationServiceImpl public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { - if(GuiActivator.getConfigurationService().getBoolean( - CertificateVerificationService.ALWAYS_TRUST_MODE_ENABLED_PROP_NAME, - false)) - return; + if(CertificateVerificationActivator.getConfigurationService() + .getBoolean(CertificateVerificationService + .ALWAYS_TRUST_MODE_ENABLED_PROP_NAME, + false)) + { + return; + } try { tm.checkServerTrusted(chain, authType); // everything is fine certificate is globally trusted - } catch (CertificateException certificateException) + } + catch (CertificateException certificateException) { KeyStore kStore = getKeyStore(); diff --git a/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf b/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf new file mode 100644 index 0000000..03a8ee7 --- /dev/null +++ b/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf @@ -0,0 +1,18 @@ +Bundle-Activator: net.java.sip.communicator.impl.certificate.CertificateVerificationActivator +Bundle-Name: Certificate Verification Activator +Bundle-Description: A bundle that offers certificate verification +Bundle-Vendor: sip-communicator.org +Bundle-Version: 0.0.1 +System-Bundle: yes +Export-Package: net.java.sip.communicator.service.certificate +Import-Package: org.osgi.framework, + net.java.sip.communicator.util, + net.java.sip.communicator.service.resources, + net.java.sip.communicator.service.fileaccess, + net.java.sip.communicator.service.configuration, + net.java.sip.communicator.util.swing, + javax.net.ssl, + javax.security.auth.x500, + javax.naming, + javax.naming.ldap, + javax.swing diff --git a/src/net/java/sip/communicator/impl/gui/GuiActivator.java b/src/net/java/sip/communicator/impl/gui/GuiActivator.java index b32ad69..ef0f8d3 100644 --- a/src/net/java/sip/communicator/impl/gui/GuiActivator.java +++ b/src/net/java/sip/communicator/impl/gui/GuiActivator.java @@ -138,11 +138,6 @@ public class GuiActivator implements BundleActivator (ShutdownService) uiService, null); - bundleContext.registerService( - CertificateVerificationService.class.getName(), - new CertificateVerificationServiceImpl(), - null); - logger.logEntry(); } finally diff --git a/src/net/java/sip/communicator/impl/gui/main/account/Account.java b/src/net/java/sip/communicator/impl/gui/main/account/Account.java index ea9823f..4efd05f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/account/Account.java +++ b/src/net/java/sip/communicator/impl/gui/main/account/Account.java @@ -231,7 +231,7 @@ public class Account { ProtocolIcon protocolIcon = protocolProvider.getProtocolIcon(); Image protocolImage - = GuiUtils.getBytesInImage( + = ImageUtils.getBytesInImage( protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_32x32)); if (protocolImage != null) @@ -240,12 +240,12 @@ public class Account } else { - protocolImage = GuiUtils.getBytesInImage( + protocolImage = ImageUtils.getBytesInImage( protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_48x48)); if (protocolImage == null) protocolImage - = GuiUtils.getBytesInImage( + = ImageUtils.getBytesInImage( protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_64x64)); if (protocolImage != null) diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java index bcd3656..dede6e0 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java @@ -161,7 +161,7 @@ public class ChatTransportSelectorBox { return ImageLoader.badgeImageWithProtocolIndex( - GuiUtils.getBytesInImage( + ImageUtils.getBytesInImage( chatTransport.getStatus().getStatusIcon()), chatTransport.getProtocolProvider()); } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java index b764ec1..3ce1324 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java @@ -461,7 +461,7 @@ public class AddContactDialog if (provider != null) { Image protocolImg - = GuiUtils.getBytesInImage(provider.getProtocolIcon() + = ImageUtils.getBytesInImage(provider.getProtocolIcon() .getIcon(ProtocolIcon.ICON_SIZE_16x16)); if (protocolImg != null) diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/MetaContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/MetaContactRightButtonMenu.java index 3af0051..d123d88 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/MetaContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/MetaContactRightButtonMenu.java @@ -753,7 +753,7 @@ public class MetaContactRightButtonMenu { return ImageLoader.badgeImageWithProtocolIndex( - GuiUtils.getBytesInImage( + ImageUtils.getBytesInImage( protoContact.getPresenceStatus().getStatusIcon()), protoContact.getProtocolProvider()); } diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java b/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java index 1b8425f..7b2be23 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java @@ -40,17 +40,24 @@ public class SimpleStatusMenu /** * Creates an instance of <tt>SimpleStatusMenu</tt>. * - * @param protocolProvider The protocol provider. + * @param protocolProvider the protocol provider */ public SimpleStatusMenu(ProtocolProviderService protocolProvider) { this(protocolProvider, protocolProvider.getAccountID().getDisplayName(), - GuiUtils.getBytesInImage( + ImageUtils.getBytesInImage( protocolProvider.getProtocolIcon().getIcon( ProtocolIcon.ICON_SIZE_16x16))); } + /** + * Creates an instance of <tt>SimpleStatusMenu</tt>. + * + * @param protocolProvider the protocol provider + * @param displayName the display name for the menu + * @param onlineImage the image used for the online state + */ private SimpleStatusMenu(ProtocolProviderService protocolProvider, String displayName, Image onlineImage) @@ -167,13 +174,13 @@ public class SimpleStatusMenu public void loadSkin() { super.loadSkin(); - setIcon(new ImageIcon(GuiUtils.getBytesInImage( + setIcon(new ImageIcon(ImageUtils.getBytesInImage( protocolProvider.getProtocolIcon().getIcon( ProtocolIcon.ICON_SIZE_16x16)))); onlineItem.setIcon(getIcon()); offlineItem.setIcon( new ImageIcon(LightGrayFilter.createDisabledImage( - GuiUtils.getBytesInImage( + ImageUtils.getBytesInImage( protocolProvider.getProtocolIcon().getIcon( ProtocolIcon.ICON_SIZE_16x16))))); } diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java index 2bf04a4..78e2e2a 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -1305,13 +1305,13 @@ public class ImageLoader Image statusImage; if (presence != null) { - statusImage = GuiUtils.getBytesInImage( + statusImage = ImageUtils.getBytesInImage( presence.getPresenceStatus().getStatusIcon()); } else { statusImage - = GuiUtils.getBytesInImage(pps.getProtocolIcon().getIcon( + = ImageUtils.getBytesInImage(pps.getProtocolIcon().getIcon( ProtocolIcon.ICON_SIZE_16x16)); if (!pps.isRegistered()) @@ -1427,10 +1427,10 @@ public class ImageLoader ProtocolIcon protocolIcon = protocolProvider.getProtocolIcon(); if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_64x64)) - image = GuiUtils.getBytesInImage( + image = ImageUtils.getBytesInImage( protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_64x64)); else if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_48x48)) - image = GuiUtils.getBytesInImage( + image = ImageUtils.getBytesInImage( protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_48x48)); } diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java index a8f29d4..8d8b06d 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java @@ -20,7 +20,7 @@ import net.java.sip.communicator.util.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.inputevt.*; import net.java.sip.communicator.impl.protocol.jabber.sasl.*; -import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.certificate.*; import org.jivesoftware.smack.*; import org.jivesoftware.smack.packet.*; diff --git a/src/net/java/sip/communicator/impl/protocol/sip/net/SslNetworkLayer.java b/src/net/java/sip/communicator/impl/protocol/sip/net/SslNetworkLayer.java index ce925be..eeb5584 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/net/SslNetworkLayer.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/net/SslNetworkLayer.java @@ -15,7 +15,7 @@ import javax.net.ssl.*; import gov.nist.core.net.*; import net.java.sip.communicator.impl.protocol.sip.*; -import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.certificate.*; import net.java.sip.communicator.util.*; import org.osgi.framework.*; diff --git a/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf index a1cc7da..ac7263a 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf +++ b/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf @@ -38,7 +38,7 @@ Import-Package: org.apache.log4j, net.java.sip.communicator.service.configuration, net.java.sip.communicator.service.credentialsstorage, net.java.sip.communicator.service.configuration.event, - net.java.sip.communicator.service.gui, + net.java.sip.communicator.service.certificate, net.java.sip.communicator.service.neomedia, net.java.sip.communicator.service.neomedia.device, net.java.sip.communicator.service.neomedia.event, diff --git a/src/net/java/sip/communicator/service/gui/CertificateVerificationService.java b/src/net/java/sip/communicator/service/certificate/CertificateVerificationService.java index c76626d..1543751 100644 --- a/src/net/java/sip/communicator/service/gui/CertificateVerificationService.java +++ b/src/net/java/sip/communicator/service/certificate/CertificateVerificationService.java @@ -4,7 +4,7 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package net.java.sip.communicator.service.gui; +package net.java.sip.communicator.service.certificate; import java.io.*; import java.security.*; diff --git a/src/net/java/sip/communicator/util/GuiUtils.java b/src/net/java/sip/communicator/util/GuiUtils.java index ace1efe..4bcdd6f 100644 --- a/src/net/java/sip/communicator/util/GuiUtils.java +++ b/src/net/java/sip/communicator/util/GuiUtils.java @@ -9,10 +9,8 @@ package net.java.sip.communicator.util; import java.awt.*; import java.awt.font.*; import java.awt.geom.*; -import java.io.*; import java.util.*; -import javax.imageio.*; import javax.swing.*; /** @@ -26,11 +24,6 @@ import javax.swing.*; public class GuiUtils { /** - * The logger for this class. - */ - private static Logger logger = Logger.getLogger(GuiUtils.class); - - /** * List of all windows owned by the app. */ private static final ArrayList<Window> WINDOW_LIST @@ -505,25 +498,4 @@ public class GuiUtils } } } - - /** - * Loads an image from a given bytes array. - * @param imageBytes The bytes array to load the image from. - * @return The image for the given bytes array. - */ - public static Image getBytesInImage(byte[] imageBytes) - { - Image image = null; - try - { - image = ImageIO.read( - new ByteArrayInputStream(imageBytes)); - - } - catch (Exception e) - { - logger.error("Failed to convert bytes to image.", e); - } - return image; - } } diff --git a/src/net/java/sip/communicator/util/ImageUtils.java b/src/net/java/sip/communicator/util/ImageUtils.java index 5562408..c0a7f70 100644 --- a/src/net/java/sip/communicator/util/ImageUtils.java +++ b/src/net/java/sip/communicator/util/ImageUtils.java @@ -283,7 +283,9 @@ public class ImageUtils int width = source.getWidth(null); int height = source.getHeight(null); - BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + BufferedImage image + = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics graphics = image.createGraphics(); graphics.drawImage(source, 0, 0, null); graphics.dispose(); @@ -311,4 +313,25 @@ public class ImageUtils return out.toByteArray(); } + + /** + * Loads an image from a given bytes array. + * @param imageBytes The bytes array to load the image from. + * @return The image for the given bytes array. + */ + public static Image getBytesInImage(byte[] imageBytes) + { + Image image = null; + try + { + image = ImageIO.read( + new ByteArrayInputStream(imageBytes)); + + } + catch (Exception e) + { + logger.error("Failed to convert bytes to image.", e); + } + return image; + } } diff --git a/src/net/java/sip/communicator/impl/gui/utils/SIPCommHTMLEditorKit.java b/src/net/java/sip/communicator/util/swing/SIPCommHTMLEditorKit.java index d717548..b6277f0 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/SIPCommHTMLEditorKit.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommHTMLEditorKit.java @@ -5,7 +5,7 @@ * See terms of license at gnu.org. */ -package net.java.sip.communicator.impl.gui.utils; +package net.java.sip.communicator.util.swing; import java.awt.*; @@ -24,6 +24,12 @@ public class SIPCommHTMLEditorKit extends HTMLEditorKit { private final JComponent container; + /** + * Creates an instance of <tt>SIPCommHTMLEditorKit</tt> by specifying the + * container, where the editor kit would be used. + * + * @param container + */ public SIPCommHTMLEditorKit(JComponent container) { this.container = container; @@ -31,6 +37,8 @@ public class SIPCommHTMLEditorKit extends HTMLEditorKit /** * Returns the extended <tt>HTMLFactory</tt> defined here. + * + * @return the extended view factory */ public ViewFactory getViewFactory() { @@ -62,6 +70,10 @@ public class SIPCommHTMLEditorKit extends HTMLEditorKit } } + /** + * An extended component view, which provides horizontal and vertical + * filling. + */ private class MyComponentView extends ComponentView { /** @@ -153,6 +165,11 @@ public class SIPCommHTMLEditorKit extends HTMLEditorKit */ static class ParagraphViewX extends ParagraphView { + /** + * Creates an instance of <tt>ParagraphViewX</tt>. + * + * @param elem the element that this view is responsible for + */ public ParagraphViewX(Element elem) { super(elem); @@ -163,6 +180,10 @@ public class SIPCommHTMLEditorKit extends HTMLEditorKit * is implemented to forward the request to the logical * view by calling getMinimumSpan, getPreferredSpan, and * getMaximumSpan on it. + * + * @param axis the axis, for which we calculate size requirements + * @param sizeRequirements the initial size requirements + * @return the recalculated size requirements for the given axis */ protected SizeRequirements calculateMinorAxisRequirements ( int axis, SizeRequirements sizeRequirements) diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/StyledHTMLEditorPane.java b/src/net/java/sip/communicator/util/swing/StyledHTMLEditorPane.java index d796b57..14b1fef 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/StyledHTMLEditorPane.java +++ b/src/net/java/sip/communicator/util/swing/StyledHTMLEditorPane.java @@ -4,7 +4,7 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package net.java.sip.communicator.impl.gui.customcontrols; +package net.java.sip.communicator.util.swing; import java.io.*; @@ -12,20 +12,39 @@ import javax.swing.*; import javax.swing.text.*; import javax.swing.text.html.*; -import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.util.*; +/** + * A custom styled HTML editor pane. + * + * @author Yana Stamcheva + */ public class StyledHTMLEditorPane extends JEditorPane { + /** + * The serial version id. + */ private static final long serialVersionUID = 1L; + /** + * The logger for this class. + */ private final Logger logger = Logger.getLogger(StyledHTMLEditorPane.class); - + + /** + * The editor kit of this editor pane. + */ private final HTMLEditorKit editorKit; - + + /** + * The document of this editor pane. + */ private final HTMLDocument document; - + + /** + * Creates an instance of <tt>StyledHTMLEditorPane</tt>. + */ public StyledHTMLEditorPane() { editorKit = new SIPCommHTMLEditorKit(this); @@ -38,14 +57,18 @@ public class StyledHTMLEditorPane this.setDocument(document); putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); - Constants.loadSimpleStyle(document.getStyleSheet(), getFont()); } + /** + * Appends text to end of the editor pane. + * + * @param text the text to append + */ public void appendToEnd(String text) { Element root = document.getDefaultRootElement(); try - { + { document.insertAfterEnd(root .getElement(root.getElementCount() - 1), text); } @@ -58,17 +81,27 @@ public class StyledHTMLEditorPane logger.error("Insert in the HTMLDocument failed.", e); } } - + + /** + * Inserts the given text in the beginning of the editor pane. + * + * @param text the text to insert + */ public void insertAfterStart(String text) { Element root = this.document.getDefaultRootElement(); - - try { + + try + { this.document.insertBeforeStart(root - .getElement(0), text); - } catch (BadLocationException e) { + .getElement(0), text); + } + catch (BadLocationException e) + { logger.error("Insert in the HTMLDocument failed.", e); - } catch (IOException e) { + } + catch (IOException e) + { logger.error("Insert in the HTMLDocument failed.", e); } } |