Guest User

Untitled

a guest
Mar 8th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. //
  2. // Purple.m
  3. // MobileChatApp
  4. //
  5. // Created by Shaun Harrison on 9/28/07.
  6. // Copyright 2007 twenty08. All rights reserved.
  7. //
  8.  
  9. #include "Purple.h"
  10. #include "PurpleAssistant.h"
  11.  
  12. @implementation Purple
  13.  
  14. - (id) init {
  15. id parent = [super init];
  16. int i;
  17.  
  18. init_libpurple();
  19. _iter = purple_plugins_get_protocols();
  20. _loop = g_main_loop_new(NULL, FALSE);
  21.  
  22. for (i = 0; _iter; _iter = _iter->next) {
  23. PurplePlugin* plugin = _iter->data;
  24. PurplePluginInfo* info = plugin->info;
  25. if (info && info->name) {
  26. //NSLog(@"%d -- %s", i++, info->name);
  27. _names = g_list_append(_names, info->id);
  28. }
  29.  
  30. }
  31.  
  32. //[NSThread detachNewThreadSelector:@selector(startLoop) toTarget:self withObject:nil];
  33. return parent;
  34. }
  35.  
  36. - (void) startLoop {
  37. NSAutoreleasePool* p = [[NSAutoreleasePool alloc] init];
  38. g_main_loop_run(_loop);
  39. [p release];
  40. }
  41.  
  42.  
  43.  
  44. - (void) connectWithUser: (NSString*) user withPass: (NSString*) pw withProtocol: (int) proto {
  45. _acct = purple_account_new([user cString], g_list_nth_data(_names, proto));
  46.  
  47. purple_account_register(_acct);
  48. purple_account_set_password(_acct, [pw cString]);
  49. purple_account_set_enabled(_acct, UI_ID, TRUE);
  50.  
  51. _status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE);
  52. purple_savedstatus_activate(status);
  53.  
  54. connect_to_signals_for_demonstration_purposes_only();
  55. g_main_loop_run(_loop);
  56. }
  57.  
  58. @end
Add Comment
Please, Sign In to add comment