Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Get set sep-0045 subject #97

Open
halfsoft opened this Issue · 2 comments

2 participants

@halfsoft

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
 - (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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.