GithubHelp home page GithubHelp logo

Comments (4)

chrisballinger avatar chrisballinger commented on May 18, 2024

OTRCodec.m is where all of the real communication with the OTR library happens. I actually don't know how to explicitly request a disconnect at the moment, but I'm sure if you looked at the Adium OTR plugin source or pidgin-otr plugin you'd be able to figure out what is going on.

from chatsecure-ios.

gemamegantara avatar gemamegantara commented on May 18, 2024

in libotr/message.c, I see this function

/* Put a connection into the PLAINTEXT state, first sending the
  other side a notice that we're doing so if we're currently ENCRYPTED,
  and we think he's logged in. */

void otrl_message_disconnect(OtrlUserState us, const OtrlMessageAppOps *ops, void *opdata, const char *accountname, const char *protocol, const char *username)
{
    ConnContext *context = otrl_context_find(us, username, accountname,
        protocol, 0, NULL, NULL, NULL);

    if (!context) return;

    if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
        context->their_keyid > 0 &&
        ops->is_logged_in &&
        ops->is_logged_in(opdata, accountname, protocol, username) == 1) {
    if (ops->inject_message) {
        char *encmsg = NULL;
        gcry_error_t err;
        OtrlTLV *tlv = otrl_tlv_new(OTRL_TLV_DISCONNECTED, 0, NULL);

        err = otrl_proto_create_data(&encmsg, context, "", tlv,
            OTRL_MSGFLAGS_IGNORE_UNREADABLE);
        if (!err) {
        ops->inject_message(opdata, accountname, protocol,
            username, encmsg);
        }
        free(encmsg);
    }
    }

    otrl_context_force_plaintext(context);
    if (ops->update_context_list) {
    ops->update_context_list(opdata);
    }
}

and I see in Adium OTR plugin source, it also called that function to disconnect.
So I try to add this code below in your OTR iOS :

+(void) disconnectSession:(NSString*)sender recipient:(NSString*)recipient protocol:(NSString*)protocol
{
    
    OTRProtocolManager *protocolManager = [OTRProtocolManager sharedInstance];
    
    OtrlUserState userstate = protocolManager.encryptionManager.userState;
    
    if(!userstate)
        NSLog(@"userstate is nil!");

    otrl_message_disconnect(userstate, &ui_ops,
                                 NULL, [sender UTF8String], [protocol UTF8String],
                                 [recipient UTF8String]);
  
}

but it does nothing. It suppose to call the inject_message function. Can you help me here Chris ?

from chatsecure-ios.

chrisballinger avatar chrisballinger commented on May 18, 2024

Hmm if it isn't forcing plaintext by injecting a message then perhaps err != nil?

from chatsecure-ios.

chrisballinger avatar chrisballinger commented on May 18, 2024

Were you able to figure out the problem? I'm going to close this issue for now, feel free to reopen it if you have any other questions.

from chatsecure-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.