Right now plugins can process incoming and outgoing messages via processIncomingMessage:: / processOutgoingMessage:: (or the corresponding methods for other languages than ObjC).
These two methods only give access to the message after Colloquy did its own processing on it, ie. nick highlighting, URL detection etc. There are plugin-types, though, for which this behaviour is not optimal. For example an encryption plugin needs to decrypt the raw incoming message (encrypt the raw outgoing message) before Colloquy does its processing, as it won't find anything in an encrypted message.
I am currently developing a Blowfish encryption plugin, and it's limited by the current plugin interface. Another problem is the encoding of the strings. Afaik Colloquy does inform the user if an incoming message has a different encoding as selected for the current channel. I am not sure, but it might be doing fallback-encodings, too. But all this happens before my plugin gets to decrypt the message.
As already suggested in ticket:556 I suggest to provide a richer plugin interface, allowing plugins to work on the NSDatas before they get processed by Colloquy. This way, for example encryption plugins wouldn't even know about string encodings and such. To fix ticket:556 another methods might be supplied to let plugins work on NSStrings before the message gets translated to HTML. The same would be needed for outgoing messages, ie. a method to work on the raw message NSData before it gets send, and the raw NSString, after the conversion from HTML, and before encoding it in an NSData object.
Possible methods might be:
- (processIncomingRawMessage:(NSData *)message from:(NSString/MVChatUser):sender in:(NSString/MVDirectChat/MVChatRoom)context on:(MVChatConnection *)connection
- (processOutgoingRawMessage:(NSData *)message to:(NSString/MVChatUser):sender in:(NSString/MVDirectChat/MVChatRoom)context on:(MVChatConnection *)connection
Browsing the code quickly, some possible positions to do the raw data notifications would be:
For outgoing messages:
Outgoing:
- MVIRCChatConnection - (void) _sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) msgEncoding toTarget:(NSString *) target asAction:(BOOL) action
- MVDirectChatConnection - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action
Incoming:
JVChatController
- (void) _gotDirectChatMessage:(NSNotification *) notification
- (void) _gotRoomMessage:(NSNotification *) notification
- (void) _gotPrivateMessage:(NSNotification *) notification