From bbec2a66cd4321b3f8c39684236e1bbb8de52da5 Mon Sep 17 00:00:00 2001
From: edgrif <edgrif>
Date: Fri, 14 Aug 2009 09:52:36 +0000
Subject: [PATCH] add request tag to xml.

---
 src/zmapApp/zmapAppremote.c                | 56 +++++++++++++++++-----
 src/zmapControl/zmapControl.c              |  6 +--
 src/zmapControl/zmapControlRemoteReceive.c | 29 +++++++++--
 3 files changed, 74 insertions(+), 17 deletions(-)

diff --git a/src/zmapApp/zmapAppremote.c b/src/zmapApp/zmapAppremote.c
index 7e711b2fe..134c04f6d 100755
--- a/src/zmapApp/zmapAppremote.c
+++ b/src/zmapApp/zmapAppremote.c
@@ -27,9 +27,9 @@
  *
  * Exported functions: None
  * HISTORY:
- * Last edited: Dec 19 09:58 2008 (edgrif)
+ * Last edited: Aug 13 18:01 2009 (edgrif)
  * Created: Thu May  5 18:19:30 2005 (rds)
- * CVS info:   $Id: zmapAppremote.c,v 1.37 2008-12-19 10:00:56 edgrif Exp $
+ * CVS info:   $Id: zmapAppremote.c,v 1.38 2009-08-14 09:52:36 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -78,6 +78,8 @@ typedef struct
 static char *application_execute_command(char *command_text, gpointer app_context, int *statusCode);
 static gboolean start(void *userData, ZMapXMLElement element, ZMapXMLParser parser);
 static gboolean end(void *userData, ZMapXMLElement element, ZMapXMLParser parser);
+static gboolean req_start(void *userData, ZMapXMLElement element, ZMapXMLParser parser);
+static gboolean req_end(void *userData, ZMapXMLElement element, ZMapXMLParser parser);
 
 static void createZMap(ZMapAppContext app, RequestData request_data, ResponseContext response);
 static void send_finalised(ZMapXRemoteObj client);
@@ -85,10 +87,12 @@ static gboolean finalExit(gpointer data) ;
 
 static ZMapXMLObjTagFunctionsStruct start_handlers_G[] = {
   { "zmap", start },
+  { "request", req_start },
   { NULL,   NULL  }
 };
 static ZMapXMLObjTagFunctionsStruct end_handlers_G[] = {
-  { "zmap", end  },
+  { "zmap",    end  },
+  { "request", req_end  },
   { NULL,   NULL }
 };
 
@@ -131,11 +135,13 @@ void zmapAppRemoteInstaller(GtkWidget *widget, gpointer app_context_data)
 
               zMapXRemoteSetResponseAtomName(client, ZMAP_CLIENT_RESPONSE_ATOM_NAME);
 
-              req = g_strdup_printf("<zmap action=\"register_client\">\n"
-                                    "  <client xwid=\"0x%lx\" request_atom=\"%s\" response_atom=\"%s\" >\n"
-                                    "    <action>%s</action>\n"
-                                    "    <action>%s</action>\n"
-                                    "  </client>\n"
+              req = g_strdup_printf("<zmap>\n"
+				    "  <request action=\"register_client\">\n"
+                                    "    <client xwid=\"0x%lx\" request_atom=\"%s\" response_atom=\"%s\" >\n"
+                                    "      <action>%s</action>\n"
+                                    "      <action>%s</action>\n"
+                                    "    </client>\n"
+				    "  </request>\n"
                                     "</zmap>",
                                     id,
                                     ZMAP_DEFAULT_REQUEST_ATOM_NAME,
@@ -287,7 +293,9 @@ static void createZMap(ZMapAppContext app, RequestData request_data, ResponseCon
 
 static void send_finalised(ZMapXRemoteObj client)
 {
-  char *request = "<zmap action=\"finalised\" />";
+  char *request = "<zmap>\n"
+                  "  <request action=\"finalised\" />\n"
+                  "</zmap>" ;
   char *response = NULL;
 
   g_return_if_fail(client != NULL);
@@ -314,7 +322,33 @@ static gboolean finalExit(gpointer data)
 }
 
 
+/* all the action has been moved from <zmap> to <request> */
 static gboolean start(void *user_data, ZMapXMLElement element, ZMapXMLParser parser)
+{
+  gboolean handled  = FALSE;
+
+#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
+  RequestData request_data = (RequestData)user_data;
+#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
+
+  
+  return handled ;
+}
+
+static gboolean end(void *user_data, ZMapXMLElement element, ZMapXMLParser parser)
+{
+  gboolean handled = TRUE ;
+
+#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
+  RequestData request_data = (RequestData)user_data;
+#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
+
+
+  return handled;
+}
+
+
+static gboolean req_start(void *user_data, ZMapXMLElement element, ZMapXMLParser parser)
 {
   gboolean handled  = FALSE;
   RequestData request_data = (RequestData)user_data;
@@ -336,12 +370,12 @@ static gboolean start(void *user_data, ZMapXMLElement element, ZMapXMLParser par
 	}
     }
   else
-    zMapXMLParserRaiseParsingError(parser, "Attribute 'action' is required for element 'zmap'.");
+    zMapXMLParserRaiseParsingError(parser, "Attribute 'action' is required for element 'request'.");
 
   return handled ;
 }
 
-static gboolean end(void *user_data, ZMapXMLElement element, ZMapXMLParser parser)
+static gboolean req_end(void *user_data, ZMapXMLElement element, ZMapXMLParser parser)
 {
   gboolean handled = TRUE ;
   RequestData request_data = (RequestData)user_data;
diff --git a/src/zmapControl/zmapControl.c b/src/zmapControl/zmapControl.c
index a1e376a4a..e5e601ea9 100755
--- a/src/zmapControl/zmapControl.c
+++ b/src/zmapControl/zmapControl.c
@@ -26,9 +26,9 @@
  *              the window code and the threaded server code.
  * Exported functions: See ZMap.h
  * HISTORY:
- * Last edited: Jun 12 14:41 2009 (edgrif)
+ * Last edited: Aug 14 09:11 2009 (edgrif)
  * Created: Thu Jul 24 16:06:44 2003 (edgrif)
- * CVS info:   $Id: zmapControl.c,v 1.94 2009-06-12 13:58:49 edgrif Exp $
+ * CVS info:   $Id: zmapControl.c,v 1.95 2009-08-14 09:54:18 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -1046,7 +1046,7 @@ static void remoteSendViewClosed(ZMapXRemoteObj client, unsigned long xwid)
   char *request ;
   char *response = NULL;
 
-  request = g_strdup_printf("<zmap action=\"view_closed\" > <client xwid=\"0x%lx\" /> </zmap>", xwid) ;
+  request = g_strdup_printf("<zmap> <request action=\"view_closed\"> <client xwid=\"0x%lx\" /> </request> </zmap>", xwid) ;
 
   if (zMapXRemoteSendRemoteCommand(client, request, &response) != ZMAPXREMOTE_SENDCOMMAND_SUCCEED)
     {
diff --git a/src/zmapControl/zmapControlRemoteReceive.c b/src/zmapControl/zmapControlRemoteReceive.c
index 4331a263d..7f1640ad4 100755
--- a/src/zmapControl/zmapControlRemoteReceive.c
+++ b/src/zmapControl/zmapControlRemoteReceive.c
@@ -28,9 +28,9 @@
  * Exported functions: See zmapControl_P.h
  *              
  * HISTORY:
- * Last edited: Dec 18 11:02 2008 (edgrif)
+ * Last edited: Aug 13 17:26 2009 (edgrif)
  * Created: Thu Jul 12 14:54:30 2007 (rds)
- * CVS info:   $Id: zmapControlRemoteReceive.c,v 1.4 2008-12-18 13:29:44 edgrif Exp $
+ * CVS info:   $Id: zmapControlRemoteReceive.c,v 1.5 2009-08-14 09:55:20 edgrif Exp $
  *-------------------------------------------------------------------
  */
 
@@ -104,6 +104,9 @@ static void findView(gpointer data, gpointer user_data) ;
 static gboolean xml_zmap_start_cb(gpointer user_data, 
                                   ZMapXMLElement zmap_element,
                                   ZMapXMLParser parser);
+static gboolean xml_request_start_cb(gpointer user_data, 
+				     ZMapXMLElement zmap_element,
+				     ZMapXMLParser parser);
 static gboolean xml_segment_end_cb(gpointer user_data, 
                                    ZMapXMLElement segment, 
                                    ZMapXMLParser parser);
@@ -121,20 +124,26 @@ static gboolean control_execute_debug_G = FALSE;
 
 static ZMapXMLObjTagFunctionsStruct control_starts_G[] = {
   { "zmap",       xml_zmap_start_cb       },
+  { "request",    xml_request_start_cb    },
+
 #ifdef NOT_YET
   { "featureset", xml_featureset_start_cb },
   { "feature",    xml_feature_start_cb    },
 #endif
+
   { "client",     zMapXRemoteXMLGenericClientStartCB },
   {NULL, NULL}
 };
 static ZMapXMLObjTagFunctionsStruct control_ends_G[] = {
   { "zmap",       xml_return_true_cb    },
+  { "request",    xml_return_true_cb    },
   { "feature",    xml_return_true_cb    },
   { "segment",    xml_segment_end_cb    },
+
 #ifdef NOT_YET
   { "subfeature", xml_subfeature_end_cb },
 #endif
+
   { "location",   xml_location_end_cb   },
   { "style",      xml_style_end_cb      },
   {NULL, NULL}
@@ -380,9 +389,23 @@ static void createClient(ZMap zmap, ZMapXRemoteParseCommandData input_data, Resp
 
 /* Handlers */
 
+/* all the action happens in <request> now. */
 static gboolean xml_zmap_start_cb(gpointer user_data, ZMapXMLElement zmap_element,
                                   ZMapXMLParser parser)
 {
+
+#ifdef ED_G_NEVER_INCLUDE_THIS_CODE
+  ZMapXRemoteParseCommandData parsing_data = (ZMapXRemoteParseCommandData)user_data;
+#endif /* ED_G_NEVER_INCLUDE_THIS_CODE */
+
+
+  return FALSE;
+}
+
+
+static gboolean xml_request_start_cb(gpointer user_data, ZMapXMLElement zmap_element,
+				     ZMapXMLParser parser)
+{
   ZMapXMLAttribute attr = NULL;
   ZMapXRemoteParseCommandData parsing_data = (ZMapXRemoteParseCommandData)user_data;
   GQuark action = 0;
@@ -410,7 +433,7 @@ static gboolean xml_zmap_start_cb(gpointer user_data, ZMapXMLElement zmap_elemen
     }
   else
     {
-      zMapXMLParserRaiseParsingError(parser, "action is a required attribute for zmap.");
+      zMapXMLParserRaiseParsingError(parser, "action is a required attribute for request.");
       parsing_data->common.action = ZMAPCONTROL_REMOTE_INVALID;
     }
 
-- 
GitLab