Back to index

citadel  8.12
serv_xmpp.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2007-2009 by Art Cancro
00003  *
00004  *  This program is open source software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License version 3.
00006  *  
00007  *  
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  
00015  *  
00016  *  
00017  */
00018 
00019 typedef struct _citxmpp {                 /* Information about the current session */
00020        XML_Parser xp;                     /* XML parser instance for incoming client stream */
00021        char server_name[256];             /* who they think we are */
00022        char *chardata;
00023        int chardata_len;
00024        int chardata_alloc;
00025        char client_jid[256];              /* "full JID" of the client */
00026        int last_event_processed;
00027 
00028        char iq_type[256];          /* for <iq> stanzas */
00029        char iq_id[256];
00030        char iq_from[256];
00031        char iq_to[256];
00032        char iq_client_username[256];      /* username requested by the client (NON SASL ONLY) */
00033        char iq_client_password[256];      /* password requested by the client (NON SASL ONLY) */
00034        char iq_client_resource[256];      /* resource name requested by the client */
00035        int iq_session;                    /* nonzero == client is requesting a session */
00036        char iq_query_xmlns[256];   /* Namespace of <query> */
00037 
00038        char sasl_auth_mech[32];    /* SASL auth mechanism requested by the client */
00039 
00040        char message_to[256];
00041        char *message_body;         /* Message body in transit */
00042        int html_tag_level;         /* <html> tag nesting level */
00043 
00044        int bind_requested;         /* In this stanza, client is asking server to bind a resource. */
00045        int ping_requested;         /* In this stanza, client is pinging the server. */
00046 } citxmpp;
00047 
00048 #define XMPP ((citxmpp *)CC->session_specific_data)
00049 
00050 struct xmpp_event {
00051        struct xmpp_event *next;
00052        int event_seq;
00053        time_t event_time;
00054        int event_type;
00055        char event_jid[256];
00056        int session_which_generated_this_event;
00057 };
00058 
00059 extern struct xmpp_event *xmpp_queue;
00060 extern int queue_event_seq;
00061 
00062 enum {
00063        XMPP_EVT_LOGIN,
00064        XMPP_EVT_LOGOUT
00065 };
00066 
00067 void xmpp_cleanup_function(void);
00068 void xmpp_greeting(void);
00069 void xmpp_command_loop(void);
00070 void xmpp_async_loop(void);
00071 void xmpp_sasl_auth(char *, char *);
00072 void xmpp_output_auth_mechs(void);
00073 void xmpp_query_namespace(char *, char *, char *, char *);
00074 void xmpp_wholist_presence_dump(void);
00075 void xmpp_output_incoming_messages(void);
00076 void xmpp_queue_event(int, char *);
00077 void xmpp_process_events(void);
00078 void xmpp_presence_notify(char *, int);
00079 void xmpp_roster_item(struct CitContext *);
00080 void xmpp_send_message(char *, char *);
00081 void xmpp_non_sasl_authenticate(char *, char *, char *, char *);
00082 void xmpp_massacre_roster(void);
00083 void xmpp_delete_old_buddies_who_no_longer_exist_from_the_client_roster(void);
00084 int xmpp_is_visible(struct CitContext *from, struct CitContext *to_whom);
00085 char *xmlesc(char *buf, char *str, int bufsiz);
00086 
00087 extern int XMPPSrvDebugEnable;
00088 
00089 #define DBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (XMPPSrvDebugEnable != 0))
00090 
00091 #define XMPP_syslog(LEVEL, FORMAT, ...)                        \
00092        DBGLOG(LEVEL) syslog(LEVEL,                      \
00093                           "XMPP: " FORMAT, __VA_ARGS__)
00094 
00095 #define XMPPM_syslog(LEVEL, FORMAT)              \
00096        DBGLOG(LEVEL) syslog(LEVEL,        \
00097                           "XMPP: " FORMAT);
00098