summary refs log blame commit diff stats
path: root/src/common/ssl.h
blob: 26eb0f883c911e0d298322b28df0f38dc5d92b6b (plain) (tree)
































































                                                                                                                   
/*
    ...
*/

struct cert_info {
    char subject[256];
    char *subject_word[12];
    char issuer[256];
    char *issuer_word[12];
    char algorithm[32];
    int algorithm_bits;
    char sign_algorithm[32];
    int sign_algorithm_bits;
    char notbefore[32];
    char notafter[32];

    int rsa_tmp_bits;
};

struct chiper_info {
    char version[16];
    char chiper[24];
    int chiper_bits;
};

SSL_CTX *_SSL_context_init (void (*info_cb_func), int server);
#define _SSL_context_free(a)	SSL_CTX_free(a);

SSL *_SSL_socket (SSL_CTX *ctx, int sd);
char *_SSL_set_verify (SSL_CTX *ctx, void *(verify_callback), char *cacert);
/*
    int SSL_connect(SSL *);
    int SSL_accept(SSL *);
    int SSL_get_fd(SSL *);
*/
void _SSL_close (SSL * ssl);

int _SSL_get_cert_info (struct cert_info *cert_info, SSL * ssl);
struct chiper_info *_SSL_get_cipher_info (SSL * ssl);

/*char *_SSL_add_keypair (SSL_CTX *ctx, char *privkey, char *cert);*/
/*void _SSL_add_random_keypair(SSL_CTX *ctx, int bits);*/

int _SSL_send (SSL * ssl, char *buf, int len);
int _SSL_recv (SSL * ssl, char *buf, int len);

/* misc */
/*void broke_oneline (char *oneline, char *parray[]);*/

/*char *_SSL_do_cipher_base64(char *buf, int buf_len, char *key, int operation);*/		/* must be freed */

/*void *_SSL_get_sess_obj(SSL *ssl, int type);*/		/* NOT must be freed */
#define	_SSL_get_sess_pkey(a)	_SSL_get_sess_obj(a, 0)
#define	_SSL_get_sess_prkey(a)	_SSL_get_sess_obj(a, 1)
#define	_SSL_get_sess_x509(a)	_SSL_get_sess_obj(a, 2)
/*char *_SSL_get_obj_base64(void *s, int type);*/		/* must be freed */
#define	_SSL_get_pkey_base64(a)		_SSL_get_obj_base64(a, 0)
#define	_SSL_get_prkey_base64(a)	_SSL_get_obj_base64(a, 1)
#define	_SSL_get_x509_base64(a)		_SSL_get_obj_base64(a, 2)
/*char *_SSL_get_ctx_obj_base64(SSL_CTX *ctx, int type);*/	/* must be freed */
#define	_SSL_get_ctx_pkey_base64(a)	_SSL_get_ctx_obj_base64(a, 0)
#define	_SSL_get_ctx_prkey_base64(a)	_SSL_get_ctx_obj_base64(a, 1)
#define	_SSL_get_ctx_x509_base64(a)	_SSL_get_ctx_obj_base64(a, 2)

/*int _SSL_verify_x509(X509 *x509);*/
span class="cpf">"config.h" #include <glib.h> #include "../common/hexchat-plugin.h" #include "../common/inbound.h" /* For alert_match_word() */ #include "notifications/notification-backend.h" static hexchat_plugin *ph; static gboolean should_alert (void) { int omit_away, omit_focused, omit_tray; if (hexchat_get_prefs (ph, "gui_focus_omitalerts", NULL, &omit_focused) == 3 && omit_focused) { const char *status = hexchat_get_info (ph, "win_status"); if (status && !g_strcmp0 (status, "active")) return FALSE; } if (hexchat_get_prefs (ph, "away_omit_alerts", NULL, &omit_away) == 3 && omit_away) { if (hexchat_get_info (ph, "away")) return FALSE; } if (hexchat_get_prefs (ph, "gui_tray_quiet", NULL, &omit_tray) == 3 && omit_tray) { int tray_enabled; if (hexchat_get_prefs (ph, "gui_tray", NULL, &tray_enabled) == 3 && tray_enabled) { const char *status = hexchat_get_info (ph, "win_status"); if (status && g_strcmp0 (status, "hidden") != 0) return FALSE; } } return TRUE; } static gboolean is_ignored (char *nick) { const char *no_hilight; if (hexchat_get_prefs (ph, "irc_no_hilight", &no_hilight, NULL) == 1 && no_hilight) { return alert_match_word (nick, (char*)no_hilight); } return FALSE; } static void show_notification (const char *title, const char *text) { char *stripped_title, *stripped_text; /* Strip all colors */ stripped_title = hexchat_strip (ph, title, -1, 7); stripped_text = hexchat_strip (ph, text, -1, 7); notification_backend_show (stripped_title, stripped_text); hexchat_free (ph, stripped_title); hexchat_free (ph, stripped_text); } static void show_notificationf (const char *text, const char *format, ...) { va_list args; char *buf; va_start (args, format); buf = g_strdup_vprintf (format, args); va_end (args); show_notification (buf, text); g_free (buf); } static int incoming_hilight_cb (char *word[], gpointer userdata) { int hilight; if (hexchat_get_prefs (ph, "input_balloon_hilight", NULL, &hilight) == 3 && hilight && should_alert()) { show_notificationf (word[2], _("Highlighted message from: %s (%s)"), word[1], hexchat_get_info (ph, "channel")); } return HEXCHAT_EAT_NONE; } static int incoming_message_cb (char *word[], gpointer userdata) { int message; if (hexchat_get_prefs (ph, "input_balloon_chans", NULL, &message) == 3 && message && should_alert ()) { show_notificationf (word[2], _("Channel message from: %s (%s)"), word[1], hexchat_get_info (ph, "channel")); } return HEXCHAT_EAT_NONE; } static int incoming_priv_cb (char *word[], gpointer userdata) { int priv; if (hexchat_get_prefs (ph, "input_balloon_priv", NULL, &priv) == 3 && priv && should_alert ()) { const char *network = hexchat_get_info (ph, "network"); if (!network) network = hexchat_get_info (ph, "server"); if (userdata != NULL) /* Special event */ { if (GPOINTER_TO_INT (userdata) == 3) { if (!is_ignored (word[2])) show_notificationf (word[1], _("File offer from: %s (%s)"), word[2], network); } else if (GPOINTER_TO_INT (userdata) == 2) { if (!is_ignored (word[2])) show_notificationf (word[1], _("Invited to channel by: %s (%s)"), word[2], network); } else { if (!is_ignored (word[1])) show_notificationf (word[2], _("Notice from: %s (%s)"), word[1], network); } } else show_notificationf (word[2], _("Private message from: %s (%s)"), word[1], network); } return HEXCHAT_EAT_NONE; } static int tray_cmd_cb (char *word[], char *word_eol[], gpointer userdata) { if (word[2] && !g_ascii_strcasecmp (word[2], "-b") && word[3] && word[4]) { if (should_alert ()) show_notification (word[3], word_eol[4]); return HEXCHAT_EAT_ALL; } return HEXCHAT_EAT_NONE; } int notification_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { if (!notification_backend_init ()) return 0; ph = plugin_handle; *plugin_name = ""; *plugin_desc = ""; *plugin_version = ""; hexchat_hook_print (ph, "Channel Msg Hilight", HEXCHAT_PRI_LOWEST, incoming_hilight_cb, NULL); hexchat_hook_print (ph, "Channel Action Hilight", HEXCHAT_PRI_LOWEST, incoming_hilight_cb, NULL); hexchat_hook_print (ph, "Channel Message", HEXCHAT_PRI_LOWEST, incoming_message_cb, NULL); hexchat_hook_print (ph, "Channel Action", HEXCHAT_PRI_LOWEST, incoming_message_cb, NULL); hexchat_hook_print (ph, "Channel Notice", HEXCHAT_PRI_LOWEST, incoming_message_cb, NULL); hexchat_hook_print (ph, "Private Message", HEXCHAT_PRI_LOWEST, incoming_priv_cb, NULL); hexchat_hook_print (ph, "Private Message to Dialog", HEXCHAT_PRI_LOWEST, incoming_priv_cb, NULL); hexchat_hook_print (ph, "Private Action", HEXCHAT_PRI_LOWEST, incoming_priv_cb, NULL); hexchat_hook_print (ph, "Private Action to Dialog", HEXCHAT_PRI_LOWEST, incoming_priv_cb, NULL); /* Special events treated as priv */ hexchat_hook_print (ph, "Notice", HEXCHAT_PRI_LOWEST, incoming_priv_cb, GINT_TO_POINTER (1)); hexchat_hook_print (ph, "Invited", HEXCHAT_PRI_LOWEST, incoming_priv_cb, GINT_TO_POINTER (2)); hexchat_hook_print (ph, "DCC Offer", HEXCHAT_PRI_LOWEST, incoming_priv_cb, GINT_TO_POINTER (3)); hexchat_hook_command (ph, "TRAY", HEXCHAT_PRI_HIGH, tray_cmd_cb, NULL, NULL); return 1; } int notification_plugin_deinit (void) { notification_backend_deinit (); return 1; }