1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Finished handle usage

This commit is contained in:
James Booth 2013-05-20 22:51:35 +01:00
parent 4a8db64d7a
commit ecc62af305
6 changed files with 65 additions and 29 deletions

View File

@ -2017,6 +2017,12 @@ _cmd_roster(gchar **args, struct cmd_help_t help)
}
roster_change_handle(jid, handle);
if (handle == NULL) {
cons_show("Nickname for %s removed.", jid);
} else {
cons_show("Nickname for %s set to: %s.", jid, handle);
}
return TRUE;
}
}
@ -2064,6 +2070,7 @@ static gboolean
_cmd_status(gchar **args, struct cmd_help_t help)
{
char *usr = args[0];
char *usr_jid = NULL;
jabber_conn_status_t conn_status = jabber_get_connection_status();
win_type_t win_type = ui_current_win_type();
@ -2098,7 +2105,11 @@ _cmd_status(gchar **args, struct cmd_help_t help)
break;
case WIN_CONSOLE:
if (usr != NULL) {
cons_show_status(usr);
usr_jid = roster_jid_from_handle(usr);
if (usr_jid == NULL) {
usr_jid = usr;
}
cons_show_status(usr_jid);
} else {
cons_show("Usage: %s", help.usage);
}

View File

@ -122,11 +122,19 @@ cons_show_error(const char * const msg, ...)
}
void
cons_show_typing(const char * const short_from)
cons_show_typing(const char * const barejid)
{
PContact contact = roster_get_contact(barejid);
const char * display_usr = NULL;
if (p_contact_name(contact) != NULL) {
display_usr = p_contact_name(contact);
} else {
display_usr = barejid;
}
win_print_time(console, '-');
wattron(console->win, COLOUR_TYPING);
wprintw(console->win, "!! %s is typing a message...\n", short_from);
wprintw(console->win, "!! %s is typing a message...\n", display_usr);
wattroff(console->win, COLOUR_TYPING);
ui_console_dirty();
@ -704,14 +712,14 @@ cons_show_disco_items(GSList *items, const char * const jid)
}
void
cons_show_status(const char * const contact)
cons_show_status(const char * const barejid)
{
PContact pcontact = roster_get_contact(contact);
PContact pcontact = roster_get_contact(barejid);
if (pcontact != NULL) {
win_show_contact(console, pcontact);
} else {
cons_show("No such contact \"%s\" in roster.", contact);
cons_show("No such contact \"%s\" in roster.", barejid);
}
ui_console_dirty();
_cons_alert();

View File

@ -226,18 +226,18 @@ ui_duck_exists(void)
}
void
ui_contact_typing(const char * const from)
ui_contact_typing(const char * const barejid)
{
int win_index = _find_prof_win_index(from);
int win_index = _find_prof_win_index(barejid);
if (prefs_get_boolean(PREF_INTYPE)) {
// no chat window for user
if (win_index == NUM_WINS) {
cons_show_typing(from);
cons_show_typing(barejid);
// have chat window but not currently in it
} else if (win_index != current_index) {
cons_show_typing(from);
cons_show_typing(barejid);
current_win_dirty = TRUE;
// in chat window with user
@ -250,8 +250,16 @@ ui_contact_typing(const char * const from)
}
}
if (prefs_get_boolean(PREF_NOTIFY_TYPING))
notify_typing(from);
if (prefs_get_boolean(PREF_NOTIFY_TYPING)) {
PContact contact = roster_get_contact(barejid);
char const *display_usr = NULL;
if (p_contact_name(contact) != NULL) {
display_usr = p_contact_name(contact);
} else {
display_usr = barejid;
}
notify_typing(display_usr);
}
}
void
@ -490,7 +498,8 @@ ui_contact_offline(const char * const from, const char * const show,
_show_status_string(console, display_str->str, show, status, NULL, "--",
"offline");
int win_index = _find_prof_win_index(from);
int win_index = _find_prof_win_index(jidp->barejid);
cons_debug("INDEX %d", win_index);
if (win_index != NUM_WINS) {
ProfWin *window = windows[win_index];
_show_status_string(window, display_str->str, show, status, NULL, "--",
@ -802,21 +811,29 @@ ui_print_system_msg_from_recipient(const char * const from, const char *message)
}
void
ui_recipient_gone(const char * const from)
ui_recipient_gone(const char * const barejid)
{
int win_index;
ProfWin *window;
if (from == NULL)
if (barejid == NULL)
return;
win_index = _find_prof_win_index(from);
PContact contact = roster_get_contact(barejid);
const char * display_usr = NULL;
if (p_contact_name(contact) != NULL) {
display_usr = p_contact_name(contact);
} else {
display_usr = barejid;
}
win_index = _find_prof_win_index(barejid);
// chat window exists
if (win_index < NUM_WINS) {
window = windows[win_index];
win_print_time(window, '-');
win_print_time(window, '!');
wattron(window->win, COLOUR_GONE);
wprintw(window->win, "*%s ", from);
wprintw(window->win, "<- %s ", display_usr);
wprintw(window->win, "has left the conversation.");
wprintw(window->win, "\n");
wattroff(window->win, COLOUR_GONE);

View File

@ -58,10 +58,10 @@ notifier_uninit(void)
}
void
notify_typing(const char * const from)
notify_typing(const char * const handle)
{
char message[strlen(from) + 1 + 11];
sprintf(message, "%s: typing...", from);
char message[strlen(handle) + 1 + 11];
sprintf(message, "%s: typing...", handle);
_notify(message, 10000, "Incoming message");
}
@ -84,10 +84,10 @@ notify_invite(const char * const from, const char * const room,
}
void
notify_message(const char * const short_from)
notify_message(const char * const handle)
{
char message[strlen(short_from) + 1 + 10];
sprintf(message, "%s: message.", short_from);
char message[strlen(handle) + 1 + 10];
sprintf(message, "%s: message.", handle);
_notify(message, 10000, "Incoming message");
}

View File

@ -23,8 +23,8 @@
void notifier_init(void);
void notifier_uninit(void);
void notify_typing(const char * const from);
void notify_message(const char * const short_from);
void notify_typing(const char * const handle);
void notify_message(const char * const handle);
void notify_remind(void);
void notify_invite(const char * const from, const char * const room,
const char * const reason);

View File

@ -91,7 +91,7 @@ void ui_contact_online(const char * const barejid, const char * const resource,
void ui_contact_offline(const char * const from, const char * const show,
const char * const status);
void ui_disconnected(void);
void ui_recipient_gone(const char * const from);
void ui_recipient_gone(const char * const barejid);
void ui_outgoing_msg(const char * const from, const char * const to,
const char * const message);
void ui_room_join(Jid *jid);
@ -166,7 +166,7 @@ void cons_show_error(const char * const cmd, ...);
void cons_highlight_show(const char * const cmd);
void cons_show_contacts(GSList * list);
void cons_show_wins(void);
void cons_show_status(const char * const contact);
void cons_show_status(const char * const barejid);
void cons_show_info(PContact pcontact);
void cons_show_caps(const char * const contact, Resource *resource);
void cons_show_themes(GSList *themes);
@ -181,7 +181,7 @@ void cons_show_disco_info(const char *from, GSList *identities, GSList *features
void cons_show_room_invite(const char * const invitor, const char * const room,
const char * const reason);
void cons_check_version(gboolean not_available_msg);
void cons_show_typing(const char * const short_from);
void cons_show_typing(const char * const barejid);
void cons_show_incoming_message(const char * const short_from, const int win_index);
void cons_show_room_invites(GSList *invites);
void cons_show_received_subs(void);