Re: Newbie troubles with MUCRoom
From: "TugolukovAP@xxxxxxxxxxx" <TugolukovAP@xxxxxxxxxxx>
Date: Sat, 08 Nov 2008 08:41:23 +0100

Hello again!

I've found a solution obscenely groveling through XMPP documentation. I hope that someone'll find it useful. Here's what I've done.

I created a new MUCRoom and registered a MUCRoomConfigHandler for it.
In ConnectionListener::OnConnect method I call MUCRoom::join and then MUCRoom::requestRoomConfig After that MUCRoomConfigHandler::handleMUCConfigForm is called with a configuration form for a created room. Here I stunned for a few days with no idea on how to change room configuration. That's definitely not a most elegant solution. Any complements, improvement and critics are appreciated.


void MessageTest::handleMUCConfigForm( MUCRoom *room, const DataForm& form )
{
   DataForm l_newOne(DataForm::FormTypeSubmit, "Wanna persistent room");


l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_roomowners", "robot@vitamagic"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_persistentroom", "1"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_roomname", "A room"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_roomdesc", "A room desc"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_enablelogging", "0"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_changesubject", "1"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_allowinvites", "0"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_maxusers", "10"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_publicroom", "0"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_persistentroom", "1"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_moderatedroom", "0"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_membersonly", "0"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_passwordprotectedroom", "0"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_roomsecret", ""); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_whois", "moderators"); l_newOne.addField(DataFormField::FieldTypeTextSingle, "muc#roomconfig_roomadmins", "robot@vitamagic"); Stanza *l_newCfg = Stanza::createIqStanza(JID("more_robots@xxxxxxxxxxxxxxxxxxxx"), j->getID(), StanzaIqSet, "http://jabber.org/protocol/muc#owner";, l_newOne.tag());
   l_newCfg->addAttribute( "from", "robot@vitamagic");
m_client->send(l_newCfg);
}

Here's a link for more information on magic strings like "muc#...":
http://xmpp.org/extensions/xep-0045.html

I hope it'll save someone's time. =)

Best regards
Anton Tugolukov



TugolukovAP@xxxxxxxxxxx wrote:

Hello gloox development team.

I'm trying to create chat rooms using gloox library v.0.9.9.5.
I've looked through mucroomexample.cpp, mucroom.h and mucroom.cpp files. I didn't figure out how to make a room persistent.
Can you please help me with this.
I found that m_flags member variable in MUCRoom class can contain FlagPersistent flag but I didn't figure out how to set it properly. I suppose that in this case new iq stanza with "muc_persistent" value should be created and sent to client somehow. Am I right?

It would be helpful to view sources of a gloox based XMPP client but I didn't found any client that is able to manage chat rooms. Can you give me a link on where can I find such client applications? Fragments of source code that implements persistent chartroom creation can be useful too.

Looking forward to hearing from you.

Best regards,
Anton Tugolukov






--
gloox-dev mailing list
to unsubscribe:
send a message with subject 'unsubscribe gloox-dev' to minimalist@xxxxxxxxxx