[OTR-dev] SMP event handling

Ian Goldberg ian at cypherpunks.ca
Wed Jul 2 11:59:05 EDT 2008


I've checked in changes (largely from Willy) to add a callback to handle
SMP events.  Now there's no need to do anything at all in your
message_receiving function.  (Before, you had to implement part of the SMP
state machine there yourself.  Ick!)

The callback for gaim-otr is this:

static void handle_smp_event(void *opdata, OtrlSMPEvent smp_event,
        ConnContext *context, unsigned short progress_percent,
        char *question)
{
    if (!context) return;
    switch (smp_event)
    {
        case OTRL_SMPEVENT_ASK_FOR_SECRET :
            otrg_dialog_socialist_millionaires(context);
            break;
        case OTRL_SMPEVENT_ASK_FOR_ANSWER :
            otrg_dialog_socialist_millionaires_q(context, question);
            break;
        case OTRL_SMPEVENT_CHEATED :
            otrg_plugin_abort_smp(context);
            /* FALLTHROUGH */
        case OTRL_SMPEVENT_IN_PROGRESS :
        case OTRL_SMPEVENT_SUCCESS :
        case OTRL_SMPEVENT_FAILURE :
        case OTRL_SMPEVENT_ABORT :
            otrg_dialog_update_smp(context,
                    smp_event, ((gdouble)progress_percent)/100.0);
            break;
        case OTRL_SMPEVENT_ERROR :
            otrg_plugin_abort_smp(context);
            break;
    }
}

Does this look good to people?  Any changes you'd like?

Thanks,

   - Ian



More information about the OTR-dev mailing list