ekg2
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje Grupay Strony
Definicje | Funkcje | Zmienne
Dokumentacja pliku gg.c
#include "ekg2-config.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <limits.h>
#include <unistd.h>
#include <time.h>
#include <libgadu.h>
#include <ekg/commands.h>
#include <ekg/debug.h>
#include <ekg/dynstuff.h>
#include <ekg/msgqueue.h>
#include <ekg/protocol.h>
#include <ekg/sessions.h>
#include <ekg/stuff.h>
#include <ekg/userlist.h>
#include <ekg/themes.h>
#include <ekg/vars.h>
#include <ekg/xmalloc.h>
#include <ekg/log.h>
#include <ekg/queries.h>
#include "dcc.h"
#include "gg.h"
#include "misc.h"
#include "pubdir.h"
#include "images.h"
#include "pubdir50.h"

Definicje

#define GG_ACK_BLOCKED   0x0001
#define GG_ACK_MBOXFULL   0x0004

Funkcje

static int gg_theme_init ()
static void gg_session_handler_msg (session_t *s, struct gg_event *e)
 PLUGIN_DEFINE (gg, PLUGIN_PROTOCOL, gg_theme_init)
static int gg_session_init (void *data, va_list ap)
static int gg_session_deinit (void *data, va_list ap)
static int gg_userlist_info_handle (void *data, va_list ap)
static int gg_user_offline_handle (void *data, va_list ap)
static int gg_user_online_handle (void *data, va_list ap)
static int gg_status_show_handle (void *data, va_list ap)
uin_t str_to_uin (const char *text)
static int gg_add_notify_handle (void *data, va_list ap)
static int gg_remove_notify_handle (void *data, va_list ap)
static int gg_print_version (void *data, va_list ap)
static int gg_validate_uid (void *data, va_list ap)
static int gg_userlist_priv_handler (void *data, va_list ap)
static int gg_ping_timer_handler (int type, session_t *s)
static int gg_inv_check_handler (int type, void *data)
static void gg_session_handler_success (session_t *s)
static void gg_session_handler_failure (session_t *s, struct gg_event *e)
static void gg_session_handler_disconnect (session_t *s)
static void gg_session_handler_status (session_t *s, uin_t uin, int status, const char *descr, uint32_t ip, uint16_t port, int protocol)
static void gg_session_handler_ack (session_t *s, struct gg_event *e)
static void gg_session_handler_image (session_t *s, struct gg_event *e)
static void gg_session_handler_userlist (session_t *s, struct gg_event *e)
int gg_session_handler (int type, int fd, watch_type_t watch, session_t *s)
static void gg_changed_private (session_t *s, const char *var)
static void gg_changed_proxy (session_t *s, const char *var)
static void gg_statusdescr_handler (session_t *s, const char *varname)
static int gg_setvar_default (void *data, va_list ap)
static void libgadu_debug_handler (int level, const char *format, va_list ap)
static int gg_scroll_timer (int type, void *data)
int EXPORT gg_plugin_init (int prio)
static int gg_plugin_destroy ()

Zmienne

list_t gg_currently_checked = NULL
char * last_tokenid
int gg_config_display_token
int gg_config_skip_default_format
int gg_config_split_messages
static plugins_params_t gg_plugin_vars []
static const char * gg_protocols [] = { "gg:", NULL }
static const status_t gg_statuses []
static struct protocol_plugin_priv gg_priv

Dokumentacja definicji

#define GG_ACK_BLOCKED   0x0001
#define GG_ACK_MBOXFULL   0x0004

Dokumentacja funkcji

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

gg_add_notify_handle()

Handler for: ADD_NOTIFY
(Emited by: /add command, when you successfully add smb to the userlist)
Notify gg server about it.

Do zrobienia:
We ignore gg_add_notify_ex() result
Parametry
ap1st param: (char *) session_uid - session uid
ap2nd param: (char *) uid - user uid
dataNULL
Zwraca
1 - If smth is wrong, session_uid or uid isn't valid gg number, or session is without private struct.
else 0
static void gg_changed_private ( session_t s,
const char *  var 
)
static

gg_changed_private()

When connected, notify gg server about our privacy policy [Do we or don't we want to notify users not in our userlist about our status/description
Handler executed when session variable: "private" change.

Parametry
s- session
var- session variable name
static void gg_changed_proxy ( session_t s,
const char *  var 
)
static

changed_proxy()

Handler execute when session variable: "proxy" change

Błąd:
BIG XXX, Mistake at art, it should use global config variable, not session ones, because it's used to inform libgadu about proxy servers.
And libgadu has got this variables global, not session private. Maybe we somehow can update these variables before gg_login() by callng gg_changed_proxy() but now it's BAD, BAD, BAD.
static int gg_inv_check_handler ( int  type,
void *  data 
)
static
static int gg_ping_timer_handler ( int  type,
session_t s 
)
static
static int gg_plugin_destroy ( )
static
int EXPORT gg_plugin_init ( int  prio)
static int gg_print_version ( void *  data,
va_list  ap 
)
static

gg_print_version()

Handler for: PLUGIN_PRINT_VERSION print info about libgadu version.

Zwraca
0
static int gg_remove_notify_handle ( void *  data,
va_list  ap 
)
static

gg_remove_notify_handle()

Handler for: REMOVE_NOTIFY
(Emited by: /del command, when we sucessfully remove smb from userlist.
Notify gg server about it.

Do zrobienia:
We ignore gg_remove_notify() result
Parametry
ap1st param: (char *) session_uid - session uid
ap2nd param: (char *) uid - user uid
dataNULL
Zwraca
1 - If smth is wrong, session_uid or uid isn't valid gg number, or session is without private struct.
else 0
static int gg_scroll_timer ( int  type,
void *  data 
)
static
static int gg_session_deinit ( void *  data,
va_list  ap 
)
static

gg_session_deinit()

Handler for: SESSION_REMOVED
Free memory allocated by gg_private_t if session is gg one.

Parametry
ap1st param: (char *) session - uid of session
dataNULL
Do zrobienia:
Check if we really free all memory allocated by session.
Zwraca
0 if session is gg one, and memory allocated where xfree()'d.
1 if not such session, or it wasn't gg session [most probable], or we already free memory.
int gg_session_handler ( int  type,
int  fd,
watch_type_t  watch,
session_t s 
)
static void gg_session_handler_ack ( session_t s,
struct gg_event *  e 
)
static

gg_session_handler_ack()

Support for messages acknowledgement.
Handler for libgadu: GG_EVENT_ACK events

static void gg_session_handler_disconnect ( session_t s)
static
static void gg_session_handler_failure ( session_t s,
struct gg_event *  e 
)
static
static void gg_session_handler_image ( session_t s,
struct gg_event *  e 
)
static
static void gg_session_handler_msg ( session_t s,
struct gg_event *  e 
)
static
static void gg_session_handler_status ( session_t s,
uin_t  uin,
int  status,
const char *  descr,
uint32_t  ip,
uint16_t  port,
int  protocol 
)
static
static void gg_session_handler_success ( session_t s)
static
static void gg_session_handler_userlist ( session_t s,
struct gg_event *  e 
)
static
static int gg_session_init ( void *  data,
va_list  ap 
)
static

gg_session_init()

Handler for: SESSION_ADDED
Init private session struct gg_private_t if session is gg one.
Read saved userlist by userlist_read()

Parametry
ap1st param: (char *) session - uid of session
dataNULL
Zwraca
0 if session is gg one, and we init memory
1 if we don't found such session, or it wasn't gg session [most probable], or we already init memory.
static int gg_setvar_default ( void *  data,
va_list  ap 
)
static
static int gg_status_show_handle ( void *  data,
va_list  ap 
)
static
static void gg_statusdescr_handler ( session_t s,
const char *  varname 
)
static
static int gg_theme_init ( )
static
static int gg_user_offline_handle ( void *  data,
va_list  ap 
)
static
static int gg_user_online_handle ( void *  data,
va_list  ap 
)
static
static int gg_userlist_info_handle ( void *  data,
va_list  ap 
)
static

gg_userlist_info_handle()

Handler for: USERLIST_INFO
(Emited by: /list command, when we want know more about given user)
printq() all gg-protocol-only-data like: possible client version [read: which version of protocol he use], if he has voip, etc..

Parametry
ap1st param: (userlist_t *) u - item.
ap2nd param: (int) quiet - If quiet for printq()
dataNULL
Zwraca
1 - If no u passed, or it's invalid for gg plugin
else printq() info and return 0
static int gg_userlist_priv_handler ( void *  data,
va_list  ap 
)
static
static int gg_validate_uid ( void *  data,
va_list  ap 
)
static

gg_validate_uid()

handler for PROTOCOL_VALIDATE_UID
checks, if uid is proper for gg plugin.

Nota
Proper for gg plugin means if uid starts with "gg:" and uid len > 3
Do zrobienia:

Blah, irc does xstrncasecmp() here it's only xstrncmp() let's decide... GG: and gg: is proper, or only gg:

Maybe let's check if after gg: we have max 32b number.. because libgadu and gg protocol only support 32bit uids... ;)

Parametry
ap1st param: (char *) uid - of user/session/command/whatever
ap2nd param: (int) valid - place to put 1 if uid is valid for gg plugin.
dataNULL
Zwraca
-1 if it's valid uid for gg plugin
0 if not
static void libgadu_debug_handler ( int  level,
const char *  format,
va_list  ap 
)
static

libgadu_debug_handler()

Handler for libgadu: gg_debug_handler
It's communcation channel between libgadu debug messages, and ekg2.
Here we translate libgadu levels to ekg2 one, and than pass it to ekg_debug_handler()

Parametry
level- libgadu debug level
PLUGIN_DEFINE ( gg  ,
PLUGIN_PROTOCOL  ,
gg_theme_init   
)
uin_t str_to_uin ( const char *  text)

Dokumentacja zmiennych

int gg_config_display_token
int gg_config_skip_default_format
int gg_config_split_messages
list_t gg_currently_checked = NULL
plugins_params_t gg_plugin_vars[]
static
Wartość początkowa:
{
PLUGIN_VAR_ADD("alias", VAR_STR, 0, 0, NULL),
PLUGIN_VAR_ADD("auto_away", VAR_INT, "600", 0, NULL),
PLUGIN_VAR_ADD("auto_away_descr", VAR_STR, 0, 0, NULL),
PLUGIN_VAR_ADD("auto_back", VAR_INT, "0", 0, NULL),
PLUGIN_VAR_ADD("auto_connect", VAR_BOOL, "0", 0, NULL),
PLUGIN_VAR_ADD("auto_find", VAR_INT, "0", 0, NULL),
PLUGIN_VAR_ADD("auto_reconnect", VAR_INT, "10", 0, NULL),
PLUGIN_VAR_ADD("concat_multiline_status",VAR_INT, "3", 0, NULL),
PLUGIN_VAR_ADD("connection_save", VAR_INT, "0", 0, NULL),
PLUGIN_VAR_ADD("display_notify", VAR_INT, "-1", 0, NULL),
PLUGIN_VAR_ADD("email", VAR_STR, 0, 0, NULL),
PLUGIN_VAR_ADD("invisible_check_interval",VAR_INT, 0, 0, NULL),
PLUGIN_VAR_ADD("local_ip", VAR_STR, 0, 0, NULL),
PLUGIN_VAR_ADD("log_formats", VAR_STR, "xml,simple,sqlite", 0, NULL),
PLUGIN_VAR_ADD("password", VAR_STR, NULL, 1, NULL),
PLUGIN_VAR_ADD("port", VAR_INT, "8074", 0, NULL),
PLUGIN_VAR_ADD("protocol", VAR_INT, "0", 0, NULL),
PLUGIN_VAR_ADD("proxy_forwarding", VAR_STR, NULL, 0, NULL),
PLUGIN_VAR_ADD("scroll_long_desc", VAR_INT, "0", 0, NULL),
PLUGIN_VAR_ADD("scroll_mode", VAR_STR, "bounce", 0, NULL),
PLUGIN_VAR_ADD("server", VAR_STR, NULL, 0, NULL),
}
struct protocol_plugin_priv gg_priv
static
Wartość początkowa:
{
.protocols = gg_protocols,
.statuses = gg_statuses
}
const char* gg_protocols[] = { "gg:", NULL }
static
const status_t gg_statuses[]
static
char* last_tokenid