Merge Irssi 0.8.16-rc1
[silc.git] / apps / irssi / src / core / queries.c
index cc16ad1e60877141531fb466e46ad9340e73a4d1..fd51fbb8bda03fd718d5fec24adcab4135e2db70 100644 (file)
@@ -13,9 +13,9 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
 #include "module.h"
 
 GSList *queries;
 
+static const char *query_get_target(WI_ITEM_REC *item)
+{
+       return ((QUERY_REC *) item)->name;
+}
+
 void query_init(QUERY_REC *query, int automatic)
 {
        g_return_if_fail(query != NULL);
@@ -37,6 +42,11 @@ void query_init(QUERY_REC *query, int automatic)
         MODULE_DATA_INIT(query);
        query->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY");
         query->destroy = (void (*) (WI_ITEM_REC *)) query_destroy;
+       query->get_target = query_get_target;
+       query->createtime = time(NULL);
+       query->last_unread_msg = time(NULL);
+       query->visible_name = g_strdup(query->name);
+
        if (query->server_tag != NULL) {
                query->server = server_find_tag(query->server_tag);
                if (query->server != NULL) {
@@ -66,6 +76,7 @@ void query_destroy(QUERY_REC *query)
        g_free_not_null(query->hilight_color);
         g_free_not_null(query->server_tag);
         g_free_not_null(query->address);
+       g_free(query->visible_name);
        g_free(query->name);
 
         query->type = 0;
@@ -121,7 +132,12 @@ void query_change_nick(QUERY_REC *query, const char *nick)
 
         oldnick = query->name;
        query->name = g_strdup(nick);
+
+       g_free(query->visible_name);
+       query->visible_name = g_strdup(nick);
+
        signal_emit("query nick changed", 2, query, oldnick);
+       signal_emit("window item name changed", 1, query);
         g_free(oldnick);
 }
 
@@ -155,5 +171,4 @@ void queries_init(void)
 
 void queries_deinit(void)
 {
-       module_uniq_destroy("QUERY");
 }