diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-07-04 11:38:45 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-07-04 13:27:33 +0200 |
commit | 7c83ee02f22bed1166d3ffed208679fd016bb4b6 (patch) | |
tree | 91f3664c44f2903b57cbea5f81c249b286ea1702 /src | |
parent | 8dc75564c2c799fae37014604d3cb085b6fe9699 (diff) | |
download | weechat-7c83ee02f22bed1166d3ffed208679fd016bb4b6.zip |
tests: add tests on typing plugin functions
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/typing/typing-status.c | 37 | ||||
-rw-r--r-- | src/plugins/typing/typing-status.h | 5 |
2 files changed, 23 insertions, 19 deletions
diff --git a/src/plugins/typing/typing-status.c b/src/plugins/typing/typing-status.c index 298b9d496..1d4d540b6 100644 --- a/src/plugins/typing/typing-status.c +++ b/src/plugins/typing/typing-status.c @@ -53,6 +53,9 @@ typing_status_search_state (const char *state) { int i; + if (!state) + return -1; + for (i = 0; i < TYPING_STATUS_NUM_STATES; i++) { if (strcmp (typing_status_state_string[i], state) == 0) @@ -298,47 +301,47 @@ typing_status_nick_add (struct t_gui_buffer *buffer, const char *nick, } /* - * Removes a nick typing status from a buffer. + * Searches a nick typing status for a buffer. * - * Returns: - * 1: OK - * 0: error + * Returns pointer to t_typing_status found, NULL if not found. */ -void -typing_status_nick_remove (struct t_gui_buffer *buffer, const char *nick) +struct t_typing_status * +typing_status_nick_search (struct t_gui_buffer *buffer, const char *nick) { struct t_hashtable *ptr_nicks; - if (!typing_status_nicks) - return; + if (!typing_status_nicks || !buffer || !nick) + return NULL; ptr_nicks = weechat_hashtable_get (typing_status_nicks, buffer); if (!ptr_nicks) - return; + return NULL; - weechat_hashtable_remove (ptr_nicks, nick); + return weechat_hashtable_get (ptr_nicks, nick); } /* - * Searches a nick typing status for a buffer. + * Removes a nick typing status from a buffer. * - * Returns pointer to t_typing_status found, NULL if not found. + * Returns: + * 1: OK + * 0: error */ -struct t_typing_status * -typing_status_nick_search (struct t_gui_buffer *buffer, const char *nick) +void +typing_status_nick_remove (struct t_gui_buffer *buffer, const char *nick) { struct t_hashtable *ptr_nicks; if (!typing_status_nicks) - return NULL; + return; ptr_nicks = weechat_hashtable_get (typing_status_nicks, buffer); if (!ptr_nicks) - return NULL; + return; - return weechat_hashtable_get (ptr_nicks, nick); + weechat_hashtable_remove (ptr_nicks, nick); } /* diff --git a/src/plugins/typing/typing-status.h b/src/plugins/typing/typing-status.h index 8b5cc2417..0a1ed4e46 100644 --- a/src/plugins/typing/typing-status.h +++ b/src/plugins/typing/typing-status.h @@ -40,6 +40,7 @@ struct t_typing_status time_t last_typed; /* when was last char typed */ }; +extern char *typing_status_state_string[]; extern struct t_hashtable *typing_status_self; extern struct t_hashtable *typing_status_nicks; @@ -52,10 +53,10 @@ extern struct t_typing_status *typing_status_nick_add (struct t_gui_buffer *buff const char *nick, int state, int last_typed); -extern void typing_status_nick_remove (struct t_gui_buffer *buffer, - const char *nick); extern struct t_typing_status *typing_status_nick_search (struct t_gui_buffer *buffer, const char *nick); +extern void typing_status_nick_remove (struct t_gui_buffer *buffer, + const char *nick); extern void typing_status_end (); #endif /* WEECHAT_PLUGIN_TYPING_STATUS_H */ |