* Adium is the legal property of its developers, whose names are listed in the copyright file included * with this source distribution. * This program is free software; you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. * You should have received a copy of the GNU General Public License along with this program; if not, * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #import "AIJabberConsoleController.h" #import <libpurple/jabber.h> #import <AIUtilities/AIAutoScrollView.h> #define XML_PREFIX @"<?xml version='1.0' encoding='UTF-8' ?>\n" @interface AIJabberConsoleController () - (PurpleConnection *)gc; xmlnode_received_cb(PurpleConnection *gc, xmlnode **packet, gpointer this) AIJabberConsoleController *self = (AIJabberConsoleController *)this; if (!this || [self gc] != gc) char *str = xmlnode_to_formatted_str(*packet, NULL); NSString *sstr = [NSString stringWithUTF8String:str]; if ([sstr hasPrefix:XML_PREFIX]) sstr = [sstr substringFromIndex:[XML_PREFIX length]]; NSAttributedString *astr = [[NSAttributedString alloc] initWithString:sstr xmlnode_sent_cb(PurpleConnection *gc, char **packet, gpointer this) AIJabberConsoleController *self = (AIJabberConsoleController *)this; if (!this || [self gc] != gc) node = ((*packet && strlen(*packet) && ((*packet)[0] == '<')) ? xmlnode_from_str(*packet, -1) : char *str = xmlnode_to_formatted_str(node, NULL); NSString *sstr = [NSString stringWithUTF8String:str]; if ([sstr hasPrefix:XML_PREFIX]) sstr = [sstr substringFromIndex:[XML_PREFIX length]]; NSAttributedString *astr = [[NSAttributedString alloc] initWithString:sstr attributes:[NSDictionary dictionaryWithObject:[NSColor blueColor] forKey:NSForegroundColorAttributeName]]; @implementation AIJabberConsoleController purple_signals_disconnect_by_handle(self); - (IBAction)send:(id)sender { NSData *rawXMLData = [[injectView string] dataUsingEncoding:NSUTF8StringEncoding]; NSAssert( INT_MAX >= [rawXMLData length], @"Sending more jabber data value than libpurple can handle. Abort." ); jabber_prpl_send_raw(gc, [rawXMLData bytes], (int)[rawXMLData length]); - (IBAction)showWindow:(id)sender { [super showWindow:sender]; //Connect to the signals for updating the window PurplePlugin *jabber = purple_find_prpl("prpl-jabber"); if (!jabber) AILog(@"Unable to locate jabber prpl"); purple_signal_connect(jabber, "jabber-receiving-xmlnode", self, PURPLE_CALLBACK(xmlnode_received_cb), self); purple_signal_connect(jabber, "jabber-sending-text", self, PURPLE_CALLBACK(xmlnode_sent_cb), self); - (void)windowWillClose:(NSNotification *)notification [super windowWillClose:notification]; //We don't need to watch the signals with the window closed purple_signals_disconnect_by_handle(self); - (PurpleConnection*)gc { - (void)setPurpleConnection:(PurpleConnection *)inGc