soc.2008.masterpassword: 4c7422c7: Fix Perl compile. This probably doesn't ...
qulogic at pidgin.im
qulogic at pidgin.im
Mon Nov 7 02:37:30 EST 2011
----------------------------------------------------------------------
Revision: 4c7422c71f98e7262dd9b279a19507b655f82d1a
Parent: 08ad64ae65472ad7225de496ddbd45d9f14709c4
Author: qulogic at pidgin.im
Date: 11/05/11 22:05:29
Branch: im.pidgin.soc.2008.masterpassword
URL: http://d.pidgin.im/viewmtn/revision/info/4c7422c71f98e7262dd9b279a19507b655f82d1a
Changelog:
Fix Perl compile. This probably doesn't work. I just copy and pasted
things. Someone should really check this stuff.
Changes against parent 08ad64ae65472ad7225de496ddbd45d9f14709c4
patched libpurple/plugins/perl/common/Account.xs
patched libpurple/plugins/perl/perl-handlers.c
patched libpurple/plugins/perl/perl-handlers.h
-------------- next part --------------
============================================================
--- libpurple/plugins/perl/common/Account.xs f36af75ca5cac6c275b9525ea1bfa47a4345d34d
+++ libpurple/plugins/perl/common/Account.xs b28d0b0c2cc2d89ab8f8c5b82f2241d578b05772
@@ -1,4 +1,5 @@
#include "module.h"
+#include "../perl-handlers.h"
MODULE = Purple::Account PACKAGE = Purple::Account PREFIX = purple_account_
PROTOTYPES: ENABLE
@@ -44,9 +45,13 @@ void
const char * username
void
-purple_account_set_password(account, password)
+purple_account_set_password(account, password, func, data = 0)
Purple::Account account
const char * password
+ SV *func
+ SV *data
+CODE:
+ purple_perl_account_set_password(account, password, func, data);
void
purple_account_set_alias(account, alias)
@@ -130,9 +135,13 @@ purple_account_get_username(account)
purple_account_get_username(account)
Purple::Account account
-const char *
-purple_account_get_password(account)
+void
+purple_account_get_password(account, func, data = 0)
Purple::Account account
+ SV *func
+ SV *data
+CODE:
+ purple_perl_account_get_password(account, func, data);
const char *
purple_account_get_alias(account)
============================================================
--- libpurple/plugins/perl/perl-handlers.c 79fadbaf8709ffd84040f0c17c93f3e75f884df5
+++ libpurple/plugins/perl/perl-handlers.c f83bd521765ec8b10dcc0ac5a4546949f6b30445
@@ -845,3 +845,127 @@ void purple_perl_pref_cb_clear_for_plugi
destroy_prefs_handler(handler);
}
}
+
+static void
+perl_account_save_cb(PurpleAccount *account, GError *error, gpointer data)
+{
+ int count;
+ SV *accountSV, *errorSV;
+ PurplePerlAccountPasswordHandler *handler = data;
+
+ dSP;
+ ENTER;
+ SAVETMPS;
+ PUSHMARK(SP);
+
+ /* Push the account onto the perl stack */
+ accountSV = sv_2mortal(purple_perl_bless_object(account, "Purple::Account"));
+ XPUSHs(accountSV);
+
+ /* Push the error onto the perl stack */
+ errorSV = sv_2mortal(purple_perl_bless_object(account, "GLib::Error"));
+ XPUSHs(errorSV);
+
+ /* Push the data onto the perl stack */
+ XPUSHs((SV *)handler->data);
+
+ PUTBACK;
+ count = call_sv(handler->callback, G_EVAL | G_SCALAR);
+
+ if (count != 0)
+ croak("call_sv: Did not return the correct number of values.\n");
+
+ if (SvTRUE(ERRSV)) {
+ purple_debug_error("perl",
+ "Perl plugin command function exited abnormally: %s\n",
+ SvPVutf8_nolen(ERRSV));
+ }
+
+ SPAGAIN;
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+
+ g_free(handler);
+}
+
+static void
+perl_account_read_cb(PurpleAccount *account, const gchar *password,
+ GError *error, gpointer data)
+{
+ int count;
+ SV *accountSV, *passwordSV, *errorSV;
+ PurplePerlAccountPasswordHandler *handler = data;
+
+ dSP;
+ ENTER;
+ SAVETMPS;
+ PUSHMARK(SP);
+
+ /* Push the account onto the perl stack */
+ accountSV = sv_2mortal(purple_perl_bless_object(account, "Purple::Account"));
+ XPUSHs(accountSV);
+
+ /* Push the password onto the perl stack */
+ passwordSV = newSVpv(password, 0);
+ passwordSV = sv_2mortal(passwordSV);
+ XPUSHs(passwordSV);
+
+ /* Push the error onto the perl stack */
+ errorSV = sv_2mortal(purple_perl_bless_object(account, "GLib::Error"));
+ XPUSHs(errorSV);
+
+ /* Push the data onto the perl stack */
+ XPUSHs((SV *)handler->data);
+
+ PUTBACK;
+ count = call_sv(handler->callback, G_EVAL | G_SCALAR);
+
+ if (count != 0)
+ croak("call_sv: Did not return the correct number of values.\n");
+
+ if (SvTRUE(ERRSV)) {
+ purple_debug_error("perl",
+ "Perl plugin command function exited abnormally: %s\n",
+ SvPVutf8_nolen(ERRSV));
+ }
+
+ SPAGAIN;
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+
+ g_free(handler);
+}
+
+void
+purple_perl_account_get_password(PurpleAccount *account, SV *func, SV *data)
+{
+ PurplePerlAccountPasswordHandler *handler;
+
+ handler = g_new0(PurplePerlAccountPasswordHandler, 1);
+ handler->callback = (func != NULL &&
+ func != &PL_sv_undef ? newSVsv(func) : NULL);
+ handler->data = (data != NULL &&
+ data != &PL_sv_undef ? newSVsv(data) : NULL);
+
+ purple_account_get_password(account, perl_account_read_cb, data);
+}
+
+void
+purple_perl_account_set_password(PurpleAccount *account, const char *password,
+ SV *func, SV *data)
+{
+ PurplePerlAccountPasswordHandler *handler;
+
+ handler = g_new0(PurplePerlAccountPasswordHandler, 1);
+ handler->callback = (func != NULL &&
+ func != &PL_sv_undef ? newSVsv(func) : NULL);
+ handler->data = (data != NULL &&
+ data != &PL_sv_undef ? newSVsv(data) : NULL);
+
+ purple_account_set_password(account, password, perl_account_save_cb, data);
+}
+
============================================================
--- libpurple/plugins/perl/perl-handlers.h a4a40f9641594ba13824f16a8d23b29ae6d424a1
+++ libpurple/plugins/perl/perl-handlers.h d489f09b0db9e3fa18fa3947091505a68b3b347d
@@ -48,6 +48,13 @@ typedef struct
} PurplePerlPrefsHandler;
+typedef struct
+{
+ SV *callback;
+ SV *data;
+
+} PurplePerlAccountPasswordHandler;
+
void purple_perl_plugin_action_cb(PurplePluginAction * gpa);
GList *purple_perl_plugin_actions(PurplePlugin *plugin, gpointer context);
@@ -82,4 +89,10 @@ void purple_perl_pref_cb_clear_for_plugi
void purple_perl_prefs_disconnect_callback(guint callback_id);
void purple_perl_pref_cb_clear_for_plugin(PurplePlugin *plugin);
+void
+purple_perl_account_get_password(PurpleAccount *account, SV *func, SV *data);
+void
+purple_perl_account_set_password(PurpleAccount *account, const char *password,
+ SV *func, SV *data);
+
#endif /* _PURPLE_PERL_HANDLERS_H_ */
More information about the Commits
mailing list