[Pkg-privacy-commits] [irssi-plugin-otr] 157/267: Cleanup unused policy code
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:38 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.
commit 986d9e7191bf899e14322909aa9ece6ac0f7ecf3
Author: David Goulet <dgoulet at ev0ke.net>
Date: Tue Nov 27 21:53:52 2012 -0500
Cleanup unused policy code
Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
src/module.c | 18 +++++++----------
src/otr-ops.c | 50 +++-------------------------------------------
src/otr.c | 64 -----------------------------------------------------------
src/otr.h | 18 ++---------------
4 files changed, 12 insertions(+), 138 deletions(-)
diff --git a/src/module.c b/src/module.c
index 000746b..cec16f7 100644
--- a/src/module.c
+++ b/src/module.c
@@ -32,12 +32,15 @@
#include "utils.h"
static const char *signal_args_otr_event[] = {
- "iobject", "string", "string", "NULL" };
+ "iobject", "string", "string", "NULL"
+};
int debug = FALSE;
-/* need this to decode arguments in perl signal handlers. Maybe irssi should
- * install perl/perl-signals.h which is where this definition comes from? */
+/*
+ * Need this to decode arguments in perl signal handlers. Maybe irssi should
+ * install perl/perl-signals.h which is where this definition comes from?
+ */
void perl_signal_register(const char *signal, const char **args);
/*
@@ -233,8 +236,7 @@ static void otr_statusbar(struct SBAR_ITEM_REC *item, int get_size_only)
static void read_settings(void)
{
- otr_setpolicies(user_state_global, settings_get_str("otr_policy"), FALSE);
- otr_setpolicies(user_state_global, settings_get_str("otr_policy_known"), TRUE);
+ return;
}
void irssi_send_message(SERVER_REC *irssi, const char *recipient,
@@ -275,12 +277,6 @@ void otr_init(void)
command_bind_first("quit", NULL, (SIGNAL_FUNC) cmd_quit);
command_bind_irc_first("me", NULL, (SIGNAL_FUNC) cmd_me);
- settings_add_str("otr", "otr_policy", OTR_DEFAULT_POLICY);
- settings_add_str("otr", "otr_policy_known", OTR_DEFAULT_POLICY_KNOWN);
- settings_add_str("otr", "otr_ignore", OTR_DEFAULT_IGNORE);
- settings_add_bool("otr", "otr_finishonunload", TRUE);
- settings_add_bool("otr", "otr_createqueries", TRUE);
-
read_settings();
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
diff --git a/src/otr-ops.c b/src/otr-ops.c
index 4b63a99..086955b 100644
--- a/src/otr-ops.c
+++ b/src/otr-ops.c
@@ -22,59 +22,15 @@
#include "key.h"
#include "module.h"
-OtrlPolicy IO_DEFAULT_OTR_POLICY =
+static OtrlPolicy OTR_DEFAULT_POLICY =
OTRL_POLICY_MANUAL | OTRL_POLICY_WHITESPACE_START_AKE;
/*
- * Return policy for given context based on the otr_policy /setting
+ * Return default policy for now.
*/
static OtrlPolicy ops_policy(void *opdata, ConnContext *context)
{
- int ret;
- char *server = strchr(context->accountname, '@') + 1;
- OtrlPolicy op = IO_DEFAULT_OTR_POLICY;
- GSList *pl;
- char fullname[1024];
-
- ret = snprintf(fullname, sizeof(fullname), "%s@%s", context->username,
- server);
- if (ret < 0) {
- /* Return default policy */
- goto error;
- }
-
- /* Unknown policy */
- if (user_state_global->policy_unknown_list) {
- pl = user_state_global->policy_unknown_list;
- do {
- struct plistentry *ple = pl->data;
-
- if (g_pattern_match_string(ple->namepat, fullname)) {
- op = ple->policy;
- }
- } while ((pl = g_slist_next(pl)));
- }
-
- /* Known policy */
- if (user_state_global->policy_known_list && context->fingerprint_root.next) {
- pl = user_state_global->policy_known_list;
-
- do {
- struct plistentry *ple = pl->data;
-
- if (g_pattern_match_string(ple->namepat, fullname)) {
- op = ple->policy;
- }
- } while ((pl = g_slist_next(pl)));
- }
-
- if (context->msgstate == OTRL_MSGSTATE_FINISHED &&
- (op == OTRL_POLICY_OPPORTUNISTIC || op == OTRL_POLICY_ALWAYS)) {
- op = OTRL_POLICY_MANUAL | OTRL_POLICY_WHITESPACE_START_AKE;
- }
-
-error:
- return op;
+ return OTR_DEFAULT_POLICY;
}
/*
diff --git a/src/otr.c b/src/otr.c
index 44f6006..cd47f7c 100644
--- a/src/otr.c
+++ b/src/otr.c
@@ -270,9 +270,6 @@ void otr_free_user(struct otr_user_state *ustate)
ustate->otr_state = NULL;
}
- otr_setpolicies(ustate, "", FALSE);
- otr_setpolicies(ustate, "", TRUE);
-
free(ustate);
}
@@ -665,67 +662,6 @@ error:
return ret;
}
-void otr_setpolicies(struct otr_user_state *ustate, const char *policies, int known)
-{
-#ifdef HAVE_GREGEX_H
- GMatchInfo *match_info;
- GSList *plist = known ? ustate->policy_known_list : ustate->policy_unknown_list;
-
- if (plist) {
- GSList *p = plist;
- do {
- struct plistentry *ple = p->data;
- g_pattern_spec_free(ple->namepat);
- g_free(p->data);
- } while ((p = g_slist_next(p)));
-
- g_slist_free(plist);
- plist = NULL;
- }
-
- g_regex_match(regex_policies, policies, 0, &match_info);
-
- while (g_match_info_matches(match_info)) {
- struct plistentry *ple =
- (struct plistentry *) g_malloc0(sizeof(struct plistentry));
- char *pol = g_match_info_fetch(match_info, 2);
-
- ple->namepat = g_pattern_spec_new(g_match_info_fetch(match_info, 1));
-
- switch (*pol) {
- case 'n':
- ple->policy = OTRL_POLICY_NEVER;
- break;
- case 'm':
- ple->policy = OTRL_POLICY_MANUAL;
- break;
- case 'h':
- ple->policy = OTRL_POLICY_MANUAL | OTRL_POLICY_WHITESPACE_START_AKE;
- break;
- case 'o':
- ple->policy = OTRL_POLICY_OPPORTUNISTIC;
- break;
- case 'a':
- ple->policy = OTRL_POLICY_ALWAYS;
- break;
- }
-
- plist = g_slist_append(plist, ple);
-
- g_free(pol);
-
- g_match_info_next(match_info, NULL);
- }
-
- g_match_info_free(match_info);
-
- if (known)
- ustate->policy_known_list = plist;
- else
- ustate->policy_unknown_list = plist;
-#endif
-}
-
/*
* Get the OTR status of this conversation.
*/
diff --git a/src/otr.h b/src/otr.h
index 45c7ca5..ded42dc 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -45,13 +45,6 @@
#define OTR_FINGERPRINTS_FILE "/otr/otr.fp"
#define OTR_INSTAG_FILE "/otr/otr.instag"
-/* some defaults */
-#define OTR_DEFAULT_POLICY \
- "*@localhost opportunistic, *@im.* opportunistic, *serv at irc* never"
-
-#define OTR_DEFAULT_POLICY_KNOWN "* always"
-#define OTR_DEFAULT_IGNORE "xmlconsole[0-9]*"
-
/*
* Memory allocation zeroed. Really useful!
*/
@@ -60,8 +53,6 @@
/* Irssi otr user state */
struct otr_user_state {
OtrlUserState otr_state;
- GSList *policy_unknown_list;
- GSList *policy_known_list;
};
/*
@@ -128,18 +119,13 @@ void otr_free_user(struct otr_user_state *ustate);
void otr_lib_init();
void otr_lib_uninit();
-void otr_setpolicies(struct otr_user_state *ustate, const char *policies,
- int known);
-
-/* basic send/receive/status stuff */
-
+/* Message transport. */
int otr_send(SERVER_REC *irssi, const char *msg, const char *to,
char **otr_msg);
int otr_receive(SERVER_REC *irssi, const char *msg,
const char *from, char **new_msg);
-/* user interaction */
-
+/* User interaction */
void otr_finish(SERVER_REC *irssi, const char *nick);
void otr_auth(SERVER_REC *irssi, const char *nick, const char *question,
const char *secret);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git
More information about the Pkg-privacy-commits
mailing list