# HG changeset patch # User Andreas Monitzer # Date 1181088075 0 # Node ID a75079eae08565d2983afb23d5b851e789a6c178 # Parent f41a561e3b7bf1c2cae089331f209459e73689a4 added preliminary frame for pep-support diff -r f41a561e3b7b -r a75079eae085 libpurple/protocols/jabber/disco.c --- a/libpurple/protocols/jabber/disco.c Tue Jun 05 16:31:20 2007 +0000 +++ b/libpurple/protocols/jabber/disco.c Wed Jun 06 00:01:15 2007 +0000 @@ -30,6 +30,7 @@ #include "jabber.h" #include "presence.h" #include "roster.h" +#include "pep.h" struct _jabber_disco_info_cb_data { gpointer data; @@ -261,9 +262,13 @@ child = xmlnode_get_next_twin(child)) { const char *category, *type, *name; category = xmlnode_get_attrib(child, "category"); + type = xmlnode_get_attrib(child, "type"); + if(category && type && !strcmp(category, "pubsub") && !strcmp(type,"pep")) { + /* server supports pep, initialize it */ + jabber_pep_init(js); + } if (!category || strcmp(category, "server")) continue; - type = xmlnode_get_attrib(child, "type"); if (!type || strcmp(type, "im")) continue; diff -r f41a561e3b7b -r a75079eae085 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Tue Jun 05 16:31:20 2007 +0000 +++ b/libpurple/protocols/jabber/jabber.c Wed Jun 06 00:01:15 2007 +0000 @@ -53,6 +53,7 @@ #include "roster.h" #include "si.h" #include "xdata.h" +#include "pep.h" #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) diff -r f41a561e3b7b -r a75079eae085 libpurple/protocols/jabber/message.c --- a/libpurple/protocols/jabber/message.c Tue Jun 05 16:31:20 2007 +0000 +++ b/libpurple/protocols/jabber/message.c Wed Jun 06 00:01:15 2007 +0000 @@ -30,6 +30,7 @@ #include "google.h" #include "message.h" #include "xmlnode.h" +#include "pep.h" void jabber_message_free(JabberMessage *jm) { @@ -308,22 +309,25 @@ jm->id = g_strdup(xmlnode_get_attrib(packet, "id")); for(child = packet->child; child; child = child->next) { + const char *xmlns = xmlnode_get_namespace(child); + if(!xmlns) + xmlns = ""; if(child->type != XMLNODE_TYPE_TAG) continue; - if(!strcmp(child->name, "subject")) { + if(!strcmp(child->name, "subject") && strlen(xmlns) == 0) { if(!jm->subject) jm->subject = xmlnode_get_data(child); - } else if(!strcmp(child->name, "thread")) { + } else if(!strcmp(child->name, "thread") && strlen(xmlns) == 0) { if(!jm->thread_id) jm->thread_id = xmlnode_get_data(child); - } else if(!strcmp(child->name, "body")) { + } else if(!strcmp(child->name, "body") && strlen(xmlns) == 0) { if(!jm->body) { char *msg = xmlnode_to_str(child, NULL); jm->body = purple_strdup_withhtml(msg); g_free(msg); } - } else if(!strcmp(child->name, "html")) { + } else if(!strcmp(child->name, "html") && !strcmp(xmlns,"http://jabber.org/protocol/xhtml-im")) { if(!jm->xhtml && xmlnode_get_child(child, "body")) { char *c; jm->xhtml = xmlnode_to_str(child, NULL); @@ -335,21 +339,27 @@ *c = ' '; } } - } else if(!strcmp(child->name, "active")) { + } else if(!strcmp(child->name, "active") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { jm->chat_state = JM_STATE_ACTIVE; jm->typing_style |= JM_TS_JEP_0085; - } else if(!strcmp(child->name, "composing")) { + } else if(!strcmp(child->name, "composing") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { jm->chat_state = JM_STATE_COMPOSING; jm->typing_style |= JM_TS_JEP_0085; - } else if(!strcmp(child->name, "paused")) { + } else if(!strcmp(child->name, "paused") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { jm->chat_state = JM_STATE_PAUSED; jm->typing_style |= JM_TS_JEP_0085; - } else if(!strcmp(child->name, "inactive")) { + } else if(!strcmp(child->name, "inactive") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { jm->chat_state = JM_STATE_INACTIVE; jm->typing_style |= JM_TS_JEP_0085; - } else if(!strcmp(child->name, "gone")) { + } else if(!strcmp(child->name, "gone") && !strcmp(xmlns,"http://jabber.org/protocol/chatstates")) { jm->chat_state = JM_STATE_GONE; jm->typing_style |= JM_TS_JEP_0085; + } else if(!strcmp(child->name, "event") && jm->type == JABBER_MESSAGE_HEADLINE && + !strcmp(xmlns,"http://jabber.org/protocol/pubsub#event")) { + xmlnode *items; + jm->type = JABBER_MESSAGE_EVENT; + for(items = child->child; child; child = child->next) + jm->eventitems = g_list_append(jm->eventitems, items); } else if(!strcmp(child->name, "error")) { const char *code = xmlnode_get_attrib(child, "code"); char *code_txt = NULL; @@ -365,7 +375,6 @@ g_free(code_txt); g_free(text); } else if(!strcmp(child->name, "x")) { - const char *xmlns = xmlnode_get_namespace(child); if(xmlns && !strcmp(xmlns, "jabber:x:event")) { if(xmlnode_get_child(child, "composing")) { if(jm->chat_state == JM_STATE_ACTIVE) @@ -425,6 +434,9 @@ case JABBER_MESSAGE_GROUPCHAT_INVITE: handle_groupchat_invite(jm); break; + case JABBER_MESSAGE_EVENT: + jabber_handle_event(jm); + break; case JABBER_MESSAGE_ERROR: handle_error(jm); break; @@ -461,6 +473,7 @@ type = "error"; break; case JABBER_MESSAGE_OTHER: + default: type = NULL; break; } diff -r f41a561e3b7b -r a75079eae085 libpurple/protocols/jabber/message.h --- a/libpurple/protocols/jabber/message.h Tue Jun 05 16:31:20 2007 +0000 +++ b/libpurple/protocols/jabber/message.h Wed Jun 06 00:01:15 2007 +0000 @@ -35,6 +35,7 @@ JABBER_MESSAGE_HEADLINE, JABBER_MESSAGE_ERROR, JABBER_MESSAGE_GROUPCHAT_INVITE, + JABBER_MESSAGE_EVENT, JABBER_MESSAGE_OTHER } type; time_t sent; @@ -61,6 +62,7 @@ JM_STATE_GONE } chat_state; GList *etc; + GList *eventitems; } JabberMessage; void jabber_message_free(JabberMessage *jm); diff -r f41a561e3b7b -r a75079eae085 libpurple/protocols/jabber/pep.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocols/jabber/pep.c Wed Jun 06 00:01:15 2007 +0000 @@ -0,0 +1,31 @@ +/* + * purple - Jabber Protocol Plugin + * + * Copyright (C) 2007, Andreas Monitzer + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "pep.h" + +void jabber_pep_init(JabberStream *js) { + +} + +void jabber_handle_event(JabberMessage *jm) { + /* this may be called even when the own server doesn't support pep! */ + +} diff -r f41a561e3b7b -r a75079eae085 libpurple/protocols/jabber/pep.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocols/jabber/pep.h Wed Jun 06 00:01:15 2007 +0000 @@ -0,0 +1,32 @@ +/* + * purple - Jabber Protocol Plugin + * + * Copyright (C) 2007, Andreas Monitzer + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _PURPLE_JABBER_PEP_H_ +#define _PURPLE_JABBER_PEP_H_ + +#include "jabber.h" +#include "message.h" + +void jabber_pep_init(JabberStream *js); + +void jabber_handle_event(JabberMessage *jm); + +#endif /* _PURPLE_JABBER_PEP_H_ */