Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-02-2011, 03:43 AM
Special Member
 
Posts: 117
Default Hook code on delete, send, receive and move email

I want to log some information when user delete, receive, send and move an email in zimbra. For that I've tried to write a zimbra extension. See following code. But I couldn't find a way to differentiate the events. The extension is getting call every time but no way to say that whether it is delete or move or send email event.

Can anybody shed some more light?

Code:
package my.listener;

import com.zimbra.common.service.ServiceException;
import com.zimbra.cs.extension.ExtensionException;
import com.zimbra.cs.extension.ZimbraExtension;
import com.zimbra.cs.mailbox.MailItem;
import com.zimbra.cs.mailbox.MailboxListener;
import com.zimbra.cs.mailbox.OperationContext;
import com.zimbra.cs.session.PendingModifications;

public class MyDeleteMailListener extends MailboxListener implements ZimbraExtension{

	@Override
	public void destroy() {
		System.out.println("MyDeleteMailListener - In Destroy");
		
	}

	@Override
	public String getName() {
		return "MyDeleteMailListener";
	}

	@Override
	public void init() throws ExtensionException, ServiceException {
		System.out.println("MyDeleteMailListener - In Init and registering");
		register(this);
	}

	@Override
	public void handleMailboxChange(String arg0, PendingModifications arg1,
			OperationContext arg2, int arg3) {
		System.out.println("MyDeleteMailListener - In MailboxChange for account id: " + arg0);
		System.out.println("MyDeleteMailListener - In MailboxChange : " + arg1.changedTypes);
	}

	@Override
	public int registerForItemTypes() {
		System.out.println("MyDeleteMailListener - In RegisterForItemTypes " + MailItem.typeToBitmask(MailItem.TYPE_CONVERSATION) + " and " + MailItem.typeToBitmask(MailItem.TYPE_MESSAGE));
		return MailItem.typeToBitmask(MailItem.TYPE_CONVERSATION) | MailItem.typeToBitmask(MailItem.TYPE_MESSAGE);
	}	
}
Thank You!
Reply With Quote
  #2 (permalink)  
Old 12-04-2011, 10:36 PM
Zimbra Employee
 
Posts: 70
Default

PendingModifications has data structures "created", "modified", and "deleted". Also, for a modified item the reasons are enumerated in PendingModifications.Change.

Note that this API is not officially supported and is subject to change in future releases.
Reply With Quote
  #3 (permalink)  
Old 12-04-2011, 10:41 PM
Special Member
 
Posts: 117
Default

Quote:
Originally Posted by vmahajan View Post
PendingModifications has data structures "created", "modified", and "deleted". Also, for a modified item the reasons are enumerated in PendingModifications.Change.

Note that this API is not officially supported and is subject to change in future releases.
Alright, thank you. That is just I want. Is there any plan to extends these APIs? They are very much helpful and will make zimbra more flexible for developers.
Reply With Quote
  #4 (permalink)  
Old 12-05-2011, 02:49 AM
Project Contributor
 
Posts: 92
Default

"notify" method in com.zimbra.cs.mailbox.alerts.CalItemReminderServic e class
is good example for you, I guess.
Reply With Quote
  #5 (permalink)  
Old 12-05-2011, 03:11 AM
Special Member
 
Posts: 117
Default

Quote:
Originally Posted by yutaka View Post
"notify" method in com.zimbra.cs.mailbox.alerts.CalItemReminderServic e class
is good example for you, I guess.
Thank you for reply. I'll take a look.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.