1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-30 21:55:24 +00:00

Handle when servers do not send fulljid with presence

A default resource "__prof_default" is created, and invisible to the
user for most purposes.
This commit is contained in:
James Booth 2013-04-07 19:19:02 +01:00
parent b6095ca955
commit f4041f049c
2 changed files with 42 additions and 16 deletions

View File

@ -457,13 +457,21 @@ ui_contact_online(const char * const barejid, const char * const resource,
const char * const show, const char * const status, GDateTime *last_activity)
{
Jid *jid = jid_create_from_bare_and_resource(barejid, resource);
_show_status_string(console->win, jid->fulljid, show, status, last_activity, "++",
char *display_str = NULL;
if (strcmp(jid->resourcepart, "__prof_default") == 0) {
display_str = jid->barejid;
} else {
display_str = jid->fulljid;
}
_show_status_string(console->win, display_str, show, status, last_activity, "++",
"online");
int win_index = _find_prof_win_index(barejid);
if (win_index != NUM_WINS) {
WINDOW *win = windows[win_index]->win;
_show_status_string(win, jid->fulljid, show, status, last_activity, "++",
_show_status_string(win, display_str, show, status, last_activity, "++",
"online");
}
@ -477,12 +485,21 @@ void
ui_contact_offline(const char * const from, const char * const show,
const char * const status)
{
_show_status_string(console->win, from, show, status, NULL, "--", "offline");
Jid *jidp = jid_create(from);
char *display_str = NULL;
if (strcmp(jidp->resourcepart, "__prof_default") == 0) {
display_str = jidp->barejid;
} else {
display_str = jidp->fulljid;
}
_show_status_string(console->win, display_str, show, status, NULL, "--", "offline");
int win_index = _find_prof_win_index(from);
if (win_index != NUM_WINS) {
WINDOW *win = windows[win_index]->win;
_show_status_string(win, from, show, status, NULL, "--", "offline");
_show_status_string(win, display_str, show, status, NULL, "--", "offline");
}
if (win_index == current_index)

View File

@ -339,6 +339,10 @@ _unavailable_handler(xmpp_conn_t * const conn,
if (strcmp(my_jid->barejid, from_jid->barejid) !=0) {
if (from_jid->resourcepart != NULL) {
prof_handle_contact_offline(from_jid->barejid, from_jid->resourcepart, status_str);
// hack for servers that do not send full jid with unavailable presence
} else {
prof_handle_contact_offline(from_jid->barejid, "__prof_default", status_str);
}
} else {
if (from_jid->resourcepart != NULL) {
@ -409,21 +413,26 @@ _available_handler(xmpp_conn_t * const conn,
}
}
// handle resource, if exists
if (from_jid->resourcepart != NULL) {
resource_presence_t presence = resource_presence_from_string(show_str);
Resource *resource = resource_new(from_jid->resourcepart, presence,
resource_presence_t presence = resource_presence_from_string(show_str);
Resource *resource = NULL;
// hack for servers that do not send fulljid with initial presence
if (from_jid->resourcepart == NULL) {
resource = resource_new("__prof_default", presence,
status_str, priority, caps_key);
} else {
resource = resource_new(from_jid->resourcepart, presence,
status_str, priority, caps_key);
}
// self presence
if (strcmp(my_jid->barejid, from_jid->barejid) ==0) {
connection_add_available_resource(resource);
// self presence
if (strcmp(my_jid->barejid, from_jid->barejid) ==0) {
connection_add_available_resource(resource);
// contact presence
} else {
prof_handle_contact_online(from_jid->barejid, resource,
last_activity);
}
// contact presence
} else {
prof_handle_contact_online(from_jid->barejid, resource,
last_activity);
}
jid_destroy(my_jid);