|
|
#include "libjabber.h"
#include "libxode.h"
Go to the source code of this file.
Functions | |
jabpacket | jabpacket_new (xode x) |
jabpacket | jabpacket_reset (jabpacket p) |
int | jabpacket_subtype (jabpacket p) |
|
Definition at line 48 of file jpacket.c. References _jabpacket, jabpacket, jabpacket_reset(), jabpacket_struct::x, xode, xode_get_pool(), and xode_pool_malloc(). 00049 { 00050 jabpacket p; 00051 00052 if (x == NULL) 00053 return NULL; 00054 00055 p = xode_pool_malloc(xode_get_pool(x), sizeof(_jabpacket)); 00056 p->x = x; 00057 00058 return jabpacket_reset(p); 00059 }
|
|
Definition at line 62 of file jpacket.c. References _jabpacket, jabpacket_struct::from, jabpacket_struct::iq, jabpacket_struct::iqns, jabpacket, jabpacket_subtype(), jid_new(), jabpacket_struct::p, jabpacket_struct::subtype, jabpacket_struct::to, jabpacket_struct::type, jabpacket_struct::x, xode, xode_get_attrib(), xode_get_name(), xode_get_pool(), and xode_get_tag(). Referenced by jab_on_packet_handler(), and jabpacket_new(). 00063 { 00064 char *val; 00065 xode x; 00066 00067 x = p->x; 00068 memset(p, 0, sizeof(_jabpacket)); 00069 p->x = x; 00070 p->p = xode_get_pool(x); 00071 00072 if (strncmp(xode_get_name(x), "message", 7) == 0) { 00073 p->type = JABPACKET_MESSAGE; 00074 } 00075 else if (strncmp(xode_get_name(x), "presence", 8) == 0) { 00076 p->type = JABPACKET_PRESENCE; 00077 } 00078 else if (strncmp(xode_get_name(x), "iq", 2) == 0) { 00079 p->type = JABPACKET_IQ; 00080 p->iq = xode_get_tag(x, "?xmlns"); 00081 p->iqns = xode_get_attrib(p->iq, "xmlns"); 00082 } 00083 00084 val = xode_get_attrib(x, "to"); 00085 if (val != NULL) 00086 if ((p->to = jid_new(p->p, val)) == NULL) 00087 p->type = JABPACKET_UNKNOWN; 00088 val = xode_get_attrib(x, "from"); 00089 if (val != NULL) 00090 if ((p->from = jid_new(p->p, val)) == NULL) 00091 p->type = JABPACKET_UNKNOWN; 00092 00093 p->subtype = JABPACKET__UNKNOWN; 00094 p->subtype = jabpacket_subtype(p); 00095 00096 return p; 00097 }
|
|
Definition at line 101 of file jpacket.c. References j_strcmp(), jabpacket, JABPACKET_IQ, JABPACKET_MESSAGE, JABPACKET_PRESENCE, jabpacket_struct::subtype, jabpacket_struct::type, jabpacket_struct::x, and xode_get_attrib(). Referenced by jabpacket_reset(). 00102 { 00103 char *type; 00104 int ret = p->subtype; 00105 00106 if (ret != JABPACKET__UNKNOWN) 00107 return ret; 00108 00109 ret = JABPACKET__NONE; 00110 type = xode_get_attrib(p->x, "type"); 00111 if (j_strcmp(type, "error") == 0) 00112 ret = JABPACKET__ERROR; 00113 else 00114 switch (p->type) { 00115 case JABPACKET_MESSAGE: 00116 if (j_strcmp(type, "chat") == 0) 00117 ret = JABPACKET__CHAT; 00118 else if (j_strcmp(type, "groupchat") == 0) 00119 ret = JABPACKET__GROUPCHAT; 00120 else if (j_strcmp(type, "headline") == 0) 00121 ret = JABPACKET__HEADLINE; 00122 else if (j_strcmp(type, "internal") == 0) 00123 ret = JABPACKET__INTERNAL; 00124 else 00125 ret = JABPACKET__UNKNOWN; 00126 break; 00127 00128 case JABPACKET_PRESENCE: 00129 if (type == NULL) 00130 ret = JABPACKET__AVAILABLE; 00131 else if (j_strcmp(type, "unavailable") == 0) 00132 ret = JABPACKET__UNAVAILABLE; 00133 else if (j_strcmp(type, "probe") == 0) 00134 ret = JABPACKET__PROBE; 00135 else if (j_strcmp(type, "error") == 0) 00136 ret = JABPACKET__ERROR; 00137 else if (j_strcmp(type, "invisible") == 0) 00138 ret = JABPACKET__INVISIBLE; 00139 else if (j_strcmp(type, "available") == 0) 00140 ret = JABPACKET__AVAILABLE; 00141 else if (j_strcmp(type, "online") == 0) 00142 ret = JABPACKET__AVAILABLE; 00143 else if (j_strcmp(type, "subscribe") == 0) 00144 ret = JABPACKET__SUBSCRIBE; 00145 else if (j_strcmp(type, "subscribed") == 0) 00146 ret = JABPACKET__SUBSCRIBED; 00147 else if (j_strcmp(type, "unsubscribe") == 0) 00148 ret = JABPACKET__UNSUBSCRIBE; 00149 else if (j_strcmp(type, "unsubscribed") == 0) 00150 ret = JABPACKET__UNSUBSCRIBED; 00151 else 00152 ret = JABPACKET__UNKNOWN; 00153 break; 00154 00155 case JABPACKET_IQ: 00156 if (j_strcmp(type, "get") == 0) 00157 ret = JABPACKET__GET; 00158 else if (j_strcmp(type, "set") == 0) 00159 ret = JABPACKET__SET; 00160 else if (j_strcmp(type, "result") == 0) 00161 ret = JABPACKET__RESULT; 00162 else 00163 ret = JABPACKET__UNKNOWN; 00164 break; 00165 } 00166 00167 return ret; 00168 }
|
Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |