ekg2
GIT master
Strona główna
Dodatkowe strony
Moduły
Struktury Danych
Pliki
Lista plików
Globalne
All
Struktury Danych
Pliki
Funkcje
Zmienne
Definicje typów
Wyliczenia
Wartości wyliczeń
Definicje
Grupay
Strony
ekg
sessions.h
Idź do dokumentacji tego pliku.
1
/* $Id$ */
2
3
/*
4
* (C) Copyright 2003 Wojtek Kaniewski <wojtekka@irc.pl>
5
* 2004 Piotr Kupisiewicz <deli@rzepaknet.us>
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License Version 2 as
9
* published by the Free Software Foundation.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
*/
20
21
#ifndef __EKG_SESSIONS_H
22
#define __EKG_SESSIONS_H
23
24
#include <time.h>
25
#include "
dynstuff.h
"
26
27
#ifdef __cplusplus
28
extern
"C"
{
29
#endif
30
31
/* --NOTE--
32
* When modifying status_t, remember to update status tables in stuff.c!
33
*/
34
39
typedef
enum
{
40
EKG_STATUS_NULL
= 0x00,
/* special value */
41
42
/* These statuses should be considered as no-delivery */
43
EKG_STATUS_ERROR
,
/* used in Jabber */
44
EKG_STATUS_BLOCKED
,
/* used in GG */
45
46
/* These statuses should be considered as 'not sure' */
47
EKG_STATUS_UNKNOWN
,
/* used in Jabber */
48
EKG_STATUS_NA
,
/* universal */
49
50
/* These should be considered as 'probably available' */
51
EKG_STATUS_INVISIBLE
,
/* GG; hard to prioritize... */
52
EKG_STATUS_DND
,
/* Jabber */
53
EKG_STATUS_GONE
,
/* ICQ */
54
EKG_STATUS_XA
,
/* Jabber */
55
EKG_STATUS_AWAY
,
/* universal */
56
57
/* These should be considered as 'sure available' */
58
EKG_STATUS_AVAIL
,
/* universal */
59
EKG_STATUS_FFC
,
/* Jabber */
60
61
EKG_STATUS_LAST
,
62
/* XXX: autostatuses are going to be rewritten and then below will be removed */
63
/* These are special statuses, which are to be used only with dedicated functions */
64
EKG_STATUS_AUTOAWAY
= 0x80,
/* putting in auto-away */
65
EKG_STATUS_AUTOXA
,
/* putting in auto-xa */
66
EKG_STATUS_AUTOBACK
/* returning to previous status */
67
}
status_t
;
68
69
typedef
enum
{
70
EKG_CHATSTATE_COMPOSING
= 1 << 0,
71
EKG_CHATSTATE_ACTIVE
= 1 << 1,
72
EKG_CHATSTATE_GONE
= 1 << 2,
73
_EKG_CHATSTATE_NOT
= 1 << 10,
74
EKG_CHATSTATE_PAUSED
=
_EKG_CHATSTATE_NOT
|
EKG_CHATSTATE_COMPOSING
,
75
EKG_CHATSTATE_INACTIVE
=
_EKG_CHATSTATE_NOT
|
EKG_CHATSTATE_ACTIVE
76
}
chatstates_t
;
77
/* Few words about statuses:
78
*
79
* All of the enum statuses are proritity-sorted. I mean, if we want to determine, which of the two given statuses is more
80
* important, we just do standard arithmetic comparation (e.g. (status1 > status2)). The statuses are also divided into few
81
* functional groups.
82
*
83
* EKG_STATUS_NULL is just declared for fun. It can be used locally (e.g. in functions, where status can be set conditionally,
84
* 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
85
* probably treated like unknown status. I even don't think anyone would use that long name, instead of putting 0.
86
*
87
* The next two statuses, blocked and error, represent situations, in which messages sent to user probably won't be delivered.
88
* They both aren't currently treated specially by core, but this may change in future. If You want to check, if given status
89
* belongs to that group, you should use EKG_STATUS_IS_NODELIVERY.
90
*
91
* 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
92
* delivered or queued. EKG_STATUS_UNKNOWN would probably be the lowest prioritized of these statuses, so it is used as a mark
93
* 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
94
* (combined with above) is identified by macro EKG_STATUS_IS_NA.
95
*
96
* Next status, EKG_STATUS_INVISIBLE, is very problematic. It means that user has sent us an N/A status, but some magic says
97
* 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
98
* 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
99
* available' than EKG_STATUS_NA, so it's put after it. But this _can change_.
100
*
101
* Status described above starts the third group of statuses, aways. These are statuses, which say that user is connected with
102
* server, and messages are delivered directly to him/her, but he/she is probably AFK, busy or like that. All those statuses
103
* are grouped by macro EKG_STATUS_IS_AWAY.
104
*
105
* And the last formal group is available-statuses. The first of them, most traditional 'available', is a mark for this
106
* and above group. The macro is EKG_STATUS_IS_AVAIL.
107
*
108
* The real last group is designed for special use only. Currently, there are only statuses for setting and disabling auto-away
109
* mode in EKG2. These three can be passed only to session_status_set(), and aren't recognized by everything else.
110
*/
111
112
#define EKG_STATUS_IS_NODELIVERY(x) (x < EKG_STATUS_UNKNOWN)
113
#define EKG_STATUS_IS_NA(x) (x <= EKG_STATUS_NA)
114
#define EKG_STATUS_IS_AWAY(x) ((x > EKG_STATUS_NA) && (x < EKG_STATUS_AVAIL))
115
#define EKG_STATUS_IS_AVAIL(x) (x >= EKG_STATUS_AVAIL)
116
117
typedef
struct
session_param
{
118
struct
session_param
*
next
;
119
120
char
*
key
;
/* nazwa parametru */
121
char
*
value
;
/* wartość parametru */
122
}
session_param_t
;
123
127
typedef
struct
ekg_session
{
128
struct
ekg_session
*
next
;
129
130
/* public: */
131
void
*
plugin
;
132
char
*
uid
;
133
char
*
alias
;
134
void
*
priv
;
135
struct
userlist
*
userlist
;
137
/* private: */
138
status_t
status
;
139
char
*
descr
;
140
char
*
password
;
142
unsigned
int
connected
: 1;
143
unsigned
int
connecting
: 2;
144
unsigned
int
autoaway
: 1;
146
time_t
activity
;
147
time_t
last_conn
;
149
int
global_vars_count
;
150
char
**
values
;
151
session_param_t
*
local_vars
;
152
153
/* new auto-away */
154
status_t
last_status
;
155
char
*
last_descr
;
157
#ifdef HAVE_FLOCK
/* XXX: -D for docs? */
158
int
lock_fd;
159
#endif
160
}
session_t
;
161
162
#ifndef EKG2_WIN32_NOFUNCTION
163
extern
session_t
*
sessions
;
164
165
extern
session_t
*
session_current
;
166
167
session_t
*
session_find
(
const
char
*
uid
);
168
session_t
*
session_find_ptr
(
session_t
*s);
169
170
int
session_is_var
(
session_t
*s,
const
char
*key);
171
172
const
char
*
session_uid_get
(
session_t
*s);
173
174
const
char
*
session_alias_get
(
session_t
*s);
175
int
session_alias_set
(
session_t
*s,
const
char
*
alias
);
176
177
int
session_status_get
(
session_t
*s);
178
#define session_status_get_n(a) session_status_get(session_find(a))
179
int
session_status_set
(
session_t
*s,
status_t
status
);
180
181
const
char
*
session_descr_get
(
session_t
*s);
182
int
session_descr_set
(
session_t
*s,
const
char
*
descr
);
183
184
const
char
*
session_password_get
(
session_t
*s);
185
int
session_password_set
(
session_t
*s,
const
char
*password);
186
187
void
*
session_private_get
(
session_t
*s);
188
int
session_private_set
(
session_t
*s,
void
*
priv
);
189
190
int
session_connected_get
(
session_t
*s);
191
int
session_connected_set
(
session_t
*s,
int
connected);
192
193
const
char
*
session_get
(
session_t
*s,
const
char
*key);
194
int
session_int_get
(
session_t
*s,
const
char
*key);
195
int
session_set
(
session_t
*s,
const
char
*key,
const
char
*value);
196
int
session_int_set
(
session_t
*s,
const
char
*key,
int
value);
197
198
const
char
*
session_format
(
session_t
*s);
199
#define session_format_n(a) session_format(session_find(a))
200
201
/* alias or uid - formatted */
202
const
char
*
session_name
(
session_t
*s);
203
204
/* alias or uid - not formatted */
205
#define session_alias_uid(a) (a->alias) ? a->alias : a->uid
206
#define session_alias_uid_n(a) session_alias_uid(session_find(a))
207
208
int
session_check
(
session_t
*s,
int
need_private,
const
char
*protocol);
209
210
int
session_unidle
(
session_t
*s);
211
212
session_t
*
session_add
(
const
char
*
uid
);
213
int
session_remove
(
const
char
*
uid
);
214
215
int
session_read
(
const
gchar *plugin_name) G_GNUC_INTERNAL;
216
void
session_write
();
217
218
void
sessions_free
();
219
220
void
session_help
(
session_t
*s,
const
char
*
name
);
221
#endif
222
223
#ifdef __cplusplus
224
}
225
#endif
226
227
#endif
/* __EKG_SESSIONS_H */
228
229
/*
230
* Local Variables:
231
* mode: c
232
* c-file-style: "k&r"
233
* c-basic-offset: 8
234
* indent-tabs-mode: t
235
* End:
236
*/
Wygenerowano Wt, 29 paź 2013 20:17:04 dla ekg2 programem
1.8.4