ekg2  GIT master
Funkcje | Zmienne
Dokumentacja pliku protocol.c
#include "ekg2.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "emoticons.h"
#include "objects.h"
Wykres zależności załączania dla protocol.c:

Funkcje

static int protocol_disconnected (void *data, va_list ap)
 
static int protocol_connected (void *data, va_list ap)
 
static int protocol_message_ack (void *data, va_list ap)
 
static int protocol_status (void *data, va_list ap)
 
static int protocol_message (void *data, va_list ap)
 
static int protocol_xstate (void *data, va_list ap)
 
static int protocol_userlist_changed (void *data, va_list ap)
 
void protocol_init ()
 
static gint protocol_reconnect_handler (gint type, session_t *s)
 
int protocol_disconnected_emit (const session_t *s, const char *reason, int type)
 
int protocol_connected_emit (const session_t *s)
 
int protocol_status_emit (const session_t *s, const char *uid, int status, char *descr, time_t when)
 
char * message_print (const char *session, const char *sender, const char **rcpts, const char *__text, const guint32 *format, time_t sent, int mclass, const char *seq, int dobeep, int secure)
 
int protocol_message_emit (const session_t *s, const char *uid, char **rcpts, const char *text, const guint32 *format, time_t sent, int mclass, const char *seq, int dobeep, int secure)
 
int protocol_message_ack_emit (const session_t *s, const char *rcpt, const char *seq, int status)
 
int protocol_xstate_emit (const session_t *s, const char *uid, int state, int offstate)
 
char * protocol_uid (const char *proto, const char *target)
 
static void dcc_free_item (dcc_t *data)
 
static void dccs_add (dcc_t *new_)
 
static void dccs_remove (dcc_t *elem)
 
dcc_tdcc_add (session_t *session, const char *uid, dcc_type_t type, void *priv)
 
int dcc_close (dcc_t *d)
 
dcc_close_handler_t dcc_close_handler_get (dcc_t *o)
 
int dcc_close_handler_set (dcc_t *o, dcc_close_handler_t v)
 
int dcc_filename_set (dcc_t *o, const char *v)
 
const char * dcc_filename_get (dcc_t *o)
 
int dcc_offset_get (dcc_t *o)
 
int dcc_offset_set (dcc_t *o, int v)
 
int dcc_size_get (dcc_t *o)
 
int dcc_size_set (dcc_t *o, int v)
 
const char * dcc_uid_get (dcc_t *o)
 
int dcc_id_get (dcc_t *o)
 
void * dcc_private_get (dcc_t *o)
 
int dcc_private_set (dcc_t *o, void *v)
 
time_t dcc_started_get (dcc_t *o)
 
int dcc_active_get (dcc_t *o)
 
int dcc_active_set (dcc_t *o, int v)
 
dcc_type_t dcc_type_get (dcc_t *o)
 
int dcc_type_set (dcc_t *o, dcc_type_t v)
 

Zmienne

static int auto_find_limit = 100
 
dcc_tdccs = NULL
 

Dokumentacja funkcji

◆ dcc_active_get()

int dcc_active_get ( dcc_t o)

◆ dcc_active_set()

int dcc_active_set ( dcc_t o,
int  v 
)

◆ dcc_add()

dcc_t* dcc_add ( session_t session,
const char *  uid,
dcc_type_t  type,
void *  priv 
)

◆ dcc_close()

int dcc_close ( dcc_t d)

◆ dcc_close_handler_get()

dcc_close_handler_t dcc_close_handler_get ( dcc_t o)

◆ dcc_close_handler_set()

int dcc_close_handler_set ( dcc_t o,
dcc_close_handler_t  v 
)

◆ dcc_filename_get()

const char* dcc_filename_get ( dcc_t o)

◆ dcc_filename_set()

int dcc_filename_set ( dcc_t o,
const char *  v 
)

◆ dcc_free_item()

static void dcc_free_item ( dcc_t data)
static

◆ dcc_id_get()

int dcc_id_get ( dcc_t o)

◆ dcc_offset_get()

int dcc_offset_get ( dcc_t o)

◆ dcc_offset_set()

int dcc_offset_set ( dcc_t o,
int  v 
)

◆ dcc_private_get()

void* dcc_private_get ( dcc_t o)

◆ dcc_private_set()

int dcc_private_set ( dcc_t o,
void *  v 
)

◆ dcc_size_get()

int dcc_size_get ( dcc_t o)

◆ dcc_size_set()

int dcc_size_set ( dcc_t o,
int  v 
)

◆ dcc_started_get()

time_t dcc_started_get ( dcc_t o)

◆ dcc_type_get()

dcc_type_t dcc_type_get ( dcc_t o)

◆ dcc_type_set()

int dcc_type_set ( dcc_t o,
dcc_type_t  v 
)

◆ dcc_uid_get()

const char* dcc_uid_get ( dcc_t o)

◆ dccs_add()

static void dccs_add ( dcc_t new_)
static

◆ dccs_remove()

static void dccs_remove ( dcc_t elem)
static

◆ message_print()

char* message_print ( const char *  session,
const char *  sender,
const char **  rcpts,
const char *  __text,
const guint32 *  format,
time_t  sent,
int  mclass,
const char *  seq,
int  dobeep,
int  secure 
)

◆ protocol_connected()

static int protocol_connected ( void *  data,
va_list  ap 
)
static

protocol_connected()

Handler for PROTOCOL_CONNECTED
When session notify core about connection we do here:

  • If we have ourselves on the userlist. It update status and description
  • Display notify through UI-plugin
  • If we have messages in session queue, than send it and display info.
  • Update last_conn state and set connected state to 1.
  • Remove "reconnect" timer.
Parametry
ap1st param: (char *) session - session uid which goes connected.
dataNULL
Zwraca
0

◆ protocol_connected_emit()

int protocol_connected_emit ( const session_t s)

◆ protocol_disconnected()

static int protocol_disconnected ( void *  data,
va_list  ap 
)
static

protocol_disconnected()

Handler for PROTOCOL_DISCONNECTED
When session notify core about disconnection we do here:

  • clear all user status, presence, resources details.
    Zobacz również
    userlist_clear_status()
  • update s->last_conn state, and set s->connected to 0
  • check if disconnect type was either EKG_DISCONNECT_NETWORK: or EKG_DISCONNECT_FAILURE: and if yes, create reconnect timer (if user set auto_reconnect variable)
  • display notify through UI-plugin
Nota
About different types [type] of disconnections:
  • EKG_DISCONNECT_USER - when user do /disconnect [with reason, in reason we should have param of /disconnect command][without reconnection]
  • EKG_DISCONNECT_NETWORK - when smth is wrong with network... (read: when recv() fail, or send() or SSL wrappers for rcving/sending data fail with -1 and with bad errno) [with reason describiny why we fail (strerror() is good here)][with reconnection]
  • EKG_DISCONNECT_FORCED - when server force us to disconnection. [without reason][without reconnection]
  • EKG_DISCONNECT_FAILURE - when we fail to connect to server (read: when we fail connect session, after /connect) [with reason describiny why we fail (strerror() is good here)][with reconnection]
  • EKG_DISCONNECT_STOPPED - when user do /disconnect during connection [without reason] [without reconnection]
Parametry
ap1st param: (char *) session - session uid which goes disconnect
ap2nd param: (char *) reason - reason why session goes disconnect.. It's reason specifed by user if EKG_DISCONNECT_USER, else string with error description like from: strerror().. [if EKG_DISCONNECT_FAILURE]
ap3rd param: (int) type - type of disconnection one of: [EKG_DISCONNECT_USER, EKG_DISCONNECT_NETWORK, EKG_DISCONNECT_FORCED, EKG_DISCONNECT_FAILURE, EKG_DISCONNECT_STOPPED]
dataNULL
Zwraca
0

◆ protocol_disconnected_emit()

int protocol_disconnected_emit ( const session_t s,
const char *  reason,
int  type 
)

◆ protocol_init()

void protocol_init ( )

protocol_init()

Init communication between core and PROTOCOL plugins

Here, we register main communication channels like:

  • status changes: PROTOCOL_STATUS
  • message I/O: PROTOCOL_MESSAGE
  • acknowledge of messages: PROTOCOL_MESSAGE_ACK
  • misc user events like typing notifies:PROTOCOL_XSTATE
  • session connection/disconnection: PROTOCOL_CONNECTED and PROTOCOL_DISCONNECTED
  • roster changes: USERLIST_ADDED and USERLIST_REMOVED and USERLIST_RENAMED
Zobacz również
query_connect() - Function to add listener on specified events.
query_emit() - Function to emit specified events.

◆ protocol_message()

static int protocol_message ( void *  data,
va_list  ap 
)
static

◆ protocol_message_ack()

static int protocol_message_ack ( void *  data,
va_list  ap 
)
static

protocol_message_ack()

Handler for PROTOCOL_MESSAGE_ACK When session notifies core about receiving acknowledgement for our message, we:

  • Remove message with given sequence id (seq) from msgqueue
    Zobacz również
    msg_queue_remove_seq()
  • If corresponding config_display_ack variable bit is set, then display notification through UI-plugin
Nota
About different types of confirmations (__status):
  • EKG_ACK_DELIVERED - when message was successfully delivered to user
  • EKG_ACK_QUEUED - when user is somewhat unavailable and server confirmed to accept the message for later delivery
  • EKG_ACK_DROPPED - when user or server rejected to deliver our message (forbidden content?) and it was dropped; further retries will probably fail, if second side doesn't perform some kind of action (e.g. add us to roster in GG)
  • EKG_ACK_TEMPFAIL - when server failed temporarily to deliver our message, but encourages us to try again later (e.g. message queue full)
  • EKG_ACK_UNKNOWN - when it's not clear what happened with our message
Do zrobienia:
Should we remove msg from msgqueue only when sequenceid and session and rcpt matches? I think it's buggy cause user at jabber can send us acknowledge of message which we never send, but if seq match with other message, which wasn't send (because session was for example disconnected) we remove that messageid, and than we'll never send it, and we'll never know that we don't send it.
Parametry
ap1st param: (char *) session - session which send this notify
ap2nd param: (char *) rcpt - user uid who confirm receiving messages
ap3rd param: (char *) seq - sequence id of message
ap4th param: int __status - type of confirmation; one of: [EKG_ACK_DELIVERED, EKG_ACK_QUEUED, EKG_ACK_DROPPED, EKG_ACK_TEMPFAIL, EKG_ACK_UNKNOWN]
dataNULL
Zwraca
0

◆ protocol_message_ack_emit()

int protocol_message_ack_emit ( const session_t s,
const char *  rcpt,
const char *  seq,
int  status 
)

◆ protocol_message_emit()

int protocol_message_emit ( const session_t s,
const char *  uid,
char **  rcpts,
const char *  text,
const guint32 *  format,
time_t  sent,
int  mclass,
const char *  seq,
int  dobeep,
int  secure 
)

◆ protocol_reconnect_handler()

static gint protocol_reconnect_handler ( gint  type,
session_t s 
)
static

protocol_reconnect_handler()

Handler of reconnect timer created by protocol_disconnected()

Parametry
type- 0 - If timer should do his job
1 - If timer'll be destroy, and handler should free his data
s- session to reconnect
Zwraca
-1 [TEMPORARY TIMER]

◆ protocol_status()

static int protocol_status ( void *  data,
va_list  ap 
)
static

◆ protocol_status_emit()

int protocol_status_emit ( const session_t s,
const char *  uid,
int  status,
char *  descr,
time_t  when 
)

◆ protocol_uid()

char* protocol_uid ( const char *  proto,
const char *  target 
)

◆ protocol_userlist_changed()

static int protocol_userlist_changed ( void *  data,
va_list  ap 
)
static

◆ protocol_xstate()

static int protocol_xstate ( void *  data,
va_list  ap 
)
static

◆ protocol_xstate_emit()

int protocol_xstate_emit ( const session_t s,
const char *  uid,
int  state,
int  offstate 
)

Dokumentacja zmiennych

◆ auto_find_limit

int auto_find_limit = 100
static

◆ dccs

dcc_t* dccs = NULL