[ekg2-commit] r3830 - trunk/ekg: trunk/ekg/commands.c trunk/ekg/commands.h trunk/ekg/debug.h trunk/ekg/dynstuff.c trunk/ekg/dynstuff.h trunk/ekg/log.h trunk/ekg/metacontacts.h trunk/ekg/msgqueue.h trunk/ekg/plugins.h trunk/ekg/protocol.c trunk/ekg/protocol.h trunk/ekg/sessions.c trunk/ekg/sessions.h trunk/ekg/strings.c trunk/ekg/strings.h trunk/ekg/stuff.c trunk/ekg/stuff.h trunk/ekg/themes.h trunk/ekg/userlist.c trunk/ekg/userlist.h trunk/ekg/windows.c trunk/ekg/windows.h
SVN commit
svn w toxygen.net
Nie, 2 Mar 2008, 20:27:48 CET
Author: peres
Date: 2008-03-02 20:27:48 +0100 (Sun, 02 Mar 2008)
New Revision: 3830
Modified:
trunk/ekg/commands.c
trunk/ekg/commands.h
trunk/ekg/debug.h
trunk/ekg/dynstuff.c
trunk/ekg/dynstuff.h
trunk/ekg/log.h
trunk/ekg/metacontacts.h
trunk/ekg/msgqueue.h
trunk/ekg/plugins.h
trunk/ekg/protocol.c
trunk/ekg/protocol.h
trunk/ekg/sessions.c
trunk/ekg/sessions.h
trunk/ekg/strings.c
trunk/ekg/strings.h
trunk/ekg/stuff.c
trunk/ekg/stuff.h
trunk/ekg/themes.h
trunk/ekg/userlist.c
trunk/ekg/userlist.h
trunk/ekg/windows.c
trunk/ekg/windows.h
Log:
The great and powerful ABI-breaker; changing many, many ints
to 'narrower' in use variables:
- boolean things into 1-bit fields,
- magical bools to 2 or more (and dev w/ first look sees
that field has some magic),
- timedate things into time_t,
- sizes, counts into size_t,
- offsets, indexes into off_t (not all, exactly),
- some enum-defined values into correct enums.
Also broke magical 'xstate' field into 2 one-bit fields.
XXX: think about magical XSTATE query.
What do you think about switching boolean args to functions
into bool? Basic motivation: to make dev be sure, whether
that arg is 0/1, or it is another thing of magical whatever.
Modified: trunk/ekg/commands.c
===================================================================
--- trunk/ekg/commands.c 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/commands.c 2008-03-02 19:27:48 UTC (rev 3830)
@@ -3825,7 +3825,7 @@
&& xstrlen(format_find("last_list_timestamp"))>0)
xstrcpy(buf, "TOOLONG");
- if (show_sent && ll->type == 0 && !(ll->sent_time - config_time_deviation <= ll->time && ll->time <= ll->sent_time + config_time_deviation)) {
+ if (show_sent && !ll->type && !(ll->sent_time - config_time_deviation <= ll->time && ll->time <= ll->sent_time + config_time_deviation)) {
st = localtime(&ll->sent_time);
form = format_find((tm->tm_yday == now->tm_yday) ? "last_list_timestamp_today" : "last_list_timestamp");
if (!strftime(buf2, sizeof(buf2), form, st) && xstrlen(form)>0)
@@ -3834,11 +3834,7 @@
} else
time_str = xstrdup(buf);
- if (config_last & 4 && ll->type == 1)
- printq("last_list_out", time_str, format_user(session, ll->uid), ll->message);
- else
- printq("last_list_in", time_str, format_user(session, ll->uid), ll->message);
-
+ printq(config_last & 4 && ll->type ? "last_list_out" : "last_list_in", time_str, format_user(session, ll->uid), ll->message);
xfree(time_str);
}
}
Modified: trunk/ekg/commands.h
===================================================================
--- trunk/ekg/commands.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/commands.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -31,45 +31,41 @@
#define COMMAND(x) int x(const char *name, const char **params, session_t *session, const char *target, int quiet)
+typedef enum {
/* INFORMATIONAL FLAGS */
- /* command is binded by alias managment */
-#define COMMAND_ISALIAS 0x01
- /* command is binded by script mangament */
-#define COMMAND_ISSCRIPT 0x02
- /* [XXX] command uses resource, and resource should be passed */
-#define COMMAND_WITH_RESOURCE 0x04
+ COMMAND_ISALIAS = 0x01, /* command is binded by alias management */
+ COMMAND_ISSCRIPT = 0x02, /* command is binded by script management */
+ COMMAND_WITH_RESOURCE = 0x04, /* [XXX] command uses resource, and resource should be passed */
/* .... */
/* CONDITIONAL FLAGS */
- /* '!' in params means that arg must exist in par[..] (?) */
-#define COMMAND_ENABLEREQPARAMS 0x10
- /* when par[0] != NULL, than target = par[0] and than par list moves up (par++ ; par[0] == par[1] and so on */
-#define COMMAND_PARAMASTARGET 0x20
- /* session must be connected to execute that command */
-#define SESSION_MUSTBECONNECTED 0x40
- /* command must come from the same plugin as session (?) */
-#define SESSION_MUSTBELONG 0x80
- /* if session == NULL, we try session_current, if still NULL. we return -1... mh, i really don't know if this
- * flag is obsolete... but we do simillar thing in many places in code, so implemented. */
-#define SESSION_MUSTHAS 0x100
- /* session must exist and has private struct */
-#define SESSION_MUSTHASPRIVATE 0x200
- /* before executing handler, check if target (or params[0] if COMMAND_PARAMASTARGET set) is valid uid for current session, or we've got smb with this nickname
- * on userlist... (read: we check if get_uid(session, target) return smth, if not we print message) */
-#define COMMAND_TARGET_VALID_UID 0x400
+ COMMAND_ENABLEREQPARAMS = 0x10, /* '!' in params means that arg must exist in par[..] (?) */
+ COMMAND_PARAMASTARGET = 0x20, /* when par[0] != NULL, than target = par[0] and than par list moves up
+ (par++ ; par[0] == par[1] and so on */
+ SESSION_MUSTBECONNECTED = 0x40, /* session must be connected to execute that command */
+ SESSION_MUSTBELONG = 0x80, /* command must come from the same plugin as session (?) */
+ SESSION_MUSTHAS = 0x100, /* if session == NULL, we try session_current, if still NULL. we return -1...
+ mh, i really don't know if this flag is obsolete... but we do simillar thing
+ in many places in code, so implemented. */
+ SESSION_MUSTHASPRIVATE = 0x200, /* session must exist and has private struct */
+ COMMAND_TARGET_VALID_UID = 0x400 /* before executing handler, check if target (or params[0] if COMMAND_PARAMASTARGET
+ set) is valid uid for current session, or we've got smb with this nickname
+ on userlist... (read: we check if get_uid(session, target) return smth,
+ if not we print message) */
+} command_flags_t;
typedef COMMAND(command_func_t);
typedef struct {
- /* public: */
- const char *name;
- plugin_t *plugin;
+/* public: */
+ const char *name;
+ plugin_t *plugin;
- /* private: */
- char**params;
- command_func_t *function;
- int flags;
- char **possibilities;
+/* private: */
+ char **params;
+ command_func_t *function;
+ command_flags_t flags;
+ char **possibilities;
} command_t;
#ifndef EKG2_WIN32_NOFUNCTION
Modified: trunk/ekg/debug.h
===================================================================
--- trunk/ekg/debug.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/debug.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -3,15 +3,17 @@
#ifndef __EKG_DEBUG_H
#define __EKG_DEBUG_H
-#define DEBUG_IO 1
-#define DEBUG_IORECV 2
-#define DEBUG_FUNCTION 3
-#define DEBUG_ERROR 4
-#define DEBUG_GGMISC 5 /* cause of a lot GG_DEBUG_MISC in libgadu we've got special formats for them... */
-#define DEBUG_WHITE 6
+typedef enum {
+ DEBUG_IO = 1,
+ DEBUG_IORECV,
+ DEBUG_FUNCTION,
+ DEBUG_ERROR,
+ DEBUG_GGMISC, /* cause of a lot GG_DEBUG_MISC in libgadu we've got special formats for them... */
+ DEBUG_WHITE
+} debug_level_t;
void debug(const char *format, ...);
-void debug_ext(int level, const char *format, ...);
+void debug_ext(debug_level_t level, const char *format, ...);
#define debug_io(args...) debug_ext(DEBUG_IO, args)
#define debug_iorecv(args...) debug_ext(DEBUG_IORECV, args)
Modified: trunk/ekg/dynstuff.c
===================================================================
--- trunk/ekg/dynstuff.c 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/dynstuff.c 2008-03-02 19:27:48 UTC (rev 3830)
@@ -40,7 +40,7 @@
*
* zwraca wskaźnik zaalokowanego elementu lub NULL w przpadku błędu.
*/
-void *list_add_sorted(list_t *list, void *data, int alloc_size, int (*comparision)(void *, void *))
+void *list_add_sorted(list_t *list, void *data, size_t alloc_size, int (*comparision)(void *, void *))
{
list_t new, tmp;
@@ -100,7 +100,7 @@
* @sa list_remove()
*/
-void *list_add_beginning(list_t *list, void *data, int alloc_size) {
+void *list_add_beginning(list_t *list, void *data, size_t alloc_size) {
list_t new;
@@ -134,7 +134,7 @@
* @sa list_add_sorted()
*/
-void *list_add(list_t *list, void *data, int alloc_size)
+void *list_add(list_t *list, void *data, size_t alloc_size)
{
return list_add_sorted(list, data, alloc_size, NULL);
}
@@ -266,7 +266,7 @@
* @return n'th item (list->data) if found, or NULL with errno set to ENOENT
*/
-void *list_get_nth(list_t list, int id) {
+void *list_get_nth(list_t list, off_t id) {
while (list) {
if ((--id) == 0) {
/* errno = !ENOENT; */
@@ -364,7 +364,7 @@
* - s - ciąg znaków,
* - count - wymagana ilość znaków (bez końcowego '\0').
*/
-static void string_realloc(string_t s, int count)
+static void string_realloc(string_t s, size_t count)
{
char *tmp;
@@ -423,7 +423,7 @@
* -1 and errno set to EFAULT if input params were wrong (s == NULL || str == NULL)
*/
-int string_append_n(string_t s, const char *str, int count)
+int string_append_n(string_t s, const char *str, size_t count)
{
if (!s || !str) {
errno = EFAULT;
@@ -493,7 +493,7 @@
* @todo XXX Protect from negative count (and less than -1) ?
*/
-int string_append_raw(string_t s, const char *str, int count) {
+int string_append_raw(string_t s, const char *str, size_t count) {
if (!s || !str) {
errno = EFAULT;
return -1;
@@ -535,7 +535,7 @@
* - str - tekst do dopisania,
* - count - ilość znaków do dopisania (-1 znaczy, że wszystkie).
*/
-void string_insert_n(string_t s, int index, const char *str, int count)
+void string_insert_n(string_t s, off_t index, const char *str, size_t count)
{
if (!s || !str)
return;
@@ -567,7 +567,7 @@
* @sa string_insert_n()
*/
-void string_insert(string_t s, int index, const char *str)
+void string_insert(string_t s, off_t index, const char *str)
{
string_insert_n(s, index, str, -1);
}
@@ -605,7 +605,7 @@
*
*/
-void string_remove(string_t s, int count) {
+void string_remove(string_t s, size_t count) {
if (!s || count <= 0)
return;
@@ -717,7 +717,7 @@
* zaalokowaną tablicę z zaalokowanymi ciągami znaków, którą należy
* zwolnić funkcją array_free()
*/
-char **array_make(const char *string, const char *sep, int max, int trim, int quotes)
+char **array_make(const char *string, const char *sep, size_t max, int trim, int quotes)
{
const char *p, *q;
char **result = NULL;
@@ -894,7 +894,7 @@
return string_free(s, 0);
}
-char *array_join_count(char **array, const char *sep, int count) {
+char *array_join_count(char **array, const char *sep, size_t count) {
string_t s = string_init(NULL);
if (array) {
@@ -986,7 +986,7 @@
xfree(array);
}
-void array_free_count(char **array, int count) {
+void array_free_count(char **array, size_t count) {
char **tmp;
if (!array)
Modified: trunk/ekg/dynstuff.h
===================================================================
--- trunk/ekg/dynstuff.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/dynstuff.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -21,6 +21,9 @@
#ifndef __EKG_DYNSTUFF_H
#define __EKG_DYNSTUFF_H
+#include <stdlib.h> /* size_t */
+#include <sys/types.h> /* off_t */
+
/*
* typedef list_t
*
@@ -61,12 +64,12 @@
#define LIST_DESTROY(list, func) list_destroy2(list, (void *) func)
-void *list_add(list_t *list, void *data, int alloc_size);
-void *list_add_beginning(list_t *list, void *data, int alloc_size);
-void *list_add_sorted(list_t *list, void *data, int alloc_size, int (*comparision)(void *, void *));
+void *list_add(list_t *list, void *data, size_t alloc_size);
+void *list_add_beginning(list_t *list, void *data, size_t alloc_size);
+void *list_add_sorted(list_t *list, void *data, size_t alloc_size, int (*comparision)(void *, void *));
int list_count(list_t list);
-void *list_get_nth(list_t list, int id);
+void *list_get_nth(list_t list, off_t id);
void list_resort(list_t *list, int (*comparision)(void *, void *));
int list_remove(list_t *list, void *data, int free_data);
@@ -98,7 +101,7 @@
struct string {
char *str;
- int len, size;
+ size_t len, size;
};
typedef struct string *string_t;
@@ -107,20 +110,20 @@
string_t string_init(const char *str);
int string_append(string_t s, const char *str);
-int string_append_n(string_t s, const char *str, int count);
+int string_append_n(string_t s, const char *str, size_t count);
int string_append_c(string_t s, char ch);
-int string_append_raw(string_t s, const char *str, int count);
+int string_append_raw(string_t s, const char *str, size_t count);
int string_append_format(string_t s, const char *format, ...);
-void string_insert(string_t s, int index, const char *str);
-void string_insert_n(string_t s, int index, const char *str, int count);
-void string_remove(string_t s, int count);
+void string_insert(string_t s, off_t index, const char *str);
+void string_insert_n(string_t s, off_t index, const char *str, size_t count);
+void string_remove(string_t s, size_t count);
void string_clear(string_t s);
char *string_free(string_t s, int free_string);
/* tablice stringow */
-char **array_make(const char *string, const char *sep, int max, int trim, int quotes);
+char **array_make(const char *string, const char *sep, size_t max, int trim, int quotes);
char *array_join(char **array, const char *sep);
-char *array_join_count(char **array, const char *sep, int count);
+char *array_join_count(char **array, const char *sep, size_t count);
void array_add(char ***array, char *string);
void array_add_check(char ***array, char *string, int casesensitive);
@@ -128,7 +131,7 @@
int array_contains(char **array, const char *string, int casesensitive);
int array_item_contains(char **array, const char *string, int casesensitive);
void array_free(char **array);
-void array_free_count(char **array, int count);
+void array_free_count(char **array, size_t count);
/* rozszerzenia libców */
Modified: trunk/ekg/log.h
===================================================================
--- trunk/ekg/log.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/log.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -30,11 +30,11 @@
#include "dynstuff.h"
struct last {
- int type; /* 0 - przychodząca, 1 - wychodząca */
- char *uid; /* od kogo, lub do kogo przy wysyłanych */
- time_t time; /* czas */
- time_t sent_time; /* czas wysłania wiadomości przychodzącej */
- char *message; /* wiadomość */
+ unsigned int type : 1; /* 0 - przychodząca, 1 - wychodząca */
+ char *uid; /* od kogo, lub do kogo przy wysyłanych */
+ time_t time; /* czas */
+ time_t sent_time; /* czas wysłania wiadomości przychodzącej */
+ char *message; /* wiadomość */
};
#ifndef EKG2_WIN32_NOFUNCTION
Modified: trunk/ekg/metacontacts.h
===================================================================
--- trunk/ekg/metacontacts.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/metacontacts.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -22,9 +22,9 @@
#include "dynstuff.h"
typedef struct {
- char *name; /* uid or name */
- unsigned int prio; /* prio */
- char *s_uid; /* session uid */
+ char *name; /* uid or name */
+ unsigned int prio; /* prio */
+ char *s_uid; /* session uid */
} metacontact_item_t;
typedef struct {
Modified: trunk/ekg/msgqueue.h
===================================================================
--- trunk/ekg/msgqueue.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/msgqueue.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -27,12 +27,12 @@
#include "dynstuff.h"
typedef struct {
- char *session; /* do której sesji należy */
- char *rcpts; /* uidy odbiorców */
- char *message; /* treść */
- char *seq; /* numer sekwencyjny */
- time_t time; /* czas wysłania */
- int mark;
+ char *session; /* do której sesji należy */
+ char *rcpts; /* uidy odbiorców */
+ char *message; /* treść */
+ char *seq; /* numer sekwencyjny */
+ time_t time; /* czas wysłania */
+ unsigned int mark : 1; /* if added during cleanup */
} msg_queue_t;
extern list_t msg_queue;
Modified: trunk/ekg/plugins.h
===================================================================
--- trunk/ekg/plugins.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/plugins.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -26,7 +26,7 @@
#include "dynstuff.h"
#include "sessions.h"
-#define EKG_ABI_VER 3826
+#define EKG_ABI_VER 3828
#define EXPORT __attribute__ ((visibility("default")))
Modified: trunk/ekg/protocol.c
===================================================================
--- trunk/ekg/protocol.c 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/protocol.c 2008-03-02 19:27:48 UTC (rev 3830)
@@ -709,10 +709,10 @@
/* display blinking */
if (config_display_blinking && userlist && (class < EKG_MSGCLASS_SENT) && (!rcpts || !rcpts[0])) {
- int oldstate = userlist->xstate;
+ int oldstate = userlist->blink;
if (config_make_window && xstrcmp(get_uid(session_class, window_current->target), get_uid(session_class, uid)))
- userlist->xstate |= EKG_XSTATE_BLINK;
+ userlist->blink = 1;
else if (!config_make_window) {
window_t *w;
@@ -722,13 +722,11 @@
*/
w = window_find_s(session_class, uid);
- if (!w && window_current->id != 1)
- userlist->xstate |= EKG_XSTATE_BLINK;
- if (w && window_current->id != w->id)
- userlist->xstate |= EKG_XSTATE_BLINK;
+ if (w ? (window_current->id != w->id) : (window_current->id != 1))
+ userlist->blink = 1;
}
- if (oldstate != userlist->xstate)
+ if (oldstate != userlist->blink)
query_emit_id(NULL, USERLIST_CHANGED, &session, &uid);
}
@@ -871,17 +869,24 @@
if ((w = window_find_s(s, uid))) {
if (offstate & EKG_XSTATE_TYPING)
- w->in_typing = 0;
+ w->in_typing = 0;
else if (state & EKG_XSTATE_TYPING)
- w->in_typing = 1;
+ w->in_typing = 1;
+ else
+ goto xs_userlist;
+
query_emit_id(NULL, UI_WINDOW_ACT_CHANGED);
}
+xs_userlist:
if ((u = userlist_find(s, uid)) || (config_auto_user_add && (u = userlist_add(s, uid, uid)))) {
if (offstate & EKG_XSTATE_TYPING)
- u->xstate &= ~EKG_XSTATE_TYPING;
+ u->typing = 0;
else if (state & EKG_XSTATE_TYPING)
- u->xstate |= EKG_XSTATE_TYPING;
+ u->typing = 1;
+ else
+ return 0;
+
query_emit_id(NULL, USERLIST_CHANGED, __session, __uid);
}
Modified: trunk/ekg/protocol.h
===================================================================
--- trunk/ekg/protocol.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/protocol.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -27,6 +27,8 @@
#include <stdarg.h>
#include <stdint.h>
#include <time.h>
+#include <stdlib.h> /* size_t */
+#include <sys/types.h> /* off_t */
#define EKG_FORMAT_RGB_MASK 0x00ffffffL /* 0x00BBGGRR */
#define EKG_FORMAT_R_MASK 0x00ff0000L
@@ -78,7 +80,8 @@
#ifndef EKG2_WIN32_NOFUNCTION
void protocol_init();
-char *message_print(const char *session, const char *sender, const char **rcpts, const char *text, const uint32_t *format, time_t sent, int class, const char *seq, int dobeep, int secure);
+char *message_print(const char *session, const char *sender, const char **rcpts, const char *text, const uint32_t *format,
+ time_t sent, int class, const char *seq, int dobeep, int secure);
#endif
typedef enum {
@@ -93,18 +96,18 @@
typedef void (*dcc_close_handler_t)(struct dcc_s *);
typedef struct dcc_s {
- session_t *session; /* ktora sesja? */
- char *uid; /* z kim połączenie */
- dcc_type_t type; /* rodzaj połączenia */
- int id; /* numer połączenia */
- void *priv; /* dane prywatne pluginu */
+ session_t *session; /* ktora sesja? */
+ char *uid; /* z kim połączenie */
+ dcc_type_t type; /* rodzaj połączenia */
+ int id; /* numer połączenia */
+ void *priv; /* dane prywatne pluginu */
dcc_close_handler_t close_handler; /* obsługa /dcc close */
- int active; /* czy połączono? */
- time_t started; /* kiedy utworzono? */
+ unsigned int active : 1; /* czy połączono? */
+ time_t started; /* kiedy utworzono? */
- char *filename; /* nazwa pliku */
- int size; /* rozmiar pliku */
- int offset; /* ile już wykonano */
+ char *filename; /* nazwa pliku */
+ size_t size; /* rozmiar pliku */
+ off_t offset; /* ile już wykonano */
} dcc_t;
#ifndef EKG2_WIN32_NOFUNCTION
Modified: trunk/ekg/sessions.c
===================================================================
--- trunk/ekg/sessions.c 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/sessions.c 2008-03-02 19:27:48 UTC (rev 3830)
@@ -324,7 +324,7 @@
xfree(s->uid);
xfree(s->descr);
xfree(s->password);
- xfree(s->lastdescr);
+ xfree(s->last_descr);
/* free memory like sessions_free() do */
userlist_free(s);
@@ -335,7 +335,7 @@
PROPERTY_INT_GET(session, status, int)
-int session_status_set(session_t *s, int status)
+int session_status_set(session_t *s, status_t status)
{
int is_xa;
@@ -359,9 +359,9 @@
/* save current status/ descr && turn autoaway on */
if (!s->autoaway) { /* don't overwrite laststatus, if already on aa */
- xfree(s->lastdescr); /* just in case */
- s->laststatus = s->status;
- s->lastdescr = xstrdup(s->descr);
+ xfree(s->last_descr); /* just in case */
+ s->last_status = s->status;
+ s->last_descr = xstrdup(s->descr);
s->autoaway = 1;
}
/* new status */
@@ -372,7 +372,7 @@
xfree(s->descr);
if (xstrchr(tmp, '%')) { /* the New&Better-AutoAway-Markup^TM */
- const char *current_descr = (s->autoaway ? s->lastdescr : s->descr);
+ const char *current_descr = (s->autoaway ? s->last_descr : s->descr);
char *c, *xbuf, *xc;
int xm = 0;
@@ -430,15 +430,15 @@
/* if it's autoback */
if (status == EKG_STATUS_AUTOBACK) {
/* set status */
- s->status = s->laststatus ? s->laststatus : EKG_STATUS_AVAIL;
+ s->status = s->last_status ? s->last_status : EKG_STATUS_AVAIL;
/* set descr */
- if (s->autoaway || s->lastdescr) {
+ if (s->autoaway || s->last_descr) {
xfree(s->descr);
- s->descr = s->lastdescr;
+ s->descr = s->last_descr;
}
- s->laststatus = 0;
- s->lastdescr = NULL;
+ s->last_status = 0;
+ s->last_descr = NULL;
s->autoaway = 0;
return 0;
}
@@ -447,8 +447,8 @@
/* if it wasn't neither _autoback nor _autoaway|_autoxa, it should be one of valid status types... */
if (s->autoaway) { /* if we're @ away, set previous, set lastdescr status & free data */
- s->laststatus = 0; /* EKG_STATUS_NULL */
- xfree(s->descr); s->descr = s->lastdescr; s->lastdescr = NULL;
+ s->last_status = 0; /* EKG_STATUS_NULL */
+ xfree(s->descr); s->descr = s->last_descr; s->last_descr = NULL;
s->autoaway = 0;
}
return 0;
@@ -509,8 +509,8 @@
return -1;
if (s->autoaway) {
- xfree(s->lastdescr);
- s->lastdescr = xstrdup(descr);
+ xfree(s->last_descr);
+ s->last_descr = xstrdup(descr);
} else {
xfree(s->descr);
s->descr = xstrdup(descr);
@@ -848,9 +848,9 @@
if (s->alias)
fprintf(f, "alias=%s\n", s->alias);
if (s->status && config_keep_reason != 2)
- fprintf(f, "status=%s\n", ekg_status_string(s->autoaway ? s->laststatus : s->status, 0));
+ fprintf(f, "status=%s\n", ekg_status_string(s->autoaway ? s->last_status : s->status, 0));
if (s->descr && config_keep_reason) {
- char *myvar = (s->autoaway ? s->lastdescr : s->descr);
+ char *myvar = (s->autoaway ? s->last_descr : s->descr);
xstrtr(myvar, '\n', '\002');
fprintf(f, "descr=%s\n", myvar);
xstrtr(myvar, '\002', '\n');
@@ -1024,9 +1024,9 @@
if (s->alias)
debug("alias=%s\n", s->alias);
if (s->status)
- debug("status=%s\n", ekg_status_string(s->autoaway ? s->laststatus : s->status, 0));
+ debug("status=%s\n", ekg_status_string(s->autoaway ? s->last_status : s->status, 0));
if (s->descr)
- debug("descr=%s\n", (s->autoaway ? s->lastdescr : s->descr));
+ debug("descr=%s\n", (s->autoaway ? s->last_descr : s->descr));
/* _global_ vars: */
if (p) {
@@ -1503,7 +1503,7 @@
xfree(s->uid);
xfree(s->descr);
xfree(s->password);
- xfree(s->lastdescr);
+ xfree(s->last_descr);
userlist_free(s);
}
Modified: trunk/ekg/sessions.h
===================================================================
--- trunk/ekg/sessions.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/sessions.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -24,6 +24,77 @@
#include <time.h>
#include "dynstuff.h"
+/**
+ * status_t - user's current status, as prioritized enum
+ */
+
+typedef enum {
+ EKG_STATUS_NULL = 0x00, /* special value */
+
+ /* These statuses should be considered as no-delivery */
+ EKG_STATUS_ERROR, /* used in Jabber */
+ EKG_STATUS_BLOCKED, /* used in GG */
+
+ /* These statuses should be considered as 'not sure' */
+ EKG_STATUS_UNKNOWN = 0x10, /* used in Jabber */
+ EKG_STATUS_NA = 0x20, /* universal */
+
+ /* These should be considered as 'probably available' */
+ EKG_STATUS_INVISIBLE, /* GG; hard to prioritize... */
+ EKG_STATUS_DND, /* Jabber */
+ EKG_STATUS_XA, /* Jabber */
+ EKG_STATUS_AWAY, /* universal */
+
+ /* These should be considered as 'sure available' */
+ EKG_STATUS_AVAIL = 0x40, /* universal */
+ EKG_STATUS_FFC, /* Jabber */
+
+ /* These are special statuses, which are to be used only with dedicated functions */
+ EKG_STATUS_AUTOAWAY = 0x80, /* putting in auto-away */
+ EKG_STATUS_AUTOXA, /* putting in auto-xa */
+ EKG_STATUS_AUTOBACK /* returning to previous status */
+} status_t;
+
+/* Few words about statuses:
+ *
+ * All of the enum statuses are proritity-sorted. I mean, if we want to determine, which of the two given statuses is more
+ * important, we just do standard arithmetic comparation (e.g. (status1 > status2)). The statuses are also divided into few
+ * functional groups.
+ *
+ * EKG_STATUS_NULL is just declared for fun. It can be used locally (e.g. in functions, where status can be set conditionally,
+ * to see if some condition was true), but it can't be passed to core. None of the core functions recognizes it, so it will be
+ * probably treated like unknown status. I even don't think anyone would use that long name, instead of putting 0.
+ *
+ * The next two statuses, blocked and error, represent situations, in which messages sent to user probably won't be delivered.
+ * They both aren't currently treated specially by core, but this may change in future. If You want to check, if given status
+ * belongs to that group, you should use EKG_STATUS_IS_NODELIVERY.
+ *
+ * Then, we've got two kinds of N/A. Both of them mean the user may be unavailable at the moment, but the messages will be
+ * delivered or queued. EKG_STATUS_UNKNOWN would probably be the lowest prioritized of these statuses, so it is used as a mark
+ * for above group, and EKG_STATUS_NA would be the highest one, so it is used as a mark for all N/A statuses. This group
+ * (combined with above) is identified by macro EKG_STATUS_IS_NA.
+ *
+ * Next status, EKG_STATUS_INVISIBLE, is very problematic. It means that user has sent us an N/A status, but some magic says
+ * it is available although. It's hard to say, if it's an N/A status, or more 'deep kind of away' (often invisible is used
+ * when someone goes AFK for a long time). I don't think it should be used as some kind of mark, and also shouldn't be 'less
+ * available' than EKG_STATUS_NA, so it's put after it. But this _can change_.
+ *
+ * Status described above starts the third group of statuses, aways. These are statuses, which say that user is connected with
+ * server, and messages are delivered directly to him/her, but he/she is probably AFK, busy or like that. All those statuses
+ * are grouped by macro EKG_STATUS_IS_AWAY.
+ *
+ * And the last formal group is available-statuses. The first of them, most traditional 'available', is a mark for this
+ * and above group. The macro is EKG_STATUS_IS_AVAIL.
+ *
+ * The real last group is designed for special use only. Currently, there are only statuses for setting and disabling auto-away
+ * mode in EKG2. These three can be passed only to session_status_set(), and aren't recognized by everything else.
+ */
+
+#define EKG_STATUS_IS_NODELIVERY(x) (x < EKG_STATUS_UNKNOWN)
+#define EKG_STATUS_IS_NA(x) (x <= EKG_STATUS_NA)
+#define EKG_STATUS_IS_AWAY(x) ((x > EKG_STATUS_NA) && (x < EKG_STATUS_AVAIL))
+#define EKG_STATUS_IS_AVAIL(x) (x >= EKG_STATUS_AVAIL)
+
typedef struct {
char *key; /* nazwa parametru */
char *value; /* wartość parametru */
@@ -33,35 +104,35 @@
* session_t contains all information about session
*/
typedef struct {
- /* public: */
- void *plugin; /**< protocol plugin owing session */
- char *uid; /**< user ID */
- char *alias; /**< short name */
- void *priv; /**< protocol plugin's private data */
- list_t userlist; /**< session's userlist */
+/* public: */
+ void *plugin; /**< protocol plugin owing session */
+ char *uid; /**< user ID */
+ char *alias; /**< short name */
+ void *priv; /**< protocol plugin's private data */
+ list_t userlist; /**< session's userlist */
- /* private: */
- int status; /**< session's user status */
- char *descr; /**< session's user description */
- char *password; /**< session's account password */
- int connected; /**< whether session is connected */
- int activity; /**< timestamp of last activity */
- int autoaway; /**< whether we're in autoaway */
- int scroll_last;
- int scroll_pos;
- int scroll_op;
- time_t last_conn; /**< timestamp of connecting */
+/* private: */
+ status_t status; /**< session's user status */
+ char *descr; /**< session's user description */
+ char *password; /**< session's account password */
+ int connected; /**< whether session is connected */
+ time_t activity; /**< timestamp of last activity */
+ int autoaway; /**< whether we're in autoaway */
+ int scroll_last;
+ int scroll_pos;
+ int scroll_op;
+ time_t last_conn; /**< timestamp of connecting */
- int global_vars_count;
- char **values;
- list_t local_vars;
+ int global_vars_count;
+ char **values;
+ list_t local_vars;
- /* new auto-away */
- int laststatus; /**< user's status before going into autoaway */
- char *lastdescr; /**< user's description before going into autoaway */
+/* new auto-away */
+ status_t last_status; /**< user's status before going into autoaway */
+ char *last_descr; /**< user's description before going into autoaway */
#ifdef HAVE_FLOCK /* XXX: -D for docs? */
- int lock_fd; /**< fd used for session locking */
+ int lock_fd; /**< fd used for session locking */
#endif
} session_t;
@@ -82,7 +153,7 @@
int session_status_get(session_t *s);
#define session_status_get_n(a) session_status_get(session_find(a))
-int session_status_set(session_t *s, int status);
+int session_status_set(session_t *s, status_t status);
const char *session_descr_get(session_t *s);
int session_descr_set(session_t *s, const char *descr);
Modified: trunk/ekg/strings.c
===================================================================
--- trunk/ekg/strings.c 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/strings.c 2008-03-02 19:27:48 UTC (rev 3830)
@@ -43,11 +43,11 @@
/* stringo-naprawiacz, taki jak ufix() w xmalloc */
#define ufix(x) ((wchar_t *) x ? (wchar_t *) x : (wchar_t *) L"")
-inline int xwcslen(const CHAR_T *str) {
+inline size_t xwcslen(const CHAR_T *str) {
return wcslen(ufix(str));
}
-inline int xmbslen(const char *str) {
+inline size_t xmbslen(const char *str) {
return mbstowcs(NULL, str ? str : "", 0);
}
Modified: trunk/ekg/strings.h
===================================================================
--- trunk/ekg/strings.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/strings.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -36,8 +36,8 @@
#define STRING_FORMAT "%ls"
#define CHAR_FORMAT "%lc"
-inline int xwcslen(const CHAR_T *str);
-inline int xmbslen(const char *str);
+inline size_t xwcslen(const CHAR_T *str);
+inline size_t xmbslen(const char *str);
inline CHAR_T *xwcscpy(CHAR_T *dst, CHAR_T *src);
inline CHAR_T *xwcsdup(CHAR_T *str);
inline CHAR_T *xwcscat(CHAR_T *dst, const CHAR_T *src);
Modified: trunk/ekg/stuff.c
===================================================================
--- trunk/ekg/stuff.c 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/stuff.c 2008-03-02 19:27:48 UTC (rev 3830)
@@ -657,13 +657,14 @@
{
list_t sl;
- /* wyłanczamy wszystkie blinkające uid'y */
+ /* wyłączamy wszystkie blinkające uid'y */
for (sl = sessions; sl; sl = sl->next) {
list_t l;
session_t *s = sl->data;
+
for (l = s->userlist; l; l = l->next) {
- userlist_t *u = l->data;
- u->xstate &= ~EKG_XSTATE_BLINK;
+ userlist_t *u = l->data;
+ u->blink = 0;;
}
}
}
@@ -2280,7 +2281,7 @@
#endif
}
-void debug_ext(int level, const char *format, ...) {
+void debug_ext(debug_level_t level, const char *format, ...) {
va_list ap;
if (!config_debug) return;
@@ -2531,7 +2532,8 @@
u->status = EKG_STATUS_NA;
else
u->status = session->status;
- u->xstate &= ~EKG_XSTATE_BLINK;
+
+ u->blink = 0;
}
}
Modified: trunk/ekg/stuff.h
===================================================================
--- trunk/ekg/stuff.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/stuff.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -58,11 +58,11 @@
typedef void (*child_handler_t)(struct child_s *c, int pid, const char *name, int status, void *data);
typedef struct child_s {
- int pid; /* id procesu */
- plugin_t *plugin; /* obsługujący plugin */
- char *name; /* nazwa, wyświetlana przy /exec */
- child_handler_t handler; /* zakład pogrzebowy */
- void *private; /* dane procesu */
+ pid_t pid; /* id procesu */
+ plugin_t *plugin; /* obsługujący plugin */
+ char *name; /* nazwa, wyświetlana przy /exec */
+ child_handler_t handler; /* zakład pogrzebowy */
+ void *private; /* dane procesu */
} child_t;
#ifndef EKG2_WIN32_NOFUNCTION
@@ -72,29 +72,29 @@
#ifndef EKG2_WIN32_NOFUNCTION
struct alias {
- char *name; /* nazwa aliasu */
- list_t commands; /* commands->data to (char*) */
+ char *name; /* nazwa aliasu */
+ list_t commands; /* commands->data to (char*) */
};
#endif
#define BINDING_FUNCTION(x) void x(const char *arg)
struct binding {
- char *key;
+ char *key;
- char *action; /* akcja */
- int internal; /* czy domyślna kombinacja? */
- void (*function)(const char *arg); /* funkcja obsługująca */
- char *arg; /* argument funkcji */
+ char *action; /* akcja */
+ unsigned int internal : 1; /* czy domyślna kombinacja? */
+ void (*function)(const char *arg); /* funkcja obsługująca */
+ char *arg; /* argument funkcji */
- char *default_action; /* domyślna akcja */
- void (*default_function)(const char *arg); /* domyślna funkcja */
- char *default_arg; /* domyślny argument */
+ char *default_action; /* domyślna akcja */
+ void (*default_function)(const char *arg); /* domyślna funkcja */
+ char *default_arg; /* domyślny argument */
};
typedef struct {
- char *sequence;
- struct binding *binding;
+ char *sequence;
+ struct binding *binding;
} binding_added_t;
enum mesg_t {
@@ -108,41 +108,41 @@
#define TIMER_SESSION(x) int x(int type, session_t *s)
struct timer {
- char *name; /* nazwa timera */
- plugin_t *plugin; /* wtyczka obsługująca deksryptor */
- struct timeval ends; /* kiedy się kończy? */
- time_t period; /* ile sekund ma trwać czekanie */
- int persist; /* czy ma być na zawsze? */
- int (*function)(int, void *);
- /* funkcja do wywołania */
- void *data; /* dane dla funkcji */
- int at; /* /at? trzeba się tego jakoś pozbyć
- * i ujednolicić z /timer */
- int is_session; /* czy sesyjny */
+ char *name; /* nazwa timera */
+ plugin_t *plugin; /* wtyczka obsługująca deksryptor */
+ struct timeval ends; /* kiedy się kończy? */
+ time_t period; /* ile sekund ma trwać czekanie */
+ int (*function)(int, void *); /* funkcja do wywołania */
+ void *data; /* dane dla funkcji */
+
+ unsigned int persist : 1; /* czy ma być na zawsze? */
+ unsigned int at : 1; /* /at? trzeba się tego jakoś pozbyć
+ * i ujednolicić z /timer */
+ unsigned int is_session : 1; /* czy sesyjny */
};
struct conference {
- char *name;
- int ignore;
- list_t recipients;
+ char *name;
+ ignore_t ignore;
+ list_t recipients;
};
typedef struct {
- char *session;
- char *name;
- list_t participants;
- void *private;
+ char *session;
+ char *name;
+ list_t participants;
+ void *private;
} newconference_t;
struct buffer {
- time_t ts;
- char *target;
- char *line;
+ time_t ts;
+ char *target;
+ char *line;
};
struct color_map {
- int color;
- unsigned char r, g, b;
+ int color;
+ unsigned char r, g, b;
};
#ifndef EKG2_WIN32_NOFUNCTION
Modified: trunk/ekg/themes.h
===================================================================
--- trunk/ekg/themes.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/themes.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -31,20 +31,21 @@
typedef struct {
union {
- char *b; /* possibly multibyte string */
- CHAR_T *w; /* wide char string */
+ char *b; /* possibly multibyte string */
+ CHAR_T *w; /* wide char string */
} str; /* A \0-terminated string of characters. Before the
fstring_t is added to history, should be referred to using 'str->b'.
Adding to history recodes it to CHAR_T, so afterwards it should be
referred to by 'str->w'. */
- short *attr; /* atrybuty, ciąg o długości strlen(str) */
- int ts; /* timestamp */
- int prompt_len; /* długość promptu, który będzie powtarzany przy i
- przejściu do kolejnej linii. */
- int prompt_empty; /* prompt przy przenoszeniu będzie pusty */
- int margin_left; /* where the margin is set (on what char) */
- void *private; /* can be helpfull */
+ short *attr; /* atrybuty, ciąg o długości strlen(str) */
+ time_t ts; /* timestamp */
+
+ size_t prompt_len; /* długość promptu, który będzie powtarzany przy
+ przejściu do kolejnej linii. */
+ unsigned int prompt_empty : 1; /* prompt przy przenoszeniu będzie pusty */
+ int margin_left; /* where the margin is set (on what char) */
+ void *private; /* can be helpfull */
} fstring_t;
#define print(x...) print_window_w(NULL, 0, x)
@@ -76,19 +77,21 @@
*/
#define isalpha_pl_PL(x) ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') || x == 'ą' || x == 'ć' || x == 'ę' || x == 'ł' || x == 'ń' || x == 'ó' || x == 'ś' || x == 'ż' || x == 'ź' || x == 'Ą' || x == 'Ć' || x == 'Ę' || x == 'Ł' || x == 'Ń' || x == 'Ó' || x == 'Ś' || x == 'Ż' || x == 'Ź')
-#define FSTR_FOREA 1
-#define FSTR_FOREB 2
-#define FSTR_FOREC 4
-#define FSTR_FOREMASK (FSTR_FOREA|FSTR_FOREB|FSTR_FOREC)
-#define FSTR_BACKA 8
-#define FSTR_BACKB 16
-#define FSTR_BACKC 32
-#define FSTR_BACKMASK (FSTR_BACKA|FSTR_BACKB|FSTR_BACKC)
-#define FSTR_BOLD 64
-#define FSTR_NORMAL 128
-#define FSTR_BLINK 256
-#define FSTR_UNDERLINE 512
-#define FSTR_REVERSE 1024
+typedef enum {
+ FSTR_FOREA = 1,
+ FSTR_FOREB = 2,
+ FSTR_FOREC = 4,
+ FSTR_FOREMASK = (FSTR_FOREA|FSTR_FOREB|FSTR_FOREC),
+ FSTR_BACKA = 8,
+ FSTR_BACKB = 16,
+ FSTR_BACKC = 32,
+ FSTR_BACKMASK = (FSTR_BACKA|FSTR_BACKB|FSTR_BACKC),
+ FSTR_BOLD = 64,
+ FSTR_NORMAL = 128,
+ FSTR_BLINK = 256,
+ FSTR_UNDERLINE = 512,
+ FSTR_REVERSE = 1024
+} fstr_t;
#endif /* __EKG_THEMES_H */
Modified: trunk/ekg/userlist.c
===================================================================
--- trunk/ekg/userlist.c 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/userlist.c 2008-03-02 19:27:48 UTC (rev 3830)
@@ -920,7 +920,7 @@
* - uin.
* - level.
*/
-int ignored_add(session_t *session, const char *uid, int level) {
+int ignored_add(session_t *session, const char *uid, ignore_t level) {
userlist_t *u;
char *tmps, *tmp;
int oldlevel = 0;
Modified: trunk/ekg/userlist.h
===================================================================
--- trunk/ekg/userlist.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/userlist.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -48,41 +48,42 @@
*/
typedef struct {
- char *uid; /**< uin in form protocol:id */
- char *nickname; /**< nickname */
- list_t groups; /**< list_t with ekg_group<br>
- * Groups to which this user belongs like: work, friends, family..<br>
- * It's also used internally by ekg2, for example when user is ignore he has group with name: __ignore */
+ char *uid; /**< uin in form protocol:id */
+ char *nickname; /**< nickname */
+ list_t groups; /**< list_t with ekg_group<br>
+ * Groups to which this user belongs like: work, friends, family..<br>
+ * It's also used internally by ekg2, for example when user is ignore he has group with name: __ignore */
- int status; /**< current status */
- char *descr; /**< description of status. */
- list_t resources; /**< list_t with ekg_resource_t<br>It's used to handle Jabber resources, and also by irc friendlist. */
+ status_t status; /**< current status */
+ char *descr; /**< description of status. */
+ list_t resources; /**< list_t with ekg_resource_t<br>It's used to handle Jabber resources, and also by irc friendlist. */
- time_t last_seen; /**< Last time when user was available [when u->status was > notavail] */
+ time_t last_seen; /**< Last time when user was available [when u->status was > notavail] */
- char *foreign; /**< For compatilibity with ekg1 userlist. */
+ char *foreign; /**< For compatilibity with ekg1 userlist. */
- void *priv; /**< Private data for protocol plugin. */
+ void *priv; /**< Private data for protocol plugin. */
- int xstate; /**< Extended userlist element state, for example blinking or typing notify */
+ unsigned int blink : 1; /**< Blink userlist entry (message) */
+ unsigned int typing : 1; /**< User is composing */
- int last_status; /**< Lastseen status */
- char *last_descr; /**< Lastseen description */
- time_t status_time; /**< From when we have this status, description */
- void *private; /**< Alternate private data, used by ncurses plugin */
+ status_t last_status; /**< Lastseen status */
+ char *last_descr; /**< Lastseen description */
+ time_t status_time; /**< From when we have this status, description */
+ void *private; /**< Alternate private data, used by ncurses plugin */
} userlist_t;
-enum xstate_t {
+typedef enum {
EKG_XSTATE_BLINK = 1,
EKG_XSTATE_TYPING = 2
-};
+} xstate_t;
/**
* userlist_privhandler_func_t - here we declare possible options for 'function' arg in USERLIST_PRIVHANDLE
*
* All of them, excluding EKG_USERLIST_PRIVHANDLER_FREE, should alloc&init priv if needed
*/
-enum userlist_privhandler_func_t {
+typedef enum {
EKG_USERLIST_PRIVHANDLER_FREE = 0, /**< Free private data (called when freeing userlist_t) */
EKG_USERLIST_PRIVHANDLER_GET, /**< Return private data ptr, arg is void** for ptr */
EKG_USERLIST_PRIVHANDLER_READING, /**< Called when reading userlist file,<br>
@@ -102,90 +103,19 @@
EKG_USERLIST_PRIVHANDLER_SETVAR_BYNAME = 0xC0, /**< Set private 'variable' by name, args care char** with var name
* and char** with value (will be duplicated) */
-};
+} userlist_privhandler_func_t;
-/**
- * status_t - user's current status, as prioritized enum
- */
-
-enum status_t {
- EKG_STATUS_NULL = 0x00, /* special value */
-
- /* These statuses should be considered as no-delivery */
- EKG_STATUS_ERROR, /* used in Jabber */
- EKG_STATUS_BLOCKED, /* used in GG */
-
- /* These statuses should be considered as 'not sure' */
- EKG_STATUS_UNKNOWN = 0x10, /* used in Jabber */
- EKG_STATUS_NA = 0x20, /* universal */
-
- /* These should be considered as 'probably available' */
- EKG_STATUS_INVISIBLE, /* GG; hard to prioritize... */
- EKG_STATUS_DND, /* Jabber */
- EKG_STATUS_XA, /* Jabber */
- EKG_STATUS_AWAY, /* universal */
-
- /* These should be considered as 'sure available' */
- EKG_STATUS_AVAIL = 0x40, /* universal */
- EKG_STATUS_FFC, /* Jabber */
-
- /* These are special statuses, which are to be used only with dedicated functions */
- EKG_STATUS_AUTOAWAY = 0x80, /* putting in auto-away */
- EKG_STATUS_AUTOXA, /* putting in auto-xa */
- EKG_STATUS_AUTOBACK /* returning to previous status */
-};
-
-/* Few words about statuses:
- *
- * All of the enum statuses are proritity-sorted. I mean, if we want to determine, which of the two given statuses is more
- * important, we just do standard arithmetic comparation (e.g. (status1 > status2)). The statuses are also divided into few
- * functional groups.
- *
- * EKG_STATUS_NULL is just declared for fun. It can be used locally (e.g. in functions, where status can be set conditionally,
- * to see if some condition was true), but it can't be passed to core. None of the core functions recognizes it, so it will be
- * probably treated like unknown status. I even don't think anyone would use that long name, instead of putting 0.
- *
- * The next two statuses, blocked and error, represent situations, in which messages sent to user probably won't be delivered.
- * They both aren't currently treated specially by core, but this may change in future. If You want to check, if given status
- * belongs to that group, you should use EKG_STATUS_IS_NODELIVERY.
- *
- * Then, we've got two kinds of N/A. Both of them mean the user may be unavailable at the moment, but the messages will be
- * delivered or queued. EKG_STATUS_UNKNOWN would probably be the lowest prioritized of these statuses, so it is used as a mark
- * for above group, and EKG_STATUS_NA would be the highest one, so it is used as a mark for all N/A statuses. This group
- * (combined with above) is identified by macro EKG_STATUS_IS_NA.
- *
- * Next status, EKG_STATUS_INVISIBLE, is very problematic. It means that user has sent us an N/A status, but some magic says
- * it is available although. It's hard to say, if it's an N/A status, or more 'deep kind of away' (often invisible is used
- * when someone goes AFK for a long time). I don't think it should be used as some kind of mark, and also shouldn't be 'less
- * available' than EKG_STATUS_NA, so it's put after it. But this _can change_.
- *
- * Status described above starts the third group of statuses, aways. These are statuses, which say that user is connected with
- * server, and messages are delivered directly to him/her, but he/she is probably AFK, busy or like that. All those statuses
- * are grouped by macro EKG_STATUS_IS_AWAY.
- *
- * And the last formal group is available-statuses. The first of them, most traditional 'available', is a mark for this
- * and above group. The macro is EKG_STATUS_IS_AVAIL.
- *
- * The real last group is designed for special use only. Currently, there are only statuses for setting and disabling auto-away
- * mode in EKG2. These three can be passed only to session_status_set(), and aren't recognized by everything else.
- */
-
-#define EKG_STATUS_IS_NODELIVERY(x) (x < EKG_STATUS_UNKNOWN)
-#define EKG_STATUS_IS_NA(x) (x <= EKG_STATUS_NA)
-#define EKG_STATUS_IS_AWAY(x) ((x > EKG_STATUS_NA) && (x < EKG_STATUS_AVAIL))
-#define EKG_STATUS_IS_AVAIL(x) (x >= EKG_STATUS_AVAIL)
-
/**
* ekg_resource_t is used to manage userlist_t resources.<br>
* For example jabber resources, or irc friendlist
*/
typedef struct {
- char *name; /**< name of resource */
- int status; /**< status, like u->status [status of resource] */
- char *descr; /**< descr, like u->descr [description of resource] */
- int prio; /**< prio of resource [priority of this resource] */
- void *private; /**< priv, like u->private [private data info/struct] */
+ char *name; /**< name of resource */
+ status_t status; /**< status, like u->status [status of resource] */
+ char *descr; /**< descr, like u->descr [description of resource] */
+ int prio; /**< prio of resource [priority of this resource] */
+ void *private; /**< priv, like u->private [private data info/struct] */
} ekg_resource_t;
/**
@@ -196,7 +126,7 @@
char *name; /**< name of group */
};
-enum ignore_t {
+typedef enum {
IGNORE_STATUS = 0x01,
IGNORE_STATUS_DESCR = 0x02,
IGNORE_MSG = 0x04,
@@ -206,11 +136,11 @@
IGNORE_XOSD = 0x40,
IGNORE_ALL = 0xFF
-};
+} ignore_t;
struct ignore_label {
- int level;
- char *name;
+ ignore_t level;
+ char *name;
};
#define IGNORE_LABELS_MAX 8
@@ -243,7 +173,7 @@
void userlist_resource_remove(userlist_t *u, ekg_resource_t *r);
void userlist_resource_free(userlist_t *u);
-int ignored_add(session_t *session, const char *uid, int level);
+int ignored_add(session_t *session, const char *uid, ignore_t level);
int ignored_remove(session_t *session, const char *uid);
int ignored_check(session_t *session, const char *uid);
int ignore_flags(const char *str);
Modified: trunk/ekg/windows.c
===================================================================
--- trunk/ekg/windows.c 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/windows.c 2008-03-02 19:27:48 UTC (rev 3830)
@@ -206,9 +206,9 @@
query_emit_id(NULL, UI_WINDOW_SWITCH, &w); /* XXX */
w->act = 0;
- if (w->target && w->session && (u = userlist_find(w->session, w->target)) && (u->xstate & EKG_XSTATE_BLINK)) {
- u->xstate &= ~EKG_XSTATE_BLINK;
- ul_refresh = 1;
+ if (w->target && w->session && (u = userlist_find(w->session, w->target)) && u->blink) {
+ u->blink = 0;
+ ul_refresh = 1;
}
if (!(config_make_window & 3) && w->id == 1 && session_current) {
@@ -218,9 +218,9 @@
for (l = s->userlist; l; l = l->next) {
userlist_t *u = l->data;
- if ((u->xstate & EKG_XSTATE_BLINK) && !window_find_s(s, u->uid)) {
- u->xstate &= ~EKG_XSTATE_BLINK;
- ul_refresh = 1;
+ if (u->blink && !window_find_s(s, u->uid)) {
+ u->blink = 0;
+ ul_refresh = 1;
}
}
}
@@ -596,7 +596,7 @@
if (w->id) {
if (w->target) {
- if (!w->floating)
+ if (!w->floating)
printq("window_list_query", itoa(w->id), w->target);
else
printq("window_list_floating", itoa(w->id), itoa(w->left), itoa(w->top), itoa(w->width), itoa(w->height), w->target);
Modified: trunk/ekg/windows.h
===================================================================
--- trunk/ekg/windows.h 2008-03-01 14:55:22 UTC (rev 3829)
+++ trunk/ekg/windows.h 2008-03-02 19:27:48 UTC (rev 3830)
@@ -34,23 +34,23 @@
#endif
typedef struct {
- void *w; /* window, if NULL it means current */
- int casense; /* 0 - ignore case; 1 - don't ignore case, -1 - use global variable */
- int lock; /* if 0, don't update */
- int isregex; /* 1 - in target regexp */
+ void *w; /* window, if NULL it means current */
+ int casense : 2; /* 0 - ignore case; 1 - don't ignore case, -1 - use global variable */
+ unsigned int lock : 1; /* if 0, don't update */
+ unsigned int isregex : 1; /* 1 - in target regexp */
#ifdef HAVE_REGEX_H
- regex_t reg; /* regexp compilated expression */
+ regex_t reg; /* regexp compilated expression */
#endif
- char *expression; /* expression */
+ char *expression; /* expression */
} window_lastlog_t;
typedef struct {
- int id; /* numer okna */
- char *target; /* nick query albo inna nazwa albo NULL */
- session_t *session; /* której sesji dotyczy okno */
+ unsigned short int id; /* numer okna */
+ char *target; /* nick query albo inna nazwa albo NULL */
+ session_t *session; /* której sesji dotyczy okno */
- int left, top; /* pozycja (x, y) względem początku ekranu */
- int width, height; /* wymiary okna */
+ unsigned short int left, top; /* pozycja (x, y) względem początku ekranu */
+ unsigned short int width, height; /* wymiary okna */
unsigned int act : 2; /* activity: 1 - status/junk; 2 - msg */
unsigned int in_typing : 1; /* user is composing a message to us */
@@ -58,21 +58,23 @@
so we can start sending composing to him/her */
unsigned int out_active : 1; /* we 'started' sending messages to user (considered
ourselves active), so we shall say goodbye when done */
- int more; /* pojawiło się coś poza ekranem */
+ unsigned int more : 1; /* pojawiło się coś poza ekranem */
+ unsigned int floating : 1; /* czy pływające? */
+ unsigned int doodle : 1; /* czy do gryzmolenia? [we don't set it anywhere] */
- int floating; /* czy pływające? */
- int doodle; /* czy do gryzmolenia? */
- int frames; /* informacje o ramkach */
- int edge; /* okienko brzegowe */
- int last_update; /* czas ostatniego uaktualnienia */
- int nowrap; /* nie zawijamy linii */
- int hide; /* ukrywamy, bo jest zbyt duże */
- int lock; /* blokowanie zmian w obrębie komendy */
+ unsigned int frames : 4; /* informacje o ramkach */
+ unsigned int edge : 4; /* okienko brzegowe */
- list_t userlist; /* sometimes window may require separate userlist */
+ unsigned int nowrap : 1; /* nie zawijamy linii */
+ unsigned int hide : 1; /* ukrywamy, bo jest zbyt duże */
+ time_t last_update; /* czas ostatniego uaktualnienia */
+ unsigned short int lock; /* blokowanie zmian w obrębie komendy */
+
+ list_t userlist; /* sometimes window may require separate userlist */
+
window_lastlog_t *lastlog; /* prywatne informacje lastloga */
- void *private; /* prywatne informacje ui */
+ void *private; /* prywatne informacje ui */
} window_t;
#ifndef EKG2_WIN32_NOFUNCTION
Więcej informacji o liście dyskusyjnej ekg2-commit