aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/gibberishaccregwizz
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/gibberishaccregwizz
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/gibberishaccregwizz')
-rw-r--r--src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccountRegistrationWizard.java4
-rw-r--r--src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java78
-rw-r--r--src/net/java/sip/communicator/plugin/gibberishaccregwizz/gibberishaccregwizz.manifest.mf1
3 files changed, 38 insertions, 45 deletions
diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccountRegistrationWizard.java
index 7ca29ee..54d0424 100644
--- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/GibberishAccountRegistrationWizard.java
@@ -86,7 +86,7 @@ public class GibberishAccountRegistrationWizard
*/
public String getProtocolName()
{
- return Resources.getString("protocolName");
+ return Resources.getString("protocolNameGibberish");
}
/**
@@ -96,7 +96,7 @@ public class GibberishAccountRegistrationWizard
*/
public String getProtocolDescription()
{
- return Resources.getString("protocolDescription");
+ return Resources.getString("protocolDescriptionGibberish");
}
/**
diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java
index 0010823..afe720b 100644
--- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java
+++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/Resources.java
@@ -8,10 +8,12 @@
package net.java.sip.communicator.plugin.gibberishaccregwizz;
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,41 +25,17 @@ 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.gibberishaccregwizz.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.gibberishaccregwizz.resources";
-
- /**
- * The string resource bundle.
- */
- private static final ResourceBundle STRING_RESOURCE_BUNDLE
- = ResourceBundle.getBundle(STRING_RESOURCE_NAME);
-
- /**
- * The image resource bundle.
- */
- private static final ResourceBundle IMAGE_RESOURCE_BUNDLE
- = ResourceBundle.getBundle(IMAGE_RESOURCE_NAME);
+ private static ResourceManagementService resourcesService;
/**
* A constant pointing to the Gibberish protocol logo icon.
*/
- public static ImageID GIBBERISH_LOGO = new ImageID("protocolIcon");
+ public static ImageID GIBBERISH_LOGO = new ImageID("protocolIconGibberish");
/**
* A constant pointing to the Gibberish protocol wizard page image.
*/
- public static ImageID PAGE_IMAGE = new ImageID("pageImage");
+ public static ImageID PAGE_IMAGE = new ImageID("pageImageGibberish");
/**
* Returns an internationalized string corresponding to the given key.
@@ -67,14 +45,7 @@ public class Resources
*/
public static String getString(String key)
{
- try
- {
- return STRING_RESOURCE_BUNDLE.getString(key);
- }
- catch (MissingResourceException exc)
- {
- return '!' + key + '!';
- }
+ return getResources().getI18NString(key);
}
/**
@@ -85,18 +56,22 @@ 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 exc)
+ catch (IOException e)
{
- log.error("Failed to load image:" + path, exc);
+ log.error("Failed to load image:" + imageID, e);
}
return image;
@@ -119,5 +94,22 @@ public class Resources
return id;
}
}
+
+ public static ResourceManagementService getResources()
+ {
+ if (resourcesService == null)
+ {
+ ServiceReference serviceReference = GibberishAccRegWizzActivator.bundleContext
+ .getServiceReference(ResourceManagementService.class.getName());
+
+ if(serviceReference == null)
+ return null;
+
+ resourcesService =
+ (ResourceManagementService)GibberishAccRegWizzActivator.bundleContext
+ .getService(serviceReference);
+ }
+ return resourcesService;
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/gibberishaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/gibberishaccregwizz.manifest.mf
index 13505e1..06d5959 100644
--- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/gibberishaccregwizz.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/gibberishaccregwizz.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,