mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Now checks for exitence of contact before sending message
This commit is contained in:
parent
9e23060986
commit
e486114e05
@ -155,10 +155,12 @@ static struct cmd_t main_commands[] =
|
|||||||
|
|
||||||
{ "/who",
|
{ "/who",
|
||||||
_cmd_who,
|
_cmd_who,
|
||||||
{ "/who", "Find out who is online.",
|
{ "/who [status]", "Show contacts with chosen status.",
|
||||||
{ "/who",
|
{ "/who [status]",
|
||||||
"----",
|
"-------------",
|
||||||
"Show the list of all online contacts with their current status message.",
|
"Show contacts with the specified status, no status shows all contacts.",
|
||||||
|
"Possible statuses are: online, offline, away, dnd, xa, chat.",
|
||||||
|
"online includes: chat, dnd, away, xa.",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
{ "/close",
|
{ "/close",
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "contact.h"
|
#include "contact.h"
|
||||||
#include "prof_autocomplete.h"
|
#include "prof_autocomplete.h"
|
||||||
|
|
||||||
@ -70,3 +72,19 @@ find_contact(char *search_str)
|
|||||||
{
|
{
|
||||||
return p_autocomplete_complete(ac, search_str);
|
return p_autocomplete_complete(ac, search_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PContact
|
||||||
|
contact_list_get_contact(const char const *jid)
|
||||||
|
{
|
||||||
|
GSList *contacts = get_contact_list();
|
||||||
|
|
||||||
|
while (contacts != NULL) {
|
||||||
|
PContact contact = contacts->data;
|
||||||
|
if (strcmp(p_contact_name(contact), jid) == 0) {
|
||||||
|
return contact;
|
||||||
|
}
|
||||||
|
contacts = g_slist_next(contacts);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "contact.h"
|
||||||
|
|
||||||
void contact_list_init(void);
|
void contact_list_init(void);
|
||||||
void contact_list_clear(void);
|
void contact_list_clear(void);
|
||||||
void reset_search_attempts(void);
|
void reset_search_attempts(void);
|
||||||
@ -33,5 +35,6 @@ gboolean contact_list_add(const char * const name, const char * const show,
|
|||||||
gboolean contact_list_remove(const char * const name);
|
gboolean contact_list_remove(const char * const name);
|
||||||
GSList * get_contact_list(void);
|
GSList * get_contact_list(void);
|
||||||
char * find_contact(char *search_str);
|
char * find_contact(char *search_str);
|
||||||
|
PContact contact_list_get_contact(const char const *jid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "contact.h"
|
#include "contact.h"
|
||||||
|
#include "contact_list.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
@ -357,15 +358,23 @@ void
|
|||||||
win_show_outgoing_msg(const char * const from, const char * const to,
|
win_show_outgoing_msg(const char * const from, const char * const to,
|
||||||
const char * const message)
|
const char * const message)
|
||||||
{
|
{
|
||||||
int win_index = _find_prof_win_index(to);
|
// if the contact is offline, show a message
|
||||||
if (win_index == NUM_WINS)
|
PContact contact = contact_list_get_contact(to);
|
||||||
win_index = _new_prof_win(to);
|
|
||||||
|
if (contact == NULL) {
|
||||||
|
cons_show("%s is not one of your contacts.");
|
||||||
|
} else {
|
||||||
|
int win_index = _find_prof_win_index(to);
|
||||||
|
|
||||||
WINDOW *win = _wins[win_index].win;
|
if (win_index == NUM_WINS)
|
||||||
_win_show_time(win);
|
win_index = _new_prof_win(to);
|
||||||
_win_show_user(win, from, 0);
|
|
||||||
_win_show_message(win, message);
|
WINDOW *win = _wins[win_index].win;
|
||||||
_win_switch_if_active(win_index);
|
_win_show_time(win);
|
||||||
|
_win_show_user(win, from, 0);
|
||||||
|
_win_show_message(win, message);
|
||||||
|
_win_switch_if_active(win_index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user