345
346
update_user_presence(XMPP_SERVER_REC *server, const char *full_jid,
346
const char *show_str, const char *status, const char *priority_str)
347
const char *show_str, const char *status, const char *priority_str,
348
350
XMPP_ROSTER_GROUP_REC *group;
349
351
XMPP_ROSTER_USER_REC *user;
387
389
resource->show = show;
388
390
resource->status = g_strdup(status);
389
391
resource->priority = priority;
392
resource->pgp_keyid = pgp_keyid;
391
394
user->resources = g_slist_sort(
392
395
user->resources, func_sort_resource);
485
488
sig_recv_presence(XMPP_SERVER_REC *server, LmMessage *lmsg, const int type,
486
489
const char *id, const char *from, const char *to)
488
LmMessageNode *node, *node_show, *node_priority;
491
LmMessageNode *node, *node_show, *node_priority, *signature;
492
char *status, *pgp_keyid = NULL;
491
494
if (server->ischannel(SERVER(server), from))
496
499
node = lm_message_node_get_child(lmsg->node, "status");
497
500
status = node != NULL ? xmpp_recode_in(node->value) : NULL;
498
501
node_priority = lm_message_node_get_child(lmsg->node, "priority");
502
signature = lm_find_node(lmsg->node, "x", "xmlns", "jabber:x:signed");
504
char *send_to_gpg = malloc(sizeof( \
505
"-----BEGIN PGP SIGNATURE-----\n\n" \
506
"-----END PGP SIGNATURE-----\n")+ \
507
strlen(signature->value)+1 \
509
char *send_status = status ? status : "";
512
send_to_gpg[0] = '\0';
513
strcat(send_to_gpg, "-----BEGIN PGP SIGNATURE-----\n\n");
514
strcat(send_to_gpg, signature->value);
515
strcat(send_to_gpg, "-----END PGP SIGNATURE-----\n");
517
from_gpg = call_gpg("--verify", send_to_gpg, send_status, 1, 0);
520
/* If there is a good signature, grab the key ID */
521
if(from_gpg && strstr(from_gpg, "Good signature from")) {
522
char *s = strstr(from_gpg, "key ID ");
524
pgp_keyid = malloc(sizeof(*pgp_keyid)*9);
525
strncpy(pgp_keyid, s+7, 8);
529
if(from_gpg) free(from_gpg);
499
531
update_user_presence(server, from,
500
532
node_show != NULL ? node_show->value : NULL, status,
501
node_priority != NULL ? node_priority->value : NULL);
533
node_priority != NULL ? node_priority->value : NULL,
504
537
case LM_MESSAGE_SUB_TYPE_UNAVAILABLE: