BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-13-2007, 06:30 AM   #1 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Folder listener: It works with mails, but not with PINs

Please Login to Remove!

we have implemented a FolderListener/MessageListener.
It works very well with mails, does not work with PINs though.
As we inted to work with PINs this is quite unfortunate.
We are still waiting for a reply from RIM so i decided to give the forum a try

hope somebody comes up with an idea
attached is the complete class

Code:
public class InboxService implements FolderListener, MessageListener {

	private Store store;

	public InboxService() {
		try {
			Session session = Session.waitForDefaultSession();
			Logger.debug("InboxService.init() - session: " + session.getServiceConfiguration().getEmailAddress());
			store = session.getStore();
			store.addFolderListener(this);
			Logger.debug("InboxService.init() - Listener added to store");
		} catch (Exception e) {
			Logger.error("InboxService.init()", e);
		}
		
		Logger.debug("InboxService.init() - done");
	}

	public void destroyInboxService() {
		if (store != null) {
			store.removeFolderListener(this);
		}
	}

	private void processEvent(Message message) {
		if (message.isInbound() && message.getSubject().startsWith("DURCHBRUCH:")) {
			Logger.debug("InboxService.processEvent()");
			
			Object content = message.getContent();
			if (content instanceof BodyPart) {
				BodyPart bodyPart = (BodyPart) content;
				if (bodyPart.hasMore()) {						Logger.debug("InboxService.processEvent() - Message has more parts");
					
					if (!bodyPart.moreRequestSent()) {						message.addMessageListener(this);
						
						try {
							
							Transport.more(bodyPart, true);
						} catch (Exception e) {
							Logger.error("InboxService.processEvent()", e);
						}
					}
				} else {
					
					message.removeMessageListener(this);
					Logger.debug("InboxService.processEvent() - Removed MessageListener");
	
					
					try {
						if (message.getMessageType() == Message.PIN_MESSAGE) {
							Dialog.alert("Message received: " + message.getSubject());
						}
					} catch (Exception e) {
						Logger.error("InboxService.processEvent() - processing message failed", e);
					}
					
					try {
						
						Folder folder = message.getFolder();
						folder.deleteMessage(message);
						Logger.debug("InboxService.processEvent() - Deleted Message with subject: " + message.getSubject());
					} catch (Exception e) {
						Logger.error("InboxService.processEvent() - Deleting message failed", e);
					}
				}
			}
		}
	}

	
	public void changed(MessageEvent event) {
		processEvent(event.getMessage());
	}

	
	public void messagesAdded(FolderEvent event) {
		processEvent(event.getMessage());
	}

	
	public void messagesRemoved(FolderEvent event) {
		// nothing todo
	}
}
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

2KW-2.2KW Single-Phase Automatic Voltage Regulator Petrol Generator AVR -J2
$18.5
2KW-2.2KW Single-Phase Automatic Voltage Regulator Petrol Generator AVR  -J2 picturebayite DC 5-120V 100A Mini Digital Current Voltage Amp Meter Gauge with Hall Eff
$22.45
bayite DC 5-120V 100A Mini Digital Current Voltage Amp Meter Gauge with Hall Eff picture36 Lot Porcelain Knob Insulators High Voltage Electric Fence Ceramic
$49.99
36 Lot Porcelain Knob Insulators High Voltage Electric Fence Ceramic picture10 of L7805 Voltage Regulator IC 5V 1.5A L7805CV L7805 LM7805
$1.29
10 of L7805 Voltage Regulator IC 5V 1.5A L7805CV L7805 LM7805 picture10 of L7805 Voltage Regulator IC 5V 1.5A L7805CV L7805 LM7805 l l
$1.31
10 of L7805 Voltage Regulator IC 5V 1.5A L7805CV L7805 LM7805 l l picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.