Class: PurpleRuby
- Inherits:
-
Object
- Object
- PurpleRuby
- Defined in:
- ext/purple_ruby.c
Defined Under Namespace
Classes: Account
Constant Summary collapse
- NOTIFY_MSG_ERROR =
INT2NUM(PURPLE_NOTIFY_MSG_ERROR)
- NOTIFY_MSG_WARNING =
INT2NUM(PURPLE_NOTIFY_MSG_WARNING)
- NOTIFY_MSG_INFO =
INT2NUM(PURPLE_NOTIFY_MSG_INFO)
Class Method Summary collapse
- .init(*args) ⇒ Object
- .list_protocols ⇒ Object
- .login(protocol, username, password) ⇒ Object
- .main_loop_run ⇒ Object
- .main_loop_stop ⇒ Object
- .watch_connection_error ⇒ Object
- .watch_incoming_im ⇒ Object
- .watch_incoming_ipc(serverip, port) ⇒ Object
- .watch_new_buddy ⇒ Object
- .watch_notify_message ⇒ Object
- .watch_request ⇒ Object
- .watch_signed_off_event ⇒ Object
- .watch_signed_on_event ⇒ Object
- .watch_timer(delay) ⇒ Object
Class Method Details
.init(*args) ⇒ Object
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'ext/purple_ruby.c', line 379 static VALUE init(int argc, VALUE* argv, VALUE self) { VALUE debug, path; rb_scan_args(argc, argv, "02", &debug, &path); signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); signal(SIGINT, sighandler); signal(SIGQUIT, sighandler); signal(SIGTERM, sighandler); data_hash_table = g_hash_table_new(NULL, NULL); fd_hash_table = g_hash_table_new(NULL, NULL); purple_debug_set_enabled((NIL_P(debug) || debug == Qfalse) ? FALSE : TRUE); if (!NIL_P(path)) { Check_Type(path, T_STRING); purple_util_set_user_dir(RSTRING_PTR(path)); } purple_core_set_ui_ops(&core_uiops); purple_eventloop_set_ui_ops(&glib_eventloops); if (!purple_core_init(UI_ID)) { rb_raise(rb_eRuntimeError, "libpurple initialization failed"); } /* Create and load the buddylist. */ purple_set_blist(purple_blist_new()); purple_blist_load(); /* Load the preferences. */ purple_prefs_load(); /* Load the pounces. */ purple_pounces_load(); return Qnil; } |
.list_protocols ⇒ Object
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 |
# File 'ext/purple_ruby.c', line 727 static VALUE list_protocols(VALUE self) { VALUE array = rb_ary_new(); GList *iter = purple_plugins_get_protocols(); int i; for (i = 0; iter; iter = iter->next) { PurplePlugin *plugin = iter->data; PurplePluginInfo *info = plugin->info; if (info && info->name) { char s[256]; snprintf(s, sizeof(s) -1, "%s %s", info->id, info->name); rb_ary_push(array, rb_str_new2(s)); } } return array; } |
.login(protocol, username, password) ⇒ Object
622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
# File 'ext/purple_ruby.c', line 622 static VALUE login(VALUE self, VALUE protocol, VALUE username, VALUE password) { PurpleAccount* account = purple_account_new(RSTRING_PTR(username), RSTRING_PTR(protocol)); if (NULL == account || NULL == account->presence) { rb_raise(rb_eRuntimeError, "No able to create account: %s", RSTRING_PTR(protocol)); } purple_account_set_password(account, RSTRING_PTR(password)); purple_account_set_remember_password(account, TRUE); purple_account_set_enabled(account, UI_ID, TRUE); PurpleSavedStatus *status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE); purple_savedstatus_activate(status); return Data_Wrap_Struct(cAccount, NULL, NULL, account); } |
.main_loop_run ⇒ Object
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
# File 'ext/purple_ruby.c', line 646 static VALUE main_loop_run(VALUE self) { main_loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(main_loop); #ifdef DEBUG_MEM_LEAK printf("QUIT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); purple_core_quit(); if (im_handler == Qnil) rb_gc_unregister_address(&im_handler); if (signed_on_handler == Qnil) rb_gc_unregister_address(&signed_on_handler); if (signed_off_handler == Qnil) rb_gc_unregister_address(&signed_off_handler); if (connection_error_handler == Qnil) rb_gc_unregister_address(&connection_error_handler); if ( == Qnil) rb_gc_unregister_address(&); if (request_handler == Qnil) rb_gc_unregister_address(&request_handler); if (ipc_handler == Qnil) rb_gc_unregister_address(&ipc_handler); if (timer_timeout != 0) g_source_remove(timer_timeout); if (timer_handler == Qnil) rb_gc_unregister_address(&timer_handler); if (new_buddy_handler == Qnil) rb_gc_unregister_address(&new_buddy_handler); rb_gc_start(); #endif return Qnil; } |
.main_loop_stop ⇒ Object
670 671 672 673 674 |
# File 'ext/purple_ruby.c', line 670 static VALUE main_loop_stop(VALUE self) { g_main_loop_quit(main_loop); return Qnil; } |
.watch_connection_error ⇒ Object
482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'ext/purple_ruby.c', line 482 static VALUE watch_connection_error(VALUE self) { finch_connections_init(); purple_connections_set_ui_ops(&connection_ops); set_callback(&connection_error_handler, "connection_error_handler"); /*int handle; purple_signal_connect(purple_connections_get_handle(), "connection-error", &handle, PURPLE_CALLBACK(connection_error), NULL);*/ return connection_error_handler; } |
.watch_incoming_im ⇒ Object
420 421 422 423 424 425 |
# File 'ext/purple_ruby.c', line 420 static VALUE watch_incoming_im(VALUE self) { purple_conversations_set_ui_ops(&conv_uiops); set_callback(&im_handler, "im_handler"); return im_handler; } |
.watch_incoming_ipc(serverip, port) ⇒ Object
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
# File 'ext/purple_ruby.c', line 560 static VALUE watch_incoming_ipc(VALUE self, VALUE serverip, VALUE port) { struct sockaddr_in my_addr; int soc; int on = 1; /* Open a listening socket for incoming conversations */ if ((soc = socket(PF_INET, SOCK_STREAM, 0)) < 0) { rb_raise(rb_eRuntimeError, "Cannot open socket: %s\n", g_strerror(errno)); return Qnil; } if (setsockopt(soc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) { rb_raise(rb_eRuntimeError, "SO_REUSEADDR failed: %s\n", g_strerror(errno)); return Qnil; } memset(&my_addr, 0, sizeof(struct sockaddr_in)); my_addr.sin_family = AF_INET; my_addr.sin_addr.s_addr = inet_addr(RSTRING_PTR(serverip)); my_addr.sin_port = htons(FIX2INT(port)); if (bind(soc, (struct sockaddr*)&my_addr, sizeof(struct sockaddr)) != 0) { rb_raise(rb_eRuntimeError, "Unable to bind to port %d: %s\n", (int)FIX2INT(port), g_strerror(errno)); return Qnil; } /* Attempt to listen on the bound socket */ if (listen(soc, 10) != 0) { rb_raise(rb_eRuntimeError, "Cannot listen on socket: %s\n", g_strerror(errno)); return Qnil; } set_callback(&ipc_handler, "ipc_handler"); /* Open a watcher in the socket we have just opened */ purple_input_add(soc, PURPLE_INPUT_READ, _accept_socket_handler, NULL); return port; } |
.watch_new_buddy ⇒ Object
441 442 443 444 445 446 |
# File 'ext/purple_ruby.c', line 441 static VALUE watch_new_buddy(VALUE self) { purple_accounts_set_ui_ops(&account_ops); set_callback(&new_buddy_handler, "new_buddy_handler"); return new_buddy_handler; } |
.watch_notify_message ⇒ Object
427 428 429 430 431 432 |
# File 'ext/purple_ruby.c', line 427 static VALUE (VALUE self) { purple_notify_set_ui_ops(¬ify_ops); set_callback(&, "notify_message_handler"); return ; } |
.watch_request ⇒ Object
434 435 436 437 438 439 |
# File 'ext/purple_ruby.c', line 434 static VALUE watch_request(VALUE self) { purple_request_set_ui_ops(&request_ops); set_callback(&request_handler, "request_handler"); return request_handler; } |
.watch_signed_off_event ⇒ Object
473 474 475 476 477 478 479 480 |
# File 'ext/purple_ruby.c', line 473 static VALUE watch_signed_off_event(VALUE self) { set_callback(&signed_off_handler, "signed_off_handler"); int handle; purple_signal_connect(purple_connections_get_handle(), "signed-off", &handle, PURPLE_CALLBACK(signed_off), NULL); return signed_off_handler; } |
.watch_signed_on_event ⇒ Object
464 465 466 467 468 469 470 471 |
# File 'ext/purple_ruby.c', line 464 static VALUE watch_signed_on_event(VALUE self) { set_callback(&signed_on_handler, "signed_on_handler"); int handle; purple_signal_connect(purple_connections_get_handle(), "signed-on", &handle, PURPLE_CALLBACK(signed_on), NULL); return signed_on_handler; } |
.watch_timer(delay) ⇒ Object
613 614 615 616 617 618 619 620 |
# File 'ext/purple_ruby.c', line 613 static VALUE watch_timer(VALUE self, VALUE delay) { set_callback(&timer_handler, "timer_handler"); if (timer_timeout != 0) g_source_remove(timer_timeout); timer_timeout = g_timeout_add(delay, do_timeout, timer_handler); return delay; } |