[Pkg-privacy-commits] [pidgin-otr] 02/255: * otr-plugin.h: * otr-plugin.c (otrg_plugin_proto_supports_otr): New function to check whether a given protocol supports OTR. Right now, everything except IRC is assumed to support it.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:51:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch experimental
in repository pidgin-otr.
commit 80ad8452bc6d8a366625fa14eed853f9b9b62c0f
Author: cypherpunk <cypherpunk>
Date: Thu May 19 13:34:43 2005 +0000
* otr-plugin.h:
* otr-plugin.c (otrg_plugin_proto_supports_otr): New function to
check whether a given protocol supports OTR. Right now,
everything except IRC is assumed to support it.
* otr-plugin.c (supply_extended_menu): Don't add the "OTR
Settings" menu option to the per-buddy menu if this buddy's
protocol doesn't support OTR.
* ui.c (otrg_ui_find_policy): If the protocol doesn't support
OTR, always return a policy of OTRL_POLICY_NEVER.
---
ChangeLog | 14 ++++++++++++++
NEWS | 6 ++++++
otr-plugin.c | 25 +++++++++++++++++++++++--
otr-plugin.h | 3 +++
ui.c | 6 ++++++
5 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ad0fca6..2cea8a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2005-05-19
+
+ * otr-plugin.h:
+ * otr-plugin.c (otrg_plugin_proto_supports_otr): New function to
+ check whether a given protocol supports OTR. Right now,
+ everything except IRC is assumed to support it.
+
+ * otr-plugin.c (supply_extended_menu): Don't add the "OTR
+ Settings" menu option to the per-buddy menu if this buddy's
+ protocol doesn't support OTR.
+
+ * ui.c (otrg_ui_find_policy): If the protocol doesn't support
+ OTR, always return a policy of OTRL_POLICY_NEVER.
+
2005-05-03
* README:
diff --git a/NEWS b/NEWS
index 1916915..890a6fe 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+19 May 2005:
+- OTR doesn't work over IRC (since IRC's maximum message size is too
+ small for a Key Exchange Message to fit), so don't even provide the
+ OTR Settings buddy-menu option or the OTR conversation window button
+ for IRC.
+
3 May 2005:
- Released 2.0.2
- Fix to co-exist more nicely with other encrypting gaim plugins.
diff --git a/otr-plugin.c b/otr-plugin.c
index 8f0067b..b535f1d 100644
--- a/otr-plugin.c
+++ b/otr-plugin.c
@@ -423,11 +423,21 @@ static void otr_options_cb(GaimBlistNode *node, gpointer user_data)
static void supply_extended_menu(GaimBlistNode *node, GList **menu)
{
GaimBlistNodeAction *act;
+ GaimBuddy *buddy;
+ GaimAccount *acct;
+ const char *proto;
if (!GAIM_BLIST_NODE_IS_BUDDY(node)) return;
- act = gaim_blist_node_action_new("OTR Settings", otr_options_cb, NULL);
- *menu = g_list_append(*menu, act);
+ /* Extract the account, and then the protocol, for this buddy */
+ buddy = (GaimBuddy *)node;
+ acct = buddy->account;
+ if (acct == NULL) return;
+ proto = gaim_account_get_protocol_id(acct);
+ if (!otrg_plugin_proto_supports_otr(proto)) return;
+
+ act = gaim_blist_node_action_new("OTR Settings", otr_options_cb, NULL);
+ *menu = g_list_append(*menu, act);
}
/* Disconnect a context, sending a notice to the other side, if
@@ -511,6 +521,17 @@ static gboolean otr_plugin_unload(GaimPlugin *handle)
return 1;
}
+/* Return 1 if the given protocol supports OTR, 0 otherwise. */
+int otrg_plugin_proto_supports_otr(const char *proto)
+{
+ /* IRC is the only protocol we know of that OTR doesn't work on (its
+ * maximum message size is too small to fit a Key Exchange Message). */
+ if (proto && !strcmp(proto, "prpl-irc")) {
+ return 0;
+ }
+ return 1;
+}
+
#ifdef USING_GTK
static GaimGtkPluginUiInfo ui_info =
diff --git a/otr-plugin.h b/otr-plugin.h
index 558bbff..67c2f3a 100644
--- a/otr-plugin.h
+++ b/otr-plugin.h
@@ -58,4 +58,7 @@ void otrg_plugin_send_default_query_conv(GaimConversation *conv);
* appropriate. */
void otrg_plugin_disconnect(ConnContext *context);
+/* Return 1 if the given protocol supports OTR, 0 otherwise. */
+int otrg_plugin_proto_supports_otr(const char *proto);
+
#endif
diff --git a/ui.c b/ui.c
index c152943..446ae90 100644
--- a/ui.c
+++ b/ui.c
@@ -132,6 +132,12 @@ void otrg_ui_config_buddy(GaimBuddy *buddy)
/* Calculate the policy for a particular account / username */
OtrlPolicy otrg_ui_find_policy(GaimAccount *account, const char *name)
{
+ /* Check to see if the protocol for this account supports OTR at all. */
+ const char *proto = gaim_account_get_protocol_id(account);
+ if (!otrg_plugin_proto_supports_otr(proto)) {
+ return OTRL_POLICY_NEVER;
+ }
+
if (ui_ops != NULL) {
return ui_ops->find_policy(account, name);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/pidgin-otr.git
More information about the Pkg-privacy-commits
mailing list