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

5in1 Cavitation RF Ultrasonic 40K Bipolar Vacuum Weight Loss Slim Body Machine
$367.85
5in1 Cavitation RF Ultrasonic 40K Bipolar Vacuum Weight Loss Slim Body Machine pictureGenuine Joe Contemp Design Vacuum Insulated Carafe - GJO11958
$27.68
Genuine Joe Contemp Design Vacuum Insulated Carafe - GJO11958 pictureGenuine Joe 1.2L Vacuum-insulated Flip-top Carafe - GJO11951
$23.56
Genuine Joe 1.2L Vacuum-insulated Flip-top Carafe - GJO11951 pictureHormel Stainless Steel Vacuum Liner Carafe - HORSVC190
$52.8
Hormel Stainless Steel Vacuum Liner Carafe - HORSVC190 pictureStanley Stopper for 11 and 13 Replacement After 2002 For Thermos Vacuum Bottles
$9.03
Stanley Stopper for 11 and 13 Replacement After 2002 For Thermos Vacuum Bottles  picture






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