Rename is_wap to is_mobile
[citadel.git] / webcit / webcit.c
index 9c50938438744b4dea9d415f26f4848e13b4f1fd..f06c546a988790a2b1f76286b1ac0abea613da05 100644 (file)
@@ -1314,7 +1314,19 @@ void seconds_since_last_gexp(void)
        end_ajax_response();
 }
 
-
+/**
+ * \brief Detects a 'mobile' user agent 
+ */
+int is_mobile_ua(char *user_agent) {
+       if (strstr(user_agent,"iPhone OS") != NULL) {
+               return 1;
+       } else if (strstr(user_agent,"Windows CE") != NULL) {
+               return 1;
+       } else if (strstr(user_agent,"SymbianOS") != NULL) {
+               return 1;
+       }
+       return 0;
+}
 
 
 /*
@@ -1364,7 +1376,7 @@ void session_loop(struct httprequest *req)
 
        WC->upload_length = 0;
        WC->upload = NULL;
-       WC->is_wap = 0;
+       WC->is_mobile = 0;
 
        hptr = req;
        if (hptr == NULL) return;
@@ -1422,6 +1434,9 @@ void session_loop(struct httprequest *req)
                }
                else if (!strncasecmp(buf, "User-agent: ", 12)) {
                        safestrncpy(user_agent, &buf[12], sizeof user_agent);
+                       if (is_mobile_ua(&buf[12])) {
+                               WC->is_mobile = 1;
+                       }
                }
                else if (!strncasecmp(buf, "X-Forwarded-Host: ", 18)) {
                        if (follow_xff) {
@@ -1440,12 +1455,6 @@ void session_loop(struct httprequest *req)
                        }
                        striplt(browser_host);
                }
-               /** Only WAP gateways explicitly name this content-type */
-               else if (strstr(buf, "text/vnd.wap.wml")) {
-                       /* since we don't have wap pages we disable this.
-                        * WC->is_wap = 1;
-                        */
-               }
        }
 
        if (ContentLength > 0) {
@@ -2110,6 +2119,7 @@ SKIP_ALL_THIS_CRAP:
        }
 }
 
+
 /*
  * Replacement for sleep() that uses select() in order to avoid SIGALRM
  */