ekg2
ekg/userlist.h
Idź do dokumentacji tego pliku.
00001 /* $Id$ */
00002 
00003 /*
00004  *  (C) Copyright 2001-2003 Wojtek Kaniewski <wojtekka@irc.pl>
00005  *                          Robert J. Woźny <speedy@ziew.org>
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License Version 2 as
00009  *  published by the Free Software Foundation.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifndef __EKG_USERLIST_H
00022 #define __EKG_USERLIST_H
00023 
00024 #include "ekg2-config.h"
00025 #include "win32.h"
00026 
00027 #include <sys/types.h>
00028 
00029 #ifndef NO_POSIX_SYSTEM
00030 #include <sys/socket.h>
00031 #include <netinet/in.h>
00032 #endif
00033 
00034 #include <stdio.h>
00035 #include <stdarg.h>
00036 #include <time.h>
00037 
00038 #include "dynstuff.h"
00039 #include "sessions.h"
00040 #include "plugins.h"
00041 #include "windows.h"
00042 
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046 
00054 typedef struct userlist {
00055         struct userlist *next;
00056 
00057         const char      *uid;           
00058         char            *nickname;      
00059         struct ekg_group *groups;       
00063         status_t        status;         
00064         char            *descr;         
00065         char            *descr1line;    
00066         struct ekg_resource *resources; 
00068         time_t          last_seen;      
00070         char            *foreign;       
00072         void            *priv;          
00074         unsigned int    blink   : 1;    
00075         unsigned int    typing  : 1;    
00077         status_t        last_status;    
00078         char            *last_descr;    
00079         time_t          status_time;    
00080         void            *priv_data;     
00081         private_data_t  *priv_list;     /* New user private data */
00082 } userlist_t;
00083 
00084 typedef enum {
00085         EKG_XSTATE_BLINK        = 1,
00086         EKG_XSTATE_TYPING       = 2
00087 } xstate_t;
00088 
00094 typedef enum {
00095         EKG_USERLIST_PRIVHANDLER_FREE           = 0,    
00096         EKG_USERLIST_PRIVHANDLER_GET,                   
00097         EKG_USERLIST_PRIVHANDLER_READING,               
00103         EKG_USERLIST_PRIVHANDLER_WRITING,               
00105         EKG_USERLIST_PRIVHANDLER_SETVAR_BYNAME  = 0xC0, 
00107 } userlist_privhandler_func_t;
00108 
00114 typedef struct ekg_resource {
00115         struct ekg_resource *next;
00116 
00117         char            *name;          
00118         status_t        status;         
00119         char            *descr;         
00120         int             prio;           
00121         void            *priv_data;     
00122 } ekg_resource_t;
00123 
00128 struct ekg_group {
00129         struct ekg_group *next;
00130 
00131         char *name;             
00132 };
00133 
00134 typedef enum {
00135         IGNORE_STATUS           = 0x01,
00136         IGNORE_STATUS_DESCR     = 0x02,
00137         IGNORE_MSG              = 0x04,
00138         IGNORE_DCC              = 0x08,
00139         IGNORE_EVENTS           = 0x10,
00140         IGNORE_NOTIFY           = 0x20,
00141         IGNORE_XOSD             = 0x40,
00142         IGNORE_LOG              = 0x80,
00143         
00144         IGNORE_ALL              = 0xFF
00145 } ignore_t;
00146 
00147 struct ignore_label {
00148         ignore_t        level;
00149         char            *name;
00150 };
00151 
00152 #define IGNORE_LABELS_MAX 9
00153 extern struct ignore_label ignore_labels[IGNORE_LABELS_MAX];
00154 
00155 #ifndef EKG2_WIN32_NOFUNCTION
00156 
00157 int userlist_read(session_t* session);
00158 int userlist_write(session_t *session);
00159 void userlist_write_crash();
00160 void userlist_clear_status(session_t *session, const char *uid);
00161 userlist_t *userlist_add(session_t *session, const char *uid, const char *nickname);
00162 userlist_t *userlist_add_u(userlist_t **userlist, const char *uid, const char *nickname);
00163 void userlist_add_entry(session_t *session,const char *line);
00164 int userlist_remove(session_t *session, userlist_t *u);
00165 int userlist_remove_u(userlist_t **userlist, userlist_t *u);
00166 int userlist_replace(session_t *session, userlist_t *u);
00167 userlist_t *userlist_find(session_t *session, const char *uid);
00168 userlist_t *userlist_find_u(userlist_t **userlist, const char *uid);
00169 #define userlist_find_n(a, b) userlist_find(session_find(a), b)
00170 void userlist_free(session_t *session);
00171 void userlists_destroy(userlist_t **userlist);
00172 
00173 void *userlist_private_get(plugin_t *plugin, userlist_t *u);
00174 
00175 /* u->resource */
00176 ekg_resource_t *userlist_resource_add(userlist_t *u, const char *name, int prio);
00177 ekg_resource_t *userlist_resource_find(userlist_t *u, const char *name);
00178 void userlist_resource_remove(userlist_t *u, ekg_resource_t *r);
00179 
00180 int ignored_add(session_t *session, const char *uid, ignore_t level);
00181 int ignored_remove(session_t *session, const char *uid);
00182 int ignored_check(session_t *session, const char *uid);
00183 int ignore_flags(const char *str);
00184 const char *ignore_format(int level);
00185 
00186 int ekg_group_add(userlist_t *u, const char *group);
00187 int ekg_group_remove(userlist_t *u, const char *group);
00188 int ekg_group_member(userlist_t *u, const char *group);
00189 char *group_to_string(struct ekg_group *l, int meta, int sep);
00190 struct ekg_group *group_init(const char *groups);
00191 
00192 int valid_nick(const char *nick);
00193 int valid_plugin_uid(plugin_t *plugin, const char *uid);
00194 const char *format_user(session_t *session, const char *uid);
00195 const char *get_uid(session_t *session, const char *text);
00196 const char *get_uid_any(session_t *session, const char *text);
00197 const char *get_nickname(session_t *session, const char *text);
00198 char *get_user_name(userlist_t *u);
00199 
00200 #endif
00201 
00202 #define user_private_item_get_safe(user, name, result) \
00203         private_item_get_safe(&(user)->priv_list, name, result)
00204 #define user_private_item_get(user, name) \
00205         private_item_get(&(user)->priv_list, name)
00206 #define user_private_item_get_int_safe(user, name, result) \
00207         private_item_get_int_safe(&(user)->priv_list), name, int *result)
00208 #define user_private_item_get_int(user, name) \
00209         private_item_get_int(&(user)->priv_list, name)
00210 #define user_private_item_set(user, name, value) \
00211         private_item_set(&(user)->priv_list, name, value)
00212 #define user_private_item_set_int(user, name, value) \
00213         private_item_set_int(&(user)->priv_list, name, value)
00214 
00215 #define user_private_items_destroy(user) \
00216         private_items_destroy(&(user)->priv_list);
00217 
00218 #ifdef __cplusplus
00219 }
00220 #endif
00221 
00222 #endif /* __EKG_USERLIST_H */
00223 
00224 /*
00225  * Local Variables:
00226  * mode: c
00227  * c-file-style: "k&r"
00228  * c-basic-offset: 8
00229  * indent-tabs-mode: t
00230  * End:
00231  */
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje