randomfox: (Default)
[personal profile] randomfox
I use this plugin in conjunction with a clipboard manager utility. It's a crude way to have a history recall of sent IMs.


/* Send to Clipboard plugin */
/* A Pidgin plugin that saves a copy to the clipboard of each instant
 * message that you send. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

/* config.h may define PURPLE_PLUGINS; protect the definition here so that we
 * don't get complaints about redefinition when it's not necessary. */
#ifndef PURPLE_PLUGINS
# define PURPLE_PLUGINS
#endif

#include <glib.h>
#include <string.h>

/* This will prevent compiler errors in some instances and is better
 * explained in the how-to documents on the wiki */
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
#  define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
#  define G_GNUC_NULL_TERMINATED
# endif
#endif

#include <notify.h>
#include <plugin.h>
#include <version.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>

PurplePlugin *sendclip_plugin = NULL;

/* Callback function that we will hook onto the "IM sent" signal. */
static void
im_msg_sent_cb(PurpleAccount *account, const char *receiver,
	       const char *message, void *data)
{
  char *s = purple_markup_strip_html(message);

  GtkClipboard *gtkclip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);

  /* set and store the clipboard text */
  gtk_clipboard_set_text(gtkclip, s, strlen(s));
  gtk_clipboard_store(gtkclip);

  g_free(s);

#if 0
  purple_notify_message (sendclip_plugin, PURPLE_NOTIFY_MSG_INFO,
			 "Send to Clipboard", message, NULL, NULL,
			 NULL);
#endif
}

/* Apparently, any pointer value can be used as a handle. */
static void *
sendclip_get_handle()
{
  static int handle;
  return &handle;
}

/* Connect the signal to our callback function when plugin is enabled. */
static gboolean
plugin_load(PurplePlugin *plugin)
{
  purple_signal_connect(purple_conversations_get_handle(), "sent-im-msg",
			sendclip_get_handle(),
			PURPLE_CALLBACK(im_msg_sent_cb), NULL);
  sendclip_plugin = plugin; /* assign this here so we have a valid handle later */
  return TRUE;
}

/* Disconnect our callback function from the signal when plugin is
 * disabled. */
static gboolean
plugin_unload(PurplePlugin *plugin)
{
  purple_signals_disconnect_by_handle(sendclip_get_handle());
  return TRUE;
}

static void
sendclip_init(PurplePlugin * plugin)
{
}

/* For specific notes on the meanings of each of these members, consult the
 * C Plugin Howto on the website. */
static PurplePluginInfo info = {
  PURPLE_PLUGIN_MAGIC,
  PURPLE_MAJOR_VERSION,
  PURPLE_MINOR_VERSION,
  PURPLE_PLUGIN_STANDARD,
  NULL,
  0,
  NULL,
  PURPLE_PRIORITY_DEFAULT,

  "gtk-sendclip",
  "Send to Clipboard",
  DISPLAY_VERSION, 

  "Send to Clipboard Plugin",
  "Send to Clipboard Plugin copies each sent IM message to the clipboard",
  "Po Shan Cheah <morton@mortonfox.com>",
  "http://mortonfox.livejournal.com",


  plugin_load,
  plugin_unload,
  NULL,

  NULL,
  NULL,
  NULL,
  NULL,		/* this tells libpurple the address of the function to call
		   to get the list of plugin actions. */
  NULL,
  NULL,
  NULL,
  NULL
};

PURPLE_INIT_PLUGIN(sendclip, sendclip_init, info);

/* End */

From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

Profile

randomfox: (Default)
randomfox

November 2012

S M T W T F S
    123
45678910
11121314151617
18192021222324
25262728 2930 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 23rd, 2017 10:41 am
Powered by Dreamwidth Studios