0.14.1: --chat: fix use of username without domain

One to one chats with a username without a domain would echo back
messages. Use the domain from the user's JID:

```
xmppipe -u user1@example.com --chat user2
```
master
Michael Santos 2 years ago
parent 15859bb11e
commit f9bdddd910

@ -1,4 +1,4 @@
Copyright (c) 2015-2016, Michael Santos <michael.santos@gmail.com>
Copyright (c) 2015-2022, Michael Santos <michael.santos@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above

@ -1,4 +1,4 @@
/* Copyright (c) 2015-2020, Michael Santos <michael.santos@gmail.com>
/* Copyright (c) 2015-2022, Michael Santos <michael.santos@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -237,7 +237,7 @@ int main(int argc, char **argv) {
state->out = xmppipe_strdup(state->room);
state->mucjid = xmppipe_mucjid(state->out, state->resource);
} else if (!(state->opt & XMPPIPE_OPT_GROUPCHAT)) {
state->out = xmppipe_strdup(jid);
state->out = xmppipe_chatjid(state->room, state->server);
}
if (xmppipe_fmt_init() < 0)

@ -1,4 +1,4 @@
/* Copyright (c) 2015-2019, Michael Santos <michael.santos@gmail.com>
/* Copyright (c) 2015-2022, Michael Santos <michael.santos@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -27,7 +27,7 @@
#include "strtonum.h"
#endif
#define XMPPIPE_VERSION "0.14.0"
#define XMPPIPE_VERSION "0.14.1"
#define XMPPIPE_RESOURCE "xmppipe"
#define XMPPIPE_STREQ(a, b) (strcmp((a), (b)) == 0)
@ -141,6 +141,7 @@ char *xmppipe_servername(char *);
char *xmppipe_roomname(char *);
char *xmppipe_conference(char *, char *);
char *xmppipe_mucjid(char *, char *);
char *xmppipe_chatjid(char *, char *);
void xmppipe_next_state(xmppipe_state_t *state, int status);
void xmppipe_stream_close(xmppipe_state_t *);

@ -1,4 +1,4 @@
/* Copyright (c) 2015-2019, Michael Santos <michael.santos@gmail.com>
/* Copyright (c) 2015-2022, Michael Santos <michael.santos@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -234,6 +234,15 @@ char *xmppipe_mucjid(char *muc, char *resource) {
return buf;
}
char *xmppipe_chatjid(char *jid, char *servername) {
size_t len = strlen(jid) + 1 + strlen(servername) + 1;
char *buf = xmppipe_malloc(len);
(void)snprintf(buf, len, "%s@%s", jid, servername);
return buf;
}
char *xmppipe_roomname(char *label) {
char *buf = NULL;
size_t len = 64;

Loading…
Cancel
Save