mirror of
https://github.com/irssi/irssi.git
synced 2026-08-16 15:12:11 +02:00
Updates.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@641 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
28a7908e73
commit
755a8d40eb
31 changed files with 386 additions and 217 deletions
|
|
@ -28,6 +28,21 @@ typedef CHANNEL_REC *(*CHANNEL_FIND_FUNC)(SERVER_REC *, const char *);
|
|||
|
||||
GSList *channels; /* List of all channels */
|
||||
|
||||
/* Create a new channel */
|
||||
CHANNEL_REC *channel_create(int chat_type, SERVER_REC *server,
|
||||
const char *name, int automatic)
|
||||
{
|
||||
CHANNEL_REC *channel;
|
||||
|
||||
g_return_val_if_fail(server == NULL || IS_SERVER(server), NULL);
|
||||
g_return_val_if_fail(name != NULL, NULL);
|
||||
|
||||
channel = NULL;
|
||||
signal_emit("channel create", 5, &channel, GINT_TO_POINTER(chat_type),
|
||||
server, name, GINT_TO_POINTER(automatic));
|
||||
return channel;
|
||||
}
|
||||
|
||||
void channel_init(CHANNEL_REC *channel, int automatic)
|
||||
{
|
||||
g_return_if_fail(channel != NULL);
|
||||
|
|
@ -40,7 +55,7 @@ void channel_init(CHANNEL_REC *channel, int automatic)
|
|||
}
|
||||
|
||||
MODULE_DATA_INIT(channel);
|
||||
channel->type = module_get_uniq_id("CHANNEL", 0);
|
||||
channel->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL");
|
||||
channel->mode = g_strdup("");
|
||||
channel->createtime = time(NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
/* Returns CHANNEL_REC if it's channel, NULL if it isn't. */
|
||||
#define CHANNEL(channel) \
|
||||
MODULE_CHECK_CAST(channel, CHANNEL_REC, type, "CHANNEL")
|
||||
MODULE_CHECK_CAST_MODULE(channel, CHANNEL_REC, type, \
|
||||
"WINDOW ITEM TYPE", "CHANNEL")
|
||||
|
||||
#define IS_CHANNEL(channel) \
|
||||
(CHANNEL(channel) ? TRUE : FALSE)
|
||||
|
|
@ -17,8 +18,9 @@ typedef struct {
|
|||
|
||||
extern GSList *channels;
|
||||
|
||||
void channels_init(void);
|
||||
void channels_deinit(void);
|
||||
/* Create a new channel */
|
||||
CHANNEL_REC *channel_create(int chat_type, SERVER_REC *server,
|
||||
const char *name, int automatic);
|
||||
|
||||
/* Create new channel record */
|
||||
void channel_init(CHANNEL_REC *channel, int automatic);
|
||||
|
|
@ -27,4 +29,7 @@ void channel_destroy(CHANNEL_REC *channel);
|
|||
/* find channel by name, if `server' is NULL, search from all servers */
|
||||
CHANNEL_REC *channel_find(SERVER_REC *server, const char *name);
|
||||
|
||||
void channels_init(void);
|
||||
void channels_deinit(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -30,8 +30,16 @@ static int next_uniq_id;
|
|||
|
||||
void *module_check_cast(void *object, int type_pos, const char *id)
|
||||
{
|
||||
return object == NULL ||
|
||||
module_find_id(id, G_STRUCT_MEMBER(int, object, type_pos)) == -1 ? NULL : object;
|
||||
return object == NULL || module_find_id(id,
|
||||
G_STRUCT_MEMBER(int, object, type_pos)) == -1 ? NULL : object;
|
||||
}
|
||||
|
||||
void *module_check_cast_module(void *object, int type_pos,
|
||||
const char *module, const char *id)
|
||||
{
|
||||
return object == NULL || strcmp(module_find_id_str(module,
|
||||
G_STRUCT_MEMBER(int, object, type_pos)), id) == 0 ?
|
||||
NULL : object;
|
||||
}
|
||||
|
||||
/* return unique number across all modules for `id' */
|
||||
|
|
|
|||
|
|
@ -33,7 +33,12 @@ void module_unload(MODULE_REC *module);
|
|||
|
||||
#define MODULE_CHECK_CAST(object, cast, type_field, id) \
|
||||
((cast *) module_check_cast(object, offsetof(cast, type_field), id))
|
||||
#define MODULE_CHECK_CAST_MODULE(object, cast, type_field, module, id) \
|
||||
((cast *) module_check_cast_module(object, \
|
||||
offsetof(cast, type_field), module, id))
|
||||
void *module_check_cast(void *object, int type_pos, const char *id);
|
||||
void *module_check_cast_module(void *object, int type_pos,
|
||||
const char *module, const char *id);
|
||||
|
||||
/* return unique number across all modules for `id' */
|
||||
int module_get_uniq_id(const char *module, int id);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,21 @@ GSList *queries;
|
|||
|
||||
typedef QUERY_REC *(*QUERY_FIND_FUNC)(SERVER_REC *, const char *);
|
||||
|
||||
/* Create a new query */
|
||||
QUERY_REC *query_create(int chat_type, SERVER_REC *server,
|
||||
const char *nick, int automatic)
|
||||
{
|
||||
QUERY_REC *query;
|
||||
|
||||
g_return_val_if_fail(server == NULL || IS_SERVER(server), NULL);
|
||||
g_return_val_if_fail(nick != NULL, NULL);
|
||||
|
||||
query = NULL;
|
||||
signal_emit("query create", 5, &query, GINT_TO_POINTER(chat_type),
|
||||
server, nick, GINT_TO_POINTER(automatic));
|
||||
return query;
|
||||
}
|
||||
|
||||
void query_init(QUERY_REC *query, int automatic)
|
||||
{
|
||||
g_return_if_fail(query != NULL);
|
||||
|
|
@ -40,7 +55,7 @@ void query_init(QUERY_REC *query, int automatic)
|
|||
}
|
||||
|
||||
MODULE_DATA_INIT(query);
|
||||
query->type = module_get_uniq_id("QUERY", 0);
|
||||
query->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY");
|
||||
if (query->server != NULL)
|
||||
query->server_tag = g_strdup(query->server->tag);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
/* Returns QUERY_REC if it's query, NULL if it isn't. */
|
||||
#define QUERY(query) \
|
||||
MODULE_CHECK_CAST(query, QUERY_REC, type, "QUERY")
|
||||
MODULE_CHECK_CAST_MODULE(query, QUERY_REC, type, \
|
||||
"WINDOW ITEM TYPE", "QUERY")
|
||||
|
||||
#define IS_QUERY(query) \
|
||||
(QUERY(query) ? TRUE : FALSE)
|
||||
|
|
@ -20,6 +21,10 @@ extern GSList *queries;
|
|||
void query_init(QUERY_REC *query, int automatic);
|
||||
void query_destroy(QUERY_REC *query);
|
||||
|
||||
/* Create a new query */
|
||||
QUERY_REC *query_create(int chat_type, SERVER_REC *server,
|
||||
const char *nick, int automatic);
|
||||
|
||||
/* Find query by name, if `server' is NULL, search from all servers */
|
||||
QUERY_REC *query_find(SERVER_REC *server, const char *nick);
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ server_connect_copy_skeleton(SERVER_CONNECT_REC *src)
|
|||
signal_emit("server connect copy", 2, &dest, src);
|
||||
g_return_val_if_fail(dest != NULL, NULL);
|
||||
|
||||
dest->type = module_get_uniq_id("SERVER CONNECT", 0);
|
||||
dest->proxy = g_strdup(src->proxy);
|
||||
dest->proxy_port = src->proxy_port;
|
||||
dest->proxy_string = g_strdup(src->proxy_string);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "module.h"
|
||||
#include "signals.h"
|
||||
#include "commands.h"
|
||||
#include "line-split.h"
|
||||
#include "net-nonblock.h"
|
||||
#include "net-sendbuffer.h"
|
||||
|
|
@ -28,6 +29,7 @@
|
|||
#include "settings.h"
|
||||
|
||||
#include "servers.h"
|
||||
#include "servers-reconnect.h"
|
||||
#include "servers-redirect.h"
|
||||
#include "servers-setup.h"
|
||||
#include "channels.h"
|
||||
|
|
@ -397,10 +399,49 @@ void server_connect_free(SERVER_CONNECT_REC *conn)
|
|||
g_free(conn);
|
||||
}
|
||||
|
||||
/* `optlist' should contain only one key - the server tag.
|
||||
returns NULL if there was unknown -option */
|
||||
SERVER_REC *cmd_options_get_server(const char *cmd,
|
||||
GHashTable *optlist,
|
||||
SERVER_REC *defserver)
|
||||
{
|
||||
SERVER_REC *server;
|
||||
GSList *list, *tmp, *next;
|
||||
|
||||
/* get all the options, then remove the known ones. there should
|
||||
be only one left - the server tag. */
|
||||
list = hashtable_get_keys(optlist);
|
||||
for (tmp = list; tmp != NULL; tmp = next) {
|
||||
char *option = tmp->data;
|
||||
next = tmp->next;
|
||||
|
||||
if (command_have_option(cmd, option))
|
||||
list = g_slist_remove(list, option);
|
||||
}
|
||||
|
||||
if (list == NULL)
|
||||
return defserver;
|
||||
|
||||
server = server_find_tag(list->data);
|
||||
if (server == NULL || list->next != NULL) {
|
||||
/* unknown option (not server tag) */
|
||||
signal_emit("error command", 2,
|
||||
GINT_TO_POINTER(CMDERR_OPTION_UNKNOWN),
|
||||
server == NULL ? list->data : list->next->data);
|
||||
signal_stop();
|
||||
|
||||
server = NULL;
|
||||
}
|
||||
|
||||
g_slist_free(list);
|
||||
return server;
|
||||
}
|
||||
|
||||
void servers_init(void)
|
||||
{
|
||||
lookup_servers = servers = NULL;
|
||||
|
||||
servers_reconnect_init();
|
||||
servers_redirect_init();
|
||||
servers_setup_init();
|
||||
}
|
||||
|
|
@ -414,6 +455,7 @@ void servers_deinit(void)
|
|||
|
||||
servers_setup_deinit();
|
||||
servers_redirect_deinit();
|
||||
servers_reconnect_deinit();
|
||||
|
||||
module_uniq_destroy("SERVER");
|
||||
module_uniq_destroy("SERVER CONNECT");
|
||||
|
|
|
|||
|
|
@ -48,4 +48,10 @@ SERVER_REC *server_find_chatnet(const char *chatnet);
|
|||
int server_start_connect(SERVER_REC *server);
|
||||
void server_connect_free(SERVER_CONNECT_REC *conn);
|
||||
|
||||
/* `optlist' should contain only one key - the server tag.
|
||||
returns NULL if there was unknown -option */
|
||||
SERVER_REC *cmd_options_get_server(const char *cmd,
|
||||
GHashTable *optlist,
|
||||
SERVER_REC *defserver);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue