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
FIND=find
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)
LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs)

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

@ -323,7 +323,8 @@ void channel__member_speaking_rename_if_present(struct t_account *account,
for (j = 0; j < list_size; 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);
}
}

@ -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)
{
struct t_account *account = (struct t_account *)userdata;
struct t_user *user;
struct t_channel *channel;
const char *to, *from, *from_bare;
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);
to = xmpp_stanza_get_to(stanza);
struct t_user *user = user__search(account, from);
user = user__search(account, from);
if (!user)
user = user__new(account, from, from);
struct t_channel *channel = channel__search(account, from_bare);
channel = channel__search(account, from_bare);
if (!channel)
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_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)
{
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;
char *intext, *replytext;
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");
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;
}
type = xmpp_stanza_get_type(stanza);
if (type != NULL && strcmp(type, "error") == 0)
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);
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)
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)
weechat_printf_date_tags(channel->buffer, date, NULL, "%s[to %s]: %s",
user__as_prefix_raw(account->context, from),
to, intext);
to, intext ? intext : "");
else if (weechat_string_match(intext, "/me *", 0))
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
weechat_printf_date_tags(channel->buffer, date, NULL, "%s%s",
user__as_prefix_raw(account->context, from),
intext);
intext ? intext : "");
if (intext)
xmpp_free(account->context, intext);
return 1;

@ -95,6 +95,10 @@ void user__nicklist_add(struct t_account *account,
{
struct t_gui_nick_group *ptr_group;
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;
@ -102,7 +106,7 @@ void user__nicklist_add(struct t_account *account,
user->is_away ?
"+" : "...");
weechat_nicklist_add_nick(ptr_buffer, ptr_group,
user->profile.display_name,
name,
user->is_away ?
"weechat.color.nicklist_away" :
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.display_name = display_name[0] ?
strdup(display_name) :
strdup("xmppbot");
strdup("???");
new_user->profile.real_name_normalized = NULL;
new_user->profile.email = NULL;
new_user->profile.team = NULL;

Loading…
Cancel
Save