summaryrefslogtreecommitdiffstats
path: root/src/objects/dcc-chat-object.c
diff options
context:
space:
mode:
authorChristopher Davis <loafier@gmail.com>2006-08-12 22:16:53 +0000
committerChristopher Davis <loafier@gmail.com>2006-08-12 22:16:53 +0000
commit3a028090359e5d5d24ccbfc11d9b6ff5681aab4f (patch)
tree0cfb8ec1eb8a49366fc663bef00bf4dfb1f7c307 /src/objects/dcc-chat-object.c
parentf13ea25509e932d426ebd69d90368fe9b1d4c1ab (diff)
downloadirssi-python-3a028090359e5d5d24ccbfc11d9b6ff5681aab4f.tar.gz
irssi-python-3a028090359e5d5d24ccbfc11d9b6ff5681aab4f.tar.xz
irssi-python-3a028090359e5d5d24ccbfc11d9b6ff5681aab4f.zip
directory structure change
git-svn-id: http://svn.irssi.org/repos/irssi-python@4312 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/objects/dcc-chat-object.c')
-rw-r--r--src/objects/dcc-chat-object.c137
1 files changed, 137 insertions, 0 deletions
diff --git a/src/objects/dcc-chat-object.c b/src/objects/dcc-chat-object.c
new file mode 100644
index 0000000..5cfe796
--- /dev/null
+++ b/src/objects/dcc-chat-object.c
@@ -0,0 +1,137 @@
+#include <Python.h>
+#include "pyirssi_irc.h"
+#include "pymodule.h"
+#include "dcc-chat-object.h"
+#include "factory.h"
+#include "pycore.h"
+
+/* inherit destroy and cleanup from DccChat type */
+
+/* Getters */
+PyDoc_STRVAR(PyDccChat_id_doc,
+ "Unique identifier - usually same as nick"
+);
+static PyObject *PyDccChat_id_get(PyDccChat *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ RET_AS_STRING_OR_NONE(self->data->id);
+}
+
+PyDoc_STRVAR(PyDccChat_mirc_ctcp_doc,
+ "Send CTCPs without the CTCP_MESSAGE prefix"
+);
+static PyObject *PyDccChat_mirc_ctcp_get(PyDccChat *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->mirc_ctcp);
+}
+
+PyDoc_STRVAR(PyDccChat_connection_lost_doc,
+ "Other side closed connection"
+);
+static PyObject *PyDccChat_connection_lost_get(PyDccChat *self, void *closure)
+{
+ RET_NULL_IF_INVALID(self->data);
+ return PyBool_FromLong(self->data->connection_lost);
+}
+
+/* specialized getters/setters */
+static PyGetSetDef PyDccChat_getseters[] = {
+ {"id", (getter)PyDccChat_id_get, NULL,
+ PyDccChat_id_doc, NULL},
+ {"mirc_ctcp", (getter)PyDccChat_mirc_ctcp_get, NULL,
+ PyDccChat_mirc_ctcp_doc, NULL},
+ {"connection_lost", (getter)PyDccChat_connection_lost_get, NULL,
+ PyDccChat_connection_lost_doc, NULL},
+ {NULL}
+};
+
+/* Methods */
+PyDoc_STRVAR(PyDccChat_chat_send_doc,
+ "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)
+{
+ static char *kwlist[] = {"data", NULL};
+ char *data = "";
+
+ RET_NULL_IF_INVALID(self->data);
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist,
+ &data))
+ return NULL;
+
+ dcc_chat_send(self->data, data);
+
+ Py_RETURN_NONE;
+}
+
+/* Methods for object */
+static PyMethodDef PyDccChat_methods[] = {
+ {"chat_send", (PyCFunction)PyDccChat_chat_send, METH_VARARGS | METH_KEYWORDS,
+ PyDccChat_chat_send_doc},
+ {NULL} /* Sentinel */
+};
+
+PyTypeObject PyDccChatType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "DccChat", /*tp_name*/
+ sizeof(PyDccChat), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ 0, /*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*/
+ "PyDccChat objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ PyDccChat_methods, /* tp_methods */
+ 0, /* tp_members */
+ PyDccChat_getseters, /* tp_getset */
+ &PyDccType, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
+PyObject *pydcc_chat_new(void *dcc)
+{
+ static const char *name = "DCC CHAT";
+ return pydcc_sub_new(dcc, name, &PyDccChatType);
+}
+
+int dcc_chat_object_init(void)
+{
+ g_return_val_if_fail(py_module != NULL, 0);
+
+ if (PyType_Ready(&PyDccChatType) < 0)
+ return 0;
+
+ Py_INCREF(&PyDccChatType);
+ PyModule_AddObject(py_module, "DccChat", (PyObject *)&PyDccChatType);
+
+ return 1;
+}