ekg2
ekg/protocol.h
Idź do dokumentacji tego pliku.
00001 /* $Id$ */
00002 
00003 /*
00004  *  (C) Copyright 2003 Wojtek Kaniewski <wojtekka@irc.pl>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License Version 2 as
00008  *  published by the Free Software Foundation.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 #ifndef __EKG_PROTOCOL_H
00021 #define __EKG_PROTOCOL_H
00022 
00023 #include "ekg2-config.h"
00024 
00025 #include "dynstuff.h"
00026 #include "sessions.h"
00027 #include <stdarg.h>
00028 #include <stdint.h>
00029 #include <time.h>
00030 #include <stdlib.h> /* size_t */
00031 #include <sys/types.h> /* off_t */
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036 
00037 #define EKG_FORMAT_RGB_MASK 0x00ffffffL /* 0x00BBGGRR */
00038 #define EKG_FORMAT_R_MASK 0x00ff0000L
00039 #define EKG_FORMAT_G_MASK 0x0000ff00L
00040 #define EKG_FORMAT_B_MASK 0x000000ffL
00041 #define EKG_FORMAT_COLOR 0x01000000L
00042 #define EKG_FORMAT_BOLD 0x02000000L
00043 #define EKG_FORMAT_ITALIC 0x04000000L
00044 #define EKG_FORMAT_UNDERLINE 0x08000000L
00045 #define EKG_FORMAT_REVERSE 0x10000000L
00046 
00047 #define EKG_NO_THEMEBIT 256
00048 
00049 enum msgack_t {
00050         EKG_ACK_DELIVERED       = 0,    /* message delivered successfully */
00051         EKG_ACK_QUEUED,                 /* message queued for delivery */
00052         EKG_ACK_DROPPED,                /* message rejected 'permamently' */
00053         EKG_ACK_TEMPFAIL,               /* temporary delivery failure */
00054         EKG_ACK_UNKNOWN,                /* delivery status unknown */
00055         
00056         EKG_ACK_MAX                     /* we don't want to read after array */
00057 };
00058 
00059 typedef enum {
00060         EKG_DISCONNECT_USER     = 0,    /* user-engaged disconnect */
00061         EKG_DISCONNECT_NETWORK,         /* network problems */
00062         EKG_DISCONNECT_FORCED,          /* server forced to disconnect */
00063         EKG_DISCONNECT_FAILURE,         /* connecting failed */
00064         EKG_DISCONNECT_STOPPED          /* connecting canceled */
00065 } disconnect_t;
00066 
00067 #define EKG_NO_BEEP 0
00068 #define EKG_TRY_BEEP 1
00069 
00070 typedef enum {
00071         /* recv */
00072         EKG_MSGCLASS_MESSAGE    = 0,    /* single message */
00073         EKG_MSGCLASS_CHAT,              /* chat message */
00074         EKG_MSGCLASS_SYSTEM,            /* system message */
00075         EKG_MSGCLASS_LOG,               /* old logged message (used by logsqlite 'last_print_on_open') */
00076 
00077         EKG_MSGCLASS_NOT2US     = 16,   /* message is not to us */
00078 
00079         /* sent */
00080         EKG_MSGCLASS_SENT       = 32,   /* single sent message */
00081         EKG_MSGCLASS_SENT_CHAT,         /* chat sent message */
00082         EKG_MSGCLASS_SENT_LOG,          /* old logged message (used by logsqlite 'last_print_on_open') */
00083         /* priv */
00084         EKG_MSGCLASS_PRIV_STATUS= 64    /* used by logs */
00085 } msgclass_t;
00086 
00087 #ifndef EKG2_WIN32_NOFUNCTION
00088 void protocol_init();
00089 
00090 char *message_print(const char *session, const char *sender, const char **rcpts, const char *text, const uint32_t *format,
00091                 time_t sent, int mclass, const char *seq, int dobeep, int secure);
00092 
00093 int protocol_connected_emit(const session_t *s);
00094 int protocol_disconnected_emit(const session_t *s, const char *reason, int type);
00095 int protocol_message_ack_emit(const session_t *s, const char *rcpt, const char *seq, int status);
00096 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);
00097 int protocol_status_emit(const session_t *s, const char *uid, int status, char *descr, time_t when);
00098 int protocol_xstate_emit(const session_t *s, const char *uid, int state, int offstate);
00099 
00100 char *protocol_uid(const char *proto, const char *target);      /* XXX ? */
00101 #endif
00102 
00103 typedef enum {
00104         DCC_NONE = 0,
00105         DCC_SEND,
00106         DCC_GET,
00107         DCC_VOICE
00108 } dcc_type_t;
00109 
00110 struct dcc_s;
00111 
00112 typedef void (*dcc_close_handler_t)(struct dcc_s *);
00113 
00114 typedef struct dcc_s {
00115         struct dcc_s    *next;
00116 
00117         session_t       *session;               /* ktora sesja? */
00118         char            *uid;                   /* z kim połączenie */
00119         dcc_type_t      type;                   /* rodzaj połączenia */
00120         int             id;                     /* numer połączenia */
00121         void            *priv;                  /* dane prywatne pluginu */
00122         dcc_close_handler_t close_handler;      /* obsługa /dcc close */
00123         unsigned int    active          : 1;    /* czy połączono? */
00124         time_t          started;                /* kiedy utworzono? */
00125         
00126         char            *filename;              /* nazwa pliku */
00127         size_t          size;                   /* rozmiar pliku */
00128         off_t           offset;                 /* ile już wykonano */
00129 } dcc_t;
00130 
00131 #ifndef EKG2_WIN32_NOFUNCTION
00132 dcc_t *dcc_add(session_t *session, const char *uid, dcc_type_t type, void *priv);
00133 int dcc_close(dcc_t *d);
00134 
00135 int dcc_private_set(dcc_t *, void *);
00136 void *dcc_private_get(dcc_t *);
00137 int dcc_close_handler_set(dcc_t *, dcc_close_handler_t);
00138 dcc_close_handler_t dcc_close_handler_get(dcc_t *);
00139 const char *dcc_uid_get(dcc_t *);
00140 int dcc_id_get(dcc_t *);
00141 time_t dcc_started_get(dcc_t *);
00142 int dcc_active_set(dcc_t *, int);
00143 int dcc_active_get(dcc_t *);
00144 int dcc_offset_set(dcc_t *, int);
00145 int dcc_offset_get(dcc_t *);
00146 int dcc_size_set(dcc_t *, int);
00147 int dcc_size_get(dcc_t *);
00148 int dcc_filename_set(dcc_t *, const char *);
00149 const char *dcc_filename_get(dcc_t *);
00150 dcc_type_t dcc_type_get(dcc_t *);
00151 
00152 extern dcc_t *dccs;
00153 
00154 #endif
00155 
00156 #ifdef __cplusplus
00157 }
00158 #endif
00159 
00160 #endif /* __EKG_PROTOCOL_H */
00161 
00162 /*
00163  * Local Variables:
00164  * mode: c
00165  * c-file-style: "k&r"
00166  * c-basic-offset: 8
00167  * indent-tabs-mode: t
00168  * End:
00169  */
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje