Added profile parameter to TWC_CHECK_FRIEND_NUMBER macro.

This commit is contained in:
Håvard Pettersson 2014-11-19 06:20:02 +01:00
parent 8585b09700
commit 14ca66e394

View File

@ -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);