Sat, 08 Sep 2007 03:09:35 +0000
The FSF changed its address a while ago; our files were out of date.
This is a quick update done with a for loop, find, and sed.
|
19617
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
1 | /* MySpaceIM Protocol Plugin, session |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
2 | * |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
3 | * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
4 | * |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
9 | * |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
14 | * |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
16 | * along with this program; if not, write to the Free Software |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19617
diff
changeset
|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
19617
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
18 | */ |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
19 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
20 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
21 | #include "myspace.h" |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
22 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
23 | /* Session methods */ |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
24 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
25 | /** |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
26 | * Create a new MSIM session. |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
27 | * |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
28 | * @param acct The account to create the session from. |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
29 | * |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
30 | * @return Pointer to a new session. Free with msim_session_destroy. |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
31 | */ |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
32 | MsimSession * |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
33 | msim_session_new(PurpleAccount *acct) |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
34 | { |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
35 | MsimSession *session; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
36 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
37 | g_return_val_if_fail(acct != NULL, NULL); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
38 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
39 | session = g_new0(MsimSession, 1); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
40 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
41 | session->magic = MSIM_SESSION_STRUCT_MAGIC; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
42 | session->account = acct; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
43 | session->gc = purple_account_get_connection(acct); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
44 | session->sesskey = 0; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
45 | session->userid = 0; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
46 | session->username = NULL; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
47 | session->fd = -1; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
48 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
49 | /* TODO: Remove. */ |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
50 | session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
51 | g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
52 | session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
53 | g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
54 | they could be integers inside gpointers |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
55 | or strings, so I don't freed them. |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
56 | Figure this out, once free cache. */ |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
57 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
58 | /* Created in msim_process_server_info() */ |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
59 | session->server_info = NULL; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
60 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
61 | session->rxoff = 0; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
62 | session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
63 | session->next_rid = 1; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
64 | session->last_comm = time(NULL); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
65 | session->inbox_status = 0; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
66 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
67 | return session; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
68 | } |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
69 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
70 | /** |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
71 | * Free a session. |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
72 | * |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
73 | * @param session The session to destroy. |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
74 | */ |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
75 | void |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
76 | msim_session_destroy(MsimSession *session) |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
77 | { |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
78 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
79 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
80 | session->magic = -1; |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
81 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
82 | g_free(session->rxbuf); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
83 | g_free(session->username); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
84 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
85 | /* TODO: Remove. */ |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
86 | g_hash_table_destroy(session->user_lookup_cb); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
87 | g_hash_table_destroy(session->user_lookup_cb_data); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
88 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
89 | if (session->server_info) { |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
90 | msim_msg_free(session->server_info); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
91 | } |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
92 | |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
93 | g_free(session); |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
94 | } |
|
c2da44d56312
In msimprpl, move session-related functions to a new session module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
95 |