#include "jserver-c.h"
-/* ------------------------------------------------
- some pre-packaged Jabber XML
- ------------------------------------------------ */
-static const char* xml_parse_error = "<stream:stream xmlns:stream='http://etherx.jabber.org/streams'"
- "version='1.0'><stream:error xmlns:stream='http://etherx.jabber.org/streams'>"
- "<xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>"
- "<text xmlns='urn:ietf:params:xml:ns:xmpp-streams'>syntax error</text></stream:error></stream:stream>";
-
-static const char* xml_login_ok = "<iq xmlns='jabber:client' id='asdfjkl' type='result'/>";
-
-
jserver* jserver_init() {
jserver* js = safe_malloc(sizeof(jserver));
js->mgr = safe_malloc(sizeof(socket_manager));
jclient_node* node = (jclient_node*) blob;
if(node == NULL) return;
info_handler("Client logging in ok => %d", node->id);
- jserver_send_id(node->id, xml_login_ok);
+ //jserver_send_id(node->id, xml_login_ok);
+ jserver_send_id(node->id, JSTRING_LOGIN_OK);
}
void jserver_client_handle_msg(
info_handler("replying with error...");
char buf[2048];
memset(buf, 0, 2048);
+ /*
snprintf(buf, 2047, "<message xmlns='jabber:client' type='error' from='%s' "
"to='%s'><error type='cancel' code='404'><item-not-found "
"xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>"
"<body>NOT ADDING BODY</body></message>", to_addr, from->addr );
+ */
+ snprintf(buf, 2047, JSTRING_NO_RECIPIENT, to_addr, from->addr );
jserver_send_id(from_id, buf);
}
}
if(_jserver_push_client_data(node, data) == -1) {
warning_handler("Client sent bad data, disconnecting...");
- jserver_send_id(node->id, xml_parse_error);
+ //jserver_send_id(node->id, xml_parse_error);
+ jserver_send_id(node->id, JSTRING_PARSE_ERROR);
_jserver_remove_client(js, node->addr);
} else {
-
debug_handler("jserver-c_session received opening stream from client on domain %s",
session->current_domain);
- char buf[512];
- memset(buf,0,512);
-
- /* reply with the stock jabber login response */
- sprintf(buf, "<?xml version='1.0'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' "
- "xmlns='jabber:client' from='%s' to='%s' version='1.0' id='d253et09iw1fv8a2noqc38f28sb0y5fc7kfmegvx'>",
- session->current_domain, from_domain);
+ char buf[1024];
+ memset(buf,0,1024);
+ snprintf(buf, 1023, JSTRING_START_STREAM, session->current_domain, from_domain);
debug_handler("Session Sending: %s", buf);
--- /dev/null
+/* ------------------------------------------------
+ some pre-packaged Jabber XML
+ ------------------------------------------------ */
+
+#ifndef _JSTRINGS_H_
+#define _JSTRINGS_H_
+
+#define JSTRING_START_STREAM "<?xml version='1.0'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' from='%s' to='%s' version='1.0' id='d253et09iw1fv8a2noqc38f28sb0y5fc7kfmegvx'>" /* this will need to by dynamic when we add login handling */
+
+
+#define JSTRING_PARSE_ERROR "<stream:stream xmlns:stream='http://etherx.jabber.org/streams' version='1.0'><stream:error xmlns:stream='http://etherx.jabber.org/streams'><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xmlns='urn:ietf:params:xml:ns:xmpp-streams'>syntax error</text></stream:error></stream:stream>"
+
+#define JSTRING_LOGIN_OK "<iq xmlns='jabber:client' id='0123456789' type='result'/>"
+
+#define JSTRING_NO_RECIPIENT "<message xmlns='jabber:client' type='error' from='%s' to='%s'><error type='cancel' code='404'><item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error><body>NOT ADDING BODY</body></message>"
+
+#endif