Added support for a message hook and simple message sending
[cascardo/chat.git] / message.c
diff --git a/message.c b/message.c
new file mode 100644 (file)
index 0000000..be28d5d
--- /dev/null
+++ b/message.c
@@ -0,0 +1,32 @@
+/*
+ *  Copyright (C) 2008  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "xmpp.h"
+
+void
+hc_xmpp_send_message (hc_xmpp_t *xmpp, char *to, char *body)
+{
+  iks *msg;
+  iks *bd;
+  msg = iks_new ("message");
+  iks_insert_attrib (msg, "to", to);
+  bd = iks_insert (msg, "body");
+  iks_insert_cdata (bd, body, 0);
+  hc_xmpp_send_iks (xmpp, msg);
+  iks_delete (msg);
+}