From d195c49d96314fc3a597d04fbc7d279c307a9311 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 26 Jun 2008 11:03:36 -0400 Subject: use jabber.php more from xmppdaemon darcs-hash:20080626150336-34904-bfa5ec8740ba1edf60c34e1ef6aafdfd73fc99a2.gz --- xmppdaemon.php | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) mode change 100644 => 100755 xmppdaemon.php (limited to 'xmppdaemon.php') diff --git a/xmppdaemon.php b/xmppdaemon.php old mode 100644 new mode 100755 index ac3ab8aca..c8204ba0e --- a/xmppdaemon.php +++ b/xmppdaemon.php @@ -1,3 +1,4 @@ +#!/usr/bin/env php resource = $resource; + } else { + $this->resource = common_config('xmpp', 'resource') . 'daemon'; } + + $this->log(LOG_INFO, "{$this->user}@{$this->server}/{$this->resource}"); } function connect() { - $this->conn = jabber_connect($this->resource, - "Send me a message to post a notice"); + $connect_to = ($this->host) ? $this->host : $this->server; + + $this->log(LOG_INFO, "Connecting to $connect_to on port $this->port"); + + $this->conn = jabber_connect($this->resource); + if (!$this->conn) { return false; } @@ -189,30 +197,20 @@ class XMPPDaemon { } function subscribed($to) { - $this->special_presence('subscribed', $to); + jabber_special_presence('subscribed', $to); } - function special_presence($type, $to=NULL, $show=NULL, $status=NULL) { - $to = htmlspecialchars($to); - $status = htmlspecialchars($status); - $out = "conn->send($out); + function set_status($status) { + jabber_send_presence($status); } } -$daemon = new XMPPDaemon(); +$resource = ($argc > 1) ? $argv[1] : NULL; + +$daemon = new XMPPDaemon($resource); if ($daemon->connect()) { + $daemon->set_status("Send me a message to post a notice"); $daemon->handle(); } ?> -- cgit v1.2.3-54-g00ecf