mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Refactored roster_change_name
This commit is contained in:
parent
ef920971e0
commit
06ce95f68a
@ -1110,7 +1110,10 @@ cmd_roster(gchar **args, struct cmd_help_t help)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
roster_change_name(jid, name);
|
const char *barejid = p_contact_barejid(contact);
|
||||||
|
roster_change_name(contact, name);
|
||||||
|
GSList *groups = p_contact_groups(contact);
|
||||||
|
roster_send_name_change(barejid, name, groups);
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
cons_show("Nickname for %s removed.", jid);
|
cons_show("Nickname for %s removed.", jid);
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
#include "contact.h"
|
#include "contact.h"
|
||||||
#include "jid.h"
|
#include "jid.h"
|
||||||
#include "tools/autocomplete.h"
|
#include "tools/autocomplete.h"
|
||||||
#include "xmpp/xmpp.h"
|
|
||||||
#include "profanity.h"
|
#include "profanity.h"
|
||||||
|
#include "xmpp/xmpp.h"
|
||||||
|
|
||||||
// nicknames
|
// nicknames
|
||||||
static Autocomplete name_ac;
|
static Autocomplete name_ac;
|
||||||
@ -157,21 +157,19 @@ roster_free(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
roster_change_name(const char * const barejid, const char * const new_name)
|
roster_change_name(PContact contact, const char * const new_name)
|
||||||
{
|
{
|
||||||
PContact contact = g_hash_table_lookup(contacts, barejid);
|
assert(contact != NULL);
|
||||||
|
|
||||||
const char *current_name = NULL;
|
const char *current_name = NULL;
|
||||||
|
const char *barejid = p_contact_barejid(contact);
|
||||||
|
|
||||||
if (p_contact_name(contact) != NULL) {
|
if (p_contact_name(contact) != NULL) {
|
||||||
current_name = strdup(p_contact_name(contact));
|
current_name = strdup(p_contact_name(contact));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact != NULL) {
|
|
||||||
p_contact_set_name(contact, new_name);
|
p_contact_set_name(contact, new_name);
|
||||||
_replace_name(current_name, new_name, barejid);
|
_replace_name(current_name, new_name, barejid);
|
||||||
|
|
||||||
GSList *groups = p_contact_groups(contact);
|
|
||||||
roster_send_name_change(barejid, new_name, groups);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -37,7 +37,7 @@ gboolean roster_contact_offline(const char * const barejid,
|
|||||||
void roster_reset_search_attempts(void);
|
void roster_reset_search_attempts(void);
|
||||||
void roster_init(void);
|
void roster_init(void);
|
||||||
void roster_free(void);
|
void roster_free(void);
|
||||||
void roster_change_name(const char * const barejid, const char * const new_name);
|
void roster_change_name(PContact contact, const char * const new_name);
|
||||||
void roster_remove(const char * const name, const char * const barejid);
|
void roster_remove(const char * const name, const char * const barejid);
|
||||||
void roster_update(const char * const barejid, const char * const name,
|
void roster_update(const char * const barejid, const char * const name,
|
||||||
GSList *groups, const char * const subscription, gboolean pending_out);
|
GSList *groups, const char * const subscription, gboolean pending_out);
|
||||||
|
Loading…
Reference in New Issue
Block a user