1
0
mirror of https://github.com/irssi/irssi.git synced 2024-08-04 03:34:18 -04:00

chat_protocol_register() didn't work properly when the chat protocol

was already registered.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1242 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-02-18 23:40:18 +00:00 committed by cras
parent 6a469c46bb
commit 0123ba3b26

View File

@ -102,27 +102,31 @@ CHAT_PROTOCOL_REC *chat_protocol_find_net(GHashTable *optlist)
CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec) CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec)
{ {
CHAT_PROTOCOL_REC *newrec; CHAT_PROTOCOL_REC *newrec;
int created;
g_return_val_if_fail(rec != NULL, NULL); g_return_val_if_fail(rec != NULL, NULL);
newrec = chat_protocol_find(rec->name); newrec = chat_protocol_find(rec->name);
if (newrec == NULL) created = newrec == NULL;
if (newrec == NULL) {
newrec = g_new0(CHAT_PROTOCOL_REC, 1); newrec = g_new0(CHAT_PROTOCOL_REC, 1);
else if (rec->fullname != NULL) { chat_protocols = g_slist_append(chat_protocols, newrec);
/* already registered */ } else {
return newrec; /* updating existing protocol */
g_free(newrec->name);
} }
memcpy(newrec, rec, sizeof(CHAT_PROTOCOL_REC)); memcpy(newrec, rec, sizeof(CHAT_PROTOCOL_REC));
newrec->id = module_get_uniq_id_str("PROTOCOL", rec->name); newrec->id = module_get_uniq_id_str("PROTOCOL", rec->name);
newrec->name = g_strdup(rec->name); newrec->name = g_strdup(rec->name);
chat_protocols = g_slist_append(chat_protocols, newrec);
if (default_proto == NULL) if (default_proto == NULL)
chat_protocol_set_default(newrec); chat_protocol_set_default(newrec);
signal_emit("chat protocol created", 1, newrec); if (created)
signal_emit("chat protocol created", 1, newrec);
else
signal_emit("chat protocol updated", 1, newrec);
return newrec; return newrec;
} }