Ignore:
Timestamp:
2010-12-06T00:18:27Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
a97a336
Parents:
d88c92a
Message:

Add support for XEP 202 (replacement for jabber:iq:time).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    rd88c92a rd76e12f  
    5151        {
    5252                if( !( ( c = xt_find_node( node->children, "query" ) ) ||
    53                        ( c = xt_find_node( node->children, "ping" ) ) ) ||
     53                       ( c = xt_find_node( node->children, "ping" ) ) ||
     54                       ( c = xt_find_node( node->children, "time" ) ) ) ||
    5455                    !( s = xt_find_attr( c, "xmlns" ) ) )
    5556                {
     
    6970                        xt_add_child( reply, xt_new_node( "os", ARCH, NULL ) );
    7071                }
    71                 else if( strcmp( s, XMLNS_TIME ) == 0 )
     72                else if( strcmp( s, XMLNS_TIME_OLD ) == 0 )
    7273                {
    7374                        time_t time_ep;
     
    8283                        strftime( buf, sizeof( buf ) - 1, "%Z", localtime( &time_ep ) );
    8384                        xt_add_child( reply, xt_new_node( "tz", buf, NULL ) );
     85                }
     86                else if( strcmp( s, XMLNS_TIME ) == 0 )
     87                {
     88                        time_t time_ep;
     89                        char buf[1024];
     90                       
     91                        buf[sizeof(buf)-1] = 0;
     92                        time_ep = time( NULL );
     93                       
     94                        xt_free_node( reply );
     95                        reply = xt_new_node( "time", NULL, NULL );
     96                        xt_add_attr( reply, "xmlns", XMLNS_TIME );
     97                       
     98                        strftime( buf, sizeof( buf ) - 1, "%Y%m%dT%H:%M:%SZ", gmtime( &time_ep ) );
     99                        xt_add_child( reply, xt_new_node( "utc", buf, NULL ) );
     100                       
     101                        strftime( buf, sizeof( buf ) - 1, "%z", localtime( &time_ep ) );
     102                        if( strlen( buf ) >= 5 )
     103                        {
     104                                buf[6] = '\0';
     105                                buf[5] = buf[4];
     106                                buf[4] = buf[3];
     107                                buf[3] = ':';
     108                        }
     109                        xt_add_child( reply, xt_new_node( "tzo", buf, NULL ) );
    84110                }
    85111                else if( strcmp( s, XMLNS_PING ) == 0 )
     
    95121                        const char *features[] = { XMLNS_DISCO_INFO,
    96122                                                   XMLNS_VERSION,
     123                                                   XMLNS_TIME_OLD,
    97124                                                   XMLNS_TIME,
    98125                                                   XMLNS_CHATSTATES,
Note: See TracChangeset for help on using the changeset viewer.