1 /* $Id: sessions.h,v 1.29 2004/03/16 19:30:25 mmazur Exp $ */ 2 3 /* 4 * (C) Copyright 2002-2013 Jacek Konieczny [jajcus(a)jajcus,net] 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License Version 2 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 */ 19 20 #ifndef sessions_h 21 #define sessions_h 22 23 #include "users.h" 24 25 typedef struct resource_s{ 26 char *name; 27 int priority; 28 int available; 29 char *show; 30 char *status; 31 struct session_s *session; 32 guint disconnect_delay_func; 33 }Resource; 34 35 typedef struct session_s{ 36 User *user; 37 38 struct gg_session *ggs; /* GG session */ 39 int gg_status; /* status set at GG server */ 40 char *gg_status_descr; 41 42 GSource *g_source; 43 GPollFD g_pollfd; 44 45 int connected; 46 GList *current_server; 47 48 char *jid; /* users JID, with resource */ 49 struct stream_s *s; /* Jabber stream */ 50 GList *resources; 51 52 char *req_id; /* ID if user registration request (<iq/>) */ 53 54 xmlnode query; /* The query */ 55 gg_pubdir50_t pubdir_change; /* Info for public directory change reqested on registration */ 56 int get_roster; 57 guint ping_timeout_func; 58 guint timeout_func; 59 GTimer *ping_timer; 60 gboolean waiting_for_pong; 61 }Session; 62 63 typedef struct gg_server_s { 64 struct in_addr addr; 65 int port; 66 int tls; 67 }GgServer; 68 69 extern GHashTable *sessions_jid; 70 71 Session *session_create(User *user,const char *jid,const char *req_id, 72 const xmlnode query,struct stream_s *stream,int delay_login); 73 int session_remove(Session *s); 74 75 /* available==-1 means invisible */ 76 int session_set_status(Session *s,const char *resource,int available, 77 const char *show,const char *status,int priority); 78 int session_send_status(Session *s); 79 80 int session_update_contact(Session *s, Contact *c); 81 82 int session_send_message(Session *s,uin_t uin,int chat,const char *body); 83 int session_send_notify(Session *s); 84 85 /* Finds resource representing current state, 86 * probably the one with highest priority */ 87 Resource *session_get_cur_resource(Session *s); 88 89 /* 90 * Finds session associated with JID. 91 * If none exists and stream is given, new session is created 92 * If delay_login != 0, than the session is not logged in, when created, but on 93 * the first status change 94 */ 95 Session *session_get_by_jid(const char *jid,struct stream_s *stream,int delay_login); 96 97 void session_print(Session *s,int indent); 98 void sessions_print_all(int indent); 99 char * session_get_info_string(const Session *sess); 100 101 int sessions_init(); 102 int sessions_done(); 103 104 #endif 105