[Affelio-cvs 1229] CVS update: affelio/apps/diary/Diary

Back to archive index

Tadashi Okoshi slash****@users*****
2006年 4月 17日 (月) 16:09:17 JST


Index: affelio/apps/diary/Diary/RetrieveMoblog.pm
diff -u affelio/apps/diary/Diary/RetrieveMoblog.pm:1.2 affelio/apps/diary/Diary/RetrieveMoblog.pm:1.3
--- affelio/apps/diary/Diary/RetrieveMoblog.pm:1.2	Thu Apr  6 02:27:52 2006
+++ affelio/apps/diary/Diary/RetrieveMoblog.pm	Mon Apr 17 16:09:17 2006
@@ -83,7 +83,7 @@
 	#####################################
 	#For each message....
 	for(my $count=0; $count < $num_mail; $count++) {
-	    
+   
 	    my $msg_id = $msgid_list[$count];
 	    my $entity = $parser->parse_data($popper->get($msg_id));
 	    if(!$entity){
@@ -110,7 +110,7 @@
 	    }
 	    debug_print("Diary::Moblog::retrieve: Mail from : $1\n");
 	    
-	    $this_date = &conv_datetime($entity->head->get('date'));
+	    $this_date = &distill_datetime($entity->head->get('date'));
 	    my $this_title = $entity->head->get('subject');
 	    my $this_body = "";
 	    my $this_num_files = 0;
@@ -191,8 +191,6 @@
 	    }
 	    #if(multipart)
 	    
-	    # POP3サーバのファイルを削除
-	    $popper->delete($msg_id);
 	    
 	    #####################################
 	    #Several processing on title & body
@@ -222,30 +220,19 @@
 		  }
 		 );
 
-	    debug_print("Diary::Moblog::retrieve: going to next message...");
-	}
-	
-	#####################################
-	#Logoff
-	$popper->quit;
-
-	##############################################################
-	#メールサーバとのやりとりが終了... let's post them
-	##############################################################
-	foreach my $entry (@mesgs){
-	    debug_print("Diary::Moblog::retrieve: " . $entry->{title});
-	    debug_print("Diary::Moblog::retrieve: " . $entry->{body});
-	    debug_print("Diary::Moblog::retrieve: " . $entry->{files});
-
-	    foreach my $image (@{$entry->{files}}){
-		$entry->{body} .= '<p><image="' . $image . '"></p>';
+	    foreach my $image (@this_files){
+		$this_body .= '<p><image="' . $image . '"></p>';
 	    }
 
 	    debug_print("Diary::Write::show: before add entry");
 	    my $time = time;
+
+	    $this_title =~ s|\r$||g;
+	    $this_title =~ s|\n$||g;
+
 	    my $new_id = addEntry($diary, 
-				  $entry->{title}, 
-				  $entry->{body}, 
+				  $this_title,
+				  $this_body,
 				  1, 
 				  $diary->{afap}->get_owner_info("nickname"),
 				  $diary->{afap}->get_owner_info("afid"),
@@ -253,7 +240,7 @@
 	    copyUploadImage($diary, $new_id);
 	    debug_print("Diary::Write::show: post news");
 
-	    $diary->{afap}->post_news($entry->{title}, 
+	    $diary->{afap}->post_news($this_title,
 				      "", 
 				      $diary->{afap}->get_owner_info("nickname"),
 				      $diary->{afap}->get_site_info("web_root") . "/apps/". 
@@ -266,13 +253,18 @@
 #	    }
 	    debug_print("Diary::Write::show: after submit");
 
+	    # POP3サーバのファイルを削除
+	    $popper->delete($msg_id);
 
+	    debug_print("Diary::Moblog::retrieve: going to next message...");
 	}
-	#foreach
 	
+	#####################################
+	#Logoff
+	$popper->quit;
 
     }
-    
+
 
     sub setup_regex{
 	return(
@@ -287,38 +279,24 @@
 q{;:".\\\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\\\x80-\xff\n\015\[\]]|\\\\[} .
 q{^\x80-\xff])*\]))*} );
     }
-
-
-
 }
 
-
-sub conv_datetime {
-	my %monthlist = ("Jan" => "01", "Feb" => "02", "Mar" => "03", "Apr" => "04", 
-						"May" => "05", "Jun" => "06", "Jul" => "07", "Aug" => "08", 
-						"Sep" => "09", "Oct" => "10", "Nov" => "11", "Dec" => "12");
-	my $converted = "";
-	#カッコはコメントなので、無視するために削除する
-	$_[0] =~ s/\(\w*\)//g;
-	if ($_[0] =~ /\w*\s(\d{1})\s([A-Z][a-z][a-z])\s(\d+)\s(\d+):(\d+):(\d+)/) {
-		#day = $1, month = $monthlist{$2}, year = $3, $hour = $4, $minute = $5, $second = $6
-		#秒が省略されていた場合は00をセットする
-		if ($6 eq "") {
-			$6 = "00";
-		}
-		$converted = $3 . $monthlist{$2} . "0" . $1 . $4 . $5 . $6;
-	}
-	elsif ($_[0] =~ /\w*\s(\d+)\s([A-Z][a-z][a-z])\s(\d+)\s(\d+):(\d+):(\d+)/) {
-		#day = $1, month = $monthlist{$2}, year = $3, $hour = $4, $minute = $5, $second = $6
-		#秒が省略されていた場合は00をセットする
-		if ($6 eq "") {
-			$6 = "00";
-		}
-		$converted = $3 . $monthlist{$2} . $1 . $4 . $5 . $6;
-	}
-	return $converted;
+sub distill_datetime {
+    my $in = shift;
+    my %m = ("Jan" => "01", "Feb" => "02", "Mar" => "03", "Apr" => "04", "May" => "05", "Jun" => "06", 
+	     "Jul" => "07", "Aug" => "08", "Sep" => "09", "Oct" => "10", "Nov" => "11", "Dec" => "12");
+    my $c = "";
+    
+    $in =~ s/\(\w*\)//g;
+    if ($in =~ /\w*\s(\d{1})\s([A-Z][a-z][a-z])\s(\d+)\s(\d+):(\d+):(\d+)/) {
+	if ($6 eq "") { $6 = "00"; }
+	$c = $3 . $m{$2} . "0" . $1 . $4 . $5 . $6;
+    }
+    elsif ($in =~ /\w*\s(\d+)\s([A-Z][a-z][a-z])\s(\d+)\s(\d+):(\d+):(\d+)/) {
+	if ($6 eq "") { $6 = "00"; }
+	$c = $3 . $m{$2} . $1 . $4 . $5 . $6;
+    }
+    return $c;
 }
 
-
-
 1;


Affelio-cvs メーリングリストの案内
Back to archive index