changeset 23658:9d7ebd28d339

Another Perl patch from Zsombor Welker to add more functions. Fixes #5957
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 07 Aug 2008 04:03:23 +0000
parents ae3263bfd3f5
children f441a38932a2
files libpurple/plugins/perl/common/Certificate.xs libpurple/plugins/perl/common/Idle.xs libpurple/plugins/perl/common/Makefile.mingw libpurple/plugins/perl/common/Purple.xs libpurple/plugins/perl/common/Whiteboard.xs libpurple/plugins/perl/common/module.h libpurple/plugins/perl/common/typemap
diffstat 7 files changed, 428 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/plugins/perl/common/Certificate.xs	Thu Aug 07 04:03:23 2008 +0000
@@ -0,0 +1,302 @@
+#include "module.h"
+
+struct cb_data {
+	SV *cb;
+	SV *user_data;
+};
+
+static void cb_cert_verify(PurpleCertificateVerificationStatus st, struct cb_data *d) {
+	dSP;
+
+	ENTER;
+	SAVETMPS;
+
+	PUSHMARK(SP);
+
+	XPUSHs(sv_2mortal(newSViv(st)));
+	XPUSHs(d->user_data);
+
+	PUTBACK;
+
+	call_sv(d->cb, G_VOID | G_EVAL);
+
+	if(SvTRUE(ERRSV)) {
+		STRLEN l_a;
+		purple_debug_warning("perl", "Failed to run 'certificate verify' callback: %s\n", SvPV(ERRSV, l_a));
+	}
+
+	FREETMPS;
+	LEAVE;
+
+	SvREFCNT_dec(d->cb);
+	SvREFCNT_dec(d->user_data);
+
+	g_free(d);
+}
+
+MODULE = Purple::Certificate  PACKAGE = Purple::Certificate  PREFIX = purple_certificate_
+PROTOTYPES: ENABLE
+
+BOOT:
+{
+	HV *stash = gv_stashpv("Purple::Certificate", 1);
+
+	static const constiv *civ, const_iv[] = {
+#define const_iv(name) {#name, (IV)PURPLE_CERTIFICATE_##name}
+		const_iv(INVALID),
+		const_iv(VALID),
+	};
+
+	for (civ = const_iv + sizeof(const_iv) / sizeof(const_iv[0]); civ-- > const_iv; )
+		newCONSTSUB(stash, (char *)civ->name, newSViv(civ->iv));
+}
+
+void
+purple_certificate_add_ca_search_path(path)
+	const char* path
+
+gboolean
+purple_certificate_check_subject_name(crt, name)
+	Purple::Certificate crt
+	const gchar* name
+
+Purple::Certificate
+purple_certificate_copy(crt)
+	Purple::Certificate crt
+
+void
+purple_certificate_destroy(crt)
+	Purple::Certificate crt
+
+void
+purple_certificate_display_x509(crt)
+	Purple::Certificate crt
+
+## changed order of arguments, so that $cert->export($file) could be used
+gboolean
+purple_certificate_export(crt, filename)
+	const gchar* filename
+	Purple::Certificate crt
+	C_ARGS:
+		filename, crt
+
+Purple::Certificate::Pool
+purple_certificate_find_pool(scheme_name, pool_name)
+	const gchar* scheme_name
+	const gchar* pool_name
+
+Purple::Certificate::Scheme
+purple_certificate_find_scheme(name)
+	const gchar* name
+
+Purple::Certificate::Verifier
+purple_certificate_find_verifier(scheme_name, ver_name)
+	const gchar* scheme_name
+	const gchar* ver_name
+
+Purple::Handle
+purple_certificate_get_handle()
+
+gchar_own*
+purple_certificate_get_issuer_unique_id(crt)
+	Purple::Certificate crt
+
+gchar_own*
+purple_certificate_get_subject_name(crt)
+	Purple::Certificate crt
+
+gchar_own*
+purple_certificate_get_unique_id(crt)
+	Purple::Certificate crt
+
+Purple::Certificate
+purple_certificate_import(scheme, filename)
+	Purple::Certificate::Scheme scheme
+	const gchar* filename
+
+gboolean
+purple_certificate_register_pool(pool)
+	Purple::Certificate::Pool pool
+
+gboolean
+purple_certificate_register_scheme(scheme)
+	Purple::Certificate::Scheme scheme
+
+gboolean
+purple_certificate_register_verifier(vr)
+	Purple::Certificate::Verifier vr
+
+gboolean
+purple_certificate_signed_by(crt, issuer)
+	Purple::Certificate crt
+	Purple::Certificate issuer
+
+gboolean
+purple_certificate_unregister_pool(pool)
+	Purple::Certificate::Pool pool
+
+gboolean
+purple_certificate_unregister_scheme(scheme)
+	Purple::Certificate::Scheme scheme
+
+gboolean
+purple_certificate_unregister_verifier(vr)
+	Purple::Certificate::Verifier vr
+
+void
+purple_certificate_verify_complete(vrq, st)
+	Purple::Certificate::VerificationRequest vrq
+	Purple::Certificate::VerificationStatus st
+
+gboolean
+purple_certificate_get_times(crt, OUTLIST time_t activation, OUTLIST time_t expiration)
+	Purple::Certificate crt
+	PROTOTYPE: $
+
+void
+purple_certificate_destroy_list(...)
+	PREINIT:
+	GList* l = NULL;
+	int i = 0;
+	CODE:
+		for(i = 0; i < items; i++) { /* PurpleCertificate */
+			l = g_list_prepend(l, purple_perl_ref_object(ST(i)));
+		}
+		purple_certificate_destroy_list(l);
+
+void
+purple_certificate_get_pools()
+	PREINIT:
+		GList *l;
+	PPCODE:
+		for(l = purple_certificate_get_pools(); l; l = l->next) {
+			XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Certificate::Pool")));
+		}
+
+void
+purple_certificate_get_schemes()
+	PREINIT:
+		GList *l;
+	PPCODE:
+		for(l = purple_certificate_get_schemes(); l; l = l->next) {
+			XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Certificate::Scheme")));
+		}
+
+void
+purple_certificate_get_verifiers()
+	PREINIT:
+		GList *l;
+	PPCODE:
+		for(l = purple_certificate_get_verifiers(); l; l = l->next) {
+			XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::Certificate::Verifier")));
+		}
+
+void
+purple_certificate_check_signature_chain(...)
+	PREINIT:
+		GList *l = NULL;
+		gboolean ret;
+		int i;
+	PPCODE:
+		for(i = 0; i < items; i++) { /* PurpleCertificate */
+			l = g_list_prepend(l, purple_perl_ref_object(ST(i)));
+		}
+		l = g_list_reverse(l);
+		ret = purple_certificate_check_signature_chain(l);
+		g_list_free(l);
+		if(ret) XSRETURN_YES;
+		XSRETURN_NO;
+
+SV*
+purple_certificate_get_fingerprint_sha1(crt)
+	Purple::Certificate crt
+	PREINIT:
+		GByteArray *gba = NULL;
+	CODE:
+		gba = purple_certificate_get_fingerprint_sha1(crt);
+		RETVAL = newSVpv(gba->data, gba->len);
+		g_byte_array_free(gba, TRUE);
+	OUTPUT:
+		RETVAL
+
+void
+purple_certificate_verify(verifier, subject_name, cert_chain, cb, cb_data)
+	Purple::Certificate::Verifier verifier
+	const gchar* subject_name
+	AV* cert_chain
+	CV *cb
+	SV *cb_data
+	PREINIT:
+		GList *l = NULL;
+		int len = 0, i = 0;
+		struct cb_data *d = NULL;
+	PPCODE:
+		len = av_len(cert_chain) + 1;
+		for(i = 0; i < len; i++) {
+			SV **sv = av_fetch(cert_chain, i, 0);
+			if(!sv || !purple_perl_is_ref_object(*sv)) {
+				g_list_free(l);
+				warn("Purple::Certificate::verify: cert_chain: non-purple object in array...");
+				XSRETURN_UNDEF;
+			}
+			l = g_list_prepend(l, purple_perl_ref_object(*sv));
+		}
+		l = g_list_reverse(l);
+
+		d = g_new0(struct cb_data, 1);
+		d->cb = newSVsv(ST(3));
+		d->user_data = newSVsv(cb_data);
+		
+		purple_certificate_verify(verifier, subject_name, l, (PurpleCertificateVerifiedCallback) cb_cert_verify, d);
+
+		g_list_free(l);
+
+MODULE = Purple::Certificate  PACKAGE = Purple::Certificate::Pool  PREFIX = purple_certificate_pool_
+PROTOTYPES: ENABLE
+
+void
+purple_certificate_pool_get_idlist(pool)
+	Purple::Certificate::Pool pool
+	PREINIT:
+		GList *l, *b;
+	PPCODE:
+		b = purple_certificate_pool_get_idlist(pool);
+		for(l = b; l; l = l->next) {
+			XPUSHs(sv_2mortal(newSVpv(l->data, 0)));
+		}
+		purple_certificate_pool_destroy_idlist(b);
+
+gboolean
+purple_certificate_pool_contains(pool, id)
+	Purple::Certificate::Pool pool
+	const gchar* id
+
+gboolean
+purple_certificate_pool_delete(pool, id)
+	Purple::Certificate::Pool pool
+	const gchar* id
+
+Purple::Certificate::Scheme
+purple_certificate_pool_get_scheme(pool)
+	Purple::Certificate::Pool pool
+
+gchar_own*
+purple_certificate_pool_mkpath(pool, id)
+	Purple::Certificate::Pool pool
+	const gchar* id
+
+Purple::Certificate
+purple_certificate_pool_retrieve(pool, id)
+	Purple::Certificate::Pool pool
+	const gchar* id
+
+gboolean
+purple_certificate_pool_store(pool, id, crt)
+	Purple::Certificate::Pool pool
+	const gchar* id
+	Purple::Certificate crt
+
+gboolean
+purple_certificate_pool_usable(pool)
+	Purple::Certificate::Pool pool
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/plugins/perl/common/Idle.xs	Thu Aug 07 04:03:23 2008 +0000
@@ -0,0 +1,12 @@
+#include "module.h"
+
+MODULE = Purple::Idle  PACKAGE = Purple::Idle  PREFIX = purple_idle_
+PROTOTYPES: ENABLE
+
+void
+purple_idle_touch()
+
+void
+purple_idle_set(time)
+	time_t time
+
--- a/libpurple/plugins/perl/common/Makefile.mingw	Thu Aug 07 03:27:21 2008 +0000
+++ b/libpurple/plugins/perl/common/Makefile.mingw	Thu Aug 07 04:03:23 2008 +0000
@@ -39,11 +39,13 @@
 				BuddyList.xs \
 				Cipher.xs \
 				Cmds.xs \
+				Certificate.xs \
 				Connection.xs \
 				Conversation.xs \
 				Core.xs \
 				Debug.xs \
 				FT.xs \
+				Idle.xs \
 				Purple.xs \
 				ImgStore.xs \
 				Log.xs \
@@ -67,6 +69,7 @@
 				Status.xs \
 				Stringref.xs \
 				Util.xs \
+				Whiteboard.xs \
 				XMLNode.xs
 
 #FALLBACKS =	const-c.inc const-xs.inc
--- a/libpurple/plugins/perl/common/Purple.xs	Thu Aug 07 03:27:21 2008 +0000
+++ b/libpurple/plugins/perl/common/Purple.xs	Thu Aug 07 04:03:23 2008 +0000
@@ -6,6 +6,7 @@
 PURPLE_PERL_BOOT_PROTO(Account__Option);
 PURPLE_PERL_BOOT_PROTO(Buddy__Icon);
 PURPLE_PERL_BOOT_PROTO(BuddyList);
+PURPLE_PERL_BOOT_PROTO(Certificate);
 PURPLE_PERL_BOOT_PROTO(Cipher);
 PURPLE_PERL_BOOT_PROTO(Cmd);
 PURPLE_PERL_BOOT_PROTO(Connection);
@@ -13,6 +14,7 @@
 PURPLE_PERL_BOOT_PROTO(Core);
 PURPLE_PERL_BOOT_PROTO(Debug);
 PURPLE_PERL_BOOT_PROTO(Xfer);
+PURPLE_PERL_BOOT_PROTO(Idle);
 PURPLE_PERL_BOOT_PROTO(ImgStore);
 PURPLE_PERL_BOOT_PROTO(Log);
 PURPLE_PERL_BOOT_PROTO(Network);
@@ -35,6 +37,7 @@
 PURPLE_PERL_BOOT_PROTO(Status);
 PURPLE_PERL_BOOT_PROTO(Stringref);
 PURPLE_PERL_BOOT_PROTO(Util);
+PURPLE_PERL_BOOT_PROTO(Whiteboard);
 PURPLE_PERL_BOOT_PROTO(XMLNode);
 
 MODULE = Purple PACKAGE = Purple PREFIX = purple_
@@ -45,6 +48,7 @@
 	PURPLE_PERL_BOOT(Account__Option);
 	PURPLE_PERL_BOOT(Buddy__Icon);
 	PURPLE_PERL_BOOT(BuddyList);
+	PURPLE_PERL_BOOT(Certificate);
 	PURPLE_PERL_BOOT(Cipher);
 	PURPLE_PERL_BOOT(Cmd);
 	PURPLE_PERL_BOOT(Connection);
@@ -52,6 +56,7 @@
 	PURPLE_PERL_BOOT(Core);
 	PURPLE_PERL_BOOT(Debug);
 	PURPLE_PERL_BOOT(Xfer);
+	PURPLE_PERL_BOOT(Idle);
 	PURPLE_PERL_BOOT(ImgStore);
 	PURPLE_PERL_BOOT(Log);
 	PURPLE_PERL_BOOT(Network);
@@ -74,6 +79,7 @@
 	PURPLE_PERL_BOOT(Status);
 	PURPLE_PERL_BOOT(Stringref);
 	PURPLE_PERL_BOOT(Util);
+	PURPLE_PERL_BOOT(Whiteboard);
 	PURPLE_PERL_BOOT(XMLNode);
 
 guint
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/plugins/perl/common/Whiteboard.xs	Thu Aug 07 04:03:23 2008 +0000
@@ -0,0 +1,78 @@
+#include "module.h"
+
+MODULE = Purple::Whiteboard  PACKAGE = Purple::Whiteboard  PREFIX = purple_whiteboard_
+PROTOTYPES: ENABLE
+
+void
+purple_whiteboard_clear(wb)
+	Purple::Whiteboard wb
+
+Purple::Whiteboard
+purple_whiteboard_create(account, who, state)
+	Purple::Account account
+	const char* who
+	int state
+
+void
+purple_whiteboard_destroy(wb)
+	Purple::Whiteboard wb
+
+void
+purple_whiteboard_draw_line(wb, x1, y1, x2, y2, color, size)
+	Purple::Whiteboard wb
+	int x1
+	int y1
+	int x2
+	int y2
+	int color
+	int size
+
+void
+purple_whiteboard_draw_point(wb, x, y, color, size)
+	Purple::Whiteboard wb
+	int x
+	int y
+	int color
+	int size
+
+Purple::Whiteboard
+purple_whiteboard_get_session(account, who)
+	Purple::Account account
+	const char* who
+
+void
+purple_whiteboard_send_brush(wb, size, color)
+	Purple::Whiteboard wb
+	int size
+	int color
+
+void
+purple_whiteboard_send_clear(wb)
+	Purple::Whiteboard wb
+
+void
+purple_whiteboard_set_brush(wb, size, color)
+	Purple::Whiteboard wb
+	int size
+	int color
+
+void
+purple_whiteboard_set_dimensions(wb, width, height)
+	Purple::Whiteboard wb
+	int width
+	int height
+
+gboolean
+purple_whiteboard_get_brush(wb, OUTLIST int size, OUTLIST int color)
+	Purple::Whiteboard wb
+	PROTOTYPE: $
+
+gboolean
+purple_whiteboard_get_dimensions(wb, OUTLIST int width, OUTLIST int height)
+	Purple::Whiteboard wb
+	PROTOTYPE: $
+
+void
+purple_whiteboard_start(wb)
+	Purple::Whiteboard wb
+
--- a/libpurple/plugins/perl/common/module.h	Thu Aug 07 03:27:21 2008 +0000
+++ b/libpurple/plugins/perl/common/module.h	Thu Aug 07 04:03:23 2008 +0000
@@ -20,6 +20,7 @@
 #include "accountopt.h"
 #include "blist.h"
 #include "buddyicon.h"
+#include "certificate.h"
 #include "cipher.h"
 #include "cmds.h"
 #include "connection.h"
@@ -36,6 +37,7 @@
 #include "gtkconv.h"
 #include "gtkutils.h"
 #endif
+#include "idle.h"
 #include "imgstore.h"
 #include "network.h"
 #include "notify.h"
@@ -59,6 +61,7 @@
 /* Ewww. perl has it's own util.h which is in the include path :( */
 #include "libpurple/util.h"
 #include "value.h"
+#include "whiteboard.h"
 #include "xmlnode.h"
 
 /* account.h */
@@ -81,6 +84,14 @@
 /* buddyicon.h */
 typedef PurpleBuddyIcon *			Purple__Buddy__Icon;
 
+/* certificate.h */
+typedef PurpleCertificate *			Purple__Certificate;
+typedef PurpleCertificatePool *			Purple__Certificate__Pool;
+typedef PurpleCertificateScheme *		Purple__Certificate__Scheme;
+typedef PurpleCertificateVerifier *		Purple__Certificate__Verifier;
+typedef PurpleCertificateVerificationRequest *	Purple__Certificate__VerificationRequest;
+typedef PurpleCertificateVerificationStatus	Purple__Certificate__VerificationStatus;
+
 /* cipher.h */
 typedef PurpleCipher *			Purple__Cipher;
 typedef PurpleCipherCaps			Purple__CipherCaps;
@@ -274,6 +285,9 @@
 /* value.h */
 typedef PurpleValue *			Purple__Value;
 
+/* whiteboard.h */
+typedef PurpleWhiteboard *		Purple__Whiteboard;
+
 /* xmlnode.h */
 typedef xmlnode *			Purple__XMLNode;
 typedef XMLNodeType			XMLNode__Type;
@@ -287,3 +301,4 @@
 	const char *name;
 	IV iv;
 } constiv;
+
--- a/libpurple/plugins/perl/common/typemap	Thu Aug 07 03:27:21 2008 +0000
+++ b/libpurple/plugins/perl/common/typemap	Thu Aug 07 04:03:23 2008 +0000
@@ -175,6 +175,14 @@
 
 /* enums */
 
+/* certificate.h */
+Purple::Certificate				T_PurpleObj
+Purple::Certificate::Pool			T_PurpleObj
+Purple::Certificate::Scheme			T_PurpleObj
+Purple::Certificate::Verifier			T_PurpleObj
+Purple::Certificate::VerificationRequest	T_PurpleObj
+Purple::Certificate::VerificationStatus		T_IV
+
 /* cipher.h */
 Purple::Cipher::BatchMode	T_IV
 
@@ -186,7 +194,7 @@
 /* conversation.h */
 Purple::ConvChatBuddyFlags		T_IV
 Purple::ConvUpdateType			T_IV
-Purple::ConversationType			T_IV
+Purple::ConversationType		T_IV
 Purple::MessageFlags			T_IV
 Purple::TypingState			T_IV
 Purple::UnseenState			T_IV
@@ -195,6 +203,9 @@
 Purple::ConnectionFlags			T_IV
 Purple::ConnectionState			T_IV
 
+/* whiteboard.h */
+Purple::Whiteboard			T_PurpleObj
+
 INPUT
 
 T_PurpleObj