OSDN Git Service

* Added GUID parameter converter.
authorAtsushi Konno <konn@users.sourceforge.jp>
Fri, 12 Dec 2008 10:19:12 +0000 (19:19 +0900)
committerAtsushi Konno <konn@users.sourceforge.jp>
Fri, 12 Dec 2008 10:19:12 +0000 (19:19 +0900)
include/chxj_tag_util.h
src/chxj_chtml10.c
src/chxj_chtml20.c
src/chxj_chtml30.c
src/chxj_chtml40.c
src/chxj_chtml50.c
src/chxj_jhtml.c
src/chxj_jxhtml.c
src/chxj_tag_util.c
src/chxj_xhtml_mobile_1_0.c
src/mod_chxj.c

index dc7aa0d..f89e01c 100644 (file)
@@ -38,7 +38,7 @@ extern int   qs_is_checked_checkbox_attr(Doc *doc, Node *tag, apr_pool_t *pool);
 extern int   chxj_chxjif_is_mine(device_table *spec, Doc *doc, Node *tag);
 extern char *qs_get_destlang_attr(Doc *doc, Node *tag, apr_pool_t *pool);
 extern char *qs_get_parse_attr(Doc *doc, Node *tag, apr_pool_t *pool);
-extern char *chxj_form_action_to_hidden_tag(request_rec *r, apr_pool_t *pool, const char *str, int xmlFlag, int post);
+extern char *chxj_form_action_to_hidden_tag(request_rec *r, apr_pool_t *pool, const char *str, int xmlFlag, int post, char **new_query_string, int docomo);
 
 #endif
 /*
index dea488a..3262bcd 100644 (file)
@@ -1861,15 +1861,20 @@ s_chtml10_start_form_tag(void *pdoc, Node *node)
   W_L("<form");
   if (attr_value) {
     char *q;
+    char *new_query_string = NULL;
     q = strchr(attr_value, '?');
     if (q) {
-      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_value, 0, post_flag);
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_value, 0, post_flag, &new_query_string, CHXJ_TRUE);
       if (new_hidden_tag) {
         *q = 0;
       }
     }
     W_L(" action=\"");
     W_V(attr_value);
+    if (new_query_string) {
+      W_L("?");
+      W_V(new_query_string);
+    }
     W_L("\"");
   }
   if (attr_method) {
index 107f685..254c608 100644 (file)
@@ -1496,15 +1496,20 @@ s_chtml20_start_form_tag(void *pdoc, Node *node)
   W_L("<form");
   if (attr_action) {
     char *q;
+    char *new_query_string = NULL;
     q = strchr(attr_action, '?');
     if (q) {
-      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag);
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &new_query_string, CHXJ_TRUE);
       if (new_hidden_tag) {
         *q = 0;
       }
     }
     W_L(" action=\"");
     W_V(attr_action);
+    if (new_query_string) {
+      W_L("?");
+      W_V(new_query_string);
+    }
     W_L("\"");
   }
   if (attr_method) {
index 3a99038..fd1600e 100644 (file)
@@ -1350,15 +1350,20 @@ s_chtml30_start_form_tag(void *pdoc, Node *node)
   W_L("<form");
   if (attr_action) {
     char *q;
+    char *new_query_string = NULL;
     q = strchr(attr_action, '?');
     if (q) {
-      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag);
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &new_query_string, CHXJ_TRUE);
       if (new_hidden_tag) {
         *q = 0;
       }
     }
     W_L(" action=\"");
     W_V(attr_action);
+    if (new_query_string) {
+      W_L("?");
+      W_V(new_query_string);
+    }
     W_L("\"");
   }
   if (attr_method) {
index a8076a0..667af52 100644 (file)
@@ -1356,15 +1356,20 @@ s_chtml40_start_form_tag(void *pdoc, Node *node)
   W_L("<form");
   if (attr_action) {
     char *q;
+    char *new_query_string = NULL;
     q = strchr(attr_action, '?');
     if (q) {
-      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag);
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &new_query_string, CHXJ_TRUE);
       if (new_hidden_tag) {
         *q = 0;
       }
     }
     W_L(" action=\"");
     W_V(attr_action);
+    if (new_query_string) {
+      W_L("?");
+      W_V(new_query_string);
+    }
     W_L("\"");
   }
   if (attr_method) {
index 7708135..020f6a9 100644 (file)
@@ -1397,15 +1397,20 @@ s_chtml50_start_form_tag(void *pdoc, Node *node)
   W_L("<form");
   if (attr_action) {
     char *q;
+    char *new_query_string = NULL;
     q = strchr(attr_action, '?');
     if (q) {
-      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag);
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &new_query_string, CHXJ_TRUE);
       if (new_hidden_tag) {
         *q = 0;
       }
     }
     W_L(" action=\"");
     W_V(attr_action);
+    if (new_query_string) {
+      W_L("?");
+      W_V(new_query_string);
+    }
     W_L("\"");
   }
   if (attr_method) {
index bd6eafe..cc252dc 100644 (file)
@@ -1397,9 +1397,10 @@ s_jhtml_start_form_tag(void *pdoc, Node *node)
   W_L("<form");
   if (attr_action) {
     char *q;
+    char *unused = NULL;
     q = strchr(attr_action, '?');
     if (q) {
-      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag);
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 0, post_flag, &unused, CHXJ_FALSE);
       if (new_hidden_tag) {
         *q = 0;
       }
index 112b855..5f3e973 100644 (file)
@@ -1447,9 +1447,10 @@ s_jxhtml_start_form_tag(void *pdoc, Node *node)
   W_L("<form");
   if (attr_action) {
     char *q;
+    char *unused = NULL;
     q = strchr(attr_action, '?');
     if (q) {
-      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag);
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag, &unused, CHXJ_FALSE);
       if (new_hidden_tag) {
         *q = 0;
       }
index 023adac..f63ff18 100644 (file)
@@ -591,9 +591,10 @@ qs_get_parse_attr(Doc *doc, Node *tag, apr_pool_t *pool)
 
 
 char *
-chxj_form_action_to_hidden_tag(request_rec *r, apr_pool_t *pool, const char *str, int xmlFlag, int post)
+chxj_form_action_to_hidden_tag(request_rec *r, apr_pool_t *pool, const char *str, int xmlFlag, int post, char **new_query_string, int docomo)
 {
   char *s = apr_pstrdup(pool, str);
+  *new_query_string = NULL;
   if (!s) return NULL;
   if (chxj_starts_with(s, "http://") || chxj_starts_with(s, "https://")) {
     apr_uri_t url;
@@ -620,17 +621,22 @@ chxj_form_action_to_hidden_tag(request_rec *r, apr_pool_t *pool, const char *str
       if (!val) val = "";
     }
     char *tmp = NULL;
-    if (! post || strcasecmp(key, "_chxj_cc") == 0 || strcasecmp(key, "_chxj_nc") == 0) {
-      tmp = apr_psprintf(pool, "<input type=\"hidden\" name=\"%s\" value=\"%s\"%s>", key, chxj_url_decode(pool, val), (xmlFlag == 1) ? " /" : "");
+    if (strcasecmp(key, "guid") == 0 && docomo) {
+      *new_query_string = apr_psprintf(pool, "%s=%s", key, val);
     }
     else {
-      tmp = apr_psprintf(pool, "<input type=\"hidden\" name=\"_chxj_qs_%s\" value=\"%s\"%s>", key, chxj_url_decode(pool, val), (xmlFlag == 1) ? " /" : "");
-    }
-    if (result) {
-      result = apr_pstrcat(pool, result, tmp, NULL);
-    }
-    else {
-      result = tmp;
+      if (! post || strcasecmp(key, "_chxj_cc") == 0 || strcasecmp(key, "_chxj_nc") == 0) {
+        tmp = apr_psprintf(pool, "<input type=\"hidden\" name=\"%s\" value=\"%s\"%s>", key, chxj_url_decode(pool, val), (xmlFlag == 1) ? " /" : "");
+      }
+      else {
+        tmp = apr_psprintf(pool, "<input type=\"hidden\" name=\"_chxj_qs_%s\" value=\"%s\"%s>", key, chxj_url_decode(pool, val), (xmlFlag == 1) ? " /" : "");
+      }
+      if (result) {
+        result = apr_pstrcat(pool, result, tmp, NULL);
+      }
+      else {
+        result = tmp;
+      }
     }
   }
   return result;
index bdd73db..59b7da5 100644 (file)
@@ -1355,9 +1355,10 @@ s_xhtml_1_0_start_form_tag(void *pdoc, Node *node)
   W_L("<form");
   if (attr_action) {
     char *q;
+    char *unused = NULL;
     q = strchr(attr_action, '?');
     if (q) {
-      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag);
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag, &unused, CHXJ_FALSE);
       if (new_hidden_tag) {
         *q = 0;
       }
index 17bf27b..84d6d19 100644 (file)
@@ -144,7 +144,8 @@ converter_t convert_routine[] = {
   },
 };
 
-static int chxj_convert_input_header(request_rec *r,chxjconvrule_entry *entryp);
+static int chxj_convert_input_header(request_rec *r,chxjconvrule_entry *entryp, device_table *spec);
+static void s_convert_guid_parameter_to_header(request_rec *r, const char *param, device_table *spec);
 static void s_add_cookie_id_if_has_location_header(request_rec *r, cookie_t *cookie);
 static void s_clear_cookie_header(request_rec *r, device_table *spec);
 
@@ -222,7 +223,7 @@ chxj_headers_fixup(request_rec *r)
                      HTTP_USER_AGENT, 
                      entryp->user_agent);
 
-    chxj_convert_input_header(r,entryp);
+    chxj_convert_input_header(r,entryp, spec);
 
     break;
   
@@ -426,12 +427,44 @@ chxj_convert(request_rec *r, const char **src, apr_size_t *len, device_table *sp
 
 
 /**
+ * convert GUID parameter.
+ *
+ */
+static void
+s_convert_guid_parameter_to_header(request_rec *r, const char *param, device_table *spec)
+{
+  if (strcasecmp(param, "guid") == 0) {
+    switch(spec->html_spec_type) {
+    case CHXJ_SPEC_XHtml_Mobile_1_0:
+      do {
+        char *x_up_subno = (char *)apr_table_get(r->headers_in, "x-up-subno");
+        if (x_up_subno) {
+          apr_table_setn(r->headers_in, "X-DCMGUID", x_up_subno);
+        }
+      } while(0);
+      break;
+    case CHXJ_SPEC_Jhtml:
+    case CHXJ_SPEC_Jxhtml:
+      do {
+        char *x_jphone_uid = (char *)apr_table_get(r->headers_in, "x-jphone-uid");
+        if (x_jphone_uid) {
+          apr_table_setn(r->headers_in, "X-DCMGUID", x_jphone_uid);
+        }
+      } while(0);
+      break;
+    default:
+      break;
+    }
+  }
+}
+
+/**
  * It converts it from HEADER.
  *
  * @param r   [i]
  */
 static int
-chxj_convert_input_header(request_rec *r,chxjconvrule_entry *entryp) 
+chxj_convert_input_header(request_rec *r,chxjconvrule_entry *entryp, device_table *spec
 {
 
   char       *buff;
@@ -532,7 +565,7 @@ chxj_convert_input_header(request_rec *r,chxjconvrule_entry *entryp)
         else {
           dname = "";
         }
-
+        s_convert_guid_parameter_to_header(r, dname, spec);
         result = apr_pstrcat(r->pool, result, dname, "=", dvalue, NULL);
       }
       else {
@@ -608,7 +641,8 @@ chxj_input_convert(
   request_rec         *r, 
   const char          **src, 
   apr_size_t          *len, 
-  chxjconvrule_entry  *entryp)
+  chxjconvrule_entry  *entryp,
+  device_table        *spec)
 {
   char     *pair;
   char     *name;
@@ -715,6 +749,7 @@ chxj_input_convert(
           dname = "";
         }
 
+
         result = apr_pstrcat(pool, result, dname, "=", dvalue, NULL);
       }
       else {
@@ -790,6 +825,7 @@ chxj_input_convert(
         else {
           r->args = apr_pstrcat(pool, &name[sizeof(CHXJ_QUERY_STRING_PARAM_PREFIX)-1], "=", dvalue, NULL);
         }
+        s_convert_guid_parameter_to_header(r, &name[sizeof(CHXJ_QUERY_STRING_PARAM_PREFIX)-1], spec);
       }
     }
     else
@@ -807,6 +843,7 @@ chxj_input_convert(
         else {
           r->args = apr_pstrcat(pool, &name[sizeof(CHXJ_QUERY_STRING_PARAM_PREFIX_ENC)-1], "=", dvalue, NULL);
         }
+        s_convert_guid_parameter_to_header(r, &name[sizeof(CHXJ_QUERY_STRING_PARAM_PREFIX_ENC)-1], spec);
       }
     }
     DBG(r, "REQ[%X] ************************ name:[%s]", (unsigned int)(apr_size_t)r, name);
@@ -1258,7 +1295,7 @@ chxj_input_handler(request_rec *r)
    * now convert.
    */
   if (post_data_len > 0) {
-    post_data = chxj_input_convert(r, (const char**)&post_data, (apr_size_t*)&post_data_len, entryp);
+    post_data = chxj_input_convert(r, (const char**)&post_data, (apr_size_t*)&post_data_len, entryp, spec);
     DBG(r, "(in:exchange)POSTDATA:[%s]", post_data);
   }