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

« back to all changes in this revision

Viewing changes to src/core/protocol.c

  • Committer: Package Import Robot
  • Author(s): Florian Schlichting
  • Date: 2015-03-27 21:44:52 UTC
  • Revision ID: package-import@ubuntu.com-20150327214452-fia86qdiv03fwee7
Tags: 0.52+git20140102-3
* Update XMPP-PGP support (closes: #779156)
* Add strip_resource_08082009.patch to optionally ignore random resource
  strings
* Bump Standards-Version to 3.9.6 (no changes necessary)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 */
17
17
 
18
18
#include "module.h"
 
19
#include "channels.h"
19
20
#include "signals.h"
20
21
#include "settings.h"
21
22
 
22
23
#include "xmpp-servers.h"
23
24
#include "rosters-tools.h"
24
25
#include "tools.h"
 
26
#include "xep/disco.h"
25
27
 
26
28
char *pgp_passwd = NULL;
27
29
 
62
64
        if((pgp_keyid = settings_get_str("xmpp_pgp"))) {
63
65
                LmMessageNode *x;
64
66
                char *signature = call_gpg("-ab", str, NULL, 0, 1);
 
67
                disco_add_feature("jabber:x:signed");
 
68
                disco_add_feature("jabber:x:encrypted");
65
69
 
66
70
                if(signature) {
67
71
                        x = lm_message_node_add_child(lmsg->node, "x", signature);
91
95
{
92
96
        LmMessageNode *node, *encrypted;
93
97
        char *str, *subject;
 
98
        const char *from_stripped;
 
99
 
 
100
        /* assing from_stripped. If setting xmpp_strip_resource is
 
101
           True and from is not from a channel private message set
 
102
           from_stripped to same as from, but strip the
 
103
           resource. Otherwise just duplicate from to
 
104
           from_stripped. */
 
105
        str = xmpp_strip_resource(from);
 
106
        from_stripped =
 
107
                ((settings_get_bool("xmpp_strip_resource")) &&
 
108
                 (channel_find(SERVER(server), str)) == NULL) ?
 
109
                g_strdup(str) : g_strdup(from);
 
110
        g_free(str);
94
111
        
95
112
        if ((type != LM_MESSAGE_SUB_TYPE_NOT_SET
96
113
            && type != LM_MESSAGE_SUB_TYPE_HEADLINE
103
120
                str = xmpp_recode_in(node->value);
104
121
                subject = g_strconcat("Subject: ", str, (void *)NULL);
105
122
                g_free(str);
106
 
                signal_emit("message private", 4, server, subject, from, from);
 
123
                signal_emit("message private", 4, server, subject, from_stripped, from);
107
124
                g_free(subject);
108
125
        }
109
126
 
140
157
        if(str) {
141
158
                if (g_ascii_strncasecmp(str, "/me ", 4) == 0)
142
159
                        signal_emit("message xmpp action", 5,
143
 
                            server, str+4, from, from,
 
160
                            server, str+4, from_stripped, from,
144
161
                            GINT_TO_POINTER(SEND_TARGET_NICK));
145
162
                else
146
163
                        signal_emit("message private", 4, server,
147
 
                            str, from, from);
 
164
                            str, from_stripped, from);
148
165
                g_free(str);
149
166
        }
150
167
}