summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@kodafritt.se>2015-06-15 18:21:21 (GMT)
committerSamuel Lidén Borell <samuel@kodafritt.se>2015-06-15 18:26:12 (GMT)
commita7ed686bccf488a457514262782c564ecb447e0b (patch)
tree538be078b6afa9d2b1dfffd9cba8f012c28a57b7
parente8461bce4c4af65b3aac89d3f48c95f94c960422 (diff)
downloadfishlim-a7ed686bccf488a457514262782c564ecb447e0b.zip
fishlim-a7ed686bccf488a457514262782c564ecb447e0b.tar.gz
fishlim-a7ed686bccf488a457514262782c564ecb447e0b.tar.bz2
Update HexChat plugin API, drop support for XChat
-rw-r--r--INSTALL2
-rw-r--r--LICENSE2
-rw-r--r--README4
-rw-r--r--plugin_xchat.c102
4 files changed, 55 insertions, 55 deletions
diff --git a/INSTALL b/INSTALL
index d0d61ff..2cba77d 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,7 +1,7 @@
Install dependencies (on Debian/Ubuntu):
- sudo apt-get install build-essential libglib2.0-dev libssl-dev
+ sudo apt-get install build-essential libglib2.0-dev libssl-dev hexchat-common
Build the plugin with:
diff --git a/LICENSE b/LICENSE
index a3e0474..c8d4b0f 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
-Copyright (c) 2010-2011 Samuel Lidén Borell <samuel@kodafritt.se>
+Copyright (c) 2010-2015 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README b/README
index 00d7f68..7ff0b15 100644
--- a/README
+++ b/README
@@ -5,7 +5,7 @@
http://fishlim.kodafritt.se/
-FiSHLiM is an XChat plugin for FiSH IRC encryption. It's my attempt at making
+FiSHLiM is a HexChat plugin for FiSH IRC encryption. It's my attempt at making
a simple, lightweight and secure plugin for this encryption protocol.
For installation instructions, see the INSTALL file.
@@ -35,7 +35,7 @@ Commands
/setkey [nick or #channel] password
Sets the encryption key for the nick or channel to password. The keys
- are stored in the configuration file in ~/.xchat2/blow.ini
+ are stored in the configuration file in ~/.config/hexchat/blow.ini
/delkey nick-or-#channel
diff --git a/plugin_xchat.c b/plugin_xchat.c
index fcaa371..ab71ff8 100644
--- a/plugin_xchat.c
+++ b/plugin_xchat.c
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2010-2011 Samuel Lidén Borell <samuel@kodafritt.se>
+ Copyright (c) 2010-2015 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -28,11 +28,11 @@
// #pragma GCC visibility push(default)
#ifdef _MSC_VER
-#include "xchat-plugin.h"
+ #include "hexchat-plugin.h"
#else
-#include <xchat/xchat-plugin.h>
+ #include <hexchat-plugin.h>
#endif
-#define XCHAT_MAX_WORDS 32
+#define HEXCHAT_MAX_WORDS 32
// #pragma GCC visibility pop
//#define EXPORT __attribute((visibility("default")))
@@ -49,14 +49,14 @@ static const char plugin_version[] = "0.0.17";
static const char usage_setkey[] = "Usage: SETKEY [<nick or #channel>] <password>, sets the key for a channel or nick";
static const char usage_delkey[] = "Usage: DELKEY <nick or #channel>, deletes the key for a channel or nick";
-static xchat_plugin *ph;
+static hexchat_plugin *ph;
/**
* Returns the path to the key store file.
*/
gchar *get_config_filename() {
- return g_build_filename(xchat_get_info(ph, "xchatdirfs"), "blow.ini", NULL);
+ return g_build_filename(hexchat_get_info(ph, "configdir"), "blow.ini", NULL);
}
/**
@@ -78,12 +78,12 @@ static bool append(char **s, size_t *length, const char *data) {
/*static int handle_debug(char *word[], char *word_eol[], void *userdata) {
- xchat_printf(ph, "debug incoming: ");
+ hexchat_printf(ph, "debug incoming: ");
for (size_t i = 1; word[i] != NULL && word[i][0] != '\0'; i++) {
- xchat_printf(ph, ">%s< ", word[i]);
+ hexchat_printf(ph, ">%s< ", word[i]);
}
- xchat_printf(ph, "\n");
- return XCHAT_EAT_NONE;
+ hexchat_printf(ph, "\n");
+ return HEXCHAT_EAT_NONE;
}*/
/**
@@ -92,19 +92,19 @@ static bool append(char **s, size_t *length, const char *data) {
static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
const char *own_nick;
// Encrypt the message if possible
- const char *channel = xchat_get_info(ph, "channel");
+ const char *channel = hexchat_get_info(ph, "channel");
char *encrypted = fish_encrypt_for_nick(channel, word_eol[1]);
- if (!encrypted) return XCHAT_EAT_NONE;
+ if (!encrypted) return HEXCHAT_EAT_NONE;
// Display message
- own_nick = xchat_get_info(ph, "nick");
- xchat_emit_print(ph, "Your Message", own_nick, word_eol[1], NULL);
+ own_nick = hexchat_get_info(ph, "nick");
+ hexchat_emit_print(ph, "Your Message", own_nick, word_eol[1], NULL);
// Send message
- xchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted);
+ hexchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted);
free(encrypted);
- return XCHAT_EAT_XCHAT;
+ return HEXCHAT_EAT_HEXCHAT;
}
/**
@@ -126,19 +126,19 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
char prefix_char = 0;
if (!irc_parse_message((const char **)word, &prefix, &command, &w))
- return XCHAT_EAT_NONE;
+ return HEXCHAT_EAT_NONE;
// Topic (command 332) has an extra parameter
if (!strcmp(command, "332")) w++;
// Look for encrypted data
- for (ew = w+1; ew < XCHAT_MAX_WORDS-1; ew++) {
+ for (ew = w+1; ew < HEXCHAT_MAX_WORDS-1; ew++) {
const char *s = (ew == w+1 ? word[ew]+1 : word[ew]);
if (*s && (s[1] == '+' || s[1] == 'm')) { prefix_char = *(s++); }
else { prefix_char = 0; }
if (strcmp(s, "+OK") == 0 || strcmp(s, "mcps") == 0) goto has_encrypted_data;
}
- return XCHAT_EAT_NONE;
+ return HEXCHAT_EAT_NONE;
has_encrypted_data: ;
// Extract sender nick and recipient nick/channel
sender_nick = irc_prefix_get_nick(prefix);
@@ -157,7 +157,7 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
length = 0;
if (!append(&message, &length, "RECV")) goto decrypt_error;
- for (uw = 1; uw < XCHAT_MAX_WORDS; uw++) {
+ for (uw = 1; uw < HEXCHAT_MAX_WORDS; uw++) {
if (word[uw][0] != '\0' && !append(&message, &length, " ")) goto decrypt_error;
if (uw == ew) {
@@ -186,16 +186,16 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
// Simulate unencrypted message
//xchat_printf(ph, "simulating: %s\n", message);
- xchat_command(ph, message);
+ hexchat_command(ph, message);
free(message);
free(sender_nick);
- return XCHAT_EAT_XCHAT;
+ return HEXCHAT_EAT_HEXCHAT;
decrypt_error:
free(decrypted);
free(sender_nick);
- return XCHAT_EAT_NONE;
+ return HEXCHAT_EAT_NONE;
}
/**
@@ -207,13 +207,13 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) {
// Check syntax
if (*word[2] == '\0') {
- xchat_printf(ph, "%s\n", usage_setkey);
- return XCHAT_EAT_XCHAT;
+ hexchat_printf(ph, "%s\n", usage_setkey);
+ return HEXCHAT_EAT_HEXCHAT;
}
if (*word[3] == '\0') {
// /setkey password
- nick = xchat_get_info(ph, "channel");
+ nick = hexchat_get_info(ph, "channel");
key = word_eol[2];
} else {
// /setkey #channel password
@@ -223,12 +223,12 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) {
// Set password
if (keystore_store_key(nick, key)) {
- xchat_printf(ph, "Stored key for %s\n", nick);
+ hexchat_printf(ph, "Stored key for %s\n", nick);
} else {
- xchat_printf(ph, "\00305Failed to store key in blow.ini\n", nick, key);
+ hexchat_printf(ph, "\00305Failed to store key in blow.ini\n", nick, key);
}
- return XCHAT_EAT_XCHAT;
+ return HEXCHAT_EAT_HEXCHAT;
}
/**
@@ -239,26 +239,26 @@ static int handle_delkey(char *word[], char *word_eol[], void *userdata) {
// Check syntax
if (*word[2] == '\0' || *word[3] != '\0') {
- xchat_printf(ph, "%s\n", usage_delkey);
- return XCHAT_EAT_XCHAT;
+ hexchat_printf(ph, "%s\n", usage_delkey);
+ return HEXCHAT_EAT_HEXCHAT;
}
nick = word_eol[2];
// Delete the given nick from the key store
if (keystore_delete_nick(nick)) {
- xchat_printf(ph, "Deleted key for %s\n", nick);
+ hexchat_printf(ph, "Deleted key for %s\n", nick);
} else {
- xchat_printf(ph, "\00305Failed to delete key in blow.ini!\n", nick);
+ hexchat_printf(ph, "\00305Failed to delete key in blow.ini!\n", nick);
}
- return XCHAT_EAT_XCHAT;
+ return HEXCHAT_EAT_HEXCHAT;
}
/**
* Returns the plugin name version information.
*/
-void xchat_plugin_get_info(const char **name, const char **desc,
+void hexchat_plugin_get_info(const char **name, const char **desc,
const char **version, void **reserved) {
*name = plugin_name;
*desc = plugin_desc;
@@ -268,11 +268,11 @@ void xchat_plugin_get_info(const char **name, const char **desc,
/**
* Plugin entry point.
*/
-int xchat_plugin_init(xchat_plugin *plugin_handle,
- const char **name,
- const char **desc,
- const char **version,
- char *arg) {
+int hexchat_plugin_init(hexchat_plugin *plugin_handle,
+ const char **name,
+ const char **desc,
+ const char **version,
+ char *arg) {
ph = plugin_handle;
/* Send our info to XChat */
@@ -281,24 +281,24 @@ int xchat_plugin_init(xchat_plugin *plugin_handle,
*version = plugin_version;
/* Register commands */
- xchat_hook_command(ph, "SETKEY", XCHAT_PRI_NORM, handle_setkey, usage_setkey, NULL);
- xchat_hook_command(ph, "DELKEY", XCHAT_PRI_NORM, handle_delkey, usage_delkey, NULL);
+ hexchat_hook_command(ph, "SETKEY", HEXCHAT_PRI_NORM, handle_setkey, usage_setkey, NULL);
+ hexchat_hook_command(ph, "DELKEY", HEXCHAT_PRI_NORM, handle_delkey, usage_delkey, NULL);
/* Add handlers */
- xchat_hook_command(ph, "", XCHAT_PRI_NORM, handle_outgoing, NULL, NULL);
- xchat_hook_server(ph, "NOTICE", XCHAT_PRI_NORM, handle_incoming, NULL);
- xchat_hook_server(ph, "PRIVMSG", XCHAT_PRI_NORM, handle_incoming, NULL);
- //xchat_hook_server(ph, "RAW LINE", XCHAT_PRI_NORM, handle_debug, NULL);
- xchat_hook_server(ph, "TOPIC", XCHAT_PRI_NORM, handle_incoming, NULL);
- xchat_hook_server(ph, "332", XCHAT_PRI_NORM, handle_incoming, NULL);
+ hexchat_hook_command(ph, "", HEXCHAT_PRI_NORM, handle_outgoing, NULL, NULL);
+ hexchat_hook_server(ph, "NOTICE", HEXCHAT_PRI_NORM, handle_incoming, NULL);
+ hexchat_hook_server(ph, "PRIVMSG", HEXCHAT_PRI_NORM, handle_incoming, NULL);
+ //hexchat_hook_server(ph, "RAW LINE", HEXCHAT_PRI_NORM, handle_debug, NULL);
+ hexchat_hook_server(ph, "TOPIC", HEXCHAT_PRI_NORM, handle_incoming, NULL);
+ hexchat_hook_server(ph, "332", HEXCHAT_PRI_NORM, handle_incoming, NULL);
- xchat_printf(ph, "%s plugin loaded\n", plugin_name);
+ hexchat_printf(ph, "%s plugin loaded\n", plugin_name);
/* Return success */
return 1;
}
-int xchat_plugin_deinit(void) {
- xchat_printf(ph, "%s plugin unloaded\n", plugin_name);
+int hexchat_plugin_deinit(void) {
+ hexchat_printf(ph, "%s plugin unloaded\n", plugin_name);
return 1;
}