-
Notifications
You must be signed in to change notification settings - Fork 5
/
plugin-all.h
148 lines (112 loc) · 5.48 KB
/
plugin-all.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
* Off-the-Record Messaging plugin for pidgin
* Copyright (C) 2004-2018 Ian Goldberg, Rob Smits,
* Chris Alexander, Willy Lew,
* Nikita Borisov
* The pidgin-otrng contributors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __OTRG_PLUGIN_ALL_H__
#define __OTRG_PLUGIN_ALL_H__
/* Purple headers */
#include <account.h>
#include <plugin.h>
/* libotr headers */
#include <libotr/context.h>
#include <libotr/instag.h>
#include <libotr/userstate.h>
#include <libotr-ng/messaging.h>
/* libotrng headers */
#include "otrng-client.h"
#include "plugin-conversation.h"
#include "pidgin-helpers.h"
#define PRIVKEY_FILE_NAME "otr.private_key"
#define INSTAG_FILE_NAME "otr.instance_tags"
#define MAX_MSG_SIZE_FILE_NAME "otr.max_message_size"
extern PurplePlugin *otrng_plugin_handle;
extern otrng_global_state_s *otrng_state;
/* Given a PurpleConversation, return the ConnContext corresponding to the
* selected instance tag. */
ConnContext *otrng_plugin_conv_to_selected_context(PurpleConversation *conv,
int force_create);
/* Given a PurpleConversation, return the selected instag. */
otrl_instag_t otrng_plugin_conv_to_selected_instag(PurpleConversation *conv,
otrl_instag_t default_val);
/* Send an IM from the given account to the given recipient. Display an
* error dialog if that account isn't currently logged in. */
void otrng_plugin_inject_message(PurpleAccount *account, const char *recipient,
const char *message);
/* Generate a instance tag for the given accountname/protocol */
void otrng_plugin_create_instag(const PurpleAccount *account);
// TODO: REPLACE by using opdata to get this information
otrng_plugin_conversation *
purple_conversation_to_plugin_conversation(const PurpleConversation *conv);
int otrng_plugin_buddy_is_offline(PurpleAccount *account, PurpleBuddy *buddy);
void otrng_plugin_send_non_interactive_auth(const char *username,
PurpleAccount *account);
otrng_client_s *
otrng_plugin_conversation_to_client(const otrng_plugin_conversation *conv);
otrng_plugin_conversation *
otrng_plugin_conversation_copy(const otrng_plugin_conversation *);
/* Start the Socialist Millionaires' Protocol over the current connection,
* using the given initial secret, and optionally a question to pass to
* the buddy. */
void otrng_plugin_start_smp(otrng_plugin_conversation *conv,
const unsigned char *question, const size_t q_len,
const unsigned char *secret, size_t secretlen);
void otrng_plugin_continue_smp(otrng_plugin_conversation *conv,
const unsigned char *secret, size_t secretlen);
/* Abort the SMP protocol. Used when malformed or unexpected messages
* are received. */
void otrng_plugin_abort_smp(const otrng_plugin_conversation *conv);
void otrng_plugin_send_default_query(otrng_plugin_conversation *conv);
/* Send the default OTR Query message to the correspondent of the given
* conversation. */
void otrng_plugin_send_default_query_conv(PurpleConversation *conv);
/* Disconnect a context, sending a notice to the other side, if
* appropriate. */
void otrng_plugin_disconnect(otrng_plugin_conversation *conv);
/* Find the ConnContext appropriate to a given PurpleConversation. */
ConnContext *otrng_plugin_conv_to_context(PurpleConversation *conv,
otrl_instag_t their_instance,
int force_create);
/* Find the PurpleConversation appropriate to the given ConnContext. If
* one doesn't yet exist, create it if force_create is true. */
PurpleConversation *otrng_plugin_context_to_conv(ConnContext *context,
int force_create);
typedef enum {
TRUST_NOT_PRIVATE,
TRUST_UNVERIFIED,
TRUST_PRIVATE,
TRUST_FINISHED
} TrustLevel;
TrustLevel
otrng_plugin_conversation_to_trust(const otrng_plugin_conversation *conv);
/* What level of trust do we have in the privacy of this ConnContext? */
TrustLevel otrng_plugin_context_to_trust(ConnContext *context);
/* Return 1 if the given protocol supports OTR, 0 otherwise. */
int otrng_plugin_proto_supports_otr(const char *proto);
int otrng_plugin_conversation_to_protocol_version(
const otrng_plugin_conversation *conv);
static inline PurpleConversation *
otrng_plugin_conversation_to_purple_conv(const otrng_plugin_conversation *conv,
int force) {
return otrng_plugin_userinfo_to_conv(conv->account, conv->protocol,
conv->peer, force);
}
gboolean otrng_plugin_unload(PurplePlugin *handle);
gboolean otrng_plugin_load(PurplePlugin *handle);
#endif