ekg2  GIT master
Funkcje | Zmienne
Dokumentacja pliku sessions.c
#include "ekg2.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "objects.h"
Wykres zależności załączania dla sessions.c:

Funkcje

static int session_compare (const session_t *data1, const session_t *data2)
 
static void sessions_add (session_t *new_)
 
static int sessions_count (void)
 
static void session_param_free_item (session_param_t *data)
 
static void session_vars_add (session_param_t **lista, session_param_t *new_)
 
static void session_vars_destroy (session_param_t **lista)
 
session_tsession_find_ptr (session_t *s)
 
session_tsession_find (const char *uid)
 
session_tsession_add (const char *uid)
 
static void session_free_item (session_t *data)
 
static void sessions_remove (session_t *elem)
 
static void sessions_destroy (void)
 
int session_remove (const char *uid)
 
int session_status_get (session_t *o)
 
int session_status_set (session_t *s, status_t status)
 
int session_password_set (session_t *s, const char *password)
 
const char * session_password_get (session_t *s)
 
const char * session_descr_get (session_t *o)
 
int session_descr_set (session_t *s, const char *descr)
 
int session_alias_set (session_t *o, const char *v)
 
const char * session_alias_get (session_t *o)
 
void * session_private_get (session_t *o)
 
int session_private_set (session_t *o, void *v)
 
int session_connected_get (session_t *o)
 
int session_connected_set (session_t *s, int connected)
 
const char * session_uid_get (session_t *o)
 
static const status_t session_statusdescr_split (const char **statusdescr)
 
static status_t session_status_nearest (session_t *s, status_t status)
 
static const int session_statusdescr_set (session_t *s, const char *statusdescr)
 
session_param_tsession_localvar_find (session_t *s, const char *key)
 
static plugins_params_tPLUGIN_VAR_FIND_BYID (plugin_t *plugin, int id)
 
const char * session_get (session_t *s, const char *key)
 
int session_int_get (session_t *s, const char *key)
 
int session_is_var (session_t *s, const char *key)
 
int session_set (session_t *s, const char *key, const char *value)
 
int session_int_set (session_t *s, const char *key, int value)
 
int session_read (const gchar *plugin_name)
 
void session_write ()
 
const char * session_format (session_t *s)
 
int session_check (session_t *s, int need_private, const char *protocol)
 
const char * session_name (session_t *s)
 
int session_unidle (session_t *s)
 
int session_command (const char *name, const char **params, session_t *session, const char *target, int quiet)
 
void sessions_free ()
 
void session_help (session_t *s, const char *name)
 
void changed_session_locks (const char *varname)
 

Zmienne

session_tsessions = NULL
 
session_tsession_current = NULL
 

Dokumentacja funkcji

◆ changed_session_locks()

void changed_session_locks ( const char *  varname)

changed_session_locks() is called whenever 'session_locks' variable changes it's value.

It should cleanup old locks and reinit new, if needed.

◆ PLUGIN_VAR_FIND_BYID()

static plugins_params_t* PLUGIN_VAR_FIND_BYID ( plugin_t plugin,
int  id 
)
static

◆ session_add()

session_t* session_add ( const char *  uid)

session_add()

Add session with uid to session list.
Check by plugin_find_uid() if any plugin can handle this type of session if not return NULL
Allocate memory for variables, switch windows.. etc, etc..
Emit global SESSION_ADDED plugin which handle this session can alloc memory for his private data

Do zrobienia:
See XXX's
Parametry
uid- full uid of new session
Zobacz również
session_remove() - To remove session
Zwraca
NULL if none plugin can handle this session uid
allocated session_t struct.

◆ session_alias_get()

const char* session_alias_get ( session_t o)

◆ session_alias_set()

int session_alias_set ( session_t o,
const char *  v 
)

◆ session_check()

int session_check ( session_t s,
int  need_private,
const char *  protocol 
)

◆ session_command()

int session_command ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

◆ session_compare()

static int session_compare ( const session_t data1,
const session_t data2 
)
static

◆ session_connected_get()

int session_connected_get ( session_t o)

◆ session_connected_set()

int session_connected_set ( session_t s,
int  connected 
)

◆ session_descr_get()

const char* session_descr_get ( session_t o)

◆ session_descr_set()

int session_descr_set ( session_t s,
const char *  descr 
)

◆ session_find()

session_t* session_find ( const char *  uid)

session_find()

It's search over sessions list and checks if we have session with uid uid

Parametry
uid- uid of session you look for
Zobacz również
session_find_ptr() - If you are looking for smth faster ;) but less reliable.
Zwraca
It returns pointer to session_t struct of found session, or NULL

◆ session_find_ptr()

session_t* session_find_ptr ( session_t s)

session_find_ptr()

it's search over sessions list and checks if param s is in that list. it's useful for all watch handler, and if programmer was too lazy to destroy watches associated with that session (in private watch data struct) before it gone.

Nota
It's possible to find another session with the same address as old one.. it's rather not possible.. however. It's better if you use session_find() function.. Yeah, i know it's slower.
Parametry
s- session to look for.
Zwraca
It returns s if session was found, otherwise NULL.

◆ session_format()

const char* session_format ( session_t s)

◆ session_free_item()

static void session_free_item ( session_t data)
static

◆ session_get()

const char* session_get ( session_t s,
const char *  key 
)

◆ session_help()

void session_help ( session_t s,
const char *  name 
)

◆ session_int_get()

int session_int_get ( session_t s,
const char *  key 
)

◆ session_int_set()

int session_int_set ( session_t s,
const char *  key,
int  value 
)

◆ session_is_var()

int session_is_var ( session_t s,
const char *  key 
)

◆ session_localvar_find()

session_param_t* session_localvar_find ( session_t s,
const char *  key 
)

◆ session_name()

const char* session_name ( session_t s)

◆ session_param_free_item()

static void session_param_free_item ( session_param_t data)
static

◆ session_password_get()

const char* session_password_get ( session_t s)

session_password_get()

It's decrypt ,,encrypted''(and return) using base64 from session struct (s->password) is s was passed, otherwise it cleanup decrypted password from internal buffer.

Nota
static buffer is a better idea - i think (del)
Zobacz również
base64_decode() - function to decode base64 strings.
session_get() - session_get() can be used to get password also... but it's just a wrapper with several xstrcmp() to this function so it's slower. Instead of using session_get(session, "password") it's better If you use: session_password_get(session)
Parametry
s- session of which we want get password from or NULL if we want to erase internal buf with password
Zwraca
,,decrypted'' password if succeed
otherwise ""
or even NULL if s was NULL

◆ session_password_set()

int session_password_set ( session_t s,
const char *  password 
)

◆ session_private_get()

void* session_private_get ( session_t o)

◆ session_private_set()

int session_private_set ( session_t o,
void *  v 
)

◆ session_read()

int session_read ( const gchar *  plugin_name)

◆ session_remove()

int session_remove ( const char *  uid)

session_remove()

Remove session with uid passed in uid
This function free session params variable and internal
session data like alias, current status, descr, password..
If sesssion is connected, /disconnect command will be executed with session uid as reason
Also it remove watches connected with this session (if watch->is_session && watch->data == s)br> It'll do window->session swapping if needed... and changing current session also.

Błąd:
Possible implementation/idea bug in window_session_cycle() I really don't know if we should change session on this windows... Maybe swaping is ok... but we really need think about protocol.. Now If we change session from jabber to gg one this window won't be very useful..
Nota
If plugin allocated memory for session example in s->priv you should connect to SESSION_REMOVED query event, and free alloced memory (remember about checking if this is your session) timers and watches will be automagicly removed.
Current ekg2 API have got session watches. Use watch_add_session()
Current ekg2 API have got timer watches. Use timer_add_session()
Parametry
uid- uid of session to remove
Zwraca
0 if session was found, and removed.
-1 if session wasn't founded.

◆ session_set()

int session_set ( session_t s,
const char *  key,
const char *  value 
)

◆ session_status_get()

int session_status_get ( session_t o)

◆ session_status_nearest()

static status_t session_status_nearest ( session_t s,
status_t  status 
)
inlinestatic

◆ session_status_set()

int session_status_set ( session_t s,
status_t  status 
)

◆ session_statusdescr_set()

static const int session_statusdescr_set ( session_t s,
const char *  statusdescr 
)
static

◆ session_statusdescr_split()

static const status_t session_statusdescr_split ( const char **  statusdescr)
inlinestatic

◆ session_uid_get()

const char* session_uid_get ( session_t o)

◆ session_unidle()

int session_unidle ( session_t s)

◆ session_vars_add()

static void session_vars_add ( session_param_t **  lista,
session_param_t new_ 
)
static

◆ session_vars_destroy()

static void session_vars_destroy ( session_param_t **  lista)
static

◆ session_write()

void session_write ( )

◆ sessions_add()

static void sessions_add ( session_t new_)
static

◆ sessions_count()

static int sessions_count ( void  )
static

◆ sessions_destroy()

static void sessions_destroy ( void  )
static

◆ sessions_free()

void sessions_free ( )

◆ sessions_remove()

static void sessions_remove ( session_t elem)
static

Dokumentacja zmiennych

◆ session_current

session_t* session_current = NULL

◆ sessions

session_t* sessions = NULL