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

Extron RGB 202xi ADSP Universal Analog, ECL and TTL Computer-Video Interface
$30.99
Extron RGB 202xi ADSP Universal Analog, ECL and TTL Computer-Video Interface pictureExtron RGB-190F Universal Analog Computer-Video Interface
$50.0
Extron RGB-190F Universal Analog Computer-Video Interface pictureComputer Components Springfield Big and Bold Outdoor Thermometer (13.25-Inch)
$13.18
Computer Components Springfield Big and Bold Outdoor Thermometer (13.25-Inch) pictureMeasurement Computing PCIe-DAS1602/16 Analog and Digital I/O Board
$299.0
Measurement Computing PCIe-DAS1602/16 Analog and Digital I/O Board pictureMeasurement Computing PCI-DAS1602/16 Analog and Digital I/O Board
$269.95
Measurement Computing PCI-DAS1602/16 Analog and Digital I/O Board picture






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