~ubuntu-branches/ubuntu/trusty/irssi-plugin-xmpp/trusty

« back to all changes in this revision

Viewing changes to src/core/xmpp-commands.c

  • Committer: Package Import Robot
  • Author(s): Florian Schlichting, Florian Schlichting
  • Date: 2014-01-03 00:25:20 UTC
  • mfrom: (2.2.7 sid)
  • Revision ID: package-import@ubuntu.com-20140103002520-4ztm9phbq47vn4bl
Tags: 0.52+git20140102-1
[ Florian Schlichting ]
* Import Upstream version 0.52+git20140102
* Add VCS-* fields for collab-maint on alioth
* Add upstream git URL to Source field in debian/copyright
* Drop patches plucked from upstream CVS
* Refresh hardening.patch (offset, drop hunk fixed upstream)
* Provide xmpp-admin.pl script by Seth Difley
* Add GTalk-MUC-support.patch, plucked from github/freemandrew
* Add support for XMPP-PGP, plucked from github/singpolyma
* New useless-dependency-on-libidn.patch, to fix a lintian warning
* Declare compliance with Debian Policy 3.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: xmpp-commands.c,v 1.61 2010/07/14 16:07:13 cdidier Exp $
3
 
 *
4
2
 * Copyright (C) 2007 Colin DIDIER
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or modify
519
517
        int type;
520
518
 
521
519
        CMD_XMPP_SERVER(server);
522
 
        if (*data == '\0')
 
520
        if (item == NULL || *data == '\0')
523
521
                return;
524
522
        g_strstrip((char *)data);
525
523
        if (*data == '\0')
536
534
        g_free(recoded);
537
535
}
538
536
 
 
537
/* SYNTAX: XMPPPGP <on|off|KEYID> */
 
538
static void
 
539
cmd_xmpppgp(const char *data, XMPP_SERVER_REC *server, WI_ITEM_REC *item)
 
540
{
 
541
        if(IS_QUERY(item) && QUERY(item)->name) {
 
542
                XMPP_ROSTER_USER_REC *user = rosters_find_user(server->roster, \
 
543
                        QUERY(item)->name, NULL, NULL);
 
544
                XMPP_ROSTER_RESOURCE_REC *res;
 
545
                if(!user) goto error;
 
546
                res = rosters_find_resource(user->resources, \
 
547
                        xmpp_extract_resource(QUERY(item)->name));
 
548
                if(!res) goto error;
 
549
 
 
550
                if(res->pgp_keyid && strcmp(data, "on") == 0) {
 
551
                        res->pgp_encrypt = 1;
 
552
                } else if(strcmp(data, "off") == 0) {
 
553
                        res->pgp_encrypt = 0;
 
554
                } else {
 
555
                        res->pgp_keyid = malloc(9);
 
556
                        strcpy(res->pgp_keyid, data);
 
557
                }
 
558
        }
 
559
error:
 
560
        return;
 
561
}
 
562
 
539
563
char *
540
564
xmpp_get_dest(const char *cmd_dest, XMPP_SERVER_REC *server, WI_ITEM_REC *item)
541
565
{
581
605
        command_bind_xmpp("presence unsubscribe", NULL,
582
606
            (SIGNAL_FUNC)cmd_presence_unsubscribe);
583
607
        command_bind_xmpp("me", NULL, (SIGNAL_FUNC)cmd_me);
 
608
        command_bind_xmpp("xmpppgp", NULL, (SIGNAL_FUNC)cmd_xmpppgp);
584
609
        settings_add_str("xmpp", "xmpp_default_away_mode", "away");
585
610
}
586
611
 
605
630
        command_unbind("presence unsubscribe",
606
631
            (SIGNAL_FUNC)cmd_presence_unsubscribe);
607
632
        command_unbind("me", (SIGNAL_FUNC)cmd_me);
 
633
        command_unbind("xmpppgp", (SIGNAL_FUNC)cmd_xmpppgp);
608
634
}