aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/dictaccregwizz
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2008-07-14 16:29:25 +0000
committerDamian Minkov <damencho@jitsi.org>2008-07-14 16:29:25 +0000
commit795fac7d71f64c1cf8db64ed1a896633ecc57a46 (patch)
treeea00e453c6721ae4c620aae18963dc91462c0165 /src/net/java/sip/communicator/plugin/dictaccregwizz
parent4922ad2ddd75f8b35dc369536ddcbe81ccf7a05e (diff)
downloadjitsi-795fac7d71f64c1cf8db64ed1a896633ecc57a46.zip
jitsi-795fac7d71f64c1cf8db64ed1a896633ecc57a46.tar.gz
jitsi-795fac7d71f64c1cf8db64ed1a896633ecc57a46.tar.bz2
Resource Management Service and its implementation. The service holds all resources and all bundles(except configuration service) use it to retrieve i18n strings,images,settings...
Diffstat (limited to 'src/net/java/sip/communicator/plugin/dictaccregwizz')
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistrationWizard.java4
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java79
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf1
3 files changed, 39 insertions, 45 deletions
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistrationWizard.java
index 7fa4f61..1d48b41 100644
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistrationWizard.java
@@ -86,7 +86,7 @@ public class DictAccountRegistrationWizard
*/
public String getProtocolName()
{
- return Resources.getString("protocolName");
+ return Resources.getString("protocolNameDict");
}
/**
@@ -96,7 +96,7 @@ public class DictAccountRegistrationWizard
*/
public String getProtocolDescription()
{
- return Resources.getString("protocolDescription");
+ return Resources.getString("protocolDescriptionDict");
}
/**
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java
index 4266c2c..348f0f6 100644
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java
+++ b/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java
@@ -10,8 +10,11 @@ package net.java.sip.communicator.plugin.dictaccregwizz;
import java.io.*;
import java.util.*;
+import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
+import org.osgi.framework.*;
+
/**
* The <tt>Resources</tt> class manages the access to the internationalization
* properties files and the image resources used in this plugin.
@@ -23,35 +26,11 @@ public class Resources
{
private static Logger log = Logger.getLogger(Resources.class);
- /**
- * The name of the resource, where internationalization strings for this
- * plugin are stored.
- */
- private static final String STRING_RESOURCE_NAME
- = "resources.languages.plugin.dictaccregwizz.resources";
-
- /**
- * The name of the resource, where paths to images used in this bundle are
- * stored.
- */
- private static final String IMAGE_RESOURCE_NAME
- = "net.java.sip.communicator.plugin.dictaccregwizz.resources";
-
- /**
- * The string resource bundle.
- */
- private static final ResourceBundle STRING_RESOURCE_BUNDLE
- = ResourceBundle.getBundle(STRING_RESOURCE_NAME);
+ private static ResourceManagementService resourcesService;
- /**
- * The image resource bundle.
- */
- private static final ResourceBundle IMAGE_RESOURCE_BUNDLE
- = ResourceBundle.getBundle(IMAGE_RESOURCE_NAME);
+ public static ImageID DICT_LOGO = new ImageID("protocolIconDict");
- public static ImageID DICT_LOGO = new ImageID("protocolIcon");
-
- public static ImageID PAGE_IMAGE = new ImageID("pageImage");
+ public static ImageID PAGE_IMAGE = new ImageID("pageImageDict");
/**
* Returns an internationalized string corresponding to the given key.
@@ -61,15 +40,7 @@ public class Resources
*/
public static String getString(String key)
{
- try
- {
- return STRING_RESOURCE_BUNDLE.getString(key);
- }
- catch (MissingResourceException e)
- {
- return '!' + key + '!';
- }
- //return '!' + key + '!';
+ return getResources().getI18NString(key);
}
/**
@@ -79,20 +50,24 @@ public class Resources
*/
public static byte[] getImage(ImageID imageID)
{
- byte[] image = new byte[100000];
-
- String path = IMAGE_RESOURCE_BUNDLE.getString(imageID.getId());
+ InputStream in =
+ getResources().getImageInputStream(imageID.getId());
+ if(in == null)
+ return null;
+
+ byte[] image = null;
+
try
{
- Resources.class.getClassLoader()
- .getResourceAsStream(path).read(image);
+ image = new byte[in.available()];
+ in.read(image);
}
catch (IOException e)
{
- log.error("Failed to load image:" + path, e);
+ log.error("Failed to load image:" + imageID, e);
}
-
+
return image;
}
@@ -113,4 +88,22 @@ public class Resources
return id;
}
}
+
+ public static ResourceManagementService getResources()
+ {
+ if (resourcesService == null)
+ {
+ ServiceReference serviceReference = DictAccRegWizzActivator.bundleContext
+ .getServiceReference(ResourceManagementService.class.getName());
+
+ if(serviceReference == null)
+ return null;
+
+ resourcesService =
+ (ResourceManagementService)DictAccRegWizzActivator.bundleContext
+ .getService(serviceReference);
+ }
+
+ return resourcesService;
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf
index 4dcab77..c1c4169 100644
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf
@@ -5,6 +5,7 @@ Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
Import-Package: org.osgi.framework,
net.java.sip.communicator.util,
+ net.java.sip.communicator.service.resources,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.service.configuration.event,
net.java.sip.communicator.service.protocol,