Added SILC Thread Queue API
[runtime.git] / apps / irssi / src / core / nicklist.c
index b7e8540725c4b5c8902e710437e75f1ae9b95dd6..4f322bf55a5dd225030d3a473b0b0f3a1e75a2ef 100644 (file)
@@ -102,6 +102,9 @@ static void nicklist_destroy(CHANNEL_REC *channel, NICK_REC *nick)
 {
        signal_emit("nicklist remove", 2, channel, nick);
 
+       if (channel->ownnick == nick)
+                channel->ownnick = NULL;
+
         /*MODULE_DATA_DEINIT(nick);*/
        g_free(nick->nick);
        g_free_not_null(nick->realname);
@@ -353,8 +356,16 @@ GSList *nicklist_get_same_unique(SERVER_REC *server, void *id)
        return rec.list;
 }
 
+#if GLIB_MAJOR_VERSION < 2
+/* glib1 doesn't have g_slist_sort_with_data, so non-standard prefixes won't be sorted correctly */
+int nicklist_compare_glib1(NICK_REC *p1, NICK_REC *p2)
+{
+       return nicklist_compare(p1, p2, NULL);
+}
+#endif
+
 /* nick record comparision for sort functions */
-int nicklist_compare(NICK_REC *p1, NICK_REC *p2)
+int nicklist_compare(NICK_REC *p1, NICK_REC *p2, const char *nick_prefix)
 {
        int status1, status2;
        
@@ -366,7 +377,10 @@ int nicklist_compare(NICK_REC *p1, NICK_REC *p2)
         * returns :-)
         * -- yath */
 
-       if (p1->op)
+       if (p1->other) {
+               const char *other = (nick_prefix == NULL) ? NULL : strchr(nick_prefix, p1->other);
+               status1 = (other == NULL) ? 5 : 1000 - (other - nick_prefix);
+       } else if (p1->op)
                status1 = 4;
        else if (p1->halfop)
                status1 = 3;
@@ -375,7 +389,10 @@ int nicklist_compare(NICK_REC *p1, NICK_REC *p2)
        else
                status1 = 1;
 
-       if (p2->op)
+       if (p2->other) {
+               const char *other = (nick_prefix == NULL) ? NULL : strchr(nick_prefix, p2->other);
+               status2 = (other == NULL) ? 5 : 1000 - (other - nick_prefix);
+       } else if (p2->op)
                status2 = 4;
        else if (p2->halfop)
                status2 = 3;