Changeset 371
- Timestamp:
- 05/09/07 17:05:29 (15 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
sm/mod_iq_time.c (modified) (3 diffs)
-
sm/sm.c (modified) (1 diff)
-
util/uri.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sm/mod_iq_time.c
r2 r371 28 28 */ 29 29 30 # define uri_TIME "jabber:iq:time"30 #ifdef ENABLE_SUPERSEDED 31 31 static int ns_TIME = 0; 32 #endif 33 static int ns_URN_TIME = 0; 32 34 33 35 #ifdef HAVE_TZNAME … … 43 45 44 46 /* we only want to play with iq:time gets */ 45 if(pkt->type != pkt_IQ || pkt->ns != ns_TIME) 47 #ifdef ENABLE_SUPERSEDED 48 if(pkt->type != pkt_IQ || (pkt->ns != ns_TIME && pkt->ns != ns_URN_TIME)) 49 #else 50 if(pkt->type != pkt_IQ || pkt->ns != ns_URN_TIME) 51 #endif 46 52 return mod_PASS; 47 53 48 54 t = time(NULL); 55 tm = localtime(&t); 56 #ifdef HAVE_TZSET 57 tzset(); 58 #endif 49 59 50 sm_timestamp(t, buf); 60 #ifdef ENABLE_SUPERSEDED 61 if(pkt->ns == ns_TIME) { 62 datetime_out(t, dt_LEGACY, buf, 64); 63 nad_insert_elem(pkt->nad, 2, NAD_ENS(pkt->nad, 1), "utc", buf); 64 65 strcpy(buf, asctime(tm)); 66 c = strchr(buf, '\n'); 67 if(c != NULL) 68 *c = '\0'; 69 nad_insert_elem(pkt->nad, 2, NAD_ENS(pkt->nad, 1), "display", buf); 70 #if defined(HAVE_STRUCT_TM_TM_ZONE) 71 nad_insert_elem(pkt->nad, 2, NAD_ENS(pkt->nad, 1), "tz", (char *) tm->tm_zone); 72 #elif defined(HAVE_TZNAME) 73 nad_insert_elem(pkt->nad, 2, NAD_ENS(pkt->nad, 1), "tz", tzname[0]); 74 #endif 75 } else { 76 #endif /* ENABLE_SUPERSEDED */ 77 78 datetime_out(t, dt_DATETIME, buf, 64); 51 79 nad_insert_elem(pkt->nad, 2, NAD_ENS(pkt->nad, 1), "utc", buf); 52 80 53 tm = localtime(&t); 81 snprintf(buf, 64, "%+03d:%02d", (int) -timezone/(60*60), (int) -timezone%(60*60)); 82 nad_insert_elem(pkt->nad, 2, NAD_ENS(pkt->nad, 1), "tzo", buf); 54 83 55 strcpy(buf, asctime(tm)); 56 c = strchr(buf, '\n'); 57 if(c != NULL) 58 *c = '\0'; 59 nad_insert_elem(pkt->nad, 2, NAD_ENS(pkt->nad, 1), "display", buf); 60 61 tzset(); 62 #if defined(HAVE_STRUCT_TM_TM_ZONE) 63 nad_insert_elem(pkt->nad, 2, NAD_ENS(pkt->nad, 1), "tz", (char *) tm->tm_zone); 64 #elif defined(HAVE_TZNAME) 65 nad_insert_elem(pkt->nad, 2, NAD_ENS(pkt->nad, 1), "tz", tzname[0]); 84 #ifdef ENABLE_SUPERSEDED 85 } 66 86 #endif 67 68 87 /* tell them */ 69 88 nad_set_attr(pkt->nad, 1, -1, "type", "result", 6); … … 86 105 mod->free = _iq_time_free; 87 106 107 #ifdef ENABLE_SUPERSEDED 88 108 ns_TIME = sm_register_ns(mod->mm->sm, uri_TIME); 89 109 feature_register(mod->mm->sm, uri_TIME); 110 #endif 111 ns_URN_TIME = sm_register_ns(mod->mm->sm, uri_URN_TIME); 112 feature_register(mod->mm->sm, uri_URN_TIME); 90 113 91 114 return 0; -
trunk/sm/sm.c
r233 r371 262 262 } 263 263 264 /** this was jutil_timestamp in a former life */265 void sm_timestamp(time_t t, char timestamp[18])266 {267 struct tm *gm = gmtime(&t);268 269 snprintf(timestamp, 18, "%d%02d%02dT%02d:%02d:%02d", 1900 + gm->tm_year,270 gm->tm_mon + 1, gm->tm_mday, gm->tm_hour, gm->tm_min, gm->tm_sec);271 272 return;273 }274 275 264 /** send a new action route */ 276 265 void sm_c2s_action(sess_t dest, char *action, char *target) { -
trunk/util/uri.h
r287 r371 29 29 #define INCL_UTIL_URI_H 1 30 30 31 #define uri_XML "http://www.w3.org/XML/1998/namespace" 32 31 33 /* known namespace uri */ 32 34 #define uri_STREAMS "http://etherx.jabber.org/streams" … … 34 36 #define uri_SERVER "jabber:server" 35 37 #define uri_DIALBACK "jabber:server:dialback" 38 #define uri_DIALBACK_L 22 /* strlen(uri_DIALBACK) */ 36 39 #define uri_TLS "urn:ietf:params:xml:ns:xmpp-tls" 37 40 #define uri_SASL "urn:ietf:params:xml:ns:xmpp-sasl" 38 41 #define uri_BIND "urn:ietf:params:xml:ns:xmpp-bind" 39 42 #define uri_XSESSION "urn:ietf:params:xml:ns:xmpp-session" 43 #define uri_COMPRESS "http://jabber.org/protocol/compress" 44 #define uri_IQAUTH "http://jabber.org/features/iq-auth" 45 #define uri_IQREGISTER "http://jabber.org/features/iq-register" 40 46 #define uri_STREAM_ERR "urn:ietf:params:xml:ns:xmpp-streams" 41 47 #define uri_STANZA_ERR "urn:ietf:params:xml:ns:xmpp-stanzas" … … 44 50 #define uri_RESOLVER "http://jabberd.jabberstudio.org/ns/resolver/1.0" 45 51 #define uri_XDATA "jabber:x:data" 46 #define uri_XML "http://www.w3.org/XML/1998/namespace"47 52 #define uri_OOB "jabber:x:oob" 48 53 54 /* these are used by SM mainly */ 55 #define uri_AUTH "jabber:iq:auth" 56 #define uri_REGISTER "jabber:iq:register" 57 #define uri_ROSTER "jabber:iq:roster" 58 #define uri_AGENTS "jabber:iq:agents" 59 #define uri_DELAY "jabber:x:delay" 60 #define uri_URN_DELAY "urn:xmpp:delay" 61 #define uri_TIME "jabber:iq:time" 62 #define uri_URN_TIME "urn:xmpp:time" 63 #define uri_BROWSE "jabber:iq:browse" 64 #define uri_EVENT "jabber:x:event" 65 #define uri_GATEWAY "jabber:iq:gateway" 66 #define uri_EXPIRE "jabber:x:expire" 67 #define uri_SEARCH "jabber:iq:search" 68 #define uri_DISCO "http://jabber.org/protocol/disco" 69 #define uri_DISCO_ITEMS "http://jabber.org/protocol/disco#items" 70 #define uri_DISCO_INFO "http://jabber.org/protocol/disco#info" 71 72 #define uri_AMP "http://jabber.org/protocol/amp" 73 #define uri_AMP_ERRORS "http://jabber.org/protocol/amp#errors" 74 #define uri_AMP_ACTION_DROP "http://jabber.org/protocol/amp?action=drop" 75 #define uri_AMP_ACTION_ERROR "http://jabber.org/protocol/amp?action=error" 76 #define uri_AMP_ACTION_NOTIFY "http://jabber.org/protocol/amp?action=notify" 77 #define uri_AMP_CONDITION_DELIVER "http://jabber.org/protocol/amp?condition=deliver" 78 #define uri_AMP_CONDITION_EXPIREAT "http://jabber.org/protocol/amp?condition=expire-at" 79 #define uri_AMP_CONDITION_MATCHRESOURCE "http://jabber.org/protocol/amp?condition=match-resource" 80 49 81 #endif
