1 /* 2 * Off-the-Record Messaging plugin for pidgin 3 * Copyright (C) 2004-2012 Ian Goldberg, Rob Smits, 4 * Chris Alexander, Willy Lew, 5 * Lisa Du, Nikita Borisov 6 * <otr@cypherpunks.ca> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of version 2 of the GNU General Public License as 10 * published by the Free Software Foundation. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef __OTRG_OTR_PLUGIN_H__ 23 #define __OTRG_OTR_PLUGIN_H__ 24 25 /* Purple headers */ 26 #include "account.h" 27 #include "plugin.h" 28 29 /* libotr headers */ 30 #include <libotr/context.h> 31 #include <libotr/userstate.h> 32 #include <libotr/instag.h> 33 34 #define PRIVKEYFNAME "otr.private_key" 35 #define STOREFNAME "otr.fingerprints" 36 #define INSTAGFNAME "otr.instance_tags" 37 #define MAXMSGSIZEFNAME "otr.max_message_size" 38 39 extern PurplePlugin *otrg_plugin_handle; 40 41 extern OtrlUserState otrg_plugin_userstate; 42 43 /* Given a PurpleConversation, return the ConnContext corresponding to the 44 * selected instance tag. */ 45 ConnContext* otrg_plugin_conv_to_selected_context(PurpleConversation *conv, 46 int force_create); 47 48 /* Given a PurpleConversation, return the selected instag. */ 49 otrl_instag_t otrg_plugin_conv_to_selected_instag(PurpleConversation *conv, 50 otrl_instag_t default_value); 51 52 /* Send an IM from the given account to the given recipient. Display an 53 * error dialog if that account isn't currently logged in. */ 54 void otrg_plugin_inject_message(PurpleAccount *account, const char *recipient, 55 const char *message); 56 57 /* Generate a private key for the given accountname/protocol */ 58 void otrg_plugin_create_privkey(const char *accountname, 59 const char *protocol); 60 61 /* Generate a instance tag for the given accountname/protocol */ 62 void otrg_plugin_create_instag(const char *accountname, 63 const char *protocol); 64 65 /* Start the Socialist Millionaires' Protocol over the current connection, 66 * using the given initial secret, and optionally a question to pass to 67 * the buddy. */ 68 void otrg_plugin_start_smp(ConnContext *context, const char *question, 69 const unsigned char *secret, size_t secretlen); 70 void otrg_plugin_continue_smp(ConnContext *context, 71 const unsigned char *secret, size_t secretlen); 72 73 /* Abort the SMP protocol. Used when malformed or unexpected messages 74 * are received. */ 75 void otrg_plugin_abort_smp(ConnContext *context); 76 77 /* Send the default OTR Query message to the correspondent of the given 78 * context, from the given account. [account is actually a 79 * PurpleAccount*, but it's declared here as void* so this can be passed 80 * as a callback.] */ 81 void otrg_plugin_send_default_query(ConnContext *context, void *account); 82 83 /* Send the default OTR Query message to the correspondent of the given 84 * conversation. */ 85 void otrg_plugin_send_default_query_conv(PurpleConversation *conv); 86 87 /* Disconnect a context, sending a notice to the other side, if 88 * appropriate. */ 89 void otrg_plugin_disconnect(ConnContext *context); 90 91 /* Write the fingerprints to disk. */ 92 void otrg_plugin_write_fingerprints(void); 93 94 /* Find the ConnContext appropriate to a given PurpleConversation. */ 95 ConnContext *otrg_plugin_conv_to_context(PurpleConversation *conv, 96 otrl_instag_t their_instance, int force_create); 97 98 /* Find the PurpleConversation appropriate to the given userinfo. If 99 * one doesn't yet exist, create it if force_create is true. */ 100 PurpleConversation *otrg_plugin_userinfo_to_conv(const char *accountname, 101 const char *protocol, const char *username, int force_create); 102 103 /* Find the PurpleConversation appropriate to the given ConnContext. If 104 * one doesn't yet exist, create it if force_create is true. */ 105 PurpleConversation *otrg_plugin_context_to_conv(ConnContext *context, 106 int force_create); 107 108 109 typedef enum { 110 TRUST_NOT_PRIVATE, 111 TRUST_UNVERIFIED, 112 TRUST_PRIVATE, 113 TRUST_FINISHED 114 } TrustLevel; 115 116 /* What level of trust do we have in the privacy of this ConnContext? */ 117 TrustLevel otrg_plugin_context_to_trust(ConnContext *context); 118 119 /* Return 1 if the given protocol supports OTR, 0 otherwise. */ 120 int otrg_plugin_proto_supports_otr(const char *proto); 121 122 #endif 123