static void chatnet_read(CONFIG_NODE *node) { CHAT_PROTOCOL_REC *proto; CHATNET_REC *rec; char *type; if (node == NULL || node->key == NULL) return; type = config_node_get_str(node, "type", NULL); proto = type == NULL ? NULL : chat_protocol_find(type); if (proto == NULL) { proto = type == NULL ? chat_protocol_get_default() : chat_protocol_get_unknown(type); } if (type == NULL) iconfig_node_set_str(node, "type", proto->name); rec = proto->create_chatnet(); rec->type = module_get_uniq_id("CHATNET", 0); rec->chat_type = proto->id; rec->name = g_strdup(node->key); rec->nick = g_strdup(config_node_get_str(node, "nick", NULL)); rec->username = g_strdup(config_node_get_str(node, "username", NULL)); rec->realname = g_strdup(config_node_get_str(node, "realname", NULL)); rec->own_host = g_strdup(config_node_get_str(node, "host", NULL)); rec->autosendcmd = g_strdup(config_node_get_str(node, "autosendcmd", NULL)); chatnets = g_slist_append(chatnets, rec); signal_emit("chatnet read", 2, rec, node); }
void icb_core_deinit(void) { icb_servers_deinit(); icb_servers_reconnect_deinit(); icb_channels_deinit(); icb_protocol_deinit(); icb_commands_deinit(); icb_session_deinit(); signal_emit("chat protocol deinit", 1, chat_protocol_find("ICB")); chat_protocol_unregister("ICB"); }
static void test_server_destroy_flood(ServerDestroyFloodData *fixture, const void *data) { SERVER_REC *server; /* = g_new0(IRC_SERVER_REC, 1); */ CHAT_PROTOCOL_REC *proto; SERVER_CONNECT_REC *conn; GLogLevelFlags loglev; g_test_bug("796"); /* for the purpose of this exercise, we are ignoring the errors of g_hash_table_lookup failure */ loglev = g_log_set_always_fatal(G_LOG_FATAL_MASK); proto = chat_protocol_find("IRC"); conn = server_create_conn(proto->id, "localhost", 0, "", "", "user"); server = proto->server_init_connect(conn); server->session_reconnect = TRUE; server->tag = g_strdup("testserver"); g_test_message("created server: %p", server); /* we skip some initialisations that would try to send data */ /* irc_servers_deinit(); */ irc_session_deinit(); irc_irc_deinit(); server_connect_finished(server); /* make up for the skipped session init */ irc_server_init_bare_minimum(IRC_SERVER(server)); irc_irc_init(); irc_session_init(); /* irc_servers_init(); */ /* simulate failing irc_server_send_data() */ server->connection_lost = TRUE; /* chat_completion_deinit(); fe_messages_deinit(); irc_notifylist_deinit(); */ server_ref(server); signal_emit("event privmsg", 4, server, "#someroom :test message", "nick", "user@host"); server_unref(server); g_log_set_always_fatal(loglev); }
void xmpp_core_deinit(void) { xep_deinit(); /* deinit servers first to disconnect servers before unloading */ xmpp_servers_deinit(); xmpp_commands_deinit(); xmpp_servers_reconnect_deinit(); xmpp_settings_deinit(); protocol_deinit(); rosters_deinit(); stanzas_deinit(); signal_emit("chat protocol deinit", 1, chat_protocol_find("XMPP")); chat_protocol_unregister("XMPP"); }
void irc_core_deinit(void) { signal_emit("chat protocol deinit", 1, chat_protocol_find("IRC")); irc_expandos_deinit(); netsplit_deinit(); lag_deinit(); irc_commands_deinit(); ctcp_deinit(); irc_queries_deinit(); irc_channels_deinit(); irc_irc_deinit(); irc_servers_deinit(); irc_chatnets_deinit(); irc_session_deinit(); chat_protocol_unregister("IRC"); }
static void sig_layout_restore_item(WINDOW_REC *window, const char *type, CONFIG_NODE *node) { char *name, *tag, *chat_type; chat_type = config_node_get_str(node, "chat_type", NULL); name = config_node_get_str(node, "name", NULL); tag = config_node_get_str(node, "tag", NULL); if (name == NULL || tag == NULL) return; if (g_ascii_strcasecmp(type, "CHANNEL") == 0) { /* bind channel to window */ WINDOW_BIND_REC *rec = window_bind_add(window, tag, name); rec->sticky = TRUE; } else if (g_ascii_strcasecmp(type, "QUERY") == 0 && chat_type != NULL) { CHAT_PROTOCOL_REC *protocol; /* create query immediately */ signal_add("query created", (SIGNAL_FUNC) signal_query_created_curwin); restore_win = window; protocol = chat_protocol_find(chat_type); if (protocol == NULL) window_bind_add(window, tag, name); else if (protocol->query_create != NULL) protocol->query_create(tag, name, TRUE); else { QUERY_REC *query; query = g_new0(QUERY_REC, 1); query->chat_type = chat_protocol_lookup(chat_type); query->name = g_strdup(name); query->server_tag = g_strdup(tag); query_init(query, TRUE); } signal_remove("query created", (SIGNAL_FUNC) signal_query_created_curwin); } }
static void sig_window_restore_item(WINDOW_REC *window, const char *type, CONFIG_NODE *node) { char *name, *tag, *chat_type; chat_type = config_node_get_str(node, "chat_type", NULL); name = config_node_get_str(node, "name", NULL); tag = config_node_get_str(node, "tag", NULL); if (name == NULL || tag == NULL) return; if (g_strcasecmp(type, "CHANNEL") == 0) { /* bind channel to window */ WINDOW_BIND_REC *rec = window_bind_add(window, tag, name); rec->sticky = TRUE; } else if (g_strcasecmp(type, "QUERY") == 0 && chat_type != NULL) { /* create query immediately */ chat_protocol_find(chat_type)->query_create(tag, name, TRUE); } }
static void session_restore_server(CONFIG_NODE *node) { CHAT_PROTOCOL_REC *proto; SERVER_CONNECT_REC *conn; SERVER_REC *server; const char *chat_type, *address, *chatnet, *password, *nick; int port, handle; chat_type = config_node_get_str(node, "chat_type", NULL); address = config_node_get_str(node, "address", NULL); port = config_node_get_int(node, "port", 0); chatnet = config_node_get_str(node, "chatnet", NULL); password = config_node_get_str(node, "password", NULL); nick = config_node_get_str(node, "nick", NULL); handle = config_node_get_int(node, "handle", -1); if (chat_type == NULL || address == NULL || nick == NULL || handle < 0) return; proto = chat_protocol_find(chat_type); if (proto == NULL || proto->not_initialized) { if (handle < 0) close(handle); return; } conn = server_create_conn(proto->id, address, port, chatnet, password, nick); if (conn != NULL) { conn->reconnection = TRUE; conn->connect_handle = g_io_channel_new(handle); server = proto->server_init_connect(conn); server->version = g_strdup(config_node_get_str(node, "version", NULL)); server->session_reconnect = TRUE; signal_emit("session restore server", 2, server, node); proto->server_connect(server); } }
static void network_save(GObject *obj, NetworkConfig *network) { ChatProtocol *proto; GtkEntry *entry; const char *name, *proto_name; entry = g_object_get_data(obj, "name"); name = gtk_entry_get_text(entry); if (*name == '\0') { /* name can't be empty */ gui_popup_error("Network name can't be empty"); return; } if (network == NULL) { /* create network */ entry = g_object_get_data(obj, "protocol"); proto_name = gtk_entry_get_text(entry); proto = chat_protocol_find(proto_name); if (proto == NULL) proto = chat_protocol_get_unknown(proto_name); network = proto->create_chatnet(); network->chat_type = proto->id; } g_free(network->name); network->name = g_strdup(name); gui_entry_update(obj, "nick", &network->nick); gui_entry_update(obj, "username", &network->username); gui_entry_update(obj, "realname", &network->realname); gui_entry_update(obj, "own_host", &network->own_host); gui_entry_update(obj, "autosendcmd", &network->autosendcmd); chatnet_create(network); }
void muc_init(void) { CHAT_PROTOCOL_REC *chat; if ((chat = chat_protocol_find(XMPP_PROTOCOL_NAME)) != NULL) chat->channel_create = (CHANNEL_REC *(*) (SERVER_REC *, const char *, const char *, int))muc_create; disco_add_feature(XMLNS_MUC); muc_commands_init(); muc_events_init(); muc_nicklist_init(); muc_reconnect_init(); signal_add("xmpp features", sig_features); signal_add("channel created", sig_channel_created); signal_add("channel destroyed", sig_channel_destroyed); signal_add("server connected", sig_connected); signal_add("xmpp set presence", sig_set_presence); settings_add_int("xmpp_lookandfeel", "xmpp_history_maxstanzas", 30); }