Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
tambunanw #1
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members
Show profile · Link to this post
Subject: Nested Tag in Custom Element
Hi,

i want to create jingle extension based on XEP-0166: Jingle
because it's not supported yet from either agsXmpp and MatriX

  1.          <iq from='juliet@capulet.lit/balcony'
  2.                id='vua614d9'
  3.                to='romeo@montague.lit/orchard'
  4.                type='set'>
  5.                 <jingle xmlns='urn:xmpp:jingle:1'
  6.                        action='session-terminate'
  7.                        sid='a73sjjvkla37jfea'>
  8.                     <reason>
  9.                         <success/>
  10.                         <text>Sorry, gotta go!</text>
  11.                     </reason>
  12.                 </jingle>
  13.             </iq>

i've already create JingleIq and Jingle (element) for that. my question is..

  1.                     <reason>
  2.                         <success/>
  3.                         <text>Sorry, gotta go!</text>
  4.                     </reason>

is that required to create element to for <reason>, <success>, and <text> in order to create that stanza?
because it doesn't have a namespace, i think it's not XmppXElement. So how we create that?

Thanx before
Avatar
Alex #2
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Yes you should create subclasses. I am on the mobile right now. I will attach a example for this later to this thread.

Alex
Avatar
Alex #3
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I have attached the MatriX sources of the Vcard. This is a good example because it used also nested tags.

Alex
The author has attached one file to this post:
Vcard.zip 6.4 kBytes
You have no permission to open this file.
Avatar
tambunanw #4
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members
Show profile · Link to this post
Thanks a lot Alex. That's very kind of you.
Avatar
tambunanw #5
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members
Show profile · Link to this post
so i assume we have to create reason as XmppXElement and set the namespace in order to work with Matrix parser?
Avatar
tambunanw #6
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members
Show profile · Link to this post
oh and.. btw.. i don't have AddFirstOrRemoveTag method in my MatriX library?
is that for licensed version only?

i add the code like this. is that fine?

  1.         public bool IsSuccess
  2.         {
  3.             get { return HasTag("success"); }
  4.             set {  AddFirstOrRemoveTag("success", value); }
  5.         }
  6.  
  7.         private void AddFirstOrRemoveTag(string p, bool value)
  8.         {
  9.             if (value)
  10.                 SetTag(p);
  11.             else
  12.                 RemoveTag(p);
  13.         }
Avatar
Alex #7
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #5
Quote by tambunanw:
so i assume we have to create reason as XmppXElement and set the namespace in order to work with Matrix parser?

correct.

Alex
Avatar
Alex #8
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
those are internal, here is the code of these functions. Yo can add them as extension methods:


  1. /// <summary>
  2. /// Adds or removes the given empty tag.
  3. /// </summary>
  4. /// <param name="tagname">The tagname.</param>
  5. /// <param name="add">if set to <c>true</c> add, otherwise remove.</param>
  6. internal void AddOrRemoveTag(string tagname, bool add)
  7. {
  8.     AddOrRemoveTag(tagname, add, false);
  9. }
  10.  
  11. internal void AddFirstOrRemoveTag(string tagname, bool add)
  12. {
  13.     AddOrRemoveTag(tagname, add, true);
  14. }
  15.  
  16. /// <summary>
  17. /// Adds or removes the given empty tag.
  18. /// </summary>
  19. /// <param name="tagname">The tagname.</param>
  20. /// <param name="add">if set to <c>true</c> [add].</param>
  21. /// <param name="addFirst">if set to <c>true</c> [add first].</param>
  22. internal void AddOrRemoveTag(string tagname, bool add, bool addFirst)
  23. {
  24.     if (add)
  25.     {
  26.         if (addFirst)
  27.             SetTagFirst(tagname);
  28.         else
  29.             SetTag(tagname);
  30.     }
  31.     else
  32.     {
  33.         RemoveTag(tagname);
  34.     }
  35. }
Avatar
tambunanw #9
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members
Show profile · Link to this post
ok Alex. Thanks a lot. it works.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: