~ubuntu-branches/ubuntu/vivid/irssi-plugin-otr/vivid-proposed

« back to all changes in this revision

Viewing changes to otr.h

  • Committer: Package Import Robot
  • Author(s): Antoine Beaupré
  • Date: 2013-05-10 19:43:24 UTC
  • mfrom: (4.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130510194324-cxrycs8zwiofjia9
Tags: 1.0.0~alpha2-1
* Ship a second binary package, with debugging symbols.
* New upstream patch: gmodule-nolink.patch to remove extra linking.
* Upload to unstable now that libotr5 is usable there.
* Restore the libotr5-4.0.0-2.1 dependency to make sure this is usuable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Off-the-Record Messaging (OTR) module for the irssi IRC client
3
 
 * Copyright (C) 2008  Uli Meis <a.sporto+bee@gmail.com>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA
18
 
 */
19
 
 
20
 
#include <stdlib.h>
21
 
#include <unistd.h>
22
 
#include <errno.h>
23
 
 
24
 
/* OTR */
25
 
 
26
 
#include <libotr/proto.h>
27
 
#include <libotr/context.h>
28
 
#include <libotr/message.h>
29
 
#include <libotr/privkey.h>
30
 
 
31
 
/* glib */
32
 
 
33
 
#include <glib.h>
34
 
#include <glib/gprintf.h>
35
 
#include <glib/gstdio.h>
36
 
 
37
 
/* irssi */
38
 
 
39
 
#ifdef TARGET_IRSSI
40
 
#include <irssi_otr.h>
41
 
#endif
42
 
 
43
 
/* xchat */
44
 
 
45
 
#ifdef TARGET_XCHAT
46
 
#include <xchat_otr.h>
47
 
#endif
48
 
 
49
 
/* log stuff */
50
 
 
51
 
#define LOGMAX 1024
52
 
 
53
 
#define LVL_NOTICE  0
54
 
#define LVL_DEBUG   1
55
 
 
56
 
#define otr_logst(level,format,...) \
57
 
        otr_log(NULL,NULL,level,format, ## __VA_ARGS__)
58
 
 
59
 
void otr_log(IRC_CTX *server, const char *to, 
60
 
             int level, const char *format, ...);
61
 
 
62
 
/* own */
63
 
 
64
 
#include "io-config.h"
65
 
 
66
 
/* irssi module name */
67
 
#define MODULE_NAME "otr"
68
 
 
69
 
#include "otr-formats.h"
70
 
 
71
 
/* 
72
 
 * maybe this should be configurable?
73
 
 * I believe bitlbee has something >500.
74
 
 */
75
 
#define OTR_MAX_MSG_SIZE 400
76
 
 
77
 
/* otr protocol id */
78
 
#define PROTOCOLID "IRC"
79
 
 
80
 
#define KEYFILE    "/otr/otr.key"
81
 
#define TMPKEYFILE "/otr/otr.key.tmp"
82
 
#define FPSFILE    "/otr/otr.fp"
83
 
 
84
 
/* some defaults */
85
 
#define IO_DEFAULT_POLICY "*@localhost opportunistic,*bitlbee* opportunistic,*@im.* opportunistic, *serv@irc* never"
86
 
#define IO_DEFAULT_POLICY_KNOWN "* always"
87
 
#define IO_DEFAULT_IGNORE "xmlconsole[0-9]*"
88
 
 
89
 
/* one for each OTR context (=communication pair) */
90
 
struct co_info {
91
 
        char *msgqueue;                 /* holds partially reconstructed base64
92
 
                                           messages */
93
 
        IRC_CTX *ircctx;                /* irssi server object for this peer */
94
 
        int received_smp_init;          /* received SMP init msg */
95
 
        int smp_failed;                 /* last SMP failed */
96
 
        char better_msg_two[256];       /* what the second line of the "better"
97
 
                                           default query msg should like. Eat it
98
 
                                           up when it comes in */
99
 
        int finished;                   /* true after you've /otr finished */
100
 
};
101
 
 
102
 
/* these are returned by /otr contexts */
103
 
 
104
 
struct fplist_ {
105
 
        char *fp;
106
 
        enum { NOAUTH,AUTHSMP,AUTHMAN } authby;
107
 
        struct fplist_ *next;
108
 
};
109
 
 
110
 
struct ctxlist_ {
111
 
        char *username;
112
 
        char *accountname;
113
 
        enum { STUNENCRYPTED,STENCRYPTED,STFINISHED,STUNKNOWN } state;
114
 
        struct fplist_ *fplist;
115
 
        struct ctxlist_ *next;
116
 
};
117
 
 
118
 
/* policy list generated from /set otr_policy */
119
 
 
120
 
struct plistentry {
121
 
        GPatternSpec *namepat;
122
 
        OtrlPolicy policy;
123
 
};
124
 
 
125
 
/* used by the logging functions below */
126
 
extern int debug;
127
 
 
128
 
void irc_send_message(IRC_CTX *ircctx, const char *recipient, char *msg);
129
 
IRC_CTX *server_find_address(char *address);
130
 
 
131
 
/* init stuff */
132
 
 
133
 
int otrlib_init();
134
 
void otrlib_deinit();
135
 
void otr_initops();
136
 
void otr_setpolicies(const char *policies, int known);
137
 
 
138
 
/* basic send/receive/status stuff */
139
 
 
140
 
char *otr_send(IRC_CTX *server,const char *msg,const char *to);
141
 
char *otr_receive(IRC_CTX *server,const char *msg,const char *from);
142
 
int otr_getstatus(char *mynick, char *nick, char *server);
143
 
ConnContext *otr_getcontext(const char *accname,const char *nick,int create,void *data);
144
 
 
145
 
/* user interaction */
146
 
 
147
 
void otr_trust(IRC_CTX *server, char *nick, const char *peername);
148
 
void otr_finish(IRC_CTX *server, char *nick, const char *peername, int inquery);
149
 
void otr_auth(IRC_CTX *server, char *nick, const char *peername, const char *secret);
150
 
void otr_authabort(IRC_CTX *server, char *nick, const char *peername);
151
 
struct ctxlist_ *otr_contexts();
152
 
void otr_finishall();
153
 
 
154
 
 
155
 
/* key/fingerprint stuff */
156
 
 
157
 
void keygen_run(const char *accname);
158
 
void keygen_abort();
159
 
void key_load();
160
 
void fps_load();
161
 
void otr_writefps();
162