imap: add callback to connect/disconnect