static VALUE set_public_alias(VALUE self, VALUE nickname) { PurpleAccount *account = PURPLE_ACCOUNT(self); PurpleConnection *connection = NULL; PurplePlugin *prpl = NULL; const char *alias = NULL; void (*set_alias) (PurpleConnection *gc, const char *alias); alias = RSTRING_PTR( nickname ); connection = purple_account_get_connection( account ); if (!connection) { purple_account_set_public_alias( account, alias, NULL, NULL ); return Qnil; } prpl = purple_connection_get_prpl( connection ); if (!g_module_symbol( prpl->handle, "set_alias", (void *) &set_alias ) ) { // purple_account_set_public_alias( account, alias, NULL, NULL ); return Qnil; } set_alias( connection, alias ); return Qnil; }
static void purple_protocol_finalize(GObject *object) { PurpleProtocol *protocol = PURPLE_PROTOCOL(object); GList *accounts, *l; accounts = purple_accounts_get_all_active(); for (l = accounts; l != NULL; l = l->next) { PurpleAccount *account = PURPLE_ACCOUNT(l->data); if (purple_account_is_disconnected(account)) continue; if (purple_strequal(protocol->id, purple_account_get_protocol_id(account))) purple_account_disconnect(account); } g_list_free(accounts); purple_request_close_with_handle(protocol); purple_notify_close_with_handle(protocol); purple_signals_disconnect_by_handle(protocol); purple_signals_unregister_by_instance(protocol); purple_prefs_disconnect_by_handle(protocol); user_splits_free(protocol); account_options_free(protocol); icon_spec_free(protocol); PURPLE_DBUS_UNREGISTER_POINTER(protocol); parent_class->finalize(object); }
static VALUE account_send_typing( VALUE self, VALUE buddy_name ) { PurpleAccount *account = PURPLE_ACCOUNT( self); PurpleConnection *gc = NULL; gc = purple_account_get_connection( account ); serv_send_typing( gc, RSTRING_PTR(buddy_name), PURPLE_TYPING ); return Qtrue; }
static VALUE account_is_connected( VALUE self ) { PurpleAccount *account = PURPLE_ACCOUNT(self); if( purple_account_is_connected( account ) == TRUE ) { return Qtrue; } else { return Qfalse; } }
static VALUE account_get_buddies_list( VALUE self ) { PurpleAccount *account = PURPLE_ACCOUNT(self); PurpleBuddy *buddy = NULL; GList *iter = NULL; VALUE buddies = rb_ary_new(); for( iter = (GList *) purple_find_buddies( account, NULL ); iter; iter = iter->next ) { buddy = iter->data; if( buddy != NULL && buddy->name != NULL ) { rb_ary_push( buddies, RB_BLIST_BUDDY( buddy ) ); } } return buddies; }
static VALUE set_personal_message( VALUE self, VALUE psm ) { PurplePlugin *prpl = NULL; PurpleAccount *account = PURPLE_ACCOUNT(self); void (*set_psm) (PurpleConnection *gc, const char *psm); PurpleConnection *gc = NULL; gc = purple_account_get_connection( account ); if (!gc) { return; } prpl = purple_connection_get_prpl( gc ); if (!g_module_symbol (prpl->handle, "msn_set_personal_message_cb", (void *) &set_psm)) { return; } set_psm( gc, (const char *) RSTRING_PTR( psm ) ); return Qnil; }
static VALUE set_avatar_from_file( VALUE self, VALUE filepath ) { FILE *file = NULL; size_t file_len = 0; unsigned char *file_data = NULL; char *filename = NULL; unsigned char *icon_data = NULL; PurpleAccount *account = PURPLE_ACCOUNT(self); filename = RSTRING_PTR( filepath ); file = fopen( filename, "rb" ); if( file != NULL ) { // get file size fseek( file, 0, SEEK_END ); file_len = ftell( file ); fseek( file, 0, SEEK_SET ); // read data file_data = g_malloc( file_len ); fread( file_data, file_len, 1, file ); // close file fclose( file ); } else { rb_raise( rb_eRuntimeError, "Error when opening picture: %s", filename ); } // set filename // purple_account_set_buddy_icon_path( account, filename ); // set account icon icon_data = g_malloc( file_len ); memcpy( icon_data, file_data, file_len ); purple_buddy_icons_set_account_icon( account, icon_data, file_len ); // purple_account_set_bool( account, "use-global-buddyicon", 1 ); return Qtrue; }