Crypt-OTR

 view release on metacpan or  search on metacpan

crypt-otr.h  view on Meta::CPAN


// There is a struct name conflict with perl.h
#define context otr_context
#include <libotr/context.h>
#undef context

#include <libotr/proto.h>
#include <libotr/message.h>
#include <libotr/privkey.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define PRIVKEY_FILE_NAME "otr.private_key"
#define STORE_FILE_NAME "otr.fingerprints"

// max message size
const unsigned int CRYPT_OTR_MAX_SIZE = 65535;

typedef struct crypt_otr_user_state* CryptOTRUserState;

struct crypt_otr_user_state {
	OtrlUserState otrl_state;
	char* root;
	char* keyfile;
	char* fprfile;	
	unsigned int max_size;
    unsigned short privkey_loaded;

	CV* inject_cb;
	CV* system_message_cb;
	CV* connected_cb;
	CV* unverified_cb;
	CV* disconnected_cb;
	CV* stillconnected_cb;
	CV* error_cb;
	CV* warning_cb;
	CV* info_cb;
	CV* new_fpr_cb;
	CV* smp_request_cb;
};

typedef enum {
	SMP_PROGRESS,
	SMP_ESTABLISHED,
	SMP_REQUEST_SECRET,
	SMP_REQUEST_SECRET_Q
} SMPNotifyType;

void crypt_otr_store_callback( CV* struct_callback, CV* perl_callback );

char *expand_filename(const char *fname);

void 		crypt_otr_handle_connected(CryptOTRUserState in_state, ConnContext* context);
void 		crypt_otr_handle_trusted_connection( CryptOTRUserState in_state,  char* username );
void 		crypt_otr_handle_unverified_connection( CryptOTRUserState in_state, char* username );
void 		crypt_otr_handle_disconnection( CryptOTRUserState in_state, char* username );
void 		crypt_otr_handle_stillconnected( CryptOTRUserState in_state, char* username );

static int 	crypt_otr_display_otr_message( CryptOTRUserState crypt_state, const char* accountname, const char* protocol, const char* username, const char* message );
static void 	crypt_otr_inject_message( CryptOTRUserState crypt_state, const char* account, const char* protocol, const char* recipient, const char* message );

void crypt_otr_process_receiving( CryptOTRUserState crypt_state, const char* in_accountname, const char* in_protocol, int in_max, 
                                  const char* who, const char* message, SV**, short *out_should_discard );

void crypt_otr_notify( CryptOTRUserState crypt_state, OtrlNotifyLevel level, const char* accountname, const char* protocol, const char* username, const char* title, const char* primary, const char* secondary );

static void 	crypt_otr_message_disconnect( CryptOTRUserState crypt_state, ConnContext* ctx );
ConnContext* 	crypt_otr_get_context( CryptOTRUserState crypt_state, char* accountname, char* protocol, char* username );
void 		crypt_otr_create_privkey( CryptOTRUserState crypt_state, const char *accountname, const char *protocol);
void crypt_otr_load_privkey( CryptOTRUserState in_state, const char* in_account, const char* in_proto, int in_max );

void process_sending_im( char* who, char* message );

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.719 second using v1.00-cache-2.02-grep-82fe00e-cpan-2cc899e4a130 )