Code

update user messaging
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 30 Apr 2008 13:05:21 +0000 (13:05 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 30 Apr 2008 13:05:21 +0000 (13:05 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10748 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/client/events/corefunctions.pm
gosa-si/client/events/gosaTriggered.pm
gosa-si/gosa-si-server

index 62f744f07fffd2fc4ed9ad1238f0ed5a87a1ec4a..a6f96e3bc441a3a5e96b837707fa17555cf3f299 100644 (file)
@@ -6,11 +6,11 @@ my @events = (
     "registered",
     "new_ldap_config",
     "new_key",
-    "generate_hw_digest",
+    "generate_hw_digest",     # no implementations
     "detect_hardware",
     "confirm_new_key",
     "ping",
-    "import_events",
+    "import_events",    # no implementations
     );
 @EXPORT = @events;
 
index a5077f13d2faf711371dd33ba5a841a79a6a4493..789996d3b0577ad6e936608d4dbdf2419f403e77 100644 (file)
@@ -8,11 +8,11 @@ my @events = (
     "trigger_action_halt",
     "trigger_action_faireboot",
     "trigger_action_reboot",
-    "trigger_action_memcheck",
+#    "trigger_action_memcheck",   # not yet implemented
     "trigger_action_reinstall",
     "trigger_action_update",
     "trigger_action_instant_update",
-    "trigger_action_sysinfo",
+#    "trigger_action_sysinfo",    # not yet implemented
     );
 @EXPORT = @events;
 
index 45d0b2c1e49ef601d1469f8880ea5cd7f48a7712..c5488c3201612f26c58b4b9d31b1a463dc331c56 100755 (executable)
@@ -1380,7 +1380,6 @@ sub watch_for_new_messages {
 
         # create outgoing messages
         my $message_to = @{$hit}[3];
-
         # translate message_to to plain login name
         my @message_to_l = split(/,/, $message_to);  
                my %receiver_h; 
@@ -1453,26 +1452,36 @@ sub watch_for_delivery_messages {
         # reciver is logged in nowhere
         if (not ref(@$res[0]) eq "ARRAY") { next; }    
 
-        # receiver is logged in at host
-        my $receiver_host = @{@{$res}[0]}[0];
-
-        # fetch key to encrypt msg propperly for usr/host
-        $sql = "SELECT * FROM $known_clients_tn WHERE (hostname='$receiver_host')";
-        &daemon_log("0 DEBUG: $sql", 7);
-        $res = $known_clients_db->exec_statement($sql);
-        my $receiver_key = @{@{$res}[0]}[2];
-
-        my %data = ('subject' => $subject, 'message' => $message, 'usr' => $receiver);
-        my $out_msg = &build_msg("usr_msg", $server_address, $receiver_host, \%data ); 
-        my $error_state = &send_msg_to_target($out_msg, $receiver_host, $receiver_key, "usr_msg", 0); 
+               my $send_succeed = 0;
+               foreach my $hit (@$res) {
+                               my $receiver_host = @$hit[0];
+                               &daemon_log("M DEBUG: user '$receiver' is logged in at host '$receiver_host'", 7);
+
+                               # fetch key to encrypt msg propperly for usr/host
+                               my $sql = "SELECT * FROM $known_clients_tn WHERE (hostname='$receiver_host')";
+                               &daemon_log("0 DEBUG: $sql", 7);
+                               my $res = $known_clients_db->exec_statement($sql);
+
+                               # host is already down
+                               if (not ref(@$res[0]) eq "ARRAY") { next; }
+
+                               # host is on
+                               my $receiver_key = @{@{$res}[0]}[2];
+                               my %data = ('subject' => $subject, 'message' => $message, 'usr' => $receiver);
+                               my $out_msg = &build_msg("usr_msg", $server_address, $receiver_host, \%data ); 
+                               my $error = &send_msg_to_target($out_msg, $receiver_host, $receiver_key, "usr_msg", 0); 
+                               if ($error != 0 ) {
+                                       $send_succeed++ ;
+                               }
+               }
 
-        if ($error_state == 0) {
-            # set outgoing msg at db to deliverd
-            my $sql = "UPDATE $messaging_tn SET flag='d' WHERE (id='$msg_id' AND direction='out' AND message_to='$receiver')"; 
-            &daemon_log("0 DEBUG: $sql", 7);
-            my $res = $messaging_db->exec_statement($sql); 
-        }
-    }
+               if ($send_succeed) {
+                               # set outgoing msg at db to deliverd
+                               my $sql = "UPDATE $messaging_tn SET flag='d' WHERE (id='$msg_id' AND direction='out' AND message_to='$receiver')"; 
+                               &daemon_log("0 DEBUG: $sql", 7);
+                               my $res = $messaging_db->exec_statement($sql); 
+               }
+       }
 
     $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay); 
     return;