summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Davis <loafier@gmail.com>2006-08-10 02:10:22 +0000
committerChristopher Davis <loafier@gmail.com>2006-08-10 02:10:22 +0000
commitb1b54c58af7cd9419631d7b82b860a7b19097836 (patch)
treebd0a8c8cd93ad473a3d835de14b2481d3c5a5c83
parentc0ac6d60c5319a08148d743fd03ba3f66b22dfe0 (diff)
downloadirssi-python-b1b54c58af7cd9419631d7b82b860a7b19097836.tar.gz
irssi-python-b1b54c58af7cd9419631d7b82b860a7b19097836.tar.xz
irssi-python-b1b54c58af7cd9419631d7b82b860a7b19097836.zip
added function headers to documentation of module and all objects.
added MainWindow object git-svn-id: http://svn.irssi.org/repos/irssi-python@4310 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--objects/Makefile2
-rw-r--r--objects/channel-object.c264
-rw-r--r--objects/command-object.c2
-rw-r--r--objects/connect-object.c129
-rw-r--r--objects/dcc-chat-object.c4
-rw-r--r--objects/dcc-object.c26
-rw-r--r--objects/factory.c3
-rw-r--r--objects/factory.h1
-rw-r--r--objects/ignore-object.c29
-rw-r--r--objects/irc-channel-object.c21
-rw-r--r--objects/irc-connect-object.c31
-rw-r--r--objects/irc-server-object.c169
-rw-r--r--objects/log-object.c24
-rw-r--r--objects/main-window-object.c199
-rw-r--r--objects/main-window-object.h20
-rw-r--r--objects/netsplit-object.c4
-rw-r--r--objects/nick-object.c185
-rw-r--r--objects/notifylist-object.c8
-rw-r--r--objects/pyscript-object.c12
-rw-r--r--objects/query-object.c67
-rw-r--r--objects/rawlog-object.c45
-rw-r--r--objects/reconnect-object.c1
-rw-r--r--objects/server-object.c76
-rw-r--r--objects/statusbar-item-object.c40
-rw-r--r--objects/window-item-object.c35
-rw-r--r--objects/window-object.c70
-rw-r--r--pyirssi.h1
-rw-r--r--pyirssi_irc.h1
-rw-r--r--pymodule.c398
-rw-r--r--pythemes.c4
30 files changed, 1407 insertions, 464 deletions
diff --git a/objects/Makefile b/objects/Makefile
index db2c7bb..6cc56fb 100644
--- a/objects/Makefile
+++ b/objects/Makefile
@@ -16,7 +16,7 @@ rawlog-object.o log-object.o logitem-object.o ignore-object.o \
dcc-object.o dcc-chat-object.o dcc-get-object.o dcc-send-object.o \
netsplit-object.o netsplit-server-object.o netsplit-channel-object.o \
notifylist-object.o process-object.o command-object.o theme-object.o \
-statusbar-item-object.o factory.o
+statusbar-item-object.o main-window-object.o factory.o
pyobjects.a: $(OBJ)
ar r pyobjects.a $(OBJ)
diff --git a/objects/channel-object.c b/objects/channel-object.c
index 7e3758d..fa4edd4 100644
--- a/objects/channel-object.c
+++ b/objects/channel-object.c
@@ -5,25 +5,6 @@
#include "channel-object.h"
#include "pycore.h"
-/* member IDs */
-enum
-{
- M_CHANNEL_TOPIC,
- M_CHANNEL_TOPIC_BY,
- M_CHANNEL_TOPIC_TIME,
- M_CHANNEL_NO_MODES,
- M_CHANNEL_MODE,
- M_CHANNEL_LIMIT,
- M_CHANNEL_KEY,
- M_CHANNEL_CHANOP,
- M_CHANNEL_NAMES_GOT,
- M_CHANNEL_WHOLIST,
- M_CHANNEL_SYNCED,
- M_CHANNEL_JOINED,
- M_CHANNEL_LEFT,
- M_CHANNEL_KICKED,
-};
-
/* monitor "channel destroyed" signal */
static void chan_cleanup(CHANNEL_REC *chan)
{
@@ -45,112 +26,171 @@ static void PyChannel_dealloc(PyChannel *self)
self->ob_type->tp_free((PyObject*)self);
}
-
-static PyObject *PyChannel_get(PyChannel *self, void *closure)
+/* Getters */
+PyDoc_STRVAR(PyChannel_topic_doc,
+ "Channel topic"
+);
+static PyObject *PyChannel_topic_get(PyChannel *self, void *closure)
{
- int member = GPOINTER_TO_INT(closure);
-
RET_NULL_IF_INVALID(self->data);
-
- switch (member)
- {
- case M_CHANNEL_TOPIC:
- RET_AS_STRING_OR_NONE(self->data->topic);
- case M_CHANNEL_TOPIC_BY:
- RET_AS_STRING_OR_NONE(self->data->topic_by);
- case M_CHANNEL_TOPIC_TIME:
- return PyLong_FromLong(self->data->topic_time);
- case M_CHANNEL_NO_MODES:
- return PyBool_FromLong(self->data->no_modes);
- case M_CHANNEL_MODE:
- RET_AS_STRING_OR_NONE(self->data->mode);
- case M_CHANNEL_LIMIT:
- return PyInt_FromLong(self->data->limit);
- case M_CHANNEL_KEY:
- RET_AS_STRING_OR_NONE(self->data->key);
- case M_CHANNEL_CHANOP:
- return PyBool_FromLong(self->data->chanop);
- case M_CHANNEL_NAMES_GOT:
- return PyBool_FromLong(self->data->names_got);
- case M_CHANNEL_WHOLIST:
- return PyBool_FromLong(self->data->wholist);
- case M_CHANNEL_SYNCED:
- return PyBool_FromLong(self->data->synced);
- case M_CHANNEL_JOINED:
- return PyBool_FromLong(self->data->joined);
- case M_CHANNEL_LEFT:
- return PyBool_FromLong(self->data->left);
- case M_CHANNEL_KICKED:
- return PyBool_FromLong(self->data->kicked);
- }
-
- /* This shouldn't be reached... but... */
- return PyErr_Format(PyExc_RuntimeError, "invalid member id, %d", member);
+ RET_AS_STRING_OR_NONE(self->data->topic);
}
-/* specialized getters/setters */
-static PyGetSetDef PyChannel_getseters[] = {
- {"topic", (getter)PyChannel_get, NULL,
- "Channel topic",
- GINT_TO_POINTER(M_CHANNEL_TOPIC)},
-
- {"topic_by", (getter)PyChannel_get, NULL,
- "Nick who set the topic",
- GINT_TO_POINTER(M_CHANNEL_TOPIC_BY)},
+PyDoc_STRVAR(PyChannel_topic_by_doc,
+ "Nick who set the topic"
+);
+static PyObject *PyChannel_topic_by_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->topic_by);
+}
- {"topic_time", (getter)PyChannel_get, NULL,
- "Timestamp when the topic was set",
- GINT_TO_POINTER(M_CHANNEL_TOPIC_TIME)},
+PyDoc_STRVAR(PyChannel_topic_time_doc,
+ "Timestamp when the topic was set"
+);
+static PyObject *PyChannel_topic_time_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyLong_FromLong(self->data->topic_time);
+}
- {"no_modes", (getter)PyChannel_get, NULL,
- "Channel is modeless",
- GINT_TO_POINTER(M_CHANNEL_NO_MODES)},
+PyDoc_STRVAR(PyChannel_no_modes_doc,
+ "Channel is modeless"
+);
+static PyObject *PyChannel_no_modes_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->no_modes);
+}
- {"mode", (getter)PyChannel_get, NULL,
- "Channel mode",
- GINT_TO_POINTER(M_CHANNEL_MODE)},
+PyDoc_STRVAR(PyChannel_mode_doc,
+ "Channel mode"
+);
+static PyObject *PyChannel_mode_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->mode);
+}
- {"limit", (getter)PyChannel_get, NULL,
- "Max. users in channel (+l mode)",
- GINT_TO_POINTER(M_CHANNEL_LIMIT)},
+PyDoc_STRVAR(PyChannel_limit_doc,
+ "Max. users in channel (+l mode)"
+);
+static PyObject *PyChannel_limit_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyInt_FromLong(self->data->limit);
+}
- {"key", (getter)PyChannel_get, NULL,
- "Channel key (password)",
- GINT_TO_POINTER(M_CHANNEL_KEY)},
+PyDoc_STRVAR(PyChannel_key_doc,
+ "Channel key (password)"
+);
+static PyObject *PyChannel_key_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->key);
+}
- {"chanop", (getter)PyChannel_get, NULL,
- "You are channel operator",
- GINT_TO_POINTER(M_CHANNEL_CHANOP)},
+PyDoc_STRVAR(PyChannel_chanop_doc,
+ "You are channel operator"
+);
+static PyObject *PyChannel_chanop_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->chanop);
+}
- {"names_got", (getter)PyChannel_get, NULL,
- "/NAMES list has been received",
- GINT_TO_POINTER(M_CHANNEL_NAMES_GOT)},
+PyDoc_STRVAR(PyChannel_names_got_doc,
+ "/NAMES list has been received"
+);
+static PyObject *PyChannel_names_got_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->names_got);
+}
- {"wholist", (getter)PyChannel_get, NULL,
- "/WHO list has been received",
- GINT_TO_POINTER(M_CHANNEL_WHOLIST)},
+PyDoc_STRVAR(PyChannel_wholist_doc,
+ "/WHO list has been received"
+);
+static PyObject *PyChannel_wholist_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->wholist);
+}
- {"synced", (getter)PyChannel_get, NULL,
- "Channel is fully synchronized",
- GINT_TO_POINTER(M_CHANNEL_SYNCED)},
+PyDoc_STRVAR(PyChannel_synced_doc,
+ "Channel is fully synchronized"
+);
+static PyObject *PyChannel_synced_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->synced);
+}
- {"joined", (getter)PyChannel_get, NULL,
- "JOIN event for this channel has been received",
- GINT_TO_POINTER(M_CHANNEL_JOINED)},
+PyDoc_STRVAR(PyChannel_joined_doc,
+ "JOIN event for this channel has been received"
+);
+static PyObject *PyChannel_joined_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->joined);
+}
- {"left", (getter)PyChannel_get, NULL,
- "You just left the channel (for 'channel destroyed' event)",
- GINT_TO_POINTER(M_CHANNEL_LEFT)},
+PyDoc_STRVAR(PyChannel_left_doc,
+ "You just left the channel (for 'channel destroyed' event)"
+);
+static PyObject *PyChannel_left_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->left);
+}
- {"kicked", (getter)PyChannel_get, NULL,
- "You was just kicked out of the channel (for 'channel destroyed' event)",
- GINT_TO_POINTER(M_CHANNEL_KICKED)},
+PyDoc_STRVAR(PyChannel_kicked_doc,
+ "You were just kicked out of the channel (for 'channel destroyed' event)"
+);
+static PyObject *PyChannel_kicked_get(PyChannel *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->kicked);
+}
+/* specialized getters/setters */
+static PyGetSetDef PyChannel_getseters[] = {
+ {"topic", (getter)PyChannel_topic_get, NULL,
+ PyChannel_topic_doc, NULL},
+ {"topic_by", (getter)PyChannel_topic_by_get, NULL,
+ PyChannel_topic_by_doc, NULL},
+ {"topic_time", (getter)PyChannel_topic_time_get, NULL,
+ PyChannel_topic_time_doc, NULL},
+ {"no_modes", (getter)PyChannel_no_modes_get, NULL,
+ PyChannel_no_modes_doc, NULL},
+ {"mode", (getter)PyChannel_mode_get, NULL,
+ PyChannel_mode_doc, NULL},
+ {"limit", (getter)PyChannel_limit_get, NULL,
+ PyChannel_limit_doc, NULL},
+ {"key", (getter)PyChannel_key_get, NULL,
+ PyChannel_key_doc, NULL},
+ {"chanop", (getter)PyChannel_chanop_get, NULL,
+ PyChannel_chanop_doc, NULL},
+ {"names_got", (getter)PyChannel_names_got_get, NULL,
+ PyChannel_names_got_doc, NULL},
+ {"wholist", (getter)PyChannel_wholist_get, NULL,
+ PyChannel_wholist_doc, NULL},
+ {"synced", (getter)PyChannel_synced_get, NULL,
+ PyChannel_synced_doc, NULL},
+ {"joined", (getter)PyChannel_joined_get, NULL,
+ PyChannel_joined_doc, NULL},
+ {"left", (getter)PyChannel_left_get, NULL,
+ PyChannel_left_doc, NULL},
+ {"kicked", (getter)PyChannel_kicked_get, NULL,
+ PyChannel_kicked_doc, NULL},
{NULL}
};
+/* Methods */
PyDoc_STRVAR(PyChannel_nicks_doc,
- "Return a list of nicks in the channel."
+ "nicks() -> list of Nick objects\n"
+ "\n"
+ "Return a list of nicks in the channel.\n"
);
static PyObject *PyChannel_nicks(PyChannel *self, PyObject *args)
{
@@ -160,7 +200,9 @@ static PyObject *PyChannel_nicks(PyChannel *self, PyObject *args)
}
PyDoc_STRVAR(PyChannel_nicks_find_mask_doc,
- "Find nick mask from nicklist, wildcards allowed."
+ "nicks_find_mask(mask) -> Nick object or None\n"
+ "\n"
+ "Find nick mask from nicklist, wildcards allowed.\n"
);
static PyObject *PyChannel_nicks_find_mask(PyChannel *self, PyObject *args, PyObject *kwds)
{
@@ -177,7 +219,9 @@ static PyObject *PyChannel_nicks_find_mask(PyChannel *self, PyObject *args, PyOb
}
PyDoc_STRVAR(PyChannel_nick_find_doc,
- "Find nick from nicklist."
+ "nick_find(nick) -> Nick object or None\n"
+ "\n"
+ "Find nick from nicklist.\n"
);
static PyObject *PyChannel_nick_find(PyChannel *self, PyObject *args, PyObject *kwds)
{
@@ -194,7 +238,9 @@ static PyObject *PyChannel_nick_find(PyChannel *self, PyObject *args, PyObject *
}
PyDoc_STRVAR(PyChannel_nick_remove_doc,
- "Remove nick from nicklist."
+ "nick_remove(nick) -> None\n"
+ "\n"
+ "Remove nick from nicklist.\n"
);
static PyObject *PyChannel_nick_remove(PyChannel *self, PyObject *args, PyObject *kwds)
{
@@ -216,7 +262,9 @@ static PyObject *PyChannel_nick_remove(PyChannel *self, PyObject *args, PyObject
}
PyDoc_STRVAR(PyChannel_nick_insert_obj_doc,
- "Insert nick object into nicklist."
+ "nick_insert(nick) -> None\n"
+ "\n"
+ "Insert nick object into nicklist.\n"
);
static PyObject *PyChannel_nick_insert_obj(PyChannel *self, PyObject *args, PyObject *kwds)
{
diff --git a/objects/command-object.c b/objects/command-object.c
index 74f9fc2..ad60012 100644
--- a/objects/command-object.c
+++ b/objects/command-object.c
@@ -38,7 +38,7 @@ static PyObject *PyCommand_new(PyTypeObject *type, PyObject *args, PyObject *kwd
return (PyObject *)self;
}
-/* Getter */
+/* Getters */
PyDoc_STRVAR(PyCommand_cmd_doc,
"Command name"
);
diff --git a/objects/connect-object.c b/objects/connect-object.c
index 2db0e13..8ef9a29 100644
--- a/objects/connect-object.c
+++ b/objects/connect-object.c
@@ -6,18 +6,6 @@
#include "pycore.h"
#include "pyutils.h"
-/* member IDs */
-enum
-{
- M_CONNECT_ADDRESS,
- M_CONNECT_PORT,
- M_CONNECT_CHATNET,
- M_CONNECT_PASSWORD,
- M_CONNECT_WANTED_NICK,
- M_CONNECT_USERNAME,
- M_CONNECT_REALNAME,
-};
-
static void connect_cleanup(SERVER_CONNECT_REC *connect)
{
PyConnect *pyconn = signal_get_user_data();
@@ -40,63 +28,86 @@ static void PyConnect_dealloc(PyConnect *self)
self->ob_type->tp_free((PyObject*)self);
}
-static PyObject *PyConnect_get(PyConnect *self, void *closure)
+/* Getters */
+PyDoc_STRVAR(PyConnect_address_doc,
+ "Address where we connected (irc.blah.org)"
+);
+static PyObject *PyConnect_address_get(PyConnect *self, void *closure)
{
- int member = GPOINTER_TO_INT(closure);
-
RET_NULL_IF_INVALID(self->data);
-
- switch (member)
- {
- case M_CONNECT_ADDRESS:
- RET_AS_STRING_OR_NONE(self->data->address);
- case M_CONNECT_PORT:
- return PyInt_FromLong(self->data->port);
- case M_CONNECT_CHATNET:
- RET_AS_STRING_OR_NONE(self->data->chatnet);
- case M_CONNECT_PASSWORD:
- RET_AS_STRING_OR_NONE(self->data->password);
- case M_CONNECT_WANTED_NICK:
- RET_AS_STRING_OR_NONE(self->data->nick);
- case M_CONNECT_USERNAME:
- RET_AS_STRING_OR_NONE(self->data->username);
- case M_CONNECT_REALNAME:
- RET_AS_STRING_OR_NONE(self->data->realname);
- }
-
- /* This shouldn't be reached... but... */
- return PyErr_Format(PyExc_RuntimeError, "invalid member id, %d", member);
+ RET_AS_STRING_OR_NONE(self->data->address);
}
-static PyGetSetDef PyConnect_getseters[] = {
- {"address", (getter)PyConnect_get, NULL,
- "Address where we connected (irc.blah.org)",
- GINT_TO_POINTER(M_CONNECT_ADDRESS)},
-
- {"port", (getter)PyConnect_get, NULL,
- "Port where we connected",
- GINT_TO_POINTER(M_CONNECT_PORT)},
+PyDoc_STRVAR(PyConnect_port_doc,
+ "Port where we're connected"
+);
+static PyObject *PyConnect_port_get(PyConnect *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyInt_FromLong(self->data->port);
+}
- {"chatnet", (getter)PyConnect_get, NULL,
- "Chat network",
- GINT_TO_POINTER(M_CONNECT_CHATNET)},
+PyDoc_STRVAR(PyConnect_chatnet_doc,
+ "Chat network"
+);
+static PyObject *PyConnect_chatnet_get(PyConnect *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->chatnet);
+}
- {"password", (getter)PyConnect_get, NULL,
- "Password we used in connection.",
- GINT_TO_POINTER(M_CONNECT_PASSWORD)},
+PyDoc_STRVAR(PyConnect_password_doc,
+ "Password we used in connection."
+);
+static PyObject *PyConnect_password_get(PyConnect *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->password);
+}
- {"wanted_nick", (getter)PyConnect_get, NULL,
- "Nick which we would prefer to use",
- GINT_TO_POINTER(M_CONNECT_WANTED_NICK)},
+PyDoc_STRVAR(PyConnect_wanted_nick_doc,
+ "Nick which we would prefer to use"
+);
+static PyObject *PyConnect_wanted_nick_get(PyConnect *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->nick);
+}
- {"username", (getter)PyConnect_get, NULL,
- "User name",
- GINT_TO_POINTER(M_CONNECT_USERNAME)},
+PyDoc_STRVAR(PyConnect_username_doc,
+ "User name"
+);
+static PyObject *PyConnect_username_get(PyConnect *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->username);
+}
- {"realname", (getter)PyConnect_get, NULL,
- "Real name",
- GINT_TO_POINTER(M_CONNECT_REALNAME)},
+PyDoc_STRVAR(PyConnect_realname_doc,
+ "Real name"
+);
+static PyObject *PyConnect_realname_get(PyConnect *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->realname);
+}
+/* Get/Set */
+static PyGetSetDef PyConnect_getseters[] = {
+ {"address", (getter)PyConnect_address_get, NULL,
+ PyConnect_address_doc, NULL},
+ {"port", (getter)PyConnect_port_get, NULL,
+ PyConnect_port_doc, NULL},
+ {"chatnet", (getter)PyConnect_chatnet_get, NULL,
+ PyConnect_chatnet_doc, NULL},
+ {"password", (getter)PyConnect_password_get, NULL,
+ PyConnect_password_doc, NULL},
+ {"wanted_nick", (getter)PyConnect_wanted_nick_get, NULL,
+ PyConnect_wanted_nick_doc, NULL},
+ {"username", (getter)PyConnect_username_get, NULL,
+ PyConnect_username_doc, NULL},
+ {"realname", (getter)PyConnect_realname_get, NULL,
+ PyConnect_realname_doc, NULL},
{NULL}
};
diff --git a/objects/dcc-chat-object.c b/objects/dcc-chat-object.c
index c7e25f9..5cfe796 100644
--- a/objects/dcc-chat-object.c
+++ b/objects/dcc-chat-object.c
@@ -48,7 +48,9 @@ static PyGetSetDef PyDccChat_getseters[] = {
/* Methods */
PyDoc_STRVAR(PyDccChat_chat_send_doc,
- "Send data to a dcc chat session."
+ "chat_send(data) -> None\n"
+ "\n"
+ "Send data to a dcc chat session.\n"
);
static PyObject *PyDccChat_chat_send(PyDccChat *self, PyObject *args, PyObject *kwds)
{
diff --git a/objects/dcc-object.c b/objects/dcc-object.c
index 62b5915..95a3a4a 100644
--- a/objects/dcc-object.c
+++ b/objects/dcc-object.c
@@ -185,7 +185,9 @@ static PyGetSetDef PyDcc_getseters[] = {
/* Methods */
PyDoc_STRVAR(PyDcc_destroy_doc,
- "Destroy DCC connection"
+ "destroy() -> None\n"
+ "\n"
+ "Destroy DCC connection\n"
);
static PyObject *PyDcc_destroy(PyDcc *self, PyObject *args)
{
@@ -197,7 +199,9 @@ static PyObject *PyDcc_destroy(PyDcc *self, PyObject *args)
}
PyDoc_STRVAR(PyDcc_reject_doc,
- "?"
+ "reject() -> None\n"
+ "\n"
+ "?\n"
);
static PyObject *PyDcc_reject(PyDcc *self, PyObject *args, PyObject *kwds)
{
@@ -219,7 +223,9 @@ static PyObject *PyDcc_reject(PyDcc *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(PyDcc_close_doc,
- "Close and destroy DCC connection"
+ "close() -> None\n"
+ "\n"
+ "Close and destroy DCC connection.\n"
);
static PyObject *PyDcc_close(PyDcc *self, PyObject *args)
{
@@ -295,18 +301,24 @@ PyObject *pydcc_sub_new(void *dcc, const char *name, PyTypeObject *subclass)
if (!server)
return NULL;
- //XXX: do dcc chat
-
+ chat = py_irssi_chat_new(rec->chat, 1);
+ if (!chat)
+ {
+ Py_DECREF(server);
+ return NULL;
+ }
+
pydcc = py_instp(PyDcc, subclass);
if (!pydcc)
{
- Py_XDECREF(server);
- Py_XDECREF(chat);
+ Py_DECREF(server);
+ Py_DECREF(chat);
return NULL;
}
pydcc->data = dcc;
pydcc->server = server;
+ pydcc->chat = chat;
pydcc->base_name = name;
pydcc->cleanup_installed = 1;
diff --git a/objects/factory.c b/objects/factory.c
index 25ac611..49336e6 100644
--- a/objects/factory.c
+++ b/objects/factory.c
@@ -124,6 +124,9 @@ static int init_objects(void)
if (!statusbar_item_object_init())
return 0;
+
+ if (!main_window_object_init())
+ return 0;
return 1;
}
diff --git a/objects/factory.h b/objects/factory.h
index 28b1e03..9d4bd79 100644
--- a/objects/factory.h
+++ b/objects/factory.h
@@ -34,6 +34,7 @@
#include "command-object.h"
#include "theme-object.h"
#include "statusbar-item-object.h"
+#include "main-window-object.h"
int factory_init(void);
void factory_deinit(void);
diff --git a/objects/ignore-object.c b/objects/ignore-object.c
index 7c6073c..979c9b1 100644
--- a/objects/ignore-object.c
+++ b/objects/ignore-object.c
@@ -131,8 +131,11 @@ static PyGetSetDef PyIgnore_getseters[] = {
{NULL}
};
+/* Methods */
PyDoc_STRVAR(PyIgnore_channels_doc,
- "Ignore only in channels (list of names)"
+ "channels() -> list of str\n"
+ "\n"
+ "Ignore only in channels (list of names)\n"
);
static PyObject *PyIgnore_channels(PyIgnore *self, PyObject *args)
{
@@ -148,26 +151,30 @@ static PyObject *PyIgnore_channels(PyIgnore *self, PyObject *args)
for (p = self->data->channels; *p; p++)
{
int ret;
- PyObject *str = PyString_FromString(*p);
-
+ PyObject *str;
+
+ str = PyString_FromString(*p);
if (!str)
- goto error;
+ {
+ Py_XDECREF(list);
+ return NULL;
+ }
ret = PyList_Append(list, str);
Py_DECREF(str);
if (ret != 0)
- goto error;
+ {
+ Py_XDECREF(list);
+ return NULL;
+ }
}
return list;
-
-error:
- Py_XDECREF(list);
- return NULL;
}
-/* Methods */
PyDoc_STRVAR(PyIgnore_add_rec_doc,
+ "add_rec() -> None\n"
+ "\n"
"Add ignore record"
);
static PyObject *PyIgnore_add_rec(PyIgnore *self, PyObject *args)
@@ -180,6 +187,8 @@ static PyObject *PyIgnore_add_rec(PyIgnore *self, PyObject *args)
}
PyDoc_STRVAR(PyIgnore_update_rec_doc,
+ "update_rec() -> None\n"
+ "\n"
"Update ignore record in configuration"
);
static PyObject *PyIgnore_update_rec(PyIgnore *self, PyObject *args)
diff --git a/objects/irc-channel-object.c b/objects/irc-channel-object.c
index daf3329..5e9531d 100644
--- a/objects/irc-channel-object.c
+++ b/objects/irc-channel-object.c
@@ -12,16 +12,23 @@ static PyGetSetDef PyIrcChannel_getseters[] = {
{NULL}
};
+/* Methods */
PyDoc_STRVAR(bans_doc,
- "Returns a list of bans in the channel."
+ "bans() -> list of Ban objects\n"
+ "\n"
+ "Returns a list of bans in the channel.\n"
);
static PyObject *PyIrcChannel_bans(PyIrcChannel *self, PyObject *args)
{
+ RET_NULL_IF_INVALID(self->data);
+
return py_irssi_objlist_new(self->data->banlist, 1, (InitFunc)pyban_new);
}
PyDoc_STRVAR(ban_get_mask_doc,
- "Get ban mask for 'nick'."
+ "ban_get_mask(nick, ban_type=0) -> str\n"
+ "\n"
+ "Get ban mask for 'nick'.\n"
);
static PyObject *PyIrcChannel_ban_get_mask(PyIrcChannel *self, PyObject *args, PyObject *kwds)
{
@@ -46,6 +53,8 @@ static PyObject *PyIrcChannel_ban_get_mask(PyIrcChannel *self, PyObject *args, P
}
PyDoc_STRVAR(banlist_add_doc,
+ "banlist_add(ban, nick, time) -> Ban object or None\n"
+ "\n"
"Add a new ban to channel. Return None if duplicate."
);
static PyObject *PyIrcChannel_banlist_add(PyIrcChannel *self, PyObject *args, PyObject *kwds)
@@ -69,7 +78,9 @@ static PyObject *PyIrcChannel_banlist_add(PyIrcChannel *self, PyObject *args, Py
}
PyDoc_STRVAR(banlist_remove_doc,
- "Remove a new ban from channel."
+ "banlist_remove(ban, nick) -> None\n"
+ "\n"
+ "Remove a new ban from channel.\n"
);
static PyObject *PyIrcChannel_banlist_remove(PyIrcChannel *self, PyObject *args, PyObject *kwds)
{
@@ -89,16 +100,12 @@ static PyObject *PyIrcChannel_banlist_remove(PyIrcChannel *self, PyObject *args,
static PyMethodDef PyIrcChannel_methods[] = {
{"bans", (PyCFunction)PyIrcChannel_bans, METH_NOARGS,
bans_doc},
-
{"ban_get_mask", (PyCFunction)PyIrcChannel_ban_get_mask, METH_VARARGS | METH_KEYWORDS,
ban_get_mask_doc},
-
{"banlist_add", (PyCFunction)PyIrcChannel_banlist_add, METH_VARARGS | METH_KEYWORDS,
banlist_add_doc},
-
{"banlist_remove", (PyCFunction)PyIrcChannel_banlist_remove, METH_VARARGS | METH_KEYWORDS,
banlist_remove_doc},
-
{NULL} /* Sentinel */
};
diff --git a/objects/irc-connect-object.c b/objects/irc-connect-object.c
index 6e2d3a7..5068dea 100644
--- a/objects/irc-connect-object.c
+++ b/objects/irc-connect-object.c
@@ -6,35 +6,22 @@
#include "pycore.h"
#include "pyutils.h"
-/* member IDs */
-enum
-{
- M_IRC_CONNECT_ALTERNATE_NICK,
-};
-
/* cleanup and deallocation handled by Connect base */
-static PyObject *PyIrcConnect_get(PyIrcConnect *self, void *closure)
+/* Getters */
+PyDoc_STRVAR(PyIrcConnect_alternate_nick_doc,
+ "Alternate nick to use if default nick is taken"
+);
+static PyObject *PyIrcConnect_alternate_nick_get(PyIrcConnect *self, void *closure)
{
- int member = GPOINTER_TO_INT(closure);
-
RET_NULL_IF_INVALID(self->data);
-
- switch (member)
- {
- case M_IRC_CONNECT_ALTERNATE_NICK:
- RET_AS_STRING_OR_NONE(self->data->alternate_nick);
- }
-
- /* This shouldn't be reached... but... */
- return PyErr_Format(PyExc_RuntimeError, "invalid member id, %d", member);
+ RET_AS_STRING_OR_NONE(self->data->alternate_nick);
}
+/* Get/Set */
static PyGetSetDef PyIrcConnect_getseters[] = {
- {"alternate_nick", (getter)PyIrcConnect_get, NULL,
- "Alternate nick to use if default nick is taken",
- GINT_TO_POINTER(M_IRC_CONNECT_ALTERNATE_NICK)},
-
+ {"alternate_nick", (getter)PyIrcConnect_alternate_nick_get, NULL,
+ PyIrcConnect_alternate_nick_doc, NULL},
{NULL}
};
diff --git a/objects/irc-server-object.c b/objects/irc-server-object.c
index c162dfa..a8d9845 100644
--- a/objects/irc-server-object.c
+++ b/objects/irc-server-object.c
@@ -49,6 +49,8 @@ static PyGetSetDef PyIrcServer_getseters[] = {
/* Methods */
PyDoc_STRVAR(get_channels_doc,
+ "get_channels() -> str\n"
+ "\n"
"Return a string of all channels (and keys, if any have them) in server,\n"
"like '#a,#b,#c,#d x,b_chan_key,x,x' or just '#e,#f,#g'\n"
);
@@ -67,6 +69,8 @@ static PyObject *PyIrcServer_get_channels(PyIrcServer *self, PyObject *args)
}
PyDoc_STRVAR(send_raw_doc,
+ "send_raw(cmd) -> None\n"
+ "\n"
"Send raw message to server, it will be flood protected so you\n"
"don't need to worry about it.\n"
);
@@ -86,6 +90,8 @@ static PyObject *PyIrcServer_send_raw(PyIrcServer *self, PyObject *args, PyObjec
}
PyDoc_STRVAR(send_raw_now_doc,
+ "send_raw_now(cmd) -> None\n"
+ "\n"
"Send raw message to server immediately without flood protection.\n"
);
static PyObject *PyIrcServer_send_raw_now(PyIrcServer *self, PyObject *args, PyObject *kwds)
@@ -104,6 +110,8 @@ static PyObject *PyIrcServer_send_raw_now(PyIrcServer *self, PyObject *args, PyO
}
PyDoc_STRVAR(send_raw_split_doc,
+ "send_raw_split(cmd, nickarg, max_nicks) -> None\n"
+ "\n"
"Split the `cmd' into several commands so `nickarg' argument has only\n"
"`max_nicks' number of nicks.\n"
"\n"
@@ -131,6 +139,8 @@ static PyObject *PyIrcServer_send_raw_split(PyIrcServer *self, PyObject *args, P
}
PyDoc_STRVAR(ctcp_send_reply_doc,
+ "ctcp_send_reply(data) -> None\n"
+ "\n"
"Send CTCP reply. This will be 'CTCP flood protected' so if there's too\n"
"many CTCP requests in buffer, this reply might not get sent. The data\n"
"is the full raw command to be sent to server, like\n"
@@ -152,6 +162,8 @@ static PyObject *PyIrcServer_ctcp_send_reply(PyIrcServer *self, PyObject *args,
}
PyDoc_STRVAR(isupport_doc,
+ "isupport(name) -> str or None\n"
+ "\n"
"Returns the value of the named item in the ISUPPORT (005) numeric to the\n"
"script. If the item is not present returns undef, if the item has no value\n"
"then '' is returned use defined server.isupport('name') if you need to\n"
@@ -176,6 +188,8 @@ static PyObject *PyIrcServer_isupport(PyIrcServer *self, PyObject *args, PyObjec
}
PyDoc_STRVAR(PyIrcServer_netsplit_find_doc,
+ "netsplit_find(nick, address) -> Netsplit object or None\n"
+ "\n"
"Check if nick!address is on the other side of netsplit. Netsplit records\n"
"are automatically removed after 30 minutes (current default)..\n"
);
@@ -200,7 +214,9 @@ static PyObject *PyIrcServer_netsplit_find(PyIrcServer *self, PyObject *args, Py
}
PyDoc_STRVAR(PyIrcServer_netsplit_find_channel_doc,
- "Find nick record for nick!address in channel `channel'."
+ "netsplit_find_channel(nick, address, channel) -> NetsplitChannel object or None\n"
+ "\n"
+ "Find nick record for nick!address in channel `channel'.\n"
);
static PyObject *PyIrcServer_netsplit_find_channel(PyIrcServer *self, PyObject *args, PyObject *kwds)
{
@@ -224,7 +240,9 @@ static PyObject *PyIrcServer_netsplit_find_channel(PyIrcServer *self, PyObject *
}
PyDoc_STRVAR(PyIrcServer_notifylist_ison_doc,
- "Check if nick is on server"
+ "notifylist_ison(nick) -> bool\n"
+ "\n"
+ "Check if nick is on server\n"
);
static PyObject *PyIrcServer_notifylist_ison(PyIrcServer *self, PyObject *args, PyObject *kwds)
{
@@ -240,6 +258,147 @@ static PyObject *PyIrcServer_notifylist_ison(PyIrcServer *self, PyObject *args,
return PyBool_FromLong(notifylist_ison_server(self->data, nick));
}
+/* expect a list of tuples [('str', 'str'), ...] */
+static GSList *py_event_conv(PyObject *list)
+{
+ int i;
+ GSList *ret = NULL;
+
+ if (!PyList_Check(list))
+ {
+ PyErr_Format(PyExc_TypeError, "expect a list of tuples of two strings");
+ return NULL;
+ }
+
+ for (i = 0; i < PyList_Size(list); i++)
+ {
+ char *key;
+ char *val;
+ PyObject *tup = PyList_GET_ITEM(list, i);
+
+ if (!PyTuple_Check(tup) || !PyArg_ParseTuple(tup, "ss", &key, &val))
+ {
+ GSList *node;
+
+ for (node = ret; node; node = node->next)
+ g_free(node->data);
+
+ if (!PyErr_Occurred() || PyErr_ExceptionMatches(PyExc_TypeError))
+ {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError, "expect a list of tuples of two strings");
+ }
+
+ return NULL;
+ }
+
+ ret = g_slist_append(ret, g_strdup(key));
+ ret = g_slist_append(ret, g_strdup(val));
+ }
+
+ return ret;
+}
+
+PyDoc_STRVAR(PyIrcServer_redirect_event_doc,
+ "redirect_event(command, signals, arg=None, count=1, remote=-1, failure_signal=None) -> None\n"
+ "\n"
+ "Specify that the next command sent to server will be redirected.\n"
+ "NOTE: This command MUST be called before sending the command to server.\n"
+ "\n"
+ "`command' - Name of the registered redirection that we're using.\n"
+ "\n"
+ "`count' - How many times to execute the redirection. Some commands may\n"
+ "send multiple stop events, like MODE #a,#b.\n"
+ "\n"
+ "`arg' - The argument to be compared in event strings. You can give multiple\n"
+ "arguments separated with space.\n"
+ "\n"
+ "`remote' - Specifies if the command is a remote command, -1 = use default.\n"
+ "\n"
+ "`failure_signal' - If irssi can't find the stop signal for the redirection,\n"
+ "this signal is called.\n"
+ "\n"
+ "`signals' - hash reference with \"event\" => \"redir signal\" entries.\n"
+ "If the event is "", all the events belonging to the redirection but not\n"
+ "specified here, will be sent there.\n"
+ "\n"
+ "Example:\n"
+ "\n"
+ "# ignore all events generated by whois query, except 311.\n"
+ "\n"
+ "server.redirect_event(\"whois\",\n"
+ " remote = 0,\n"
+ " arg = \"cras\",\n"
+ " signals = [\n"
+ " ('event 311', 'redir whois'),\n"
+ " ('', 'event empty') \n"
+ " ]\n"
+ ")\n"
+ "server.send_raw(\"WHOIS :cras\")\n"
+);
+static PyObject *PyIrcServer_redirect_event(PyIrcServer *self, PyObject *args, PyObject *kwds)
+{
+ static char *kwlist[] = {"command", "signals", "arg", "count", "remote", "failure_signal", NULL};
+ char *command = "";
+ int count = 1;
+ char *arg = NULL;
+ int remote = -1;
+ char *failure_signal = NULL;
+ PyObject *signals = NULL;
+ GSList *gsignals;
+
+ RET_NULL_IF_INVALID(self->data);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO|ziiz", kwlist,
+ &command, &signals, &arg, &count, &remote, &failure_signal))
+ return NULL;
+
+ gsignals = py_event_conv(signals);
+ if (!gsignals)
+ return NULL;
+
+ server_redirect_event(self->data, command, count, arg, remote, failure_signal, gsignals);
+
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(PyIrcServer_redirect_get_signal_doc,
+ "redirect_get_signal(event, args) -> str\n"
+);
+static PyObject *PyIrcServer_redirect_get_signal(PyIrcServer *self, PyObject *args, PyObject *kwds)
+{
+ static char *kwlist[] = {"event", "args", NULL};
+ char *event = "";
+ char *pargs = "";
+
+ RET_NULL_IF_INVALID(self->data);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss", kwlist,
+ &event, &pargs))
+ return NULL;
+
+ RET_AS_STRING_OR_NONE(server_redirect_get_signal(self->data, event, pargs));
+}
+
+PyDoc_STRVAR(PyIrcServer_redirect_peek_signal_doc,
+ "redirect_peek_signal(event, args) -> str\n"
+);
+static PyObject *PyIrcServer_redirect_peek_signal(PyIrcServer *self, PyObject *args, PyObject *kwds)
+{
+ static char *kwlist[] = {"event", "args", NULL};
+ char *event = "";
+ char *pargs = "";
+ int redirection;
+
+ RET_NULL_IF_INVALID(self->data);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss", kwlist,
+ &event, &pargs))
+ return NULL;
+
+ RET_AS_STRING_OR_NONE(server_redirect_peek_signal(self->data, event, pargs, &redirection));
+}
+
/* Methods for object */
static PyMethodDef PyIrcServer_methods[] = {
{"get_channels", (PyCFunction)PyIrcServer_get_channels, METH_NOARGS,
@@ -260,6 +419,12 @@ static PyMethodDef PyIrcServer_methods[] = {
PyIrcServer_netsplit_find_channel_doc},
{"notifylist_ison", (PyCFunction)PyIrcServer_notifylist_ison, METH_VARARGS | METH_KEYWORDS,
PyIrcServer_notifylist_ison_doc},
+ {"redirect_event", (PyCFunction)PyIrcServer_redirect_event, METH_VARARGS | METH_KEYWORDS,
+ PyIrcServer_redirect_event_doc},
+ {"redirect_get_signal", (PyCFunction)PyIrcServer_redirect_get_signal, METH_VARARGS | METH_KEYWORDS,
+ PyIrcServer_redirect_get_signal_doc},
+ {"redirect_peek_signal", (PyCFunction)PyIrcServer_redirect_peek_signal, METH_VARARGS | METH_KEYWORDS,
+ PyIrcServer_redirect_peek_signal_doc},
{NULL} /* Sentinel */
};
diff --git a/objects/log-object.c b/objects/log-object.c
index fae9cd4..b18f826 100644
--- a/objects/log-object.c
+++ b/objects/log-object.c
@@ -200,7 +200,9 @@ static PyGetSetDef PyLog_getseters[] = {
/* Methods */
PyDoc_STRVAR(PyLog_items_doc,
- "Return a list of log items"
+ "items() -> list of Log objects\n"
+ "\n"
+ "Return a list of log items\n"
);
static PyObject *PyLog_items(PyLog *self, PyObject *args)
{
@@ -209,7 +211,9 @@ static PyObject *PyLog_items(PyLog *self, PyObject *args)
}
PyDoc_STRVAR(PyLog_update_doc,
- "Add log to list of logs / save changes to config file."
+ "update() -> None\n"
+ "\n"
+ "Add log to list of logs / save changes to config file.\n"
);
static PyObject *PyLog_update(PyLog *self, PyObject *args)
{
@@ -221,7 +225,9 @@ static PyObject *PyLog_update(PyLog *self, PyObject *args)
}
PyDoc_STRVAR(PyLog_close_doc,
- "Destroy the log file"
+ "destroy() -> None\n"
+ "\n"
+ "Destroy the log file\n"
);
static PyObject *PyLog_close(PyLog *self, PyObject *args)
{
@@ -233,7 +239,9 @@ static PyObject *PyLog_close(PyLog *self, PyObject *args)
}
PyDoc_STRVAR(PyLog_start_logging_doc,
- "Open log file and start logging."
+ "start_logging() -> None\n"
+ "\n"
+ "Open log file and start logging.\n"
);
static PyObject *PyLog_start_logging(PyLog *self, PyObject *args)
{
@@ -245,7 +253,9 @@ static PyObject *PyLog_start_logging(PyLog *self, PyObject *args)
}
PyDoc_STRVAR(PyLog_stop_logging_doc,
- "Stop and close the log file."
+ "stop_logging() -> None\n"
+ "\n"
+ "Stop and close the log file.\n"
);
static PyObject *PyLog_stop_logging(PyLog *self, PyObject *args)
{
@@ -314,7 +324,9 @@ static PyObject *PyLog_item_add(PyLog *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(PyLog_item_destroy_doc,
- "Remove log item from log."
+ "item_destroy(item) -> None\n"
+ "\n"
+ "Remove log item from log.\n"
);
static PyObject *PyLog_item_destroy(PyLog *self, PyObject *args, PyObject *kwds)
{
diff --git a/objects/main-window-object.c b/objects/main-window-object.c
new file mode 100644
index 0000000..331cef6
--- /dev/null
+++ b/objects/main-window-object.c
@@ -0,0 +1,199 @@
+#include <Python.h>
+#include "pyirssi.h"
+#include "pymodule.h"
+#include "main-window-object.h"
+#include "factory.h"
+#include "pycore.h"
+
+#define MW(data) ((MAIN_WINDOW_REC *) data)
+
+/* monitor "mainwindow destroyed" signal */
+static void main_window_cleanup(MAIN_WINDOW_REC *mw)
+{
+ PyMainWindow *pymw = signal_get_user_data();
+
+ if (mw == pymw->data)
+ {
+ pymw->data = NULL;
+ pymw->cleanup_installed = 0;
+ signal_remove_data("mainwindow destroyed", main_window_cleanup, pymw);
+ }
+}
+
+static void PyMainWindow_dealloc(PyMainWindow *self)
+{
+ if (self->cleanup_installed)
+ signal_remove_data("mainwindow destroyed", main_window_cleanup, self);
+
+ Py_XDECREF(self->active);
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject *PyMainWindow_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PyMainWindow *self;
+
+ self = (PyMainWindow *)type->tp_alloc(type, 0);
+ if (!self)
+ return NULL;
+
+ return (PyObject *)self;
+}
+
+/* getters */
+PyDoc_STRVAR(PyMainWindow_active_doc,
+ "active window object"
+);
+static PyObject *PyMainWindow_active_get(PyMainWindow *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_OBJ_OR_NONE(self->active);
+}
+
+PyDoc_STRVAR(PyMainWindow_first_line_doc,
+ "first line used by this window (0..x) (includes statusbars)"
+);
+static PyObject *PyMainWindow_first_line_get(PyMainWindow *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyInt_FromLong(MW(self->data)->first_line);
+}
+
+PyDoc_STRVAR(PyMainWindow_last_line_doc,
+ "last line used by this window (0..x) (includes statusbars)"
+);
+static PyObject *PyMainWindow_last_line_get(PyMainWindow *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyInt_FromLong(MW(self->data)->last_line);
+}
+
+PyDoc_STRVAR(PyMainWindow_width_doc,
+ "width of the window (includes statusbars)"
+);
+static PyObject *PyMainWindow_width_get(PyMainWindow *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyInt_FromLong(MW(self->data)->width);
+}
+
+PyDoc_STRVAR(PyMainWindow_height_doc,
+ "height of the window (includes statusbars)"
+);
+static PyObject *PyMainWindow_height_get(PyMainWindow *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyInt_FromLong(MW(self->data)->height);
+}
+
+PyDoc_STRVAR(PyMainWindow_statusbar_lines_doc,
+ "???"
+);
+static PyObject *PyMainWindow_statusbar_lines_get(PyMainWindow *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyInt_FromLong(MW(self->data)->statusbar_lines);
+}
+
+/* specialized getters/setters */
+static PyGetSetDef PyMainWindow_getseters[] = {
+ {"active", (getter)PyMainWindow_active_get, NULL,
+ PyMainWindow_active_doc, NULL},
+ {"first_line", (getter)PyMainWindow_first_line_get, NULL,
+ PyMainWindow_first_line_doc, NULL},
+ {"last_line", (getter)PyMainWindow_last_line_get, NULL,
+ PyMainWindow_last_line_doc, NULL},
+ {"width", (getter)PyMainWindow_width_get, NULL,
+ PyMainWindow_width_doc, NULL},
+ {"height", (getter)PyMainWindow_height_get, NULL,
+ PyMainWindow_height_doc, NULL},
+ {"statusbar_lines", (getter)PyMainWindow_statusbar_lines_get, NULL,
+ PyMainWindow_statusbar_lines_doc, NULL},
+ {NULL}
+};
+
+/* Methods for object */
+static PyMethodDef PyMainWindow_methods[] = {
+ {NULL} /* Sentinel */
+};
+
+PyTypeObject PyMainWindowType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "MainWindow", /*tp_name*/
+ sizeof(PyMainWindow), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)PyMainWindow_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "PyMainWindow objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ PyMainWindow_methods, /* tp_methods */
+ 0, /* tp_members */
+ PyMainWindow_getseters, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ PyMainWindow_new, /* tp_new */
+};
+
+
+/* main window wrapper factory function */
+PyObject *pymain_window_new(MAIN_WINDOW_REC *mw)
+{
+ PyObject *pyactive = NULL;
+ PyMainWindow *pymw;
+
+ pyactive = pywindow_new(mw->active);
+ if (!pyactive)
+ return NULL;
+
+ pymw = py_inst(PyMainWindow, PyMainWindowType);
+ if (!pymw)
+ {
+ Py_XDECREF(pyactive);
+ return NULL;
+ }
+
+ pymw->active = pyactive;
+ pymw->data = mw;
+ pymw->cleanup_installed = 1;
+ signal_add_last_data("mainwindow destroyed", main_window_cleanup, pymw);
+
+ return (PyObject *)pymw;
+}
+
+int main_window_object_init(void)
+{
+ g_return_val_if_fail(py_module != NULL, 0);
+
+ if (PyType_Ready(&PyMainWindowType) < 0)
+ return 0;
+
+ Py_INCREF(&PyMainWindowType);
+ PyModule_AddObject(py_module, "MainWindow", (PyObject *)&PyMainWindowType);
+
+ return 1;
+}
diff --git a/objects/main-window-object.h b/objects/main-window-object.h
new file mode 100644
index 0000000..fbbdac0
--- /dev/null
+++ b/objects/main-window-object.h
@@ -0,0 +1,20 @@
+#ifndef _MAIN_WINDOW_OBJECT_H_
+#define _MAIN_WINDOW_OBJECT_H_
+
+#include <Python.h>
+#include "base-objects.h"
+#include "pyirssi.h"
+
+typedef struct
+{
+ PyIrssiFinal_HEAD(void)
+ PyObject *active;
+} PyMainWindow;
+
+extern PyTypeObject PyMainWindowType;
+
+int main_window_object_init(void);
+PyObject *pymain_window_new(MAIN_WINDOW_REC *mw);
+#define pymain_window_check(op) PyObject_TypeCheck(op, &PyMainWindowType)
+
+#endif
diff --git a/objects/netsplit-object.c b/objects/netsplit-object.c
index 4864aba..d64bd97 100644
--- a/objects/netsplit-object.c
+++ b/objects/netsplit-object.c
@@ -91,7 +91,9 @@ static PyGetSetDef PyNetsplit_getseters[] = {
/* Methods */
PyDoc_STRVAR(PyNetsplit_channels_doc,
- "Return list of NetsplitChannel objects"
+ "channels() -> list of NetsplitChannel objects\n"
+ "\n"
+ "Return list of NetsplitChannel objects\n"
);
static PyObject *PyNetsplit_channels(PyNetsplit *self, PyObject *args)
{
diff --git a/objects/nick-object.c b/objects/nick-object.c
index 7ad4a65..79f3a85 100644
--- a/objects/nick-object.c
+++ b/objects/nick-object.c
@@ -6,22 +6,6 @@
#include "pycore.h"
#include "pyutils.h"
-/* member IDs */
-enum
-{
- M_NICK_NICK,
- M_NICK_HOST,
- M_NICK_REALNAME,
- M_NICK_HOPS,
- M_NICK_GONE,
- M_NICK_SERVEROP,
- M_NICK_OP,
- M_NICK_VOICE,
- M_NICK_HALFOP,
- M_NICK_LAST_CHECK,
- M_NICK_SEND_MASSJOIN,
-};
-
static void nick_cleanup(CHANNEL_REC *chan, NICK_REC *nick)
{
PyNick *pynick = signal_get_user_data();
@@ -42,39 +26,7 @@ static void PyNick_dealloc(PyNick *self)
self->ob_type->tp_free((PyObject*)self);
}
-static PyObject *PyNick_get(PyNick *self, void *closure)
-{
- int member = GPOINTER_TO_INT(closure);
-
- RET_NULL_IF_INVALID(self->data);
-
- switch (member)
- {
- case M_NICK_NICK:
- RET_AS_STRING_OR_NONE(self->data->nick);
- case M_NICK_HOST:
- RET_AS_STRING_OR_NONE(self->data->host);
- case M_NICK_REALNAME:
- RET_AS_STRING_OR_NONE(self->data->realname);
- case M_NICK_HOPS:
- return PyInt_FromLong(self->data->hops);
- case M_NICK_GONE:
- return PyBool_FromLong(self->data->gone);
- case M_NICK_SERVEROP:
- return PyBool_FromLong(self->data->serverop);
- case M_NICK_OP:
- return PyBool_FromLong(self->data->op);
- case M_NICK_VOICE:
- return PyBool_FromLong(self->data->voice);
- case M_NICK_HALFOP:
- return PyBool_FromLong(self->data->halfop);
- case M_NICK_LAST_CHECK:
- return PyLong_FromUnsignedLong(self->data->last_check);
- }
-
- INVALID_MEMBER(member);
-}
-
+/* Getters */
PyDoc_STRVAR(PyNick_send_massjoin_doc,
"Waiting to be sent in a 'massjoin' signal, True or False"
);
@@ -84,51 +36,120 @@ static PyObject *PyNick_send_massjoin_get(PyNick *self, void *closure)
return PyBool_FromLong(self->data->send_massjoin);
}
+PyDoc_STRVAR(PyNick_nick_doc,
+ "Plain nick"
+);
+static PyObject *PyNick_nick_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->nick);
+}
+PyDoc_STRVAR(PyNick_host_doc,
+ "Host address"
+);
+static PyObject *PyNick_host_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->host);
+}
-/* specialized getters/setters */
-static PyGetSetDef PyNick_getseters[] = {
- {"nick", (getter)PyNick_get, NULL,
- "Plain nick",
- GINT_TO_POINTER(M_NICK_NICK)},
-
- {"host", (getter)PyNick_get, NULL,
- "Host address",
- GINT_TO_POINTER(M_NICK_HOST)},
+PyDoc_STRVAR(PyNick_realname_doc,
+ "Real name"
+);
+static PyObject *PyNick_realname_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->realname);
+}
- {"realname", (getter)PyNick_get, NULL,
- "Real name",
- GINT_TO_POINTER(M_NICK_REALNAME)},
+PyDoc_STRVAR(PyNick_hops_doc,
+ "Hop count to the server the nick is using"
+);
+static PyObject *PyNick_hops_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyInt_FromLong(self->data->hops);
+}
- {"hops", (getter)PyNick_get, NULL,
- "Hop count to the server the nick is using",
- GINT_TO_POINTER(M_NICK_HOPS)},
+PyDoc_STRVAR(PyNick_gone_doc,
+ "User status"
+);
+static PyObject *PyNick_gone_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->gone);
+}
- {"gone", (getter)PyNick_get, NULL,
- "User status",
- GINT_TO_POINTER(M_NICK_GONE)},
+PyDoc_STRVAR(PyNick_serverop_doc,
+ "User status"
+);
+static PyObject *PyNick_serverop_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->serverop);
+}
- {"serverop", (getter)PyNick_get, NULL,
- "User status",
- GINT_TO_POINTER(M_NICK_SERVEROP)},
+PyDoc_STRVAR(PyNick_op_doc,
+ "User status"
+);
+static PyObject *PyNick_op_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->op);
+}
- {"op", (getter)PyNick_get, NULL,
- "User status",
- GINT_TO_POINTER(M_NICK_OP)},
+PyDoc_STRVAR(PyNick_voice_doc,
+ "User status"
+);
+static PyObject *PyNick_voice_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->voice);
+}
- {"voice", (getter)PyNick_get, NULL,
- "Channel status",
- GINT_TO_POINTER(M_NICK_VOICE)},
+PyDoc_STRVAR(PyNick_halfop_doc,
+ "User status"
+);
+static PyObject *PyNick_halfop_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->halfop);
+}
- {"halfop", (getter)PyNick_get, NULL,
- "Channel status",
- GINT_TO_POINTER(M_NICK_HALFOP)},
+PyDoc_STRVAR(PyNick_last_check_doc,
+ "timestamp when last checked gone/ircop status."
+);
+static PyObject *PyNick_last_check_get(PyNick *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyLong_FromUnsignedLong(self->data->last_check);
+}
- {"last_check", (getter)PyNick_get, NULL,
- "timestamp when last checked gone/ircop status.",
- GINT_TO_POINTER(M_NICK_LAST_CHECK)},
+/* specialized getters/setters */
+static PyGetSetDef PyNick_getseters[] = {
{"send_massjoin", (getter)PyNick_send_massjoin_get, NULL,
PyNick_send_massjoin_doc, NULL},
+ {"nick", (getter)PyNick_nick_get, NULL,
+ PyNick_nick_doc, NULL},
+ {"host", (getter)PyNick_host_get, NULL,
+ PyNick_host_doc, NULL},
+ {"realname", (getter)PyNick_realname_get, NULL,
+ PyNick_realname_doc, NULL},
+ {"hops", (getter)PyNick_hops_get, NULL,
+ PyNick_hops_doc, NULL},
+ {"gone", (getter)PyNick_gone_get, NULL,
+ PyNick_gone_doc, NULL},
+ {"serverop", (getter)PyNick_serverop_get, NULL,
+ PyNick_serverop_doc, NULL},
+ {"op", (getter)PyNick_op_get, NULL,
+ PyNick_op_doc, NULL},
+ {"voice", (getter)PyNick_voice_get, NULL,
+ PyNick_voice_doc, NULL},
+ {"halfop", (getter)PyNick_halfop_get, NULL,
+ PyNick_halfop_doc, NULL},
+ {"last_check", (getter)PyNick_last_check_get, NULL,
+ PyNick_last_check_doc, NULL},
{NULL}
};
diff --git a/objects/notifylist-object.c b/objects/notifylist-object.c
index 890c256..3366d0f 100644
--- a/objects/notifylist-object.c
+++ b/objects/notifylist-object.c
@@ -79,7 +79,9 @@ static PyGetSetDef PyNotifylist_getseters[] = {
/* Methods */
PyDoc_STRVAR(PyNotifylist_ircnets_doc,
- "Return list of ircnets the notify is checked"
+ "ircnets() -> list of str\n"
+ "\n"
+ "Return list of ircnets the notify is checked\n"
);
static PyObject *PyNotifylist_ircnets(PyNotifylist *self, PyObject *args)
{
@@ -119,7 +121,9 @@ static PyObject *PyNotifylist_ircnets(PyNotifylist *self, PyObject *args)
}
PyDoc_STRVAR(PyNotifylist_ircnets_match_doc,
- "Return True if notify is checked in ircnet"
+ "ircnets_match(ircnet) -> bool\n"
+ "\n"
+ "Return True if notify is checked in ircnet\n"
);
static PyObject *PyNotifylist_ircnets_match(PyNotifylist *self, PyObject *args, PyObject *kwds)
{
diff --git a/objects/pyscript-object.c b/objects/pyscript-object.c
index d2750bf..ae4770e 100644
--- a/objects/pyscript-object.c
+++ b/objects/pyscript-object.c
@@ -380,7 +380,7 @@ static int py_settings_remove(PyScript *self, const char *name)
}
PyDoc_STRVAR(PyScript_settings_add_str_doc,
- ""
+ "settings_add_str(section, key, def) -> None\n"
);
static PyObject *PyScript_settings_add_str(PyScript *self, PyObject *args, PyObject *kwds)
{
@@ -402,7 +402,7 @@ static PyObject *PyScript_settings_add_str(PyScript *self, PyObject *args, PyObj
}
PyDoc_STRVAR(PyScript_settings_add_int_doc,
- ""
+ "settings_add_int(section, key, def) -> None\n"
);
static PyObject *PyScript_settings_add_int(PyScript *self, PyObject *args, PyObject *kwds)
{
@@ -424,7 +424,7 @@ static PyObject *PyScript_settings_add_int(PyScript *self, PyObject *args, PyObj
}
PyDoc_STRVAR(PyScript_settings_add_bool_doc,
- ""
+ "settings_add_bool(section, key, def) -> None\n"
);
static PyObject *PyScript_settings_add_bool(PyScript *self, PyObject *args, PyObject *kwds)
{
@@ -446,7 +446,7 @@ static PyObject *PyScript_settings_add_bool(PyScript *self, PyObject *args, PyOb
}
PyDoc_STRVAR(PyScript_settings_add_time_doc,
- ""
+ "settings_add_time(section, key, def) -> None\n"
);
static PyObject *PyScript_settings_add_time(PyScript *self, PyObject *args, PyObject *kwds)
{
@@ -468,7 +468,7 @@ static PyObject *PyScript_settings_add_time(PyScript *self, PyObject *args, PyOb
}
PyDoc_STRVAR(PyScript_settings_add_level_doc,
- ""
+ "settings_add_level(section, key, def) -> None\n"
);
static PyObject *PyScript_settings_add_level(PyScript *self, PyObject *args, PyObject *kwds)
{
@@ -490,7 +490,7 @@ static PyObject *PyScript_settings_add_level(PyScript *self, PyObject *args, PyO
}
PyDoc_STRVAR(PyScript_settings_add_size_doc,
- ""
+ "settings_add_size(section, key, def) -> None\n"
);
static PyObject *PyScript_settings_add_size(PyScript *self, PyObject *args, PyObject *kwds)
{
diff --git a/objects/query-object.c b/objects/query-object.c
index 1370b34..47badd5 100644
--- a/objects/query-object.c
+++ b/objects/query-object.c
@@ -7,14 +7,6 @@
#include "server-object.h"
#include "pycore.h"
-/* member IDs */
-enum
-{
- M_QUERY_ADDRESS,
- M_QUERY_SERVER_TAG,
- M_QUERY_UNWANTED,
-};
-
/* monitor "query destroyed" signal */
static void query_cleanup(QUERY_REC *query)
{
@@ -36,46 +28,49 @@ static void PyQuery_dealloc(PyQuery *self)
self->ob_type->tp_free((PyObject*)self);
}
-
-static PyObject *PyQuery_get(PyQuery *self, void *closure)
+/* Getters */
+PyDoc_STRVAR(PyQuery_address_doc,
+ "Host address of the queries nick"
+);
+static PyObject *PyQuery_address_get(PyQuery *self, void *closure)
{
- int member = GPOINTER_TO_INT(closure);
-
RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->address);
+}
- switch (member)
- {
- case M_QUERY_ADDRESS:
- RET_AS_STRING_OR_NONE(self->data->address);
- case M_QUERY_SERVER_TAG:
- RET_AS_STRING_OR_NONE(self->data->server_tag);
- case M_QUERY_UNWANTED:
- return PyBool_FromLong(self->data->unwanted);
- }
+PyDoc_STRVAR(PyQuery_server_tag_doc,
+ "Server tag used for this nick (doesn't get erased if server gets disconnected)"
+);
+static PyObject *PyQuery_server_tag_get(PyQuery *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->server_tag);
+}
- /* This shouldn't be reached... but... */
- return PyErr_Format(PyExc_RuntimeError, "invalid member id, %d", member);
+PyDoc_STRVAR(PyQuery_unwanted_doc,
+ "1 if the other side closed or some error occured (DCC chats)"
+);
+static PyObject *PyQuery_unwanted_get(PyQuery *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->unwanted);
}
/* specialized getters/setters */
static PyGetSetDef PyQuery_getseters[] = {
- {"address", (getter)PyQuery_get, NULL,
- "Host address of the queries nick",
- GINT_TO_POINTER(M_QUERY_ADDRESS)},
-
- {"server_tag", (getter)PyQuery_get, NULL,
- "Server tag used for this nick (doesn't get erased if server gets disconnected)",
- GINT_TO_POINTER(M_QUERY_SERVER_TAG)},
-
- {"unwanted", (getter)PyQuery_get, NULL,
- "1 if the other side closed or some error occured (DCC chats)",
- GINT_TO_POINTER(M_QUERY_UNWANTED)},
-
+ {"address", (getter)PyQuery_address_get, NULL,
+ PyQuery_address_doc, NULL},
+ {"server_tag", (getter)PyQuery_server_tag_get, NULL,
+ PyQuery_server_tag_doc, NULL},
+ {"unwanted", (getter)PyQuery_unwanted_get, NULL,
+ PyQuery_unwanted_doc, NULL},
{NULL}
};
PyDoc_STRVAR(change_server_doc,
- "Change the active server for the query."
+ "change_server(server) -> None\n"
+ "\n"
+ "Change the active server for the query.\n"
);
static PyObject *PyQuery_change_server(PyQuery *self, PyObject *args, PyObject *kwds)
{
diff --git a/objects/rawlog-object.c b/objects/rawlog-object.c
index eed5996..340d60a 100644
--- a/objects/rawlog-object.c
+++ b/objects/rawlog-object.c
@@ -58,7 +58,9 @@ static PyGetSetDef PyRawlog_getseters[] = {
/* Methods */
PyDoc_STRVAR(PyRawlog_get_lines_doc,
- "Return a list of lines for rawlog."
+ "get_lines() -> list of str\n"
+ "\n"
+ "Return a list of lines for rawlog.\n"
);
static PyObject *PyRawlog_get_lines(PyRawlog *self, PyObject *args)
{
@@ -77,23 +79,27 @@ static PyObject *PyRawlog_get_lines(PyRawlog *self, PyObject *args)
PyObject *line = PyString_FromString(node->data);
if (!line)
- goto error;
+ {
+ Py_XDECREF(lines);
+ return NULL;
+ }
ret = PyList_Append(lines, line);
Py_DECREF(line);
if (ret != 0)
- goto error;
+ {
+ Py_XDECREF(lines);
+ return NULL;
+ }
}
return lines;
-
-error:
- Py_XDECREF(lines);
- return NULL;
}
PyDoc_STRVAR(PyRawlog_destroy_doc,
- "Destroy rawlog"
+ "destroy() -> None\n"
+ "\n"
+ "Destroy rawlog\n"
);
static PyObject *PyRawlog_destroy(PyRawlog *self, PyObject *args)
{
@@ -108,7 +114,9 @@ static PyObject *PyRawlog_destroy(PyRawlog *self, PyObject *args)
}
PyDoc_STRVAR(PyRawlog_input_doc,
- "Send str to rawlog as input text."
+ "input(str) -> None\n"
+ "\n"
+ "Send str to rawlog as input text.\n"
);
static PyObject *PyRawlog_input(PyRawlog *self, PyObject *args, PyObject *kwds)
{
@@ -127,7 +135,9 @@ static PyObject *PyRawlog_input(PyRawlog *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(PyRawlog_output_doc,
- "Send str to rawlog as output text."
+ "output(str) -> None\n"
+ "\n"
+ "Send str to rawlog as output text.\n"
);
static PyObject *PyRawlog_output(PyRawlog *self, PyObject *args, PyObject *kwds)
{
@@ -146,6 +156,8 @@ static PyObject *PyRawlog_output(PyRawlog *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(PyRawlog_redirect_doc,
+ "redirect(str) -> None\n"
+ "\n"
"Send str to rawlog as redirection text."
);
static PyObject *PyRawlog_redirect(PyRawlog *self, PyObject *args, PyObject *kwds)
@@ -165,7 +177,9 @@ static PyObject *PyRawlog_redirect(PyRawlog *self, PyObject *args, PyObject *kwd
}
PyDoc_STRVAR(PyRawlog_open_doc,
- "Start logging new messages in rawlog to specified file."
+ "open(fname) -> None\n"
+ "\n"
+ "Start logging new messages in rawlog to specified file.\n"
);
static PyObject *PyRawlog_open(PyRawlog *self, PyObject *args, PyObject *kwds)
{
@@ -184,7 +198,9 @@ static PyObject *PyRawlog_open(PyRawlog *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(PyRawlog_close_doc,
- "Stop logging to file"
+ "close() -> None\n"
+ "\n"
+ "Stop logging to file\n"
);
static PyObject *PyRawlog_close(PyRawlog *self, PyObject *args)
{
@@ -196,7 +212,9 @@ static PyObject *PyRawlog_close(PyRawlog *self, PyObject *args)
}
PyDoc_STRVAR(PyRawlog_save_doc,
- "Save the current rawlog history to specified file."
+ "save(fname) -> None\n"
+ "\n"
+ "Save the current rawlog history to specified file.\n"
);
static PyObject *PyRawlog_save(PyRawlog *self, PyObject *args, PyObject *kwds)
{
@@ -213,7 +231,6 @@ static PyObject *PyRawlog_save(PyRawlog *self, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
}
-
/* Methods for object */
static PyMethodDef PyRawlog_methods[] = {
{"get_lines", (PyCFunction)PyRawlog_get_lines, METH_NOARGS,
diff --git a/objects/reconnect-object.c b/objects/reconnect-object.c
index 4e60599..6483242 100644
--- a/objects/reconnect-object.c
+++ b/objects/reconnect-object.c
@@ -25,7 +25,6 @@ static PyObject *PyReconnect_new(PyTypeObject *type, PyObject *args, PyObject *k
}
/* Getters */
-
PyDoc_STRVAR(PyReconnect_tag_doc,
"Unique numeric tag"
);
diff --git a/objects/server-object.c b/objects/server-object.c
index c000b80..31415b8 100644
--- a/objects/server-object.c
+++ b/objects/server-object.c
@@ -206,6 +206,8 @@ static PyGetSetDef PyServer_getseters[] = {
/* Methods */
PyDoc_STRVAR(print_doc,
+ "prnt(channel, str, level) -> None\n"
+ "\n"
"Print to server\n"
);
static PyObject *PyServer_prnt(PyServer *self, PyObject *args, PyObject *kwds)
@@ -225,6 +227,8 @@ static PyObject *PyServer_prnt(PyServer *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(command_doc,
+ "command(cmd) -> None\n"
+ "\n"
"Send command\n"
);
static PyObject *PyServer_command(PyServer *self, PyObject *args, PyObject *kwds)
@@ -243,6 +247,8 @@ static PyObject *PyServer_command(PyServer *self, PyObject *args, PyObject *kwds
}
PyDoc_STRVAR(disconnect_doc,
+ "disconnect() -> None\n"
+ "\n"
"Disconnect from server\n"
);
static PyObject *PyServer_disconnect(PyServer *self, PyObject *args)
@@ -255,6 +261,8 @@ static PyObject *PyServer_disconnect(PyServer *self, PyObject *args)
}
PyDoc_STRVAR(isnickflag_doc,
+ "isnickflag(flag) -> bool\n"
+ "\n"
"Returns True if flag is a nick mode flag (@, + or % in IRC)\n"
);
static PyObject *PyServer_isnickflag(PyServer *self, PyObject *args, PyObject *kwds)
@@ -274,6 +282,8 @@ static PyObject *PyServer_isnickflag(PyServer *self, PyObject *args, PyObject *k
}
PyDoc_STRVAR(ischannel_doc,
+ "ischannel(data) -> bool\n"
+ "\n"
"Returns True if start of `data' seems to mean channel.\n"
);
static PyObject *PyServer_ischannel(PyServer *self, PyObject *args, PyObject *kwds)
@@ -293,6 +303,8 @@ static PyObject *PyServer_ischannel(PyServer *self, PyObject *args, PyObject *kw
}
PyDoc_STRVAR(get_nick_flags_doc,
+ "get_nick_flags() -> str\n"
+ "\n"
"Returns nick flag characters in order: op, voice, halfop (\"@+%\") in IRC\n"
);
static PyObject *PyServer_get_nick_flags(PyServer *self, PyObject *args)
@@ -307,6 +319,8 @@ static PyObject *PyServer_get_nick_flags(PyServer *self, PyObject *args)
}
PyDoc_STRVAR(send_message_doc,
+ "send_message(target, msg, target_type) -> None\n"
+ "\n"
"Sends a message to nick/channel. target_type 0 = channel, 1 = nick\n"
);
static PyObject *PyServer_send_message(PyServer *self, PyObject *args, PyObject *kwds)
@@ -326,7 +340,7 @@ static PyObject *PyServer_send_message(PyServer *self, PyObject *args, PyObject
}
PyDoc_STRVAR(channels_join_doc,
- " channels_join(channels, automatic=False) -> None\n"
+ "channels_join(channels, automatic=False) -> None\n"
"\n"
"Join to channels in server. `channels' may also contain keys for\n"
"channels just like with /JOIN command. `automatic' specifies if this\n"
@@ -351,7 +365,9 @@ static PyObject *PyServer_channels_join(PyServer *self, PyObject *args, PyObject
}
PyDoc_STRVAR(PyServer_window_item_find_doc,
- "Find window item that matches best to given arguments"
+ "window_item_find(name) -> WindowItem object or None\n"
+ "\n"
+ "Find window item that matches best to given arguments\n"
);
static PyObject *PyServer_window_item_find(PyServer *self, PyObject *args, PyObject *kwds)
{
@@ -368,7 +384,9 @@ static PyObject *PyServer_window_item_find(PyServer *self, PyObject *args, PyObj
}
PyDoc_STRVAR(PyServer_window_find_item_doc,
- "Find window which contains window item with specified name/server"
+ "window_find_item(name) -> Window object or None\n"
+ "\n"
+ "Find window which contains window item with specified name/server\n"
);
static PyObject *PyServer_window_find_item(PyServer *self, PyObject *args, PyObject *kwds)
{
@@ -390,7 +408,9 @@ static PyObject *PyServer_window_find_item(PyServer *self, PyObject *args, PyObj
}
PyDoc_STRVAR(PyServer_window_find_level_doc,
- "Find window with level"
+ "window_find_level(level) -> Window object or None\n"
+ "\n"
+ "Find window with level\n"
);
static PyObject *PyServer_window_find_level(PyServer *self, PyObject *args, PyObject *kwds)
{
@@ -412,6 +432,8 @@ static PyObject *PyServer_window_find_level(PyServer *self, PyObject *args, PyOb
}
PyDoc_STRVAR(PyServer_window_find_closest_doc,
+ "window_find_closest(name, level) -> Window object or None\n"
+ "\n"
"Find window that matches best to given arguments. `name' can be either\n"
"window name or name of one of the window items.\n"
);
@@ -436,7 +458,9 @@ static PyObject *PyServer_window_find_closest(PyServer *self, PyObject *args, Py
}
PyDoc_STRVAR(PyServer_channels_doc,
- "Return list of channels for server"
+ "channels() -> list of Channel objects\n"
+ "\n"
+ "Return list of channels for server\n"
);
static PyObject *PyServer_channels(PyServer *self, PyObject *args)
{
@@ -446,7 +470,9 @@ static PyObject *PyServer_channels(PyServer *self, PyObject *args)
}
PyDoc_STRVAR(PyServer_channel_find_doc,
- "Find channel from this server"
+ "channel_find(name) -> Channel object or None\n"
+ "\n"
+ "Find channel from this server\n"
);
static PyObject *PyServer_channel_find(PyServer *self, PyObject *args, PyObject *kwds)
{
@@ -463,6 +489,8 @@ static PyObject *PyServer_channel_find(PyServer *self, PyObject *args, PyObject
}
PyDoc_STRVAR(PyServer_nicks_get_same_doc,
+ "nicks_get_same(nick)\n"
+ "\n"
"Return all nick objects in all channels in server. List is in format:\n"
"[(Channel, Nick), (Channel, Nick), ...]\n"
);
@@ -493,23 +521,27 @@ static PyObject *PyServer_nicks_get_same(PyServer *self, PyObject *args, PyObjec
py_irssi_chat_new(node->data, 1),
py_irssi_chat_new(node->next->data, 1));
if (!tup)
- goto error;
+ {
+ Py_XDECREF(pylist);
+ return NULL;
+ }
ret = PyList_Append(pylist, tup);
Py_DECREF(tup);
if (ret != 0)
- goto error;
+ {
+ Py_XDECREF(pylist);
+ return NULL;
+ }
}
return pylist;
-
-error:
- Py_XDECREF(pylist);
- return NULL;
}
PyDoc_STRVAR(PyServer_queries_doc,
- "Return a list of queries for server."
+ "queries() -> list of Query objects\n"
+ "\n"
+ "Return a list of queries for server.\n"
);
static PyObject *PyServer_queries(PyServer *self, PyObject *args)
{
@@ -519,7 +551,9 @@ static PyObject *PyServer_queries(PyServer *self, PyObject *args)
}
PyDoc_STRVAR(PyServer_query_find_doc,
- "Find a query on this server."
+ "query_find(nick) -> Query object or None\n"
+ "\n"
+ "Find a query on this server.\n"
);
static PyObject *PyServer_query_find(PyServer *self, PyObject *args, PyObject *kwds)
{
@@ -536,7 +570,9 @@ static PyObject *PyServer_query_find(PyServer *self, PyObject *args, PyObject *k
}
PyDoc_STRVAR(PyServer_mask_match_doc,
- "Return true if mask matches nick!user@host"
+ "mask_match(mask, nick, user, host) -> bool\n"
+ "\n"
+ "Return true if mask matches nick!user@host\n"
);
static PyObject *PyServer_mask_match(PyServer *self, PyObject *args, PyObject *kwds)
{
@@ -556,7 +592,9 @@ static PyObject *PyServer_mask_match(PyServer *self, PyObject *args, PyObject *k
}
PyDoc_STRVAR(PyServer_mask_match_address_doc,
- "Return True if mask matches nick!address"
+ "mask_match_address(mask, nick, address) -> bool\n"
+ "\n"
+ "Return True if mask matches nick!address\n"
);
static PyObject *PyServer_mask_match_address(PyServer *self, PyObject *args, PyObject *kwds)
{
@@ -575,6 +613,8 @@ static PyObject *PyServer_mask_match_address(PyServer *self, PyObject *args, PyO
}
PyDoc_STRVAR(PyServer_masks_match_doc,
+ "masks_match(masks, nick, address) -> bool\n"
+ "\n"
"Return True if any mask in the masks (string separated by spaces)\n"
"matches nick!address\n"
);
@@ -595,7 +635,9 @@ static PyObject *PyServer_masks_match(PyServer *self, PyObject *args, PyObject *
}
PyDoc_STRVAR(PyServer_ignore_check_doc,
- "Return True if ignore matches"
+ "ignore_check(nick, host, channel, text, level) -> bool\n"
+ "\n"
+ "Return True if ignore matches\n"
);
static PyObject *PyServer_ignore_check(PyServer *self, PyObject *args, PyObject *kwds)
{
diff --git a/objects/statusbar-item-object.c b/objects/statusbar-item-object.c
index 14b0208..f6768af 100644
--- a/objects/statusbar-item-object.c
+++ b/objects/statusbar-item-object.c
@@ -82,11 +82,47 @@ static PyObject *PyStatusbarItem_window_get(PyStatusbarItem *self, void *closure
RET_AS_OBJ_OR_NONE(self->window);
}
+/* setters */
+static int py_setint(int *iv, PyObject *value)
+{
+ int tmp;
+
+ if (value == NULL)
+ {
+ PyErr_SetString(PyExc_AttributeError, "can't delete member");
+ return -1;
+ }
+
+ if (!PyInt_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "value must be int");
+ return -1;
+ }
+
+ tmp = PyInt_AsLong(value);
+ if (PyErr_Occurred())
+ return -1;
+
+ *iv = tmp;
+
+ return 0;
+}
+
+static int PyStatusbarItem_min_size_set(PyStatusbarItem *self, PyObject *value, void *closure)
+{
+ return py_setint(&self->data->min_size, value);
+}
+
+static int PyStatusbarItem_max_size_set(PyStatusbarItem *self, PyObject *value, void *closure)
+{
+ return py_setint(&self->data->max_size, value);
+}
+
/* specialized getters/setters */
static PyGetSetDef PyStatusbarItem_getseters[] = {
- {"min_size", (getter)PyStatusbarItem_min_size_get, NULL,
+ {"min_size", (getter)PyStatusbarItem_min_size_get, (setter)PyStatusbarItem_min_size_set,
PyStatusbarItem_min_size_doc, NULL},
- {"max_size", (getter)PyStatusbarItem_max_size_get, NULL,
+ {"max_size", (getter)PyStatusbarItem_max_size_get, (setter)PyStatusbarItem_max_size_set,
PyStatusbarItem_max_size_doc, NULL},
{"xpos", (getter)PyStatusbarItem_xpos_get, NULL,
PyStatusbarItem_xpos_doc, NULL},
diff --git a/objects/window-item-object.c b/objects/window-item-object.c
index 7acb075..2f18f7d 100644
--- a/objects/window-item-object.c
+++ b/objects/window-item-object.c
@@ -71,7 +71,9 @@ static PyGetSetDef PyWindowItem_getseters[] = {
/* Methods */
PyDoc_STRVAR(PyWindowItem_prnt_doc,
- "Print to window item"
+ "prnt(str, level) -> None\n"
+ "\n"
+ "Print to window item\n"
);
static PyObject *PyWindowItem_prnt(PyWindowItem *self, PyObject *args, PyObject *kwds)
{
@@ -90,7 +92,9 @@ static PyObject *PyWindowItem_prnt(PyWindowItem *self, PyObject *args, PyObject
}
PyDoc_STRVAR(PyWindowItem_command_doc,
- "Send command to window item"
+ "command(cmd) -> None\n"
+ "\n"
+ "Send command to window item\n"
);
static PyObject *PyWindowItem_command(PyWindowItem *self, PyObject *args, PyObject *kwds)
{
@@ -108,7 +112,9 @@ static PyObject *PyWindowItem_command(PyWindowItem *self, PyObject *args, PyObje
}
PyDoc_STRVAR(PyWindowItem_window_doc,
- "Return parent window for window item"
+ "window() -> Window object or None\n"
+ "\n"
+ "Return parent window for window item\n"
);
static PyObject *PyWindowItem_window(PyWindowItem *self, PyObject *args)
{
@@ -124,7 +130,9 @@ static PyObject *PyWindowItem_window(PyWindowItem *self, PyObject *args)
}
PyDoc_STRVAR(PyWindowItem_change_server_doc,
- "Change server for window item"
+ "change_server(server) -> None\n"
+ "\n"
+ "Change server for window item\n"
);
static PyObject *PyWindowItem_change_server(PyWindowItem *self, PyObject *args, PyObject *kwds)
{
@@ -146,7 +154,9 @@ static PyObject *PyWindowItem_change_server(PyWindowItem *self, PyObject *args,
}
PyDoc_STRVAR(PyWindowItem_is_active_doc,
- "Returns true if window item is active"
+ "is_active() -> bool\n"
+ "\n"
+ "Returns true if window item is active\n"
);
static PyObject *PyWindowItem_is_active(PyWindowItem *self, PyObject *args)
{
@@ -156,7 +166,9 @@ static PyObject *PyWindowItem_is_active(PyWindowItem *self, PyObject *args)
}
PyDoc_STRVAR(PyWindowItem_set_active_doc,
- "Set window item active"
+ "set_active() -> None\n"
+ "\n"
+ "Set window item active\n"
);
static PyObject *PyWindowItem_set_active(PyWindowItem *self, PyObject *args)
{
@@ -168,7 +180,8 @@ static PyObject *PyWindowItem_set_active(PyWindowItem *self, PyObject *args)
}
PyDoc_STRVAR(PyWindowItem_activity_doc,
- "Unknown/untested"
+ "activity(data_level, hilight_color) -> None\n"
+ "\n"
);
static PyObject *PyWindowItem_activity(PyWindowItem *self, PyObject *args, PyObject *kwds)
{
@@ -188,7 +201,9 @@ static PyObject *PyWindowItem_activity(PyWindowItem *self, PyObject *args, PyObj
}
PyDoc_STRVAR(PyWindowItem_destroy_doc,
- "Destroy channel or query"
+ "destroy() -> None\n"
+ "\n"
+ "Destroy channel or query\n"
);
static PyObject *PyWindowItem_destroy(PyWindowItem *self, PyObject *args)
{
@@ -200,7 +215,9 @@ static PyObject *PyWindowItem_destroy(PyWindowItem *self, PyObject *args)
}
PyDoc_STRVAR(PyWindowItem_get_dcc_doc,
- "If item is a query of a =nick, return DCC chat record of nick"
+ "get_dcc() -> DccChat object or None\n"
+ "\n"
+ "If item is a query of a =nick, return DCC chat record of nick\n"
);
static PyObject *PyWindowItem_get_dcc(PyWindowItem *self, PyObject *args)
{
diff --git a/objects/window-object.c b/objects/window-object.c
index df74766..d5aa475 100644
--- a/objects/window-object.c
+++ b/objects/window-object.c
@@ -213,7 +213,9 @@ static PyGetSetDef PyWindow_getseters[] = {
/* Methods */
PyDoc_STRVAR(PyWindow_items_doc,
- "Return a list of items in window."
+ "items() -> list of WindowItem objects\n"
+ "\n"
+ "Return a list of items in window.\n"
);
static PyObject *PyWindow_items(PyWindow *self, PyObject *args)
{
@@ -222,7 +224,9 @@ static PyObject *PyWindow_items(PyWindow *self, PyObject *args)
}
PyDoc_STRVAR(PyWindow_prnt_doc,
- "Print to window"
+ "prnt(str, level=MSGLEVEL_CLIENTNOTICE) -> None\n"
+ "\n"
+ "Print to window\n"
);
static PyObject *PyWindow_prnt(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -242,7 +246,9 @@ static PyObject *PyWindow_prnt(PyWindow *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(PyWindow_command_doc,
- "Send command to window"
+ "command(cmd) -> None\n"
+ "\n"
+ "Send command to window\n"
);
static PyObject *PyWindow_command(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -266,7 +272,7 @@ static PyObject *PyWindow_command(PyWindow *self, PyObject *args, PyObject *kwds
}
PyDoc_STRVAR(PyWindow_item_add_doc,
- " item_add(item, automatic=False) -> None\n"
+ "item_add(item, automatic=False) -> None\n"
"\n"
"Add window item\n"
);
@@ -291,7 +297,9 @@ static PyObject *PyWindow_item_add(PyWindow *self, PyObject *args, PyObject *kwd
}
PyDoc_STRVAR(PyWindow_item_remove_doc,
- "Remove window item"
+ "item_remove(item) -> None\n"
+ "\n"
+ "Remove window item\n"
);
static PyObject *PyWindow_item_remove(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -313,7 +321,9 @@ static PyObject *PyWindow_item_remove(PyWindow *self, PyObject *args, PyObject *
}
PyDoc_STRVAR(PyWindow_item_destroy_doc,
- "Destroy window item"
+ "item_destroy(item) -> None\n"
+ "\n"
+ "Destroy window item\n"
);
static PyObject *PyWindow_item_destroy(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -335,7 +345,9 @@ static PyObject *PyWindow_item_destroy(PyWindow *self, PyObject *args, PyObject
}
PyDoc_STRVAR(PyWindow_item_prev_doc,
- "Change to previous window item"
+ "item_prev() -> None\n"
+ "\n"
+ "Change to previous window item\n"
);
static PyObject *PyWindow_item_prev(PyWindow *self, PyObject *args)
{
@@ -347,7 +359,9 @@ static PyObject *PyWindow_item_prev(PyWindow *self, PyObject *args)
}
PyDoc_STRVAR(PyWindow_item_next_doc,
- "Change to next window item"
+ "item_next() -> None\n"
+ "\n"
+ "Change to next window item\n"
);
static PyObject *PyWindow_item_next(PyWindow *self, PyObject *args)
{
@@ -359,7 +373,9 @@ static PyObject *PyWindow_item_next(PyWindow *self, PyObject *args)
}
PyDoc_STRVAR(PyWindow_destroy_doc,
- "Destroy the window."
+ "destroy() -> None\n"
+ "\n"
+ "Destroy the window.\n"
);
static PyObject *PyWindow_destroy(PyWindow *self, PyObject *args)
{
@@ -371,7 +387,9 @@ static PyObject *PyWindow_destroy(PyWindow *self, PyObject *args)
}
PyDoc_STRVAR(PyWindow_set_active_doc,
- "Set window active."
+ "set_active() -> None\n"
+ "\n"
+ "Set window active.\n"
);
static PyObject *PyWindow_set_active(PyWindow *self, PyObject *args)
{
@@ -383,7 +401,9 @@ static PyObject *PyWindow_set_active(PyWindow *self, PyObject *args)
}
PyDoc_STRVAR(PyWindow_change_server_doc,
- "Change server in window"
+ "change_server(server) -> None\n"
+ "\n"
+ "Change server in window\n"
);
static PyObject *PyWindow_change_server(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -405,7 +425,9 @@ static PyObject *PyWindow_change_server(PyWindow *self, PyObject *args, PyObject
}
PyDoc_STRVAR(PyWindow_set_refnum_doc,
- "Set window refnum"
+ "set_refnum(refnum) -> None\n"
+ "\n"
+ "Set window refnum\n"
);
static PyObject *PyWindow_set_refnum(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -424,7 +446,9 @@ static PyObject *PyWindow_set_refnum(PyWindow *self, PyObject *args, PyObject *k
}
PyDoc_STRVAR(PyWindow_set_name_doc,
- "Set window name"
+ "set_name(name) -> None\n"
+ "\n"
+ "Set window name\n"
);
static PyObject *PyWindow_set_name(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -442,9 +466,10 @@ static PyObject *PyWindow_set_name(PyWindow *self, PyObject *args, PyObject *kwd
Py_RETURN_NONE;
}
-/* Methods for object */
PyDoc_STRVAR(PyWindow_set_history_doc,
- "Set window history"
+ "set_history(history) -> None\n"
+ "\n"
+ "Set window history\n"
);
static PyObject *PyWindow_set_history(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -463,7 +488,9 @@ static PyObject *PyWindow_set_history(PyWindow *self, PyObject *args, PyObject *
}
PyDoc_STRVAR(PyWindow_set_level_doc,
- "Set window level"
+ "set_level(level) -> None\n"
+ "\n"
+ "Set window level\n"
);
static PyObject *PyWindow_set_level(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -482,7 +509,8 @@ static PyObject *PyWindow_set_level(PyWindow *self, PyObject *args, PyObject *kw
}
PyDoc_STRVAR(PyWindow_activity_doc,
- "Unknown/Untested"
+ "activity(data_level, hilight_color) -> None\n"
+ "\n"
);
static PyObject *PyWindow_activity(PyWindow *self, PyObject *args, PyObject *kwds)
{
@@ -502,7 +530,9 @@ static PyObject *PyWindow_activity(PyWindow *self, PyObject *args, PyObject *kwd
}
PyDoc_STRVAR(PyWindow_get_active_name_doc,
- "Return active item's name, or if none is active, window's name."
+ "get_active_name() -> str or None\n"
+ "\n"
+ "Return active item's name, or if none is active, window's name.\n"
);
static PyObject *PyWindow_get_active_name(PyWindow *self, PyObject *args)
{
@@ -511,7 +541,9 @@ static PyObject *PyWindow_get_active_name(PyWindow *self, PyObject *args)
}
PyDoc_STRVAR(PyWindow_item_find_doc,
- "Find window item that matches best to given arguments"
+ "item_find(server, name) -> WindowItem or None\n"
+ "\n"
+ "Find window item that matches best to given arguments\n"
);
static PyObject *PyWindow_item_find(PyWindow *self, PyObject *args, PyObject *kwds)
{
diff --git a/pyirssi.h b/pyirssi.h
index ea8c79a..fda54e6 100644
--- a/pyirssi.h
+++ b/pyirssi.h
@@ -9,6 +9,7 @@
#include "settings.h"
#include "printtext.h"
#include "statusbar.h"
+#include "mainwindows.h"
#include "window-items.h"
#include "window-activity.h"
#include "levels.h"
diff --git a/pyirssi_irc.h b/pyirssi_irc.h
index b157eff..1d654ba 100644
--- a/pyirssi_irc.h
+++ b/pyirssi_irc.h
@@ -4,6 +4,7 @@
#include "pyirssi.h"
#include "irc.h"
#include "irc-servers.h"
+#include "servers-redirect.h"
#include "irc-channels.h"
#include "ctcp.h"
#include "mode-lists.h"
diff --git a/pymodule.c b/pymodule.c
index 2f6b79c..8d6d028 100644
--- a/pymodule.c
+++ b/pymodule.c
@@ -1,7 +1,6 @@
#include <Python.h>
#include "pymodule.h"
#include "pyirssi_irc.h"
-#include "pyscript-object.h"
#include "factory.h"
#include "pyutils.h"
#include "pysignals.h"
@@ -24,7 +23,9 @@ PyObject *py_module = NULL;
/* Module functions */
/*XXX: prefix PY to avoid ambiguity with py_command function */
PyDoc_STRVAR(PY_command_doc,
- "Execute command"
+ "command(cmd) -> None\n"
+ "\n"
+ "Execute command\n"
);
static PyObject *PY_command(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -41,7 +42,9 @@ static PyObject *PY_command(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_prnt_doc,
- "print output"
+ "prnt(text, msglvl=MSGLEVEL_CLIENTNOTICE) -> None\n"
+ "\n"
+ "print output\n"
);
/*XXX: print is a python keyword, so abbreviate it */
static PyObject *py_prnt(PyObject *self, PyObject *args, PyObject *kwargs)
@@ -60,7 +63,9 @@ static PyObject *py_prnt(PyObject *self, PyObject *args, PyObject *kwargs)
}
PyDoc_STRVAR(py_get_script_doc,
- "Get Irssi script object"
+ "get_script() -> Script object\n"
+ "\n"
+ "Find current Irssi script object\n"
);
static PyObject *py_get_script(PyObject *self, PyObject *args)
{
@@ -77,7 +82,9 @@ static PyObject *py_get_script(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_chatnet_find_doc,
- "Find chat network with name"
+ "chatnet_find(name) -> Chatnet object or None\n"
+ "\n"
+ "Find chat network with name\n"
);
static PyObject *py_chatnet_find(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -92,7 +99,9 @@ static PyObject *py_chatnet_find(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_chatnets_doc,
- "Return a list of all chatnets"
+ "chatnets() -> list of Chatnet objects\n"
+ "\n"
+ "Return a list of all chatnets\n"
);
static PyObject *py_chatnets(PyObject *self, PyObject *args)
{
@@ -100,7 +109,9 @@ static PyObject *py_chatnets(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_reconnects_doc,
- "Return a list of all reconnects"
+ "reconnects() -> list of Reconnect objects\n"
+ "\n"
+ "Return a list of all reconnects\n"
);
static PyObject *py_reconnects(PyObject *self, PyObject *args)
{
@@ -108,7 +119,9 @@ static PyObject *py_reconnects(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_servers_doc,
- "Return a list of all servers"
+ "servers() -> list of Server objects\n"
+ "\n"
+ "Return a list of all servers\n"
);
static PyObject *py_servers(PyObject *self, PyObject *args)
{
@@ -116,7 +129,9 @@ static PyObject *py_servers(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_channels_doc,
- "Return channel list"
+ "channels() -> list of Channel objects\n"
+ "\n"
+ "Return channel list\n"
);
static PyObject *py_channels(PyObject *self, PyObject *args)
{
@@ -124,7 +139,9 @@ static PyObject *py_channels(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_channel_find_doc,
- "Find channel from any server"
+ "channel_find(name) -> Channel object or None\n"
+ "\n"
+ "Find channel from any server\n"
);
static PyObject *py_channel_find(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -139,7 +156,9 @@ static PyObject *py_channel_find(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_windows_doc,
- "Get a list of all windows"
+ "windows() -> list of Window objects\n"
+ "\n"
+ "Get a list of all windows\n"
);
static PyObject *py_windows(PyObject *self, PyObject *args)
{
@@ -147,7 +166,9 @@ static PyObject *py_windows(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_active_win_doc,
- "Return active window"
+ "active_win() -> Window object\n"
+ "\n"
+ "Return active window\n"
);
static PyObject *py_active_win(PyObject *self, PyObject *args)
{
@@ -158,7 +179,9 @@ static PyObject *py_active_win(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_active_server_doc,
- "Return active server"
+ "active_server() -> Server object or None\n"
+ "\n"
+ "Return active server\n"
);
static PyObject *py_active_server(PyObject *self, PyObject *args)
{
@@ -169,7 +192,9 @@ static PyObject *py_active_server(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_window_find_name_doc,
- "Find window with name"
+ "window_find_name(name) -> Window object or None\n"
+ "\n"
+ "Find window with name\n"
);
static PyObject *py_window_find_name(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -189,7 +214,9 @@ static PyObject *py_window_find_name(PyObject *self, PyObject *args, PyObject *k
}
PyDoc_STRVAR(py_window_find_refnum_doc,
- "Find window with reference number"
+ "window_find_refnum(refnum) -> Window object or None\n"
+ "\n"
+ "Find window with reference number\n"
);
static PyObject *py_window_find_refnum(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -209,7 +236,9 @@ static PyObject *py_window_find_refnum(PyObject *self, PyObject *args, PyObject
}
PyDoc_STRVAR(py_window_refnum_prev_doc,
- "Return refnum for window that's previous in window list"
+ "window_refnum_prev(refnum, wrap) -> int\n"
+ "\n"
+ "Return refnum for window that's previous in window list\n"
);
static PyObject *py_window_refnum_prev(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -225,7 +254,9 @@ static PyObject *py_window_refnum_prev(PyObject *self, PyObject *args, PyObject
}
PyDoc_STRVAR(py_window_refnum_next_doc,
- "Return refnum for window that's next in window list"
+ "window_refnum_next(refnum, wrap) -> int\n"
+ "\n"
+ "Return refnum for window that's next in window list\n"
);
static PyObject *py_window_refnum_next(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -241,7 +272,9 @@ static PyObject *py_window_refnum_next(PyObject *self, PyObject *args, PyObject
}
PyDoc_STRVAR(py_windows_refnum_last_doc,
- "Return refnum for last window."
+ "windows_refnum_last() -> int\n"
+ "\n"
+ "Return refnum for last window.\n"
);
static PyObject *py_windows_refnum_last(PyObject *self, PyObject *args)
{
@@ -249,7 +282,9 @@ static PyObject *py_windows_refnum_last(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_window_find_level_doc,
- "Find window with level."
+ "window_find_level(level) -> Window object or None\n"
+ "\n"
+ "Find window with level.\n"
);
static PyObject *py_window_find_level(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -269,7 +304,9 @@ static PyObject *py_window_find_level(PyObject *self, PyObject *args, PyObject *
}
PyDoc_STRVAR(py_window_find_item_doc,
- "Find window which contains window item with specified name."
+ "window_find_item(name) -> Window object or None\n"
+ "\n"
+ "Find window which contains window item with specified name.\n"
);
static PyObject *py_window_find_item(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -289,8 +326,10 @@ static PyObject *py_window_find_item(PyObject *self, PyObject *args, PyObject *k
}
PyDoc_STRVAR(py_window_find_closest_doc,
- "Find window that matches best to given arguments. `name' can be either"
- "window name or name of one of the window items."
+ "window_find_closest(name, level) -> Window object or None\n"
+ "\n"
+ "Find window that matches best to given arguments. `name' can be either\n"
+ "window name or name of one of the window items.\n"
);
static PyObject *py_window_find_closest(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -311,7 +350,9 @@ static PyObject *py_window_find_closest(PyObject *self, PyObject *args, PyObject
}
PyDoc_STRVAR(py_window_item_find_doc,
- "Find window item that matches best to given arguments."
+ "window_item_find(name) -> WindowItem object or None\n"
+ "\n"
+ "Find window item that matches best to given arguments.\n"
);
static PyObject *py_window_item_find(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -367,7 +408,9 @@ static PyObject *py_window_create(PyObject *self, PyObject *args, PyObject *kwds
}
PyDoc_STRVAR(py_server_find_tag_doc,
- "Find server with tag"
+ "server_find_tag(tag) -> Server object or None\n"
+ "\n"
+ "Find server with tag\n"
);
static PyObject *py_server_find_tag(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -382,7 +425,9 @@ static PyObject *py_server_find_tag(PyObject *self, PyObject *args, PyObject *kw
}
PyDoc_STRVAR(py_server_find_chatnet_doc,
- "Find first server that is in chatnet"
+ "server_find_chatnet(chatnet) -> Server object or None\n"
+ "\n"
+ "Find first server that is in chatnet\n"
);
static PyObject *py_server_find_chatnet(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -397,7 +442,9 @@ static PyObject *py_server_find_chatnet(PyObject *self, PyObject *args, PyObject
}
PyDoc_STRVAR(py_queries_doc,
- "Return a list of open queries."
+ "queries() -> list of Query objects\n"
+ "\n"
+ "Return a list of open queries.\n"
);
static PyObject *py_queries(PyObject *self, PyObject *args)
{
@@ -405,7 +452,9 @@ static PyObject *py_queries(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_query_find_doc,
- "Find a query from any server."
+ "query_find(nick) -> Query object or None\n"
+ "\n"
+ "Find a query from any server.\n"
);
static PyObject *py_query_find(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -420,7 +469,9 @@ static PyObject *py_query_find(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_mask_match_doc,
- "Return true if mask matches nick!user@host"
+ "mask_match(mask, nick, user, host) -> bool\n"
+ "\n"
+ "Return true if mask matches nick!user@host\n"
);
static PyObject *py_mask_match(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -438,7 +489,9 @@ static PyObject *py_mask_match(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_mask_match_address_doc,
- "Return True if mask matches nick!address"
+ "mask_match_address(mask, nick, address) -> bool\n"
+ "\n"
+ "Return True if mask matches nick!address\n"
);
static PyObject *py_mask_match_address(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -455,6 +508,8 @@ static PyObject *py_mask_match_address(PyObject *self, PyObject *args, PyObject
}
PyDoc_STRVAR(py_masks_match_doc,
+ "masks_match(masks, nick, address) -> bool\n"
+ "\n"
"Return True if any mask in the masks (string separated by spaces)\n"
"matches nick!address\n"
);
@@ -473,7 +528,9 @@ static PyObject *py_masks_match(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_rawlog_set_size_doc,
- "Set the default rawlog size for new rawlogs."
+ "rawlog_set_size(lines) -> None\n"
+ "\n"
+ "Set the default rawlog size for new rawlogs.\n"
);
static PyObject *py_rawlog_set_size(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -490,7 +547,9 @@ static PyObject *py_rawlog_set_size(PyObject *self, PyObject *args, PyObject *kw
}
PyDoc_STRVAR(py_logs_doc,
- "Return list of logs."
+ "logs() -> list of Log objects\n"
+ "\n"
+ "Return list of logs.\n"
);
static PyObject *py_logs(PyObject *self, PyObject *args)
{
@@ -498,7 +557,9 @@ static PyObject *py_logs(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_log_find_doc,
- "Find log by file name."
+ "log_find(fname) -> Log object or None\n"
+ "\n"
+ "Find log by file name.\n"
);
static PyObject *py_log_find(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -518,7 +579,9 @@ static PyObject *py_log_find(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_ignores_doc,
- "Return a list of ignore entries"
+ "ignores() -> list of Ignore objects\n"
+ "\n"
+ "Return a list of ignore entries\n"
);
static PyObject *py_ignores(PyObject *self, PyObject *args)
{
@@ -526,7 +589,9 @@ static PyObject *py_ignores(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_ignore_check_doc,
- "Return True if ignore matches"
+ "ignore_check(nick, host, channel, text, level) -> bool\n"
+ "\n"
+ "Return True if ignore matches\n"
);
static PyObject *py_ignore_check(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -545,7 +610,9 @@ static PyObject *py_ignore_check(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_dccs_doc,
- "Return list of active DCCs"
+ "dccs() -> list of Dcc objects\n"
+ "\n"
+ "Return list of active DCCs\n"
);
static PyObject *py_dccs(PyObject *self, PyObject *args)
{
@@ -553,7 +620,9 @@ static PyObject *py_dccs(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_dcc_register_type_doc,
- "???"
+ "dcc_register_type(type) -> None\n"
+ "\n"
+ "???\n"
);
static PyObject *py_dcc_register_type(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -570,7 +639,9 @@ static PyObject *py_dcc_register_type(PyObject *self, PyObject *args, PyObject *
}
PyDoc_STRVAR(py_dcc_unregister_type_doc,
- "???"
+ "dcc_unregister_type(type) -> None\n"
+ "\n"
+ "???\n"
);
static PyObject *py_dcc_unregister_type(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -587,7 +658,9 @@ static PyObject *py_dcc_unregister_type(PyObject *self, PyObject *args, PyObject
}
PyDoc_STRVAR(py_dcc_find_request_latest_doc,
- "???"
+ "dcc_find_request_latest(type) -> Dcc object or None\n"
+ "\n"
+ "???\n"
);
static PyObject *py_dcc_find_request_latest(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -602,7 +675,9 @@ static PyObject *py_dcc_find_request_latest(PyObject *self, PyObject *args, PyOb
}
PyDoc_STRVAR(py_dcc_find_request_doc,
- "???"
+ "dcc_find_request(type, nick, arg) -> Dcc object or None\n"
+ "\n"
+ "???\n"
);
static PyObject *py_dcc_find_request(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -619,7 +694,9 @@ static PyObject *py_dcc_find_request(PyObject *self, PyObject *args, PyObject *k
}
PyDoc_STRVAR(py_dcc_chat_find_id_doc,
- "???"
+ "dcc_chat_find_id(id) -> Dcc object or None\n"
+ "\n"
+ "???\n"
);
static PyObject *py_dcc_chat_find_id(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -634,7 +711,9 @@ static PyObject *py_dcc_chat_find_id(PyObject *self, PyObject *args, PyObject *k
}
PyDoc_STRVAR(py_dcc_str2type_doc,
- "???"
+ "dcc_str2type(type) -> int\n"
+ "\n"
+ "???\n"
);
static PyObject *py_dcc_str2type(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -649,7 +728,9 @@ static PyObject *py_dcc_str2type(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_dcc_type2str_doc,
- "???"
+ "dcc_type2str(type) -> str or None\n"
+ "\n"
+ "???\n"
);
static PyObject *py_dcc_type2str(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -664,7 +745,9 @@ static PyObject *py_dcc_type2str(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_dcc_get_download_path_doc,
- "???"
+ "dcc_get_download(fname) -> str\n"
+ "\n"
+ "???\n"
);
static PyObject *py_dcc_get_download_path(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -688,7 +771,9 @@ static PyObject *py_dcc_get_download_path(PyObject *self, PyObject *args, PyObje
}
PyDoc_STRVAR(py_notifies_doc,
- "Return list of notifies"
+ "notifies() -> list of Notifylist objects\n"
+ "\n"
+ "Return list of notifies\n"
);
static PyObject *py_notifies(PyObject *self, PyObject *args)
{
@@ -721,7 +806,9 @@ static PyObject *py_notifylist_add(PyObject *self, PyObject *args, PyObject *kwd
}
PyDoc_STRVAR(py_notifylist_remove_doc,
- "Remove notify item from notify list"
+ "notifylist_remove(mask) -> None\n"
+ "\n"
+ "Remove notify item from notify list\n"
);
static PyObject *py_notifylist_remove(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -780,7 +867,9 @@ static PyObject *py_notifylist_find(PyObject *self, PyObject *args, PyObject *kw
}
PyDoc_STRVAR(py_commands_doc,
- "Return a list of all commands."
+ "commands() -> list of Command objects\n"
+ "\n"
+ "Return a list of all commands.\n"
);
static PyObject *py_commands(PyObject *self, PyObject *args)
{
@@ -788,7 +877,9 @@ static PyObject *py_commands(PyObject *self, PyObject *args)
}
PyDoc_STRVAR(py_level2bits_doc,
- "Level string -> number"
+ "level2bits(level) -> long\n"
+ "\n"
+ "Level string -> number\n"
);
static PyObject *py_level2bits(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -803,7 +894,9 @@ static PyObject *py_level2bits(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_bits2level_doc,
- "Level number -> string"
+ "bits2level(bits) -> str\n"
+ "\n"
+ "Level number -> string\n"
);
static PyObject *py_bits2level(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -828,7 +921,9 @@ static PyObject *py_bits2level(PyObject *self, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(py_combine_level_doc,
- "Combine level number to level string ('+level -level'). Return new level number."
+ "combine_level(level, str) -> long\n"
+ "\n"
+ "Combine level number to level string ('+level -level'). Return new level number.\n"
);
static PyObject *py_combine_level(PyObject *self, PyObject *args, PyObject *kwds)
{
@@ -1419,6 +1514,203 @@ static PyObject *py_statusbar_item_unregister(PyObject *self, PyObject *args, Py
Py_RETURN_NONE;
}
+PyDoc_STRVAR(py_active_mainwin_doc,
+ "active_mainwin() -> MainWindow object\n"
+ "\n"
+ "return active main window\n"
+);
+static PyObject *py_active_mainwin(PyObject *self, PyObject *args)
+{
+ if (!active_mainwin)
+ Py_RETURN_NONE;
+
+ return pymain_window_new(active_mainwin);
+}
+
+PyDoc_STRVAR(py_mainwindows_doc,
+ "mainwindows() -> list of MainWindow objects\n"
+ "\n"
+ "return a list of mainwindows\n"
+);
+static PyObject *py_mainwindows(PyObject *self, PyObject *args)
+{
+ return py_irssi_objlist_new(mainwindows, 1, (InitFunc)pymain_window_new);
+}
+
+/* expect a list of tuples [('str', 0), ...] */
+static GSList *py_register_conv(PyObject *list)
+{
+ int i;
+ GSList *ret = NULL;
+
+ if (list == Py_None)
+ return NULL;
+
+ if (!PyList_Check(list))
+ {
+ PyErr_Format(PyExc_TypeError, "expect a list of tuples of string and int");
+ return NULL;
+ }
+
+ for (i = 0; i < PyList_Size(list); i++)
+ {
+ char *key;
+ int val;
+ PyObject *tup = PyList_GET_ITEM(list, i);
+
+ if (!PyTuple_Check(tup) || !PyArg_ParseTuple(tup, "si", &key, &val))
+ {
+ if (!PyErr_Occurred() || PyErr_ExceptionMatches(PyExc_TypeError))
+ {
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError, "expect a list of tuples of string and int");
+ }
+
+ /* return the list so far; caller will clear it on error */
+ break;
+ }
+
+ ret = g_slist_append(ret, g_strdup(key));
+ ret = g_slist_append(ret, GINT_TO_POINTER(val));
+ }
+
+ return ret;
+}
+
+PyDoc_STRVAR(py_server_redirect_register_doc,
+ "server_redirect_register(command, stop, start=None, opt=None, remote=False, timeout=0) -> None\n"
+ "\n"
+ "Register new redirection command. By default irssi has already\n"
+ "registered at least: whois, whowas, who, list, ison, userhost, ping,\n"
+ "\"mode channel\" (/MODE #channel), \"mode b\" (/MODE #channel b), \"mode e\"\n"
+ "and \"mode I\".\n"
+ "\n"
+ "`command' specifies the name of the command to register, it doesn't\n"
+ "have to be a real command name, but something you just specify to\n"
+ "Server.redirect_event() when using this redirection.\n"
+ "\n"
+ "`start', `stop', `opt' - lists of ('event', argpos) tuples.\n"
+ "List of events that start and stop this redirection.\n"
+ "Start event list may be empty, but there must be at least one\n"
+ "stop event. Optional events are checked only if they are received\n"
+ "immediately after one of the stop-events. `argpos' specifies the\n"
+ "word number in event string which is compared to wanted argument,\n"
+ "-1 = don't compare, TRUE always.\n"
+ "\n"
+ "`remote' specifies if the command is by default a remote command\n"
+ "(eg. sent to another server). Server.redirect_event() may override this.\n"
+ "\n"
+ "`timeout' - If remote is TRUE, specifies how many seconds to wait for\n"
+ "reply before aborting.\n"
+ "\n"
+ "Example (already done by irssi):\n"
+ "\n"
+ "server_redirect_register('mode channel',\n"
+ " start = None,\n"
+ " stop = [ \n"
+ " ('event 324', 1), # MODE-reply\n"
+ " ('event 403', 1), # no such channel\n"
+ " ('event 442', 1), # \"you're not on that channel\"\n"
+ " ('event 479', 1) # \"Cannot join channel (illegal name)\"\n"
+ " ], \n"
+ " opt = [ \n"
+ " ('event 329', 1) # Channel create time\n"
+ " ] \n"
+ ")\n"
+);
+static PyObject *py_server_redirect_register(PyObject *self, PyObject *args, PyObject *kwds)
+{
+ static char *kwlist[] = {"command", "stop", "start", "opt", "remote", "timeout", NULL};
+ char *command = "";
+ int remote = 0;
+ int timeout = 0;
+ PyObject *start = NULL;
+ PyObject *stop = NULL;
+ PyObject *opt = NULL;
+ GSList *node;
+ GSList *gstart = NULL;
+ GSList *gstop = NULL;
+ GSList *gopt = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO|OOii", kwlist,
+ &command, &stop, &start, &opt, &remote, &timeout))
+ return NULL;
+
+ gstart = py_register_conv(start);
+ if (PyErr_Occurred())
+ goto error;
+
+ gstop = py_register_conv(stop);
+ if (!gstop || PyErr_Occurred())
+ {
+ if (!PyErr_Occurred())
+ PyErr_SetString(PyExc_TypeError, "stop list must be provided");
+
+ goto error;
+ }
+
+ gopt = py_register_conv(opt);
+ if (PyErr_Occurred())
+ goto error;
+
+ server_redirect_register_list(command, remote, timeout, gstart, gstop, gopt);
+
+ Py_RETURN_NONE;
+
+error:
+ /* clean up all lists */
+ for (node = gstart; node; node = node->next->next)
+ g_free(node->data);
+ for (node = gstop; node; node = node->next->next)
+ g_free(node->data);
+ for (node = gopt; node; node = node->next->next)
+ g_free(node->data);
+
+ return NULL;
+
+}
+
+PyDoc_STRVAR(py_command_runsub_doc,
+ "command_runsub(cmd, data, server=None, item=None) -> None\n"
+ "\n"
+ "Run subcommands for `cmd'. First word in `data' is parsed as\n"
+ "subcommand. `server' is Server object for current\n"
+ "WindowItem `item'.\n"
+ "\n"
+ "Call command_runsub in handler function for `cmd' and bind\n"
+ "with command_bind(\"`cmd' `subcmd'\", subcmdfunc[, category]);\n"
+);
+static PyObject *py_command_runsub(PyObject *self, PyObject *args, PyObject *kwds)
+{
+ static char *kwlist[] = {"cmd", "data", "server", "item", NULL};
+ char *cmd = "";
+ char *data = "";
+ PyObject *pserver = Py_None;
+ PyObject *pitem = Py_None;
+ SERVER_REC *server = NULL;
+ WI_ITEM_REC *item = NULL;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|OO", kwlist,
+ &cmd, &data, &pserver, &pitem))
+ return NULL;
+
+ if (pserver != Py_None && !pyserver_check(pserver))
+ return PyErr_Format(PyExc_TypeError, "server must be a server");
+
+ if (pitem != Py_None && !pywindow_item_check(pitem))
+ return PyErr_Format(PyExc_TypeError, "item must be a window item");
+
+ if (pserver != Py_None)
+ server = DATA(pserver);
+
+ if (pitem != Py_None)
+ item = DATA(pitem);
+
+ command_runsub(cmd, data, server, item);
+
+ Py_RETURN_NONE;
+}
+
static PyMethodDef ModuleMethods[] = {
{"prnt", (PyCFunction)py_prnt, METH_VARARGS | METH_KEYWORDS,
py_prnt_doc},
@@ -1582,6 +1874,14 @@ static PyMethodDef ModuleMethods[] = {
py_statusbars_recreate_items_doc},
{"statusbar_item_unregister", (PyCFunction)py_statusbar_item_unregister, METH_VARARGS | METH_KEYWORDS,
py_statusbar_item_unregister_doc},
+ {"active_mainwin", (PyCFunction)py_active_mainwin, METH_NOARGS,
+ py_active_mainwin_doc},
+ {"mainwindows", (PyCFunction)py_mainwindows, METH_NOARGS,
+ py_mainwindows_doc},
+ {"server_redirect_register", (PyCFunction)py_server_redirect_register, METH_VARARGS | METH_KEYWORDS,
+ py_server_redirect_register_doc},
+ {"command_runsub", (PyCFunction)py_command_runsub, METH_VARARGS | METH_KEYWORDS,
+ py_command_runsub_doc},
{NULL, NULL, 0, NULL} /* Sentinel */
};
diff --git a/pythemes.c b/pythemes.c
index 1e03f10..a3e8927 100644
--- a/pythemes.c
+++ b/pythemes.c
@@ -110,9 +110,9 @@ int pythemes_register(const char *name, PyObject *list)
rec = &formatrecs[i + 1];
item = PyList_GET_ITEM(list, i);
- if (!PyArg_ParseTuple(item, "ss", &key, &value))
+ if (!PyTuple_Check(item) || !PyArg_ParseTuple(item, "ss", &key, &value))
{
- if (PyErr_ExceptionMatches(PyExc_TypeError))
+ if (!PyErr_Occurred() || PyErr_ExceptionMatches(PyExc_TypeError))
{
PyErr_Clear();
PyErr_Format(PyExc_TypeError, "format list must contain tuples of two strings");