SHOW Signed
 

net.rim.device.api.system
Interface PersistentContentListener

All Known Implementing Classes:
ContentProtectedVector, ContentProtectedHashtable

public interface PersistentContentListener

A listener class for persistent content events.

Example

Register the listener

 public static void main(String[] args)
 {
     if ( args != null && args.length > 0 && args[0].equals("startup") )
     {
         PersistentObject store = PersistentStore.getPersistentObject(PERSISTENT_STORE_DEMO_ID);                       
              
         // We synchronize on our PersistentObject so that no other object can
         // acquire the lock before we finish our commit operation.     
         synchronized(store)
         {         
             // If our PersistentObject is empty, we need to initialize it.
             if(store.getContents() == null)
             {
                 store.setContents(new Vector());
                 PersistentObject.commit(store);
             }            
         }    
           
         // We register a PersistentContentListener upon device start-up.
         // The listener listens for changes to the device content
         // protection and compression settings as well as persistent
         // content state changes.
         PersistentContent.addListener(new PersistentStoreListener());
     }
     else
     {   
         // Launch GUI version of our application.
         PersistentStoreDemo theApp = new PersistentStoreDemo();
         theApp.enterEventDispatcher();
     }
 }
 

Implement the listener
 // Persistent content listener for the PersistentStoreDemo app.  Listens for
 //changes to the device's Content Protection/Compression security settings and
 //re-encodes data accordingly. Changes to the device's state are ignored.
 final class PersistentStoreListener implements PersistentContentListener
 {
 
     // Called when the state of the device changes
     // (unlocked/locking/locked insecure/locked secure). This app doesn't care
     // about these state changes because data is always encoded inside the
     // Meeting objects; thus, there is no need to encode or decode them during
     // locking and unlocking. 
     // @param state The device's new state.
     public void persistentContentStateChanged(int state)
     {
         // ...
     }    
     
     // Called when the device's Content Protection/Compression security settings
     // are changed.  Re-encodes the data accordingly. 
     // @param generation Used to determine if the user has changed the content protection settings since the listener was notified.
     public void persistentContentModeChanged(int generation)
     {        
         PersistentObject persist = PersistentStore.getPersistentObject(PersistentStoreDemo.PERSISTENT_STORE_DEMO_ID);            
             
         if (persist != null)
         {  
             synchronized(persist.getContents())
             {
                 Vector meetings = (Vector) persist.getContents();
                 if (meetings == null)
                 {
                     // Contents empty; nothing to re-encode.
                     return;
                 }           
                 for (int i = 0; i < meetings.size(); ++i)
                 {
                     Meeting meeting = (Meeting)meetings.elementAt( i );
                     
                     // meeting.reEncode(); 
                     // meeting object contains a _fields Vector.
                     for (int i = 0; i < meeting.NUM_FIELDS; ++i)
                     {
                         Object encoding = meeting._fields.elementAt(i);
                         if(!PersistentContent.checkEncoding(encoding))
                         {
                             encoding = PersistentContent.reEncode(encoding);
                             meeting._fields.setElementAt(encoding, i);
                         }
                     }
                     
                     if ( generation != PersistentContent.getModeGeneration() )
                     {
                         // Device's Content Protection/Compression security
                         // settings have changed again since the listener was
                         // last notified.  Abort this re-encoding because it
                         // will have to be done again anyway according to the
                         // new Content Protection/Compression security settings.
                         break;
                     }
                 }
                 // Commit the updated data to the persistent store.            
                 persist.commit();  
              }           
         }
     }        
 }
 
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

Since:
JDE 4.0.0
See Also:
PersistentContent

Field Summary
 Category: Signed static int PERSISTENT_CONTENT_LOCKED_INSECURE
          Indicates that data on the device is not secured, i.e., the device is locked but some data may be on the device in plaintext format.
 Category: Signed static int PERSISTENT_CONTENT_LOCKED_SECURE
          Indicates that data on the device is secured, i.e., the device is locked and all data that should be encoded is encoded.
 Category: Signed static int PERSISTENT_CONTENT_LOCKING
          Indicates that the device is locking.
 Category: Signed static int PERSISTENT_CONTENT_UNLOCKED
          Indicates that the device is currently unlocked.
 
Method Summary
 Category: Signed  void persistentContentModeChanged(int generation)
          Invoked when the persistent content mode changes, i.e., the Content Protection/Compression security settings on the device change.
 Category: Signed  void persistentContentStateChanged(int state)
          Invoked when the persistent content state changes (e.g., the device changes from locked to unlocked).
 

Field Detail

PERSISTENT_CONTENT_LOCKED_INSECURE

public static final int PERSISTENT_CONTENT_LOCKED_INSECURE
Indicates that data on the device is not secured, i.e., the device is locked but some data may be on the device in plaintext format.

This occurs if data is received while the device is locked.

Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

PERSISTENT_CONTENT_LOCKED_SECURE

public static final int PERSISTENT_CONTENT_LOCKED_SECURE
Indicates that data on the device is secured, i.e., the device is locked and all data that should be encoded is encoded.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

PERSISTENT_CONTENT_LOCKING

public static final int PERSISTENT_CONTENT_LOCKING
Indicates that the device is locking.

Content may be encoded when the device is unlocked or locked. However, content that was encoded using encryption may not be decoded if the device is locked.

Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

PERSISTENT_CONTENT_UNLOCKED

public static final int PERSISTENT_CONTENT_UNLOCKED
Indicates that the device is currently unlocked.

Content may be encoded when the device is unlocked or locked. However, content that was encoded using encryption may not be decoded if the device is locked.

Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Method Detail

persistentContentModeChanged

public void persistentContentModeChanged(int generation)
Invoked when the persistent content mode changes, i.e., the Content Protection/Compression security settings on the device change.

Listeners should call PersistentContent.checkEncoding(java.lang.Object) to see if they need to call PersistentContent.reEncode(java.lang.Object).

Listeners should periodically compare the generation parameter to PersistentContent.getModeGeneration(). If they are different, then the listeners should terminate their checkEncoding/reEncoding loops because the security settings on the device have changed and they will have to be rechecked and/or re-encoded anyway.

Parameters:
generation - Used to determine if the user has changed the content protection settings since the listener was notified.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

persistentContentStateChanged

public void persistentContentStateChanged(int state)
Invoked when the persistent content state changes (e.g., the device changes from locked to unlocked).
Parameters:
state - New state.
Since:
JDE 4.0.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.