Get set sep-0045 subject #97

Open
halfsoft opened this Issue Aug 8, 2012 · 2 comments

Comments

Projects
None yet
2 participants

halfsoft commented Aug 8, 2012

I am writing the missing get and set room subject functions, however it will be nice if they are implemented in the framework also, i really have no idea how to submit a patch however I may try to do it later.

jonasman commented Aug 9, 2012

 - (void)changeRoomSubject:(NSString *)newRoomSubject
{
if ([newRoomSubject length] == 0) return;

dispatch_block_t block = ^{ @autoreleasepool {

    //XMPPLogTrace();
    /*
    <message
        from='wiccarocks@shakespeare.lit/laptop'
        id='lh2bs617'
        to='coven@chat.shakespeare.lit'
        type='groupchat'>
      <subject>Fire Burn and Cauldron Bubble!</subject>
    </message>
     */

    NSXMLElement *subject = [NSXMLElement elementWithName:@"subject" stringValue:newRoomSubject];

    XMPPMessage *message = [XMPPMessage message];
    [message addAttributeWithName:@"to" stringValue:[roomJID full]];
    [message addAttributeWithName:@"type" stringValue:@"groupchat"];
    [message addChild:subject];

    [xmppStream sendElement:message];

}};

if (dispatch_get_current_queue() == moduleQueue)
    block();
else
    dispatch_async(moduleQueue, block);
}

If you want an implementation!

jonasman commented Aug 9, 2012

to get it is a little different I also have one implementation:

- (void)handleRoomInfoResponse:(XMPPIQ *)iq withInfo:(id <XMPPTrackingInfo>)info
{
//XMPPLogTrace();

if ([[iq type] isEqualToString:@"result"])
{
    // <iq type='result'
    //     from='coven@chat.shakespeare.lit'
    //       id='create1'>
    //   <query xmlns='http://jabber.org/protocol/disco#info'>
    //     <identity
    /*          category='conference'
                name='A Dark Cave'
                type='text'/>
            <feature var='http://jabber.org/protocol/muc'/>
            <feature var='muc_passwordprotected'/>
            <feature var='muc_hidden'/>
            <feature var='muc_temporary'/>
            <feature var='muc_open'/>
            <feature var='muc_unmoderated'/>
            <feature var='muc_nonanonymous'/>
            </query>
    */// </iq>

    NSXMLElement *query = [iq elementForName:@"query" xmlns:@"http://jabber.org/protocol/disco#info"];
    NSXMLElement *identity = [query elementForName:@"identity"];

    [multicastDelegate xmppRoom:self handleRoomInfoResponse:identity];
}
}



- (void)fetchRoomInfo
{
dispatch_block_t block = ^{ @autoreleasepool {

    //XMPPLogTrace();

    // <iq type='get'
    //       id='config1'
    //       to='coven@chat.shakespeare.lit'>
    //   <query xmlns='http://jabber.org/protocol/disco#info'/>
    // </iq>

    NSString *fetchID = [xmppStream generateUUID];

    NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:@"http://jabber.org/protocol/disco#info"];
    XMPPIQ *iq = [XMPPIQ iqWithType:@"get" to:roomJID elementID:fetchID child:query];

    [xmppStream sendElement:iq];

    [responseTracker addID:fetchID
                    target:self
                  selector:@selector(handleRoomInfoResponse:withInfo:)
                   timeout:60.0];

}};

if (dispatch_get_current_queue() == moduleQueue)
    block();
else
    dispatch_async(moduleQueue, block);
}

You must add to the delegate the previous method

@davidchiles davidchiles pushed a commit to davidchiles/XMPPFramework that referenced this issue Jan 26, 2016

@robbiehanson robbiehanson Bug fix for XMPPStream's keepAlive functionality. Fixes issue #97 f2a655d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment