Jabber is an open source instant messaging system designed to give the power of choice and freedom back to the users of instant messaging. Not only does Jabber allow its users to use (and create) clients for numerous platforms, but it allows people to communicate to whomever they want in the way which is most convenient for them. Google Talk uses Jabber.

You may login to %site using a Jabber ID. The format of a Jabber ID is the same as an email address: name@server An example of valid Jabber ID is someone@gmail.com. Note that you must be able to access port 111 on the Jabber server from your web server. For example, sourceforge.net blocks port 111 so Jabber authentication does not work.

', array('%site' => theme('placeholder', variable_get('site_name', 'drupal')))); } return $output; } /** * Implementation of hook_info(). */ function jabber_info($field = 0) { $info['name'] = 'Jabber'; $info['protocol'] = 'Jabber'; if ($field) { return $info[$field]; } else { return $info; } } function _jabber_start($parser, $name, $attributes) { if (isset($attributes['ID']) && $attributes['ID']) { jabber_set('jid', $attributes['ID']); } if (stristr($name, "error") || (isset($attributes['ERROR']) && $attributes['ERROR'])) { _jabber_set('error', TRUE); } } function _jabber_end($parser, $name) { } function _jabber_data($parser, $data) { _jabber_set('data', $data); } function _jabber_send($request, $message) { fwrite($request, $message, strlen($message)); } function _jabber_recv($request, $timout = 50) { while ($count < $timout) { $data = fread($request, 1); if ($data) { $message .= $data; } else { usleep(100); $count = $count + 1; } } if ($message) { return $message; } } function jabber_auth($username, $password, $server) { if ($server == 'gmail.com') { $request = fsockopen('talk.google.com', 5223, $errno, $errstr, 5); } else { $request = fsockopen($server, 5222, $errno, $errstr, 5); } if ($request) { $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "_jabber_start", "_jabber_end"); xml_set_character_data_handler($xml_parser, "_jabber_data"); // Switch the given socket descriptor '$request' to non-blocking mode: set_socket_blocking($request, false); /* A jabber session consists of two parallel XML streams, one from the client to the server and one from the server to the client. On connecting to a Jabber server, a Jabber client initiates the client-to-server XML stream and the server responds by initiating the server-to-client XML stream: */ _jabber_send($request, ""); _jabber_send($request, ""); $data = _jabber_recv($request); if (!xml_parse($xml_parser, $data, 0)) { watchdog("error", "XML error: '". xml_error_string(xml_get_error_code($xml_parser)) ."' at line ". xml_get_current_line_number($xml_parser)); return; } $jabber = _jabber_get(); if (isset($jabber['error'])) { watchdog('jabber', "protocol error: ". $jabber['data'], WATCHDOG_ERROR); return; } _jabber_send($request, "$username$passworddrupal"); $data = _jabber_recv($request); if (!xml_parse($xml_parser, $data, 0)) { watchdog('jabber', "XML error: '". xml_error_string(xml_get_error_code($xml_parser)) ."' at line ". xml_get_current_line_number($xml_parser), WATCHDOG_ERROR); } if (isset($jabber['error'])) { watchdog('jabber', 'protocol error: '. $jabber['data'], WATCHDOG_ERROR); return 0; } xml_parser_free($xml_parser); return 1; } else { watchdog('jabber', "failed to open socket to jabber server:\n $errno, $errstr", WATCHDOG_ERROR); return 0; } } function _jabber_set($key = '', $value = '') { static $_jabber = array(); if ($key) { $_jabber[$key] = $value; } return $_jabber; } function _jabber_get() { return _jabber_set(); } ?>