summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Bouthenot <kolter@openics.org>2005-07-12 14:46:44 +0000
committerEmmanuel Bouthenot <kolter@openics.org>2005-07-12 14:46:44 +0000
commitd286f3922c15630f97555cdd87f0715b588b4031 (patch)
treea5cae53e7e015f7fa5b2d575e7b4af2f511595cb
parent505b43d15b2828a2eb40ed358753f444411e9985 (diff)
downloadweechat-d286f3922c15630f97555cdd87f0715b588b4031.zip
adding getinfo feature about dccs
-rw-r--r--src/plugins/python/wee-python.c48
-rw-r--r--weechat/src/plugins/python/wee-python.c48
2 files changed, 96 insertions, 0 deletions
diff --git a/src/plugins/python/wee-python.c b/src/plugins/python/wee-python.c
index b984281ea..7475bbb24 100644
--- a/src/plugins/python/wee-python.c
+++ b/src/plugins/python/wee-python.c
@@ -362,6 +362,54 @@ wee_python_get_info (PyObject *self, PyObject *args)
{
return Py_BuildValue ("i", SERVER(gui_current_window->buffer)->is_away);
}
+ else if ( (strcasecmp (arg, "100") == 0) || (strcasecmp (arg, "dccs") == 0) )
+ {
+ t_irc_dcc *p = dcc_list;
+ int nbdccs = 0;
+
+ for(; p; p = p->next_dcc)
+ nbdccs++;
+
+ if (nbdccs == 0)
+ return Py_None;
+
+ PyObject *tuple = PyTuple_New(nbdccs);
+
+ if (!tuple)
+ return Py_None;
+
+ PyObject *tuplevalue;
+
+ int pos = 0;
+ for(; p; p = p->next_dcc)
+ {
+ tuplevalue = Py_BuildValue("{s:k,s:k,s:s,s:s,s:s,s:i,s:k,s:k,s:i,s:i}",
+ "address32", p->addr,
+ "cps", p->bytes_per_sec,
+ "remote_file", p->filename,
+ "local_file", p->local_filename,
+ "nick", p->nick,
+ "port", p->port,
+ "pos", p->pos,
+ "size", p->size,
+ "status", p->status,
+ "type", p->type);
+ if (tuplevalue)
+ {
+ if (PyTuple_SetItem(tuple, pos, tuplevalue) != 0)
+ {
+ PyMem_Free(tuplevalue);
+ PyMem_Free(tuple);
+ return Py_None;
+ }
+ }
+ else
+ return Py_None;
+ pos++;
+ }
+
+ return tuple;
+ }
if (info)
return Py_BuildValue ("s", info);
diff --git a/weechat/src/plugins/python/wee-python.c b/weechat/src/plugins/python/wee-python.c
index b984281ea..7475bbb24 100644
--- a/weechat/src/plugins/python/wee-python.c
+++ b/weechat/src/plugins/python/wee-python.c
@@ -362,6 +362,54 @@ wee_python_get_info (PyObject *self, PyObject *args)
{
return Py_BuildValue ("i", SERVER(gui_current_window->buffer)->is_away);
}
+ else if ( (strcasecmp (arg, "100") == 0) || (strcasecmp (arg, "dccs") == 0) )
+ {
+ t_irc_dcc *p = dcc_list;
+ int nbdccs = 0;
+
+ for(; p; p = p->next_dcc)
+ nbdccs++;
+
+ if (nbdccs == 0)
+ return Py_None;
+
+ PyObject *tuple = PyTuple_New(nbdccs);
+
+ if (!tuple)
+ return Py_None;
+
+ PyObject *tuplevalue;
+
+ int pos = 0;
+ for(; p; p = p->next_dcc)
+ {
+ tuplevalue = Py_BuildValue("{s:k,s:k,s:s,s:s,s:s,s:i,s:k,s:k,s:i,s:i}",
+ "address32", p->addr,
+ "cps", p->bytes_per_sec,
+ "remote_file", p->filename,
+ "local_file", p->local_filename,
+ "nick", p->nick,
+ "port", p->port,
+ "pos", p->pos,
+ "size", p->size,
+ "status", p->status,
+ "type", p->type);
+ if (tuplevalue)
+ {
+ if (PyTuple_SetItem(tuple, pos, tuplevalue) != 0)
+ {
+ PyMem_Free(tuplevalue);
+ PyMem_Free(tuple);
+ return Py_None;
+ }
+ }
+ else
+ return Py_None;
+ pos++;
+ }
+
+ return tuple;
+ }
if (info)
return Py_BuildValue ("s", info);