Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Purple.m
- // MobileChatApp
- //
- // Created by Shaun Harrison on 9/28/07.
- // Copyright 2007 twenty08. All rights reserved.
- //
- #include "Purple.h"
- #include "PurpleAssistant.h"
- @implementation Purple
- - (id) init {
- id parent = [super init];
- int i;
- init_libpurple();
- _iter = purple_plugins_get_protocols();
- _loop = g_main_loop_new(NULL, FALSE);
- for (i = 0; _iter; _iter = _iter->next) {
- PurplePlugin* plugin = _iter->data;
- PurplePluginInfo* info = plugin->info;
- if (info && info->name) {
- //NSLog(@"%d -- %s", i++, info->name);
- _names = g_list_append(_names, info->id);
- }
- }
- //[NSThread detachNewThreadSelector:@selector(startLoop) toTarget:self withObject:nil];
- return parent;
- }
- - (void) startLoop {
- NSAutoreleasePool* p = [[NSAutoreleasePool alloc] init];
- g_main_loop_run(_loop);
- [p release];
- }
- - (void) connectWithUser: (NSString*) user withPass: (NSString*) pw withProtocol: (int) proto {
- _acct = purple_account_new([user cString], g_list_nth_data(_names, proto));
- purple_account_register(_acct);
- purple_account_set_password(_acct, [pw cString]);
- purple_account_set_enabled(_acct, UI_ID, TRUE);
- _status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE);
- purple_savedstatus_activate(status);
- connect_to_signals_for_demonstration_purposes_only();
- g_main_loop_run(_loop);
- }
- @end
Add Comment
Please, Sign In to add comment