Tadashi Okoshi
slash****@users*****
2005年 12月 10日 (土) 07:14:09 JST
Index: affelio/lib/Affelio/Managing/NewsAggregator.pm
diff -u /dev/null affelio/lib/Affelio/Managing/NewsAggregator.pm:1.1
--- /dev/null Sat Dec 10 07:14:08 2005
+++ affelio/lib/Affelio/Managing/NewsAggregator.pm Sat Dec 10 07:14:08 2005
@@ -0,0 +1,112 @@
+# Copyright (C) 2005 FishGrove Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id: NewsAggregator.pm,v 1.1 2005/12/09 22:14:08 slash5234 Exp $
+
+package Affelio::Managing::NewsAggregator;
+{
+ use strict;
+ use lib("../../../extlib");
+ use DBI;
+ use Jcode;
+ use lib("../../");
+ use Affelio::misc::CGIError;
+ use Affelio::misc::Time qw(get_timestamp);
+ use Affelio::misc::Encoding qw(db_encode db_decode);
+ use Affelio::misc::Debug qw(debug_print);
+ use Affelio::misc::WSSE;
+ use Affelio::SNS::Handshaker_c;
+ use Affelio::exception::CommunicationException;
+
+ #######################################################################
+ #Constructor
+ #######################################################################
+ sub new{
+ my $class = shift;
+ my $af = shift;
+
+ debug_print("NewsAggregator::new: start.");
+
+ my $self = {af => $af
+ };
+
+ bless $self, $class;
+
+ debug_print("NewsAggregator::new: end.");
+ return $self;
+ }
+
+ #######################################################################
+ #get_one
+ #######################################################################
+ sub get_one{
+ my $self = shift;
+ my $af = $self->{af};
+
+ debug_print("NewsAggregator::get_one: start.");
+
+ #########################################################
+ #Get a friend whose last_news_in is smallet (oldest).
+ my $result = $af->getFM->get_all_friend_list(sort => "last_news_in",
+ order => "desc");
+
+ my @row = $result->fetchrow_array;
+ #uid, af_id, nickname, timestamp, password, intro, option_pid, lastupdated, f2list, last_news_in, last_news_out
+
+ my $af_id = $row[1];
+ my $password = $row[4];
+
+ #########################################################
+ #generate X-WSSE message
+ my $xwsse_mesg = Affelio::misc::WSSE::make_XWSSE($af->{site__web_root},
+ $password);
+
+ #########################################################
+ #Invoke SNS/Handshaker_c
+ my $ret="";
+ try{
+ $ret = get_news(dest_uri => "$af_id/bin/xml-rpc-serv.cgi",
+ xwsse_mesg => $xwsse_mesg);
+
+ }catch Affelio::exception::NetworkException with{
+ my $E = shift;
+ throw Affelio::exception::CommunicationException($E);
+
+ }catch Error with{
+ my $E = shift;
+ throw Affelio::exception::Exception($E);
+ };
+
+ #########################################################
+ #Analyze returned value
+ debug_print("NewsAggregator::get_one: ret=[$ret]");
+
+ }
+
+
+
+ #######################################################################
+ #save
+ #######################################################################
+
+
+
+ #######################################################################
+ #show
+ #######################################################################
+
+}#package
+1;
Index: affelio/lib/Affelio/Managing/WhatsNewManager.pm
diff -u affelio/lib/Affelio/Managing/WhatsNewManager.pm:1.4 affelio/lib/Affelio/Managing/WhatsNewManager.pm:removed
--- affelio/lib/Affelio/Managing/WhatsNewManager.pm:1.4 Thu Oct 27 20:15:01 2005
+++ affelio/lib/Affelio/Managing/WhatsNewManager.pm Sat Dec 10 07:14:09 2005
@@ -1,127 +0,0 @@
-# Copyright (C) 2005 FishGrove Inc.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id: WhatsNewManager.pm,v 1.4 2005/10/27 11:15:01 slash5234 Exp $
-
-package Affelio::Managing::WhatsNewManager;
-{
- use strict;
- use lib("../../../extlib");
- use DBI;
- use Jcode;
- use lib("../../");
- use Affelio::misc::CGIError;
- use Affelio::misc::Time qw(get_timestamp);
- use Affelio::misc::Encoding qw(db_encode db_decode);
- use Affelio::misc::Debug qw(debug_print);
-
- #######################################################################
- #Constructor
- #######################################################################
- sub new{
- my $class = shift;
- my $af = shift;
-
- debug_print("WhatsNewManager::new: start.");
-
- my $self = {af => $af
- };
-
- bless $self, $class;
-
- debug_print("WhatsNewManager::new: end.");
- return $self;
- }
-
- #WhatsNewManager looks up each application directory
- #to get the whole list of message types.
-
- ########################################################################
- #retrieve_message
- ########################################################################
- #sub SQL_result get_all_group_list
- # result (mid,timestamp,msg_title,msg_type,msg_from,msg_body,readflag)
- sub retrieve_all_messages{
- my $self = shift;
-
- debug_print("MM::retrieve: start");
- my $af = $self->{af};
-
- ##############################
- #retrieve all friend records from DB
- my $sth = $af->getDB->prepare(q{SELECT * FROM AFuser_CORE_message}) or die $af->getDB->errstr;
- $sth->execute;
-
- debug_print("MM::retrieve: end");
- return($sth);
- }
-
- #######################################################################
- #post_message
- # arg1 SenderName: (app_name)
- # arg2 Title: (UTF-8)
- # arg3 Type: (Ascii)
- # arg4 Body: (free text including URL)
- #######################################################################
- sub post_message{
- my $self = shift;
- my $from = shift; #1
- my $title = shift; #2
- my $type = shift; #3
- my $body = shift; #4
-
- my $af = $self->{af};
-
- Affelio::misc::Debug::debug_print("MM::post_message: start.");
-
-# $body = Affelio::misc::Encoding::db_encode($body);
-# $title = Affelio::misc::Encoding::db_encode($title);
-# $from = Affelio::misc::Encoding::db_encode($from);
-
- #mid,timestamp,msg_title,msg_type,msg_from,msg_body,readflag
-
- ##############################
- #Get existing max ID
- my $sth = $af->getDB->prepare(q{SELECT max(mid) FROM AFuser_CORE_message}) or die $af->getDB->errstr;
- $sth->execute;
- my @row = $sth->fetchrow_array;
- my $maxid = $row[0];
- if(defined($row[0])){
- $maxid = $row[0];
- }else{
- $maxid = 0;
- }
- my $newid = $maxid+1;
- Affelio::misc::Debug::debug_print("MM::post_message: newid = $newid");
-
- my $cur_time = Affelio::misc::Time::get_timestamp();
-
- Affelio::misc::Debug::debug_print("MM::post_message: Writing to DB...");
- Affelio::misc::Debug::debug_print("MM::post_message: [$body]");
-
- ##############################
- #Insert a new record
- my $str1 = "insert into AFuser_CORE_message(mid, timestamp, msgtitle, msgtype, msgfrom, msgbody, readflag) values ($newid, '$cur_time', '$title', '$type', '$from', '$body', 0)";
- $sth = $af->getDB->prepare($str1) or die $af->getDB->errstr;
- $sth->execute or die $af->getDB->errstr;
-
- Affelio::misc::Debug::debug_print("MM::post_message: end.");
-
- return("");
- }
-
-}#package
-1;