[374] in BarnOwl Developers
[D-O-H] r514 - in trunk: . owl
daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:05:28 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Wed, 10 Jan 2007 15:03:48 -0500 (EST)
Author: nelhage
Date: 2007-01-10 15:03:48 -0500 (Wed, 10 Jan 2007)
New Revision: 514
Modified:
trunk/
trunk/owl/commands.c
trunk/owl/message.c
Log:
r17909@phanatique: nelhage | 2007-01-10 15:02:27 -0500
Adding infrastructure for admin messages that are questions
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- bb873fd7-8e23-0410-944a-99ec44c633eb:/branches/owl/filter-rewrite:15925
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/d-o-h/trunk:17907
+ bb873fd7-8e23-0410-944a-99ec44c633eb:/branches/owl/filter-rewrite:15925
bb873fd7-8e23-0410-944a-99ec44c633eb:/local/d-o-h/trunk:17909
Modified: trunk/owl/commands.c
===================================================================
--- trunk/owl/commands.c 2007-01-10 16:12:05 UTC (rev 513)
+++ trunk/owl/commands.c 2007-01-10 20:03:48 UTC (rev 514)
@@ -732,6 +732,16 @@
"message <message>",
""),
+ OWLCMD_VOID("yes", owl_command_yes, OWL_CTX_RECV,
+ "Answer yes to a question",
+ "yes",
+ ""),
+
+ OWLCMD_VOID("no", owl_command_no, OWL_CTX_RECV,
+ "Answer no to a question",
+ "no",
+ ""),
+
/****************************************************************/
/************************* EDIT-SPECIFIC ************************/
/****************************************************************/
@@ -2429,6 +2439,50 @@
return NULL;
}
+void owl_command_yes(void)
+{
+ owl_message *m = owl_view_get_element(owl_global_get_current_view(&g),
+ owl_global_get_curmsg(&g));
+ if(!owl_message_is_question(m)) {
+ owl_function_error("That message isn't a question.");
+ return NULL;
+ }
+ if(owl_message_is_answered(m)) {
+ owl_function_error("You already answered that question.");
+ return NULL;
+ }
+ char * cmd = owl_message_get_attribute_value(m, "yescommand");
+ if(!cmd) {
+ owl_function_error("No yes command!");
+ return NULL;
+ }
+
+ owl_function_command_norv(cmd);
+ owl_message_set_isanswered(m);
+}
+
+char *owl_command_no(void)
+{
+ owl_message *m = owl_view_get_element(owl_global_get_current_view(&g),
+ owl_global_get_curmsg(&g));
+ if(!owl_message_is_question(m)) {
+ owl_function_error("That message isn't a question.");
+ return NULL;
+ }
+ if(owl_message_is_answered(m)) {
+ owl_function_error("You already answered that question.");
+ return NULL;
+ }
+ char * cmd = owl_message_get_attribute_value(m, "nocommand");
+ if(!cmd) {
+ owl_function_error("No no command!");
+ return NULL;
+ }
+
+ owl_function_command_norv(cmd);
+ owl_message_set_isanswered(m);
+}
+
/*********************************************************************/
/************************** EDIT SPECIFIC ****************************/
/*********************************************************************/
Modified: trunk/owl/message.c
===================================================================
--- trunk/owl/message.c 2007-01-10 16:12:05 UTC (rev 513)
+++ trunk/owl/message.c 2007-01-10 20:03:48 UTC (rev 514)
@@ -554,6 +554,24 @@
return(0);
}
+int owl_message_is_question(owl_message *m)
+{
+ if(!owl_message_is_type_admin(m)) return 0;
+ if(owl_message_get_attribute_value(m, "question") != NULL) return 1;
+ return 0;
+}
+
+int owl_message_is_answered(owl_message *m) {
+ if(!owl_message_is_question(m)) return 0;
+ char * q = owl_message_get_attribute_value(m, "question");
+ if(!q) return 0;
+ return !strcmp(q, "answered");
+}
+
+void owl_message_set_isanswered(owl_message *m) {
+ owl_message_set_attribute(m, "question", "answered");
+}
+
int owl_message_is_from_me(owl_message *m)
{
if (owl_message_is_type_zephyr(m)) {