ekg2
Funkcje | Zmienne

Dokumentacja pliku ekg/protocol.c

#include "ekg2-config.h"
#include "win32.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "debug.h"
#include "dynstuff.h"
#include "dynstuff_inline.h"
#include "xmalloc.h"
#include "commands.h"
#include "emoticons.h"
#include "objects.h"
#include "userlist.h"
#include "windows.h"
#include "log.h"
#include "msgqueue.h"
#include "protocol.h"
#include "stuff.h"
#include "themes.h"
#include "queries.h"

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 int protocol_reconnect_handler (int 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 uint32_t *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 uint32_t *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 LIST_FREE_ITEM (dcc_free_item, dcc_t *)
 DYNSTUFF_LIST_DECLARE (dccs, dcc_t, dcc_free_item, static __DYNSTUFF_LIST_ADD, static __DYNSTUFF_LIST_REMOVE_SAFE, __DYNSTUFF_NODESTROY) dcc_t *dcc_add(session_t *session

Zmienne

static int auto_find_limit = 100
dcc_tdccs = NULL
const char * uid
const char dcc_type_t type

Dokumentacja funkcji

DYNSTUFF_LIST_DECLARE ( dccs  ,
dcc_t  ,
dcc_free_item  ,
static  __DYNSTUFF_LIST_ADD,
static  __DYNSTUFF_LIST_REMOVE_SAFE,
__DYNSTUFF_NODESTROY   
)
static LIST_FREE_ITEM ( dcc_free_item  ,
dcc_t  
) [static]
char* message_print ( const char *  session,
const char *  sender,
const char **  rcpts,
const char *  __text,
const uint32_t *  format,
time_t  sent,
int  mclass,
const char *  seq,
int  dobeep,
int  secure 
)
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
int protocol_connected_emit ( const session_t s)
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
int protocol_disconnected_emit ( const session_t s,
const char *  reason,
int  type 
)
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.
static int protocol_message ( void *  data,
va_list  ap 
) [static]
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
int protocol_message_ack_emit ( const session_t s,
const char *  rcpt,
const char *  seq,
int  status 
)
int protocol_message_emit ( const session_t s,
const char *  uid,
char **  rcpts,
const char *  text,
const uint32_t *  format,
time_t  sent,
int  mclass,
const char *  seq,
int  dobeep,
int  secure 
)
static int protocol_reconnect_handler ( int  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]
static int protocol_status ( void *  data,
va_list  ap 
) [static]
int protocol_status_emit ( const session_t s,
const char *  uid,
int  status,
char *  descr,
time_t  when 
)
char* protocol_uid ( const char *  proto,
const char *  target 
)
static int protocol_userlist_changed ( void *  data,
va_list  ap 
) [static]
static int protocol_xstate ( void *  data,
va_list  ap 
) [static]
int protocol_xstate_emit ( const session_t s,
const char *  uid,
int  state,
int  offstate 
)

Dokumentacja zmiennych

int auto_find_limit = 100 [static]
dcc_t* dccs = NULL
const char dcc_type_t type
const char* uid
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje