libpurple/protocols/myspace/session.c

changeset 25197
077b4d6fc595
parent 24672
3e12ba88e3b9
child 29299
da6ffa6a31ca
equal deleted inserted replaced
25196:34813ddd7169 25197:077b4d6fc595
14 * 14 *
15 * You should have received a copy of the GNU General Public License 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 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
18 */ 18 */
19
20 19
21 #include "myspace.h" 20 #include "myspace.h"
22 21
23 /* Session methods */ 22 /* Session methods */
24 23
45 session->userid = 0; 44 session->userid = 0;
46 session->username = NULL; 45 session->username = NULL;
47 session->fd = -1; 46 session->fd = -1;
48 47
49 /* TODO: Remove. */ 48 /* TODO: Remove. */
50 session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, 49 session->user_lookup_cb = g_hash_table_new_full(g_direct_hash,
51 g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ 50 g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */
52 session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, 51 session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash,
53 g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, 52 g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are,
54 they could be integers inside gpointers 53 they could be integers inside gpointers
55 or strings, so I don't freed them. 54 or strings, so I don't freed them.
56 Figure this out, once free cache. */ 55 Figure this out, once free cache. */
57 56
63 session->rxbuf = g_new0(gchar, session->rxsize); 62 session->rxbuf = g_new0(gchar, session->rxsize);
64 session->next_rid = 1; 63 session->next_rid = 1;
65 session->last_comm = time(NULL); 64 session->last_comm = time(NULL);
66 session->inbox_status = 0; 65 session->inbox_status = 0;
67 session->inbox_handle = 0; 66 session->inbox_handle = 0;
68 67
69 return session; 68 return session;
70 } 69 }
71 70
72 /** 71 /**
73 * Free a session. 72 * Free a session.
74 * 73 *
75 * @param session The session to destroy. 74 * @param session The session to destroy.
76 */ 75 */
77 void 76 void
78 msim_session_destroy(MsimSession *session) 77 msim_session_destroy(MsimSession *session)
79 { 78 {
80 g_return_if_fail(MSIM_SESSION_VALID(session)); 79 g_return_if_fail(MSIM_SESSION_VALID(session));
81 80
82 session->magic = -1; 81 session->magic = -1;
83 82
84 g_free(session->rxbuf); 83 g_free(session->rxbuf);
85 g_free(session->username); 84 g_free(session->username);
86 85
89 g_hash_table_destroy(session->user_lookup_cb_data); 88 g_hash_table_destroy(session->user_lookup_cb_data);
90 89
91 if (session->server_info) { 90 if (session->server_info) {
92 msim_msg_free(session->server_info); 91 msim_msg_free(session->server_info);
93 } 92 }
94 93
95 /* Stop checking the inbox at the end of the session. */ 94 /* Stop checking the inbox at the end of the session. */
96 if (session->inbox_handle) { 95 if (session->inbox_handle) {
97 purple_timeout_remove(session->inbox_handle); 96 purple_timeout_remove(session->inbox_handle);
98 } 97 }
99 98
100 g_free(session); 99 g_free(session);
101 } 100 }
102

mercurial