summaryrefslogtreecommitdiff
path: root/contrib/splice3/TOOLS
diff options
context:
space:
mode:
authord3v11 <d3v11@d3v11.ano>2011-10-08 00:33:36 -0500
committerd3v11 <d3v11@d3v11.ano>2011-10-08 00:33:36 -0500
commit0984029a209ccad799e1750037c38d7076ebb546 (patch)
tree3c63e6d5eec151289ff263c89c7330d3fbfa514e /contrib/splice3/TOOLS
parent98a99d81fc2be7afc97a595de2c26ab98e03df43 (diff)
downloadresdb-0984029a209ccad799e1750037c38d7076ebb546.tar.gz
resdb-0984029a209ccad799e1750037c38d7076ebb546.zip
d3v11 added im-steal.c for splice3 in contrib/splice3/TOOLS/IM-STEAL
enjoy :-)
Diffstat (limited to 'contrib/splice3/TOOLS')
-rw-r--r--contrib/splice3/TOOLS/IM-STEAL/README45
-rw-r--r--contrib/splice3/TOOLS/IM-STEAL/im-steal.c173
2 files changed, 218 insertions, 0 deletions
diff --git a/contrib/splice3/TOOLS/IM-STEAL/README b/contrib/splice3/TOOLS/IM-STEAL/README
new file mode 100644
index 0000000..cd19ff8
--- /dev/null
+++ b/contrib/splice3/TOOLS/IM-STEAL/README
@@ -0,0 +1,45 @@
+DESCRIPTION:
+ im-steal.c is a modified nullclient.c that uses
+ libpurple to test for a successfull login on
+ multiple instant messenger protocols.
+
+USAGE:
+ im-steal <prpl-protocol> <username> <password>
+
+SPLICE3 USAGE:
+ splice3
+ --command='im-steal <prpl-protocol> <username> PASSWORD'
+ --<modules>
+ --test='Account Connected'
+
+DEPENDS:
+ libpurple-dev, libpurple
+
+INSTALL:
+ gcc `pkg-config --libs glib-2.0` -I /usr/include/libpurple/
+ -I /usr/include/glib-2.0/ -I /usr/lib/glib-2.0/include/
+ -lpurple im-steal.c -o /usr/bin/im-steal
+
+UNINSTALL:
+ rm /usr/bin/im-steal
+
+PRPL-PROTOCOL:
+ libpurple requires and allows several prpl-* arguments
+ to call various instant messenger protocols.
+
+ AIM == prpl-aim
+ Bonjour == prpl-bonjour
+ Gadu-Gadu == prpl-gg
+ GroupWise == prpl-novell
+ ICQ == prpl-icq
+ IRC == prpl-irc
+ MSN == prpl-msn
+ MySpaceIM == prpl-myspace
+ QQ == prpl-qq
+ SILC == prpl-silc
+ SIMPLE == prpl-simple
+ Sametime == prpl-meanwhile
+ XMPP == prpl-jabber
+ Yahoo == prpl-yahoo
+ Yahoo JAPAN == prpl-yahoojp
+ Zephyr == prpl-zephyr
diff --git a/contrib/splice3/TOOLS/IM-STEAL/im-steal.c b/contrib/splice3/TOOLS/IM-STEAL/im-steal.c
new file mode 100644
index 0000000..fad7026
--- /dev/null
+++ b/contrib/splice3/TOOLS/IM-STEAL/im-steal.c
@@ -0,0 +1,173 @@
+/*
+ * Modified libpurple nullclient.c from http://pidgin.sourcearchive.com.
+ * This libpurple program serves no other purpose other than testing
+ * for a successfull login.
+ */
+
+#include "purple.h"
+#include <glib.h>
+#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#define CUSTOM_USER_DIRECTORY "/dev/null"
+#define CUSTOM_PLUGIN_PATH ""
+#define PLUGIN_SAVE_PREF "/purple/user/plugins/saved"
+#define UI_ID "user"
+#define PURPLE_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
+#define PURPLE_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
+
+typedef struct _PurpleGLibIOClosure {
+ PurpleInputFunction function;
+ guint result;
+ gpointer data;
+} PurpleGLibIOClosure;
+
+
+static void purple_glib_io_destroy(gpointer data)
+{
+ g_free(data);
+}
+
+static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
+{
+ PurpleGLibIOClosure *closure = data;
+ PurpleInputCondition purple_cond = 0;
+
+ if (condition & PURPLE_GLIB_READ_COND)
+ purple_cond |= PURPLE_INPUT_READ;
+ if (condition & PURPLE_GLIB_WRITE_COND)
+ purple_cond |= PURPLE_INPUT_WRITE;
+
+ closure->function(closure->data, g_io_channel_unix_get_fd(source),
+ purple_cond);
+
+ return TRUE;
+}
+
+static guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
+ gpointer data)
+{
+ PurpleGLibIOClosure *closure = g_new0(PurpleGLibIOClosure, 1);
+ GIOChannel *channel;
+ GIOCondition cond = 0;
+
+ closure->function = function;
+ closure->data = data;
+
+ if (condition & PURPLE_INPUT_READ)
+ cond |= PURPLE_GLIB_READ_COND;
+ if (condition & PURPLE_INPUT_WRITE)
+ cond |= PURPLE_GLIB_WRITE_COND;
+
+ channel = g_io_channel_unix_new(fd);
+ closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
+ purple_glib_io_invoke, closure, purple_glib_io_destroy);
+
+ g_io_channel_unref(channel);
+ return closure->result;
+}
+
+static PurpleEventLoopUiOps glib_eventloops =
+{
+ g_timeout_add,
+ g_source_remove,
+ glib_input_add,
+ g_source_remove,
+ NULL,
+#if GLIB_CHECK_VERSION(2,14,0)
+ g_timeout_add_seconds,
+#else
+ NULL,
+#endif
+ NULL,
+ NULL,
+ NULL
+};
+
+static void network_disconnected(void)
+{
+ printf("This machine has been disconnected from the internet\n");
+}
+
+static void report_disconnect_reason(PurpleConnection *gc, PurpleConnectionError reason, const char *text)
+{
+ PurpleAccount *account = purple_connection_get_account(gc);
+ printf("Connection disconnected: \"%s\" (%s)\n >Error: %d\n >Reason: %s\n", purple_account_get_username(account), purple_account_get_protocol_id(account), reason, text);
+}
+
+static PurpleConnectionUiOps connection_uiops =
+{
+ NULL, /* connect_progress */
+ NULL, /* connected */
+ NULL, /* disconnected */
+ NULL, /* notice */
+ NULL, /* report_disconnect */
+ NULL, /* network_connected */
+ network_disconnected, /* network_disconnected */
+ report_disconnect_reason, /* report_disconnect_reason */
+ NULL,
+ NULL,
+ NULL
+};
+
+static void ui_init(void)
+{
+ purple_connections_set_ui_ops(&connection_uiops);
+}
+
+static PurpleCoreUiOps core_uiops =
+{
+ NULL,
+ NULL,
+ ui_init,
+ NULL,
+
+ /* padding */
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+static void init_libpurple(void)
+{
+ purple_debug_set_enabled(FALSE);
+ purple_core_set_ui_ops(&core_uiops);
+ purple_eventloop_set_ui_ops(&glib_eventloops);
+
+ if (!purple_core_init(UI_ID)) {
+ fprintf(stderr,
+ "libpurple initialization failed. Dumping core.\n"
+ "Please report this!\n");
+ abort();
+ }
+ purple_set_blist(purple_blist_new()); // "Unnecessary" code left here to prevent output spam.
+}
+
+static void signed_on(PurpleConnection *gc)
+{
+ printf("Account Connected\n");
+ abort();
+}
+
+static void connect_to_signals(void)
+{
+ static int handle;
+ purple_signal_connect(purple_connections_get_handle(), "signed-on", &handle,
+ PURPLE_CALLBACK(signed_on), NULL);
+}
+
+int main(int argc, char *argv[])
+{
+ GMainLoop *loop = g_main_loop_new(NULL, FALSE);
+ signal(SIGCHLD, SIG_IGN);
+ init_libpurple();
+ connect_to_signals();
+ PurpleAccount *account = purple_account_new(argv[2], argv[1]);
+ purple_account_set_password(account, argv[3]);
+ purple_accounts_add(account);
+ purple_account_set_enabled(account, UI_ID, TRUE);
+ g_main_loop_run(loop);
+ return 0;
+}