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

UU1: Vintage Apple Powerbook Low Power AC Adapter ADP-17AB
$19.99
UU1: Vintage Apple Powerbook Low Power AC Adapter ADP-17AB pictureVINTAGE LOT APPLE McIntosh Delicious Cortland Rome CUT LETTERPRESS PRINTING
$9.99
VINTAGE LOT APPLE McIntosh Delicious Cortland Rome CUT LETTERPRESS PRINTING    pictureVintage Apple Writer 2 dotted computer paper- 11 X 9.5
$29.99
Vintage Apple Writer 2 dotted computer paper-  11 X 9.5  pictureVintage Apple & Pear Fruit Firmness Tester
$27.0
Vintage Apple & Pear Fruit Firmness Tester  pictureVintage Apple Mac OS 8.5 Software NEW Sealed Sticker QuickTime 3 Pro
$18.99
Vintage Apple Mac OS 8.5 Software NEW Sealed Sticker QuickTime 3 Pro  picture






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