Re: Component source JID & memory management
From: Jakob Schroeter <js@xxxxxxxxxx>
Date: Mon, 15 Jan 2007 01:47:28 +0100
On Mon Jan 15 2007, Petr Mensik wrote:
> Hello again
>
> i would like if there be some settings for component to enable automatic
> appending "from=component.xxx.yyy" parameter to all stanzas. Source
> would be same as that we connected in with. That is because components
> are connected in different way and servers does not do source managing
> for them. They have to specify from atribute themselves always. It would
> be nice if for stanzas without from attribute gloox will add it itself,
> or it can be told to.

You can achieve this by creating a simple wrapper class derived from 
Component, overloading virtual void ClientBase::send( Tag* tag ).


> Also i want ask how memory management works with tags? When i do New
> Tag("x") for example, then i add to it new Tag("y") asi children. How
> should i free its memory? should i free both y and x, only x as y will
> be freed by x destructor, or nothing? I tried to free Tag i created and
> it crashed. It there general guide for good memory management to follow
> in gloox?

The rules are pretty simple:
Never delete a Tag/Stanza you received from any handler.
Never delete a Tag/Stanza you sent off using ClientBase::send() (or similar).
If you delete a Tag/Stanza manually, only delete the root Tag/Stanza. It will 
delete all its children in its dtor.


> Last note i have about data forms. Would it be possible making next
> constructor for DataFormField(const std::string &var, const std::string
> &label = "", enum type = TYPE_FIELD_TEXT_SINGLE) ?
> You know it is weird when i must have always three lines for every
> field. If there would be also overloaded operator=(const std::string
> &s), i could make field with
> DataFormField f("jid", "Jabber ID");
> f="someone@xxxxxxxxxxxxx";
> very easy form. Form fields also look like how they would be offered to
> user a little, so if you have more, you recognize sooner which one is this.

Yes, these seem reasonable. I'll add them in one of the next (pre-)releases.


> Also i am missing a little addField method in DataForm. It would be
> simplier without need for extra list variable and setFields after that.

This one is in 0.9 already.

cheers,
Jakob

Attachment: pgp7UfLTx8KG6.pgp
Description: PGP signature

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