i am upstream now. so release 0.5. much thanks to fgsch@, for
testing, bug-hunting, and diffs.
This commit is contained in:
parent
56484b9d13
commit
c86fa684dc
@ -1,17 +1,17 @@
|
||||
# $OpenBSD: Makefile,v 1.8 2008/03/23 05:46:29 fgsch Exp $
|
||||
# $OpenBSD: Makefile,v 1.9 2008/07/08 21:29:20 martynas Exp $
|
||||
|
||||
SHARED_ONLY= Yes
|
||||
|
||||
COMMENT= Python bindings for the SILC toolkit
|
||||
|
||||
V= 0.4
|
||||
V= 0.5
|
||||
DISTNAME= pysilc-${V}
|
||||
PKGNAME= py-silc-${V}p3v0
|
||||
PKGNAME= py-silc-${V}v0
|
||||
CATEGORIES= devel
|
||||
|
||||
HOMEPAGE= http://www.liquidx.net/pysilc/
|
||||
|
||||
MAINTAINER= Martynas Venckus <martynas@altroot.org>
|
||||
MAINTAINER= Martynas Venckus <martynas@openbsd.org>
|
||||
|
||||
# BSD
|
||||
PERMIT_PACKAGE_CDROM= Yes
|
||||
|
@ -1,5 +1,5 @@
|
||||
MD5 (pysilc-0.4.tar.bz2) = GIFuY9R3mtLMaDw4iAzw8A==
|
||||
RMD160 (pysilc-0.4.tar.bz2) = RkdVrghbaY76ezpgoDNtefud3P0=
|
||||
SHA1 (pysilc-0.4.tar.bz2) = udO8Qr7MoPs3Ew9m+in4r2ffD9w=
|
||||
SHA256 (pysilc-0.4.tar.bz2) = 2phGYqEb5t1g8B77awD38lCTK+bZsykyYxDgWV3MOZQ=
|
||||
SIZE (pysilc-0.4.tar.bz2) = 15387
|
||||
MD5 (pysilc-0.5.tar.bz2) = RLggNkeXeVfwKTkQilDoMA==
|
||||
RMD160 (pysilc-0.5.tar.bz2) = kurmdpMoIHaPoR6Ayd9bTqFeo+I=
|
||||
SHA1 (pysilc-0.5.tar.bz2) = 6f0QwHe4xPc8cYzm/2/OWEAWuns=
|
||||
SHA256 (pysilc-0.5.tar.bz2) = Eq3V2GU5TiTxsa1hN5JBfwGFvXotLIzH9B3kyYALgH8=
|
||||
SIZE (pysilc-0.5.tar.bz2) = 18230
|
||||
|
@ -1,21 +0,0 @@
|
||||
$OpenBSD: patch-README,v 1.3 2007/10/02 17:35:48 martynas Exp $
|
||||
--- README.orig Mon Jul 10 12:16:09 2006
|
||||
+++ README Sun Jul 1 22:52:11 2007
|
||||
@@ -73,6 +73,9 @@ class EchoClient(silc.SilcClient):
|
||||
print message
|
||||
self.send_private_message(sender, message)
|
||||
|
||||
+ def running(self):
|
||||
+ self.connect_to_server("silc.example.com")
|
||||
+
|
||||
def connected(self):
|
||||
print "* Connected"
|
||||
self.command_call("JOIN crazybotchannel")
|
||||
@@ -99,7 +102,6 @@ class EchoClient(silc.SilcClient):
|
||||
if __name__ == "__main__":
|
||||
keys = silc.create_key_pair("silc.pub", "silc.prv")
|
||||
client = EchoClient(keys, "echobot", "echobot", "Echo Bot")
|
||||
- client.connect_to_server("silc.example.com")
|
||||
|
||||
while True:
|
||||
try:
|
@ -1,34 +0,0 @@
|
||||
$OpenBSD: patch-examples_demo_py,v 1.4 2008/03/23 05:46:29 fgsch Exp $
|
||||
--- examples/demo.py.orig Mon Jul 10 00:57:15 2006
|
||||
+++ examples/demo.py Sun Mar 23 05:36:57 2008
|
||||
@@ -29,6 +29,10 @@ class SupySilcClient(silc.SilcClient):
|
||||
def _cache_channel(self, channel):
|
||||
self.channels[channel.channel_name] = channel
|
||||
|
||||
+ def running(self):
|
||||
+ print 'SILC: Running.'
|
||||
+ self.connect_to_server(sys.argv[1], 706)
|
||||
+
|
||||
def connected(self):
|
||||
print 'SILC: Connected to server.'
|
||||
self.isconnected = True
|
||||
@@ -195,8 +199,9 @@ class SupySilcClient(silc.SilcClient):
|
||||
print 'SILC: Reply (Leave):', channel
|
||||
|
||||
def command_reply_users(self, channel, users):
|
||||
- self._cache_user(user)
|
||||
- print 'SILC: Reply (Users):', type, user
|
||||
+ for user in users:
|
||||
+ self._cache_user(user)
|
||||
+ print 'SILC: Reply (Users):', channel, users
|
||||
|
||||
def command_reply_service(self, *args):
|
||||
pass # not implemented
|
||||
@@ -209,7 +214,6 @@ class SupySilcClient(silc.SilcClient):
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
c = SupySilcClient()
|
||||
- c.connect_to_server(sys.argv[1], 706)
|
||||
try:
|
||||
while True:
|
||||
c.run_one()
|
@ -1,24 +0,0 @@
|
||||
$OpenBSD: patch-examples_echo_py,v 1.3 2007/10/02 17:35:48 martynas Exp $
|
||||
--- examples/echo.py.orig Mon Jul 10 03:09:26 2006
|
||||
+++ examples/echo.py Sun Jul 1 22:52:11 2007
|
||||
@@ -11,6 +11,10 @@ class EchoClient(silc.SilcClient):
|
||||
print message
|
||||
self.send_private_message(sender, message)
|
||||
|
||||
+ def running(self):
|
||||
+ print "* Running"
|
||||
+ client.connect_to_server("silc.example.com")
|
||||
+
|
||||
def connected(self):
|
||||
print "* Connected"
|
||||
self.command_call("JOIN #cam")
|
||||
@@ -37,8 +41,7 @@ class EchoClient(silc.SilcClient):
|
||||
if __name__ == "__main__":
|
||||
keys = silc.create_key_pair("silc.pub", "silc.prv", passphrase = "")
|
||||
client = EchoClient(keys, "echobot", "echobot", "Echo Bot")
|
||||
- client.connect_to_server("silc.example.com")
|
||||
-
|
||||
+
|
||||
while True:
|
||||
try:
|
||||
client.run_one()
|
@ -1,19 +0,0 @@
|
||||
$OpenBSD: patch-setup_py,v 1.4 2007/10/02 17:35:48 martynas Exp $
|
||||
--- setup.py.orig Mon Jul 10 11:44:43 2006
|
||||
+++ setup.py Sun Jul 1 22:53:24 2007
|
||||
@@ -9,10 +9,13 @@ except:
|
||||
|
||||
ext_modules = [
|
||||
Extension('silc', ['src/pysilc.c'],
|
||||
- libraries = ['silc', 'silcclient'],
|
||||
+ libraries = ['iconv', 'silc', 'silcclient'],
|
||||
extra_compile_args = ['-g'],
|
||||
+ library_dirs = ['%%LOCALBASE%%/lib'],
|
||||
include_dirs = ['/usr/include/silc-toolkit',
|
||||
- '/usr/local/include/silc'],
|
||||
+ '%%LOCALBASE%%/include/silc-toolkit',
|
||||
+ '/usr/include/silc',
|
||||
+ '%%LOCALBASE%%/include/silc'],
|
||||
depends = ['src/pysilc_callbacks.c',
|
||||
'src/pysilc_channel.c',
|
||||
'src/pysilc_user.c',
|
@ -1,233 +0,0 @@
|
||||
$OpenBSD: patch-src_pysilc_c,v 1.3 2007/10/02 17:35:48 martynas Exp $
|
||||
--- src/pysilc.c.orig Mon Jul 10 01:27:57 2006
|
||||
+++ src/pysilc.c Sun Jul 1 22:52:11 2007
|
||||
@@ -26,26 +26,28 @@ void initsilc() {
|
||||
PY_MOD_ADD_CLASS(mod, SilcClient);
|
||||
PY_MOD_ADD_CLASS(mod, SilcChannel);
|
||||
PY_MOD_ADD_CLASS(mod, SilcUser);
|
||||
+ PyModule_AddIntConstant(mod, "SILC_ID_CLIENT", SILC_ID_CLIENT);
|
||||
+ PyModule_AddIntConstant(mod, "SILC_ID_CHANNEL", SILC_ID_CHANNEL);
|
||||
+ PyModule_AddIntConstant(mod, "SILC_ID_SERVER", SILC_ID_SERVER);
|
||||
}
|
||||
|
||||
static int PySilcClient_Init(PyObject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PySilcClient *pyclient = (PySilcClient *)self;
|
||||
+
|
||||
+ pyclient->conncallback = _pysilc_client_connect_callback;
|
||||
+
|
||||
pyclient->callbacks.say = _pysilc_client_callback_say;
|
||||
pyclient->callbacks.channel_message = _pysilc_client_callback_channel_message;
|
||||
pyclient->callbacks.private_message = _pysilc_client_callback_private_message;
|
||||
pyclient->callbacks.notify = _pysilc_client_callback_notify;
|
||||
pyclient->callbacks.command = _pysilc_client_callback_command;
|
||||
pyclient->callbacks.command_reply = _pysilc_client_callback_command_reply;
|
||||
- pyclient->callbacks.connected = _pysilc_client_callback_connected;
|
||||
- pyclient->callbacks.disconnected = _pysilc_client_callback_disconnected;
|
||||
pyclient->callbacks.get_auth_method = _pysilc_client_callback_get_auth_method;
|
||||
pyclient->callbacks.verify_public_key = _pysilc_client_callback_verify_key;
|
||||
pyclient->callbacks.ask_passphrase = _pysilc_client_callback_ask_passphrase;
|
||||
- pyclient->callbacks.failure = _pysilc_client_callback_failure;
|
||||
pyclient->callbacks.key_agreement = _pysilc_client_callback_key_agreement;
|
||||
pyclient->callbacks.ftp = _pysilc_client_callback_ftp;
|
||||
- pyclient->callbacks.detach = _pysilc_client_callback_detach;
|
||||
|
||||
char *nickname = NULL, *username = NULL, *realname = NULL, *hostname = NULL;
|
||||
static char *kwlist[] = {"keys", "nickname", "username", "realname", "hostname", NULL};
|
||||
@@ -67,9 +69,11 @@ static int PySilcClient_Init(PyObject *self, PyObject
|
||||
return -1;
|
||||
|
||||
pyclient->silcconn = NULL;
|
||||
-
|
||||
+
|
||||
+ memset(&(pyclient->params), 0, sizeof(pyclient->params));
|
||||
+
|
||||
if (nickname)
|
||||
- pyclient->silcobj->nickname = strdup(nickname);
|
||||
+ pyclient->params.nickname = strdup(nickname);
|
||||
if (username)
|
||||
pyclient->silcobj->username = strdup(username);
|
||||
else
|
||||
@@ -83,29 +87,22 @@ static int PySilcClient_Init(PyObject *self, PyObject
|
||||
else
|
||||
pyclient->silcobj->hostname = silc_net_localhost();
|
||||
|
||||
- pyclient->silcobj->pkcs = keys->pkcs;
|
||||
- pyclient->silcobj->public_key = keys->public;
|
||||
- pyclient->silcobj->private_key = keys->private;
|
||||
-
|
||||
pyclient->keys = keys;
|
||||
Py_INCREF(keys);
|
||||
|
||||
- silc_client_init(pyclient->silcobj);
|
||||
+ silc_client_init(pyclient->silcobj, pyclient->silcobj->username,
|
||||
+ pyclient->silcobj->hostname,
|
||||
+ pyclient->silcobj->realname, _pysilc_client_running,
|
||||
+ pyclient->silcobj);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void PySilcClient_Del(PyObject *obj)
|
||||
{
|
||||
- printf("SilcClient.__del__\n");
|
||||
PySilcClient *pyclient = (PySilcClient *)obj;
|
||||
if (pyclient->silcobj) {
|
||||
- silc_client_stop(pyclient->silcobj);
|
||||
- if (pyclient->silcobj->username)
|
||||
- free(pyclient->silcobj->username);
|
||||
- if (pyclient->silcobj->realname)
|
||||
- free(pyclient->silcobj->realname);
|
||||
- if (pyclient->silcobj->hostname)
|
||||
- free(pyclient->silcobj->hostname);
|
||||
+ silc_client_stop(pyclient->silcobj, NULL, NULL);
|
||||
silc_client_free(pyclient->silcobj);
|
||||
}
|
||||
Py_XDECREF(pyclient->keys);
|
||||
@@ -114,27 +111,30 @@ static void PySilcClient_Del(PyObject *obj)
|
||||
|
||||
static PyObject *pysilc_client_connect_to_server(PyObject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
- int result;
|
||||
+ SilcAsyncOperation op;
|
||||
unsigned int port = 706;
|
||||
char *host;
|
||||
static char *kwlist[] = {"host", "port", NULL};
|
||||
PySilcClient *pyclient = (PySilcClient *)self;
|
||||
-
|
||||
+
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|I", kwlist, &host, &port))
|
||||
return NULL;
|
||||
-
|
||||
+
|
||||
if (!pyclient || !pyclient->silcobj) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "SILC Client Not Initialised");
|
||||
return NULL;
|
||||
}
|
||||
-
|
||||
- result = silc_client_connect_to_server(pyclient->silcobj, NULL, port, host, NULL);
|
||||
- if (result != -1) {
|
||||
+
|
||||
+ op = silc_client_connect_to_server(pyclient->silcobj,
|
||||
+ &(pyclient->params), pyclient->keys->public, pyclient->keys->private,
|
||||
+ host, port, pyclient->conncallback, NULL);
|
||||
+
|
||||
+ if (!op) {
|
||||
Py_INCREF(self);
|
||||
- return PyInt_FromLong(result);
|
||||
+ return PyInt_FromLong(-1);
|
||||
}
|
||||
-
|
||||
- return PyInt_FromLong(result);
|
||||
+
|
||||
+ return PyInt_FromLong(0);
|
||||
}
|
||||
|
||||
static PyObject *pysilc_client_run_one(PyObject *self)
|
||||
@@ -184,12 +184,11 @@ static PyObject *pysilc_client_send_channel_message(Py
|
||||
PyObject *private_key = NULL; // TODO: ignored at the moment
|
||||
unsigned int defaultFlags = SILC_MESSAGE_FLAG_UTF8;
|
||||
unsigned int flags = 0;
|
||||
- bool force_send = 1;
|
||||
PySilcClient *pyclient = (PySilcClient *)self;
|
||||
|
||||
- static char *kwlist[] = {"channel", "msg", "private_key", "flags", "force_send", NULL};
|
||||
+ static char *kwlist[] = {"channel", "msg", "private_key", "flags", NULL};
|
||||
|
||||
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oes#|OIb", kwlist, &channel, "utf-8", &message, &length, &private_key, &flags, &force_send))
|
||||
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oes#|OI", kwlist, &channel, "utf-8", &message, &length, &private_key, &flags))
|
||||
return NULL;
|
||||
|
||||
if (!PyObject_IsInstance((PyObject *)channel, (PyObject *)&PySilcChannel_Type))
|
||||
@@ -205,8 +204,8 @@ static PyObject *pysilc_client_send_channel_message(Py
|
||||
channel->silcobj,
|
||||
NULL,
|
||||
flags | defaultFlags,
|
||||
- message, length,
|
||||
- force_send);
|
||||
+ NULL,
|
||||
+ message, length);
|
||||
|
||||
return PyInt_FromLong(result);
|
||||
}
|
||||
@@ -220,13 +219,12 @@ static PyObject *pysilc_client_send_private_message(Py
|
||||
int result = 0;
|
||||
unsigned int defaultFlags = SILC_MESSAGE_FLAG_UTF8;
|
||||
unsigned int flags = 0;
|
||||
- bool force_send = 1;
|
||||
PySilcClient *pyclient = (PySilcClient *)self;
|
||||
|
||||
|
||||
- static char *kwlist[] = {"user", "message", "flags", "force_send", NULL};
|
||||
+ static char *kwlist[] = {"user", "message", "flags", NULL};
|
||||
|
||||
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oes#|Ib", kwlist, &user, "utf-8", &message, &length, &flags, &force_send))
|
||||
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "Oes#|I", kwlist, &user, "utf-8", &message, &length, &flags))
|
||||
return NULL;
|
||||
|
||||
if (!PyObject_IsInstance((PyObject *)user, (PyObject *)&PySilcUser_Type))
|
||||
@@ -241,9 +239,9 @@ static PyObject *pysilc_client_send_private_message(Py
|
||||
pyclient->silcconn,
|
||||
user->silcobj,
|
||||
flags | defaultFlags,
|
||||
+ NULL,
|
||||
message,
|
||||
- length,
|
||||
- force_send);
|
||||
+ length);
|
||||
|
||||
return PyInt_FromLong(result);
|
||||
}
|
||||
@@ -307,7 +305,6 @@ static PyObject *pysilc_create_key_pair(PyObject *mod,
|
||||
char *pub_identifier = NULL;
|
||||
|
||||
SilcUInt32 key_length = 2048;
|
||||
- SilcPKCS pkcs;
|
||||
SilcPublicKey public_key;
|
||||
SilcPrivateKey private_key;
|
||||
|
||||
@@ -331,13 +328,13 @@ static PyObject *pysilc_create_key_pair(PyObject *mod,
|
||||
|
||||
bool result = silc_create_key_pair(pkcs_name, key_length, pub_filename,
|
||||
prv_filename, pub_identifier, passphrase,
|
||||
- &pkcs, &public_key, &private_key, 0);
|
||||
+ &public_key, &private_key, 0);
|
||||
if (!result) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Unable to generate keys.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- return PySilcKeys_New(pkcs, public_key, private_key);
|
||||
+ return PySilcKeys_New(public_key, private_key);
|
||||
}
|
||||
|
||||
static PyObject *pysilc_load_key_pair(PyObject *mod, PyObject *args, PyObject *kwds)
|
||||
@@ -346,7 +343,6 @@ static PyObject *pysilc_load_key_pair(PyObject *mod, P
|
||||
char *passphrase = NULL;
|
||||
char *pub_filename , *prv_filename;
|
||||
|
||||
- SilcPKCS pkcs;
|
||||
SilcPublicKey public_key;
|
||||
SilcPrivateKey private_key;
|
||||
|
||||
@@ -368,15 +364,14 @@ static PyObject *pysilc_load_key_pair(PyObject *mod, P
|
||||
}
|
||||
|
||||
// Use the passphrase passed.
|
||||
- bool result = silc_load_key_pair(pub_filename, prv_filename,
|
||||
- passphrase,
|
||||
- &pkcs, &public_key, &private_key);
|
||||
-
|
||||
+ bool result = silc_load_key_pair(pub_filename, prv_filename,
|
||||
+ passphrase, &public_key,
|
||||
+ &private_key);
|
||||
+
|
||||
if (!result) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Unable to load keys.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- return PySilcKeys_New(pkcs, public_key, private_key);
|
||||
+ return PySilcKeys_New(public_key, private_key);
|
||||
}
|
||||
-
|
@ -1,654 +0,0 @@
|
||||
$OpenBSD: patch-src_pysilc_callbacks_c,v 1.4 2008/03/23 05:46:29 fgsch Exp $
|
||||
--- src/pysilc_callbacks.c.orig Sun Jul 9 18:18:27 2006
|
||||
+++ src/pysilc_callbacks.c Sun Mar 23 05:38:15 2008
|
||||
@@ -46,6 +46,81 @@
|
||||
#define PYSILC_SILCBUFFER_TO_PYLIST(source, destination, Type) \
|
||||
do { } while (0);
|
||||
|
||||
+static void _pysilc_client_running(SilcClient client,
|
||||
+ void *context)
|
||||
+{
|
||||
+ PYSILC_GET_CLIENT_OR_DIE(client, pyclient);
|
||||
+ PyObject *callback = NULL, *result = NULL;
|
||||
+
|
||||
+ callback = PyObject_GetAttrString((PyObject *)pyclient, "running");
|
||||
+ if (!PyCallable_Check(callback))
|
||||
+ goto cleanup;
|
||||
+ if ((result = PyObject_CallObject(callback, NULL)) == 0)
|
||||
+ PyErr_Print();
|
||||
+
|
||||
+cleanup:
|
||||
+ Py_XDECREF(callback);
|
||||
+ Py_XDECREF(result);
|
||||
+}
|
||||
+
|
||||
+static void _pysilc_client_connect_callback(SilcClient client,
|
||||
+ SilcClientConnection conn,
|
||||
+ SilcClientConnectionStatus status,
|
||||
+ SilcStatus error,
|
||||
+ const char *message,
|
||||
+ void *context)
|
||||
+{
|
||||
+ PYSILC_GET_CLIENT_OR_DIE(client, pyclient);
|
||||
+ PyObject *args = NULL, *callback = NULL, *result = NULL;
|
||||
+
|
||||
+ if ((status == SILC_CLIENT_CONN_SUCCESS) || (status == SILC_CLIENT_CONN_SUCCESS_RESUME)) {
|
||||
+ if (error != SILC_STATUS_OK) {
|
||||
+ // TODO: raise an exception and abort
|
||||
+ // call silc_client_close_connection(client, conn);
|
||||
+ pyclient->silcconn = NULL;
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ pyclient->silcconn = conn;
|
||||
+
|
||||
+ callback = PyObject_GetAttrString((PyObject *)pyclient, "connected");
|
||||
+ if (!PyCallable_Check(callback))
|
||||
+ goto cleanup;
|
||||
+ if ((result = PyObject_CallObject(callback, NULL)) == 0)
|
||||
+ PyErr_Print();
|
||||
+ }
|
||||
+ else if (status == SILC_CLIENT_CONN_DISCONNECTED) {
|
||||
+ if (status != SILC_STATUS_OK) {
|
||||
+ // TODO: raise an exception and abort
|
||||
+ // call silc_client_close_connection(client, conn);
|
||||
+ }
|
||||
+
|
||||
+ // TODO: we're not letting the user know about ClientConnection atm.
|
||||
+ pyclient->silcconn = NULL;
|
||||
+ callback = PyObject_GetAttrString((PyObject *)pyclient, "disconnected");
|
||||
+ if (!PyCallable_Check(callback))
|
||||
+ goto cleanup;
|
||||
+
|
||||
+ if (!(args = Py_BuildValue("(s)", message)))
|
||||
+ goto cleanup;
|
||||
+ if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
+ PyErr_Print();
|
||||
+ }
|
||||
+ else {
|
||||
+ callback = PyObject_GetAttrString((PyObject *)pyclient, "failure");
|
||||
+ if (!PyCallable_Check(callback))
|
||||
+ goto cleanup;
|
||||
+ // TODO: pass on protocol, failure parameters
|
||||
+ if ((result = PyObject_CallObject(callback, NULL)) == 0)
|
||||
+ PyErr_Print();
|
||||
+ }
|
||||
+
|
||||
+cleanup:
|
||||
+ Py_XDECREF(args);
|
||||
+ Py_XDECREF(callback);
|
||||
+ Py_XDECREF(result);
|
||||
+}
|
||||
+
|
||||
static void _pysilc_client_callback_say(SilcClient client,
|
||||
SilcClientConnection conn,
|
||||
SilcClientMessageType type,
|
||||
@@ -72,10 +147,11 @@ cleanup:
|
||||
|
||||
static void _pysilc_client_callback_command(SilcClient client,
|
||||
SilcClientConnection conn,
|
||||
- SilcClientCommandContext cmd_context,
|
||||
- bool success,
|
||||
+ SilcBool success,
|
||||
SilcCommand command,
|
||||
- SilcStatus status)
|
||||
+ SilcStatus status,
|
||||
+ SilcUInt32 argc,
|
||||
+ unsigned char **argv)
|
||||
{
|
||||
PyObject *callback = NULL, *args = NULL, *result = NULL;
|
||||
|
||||
@@ -155,78 +231,26 @@ cleanup:
|
||||
Py_XDECREF(result);
|
||||
}
|
||||
|
||||
-static void _pysilc_client_callback_connected(SilcClient client,
|
||||
- SilcClientConnection conn,
|
||||
- SilcClientConnectionStatus status)
|
||||
-{
|
||||
- PyObject *result = NULL, *callback = NULL;
|
||||
- PYSILC_GET_CLIENT_OR_DIE(client, pyclient);
|
||||
-
|
||||
- if (status != SILC_STATUS_OK) {
|
||||
- // TODO: raise an exception and abort
|
||||
- // call silc_client_close_connection(client, conn);
|
||||
- pyclient->silcconn = NULL;
|
||||
- goto cleanup;
|
||||
- }
|
||||
-
|
||||
-
|
||||
- pyclient->silcconn = conn;
|
||||
-
|
||||
- callback = PyObject_GetAttrString((PyObject *)pyclient, "connected");
|
||||
- if (!PyCallable_Check(callback))
|
||||
- goto cleanup;
|
||||
- if ((result = PyObject_CallObject(callback, NULL)) == 0)
|
||||
- PyErr_Print();
|
||||
-cleanup:
|
||||
- Py_XDECREF(callback);
|
||||
- Py_XDECREF(result);
|
||||
-}
|
||||
-
|
||||
-static void _pysilc_client_callback_disconnected(SilcClient client,
|
||||
- SilcClientConnection conn,
|
||||
- SilcStatus status,
|
||||
- const char *message)
|
||||
-{
|
||||
- PyObject *result = NULL, *callback = NULL, *args = NULL;
|
||||
- PYSILC_GET_CLIENT_OR_DIE(client, pyclient);
|
||||
-
|
||||
- if (status != SILC_STATUS_OK) {
|
||||
- // TODO: raise an exception and abort
|
||||
- // call silc_client_close_connection(client, conn);
|
||||
- }
|
||||
-
|
||||
- // TODO: we're not letting the user know about ClientConnection atm.
|
||||
- pyclient->silcconn = NULL;
|
||||
- callback = PyObject_GetAttrString((PyObject *)pyclient, "disconnected");
|
||||
- if (!PyCallable_Check(callback))
|
||||
- goto cleanup;
|
||||
-
|
||||
- if (!(args = Py_BuildValue("(s)", message)))
|
||||
- goto cleanup;
|
||||
- if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
- PyErr_Print();
|
||||
-cleanup:
|
||||
- Py_XDECREF(callback);
|
||||
- Py_XDECREF(args);
|
||||
- Py_XDECREF(result);
|
||||
-}
|
||||
-
|
||||
typedef struct _PySilcClient_Callback_Join_Context
|
||||
{
|
||||
char *channel_name;
|
||||
char *topic;
|
||||
char *hmac_name;
|
||||
+ char *cipher;
|
||||
PyObject *pychannel;
|
||||
SilcUInt32 channel_mode;
|
||||
- SilcUInt32 user_limit;
|
||||
+ SilcUInt32 user_limit;
|
||||
+ SilcHashTableList *user_list;
|
||||
} PySilcClient_Callback_Join_Context;
|
||||
|
||||
static void _pysilc_client_callback_command_reply_join_finished(SilcClient client,
|
||||
SilcClientConnection conn,
|
||||
- SilcClientEntry *user_list,
|
||||
- SilcUInt32 user_count,
|
||||
- void * context)
|
||||
+ void *context)
|
||||
{
|
||||
+ SilcUInt32 user_count;
|
||||
+ SilcClientEntry user;
|
||||
+ SilcChannelUser user_channel;
|
||||
+
|
||||
PyObject *result = NULL, *callback = NULL, *args = NULL;
|
||||
PyObject *pytopic = NULL, *pyhmac_name = NULL, *users = NULL;
|
||||
PySilcClient_Callback_Join_Context *join_context = NULL;
|
||||
@@ -243,13 +267,16 @@ static void _pysilc_client_callback_command_reply_join
|
||||
|
||||
// extract all the users
|
||||
SilcUInt32 i = 0;
|
||||
- users = PyTuple_New(user_count);
|
||||
- for (i = 0; i < user_count; i++) {
|
||||
- PyObject *u = PySilcUser_New(user_list[i]);
|
||||
+ user_count = silc_hash_table_count(join_context->user_list->ht);
|
||||
+ users = PyTuple_New(user_count);
|
||||
+ i = 0;
|
||||
+ while (silc_hash_table_get(join_context->user_list, (void *)&user, (void *)&user_channel)) {
|
||||
+ PyObject *u = PySilcUser_New(user);
|
||||
PyTuple_SetItem(users, i, u);
|
||||
+ i++;
|
||||
// TODO: we don't DECREF because PyTuple doesn't incr ref count.
|
||||
}
|
||||
-
|
||||
+
|
||||
// prepare some possibly NULL values
|
||||
if (join_context->topic == NULL) {
|
||||
pytopic = Py_None;
|
||||
@@ -292,14 +319,18 @@ static void _pysilc_client_callback_command_reply_join
|
||||
Py_XDECREF(args);
|
||||
Py_XDECREF(result);
|
||||
}
|
||||
-
|
||||
-
|
||||
+
|
||||
+
|
||||
static void _pysilc_client_callback_notify(SilcClient client,
|
||||
SilcClientConnection conn,
|
||||
SilcNotifyType type, ...) {
|
||||
|
||||
PyObject *args = NULL, *result = NULL, *pyuser = NULL, *pychannel = NULL;
|
||||
PyObject *callback = NULL, *pyarg = NULL;
|
||||
+ SilcIdType idtype;
|
||||
+ SilcUInt32 mode;
|
||||
+ void *entry = NULL;
|
||||
+ char *topic = NULL;
|
||||
|
||||
PYSILC_GET_CLIENT_OR_DIE(client, pyclient);
|
||||
va_list va;
|
||||
@@ -357,30 +388,34 @@ static void _pysilc_client_callback_notify(SilcClient
|
||||
break;
|
||||
case SILC_NOTIFY_TYPE_TOPIC_SET:
|
||||
PYSILC_GET_CALLBACK_OR_BREAK("notify_topic_set");
|
||||
- int idtype = va_arg(va, int);
|
||||
- void *entry = va_arg(va, void *);
|
||||
- char *topic = va_arg(va, char *);
|
||||
+ idtype = va_arg(va, int);
|
||||
+ entry = va_arg(va, void *);
|
||||
+ topic = va_arg(va, char *);
|
||||
PYSILC_NEW_CHANNEL_OR_BREAK(va_arg(va, SilcChannelEntry), pychannel);
|
||||
|
||||
switch (idtype) {
|
||||
- case SILC_ID_CLIENT:
|
||||
- PYSILC_NEW_USER_OR_BREAK(entry, pyuser);
|
||||
- if ((args = Py_BuildValue("(iOOs)", idtype, pyuser, pychannel, topic)) == NULL)
|
||||
+ case SILC_ID_CLIENT:
|
||||
+ PYSILC_NEW_USER_OR_BREAK(entry, pyarg);
|
||||
break;
|
||||
- if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
- PyErr_Print();
|
||||
- break;
|
||||
- case SILC_ID_CHANNEL:
|
||||
- PYSILC_NEW_CHANNEL_OR_BREAK(entry, pyarg);
|
||||
- if ((args = Py_BuildValue("(iOOs)", idtype, pyarg, pychannel, topic)) == NULL)
|
||||
+ case SILC_ID_CHANNEL:
|
||||
+ PYSILC_NEW_CHANNEL_OR_BREAK(entry, pyarg);
|
||||
break;
|
||||
- if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
- PyErr_Print();
|
||||
- break;
|
||||
- case SILC_ID_SERVER:
|
||||
- // TODO: Unimplemented
|
||||
- break;
|
||||
+ case SILC_ID_SERVER:
|
||||
+ pyarg = Py_None;
|
||||
+ Py_INCREF(pyarg); // TODO: no server type
|
||||
+ break;
|
||||
}
|
||||
+
|
||||
+ args = Py_BuildValue("(iOOs)",
|
||||
+ idtype,
|
||||
+ pyarg,
|
||||
+ pychannel,
|
||||
+ topic);
|
||||
+
|
||||
+ if (args == NULL)
|
||||
+ break;
|
||||
+ if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
+ PyErr_Print();
|
||||
break;
|
||||
|
||||
case SILC_NOTIFY_TYPE_NICK_CHANGE:
|
||||
@@ -394,30 +429,80 @@ static void _pysilc_client_callback_notify(SilcClient
|
||||
break;
|
||||
|
||||
case SILC_NOTIFY_TYPE_CMODE_CHANGE:
|
||||
- /*
|
||||
- if (!PyCallable_Check(pyclient->notify_cmode_change))
|
||||
- break;
|
||||
+ PYSILC_GET_CALLBACK_OR_BREAK("notify_cmode_change");
|
||||
+ idtype = va_arg(va, int);
|
||||
+ entry = va_arg(va, void *);
|
||||
+ mode = va_arg(va, SilcUInt32);
|
||||
+ char *cipher_name = va_arg(va, char *);
|
||||
+ char *hmac_name = va_arg(va, char *);
|
||||
+ char *passphrase = va_arg(va, char *);
|
||||
+ SilcPublicKey founder_key = va_arg(va, SilcPublicKey);
|
||||
+ SilcBuffer channel_pubkeys = va_arg(va, SilcBuffer);
|
||||
PYSILC_NEW_CHANNEL_OR_BREAK(va_arg(va, SilcChannelEntry), pychannel);
|
||||
- PYSILC_NEW_USER_OR_BREAK(va_arg(va, SilcClientEntry), pyuser);
|
||||
- if ((args = Py_BuildValue("(IOO)", status, pychannel, pyuser)) == NULL)
|
||||
+
|
||||
+ switch (idtype) {
|
||||
+ case SILC_ID_CLIENT:
|
||||
+ PYSILC_NEW_USER_OR_BREAK(entry, pyarg);
|
||||
+ break;
|
||||
+ case SILC_ID_CHANNEL:
|
||||
+ PYSILC_NEW_CHANNEL_OR_BREAK(entry, pyarg);
|
||||
+ break;
|
||||
+ case SILC_ID_SERVER:
|
||||
+ pyarg = Py_None; // TODO: no server objects
|
||||
+ Py_INCREF(Py_None);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ args = Py_BuildValue("(iOOissss)",
|
||||
+ idtype,
|
||||
+ pyarg,
|
||||
+ mode,
|
||||
+ cipher_name,
|
||||
+ hmac_name,
|
||||
+ passphrase,
|
||||
+ Py_None,
|
||||
+ Py_None,
|
||||
+ pychannel);
|
||||
+
|
||||
+ if (args == NULL)
|
||||
break;
|
||||
|
||||
- result = PyObject_CallObject(pyclient->notify_cmode_change, args);
|
||||
- */
|
||||
- // TODO: wrong implementation
|
||||
+ if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
+ PyErr_Print();
|
||||
break;
|
||||
|
||||
case SILC_NOTIFY_TYPE_CUMODE_CHANGE:
|
||||
- /*
|
||||
- if (!PyCallable_Check(pyclient->notify_cumode_change))
|
||||
- break;
|
||||
+ PYSILC_GET_CALLBACK_OR_BREAK("notify_cumode_change");
|
||||
+ idtype = va_arg(va, int);
|
||||
+ entry = va_arg(va, void *);
|
||||
+ mode = va_arg(va, SilcUInt32);
|
||||
PYSILC_NEW_CHANNEL_OR_BREAK(va_arg(va, SilcChannelEntry), pychannel);
|
||||
PYSILC_NEW_USER_OR_BREAK(va_arg(va, SilcClientEntry), pyuser);
|
||||
- if ((args = Py_BuildValue("(IOO)", status, pychannel, pyuser)) == NULL)
|
||||
+ switch (idtype) {
|
||||
+ case SILC_ID_CLIENT:
|
||||
+ PYSILC_NEW_USER_OR_BREAK(entry, pyarg);
|
||||
break;
|
||||
- result = PyObject_CallObject(pyclient->notify_cumode_change, args);
|
||||
- */
|
||||
- // TODO: wrong implementation
|
||||
+ case SILC_ID_CHANNEL:
|
||||
+ PYSILC_NEW_CHANNEL_OR_BREAK(entry, pyarg);
|
||||
+ break;
|
||||
+ case SILC_ID_SERVER:
|
||||
+ pyarg = Py_None; // TODO: no server objects
|
||||
+ Py_INCREF(Py_None);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ args = Py_BuildValue("(iOiOO)",
|
||||
+ idtype,
|
||||
+ pyarg,
|
||||
+ mode,
|
||||
+ pychannel,
|
||||
+ pyuser);
|
||||
+
|
||||
+ if (args == NULL)
|
||||
+ break;
|
||||
+
|
||||
+ if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
+ PyErr_Print();
|
||||
break;
|
||||
|
||||
case SILC_NOTIFY_TYPE_MOTD:
|
||||
@@ -444,9 +529,8 @@ static void _pysilc_client_callback_notify(SilcClient
|
||||
|
||||
case SILC_NOTIFY_TYPE_KICKED:
|
||||
PYSILC_GET_CALLBACK_OR_BREAK("notify_kicked");
|
||||
- char *message;
|
||||
- PYSILC_NEW_USER_OR_BREAK(va_arg(va, SilcClientEntry), pyarg);
|
||||
- message = va_arg(va, char *);
|
||||
+ PYSILC_NEW_USER_OR_BREAK(va_arg(va, SilcClientEntry), pyarg);
|
||||
+ char *message = va_arg(va, char *);
|
||||
PYSILC_NEW_USER_OR_BREAK(va_arg(va, SilcClientEntry), pyuser);
|
||||
PYSILC_NEW_CHANNEL_OR_BREAK(va_arg(va, SilcChannelEntry), pychannel);
|
||||
|
||||
@@ -457,7 +541,37 @@ static void _pysilc_client_callback_notify(SilcClient
|
||||
break;
|
||||
|
||||
case SILC_NOTIFY_TYPE_KILLED:
|
||||
- break; // TODO: Unimplemented
|
||||
+ PYSILC_GET_CALLBACK_OR_BREAK("notify_killed");
|
||||
+ PYSILC_NEW_USER_OR_BREAK(va_arg(va, SilcClientEntry), pyuser);
|
||||
+ char *kill_message = va_arg(va, char *);
|
||||
+ idtype = va_arg(va, int);
|
||||
+ entry = va_arg(va, void *);
|
||||
+ PYSILC_NEW_CHANNEL_OR_BREAK(va_arg(va, SilcChannelEntry), pychannel);
|
||||
+ switch (idtype) {
|
||||
+ case SILC_ID_CLIENT:
|
||||
+ PYSILC_NEW_USER_OR_BREAK(entry, pyarg);
|
||||
+ break;
|
||||
+ case SILC_ID_CHANNEL:
|
||||
+ PYSILC_NEW_CHANNEL_OR_BREAK(entry, pyarg);
|
||||
+ break;
|
||||
+ case SILC_ID_SERVER:
|
||||
+ pyarg = Py_None; // TODO: no server objects
|
||||
+ Py_INCREF(Py_None);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ args = Py_BuildValue("(OsOO)",
|
||||
+ pyuser, // client that was killed
|
||||
+ kill_message,
|
||||
+ pyarg, // the killer, either a SilcClient or SilcChannel or None
|
||||
+ pychannel);
|
||||
+
|
||||
+ if (args == NULL)
|
||||
+ break;
|
||||
+
|
||||
+ if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
+ PyErr_Print();
|
||||
+ break;
|
||||
|
||||
case SILC_NOTIFY_TYPE_ERROR:
|
||||
PYSILC_GET_CALLBACK_OR_BREAK("notify_error");
|
||||
@@ -494,30 +608,27 @@ static void _pysilc_client_callback_notify(SilcClient
|
||||
|
||||
|
||||
|
||||
-static void _pysilc_client_callback_command_reply(SilcClient client,
|
||||
+static void _pysilc_client_callback_command_reply(SilcClient client,
|
||||
SilcClientConnection conn,
|
||||
- SilcCommandPayload cmd_payload,
|
||||
- bool success,
|
||||
- SilcCommand command,
|
||||
- SilcStatus status, ...)
|
||||
+ SilcCommand command,
|
||||
+ SilcStatus status,
|
||||
+ SilcStatus error, va_list va)
|
||||
{
|
||||
PyObject *args = NULL, *result = NULL, *pyuser = NULL, *pychannel = NULL;
|
||||
PyObject *callback = NULL, *pyarg = NULL;
|
||||
|
||||
PYSILC_GET_CLIENT_OR_DIE(client, pyclient);
|
||||
- va_list va;
|
||||
- va_start(va, status);
|
||||
|
||||
- if (!success) {
|
||||
- // we encounter an error, return the command and status
|
||||
+ if (status != SILC_STATUS_OK) {
|
||||
+ // we encounter an error, return the command and error
|
||||
callback = PyObject_GetAttrString((PyObject *)pyclient,
|
||||
"command_reply_failed");
|
||||
if (!PyCallable_Check(callback))
|
||||
return;
|
||||
if (!(args = Py_BuildValue("(isis)", command,
|
||||
silc_get_command_name(command),
|
||||
- status,
|
||||
- silc_get_status_message(status)))) {
|
||||
+ error,
|
||||
+ silc_get_status_message(error)))) {
|
||||
Py_DECREF(callback);
|
||||
return;
|
||||
}
|
||||
@@ -677,7 +788,6 @@ static void _pysilc_client_callback_command_reply(Silc
|
||||
case SILC_COMMAND_PING:
|
||||
{
|
||||
PYSILC_GET_CALLBACK_OR_BREAK("command_reply_ping");
|
||||
- printf("command ping callback found\n") ;
|
||||
if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
PyErr_Print();
|
||||
break;
|
||||
@@ -696,14 +806,11 @@ static void _pysilc_client_callback_command_reply(Silc
|
||||
memset(context, 0, sizeof(PySilcClient_Callback_Join_Context));
|
||||
if (!context)
|
||||
break;
|
||||
-
|
||||
+
|
||||
char *tmpstr = NULL;
|
||||
- int ignored;
|
||||
- void *dummy;
|
||||
SilcUInt32 client_count;
|
||||
SilcBuffer client_list;
|
||||
-
|
||||
-
|
||||
+
|
||||
tmpstr = va_arg(va, char *);
|
||||
if (tmpstr)
|
||||
context->channel_name = strdup(tmpstr);
|
||||
@@ -711,27 +818,19 @@ static void _pysilc_client_callback_command_reply(Silc
|
||||
context->pychannel = pychannel;
|
||||
Py_INCREF(pychannel);
|
||||
context->channel_mode = va_arg(va, SilcUInt32);
|
||||
- ignored = va_arg(va, int); // ignored: ignore
|
||||
- dummy = va_arg(va, void *); // ignored: key_payload
|
||||
- dummy = va_arg(va, void *); // NULL
|
||||
- dummy = va_arg(va, void *); // NULL
|
||||
+ context->user_list = va_arg(va, SilcHashTableList *);
|
||||
tmpstr = va_arg(va, char *);
|
||||
if (tmpstr)
|
||||
context->topic = strdup(tmpstr);
|
||||
tmpstr = va_arg(va, char *);
|
||||
+ context->cipher = strdup(tmpstr);
|
||||
+ tmpstr = va_arg(va, char *);
|
||||
if (tmpstr)
|
||||
context->hmac_name = strdup(tmpstr);
|
||||
- client_count = va_arg(va, SilcUInt32);
|
||||
- client_list = va_arg(va, SilcBuffer);
|
||||
- dummy = va_arg(va, void *); // TODO: SilcBuffer client_mode_list
|
||||
- dummy = va_arg(va, void *); // TODO: SilcPublicKey founder_key
|
||||
- dummy = va_arg(va, void *); // TODO: SilcBuffer channel_pubkeys
|
||||
context->user_limit = va_arg(va, SilcUInt32);
|
||||
-
|
||||
- silc_client_get_clients_by_list(client, conn,
|
||||
- client_count, client_list,
|
||||
- _pysilc_client_callback_command_reply_join_finished,
|
||||
- context);
|
||||
+
|
||||
+ _pysilc_client_callback_command_reply_join_finished(client, conn, context);
|
||||
+
|
||||
break;
|
||||
}
|
||||
case SILC_COMMAND_MOTD:
|
||||
@@ -832,21 +931,19 @@ static void _pysilc_client_callback_command_reply(Silc
|
||||
PYSILC_NEW_CHANNEL_OR_BREAK(va_arg(va, SilcChannelEntry), pychannel);
|
||||
|
||||
// get all users from this channel .. tedious
|
||||
- SilcUInt32 user_count = va_arg(va, SilcUInt32);
|
||||
- pyuser = PyTuple_New(user_count); // hijack pyuser so we get autocleanup
|
||||
int i = 0;
|
||||
SilcHashTableList hash_list;
|
||||
SilcClientEntry user, cached;
|
||||
SilcChannelUser user_channel;
|
||||
PyObject *u = NULL;
|
||||
SilcChannelEntry channel = ((PySilcChannel *)pychannel)->silcobj;
|
||||
+ SilcUInt32 user_count = silc_hash_table_count(channel->user_list);
|
||||
+ pyuser = PyTuple_New(user_count); // hijack pyuser so we get autocleanup
|
||||
|
||||
- printf("user: %d\n", user_count);
|
||||
-
|
||||
if (channel && channel->user_list) {
|
||||
silc_hash_table_list(channel->user_list, &hash_list);
|
||||
while (silc_hash_table_get(&hash_list, (void *)&user, (void *)&user_channel)) {
|
||||
- cached = silc_client_get_client_by_id(client, conn, user->id);
|
||||
+ cached = silc_client_get_client_by_id(client, conn, &(user->id));
|
||||
if (cached) {
|
||||
u = PySilcUser_New(cached);
|
||||
PyTuple_SetItem(pyuser, i, u);
|
||||
@@ -880,60 +977,37 @@ cleanup:
|
||||
Py_XDECREF(pyuser);
|
||||
}
|
||||
|
||||
-static void _pysilc_client_callback_verify_key(SilcClient client,
|
||||
+static void _pysilc_client_callback_verify_key(SilcClient client,
|
||||
SilcClientConnection conn,
|
||||
- SilcSocketType conn_type,
|
||||
- unsigned char *pk,
|
||||
- SilcUInt32 pk_len,
|
||||
- SilcSKEPKType pk_type,
|
||||
- SilcVerifyPublicKey completion,
|
||||
+ SilcConnectionType conn_type,
|
||||
+ SilcPublicKey public_key,
|
||||
+ SilcVerifyPublicKey completion,
|
||||
void *context)
|
||||
{
|
||||
// TODO: implement me
|
||||
completion(TRUE, context);
|
||||
}
|
||||
|
||||
-static void _pysilc_client_callback_get_auth_method(SilcClient client,
|
||||
+static void _pysilc_client_callback_get_auth_method(SilcClient client,
|
||||
SilcClientConnection conn,
|
||||
- char *hostname,
|
||||
+ char *hostname,
|
||||
SilcUInt16 port,
|
||||
- SilcGetAuthMeth completion,
|
||||
+ SilcAuthMethod auth_method,
|
||||
+ SilcGetAuthMeth completion,
|
||||
void *context)
|
||||
{
|
||||
// TODO: implement this properly
|
||||
- completion(TRUE, SILC_AUTH_PUBLIC_KEY, NULL, 0, context);
|
||||
+ completion(SILC_AUTH_PUBLIC_KEY, NULL, 0, context);
|
||||
}
|
||||
|
||||
-static void _pysilc_client_callback_failure(SilcClient client,
|
||||
- SilcClientConnection conn,
|
||||
- SilcProtocol protocol,
|
||||
- void *failure)
|
||||
+static void _pysilc_client_callback_key_agreement(SilcClient client,
|
||||
+ SilcClientConnection conn,
|
||||
+ SilcClientEntry client_entry,
|
||||
+ const char *hostname,
|
||||
+ SilcUInt16 protocol,
|
||||
+ SilcUInt16 port)
|
||||
{
|
||||
- PYSILC_GET_CLIENT_OR_DIE(client, pyclient);
|
||||
- PyObject *callback = NULL, *result = NULL;
|
||||
-
|
||||
- callback = PyObject_GetAttrString((PyObject *)pyclient, "failure");
|
||||
- if (!PyCallable_Check(callback))
|
||||
- goto cleanup;
|
||||
- // TODO: pass on protocol, failure parameters
|
||||
- if ((result = PyObject_CallObject(callback, NULL)) == 0)
|
||||
- PyErr_Print();
|
||||
-cleanup:
|
||||
- Py_XDECREF(callback);
|
||||
- Py_XDECREF(result);
|
||||
-}
|
||||
-
|
||||
-
|
||||
-static bool _pysilc_client_callback_key_agreement(SilcClient client,
|
||||
- SilcClientConnection conn,
|
||||
- SilcClientEntry client_entry,
|
||||
- const char *hostname,
|
||||
- SilcUInt16 port,
|
||||
- SilcKeyAgreementCallback *completion,
|
||||
- void **context)
|
||||
-{
|
||||
// TODO :implement me
|
||||
- return FALSE;
|
||||
}
|
||||
|
||||
static void _pysilc_client_callback_ftp(SilcClient client,
|
||||
@@ -973,25 +1047,3 @@ cleanup:
|
||||
Py_XDECREF(callback);
|
||||
Py_XDECREF(result);
|
||||
}
|
||||
-
|
||||
-static void _pysilc_client_callback_detach(SilcClient client,
|
||||
- SilcClientConnection conn,
|
||||
- const unsigned char *detach_data,
|
||||
- SilcUInt32 detach_data_len)
|
||||
-{
|
||||
- PYSILC_GET_CLIENT_OR_DIE(client, pyclient);
|
||||
- PyObject *result = NULL, *callback = NULL, *args = NULL;
|
||||
- callback = PyObject_GetAttrString((PyObject *)pyclient, "detach");
|
||||
- if (!PyCallable_Check(callback))
|
||||
- goto cleanup;
|
||||
-
|
||||
- if (!(args = Py_BuildValue("(s#)", detach_data, detach_data_len)))
|
||||
- goto cleanup;
|
||||
- if ((result = PyObject_CallObject(callback, args)) == 0)
|
||||
- PyErr_Print();
|
||||
-
|
||||
-cleanup:
|
||||
- Py_XDECREF(callback);
|
||||
- Py_XDECREF(args);
|
||||
- Py_XDECREF(result);
|
||||
-}
|
@ -1,59 +0,0 @@
|
||||
$OpenBSD: patch-src_pysilc_channel_c,v 1.3 2007/10/02 17:35:48 martynas Exp $
|
||||
--- src/pysilc_channel.c.orig Sun Jul 9 20:18:40 2006
|
||||
+++ src/pysilc_channel.c Sun Jul 1 22:52:11 2007
|
||||
@@ -40,7 +40,6 @@ static PyObject *PySilcChannel_GetAttr(PyObject *self,
|
||||
// - (TODO) founder_key
|
||||
// - unsigned int user_limit
|
||||
// - (TODO) user_list
|
||||
- // - int resolve_cmd_ident
|
||||
|
||||
int result;
|
||||
PyObject *temp = NULL, *value = NULL;
|
||||
@@ -85,7 +84,7 @@ static PyObject *PySilcChannel_GetAttr(PyObject *self,
|
||||
goto cleanup;
|
||||
if (result == 0) {
|
||||
char buf[160];
|
||||
- memcpy(&buf, (pychannel->silcobj->id), 160);
|
||||
+ memcpy(&buf, &(pychannel->silcobj->id), 160);
|
||||
value = PyString_FromStringAndSize(buf, 160);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -110,16 +109,6 @@ static PyObject *PySilcChannel_GetAttr(PyObject *self,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- // check for resolve_cmd_ident
|
||||
- Py_DECREF(temp);
|
||||
- temp = PyString_FromString("resolve_cmd_ident");
|
||||
- if (PyObject_Cmp(temp, name, &result) == -1)
|
||||
- goto cleanup;
|
||||
- if (result == 0) {
|
||||
- value = PyInt_FromLong(pychannel->silcobj->resolve_cmd_ident);
|
||||
- goto cleanup;
|
||||
- }
|
||||
-
|
||||
cleanup:
|
||||
Py_XDECREF(temp);
|
||||
if (value)
|
||||
@@ -155,13 +144,12 @@ static int PySilcChannel_Compare(PyObject *self, PyObj
|
||||
}
|
||||
|
||||
|
||||
-static PyObject *PySilcKeys_New(SilcPKCS pkcs, SilcPublicKey public, SilcPrivateKey private)
|
||||
+static PyObject *PySilcKeys_New(SilcPublicKey public, SilcPrivateKey private)
|
||||
{
|
||||
PySilcKeys *pykeys = (PySilcKeys *)PyObject_New(PySilcKeys, &PySilcKeys_Type);
|
||||
if (!pykeys)
|
||||
return NULL;
|
||||
|
||||
- pykeys->pkcs = pkcs;
|
||||
pykeys->private = private;
|
||||
pykeys->public = public;
|
||||
|
||||
@@ -171,6 +159,5 @@ static PyObject *PySilcKeys_New(SilcPKCS pkcs, SilcPub
|
||||
static void PySilcKeys_Del(PyObject *object)
|
||||
{
|
||||
// TODO: free them properly
|
||||
- //silc_pkcs_free((PySilcKeys *)object)->pkcs);
|
||||
PyObject_Del(object);
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
$OpenBSD: patch-src_pysilc_h,v 1.4 2007/10/02 17:35:48 martynas Exp $
|
||||
--- src/pysilc.h.orig Mon Jul 10 11:42:36 2006
|
||||
+++ src/pysilc.h Sun Jul 1 22:52:11 2007
|
||||
@@ -22,7 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include "pysilc_macros.h"
|
||||
-#include <silcincludes.h>
|
||||
+#include <silc.h>
|
||||
#include <silcclient.h>
|
||||
#include <silctypes.h>
|
||||
|
||||
@@ -40,7 +40,6 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
- SilcPKCS pkcs;
|
||||
SilcPublicKey public;
|
||||
SilcPrivateKey private;
|
||||
} PySilcKeys;
|
||||
@@ -107,9 +106,11 @@ typedef struct {
|
||||
*ftp,
|
||||
*detach;
|
||||
|
||||
- SilcClient silcobj;
|
||||
- SilcClientConnection silcconn;
|
||||
- SilcClientOperations callbacks;
|
||||
+ SilcClient silcobj;
|
||||
+ SilcClientConnection silcconn;
|
||||
+ SilcClientConnectCallback conncallback;
|
||||
+ SilcClientOperations callbacks;
|
||||
+ SilcClientConnectionParams params;
|
||||
|
||||
} PySilcClient;
|
||||
|
||||
@@ -182,7 +183,7 @@ static PyMemberDef pysilc_user_members[] = {
|
||||
|
||||
/* ---------------- pysilc keys ------------- */
|
||||
|
||||
-static PyObject *PySilcKeys_New(SilcPKCS pkcs, SilcPublicKey public, SilcPrivateKey private);
|
||||
+static PyObject *PySilcKeys_New(SilcPublicKey public, SilcPrivateKey private);
|
||||
static void PySilcKeys_Del(PyObject *object);
|
||||
|
||||
static PyMethodDef pysilc_keys_methods[] = {
|
||||
@@ -227,9 +228,8 @@ static PyMethodDef pysilc_client_methods[] = {
|
||||
(PyCFunction)pysilc_client_send_channel_message,
|
||||
METH_VARARGS | METH_KEYWORDS,
|
||||
"send_channel_message(channel, messsage, private_key = None,\n"
|
||||
- " flags = 0, force_send = False)\n\n"
|
||||
+ " flags = 0)\n\n"
|
||||
"Send a message (Unicode string) to a channel (SilcChannel object).\n"
|
||||
- "Setting 'force_send' to True means send the packet immediately\n."
|
||||
"TODO: flags and private_key support not implemented.\n"
|
||||
},
|
||||
{
|
||||
@@ -237,9 +237,8 @@ static PyMethodDef pysilc_client_methods[] = {
|
||||
(PyCFunction)pysilc_client_send_private_message,
|
||||
METH_VARARGS | METH_KEYWORDS,
|
||||
"send_private_message(user, messsage, private_key = None,\n"
|
||||
- " flags = 0, force_send = False)\n\n"
|
||||
+ " flags = 0)\n\n"
|
||||
"Send a message (Unicode string) to a user (SilcUser object).\n"
|
||||
- "Setting 'force_send' to True means send the packet immediately\n."
|
||||
"TODO: flags and private_key support not implemented.\n"
|
||||
},
|
||||
{
|
||||
@@ -402,7 +401,8 @@ static PyMemberDef pysilc_client_members[] = {
|
||||
};
|
||||
|
||||
#define PYSILC_CLIENT_DOC "\
|
||||
- SilcClient(keys, nickname = \"\", username = \"\",\n\ realname = \"\",\
|
||||
+ SilcClient(keys, nickname = \"\", username = \"\",\n\
|
||||
+ realname = \"\",\
|
||||
hostname = \"\")\n\n\
|
||||
A SILC Client. 'keys' is a SilcKeys representing a public private\n\
|
||||
key pair. 'nickname', 'username', 'realname' and 'hostname'\n\
|
||||
@@ -461,8 +461,7 @@ Attributes accessible:\n\n\
|
||||
channel_id = string (64-160bit)\n\n\
|
||||
mode = int\n\n\
|
||||
topic = string\n\n\
|
||||
- user_limit = int \n\n\
|
||||
- resolve_cmd_ident = int"
|
||||
+ user_limit = int"
|
||||
|
||||
static PyTypeObject PySilcChannel_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
||||
@@ -514,11 +513,8 @@ Accessible Attributes:\n\n\
|
||||
server = string\n\n\
|
||||
realname = string\n\n\
|
||||
fingerprint = string\n\n\
|
||||
- fingerprint_len = int\n\n\
|
||||
user_id = string (64/160bit)\n\n\
|
||||
- mode = int\n\n\
|
||||
- status = int\n\n\
|
||||
- resolve_cmd_ident = int"
|
||||
+ mode = int"
|
||||
|
||||
static PyTypeObject PySilcUser_Type = {
|
||||
PyObject_HEAD_INIT(&PyType_Type)
|
@ -1,64 +0,0 @@
|
||||
$OpenBSD: patch-src_pysilc_user_c,v 1.3 2007/10/02 17:35:48 martynas Exp $
|
||||
--- src/pysilc_user.c.orig Sun Jul 9 20:18:34 2006
|
||||
+++ src/pysilc_user.c Sun Jul 1 22:52:11 2007
|
||||
@@ -39,15 +39,12 @@ static PyObject *PySilcUser_GetAttr(PyObject *self, Py
|
||||
// - char *server
|
||||
// - char *realname
|
||||
// - unsigned char *fingerprint;
|
||||
- // SilcUInt32 finderprint_len;
|
||||
//
|
||||
// - 64/160 bit user id
|
||||
// - unsigned int mode
|
||||
// - (TODO) attrs;
|
||||
// - (TODO) public_key;
|
||||
- // - int status
|
||||
// - (TODO) channels
|
||||
- // - int resolve_cmd_ident;
|
||||
|
||||
int result;
|
||||
PyObject *temp = NULL, *value = NULL;
|
||||
@@ -137,7 +134,7 @@ static PyObject *PySilcUser_GetAttr(PyObject *self, Py
|
||||
goto cleanup;
|
||||
if (result == 0) {
|
||||
if (pyuser->silcobj->fingerprint)
|
||||
- value = PyString_FromStringAndSize(pyuser->silcobj->fingerprint, pyuser->silcobj->fingerprint_len);
|
||||
+ value = PyString_FromStringAndSize(pyuser->silcobj->fingerprint, 20);
|
||||
else {
|
||||
value = Py_None;
|
||||
Py_INCREF(value);
|
||||
@@ -152,7 +149,7 @@ static PyObject *PySilcUser_GetAttr(PyObject *self, Py
|
||||
goto cleanup;
|
||||
if (result == 0) {
|
||||
char buf[224];
|
||||
- memcpy(&buf, (pyuser->silcobj->id), 224);
|
||||
+ memcpy(&buf, &(pyuser->silcobj->id), 224);
|
||||
value = PyString_FromStringAndSize(buf, 224);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -164,26 +161,6 @@ static PyObject *PySilcUser_GetAttr(PyObject *self, Py
|
||||
goto cleanup;
|
||||
if (result == 0) {
|
||||
value = PyInt_FromLong(pyuser->silcobj->mode);
|
||||
- goto cleanup;
|
||||
- }
|
||||
-
|
||||
- // check for status
|
||||
- Py_DECREF(temp);
|
||||
- temp = PyString_FromString("status");
|
||||
- if (PyObject_Cmp(temp, name, &result) == -1)
|
||||
- goto cleanup;
|
||||
- if (result == 0) {
|
||||
- value = PyInt_FromLong(pyuser->silcobj->status);
|
||||
- goto cleanup;
|
||||
- }
|
||||
-
|
||||
- // check for resolve_cmd_ident
|
||||
- Py_DECREF(temp);
|
||||
- temp = PyString_FromString("resolve_cmd_ident");
|
||||
- if (PyObject_Cmp(temp, name, &result) == -1)
|
||||
- goto cleanup;
|
||||
- if (result == 0) {
|
||||
- value = PyInt_FromLong(pyuser->silcobj->resolve_cmd_ident);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2006/10/09 13:10:34 alek Exp $
|
||||
@comment $OpenBSD: PLIST,v 1.2 2008/07/08 21:29:20 martynas Exp $
|
||||
lib/python${MODPY_VERSION}/site-packages/pysilc-0.5-py${MODPY_VERSION}.egg-info
|
||||
lib/python${MODPY_VERSION}/site-packages/silc.so
|
||||
share/doc/py-silc/
|
||||
share/doc/py-silc/README
|
||||
|
Loading…
Reference in New Issue
Block a user