summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 93ca5e2)
raw | patch | inline | side by side (parent: 93ca5e2)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Nov 2008 13:48:51 +0000 (13:48 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Nov 2008 13:48:51 +0000 (13:48 +0000) |
* si-client wachtes /tmp/goto_notify_* pattern and send confirm msg of seen user messages back to server
* goto2/konch/src/goto-notify was changed under this circumstance
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12940 594d385d-05f5-0310-b6e9-bd551577e9d8
* goto2/konch/src/goto-notify was changed under this circumstance
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12940 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/client/events/gosaTriggered.pm | patch | blob | history | |
gosa-si/gosa-si-client | patch | blob | history |
index 412587ebece8527ecb8ad863ee616b72bab9830b..2f6517e2c8f896621c2871b6156388719b0975d0 100644 (file)
use GOSA::GosaSupportDaemon;
use Data::Dumper;
use MIME::Base64;
+use Data::Random qw(:all);
BEGIN {}
my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]);
my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
- system( "/usr/bin/goto-notify user-message '$to' '$subject' '$message'" );
+ my $rand_file = "/tmp/goto_notify_".join("",rand_chars(set=>'alphanumeric', min=>16, max=>16));
+ open(DATEI, ">$rand_file");
+ print DATEI "source:$source\ntarget:$target\nusr:$to\nsubject:".@{$msg_hash->{'subject'}}[0]."\nmessage:".@{$msg_hash->{'message'}}[0]."\n";
+ close DATEI;
+
+ my $feedback = system("/usr/bin/goto-notify user-message '$to' '$subject' '$message' '$rand_file' &" );
# give gosa-si-server feedback, that msg was received
- $msg =~ s/<header>usr_msg<\/header>/<header>confirm_usr_msg<\/header>/g;
- my $out_hash = &create_xml_hash("confirm_usr_msg", $target, $source);
- &add_content2xml_hash($out_hash, 'usr', $to);
- &add_content2xml_hash($out_hash, 'subject', @{$msg_hash->{'subject'}}[0]);
- &add_content2xml_hash($out_hash, 'message', @{$msg_hash->{'message'}}[0]);
+# $msg =~ s/<header>usr_msg<\/header>/<header>confirm_usr_msg<\/header>/g;
+# my $out_hash = &create_xml_hash("confirm_usr_msg", $target, $source);
+# &add_content2xml_hash($out_hash, 'usr', $to);
+# &add_content2xml_hash($out_hash, 'subject', @{$msg_hash->{'subject'}}[0]);
+# &add_content2xml_hash($out_hash, 'message', @{$msg_hash->{'message'}}[0]);
- return &create_xml_string($out_hash);
+# return &create_xml_string($out_hash);
+ return
}
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index a3987e70ea920ee83c64028be8bc654ee7441741..962102fe600bb023ef651d5ffdacc487fc7da200 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
my $delay_set_time = 10;
our $prg= basename($0);
-# all x seconds the client reports logged_in users to gosa-si-server
+# all n seconds the client reports logged_in users to gosa-si-server
my $trigger_logged_in_users_report_delay = 600;
+# all n seconds the client reports messages seen by user
+my $trigger_seen_messages_delay = 30;
+
# directory where all log files from installation are stored
my $fai_log_dir = "/var/log/fai";
}
+sub trigger_seen_messages {
+ my ($kernel) = $_[KERNEL] ;
+
+ # Select all files under /tmp with prefix 'goto_notify'
+ my $goto_dir = "/tmp";
+ opendir(DIR, $goto_dir);
+ my @goto_files = grep { /^goto_notify_/ && -f "$goto_dir/$_" } readdir(DIR);
+ closedir DIR;
+
+ # Check if file has 'seen' tag
+ foreach my $goto_file (@goto_files) {
+ open(FILE, "$goto_dir/$goto_file");
+ my @lines = <FILE>;
+ close FILE;
+
+ my $source;
+ my $target;
+ my $usr;
+ my $subject;
+ my $message;
+ my $seen = 0;
+ chomp(@lines);
+ foreach my $line (@lines) {
+ if ($line =~ /^source:([\S\s]*)$/) {
+ $source = $1
+ }
+ if ($line =~ /^target:([\S\s]*)$/) {
+ $target = $1;
+ }
+ if ($line =~ /^usr:([\S\s]*)$/) {
+ $usr = $1;
+ }
+ if ($line =~ /^subject:([\S\s]*)$/) {
+ $subject = $1;
+ }
+ if ($line =~ /^message:([\S\s]*)$/) {
+ $message = $1;
+ }
+ if ($line =~ /^seen$/) {
+ $seen++;
+ }
+ }
+
+ # Send 'confirm_usr_msg' back to msg-hosting server
+ if ($seen) {
+ my %data = ('usr'=>$usr, 'subject'=>$subject, 'message'=>$message);
+ my $confirm_msg = &build_msg("confirm_usr_msg", $target, $source, \%data);
+ my $send_error = &send_msg_to_target($confirm_msg, $server_address, $server_key);
+
+ # Delete file
+ if (not $send_error) {
+ system("rm $goto_dir/$goto_file");
+ }
+ }
+ }
+
+ $kernel->delay_set('trigger_seen_messages', $trigger_seen_messages_delay);
+
+ return;
+}
+
+
sub generic_file_error {
my ( $heap, $operation, $errno, $error_string, $wheel_id ) =
@_[ HEAP, ARG0, ARG1, ARG2, ARG3 ];
$heap->{watchers}->{ $watcher->ID } = $watcher;
}
$kernel->yield('trigger_logged_in_users_report');
+ $kernel->yield('trigger_seen_messages');
}
# trigger periodical tasks
trigger_new_key => \&trigger_new_key,
trigger_logged_in_users_report => \&trigger_logged_in_users_report,
+ trigger_seen_messages => \&trigger_seen_messages,
# handle records from each defined file differently
fifo_record => \&fifo_got_record,