summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c3360b6)
raw | patch | inline | side by side (parent: c3360b6)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 29 Jan 2008 16:11:00 +0000 (16:11 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 29 Jan 2008 16:11:00 +0000 (16:11 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8638 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_daemonCommunicator.inc | [new file with mode: 0644] | patch | blob |
gosa-core/include/class_gosaSupportDaemon.inc | patch | blob | history | |
gosa-core/plugins/addons/gotomasses/class_gotomasses.inc | patch | blob | history |
diff --git a/gosa-core/include/class_daemonCommunicator.inc b/gosa-core/include/class_daemonCommunicator.inc
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2008 Cajus Pollmeier <pollmeier@gonicus.de>
+
+ 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
+*/
+
+class daemonCommunicator
+{
+ static function send($header, $to, $data= array())
+ {
+ $xml_message= "";
+
+ /* Get communication object */
+ $d= new gosaSupportDaemon(TRUE,10);
+
+ /* Prepare data */
+ foreach ($data as $key => $value){
+ $xml_message.= "<$key>$value</$key>";
+ }
+
+ return $d->send("<xml><header>$header</header><target>$to</target>".$xml_message."</xml>");
+ }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-core/include/class_gosaSupportDaemon.inc b/gosa-core/include/class_gosaSupportDaemon.inc
index 398160ee38be2b44d8b10476ef8d0a0224eb3cad..944e1fa2d8778888dc088f5b934a094f706b56f1 100644 (file)
number_of_queued_entries - Returns the number of currently queued entries.
*/
-
-
class gosaSupportDaemon
{
+ static private $s_host = "";
+ static private $i_port = 0;
+ static private $s_encryption_key = "";
+
private $o_sock = NULL;
- private $s_host = "";
- private $i_port = 0;
private $f_timeout = 2;
private $s_error = "";
private $b_error = FALSE;
private $is_connected = FALSE;
- private $s_encryption_key = "";
/*! \brief Creates a new gosaSupportDaemon object.
@param boolean Connect Directly connect to deamon socket.
@param float Timeout The timelimit for all socket actions.
*/
- public function __construct($host,$port,$key="secret-gosa-password",$connect=TRUE,$timeout=0.2)
+ public function __construct($connect=TRUE,$timeout=0.2)
{
- $this->s_host = $host;
- $this->i_port = $port;
- $this->f_timeout = $timeout;
- $this->s_encryption_key = $key;
- if($connect){
- $this->connect();
+ #FIXME: bad idea about referencing global variables from within classes
+ global $config;
+
+ # load from config, store statically
+ if (isset($config->current['GOSA_SI'])){
+
+ if (gosaSupportDaemon::$s_host == ""){
+ $host= preg_replace("/^.*@([^:]+):.*$/", "$1", $config->current['GOSA_SI']);
+ $port= preg_replace("/^.*@[^:]+:(.*)$/", "$1", $config->current['GOSA_SI']);
+ $key = preg_replace("/^(.*)@[^:]+:.*$/", "$1", $config->current['GOSA_SI']);
+
+ gosaSupportDaemon::$s_host = $host;
+ gosaSupportDaemon::$i_port = $port;
+ gosaSupportDaemon::$s_encryption_key = $key;
+ }
+
+ $this->f_timeout = $timeout;
+ if($connect){
+ $this->connect();
+ }
}
}
*/
public function connect()
{
- $this->o_sock = new Socket_Client($this->s_host,$this->i_port,TRUE,$this->f_timeout);
+ $this->o_sock = new Socket_Client(gosaSupportDaemon::$s_host,gosaSupportDaemon::$i_port,TRUE,$this->f_timeout);
if($this->o_sock->connected()){
- $this->o_sock->setEncryptionKey($this->s_encryption_key);
+ $this->o_sock->setEncryptionKey(gosaSupportDaemon::$s_encryption_key);
$this->is_connected = TRUE;
}else{
$this->error = $this->o_sock->get_error();
}
return(-1);
}
+
+
+ /*! \brief Returns an array containing all queued entries.
+ @return Array All queued entries as an array.
+ */
+ public function send($data, $answer_expected= FALSE)
+ {
+ $this->b_error = FALSE;
+ $this->s_error = "";
+ $ret = array();
+
+ if($this->connect()){
+ $this->o_sock->write($data);
+ if ($answer_exepcted){
+ $str = trim($this->o_sock->read());
+ $entries = $this->xml_to_array($str);
+ if(isset($entries['XML']) && is_array($entries['XML'])){
+ $ret = $entries;
+ }
+ }
+ }
+ return($ret);
+ }
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc b/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc
index d4424187fd029f96f6b9caad03c11ad855eceb62..d3b15f2a7cca3fd50d2327a20c4c9f32c5f35667 100644 (file)
{
/* Include config object */
$this->config= &$config;
- $this->o_queue = new gosaSupportDaemon("10.3.67.111","20081","secret-gosa-password",TRUE,10);
+ $this->o_queue = new gosaSupportDaemon(TRUE,10);
}