Changeset c239fff
- Timestamp:
- 2014-02-07T16:00:40Z (11 years ago)
- Branches:
- master
- Children:
- e76cf26
- Parents:
- 71004a3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user-guide/commands.xml
r71004a3 rc239fff 413 413 <bitlbee-command name="disconnect"> 414 414 <syntax>otr disconnect <nick></syntax> 415 416 <description> 417 418 <para> 419 Resets the connection with the specified user to cleartext. 415 <syntax>otr disconnect *</syntax> 416 417 <description> 418 419 <para> 420 Resets the connection with the specified user/all users to cleartext. 420 421 </para> 421 422 -
otr.c
r71004a3 rc239fff 208 208 int strsane(const char *s); 209 209 210 /* close the OTR connection with the given buddy */ 211 gboolean otr_disconnect_user(irc_t *irc, irc_user_t *u); 212 213 /* close all active OTR connections */ 214 void otr_disconnect_all(irc_t *irc); 215 210 216 /* functions to be called for certain events */ 211 217 static const struct irc_plugin otr_plugin; 212 213 218 214 219 /*** routines declared in otr.h: ***/ … … 283 288 { 284 289 otr_t *otr = irc->otr; 290 otr_disconnect_all(irc); 285 291 b_event_remove(otr->timer); 286 292 otrl_userstate_free(otr->us); … … 638 644 void op_gone_insecure(void *opdata, ConnContext *context) 639 645 { 640 /* XXX on 'otr disconnect', this gets called for every instance and we641 * get the message multiple times... */642 643 646 struct im_connection *ic = 644 647 check_imc(opdata, context->accountname, context->protocol); … … 949 952 irc_user_t *u; 950 953 951 u = irc_user_by_name(irc, args[1]); 952 if(!u || !u->bu || !u->bu->ic) { 953 irc_rootmsg(irc, "%s: unknown user", args[1]); 954 return; 955 } 956 957 /* XXX we disconnect all instances; is that what we want? */ 958 otrl_message_disconnect_all_instances(irc->otr->us, &otr_ops, 959 u->bu->ic, u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, u->bu->handle); 960 961 /* for some reason, libotr (4.0.0) doesn't do this itself: */ 962 if(!(u->flags & IRC_USER_OTR_ENCRYPTED)) 963 return; 964 965 ConnContext *ctx, *p; 966 ctx = otrl_context_find(irc->otr->us, u->bu->handle, u->bu->ic->acc->user, 967 u->bu->ic->acc->prpl->name, OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL); 968 if(!ctx) { /* huh? */ 969 u->flags &= ( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED ); 970 return; 971 } 972 973 for(p=ctx; p && p->m_context == ctx->m_context; p=p->next) 974 op_gone_insecure(u->bu->ic, p); 954 if(!strcmp("*", args[1])) { 955 otr_disconnect_all(irc); 956 irc_rootmsg(irc, "all conversations are now in cleartext"); 957 } else { 958 u = irc_user_by_name(irc, args[1]); 959 if(otr_disconnect_user(irc, u)) 960 irc_usernotice(u, "conversation is now in cleartext"); 961 else 962 irc_rootmsg(irc, "%s: unknown user", args[1]); 963 } 975 964 } 976 965 … … 2006 1995 } 2007 1996 1997 /* close the OTR connection with the given buddy */ 1998 gboolean otr_disconnect_user(irc_t *irc, irc_user_t *u) 1999 { 2000 if(!u || !u->bu || !u->bu->ic) 2001 return FALSE; 2002 2003 /* XXX we disconnect all instances; is that what we want? */ 2004 otrl_message_disconnect_all_instances(irc->otr->us, &otr_ops, 2005 u->bu->ic, u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, u->bu->handle); 2006 2007 u->flags &= ~IRC_USER_OTR_TRUSTED; 2008 u->flags &= ~IRC_USER_OTR_ENCRYPTED; 2009 otr_update_modeflags(irc, u); 2010 2011 return TRUE; 2012 } 2013 2014 /* close all active OTR connections */ 2015 void otr_disconnect_all(irc_t *irc) 2016 { 2017 irc_user_t *u; 2018 ConnContext *ctx; 2019 2020 for(ctx=irc->otr->us->context_root; ctx; ctx=ctx->next) { 2021 if(ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) { 2022 u = peeruser(irc, ctx->username, ctx->protocol); 2023 (void) otr_disconnect_user(irc, u); 2024 } 2025 } 2026 } 2027 2008 2028 /* vim: set noet ts=4 sw=4: */
Note: See TracChangeset
for help on using the changeset viewer.