X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fclient_notify.c;h=2ccb574c1ac8a384d7fd6a36939e8a0c5b097e52;hb=805fddcf6431e784f9f77114782a90c9d12f9cbe;hp=07d2589a85233c3d1e284fbd19f1dc4868e7432b;hpb=48ceb25636aaf832a00e0067405be63fd72622b2;p=silc.git diff --git a/lib/silcclient/client_notify.c b/lib/silcclient/client_notify.c index 07d2589a..2ccb574c 100644 --- a/lib/silcclient/client_notify.c +++ b/lib/silcclient/client_notify.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 Pekka Riikonen + Copyright (C) 1997 - 2008 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -56,9 +56,14 @@ static void silc_client_notify_resolved(SilcClient client, /* If entry is still invalid, resolving failed. Finish notify processing. */ if (notify->client_entry && !notify->client_entry->internal.valid) { /* If resolving timedout try it again many times. */ - if (status != SILC_STATUS_ERR_TIMEDOUT || ++notify->resolve_retry > 1000) + if (status != SILC_STATUS_ERR_TIMEDOUT || ++notify->resolve_retry > 1000) { silc_fsm_next(notify->fsm, silc_client_notify_processed); - silc_client_unref_client(client, conn, notify->client_entry); + + /* Unref client only in case of non-timeout error. In case of timeout + occurred, the routine reprocessing the notify is expected not to + create new references of the entry. */ + silc_client_unref_client(client, conn, notify->client_entry); + } } /* If no entries found, just finish the notify processing */ @@ -293,8 +298,14 @@ SILC_FSM_STATE(silc_client_notify_invite) /* Get the channel entry */ channel = silc_client_get_channel_by_id(client, conn, &id.u.channel_id); - if (!channel) - goto out; + if (!channel) { + /** Resolve channel */ + SILC_FSM_CALL(silc_client_get_channel_by_id_resolve( + client, conn, &id.u.channel_id, + silc_client_notify_resolved, + notify)); + /* NOT REACHED */ + } /* If channel is being resolved handle notify after resolving */ if (channel->internal.resolve_cmd_ident) { @@ -503,7 +514,7 @@ SILC_FSM_STATE(silc_client_notify_signoff) SilcNotifyType type = silc_notify_get_type(payload); SilcArgumentPayload args = silc_notify_get_args(payload); SilcClientEntry client_entry; - SilcChannelEntry channel; + SilcChannelEntry channel = NULL; unsigned char *tmp; SilcUInt32 tmp_len; SilcID id; @@ -524,20 +535,19 @@ SILC_FSM_STATE(silc_client_notify_signoff) if (tmp && tmp_len > 128) tmp[128] = '\0'; + if (packet->dst_id_type == SILC_ID_CHANNEL) + if (silc_id_str2id(packet->dst_id, packet->dst_id_len, SILC_ID_CHANNEL, + &id.u.channel_id, sizeof(id.u.channel_id))) + channel = silc_client_get_channel_by_id(client, conn, &id.u.channel_id); + /* Notify application */ if (client_entry->internal.valid) - NOTIFY(client, conn, type, client_entry, tmp); + NOTIFY(client, conn, type, client_entry, tmp, channel); /* Remove from channel */ - if (packet->dst_id_type == SILC_ID_CHANNEL) { - if (silc_id_str2id(packet->dst_id, packet->dst_id_len, SILC_ID_CHANNEL, - &id.u.channel_id, sizeof(id.u.channel_id))) { - channel = silc_client_get_channel_by_id(client, conn, &id.u.channel_id); - if (channel) { - silc_client_remove_from_channel(client, conn, channel, client_entry); - silc_client_unref_channel(client, conn, channel); - } - } + if (channel) { + silc_client_remove_from_channel(client, conn, channel, client_entry); + silc_client_unref_channel(client, conn, channel); } /* Delete client */ @@ -691,7 +701,7 @@ SILC_FSM_STATE(silc_client_notify_nick_change) SilcNotifyType type = silc_notify_get_type(payload); SilcArgumentPayload args = silc_notify_get_args(payload); SilcClientEntry client_entry = NULL; - unsigned char *tmp, oldnick[128 + 1]; + unsigned char *tmp, oldnick[256 + 1]; SilcUInt32 tmp_len; SilcID id, id2; SilcBool valid; @@ -928,13 +938,15 @@ SILC_FSM_STATE(silc_client_notify_cmode_change) if (!(channel->mode & SILC_CHANNEL_MODE_ULIMIT)) channel->user_limit = 0; - /* Save the new mode */ - channel->mode = mode; - /* Get the channel public key that was added or removed */ tmp = silc_argument_get_arg_type(args, 7, &tmp_len); if (tmp) - silc_client_channel_save_public_keys(channel, tmp, tmp_len); + silc_client_channel_save_public_keys(channel, tmp, tmp_len, FALSE); + else if (channel->mode & SILC_CHANNEL_MODE_CHANNEL_AUTH) + silc_client_channel_save_public_keys(channel, NULL, 0, TRUE); + + /* Save the new mode */ + channel->mode = mode; silc_rwlock_unlock(channel->internal.lock); @@ -1492,7 +1504,7 @@ SILC_FSM_STATE(silc_client_notify_error) if (!silc_argument_get_decoded(args, 2, SILC_ARGUMENT_ID, &id, NULL)) goto out; client_entry = silc_client_get_client_by_id(client, conn, &id.u.client_id); - if (client_entry) { + if (client_entry && client_entry != conn->local_entry) { silc_client_remove_from_channels(client, conn, client_entry); silc_client_del_client(client, conn, client_entry); silc_client_unref_client(client, conn, client_entry);