Mercurial > pidgin
annotate src/protocols/msn/session.h @ 8436:4bb3d8dc717e
[gaim-migrate @ 9166]
" If getaddrinfo() is used, the addrlen and addr returned
through that function are written through the pipe to
the child Gaim processes. getaddrinfo() sets the
addrlen and addr fields through the following
structure, defined in <netdb.h>:
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
size_t ai_addrlen;
char *ai_canonname;
struct sockaddr *ai_addr;
struct addrinfo *ai_next;
};
This is from FreeBSD/amd64 5.2.1-RELEASE. This
structure is defined differently on different systems.
Take, for example, this OpenBSD/i386 3.5-beta system:
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
socklen_t ai_addrlen;
struct sockaddr *ai_addr;
char *ai_canonname;
struct addrinfo *ai_next;
};
After being read, the addrlen and addr of each host is
written through the descriptor:
src/proxy.c:
466 rc =
getaddrinfo(dns_params.hostname, servname, &hints, &res);
...
478 while(res) {
479
write(child_out[1], &(res->ai_addrlen),
sizeof(res->ai_addrlen));
480
write(child_out[1], res->ai_addr, res->ai_addrlen);
481 res =
res->ai_next;
482 }
And later subsequently read:
286 rc=read(req->fd_out,
&addrlen, sizeof(addrlen));
287 if(rc>0 && addrlen > 0) {
288
addr=g_malloc(addrlen);
289
rc=read(req->fd_out, addr, addrlen);
So hence, the type of addrlen that is used in
host_resolved() must match that of the addrlen used in
the addrinfo structure, or they must at least be
guarenteed to be the same size." --jarady
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Fri, 12 Mar 2004 16:59:22 +0000 |
| parents | c719f9a181d4 |
| children | 06f57183e29f |
| rev | line source |
|---|---|
| 5309 | 1 /** |
| 2 * @file session.h MSN session functions | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
| 6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
7 * |
| 5309 | 8 * This program is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 */ | |
| 22 #ifndef _MSN_SESSION_H_ | |
| 23 #define _MSN_SESSION_H_ | |
| 24 | |
| 25 typedef struct _MsnSession MsnSession; | |
| 26 | |
|
8171
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7631
diff
changeset
|
27 #include "group.h" |
|
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7631
diff
changeset
|
28 #include "nexus.h" |
|
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7631
diff
changeset
|
29 #include "servconn.h" |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
30 #include "sslconn.h" |
| 5309 | 31 #include "switchboard.h" |
| 32 #include "user.h" | |
|
8171
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7631
diff
changeset
|
33 |
| 5309 | 34 |
| 35 struct _MsnSession | |
| 36 { | |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
37 GaimAccount *account; |
|
5363
ebebc833cf77
[gaim-migrate @ 5739]
Christian Hammond <chipx86@chipx86.com>
parents:
5327
diff
changeset
|
38 MsnUser *user; |
|
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
39 char *away_state; |
| 5309 | 40 |
| 7631 | 41 guint protocol_ver; |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
42 |
| 5309 | 43 char *dispatch_server; |
| 44 int dispatch_port; | |
| 45 | |
| 46 gboolean connected; | |
| 47 | |
| 48 MsnServConn *dispatch_conn; | |
| 49 MsnServConn *notification_conn; | |
| 50 | |
|
8171
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7631
diff
changeset
|
51 MsnNexus *nexus; |
|
d0ba2f7b40e7
[gaim-migrate @ 8884]
Christian Hammond <chipx86@chipx86.com>
parents:
7631
diff
changeset
|
52 |
| 5309 | 53 unsigned int trId; |
| 54 | |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
55 gboolean http_method; |
|
8298
c719f9a181d4
[gaim-migrate @ 9022]
Christian Hammond <chipx86@chipx86.com>
parents:
8171
diff
changeset
|
56 gint http_poll_timer; |
|
7288
ff9127038a5a
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
57 |
| 5309 | 58 MsnUsers *users; |
|
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
59 MsnGroups *groups; |
| 5309 | 60 |
|
5898
5baeb89ee2d4
[gaim-migrate @ 6330]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
61 GList *servconns; |
| 5309 | 62 GList *switches; |
| 63 | |
| 64 struct | |
| 65 { | |
| 66 GSList *forward; | |
| 67 GSList *reverse; | |
| 68 GSList *allow; | |
| 69 GSList *block; | |
| 70 | |
| 71 } lists; | |
| 72 | |
| 73 struct | |
| 74 { | |
| 75 char *kv; | |
| 76 char *sid; | |
| 77 char *mspauth; | |
| 78 unsigned long sl; | |
| 79 char *file; | |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
80 char *client_ip; |
|
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
81 int client_port; |
| 5309 | 82 |
| 83 } passport_info; | |
| 84 | |
|
5322
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
85 /* You have no idea how much I hate all that is below. */ |
| 5309 | 86 GaimPlugin *prpl; |
|
5322
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
87 |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
88 /* For MSNP8 and MSNP9. */ |
|
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
89 int num_users; |
|
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
90 int total_users; |
|
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
91 int num_groups; |
|
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
92 int total_groups; |
|
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
93 MsnUser *last_user_added; |
|
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
94 |
|
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5898
diff
changeset
|
95 /* For MSNP7 and lower. */ |
|
5456
40e976d42028
[gaim-migrate @ 5844]
Christian Hammond <chipx86@chipx86.com>
parents:
5406
diff
changeset
|
96 gboolean syncing_lists; |
|
5406
9acf4832c0dc
[gaim-migrate @ 5782]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
97 gboolean lists_synced; |
|
9acf4832c0dc
[gaim-migrate @ 5782]
Christian Hammond <chipx86@chipx86.com>
parents:
5363
diff
changeset
|
98 |
|
5322
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
99 /* For moving buddies from one group to another. Ugh. */ |
|
a4d017bee1de
[gaim-migrate @ 5694]
Christian Hammond <chipx86@chipx86.com>
parents:
5318
diff
changeset
|
100 gboolean moving_buddy; |
|
5327
b716ffc25d2d
[gaim-migrate @ 5700]
Christian Hammond <chipx86@chipx86.com>
parents:
5322
diff
changeset
|
101 char *dest_group_name; |
|
5518
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
102 MsnUser *moving_user; |
|
bf2a7a7b739d
[gaim-migrate @ 5918]
Christian Hammond <chipx86@chipx86.com>
parents:
5456
diff
changeset
|
103 MsnGroup *old_group; |
| 5309 | 104 }; |
| 105 | |
| 106 /** | |
| 107 * Creates an MSN session. | |
| 108 * | |
| 109 * @param account The account. | |
| 110 * @param server The dispatch server. | |
| 111 * @param port The dispatch port. | |
| 112 * | |
| 113 * @return The new MSN session. | |
| 114 */ | |
|
5564
187c740f2a4e
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5518
diff
changeset
|
115 MsnSession *msn_session_new(GaimAccount *account, |
| 5309 | 116 const char *server, int port); |
| 117 | |
| 118 /** | |
| 119 * Destroys an MSN session. | |
| 120 * | |
| 121 * @param session The MSN session to destroy. | |
| 122 */ | |
| 123 void msn_session_destroy(MsnSession *session); | |
| 124 | |
| 125 /** | |
| 126 * Connects to and initiates an MSN session. | |
| 127 * | |
| 128 * @param session The MSN session. | |
| 129 * | |
| 130 * @return @c TRUE on success, @c FALSE on failure. | |
| 131 */ | |
| 132 gboolean msn_session_connect(MsnSession *session); | |
| 133 | |
| 134 /** | |
| 135 * Disconnects from an MSN session. | |
| 136 * | |
| 137 * @param session The MSN session. | |
| 138 */ | |
| 139 void msn_session_disconnect(MsnSession *session); | |
| 140 | |
| 141 /** | |
| 142 * Opens a new switchboard connection. | |
| 143 * | |
| 144 * @param session The MSN session. | |
| 145 * | |
| 146 * @return The new switchboard connection. | |
| 147 */ | |
| 148 MsnSwitchBoard *msn_session_open_switchboard(MsnSession *session); | |
| 149 | |
| 150 /** | |
|
7590
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
151 * Changes the status of the user. |
|
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
152 * |
|
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
153 * @param session The MSN session. |
|
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
154 * @param state The new state. |
|
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
155 */ |
|
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
156 gboolean msn_session_change_status(MsnSession *session, const char *state); |
|
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
157 |
|
3a48ade4f510
[gaim-migrate @ 8208]
Christian Hammond <chipx86@chipx86.com>
parents:
7288
diff
changeset
|
158 /** |
| 5309 | 159 * Finds a switch with the given passport. |
| 160 * | |
| 161 * @param session The MSN session. | |
| 162 * @param passport The passport to search for. | |
| 163 * | |
| 164 * @return The switchboard, if found. | |
| 165 */ | |
| 166 MsnSwitchBoard *msn_session_find_switch_with_passport( | |
| 167 const MsnSession *session, const char *passport); | |
| 168 | |
| 169 /** | |
| 170 * Finds a switchboard with the given chat ID. | |
| 171 * | |
| 172 * @param session The MSN session. | |
| 173 * @param chat_id The chat ID to search for. | |
| 174 * | |
| 175 * @return The switchboard, if found. | |
| 176 */ | |
| 177 MsnSwitchBoard *msn_session_find_switch_with_id(const MsnSession *session, | |
| 178 int chat_id); | |
| 179 | |
| 180 /** | |
| 181 * Finds the first unused switchboard. | |
| 182 * | |
| 183 * @param session The MSN session. | |
| 184 * | |
| 185 * @return The first unused, writable switchboard, if found. | |
| 186 */ | |
| 187 MsnSwitchBoard *msn_session_find_unused_switch(const MsnSession *session); | |
| 188 | |
| 189 #endif /* _MSN_SESSION_H_ */ |
