Code

Updated focus.js
[gosa.git] / gosa-core / include / class_gosaSupportDaemon.inc
index ede15bc3671a273d7633e737902cbcfbae29ae5a..219fdbb36ca2ed0d03dcce6ff3d5524e5527e3c8 100644 (file)
@@ -68,14 +68,18 @@ class gosaSupportDaemon
    */
   public function connect()
   {
-    $this->o_sock = new Socket_Client($this->s_host,$this->i_port,TRUE,$this->f_timeout);
-    if($this->o_sock->connected()){ 
-      $this->o_sock->setEncryptionKey($this->s_encryption_key); 
-      $this->is_connected = TRUE;
+    if(!empty($this->s_host) && !empty($this->i_port)){
+      $this->o_sock = new Socket_Client($this->s_host,$this->i_port,TRUE,$this->f_timeout);
+      if($this->o_sock->connected()){ 
+        $this->o_sock->setEncryptionKey($this->s_encryption_key); 
+        $this->is_connected = TRUE;
+      }else{
+        $this->set_error($this->o_sock->get_error());
+        $this->disconnect();
+        new log("debug","gosaSupportDaemon::connect()", "Could not connect to server.", array(),$this->get_error());
+      }
     }else{
-      $this->set_error($this->o_sock->get_error());
-      $this->disconnect();
-      new log("debug","gosaSupportDaemon::connect()", "Could not connect to server.", array(),$this->get_error());
+      $this->set_error(msgPool::cmdnotfound("GOSA_SI",_("GOsa support daemon")));
     }
     return($this->is_connected);
   }
@@ -130,6 +134,57 @@ class gosaSupportDaemon
   }
 
 
+  public function FAI_get_packages($release,$package = "")
+  {
+    $this->reset_error();
+
+    if(empty($package)){
+      $xml_msg = "<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
+        "<where><clause><phrase><distribution>".$release."</distribution></phrase></clause></where></xml>";
+    }else{
+      $xml_msg = 
+        "<xml><header>gosa_query_packages_list</header><target>GOSA</target><source>GOSA</source>".
+          "<where><clause>".
+            "<connector>AND</connector>".
+            "<phrase><distribution>".$release."</distribution></phrase>".
+            "<phrase><package>".$package."</package></phrase>".
+          "</clause></where>".
+        "</xml>";
+    }
+
+    $ret = array();
+    if($this->connect()){
+      $this->o_sock->write($xml_msg);
+      $str = trim($this->o_sock->read());
+      $entries = $this->xml_to_array($str);
+      if(isset($entries['XML']) && is_array($entries['XML'])){
+
+        /* Check if returned values represent a valid answer */
+        if(isset($entries['XML'])){
+          if(isset($entries['XML']['ERROR_STRING'])) {
+            $this->set_error($entries['XML']['ERROR_STRING']);
+            new log("debug","GOsa-si",
+                get_class($this)."::".__FUNCTION__, array(),
+                "FAILED error was ".$this->get_error());
+            return($ret);
+          }
+
+          /* Unset header tags */
+          foreach(array("HEADER","SOURCE","TARGET","SESSION_ID") as $type){
+            if(isset($entries['XML'][$type])){
+              unset($entries['XML'][$type]);
+            }
+          }
+          $ret = $entries['XML'];
+        }
+      }
+    }
+    return($ret);
+
+    
+  }
+
+
   public function FAI_get_server($name = "")
   {
     $this->reset_error();