| 1 /* |
1 /* -------------------------------------------------------------------------- |
| 2 * This program is free software; you can redistribute it and/or modify |
2 * |
| 3 * it under the terms of the GNU General Public License as published by |
3 * License |
| 4 * the Free Software Foundation; either version 2 of the License, or |
4 * |
| 5 * (at your option) any later version. |
5 * The contents of this file are subject to the Jabber Open Source License |
| 6 * |
6 * Version 1.0 (the "JOSL"). You may not copy or use this file, in either |
| 7 * This program is distributed in the hope that it will be useful, |
7 * source code or executable form, except in compliance with the JOSL. You |
| 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
8 * may obtain a copy of the JOSL at http://www.jabber.org/ or at |
| 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9 * http://www.opensource.org/. |
| 10 * GNU General Public License for more details. |
10 * |
| 11 * |
11 * Software distributed under the JOSL is distributed on an "AS IS" basis, |
| 12 * You should have received a copy of the GNU General Public License |
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the JOSL |
| 13 * along with this program; if not, write to the Free Software |
13 * for the specific language governing rights and limitations under the |
| 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
14 * JOSL. |
| 15 * |
15 * |
| 16 * Jabber |
16 * Copyrights |
| 17 * Copyright (C) 1998-1999 The Jabber Team http://jabber.org/ |
17 * |
| 18 */ |
18 * Portions created by or assigned to Jabber.com, Inc. are |
| 19 |
19 * Copyright (c) 1999-2002 Jabber.com, Inc. All Rights Reserved. Contact |
| 20 #include "jabber.h" |
20 * information for Jabber.com, Inc. is available at http://www.jabber.com/. |
| |
21 * |
| |
22 * Portions Copyright (c) 1998-1999 Jeremie Miller. |
| |
23 * |
| |
24 * Acknowledgements |
| |
25 * |
| |
26 * Special thanks to the Jabber Open Source Contributors for their |
| |
27 * suggestions and support of Jabber. |
| |
28 * |
| |
29 * Alternatively, the contents of this file may be used under the terms of the |
| |
30 * GNU General Public License Version 2 or later (the "GPL"), in which case |
| |
31 * the provisions of the GPL are applicable instead of those above. If you |
| |
32 * wish to allow use of your version of this file only under the terms of the |
| |
33 * GPL and not to allow others to use your version of this file under the JOSL, |
| |
34 * indicate your decision by deleting the provisions above and replace them |
| |
35 * with the notice and other provisions required by the GPL. If you do not |
| |
36 * delete the provisions above, a recipient may use your version of this file |
| |
37 * under either the JOSL or the GPL. |
| |
38 * |
| |
39 * |
| |
40 * --------------------------------------------------------------------------*/ |
| |
41 |
| |
42 #include "lib.h" |
| 21 |
43 |
| 22 /* these aren't the most efficient things in the world, a hash optimized for tiny spaces would be far better */ |
44 /* these aren't the most efficient things in the world, a hash optimized for tiny spaces would be far better */ |
| 23 |
45 |
| 24 ppdb _ppdb_new(pool p, jid id) |
46 ppdb _ppdb_new(pool p, jid id) |
| 25 { |
47 { |
| 79 cur->x = xmlnode_dup(x); |
100 cur->x = xmlnode_dup(x); |
| 80 cur->pri = jutil_priority(x); |
101 cur->pri = jutil_priority(x); |
| 81 cur->next = db->next; |
102 cur->next = db->next; |
| 82 db->next = cur; |
103 db->next = cur; |
| 83 |
104 |
| 84 /* this is a presence from a resource, make an entry for just the user */ |
105 /* if this is a user's resource presence, get the the user entry */ |
| 85 if(id->user != NULL && id->resource != NULL) |
106 if(id->user != NULL && (curu = _ppdb_get(db,jid_user(id))) != cur) |
| 86 { |
107 { |
| 87 /* modify the id to just user@host */ |
|
| 88 res = id->resource; |
|
| 89 jid_set(id,NULL,JID_RESOURCE); |
|
| 90 curu = _ppdb_get(db,id); |
|
| 91 |
|
| 92 /* no user entry, make one */ |
108 /* no user entry, make one */ |
| 93 if(curu == NULL) |
109 if(curu == NULL) |
| 94 { |
110 { |
| 95 curu = _ppdb_new(db->p,id); |
111 curu = _ppdb_new(db->p,jid_user(id)); |
| 96 curu->next = db->next; |
112 curu->next = db->next; |
| 97 db->next = curu; |
113 db->next = curu; |
| 98 } |
114 } |
| 99 |
|
| 100 /* restore the id */ |
|
| 101 jid_set(id,res,JID_RESOURCE); |
|
| 102 |
115 |
| 103 /* insert this resource into the user list */ |
116 /* insert this resource into the user list */ |
| 104 cur->user = curu->user; |
117 cur->user = curu->user; |
| 105 curu->user = cur; |
118 curu->user = cur; |
| 106 } |
119 } |