ekg2
Funkcje | Zmienne

Dokumentacja pliku ekg/sessions.c

#include "ekg2-config.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 "debug.h"
#include "dynstuff.h"
#include "sessions.h"
#include "stuff.h"
#include "themes.h"
#include "userlist.h"
#include "vars.h"
#include "windows.h"
#include "xmalloc.h"
#include "dynstuff_inline.h"
#include "objects.h"
#include "compat/strlcpy.h"
#include "queries.h"

Funkcje

static int session_compare (session_t *data1, session_t *data2)
static __DYNSTUFF_LIST_ADD_SORTED (sessions, session_t, session_compare)
static __DYNSTUFF_LIST_COUNT (sessions, session_t)
static LIST_FREE_ITEM (session_param_free_item, session_param_t *)
static __DYNSTUFF_ADD_BEGINNING (session_vars, session_param_t, NULL)
static __DYNSTUFF_DESTROY (session_vars, session_param_t, session_param_free_item)
session_tsession_find_ptr (session_t *s)
session_tsession_find (const char *uid)
session_tsession_add (const char *uid)
static LIST_FREE_ITEM (session_free_item, session_t *)
static __DYNSTUFF_LIST_REMOVE_SAFE (sessions, session_t, session_free_item)
static __DYNSTUFF_LIST_DESTROY (sessions, session_t, session_free_item)
int session_remove (const char *uid)
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)
int session_descr_set (session_t *s, const char *descr)
int session_connected_set (session_t *s, int connected)
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 char *filename)
int 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

static __DYNSTUFF_ADD_BEGINNING ( session_vars  ,
session_param_t  ,
NULL   
) [static]
static __DYNSTUFF_DESTROY ( session_vars  ,
session_param_t  ,
session_param_free_item   
) [static]
static __DYNSTUFF_LIST_ADD_SORTED ( sessions  ,
session_t  ,
session_compare   
) [static]
static __DYNSTUFF_LIST_COUNT ( sessions  ,
session_t   
) [static]
static __DYNSTUFF_LIST_DESTROY ( sessions  ,
session_t  ,
session_free_item   
) [static]
static __DYNSTUFF_LIST_REMOVE_SAFE ( sessions  ,
session_t  ,
session_free_item   
) [static]
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.

static LIST_FREE_ITEM ( session_free_item  ,
session_t  
) [static]
static LIST_FREE_ITEM ( session_param_free_item  ,
session_param_t  
) [static]
static plugins_params_t* PLUGIN_VAR_FIND_BYID ( plugin_t plugin,
int  id 
) [static]
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.
int session_check ( session_t s,
int  need_private,
const char *  protocol 
)
int session_command ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)
static int session_compare ( session_t data1,
session_t data2 
) [static]
int session_connected_set ( session_t s,
int  connected 
)
int session_descr_set ( session_t s,
const char *  descr 
)
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_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.
const char* session_format ( session_t s)
const char* session_get ( session_t s,
const char *  key 
)
void session_help ( session_t s,
const char *  name 
)
int session_int_get ( session_t s,
const char *  key 
)
int session_int_set ( session_t s,
const char *  key,
int  value 
)
int session_is_var ( session_t s,
const char *  key 
)
session_param_t* session_localvar_find ( session_t s,
const char *  key 
)
const char* session_name ( session_t s)
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
int session_password_set ( session_t s,
const char *  password 
)
int session_read ( const char *  filename)
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.
int session_set ( session_t s,
const char *  key,
const char *  value 
)
static status_t session_status_nearest ( session_t s,
status_t  status 
) [inline, static]
int session_status_set ( session_t s,
status_t  status 
)
static const int session_statusdescr_set ( session_t s,
const char *  statusdescr 
) [static]
static const status_t session_statusdescr_split ( const char **  statusdescr) [inline, static]
int session_unidle ( session_t s)
int session_write ( )
void sessions_free ( )

Dokumentacja zmiennych

 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje