From 14ca66e3947e30c08eee88bade538eb66b03b19b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Wed, 19 Nov 2014 06:20:02 +0100 Subject: [PATCH] Added profile parameter to TWC_CHECK_FRIEND_NUMBER macro. --- src/twc-commands.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/twc-commands.c b/src/twc-commands.c index 4ca8d86..5fe2f7c 100644 --- a/src/twc-commands.c +++ b/src/twc-commands.c @@ -90,8 +90,7 @@ enum TWC_FRIEND_MATCH } /** - * Make sure a profile with the given name exists. If not, warn user and - * abort. + * Make sure a profile with the given name exists. If not, warn user and abort. */ #define TWC_CHECK_PROFILE_EXISTS(profile) \ if (!profile) \ @@ -118,7 +117,7 @@ enum TWC_FRIEND_MATCH /** * Make sure friend exists. */ -#define TWC_CHECK_FRIEND_NUMBER(number, string) \ +#define TWC_CHECK_FRIEND_NUMBER(profile, number, string) \ if (number == TWC_FRIEND_MATCH_NOMATCH) \ { \ weechat_printf(profile->buffer, \ @@ -374,7 +373,7 @@ twc_cmd_friend(void *data, struct t_gui_buffer *buffer, else if (argc >= 3 && (weechat_strcasecmp(argv[1], "remove") == 0)) { int32_t friend_number = twc_match_friend(profile, argv[2]); - TWC_CHECK_FRIEND_NUMBER(friend_number, argv[2]); + TWC_CHECK_FRIEND_NUMBER(profile, friend_number, argv[2]); char *name = twc_get_name_nt(profile->tox, friend_number); if (tox_del_friend(profile->tox, friend_number) == 0) @@ -595,15 +594,13 @@ twc_cmd_invite(void *data, struct t_gui_buffer *buffer, if (argc == 1) return WEECHAT_RC_ERROR; - struct t_twc_profile *profile = twc_profile_search_buffer(buffer); - TWC_CHECK_PROFILE(profile); - TWC_CHECK_PROFILE_LOADED(profile); struct t_twc_chat *chat = twc_chat_search_buffer(buffer); + TWC_CHECK_PROFILE_LOADED(chat->profile); TWC_CHECK_GROUP_CHAT(chat); - int32_t friend_number = twc_match_friend(profile, argv_eol[1]); - TWC_CHECK_FRIEND_NUMBER(friend_number, argv_eol[1]); + int32_t friend_number = twc_match_friend(chat->profile, argv_eol[1]); + TWC_CHECK_FRIEND_NUMBER(chat->profile, friend_number, argv_eol[1]); int rc = tox_invite_friend(chat->profile->tox, friend_number, chat->group_number); @@ -676,7 +673,7 @@ twc_cmd_msg(void *data, struct t_gui_buffer *buffer, } int32_t friend_number = twc_match_friend(profile, recipient); - TWC_CHECK_FRIEND_NUMBER(friend_number, recipient); + TWC_CHECK_FRIEND_NUMBER(profile, friend_number, recipient); // create chat buffer if it does not exist struct t_twc_chat *chat = twc_chat_search_friend(profile, friend_number, true);