--- xmpp_api.internal.inc 2009-12-16 01:08:30.000000000 -0500 +++ ../xmpp_api.internal.fix.inc 2009-12-16 00:51:16.000000000 -0500 @@ -177,24 +179,26 @@ return FALSE; } - // setting the room including nickname we will utilize $room = $name .'@'. $service .'/xwchat-drupal'; - // sending the initial presence to the room so we can create it - $conn->sendInitialRoomPresence($room); - $payload = $conn->processUntil('initial_room_enter', XMPP_API_PROCESS_TIMEOUT); - if ($payload[0][1] != 'result') { + // sending request for the form in order to configure the room and receiving processed contents in return + $conn->joinMucRoom($room); + $payload = $conn->processUntil('room_enter', XMPP_API_PROCESS_TIMEOUT); + + if ($payload[0][1] == 'error') { // PATCH 1, a susccessful response from ejabberd-2.1.0 doesn't have a type attribute _xmpp_api_disconnect($conn); - watchdog('xmpp_api', '@name does not have privileges to create muc rooms', array('@name' => XMPP_API_ADMINJID), WATCHDOG_ERROR); + watchdog('xmpp_api', 'Could not join/create the room "@room"', array("@room" => $room), WATCHDOG_ERROR); return FALSE; } - // resetting the room variable this time without the nickname on it $room = $name .'@'. $service; + // sending request for the form in order to configure the room and receiving processed contents in return - $conn->createMucRoom($room); + $conn->configureMucRoom($room); + $conn->configureMucRoom($room); // PATCH 2, will hang without calling twice....weird $payload = $conn->processUntil('muc_created', XMPP_API_PROCESS_TIMEOUT); $packet = $payload[0][1]; + // if we are not returned an array we know there was an error in the configuration if (!is_array($packet)) { _xmpp_api_disconnect($conn); @@ -206,11 +210,12 @@ $options = _xmpp_api_muc_config_options($title); foreach ($packet as $key => $values) { if (array_key_exists($key, $options)) { - $values['data'] = $options[$key]; + $packet[$key]['data'] = $options[$key]; // PATCH 3, save changes in original $packet array } } + // sending request to configure the room with our pertinent information set - $conn->createMucRoomFormSend($room, $packet); + $conn->configureMucRoomFormSend($room, $packet); $payload = $conn->processUntil('muc_configured', XMPP_API_PROCESS_TIMEOUT); if ($payload[0][1] != 'result') { @@ -237,7 +243,7 @@ $room = $name .'@'. $service; // sending request for the form in order to configure the room and receiving processed contents in return // note at this point it will not create the room since it it should already exist in the system - $conn->createMucRoom($room); + $conn->configureMucRoom($room); $payload = $conn->processUntil('muc_created', XMPP_API_PROCESS_TIMEOUT); $packet = $payload[0][1]; // if we are not returned an array we know there was an error in the configuration @@ -249,11 +255,11 @@ $options = _xmpp_api_muc_config_options($value); foreach ($packet as $key => $values) { if (array_key_exists($key, $options)) { - $values['data'] = $options[$key]; + $packet[$key]['data'] = $options[$key]; // PATCH 3, save changes in original $packet array } } // sending request to configure the room with our pertinent information set - $conn->createMucRoomFormSend($room, $packet); + $conn->configureMucRoomFormSend($room, $packet); $conn->processUntil('muc_configured', XMPP_API_PROCESS_TIMEOUT); if ($payload[0][1] != 'result') { @@ -485,7 +491,7 @@ // if we received a username and password use them if (!empty($params['jid']) && !empty($params['password'])) { $pieces = explode('@', $params['jid']); - $params += array('username' => $pieces[0], 'server' => $pieces[1]); + $params = array_merge($params, array('username' => $pieces[0], 'server' => $pieces[1])); // PATCH 4, I think array_merge() was correctly merging compared to += operator. } // Check minimum parameters and add defaults