traverse it in a safe manner.
struct CitContext *cptr;
static int unsolicited_id;
int visible_sessions = 0;
struct CitContext *cptr;
static int unsolicited_id;
int visible_sessions = 0;
int aide = (CC->user.axlevel >= 6);
if (IsEmptyStr(presence_jid)) return;
int aide = (CC->user.axlevel >= 6);
if (IsEmptyStr(presence_jid)) return;
+ cptr = CtdlGetContextArray(&nContexts);
+ if (!cptr)
+ return ; /** FIXME: Does jabber need to send something to maintain the protocol? */
+
/* Count the visible sessions for this user */
/* Count the visible sessions for this user */
- for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
- if (cptr->logged_in) {
- if ( (!strcasecmp(cptr->cs_inet_email, presence_jid))
- && (((cptr->cs_flags&CS_STEALTH)==0) || (aide))
+ for (i=0; i<nContexts; i++) {
+ if (cptr[i].logged_in) {
+ if ( (!strcasecmp(cptr[i].cs_inet_email, presence_jid))
+ && (((cptr[i].cs_flags&CS_STEALTH)==0) || (aide))
) {
++visible_sessions;
}
) {
++visible_sessions;
}
lprintf(CTDL_DEBUG, "Telling session %d that <%s> logged in\n", CC->cs_pid, presence_jid);
/* Do an unsolicited roster update that adds a new contact. */
lprintf(CTDL_DEBUG, "Telling session %d that <%s> logged in\n", CC->cs_pid, presence_jid);
/* Do an unsolicited roster update that adds a new contact. */
- for (cptr = ContextList; cptr != NULL; cptr = cptr->next) {
- if (cptr->logged_in) {
- if (!strcasecmp(cptr->cs_inet_email, presence_jid)) {
+ for (i=0; i<nContexts; i++) {
+ if (cptr[i].logged_in) {
+ if (!strcasecmp(cptr[i].cs_inet_email, presence_jid)) {
cprintf("<iq id=\"unsolicited_%x\" type=\"result\">",
++unsolicited_id);
cprintf("<query xmlns=\"jabber:iq:roster\">");
cprintf("<iq id=\"unsolicited_%x\" type=\"result\">",
++unsolicited_id);
cprintf("<query xmlns=\"jabber:iq:roster\">");
- jabber_roster_item(cptr);
+ jabber_roster_item(&cptr[i]);
cprintf("</query>"
"</iq>");
}
cprintf("</query>"
"</iq>");
}
cprintf("</query>"
"</iq>");
}
cprintf("</query>"
"</iq>");
}