Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / fe-common / core / windows-layout.c
index a19b2942485661324203a783f456ce52d8827e1d..223b65244c7dcbfc6695405744a204baa0a3f116 100644 (file)
@@ -61,12 +61,25 @@ static void sig_layout_restore_item(WINDOW_REC *window, const char *type,
                WINDOW_BIND_REC *rec = window_bind_add(window, tag, name);
                 rec->sticky = TRUE;
        } else if (g_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;
-               chat_protocol_find(chat_type)->query_create(tag, name, TRUE);
+               
+               protocol = chat_protocol_find(chat_type);
+               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);
@@ -136,6 +149,7 @@ static void sig_layout_save_item(WINDOW_REC *window, WI_ITEM_REC *item,
                                 CONFIG_NODE *node)
 {
        CONFIG_NODE *subnode;
+        CHAT_PROTOCOL_REC *proto;
        const char *type;
 
        type = module_find_id_str("WINDOW ITEM TYPE", item->type);
@@ -145,9 +159,11 @@ static void sig_layout_save_item(WINDOW_REC *window, WI_ITEM_REC *item,
        subnode = config_node_section(node, NULL, NODE_TYPE_BLOCK);
 
        iconfig_node_set_str(subnode, "type", type);
-       type = chat_protocol_find_id(item->chat_type)->name;
-       iconfig_node_set_str(subnode, "chat_type", type);
-       iconfig_node_set_str(subnode, "name", item->name);
+       proto = item->chat_type == 0 ? NULL :
+               chat_protocol_find_id(item->chat_type);
+       if (proto != NULL)
+               iconfig_node_set_str(subnode, "chat_type", proto->name);
+       iconfig_node_set_str(subnode, "name", item->visible_name);
 
        if (item->server != NULL)
                iconfig_node_set_str(subnode, "tag", item->server->tag);