nicklists and subject

v1
Tony Olagbaiye 4 years ago
parent a18a815c0c
commit c5436de370
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -5,7 +5,7 @@ endif
RM=rm -f RM=rm -f
FIND=find FIND=find
INCLUDES=-Ilibstrophe $(shell xml2-config --cflags) INCLUDES=-Ilibstrophe $(shell xml2-config --cflags)
CFLAGS+=$(DBGCFLAGS) -fno-omit-frame-pointer -fPIC -std=gnu99 -g -Wall -Wextra -Werror-implicit-function-declaration -Wno-missing-field-initializers -D_XOPEN_SOURCE=500 $(INCLUDES) CFLAGS+=$(DBGCFLAGS) -fno-omit-frame-pointer -fPIC -std=gnu99 -g -Wall -Wextra -Werror-implicit-function-declaration -Wno-missing-field-initializers -D_XOPEN_SOURCE=700 $(INCLUDES)
LDFLAGS+=$(DBGLDFLAGS) -shared -g $(DBGCFLAGS) LDFLAGS+=$(DBGLDFLAGS) -shared -g $(DBGCFLAGS)
LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs) LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs)

@ -90,10 +90,10 @@
* [ ] [#B] Edits * [ ] [#B] Edits
* [ ] [#B] Handle errors gracefully * [ ] [#B] Handle errors gracefully
* [ ] [#B] Presence/nicklist * [ ] [#B] Presence/nicklist
* [ ] [#B] Enters * [X] [#B] Enters
* [ ] [#B] Leaves * [ ] [#B] Leaves
* [ ] [#B] Tracking * [X] [#B] Tracking
* [ ] [#B] Set/show topic * [X] [#B] Set/show topic
* [ ] OMEMO (libsignal-protocol-c / axc) * [ ] OMEMO (libsignal-protocol-c / axc)
* [ ] Presence * [ ] Presence
* [ ] Messages * [ ] Messages

@ -323,7 +323,8 @@ void channel__member_speaking_rename_if_present(struct t_account *account,
for (j = 0; j < list_size; j++) for (j = 0; j < list_size; j++)
{ {
ptr_item = weechat_list_get (channel->members_speaking[i], j); ptr_item = weechat_list_get (channel->members_speaking[i], j);
if (ptr_item && (strcasecmp(weechat_list_string(ptr_item), nick) == 0)) if (ptr_item && (weechat_strcasecmp(weechat_list_string(ptr_item),
nick) == 0))
weechat_list_set(ptr_item, nick); weechat_list_set(ptr_item, nick);
} }
} }

@ -75,6 +75,8 @@ int version_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
int presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata) int presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
{ {
struct t_account *account = (struct t_account *)userdata; struct t_account *account = (struct t_account *)userdata;
struct t_user *user;
struct t_channel *channel;
const char *to, *from, *from_bare; const char *to, *from, *from_bare;
from = xmpp_stanza_get_from(stanza); from = xmpp_stanza_get_from(stanza);
@ -83,13 +85,14 @@ int presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
from_bare = xmpp_jid_bare(account->context, from); from_bare = xmpp_jid_bare(account->context, from);
to = xmpp_stanza_get_to(stanza); to = xmpp_stanza_get_to(stanza);
struct t_user *user = user__search(account, from); user = user__search(account, from);
if (!user) if (!user)
user = user__new(account, from, from); user = user__new(account, from, from);
struct t_channel *channel = channel__search(account, from_bare); channel = channel__search(account, from_bare);
if (!channel) if (!channel)
channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare); channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare);
channel__add_member(account, channel, from);
weechat_printf(account->buffer, "%s%s (%s) presence", weechat_printf(account->buffer, "%s%s (%s) presence",
weechat_prefix("action"), weechat_prefix("action"),
@ -101,7 +104,8 @@ int presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata) int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
{ {
struct t_account *account = (struct t_account *)userdata; struct t_account *account = (struct t_account *)userdata;
xmpp_stanza_t *body, *reply, *delay; struct t_channel *channel;
xmpp_stanza_t *body, *reply, *delay, *topic;
const char *type, *from, *from_bare, *to, *timestamp = 0; const char *type, *from, *from_bare, *to, *timestamp = 0;
char *intext, *replytext; char *intext, *replytext;
struct tm time = {0}; struct tm time = {0};
@ -109,7 +113,24 @@ int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
body = xmpp_stanza_get_child_by_name(stanza, "body"); body = xmpp_stanza_get_child_by_name(stanza, "body");
if (body == NULL) if (body == NULL)
{
topic = xmpp_stanza_get_child_by_name(stanza, "subject");
if (topic == NULL)
return 1;
intext = xmpp_stanza_get_text(topic);
from = xmpp_stanza_get_from(stanza);
if (from == NULL)
return 1;
from_bare = xmpp_jid_bare(account->context, from);
from = xmpp_jid_resource(account->context, from);
channel = channel__search(account, from_bare);
if (!channel)
channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare);
channel__update_topic(channel, intext ? intext : "", from, 0);
if (intext != NULL)
xmpp_free(account->context, intext);
return 1; return 1;
}
type = xmpp_stanza_get_type(stanza); type = xmpp_stanza_get_type(stanza);
if (type != NULL && strcmp(type, "error") == 0) if (type != NULL && strcmp(type, "error") == 0)
return 1; return 1;
@ -120,10 +141,8 @@ int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
to = xmpp_stanza_get_to(stanza); to = xmpp_stanza_get_to(stanza);
intext = xmpp_stanza_get_text(body); intext = xmpp_stanza_get_text(body);
if (intext == NULL)
intext = strdup("");
struct t_channel *channel = channel__search(account, from_bare); channel = channel__search(account, from_bare);
if (!channel) if (!channel)
channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare); channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare);
@ -146,15 +165,17 @@ int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
if (strcmp(to, channel->id) == 0) if (strcmp(to, channel->id) == 0)
weechat_printf_date_tags(channel->buffer, date, NULL, "%s[to %s]: %s", weechat_printf_date_tags(channel->buffer, date, NULL, "%s[to %s]: %s",
user__as_prefix_raw(account->context, from), user__as_prefix_raw(account->context, from),
to, intext); to, intext ? intext : "");
else if (weechat_string_match(intext, "/me *", 0)) else if (weechat_string_match(intext, "/me *", 0))
weechat_printf_date_tags(channel->buffer, date, NULL, "%s%s %s", weechat_printf_date_tags(channel->buffer, date, NULL, "%s%s %s",
weechat_prefix("action"), from, intext+4); weechat_prefix("action"), from,
intext ? intext+4 : "");
else else
weechat_printf_date_tags(channel->buffer, date, NULL, "%s%s", weechat_printf_date_tags(channel->buffer, date, NULL, "%s%s",
user__as_prefix_raw(account->context, from), user__as_prefix_raw(account->context, from),
intext); intext ? intext : "");
if (intext)
xmpp_free(account->context, intext); xmpp_free(account->context, intext);
return 1; return 1;

@ -95,6 +95,10 @@ void user__nicklist_add(struct t_account *account,
{ {
struct t_gui_nick_group *ptr_group; struct t_gui_nick_group *ptr_group;
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
char *name = user->profile.display_name;
if (channel && weechat_strcasecmp(xmpp_jid_bare(account->context, name),
channel->id) == 0)
name = xmpp_jid_resource(account->context, name);
ptr_buffer = channel ? channel->buffer : account->buffer; ptr_buffer = channel ? channel->buffer : account->buffer;
@ -102,7 +106,7 @@ void user__nicklist_add(struct t_account *account,
user->is_away ? user->is_away ?
"+" : "..."); "+" : "...");
weechat_nicklist_add_nick(ptr_buffer, ptr_group, weechat_nicklist_add_nick(ptr_buffer, ptr_group,
user->profile.display_name, name,
user->is_away ? user->is_away ?
"weechat.color.nicklist_away" : "weechat.color.nicklist_away" :
user__get_colour_for_nicklist(user), user__get_colour_for_nicklist(user),
@ -165,7 +169,7 @@ struct t_user *user__new(struct t_account *account,
new_user->profile.real_name = NULL; new_user->profile.real_name = NULL;
new_user->profile.display_name = display_name[0] ? new_user->profile.display_name = display_name[0] ?
strdup(display_name) : strdup(display_name) :
strdup("xmppbot"); strdup("???");
new_user->profile.real_name_normalized = NULL; new_user->profile.real_name_normalized = NULL;
new_user->profile.email = NULL; new_user->profile.email = NULL;
new_user->profile.team = NULL; new_user->profile.team = NULL;

Loading…
Cancel
Save