Mercurial > pidgin.yaz
comparison libpurple/protocols/myspace/session.c @ 19433:9a1b28a10c95
In msimprpl, move session-related functions to a new session module.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sun, 26 Aug 2007 06:36:56 +0000 |
parents | |
children | 44b4e8bd759b 36ba89a2b7da |
comparison
equal
deleted
inserted
replaced
19432:210f792efd7c | 19433:9a1b28a10c95 |
---|---|
1 /* MySpaceIM Protocol Plugin, session | |
2 * | |
3 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> | |
4 * | |
5 * This program is free software; you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation; either version 2 of the License, or | |
8 * (at your option) any later version. | |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 */ | |
19 | |
20 | |
21 #include "myspace.h" | |
22 | |
23 /* Session methods */ | |
24 | |
25 /** | |
26 * Create a new MSIM session. | |
27 * | |
28 * @param acct The account to create the session from. | |
29 * | |
30 * @return Pointer to a new session. Free with msim_session_destroy. | |
31 */ | |
32 MsimSession * | |
33 msim_session_new(PurpleAccount *acct) | |
34 { | |
35 MsimSession *session; | |
36 | |
37 g_return_val_if_fail(acct != NULL, NULL); | |
38 | |
39 session = g_new0(MsimSession, 1); | |
40 | |
41 session->magic = MSIM_SESSION_STRUCT_MAGIC; | |
42 session->account = acct; | |
43 session->gc = purple_account_get_connection(acct); | |
44 session->sesskey = 0; | |
45 session->userid = 0; | |
46 session->username = NULL; | |
47 session->fd = -1; | |
48 | |
49 /* TODO: Remove. */ | |
50 session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, | |
51 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, | |
53 g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, | |
54 they could be integers inside gpointers | |
55 or strings, so I don't freed them. | |
56 Figure this out, once free cache. */ | |
57 | |
58 /* Created in msim_process_server_info() */ | |
59 session->server_info = NULL; | |
60 | |
61 session->rxoff = 0; | |
62 session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); | |
63 session->next_rid = 1; | |
64 session->last_comm = time(NULL); | |
65 session->inbox_status = 0; | |
66 | |
67 return session; | |
68 } | |
69 | |
70 /** | |
71 * Free a session. | |
72 * | |
73 * @param session The session to destroy. | |
74 */ | |
75 void | |
76 msim_session_destroy(MsimSession *session) | |
77 { | |
78 g_return_if_fail(MSIM_SESSION_VALID(session)); | |
79 | |
80 session->magic = -1; | |
81 | |
82 g_free(session->rxbuf); | |
83 g_free(session->username); | |
84 | |
85 /* TODO: Remove. */ | |
86 g_hash_table_destroy(session->user_lookup_cb); | |
87 g_hash_table_destroy(session->user_lookup_cb_data); | |
88 | |
89 if (session->server_info) { | |
90 msim_msg_free(session->server_info); | |
91 } | |
92 | |
93 g_free(session); | |
94 } | |
95 |