aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/libotr/libotr-3.2.0/src/message.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/libotr/libotr-3.2.0/src/message.h')
-rwxr-xr-xlinden/indra/libotr/libotr-3.2.0/src/message.h210
1 files changed, 210 insertions, 0 deletions
diff --git a/linden/indra/libotr/libotr-3.2.0/src/message.h b/linden/indra/libotr/libotr-3.2.0/src/message.h
new file mode 100755
index 0000000..e658e9d
--- /dev/null
+++ b/linden/indra/libotr/libotr-3.2.0/src/message.h
@@ -0,0 +1,210 @@
1/*
2 * Off-the-Record Messaging library
3 * Copyright (C) 2004-2008 Ian Goldberg, Chris Alexander, Nikita Borisov
4 * <otr@cypherpunks.ca>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of version 2.1 of the GNU Lesser General
8 * Public License as published by the Free Software Foundation.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef __MESSAGE_H__
21#define __MESSAGE_H__
22
23typedef enum {
24 OTRL_NOTIFY_ERROR,
25 OTRL_NOTIFY_WARNING,
26 OTRL_NOTIFY_INFO
27} OtrlNotifyLevel;
28
29typedef struct s_OtrlMessageAppOps {
30 /* Return the OTR policy for the given context. */
31 OtrlPolicy (*policy)(void *opdata, ConnContext *context);
32
33 /* Create a private key for the given accountname/protocol if
34 * desired. */
35 void (*create_privkey)(void *opdata, const char *accountname,
36 const char *protocol);
37
38 /* Report whether you think the given user is online. Return 1 if
39 * you think he is, 0 if you think he isn't, -1 if you're not sure.
40 *
41 * If you return 1, messages such as heartbeats or other
42 * notifications may be sent to the user, which could result in "not
43 * logged in" errors if you're wrong. */
44 int (*is_logged_in)(void *opdata, const char *accountname,
45 const char *protocol, const char *recipient);
46
47 /* Send the given IM to the given recipient from the given
48 * accountname/protocol. */
49 void (*inject_message)(void *opdata, const char *accountname,
50 const char *protocol, const char *recipient, const char *message);
51
52 /* Display a notification message for a particular accountname /
53 * protocol / username conversation. */
54 void (*notify)(void *opdata, OtrlNotifyLevel level,
55 const char *accountname, const char *protocol,
56 const char *username, const char *title,
57 const char *primary, const char *secondary);
58
59 /* Display an OTR control message for a particular accountname /
60 * protocol / username conversation. Return 0 if you are able to
61 * successfully display it. If you return non-0 (or if this
62 * function is NULL), the control message will be displayed inline,
63 * as a received message, or else by using the above notify()
64 * callback. */
65 int (*display_otr_message)(void *opdata, const char *accountname,
66 const char *protocol, const char *username, const char *msg);
67
68 /* When the list of ConnContexts changes (including a change in
69 * state), this is called so the UI can be updated. */
70 void (*update_context_list)(void *opdata);
71
72 /* Return a newly allocated string containing a human-friendly name
73 * for the given protocol id */
74 const char *(*protocol_name)(void *opdata, const char *protocol);
75
76 /* Deallocate a string allocated by protocol_name */
77 void (*protocol_name_free)(void *opdata, const char *protocol_name);
78
79 /* A new fingerprint for the given user has been received. */
80 void (*new_fingerprint)(void *opdata, OtrlUserState us,
81 const char *accountname, const char *protocol,
82 const char *username, unsigned char fingerprint[20]);
83
84 /* The list of known fingerprints has changed. Write them to disk. */
85 void (*write_fingerprints)(void *opdata);
86
87 /* A ConnContext has entered a secure state. */
88 void (*gone_secure)(void *opdata, ConnContext *context);
89
90 /* A ConnContext has left a secure state. */
91 void (*gone_insecure)(void *opdata, ConnContext *context);
92
93 /* We have completed an authentication, using the D-H keys we
94 * already knew. is_reply indicates whether we initiated the AKE. */
95 void (*still_secure)(void *opdata, ConnContext *context, int is_reply);
96
97 /* Log a message. The passed message will end in "\n". */
98 void (*log_message)(void *opdata, const char *message);
99
100 /* Find the maximum message size supported by this protocol. */
101 int (*max_message_size)(void *opdata, ConnContext *context);
102
103 /* Return a newly allocated string containing a human-friendly
104 * representation for the given account */
105 const char *(*account_name)(void *opdata, const char *account,
106 const char *protocol);
107
108 /* Deallocate a string returned by account_name */
109 void (*account_name_free)(void *opdata, const char *account_name);
110
111} OtrlMessageAppOps;
112
113/* Deallocate a message allocated by other otrl_message_* routines. */
114void otrl_message_free(char *message);
115
116/* Handle a message about to be sent to the network. It is safe to pass
117 * all messages about to be sent to this routine. add_appdata is a
118 * function that will be called in the event that a new ConnContext is
119 * created. It will be passed the data that you supplied, as well as a
120 * pointer to the new ConnContext. You can use this to add
121 * application-specific information to the ConnContext using the
122 * "context->app" field, for example. If you don't need to do this, you
123 * can pass NULL for the last two arguments of otrl_message_sending.
124 *
125 * tlvs is a chain of OtrlTLVs to append to the private message. It is
126 * usually correct to just pass NULL here.
127 *
128 * If this routine returns non-zero, then the library tried to encrypt
129 * the message, but for some reason failed. DO NOT send the message in
130 * the clear in that case.
131 *
132 * If *messagep gets set by the call to something non-NULL, then you
133 * should replace your message with the contents of *messagep, and
134 * send that instead. Call otrl_message_free(*messagep) when you're
135 * done with it. */
136gcry_error_t otrl_message_sending(OtrlUserState us,
137 const OtrlMessageAppOps *ops,
138 void *opdata, const char *accountname, const char *protocol,
139 const char *recipient, const char *message, OtrlTLV *tlvs,
140 char **messagep,
141 void (*add_appdata)(void *data, ConnContext *context),
142 void *data);
143
144/* Handle a message just received from the network. It is safe to pass
145 * all received messages to this routine. add_appdata is a function
146 * that will be called in the event that a new ConnContext is created.
147 * It will be passed the data that you supplied, as well as
148 * a pointer to the new ConnContext. You can use this to add
149 * application-specific information to the ConnContext using the
150 * "context->app" field, for example. If you don't need to do this, you
151 * can pass NULL for the last two arguments of otrl_message_receiving.
152 *
153 * If otrl_message_receiving returns 1, then the message you received
154 * was an internal protocol message, and no message should be delivered
155 * to the user.
156 *
157 * If it returns 0, then check if *messagep was set to non-NULL. If
158 * so, replace the received message with the contents of *messagep, and
159 * deliver that to the user instead. You must call
160 * otrl_message_free(*messagep) when you're done with it. If tlvsp is
161 * non-NULL, *tlvsp will be set to a chain of any TLVs that were
162 * transmitted along with this message. You must call
163 * otrl_tlv_free(*tlvsp) when you're done with those.
164 *
165 * If otrl_message_receiving returns 0 and *messagep is NULL, then this
166 * was an ordinary, non-OTR message, which should just be delivered to
167 * the user without modification. */
168int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
169 void *opdata, const char *accountname, const char *protocol,
170 const char *sender, const char *message, char **newmessagep,
171 OtrlTLV **tlvsp,
172 void (*add_appdata)(void *data, ConnContext *context),
173 void *data);
174
175/* Send a message to the network, fragmenting first if necessary.
176 * All messages to be sent to the network should go through this
177 * method immediately before they are sent, ie after encryption. */
178gcry_error_t otrl_message_fragment_and_send(const OtrlMessageAppOps *ops,
179 void *opdata, ConnContext *context, const char *message,
180 OtrlFragmentPolicy fragPolicy, char **returnFragment);
181
182/* Put a connection into the PLAINTEXT state, first sending the
183 * other side a notice that we're doing so if we're currently ENCRYPTED,
184 * and we think he's logged in. */
185void otrl_message_disconnect(OtrlUserState us, const OtrlMessageAppOps *ops,
186 void *opdata, const char *accountname, const char *protocol,
187 const char *username);
188
189/* Initiate the Socialist Millionaires' Protocol */
190void otrl_message_initiate_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
191 void *opdata, ConnContext *context, const unsigned char *secret,
192 size_t secretlen);
193
194/* Initiate the Socialist Millionaires' Protocol and send a prompt
195 * question to the buddy */
196void otrl_message_initiate_smp_q(OtrlUserState us,
197 const OtrlMessageAppOps *ops, void *opdata, ConnContext *context,
198 const char *question, const unsigned char *secret, size_t secretlen);
199
200/* Respond to a buddy initiating the Socialist Millionaires' Protocol */
201void otrl_message_respond_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
202 void *opdata, ConnContext *context, const unsigned char *secret,
203 size_t secretlen);
204
205/* Abort the SMP. Called when an unexpected SMP message breaks the
206 * normal flow. */
207void otrl_message_abort_smp(OtrlUserState us, const OtrlMessageAppOps *ops,
208 void *opdata, ConnContext *context);
209
210#endif