cprintf("<query xmlns=\"jabber:iq:roster\">");
cptr = CtdlGetContextArray(&nContexts);
- if (!cptr)
- return ; /** FIXME: Does jabber need to send something to maintain the protocol? */
-
- for (i=0; i<nContexts; i++) {
- if (cptr[i].logged_in) {
- if (
- (((cptr[i].cs_flags&CS_STEALTH)==0) || (aide))
- && (cptr[i].user.usernum != CC->user.usernum)
- ) {
- jabber_roster_item(&cptr[i]);
+ if (cptr) {
+ for (i=0; i<nContexts; i++) {
+ if (cptr[i].logged_in) {
+ if (
+ (((cptr[i].cs_flags&CS_STEALTH)==0) || (aide))
+ && (cptr[i].user.usernum != CC->user.usernum)
+ ) {
+ jabber_roster_item(&cptr[i]);
+ }
}
}
+ free (cptr);
}
- free (cptr);
cprintf("</query>");
}
*
*/
-void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_xmlns) {
+void xmpp_query_namespace(char *iq_id, char *iq_from, char *iq_to, char *query_xmlns)
+{
+ int supported_namespace = 0;
+
+ /* We need to know before we begin the response whether this is a supported namespace, so
+ * unfortunately all supported namespaces need to be defined here *and* down below where
+ * they are handled.
+ */
+ if (
+ (!strcasecmp(query_xmlns, "jabber:iq:roster:query"))
+ && (!strcasecmp(query_xmlns, "jabber:iq:auth:query"))
+ ) {
+ supported_namespace = 1;
+ }
CtdlLogPrintf(CTDL_DEBUG, "xmpp_query_namespace(%s, %s, %s, %s)\n", iq_id, iq_from, iq_to, query_xmlns);
/*
* Beginning of query result.
*/
- cprintf("<iq type=\"result\" ");
+ if (supported_namespace) {
+ cprintf("<iq type=\"result\" ");
+ }
+ else {
+ cprintf("<iq type=\"error\" ");
+ }
if (!IsEmptyStr(iq_from)) {
cprintf("to=\"%s\" ", iq_from);
}
);
}
+ else {
+ CtdlLogPrintf(CTDL_DEBUG, "Unknown namespace; returning <service-unavailable/>\n");
+ cprintf("<error code=\"503\" type=\"cancel\">"
+ "<service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
+ "</error>"
+ );
+ }
+
/*
- * End of query result. If we didn't hit any known namespaces then we will
- * have simply delivered an empty result stanza, which should be ok.
+ * End of query result. If we didn't hit any known namespaces then we should
+ * deliver a "service unavailable" error (see RFC3921 section 2.4 and 11.1.5.4)
*/
cprintf("</iq>");
-
}
int msglen = 0;
rss_item *ri = rssc->Item;
- CtdlLogPrintf(0, "RSS: saving item...\n");
recp = (struct recptypes *) malloc(sizeof(struct recptypes));
if (recp == NULL) return;
memset(recp, 0, sizeof(struct recptypes));
}
else {
/* Item has not been seen, so save it. */
-
+ CtdlLogPrintf(CTDL_DEBUG, "RSS: saving item...\n");
if (ri->description == NULL) ri->description = strdup("");
for (i=strlen(ri->description); i>=0; --i) {
if (isspace(ri->description[i])) {