OSDN Git Service

First cut of emobile support. Closes #12453.
authormatusita <matusita@180c8125-5b33-4295-ad04-72a68a15b4cc>
Tue, 13 May 2008 02:53:31 +0000 (02:53 +0000)
committermatusita <matusita@180c8125-5b33-4295-ad04-72a68a15b4cc>
Tue, 13 May 2008 02:53:31 +0000 (02:53 +0000)
TODO: is_emobile*() logic is somewhat ugly.

ChangeLog
etc/dot.keitairc
keitairc
lib/Keitairc/ClientInfo.pm
lib/Keitairc/Config.pm
lib/Keitairc/View.pm
lib/plugins/00location_receiver
lib/templates/location.html

index 0b34ec1..f605a15 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-05-12  Makoto Matsushita  <matusita@jp.FreeBSD.org>
+
+       * keitairc, etc/dot.keitairc, lib/Keitairc/ClientInfo.pm,
+       lib/Keitairc/Config.pm, lib/Keitairc/View.pm,
+       lib/plugins/00location_receiver, lib/templates/location.html:
+       emobile\e$BC<Kv%5%]!<%H!%%f!<%6\e(BID(x-em-uid)\e$B$K$h$k%f!<%6G'>Z!$$*$h$S0L\e(B
+       \e$BCV>pJsAw?.\e(B(\e$B8=;~E@$G$O\e(BH11T\e$B$N$_\e(B)\e$B$KBP1~!%\e(B Closes #12453.
+
 2008-05-11  ISHIKAWA Mutsumi <ishikawa@debian.org>
 
        * keitairc
index f9d8918..2eb4a41 100644 (file)
@@ -1,7 +1,7 @@
 #
 # sample ~/.keitairc for keitairc 2.x
 #
-# $Id: dot.keitairc,v 1.13 2008-05-10 05:27:54 matusita Exp $
+# $Id: dot.keitairc,v 1.14 2008-05-13 02:53:31 matusita Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/etc/dot.keitairc,v $
 
 ################################################################
@@ -48,6 +48,9 @@ web_password = 1234
 # Softbank
 # softbank_serial_key = XXXXXXXXXXXXXXXXXXXXXXX
 
+# E-MOBILE
+# emobile_userid = uXXXXXXXXXXXXXXXXX
+
 ################################################################
 # Advanced setup
 ################################################################
index c1549a6..c325132 100755 (executable)
--- a/keitairc
+++ b/keitairc
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 # keitairc
-# $Id: keitairc,v 1.54 2008-05-11 12:24:54 ishikawa Exp $
+# $Id: keitairc,v 1.55 2008-05-13 02:53:31 matusita Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/keitairc,v $
 #
 # Copyright (c) 2003-2008 Jun Morimoto <morimoto@mrmt.net>
@@ -353,6 +353,25 @@ sub action_root{
                }
        }
 
+       if($ci->is_emobile()){
+               my $userid = $ci->{header}->{x_em_uid};
+               if(length $userid){
+                       if(my $s = $sm->verify({serial_key => $userid,
+                                               user_agent => $ci->user_agent()})){
+                               ::log_debug("redirect to /$s->{id}/index from userid");
+                               my $view = new Keitairc::View($cf, $ci, $s->{id});
+                               return $view->redirect("/$s->{id}/index");
+                       }
+
+                       if($userid eq $cf->emobile_userid()){
+                               my $s = $sm->add($ci->user_agent(), $userid);
+                               ::log_debug("redirect to /$s->{id}/index from emobile_userid");
+                               my $view = new Keitairc::View($cf, $ci, $s->{id});
+                               return $view->redirect("/$s->{id}/index");
+                       }
+               }
+       }
+
        my $view = new Keitairc::View($cf, $ci);
        return $view->render('root.html', {
                docomo_foma_icc => $cf->docomo_foma_icc(),
index e6bad62..154d871 100644 (file)
@@ -1,6 +1,6 @@
 # -*-perl-*-
 # Keitairc::ClientInfo
-# $Id: ClientInfo.pm,v 1.3 2008-05-08 14:23:16 matusita Exp $
+# $Id: ClientInfo.pm,v 1.4 2008-05-13 02:53:31 matusita Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/ClientInfo.pm,v $
 #
 # Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
@@ -63,9 +63,29 @@ sub is_softbank{
 }
 
 ################################################################
+sub is_emobile{
+       my $me = shift;
+       $me->is_emobile_mobilebrowser() + $me->is_emobile_openbrowser();
+}
+
+################################################################
+sub is_emobile_mobilebrowser{
+       my $me = shift;
+       $me->{header}->{user_agent} =~ /^emobile/;
+}
+
+################################################################
+sub is_emobile_openbrowser{
+       my $me = shift;
+       # http://developer.emnet.ne.jp/useragent.html
+       $me->{header}->{user_agent} =~ /(H11T; like Gecko|\) S11HT$)/;
+}
+
+################################################################
 sub is_mobile{
        my $me = shift;
-       $me->is_ezweb() + $me->is_docomo() + $me->is_softbank();
+       $me->is_ezweb() + $me->is_docomo()
+               + $me->is_softbank() + $me->is_emobile_mobilebrowser();
 }
 
 ################################################################
@@ -101,6 +121,12 @@ sub subscribe_id{
 }
 
 ################################################################
+sub userid{
+       my $me = shift;
+       $me->{header}->{x_em_uid};
+}
+
+################################################################
 sub serial_key{
        my $me = shift;
        if($me->is_softbank()){
@@ -109,6 +135,9 @@ sub serial_key{
        if($me->is_ezweb()){
                return $me->subscribe_id();
        }
+       if($me->is_emobile()){
+               return $me->userid();
+       }
 }
 
 ################################################################
index 066b93d..3ef46fe 100644 (file)
@@ -1,6 +1,6 @@
 # -*-perl-*-
 # Keitairc::Config
-# $Id: Config.pm,v 1.13 2008-05-10 05:27:54 matusita Exp $
+# $Id: Config.pm,v 1.14 2008-05-13 02:53:31 matusita Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/Config.pm,v $
 #
 # Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
@@ -28,7 +28,7 @@ sub new{
                   irc_keyword
                   au_subscriber_id au_pcsv
                   docomo_foma_icc docomo_imodeid
-                  softbank_serial_key
+                  softbank_serial_key emobile_userid
                   use_cookie cookie_ttl session_ttl
                   web_port web_title web_lines web_root
                   web_username web_password web_host
index cc51b6e..ca6ee8f 100644 (file)
@@ -1,6 +1,6 @@
 # -*-perl-*-
 # Keitairc::View
-# $Id: View.pm,v 1.11 2008-05-10 05:27:54 matusita Exp $
+# $Id: View.pm,v 1.12 2008-05-13 02:53:31 matusita Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/Keitairc/View.pm,v $
 #
 # Copyright (c) 2008 Jun Morimoto <morimoto@mrmt.net>
@@ -79,6 +79,7 @@ sub template{
        $p->{is_docomo} = $me->{ClientInfo}->is_docomo();
        $p->{is_ezweb} = $me->{ClientInfo}->is_ezweb();
        $p->{is_softbank} = $me->{ClientInfo}->is_softbank();
+       $p->{is_emobile} = $me->{ClientInfo}->is_emobile();
        $p->{is_mobile} = $me->{ClientInfo}->is_mobile();
 
        map {
index 4afab25..c97b57a 100644 (file)
@@ -2,7 +2,7 @@
 # keitairc/lib/plugins/00location_receiver
 # °ÌÃÖ¾ðÊóÁ÷¿®¡¢¤Î¥³¡¼¥ë¥Ð¥Ã¥¯
 #
-# $Id: 00location_receiver,v 1.9 2008-05-11 14:18:51 matusita Exp $
+# $Id: 00location_receiver,v 1.10 2008-05-13 02:53:31 matusita Exp $
 # $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00location_receiver,v $
 
 use Net::HTTP;
@@ -238,6 +238,49 @@ $plugin = {
                        return $view->render('location_receiver.html', $p);
                }
 
+               # http://developer.emnet.ne.jp/browser3-1.html
+               # Example:
+               # http://www.emobilemap.net/positioning.cgi?ver=MOPA-001-2001&pos=N35.44.33.156E135.22.33.124&geo=wgs84&x-acy=1
+               if($ci->is_emobile()){
+                       unless(defined $h{pos}) {
+                               $p->{error} = 1;
+                               $p->{error_lcs} = 1;
+                               return $view->render('location_receiver.html', $p);
+                       }
+
+                       my ($wx, $wy);
+                       if($h{pos} =~ /N([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)E([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/){
+                               ($wx, $wy) = ($1, $2);
+                       }
+
+                       ($wx, $wy) = (dms_to_degree($wx), dms_to_degree($wy));
+                       my ($tx, $ty) = wgs84_to_tokyo($wx, $wy);
+                       my $xml_code = get_rgeocode_xml($wx, $wy);
+                       unless($xml_code){
+                               $p->{error} = 1;
+                               $p->{rgeocode_noresponse} = 1;
+                               return $view->render('location_receiver.html', $p);
+                       }
+
+                       my $xml = XMLin($xml_code);
+                       if($xml->{status} ne 'true'){
+                               $p->{error} = 1;
+                               $p->{rgeocode_invalid} = 1;
+                               return $view->render('location_receiver.html', $p);
+                       }
+                       $p->{wx} = $wx;
+                       $p->{wy} = $wy;
+                       $p->{tx} = $tx;
+                       $p->{ty} = $ty;
+                       $p->{map_image_url} = google_map_image($wx, $wy, 'gif');
+                       $p->{address} = $xml->{prefecture}->{pname} .
+                                       $xml->{municipality}->{mname} .
+                                       $xml->{local}->{section};
+                       Encode::_utf8_off($p->{address}) if Encode::is_utf8($p->{address});
+                       Encode::from_to($p->{address}, 'utf8', 'shiftjis');
+                       return $view->render('location_receiver.html', $p);
+               }
+
                return $view->render('location_receiver.html', $p);
        }
 };
index 5ddd3e3..038ac0f 100644 (file)
       <a accesskey="2" href="location:auto?url=http://<!-- tmpl_var web_host -->:<!-- tmpl_var root -->/<!-- tmpl_var session_id -->/location_receiver/<!-- tmpl_var cid -->">[2] \88Ê\92u\8fî\95ñ\91ª\92è(3GC\92[\96\96)</a><br />
     </tmpl_if>
 
+    <tmpl_if is_emobile>
+      <a accesskey="1" href="<!-- tmpl_var root --><!-- tmpl_var session_id -->/location_receiver/<!-- tmpl_var cid -->" measure="auto">[1] GPS\88Ê\92u\91ª\92è</a><br />
+      <a accesskey="2" href="<!-- tmpl_var root --><!-- tmpl_var session_id -->/location_receiver/<!-- tmpl_var cid -->" measure="cid">[2] \8aÈ\88Õ\88Ê\92u\91ª\92è</a><br />
+    </tmpl_if>
+
     <hr />
     <a accesskey="8" href="../index">[8] Á¬ÈÙؽÄ</a><br />
     <hr />